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AAA,SAAyBsC,EAAa,CACpC/B,EAAS+B,EAAM,OAAQ,CAAC,CAACI,GAAS,SAAS,CAAC,CAAC,EAC7C,KAAK,kBAAkBJ,CAAI,CAC7B,EAqBAtC,EAAA,UAAA,kBAAA,SACEsC,EACAK,EAA2C,CAE3CpC,EAAS+B,EAAM,OAAQ,CAAC,CAACI,GAAS,SAAS,CAAC,CAAC,EAC7CpB,EAAkBqB,EAAU,WAAY,CAAC,QAAQ,CAAC,EAGlD,QADM/B,EAAU,KAAK,UAAU,WAAU,EAChCC,EAAM,EAAGC,EAAMF,EAAQ,OAAQC,EAAMC,EAAKD,IAAO,CACxD,IAAME,EAASH,EAAQC,CAAG,EAC1B,KAAK,uBAAuBE,EAAQuB,EAAMK,CAAQ,EAEtD,EAEQ3C,EAAA,UAAA,uBAAR,SACEe,EACAuB,EACAK,EAA2C,CAE3C,IAAMC,EAAaD,GAAYE,GACzBC,EAAcC,GAAoBH,EAAW,KAAM7B,EAAQuB,CAAI,CAAC,EACtE,KAAK,+BAA+BvB,EAAQuB,EAAMQ,CAAW,CAC/D,EA3NO9C,EAAA,GAAK,SACVG,EACAC,EACAC,EAAgB,CACb,OAAA,IAAIL,EAAUG,EAAgBC,EAAKC,CAAG,CAAtC,EAwNPL,GAxOuCgD,EAAQ,KAA1BhD","names":["chars","lookup","i","encodeToBase64","bytes","base64","len","decodeFromBase64","bufferLength","p","encoded1","encoded2","encoded3","encoded4","DATA_URI_PREFIX_REGEX","decodeFromBase64DataUri","dataUri","trimmedUri","prefix","res","fullMatch","data","toCharCode","character","toCodePoint","toHexStringOfMinLength","num","minLength","padStart","toHexString","charFromCode","code","charFromHexCode","hex","value","length","padChar","padding","idx","len","copyStringIntoBuffer","str","buffer","offset","addRandomSuffix","prefix","suffixLength","escapeRegExp","cleanText","text","escapedNewlineChars","newlineChars","isNewlineChar","lineSplit","mergeLines","charAtIndex","index","cuFirst","cuSecond","nextIndex","charSplit","chars","_a","c","cLen","buildWordBreakRegex","wordBreaks","newlineCharUnion","escapedRules","wordBreak","breakRules","breakTextIntoLines","maxWidth","computeWidthOfText","regex","words","currLine","currWidth","lines","pushCurrLine","word","width","dateRegex","parseDate","dateStr","match","year","month","_b","day","_c","hours","_d","mins","_e","secs","_f","offsetSign","_g","offsetHours","_h","offsetMins","tzOffset","date","findLastMatch","position","lastMatch","last","array","typedArrayFor","value","length","typedArray","idx","mergeIntoTypedArray","arrays","_i","arrayCount","typedArrays","element","totalSize","merged","offset","arrIdx","arr","byteIdx","arrLen","mergeUint8Arrays","len","mergedBuffer","arrayAsString","str","charFromCode","byAscendingId","a","b","sortedUniq","indexer","uniq","curr","prev","reverseArray","arrayLen","leftIdx","rightIdx","temp","sum","total","range","start","end","pluckIndices","indices","plucked","canBeConvertedToUint8Array","input","toUint8Array","decodeFromBase64DataUri","waitForTick","resolve","utf8Encode","input","byteOrderMark","encoded","idx","len","codePoint","byte1","byte2","byte3","byte4","toHexString","utf16Encode","highSurrogate","lowSurrogate","isWithinBMP","hasSurrogates","ByteOrder","REPLACEMENT","utf16Decode","byteOrder","readBOM","codePoints","first","decodeValues","isHighSurrogate","second","isLowSurrogate","bytes","hasUtf16BigEndianBOM","hasUtf16LittleEndianBOM","hasUtf16BOM","numberToString","num","numStr","negative","sizeInBytes","n","bytesFor","bytes","i","error","msg","FontNames","values","obj","k","StandardFontValues","isStandardFont","input","rectanglesAreEqual","a","b","backtick","val","singleQuote","formatValue","value","type","createValueErrorMsg","valueName","values","allowedValues","idx","len","v","joinedValues","assertIsOneOf","assertIsOneOfOrUndefined","assertIsSubset","getType","isType","createTypeErrorMsg","types","allowedTypes","joinedTypes","assertIs","assertOrUndefined","assertEachIs","assertRange","min","max","assertRangeOrUndefined","assertMultiple","multiplier","assertInteger","assertPositive","pdfDocEncodingToUnicode","idx","toCharCode","pdfDocEncodingDecode","bytes","codePoints","len","Cache","populate","Cache_default","MethodNotImplementedError","_super","__extends","className","methodName","_this","msg","PrivateConstructorError","_super","__extends","className","_this","msg","UnexpectedObjectTypeError","_super","__extends","expected","actual","_this","name","t","_a","_b","expectedTypes","msg","UnsupportedEncodingError","_super","__extends","encoding","_this","msg","ReparseError","_super","__extends","className","methodName","_this","msg","MissingCatalogError","_super","__extends","ref","_this","msg","MissingPageContentsEmbeddingError","_super","__extends","_this","msg","UnrecognizedStreamTypeError","_super","__extends","stream","_this","streamType","_c","_b","_a","msg","PageEmbeddingMismatchedContextError","_super","__extends","_this","msg","PDFArrayIsNotRectangleError","_super","__extends","size","_this","msg","InvalidPDFDateStringError","_super","__extends","value","_this","msg","InvalidTargetIndexError","_super","__extends","targetIndex","Count","_this","msg","CorruptPageTreeError","_super","__extends","targetIndex","operation","_this","msg","IndexOutOfBoundsError","_super","__extends","index","min","max","_this","msg","InvalidAcroFieldValueError","_super","__extends","_this","msg","MultiSelectValueError","_super","__extends","_this","msg","MissingDAEntryError","_super","__extends","fieldName","_this","msg","MissingTfOperatorError","_super","__extends","fieldName","_this","msg","NumberParsingError","_super","__extends","pos","value","_this","msg","PDFParsingError","_super","__extends","pos","details","_this","msg","NextByteAssertionError","_super","__extends","pos","expectedByte","actualByte","_this","msg","PDFParsingError","PDFObjectParsingError","_super","__extends","pos","byte","_this","msg","PDFParsingError","PDFInvalidObjectParsingError","_super","__extends","pos","_this","msg","PDFParsingError","PDFStreamParsingError","_super","__extends","pos","_this","msg","PDFParsingError","UnbalancedParenthesisError","_super","__extends","pos","_this","msg","PDFParsingError","StalledParserError","_super","__extends","pos","_this","msg","PDFParsingError","MissingPDFHeaderError","_super","__extends","pos","_this","msg","PDFParsingError","MissingKeywordError","_super","__extends","pos","keyword","_this","msg","arrayAsString","PDFParsingError","CharCodes","CharCodes_default","pako","PDFHeader","major","minor","bc","charFromCode","buffer","offset","initialOffset","CharCodes_default","copyStringIntoBuffer","PDFHeader_default","PDFObject","_context","MethodNotImplementedError","_buffer","_offset","PDFObject_default","PDFNumber","_super","__extends","value","_this","numberToString","buffer","offset","copyStringIntoBuffer","PDFObject_default","PDFNumber_default","PDFArray","_super","__extends","context","_this","object","index","idx","types","_i","_a","__spreadArrays","PDFArrayIsNotRectangleError","lowerLeftX","PDFNumber_default","lowerLeftY","upperRightX","upperRightY","x","y","width","height","clone","len","arrayString","size","buffer","offset","initialOffset","CharCodes_default","el","factor","PDFObject_default","PDFArray_default","ENFORCER","PDFBool","_super","__extends","enforcer","value","_this","PrivateConstructorError","buffer","offset","CharCodes_default","PDFObject_default","PDFBool_default","IsDelimiter","CharCodes_default","IsWhitespace","CharCodes_default","IsIrregular","idx","len","IsWhitespace","IsDelimiter","CharCodes_default","decodeName","name","_","hex","charFromHexCode","isRegularChar","charCode","CharCodes_default","IsIrregular","ENFORCER","pool","PDFName","_super","__extends","enforcer","_this","PrivateConstructorError","encodedName","idx","len","character","code","toCharCode","toHexString","bytes","escaped","pushByte","byte","char","nextChar","buffer","offset","copyStringIntoBuffer","decodedValue","instance","PDFObject_default","PDFName_default","PDFNull","_super","__extends","buffer","offset","CharCodes_default","PDFObject_default","PDFNull_default","PDFDict","_super","__extends","map","context","_this","key","value","preservePDFNull","PDFNull_default","types","_i","_a","__spreadArrays","tag","existingKeys","PDFName_default","clone","entries","idx","len","dictString","size","buffer","offset","initialOffset","CharCodes_default","PDFObject_default","PDFDict_default","PDFStream","_super","__extends","dict","_this","_context","MethodNotImplementedError","contentsSize","PDFName_default","PDFNumber_default","streamString","buffer","offset","initialOffset","CharCodes_default","contents","idx","len","PDFObject_default","PDFStream_default","PDFRawStream","_super","__extends","dict","contents","_this","context","arrayAsString","PDFStream_default","PDFRawStream_default","ENFORCER","pool","PDFRef","_super","__extends","enforcer","objectNumber","generationNumber","_this","PrivateConstructorError","buffer","offset","copyStringIntoBuffer","tag","instance","PDFObject_default","PDFRef_default","PDFOperator","name","args","context","idx","len","arg","PDFObject_default","value","size","buffer","offset","initialOffset","copyStringIntoBuffer","CharCodes_default","PDFOperator_default","PDFOperatorNames","PDFOperatorNames_default","pako","PDFFlateStream","_super","__extends","dict","encode","_this","unencodedContents","pako","PDFName_default","Cache_default","MethodNotImplementedError","PDFStream_default","PDFFlateStream_default","PDFContentStream","_super","__extends","dict","operators","encode","_this","_i","_a","context","idx","len","value","buffer","offset","CharCodes_default","size","PDFFlateStream_default","PDFContentStream_default","SimpleRNG","seed","x","byAscendingObjectNumber","_a","_b","a","b","PDFContext","PDFHeader_default","SimpleRNG","ref","object","PDFRef_default","types","_i","preservePDFNull","PDFNull_default","result","idx","len","type","UnexpectedObjectTypeError","pdfObject","entries","literal","PDFObject_default","PDFName_default","PDFNumber_default","PDFBool_default","array","PDFArray_default","dict","PDFDict_default","keys","key","value","contents","PDFRawStream_default","typedArrayFor","pako","__assign","operators","PDFContentStream_default","op","PDFOperator_default","PDFOperatorNames_default","stream","prefix","suffixLength","PDFContext_default","PDFPageLeaf","_super","__extends","map","context","autoNormalizeCTM","_this","clone","entries","idx","len","_a","key","value","PDFName_default","PDFDict_default","PDFArray_default","dictOrRef","arrayOrRef","numberOrRef","PDFNumber_default","name","attribute","node","parentRef","contentStreamRef","Contents","startStream","endStream","annotRef","Annots","index","fontDictRef","Font","tag","xObjectRef","XObject","extGStateRef","ExtGState","visitor","Parent","contentsRef","contents","PDFStream_default","Resources","parent","dict","PDFPageLeaf_default","PDFObjectCopier","src","dest","_this","object","PDFPageLeaf_default","PDFDict_default","PDFArray_default","PDFStream_default","PDFRef_default","originalPage","clonedPage","InheritableEntries","idx","len","key","PDFName_default","value","originalDict","clonedDict","entries","_a","originalArray","clonedArray","originalStream","clonedStream","ref","alreadyMapped","newRef","dereferencedValue","cloned","PDFObjectCopier_default","PDFCrossRefSection","firstEntry","ref","offset","nextFreeObjectNumber","section","rangeIdx","rangeLen","range","entryIdx","entryLen","entry","padStart","size","idx","len","subsection","subsectionLength","buffer","initialOffset","CharCodes_default","subsections","length","firstObjectNumber","copyStringIntoBuffer","rangeLength","entries","entryOffset","entryGen","currEntry","chunk","prevEntry","PDFRef_default","PDFCrossRefSection_default","PDFTrailer","lastXRefOffset","buffer","offset","initialOffset","CharCodes_default","copyStringIntoBuffer","PDFTrailer_default","PDFTrailerDict","dict","buffer","offset","initialOffset","CharCodes_default","PDFTrailerDict_default","PDFObjectStream","_super","__extends","context","objects","encode","_this","PDFName_default","PDFNumber_default","value","idx","len","_a","object","buffer","offset","copyStringIntoBuffer","CharCodes_default","last","offsetsString","objectNumber","offsets","ref","PDFFlateStream_default","PDFObjectStream_default","PDFWriter","context","objectsPerTick","_this","_a","_c","size","header","indirectObjects","xref","trailerDict","trailer","offset","buffer","CharCodes_default","idx","len","_b","ref","object","objectNumber","copyStringIntoBuffer","generationNumber","n","PDFObjectStream_default","waitForTick","refSize","objectSize","PDFHeader_default","PDFCrossRefSection_default","indirectObject","xrefOffset","PDFTrailerDict_default","PDFTrailer_default","PDFWriter_default","PDFInvalidObject","_super","__extends","data","_this","buffer","offset","length","idx","PDFObject_default","PDFInvalidObject_default","EntryType","PDFCrossRefStream","_super","__extends","dict","entries","encode","_this","subsections","subsectionLength","idx","len","currEntry","prevEntry","entryTuples","entry","type","nextFreeObjectNumber","ref","offset","objectStreamRef","index","widths","_a","first","second","third","firstSize","sizeInBytes","secondSize","thirdSize","Cache_default","PDFName_default","context","byteWidths","value","entryIdx","entriesLen","firstBytes","reverseArray","bytesFor","secondBytes","thirdBytes","buffer","entryWidth","sum","stream","PDFRef_default","PDFFlateStream_default","PDFCrossRefStream_default","PDFStreamWriter","_super","__extends","context","objectsPerTick","encodeStreams","objectsPerStream","_this","objectNumber","header","PDFHeader_default","size","xrefStream","PDFCrossRefStream_default","uncompressedObjects","compressedObjects","objectStreamRefs","indirectObjects","idx","len","indirectObject","ref","object","shouldNotCompress","PDFStream_default","PDFInvalidObject_default","waitForTick","_a","chunk","last","objectStreamRef","PDFRef_default","objectStream","PDFObjectStream_default","xrefStreamRef","PDFName_default","PDFNumber_default","xrefOffset","trailer","PDFTrailer_default","PDFWriter_default","PDFStreamWriter_default","Encodings","Font","FontNames","PDFHexString","_super","__extends","value","_this","hex","hexLength","bytes","hexOffset","bytesOffset","byte","hasUtf16BOM","utf16Decode","pdfDocEncodingDecode","text","date","parseDate","InvalidPDFDateStringError","buffer","offset","CharCodes_default","copyStringIntoBuffer","encoded","utf16Encode","idx","len","toHexStringOfMinLength","PDFObject_default","PDFHexString_default","StandardFontEmbedder","fontName","customName","FontNames","Encodings","Font","text","glyphs","hexCodes","idx","len","toHexString","PDFHexString_default","size","totalWidth","left","right","kernAmount","scale","options","_a","descender","_b","Ascender","Descender","FontBBox","yTop","yBottom","height","context","ref","fontDict","glyphName","codePoints","codePoint","toCodePoint","StandardFontEmbedder_default","createCmap","glyphs","glyphId","bfChars","idx","len","glyph","id","cmapHexFormat","cmapHexString","unicode","cmapCodePointFormat","fillCmapTemplate","_a","codePoint","values","_i","value","toHexStringOfMinLength","isWithinBMP","hasSurrogates","hs","highSurrogate","ls","lowSurrogate","hex","toHexString","msg","makeFontFlags","options","flags","flipBit","bit","deriveFontFlags","font","familyClass","PDFString","_super","__extends","value","_this","bytes","octal","escaped","pushByte","byte","idx","len","char","toCharCode","nextChar","CharCodes_default","hasUtf16BOM","utf16Decode","pdfDocEncodingDecode","text","date","parseDate","InvalidPDFDateStringError","buffer","offset","copyStringIntoBuffer","year","padStart","month","day","hours","mins","secs","PDFObject_default","PDFString_default","CustomFontEmbedder","font","fontData","customName","fontFeatures","_this","glyphs","idx","len","codePoint","sortedUniq","byAscendingId","g","Cache_default","fontkit","_a","text","hexCodes","toHexStringOfMinLength","PDFHexString_default","size","totalWidth","scale","options","descender","_b","ascent","descent","bbox","yTop","yBottom","height","context","ref","cidFontDictRef","unicodeCMapRef","fontDict","fontDescriptorRef","cidFontDict","PDFString_default","fontStreamRef","_d","italicAngle","capHeight","xHeight","minX","minY","maxX","maxY","fontDescriptor","_c","deriveFontFlags","fontStream","cmap","createCmap","cmapStream","glyph","widths","currSection","currGlyph","prevGlyph","currGlyphId","prevGlyphId","CustomFontEmbedder_default","CustomFontSubsetEmbedder","_super","__extends","font","fontData","customFontName","fontFeatures","_this","Cache_default","fontkit","_a","text","glyphs","hexCodes","idx","len","glyph","subsetGlyphId","toHexStringOfMinLength","PDFHexString_default","resolve","reject","parts","bytes","mergeUint8Arrays","err","CustomFontEmbedder_default","CustomFontSubsetEmbedder_default","AFRelationship","FileEmbedder","fileData","fileName","options","bytes","context","ref","_a","mimeType","description","creationDate","modificationDate","afRelationship","embeddedFileStream","PDFString_default","embeddedFileStreamRef","fileSpecDict","PDFHexString_default","FileEmbedder_default","MARKERS","ColorSpace","ChannelToColorSpace","JpegEmbedder","imageData","bitsPerComponent","width","height","colorSpace","dataView","soi","pos","marker","channelByte","channelName","context","ref","xObject","JpegEmbedder_default","UPNG","getImageType","ctype","PngType","splitAlphaChannel","rgbaChannel","pixelCount","rgbChannel","alphaChannel","rgbaOffset","rgbOffset","alphaOffset","PNG","pngData","upng","frames","frame","_a","hasAlphaValues","a","PngEmbedder","png","imageData","PNG","context","ref","SMask","xObject","PngEmbedder_default","Stream","buffer","start","length","b0","b1","b2","b3","forceClamped","bytes","pos","strEnd","end","subarray","peekedByte","n","Stream_default","emptyBuffer","DecodeStream","maybeMinBufferLength","pos","b0","b1","b2","b3","length","forceClamped","end","bufEnd","subarray","peekedByte","bytes","n","start","Stream_default","MethodNotImplementedError","requested","buffer","size","buffer2","DecodeStream_default","isSpace","ch","Ascii85Stream","_super","__extends","stream","maybeLength","_this","TILDA_CHAR","Z_LOWER_CHAR","EOF","c","bufferLength","buffer","i","input","t","DecodeStream_default","Ascii85Stream_default","AsciiHexStream","_super","__extends","stream","maybeLength","_this","UPSTREAM_BLOCK_SIZE","bytes","maxDecodeLength","buffer","bufferLength","firstDigit","i","ii","ch","digit","DecodeStream_default","AsciiHexStream_default","codeLenCodeMap","lengthDecode","distDecode","fixedLitCodeTab","fixedDistCodeTab","FlateStream","_super","__extends","stream","maybeLength","_this","cmf","flg","buffer","len","str","hdr","b","blockLen","check","bufferLength","end","n","litCodeTable","distCodeTable","numLitCodes","numDistCodes","numCodeLenCodes","codeLenCodeLengths","i","codeLenCodeTab","codes","codeLengths","bitsLength","bitsOffset","what","code","repeatLength","limit","pos","code1","code2","dist","k","bits","codeSize","codeBuf","table","maxLen","codeLen","codeVal","lengths","size","skip","val","t","DecodeStream_default","FlateStream_default","LZWStream","_super","__extends","stream","maybeLength","earlyChange","_this","maxLzwDictionarySize","lzwState","i","blockSize","estimatedDecodedSize","decodedSizeDelta","j","q","nextCode","dictionaryValues","dictionaryLengths","dictionaryPrevCodes","codeLength","prevCode","currentSequence","currentSequenceLength","decodedLength","currentBufferLength","buffer","code","hasPrev","n","bitsCached","cachedData","c","DecodeStream_default","LZWStream_default","RunLengthStream","_super","__extends","stream","maybeLength","_this","repeatHeader","buffer","bufferLength","n","source","b","i","DecodeStream_default","RunLengthStream_default","decodeStream","stream","encoding","params","PDFName_default","FlateStream_default","earlyChange","PDFDict_default","EarlyChange","PDFNumber_default","LZWStream_default","Ascii85Stream_default","AsciiHexStream_default","RunLengthStream_default","UnsupportedEncodingError","decodePDFRawStream","_a","dict","contents","Stream_default","Filter","DecodeParms","PDFArray_default","idx","len","UnexpectedObjectTypeError","fullPageBoundingBox","page","mediaBox","width","PDFNumber_default","height","boundingBoxAdjustedMatrix","bb","PDFPageEmbedder","boundingBox","transformationMatrix","context","ref","_a","Contents","Resources","MissingPageContentsEmbeddingError","decodedContents","_b","left","bottom","right","top","xObject","contents","newline","CharCodes_default","idx","len","stream","PDFStream_default","content","PDFRawStream_default","decodePDFRawStream","PDFContentStream_default","UnrecognizedStreamTypeError","mergeIntoTypedArray","PDFPageEmbedder_default","asEnum","rawValue","enumType","NonFullScreenPageMode","ReadingDirection","PrintScaling","Duplex","ViewerPreferences","dict","key","returnObj","PDFName_default","PDFBool_default","PrintPageRange","PDFArray_default","NumCopies","PDFNumber_default","_b","_a","mode","direction","scaling","duplex","rng","pageRanges","i","start","end","hideToolbar","HideToolbar","hideMenubar","HideMenubar","hideWindowUI","HideWindowUI","fitWindow","FitWindow","centerWindow","CenterWindow","displayTitle","DisplayDocTitle","nonFullScreenPageMode","assertIsOneOf","readingDirection","printScaling","dup","pickTrayByPDFSize","PickTrayByPDFSize","printPageRange","flatRange","idx","len","assertEachIs","numCopies","assertRange","assertInteger","context","ViewerPreferences_default","tfRegex","PDFAcroField","dict","ref","PDFName_default","PDFString_default","PDFHexString_default","numberOrRef","PDFNumber_default","valueOrRef","PDFArray_default","da","kids","parentRef","PDFRef_default","parent_1","PDFDict_default","parent","_a","partialName","appearance","DA","fontSize","name","MissingDAEntryError","daMatch","findLastMatch","MissingTfOperatorError","daStart","daEnd","fontName","modifiedDa","_b","flags","flag","enable","attribute","node","visitor","PDFAcroField_default","BorderStyle","dict","W","PDFName_default","PDFNumber_default","_b","_a","width","BorderStyle_default","PDFAnnotation","dict","PDFName_default","PDFArray_default","PDFDict_default","numberOrRef","PDFNumber_default","Rect","_a","rect","x","y","width","height","AS","state","appearances","AP","N","PDFRef_default","appearance","PDFStream_default","R","D","_b","flags","flag","enable","PDFAnnotation_default","AppearanceCharacteristics","dict","R","PDFName_default","PDFNumber_default","BC","PDFArray_default","BG","CA","PDFHexString_default","PDFString_default","RC","AC","_a","components","idx","len","component","rotation","color","captions","AppearanceCharacteristics_default","PDFWidgetAnnotation","_super","__extends","MK","PDFName_default","PDFDict_default","BS","da","PDFString_default","PDFHexString_default","P","PDFRef_default","page","appearance","DA","AppearanceCharacteristics_default","ac","BorderStyle_default","bs","normal","_a","keys","idx","len","key","dict","context","parent","PDFAnnotation_default","PDFWidgetAnnotation_default","PDFAcroTerminal","_super","__extends","nameOrRef","PDFName_default","kidDicts","PDFWidgetAnnotation_default","widgets","idx","len","dict","PDFDict_default","ref","Kids","IndexOutOfBoundsError","PDFAcroField_default","PDFAcroTerminal_default","PDFAcroButton","_super","__extends","PDFName_default","PDFString_default","PDFHexString_default","PDFArray_default","opt","values","idx","len","value","IndexOutOfBoundsError","exportValues","_a","Opt","widgets","widget","exportVal","_b","_d","_c","useExistingOptIdx","optText","existingIdx","optIdx","apStateValue","PDFAcroTerminal_default","PDFAcroButton_default","PDFAcroCheckBox","_super","__extends","value","onValue","_a","PDFName_default","InvalidAcroFieldValueError","widgets","idx","len","widget","state","v","dict","ref","context","PDFAcroButton_default","PDFAcroCheckBox_default","flag","bitIndex","AcroFieldFlags","AcroButtonFlags","AcroTextFlags","AcroChoiceFlags","PDFAcroChoice","_super","__extends","values","AcroChoiceFlags","InvalidAcroFieldValueError","PDFName_default","MultiSelectValueError","options","idx","len","val","o","indices","v","PDFString_default","PDFHexString_default","PDFArray_default","value","newOpt","_a","display","Opt","res","item","first","second","PDFAcroTerminal_default","PDFAcroChoice_default","PDFAcroComboBox","_super","__extends","dict","ref","context","AcroChoiceFlags","PDFAcroChoice_default","PDFAcroComboBox_default","PDFAcroNonTerminal","_super","__extends","field","Kids","PDFName_default","dict","ref","context","PDFAcroField_default","PDFAcroNonTerminal_default","PDFAcroSignature","_super","__extends","dict","ref","PDFAcroTerminal_default","PDFAcroSignature_default","PDFAcroText","_super","__extends","maxLen","PDFName_default","PDFNumber_default","q","maxLength","_a","quadding","value","v","PDFString_default","PDFHexString_default","dict","ref","context","PDFAcroTerminal_default","PDFAcroText_default","PDFAcroPushButton","_super","__extends","dict","ref","context","AcroButtonFlags","PDFAcroButton_default","PDFAcroPushButton_default","PDFAcroRadioButton","_super","__extends","value","onValues","PDFName_default","InvalidAcroFieldValueError","widgets","idx","len","widget","state","v","onValue","dict","ref","context","AcroButtonFlags","PDFAcroButton_default","PDFAcroRadioButton_default","PDFAcroListBox","_super","__extends","dict","ref","context","PDFAcroChoice_default","PDFAcroListBox_default","createPDFAcroFields","kidDicts","kids","idx","len","ref","dict","PDFRef_default","PDFDict_default","createPDFAcroField","isNonTerminal","isNonTerminalAcroField","PDFAcroNonTerminal_default","createPDFAcroTerminal","PDFName_default","PDFArray_default","kid","kidIsField","ftNameOrRef","getInheritableAttribute","type","createPDFAcroButton","createPDFAcroChoice","PDFAcroText_default","PDFAcroSignature_default","PDFAcroTerminal_default","ffNumberOrRef","ffNumber","PDFNumber_default","flags","_a","flagIsSet","AcroButtonFlags","PDFAcroPushButton_default","PDFAcroRadioButton_default","PDFAcroCheckBox_default","AcroChoiceFlags","PDFAcroComboBox_default","PDFAcroListBox_default","flag","startNode","name","attribute","ascend","node","visitor","Parent","PDFAcroForm","dict","fields","PDFName_default","PDFArray_default","Fields","idx","len","ref","PDFDict_default","createPDFAcroField","allFields","pushFields","field","fieldModel","PDFAcroNonTerminal_default","createPDFAcroFields","parent","index","context","PDFAcroForm_default","PDFCatalog","_super","__extends","PDFName_default","PDFDict_default","dict","PDFAcroForm_default","acroForm","acroFormRef","ViewerPreferences_default","viewerPrefs","viewerPrefsRef","leafRef","index","pagesRef","maybeParentRef","context","pages","map","PDFCatalog_default","PDFPageTree","_super","__extends","PDFName_default","PDFArray_default","PDFNumber_default","treeRef","Kids","leafRef","targetIndex","Count","InvalidTargetIndexError","leafsRemainingUntilTarget","idx","len","kidRef","kid","PDFPageLeaf_default","CorruptPageTreeError","prune","visitor","Parent","kidIdx","node","newCount","context","parent","dict","map","PDFDict_default","PDFPageTree_default","IsDigit","CharCodes_default","IsNumericPrefix","IsNumeric","idx","len","Newline","CharCodes_default","CarriageReturn","BaseParser","bytes","capNumbers","value","byte","IsDigit","charFromCode","numberValue","NumberParsingError","IsNumeric","msg","IsWhitespace","keyword","initialOffset","idx","len","BaseParser_default","ByteStream","bytes","offset","byte","CharCodes_default","expected","NextByteAssertionError","steps","start","end","rawStream","decodePDFRawStream","ByteStream_default","Space","CharCodes_default","CarriageReturn","Newline","stream","endstream","Keywords","__spreadArrays","PDFObjectParser","_super","__extends","byteStream","context","capNumbers","_this","Keywords","PDFBool_default","PDFNull_default","byte","CharCodes_default","IsNumeric","PDFObjectParsingError","firstNum","lookaheadStart","IsDigit","secondNum","PDFRef_default","PDFNumber_default","value","charFromCode","PDFHexString_default","nestingLvl","isEscaped","PDFString_default","UnbalancedParenthesisError","name","IsWhitespace","IsDelimiter","PDFName_default","pdfArray","PDFArray_default","element","dict","key","Type","PDFCatalog_default","PDFPageTree_default","PDFPageLeaf_default","PDFDict_default","startPos","start","end","Length","contents","PDFRawStream_default","PDFStreamParsingError","bytes","ByteStream_default","BaseParser_default","PDFObjectParser_default","PDFObjectStreamParser","_super","__extends","rawStream","shouldWaitForTick","_this","ByteStream_default","dict","PDFName_default","PDFNumber_default","ReparseError","offsetsAndObjectNumbers","idx","len","_a","objectNumber","offset","object","ref","PDFRef_default","waitForTick","_b","PDFObjectParser_default","PDFObjectStreamParser_default","PDFXRefStreamParser","rawStream","ByteStream_default","Size","PDFName_default","PDFNumber_default","Index","PDFArray_default","idx","len","firstObjectNumber","length_1","W","ReparseError","entries","_a","typeFieldWidth","offsetFieldWidth","genFieldWidth","subsectionIdx","subsectionLen","_b","length_2","objIdx","type","offset","generationNumber","objectNumber","entry","PDFRef_default","PDFXRefStreamParser_default","PDFParser","_super","__extends","pdfBytes","objectsPerTick","throwOnInvalidObject","capNumbers","_this","ByteStream_default","PDFContext_default","ReparseError","_a","offset","prevOffset","StalledParserError","PDFRef_default","isValidCatalog","obj","PDFDict_default","PDFName_default","catalog","indirectObjects","idx","len","ref","object","Keywords","major","CharCodes_default","minor","header","PDFHeader_default","MissingPDFHeaderError","objectNumber","generationNumber","MissingKeywordError","initialOffset","PDFRawStream_default","PDFObjectStreamParser_default","PDFXRefStreamParser_default","startPos","msg","start","failed","PDFInvalidObjectParsingError","end","PDFInvalidObject_default","IsDigit","waitForTick","xref","PDFCrossRefSection_default","firstInt","secondInt","byte","dict","context","PDFTrailer_default","isAlphaNumeric","PDFObjectParser_default","PDFParser_default","flag","bitIndex","AnnotationFlags","asPDFName","name","PDFName_default","asPDFNumber","num","PDFNumber_default","asNumber","RotationTypes","radians","radianAngle","assertIs","degrees","degreeAngle","Radians","Degrees","degreesToRadians","degree","radiansToDegrees","radian","toRadians","rotation","error","toDegrees","reduceRotation","quadrants","adjustDimsForRotation","dims","rotateRectangle","rectangle","borderWidth","x","y","w","h","r","b","clip","PDFOperator_default","PDFOperatorNames_default","clipEvenOdd","cos","sin","tan","concatTransformationMatrix","a","b","c","d","e","f","asPDFNumber","translate","xPos","yPos","scale","rotateRadians","angle","asNumber","rotateDegrees","degreesToRadians","skewRadians","xSkewAngle","ySkewAngle","skewDegrees","setDashPattern","dashArray","dashPhase","restoreDashPattern","LineCapStyle","setLineCap","style","LineJoinStyle","setLineJoin","setGraphicsState","state","asPDFName","pushGraphicsState","popGraphicsState","setLineWidth","width","appendBezierCurve","x1","y1","x2","y2","x3","y3","appendQuadraticCurve","closePath","moveTo","lineTo","rectangle","height","square","size","stroke","fill","fillAndStroke","endPath","nextLine","moveText","x","y","showText","text","beginText","endText","setFontAndSize","name","setCharacterSpacing","spacing","setWordSpacing","setCharacterSqueeze","squeeze","setLineHeight","lineHeight","setTextRise","rise","TextRenderingMode","setTextRenderingMode","mode","setTextMatrix","rotateAndSkewTextRadiansAndTranslate","rotationAngle","rotateAndSkewTextDegreesAndTranslate","drawObject","setFillingGrayscaleColor","gray","setStrokingGrayscaleColor","setFillingRgbColor","red","green","blue","setStrokingRgbColor","setFillingCmykColor","cyan","magenta","yellow","key","setStrokingCmykColor","beginMarkedContent","tag","endMarkedContent","ColorTypes","grayscale","gray","assertRange","rgb","red","green","blue","cmyk","cyan","magenta","yellow","key","Grayscale","RGB","CMYK","setFillingColor","color","setFillingGrayscaleColor","setFillingRgbColor","setFillingCmykColor","error","setStrokingColor","setStrokingGrayscaleColor","setStrokingRgbColor","setStrokingCmykColor","componentsToColor","comps","scale","colorToComponents","cx","cy","px","py","sx","sy","parameters","parse","path","cmd","ret","args","curArg","foundDecimal","params","_i","path_1","c","apply","commands","cmds","i","runners","a","moveTo","appendBezierCurve","appendQuadraticCurve","solveArc","lineTo","closePath","x","y","coords","rx","ry","rot","large","sweep","ex","ey","segs","arcToSegments","segs_1","seg","bez","segmentToBezier","rotateX","ox","oy","th","sinTh","cosTh","pl","a00","a01","a10","a11","x0","y0","x1","y1","d","sfactorSq","sfactor","xc","yc","th0","th1","thArc","segments","result","th2","th3","cx1","cy1","thHalf","t","x3","y3","x2","y2","svgPathToOperators","drawText","line","options","pushGraphicsState","setGraphicsState","beginText","setFillingColor","setFontAndSize","rotateAndSkewTextRadiansAndTranslate","toRadians","showText","endText","popGraphicsState","drawLinesOfText","lines","operators","setLineHeight","idx","len","nextLine","drawImage","name","translate","rotateRadians","scale","skewRadians","drawObject","drawPage","drawLine","setStrokingColor","setLineWidth","setDashPattern","_a","_b","moveTo","setLineCap","lineTo","stroke","drawRectangle","closePath","fillAndStroke","fill","KAPPA","drawEllipsePath","config","x","asNumber","y","xScale","yScale","ox","oy","xe","ye","xm","ym","appendBezierCurve","drawEllipseCurves","centerX","centerY","drawEllipse","__spreadArrays","_c","degrees","drawSvgPath","path","svgPathToOperators","drawCheckMark","size","p2x","p2y","p3y","p3x","p1x","p1y","rotateInPlace","rotateDegrees","drawCheckBox","outline","width","height","checkMarkSize","checkMark","drawRadioButton","outlineScale","dot","drawButton","background","drawTextLines","encoded","drawTextField","borderWidth","padding","clipX","clipY","clipWidth","clipHeight","clippingArea","clip","endPath","markedContent","beginMarkedContent","endMarkedContent","drawOptionList","lineHeight","highlights","EncryptedPDFError","_super","__extends","_this","msg","FontkitNotRegisteredError","_super","__extends","_this","msg","ForeignPageError","_super","__extends","_this","msg","RemovePageFromEmptyDocumentError","_super","__extends","_this","msg","NoSuchFieldError","_super","__extends","name","_this","msg","UnexpectedFieldTypeError","_super","__extends","name","expected","actual","_this","expectedType","actualType","_b","_a","msg","MissingOnValueCheckError","_super","__extends","onValue","_this","msg","FieldAlreadyExistsError","_super","__extends","name","_this","msg","InvalidFieldNamePartError","_super","__extends","namePart","_this","msg","FieldExistsAsNonTerminalError","_super","__extends","name","_this","msg","RichTextFieldReadError","_super","__extends","fieldName","_this","msg","CombedTextLayoutError","_super","__extends","lineLength","cellCount","_this","msg","ExceededMaxLengthError","_super","__extends","textLength","maxLength","name","_this","msg","InvalidMaxLengthError","_super","__extends","textLength","maxLength","name","_this","msg","TextAlignment","MIN_FONT_SIZE","MAX_FONT_SIZE","computeFontSize","lines","font","bounds","multiline","fontSize","linesUsed","lineIdx","lineLen","line","words","spaceInLineRemaining","idx","len","isLastWord","word","widthOfWord","height","lineHeight","totalHeight","computeCombedFontSize","cellCount","cellWidth","cellHeight","chars","charSplit","tooLong","lastIndexOfWhitespace","splitOutLines","input","maxWidth","lastWhitespaceIdx","encoded","width","remainder","_a","layoutMultilineText","text","alignment","lineSplit","cleanText","textLines","minX","minY","maxX","maxY","y","prevRemainder","_b","x","TextAlignment","layoutCombedText","mergeLines","CombedTextLayoutError","cells","cellOffset","charOffset","charAtIndex","char","charLength","cellCenter","layoutSinglelineText","normalizeAppearance","appearance","tfRegex","getDefaultFontSize","field","da","_a","daMatch","_b","findLastMatch","defaultFontSize","colorRegex","getDefaultColor","c1","c2","c3","c4","colorSpace","grayscale","rgb","cmyk","updateDefaultAppearance","color","font","fontSize","setFillingColor","setFontAndSize","defaultCheckBoxAppearanceProvider","checkBox","widget","widgetColor","fieldColor","rectangle","ap","bs","borderWidth","rotation","reduceRotation","_d","adjustDimsForRotation","width","height","rotate","rotateInPlace","__assign","black","borderColor","componentsToColor","normalBackgroundColor","downBackgroundColor","textColor","_c","options","__spreadArrays","drawCheckBox","defaultRadioGroupAppearanceProvider","radioGroup","drawRadioButton","defaultButtonAppearanceProvider","button","widgetFontSize","fieldFontSize","captions","normalText","downText","_f","bounds","normalLayout","layoutSinglelineText","TextAlignment","downLayout","_e","drawButton","defaultTextFieldAppearanceProvider","textField","text","textLines","padding","layout","layoutMultilineText","layoutCombedText","drawTextField","defaultDropdownAppearanceProvider","dropdown","line","defaultOptionListAppearanceProvider","optionList","selected","idx","len","lines","lineHeight","selectedLines","blue","drawOptionList","PDFEmbeddedPage","ref","doc","embedder","assertIs","PDFRef_default","PDFDocument_default","PDFPageEmbedder_default","factor","_a","PDFFont","ref","doc","embedder","assertIs","PDFRef_default","PDFDocument_default","CustomFontEmbedder_default","StandardFontEmbedder_default","text","size","options","assertOrUndefined","_a","height","PDFImage","ref","doc","embedder","assertIs","PDFRef_default","PDFDocument_default","JpegEmbedder_default","PngEmbedder_default","factor","width","height","imgWidthScale","imgHeightScale","scale","_a","_b","ImageAlignment","assertFieldAppearanceOptions","options","assertOrUndefined","PDFField","acroField","ref","doc","assertIs","PDFAcroTerminal_default","PDFRef_default","PDFDocument_default","_a","AcroFieldFlags","MethodNotImplementedError","_font","textColor","backgroundColor","borderColor","borderWidth","degreesAngle","toDegrees","caption","x","y","width","height","hidden","pageRef","assertMultiple","widget","PDFWidgetAnnotation_default","rect","rotateRectangle","ac","colorToComponents","bs","AnnotationFlags","da","newDa","setFillingColor","font","normal","rollover","down","onValue","appearance","context","_b","Resources","stream","streamRef","image","alignment","rectangle","ap","rotation","reduceRotation","rotate","rotateInPlace","__assign","adj","adjustDimsForRotation","imageDims","degrees","ImageAlignment","imageName","__spreadArrays","drawImage","onStreamRef","offStreamRef","appearanceDict","PDFName_default","PDFCheckBox","_super","__extends","acroCheckBox","ref","doc","_this","assertIs","PDFAcroCheckBox_default","onValue","_a","PDFName_default","page","options","PDFPage_default","assertFieldAppearanceOptions","rgb","widget","_b","_c","_d","_e","_f","degrees","widgetRef","widgets","idx","len","state","normal","PDFDict_default","provider","assertOrUndefined","apProvider","defaultCheckBoxAppearanceProvider","appearances","normalizeAppearance","PDFField_default","PDFDropdown","_super","__extends","acroComboBox","ref","doc","_this","assertIs","PDFAcroComboBox_default","rawOptions","options","idx","len","_a","display","value","values","selected","optionObjects","PDFHexString_default","optionsArr","existingOptions","newOptions","merge","validOptions","hasCustomOption","option","existingValues","fontSize","assertPositive","AcroChoiceFlags","page","PDFPage_default","assertFieldAppearanceOptions","rgb","widget","_b","_c","_d","_e","_f","degrees","widgetRef","font","_g","widgets","hasAppearances","PDFStream_default","PDFFont_default","provider","assertOrUndefined","apProvider","defaultDropdownAppearanceProvider","appearances","normalizeAppearance","PDFField_default","PDFOptionList","_super","__extends","acroListBox","ref","doc","_this","assertIs","PDFAcroListBox_default","rawOptions","options","idx","len","_a","display","value","values","selected","optionObjects","PDFHexString_default","optionsArr","existingOptions","newOptions","merge","validOptions","assertIsSubset","existingValues","fontSize","assertPositive","AcroChoiceFlags","page","PDFPage_default","assertFieldAppearanceOptions","rgb","widget","_b","_c","_d","_e","_f","degrees","widgetRef","font","_g","widgets","hasAppearances","PDFStream_default","PDFFont_default","provider","assertOrUndefined","apProvider","defaultOptionListAppearanceProvider","appearances","normalizeAppearance","PDFField_default","PDFRadioGroup","_super","__extends","acroRadioButton","ref","doc","_this","assertIs","PDFAcroRadioButton_default","exportValues","exportOptions","idx","len","onValues","onOptions","value","PDFName_default","option","validOptions","assertIsOneOf","AcroButtonFlags","page","options","PDFPage_default","assertFieldAppearanceOptions","widget","_a","_b","_c","_d","_e","rgb","_f","_g","_h","_j","degrees","widgetRef","apStateValue","PDFHexString_default","widgets","state","normal","PDFDict_default","provider","assertOrUndefined","onValue","apProvider","defaultRadioGroupAppearanceProvider","appearances","normalizeAppearance","PDFField_default","PDFSignature","_super","__extends","acroSignature","ref","doc","_this","assertIs","PDFAcroSignature_default","PDFField_default","PDFTextField","_super","__extends","acroText","ref","doc","_this","assertIs","PDFAcroText_default","value","RichTextFieldReadError","text","assertOrUndefined","maxLength","ExceededMaxLengthError","PDFHexString_default","quadding","TextAlignment","alignment","assertIsOneOf","assertRangeOrUndefined","InvalidMaxLengthError","image","fieldAlignment","ImageAlignment","widgets","idx","len","widget","streamRef","fontSize","assertPositive","AcroTextFlags","msg","page","options","PDFPage_default","assertFieldAppearanceOptions","rgb","_a","_b","_c","_d","_e","_f","degrees","widgetRef","font","_g","hasAppearances","PDFStream_default","PDFFont_default","provider","apProvider","defaultTextFieldAppearanceProvider","appearances","normalizeAppearance","PDFField_default","StandardFonts","PDFForm","acroForm","doc","_this","StandardFonts","assertIs","PDFAcroForm_default","PDFDocument_default","Cache_default","PDFName_default","allFields","fields","idx","len","_a","acroField","ref","field","convertToPDFField","name","NoSuchFieldError","PDFButton_default","UnexpectedFieldTypeError","PDFCheckBox_default","PDFDropdown_default","PDFOptionList_default","PDFRadioGroup_default","PDFSignature_default","PDFTextField_default","nameParts","splitFieldName","parent","button","PDFAcroPushButton_default","addFieldToParent","checkBox","PDFAcroCheckBox_default","comboBox","PDFAcroComboBox_default","listBox","PDFAcroListBox_default","radioButton","PDFAcroRadioButton_default","text","PDFAcroText_default","options","i","lenFields","widgets","j","lenWidgets","widget","page","widgetRef","xObjectKey","rectangle","operators","__spreadArrays","pushGraphicsState","translate","rotateInPlace","__assign","drawObject","popGraphicsState","pages","fieldKids","kidsCount","childIndex","child","PDFRef_default","font","assertOrUndefined","PDFFont_default","fieldRef","pageRef","x","refOrDict","PDFDict_default","value","name_1","partialNames","nonTerminal","namePart","InvalidFieldNamePartError","parent_1","parentRef","res","node","PDFAcroNonTerminal_default","nodeRef","partialName","createPDFAcroFields","FieldAlreadyExistsError","PDFAcroSignature_default","fullyQualifiedName","parts","_b","entries","PageSizes","ParseSpeeds","PDFEmbeddedFile","ref","doc","embedder","_a","PDFName_default","Names","PDFDict_default","EmbeddedFiles","EFNames","PDFArray_default","PDFHexString_default","AF","PDFJavaScript","ref","doc","embedder","_a","catalog","context","_b","PDFName_default","Names","PDFDict_default","Javascript","JSNames","PDFArray_default","PDFHexString_default","JavaScriptEmbedder","script","scriptName","context","ref","jsActionDict","PDFHexString_default","JavaScriptEmbedder_default","PDFDocument","context","ignoreEncryption","updateMetadata","_this","pages","node","ref","PDFPageLeaf_default","page","PDFPage_default","acroForm","PDFForm_default","assertIs","PDFContext_default","Cache_default","EncryptedPDFError","pdf","options","_a","_b","parseSpeed","ParseSpeeds","_c","throwOnInvalidObject","_d","_e","capNumbers","bytes","toUint8Array","PDFParser_default","_f","pageTree","PDFPageTree_default","pageTreeRef","catalog","PDFCatalog_default","fontkit","form","title","PDFName_default","assertIsLiteralOrHexString","author","subject","keywords","creator","producer","creationDate","modificationDate","key","PDFHexString_default","prefs","language","PDFString_default","index","assertRange","range","pageCount","RemovePageFromEmptyDocumentError","dims","PageSizes","ForeignPageError","parentRef","srcDoc","indices","copier","PDFObjectCopier_default","srcPages","copiedPages","idx","len","srcPage","copiedPage","pdfCopy","contentPages","name","script","embedder","JavaScriptEmbedder_default","javaScript","PDFJavaScript_default","attachment","assertOrUndefined","assertIsOneOfOrUndefined","AFRelationship","FileEmbedder_default","embeddedFile","PDFEmbeddedFile_default","font","subset","customName","features","isStandardFont","StandardFontEmbedder_default","canBeConvertedToUint8Array","CustomFontSubsetEmbedder_default","CustomFontEmbedder_default","pdfFont","PDFFont_default","jpg","JpegEmbedder_default","pdfImage","PDFImage_default","png","PngEmbedder_default","pluckIndices","boundingBox","transformationMatrix","embeddedPage","boundingBoxes","transformationMatrices","currPage","nextPage","PageEmbeddingMismatchedContextError","maybeCopyPage","p","embeddedPages","box","matrix","PDFPageEmbedder_default","PDFEmbeddedPage_default","useObjectStreams","addDefaultPage","objectsPerTick","updateFieldAppearances","Writer","PDFStreamWriter_default","PDFWriter_default","dataUri","otherOptions","__rest","base64","encodeToBase64","annotations","embeddables","pdfLib","now","info","existingInfo","PDFDict_default","newInfo","FontkitNotRegisteredError","pdfObject","UnexpectedObjectTypeError","BlendMode","PDFPage","leafNode","ref","doc","rgb","assertIs","PDFPageLeaf_default","PDFRef_default","PDFDocument_default","angle","degreesAngle","toDegrees","assertMultiple","PDFName_default","Rotate","degrees","width","height","mediaBox","cropBox","bleedBox","trimBox","artBox","hasCropBox","hasBleedBox","hasTrimBox","hasArtBox","rectanglesAreEqual","x","y","_a","start","pushGraphicsState","translate","startRef","end","popGraphicsState","endRef","scale","annots","idx","annot","PDFDict_default","font","PDFFont_default","fontSize","fontColor","lineHeight","yDecrease","yIncrease","xDecrease","xIncrease","operator","_i","assertEachIs","PDFOperator_default","contentStream","text","options","assertOrUndefined","assertRangeOrUndefined","assertIsOneOfOrUndefined","BlendMode","_h","oldFont","newFont","newFontKey","wordBreaks","textWidth","t","lines","lineSplit","cleanText","breakTextIntoLines","encodedLines","len","graphicsStateKey","drawLinesOfText","_b","_c","_d","_e","_f","_g","image","PDFImage_default","xObjectKey","drawImage","embeddedPage","PDFEmbeddedPage_default","xScale","yScale","drawPage","path","LineCapStyle","drawSvgPath","_j","drawLine","drawRectangle","_k","_l","_m","_o","size","__assign","drawEllipse","oldFontKey","StandardFonts","useExisting","operators","dict","PDFContentStream_default","opacity","borderOpacity","blendMode","graphicsState","key","selectors","list","PDFArray_default","inkLists","arr","dummyRef","pageLeaf","pageRef","PDFButton","_super","__extends","acroPushButton","ref","doc","_this","assertIs","PDFAcroPushButton_default","image","alignment","ImageAlignment","widgets","idx","len","widget","streamRef","fontSize","assertPositive","text","page","options","assertOrUndefined","PDFPage_default","assertFieldAppearanceOptions","_a","_b","_c","_d","_e","_f","_g","rgb","_h","_j","_k","degrees","widgetRef","font","_l","hasAppearances","PDFStream_default","PDFFont_default","provider","apProvider","defaultButtonAppearanceProvider","appearances","normalizeAppearance","PDFField_default"],"sourceRoot":"/","sources":["../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/base64.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/strings.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/arrays.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/async.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/unicode.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/numbers.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/errors.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/objects.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/validators.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/pdfDocEncoding.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/Cache.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/errors.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/syntax/CharCodes.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/PDFContext.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/document/PDFHeader.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFObject.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFNumber.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFArray.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFBool.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/syntax/Delimiters.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/syntax/Whitespace.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/syntax/Irregular.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFName.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFNull.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFDict.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFRawStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFRef.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/operators/PDFOperator.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/operators/PDFOperatorNames.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/structures/PDFFlateStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/structures/PDFContentStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/rng.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/structures/PDFPageLeaf.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/PDFObjectCopier.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/document/PDFCrossRefSection.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/document/PDFTrailer.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/document/PDFTrailerDict.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/structures/PDFObjectStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/writers/PDFWriter.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFInvalidObject.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/structures/PDFCrossRefStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/writers/PDFStreamWriter.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/StandardFontEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFHexString.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/CMap.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/FontFlags.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/objects/PDFString.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/CustomFontEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/CustomFontSubsetEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/FileEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/JpegEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/utils/png.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/PngEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/Stream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/DecodeStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/Ascii85Stream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/AsciiHexStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/FlateStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/LZWStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/RunLengthStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/streams/decode.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/PDFPageEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/interactive/ViewerPreferences.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroField.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/annotation/BorderStyle.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/annotation/PDFAnnotation.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/annotation/AppearanceCharacteristics.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/annotation/PDFWidgetAnnotation.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroTerminal.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroButton.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroCheckBox.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/flags.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroChoice.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroComboBox.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroNonTerminal.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroSignature.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroText.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroPushButton.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroRadioButton.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroListBox.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/utils.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/acroform/PDFAcroForm.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/structures/PDFCatalog.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/structures/PDFPageTree.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/syntax/Numeric.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/parser/BaseParser.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/parser/ByteStream.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/syntax/Keywords.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/parser/PDFObjectParser.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/parser/PDFObjectStreamParser.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/parser/PDFXRefStreamParser.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/parser/PDFParser.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/annotation/flags.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/objects.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/rotations.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/operators.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/colors.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/svgPath.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/operations.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/errors.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/text/alignment.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/text/layout.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/appearances.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFEmbeddedPage.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFFont.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFImage.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/image/alignment.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFField.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFCheckBox.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFDropdown.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFOptionList.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFRadioGroup.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFSignature.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFTextField.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/StandardFonts.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFForm.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/sizes.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFDocumentOptions.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFEmbeddedFile.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFJavaScript.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/core/embedders/JavaScriptEmbedder.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFDocument.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFPageOptions.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/PDFPage.ts","../esmd/npm/pdf-lib@1.17.1/node_modules/.pnpm/pdf-lib@1.17.1/node_modules/pdf-lib/src/api/form/PDFButton.ts"],"sourcesContent":["/*\n * The `chars`, `lookup`, `encode`, and `decode` members of this file are\n * licensed under the following:\n *\n *     base64-arraybuffer\n *     https://github.com/niklasvh/base64-arraybuffer\n *\n *     Copyright (c) 2012 Niklas von Hertzen\n *     Licensed under the MIT license.\n *\n */\n\nconst chars =\n  'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n\n// Use a lookup table to find the index.\nconst lookup = new Uint8Array(256);\nfor (let i = 0; i \u003c chars.length; i++) {\n  lookup[chars.charCodeAt(i)] = i;\n}\n\nexport const encodeToBase64 = (bytes: Uint8Array): string =\u003e {\n  let base64 = '';\n  const len = bytes.length;\n  for (let i = 0; i \u003c len; i += 3) {\n    base64 += chars[bytes[i] \u003e\u003e 2];\n    base64 += chars[((bytes[i] \u0026 3) \u003c\u003c 4) | (bytes[i + 1] \u003e\u003e 4)];\n    base64 += chars[((bytes[i + 1] \u0026 15) \u003c\u003c 2) | (bytes[i + 2] \u003e\u003e 6)];\n    base64 += chars[bytes[i + 2] \u0026 63];\n  }\n\n  if (len % 3 === 2) {\n    base64 = base64.substring(0, base64.length - 1) + '=';\n  } else if (len % 3 === 1) {\n    base64 = base64.substring(0, base64.length - 2) + '==';\n  }\n\n  return base64;\n};\n\nexport const decodeFromBase64 = (base64: string): Uint8Array =\u003e {\n  let bufferLength = base64.length * 0.75;\n  const len = base64.length;\n  let i;\n  let p = 0;\n  let encoded1;\n  let encoded2;\n  let encoded3;\n  let encoded4;\n\n  if (base64[base64.length - 1] === '=') {\n    bufferLength--;\n    if (base64[base64.length - 2] === '=') {\n      bufferLength--;\n    }\n  }\n\n  const bytes = new Uint8Array(bufferLength);\n\n  for (i = 0; i \u003c len; i += 4) {\n    encoded1 = lookup[base64.charCodeAt(i)];\n    encoded2 = lookup[base64.charCodeAt(i + 1)];\n    encoded3 = lookup[base64.charCodeAt(i + 2)];\n    encoded4 = lookup[base64.charCodeAt(i + 3)];\n\n    bytes[p++] = (encoded1 \u003c\u003c 2) | (encoded2 \u003e\u003e 4);\n    bytes[p++] = ((encoded2 \u0026 15) \u003c\u003c 4) | (encoded3 \u003e\u003e 2);\n    bytes[p++] = ((encoded3 \u0026 3) \u003c\u003c 6) | (encoded4 \u0026 63);\n  }\n\n  return bytes;\n};\n\n// This regex is designed to be as flexible as possible. It will parse certain\n// invalid data URIs.\nconst DATA_URI_PREFIX_REGEX = /^(data)?:?([\\w\\/\\+]+)?;?(charset=[\\w-]+|base64)?.*,/i;\n\n/**\n * If the `dataUri` input is a data URI, then the data URI prefix must not be\n * longer than 100 characters, or this function will fail to decode it.\n *\n * @param dataUri a base64 data URI or plain base64 string\n * @returns a Uint8Array containing the decoded input\n */\nexport const decodeFromBase64DataUri = (dataUri: string): Uint8Array =\u003e {\n  const trimmedUri = dataUri.trim();\n\n  const prefix = trimmedUri.substring(0, 100);\n  const res = prefix.match(DATA_URI_PREFIX_REGEX);\n\n  // Assume it's not a data URI - just a plain base64 string\n  if (!res) return decodeFromBase64(trimmedUri);\n\n  // Remove the data URI prefix and parse the remainder as a base64 string\n  const [fullMatch] = res;\n  const data = trimmedUri.substring(fullMatch.length);\n\n  return decodeFromBase64(data);\n};\n","export const toCharCode = (character: string) =\u003e character.charCodeAt(0);\n\nexport const toCodePoint = (character: string) =\u003e character.codePointAt(0);\n\nexport const toHexStringOfMinLength = (num: number, minLength: number) =\u003e\n  padStart(num.toString(16), minLength, '0').toUpperCase();\n\nexport const toHexString = (num: number) =\u003e toHexStringOfMinLength(num, 2);\n\nexport const charFromCode = (code: number) =\u003e String.fromCharCode(code);\n\nexport const charFromHexCode = (hex: string) =\u003e charFromCode(parseInt(hex, 16));\n\nexport const padStart = (value: string, length: number, padChar: string) =\u003e {\n  let padding = '';\n  for (let idx = 0, len = length - value.length; idx \u003c len; idx++) {\n    padding += padChar;\n  }\n  return padding + value;\n};\n\nexport const copyStringIntoBuffer = (\n  str: string,\n  buffer: Uint8Array,\n  offset: number,\n): number =\u003e {\n  const length = str.length;\n  for (let idx = 0; idx \u003c length; idx++) {\n    buffer[offset++] = str.charCodeAt(idx);\n  }\n  return length;\n};\n\nexport const addRandomSuffix = (prefix: string, suffixLength = 4) =\u003e\n  `${prefix}-${Math.floor(Math.random() * 10 ** suffixLength)}`;\n\nexport const escapeRegExp = (str: string) =\u003e\n  str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$\u0026');\n\nexport const cleanText = (text: string) =\u003e\n  text.replace(/\\t|\\u0085|\\u2028|\\u2029/g, '    ').replace(/[\\b\\v]/g, '');\n\nexport const escapedNewlineChars = ['\\\\n', '\\\\f', '\\\\r', '\\\\u000B'];\n\nexport const newlineChars = ['\\n', '\\f', '\\r', '\\u000B'];\n\nexport const isNewlineChar = (text: string) =\u003e /^[\\n\\f\\r\\u000B]$/.test(text);\n\nexport const lineSplit = (text: string) =\u003e text.split(/[\\n\\f\\r\\u000B]/);\n\nexport const mergeLines = (text: string) =\u003e\n  text.replace(/[\\n\\f\\r\\u000B]/g, ' ');\n\n// JavaScript's String.charAt() method doesn work on strings containing UTF-16\n// characters (with high and low surrogate pairs), such as 💩 (poo emoji). This\n// `charAtIndex()` function does.\n//\n// Credit: https://github.com/mathiasbynens/String.prototype.at/blob/master/at.js#L14-L48\nexport const charAtIndex = (text: string, index: number): [string, number] =\u003e {\n  // Get the first code unit and code unit value\n  const cuFirst = text.charCodeAt(index);\n  let cuSecond: number;\n  const nextIndex = index + 1;\n  let length = 1;\n  if (\n    // Check if it's the start of a surrogate pair.\n    cuFirst \u003e= 0xd800 \u0026\u0026\n    cuFirst \u003c= 0xdbff \u0026\u0026 // high surrogate\n    text.length \u003e nextIndex // there is a next code unit\n  ) {\n    cuSecond = text.charCodeAt(nextIndex);\n    if (cuSecond \u003e= 0xdc00 \u0026\u0026 cuSecond \u003c= 0xdfff) length = 2; // low surrogate\n  }\n  return [text.slice(index, index + length), length];\n};\n\nexport const charSplit = (text: string) =\u003e {\n  const chars: string[] = [];\n\n  for (let idx = 0, len = text.length; idx \u003c len; ) {\n    const [c, cLen] = charAtIndex(text, idx);\n    chars.push(c);\n    idx += cLen;\n  }\n\n  return chars;\n};\n\nconst buildWordBreakRegex = (wordBreaks: string[]) =\u003e {\n  const newlineCharUnion = escapedNewlineChars.join('|');\n\n  const escapedRules: string[] = ['$'];\n  for (let idx = 0, len = wordBreaks.length; idx \u003c len; idx++) {\n    const wordBreak = wordBreaks[idx];\n    if (isNewlineChar(wordBreak)) {\n      throw new TypeError(`\\`wordBreak\\` must not include ${newlineCharUnion}`);\n    }\n    escapedRules.push(wordBreak === '' ? '.' : escapeRegExp(wordBreak));\n  }\n\n  const breakRules = escapedRules.join('|');\n  return new RegExp(`(${newlineCharUnion})|((.*?)(${breakRules}))`, 'gm');\n};\n\nexport const breakTextIntoLines = (\n  text: string,\n  wordBreaks: string[],\n  maxWidth: number,\n  computeWidthOfText: (t: string) =\u003e number,\n): string[] =\u003e {\n  const regex = buildWordBreakRegex(wordBreaks);\n\n  const words = cleanText(text).match(regex)!;\n\n  let currLine = '';\n  let currWidth = 0;\n  const lines: string[] = [];\n\n  const pushCurrLine = () =\u003e {\n    if (currLine !== '') lines.push(currLine);\n    currLine = '';\n    currWidth = 0;\n  };\n\n  for (let idx = 0, len = words.length; idx \u003c len; idx++) {\n    const word = words[idx];\n    if (isNewlineChar(word)) {\n      pushCurrLine();\n    } else {\n      const width = computeWidthOfText(word);\n      if (currWidth + width \u003e maxWidth) pushCurrLine();\n      currLine += word;\n      currWidth += width;\n    }\n  }\n  pushCurrLine();\n\n  return lines;\n};\n\n// See section \"7.9.4 Dates\" of the PDF specification\nconst dateRegex = /^D:(\\d\\d\\d\\d)(\\d\\d)?(\\d\\d)?(\\d\\d)?(\\d\\d)?(\\d\\d)?([+\\-Z])?(\\d\\d)?'?(\\d\\d)?'?$/;\n\nexport const parseDate = (dateStr: string): Date | undefined =\u003e {\n  const match = dateStr.match(dateRegex);\n\n  if (!match) return undefined;\n\n  const [\n    ,\n    year,\n    month = '01',\n    day = '01',\n    hours = '00',\n    mins = '00',\n    secs = '00',\n    offsetSign = 'Z',\n    offsetHours = '00',\n    offsetMins = '00',\n  ] = match;\n\n  // http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15\n  const tzOffset =\n    offsetSign === 'Z' ? 'Z' : `${offsetSign}${offsetHours}:${offsetMins}`;\n  const date = new Date(\n    `${year}-${month}-${day}T${hours}:${mins}:${secs}${tzOffset}`,\n  );\n\n  return date;\n};\n\nexport const findLastMatch = (value: string, regex: RegExp) =\u003e {\n  let position = 0;\n  let lastMatch: RegExpMatchArray | undefined;\n  while (position \u003c value.length) {\n    const match = value.substring(position).match(regex);\n    if (!match) return { match: lastMatch, pos: position };\n    lastMatch = match;\n    position += (match.index ?? 0) + match[0].length;\n  }\n  return { match: lastMatch, pos: position };\n};\n","import { decodeFromBase64DataUri } from 'src/utils/base64';\nimport { charFromCode } from 'src/utils/strings';\n\nexport const last = \u003cT\u003e(array: T[]): T =\u003e array[array.length - 1];\n\n// export const dropLast = \u003cT\u003e(array: T[]): T[] =\u003e\n// array.slice(0, array.length - 1);\n\nexport const typedArrayFor = (value: string | Uint8Array): Uint8Array =\u003e {\n  if (value instanceof Uint8Array) return value;\n  const length = value.length;\n  const typedArray = new Uint8Array(length);\n  for (let idx = 0; idx \u003c length; idx++) {\n    typedArray[idx] = value.charCodeAt(idx);\n  }\n  return typedArray;\n};\n\nexport const mergeIntoTypedArray = (...arrays: (string | Uint8Array)[]) =\u003e {\n  const arrayCount = arrays.length;\n\n  const typedArrays: Uint8Array[] = [];\n  for (let idx = 0; idx \u003c arrayCount; idx++) {\n    const element = arrays[idx];\n    typedArrays[idx] =\n      element instanceof Uint8Array ? element : typedArrayFor(element);\n  }\n\n  let totalSize = 0;\n  for (let idx = 0; idx \u003c arrayCount; idx++) {\n    totalSize += arrays[idx].length;\n  }\n\n  const merged = new Uint8Array(totalSize);\n  let offset = 0;\n  for (let arrIdx = 0; arrIdx \u003c arrayCount; arrIdx++) {\n    const arr = typedArrays[arrIdx];\n    for (let byteIdx = 0, arrLen = arr.length; byteIdx \u003c arrLen; byteIdx++) {\n      merged[offset++] = arr[byteIdx];\n    }\n  }\n\n  return merged;\n};\n\nexport const mergeUint8Arrays = (arrays: Uint8Array[]): Uint8Array =\u003e {\n  let totalSize = 0;\n  for (let idx = 0, len = arrays.length; idx \u003c len; idx++) {\n    totalSize += arrays[idx].length;\n  }\n\n  const mergedBuffer = new Uint8Array(totalSize);\n  let offset = 0;\n  for (let idx = 0, len = arrays.length; idx \u003c len; idx++) {\n    const array = arrays[idx];\n    mergedBuffer.set(array, offset);\n    offset += array.length;\n  }\n\n  return mergedBuffer;\n};\n\nexport const arrayAsString = (array: Uint8Array | number[]): string =\u003e {\n  let str = '';\n  for (let idx = 0, len = array.length; idx \u003c len; idx++) {\n    str += charFromCode(array[idx]);\n  }\n  return str;\n};\n\nexport const byAscendingId = \u003cT extends { id: any }\u003e(a: T, b: T) =\u003e a.id - b.id;\n\nexport const sortedUniq = \u003cT\u003e(array: T[], indexer: (elem: T) =\u003e any): T[] =\u003e {\n  const uniq: T[] = [];\n\n  for (let idx = 0, len = array.length; idx \u003c len; idx++) {\n    const curr = array[idx];\n    const prev = array[idx - 1];\n    if (idx === 0 || indexer(curr) !== indexer(prev)) {\n      uniq.push(curr);\n    }\n  }\n\n  return uniq;\n};\n\n// Arrays and TypedArrays in JS both have .reverse() methods, which would seem\n// to negate the need for this function. However, not all runtimes support this\n// method (e.g. React Native). This function compensates for that fact.\nexport const reverseArray = (array: Uint8Array) =\u003e {\n  const arrayLen = array.length;\n  for (let idx = 0, len = Math.floor(arrayLen / 2); idx \u003c len; idx++) {\n    const leftIdx = idx;\n    const rightIdx = arrayLen - idx - 1;\n    const temp = array[idx];\n\n    array[leftIdx] = array[rightIdx];\n    array[rightIdx] = temp;\n  }\n  return array;\n};\n\nexport const sum = (array: number[] | Uint8Array): number =\u003e {\n  let total = 0;\n  for (let idx = 0, len = array.length; idx \u003c len; idx++) {\n    total += array[idx];\n  }\n  return total;\n};\n\nexport const range = (start: number, end: number): number[] =\u003e {\n  const arr = new Array(end - start);\n  for (let idx = 0, len = arr.length; idx \u003c len; idx++) {\n    arr[idx] = start + idx;\n  }\n  return arr;\n};\n\nexport const pluckIndices = \u003cT\u003e(arr: T[], indices: number[]) =\u003e {\n  const plucked = new Array\u003cT\u003e(indices.length);\n  for (let idx = 0, len = indices.length; idx \u003c len; idx++) {\n    plucked[idx] = arr[indices[idx]];\n  }\n  return plucked;\n};\n\nexport const canBeConvertedToUint8Array = (\n  input: any,\n): input is string | ArrayBuffer | Uint8Array =\u003e\n  input instanceof Uint8Array ||\n  input instanceof ArrayBuffer ||\n  typeof input === 'string';\n\nexport const toUint8Array = (input: string | ArrayBuffer | Uint8Array) =\u003e {\n  if (typeof input === 'string') {\n    return decodeFromBase64DataUri(input);\n  } else if (input instanceof ArrayBuffer) {\n    return new Uint8Array(input);\n  } else if (input instanceof Uint8Array) {\n    return input;\n  } else {\n    throw new TypeError(\n      '`input` must be one of `string | ArrayBuffer | Uint8Array`',\n    );\n  }\n};\n","/**\n * Returns a Promise that resolves after at least one tick of the\n * Macro Task Queue occurs.\n */\nexport const waitForTick = (): Promise\u003cvoid\u003e =\u003e\n  new Promise((resolve) =\u003e {\n    setTimeout(() =\u003e resolve(), 0);\n  });\n","import { toHexString } from 'src/utils/strings';\n\n/**\n * Encodes a string to UTF-8.\n *\n * @param input The string to be encoded.\n * @param byteOrderMark Whether or not a byte order marker (BOM) should be added\n *                      to the start of the encoding. (default `true`)\n * @returns A Uint8Array containing the UTF-8 encoding of the input string.\n *\n * -----------------------------------------------------------------------------\n *\n * JavaScript strings are composed of Unicode code points. Code points are\n * integers in the range 0 to 1,114,111 (0x10FFFF). When serializing a string,\n * it must be encoded as a sequence of words. A word is typically 8, 16, or 32\n * bytes in size. As such, Unicode defines three encoding forms: UTF-8, UTF-16,\n * and UTF-32. These encoding forms are described in the Unicode standard [1].\n * This function implements the UTF-8 encoding form.\n *\n * -----------------------------------------------------------------------------\n *\n * In UTF-8, each code point is mapped to a sequence of 1, 2, 3, or 4 bytes.\n * Note that the logic which defines this mapping is slightly convoluted, and\n * not as straightforward as the mapping logic for UTF-16 or UTF-32. The UTF-8\n * mapping logic is as follows [2]:\n *\n * • If a code point is in the range U+0000..U+007F, then view it as a 7-bit\n *   integer: 0bxxxxxxx. Map the code point to 1 byte with the first high order\n *   bit set to 0:\n *\n *       b1=0b0xxxxxxx\n *\n * • If a code point is in the range U+0080..U+07FF, then view it as an 11-bit\n *   integer: 0byyyyyxxxxxx. Map the code point to 2 bytes with the first 5 bits\n *   of the code point stored in the first byte, and the last 6 bits stored in\n *   the second byte:\n *\n *       b1=0b110yyyyy    b2=0b10xxxxxx\n *\n * • If a code point is in the range U+0800..U+FFFF, then view it as a 16-bit\n *   integer, 0bzzzzyyyyyyxxxxxx. Map the code point to 3 bytes with the first\n *   4 bits stored in the first byte, the next 6 bits stored in the second byte,\n *   and the last 6 bits in the third byte:\n *\n *       b1=0b1110zzzz    b2=0b10yyyyyy    b3=0b10xxxxxx\n *\n * • If a code point is in the range U+10000...U+10FFFF, then view it as a\n *   21-bit integer, 0bvvvzzzzzzyyyyyyxxxxxx. Map the code point to 4 bytes with\n *   the first 3 bits stored in the first byte, the next 6 bits stored in the\n *   second byte, the next 6 bits stored in the third byte, and the last 6 bits\n *   stored in the fourth byte:\n *\n *       b1=0b11110xxx    b2=0b10zzzzzz    b3=0b10yyyyyy    b4=0b10xxxxxx\n *\n * -----------------------------------------------------------------------------\n *\n * It is important to note, when iterating through the code points of a string\n * in JavaScript, that if a character is encoded as a surrogate pair it will\n * increase the string's length by 2 instead of 1 [4]. For example:\n *\n * ```\n * \u003e 'a'.length\n * 1\n * \u003e '💩'.length\n * 2\n * \u003e '語'.length\n * 1\n * \u003e 'a💩語'.length\n * 4\n * ```\n *\n * The results of the above example are explained by the fact that the\n * characters 'a' and '語' are not represented by surrogate pairs, but '💩' is.\n *\n * Because of this idiosyncrasy in JavaScript's string implementation and APIs,\n * we must \"jump\" an extra index after encoding a character as a surrogate\n * pair. In practice, this means we must increment the index of our for loop by\n * 2 if we encode a surrogate pair, and 1 in all other cases.\n *\n * -----------------------------------------------------------------------------\n *\n * References:\n *   - [1] https://www.unicode.org/versions/Unicode12.0.0/UnicodeStandard-12.0.pdf\n *         3.9  Unicode Encoding Forms - UTF-8\n *   - [2] http://www.herongyang.com/Unicode/UTF-8-UTF-8-Encoding.html\n *   - [3] http://www.herongyang.com/Unicode/UTF-8-UTF-8-Encoding-Algorithm.html\n *   - [4] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#Description\n *\n */\nexport const utf8Encode = (input: string, byteOrderMark = true): Uint8Array =\u003e {\n  const encoded = [];\n\n  if (byteOrderMark) encoded.push(0xef, 0xbb, 0xbf);\n\n  for (let idx = 0, len = input.length; idx \u003c len; ) {\n    const codePoint = input.codePointAt(idx)!;\n\n    // One byte encoding\n    if (codePoint \u003c 0x80) {\n      const byte1 = codePoint \u0026 0x7f;\n      encoded.push(byte1);\n      idx += 1;\n    }\n\n    // Two byte encoding\n    else if (codePoint \u003c 0x0800) {\n      const byte1 = ((codePoint \u003e\u003e 6) \u0026 0x1f) | 0xc0;\n      const byte2 = (codePoint \u0026 0x3f) | 0x80;\n      encoded.push(byte1, byte2);\n      idx += 1;\n    }\n\n    // Three byte encoding\n    else if (codePoint \u003c 0x010000) {\n      const byte1 = ((codePoint \u003e\u003e 12) \u0026 0x0f) | 0xe0;\n      const byte2 = ((codePoint \u003e\u003e 6) \u0026 0x3f) | 0x80;\n      const byte3 = (codePoint \u0026 0x3f) | 0x80;\n      encoded.push(byte1, byte2, byte3);\n      idx += 1;\n    }\n\n    // Four byte encoding (surrogate pair)\n    else if (codePoint \u003c 0x110000) {\n      const byte1 = ((codePoint \u003e\u003e 18) \u0026 0x07) | 0xf0;\n      const byte2 = ((codePoint \u003e\u003e 12) \u0026 0x3f) | 0x80;\n      const byte3 = ((codePoint \u003e\u003e 6) \u0026 0x3f) | 0x80;\n      const byte4 = ((codePoint \u003e\u003e 0) \u0026 0x3f) | 0x80;\n      encoded.push(byte1, byte2, byte3, byte4);\n      idx += 2;\n    }\n\n    // Should never reach this case\n    else throw new Error(`Invalid code point: 0x${toHexString(codePoint)}`);\n  }\n\n  return new Uint8Array(encoded);\n};\n\n/**\n * Encodes a string to UTF-16.\n *\n * @param input The string to be encoded.\n * @param byteOrderMark Whether or not a byte order marker (BOM) should be added\n *                      to the start of the encoding. (default `true`)\n * @returns A Uint16Array containing the UTF-16 encoding of the input string.\n *\n * -----------------------------------------------------------------------------\n *\n * JavaScript strings are composed of Unicode code points. Code points are\n * integers in the range 0 to 1,114,111 (0x10FFFF). When serializing a string,\n * it must be encoded as a sequence of words. A word is typically 8, 16, or 32\n * bytes in size. As such, Unicode defines three encoding forms: UTF-8, UTF-16,\n * and UTF-32. These encoding forms are described in the Unicode standard [1].\n * This function implements the UTF-16 encoding form.\n *\n * -----------------------------------------------------------------------------\n *\n * In UTF-16, each code point is mapped to one or two 16-bit integers. The\n * UTF-16 mapping logic is as follows [2]:\n *\n * • If a code point is in the range U+0000..U+FFFF, then map the code point to\n *   a 16-bit integer with the most significant byte first.\n *\n * • If a code point is in the range U+10000..U+10000, then map the code point\n *   to two 16-bit integers. The first integer should contain the high surrogate\n *   and the second integer should contain the low surrogate. Both surrogates\n *   should be written with the most significant byte first.\n *\n * -----------------------------------------------------------------------------\n *\n * It is important to note, when iterating through the code points of a string\n * in JavaScript, that if a character is encoded as a surrogate pair it will\n * increase the string's length by 2 instead of 1 [4]. For example:\n *\n * ```\n * \u003e 'a'.length\n * 1\n * \u003e '💩'.length\n * 2\n * \u003e '語'.length\n * 1\n * \u003e 'a💩語'.length\n * 4\n * ```\n *\n * The results of the above example are explained by the fact that the\n * characters 'a' and '語' are not represented by surrogate pairs, but '💩' is.\n *\n * Because of this idiosyncrasy in JavaScript's string implementation and APIs,\n * we must \"jump\" an extra index after encoding a character as a surrogate\n * pair. In practice, this means we must increment the index of our for loop by\n * 2 if we encode a surrogate pair, and 1 in all other cases.\n *\n * -----------------------------------------------------------------------------\n *\n * References:\n *   - [1] https://www.unicode.org/versions/Unicode12.0.0/UnicodeStandard-12.0.pdf\n *         3.9  Unicode Encoding Forms - UTF-8\n *   - [2] http://www.herongyang.com/Unicode/UTF-16-UTF-16-Encoding.html\n *   - [3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#Description\n *\n */\nexport const utf16Encode = (\n  input: string,\n  byteOrderMark = true,\n): Uint16Array =\u003e {\n  const encoded = [];\n\n  if (byteOrderMark) encoded.push(0xfeff);\n\n  for (let idx = 0, len = input.length; idx \u003c len; ) {\n    const codePoint = input.codePointAt(idx)!;\n\n    // Two byte encoding\n    if (codePoint \u003c 0x010000) {\n      encoded.push(codePoint);\n      idx += 1;\n    }\n\n    // Four byte encoding (surrogate pair)\n    else if (codePoint \u003c 0x110000) {\n      encoded.push(highSurrogate(codePoint), lowSurrogate(codePoint));\n      idx += 2;\n    }\n\n    // Should never reach this case\n    else throw new Error(`Invalid code point: 0x${toHexString(codePoint)}`);\n  }\n\n  return new Uint16Array(encoded);\n};\n\n/**\n * Returns `true` if the `codePoint` is within the\n * Basic Multilingual Plane (BMP). Code points inside the BMP are not encoded\n * with surrogate pairs.\n * @param codePoint The code point to be evaluated.\n *\n * Reference: https://en.wikipedia.org/wiki/UTF-16#Description\n */\nexport const isWithinBMP = (codePoint: number) =\u003e\n  codePoint \u003e= 0 \u0026\u0026 codePoint \u003c= 0xffff;\n\n/**\n * Returns `true` if the given `codePoint` is valid and must be represented\n * with a surrogate pair when encoded.\n * @param codePoint The code point to be evaluated.\n *\n * Reference: https://en.wikipedia.org/wiki/UTF-16#Description\n */\nexport const hasSurrogates = (codePoint: number) =\u003e\n  codePoint \u003e= 0x010000 \u0026\u0026 codePoint \u003c= 0x10ffff;\n\n// From Unicode 3.0 spec, section 3.7:\n//   http://unicode.org/versions/Unicode3.0.0/ch03.pdf\nexport const highSurrogate = (codePoint: number) =\u003e\n  Math.floor((codePoint - 0x10000) / 0x400) + 0xd800;\n\n// From Unicode 3.0 spec, section 3.7:\n//   http://unicode.org/versions/Unicode3.0.0/ch03.pdf\nexport const lowSurrogate = (codePoint: number) =\u003e\n  ((codePoint - 0x10000) % 0x400) + 0xdc00;\n\nenum ByteOrder {\n  BigEndian = 'BigEndian',\n  LittleEndian = 'LittleEndian',\n}\n\nconst REPLACEMENT = '�'.codePointAt(0)!;\n\n/**\n * Decodes a Uint8Array of data to a string using UTF-16.\n *\n * Note that this function attempts to recover from erronous input by\n * inserting the replacement character (�) to mark invalid code points\n * and surrogate pairs.\n *\n * @param input A Uint8Array containing UTF-16 encoded data\n * @param byteOrderMark Whether or not a byte order marker (BOM) should be read\n *                      at the start of the encoding. (default `true`)\n * @returns The decoded string.\n */\nexport const utf16Decode = (\n  input: Uint8Array,\n  byteOrderMark = true,\n): string =\u003e {\n  // Need at least 2 bytes of data in UTF-16 encodings\n  if (input.length \u003c= 1) return String.fromCodePoint(REPLACEMENT);\n\n  const byteOrder = byteOrderMark ? readBOM(input) : ByteOrder.BigEndian;\n\n  // Skip byte order mark if needed\n  let idx = byteOrderMark ? 2 : 0;\n\n  const codePoints: number[] = [];\n\n  while (input.length - idx \u003e= 2) {\n    const first = decodeValues(input[idx++], input[idx++], byteOrder);\n\n    if (isHighSurrogate(first)) {\n      if (input.length - idx \u003c 2) {\n        // Need at least 2 bytes left for the low surrogate that is required\n        codePoints.push(REPLACEMENT);\n      } else {\n        const second = decodeValues(input[idx++], input[idx++], byteOrder);\n        if (isLowSurrogate(second)) {\n          codePoints.push(first, second);\n        } else {\n          // Low surrogates should always follow high surrogates\n          codePoints.push(REPLACEMENT);\n        }\n      }\n    } else if (isLowSurrogate(first)) {\n      // High surrogates should always come first since `decodeValues()`\n      // accounts for the byte ordering\n      idx += 2;\n      codePoints.push(REPLACEMENT);\n    } else {\n      codePoints.push(first);\n    }\n  }\n\n  // There shouldn't be extra byte(s) left over\n  if (idx \u003c input.length) codePoints.push(REPLACEMENT);\n\n  return String.fromCodePoint(...codePoints);\n};\n\n/**\n * Returns `true` if the given `codePoint` is a high surrogate.\n * @param codePoint The code point to be evaluated.\n *\n * Reference: https://en.wikipedia.org/wiki/UTF-16#Description\n */\nconst isHighSurrogate = (codePoint: number) =\u003e\n  codePoint \u003e= 0xd800 \u0026\u0026 codePoint \u003c= 0xdbff;\n\n/**\n * Returns `true` if the given `codePoint` is a low surrogate.\n * @param codePoint The code point to be evaluated.\n *\n * Reference: https://en.wikipedia.org/wiki/UTF-16#Description\n */\nconst isLowSurrogate = (codePoint: number) =\u003e\n  codePoint \u003e= 0xdc00 \u0026\u0026 codePoint \u003c= 0xdfff;\n\n/**\n * Decodes the given utf-16 values first and second using the specified\n * byte order.\n * @param first The first byte of the encoding.\n * @param second The second byte of the encoding.\n * @param byteOrder The byte order of the encoding.\n * Reference: https://en.wikipedia.org/wiki/UTF-16#Examples\n */\nconst decodeValues = (first: number, second: number, byteOrder: ByteOrder) =\u003e {\n  // Append the binary representation of the preceding byte by shifting the\n  // first one 8 to the left and than applying a bitwise or-operator to append\n  // the second one.\n  if (byteOrder === ByteOrder.LittleEndian) return (second \u003c\u003c 8) | first;\n  if (byteOrder === ByteOrder.BigEndian) return (first \u003c\u003c 8) | second;\n  throw new Error(`Invalid byteOrder: ${byteOrder}`);\n};\n\n/**\n * Returns whether the given array contains a byte order mark for the\n * UTF-16BE or UTF-16LE encoding. If it has neither, BigEndian is assumed.\n *\n * Reference: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-16\n *\n * @param bytes The byte array to be evaluated.\n */\n// prettier-ignore\nconst readBOM = (bytes: Uint8Array): ByteOrder =\u003e (\n    hasUtf16BigEndianBOM(bytes) ? ByteOrder.BigEndian\n  : hasUtf16LittleEndianBOM(bytes) ? ByteOrder.LittleEndian\n  : ByteOrder.BigEndian\n);\n\nconst hasUtf16BigEndianBOM = (bytes: Uint8Array) =\u003e\n  bytes[0] === 0xfe \u0026\u0026 bytes[1] === 0xff;\n\nconst hasUtf16LittleEndianBOM = (bytes: Uint8Array) =\u003e\n  bytes[0] === 0xff \u0026\u0026 bytes[1] === 0xfe;\n\nexport const hasUtf16BOM = (bytes: Uint8Array) =\u003e\n  hasUtf16BigEndianBOM(bytes) || hasUtf16LittleEndianBOM(bytes);\n","// tslint:disable radix\n\n/**\n * Converts a number to its string representation in decimal. This function\n * differs from simply converting a number to a string with `.toString()`\n * because this function's output string will **not** contain exponential\n * notation.\n *\n * Credit: https://stackoverflow.com/a/46545519\n */\nexport const numberToString = (num: number) =\u003e {\n  let numStr = String(num);\n\n  if (Math.abs(num) \u003c 1.0) {\n    const e = parseInt(num.toString().split('e-')[1]);\n    if (e) {\n      const negative = num \u003c 0;\n      if (negative) num *= -1;\n      num *= Math.pow(10, e - 1);\n      numStr = '0.' + new Array(e).join('0') + num.toString().substring(2);\n      if (negative) numStr = '-' + numStr;\n    }\n  } else {\n    let e = parseInt(num.toString().split('+')[1]);\n    if (e \u003e 20) {\n      e -= 20;\n      num /= Math.pow(10, e);\n      numStr = num.toString() + new Array(e + 1).join('0');\n    }\n  }\n\n  return numStr;\n};\n\nexport const sizeInBytes = (n: number) =\u003e Math.ceil(n.toString(2).length / 8);\n\n/**\n * Converts a number into its constituent bytes and returns them as\n * a number[].\n *\n * Returns most significant byte as first element in array. It may be necessary\n * to call .reverse() to get the bits in the desired order.\n *\n * Example:\n *   bytesFor(0x02A41E) =\u003e [ 0b10, 0b10100100, 0b11110 ]\n *\n * Credit for algorithm: https://stackoverflow.com/a/1936865\n */\nexport const bytesFor = (n: number) =\u003e {\n  const bytes = new Uint8Array(sizeInBytes(n));\n  for (let i = 1; i \u003c= bytes.length; i++) {\n    bytes[i - 1] = n \u003e\u003e ((bytes.length - i) * 8);\n  }\n  return bytes;\n};\n","export const error = (msg: string) =\u003e {\n  throw new Error(msg);\n};\n","import { FontNames } from '@pdf-lib/standard-fonts';\n\nexport const values = (obj: any) =\u003e Object.keys(obj).map((k) =\u003e obj[k]);\n\nexport const StandardFontValues = values(FontNames);\n\nexport const isStandardFont = (input: any): input is FontNames =\u003e\n  StandardFontValues.includes(input);\n\nexport const rectanglesAreEqual = (\n  a: { x: number; y: number; width: number; height: number },\n  b: { x: number; y: number; width: number; height: number },\n) =\u003e a.x === b.x \u0026\u0026 a.y === b.y \u0026\u0026 a.width === b.width \u0026\u0026 a.height === b.height;\n","/* tslint:disable:ban-types */\n\nimport { values as objectValues } from 'src/utils/objects';\n\nexport const backtick = (val: any) =\u003e `\\`${val}\\``;\nexport const singleQuote = (val: any) =\u003e `'${val}'`;\n\ntype Primitive = string | number | boolean | undefined | null;\n\n// prettier-ignore\nconst formatValue = (value: any) =\u003e {\n  const type = typeof value;\n  if (type ==='string') return singleQuote(value);\n  else if (type ==='undefined') return backtick(value);\n  else return value;\n};\n\nexport const createValueErrorMsg = (\n  value: any,\n  valueName: string,\n  values: Primitive[],\n) =\u003e {\n  const allowedValues = new Array(values.length);\n\n  for (let idx = 0, len = values.length; idx \u003c len; idx++) {\n    const v = values[idx];\n    allowedValues[idx] = formatValue(v);\n  }\n\n  const joinedValues = allowedValues.join(' or ');\n\n  // prettier-ignore\n  return `${backtick(valueName)} must be one of ${joinedValues}, but was actually ${formatValue(value)}`;\n};\n\nexport const assertIsOneOf = (\n  value: any,\n  valueName: string,\n  allowedValues: Primitive[] | { [key: string]: Primitive },\n) =\u003e {\n  if (!Array.isArray(allowedValues)) {\n    allowedValues = objectValues(allowedValues);\n  }\n  for (let idx = 0, len = allowedValues.length; idx \u003c len; idx++) {\n    if (value === allowedValues[idx]) return;\n  }\n  throw new TypeError(createValueErrorMsg(value, valueName, allowedValues));\n};\n\nexport const assertIsOneOfOrUndefined = (\n  value: any,\n  valueName: string,\n  allowedValues: Primitive[] | { [key: string]: Primitive },\n) =\u003e {\n  if (!Array.isArray(allowedValues)) {\n    allowedValues = objectValues(allowedValues);\n  }\n  assertIsOneOf(value, valueName, allowedValues.concat(undefined));\n};\n\nexport const assertIsSubset = (\n  values: any[],\n  valueName: string,\n  allowedValues: Primitive[] | { [key: string]: Primitive },\n) =\u003e {\n  if (!Array.isArray(allowedValues)) {\n    allowedValues = objectValues(allowedValues);\n  }\n  for (let idx = 0, len = values.length; idx \u003c len; idx++) {\n    assertIsOneOf(values[idx], valueName, allowedValues);\n  }\n};\n\nexport const getType = (val: any) =\u003e {\n  if (val === null) return 'null';\n  if (val === undefined) return 'undefined';\n  if (typeof val === 'string') return 'string';\n  if (isNaN(val)) return 'NaN';\n  if (typeof val === 'number') return 'number';\n  if (typeof val === 'boolean') return 'boolean';\n  if (typeof val === 'symbol') return 'symbol';\n  if (typeof val === 'bigint') return 'bigint';\n  if (val.constructor \u0026\u0026 val.constructor.name) return val.constructor.name;\n  if (val.name) return val.name;\n  if (val.constructor) return String(val.constructor);\n  return String(val);\n};\n\nexport type TypeDescriptor =\n  | 'null'\n  | 'undefined'\n  | 'string'\n  | 'number'\n  | 'boolean'\n  | 'symbol'\n  | 'bigint'\n  | DateConstructor\n  | ArrayConstructor\n  | Uint8ArrayConstructor\n  | ArrayBufferConstructor\n  | FunctionConstructor\n  | [Function, string];\n\nexport const isType = (value: any, type: TypeDescriptor) =\u003e {\n  if (type === 'null') return value === null;\n  if (type === 'undefined') return value === undefined;\n  if (type === 'string') return typeof value === 'string';\n  if (type === 'number') return typeof value === 'number' \u0026\u0026 !isNaN(value);\n  if (type === 'boolean') return typeof value === 'boolean';\n  if (type === 'symbol') return typeof value === 'symbol';\n  if (type === 'bigint') return typeof value === 'bigint';\n  if (type === Date) return value instanceof Date;\n  if (type === Array) return value instanceof Array;\n  if (type === Uint8Array) return value instanceof Uint8Array;\n  if (type === ArrayBuffer) return value instanceof ArrayBuffer;\n  if (type === Function) return value instanceof Function;\n  return value instanceof (type as [Function, string])[0];\n};\n\nexport const createTypeErrorMsg = (\n  value: any,\n  valueName: string,\n  types: TypeDescriptor[],\n) =\u003e {\n  const allowedTypes = new Array(types.length);\n\n  for (let idx = 0, len = types.length; idx \u003c len; idx++) {\n    const type = types[idx];\n    if (type === 'null') allowedTypes[idx] = backtick('null');\n    if (type === 'undefined') allowedTypes[idx] = backtick('undefined');\n    if (type === 'string') allowedTypes[idx] = backtick('string');\n    else if (type === 'number') allowedTypes[idx] = backtick('number');\n    else if (type === 'boolean') allowedTypes[idx] = backtick('boolean');\n    else if (type === 'symbol') allowedTypes[idx] = backtick('symbol');\n    else if (type === 'bigint') allowedTypes[idx] = backtick('bigint');\n    else if (type === Array) allowedTypes[idx] = backtick('Array');\n    else if (type === Uint8Array) allowedTypes[idx] = backtick('Uint8Array');\n    else if (type === ArrayBuffer) allowedTypes[idx] = backtick('ArrayBuffer');\n    else allowedTypes[idx] = backtick((type as [Function, string])[1]);\n  }\n\n  const joinedTypes = allowedTypes.join(' or ');\n\n  // prettier-ignore\n  return `${backtick(valueName)} must be of type ${joinedTypes}, but was actually of type ${backtick(getType(value))}`;\n};\n\nexport const assertIs = (\n  value: any,\n  valueName: string,\n  types: TypeDescriptor[],\n) =\u003e {\n  for (let idx = 0, len = types.length; idx \u003c len; idx++) {\n    if (isType(value, types[idx])) return;\n  }\n  throw new TypeError(createTypeErrorMsg(value, valueName, types));\n};\n\nexport const assertOrUndefined = (\n  value: any,\n  valueName: string,\n  types: TypeDescriptor[],\n) =\u003e {\n  assertIs(value, valueName, types.concat('undefined'));\n};\n\nexport const assertEachIs = (\n  values: any[],\n  valueName: string,\n  types: TypeDescriptor[],\n) =\u003e {\n  for (let idx = 0, len = values.length; idx \u003c len; idx++) {\n    assertIs(values[idx], valueName, types);\n  }\n};\n\nexport const assertRange = (\n  value: any,\n  valueName: string,\n  min: number,\n  max: number,\n) =\u003e {\n  assertIs(value, valueName, ['number']);\n  assertIs(min, 'min', ['number']);\n  assertIs(max, 'max', ['number']);\n  max = Math.max(min, max);\n  if (value \u003c min || value \u003e max) {\n    // prettier-ignore\n    throw new Error(`${backtick(valueName)} must be at least ${min} and at most ${max}, but was actually ${value}`);\n  }\n};\n\nexport const assertRangeOrUndefined = (\n  value: any,\n  valueName: string,\n  min: number,\n  max: number,\n) =\u003e {\n  assertIs(value, valueName, ['number', 'undefined']);\n  if (typeof value === 'number') assertRange(value, valueName, min, max);\n};\n\nexport const assertMultiple = (\n  value: any,\n  valueName: string,\n  multiplier: number,\n) =\u003e {\n  assertIs(value, valueName, ['number']);\n  if (value % multiplier !== 0) {\n    // prettier-ignore\n    throw new Error(`${backtick(valueName)} must be a multiple of ${multiplier}, but was actually ${value}`);\n  }\n};\n\nexport const assertInteger = (value: any, valueName: string) =\u003e {\n  if (!Number.isInteger(value)) {\n    throw new Error(\n      `${backtick(valueName)} must be an integer, but was actually ${value}`,\n    );\n  }\n};\n\nexport const assertPositive = (value: number, valueName: string) =\u003e {\n  if (![1, 0].includes(Math.sign(value))) {\n    // prettier-ignore\n    throw new Error(`${backtick(valueName)} must be a positive number or 0, but was actually ${value}`);\n  }\n};\n","import { toCharCode } from 'src/utils/strings';\n\n// Mapping from PDFDocEncoding to Unicode code point\nconst pdfDocEncodingToUnicode = new Uint16Array(256);\n\n// Initialize the code points which are the same\nfor (let idx = 0; idx \u003c 256; idx++) {\n  pdfDocEncodingToUnicode[idx] = idx;\n}\n\n// Set differences (see \"Table D.2 – PDFDocEncoding Character Set\" of the PDF spec)\npdfDocEncodingToUnicode[0x16] = toCharCode('\\u0017'); // SYNCRONOUS IDLE\npdfDocEncodingToUnicode[0x18] = toCharCode('\\u02D8'); // BREVE\npdfDocEncodingToUnicode[0x19] = toCharCode('\\u02C7'); // CARON\npdfDocEncodingToUnicode[0x1a] = toCharCode('\\u02C6'); // MODIFIER LETTER CIRCUMFLEX ACCENT\npdfDocEncodingToUnicode[0x1b] = toCharCode('\\u02D9'); // DOT ABOVE\npdfDocEncodingToUnicode[0x1c] = toCharCode('\\u02DD'); // DOUBLE ACUTE ACCENT\npdfDocEncodingToUnicode[0x1d] = toCharCode('\\u02DB'); // OGONEK\npdfDocEncodingToUnicode[0x1e] = toCharCode('\\u02DA'); // RING ABOVE\npdfDocEncodingToUnicode[0x1f] = toCharCode('\\u02DC'); // SMALL TILDE\npdfDocEncodingToUnicode[0x7f] = toCharCode('\\uFFFD'); // REPLACEMENT CHARACTER (box with questionmark)\npdfDocEncodingToUnicode[0x80] = toCharCode('\\u2022'); // BULLET\npdfDocEncodingToUnicode[0x81] = toCharCode('\\u2020'); // DAGGER\npdfDocEncodingToUnicode[0x82] = toCharCode('\\u2021'); // DOUBLE DAGGER\npdfDocEncodingToUnicode[0x83] = toCharCode('\\u2026'); // HORIZONTAL ELLIPSIS\npdfDocEncodingToUnicode[0x84] = toCharCode('\\u2014'); // EM DASH\npdfDocEncodingToUnicode[0x85] = toCharCode('\\u2013'); // EN DASH\npdfDocEncodingToUnicode[0x86] = toCharCode('\\u0192'); // LATIN SMALL LETTER SCRIPT F\npdfDocEncodingToUnicode[0x87] = toCharCode('\\u2044'); // FRACTION SLASH (solidus)\npdfDocEncodingToUnicode[0x88] = toCharCode('\\u2039'); // SINGLE LEFT-POINTING ANGLE QUOTATION MARK\npdfDocEncodingToUnicode[0x89] = toCharCode('\\u203A'); // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK\npdfDocEncodingToUnicode[0x8a] = toCharCode('\\u2212'); // MINUS SIGN\npdfDocEncodingToUnicode[0x8b] = toCharCode('\\u2030'); // PER MILLE SIGN\npdfDocEncodingToUnicode[0x8c] = toCharCode('\\u201E'); // DOUBLE LOW-9 QUOTATION MARK (quotedblbase)\npdfDocEncodingToUnicode[0x8d] = toCharCode('\\u201C'); // LEFT DOUBLE QUOTATION MARK (quotedblleft)\npdfDocEncodingToUnicode[0x8e] = toCharCode('\\u201D'); // RIGHT DOUBLE QUOTATION MARK (quotedblright)\npdfDocEncodingToUnicode[0x8f] = toCharCode('\\u2018'); // LEFT SINGLE QUOTATION MARK (quoteleft)\npdfDocEncodingToUnicode[0x90] = toCharCode('\\u2019'); // RIGHT SINGLE QUOTATION MARK (quoteright)\npdfDocEncodingToUnicode[0x91] = toCharCode('\\u201A'); // SINGLE LOW-9 QUOTATION MARK (quotesinglbase)\npdfDocEncodingToUnicode[0x92] = toCharCode('\\u2122'); // TRADE MARK SIGN\npdfDocEncodingToUnicode[0x93] = toCharCode('\\uFB01'); // LATIN SMALL LIGATURE FI\npdfDocEncodingToUnicode[0x94] = toCharCode('\\uFB02'); // LATIN SMALL LIGATURE FL\npdfDocEncodingToUnicode[0x95] = toCharCode('\\u0141'); // LATIN CAPITAL LETTER L WITH STROKE\npdfDocEncodingToUnicode[0x96] = toCharCode('\\u0152'); // LATIN CAPITAL LIGATURE OE\npdfDocEncodingToUnicode[0x97] = toCharCode('\\u0160'); // LATIN CAPITAL LETTER S WITH CARON\npdfDocEncodingToUnicode[0x98] = toCharCode('\\u0178'); // LATIN CAPITAL LETTER Y WITH DIAERESIS\npdfDocEncodingToUnicode[0x99] = toCharCode('\\u017D'); // LATIN CAPITAL LETTER Z WITH CARON\npdfDocEncodingToUnicode[0x9a] = toCharCode('\\u0131'); // LATIN SMALL LETTER DOTLESS I\npdfDocEncodingToUnicode[0x9b] = toCharCode('\\u0142'); // LATIN SMALL LETTER L WITH STROKE\npdfDocEncodingToUnicode[0x9c] = toCharCode('\\u0153'); // LATIN SMALL LIGATURE OE\npdfDocEncodingToUnicode[0x9d] = toCharCode('\\u0161'); // LATIN SMALL LETTER S WITH CARON\npdfDocEncodingToUnicode[0x9e] = toCharCode('\\u017E'); // LATIN SMALL LETTER Z WITH CARON\npdfDocEncodingToUnicode[0x9f] = toCharCode('\\uFFFD'); // REPLACEMENT CHARACTER (box with questionmark)\npdfDocEncodingToUnicode[0xa0] = toCharCode('\\u20AC'); // EURO SIGN\npdfDocEncodingToUnicode[0xad] = toCharCode('\\uFFFD'); // REPLACEMENT CHARACTER (box with questionmark)\n\n/**\n * Decode a byte array into a string using PDFDocEncoding.\n *\n * @param bytes a byte array (decimal representation) containing a string\n *              encoded with PDFDocEncoding.\n */\nexport const pdfDocEncodingDecode = (bytes: Uint8Array): string =\u003e {\n  const codePoints = new Array(bytes.length);\n  for (let idx = 0, len = bytes.length; idx \u003c len; idx++) {\n    codePoints[idx] = pdfDocEncodingToUnicode[bytes[idx]];\n  }\n  return String.fromCodePoint(...codePoints);\n};\n","class Cache\u003cT\u003e {\n  static readonly populatedBy = \u003cT\u003e(populate: () =\u003e T) =\u003e new Cache(populate);\n\n  private readonly populate: () =\u003e T;\n  private value: T | undefined;\n\n  private constructor(populate: () =\u003e T) {\n    this.populate = populate;\n    this.value = undefined;\n  }\n\n  getValue(): T | undefined {\n    return this.value;\n  }\n\n  access(): T {\n    if (!this.value) this.value = this.populate();\n    return this.value;\n  }\n\n  invalidate(): void {\n    this.value = undefined;\n  }\n}\n\nexport default Cache;\n","// tslint:disable: max-classes-per-file\nimport PDFObject from 'src/core/objects/PDFObject';\nimport { arrayAsString } from 'src/utils';\n\nexport class MethodNotImplementedError extends Error {\n  constructor(className: string, methodName: string) {\n    const msg = `Method ${className}.${methodName}() not implemented`;\n    super(msg);\n  }\n}\n\nexport class PrivateConstructorError extends Error {\n  constructor(className: string) {\n    const msg = `Cannot construct ${className} - it has a private constructor`;\n    super(msg);\n  }\n}\n\nexport class UnexpectedObjectTypeError extends Error {\n  constructor(expected: any | any[], actual: any) {\n    const name = (t: any) =\u003e t?.name ?? t?.constructor?.name;\n\n    const expectedTypes = Array.isArray(expected)\n      ? expected.map(name)\n      : [name(expected)];\n\n    const msg =\n      `Expected instance of ${expectedTypes.join(' or ')}, ` +\n      `but got instance of ${actual ? name(actual) : actual}`;\n\n    super(msg);\n  }\n}\n\nexport class UnsupportedEncodingError extends Error {\n  constructor(encoding: string) {\n    const msg = `${encoding} stream encoding not supported`;\n    super(msg);\n  }\n}\n\nexport class ReparseError extends Error {\n  constructor(className: string, methodName: string) {\n    const msg = `Cannot call ${className}.${methodName}() more than once`;\n    super(msg);\n  }\n}\n\nexport class MissingCatalogError extends Error {\n  constructor(ref?: PDFObject) {\n    const msg = `Missing catalog (ref=${ref})`;\n    super(msg);\n  }\n}\n\nexport class MissingPageContentsEmbeddingError extends Error {\n  constructor() {\n    const msg = `Can't embed page with missing Contents`;\n    super(msg);\n  }\n}\n\nexport class UnrecognizedStreamTypeError extends Error {\n  constructor(stream: any) {\n    const streamType = stream?.contructor?.name ?? stream?.name ?? stream;\n    const msg = `Unrecognized stream type: ${streamType}`;\n    super(msg);\n  }\n}\n\nexport class PageEmbeddingMismatchedContextError extends Error {\n  constructor() {\n    const msg = `Found mismatched contexts while embedding pages. All pages in the array passed to \\`PDFDocument.embedPages()\\` must be from the same document.`;\n    super(msg);\n  }\n}\n\nexport class PDFArrayIsNotRectangleError extends Error {\n  constructor(size: number) {\n    const msg = `Attempted to convert PDFArray with ${size} elements to rectangle, but must have exactly 4 elements.`;\n    super(msg);\n  }\n}\n\nexport class InvalidPDFDateStringError extends Error {\n  constructor(value: string) {\n    const msg = `Attempted to convert \"${value}\" to a date, but it does not match the PDF date string format.`;\n    super(msg);\n  }\n}\n\nexport class InvalidTargetIndexError extends Error {\n  constructor(targetIndex: number, Count: number) {\n    const msg = `Invalid targetIndex specified: targetIndex=${targetIndex} must be less than Count=${Count}`;\n    super(msg);\n  }\n}\n\nexport class CorruptPageTreeError extends Error {\n  constructor(targetIndex: number, operation: string) {\n    const msg = `Failed to ${operation} at targetIndex=${targetIndex} due to corrupt page tree: It is likely that one or more 'Count' entries are invalid`;\n    super(msg);\n  }\n}\n\nexport class IndexOutOfBoundsError extends Error {\n  constructor(index: number, min: number, max: number) {\n    const msg = `index should be at least ${min} and at most ${max}, but was actually ${index}`;\n    super(msg);\n  }\n}\n\nexport class InvalidAcroFieldValueError extends Error {\n  constructor() {\n    const msg = `Attempted to set invalid field value`;\n    super(msg);\n  }\n}\n\nexport class MultiSelectValueError extends Error {\n  constructor() {\n    const msg = `Attempted to select multiple values for single-select field`;\n    super(msg);\n  }\n}\n\nexport class MissingDAEntryError extends Error {\n  constructor(fieldName: string) {\n    const msg = `No /DA (default appearance) entry found for field: ${fieldName}`;\n    super(msg);\n  }\n}\n\nexport class MissingTfOperatorError extends Error {\n  constructor(fieldName: string) {\n    const msg = `No Tf operator found for DA of field: ${fieldName}`;\n    super(msg);\n  }\n}\n\n/***** Parser Errors ******/\n\nexport interface Position {\n  line: number;\n  column: number;\n  offset: number;\n}\n\nexport class NumberParsingError extends Error {\n  constructor(pos: Position, value: string) {\n    const msg =\n      `Failed to parse number ` +\n      `(line:${pos.line} col:${pos.column} offset=${pos.offset}): \"${value}\"`;\n    super(msg);\n  }\n}\n\nexport class PDFParsingError extends Error {\n  constructor(pos: Position, details: string) {\n    const msg =\n      `Failed to parse PDF document ` +\n      `(line:${pos.line} col:${pos.column} offset=${pos.offset}): ${details}`;\n    super(msg);\n  }\n}\n\nexport class NextByteAssertionError extends PDFParsingError {\n  constructor(pos: Position, expectedByte: number, actualByte: number) {\n    const msg = `Expected next byte to be ${expectedByte} but it was actually ${actualByte}`;\n    super(pos, msg);\n  }\n}\n\nexport class PDFObjectParsingError extends PDFParsingError {\n  constructor(pos: Position, byte: number) {\n    const msg = `Failed to parse PDF object starting with the following byte: ${byte}`;\n    super(pos, msg);\n  }\n}\n\nexport class PDFInvalidObjectParsingError extends PDFParsingError {\n  constructor(pos: Position) {\n    const msg = `Failed to parse invalid PDF object`;\n    super(pos, msg);\n  }\n}\n\nexport class PDFStreamParsingError extends PDFParsingError {\n  constructor(pos: Position) {\n    const msg = `Failed to parse PDF stream`;\n    super(pos, msg);\n  }\n}\n\nexport class UnbalancedParenthesisError extends PDFParsingError {\n  constructor(pos: Position) {\n    const msg = `Failed to parse PDF literal string due to unbalanced parenthesis`;\n    super(pos, msg);\n  }\n}\n\nexport class StalledParserError extends PDFParsingError {\n  constructor(pos: Position) {\n    const msg = `Parser stalled`;\n    super(pos, msg);\n  }\n}\n\nexport class MissingPDFHeaderError extends PDFParsingError {\n  constructor(pos: Position) {\n    const msg = `No PDF header found`;\n    super(pos, msg);\n  }\n}\n\nexport class MissingKeywordError extends PDFParsingError {\n  constructor(pos: Position, keyword: number[]) {\n    const msg = `Did not find expected keyword '${arrayAsString(keyword)}'`;\n    super(pos, msg);\n  }\n}\n","enum CharCodes {\n  Null = 0,\n  Backspace = 8,\n  Tab = 9,\n  Newline = 10,\n  FormFeed = 12,\n  CarriageReturn = 13,\n  Space = 32,\n  ExclamationPoint = 33,\n  Hash = 35,\n  Percent = 37,\n  LeftParen = 40,\n  RightParen = 41,\n  Plus = 43,\n  Minus = 45,\n  Dash = 45,\n  Period = 46,\n  ForwardSlash = 47,\n  Zero = 48,\n  One = 49,\n  Two = 50,\n  Three = 51,\n  Four = 52,\n  Five = 53,\n  Six = 54,\n  Seven = 55,\n  Eight = 56,\n  Nine = 57,\n  LessThan = 60,\n  GreaterThan = 62,\n  A = 65,\n  D = 68,\n  E = 69,\n  F = 70,\n  O = 79,\n  P = 80,\n  R = 82,\n  LeftSquareBracket = 91,\n  BackSlash = 92,\n  RightSquareBracket = 93,\n  a = 97,\n  b = 98,\n  d = 100,\n  e = 101,\n  f = 102,\n  i = 105,\n  j = 106,\n  l = 108,\n  m = 109,\n  n = 110,\n  o = 111,\n  r = 114,\n  s = 115,\n  t = 116,\n  u = 117,\n  x = 120,\n  LeftCurly = 123,\n  RightCurly = 125,\n  Tilde = 126,\n}\n\nexport default CharCodes;\n","import pako from 'pako';\n\nimport PDFHeader from 'src/core/document/PDFHeader';\nimport { UnexpectedObjectTypeError } from 'src/core/errors';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFBool from 'src/core/objects/PDFBool';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNull from 'src/core/objects/PDFNull';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFOperator from 'src/core/operators/PDFOperator';\nimport Ops from 'src/core/operators/PDFOperatorNames';\nimport PDFContentStream from 'src/core/structures/PDFContentStream';\nimport { typedArrayFor } from 'src/utils';\nimport { SimpleRNG } from 'src/utils/rng';\n\ntype LookupKey = PDFRef | PDFObject | undefined;\n\ninterface LiteralObject {\n  [name: string]: Literal | PDFObject;\n}\n\ninterface LiteralArray {\n  [index: number]: Literal | PDFObject;\n}\n\ntype Literal =\n  | LiteralObject\n  | LiteralArray\n  | string\n  | number\n  | boolean\n  | null\n  | undefined;\n\nconst byAscendingObjectNumber = (\n  [a]: [PDFRef, PDFObject],\n  [b]: [PDFRef, PDFObject],\n) =\u003e a.objectNumber - b.objectNumber;\n\nclass PDFContext {\n  static create = () =\u003e new PDFContext();\n\n  largestObjectNumber: number;\n  header: PDFHeader;\n  trailerInfo: {\n    Root?: PDFObject;\n    Encrypt?: PDFObject;\n    Info?: PDFObject;\n    ID?: PDFObject;\n  };\n  rng: SimpleRNG;\n\n  private readonly indirectObjects: Map\u003cPDFRef, PDFObject\u003e;\n\n  private pushGraphicsStateContentStreamRef?: PDFRef;\n  private popGraphicsStateContentStreamRef?: PDFRef;\n\n  private constructor() {\n    this.largestObjectNumber = 0;\n    this.header = PDFHeader.forVersion(1, 7);\n    this.trailerInfo = {};\n\n    this.indirectObjects = new Map();\n    this.rng = SimpleRNG.withSeed(1);\n  }\n\n  assign(ref: PDFRef, object: PDFObject): void {\n    this.indirectObjects.set(ref, object);\n    if (ref.objectNumber \u003e this.largestObjectNumber) {\n      this.largestObjectNumber = ref.objectNumber;\n    }\n  }\n\n  nextRef(): PDFRef {\n    this.largestObjectNumber += 1;\n    return PDFRef.of(this.largestObjectNumber);\n  }\n\n  register(object: PDFObject): PDFRef {\n    const ref = this.nextRef();\n    this.assign(ref, object);\n    return ref;\n  }\n\n  delete(ref: PDFRef): boolean {\n    return this.indirectObjects.delete(ref);\n  }\n\n  lookupMaybe(ref: LookupKey, type: typeof PDFArray): PDFArray | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFBool): PDFBool | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFDict): PDFDict | undefined;\n  lookupMaybe(\n    ref: LookupKey,\n    type: typeof PDFHexString,\n  ): PDFHexString | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFName): PDFName | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFNull): typeof PDFNull | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFNumber): PDFNumber | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFStream): PDFStream | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFRef): PDFRef | undefined;\n  lookupMaybe(ref: LookupKey, type: typeof PDFString): PDFString | undefined;\n  lookupMaybe(\n    ref: LookupKey,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n  ): PDFString | PDFHexString | undefined;\n\n  lookupMaybe(ref: LookupKey, ...types: any[]) {\n    // TODO: `preservePDFNull` is for backwards compatibility. Should be\n    // removed in next breaking API change.\n    const preservePDFNull = types.includes(PDFNull);\n\n    const result = ref instanceof PDFRef ? this.indirectObjects.get(ref) : ref;\n\n    if (!result || (result === PDFNull \u0026\u0026 !preservePDFNull)) return undefined;\n\n    for (let idx = 0, len = types.length; idx \u003c len; idx++) {\n      const type = types[idx];\n      if (type === PDFNull) {\n        if (result === PDFNull) return result;\n      } else {\n        if (result instanceof type) return result;\n      }\n    }\n    throw new UnexpectedObjectTypeError(types, result);\n  }\n\n  lookup(ref: LookupKey): PDFObject | undefined;\n  lookup(ref: LookupKey, type: typeof PDFArray): PDFArray;\n  lookup(ref: LookupKey, type: typeof PDFBool): PDFBool;\n  lookup(ref: LookupKey, type: typeof PDFDict): PDFDict;\n  lookup(ref: LookupKey, type: typeof PDFHexString): PDFHexString;\n  lookup(ref: LookupKey, type: typeof PDFName): PDFName;\n  lookup(ref: LookupKey, type: typeof PDFNull): typeof PDFNull;\n  lookup(ref: LookupKey, type: typeof PDFNumber): PDFNumber;\n  lookup(ref: LookupKey, type: typeof PDFStream): PDFStream;\n  lookup(ref: LookupKey, type: typeof PDFRef): PDFRef;\n  lookup(ref: LookupKey, type: typeof PDFString): PDFString;\n  lookup(\n    ref: LookupKey,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n  ): PDFString | PDFHexString;\n\n  lookup(ref: LookupKey, ...types: any[]) {\n    const result = ref instanceof PDFRef ? this.indirectObjects.get(ref) : ref;\n\n    if (types.length === 0) return result;\n\n    for (let idx = 0, len = types.length; idx \u003c len; idx++) {\n      const type = types[idx];\n      if (type === PDFNull) {\n        if (result === PDFNull) return result;\n      } else {\n        if (result instanceof type) return result;\n      }\n    }\n\n    throw new UnexpectedObjectTypeError(types, result);\n  }\n\n  getObjectRef(pdfObject: PDFObject): PDFRef | undefined {\n    const entries = Array.from(this.indirectObjects.entries());\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [ref, object] = entries[idx];\n      if (object === pdfObject) {\n        return ref;\n      }\n    }\n\n    return undefined;\n  }\n\n  enumerateIndirectObjects(): [PDFRef, PDFObject][] {\n    return Array.from(this.indirectObjects.entries()).sort(\n      byAscendingObjectNumber,\n    );\n  }\n\n  obj(literal: null | undefined): typeof PDFNull;\n  obj(literal: string): PDFName;\n  obj(literal: number): PDFNumber;\n  obj(literal: boolean): PDFBool;\n  obj(literal: LiteralObject): PDFDict;\n  obj(literal: LiteralArray): PDFArray;\n\n  obj(literal: Literal) {\n    if (literal instanceof PDFObject) {\n      return literal;\n    } else if (literal === null || literal === undefined) {\n      return PDFNull;\n    } else if (typeof literal === 'string') {\n      return PDFName.of(literal);\n    } else if (typeof literal === 'number') {\n      return PDFNumber.of(literal);\n    } else if (typeof literal === 'boolean') {\n      return literal ? PDFBool.True : PDFBool.False;\n    } else if (Array.isArray(literal)) {\n      const array = PDFArray.withContext(this);\n      for (let idx = 0, len = literal.length; idx \u003c len; idx++) {\n        array.push(this.obj(literal[idx]));\n      }\n      return array;\n    } else {\n      const dict = PDFDict.withContext(this);\n      const keys = Object.keys(literal);\n      for (let idx = 0, len = keys.length; idx \u003c len; idx++) {\n        const key = keys[idx];\n        const value = (literal as LiteralObject)[key] as any;\n        if (value !== undefined) dict.set(PDFName.of(key), this.obj(value));\n      }\n      return dict;\n    }\n  }\n\n  stream(\n    contents: string | Uint8Array,\n    dict: LiteralObject = {},\n  ): PDFRawStream {\n    return PDFRawStream.of(this.obj(dict), typedArrayFor(contents));\n  }\n\n  flateStream(\n    contents: string | Uint8Array,\n    dict: LiteralObject = {},\n  ): PDFRawStream {\n    return this.stream(pako.deflate(typedArrayFor(contents)), {\n      ...dict,\n      Filter: 'FlateDecode',\n    });\n  }\n\n  contentStream(\n    operators: PDFOperator[],\n    dict: LiteralObject = {},\n  ): PDFContentStream {\n    return PDFContentStream.of(this.obj(dict), operators);\n  }\n\n  formXObject(\n    operators: PDFOperator[],\n    dict: LiteralObject = {},\n  ): PDFContentStream {\n    return this.contentStream(operators, {\n      BBox: this.obj([0, 0, 0, 0]),\n      Matrix: this.obj([1, 0, 0, 1, 0, 0]),\n      ...dict,\n      Type: 'XObject',\n      Subtype: 'Form',\n    });\n  }\n\n  /*\n   * Reference to PDFContentStream that contains a single PDFOperator: `q`.\n   * Used by [[PDFPageLeaf]] instances to ensure that when content streams are\n   * added to a modified PDF, they start in the default, unchanged graphics\n   * state.\n   */\n  getPushGraphicsStateContentStream(): PDFRef {\n    if (this.pushGraphicsStateContentStreamRef) {\n      return this.pushGraphicsStateContentStreamRef;\n    }\n    const dict = this.obj({});\n    const op = PDFOperator.of(Ops.PushGraphicsState);\n    const stream = PDFContentStream.of(dict, [op]);\n    this.pushGraphicsStateContentStreamRef = this.register(stream);\n    return this.pushGraphicsStateContentStreamRef;\n  }\n\n  /*\n   * Reference to PDFContentStream that contains a single PDFOperator: `Q`.\n   * Used by [[PDFPageLeaf]] instances to ensure that when content streams are\n   * added to a modified PDF, they start in the default, unchanged graphics\n   * state.\n   */\n  getPopGraphicsStateContentStream(): PDFRef {\n    if (this.popGraphicsStateContentStreamRef) {\n      return this.popGraphicsStateContentStreamRef;\n    }\n    const dict = this.obj({});\n    const op = PDFOperator.of(Ops.PopGraphicsState);\n    const stream = PDFContentStream.of(dict, [op]);\n    this.popGraphicsStateContentStreamRef = this.register(stream);\n    return this.popGraphicsStateContentStreamRef;\n  }\n\n  addRandomSuffix(prefix: string, suffixLength = 4): string {\n    return `${prefix}-${Math.floor(this.rng.nextInt() * 10 ** suffixLength)}`;\n  }\n}\n\nexport default PDFContext;\n","import CharCodes from 'src/core/syntax/CharCodes';\nimport { charFromCode, copyStringIntoBuffer } from 'src/utils';\n\nclass PDFHeader {\n  static forVersion = (major: number, minor: number) =\u003e\n    new PDFHeader(major, minor);\n\n  private readonly major: string;\n  private readonly minor: string;\n\n  private constructor(major: number, minor: number) {\n    this.major = String(major);\n    this.minor = String(minor);\n  }\n\n  toString(): string {\n    const bc = charFromCode(129);\n    return `%PDF-${this.major}.${this.minor}\\n%${bc}${bc}${bc}${bc}`;\n  }\n\n  sizeInBytes(): number {\n    return 12 + this.major.length + this.minor.length;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const initialOffset = offset;\n\n    buffer[offset++] = CharCodes.Percent;\n    buffer[offset++] = CharCodes.P;\n    buffer[offset++] = CharCodes.D;\n    buffer[offset++] = CharCodes.F;\n    buffer[offset++] = CharCodes.Dash;\n\n    offset += copyStringIntoBuffer(this.major, buffer, offset);\n    buffer[offset++] = CharCodes.Period;\n    offset += copyStringIntoBuffer(this.minor, buffer, offset);\n    buffer[offset++] = CharCodes.Newline;\n\n    buffer[offset++] = CharCodes.Percent;\n    buffer[offset++] = 129;\n    buffer[offset++] = 129;\n    buffer[offset++] = 129;\n    buffer[offset++] = 129;\n\n    return offset - initialOffset;\n  }\n}\n\nexport default PDFHeader;\n","import { MethodNotImplementedError } from 'src/core/errors';\nimport PDFContext from 'src/core/PDFContext';\n\nclass PDFObject {\n  clone(_context?: PDFContext): PDFObject {\n    throw new MethodNotImplementedError(this.constructor.name, 'clone');\n  }\n\n  toString(): string {\n    throw new MethodNotImplementedError(this.constructor.name, 'toString');\n  }\n\n  sizeInBytes(): number {\n    throw new MethodNotImplementedError(this.constructor.name, 'sizeInBytes');\n  }\n\n  copyBytesInto(_buffer: Uint8Array, _offset: number): number {\n    throw new MethodNotImplementedError(this.constructor.name, 'copyBytesInto');\n  }\n}\n\nexport default PDFObject;\n","import { copyStringIntoBuffer, numberToString } from 'src/utils/index';\n\nimport PDFObject from 'src/core/objects/PDFObject';\n\nclass PDFNumber extends PDFObject {\n  static of = (value: number) =\u003e new PDFNumber(value);\n\n  private readonly numberValue: number;\n  private readonly stringValue: string;\n\n  private constructor(value: number) {\n    super();\n    this.numberValue = value;\n    this.stringValue = numberToString(value);\n  }\n\n  asNumber(): number {\n    return this.numberValue;\n  }\n\n  /** @deprecated in favor of [[PDFNumber.asNumber]] */\n  value(): number {\n    return this.numberValue;\n  }\n\n  clone(): PDFNumber {\n    return PDFNumber.of(this.numberValue);\n  }\n\n  toString(): string {\n    return this.stringValue;\n  }\n\n  sizeInBytes(): number {\n    return this.stringValue.length;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    offset += copyStringIntoBuffer(this.stringValue, buffer, offset);\n    return this.stringValue.length;\n  }\n}\n\nexport default PDFNumber;\n","import PDFBool from 'src/core/objects/PDFBool';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNull from 'src/core/objects/PDFNull';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFContext from 'src/core/PDFContext';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { PDFArrayIsNotRectangleError } from 'src/core/errors';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\n\nclass PDFArray extends PDFObject {\n  static withContext = (context: PDFContext) =\u003e new PDFArray(context);\n\n  private readonly array: PDFObject[];\n  private readonly context: PDFContext;\n\n  private constructor(context: PDFContext) {\n    super();\n    this.array = [];\n    this.context = context;\n  }\n\n  size(): number {\n    return this.array.length;\n  }\n\n  push(object: PDFObject): void {\n    this.array.push(object);\n  }\n\n  insert(index: number, object: PDFObject): void {\n    this.array.splice(index, 0, object);\n  }\n\n  indexOf(object: PDFObject): number | undefined {\n    const index = this.array.indexOf(object);\n    return index === -1 ? undefined : index;\n  }\n\n  remove(index: number): void {\n    this.array.splice(index, 1);\n  }\n\n  set(idx: number, object: PDFObject): void {\n    this.array[idx] = object;\n  }\n\n  get(index: number): PDFObject {\n    return this.array[index];\n  }\n\n  lookupMaybe(index: number, type: typeof PDFArray): PDFArray | undefined;\n  lookupMaybe(index: number, type: typeof PDFBool): PDFBool | undefined;\n  lookupMaybe(index: number, type: typeof PDFDict): PDFDict | undefined;\n  lookupMaybe(\n    index: number,\n    type: typeof PDFHexString,\n  ): PDFHexString | undefined;\n  lookupMaybe(index: number, type: typeof PDFName): PDFName | undefined;\n  lookupMaybe(index: number, type: typeof PDFNull): typeof PDFNull | undefined;\n  lookupMaybe(index: number, type: typeof PDFNumber): PDFNumber | undefined;\n  lookupMaybe(index: number, type: typeof PDFStream): PDFStream | undefined;\n  lookupMaybe(\n    index: number,\n    type: typeof PDFRawStream,\n  ): PDFRawStream | undefined;\n  lookupMaybe(index: number, type: typeof PDFRef): PDFRef | undefined;\n  lookupMaybe(index: number, type: typeof PDFString): PDFString | undefined;\n  lookupMaybe(\n    index: number,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n  ): PDFString | PDFHexString | undefined;\n\n  lookupMaybe(index: number, ...types: any[]) {\n    return this.context.lookupMaybe(\n      this.get(index),\n      // @ts-ignore\n      ...types,\n    ) as any;\n  }\n\n  lookup(index: number): PDFObject | undefined;\n  lookup(index: number, type: typeof PDFArray): PDFArray;\n  lookup(index: number, type: typeof PDFBool): PDFBool;\n  lookup(index: number, type: typeof PDFDict): PDFDict;\n  lookup(index: number, type: typeof PDFHexString): PDFHexString;\n  lookup(index: number, type: typeof PDFName): PDFName;\n  lookup(index: number, type: typeof PDFNull): typeof PDFNull;\n  lookup(index: number, type: typeof PDFNumber): PDFNumber;\n  lookup(index: number, type: typeof PDFStream): PDFStream;\n  lookup(index: number, type: typeof PDFRawStream): PDFRawStream;\n  lookup(index: number, type: typeof PDFRef): PDFRef;\n  lookup(index: number, type: typeof PDFString): PDFString;\n  lookup(\n    index: number,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n  ): PDFString | PDFHexString;\n\n  lookup(index: number, ...types: any[]) {\n    return this.context.lookup(\n      this.get(index),\n      // @ts-ignore\n      ...types,\n    ) as any;\n  }\n\n  asRectangle(): { x: number; y: number; width: number; height: number } {\n    if (this.size() !== 4) throw new PDFArrayIsNotRectangleError(this.size());\n\n    const lowerLeftX = this.lookup(0, PDFNumber).asNumber();\n    const lowerLeftY = this.lookup(1, PDFNumber).asNumber();\n    const upperRightX = this.lookup(2, PDFNumber).asNumber();\n    const upperRightY = this.lookup(3, PDFNumber).asNumber();\n\n    const x = lowerLeftX;\n    const y = lowerLeftY;\n    const width = upperRightX - lowerLeftX;\n    const height = upperRightY - lowerLeftY;\n\n    return { x, y, width, height };\n  }\n\n  asArray(): PDFObject[] {\n    return this.array.slice();\n  }\n\n  clone(context?: PDFContext): PDFArray {\n    const clone = PDFArray.withContext(context || this.context);\n    for (let idx = 0, len = this.size(); idx \u003c len; idx++) {\n      clone.push(this.array[idx]);\n    }\n    return clone;\n  }\n\n  toString(): string {\n    let arrayString = '[ ';\n    for (let idx = 0, len = this.size(); idx \u003c len; idx++) {\n      arrayString += this.get(idx).toString();\n      arrayString += ' ';\n    }\n    arrayString += ']';\n    return arrayString;\n  }\n\n  sizeInBytes(): number {\n    let size = 3;\n    for (let idx = 0, len = this.size(); idx \u003c len; idx++) {\n      size += this.get(idx).sizeInBytes() + 1;\n    }\n    return size;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const initialOffset = offset;\n\n    buffer[offset++] = CharCodes.LeftSquareBracket;\n    buffer[offset++] = CharCodes.Space;\n    for (let idx = 0, len = this.size(); idx \u003c len; idx++) {\n      offset += this.get(idx).copyBytesInto(buffer, offset);\n      buffer[offset++] = CharCodes.Space;\n    }\n    buffer[offset++] = CharCodes.RightSquareBracket;\n\n    return offset - initialOffset;\n  }\n\n  scalePDFNumbers(x: number, y: number): void {\n    for (let idx = 0, len = this.size(); idx \u003c len; idx++) {\n      const el = this.lookup(idx);\n      if (el instanceof PDFNumber) {\n        const factor = idx % 2 === 0 ? x : y;\n        this.set(idx, PDFNumber.of(el.asNumber() * factor));\n      }\n    }\n  }\n}\n\nexport default PDFArray;\n","import { PrivateConstructorError } from 'src/core/errors';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport CharCodes from 'src/core/syntax/CharCodes';\n\nconst ENFORCER = {};\n\nclass PDFBool extends PDFObject {\n  static readonly True = new PDFBool(ENFORCER, true);\n  static readonly False = new PDFBool(ENFORCER, false);\n\n  private readonly value: boolean;\n\n  private constructor(enforcer: any, value: boolean) {\n    if (enforcer !== ENFORCER) throw new PrivateConstructorError('PDFBool');\n    super();\n    this.value = value;\n  }\n\n  asBoolean(): boolean {\n    return this.value;\n  }\n\n  clone(): PDFBool {\n    return this;\n  }\n\n  toString(): string {\n    return String(this.value);\n  }\n\n  sizeInBytes(): number {\n    return this.value ? 4 : 5;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    if (this.value) {\n      buffer[offset++] = CharCodes.t;\n      buffer[offset++] = CharCodes.r;\n      buffer[offset++] = CharCodes.u;\n      buffer[offset++] = CharCodes.e;\n      return 4;\n    } else {\n      buffer[offset++] = CharCodes.f;\n      buffer[offset++] = CharCodes.a;\n      buffer[offset++] = CharCodes.l;\n      buffer[offset++] = CharCodes.s;\n      buffer[offset++] = CharCodes.e;\n      return 5;\n    }\n  }\n}\n\nexport default PDFBool;\n","import CharCodes from 'src/core/syntax/CharCodes';\n\nexport const IsDelimiter = new Uint8Array(256);\n\nIsDelimiter[CharCodes.LeftParen] = 1;\nIsDelimiter[CharCodes.RightParen] = 1;\nIsDelimiter[CharCodes.LessThan] = 1;\nIsDelimiter[CharCodes.GreaterThan] = 1;\nIsDelimiter[CharCodes.LeftSquareBracket] = 1;\nIsDelimiter[CharCodes.RightSquareBracket] = 1;\nIsDelimiter[CharCodes.LeftCurly] = 1;\nIsDelimiter[CharCodes.RightCurly] = 1;\nIsDelimiter[CharCodes.ForwardSlash] = 1;\nIsDelimiter[CharCodes.Percent] = 1;\n","import CharCodes from 'src/core/syntax/CharCodes';\n\nexport const IsWhitespace = new Uint8Array(256);\n\nIsWhitespace[CharCodes.Null] = 1;\nIsWhitespace[CharCodes.Tab] = 1;\nIsWhitespace[CharCodes.Newline] = 1;\nIsWhitespace[CharCodes.FormFeed] = 1;\nIsWhitespace[CharCodes.CarriageReturn] = 1;\nIsWhitespace[CharCodes.Space] = 1;\n","import CharCodes from 'src/core/syntax/CharCodes';\nimport { IsDelimiter } from 'src/core/syntax/Delimiters';\nimport { IsWhitespace } from 'src/core/syntax/Whitespace';\n\nexport const IsIrregular = new Uint8Array(256);\n\nfor (let idx = 0, len = 256; idx \u003c len; idx++) {\n  IsIrregular[idx] = IsWhitespace[idx] || IsDelimiter[idx] ? 1 : 0;\n}\nIsIrregular[CharCodes.Hash] = 1;\n","import { PrivateConstructorError } from 'src/core/errors';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { IsIrregular } from 'src/core/syntax/Irregular';\nimport {\n  charFromHexCode,\n  copyStringIntoBuffer,\n  toCharCode,\n  toHexString,\n} from 'src/utils';\n\nconst decodeName = (name: string) =\u003e\n  name.replace(/#([\\dABCDEF]{2})/g, (_, hex) =\u003e charFromHexCode(hex));\n\nconst isRegularChar = (charCode: number) =\u003e\n  charCode \u003e= CharCodes.ExclamationPoint \u0026\u0026\n  charCode \u003c= CharCodes.Tilde \u0026\u0026\n  !IsIrregular[charCode];\n\nconst ENFORCER = {};\nconst pool = new Map\u003cstring, PDFName\u003e();\n\nclass PDFName extends PDFObject {\n  static of = (name: string): PDFName =\u003e {\n    const decodedValue = decodeName(name);\n\n    let instance = pool.get(decodedValue);\n    if (!instance) {\n      instance = new PDFName(ENFORCER, decodedValue);\n      pool.set(decodedValue, instance);\n    }\n\n    return instance;\n  };\n\n  /* tslint:disable member-ordering */\n  static readonly Length = PDFName.of('Length');\n  static readonly FlateDecode = PDFName.of('FlateDecode');\n  static readonly Resources = PDFName.of('Resources');\n  static readonly Font = PDFName.of('Font');\n  static readonly XObject = PDFName.of('XObject');\n  static readonly ExtGState = PDFName.of('ExtGState');\n  static readonly Contents = PDFName.of('Contents');\n  static readonly Type = PDFName.of('Type');\n  static readonly Parent = PDFName.of('Parent');\n  static readonly MediaBox = PDFName.of('MediaBox');\n  static readonly Page = PDFName.of('Page');\n  static readonly Annots = PDFName.of('Annots');\n  static readonly TrimBox = PDFName.of('TrimBox');\n  static readonly ArtBox = PDFName.of('ArtBox');\n  static readonly BleedBox = PDFName.of('BleedBox');\n  static readonly CropBox = PDFName.of('CropBox');\n  static readonly Rotate = PDFName.of('Rotate');\n  static readonly Title = PDFName.of('Title');\n  static readonly Author = PDFName.of('Author');\n  static readonly Subject = PDFName.of('Subject');\n  static readonly Creator = PDFName.of('Creator');\n  static readonly Keywords = PDFName.of('Keywords');\n  static readonly Producer = PDFName.of('Producer');\n  static readonly CreationDate = PDFName.of('CreationDate');\n  static readonly ModDate = PDFName.of('ModDate');\n  /* tslint:enable member-ordering */\n\n  private readonly encodedName: string;\n\n  private constructor(enforcer: any, name: string) {\n    if (enforcer !== ENFORCER) throw new PrivateConstructorError('PDFName');\n    super();\n\n    let encodedName = '/';\n    for (let idx = 0, len = name.length; idx \u003c len; idx++) {\n      const character = name[idx];\n      const code = toCharCode(character);\n      encodedName += isRegularChar(code) ? character : `#${toHexString(code)}`;\n    }\n\n    this.encodedName = encodedName;\n  }\n\n  asBytes(): Uint8Array {\n    const bytes: number[] = [];\n\n    let hex = '';\n    let escaped = false;\n\n    const pushByte = (byte?: number) =\u003e {\n      if (byte !== undefined) bytes.push(byte);\n      escaped = false;\n    };\n\n    for (let idx = 1, len = this.encodedName.length; idx \u003c len; idx++) {\n      const char = this.encodedName[idx];\n      const byte = toCharCode(char);\n      const nextChar = this.encodedName[idx + 1];\n      if (!escaped) {\n        if (byte === CharCodes.Hash) escaped = true;\n        else pushByte(byte);\n      } else {\n        if (\n          (byte \u003e= CharCodes.Zero \u0026\u0026 byte \u003c= CharCodes.Nine) ||\n          (byte \u003e= CharCodes.a \u0026\u0026 byte \u003c= CharCodes.f) ||\n          (byte \u003e= CharCodes.A \u0026\u0026 byte \u003c= CharCodes.F)\n        ) {\n          hex += char;\n          if (\n            hex.length === 2 ||\n            !(\n              (nextChar \u003e= '0' \u0026\u0026 nextChar \u003c= '9') ||\n              (nextChar \u003e= 'a' \u0026\u0026 nextChar \u003c= 'f') ||\n              (nextChar \u003e= 'A' \u0026\u0026 nextChar \u003c= 'F')\n            )\n          ) {\n            pushByte(parseInt(hex, 16));\n            hex = '';\n          }\n        } else {\n          pushByte(byte);\n        }\n      }\n    }\n\n    return new Uint8Array(bytes);\n  }\n\n  // TODO: This should probably use `utf8Decode()`\n  // TODO: Polyfill Array.from?\n  decodeText(): string {\n    const bytes = this.asBytes();\n    return String.fromCharCode(...Array.from(bytes));\n  }\n\n  asString(): string {\n    return this.encodedName;\n  }\n\n  /** @deprecated in favor of [[PDFName.asString]] */\n  value(): string {\n    return this.encodedName;\n  }\n\n  clone(): PDFName {\n    return this;\n  }\n\n  toString(): string {\n    return this.encodedName;\n  }\n\n  sizeInBytes(): number {\n    return this.encodedName.length;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    offset += copyStringIntoBuffer(this.encodedName, buffer, offset);\n    return this.encodedName.length;\n  }\n}\n\nexport default PDFName;\n","import PDFObject from 'src/core/objects/PDFObject';\nimport CharCodes from 'src/core/syntax/CharCodes';\n\nclass PDFNull extends PDFObject {\n  asNull(): null {\n    return null;\n  }\n\n  clone(): PDFNull {\n    return this;\n  }\n\n  toString(): string {\n    return 'null';\n  }\n\n  sizeInBytes(): number {\n    return 4;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    buffer[offset++] = CharCodes.n;\n    buffer[offset++] = CharCodes.u;\n    buffer[offset++] = CharCodes.l;\n    buffer[offset++] = CharCodes.l;\n    return 4;\n  }\n}\n\nexport default new PDFNull();\n","import PDFArray from 'src/core/objects/PDFArray';\nimport PDFBool from 'src/core/objects/PDFBool';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNull from 'src/core/objects/PDFNull';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFContext from 'src/core/PDFContext';\nimport CharCodes from 'src/core/syntax/CharCodes';\n\nexport type DictMap = Map\u003cPDFName, PDFObject\u003e;\n\nclass PDFDict extends PDFObject {\n  static withContext = (context: PDFContext) =\u003e new PDFDict(new Map(), context);\n\n  static fromMapWithContext = (map: DictMap, context: PDFContext) =\u003e\n    new PDFDict(map, context);\n\n  readonly context: PDFContext;\n\n  private readonly dict: DictMap;\n\n  protected constructor(map: DictMap, context: PDFContext) {\n    super();\n    this.dict = map;\n    this.context = context;\n  }\n\n  keys(): PDFName[] {\n    return Array.from(this.dict.keys());\n  }\n\n  values(): PDFObject[] {\n    return Array.from(this.dict.values());\n  }\n\n  entries(): [PDFName, PDFObject][] {\n    return Array.from(this.dict.entries());\n  }\n\n  set(key: PDFName, value: PDFObject): void {\n    this.dict.set(key, value);\n  }\n\n  get(\n    key: PDFName,\n    // TODO: `preservePDFNull` is for backwards compatibility. Should be\n    // removed in next breaking API change.\n    preservePDFNull = false,\n  ): PDFObject | undefined {\n    const value = this.dict.get(key);\n    if (value === PDFNull \u0026\u0026 !preservePDFNull) return undefined;\n    return value;\n  }\n\n  has(key: PDFName): boolean {\n    const value = this.dict.get(key);\n    return value !== undefined \u0026\u0026 value !== PDFNull;\n  }\n\n  lookupMaybe(key: PDFName, type: typeof PDFArray): PDFArray | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFBool): PDFBool | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFDict): PDFDict | undefined;\n  lookupMaybe(\n    key: PDFName,\n    type: typeof PDFHexString,\n  ): PDFHexString | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFName): PDFName | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFNull): typeof PDFNull | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFNumber): PDFNumber | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFStream): PDFStream | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFRef): PDFRef | undefined;\n  lookupMaybe(key: PDFName, type: typeof PDFString): PDFString | undefined;\n  lookupMaybe(\n    ref: PDFName,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n  ): PDFString | PDFHexString | undefined;\n  lookupMaybe(\n    ref: PDFName,\n    type1: typeof PDFDict,\n    type2: typeof PDFStream,\n  ): PDFDict | PDFStream | undefined;\n  lookupMaybe(\n    ref: PDFName,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n    type3: typeof PDFArray,\n  ): PDFString | PDFHexString | PDFArray | undefined;\n\n  lookupMaybe(key: PDFName, ...types: any[]) {\n    // TODO: `preservePDFNull` is for backwards compatibility. Should be\n    // removed in next breaking API change.\n    const preservePDFNull = types.includes(PDFNull);\n\n    const value = this.context.lookupMaybe(\n      this.get(key, preservePDFNull),\n      // @ts-ignore\n      ...types,\n    ) as any;\n\n    if (value === PDFNull \u0026\u0026 !preservePDFNull) return undefined;\n\n    return value;\n  }\n\n  lookup(key: PDFName): PDFObject | undefined;\n  lookup(key: PDFName, type: typeof PDFArray): PDFArray;\n  lookup(key: PDFName, type: typeof PDFBool): PDFBool;\n  lookup(key: PDFName, type: typeof PDFDict): PDFDict;\n  lookup(key: PDFName, type: typeof PDFHexString): PDFHexString;\n  lookup(key: PDFName, type: typeof PDFName): PDFName;\n  lookup(key: PDFName, type: typeof PDFNull): typeof PDFNull;\n  lookup(key: PDFName, type: typeof PDFNumber): PDFNumber;\n  lookup(key: PDFName, type: typeof PDFStream): PDFStream;\n  lookup(key: PDFName, type: typeof PDFRef): PDFRef;\n  lookup(key: PDFName, type: typeof PDFString): PDFString;\n  lookup(\n    ref: PDFName,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n  ): PDFString | PDFHexString;\n  lookup(\n    ref: PDFName,\n    type1: typeof PDFDict,\n    type2: typeof PDFStream,\n  ): PDFDict | PDFStream;\n  lookup(\n    ref: PDFName,\n    type1: typeof PDFString,\n    type2: typeof PDFHexString,\n    type3: typeof PDFArray,\n  ): PDFString | PDFHexString | PDFArray;\n\n  lookup(key: PDFName, ...types: any[]) {\n    // TODO: `preservePDFNull` is for backwards compatibility. Should be\n    // removed in next breaking API change.\n    const preservePDFNull = types.includes(PDFNull);\n\n    const value = this.context.lookup(\n      this.get(key, preservePDFNull),\n      // @ts-ignore\n      ...types,\n    ) as any;\n\n    if (value === PDFNull \u0026\u0026 !preservePDFNull) return undefined;\n\n    return value;\n  }\n\n  delete(key: PDFName): boolean {\n    return this.dict.delete(key);\n  }\n\n  asMap(): Map\u003cPDFName, PDFObject\u003e {\n    return new Map(this.dict);\n  }\n\n  /** Generate a random key that doesn't exist in current key set */\n  uniqueKey(tag = ''): PDFName {\n    const existingKeys = this.keys();\n    let key = PDFName.of(this.context.addRandomSuffix(tag, 10));\n    while (existingKeys.includes(key)) {\n      key = PDFName.of(this.context.addRandomSuffix(tag, 10));\n    }\n    return key;\n  }\n\n  clone(context?: PDFContext): PDFDict {\n    const clone = PDFDict.withContext(context || this.context);\n    const entries = this.entries();\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [key, value] = entries[idx];\n      clone.set(key, value);\n    }\n    return clone;\n  }\n\n  toString(): string {\n    let dictString = '\u003c\u003c\\n';\n    const entries = this.entries();\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [key, value] = entries[idx];\n      dictString += key.toString() + ' ' + value.toString() + '\\n';\n    }\n    dictString += '\u003e\u003e';\n    return dictString;\n  }\n\n  sizeInBytes(): number {\n    let size = 5;\n    const entries = this.entries();\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [key, value] = entries[idx];\n      size += key.sizeInBytes() + value.sizeInBytes() + 2;\n    }\n    return size;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const initialOffset = offset;\n\n    buffer[offset++] = CharCodes.LessThan;\n    buffer[offset++] = CharCodes.LessThan;\n    buffer[offset++] = CharCodes.Newline;\n\n    const entries = this.entries();\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [key, value] = entries[idx];\n      offset += key.copyBytesInto(buffer, offset);\n      buffer[offset++] = CharCodes.Space;\n      offset += value.copyBytesInto(buffer, offset);\n      buffer[offset++] = CharCodes.Newline;\n    }\n\n    buffer[offset++] = CharCodes.GreaterThan;\n    buffer[offset++] = CharCodes.GreaterThan;\n\n    return offset - initialOffset;\n  }\n}\n\nexport default PDFDict;\n","import { MethodNotImplementedError } from 'src/core/errors';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFContext from 'src/core/PDFContext';\nimport CharCodes from 'src/core/syntax/CharCodes';\n\nclass PDFStream extends PDFObject {\n  readonly dict: PDFDict;\n\n  constructor(dict: PDFDict) {\n    super();\n    this.dict = dict;\n  }\n\n  clone(_context?: PDFContext): PDFStream {\n    throw new MethodNotImplementedError(this.constructor.name, 'clone');\n  }\n\n  getContentsString(): string {\n    throw new MethodNotImplementedError(\n      this.constructor.name,\n      'getContentsString',\n    );\n  }\n\n  getContents(): Uint8Array {\n    throw new MethodNotImplementedError(this.constructor.name, 'getContents');\n  }\n\n  getContentsSize(): number {\n    throw new MethodNotImplementedError(\n      this.constructor.name,\n      'getContentsSize',\n    );\n  }\n\n  updateDict(): void {\n    const contentsSize = this.getContentsSize();\n    this.dict.set(PDFName.Length, PDFNumber.of(contentsSize));\n  }\n\n  sizeInBytes(): number {\n    this.updateDict();\n    return this.dict.sizeInBytes() + this.getContentsSize() + 18;\n  }\n\n  toString(): string {\n    this.updateDict();\n    let streamString = this.dict.toString();\n    streamString += '\\nstream\\n';\n    streamString += this.getContentsString();\n    streamString += '\\nendstream';\n    return streamString;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    this.updateDict();\n    const initialOffset = offset;\n\n    offset += this.dict.copyBytesInto(buffer, offset);\n    buffer[offset++] = CharCodes.Newline;\n\n    buffer[offset++] = CharCodes.s;\n    buffer[offset++] = CharCodes.t;\n    buffer[offset++] = CharCodes.r;\n    buffer[offset++] = CharCodes.e;\n    buffer[offset++] = CharCodes.a;\n    buffer[offset++] = CharCodes.m;\n    buffer[offset++] = CharCodes.Newline;\n\n    const contents = this.getContents();\n    for (let idx = 0, len = contents.length; idx \u003c len; idx++) {\n      buffer[offset++] = contents[idx];\n    }\n\n    buffer[offset++] = CharCodes.Newline;\n    buffer[offset++] = CharCodes.e;\n    buffer[offset++] = CharCodes.n;\n    buffer[offset++] = CharCodes.d;\n    buffer[offset++] = CharCodes.s;\n    buffer[offset++] = CharCodes.t;\n    buffer[offset++] = CharCodes.r;\n    buffer[offset++] = CharCodes.e;\n    buffer[offset++] = CharCodes.a;\n    buffer[offset++] = CharCodes.m;\n\n    return offset - initialOffset;\n  }\n}\n\nexport default PDFStream;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFContext from 'src/core/PDFContext';\nimport { arrayAsString } from 'src/utils';\n\nclass PDFRawStream extends PDFStream {\n  static of = (dict: PDFDict, contents: Uint8Array) =\u003e\n    new PDFRawStream(dict, contents);\n\n  readonly contents: Uint8Array;\n\n  private constructor(dict: PDFDict, contents: Uint8Array) {\n    super(dict);\n    this.contents = contents;\n  }\n\n  asUint8Array(): Uint8Array {\n    return this.contents.slice();\n  }\n\n  clone(context?: PDFContext): PDFRawStream {\n    return PDFRawStream.of(this.dict.clone(context), this.contents.slice());\n  }\n\n  getContentsString(): string {\n    return arrayAsString(this.contents);\n  }\n\n  getContents(): Uint8Array {\n    return this.contents;\n  }\n\n  getContentsSize(): number {\n    return this.contents.length;\n  }\n}\n\nexport default PDFRawStream;\n","import { PrivateConstructorError } from 'src/core/errors';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport { copyStringIntoBuffer } from 'src/utils';\n\nconst ENFORCER = {};\nconst pool = new Map\u003cstring, PDFRef\u003e();\n\nclass PDFRef extends PDFObject {\n  static of = (objectNumber: number, generationNumber = 0) =\u003e {\n    const tag = `${objectNumber} ${generationNumber} R`;\n\n    let instance = pool.get(tag);\n    if (!instance) {\n      instance = new PDFRef(ENFORCER, objectNumber, generationNumber);\n      pool.set(tag, instance);\n    }\n\n    return instance;\n  };\n\n  readonly objectNumber: number;\n  readonly generationNumber: number;\n  readonly tag: string;\n\n  private constructor(\n    enforcer: any,\n    objectNumber: number,\n    generationNumber: number,\n  ) {\n    if (enforcer !== ENFORCER) throw new PrivateConstructorError('PDFRef');\n    super();\n    this.objectNumber = objectNumber;\n    this.generationNumber = generationNumber;\n    this.tag = `${objectNumber} ${generationNumber} R`;\n  }\n\n  clone(): PDFRef {\n    return this;\n  }\n\n  toString(): string {\n    return this.tag;\n  }\n\n  sizeInBytes(): number {\n    return this.tag.length;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    offset += copyStringIntoBuffer(this.tag, buffer, offset);\n    return this.tag.length;\n  }\n}\n\nexport default PDFRef;\n","import PDFArray from 'src/core/objects/PDFArray';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFOperatorNames from 'src/core/operators/PDFOperatorNames';\nimport PDFContext from 'src/core/PDFContext';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { copyStringIntoBuffer } from 'src/utils';\n\nexport type PDFOperatorArg =\n  | string\n  | PDFName\n  | PDFArray\n  | PDFNumber\n  | PDFString\n  | PDFHexString;\n\nclass PDFOperator {\n  static of = (name: PDFOperatorNames, args?: PDFOperatorArg[]) =\u003e\n    new PDFOperator(name, args);\n\n  private readonly name: PDFOperatorNames;\n  private readonly args: PDFOperatorArg[];\n\n  private constructor(name: PDFOperatorNames, args?: PDFOperatorArg[]) {\n    this.name = name;\n    this.args = args || [];\n  }\n\n  clone(context?: PDFContext): PDFOperator {\n    const args = new Array(this.args.length);\n    for (let idx = 0, len = args.length; idx \u003c len; idx++) {\n      const arg = this.args[idx];\n      args[idx] = arg instanceof PDFObject ? arg.clone(context) : arg;\n    }\n    return PDFOperator.of(this.name, args);\n  }\n\n  toString(): string {\n    let value = '';\n    for (let idx = 0, len = this.args.length; idx \u003c len; idx++) {\n      value += String(this.args[idx]) + ' ';\n    }\n    value += this.name;\n    return value;\n  }\n\n  sizeInBytes(): number {\n    let size = 0;\n    for (let idx = 0, len = this.args.length; idx \u003c len; idx++) {\n      const arg = this.args[idx];\n      size += (arg instanceof PDFObject ? arg.sizeInBytes() : arg.length) + 1;\n    }\n    size += this.name.length;\n    return size;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const initialOffset = offset;\n\n    for (let idx = 0, len = this.args.length; idx \u003c len; idx++) {\n      const arg = this.args[idx];\n      if (arg instanceof PDFObject) {\n        offset += arg.copyBytesInto(buffer, offset);\n      } else {\n        offset += copyStringIntoBuffer(arg, buffer, offset);\n      }\n      buffer[offset++] = CharCodes.Space;\n    }\n\n    offset += copyStringIntoBuffer(this.name, buffer, offset);\n\n    return offset - initialOffset;\n  }\n}\n\nexport default PDFOperator;\n","enum PDFOperatorNames {\n  // Non Stroking Color Operators\n  NonStrokingColor = 'sc',\n  NonStrokingColorN = 'scn',\n  NonStrokingColorRgb = 'rg',\n  NonStrokingColorGray = 'g',\n  NonStrokingColorCmyk = 'k',\n  NonStrokingColorspace = 'cs',\n\n  // Stroking Color Operators\n  StrokingColor = 'SC',\n  StrokingColorN = 'SCN',\n  StrokingColorRgb = 'RG',\n  StrokingColorGray = 'G',\n  StrokingColorCmyk = 'K',\n  StrokingColorspace = 'CS',\n\n  // Marked Content Operators\n  BeginMarkedContentSequence = 'BDC',\n  BeginMarkedContent = 'BMC',\n  EndMarkedContent = 'EMC',\n  MarkedContentPointWithProps = 'DP',\n  MarkedContentPoint = 'MP',\n  DrawObject = 'Do',\n\n  // Graphics State Operators\n  ConcatTransformationMatrix = 'cm',\n  PopGraphicsState = 'Q',\n  PushGraphicsState = 'q',\n  SetFlatness = 'i',\n  SetGraphicsStateParams = 'gs',\n  SetLineCapStyle = 'J',\n  SetLineDashPattern = 'd',\n  SetLineJoinStyle = 'j',\n  SetLineMiterLimit = 'M',\n  SetLineWidth = 'w',\n  SetTextMatrix = 'Tm',\n  SetRenderingIntent = 'ri',\n\n  // Graphics Operators\n  AppendRectangle = 're',\n  BeginInlineImage = 'BI',\n  BeginInlineImageData = 'ID',\n  EndInlineImage = 'EI',\n  ClipEvenOdd = 'W*',\n  ClipNonZero = 'W',\n  CloseAndStroke = 's',\n  CloseFillEvenOddAndStroke = 'b*',\n  CloseFillNonZeroAndStroke = 'b',\n  ClosePath = 'h',\n  AppendBezierCurve = 'c',\n  CurveToReplicateFinalPoint = 'y',\n  CurveToReplicateInitialPoint = 'v',\n  EndPath = 'n',\n  FillEvenOddAndStroke = 'B*',\n  FillEvenOdd = 'f*',\n  FillNonZeroAndStroke = 'B',\n  FillNonZero = 'f',\n  LegacyFillNonZero = 'F',\n  LineTo = 'l',\n  MoveTo = 'm',\n  ShadingFill = 'sh',\n  StrokePath = 'S',\n\n  // Text Operators\n  BeginText = 'BT',\n  EndText = 'ET',\n  MoveText = 'Td',\n  MoveTextSetLeading = 'TD',\n  NextLine = 'T*',\n  SetCharacterSpacing = 'Tc',\n  SetFontAndSize = 'Tf',\n  SetTextHorizontalScaling = 'Tz',\n  SetTextLineHeight = 'TL',\n  SetTextRenderingMode = 'Tr',\n  SetTextRise = 'Ts',\n  SetWordSpacing = 'Tw',\n  ShowText = 'Tj',\n  ShowTextAdjusted = 'TJ',\n  ShowTextLine = \"'\", // tslint:disable-line quotemark\n  ShowTextLineAndSpace = '\"',\n\n  // Type3 Font Operators\n  Type3D0 = 'd0',\n  Type3D1 = 'd1',\n\n  // Compatibility Section Operators\n  BeginCompatibilitySection = 'BX',\n  EndCompatibilitySection = 'EX',\n}\n\nexport default PDFOperatorNames;\n","import pako from 'pako';\n\nimport { MethodNotImplementedError } from 'src/core/errors';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport { Cache } from 'src/utils';\n\nclass PDFFlateStream extends PDFStream {\n  protected readonly contentsCache: Cache\u003cUint8Array\u003e;\n  protected readonly encode: boolean;\n\n  constructor(dict: PDFDict, encode: boolean) {\n    super(dict);\n\n    this.encode = encode;\n\n    if (encode) dict.set(PDFName.of('Filter'), PDFName.of('FlateDecode'));\n    this.contentsCache = Cache.populatedBy(this.computeContents);\n  }\n\n  computeContents = (): Uint8Array =\u003e {\n    const unencodedContents = this.getUnencodedContents();\n    return this.encode ? pako.deflate(unencodedContents) : unencodedContents;\n  };\n\n  getContents(): Uint8Array {\n    return this.contentsCache.access();\n  }\n\n  getContentsSize(): number {\n    return this.contentsCache.access().length;\n  }\n\n  getUnencodedContents(): Uint8Array {\n    throw new MethodNotImplementedError(\n      this.constructor.name,\n      'getUnencodedContents',\n    );\n  }\n}\n\nexport default PDFFlateStream;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFOperator from 'src/core/operators/PDFOperator';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFFlateStream from 'src/core/structures/PDFFlateStream';\nimport CharCodes from 'src/core/syntax/CharCodes';\n\nclass PDFContentStream extends PDFFlateStream {\n  static of = (dict: PDFDict, operators: PDFOperator[], encode = true) =\u003e\n    new PDFContentStream(dict, operators, encode);\n\n  private readonly operators: PDFOperator[];\n\n  private constructor(dict: PDFDict, operators: PDFOperator[], encode = true) {\n    super(dict, encode);\n    this.operators = operators;\n  }\n\n  push(...operators: PDFOperator[]): void {\n    this.operators.push(...operators);\n  }\n\n  clone(context?: PDFContext): PDFContentStream {\n    const operators = new Array(this.operators.length);\n    for (let idx = 0, len = this.operators.length; idx \u003c len; idx++) {\n      operators[idx] = this.operators[idx].clone(context);\n    }\n    const { dict, encode } = this;\n    return PDFContentStream.of(dict.clone(context), operators, encode);\n  }\n\n  getContentsString(): string {\n    let value = '';\n    for (let idx = 0, len = this.operators.length; idx \u003c len; idx++) {\n      value += `${this.operators[idx]}\\n`;\n    }\n    return value;\n  }\n\n  getUnencodedContents(): Uint8Array {\n    const buffer = new Uint8Array(this.getUnencodedContentsSize());\n    let offset = 0;\n    for (let idx = 0, len = this.operators.length; idx \u003c len; idx++) {\n      offset += this.operators[idx].copyBytesInto(buffer, offset);\n      buffer[offset++] = CharCodes.Newline;\n    }\n    return buffer;\n  }\n\n  getUnencodedContentsSize(): number {\n    let size = 0;\n    for (let idx = 0, len = this.operators.length; idx \u003c len; idx++) {\n      size += this.operators[idx].sizeInBytes() + 1;\n    }\n    return size;\n  }\n}\n\nexport default PDFContentStream;\n","/**\n * Generates a pseudo random number. Although it is not cryptographically secure\n * and uniformly distributed, it is not a concern for the intended use-case,\n * which is to generate distinct numbers.\n *\n * Credit: https://stackoverflow.com/a/19303725/10254049\n */\nexport class SimpleRNG {\n  static withSeed = (seed: number) =\u003e new SimpleRNG(seed);\n\n  private seed: number;\n\n  private constructor(seed: number) {\n    this.seed = seed;\n  }\n\n  nextInt(): number {\n    const x = Math.sin(this.seed++) * 10000;\n    return x - Math.floor(x);\n  }\n}\n","import PDFArray from 'src/core/objects/PDFArray';\nimport PDFDict, { DictMap } from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFPageTree from 'src/core/structures/PDFPageTree';\n\nclass PDFPageLeaf extends PDFDict {\n  static readonly InheritableEntries = [\n    'Resources',\n    'MediaBox',\n    'CropBox',\n    'Rotate',\n  ];\n\n  static withContextAndParent = (context: PDFContext, parent: PDFRef) =\u003e {\n    const dict = new Map();\n    dict.set(PDFName.Type, PDFName.Page);\n    dict.set(PDFName.Parent, parent);\n    dict.set(PDFName.Resources, context.obj({}));\n    dict.set(PDFName.MediaBox, context.obj([0, 0, 612, 792]));\n    return new PDFPageLeaf(dict, context, false);\n  };\n\n  static fromMapWithContext = (\n    map: DictMap,\n    context: PDFContext,\n    autoNormalizeCTM = true,\n  ) =\u003e new PDFPageLeaf(map, context, autoNormalizeCTM);\n\n  private normalized = false;\n  private readonly autoNormalizeCTM: boolean;\n\n  private constructor(\n    map: DictMap,\n    context: PDFContext,\n    autoNormalizeCTM = true,\n  ) {\n    super(map, context);\n    this.autoNormalizeCTM = autoNormalizeCTM;\n  }\n\n  clone(context?: PDFContext): PDFPageLeaf {\n    const clone = PDFPageLeaf.fromMapWithContext(\n      new Map(),\n      context || this.context,\n      this.autoNormalizeCTM,\n    );\n    const entries = this.entries();\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [key, value] = entries[idx];\n      clone.set(key, value);\n    }\n    return clone;\n  }\n\n  Parent(): PDFPageTree | undefined {\n    return this.lookupMaybe(PDFName.Parent, PDFDict) as PDFPageTree | undefined;\n  }\n\n  Contents(): PDFStream | PDFArray | undefined {\n    return this.lookup(PDFName.of('Contents')) as\n      | PDFStream\n      | PDFArray\n      | undefined;\n  }\n\n  Annots(): PDFArray | undefined {\n    return this.lookupMaybe(PDFName.Annots, PDFArray);\n  }\n\n  BleedBox(): PDFArray | undefined {\n    return this.lookupMaybe(PDFName.BleedBox, PDFArray);\n  }\n\n  TrimBox(): PDFArray | undefined {\n    return this.lookupMaybe(PDFName.TrimBox, PDFArray);\n  }\n\n  ArtBox(): PDFArray | undefined {\n    return this.lookupMaybe(PDFName.ArtBox, PDFArray);\n  }\n\n  Resources(): PDFDict | undefined {\n    const dictOrRef = this.getInheritableAttribute(PDFName.Resources);\n    return this.context.lookupMaybe(dictOrRef, PDFDict);\n  }\n\n  MediaBox(): PDFArray {\n    const arrayOrRef = this.getInheritableAttribute(PDFName.MediaBox);\n    return this.context.lookup(arrayOrRef, PDFArray);\n  }\n\n  CropBox(): PDFArray | undefined {\n    const arrayOrRef = this.getInheritableAttribute(PDFName.CropBox);\n    return this.context.lookupMaybe(arrayOrRef, PDFArray);\n  }\n\n  Rotate(): PDFNumber | undefined {\n    const numberOrRef = this.getInheritableAttribute(PDFName.Rotate);\n    return this.context.lookupMaybe(numberOrRef, PDFNumber);\n  }\n\n  getInheritableAttribute(name: PDFName): PDFObject | undefined {\n    let attribute: PDFObject | undefined;\n    this.ascend((node) =\u003e {\n      if (!attribute) attribute = node.get(name);\n    });\n    return attribute;\n  }\n\n  setParent(parentRef: PDFRef): void {\n    this.set(PDFName.Parent, parentRef);\n  }\n\n  addContentStream(contentStreamRef: PDFRef): void {\n    const Contents = this.normalizedEntries().Contents || this.context.obj([]);\n    this.set(PDFName.Contents, Contents);\n    Contents.push(contentStreamRef);\n  }\n\n  wrapContentStreams(startStream: PDFRef, endStream: PDFRef): boolean {\n    const Contents = this.Contents();\n    if (Contents instanceof PDFArray) {\n      Contents.insert(0, startStream);\n      Contents.push(endStream);\n      return true;\n    }\n    return false;\n  }\n\n  addAnnot(annotRef: PDFRef): void {\n    const { Annots } = this.normalizedEntries();\n    Annots.push(annotRef);\n  }\n\n  removeAnnot(annotRef: PDFRef) {\n    const { Annots } = this.normalizedEntries();\n    const index = Annots.indexOf(annotRef);\n    if (index !== undefined) {\n      Annots.remove(index);\n    }\n  }\n\n  setFontDictionary(name: PDFName, fontDictRef: PDFRef): void {\n    const { Font } = this.normalizedEntries();\n    Font.set(name, fontDictRef);\n  }\n\n  newFontDictionaryKey(tag: string): PDFName {\n    const { Font } = this.normalizedEntries();\n    return Font.uniqueKey(tag);\n  }\n\n  newFontDictionary(tag: string, fontDictRef: PDFRef): PDFName {\n    const key = this.newFontDictionaryKey(tag);\n    this.setFontDictionary(key, fontDictRef);\n    return key;\n  }\n\n  setXObject(name: PDFName, xObjectRef: PDFRef): void {\n    const { XObject } = this.normalizedEntries();\n    XObject.set(name, xObjectRef);\n  }\n\n  newXObjectKey(tag: string): PDFName {\n    const { XObject } = this.normalizedEntries();\n    return XObject.uniqueKey(tag);\n  }\n\n  newXObject(tag: string, xObjectRef: PDFRef): PDFName {\n    const key = this.newXObjectKey(tag);\n    this.setXObject(key, xObjectRef);\n    return key;\n  }\n\n  setExtGState(name: PDFName, extGStateRef: PDFRef | PDFDict): void {\n    const { ExtGState } = this.normalizedEntries();\n    ExtGState.set(name, extGStateRef);\n  }\n\n  newExtGStateKey(tag: string): PDFName {\n    const { ExtGState } = this.normalizedEntries();\n    return ExtGState.uniqueKey(tag);\n  }\n\n  newExtGState(tag: string, extGStateRef: PDFRef | PDFDict): PDFName {\n    const key = this.newExtGStateKey(tag);\n    this.setExtGState(key, extGStateRef);\n    return key;\n  }\n\n  ascend(visitor: (node: PDFPageTree | PDFPageLeaf) =\u003e any): void {\n    visitor(this);\n    const Parent = this.Parent();\n    if (Parent) Parent.ascend(visitor);\n  }\n\n  normalize() {\n    if (this.normalized) return;\n\n    const { context } = this;\n\n    const contentsRef = this.get(PDFName.Contents);\n    const contents = this.context.lookup(contentsRef);\n    if (contents instanceof PDFStream) {\n      this.set(PDFName.Contents, context.obj([contentsRef]));\n    }\n\n    if (this.autoNormalizeCTM) {\n      this.wrapContentStreams(\n        this.context.getPushGraphicsStateContentStream(),\n        this.context.getPopGraphicsStateContentStream(),\n      );\n    }\n\n    // TODO: Clone `Resources` if it is inherited\n    const dictOrRef = this.getInheritableAttribute(PDFName.Resources);\n    const Resources =\n      context.lookupMaybe(dictOrRef, PDFDict) || context.obj({});\n    this.set(PDFName.Resources, Resources);\n\n    // TODO: Clone `Font` if it is inherited\n    const Font =\n      Resources.lookupMaybe(PDFName.Font, PDFDict) || context.obj({});\n    Resources.set(PDFName.Font, Font);\n\n    // TODO: Clone `XObject` if it is inherited\n    const XObject =\n      Resources.lookupMaybe(PDFName.XObject, PDFDict) || context.obj({});\n    Resources.set(PDFName.XObject, XObject);\n\n    // TODO: Clone `ExtGState` if it is inherited\n    const ExtGState =\n      Resources.lookupMaybe(PDFName.ExtGState, PDFDict) || context.obj({});\n    Resources.set(PDFName.ExtGState, ExtGState);\n\n    const Annots = this.Annots() || context.obj([]);\n    this.set(PDFName.Annots, Annots);\n\n    this.normalized = true;\n  }\n\n  normalizedEntries() {\n    this.normalize();\n    const Annots = this.Annots()!;\n    const Resources = this.Resources()!;\n    const Contents = this.Contents() as PDFArray | undefined;\n    return {\n      Annots,\n      Resources,\n      Contents,\n      Font: Resources.lookup(PDFName.Font, PDFDict),\n      XObject: Resources.lookup(PDFName.XObject, PDFDict),\n      ExtGState: Resources.lookup(PDFName.ExtGState, PDFDict),\n    };\n  }\n}\n\nexport default PDFPageLeaf;\n","import PDFArray from 'src/core/objects/PDFArray';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFPageLeaf from 'src/core/structures/PDFPageLeaf';\n\n/**\n * PDFObjectCopier copies PDFObjects from a src context to a dest context.\n * The primary use case for this is to copy pages between PDFs.\n *\n * _Copying_ an object with a PDFObjectCopier is different from _cloning_ an\n * object with its [[PDFObject.clone]] method:\n *\n * ```\n *   const src: PDFContext = ...\n *   const dest: PDFContext = ...\n *   const originalObject: PDFObject = ...\n *   const copiedObject = PDFObjectCopier.for(src, dest).copy(originalObject);\n *   const clonedObject = originalObject.clone();\n * ```\n *\n * Copying an object is equivalent to cloning it and then copying over any other\n * objects that it references. Note that only dictionaries, arrays, and streams\n * (or structures build from them) can contain indirect references to other\n * objects. Copying a PDFObject that is not a dictionary, array, or stream is\n * supported, but is equivalent to cloning it.\n */\nclass PDFObjectCopier {\n  static for = (src: PDFContext, dest: PDFContext) =\u003e\n    new PDFObjectCopier(src, dest);\n\n  private readonly src: PDFContext;\n  private readonly dest: PDFContext;\n  private readonly traversedObjects = new Map\u003cPDFObject, PDFObject\u003e();\n\n  private constructor(src: PDFContext, dest: PDFContext) {\n    this.src = src;\n    this.dest = dest;\n  }\n\n  // prettier-ignore\n  copy = \u003cT extends PDFObject\u003e(object: T): T =\u003e (\n      object instanceof PDFPageLeaf ? this.copyPDFPage(object)\n    : object instanceof PDFDict     ? this.copyPDFDict(object)\n    : object instanceof PDFArray    ? this.copyPDFArray(object)\n    : object instanceof PDFStream   ? this.copyPDFStream(object)\n    : object instanceof PDFRef      ? this.copyPDFIndirectObject(object)\n    : object.clone()\n  ) as T;\n\n  private copyPDFPage = (originalPage: PDFPageLeaf): PDFPageLeaf =\u003e {\n    const clonedPage = originalPage.clone();\n\n    // Move any entries that the originalPage is inheriting from its parent\n    // tree nodes directly into originalPage so they are preserved during\n    // the copy.\n    const { InheritableEntries } = PDFPageLeaf;\n    for (let idx = 0, len = InheritableEntries.length; idx \u003c len; idx++) {\n      const key = PDFName.of(InheritableEntries[idx]);\n      const value = clonedPage.getInheritableAttribute(key)!;\n      if (!clonedPage.get(key) \u0026\u0026 value) clonedPage.set(key, value);\n    }\n\n    // Remove the parent reference to prevent the whole donor document's page\n    // tree from being copied when we only need a single page.\n    clonedPage.delete(PDFName.of('Parent'));\n\n    return this.copyPDFDict(clonedPage) as PDFPageLeaf;\n  };\n\n  private copyPDFDict = (originalDict: PDFDict): PDFDict =\u003e {\n    if (this.traversedObjects.has(originalDict)) {\n      return this.traversedObjects.get(originalDict) as PDFDict;\n    }\n\n    const clonedDict = originalDict.clone(this.dest);\n    this.traversedObjects.set(originalDict, clonedDict);\n\n    const entries = originalDict.entries();\n\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [key, value] = entries[idx];\n      clonedDict.set(key, this.copy(value));\n    }\n\n    return clonedDict;\n  };\n\n  private copyPDFArray = (originalArray: PDFArray): PDFArray =\u003e {\n    if (this.traversedObjects.has(originalArray)) {\n      return this.traversedObjects.get(originalArray) as PDFArray;\n    }\n\n    const clonedArray = originalArray.clone(this.dest);\n    this.traversedObjects.set(originalArray, clonedArray);\n\n    for (let idx = 0, len = originalArray.size(); idx \u003c len; idx++) {\n      const value = originalArray.get(idx);\n      clonedArray.set(idx, this.copy(value));\n    }\n\n    return clonedArray;\n  };\n\n  private copyPDFStream = (originalStream: PDFStream): PDFStream =\u003e {\n    if (this.traversedObjects.has(originalStream)) {\n      return this.traversedObjects.get(originalStream) as PDFStream;\n    }\n\n    const clonedStream = originalStream.clone(this.dest);\n    this.traversedObjects.set(originalStream, clonedStream);\n\n    const entries = originalStream.dict.entries();\n    for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n      const [key, value] = entries[idx];\n      clonedStream.dict.set(key, this.copy(value));\n    }\n\n    return clonedStream;\n  };\n\n  private copyPDFIndirectObject = (ref: PDFRef): PDFRef =\u003e {\n    const alreadyMapped = this.traversedObjects.has(ref);\n\n    if (!alreadyMapped) {\n      const newRef = this.dest.nextRef();\n      this.traversedObjects.set(ref, newRef);\n\n      const dereferencedValue = this.src.lookup(ref);\n      if (dereferencedValue) {\n        const cloned = this.copy(dereferencedValue);\n        this.dest.assign(newRef, cloned);\n      }\n    }\n\n    return this.traversedObjects.get(ref) as PDFRef;\n  };\n}\n\nexport default PDFObjectCopier;\n","import PDFRef from 'src/core/objects/PDFRef';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { copyStringIntoBuffer, padStart } from 'src/utils';\n\nexport interface Entry {\n  ref: PDFRef;\n  offset: number;\n  deleted: boolean;\n}\n\n/**\n * Entries should be added using the [[addEntry]] and [[addDeletedEntry]]\n * methods **in order of ascending object number**.\n */\nclass PDFCrossRefSection {\n  static create = () =\u003e\n    new PDFCrossRefSection({\n      ref: PDFRef.of(0, 65535),\n      offset: 0,\n      deleted: true,\n    });\n\n  static createEmpty = () =\u003e new PDFCrossRefSection();\n\n  private subsections: Entry[][];\n  private chunkIdx: number;\n  private chunkLength: number;\n\n  private constructor(firstEntry: Entry | void) {\n    this.subsections = firstEntry ? [[firstEntry]] : [];\n    this.chunkIdx = 0;\n    this.chunkLength = firstEntry ? 1 : 0;\n  }\n\n  addEntry(ref: PDFRef, offset: number): void {\n    this.append({ ref, offset, deleted: false });\n  }\n\n  addDeletedEntry(ref: PDFRef, nextFreeObjectNumber: number): void {\n    this.append({ ref, offset: nextFreeObjectNumber, deleted: true });\n  }\n\n  toString(): string {\n    let section = `xref\\n`;\n\n    for (\n      let rangeIdx = 0, rangeLen = this.subsections.length;\n      rangeIdx \u003c rangeLen;\n      rangeIdx++\n    ) {\n      const range = this.subsections[rangeIdx];\n      section += `${range[0].ref.objectNumber} ${range.length}\\n`;\n      for (\n        let entryIdx = 0, entryLen = range.length;\n        entryIdx \u003c entryLen;\n        entryIdx++\n      ) {\n        const entry = range[entryIdx];\n        section += padStart(String(entry.offset), 10, '0');\n        section += ' ';\n        section += padStart(String(entry.ref.generationNumber), 5, '0');\n        section += ' ';\n        section += entry.deleted ? 'f' : 'n';\n        section += ' \\n';\n      }\n    }\n\n    return section;\n  }\n\n  sizeInBytes(): number {\n    let size = 5;\n    for (let idx = 0, len = this.subsections.length; idx \u003c len; idx++) {\n      const subsection = this.subsections[idx];\n      const subsectionLength = subsection.length;\n      const [firstEntry] = subsection;\n      size += 2;\n      size += String(firstEntry.ref.objectNumber).length;\n      size += String(subsectionLength).length;\n      size += 20 * subsectionLength;\n    }\n    return size;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const initialOffset = offset;\n\n    buffer[offset++] = CharCodes.x;\n    buffer[offset++] = CharCodes.r;\n    buffer[offset++] = CharCodes.e;\n    buffer[offset++] = CharCodes.f;\n    buffer[offset++] = CharCodes.Newline;\n\n    offset += this.copySubsectionsIntoBuffer(this.subsections, buffer, offset);\n\n    return offset - initialOffset;\n  }\n\n  private copySubsectionsIntoBuffer(\n    subsections: Entry[][],\n    buffer: Uint8Array,\n    offset: number,\n  ): number {\n    const initialOffset = offset;\n    const length = subsections.length;\n\n    for (let idx = 0; idx \u003c length; idx++) {\n      const subsection = this.subsections[idx];\n\n      const firstObjectNumber = String(subsection[0].ref.objectNumber);\n      offset += copyStringIntoBuffer(firstObjectNumber, buffer, offset);\n      buffer[offset++] = CharCodes.Space;\n\n      const rangeLength = String(subsection.length);\n      offset += copyStringIntoBuffer(rangeLength, buffer, offset);\n      buffer[offset++] = CharCodes.Newline;\n\n      offset += this.copyEntriesIntoBuffer(subsection, buffer, offset);\n    }\n\n    return offset - initialOffset;\n  }\n\n  private copyEntriesIntoBuffer(\n    entries: Entry[],\n    buffer: Uint8Array,\n    offset: number,\n  ): number {\n    const length = entries.length;\n\n    for (let idx = 0; idx \u003c length; idx++) {\n      const entry = entries[idx];\n\n      const entryOffset = padStart(String(entry.offset), 10, '0');\n      offset += copyStringIntoBuffer(entryOffset, buffer, offset);\n      buffer[offset++] = CharCodes.Space;\n\n      const entryGen = padStart(String(entry.ref.generationNumber), 5, '0');\n      offset += copyStringIntoBuffer(entryGen, buffer, offset);\n      buffer[offset++] = CharCodes.Space;\n\n      buffer[offset++] = entry.deleted ? CharCodes.f : CharCodes.n;\n\n      buffer[offset++] = CharCodes.Space;\n      buffer[offset++] = CharCodes.Newline;\n    }\n\n    return 20 * length;\n  }\n\n  private append(currEntry: Entry): void {\n    if (this.chunkLength === 0) {\n      this.subsections.push([currEntry]);\n      this.chunkIdx = 0;\n      this.chunkLength = 1;\n      return;\n    }\n\n    const chunk = this.subsections[this.chunkIdx];\n    const prevEntry = chunk[this.chunkLength - 1];\n\n    if (currEntry.ref.objectNumber - prevEntry.ref.objectNumber \u003e 1) {\n      this.subsections.push([currEntry]);\n      this.chunkIdx += 1;\n      this.chunkLength = 1;\n    } else {\n      chunk.push(currEntry);\n      this.chunkLength += 1;\n    }\n  }\n}\n\nexport default PDFCrossRefSection;\n","import CharCodes from 'src/core/syntax/CharCodes';\nimport { copyStringIntoBuffer } from 'src/utils';\n\nclass PDFTrailer {\n  static forLastCrossRefSectionOffset = (offset: number) =\u003e\n    new PDFTrailer(offset);\n\n  private readonly lastXRefOffset: string;\n\n  private constructor(lastXRefOffset: number) {\n    this.lastXRefOffset = String(lastXRefOffset);\n  }\n\n  toString(): string {\n    return `startxref\\n${this.lastXRefOffset}\\n%%EOF`;\n  }\n\n  sizeInBytes(): number {\n    return 16 + this.lastXRefOffset.length;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const initialOffset = offset;\n\n    buffer[offset++] = CharCodes.s;\n    buffer[offset++] = CharCodes.t;\n    buffer[offset++] = CharCodes.a;\n    buffer[offset++] = CharCodes.r;\n    buffer[offset++] = CharCodes.t;\n    buffer[offset++] = CharCodes.x;\n    buffer[offset++] = CharCodes.r;\n    buffer[offset++] = CharCodes.e;\n    buffer[offset++] = CharCodes.f;\n    buffer[offset++] = CharCodes.Newline;\n\n    offset += copyStringIntoBuffer(this.lastXRefOffset, buffer, offset);\n\n    buffer[offset++] = CharCodes.Newline;\n    buffer[offset++] = CharCodes.Percent;\n    buffer[offset++] = CharCodes.Percent;\n    buffer[offset++] = CharCodes.E;\n    buffer[offset++] = CharCodes.O;\n    buffer[offset++] = CharCodes.F;\n\n    return offset - initialOffset;\n  }\n}\n\nexport default PDFTrailer;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport CharCodes from 'src/core/syntax/CharCodes';\n\nclass PDFTrailerDict {\n  static of = (dict: PDFDict) =\u003e new PDFTrailerDict(dict);\n\n  readonly dict: PDFDict;\n\n  private constructor(dict: PDFDict) {\n    this.dict = dict;\n  }\n\n  toString(): string {\n    return `trailer\\n${this.dict.toString()}`;\n  }\n\n  sizeInBytes(): number {\n    return 8 + this.dict.sizeInBytes();\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const initialOffset = offset;\n\n    buffer[offset++] = CharCodes.t;\n    buffer[offset++] = CharCodes.r;\n    buffer[offset++] = CharCodes.a;\n    buffer[offset++] = CharCodes.i;\n    buffer[offset++] = CharCodes.l;\n    buffer[offset++] = CharCodes.e;\n    buffer[offset++] = CharCodes.r;\n    buffer[offset++] = CharCodes.Newline;\n\n    offset += this.dict.copyBytesInto(buffer, offset);\n\n    return offset - initialOffset;\n  }\n}\n\nexport default PDFTrailerDict;\n","import PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFFlateStream from 'src/core/structures/PDFFlateStream';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { copyStringIntoBuffer, last } from 'src/utils';\n\nexport type IndirectObject = [PDFRef, PDFObject];\n\nclass PDFObjectStream extends PDFFlateStream {\n  static withContextAndObjects = (\n    context: PDFContext,\n    objects: IndirectObject[],\n    encode = true,\n  ) =\u003e new PDFObjectStream(context, objects, encode);\n\n  private readonly objects: IndirectObject[];\n  private readonly offsets: [number, number][];\n  private readonly offsetsString: string;\n\n  private constructor(\n    context: PDFContext,\n    objects: IndirectObject[],\n    encode = true,\n  ) {\n    super(context.obj({}), encode);\n\n    this.objects = objects;\n    this.offsets = this.computeObjectOffsets();\n    this.offsetsString = this.computeOffsetsString();\n\n    this.dict.set(PDFName.of('Type'), PDFName.of('ObjStm'));\n    this.dict.set(PDFName.of('N'), PDFNumber.of(this.objects.length));\n    this.dict.set(PDFName.of('First'), PDFNumber.of(this.offsetsString.length));\n  }\n\n  getObjectsCount(): number {\n    return this.objects.length;\n  }\n\n  clone(context?: PDFContext): PDFObjectStream {\n    return PDFObjectStream.withContextAndObjects(\n      context || this.dict.context,\n      this.objects.slice(),\n      this.encode,\n    );\n  }\n\n  getContentsString(): string {\n    let value = this.offsetsString;\n    for (let idx = 0, len = this.objects.length; idx \u003c len; idx++) {\n      const [, object] = this.objects[idx];\n      value += `${object}\\n`;\n    }\n    return value;\n  }\n\n  getUnencodedContents(): Uint8Array {\n    const buffer = new Uint8Array(this.getUnencodedContentsSize());\n    let offset = copyStringIntoBuffer(this.offsetsString, buffer, 0);\n    for (let idx = 0, len = this.objects.length; idx \u003c len; idx++) {\n      const [, object] = this.objects[idx];\n      offset += object.copyBytesInto(buffer, offset);\n      buffer[offset++] = CharCodes.Newline;\n    }\n    return buffer;\n  }\n\n  getUnencodedContentsSize(): number {\n    return (\n      this.offsetsString.length +\n      last(this.offsets)[1] +\n      last(this.objects)[1].sizeInBytes() +\n      1\n    );\n  }\n\n  private computeOffsetsString(): string {\n    let offsetsString = '';\n    for (let idx = 0, len = this.offsets.length; idx \u003c len; idx++) {\n      const [objectNumber, offset] = this.offsets[idx];\n      offsetsString += `${objectNumber} ${offset} `;\n    }\n    return offsetsString;\n  }\n\n  private computeObjectOffsets(): [number, number][] {\n    let offset = 0;\n    const offsets = new Array(this.objects.length);\n    for (let idx = 0, len = this.objects.length; idx \u003c len; idx++) {\n      const [ref, object] = this.objects[idx];\n      offsets[idx] = [ref.objectNumber, offset];\n      offset += object.sizeInBytes() + 1; // '\\n'\n    }\n    return offsets;\n  }\n}\n\nexport default PDFObjectStream;\n","import PDFCrossRefSection from 'src/core/document/PDFCrossRefSection';\nimport PDFHeader from 'src/core/document/PDFHeader';\nimport PDFTrailer from 'src/core/document/PDFTrailer';\nimport PDFTrailerDict from 'src/core/document/PDFTrailerDict';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFObjectStream from 'src/core/structures/PDFObjectStream';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { copyStringIntoBuffer, waitForTick } from 'src/utils';\n\nexport interface SerializationInfo {\n  size: number;\n  header: PDFHeader;\n  indirectObjects: [PDFRef, PDFObject][];\n  xref?: PDFCrossRefSection;\n  trailerDict?: PDFTrailerDict;\n  trailer: PDFTrailer;\n}\n\nclass PDFWriter {\n  static forContext = (context: PDFContext, objectsPerTick: number) =\u003e\n    new PDFWriter(context, objectsPerTick);\n\n  protected readonly context: PDFContext;\n\n  protected readonly objectsPerTick: number;\n  private parsedObjects = 0;\n\n  protected constructor(context: PDFContext, objectsPerTick: number) {\n    this.context = context;\n    this.objectsPerTick = objectsPerTick;\n  }\n\n  async serializeToBuffer(): Promise\u003cUint8Array\u003e {\n    const {\n      size,\n      header,\n      indirectObjects,\n      xref,\n      trailerDict,\n      trailer,\n    } = await this.computeBufferSize();\n\n    let offset = 0;\n    const buffer = new Uint8Array(size);\n\n    offset += header.copyBytesInto(buffer, offset);\n    buffer[offset++] = CharCodes.Newline;\n    buffer[offset++] = CharCodes.Newline;\n\n    for (let idx = 0, len = indirectObjects.length; idx \u003c len; idx++) {\n      const [ref, object] = indirectObjects[idx];\n\n      const objectNumber = String(ref.objectNumber);\n      offset += copyStringIntoBuffer(objectNumber, buffer, offset);\n      buffer[offset++] = CharCodes.Space;\n\n      const generationNumber = String(ref.generationNumber);\n      offset += copyStringIntoBuffer(generationNumber, buffer, offset);\n      buffer[offset++] = CharCodes.Space;\n\n      buffer[offset++] = CharCodes.o;\n      buffer[offset++] = CharCodes.b;\n      buffer[offset++] = CharCodes.j;\n      buffer[offset++] = CharCodes.Newline;\n\n      offset += object.copyBytesInto(buffer, offset);\n\n      buffer[offset++] = CharCodes.Newline;\n      buffer[offset++] = CharCodes.e;\n      buffer[offset++] = CharCodes.n;\n      buffer[offset++] = CharCodes.d;\n      buffer[offset++] = CharCodes.o;\n      buffer[offset++] = CharCodes.b;\n      buffer[offset++] = CharCodes.j;\n      buffer[offset++] = CharCodes.Newline;\n      buffer[offset++] = CharCodes.Newline;\n\n      const n =\n        object instanceof PDFObjectStream ? object.getObjectsCount() : 1;\n      if (this.shouldWaitForTick(n)) await waitForTick();\n    }\n\n    if (xref) {\n      offset += xref.copyBytesInto(buffer, offset);\n      buffer[offset++] = CharCodes.Newline;\n    }\n\n    if (trailerDict) {\n      offset += trailerDict.copyBytesInto(buffer, offset);\n      buffer[offset++] = CharCodes.Newline;\n      buffer[offset++] = CharCodes.Newline;\n    }\n\n    offset += trailer.copyBytesInto(buffer, offset);\n\n    return buffer;\n  }\n\n  protected computeIndirectObjectSize([ref, object]: [\n    PDFRef,\n    PDFObject,\n  ]): number {\n    const refSize = ref.sizeInBytes() + 3; // 'R' -\u003e 'obj\\n'\n    const objectSize = object.sizeInBytes() + 9; // '\\nendobj\\n\\n'\n    return refSize + objectSize;\n  }\n\n  protected createTrailerDict(): PDFDict {\n    return this.context.obj({\n      Size: this.context.largestObjectNumber + 1,\n      Root: this.context.trailerInfo.Root,\n      Encrypt: this.context.trailerInfo.Encrypt,\n      Info: this.context.trailerInfo.Info,\n      ID: this.context.trailerInfo.ID,\n    });\n  }\n\n  protected async computeBufferSize(): Promise\u003cSerializationInfo\u003e {\n    const header = PDFHeader.forVersion(1, 7);\n\n    let size = header.sizeInBytes() + 2;\n\n    const xref = PDFCrossRefSection.create();\n\n    const indirectObjects = this.context.enumerateIndirectObjects();\n\n    for (let idx = 0, len = indirectObjects.length; idx \u003c len; idx++) {\n      const indirectObject = indirectObjects[idx];\n      const [ref] = indirectObject;\n      xref.addEntry(ref, size);\n      size += this.computeIndirectObjectSize(indirectObject);\n      if (this.shouldWaitForTick(1)) await waitForTick();\n    }\n\n    const xrefOffset = size;\n    size += xref.sizeInBytes() + 1; // '\\n'\n\n    const trailerDict = PDFTrailerDict.of(this.createTrailerDict());\n    size += trailerDict.sizeInBytes() + 2; // '\\n\\n'\n\n    const trailer = PDFTrailer.forLastCrossRefSectionOffset(xrefOffset);\n    size += trailer.sizeInBytes();\n\n    return { size, header, indirectObjects, xref, trailerDict, trailer };\n  }\n\n  protected shouldWaitForTick = (n: number) =\u003e {\n    this.parsedObjects += n;\n    return this.parsedObjects % this.objectsPerTick === 0;\n  };\n}\n\nexport default PDFWriter;\n","import PDFObject from 'src/core/objects/PDFObject';\n\nclass PDFInvalidObject extends PDFObject {\n  static of = (data: Uint8Array) =\u003e new PDFInvalidObject(data);\n\n  private readonly data: Uint8Array;\n\n  private constructor(data: Uint8Array) {\n    super();\n    this.data = data;\n  }\n\n  clone(): PDFInvalidObject {\n    return PDFInvalidObject.of(this.data.slice());\n  }\n\n  toString(): string {\n    return `PDFInvalidObject(${this.data.length} bytes)`;\n  }\n\n  sizeInBytes(): number {\n    return this.data.length;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    const length = this.data.length;\n    for (let idx = 0; idx \u003c length; idx++) {\n      buffer[offset++] = this.data[idx];\n    }\n    return length;\n  }\n}\n\nexport default PDFInvalidObject;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFFlateStream from 'src/core/structures/PDFFlateStream';\nimport { bytesFor, Cache, reverseArray, sizeInBytes, sum } from 'src/utils';\n\nexport enum EntryType {\n  Deleted = 0,\n  Uncompressed = 1,\n  Compressed = 2,\n}\n\nexport interface DeletedEntry {\n  type: EntryType.Deleted;\n  ref: PDFRef;\n  nextFreeObjectNumber: number;\n}\n\nexport interface UncompressedEntry {\n  type: EntryType.Uncompressed;\n  ref: PDFRef;\n  offset: number;\n}\n\nexport interface CompressedEntry {\n  type: EntryType.Compressed;\n  ref: PDFRef;\n  objectStreamRef: PDFRef;\n  index: number;\n}\n\nexport type Entry = DeletedEntry | UncompressedEntry | CompressedEntry;\n\nexport type EntryTuple = [number, number, number];\n\n/**\n * Entries should be added using the [[addDeletedEntry]],\n * [[addUncompressedEntry]], and [[addCompressedEntry]] methods\n * **in order of ascending object number**.\n */\nclass PDFCrossRefStream extends PDFFlateStream {\n  static create = (dict: PDFDict, encode = true) =\u003e {\n    const stream = new PDFCrossRefStream(dict, [], encode);\n    stream.addDeletedEntry(PDFRef.of(0, 65535), 0);\n    return stream;\n  };\n\n  static of = (dict: PDFDict, entries: Entry[], encode = true) =\u003e\n    new PDFCrossRefStream(dict, entries, encode);\n\n  private readonly entries: Entry[];\n  private readonly entryTuplesCache: Cache\u003cEntryTuple[]\u003e;\n  private readonly maxByteWidthsCache: Cache\u003c[number, number, number]\u003e;\n  private readonly indexCache: Cache\u003cnumber[]\u003e;\n\n  private constructor(dict: PDFDict, entries?: Entry[], encode = true) {\n    super(dict, encode);\n\n    this.entries = entries || [];\n    this.entryTuplesCache = Cache.populatedBy(this.computeEntryTuples);\n    this.maxByteWidthsCache = Cache.populatedBy(this.computeMaxEntryByteWidths);\n    this.indexCache = Cache.populatedBy(this.computeIndex);\n\n    dict.set(PDFName.of('Type'), PDFName.of('XRef'));\n  }\n\n  addDeletedEntry(ref: PDFRef, nextFreeObjectNumber: number) {\n    const type = EntryType.Deleted;\n    this.entries.push({ type, ref, nextFreeObjectNumber });\n    this.entryTuplesCache.invalidate();\n    this.maxByteWidthsCache.invalidate();\n    this.indexCache.invalidate();\n    this.contentsCache.invalidate();\n  }\n\n  addUncompressedEntry(ref: PDFRef, offset: number) {\n    const type = EntryType.Uncompressed;\n    this.entries.push({ type, ref, offset });\n    this.entryTuplesCache.invalidate();\n    this.maxByteWidthsCache.invalidate();\n    this.indexCache.invalidate();\n    this.contentsCache.invalidate();\n  }\n\n  addCompressedEntry(ref: PDFRef, objectStreamRef: PDFRef, index: number) {\n    const type = EntryType.Compressed;\n    this.entries.push({ type, ref, objectStreamRef, index });\n    this.entryTuplesCache.invalidate();\n    this.maxByteWidthsCache.invalidate();\n    this.indexCache.invalidate();\n    this.contentsCache.invalidate();\n  }\n\n  clone(context?: PDFContext): PDFCrossRefStream {\n    const { dict, entries, encode } = this;\n    return PDFCrossRefStream.of(dict.clone(context), entries.slice(), encode);\n  }\n\n  getContentsString(): string {\n    const entryTuples = this.entryTuplesCache.access();\n    const byteWidths = this.maxByteWidthsCache.access();\n    let value = '';\n\n    for (\n      let entryIdx = 0, entriesLen = entryTuples.length;\n      entryIdx \u003c entriesLen;\n      entryIdx++\n    ) {\n      const [first, second, third] = entryTuples[entryIdx];\n\n      const firstBytes = reverseArray(bytesFor(first));\n      const secondBytes = reverseArray(bytesFor(second));\n      const thirdBytes = reverseArray(bytesFor(third));\n\n      for (let idx = byteWidths[0] - 1; idx \u003e= 0; idx--) {\n        value += (firstBytes[idx] || 0).toString(2);\n      }\n      for (let idx = byteWidths[1] - 1; idx \u003e= 0; idx--) {\n        value += (secondBytes[idx] || 0).toString(2);\n      }\n      for (let idx = byteWidths[2] - 1; idx \u003e= 0; idx--) {\n        value += (thirdBytes[idx] || 0).toString(2);\n      }\n    }\n\n    return value;\n  }\n\n  getUnencodedContents(): Uint8Array {\n    const entryTuples = this.entryTuplesCache.access();\n    const byteWidths = this.maxByteWidthsCache.access();\n    const buffer = new Uint8Array(this.getUnencodedContentsSize());\n\n    let offset = 0;\n    for (\n      let entryIdx = 0, entriesLen = entryTuples.length;\n      entryIdx \u003c entriesLen;\n      entryIdx++\n    ) {\n      const [first, second, third] = entryTuples[entryIdx];\n\n      const firstBytes = reverseArray(bytesFor(first));\n      const secondBytes = reverseArray(bytesFor(second));\n      const thirdBytes = reverseArray(bytesFor(third));\n\n      for (let idx = byteWidths[0] - 1; idx \u003e= 0; idx--) {\n        buffer[offset++] = firstBytes[idx] || 0;\n      }\n      for (let idx = byteWidths[1] - 1; idx \u003e= 0; idx--) {\n        buffer[offset++] = secondBytes[idx] || 0;\n      }\n      for (let idx = byteWidths[2] - 1; idx \u003e= 0; idx--) {\n        buffer[offset++] = thirdBytes[idx] || 0;\n      }\n    }\n\n    return buffer;\n  }\n\n  getUnencodedContentsSize(): number {\n    const byteWidths = this.maxByteWidthsCache.access();\n    const entryWidth = sum(byteWidths);\n    return entryWidth * this.entries.length;\n  }\n\n  updateDict(): void {\n    super.updateDict();\n\n    const byteWidths = this.maxByteWidthsCache.access();\n    const index = this.indexCache.access();\n\n    const { context } = this.dict;\n    this.dict.set(PDFName.of('W'), context.obj(byteWidths));\n    this.dict.set(PDFName.of('Index'), context.obj(index));\n  }\n\n  // Returns an array of integer pairs for each subsection of the cross ref\n  // section, where each integer pair represents:\n  //   firstObjectNumber(OfSection), length(OfSection)\n  private computeIndex = (): number[] =\u003e {\n    const subsections: number[] = [];\n\n    let subsectionLength = 0;\n    for (let idx = 0, len = this.entries.length; idx \u003c len; idx++) {\n      const currEntry = this.entries[idx];\n      const prevEntry = this.entries[idx - 1];\n\n      if (idx === 0) {\n        subsections.push(currEntry.ref.objectNumber);\n      } else if (currEntry.ref.objectNumber - prevEntry.ref.objectNumber \u003e 1) {\n        subsections.push(subsectionLength);\n        subsections.push(currEntry.ref.objectNumber);\n        subsectionLength = 0;\n      }\n\n      subsectionLength += 1;\n    }\n    subsections.push(subsectionLength);\n\n    return subsections;\n  };\n\n  private computeEntryTuples = (): EntryTuple[] =\u003e {\n    const entryTuples: EntryTuple[] = new Array(this.entries.length);\n\n    for (let idx = 0, len = this.entries.length; idx \u003c len; idx++) {\n      const entry = this.entries[idx];\n      if (entry.type === EntryType.Deleted) {\n        const { type, nextFreeObjectNumber, ref } = entry;\n        entryTuples[idx] = [type, nextFreeObjectNumber, ref.generationNumber];\n      }\n      if (entry.type === EntryType.Uncompressed) {\n        const { type, offset, ref } = entry;\n        entryTuples[idx] = [type, offset, ref.generationNumber];\n      }\n      if (entry.type === EntryType.Compressed) {\n        const { type, objectStreamRef, index } = entry;\n        entryTuples[idx] = [type, objectStreamRef.objectNumber, index];\n      }\n    }\n\n    return entryTuples;\n  };\n\n  private computeMaxEntryByteWidths = (): [number, number, number] =\u003e {\n    const entryTuples = this.entryTuplesCache.access();\n    const widths: [number, number, number] = [0, 0, 0];\n\n    for (let idx = 0, len = entryTuples.length; idx \u003c len; idx++) {\n      const [first, second, third] = entryTuples[idx];\n\n      const firstSize = sizeInBytes(first);\n      const secondSize = sizeInBytes(second);\n      const thirdSize = sizeInBytes(third);\n\n      if (firstSize \u003e widths[0]) widths[0] = firstSize;\n      if (secondSize \u003e widths[1]) widths[1] = secondSize;\n      if (thirdSize \u003e widths[2]) widths[2] = thirdSize;\n    }\n\n    return widths;\n  };\n}\n\nexport default PDFCrossRefStream;\n","import PDFHeader from 'src/core/document/PDFHeader';\nimport PDFTrailer from 'src/core/document/PDFTrailer';\nimport PDFInvalidObject from 'src/core/objects/PDFInvalidObject';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFCrossRefStream from 'src/core/structures/PDFCrossRefStream';\nimport PDFObjectStream from 'src/core/structures/PDFObjectStream';\nimport PDFWriter from 'src/core/writers/PDFWriter';\nimport { last, waitForTick } from 'src/utils';\n\nclass PDFStreamWriter extends PDFWriter {\n  static forContext = (\n    context: PDFContext,\n    objectsPerTick: number,\n    encodeStreams = true,\n    objectsPerStream = 50,\n  ) =\u003e\n    new PDFStreamWriter(\n      context,\n      objectsPerTick,\n      encodeStreams,\n      objectsPerStream,\n    );\n\n  private readonly encodeStreams: boolean;\n  private readonly objectsPerStream: number;\n\n  private constructor(\n    context: PDFContext,\n    objectsPerTick: number,\n    encodeStreams: boolean,\n    objectsPerStream: number,\n  ) {\n    super(context, objectsPerTick);\n\n    this.encodeStreams = encodeStreams;\n    this.objectsPerStream = objectsPerStream;\n  }\n\n  protected async computeBufferSize() {\n    let objectNumber = this.context.largestObjectNumber + 1;\n\n    const header = PDFHeader.forVersion(1, 7);\n\n    let size = header.sizeInBytes() + 2;\n\n    const xrefStream = PDFCrossRefStream.create(\n      this.createTrailerDict(),\n      this.encodeStreams,\n    );\n\n    const uncompressedObjects: [PDFRef, PDFObject][] = [];\n    const compressedObjects: [PDFRef, PDFObject][][] = [];\n    const objectStreamRefs: PDFRef[] = [];\n\n    const indirectObjects = this.context.enumerateIndirectObjects();\n    for (let idx = 0, len = indirectObjects.length; idx \u003c len; idx++) {\n      const indirectObject = indirectObjects[idx];\n      const [ref, object] = indirectObject;\n\n      const shouldNotCompress =\n        ref === this.context.trailerInfo.Encrypt ||\n        object instanceof PDFStream ||\n        object instanceof PDFInvalidObject ||\n        ref.generationNumber !== 0;\n\n      if (shouldNotCompress) {\n        uncompressedObjects.push(indirectObject);\n        xrefStream.addUncompressedEntry(ref, size);\n        size += this.computeIndirectObjectSize(indirectObject);\n        if (this.shouldWaitForTick(1)) await waitForTick();\n      } else {\n        let chunk = last(compressedObjects);\n        let objectStreamRef = last(objectStreamRefs);\n        if (!chunk || chunk.length % this.objectsPerStream === 0) {\n          chunk = [];\n          compressedObjects.push(chunk);\n          objectStreamRef = PDFRef.of(objectNumber++);\n          objectStreamRefs.push(objectStreamRef);\n        }\n        xrefStream.addCompressedEntry(ref, objectStreamRef, chunk.length);\n        chunk.push(indirectObject);\n      }\n    }\n\n    for (let idx = 0, len = compressedObjects.length; idx \u003c len; idx++) {\n      const chunk = compressedObjects[idx];\n      const ref = objectStreamRefs[idx];\n\n      const objectStream = PDFObjectStream.withContextAndObjects(\n        this.context,\n        chunk,\n        this.encodeStreams,\n      );\n\n      xrefStream.addUncompressedEntry(ref, size);\n      size += this.computeIndirectObjectSize([ref, objectStream]);\n\n      uncompressedObjects.push([ref, objectStream]);\n\n      if (this.shouldWaitForTick(chunk.length)) await waitForTick();\n    }\n\n    const xrefStreamRef = PDFRef.of(objectNumber++);\n    xrefStream.dict.set(PDFName.of('Size'), PDFNumber.of(objectNumber));\n    xrefStream.addUncompressedEntry(xrefStreamRef, size);\n    const xrefOffset = size;\n    size += this.computeIndirectObjectSize([xrefStreamRef, xrefStream]);\n\n    uncompressedObjects.push([xrefStreamRef, xrefStream]);\n\n    const trailer = PDFTrailer.forLastCrossRefSectionOffset(xrefOffset);\n    size += trailer.sizeInBytes();\n\n    return { size, header, indirectObjects: uncompressedObjects, trailer };\n  }\n}\n\nexport default PDFStreamWriter;\n","import {\n  Encodings,\n  Font,\n  FontNames,\n  EncodingType,\n} from '@pdf-lib/standard-fonts';\n\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\nimport { toCodePoint, toHexString } from 'src/utils';\n\nexport interface Glyph {\n  code: number;\n  name: string;\n}\n\n/**\n * A note of thanks to the developers of https://github.com/foliojs/pdfkit, as\n * this class borrows from:\n *   https://github.com/foliojs/pdfkit/blob/f91bdd61c164a72ea06be1a43dc0a412afc3925f/lib/font/afm.coffee\n */\nclass StandardFontEmbedder {\n  static for = (fontName: FontNames, customName?: string) =\u003e\n    new StandardFontEmbedder(fontName, customName);\n\n  readonly font: Font;\n  readonly encoding: EncodingType;\n  readonly fontName: string;\n  readonly customName: string | undefined;\n\n  private constructor(fontName: FontNames, customName?: string) {\n    // prettier-ignore\n    this.encoding = (\n        fontName === FontNames.ZapfDingbats ? Encodings.ZapfDingbats\n      : fontName === FontNames.Symbol       ? Encodings.Symbol\n      : Encodings.WinAnsi\n    );\n    this.font = Font.load(fontName);\n    this.fontName = this.font.FontName;\n    this.customName = customName;\n  }\n\n  /**\n   * Encode the JavaScript string into this font. (JavaScript encodes strings in\n   * Unicode, but standard fonts use either WinAnsi, ZapfDingbats, or Symbol\n   * encodings)\n   */\n  encodeText(text: string): PDFHexString {\n    const glyphs = this.encodeTextAsGlyphs(text);\n    const hexCodes = new Array(glyphs.length);\n    for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n      hexCodes[idx] = toHexString(glyphs[idx].code);\n    }\n    return PDFHexString.of(hexCodes.join(''));\n  }\n\n  widthOfTextAtSize(text: string, size: number): number {\n    const glyphs = this.encodeTextAsGlyphs(text);\n    let totalWidth = 0;\n\n    for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n      const left = glyphs[idx].name;\n      const right = (glyphs[idx + 1] || {}).name;\n      const kernAmount = this.font.getXAxisKerningForPair(left, right) || 0;\n      totalWidth += this.widthOfGlyph(left) + kernAmount;\n    }\n\n    const scale = size / 1000;\n    return totalWidth * scale;\n  }\n\n  heightOfFontAtSize(\n    size: number,\n    options: { descender?: boolean } = {},\n  ): number {\n    const { descender = true } = options;\n\n    const { Ascender, Descender, FontBBox } = this.font;\n    const yTop = Ascender || FontBBox[3];\n    const yBottom = Descender || FontBBox[1];\n\n    let height = yTop - yBottom;\n    if (!descender) height += Descender || 0;\n\n    return (height / 1000) * size;\n  }\n\n  sizeOfFontAtHeight(height: number): number {\n    const { Ascender, Descender, FontBBox } = this.font;\n    const yTop = Ascender || FontBBox[3];\n    const yBottom = Descender || FontBBox[1];\n    return (1000 * height) / (yTop - yBottom);\n  }\n\n  embedIntoContext(context: PDFContext, ref?: PDFRef): PDFRef {\n    const fontDict = context.obj({\n      Type: 'Font',\n      Subtype: 'Type1',\n      BaseFont: this.customName || this.fontName,\n\n      Encoding:\n        this.encoding === Encodings.WinAnsi ? 'WinAnsiEncoding' : undefined,\n    });\n\n    if (ref) {\n      context.assign(ref, fontDict);\n      return ref;\n    } else {\n      return context.register(fontDict);\n    }\n  }\n\n  private widthOfGlyph(glyphName: string): number {\n    // Default to 250 if font doesn't specify a width\n    return this.font.getWidthOfGlyph(glyphName) || 250;\n  }\n\n  private encodeTextAsGlyphs(text: string): Glyph[] {\n    const codePoints = Array.from(text);\n    const glyphs: Glyph[] = new Array(codePoints.length);\n    for (let idx = 0, len = codePoints.length; idx \u003c len; idx++) {\n      const codePoint = toCodePoint(codePoints[idx])!;\n      glyphs[idx] = this.encoding.encodeUnicodeCodePoint(codePoint);\n    }\n    return glyphs;\n  }\n}\n\nexport default StandardFontEmbedder;\n","import PDFObject from 'src/core/objects/PDFObject';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport {\n  copyStringIntoBuffer,\n  toHexStringOfMinLength,\n  utf16Decode,\n  utf16Encode,\n  pdfDocEncodingDecode,\n  parseDate,\n  hasUtf16BOM,\n} from 'src/utils';\nimport { InvalidPDFDateStringError } from 'src/core/errors';\n\nclass PDFHexString extends PDFObject {\n  static of = (value: string) =\u003e new PDFHexString(value);\n\n  static fromText = (value: string) =\u003e {\n    const encoded = utf16Encode(value);\n\n    let hex = '';\n    for (let idx = 0, len = encoded.length; idx \u003c len; idx++) {\n      hex += toHexStringOfMinLength(encoded[idx], 4);\n    }\n\n    return new PDFHexString(hex);\n  };\n\n  private readonly value: string;\n\n  constructor(value: string) {\n    super();\n    this.value = value;\n  }\n\n  asBytes(): Uint8Array {\n    // Append a zero if the number of digits is odd. See PDF spec 7.3.4.3\n    const hex = this.value + (this.value.length % 2 === 1 ? '0' : '');\n    const hexLength = hex.length;\n\n    const bytes = new Uint8Array(hex.length / 2);\n\n    let hexOffset = 0;\n    let bytesOffset = 0;\n\n    // Interpret each pair of hex digits as a single byte\n    while (hexOffset \u003c hexLength) {\n      const byte = parseInt(hex.substring(hexOffset, hexOffset + 2), 16);\n      bytes[bytesOffset] = byte;\n\n      hexOffset += 2;\n      bytesOffset += 1;\n    }\n\n    return bytes;\n  }\n\n  decodeText(): string {\n    const bytes = this.asBytes();\n    if (hasUtf16BOM(bytes)) return utf16Decode(bytes);\n    return pdfDocEncodingDecode(bytes);\n  }\n\n  decodeDate(): Date {\n    const text = this.decodeText();\n    const date = parseDate(text);\n    if (!date) throw new InvalidPDFDateStringError(text);\n    return date;\n  }\n\n  asString(): string {\n    return this.value;\n  }\n\n  clone(): PDFHexString {\n    return PDFHexString.of(this.value);\n  }\n\n  toString(): string {\n    return `\u003c${this.value}\u003e`;\n  }\n\n  sizeInBytes(): number {\n    return this.value.length + 2;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    buffer[offset++] = CharCodes.LessThan;\n    offset += copyStringIntoBuffer(this.value, buffer, offset);\n    buffer[offset++] = CharCodes.GreaterThan;\n    return this.value.length + 2;\n  }\n}\n\nexport default PDFHexString;\n","import { Glyph } from 'src/types/fontkit';\n\nimport { toHexString, toHexStringOfMinLength } from 'src/utils';\nimport {\n  hasSurrogates,\n  highSurrogate,\n  isWithinBMP,\n  lowSurrogate,\n} from 'src/utils/unicode';\n\n/** [fontId, codePoint] */\ntype BfChar = [string, string];\n\n/** `glyphs` should be an array of unique glyphs */\nexport const createCmap = (glyphs: Glyph[], glyphId: (g?: Glyph) =\u003e number) =\u003e {\n  const bfChars: BfChar[] = new Array(glyphs.length);\n  for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n    const glyph = glyphs[idx];\n    const id = cmapHexFormat(cmapHexString(glyphId(glyph)));\n    const unicode = cmapHexFormat(...glyph.codePoints.map(cmapCodePointFormat));\n    bfChars[idx] = [id, unicode];\n  }\n\n  return fillCmapTemplate(bfChars);\n};\n\n/* =============================== Templates ================================ */\n\nconst fillCmapTemplate = (bfChars: BfChar[]) =\u003e `\\\n/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo \u003c\u003c\n  /Registry (Adobe)\n  /Ordering (UCS)\n  /Supplement 0\n\u003e\u003e def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n\u003c0000\u003e\u003cffff\u003e\nendcodespacerange\n${bfChars.length} beginbfchar\n${bfChars.map(([glyphId, codePoint]) =\u003e `${glyphId} ${codePoint}`).join('\\n')}\nendbfchar\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend\\\n`;\n\n/* =============================== Utilities ================================ */\n\nconst cmapHexFormat = (...values: string[]) =\u003e `\u003c${values.join('')}\u003e`;\n\nconst cmapHexString = (value: number) =\u003e toHexStringOfMinLength(value, 4);\n\nconst cmapCodePointFormat = (codePoint: number) =\u003e {\n  if (isWithinBMP(codePoint)) return cmapHexString(codePoint);\n\n  if (hasSurrogates(codePoint)) {\n    const hs = highSurrogate(codePoint);\n    const ls = lowSurrogate(codePoint);\n    return `${cmapHexString(hs)}${cmapHexString(ls)}`;\n  }\n\n  const hex = toHexString(codePoint);\n  const msg = `0x${hex} is not a valid UTF-8 or UTF-16 codepoint.`;\n  throw new Error(msg);\n};\n","import { Font } from 'src/types/fontkit';\n\nexport interface FontFlagOptions {\n  fixedPitch?: boolean;\n  serif?: boolean;\n  symbolic?: boolean;\n  script?: boolean;\n  nonsymbolic?: boolean;\n  italic?: boolean;\n  allCap?: boolean;\n  smallCap?: boolean;\n  forceBold?: boolean;\n}\n\n// prettier-ignore\nconst makeFontFlags = (options: FontFlagOptions) =\u003e {\n  let flags = 0;\n\n  const flipBit = (bit: number) =\u003e { flags |= (1 \u003c\u003c (bit - 1)); };\n\n  if (options.fixedPitch)  flipBit(1);\n  if (options.serif)       flipBit(2);\n  if (options.symbolic)    flipBit(3);\n  if (options.script)      flipBit(4);\n  if (options.nonsymbolic) flipBit(6);\n  if (options.italic)      flipBit(7);\n  if (options.allCap)      flipBit(17);\n  if (options.smallCap)    flipBit(18);\n  if (options.forceBold)   flipBit(19);\n\n  return flags;\n};\n\n// From: https://github.com/foliojs/pdfkit/blob/83f5f7243172a017adcf6a7faa5547c55982c57b/lib/font/embedded.js#L123-L129\nexport const deriveFontFlags = (font: Font): number =\u003e {\n  const familyClass = font['OS/2'] ? font['OS/2'].sFamilyClass : 0;\n  const flags = makeFontFlags({\n    fixedPitch: font.post.isFixedPitch,\n    serif: 1 \u003c= familyClass \u0026\u0026 familyClass \u003c= 7,\n    symbolic: true, // Assume the font uses non-latin characters\n    script: familyClass === 10,\n    italic: font.head.macStyle.italic,\n  });\n  return flags;\n};\n","import PDFObject from 'src/core/objects/PDFObject';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport {\n  copyStringIntoBuffer,\n  padStart,\n  utf16Decode,\n  pdfDocEncodingDecode,\n  toCharCode,\n  parseDate,\n  hasUtf16BOM,\n} from 'src/utils';\nimport { InvalidPDFDateStringError } from 'src/core/errors';\n\nclass PDFString extends PDFObject {\n  // The PDF spec allows newlines and parens to appear directly within a literal\n  // string. These character _may_ be escaped. But they do not _have_ to be. So\n  // for simplicity, we will not bother escaping them.\n  static of = (value: string) =\u003e new PDFString(value);\n\n  static fromDate = (date: Date) =\u003e {\n    const year = padStart(String(date.getUTCFullYear()), 4, '0');\n    const month = padStart(String(date.getUTCMonth() + 1), 2, '0');\n    const day = padStart(String(date.getUTCDate()), 2, '0');\n    const hours = padStart(String(date.getUTCHours()), 2, '0');\n    const mins = padStart(String(date.getUTCMinutes()), 2, '0');\n    const secs = padStart(String(date.getUTCSeconds()), 2, '0');\n    return new PDFString(`D:${year}${month}${day}${hours}${mins}${secs}Z`);\n  };\n\n  private readonly value: string;\n\n  private constructor(value: string) {\n    super();\n    this.value = value;\n  }\n\n  asBytes(): Uint8Array {\n    const bytes: number[] = [];\n\n    let octal = '';\n    let escaped = false;\n\n    const pushByte = (byte?: number) =\u003e {\n      if (byte !== undefined) bytes.push(byte);\n      escaped = false;\n    };\n\n    for (let idx = 0, len = this.value.length; idx \u003c len; idx++) {\n      const char = this.value[idx];\n      const byte = toCharCode(char);\n      const nextChar = this.value[idx + 1];\n      if (!escaped) {\n        if (byte === CharCodes.BackSlash) escaped = true;\n        else pushByte(byte);\n      } else {\n        if (byte === CharCodes.Newline) pushByte();\n        else if (byte === CharCodes.CarriageReturn) pushByte();\n        else if (byte === CharCodes.n) pushByte(CharCodes.Newline);\n        else if (byte === CharCodes.r) pushByte(CharCodes.CarriageReturn);\n        else if (byte === CharCodes.t) pushByte(CharCodes.Tab);\n        else if (byte === CharCodes.b) pushByte(CharCodes.Backspace);\n        else if (byte === CharCodes.f) pushByte(CharCodes.FormFeed);\n        else if (byte === CharCodes.LeftParen) pushByte(CharCodes.LeftParen);\n        else if (byte === CharCodes.RightParen) pushByte(CharCodes.RightParen);\n        else if (byte === CharCodes.Backspace) pushByte(CharCodes.BackSlash);\n        else if (byte \u003e= CharCodes.Zero \u0026\u0026 byte \u003c= CharCodes.Seven) {\n          octal += char;\n          if (octal.length === 3 || !(nextChar \u003e= '0' \u0026\u0026 nextChar \u003c= '7')) {\n            pushByte(parseInt(octal, 8));\n            octal = '';\n          }\n        } else {\n          pushByte(byte);\n        }\n      }\n    }\n\n    return new Uint8Array(bytes);\n  }\n\n  decodeText(): string {\n    const bytes = this.asBytes();\n    if (hasUtf16BOM(bytes)) return utf16Decode(bytes);\n    return pdfDocEncodingDecode(bytes);\n  }\n\n  decodeDate(): Date {\n    const text = this.decodeText();\n    const date = parseDate(text);\n    if (!date) throw new InvalidPDFDateStringError(text);\n    return date;\n  }\n\n  asString(): string {\n    return this.value;\n  }\n\n  clone(): PDFString {\n    return PDFString.of(this.value);\n  }\n\n  toString(): string {\n    return `(${this.value})`;\n  }\n\n  sizeInBytes(): number {\n    return this.value.length + 2;\n  }\n\n  copyBytesInto(buffer: Uint8Array, offset: number): number {\n    buffer[offset++] = CharCodes.LeftParen;\n    offset += copyStringIntoBuffer(this.value, buffer, offset);\n    buffer[offset++] = CharCodes.RightParen;\n    return this.value.length + 2;\n  }\n}\n\nexport default PDFString;\n","import { Font, Fontkit, Glyph, TypeFeatures } from 'src/types/fontkit';\n\nimport { createCmap } from 'src/core/embedders/CMap';\nimport { deriveFontFlags } from 'src/core/embedders/FontFlags';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFContext from 'src/core/PDFContext';\nimport {\n  byAscendingId,\n  Cache,\n  sortedUniq,\n  toHexStringOfMinLength,\n} from 'src/utils';\n\n/**\n * A note of thanks to the developers of https://github.com/foliojs/pdfkit, as\n * this class borrows from:\n *   https://github.com/devongovett/pdfkit/blob/e71edab0dd4657b5a767804ba86c94c58d01fbca/lib/image/jpeg.coffee\n */\nclass CustomFontEmbedder {\n  static async for(\n    fontkit: Fontkit,\n    fontData: Uint8Array,\n    customName?: string,\n    fontFeatures?: TypeFeatures,\n  ) {\n    const font = await fontkit.create(fontData);\n    return new CustomFontEmbedder(font, fontData, customName, fontFeatures);\n  }\n\n  readonly font: Font;\n  readonly scale: number;\n  readonly fontData: Uint8Array;\n  readonly fontName: string;\n  readonly customName: string | undefined;\n  readonly fontFeatures: TypeFeatures | undefined;\n\n  protected baseFontName: string;\n  protected glyphCache: Cache\u003cGlyph[]\u003e;\n\n  protected constructor(\n    font: Font,\n    fontData: Uint8Array,\n    customName?: string,\n    fontFeatures?: TypeFeatures,\n  ) {\n    this.font = font;\n    this.scale = 1000 / this.font.unitsPerEm;\n    this.fontData = fontData;\n    this.fontName = this.font.postscriptName || 'Font';\n    this.customName = customName;\n    this.fontFeatures = fontFeatures;\n\n    this.baseFontName = '';\n    this.glyphCache = Cache.populatedBy(this.allGlyphsInFontSortedById);\n  }\n\n  /**\n   * Encode the JavaScript string into this font. (JavaScript encodes strings in\n   * Unicode, but embedded fonts use their own custom encodings)\n   */\n  encodeText(text: string): PDFHexString {\n    const { glyphs } = this.font.layout(text, this.fontFeatures);\n    const hexCodes = new Array(glyphs.length);\n    for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n      hexCodes[idx] = toHexStringOfMinLength(glyphs[idx].id, 4);\n    }\n    return PDFHexString.of(hexCodes.join(''));\n  }\n\n  // The advanceWidth takes into account kerning automatically, so we don't\n  // have to do that manually like we do for the standard fonts.\n  widthOfTextAtSize(text: string, size: number): number {\n    const { glyphs } = this.font.layout(text, this.fontFeatures);\n    let totalWidth = 0;\n    for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n      totalWidth += glyphs[idx].advanceWidth * this.scale;\n    }\n    const scale = size / 1000;\n    return totalWidth * scale;\n  }\n\n  heightOfFontAtSize(\n    size: number,\n    options: { descender?: boolean } = {},\n  ): number {\n    const { descender = true } = options;\n\n    const { ascent, descent, bbox } = this.font;\n    const yTop = (ascent || bbox.maxY) * this.scale;\n    const yBottom = (descent || bbox.minY) * this.scale;\n\n    let height = yTop - yBottom;\n    if (!descender) height -= Math.abs(descent) || 0;\n\n    return (height / 1000) * size;\n  }\n\n  sizeOfFontAtHeight(height: number): number {\n    const { ascent, descent, bbox } = this.font;\n    const yTop = (ascent || bbox.maxY) * this.scale;\n    const yBottom = (descent || bbox.minY) * this.scale;\n    return (1000 * height) / (yTop - yBottom);\n  }\n\n  embedIntoContext(context: PDFContext, ref?: PDFRef): Promise\u003cPDFRef\u003e {\n    this.baseFontName =\n      this.customName || context.addRandomSuffix(this.fontName);\n    return this.embedFontDict(context, ref);\n  }\n\n  protected async embedFontDict(\n    context: PDFContext,\n    ref?: PDFRef,\n  ): Promise\u003cPDFRef\u003e {\n    const cidFontDictRef = await this.embedCIDFontDict(context);\n    const unicodeCMapRef = this.embedUnicodeCmap(context);\n\n    const fontDict = context.obj({\n      Type: 'Font',\n      Subtype: 'Type0',\n      BaseFont: this.baseFontName,\n      Encoding: 'Identity-H',\n      DescendantFonts: [cidFontDictRef],\n      ToUnicode: unicodeCMapRef,\n    });\n\n    if (ref) {\n      context.assign(ref, fontDict);\n      return ref;\n    } else {\n      return context.register(fontDict);\n    }\n  }\n\n  protected isCFF(): boolean {\n    return this.font.cff;\n  }\n\n  protected async embedCIDFontDict(context: PDFContext): Promise\u003cPDFRef\u003e {\n    const fontDescriptorRef = await this.embedFontDescriptor(context);\n\n    const cidFontDict = context.obj({\n      Type: 'Font',\n      Subtype: this.isCFF() ? 'CIDFontType0' : 'CIDFontType2',\n      CIDToGIDMap: 'Identity',\n      BaseFont: this.baseFontName,\n      CIDSystemInfo: {\n        Registry: PDFString.of('Adobe'),\n        Ordering: PDFString.of('Identity'),\n        Supplement: 0,\n      },\n      FontDescriptor: fontDescriptorRef,\n      W: this.computeWidths(),\n    });\n\n    return context.register(cidFontDict);\n  }\n\n  protected async embedFontDescriptor(context: PDFContext): Promise\u003cPDFRef\u003e {\n    const fontStreamRef = await this.embedFontStream(context);\n\n    const { scale } = this;\n    const { italicAngle, ascent, descent, capHeight, xHeight } = this.font;\n    const { minX, minY, maxX, maxY } = this.font.bbox;\n\n    const fontDescriptor = context.obj({\n      Type: 'FontDescriptor',\n      FontName: this.baseFontName,\n      Flags: deriveFontFlags(this.font),\n      FontBBox: [minX * scale, minY * scale, maxX * scale, maxY * scale],\n      ItalicAngle: italicAngle,\n      Ascent: ascent * scale,\n      Descent: descent * scale,\n      CapHeight: (capHeight || ascent) * scale,\n      XHeight: (xHeight || 0) * scale,\n\n      // Not sure how to compute/find this, nor is anybody else really:\n      // https://stackoverflow.com/questions/35485179/stemv-value-of-the-truetype-font\n      StemV: 0,\n\n      [this.isCFF() ? 'FontFile3' : 'FontFile2']: fontStreamRef,\n    });\n\n    return context.register(fontDescriptor);\n  }\n\n  protected async serializeFont(): Promise\u003cUint8Array\u003e {\n    return this.fontData;\n  }\n\n  protected async embedFontStream(context: PDFContext): Promise\u003cPDFRef\u003e {\n    const fontStream = context.flateStream(await this.serializeFont(), {\n      Subtype: this.isCFF() ? 'CIDFontType0C' : undefined,\n    });\n    return context.register(fontStream);\n  }\n\n  protected embedUnicodeCmap(context: PDFContext): PDFRef {\n    const cmap = createCmap(this.glyphCache.access(), this.glyphId.bind(this));\n    const cmapStream = context.flateStream(cmap);\n    return context.register(cmapStream);\n  }\n\n  protected glyphId(glyph?: Glyph): number {\n    return glyph ? glyph.id : -1;\n  }\n\n  protected computeWidths(): (number | number[])[] {\n    const glyphs = this.glyphCache.access();\n\n    const widths: (number | number[])[] = [];\n    let currSection: number[] = [];\n\n    for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n      const currGlyph = glyphs[idx];\n      const prevGlyph = glyphs[idx - 1];\n\n      const currGlyphId = this.glyphId(currGlyph);\n      const prevGlyphId = this.glyphId(prevGlyph);\n\n      if (idx === 0) {\n        widths.push(currGlyphId);\n      } else if (currGlyphId - prevGlyphId !== 1) {\n        widths.push(currSection);\n        widths.push(currGlyphId);\n        currSection = [];\n      }\n\n      currSection.push(currGlyph.advanceWidth * this.scale);\n    }\n\n    widths.push(currSection);\n\n    return widths;\n  }\n\n  private allGlyphsInFontSortedById = (): Glyph[] =\u003e {\n    const glyphs: Glyph[] = new Array(this.font.characterSet.length);\n    for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n      const codePoint = this.font.characterSet[idx];\n      glyphs[idx] = this.font.glyphForCodePoint(codePoint);\n    }\n    return sortedUniq(glyphs.sort(byAscendingId), (g) =\u003e g.id);\n  };\n}\n\nexport default CustomFontEmbedder;\n","import { Font, Fontkit, Glyph, Subset, TypeFeatures } from 'src/types/fontkit';\n\nimport CustomFontEmbedder from 'src/core/embedders/CustomFontEmbedder';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport { Cache, mergeUint8Arrays, toHexStringOfMinLength } from 'src/utils';\n\n/**\n * A note of thanks to the developers of https://github.com/foliojs/pdfkit, as\n * this class borrows from:\n *   https://github.com/devongovett/pdfkit/blob/e71edab0dd4657b5a767804ba86c94c58d01fbca/lib/image/jpeg.coffee\n */\nclass CustomFontSubsetEmbedder extends CustomFontEmbedder {\n  static async for(\n    fontkit: Fontkit,\n    fontData: Uint8Array,\n    customFontName?: string,\n    fontFeatures?: TypeFeatures,\n  ) {\n    const font = await fontkit.create(fontData);\n    return new CustomFontSubsetEmbedder(\n      font,\n      fontData,\n      customFontName,\n      fontFeatures,\n    );\n  }\n\n  private readonly subset: Subset;\n  private readonly glyphs: Glyph[];\n  private readonly glyphIdMap: Map\u003cnumber, number\u003e;\n\n  private constructor(\n    font: Font,\n    fontData: Uint8Array,\n    customFontName?: string,\n    fontFeatures?: TypeFeatures,\n  ) {\n    super(font, fontData, customFontName, fontFeatures);\n\n    this.subset = this.font.createSubset();\n    this.glyphs = [];\n    this.glyphCache = Cache.populatedBy(() =\u003e this.glyphs);\n    this.glyphIdMap = new Map();\n  }\n\n  encodeText(text: string): PDFHexString {\n    const { glyphs } = this.font.layout(text, this.fontFeatures);\n    const hexCodes = new Array(glyphs.length);\n\n    for (let idx = 0, len = glyphs.length; idx \u003c len; idx++) {\n      const glyph = glyphs[idx];\n      const subsetGlyphId = this.subset.includeGlyph(glyph);\n\n      this.glyphs[subsetGlyphId - 1] = glyph;\n      this.glyphIdMap.set(glyph.id, subsetGlyphId);\n\n      hexCodes[idx] = toHexStringOfMinLength(subsetGlyphId, 4);\n    }\n\n    this.glyphCache.invalidate();\n    return PDFHexString.of(hexCodes.join(''));\n  }\n\n  protected isCFF(): boolean {\n    return (this.subset as any).cff;\n  }\n\n  protected glyphId(glyph?: Glyph): number {\n    return glyph ? this.glyphIdMap.get(glyph.id)! : -1;\n  }\n\n  protected serializeFont(): Promise\u003cUint8Array\u003e {\n    return new Promise((resolve, reject) =\u003e {\n      const parts: Uint8Array[] = [];\n      this.subset\n        .encodeStream()\n        .on('data', (bytes) =\u003e parts.push(bytes))\n        .on('end', () =\u003e resolve(mergeUint8Arrays(parts)))\n        .on('error' as any, (err) =\u003e reject(err));\n    });\n  }\n}\n\nexport default CustomFontSubsetEmbedder;\n","import PDFString from 'src/core/objects/PDFString';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFRef from 'src/core/objects/PDFRef';\n\n/**\n * From the PDF-A3 specification, section **3.1. Requirements - General**.\n * See:\n * * https://www.pdfa.org/wp-content/uploads/2018/10/PDF20_AN002-AF.pdf\n */\nexport enum AFRelationship {\n  Source = 'Source',\n  Data = 'Data',\n  Alternative = 'Alternative',\n  Supplement = 'Supplement',\n  EncryptedPayload = 'EncryptedPayload',\n  FormData = 'EncryptedPayload',\n  Schema = 'Schema',\n  Unspecified = 'Unspecified',\n}\n\nexport interface EmbeddedFileOptions {\n  mimeType?: string;\n  description?: string;\n  creationDate?: Date;\n  modificationDate?: Date;\n  afRelationship?: AFRelationship;\n}\n\nclass FileEmbedder {\n  static for(\n    bytes: Uint8Array,\n    fileName: string,\n    options: EmbeddedFileOptions = {},\n  ) {\n    return new FileEmbedder(bytes, fileName, options);\n  }\n\n  private readonly fileData: Uint8Array;\n  readonly fileName: string;\n  readonly options: EmbeddedFileOptions;\n\n  private constructor(\n    fileData: Uint8Array,\n    fileName: string,\n    options: EmbeddedFileOptions = {},\n  ) {\n    this.fileData = fileData;\n    this.fileName = fileName;\n    this.options = options;\n  }\n\n  async embedIntoContext(context: PDFContext, ref?: PDFRef): Promise\u003cPDFRef\u003e {\n    const {\n      mimeType,\n      description,\n      creationDate,\n      modificationDate,\n      afRelationship,\n    } = this.options;\n\n    const embeddedFileStream = context.flateStream(this.fileData, {\n      Type: 'EmbeddedFile',\n      Subtype: mimeType ?? undefined,\n      Params: {\n        Size: this.fileData.length,\n        CreationDate: creationDate\n          ? PDFString.fromDate(creationDate)\n          : undefined,\n        ModDate: modificationDate\n          ? PDFString.fromDate(modificationDate)\n          : undefined,\n      },\n    });\n    const embeddedFileStreamRef = context.register(embeddedFileStream);\n\n    const fileSpecDict = context.obj({\n      Type: 'Filespec',\n      F: PDFString.of(this.fileName), // TODO: Assert that this is plain ASCII\n      UF: PDFHexString.fromText(this.fileName),\n      EF: { F: embeddedFileStreamRef },\n      Desc: description ? PDFHexString.fromText(description) : undefined,\n      AFRelationship: afRelationship ?? undefined,\n    });\n\n    if (ref) {\n      context.assign(ref, fileSpecDict);\n      return ref;\n    } else {\n      return context.register(fileSpecDict);\n    }\n  }\n}\n\nexport default FileEmbedder;\n","import PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\n\n// prettier-ignore\nconst MARKERS = [\n  0xffc0, 0xffc1, 0xffc2,\n  0xffc3, 0xffc5, 0xffc6,\n  0xffc7, 0xffc8, 0xffc9,\n  0xffca, 0xffcb, 0xffcc,\n  0xffcd, 0xffce, 0xffcf,\n];\n\nenum ColorSpace {\n  DeviceGray = 'DeviceGray',\n  DeviceRGB = 'DeviceRGB',\n  DeviceCMYK = 'DeviceCMYK',\n}\n\nconst ChannelToColorSpace: { [idx: number]: ColorSpace | undefined } = {\n  1: ColorSpace.DeviceGray,\n  3: ColorSpace.DeviceRGB,\n  4: ColorSpace.DeviceCMYK,\n};\n\n/**\n * A note of thanks to the developers of https://github.com/foliojs/pdfkit, as\n * this class borrows from:\n *   https://github.com/foliojs/pdfkit/blob/a6af76467ce06bd6a2af4aa7271ccac9ff152a7d/lib/image/jpeg.js\n */\nclass JpegEmbedder {\n  static async for(imageData: Uint8Array) {\n    const dataView = new DataView(imageData.buffer);\n\n    const soi = dataView.getUint16(0);\n    if (soi !== 0xffd8) throw new Error('SOI not found in JPEG');\n\n    let pos = 2;\n    let marker: number;\n\n    while (pos \u003c dataView.byteLength) {\n      marker = dataView.getUint16(pos);\n      pos += 2;\n      if (MARKERS.includes(marker)) break;\n      pos += dataView.getUint16(pos);\n    }\n\n    if (!MARKERS.includes(marker!)) throw new Error('Invalid JPEG');\n    pos += 2;\n\n    const bitsPerComponent = dataView.getUint8(pos++);\n    const height = dataView.getUint16(pos);\n    pos += 2;\n\n    const width = dataView.getUint16(pos);\n    pos += 2;\n\n    const channelByte = dataView.getUint8(pos++);\n    const channelName = ChannelToColorSpace[channelByte];\n\n    if (!channelName) throw new Error('Unknown JPEG channel.');\n\n    const colorSpace = channelName;\n\n    return new JpegEmbedder(\n      imageData,\n      bitsPerComponent,\n      width,\n      height,\n      colorSpace,\n    );\n  }\n\n  readonly bitsPerComponent: number;\n  readonly height: number;\n  readonly width: number;\n  readonly colorSpace: ColorSpace;\n\n  private readonly imageData: Uint8Array;\n\n  private constructor(\n    imageData: Uint8Array,\n    bitsPerComponent: number,\n    width: number,\n    height: number,\n    colorSpace: ColorSpace,\n  ) {\n    this.imageData = imageData;\n    this.bitsPerComponent = bitsPerComponent;\n    this.width = width;\n    this.height = height;\n    this.colorSpace = colorSpace;\n  }\n\n  async embedIntoContext(context: PDFContext, ref?: PDFRef): Promise\u003cPDFRef\u003e {\n    const xObject = context.stream(this.imageData, {\n      Type: 'XObject',\n      Subtype: 'Image',\n      BitsPerComponent: this.bitsPerComponent,\n      Width: this.width,\n      Height: this.height,\n      ColorSpace: this.colorSpace,\n      Filter: 'DCTDecode',\n\n      // CMYK JPEG streams in PDF are typically stored complemented,\n      // with 1 as 'off' and 0 as 'on' (PDF 32000-1:2008, 8.6.4.4).\n      //\n      // Standalone CMYK JPEG (usually exported by Photoshop) are\n      // stored inverse, with 0 as 'off' and 1 as 'on', like RGB.\n      //\n      // Applying a swap here as a hedge that most bytes passing\n      // through this method will benefit from it.\n      Decode:\n        this.colorSpace === ColorSpace.DeviceCMYK\n          ? [1, 0, 1, 0, 1, 0, 1, 0]\n          : undefined,\n    });\n\n    if (ref) {\n      context.assign(ref, xObject);\n      return ref;\n    } else {\n      return context.register(xObject);\n    }\n  }\n}\n\nexport default JpegEmbedder;\n","import UPNG from '@pdf-lib/upng';\n\nconst getImageType = (ctype: number) =\u003e {\n  if (ctype === 0) return PngType.Greyscale;\n  if (ctype === 2) return PngType.Truecolour;\n  if (ctype === 3) return PngType.IndexedColour;\n  if (ctype === 4) return PngType.GreyscaleWithAlpha;\n  if (ctype === 6) return PngType.TruecolourWithAlpha;\n  throw new Error(`Unknown color type: ${ctype}`);\n};\n\nconst splitAlphaChannel = (rgbaChannel: Uint8Array) =\u003e {\n  const pixelCount = Math.floor(rgbaChannel.length / 4);\n\n  const rgbChannel = new Uint8Array(pixelCount * 3);\n  const alphaChannel = new Uint8Array(pixelCount * 1);\n\n  let rgbaOffset = 0;\n  let rgbOffset = 0;\n  let alphaOffset = 0;\n\n  while (rgbaOffset \u003c rgbaChannel.length) {\n    rgbChannel[rgbOffset++] = rgbaChannel[rgbaOffset++];\n    rgbChannel[rgbOffset++] = rgbaChannel[rgbaOffset++];\n    rgbChannel[rgbOffset++] = rgbaChannel[rgbaOffset++];\n    alphaChannel[alphaOffset++] = rgbaChannel[rgbaOffset++];\n  }\n\n  return { rgbChannel, alphaChannel };\n};\n\nexport enum PngType {\n  Greyscale = 'Greyscale',\n  Truecolour = 'Truecolour',\n  IndexedColour = 'IndexedColour',\n  GreyscaleWithAlpha = 'GreyscaleWithAlpha',\n  TruecolourWithAlpha = 'TruecolourWithAlpha',\n}\n\nexport class PNG {\n  static load = (pngData: Uint8Array) =\u003e new PNG(pngData);\n\n  readonly rgbChannel: Uint8Array;\n  readonly alphaChannel?: Uint8Array;\n  readonly type: PngType;\n  readonly width: number;\n  readonly height: number;\n  readonly bitsPerComponent: number;\n\n  private constructor(pngData: Uint8Array) {\n    const upng = UPNG.decode(pngData);\n    const frames = UPNG.toRGBA8(upng);\n\n    if (frames.length \u003e 1) throw new Error(`Animated PNGs are not supported`);\n\n    const frame = new Uint8Array(frames[0]);\n    const { rgbChannel, alphaChannel } = splitAlphaChannel(frame);\n\n    this.rgbChannel = rgbChannel;\n\n    const hasAlphaValues = alphaChannel.some((a) =\u003e a \u003c 255);\n    if (hasAlphaValues) this.alphaChannel = alphaChannel;\n\n    this.type = getImageType(upng.ctype);\n\n    this.width = upng.width;\n    this.height = upng.height;\n    this.bitsPerComponent = 8;\n  }\n}\n","import PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\nimport { PNG } from 'src/utils/png';\n\n/**\n * A note of thanks to the developers of https://github.com/foliojs/pdfkit, as\n * this class borrows from:\n *   https://github.com/devongovett/pdfkit/blob/e71edab0dd4657b5a767804ba86c94c58d01fbca/lib/image/png.coffee\n */\nclass PngEmbedder {\n  static async for(imageData: Uint8Array) {\n    const png = PNG.load(imageData);\n    return new PngEmbedder(png);\n  }\n\n  readonly bitsPerComponent: number;\n  readonly height: number;\n  readonly width: number;\n  readonly colorSpace: 'DeviceRGB';\n\n  private readonly image: PNG;\n\n  private constructor(png: PNG) {\n    this.image = png;\n    this.bitsPerComponent = png.bitsPerComponent;\n    this.width = png.width;\n    this.height = png.height;\n    this.colorSpace = 'DeviceRGB';\n  }\n\n  async embedIntoContext(context: PDFContext, ref?: PDFRef): Promise\u003cPDFRef\u003e {\n    const SMask = this.embedAlphaChannel(context);\n\n    const xObject = context.flateStream(this.image.rgbChannel, {\n      Type: 'XObject',\n      Subtype: 'Image',\n      BitsPerComponent: this.image.bitsPerComponent,\n      Width: this.image.width,\n      Height: this.image.height,\n      ColorSpace: this.colorSpace,\n      SMask,\n    });\n\n    if (ref) {\n      context.assign(ref, xObject);\n      return ref;\n    } else {\n      return context.register(xObject);\n    }\n  }\n\n  private embedAlphaChannel(context: PDFContext): PDFRef | undefined {\n    if (!this.image.alphaChannel) return undefined;\n\n    const xObject = context.flateStream(this.image.alphaChannel, {\n      Type: 'XObject',\n      Subtype: 'Image',\n      Height: this.image.height,\n      Width: this.image.width,\n      BitsPerComponent: this.image.bitsPerComponent,\n      ColorSpace: 'DeviceGray',\n      Decode: [0, 1],\n    });\n\n    return context.register(xObject);\n  }\n}\n\nexport default PngEmbedder;\n","/*\n * Copyright 2012 Mozilla Foundation\n *\n * The Stream class contained in this file is a TypeScript port of the\n * JavaScript Stream class in Mozilla's pdf.js project, made available\n * under the Apache 2.0 open source license.\n */\n\nexport interface StreamType {\n  isEmpty: boolean;\n  getByte(): number;\n  getUint16(): number;\n  getInt32(): number;\n  getBytes(\n    length: number,\n    forceClamped?: boolean,\n  ): Uint8Array | Uint8ClampedArray;\n  peekByte(): number;\n  peekBytes(\n    length: number,\n    forceClamped?: boolean,\n  ): Uint8Array | Uint8ClampedArray;\n  skip(n: number): void;\n  reset(): void;\n  makeSubStream(start: number, length: number): StreamType;\n  decode(): Uint8Array;\n}\n\nclass Stream implements StreamType {\n  private bytes: Uint8Array;\n  private start: number;\n  private pos: number;\n  private end: number;\n\n  constructor(buffer: Uint8Array, start?: number, length?: number) {\n    this.bytes = buffer;\n    this.start = start || 0;\n    this.pos = this.start;\n    this.end = !!start \u0026\u0026 !!length ? start + length : this.bytes.length;\n  }\n\n  get length() {\n    return this.end - this.start;\n  }\n\n  get isEmpty() {\n    return this.length === 0;\n  }\n\n  getByte() {\n    if (this.pos \u003e= this.end) {\n      return -1;\n    }\n    return this.bytes[this.pos++];\n  }\n\n  getUint16() {\n    const b0 = this.getByte();\n    const b1 = this.getByte();\n    if (b0 === -1 || b1 === -1) {\n      return -1;\n    }\n    return (b0 \u003c\u003c 8) + b1;\n  }\n\n  getInt32() {\n    const b0 = this.getByte();\n    const b1 = this.getByte();\n    const b2 = this.getByte();\n    const b3 = this.getByte();\n    return (b0 \u003c\u003c 24) + (b1 \u003c\u003c 16) + (b2 \u003c\u003c 8) + b3;\n  }\n\n  // Returns subarray of original buffer, should only be read.\n  getBytes(length: number, forceClamped = false) {\n    const bytes = this.bytes;\n    const pos = this.pos;\n    const strEnd = this.end;\n\n    if (!length) {\n      const subarray = bytes.subarray(pos, strEnd);\n      // `this.bytes` is always a `Uint8Array` here.\n      return forceClamped ? new Uint8ClampedArray(subarray) : subarray;\n    } else {\n      let end = pos + length;\n      if (end \u003e strEnd) {\n        end = strEnd;\n      }\n      this.pos = end;\n      const subarray = bytes.subarray(pos, end);\n      // `this.bytes` is always a `Uint8Array` here.\n      return forceClamped ? new Uint8ClampedArray(subarray) : subarray;\n    }\n  }\n\n  peekByte() {\n    const peekedByte = this.getByte();\n    this.pos--;\n    return peekedByte;\n  }\n\n  peekBytes(length: number, forceClamped = false) {\n    const bytes = this.getBytes(length, forceClamped);\n    this.pos -= bytes.length;\n    return bytes;\n  }\n\n  skip(n: number) {\n    if (!n) {\n      n = 1;\n    }\n    this.pos += n;\n  }\n\n  reset() {\n    this.pos = this.start;\n  }\n\n  moveStart() {\n    this.start = this.pos;\n  }\n\n  makeSubStream(start: number, length: number) {\n    return new Stream(this.bytes, start, length);\n  }\n\n  decode(): Uint8Array {\n    return this.bytes;\n  }\n}\n\nexport default Stream;\n","import { MethodNotImplementedError } from 'src/core/errors';\nimport Stream, { StreamType } from 'src/core/streams/Stream';\n\n/*\n * Copyright 2012 Mozilla Foundation\n *\n * The DecodeStream class contained in this file is a TypeScript port of the\n * JavaScript DecodeStream class in Mozilla's pdf.js project, made available\n * under the Apache 2.0 open source license.\n */\n\n// Lots of DecodeStreams are created whose buffers are never used.  For these\n// we share a single empty buffer. This is (a) space-efficient and (b) avoids\n// having special cases that would be required if we used |null| for an empty\n// buffer.\nconst emptyBuffer = new Uint8Array(0);\n\n/**\n * Super class for the decoding streams\n */\nclass DecodeStream implements StreamType {\n  protected bufferLength: number;\n  protected buffer: Uint8Array;\n  protected eof: boolean;\n\n  private pos: number;\n  private minBufferLength: number;\n\n  constructor(maybeMinBufferLength?: number) {\n    this.pos = 0;\n    this.bufferLength = 0;\n    this.eof = false;\n    this.buffer = emptyBuffer;\n    this.minBufferLength = 512;\n    if (maybeMinBufferLength) {\n      // Compute the first power of two that is as big as maybeMinBufferLength.\n      while (this.minBufferLength \u003c maybeMinBufferLength) {\n        this.minBufferLength *= 2;\n      }\n    }\n  }\n\n  get isEmpty() {\n    while (!this.eof \u0026\u0026 this.bufferLength === 0) {\n      this.readBlock();\n    }\n    return this.bufferLength === 0;\n  }\n\n  getByte() {\n    const pos = this.pos;\n    while (this.bufferLength \u003c= pos) {\n      if (this.eof) {\n        return -1;\n      }\n      this.readBlock();\n    }\n    return this.buffer[this.pos++];\n  }\n\n  getUint16() {\n    const b0 = this.getByte();\n    const b1 = this.getByte();\n    if (b0 === -1 || b1 === -1) {\n      return -1;\n    }\n    return (b0 \u003c\u003c 8) + b1;\n  }\n\n  getInt32() {\n    const b0 = this.getByte();\n    const b1 = this.getByte();\n    const b2 = this.getByte();\n    const b3 = this.getByte();\n    return (b0 \u003c\u003c 24) + (b1 \u003c\u003c 16) + (b2 \u003c\u003c 8) + b3;\n  }\n\n  getBytes(length: number, forceClamped = false) {\n    let end;\n    const pos = this.pos;\n\n    if (length) {\n      this.ensureBuffer(pos + length);\n      end = pos + length;\n\n      while (!this.eof \u0026\u0026 this.bufferLength \u003c end) {\n        this.readBlock();\n      }\n      const bufEnd = this.bufferLength;\n      if (end \u003e bufEnd) {\n        end = bufEnd;\n      }\n    } else {\n      while (!this.eof) {\n        this.readBlock();\n      }\n      end = this.bufferLength;\n    }\n\n    this.pos = end;\n    const subarray = this.buffer.subarray(pos, end);\n    // `this.buffer` is either a `Uint8Array` or `Uint8ClampedArray` here.\n    return forceClamped \u0026\u0026 !(subarray instanceof Uint8ClampedArray)\n      ? new Uint8ClampedArray(subarray)\n      : subarray;\n  }\n\n  peekByte() {\n    const peekedByte = this.getByte();\n    this.pos--;\n    return peekedByte;\n  }\n\n  peekBytes(length: number, forceClamped = false) {\n    const bytes = this.getBytes(length, forceClamped);\n    this.pos -= bytes.length;\n    return bytes;\n  }\n\n  skip(n: number) {\n    if (!n) {\n      n = 1;\n    }\n    this.pos += n;\n  }\n\n  reset() {\n    this.pos = 0;\n  }\n\n  makeSubStream(start: number, length: number /* dict */) {\n    const end = start + length;\n    while (this.bufferLength \u003c= end \u0026\u0026 !this.eof) {\n      this.readBlock();\n    }\n    return new Stream(this.buffer, start, length /* dict */);\n  }\n\n  decode(): Uint8Array {\n    while (!this.eof) this.readBlock();\n    return this.buffer.subarray(0, this.bufferLength);\n  }\n\n  protected readBlock(): void {\n    throw new MethodNotImplementedError(this.constructor.name, 'readBlock');\n  }\n\n  protected ensureBuffer(requested: number) {\n    const buffer = this.buffer;\n    if (requested \u003c= buffer.byteLength) {\n      return buffer;\n    }\n    let size = this.minBufferLength;\n    while (size \u003c requested) {\n      size *= 2;\n    }\n    const buffer2 = new Uint8Array(size);\n    buffer2.set(buffer);\n    return (this.buffer = buffer2);\n  }\n\n  // getBaseStreams() {\n  //   if (this.str \u0026\u0026 this.str.getBaseStreams) {\n  //     return this.str.getBaseStreams();\n  //   }\n  //   return [];\n  // }\n}\n\nexport default DecodeStream;\n","/*\n * Copyright 2012 Mozilla Foundation\n *\n * The Ascii85Stream class contained in this file is a TypeScript port of the\n * JavaScript Ascii85Stream class in Mozilla's pdf.js project, made available\n * under the Apache 2.0 open source license.\n */\n\nimport DecodeStream from 'src/core/streams/DecodeStream';\nimport { StreamType } from 'src/core/streams/Stream';\n\nconst isSpace = (ch: number) =\u003e\n  ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;\n\nclass Ascii85Stream extends DecodeStream {\n  private stream: StreamType;\n  private input: Uint8Array;\n\n  constructor(stream: StreamType, maybeLength?: number) {\n    super(maybeLength);\n\n    this.stream = stream;\n    this.input = new Uint8Array(5);\n\n    // Most streams increase in size when decoded, but Ascii85 streams\n    // typically shrink by ~20%.\n    if (maybeLength) {\n      maybeLength = 0.8 * maybeLength;\n    }\n  }\n\n  protected readBlock() {\n    const TILDA_CHAR = 0x7e; // '~'\n    const Z_LOWER_CHAR = 0x7a; // 'z'\n    const EOF = -1;\n\n    const stream = this.stream;\n\n    let c = stream.getByte();\n    while (isSpace(c)) {\n      c = stream.getByte();\n    }\n\n    if (c === EOF || c === TILDA_CHAR) {\n      this.eof = true;\n      return;\n    }\n\n    const bufferLength = this.bufferLength;\n    let buffer;\n    let i;\n\n    // special code for z\n    if (c === Z_LOWER_CHAR) {\n      buffer = this.ensureBuffer(bufferLength + 4);\n      for (i = 0; i \u003c 4; ++i) {\n        buffer[bufferLength + i] = 0;\n      }\n      this.bufferLength += 4;\n    } else {\n      const input = this.input;\n      input[0] = c;\n      for (i = 1; i \u003c 5; ++i) {\n        c = stream.getByte();\n        while (isSpace(c)) {\n          c = stream.getByte();\n        }\n\n        input[i] = c;\n\n        if (c === EOF || c === TILDA_CHAR) {\n          break;\n        }\n      }\n      buffer = this.ensureBuffer(bufferLength + i - 1);\n      this.bufferLength += i - 1;\n\n      // partial ending;\n      if (i \u003c 5) {\n        for (; i \u003c 5; ++i) {\n          input[i] = 0x21 + 84;\n        }\n        this.eof = true;\n      }\n      let t = 0;\n      for (i = 0; i \u003c 5; ++i) {\n        t = t * 85 + (input[i] - 0x21);\n      }\n\n      for (i = 3; i \u003e= 0; --i) {\n        buffer[bufferLength + i] = t \u0026 0xff;\n        t \u003e\u003e= 8;\n      }\n    }\n  }\n}\n\nexport default Ascii85Stream;\n","/*\n * Copyright 2012 Mozilla Foundation\n *\n * The AsciiHexStream class contained in this file is a TypeScript port of the\n * JavaScript AsciiHexStream class in Mozilla's pdf.js project, made available\n * under the Apache 2.0 open source license.\n */\n\nimport DecodeStream from 'src/core/streams/DecodeStream';\nimport { StreamType } from 'src/core/streams/Stream';\n\nclass AsciiHexStream extends DecodeStream {\n  private stream: StreamType;\n  private firstDigit: number;\n\n  constructor(stream: StreamType, maybeLength?: number) {\n    super(maybeLength);\n\n    this.stream = stream;\n\n    this.firstDigit = -1;\n\n    // Most streams increase in size when decoded, but AsciiHex streams shrink\n    // by 50%.\n    if (maybeLength) {\n      maybeLength = 0.5 * maybeLength;\n    }\n  }\n\n  protected readBlock() {\n    const UPSTREAM_BLOCK_SIZE = 8000;\n    const bytes = this.stream.getBytes(UPSTREAM_BLOCK_SIZE);\n    if (!bytes.length) {\n      this.eof = true;\n      return;\n    }\n\n    const maxDecodeLength = (bytes.length + 1) \u003e\u003e 1;\n    const buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);\n    let bufferLength = this.bufferLength;\n\n    let firstDigit = this.firstDigit;\n    for (let i = 0, ii = bytes.length; i \u003c ii; i++) {\n      const ch = bytes[i];\n      let digit;\n      if (ch \u003e= 0x30 \u0026\u0026 ch \u003c= 0x39) {\n        // '0'-'9'\n        digit = ch \u0026 0x0f;\n      } else if ((ch \u003e= 0x41 \u0026\u0026 ch \u003c= 0x46) || (ch \u003e= 0x61 \u0026\u0026 ch \u003c= 0x66)) {\n        // 'A'-'Z', 'a'-'z'\n        digit = (ch \u0026 0x0f) + 9;\n      } else if (ch === 0x3e) {\n        // '\u003e'\n        this.eof = true;\n        break;\n      } else {\n        // probably whitespace\n        continue; // ignoring\n      }\n      if (firstDigit \u003c 0) {\n        firstDigit = digit;\n      } else {\n        buffer[bufferLength++] = (firstDigit \u003c\u003c 4) | digit;\n        firstDigit = -1;\n      }\n    }\n    if (firstDigit \u003e= 0 \u0026\u0026 this.eof) {\n      // incomplete byte\n      buffer[bufferLength++] = firstDigit \u003c\u003c 4;\n      firstDigit = -1;\n    }\n    this.firstDigit = firstDigit;\n    this.bufferLength = bufferLength;\n  }\n}\n\nexport default AsciiHexStream;\n","/*\n * Copyright 1996-2003 Glyph \u0026 Cog, LLC\n *\n * The flate stream implementation contained in this file is a JavaScript port\n * of XPDF's implementation, made available under the Apache 2.0 open source\n * license.\n */\n\n/*\n * Copyright 2012 Mozilla Foundation\n *\n * The FlateStream class contained in this file is a TypeScript port of the\n * JavaScript FlateStream class in Mozilla's pdf.js project, made available\n * under the Apache 2.0 open source license.\n */\n\n/* tslint:disable  no-conditional-assignment */\nimport DecodeStream from 'src/core/streams/DecodeStream';\nimport { StreamType } from 'src/core/streams/Stream';\n\n// prettier-ignore\nconst codeLenCodeMap = new Int32Array([\n  16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15\n]);\n\n// prettier-ignore\nconst lengthDecode = new Int32Array([\n  0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a,\n  0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f,\n  0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073,\n  0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102\n]);\n\n// prettier-ignore\nconst distDecode = new Int32Array([\n  0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d,\n  0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1,\n  0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01,\n  0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001\n]);\n\n// prettier-ignore\nconst fixedLitCodeTab = [new Int32Array([\n  0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0,\n  0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0,\n  0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0,\n  0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0,\n  0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8,\n  0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8,\n  0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8,\n  0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8,\n  0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4,\n  0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4,\n  0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4,\n  0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4,\n  0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc,\n  0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec,\n  0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc,\n  0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc,\n  0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2,\n  0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2,\n  0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2,\n  0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2,\n  0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca,\n  0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea,\n  0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da,\n  0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa,\n  0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6,\n  0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6,\n  0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6,\n  0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6,\n  0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce,\n  0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee,\n  0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de,\n  0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe,\n  0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1,\n  0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1,\n  0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1,\n  0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1,\n  0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9,\n  0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9,\n  0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9,\n  0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9,\n  0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5,\n  0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5,\n  0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5,\n  0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5,\n  0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd,\n  0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed,\n  0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd,\n  0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd,\n  0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3,\n  0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3,\n  0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3,\n  0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3,\n  0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb,\n  0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb,\n  0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db,\n  0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb,\n  0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7,\n  0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7,\n  0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7,\n  0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7,\n  0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf,\n  0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef,\n  0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df,\n  0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff\n]), 9] as [Int32Array, number];\n\n// prettier-ignore\nconst fixedDistCodeTab = [new Int32Array([\n  0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c,\n  0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000,\n  0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d,\n  0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000\n]), 5] as [Int32Array, number];\n\nclass FlateStream extends DecodeStream {\n  private stream: StreamType;\n  private codeSize: number;\n  private codeBuf: number;\n\n  constructor(stream: StreamType, maybeLength?: number) {\n    super(maybeLength);\n\n    this.stream = stream;\n\n    const cmf = stream.getByte();\n    const flg = stream.getByte();\n    if (cmf === -1 || flg === -1) {\n      throw new Error(`Invalid header in flate stream: ${cmf}, ${flg}`);\n    }\n    if ((cmf \u0026 0x0f) !== 0x08) {\n      throw new Error(\n        `Unknown compression method in flate stream: ${cmf}, ${flg}`,\n      );\n    }\n    if (((cmf \u003c\u003c 8) + flg) % 31 !== 0) {\n      throw new Error(`Bad FCHECK in flate stream: ${cmf}, ${flg}`);\n    }\n    if (flg \u0026 0x20) {\n      throw new Error(`FDICT bit set in flate stream: ${cmf}, ${flg}`);\n    }\n\n    this.codeSize = 0;\n    this.codeBuf = 0;\n  }\n\n  protected readBlock() {\n    let buffer;\n    let len;\n    const str = this.stream;\n    // read block header\n    let hdr = this.getBits(3);\n    if (hdr \u0026 1) {\n      this.eof = true;\n    }\n    hdr \u003e\u003e= 1;\n\n    if (hdr === 0) {\n      // uncompressed block\n      let b;\n\n      if ((b = str.getByte()) === -1) {\n        throw new Error('Bad block header in flate stream');\n      }\n      let blockLen = b;\n      if ((b = str.getByte()) === -1) {\n        throw new Error('Bad block header in flate stream');\n      }\n      blockLen |= b \u003c\u003c 8;\n      if ((b = str.getByte()) === -1) {\n        throw new Error('Bad block header in flate stream');\n      }\n      let check = b;\n      if ((b = str.getByte()) === -1) {\n        throw new Error('Bad block header in flate stream');\n      }\n      check |= b \u003c\u003c 8;\n      if (check !== (~blockLen \u0026 0xffff) \u0026\u0026 (blockLen !== 0 || check !== 0)) {\n        // Ignoring error for bad \"empty\" block (see issue 1277)\n        throw new Error('Bad uncompressed block length in flate stream');\n      }\n\n      this.codeBuf = 0;\n      this.codeSize = 0;\n\n      const bufferLength = this.bufferLength;\n      buffer = this.ensureBuffer(bufferLength + blockLen);\n      const end = bufferLength + blockLen;\n      this.bufferLength = end;\n      if (blockLen === 0) {\n        if (str.peekByte() === -1) {\n          this.eof = true;\n        }\n      } else {\n        for (let n = bufferLength; n \u003c end; ++n) {\n          if ((b = str.getByte()) === -1) {\n            this.eof = true;\n            break;\n          }\n          buffer[n] = b;\n        }\n      }\n      return;\n    }\n\n    let litCodeTable;\n    let distCodeTable;\n    if (hdr === 1) {\n      // compressed block, fixed codes\n      litCodeTable = fixedLitCodeTab;\n      distCodeTable = fixedDistCodeTab;\n    } else if (hdr === 2) {\n      // compressed block, dynamic codes\n      const numLitCodes = this.getBits(5) + 257;\n      const numDistCodes = this.getBits(5) + 1;\n      const numCodeLenCodes = this.getBits(4) + 4;\n\n      // build the code lengths code table\n      const codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);\n\n      let i;\n      for (i = 0; i \u003c numCodeLenCodes; ++i) {\n        codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);\n      }\n      const codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);\n\n      // build the literal and distance code tables\n      len = 0;\n      i = 0;\n      const codes = numLitCodes + numDistCodes;\n      const codeLengths = new Uint8Array(codes);\n      let bitsLength;\n      let bitsOffset;\n      let what;\n      while (i \u003c codes) {\n        const code = this.getCode(codeLenCodeTab);\n        if (code === 16) {\n          bitsLength = 2;\n          bitsOffset = 3;\n          what = len;\n        } else if (code === 17) {\n          bitsLength = 3;\n          bitsOffset = 3;\n          what = len = 0;\n        } else if (code === 18) {\n          bitsLength = 7;\n          bitsOffset = 11;\n          what = len = 0;\n        } else {\n          codeLengths[i++] = len = code;\n          continue;\n        }\n\n        let repeatLength = this.getBits(bitsLength) + bitsOffset;\n        while (repeatLength-- \u003e 0) {\n          codeLengths[i++] = what;\n        }\n      }\n\n      litCodeTable = this.generateHuffmanTable(\n        codeLengths.subarray(0, numLitCodes),\n      );\n      distCodeTable = this.generateHuffmanTable(\n        codeLengths.subarray(numLitCodes, codes),\n      );\n    } else {\n      throw new Error('Unknown block type in flate stream');\n    }\n\n    buffer = this.buffer;\n    let limit = buffer ? buffer.length : 0;\n    let pos = this.bufferLength;\n    while (true) {\n      let code1 = this.getCode(litCodeTable);\n      if (code1 \u003c 256) {\n        if (pos + 1 \u003e= limit) {\n          buffer = this.ensureBuffer(pos + 1);\n          limit = buffer.length;\n        }\n        buffer[pos++] = code1;\n        continue;\n      }\n      if (code1 === 256) {\n        this.bufferLength = pos;\n        return;\n      }\n      code1 -= 257;\n      code1 = lengthDecode[code1];\n      let code2 = code1 \u003e\u003e 16;\n      if (code2 \u003e 0) {\n        code2 = this.getBits(code2);\n      }\n      len = (code1 \u0026 0xffff) + code2;\n      code1 = this.getCode(distCodeTable);\n      code1 = distDecode[code1];\n      code2 = code1 \u003e\u003e 16;\n      if (code2 \u003e 0) {\n        code2 = this.getBits(code2);\n      }\n      const dist = (code1 \u0026 0xffff) + code2;\n      if (pos + len \u003e= limit) {\n        buffer = this.ensureBuffer(pos + len);\n        limit = buffer.length;\n      }\n      for (let k = 0; k \u003c len; ++k, ++pos) {\n        buffer[pos] = buffer[pos - dist];\n      }\n    }\n  }\n\n  private getBits(bits: number) {\n    const str = this.stream;\n    let codeSize = this.codeSize;\n    let codeBuf = this.codeBuf;\n\n    let b;\n    while (codeSize \u003c bits) {\n      if ((b = str.getByte()) === -1) {\n        throw new Error('Bad encoding in flate stream');\n      }\n      codeBuf |= b \u003c\u003c codeSize;\n      codeSize += 8;\n    }\n    b = codeBuf \u0026 ((1 \u003c\u003c bits) - 1);\n    this.codeBuf = codeBuf \u003e\u003e bits;\n    this.codeSize = codeSize -= bits;\n\n    return b;\n  }\n\n  private getCode(table: [Int32Array, number]) {\n    const str = this.stream;\n    const codes = table[0];\n    const maxLen = table[1];\n    let codeSize = this.codeSize;\n    let codeBuf = this.codeBuf;\n\n    let b;\n    while (codeSize \u003c maxLen) {\n      if ((b = str.getByte()) === -1) {\n        // premature end of stream. code might however still be valid.\n        // codeSize \u003c codeLen check below guards against incomplete codeVal.\n        break;\n      }\n      codeBuf |= b \u003c\u003c codeSize;\n      codeSize += 8;\n    }\n    const code = codes[codeBuf \u0026 ((1 \u003c\u003c maxLen) - 1)];\n    if (typeof codes === 'number') {\n      console.log('FLATE:', code);\n    }\n    const codeLen = code \u003e\u003e 16;\n    const codeVal = code \u0026 0xffff;\n    if (codeLen \u003c 1 || codeSize \u003c codeLen) {\n      throw new Error('Bad encoding in flate stream');\n    }\n    this.codeBuf = codeBuf \u003e\u003e codeLen;\n    this.codeSize = codeSize - codeLen;\n    return codeVal;\n  }\n\n  private generateHuffmanTable(lengths: Uint8Array): [Int32Array, number] {\n    const n = lengths.length;\n\n    // find max code length\n    let maxLen = 0;\n    let i;\n    for (i = 0; i \u003c n; ++i) {\n      if (lengths[i] \u003e maxLen) {\n        maxLen = lengths[i];\n      }\n    }\n\n    // build the table\n    const size = 1 \u003c\u003c maxLen;\n    const codes = new Int32Array(size);\n    for (\n      let len = 1, code = 0, skip = 2;\n      len \u003c= maxLen;\n      ++len, code \u003c\u003c= 1, skip \u003c\u003c= 1\n    ) {\n      for (let val = 0; val \u003c n; ++val) {\n        if (lengths[val] === len) {\n          // bit-reverse the code\n          let code2 = 0;\n          let t = code;\n          for (i = 0; i \u003c len; ++i) {\n            code2 = (code2 \u003c\u003c 1) | (t \u0026 1);\n            t \u003e\u003e= 1;\n          }\n\n          // fill the table entries\n          for (i = code2; i \u003c size; i += skip) {\n            codes[i] = (len \u003c\u003c 16) | val;\n          }\n          ++code;\n        }\n      }\n    }\n\n    return [codes, maxLen];\n  }\n}\n\nexport default FlateStream;\n","/*\n * Copyright 2012 Mozilla Foundation\n *\n * The LZWStream class contained in this file is a TypeScript port of the\n * JavaScript LZWStream class in Mozilla's pdf.js project, made available\n * under the Apache 2.0 open source license.\n */\n\nimport DecodeStream from 'src/core/streams/DecodeStream';\nimport { StreamType } from 'src/core/streams/Stream';\n\nclass LZWStream extends DecodeStream {\n  private stream: StreamType;\n  private cachedData: number;\n  private bitsCached: number;\n  private lzwState: {\n    earlyChange: 0 | 1;\n    codeLength: number;\n    nextCode: number;\n    dictionaryValues: Uint8Array;\n    dictionaryLengths: Uint16Array;\n    dictionaryPrevCodes: Uint16Array;\n    currentSequence: Uint8Array;\n    currentSequenceLength: number;\n    prevCode?: number | null;\n  };\n\n  constructor(\n    stream: StreamType,\n    maybeLength: number | undefined,\n    earlyChange: 0 | 1,\n  ) {\n    super(maybeLength);\n\n    this.stream = stream;\n    this.cachedData = 0;\n    this.bitsCached = 0;\n\n    const maxLzwDictionarySize = 4096;\n    const lzwState = {\n      earlyChange,\n      codeLength: 9,\n      nextCode: 258,\n      dictionaryValues: new Uint8Array(maxLzwDictionarySize),\n      dictionaryLengths: new Uint16Array(maxLzwDictionarySize),\n      dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),\n      currentSequence: new Uint8Array(maxLzwDictionarySize),\n      currentSequenceLength: 0,\n    };\n    for (let i = 0; i \u003c 256; ++i) {\n      lzwState.dictionaryValues[i] = i;\n      lzwState.dictionaryLengths[i] = 1;\n    }\n    this.lzwState = lzwState;\n  }\n\n  protected readBlock() {\n    const blockSize = 512;\n\n    let estimatedDecodedSize = blockSize * 2;\n    const decodedSizeDelta = blockSize;\n    let i;\n    let j;\n    let q;\n\n    const lzwState = this.lzwState;\n    if (!lzwState) {\n      return; // eof was found\n    }\n\n    const earlyChange = lzwState.earlyChange;\n    let nextCode = lzwState.nextCode;\n    const dictionaryValues = lzwState.dictionaryValues;\n    const dictionaryLengths = lzwState.dictionaryLengths;\n    const dictionaryPrevCodes = lzwState.dictionaryPrevCodes;\n    let codeLength = lzwState.codeLength;\n    let prevCode = lzwState.prevCode;\n    const currentSequence = lzwState.currentSequence;\n    let currentSequenceLength = lzwState.currentSequenceLength;\n\n    let decodedLength = 0;\n    let currentBufferLength = this.bufferLength;\n    let buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);\n\n    for (i = 0; i \u003c blockSize; i++) {\n      const code = this.readBits(codeLength);\n      const hasPrev = currentSequenceLength \u003e 0;\n      if (!code || code \u003c 256) {\n        currentSequence[0] = code as number;\n        currentSequenceLength = 1;\n      } else if (code \u003e= 258) {\n        if (code \u003c nextCode) {\n          currentSequenceLength = dictionaryLengths[code];\n          for (j = currentSequenceLength - 1, q = code; j \u003e= 0; j--) {\n            currentSequence[j] = dictionaryValues[q];\n            q = dictionaryPrevCodes[q];\n          }\n        } else {\n          currentSequence[currentSequenceLength++] = currentSequence[0];\n        }\n      } else if (code === 256) {\n        codeLength = 9;\n        nextCode = 258;\n        currentSequenceLength = 0;\n        continue;\n      } else {\n        this.eof = true;\n        delete this.lzwState;\n        break;\n      }\n\n      if (hasPrev) {\n        dictionaryPrevCodes[nextCode] = prevCode as number;\n        dictionaryLengths[nextCode] = dictionaryLengths[prevCode as number] + 1;\n        dictionaryValues[nextCode] = currentSequence[0];\n        nextCode++;\n        codeLength =\n          (nextCode + earlyChange) \u0026 (nextCode + earlyChange - 1)\n            ? codeLength\n            : Math.min(\n                Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1,\n                12,\n              ) | 0;\n      }\n      prevCode = code;\n\n      decodedLength += currentSequenceLength;\n      if (estimatedDecodedSize \u003c decodedLength) {\n        do {\n          estimatedDecodedSize += decodedSizeDelta;\n        } while (estimatedDecodedSize \u003c decodedLength);\n        buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);\n      }\n      for (j = 0; j \u003c currentSequenceLength; j++) {\n        buffer[currentBufferLength++] = currentSequence[j];\n      }\n    }\n    lzwState.nextCode = nextCode;\n    lzwState.codeLength = codeLength;\n    lzwState.prevCode = prevCode;\n    lzwState.currentSequenceLength = currentSequenceLength;\n\n    this.bufferLength = currentBufferLength;\n  }\n\n  private readBits(n: number) {\n    let bitsCached = this.bitsCached;\n    let cachedData = this.cachedData;\n    while (bitsCached \u003c n) {\n      const c = this.stream.getByte();\n      if (c === -1) {\n        this.eof = true;\n        return null;\n      }\n      cachedData = (cachedData \u003c\u003c 8) | c;\n      bitsCached += 8;\n    }\n    this.bitsCached = bitsCached -= n;\n    this.cachedData = cachedData;\n    return (cachedData \u003e\u003e\u003e bitsCached) \u0026 ((1 \u003c\u003c n) - 1);\n  }\n}\n\nexport default LZWStream;\n","/*\n * Copyright 2012 Mozilla Foundation\n *\n * The RunLengthStream class contained in this file is a TypeScript port of the\n * JavaScript RunLengthStream class in Mozilla's pdf.js project, made available\n * under the Apache 2.0 open source license.\n */\n\nimport DecodeStream from 'src/core/streams/DecodeStream';\nimport { StreamType } from 'src/core/streams/Stream';\n\nclass RunLengthStream extends DecodeStream {\n  private stream: StreamType;\n\n  constructor(stream: StreamType, maybeLength?: number) {\n    super(maybeLength);\n    this.stream = stream;\n  }\n\n  protected readBlock() {\n    // The repeatHeader has following format. The first byte defines type of run\n    // and amount of bytes to repeat/copy: n = 0 through 127 - copy next n bytes\n    // (in addition to the second byte from the header), n = 129 through 255 -\n    // duplicate the second byte from the header (257 - n) times, n = 128 - end.\n    const repeatHeader = this.stream.getBytes(2);\n    if (!repeatHeader || repeatHeader.length \u003c 2 || repeatHeader[0] === 128) {\n      this.eof = true;\n      return;\n    }\n\n    let buffer;\n    let bufferLength = this.bufferLength;\n    let n = repeatHeader[0];\n    if (n \u003c 128) {\n      // copy n bytes\n      buffer = this.ensureBuffer(bufferLength + n + 1);\n      buffer[bufferLength++] = repeatHeader[1];\n      if (n \u003e 0) {\n        const source = this.stream.getBytes(n);\n        buffer.set(source, bufferLength);\n        bufferLength += n;\n      }\n    } else {\n      n = 257 - n;\n      const b = repeatHeader[1];\n      buffer = this.ensureBuffer(bufferLength + n + 1);\n      for (let i = 0; i \u003c n; i++) {\n        buffer[bufferLength++] = b;\n      }\n    }\n    this.bufferLength = bufferLength;\n  }\n}\n\nexport default RunLengthStream;\n","import {\n  UnexpectedObjectTypeError,\n  UnsupportedEncodingError,\n} from 'src/core/errors';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNull from 'src/core/objects/PDFNull';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport Ascii85Stream from 'src/core/streams/Ascii85Stream';\nimport AsciiHexStream from 'src/core/streams/AsciiHexStream';\nimport FlateStream from 'src/core/streams/FlateStream';\nimport LZWStream from 'src/core/streams/LZWStream';\nimport RunLengthStream from 'src/core/streams/RunLengthStream';\nimport Stream, { StreamType } from 'src/core/streams/Stream';\n\nconst decodeStream = (\n  stream: StreamType,\n  encoding: PDFName,\n  params: undefined | typeof PDFNull | PDFDict,\n) =\u003e {\n  if (encoding === PDFName.of('FlateDecode')) {\n    return new FlateStream(stream);\n  }\n  if (encoding === PDFName.of('LZWDecode')) {\n    let earlyChange = 1;\n    if (params instanceof PDFDict) {\n      const EarlyChange = params.lookup(PDFName.of('EarlyChange'));\n      if (EarlyChange instanceof PDFNumber) {\n        earlyChange = EarlyChange.asNumber();\n      }\n    }\n    return new LZWStream(stream, undefined, earlyChange as 0 | 1);\n  }\n  if (encoding === PDFName.of('ASCII85Decode')) {\n    return new Ascii85Stream(stream);\n  }\n  if (encoding === PDFName.of('ASCIIHexDecode')) {\n    return new AsciiHexStream(stream);\n  }\n  if (encoding === PDFName.of('RunLengthDecode')) {\n    return new RunLengthStream(stream);\n  }\n  throw new UnsupportedEncodingError(encoding.asString());\n};\n\nexport const decodePDFRawStream = ({ dict, contents }: PDFRawStream) =\u003e {\n  let stream: StreamType = new Stream(contents);\n\n  const Filter = dict.lookup(PDFName.of('Filter'));\n  const DecodeParms = dict.lookup(PDFName.of('DecodeParms'));\n\n  if (Filter instanceof PDFName) {\n    stream = decodeStream(\n      stream,\n      Filter,\n      DecodeParms as PDFDict | typeof PDFNull | undefined,\n    );\n  } else if (Filter instanceof PDFArray) {\n    for (let idx = 0, len = Filter.size(); idx \u003c len; idx++) {\n      stream = decodeStream(\n        stream,\n        Filter.lookup(idx, PDFName),\n        DecodeParms \u0026\u0026 (DecodeParms as PDFArray).lookupMaybe(idx, PDFDict),\n      );\n    }\n  } else if (!!Filter) {\n    throw new UnexpectedObjectTypeError([PDFName, PDFArray], Filter);\n  }\n\n  return stream;\n};\n","import {\n  MissingPageContentsEmbeddingError,\n  UnrecognizedStreamTypeError,\n} from 'src/core/errors';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFContext from 'src/core/PDFContext';\nimport { decodePDFRawStream } from 'src/core/streams/decode';\nimport PDFContentStream from 'src/core/structures/PDFContentStream';\nimport PDFPageLeaf from 'src/core/structures/PDFPageLeaf';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { TransformationMatrix } from 'src/types/matrix';\nimport { mergeIntoTypedArray } from 'src/utils';\n\n/**\n * Represents a page bounding box.\n * Usually `left` and `bottom` are 0 and right, top are equal\n * to width, height if you want to clip to the whole page.\n *\n *       y\n *       ^\n *       | +--------+ (width,height)\n *       | |        |\n *       | |  Page  |\n *       | |        |\n *       | |        |\n * (0,0) | +--------+\n *       +----------\u003e x\n */\nexport interface PageBoundingBox {\n  left: number /** The left of the bounding box */;\n  bottom: number /** The bottom of the bounding box */;\n  right: number /** The right of the bounding box */;\n  top: number /** The top of the bounding box */;\n}\n\nconst fullPageBoundingBox = (page: PDFPageLeaf) =\u003e {\n  const mediaBox = page.MediaBox();\n\n  const width =\n    mediaBox.lookup(2, PDFNumber).asNumber() -\n    mediaBox.lookup(0, PDFNumber).asNumber();\n\n  const height =\n    mediaBox.lookup(3, PDFNumber).asNumber() -\n    mediaBox.lookup(1, PDFNumber).asNumber();\n\n  return { left: 0, bottom: 0, right: width, top: height };\n};\n\n// Returns the identity matrix, modified to position the content of the given\n// bounding box at (0, 0).\nconst boundingBoxAdjustedMatrix = (\n  bb: PageBoundingBox,\n): TransformationMatrix =\u003e [1, 0, 0, 1, -bb.left, -bb.bottom];\n\nclass PDFPageEmbedder {\n  static async for(\n    page: PDFPageLeaf,\n    boundingBox?: PageBoundingBox,\n    transformationMatrix?: TransformationMatrix,\n  ) {\n    return new PDFPageEmbedder(page, boundingBox, transformationMatrix);\n  }\n\n  readonly width: number;\n  readonly height: number;\n  readonly boundingBox: PageBoundingBox;\n  readonly transformationMatrix: TransformationMatrix;\n\n  private readonly page: PDFPageLeaf;\n\n  private constructor(\n    page: PDFPageLeaf,\n    boundingBox?: PageBoundingBox,\n    transformationMatrix?: TransformationMatrix,\n  ) {\n    this.page = page;\n\n    const bb = boundingBox ?? fullPageBoundingBox(page);\n\n    this.width = bb.right - bb.left;\n    this.height = bb.top - bb.bottom;\n    this.boundingBox = bb;\n    this.transformationMatrix =\n      transformationMatrix ?? boundingBoxAdjustedMatrix(bb);\n  }\n\n  async embedIntoContext(context: PDFContext, ref?: PDFRef): Promise\u003cPDFRef\u003e {\n    const { Contents, Resources } = this.page.normalizedEntries();\n\n    if (!Contents) throw new MissingPageContentsEmbeddingError();\n    const decodedContents = this.decodeContents(Contents);\n\n    const { left, bottom, right, top } = this.boundingBox;\n    const xObject = context.flateStream(decodedContents, {\n      Type: 'XObject',\n      Subtype: 'Form',\n      FormType: 1,\n      BBox: [left, bottom, right, top],\n      Matrix: this.transformationMatrix,\n      Resources,\n    });\n\n    if (ref) {\n      context.assign(ref, xObject);\n      return ref;\n    } else {\n      return context.register(xObject);\n    }\n  }\n\n  // `contents` is an array of streams which are merged to include them in the XObject.\n  // This methods extracts each stream and joins them with a newline character.\n  private decodeContents(contents: PDFArray) {\n    const newline = Uint8Array.of(CharCodes.Newline);\n    const decodedContents: Uint8Array[] = [];\n\n    for (let idx = 0, len = contents.size(); idx \u003c len; idx++) {\n      const stream = contents.lookup(idx, PDFStream);\n\n      let content: Uint8Array;\n      if (stream instanceof PDFRawStream) {\n        content = decodePDFRawStream(stream).decode();\n      } else if (stream instanceof PDFContentStream) {\n        content = stream.getUnencodedContents();\n      } else {\n        throw new UnrecognizedStreamTypeError(stream);\n      }\n\n      decodedContents.push(content, newline);\n    }\n\n    return mergeIntoTypedArray(...decodedContents);\n  }\n}\n\nexport default PDFPageEmbedder;\n","import PDFArray from 'src/core/objects/PDFArray';\nimport PDFBool from 'src/core/objects/PDFBool';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFContext from 'src/core/PDFContext';\nimport {\n  assertEachIs,\n  assertInteger,\n  assertIsOneOf,\n  assertRange,\n} from 'src/utils';\n\nconst asEnum = \u003cT extends string | number, U extends { [key: string]: T }\u003e(\n  rawValue: T | undefined,\n  enumType: U,\n): U[keyof U] | undefined =\u003e {\n  if (rawValue === undefined) return undefined;\n  return enumType[rawValue];\n};\n\nexport enum NonFullScreenPageMode {\n  /**\n   * After exiting FullScreen mode, neither the document outline nor thumbnail\n   * images should be visible.\n   */\n  UseNone = 'UseNone',\n\n  /** After exiting FullScreen mode, the document outline should be visible. */\n  UseOutlines = 'UseOutlines',\n\n  /** After exiting FullScreen mode, thumbnail images should be visible. */\n  UseThumbs = 'UseThumbs',\n\n  /**\n   * After exiting FullScreen mode, the optional content group panel should be\n   * visible.\n   */\n  UseOC = 'UseOC',\n}\n\nexport enum ReadingDirection {\n  /** The predominant reading order is Left to Right. */\n  L2R = 'L2R',\n\n  /**\n   * The predominant reading order is Right to left (including vertical writing\n   * systems, such as Chinese, Japanese and Korean).\n   */\n  R2L = 'R2L',\n}\n\nexport enum PrintScaling {\n  /** No page scaling. */\n  None = 'None',\n\n  /* Use the PDF reader's default print scaling. */\n  AppDefault = 'AppDefault',\n}\n\nexport enum Duplex {\n  /** The PDF reader should print single-sided. */\n  Simplex = 'Simplex',\n\n  /**\n   * The PDF reader should print double sided and flip on the short edge of the\n   * sheet.\n   */\n  DuplexFlipShortEdge = 'DuplexFlipShortEdge',\n\n  /**\n   * The PDF reader should print double sided and flip on the long edge of the\n   * sheet.\n   */\n  DuplexFlipLongEdge = 'DuplexFlipLongEdge',\n}\n\ntype BoolViewerPrefKey =\n  | 'HideToolbar'\n  | 'HideMenubar'\n  | 'HideWindowUI'\n  | 'FitWindow'\n  | 'CenterWindow'\n  | 'DisplayDocTitle'\n  | 'PickTrayByPDFSize';\ntype NameViewerPrefKey =\n  | 'NonFullScreenPageMode'\n  | 'Direction'\n  | 'PrintScaling'\n  | 'Duplex';\n\ninterface PageRange {\n  start: number;\n  end: number;\n}\n\nclass ViewerPreferences {\n  /** @ignore */\n  readonly dict: PDFDict;\n\n  /** @ignore */\n  static fromDict = (dict: PDFDict): ViewerPreferences =\u003e\n    new ViewerPreferences(dict);\n\n  /** @ignore */\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({});\n    return new ViewerPreferences(dict);\n  };\n\n  /** @ignore */\n  protected constructor(dict: PDFDict) {\n    this.dict = dict;\n  }\n\n  protected lookupBool(key: BoolViewerPrefKey): PDFBool | undefined {\n    const returnObj = this.dict.lookup(PDFName.of(key));\n    if (returnObj instanceof PDFBool) return returnObj;\n    return undefined;\n  }\n\n  protected lookupName(key: NameViewerPrefKey): PDFName | undefined {\n    const returnObj = this.dict.lookup(PDFName.of(key));\n    if (returnObj instanceof PDFName) return returnObj;\n    return undefined;\n  }\n\n  /** @ignore */\n  HideToolbar(): PDFBool | undefined {\n    return this.lookupBool('HideToolbar');\n  }\n\n  /** @ignore */\n  HideMenubar(): PDFBool | undefined {\n    return this.lookupBool('HideMenubar');\n  }\n\n  /** @ignore */\n  HideWindowUI(): PDFBool | undefined {\n    return this.lookupBool('HideWindowUI');\n  }\n\n  /** @ignore */\n  FitWindow(): PDFBool | undefined {\n    return this.lookupBool('FitWindow');\n  }\n\n  /** @ignore */\n  CenterWindow(): PDFBool | undefined {\n    return this.lookupBool('CenterWindow');\n  }\n\n  /** @ignore */\n  DisplayDocTitle(): PDFBool | undefined {\n    return this.lookupBool('DisplayDocTitle');\n  }\n\n  /** @ignore */\n  NonFullScreenPageMode(): PDFName | undefined {\n    return this.lookupName('NonFullScreenPageMode');\n  }\n\n  /** @ignore */\n  Direction(): PDFName | undefined {\n    return this.lookupName('Direction');\n  }\n\n  /** @ignore */\n  PrintScaling(): PDFName | undefined {\n    return this.lookupName('PrintScaling');\n  }\n\n  /** @ignore */\n  Duplex(): PDFName | undefined {\n    return this.lookupName('Duplex');\n  }\n\n  /** @ignore */\n  PickTrayByPDFSize(): PDFBool | undefined {\n    return this.lookupBool('PickTrayByPDFSize');\n  }\n\n  /** @ignore */\n  PrintPageRange(): PDFArray | undefined {\n    const PrintPageRange = this.dict.lookup(PDFName.of('PrintPageRange'));\n    if (PrintPageRange instanceof PDFArray) return PrintPageRange;\n    return undefined;\n  }\n\n  /** @ignore */\n  NumCopies(): PDFNumber | undefined {\n    const NumCopies = this.dict.lookup(PDFName.of('NumCopies'));\n    if (NumCopies instanceof PDFNumber) return NumCopies;\n    return undefined;\n  }\n\n  /**\n   * Returns `true` if PDF readers should hide the toolbar menus when displaying\n   * this document.\n   * @returns Whether or not toolbars should be hidden.\n   */\n  getHideToolbar(): boolean {\n    return this.HideToolbar()?.asBoolean() ?? false;\n  }\n\n  /**\n   * Returns `true` if PDF readers should hide the menu bar when displaying this\n   * document.\n   * @returns Whether or not the menu bar should be hidden.\n   */\n  getHideMenubar(): boolean {\n    return this.HideMenubar()?.asBoolean() ?? false;\n  }\n\n  /**\n   * Returns `true` if PDF readers should hide the user interface elements in\n   * the document's window (such as scroll bars and navigation controls),\n   * leaving only the document's contents displayed.\n   * @returns Whether or not user interface elements should be hidden.\n   */\n  getHideWindowUI(): boolean {\n    return this.HideWindowUI()?.asBoolean() ?? false;\n  }\n\n  /**\n   * Returns `true` if PDF readers should resize the document's window to fit\n   * the size of the first displayed page.\n   * @returns Whether or not the window should be resized to fit.\n   */\n  getFitWindow(): boolean {\n    return this.FitWindow()?.asBoolean() ?? false;\n  }\n\n  /**\n   * Returns `true` if PDF readers should position the document's window in the\n   * center of the screen.\n   * @returns Whether or not to center the document window.\n   */\n  getCenterWindow(): boolean {\n    return this.CenterWindow()?.asBoolean() ?? false;\n  }\n\n  /**\n   * Returns `true` if the window's title bar should display the document\n   * `Title`, taken from the document metadata (see [[PDFDocument.getTitle]]).\n   * Returns `false` if the title bar should instead display the filename of the\n   * PDF file.\n   * @returns Whether to display the document title.\n   */\n  getDisplayDocTitle(): boolean {\n    return this.DisplayDocTitle()?.asBoolean() ?? false;\n  }\n\n  /**\n   * Returns the page mode, which tells the PDF reader how to display the\n   * document after exiting full-screen mode.\n   * @returns The page mode after exiting full-screen mode.\n   */\n  getNonFullScreenPageMode(): NonFullScreenPageMode {\n    const mode = this.NonFullScreenPageMode()?.decodeText();\n    return asEnum(mode, NonFullScreenPageMode) ?? NonFullScreenPageMode.UseNone;\n  }\n\n  /**\n   * Returns the predominant reading order for text.\n   * @returns The text reading order.\n   */\n  getReadingDirection(): ReadingDirection {\n    const direction = this.Direction()?.decodeText();\n    return asEnum(direction, ReadingDirection) ?? ReadingDirection.L2R;\n  }\n\n  /**\n   * Returns the page scaling option that the PDF reader should select when the\n   * print dialog is displayed.\n   * @returns The page scaling option.\n   */\n  getPrintScaling(): PrintScaling {\n    const scaling = this.PrintScaling()?.decodeText();\n    return asEnum(scaling, PrintScaling) ?? PrintScaling.AppDefault;\n  }\n\n  /**\n   * Returns the paper handling option that should be used when printing the\n   * file from the print dialog.\n   * @returns The paper handling option.\n   */\n  getDuplex(): Duplex | undefined {\n    const duplex = this.Duplex()?.decodeText();\n    return asEnum(duplex, Duplex);\n  }\n\n  /**\n   * Returns `true` if the PDF page size should be used to select the input\n   * paper tray.\n   * @returns Whether or not the PDF page size should be used to select the\n   *          input paper tray.\n   */\n  getPickTrayByPDFSize(): boolean | undefined {\n    return this.PickTrayByPDFSize()?.asBoolean();\n  }\n\n  /**\n   * Returns an array of page number ranges, which are the values used to\n   * initialize the print dialog box when the file is printed. Each range\n   * specifies the first (`start`) and last (`end`) pages in a sub-range of\n   * pages to be printed. The first page of the PDF file is denoted by 0.\n   * For example:\n   * ```js\n   * const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()\n   * const includesPage3 = viewerPrefs\n   *   .getPrintRanges()\n   *   .some(pr =\u003e pr.start =\u003c 2 \u0026\u0026 pr.end \u003e= 2)\n   * if (includesPage3) console.log('printRange includes page 3')\n   * ```\n   * @returns An array of objects, each with the properties `start` and `end`,\n   *          denoting page indices. If not, specified an empty array is\n   *          returned.\n   */\n  getPrintPageRange(): PageRange[] {\n    const rng = this.PrintPageRange();\n    if (!rng) return [];\n\n    const pageRanges: PageRange[] = [];\n    for (let i = 0; i \u003c rng.size(); i += 2) {\n      // Despite the spec clearly stating that \"The first page of the PDF file\n      // shall be donoted by 1\", several test PDFs (spec 1.7) created in\n      // Acrobat XI 11.0 and also read with Reader DC 2020.013 indicate this is\n      // actually a 0 based index.\n      const start = rng.lookup(i, PDFNumber).asNumber();\n      const end = rng.lookup(i + 1, PDFNumber).asNumber();\n      pageRanges.push({ start, end });\n    }\n\n    return pageRanges;\n  }\n\n  /**\n   * Returns the number of copies to be printed when the print dialog is opened\n   * for this document.\n   * @returns The default number of copies to be printed.\n   */\n  getNumCopies(): number {\n    return this.NumCopies()?.asNumber() ?? 1;\n  }\n\n  /**\n   * Choose whether the PDF reader's toolbars should be hidden while the\n   * document is active.\n   * @param hideToolbar `true` if the toolbar should be hidden.\n   */\n  setHideToolbar(hideToolbar: boolean) {\n    const HideToolbar = this.dict.context.obj(hideToolbar);\n    this.dict.set(PDFName.of('HideToolbar'), HideToolbar);\n  }\n\n  /**\n   * Choose whether the PDF reader's menu bar should be hidden while the\n   * document is active.\n   * @param hideMenubar `true` if the menu bar should be hidden.\n   */\n  setHideMenubar(hideMenubar: boolean) {\n    const HideMenubar = this.dict.context.obj(hideMenubar);\n    this.dict.set(PDFName.of('HideMenubar'), HideMenubar);\n  }\n\n  /**\n   * Choose whether the PDF reader should hide user interface elements in the\n   * document's window (such as scroll bars and navigation controls), leaving\n   * only the document's contents displayed.\n   * @param hideWindowUI `true` if the user interface elements should be hidden.\n   */\n  setHideWindowUI(hideWindowUI: boolean) {\n    const HideWindowUI = this.dict.context.obj(hideWindowUI);\n    this.dict.set(PDFName.of('HideWindowUI'), HideWindowUI);\n  }\n\n  /**\n   * Choose whether the PDF reader should resize the document's window to fit\n   * the size of the first displayed page.\n   * @param fitWindow `true` if the window should be resized.\n   */\n  setFitWindow(fitWindow: boolean) {\n    const FitWindow = this.dict.context.obj(fitWindow);\n    this.dict.set(PDFName.of('FitWindow'), FitWindow);\n  }\n\n  /**\n   * Choose whether the PDF reader should position the document's window in the\n   * center of the screen.\n   * @param centerWindow `true` if the window should be centered.\n   */\n  setCenterWindow(centerWindow: boolean) {\n    const CenterWindow = this.dict.context.obj(centerWindow);\n    this.dict.set(PDFName.of('CenterWindow'), CenterWindow);\n  }\n\n  /**\n   * Choose whether the window's title bar should display the document `Title`\n   * taken from the document metadata (see [[PDFDocument.setTitle]]). If\n   * `false`, the title bar should instead display the PDF filename.\n   * @param displayTitle `true` if the document title should be displayed.\n   */\n  setDisplayDocTitle(displayTitle: boolean) {\n    const DisplayDocTitle = this.dict.context.obj(displayTitle);\n    this.dict.set(PDFName.of('DisplayDocTitle'), DisplayDocTitle);\n  }\n\n  /**\n   * Choose how the PDF reader should display the document upon exiting\n   * full-screen mode. This entry is meaningful only if the value of the\n   * `PageMode` entry in the document's [[PDFCatalog]] is `FullScreen`.\n   *\n   * For example:\n   * ```js\n   * import { PDFDocument, NonFullScreenPageMode, PDFName } from 'pdf-lib'\n   *\n   * const pdfDoc = await PDFDocument.create()\n   *\n   * // Set the PageMode\n   * pdfDoc.catalog.set(PDFName.of('PageMode'),PDFName.of('FullScreen'))\n   *\n   * // Set what happens when full-screen is closed\n   * const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()\n   * viewerPrefs.setNonFullScreenPageMode(NonFullScreenPageMode.UseOutlines)\n   * ```\n   *\n   * @param nonFullScreenPageMode How the document should be displayed upon\n   *                              exiting full screen mode.\n   */\n  setNonFullScreenPageMode(nonFullScreenPageMode: NonFullScreenPageMode) {\n    assertIsOneOf(\n      nonFullScreenPageMode,\n      'nonFullScreenPageMode',\n      NonFullScreenPageMode,\n    );\n    const mode = PDFName.of(nonFullScreenPageMode);\n    this.dict.set(PDFName.of('NonFullScreenPageMode'), mode);\n  }\n\n  /**\n   * Choose the predominant reading order for text.\n   *\n   * This entry has no direct effect on the document's contents or page\n   * numbering, but may be used to determine the relative positioning of pages\n   * when displayed side by side or printed n-up.\n   *\n   * For example:\n   * ```js\n   * import { PDFDocument, ReadingDirection } from 'pdf-lib'\n   *\n   * const pdfDoc = await PDFDocument.create()\n   * const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()\n   * viewerPrefs.setReadingDirection(ReadingDirection.R2L)\n   * ```\n   *\n   * @param readingDirection The reading order for text.\n   */\n  setReadingDirection(readingDirection: ReadingDirection) {\n    assertIsOneOf(readingDirection, 'readingDirection', ReadingDirection);\n    const direction = PDFName.of(readingDirection);\n    this.dict.set(PDFName.of('Direction'), direction);\n  }\n\n  /**\n   * Choose the page scaling option that should be selected when a print dialog\n   * is displayed for this document.\n   *\n   * For example:\n   * ```js\n   * import { PDFDocument, PrintScaling } from 'pdf-lib'\n   *\n   * const pdfDoc = await PDFDocument.create()\n   * const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()\n   * viewerPrefs.setPrintScaling(PrintScaling.None)\n   * ```\n   *\n   * @param printScaling The print scaling option.\n   */\n  setPrintScaling(printScaling: PrintScaling) {\n    assertIsOneOf(printScaling, 'printScaling', PrintScaling);\n    const scaling = PDFName.of(printScaling);\n    this.dict.set(PDFName.of('PrintScaling'), scaling);\n  }\n\n  /**\n   * Choose the paper handling option that should be selected by default in the\n   * print dialog.\n   *\n   * For example:\n   * ```js\n   * import { PDFDocument, Duplex } from 'pdf-lib'\n   *\n   * const pdfDoc = await PDFDocument.create()\n   * const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()\n   * viewerPrefs.setDuplex(Duplex.DuplexFlipShortEdge)\n   * ```\n   *\n   * @param duplex The double or single sided printing option.\n   */\n  setDuplex(duplex: Duplex) {\n    assertIsOneOf(duplex, 'duplex', Duplex);\n    const dup = PDFName.of(duplex);\n    this.dict.set(PDFName.of('Duplex'), dup);\n  }\n\n  /**\n   * Choose whether the PDF document's page size should be used to select the\n   * input paper tray when printing. This setting influences only the preset\n   * values used to populate the print dialog presented by a PDF reader.\n   *\n   * If PickTrayByPDFSize is true, the check box in the print dialog associated\n   * with input paper tray should be checked. This setting has no effect on\n   * operating systems that do not provide the ability to pick the input tray\n   * by size.\n   *\n   * @param pickTrayByPDFSize `true` if the document's page size should be used\n   *                          to select the input paper tray.\n   */\n  setPickTrayByPDFSize(pickTrayByPDFSize: boolean) {\n    const PickTrayByPDFSize = this.dict.context.obj(pickTrayByPDFSize);\n    this.dict.set(PDFName.of('PickTrayByPDFSize'), PickTrayByPDFSize);\n  }\n\n  /**\n   * Choose the page numbers used to initialize the print dialog box when the\n   * file is printed. The first page of the PDF file is denoted by 0.\n   *\n   * For example:\n   * ```js\n   * import { PDFDocument } from 'pdf-lib'\n   *\n   * const pdfDoc = await PDFDocument.create()\n   * const viewerPrefs = pdfDoc.catalog.getOrCreateViewerPreferences()\n   *\n   * // We can set the default print range to only the first page\n   * viewerPrefs.setPrintPageRange({ start: 0, end: 0 })\n   *\n   * // Or we can supply noncontiguous ranges (e.g. pages 1, 3, and 5-7)\n   * viewerPrefs.setPrintPageRange([\n   *   { start: 0, end: 0 },\n   *   { start: 2, end: 2 },\n   *   { start: 4, end: 6 },\n   * ])\n   * ```\n   *\n   * @param printPageRange An object or array of objects, each with the\n   *                       properties `start` and `end`, denoting a range of\n   *                       page indices.\n   */\n  setPrintPageRange(printPageRange: PageRange[] | PageRange) {\n    if (!Array.isArray(printPageRange)) printPageRange = [printPageRange];\n\n    const flatRange: number[] = [];\n    for (let idx = 0, len = printPageRange.length; idx \u003c len; idx++) {\n      flatRange.push(printPageRange[idx].start);\n      flatRange.push(printPageRange[idx].end);\n    }\n\n    assertEachIs(flatRange, 'printPageRange', ['number']);\n\n    const pageRanges = this.dict.context.obj(flatRange);\n    this.dict.set(PDFName.of('PrintPageRange'), pageRanges);\n  }\n\n  /**\n   * Choose the default number of copies to be printed when the print dialog is\n   * opened for this file.\n   * @param numCopies The default number of copies.\n   */\n  setNumCopies(numCopies: number) {\n    assertRange(numCopies, 'numCopies', 1, Number.MAX_VALUE);\n    assertInteger(numCopies, 'numCopies');\n    const NumCopies = this.dict.context.obj(numCopies);\n    this.dict.set(PDFName.of('NumCopies'), NumCopies);\n  }\n}\n\nexport default ViewerPreferences;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport { findLastMatch } from 'src/utils';\nimport { MissingDAEntryError, MissingTfOperatorError } from 'src/core/errors';\n\n// Examples:\n//   `/Helv 12 Tf` -\u003e ['Helv', '12']\n//   `/HeBo 8.00 Tf` -\u003e ['HeBo', '8.00']\n//   `/HeBo Tf` -\u003e ['HeBo', undefined]\nconst tfRegex = /\\/([^\\0\\t\\n\\f\\r\\ ]+)[\\0\\t\\n\\f\\r\\ ]*(\\d*\\.\\d+|\\d+)?[\\0\\t\\n\\f\\r\\ ]+Tf/;\n\nclass PDFAcroField {\n  readonly dict: PDFDict;\n  readonly ref: PDFRef;\n\n  protected constructor(dict: PDFDict, ref: PDFRef) {\n    this.dict = dict;\n    this.ref = ref;\n  }\n\n  T(): PDFString | PDFHexString | undefined {\n    return this.dict.lookupMaybe(PDFName.of('T'), PDFString, PDFHexString);\n  }\n\n  Ff(): PDFNumber | undefined {\n    const numberOrRef = this.getInheritableAttribute(PDFName.of('Ff'));\n    return this.dict.context.lookupMaybe(numberOrRef, PDFNumber);\n  }\n\n  V(): PDFObject | undefined {\n    const valueOrRef = this.getInheritableAttribute(PDFName.of('V'));\n    return this.dict.context.lookup(valueOrRef);\n  }\n\n  Kids(): PDFArray | undefined {\n    return this.dict.lookupMaybe(PDFName.of('Kids'), PDFArray);\n  }\n\n  // Parent(): PDFDict | undefined {\n  //   return this.dict.lookupMaybe(PDFName.of('Parent'), PDFDict);\n  // }\n\n  DA(): PDFString | PDFHexString | undefined {\n    const da = this.dict.lookup(PDFName.of('DA'));\n    if (da instanceof PDFString || da instanceof PDFHexString) return da;\n    return undefined;\n  }\n\n  setKids(kids: PDFObject[]) {\n    this.dict.set(PDFName.of('Kids'), this.dict.context.obj(kids));\n  }\n\n  getParent(): PDFAcroField | undefined {\n    // const parent = this.Parent();\n    // if (!parent) return undefined;\n    // return new PDFAcroField(parent);\n\n    const parentRef = this.dict.get(PDFName.of('Parent'));\n    if (parentRef instanceof PDFRef) {\n      const parent = this.dict.lookup(PDFName.of('Parent'), PDFDict);\n      return new PDFAcroField(parent, parentRef);\n    }\n\n    return undefined;\n  }\n\n  setParent(parent: PDFRef | undefined) {\n    if (!parent) this.dict.delete(PDFName.of('Parent'));\n    else this.dict.set(PDFName.of('Parent'), parent);\n  }\n\n  getFullyQualifiedName(): string | undefined {\n    const parent = this.getParent();\n    if (!parent) return this.getPartialName();\n    return `${parent.getFullyQualifiedName()}.${this.getPartialName()}`;\n  }\n\n  getPartialName(): string | undefined {\n    return this.T()?.decodeText();\n  }\n\n  setPartialName(partialName: string | undefined) {\n    if (!partialName) this.dict.delete(PDFName.of('T'));\n    else this.dict.set(PDFName.of('T'), PDFHexString.fromText(partialName));\n  }\n\n  setDefaultAppearance(appearance: string) {\n    this.dict.set(PDFName.of('DA'), PDFString.of(appearance));\n  }\n\n  getDefaultAppearance(): string | undefined {\n    const DA = this.DA();\n\n    if (DA instanceof PDFHexString) {\n      return DA.decodeText();\n    }\n\n    return DA?.asString();\n  }\n\n  setFontSize(fontSize: number) {\n    const name = this.getFullyQualifiedName() ?? '';\n\n    const da = this.getDefaultAppearance();\n    if (!da) throw new MissingDAEntryError(name);\n\n    const daMatch = findLastMatch(da, tfRegex);\n    if (!daMatch.match) throw new MissingTfOperatorError(name);\n\n    const daStart = da.slice(0, daMatch.pos - daMatch.match[0].length);\n    const daEnd = daMatch.pos \u003c= da.length ? da.slice(daMatch.pos) : '';\n    const fontName = daMatch.match[1];\n    const modifiedDa = `${daStart} /${fontName} ${fontSize} Tf ${daEnd}`;\n\n    this.setDefaultAppearance(modifiedDa);\n  }\n\n  getFlags(): number {\n    return this.Ff()?.asNumber() ?? 0;\n  }\n\n  setFlags(flags: number) {\n    this.dict.set(PDFName.of('Ff'), PDFNumber.of(flags));\n  }\n\n  hasFlag(flag: number): boolean {\n    const flags = this.getFlags();\n    return (flags \u0026 flag) !== 0;\n  }\n\n  setFlag(flag: number) {\n    const flags = this.getFlags();\n    this.setFlags(flags | flag);\n  }\n\n  clearFlag(flag: number) {\n    const flags = this.getFlags();\n    this.setFlags(flags \u0026 ~flag);\n  }\n\n  setFlagTo(flag: number, enable: boolean) {\n    if (enable) this.setFlag(flag);\n    else this.clearFlag(flag);\n  }\n\n  getInheritableAttribute(name: PDFName): PDFObject | undefined {\n    let attribute: PDFObject | undefined;\n    this.ascend((node) =\u003e {\n      if (!attribute) attribute = node.dict.get(name);\n    });\n    return attribute;\n  }\n\n  ascend(visitor: (node: PDFAcroField) =\u003e any): void {\n    visitor(this);\n    const parent = this.getParent();\n    if (parent) parent.ascend(visitor);\n  }\n}\n\nexport default PDFAcroField;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\n\n// TODO: Also handle the `/S` and `/D` entries\nclass BorderStyle {\n  readonly dict: PDFDict;\n\n  static fromDict = (dict: PDFDict): BorderStyle =\u003e new BorderStyle(dict);\n\n  protected constructor(dict: PDFDict) {\n    this.dict = dict;\n  }\n\n  W(): PDFNumber | undefined {\n    const W = this.dict.lookup(PDFName.of('W'));\n    if (W instanceof PDFNumber) return W;\n    return undefined;\n  }\n\n  getWidth(): number | undefined {\n    return this.W()?.asNumber() ?? 1;\n  }\n\n  setWidth(width: number) {\n    const W = this.dict.context.obj(width);\n    this.dict.set(PDFName.of('W'), W);\n  }\n}\n\nexport default BorderStyle;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFNumber from 'src/core/objects/PDFNumber';\n\nclass PDFAnnotation {\n  readonly dict: PDFDict;\n\n  static fromDict = (dict: PDFDict): PDFAnnotation =\u003e new PDFAnnotation(dict);\n\n  protected constructor(dict: PDFDict) {\n    this.dict = dict;\n  }\n\n  // This is technically required by the PDF spec\n  Rect(): PDFArray | undefined {\n    return this.dict.lookup(PDFName.of('Rect'), PDFArray);\n  }\n\n  AP(): PDFDict | undefined {\n    return this.dict.lookupMaybe(PDFName.of('AP'), PDFDict);\n  }\n\n  F(): PDFNumber | undefined {\n    const numberOrRef = this.dict.lookup(PDFName.of('F'));\n    return this.dict.context.lookupMaybe(numberOrRef, PDFNumber);\n  }\n\n  getRectangle(): { x: number; y: number; width: number; height: number } {\n    const Rect = this.Rect();\n    return Rect?.asRectangle() ?? { x: 0, y: 0, width: 0, height: 0 };\n  }\n\n  setRectangle(rect: { x: number; y: number; width: number; height: number }) {\n    const { x, y, width, height } = rect;\n    const Rect = this.dict.context.obj([x, y, x + width, y + height]);\n    this.dict.set(PDFName.of('Rect'), Rect);\n  }\n\n  getAppearanceState(): PDFName | undefined {\n    const AS = this.dict.lookup(PDFName.of('AS'));\n    if (AS instanceof PDFName) return AS;\n    return undefined;\n  }\n\n  setAppearanceState(state: PDFName) {\n    this.dict.set(PDFName.of('AS'), state);\n  }\n\n  setAppearances(appearances: PDFDict) {\n    this.dict.set(PDFName.of('AP'), appearances);\n  }\n\n  ensureAP(): PDFDict {\n    let AP = this.AP();\n    if (!AP) {\n      AP = this.dict.context.obj({});\n      this.dict.set(PDFName.of('AP'), AP);\n    }\n    return AP;\n  }\n\n  getNormalAppearance(): PDFRef | PDFDict {\n    const AP = this.ensureAP();\n    const N = AP.get(PDFName.of('N'));\n    if (N instanceof PDFRef || N instanceof PDFDict) return N;\n\n    throw new Error(`Unexpected N type: ${N?.constructor.name}`);\n  }\n\n  /** @param appearance A PDFDict or PDFStream (direct or ref) */\n  setNormalAppearance(appearance: PDFRef | PDFDict) {\n    const AP = this.ensureAP();\n    AP.set(PDFName.of('N'), appearance);\n  }\n\n  /** @param appearance A PDFDict or PDFStream (direct or ref) */\n  setRolloverAppearance(appearance: PDFRef | PDFDict) {\n    const AP = this.ensureAP();\n    AP.set(PDFName.of('R'), appearance);\n  }\n\n  /** @param appearance A PDFDict or PDFStream (direct or ref) */\n  setDownAppearance(appearance: PDFRef | PDFDict) {\n    const AP = this.ensureAP();\n    AP.set(PDFName.of('D'), appearance);\n  }\n\n  removeRolloverAppearance() {\n    const AP = this.AP();\n    AP?.delete(PDFName.of('R'));\n  }\n\n  removeDownAppearance() {\n    const AP = this.AP();\n    AP?.delete(PDFName.of('D'));\n  }\n\n  getAppearances():\n    | {\n        normal: PDFStream | PDFDict;\n        rollover?: PDFStream | PDFDict;\n        down?: PDFStream | PDFDict;\n      }\n    | undefined {\n    const AP = this.AP();\n\n    if (!AP) return undefined;\n\n    const N = AP.lookup(PDFName.of('N'), PDFDict, PDFStream);\n    const R = AP.lookupMaybe(PDFName.of('R'), PDFDict, PDFStream);\n    const D = AP.lookupMaybe(PDFName.of('D'), PDFDict, PDFStream);\n\n    return { normal: N, rollover: R, down: D };\n  }\n\n  getFlags(): number {\n    return this.F()?.asNumber() ?? 0;\n  }\n\n  setFlags(flags: number) {\n    this.dict.set(PDFName.of('F'), PDFNumber.of(flags));\n  }\n\n  hasFlag(flag: number): boolean {\n    const flags = this.getFlags();\n    return (flags \u0026 flag) !== 0;\n  }\n\n  setFlag(flag: number) {\n    const flags = this.getFlags();\n    this.setFlags(flags | flag);\n  }\n\n  clearFlag(flag: number) {\n    const flags = this.getFlags();\n    this.setFlags(flags \u0026 ~flag);\n  }\n\n  setFlagTo(flag: number, enable: boolean) {\n    if (enable) this.setFlag(flag);\n    else this.clearFlag(flag);\n  }\n}\n\nexport default PDFAnnotation;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFString from 'src/core/objects/PDFString';\n\nclass AppearanceCharacteristics {\n  readonly dict: PDFDict;\n\n  static fromDict = (dict: PDFDict): AppearanceCharacteristics =\u003e\n    new AppearanceCharacteristics(dict);\n\n  protected constructor(dict: PDFDict) {\n    this.dict = dict;\n  }\n\n  R(): PDFNumber | undefined {\n    const R = this.dict.lookup(PDFName.of('R'));\n    if (R instanceof PDFNumber) return R;\n    return undefined;\n  }\n\n  BC(): PDFArray | undefined {\n    const BC = this.dict.lookup(PDFName.of('BC'));\n    if (BC instanceof PDFArray) return BC;\n    return undefined;\n  }\n\n  BG(): PDFArray | undefined {\n    const BG = this.dict.lookup(PDFName.of('BG'));\n    if (BG instanceof PDFArray) return BG;\n    return undefined;\n  }\n\n  CA(): PDFHexString | PDFString | undefined {\n    const CA = this.dict.lookup(PDFName.of('CA'));\n    if (CA instanceof PDFHexString || CA instanceof PDFString) return CA;\n    return undefined;\n  }\n\n  RC(): PDFHexString | PDFString | undefined {\n    const RC = this.dict.lookup(PDFName.of('RC'));\n    if (RC instanceof PDFHexString || RC instanceof PDFString) return RC;\n    return undefined;\n  }\n\n  AC(): PDFHexString | PDFString | undefined {\n    const AC = this.dict.lookup(PDFName.of('AC'));\n    if (AC instanceof PDFHexString || AC instanceof PDFString) return AC;\n    return undefined;\n  }\n\n  getRotation(): number | undefined {\n    return this.R()?.asNumber();\n  }\n\n  getBorderColor(): number[] | undefined {\n    const BC = this.BC();\n\n    if (!BC) return undefined;\n\n    const components: number[] = [];\n    for (let idx = 0, len = BC?.size(); idx \u003c len; idx++) {\n      const component = BC.get(idx);\n      if (component instanceof PDFNumber) components.push(component.asNumber());\n    }\n\n    return components;\n  }\n\n  getBackgroundColor(): number[] | undefined {\n    const BG = this.BG();\n\n    if (!BG) return undefined;\n\n    const components: number[] = [];\n    for (let idx = 0, len = BG?.size(); idx \u003c len; idx++) {\n      const component = BG.get(idx);\n      if (component instanceof PDFNumber) components.push(component.asNumber());\n    }\n\n    return components;\n  }\n\n  getCaptions(): { normal?: string; rollover?: string; down?: string } {\n    const CA = this.CA();\n    const RC = this.RC();\n    const AC = this.AC();\n\n    return {\n      normal: CA?.decodeText(),\n      rollover: RC?.decodeText(),\n      down: AC?.decodeText(),\n    };\n  }\n\n  setRotation(rotation: number) {\n    const R = this.dict.context.obj(rotation);\n    this.dict.set(PDFName.of('R'), R);\n  }\n\n  setBorderColor(color: number[]) {\n    const BC = this.dict.context.obj(color);\n    this.dict.set(PDFName.of('BC'), BC);\n  }\n\n  setBackgroundColor(color: number[]) {\n    const BG = this.dict.context.obj(color);\n    this.dict.set(PDFName.of('BG'), BG);\n  }\n\n  setCaptions(captions: { normal: string; rollover?: string; down?: string }) {\n    const CA = PDFHexString.fromText(captions.normal);\n    this.dict.set(PDFName.of('CA'), CA);\n\n    if (captions.rollover) {\n      const RC = PDFHexString.fromText(captions.rollover);\n      this.dict.set(PDFName.of('RC'), RC);\n    } else {\n      this.dict.delete(PDFName.of('RC'));\n    }\n\n    if (captions.down) {\n      const AC = PDFHexString.fromText(captions.down);\n      this.dict.set(PDFName.of('AC'), AC);\n    } else {\n      this.dict.delete(PDFName.of('AC'));\n    }\n  }\n}\n\nexport default AppearanceCharacteristics;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFContext from 'src/core/PDFContext';\nimport BorderStyle from 'src/core/annotation/BorderStyle';\nimport PDFAnnotation from 'src/core/annotation/PDFAnnotation';\nimport AppearanceCharacteristics from 'src/core/annotation/AppearanceCharacteristics';\n\nclass PDFWidgetAnnotation extends PDFAnnotation {\n  static fromDict = (dict: PDFDict): PDFWidgetAnnotation =\u003e\n    new PDFWidgetAnnotation(dict);\n\n  static create = (context: PDFContext, parent: PDFRef) =\u003e {\n    const dict = context.obj({\n      Type: 'Annot',\n      Subtype: 'Widget',\n      Rect: [0, 0, 0, 0],\n      Parent: parent,\n    });\n    return new PDFWidgetAnnotation(dict);\n  };\n\n  MK(): PDFDict | undefined {\n    const MK = this.dict.lookup(PDFName.of('MK'));\n    if (MK instanceof PDFDict) return MK;\n    return undefined;\n  }\n\n  BS(): PDFDict | undefined {\n    const BS = this.dict.lookup(PDFName.of('BS'));\n    if (BS instanceof PDFDict) return BS;\n    return undefined;\n  }\n\n  DA(): PDFString | PDFHexString | undefined {\n    const da = this.dict.lookup(PDFName.of('DA'));\n    if (da instanceof PDFString || da instanceof PDFHexString) return da;\n    return undefined;\n  }\n\n  P(): PDFRef | undefined {\n    const P = this.dict.get(PDFName.of('P'));\n    if (P instanceof PDFRef) return P;\n    return undefined;\n  }\n\n  setP(page: PDFRef) {\n    this.dict.set(PDFName.of('P'), page);\n  }\n\n  setDefaultAppearance(appearance: string) {\n    this.dict.set(PDFName.of('DA'), PDFString.of(appearance));\n  }\n\n  getDefaultAppearance(): string | undefined {\n    const DA = this.DA();\n\n    if (DA instanceof PDFHexString) {\n      return DA.decodeText();\n    }\n\n    return DA?.asString();\n  }\n\n  getAppearanceCharacteristics(): AppearanceCharacteristics | undefined {\n    const MK = this.MK();\n    if (MK) return AppearanceCharacteristics.fromDict(MK);\n    return undefined;\n  }\n\n  getOrCreateAppearanceCharacteristics(): AppearanceCharacteristics {\n    const MK = this.MK();\n    if (MK) return AppearanceCharacteristics.fromDict(MK);\n\n    const ac = AppearanceCharacteristics.fromDict(this.dict.context.obj({}));\n    this.dict.set(PDFName.of('MK'), ac.dict);\n    return ac;\n  }\n\n  getBorderStyle(): BorderStyle | undefined {\n    const BS = this.BS();\n    if (BS) return BorderStyle.fromDict(BS);\n    return undefined;\n  }\n\n  getOrCreateBorderStyle(): BorderStyle {\n    const BS = this.BS();\n    if (BS) return BorderStyle.fromDict(BS);\n\n    const bs = BorderStyle.fromDict(this.dict.context.obj({}));\n    this.dict.set(PDFName.of('BS'), bs.dict);\n    return bs;\n  }\n\n  getOnValue(): PDFName | undefined {\n    const normal = this.getAppearances()?.normal;\n\n    if (normal instanceof PDFDict) {\n      const keys = normal.keys();\n      for (let idx = 0, len = keys.length; idx \u003c len; idx++) {\n        const key = keys[idx];\n        if (key !== PDFName.of('Off')) return key;\n      }\n    }\n\n    return undefined;\n  }\n}\n\nexport default PDFWidgetAnnotation;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFAcroField from 'src/core/acroform/PDFAcroField';\nimport PDFWidgetAnnotation from 'src/core/annotation/PDFWidgetAnnotation';\nimport { IndexOutOfBoundsError } from 'src/core/errors';\n\nclass PDFAcroTerminal extends PDFAcroField {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroTerminal(dict, ref);\n\n  FT(): PDFName {\n    const nameOrRef = this.getInheritableAttribute(PDFName.of('FT'));\n    return this.dict.context.lookup(nameOrRef, PDFName);\n  }\n\n  getWidgets(): PDFWidgetAnnotation[] {\n    const kidDicts = this.Kids();\n\n    // This field is itself a widget\n    if (!kidDicts) return [PDFWidgetAnnotation.fromDict(this.dict)];\n\n    // This field's kids are its widgets\n    const widgets = new Array\u003cPDFWidgetAnnotation\u003e(kidDicts.size());\n    for (let idx = 0, len = kidDicts.size(); idx \u003c len; idx++) {\n      const dict = kidDicts.lookup(idx, PDFDict);\n      widgets[idx] = PDFWidgetAnnotation.fromDict(dict);\n    }\n\n    return widgets;\n  }\n\n  addWidget(ref: PDFRef) {\n    const { Kids } = this.normalizedEntries();\n    Kids.push(ref);\n  }\n\n  removeWidget(idx: number) {\n    const kidDicts = this.Kids();\n\n    if (!kidDicts) {\n      // This field is itself a widget\n      if (idx !== 0) throw new IndexOutOfBoundsError(idx, 0, 0);\n      this.setKids([]);\n    } else {\n      // This field's kids are its widgets\n      if (idx \u003c 0 || idx \u003e kidDicts.size()) {\n        throw new IndexOutOfBoundsError(idx, 0, kidDicts.size());\n      }\n      kidDicts.remove(idx);\n    }\n  }\n\n  normalizedEntries() {\n    let Kids = this.Kids();\n\n    // If this field is itself a widget (because it was only rendered once in\n    // the document, so the field and widget properties were merged) then we\n    // add itself to the `Kids` array. The alternative would be to try\n    // splitting apart the widget properties and creating a separate object\n    // for them.\n    if (!Kids) {\n      Kids = this.dict.context.obj([this.ref]);\n      this.dict.set(PDFName.of('Kids'), Kids);\n    }\n\n    return { Kids };\n  }\n}\n\nexport default PDFAcroTerminal;\n","import PDFObject from 'src/core/objects/PDFObject';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFAcroTerminal from 'src/core/acroform/PDFAcroTerminal';\nimport { IndexOutOfBoundsError } from 'src/core/errors';\n\nclass PDFAcroButton extends PDFAcroTerminal {\n  Opt(): PDFString | PDFHexString | PDFArray | undefined {\n    return this.dict.lookupMaybe(\n      PDFName.of('Opt'),\n      PDFString,\n      PDFHexString,\n      PDFArray,\n    );\n  }\n\n  setOpt(opt: PDFObject[]) {\n    this.dict.set(PDFName.of('Opt'), this.dict.context.obj(opt));\n  }\n\n  getExportValues(): (PDFString | PDFHexString)[] | undefined {\n    const opt = this.Opt();\n\n    if (!opt) return undefined;\n\n    if (opt instanceof PDFString || opt instanceof PDFHexString) {\n      return [opt];\n    }\n\n    const values: (PDFString | PDFHexString)[] = [];\n    for (let idx = 0, len = opt.size(); idx \u003c len; idx++) {\n      const value = opt.lookup(idx);\n      if (value instanceof PDFString || value instanceof PDFHexString) {\n        values.push(value);\n      }\n    }\n\n    return values;\n  }\n\n  removeExportValue(idx: number) {\n    const opt = this.Opt();\n\n    if (!opt) return;\n\n    if (opt instanceof PDFString || opt instanceof PDFHexString) {\n      if (idx !== 0) throw new IndexOutOfBoundsError(idx, 0, 0);\n      this.setOpt([]);\n    } else {\n      if (idx \u003c 0 || idx \u003e opt.size()) {\n        throw new IndexOutOfBoundsError(idx, 0, opt.size());\n      }\n      opt.remove(idx);\n    }\n  }\n\n  // Enforce use use of /Opt even if it isn't strictly necessary\n  normalizeExportValues() {\n    const exportValues = this.getExportValues() ?? [];\n\n    const Opt: (PDFString | PDFHexString)[] = [];\n\n    const widgets = this.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const exportVal =\n        exportValues[idx] ??\n        PDFHexString.fromText(widget.getOnValue()?.decodeText() ?? '');\n      Opt.push(exportVal);\n    }\n\n    this.setOpt(Opt);\n  }\n\n  /**\n   * Reuses existing opt if one exists with the same value (assuming\n   * `useExistingIdx` is `true`). Returns index of existing (or new) opt.\n   */\n  addOpt(opt: PDFHexString | PDFString, useExistingOptIdx: boolean): number {\n    this.normalizeExportValues();\n\n    const optText = opt.decodeText();\n\n    let existingIdx: number | undefined;\n    if (useExistingOptIdx) {\n      const exportValues = this.getExportValues() ?? [];\n      for (let idx = 0, len = exportValues.length; idx \u003c len; idx++) {\n        const exportVal = exportValues[idx];\n        if (exportVal.decodeText() === optText) existingIdx = idx;\n      }\n    }\n\n    const Opt = this.Opt() as PDFArray;\n    Opt.push(opt);\n\n    return existingIdx ?? Opt.size() - 1;\n  }\n\n  addWidgetWithOpt(\n    widget: PDFRef,\n    opt: PDFHexString | PDFString,\n    useExistingOptIdx: boolean,\n  ) {\n    const optIdx = this.addOpt(opt, useExistingOptIdx);\n    const apStateValue = PDFName.of(String(optIdx));\n    this.addWidget(widget);\n    return apStateValue;\n  }\n}\n\nexport default PDFAcroButton;\n","import PDFContext from 'src/core/PDFContext';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFAcroButton from 'src/core/acroform/PDFAcroButton';\nimport { InvalidAcroFieldValueError } from 'src/core/errors';\n\nclass PDFAcroCheckBox extends PDFAcroButton {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroCheckBox(dict, ref);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({\n      FT: 'Btn',\n      Kids: [],\n    });\n    const ref = context.register(dict);\n    return new PDFAcroCheckBox(dict, ref);\n  };\n\n  setValue(value: PDFName) {\n    const onValue = this.getOnValue() ?? PDFName.of('Yes');\n    if (value !== onValue \u0026\u0026 value !== PDFName.of('Off')) {\n      throw new InvalidAcroFieldValueError();\n    }\n\n    this.dict.set(PDFName.of('V'), value);\n\n    const widgets = this.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const state = widget.getOnValue() === value ? value : PDFName.of('Off');\n      widget.setAppearanceState(state);\n    }\n  }\n\n  getValue(): PDFName {\n    const v = this.V();\n    if (v instanceof PDFName) return v;\n    return PDFName.of('Off');\n  }\n\n  getOnValue(): PDFName | undefined {\n    const [widget] = this.getWidgets();\n    return widget?.getOnValue();\n  }\n}\n\nexport default PDFAcroCheckBox;\n","const flag = (bitIndex: number) =\u003e 1 \u003c\u003c bitIndex;\n\n/** From PDF spec table 221 */\nexport enum AcroFieldFlags {\n  /**\n   * If set, the user may not change the value of the field. Any associated\n   * widget annotations will not interact with the user; that is, they will not\n   * respond to mouse clicks or change their appearance in response to mouse\n   * motions. This flag is useful for fields whose values are computed or\n   * imported from a database.\n   */\n  ReadOnly = flag(1 - 1),\n\n  /**\n   * If set, the field shall have a value at the time it is exported by a\n   * submit-form action (see 12.7.5.2, \"Submit-Form Action\").\n   */\n  Required = flag(2 - 1),\n\n  /**\n   * If set, the field shall not be exported by a submit-form action\n   * (see 12.7.5.2, \"Submit-Form Action\").\n   */\n  NoExport = flag(3 - 1),\n}\n\n/** From PDF spec table 226 */\nexport enum AcroButtonFlags {\n  /**\n   * (Radio buttons only) If set, exactly one radio button shall be selected at\n   * all times; selecting the currently selected button has no effect. If clear,\n   * clicking the selected button deselects it, leaving no button selected.\n   */\n  NoToggleToOff = flag(15 - 1),\n\n  /**\n   * If set, the field is a set of radio buttons; if clear, the field is a check\n   * box. This flag may be set only if the Pushbutton flag is clear.\n   */\n  Radio = flag(16 - 1),\n\n  /**\n   * If set, the field is a pushbutton that does not retain a permanent value.\n   */\n  PushButton = flag(17 - 1),\n\n  /**\n   * If set, a group of radio buttons within a radio button field that use the\n   * same value for the on state will turn on and off in unison; that is if one\n   * is checked, they are all checked. If clear, the buttons are mutually\n   * exclusive (the same behavior as HTML radio buttons).\n   */\n  RadiosInUnison = flag(26 - 1),\n}\n\n/** From PDF spec table 228 */\nexport enum AcroTextFlags {\n  /**\n   * If set, the field may contain multiple lines of text; if clear, the field's\n   * text shall be restricted to a single line.\n   */\n  Multiline = flag(13 - 1),\n\n  /**\n   * If set, the field is intended for entering a secure password that should\n   * not be echoed visibly to the screen. Characters typed from the keyboard\n   * shall instead be echoed in some unreadable form, such as asterisks or\n   * bullet characters.\n   * \u003e NOTE   To protect password confidentiality, readers should never store\n   * \u003e        the value of the text field in the PDF file if this flag is set.\n   */\n  Password = flag(14 - 1),\n\n  /**\n   * If set, the text entered in the field represents the pathname of a file\n   * whose contents shall be submitted as the value of the field.\n   */\n  FileSelect = flag(21 - 1),\n\n  /**\n   * If set, text entered in the field shall not be spell-checked.\n   */\n  DoNotSpellCheck = flag(23 - 1),\n\n  /**\n   * If set, the field shall not scroll (horizontally for single-line fields,\n   * vertically for multiple-line fields) to accommodate more text than fits\n   * within its annotation rectangle. Once the field is full, no further text\n   * shall be accepted for interactive form filling; for non-interactive form\n   * filling, the filler should take care not to add more character than will\n   * visibly fit in the defined area.\n   */\n  DoNotScroll = flag(24 - 1),\n\n  /**\n   * May be set only if the MaxLen entry is present in the text field dictionary\n   * (see Table 229) and if the Multiline, Password, and FileSelect flags are\n   * clear. If set, the field shall be automatically divided into as many\n   * equally spaced positions, or combs, as the value of MaxLen, and the text\n   * is laid out into those combs.\n   */\n  Comb = flag(25 - 1),\n\n  /**\n   * If set, the value of this field shall be a rich text string\n   * (see 12.7.3.4, \"Rich Text Strings\"). If the field has a value, the RV\n   * entry of the field dictionary (Table 222) shall specify the rich text\n   * string.\n   */\n  RichText = flag(26 - 1),\n}\n\n/** From PDF spec table 230 */\nexport enum AcroChoiceFlags {\n  /**\n   * If set, the field is a combo box; if clear, the field is a list box.\n   */\n  Combo = flag(18 - 1),\n\n  /**\n   * If set, the combo box shall include an editable text box as well as a\n   * drop-down list; if clear, it shall include only a drop-down list. This\n   * flag shall be used only if the Combo flag is set.\n   */\n  Edit = flag(19 - 1),\n\n  /**\n   * If set, the field's option items shall be sorted alphabetically. This flag\n   * is intended for use by writers, not by readers. Conforming readers shall\n   * display the options in the order in which they occur in the Opt array\n   * (see Table 231).\n   */\n  Sort = flag(20 - 1),\n\n  /**\n   * If set, more than one of the field's option items may be selected\n   * simultaneously; if clear, at most one item shall be selected.\n   */\n  MultiSelect = flag(22 - 1),\n\n  /**\n   * If set, text entered in the field shall not be spell-checked. This flag\n   * shall not be used unless the Combo and Edit flags are both set.\n   */\n  DoNotSpellCheck = flag(23 - 1),\n\n  /**\n   * If set, the new value shall be committed as soon as a selection is made\n   * (commonly with the pointing device). In this case, supplying a value for\n   * a field involves three actions: selecting the field for fill-in,\n   * selecting a choice for the fill-in value, and leaving that field, which\n   * finalizes or \"commits\" the data choice and triggers any actions associated\n   * with the entry or changing of this data. If this flag is on, then\n   * processing does not wait for leaving the field action to occur, but\n   * immediately proceeds to the third step.\n   *\n   * This option enables applications to perform an action once a selection is\n   * made, without requiring the user to exit the field. If clear, the new\n   * value is not committed until the user exits the field.\n   */\n  CommitOnSelChange = flag(27 - 1),\n}\n","import PDFAcroTerminal from 'src/core/acroform/PDFAcroTerminal';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFName from 'src/core/objects/PDFName';\nimport { AcroChoiceFlags } from 'src/core/acroform/flags';\nimport {\n  InvalidAcroFieldValueError,\n  MultiSelectValueError,\n} from 'src/core/errors';\n\nclass PDFAcroChoice extends PDFAcroTerminal {\n  setValues(values: (PDFString | PDFHexString)[]) {\n    if (\n      this.hasFlag(AcroChoiceFlags.Combo) \u0026\u0026\n      !this.hasFlag(AcroChoiceFlags.Edit) \u0026\u0026\n      !this.valuesAreValid(values)\n    ) {\n      throw new InvalidAcroFieldValueError();\n    }\n\n    if (values.length === 0) {\n      this.dict.delete(PDFName.of('V'));\n    }\n    if (values.length === 1) {\n      this.dict.set(PDFName.of('V'), values[0]);\n    }\n    if (values.length \u003e 1) {\n      if (!this.hasFlag(AcroChoiceFlags.MultiSelect)) {\n        throw new MultiSelectValueError();\n      }\n      this.dict.set(PDFName.of('V'), this.dict.context.obj(values));\n    }\n\n    this.updateSelectedIndices(values);\n  }\n\n  valuesAreValid(values: (PDFString | PDFHexString)[]): boolean {\n    const options = this.getOptions();\n    for (let idx = 0, len = values.length; idx \u003c len; idx++) {\n      const val = values[idx].decodeText();\n      if (!options.find((o) =\u003e val === (o.display || o.value).decodeText())) {\n        return false;\n      }\n    }\n    return true;\n  }\n\n  updateSelectedIndices(values: (PDFString | PDFHexString)[]) {\n    if (values.length \u003e 1) {\n      const indices = new Array\u003cnumber\u003e(values.length);\n      const options = this.getOptions();\n      for (let idx = 0, len = values.length; idx \u003c len; idx++) {\n        const val = values[idx].decodeText();\n        indices[idx] = options.findIndex(\n          (o) =\u003e val === (o.display || o.value).decodeText(),\n        );\n      }\n      this.dict.set(PDFName.of('I'), this.dict.context.obj(indices.sort()));\n    } else {\n      this.dict.delete(PDFName.of('I'));\n    }\n  }\n\n  getValues(): (PDFString | PDFHexString)[] {\n    const v = this.V();\n\n    if (v instanceof PDFString || v instanceof PDFHexString) return [v];\n\n    if (v instanceof PDFArray) {\n      const values: (PDFString | PDFHexString)[] = [];\n\n      for (let idx = 0, len = v.size(); idx \u003c len; idx++) {\n        const value = v.lookup(idx);\n        if (value instanceof PDFString || value instanceof PDFHexString) {\n          values.push(value);\n        }\n      }\n\n      return values;\n    }\n\n    return [];\n  }\n\n  Opt(): PDFArray | PDFString | PDFHexString | undefined {\n    return this.dict.lookupMaybe(\n      PDFName.of('Opt'),\n      PDFString,\n      PDFHexString,\n      PDFArray,\n    );\n  }\n\n  setOptions(\n    options: {\n      value: PDFString | PDFHexString;\n      display?: PDFString | PDFHexString;\n    }[],\n  ) {\n    const newOpt = new Array\u003cPDFArray\u003e(options.length);\n    for (let idx = 0, len = options.length; idx \u003c len; idx++) {\n      const { value, display } = options[idx];\n      newOpt[idx] = this.dict.context.obj([value, display || value]);\n    }\n    this.dict.set(PDFName.of('Opt'), this.dict.context.obj(newOpt));\n  }\n\n  getOptions(): {\n    value: PDFString | PDFHexString;\n    display: PDFString | PDFHexString;\n  }[] {\n    const Opt = this.Opt();\n\n    // Not supposed to happen - Opt _should_ always be `PDFArray | undefined`\n    if (Opt instanceof PDFString || Opt instanceof PDFHexString) {\n      return [{ value: Opt, display: Opt }];\n    }\n\n    if (Opt instanceof PDFArray) {\n      const res: {\n        value: PDFString | PDFHexString;\n        display: PDFString | PDFHexString;\n      }[] = [];\n\n      for (let idx = 0, len = Opt.size(); idx \u003c len; idx++) {\n        const item = Opt.lookup(idx);\n\n        // If `item` is a string, use that as both the export and text value\n        if (item instanceof PDFString || item instanceof PDFHexString) {\n          res.push({ value: item, display: item });\n        }\n\n        // If `item` is an array of one, treat it the same as just a string,\n        // if it's an array of two then `item[0]` is the export value and\n        // `item[1]` is the text value\n        if (item instanceof PDFArray) {\n          if (item.size() \u003e 0) {\n            const first = item.lookup(0, PDFString, PDFHexString);\n            const second = item.lookupMaybe(1, PDFString, PDFHexString);\n            res.push({ value: first, display: second || first });\n          }\n        }\n      }\n\n      return res;\n    }\n\n    return [];\n  }\n}\n\nexport default PDFAcroChoice;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFAcroChoice from 'src/core/acroform/PDFAcroChoice';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport { AcroChoiceFlags } from 'src/core/acroform/flags';\n\nclass PDFAcroComboBox extends PDFAcroChoice {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroComboBox(dict, ref);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({\n      FT: 'Ch',\n      Ff: AcroChoiceFlags.Combo,\n      Kids: [],\n    });\n    const ref = context.register(dict);\n    return new PDFAcroComboBox(dict, ref);\n  };\n}\n\nexport default PDFAcroComboBox;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFAcroField from 'src/core/acroform/PDFAcroField';\n\nclass PDFAcroNonTerminal extends PDFAcroField {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroNonTerminal(dict, ref);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({});\n    const ref = context.register(dict);\n    return new PDFAcroNonTerminal(dict, ref);\n  };\n\n  addField(field: PDFRef) {\n    const { Kids } = this.normalizedEntries();\n    Kids?.push(field);\n  }\n\n  normalizedEntries() {\n    let Kids = this.Kids();\n\n    if (!Kids) {\n      Kids = this.dict.context.obj([]);\n      this.dict.set(PDFName.of('Kids'), Kids);\n    }\n\n    return { Kids };\n  }\n}\n\nexport default PDFAcroNonTerminal;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFAcroTerminal from 'src/core/acroform/PDFAcroTerminal';\n\nclass PDFAcroSignature extends PDFAcroTerminal {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroSignature(dict, ref);\n}\n\nexport default PDFAcroSignature;\n","import PDFContext from 'src/core/PDFContext';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFString from 'src/core/objects/PDFString';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFAcroTerminal from 'src/core/acroform/PDFAcroTerminal';\n\nclass PDFAcroText extends PDFAcroTerminal {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e new PDFAcroText(dict, ref);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({\n      FT: 'Tx',\n      Kids: [],\n    });\n    const ref = context.register(dict);\n    return new PDFAcroText(dict, ref);\n  };\n\n  MaxLen(): PDFNumber | undefined {\n    const maxLen = this.dict.lookup(PDFName.of('MaxLen'));\n    if (maxLen instanceof PDFNumber) return maxLen;\n    return undefined;\n  }\n\n  Q(): PDFNumber | undefined {\n    const q = this.dict.lookup(PDFName.of('Q'));\n    if (q instanceof PDFNumber) return q;\n    return undefined;\n  }\n\n  setMaxLength(maxLength: number) {\n    this.dict.set(PDFName.of('MaxLen'), PDFNumber.of(maxLength));\n  }\n\n  removeMaxLength() {\n    this.dict.delete(PDFName.of('MaxLen'));\n  }\n\n  getMaxLength(): number | undefined {\n    return this.MaxLen()?.asNumber();\n  }\n\n  setQuadding(quadding: 0 | 1 | 2) {\n    this.dict.set(PDFName.of('Q'), PDFNumber.of(quadding));\n  }\n\n  getQuadding(): number | undefined {\n    return this.Q()?.asNumber();\n  }\n\n  setValue(value: PDFHexString | PDFString) {\n    this.dict.set(PDFName.of('V'), value);\n\n    // const widgets = this.getWidgets();\n    // for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n    //   const widget = widgets[idx];\n    //   const state = widget.getOnValue() === value ? value : PDFName.of('Off');\n    //   widget.setAppearanceState(state);\n    // }\n  }\n\n  removeValue() {\n    this.dict.delete(PDFName.of('V'));\n  }\n\n  getValue(): PDFString | PDFHexString | undefined {\n    const v = this.V();\n    if (v instanceof PDFString || v instanceof PDFHexString) return v;\n    return undefined;\n  }\n}\n\nexport default PDFAcroText;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFAcroButton from 'src/core/acroform/PDFAcroButton';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport { AcroButtonFlags } from 'src/core/acroform/flags';\n\nclass PDFAcroPushButton extends PDFAcroButton {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroPushButton(dict, ref);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({\n      FT: 'Btn',\n      Ff: AcroButtonFlags.PushButton,\n      Kids: [],\n    });\n    const ref = context.register(dict);\n    return new PDFAcroPushButton(dict, ref);\n  };\n}\n\nexport default PDFAcroPushButton;\n","import PDFRef from 'src/core/objects/PDFRef';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFAcroButton from 'src/core/acroform/PDFAcroButton';\nimport PDFContext from 'src/core/PDFContext';\nimport { AcroButtonFlags } from 'src/core/acroform/flags';\nimport { InvalidAcroFieldValueError } from 'src/core/errors';\n\nclass PDFAcroRadioButton extends PDFAcroButton {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroRadioButton(dict, ref);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({\n      FT: 'Btn',\n      Ff: AcroButtonFlags.Radio,\n      Kids: [],\n    });\n    const ref = context.register(dict);\n    return new PDFAcroRadioButton(dict, ref);\n  };\n\n  setValue(value: PDFName) {\n    const onValues = this.getOnValues();\n    if (!onValues.includes(value) \u0026\u0026 value !== PDFName.of('Off')) {\n      throw new InvalidAcroFieldValueError();\n    }\n\n    this.dict.set(PDFName.of('V'), value);\n\n    const widgets = this.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const state = widget.getOnValue() === value ? value : PDFName.of('Off');\n      widget.setAppearanceState(state);\n    }\n  }\n\n  getValue(): PDFName {\n    const v = this.V();\n    if (v instanceof PDFName) return v;\n    return PDFName.of('Off');\n  }\n\n  getOnValues(): PDFName[] {\n    const widgets = this.getWidgets();\n\n    const onValues: PDFName[] = [];\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const onValue = widgets[idx].getOnValue();\n      if (onValue) onValues.push(onValue);\n    }\n\n    return onValues;\n  }\n}\n\nexport default PDFAcroRadioButton;\n","import PDFDict from 'src/core/objects/PDFDict';\nimport PDFAcroChoice from 'src/core/acroform/PDFAcroChoice';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFRef from 'src/core/objects/PDFRef';\n\nclass PDFAcroListBox extends PDFAcroChoice {\n  static fromDict = (dict: PDFDict, ref: PDFRef) =\u003e\n    new PDFAcroListBox(dict, ref);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({\n      FT: 'Ch',\n      Kids: [],\n    });\n    const ref = context.register(dict);\n    return new PDFAcroListBox(dict, ref);\n  };\n}\n\nexport default PDFAcroListBox;\n","import PDFObject from 'src/core/objects/PDFObject';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFRef from 'src/core/objects/PDFRef';\n\nimport PDFAcroField from 'src/core/acroform/PDFAcroField';\nimport PDFAcroTerminal from 'src/core/acroform/PDFAcroTerminal';\nimport PDFAcroNonTerminal from 'src/core/acroform/PDFAcroNonTerminal';\nimport PDFAcroButton from 'src/core/acroform/PDFAcroButton';\nimport PDFAcroSignature from 'src/core/acroform/PDFAcroSignature';\nimport PDFAcroChoice from 'src/core/acroform/PDFAcroChoice';\nimport PDFAcroText from 'src/core/acroform/PDFAcroText';\nimport PDFAcroPushButton from 'src/core/acroform/PDFAcroPushButton';\nimport PDFAcroRadioButton from 'src/core/acroform/PDFAcroRadioButton';\nimport PDFAcroCheckBox from 'src/core/acroform/PDFAcroCheckBox';\nimport PDFAcroComboBox from 'src/core/acroform/PDFAcroComboBox';\nimport PDFAcroListBox from 'src/core/acroform/PDFAcroListBox';\nimport { AcroButtonFlags, AcroChoiceFlags } from 'src/core/acroform/flags';\n\nexport const createPDFAcroFields = (\n  kidDicts?: PDFArray,\n): [PDFAcroField, PDFRef][] =\u003e {\n  if (!kidDicts) return [];\n\n  const kids: [PDFAcroField, PDFRef][] = [];\n  for (let idx = 0, len = kidDicts.size(); idx \u003c len; idx++) {\n    const ref = kidDicts.get(idx);\n    const dict = kidDicts.lookup(idx);\n    // if (dict instanceof PDFDict) kids.push(PDFAcroField.fromDict(dict));\n    if (ref instanceof PDFRef \u0026\u0026 dict instanceof PDFDict) {\n      kids.push([createPDFAcroField(dict, ref), ref]);\n    }\n  }\n\n  return kids;\n};\n\nexport const createPDFAcroField = (\n  dict: PDFDict,\n  ref: PDFRef,\n): PDFAcroField =\u003e {\n  const isNonTerminal = isNonTerminalAcroField(dict);\n  if (isNonTerminal) return PDFAcroNonTerminal.fromDict(dict, ref);\n  return createPDFAcroTerminal(dict, ref);\n};\n\n// TODO: Maybe just check if the dict is *not* a widget? That might be better.\n\n// According to the PDF spec:\n//\n//   \u003e A field's children in the hierarchy may also include widget annotations\n//   \u003e that define its appearance on the page. A field that has children that\n//   \u003e are fields is called a non-terminal field. A field that does not have\n//   \u003e children that are fields is called a terminal field.\n//\n// The spec is not entirely clear about how to determine whether a given\n// dictionary represents an acrofield or a widget annotation. So we will assume\n// that a dictionary is an acrofield if it is a member of the `/Kids` array\n// and it contains a `/T` entry (widgets do not have `/T` entries). This isn't\n// a bullet proof solution, because the `/T` entry is technically defined as\n// optional for acrofields by the PDF spec. But in practice all acrofields seem\n// to have a `/T` entry defined.\nconst isNonTerminalAcroField = (dict: PDFDict): boolean =\u003e {\n  const kids = dict.lookup(PDFName.of('Kids'));\n\n  if (kids instanceof PDFArray) {\n    for (let idx = 0, len = kids.size(); idx \u003c len; idx++) {\n      const kid = kids.lookup(idx);\n      const kidIsField = kid instanceof PDFDict \u0026\u0026 kid.has(PDFName.of('T'));\n      if (kidIsField) return true;\n    }\n  }\n\n  return false;\n};\n\nconst createPDFAcroTerminal = (dict: PDFDict, ref: PDFRef): PDFAcroTerminal =\u003e {\n  const ftNameOrRef = getInheritableAttribute(dict, PDFName.of('FT'));\n  const type = dict.context.lookup(ftNameOrRef, PDFName);\n\n  if (type === PDFName.of('Btn')) return createPDFAcroButton(dict, ref);\n  if (type === PDFName.of('Ch')) return createPDFAcroChoice(dict, ref);\n  if (type === PDFName.of('Tx')) return PDFAcroText.fromDict(dict, ref);\n  if (type === PDFName.of('Sig')) return PDFAcroSignature.fromDict(dict, ref);\n\n  // We should never reach this line. But there are a lot of weird PDFs out\n  // there. So, just to be safe, we'll try to handle things gracefully instead\n  // of throwing an error.\n  return PDFAcroTerminal.fromDict(dict, ref);\n};\n\nconst createPDFAcroButton = (dict: PDFDict, ref: PDFRef): PDFAcroButton =\u003e {\n  const ffNumberOrRef = getInheritableAttribute(dict, PDFName.of('Ff'));\n  const ffNumber = dict.context.lookupMaybe(ffNumberOrRef, PDFNumber);\n  const flags = ffNumber?.asNumber() ?? 0;\n\n  if (flagIsSet(flags, AcroButtonFlags.PushButton)) {\n    return PDFAcroPushButton.fromDict(dict, ref);\n  } else if (flagIsSet(flags, AcroButtonFlags.Radio)) {\n    return PDFAcroRadioButton.fromDict(dict, ref);\n  } else {\n    return PDFAcroCheckBox.fromDict(dict, ref);\n  }\n};\n\nconst createPDFAcroChoice = (dict: PDFDict, ref: PDFRef): PDFAcroChoice =\u003e {\n  const ffNumberOrRef = getInheritableAttribute(dict, PDFName.of('Ff'));\n  const ffNumber = dict.context.lookupMaybe(ffNumberOrRef, PDFNumber);\n  const flags = ffNumber?.asNumber() ?? 0;\n\n  if (flagIsSet(flags, AcroChoiceFlags.Combo)) {\n    return PDFAcroComboBox.fromDict(dict, ref);\n  } else {\n    return PDFAcroListBox.fromDict(dict, ref);\n  }\n};\n\nconst flagIsSet = (flags: number, flag: number): boolean =\u003e\n  (flags \u0026 flag) !== 0;\n\nconst getInheritableAttribute = (startNode: PDFDict, name: PDFName) =\u003e {\n  let attribute: PDFObject | undefined;\n  ascend(startNode, (node) =\u003e {\n    if (!attribute) attribute = node.get(name);\n  });\n  return attribute;\n};\n\nconst ascend = (startNode: PDFDict, visitor: (node: PDFDict) =\u003e any) =\u003e {\n  visitor(startNode);\n  const Parent = startNode.lookupMaybe(PDFName.of('Parent'), PDFDict);\n  if (Parent) ascend(Parent, visitor);\n};\n","import PDFContext from 'src/core/PDFContext';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFAcroField from 'src/core/acroform/PDFAcroField';\nimport PDFAcroNonTerminal from 'src/core/acroform/PDFAcroNonTerminal';\nimport {\n  createPDFAcroField,\n  createPDFAcroFields,\n} from 'src/core/acroform/utils';\n\nclass PDFAcroForm {\n  readonly dict: PDFDict;\n\n  static fromDict = (dict: PDFDict) =\u003e new PDFAcroForm(dict);\n\n  static create = (context: PDFContext) =\u003e {\n    const dict = context.obj({ Fields: [] });\n    return new PDFAcroForm(dict);\n  };\n\n  private constructor(dict: PDFDict) {\n    this.dict = dict;\n  }\n\n  Fields(): PDFArray | undefined {\n    const fields = this.dict.lookup(PDFName.of('Fields'));\n    if (fields instanceof PDFArray) return fields;\n    return undefined;\n  }\n\n  getFields(): [PDFAcroField, PDFRef][] {\n    const { Fields } = this.normalizedEntries();\n\n    const fields = new Array(Fields.size());\n    for (let idx = 0, len = Fields.size(); idx \u003c len; idx++) {\n      const ref = Fields.get(idx) as PDFRef;\n      const dict = Fields.lookup(idx, PDFDict);\n      fields[idx] = [createPDFAcroField(dict, ref), ref];\n    }\n\n    return fields;\n  }\n\n  getAllFields(): [PDFAcroField, PDFRef][] {\n    const allFields: [PDFAcroField, PDFRef][] = [];\n\n    const pushFields = (fields?: [PDFAcroField, PDFRef][]) =\u003e {\n      if (!fields) return;\n      for (let idx = 0, len = fields.length; idx \u003c len; idx++) {\n        const field = fields[idx];\n        allFields.push(field);\n        const [fieldModel] = field;\n        if (fieldModel instanceof PDFAcroNonTerminal) {\n          pushFields(createPDFAcroFields(fieldModel.Kids()));\n        }\n      }\n    };\n\n    pushFields(this.getFields());\n\n    return allFields;\n  }\n\n  addField(field: PDFRef) {\n    const { Fields } = this.normalizedEntries();\n    Fields?.push(field);\n  }\n\n  removeField(field: PDFAcroField): void {\n    const parent = field.getParent();\n    const fields =\n      parent === undefined ? this.normalizedEntries().Fields : parent.Kids();\n\n    const index = fields?.indexOf(field.ref);\n    if (fields === undefined || index === undefined) {\n      throw new Error(\n        `Tried to remove inexistent field ${field.getFullyQualifiedName()}`,\n      );\n    }\n\n    fields.remove(index);\n\n    if (parent !== undefined \u0026\u0026 fields.size() === 0) {\n      this.removeField(parent);\n    }\n  }\n\n  normalizedEntries() {\n    let Fields = this.Fields();\n\n    if (!Fields) {\n      Fields = this.dict.context.obj([]);\n      this.dict.set(PDFName.of('Fields'), Fields);\n    }\n\n    return { Fields };\n  }\n}\n\nexport default PDFAcroForm;\n","import PDFDict, { DictMap } from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFPageTree from 'src/core/structures/PDFPageTree';\nimport { PDFAcroForm } from 'src/core/acroform';\nimport ViewerPreferences from '../interactive/ViewerPreferences';\n\nclass PDFCatalog extends PDFDict {\n  static withContextAndPages = (\n    context: PDFContext,\n    pages: PDFPageTree | PDFRef,\n  ) =\u003e {\n    const dict = new Map();\n    dict.set(PDFName.of('Type'), PDFName.of('Catalog'));\n    dict.set(PDFName.of('Pages'), pages);\n    return new PDFCatalog(dict, context);\n  };\n\n  static fromMapWithContext = (map: DictMap, context: PDFContext) =\u003e\n    new PDFCatalog(map, context);\n\n  Pages(): PDFPageTree {\n    return this.lookup(PDFName.of('Pages'), PDFDict) as PDFPageTree;\n  }\n\n  AcroForm(): PDFDict | undefined {\n    return this.lookupMaybe(PDFName.of('AcroForm'), PDFDict);\n  }\n\n  getAcroForm(): PDFAcroForm | undefined {\n    const dict = this.AcroForm();\n    if (!dict) return undefined;\n    return PDFAcroForm.fromDict(dict);\n  }\n\n  getOrCreateAcroForm(): PDFAcroForm {\n    let acroForm = this.getAcroForm();\n    if (!acroForm) {\n      acroForm = PDFAcroForm.create(this.context);\n      const acroFormRef = this.context.register(acroForm.dict);\n      this.set(PDFName.of('AcroForm'), acroFormRef);\n    }\n    return acroForm;\n  }\n\n  ViewerPreferences(): PDFDict | undefined {\n    return this.lookupMaybe(PDFName.of('ViewerPreferences'), PDFDict);\n  }\n\n  getViewerPreferences(): ViewerPreferences | undefined {\n    const dict = this.ViewerPreferences();\n    if (!dict) return undefined;\n    return ViewerPreferences.fromDict(dict);\n  }\n\n  getOrCreateViewerPreferences(): ViewerPreferences {\n    let viewerPrefs = this.getViewerPreferences();\n    if (!viewerPrefs) {\n      viewerPrefs = ViewerPreferences.create(this.context);\n      const viewerPrefsRef = this.context.register(viewerPrefs.dict);\n      this.set(PDFName.of('ViewerPreferences'), viewerPrefsRef);\n    }\n    return viewerPrefs;\n  }\n\n  /**\n   * Inserts the given ref as a leaf node of this catalog's page tree at the\n   * specified index (zero-based). Also increments the `Count` of each node in\n   * the page tree hierarchy to accomodate the new page.\n   *\n   * Returns the ref of the PDFPageTree node into which `leafRef` was inserted.\n   */\n  insertLeafNode(leafRef: PDFRef, index: number): PDFRef {\n    const pagesRef = this.get(PDFName.of('Pages')) as PDFRef;\n    const maybeParentRef = this.Pages().insertLeafNode(leafRef, index);\n    return maybeParentRef || pagesRef;\n  }\n\n  removeLeafNode(index: number): void {\n    this.Pages().removeLeafNode(index);\n  }\n}\n\nexport default PDFCatalog;\n","import PDFArray from 'src/core/objects/PDFArray';\nimport PDFDict, { DictMap } from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFPageLeaf from 'src/core/structures/PDFPageLeaf';\nimport { InvalidTargetIndexError, CorruptPageTreeError } from 'src/core/errors';\n\nexport type TreeNode = PDFPageTree | PDFPageLeaf;\n\nclass PDFPageTree extends PDFDict {\n  static withContext = (context: PDFContext, parent?: PDFRef) =\u003e {\n    const dict = new Map();\n    dict.set(PDFName.of('Type'), PDFName.of('Pages'));\n    dict.set(PDFName.of('Kids'), context.obj([]));\n    dict.set(PDFName.of('Count'), context.obj(0));\n    if (parent) dict.set(PDFName.of('Parent'), parent);\n    return new PDFPageTree(dict, context);\n  };\n\n  static fromMapWithContext = (map: DictMap, context: PDFContext) =\u003e\n    new PDFPageTree(map, context);\n\n  Parent(): PDFPageTree | undefined {\n    return this.lookup(PDFName.of('Parent')) as PDFPageTree | undefined;\n  }\n\n  Kids(): PDFArray {\n    return this.lookup(PDFName.of('Kids'), PDFArray);\n  }\n\n  Count(): PDFNumber {\n    return this.lookup(PDFName.of('Count'), PDFNumber);\n  }\n\n  pushTreeNode(treeRef: PDFRef): void {\n    const Kids = this.Kids();\n    Kids.push(treeRef);\n  }\n\n  pushLeafNode(leafRef: PDFRef): void {\n    const Kids = this.Kids();\n    this.insertLeafKid(Kids.size(), leafRef);\n  }\n\n  /**\n   * Inserts the given ref as a leaf node of this page tree at the specified\n   * index (zero-based). Also increments the `Count` of each page tree in the\n   * hierarchy to accomodate the new page.\n   *\n   * Returns the ref of the PDFPageTree node into which `leafRef` was inserted,\n   * or `undefined` if it was inserted into the root node (the PDFPageTree upon\n   * which the method was first called).\n   */\n  insertLeafNode(leafRef: PDFRef, targetIndex: number): PDFRef | undefined {\n    const Kids = this.Kids();\n    const Count = this.Count().asNumber();\n\n    if (targetIndex \u003e Count) {\n      throw new InvalidTargetIndexError(targetIndex, Count);\n    }\n\n    let leafsRemainingUntilTarget = targetIndex;\n    for (let idx = 0, len = Kids.size(); idx \u003c len; idx++) {\n      if (leafsRemainingUntilTarget === 0) {\n        // Insert page and return\n        this.insertLeafKid(idx, leafRef);\n        return undefined;\n      }\n\n      const kidRef = Kids.get(idx) as PDFRef;\n      const kid = this.context.lookup(kidRef);\n\n      if (kid instanceof PDFPageTree) {\n        if (kid.Count().asNumber() \u003e leafsRemainingUntilTarget) {\n          // Dig in\n          return (\n            kid.insertLeafNode(leafRef, leafsRemainingUntilTarget) || kidRef\n          );\n        } else {\n          // Move on\n          leafsRemainingUntilTarget -= kid.Count().asNumber();\n        }\n      }\n\n      if (kid instanceof PDFPageLeaf) {\n        // Move on\n        leafsRemainingUntilTarget -= 1;\n      }\n    }\n\n    if (leafsRemainingUntilTarget === 0) {\n      // Insert page at the end and return\n      this.insertLeafKid(Kids.size(), leafRef);\n      return undefined;\n    }\n\n    // Should never get here if `targetIndex` is valid\n    throw new CorruptPageTreeError(targetIndex, 'insertLeafNode');\n  }\n\n  /**\n   * Removes the leaf node at the specified index (zero-based) from this page\n   * tree. Also decrements the `Count` of each page tree in the hierarchy to\n   * account for the removed page.\n   *\n   * If `prune` is true, then intermediate tree nodes will be removed from the\n   * tree if they contain 0 children after the leaf node is removed.\n   */\n  removeLeafNode(targetIndex: number, prune = true): void {\n    const Kids = this.Kids();\n    const Count = this.Count().asNumber();\n\n    if (targetIndex \u003e= Count) {\n      throw new InvalidTargetIndexError(targetIndex, Count);\n    }\n\n    let leafsRemainingUntilTarget = targetIndex;\n    for (let idx = 0, len = Kids.size(); idx \u003c len; idx++) {\n      const kidRef = Kids.get(idx) as PDFRef;\n      const kid = this.context.lookup(kidRef);\n\n      if (kid instanceof PDFPageTree) {\n        if (kid.Count().asNumber() \u003e leafsRemainingUntilTarget) {\n          // Dig in\n          kid.removeLeafNode(leafsRemainingUntilTarget, prune);\n          if (prune \u0026\u0026 kid.Kids().size() === 0) Kids.remove(idx);\n          return;\n        } else {\n          // Move on\n          leafsRemainingUntilTarget -= kid.Count().asNumber();\n        }\n      }\n\n      if (kid instanceof PDFPageLeaf) {\n        if (leafsRemainingUntilTarget === 0) {\n          // Remove page and return\n          this.removeKid(idx);\n          return;\n        } else {\n          // Move on\n          leafsRemainingUntilTarget -= 1;\n        }\n      }\n    }\n\n    // Should never get here if `targetIndex` is valid\n    throw new CorruptPageTreeError(targetIndex, 'removeLeafNode');\n  }\n\n  ascend(visitor: (node: PDFPageTree) =\u003e any): void {\n    visitor(this);\n    const Parent = this.Parent();\n    if (Parent) Parent.ascend(visitor);\n  }\n\n  /** Performs a Post-Order traversal of this page tree */\n  traverse(visitor: (node: TreeNode, ref: PDFRef) =\u003e any): void {\n    const Kids = this.Kids();\n    for (let idx = 0, len = Kids.size(); idx \u003c len; idx++) {\n      const kidRef = Kids.get(idx) as PDFRef;\n      const kid = this.context.lookup(kidRef) as TreeNode;\n      if (kid instanceof PDFPageTree) kid.traverse(visitor);\n      visitor(kid, kidRef);\n    }\n  }\n\n  private insertLeafKid(kidIdx: number, leafRef: PDFRef): void {\n    const Kids = this.Kids();\n\n    this.ascend((node) =\u003e {\n      const newCount = node.Count().asNumber() + 1;\n      node.set(PDFName.of('Count'), PDFNumber.of(newCount));\n    });\n\n    Kids.insert(kidIdx, leafRef);\n  }\n\n  private removeKid(kidIdx: number): void {\n    const Kids = this.Kids();\n\n    const kid = Kids.lookup(kidIdx);\n    if (kid instanceof PDFPageLeaf) {\n      this.ascend((node) =\u003e {\n        const newCount = node.Count().asNumber() - 1;\n        node.set(PDFName.of('Count'), PDFNumber.of(newCount));\n      });\n    }\n\n    Kids.remove(kidIdx);\n  }\n}\n\nexport default PDFPageTree;\n","import CharCodes from 'src/core/syntax/CharCodes';\n\nexport const IsDigit = new Uint8Array(256);\n\nIsDigit[CharCodes.Zero] = 1;\nIsDigit[CharCodes.One] = 1;\nIsDigit[CharCodes.Two] = 1;\nIsDigit[CharCodes.Three] = 1;\nIsDigit[CharCodes.Four] = 1;\nIsDigit[CharCodes.Five] = 1;\nIsDigit[CharCodes.Six] = 1;\nIsDigit[CharCodes.Seven] = 1;\nIsDigit[CharCodes.Eight] = 1;\nIsDigit[CharCodes.Nine] = 1;\n\nexport const IsNumericPrefix = new Uint8Array(256);\n\nIsNumericPrefix[CharCodes.Period] = 1;\nIsNumericPrefix[CharCodes.Plus] = 1;\nIsNumericPrefix[CharCodes.Minus] = 1;\n\nexport const IsNumeric = new Uint8Array(256);\n\nfor (let idx = 0, len = 256; idx \u003c len; idx++) {\n  IsNumeric[idx] = IsDigit[idx] || IsNumericPrefix[idx] ? 1 : 0;\n}\n","import { NumberParsingError } from 'src/core/errors';\nimport ByteStream from 'src/core/parser/ByteStream';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { IsDigit, IsNumeric } from 'src/core/syntax/Numeric';\nimport { IsWhitespace } from 'src/core/syntax/Whitespace';\nimport { charFromCode } from 'src/utils';\n\nconst { Newline, CarriageReturn } = CharCodes;\n\n// TODO: Throw error if eof is reached before finishing object parse...\nclass BaseParser {\n  protected readonly bytes: ByteStream;\n  protected readonly capNumbers: boolean;\n\n  constructor(bytes: ByteStream, capNumbers = false) {\n    this.bytes = bytes;\n    this.capNumbers = capNumbers;\n  }\n\n  protected parseRawInt(): number {\n    let value = '';\n\n    while (!this.bytes.done()) {\n      const byte = this.bytes.peek();\n      if (!IsDigit[byte]) break;\n      value += charFromCode(this.bytes.next());\n    }\n\n    const numberValue = Number(value);\n\n    if (!value || !isFinite(numberValue)) {\n      throw new NumberParsingError(this.bytes.position(), value);\n    }\n\n    return numberValue;\n  }\n\n  // TODO: Maybe handle exponential format?\n  // TODO: Compare performance of string concatenation to charFromCode(...bytes)\n  protected parseRawNumber(): number {\n    let value = '';\n\n    // Parse integer-part, the leading (+ | - | . | 0-9)\n    while (!this.bytes.done()) {\n      const byte = this.bytes.peek();\n      if (!IsNumeric[byte]) break;\n      value += charFromCode(this.bytes.next());\n      if (byte === CharCodes.Period) break;\n    }\n\n    // Parse decimal-part, the trailing (0-9)\n    while (!this.bytes.done()) {\n      const byte = this.bytes.peek();\n      if (!IsDigit[byte]) break;\n      value += charFromCode(this.bytes.next());\n    }\n\n    const numberValue = Number(value);\n\n    if (!value || !isFinite(numberValue)) {\n      throw new NumberParsingError(this.bytes.position(), value);\n    }\n\n    if (numberValue \u003e Number.MAX_SAFE_INTEGER) {\n      if (this.capNumbers) {\n        const msg = `Parsed number that is too large for some PDF readers: ${value}, using Number.MAX_SAFE_INTEGER instead.`;\n        console.warn(msg);\n        return Number.MAX_SAFE_INTEGER;\n      } else {\n        const msg = `Parsed number that is too large for some PDF readers: ${value}, not capping.`;\n        console.warn(msg);\n      }\n    }\n\n    return numberValue;\n  }\n\n  protected skipWhitespace(): void {\n    while (!this.bytes.done() \u0026\u0026 IsWhitespace[this.bytes.peek()]) {\n      this.bytes.next();\n    }\n  }\n\n  protected skipLine(): void {\n    while (!this.bytes.done()) {\n      const byte = this.bytes.peek();\n      if (byte === Newline || byte === CarriageReturn) return;\n      this.bytes.next();\n    }\n  }\n\n  protected skipComment(): boolean {\n    if (this.bytes.peek() !== CharCodes.Percent) return false;\n    while (!this.bytes.done()) {\n      const byte = this.bytes.peek();\n      if (byte === Newline || byte === CarriageReturn) return true;\n      this.bytes.next();\n    }\n    return true;\n  }\n\n  protected skipWhitespaceAndComments(): void {\n    this.skipWhitespace();\n    while (this.skipComment()) this.skipWhitespace();\n  }\n\n  protected matchKeyword(keyword: number[]): boolean {\n    const initialOffset = this.bytes.offset();\n    for (let idx = 0, len = keyword.length; idx \u003c len; idx++) {\n      if (this.bytes.done() || this.bytes.next() !== keyword[idx]) {\n        this.bytes.moveTo(initialOffset);\n        return false;\n      }\n    }\n    return true;\n  }\n}\n\nexport default BaseParser;\n","import { NextByteAssertionError } from 'src/core/errors';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport { decodePDFRawStream } from 'src/core/streams/decode';\nimport CharCodes from 'src/core/syntax/CharCodes';\n\n// TODO: See how line/col tracking affects performance\nclass ByteStream {\n  static of = (bytes: Uint8Array) =\u003e new ByteStream(bytes);\n\n  static fromPDFRawStream = (rawStream: PDFRawStream) =\u003e\n    ByteStream.of(decodePDFRawStream(rawStream).decode());\n\n  private readonly bytes: Uint8Array;\n  private readonly length: number;\n\n  private idx = 0;\n  private line = 0;\n  private column = 0;\n\n  constructor(bytes: Uint8Array) {\n    this.bytes = bytes;\n    this.length = this.bytes.length;\n  }\n\n  moveTo(offset: number): void {\n    this.idx = offset;\n  }\n\n  next(): number {\n    const byte = this.bytes[this.idx++];\n    if (byte === CharCodes.Newline) {\n      this.line += 1;\n      this.column = 0;\n    } else {\n      this.column += 1;\n    }\n    return byte;\n  }\n\n  assertNext(expected: number): number {\n    if (this.peek() !== expected) {\n      throw new NextByteAssertionError(this.position(), expected, this.peek());\n    }\n    return this.next();\n  }\n\n  peek(): number {\n    return this.bytes[this.idx];\n  }\n\n  peekAhead(steps: number) {\n    return this.bytes[this.idx + steps];\n  }\n\n  peekAt(offset: number) {\n    return this.bytes[offset];\n  }\n\n  done(): boolean {\n    return this.idx \u003e= this.length;\n  }\n\n  offset(): number {\n    return this.idx;\n  }\n\n  slice(start: number, end: number): Uint8Array {\n    return this.bytes.slice(start, end);\n  }\n\n  position(): { line: number; column: number; offset: number } {\n    return { line: this.line, column: this.column, offset: this.idx };\n  }\n}\n\nexport default ByteStream;\n","import CharCodes from 'src/core/syntax/CharCodes';\n\nconst { Space, CarriageReturn, Newline } = CharCodes;\n\nconst stream = [\n  CharCodes.s,\n  CharCodes.t,\n  CharCodes.r,\n  CharCodes.e,\n  CharCodes.a,\n  CharCodes.m,\n];\n\nconst endstream = [\n  CharCodes.e,\n  CharCodes.n,\n  CharCodes.d,\n  CharCodes.s,\n  CharCodes.t,\n  CharCodes.r,\n  CharCodes.e,\n  CharCodes.a,\n  CharCodes.m,\n];\n\nexport const Keywords = {\n  header: [\n    CharCodes.Percent,\n    CharCodes.P,\n    CharCodes.D,\n    CharCodes.F,\n    CharCodes.Dash,\n  ],\n  eof: [\n    CharCodes.Percent,\n    CharCodes.Percent,\n    CharCodes.E,\n    CharCodes.O,\n    CharCodes.F,\n  ],\n  obj: [CharCodes.o, CharCodes.b, CharCodes.j],\n  endobj: [\n    CharCodes.e,\n    CharCodes.n,\n    CharCodes.d,\n    CharCodes.o,\n    CharCodes.b,\n    CharCodes.j,\n  ],\n  xref: [CharCodes.x, CharCodes.r, CharCodes.e, CharCodes.f],\n  trailer: [\n    CharCodes.t,\n    CharCodes.r,\n    CharCodes.a,\n    CharCodes.i,\n    CharCodes.l,\n    CharCodes.e,\n    CharCodes.r,\n  ],\n  startxref: [\n    CharCodes.s,\n    CharCodes.t,\n    CharCodes.a,\n    CharCodes.r,\n    CharCodes.t,\n    CharCodes.x,\n    CharCodes.r,\n    CharCodes.e,\n    CharCodes.f,\n  ],\n  true: [CharCodes.t, CharCodes.r, CharCodes.u, CharCodes.e],\n  false: [CharCodes.f, CharCodes.a, CharCodes.l, CharCodes.s, CharCodes.e],\n  null: [CharCodes.n, CharCodes.u, CharCodes.l, CharCodes.l],\n  stream,\n  streamEOF1: [...stream, Space, CarriageReturn, Newline],\n  streamEOF2: [...stream, CarriageReturn, Newline],\n  streamEOF3: [...stream, CarriageReturn],\n  streamEOF4: [...stream, Newline],\n  endstream,\n  EOF1endstream: [CarriageReturn, Newline, ...endstream],\n  EOF2endstream: [CarriageReturn, ...endstream],\n  EOF3endstream: [Newline, ...endstream],\n};\n","import {\n  PDFObjectParsingError,\n  PDFStreamParsingError,\n  Position,\n  UnbalancedParenthesisError,\n} from 'src/core/errors';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFBool from 'src/core/objects/PDFBool';\nimport PDFDict, { DictMap } from 'src/core/objects/PDFDict';\nimport PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNull from 'src/core/objects/PDFNull';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport PDFStream from 'src/core/objects/PDFStream';\nimport PDFString from 'src/core/objects/PDFString';\nimport BaseParser from 'src/core/parser/BaseParser';\nimport ByteStream from 'src/core/parser/ByteStream';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFCatalog from 'src/core/structures/PDFCatalog';\nimport PDFPageLeaf from 'src/core/structures/PDFPageLeaf';\nimport PDFPageTree from 'src/core/structures/PDFPageTree';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { IsDelimiter } from 'src/core/syntax/Delimiters';\nimport { Keywords } from 'src/core/syntax/Keywords';\nimport { IsDigit, IsNumeric } from 'src/core/syntax/Numeric';\nimport { IsWhitespace } from 'src/core/syntax/Whitespace';\nimport { charFromCode } from 'src/utils';\n\n// TODO: Throw error if eof is reached before finishing object parse...\nclass PDFObjectParser extends BaseParser {\n  static forBytes = (\n    bytes: Uint8Array,\n    context: PDFContext,\n    capNumbers?: boolean,\n  ) =\u003e new PDFObjectParser(ByteStream.of(bytes), context, capNumbers);\n\n  static forByteStream = (\n    byteStream: ByteStream,\n    context: PDFContext,\n    capNumbers = false,\n  ) =\u003e new PDFObjectParser(byteStream, context, capNumbers);\n\n  protected readonly context: PDFContext;\n\n  constructor(byteStream: ByteStream, context: PDFContext, capNumbers = false) {\n    super(byteStream, capNumbers);\n    this.context = context;\n  }\n\n  // TODO: Is it possible to reduce duplicate parsing for ref lookaheads?\n  parseObject(): PDFObject {\n    this.skipWhitespaceAndComments();\n\n    if (this.matchKeyword(Keywords.true)) return PDFBool.True;\n    if (this.matchKeyword(Keywords.false)) return PDFBool.False;\n    if (this.matchKeyword(Keywords.null)) return PDFNull;\n\n    const byte = this.bytes.peek();\n\n    if (\n      byte === CharCodes.LessThan \u0026\u0026\n      this.bytes.peekAhead(1) === CharCodes.LessThan\n    ) {\n      return this.parseDictOrStream();\n    }\n    if (byte === CharCodes.LessThan) return this.parseHexString();\n    if (byte === CharCodes.LeftParen) return this.parseString();\n    if (byte === CharCodes.ForwardSlash) return this.parseName();\n    if (byte === CharCodes.LeftSquareBracket) return this.parseArray();\n    if (IsNumeric[byte]) return this.parseNumberOrRef();\n\n    throw new PDFObjectParsingError(this.bytes.position(), byte);\n  }\n\n  protected parseNumberOrRef(): PDFNumber | PDFRef {\n    const firstNum = this.parseRawNumber();\n    this.skipWhitespaceAndComments();\n\n    const lookaheadStart = this.bytes.offset();\n    if (IsDigit[this.bytes.peek()]) {\n      const secondNum = this.parseRawNumber();\n      this.skipWhitespaceAndComments();\n      if (this.bytes.peek() === CharCodes.R) {\n        this.bytes.assertNext(CharCodes.R);\n        return PDFRef.of(firstNum, secondNum);\n      }\n    }\n\n    this.bytes.moveTo(lookaheadStart);\n    return PDFNumber.of(firstNum);\n  }\n\n  // TODO: Maybe update PDFHexString.of() logic to remove whitespace and validate input?\n  protected parseHexString(): PDFHexString {\n    let value = '';\n\n    this.bytes.assertNext(CharCodes.LessThan);\n    while (!this.bytes.done() \u0026\u0026 this.bytes.peek() !== CharCodes.GreaterThan) {\n      value += charFromCode(this.bytes.next());\n    }\n    this.bytes.assertNext(CharCodes.GreaterThan);\n\n    return PDFHexString.of(value);\n  }\n\n  protected parseString(): PDFString {\n    let nestingLvl = 0;\n    let isEscaped = false;\n    let value = '';\n\n    while (!this.bytes.done()) {\n      const byte = this.bytes.next();\n      value += charFromCode(byte);\n\n      // Check for unescaped parenthesis\n      if (!isEscaped) {\n        if (byte === CharCodes.LeftParen) nestingLvl += 1;\n        if (byte === CharCodes.RightParen) nestingLvl -= 1;\n      }\n\n      // Track whether current character is being escaped or not\n      if (byte === CharCodes.BackSlash) {\n        isEscaped = !isEscaped;\n      } else if (isEscaped) {\n        isEscaped = false;\n      }\n\n      // Once (if) the unescaped parenthesis balance out, return their contents\n      if (nestingLvl === 0) {\n        // Remove the outer parens so they aren't part of the contents\n        return PDFString.of(value.substring(1, value.length - 1));\n      }\n    }\n\n    throw new UnbalancedParenthesisError(this.bytes.position());\n  }\n\n  // TODO: Compare performance of string concatenation to charFromCode(...bytes)\n  // TODO: Maybe preallocate small Uint8Array if can use charFromCode?\n  protected parseName(): PDFName {\n    this.bytes.assertNext(CharCodes.ForwardSlash);\n\n    let name = '';\n    while (!this.bytes.done()) {\n      const byte = this.bytes.peek();\n      if (IsWhitespace[byte] || IsDelimiter[byte]) break;\n      name += charFromCode(byte);\n      this.bytes.next();\n    }\n\n    return PDFName.of(name);\n  }\n\n  protected parseArray(): PDFArray {\n    this.bytes.assertNext(CharCodes.LeftSquareBracket);\n    this.skipWhitespaceAndComments();\n\n    const pdfArray = PDFArray.withContext(this.context);\n    while (this.bytes.peek() !== CharCodes.RightSquareBracket) {\n      const element = this.parseObject();\n      pdfArray.push(element);\n      this.skipWhitespaceAndComments();\n    }\n    this.bytes.assertNext(CharCodes.RightSquareBracket);\n    return pdfArray;\n  }\n\n  protected parseDict(): PDFDict {\n    this.bytes.assertNext(CharCodes.LessThan);\n    this.bytes.assertNext(CharCodes.LessThan);\n    this.skipWhitespaceAndComments();\n\n    const dict: DictMap = new Map();\n\n    while (\n      !this.bytes.done() \u0026\u0026\n      this.bytes.peek() !== CharCodes.GreaterThan \u0026\u0026\n      this.bytes.peekAhead(1) !== CharCodes.GreaterThan\n    ) {\n      const key = this.parseName();\n      const value = this.parseObject();\n      dict.set(key, value);\n      this.skipWhitespaceAndComments();\n    }\n\n    this.skipWhitespaceAndComments();\n    this.bytes.assertNext(CharCodes.GreaterThan);\n    this.bytes.assertNext(CharCodes.GreaterThan);\n\n    const Type = dict.get(PDFName.of('Type'));\n\n    if (Type === PDFName.of('Catalog')) {\n      return PDFCatalog.fromMapWithContext(dict, this.context);\n    } else if (Type === PDFName.of('Pages')) {\n      return PDFPageTree.fromMapWithContext(dict, this.context);\n    } else if (Type === PDFName.of('Page')) {\n      return PDFPageLeaf.fromMapWithContext(dict, this.context);\n    } else {\n      return PDFDict.fromMapWithContext(dict, this.context);\n    }\n  }\n\n  protected parseDictOrStream(): PDFDict | PDFStream {\n    const startPos = this.bytes.position();\n\n    const dict = this.parseDict();\n\n    this.skipWhitespaceAndComments();\n\n    if (\n      !this.matchKeyword(Keywords.streamEOF1) \u0026\u0026\n      !this.matchKeyword(Keywords.streamEOF2) \u0026\u0026\n      !this.matchKeyword(Keywords.streamEOF3) \u0026\u0026\n      !this.matchKeyword(Keywords.streamEOF4) \u0026\u0026\n      !this.matchKeyword(Keywords.stream)\n    ) {\n      return dict;\n    }\n\n    const start = this.bytes.offset();\n    let end: number;\n\n    const Length = dict.get(PDFName.of('Length'));\n    if (Length instanceof PDFNumber) {\n      end = start + Length.asNumber();\n      this.bytes.moveTo(end);\n      this.skipWhitespaceAndComments();\n      if (!this.matchKeyword(Keywords.endstream)) {\n        this.bytes.moveTo(start);\n        end = this.findEndOfStreamFallback(startPos);\n      }\n    } else {\n      end = this.findEndOfStreamFallback(startPos);\n    }\n\n    const contents = this.bytes.slice(start, end);\n\n    return PDFRawStream.of(dict, contents);\n  }\n\n  protected findEndOfStreamFallback(startPos: Position) {\n    // Move to end of stream, while handling nested streams\n    let nestingLvl = 1;\n    let end = this.bytes.offset();\n\n    while (!this.bytes.done()) {\n      end = this.bytes.offset();\n\n      if (this.matchKeyword(Keywords.stream)) {\n        nestingLvl += 1;\n      } else if (\n        this.matchKeyword(Keywords.EOF1endstream) ||\n        this.matchKeyword(Keywords.EOF2endstream) ||\n        this.matchKeyword(Keywords.EOF3endstream) ||\n        this.matchKeyword(Keywords.endstream)\n      ) {\n        nestingLvl -= 1;\n      } else {\n        this.bytes.next();\n      }\n\n      if (nestingLvl === 0) break;\n    }\n\n    if (nestingLvl !== 0) throw new PDFStreamParsingError(startPos);\n\n    return end;\n  }\n}\n\nexport default PDFObjectParser;\n","import { ReparseError } from 'src/core/errors';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport ByteStream from 'src/core/parser/ByteStream';\nimport PDFObjectParser from 'src/core/parser/PDFObjectParser';\nimport { waitForTick } from 'src/utils';\n\nclass PDFObjectStreamParser extends PDFObjectParser {\n  static forStream = (\n    rawStream: PDFRawStream,\n    shouldWaitForTick?: () =\u003e boolean,\n  ) =\u003e new PDFObjectStreamParser(rawStream, shouldWaitForTick);\n\n  private alreadyParsed: boolean;\n  private readonly shouldWaitForTick: () =\u003e boolean;\n  private readonly firstOffset: number;\n  private readonly objectCount: number;\n\n  constructor(rawStream: PDFRawStream, shouldWaitForTick?: () =\u003e boolean) {\n    super(ByteStream.fromPDFRawStream(rawStream), rawStream.dict.context);\n\n    const { dict } = rawStream;\n\n    this.alreadyParsed = false;\n    this.shouldWaitForTick = shouldWaitForTick || (() =\u003e false);\n    this.firstOffset = dict.lookup(PDFName.of('First'), PDFNumber).asNumber();\n    this.objectCount = dict.lookup(PDFName.of('N'), PDFNumber).asNumber();\n  }\n\n  async parseIntoContext(): Promise\u003cvoid\u003e {\n    if (this.alreadyParsed) {\n      throw new ReparseError('PDFObjectStreamParser', 'parseIntoContext');\n    }\n    this.alreadyParsed = true;\n\n    const offsetsAndObjectNumbers = this.parseOffsetsAndObjectNumbers();\n    for (let idx = 0, len = offsetsAndObjectNumbers.length; idx \u003c len; idx++) {\n      const { objectNumber, offset } = offsetsAndObjectNumbers[idx];\n      this.bytes.moveTo(this.firstOffset + offset);\n      const object = this.parseObject();\n      const ref = PDFRef.of(objectNumber, 0);\n      this.context.assign(ref, object);\n      if (this.shouldWaitForTick()) await waitForTick();\n    }\n  }\n\n  private parseOffsetsAndObjectNumbers(): {\n    objectNumber: number;\n    offset: number;\n  }[] {\n    const offsetsAndObjectNumbers = [];\n    for (let idx = 0, len = this.objectCount; idx \u003c len; idx++) {\n      this.skipWhitespaceAndComments();\n      const objectNumber = this.parseRawInt();\n\n      this.skipWhitespaceAndComments();\n      const offset = this.parseRawInt();\n\n      offsetsAndObjectNumbers.push({ objectNumber, offset });\n    }\n    return offsetsAndObjectNumbers;\n  }\n}\n\nexport default PDFObjectStreamParser;\n","import { ReparseError } from 'src/core/errors';\nimport PDFArray from 'src/core/objects/PDFArray';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFNumber from 'src/core/objects/PDFNumber';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport ByteStream from 'src/core/parser/ByteStream';\nimport PDFContext from 'src/core/PDFContext';\n\nexport interface Entry {\n  ref: PDFRef;\n  offset: number;\n  deleted: boolean;\n  inObjectStream: boolean;\n}\n\nclass PDFXRefStreamParser {\n  static forStream = (rawStream: PDFRawStream) =\u003e\n    new PDFXRefStreamParser(rawStream);\n\n  private alreadyParsed: boolean;\n\n  private readonly dict: PDFDict;\n  private readonly context: PDFContext;\n  private readonly bytes: ByteStream;\n  private readonly subsections: {\n    firstObjectNumber: number;\n    length: number;\n  }[];\n  private readonly byteWidths: [number, number, number];\n\n  constructor(rawStream: PDFRawStream) {\n    this.alreadyParsed = false;\n\n    this.dict = rawStream.dict;\n    this.bytes = ByteStream.fromPDFRawStream(rawStream);\n    this.context = this.dict.context;\n\n    const Size = this.dict.lookup(PDFName.of('Size'), PDFNumber);\n\n    const Index = this.dict.lookup(PDFName.of('Index'));\n    if (Index instanceof PDFArray) {\n      this.subsections = [];\n      for (let idx = 0, len = Index.size(); idx \u003c len; idx += 2) {\n        const firstObjectNumber = Index.lookup(idx + 0, PDFNumber).asNumber();\n        const length = Index.lookup(idx + 1, PDFNumber).asNumber();\n        this.subsections.push({ firstObjectNumber, length });\n      }\n    } else {\n      this.subsections = [{ firstObjectNumber: 0, length: Size.asNumber() }];\n    }\n\n    const W = this.dict.lookup(PDFName.of('W'), PDFArray);\n    this.byteWidths = [-1, -1, -1];\n    for (let idx = 0, len = W.size(); idx \u003c len; idx++) {\n      this.byteWidths[idx] = W.lookup(idx, PDFNumber).asNumber();\n    }\n  }\n\n  parseIntoContext(): Entry[] {\n    if (this.alreadyParsed) {\n      throw new ReparseError('PDFXRefStreamParser', 'parseIntoContext');\n    }\n    this.alreadyParsed = true;\n\n    this.context.trailerInfo = {\n      Root: this.dict.get(PDFName.of('Root')),\n      Encrypt: this.dict.get(PDFName.of('Encrypt')),\n      Info: this.dict.get(PDFName.of('Info')),\n      ID: this.dict.get(PDFName.of('ID')),\n    };\n\n    const entries = this.parseEntries();\n\n    // for (let idx = 0, len = entries.length; idx \u003c len; idx++) {\n    // const entry = entries[idx];\n    // if (entry.deleted) this.context.delete(entry.ref);\n    // }\n\n    return entries;\n  }\n\n  private parseEntries(): Entry[] {\n    const entries = [];\n    const [typeFieldWidth, offsetFieldWidth, genFieldWidth] = this.byteWidths;\n\n    for (\n      let subsectionIdx = 0, subsectionLen = this.subsections.length;\n      subsectionIdx \u003c subsectionLen;\n      subsectionIdx++\n    ) {\n      const { firstObjectNumber, length } = this.subsections[subsectionIdx];\n\n      for (let objIdx = 0; objIdx \u003c length; objIdx++) {\n        let type = 0;\n        for (let idx = 0, len = typeFieldWidth; idx \u003c len; idx++) {\n          type = (type \u003c\u003c 8) | this.bytes.next();\n        }\n\n        let offset = 0;\n        for (let idx = 0, len = offsetFieldWidth; idx \u003c len; idx++) {\n          offset = (offset \u003c\u003c 8) | this.bytes.next();\n        }\n\n        let generationNumber = 0;\n        for (let idx = 0, len = genFieldWidth; idx \u003c len; idx++) {\n          generationNumber = (generationNumber \u003c\u003c 8) | this.bytes.next();\n        }\n\n        // When the `type` field is absent, it defaults to 1\n        if (typeFieldWidth === 0) type = 1;\n\n        const objectNumber = firstObjectNumber + objIdx;\n        const entry = {\n          ref: PDFRef.of(objectNumber, generationNumber),\n          offset,\n          deleted: type === 0,\n          inObjectStream: type === 2,\n        };\n\n        entries.push(entry);\n      }\n    }\n\n    return entries;\n  }\n}\n\nexport default PDFXRefStreamParser;\n","import PDFCrossRefSection from 'src/core/document/PDFCrossRefSection';\nimport PDFHeader from 'src/core/document/PDFHeader';\nimport PDFTrailer from 'src/core/document/PDFTrailer';\nimport {\n  MissingKeywordError,\n  MissingPDFHeaderError,\n  PDFInvalidObjectParsingError,\n  ReparseError,\n  StalledParserError,\n} from 'src/core/errors';\nimport PDFDict from 'src/core/objects/PDFDict';\nimport PDFInvalidObject from 'src/core/objects/PDFInvalidObject';\nimport PDFName from 'src/core/objects/PDFName';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRawStream from 'src/core/objects/PDFRawStream';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport ByteStream from 'src/core/parser/ByteStream';\nimport PDFObjectParser from 'src/core/parser/PDFObjectParser';\nimport PDFObjectStreamParser from 'src/core/parser/PDFObjectStreamParser';\nimport PDFXRefStreamParser from 'src/core/parser/PDFXRefStreamParser';\nimport PDFContext from 'src/core/PDFContext';\nimport CharCodes from 'src/core/syntax/CharCodes';\nimport { Keywords } from 'src/core/syntax/Keywords';\nimport { IsDigit } from 'src/core/syntax/Numeric';\nimport { waitForTick } from 'src/utils';\n\nclass PDFParser extends PDFObjectParser {\n  static forBytesWithOptions = (\n    pdfBytes: Uint8Array,\n    objectsPerTick?: number,\n    throwOnInvalidObject?: boolean,\n    capNumbers?: boolean,\n  ) =\u003e\n    new PDFParser(pdfBytes, objectsPerTick, throwOnInvalidObject, capNumbers);\n\n  private readonly objectsPerTick: number;\n  private readonly throwOnInvalidObject: boolean;\n  private alreadyParsed = false;\n  private parsedObjects = 0;\n\n  constructor(\n    pdfBytes: Uint8Array,\n    objectsPerTick = Infinity,\n    throwOnInvalidObject = false,\n    capNumbers = false,\n  ) {\n    super(ByteStream.of(pdfBytes), PDFContext.create(), capNumbers);\n    this.objectsPerTick = objectsPerTick;\n    this.throwOnInvalidObject = throwOnInvalidObject;\n  }\n\n  async parseDocument(): Promise\u003cPDFContext\u003e {\n    if (this.alreadyParsed) {\n      throw new ReparseError('PDFParser', 'parseDocument');\n    }\n    this.alreadyParsed = true;\n\n    this.context.header = this.parseHeader();\n\n    let prevOffset;\n    while (!this.bytes.done()) {\n      await this.parseDocumentSection();\n      const offset = this.bytes.offset();\n      if (offset === prevOffset) {\n        throw new StalledParserError(this.bytes.position());\n      }\n      prevOffset = offset;\n    }\n\n    this.maybeRecoverRoot();\n\n    if (this.context.lookup(PDFRef.of(0))) {\n      console.warn('Removing parsed object: 0 0 R');\n      this.context.delete(PDFRef.of(0));\n    }\n\n    return this.context;\n  }\n\n  private maybeRecoverRoot(): void {\n    const isValidCatalog = (obj?: PDFObject) =\u003e\n      obj instanceof PDFDict \u0026\u0026\n      obj.lookup(PDFName.of('Type')) === PDFName.of('Catalog');\n\n    const catalog = this.context.lookup(this.context.trailerInfo.Root);\n\n    if (!isValidCatalog(catalog)) {\n      const indirectObjects = this.context.enumerateIndirectObjects();\n      for (let idx = 0, len = indirectObjects.length; idx \u003c len; idx++) {\n        const [ref, object] = indirectObjects[idx];\n        if (isValidCatalog(object)) {\n          this.context.trailerInfo.Root = ref;\n        }\n      }\n    }\n  }\n\n  private parseHeader(): PDFHeader {\n    while (!this.bytes.done()) {\n      if (this.matchKeyword(Keywords.header)) {\n        const major = this.parseRawInt();\n        this.bytes.assertNext(CharCodes.Period);\n        const minor = this.parseRawInt();\n        const header = PDFHeader.forVersion(major, minor);\n        this.skipBinaryHeaderComment();\n        return header;\n      }\n      this.bytes.next();\n    }\n\n    throw new MissingPDFHeaderError(this.bytes.position());\n  }\n\n  private parseIndirectObjectHeader(): PDFRef {\n    this.skipWhitespaceAndComments();\n    const objectNumber = this.parseRawInt();\n\n    this.skipWhitespaceAndComments();\n    const generationNumber = this.parseRawInt();\n\n    this.skipWhitespaceAndComments();\n    if (!this.matchKeyword(Keywords.obj)) {\n      throw new MissingKeywordError(this.bytes.position(), Keywords.obj);\n    }\n\n    return PDFRef.of(objectNumber, generationNumber);\n  }\n\n  private matchIndirectObjectHeader(): boolean {\n    const initialOffset = this.bytes.offset();\n    try {\n      this.parseIndirectObjectHeader();\n      return true;\n    } catch (e) {\n      this.bytes.moveTo(initialOffset);\n      return false;\n    }\n  }\n\n  private shouldWaitForTick = () =\u003e {\n    this.parsedObjects += 1;\n    return this.parsedObjects % this.objectsPerTick === 0;\n  };\n\n  private async parseIndirectObject(): Promise\u003cPDFRef\u003e {\n    const ref = this.parseIndirectObjectHeader();\n\n    this.skipWhitespaceAndComments();\n    const object = this.parseObject();\n\n    this.skipWhitespaceAndComments();\n    // if (!this.matchKeyword(Keywords.endobj)) {\n    // throw new MissingKeywordError(this.bytes.position(), Keywords.endobj);\n    // }\n\n    // TODO: Log a warning if this fails...\n    this.matchKeyword(Keywords.endobj);\n\n    if (\n      object instanceof PDFRawStream \u0026\u0026\n      object.dict.lookup(PDFName.of('Type')) === PDFName.of('ObjStm')\n    ) {\n      await PDFObjectStreamParser.forStream(\n        object,\n        this.shouldWaitForTick,\n      ).parseIntoContext();\n    } else if (\n      object instanceof PDFRawStream \u0026\u0026\n      object.dict.lookup(PDFName.of('Type')) === PDFName.of('XRef')\n    ) {\n      PDFXRefStreamParser.forStream(object).parseIntoContext();\n    } else {\n      this.context.assign(ref, object);\n    }\n\n    return ref;\n  }\n\n  // TODO: Improve and clean this up\n  private tryToParseInvalidIndirectObject() {\n    const startPos = this.bytes.position();\n\n    const msg = `Trying to parse invalid object: ${JSON.stringify(startPos)})`;\n    if (this.throwOnInvalidObject) throw new Error(msg);\n    console.warn(msg);\n\n    const ref = this.parseIndirectObjectHeader();\n\n    console.warn(`Invalid object ref: ${ref}`);\n\n    this.skipWhitespaceAndComments();\n    const start = this.bytes.offset();\n\n    let failed = true;\n    while (!this.bytes.done()) {\n      if (this.matchKeyword(Keywords.endobj)) {\n        failed = false;\n      }\n      if (!failed) break;\n      this.bytes.next();\n    }\n\n    if (failed) throw new PDFInvalidObjectParsingError(startPos);\n\n    const end = this.bytes.offset() - Keywords.endobj.length;\n\n    const object = PDFInvalidObject.of(this.bytes.slice(start, end));\n    this.context.assign(ref, object);\n\n    return ref;\n  }\n\n  private async parseIndirectObjects(): Promise\u003cvoid\u003e {\n    this.skipWhitespaceAndComments();\n\n    while (!this.bytes.done() \u0026\u0026 IsDigit[this.bytes.peek()]) {\n      const initialOffset = this.bytes.offset();\n\n      try {\n        await this.parseIndirectObject();\n      } catch (e) {\n        // TODO: Add tracing/logging mechanism to track when this happens!\n        this.bytes.moveTo(initialOffset);\n        this.tryToParseInvalidIndirectObject();\n      }\n      this.skipWhitespaceAndComments();\n\n      // TODO: Can this be done only when needed, to avoid harming performance?\n      this.skipJibberish();\n\n      if (this.shouldWaitForTick()) await waitForTick();\n    }\n  }\n\n  private maybeParseCrossRefSection(): PDFCrossRefSection | void {\n    this.skipWhitespaceAndComments();\n    if (!this.matchKeyword(Keywords.xref)) return;\n    this.skipWhitespaceAndComments();\n\n    let objectNumber = -1;\n    const xref = PDFCrossRefSection.createEmpty();\n\n    while (!this.bytes.done() \u0026\u0026 IsDigit[this.bytes.peek()]) {\n      const firstInt = this.parseRawInt();\n      this.skipWhitespaceAndComments();\n\n      const secondInt = this.parseRawInt();\n      this.skipWhitespaceAndComments();\n\n      const byte = this.bytes.peek();\n      if (byte === CharCodes.n || byte === CharCodes.f) {\n        const ref = PDFRef.of(objectNumber, secondInt);\n        if (this.bytes.next() === CharCodes.n) {\n          xref.addEntry(ref, firstInt);\n        } else {\n          // this.context.delete(ref);\n          xref.addDeletedEntry(ref, firstInt);\n        }\n        objectNumber += 1;\n      } else {\n        objectNumber = firstInt;\n      }\n      this.skipWhitespaceAndComments();\n    }\n\n    return xref;\n  }\n\n  private maybeParseTrailerDict(): void {\n    this.skipWhitespaceAndComments();\n    if (!this.matchKeyword(Keywords.trailer)) return;\n    this.skipWhitespaceAndComments();\n\n    const dict = this.parseDict();\n\n    const { context } = this;\n    context.trailerInfo = {\n      Root: dict.get(PDFName.of('Root')) || context.trailerInfo.Root,\n      Encrypt: dict.get(PDFName.of('Encrypt')) || context.trailerInfo.Encrypt,\n      Info: dict.get(PDFName.of('Info')) || context.trailerInfo.Info,\n      ID: dict.get(PDFName.of('ID')) || context.trailerInfo.ID,\n    };\n  }\n\n  private maybeParseTrailer(): PDFTrailer | void {\n    this.skipWhitespaceAndComments();\n    if (!this.matchKeyword(Keywords.startxref)) return;\n    this.skipWhitespaceAndComments();\n\n    const offset = this.parseRawInt();\n\n    this.skipWhitespace();\n    this.matchKeyword(Keywords.eof);\n    this.skipWhitespaceAndComments();\n    this.matchKeyword(Keywords.eof);\n    this.skipWhitespaceAndComments();\n\n    return PDFTrailer.forLastCrossRefSectionOffset(offset);\n  }\n\n  private async parseDocumentSection(): Promise\u003cvoid\u003e {\n    await this.parseIndirectObjects();\n    this.maybeParseCrossRefSection();\n    this.maybeParseTrailerDict();\n    this.maybeParseTrailer();\n\n    // TODO: Can this be done only when needed, to avoid harming performance?\n    this.skipJibberish();\n  }\n\n  /**\n   * This operation is not necessary for valid PDF files. But some invalid PDFs\n   * contain jibberish in between indirect objects. This method is designed to\n   * skip past that jibberish, should it exist, until it reaches the next\n   * indirect object header, an xref table section, or the file trailer.\n   */\n  private skipJibberish(): void {\n    this.skipWhitespaceAndComments();\n    while (!this.bytes.done()) {\n      const initialOffset = this.bytes.offset();\n      const byte = this.bytes.peek();\n      const isAlphaNumeric = byte \u003e= CharCodes.Space \u0026\u0026 byte \u003c= CharCodes.Tilde;\n      if (isAlphaNumeric) {\n        if (\n          this.matchKeyword(Keywords.xref) ||\n          this.matchKeyword(Keywords.trailer) ||\n          this.matchKeyword(Keywords.startxref) ||\n          this.matchIndirectObjectHeader()\n        ) {\n          this.bytes.moveTo(initialOffset);\n          break;\n        }\n      }\n      this.bytes.next();\n    }\n  }\n\n  /**\n   * Skips the binary comment following a PDF header. The specification\n   * defines this binary comment (section 7.5.2 File Header) as a sequence of 4\n   * or more bytes that are 128 or greater, and which are preceded by a \"%\".\n   *\n   * This would imply that to strip out this binary comment, we could check for\n   * a sequence of bytes starting with \"%\", and remove all subsequent bytes that\n   * are 128 or greater. This works for many documents that properly comply with\n   * the spec. But in the wild, there are PDFs that omit the leading \"%\", and\n   * include bytes that are less than 128 (e.g. 0 or 1). So in order to parse\n   * these headers correctly, we just throw out all bytes leading up to the\n   * first indirect object header.\n   */\n  private skipBinaryHeaderComment(): void {\n    this.skipWhitespaceAndComments();\n    try {\n      const initialOffset = this.bytes.offset();\n      this.parseIndirectObjectHeader();\n      this.bytes.moveTo(initialOffset);\n    } catch (e) {\n      this.bytes.next();\n      this.skipWhitespaceAndComments();\n    }\n  }\n}\n\nexport default PDFParser;\n","const flag = (bitIndex: number) =\u003e 1 \u003c\u003c bitIndex;\n\n/** From PDF spec table 165 */\nexport enum AnnotationFlags {\n  /**\n   * If set, do not display the annotation if it does not belong to one of the\n   * standard annotation types and no annotation handler is available. If clear,\n   * display such an unknown annotation using an appearance stream specified by\n   * its appearance dictionary, if any.\n   */\n  Invisible = flag(1 - 1),\n\n  /**\n   * If set, do not display or print the annotation or allow it to interact with\n   * the user, regardless of its annotation type or whether an annotation\n   * handler is available.\n   *\n   * In cases where screen space is limited, the ability to hide and show\n   * annotations selectively can be used in combination with appearance streams\n   * to display auxiliary pop-up information similar in function to online help\n   * systems.\n   */\n  Hidden = flag(2 - 1),\n\n  /**\n   * If set, print the annotation when the page is printed. If clear, never\n   * print the annotation, regardless of whether it is displayed on the screen.\n   *\n   * This can be useful for annotations representing interactive pushbuttons,\n   * which would serve no meaningful purpose on the printed page.\n   */\n  Print = flag(3 - 1),\n\n  /**\n   * If set, do not scale the annotation’s appearance to match the magnification\n   * of the page. The location of the annotation on the page (defined by the\n   * upper-left corner of its annotation rectangle) shall remain fixed,\n   * regardless of the page magnification.\n   */\n  NoZoom = flag(4 - 1),\n\n  /**\n   * If set, do not rotate the annotation’s appearance to match the rotation of\n   * the page. The upper-left corner of the annotation rectangle shall remain in\n   * a fixed location on the page, regardless of the page rotation.\n   */\n  NoRotate = flag(5 - 1),\n\n  /**\n   * If set, do not display the annotation on the screen or allow it to interact\n   * with the user. The annotation may be printed (depending on the setting of\n   * the Print flag) but should be considered hidden for purposes of on-screen\n   * display and user interaction.\n   */\n  NoView = flag(6 - 1),\n\n  /**\n   * If set, do not allow the annotation to interact with the user. The\n   * annotation may be displayed or printed (depending on the settings of the\n   * NoView and Print flags) but should not respond to mouse clicks or change\n   * its appearance in response to mouse motions.\n   *\n   * This flag shall be ignored for widget annotations; its function is\n   * subsumed by the ReadOnly flag of the associated form field.\n   */\n  ReadOnly = flag(7 - 1),\n\n  /**\n   * If set, do not allow the annotation to be deleted or its properties\n   * (including position and size) to be modified by the user. However, this\n   * flag does not restrict changes to the annotation’s contents, such as the\n   * value of a form field.\n   */\n  Locked = flag(8 - 1),\n\n  /**\n   * If set, invert the interpretation of the NoView flag for certain events.\n   *\n   * A typical use is to have an annotation that appears only when a mouse\n   * cursor is held over it.\n   */\n  ToggleNoView = flag(9 - 1),\n\n  /**\n   * If set, do not allow the contents of the annotation to be modified by the\n   * user. This flag does not restrict deletion of the annotation or changes to\n   * other annotation properties, such as position and size.\n   */\n  LockedContents = flag(10 - 1),\n}\n","import { PDFName, PDFNumber } from 'src/core';\n\nexport const asPDFName = (name: string | PDFName) =\u003e\n  name instanceof PDFName ? name : PDFName.of(name);\n\nexport const asPDFNumber = (num: number | PDFNumber) =\u003e\n  num instanceof PDFNumber ? num : PDFNumber.of(num);\n\nexport const asNumber = (num: number | PDFNumber) =\u003e\n  num instanceof PDFNumber ? num.asNumber() : num;\n","import { assertIs, error } from 'src/utils';\n\nexport enum RotationTypes {\n  Degrees = 'degrees',\n  Radians = 'radians',\n}\n\nexport interface Radians {\n  type: RotationTypes.Radians;\n  angle: number;\n}\n\nexport interface Degrees {\n  type: RotationTypes.Degrees;\n  angle: number;\n}\n\nexport type Rotation = Radians | Degrees;\n\nexport const radians = (radianAngle: number): Radians =\u003e {\n  assertIs(radianAngle, 'radianAngle', ['number']);\n  return { type: RotationTypes.Radians, angle: radianAngle };\n};\n\nexport const degrees = (degreeAngle: number): Degrees =\u003e {\n  assertIs(degreeAngle, 'degreeAngle', ['number']);\n  return { type: RotationTypes.Degrees, angle: degreeAngle };\n};\n\nconst { Radians, Degrees } = RotationTypes;\n\nexport const degreesToRadians = (degree: number) =\u003e (degree * Math.PI) / 180;\nexport const radiansToDegrees = (radian: number) =\u003e (radian * 180) / Math.PI;\n\n// prettier-ignore\nexport const toRadians = (rotation: Rotation) =\u003e \n    rotation.type === Radians ? rotation.angle\n  : rotation.type === Degrees ? degreesToRadians(rotation.angle)\n  : error(`Invalid rotation: ${JSON.stringify(rotation)}`);\n\n// prettier-ignore\nexport const toDegrees = (rotation: Rotation) =\u003e \n    rotation.type === Radians ? radiansToDegrees(rotation.angle)\n  : rotation.type === Degrees ? rotation.angle\n  : error(`Invalid rotation: ${JSON.stringify(rotation)}`);\n\nexport const reduceRotation = (degreeAngle = 0) =\u003e {\n  const quadrants = (degreeAngle / 90) % 4;\n  if (quadrants === 0) return 0;\n  if (quadrants === 1) return 90;\n  if (quadrants === 2) return 180;\n  if (quadrants === 3) return 270;\n  return 0; // `degreeAngle` is not a multiple of 90\n};\n\nexport const adjustDimsForRotation = (\n  dims: { width: number; height: number },\n  degreeAngle = 0,\n) =\u003e {\n  const rotation = reduceRotation(degreeAngle);\n  return rotation === 90 || rotation === 270\n    ? { width: dims.height, height: dims.width }\n    : { width: dims.width, height: dims.height };\n};\n\nexport const rotateRectangle = (\n  rectangle: {\n    x: number;\n    y: number;\n    width: number;\n    height: number;\n  },\n  borderWidth = 0,\n  degreeAngle = 0,\n) =\u003e {\n  const { x, y, width: w, height: h } = rectangle;\n\n  const r = reduceRotation(degreeAngle);\n  const b = borderWidth / 2;\n\n  // prettier-ignore\n  if (r === 0) return { x: x - b, y: y - b, width: w, height: h };\n  else if (r === 90) return { x: x - h + b, y: y - b, width: h, height: w };\n  else if (r === 180) return { x: x - w + b, y: y - h + b, width: w, height: h };\n  else if (r === 270) return { x: x - b, y: y - w + b, width: h, height: w };\n  else return { x: x - b, y: y - b, width: w, height: h };\n};\n","import { asNumber, asPDFName, asPDFNumber } from 'src/api/objects';\nimport { degreesToRadians } from 'src/api/rotations';\nimport {\n  PDFHexString,\n  PDFName,\n  PDFNumber,\n  PDFOperator,\n  PDFOperatorNames as Ops,\n} from 'src/core';\n\n/* ==================== Clipping Path Operators ==================== */\n\nexport const clip = () =\u003e PDFOperator.of(Ops.ClipNonZero);\nexport const clipEvenOdd = () =\u003e PDFOperator.of(Ops.ClipEvenOdd);\n\n/* ==================== Graphics State Operators ==================== */\n\nconst { cos, sin, tan } = Math;\n\nexport const concatTransformationMatrix = (\n  a: number | PDFNumber,\n  b: number | PDFNumber,\n  c: number | PDFNumber,\n  d: number | PDFNumber,\n  e: number | PDFNumber,\n  f: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.ConcatTransformationMatrix, [\n    asPDFNumber(a),\n    asPDFNumber(b),\n    asPDFNumber(c),\n    asPDFNumber(d),\n    asPDFNumber(e),\n    asPDFNumber(f),\n  ]);\n\nexport const translate = (xPos: number | PDFNumber, yPos: number | PDFNumber) =\u003e\n  concatTransformationMatrix(1, 0, 0, 1, xPos, yPos);\n\nexport const scale = (xPos: number | PDFNumber, yPos: number | PDFNumber) =\u003e\n  concatTransformationMatrix(xPos, 0, 0, yPos, 0, 0);\n\nexport const rotateRadians = (angle: number | PDFNumber) =\u003e\n  concatTransformationMatrix(\n    cos(asNumber(angle)),\n    sin(asNumber(angle)),\n    -sin(asNumber(angle)),\n    cos(asNumber(angle)),\n    0,\n    0,\n  );\n\nexport const rotateDegrees = (angle: number | PDFNumber) =\u003e\n  rotateRadians(degreesToRadians(asNumber(angle)));\n\nexport const skewRadians = (\n  xSkewAngle: number | PDFNumber,\n  ySkewAngle: number | PDFNumber,\n) =\u003e\n  concatTransformationMatrix(\n    1,\n    tan(asNumber(xSkewAngle)),\n    tan(asNumber(ySkewAngle)),\n    1,\n    0,\n    0,\n  );\n\nexport const skewDegrees = (\n  xSkewAngle: number | PDFNumber,\n  ySkewAngle: number | PDFNumber,\n) =\u003e\n  skewRadians(\n    degreesToRadians(asNumber(xSkewAngle)),\n    degreesToRadians(asNumber(ySkewAngle)),\n  );\n\nexport const setDashPattern = (\n  dashArray: (number | PDFNumber)[],\n  dashPhase: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.SetLineDashPattern, [\n    `[${dashArray.map(asPDFNumber).join(' ')}]`,\n    asPDFNumber(dashPhase),\n  ]);\n\nexport const restoreDashPattern = () =\u003e setDashPattern([], 0);\n\nexport enum LineCapStyle {\n  Butt = 0,\n  Round = 1,\n  Projecting = 2,\n}\n\nexport const setLineCap = (style: LineCapStyle) =\u003e\n  PDFOperator.of(Ops.SetLineCapStyle, [asPDFNumber(style)]);\n\nexport enum LineJoinStyle {\n  Miter = 0,\n  Round = 1,\n  Bevel = 2,\n}\n\nexport const setLineJoin = (style: LineJoinStyle) =\u003e\n  PDFOperator.of(Ops.SetLineJoinStyle, [asPDFNumber(style)]);\n\nexport const setGraphicsState = (state: string | PDFName) =\u003e\n  PDFOperator.of(Ops.SetGraphicsStateParams, [asPDFName(state)]);\n\nexport const pushGraphicsState = () =\u003e PDFOperator.of(Ops.PushGraphicsState);\n\nexport const popGraphicsState = () =\u003e PDFOperator.of(Ops.PopGraphicsState);\n\nexport const setLineWidth = (width: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.SetLineWidth, [asPDFNumber(width)]);\n\n/* ==================== Path Construction Operators ==================== */\n\nexport const appendBezierCurve = (\n  x1: number | PDFNumber,\n  y1: number | PDFNumber,\n  x2: number | PDFNumber,\n  y2: number | PDFNumber,\n  x3: number | PDFNumber,\n  y3: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.AppendBezierCurve, [\n    asPDFNumber(x1),\n    asPDFNumber(y1),\n    asPDFNumber(x2),\n    asPDFNumber(y2),\n    asPDFNumber(x3),\n    asPDFNumber(y3),\n  ]);\n\nexport const appendQuadraticCurve = (\n  x1: number | PDFNumber,\n  y1: number | PDFNumber,\n  x2: number | PDFNumber,\n  y2: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.CurveToReplicateInitialPoint, [\n    asPDFNumber(x1),\n    asPDFNumber(y1),\n    asPDFNumber(x2),\n    asPDFNumber(y2),\n  ]);\n\nexport const closePath = () =\u003e PDFOperator.of(Ops.ClosePath);\n\nexport const moveTo = (xPos: number | PDFNumber, yPos: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.MoveTo, [asPDFNumber(xPos), asPDFNumber(yPos)]);\n\nexport const lineTo = (xPos: number | PDFNumber, yPos: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.LineTo, [asPDFNumber(xPos), asPDFNumber(yPos)]);\n\n/**\n * @param xPos x coordinate for the lower left corner of the rectangle\n * @param yPos y coordinate for the lower left corner of the rectangle\n * @param width width of the rectangle\n * @param height height of the rectangle\n */\nexport const rectangle = (\n  xPos: number | PDFNumber,\n  yPos: number | PDFNumber,\n  width: number | PDFNumber,\n  height: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.AppendRectangle, [\n    asPDFNumber(xPos),\n    asPDFNumber(yPos),\n    asPDFNumber(width),\n    asPDFNumber(height),\n  ]);\n\n/**\n * @param xPos x coordinate for the lower left corner of the square\n * @param yPos y coordinate for the lower left corner of the square\n * @param size width and height of the square\n */\nexport const square = (xPos: number, yPos: number, size: number) =\u003e\n  rectangle(xPos, yPos, size, size);\n\n/* ==================== Path Painting Operators ==================== */\n\nexport const stroke = () =\u003e PDFOperator.of(Ops.StrokePath);\n\nexport const fill = () =\u003e PDFOperator.of(Ops.FillNonZero);\n\nexport const fillAndStroke = () =\u003e PDFOperator.of(Ops.FillNonZeroAndStroke);\n\nexport const endPath = () =\u003e PDFOperator.of(Ops.EndPath);\n\n/* ==================== Text Positioning Operators ==================== */\n\nexport const nextLine = () =\u003e PDFOperator.of(Ops.NextLine);\n\nexport const moveText = (x: number | PDFNumber, y: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.MoveText, [asPDFNumber(x), asPDFNumber(y)]);\n\n/* ==================== Text Showing Operators ==================== */\n\nexport const showText = (text: PDFHexString) =\u003e\n  PDFOperator.of(Ops.ShowText, [text]);\n\n/* ==================== Text State Operators ==================== */\n\nexport const beginText = () =\u003e PDFOperator.of(Ops.BeginText);\nexport const endText = () =\u003e PDFOperator.of(Ops.EndText);\n\nexport const setFontAndSize = (\n  name: string | PDFName,\n  size: number | PDFNumber,\n) =\u003e PDFOperator.of(Ops.SetFontAndSize, [asPDFName(name), asPDFNumber(size)]);\n\nexport const setCharacterSpacing = (spacing: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.SetCharacterSpacing, [asPDFNumber(spacing)]);\n\nexport const setWordSpacing = (spacing: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.SetWordSpacing, [asPDFNumber(spacing)]);\n\n/** @param squeeze horizontal character spacing */\nexport const setCharacterSqueeze = (squeeze: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.SetTextHorizontalScaling, [asPDFNumber(squeeze)]);\n\nexport const setLineHeight = (lineHeight: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.SetTextLineHeight, [asPDFNumber(lineHeight)]);\n\nexport const setTextRise = (rise: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.SetTextRise, [asPDFNumber(rise)]);\n\nexport enum TextRenderingMode {\n  Fill = 0,\n  Outline = 1,\n  FillAndOutline = 2,\n  Invisible = 3,\n  FillAndClip = 4,\n  OutlineAndClip = 5,\n  FillAndOutlineAndClip = 6,\n  Clip = 7,\n}\n\nexport const setTextRenderingMode = (mode: TextRenderingMode) =\u003e\n  PDFOperator.of(Ops.SetTextRenderingMode, [asPDFNumber(mode)]);\n\nexport const setTextMatrix = (\n  a: number | PDFNumber,\n  b: number | PDFNumber,\n  c: number | PDFNumber,\n  d: number | PDFNumber,\n  e: number | PDFNumber,\n  f: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.SetTextMatrix, [\n    asPDFNumber(a),\n    asPDFNumber(b),\n    asPDFNumber(c),\n    asPDFNumber(d),\n    asPDFNumber(e),\n    asPDFNumber(f),\n  ]);\n\nexport const rotateAndSkewTextRadiansAndTranslate = (\n  rotationAngle: number | PDFNumber,\n  xSkewAngle: number | PDFNumber,\n  ySkewAngle: number | PDFNumber,\n  x: number | PDFNumber,\n  y: number | PDFNumber,\n) =\u003e\n  setTextMatrix(\n    cos(asNumber(rotationAngle)),\n    sin(asNumber(rotationAngle)) + tan(asNumber(xSkewAngle)),\n    -sin(asNumber(rotationAngle)) + tan(asNumber(ySkewAngle)),\n    cos(asNumber(rotationAngle)),\n    x,\n    y,\n  );\n\nexport const rotateAndSkewTextDegreesAndTranslate = (\n  rotationAngle: number | PDFNumber,\n  xSkewAngle: number | PDFNumber,\n  ySkewAngle: number | PDFNumber,\n  x: number | PDFNumber,\n  y: number | PDFNumber,\n) =\u003e\n  rotateAndSkewTextRadiansAndTranslate(\n    degreesToRadians(asNumber(rotationAngle)),\n    degreesToRadians(asNumber(xSkewAngle)),\n    degreesToRadians(asNumber(ySkewAngle)),\n    x,\n    y,\n  );\n\n/* ==================== XObject Operator ==================== */\n\nexport const drawObject = (name: string | PDFName) =\u003e\n  PDFOperator.of(Ops.DrawObject, [asPDFName(name)]);\n\n/* ==================== Color Operators ==================== */\n\nexport const setFillingGrayscaleColor = (gray: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.NonStrokingColorGray, [asPDFNumber(gray)]);\n\nexport const setStrokingGrayscaleColor = (gray: number | PDFNumber) =\u003e\n  PDFOperator.of(Ops.StrokingColorGray, [asPDFNumber(gray)]);\n\nexport const setFillingRgbColor = (\n  red: number | PDFNumber,\n  green: number | PDFNumber,\n  blue: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.NonStrokingColorRgb, [\n    asPDFNumber(red),\n    asPDFNumber(green),\n    asPDFNumber(blue),\n  ]);\n\nexport const setStrokingRgbColor = (\n  red: number | PDFNumber,\n  green: number | PDFNumber,\n  blue: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.StrokingColorRgb, [\n    asPDFNumber(red),\n    asPDFNumber(green),\n    asPDFNumber(blue),\n  ]);\n\nexport const setFillingCmykColor = (\n  cyan: number | PDFNumber,\n  magenta: number | PDFNumber,\n  yellow: number | PDFNumber,\n  key: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.NonStrokingColorCmyk, [\n    asPDFNumber(cyan),\n    asPDFNumber(magenta),\n    asPDFNumber(yellow),\n    asPDFNumber(key),\n  ]);\n\nexport const setStrokingCmykColor = (\n  cyan: number | PDFNumber,\n  magenta: number | PDFNumber,\n  yellow: number | PDFNumber,\n  key: number | PDFNumber,\n) =\u003e\n  PDFOperator.of(Ops.StrokingColorCmyk, [\n    asPDFNumber(cyan),\n    asPDFNumber(magenta),\n    asPDFNumber(yellow),\n    asPDFNumber(key),\n  ]);\n\n/* ==================== Marked Content Operators ==================== */\n\nexport const beginMarkedContent = (tag: string | PDFName) =\u003e\n  PDFOperator.of(Ops.BeginMarkedContent, [asPDFName(tag)]);\n\nexport const endMarkedContent = () =\u003e PDFOperator.of(Ops.EndMarkedContent);\n","import {\n  setFillingCmykColor,\n  setFillingGrayscaleColor,\n  setFillingRgbColor,\n  setStrokingCmykColor,\n  setStrokingGrayscaleColor,\n  setStrokingRgbColor,\n} from 'src/api/operators';\nimport { assertRange, error } from 'src/utils';\n\nexport enum ColorTypes {\n  Grayscale = 'Grayscale',\n  RGB = 'RGB',\n  CMYK = 'CMYK',\n}\n\nexport interface Grayscale {\n  type: ColorTypes.Grayscale;\n  gray: number;\n}\n\nexport interface RGB {\n  type: ColorTypes.RGB;\n  red: number;\n  green: number;\n  blue: number;\n}\n\nexport interface CMYK {\n  type: ColorTypes.CMYK;\n  cyan: number;\n  magenta: number;\n  yellow: number;\n  key: number;\n}\n\nexport type Color = Grayscale | RGB | CMYK;\n\nexport const grayscale = (gray: number): Grayscale =\u003e {\n  assertRange(gray, 'gray', 0.0, 1.0);\n  return { type: ColorTypes.Grayscale, gray };\n};\n\nexport const rgb = (red: number, green: number, blue: number): RGB =\u003e {\n  assertRange(red, 'red', 0, 1);\n  assertRange(green, 'green', 0, 1);\n  assertRange(blue, 'blue', 0, 1);\n  return { type: ColorTypes.RGB, red, green, blue };\n};\n\nexport const cmyk = (\n  cyan: number,\n  magenta: number,\n  yellow: number,\n  key: number,\n): CMYK =\u003e {\n  assertRange(cyan, 'cyan', 0, 1);\n  assertRange(magenta, 'magenta', 0, 1);\n  assertRange(yellow, 'yellow', 0, 1);\n  assertRange(key, 'key', 0, 1);\n  return { type: ColorTypes.CMYK, cyan, magenta, yellow, key };\n};\n\nconst { Grayscale, RGB, CMYK } = ColorTypes;\n\n// prettier-ignore\nexport const setFillingColor = (color: Color) =\u003e \n    color.type === Grayscale ? setFillingGrayscaleColor(color.gray)\n  : color.type === RGB       ? setFillingRgbColor(color.red, color.green, color.blue)\n  : color.type === CMYK      ? setFillingCmykColor(color.cyan, color.magenta, color.yellow, color.key)\n  : error(`Invalid color: ${JSON.stringify(color)}`);\n\n// prettier-ignore\nexport const setStrokingColor = (color: Color) =\u003e \n    color.type === Grayscale ? setStrokingGrayscaleColor(color.gray)\n  : color.type === RGB       ? setStrokingRgbColor(color.red, color.green, color.blue)\n  : color.type === CMYK      ? setStrokingCmykColor(color.cyan, color.magenta, color.yellow, color.key)\n  : error(`Invalid color: ${JSON.stringify(color)}`);\n\n// prettier-ignore\nexport const componentsToColor = (comps?: number[], scale = 1) =\u003e (\n    comps?.length === 1 ? grayscale(\n      comps[0] * scale,\n    )\n  : comps?.length === 3 ? rgb(\n      comps[0] * scale, \n      comps[1] * scale, \n      comps[2] * scale,\n    )\n  : comps?.length === 4 ? cmyk(\n      comps[0] * scale, \n      comps[1] * scale, \n      comps[2] * scale, \n      comps[3] * scale,\n    )\n  : undefined\n);\n\n// prettier-ignore\nexport const colorToComponents = (color: Color) =\u003e\n    color.type === Grayscale ? [color.gray]\n  : color.type === RGB       ? [color.red, color.green, color.blue]\n  : color.type === CMYK      ? [color.cyan, color.magenta, color.yellow, color.key]\n  : error(`Invalid color: ${JSON.stringify(color)}`);\n","// Originated from pdfkit Copyright (c) 2014 Devon Govett\n// https://github.com/foliojs/pdfkit/blob/1e62e6ffe24b378eb890df507a47610f4c4a7b24/lib/path.js\n// MIT LICENSE\n// Updated for pdf-lib \u0026 TypeScript by Jeremy Messenger\n\nimport {\n  appendBezierCurve,\n  appendQuadraticCurve,\n  closePath,\n  lineTo,\n  moveTo,\n} from 'src/api/operators';\nimport { PDFOperator } from 'src/core';\n\nlet cx: number = 0;\nlet cy: number = 0;\nlet px: number | null = 0;\nlet py: number | null = 0;\nlet sx: number = 0;\nlet sy: number = 0;\n\nconst parameters = new Map\u003cstring, number\u003e([\n  ['A', 7],\n  ['a', 7],\n  ['C', 6],\n  ['c', 6],\n  ['H', 1],\n  ['h', 1],\n  ['L', 2],\n  ['l', 2],\n  ['M', 2],\n  ['m', 2],\n  ['Q', 4],\n  ['q', 4],\n  ['S', 4],\n  ['s', 4],\n  ['T', 2],\n  ['t', 2],\n  ['V', 1],\n  ['v', 1],\n  ['Z', 0],\n  ['z', 0],\n]);\n\ninterface Cmd {\n  cmd?: string;\n  args: number[];\n}\n\nconst parse = (path: string) =\u003e {\n  let cmd;\n  const ret: Cmd[] = [];\n  let args: number[] = [];\n  let curArg = '';\n  let foundDecimal = false;\n  let params = 0;\n\n  for (const c of path) {\n    if (parameters.has(c)) {\n      params = parameters.get(c)!;\n      if (cmd) {\n        // save existing command\n        if (curArg.length \u003e 0) {\n          args[args.length] = +curArg;\n        }\n        ret[ret.length] = { cmd, args };\n\n        args = [];\n        curArg = '';\n        foundDecimal = false;\n      }\n\n      cmd = c;\n    } else if (\n      [' ', ','].includes(c) ||\n      (c === '-' \u0026\u0026 curArg.length \u003e 0 \u0026\u0026 curArg[curArg.length - 1] !== 'e') ||\n      (c === '.' \u0026\u0026 foundDecimal)\n    ) {\n      if (curArg.length === 0) {\n        continue;\n      }\n\n      if (args.length === params) {\n        // handle reused commands\n        ret[ret.length] = { cmd, args };\n        args = [+curArg];\n\n        // handle assumed commands\n        if (cmd === 'M') {\n          cmd = 'L';\n        }\n        if (cmd === 'm') {\n          cmd = 'l';\n        }\n      } else {\n        args[args.length] = +curArg;\n      }\n\n      foundDecimal = c === '.';\n\n      // fix for negative numbers or repeated decimals with no delimeter between commands\n      curArg = ['-', '.'].includes(c) ? c : '';\n    } else {\n      curArg += c;\n      if (c === '.') {\n        foundDecimal = true;\n      }\n    }\n  }\n\n  // add the last command\n  if (curArg.length \u003e 0) {\n    if (args.length === params) {\n      // handle reused commands\n      ret[ret.length] = { cmd, args };\n      args = [+curArg];\n\n      // handle assumed commands\n      if (cmd === 'M') {\n        cmd = 'L';\n      }\n      if (cmd === 'm') {\n        cmd = 'l';\n      }\n    } else {\n      args[args.length] = +curArg;\n    }\n  }\n\n  ret[ret.length] = { cmd, args };\n\n  return ret;\n};\n\nconst apply = (commands: Cmd[]) =\u003e {\n  // current point, control point, and subpath starting point\n  cx = cy = px = py = sx = sy = 0;\n\n  // run the commands\n  let cmds: PDFOperator[] = [];\n  for (let i = 0; i \u003c commands.length; i++) {\n    const c = commands[i];\n    if (c.cmd \u0026\u0026 typeof runners[c.cmd] === 'function') {\n      const cmd = runners[c.cmd](c.args);\n      if (Array.isArray(cmd)) {\n        cmds = cmds.concat(cmd);\n      } else {\n        cmds.push(cmd);\n      }\n    }\n  }\n  return cmds;\n};\n\ninterface CmdToOperatorsMap {\n  [cmd: string]: (a: number[]) =\u003e PDFOperator | PDFOperator[];\n}\n\nconst runners: CmdToOperatorsMap = {\n  M(a) {\n    cx = a[0];\n    cy = a[1];\n    px = py = null;\n    sx = cx;\n    sy = cy;\n    return moveTo(cx, cy);\n  },\n\n  m(a) {\n    cx += a[0];\n    cy += a[1];\n    px = py = null;\n    sx = cx;\n    sy = cy;\n    return moveTo(cx, cy);\n  },\n\n  C(a) {\n    cx = a[4];\n    cy = a[5];\n    px = a[2];\n    py = a[3];\n    return appendBezierCurve(a[0], a[1], a[2], a[3], a[4], a[5]);\n  },\n\n  c(a) {\n    const cmd = appendBezierCurve(\n      a[0] + cx,\n      a[1] + cy,\n      a[2] + cx,\n      a[3] + cy,\n      a[4] + cx,\n      a[5] + cy,\n    );\n    px = cx + a[2];\n    py = cy + a[3];\n    cx += a[4];\n    cy += a[5];\n    return cmd;\n  },\n\n  S(a) {\n    if (px === null || py === null) {\n      px = cx;\n      py = cy;\n    }\n\n    const cmd = appendBezierCurve(\n      cx - (px - cx),\n      cy - (py - cy),\n      a[0],\n      a[1],\n      a[2],\n      a[3],\n    );\n    px = a[0];\n    py = a[1];\n    cx = a[2];\n    cy = a[3];\n    return cmd;\n  },\n\n  s(a) {\n    if (px === null || py === null) {\n      px = cx;\n      py = cy;\n    }\n\n    const cmd = appendBezierCurve(\n      cx - (px - cx),\n      cy - (py - cy),\n      cx + a[0],\n      cy + a[1],\n      cx + a[2],\n      cy + a[3],\n    );\n    px = cx + a[0];\n    py = cy + a[1];\n    cx += a[2];\n    cy += a[3];\n    return cmd;\n  },\n\n  Q(a) {\n    px = a[0];\n    py = a[1];\n    cx = a[2];\n    cy = a[3];\n    return appendQuadraticCurve(a[0], a[1], cx, cy);\n  },\n\n  q(a) {\n    const cmd = appendQuadraticCurve(\n      a[0] + cx,\n      a[1] + cy,\n      a[2] + cx,\n      a[3] + cy,\n    );\n    px = cx + a[0];\n    py = cy + a[1];\n    cx += a[2];\n    cy += a[3];\n    return cmd;\n  },\n\n  T(a) {\n    if (px === null || py === null) {\n      px = cx;\n      py = cy;\n    } else {\n      px = cx - (px - cx);\n      py = cy - (py - cy);\n    }\n\n    const cmd = appendQuadraticCurve(px, py, a[0], a[1]);\n    px = cx - (px - cx);\n    py = cy - (py - cy);\n    cx = a[0];\n    cy = a[1];\n    return cmd;\n  },\n\n  t(a) {\n    if (px === null || py === null) {\n      px = cx;\n      py = cy;\n    } else {\n      px = cx - (px - cx);\n      py = cy - (py - cy);\n    }\n\n    const cmd = appendQuadraticCurve(px, py, cx + a[0], cy + a[1]);\n    cx += a[0];\n    cy += a[1];\n    return cmd;\n  },\n\n  A(a) {\n    const cmds = solveArc(cx, cy, a);\n    cx = a[5];\n    cy = a[6];\n    return cmds;\n  },\n\n  a(a) {\n    a[5] += cx;\n    a[6] += cy;\n    const cmds = solveArc(cx, cy, a);\n    cx = a[5];\n    cy = a[6];\n    return cmds;\n  },\n\n  L(a) {\n    cx = a[0];\n    cy = a[1];\n    px = py = null;\n    return lineTo(cx, cy);\n  },\n\n  l(a) {\n    cx += a[0];\n    cy += a[1];\n    px = py = null;\n    return lineTo(cx, cy);\n  },\n\n  H(a) {\n    cx = a[0];\n    px = py = null;\n    return lineTo(cx, cy);\n  },\n\n  h(a) {\n    cx += a[0];\n    px = py = null;\n    return lineTo(cx, cy);\n  },\n\n  V(a) {\n    cy = a[0];\n    px = py = null;\n    return lineTo(cx, cy);\n  },\n\n  v(a) {\n    cy += a[0];\n    px = py = null;\n    return lineTo(cx, cy);\n  },\n\n  Z() {\n    const cmd = closePath();\n    cx = sx;\n    cy = sy;\n    return cmd;\n  },\n\n  z() {\n    const cmd = closePath();\n    cx = sx;\n    cy = sy;\n    return cmd;\n  },\n};\n\nconst solveArc = (x: number, y: number, coords: number[]) =\u003e {\n  const [rx, ry, rot, large, sweep, ex, ey] = coords;\n  const segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y);\n\n  const cmds: PDFOperator[] = [];\n  for (const seg of segs) {\n    const bez = segmentToBezier(...seg);\n    cmds.push(appendBezierCurve(...bez));\n  }\n  return cmds;\n};\n\ntype Segment = [number, number, number, number, number, number, number, number];\ntype Bezier = [number, number, number, number, number, number];\n\n// from Inkscape svgtopdf, thanks!\nconst arcToSegments = (\n  x: number,\n  y: number,\n  rx: number,\n  ry: number,\n  large: number,\n  sweep: number,\n  rotateX: number,\n  ox: number,\n  oy: number,\n) =\u003e {\n  const th = rotateX * (Math.PI / 180);\n  const sinTh = Math.sin(th);\n  const cosTh = Math.cos(th);\n  rx = Math.abs(rx);\n  ry = Math.abs(ry);\n  px = cosTh * (ox - x) * 0.5 + sinTh * (oy - y) * 0.5;\n  py = cosTh * (oy - y) * 0.5 - sinTh * (ox - x) * 0.5;\n  let pl = (px * px) / (rx * rx) + (py * py) / (ry * ry);\n  if (pl \u003e 1) {\n    pl = Math.sqrt(pl);\n    rx *= pl;\n    ry *= pl;\n  }\n\n  const a00 = cosTh / rx;\n  const a01 = sinTh / rx;\n  const a10 = -sinTh / ry;\n  const a11 = cosTh / ry;\n  const x0 = a00 * ox + a01 * oy;\n  const y0 = a10 * ox + a11 * oy;\n  const x1 = a00 * x + a01 * y;\n  const y1 = a10 * x + a11 * y;\n\n  const d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);\n  let sfactorSq = 1 / d - 0.25;\n  if (sfactorSq \u003c 0) {\n    sfactorSq = 0;\n  }\n  let sfactor = Math.sqrt(sfactorSq);\n  if (sweep === large) {\n    sfactor = -sfactor;\n  }\n\n  const xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);\n  const yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);\n\n  const th0 = Math.atan2(y0 - yc, x0 - xc);\n  const th1 = Math.atan2(y1 - yc, x1 - xc);\n\n  let thArc = th1 - th0;\n  if (thArc \u003c 0 \u0026\u0026 sweep === 1) {\n    thArc += 2 * Math.PI;\n  } else if (thArc \u003e 0 \u0026\u0026 sweep === 0) {\n    thArc -= 2 * Math.PI;\n  }\n\n  const segments = Math.ceil(Math.abs(thArc / (Math.PI * 0.5 + 0.001)));\n  const result: Segment[] = [];\n\n  for (let i = 0; i \u003c segments; i++) {\n    const th2 = th0 + (i * thArc) / segments;\n    const th3 = th0 + ((i + 1) * thArc) / segments;\n    result[i] = [xc, yc, th2, th3, rx, ry, sinTh, cosTh];\n  }\n\n  return result;\n};\n\nconst segmentToBezier = (\n  cx1: number,\n  cy1: number,\n  th0: number,\n  th1: number,\n  rx: number,\n  ry: number,\n  sinTh: number,\n  cosTh: number,\n) =\u003e {\n  const a00 = cosTh * rx;\n  const a01 = -sinTh * ry;\n  const a10 = sinTh * rx;\n  const a11 = cosTh * ry;\n\n  const thHalf = 0.5 * (th1 - th0);\n  const t =\n    ((8 / 3) * Math.sin(thHalf * 0.5) * Math.sin(thHalf * 0.5)) /\n    Math.sin(thHalf);\n  const x1 = cx1 + Math.cos(th0) - t * Math.sin(th0);\n  const y1 = cy1 + Math.sin(th0) + t * Math.cos(th0);\n  const x3 = cx1 + Math.cos(th1);\n  const y3 = cy1 + Math.sin(th1);\n  const x2 = x3 + t * Math.sin(th1);\n  const y2 = y3 - t * Math.cos(th1);\n\n  const result: Bezier = [\n    a00 * x1 + a01 * y1,\n    a10 * x1 + a11 * y1,\n    a00 * x2 + a01 * y2,\n    a10 * x2 + a11 * y2,\n    a00 * x3 + a01 * y3,\n    a10 * x3 + a11 * y3,\n  ];\n  return result;\n};\n\nexport const svgPathToOperators = (path: string) =\u003e apply(parse(path));\n","import { Color, setFillingColor, setStrokingColor } from 'src/api/colors';\nimport {\n  beginText,\n  closePath,\n  drawObject,\n  endText,\n  fill,\n  fillAndStroke,\n  lineTo,\n  moveTo,\n  nextLine,\n  popGraphicsState,\n  pushGraphicsState,\n  rotateAndSkewTextRadiansAndTranslate,\n  rotateRadians,\n  scale,\n  setFontAndSize,\n  setLineHeight,\n  setLineWidth,\n  showText,\n  skewRadians,\n  stroke,\n  translate,\n  LineCapStyle,\n  setLineCap,\n  rotateDegrees,\n  setGraphicsState,\n  setDashPattern,\n  beginMarkedContent,\n  endMarkedContent,\n  clip,\n  endPath,\n  appendBezierCurve,\n} from 'src/api/operators';\nimport { Rotation, degrees, toRadians } from 'src/api/rotations';\nimport { svgPathToOperators } from 'src/api/svgPath';\nimport { PDFHexString, PDFName, PDFNumber, PDFOperator } from 'src/core';\nimport { asNumber } from 'src/api/objects';\n\nexport interface DrawTextOptions {\n  color: Color;\n  font: string | PDFName;\n  size: number | PDFNumber;\n  rotate: Rotation;\n  xSkew: Rotation;\n  ySkew: Rotation;\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  graphicsState?: string | PDFName;\n}\n\nexport const drawText = (\n  line: PDFHexString,\n  options: DrawTextOptions,\n): PDFOperator[] =\u003e\n  [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n    beginText(),\n    setFillingColor(options.color),\n    setFontAndSize(options.font, options.size),\n    rotateAndSkewTextRadiansAndTranslate(\n      toRadians(options.rotate),\n      toRadians(options.xSkew),\n      toRadians(options.ySkew),\n      options.x,\n      options.y,\n    ),\n    showText(line),\n    endText(),\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n\nexport interface DrawLinesOfTextOptions extends DrawTextOptions {\n  lineHeight: number | PDFNumber;\n}\n\nexport const drawLinesOfText = (\n  lines: PDFHexString[],\n  options: DrawLinesOfTextOptions,\n): PDFOperator[] =\u003e {\n  const operators = [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n    beginText(),\n    setFillingColor(options.color),\n    setFontAndSize(options.font, options.size),\n    setLineHeight(options.lineHeight),\n    rotateAndSkewTextRadiansAndTranslate(\n      toRadians(options.rotate),\n      toRadians(options.xSkew),\n      toRadians(options.ySkew),\n      options.x,\n      options.y,\n    ),\n  ].filter(Boolean) as PDFOperator[];\n\n  for (let idx = 0, len = lines.length; idx \u003c len; idx++) {\n    operators.push(showText(lines[idx]), nextLine());\n  }\n\n  operators.push(endText(), popGraphicsState());\n  return operators;\n};\n\nexport const drawImage = (\n  name: string | PDFName,\n  options: {\n    x: number | PDFNumber;\n    y: number | PDFNumber;\n    width: number | PDFNumber;\n    height: number | PDFNumber;\n    rotate: Rotation;\n    xSkew: Rotation;\n    ySkew: Rotation;\n    graphicsState?: string | PDFName;\n  },\n): PDFOperator[] =\u003e\n  [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n    translate(options.x, options.y),\n    rotateRadians(toRadians(options.rotate)),\n    scale(options.width, options.height),\n    skewRadians(toRadians(options.xSkew), toRadians(options.ySkew)),\n    drawObject(name),\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n\nexport const drawPage = (\n  name: string | PDFName,\n  options: {\n    x: number | PDFNumber;\n    y: number | PDFNumber;\n    xScale: number | PDFNumber;\n    yScale: number | PDFNumber;\n    rotate: Rotation;\n    xSkew: Rotation;\n    ySkew: Rotation;\n    graphicsState?: string | PDFName;\n  },\n): PDFOperator[] =\u003e\n  [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n    translate(options.x, options.y),\n    rotateRadians(toRadians(options.rotate)),\n    scale(options.xScale, options.yScale),\n    skewRadians(toRadians(options.xSkew), toRadians(options.ySkew)),\n    drawObject(name),\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n\nexport const drawLine = (options: {\n  start: { x: number | PDFNumber; y: number | PDFNumber };\n  end: { x: number | PDFNumber; y: number | PDFNumber };\n  thickness: number | PDFNumber;\n  color: Color | undefined;\n  dashArray?: (number | PDFNumber)[];\n  dashPhase?: number | PDFNumber;\n  lineCap?: LineCapStyle;\n  graphicsState?: string | PDFName;\n}) =\u003e\n  [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n    options.color \u0026\u0026 setStrokingColor(options.color),\n    setLineWidth(options.thickness),\n    setDashPattern(options.dashArray ?? [], options.dashPhase ?? 0),\n    moveTo(options.start.x, options.start.y),\n    options.lineCap \u0026\u0026 setLineCap(options.lineCap),\n    moveTo(options.start.x, options.start.y),\n    lineTo(options.end.x, options.end.y),\n    stroke(),\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n\nexport const drawRectangle = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  width: number | PDFNumber;\n  height: number | PDFNumber;\n  borderWidth: number | PDFNumber;\n  color: Color | undefined;\n  borderColor: Color | undefined;\n  rotate: Rotation;\n  xSkew: Rotation;\n  ySkew: Rotation;\n  borderLineCap?: LineCapStyle;\n  borderDashArray?: (number | PDFNumber)[];\n  borderDashPhase?: number | PDFNumber;\n  graphicsState?: string | PDFName;\n}) =\u003e\n  [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n    options.color \u0026\u0026 setFillingColor(options.color),\n    options.borderColor \u0026\u0026 setStrokingColor(options.borderColor),\n    setLineWidth(options.borderWidth),\n    options.borderLineCap \u0026\u0026 setLineCap(options.borderLineCap),\n    setDashPattern(options.borderDashArray ?? [], options.borderDashPhase ?? 0),\n    translate(options.x, options.y),\n    rotateRadians(toRadians(options.rotate)),\n    skewRadians(toRadians(options.xSkew), toRadians(options.ySkew)),\n    moveTo(0, 0),\n    lineTo(0, options.height),\n    lineTo(options.width, options.height),\n    lineTo(options.width, 0),\n    closePath(),\n\n    // prettier-ignore\n    options.color \u0026\u0026 options.borderWidth ? fillAndStroke()\n  : options.color                      ? fill()\n  : options.borderColor                ? stroke()\n  : closePath(),\n\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n\nconst KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0);\n\n/** @deprecated */\nexport const drawEllipsePath = (config: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  xScale: number | PDFNumber;\n  yScale: number | PDFNumber;\n}): PDFOperator[] =\u003e {\n  let x = asNumber(config.x);\n  let y = asNumber(config.y);\n  const xScale = asNumber(config.xScale);\n  const yScale = asNumber(config.yScale);\n\n  x -= xScale;\n  y -= yScale;\n\n  const ox = xScale * KAPPA;\n  const oy = yScale * KAPPA;\n  const xe = x + xScale * 2;\n  const ye = y + yScale * 2;\n  const xm = x + xScale;\n  const ym = y + yScale;\n\n  return [\n    pushGraphicsState(),\n    moveTo(x, ym),\n    appendBezierCurve(x, ym - oy, xm - ox, y, xm, y),\n    appendBezierCurve(xm + ox, y, xe, ym - oy, xe, ym),\n    appendBezierCurve(xe, ym + oy, xm + ox, ye, xm, ye),\n    appendBezierCurve(xm - ox, ye, x, ym + oy, x, ym),\n    popGraphicsState(),\n  ];\n};\n\nconst drawEllipseCurves = (config: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  xScale: number | PDFNumber;\n  yScale: number | PDFNumber;\n  rotate: Rotation;\n}): PDFOperator[] =\u003e {\n  const centerX = asNumber(config.x);\n  const centerY = asNumber(config.y);\n  const xScale = asNumber(config.xScale);\n  const yScale = asNumber(config.yScale);\n\n  const x = -xScale;\n  const y = -yScale;\n\n  const ox = xScale * KAPPA;\n  const oy = yScale * KAPPA;\n  const xe = x + xScale * 2;\n  const ye = y + yScale * 2;\n  const xm = x + xScale;\n  const ym = y + yScale;\n\n  return [\n    translate(centerX, centerY),\n    rotateRadians(toRadians(config.rotate)),\n    moveTo(x, ym),\n    appendBezierCurve(x, ym - oy, xm - ox, y, xm, y),\n    appendBezierCurve(xm + ox, y, xe, ym - oy, xe, ym),\n    appendBezierCurve(xe, ym + oy, xm + ox, ye, xm, ye),\n    appendBezierCurve(xm - ox, ye, x, ym + oy, x, ym),\n  ];\n};\n\nexport const drawEllipse = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  xScale: number | PDFNumber;\n  yScale: number | PDFNumber;\n  rotate?: Rotation;\n  color: Color | undefined;\n  borderColor: Color | undefined;\n  borderWidth: number | PDFNumber;\n  borderDashArray?: (number | PDFNumber)[];\n  borderDashPhase?: number | PDFNumber;\n  graphicsState?: string | PDFName;\n  borderLineCap?: LineCapStyle;\n}) =\u003e\n  [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n    options.color \u0026\u0026 setFillingColor(options.color),\n    options.borderColor \u0026\u0026 setStrokingColor(options.borderColor),\n    setLineWidth(options.borderWidth),\n    options.borderLineCap \u0026\u0026 setLineCap(options.borderLineCap),\n    setDashPattern(options.borderDashArray ?? [], options.borderDashPhase ?? 0),\n\n    // The `drawEllipsePath` branch is only here for backwards compatibility.\n    // See https://github.com/Hopding/pdf-lib/pull/511#issuecomment-667685655.\n    ...(options.rotate === undefined\n      ? drawEllipsePath({\n          x: options.x,\n          y: options.y,\n          xScale: options.xScale,\n          yScale: options.yScale,\n        })\n      : drawEllipseCurves({\n          x: options.x,\n          y: options.y,\n          xScale: options.xScale,\n          yScale: options.yScale,\n          rotate: options.rotate ?? degrees(0),\n        })),\n\n    // prettier-ignore\n    options.color \u0026\u0026 options.borderWidth ? fillAndStroke()\n  : options.color                      ? fill()\n  : options.borderColor                ? stroke()\n  : closePath(),\n\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n\nexport const drawSvgPath = (\n  path: string,\n  options: {\n    x: number | PDFNumber;\n    y: number | PDFNumber;\n    rotate?: Rotation;\n    scale: number | PDFNumber | undefined;\n    color: Color | undefined;\n    borderColor: Color | undefined;\n    borderWidth: number | PDFNumber;\n    borderDashArray?: (number | PDFNumber)[];\n    borderDashPhase?: number | PDFNumber;\n    borderLineCap?: LineCapStyle;\n    graphicsState?: string | PDFName;\n  },\n) =\u003e\n  [\n    pushGraphicsState(),\n    options.graphicsState \u0026\u0026 setGraphicsState(options.graphicsState),\n\n    translate(options.x, options.y),\n    rotateRadians(toRadians(options.rotate ?? degrees(0))),\n\n    // SVG path Y axis is opposite pdf-lib's\n    options.scale ? scale(options.scale, -options.scale) : scale(1, -1),\n\n    options.color \u0026\u0026 setFillingColor(options.color),\n    options.borderColor \u0026\u0026 setStrokingColor(options.borderColor),\n    options.borderWidth \u0026\u0026 setLineWidth(options.borderWidth),\n    options.borderLineCap \u0026\u0026 setLineCap(options.borderLineCap),\n\n    setDashPattern(options.borderDashArray ?? [], options.borderDashPhase ?? 0),\n\n    ...svgPathToOperators(path),\n\n    // prettier-ignore\n    options.color \u0026\u0026 options.borderWidth ? fillAndStroke()\n  : options.color                      ? fill()\n  : options.borderColor                ? stroke()\n  : closePath(),\n\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n\nexport const drawCheckMark = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  size: number | PDFNumber;\n  thickness: number | PDFNumber;\n  color: Color | undefined;\n}) =\u003e {\n  const size = asNumber(options.size);\n\n  /*********************** Define Check Mark Points ***************************/\n  // A check mark is defined by three points in some coordinate space. Here, we\n  // define these points in a unit coordinate system, where the range of the x\n  // and y axis are both [-1, 1].\n  //\n  // Note that we do not hard code `p1y` in case we wish to change the\n  // size/shape of the check mark in the future. We want the check mark to\n  // always form a right angle. This means that the dot product between (p1-p2)\n  // and (p3-p2) should be zero:\n  //\n  //   (p1x-p2x) * (p3x-p2x) + (p1y-p2y) * (p3y-p2y) = 0\n  //\n  // We can now rejigger this equation to solve for `p1y`:\n  //\n  //   (p1y-p2y) * (p3y-p2y) = -((p1x-p2x) * (p3x-p2x))\n  //   (p1y-p2y) = -((p1x-p2x) * (p3x-p2x)) / (p3y-p2y)\n  //   p1y = -((p1x-p2x) * (p3x-p2x)) / (p3y-p2y) + p2y\n  //\n  // Thanks to my friend Joel Walker (https://github.com/JWalker1995) for\n  // devising the above equation and unit coordinate system approach!\n\n  // (x, y) coords of the check mark's bottommost point\n  const p2x = -1 + 0.75;\n  const p2y = -1 + 0.51;\n\n  // (x, y) coords of the check mark's topmost point\n  const p3y = 1 - 0.525;\n  const p3x = 1 - 0.31;\n\n  // (x, y) coords of the check mark's center (vertically) point\n  const p1x = -1 + 0.325;\n  const p1y = -((p1x - p2x) * (p3x - p2x)) / (p3y - p2y) + p2y;\n  /****************************************************************************/\n\n  return [\n    pushGraphicsState(),\n    options.color \u0026\u0026 setStrokingColor(options.color),\n    setLineWidth(options.thickness),\n\n    translate(options.x, options.y),\n    moveTo(p1x * size, p1y * size),\n    lineTo(p2x * size, p2y * size),\n    lineTo(p3x * size, p3y * size),\n\n    stroke(),\n    popGraphicsState(),\n  ].filter(Boolean) as PDFOperator[];\n};\n\n// prettier-ignore\nexport const rotateInPlace = (options: {\n  width: number | PDFNumber;\n  height: number | PDFNumber;\n  rotation: 0 | 90 | 180 | 270;\n}) =\u003e\n    options.rotation === 0 ? [\n      translate(0, 0),\n      rotateDegrees(0)\n    ]\n  : options.rotation === 90 ? [\n      translate(options.width, 0),\n      rotateDegrees(90)\n    ]\n  : options.rotation === 180 ? [\n      translate(options.width, options.height),\n      rotateDegrees(180)\n    ]\n  : options.rotation === 270 ? [\n      translate(0, options.height),\n      rotateDegrees(270)\n    ]\n  : []; // Invalid rotation - noop\n\nexport const drawCheckBox = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  width: number | PDFNumber;\n  height: number | PDFNumber;\n  thickness: number | PDFNumber;\n  borderWidth: number | PDFNumber;\n  markColor: Color | undefined;\n  color: Color | undefined;\n  borderColor: Color | undefined;\n  filled: boolean;\n}) =\u003e {\n  const outline = drawRectangle({\n    x: options.x,\n    y: options.y,\n    width: options.width,\n    height: options.height,\n    borderWidth: options.borderWidth,\n    color: options.color,\n    borderColor: options.borderColor,\n    rotate: degrees(0),\n    xSkew: degrees(0),\n    ySkew: degrees(0),\n  });\n\n  if (!options.filled) return outline;\n\n  const width = asNumber(options.width);\n  const height = asNumber(options.height);\n\n  const checkMarkSize = Math.min(width, height) / 2;\n\n  const checkMark = drawCheckMark({\n    x: width / 2,\n    y: height / 2,\n    size: checkMarkSize,\n    thickness: options.thickness,\n    color: options.markColor,\n  });\n\n  return [pushGraphicsState(), ...outline, ...checkMark, popGraphicsState()];\n};\n\nexport const drawRadioButton = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  width: number | PDFNumber;\n  height: number | PDFNumber;\n  borderWidth: number | PDFNumber;\n  dotColor: Color | undefined;\n  color: Color | undefined;\n  borderColor: Color | undefined;\n  filled: boolean;\n}) =\u003e {\n  const width = asNumber(options.width);\n  const height = asNumber(options.height);\n\n  const outlineScale = Math.min(width, height) / 2;\n\n  const outline = drawEllipse({\n    x: options.x,\n    y: options.y,\n    xScale: outlineScale,\n    yScale: outlineScale,\n    color: options.color,\n    borderColor: options.borderColor,\n    borderWidth: options.borderWidth,\n  });\n\n  if (!options.filled) return outline;\n\n  const dot = drawEllipse({\n    x: options.x,\n    y: options.y,\n    xScale: outlineScale * 0.45,\n    yScale: outlineScale * 0.45,\n    color: options.dotColor,\n    borderColor: undefined,\n    borderWidth: 0,\n  });\n\n  return [pushGraphicsState(), ...outline, ...dot, popGraphicsState()];\n};\n\nexport const drawButton = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  width: number | PDFNumber;\n  height: number | PDFNumber;\n  borderWidth: number | PDFNumber;\n  color: Color | undefined;\n  borderColor: Color | undefined;\n  textLines: { encoded: PDFHexString; x: number; y: number }[];\n  textColor: Color;\n  font: string | PDFName;\n  fontSize: number | PDFNumber;\n}) =\u003e {\n  const x = asNumber(options.x);\n  const y = asNumber(options.y);\n  const width = asNumber(options.width);\n  const height = asNumber(options.height);\n\n  const background = drawRectangle({\n    x,\n    y,\n    width,\n    height,\n    borderWidth: options.borderWidth,\n    color: options.color,\n    borderColor: options.borderColor,\n    rotate: degrees(0),\n    xSkew: degrees(0),\n    ySkew: degrees(0),\n  });\n\n  const lines = drawTextLines(options.textLines, {\n    color: options.textColor,\n    font: options.font,\n    size: options.fontSize,\n    rotate: degrees(0),\n    xSkew: degrees(0),\n    ySkew: degrees(0),\n  });\n\n  return [pushGraphicsState(), ...background, ...lines, popGraphicsState()];\n};\n\nexport interface DrawTextLinesOptions {\n  color: Color;\n  font: string | PDFName;\n  size: number | PDFNumber;\n  rotate: Rotation;\n  xSkew: Rotation;\n  ySkew: Rotation;\n}\n\nexport const drawTextLines = (\n  lines: { encoded: PDFHexString; x: number; y: number }[],\n  options: DrawTextLinesOptions,\n): PDFOperator[] =\u003e {\n  const operators = [\n    beginText(),\n    setFillingColor(options.color),\n    setFontAndSize(options.font, options.size),\n  ];\n\n  for (let idx = 0, len = lines.length; idx \u003c len; idx++) {\n    const { encoded, x, y } = lines[idx];\n    operators.push(\n      rotateAndSkewTextRadiansAndTranslate(\n        toRadians(options.rotate),\n        toRadians(options.xSkew),\n        toRadians(options.ySkew),\n        x,\n        y,\n      ),\n      showText(encoded),\n    );\n  }\n\n  operators.push(endText());\n\n  return operators;\n};\n\nexport const drawTextField = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  width: number | PDFNumber;\n  height: number | PDFNumber;\n  borderWidth: number | PDFNumber;\n  color: Color | undefined;\n  borderColor: Color | undefined;\n  textLines: { encoded: PDFHexString; x: number; y: number }[];\n  textColor: Color;\n  font: string | PDFName;\n  fontSize: number | PDFNumber;\n  padding: number | PDFNumber;\n}) =\u003e {\n  const x = asNumber(options.x);\n  const y = asNumber(options.y);\n  const width = asNumber(options.width);\n  const height = asNumber(options.height);\n  const borderWidth = asNumber(options.borderWidth);\n  const padding = asNumber(options.padding);\n\n  const clipX = x + borderWidth / 2 + padding;\n  const clipY = y + borderWidth / 2 + padding;\n  const clipWidth = width - (borderWidth / 2 + padding) * 2;\n  const clipHeight = height - (borderWidth / 2 + padding) * 2;\n\n  const clippingArea = [\n    moveTo(clipX, clipY),\n    lineTo(clipX, clipY + clipHeight),\n    lineTo(clipX + clipWidth, clipY + clipHeight),\n    lineTo(clipX + clipWidth, clipY),\n    closePath(),\n    clip(),\n    endPath(),\n  ];\n\n  const background = drawRectangle({\n    x,\n    y,\n    width,\n    height,\n    borderWidth: options.borderWidth,\n    color: options.color,\n    borderColor: options.borderColor,\n    rotate: degrees(0),\n    xSkew: degrees(0),\n    ySkew: degrees(0),\n  });\n\n  const lines = drawTextLines(options.textLines, {\n    color: options.textColor,\n    font: options.font,\n    size: options.fontSize,\n    rotate: degrees(0),\n    xSkew: degrees(0),\n    ySkew: degrees(0),\n  });\n\n  const markedContent = [\n    beginMarkedContent('Tx'),\n    pushGraphicsState(),\n    ...lines,\n    popGraphicsState(),\n    endMarkedContent(),\n  ];\n\n  return [\n    pushGraphicsState(),\n    ...background,\n    ...clippingArea,\n    ...markedContent,\n    popGraphicsState(),\n  ];\n};\n\nexport const drawOptionList = (options: {\n  x: number | PDFNumber;\n  y: number | PDFNumber;\n  width: number | PDFNumber;\n  height: number | PDFNumber;\n  borderWidth: number | PDFNumber;\n  color: Color | undefined;\n  borderColor: Color | undefined;\n  textLines: { encoded: PDFHexString; x: number; y: number; height: number }[];\n  textColor: Color;\n  font: string | PDFName;\n  fontSize: number | PDFNumber;\n  lineHeight: number | PDFNumber;\n  selectedLines: number[];\n  selectedColor: Color;\n  padding: number | PDFNumber;\n}) =\u003e {\n  const x = asNumber(options.x);\n  const y = asNumber(options.y);\n  const width = asNumber(options.width);\n  const height = asNumber(options.height);\n  const lineHeight = asNumber(options.lineHeight);\n  const borderWidth = asNumber(options.borderWidth);\n  const padding = asNumber(options.padding);\n\n  const clipX = x + borderWidth / 2 + padding;\n  const clipY = y + borderWidth / 2 + padding;\n  const clipWidth = width - (borderWidth / 2 + padding) * 2;\n  const clipHeight = height - (borderWidth / 2 + padding) * 2;\n\n  const clippingArea = [\n    moveTo(clipX, clipY),\n    lineTo(clipX, clipY + clipHeight),\n    lineTo(clipX + clipWidth, clipY + clipHeight),\n    lineTo(clipX + clipWidth, clipY),\n    closePath(),\n    clip(),\n    endPath(),\n  ];\n\n  const background = drawRectangle({\n    x,\n    y,\n    width,\n    height,\n    borderWidth: options.borderWidth,\n    color: options.color,\n    borderColor: options.borderColor,\n    rotate: degrees(0),\n    xSkew: degrees(0),\n    ySkew: degrees(0),\n  });\n\n  const highlights: PDFOperator[] = [];\n  for (let idx = 0, len = options.selectedLines.length; idx \u003c len; idx++) {\n    const line = options.textLines[options.selectedLines[idx]];\n    highlights.push(\n      ...drawRectangle({\n        x: line.x - padding,\n        y: line.y - (lineHeight - line.height) / 2,\n        width: width - borderWidth,\n        height: line.height + (lineHeight - line.height) / 2,\n        borderWidth: 0,\n        color: options.selectedColor,\n        borderColor: undefined,\n        rotate: degrees(0),\n        xSkew: degrees(0),\n        ySkew: degrees(0),\n      }),\n    );\n  }\n\n  const lines = drawTextLines(options.textLines, {\n    color: options.textColor,\n    font: options.font,\n    size: options.fontSize,\n    rotate: degrees(0),\n    xSkew: degrees(0),\n    ySkew: degrees(0),\n  });\n\n  const markedContent = [\n    beginMarkedContent('Tx'),\n    pushGraphicsState(),\n    ...lines,\n    popGraphicsState(),\n    endMarkedContent(),\n  ];\n\n  return [\n    pushGraphicsState(),\n    ...background,\n    ...highlights,\n    ...clippingArea,\n    ...markedContent,\n    popGraphicsState(),\n  ];\n};\n","// tslint:disable: max-classes-per-file\n\n// TODO: Include link to documentation with example\nexport class EncryptedPDFError extends Error {\n  constructor() {\n    const msg =\n      'Input document to `PDFDocument.load` is encrypted. You can use `PDFDocument.load(..., { ignoreEncryption: true })` if you wish to load the document anyways.';\n    super(msg);\n  }\n}\n\n// TODO: Include link to documentation with example\nexport class FontkitNotRegisteredError extends Error {\n  constructor() {\n    const msg =\n      'Input to `PDFDocument.embedFont` was a custom font, but no `fontkit` instance was found. You must register a `fontkit` instance with `PDFDocument.registerFontkit(...)` before embedding custom fonts.';\n    super(msg);\n  }\n}\n\n// TODO: Include link to documentation with example\nexport class ForeignPageError extends Error {\n  constructor() {\n    const msg =\n      'A `page` passed to `PDFDocument.addPage` or `PDFDocument.insertPage` was from a different (foreign) PDF document. If you want to copy pages from one PDFDocument to another, you must use `PDFDocument.copyPages(...)` to copy the pages before adding or inserting them.';\n    super(msg);\n  }\n}\n\n// TODO: Include link to documentation with example\nexport class RemovePageFromEmptyDocumentError extends Error {\n  constructor() {\n    const msg =\n      'PDFDocument has no pages so `PDFDocument.removePage` cannot be called';\n    super(msg);\n  }\n}\n\nexport class NoSuchFieldError extends Error {\n  constructor(name: string) {\n    const msg = `PDFDocument has no form field with the name \"${name}\"`;\n    super(msg);\n  }\n}\n\nexport class UnexpectedFieldTypeError extends Error {\n  constructor(name: string, expected: any, actual: any) {\n    const expectedType = expected?.name;\n    const actualType = actual?.constructor?.name ?? actual;\n    const msg =\n      `Expected field \"${name}\" to be of type ${expectedType}, ` +\n      `but it is actually of type ${actualType}`;\n    super(msg);\n  }\n}\n\nexport class MissingOnValueCheckError extends Error {\n  constructor(onValue: any) {\n    const msg = `Failed to select check box due to missing onValue: \"${onValue}\"`;\n    super(msg);\n  }\n}\n\nexport class FieldAlreadyExistsError extends Error {\n  constructor(name: string) {\n    const msg = `A field already exists with the specified name: \"${name}\"`;\n    super(msg);\n  }\n}\n\nexport class InvalidFieldNamePartError extends Error {\n  constructor(namePart: string) {\n    const msg = `Field name contains invalid component: \"${namePart}\"`;\n    super(msg);\n  }\n}\n\nexport class FieldExistsAsNonTerminalError extends Error {\n  constructor(name: string) {\n    const msg = `A non-terminal field already exists with the specified name: \"${name}\"`;\n    super(msg);\n  }\n}\n\nexport class RichTextFieldReadError extends Error {\n  constructor(fieldName: string) {\n    const msg = `Reading rich text fields is not supported: Attempted to read rich text field: ${fieldName}`;\n    super(msg);\n  }\n}\n\nexport class CombedTextLayoutError extends Error {\n  constructor(lineLength: number, cellCount: number) {\n    const msg = `Failed to layout combed text as lineLength=${lineLength} is greater than cellCount=${cellCount}`;\n    super(msg);\n  }\n}\n\nexport class ExceededMaxLengthError extends Error {\n  constructor(textLength: number, maxLength: number, name: string) {\n    const msg = `Attempted to set text with length=${textLength} for TextField with maxLength=${maxLength} and name=${name}`;\n    super(msg);\n  }\n}\n\nexport class InvalidMaxLengthError extends Error {\n  constructor(textLength: number, maxLength: number, name: string) {\n    const msg = `Attempted to set maxLength=${maxLength}, which is less than ${textLength}, the length of this field's current value (name=${name})`;\n    super(msg);\n  }\n}\n","export enum TextAlignment {\n  Left = 0,\n  Center = 1,\n  Right = 2,\n}\n","import PDFFont from 'src/api/PDFFont';\nimport { CombedTextLayoutError } from 'src/api/errors';\nimport { TextAlignment } from 'src/api/text/alignment';\n\nimport { PDFHexString } from 'src/core';\nimport {\n  cleanText,\n  lineSplit,\n  mergeLines,\n  charAtIndex,\n  charSplit,\n} from 'src/utils';\n\nexport interface TextPosition {\n  text: string;\n  encoded: PDFHexString;\n  x: number;\n  y: number;\n  width: number;\n  height: number;\n}\n\nexport interface LayoutBounds {\n  x: number;\n  y: number;\n  width: number;\n  height: number;\n}\n\nconst MIN_FONT_SIZE = 4;\nconst MAX_FONT_SIZE = 500;\n\nconst computeFontSize = (\n  lines: string[],\n  font: PDFFont,\n  bounds: LayoutBounds,\n  multiline: boolean = false,\n) =\u003e {\n  let fontSize = MIN_FONT_SIZE;\n\n  while (fontSize \u003c MAX_FONT_SIZE) {\n    let linesUsed = 0;\n\n    for (\n      let lineIdx = 0, lineLen = lines.length;\n      lineIdx \u003c lineLen;\n      lineIdx++\n    ) {\n      linesUsed += 1;\n\n      const line = lines[lineIdx];\n      const words = line.split(' ');\n\n      // Layout the words using the current `fontSize`, line wrapping\n      // whenever we reach the end of the current line.\n      let spaceInLineRemaining = bounds.width;\n      for (let idx = 0, len = words.length; idx \u003c len; idx++) {\n        const isLastWord = idx === len - 1;\n        const word = isLastWord ? words[idx] : words[idx] + ' ';\n        const widthOfWord = font.widthOfTextAtSize(word, fontSize);\n        spaceInLineRemaining -= widthOfWord;\n        if (spaceInLineRemaining \u003c= 0) {\n          linesUsed += 1;\n          spaceInLineRemaining = bounds.width - widthOfWord;\n        }\n      }\n    }\n\n    // Return if we exceeded the allowed width\n    if (!multiline \u0026\u0026 linesUsed \u003e lines.length) return fontSize - 1;\n\n    const height = font.heightAtSize(fontSize);\n    const lineHeight = height + height * 0.2;\n    const totalHeight = lineHeight * linesUsed;\n\n    // Return if we exceeded the allowed height\n    if (totalHeight \u003e Math.abs(bounds.height)) return fontSize - 1;\n\n    fontSize += 1;\n  }\n\n  return fontSize;\n};\n\nconst computeCombedFontSize = (\n  line: string,\n  font: PDFFont,\n  bounds: LayoutBounds,\n  cellCount: number,\n) =\u003e {\n  const cellWidth = bounds.width / cellCount;\n  const cellHeight = bounds.height;\n\n  let fontSize = MIN_FONT_SIZE;\n\n  const chars = charSplit(line);\n  while (fontSize \u003c MAX_FONT_SIZE) {\n    for (let idx = 0, len = chars.length; idx \u003c len; idx++) {\n      const c = chars[idx];\n      const tooLong = font.widthOfTextAtSize(c, fontSize) \u003e cellWidth * 0.75;\n      if (tooLong) return fontSize - 1;\n    }\n\n    const height = font.heightAtSize(fontSize, { descender: false });\n    if (height \u003e cellHeight) return fontSize - 1;\n\n    fontSize += 1;\n  }\n\n  return fontSize;\n};\n\nexport interface LayoutTextOptions {\n  alignment: TextAlignment;\n  fontSize?: number;\n  font: PDFFont;\n  bounds: LayoutBounds;\n}\n\nexport interface MultilineTextLayout {\n  bounds: LayoutBounds;\n  lines: TextPosition[];\n  fontSize: number;\n  lineHeight: number;\n}\n\nconst lastIndexOfWhitespace = (line: string) =\u003e {\n  for (let idx = line.length; idx \u003e 0; idx--) {\n    if (/\\s/.test(line[idx])) return idx;\n  }\n  return undefined;\n};\n\nconst splitOutLines = (\n  input: string,\n  maxWidth: number,\n  font: PDFFont,\n  fontSize: number,\n) =\u003e {\n  let lastWhitespaceIdx = input.length;\n  while (lastWhitespaceIdx \u003e 0) {\n    const line = input.substring(0, lastWhitespaceIdx);\n    const encoded = font.encodeText(line);\n    const width = font.widthOfTextAtSize(line, fontSize);\n    if (width \u003c maxWidth) {\n      const remainder = input.substring(lastWhitespaceIdx) || undefined;\n      return { line, encoded, width, remainder };\n    }\n    lastWhitespaceIdx = lastIndexOfWhitespace(line) ?? 0;\n  }\n\n  // We were unable to split the input enough to get a chunk that would fit\n  // within the specified `maxWidth` so we'll just return everything\n  return {\n    line: input,\n    encoded: font.encodeText(input),\n    width: font.widthOfTextAtSize(input, fontSize),\n    remainder: undefined,\n  };\n};\n\nexport const layoutMultilineText = (\n  text: string,\n  { alignment, fontSize, font, bounds }: LayoutTextOptions,\n): MultilineTextLayout =\u003e {\n  const lines = lineSplit(cleanText(text));\n\n  if (fontSize === undefined || fontSize === 0) {\n    fontSize = computeFontSize(lines, font, bounds, true);\n  }\n  const height = font.heightAtSize(fontSize);\n  const lineHeight = height + height * 0.2;\n\n  const textLines: TextPosition[] = [];\n\n  let minX = bounds.x;\n  let minY = bounds.y;\n  let maxX = bounds.x + bounds.width;\n  let maxY = bounds.y + bounds.height;\n\n  let y = bounds.y + bounds.height;\n  for (let idx = 0, len = lines.length; idx \u003c len; idx++) {\n    let prevRemainder: string | undefined = lines[idx];\n    while (prevRemainder !== undefined) {\n      const { line, encoded, width, remainder } = splitOutLines(\n        prevRemainder,\n        bounds.width,\n        font,\n        fontSize,\n      );\n\n      // prettier-ignore\n      const x = (\n          alignment === TextAlignment.Left   ? bounds.x\n        : alignment === TextAlignment.Center ? bounds.x + (bounds.width / 2) - (width / 2)\n        : alignment === TextAlignment.Right  ? bounds.x + bounds.width - width\n        : bounds.x\n      );\n\n      y -= lineHeight;\n\n      if (x \u003c minX) minX = x;\n      if (y \u003c minY) minY = y;\n      if (x + width \u003e maxX) maxX = x + width;\n      if (y + height \u003e maxY) maxY = y + height;\n\n      textLines.push({ text: line, encoded, width, height, x, y });\n\n      // Only trim lines that we had to split ourselves. So we won't trim lines\n      // that the user provided themselves with whitespace.\n      prevRemainder = remainder?.trim();\n    }\n  }\n\n  return {\n    fontSize,\n    lineHeight,\n    lines: textLines,\n    bounds: {\n      x: minX,\n      y: minY,\n      width: maxX - minX,\n      height: maxY - minY,\n    },\n  };\n};\n\nexport interface LayoutCombedTextOptions {\n  fontSize?: number;\n  font: PDFFont;\n  bounds: LayoutBounds;\n  cellCount: number;\n}\n\nexport interface CombedTextLayout {\n  bounds: LayoutBounds;\n  cells: TextPosition[];\n  fontSize: number;\n}\n\nexport const layoutCombedText = (\n  text: string,\n  { fontSize, font, bounds, cellCount }: LayoutCombedTextOptions,\n): CombedTextLayout =\u003e {\n  const line = mergeLines(cleanText(text));\n\n  if (line.length \u003e cellCount) {\n    throw new CombedTextLayoutError(line.length, cellCount);\n  }\n\n  if (fontSize === undefined || fontSize === 0) {\n    fontSize = computeCombedFontSize(line, font, bounds, cellCount);\n  }\n\n  const cellWidth = bounds.width / cellCount;\n\n  const height = font.heightAtSize(fontSize, { descender: false });\n  const y = bounds.y + (bounds.height / 2 - height / 2);\n\n  const cells: TextPosition[] = [];\n\n  let minX = bounds.x;\n  let minY = bounds.y;\n  let maxX = bounds.x + bounds.width;\n  let maxY = bounds.y + bounds.height;\n\n  let cellOffset = 0;\n  let charOffset = 0;\n  while (cellOffset \u003c cellCount) {\n    const [char, charLength] = charAtIndex(line, charOffset);\n\n    const encoded = font.encodeText(char);\n    const width = font.widthOfTextAtSize(char, fontSize);\n\n    const cellCenter = bounds.x + (cellWidth * cellOffset + cellWidth / 2);\n    const x = cellCenter - width / 2;\n\n    if (x \u003c minX) minX = x;\n    if (y \u003c minY) minY = y;\n    if (x + width \u003e maxX) maxX = x + width;\n    if (y + height \u003e maxY) maxY = y + height;\n\n    cells.push({ text: line, encoded, width, height, x, y });\n\n    cellOffset += 1;\n    charOffset += charLength;\n  }\n\n  return {\n    fontSize,\n    cells,\n    bounds: {\n      x: minX,\n      y: minY,\n      width: maxX - minX,\n      height: maxY - minY,\n    },\n  };\n};\n\nexport interface LayoutSinglelineTextOptions {\n  alignment: TextAlignment;\n  fontSize?: number;\n  font: PDFFont;\n  bounds: LayoutBounds;\n}\n\nexport interface SinglelineTextLayout {\n  bounds: LayoutBounds;\n  line: TextPosition;\n  fontSize: number;\n}\n\nexport const layoutSinglelineText = (\n  text: string,\n  { alignment, fontSize, font, bounds }: LayoutSinglelineTextOptions,\n): SinglelineTextLayout =\u003e {\n  const line = mergeLines(cleanText(text));\n\n  if (fontSize === undefined || fontSize === 0) {\n    fontSize = computeFontSize([line], font, bounds);\n  }\n\n  const encoded = font.encodeText(line);\n  const width = font.widthOfTextAtSize(line, fontSize);\n  const height = font.heightAtSize(fontSize, { descender: false });\n\n  // prettier-ignore\n  const x = (\n      alignment === TextAlignment.Left   ? bounds.x\n    : alignment === TextAlignment.Center ? bounds.x + (bounds.width / 2) - (width / 2)\n    : alignment === TextAlignment.Right  ? bounds.x + bounds.width - width\n    : bounds.x\n  );\n\n  const y = bounds.y + (bounds.height / 2 - height / 2);\n\n  return {\n    fontSize,\n    line: { text: line, encoded, width, height, x, y },\n    bounds: { x, y, width, height },\n  };\n};\n","import { PDFOperator, PDFWidgetAnnotation } from 'src/core';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFButton from 'src/api/form/PDFButton';\nimport PDFCheckBox from 'src/api/form/PDFCheckBox';\nimport PDFDropdown from 'src/api/form/PDFDropdown';\nimport PDFField from 'src/api/form/PDFField';\nimport PDFOptionList from 'src/api/form/PDFOptionList';\nimport PDFRadioGroup from 'src/api/form/PDFRadioGroup';\nimport PDFSignature from 'src/api/form/PDFSignature';\nimport PDFTextField from 'src/api/form/PDFTextField';\nimport {\n  drawCheckBox,\n  rotateInPlace,\n  drawRadioButton,\n  drawButton,\n  drawTextField,\n  drawOptionList,\n} from 'src/api/operations';\nimport {\n  rgb,\n  componentsToColor,\n  setFillingColor,\n  grayscale,\n  cmyk,\n  Color,\n} from 'src/api/colors';\nimport { reduceRotation, adjustDimsForRotation } from 'src/api/rotations';\nimport {\n  layoutMultilineText,\n  layoutCombedText,\n  TextPosition,\n  layoutSinglelineText,\n} from 'src/api/text/layout';\nimport { TextAlignment } from 'src/api/text/alignment';\nimport { setFontAndSize } from 'src/api/operators';\nimport { findLastMatch } from 'src/utils';\n\n/*********************** Appearance Provider Types ****************************/\n\ntype CheckBoxAppearanceProvider = (\n  checkBox: PDFCheckBox,\n  widget: PDFWidgetAnnotation,\n) =\u003e AppearanceOrMapping\u003c{\n  on: PDFOperator[];\n  off: PDFOperator[];\n}\u003e;\n\ntype RadioGroupAppearanceProvider = (\n  radioGroup: PDFRadioGroup,\n  widget: PDFWidgetAnnotation,\n) =\u003e AppearanceOrMapping\u003c{\n  on: PDFOperator[];\n  off: PDFOperator[];\n}\u003e;\n\ntype ButtonAppearanceProvider = (\n  button: PDFButton,\n  widget: PDFWidgetAnnotation,\n  font: PDFFont,\n) =\u003e AppearanceOrMapping\u003cPDFOperator[]\u003e;\n\ntype DropdownAppearanceProvider = (\n  dropdown: PDFDropdown,\n  widget: PDFWidgetAnnotation,\n  font: PDFFont,\n) =\u003e AppearanceOrMapping\u003cPDFOperator[]\u003e;\n\ntype OptionListAppearanceProvider = (\n  optionList: PDFOptionList,\n  widget: PDFWidgetAnnotation,\n  font: PDFFont,\n) =\u003e AppearanceOrMapping\u003cPDFOperator[]\u003e;\n\ntype TextFieldAppearanceProvider = (\n  textField: PDFTextField,\n  widget: PDFWidgetAnnotation,\n  font: PDFFont,\n) =\u003e AppearanceOrMapping\u003cPDFOperator[]\u003e;\n\ntype SignatureAppearanceProvider = (\n  signature: PDFSignature,\n  widget: PDFWidgetAnnotation,\n  font: PDFFont,\n) =\u003e AppearanceOrMapping\u003cPDFOperator[]\u003e;\n\n/******************* Appearance Provider Utility Types ************************/\n\nexport type AppearanceMapping\u003cT\u003e = { normal: T; rollover?: T; down?: T };\n\ntype AppearanceOrMapping\u003cT\u003e = T | AppearanceMapping\u003cT\u003e;\n\n// prettier-ignore\nexport type AppearanceProviderFor\u003cT extends PDFField\u003e = \n  T extends PDFCheckBox   ? CheckBoxAppearanceProvider\n: T extends PDFRadioGroup ? RadioGroupAppearanceProvider\n: T extends PDFButton     ? ButtonAppearanceProvider\n: T extends PDFDropdown   ? DropdownAppearanceProvider\n: T extends PDFOptionList ? OptionListAppearanceProvider\n: T extends PDFTextField  ? TextFieldAppearanceProvider\n: T extends PDFSignature  ? SignatureAppearanceProvider\n: never;\n\n/********************* Appearance Provider Functions **************************/\n\nexport const normalizeAppearance = \u003cT\u003e(\n  appearance: T | AppearanceMapping\u003cT\u003e,\n): AppearanceMapping\u003cT\u003e =\u003e {\n  if ('normal' in appearance) return appearance;\n  return { normal: appearance };\n};\n\n// Examples:\n//   `/Helv 12 Tf` -\u003e ['/Helv 12 Tf', 'Helv', '12']\n//   `/HeBo 8.00 Tf` -\u003e ['/HeBo 8 Tf', 'HeBo', '8.00']\nconst tfRegex = /\\/([^\\0\\t\\n\\f\\r\\ ]+)[\\0\\t\\n\\f\\r\\ ]+(\\d*\\.\\d+|\\d+)[\\0\\t\\n\\f\\r\\ ]+Tf/;\n\nconst getDefaultFontSize = (field: {\n  getDefaultAppearance(): string | undefined;\n}) =\u003e {\n  const da = field.getDefaultAppearance() ?? '';\n  const daMatch = findLastMatch(da, tfRegex).match ?? [];\n  const defaultFontSize = Number(daMatch[2]);\n  return isFinite(defaultFontSize) ? defaultFontSize : undefined;\n};\n\n// Examples:\n//   `0.3 g` -\u003e ['0.3', 'g']\n//   `0.3 1 .3 rg` -\u003e ['0.3', '1', '.3', 'rg']\n//   `0.3 1 .3 0 k` -\u003e ['0.3', '1', '.3', '0', 'k']\nconst colorRegex = /(\\d*\\.\\d+|\\d+)[\\0\\t\\n\\f\\r\\ ]*(\\d*\\.\\d+|\\d+)?[\\0\\t\\n\\f\\r\\ ]*(\\d*\\.\\d+|\\d+)?[\\0\\t\\n\\f\\r\\ ]*(\\d*\\.\\d+|\\d+)?[\\0\\t\\n\\f\\r\\ ]+(g|rg|k)/;\n\nconst getDefaultColor = (field: {\n  getDefaultAppearance(): string | undefined;\n}) =\u003e {\n  const da = field.getDefaultAppearance() ?? '';\n  const daMatch = findLastMatch(da, colorRegex).match;\n\n  const [, c1, c2, c3, c4, colorSpace] = daMatch ?? [];\n\n  if (colorSpace === 'g' \u0026\u0026 c1) {\n    return grayscale(Number(c1));\n  }\n  if (colorSpace === 'rg' \u0026\u0026 c1 \u0026\u0026 c2 \u0026\u0026 c3) {\n    return rgb(Number(c1), Number(c2), Number(c3));\n  }\n  if (colorSpace === 'k' \u0026\u0026 c1 \u0026\u0026 c2 \u0026\u0026 c3 \u0026\u0026 c4) {\n    return cmyk(Number(c1), Number(c2), Number(c3), Number(c4));\n  }\n\n  return undefined;\n};\n\nconst updateDefaultAppearance = (\n  field: { setDefaultAppearance(appearance: string): void },\n  color: Color,\n  font?: PDFFont,\n  fontSize: number = 0,\n) =\u003e {\n  const da = [\n    setFillingColor(color).toString(),\n    setFontAndSize(font?.name ?? 'dummy__noop', fontSize).toString(),\n  ].join('\\n');\n  field.setDefaultAppearance(da);\n};\n\nexport const defaultCheckBoxAppearanceProvider: AppearanceProviderFor\u003cPDFCheckBox\u003e = (\n  checkBox,\n  widget,\n) =\u003e {\n  // The `/DA` entry can be at the widget or field level - so we handle both\n  const widgetColor = getDefaultColor(widget);\n  const fieldColor = getDefaultColor(checkBox.acroField);\n\n  const rectangle = widget.getRectangle();\n  const ap = widget.getAppearanceCharacteristics();\n  const bs = widget.getBorderStyle();\n\n  const borderWidth = bs?.getWidth() ?? 0;\n  const rotation = reduceRotation(ap?.getRotation());\n  const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n  const rotate = rotateInPlace({ ...rectangle, rotation });\n\n  const black = rgb(0, 0, 0);\n  const borderColor = componentsToColor(ap?.getBorderColor()) ?? black;\n  const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n  const downBackgroundColor = componentsToColor(ap?.getBackgroundColor(), 0.8);\n\n  // Update color\n  const textColor = widgetColor ?? fieldColor ?? black;\n  if (widgetColor) {\n    updateDefaultAppearance(widget, textColor);\n  } else {\n    updateDefaultAppearance(checkBox.acroField, textColor);\n  }\n\n  const options = {\n    x: 0 + borderWidth / 2,\n    y: 0 + borderWidth / 2,\n    width: width - borderWidth,\n    height: height - borderWidth,\n    thickness: 1.5,\n    borderWidth,\n    borderColor,\n    markColor: textColor,\n  };\n\n  return {\n    normal: {\n      on: [\n        ...rotate,\n        ...drawCheckBox({\n          ...options,\n          color: normalBackgroundColor,\n          filled: true,\n        }),\n      ],\n      off: [\n        ...rotate,\n        ...drawCheckBox({\n          ...options,\n          color: normalBackgroundColor,\n          filled: false,\n        }),\n      ],\n    },\n    down: {\n      on: [\n        ...rotate,\n        ...drawCheckBox({\n          ...options,\n          color: downBackgroundColor,\n          filled: true,\n        }),\n      ],\n      off: [\n        ...rotate,\n        ...drawCheckBox({\n          ...options,\n          color: downBackgroundColor,\n          filled: false,\n        }),\n      ],\n    },\n  };\n};\n\nexport const defaultRadioGroupAppearanceProvider: AppearanceProviderFor\u003cPDFRadioGroup\u003e = (\n  radioGroup,\n  widget,\n) =\u003e {\n  // The `/DA` entry can be at the widget or field level - so we handle both\n  const widgetColor = getDefaultColor(widget);\n  const fieldColor = getDefaultColor(radioGroup.acroField);\n\n  const rectangle = widget.getRectangle();\n  const ap = widget.getAppearanceCharacteristics();\n  const bs = widget.getBorderStyle();\n\n  const borderWidth = bs?.getWidth() ?? 0;\n  const rotation = reduceRotation(ap?.getRotation());\n  const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n  const rotate = rotateInPlace({ ...rectangle, rotation });\n\n  const black = rgb(0, 0, 0);\n  const borderColor = componentsToColor(ap?.getBorderColor()) ?? black;\n  const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n  const downBackgroundColor = componentsToColor(ap?.getBackgroundColor(), 0.8);\n\n  // Update color\n  const textColor = widgetColor ?? fieldColor ?? black;\n  if (widgetColor) {\n    updateDefaultAppearance(widget, textColor);\n  } else {\n    updateDefaultAppearance(radioGroup.acroField, textColor);\n  }\n\n  const options = {\n    x: width / 2,\n    y: height / 2,\n    width: width - borderWidth,\n    height: height - borderWidth,\n    borderWidth,\n    borderColor,\n    dotColor: textColor,\n  };\n\n  return {\n    normal: {\n      on: [\n        ...rotate,\n        ...drawRadioButton({\n          ...options,\n          color: normalBackgroundColor,\n          filled: true,\n        }),\n      ],\n      off: [\n        ...rotate,\n        ...drawRadioButton({\n          ...options,\n          color: normalBackgroundColor,\n          filled: false,\n        }),\n      ],\n    },\n    down: {\n      on: [\n        ...rotate,\n        ...drawRadioButton({\n          ...options,\n          color: downBackgroundColor,\n          filled: true,\n        }),\n      ],\n      off: [\n        ...rotate,\n        ...drawRadioButton({\n          ...options,\n          color: downBackgroundColor,\n          filled: false,\n        }),\n      ],\n    },\n  };\n};\n\nexport const defaultButtonAppearanceProvider: AppearanceProviderFor\u003cPDFButton\u003e = (\n  button,\n  widget,\n  font,\n) =\u003e {\n  // The `/DA` entry can be at the widget or field level - so we handle both\n  const widgetColor = getDefaultColor(widget);\n  const fieldColor = getDefaultColor(button.acroField);\n  const widgetFontSize = getDefaultFontSize(widget);\n  const fieldFontSize = getDefaultFontSize(button.acroField);\n\n  const rectangle = widget.getRectangle();\n  const ap = widget.getAppearanceCharacteristics();\n  const bs = widget.getBorderStyle();\n  const captions = ap?.getCaptions();\n  const normalText = captions?.normal ?? '';\n  const downText = captions?.down ?? normalText ?? '';\n\n  const borderWidth = bs?.getWidth() ?? 0;\n  const rotation = reduceRotation(ap?.getRotation());\n  const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n  const rotate = rotateInPlace({ ...rectangle, rotation });\n\n  const black = rgb(0, 0, 0);\n\n  const borderColor = componentsToColor(ap?.getBorderColor());\n  const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n  const downBackgroundColor = componentsToColor(ap?.getBackgroundColor(), 0.8);\n\n  const bounds = {\n    x: borderWidth,\n    y: borderWidth,\n    width: width - borderWidth * 2,\n    height: height - borderWidth * 2,\n  };\n  const normalLayout = layoutSinglelineText(normalText, {\n    alignment: TextAlignment.Center,\n    fontSize: widgetFontSize ?? fieldFontSize,\n    font,\n    bounds,\n  });\n  const downLayout = layoutSinglelineText(downText, {\n    alignment: TextAlignment.Center,\n    fontSize: widgetFontSize ?? fieldFontSize,\n    font,\n    bounds,\n  });\n\n  // Update font size and color\n  const fontSize = Math.min(normalLayout.fontSize, downLayout.fontSize);\n  const textColor = widgetColor ?? fieldColor ?? black;\n  if (widgetColor || widgetFontSize !== undefined) {\n    updateDefaultAppearance(widget, textColor, font, fontSize);\n  } else {\n    updateDefaultAppearance(button.acroField, textColor, font, fontSize);\n  }\n\n  const options = {\n    x: 0 + borderWidth / 2,\n    y: 0 + borderWidth / 2,\n    width: width - borderWidth,\n    height: height - borderWidth,\n    borderWidth,\n    borderColor,\n    textColor,\n    font: font.name,\n    fontSize,\n  };\n\n  return {\n    normal: [\n      ...rotate,\n      ...drawButton({\n        ...options,\n        color: normalBackgroundColor,\n        textLines: [normalLayout.line],\n      }),\n    ],\n    down: [\n      ...rotate,\n      ...drawButton({\n        ...options,\n        color: downBackgroundColor,\n        textLines: [downLayout.line],\n      }),\n    ],\n  };\n};\n\nexport const defaultTextFieldAppearanceProvider: AppearanceProviderFor\u003cPDFTextField\u003e = (\n  textField,\n  widget,\n  font,\n) =\u003e {\n  // The `/DA` entry can be at the widget or field level - so we handle both\n  const widgetColor = getDefaultColor(widget);\n  const fieldColor = getDefaultColor(textField.acroField);\n  const widgetFontSize = getDefaultFontSize(widget);\n  const fieldFontSize = getDefaultFontSize(textField.acroField);\n\n  const rectangle = widget.getRectangle();\n  const ap = widget.getAppearanceCharacteristics();\n  const bs = widget.getBorderStyle();\n  const text = textField.getText() ?? '';\n\n  const borderWidth = bs?.getWidth() ?? 0;\n  const rotation = reduceRotation(ap?.getRotation());\n  const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n  const rotate = rotateInPlace({ ...rectangle, rotation });\n\n  const black = rgb(0, 0, 0);\n\n  const borderColor = componentsToColor(ap?.getBorderColor());\n  const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n\n  let textLines: TextPosition[];\n  let fontSize: number;\n\n  const padding = textField.isCombed() ? 0 : 1;\n  const bounds = {\n    x: borderWidth + padding,\n    y: borderWidth + padding,\n    width: width - (borderWidth + padding) * 2,\n    height: height - (borderWidth + padding) * 2,\n  };\n  if (textField.isMultiline()) {\n    const layout = layoutMultilineText(text, {\n      alignment: textField.getAlignment(),\n      fontSize: widgetFontSize ?? fieldFontSize,\n      font,\n      bounds,\n    });\n    textLines = layout.lines;\n    fontSize = layout.fontSize;\n  } else if (textField.isCombed()) {\n    const layout = layoutCombedText(text, {\n      fontSize: widgetFontSize ?? fieldFontSize,\n      font,\n      bounds,\n      cellCount: textField.getMaxLength() ?? 0,\n    });\n    textLines = layout.cells;\n    fontSize = layout.fontSize;\n  } else {\n    const layout = layoutSinglelineText(text, {\n      alignment: textField.getAlignment(),\n      fontSize: widgetFontSize ?? fieldFontSize,\n      font,\n      bounds,\n    });\n    textLines = [layout.line];\n    fontSize = layout.fontSize;\n  }\n\n  // Update font size and color\n  const textColor = widgetColor ?? fieldColor ?? black;\n  if (widgetColor || widgetFontSize !== undefined) {\n    updateDefaultAppearance(widget, textColor, font, fontSize);\n  } else {\n    updateDefaultAppearance(textField.acroField, textColor, font, fontSize);\n  }\n\n  const options = {\n    x: 0 + borderWidth / 2,\n    y: 0 + borderWidth / 2,\n    width: width - borderWidth,\n    height: height - borderWidth,\n    borderWidth: borderWidth ?? 0,\n    borderColor,\n    textColor,\n    font: font.name,\n    fontSize,\n    color: normalBackgroundColor,\n    textLines,\n    padding,\n  };\n\n  return [...rotate, ...drawTextField(options)];\n};\n\nexport const defaultDropdownAppearanceProvider: AppearanceProviderFor\u003cPDFDropdown\u003e = (\n  dropdown,\n  widget,\n  font,\n) =\u003e {\n  // The `/DA` entry can be at the widget or field level - so we handle both\n  const widgetColor = getDefaultColor(widget);\n  const fieldColor = getDefaultColor(dropdown.acroField);\n  const widgetFontSize = getDefaultFontSize(widget);\n  const fieldFontSize = getDefaultFontSize(dropdown.acroField);\n\n  const rectangle = widget.getRectangle();\n  const ap = widget.getAppearanceCharacteristics();\n  const bs = widget.getBorderStyle();\n  const text = dropdown.getSelected()[0] ?? '';\n\n  const borderWidth = bs?.getWidth() ?? 0;\n  const rotation = reduceRotation(ap?.getRotation());\n  const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n  const rotate = rotateInPlace({ ...rectangle, rotation });\n\n  const black = rgb(0, 0, 0);\n\n  const borderColor = componentsToColor(ap?.getBorderColor());\n  const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n\n  const padding = 1;\n  const bounds = {\n    x: borderWidth + padding,\n    y: borderWidth + padding,\n    width: width - (borderWidth + padding) * 2,\n    height: height - (borderWidth + padding) * 2,\n  };\n  const { line, fontSize } = layoutSinglelineText(text, {\n    alignment: TextAlignment.Left,\n    fontSize: widgetFontSize ?? fieldFontSize,\n    font,\n    bounds,\n  });\n\n  // Update font size and color\n  const textColor = widgetColor ?? fieldColor ?? black;\n  if (widgetColor || widgetFontSize !== undefined) {\n    updateDefaultAppearance(widget, textColor, font, fontSize);\n  } else {\n    updateDefaultAppearance(dropdown.acroField, textColor, font, fontSize);\n  }\n\n  const options = {\n    x: 0 + borderWidth / 2,\n    y: 0 + borderWidth / 2,\n    width: width - borderWidth,\n    height: height - borderWidth,\n    borderWidth: borderWidth ?? 0,\n    borderColor,\n    textColor,\n    font: font.name,\n    fontSize,\n    color: normalBackgroundColor,\n    textLines: [line],\n    padding,\n  };\n\n  return [...rotate, ...drawTextField(options)];\n};\n\nexport const defaultOptionListAppearanceProvider: AppearanceProviderFor\u003cPDFOptionList\u003e = (\n  optionList,\n  widget,\n  font,\n) =\u003e {\n  // The `/DA` entry can be at the widget or field level - so we handle both\n  const widgetColor = getDefaultColor(widget);\n  const fieldColor = getDefaultColor(optionList.acroField);\n  const widgetFontSize = getDefaultFontSize(widget);\n  const fieldFontSize = getDefaultFontSize(optionList.acroField);\n\n  const rectangle = widget.getRectangle();\n  const ap = widget.getAppearanceCharacteristics();\n  const bs = widget.getBorderStyle();\n\n  const borderWidth = bs?.getWidth() ?? 0;\n  const rotation = reduceRotation(ap?.getRotation());\n  const { width, height } = adjustDimsForRotation(rectangle, rotation);\n\n  const rotate = rotateInPlace({ ...rectangle, rotation });\n\n  const black = rgb(0, 0, 0);\n\n  const borderColor = componentsToColor(ap?.getBorderColor());\n  const normalBackgroundColor = componentsToColor(ap?.getBackgroundColor());\n\n  const options = optionList.getOptions();\n  const selected = optionList.getSelected();\n\n  if (optionList.isSorted()) options.sort();\n\n  let text = '';\n  for (let idx = 0, len = options.length; idx \u003c len; idx++) {\n    text += options[idx];\n    if (idx \u003c len - 1) text += '\\n';\n  }\n\n  const padding = 1;\n  const bounds = {\n    x: borderWidth + padding,\n    y: borderWidth + padding,\n    width: width - (borderWidth + padding) * 2,\n    height: height - (borderWidth + padding) * 2,\n  };\n  const { lines, fontSize, lineHeight } = layoutMultilineText(text, {\n    alignment: TextAlignment.Left,\n    fontSize: widgetFontSize ?? fieldFontSize,\n    font,\n    bounds,\n  });\n\n  const selectedLines: number[] = [];\n  for (let idx = 0, len = lines.length; idx \u003c len; idx++) {\n    const line = lines[idx];\n    if (selected.includes(line.text)) selectedLines.push(idx);\n  }\n\n  const blue = rgb(153 / 255, 193 / 255, 218 / 255);\n\n  // Update font size and color\n  const textColor = widgetColor ?? fieldColor ?? black;\n  if (widgetColor || widgetFontSize !== undefined) {\n    updateDefaultAppearance(widget, textColor, font, fontSize);\n  } else {\n    updateDefaultAppearance(optionList.acroField, textColor, font, fontSize);\n  }\n\n  return [\n    ...rotate,\n    ...drawOptionList({\n      x: 0 + borderWidth / 2,\n      y: 0 + borderWidth / 2,\n      width: width - borderWidth,\n      height: height - borderWidth,\n      borderWidth: borderWidth ?? 0,\n      borderColor,\n      textColor,\n      font: font.name,\n      fontSize,\n      color: normalBackgroundColor,\n      textLines: lines,\n      lineHeight,\n      selectedColor: blue,\n      selectedLines,\n      padding,\n    }),\n  ];\n};\n","import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport { PDFPageEmbedder, PDFRef } from 'src/core';\nimport { assertIs } from 'src/utils';\n\n/**\n * Represents a PDF page that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFEmbeddedPage implements Embeddable {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.embedPdf]] and\n   * \u003e [[PDFDocument.embedPage]] methods, which will create instances of\n   * \u003e [[PDFEmbeddedPage]] for you.\n   *\n   * Create an instance of [[PDFEmbeddedPage]] from an existing ref and embedder\n   *\n   * @param ref The unique reference for this embedded page.\n   * @param doc The document to which the embedded page will belong.\n   * @param embedder The embedder that will be used to embed the page.\n   */\n  static of = (ref: PDFRef, doc: PDFDocument, embedder: PDFPageEmbedder) =\u003e\n    new PDFEmbeddedPage(ref, doc, embedder);\n\n  /** The unique reference assigned to this embedded page within the document. */\n  readonly ref: PDFRef;\n\n  /** The document to which this embedded page belongs. */\n  readonly doc: PDFDocument;\n\n  /** The width of this page in pixels. */\n  readonly width: number;\n\n  /** The height of this page in pixels. */\n  readonly height: number;\n\n  private alreadyEmbedded = false;\n  private readonly embedder: PDFPageEmbedder;\n\n  private constructor(\n    ref: PDFRef,\n    doc: PDFDocument,\n    embedder: PDFPageEmbedder,\n  ) {\n    assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n    assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n    assertIs(embedder, 'embedder', [[PDFPageEmbedder, 'PDFPageEmbedder']]);\n\n    this.ref = ref;\n    this.doc = doc;\n    this.width = embedder.width;\n    this.height = embedder.height;\n\n    this.embedder = embedder;\n  }\n\n  /**\n   * Compute the width and height of this page after being scaled by the\n   * given `factor`. For example:\n   * ```js\n   * embeddedPage.width  // =\u003e 500\n   * embeddedPage.height // =\u003e 250\n   *\n   * const scaled = embeddedPage.scale(0.5)\n   * scaled.width  // =\u003e 250\n   * scaled.height // =\u003e 125\n   * ```\n   * This operation is often useful before drawing a page with\n   * [[PDFPage.drawPage]] to compute the `width` and `height` options.\n   * @param factor The factor by which this page should be scaled.\n   * @returns The width and height of the page after being scaled.\n   */\n  scale(factor: number) {\n    assertIs(factor, 'factor', ['number']);\n    return { width: this.width * factor, height: this.height * factor };\n  }\n\n  /**\n   * Get the width and height of this page. For example:\n   * ```js\n   * const { width, height } = embeddedPage.size()\n   * ```\n   * @returns The width and height of the page.\n   */\n  size() {\n    return this.scale(1);\n  }\n\n  /**\n   * \u003e **NOTE:** You probably don't need to call this method directly. The\n   * \u003e [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n   * \u003e automatically ensure all embeddable pages get embedded.\n   *\n   * Embed this embeddable page in its document.\n   *\n   * @returns Resolves when the embedding is complete.\n   */\n  async embed(): Promise\u003cvoid\u003e {\n    if (!this.alreadyEmbedded) {\n      await this.embedder.embedIntoContext(this.doc.context, this.ref);\n      this.alreadyEmbedded = true;\n    }\n  }\n}\n","import Embeddable from 'src/api//Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport {\n  CustomFontEmbedder,\n  PDFHexString,\n  PDFRef,\n  StandardFontEmbedder,\n} from 'src/core';\nimport { assertIs, assertOrUndefined } from 'src/utils';\n\nexport type FontEmbedder = CustomFontEmbedder | StandardFontEmbedder;\n\n/**\n * Represents a font that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFFont implements Embeddable {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.embedFont]] and\n   * \u003e [[PDFDocument.embedStandardFont]] methods, which will create instances\n   * \u003e of [[PDFFont]] for you.\n   *\n   * Create an instance of [[PDFFont]] from an existing ref and embedder\n   *\n   * @param ref The unique reference for this font.\n   * @param doc The document to which the font will belong.\n   * @param embedder The embedder that will be used to embed the font.\n   */\n  static of = (ref: PDFRef, doc: PDFDocument, embedder: FontEmbedder) =\u003e\n    new PDFFont(ref, doc, embedder);\n\n  /** The unique reference assigned to this font within the document. */\n  readonly ref: PDFRef;\n\n  /** The document to which this font belongs. */\n  readonly doc: PDFDocument;\n\n  /** The name of this font. */\n  readonly name: string;\n\n  private modified = true;\n  private readonly embedder: FontEmbedder;\n\n  private constructor(ref: PDFRef, doc: PDFDocument, embedder: FontEmbedder) {\n    assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n    assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n    assertIs(embedder, 'embedder', [\n      [CustomFontEmbedder, 'CustomFontEmbedder'],\n      [StandardFontEmbedder, 'StandardFontEmbedder'],\n    ]);\n\n    this.ref = ref;\n    this.doc = doc;\n    this.name = embedder.fontName;\n\n    this.embedder = embedder;\n  }\n\n  /**\n   * \u003e **NOTE:** You probably don't need to call this method directly. The\n   * \u003e [[PDFPage.drawText]] method will automatically encode the text it is\n   * \u003e given.\n   *\n   * Encodes a string of text in this font.\n   *\n   * @param text The text to be encoded.\n   * @returns The encoded text as a hex string.\n   */\n  encodeText(text: string): PDFHexString {\n    assertIs(text, 'text', ['string']);\n    this.modified = true;\n    return this.embedder.encodeText(text);\n  }\n\n  /**\n   * Measure the width of a string of text drawn in this font at a given size.\n   * For example:\n   * ```js\n   * const width = font.widthOfTextAtSize('Foo Bar Qux Baz', 36)\n   * ```\n   * @param text The string of text to be measured.\n   * @param size The font size to be used for this measurement.\n   * @returns The width of the string of text when drawn in this font at the\n   *          given size.\n   */\n  widthOfTextAtSize(text: string, size: number): number {\n    assertIs(text, 'text', ['string']);\n    assertIs(size, 'size', ['number']);\n    return this.embedder.widthOfTextAtSize(text, size);\n  }\n\n  /**\n   * Measure the height of this font at a given size. For example:\n   * ```js\n   * const height = font.heightAtSize(24)\n   * ```\n   *\n   * The `options.descender` value controls whether or not the font's\n   * descender is included in the height calculation.\n   *\n   * @param size The font size to be used for this measurement.\n   * @param options The options to be used when computing this measurement.\n   * @returns The height of this font at the given size.\n   */\n  heightAtSize(size: number, options?: { descender?: boolean }): number {\n    assertIs(size, 'size', ['number']);\n    assertOrUndefined(options?.descender, 'options.descender', ['boolean']);\n    return this.embedder.heightOfFontAtSize(size, {\n      descender: options?.descender ?? true,\n    });\n  }\n\n  /**\n   * Compute the font size at which this font is a given height. For example:\n   * ```js\n   * const fontSize = font.sizeAtHeight(12)\n   * ```\n   * @param height The height to be used for this calculation.\n   * @returns The font size at which this font is the given height.\n   */\n  sizeAtHeight(height: number): number {\n    assertIs(height, 'height', ['number']);\n    return this.embedder.sizeOfFontAtHeight(height);\n  }\n\n  /**\n   * Get the set of unicode code points that can be represented by this font.\n   * @returns The set of unicode code points supported by this font.\n   */\n  getCharacterSet(): number[] {\n    if (this.embedder instanceof StandardFontEmbedder) {\n      return this.embedder.encoding.supportedCodePoints;\n    } else {\n      return this.embedder.font.characterSet;\n    }\n  }\n\n  /**\n   * \u003e **NOTE:** You probably don't need to call this method directly. The\n   * \u003e [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n   * \u003e automatically ensure all fonts get embedded.\n   *\n   * Embed this font in its document.\n   *\n   * @returns Resolves when the embedding is complete.\n   */\n  async embed(): Promise\u003cvoid\u003e {\n    // TODO: Cleanup orphan embedded objects if a font is embedded multiple times...\n    if (this.modified) {\n      await this.embedder.embedIntoContext(this.doc.context, this.ref);\n      this.modified = false;\n    }\n  }\n}\n","import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport { JpegEmbedder, PDFRef, PngEmbedder } from 'src/core';\nimport { assertIs } from 'src/utils';\n\nexport type ImageEmbedder = JpegEmbedder | PngEmbedder;\n\n/**\n * Represents an image that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFImage implements Embeddable {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.embedPng]] and [[PDFDocument.embedJpg]]\n   * \u003e methods, which will create instances of [[PDFImage]] for you.\n   *\n   * Create an instance of [[PDFImage]] from an existing ref and embedder\n   *\n   * @param ref The unique reference for this image.\n   * @param doc The document to which the image will belong.\n   * @param embedder The embedder that will be used to embed the image.\n   */\n  static of = (ref: PDFRef, doc: PDFDocument, embedder: ImageEmbedder) =\u003e\n    new PDFImage(ref, doc, embedder);\n\n  /** The unique reference assigned to this image within the document. */\n  readonly ref: PDFRef;\n\n  /** The document to which this image belongs. */\n  readonly doc: PDFDocument;\n\n  /** The width of this image in pixels. */\n  readonly width: number;\n\n  /** The height of this image in pixels. */\n  readonly height: number;\n\n  private embedder: ImageEmbedder | undefined;\n  private embedTask: Promise\u003cPDFRef\u003e | undefined;\n\n  private constructor(ref: PDFRef, doc: PDFDocument, embedder: ImageEmbedder) {\n    assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n    assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n    assertIs(embedder, 'embedder', [\n      [JpegEmbedder, 'JpegEmbedder'],\n      [PngEmbedder, 'PngEmbedder'],\n    ]);\n\n    this.ref = ref;\n    this.doc = doc;\n    this.width = embedder.width;\n    this.height = embedder.height;\n\n    this.embedder = embedder;\n  }\n\n  /**\n   * Compute the width and height of this image after being scaled by the\n   * given `factor`. For example:\n   * ```js\n   * image.width  // =\u003e 500\n   * image.height // =\u003e 250\n   *\n   * const scaled = image.scale(0.5)\n   * scaled.width  // =\u003e 250\n   * scaled.height // =\u003e 125\n   * ```\n   * This operation is often useful before drawing an image with\n   * [[PDFPage.drawImage]] to compute the `width` and `height` options.\n   * @param factor The factor by which this image should be scaled.\n   * @returns The width and height of the image after being scaled.\n   */\n  scale(factor: number) {\n    assertIs(factor, 'factor', ['number']);\n    return { width: this.width * factor, height: this.height * factor };\n  }\n\n  /**\n   * Get the width and height of this image after scaling it as large as\n   * possible while maintaining its aspect ratio and not exceeding the\n   * specified `width` and `height`. For example:\n   * ```\n   * image.width  // =\u003e 500\n   * image.height // =\u003e 250\n   *\n   * const scaled = image.scaleToFit(750, 1000)\n   * scaled.width  // =\u003e 750\n   * scaled.height // =\u003e 375\n   * ```\n   * The `width` and `height` parameters can also be thought of as the width\n   * and height of a box that the scaled image must fit within.\n   * @param width The bounding box's width.\n   * @param height The bounding box's height.\n   * @returns The width and height of the image after being scaled.\n   */\n  scaleToFit(width: number, height: number) {\n    assertIs(width, 'width', ['number']);\n    assertIs(height, 'height', ['number']);\n\n    const imgWidthScale = width / this.width;\n    const imgHeightScale = height / this.height;\n    const scale = Math.min(imgWidthScale, imgHeightScale);\n\n    return this.scale(scale);\n  }\n\n  /**\n   * Get the width and height of this image. For example:\n   * ```js\n   * const { width, height } = image.size()\n   * ```\n   * @returns The width and height of the image.\n   */\n  size() {\n    return this.scale(1);\n  }\n\n  /**\n   * \u003e **NOTE:** You probably don't need to call this method directly. The\n   * \u003e [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n   * \u003e automatically ensure all images get embedded.\n   *\n   * Embed this image in its document.\n   *\n   * @returns Resolves when the embedding is complete.\n   */\n  async embed(): Promise\u003cvoid\u003e {\n    if (!this.embedder) return;\n\n    // The image should only be embedded once. If there's a pending embed\n    // operation then wait on it. Otherwise we need to start the embed.\n    if (!this.embedTask) {\n      const { doc, ref } = this;\n      this.embedTask = this.embedder.embedIntoContext(doc.context, ref);\n    }\n    await this.embedTask;\n\n    // We clear `this.embedder` so that the indirectly referenced image data\n    // can be garbage collected, thus avoiding a memory leak.\n    // See https://github.com/Hopding/pdf-lib/pull/1032/files.\n    this.embedder = undefined;\n  }\n}\n","export enum ImageAlignment {\n  Left = 0,\n  Center = 1,\n  Right = 2,\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFFont from 'src/api/PDFFont';\nimport { AppearanceMapping } from 'src/api/form/appearances';\nimport { Color, colorToComponents, setFillingColor } from 'src/api/colors';\nimport {\n  Rotation,\n  toDegrees,\n  rotateRectangle,\n  reduceRotation,\n  adjustDimsForRotation,\n  degrees,\n} from 'src/api/rotations';\n\nimport {\n  PDFRef,\n  PDFWidgetAnnotation,\n  PDFOperator,\n  PDFName,\n  PDFDict,\n  MethodNotImplementedError,\n  AcroFieldFlags,\n  PDFAcroTerminal,\n  AnnotationFlags,\n} from 'src/core';\nimport { assertIs, assertMultiple, assertOrUndefined } from 'src/utils';\nimport { ImageAlignment } from '../image';\nimport PDFImage from '../PDFImage';\nimport { drawImage, rotateInPlace } from '../operations';\n\nexport interface FieldAppearanceOptions {\n  x?: number;\n  y?: number;\n  width?: number;\n  height?: number;\n  textColor?: Color;\n  backgroundColor?: Color;\n  borderColor?: Color;\n  borderWidth?: number;\n  rotate?: Rotation;\n  font?: PDFFont;\n  hidden?: boolean;\n}\n\nexport const assertFieldAppearanceOptions = (\n  options?: FieldAppearanceOptions,\n) =\u003e {\n  assertOrUndefined(options?.x, 'options.x', ['number']);\n  assertOrUndefined(options?.y, 'options.y', ['number']);\n  assertOrUndefined(options?.width, 'options.width', ['number']);\n  assertOrUndefined(options?.height, 'options.height', ['number']);\n  assertOrUndefined(options?.textColor, 'options.textColor', [\n    [Object, 'Color'],\n  ]);\n  assertOrUndefined(options?.backgroundColor, 'options.backgroundColor', [\n    [Object, 'Color'],\n  ]);\n  assertOrUndefined(options?.borderColor, 'options.borderColor', [\n    [Object, 'Color'],\n  ]);\n  assertOrUndefined(options?.borderWidth, 'options.borderWidth', ['number']);\n  assertOrUndefined(options?.rotate, 'options.rotate', [[Object, 'Rotation']]);\n};\n\n/**\n * Represents a field of a [[PDFForm]].\n *\n * This class is effectively abstract. All fields in a [[PDFForm]] will\n * actually be an instance of a subclass of this class.\n *\n * Note that each field in a PDF is represented by a single field object.\n * However, a given field object may be rendered at multiple locations within\n * the document (across one or more pages). The rendering of a field is\n * controlled by its widgets. Each widget causes its field to be displayed at a\n * particular location in the document.\n *\n * Most of the time each field in a PDF has only a single widget, and thus is\n * only rendered once. However, if a field is rendered multiple times, it will\n * have multiple widgets - one for each location it is rendered.\n *\n * This abstraction of field objects and widgets is defined in the PDF\n * specification and dictates how PDF files store fields and where they are\n * to be rendered.\n */\nexport default class PDFField {\n  /** The low-level PDFAcroTerminal wrapped by this field. */\n  readonly acroField: PDFAcroTerminal;\n\n  /** The unique reference assigned to this field within the document. */\n  readonly ref: PDFRef;\n\n  /** The document to which this field belongs. */\n  readonly doc: PDFDocument;\n\n  protected constructor(\n    acroField: PDFAcroTerminal,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) {\n    assertIs(acroField, 'acroField', [[PDFAcroTerminal, 'PDFAcroTerminal']]);\n    assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n    assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n\n    this.acroField = acroField;\n    this.ref = ref;\n    this.doc = doc;\n  }\n\n  /**\n   * Get the fully qualified name of this field. For example:\n   * ```js\n   * const fields = form.getFields()\n   * fields.forEach(field =\u003e {\n   *   const name = field.getName()\n   *   console.log('Field name:', name)\n   * })\n   * ```\n   * Note that PDF fields are structured as a tree. Each field is the\n   * descendent of a series of ancestor nodes all the way up to the form node,\n   * which is always the root of the tree. Each node in the tree (except for\n   * the form node) has a partial name. Partial names can be composed of any\n   * unicode characters except a period (`.`). The fully qualified name of a\n   * field is composed of the partial names of all its ancestors joined\n   * with periods. This means that splitting the fully qualified name on\n   * periods and taking the last element of the resulting array will give you\n   * the partial name of a specific field.\n   * @returns The fully qualified name of this field.\n   */\n  getName(): string {\n    return this.acroField.getFullyQualifiedName() ?? '';\n  }\n\n  /**\n   * Returns `true` if this field is read only. This means that PDF readers\n   * will not allow users to interact with the field or change its value. See\n   * [[PDFField.enableReadOnly]] and [[PDFField.disableReadOnly]].\n   * For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * if (field.isReadOnly()) console.log('Read only is enabled')\n   * ```\n   * @returns Whether or not this is a read only field.\n   */\n  isReadOnly(): boolean {\n    return this.acroField.hasFlag(AcroFieldFlags.ReadOnly);\n  }\n\n  /**\n   * Prevent PDF readers from allowing users to interact with this field or\n   * change its value. The field will not respond to mouse or keyboard input.\n   * For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * field.enableReadOnly()\n   * ```\n   * Useful for fields whose values are computed, imported from a database, or\n   * prefilled by software before being displayed to the user.\n   */\n  enableReadOnly() {\n    this.acroField.setFlagTo(AcroFieldFlags.ReadOnly, true);\n  }\n\n  /**\n   * Allow users to interact with this field and change its value in PDF\n   * readers via mouse and keyboard input. For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * field.disableReadOnly()\n   * ```\n   */\n  disableReadOnly() {\n    this.acroField.setFlagTo(AcroFieldFlags.ReadOnly, false);\n  }\n\n  /**\n   * Returns `true` if this field must have a value when the form is submitted.\n   * See [[PDFField.enableRequired]] and [[PDFField.disableRequired]].\n   * For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * if (field.isRequired()) console.log('Field is required')\n   * ```\n   * @returns Whether or not this field is required.\n   */\n  isRequired(): boolean {\n    return this.acroField.hasFlag(AcroFieldFlags.Required);\n  }\n\n  /**\n   * Require this field to have a value when the form is submitted.\n   * For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * field.enableRequired()\n   * ```\n   */\n  enableRequired() {\n    this.acroField.setFlagTo(AcroFieldFlags.Required, true);\n  }\n\n  /**\n   * Do not require this field to have a value when the form is submitted.\n   * For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * field.disableRequired()\n   * ```\n   */\n  disableRequired() {\n    this.acroField.setFlagTo(AcroFieldFlags.Required, false);\n  }\n\n  /**\n   * Returns `true` if this field's value should be exported when the form is\n   * submitted. See [[PDFField.enableExporting]] and\n   * [[PDFField.disableExporting]].\n   * For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * if (field.isExported()) console.log('Exporting is enabled')\n   * ```\n   * @returns Whether or not this field's value should be exported.\n   */\n  isExported(): boolean {\n    return !this.acroField.hasFlag(AcroFieldFlags.NoExport);\n  }\n\n  /**\n   * Indicate that this field's value should be exported when the form is\n   * submitted in a PDF reader. For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * field.enableExporting()\n   * ```\n   */\n  enableExporting() {\n    this.acroField.setFlagTo(AcroFieldFlags.NoExport, false);\n  }\n\n  /**\n   * Indicate that this field's value should **not** be exported when the form\n   * is submitted in a PDF reader. For example:\n   * ```js\n   * const field = form.getField('some.field')\n   * field.disableExporting()\n   * ```\n   */\n  disableExporting() {\n    this.acroField.setFlagTo(AcroFieldFlags.NoExport, true);\n  }\n\n  /** @ignore */\n  needsAppearancesUpdate(): boolean {\n    throw new MethodNotImplementedError(\n      this.constructor.name,\n      'needsAppearancesUpdate',\n    );\n  }\n\n  /** @ignore */\n  defaultUpdateAppearances(_font: PDFFont) {\n    throw new MethodNotImplementedError(\n      this.constructor.name,\n      'defaultUpdateAppearances',\n    );\n  }\n\n  protected markAsDirty() {\n    this.doc.getForm().markFieldAsDirty(this.ref);\n  }\n\n  protected markAsClean() {\n    this.doc.getForm().markFieldAsClean(this.ref);\n  }\n\n  protected isDirty(): boolean {\n    return this.doc.getForm().fieldIsDirty(this.ref);\n  }\n\n  protected createWidget(options: {\n    x: number;\n    y: number;\n    width: number;\n    height: number;\n    textColor?: Color;\n    backgroundColor?: Color;\n    borderColor?: Color;\n    borderWidth: number;\n    rotate: Rotation;\n    caption?: string;\n    hidden?: boolean;\n    page?: PDFRef;\n  }): PDFWidgetAnnotation {\n    const textColor = options.textColor;\n    const backgroundColor = options.backgroundColor;\n    const borderColor = options.borderColor;\n    const borderWidth = options.borderWidth;\n    const degreesAngle = toDegrees(options.rotate);\n    const caption = options.caption;\n    const x = options.x;\n    const y = options.y;\n    const width = options.width + borderWidth;\n    const height = options.height + borderWidth;\n    const hidden = Boolean(options.hidden);\n    const pageRef = options.page;\n\n    assertMultiple(degreesAngle, 'degreesAngle', 90);\n\n    // Create a widget for this field\n    const widget = PDFWidgetAnnotation.create(this.doc.context, this.ref);\n\n    // Set widget properties\n    const rect = rotateRectangle(\n      { x, y, width, height },\n      borderWidth,\n      degreesAngle,\n    );\n    widget.setRectangle(rect);\n\n    if (pageRef) widget.setP(pageRef);\n\n    const ac = widget.getOrCreateAppearanceCharacteristics();\n    if (backgroundColor) {\n      ac.setBackgroundColor(colorToComponents(backgroundColor));\n    }\n    ac.setRotation(degreesAngle);\n    if (caption) ac.setCaptions({ normal: caption });\n    if (borderColor) ac.setBorderColor(colorToComponents(borderColor));\n\n    const bs = widget.getOrCreateBorderStyle();\n    if (borderWidth !== undefined) bs.setWidth(borderWidth);\n\n    widget.setFlagTo(AnnotationFlags.Print, true);\n    widget.setFlagTo(AnnotationFlags.Hidden, hidden);\n    widget.setFlagTo(AnnotationFlags.Invisible, false);\n\n    // Set acrofield properties\n    if (textColor) {\n      const da = this.acroField.getDefaultAppearance() ?? '';\n      const newDa = da + '\\n' + setFillingColor(textColor).toString();\n      this.acroField.setDefaultAppearance(newDa);\n    }\n\n    return widget;\n  }\n\n  protected updateWidgetAppearanceWithFont(\n    widget: PDFWidgetAnnotation,\n    font: PDFFont,\n    { normal, rollover, down }: AppearanceMapping\u003cPDFOperator[]\u003e,\n  ) {\n    this.updateWidgetAppearances(widget, {\n      normal: this.createAppearanceStream(widget, normal, font),\n      rollover: rollover \u0026\u0026 this.createAppearanceStream(widget, rollover, font),\n      down: down \u0026\u0026 this.createAppearanceStream(widget, down, font),\n    });\n  }\n\n  protected updateOnOffWidgetAppearance(\n    widget: PDFWidgetAnnotation,\n    onValue: PDFName,\n    {\n      normal,\n      rollover,\n      down,\n    }: AppearanceMapping\u003c{ on: PDFOperator[]; off: PDFOperator[] }\u003e,\n  ) {\n    this.updateWidgetAppearances(widget, {\n      normal: this.createAppearanceDict(widget, normal, onValue),\n      rollover:\n        rollover \u0026\u0026 this.createAppearanceDict(widget, rollover, onValue),\n      down: down \u0026\u0026 this.createAppearanceDict(widget, down, onValue),\n    });\n  }\n\n  protected updateWidgetAppearances(\n    widget: PDFWidgetAnnotation,\n    { normal, rollover, down }: AppearanceMapping\u003cPDFRef | PDFDict\u003e,\n  ) {\n    widget.setNormalAppearance(normal);\n\n    if (rollover) {\n      widget.setRolloverAppearance(rollover);\n    } else {\n      widget.removeRolloverAppearance();\n    }\n\n    if (down) {\n      widget.setDownAppearance(down);\n    } else {\n      widget.removeDownAppearance();\n    }\n  }\n\n  // // TODO: Do we need to do this...?\n  // private foo(font: PDFFont, dict: PDFDict) {\n  //   if (!dict.lookup(PDFName.of('DR'))) {\n  //     dict.set(PDFName.of('DR'), dict.context.obj({}));\n  //   }\n  //   const DR = dict.lookup(PDFName.of('DR'), PDFDict);\n\n  //   if (!DR.lookup(PDFName.of('Font'))) {\n  //     DR.set(PDFName.of('Font'), dict.context.obj({}));\n  //   }\n  //   const Font = DR.lookup(PDFName.of('Font'), PDFDict);\n\n  //   Font.set(PDFName.of(font.name), font.ref);\n  // }\n\n  private createAppearanceStream(\n    widget: PDFWidgetAnnotation,\n    appearance: PDFOperator[],\n    font?: PDFFont,\n  ): PDFRef {\n    const { context } = this.acroField.dict;\n    const { width, height } = widget.getRectangle();\n\n    // TODO: Do we need to do this...?\n    // if (font) {\n    //   this.foo(font, widget.dict);\n    //   this.foo(font, this.doc.getForm().acroForm.dict);\n    // }\n    // END TODO\n\n    const Resources = font \u0026\u0026 { Font: { [font.name]: font.ref } };\n    const stream = context.formXObject(appearance, {\n      Resources,\n      BBox: context.obj([0, 0, width, height]),\n      Matrix: context.obj([1, 0, 0, 1, 0, 0]),\n    });\n    const streamRef = context.register(stream);\n\n    return streamRef;\n  }\n\n  /**\n   * Create a FormXObject of the supplied image and add it to context.\n   * The FormXObject size is calculated based on the widget (including\n   * the alignment).\n   * @param widget The widget that should display the image.\n   * @param alignment The alignment of the image.\n   * @param image The image that should be displayed.\n   * @returns The ref for the FormXObject that was added to the context.\n   */\n  protected createImageAppearanceStream(\n    widget: PDFWidgetAnnotation,\n    image: PDFImage,\n    alignment: ImageAlignment,\n  ): PDFRef {\n    // NOTE: This implementation doesn't handle image borders.\n    // NOTE: Acrobat seems to resize the image (maybe even skewing its aspect\n    //       ratio) to fit perfectly within the widget's rectangle. This method\n    //       does not currently do that. Should there be an option for that?\n\n    const { context } = this.acroField.dict;\n\n    const rectangle = widget.getRectangle();\n    const ap = widget.getAppearanceCharacteristics();\n    const bs = widget.getBorderStyle();\n\n    const borderWidth = bs?.getWidth() ?? 0;\n    const rotation = reduceRotation(ap?.getRotation());\n\n    const rotate = rotateInPlace({ ...rectangle, rotation });\n\n    const adj = adjustDimsForRotation(rectangle, rotation);\n    const imageDims = image.scaleToFit(\n      adj.width - borderWidth * 2,\n      adj.height - borderWidth * 2,\n    );\n\n    // Support borders on images and maybe other properties\n    const options = {\n      x: borderWidth,\n      y: borderWidth,\n      width: imageDims.width,\n      height: imageDims.height,\n      //\n      rotate: degrees(0),\n      xSkew: degrees(0),\n      ySkew: degrees(0),\n    };\n\n    if (alignment === ImageAlignment.Center) {\n      options.x += (adj.width - borderWidth * 2) / 2 - imageDims.width / 2;\n      options.y += (adj.height - borderWidth * 2) / 2 - imageDims.height / 2;\n    } else if (alignment === ImageAlignment.Right) {\n      options.x = adj.width - borderWidth - imageDims.width;\n      options.y = adj.height - borderWidth - imageDims.height;\n    }\n\n    const imageName = this.doc.context.addRandomSuffix('Image', 10);\n    const appearance = [...rotate, ...drawImage(imageName, options)];\n    ////////////\n\n    const Resources = { XObject: { [imageName]: image.ref } };\n    const stream = context.formXObject(appearance, {\n      Resources,\n      BBox: context.obj([0, 0, rectangle.width, rectangle.height]),\n      Matrix: context.obj([1, 0, 0, 1, 0, 0]),\n    });\n\n    return context.register(stream);\n  }\n\n  private createAppearanceDict(\n    widget: PDFWidgetAnnotation,\n    appearance: { on: PDFOperator[]; off: PDFOperator[] },\n    onValue: PDFName,\n  ): PDFDict {\n    const { context } = this.acroField.dict;\n\n    const onStreamRef = this.createAppearanceStream(widget, appearance.on);\n    const offStreamRef = this.createAppearanceStream(widget, appearance.off);\n\n    const appearanceDict = context.obj({});\n    appearanceDict.set(onValue, onStreamRef);\n    appearanceDict.set(PDFName.of('Off'), offStreamRef);\n\n    return appearanceDict;\n  }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport {\n  AppearanceProviderFor,\n  normalizeAppearance,\n  defaultCheckBoxAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\nimport PDFField, {\n  FieldAppearanceOptions,\n  assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\n\nimport {\n  PDFName,\n  PDFRef,\n  PDFDict,\n  PDFAcroCheckBox,\n  PDFWidgetAnnotation,\n} from 'src/core';\nimport { assertIs, assertOrUndefined } from 'src/utils';\n\n/**\n * Represents a check box field of a [[PDFForm]].\n *\n * [[PDFCheckBox]] fields are interactive boxes that users can click with their\n * mouse. This type of [[PDFField]] has two states: `on` and `off`. The purpose\n * of a check box is to enable users to select from one or more options, where\n * each option is represented by a single check box. Check boxes are typically\n * square in shape and display a check mark when they are in the `on` state.\n */\nexport default class PDFCheckBox extends PDFField {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFForm.getCheckBox]] method, which will create an\n   * \u003e instance of [[PDFCheckBox]] for you.\n   *\n   * Create an instance of [[PDFCheckBox]] from an existing acroCheckBox and ref\n   *\n   * @param acroCheckBox The underlying `PDFAcroCheckBox` for this check box.\n   * @param ref The unique reference for this check box.\n   * @param doc The document to which this check box will belong.\n   */\n  static of = (acroCheckBox: PDFAcroCheckBox, ref: PDFRef, doc: PDFDocument) =\u003e\n    new PDFCheckBox(acroCheckBox, ref, doc);\n\n  /** The low-level PDFAcroCheckBox wrapped by this check box. */\n  readonly acroField: PDFAcroCheckBox;\n\n  private constructor(\n    acroCheckBox: PDFAcroCheckBox,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) {\n    super(acroCheckBox, ref, doc);\n\n    assertIs(acroCheckBox, 'acroCheckBox', [\n      [PDFAcroCheckBox, 'PDFAcroCheckBox'],\n    ]);\n\n    this.acroField = acroCheckBox;\n  }\n\n  /**\n   * Mark this check box. This operation is analogous to a human user clicking\n   * a check box to fill it in a PDF reader. This method will update the\n   * underlying state of the check box field to indicate it has been selected.\n   * PDF libraries and readers will be able to extract this value from the\n   * saved document and determine that it was selected.\n   *\n   * For example:\n   * ```js\n   * const checkBox = form.getCheckBox('some.checkBox.field')\n   * checkBox.check()\n   * ```\n   *\n   * This method will mark this check box as dirty, causing its appearance\n   * streams to be updated when either [[PDFDocument.save]] or\n   * [[PDFForm.updateFieldAppearances]] is called. The updated appearance\n   * streams will display a check mark inside the widgets of this check box\n   * field.\n   */\n  check() {\n    const onValue = this.acroField.getOnValue() ?? PDFName.of('Yes');\n    this.markAsDirty();\n    this.acroField.setValue(onValue);\n  }\n\n  /**\n   * Clears this check box. This operation is analogous to a human user clicking\n   * a check box to unmark it in a PDF reader. This method will update the\n   * underlying state of the check box field to indicate it has been deselected.\n   * PDF libraries and readers will be able to extract this value from the\n   * saved document and determine that it was not selected.\n   *\n   * For example:\n   * ```js\n   * const checkBox = form.getCheckBox('some.checkBox.field')\n   * checkBox.uncheck()\n   * ```\n   *\n   * This method will mark this check box as dirty. See [[PDFCheckBox.check]]\n   * for more details about what this means.\n   */\n  uncheck() {\n    this.markAsDirty();\n    this.acroField.setValue(PDFName.of('Off'));\n  }\n\n  /**\n   * Returns `true` if this check box is selected (either by a human user via\n   * a PDF reader, or else programmatically via software). For example:\n   * ```js\n   * const checkBox = form.getCheckBox('some.checkBox.field')\n   * if (checkBox.isChecked()) console.log('check box is selected')\n   * ```\n   * @returns Whether or not this check box is selected.\n   */\n  isChecked(): boolean {\n    const onValue = this.acroField.getOnValue();\n    return !!onValue \u0026\u0026 onValue === this.acroField.getValue();\n  }\n\n  /**\n   * Show this check box on the specified page. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const checkBox = form.createCheckBox('some.checkBox.field')\n   *\n   * checkBox.addToPage(page, {\n   *   x: 50,\n   *   y: 75,\n   *   width: 25,\n   *   height: 25,\n   *   textColor: rgb(1, 0, 0),\n   *   backgroundColor: rgb(0, 1, 0),\n   *   borderColor: rgb(0, 0, 1),\n   *   borderWidth: 2,\n   *   rotate: degrees(90),\n   * })\n   * ```\n   * This will create a new widget for this check box field.\n   * @param page The page to which this check box widget should be added.\n   * @param options The options to be used when adding this check box widget.\n   */\n  addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n    assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n    assertFieldAppearanceOptions(options);\n\n    if (!options) options = {};\n\n    if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n    if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n    if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n    if (!('borderWidth' in options)) options.borderWidth = 1;\n\n    // Create a widget for this check box\n    const widget = this.createWidget({\n      x: options.x ?? 0,\n      y: options.y ?? 0,\n      width: options.width ?? 50,\n      height: options.height ?? 50,\n      textColor: options.textColor,\n      backgroundColor: options.backgroundColor,\n      borderColor: options.borderColor,\n      borderWidth: options.borderWidth ?? 0,\n      rotate: options.rotate ?? degrees(0),\n      hidden: options.hidden,\n      page: page.ref,\n    });\n    const widgetRef = this.doc.context.register(widget.dict);\n\n    // Add widget to this field\n    this.acroField.addWidget(widgetRef);\n\n    // Set appearance streams for widget\n    widget.setAppearanceState(PDFName.of('Off'));\n    this.updateWidgetAppearance(widget, PDFName.of('Yes'));\n\n    // Add widget to the given page\n    page.node.addAnnot(widgetRef);\n  }\n\n  /**\n   * Returns `true` if any of this check box's widgets do not have an\n   * appearance stream for its current state. For example:\n   * ```js\n   * const checkBox = form.getCheckBox('some.checkBox.field')\n   * if (checkBox.needsAppearancesUpdate()) console.log('Needs update')\n   * ```\n   * @returns Whether or not this check box needs an appearance update.\n   */\n  needsAppearancesUpdate(): boolean {\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const state = widget.getAppearanceState();\n      const normal = widget.getAppearances()?.normal;\n\n      if (!(normal instanceof PDFDict)) return true;\n      if (state \u0026\u0026 !normal.has(state)) return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * Update the appearance streams for each of this check box's widgets using\n   * the default appearance provider for check boxes. For example:\n   * ```js\n   * const checkBox = form.getCheckBox('some.checkBox.field')\n   * checkBox.defaultUpdateAppearances()\n   * ```\n   */\n  defaultUpdateAppearances() {\n    this.updateAppearances();\n  }\n\n  /**\n   * Update the appearance streams for each of this check box's widgets using\n   * the given appearance provider. If no `provider` is passed, the default\n   * appearance provider for check boxs will be used. For example:\n   * ```js\n   * const checkBox = form.getCheckBox('some.checkBox.field')\n   * checkBox.updateAppearances((field, widget) =\u003e {\n   *   ...\n   *   return {\n   *     normal: { on: drawCheckBox(...), off: drawCheckBox(...) },\n   *     down: { on: drawCheckBox(...), off: drawCheckBox(...) },\n   *   }\n   * })\n   * ```\n   * @param provider Optionally, the appearance provider to be used for\n   *                 generating the contents of the appearance streams.\n   */\n  updateAppearances(provider?: AppearanceProviderFor\u003cPDFCheckBox\u003e) {\n    assertOrUndefined(provider, 'provider', [Function]);\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const onValue = widget.getOnValue() ?? PDFName.of('Yes');\n      if (!onValue) continue;\n      this.updateWidgetAppearance(widget, onValue, provider);\n    }\n    this.markAsClean();\n  }\n\n  private updateWidgetAppearance(\n    widget: PDFWidgetAnnotation,\n    onValue: PDFName,\n    provider?: AppearanceProviderFor\u003cPDFCheckBox\u003e,\n  ) {\n    const apProvider = provider ?? defaultCheckBoxAppearanceProvider;\n    const appearances = normalizeAppearance(apProvider(this, widget));\n    this.updateOnOffWidgetAppearance(widget, onValue, appearances);\n  }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFField, {\n  FieldAppearanceOptions,\n  assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n  AppearanceProviderFor,\n  normalizeAppearance,\n  defaultDropdownAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n  PDFHexString,\n  PDFRef,\n  PDFString,\n  PDFStream,\n  PDFWidgetAnnotation,\n  PDFAcroComboBox,\n  AcroChoiceFlags,\n} from 'src/core';\nimport { assertIs, assertOrUndefined, assertPositive } from 'src/utils';\n\n/**\n * Represents a dropdown field of a [[PDFForm]].\n *\n * [[PDFDropdown]] fields are interactive text boxes that display a single\n * element (the currently selected value). The purpose of a dropdown is to\n * enable users to select a single option from a set of possible options. Users\n * can click on a dropdown to view the full list of options it provides.\n * Clicking on an option in the list will cause it to be selected and displayed\n * in the dropdown's text box. Some dropdowns allow users to enter text\n * directly into the box from their keyboard, rather than only being allowed to\n * choose an option from the list (see [[PDFDropdown.isEditable]]).\n */\nexport default class PDFDropdown extends PDFField {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFForm.getDropdown]] method, which will create an\n   * \u003e instance of [[PDFDropdown]] for you.\n   *\n   * Create an instance of [[PDFDropdown]] from an existing acroComboBox and ref\n   *\n   * @param acroComboBox The underlying `PDFAcroComboBox` for this dropdown.\n   * @param ref The unique reference for this dropdown.\n   * @param doc The document to which this dropdown will belong.\n   */\n  static of = (acroComboBox: PDFAcroComboBox, ref: PDFRef, doc: PDFDocument) =\u003e\n    new PDFDropdown(acroComboBox, ref, doc);\n\n  /** The low-level PDFAcroComboBox wrapped by this dropdown. */\n  readonly acroField: PDFAcroComboBox;\n\n  private constructor(\n    acroComboBox: PDFAcroComboBox,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) {\n    super(acroComboBox, ref, doc);\n\n    assertIs(acroComboBox, 'acroComboBox', [\n      [PDFAcroComboBox, 'PDFAcroComboBox'],\n    ]);\n\n    this.acroField = acroComboBox;\n  }\n\n  /**\n   * Get the list of available options for this dropdown. These options will be\n   * displayed to users who click on this dropdown in a PDF reader.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * const options = dropdown.getOptions()\n   * console.log('Dropdown options:', options)\n   * ```\n   * @returns The options for this dropdown.\n   */\n  getOptions(): string[] {\n    const rawOptions = this.acroField.getOptions();\n\n    const options = new Array\u003cstring\u003e(rawOptions.length);\n    for (let idx = 0, len = options.length; idx \u003c len; idx++) {\n      const { display, value } = rawOptions[idx];\n      options[idx] = (display ?? value).decodeText();\n    }\n\n    return options;\n  }\n\n  /**\n   * Get the selected options for this dropdown. These are the values that were\n   * selected by a human user via a PDF reader, or programatically via\n   * software.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * const selections = dropdown.getSelected()\n   * console.log('Dropdown selections:', selections)\n   * ```\n   * \u003e **NOTE:** Note that PDF readers only display one selected option when\n   * \u003e rendering dropdowns. However, the PDF specification does allow for\n   * \u003e multiple values to be selected in a dropdown. As such, the `pdf-lib`\n   * \u003e API supports this. However, in most cases the array returned by this\n   * \u003e method will contain only a single element (or no elements).\n   * @returns The selected options in this dropdown.\n   */\n  getSelected(): string[] {\n    const values = this.acroField.getValues();\n\n    const selected = new Array\u003cstring\u003e(values.length);\n    for (let idx = 0, len = values.length; idx \u003c len; idx++) {\n      selected[idx] = values[idx].decodeText();\n    }\n\n    return selected;\n  }\n\n  /**\n   * Set the list of options that are available for this dropdown. These are\n   * the values that will be available for users to select when they view this\n   * dropdown in a PDF reader. Note that preexisting options for this dropdown\n   * will be removed. Only the values passed as `options` will be available to\n   * select.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('planets.dropdown')\n   * dropdown.setOptions(['Earth', 'Mars', 'Pluto', 'Venus'])\n   * ```\n   * @param options The options that should be available in this dropdown.\n   */\n  setOptions(options: string[]) {\n    assertIs(options, 'options', [Array]);\n\n    const optionObjects = new Array\u003c{ value: PDFHexString }\u003e(options.length);\n    for (let idx = 0, len = options.length; idx \u003c len; idx++) {\n      optionObjects[idx] = { value: PDFHexString.fromText(options[idx]) };\n    }\n    this.acroField.setOptions(optionObjects);\n  }\n\n  /**\n   * Add to the list of options that are available for this dropdown. Users\n   * will be able to select these values in a PDF reader. In addition to the\n   * values passed as `options`, any preexisting options for this dropdown will\n   * still be available for users to select.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('rockets.dropdown')\n   * dropdown.addOptions(['Saturn IV', 'Falcon Heavy'])\n   * ```\n   * @param options New options that should be available in this dropdown.\n   */\n  addOptions(options: string | string[]) {\n    assertIs(options, 'options', ['string', Array]);\n\n    const optionsArr = Array.isArray(options) ? options : [options];\n\n    const existingOptions: {\n      value: PDFString | PDFHexString;\n      display?: PDFString | PDFHexString;\n    }[] = this.acroField.getOptions();\n\n    const newOptions = new Array\u003c{ value: PDFHexString }\u003e(optionsArr.length);\n    for (let idx = 0, len = optionsArr.length; idx \u003c len; idx++) {\n      newOptions[idx] = { value: PDFHexString.fromText(optionsArr[idx]) };\n    }\n\n    this.acroField.setOptions(existingOptions.concat(newOptions));\n  }\n\n  /**\n   * Select one or more values for this dropdown. This operation is analogous\n   * to a human user opening the dropdown in a PDF reader and clicking on a\n   * value to select it. This method will update the underlying state of the\n   * dropdown to indicate which values have been selected. PDF libraries and\n   * readers will be able to extract these values from the saved document and\n   * determine which values were selected.\n   *\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('best.superhero.dropdown')\n   * dropdown.select('One Punch Man')\n   * ```\n   *\n   * This method will mark this dropdown as dirty, causing its appearance\n   * streams to be updated when either [[PDFDocument.save]] or\n   * [[PDFForm.updateFieldAppearances]] is called. The updated streams will\n   * display the selected option inside the widgets of this dropdown.\n   *\n   * **IMPORTANT:** The default font used to update appearance streams is\n   * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n   * that encoding errors will be thrown if the selected option for this field\n   * contains characters outside the WinAnsi character set (the latin alphabet).\n   *\n   * Embedding a custom font and passing it to\n   * [[PDFForm.updateFieldAppearances]] or [[PDFDropdown.updateAppearances]]\n   * allows you to generate appearance streams with characters outside the\n   * latin alphabet (assuming the custom font supports them).\n   *\n   * Selecting an option that does not exist in this dropdown's option list\n   * (see [[PDFDropdown.getOptions]]) will enable editing on this dropdown\n   * (see [[PDFDropdown.enableEditing]]).\n   *\n   * \u003e **NOTE:** PDF readers only display one selected option when rendering\n   * \u003e dropdowns. However, the PDF specification does allow for multiple values\n   * \u003e to be selected in a dropdown. As such, the `pdf-lib` API supports this.\n   * \u003e However, it is not recommended to select more than one value with this\n   * \u003e method, as only one will be visible. [[PDFOptionList]] fields are better\n   * \u003e suited for displaying multiple selected values.\n   *\n   * @param options The options to be selected.\n   * @param merge Whether or not existing selections should be preserved.\n   */\n  select(options: string | string[], merge = false) {\n    assertIs(options, 'options', ['string', Array]);\n    assertIs(merge, 'merge', ['boolean']);\n\n    const optionsArr = Array.isArray(options) ? options : [options];\n\n    const validOptions = this.getOptions();\n    const hasCustomOption = optionsArr.find(\n      (option) =\u003e !validOptions.includes(option),\n    );\n    if (hasCustomOption) this.enableEditing();\n\n    this.markAsDirty();\n\n    if (optionsArr.length \u003e 1 || (optionsArr.length === 1 \u0026\u0026 merge)) {\n      this.enableMultiselect();\n    }\n\n    const values = new Array\u003cPDFHexString\u003e(optionsArr.length);\n    for (let idx = 0, len = optionsArr.length; idx \u003c len; idx++) {\n      values[idx] = PDFHexString.fromText(optionsArr[idx]);\n    }\n\n    if (merge) {\n      const existingValues = this.acroField.getValues();\n      this.acroField.setValues(existingValues.concat(values));\n    } else {\n      this.acroField.setValues(values);\n    }\n  }\n\n  /**\n   * Clear all selected values for this dropdown. This operation is equivalent\n   * to selecting an empty list. This method will update the underlying state\n   * of the dropdown to indicate that no values have been selected.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.clear()\n   * ```\n   * This method will mark this text field as dirty. See [[PDFDropdown.select]]\n   * for more details about what this means.\n   */\n  clear() {\n    this.markAsDirty();\n    this.acroField.setValues([]);\n  }\n\n  /**\n   * Set the font size for this field. Larger font sizes will result in larger\n   * text being displayed when PDF readers render this dropdown. Font sizes may\n   * be integer or floating point numbers. Supplying a negative font size will\n   * cause this method to throw an error.\n   *\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.setFontSize(4)\n   * dropdown.setFontSize(15.7)\n   * ```\n   *\n   * \u003e This method depends upon the existence of a default appearance\n   * \u003e (`/DA`) string. If this field does not have a default appearance string,\n   * \u003e or that string does not contain a font size (via the `Tf` operator),\n   * \u003e then this method will throw an error.\n   *\n   * @param fontSize The font size to be used when rendering text in this field.\n   */\n  setFontSize(fontSize: number) {\n    assertPositive(fontSize, 'fontSize');\n    this.acroField.setFontSize(fontSize);\n    this.markAsDirty();\n  }\n\n  /**\n   * Returns `true` if users are allowed to edit the selected value of this\n   * dropdown directly and are not constrained by the list of available\n   * options. See [[PDFDropdown.enableEditing]] and\n   * [[PDFDropdown.disableEditing]]. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * if (dropdown.isEditable()) console.log('Editing is enabled')\n   * ```\n   * @returns Whether or not this dropdown is editable.\n   */\n  isEditable(): boolean {\n    return this.acroField.hasFlag(AcroChoiceFlags.Edit);\n  }\n\n  /**\n   * Allow users to edit the selected value of this dropdown in PDF readers\n   * with their keyboard. This means that the selected value of this dropdown\n   * will not be constrained by the list of available options. However, if this\n   * dropdown has any available options, users will still be allowed to select\n   * from that list.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.enableEditing()\n   * ```\n   */\n  enableEditing() {\n    this.acroField.setFlagTo(AcroChoiceFlags.Edit, true);\n  }\n\n  /**\n   * Do not allow users to edit the selected value of this dropdown in PDF\n   * readers with their keyboard. This will constrain the selected value of\n   * this dropdown to the list of available options. Users will only be able\n   * to select an option from that list.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.disableEditing()\n   * ```\n   */\n  disableEditing() {\n    this.acroField.setFlagTo(AcroChoiceFlags.Edit, false);\n  }\n\n  /**\n   * Returns `true` if the option list of this dropdown is always displayed\n   * in alphabetical order, irrespective of the order in which the options\n   * were added to the dropdown. See [[PDFDropdown.enableSorting]] and\n   * [[PDFDropdown.disableSorting]]. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * if (dropdown.isSorted()) console.log('Sorting is enabled')\n   * ```\n   * @returns Whether or not this dropdown's options are sorted.\n   */\n  isSorted(): boolean {\n    return this.acroField.hasFlag(AcroChoiceFlags.Sort);\n  }\n\n  /**\n   * Always display the option list of this dropdown in alphabetical order,\n   * irrespective of the order in which the options were added to this dropdown.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.enableSorting()\n   * ```\n   */\n  enableSorting() {\n    this.acroField.setFlagTo(AcroChoiceFlags.Sort, true);\n  }\n\n  /**\n   * Do not always display the option list of this dropdown in alphabetical\n   * order. Instead, display the options in whichever order they were added\n   * to the list. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.disableSorting()\n   * ```\n   */\n  disableSorting() {\n    this.acroField.setFlagTo(AcroChoiceFlags.Sort, false);\n  }\n\n  /**\n   * Returns `true` if multiple options can be selected from this dropdown's\n   * option list. See [[PDFDropdown.enableMultiselect]] and\n   * [[PDFDropdown.disableMultiselect]]. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * if (dropdown.isMultiselect()) console.log('Multiselect is enabled')\n   * ```\n   * @returns Whether or not multiple options can be selected.\n   */\n  isMultiselect(): boolean {\n    return this.acroField.hasFlag(AcroChoiceFlags.MultiSelect);\n  }\n\n  /**\n   * Allow users to select more than one option from this dropdown's option\n   * list. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.enableMultiselect()\n   * ```\n   */\n  enableMultiselect() {\n    this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, true);\n  }\n\n  /**\n   * Do not allow users to select more than one option from this dropdown's\n   * option list. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.disableMultiselect()\n   * ```\n   */\n  disableMultiselect() {\n    this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, false);\n  }\n\n  /**\n   * Returns `true` if the selected option should be spell checked by PDF\n   * readers. Spell checking will only be performed if this dropdown allows\n   * editing (see [[PDFDropdown.isEditable]]). See\n   * [[PDFDropdown.enableSpellChecking]] and\n   * [[PDFDropdown.disableSpellChecking]]. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * if (dropdown.isSpellChecked()) console.log('Spell checking is enabled')\n   * ```\n   * @returns Whether or not this dropdown can be spell checked.\n   */\n  isSpellChecked(): boolean {\n    return !this.acroField.hasFlag(AcroChoiceFlags.DoNotSpellCheck);\n  }\n\n  /**\n   * Allow PDF readers to spell check the selected option of this dropdown.\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.enableSpellChecking()\n   * ```\n   */\n  enableSpellChecking() {\n    this.acroField.setFlagTo(AcroChoiceFlags.DoNotSpellCheck, false);\n  }\n\n  /**\n   * Do not allow PDF readers to spell check the selected option of this\n   * dropdown. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.disableSpellChecking()\n   * ```\n   */\n  disableSpellChecking() {\n    this.acroField.setFlagTo(AcroChoiceFlags.DoNotSpellCheck, true);\n  }\n\n  /**\n   * Returns `true` if the option selected by a user is stored, or \"committed\",\n   * when the user clicks the option. The alternative is that the user's\n   * selection is stored when the user leaves this dropdown field (by clicking\n   * outside of it - on another field, for example). See\n   * [[PDFDropdown.enableSelectOnClick]] and\n   * [[PDFDropdown.disableSelectOnClick]]. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * if (dropdown.isSelectOnClick()) console.log('Select on click is enabled')\n   * ```\n   * @returns Whether or not options are selected immediately after they are\n   *          clicked.\n   */\n  isSelectOnClick(): boolean {\n    return this.acroField.hasFlag(AcroChoiceFlags.CommitOnSelChange);\n  }\n\n  /**\n   * Store the option selected by a user immediately after the user clicks the\n   * option. Do not wait for the user to leave this dropdown field (by clicking\n   * outside of it - on another field, for example). For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.enableSelectOnClick()\n   * ```\n   */\n  enableSelectOnClick() {\n    this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, true);\n  }\n\n  /**\n   * Wait to store the option selected by a user until they leave this dropdown\n   * field (by clicking outside of it - on another field, for example).\n   * For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.disableSelectOnClick()\n   * ```\n   */\n  disableSelectOnClick() {\n    this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, false);\n  }\n\n  /**\n   * Show this dropdown on the specified page. For example:\n   * ```js\n   * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const dropdown = form.createDropdown('best.gundam')\n   * dropdown.setOptions(['Exia', 'Dynames'])\n   * dropdown.select('Exia')\n   *\n   * dropdown.addToPage(page, {\n   *   x: 50,\n   *   y: 75,\n   *   width: 200,\n   *   height: 100,\n   *   textColor: rgb(1, 0, 0),\n   *   backgroundColor: rgb(0, 1, 0),\n   *   borderColor: rgb(0, 0, 1),\n   *   borderWidth: 2,\n   *   rotate: degrees(90),\n   *   font: ubuntuFont,\n   * })\n   * ```\n   * This will create a new widget for this dropdown field.\n   * @param page The page to which this dropdown widget should be added.\n   * @param options The options to be used when adding this dropdown widget.\n   */\n  addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n    assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n    assertFieldAppearanceOptions(options);\n\n    if (!options) options = {};\n\n    if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n    if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n    if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n    if (!('borderWidth' in options)) options.borderWidth = 1;\n\n    // Create a widget for this dropdown\n    const widget = this.createWidget({\n      x: options.x ?? 0,\n      y: options.y ?? 0,\n      width: options.width ?? 200,\n      height: options.height ?? 50,\n      textColor: options.textColor,\n      backgroundColor: options.backgroundColor,\n      borderColor: options.borderColor,\n      borderWidth: options.borderWidth ?? 0,\n      rotate: options.rotate ?? degrees(0),\n      hidden: options.hidden,\n      page: page.ref,\n    });\n    const widgetRef = this.doc.context.register(widget.dict);\n\n    // Add widget to this field\n    this.acroField.addWidget(widgetRef);\n\n    // Set appearance streams for widget\n    const font = options.font ?? this.doc.getForm().getDefaultFont();\n    this.updateWidgetAppearance(widget, font);\n\n    // Add widget to the given page\n    page.node.addAnnot(widgetRef);\n  }\n\n  /**\n   * Returns `true` if this dropdown has been marked as dirty, or if any of\n   * this dropdown's widgets do not have an appearance stream. For example:\n   * ```js\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * if (dropdown.needsAppearancesUpdate()) console.log('Needs update')\n   * ```\n   * @returns Whether or not this dropdown needs an appearance update.\n   */\n  needsAppearancesUpdate(): boolean {\n    if (this.isDirty()) return true;\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const hasAppearances =\n        widget.getAppearances()?.normal instanceof PDFStream;\n      if (!hasAppearances) return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * Update the appearance streams for each of this dropdown's widgets using\n   * the default appearance provider for dropdowns. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.defaultUpdateAppearances(helvetica)\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   */\n  defaultUpdateAppearances(font: PDFFont) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    this.updateAppearances(font);\n  }\n\n  /**\n   * Update the appearance streams for each of this dropdown's widgets using\n   * the given appearance provider. If no `provider` is passed, the default\n   * appearance provider for dropdowns will be used. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const dropdown = form.getDropdown('some.dropdown.field')\n   * dropdown.updateAppearances(helvetica, (field, widget, font) =\u003e {\n   *   ...\n   *   return drawTextField(...)\n   * })\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   * @param provider Optionally, the appearance provider to be used for\n   *                 generating the contents of the appearance streams.\n   */\n  updateAppearances(\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFDropdown\u003e,\n  ) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    assertOrUndefined(provider, 'provider', [Function]);\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      this.updateWidgetAppearance(widget, font, provider);\n    }\n    this.markAsClean();\n  }\n\n  // getOption(index: number): string {}\n  // getSelectedIndices(): number[] {}\n  // removeOptions(option: string | string[]) {}\n  // removeIndices(option: number[]) {}\n  // deselect(options: string | string[]) {}\n  // deselectIndices(optionIndices: number[]) {}\n\n  private updateWidgetAppearance(\n    widget: PDFWidgetAnnotation,\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFDropdown\u003e,\n  ) {\n    const apProvider = provider ?? defaultDropdownAppearanceProvider;\n    const appearances = normalizeAppearance(apProvider(this, widget, font));\n    this.updateWidgetAppearanceWithFont(widget, font, appearances);\n  }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFField, {\n  FieldAppearanceOptions,\n  assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n  AppearanceProviderFor,\n  normalizeAppearance,\n  defaultOptionListAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n  PDFRef,\n  PDFHexString,\n  PDFString,\n  PDFStream,\n  PDFAcroListBox,\n  AcroChoiceFlags,\n  PDFWidgetAnnotation,\n} from 'src/core';\nimport {\n  assertIs,\n  assertIsSubset,\n  assertOrUndefined,\n  assertPositive,\n} from 'src/utils';\n\n/**\n * Represents an option list field of a [[PDFForm]].\n *\n * [[PDFOptionList]] fields are interactive lists of options. The purpose of an\n * option list is to enable users to select one or more options from a set of\n * possible options. Users are able to see the full set of options without\n * first having to click on the field (though scrolling may be necessary).\n * Clicking an option in the list will cause it to be selected and displayed\n * with a highlighted background. Some option lists allow users to select\n * more than one option (see [[PDFOptionList.isMultiselect]]).\n */\nexport default class PDFOptionList extends PDFField {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFForm.getOptionList]] method, which will create\n   * \u003e an instance of [[PDFOptionList]] for you.\n   *\n   * Create an instance of [[PDFOptionList]] from an existing acroListBox and\n   * ref\n   *\n   * @param acroComboBox The underlying `PDFAcroListBox` for this option list.\n   * @param ref The unique reference for this option list.\n   * @param doc The document to which this option list will belong.\n   */\n  static of = (acroListBox: PDFAcroListBox, ref: PDFRef, doc: PDFDocument) =\u003e\n    new PDFOptionList(acroListBox, ref, doc);\n\n  /** The low-level PDFAcroListBox wrapped by this option list. */\n  readonly acroField: PDFAcroListBox;\n\n  private constructor(\n    acroListBox: PDFAcroListBox,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) {\n    super(acroListBox, ref, doc);\n\n    assertIs(acroListBox, 'acroListBox', [[PDFAcroListBox, 'PDFAcroListBox']]);\n\n    this.acroField = acroListBox;\n  }\n\n  /**\n   * Get the list of available options for this option list. These options will\n   * be displayed to users who view this option list in a PDF reader.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * const options = optionList.getOptions()\n   * console.log('Option List options:', options)\n   * ```\n   * @returns The options for this option list.\n   */\n  getOptions(): string[] {\n    const rawOptions = this.acroField.getOptions();\n\n    const options = new Array\u003cstring\u003e(rawOptions.length);\n    for (let idx = 0, len = options.length; idx \u003c len; idx++) {\n      const { display, value } = rawOptions[idx];\n      options[idx] = (display ?? value).decodeText();\n    }\n\n    return options;\n  }\n\n  /**\n   * Get the selected options for this option list. These are the values that\n   * were selected by a human user via a PDF reader, or programatically via\n   * software.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * const selections = optionList.getSelected()\n   * console.log('Option List selections:', selections)\n   * ```\n   * @returns The selected options for this option list.\n   */\n  getSelected(): string[] {\n    const values = this.acroField.getValues();\n\n    const selected = new Array\u003cstring\u003e(values.length);\n    for (let idx = 0, len = values.length; idx \u003c len; idx++) {\n      selected[idx] = values[idx].decodeText();\n    }\n\n    return selected;\n  }\n\n  /**\n   * Set the list of options that are available for this option list. These are\n   * the values that will be available for users to select when they view this\n   * option list in a PDF reader. Note that preexisting options for this\n   * option list will be removed. Only the values passed as `options` will be\n   * available to select.\n   *\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('planets.optionList')\n   * optionList.setOptions(['Earth', 'Mars', 'Pluto', 'Venus'])\n   * ```\n   *\n   * This method will mark this option list as dirty, causing its appearance\n   * streams to be updated when either [[PDFDocument.save]] or\n   * [[PDFForm.updateFieldAppearances]] is called. The updated streams will\n   * display the options this field contains inside the widgets of this text\n   * field (with selected options highlighted).\n   *\n   * **IMPORTANT:** The default font used to update appearance streams is\n   * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n   * that encoding errors will be thrown if this field contains any options\n   * with characters outside the WinAnsi character set (the latin alphabet).\n   *\n   * Embedding a custom font and passing it to\n   * [[PDFForm.updateFieldAppearances]] or [[PDFOptionList.updateAppearances]]\n   * allows you to generate appearance streams with characters outside the\n   * latin alphabet (assuming the custom font supports them).\n   *\n   * @param options The options that should be available in this option list.\n   */\n  setOptions(options: string[]) {\n    assertIs(options, 'options', [Array]);\n\n    this.markAsDirty();\n    const optionObjects = new Array\u003c{ value: PDFHexString }\u003e(options.length);\n    for (let idx = 0, len = options.length; idx \u003c len; idx++) {\n      optionObjects[idx] = { value: PDFHexString.fromText(options[idx]) };\n    }\n    this.acroField.setOptions(optionObjects);\n  }\n\n  /**\n   * Add to the list of options that are available for this option list. Users\n   * will be able to select these values in a PDF reader. In addition to the\n   * values passed as `options`, any preexisting options for this option list\n   * will still be available for users to select.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('rockets.optionList')\n   * optionList.addOptions(['Saturn IV', 'Falcon Heavy'])\n   * ```\n   * This method will mark this option list as dirty. See\n   * [[PDFOptionList.setOptions]] for more details about what this means.\n   * @param options New options that should be available in this option list.\n   */\n  addOptions(options: string | string[]) {\n    assertIs(options, 'options', ['string', Array]);\n\n    this.markAsDirty();\n\n    const optionsArr = Array.isArray(options) ? options : [options];\n\n    const existingOptions: {\n      value: PDFString | PDFHexString;\n      display?: PDFString | PDFHexString;\n    }[] = this.acroField.getOptions();\n\n    const newOptions = new Array\u003c{ value: PDFHexString }\u003e(optionsArr.length);\n    for (let idx = 0, len = optionsArr.length; idx \u003c len; idx++) {\n      newOptions[idx] = { value: PDFHexString.fromText(optionsArr[idx]) };\n    }\n\n    this.acroField.setOptions(existingOptions.concat(newOptions));\n  }\n\n  /**\n   * Select one or more values for this option list. This operation is analogous\n   * to a human user opening the option list in a PDF reader and clicking on one\n   * or more values to select them. This method will update the underlying state\n   * of the option list to indicate which values have been selected. PDF\n   * libraries and readers will be able to extract these values from the saved\n   * document and determine which values were selected.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('best.superheroes.optionList')\n   * optionList.select(['One Punch Man', 'Iron Man'])\n   * ```\n   * This method will mark this option list as dirty. See\n   * [[PDFOptionList.setOptions]] for more details about what this means.\n   * @param options The options to be selected.\n   * @param merge Whether or not existing selections should be preserved.\n   */\n  select(options: string | string[], merge = false) {\n    assertIs(options, 'options', ['string', Array]);\n    assertIs(merge, 'merge', ['boolean']);\n\n    const optionsArr = Array.isArray(options) ? options : [options];\n\n    const validOptions = this.getOptions();\n    assertIsSubset(optionsArr, 'option', validOptions);\n\n    this.markAsDirty();\n\n    if (optionsArr.length \u003e 1 || (optionsArr.length === 1 \u0026\u0026 merge)) {\n      this.enableMultiselect();\n    }\n\n    const values = new Array\u003cPDFHexString\u003e(optionsArr.length);\n    for (let idx = 0, len = optionsArr.length; idx \u003c len; idx++) {\n      values[idx] = PDFHexString.fromText(optionsArr[idx]);\n    }\n\n    if (merge) {\n      const existingValues = this.acroField.getValues();\n      this.acroField.setValues(existingValues.concat(values));\n    } else {\n      this.acroField.setValues(values);\n    }\n  }\n\n  /**\n   * Clear all selected values for this option list. This operation is\n   * equivalent to selecting an empty list. This method will update the\n   * underlying state of the option list to indicate that no values have been\n   * selected.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.clear()\n   * ```\n   * This method will mark this option list as dirty. See\n   * [[PDFOptionList.setOptions]] for more details about what this means.\n   */\n  clear() {\n    this.markAsDirty();\n    this.acroField.setValues([]);\n  }\n\n  /**\n   * Set the font size for the text in this field. There needs to be a\n   * default appearance string (DA) set with a font value specified\n   * for this to work. For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.setFontSize(4);\n   * ```\n   * @param fontSize The font size to set the font to.\n   */\n\n  /**\n   * Set the font size for this field. Larger font sizes will result in larger\n   * text being displayed when PDF readers render this option list. Font sizes\n   * may be integer or floating point numbers. Supplying a negative font size\n   * will cause this method to throw an error.\n   *\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.setFontSize(4)\n   * optionList.setFontSize(15.7)\n   * ```\n   *\n   * \u003e This method depends upon the existence of a default appearance\n   * \u003e (`/DA`) string. If this field does not have a default appearance string,\n   * \u003e or that string does not contain a font size (via the `Tf` operator),\n   * \u003e then this method will throw an error.\n   *\n   * @param fontSize The font size to be used when rendering text in this field.\n   */\n  setFontSize(fontSize: number) {\n    assertPositive(fontSize, 'fontSize');\n    this.acroField.setFontSize(fontSize);\n    this.markAsDirty();\n  }\n\n  /**\n   * Returns `true` if the options of this option list are always displayed\n   * in alphabetical order, irrespective of the order in which the options\n   * were added to the option list. See [[PDFOptionList.enableSorting]] and\n   * [[PDFOptionList.disableSorting]]. For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * if (optionList.isSorted()) console.log('Sorting is enabled')\n   * ```\n   * @returns Whether or not this option list is sorted.\n   */\n  isSorted(): boolean {\n    return this.acroField.hasFlag(AcroChoiceFlags.Sort);\n  }\n\n  /**\n   * Always display the options of this option list in alphabetical order,\n   * irrespective of the order in which the options were added to this option\n   * list.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.enableSorting()\n   * ```\n   */\n  enableSorting() {\n    this.acroField.setFlagTo(AcroChoiceFlags.Sort, true);\n  }\n\n  /**\n   * Do not always display the options of this option list in alphabetical\n   * order. Instead, display the options in whichever order they were added\n   * to this option list. For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.disableSorting()\n   * ```\n   */\n  disableSorting() {\n    this.acroField.setFlagTo(AcroChoiceFlags.Sort, false);\n  }\n\n  /**\n   * Returns `true` if multiple options can be selected from this option list.\n   * See [[PDFOptionList.enableMultiselect]] and\n   * [[PDFOptionList.disableMultiselect]]. For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * if (optionList.isMultiselect()) console.log('Multiselect is enabled')\n   * ```\n   * @returns Whether or not multiple options can be selected.\n   */\n  isMultiselect(): boolean {\n    return this.acroField.hasFlag(AcroChoiceFlags.MultiSelect);\n  }\n\n  /**\n   * Allow users to select more than one option from this option list.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.enableMultiselect()\n   * ```\n   */\n  enableMultiselect() {\n    this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, true);\n  }\n\n  /**\n   * Do not allow users to select more than one option from this option list.\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.disableMultiselect()\n   * ```\n   */\n  disableMultiselect() {\n    this.acroField.setFlagTo(AcroChoiceFlags.MultiSelect, false);\n  }\n\n  /**\n   * Returns `true` if the option selected by a user is stored, or \"committed\",\n   * when the user clicks the option. The alternative is that the user's\n   * selection is stored when the user leaves this option list field (by\n   * clicking outside of it - on another field, for example). See\n   * [[PDFOptionList.enableSelectOnClick]] and\n   * [[PDFOptionList.disableSelectOnClick]]. For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * if (optionList.isSelectOnClick()) console.log('Select on click is enabled')\n   * ```\n   * @returns Whether or not options are selected immediately after they are\n   *          clicked.\n   */\n  isSelectOnClick(): boolean {\n    return this.acroField.hasFlag(AcroChoiceFlags.CommitOnSelChange);\n  }\n\n  /**\n   * Store the option selected by a user immediately after the user clicks the\n   * option. Do not wait for the user to leave this option list field (by\n   * clicking outside of it - on another field, for example). For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.enableSelectOnClick()\n   * ```\n   */\n  enableSelectOnClick() {\n    this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, true);\n  }\n\n  /**\n   * Wait to store the option selected by a user until they leave this option\n   * list field (by clicking outside of it - on another field, for example).\n   * For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.disableSelectOnClick()\n   * ```\n   */\n  disableSelectOnClick() {\n    this.acroField.setFlagTo(AcroChoiceFlags.CommitOnSelChange, false);\n  }\n\n  /**\n   * Show this option list on the specified page. For example:\n   * ```js\n   * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const optionList = form.createOptionList('best.gundams')\n   * optionList.setOptions(['Exia', 'Dynames', 'Kyrios', 'Virtue'])\n   * optionList.select(['Exia', 'Virtue'])\n   *\n   * optionList.addToPage(page, {\n   *   x: 50,\n   *   y: 75,\n   *   width: 200,\n   *   height: 100,\n   *   textColor: rgb(1, 0, 0),\n   *   backgroundColor: rgb(0, 1, 0),\n   *   borderColor: rgb(0, 0, 1),\n   *   borderWidth: 2,\n   *   rotate: degrees(90),\n   *   font: ubuntuFont,\n   * })\n   * ```\n   * This will create a new widget for this option list field.\n   * @param page The page to which this option list widget should be added.\n   * @param options The options to be used when adding this option list widget.\n   */\n  addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n    assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n    assertFieldAppearanceOptions(options);\n\n    if (!options) options = {};\n\n    if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n    if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n    if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n    if (!('borderWidth' in options)) options.borderWidth = 1;\n\n    // Create a widget for this option list\n    const widget = this.createWidget({\n      x: options.x ?? 0,\n      y: options.y ?? 0,\n      width: options.width ?? 200,\n      height: options.height ?? 100,\n      textColor: options.textColor,\n      backgroundColor: options.backgroundColor,\n      borderColor: options.borderColor,\n      borderWidth: options.borderWidth ?? 0,\n      rotate: options.rotate ?? degrees(0),\n      hidden: options.hidden,\n      page: page.ref,\n    });\n    const widgetRef = this.doc.context.register(widget.dict);\n\n    // Add widget to this field\n    this.acroField.addWidget(widgetRef);\n\n    // Set appearance streams for widget\n    const font = options.font ?? this.doc.getForm().getDefaultFont();\n    this.updateWidgetAppearance(widget, font);\n\n    // Add widget to the given page\n    page.node.addAnnot(widgetRef);\n  }\n\n  /**\n   * Returns `true` if this option list has been marked as dirty, or if any of\n   * this option list's widgets do not have an appearance stream. For example:\n   * ```js\n   * const optionList = form.getOptionList('some.optionList.field')\n   * if (optionList.needsAppearancesUpdate()) console.log('Needs update')\n   * ```\n   * @returns Whether or not this option list needs an appearance update.\n   */\n  needsAppearancesUpdate(): boolean {\n    if (this.isDirty()) return true;\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const hasAppearances =\n        widget.getAppearances()?.normal instanceof PDFStream;\n      if (!hasAppearances) return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * Update the appearance streams for each of this option list's widgets using\n   * the default appearance provider for option lists. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.defaultUpdateAppearances(helvetica)\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   */\n  defaultUpdateAppearances(font: PDFFont) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    this.updateAppearances(font);\n  }\n\n  /**\n   * Update the appearance streams for each of this option list's widgets using\n   * the given appearance provider. If no `provider` is passed, the default\n   * appearance provider for option lists will be used. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const optionList = form.getOptionList('some.optionList.field')\n   * optionList.updateAppearances(helvetica, (field, widget, font) =\u003e {\n   *   ...\n   *   return drawOptionList(...)\n   * })\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   * @param provider Optionally, the appearance provider to be used for\n   *                 generating the contents of the appearance streams.\n   */\n  updateAppearances(\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFOptionList\u003e,\n  ) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    assertOrUndefined(provider, 'provider', [Function]);\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      this.updateWidgetAppearance(widget, font, provider);\n    }\n    this.markAsClean();\n  }\n\n  // getOption(index: number): string {}\n  // getSelectedIndices(): number[] {}\n  // removeOptions(option: string | string[]) {}\n  // removeIndices(option: number[]) {}\n  // deselect(options: string | string[]) {}\n  // deselectIndices(optionIndices: number[]) {}\n\n  private updateWidgetAppearance(\n    widget: PDFWidgetAnnotation,\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFOptionList\u003e,\n  ) {\n    const apProvider = provider ?? defaultOptionListAppearanceProvider;\n    const appearances = normalizeAppearance(apProvider(this, widget, font));\n    this.updateWidgetAppearanceWithFont(widget, font, appearances);\n  }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFField, {\n  FieldAppearanceOptions,\n  assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n  AppearanceProviderFor,\n  normalizeAppearance,\n  defaultRadioGroupAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n  PDFName,\n  PDFRef,\n  PDFHexString,\n  PDFDict,\n  PDFWidgetAnnotation,\n  PDFAcroRadioButton,\n  AcroButtonFlags,\n} from 'src/core';\nimport { assertIs, assertOrUndefined, assertIsOneOf } from 'src/utils';\n\n/**\n * Represents a radio group field of a [[PDFForm]].\n *\n * [[PDFRadioGroup]] fields are collections of radio buttons. The purpose of a\n * radio group is to enable users to select one option from a set of mutually\n * exclusive choices. Each choice in a radio group is represented by a radio\n * button. Radio buttons each have two states: `on` and `off`. At most one\n * radio button in a group may be in the `on` state at any time. Users can\n * click on a radio button to select it (and thereby automatically deselect any\n * other radio button that might have already been selected). Some radio\n * groups allow users to toggle a selected radio button `off` by clicking on\n * it (see [[PDFRadioGroup.isOffToggleable]]).\n *\n * Note that some radio groups allow multiple radio buttons to be in the `on`\n * state at the same type **if** they represent the same underlying value (see\n * [[PDFRadioGroup.isMutuallyExclusive]]).\n */\nexport default class PDFRadioGroup extends PDFField {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFForm.getOptionList]] method, which will create an\n   * \u003e instance of [[PDFOptionList]] for you.\n   *\n   * Create an instance of [[PDFOptionList]] from an existing acroRadioButton\n   * and ref\n   *\n   * @param acroRadioButton The underlying `PDFAcroRadioButton` for this\n   *                        radio group.\n   * @param ref The unique reference for this radio group.\n   * @param doc The document to which this radio group will belong.\n   */\n  static of = (\n    acroRadioButton: PDFAcroRadioButton,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) =\u003e new PDFRadioGroup(acroRadioButton, ref, doc);\n\n  /** The low-level PDFAcroRadioButton wrapped by this radio group. */\n  readonly acroField: PDFAcroRadioButton;\n\n  private constructor(\n    acroRadioButton: PDFAcroRadioButton,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) {\n    super(acroRadioButton, ref, doc);\n\n    assertIs(acroRadioButton, 'acroRadioButton', [\n      [PDFAcroRadioButton, 'PDFAcroRadioButton'],\n    ]);\n\n    this.acroField = acroRadioButton;\n  }\n\n  /**\n   * Get the list of available options for this radio group. Each option is\n   * represented by a radio button. These radio buttons are displayed at\n   * various locations in the document, potentially on different pages (though\n   * typically they are stacked horizontally or vertically on the same page).\n   * For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * const options = radioGroup.getOptions()\n   * console.log('Radio Group options:', options)\n   * ```\n   * @returns The options for this radio group.\n   */\n  getOptions(): string[] {\n    const exportValues = this.acroField.getExportValues();\n    if (exportValues) {\n      const exportOptions = new Array\u003cstring\u003e(exportValues.length);\n      for (let idx = 0, len = exportValues.length; idx \u003c len; idx++) {\n        exportOptions[idx] = exportValues[idx].decodeText();\n      }\n      return exportOptions;\n    }\n\n    const onValues = this.acroField.getOnValues();\n    const onOptions = new Array\u003cstring\u003e(onValues.length);\n    for (let idx = 0, len = onOptions.length; idx \u003c len; idx++) {\n      onOptions[idx] = onValues[idx].decodeText();\n    }\n    return onOptions;\n  }\n\n  /**\n   * Get the selected option for this radio group. The selected option is\n   * represented by the radio button in this group that is turned on. At most\n   * one radio button in a group can be selected. If no buttons in this group\n   * are selected, `undefined` is returned.\n   * For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * const selected = radioGroup.getSelected()\n   * console.log('Selected radio button:', selected)\n   * ```\n   * @returns The selected option for this radio group.\n   */\n  getSelected(): string | undefined {\n    const value = this.acroField.getValue();\n    if (value === PDFName.of('Off')) return undefined;\n    const exportValues = this.acroField.getExportValues();\n    if (exportValues) {\n      const onValues = this.acroField.getOnValues();\n      for (let idx = 0, len = onValues.length; idx \u003c len; idx++) {\n        if (onValues[idx] === value) return exportValues[idx].decodeText();\n      }\n    }\n    return value.decodeText();\n  }\n\n  // // TODO: Figure out why this seems to crash Acrobat. Maybe it's because we\n  // //       aren't removing the widget reference from the page's Annots?\n  // removeOption(option: string) {\n  //   assertIs(option, 'option', ['string']);\n  //   // TODO: Assert is valid `option`!\n\n  //   const onValues = this.acroField.getOnValues();\n  //   const exportValues = this.acroField.getExportValues();\n  //   if (exportValues) {\n  //     for (let idx = 0, len = exportValues.length; idx \u003c len; idx++) {\n  //       if (exportValues[idx].decodeText() === option) {\n  //         this.acroField.removeWidget(idx);\n  //         this.acroField.removeExportValue(idx);\n  //       }\n  //     }\n  //   } else {\n  //     for (let idx = 0, len = onValues.length; idx \u003c len; idx++) {\n  //       const value = onValues[idx];\n  //       if (value.decodeText() === option) {\n  //         this.acroField.removeWidget(idx);\n  //         this.acroField.removeExportValue(idx);\n  //       }\n  //     }\n  //   }\n  // }\n\n  /**\n   * Select an option for this radio group. This operation is analogous to a\n   * human user clicking one of the radio buttons in this group via a PDF\n   * reader to toggle it on. This method will update the underlying state of\n   * the radio group to indicate which option has been selected. PDF libraries\n   * and readers will be able to extract this value from the saved document and\n   * determine which option was selected.\n   *\n   * For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('best.superhero.radioGroup')\n   * radioGroup.select('One Punch Man')\n   * ```\n   *\n   * This method will mark this radio group as dirty, causing its appearance\n   * streams to be updated when either [[PDFDocument.save]] or\n   * [[PDFForm.updateFieldAppearances]] is called. The updated appearance\n   * streams will display a dot inside the widget of this check box field\n   * that represents the selected option.\n   *\n   * @param option The option to be selected.\n   */\n  select(option: string) {\n    assertIs(option, 'option', ['string']);\n\n    const validOptions = this.getOptions();\n    assertIsOneOf(option, 'option', validOptions);\n\n    this.markAsDirty();\n\n    const onValues = this.acroField.getOnValues();\n    const exportValues = this.acroField.getExportValues();\n    if (exportValues) {\n      for (let idx = 0, len = exportValues.length; idx \u003c len; idx++) {\n        if (exportValues[idx].decodeText() === option) {\n          this.acroField.setValue(onValues[idx]);\n        }\n      }\n    } else {\n      for (let idx = 0, len = onValues.length; idx \u003c len; idx++) {\n        const value = onValues[idx];\n        if (value.decodeText() === option) this.acroField.setValue(value);\n      }\n    }\n  }\n\n  /**\n   * Clear any selected option for this dropdown. This will result in all\n   * radio buttons in this group being toggled off. This method will update\n   * the underlying state of the dropdown to indicate that no radio buttons\n   * have been selected.\n   * For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * radioGroup.clear()\n   * ```\n   * This method will mark this radio group as dirty. See\n   * [[PDFRadioGroup.select]] for more details about what this means.\n   */\n  clear() {\n    this.markAsDirty();\n    this.acroField.setValue(PDFName.of('Off'));\n  }\n\n  /**\n   * Returns `true` if users can click on radio buttons in this group to toggle\n   * them off. The alternative is that once a user clicks on a radio button\n   * to select it, the only way to deselect it is by selecting on another radio\n   * button in the group. See [[PDFRadioGroup.enableOffToggling]] and\n   * [[PDFRadioGroup.disableOffToggling]]. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * if (radioGroup.isOffToggleable()) console.log('Off toggling is enabled')\n   * ```\n   */\n  isOffToggleable() {\n    return !this.acroField.hasFlag(AcroButtonFlags.NoToggleToOff);\n  }\n\n  /**\n   * Allow users to click on selected radio buttons in this group to toggle\n   * them off. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * radioGroup.enableOffToggling()\n   * ```\n   * \u003e **NOTE:** This feature is documented in the PDF specification\n   * \u003e (Table 226). However, most PDF readers do not respect this option and\n   * \u003e prevent users from toggling radio buttons off even when it is enabled.\n   * \u003e At the time of this writing (9/6/2020) Mac's Preview software did\n   * \u003e respect the option. Adobe Acrobat, Foxit Reader, and Google Chrome did\n   * \u003e not.\n   */\n  enableOffToggling() {\n    this.acroField.setFlagTo(AcroButtonFlags.NoToggleToOff, false);\n  }\n\n  /**\n   * Prevent users from clicking on selected radio buttons in this group to\n   * toggle them off. Clicking on a selected radio button will have no effect.\n   * The only way to deselect a selected radio button is to click on a\n   * different radio button in the group. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * radioGroup.disableOffToggling()\n   * ```\n   */\n  disableOffToggling() {\n    this.acroField.setFlagTo(AcroButtonFlags.NoToggleToOff, true);\n  }\n\n  /**\n   * Returns `true` if the radio buttons in this group are mutually exclusive.\n   * This means that when the user selects a radio button, only that specific\n   * button will be turned on. Even if other radio buttons in the group\n   * represent the same value, they will not be enabled. The alternative to\n   * this is that clicking a radio button will select that button along with\n   * any other radio buttons in the group that share the same value. See\n   * [[PDFRadioGroup.enableMutualExclusion]] and\n   * [[PDFRadioGroup.disableMutualExclusion]].\n   * For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * if (radioGroup.isMutuallyExclusive()) console.log('Mutual exclusion is enabled')\n   * ```\n   */\n  isMutuallyExclusive() {\n    return !this.acroField.hasFlag(AcroButtonFlags.RadiosInUnison);\n  }\n\n  /**\n   * When the user clicks a radio button in this group it will be selected. In\n   * addition, any other radio buttons in this group that share the same\n   * underlying value will also be selected. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * radioGroup.enableMutualExclusion()\n   * ```\n   * Note that this option must be enabled prior to adding options to the\n   * radio group. It does not currently apply retroactively to existing\n   * radio buttons in the group.\n   */\n  enableMutualExclusion() {\n    this.acroField.setFlagTo(AcroButtonFlags.RadiosInUnison, false);\n  }\n\n  /**\n   * When the user clicks a radio button in this group only it will be selected.\n   * No other radio buttons in the group will be selected, even if they share\n   * the same underlying value. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * radioGroup.disableMutualExclusion()\n   * ```\n   * Note that this option must be disabled prior to adding options to the\n   * radio group. It does not currently apply retroactively to existing\n   * radio buttons in the group.\n   */\n  disableMutualExclusion() {\n    this.acroField.setFlagTo(AcroButtonFlags.RadiosInUnison, true);\n  }\n\n  /**\n   * Add a new radio button to this group on the specified page. For example:\n   * ```js\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const radioGroup = form.createRadioGroup('best.gundam')\n   *\n   * const options = {\n   *   x: 50,\n   *   width: 25,\n   *   height: 25,\n   *   textColor: rgb(1, 0, 0),\n   *   backgroundColor: rgb(0, 1, 0),\n   *   borderColor: rgb(0, 0, 1),\n   *   borderWidth: 2,\n   *   rotate: degrees(90),\n   * }\n   *\n   * radioGroup.addOptionToPage('Exia', page, { ...options, y: 50 })\n   * radioGroup.addOptionToPage('Dynames', page, { ...options, y: 110 })\n   * ```\n   * This will create a new radio button widget for this radio group field.\n   * @param option The option that the radio button widget represents.\n   * @param page The page to which the radio button widget should be added.\n   * @param options The options to be used when adding the radio button widget.\n   */\n  addOptionToPage(\n    option: string,\n    page: PDFPage,\n    options?: FieldAppearanceOptions,\n  ) {\n    assertIs(option, 'option', ['string']);\n    assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n    assertFieldAppearanceOptions(options);\n\n    // Create a widget for this radio button\n    const widget = this.createWidget({\n      x: options?.x ?? 0,\n      y: options?.y ?? 0,\n      width: options?.width ?? 50,\n      height: options?.height ?? 50,\n      textColor: options?.textColor ?? rgb(0, 0, 0),\n      backgroundColor: options?.backgroundColor ?? rgb(1, 1, 1),\n      borderColor: options?.borderColor ?? rgb(0, 0, 0),\n      borderWidth: options?.borderWidth ?? 1,\n      rotate: options?.rotate ?? degrees(0),\n      hidden: options?.hidden,\n      page: page.ref,\n    });\n    const widgetRef = this.doc.context.register(widget.dict);\n\n    // Add widget to this field\n    const apStateValue = this.acroField.addWidgetWithOpt(\n      widgetRef,\n      PDFHexString.fromText(option),\n      !this.isMutuallyExclusive(),\n    );\n\n    // Set appearance streams for widget\n    widget.setAppearanceState(PDFName.of('Off'));\n    this.updateWidgetAppearance(widget, apStateValue);\n\n    // Add widget to the given page\n    page.node.addAnnot(widgetRef);\n  }\n\n  /**\n   * Returns `true` if any of this group's radio button widgets do not have an\n   * appearance stream for their current state. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * if (radioGroup.needsAppearancesUpdate()) console.log('Needs update')\n   * ```\n   * @returns Whether or not this radio group needs an appearance update.\n   */\n  needsAppearancesUpdate(): boolean {\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const state = widget.getAppearanceState();\n      const normal = widget.getAppearances()?.normal;\n\n      if (!(normal instanceof PDFDict)) return true;\n      if (state \u0026\u0026 !normal.has(state)) return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * Update the appearance streams for each of this group's radio button widgets\n   * using the default appearance provider for radio groups. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * radioGroup.defaultUpdateAppearances()\n   * ```\n   */\n  defaultUpdateAppearances() {\n    this.updateAppearances();\n  }\n\n  // rg.updateAppearances((field: any, widget: any) =\u003e {\n  //   assert(field === rg);\n  //   assert(widget instanceof PDFWidgetAnnotation);\n  //   return { on: [...rectangle, ...circle], off: [...rectangle, ...circle] };\n  // });\n\n  /**\n   * Update the appearance streams for each of this group's radio button widgets\n   * using the given appearance provider. If no `provider` is passed, the\n   * default appearance provider for radio groups will be used. For example:\n   * ```js\n   * const radioGroup = form.getRadioGroup('some.radioGroup.field')\n   * radioGroup.updateAppearances((field, widget) =\u003e {\n   *   ...\n   *   return {\n   *     normal: { on: drawRadioButton(...), off: drawRadioButton(...) },\n   *     down: { on: drawRadioButton(...), off: drawRadioButton(...) },\n   *   }\n   * })\n   * ```\n   * @param provider Optionally, the appearance provider to be used for\n   *                 generating the contents of the appearance streams.\n   */\n  updateAppearances(provider?: AppearanceProviderFor\u003cPDFRadioGroup\u003e) {\n    assertOrUndefined(provider, 'provider', [Function]);\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const onValue = widget.getOnValue();\n      if (!onValue) continue;\n      this.updateWidgetAppearance(widget, onValue, provider);\n    }\n  }\n\n  private updateWidgetAppearance(\n    widget: PDFWidgetAnnotation,\n    onValue: PDFName,\n    provider?: AppearanceProviderFor\u003cPDFRadioGroup\u003e,\n  ) {\n    const apProvider = provider ?? defaultRadioGroupAppearanceProvider;\n    const appearances = normalizeAppearance(apProvider(this, widget));\n    this.updateOnOffWidgetAppearance(widget, onValue, appearances);\n  }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFField from 'src/api/form/PDFField';\n\nimport { PDFRef, PDFAcroSignature } from 'src/core';\nimport { assertIs } from 'src/utils';\n\n/**\n * Represents a signature field of a [[PDFForm]].\n *\n * [[PDFSignature]] fields are digital signatures. `pdf-lib` does not\n * currently provide any specialized APIs for creating digital signatures or\n * reading the contents of existing digital signatures.\n */\nexport default class PDFSignature extends PDFField {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFForm.getSignature]] method, which will create an\n   * \u003e instance of [[PDFSignature]] for you.\n   *\n   * Create an instance of [[PDFSignature]] from an existing acroSignature and\n   * ref\n   *\n   * @param acroSignature The underlying `PDFAcroSignature` for this signature.\n   * @param ref The unique reference for this signature.\n   * @param doc The document to which this signature will belong.\n   */\n  static of = (\n    acroSignature: PDFAcroSignature,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) =\u003e new PDFSignature(acroSignature, ref, doc);\n\n  /** The low-level PDFAcroSignature wrapped by this signature. */\n  readonly acroField: PDFAcroSignature;\n\n  private constructor(\n    acroSignature: PDFAcroSignature,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) {\n    super(acroSignature, ref, doc);\n\n    assertIs(acroSignature, 'acroSignature', [\n      [PDFAcroSignature, 'PDFAcroSignature'],\n    ]);\n\n    this.acroField = acroSignature;\n  }\n\n  needsAppearancesUpdate() {\n    return false;\n  }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport PDFField, {\n  FieldAppearanceOptions,\n  assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport {\n  AppearanceProviderFor,\n  normalizeAppearance,\n  defaultTextFieldAppearanceProvider,\n} from 'src/api/form/appearances';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\nimport {\n  RichTextFieldReadError,\n  ExceededMaxLengthError,\n  InvalidMaxLengthError,\n} from 'src/api/errors';\nimport { ImageAlignment } from 'src/api/image/alignment';\nimport { TextAlignment } from 'src/api/text/alignment';\n\nimport {\n  PDFHexString,\n  PDFRef,\n  PDFStream,\n  PDFAcroText,\n  AcroTextFlags,\n  PDFWidgetAnnotation,\n} from 'src/core';\nimport {\n  assertIs,\n  assertIsOneOf,\n  assertOrUndefined,\n  assertPositive,\n  assertRangeOrUndefined,\n} from 'src/utils';\n\n/**\n * Represents a text field of a [[PDFForm]].\n *\n * [[PDFTextField]] fields are boxes that display text entered by the user. The\n * purpose of a text field is to enable users to enter text or view text values\n * in the document prefilled by software. Users can click on a text field and\n * input text via their keyboard. Some text fields allow multiple lines of text\n * to be entered (see [[PDFTextField.isMultiline]]).\n */\nexport default class PDFTextField extends PDFField {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFForm.getTextField]] method, which will create an\n   * \u003e instance of [[PDFTextField]] for you.\n   *\n   * Create an instance of [[PDFTextField]] from an existing acroText and ref\n   *\n   * @param acroText The underlying `PDFAcroText` for this text field.\n   * @param ref The unique reference for this text field.\n   * @param doc The document to which this text field will belong.\n   */\n  static of = (acroText: PDFAcroText, ref: PDFRef, doc: PDFDocument) =\u003e\n    new PDFTextField(acroText, ref, doc);\n\n  /** The low-level PDFAcroText wrapped by this text field. */\n  readonly acroField: PDFAcroText;\n\n  private constructor(acroText: PDFAcroText, ref: PDFRef, doc: PDFDocument) {\n    super(acroText, ref, doc);\n\n    assertIs(acroText, 'acroText', [[PDFAcroText, 'PDFAcroText']]);\n\n    this.acroField = acroText;\n  }\n\n  /**\n   * Get the text that this field contains. This text is visible to users who\n   * view this field in a PDF reader.\n   *\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * const text = textField.getText()\n   * console.log('Text field contents:', text)\n   * ```\n   *\n   * Note that if this text field contains no underlying value, `undefined`\n   * will be returned. Text fields may also contain an underlying value that\n   * is simply an empty string (`''`). This detail is largely irrelevant for\n   * most applications. In general, you'll want to treat both cases the same\n   * way and simply consider the text field to be empty. In either case, the\n   * text field will appear empty to users when viewed in a PDF reader.\n   *\n   * An error will be thrown if this is a rich text field. `pdf-lib` does not\n   * support reading rich text fields. Nor do most PDF readers and writers.\n   * Rich text fields are based on XFA (XML Forms Architecture). Relatively few\n   * PDFs use rich text fields or XFA. Unlike PDF itself, XFA is not an ISO\n   * standard. XFA has been deprecated in PDF 2.0:\n   * * https://en.wikipedia.org/wiki/XFA\n   * * http://blog.pdfshareforms.com/pdf-2-0-release-bid-farewell-xfa-forms/\n   *\n   * @returns The text contained in this text field.\n   */\n  getText(): string | undefined {\n    const value = this.acroField.getValue();\n    if (!value \u0026\u0026 this.isRichFormatted()) {\n      throw new RichTextFieldReadError(this.getName());\n    }\n    return value?.decodeText();\n  }\n\n  /**\n   * Set the text for this field. This operation is analogous to a human user\n   * clicking on the text field in a PDF reader and typing in text via their\n   * keyboard. This method will update the underlying state of the text field\n   * to indicate what text has been set. PDF libraries and readers will be able\n   * to extract these values from the saved document and determine what text\n   * was set.\n   *\n   * For example:\n   * ```js\n   * const textField = form.getTextField('best.superhero.text.field')\n   * textField.setText('One Punch Man')\n   * ```\n   *\n   * This method will mark this text field as dirty, causing its appearance\n   * streams to be updated when either [[PDFDocument.save]] or\n   * [[PDFForm.updateFieldAppearances]] is called. The updated streams will\n   * display the text this field contains inside the widgets of this text\n   * field.\n   *\n   * **IMPORTANT:** The default font used to update appearance streams is\n   * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n   * that encoding errors will be thrown if this field contains text outside\n   * the WinAnsi character set (the latin alphabet).\n   *\n   * Embedding a custom font and passing it to\n   * [[PDFForm.updateFieldAppearances]] or [[PDFTextField.updateAppearances]]\n   * allows you to generate appearance streams with characters outside the\n   * latin alphabet (assuming the custom font supports them).\n   *\n   * If this is a rich text field, it will be converted to a standard text\n   * field in order to set the text. `pdf-lib` does not support writing rich\n   * text strings. Nor do most PDF readers and writers. See\n   * [[PDFTextField.getText]] for more information about rich text fields and\n   * their deprecation in PDF 2.0.\n   *\n   * @param text The text this field should contain.\n   */\n  setText(text: string | undefined) {\n    assertOrUndefined(text, 'text', ['string']);\n\n    const maxLength = this.getMaxLength();\n    if (maxLength !== undefined \u0026\u0026 text \u0026\u0026 text.length \u003e maxLength) {\n      throw new ExceededMaxLengthError(text.length, maxLength, this.getName());\n    }\n\n    this.markAsDirty();\n    this.disableRichFormatting();\n\n    if (text) {\n      this.acroField.setValue(PDFHexString.fromText(text));\n    } else {\n      this.acroField.removeValue();\n    }\n  }\n\n  /**\n   * Get the alignment for this text field. This value represents the\n   * justification of the text when it is displayed to the user in PDF readers.\n   * There are three possible alignments: left, center, and right. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * const alignment = textField.getAlignment()\n   * if (alignment === TextAlignment.Left) console.log('Text is left justified')\n   * if (alignment === TextAlignment.Center) console.log('Text is centered')\n   * if (alignment === TextAlignment.Right) console.log('Text is right justified')\n   * ```\n   * @returns The alignment of this text field.\n   */\n  getAlignment(): TextAlignment {\n    const quadding = this.acroField.getQuadding();\n\n    // prettier-ignore\n    return (\n        quadding === 0 ? TextAlignment.Left\n      : quadding === 1 ? TextAlignment.Center\n      : quadding === 2 ? TextAlignment.Right\n      : TextAlignment.Left\n    );\n  }\n\n  /**\n   * Set the alignment for this text field. This will determine the\n   * justification of the text when it is displayed to the user in PDF readers.\n   * There are three possible alignments: left, center, and right. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   *\n   * // Text will be left justified when displayed\n   * textField.setAlignment(TextAlignment.Left)\n   *\n   * // Text will be centered when displayed\n   * textField.setAlignment(TextAlignment.Center)\n   *\n   * // Text will be right justified when displayed\n   * textField.setAlignment(TextAlignment.Right)\n   * ```\n   * This method will mark this text field as dirty. See\n   * [[PDFTextField.setText]] for more details about what this means.\n   * @param alignment The alignment for this text field.\n   */\n  setAlignment(alignment: TextAlignment) {\n    assertIsOneOf(alignment, 'alignment', TextAlignment);\n    this.markAsDirty();\n    this.acroField.setQuadding(alignment);\n  }\n\n  /**\n   * Get the maximum length of this field. This value represents the maximum\n   * number of characters that can be typed into this field by the user. If\n   * this field does not have a maximum length, `undefined` is returned.\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * const maxLength = textField.getMaxLength()\n   * if (maxLength === undefined) console.log('No max length')\n   * else console.log(`Max length is ${maxLength}`)\n   * ```\n   * @returns The maximum number of characters allowed in this field, or\n   *          `undefined` if no limit exists.\n   */\n  getMaxLength(): number | undefined {\n    return this.acroField.getMaxLength();\n  }\n\n  /**\n   * Set the maximum length of this field. This limits the number of characters\n   * that can be typed into this field by the user. This also limits the length\n   * of the string that can be passed to [[PDFTextField.setText]]. This limit\n   * can be removed by passing `undefined` as `maxLength`. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   *\n   * // Allow between 0 and 5 characters to be entered\n   * textField.setMaxLength(5)\n   *\n   * // Allow any number of characters to be entered\n   * textField.setMaxLength(undefined)\n   * ```\n   * This method will mark this text field as dirty. See\n   * [[PDFTextField.setText]] for more details about what this means.\n   * @param maxLength The maximum number of characters allowed in this field, or\n   *                  `undefined` to remove the limit.\n   */\n  setMaxLength(maxLength?: number) {\n    assertRangeOrUndefined(maxLength, 'maxLength', 0, Number.MAX_SAFE_INTEGER);\n\n    this.markAsDirty();\n\n    if (maxLength === undefined) {\n      this.acroField.removeMaxLength();\n    } else {\n      const text = this.getText();\n      if (text \u0026\u0026 text.length \u003e maxLength) {\n        throw new InvalidMaxLengthError(text.length, maxLength, this.getName());\n      }\n      this.acroField.setMaxLength(maxLength);\n    }\n  }\n\n  /**\n   * Remove the maximum length for this text field. This allows any number of\n   * characters to be typed into this field by the user. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.removeMaxLength()\n   * ```\n   * Calling this method is equivalent to passing `undefined` to\n   * [[PDFTextField.setMaxLength]].\n   */\n  removeMaxLength() {\n    this.markAsDirty();\n    this.acroField.removeMaxLength();\n  }\n\n  /**\n   * Display an image inside the bounds of this text field's widgets. For example:\n   * ```js\n   * const pngImage = await pdfDoc.embedPng(...)\n   * const textField = form.getTextField('some.text.field')\n   * textField.setImage(pngImage)\n   * ```\n   * This will update the appearances streams for each of this text field's widgets.\n   * @param image The image that should be displayed.\n   */\n  setImage(image: PDFImage) {\n    const fieldAlignment = this.getAlignment();\n\n    // prettier-ignore\n    const alignment = \n        fieldAlignment === TextAlignment.Center ? ImageAlignment.Center\n      : fieldAlignment === TextAlignment.Right ? ImageAlignment.Right\n      : ImageAlignment.Left;\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const streamRef = this.createImageAppearanceStream(\n        widget,\n        image,\n        alignment,\n      );\n      this.updateWidgetAppearances(widget, { normal: streamRef });\n    }\n\n    this.markAsClean();\n  }\n\n  /**\n   * Set the font size for this field. Larger font sizes will result in larger\n   * text being displayed when PDF readers render this text field. Font sizes\n   * may be integer or floating point numbers. Supplying a negative font size\n   * will cause this method to throw an error.\n   *\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.setFontSize(4)\n   * textField.setFontSize(15.7)\n   * ```\n   *\n   * \u003e This method depends upon the existence of a default appearance\n   * \u003e (`/DA`) string. If this field does not have a default appearance string,\n   * \u003e or that string does not contain a font size (via the `Tf` operator),\n   * \u003e then this method will throw an error.\n   *\n   * @param fontSize The font size to be used when rendering text in this field.\n   */\n  setFontSize(fontSize: number) {\n    assertPositive(fontSize, 'fontSize');\n    this.acroField.setFontSize(fontSize);\n    this.markAsDirty();\n  }\n\n  /**\n   * Returns `true` if each line of text is shown on a new line when this\n   * field is displayed in a PDF reader. The alternative is that all lines of\n   * text are merged onto a single line when displayed. See\n   * [[PDFTextField.enableMultiline]] and [[PDFTextField.disableMultiline]].\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.isMultiline()) console.log('Multiline is enabled')\n   * ```\n   * @returns Whether or not this is a multiline text field.\n   */\n  isMultiline(): boolean {\n    return this.acroField.hasFlag(AcroTextFlags.Multiline);\n  }\n\n  /**\n   * Display each line of text on a new line when this field is displayed in a\n   * PDF reader. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.enableMultiline()\n   * ```\n   * This method will mark this text field as dirty. See\n   * [[PDFTextField.setText]] for more details about what this means.\n   */\n  enableMultiline() {\n    this.markAsDirty();\n    this.acroField.setFlagTo(AcroTextFlags.Multiline, true);\n  }\n\n  /**\n   * Display each line of text on the same line when this field is displayed\n   * in a PDF reader. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.disableMultiline()\n   * ```\n   * This method will mark this text field as dirty. See\n   * [[PDFTextField.setText]] for more details about what this means.\n   */\n  disableMultiline() {\n    this.markAsDirty();\n    this.acroField.setFlagTo(AcroTextFlags.Multiline, false);\n  }\n\n  /**\n   * Returns `true` if this is a password text field. This means that the field\n   * is intended for storing a secure password. See\n   * [[PDFTextField.enablePassword]] and [[PDFTextField.disablePassword]].\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.isPassword()) console.log('Password is enabled')\n   * ```\n   * @returns Whether or not this is a password text field.\n   */\n  isPassword(): boolean {\n    return this.acroField.hasFlag(AcroTextFlags.Password);\n  }\n\n  /**\n   * Indicate that this text field is intended for storing a secure password.\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.enablePassword()\n   * ```\n   * Values entered into password text fields should not be displayed on the\n   * screen by PDF readers. Most PDF readers will display the value as\n   * asterisks or bullets. PDF readers should never store values entered by the\n   * user into password text fields. Similarly, applications should not\n   * write data to a password text field.\n   *\n   * **Please note that this method does not cause entered values to be\n   * encrypted or secured in any way! It simply sets a flag that PDF software\n   * and readers can access to determine the _purpose_ of this field.**\n   */\n  enablePassword() {\n    this.acroField.setFlagTo(AcroTextFlags.Password, true);\n  }\n\n  /**\n   * Indicate that this text field is **not** intended for storing a secure\n   * password. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.disablePassword()\n   * ```\n   */\n  disablePassword() {\n    this.acroField.setFlagTo(AcroTextFlags.Password, false);\n  }\n\n  /**\n   * Returns `true` if the contents of this text field represent a file path.\n   * See [[PDFTextField.enableFileSelection]] and\n   * [[PDFTextField.disableFileSelection]]. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.isFileSelector()) console.log('Is a file selector')\n   * ```\n   * @returns Whether or not this field should contain file paths.\n   */\n  isFileSelector(): boolean {\n    return this.acroField.hasFlag(AcroTextFlags.FileSelect);\n  }\n\n  /**\n   * Indicate that this text field is intended to store a file path. The\n   * contents of the file stored at that path should be submitted as the value\n   * of the field. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.enableFileSelection()\n   * ```\n   */\n  enableFileSelection() {\n    this.acroField.setFlagTo(AcroTextFlags.FileSelect, true);\n  }\n\n  /**\n   * Indicate that this text field is **not** intended to store a file path.\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.disableFileSelection()\n   * ```\n   */\n  disableFileSelection() {\n    this.acroField.setFlagTo(AcroTextFlags.FileSelect, false);\n  }\n\n  /**\n   * Returns `true` if the text entered in this field should be spell checked\n   * by PDF readers. See [[PDFTextField.enableSpellChecking]] and\n   * [[PDFTextField.disableSpellChecking]]. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.isSpellChecked()) console.log('Spell checking is enabled')\n   * ```\n   * @returns Whether or not this field should be spell checked.\n   */\n  isSpellChecked(): boolean {\n    return !this.acroField.hasFlag(AcroTextFlags.DoNotSpellCheck);\n  }\n\n  /**\n   * Allow PDF readers to spell check the text entered in this field.\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.enableSpellChecking()\n   * ```\n   */\n  enableSpellChecking() {\n    this.acroField.setFlagTo(AcroTextFlags.DoNotSpellCheck, false);\n  }\n\n  /**\n   * Do not allow PDF readers to spell check the text entered in this field.\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.disableSpellChecking()\n   * ```\n   */\n  disableSpellChecking() {\n    this.acroField.setFlagTo(AcroTextFlags.DoNotSpellCheck, true);\n  }\n\n  /**\n   * Returns `true` if PDF readers should allow the user to scroll the text\n   * field when its contents do not fit within the field's view bounds. See\n   * [[PDFTextField.enableScrolling]] and [[PDFTextField.disableScrolling]].\n   * For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.isScrollable()) console.log('Scrolling is enabled')\n   * ```\n   * @returns Whether or not the field is scrollable in PDF readers.\n   */\n  isScrollable(): boolean {\n    return !this.acroField.hasFlag(AcroTextFlags.DoNotScroll);\n  }\n\n  /**\n   * Allow PDF readers to present a scroll bar to the user when the contents\n   * of this text field do not fit within its view bounds. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.enableScrolling()\n   * ```\n   * A horizontal scroll bar should be shown for singleline fields. A vertical\n   * scroll bar should be shown for multiline fields.\n   */\n  enableScrolling() {\n    this.acroField.setFlagTo(AcroTextFlags.DoNotScroll, false);\n  }\n\n  /**\n   * Do not allow PDF readers to present a scroll bar to the user when the\n   * contents of this text field do not fit within its view bounds. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.disableScrolling()\n   * ```\n   */\n  disableScrolling() {\n    this.acroField.setFlagTo(AcroTextFlags.DoNotScroll, true);\n  }\n\n  /**\n   * Returns `true` if this is a combed text field. This means that the field\n   * is split into `n` equal size cells with one character in each (where `n`\n   * is equal to the max length of the text field). The result is that all\n   * characters in this field are displayed an equal distance apart from one\n   * another. See [[PDFTextField.enableCombing]] and\n   * [[PDFTextField.disableCombing]]. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.isCombed()) console.log('Combing is enabled')\n   * ```\n   * Note that in order for a text field to be combed, the following must be\n   * true (in addition to enabling combing):\n   * * It must not be a multiline field (see [[PDFTextField.isMultiline]])\n   * * It must not be a password field (see [[PDFTextField.isPassword]])\n   * * It must not be a file selector field (see [[PDFTextField.isFileSelector]])\n   * * It must have a max length defined (see [[PDFTextField.setMaxLength]])\n   * @returns Whether or not this field is combed.\n   */\n  isCombed(): boolean {\n    return (\n      this.acroField.hasFlag(AcroTextFlags.Comb) \u0026\u0026\n      !this.isMultiline() \u0026\u0026\n      !this.isPassword() \u0026\u0026\n      !this.isFileSelector() \u0026\u0026\n      this.getMaxLength() !== undefined\n    );\n  }\n\n  /**\n   * Split this field into `n` equal size cells with one character in each\n   * (where `n` is equal to the max length of the text field). This will cause\n   * all characters in the field to be displayed an equal distance apart from\n   * one another. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.enableCombing()\n   * ```\n   *\n   * In addition to calling this method, text fields must have a max length\n   * defined in order to be combed (see [[PDFTextField.setMaxLength]]).\n   *\n   * This method will also call the following three methods internally:\n   * * [[PDFTextField.disableMultiline]]\n   * * [[PDFTextField.disablePassword]]\n   * * [[PDFTextField.disableFileSelection]]\n   *\n   * This method will mark this text field as dirty. See\n   * [[PDFTextField.setText]] for more details about what this means.\n   */\n  enableCombing() {\n    if (this.getMaxLength() === undefined) {\n      const msg = `PDFTextFields must have a max length in order to be combed`;\n      console.warn(msg);\n    }\n\n    this.markAsDirty();\n\n    this.disableMultiline();\n    this.disablePassword();\n    this.disableFileSelection();\n\n    this.acroField.setFlagTo(AcroTextFlags.Comb, true);\n  }\n\n  /**\n   * Turn off combing for this text field. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.disableCombing()\n   * ```\n   * See [[PDFTextField.isCombed]] and [[PDFTextField.enableCombing]] for more\n   * information about what combing is.\n   *\n   * This method will mark this text field as dirty. See\n   * [[PDFTextField.setText]] for more details about what this means.\n   */\n  disableCombing() {\n    this.markAsDirty();\n    this.acroField.setFlagTo(AcroTextFlags.Comb, false);\n  }\n\n  /**\n   * Returns `true` if this text field contains rich text. See\n   * [[PDFTextField.enableRichFormatting]] and\n   * [[PDFTextField.disableRichFormatting]]. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.isRichFormatted()) console.log('Rich formatting enabled')\n   * ```\n   * @returns Whether or not this field contains rich text.\n   */\n  isRichFormatted(): boolean {\n    return this.acroField.hasFlag(AcroTextFlags.RichText);\n  }\n\n  /**\n   * Indicate that this field contains XFA data - or rich text. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.enableRichFormatting()\n   * ```\n   * Note that `pdf-lib` does not support reading or writing rich text fields.\n   * Nor do most PDF readers and writers. Rich text fields are based on XFA\n   * (XML Forms Architecture). Relatively few PDFs use rich text fields or XFA.\n   * Unlike PDF itself, XFA is not an ISO standard. XFA has been deprecated in\n   * PDF 2.0:\n   * * https://en.wikipedia.org/wiki/XFA\n   * * http://blog.pdfshareforms.com/pdf-2-0-release-bid-farewell-xfa-forms/\n   */\n  enableRichFormatting() {\n    this.acroField.setFlagTo(AcroTextFlags.RichText, true);\n  }\n\n  /**\n   * Indicate that this is a standard text field that does not XFA data (rich\n   * text). For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * textField.disableRichFormatting()\n   * ```\n   */\n  disableRichFormatting() {\n    this.acroField.setFlagTo(AcroTextFlags.RichText, false);\n  }\n\n  /**\n   * Show this text field on the specified page. For example:\n   * ```js\n   * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const textField = form.createTextField('best.gundam')\n   * textField.setText('Exia')\n   *\n   * textField.addToPage(page, {\n   *   x: 50,\n   *   y: 75,\n   *   width: 200,\n   *   height: 100,\n   *   textColor: rgb(1, 0, 0),\n   *   backgroundColor: rgb(0, 1, 0),\n   *   borderColor: rgb(0, 0, 1),\n   *   borderWidth: 2,\n   *   rotate: degrees(90),\n   *   font: ubuntuFont,\n   * })\n   * ```\n   * This will create a new widget for this text field.\n   * @param page The page to which this text field widget should be added.\n   * @param options The options to be used when adding this text field widget.\n   */\n  addToPage(page: PDFPage, options?: FieldAppearanceOptions) {\n    assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n    assertFieldAppearanceOptions(options);\n\n    if (!options) options = {};\n\n    if (!('textColor' in options)) options.textColor = rgb(0, 0, 0);\n    if (!('backgroundColor' in options)) options.backgroundColor = rgb(1, 1, 1);\n    if (!('borderColor' in options)) options.borderColor = rgb(0, 0, 0);\n    if (!('borderWidth' in options)) options.borderWidth = 1;\n\n    // Create a widget for this text field\n    const widget = this.createWidget({\n      x: options.x ?? 0,\n      y: options.y ?? 0,\n      width: options.width ?? 200,\n      height: options.height ?? 50,\n      textColor: options.textColor,\n      backgroundColor: options.backgroundColor,\n      borderColor: options.borderColor,\n      borderWidth: options.borderWidth ?? 0,\n      rotate: options.rotate ?? degrees(0),\n      hidden: options.hidden,\n      page: page.ref,\n    });\n    const widgetRef = this.doc.context.register(widget.dict);\n\n    // Add widget to this field\n    this.acroField.addWidget(widgetRef);\n\n    // Set appearance streams for widget\n    const font = options.font ?? this.doc.getForm().getDefaultFont();\n    this.updateWidgetAppearance(widget, font);\n\n    // Add widget to the given page\n    page.node.addAnnot(widgetRef);\n  }\n\n  /**\n   * Returns `true` if this text field has been marked as dirty, or if any of\n   * this text field's widgets do not have an appearance stream. For example:\n   * ```js\n   * const textField = form.getTextField('some.text.field')\n   * if (textField.needsAppearancesUpdate()) console.log('Needs update')\n   * ```\n   * @returns Whether or not this text field needs an appearance update.\n   */\n  needsAppearancesUpdate(): boolean {\n    if (this.isDirty()) return true;\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const hasAppearances =\n        widget.getAppearances()?.normal instanceof PDFStream;\n      if (!hasAppearances) return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * Update the appearance streams for each of this text field's widgets using\n   * the default appearance provider for text fields. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const textField = form.getTextField('some.text.field')\n   * textField.defaultUpdateAppearances(helvetica)\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   */\n  defaultUpdateAppearances(font: PDFFont) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    this.updateAppearances(font);\n  }\n\n  /**\n   * Update the appearance streams for each of this text field's widgets using\n   * the given appearance provider. If no `provider` is passed, the default\n   * appearance provider for text fields will be used. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const textField = form.getTextField('some.text.field')\n   * textField.updateAppearances(helvetica, (field, widget, font) =\u003e {\n   *   ...\n   *   return drawTextField(...)\n   * })\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   * @param provider Optionally, the appearance provider to be used for\n   *                 generating the contents of the appearance streams.\n   */\n  updateAppearances(\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFTextField\u003e,\n  ) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    assertOrUndefined(provider, 'provider', [Function]);\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      this.updateWidgetAppearance(widget, font, provider);\n    }\n    this.markAsClean();\n  }\n\n  private updateWidgetAppearance(\n    widget: PDFWidgetAnnotation,\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFTextField\u003e,\n  ) {\n    const apProvider = provider ?? defaultTextFieldAppearanceProvider;\n    const appearances = normalizeAppearance(apProvider(this, widget, font));\n    this.updateWidgetAppearanceWithFont(widget, font, appearances);\n  }\n}\n","export enum StandardFonts {\n  Courier = 'Courier',\n  CourierBold = 'Courier-Bold',\n  CourierOblique = 'Courier-Oblique',\n  CourierBoldOblique = 'Courier-BoldOblique',\n  Helvetica = 'Helvetica',\n  HelveticaBold = 'Helvetica-Bold',\n  HelveticaOblique = 'Helvetica-Oblique',\n  HelveticaBoldOblique = 'Helvetica-BoldOblique',\n  TimesRoman = 'Times-Roman',\n  TimesRomanBold = 'Times-Bold',\n  TimesRomanItalic = 'Times-Italic',\n  TimesRomanBoldItalic = 'Times-BoldItalic',\n  Symbol = 'Symbol',\n  ZapfDingbats = 'ZapfDingbats',\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFField from 'src/api/form/PDFField';\nimport PDFButton from 'src/api/form/PDFButton';\nimport PDFCheckBox from 'src/api/form/PDFCheckBox';\nimport PDFDropdown from 'src/api/form/PDFDropdown';\nimport PDFOptionList from 'src/api/form/PDFOptionList';\nimport PDFRadioGroup from 'src/api/form/PDFRadioGroup';\nimport PDFSignature from 'src/api/form/PDFSignature';\nimport PDFTextField from 'src/api/form/PDFTextField';\nimport {\n  NoSuchFieldError,\n  UnexpectedFieldTypeError,\n  FieldAlreadyExistsError,\n  InvalidFieldNamePartError,\n} from 'src/api/errors';\nimport PDFFont from 'src/api/PDFFont';\nimport { StandardFonts } from 'src/api/StandardFonts';\nimport { rotateInPlace } from 'src/api/operations';\nimport {\n  drawObject,\n  popGraphicsState,\n  pushGraphicsState,\n  translate,\n} from 'src/api/operators';\nimport {\n  PDFAcroForm,\n  PDFAcroField,\n  PDFAcroCheckBox,\n  PDFAcroComboBox,\n  PDFAcroListBox,\n  PDFAcroRadioButton,\n  PDFAcroSignature,\n  PDFAcroText,\n  PDFAcroPushButton,\n  PDFAcroNonTerminal,\n  PDFDict,\n  PDFOperator,\n  PDFRef,\n  createPDFAcroFields,\n  PDFName,\n  PDFWidgetAnnotation,\n} from 'src/core';\nimport { assertIs, Cache, assertOrUndefined } from 'src/utils';\n\nexport interface FlattenOptions {\n  updateFieldAppearances: boolean;\n}\n\n/**\n * Represents the interactive form of a [[PDFDocument]].\n *\n * Interactive forms (sometimes called _AcroForms_) are collections of fields\n * designed to gather information from a user. A PDF document may contains any\n * number of fields that appear on various pages, all of which make up a single,\n * global interactive form spanning the entire document. This means that\n * instances of [[PDFDocument]] shall contain at most one [[PDFForm]].\n *\n * The fields of an interactive form are represented by [[PDFField]] instances.\n */\nexport default class PDFForm {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.getForm]] method, which will create an\n   * \u003e instance of [[PDFForm]] for you.\n   *\n   * Create an instance of [[PDFForm]] from an existing acroForm and embedder\n   *\n   * @param acroForm The underlying `PDFAcroForm` for this form.\n   * @param doc The document to which the form will belong.\n   */\n  static of = (acroForm: PDFAcroForm, doc: PDFDocument) =\u003e\n    new PDFForm(acroForm, doc);\n\n  /** The low-level PDFAcroForm wrapped by this form. */\n  readonly acroForm: PDFAcroForm;\n\n  /** The document to which this form belongs. */\n  readonly doc: PDFDocument;\n\n  private readonly dirtyFields: Set\u003cPDFRef\u003e;\n  private readonly defaultFontCache: Cache\u003cPDFFont\u003e;\n\n  private constructor(acroForm: PDFAcroForm, doc: PDFDocument) {\n    assertIs(acroForm, 'acroForm', [[PDFAcroForm, 'PDFAcroForm']]);\n    assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n\n    this.acroForm = acroForm;\n    this.doc = doc;\n\n    this.dirtyFields = new Set();\n    this.defaultFontCache = Cache.populatedBy(this.embedDefaultFont);\n  }\n\n  /**\n   * Returns `true` if this [[PDFForm]] has XFA data. Most PDFs with form\n   * fields do not use XFA as it is not widely supported by PDF readers.\n   *\n   * \u003e `pdf-lib` does not support creation, modification, or reading of XFA\n   * \u003e fields.\n   *\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * if (form.hasXFA()) console.log('PDF has XFA data')\n   * ```\n   * @returns Whether or not this form has XFA data.\n   */\n  hasXFA(): boolean {\n    return this.acroForm.dict.has(PDFName.of('XFA'));\n  }\n\n  /**\n   * Disconnect the XFA data from this [[PDFForm]] (if any exists). This will\n   * force readers to fallback to standard fields if the [[PDFDocument]]\n   * contains any. For example:\n   *\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * form.deleteXFA()\n   * ```\n   */\n  deleteXFA(): void {\n    this.acroForm.dict.delete(PDFName.of('XFA'));\n  }\n\n  /**\n   * Get all fields contained in this [[PDFForm]]. For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const fields = form.getFields()\n   * fields.forEach(field =\u003e {\n   *   const type = field.constructor.name\n   *   const name = field.getName()\n   *   console.log(`${type}: ${name}`)\n   * })\n   * ```\n   * @returns An array of all fields in this form.\n   */\n  getFields(): PDFField[] {\n    const allFields = this.acroForm.getAllFields();\n\n    const fields: PDFField[] = [];\n    for (let idx = 0, len = allFields.length; idx \u003c len; idx++) {\n      const [acroField, ref] = allFields[idx];\n      const field = convertToPDFField(acroField, ref, this.doc);\n      if (field) fields.push(field);\n    }\n\n    return fields;\n  }\n\n  /**\n   * Get the field in this [[PDFForm]] with the given name. For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const field = form.getFieldMaybe('Page1.Foo.Bar[0]')\n   * if (field) console.log('Field exists!')\n   * ```\n   * @param name A fully qualified field name.\n   * @returns The field with the specified name, if one exists.\n   */\n  getFieldMaybe(name: string): PDFField | undefined {\n    assertIs(name, 'name', ['string']);\n    const fields = this.getFields();\n    for (let idx = 0, len = fields.length; idx \u003c len; idx++) {\n      const field = fields[idx];\n      if (field.getName() === name) return field;\n    }\n    return undefined;\n  }\n\n  /**\n   * Get the field in this [[PDFForm]] with the given name. For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const field = form.getField('Page1.Foo.Bar[0]')\n   * ```\n   * If no field exists with the provided name, an error will be thrown.\n   * @param name A fully qualified field name.\n   * @returns The field with the specified name.\n   */\n  getField(name: string): PDFField {\n    assertIs(name, 'name', ['string']);\n    const field = this.getFieldMaybe(name);\n    if (field) return field;\n    throw new NoSuchFieldError(name);\n  }\n\n  /**\n   * Get the button field in this [[PDFForm]] with the given name. For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const button = form.getButton('Page1.Foo.Button[0]')\n   * ```\n   * An error will be thrown if no field exists with the provided name, or if\n   * the field exists but is not a button.\n   * @param name A fully qualified button name.\n   * @returns The button with the specified name.\n   */\n  getButton(name: string): PDFButton {\n    assertIs(name, 'name', ['string']);\n    const field = this.getField(name);\n    if (field instanceof PDFButton) return field;\n    throw new UnexpectedFieldTypeError(name, PDFButton, field);\n  }\n\n  /**\n   * Get the check box field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const checkBox = form.getCheckBox('Page1.Foo.CheckBox[0]')\n   * checkBox.check()\n   * ```\n   * An error will be thrown if no field exists with the provided name, or if\n   * the field exists but is not a check box.\n   * @param name A fully qualified check box name.\n   * @returns The check box with the specified name.\n   */\n  getCheckBox(name: string): PDFCheckBox {\n    assertIs(name, 'name', ['string']);\n    const field = this.getField(name);\n    if (field instanceof PDFCheckBox) return field;\n    throw new UnexpectedFieldTypeError(name, PDFCheckBox, field);\n  }\n\n  /**\n   * Get the dropdown field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const dropdown = form.getDropdown('Page1.Foo.Dropdown[0]')\n   * const options = dropdown.getOptions()\n   * dropdown.select(options[0])\n   * ```\n   * An error will be thrown if no field exists with the provided name, or if\n   * the field exists but is not a dropdown.\n   * @param name A fully qualified dropdown name.\n   * @returns The dropdown with the specified name.\n   */\n  getDropdown(name: string): PDFDropdown {\n    assertIs(name, 'name', ['string']);\n    const field = this.getField(name);\n    if (field instanceof PDFDropdown) return field;\n    throw new UnexpectedFieldTypeError(name, PDFDropdown, field);\n  }\n\n  /**\n   * Get the option list field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const optionList = form.getOptionList('Page1.Foo.OptionList[0]')\n   * const options = optionList.getOptions()\n   * optionList.select(options[0])\n   * ```\n   * An error will be thrown if no field exists with the provided name, or if\n   * the field exists but is not an option list.\n   * @param name A fully qualified option list name.\n   * @returns The option list with the specified name.\n   */\n  getOptionList(name: string): PDFOptionList {\n    assertIs(name, 'name', ['string']);\n    const field = this.getField(name);\n    if (field instanceof PDFOptionList) return field;\n    throw new UnexpectedFieldTypeError(name, PDFOptionList, field);\n  }\n\n  /**\n   * Get the radio group field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const radioGroup = form.getRadioGroup('Page1.Foo.RadioGroup[0]')\n   * const options = radioGroup.getOptions()\n   * radioGroup.select(options[0])\n   * ```\n   * An error will be thrown if no field exists with the provided name, or if\n   * the field exists but is not a radio group.\n   * @param name A fully qualified radio group name.\n   * @returns The radio group with the specified name.\n   */\n  getRadioGroup(name: string): PDFRadioGroup {\n    assertIs(name, 'name', ['string']);\n    const field = this.getField(name);\n    if (field instanceof PDFRadioGroup) return field;\n    throw new UnexpectedFieldTypeError(name, PDFRadioGroup, field);\n  }\n\n  /**\n   * Get the signature field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const signature = form.getSignature('Page1.Foo.Signature[0]')\n   * ```\n   * An error will be thrown if no field exists with the provided name, or if\n   * the field exists but is not a signature.\n   * @param name A fully qualified signature name.\n   * @returns The signature with the specified name.\n   */\n  getSignature(name: string): PDFSignature {\n    assertIs(name, 'name', ['string']);\n    const field = this.getField(name);\n    if (field instanceof PDFSignature) return field;\n    throw new UnexpectedFieldTypeError(name, PDFSignature, field);\n  }\n\n  /**\n   * Get the text field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const textField = form.getTextField('Page1.Foo.TextField[0]')\n   * textField.setText('Are you designed to act or to be acted upon?')\n   * ```\n   * An error will be thrown if no field exists with the provided name, or if\n   * the field exists but is not a text field.\n   * @param name A fully qualified text field name.\n   * @returns The text field with the specified name.\n   */\n  getTextField(name: string): PDFTextField {\n    assertIs(name, 'name', ['string']);\n    const field = this.getField(name);\n    if (field instanceof PDFTextField) return field;\n    throw new UnexpectedFieldTypeError(name, PDFTextField, field);\n  }\n\n  /**\n   * Create a new button field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const button = form.createButton('cool.new.button')\n   *\n   * button.addToPage('Do Stuff', font, page)\n   * ```\n   * An error will be thrown if a field already exists with the provided name.\n   * @param name The fully qualified name for the new button.\n   * @returns The new button field.\n   */\n  createButton(name: string): PDFButton {\n    assertIs(name, 'name', ['string']);\n\n    const nameParts = splitFieldName(name);\n    const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n    const button = PDFAcroPushButton.create(this.doc.context);\n    button.setPartialName(nameParts.terminal);\n\n    addFieldToParent(parent, [button, button.ref], nameParts.terminal);\n\n    return PDFButton.of(button, button.ref, this.doc);\n  }\n\n  /**\n   * Create a new check box field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const checkBox = form.createCheckBox('cool.new.checkBox')\n   *\n   * checkBox.addToPage(page)\n   * ```\n   * An error will be thrown if a field already exists with the provided name.\n   * @param name The fully qualified name for the new check box.\n   * @returns The new check box field.\n   */\n  createCheckBox(name: string): PDFCheckBox {\n    assertIs(name, 'name', ['string']);\n\n    const nameParts = splitFieldName(name);\n    const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n    const checkBox = PDFAcroCheckBox.create(this.doc.context);\n    checkBox.setPartialName(nameParts.terminal);\n\n    addFieldToParent(parent, [checkBox, checkBox.ref], nameParts.terminal);\n\n    return PDFCheckBox.of(checkBox, checkBox.ref, this.doc);\n  }\n\n  /**\n   * Create a new dropdown field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const dropdown = form.createDropdown('cool.new.dropdown')\n   *\n   * dropdown.addToPage(font, page)\n   * ```\n   * An error will be thrown if a field already exists with the provided name.\n   * @param name The fully qualified name for the new dropdown.\n   * @returns The new dropdown field.\n   */\n  createDropdown(name: string): PDFDropdown {\n    assertIs(name, 'name', ['string']);\n\n    const nameParts = splitFieldName(name);\n    const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n    const comboBox = PDFAcroComboBox.create(this.doc.context);\n    comboBox.setPartialName(nameParts.terminal);\n\n    addFieldToParent(parent, [comboBox, comboBox.ref], nameParts.terminal);\n\n    return PDFDropdown.of(comboBox, comboBox.ref, this.doc);\n  }\n\n  /**\n   * Create a new option list field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const optionList = form.createOptionList('cool.new.optionList')\n   *\n   * optionList.addToPage(font, page)\n   * ```\n   * An error will be thrown if a field already exists with the provided name.\n   * @param name The fully qualified name for the new option list.\n   * @returns The new option list field.\n   */\n  createOptionList(name: string): PDFOptionList {\n    assertIs(name, 'name', ['string']);\n\n    const nameParts = splitFieldName(name);\n    const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n    const listBox = PDFAcroListBox.create(this.doc.context);\n    listBox.setPartialName(nameParts.terminal);\n\n    addFieldToParent(parent, [listBox, listBox.ref], nameParts.terminal);\n\n    return PDFOptionList.of(listBox, listBox.ref, this.doc);\n  }\n\n  /**\n   * Create a new radio group field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const radioGroup = form.createRadioGroup('cool.new.radioGroup')\n   *\n   * radioGroup.addOptionToPage('is-dog', page, { y: 0 })\n   * radioGroup.addOptionToPage('is-cat', page, { y: 75 })\n   * ```\n   * An error will be thrown if a field already exists with the provided name.\n   * @param name The fully qualified name for the new radio group.\n   * @returns The new radio group field.\n   */\n  createRadioGroup(name: string): PDFRadioGroup {\n    assertIs(name, 'name', ['string']);\n    const nameParts = splitFieldName(name);\n\n    const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n    const radioButton = PDFAcroRadioButton.create(this.doc.context);\n    radioButton.setPartialName(nameParts.terminal);\n\n    addFieldToParent(\n      parent,\n      [radioButton, radioButton.ref],\n      nameParts.terminal,\n    );\n\n    return PDFRadioGroup.of(radioButton, radioButton.ref, this.doc);\n  }\n\n  /**\n   * Create a new text field in this [[PDFForm]] with the given name.\n   * For example:\n   * ```js\n   * const font = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const textField = form.createTextField('cool.new.textField')\n   *\n   * textField.addToPage(font, page)\n   * ```\n   * An error will be thrown if a field already exists with the provided name.\n   * @param name The fully qualified name for the new radio group.\n   * @returns The new radio group field.\n   */\n  createTextField(name: string): PDFTextField {\n    assertIs(name, 'name', ['string']);\n    const nameParts = splitFieldName(name);\n\n    const parent = this.findOrCreateNonTerminals(nameParts.nonTerminal);\n\n    const text = PDFAcroText.create(this.doc.context);\n    text.setPartialName(nameParts.terminal);\n\n    addFieldToParent(parent, [text, text.ref], nameParts.terminal);\n\n    return PDFTextField.of(text, text.ref, this.doc);\n  }\n\n  /**\n   * Flatten all fields in this [[PDFForm]].\n   *\n   * Flattening a form field will take the current appearance for each of that\n   * field's widgets and make them part of their page's content stream. All form\n   * fields and annotations associated are then removed. Note that once a form\n   * has been flattened its fields can no longer be accessed or edited.\n   *\n   * This operation is often used after filling form fields to ensure a\n   * consistent appearance across different PDF readers and/or printers.\n   * Another common use case is to copy a template document with form fields\n   * into another document. In this scenario you would load the template\n   * document, fill its fields, flatten it, and then copy its pages into the\n   * recipient document - the filled fields will be copied over.\n   *\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm();\n   * form.flatten();\n   * ```\n   */\n  flatten(options: FlattenOptions = { updateFieldAppearances: true }) {\n    if (options.updateFieldAppearances) {\n      this.updateFieldAppearances();\n    }\n\n    const fields = this.getFields();\n\n    for (let i = 0, lenFields = fields.length; i \u003c lenFields; i++) {\n      const field = fields[i];\n      const widgets = field.acroField.getWidgets();\n\n      for (let j = 0, lenWidgets = widgets.length; j \u003c lenWidgets; j++) {\n        const widget = widgets[j];\n        const page = this.findWidgetPage(widget);\n        const widgetRef = this.findWidgetAppearanceRef(field, widget);\n\n        const xObjectKey = page.node.newXObject('FlatWidget', widgetRef);\n\n        const rectangle = widget.getRectangle();\n        const operators = [\n          pushGraphicsState(),\n          translate(rectangle.x, rectangle.y),\n          ...rotateInPlace({ ...rectangle, rotation: 0 }),\n          drawObject(xObjectKey),\n          popGraphicsState(),\n        ].filter(Boolean) as PDFOperator[];\n\n        page.pushOperators(...operators);\n      }\n\n      this.removeField(field);\n    }\n  }\n\n  /**\n   * Remove a field from this [[PDFForm]].\n   *\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm();\n   * const ageField = form.getFields().find(x =\u003e x.getName() === 'Age');\n   * form.removeField(ageField);\n   * ```\n   */\n  removeField(field: PDFField) {\n    const widgets = field.acroField.getWidgets();\n    const pages: Set\u003cPDFPage\u003e = new Set();\n\n    for (let i = 0, len = widgets.length; i \u003c len; i++) {\n      const widget = widgets[i];\n      const widgetRef = this.findWidgetAppearanceRef(field, widget);\n\n      const page = this.findWidgetPage(widget);\n      pages.add(page);\n\n      page.node.removeAnnot(widgetRef);\n    }\n\n    pages.forEach((page) =\u003e page.node.removeAnnot(field.ref));\n    this.acroForm.removeField(field.acroField);\n    const fieldKids = field.acroField.normalizedEntries().Kids;\n    const kidsCount = fieldKids.size();\n    for (let childIndex = 0; childIndex \u003c kidsCount; childIndex++) {\n      const child = fieldKids.get(childIndex);\n      if (child instanceof PDFRef) {\n        this.doc.context.delete(child);\n      }\n    }\n    this.doc.context.delete(field.ref);\n  }\n\n  /**\n   * Update the appearance streams for all widgets of all fields in this\n   * [[PDFForm]]. Appearance streams will only be created for a widget if it\n   * does not have any existing appearance streams, or the field's value has\n   * changed (e.g. by calling [[PDFTextField.setText]] or\n   * [[PDFDropdown.select]]).\n   *\n   * For example:\n   * ```js\n   * const courier = await pdfDoc.embedFont(StandardFonts.Courier)\n   * const form = pdfDoc.getForm()\n   * form.updateFieldAppearances(courier)\n   * ```\n   *\n   * **IMPORTANT:** The default value for the `font` parameter is\n   * [[StandardFonts.Helvetica]]. Note that this is a WinAnsi font. This means\n   * that encoding errors will be thrown if any fields contain text with\n   * characters outside the WinAnsi character set (the latin alphabet).\n   *\n   * Embedding a custom font and passing that as the `font`\n   * parameter allows you to generate appearance streams with non WinAnsi\n   * characters (assuming your custom font supports them).\n   *\n   * \u003e **NOTE:** The [[PDFDocument.save]] method will call this method to\n   * \u003e update appearances automatically if a form was accessed via the\n   * \u003e [[PDFDocument.getForm]] method prior to saving.\n   *\n   * @param font Optionally, the font to use when creating new appearances.\n   */\n  updateFieldAppearances(font?: PDFFont) {\n    assertOrUndefined(font, 'font', [[PDFFont, 'PDFFont']]);\n\n    font = font ?? this.getDefaultFont();\n\n    const fields = this.getFields();\n\n    for (let idx = 0, len = fields.length; idx \u003c len; idx++) {\n      const field = fields[idx];\n      if (field.needsAppearancesUpdate()) {\n        field.defaultUpdateAppearances(font);\n      }\n    }\n  }\n\n  /**\n   * Mark a field as dirty. This will cause its appearance streams to be\n   * updated by [[PDFForm.updateFieldAppearances]].\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const field = form.getField('foo.bar')\n   * form.markFieldAsDirty(field.ref)\n   * ```\n   * @param fieldRef The reference to the field that should be marked.\n   */\n  markFieldAsDirty(fieldRef: PDFRef) {\n    assertOrUndefined(fieldRef, 'fieldRef', [[PDFRef, 'PDFRef']]);\n    this.dirtyFields.add(fieldRef);\n  }\n\n  /**\n   * Mark a field as dirty. This will cause its appearance streams to not be\n   * updated by [[PDFForm.updateFieldAppearances]].\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const field = form.getField('foo.bar')\n   * form.markFieldAsClean(field.ref)\n   * ```\n   * @param fieldRef The reference to the field that should be marked.\n   */\n  markFieldAsClean(fieldRef: PDFRef) {\n    assertOrUndefined(fieldRef, 'fieldRef', [[PDFRef, 'PDFRef']]);\n    this.dirtyFields.delete(fieldRef);\n  }\n\n  /**\n   * Returns `true` is the specified field has been marked as dirty.\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const field = form.getField('foo.bar')\n   * if (form.fieldIsDirty(field.ref)) console.log('Field is dirty')\n   * ```\n   * @param fieldRef The reference to the field that should be checked.\n   * @returns Whether or not the specified field is dirty.\n   */\n  fieldIsDirty(fieldRef: PDFRef): boolean {\n    assertOrUndefined(fieldRef, 'fieldRef', [[PDFRef, 'PDFRef']]);\n    return this.dirtyFields.has(fieldRef);\n  }\n\n  getDefaultFont() {\n    return this.defaultFontCache.access();\n  }\n\n  private findWidgetPage(widget: PDFWidgetAnnotation): PDFPage {\n    const pageRef = widget.P();\n    let page = this.doc.getPages().find((x) =\u003e x.ref === pageRef);\n    if (page === undefined) {\n      const widgetRef = this.doc.context.getObjectRef(widget.dict);\n      if (widgetRef === undefined) {\n        throw new Error('Could not find PDFRef for PDFObject');\n      }\n\n      page = this.doc.findPageForAnnotationRef(widgetRef);\n\n      if (page === undefined) {\n        throw new Error(`Could not find page for PDFRef ${widgetRef}`);\n      }\n    }\n\n    return page;\n  }\n\n  private findWidgetAppearanceRef(\n    field: PDFField,\n    widget: PDFWidgetAnnotation,\n  ): PDFRef {\n    let refOrDict = widget.getNormalAppearance();\n\n    if (\n      refOrDict instanceof PDFDict \u0026\u0026\n      (field instanceof PDFCheckBox || field instanceof PDFRadioGroup)\n    ) {\n      const value = field.acroField.getValue();\n      const ref = refOrDict.get(value) ?? refOrDict.get(PDFName.of('Off'));\n\n      if (ref instanceof PDFRef) {\n        refOrDict = ref;\n      }\n    }\n\n    if (!(refOrDict instanceof PDFRef)) {\n      const name = field.getName();\n      throw new Error(`Failed to extract appearance ref for: ${name}`);\n    }\n\n    return refOrDict;\n  }\n\n  private findOrCreateNonTerminals(partialNames: string[]) {\n    let nonTerminal: [PDFAcroForm] | [PDFAcroNonTerminal, PDFRef] = [\n      this.acroForm,\n    ];\n    for (let idx = 0, len = partialNames.length; idx \u003c len; idx++) {\n      const namePart = partialNames[idx];\n      if (!namePart) throw new InvalidFieldNamePartError(namePart);\n      const [parent, parentRef] = nonTerminal;\n      const res = this.findNonTerminal(namePart, parent);\n\n      if (res) {\n        nonTerminal = res;\n      } else {\n        const node = PDFAcroNonTerminal.create(this.doc.context);\n        node.setPartialName(namePart);\n        node.setParent(parentRef);\n        const nodeRef = this.doc.context.register(node.dict);\n        parent.addField(nodeRef);\n        nonTerminal = [node, nodeRef];\n      }\n    }\n    return nonTerminal;\n  }\n\n  private findNonTerminal(\n    partialName: string,\n    parent: PDFAcroForm | PDFAcroNonTerminal,\n  ): [PDFAcroNonTerminal, PDFRef] | undefined {\n    const fields =\n      parent instanceof PDFAcroForm\n        ? this.acroForm.getFields()\n        : createPDFAcroFields(parent.Kids());\n\n    for (let idx = 0, len = fields.length; idx \u003c len; idx++) {\n      const [field, ref] = fields[idx];\n      if (field.getPartialName() === partialName) {\n        if (field instanceof PDFAcroNonTerminal) return [field, ref];\n        throw new FieldAlreadyExistsError(partialName);\n      }\n    }\n\n    return undefined;\n  }\n\n  private embedDefaultFont = (): PDFFont =\u003e\n    this.doc.embedStandardFont(StandardFonts.Helvetica);\n}\n\nconst convertToPDFField = (\n  field: PDFAcroField,\n  ref: PDFRef,\n  doc: PDFDocument,\n): PDFField | undefined =\u003e {\n  if (field instanceof PDFAcroPushButton) return PDFButton.of(field, ref, doc);\n  if (field instanceof PDFAcroCheckBox) return PDFCheckBox.of(field, ref, doc);\n  if (field instanceof PDFAcroComboBox) return PDFDropdown.of(field, ref, doc);\n  if (field instanceof PDFAcroListBox) return PDFOptionList.of(field, ref, doc);\n  if (field instanceof PDFAcroText) return PDFTextField.of(field, ref, doc);\n  if (field instanceof PDFAcroRadioButton) {\n    return PDFRadioGroup.of(field, ref, doc);\n  }\n  if (field instanceof PDFAcroSignature) {\n    return PDFSignature.of(field, ref, doc);\n  }\n  return undefined;\n};\n\nconst splitFieldName = (fullyQualifiedName: string) =\u003e {\n  if (fullyQualifiedName.length === 0) {\n    throw new Error('PDF field names must not be empty strings');\n  }\n\n  const parts = fullyQualifiedName.split('.');\n\n  for (let idx = 0, len = parts.length; idx \u003c len; idx++) {\n    if (parts[idx] === '') {\n      throw new Error(\n        `Periods in PDF field names must be separated by at least one character: \"${fullyQualifiedName}\"`,\n      );\n    }\n  }\n\n  if (parts.length === 1) return { nonTerminal: [], terminal: parts[0] };\n\n  return {\n    nonTerminal: parts.slice(0, parts.length - 1),\n    terminal: parts[parts.length - 1],\n  };\n};\n\nconst addFieldToParent = (\n  [parent, parentRef]: [PDFAcroForm] | [PDFAcroNonTerminal, PDFRef],\n  [field, fieldRef]: [PDFAcroField, PDFRef],\n  partialName: string,\n) =\u003e {\n  const entries = parent.normalizedEntries();\n  const fields = createPDFAcroFields(\n    'Kids' in entries ? entries.Kids : entries.Fields,\n  );\n  for (let idx = 0, len = fields.length; idx \u003c len; idx++) {\n    if (fields[idx][0].getPartialName() === partialName) {\n      throw new FieldAlreadyExistsError(partialName);\n    }\n  }\n  parent.addField(fieldRef);\n  field.setParent(parentRef);\n};\n","export const PageSizes = {\n  '4A0': [4767.87, 6740.79] as [number, number],\n  '2A0': [3370.39, 4767.87] as [number, number],\n  A0: [2383.94, 3370.39] as [number, number],\n  A1: [1683.78, 2383.94] as [number, number],\n  A2: [1190.55, 1683.78] as [number, number],\n  A3: [841.89, 1190.55] as [number, number],\n  A4: [595.28, 841.89] as [number, number],\n  A5: [419.53, 595.28] as [number, number],\n  A6: [297.64, 419.53] as [number, number],\n  A7: [209.76, 297.64] as [number, number],\n  A8: [147.4, 209.76] as [number, number],\n  A9: [104.88, 147.4] as [number, number],\n  A10: [73.7, 104.88] as [number, number],\n  B0: [2834.65, 4008.19] as [number, number],\n  B1: [2004.09, 2834.65] as [number, number],\n  B2: [1417.32, 2004.09] as [number, number],\n  B3: [1000.63, 1417.32] as [number, number],\n  B4: [708.66, 1000.63] as [number, number],\n  B5: [498.9, 708.66] as [number, number],\n  B6: [354.33, 498.9] as [number, number],\n  B7: [249.45, 354.33] as [number, number],\n  B8: [175.75, 249.45] as [number, number],\n  B9: [124.72, 175.75] as [number, number],\n  B10: [87.87, 124.72] as [number, number],\n  C0: [2599.37, 3676.54] as [number, number],\n  C1: [1836.85, 2599.37] as [number, number],\n  C2: [1298.27, 1836.85] as [number, number],\n  C3: [918.43, 1298.27] as [number, number],\n  C4: [649.13, 918.43] as [number, number],\n  C5: [459.21, 649.13] as [number, number],\n  C6: [323.15, 459.21] as [number, number],\n  C7: [229.61, 323.15] as [number, number],\n  C8: [161.57, 229.61] as [number, number],\n  C9: [113.39, 161.57] as [number, number],\n  C10: [79.37, 113.39] as [number, number],\n  RA0: [2437.8, 3458.27] as [number, number],\n  RA1: [1729.13, 2437.8] as [number, number],\n  RA2: [1218.9, 1729.13] as [number, number],\n  RA3: [864.57, 1218.9] as [number, number],\n  RA4: [609.45, 864.57] as [number, number],\n  SRA0: [2551.18, 3628.35] as [number, number],\n  SRA1: [1814.17, 2551.18] as [number, number],\n  SRA2: [1275.59, 1814.17] as [number, number],\n  SRA3: [907.09, 1275.59] as [number, number],\n  SRA4: [637.8, 907.09] as [number, number],\n  Executive: [521.86, 756.0] as [number, number],\n  Folio: [612.0, 936.0] as [number, number],\n  Legal: [612.0, 1008.0] as [number, number],\n  Letter: [612.0, 792.0] as [number, number],\n  Tabloid: [792.0, 1224.0] as [number, number],\n};\n","import { EmbeddedFileOptions } from 'src/core/embedders/FileEmbedder';\nimport { TypeFeatures } from 'src/types/fontkit';\n\nexport enum ParseSpeeds {\n  Fastest = Infinity,\n  Fast = 1500,\n  Medium = 500,\n  Slow = 100,\n}\n\nexport interface AttachmentOptions extends EmbeddedFileOptions {}\n\nexport interface SaveOptions {\n  useObjectStreams?: boolean;\n  addDefaultPage?: boolean;\n  objectsPerTick?: number;\n  updateFieldAppearances?: boolean;\n}\n\nexport interface Base64SaveOptions extends SaveOptions {\n  dataUri?: boolean;\n}\n\nexport interface LoadOptions {\n  ignoreEncryption?: boolean;\n  parseSpeed?: ParseSpeeds | number;\n  throwOnInvalidObject?: boolean;\n  updateMetadata?: boolean;\n  capNumbers?: boolean;\n}\n\nexport interface CreateOptions {\n  updateMetadata?: boolean;\n}\n\nexport interface EmbedFontOptions {\n  subset?: boolean;\n  customName?: string;\n  features?: TypeFeatures;\n}\n\nexport interface SetTitleOptions {\n  showInWindowTitleBar: boolean;\n}\n","import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport FileEmbedder from 'src/core/embedders/FileEmbedder';\nimport { PDFName, PDFArray, PDFDict, PDFHexString, PDFRef } from 'src/core';\n\n/**\n * Represents a file that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFEmbeddedFile implements Embeddable {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.attach]] method, which will create\n   * instances of [[PDFEmbeddedFile]] for you.\n   *\n   * Create an instance of [[PDFEmbeddedFile]] from an existing ref and embedder\n   *\n   * @param ref The unique reference for this file.\n   * @param doc The document to which the file will belong.\n   * @param embedder The embedder that will be used to embed the file.\n   */\n  static of = (ref: PDFRef, doc: PDFDocument, embedder: FileEmbedder) =\u003e\n    new PDFEmbeddedFile(ref, doc, embedder);\n\n  /** The unique reference assigned to this embedded file within the document. */\n  readonly ref: PDFRef;\n\n  /** The document to which this embedded file belongs. */\n  readonly doc: PDFDocument;\n\n  private alreadyEmbedded = false;\n  private readonly embedder: FileEmbedder;\n\n  private constructor(ref: PDFRef, doc: PDFDocument, embedder: FileEmbedder) {\n    this.ref = ref;\n    this.doc = doc;\n    this.embedder = embedder;\n  }\n\n  /**\n   * \u003e **NOTE:** You probably don't need to call this method directly. The\n   * \u003e [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n   * \u003e automatically ensure all embeddable files get embedded.\n   *\n   * Embed this embeddable file in its document.\n   *\n   * @returns Resolves when the embedding is complete.\n   */\n  async embed(): Promise\u003cvoid\u003e {\n    if (!this.alreadyEmbedded) {\n      const ref = await this.embedder.embedIntoContext(\n        this.doc.context,\n        this.ref,\n      );\n\n      if (!this.doc.catalog.has(PDFName.of('Names'))) {\n        this.doc.catalog.set(PDFName.of('Names'), this.doc.context.obj({}));\n      }\n      const Names = this.doc.catalog.lookup(PDFName.of('Names'), PDFDict);\n\n      if (!Names.has(PDFName.of('EmbeddedFiles'))) {\n        Names.set(PDFName.of('EmbeddedFiles'), this.doc.context.obj({}));\n      }\n      const EmbeddedFiles = Names.lookup(PDFName.of('EmbeddedFiles'), PDFDict);\n\n      if (!EmbeddedFiles.has(PDFName.of('Names'))) {\n        EmbeddedFiles.set(PDFName.of('Names'), this.doc.context.obj([]));\n      }\n      const EFNames = EmbeddedFiles.lookup(PDFName.of('Names'), PDFArray);\n\n      EFNames.push(PDFHexString.fromText(this.embedder.fileName));\n      EFNames.push(ref);\n\n      /**\n       * The AF-Tag is needed to achieve PDF-A3 compliance for embedded files\n       *\n       * The following document outlines the uses cases of the associated files (AF) tag.\n       * See:\n       * https://www.pdfa.org/wp-content/uploads/2018/10/PDF20_AN002-AF.pdf\n       */\n\n      if (!this.doc.catalog.has(PDFName.of('AF'))) {\n        this.doc.catalog.set(PDFName.of('AF'), this.doc.context.obj([]));\n      }\n      const AF = this.doc.catalog.lookup(PDFName.of('AF'), PDFArray);\n      AF.push(ref);\n\n      this.alreadyEmbedded = true;\n    }\n  }\n}\n","import Embeddable from 'src/api/Embeddable';\nimport PDFDocument from 'src/api/PDFDocument';\nimport JavaScriptEmbedder from 'src/core/embedders/JavaScriptEmbedder';\nimport { PDFName, PDFArray, PDFDict, PDFHexString, PDFRef } from 'src/core';\n\n/**\n * Represents JavaScript that has been embedded in a [[PDFDocument]].\n */\nexport default class PDFJavaScript implements Embeddable {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.addJavaScript]] method, which will\n   * create instances of [[PDFJavaScript]] for you.\n   *\n   * Create an instance of [[PDFJavaScript]] from an existing ref and script\n   *\n   * @param ref The unique reference for this script.\n   * @param doc The document to which the script will belong.\n   * @param embedder The embedder that will be used to embed the script.\n   */\n  static of = (ref: PDFRef, doc: PDFDocument, embedder: JavaScriptEmbedder) =\u003e\n    new PDFJavaScript(ref, doc, embedder);\n\n  /** The unique reference assigned to this embedded script within the document. */\n  readonly ref: PDFRef;\n\n  /** The document to which this embedded script belongs. */\n  readonly doc: PDFDocument;\n\n  private alreadyEmbedded = false;\n  private readonly embedder: JavaScriptEmbedder;\n\n  private constructor(\n    ref: PDFRef,\n    doc: PDFDocument,\n    embedder: JavaScriptEmbedder,\n  ) {\n    this.ref = ref;\n    this.doc = doc;\n    this.embedder = embedder;\n  }\n\n  /**\n   * \u003e **NOTE:** You probably don't need to call this method directly. The\n   * \u003e [[PDFDocument.save]] and [[PDFDocument.saveAsBase64]] methods will\n   * \u003e automatically ensure all JavaScripts get embedded.\n   *\n   * Embed this JavaScript in its document.\n   *\n   * @returns Resolves when the embedding is complete.\n   */\n  async embed(): Promise\u003cvoid\u003e {\n    if (!this.alreadyEmbedded) {\n      const { catalog, context } = this.doc;\n\n      const ref = await this.embedder.embedIntoContext(\n        this.doc.context,\n        this.ref,\n      );\n\n      if (!catalog.has(PDFName.of('Names'))) {\n        catalog.set(PDFName.of('Names'), context.obj({}));\n      }\n      const Names = catalog.lookup(PDFName.of('Names'), PDFDict);\n\n      if (!Names.has(PDFName.of('JavaScript'))) {\n        Names.set(PDFName.of('JavaScript'), context.obj({}));\n      }\n      const Javascript = Names.lookup(PDFName.of('JavaScript'), PDFDict);\n\n      if (!Javascript.has(PDFName.of('Names'))) {\n        Javascript.set(PDFName.of('Names'), context.obj([]));\n      }\n      const JSNames = Javascript.lookup(PDFName.of('Names'), PDFArray);\n\n      JSNames.push(PDFHexString.fromText(this.embedder.scriptName));\n      JSNames.push(ref);\n\n      this.alreadyEmbedded = true;\n    }\n  }\n}\n","import PDFHexString from 'src/core/objects/PDFHexString';\nimport PDFContext from 'src/core/PDFContext';\nimport PDFRef from 'src/core/objects/PDFRef';\n\nclass JavaScriptEmbedder {\n  static for(script: string, scriptName: string) {\n    return new JavaScriptEmbedder(script, scriptName);\n  }\n\n  private readonly script: string;\n  readonly scriptName: string;\n\n  private constructor(script: string, scriptName: string) {\n    this.script = script;\n    this.scriptName = scriptName;\n  }\n\n  async embedIntoContext(context: PDFContext, ref?: PDFRef): Promise\u003cPDFRef\u003e {\n    const jsActionDict = context.obj({\n      Type: 'Action',\n      S: 'JavaScript',\n      JS: PDFHexString.fromText(this.script),\n    });\n\n    if (ref) {\n      context.assign(ref, jsActionDict);\n      return ref;\n    } else {\n      return context.register(jsActionDict);\n    }\n  }\n}\n\nexport default JavaScriptEmbedder;\n","import Embeddable from 'src/api/Embeddable';\nimport {\n  EncryptedPDFError,\n  FontkitNotRegisteredError,\n  ForeignPageError,\n  RemovePageFromEmptyDocumentError,\n} from 'src/api/errors';\nimport PDFEmbeddedPage from 'src/api/PDFEmbeddedPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFForm from 'src/api/form/PDFForm';\nimport { PageSizes } from 'src/api/sizes';\nimport { StandardFonts } from 'src/api/StandardFonts';\nimport {\n  CustomFontEmbedder,\n  CustomFontSubsetEmbedder,\n  JpegEmbedder,\n  PageBoundingBox,\n  PageEmbeddingMismatchedContextError,\n  PDFCatalog,\n  PDFContext,\n  PDFDict,\n  PDFHexString,\n  PDFName,\n  PDFObjectCopier,\n  PDFPageEmbedder,\n  PDFPageLeaf,\n  PDFPageTree,\n  PDFParser,\n  PDFStreamWriter,\n  PDFString,\n  PDFWriter,\n  PngEmbedder,\n  StandardFontEmbedder,\n  UnexpectedObjectTypeError,\n} from 'src/core';\nimport {\n  ParseSpeeds,\n  AttachmentOptions,\n  SaveOptions,\n  Base64SaveOptions,\n  LoadOptions,\n  CreateOptions,\n  EmbedFontOptions,\n  SetTitleOptions,\n} from 'src/api/PDFDocumentOptions';\nimport PDFObject from 'src/core/objects/PDFObject';\nimport PDFRef from 'src/core/objects/PDFRef';\nimport { Fontkit } from 'src/types/fontkit';\nimport { TransformationMatrix } from 'src/types/matrix';\nimport {\n  assertIs,\n  assertIsOneOfOrUndefined,\n  assertOrUndefined,\n  assertRange,\n  Cache,\n  canBeConvertedToUint8Array,\n  encodeToBase64,\n  isStandardFont,\n  pluckIndices,\n  range,\n  toUint8Array,\n} from 'src/utils';\nimport FileEmbedder, { AFRelationship } from 'src/core/embedders/FileEmbedder';\nimport PDFEmbeddedFile from 'src/api/PDFEmbeddedFile';\nimport PDFJavaScript from 'src/api/PDFJavaScript';\nimport JavaScriptEmbedder from 'src/core/embedders/JavaScriptEmbedder';\n\n/**\n * Represents a PDF document.\n */\nexport default class PDFDocument {\n  /**\n   * Load an existing [[PDFDocument]]. The input data can be provided in\n   * multiple formats:\n   *\n   * | Type          | Contents                                               |\n   * | ------------- | ------------------------------------------------------ |\n   * | `string`      | A base64 encoded string (or data URI) containing a PDF |\n   * | `Uint8Array`  | The raw bytes of a PDF                                 |\n   * | `ArrayBuffer` | The raw bytes of a PDF                                 |\n   *\n   * For example:\n   * ```js\n   * import { PDFDocument } from 'pdf-lib'\n   *\n   * // pdf=string\n   * const base64 =\n   *  'JVBERi0xLjcKJYGBgYEKCjUgMCBvYmoKPDwKL0ZpbHRlciAvRmxhdGVEZWNvZGUKL0xlbm' +\n   *  'd0aCAxMDQKPj4Kc3RyZWFtCniccwrhMlAAwaJ0Ln2P1Jyy1JLM5ERdc0MjCwUjE4WQNC4Q' +\n   *  '6cNlCFZkqGCqYGSqEJLLZWNuYGZiZmbkYuZsZmlmZGRgZmluDCQNzc3NTM2NzdzMXMxMjQ' +\n   *  'ztFEKyuEK0uFxDuAAOERdVCmVuZHN0cmVhbQplbmRvYmoKCjYgMCBvYmoKPDwKL0ZpbHRl' +\n   *  'ciAvRmxhdGVEZWNvZGUKL1R5cGUgL09ialN0bQovTiA0Ci9GaXJzdCAyMAovTGVuZ3RoID' +\n   *  'IxNQo+PgpzdHJlYW0KeJxVj9GqwjAMhu/zFHkBzTo3nCCCiiKIHPEICuJF3cKoSCu2E8/b' +\n   *  '20wPIr1p8v9/8kVhgilmGfawX2CGaVrgcAi0/bsy0lrX7IGWpvJ4iJYEN3gEmrrGBlQwGs' +\n   *  'HHO9VBX1wNrxAqMX87RBD5xpJuddqwd82tjAHxzV1U5LPgy52DKXWnr1Lheg+j/c/pzGVr' +\n   *  'iqV0VlwZPXGPCJjElw/ybkwUmeoWgxesDXGhHJC/D/iikp1Av80ptKU0FdBEe25pPihAM1' +\n   *  'u6ytgaaWfs2Hrz35CJT1+EWmAKZW5kc3RyZWFtCmVuZG9iagoKNyAwIG9iago8PAovU2l6' +\n   *  'ZSA4Ci9Sb290IDIgMCBSCi9GaWx0ZXIgL0ZsYXRlRGVjb2RlCi9UeXBlIC9YUmVmCi9MZW' +\n   *  '5ndGggMzgKL1cgWyAxIDIgMiBdCi9JbmRleCBbIDAgOCBdCj4+CnN0cmVhbQp4nBXEwREA' +\n   *  'EBAEsCwz3vrvRmOOyyOoGhZdutHN2MT55fIAVocD+AplbmRzdHJlYW0KZW5kb2JqCgpzdG' +\n   *  'FydHhyZWYKNTEwCiUlRU9G'\n   *\n   * const dataUri = 'data:application/pdf;base64,' + base64\n   *\n   * const pdfDoc1 = await PDFDocument.load(base64)\n   * const pdfDoc2 = await PDFDocument.load(dataUri)\n   *\n   * // pdf=Uint8Array\n   * import fs from 'fs'\n   * const uint8Array = fs.readFileSync('with_update_sections.pdf')\n   * const pdfDoc3 = await PDFDocument.load(uint8Array)\n   *\n   * // pdf=ArrayBuffer\n   * const url = 'https://pdf-lib.js.org/assets/with_update_sections.pdf'\n   * const arrayBuffer = await fetch(url).then(res =\u003e res.arrayBuffer())\n   * const pdfDoc4 = await PDFDocument.load(arrayBuffer)\n   *\n   * ```\n   *\n   * @param pdf The input data containing a PDF document.\n   * @param options The options to be used when loading the document.\n   * @returns Resolves with a document loaded from the input.\n   */\n  static async load(\n    pdf: string | Uint8Array | ArrayBuffer,\n    options: LoadOptions = {},\n  ) {\n    const {\n      ignoreEncryption = false,\n      parseSpeed = ParseSpeeds.Slow,\n      throwOnInvalidObject = false,\n      updateMetadata = true,\n      capNumbers = false,\n    } = options;\n\n    assertIs(pdf, 'pdf', ['string', Uint8Array, ArrayBuffer]);\n    assertIs(ignoreEncryption, 'ignoreEncryption', ['boolean']);\n    assertIs(parseSpeed, 'parseSpeed', ['number']);\n    assertIs(throwOnInvalidObject, 'throwOnInvalidObject', ['boolean']);\n\n    const bytes = toUint8Array(pdf);\n    const context = await PDFParser.forBytesWithOptions(\n      bytes,\n      parseSpeed,\n      throwOnInvalidObject,\n      capNumbers,\n    ).parseDocument();\n    return new PDFDocument(context, ignoreEncryption, updateMetadata);\n  }\n\n  /**\n   * Create a new [[PDFDocument]].\n   * @returns Resolves with the newly created document.\n   */\n  static async create(options: CreateOptions = {}) {\n    const { updateMetadata = true } = options;\n\n    const context = PDFContext.create();\n    const pageTree = PDFPageTree.withContext(context);\n    const pageTreeRef = context.register(pageTree);\n    const catalog = PDFCatalog.withContextAndPages(context, pageTreeRef);\n    context.trailerInfo.Root = context.register(catalog);\n\n    return new PDFDocument(context, false, updateMetadata);\n  }\n\n  /** The low-level context of this document. */\n  readonly context: PDFContext;\n\n  /** The catalog of this document. */\n  readonly catalog: PDFCatalog;\n\n  /** Whether or not this document is encrypted. */\n  readonly isEncrypted: boolean;\n\n  /** The default word breaks used in PDFPage.drawText */\n  defaultWordBreaks: string[] = [' '];\n\n  private fontkit?: Fontkit;\n  private pageCount: number | undefined;\n  private readonly pageCache: Cache\u003cPDFPage[]\u003e;\n  private readonly pageMap: Map\u003cPDFPageLeaf, PDFPage\u003e;\n  private readonly formCache: Cache\u003cPDFForm\u003e;\n  private readonly fonts: PDFFont[];\n  private readonly images: PDFImage[];\n  private readonly embeddedPages: PDFEmbeddedPage[];\n  private readonly embeddedFiles: PDFEmbeddedFile[];\n  private readonly javaScripts: PDFJavaScript[];\n\n  private constructor(\n    context: PDFContext,\n    ignoreEncryption: boolean,\n    updateMetadata: boolean,\n  ) {\n    assertIs(context, 'context', [[PDFContext, 'PDFContext']]);\n    assertIs(ignoreEncryption, 'ignoreEncryption', ['boolean']);\n\n    this.context = context;\n    this.catalog = context.lookup(context.trailerInfo.Root) as PDFCatalog;\n    this.isEncrypted = !!context.lookup(context.trailerInfo.Encrypt);\n\n    this.pageCache = Cache.populatedBy(this.computePages);\n    this.pageMap = new Map();\n    this.formCache = Cache.populatedBy(this.getOrCreateForm);\n    this.fonts = [];\n    this.images = [];\n    this.embeddedPages = [];\n    this.embeddedFiles = [];\n    this.javaScripts = [];\n\n    if (!ignoreEncryption \u0026\u0026 this.isEncrypted) throw new EncryptedPDFError();\n\n    if (updateMetadata) this.updateInfoDict();\n  }\n\n  /**\n   * Register a fontkit instance. This must be done before custom fonts can\n   * be embedded. See [here](https://github.com/Hopding/pdf-lib/tree/master#fontkit-installation)\n   * for instructions on how to install and register a fontkit instance.\n   *\n   * \u003e You do **not** need to call this method to embed standard fonts.\n   *\n   * For example:\n   * ```js\n   * import { PDFDocument } from 'pdf-lib'\n   * import fontkit from '@pdf-lib/fontkit'\n   *\n   * const pdfDoc = await PDFDocument.create()\n   * pdfDoc.registerFontkit(fontkit)\n   * ```\n   *\n   * @param fontkit The fontkit instance to be registered.\n   */\n  registerFontkit(fontkit: Fontkit): void {\n    this.fontkit = fontkit;\n  }\n\n  /**\n   * Get the [[PDFForm]] containing all interactive fields for this document.\n   * For example:\n   * ```js\n   * const form = pdfDoc.getForm()\n   * const fields = form.getFields()\n   * fields.forEach(field =\u003e {\n   *   const type = field.constructor.name\n   *   const name = field.getName()\n   *   console.log(`${type}: ${name}`)\n   * })\n   * ```\n   * @returns The form for this document.\n   */\n  getForm(): PDFForm {\n    const form = this.formCache.access();\n    if (form.hasXFA()) {\n      console.warn(\n        'Removing XFA form data as pdf-lib does not support reading or writing XFA',\n      );\n      form.deleteXFA();\n    }\n    return form;\n  }\n\n  /**\n   * Get this document's title metadata. The title appears in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * const title = pdfDoc.getTitle()\n   * ```\n   * @returns A string containing the title of this document, if it has one.\n   */\n  getTitle(): string | undefined {\n    const title = this.getInfoDict().lookup(PDFName.Title);\n    if (!title) return undefined;\n    assertIsLiteralOrHexString(title);\n    return title.decodeText();\n  }\n\n  /**\n   * Get this document's author metadata. The author appears in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * const author = pdfDoc.getAuthor()\n   * ```\n   * @returns A string containing the author of this document, if it has one.\n   */\n  getAuthor(): string | undefined {\n    const author = this.getInfoDict().lookup(PDFName.Author);\n    if (!author) return undefined;\n    assertIsLiteralOrHexString(author);\n    return author.decodeText();\n  }\n\n  /**\n   * Get this document's subject metadata. The subject appears in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * const subject = pdfDoc.getSubject()\n   * ```\n   * @returns A string containing the subject of this document, if it has one.\n   */\n  getSubject(): string | undefined {\n    const subject = this.getInfoDict().lookup(PDFName.Subject);\n    if (!subject) return undefined;\n    assertIsLiteralOrHexString(subject);\n    return subject.decodeText();\n  }\n\n  /**\n   * Get this document's keywords metadata. The keywords appear in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * const keywords = pdfDoc.getKeywords()\n   * ```\n   * @returns A string containing the keywords of this document, if it has any.\n   */\n  getKeywords(): string | undefined {\n    const keywords = this.getInfoDict().lookup(PDFName.Keywords);\n    if (!keywords) return undefined;\n    assertIsLiteralOrHexString(keywords);\n    return keywords.decodeText();\n  }\n\n  /**\n   * Get this document's creator metadata. The creator appears in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * const creator = pdfDoc.getCreator()\n   * ```\n   * @returns A string containing the creator of this document, if it has one.\n   */\n  getCreator(): string | undefined {\n    const creator = this.getInfoDict().lookup(PDFName.Creator);\n    if (!creator) return undefined;\n    assertIsLiteralOrHexString(creator);\n    return creator.decodeText();\n  }\n\n  /**\n   * Get this document's producer metadata. The producer appears in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * const producer = pdfDoc.getProducer()\n   * ```\n   * @returns A string containing the producer of this document, if it has one.\n   */\n  getProducer(): string | undefined {\n    const producer = this.getInfoDict().lookup(PDFName.Producer);\n    if (!producer) return undefined;\n    assertIsLiteralOrHexString(producer);\n    return producer.decodeText();\n  }\n\n  /**\n   * Get this document's creation date metadata. The creation date appears in\n   * the \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * const creationDate = pdfDoc.getCreationDate()\n   * ```\n   * @returns A Date containing the creation date of this document,\n   *          if it has one.\n   */\n  getCreationDate(): Date | undefined {\n    const creationDate = this.getInfoDict().lookup(PDFName.CreationDate);\n    if (!creationDate) return undefined;\n    assertIsLiteralOrHexString(creationDate);\n    return creationDate.decodeDate();\n  }\n\n  /**\n   * Get this document's modification date metadata. The modification date\n   * appears in the \"Document Properties\" section of most PDF readers.\n   * For example:\n   * ```js\n   * const modification = pdfDoc.getModificationDate()\n   * ```\n   * @returns A Date containing the modification date of this document,\n   *          if it has one.\n   */\n  getModificationDate(): Date | undefined {\n    const modificationDate = this.getInfoDict().lookup(PDFName.ModDate);\n    if (!modificationDate) return undefined;\n    assertIsLiteralOrHexString(modificationDate);\n    return modificationDate.decodeDate();\n  }\n\n  /**\n   * Set this document's title metadata. The title will appear in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * pdfDoc.setTitle('🥚 The Life of an Egg 🍳')\n   * ```\n   *\n   * To display the title in the window's title bar, set the\n   * `showInWindowTitleBar` option to `true` (works for _most_ PDF readers).\n   * For example:\n   * ```js\n   * pdfDoc.setTitle('🥚 The Life of an Egg 🍳', { showInWindowTitleBar: true })\n   * ```\n   *\n   * @param title The title of this document.\n   * @param options The options to be used when setting the title.\n   */\n  setTitle(title: string, options?: SetTitleOptions): void {\n    assertIs(title, 'title', ['string']);\n    const key = PDFName.of('Title');\n    this.getInfoDict().set(key, PDFHexString.fromText(title));\n\n    // Indicate that readers should display the title rather than the filename\n    if (options?.showInWindowTitleBar) {\n      const prefs = this.catalog.getOrCreateViewerPreferences();\n      prefs.setDisplayDocTitle(true);\n    }\n  }\n\n  /**\n   * Set this document's author metadata. The author will appear in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * pdfDoc.setAuthor('Humpty Dumpty')\n   * ```\n   * @param author The author of this document.\n   */\n  setAuthor(author: string): void {\n    assertIs(author, 'author', ['string']);\n    const key = PDFName.of('Author');\n    this.getInfoDict().set(key, PDFHexString.fromText(author));\n  }\n\n  /**\n   * Set this document's subject metadata. The subject will appear in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * pdfDoc.setSubject('📘 An Epic Tale of Woe 📖')\n   * ```\n   * @param subject The subject of this document.\n   */\n  setSubject(subject: string): void {\n    assertIs(subject, 'author', ['string']);\n    const key = PDFName.of('Subject');\n    this.getInfoDict().set(key, PDFHexString.fromText(subject));\n  }\n\n  /**\n   * Set this document's keyword metadata. These keywords will appear in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * pdfDoc.setKeywords(['eggs', 'wall', 'fall', 'king', 'horses', 'men'])\n   * ```\n   * @param keywords An array of keywords associated with this document.\n   */\n  setKeywords(keywords: string[]): void {\n    assertIs(keywords, 'keywords', [Array]);\n    const key = PDFName.of('Keywords');\n    this.getInfoDict().set(key, PDFHexString.fromText(keywords.join(' ')));\n  }\n\n  /**\n   * Set this document's creator metadata. The creator will appear in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * pdfDoc.setCreator('PDF App 9000 🤖')\n   * ```\n   * @param creator The creator of this document.\n   */\n  setCreator(creator: string): void {\n    assertIs(creator, 'creator', ['string']);\n    const key = PDFName.of('Creator');\n    this.getInfoDict().set(key, PDFHexString.fromText(creator));\n  }\n\n  /**\n   * Set this document's producer metadata. The producer will appear in the\n   * \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * pdfDoc.setProducer('PDF App 9000 🤖')\n   * ```\n   * @param producer The producer of this document.\n   */\n  setProducer(producer: string): void {\n    assertIs(producer, 'creator', ['string']);\n    const key = PDFName.of('Producer');\n    this.getInfoDict().set(key, PDFHexString.fromText(producer));\n  }\n\n  /**\n   * Set this document's language metadata. The language will appear in the\n   * \"Document Properties\" section of some PDF readers. For example:\n   * ```js\n   * pdfDoc.setLanguage('en-us')\n   * ```\n   *\n   * @param language An RFC 3066 _Language-Tag_ denoting the language of this\n   *                 document, or an empty string if the language is unknown.\n   */\n  setLanguage(language: string): void {\n    assertIs(language, 'language', ['string']);\n    const key = PDFName.of('Lang');\n    this.catalog.set(key, PDFString.of(language));\n  }\n\n  /**\n   * Set this document's creation date metadata. The creation date will appear\n   * in the \"Document Properties\" section of most PDF readers. For example:\n   * ```js\n   * pdfDoc.setCreationDate(new Date())\n   * ```\n   * @param creationDate The date this document was created.\n   */\n  setCreationDate(creationDate: Date): void {\n    assertIs(creationDate, 'creationDate', [[Date, 'Date']]);\n    const key = PDFName.of('CreationDate');\n    this.getInfoDict().set(key, PDFString.fromDate(creationDate));\n  }\n\n  /**\n   * Set this document's modification date metadata. The modification date will\n   * appear in the \"Document Properties\" section of most PDF readers. For\n   * example:\n   * ```js\n   * pdfDoc.setModificationDate(new Date())\n   * ```\n   * @param modificationDate The date this document was last modified.\n   */\n  setModificationDate(modificationDate: Date): void {\n    assertIs(modificationDate, 'modificationDate', [[Date, 'Date']]);\n    const key = PDFName.of('ModDate');\n    this.getInfoDict().set(key, PDFString.fromDate(modificationDate));\n  }\n\n  /**\n   * Get the number of pages contained in this document. For example:\n   * ```js\n   * const totalPages = pdfDoc.getPageCount()\n   * ```\n   * @returns The number of pages in this document.\n   */\n  getPageCount(): number {\n    if (this.pageCount === undefined) this.pageCount = this.getPages().length;\n    return this.pageCount;\n  }\n\n  /**\n   * Get an array of all the pages contained in this document. The pages are\n   * stored in the array in the same order that they are rendered in the\n   * document. For example:\n   * ```js\n   * const pages = pdfDoc.getPages()\n   * pages[0]   // The first page of the document\n   * pages[2]   // The third page of the document\n   * pages[197] // The 198th page of the document\n   * ```\n   * @returns An array of all the pages contained in this document.\n   */\n  getPages(): PDFPage[] {\n    return this.pageCache.access();\n  }\n\n  /**\n   * Get the page rendered at a particular `index` of the document. For example:\n   * ```js\n   * pdfDoc.getPage(0)   // The first page of the document\n   * pdfDoc.getPage(2)   // The third page of the document\n   * pdfDoc.getPage(197) // The 198th page of the document\n   * ```\n   * @returns The [[PDFPage]] rendered at the given `index` of the document.\n   */\n  getPage(index: number): PDFPage {\n    const pages = this.getPages();\n    assertRange(index, 'index', 0, pages.length - 1);\n    return pages[index];\n  }\n\n  /**\n   * Get an array of indices for all the pages contained in this document. The\n   * array will contain a range of integers from\n   * `0..pdfDoc.getPageCount() - 1`. For example:\n   * ```js\n   * const pdfDoc = await PDFDocument.create()\n   * pdfDoc.addPage()\n   * pdfDoc.addPage()\n   * pdfDoc.addPage()\n   *\n   * const indices = pdfDoc.getPageIndices()\n   * indices // =\u003e [0, 1, 2]\n   * ```\n   * @returns An array of indices for all pages contained in this document.\n   */\n  getPageIndices(): number[] {\n    return range(0, this.getPageCount());\n  }\n\n  /**\n   * Remove the page at a given index from this document. For example:\n   * ```js\n   * pdfDoc.removePage(0)   // Remove the first page of the document\n   * pdfDoc.removePage(2)   // Remove the third page of the document\n   * pdfDoc.removePage(197) // Remove the 198th page of the document\n   * ```\n   * Once a page has been removed, it will no longer be rendered at that index\n   * in the document.\n   * @param index The index of the page to be removed.\n   */\n  removePage(index: number): void {\n    const pageCount = this.getPageCount();\n    if (this.pageCount === 0) throw new RemovePageFromEmptyDocumentError();\n    assertRange(index, 'index', 0, pageCount - 1);\n    this.catalog.removeLeafNode(index);\n    this.pageCount = pageCount - 1;\n  }\n\n  /**\n   * Add a page to the end of this document. This method accepts three\n   * different value types for the `page` parameter:\n   *\n   * | Type               | Behavior                                                                            |\n   * | ------------------ | ----------------------------------------------------------------------------------- |\n   * | `undefined`        | Create a new page and add it to the end of this document                            |\n   * | `[number, number]` | Create a new page with the given dimensions and add it to the end of this document  |\n   * | `PDFPage`          | Add the existing page to the end of this document                                   |\n   *\n   * For example:\n   * ```js\n   * // page=undefined\n   * const newPage = pdfDoc.addPage()\n   *\n   * // page=[number, number]\n   * import { PageSizes } from 'pdf-lib'\n   * const newPage1 = pdfDoc.addPage(PageSizes.A7)\n   * const newPage2 = pdfDoc.addPage(PageSizes.Letter)\n   * const newPage3 = pdfDoc.addPage([500, 750])\n   *\n   * // page=PDFPage\n   * const pdfDoc1 = await PDFDocument.create()\n   * const pdfDoc2 = await PDFDocument.load(...)\n   * const [existingPage] = await pdfDoc1.copyPages(pdfDoc2, [0])\n   * pdfDoc1.addPage(existingPage)\n   * ```\n   *\n   * @param page Optionally, the desired dimensions or existing page.\n   * @returns The newly created (or existing) page.\n   */\n  addPage(page?: PDFPage | [number, number]): PDFPage {\n    assertIs(page, 'page', ['undefined', [PDFPage, 'PDFPage'], Array]);\n    return this.insertPage(this.getPageCount(), page);\n  }\n\n  /**\n   * Insert a page at a given index within this document. This method accepts\n   * three different value types for the `page` parameter:\n   *\n   * | Type               | Behavior                                                                       |\n   * | ------------------ | ------------------------------------------------------------------------------ |\n   * | `undefined`        | Create a new page and insert it into this document                             |\n   * | `[number, number]` | Create a new page with the given dimensions and insert it into this document   |\n   * | `PDFPage`          | Insert the existing page into this document                                    |\n   *\n   * For example:\n   * ```js\n   * // page=undefined\n   * const newPage = pdfDoc.insertPage(2)\n   *\n   * // page=[number, number]\n   * import { PageSizes } from 'pdf-lib'\n   * const newPage1 = pdfDoc.insertPage(2, PageSizes.A7)\n   * const newPage2 = pdfDoc.insertPage(0, PageSizes.Letter)\n   * const newPage3 = pdfDoc.insertPage(198, [500, 750])\n   *\n   * // page=PDFPage\n   * const pdfDoc1 = await PDFDocument.create()\n   * const pdfDoc2 = await PDFDocument.load(...)\n   * const [existingPage] = await pdfDoc1.copyPages(pdfDoc2, [0])\n   * pdfDoc1.insertPage(0, existingPage)\n   * ```\n   *\n   * @param index The index at which the page should be inserted (zero-based).\n   * @param page Optionally, the desired dimensions or existing page.\n   * @returns The newly created (or existing) page.\n   */\n  insertPage(index: number, page?: PDFPage | [number, number]): PDFPage {\n    const pageCount = this.getPageCount();\n    assertRange(index, 'index', 0, pageCount);\n    assertIs(page, 'page', ['undefined', [PDFPage, 'PDFPage'], Array]);\n    if (!page || Array.isArray(page)) {\n      const dims = Array.isArray(page) ? page : PageSizes.A4;\n      page = PDFPage.create(this);\n      page.setSize(...dims);\n    } else if (page.doc !== this) {\n      throw new ForeignPageError();\n    }\n\n    const parentRef = this.catalog.insertLeafNode(page.ref, index);\n    page.node.setParent(parentRef);\n\n    this.pageMap.set(page.node, page);\n    this.pageCache.invalidate();\n\n    this.pageCount = pageCount + 1;\n\n    return page;\n  }\n\n  /**\n   * Copy pages from a source document into this document. Allows pages to be\n   * copied between different [[PDFDocument]] instances. For example:\n   * ```js\n   * const pdfDoc = await PDFDocument.create()\n   * const srcDoc = await PDFDocument.load(...)\n   *\n   * const copiedPages = await pdfDoc.copyPages(srcDoc, [0, 3, 89])\n   * const [firstPage, fourthPage, ninetiethPage] = copiedPages;\n   *\n   * pdfDoc.addPage(fourthPage)\n   * pdfDoc.insertPage(0, ninetiethPage)\n   * pdfDoc.addPage(firstPage)\n   * ```\n   * @param srcDoc The document from which pages should be copied.\n   * @param indices The indices of the pages that should be copied.\n   * @returns Resolves with an array of pages copied into this document.\n   */\n  async copyPages(srcDoc: PDFDocument, indices: number[]): Promise\u003cPDFPage[]\u003e {\n    assertIs(srcDoc, 'srcDoc', [[PDFDocument, 'PDFDocument']]);\n    assertIs(indices, 'indices', [Array]);\n    await srcDoc.flush();\n    const copier = PDFObjectCopier.for(srcDoc.context, this.context);\n    const srcPages = srcDoc.getPages();\n    const copiedPages: PDFPage[] = new Array(indices.length);\n    for (let idx = 0, len = indices.length; idx \u003c len; idx++) {\n      const srcPage = srcPages[indices[idx]];\n      const copiedPage = copier.copy(srcPage.node);\n      const ref = this.context.register(copiedPage);\n      copiedPages[idx] = PDFPage.of(copiedPage, ref, this);\n    }\n    return copiedPages;\n  }\n\n  /**\n   * Get a copy of this document.\n   *\n   * For example:\n   * ```js\n   * const srcDoc = await PDFDocument.load(...)\n   * const pdfDoc = await srcDoc.copy()\n   * ```\n   *\n   * \u003e **NOTE:**  This method won't copy all information over to the new\n   * \u003e document (acroforms, outlines, etc...).\n   *\n   * @returns Resolves with a copy this document.\n   */\n  async copy(): Promise\u003cPDFDocument\u003e {\n    const pdfCopy = await PDFDocument.create();\n    const contentPages = await pdfCopy.copyPages(this, this.getPageIndices());\n\n    for (let idx = 0, len = contentPages.length; idx \u003c len; idx++) {\n      pdfCopy.addPage(contentPages[idx]);\n    }\n\n    if (this.getAuthor() !== undefined) {\n      pdfCopy.setAuthor(this.getAuthor()!);\n    }\n    if (this.getCreationDate() !== undefined) {\n      pdfCopy.setCreationDate(this.getCreationDate()!);\n    }\n    if (this.getCreator() !== undefined) {\n      pdfCopy.setCreator(this.getCreator()!);\n    }\n    if (this.getModificationDate() !== undefined) {\n      pdfCopy.setModificationDate(this.getModificationDate()!);\n    }\n    if (this.getProducer() !== undefined) {\n      pdfCopy.setProducer(this.getProducer()!);\n    }\n    if (this.getSubject() !== undefined) {\n      pdfCopy.setSubject(this.getSubject()!);\n    }\n    if (this.getTitle() !== undefined) {\n      pdfCopy.setTitle(this.getTitle()!);\n    }\n    pdfCopy.defaultWordBreaks = this.defaultWordBreaks;\n\n    return pdfCopy;\n  }\n\n  /**\n   * Add JavaScript to this document. The supplied `script` is executed when the\n   * document is opened. The `script` can be used to perform some operation\n   * when the document is opened (e.g. logging to the console), or it can be\n   * used to define a function that can be referenced later in a JavaScript\n   * action. For example:\n   * ```js\n   * // Show \"Hello World!\" in the console when the PDF is opened\n   * pdfDoc.addJavaScript(\n   *   'main',\n   *   'console.show(); console.println(\"Hello World!\");'\n   * );\n   *\n   * // Define a function named \"foo\" that can be called in JavaScript Actions\n   * pdfDoc.addJavaScript(\n   *   'foo',\n   *   'function foo() { return \"foo\"; }'\n   * );\n   * ```\n   * See the [JavaScript for Acrobat API Reference](https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf)\n   * for details.\n   * @param name The name of the script. Must be unique per document.\n   * @param script The JavaScript to execute.\n   */\n  addJavaScript(name: string, script: string) {\n    assertIs(name, 'name', ['string']);\n    assertIs(script, 'script', ['string']);\n\n    const embedder = JavaScriptEmbedder.for(script, name);\n\n    const ref = this.context.nextRef();\n    const javaScript = PDFJavaScript.of(ref, this, embedder);\n    this.javaScripts.push(javaScript);\n  }\n\n  /**\n   * Add an attachment to this document. Attachments are visible in the\n   * \"Attachments\" panel of Adobe Acrobat and some other PDF readers. Any\n   * type of file can be added as an attachment. This includes, but is not\n   * limited to, `.png`, `.jpg`, `.pdf`, `.csv`, `.docx`, and `.xlsx` files.\n   *\n   * The input data can be provided in multiple formats:\n   *\n   * | Type          | Contents                                                       |\n   * | ------------- | -------------------------------------------------------------- |\n   * | `string`      | A base64 encoded string (or data URI) containing an attachment |\n   * | `Uint8Array`  | The raw bytes of an attachment                                 |\n   * | `ArrayBuffer` | The raw bytes of an attachment                                 |\n   *\n   * For example:\n   * ```js\n   * // attachment=string\n   * await pdfDoc.attach('/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD...', 'cat_riding_unicorn.jpg', {\n   *   mimeType: 'image/jpeg',\n   *   description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n   *   creationDate: new Date('2019/12/01'),\n   *   modificationDate: new Date('2020/04/19'),\n   * })\n   * await pdfDoc.attach('data:image/jpeg;base64,/9j/4AAQ...', 'cat_riding_unicorn.jpg', {\n   *   mimeType: 'image/jpeg',\n   *   description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n   *   creationDate: new Date('2019/12/01'),\n   *   modificationDate: new Date('2020/04/19'),\n   * })\n   *\n   * // attachment=Uint8Array\n   * import fs from 'fs'\n   * const uint8Array = fs.readFileSync('cat_riding_unicorn.jpg')\n   * await pdfDoc.attach(uint8Array, 'cat_riding_unicorn.jpg', {\n   *   mimeType: 'image/jpeg',\n   *   description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n   *   creationDate: new Date('2019/12/01'),\n   *   modificationDate: new Date('2020/04/19'),\n   * })\n   *\n   * // attachment=ArrayBuffer\n   * const url = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg'\n   * const arrayBuffer = await fetch(url).then(res =\u003e res.arrayBuffer())\n   * await pdfDoc.attach(arrayBuffer, 'cat_riding_unicorn.jpg', {\n   *   mimeType: 'image/jpeg',\n   *   description: 'Cool cat riding a unicorn! 🦄🐈🕶️',\n   *   creationDate: new Date('2019/12/01'),\n   *   modificationDate: new Date('2020/04/19'),\n   * })\n   * ```\n   *\n   * @param attachment The input data containing the file to be attached.\n   * @param name The name of the file to be attached.\n   * @returns Resolves when the attachment is complete.\n   */\n  async attach(\n    attachment: string | Uint8Array | ArrayBuffer,\n    name: string,\n    options: AttachmentOptions = {},\n  ): Promise\u003cvoid\u003e {\n    assertIs(attachment, 'attachment', ['string', Uint8Array, ArrayBuffer]);\n    assertIs(name, 'name', ['string']);\n    assertOrUndefined(options.mimeType, 'mimeType', ['string']);\n    assertOrUndefined(options.description, 'description', ['string']);\n    assertOrUndefined(options.creationDate, 'options.creationDate', [Date]);\n    assertOrUndefined(options.modificationDate, 'options.modificationDate', [\n      Date,\n    ]);\n    assertIsOneOfOrUndefined(\n      options.afRelationship,\n      'options.afRelationship',\n      AFRelationship,\n    );\n\n    const bytes = toUint8Array(attachment);\n    const embedder = FileEmbedder.for(bytes, name, options);\n\n    const ref = this.context.nextRef();\n    const embeddedFile = PDFEmbeddedFile.of(ref, this, embedder);\n    this.embeddedFiles.push(embeddedFile);\n  }\n\n  /**\n   * Embed a font into this document. The input data can be provided in multiple\n   * formats:\n   *\n   * | Type            | Contents                                                |\n   * | --------------- | ------------------------------------------------------- |\n   * | `StandardFonts` | One of the standard 14 fonts                            |\n   * | `string`        | A base64 encoded string (or data URI) containing a font |\n   * | `Uint8Array`    | The raw bytes of a font                                 |\n   * | `ArrayBuffer`   | The raw bytes of a font                                 |\n   *\n   * For example:\n   * ```js\n   * // font=StandardFonts\n   * import { StandardFonts } from 'pdf-lib'\n   * const font1 = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   *\n   * // font=string\n   * const font2 = await pdfDoc.embedFont('AAEAAAAVAQAABABQRFNJRx/upe...')\n   * const font3 = await pdfDoc.embedFont('data:font/opentype;base64,AAEAAA...')\n   *\n   * // font=Uint8Array\n   * import fs from 'fs'\n   * const font4 = await pdfDoc.embedFont(fs.readFileSync('Ubuntu-R.ttf'))\n   *\n   * // font=ArrayBuffer\n   * const url = 'https://pdf-lib.js.org/assets/ubuntu/Ubuntu-R.ttf'\n   * const ubuntuBytes = await fetch(url).then(res =\u003e res.arrayBuffer())\n   * const font5 = await pdfDoc.embedFont(ubuntuBytes)\n   * ```\n   * See also: [[registerFontkit]]\n   * @param font The input data for a font.\n   * @param options The options to be used when embedding the font.\n   * @returns Resolves with the embedded font.\n   */\n  async embedFont(\n    font: StandardFonts | string | Uint8Array | ArrayBuffer,\n    options: EmbedFontOptions = {},\n  ): Promise\u003cPDFFont\u003e {\n    const { subset = false, customName, features } = options;\n\n    assertIs(font, 'font', ['string', Uint8Array, ArrayBuffer]);\n    assertIs(subset, 'subset', ['boolean']);\n\n    let embedder: CustomFontEmbedder | StandardFontEmbedder;\n    if (isStandardFont(font)) {\n      embedder = StandardFontEmbedder.for(font, customName);\n    } else if (canBeConvertedToUint8Array(font)) {\n      const bytes = toUint8Array(font);\n      const fontkit = this.assertFontkit();\n      embedder = subset\n        ? await CustomFontSubsetEmbedder.for(\n            fontkit,\n            bytes,\n            customName,\n            features,\n          )\n        : await CustomFontEmbedder.for(fontkit, bytes, customName, features);\n    } else {\n      throw new TypeError(\n        '`font` must be one of `StandardFonts | string | Uint8Array | ArrayBuffer`',\n      );\n    }\n\n    const ref = this.context.nextRef();\n    const pdfFont = PDFFont.of(ref, this, embedder);\n    this.fonts.push(pdfFont);\n\n    return pdfFont;\n  }\n\n  /**\n   * Embed a standard font into this document.\n   * For example:\n   * ```js\n   * import { StandardFonts } from 'pdf-lib'\n   * const helveticaFont = pdfDoc.embedFont(StandardFonts.Helvetica)\n   * ```\n   * @param font The standard font to be embedded.\n   * @param customName The name to be used when embedding the font.\n   * @returns The embedded font.\n   */\n  embedStandardFont(font: StandardFonts, customName?: string): PDFFont {\n    assertIs(font, 'font', ['string']);\n    if (!isStandardFont(font)) {\n      throw new TypeError('`font` must be one of type `StandardFonts`');\n    }\n\n    const embedder = StandardFontEmbedder.for(font, customName);\n\n    const ref = this.context.nextRef();\n    const pdfFont = PDFFont.of(ref, this, embedder);\n    this.fonts.push(pdfFont);\n\n    return pdfFont;\n  }\n\n  /**\n   * Embed a JPEG image into this document. The input data can be provided in\n   * multiple formats:\n   *\n   * | Type          | Contents                                                      |\n   * | ------------- | ------------------------------------------------------------- |\n   * | `string`      | A base64 encoded string (or data URI) containing a JPEG image |\n   * | `Uint8Array`  | The raw bytes of a JPEG image                                 |\n   * | `ArrayBuffer` | The raw bytes of a JPEG image                                 |\n   *\n   * For example:\n   * ```js\n   * // jpg=string\n   * const image1 = await pdfDoc.embedJpg('/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD...')\n   * const image2 = await pdfDoc.embedJpg('data:image/jpeg;base64,/9j/4AAQ...')\n   *\n   * // jpg=Uint8Array\n   * import fs from 'fs'\n   * const uint8Array = fs.readFileSync('cat_riding_unicorn.jpg')\n   * const image3 = await pdfDoc.embedJpg(uint8Array)\n   *\n   * // jpg=ArrayBuffer\n   * const url = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg'\n   * const arrayBuffer = await fetch(url).then(res =\u003e res.arrayBuffer())\n   * const image4 = await pdfDoc.embedJpg(arrayBuffer)\n   * ```\n   *\n   * @param jpg The input data for a JPEG image.\n   * @returns Resolves with the embedded image.\n   */\n  async embedJpg(jpg: string | Uint8Array | ArrayBuffer): Promise\u003cPDFImage\u003e {\n    assertIs(jpg, 'jpg', ['string', Uint8Array, ArrayBuffer]);\n    const bytes = toUint8Array(jpg);\n    const embedder = await JpegEmbedder.for(bytes);\n    const ref = this.context.nextRef();\n    const pdfImage = PDFImage.of(ref, this, embedder);\n    this.images.push(pdfImage);\n    return pdfImage;\n  }\n\n  /**\n   * Embed a PNG image into this document. The input data can be provided in\n   * multiple formats:\n   *\n   * | Type          | Contents                                                     |\n   * | ------------- | ------------------------------------------------------------ |\n   * | `string`      | A base64 encoded string (or data URI) containing a PNG image |\n   * | `Uint8Array`  | The raw bytes of a PNG image                                 |\n   * | `ArrayBuffer` | The raw bytes of a PNG image                                 |\n   *\n   * For example:\n   * ```js\n   * // png=string\n   * const image1 = await pdfDoc.embedPng('iVBORw0KGgoAAAANSUhEUgAAAlgAAAF3...')\n   * const image2 = await pdfDoc.embedPng('data:image/png;base64,iVBORw0KGg...')\n   *\n   * // png=Uint8Array\n   * import fs from 'fs'\n   * const uint8Array = fs.readFileSync('small_mario.png')\n   * const image3 = await pdfDoc.embedPng(uint8Array)\n   *\n   * // png=ArrayBuffer\n   * const url = 'https://pdf-lib.js.org/assets/small_mario.png'\n   * const arrayBuffer = await fetch(url).then(res =\u003e res.arrayBuffer())\n   * const image4 = await pdfDoc.embedPng(arrayBuffer)\n   * ```\n   *\n   * @param png The input data for a PNG image.\n   * @returns Resolves with the embedded image.\n   */\n  async embedPng(png: string | Uint8Array | ArrayBuffer): Promise\u003cPDFImage\u003e {\n    assertIs(png, 'png', ['string', Uint8Array, ArrayBuffer]);\n    const bytes = toUint8Array(png);\n    const embedder = await PngEmbedder.for(bytes);\n    const ref = this.context.nextRef();\n    const pdfImage = PDFImage.of(ref, this, embedder);\n    this.images.push(pdfImage);\n    return pdfImage;\n  }\n\n  /**\n   * Embed one or more PDF pages into this document.\n   *\n   * For example:\n   * ```js\n   * const pdfDoc = await PDFDocument.create()\n   *\n   * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n   * const sourcePdf = await fetch(sourcePdfUrl).then((res) =\u003e res.arrayBuffer())\n   *\n   * // Embed page 74 of `sourcePdf` into `pdfDoc`\n   * const [embeddedPage] = await pdfDoc.embedPdf(sourcePdf, [73])\n   * ```\n   *\n   * See [[PDFDocument.load]] for examples of the allowed input data formats.\n   *\n   * @param pdf The input data containing a PDF document.\n   * @param indices The indices of the pages that should be embedded.\n   * @returns Resolves with an array of the embedded pages.\n   */\n  async embedPdf(\n    pdf: string | Uint8Array | ArrayBuffer | PDFDocument,\n    indices: number[] = [0],\n  ): Promise\u003cPDFEmbeddedPage[]\u003e {\n    assertIs(pdf, 'pdf', [\n      'string',\n      Uint8Array,\n      ArrayBuffer,\n      [PDFDocument, 'PDFDocument'],\n    ]);\n    assertIs(indices, 'indices', [Array]);\n\n    const srcDoc =\n      pdf instanceof PDFDocument ? pdf : await PDFDocument.load(pdf);\n\n    const srcPages = pluckIndices(srcDoc.getPages(), indices);\n\n    return this.embedPages(srcPages);\n  }\n\n  /**\n   * Embed a single PDF page into this document.\n   *\n   * For example:\n   * ```js\n   * const pdfDoc = await PDFDocument.create()\n   *\n   * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n   * const sourceBuffer = await fetch(sourcePdfUrl).then((res) =\u003e res.arrayBuffer())\n   * const sourcePdfDoc = await PDFDocument.load(sourceBuffer)\n   * const sourcePdfPage = sourcePdfDoc.getPages()[73]\n   *\n   * const embeddedPage = await pdfDoc.embedPage(\n   *   sourcePdfPage,\n   *\n   *   // Clip a section of the source page so that we only embed part of it\n   *   { left: 100, right: 450, bottom: 330, top: 570 },\n   *\n   *   // Translate all drawings of the embedded page by (10, 200) units\n   *   [1, 0, 0, 1, 10, 200],\n   * )\n   * ```\n   *\n   * @param page The page to be embedded.\n   * @param boundingBox\n   * Optionally, an area of the source page that should be embedded\n   * (defaults to entire page).\n   * @param transformationMatrix\n   * Optionally, a transformation matrix that is always applied to the embedded\n   * page anywhere it is drawn.\n   * @returns Resolves with the embedded pdf page.\n   */\n  async embedPage(\n    page: PDFPage,\n    boundingBox?: PageBoundingBox,\n    transformationMatrix?: TransformationMatrix,\n  ): Promise\u003cPDFEmbeddedPage\u003e {\n    assertIs(page, 'page', [[PDFPage, 'PDFPage']]);\n    const [embeddedPage] = await this.embedPages(\n      [page],\n      [boundingBox],\n      [transformationMatrix],\n    );\n    return embeddedPage;\n  }\n\n  /**\n   * Embed one or more PDF pages into this document.\n   *\n   * For example:\n   * ```js\n   * const pdfDoc = await PDFDocument.create()\n   *\n   * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n   * const sourceBuffer = await fetch(sourcePdfUrl).then((res) =\u003e res.arrayBuffer())\n   * const sourcePdfDoc = await PDFDocument.load(sourceBuffer)\n   *\n   * const page1 = sourcePdfDoc.getPages()[0]\n   * const page2 = sourcePdfDoc.getPages()[52]\n   * const page3 = sourcePdfDoc.getPages()[73]\n   *\n   * const embeddedPages = await pdfDoc.embedPages([page1, page2, page3])\n   * ```\n   *\n   * @param page\n   * The pages to be embedded (they must all share the same context).\n   * @param boundingBoxes\n   * Optionally, an array of clipping boundaries - one for each page\n   * (defaults to entirety of each page).\n   * @param transformationMatrices\n   * Optionally, an array of transformation matrices - one for each page\n   * (each page's transformation will apply anywhere it is drawn).\n   * @returns Resolves with an array of the embedded pdf pages.\n   */\n  async embedPages(\n    pages: PDFPage[],\n    boundingBoxes: (PageBoundingBox | undefined)[] = [],\n    transformationMatrices: (TransformationMatrix | undefined)[] = [],\n  ) {\n    if (pages.length === 0) return [];\n\n    // Assert all pages have the same context\n    for (let idx = 0, len = pages.length - 1; idx \u003c len; idx++) {\n      const currPage = pages[idx];\n      const nextPage = pages[idx + 1];\n      if (currPage.node.context !== nextPage.node.context) {\n        throw new PageEmbeddingMismatchedContextError();\n      }\n    }\n\n    const context = pages[0].node.context;\n    const maybeCopyPage =\n      context === this.context\n        ? (p: PDFPageLeaf) =\u003e p\n        : PDFObjectCopier.for(context, this.context).copy;\n\n    const embeddedPages = new Array\u003cPDFEmbeddedPage\u003e(pages.length);\n    for (let idx = 0, len = pages.length; idx \u003c len; idx++) {\n      const page = maybeCopyPage(pages[idx].node);\n      const box = boundingBoxes[idx];\n      const matrix = transformationMatrices[idx];\n\n      const embedder = await PDFPageEmbedder.for(page, box, matrix);\n\n      const ref = this.context.nextRef();\n      embeddedPages[idx] = PDFEmbeddedPage.of(ref, this, embedder);\n    }\n\n    this.embeddedPages.push(...embeddedPages);\n\n    return embeddedPages;\n  }\n\n  /**\n   * \u003e **NOTE:** You shouldn't need to call this method directly. The [[save]]\n   * \u003e and [[saveAsBase64]] methods will automatically ensure that all embedded\n   * \u003e assets are flushed before serializing the document.\n   *\n   * Flush all embedded fonts, PDF pages, and images to this document's\n   * [[context]].\n   *\n   * @returns Resolves when the flush is complete.\n   */\n  async flush(): Promise\u003cvoid\u003e {\n    await this.embedAll(this.fonts);\n    await this.embedAll(this.images);\n    await this.embedAll(this.embeddedPages);\n    await this.embedAll(this.embeddedFiles);\n    await this.embedAll(this.javaScripts);\n  }\n\n  /**\n   * Serialize this document to an array of bytes making up a PDF file.\n   * For example:\n   * ```js\n   * const pdfBytes = await pdfDoc.save()\n   * ```\n   *\n   * There are a number of things you can do with the serialized document,\n   * depending on the JavaScript environment you're running in:\n   * * Write it to a file in Node or React Native\n   * * Download it as a Blob in the browser\n   * * Render it in an `iframe`\n   *\n   * @param options The options to be used when saving the document.\n   * @returns Resolves with the bytes of the serialized document.\n   */\n  async save(options: SaveOptions = {}): Promise\u003cUint8Array\u003e {\n    const {\n      useObjectStreams = true,\n      addDefaultPage = true,\n      objectsPerTick = 50,\n      updateFieldAppearances = true,\n    } = options;\n\n    assertIs(useObjectStreams, 'useObjectStreams', ['boolean']);\n    assertIs(addDefaultPage, 'addDefaultPage', ['boolean']);\n    assertIs(objectsPerTick, 'objectsPerTick', ['number']);\n    assertIs(updateFieldAppearances, 'updateFieldAppearances', ['boolean']);\n\n    if (addDefaultPage \u0026\u0026 this.getPageCount() === 0) this.addPage();\n\n    if (updateFieldAppearances) {\n      const form = this.formCache.getValue();\n      if (form) form.updateFieldAppearances();\n    }\n\n    await this.flush();\n\n    const Writer = useObjectStreams ? PDFStreamWriter : PDFWriter;\n    return Writer.forContext(this.context, objectsPerTick).serializeToBuffer();\n  }\n\n  /**\n   * Serialize this document to a base64 encoded string or data URI making up a\n   * PDF file. For example:\n   * ```js\n   * const base64String = await pdfDoc.saveAsBase64()\n   * base64String // =\u003e 'JVBERi0xLjcKJYGBgYEKC...'\n   *\n   * const base64DataUri = await pdfDoc.saveAsBase64({ dataUri: true })\n   * base64DataUri // =\u003e 'data:application/pdf;base64,JVBERi0xLjcKJYGBgYEKC...'\n   * ```\n   *\n   * @param options The options to be used when saving the document.\n   * @returns Resolves with a base64 encoded string or data URI of the\n   *          serialized document.\n   */\n  async saveAsBase64(options: Base64SaveOptions = {}): Promise\u003cstring\u003e {\n    const { dataUri = false, ...otherOptions } = options;\n    assertIs(dataUri, 'dataUri', ['boolean']);\n    const bytes = await this.save(otherOptions);\n    const base64 = encodeToBase64(bytes);\n    return dataUri ? `data:application/pdf;base64,${base64}` : base64;\n  }\n\n  findPageForAnnotationRef(ref: PDFRef): PDFPage | undefined {\n    const pages = this.getPages();\n    for (let idx = 0, len = pages.length; idx \u003c len; idx++) {\n      const page = pages[idx];\n      const annotations = page.node.Annots();\n\n      if (annotations?.indexOf(ref) !== undefined) {\n        return page;\n      }\n    }\n\n    return undefined;\n  }\n\n  private async embedAll(embeddables: Embeddable[]): Promise\u003cvoid\u003e {\n    for (let idx = 0, len = embeddables.length; idx \u003c len; idx++) {\n      await embeddables[idx].embed();\n    }\n  }\n\n  private updateInfoDict(): void {\n    const pdfLib = `pdf-lib (https://github.com/Hopding/pdf-lib)`;\n    const now = new Date();\n\n    const info = this.getInfoDict();\n\n    this.setProducer(pdfLib);\n    this.setModificationDate(now);\n\n    if (!info.get(PDFName.of('Creator'))) this.setCreator(pdfLib);\n    if (!info.get(PDFName.of('CreationDate'))) this.setCreationDate(now);\n  }\n\n  private getInfoDict(): PDFDict {\n    const existingInfo = this.context.lookup(this.context.trailerInfo.Info);\n    if (existingInfo instanceof PDFDict) return existingInfo;\n\n    const newInfo = this.context.obj({});\n    this.context.trailerInfo.Info = this.context.register(newInfo);\n\n    return newInfo;\n  }\n\n  private assertFontkit(): Fontkit {\n    if (!this.fontkit) throw new FontkitNotRegisteredError();\n    return this.fontkit;\n  }\n\n  private computePages = (): PDFPage[] =\u003e {\n    const pages: PDFPage[] = [];\n    this.catalog.Pages().traverse((node, ref) =\u003e {\n      if (node instanceof PDFPageLeaf) {\n        let page = this.pageMap.get(node);\n        if (!page) {\n          page = PDFPage.of(node, ref, this);\n          this.pageMap.set(node, page);\n        }\n        pages.push(page);\n      }\n    });\n    return pages;\n  };\n\n  private getOrCreateForm = (): PDFForm =\u003e {\n    const acroForm = this.catalog.getOrCreateAcroForm();\n    return PDFForm.of(acroForm, this);\n  };\n}\n\n/* tslint:disable-next-line only-arrow-functions */\nfunction assertIsLiteralOrHexString(\n  pdfObject: PDFObject,\n): asserts pdfObject is PDFHexString | PDFString {\n  if (\n    !(pdfObject instanceof PDFHexString) \u0026\u0026\n    !(pdfObject instanceof PDFString)\n  ) {\n    throw new UnexpectedObjectTypeError([PDFHexString, PDFString], pdfObject);\n  }\n}\n","import { Color } from 'src/api/colors';\nimport PDFFont from 'src/api/PDFFont';\nimport { Rotation } from 'src/api/rotations';\nimport { LineCapStyle } from 'src/api/operators';\n\nexport enum BlendMode {\n  Normal = 'Normal',\n  Multiply = 'Multiply',\n  Screen = 'Screen',\n  Overlay = 'Overlay',\n  Darken = 'Darken',\n  Lighten = 'Lighten',\n  ColorDodge = 'ColorDodge',\n  ColorBurn = 'ColorBurn',\n  HardLight = 'HardLight',\n  SoftLight = 'SoftLight',\n  Difference = 'Difference',\n  Exclusion = 'Exclusion',\n}\n\nexport interface PDFPageDrawTextOptions {\n  color?: Color;\n  opacity?: number;\n  blendMode?: BlendMode;\n  font?: PDFFont;\n  size?: number;\n  rotate?: Rotation;\n  xSkew?: Rotation;\n  ySkew?: Rotation;\n  x?: number;\n  y?: number;\n  lineHeight?: number;\n  maxWidth?: number;\n  wordBreaks?: string[];\n}\n\nexport interface PDFPageDrawImageOptions {\n  x?: number;\n  y?: number;\n  width?: number;\n  height?: number;\n  rotate?: Rotation;\n  xSkew?: Rotation;\n  ySkew?: Rotation;\n  opacity?: number;\n  blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawPageOptions {\n  x?: number;\n  y?: number;\n  xScale?: number;\n  yScale?: number;\n  width?: number;\n  height?: number;\n  rotate?: Rotation;\n  xSkew?: Rotation;\n  ySkew?: Rotation;\n  opacity?: number;\n  blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawSVGOptions {\n  x?: number;\n  y?: number;\n  scale?: number;\n  rotate?: Rotation;\n  borderWidth?: number;\n  color?: Color;\n  opacity?: number;\n  borderColor?: Color;\n  borderOpacity?: number;\n  borderDashArray?: number[];\n  borderDashPhase?: number;\n  borderLineCap?: LineCapStyle;\n  blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawLineOptions {\n  start: { x: number; y: number };\n  end: { x: number; y: number };\n  thickness?: number;\n  color?: Color;\n  opacity?: number;\n  lineCap?: LineCapStyle;\n  dashArray?: number[];\n  dashPhase?: number;\n  blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawRectangleOptions {\n  x?: number;\n  y?: number;\n  width?: number;\n  height?: number;\n  rotate?: Rotation;\n  xSkew?: Rotation;\n  ySkew?: Rotation;\n  borderWidth?: number;\n  color?: Color;\n  opacity?: number;\n  borderColor?: Color;\n  borderOpacity?: number;\n  borderDashArray?: number[];\n  borderDashPhase?: number;\n  borderLineCap?: LineCapStyle;\n  blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawSquareOptions {\n  x?: number;\n  y?: number;\n  size?: number;\n  rotate?: Rotation;\n  xSkew?: Rotation;\n  ySkew?: Rotation;\n  borderWidth?: number;\n  color?: Color;\n  opacity?: number;\n  borderColor?: Color;\n  borderOpacity?: number;\n  borderDashArray?: number[];\n  borderDashPhase?: number;\n  borderLineCap?: LineCapStyle;\n  blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawEllipseOptions {\n  x?: number;\n  y?: number;\n  xScale?: number;\n  yScale?: number;\n  rotate?: Rotation;\n  color?: Color;\n  opacity?: number;\n  borderColor?: Color;\n  borderOpacity?: number;\n  borderWidth?: number;\n  borderDashArray?: number[];\n  borderDashPhase?: number;\n  borderLineCap?: LineCapStyle;\n  blendMode?: BlendMode;\n}\n\nexport interface PDFPageDrawCircleOptions {\n  x?: number;\n  y?: number;\n  size?: number;\n  color?: Color;\n  opacity?: number;\n  borderColor?: Color;\n  borderOpacity?: number;\n  borderWidth?: number;\n  borderDashArray?: number[];\n  borderDashPhase?: number;\n  borderLineCap?: LineCapStyle;\n  blendMode?: BlendMode;\n}\n","import { Color, rgb } from 'src/api/colors';\nimport {\n  drawImage,\n  drawLine,\n  drawLinesOfText,\n  drawPage,\n  drawRectangle,\n  drawSvgPath,\n  drawEllipse,\n} from 'src/api/operations';\nimport {\n  popGraphicsState,\n  pushGraphicsState,\n  translate,\n  LineCapStyle,\n  scale,\n} from 'src/api/operators';\nimport PDFDocument from 'src/api/PDFDocument';\nimport PDFEmbeddedPage from 'src/api/PDFEmbeddedPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport {\n  PDFPageDrawCircleOptions,\n  PDFPageDrawEllipseOptions,\n  PDFPageDrawImageOptions,\n  PDFPageDrawLineOptions,\n  PDFPageDrawPageOptions,\n  PDFPageDrawRectangleOptions,\n  PDFPageDrawSquareOptions,\n  PDFPageDrawSVGOptions,\n  PDFPageDrawTextOptions,\n  BlendMode,\n} from 'src/api/PDFPageOptions';\nimport { degrees, Rotation, toDegrees } from 'src/api/rotations';\nimport { StandardFonts } from 'src/api/StandardFonts';\nimport {\n  PDFContentStream,\n  PDFHexString,\n  PDFName,\n  PDFOperator,\n  PDFPageLeaf,\n  PDFRef,\n  PDFDict,\n  PDFArray,\n} from 'src/core';\nimport {\n  assertEachIs,\n  assertIs,\n  assertMultiple,\n  assertOrUndefined,\n  breakTextIntoLines,\n  cleanText,\n  rectanglesAreEqual,\n  lineSplit,\n  assertRangeOrUndefined,\n  assertIsOneOfOrUndefined,\n} from 'src/utils';\n\n/**\n * Represents a single page of a [[PDFDocument]].\n */\nexport default class PDFPage {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.addPage]] and [[PDFDocument.insertPage]]\n   * \u003e methods, which can create instances of [[PDFPage]] for you.\n   *\n   * Create an instance of [[PDFPage]] from an existing leaf node.\n   *\n   * @param leafNode The leaf node to be wrapped.\n   * @param ref The unique reference for the page.\n   * @param doc The document to which the page will belong.\n   */\n  static of = (leafNode: PDFPageLeaf, ref: PDFRef, doc: PDFDocument) =\u003e\n    new PDFPage(leafNode, ref, doc);\n\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFDocument.addPage]] and [[PDFDocument.insertPage]]\n   * \u003e methods, which can create instances of [[PDFPage]] for you.\n   *\n   * Create an instance of [[PDFPage]].\n   *\n   * @param doc The document to which the page will belong.\n   */\n  static create = (doc: PDFDocument) =\u003e {\n    assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n    const dummyRef = PDFRef.of(-1);\n    const pageLeaf = PDFPageLeaf.withContextAndParent(doc.context, dummyRef);\n    const pageRef = doc.context.register(pageLeaf);\n    return new PDFPage(pageLeaf, pageRef, doc);\n  };\n\n  /** The low-level PDFDictionary wrapped by this page. */\n  readonly node: PDFPageLeaf;\n\n  /** The unique reference assigned to this page within the document. */\n  readonly ref: PDFRef;\n\n  /** The document to which this page belongs. */\n  readonly doc: PDFDocument;\n\n  private fontKey?: PDFName;\n  private font?: PDFFont;\n  private fontSize = 24;\n  private fontColor = rgb(0, 0, 0) as Color;\n  private lineHeight = 24;\n  private x = 0;\n  private y = 0;\n  private contentStream?: PDFContentStream;\n  private contentStreamRef?: PDFRef;\n\n  private constructor(leafNode: PDFPageLeaf, ref: PDFRef, doc: PDFDocument) {\n    assertIs(leafNode, 'leafNode', [[PDFPageLeaf, 'PDFPageLeaf']]);\n    assertIs(ref, 'ref', [[PDFRef, 'PDFRef']]);\n    assertIs(doc, 'doc', [[PDFDocument, 'PDFDocument']]);\n\n    this.node = leafNode;\n    this.ref = ref;\n    this.doc = doc;\n  }\n\n  /**\n   * Rotate this page by a multiple of 90 degrees. For example:\n   * ```js\n   * import { degrees } from 'pdf-lib'\n   *\n   * page.setRotation(degrees(-90))\n   * page.setRotation(degrees(0))\n   * page.setRotation(degrees(90))\n   * page.setRotation(degrees(180))\n   * page.setRotation(degrees(270))\n   * ```\n   * @param angle The angle to rotate this page.\n   */\n  setRotation(angle: Rotation): void {\n    const degreesAngle = toDegrees(angle);\n    assertMultiple(degreesAngle, 'degreesAngle', 90);\n    this.node.set(PDFName.of('Rotate'), this.doc.context.obj(degreesAngle));\n  }\n\n  /**\n   * Get this page's rotation angle in degrees. For example:\n   * ```js\n   * const rotationAngle = page.getRotation().angle;\n   * ```\n   * @returns The rotation angle of the page in degrees (always a multiple of\n   *          90 degrees).\n   */\n  getRotation(): Rotation {\n    const Rotate = this.node.Rotate();\n    return degrees(Rotate ? Rotate.asNumber() : 0);\n  }\n\n  /**\n   * Resize this page by increasing or decreasing its width and height. For\n   * example:\n   * ```js\n   * page.setSize(250, 500)\n   * page.setSize(page.getWidth() + 50, page.getHeight() + 100)\n   * page.setSize(page.getWidth() - 50, page.getHeight() - 100)\n   * ```\n   *\n   * Note that the PDF specification does not allow for pages to have explicit\n   * widths and heights. Instead it defines the \"size\" of a page in terms of\n   * five rectangles: the MediaBox, CropBox, BleedBox, TrimBox, and ArtBox. As a\n   * result, this method cannot directly change the width and height of a page.\n   * Instead, it works by adjusting these five boxes.\n   *\n   * This method performs the following steps:\n   *   1. Set width \u0026 height of MediaBox.\n   *   2. Set width \u0026 height of CropBox, if it has same dimensions as MediaBox.\n   *   3. Set width \u0026 height of BleedBox, if it has same dimensions as MediaBox.\n   *   4. Set width \u0026 height of TrimBox, if it has same dimensions as MediaBox.\n   *   5. Set width \u0026 height of ArtBox, if it has same dimensions as MediaBox.\n   *\n   * This approach works well for most PDF documents as all PDF pages must\n   * have a MediaBox, but relatively few have a CropBox, BleedBox, TrimBox, or\n   * ArtBox. And when they do have these additional boxes, they often have the\n   * same dimensions as the MediaBox. However, if you find this method does not\n   * work for your document, consider setting the boxes directly:\n   *   * [[PDFPage.setMediaBox]]\n   *   * [[PDFPage.setCropBox]]\n   *   * [[PDFPage.setBleedBox]]\n   *   * [[PDFPage.setTrimBox]]\n   *   * [[PDFPage.setArtBox]]\n   *\n   * @param width The new width of the page.\n   * @param height The new height of the page.\n   */\n  setSize(width: number, height: number): void {\n    assertIs(width, 'width', ['number']);\n    assertIs(height, 'height', ['number']);\n\n    const mediaBox = this.getMediaBox();\n    this.setMediaBox(mediaBox.x, mediaBox.y, width, height);\n\n    const cropBox = this.getCropBox();\n    const bleedBox = this.getBleedBox();\n    const trimBox = this.getTrimBox();\n    const artBox = this.getArtBox();\n\n    const hasCropBox = this.node.CropBox()!!;\n    const hasBleedBox = this.node.BleedBox()!!;\n    const hasTrimBox = this.node.TrimBox()!!;\n    const hasArtBox = this.node.ArtBox()!!;\n\n    if (hasCropBox \u0026\u0026 rectanglesAreEqual(cropBox, mediaBox)) {\n      this.setCropBox(mediaBox.x, mediaBox.y, width, height);\n    }\n    if (hasBleedBox \u0026\u0026 rectanglesAreEqual(bleedBox, mediaBox)) {\n      this.setBleedBox(mediaBox.x, mediaBox.y, width, height);\n    }\n    if (hasTrimBox \u0026\u0026 rectanglesAreEqual(trimBox, mediaBox)) {\n      this.setTrimBox(mediaBox.x, mediaBox.y, width, height);\n    }\n    if (hasArtBox \u0026\u0026 rectanglesAreEqual(artBox, mediaBox)) {\n      this.setArtBox(mediaBox.x, mediaBox.y, width, height);\n    }\n  }\n\n  /**\n   * Resize this page by increasing or decreasing its width. For example:\n   * ```js\n   * page.setWidth(250)\n   * page.setWidth(page.getWidth() + 50)\n   * page.setWidth(page.getWidth() - 50)\n   * ```\n   *\n   * This method uses [[PDFPage.setSize]] to set the page's width.\n   *\n   * @param width The new width of the page.\n   */\n  setWidth(width: number): void {\n    assertIs(width, 'width', ['number']);\n    this.setSize(width, this.getSize().height);\n  }\n\n  /**\n   * Resize this page by increasing or decreasing its height. For example:\n   * ```js\n   * page.setHeight(500)\n   * page.setHeight(page.getWidth() + 100)\n   * page.setHeight(page.getWidth() - 100)\n   * ```\n   *\n   * This method uses [[PDFPage.setSize]] to set the page's height.\n   *\n   * @param height The new height of the page.\n   */\n  setHeight(height: number): void {\n    assertIs(height, 'height', ['number']);\n    this.setSize(this.getSize().width, height);\n  }\n\n  /**\n   * Set the MediaBox of this page. For example:\n   * ```js\n   * const mediaBox = page.getMediaBox()\n   *\n   * page.setMediaBox(0, 0, 250, 500)\n   * page.setMediaBox(mediaBox.x, mediaBox.y, 50, 100)\n   * page.setMediaBox(15, 5, mediaBox.width - 50, mediaBox.height - 100)\n   * ```\n   *\n   * See [[PDFPage.getMediaBox]] for details about what the MediaBox represents.\n   *\n   * @param x The x coordinate of the lower left corner of the new MediaBox.\n   * @param y The y coordinate of the lower left corner of the new MediaBox.\n   * @param width The width of the new MediaBox.\n   * @param height The height of the new MediaBox.\n   */\n  setMediaBox(x: number, y: number, width: number, height: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n    assertIs(width, 'width', ['number']);\n    assertIs(height, 'height', ['number']);\n    const mediaBox = this.doc.context.obj([x, y, x + width, y + height]);\n    this.node.set(PDFName.MediaBox, mediaBox);\n  }\n\n  /**\n   * Set the CropBox of this page. For example:\n   * ```js\n   * const cropBox = page.getCropBox()\n   *\n   * page.setCropBox(0, 0, 250, 500)\n   * page.setCropBox(cropBox.x, cropBox.y, 50, 100)\n   * page.setCropBox(15, 5, cropBox.width - 50, cropBox.height - 100)\n   * ```\n   *\n   * See [[PDFPage.getCropBox]] for details about what the CropBox represents.\n   *\n   * @param x The x coordinate of the lower left corner of the new CropBox.\n   * @param y The y coordinate of the lower left corner of the new CropBox.\n   * @param width The width of the new CropBox.\n   * @param height The height of the new CropBox.\n   */\n  setCropBox(x: number, y: number, width: number, height: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n    assertIs(width, 'width', ['number']);\n    assertIs(height, 'height', ['number']);\n    const cropBox = this.doc.context.obj([x, y, x + width, y + height]);\n    this.node.set(PDFName.CropBox, cropBox);\n  }\n\n  /**\n   * Set the BleedBox of this page. For example:\n   * ```js\n   * const bleedBox = page.getBleedBox()\n   *\n   * page.setBleedBox(0, 0, 250, 500)\n   * page.setBleedBox(bleedBox.x, bleedBox.y, 50, 100)\n   * page.setBleedBox(15, 5, bleedBox.width - 50, bleedBox.height - 100)\n   * ```\n   *\n   * See [[PDFPage.getBleedBox]] for details about what the BleedBox represents.\n   *\n   * @param x The x coordinate of the lower left corner of the new BleedBox.\n   * @param y The y coordinate of the lower left corner of the new BleedBox.\n   * @param width The width of the new BleedBox.\n   * @param height The height of the new BleedBox.\n   */\n  setBleedBox(x: number, y: number, width: number, height: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n    assertIs(width, 'width', ['number']);\n    assertIs(height, 'height', ['number']);\n    const bleedBox = this.doc.context.obj([x, y, x + width, y + height]);\n    this.node.set(PDFName.BleedBox, bleedBox);\n  }\n\n  /**\n   * Set the TrimBox of this page. For example:\n   * ```js\n   * const trimBox = page.getTrimBox()\n   *\n   * page.setTrimBox(0, 0, 250, 500)\n   * page.setTrimBox(trimBox.x, trimBox.y, 50, 100)\n   * page.setTrimBox(15, 5, trimBox.width - 50, trimBox.height - 100)\n   * ```\n   *\n   * See [[PDFPage.getTrimBox]] for details about what the TrimBox represents.\n   *\n   * @param x The x coordinate of the lower left corner of the new TrimBox.\n   * @param y The y coordinate of the lower left corner of the new TrimBox.\n   * @param width The width of the new TrimBox.\n   * @param height The height of the new TrimBox.\n   */\n  setTrimBox(x: number, y: number, width: number, height: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n    assertIs(width, 'width', ['number']);\n    assertIs(height, 'height', ['number']);\n    const trimBox = this.doc.context.obj([x, y, x + width, y + height]);\n    this.node.set(PDFName.TrimBox, trimBox);\n  }\n\n  /**\n   * Set the ArtBox of this page. For example:\n   * ```js\n   * const artBox = page.getArtBox()\n   *\n   * page.setArtBox(0, 0, 250, 500)\n   * page.setArtBox(artBox.x, artBox.y, 50, 100)\n   * page.setArtBox(15, 5, artBox.width - 50, artBox.height - 100)\n   * ```\n   *\n   * See [[PDFPage.getArtBox]] for details about what the ArtBox represents.\n   *\n   * @param x The x coordinate of the lower left corner of the new ArtBox.\n   * @param y The y coordinate of the lower left corner of the new ArtBox.\n   * @param width The width of the new ArtBox.\n   * @param height The height of the new ArtBox.\n   */\n  setArtBox(x: number, y: number, width: number, height: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n    assertIs(width, 'width', ['number']);\n    assertIs(height, 'height', ['number']);\n    const artBox = this.doc.context.obj([x, y, x + width, y + height]);\n    this.node.set(PDFName.ArtBox, artBox);\n  }\n\n  /**\n   * Get this page's width and height. For example:\n   * ```js\n   * const { width, height } = page.getSize()\n   * ```\n   *\n   * This method uses [[PDFPage.getMediaBox]] to obtain the page's\n   * width and height.\n   *\n   * @returns The width and height of the page.\n   */\n  getSize(): { width: number; height: number } {\n    const { width, height } = this.getMediaBox();\n    return { width, height };\n  }\n\n  /**\n   * Get this page's width. For example:\n   * ```js\n   * const width = page.getWidth()\n   * ```\n   *\n   * This method uses [[PDFPage.getSize]] to obtain the page's size.\n   *\n   * @returns The width of the page.\n   */\n  getWidth(): number {\n    return this.getSize().width;\n  }\n\n  /**\n   * Get this page's height. For example:\n   * ```js\n   * const height = page.getHeight()\n   * ```\n   *\n   * This method uses [[PDFPage.getSize]] to obtain the page's size.\n   *\n   * @returns The height of the page.\n   */\n  getHeight(): number {\n    return this.getSize().height;\n  }\n\n  /**\n   * Get the rectangle defining this page's MediaBox. For example:\n   * ```js\n   * const { x, y, width, height } = page.getMediaBox()\n   * ```\n   *\n   * The MediaBox of a page defines the boundaries of the physical medium on\n   * which the page is to be displayed/printed. It may include extended area\n   * surrounding the page content for bleed marks, printing marks, etc...\n   * It may also include areas close to the edges of the medium that cannot be\n   * marked because of physical limitations of the output device. Content\n   * falling outside this boundary may safely be discarded without affecting\n   * the meaning of the PDF file.\n   *\n   * @returns An object defining the lower left corner of the MediaBox and its\n   *          width \u0026 height.\n   */\n  getMediaBox(): { x: number; y: number; width: number; height: number } {\n    const mediaBox = this.node.MediaBox();\n    return mediaBox.asRectangle();\n  }\n\n  /**\n   * Get the rectangle defining this page's CropBox. For example:\n   * ```js\n   * const { x, y, width, height } = page.getCropBox()\n   * ```\n   *\n   * The CropBox of a page defines the region to which the contents of the page\n   * shall be clipped when displayed or printed. Unlike the other boxes, the\n   * CropBox does not necessarily represent the physical page geometry. It\n   * merely imposes clipping on the page contents.\n   *\n   * The CropBox's default value is the page's MediaBox.\n   *\n   * @returns An object defining the lower left corner of the CropBox and its\n   *          width \u0026 height.\n   */\n  getCropBox(): { x: number; y: number; width: number; height: number } {\n    const cropBox = this.node.CropBox();\n    return cropBox?.asRectangle() ?? this.getMediaBox();\n  }\n\n  /**\n   * Get the rectangle defining this page's BleedBox. For example:\n   * ```js\n   * const { x, y, width, height } = page.getBleedBox()\n   * ```\n   *\n   * The BleedBox of a page defines the region to which the contents of the\n   * page shall be clipped when output in a production environment. This may\n   * include any extra bleed area needed to accommodate the physical\n   * limitations of cutting, folding, and trimming equipment. The actual\n   * printed page may include printing marks that fall outside the BleedBox.\n   *\n   * The BleedBox's default value is the page's CropBox.\n   *\n   * @returns An object defining the lower left corner of the BleedBox and its\n   *          width \u0026 height.\n   */\n  getBleedBox(): { x: number; y: number; width: number; height: number } {\n    const bleedBox = this.node.BleedBox();\n    return bleedBox?.asRectangle() ?? this.getCropBox();\n  }\n\n  /**\n   * Get the rectangle defining this page's TrimBox. For example:\n   * ```js\n   * const { x, y, width, height } = page.getTrimBox()\n   * ```\n   *\n   * The TrimBox of a page defines the intended dimensions of the finished\n   * page after trimming. It may be smaller than the MediaBox to allow for\n   * production-related content, such as printing instructions, cut marks, or\n   * color bars.\n   *\n   * The TrimBox's default value is the page's CropBox.\n   *\n   * @returns An object defining the lower left corner of the TrimBox and its\n   *          width \u0026 height.\n   */\n  getTrimBox(): { x: number; y: number; width: number; height: number } {\n    const trimBox = this.node.TrimBox();\n    return trimBox?.asRectangle() ?? this.getCropBox();\n  }\n\n  /**\n   * Get the rectangle defining this page's ArtBox. For example:\n   * ```js\n   * const { x, y, width, height } = page.getArtBox()\n   * ```\n   *\n   * The ArtBox of a page defines the extent of the page's meaningful content\n   * (including potential white space).\n   *\n   * The ArtBox's default value is the page's CropBox.\n   *\n   * @returns An object defining the lower left corner of the ArtBox and its\n   *          width \u0026 height.\n   */\n  getArtBox(): { x: number; y: number; width: number; height: number } {\n    const artBox = this.node.ArtBox();\n    return artBox?.asRectangle() ?? this.getCropBox();\n  }\n\n  /**\n   * Translate this page's content to a new location on the page. This operation\n   * is often useful after resizing the page with [[setSize]]. For example:\n   * ```js\n   * // Add 50 units of whitespace to the top and right of the page\n   * page.setSize(page.getWidth() + 50, page.getHeight() + 50)\n   *\n   * // Move the page's content from the lower-left corner of the page\n   * // to the top-right corner.\n   * page.translateContent(50, 50)\n   *\n   * // Now there are 50 units of whitespace to the left and bottom of the page\n   * ```\n   * See also: [[resetPosition]]\n   * @param x The new position on the x-axis for this page's content.\n   * @param y The new position on the y-axis for this page's content.\n   */\n  translateContent(x: number, y: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n\n    this.node.normalize();\n    this.getContentStream();\n\n    const start = this.createContentStream(\n      pushGraphicsState(),\n      translate(x, y),\n    );\n    const startRef = this.doc.context.register(start);\n\n    const end = this.createContentStream(popGraphicsState());\n    const endRef = this.doc.context.register(end);\n\n    this.node.wrapContentStreams(startRef, endRef);\n  }\n\n  /**\n   * Scale the size, content, and annotations of a page.\n   *\n   * For example:\n   * ```js\n   * page.scale(0.5, 0.5);\n   * ```\n   *\n   * @param x The factor by which the width for the page should be scaled\n   *          (e.g. `0.5` is 50%).\n   * @param y The factor by which the height for the page should be scaled\n   *          (e.g. `2.0` is 200%).\n   */\n  scale(x: number, y: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n    this.setSize(this.getWidth() * x, this.getHeight() * y);\n    this.scaleContent(x, y);\n    this.scaleAnnotations(x, y);\n  }\n\n  /**\n   * Scale the content of a page. This is useful after resizing an existing\n   * page. This scales only the content, not the annotations.\n   *\n   * For example:\n   * ```js\n   * // Bisect the size of the page\n   * page.setSize(page.getWidth() / 2, page.getHeight() / 2);\n   *\n   * // Scale the content of the page down by 50% in x and y\n   * page.scaleContent(0.5, 0.5);\n   * ```\n   * See also: [[scaleAnnotations]]\n   * @param x The factor by which the x-axis for the content should be scaled\n   *          (e.g. `0.5` is 50%).\n   * @param y The factor by which the y-axis for the content should be scaled\n   *          (e.g. `2.0` is 200%).\n   */\n  scaleContent(x: number, y: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n\n    this.node.normalize();\n    this.getContentStream();\n\n    const start = this.createContentStream(pushGraphicsState(), scale(x, y));\n    const startRef = this.doc.context.register(start);\n\n    const end = this.createContentStream(popGraphicsState());\n    const endRef = this.doc.context.register(end);\n\n    this.node.wrapContentStreams(startRef, endRef);\n  }\n\n  /**\n   * Scale the annotations of a page. This is useful if you want to scale a\n   * page with comments or other annotations.\n   * ```js\n   * // Scale the content of the page down by 50% in x and y\n   * page.scaleContent(0.5, 0.5);\n   *\n   * // Scale the content of the page down by 50% in x and y\n   * page.scaleAnnotations(0.5, 0.5);\n   * ```\n   * See also: [[scaleContent]]\n   * @param x The factor by which the x-axis for the annotations should be\n   *          scaled (e.g. `0.5` is 50%).\n   * @param y The factor by which the y-axis for the annotations should be\n   *          scaled (e.g. `2.0` is 200%).\n   */\n  scaleAnnotations(x: number, y: number) {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n\n    const annots = this.node.Annots();\n    if (!annots) return;\n\n    for (let idx = 0; idx \u003c annots.size(); idx++) {\n      const annot = annots.lookup(idx);\n      if (annot instanceof PDFDict) this.scaleAnnot(annot, x, y);\n    }\n  }\n\n  /**\n   * Reset the x and y coordinates of this page to `(0, 0)`. This operation is\n   * often useful after calling [[translateContent]]. For example:\n   * ```js\n   * // Shift the page's contents up and to the right by 50 units\n   * page.translateContent(50, 50)\n   *\n   * // This text will shifted - it will be drawn at (50, 50)\n   * page.drawText('I am shifted')\n   *\n   * // Move back to (0, 0)\n   * page.resetPosition()\n   *\n   * // This text will not be shifted - it will be drawn at (0, 0)\n   * page.drawText('I am not shifted')\n   * ```\n   */\n  resetPosition(): void {\n    this.getContentStream(false);\n    this.x = 0;\n    this.y = 0;\n  }\n\n  /**\n   * Choose a default font for this page. The default font will be used whenever\n   * text is drawn on this page and no font is specified. For example:\n   * ```js\n   * import { StandardFonts } from 'pdf-lib'\n   *\n   * const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)\n   * const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const courierFont = await pdfDoc.embedFont(StandardFonts.Courier)\n   *\n   * const page = pdfDoc.addPage()\n   *\n   * page.setFont(helveticaFont)\n   * page.drawText('I will be drawn in Helvetica')\n   *\n   * page.setFont(timesRomanFont)\n   * page.drawText('I will be drawn in Courier', { font: courierFont })\n   * ```\n   * @param font The default font to be used when drawing text on this page.\n   */\n  setFont(font: PDFFont): void {\n    // TODO: Reuse image Font name if we've already added this image to Resources.Fonts\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    this.font = font;\n    this.fontKey = this.node.newFontDictionary(this.font.name, this.font.ref);\n  }\n\n  /**\n   * Choose a default font size for this page. The default font size will be\n   * used whenever text is drawn on this page and no font size is specified.\n   * For example:\n   * ```js\n   * page.setFontSize(12)\n   * page.drawText('I will be drawn in size 12')\n   *\n   * page.setFontSize(36)\n   * page.drawText('I will be drawn in size 24', { fontSize: 24 })\n   * ```\n   * @param fontSize The default font size to be used when drawing text on this\n   *                 page.\n   */\n  setFontSize(fontSize: number): void {\n    assertIs(fontSize, 'fontSize', ['number']);\n    this.fontSize = fontSize;\n  }\n\n  /**\n   * Choose a default font color for this page. The default font color will be\n   * used whenever text is drawn on this page and no font color is specified.\n   * For example:\n   * ```js\n   * import { rgb, cmyk, grayscale } from 'pdf-lib'\n   *\n   * page.setFontColor(rgb(0.97, 0.02, 0.97))\n   * page.drawText('I will be drawn in pink')\n   *\n   * page.setFontColor(cmyk(0.4, 0.7, 0.39, 0.15))\n   * page.drawText('I will be drawn in gray', { color: grayscale(0.5) })\n   * ```\n   * @param fontColor The default font color to be used when drawing text on\n   *                  this page.\n   */\n  setFontColor(fontColor: Color): void {\n    assertIs(fontColor, 'fontColor', [[Object, 'Color']]);\n    this.fontColor = fontColor;\n  }\n\n  /**\n   * Choose a default line height for this page. The default line height will be\n   * used whenever text is drawn on this page and no line height is specified.\n   * For example:\n   * ```js\n   * page.setLineHeight(12);\n   * page.drawText('These lines will be vertically \\n separated by 12 units')\n   *\n   * page.setLineHeight(36);\n   * page.drawText('These lines will be vertically \\n separated by 24 units', {\n   *   lineHeight: 24\n   * })\n   * ```\n   * @param lineHeight The default line height to be used when drawing text on\n   *                   this page.\n   */\n  setLineHeight(lineHeight: number): void {\n    assertIs(lineHeight, 'lineHeight', ['number']);\n    this.lineHeight = lineHeight;\n  }\n\n  /**\n   * Get the default position of this page. For example:\n   * ```js\n   * const { x, y } = page.getPosition()\n   * ```\n   * @returns The default position of the page.\n   */\n  getPosition(): { x: number; y: number } {\n    return { x: this.x, y: this.y };\n  }\n\n  /**\n   * Get the default x coordinate of this page. For example:\n   * ```js\n   * const x = page.getX()\n   * ```\n   * @returns The default x coordinate of the page.\n   */\n  getX(): number {\n    return this.x;\n  }\n\n  /**\n   * Get the default y coordinate of this page. For example:\n   * ```js\n   * const y = page.getY()\n   * ```\n   * @returns The default y coordinate of the page.\n   */\n  getY(): number {\n    return this.y;\n  }\n\n  /**\n   * Change the default position of this page. For example:\n   * ```js\n   * page.moveTo(0, 0)\n   * page.drawText('I will be drawn at the origin')\n   *\n   * page.moveTo(0, 25)\n   * page.drawText('I will be drawn 25 units up')\n   *\n   * page.moveTo(25, 25)\n   * page.drawText('I will be drawn 25 units up and 25 units to the right')\n   * ```\n   * @param x The new default position on the x-axis for this page.\n   * @param y The new default position on the y-axis for this page.\n   */\n  moveTo(x: number, y: number): void {\n    assertIs(x, 'x', ['number']);\n    assertIs(y, 'y', ['number']);\n    this.x = x;\n    this.y = y;\n  }\n\n  /**\n   * Change the default position of this page to be further down the y-axis.\n   * For example:\n   * ```js\n   * page.moveTo(50, 50)\n   * page.drawText('I will be drawn at (50, 50)')\n   *\n   * page.moveDown(10)\n   * page.drawText('I will be drawn at (50, 40)')\n   * ```\n   * @param yDecrease The amount by which the page's default position along the\n   *                  y-axis should be decreased.\n   */\n  moveDown(yDecrease: number): void {\n    assertIs(yDecrease, 'yDecrease', ['number']);\n    this.y -= yDecrease;\n  }\n\n  /**\n   * Change the default position of this page to be further up the y-axis.\n   * For example:\n   * ```js\n   * page.moveTo(50, 50)\n   * page.drawText('I will be drawn at (50, 50)')\n   *\n   * page.moveUp(10)\n   * page.drawText('I will be drawn at (50, 60)')\n   * ```\n   * @param yIncrease The amount by which the page's default position along the\n   *                  y-axis should be increased.\n   */\n  moveUp(yIncrease: number): void {\n    assertIs(yIncrease, 'yIncrease', ['number']);\n    this.y += yIncrease;\n  }\n\n  /**\n   * Change the default position of this page to be further left on the x-axis.\n   * For example:\n   * ```js\n   * page.moveTo(50, 50)\n   * page.drawText('I will be drawn at (50, 50)')\n   *\n   * page.moveLeft(10)\n   * page.drawText('I will be drawn at (40, 50)')\n   * ```\n   * @param xDecrease The amount by which the page's default position along the\n   *                  x-axis should be decreased.\n   */\n  moveLeft(xDecrease: number): void {\n    assertIs(xDecrease, 'xDecrease', ['number']);\n    this.x -= xDecrease;\n  }\n\n  /**\n   * Change the default position of this page to be further right on the y-axis.\n   * For example:\n   * ```js\n   * page.moveTo(50, 50)\n   * page.drawText('I will be drawn at (50, 50)')\n   *\n   * page.moveRight(10)\n   * page.drawText('I will be drawn at (60, 50)')\n   * ```\n   * @param xIncrease The amount by which the page's default position along the\n   *                  x-axis should be increased.\n   */\n  moveRight(xIncrease: number): void {\n    assertIs(xIncrease, 'xIncrease', ['number']);\n    this.x += xIncrease;\n  }\n\n  /**\n   * Push one or more operators to the end of this page's current content\n   * stream. For example:\n   * ```js\n   * import {\n   *   pushGraphicsState,\n   *   moveTo,\n   *   lineTo,\n   *   closePath,\n   *   setFillingColor,\n   *   rgb,\n   *   fill,\n   *   popGraphicsState,\n   * } from 'pdf-lib'\n   *\n   * // Draw a green triangle in the lower-left corner of the page\n   * page.pushOperators(\n   *   pushGraphicsState(),\n   *   moveTo(0, 0),\n   *   lineTo(100, 0),\n   *   lineTo(50, 100),\n   *   closePath(),\n   *   setFillingColor(rgb(0.0, 1.0, 0.0)),\n   *   fill(),\n   *   popGraphicsState(),\n   * )\n   * ```\n   * @param operator The operators to be pushed.\n   */\n  pushOperators(...operator: PDFOperator[]): void {\n    assertEachIs(operator, 'operator', [[PDFOperator, 'PDFOperator']]);\n    const contentStream = this.getContentStream();\n    contentStream.push(...operator);\n  }\n\n  /**\n   * Draw one or more lines of text on this page. For example:\n   * ```js\n   * import { StandardFonts, rgb } from 'pdf-lib'\n   *\n   * const helveticaFont = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman)\n   *\n   * const page = pdfDoc.addPage()\n   *\n   * page.setFont(helveticaFont)\n   *\n   * page.moveTo(5, 200)\n   * page.drawText('The Life of an Egg', { size: 36 })\n   *\n   * page.moveDown(36)\n   * page.drawText('An Epic Tale of Woe', { size: 30 })\n   *\n   * page.drawText(\n   *   `Humpty Dumpty sat on a wall \\n` +\n   *   `Humpty Dumpty had a great fall; \\n` +\n   *   `All the king's horses and all the king's men \\n` +\n   *   `Couldn't put Humpty together again. \\n`,\n   *   {\n   *     x: 25,\n   *     y: 100,\n   *     font: timesRomanFont,\n   *     size: 24,\n   *     color: rgb(1, 0, 0),\n   *     lineHeight: 24,\n   *     opacity: 0.75,\n   *   },\n   * )\n   * ```\n   * @param text The text to be drawn.\n   * @param options The options to be used when drawing the text.\n   */\n  drawText(text: string, options: PDFPageDrawTextOptions = {}): void {\n    assertIs(text, 'text', ['string']);\n    assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n    assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n    assertOrUndefined(options.font, 'options.font', [[PDFFont, 'PDFFont']]);\n    assertOrUndefined(options.size, 'options.size', ['number']);\n    assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n    assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n    assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n    assertOrUndefined(options.x, 'options.x', ['number']);\n    assertOrUndefined(options.y, 'options.y', ['number']);\n    assertOrUndefined(options.lineHeight, 'options.lineHeight', ['number']);\n    assertOrUndefined(options.maxWidth, 'options.maxWidth', ['number']);\n    assertOrUndefined(options.wordBreaks, 'options.wordBreaks', [Array]);\n    assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n    const { oldFont, newFont, newFontKey } = this.setOrEmbedFont(options.font);\n    const fontSize = options.size || this.fontSize;\n\n    const wordBreaks = options.wordBreaks || this.doc.defaultWordBreaks;\n    const textWidth = (t: string) =\u003e newFont.widthOfTextAtSize(t, fontSize);\n    const lines =\n      options.maxWidth === undefined\n        ? lineSplit(cleanText(text))\n        : breakTextIntoLines(text, wordBreaks, options.maxWidth, textWidth);\n\n    const encodedLines = new Array(lines.length) as PDFHexString[];\n    for (let idx = 0, len = lines.length; idx \u003c len; idx++) {\n      encodedLines[idx] = newFont.encodeText(lines[idx]);\n    }\n\n    const graphicsStateKey = this.maybeEmbedGraphicsState({\n      opacity: options.opacity,\n      blendMode: options.blendMode,\n    });\n\n    const contentStream = this.getContentStream();\n    contentStream.push(\n      ...drawLinesOfText(encodedLines, {\n        color: options.color ?? this.fontColor,\n        font: newFontKey,\n        size: fontSize,\n        rotate: options.rotate ?? degrees(0),\n        xSkew: options.xSkew ?? degrees(0),\n        ySkew: options.ySkew ?? degrees(0),\n        x: options.x ?? this.x,\n        y: options.y ?? this.y,\n        lineHeight: options.lineHeight ?? this.lineHeight,\n        graphicsState: graphicsStateKey,\n      }),\n    );\n\n    if (options.font) {\n      if (oldFont) this.setFont(oldFont);\n      else this.resetFont();\n    }\n  }\n\n  /**\n   * Draw an image on this page. For example:\n   * ```js\n   * import { degrees } from 'pdf-lib'\n   *\n   * const jpgUrl = 'https://pdf-lib.js.org/assets/cat_riding_unicorn.jpg'\n   * const jpgImageBytes = await fetch(jpgUrl).then((res) =\u003e res.arrayBuffer())\n   *\n   * const jpgImage = await pdfDoc.embedJpg(jpgImageBytes)\n   * const jpgDims = jpgImage.scale(0.5)\n   *\n   * const page = pdfDoc.addPage()\n   *\n   * page.drawImage(jpgImage, {\n   *   x: 25,\n   *   y: 25,\n   *   width: jpgDims.width,\n   *   height: jpgDims.height,\n   *   rotate: degrees(30),\n   *   opacity: 0.75,\n   * })\n   * ```\n   * @param image The image to be drawn.\n   * @param options The options to be used when drawing the image.\n   */\n  drawImage(image: PDFImage, options: PDFPageDrawImageOptions = {}): void {\n    // TODO: Reuse image XObject name if we've already added this image to Resources.XObjects\n    assertIs(image, 'image', [[PDFImage, 'PDFImage']]);\n    assertOrUndefined(options.x, 'options.x', ['number']);\n    assertOrUndefined(options.y, 'options.y', ['number']);\n    assertOrUndefined(options.width, 'options.width', ['number']);\n    assertOrUndefined(options.height, 'options.height', ['number']);\n    assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n    assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n    assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n    assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n    assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n    const xObjectKey = this.node.newXObject('Image', image.ref);\n\n    const graphicsStateKey = this.maybeEmbedGraphicsState({\n      opacity: options.opacity,\n      blendMode: options.blendMode,\n    });\n\n    const contentStream = this.getContentStream();\n    contentStream.push(\n      ...drawImage(xObjectKey, {\n        x: options.x ?? this.x,\n        y: options.y ?? this.y,\n        width: options.width ?? image.size().width,\n        height: options.height ?? image.size().height,\n        rotate: options.rotate ?? degrees(0),\n        xSkew: options.xSkew ?? degrees(0),\n        ySkew: options.ySkew ?? degrees(0),\n        graphicsState: graphicsStateKey,\n      }),\n    );\n  }\n\n  /**\n   * Draw an embedded PDF page on this page. For example:\n   * ```js\n   * import { degrees } from 'pdf-lib'\n   *\n   * const pdfDoc = await PDFDocument.create()\n   * const page = pdfDoc.addPage()\n   *\n   * const sourcePdfUrl = 'https://pdf-lib.js.org/assets/with_large_page_count.pdf'\n   * const sourcePdf = await fetch(sourcePdfUrl).then((res) =\u003e res.arrayBuffer())\n   *\n   * // Embed page 74 from the PDF\n   * const [embeddedPage] = await pdfDoc.embedPdf(sourcePdf, 73)\n   *\n   * page.drawPage(embeddedPage, {\n   *   x: 250,\n   *   y: 200,\n   *   xScale: 0.5,\n   *   yScale: 0.5,\n   *   rotate: degrees(30),\n   *   opacity: 0.75,\n   * })\n   * ```\n   *\n   * The `options` argument accepts both `width`/`height` and `xScale`/`yScale`\n   * as options. Since each of these options defines the size of the drawn page,\n   * if both options are given, `width` and `height` take precedence and the\n   * corresponding scale variants are ignored.\n   *\n   * @param embeddedPage The embedded page to be drawn.\n   * @param options The options to be used when drawing the embedded page.\n   */\n  drawPage(\n    embeddedPage: PDFEmbeddedPage,\n    options: PDFPageDrawPageOptions = {},\n  ): void {\n    // TODO: Reuse embeddedPage XObject name if we've already added this embeddedPage to Resources.XObjects\n    assertIs(embeddedPage, 'embeddedPage', [\n      [PDFEmbeddedPage, 'PDFEmbeddedPage'],\n    ]);\n    assertOrUndefined(options.x, 'options.x', ['number']);\n    assertOrUndefined(options.y, 'options.y', ['number']);\n    assertOrUndefined(options.xScale, 'options.xScale', ['number']);\n    assertOrUndefined(options.yScale, 'options.yScale', ['number']);\n    assertOrUndefined(options.width, 'options.width', ['number']);\n    assertOrUndefined(options.height, 'options.height', ['number']);\n    assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n    assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n    assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n    assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n    assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n    const xObjectKey = this.node.newXObject(\n      'EmbeddedPdfPage',\n      embeddedPage.ref,\n    );\n\n    const graphicsStateKey = this.maybeEmbedGraphicsState({\n      opacity: options.opacity,\n      blendMode: options.blendMode,\n    });\n\n    // prettier-ignore\n    const xScale = (\n        options.width  !== undefined ? options.width / embeddedPage.width\n      : options.xScale !== undefined ? options.xScale\n      : 1\n    );\n\n    // prettier-ignore\n    const yScale = (\n        options.height !== undefined ? options.height / embeddedPage.height\n      : options.yScale !== undefined ? options.yScale\n      : 1\n    );\n\n    const contentStream = this.getContentStream();\n    contentStream.push(\n      ...drawPage(xObjectKey, {\n        x: options.x ?? this.x,\n        y: options.y ?? this.y,\n        xScale,\n        yScale,\n        rotate: options.rotate ?? degrees(0),\n        xSkew: options.xSkew ?? degrees(0),\n        ySkew: options.ySkew ?? degrees(0),\n        graphicsState: graphicsStateKey,\n      }),\n    );\n  }\n\n  /**\n   * Draw an SVG path on this page. For example:\n   * ```js\n   * import { rgb } from 'pdf-lib'\n   *\n   * const svgPath = 'M 0,20 L 100,160 Q 130,200 150,120 C 190,-40 200,200 300,150 L 400,90'\n   *\n   * // Draw path as black line\n   * page.drawSvgPath(svgPath, { x: 25, y: 75 })\n   *\n   * // Change border style and opacity\n   * page.drawSvgPath(svgPath, {\n   *   x: 25,\n   *   y: 275,\n   *   borderColor: rgb(0.5, 0.5, 0.5),\n   *   borderWidth: 2,\n   *   borderOpacity: 0.75,\n   * })\n   *\n   * // Set fill color and opacity\n   * page.drawSvgPath(svgPath, {\n   *   x: 25,\n   *   y: 475,\n   *   color: rgb(1.0, 0, 0),\n   *   opacity: 0.75,\n   * })\n   *\n   * // Draw 50% of original size\n   * page.drawSvgPath(svgPath, {\n   *   x: 25,\n   *   y: 675,\n   *   scale: 0.5,\n   * })\n   * ```\n   * @param path The SVG path to be drawn.\n   * @param options The options to be used when drawing the SVG path.\n   */\n  drawSvgPath(path: string, options: PDFPageDrawSVGOptions = {}): void {\n    assertIs(path, 'path', ['string']);\n    assertOrUndefined(options.x, 'options.x', ['number']);\n    assertOrUndefined(options.y, 'options.y', ['number']);\n    assertOrUndefined(options.scale, 'options.scale', ['number']);\n    assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n    assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);\n    assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n    assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n    assertOrUndefined(options.borderColor, 'options.borderColor', [\n      [Object, 'Color'],\n    ]);\n    assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [\n      Array,\n    ]);\n    assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [\n      'number',\n    ]);\n    assertIsOneOfOrUndefined(\n      options.borderLineCap,\n      'options.borderLineCap',\n      LineCapStyle,\n    );\n    assertRangeOrUndefined(\n      options.borderOpacity,\n      'options.borderOpacity',\n      0,\n      1,\n    );\n    assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n    const graphicsStateKey = this.maybeEmbedGraphicsState({\n      opacity: options.opacity,\n      borderOpacity: options.borderOpacity,\n      blendMode: options.blendMode,\n    });\n\n    if (!('color' in options) \u0026\u0026 !('borderColor' in options)) {\n      options.borderColor = rgb(0, 0, 0);\n    }\n\n    const contentStream = this.getContentStream();\n    contentStream.push(\n      ...drawSvgPath(path, {\n        x: options.x ?? this.x,\n        y: options.y ?? this.y,\n        scale: options.scale,\n        rotate: options.rotate ?? degrees(0),\n        color: options.color ?? undefined,\n        borderColor: options.borderColor ?? undefined,\n        borderWidth: options.borderWidth ?? 0,\n        borderDashArray: options.borderDashArray ?? undefined,\n        borderDashPhase: options.borderDashPhase ?? undefined,\n        borderLineCap: options.borderLineCap ?? undefined,\n        graphicsState: graphicsStateKey,\n      }),\n    );\n  }\n\n  /**\n   * Draw a line on this page. For example:\n   * ```js\n   * import { rgb } from 'pdf-lib'\n   *\n   * page.drawLine({\n   *   start: { x: 25, y: 75 },\n   *   end: { x: 125, y: 175 },\n   *   thickness: 2,\n   *   color: rgb(0.75, 0.2, 0.2),\n   *   opacity: 0.75,\n   * })\n   * ```\n   * @param options The options to be used when drawing the line.\n   */\n  drawLine(options: PDFPageDrawLineOptions): void {\n    assertIs(options.start, 'options.start', [\n      [Object, '{ x: number, y: number }'],\n    ]);\n    assertIs(options.end, 'options.end', [\n      [Object, '{ x: number, y: number }'],\n    ]);\n    assertIs(options.start.x, 'options.start.x', ['number']);\n    assertIs(options.start.y, 'options.start.y', ['number']);\n    assertIs(options.end.x, 'options.end.x', ['number']);\n    assertIs(options.end.y, 'options.end.y', ['number']);\n    assertOrUndefined(options.thickness, 'options.thickness', ['number']);\n    assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n    assertOrUndefined(options.dashArray, 'options.dashArray', [Array]);\n    assertOrUndefined(options.dashPhase, 'options.dashPhase', ['number']);\n    assertIsOneOfOrUndefined(options.lineCap, 'options.lineCap', LineCapStyle);\n    assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n    assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n    const graphicsStateKey = this.maybeEmbedGraphicsState({\n      borderOpacity: options.opacity,\n      blendMode: options.blendMode,\n    });\n\n    if (!('color' in options)) {\n      options.color = rgb(0, 0, 0);\n    }\n\n    const contentStream = this.getContentStream();\n    contentStream.push(\n      ...drawLine({\n        start: options.start,\n        end: options.end,\n        thickness: options.thickness ?? 1,\n        color: options.color ?? undefined,\n        dashArray: options.dashArray ?? undefined,\n        dashPhase: options.dashPhase ?? undefined,\n        lineCap: options.lineCap ?? undefined,\n        graphicsState: graphicsStateKey,\n      }),\n    );\n  }\n\n  /**\n   * Draw a rectangle on this page. For example:\n   * ```js\n   * import { degrees, grayscale, rgb } from 'pdf-lib'\n   *\n   * page.drawRectangle({\n   *   x: 25,\n   *   y: 75,\n   *   width: 250,\n   *   height: 75,\n   *   rotate: degrees(-15),\n   *   borderWidth: 5,\n   *   borderColor: grayscale(0.5),\n   *   color: rgb(0.75, 0.2, 0.2),\n   *   opacity: 0.5,\n   *   borderOpacity: 0.75,\n   * })\n   * ```\n   * @param options The options to be used when drawing the rectangle.\n   */\n  drawRectangle(options: PDFPageDrawRectangleOptions = {}): void {\n    assertOrUndefined(options.x, 'options.x', ['number']);\n    assertOrUndefined(options.y, 'options.y', ['number']);\n    assertOrUndefined(options.width, 'options.width', ['number']);\n    assertOrUndefined(options.height, 'options.height', ['number']);\n    assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n    assertOrUndefined(options.xSkew, 'options.xSkew', [[Object, 'Rotation']]);\n    assertOrUndefined(options.ySkew, 'options.ySkew', [[Object, 'Rotation']]);\n    assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);\n    assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n    assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n    assertOrUndefined(options.borderColor, 'options.borderColor', [\n      [Object, 'Color'],\n    ]);\n    assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [\n      Array,\n    ]);\n    assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [\n      'number',\n    ]);\n    assertIsOneOfOrUndefined(\n      options.borderLineCap,\n      'options.borderLineCap',\n      LineCapStyle,\n    );\n    assertRangeOrUndefined(\n      options.borderOpacity,\n      'options.borderOpacity',\n      0,\n      1,\n    );\n    assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n\n    const graphicsStateKey = this.maybeEmbedGraphicsState({\n      opacity: options.opacity,\n      borderOpacity: options.borderOpacity,\n      blendMode: options.blendMode,\n    });\n\n    if (!('color' in options) \u0026\u0026 !('borderColor' in options)) {\n      options.color = rgb(0, 0, 0);\n    }\n\n    const contentStream = this.getContentStream();\n    contentStream.push(\n      ...drawRectangle({\n        x: options.x ?? this.x,\n        y: options.y ?? this.y,\n        width: options.width ?? 150,\n        height: options.height ?? 100,\n        rotate: options.rotate ?? degrees(0),\n        xSkew: options.xSkew ?? degrees(0),\n        ySkew: options.ySkew ?? degrees(0),\n        borderWidth: options.borderWidth ?? 0,\n        color: options.color ?? undefined,\n        borderColor: options.borderColor ?? undefined,\n        borderDashArray: options.borderDashArray ?? undefined,\n        borderDashPhase: options.borderDashPhase ?? undefined,\n        graphicsState: graphicsStateKey,\n        borderLineCap: options.borderLineCap ?? undefined,\n      }),\n    );\n  }\n\n  /**\n   * Draw a square on this page. For example:\n   * ```js\n   * import { degrees, grayscale, rgb } from 'pdf-lib'\n   *\n   * page.drawSquare({\n   *   x: 25,\n   *   y: 75,\n   *   size: 100,\n   *   rotate: degrees(-15),\n   *   borderWidth: 5,\n   *   borderColor: grayscale(0.5),\n   *   color: rgb(0.75, 0.2, 0.2),\n   *   opacity: 0.5,\n   *   borderOpacity: 0.75,\n   * })\n   * ```\n   * @param options The options to be used when drawing the square.\n   */\n  drawSquare(options: PDFPageDrawSquareOptions = {}): void {\n    const { size } = options;\n    assertOrUndefined(size, 'size', ['number']);\n    this.drawRectangle({ ...options, width: size, height: size });\n  }\n\n  /**\n   * Draw an ellipse on this page. For example:\n   * ```js\n   * import { grayscale, rgb } from 'pdf-lib'\n   *\n   * page.drawEllipse({\n   *   x: 200,\n   *   y: 75,\n   *   xScale: 100,\n   *   yScale: 50,\n   *   borderWidth: 5,\n   *   borderColor: grayscale(0.5),\n   *   color: rgb(0.75, 0.2, 0.2),\n   *   opacity: 0.5,\n   *   borderOpacity: 0.75,\n   * })\n   * ```\n   * @param options The options to be used when drawing the ellipse.\n   */\n  drawEllipse(options: PDFPageDrawEllipseOptions = {}): void {\n    assertOrUndefined(options.x, 'options.x', ['number']);\n    assertOrUndefined(options.y, 'options.y', ['number']);\n    assertOrUndefined(options.xScale, 'options.xScale', ['number']);\n    assertOrUndefined(options.yScale, 'options.yScale', ['number']);\n    assertOrUndefined(options.rotate, 'options.rotate', [[Object, 'Rotation']]);\n    assertOrUndefined(options.color, 'options.color', [[Object, 'Color']]);\n    assertRangeOrUndefined(options.opacity, 'opacity.opacity', 0, 1);\n    assertOrUndefined(options.borderColor, 'options.borderColor', [\n      [Object, 'Color'],\n    ]);\n    assertRangeOrUndefined(\n      options.borderOpacity,\n      'options.borderOpacity',\n      0,\n      1,\n    );\n    assertOrUndefined(options.borderWidth, 'options.borderWidth', ['number']);\n    assertOrUndefined(options.borderDashArray, 'options.borderDashArray', [\n      Array,\n    ]);\n    assertOrUndefined(options.borderDashPhase, 'options.borderDashPhase', [\n      'number',\n    ]);\n    assertIsOneOfOrUndefined(\n      options.borderLineCap,\n      'options.borderLineCap',\n      LineCapStyle,\n    );\n    assertIsOneOfOrUndefined(options.blendMode, 'options.blendMode', BlendMode);\n    const graphicsStateKey = this.maybeEmbedGraphicsState({\n      opacity: options.opacity,\n      borderOpacity: options.borderOpacity,\n      blendMode: options.blendMode,\n    });\n\n    if (!('color' in options) \u0026\u0026 !('borderColor' in options)) {\n      options.color = rgb(0, 0, 0);\n    }\n\n    const contentStream = this.getContentStream();\n    contentStream.push(\n      ...drawEllipse({\n        x: options.x ?? this.x,\n        y: options.y ?? this.y,\n        xScale: options.xScale ?? 100,\n        yScale: options.yScale ?? 100,\n        rotate: options.rotate ?? undefined,\n        color: options.color ?? undefined,\n        borderColor: options.borderColor ?? undefined,\n        borderWidth: options.borderWidth ?? 0,\n        borderDashArray: options.borderDashArray ?? undefined,\n        borderDashPhase: options.borderDashPhase ?? undefined,\n        borderLineCap: options.borderLineCap ?? undefined,\n        graphicsState: graphicsStateKey,\n      }),\n    );\n  }\n\n  /**\n   * Draw a circle on this page. For example:\n   * ```js\n   * import { grayscale, rgb } from 'pdf-lib'\n   *\n   * page.drawCircle({\n   *   x: 200,\n   *   y: 150,\n   *   size: 100,\n   *   borderWidth: 5,\n   *   borderColor: grayscale(0.5),\n   *   color: rgb(0.75, 0.2, 0.2),\n   *   opacity: 0.5,\n   *   borderOpacity: 0.75,\n   * })\n   * ```\n   * @param options The options to be used when drawing the ellipse.\n   */\n  drawCircle(options: PDFPageDrawCircleOptions = {}): void {\n    const { size = 100 } = options;\n    assertOrUndefined(size, 'size', ['number']);\n    this.drawEllipse({ ...options, xScale: size, yScale: size });\n  }\n\n  private setOrEmbedFont(font?: PDFFont) {\n    const oldFont = this.font;\n    const oldFontKey = this.fontKey;\n\n    if (font) this.setFont(font);\n    else this.getFont();\n\n    const newFont = this.font!;\n    const newFontKey = this.fontKey!;\n\n    return { oldFont, oldFontKey, newFont, newFontKey };\n  }\n\n  private getFont(): [PDFFont, PDFName] {\n    if (!this.font || !this.fontKey) {\n      const font = this.doc.embedStandardFont(StandardFonts.Helvetica);\n      this.setFont(font);\n    }\n    return [this.font!, this.fontKey!];\n  }\n\n  private resetFont(): void {\n    this.font = undefined;\n    this.fontKey = undefined;\n  }\n\n  private getContentStream(useExisting = true): PDFContentStream {\n    if (useExisting \u0026\u0026 this.contentStream) return this.contentStream;\n    this.contentStream = this.createContentStream();\n    this.contentStreamRef = this.doc.context.register(this.contentStream);\n    this.node.addContentStream(this.contentStreamRef);\n    return this.contentStream;\n  }\n\n  private createContentStream(...operators: PDFOperator[]): PDFContentStream {\n    const dict = this.doc.context.obj({});\n    const contentStream = PDFContentStream.of(dict, operators);\n    return contentStream;\n  }\n\n  private maybeEmbedGraphicsState(options: {\n    opacity?: number;\n    borderOpacity?: number;\n    blendMode?: BlendMode;\n  }): PDFName | undefined {\n    const { opacity, borderOpacity, blendMode } = options;\n\n    if (\n      opacity === undefined \u0026\u0026\n      borderOpacity === undefined \u0026\u0026\n      blendMode === undefined\n    ) {\n      return undefined;\n    }\n\n    const graphicsState = this.doc.context.obj({\n      Type: 'ExtGState',\n      ca: opacity,\n      CA: borderOpacity,\n      BM: blendMode,\n    });\n\n    const key = this.node.newExtGState('GS', graphicsState);\n\n    return key;\n  }\n\n  private scaleAnnot(annot: PDFDict, x: number, y: number) {\n    const selectors = ['RD', 'CL', 'Vertices', 'QuadPoints', 'L', 'Rect'];\n    for (let idx = 0, len = selectors.length; idx \u003c len; idx++) {\n      const list = annot.lookup(PDFName.of(selectors[idx]));\n      if (list instanceof PDFArray) list.scalePDFNumbers(x, y);\n    }\n\n    const inkLists = annot.lookup(PDFName.of('InkList'));\n    if (inkLists instanceof PDFArray) {\n      for (let idx = 0, len = inkLists.size(); idx \u003c len; idx++) {\n        const arr = inkLists.lookup(idx);\n        if (arr instanceof PDFArray) arr.scalePDFNumbers(x, y);\n      }\n    }\n  }\n}\n","import PDFDocument from 'src/api/PDFDocument';\nimport PDFPage from 'src/api/PDFPage';\nimport PDFFont from 'src/api/PDFFont';\nimport PDFImage from 'src/api/PDFImage';\nimport { ImageAlignment } from 'src/api/image/alignment';\nimport {\n  AppearanceProviderFor,\n  normalizeAppearance,\n  defaultButtonAppearanceProvider,\n} from 'src/api/form/appearances';\nimport PDFField, {\n  FieldAppearanceOptions,\n  assertFieldAppearanceOptions,\n} from 'src/api/form/PDFField';\nimport { rgb } from 'src/api/colors';\nimport { degrees } from 'src/api/rotations';\n\nimport {\n  PDFRef,\n  PDFStream,\n  PDFAcroPushButton,\n  PDFWidgetAnnotation,\n} from 'src/core';\nimport { assertIs, assertOrUndefined, assertPositive } from 'src/utils';\n\n/**\n * Represents a button field of a [[PDFForm]].\n *\n * [[PDFButton]] fields are interactive controls that users can click with their\n * mouse. This type of [[PDFField]] is not stateful. The purpose of a button\n * is to perform an action when the user clicks on it, such as opening a print\n * modal or resetting the form. Buttons are typically rectangular in shape and\n * have a text label describing the action that they perform when clicked.\n */\nexport default class PDFButton extends PDFField {\n  /**\n   * \u003e **NOTE:** You probably don't want to call this method directly. Instead,\n   * \u003e consider using the [[PDFForm.getButton]] method, which will create an\n   * \u003e instance of [[PDFButton]] for you.\n   *\n   * Create an instance of [[PDFButton]] from an existing acroPushButton and ref\n   *\n   * @param acroPushButton The underlying `PDFAcroPushButton` for this button.\n   * @param ref The unique reference for this button.\n   * @param doc The document to which this button will belong.\n   */\n  static of = (\n    acroPushButton: PDFAcroPushButton,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) =\u003e new PDFButton(acroPushButton, ref, doc);\n\n  /** The low-level PDFAcroPushButton wrapped by this button. */\n  readonly acroField: PDFAcroPushButton;\n\n  private constructor(\n    acroPushButton: PDFAcroPushButton,\n    ref: PDFRef,\n    doc: PDFDocument,\n  ) {\n    super(acroPushButton, ref, doc);\n\n    assertIs(acroPushButton, 'acroButton', [\n      [PDFAcroPushButton, 'PDFAcroPushButton'],\n    ]);\n\n    this.acroField = acroPushButton;\n  }\n\n  /**\n   * Display an image inside the bounds of this button's widgets. For example:\n   * ```js\n   * const pngImage = await pdfDoc.embedPng(...)\n   * const button = form.getButton('some.button.field')\n   * button.setImage(pngImage, ImageAlignment.Center)\n   * ```\n   * This will update the appearances streams for each of this button's widgets.\n   * @param image The image that should be displayed.\n   * @param alignment The alignment of the image.\n   */\n  setImage(image: PDFImage, alignment = ImageAlignment.Center) {\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const streamRef = this.createImageAppearanceStream(\n        widget,\n        image,\n        alignment,\n      );\n      this.updateWidgetAppearances(widget, { normal: streamRef });\n    }\n\n    this.markAsClean();\n  }\n\n  /**\n   * Set the font size for this field. Larger font sizes will result in larger\n   * text being displayed when PDF readers render this button. Font sizes may\n   * be integer or floating point numbers. Supplying a negative font size will\n   * cause this method to throw an error.\n   *\n   * For example:\n   * ```js\n   * const button = form.getButton('some.button.field')\n   * button.setFontSize(4)\n   * button.setFontSize(15.7)\n   * ```\n   *\n   * \u003e This method depends upon the existence of a default appearance\n   * \u003e (`/DA`) string. If this field does not have a default appearance string,\n   * \u003e or that string does not contain a font size (via the `Tf` operator),\n   * \u003e then this method will throw an error.\n   *\n   * @param fontSize The font size to be used when rendering text in this field.\n   */\n  setFontSize(fontSize: number) {\n    assertPositive(fontSize, 'fontSize');\n    this.acroField.setFontSize(fontSize);\n    this.markAsDirty();\n  }\n\n  /**\n   * Show this button on the specified page with the given text. For example:\n   * ```js\n   * const ubuntuFont = await pdfDoc.embedFont(ubuntuFontBytes)\n   * const page = pdfDoc.addPage()\n   *\n   * const form = pdfDoc.getForm()\n   * const button = form.createButton('some.button.field')\n   *\n   * button.addToPage('Do Stuff', page, {\n   *   x: 50,\n   *   y: 75,\n   *   width: 200,\n   *   height: 100,\n   *   textColor: rgb(1, 0, 0),\n   *   backgroundColor: rgb(0, 1, 0),\n   *   borderColor: rgb(0, 0, 1),\n   *   borderWidth: 2,\n   *   rotate: degrees(90),\n   *   font: ubuntuFont,\n   * })\n   * ```\n   * This will create a new widget for this button field.\n   * @param text The text to be displayed for this button widget.\n   * @param page The page to which this button widget should be added.\n   * @param options The options to be used when adding this button widget.\n   */\n  addToPage(\n    // TODO: This needs to be optional, e.g. for image buttons\n    text: string,\n    page: PDFPage,\n    options?: FieldAppearanceOptions,\n  ) {\n    assertOrUndefined(text, 'text', ['string']);\n    assertOrUndefined(page, 'page', [[PDFPage, 'PDFPage']]);\n    assertFieldAppearanceOptions(options);\n\n    // Create a widget for this button\n    const widget = this.createWidget({\n      x: (options?.x ?? 0) - (options?.borderWidth ?? 0) / 2,\n      y: (options?.y ?? 0) - (options?.borderWidth ?? 0) / 2,\n      width: options?.width ?? 100,\n      height: options?.height ?? 50,\n      textColor: options?.textColor ?? rgb(0, 0, 0),\n      backgroundColor: options?.backgroundColor ?? rgb(0.75, 0.75, 0.75),\n      borderColor: options?.borderColor,\n      borderWidth: options?.borderWidth ?? 0,\n      rotate: options?.rotate ?? degrees(0),\n      caption: text,\n      hidden: options?.hidden,\n      page: page.ref,\n    });\n    const widgetRef = this.doc.context.register(widget.dict);\n\n    // Add widget to this field\n    this.acroField.addWidget(widgetRef);\n\n    // Set appearance streams for widget\n    const font = options?.font ?? this.doc.getForm().getDefaultFont();\n    this.updateWidgetAppearance(widget, font);\n\n    // Add widget to the given page\n    page.node.addAnnot(widgetRef);\n  }\n\n  /**\n   * Returns `true` if this button has been marked as dirty, or if any of this\n   * button's widgets do not have an appearance stream. For example:\n   * ```js\n   * const button = form.getButton('some.button.field')\n   * if (button.needsAppearancesUpdate()) console.log('Needs update')\n   * ```\n   * @returns Whether or not this button needs an appearance update.\n   */\n  needsAppearancesUpdate(): boolean {\n    if (this.isDirty()) return true;\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      const hasAppearances =\n        widget.getAppearances()?.normal instanceof PDFStream;\n      if (!hasAppearances) return true;\n    }\n\n    return false;\n  }\n\n  /**\n   * Update the appearance streams for each of this button's widgets using\n   * the default appearance provider for buttons. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const button = form.getButton('some.button.field')\n   * button.defaultUpdateAppearances(helvetica)\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   */\n  defaultUpdateAppearances(font: PDFFont) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    this.updateAppearances(font);\n  }\n\n  /**\n   * Update the appearance streams for each of this button's widgets using\n   * the given appearance provider. If no `provider` is passed, the default\n   * appearance provider for buttons will be used. For example:\n   * ```js\n   * const helvetica = await pdfDoc.embedFont(StandardFonts.Helvetica)\n   * const button = form.getButton('some.button.field')\n   * button.updateAppearances(helvetica, (field, widget, font) =\u003e {\n   *   ...\n   *   return {\n   *     normal: drawButton(...),\n   *     down: drawButton(...),\n   *   }\n   * })\n   * ```\n   * @param font The font to be used for creating the appearance streams.\n   * @param provider Optionally, the appearance provider to be used for\n   *                 generating the contents of the appearance streams.\n   */\n  updateAppearances(\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFButton\u003e,\n  ) {\n    assertIs(font, 'font', [[PDFFont, 'PDFFont']]);\n    assertOrUndefined(provider, 'provider', [Function]);\n\n    const widgets = this.acroField.getWidgets();\n    for (let idx = 0, len = widgets.length; idx \u003c len; idx++) {\n      const widget = widgets[idx];\n      this.updateWidgetAppearance(widget, font, provider);\n    }\n  }\n\n  private updateWidgetAppearance(\n    widget: PDFWidgetAnnotation,\n    font: PDFFont,\n    provider?: AppearanceProviderFor\u003cPDFButton\u003e,\n  ) {\n    const apProvider = provider ?? defaultButtonAppearanceProvider;\n    const appearances = normalizeAppearance(apProvider(this, widget, font));\n    this.updateWidgetAppearanceWithFont(widget, font, appearances);\n  }\n}\n"],"version":3}
