@embedpdf/snippet 2.0.0-next.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- import{a as e,P as t,p as n,i as r,u as o,b as a,c as i,d as s,e as u,f as m,g as F,h as l,j as d,k as _,l as P,w as c,m as g,n as h,q as D,r as b,o as p,t as f,v as A,x as E,y as M,R as y,A as G,z as S,B as C,C as T,D as x,E as v,N as O,F as k,T as w}from"./embedpdf-bc35fbd4.js";import{P as R,b as I}from"./browser-Cm3DA8l_-7a7c1b22.js";var j,B=(j=import.meta.url,async function(e={}){var t,n,r,o=e,a=new Promise((e,t)=>{n=e,r=t});["_EPDF_GetMetaKeyCount","_EPDF_GetMetaKeyName","_EPDF_GetMetaTrapped","_EPDF_GetPageRotationByIndex","_EPDF_HasMetaText","_EPDF_PNG_EncodeRGBA","_EPDF_RenderAnnotBitmap","_EPDF_SetMetaText","_EPDF_SetMetaTrapped","_EPDFAction_CreateGoTo","_EPDFAction_CreateGoToNamed","_EPDFAction_CreateLaunch","_EPDFAction_CreateRemoteGoToByName","_EPDFAction_CreateRemoteGoToDest","_EPDFAction_CreateURI","_EPDFAnnot_ClearColor","_EPDFAnnot_GenerateAppearance","_EPDFAnnot_GenerateAppearanceWithBlend","_EPDFAnnot_GetBlendMode","_EPDFAnnot_GetBorderDashPattern","_EPDFAnnot_GetBorderDashPatternCount","_EPDFAnnot_GetBorderEffect","_EPDFAnnot_GetBorderStyle","_EPDFAnnot_GetColor","_EPDFAnnot_GetDefaultAppearance","_EPDFAnnot_GetIcon","_EPDFAnnot_GetIntent","_EPDFAnnot_GetLineEndings","_EPDFAnnot_GetOpacity","_EPDFAnnot_GetRectangleDifferences","_EPDFAnnot_GetRichContent","_EPDFAnnot_GetTextAlignment","_EPDFAnnot_GetVerticalAlignment","_EPDFAnnot_SetBorderDashPattern","_EPDFAnnot_SetBorderStyle","_EPDFAnnot_SetColor","_EPDFAnnot_SetDefaultAppearance","_EPDFAnnot_SetIcon","_EPDFAnnot_SetIntent","_EPDFAnnot_SetLine","_EPDFAnnot_SetLineEndings","_EPDFAnnot_SetLinkedAnnot","_EPDFAnnot_SetOpacity","_EPDFAnnot_SetTextAlignment","_EPDFAnnot_SetVerticalAlignment","_EPDFAnnot_SetVertices","_EPDFAnnot_UpdateAppearanceToRect","_EPDFAttachment_GetDescription","_EPDFAttachment_GetIntegerValue","_EPDFAttachment_SetDescription","_EPDFAttachment_SetSubtype","_EPDFBookmark_AppendChild","_EPDFBookmark_Clear","_EPDFBookmark_ClearTarget","_EPDFBookmark_Create","_EPDFBookmark_Delete","_EPDFBookmark_InsertAfter","_EPDFBookmark_SetAction","_EPDFBookmark_SetDest","_EPDFBookmark_SetTitle","_EPDFCatalog_GetLanguage","_EPDFDest_CreateRemoteView","_EPDFDest_CreateRemoteXYZ","_EPDFDest_CreateView","_EPDFDest_CreateXYZ","_EPDFNamedDest_Remove","_EPDFNamedDest_SetDest","_EPDFPage_CreateAnnot","_EPDFPage_GetAnnotByName","_EPDFPage_GetAnnotCountRaw","_EPDFPage_GetAnnotRaw","_EPDFPage_RemoveAnnotByName","_EPDFPage_RemoveAnnotRaw","_EPDFText_RedactInQuads","_EPDFText_RedactInRect","_FORM_CanRedo","_FORM_CanUndo","_FORM_DoDocumentAAction","_FORM_DoDocumentJSAction","_FORM_DoDocumentOpenAction","_FORM_DoPageAAction","_FORM_ForceToKillFocus","_FORM_GetFocusedAnnot","_FORM_GetFocusedText","_FORM_GetSelectedText","_FORM_IsIndexSelected","_FORM_OnAfterLoadPage","_FORM_OnBeforeClosePage","_FORM_OnChar","_FORM_OnFocus","_FORM_OnKeyDown","_FORM_OnKeyUp","_FORM_OnLButtonDoubleClick","_FORM_OnLButtonDown","_FORM_OnLButtonUp","_FORM_OnMouseMove","_FORM_OnMouseWheel","_FORM_OnRButtonDown","_FORM_OnRButtonUp","_FORM_Redo","_FORM_ReplaceAndKeepSelection","_FORM_ReplaceSelection","_FORM_SelectAllText","_FORM_SetFocusedAnnot","_FORM_SetIndexSelected","_FORM_Undo","_FPDF_AddInstalledFont","_FPDF_CloseDocument","_FPDF_ClosePage","_FPDF_CloseXObject","_FPDF_CopyViewerPreferences","_FPDF_CountNamedDests","_FPDF_CreateClipPath","_FPDF_CreateNewDocument","_FPDF_DestroyClipPath","_FPDF_DestroyLibrary","_FPDF_DeviceToPage","_FPDF_DocumentHasValidCrossReferenceTable","_FPDF_FFLDraw","_FPDF_FreeDefaultSystemFontInfo","_FPDF_GetDefaultSystemFontInfo","_FPDF_GetDefaultTTFMap","_FPDF_GetDefaultTTFMapCount","_FPDF_GetDefaultTTFMapEntry","_FPDF_GetDocPermissions","_FPDF_GetDocUserPermissions","_FPDF_GetFileIdentifier","_FPDF_GetFileVersion","_FPDF_GetFormType","_FPDF_GetLastError","_FPDF_GetMetaText","_FPDF_GetNamedDest","_FPDF_GetNamedDestByName","_FPDF_GetPageAAction","_FPDF_GetPageBoundingBox","_FPDF_GetPageCount","_FPDF_GetPageHeight","_FPDF_GetPageHeightF","_FPDF_GetPageLabel","_FPDF_GetPageSizeByIndex","_FPDF_GetPageSizeByIndexF","_FPDF_GetPageWidth","_FPDF_GetPageWidthF","_FPDF_GetSecurityHandlerRevision","_FPDF_GetSignatureCount","_FPDF_GetSignatureObject","_FPDF_GetTrailerEnds","_FPDF_GetXFAPacketContent","_FPDF_GetXFAPacketCount","_FPDF_GetXFAPacketName","_FPDF_ImportNPagesToOne","_FPDF_ImportPages","_FPDF_ImportPagesByIndex","_FPDF_InitLibrary","_FPDF_InitLibraryWithConfig","_FPDF_LoadCustomDocument","_FPDF_LoadDocument","_FPDF_LoadMemDocument","_FPDF_LoadMemDocument64","_FPDF_LoadPage","_FPDF_LoadXFA","_FPDF_MovePages","_FPDF_NewFormObjectFromXObject","_FPDF_NewXObjectFromPage","_FPDF_PageToDevice","_FPDF_RemoveFormFieldHighlight","_FPDF_RenderPage_Close","_FPDF_RenderPage_Continue","_FPDF_RenderPageBitmap","_FPDF_RenderPageBitmap_Start","_FPDF_RenderPageBitmapWithColorScheme_Start","_FPDF_RenderPageBitmapWithMatrix","_FPDF_SaveAsCopy","_FPDF_SaveWithVersion","_FPDF_SetFormFieldHighlightAlpha","_FPDF_SetFormFieldHighlightColor","_FPDF_SetSandBoxPolicy","_FPDF_SetSystemFontInfo","_FPDF_StructElement_Attr_CountChildren","_FPDF_StructElement_Attr_GetBlobValue","_FPDF_StructElement_Attr_GetBooleanValue","_FPDF_StructElement_Attr_GetChildAtIndex","_FPDF_StructElement_Attr_GetCount","_FPDF_StructElement_Attr_GetName","_FPDF_StructElement_Attr_GetNumberValue","_FPDF_StructElement_Attr_GetStringValue","_FPDF_StructElement_Attr_GetType","_FPDF_StructElement_Attr_GetValue","_FPDF_StructElement_CountChildren","_FPDF_StructElement_GetActualText","_FPDF_StructElement_GetAltText","_FPDF_StructElement_GetAttributeAtIndex","_FPDF_StructElement_GetAttributeCount","_FPDF_StructElement_GetChildAtIndex","_FPDF_StructElement_GetChildMarkedContentID","_FPDF_StructElement_GetID","_FPDF_StructElement_GetLang","_FPDF_StructElement_GetMarkedContentID","_FPDF_StructElement_GetMarkedContentIdAtIndex","_FPDF_StructElement_GetMarkedContentIdCount","_FPDF_StructElement_GetObjType","_FPDF_StructElement_GetParent","_FPDF_StructElement_GetStringAttribute","_FPDF_StructElement_GetTitle","_FPDF_StructElement_GetType","_FPDF_StructTree_Close","_FPDF_StructTree_CountChildren","_FPDF_StructTree_GetChildAtIndex","_FPDF_StructTree_GetForPage","_FPDF_VIEWERREF_GetDuplex","_FPDF_VIEWERREF_GetName","_FPDF_VIEWERREF_GetNumCopies","_FPDF_VIEWERREF_GetPrintPageRange","_FPDF_VIEWERREF_GetPrintPageRangeCount","_FPDF_VIEWERREF_GetPrintPageRangeElement","_FPDF_VIEWERREF_GetPrintScaling","_FPDFAction_GetDest","_FPDFAction_GetFilePath","_FPDFAction_GetType","_FPDFAction_GetURIPath","_FPDFAnnot_AddFileAttachment","_FPDFAnnot_AddInkStroke","_FPDFAnnot_AppendAttachmentPoints","_FPDFAnnot_AppendObject","_FPDFAnnot_CountAttachmentPoints","_FPDFAnnot_GetAP","_FPDFAnnot_GetAttachmentPoints","_FPDFAnnot_GetBorder","_FPDFAnnot_GetColor","_FPDFAnnot_GetFileAttachment","_FPDFAnnot_GetFlags","_FPDFAnnot_GetFocusableSubtypes","_FPDFAnnot_GetFocusableSubtypesCount","_FPDFAnnot_GetFontColor","_FPDFAnnot_GetFontSize","_FPDFAnnot_GetFormAdditionalActionJavaScript","_FPDFAnnot_GetFormControlCount","_FPDFAnnot_GetFormControlIndex","_FPDFAnnot_GetFormFieldAlternateName","_FPDFAnnot_GetFormFieldAtPoint","_FPDFAnnot_GetFormFieldExportValue","_FPDFAnnot_GetFormFieldFlags","_FPDFAnnot_GetFormFieldName","_FPDFAnnot_GetFormFieldType","_FPDFAnnot_GetFormFieldValue","_FPDFAnnot_GetInkListCount","_FPDFAnnot_GetInkListPath","_FPDFAnnot_GetLine","_FPDFAnnot_GetLink","_FPDFAnnot_GetLinkedAnnot","_FPDFAnnot_GetNumberValue","_FPDFAnnot_GetObject","_FPDFAnnot_GetObjectCount","_FPDFAnnot_GetOptionCount","_FPDFAnnot_GetOptionLabel","_FPDFAnnot_GetRect","_FPDFAnnot_GetStringValue","_FPDFAnnot_GetSubtype","_FPDFAnnot_GetValueType","_FPDFAnnot_GetVertices","_FPDFAnnot_HasAttachmentPoints","_FPDFAnnot_HasKey","_FPDFAnnot_IsChecked","_FPDFAnnot_IsObjectSupportedSubtype","_FPDFAnnot_IsOptionSelected","_FPDFAnnot_IsSupportedSubtype","_FPDFAnnot_RemoveInkList","_FPDFAnnot_RemoveObject","_FPDFAnnot_SetAP","_FPDFAnnot_SetAttachmentPoints","_FPDFAnnot_SetBorder","_FPDFAnnot_SetColor","_FPDFAnnot_SetFlags","_FPDFAnnot_SetFocusableSubtypes","_FPDFAnnot_SetFontColor","_FPDFAnnot_SetFormFieldFlags","_FPDFAnnot_SetRect","_FPDFAnnot_SetStringValue","_FPDFAnnot_SetURI","_FPDFAnnot_UpdateObject","_FPDFAttachment_GetFile","_FPDFAttachment_GetName","_FPDFAttachment_GetStringValue","_FPDFAttachment_GetSubtype","_FPDFAttachment_GetValueType","_FPDFAttachment_HasKey","_FPDFAttachment_SetFile","_FPDFAttachment_SetStringValue","_FPDFAvail_Create","_FPDFAvail_Destroy","_FPDFAvail_GetDocument","_FPDFAvail_GetFirstPageNum","_FPDFAvail_IsDocAvail","_FPDFAvail_IsFormAvail","_FPDFAvail_IsLinearized","_FPDFAvail_IsPageAvail","_FPDFBitmap_Create","_FPDFBitmap_CreateEx","_FPDFBitmap_Destroy","_FPDFBitmap_FillRect","_FPDFBitmap_GetBuffer","_FPDFBitmap_GetFormat","_FPDFBitmap_GetHeight","_FPDFBitmap_GetStride","_FPDFBitmap_GetWidth","_FPDFBookmark_Find","_FPDFBookmark_GetAction","_FPDFBookmark_GetCount","_FPDFBookmark_GetDest","_FPDFBookmark_GetFirstChild","_FPDFBookmark_GetNextSibling","_FPDFBookmark_GetTitle","_FPDFCatalog_IsTagged","_FPDFCatalog_SetLanguage","_FPDFClipPath_CountPaths","_FPDFClipPath_CountPathSegments","_FPDFClipPath_GetPathSegment","_FPDFDest_GetDestPageIndex","_FPDFDest_GetLocationInPage","_FPDFDest_GetView","_FPDFDoc_AddAttachment","_FPDFDoc_CloseJavaScriptAction","_FPDFDoc_DeleteAttachment","_FPDFDOC_ExitFormFillEnvironment","_FPDFDoc_GetAttachment","_FPDFDoc_GetAttachmentCount","_FPDFDoc_GetJavaScriptAction","_FPDFDoc_GetJavaScriptActionCount","_FPDFDoc_GetPageMode","_FPDFDOC_InitFormFillEnvironment","_FPDFFont_Close","_FPDFFont_GetAscent","_FPDFFont_GetBaseFontName","_FPDFFont_GetDescent","_FPDFFont_GetFamilyName","_FPDFFont_GetFlags","_FPDFFont_GetFontData","_FPDFFont_GetGlyphPath","_FPDFFont_GetGlyphWidth","_FPDFFont_GetIsEmbedded","_FPDFFont_GetItalicAngle","_FPDFFont_GetWeight","_FPDFFormObj_CountObjects","_FPDFFormObj_GetObject","_FPDFFormObj_RemoveObject","_FPDFGlyphPath_CountGlyphSegments","_FPDFGlyphPath_GetGlyphPathSegment","_FPDFImageObj_GetBitmap","_FPDFImageObj_GetIccProfileDataDecoded","_FPDFImageObj_GetImageDataDecoded","_FPDFImageObj_GetImageDataRaw","_FPDFImageObj_GetImageFilter","_FPDFImageObj_GetImageFilterCount","_FPDFImageObj_GetImageMetadata","_FPDFImageObj_GetImagePixelSize","_FPDFImageObj_GetRenderedBitmap","_FPDFImageObj_LoadJpegFile","_FPDFImageObj_LoadJpegFileInline","_FPDFImageObj_SetBitmap","_FPDFImageObj_SetMatrix","_FPDFJavaScriptAction_GetName","_FPDFJavaScriptAction_GetScript","_FPDFLink_CloseWebLinks","_FPDFLink_CountQuadPoints","_FPDFLink_CountRects","_FPDFLink_CountWebLinks","_FPDFLink_Enumerate","_FPDFLink_GetAction","_FPDFLink_GetAnnot","_FPDFLink_GetAnnotRect","_FPDFLink_GetDest","_FPDFLink_GetLinkAtPoint","_FPDFLink_GetLinkZOrderAtPoint","_FPDFLink_GetQuadPoints","_FPDFLink_GetRect","_FPDFLink_GetTextRange","_FPDFLink_GetURL","_FPDFLink_LoadWebLinks","_FPDFPage_CloseAnnot","_FPDFPage_CountObjects","_FPDFPage_CreateAnnot","_FPDFPage_Delete","_FPDFPage_Flatten","_FPDFPage_FormFieldZOrderAtPoint","_FPDFPage_GenerateContent","_FPDFPage_GetAnnot","_FPDFPage_GetAnnotCount","_FPDFPage_GetAnnotIndex","_FPDFPage_GetArtBox","_FPDFPage_GetBleedBox","_FPDFPage_GetCropBox","_FPDFPage_GetDecodedThumbnailData","_FPDFPage_GetMediaBox","_FPDFPage_GetObject","_FPDFPage_GetRawThumbnailData","_FPDFPage_GetRotation","_FPDFPage_GetThumbnailAsBitmap","_FPDFPage_GetTrimBox","_FPDFPage_HasFormFieldAtPoint","_FPDFPage_HasTransparency","_FPDFPage_InsertClipPath","_FPDFPage_InsertObject","_FPDFPage_InsertObjectAtIndex","_FPDFPage_New","_FPDFPage_RemoveAnnot","_FPDFPage_RemoveObject","_FPDFPage_SetArtBox","_FPDFPage_SetBleedBox","_FPDFPage_SetCropBox","_FPDFPage_SetMediaBox","_FPDFPage_SetRotation","_FPDFPage_SetTrimBox","_FPDFPage_TransformAnnots","_FPDFPage_TransFormWithClip","_FPDFPageObj_AddMark","_FPDFPageObj_CountMarks","_FPDFPageObj_CreateNewPath","_FPDFPageObj_CreateNewRect","_FPDFPageObj_CreateTextObj","_FPDFPageObj_Destroy","_FPDFPageObj_GetBounds","_FPDFPageObj_GetClipPath","_FPDFPageObj_GetDashArray","_FPDFPageObj_GetDashCount","_FPDFPageObj_GetDashPhase","_FPDFPageObj_GetFillColor","_FPDFPageObj_GetIsActive","_FPDFPageObj_GetLineCap","_FPDFPageObj_GetLineJoin","_FPDFPageObj_GetMark","_FPDFPageObj_GetMarkedContentID","_FPDFPageObj_GetMatrix","_FPDFPageObj_GetRotatedBounds","_FPDFPageObj_GetStrokeColor","_FPDFPageObj_GetStrokeWidth","_FPDFPageObj_GetType","_FPDFPageObj_HasTransparency","_FPDFPageObj_NewImageObj","_FPDFPageObj_NewTextObj","_FPDFPageObj_RemoveMark","_FPDFPageObj_SetBlendMode","_FPDFPageObj_SetDashArray","_FPDFPageObj_SetDashPhase","_FPDFPageObj_SetFillColor","_FPDFPageObj_SetIsActive","_FPDFPageObj_SetLineCap","_FPDFPageObj_SetLineJoin","_FPDFPageObj_SetMatrix","_FPDFPageObj_SetStrokeColor","_FPDFPageObj_SetStrokeWidth","_FPDFPageObj_Transform","_FPDFPageObj_TransformClipPath","_FPDFPageObj_TransformF","_FPDFPageObjMark_CountParams","_FPDFPageObjMark_GetName","_FPDFPageObjMark_GetParamBlobValue","_FPDFPageObjMark_GetParamIntValue","_FPDFPageObjMark_GetParamKey","_FPDFPageObjMark_GetParamStringValue","_FPDFPageObjMark_GetParamValueType","_FPDFPageObjMark_RemoveParam","_FPDFPageObjMark_SetBlobParam","_FPDFPageObjMark_SetIntParam","_FPDFPageObjMark_SetStringParam","_FPDFPath_BezierTo","_FPDFPath_Close","_FPDFPath_CountSegments","_FPDFPath_GetDrawMode","_FPDFPath_GetPathSegment","_FPDFPath_LineTo","_FPDFPath_MoveTo","_FPDFPath_SetDrawMode","_FPDFPathSegment_GetClose","_FPDFPathSegment_GetPoint","_FPDFPathSegment_GetType","_FPDFSignatureObj_GetByteRange","_FPDFSignatureObj_GetContents","_FPDFSignatureObj_GetDocMDPPermission","_FPDFSignatureObj_GetReason","_FPDFSignatureObj_GetSubFilter","_FPDFSignatureObj_GetTime","_FPDFText_ClosePage","_FPDFText_CountChars","_FPDFText_CountRects","_FPDFText_FindClose","_FPDFText_FindNext","_FPDFText_FindPrev","_FPDFText_FindStart","_FPDFText_GetBoundedText","_FPDFText_GetCharAngle","_FPDFText_GetCharBox","_FPDFText_GetCharIndexAtPos","_FPDFText_GetCharIndexFromTextIndex","_FPDFText_GetCharOrigin","_FPDFText_GetFillColor","_FPDFText_GetFontInfo","_FPDFText_GetFontSize","_FPDFText_GetFontWeight","_FPDFText_GetLooseCharBox","_FPDFText_GetMatrix","_FPDFText_GetRect","_FPDFText_GetSchCount","_FPDFText_GetSchResultIndex","_FPDFText_GetStrokeColor","_FPDFText_GetText","_FPDFText_GetTextIndexFromCharIndex","_FPDFText_GetTextObject","_FPDFText_GetUnicode","_FPDFText_HasUnicodeMapError","_FPDFText_IsGenerated","_FPDFText_IsHyphen","_FPDFText_LoadCidType2Font","_FPDFText_LoadFont","_FPDFText_LoadPage","_FPDFText_LoadStandardFont","_FPDFText_SetCharcodes","_FPDFText_SetText","_FPDFTextObj_GetFont","_FPDFTextObj_GetFontSize","_FPDFTextObj_GetRenderedBitmap","_FPDFTextObj_GetText","_FPDFTextObj_GetTextRenderMode","_FPDFTextObj_SetTextRenderMode","_PDFiumExt_CloseFileWriter","_PDFiumExt_CloseFormFillInfo","_PDFiumExt_ExitFormFillEnvironment","_PDFiumExt_GetFileWriterData","_PDFiumExt_GetFileWriterSize","_PDFiumExt_Init","_PDFiumExt_InitFormFillEnvironment","_PDFiumExt_OpenFileWriter","_PDFiumExt_OpenFormFillInfo","_PDFiumExt_SaveAsCopy","_malloc","_free","_memory","___indirect_function_table","onRuntimeInitialized"].forEach(e=>{Object.getOwnPropertyDescriptor(a,e)||Object.defineProperty(a,e,{get:()=>$("You are getting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js"),set:()=>$("You are setting "+e+" on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js")})});var i="object"==typeof window,s="function"==typeof importScripts;"object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&process.type;var u,m,F=!i&&!s,l=Object.assign({},o),d="./this.program",_="";if(F){if("object"==typeof window||"function"==typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");m=e=>{if("function"==typeof readbuffer)return new Uint8Array(readbuffer(e));let t=read(e,"binary");return C("object"==typeof t),t},u=e=>new Promise((t,n)=>{setTimeout(()=>t(m(e)))}),globalThis.clearTimeout??=e=>{},globalThis.setTimeout??=e=>"function"==typeof e?e():$(),"undefined"!=typeof print&&(globalThis.console??={},console.log=print,console.warn=console.error=globalThis.printErr??print)}else{if(!i&&!s)throw new Error("environment detection error");if(s?_=self.location.href:"undefined"!=typeof document&&document.currentScript&&(_=document.currentScript.src),j&&(_=j),_=_.startsWith("blob:")?"":_.substr(0,_.replace(/[?#].*/,"").lastIndexOf("/")+1),"object"!=typeof window&&"function"!=typeof importScripts)throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");s&&(m=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),u=e=>(C(!J(e),"readAsync does not work with file:// URLs"),fetch(e,{credentials:"same-origin"}).then(e=>e.ok?e.arrayBuffer():Promise.reject(new Error(e.status+" : "+e.url))))}var P,c=o.print||console.log.bind(console),g=o.printErr||console.error.bind(console);Object.assign(o,l),l=null,P="fetchSettings",Object.getOwnPropertyDescriptor(o,P)&&$(`\`Module.${P}\` was supplied but \`${P}\` not included in INCOMING_MODULE_JS_API`),o.arguments&&o.arguments,te("arguments","arguments_"),o.thisProgram&&(d=o.thisProgram),te("thisProgram","thisProgram"),C(void 0===o.memoryInitializerPrefixURL,"Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),C(void 0===o.pthreadMainPrefixURL,"Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),C(void 0===o.cdInitializerPrefixURL,"Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),C(void 0===o.filePackagePrefixURL,"Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),C(void 0===o.read,"Module.read option was removed"),C(void 0===o.readAsync,"Module.readAsync option was removed (modify readAsync in JS)"),C(void 0===o.readBinary,"Module.readBinary option was removed (modify readBinary in JS)"),C(void 0===o.setWindowTitle,"Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),C(void 0===o.TOTAL_MEMORY,"Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),te("asm","wasmExports"),te("readAsync","readAsync"),te("readBinary","readBinary"),te("setWindowTitle","setWindowTitle");var h,D=o.wasmBinary;te("wasmBinary","wasmBinary"),"object"!=typeof WebAssembly&&g("no native wasm support detected");var b,p,f,A,E,M,y,G,S=!1;function C(e,t){e||$("Assertion failed"+(t?": "+t:""))}function T(){var e=h.buffer;o.HEAP8=b=new Int8Array(e),o.HEAP16=f=new Int16Array(e),o.HEAPU8=p=new Uint8Array(e),o.HEAPU16=A=new Uint16Array(e),o.HEAP32=E=new Int32Array(e),o.HEAPU32=M=new Uint32Array(e),o.HEAPF32=y=new Float32Array(e),o.HEAPF64=G=new Float64Array(e)}function x(){if(!S){var e=it();0==e&&(e+=4);var t=M[e>>2],n=M[e+4>>2];34821223==t&&2310721022==n||$(`Stack overflow! Stack cookie has been overwritten at ${se(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${se(n)} ${se(t)}`),1668509029!=M[0]&&$("Runtime error: The application has corrupted its heap memory area (address zero)!")}}C(!o.STACK_SIZE,"STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),C("undefined"!=typeof Int32Array&&"undefined"!=typeof Float64Array&&null!=Int32Array.prototype.subarray&&null!=Int32Array.prototype.set,"JS engine does not provide full typed array support"),C(!o.wasmMemory,"Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally"),C(!o.INITIAL_MEMORY,"Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically");var v=[],O=[],k=[],w=!1;function R(e){v.unshift(e)}function I(e){k.unshift(e)}C(Math.imul,"This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),C(Math.fround,"This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),C(Math.clz32,"This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill"),C(Math.trunc,"This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill");var B=0,L=null,N=null,V={};function U(e){for(var t=e;;){if(!V[e])return e;e=t+Math.random()}}function W(e){B++,o.monitorRunDependencies?.(B),e?(C(!V[e]),V[e]=1,null===L&&"undefined"!=typeof setInterval&&(L=setInterval(()=>{if(S)return clearInterval(L),void(L=null);var e=!1;for(var t in V)e||(e=!0,g("still waiting on run dependencies:")),g(`dependency: ${t}`);e&&g("(end of list)")},1e4))):g("warning: run dependency added without ID")}function z(e){if(B--,o.monitorRunDependencies?.(B),e?(C(V[e]),delete V[e]):g("warning: run dependency removed without ID"),0==B&&(null!==L&&(clearInterval(L),L=null),N)){var t=N;N=null,t()}}function $(e){o.onAbort?.(e),g(e="Aborted("+e+")"),S=!0;var t=new WebAssembly.RuntimeError(e);throw r(t),t}var H,K,X,Y=e=>e.startsWith("data:application/octet-stream;base64,"),J=e=>e.startsWith("file://");function q(e,t){return(...n)=>{C(w,`native function \`${e}\` called before runtime initialization`);var r=Qe[e];return C(r,`exported native function \`${e}\` not found`),C(n.length<=t,`native function \`${e}\` called with ${n.length} args but expects ${t}`),r(...n)}}function Q(){if(o.locateFile){var e="pdfium.wasm";return Y(e)?e:(t=e,o.locateFile?o.locateFile(t,_):_+t)}var t;return F?"pdfium.wasm":new URL("pdfium.wasm",import.meta.url).href}function Z(e){if(e==H&&D)return new Uint8Array(D);if(m)return m(e);throw"both async and sync fetching of the wasm failed"}function ee(e,t,n){return function(e){return D?Promise.resolve().then(()=>Z(e)):u(e).then(e=>new Uint8Array(e),()=>Z(e))}(e).then(e=>WebAssembly.instantiate(e,t)).then(n,e=>{g(`failed to asynchronously prepare wasm: ${e}`),J(H)&&g(`warning: Loading from a file URI (${H}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),$(e)})}if((()=>{var e=new Int16Array(1),t=new Int8Array(e.buffer);if(e[0]=25459,115!==t[0]||99!==t[1])throw"Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)"})(),o.ENVIRONMENT)throw new Error("Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)");function te(e,t,n=!0){Object.getOwnPropertyDescriptor(o,e)||Object.defineProperty(o,e,{configurable:!0,get(){$(`\`Module.${e}\` has been replaced by \`${t}\``+(n?" (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)":""))}})}function ne(e){return"FS_createPath"===e||"FS_createDataFile"===e||"FS_createPreloadedFile"===e||"FS_unlink"===e||"addRunDependency"===e||"FS_createLazyFile"===e||"FS_createDevice"===e||"removeRunDependency"===e}function re(e,t){"undefined"==typeof globalThis||Object.getOwnPropertyDescriptor(globalThis,e)||Object.defineProperty(globalThis,e,{configurable:!0,get(){t()}})}function oe(e,t){re(e,()=>{Fe(`\`${e}\` is not longer defined by emscripten. ${t}`)})}function ae(e){Object.getOwnPropertyDescriptor(o,e)||Object.defineProperty(o,e,{configurable:!0,get(){var t=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;ne(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),$(t)}})}oe("buffer","Please use HEAP8.buffer or wasmMemory.buffer"),oe("asm","Please use wasmExports instead");var ie=e=>{e.forEach(e=>e(o))};o.noExitRuntime;var se=e=>(C("number"==typeof e),"0x"+(e>>>=0).toString(16).padStart(8,"0")),ue=e=>st(e),me=()=>mt(),Fe=e=>{Fe.shown||={},Fe.shown[e]||(Fe.shown[e]=1,g(e))},le="undefined"!=typeof TextDecoder?new TextDecoder:void 0,de=(e,t=0,n=NaN)=>{for(var r=t+n,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.buffer&&le)return le.decode(e.subarray(t,o));for(var a="";t<o;){var i=e[t++];if(128&i){var s=63&e[t++];if(192!=(224&i)){var u=63&e[t++];if(224==(240&i)?i=(15&i)<<12|s<<6|u:(240!=(248&i)&&Fe("Invalid UTF-8 leading byte "+se(i)+" encountered when deserializing a UTF-8 string in wasm memory to a JS string!"),i=(7&i)<<18|s<<12|u<<6|63&e[t++]),i<65536)a+=String.fromCharCode(i);else{var m=i-65536;a+=String.fromCharCode(55296|m>>10,56320|1023&m)}}else a+=String.fromCharCode((31&i)<<6|s)}else a+=String.fromCharCode(i)}return a},_e=(e,t)=>(C("number"==typeof e,`UTF8ToString expects a number (got ${typeof e})`),e?de(p,e,t):"");function Pe(){C(null!=ke.varargs);var e=E[+ke.varargs>>2];return ke.varargs+=4,e}var ce=Pe,ge={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var n=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift("..");return e},normalize:e=>{var t=ge.isAbs(e),n="/"===e.substr(-1);return(e=ge.normalizeArray(e.split("/").filter(e=>!!e),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=ge.splitPath(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=ge.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:(...e)=>ge.normalize(e.join("/")),join2:(e,t)=>ge.normalize(e+"/"+t)},he=e=>(he=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);$("no cryptographic support found for randomDevice. consider polyfilling it if you want to use something insecure like Math.random(), e.g. put this in a --pre-js: var crypto = { getRandomValues: (array) => { for (var i = 0; i < array.length; i++) array[i] = (Math.random()*256)|0 } };")})())(e),De={resolve:(...e)=>{for(var t="",n=!1,r=e.length-1;r>=-1&&!n;r--){var o=r>=0?e[r]:Oe.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");if(!o)return"";t=o+"/"+t,n=ge.isAbs(o)}return(n?"/":"")+(t=ge.normalizeArray(t.split("/").filter(e=>!!e),!n).join("/"))||"."},relative:(e,t)=>{function n(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=De.resolve(e).substr(1),t=De.resolve(t).substr(1);for(var r=n(e.split("/")),o=n(t.split("/")),a=Math.min(r.length,o.length),i=a,s=0;s<a;s++)if(r[s]!==o[s]){i=s;break}var u=[];for(s=i;s<r.length;s++)u.push("..");return(u=u.concat(o.slice(i))).join("/")}},be=[],pe=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++n):t+=3}return t},fe=(e,t,n,r)=>{if(C("string"==typeof e,`stringToUTF8Array expects a string (got ${typeof e})`),!(r>0))return 0;for(var o=n,a=n+r-1,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;s>1114111&&Fe("Invalid Unicode code point "+se(s)+" encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF)."),t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}return t[n]=0,n-o};function Ae(e,t,n){var r=n>0?n:pe(e)+1,o=new Array(r),a=fe(e,o,0,o.length);return t&&(o.length=a),o}var Ee,Me,ye={ttys:[],init(){},shutdown(){},register(e,t){ye.ttys[e]={input:[],output:[],ops:t},Oe.registerDevice(e,ye.stream_ops)},stream_ops:{open(e){var t=ye.ttys[e.node.rdev];if(!t)throw new Oe.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,n,r,o){if(!e.tty||!e.tty.ops.get_char)throw new Oe.ErrnoError(60);for(var a=0,i=0;i<r;i++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(e){throw new Oe.ErrnoError(29)}if(void 0===s&&0===a)throw new Oe.ErrnoError(6);if(null==s)break;a++,t[n+i]=s}return a&&(e.node.timestamp=Date.now()),a},write(e,t,n,r,o){if(!e.tty||!e.tty.ops.put_char)throw new Oe.ErrnoError(60);try{for(var a=0;a<r;a++)e.tty.ops.put_char(e.tty,t[n+a])}catch(e){throw new Oe.ErrnoError(29)}return r&&(e.node.timestamp=Date.now()),a}},default_tty_ops:{get_char:e=>(()=>{if(!be.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&(e=readline())&&(e+="\n"),!e)return null;be=Ae(e,!0)}return be.shift()})(),put_char(e,t){null===t||10===t?(c(de(e.output)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(c(de(e.output)),e.output=[])},ioctl_tcgets:e=>({c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}),ioctl_tcsets:(e,t,n)=>0,ioctl_tiocgwinsz:e=>[24,80]},default_tty1_ops:{put_char(e,t){null===t||10===t?(g(de(e.output)),e.output=[]):0!=t&&e.output.push(t)},fsync(e){e.output&&e.output.length>0&&(g(de(e.output)),e.output=[])}}},Ge=(e,t)=>(C(t,"alignment argument is required"),Math.ceil(e/t)*t),Se=e=>{e=Ge(e,65536);var t=nt(65536,e);return t&&((e,t)=>{p.fill(0,e,e+t)})(t,e),t},Ce={ops_table:null,mount:e=>Ce.createNode(null,"/",16895,0),createNode(e,t,n,r){if(Oe.isBlkdev(n)||Oe.isFIFO(n))throw new Oe.ErrnoError(63);Ce.ops_table||={dir:{node:{getattr:Ce.node_ops.getattr,setattr:Ce.node_ops.setattr,lookup:Ce.node_ops.lookup,mknod:Ce.node_ops.mknod,rename:Ce.node_ops.rename,unlink:Ce.node_ops.unlink,rmdir:Ce.node_ops.rmdir,readdir:Ce.node_ops.readdir,symlink:Ce.node_ops.symlink},stream:{llseek:Ce.stream_ops.llseek}},file:{node:{getattr:Ce.node_ops.getattr,setattr:Ce.node_ops.setattr},stream:{llseek:Ce.stream_ops.llseek,read:Ce.stream_ops.read,write:Ce.stream_ops.write,allocate:Ce.stream_ops.allocate,mmap:Ce.stream_ops.mmap,msync:Ce.stream_ops.msync}},link:{node:{getattr:Ce.node_ops.getattr,setattr:Ce.node_ops.setattr,readlink:Ce.node_ops.readlink},stream:{}},chrdev:{node:{getattr:Ce.node_ops.getattr,setattr:Ce.node_ops.setattr},stream:Oe.chrdev_stream_ops}};var o=Oe.createNode(e,t,n,r);return Oe.isDir(o.mode)?(o.node_ops=Ce.ops_table.dir.node,o.stream_ops=Ce.ops_table.dir.stream,o.contents={}):Oe.isFile(o.mode)?(o.node_ops=Ce.ops_table.file.node,o.stream_ops=Ce.ops_table.file.stream,o.usedBytes=0,o.contents=null):Oe.isLink(o.mode)?(o.node_ops=Ce.ops_table.link.node,o.stream_ops=Ce.ops_table.link.stream):Oe.isChrdev(o.mode)&&(o.node_ops=Ce.ops_table.chrdev.node,o.stream_ops=Ce.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var n=e.contents?e.contents.length:0;if(!(n>=t)){t=Math.max(t,n*(n<1048576?2:1.125)>>>0),0!=n&&(t=Math.max(t,256));var r=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(r.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var n=e.contents;e.contents=new Uint8Array(t),n&&e.contents.set(n.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=Oe.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,Oe.isDir(e.mode)?t.size=4096:Oe.isFile(e.mode)?t.size=e.usedBytes:Oe.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&Ce.resizeFileStorage(e,t.size)},lookup(e,t){throw Oe.genericErrors[44]},mknod:(e,t,n,r)=>Ce.createNode(e,t,n,r),rename(e,t,n){if(Oe.isDir(e.mode)){var r;try{r=Oe.lookupNode(t,n)}catch(e){}if(r)for(var o in r.contents)throw new Oe.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=n,t.contents[n]=e,t.timestamp=e.parent.timestamp},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var n=Oe.lookupNode(e,t);for(var r in n.contents)throw new Oe.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var n of Object.keys(e.contents))t.push(n);return t},symlink(e,t,n){var r=Ce.createNode(e,t,41471,0);return r.link=n,r},readlink(e){if(!Oe.isLink(e.mode))throw new Oe.ErrnoError(28);return e.link}},stream_ops:{read(e,t,n,r,o){var a=e.node.contents;if(o>=e.node.usedBytes)return 0;var i=Math.min(e.node.usedBytes-o,r);if(C(i>=0),i>8&&a.subarray)t.set(a.subarray(o,o+i),n);else for(var s=0;s<i;s++)t[n+s]=a[o+s];return i},write(e,t,n,r,o,a){if(C(!(t instanceof ArrayBuffer)),t.buffer===b.buffer&&(a=!1),!r)return 0;var i=e.node;if(i.timestamp=Date.now(),t.subarray&&(!i.contents||i.contents.subarray)){if(a)return C(0===o,"canOwn must imply no weird position inside the file"),i.contents=t.subarray(n,n+r),i.usedBytes=r,r;if(0===i.usedBytes&&0===o)return i.contents=t.slice(n,n+r),i.usedBytes=r,r;if(o+r<=i.usedBytes)return i.contents.set(t.subarray(n,n+r),o),r}if(Ce.expandFileStorage(i,o+r),i.contents.subarray&&t.subarray)i.contents.set(t.subarray(n,n+r),o);else for(var s=0;s<r;s++)i.contents[o+s]=t[n+s];return i.usedBytes=Math.max(i.usedBytes,o+r),r},llseek(e,t,n){var r=t;if(1===n?r+=e.position:2===n&&Oe.isFile(e.node.mode)&&(r+=e.node.usedBytes),r<0)throw new Oe.ErrnoError(28);return r},allocate(e,t,n){Ce.expandFileStorage(e.node,t+n),e.node.usedBytes=Math.max(e.node.usedBytes,t+n)},mmap(e,t,n,r,o){if(!Oe.isFile(e.node.mode))throw new Oe.ErrnoError(43);var a,i,s=e.node.contents;if(2&o||!s||s.buffer!==b.buffer){if(i=!0,!(a=Se(t)))throw new Oe.ErrnoError(48);s&&((n>0||n+t<s.length)&&(s=s.subarray?s.subarray(n,n+t):Array.prototype.slice.call(s,n,n+t)),b.set(s,a))}else i=!1,a=s.byteOffset;return{ptr:a,allocated:i}},msync:(e,t,n,r,o)=>(Ce.stream_ops.write(e,t,0,r,n,!1),0)}},Te=o.preloadPlugins||[],xe=(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},ve={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},Oe={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class extends Error{constructor(e){for(var t in super(w?(e=>_e(rt(e)))(e):""),this.name="ErrnoError",this.errno=e,ve)if(ve[t]===e){this.code=t;break}}},genericErrors:{},filesystems:null,syncFSRequests:0,readFiles:{},FSStream:class{constructor(){this.shared={}}get object(){return this.node}set object(e){this.node=e}get isRead(){return 1!=(2097155&this.flags)}get isWrite(){return!!(2097155&this.flags)}get isAppend(){return 1024&this.flags}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{constructor(e,t,n,r){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=Oe.nextInode++,this.name=t,this.mode=n,this.node_ops={},this.stream_ops={},this.rdev=r,this.readMode=365,this.writeMode=146}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return Oe.isDir(this.mode)}get isDevice(){return Oe.isChrdev(this.mode)}},lookupPath(e,t={}){if(!(e=De.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new Oe.ErrnoError(32);for(var n=e.split("/").filter(e=>!!e),r=Oe.root,o="/",a=0;a<n.length;a++){var i=a===n.length-1;if(i&&t.parent)break;if(r=Oe.lookupNode(r,n[a]),o=ge.join2(o,n[a]),Oe.isMountpoint(r)&&(!i||i&&t.follow_mount)&&(r=r.mounted.root),!i||t.follow)for(var s=0;Oe.isLink(r.mode);){var u=Oe.readlink(o);if(o=De.resolve(ge.dirname(o),u),r=Oe.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new Oe.ErrnoError(32)}}return{path:o,node:r}},getPath(e){for(var t;;){if(Oe.isRoot(e)){var n=e.mount.mountpoint;return t?"/"!==n[n.length-1]?`${n}/${t}`:n+t:n}t=t?`${e.name}/${t}`:e.name,e=e.parent}},hashName(e,t){for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%Oe.nameTable.length},hashAddNode(e){var t=Oe.hashName(e.parent.id,e.name);e.name_next=Oe.nameTable[t],Oe.nameTable[t]=e},hashRemoveNode(e){var t=Oe.hashName(e.parent.id,e.name);if(Oe.nameTable[t]===e)Oe.nameTable[t]=e.name_next;else for(var n=Oe.nameTable[t];n;){if(n.name_next===e){n.name_next=e.name_next;break}n=n.name_next}},lookupNode(e,t){var n=Oe.mayLookup(e);if(n)throw new Oe.ErrnoError(n);for(var r=Oe.hashName(e.id,t),o=Oe.nameTable[r];o;o=o.name_next){var a=o.name;if(o.parent.id===e.id&&a===t)return o}return Oe.lookup(e,t)},createNode(e,t,n,r){C("object"==typeof e);var o=new Oe.FSNode(e,t,n,r);return Oe.hashAddNode(o),o},destroyNode(e){Oe.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>Oe.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup(e){if(!Oe.isDir(e.mode))return 54;var t=Oe.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate(e,t){try{return Oe.lookupNode(e,t),20}catch(e){}return Oe.nodePermissions(e,"wx")},mayDelete(e,t,n){var r;try{r=Oe.lookupNode(e,t)}catch(e){return e.errno}var o=Oe.nodePermissions(e,"wx");if(o)return o;if(n){if(!Oe.isDir(r.mode))return 54;if(Oe.isRoot(r)||Oe.getPath(r)===Oe.cwd())return 10}else if(Oe.isDir(r.mode))return 31;return 0},mayOpen:(e,t)=>e?Oe.isLink(e.mode)?32:Oe.isDir(e.mode)&&("r"!==Oe.flagsToPermissionString(t)||512&t)?31:Oe.nodePermissions(e,Oe.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=Oe.MAX_OPEN_FDS;e++)if(!Oe.streams[e])return e;throw new Oe.ErrnoError(33)},getStreamChecked(e){var t=Oe.getStream(e);if(!t)throw new Oe.ErrnoError(8);return t},getStream:e=>Oe.streams[e],createStream:(e,t=-1)=>(C(t>=-1),e=Object.assign(new Oe.FSStream,e),-1==t&&(t=Oe.nextfd()),e.fd=t,Oe.streams[t]=e,e),closeStream(e){Oe.streams[e]=null},dupStream(e,t=-1){var n=Oe.createStream(e,t);return n.stream_ops?.dup?.(n),n},chrdev_stream_ops:{open(e){var t=Oe.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new Oe.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice(e,t){Oe.devices[e]={stream_ops:t}},getDevice:e=>Oe.devices[e],getMounts(e){for(var t=[],n=[e];n.length;){var r=n.pop();t.push(r),n.push(...r.mounts)}return t},syncfs(e,t){"function"==typeof e&&(t=e,e=!1),Oe.syncFSRequests++,Oe.syncFSRequests>1&&g(`warning: ${Oe.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var n=Oe.getMounts(Oe.root.mount),r=0;function o(e){return C(Oe.syncFSRequests>0),Oe.syncFSRequests--,t(e)}function a(e){if(e)return a.errored?void 0:(a.errored=!0,o(e));++r>=n.length&&o(null)}n.forEach(t=>{if(!t.type.syncfs)return a(null);t.type.syncfs(t,e,a)})},mount(e,t,n){if("string"==typeof e)throw e;var r,o="/"===n,a=!n;if(o&&Oe.root)throw new Oe.ErrnoError(10);if(!o&&!a){var i=Oe.lookupPath(n,{follow_mount:!1});if(n=i.path,r=i.node,Oe.isMountpoint(r))throw new Oe.ErrnoError(10);if(!Oe.isDir(r.mode))throw new Oe.ErrnoError(54)}var s={type:e,opts:t,mountpoint:n,mounts:[]},u=e.mount(s);return u.mount=s,s.root=u,o?Oe.root=u:r&&(r.mounted=s,r.mount&&r.mount.mounts.push(s)),u},unmount(e){var t=Oe.lookupPath(e,{follow_mount:!1});if(!Oe.isMountpoint(t.node))throw new Oe.ErrnoError(28);var n=t.node,r=n.mounted,o=Oe.getMounts(r);Object.keys(Oe.nameTable).forEach(e=>{for(var t=Oe.nameTable[e];t;){var n=t.name_next;o.includes(t.mount)&&Oe.destroyNode(t),t=n}}),n.mounted=null;var a=n.mount.mounts.indexOf(r);C(-1!==a),n.mount.mounts.splice(a,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod(e,t,n){var r=Oe.lookupPath(e,{parent:!0}).node,o=ge.basename(e);if(!o||"."===o||".."===o)throw new Oe.ErrnoError(28);var a=Oe.mayCreate(r,o);if(a)throw new Oe.ErrnoError(a);if(!r.node_ops.mknod)throw new Oe.ErrnoError(63);return r.node_ops.mknod(r,o,t,n)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,Oe.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,Oe.mknod(e,t,0)),mkdirTree(e,t){for(var n=e.split("/"),r="",o=0;o<n.length;++o)if(n[o]){r+="/"+n[o];try{Oe.mkdir(r,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,t,n)=>(void 0===n&&(n=t,t=438),t|=8192,Oe.mknod(e,t,n)),symlink(e,t){if(!De.resolve(e))throw new Oe.ErrnoError(44);var n=Oe.lookupPath(t,{parent:!0}).node;if(!n)throw new Oe.ErrnoError(44);var r=ge.basename(t),o=Oe.mayCreate(n,r);if(o)throw new Oe.ErrnoError(o);if(!n.node_ops.symlink)throw new Oe.ErrnoError(63);return n.node_ops.symlink(n,r,e)},rename(e,t){var n,r,o=ge.dirname(e),a=ge.dirname(t),i=ge.basename(e),s=ge.basename(t);if(n=Oe.lookupPath(e,{parent:!0}).node,r=Oe.lookupPath(t,{parent:!0}).node,!n||!r)throw new Oe.ErrnoError(44);if(n.mount!==r.mount)throw new Oe.ErrnoError(75);var u,m=Oe.lookupNode(n,i),F=De.relative(e,a);if("."!==F.charAt(0))throw new Oe.ErrnoError(28);if("."!==(F=De.relative(t,o)).charAt(0))throw new Oe.ErrnoError(55);try{u=Oe.lookupNode(r,s)}catch(e){}if(m!==u){var l=Oe.isDir(m.mode),d=Oe.mayDelete(n,i,l);if(d)throw new Oe.ErrnoError(d);if(d=u?Oe.mayDelete(r,s,l):Oe.mayCreate(r,s))throw new Oe.ErrnoError(d);if(!n.node_ops.rename)throw new Oe.ErrnoError(63);if(Oe.isMountpoint(m)||u&&Oe.isMountpoint(u))throw new Oe.ErrnoError(10);if(r!==n&&(d=Oe.nodePermissions(n,"w")))throw new Oe.ErrnoError(d);Oe.hashRemoveNode(m);try{n.node_ops.rename(m,r,s),m.parent=r}catch(e){throw e}finally{Oe.hashAddNode(m)}}},rmdir(e){var t=Oe.lookupPath(e,{parent:!0}).node,n=ge.basename(e),r=Oe.lookupNode(t,n),o=Oe.mayDelete(t,n,!0);if(o)throw new Oe.ErrnoError(o);if(!t.node_ops.rmdir)throw new Oe.ErrnoError(63);if(Oe.isMountpoint(r))throw new Oe.ErrnoError(10);t.node_ops.rmdir(t,n),Oe.destroyNode(r)},readdir(e){var t=Oe.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new Oe.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var t=Oe.lookupPath(e,{parent:!0}).node;if(!t)throw new Oe.ErrnoError(44);var n=ge.basename(e),r=Oe.lookupNode(t,n),o=Oe.mayDelete(t,n,!1);if(o)throw new Oe.ErrnoError(o);if(!t.node_ops.unlink)throw new Oe.ErrnoError(63);if(Oe.isMountpoint(r))throw new Oe.ErrnoError(10);t.node_ops.unlink(t,n),Oe.destroyNode(r)},readlink(e){var t=Oe.lookupPath(e).node;if(!t)throw new Oe.ErrnoError(44);if(!t.node_ops.readlink)throw new Oe.ErrnoError(28);return De.resolve(Oe.getPath(t.parent),t.node_ops.readlink(t))},stat(e,t){var n=Oe.lookupPath(e,{follow:!t}).node;if(!n)throw new Oe.ErrnoError(44);if(!n.node_ops.getattr)throw new Oe.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>Oe.stat(e,!0),chmod(e,t,n){var r;if(!(r="string"==typeof e?Oe.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new Oe.ErrnoError(63);r.node_ops.setattr(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})},lchmod(e,t){Oe.chmod(e,t,!0)},fchmod(e,t){var n=Oe.getStreamChecked(e);Oe.chmod(n.node,t)},chown(e,t,n,r){var o;if(!(o="string"==typeof e?Oe.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new Oe.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown(e,t,n){Oe.chown(e,t,n,!0)},fchown(e,t,n){var r=Oe.getStreamChecked(e);Oe.chown(r.node,t,n)},truncate(e,t){if(t<0)throw new Oe.ErrnoError(28);var n;if(!(n="string"==typeof e?Oe.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new Oe.ErrnoError(63);if(Oe.isDir(n.mode))throw new Oe.ErrnoError(31);if(!Oe.isFile(n.mode))throw new Oe.ErrnoError(28);var r=Oe.nodePermissions(n,"w");if(r)throw new Oe.ErrnoError(r);n.node_ops.setattr(n,{size:t,timestamp:Date.now()})},ftruncate(e,t){var n=Oe.getStreamChecked(e);if(!(2097155&n.flags))throw new Oe.ErrnoError(28);Oe.truncate(n.node,t)},utime(e,t,n){var r=Oe.lookupPath(e,{follow:!0}).node;r.node_ops.setattr(r,{timestamp:Math.max(t,n)})},open(e,t,n){if(""===e)throw new Oe.ErrnoError(44);var r;if(n=64&(t="string"==typeof t?(e=>{var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error(`Unknown file open mode: ${e}`);return t})(t):t)?4095&(n=void 0===n?438:n)|32768:0,"object"==typeof e)r=e;else{e=ge.normalize(e);try{r=Oe.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var a=!1;if(64&t)if(r){if(128&t)throw new Oe.ErrnoError(20)}else r=Oe.mknod(e,n,0),a=!0;if(!r)throw new Oe.ErrnoError(44);if(Oe.isChrdev(r.mode)&&(t&=-513),65536&t&&!Oe.isDir(r.mode))throw new Oe.ErrnoError(54);if(!a){var i=Oe.mayOpen(r,t);if(i)throw new Oe.ErrnoError(i)}512&t&&!a&&Oe.truncate(r,0),t&=-131713;var s=Oe.createStream({node:r,path:Oe.getPath(r),flags:t,seekable:!0,position:0,stream_ops:r.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!o.logReadFiles||1&t||e in Oe.readFiles||(Oe.readFiles[e]=1),s},close(e){if(Oe.isClosed(e))throw new Oe.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Oe.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek(e,t,n){if(Oe.isClosed(e))throw new Oe.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Oe.ErrnoError(70);if(0!=n&&1!=n&&2!=n)throw new Oe.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,n),e.ungotten=[],e.position},read(e,t,n,r,o){if(C(n>=0),r<0||o<0)throw new Oe.ErrnoError(28);if(Oe.isClosed(e))throw new Oe.ErrnoError(8);if(1==(2097155&e.flags))throw new Oe.ErrnoError(8);if(Oe.isDir(e.node.mode))throw new Oe.ErrnoError(31);if(!e.stream_ops.read)throw new Oe.ErrnoError(28);var a=void 0!==o;if(a){if(!e.seekable)throw new Oe.ErrnoError(70)}else o=e.position;var i=e.stream_ops.read(e,t,n,r,o);return a||(e.position+=i),i},write(e,t,n,r,o,a){if(C(n>=0),r<0||o<0)throw new Oe.ErrnoError(28);if(Oe.isClosed(e))throw new Oe.ErrnoError(8);if(!(2097155&e.flags))throw new Oe.ErrnoError(8);if(Oe.isDir(e.node.mode))throw new Oe.ErrnoError(31);if(!e.stream_ops.write)throw new Oe.ErrnoError(28);e.seekable&&1024&e.flags&&Oe.llseek(e,0,2);var i=void 0!==o;if(i){if(!e.seekable)throw new Oe.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,t,n,r,o,a);return i||(e.position+=s),s},allocate(e,t,n){if(Oe.isClosed(e))throw new Oe.ErrnoError(8);if(t<0||n<=0)throw new Oe.ErrnoError(28);if(!(2097155&e.flags))throw new Oe.ErrnoError(8);if(!Oe.isFile(e.node.mode)&&!Oe.isDir(e.node.mode))throw new Oe.ErrnoError(43);if(!e.stream_ops.allocate)throw new Oe.ErrnoError(138);e.stream_ops.allocate(e,t,n)},mmap(e,t,n,r,o){if(2&r&&!(2&o)&&2!=(2097155&e.flags))throw new Oe.ErrnoError(2);if(1==(2097155&e.flags))throw new Oe.ErrnoError(2);if(!e.stream_ops.mmap)throw new Oe.ErrnoError(43);if(!t)throw new Oe.ErrnoError(28);return e.stream_ops.mmap(e,t,n,r,o)},msync:(e,t,n,r,o)=>(C(n>=0),e.stream_ops.msync?e.stream_ops.msync(e,t,n,r,o):0),ioctl(e,t,n){if(!e.stream_ops.ioctl)throw new Oe.ErrnoError(59);return e.stream_ops.ioctl(e,t,n)},readFile(e,t={}){if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error(`Invalid encoding type "${t.encoding}"`);var n,r=Oe.open(e,t.flags),o=Oe.stat(e).size,a=new Uint8Array(o);return Oe.read(r,a,0,o,0),"utf8"===t.encoding?n=de(a):"binary"===t.encoding&&(n=a),Oe.close(r),n},writeFile(e,t,n={}){n.flags=n.flags||577;var r=Oe.open(e,n.flags,n.mode);if("string"==typeof t){var o=new Uint8Array(pe(t)+1),a=fe(t,o,0,o.length);Oe.write(r,o,0,a,void 0,n.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");Oe.write(r,t,0,t.byteLength,void 0,n.canOwn)}Oe.close(r)},cwd:()=>Oe.currentPath,chdir(e){var t=Oe.lookupPath(e,{follow:!0});if(null===t.node)throw new Oe.ErrnoError(44);if(!Oe.isDir(t.node.mode))throw new Oe.ErrnoError(54);var n=Oe.nodePermissions(t.node,"x");if(n)throw new Oe.ErrnoError(n);Oe.currentPath=t.path},createDefaultDirectories(){Oe.mkdir("/tmp"),Oe.mkdir("/home"),Oe.mkdir("/home/web_user")},createDefaultDevices(){Oe.mkdir("/dev"),Oe.registerDevice(Oe.makedev(1,3),{read:()=>0,write:(e,t,n,r,o)=>r}),Oe.mkdev("/dev/null",Oe.makedev(1,3)),ye.register(Oe.makedev(5,0),ye.default_tty_ops),ye.register(Oe.makedev(6,0),ye.default_tty1_ops),Oe.mkdev("/dev/tty",Oe.makedev(5,0)),Oe.mkdev("/dev/tty1",Oe.makedev(6,0));var e=new Uint8Array(1024),t=0,n=()=>(0===t&&(t=he(e).byteLength),e[--t]);Oe.createDevice("/dev","random",n),Oe.createDevice("/dev","urandom",n),Oe.mkdir("/dev/shm"),Oe.mkdir("/dev/shm/tmp")},createSpecialDirectories(){Oe.mkdir("/proc");var e=Oe.mkdir("/proc/self");Oe.mkdir("/proc/self/fd"),Oe.mount({mount(){var t=Oe.createNode(e,"fd",16895,73);return t.node_ops={lookup(e,t){var n=+t,r=Oe.getStreamChecked(n),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams(e,t,n){e?Oe.createDevice("/dev","stdin",e):Oe.symlink("/dev/tty","/dev/stdin"),t?Oe.createDevice("/dev","stdout",null,t):Oe.symlink("/dev/tty","/dev/stdout"),n?Oe.createDevice("/dev","stderr",null,n):Oe.symlink("/dev/tty1","/dev/stderr");var r=Oe.open("/dev/stdin",0),o=Oe.open("/dev/stdout",1),a=Oe.open("/dev/stderr",1);C(0===r.fd,`invalid handle for stdin (${r.fd})`),C(1===o.fd,`invalid handle for stdout (${o.fd})`),C(2===a.fd,`invalid handle for stderr (${a.fd})`)},staticInit(){[44].forEach(e=>{Oe.genericErrors[e]=new Oe.ErrnoError(e),Oe.genericErrors[e].stack="<generic error, no stack>"}),Oe.nameTable=new Array(4096),Oe.mount(Ce,{},"/"),Oe.createDefaultDirectories(),Oe.createDefaultDevices(),Oe.createSpecialDirectories(),Oe.filesystems={MEMFS:Ce}},init(e,t,n){C(!Oe.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),Oe.initialized=!0,e??=o.stdin,t??=o.stdout,n??=o.stderr,Oe.createStandardStreams(e,t,n)},quit(){Oe.initialized=!1,tt(0);for(var e=0;e<Oe.streams.length;e++){var t=Oe.streams[e];t&&Oe.close(t)}},findObject(e,t){var n=Oe.analyzePath(e,t);return n.exists?n.object:null},analyzePath(e,t){try{e=(r=Oe.lookupPath(e,{follow:!t})).path}catch(e){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var r=Oe.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=r.path,n.parentObject=r.node,n.name=ge.basename(e),r=Oe.lookupPath(e,{follow:!t}),n.exists=!0,n.path=r.path,n.object=r.node,n.name=r.node.name,n.isRoot="/"===r.path}catch(e){n.error=e.errno}return n},createPath(e,t,n,r){e="string"==typeof e?e:Oe.getPath(e);for(var o=t.split("/").reverse();o.length;){var a=o.pop();if(a){var i=ge.join2(e,a);try{Oe.mkdir(i)}catch(e){}e=i}}return i},createFile(e,t,n,r,o){var a=ge.join2("string"==typeof e?e:Oe.getPath(e),t),i=xe(r,o);return Oe.create(a,i)},createDataFile(e,t,n,r,o,a){var i=t;e&&(e="string"==typeof e?e:Oe.getPath(e),i=t?ge.join2(e,t):e);var s=xe(r,o),u=Oe.create(i,s);if(n){if("string"==typeof n){for(var m=new Array(n.length),F=0,l=n.length;F<l;++F)m[F]=n.charCodeAt(F);n=m}Oe.chmod(u,146|s);var d=Oe.open(u,577);Oe.write(d,n,0,n.length,0,a),Oe.close(d),Oe.chmod(u,s)}},createDevice(e,t,n,r){var o=ge.join2("string"==typeof e?e:Oe.getPath(e),t),a=xe(!!n,!!r);Oe.createDevice.major??=64;var i=Oe.makedev(Oe.createDevice.major++,0);return Oe.registerDevice(i,{open(e){e.seekable=!1},close(e){r?.buffer?.length&&r(10)},read(e,t,r,o,a){for(var i=0,s=0;s<o;s++){var u;try{u=n()}catch(e){throw new Oe.ErrnoError(29)}if(void 0===u&&0===i)throw new Oe.ErrnoError(6);if(null==u)break;i++,t[r+s]=u}return i&&(e.node.timestamp=Date.now()),i},write(e,t,n,o,a){for(var i=0;i<o;i++)try{r(t[n+i])}catch(e){throw new Oe.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),i}}),Oe.mkdev(o,a,i)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");try{e.contents=m(e.url),e.usedBytes=e.contents.length}catch(e){throw new Oe.ErrnoError(29)}},createLazyFile(e,t,n,r,o){class a{constructor(){this.lengthKnown=!1,this.chunks=[]}get(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,n=e/this.chunkSize|0;return this.getter(n)[t]}}setDataGetter(e){this.getter=e}cacheLength(){var e=new XMLHttpRequest;if(e.open("HEAD",n,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+n+". Status: "+e.status);var t,r=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,a=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,i=1048576;o||(i=r);var s=this;s.setDataGetter(e=>{var t=e*i,o=(e+1)*i-1;if(o=Math.min(o,r-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>r-1)throw new Error("only "+r+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",n,!1),r!==i&&o.setRequestHeader("Range","bytes="+e+"-"+t),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+n+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):Ae(o.responseText||"",!0)})(t,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]}),!a&&r||(i=r=1,r=this.getter(0).length,i=r,c("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=r,this._chunkSize=i,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if("undefined"!=typeof XMLHttpRequest){if(!s)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var i={isDevice:!1,contents:new a}}else i={isDevice:!1,url:n};var u=Oe.createFile(e,t,i,r,o);i.contents?u.contents=i.contents:i.url&&(u.contents=null,u.url=i.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var m={};function F(e,t,n,r,o){var a=e.node.contents;if(o>=a.length)return 0;var i=Math.min(a.length-o,r);if(C(i>=0),a.slice)for(var s=0;s<i;s++)t[n+s]=a[o+s];else for(s=0;s<i;s++)t[n+s]=a.get(o+s);return i}return Object.keys(u.stream_ops).forEach(e=>{var t=u.stream_ops[e];m[e]=(...e)=>(Oe.forceLoadFile(u),t(...e))}),m.read=(e,t,n,r,o)=>(Oe.forceLoadFile(u),F(e,t,n,r,o)),m.mmap=(e,t,n,r,o)=>{Oe.forceLoadFile(u);var a=Se(t);if(!a)throw new Oe.ErrnoError(48);return F(e,b,a,t,n),{ptr:a,allocated:!0}},u.stream_ops=m,u},absolutePath(){$("FS.absolutePath has been removed; use PATH_FS.resolve instead")},createFolder(){$("FS.createFolder has been removed; use FS.mkdir instead")},createLink(){$("FS.createLink has been removed; use FS.symlink instead")},joinPath(){$("FS.joinPath has been removed; use PATH.join instead")},mmapAlloc(){$("FS.mmapAlloc has been replaced by the top level function mmapAlloc")},standardizePath(){$("FS.standardizePath has been removed; use PATH.normalize instead")}},ke={DEFAULT_POLLMASK:5,calculateAt(e,t,n){if(ge.isAbs(t))return t;var r;if(r=-100===e?Oe.cwd():ke.getStreamFromFD(e).path,0==t.length){if(!n)throw new Oe.ErrnoError(44);return r}return ge.join2(r,t)},doStat(e,t,n){var r=e(t);E[n>>2]=r.dev,E[n+4>>2]=r.mode,M[n+8>>2]=r.nlink,E[n+12>>2]=r.uid,E[n+16>>2]=r.gid,E[n+20>>2]=r.rdev,X=[r.size>>>0,(K=r.size,+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[n+24>>2]=X[0],E[n+28>>2]=X[1],E[n+32>>2]=4096,E[n+36>>2]=r.blocks;var o=r.atime.getTime(),a=r.mtime.getTime(),i=r.ctime.getTime();return X=[Math.floor(o/1e3)>>>0,(K=Math.floor(o/1e3),+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[n+40>>2]=X[0],E[n+44>>2]=X[1],M[n+48>>2]=o%1e3*1e3*1e3,X=[Math.floor(a/1e3)>>>0,(K=Math.floor(a/1e3),+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[n+56>>2]=X[0],E[n+60>>2]=X[1],M[n+64>>2]=a%1e3*1e3*1e3,X=[Math.floor(i/1e3)>>>0,(K=Math.floor(i/1e3),+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[n+72>>2]=X[0],E[n+76>>2]=X[1],M[n+80>>2]=i%1e3*1e3*1e3,X=[r.ino>>>0,(K=r.ino,+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[n+88>>2]=X[0],E[n+92>>2]=X[1],0},doMsync(e,t,n,r,o){if(!Oe.isFile(t.node.mode))throw new Oe.ErrnoError(43);if(2&r)return 0;var a=p.slice(e,e+n);Oe.msync(t,a,o,n,r)},getStreamFromFD:e=>Oe.getStreamChecked(e),varargs:void 0,getStr:e=>_e(e)},we=(e,t)=>(C(e==e>>>0||e==(0|e)),C(t===(0|t)),t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN),Re=(e,t,n)=>(C("number"==typeof n,"stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),fe(e,p,t,n)),Ie=[0,31,60,91,121,152,182,213,244,274,305,335],je=[0,31,59,90,120,151,181,212,243,273,304,334],Be=e=>{var t=h.buffer,n=(e-t.byteLength+65535)/65536|0;try{return h.grow(n),T(),1}catch(n){g(`growMemory: Attempted to grow heap from ${t.byteLength} bytes to ${e} bytes, but got error: ${n}`)}},Le={},Ne=()=>{if(!Ne.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:d||"./this.program"};for(var t in Le)void 0===Le[t]?delete e[t]:e[t]=Le[t];var n=[];for(var t in e)n.push(`${t}=${e[t]}`);Ne.strings=n}return Ne.strings},Ve=[],Ue=e=>{var t=Ve[e];return t||(e>=Ve.length&&(Ve.length=e+1),Ve[e]=t=Ee.get(e)),C(Ee.get(e)==t,"JavaScript-side Wasm function table mirror is out of date!"),t},We="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,ze=(e,t)=>{C(e<16384),e<128?t.push(e):t.push(e%128|128,e>>7)},$e=(e,t)=>{if(C(!t.includes("j"),"i64 not permitted in function signatures when WASM_BIGINT is disabled"),"function"==typeof WebAssembly.Function)return new WebAssembly.Function((e=>{C(!e.includes("j"),"i64 not permitted in function signatures when WASM_BIGINT is disabled");for(var t={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},n={parameters:[],results:"v"==e[0]?[]:[t[e[0]]]},r=1;r<e.length;++r)C(e[r]in t,"invalid signature char: "+e[r]),n.parameters.push(t[e[r]]);return n})(t),e);var n=[1];((e,t)=>{var n=e.slice(0,1),r=e.slice(1),o={i:127,p:127,j:126,f:125,d:124,e:111};t.push(96),ze(r.length,t);for(var a=0;a<r.length;++a)C(r[a]in o,"invalid signature char: "+r[a]),t.push(o[r[a]]);"v"==n?t.push(0):t.push(1,o[n])})(t,n);var r=[0,97,115,109,1,0,0,0,1];ze(n.length,r),r.push(...n),r.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var o=new WebAssembly.Module(new Uint8Array(r));return new WebAssembly.Instance(o,{e:{f:e}}).exports.f},He=e=>(Me||(Me=new WeakMap,((e,t)=>{if(Me)for(var n=e;n<e+t;n++){var r=Ue(n);r&&Me.set(r,n)}})(0,Ee.length)),Me.get(e)||0),Ke=[],Xe=(e,t)=>{Ee.set(e,t),Ve[e]=Ee.get(e)},Ye=e=>ut(e),Je=(e,t,n,r,a)=>{var i={string:e=>{var t=0;return null!=e&&0!==e&&(t=(e=>{var t=pe(e)+1,n=Ye(t);return Re(e,n,t),n})(e)),t},array:e=>{var t,n,r=Ye(e.length);return n=r,C((t=e).length>=0,"writeArrayToMemory array must have a length (should be an array or typed array)"),b.set(t,n),r}},s=(e=>{var t=o["_"+e];return C(t,"Cannot call unknown function "+e+", make sure it is exported"),t})(e),u=[],m=0;if(C("array"!==t,'Return type should not be "array".'),r)for(var F=0;F<r.length;F++){var l=i[n[F]];l?(0===m&&(m=me()),u[F]=l(r[F])):u[F]=r[F]}var d=s(...u);return d=function(e){return 0!==m&&ue(m),function(e){return"string"===t?_e(e):"boolean"===t?Boolean(e):e}(e)}(d)};Oe.createPreloadedFile=(e,t,n,r,o,a,i,s,m,F)=>{var l=t?De.resolve(ge.join2(e,t)):e,d=U(`cp ${l}`);function _(n){function u(n){F?.(),s||((e,t,n,r,o,a)=>{Oe.createDataFile(e,t,n,r,o,a)})(e,t,n,r,o,m),a?.(),z(d)}((e,t,n,r)=>{"undefined"!=typeof Browser&&Browser.init();var o=!1;return Te.forEach(a=>{o||a.canHandle(t)&&(a.handle(e,t,n,r),o=!0)}),o})(n,l,u,()=>{i?.(),z(d)})||u(n)}W(d),"string"==typeof n?((e,t,n,r)=>{var o=r?"":U(`al ${e}`);u(e).then(n=>{C(n,`Loading data file "${e}" failed (no arrayBuffer).`),t(new Uint8Array(n)),o&&z(o)},t=>{if(!n)throw`Loading data file "${e}" failed.`;n()}),o&&W(o)})(n,_,i):_(n)},Oe.staticInit();var qe={__assert_fail:(e,t,n,r)=>{$(`Assertion failed: ${_e(e)}, at: `+[t?_e(t):"unknown filename",n,r?_e(r):"unknown function"])},__syscall_fcntl64:function(e,t,n){ke.varargs=n;try{var r=ke.getStreamFromFD(e);switch(t){case 0:if((o=Pe())<0)return-28;for(;Oe.streams[o];)o++;return Oe.dupStream(r,o).fd;case 1:case 2:case 13:case 14:return 0;case 3:return r.flags;case 4:var o=Pe();return r.flags|=o,0;case 12:return o=ce(),f[o+0>>1]=2,0}return-28}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_fstat64:function(e,t){try{var n=ke.getStreamFromFD(e);return ke.doStat(Oe.stat,n.path,t)}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_ftruncate64:function(e,t,n){var r=we(t,n);try{return isNaN(r)?61:(Oe.ftruncate(e,r),0)}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_getdents64:function(e,t,n){try{var r=ke.getStreamFromFD(e);r.getdents||=Oe.readdir(r.path);for(var o=280,a=0,i=Oe.llseek(r,0,1),s=Math.floor(i/o);s<r.getdents.length&&a+o<=n;){var u,m,F=r.getdents[s];if("."===F)u=r.node.id,m=4;else if(".."===F)u=Oe.lookupPath(r.path,{parent:!0}).node.id,m=4;else{var l=Oe.lookupNode(r.node,F);u=l.id,m=Oe.isChrdev(l.mode)?2:Oe.isDir(l.mode)?4:Oe.isLink(l.mode)?10:8}C(u),X=[u>>>0,(K=u,+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[t+a>>2]=X[0],E[t+a+4>>2]=X[1],X=[(s+1)*o>>>0,(K=(s+1)*o,+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[t+a+8>>2]=X[0],E[t+a+12>>2]=X[1],f[t+a+16>>1]=280,b[t+a+18]=m,Re(F,t+a+19,256),a+=o,s+=1}return Oe.llseek(r,s*o,0),a}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_ioctl:function(e,t,n){ke.varargs=n;try{var r=ke.getStreamFromFD(e);switch(t){case 21509:case 21510:case 21511:case 21512:case 21524:case 21515:return r.tty?0:-59;case 21505:if(!r.tty)return-59;if(r.tty.ops.ioctl_tcgets){var o=r.tty.ops.ioctl_tcgets(r),a=ce();E[a>>2]=o.c_iflag||0,E[a+4>>2]=o.c_oflag||0,E[a+8>>2]=o.c_cflag||0,E[a+12>>2]=o.c_lflag||0;for(var i=0;i<32;i++)b[a+i+17]=o.c_cc[i]||0;return 0}return 0;case 21506:case 21507:case 21508:if(!r.tty)return-59;if(r.tty.ops.ioctl_tcsets){a=ce();var s=E[a>>2],u=E[a+4>>2],m=E[a+8>>2],F=E[a+12>>2],l=[];for(i=0;i<32;i++)l.push(b[a+i+17]);return r.tty.ops.ioctl_tcsets(r.tty,t,{c_iflag:s,c_oflag:u,c_cflag:m,c_lflag:F,c_cc:l})}return 0;case 21519:return r.tty?(a=ce(),E[a>>2]=0,0):-59;case 21520:return r.tty?-28:-59;case 21531:return a=ce(),Oe.ioctl(r,t,a);case 21523:if(!r.tty)return-59;if(r.tty.ops.ioctl_tiocgwinsz){var d=r.tty.ops.ioctl_tiocgwinsz(r.tty);a=ce(),f[a>>1]=d[0],f[a+2>>1]=d[1]}return 0;default:return-28}}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_lstat64:function(e,t){try{return e=ke.getStr(e),ke.doStat(Oe.lstat,e,t)}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_newfstatat:function(e,t,n,r){try{t=ke.getStr(t);var o=256&r,a=4096&r;return C(!(r&=-6401),`unknown flags in __syscall_newfstatat: ${r}`),t=ke.calculateAt(e,t,a),ke.doStat(o?Oe.lstat:Oe.stat,t,n)}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_openat:function(e,t,n,r){ke.varargs=r;try{t=ke.getStr(t),t=ke.calculateAt(e,t);var o=r?Pe():0;return Oe.open(t,n,o).fd}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_rmdir:function(e){try{return e=ke.getStr(e),Oe.rmdir(e),0}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_stat64:function(e,t){try{return e=ke.getStr(e),ke.doStat(Oe.stat,e,t)}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},__syscall_unlinkat:function(e,t,n){try{return t=ke.getStr(t),t=ke.calculateAt(e,t),0===n?Oe.unlink(t):512===n?Oe.rmdir(t):$("Invalid flags passed to unlinkat"),0}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return-e.errno}},_abort_js:()=>{$("native code called abort()")},_emscripten_memcpy_js:(e,t,n)=>p.copyWithin(e,t,t+n),_emscripten_throw_longjmp:()=>{throw 1/0},_gmtime_js:function(e,t,n){var r=we(e,t),o=new Date(1e3*r);E[n>>2]=o.getUTCSeconds(),E[n+4>>2]=o.getUTCMinutes(),E[n+8>>2]=o.getUTCHours(),E[n+12>>2]=o.getUTCDate(),E[n+16>>2]=o.getUTCMonth(),E[n+20>>2]=o.getUTCFullYear()-1900,E[n+24>>2]=o.getUTCDay();var a=Date.UTC(o.getUTCFullYear(),0,1,0,0,0,0),i=(o.getTime()-a)/864e5|0;E[n+28>>2]=i},_localtime_js:function(e,t,n){var r=we(e,t),o=new Date(1e3*r);E[n>>2]=o.getSeconds(),E[n+4>>2]=o.getMinutes(),E[n+8>>2]=o.getHours(),E[n+12>>2]=o.getDate(),E[n+16>>2]=o.getMonth(),E[n+20>>2]=o.getFullYear()-1900,E[n+24>>2]=o.getDay();var a=0|(e=>{var t;return((t=e.getFullYear())%4!=0||t%100==0&&t%400!=0?je:Ie)[e.getMonth()]+e.getDate()-1})(o);E[n+28>>2]=a,E[n+36>>2]=-60*o.getTimezoneOffset();var i=new Date(o.getFullYear(),0,1),s=new Date(o.getFullYear(),6,1).getTimezoneOffset(),u=i.getTimezoneOffset(),m=0|(s!=u&&o.getTimezoneOffset()==Math.min(u,s));E[n+32>>2]=m},_tzset_js:(e,t,n,r)=>{var o=(new Date).getFullYear(),a=new Date(o,0,1),i=new Date(o,6,1),s=a.getTimezoneOffset(),u=i.getTimezoneOffset(),m=Math.max(s,u);M[e>>2]=60*m,E[t>>2]=Number(s!=u);var F=e=>{var t=e>=0?"-":"+",n=Math.abs(e);return`UTC${t}${String(Math.floor(n/60)).padStart(2,"0")}${String(n%60).padStart(2,"0")}`},l=F(s),d=F(u);C(l),C(d),C(pe(l)<=16,`timezone name truncated to fit in TZNAME_MAX (${l})`),C(pe(d)<=16,`timezone name truncated to fit in TZNAME_MAX (${d})`),u<s?(Re(l,n,17),Re(d,r,17)):(Re(l,r,17),Re(d,n,17))},emscripten_date_now:()=>Date.now(),emscripten_resize_heap:e=>{var t=p.length;C((e>>>=0)>t);var n=2147483648;if(e>n)return g(`Cannot enlarge memory, requested ${e} bytes, but the limit is 2147483648 bytes!`),!1;for(var r=1;r<=4;r*=2){var o=t*(1+.2/r);o=Math.min(o,e+100663296);var a=Math.min(n,Ge(Math.max(e,o),65536));if(Be(a))return!0}return g(`Failed to grow the heap from ${t} bytes to ${a} bytes, not enough memory!`),!1},environ_get:(e,t)=>{var n=0;return Ne().forEach((r,o)=>{var a=t+n;M[e+4*o>>2]=a,((e,t)=>{for(var n=0;n<e.length;++n)C(e.charCodeAt(n)===(255&e.charCodeAt(n))),b[t++]=e.charCodeAt(n);b[t]=0})(r,a),n+=r.length+1}),0},environ_sizes_get:(e,t)=>{var n=Ne();M[e>>2]=n.length;var r=0;return n.forEach(e=>r+=e.length+1),M[t>>2]=r,0},fd_close:function(e){try{var t=ke.getStreamFromFD(e);return Oe.close(t),0}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return e.errno}},fd_read:function(e,t,n,r){try{var o=((e,t,n,r)=>{for(var o=0,a=0;a<n;a++){var i=M[t>>2],s=M[t+4>>2];t+=8;var u=Oe.read(e,b,i,s,r);if(u<0)return-1;if(o+=u,u<s)break;void 0!==r&&(r+=u)}return o})(ke.getStreamFromFD(e),t,n);return M[r>>2]=o,0}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return e.errno}},fd_seek:function(e,t,n,r,o){var a=we(t,n);try{if(isNaN(a))return 61;var i=ke.getStreamFromFD(e);return Oe.llseek(i,a,r),X=[i.position>>>0,(K=i.position,+Math.abs(K)>=1?K>0?+Math.floor(K/4294967296)>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],E[o>>2]=X[0],E[o+4>>2]=X[1],i.getdents&&0===a&&0===r&&(i.getdents=null),0}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return e.errno}},fd_sync:function(e){try{var t=ke.getStreamFromFD(e);return t.stream_ops?.fsync?t.stream_ops.fsync(t):0}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return e.errno}},fd_write:function(e,t,n,r){try{var o=((e,t,n,r)=>{for(var o=0,a=0;a<n;a++){var i=M[t>>2],s=M[t+4>>2];t+=8;var u=Oe.write(e,b,i,s,r);if(u<0)return-1;if(o+=u,u<s)break;void 0!==r&&(r+=u)}return o})(ke.getStreamFromFD(e),t,n);return M[r>>2]=o,0}catch(e){if(void 0===Oe||"ErrnoError"!==e.name)throw e;return e.errno}},invoke_ii:function(e,t){var n=me();try{return Ue(e)(t)}catch(e){if(ue(n),e!==e+0)throw e;ot(1,0)}},invoke_iii:function(e,t,n){var r=me();try{return Ue(e)(t,n)}catch(e){if(ue(r),e!==e+0)throw e;ot(1,0)}},invoke_iiii:function(e,t,n,r){var o=me();try{return Ue(e)(t,n,r)}catch(e){if(ue(o),e!==e+0)throw e;ot(1,0)}},invoke_iiiii:function(e,t,n,r,o){var a=me();try{return Ue(e)(t,n,r,o)}catch(e){if(ue(a),e!==e+0)throw e;ot(1,0)}},invoke_v:function(e){var t=me();try{Ue(e)()}catch(e){if(ue(t),e!==e+0)throw e;ot(1,0)}},invoke_vii:function(e,t,n){var r=me();try{Ue(e)(t,n)}catch(e){if(ue(r),e!==e+0)throw e;ot(1,0)}},invoke_viii:function(e,t,n,r){var o=me();try{Ue(e)(t,n,r)}catch(e){if(ue(o),e!==e+0)throw e;ot(1,0)}},invoke_viiii:function(e,t,n,r,o){var a=me();try{Ue(e)(t,n,r,o)}catch(e){if(ue(a),e!==e+0)throw e;ot(1,0)}},invoke_viiiiiiiii:function(e,t,n,r,o,a,i,s,u,m){var F=me();try{Ue(e)(t,n,r,o,a,i,s,u,m)}catch(e){if(ue(F),e!==e+0)throw e;ot(1,0)}}},Qe=function(){var e={env:qe,wasi_snapshot_preview1:qe};function t(e,t){var n;return Qe=e.exports,o.wasmExports=Qe,C(h=Qe.memory,"memory not found in wasm exports"),T(),C(Ee=Qe.__indirect_function_table,"table not found in wasm exports"),n=Qe.__wasm_call_ctors,O.unshift(n),z("wasm-instantiate"),Qe}W("wasm-instantiate");var n,a,i,s,u=o;if(o.instantiateWasm)try{return o.instantiateWasm(e,t)}catch(e){g(`Module.instantiateWasm callback failed with error: ${e}`),r(e)}return H??=Q(),(n=D,a=H,i=e,s=function(e){C(o===u,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),u=null,t(e.instance)},n||"function"!=typeof WebAssembly.instantiateStreaming||Y(a)||"function"!=typeof fetch?ee(a,i,s):fetch(a,{credentials:"same-origin"}).then(e=>WebAssembly.instantiateStreaming(e,i).then(s,function(e){return g(`wasm streaming compile failed: ${e}`),g("falling back to ArrayBuffer instantiation"),ee(a,i,s)}))).catch(r),{}}();o._PDFiumExt_Init=q("PDFiumExt_Init",0),o._FPDF_InitLibraryWithConfig=q("FPDF_InitLibraryWithConfig",1),o._PDFiumExt_OpenFileWriter=q("PDFiumExt_OpenFileWriter",0),o._PDFiumExt_GetFileWriterSize=q("PDFiumExt_GetFileWriterSize",1),o._PDFiumExt_GetFileWriterData=q("PDFiumExt_GetFileWriterData",3),o._PDFiumExt_CloseFileWriter=q("PDFiumExt_CloseFileWriter",1),o._PDFiumExt_SaveAsCopy=q("PDFiumExt_SaveAsCopy",2),o._FPDF_SaveAsCopy=q("FPDF_SaveAsCopy",3),o._PDFiumExt_OpenFormFillInfo=q("PDFiumExt_OpenFormFillInfo",0),o._PDFiumExt_CloseFormFillInfo=q("PDFiumExt_CloseFormFillInfo",1),o._PDFiumExt_InitFormFillEnvironment=q("PDFiumExt_InitFormFillEnvironment",2),o._FPDFDOC_InitFormFillEnvironment=q("FPDFDOC_InitFormFillEnvironment",2),o._PDFiumExt_ExitFormFillEnvironment=q("PDFiumExt_ExitFormFillEnvironment",1),o._FPDFDOC_ExitFormFillEnvironment=q("FPDFDOC_ExitFormFillEnvironment",1),o._EPDFNamedDest_SetDest=q("EPDFNamedDest_SetDest",3),o._EPDFNamedDest_Remove=q("EPDFNamedDest_Remove",2),o._EPDFDest_CreateView=q("EPDFDest_CreateView",4),o._EPDFDest_CreateXYZ=q("EPDFDest_CreateXYZ",7),o._EPDFDest_CreateRemoteView=q("EPDFDest_CreateRemoteView",5),o._EPDFDest_CreateRemoteXYZ=q("EPDFDest_CreateRemoteXYZ",8),o._EPDFAction_CreateGoTo=q("EPDFAction_CreateGoTo",2),o._EPDFAction_CreateGoToNamed=q("EPDFAction_CreateGoToNamed",2),o._EPDFAction_CreateLaunch=q("EPDFAction_CreateLaunch",2),o._EPDFAction_CreateRemoteGoToByName=q("EPDFAction_CreateRemoteGoToByName",3),o._EPDFAction_CreateRemoteGoToDest=q("EPDFAction_CreateRemoteGoToDest",3),o._EPDFAction_CreateURI=q("EPDFAction_CreateURI",2),o._EPDFBookmark_Create=q("EPDFBookmark_Create",2),o._EPDFBookmark_Delete=q("EPDFBookmark_Delete",2),o._EPDFBookmark_AppendChild=q("EPDFBookmark_AppendChild",3),o._EPDFBookmark_InsertAfter=q("EPDFBookmark_InsertAfter",4),o._EPDFBookmark_Clear=q("EPDFBookmark_Clear",1),o._EPDFBookmark_SetTitle=q("EPDFBookmark_SetTitle",2),o._EPDFBookmark_SetDest=q("EPDFBookmark_SetDest",3),o._EPDFBookmark_SetAction=q("EPDFBookmark_SetAction",3),o._EPDFBookmark_ClearTarget=q("EPDFBookmark_ClearTarget",1),o._EPDF_PNG_EncodeRGBA=q("EPDF_PNG_EncodeRGBA",6),o._FPDFAnnot_IsSupportedSubtype=q("FPDFAnnot_IsSupportedSubtype",1),o._FPDFPage_CreateAnnot=q("FPDFPage_CreateAnnot",2),o._FPDFPage_GetAnnotCount=q("FPDFPage_GetAnnotCount",1),o._FPDFPage_GetAnnot=q("FPDFPage_GetAnnot",2),o._FPDFPage_GetAnnotIndex=q("FPDFPage_GetAnnotIndex",2),o._FPDFPage_CloseAnnot=q("FPDFPage_CloseAnnot",1),o._FPDFPage_RemoveAnnot=q("FPDFPage_RemoveAnnot",2),o._FPDFAnnot_GetSubtype=q("FPDFAnnot_GetSubtype",1),o._FPDFAnnot_IsObjectSupportedSubtype=q("FPDFAnnot_IsObjectSupportedSubtype",1),o._FPDFAnnot_UpdateObject=q("FPDFAnnot_UpdateObject",2),o._FPDFAnnot_AddInkStroke=q("FPDFAnnot_AddInkStroke",3),o._FPDFAnnot_RemoveInkList=q("FPDFAnnot_RemoveInkList",1),o._FPDFAnnot_AppendObject=q("FPDFAnnot_AppendObject",2),o._FPDFAnnot_GetObjectCount=q("FPDFAnnot_GetObjectCount",1),o._FPDFAnnot_GetObject=q("FPDFAnnot_GetObject",2),o._FPDFAnnot_RemoveObject=q("FPDFAnnot_RemoveObject",2),o._FPDFAnnot_SetColor=q("FPDFAnnot_SetColor",6),o._FPDFAnnot_GetColor=q("FPDFAnnot_GetColor",6),o._FPDFAnnot_HasAttachmentPoints=q("FPDFAnnot_HasAttachmentPoints",1),o._FPDFAnnot_SetAttachmentPoints=q("FPDFAnnot_SetAttachmentPoints",3),o._FPDFAnnot_AppendAttachmentPoints=q("FPDFAnnot_AppendAttachmentPoints",2),o._FPDFAnnot_CountAttachmentPoints=q("FPDFAnnot_CountAttachmentPoints",1),o._FPDFAnnot_GetAttachmentPoints=q("FPDFAnnot_GetAttachmentPoints",3),o._FPDFAnnot_SetRect=q("FPDFAnnot_SetRect",2),o._FPDFAnnot_GetRect=q("FPDFAnnot_GetRect",2),o._FPDFAnnot_GetVertices=q("FPDFAnnot_GetVertices",3),o._FPDFAnnot_GetInkListCount=q("FPDFAnnot_GetInkListCount",1),o._FPDFAnnot_GetInkListPath=q("FPDFAnnot_GetInkListPath",4),o._FPDFAnnot_GetLine=q("FPDFAnnot_GetLine",3),o._FPDFAnnot_SetBorder=q("FPDFAnnot_SetBorder",4),o._FPDFAnnot_GetBorder=q("FPDFAnnot_GetBorder",4),o._FPDFAnnot_HasKey=q("FPDFAnnot_HasKey",2),o._FPDFAnnot_GetValueType=q("FPDFAnnot_GetValueType",2),o._FPDFAnnot_SetStringValue=q("FPDFAnnot_SetStringValue",3),o._FPDFAnnot_GetStringValue=q("FPDFAnnot_GetStringValue",4),o._FPDFAnnot_GetNumberValue=q("FPDFAnnot_GetNumberValue",3),o._FPDFAnnot_SetAP=q("FPDFAnnot_SetAP",3),o._FPDFAnnot_GetAP=q("FPDFAnnot_GetAP",4),o._FPDFAnnot_GetLinkedAnnot=q("FPDFAnnot_GetLinkedAnnot",2),o._FPDFAnnot_GetFlags=q("FPDFAnnot_GetFlags",1),o._FPDFAnnot_SetFlags=q("FPDFAnnot_SetFlags",2),o._FPDFAnnot_GetFormFieldFlags=q("FPDFAnnot_GetFormFieldFlags",2),o._FPDFAnnot_SetFormFieldFlags=q("FPDFAnnot_SetFormFieldFlags",3),o._FPDFAnnot_GetFormFieldAtPoint=q("FPDFAnnot_GetFormFieldAtPoint",3),o._FPDFAnnot_GetFormFieldName=q("FPDFAnnot_GetFormFieldName",4),o._FPDFAnnot_GetFormFieldType=q("FPDFAnnot_GetFormFieldType",2),o._FPDFAnnot_GetFormAdditionalActionJavaScript=q("FPDFAnnot_GetFormAdditionalActionJavaScript",5),o._FPDFAnnot_GetFormFieldAlternateName=q("FPDFAnnot_GetFormFieldAlternateName",4),o._FPDFAnnot_GetFormFieldValue=q("FPDFAnnot_GetFormFieldValue",4),o._FPDFAnnot_GetOptionCount=q("FPDFAnnot_GetOptionCount",2),o._FPDFAnnot_GetOptionLabel=q("FPDFAnnot_GetOptionLabel",5),o._FPDFAnnot_IsOptionSelected=q("FPDFAnnot_IsOptionSelected",3),o._FPDFAnnot_GetFontSize=q("FPDFAnnot_GetFontSize",3),o._FPDFAnnot_SetFontColor=q("FPDFAnnot_SetFontColor",5),o._FPDFAnnot_GetFontColor=q("FPDFAnnot_GetFontColor",5),o._FPDFAnnot_IsChecked=q("FPDFAnnot_IsChecked",2),o._FPDFAnnot_SetFocusableSubtypes=q("FPDFAnnot_SetFocusableSubtypes",3),o._FPDFAnnot_GetFocusableSubtypesCount=q("FPDFAnnot_GetFocusableSubtypesCount",1),o._FPDFAnnot_GetFocusableSubtypes=q("FPDFAnnot_GetFocusableSubtypes",3),o._FPDFAnnot_GetLink=q("FPDFAnnot_GetLink",1),o._FPDFAnnot_GetFormControlCount=q("FPDFAnnot_GetFormControlCount",2),o._FPDFAnnot_GetFormControlIndex=q("FPDFAnnot_GetFormControlIndex",2),o._FPDFAnnot_GetFormFieldExportValue=q("FPDFAnnot_GetFormFieldExportValue",4),o._FPDFAnnot_SetURI=q("FPDFAnnot_SetURI",2),o._FPDFAnnot_GetFileAttachment=q("FPDFAnnot_GetFileAttachment",1),o._FPDFAnnot_AddFileAttachment=q("FPDFAnnot_AddFileAttachment",2),o._EPDFAnnot_SetColor=q("EPDFAnnot_SetColor",5),o._EPDFAnnot_GetColor=q("EPDFAnnot_GetColor",5),o._EPDFAnnot_ClearColor=q("EPDFAnnot_ClearColor",2),o._EPDFAnnot_SetOpacity=q("EPDFAnnot_SetOpacity",2),o._EPDFAnnot_GetOpacity=q("EPDFAnnot_GetOpacity",2),o._EPDFAnnot_GetBorderEffect=q("EPDFAnnot_GetBorderEffect",2),o._EPDFAnnot_GetRectangleDifferences=q("EPDFAnnot_GetRectangleDifferences",5),o._EPDFAnnot_GetBorderDashPatternCount=q("EPDFAnnot_GetBorderDashPatternCount",1),o._EPDFAnnot_GetBorderDashPattern=q("EPDFAnnot_GetBorderDashPattern",3),o._EPDFAnnot_SetBorderDashPattern=q("EPDFAnnot_SetBorderDashPattern",3),o._EPDFAnnot_GetBorderStyle=q("EPDFAnnot_GetBorderStyle",2),o._EPDFAnnot_SetBorderStyle=q("EPDFAnnot_SetBorderStyle",3),o._EPDFAnnot_GenerateAppearance=q("EPDFAnnot_GenerateAppearance",1),o._EPDFAnnot_GenerateAppearanceWithBlend=q("EPDFAnnot_GenerateAppearanceWithBlend",2),o._EPDFAnnot_GetBlendMode=q("EPDFAnnot_GetBlendMode",1),o._EPDFAnnot_SetIntent=q("EPDFAnnot_SetIntent",2),o._EPDFAnnot_GetIntent=q("EPDFAnnot_GetIntent",3),o._EPDFAnnot_GetRichContent=q("EPDFAnnot_GetRichContent",3),o._EPDFAnnot_SetLineEndings=q("EPDFAnnot_SetLineEndings",3),o._EPDFAnnot_GetLineEndings=q("EPDFAnnot_GetLineEndings",3),o._EPDFAnnot_SetVertices=q("EPDFAnnot_SetVertices",3),o._EPDFAnnot_SetLine=q("EPDFAnnot_SetLine",3),o._EPDFAnnot_SetDefaultAppearance=q("EPDFAnnot_SetDefaultAppearance",6),o._EPDFAnnot_GetDefaultAppearance=q("EPDFAnnot_GetDefaultAppearance",6),o._EPDFAnnot_SetTextAlignment=q("EPDFAnnot_SetTextAlignment",2),o._EPDFAnnot_GetTextAlignment=q("EPDFAnnot_GetTextAlignment",1),o._EPDFAnnot_SetVerticalAlignment=q("EPDFAnnot_SetVerticalAlignment",2),o._EPDFAnnot_GetVerticalAlignment=q("EPDFAnnot_GetVerticalAlignment",1),o._EPDFPage_GetAnnotByName=q("EPDFPage_GetAnnotByName",2),o._EPDFPage_RemoveAnnotByName=q("EPDFPage_RemoveAnnotByName",2),o._EPDFAnnot_SetLinkedAnnot=q("EPDFAnnot_SetLinkedAnnot",3),o._EPDFPage_GetAnnotCountRaw=q("EPDFPage_GetAnnotCountRaw",2),o._EPDFPage_GetAnnotRaw=q("EPDFPage_GetAnnotRaw",3),o._EPDFPage_RemoveAnnotRaw=q("EPDFPage_RemoveAnnotRaw",3),o._EPDFAnnot_SetIcon=q("EPDFAnnot_SetIcon",2),o._EPDFAnnot_GetIcon=q("EPDFAnnot_GetIcon",1),o._EPDFAnnot_UpdateAppearanceToRect=q("EPDFAnnot_UpdateAppearanceToRect",2),o._EPDFPage_CreateAnnot=q("EPDFPage_CreateAnnot",2),o._FPDFDoc_GetAttachmentCount=q("FPDFDoc_GetAttachmentCount",1),o._FPDFDoc_AddAttachment=q("FPDFDoc_AddAttachment",2),o._FPDFDoc_GetAttachment=q("FPDFDoc_GetAttachment",2),o._FPDFDoc_DeleteAttachment=q("FPDFDoc_DeleteAttachment",2),o._FPDFAttachment_GetName=q("FPDFAttachment_GetName",3),o._FPDFAttachment_HasKey=q("FPDFAttachment_HasKey",2),o._FPDFAttachment_GetValueType=q("FPDFAttachment_GetValueType",2),o._FPDFAttachment_SetStringValue=q("FPDFAttachment_SetStringValue",3),o._FPDFAttachment_GetStringValue=q("FPDFAttachment_GetStringValue",4),o._FPDFAttachment_SetFile=q("FPDFAttachment_SetFile",4),o._FPDFAttachment_GetFile=q("FPDFAttachment_GetFile",4),o._FPDFAttachment_GetSubtype=q("FPDFAttachment_GetSubtype",3),o._EPDFAttachment_SetSubtype=q("EPDFAttachment_SetSubtype",2),o._EPDFAttachment_SetDescription=q("EPDFAttachment_SetDescription",2),o._EPDFAttachment_GetDescription=q("EPDFAttachment_GetDescription",3),o._EPDFAttachment_GetIntegerValue=q("EPDFAttachment_GetIntegerValue",3),o._FPDFCatalog_IsTagged=q("FPDFCatalog_IsTagged",1),o._FPDFCatalog_SetLanguage=q("FPDFCatalog_SetLanguage",2),o._EPDFCatalog_GetLanguage=q("EPDFCatalog_GetLanguage",3),o._FPDFAvail_Create=q("FPDFAvail_Create",2),o._FPDFAvail_Destroy=q("FPDFAvail_Destroy",1),o._FPDFAvail_IsDocAvail=q("FPDFAvail_IsDocAvail",2),o._FPDFAvail_GetDocument=q("FPDFAvail_GetDocument",2),o._FPDFAvail_GetFirstPageNum=q("FPDFAvail_GetFirstPageNum",1),o._FPDFAvail_IsPageAvail=q("FPDFAvail_IsPageAvail",3),o._FPDFAvail_IsFormAvail=q("FPDFAvail_IsFormAvail",2),o._FPDFAvail_IsLinearized=q("FPDFAvail_IsLinearized",1),o._FPDFBookmark_GetFirstChild=q("FPDFBookmark_GetFirstChild",2),o._FPDFBookmark_GetNextSibling=q("FPDFBookmark_GetNextSibling",2),o._FPDFBookmark_GetTitle=q("FPDFBookmark_GetTitle",3),o._FPDFBookmark_GetCount=q("FPDFBookmark_GetCount",1),o._FPDFBookmark_Find=q("FPDFBookmark_Find",2),o._FPDFBookmark_GetDest=q("FPDFBookmark_GetDest",2),o._FPDFBookmark_GetAction=q("FPDFBookmark_GetAction",1),o._FPDFAction_GetType=q("FPDFAction_GetType",1),o._FPDFAction_GetDest=q("FPDFAction_GetDest",2),o._FPDFAction_GetFilePath=q("FPDFAction_GetFilePath",3),o._FPDFAction_GetURIPath=q("FPDFAction_GetURIPath",4),o._FPDFDest_GetDestPageIndex=q("FPDFDest_GetDestPageIndex",2),o._FPDFDest_GetView=q("FPDFDest_GetView",3),o._FPDFDest_GetLocationInPage=q("FPDFDest_GetLocationInPage",7),o._FPDFLink_GetLinkAtPoint=q("FPDFLink_GetLinkAtPoint",3),o._FPDFLink_GetLinkZOrderAtPoint=q("FPDFLink_GetLinkZOrderAtPoint",3),o._FPDFLink_GetDest=q("FPDFLink_GetDest",2),o._FPDFLink_GetAction=q("FPDFLink_GetAction",1),o._FPDFLink_Enumerate=q("FPDFLink_Enumerate",3),o._FPDFLink_GetAnnot=q("FPDFLink_GetAnnot",2),o._FPDFLink_GetAnnotRect=q("FPDFLink_GetAnnotRect",2),o._FPDFLink_CountQuadPoints=q("FPDFLink_CountQuadPoints",1),o._FPDFLink_GetQuadPoints=q("FPDFLink_GetQuadPoints",3),o._FPDF_GetPageAAction=q("FPDF_GetPageAAction",2),o._FPDF_GetFileIdentifier=q("FPDF_GetFileIdentifier",4),o._FPDF_GetMetaText=q("FPDF_GetMetaText",4),o._FPDF_GetPageLabel=q("FPDF_GetPageLabel",4),o._EPDF_SetMetaText=q("EPDF_SetMetaText",3),o._EPDF_HasMetaText=q("EPDF_HasMetaText",2),o._EPDF_GetMetaTrapped=q("EPDF_GetMetaTrapped",1),o._EPDF_SetMetaTrapped=q("EPDF_SetMetaTrapped",2),o._EPDF_GetMetaKeyCount=q("EPDF_GetMetaKeyCount",2),o._EPDF_GetMetaKeyName=q("EPDF_GetMetaKeyName",5),o._FPDFPageObj_NewImageObj=q("FPDFPageObj_NewImageObj",1),o._FPDFImageObj_LoadJpegFile=q("FPDFImageObj_LoadJpegFile",4),o._FPDFImageObj_LoadJpegFileInline=q("FPDFImageObj_LoadJpegFileInline",4),o._FPDFImageObj_SetMatrix=q("FPDFImageObj_SetMatrix",7),o._FPDFImageObj_SetBitmap=q("FPDFImageObj_SetBitmap",4),o._FPDFImageObj_GetBitmap=q("FPDFImageObj_GetBitmap",1),o._FPDFImageObj_GetRenderedBitmap=q("FPDFImageObj_GetRenderedBitmap",3),o._FPDFImageObj_GetImageDataDecoded=q("FPDFImageObj_GetImageDataDecoded",3),o._FPDFImageObj_GetImageDataRaw=q("FPDFImageObj_GetImageDataRaw",3),o._FPDFImageObj_GetImageFilterCount=q("FPDFImageObj_GetImageFilterCount",1),o._FPDFImageObj_GetImageFilter=q("FPDFImageObj_GetImageFilter",4),o._FPDFImageObj_GetImageMetadata=q("FPDFImageObj_GetImageMetadata",3),o._FPDFImageObj_GetImagePixelSize=q("FPDFImageObj_GetImagePixelSize",3),o._FPDFImageObj_GetIccProfileDataDecoded=q("FPDFImageObj_GetIccProfileDataDecoded",5),o._FPDF_CreateNewDocument=q("FPDF_CreateNewDocument",0),o._FPDFPage_Delete=q("FPDFPage_Delete",2),o._FPDF_MovePages=q("FPDF_MovePages",4),o._FPDFPage_New=q("FPDFPage_New",4),o._FPDFPage_GetRotation=q("FPDFPage_GetRotation",1),o._FPDFPage_InsertObject=q("FPDFPage_InsertObject",2),o._FPDFPage_InsertObjectAtIndex=q("FPDFPage_InsertObjectAtIndex",3),o._FPDFPage_RemoveObject=q("FPDFPage_RemoveObject",2),o._FPDFPage_CountObjects=q("FPDFPage_CountObjects",1),o._FPDFPage_GetObject=q("FPDFPage_GetObject",2),o._FPDFPage_HasTransparency=q("FPDFPage_HasTransparency",1),o._FPDFPageObj_Destroy=q("FPDFPageObj_Destroy",1),o._FPDFPageObj_GetMarkedContentID=q("FPDFPageObj_GetMarkedContentID",1),o._FPDFPageObj_CountMarks=q("FPDFPageObj_CountMarks",1),o._FPDFPageObj_GetMark=q("FPDFPageObj_GetMark",2),o._FPDFPageObj_AddMark=q("FPDFPageObj_AddMark",2),o._FPDFPageObj_RemoveMark=q("FPDFPageObj_RemoveMark",2),o._FPDFPageObjMark_GetName=q("FPDFPageObjMark_GetName",4),o._FPDFPageObjMark_CountParams=q("FPDFPageObjMark_CountParams",1),o._FPDFPageObjMark_GetParamKey=q("FPDFPageObjMark_GetParamKey",5),o._FPDFPageObjMark_GetParamValueType=q("FPDFPageObjMark_GetParamValueType",2),o._FPDFPageObjMark_GetParamIntValue=q("FPDFPageObjMark_GetParamIntValue",3),o._FPDFPageObjMark_GetParamStringValue=q("FPDFPageObjMark_GetParamStringValue",5),o._FPDFPageObjMark_GetParamBlobValue=q("FPDFPageObjMark_GetParamBlobValue",5),o._FPDFPageObj_HasTransparency=q("FPDFPageObj_HasTransparency",1),o._FPDFPageObjMark_SetIntParam=q("FPDFPageObjMark_SetIntParam",5),o._FPDFPageObjMark_SetStringParam=q("FPDFPageObjMark_SetStringParam",5),o._FPDFPageObjMark_SetBlobParam=q("FPDFPageObjMark_SetBlobParam",6),o._FPDFPageObjMark_RemoveParam=q("FPDFPageObjMark_RemoveParam",3),o._FPDFPageObj_GetType=q("FPDFPageObj_GetType",1),o._FPDFPageObj_GetIsActive=q("FPDFPageObj_GetIsActive",2),o._FPDFPageObj_SetIsActive=q("FPDFPageObj_SetIsActive",2),o._FPDFPage_GenerateContent=q("FPDFPage_GenerateContent",1),o._FPDFPageObj_Transform=q("FPDFPageObj_Transform",7),o._FPDFPageObj_TransformF=q("FPDFPageObj_TransformF",2),o._FPDFPageObj_GetMatrix=q("FPDFPageObj_GetMatrix",2),o._FPDFPageObj_SetMatrix=q("FPDFPageObj_SetMatrix",2),o._FPDFPageObj_SetBlendMode=q("FPDFPageObj_SetBlendMode",2),o._FPDFPage_TransformAnnots=q("FPDFPage_TransformAnnots",7),o._FPDFPage_SetRotation=q("FPDFPage_SetRotation",2),o._FPDFPageObj_SetFillColor=q("FPDFPageObj_SetFillColor",5),o._FPDFPageObj_GetFillColor=q("FPDFPageObj_GetFillColor",5),o._FPDFPageObj_GetBounds=q("FPDFPageObj_GetBounds",5),o._FPDFPageObj_GetRotatedBounds=q("FPDFPageObj_GetRotatedBounds",2),o._FPDFPageObj_SetStrokeColor=q("FPDFPageObj_SetStrokeColor",5),o._FPDFPageObj_GetStrokeColor=q("FPDFPageObj_GetStrokeColor",5),o._FPDFPageObj_SetStrokeWidth=q("FPDFPageObj_SetStrokeWidth",2),o._FPDFPageObj_GetStrokeWidth=q("FPDFPageObj_GetStrokeWidth",2),o._FPDFPageObj_GetLineJoin=q("FPDFPageObj_GetLineJoin",1),o._FPDFPageObj_SetLineJoin=q("FPDFPageObj_SetLineJoin",2),o._FPDFPageObj_GetLineCap=q("FPDFPageObj_GetLineCap",1),o._FPDFPageObj_SetLineCap=q("FPDFPageObj_SetLineCap",2),o._FPDFPageObj_GetDashPhase=q("FPDFPageObj_GetDashPhase",2),o._FPDFPageObj_SetDashPhase=q("FPDFPageObj_SetDashPhase",2),o._FPDFPageObj_GetDashCount=q("FPDFPageObj_GetDashCount",1),o._FPDFPageObj_GetDashArray=q("FPDFPageObj_GetDashArray",3),o._FPDFPageObj_SetDashArray=q("FPDFPageObj_SetDashArray",4),o._FPDFFormObj_CountObjects=q("FPDFFormObj_CountObjects",1),o._FPDFFormObj_GetObject=q("FPDFFormObj_GetObject",2),o._FPDFFormObj_RemoveObject=q("FPDFFormObj_RemoveObject",2),o._FPDFPageObj_CreateNewPath=q("FPDFPageObj_CreateNewPath",2),o._FPDFPageObj_CreateNewRect=q("FPDFPageObj_CreateNewRect",4),o._FPDFPath_CountSegments=q("FPDFPath_CountSegments",1),o._FPDFPath_GetPathSegment=q("FPDFPath_GetPathSegment",2),o._FPDFPath_MoveTo=q("FPDFPath_MoveTo",3),o._FPDFPath_LineTo=q("FPDFPath_LineTo",3),o._FPDFPath_BezierTo=q("FPDFPath_BezierTo",7),o._FPDFPath_Close=q("FPDFPath_Close",1),o._FPDFPath_SetDrawMode=q("FPDFPath_SetDrawMode",3),o._FPDFPath_GetDrawMode=q("FPDFPath_GetDrawMode",3),o._FPDFPathSegment_GetPoint=q("FPDFPathSegment_GetPoint",3),o._FPDFPathSegment_GetType=q("FPDFPathSegment_GetType",1),o._FPDFPathSegment_GetClose=q("FPDFPathSegment_GetClose",1),o._FPDFPageObj_NewTextObj=q("FPDFPageObj_NewTextObj",3),o._FPDFText_SetText=q("FPDFText_SetText",2),o._FPDFText_SetCharcodes=q("FPDFText_SetCharcodes",3),o._FPDFText_LoadFont=q("FPDFText_LoadFont",5),o._FPDFText_LoadStandardFont=q("FPDFText_LoadStandardFont",2),o._FPDFText_LoadCidType2Font=q("FPDFText_LoadCidType2Font",6),o._FPDFTextObj_GetFontSize=q("FPDFTextObj_GetFontSize",2),o._FPDFTextObj_GetText=q("FPDFTextObj_GetText",4),o._FPDFTextObj_GetRenderedBitmap=q("FPDFTextObj_GetRenderedBitmap",4),o._FPDFFont_Close=q("FPDFFont_Close",1),o._FPDFPageObj_CreateTextObj=q("FPDFPageObj_CreateTextObj",3),o._FPDFTextObj_GetTextRenderMode=q("FPDFTextObj_GetTextRenderMode",1),o._FPDFTextObj_SetTextRenderMode=q("FPDFTextObj_SetTextRenderMode",2),o._FPDFTextObj_GetFont=q("FPDFTextObj_GetFont",1),o._FPDFFont_GetBaseFontName=q("FPDFFont_GetBaseFontName",3),o._FPDFFont_GetFamilyName=q("FPDFFont_GetFamilyName",3),o._FPDFFont_GetFontData=q("FPDFFont_GetFontData",4),o._FPDFFont_GetIsEmbedded=q("FPDFFont_GetIsEmbedded",1),o._FPDFFont_GetFlags=q("FPDFFont_GetFlags",1),o._FPDFFont_GetWeight=q("FPDFFont_GetWeight",1),o._FPDFFont_GetItalicAngle=q("FPDFFont_GetItalicAngle",2),o._FPDFFont_GetAscent=q("FPDFFont_GetAscent",3),o._FPDFFont_GetDescent=q("FPDFFont_GetDescent",3),o._FPDFFont_GetGlyphWidth=q("FPDFFont_GetGlyphWidth",4),o._FPDFFont_GetGlyphPath=q("FPDFFont_GetGlyphPath",3),o._FPDFGlyphPath_CountGlyphSegments=q("FPDFGlyphPath_CountGlyphSegments",1),o._FPDFGlyphPath_GetGlyphPathSegment=q("FPDFGlyphPath_GetGlyphPathSegment",2),o._EPDFText_RedactInRect=q("EPDFText_RedactInRect",4),o._EPDFText_RedactInQuads=q("EPDFText_RedactInQuads",5),o._FPDFDoc_GetPageMode=q("FPDFDoc_GetPageMode",1),o._FPDFPage_Flatten=q("FPDFPage_Flatten",2),o._FPDFPage_HasFormFieldAtPoint=q("FPDFPage_HasFormFieldAtPoint",4),o._FPDFPage_FormFieldZOrderAtPoint=q("FPDFPage_FormFieldZOrderAtPoint",4),o._malloc=q("malloc",1),o._free=q("free",1),o._FORM_OnMouseMove=q("FORM_OnMouseMove",5),o._FORM_OnMouseWheel=q("FORM_OnMouseWheel",6),o._FORM_OnFocus=q("FORM_OnFocus",5),o._FORM_OnLButtonDown=q("FORM_OnLButtonDown",5),o._FORM_OnLButtonUp=q("FORM_OnLButtonUp",5),o._FORM_OnLButtonDoubleClick=q("FORM_OnLButtonDoubleClick",5),o._FORM_OnRButtonDown=q("FORM_OnRButtonDown",5),o._FORM_OnRButtonUp=q("FORM_OnRButtonUp",5),o._FORM_OnKeyDown=q("FORM_OnKeyDown",4),o._FORM_OnKeyUp=q("FORM_OnKeyUp",4),o._FORM_OnChar=q("FORM_OnChar",4),o._FORM_GetFocusedText=q("FORM_GetFocusedText",4),o._FORM_GetSelectedText=q("FORM_GetSelectedText",4),o._FORM_ReplaceAndKeepSelection=q("FORM_ReplaceAndKeepSelection",3),o._FORM_ReplaceSelection=q("FORM_ReplaceSelection",3),o._FORM_SelectAllText=q("FORM_SelectAllText",2),o._FORM_CanUndo=q("FORM_CanUndo",2),o._FORM_CanRedo=q("FORM_CanRedo",2),o._FORM_Undo=q("FORM_Undo",2),o._FORM_Redo=q("FORM_Redo",2),o._FORM_ForceToKillFocus=q("FORM_ForceToKillFocus",1),o._FORM_GetFocusedAnnot=q("FORM_GetFocusedAnnot",3),o._FORM_SetFocusedAnnot=q("FORM_SetFocusedAnnot",2),o._FPDF_FFLDraw=q("FPDF_FFLDraw",9),o._FPDF_SetFormFieldHighlightColor=q("FPDF_SetFormFieldHighlightColor",3),o._FPDF_SetFormFieldHighlightAlpha=q("FPDF_SetFormFieldHighlightAlpha",2),o._FPDF_RemoveFormFieldHighlight=q("FPDF_RemoveFormFieldHighlight",1),o._FORM_OnAfterLoadPage=q("FORM_OnAfterLoadPage",2),o._FORM_OnBeforeClosePage=q("FORM_OnBeforeClosePage",2),o._FORM_DoDocumentJSAction=q("FORM_DoDocumentJSAction",1),o._FORM_DoDocumentOpenAction=q("FORM_DoDocumentOpenAction",1),o._FORM_DoDocumentAAction=q("FORM_DoDocumentAAction",2),o._FORM_DoPageAAction=q("FORM_DoPageAAction",3),o._FORM_SetIndexSelected=q("FORM_SetIndexSelected",4),o._FORM_IsIndexSelected=q("FORM_IsIndexSelected",3),o._FPDFDoc_GetJavaScriptActionCount=q("FPDFDoc_GetJavaScriptActionCount",1),o._FPDFDoc_GetJavaScriptAction=q("FPDFDoc_GetJavaScriptAction",2),o._FPDFDoc_CloseJavaScriptAction=q("FPDFDoc_CloseJavaScriptAction",1),o._FPDFJavaScriptAction_GetName=q("FPDFJavaScriptAction_GetName",3),o._FPDFJavaScriptAction_GetScript=q("FPDFJavaScriptAction_GetScript",3),o._FPDF_ImportPagesByIndex=q("FPDF_ImportPagesByIndex",5),o._FPDF_ImportPages=q("FPDF_ImportPages",4),o._FPDF_ImportNPagesToOne=q("FPDF_ImportNPagesToOne",5),o._FPDF_NewXObjectFromPage=q("FPDF_NewXObjectFromPage",3),o._FPDF_CloseXObject=q("FPDF_CloseXObject",1),o._FPDF_NewFormObjectFromXObject=q("FPDF_NewFormObjectFromXObject",1),o._FPDF_CopyViewerPreferences=q("FPDF_CopyViewerPreferences",2),o._FPDF_RenderPageBitmapWithColorScheme_Start=q("FPDF_RenderPageBitmapWithColorScheme_Start",10),o._FPDF_RenderPageBitmap_Start=q("FPDF_RenderPageBitmap_Start",9),o._FPDF_RenderPage_Continue=q("FPDF_RenderPage_Continue",2),o._FPDF_RenderPage_Close=q("FPDF_RenderPage_Close",1),o._FPDF_SaveWithVersion=q("FPDF_SaveWithVersion",4),o._FPDFText_GetCharIndexFromTextIndex=q("FPDFText_GetCharIndexFromTextIndex",2),o._FPDFText_GetTextIndexFromCharIndex=q("FPDFText_GetTextIndexFromCharIndex",2),o._FPDF_GetSignatureCount=q("FPDF_GetSignatureCount",1),o._FPDF_GetSignatureObject=q("FPDF_GetSignatureObject",2),o._FPDFSignatureObj_GetContents=q("FPDFSignatureObj_GetContents",3),o._FPDFSignatureObj_GetByteRange=q("FPDFSignatureObj_GetByteRange",3),o._FPDFSignatureObj_GetSubFilter=q("FPDFSignatureObj_GetSubFilter",3),o._FPDFSignatureObj_GetReason=q("FPDFSignatureObj_GetReason",3),o._FPDFSignatureObj_GetTime=q("FPDFSignatureObj_GetTime",3),o._FPDFSignatureObj_GetDocMDPPermission=q("FPDFSignatureObj_GetDocMDPPermission",1),o._FPDF_StructTree_GetForPage=q("FPDF_StructTree_GetForPage",1),o._FPDF_StructTree_Close=q("FPDF_StructTree_Close",1),o._FPDF_StructTree_CountChildren=q("FPDF_StructTree_CountChildren",1),o._FPDF_StructTree_GetChildAtIndex=q("FPDF_StructTree_GetChildAtIndex",2),o._FPDF_StructElement_GetAltText=q("FPDF_StructElement_GetAltText",3),o._FPDF_StructElement_GetActualText=q("FPDF_StructElement_GetActualText",3),o._FPDF_StructElement_GetID=q("FPDF_StructElement_GetID",3),o._FPDF_StructElement_GetLang=q("FPDF_StructElement_GetLang",3),o._FPDF_StructElement_GetAttributeCount=q("FPDF_StructElement_GetAttributeCount",1),o._FPDF_StructElement_GetAttributeAtIndex=q("FPDF_StructElement_GetAttributeAtIndex",2),o._FPDF_StructElement_GetStringAttribute=q("FPDF_StructElement_GetStringAttribute",4),o._FPDF_StructElement_GetMarkedContentID=q("FPDF_StructElement_GetMarkedContentID",1),o._FPDF_StructElement_GetType=q("FPDF_StructElement_GetType",3),o._FPDF_StructElement_GetObjType=q("FPDF_StructElement_GetObjType",3),o._FPDF_StructElement_GetTitle=q("FPDF_StructElement_GetTitle",3),o._FPDF_StructElement_CountChildren=q("FPDF_StructElement_CountChildren",1),o._FPDF_StructElement_GetChildAtIndex=q("FPDF_StructElement_GetChildAtIndex",2),o._FPDF_StructElement_GetChildMarkedContentID=q("FPDF_StructElement_GetChildMarkedContentID",2),o._FPDF_StructElement_GetParent=q("FPDF_StructElement_GetParent",1),o._FPDF_StructElement_Attr_GetCount=q("FPDF_StructElement_Attr_GetCount",1),o._FPDF_StructElement_Attr_GetName=q("FPDF_StructElement_Attr_GetName",5),o._FPDF_StructElement_Attr_GetValue=q("FPDF_StructElement_Attr_GetValue",2),o._FPDF_StructElement_Attr_GetType=q("FPDF_StructElement_Attr_GetType",1),o._FPDF_StructElement_Attr_GetBooleanValue=q("FPDF_StructElement_Attr_GetBooleanValue",2),o._FPDF_StructElement_Attr_GetNumberValue=q("FPDF_StructElement_Attr_GetNumberValue",2),o._FPDF_StructElement_Attr_GetStringValue=q("FPDF_StructElement_Attr_GetStringValue",4),o._FPDF_StructElement_Attr_GetBlobValue=q("FPDF_StructElement_Attr_GetBlobValue",4),o._FPDF_StructElement_Attr_CountChildren=q("FPDF_StructElement_Attr_CountChildren",1),o._FPDF_StructElement_Attr_GetChildAtIndex=q("FPDF_StructElement_Attr_GetChildAtIndex",2),o._FPDF_StructElement_GetMarkedContentIdCount=q("FPDF_StructElement_GetMarkedContentIdCount",1),o._FPDF_StructElement_GetMarkedContentIdAtIndex=q("FPDF_StructElement_GetMarkedContentIdAtIndex",2),o._FPDF_AddInstalledFont=q("FPDF_AddInstalledFont",3),o._FPDF_SetSystemFontInfo=q("FPDF_SetSystemFontInfo",1),o._FPDF_GetDefaultTTFMap=q("FPDF_GetDefaultTTFMap",0),o._FPDF_GetDefaultTTFMapCount=q("FPDF_GetDefaultTTFMapCount",0),o._FPDF_GetDefaultTTFMapEntry=q("FPDF_GetDefaultTTFMapEntry",1),o._FPDF_GetDefaultSystemFontInfo=q("FPDF_GetDefaultSystemFontInfo",0),o._FPDF_FreeDefaultSystemFontInfo=q("FPDF_FreeDefaultSystemFontInfo",1),o._FPDFText_LoadPage=q("FPDFText_LoadPage",1),o._FPDFText_ClosePage=q("FPDFText_ClosePage",1),o._FPDFText_CountChars=q("FPDFText_CountChars",1),o._FPDFText_GetUnicode=q("FPDFText_GetUnicode",2),o._FPDFText_GetTextObject=q("FPDFText_GetTextObject",2),o._FPDFText_IsGenerated=q("FPDFText_IsGenerated",2),o._FPDFText_IsHyphen=q("FPDFText_IsHyphen",2),o._FPDFText_HasUnicodeMapError=q("FPDFText_HasUnicodeMapError",2),o._FPDFText_GetFontSize=q("FPDFText_GetFontSize",2),o._FPDFText_GetFontInfo=q("FPDFText_GetFontInfo",5),o._FPDFText_GetFontWeight=q("FPDFText_GetFontWeight",2),o._FPDFText_GetFillColor=q("FPDFText_GetFillColor",6),o._FPDFText_GetStrokeColor=q("FPDFText_GetStrokeColor",6),o._FPDFText_GetCharAngle=q("FPDFText_GetCharAngle",2),o._FPDFText_GetCharBox=q("FPDFText_GetCharBox",6),o._FPDFText_GetLooseCharBox=q("FPDFText_GetLooseCharBox",3),o._FPDFText_GetMatrix=q("FPDFText_GetMatrix",3),o._FPDFText_GetCharOrigin=q("FPDFText_GetCharOrigin",4),o._FPDFText_GetCharIndexAtPos=q("FPDFText_GetCharIndexAtPos",5),o._FPDFText_GetText=q("FPDFText_GetText",4),o._FPDFText_CountRects=q("FPDFText_CountRects",3),o._FPDFText_GetRect=q("FPDFText_GetRect",6),o._FPDFText_GetBoundedText=q("FPDFText_GetBoundedText",7),o._FPDFText_FindStart=q("FPDFText_FindStart",4),o._FPDFText_FindNext=q("FPDFText_FindNext",1),o._FPDFText_FindPrev=q("FPDFText_FindPrev",1),o._FPDFText_GetSchResultIndex=q("FPDFText_GetSchResultIndex",1),o._FPDFText_GetSchCount=q("FPDFText_GetSchCount",1),o._FPDFText_FindClose=q("FPDFText_FindClose",1),o._FPDFLink_LoadWebLinks=q("FPDFLink_LoadWebLinks",1),o._FPDFLink_CountWebLinks=q("FPDFLink_CountWebLinks",1),o._FPDFLink_GetURL=q("FPDFLink_GetURL",4),o._FPDFLink_CountRects=q("FPDFLink_CountRects",2),o._FPDFLink_GetRect=q("FPDFLink_GetRect",7),o._FPDFLink_GetTextRange=q("FPDFLink_GetTextRange",4),o._FPDFLink_CloseWebLinks=q("FPDFLink_CloseWebLinks",1),o._FPDFPage_GetDecodedThumbnailData=q("FPDFPage_GetDecodedThumbnailData",3),o._FPDFPage_GetRawThumbnailData=q("FPDFPage_GetRawThumbnailData",3),o._FPDFPage_GetThumbnailAsBitmap=q("FPDFPage_GetThumbnailAsBitmap",1),o._FPDFPage_SetMediaBox=q("FPDFPage_SetMediaBox",5),o._FPDFPage_SetCropBox=q("FPDFPage_SetCropBox",5),o._FPDFPage_SetBleedBox=q("FPDFPage_SetBleedBox",5),o._FPDFPage_SetTrimBox=q("FPDFPage_SetTrimBox",5),o._FPDFPage_SetArtBox=q("FPDFPage_SetArtBox",5),o._FPDFPage_GetMediaBox=q("FPDFPage_GetMediaBox",5),o._FPDFPage_GetCropBox=q("FPDFPage_GetCropBox",5),o._FPDFPage_GetBleedBox=q("FPDFPage_GetBleedBox",5),o._FPDFPage_GetTrimBox=q("FPDFPage_GetTrimBox",5),o._FPDFPage_GetArtBox=q("FPDFPage_GetArtBox",5),o._FPDFPage_TransFormWithClip=q("FPDFPage_TransFormWithClip",3),o._FPDFPageObj_TransformClipPath=q("FPDFPageObj_TransformClipPath",7),o._FPDFPageObj_GetClipPath=q("FPDFPageObj_GetClipPath",1),o._FPDFClipPath_CountPaths=q("FPDFClipPath_CountPaths",1),o._FPDFClipPath_CountPathSegments=q("FPDFClipPath_CountPathSegments",2),o._FPDFClipPath_GetPathSegment=q("FPDFClipPath_GetPathSegment",3),o._FPDF_CreateClipPath=q("FPDF_CreateClipPath",4),o._FPDF_DestroyClipPath=q("FPDF_DestroyClipPath",1),o._FPDFPage_InsertClipPath=q("FPDFPage_InsertClipPath",2),o._FPDF_InitLibrary=q("FPDF_InitLibrary",0),o._FPDF_DestroyLibrary=q("FPDF_DestroyLibrary",0),o._FPDF_SetSandBoxPolicy=q("FPDF_SetSandBoxPolicy",2),o._FPDF_LoadDocument=q("FPDF_LoadDocument",2),o._FPDF_GetFormType=q("FPDF_GetFormType",1),o._FPDF_LoadXFA=q("FPDF_LoadXFA",1),o._FPDF_LoadMemDocument=q("FPDF_LoadMemDocument",3),o._FPDF_LoadMemDocument64=q("FPDF_LoadMemDocument64",3),o._FPDF_LoadCustomDocument=q("FPDF_LoadCustomDocument",2),o._FPDF_GetFileVersion=q("FPDF_GetFileVersion",2),o._FPDF_DocumentHasValidCrossReferenceTable=q("FPDF_DocumentHasValidCrossReferenceTable",1),o._FPDF_GetDocPermissions=q("FPDF_GetDocPermissions",1),o._FPDF_GetDocUserPermissions=q("FPDF_GetDocUserPermissions",1),o._FPDF_GetSecurityHandlerRevision=q("FPDF_GetSecurityHandlerRevision",1),o._FPDF_GetPageCount=q("FPDF_GetPageCount",1),o._FPDF_LoadPage=q("FPDF_LoadPage",2),o._FPDF_GetPageWidthF=q("FPDF_GetPageWidthF",1),o._FPDF_GetPageWidth=q("FPDF_GetPageWidth",1),o._FPDF_GetPageHeightF=q("FPDF_GetPageHeightF",1),o._FPDF_GetPageHeight=q("FPDF_GetPageHeight",1),o._FPDF_GetPageBoundingBox=q("FPDF_GetPageBoundingBox",2),o._FPDF_RenderPageBitmap=q("FPDF_RenderPageBitmap",8),o._FPDF_RenderPageBitmapWithMatrix=q("FPDF_RenderPageBitmapWithMatrix",5),o._EPDF_RenderAnnotBitmap=q("EPDF_RenderAnnotBitmap",6),o._FPDF_ClosePage=q("FPDF_ClosePage",1),o._FPDF_CloseDocument=q("FPDF_CloseDocument",1),o._FPDF_GetLastError=q("FPDF_GetLastError",0),o._FPDF_DeviceToPage=q("FPDF_DeviceToPage",10),o._FPDF_PageToDevice=q("FPDF_PageToDevice",10),o._FPDFBitmap_Create=q("FPDFBitmap_Create",3),o._FPDFBitmap_CreateEx=q("FPDFBitmap_CreateEx",5),o._FPDFBitmap_GetFormat=q("FPDFBitmap_GetFormat",1),o._FPDFBitmap_FillRect=q("FPDFBitmap_FillRect",6),o._FPDFBitmap_GetBuffer=q("FPDFBitmap_GetBuffer",1),o._FPDFBitmap_GetWidth=q("FPDFBitmap_GetWidth",1),o._FPDFBitmap_GetHeight=q("FPDFBitmap_GetHeight",1),o._FPDFBitmap_GetStride=q("FPDFBitmap_GetStride",1),o._FPDFBitmap_Destroy=q("FPDFBitmap_Destroy",1),o._FPDF_GetPageSizeByIndexF=q("FPDF_GetPageSizeByIndexF",3),o._EPDF_GetPageRotationByIndex=q("EPDF_GetPageRotationByIndex",2),o._FPDF_GetPageSizeByIndex=q("FPDF_GetPageSizeByIndex",4),o._FPDF_VIEWERREF_GetPrintScaling=q("FPDF_VIEWERREF_GetPrintScaling",1),o._FPDF_VIEWERREF_GetNumCopies=q("FPDF_VIEWERREF_GetNumCopies",1),o._FPDF_VIEWERREF_GetPrintPageRange=q("FPDF_VIEWERREF_GetPrintPageRange",1),o._FPDF_VIEWERREF_GetPrintPageRangeCount=q("FPDF_VIEWERREF_GetPrintPageRangeCount",1),o._FPDF_VIEWERREF_GetPrintPageRangeElement=q("FPDF_VIEWERREF_GetPrintPageRangeElement",2),o._FPDF_VIEWERREF_GetDuplex=q("FPDF_VIEWERREF_GetDuplex",1),o._FPDF_VIEWERREF_GetName=q("FPDF_VIEWERREF_GetName",4),o._FPDF_CountNamedDests=q("FPDF_CountNamedDests",1),o._FPDF_GetNamedDestByName=q("FPDF_GetNamedDestByName",2),o._FPDF_GetNamedDest=q("FPDF_GetNamedDest",4),o._FPDF_GetXFAPacketCount=q("FPDF_GetXFAPacketCount",1),o._FPDF_GetXFAPacketName=q("FPDF_GetXFAPacketName",4),o._FPDF_GetXFAPacketContent=q("FPDF_GetXFAPacketContent",5),o._FPDF_GetTrailerEnds=q("FPDF_GetTrailerEnds",3);var Ze,et,tt=q("fflush",1),nt=q("emscripten_builtin_memalign",2),rt=q("strerror",1),ot=q("setThrew",2),at=()=>(at=Qe.emscripten_stack_init)(),it=()=>(it=Qe.emscripten_stack_get_end)(),st=e=>(st=Qe._emscripten_stack_restore)(e),ut=e=>(ut=Qe._emscripten_stack_alloc)(e),mt=()=>(mt=Qe.emscripten_stack_get_current)();function Ft(){var e;at(),C(!(3&(e=it()))),0==e&&(e+=4),M[e>>2]=34821223,M[e+4>>2]=2310721022,M[0]=1668509029}function lt(){var e;function t(){Ze||(Ze=1,o.calledRun=1,S||(C(!w),w=!0,x(),o.noFSInit||Oe.initialized||Oe.init(),Oe.ignorePermissions=!1,ie(O),n(o),o.onRuntimeInitialized?.(),C(!o._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),function(){x();var e=o.postRun;e&&("function"==typeof e&&(e=[e]),e.forEach(I)),ie(k)}()))}B>0||(Ft(),!et&&(et=1,(e=o.preRun)&&("function"==typeof e&&(e=[e]),e.forEach(R)),ie(v),B>0)||(o.setStatus?(o.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>o.setStatus(""),1),t()},1)):t(),x()))}if(o.dynCall_ji=q("dynCall_ji",2),o.dynCall_jij=q("dynCall_jij",4),o.dynCall_iiij=q("dynCall_iiij",5),o.dynCall_iij=q("dynCall_iij",4),o.dynCall_j=q("dynCall_j",1),o.dynCall_jji=q("dynCall_jji",4),o.dynCall_iji=q("dynCall_iji",4),o.dynCall_viijii=q("dynCall_viijii",7),o.dynCall_iiji=q("dynCall_iiji",5),o.dynCall_jiji=q("dynCall_jiji",5),o.dynCall_iiiiij=q("dynCall_iiiiij",7),o.dynCall_iiiiijj=q("dynCall_iiiiijj",9),o.dynCall_iiiiiijj=q("dynCall_iiiiiijj",10),o.dynCall_viji=q("dynCall_viji",5),o.wasmExports=Qe,o.ccall=Je,o.cwrap=(e,t,n,r)=>(...r)=>Je(e,t,n,r),o.addFunction=(e,t)=>{C(void 0!==e);var n=He(e);if(n)return n;var r=(()=>{if(Ke.length)return Ke.pop();try{Ee.grow(1)}catch(e){if(!(e instanceof RangeError))throw e;throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH."}return Ee.length-1})();try{Xe(r,e)}catch(n){if(!(n instanceof TypeError))throw n;C(void 0!==t,"Missing signature argument to addFunction: "+e);var o=$e(e,t);Xe(r,o)}return Me.set(e,r),r},o.removeFunction=e=>{Me.delete(Ue(e)),Xe(e,null),Ke.push(e)},o.setValue=function(e,t,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":case"i8":b[e]=t;break;case"i16":f[e>>1]=t;break;case"i32":E[e>>2]=t;break;case"i64":$("to do setValue(i64) use WASM_BIGINT");case"float":y[e>>2]=t;break;case"double":G[e>>3]=t;break;case"*":M[e>>2]=t;break;default:$(`invalid type for setValue: ${n}`)}},o.getValue=function(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return b[e];case"i16":return f[e>>1];case"i32":return E[e>>2];case"i64":$("to do getValue(i64) use WASM_BIGINT");case"float":return y[e>>2];case"double":return G[e>>3];case"*":return M[e>>2];default:$(`invalid type for getValue: ${t}`)}},o.UTF8ToString=_e,o.stringToUTF8=Re,o.UTF16ToString=(e,t)=>{C(e%2==0,"Pointer passed to UTF16ToString must be aligned to two bytes!");for(var n=e,r=n>>1,o=r+t/2;!(r>=o)&&A[r];)++r;if((n=r<<1)-e>32&&We)return We.decode(p.subarray(e,n));for(var a="",i=0;!(i>=t/2);++i){var s=f[e+2*i>>1];if(0==s)break;a+=String.fromCharCode(s)}return a},o.stringToUTF16=(e,t,n)=>{if(C(t%2==0,"Pointer passed to stringToUTF16 must be aligned to two bytes!"),C("number"==typeof n,"stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!"),n??=2147483647,n<2)return 0;for(var r=t,o=(n-=2)<2*e.length?n/2:e.length,a=0;a<o;++a){var i=e.charCodeAt(a);f[t>>1]=i,t+=2}return f[t>>1]=0,t-r},["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertU32PairToI53","getTempRet0","setTempRet0","exitJS","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","emscriptenLog","readEmAsmArgs","jstoi_q","listenOnce","autoResumeAudioContext","dynCallLegacy","getDynCaller","dynCall","handleException","keepRuntimeAlive","runtimeKeepalivePush","runtimeKeepalivePop","callUserCallback","maybeExit","asmjsMangle","HandleAllocator","getNativeTypeSize","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","reallyNegative","unSign","strLen","reSign","formatString","intArrayToString","AsciiToString","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","stringToNewUTF8","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","battery","registerBatteryEventCallback","setCanvasElementSize","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","checkWasiClock","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","createDyncallWrapper","safeSetTimeout","setImmediateWrapped","clearImmediateWrapped","polyfillSetImmediate","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","ExceptionInfo","findMatchingCatch","Browser_asyncPrepareDataCounter","safeRequestAnimationFrame","arraySum","addDays","getSocketFromFD","getSocketAddress","FS_unlink","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","setErrNo","demangle","stackTrace"].forEach(function(e){re(e,()=>{var t=`\`${e}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`,n=e;n.startsWith("_")||(n="$"+e),t+=` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${n}')`,ne(e)&&(t+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),Fe(t)}),ae(e)}),["run","addOnPreRun","addOnInit","addOnPreMain","addOnExit","addOnPostRun","addRunDependency","removeRunDependency","out","err","callMain","abort","wasmMemory","writeStackCookie","checkStackCookie","convertI32PairToI53Checked","stackSave","stackRestore","stackAlloc","ptrToString","zeroMemory","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","DNS","Protocols","Sockets","initRandomFill","randomFill","timers","warnOnce","readEmAsmArgsArray","jstoi_s","getExecutableName","asyncLoad","alignMemory","mmapAlloc","wasmTable","noExitRuntime","getCFunc","uleb128Encode","sigToWasmTypes","generateFuncType","convertJsFunctionToWasm","freeTableIndexes","functionsInTableMap","getEmptyTableSlot","updateTableMap","getFunctionAddress","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","stringToUTF8Array","lengthBytesUTF8","intArrayFromString","stringToAscii","UTF16Decoder","stringToUTF8OnStack","writeArrayToMemory","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","doReadv","doWritev","promiseMap","uncaughtExceptionCount","exceptionLast","exceptionCaught","Browser","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","isLeapYear","ydayFromDate","SYSCALLS","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_createPath","FS_createDevice","FS_readFile","FS","FS_createDataFile","FS_createLazyFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","allocateUTF8","allocateUTF8OnStack","print","printErr"].forEach(ae),N=function e(){Ze||lt(),Ze||(N=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();lt(),t=a;for(const t of Object.keys(o))t in e||Object.defineProperty(e,t,{configurable:!0,get(){$(`Access to module property ('${t}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return t});const L={EPDF_GetMetaKeyCount:[["number","boolean"],"number"],EPDF_GetMetaKeyName:[["number","number","boolean","number","number"],"number"],EPDF_GetMetaTrapped:[["number"],"number"],EPDF_GetPageRotationByIndex:[["number","number"],"number"],EPDF_HasMetaText:[["number","string"],"boolean"],EPDF_PNG_EncodeRGBA:[["number","number","number","number","number","number"],"number"],EPDF_RenderAnnotBitmap:[["number","number","number","number","number","number"],"boolean"],EPDF_SetMetaText:[["number","string","number"],"boolean"],EPDF_SetMetaTrapped:[["number","number"],"boolean"],EPDFAction_CreateGoTo:[["number","number"],"number"],EPDFAction_CreateGoToNamed:[["number","string"],"number"],EPDFAction_CreateLaunch:[["number","number"],"number"],EPDFAction_CreateRemoteGoToByName:[["number","number","number"],"number"],EPDFAction_CreateRemoteGoToDest:[["number","number","number"],"number"],EPDFAction_CreateURI:[["number","string"],"number"],EPDFAnnot_ClearColor:[["number","number"],"boolean"],EPDFAnnot_GenerateAppearance:[["number"],"boolean"],EPDFAnnot_GenerateAppearanceWithBlend:[["number","number"],"boolean"],EPDFAnnot_GetBlendMode:[["number"],"number"],EPDFAnnot_GetBorderDashPattern:[["number","number","number"],"boolean"],EPDFAnnot_GetBorderDashPatternCount:[["number"],"number"],EPDFAnnot_GetBorderEffect:[["number","number"],"boolean"],EPDFAnnot_GetBorderStyle:[["number","number"],"number"],EPDFAnnot_GetColor:[["number","number","number","number","number"],"boolean"],EPDFAnnot_GetDefaultAppearance:[["number","number","number","number","number","number"],"boolean"],EPDFAnnot_GetIcon:[["number"],"number"],EPDFAnnot_GetIntent:[["number","number","number"],"number"],EPDFAnnot_GetLineEndings:[["number","number","number"],"boolean"],EPDFAnnot_GetOpacity:[["number","number"],"boolean"],EPDFAnnot_GetRectangleDifferences:[["number","number","number","number","number"],"boolean"],EPDFAnnot_GetRichContent:[["number","number","number"],"number"],EPDFAnnot_GetTextAlignment:[["number"],"number"],EPDFAnnot_GetVerticalAlignment:[["number"],"number"],EPDFAnnot_SetBorderDashPattern:[["number","number","number"],"boolean"],EPDFAnnot_SetBorderStyle:[["number","number","number"],"boolean"],EPDFAnnot_SetColor:[["number","number","number","number","number"],"boolean"],EPDFAnnot_SetDefaultAppearance:[["number","number","number","number","number","number"],"boolean"],EPDFAnnot_SetIcon:[["number","number"],"boolean"],EPDFAnnot_SetIntent:[["number","string"],"boolean"],EPDFAnnot_SetLine:[["number","number","number"],"boolean"],EPDFAnnot_SetLineEndings:[["number","number","number"],"boolean"],EPDFAnnot_SetLinkedAnnot:[["number","string","number"],"boolean"],EPDFAnnot_SetOpacity:[["number","number"],"boolean"],EPDFAnnot_SetTextAlignment:[["number","number"],"boolean"],EPDFAnnot_SetVerticalAlignment:[["number","number"],"boolean"],EPDFAnnot_SetVertices:[["number","number","number"],"boolean"],EPDFAnnot_UpdateAppearanceToRect:[["number","number"],"boolean"],EPDFAttachment_GetDescription:[["number","number","number"],"number"],EPDFAttachment_GetIntegerValue:[["number","string","number"],"boolean"],EPDFAttachment_SetDescription:[["number","number"],"boolean"],EPDFAttachment_SetSubtype:[["number","string"],"boolean"],EPDFBookmark_AppendChild:[["number","number","number"],"number"],EPDFBookmark_Clear:[["number"],"boolean"],EPDFBookmark_ClearTarget:[["number"],"boolean"],EPDFBookmark_Create:[["number","number"],"number"],EPDFBookmark_Delete:[["number","number"],"boolean"],EPDFBookmark_InsertAfter:[["number","number","number","number"],"number"],EPDFBookmark_SetAction:[["number","number","number"],"boolean"],EPDFBookmark_SetDest:[["number","number","number"],"boolean"],EPDFBookmark_SetTitle:[["number","number"],"boolean"],EPDFCatalog_GetLanguage:[["number","number","number"],"number"],EPDFDest_CreateRemoteView:[["number","number","number","number","number"],"number"],EPDFDest_CreateRemoteXYZ:[["number","number","boolean","number","boolean","number","boolean","number"],"number"],EPDFDest_CreateView:[["number","number","number","number"],"number"],EPDFDest_CreateXYZ:[["number","boolean","number","boolean","number","boolean","number"],"number"],EPDFNamedDest_Remove:[["number","string"],"boolean"],EPDFNamedDest_SetDest:[["number","string","number"],"boolean"],EPDFPage_CreateAnnot:[["number","number"],"number"],EPDFPage_GetAnnotByName:[["number","number"],"number"],EPDFPage_GetAnnotCountRaw:[["number","number"],"number"],EPDFPage_GetAnnotRaw:[["number","number","number"],"number"],EPDFPage_RemoveAnnotByName:[["number","number"],"boolean"],EPDFPage_RemoveAnnotRaw:[["number","number","number"],"boolean"],EPDFText_RedactInQuads:[["number","number","number","boolean","boolean"],"boolean"],EPDFText_RedactInRect:[["number","number","boolean","boolean"],"boolean"],FORM_CanRedo:[["number","number"],"boolean"],FORM_CanUndo:[["number","number"],"boolean"],FORM_DoDocumentAAction:[["number","number"],null],FORM_DoDocumentJSAction:[["number"],null],FORM_DoDocumentOpenAction:[["number"],null],FORM_DoPageAAction:[["number","number","number"],null],FORM_ForceToKillFocus:[["number"],"boolean"],FORM_GetFocusedAnnot:[["number","number","number"],"boolean"],FORM_GetFocusedText:[["number","number","number","number"],"number"],FORM_GetSelectedText:[["number","number","number","number"],"number"],FORM_IsIndexSelected:[["number","number","number"],"boolean"],FORM_OnAfterLoadPage:[["number","number"],null],FORM_OnBeforeClosePage:[["number","number"],null],FORM_OnChar:[["number","number","number","number"],"boolean"],FORM_OnFocus:[["number","number","number","number","number"],"boolean"],FORM_OnKeyDown:[["number","number","number","number"],"boolean"],FORM_OnKeyUp:[["number","number","number","number"],"boolean"],FORM_OnLButtonDoubleClick:[["number","number","number","number","number"],"boolean"],FORM_OnLButtonDown:[["number","number","number","number","number"],"boolean"],FORM_OnLButtonUp:[["number","number","number","number","number"],"boolean"],FORM_OnMouseMove:[["number","number","number","number","number"],"boolean"],FORM_OnMouseWheel:[["number","number","number","number","number","number"],"boolean"],FORM_OnRButtonDown:[["number","number","number","number","number"],"boolean"],FORM_OnRButtonUp:[["number","number","number","number","number"],"boolean"],FORM_Redo:[["number","number"],"boolean"],FORM_ReplaceAndKeepSelection:[["number","number","number"],null],FORM_ReplaceSelection:[["number","number","number"],null],FORM_SelectAllText:[["number","number"],"boolean"],FORM_SetFocusedAnnot:[["number","number"],"boolean"],FORM_SetIndexSelected:[["number","number","number","boolean"],"boolean"],FORM_Undo:[["number","number"],"boolean"],FPDF_AddInstalledFont:[["number","number","number"],null],FPDF_CloseDocument:[["number"],null],FPDF_ClosePage:[["number"],null],FPDF_CloseXObject:[["number"],null],FPDF_CopyViewerPreferences:[["number","number"],"boolean"],FPDF_CountNamedDests:[["number"],"number"],FPDF_CreateClipPath:[["number","number","number","number"],"number"],FPDF_CreateNewDocument:[[],"number"],FPDF_DestroyClipPath:[["number"],null],FPDF_DestroyLibrary:[[],null],FPDF_DeviceToPage:[["number","number","number","number","number","number","number","number","number","number"],"boolean"],FPDF_DocumentHasValidCrossReferenceTable:[["number"],"boolean"],FPDF_FFLDraw:[["number","number","number","number","number","number","number","number","number"],null],FPDF_FreeDefaultSystemFontInfo:[["number"],null],FPDF_GetDefaultSystemFontInfo:[[],"number"],FPDF_GetDefaultTTFMap:[[],"number"],FPDF_GetDefaultTTFMapCount:[[],"number"],FPDF_GetDefaultTTFMapEntry:[["number"],"number"],FPDF_GetDocPermissions:[["number"],"number"],FPDF_GetDocUserPermissions:[["number"],"number"],FPDF_GetFileIdentifier:[["number","number","number","number"],"number"],FPDF_GetFileVersion:[["number","number"],"boolean"],FPDF_GetFormType:[["number"],"number"],FPDF_GetLastError:[[],"number"],FPDF_GetMetaText:[["number","string","number","number"],"number"],FPDF_GetNamedDest:[["number","number","number","number"],"number"],FPDF_GetNamedDestByName:[["number","string"],"number"],FPDF_GetPageAAction:[["number","number"],"number"],FPDF_GetPageBoundingBox:[["number","number"],"boolean"],FPDF_GetPageCount:[["number"],"number"],FPDF_GetPageHeight:[["number"],"number"],FPDF_GetPageHeightF:[["number"],"number"],FPDF_GetPageLabel:[["number","number","number","number"],"number"],FPDF_GetPageSizeByIndex:[["number","number","number","number"],"number"],FPDF_GetPageSizeByIndexF:[["number","number","number"],"boolean"],FPDF_GetPageWidth:[["number"],"number"],FPDF_GetPageWidthF:[["number"],"number"],FPDF_GetSecurityHandlerRevision:[["number"],"number"],FPDF_GetSignatureCount:[["number"],"number"],FPDF_GetSignatureObject:[["number","number"],"number"],FPDF_GetTrailerEnds:[["number","number","number"],"number"],FPDF_GetXFAPacketContent:[["number","number","number","number","number"],"boolean"],FPDF_GetXFAPacketCount:[["number"],"number"],FPDF_GetXFAPacketName:[["number","number","number","number"],"number"],FPDF_ImportNPagesToOne:[["number","number","number","number","number"],"number"],FPDF_ImportPages:[["number","number","string","number"],"boolean"],FPDF_ImportPagesByIndex:[["number","number","number","number","number"],"boolean"],FPDF_InitLibrary:[[],null],FPDF_InitLibraryWithConfig:[["number"],null],FPDF_LoadCustomDocument:[["number","string"],"number"],FPDF_LoadDocument:[["number","string"],"number"],FPDF_LoadMemDocument:[["number","number","string"],"number"],FPDF_LoadMemDocument64:[["number","number","string"],"number"],FPDF_LoadPage:[["number","number"],"number"],FPDF_LoadXFA:[["number"],"boolean"],FPDF_MovePages:[["number","number","number","number"],"boolean"],FPDF_NewFormObjectFromXObject:[["number"],"number"],FPDF_NewXObjectFromPage:[["number","number","number"],"number"],FPDF_PageToDevice:[["number","number","number","number","number","number","number","number","number","number"],"boolean"],FPDF_RemoveFormFieldHighlight:[["number"],null],FPDF_RenderPage_Close:[["number"],null],FPDF_RenderPage_Continue:[["number","number"],"number"],FPDF_RenderPageBitmap:[["number","number","number","number","number","number","number","number"],null],FPDF_RenderPageBitmap_Start:[["number","number","number","number","number","number","number","number","number"],"number"],FPDF_RenderPageBitmapWithColorScheme_Start:[["number","number","number","number","number","number","number","number","number","number"],"number"],FPDF_RenderPageBitmapWithMatrix:[["number","number","number","number","number"],null],FPDF_SaveAsCopy:[["number","number","number"],"boolean"],FPDF_SaveWithVersion:[["number","number","number","number"],"boolean"],FPDF_SetFormFieldHighlightAlpha:[["number","number"],null],FPDF_SetFormFieldHighlightColor:[["number","number","number"],null],FPDF_SetSandBoxPolicy:[["number","boolean"],null],FPDF_SetSystemFontInfo:[["number"],null],FPDF_StructElement_Attr_CountChildren:[["number"],"number"],FPDF_StructElement_Attr_GetBlobValue:[["number","number","number","number"],"boolean"],FPDF_StructElement_Attr_GetBooleanValue:[["number","number"],"boolean"],FPDF_StructElement_Attr_GetChildAtIndex:[["number","number"],"number"],FPDF_StructElement_Attr_GetCount:[["number"],"number"],FPDF_StructElement_Attr_GetName:[["number","number","number","number","number"],"boolean"],FPDF_StructElement_Attr_GetNumberValue:[["number","number"],"boolean"],FPDF_StructElement_Attr_GetStringValue:[["number","number","number","number"],"boolean"],FPDF_StructElement_Attr_GetType:[["number"],"number"],FPDF_StructElement_Attr_GetValue:[["number","string"],"number"],FPDF_StructElement_CountChildren:[["number"],"number"],FPDF_StructElement_GetActualText:[["number","number","number"],"number"],FPDF_StructElement_GetAltText:[["number","number","number"],"number"],FPDF_StructElement_GetAttributeAtIndex:[["number","number"],"number"],FPDF_StructElement_GetAttributeCount:[["number"],"number"],FPDF_StructElement_GetChildAtIndex:[["number","number"],"number"],FPDF_StructElement_GetChildMarkedContentID:[["number","number"],"number"],FPDF_StructElement_GetID:[["number","number","number"],"number"],FPDF_StructElement_GetLang:[["number","number","number"],"number"],FPDF_StructElement_GetMarkedContentID:[["number"],"number"],FPDF_StructElement_GetMarkedContentIdAtIndex:[["number","number"],"number"],FPDF_StructElement_GetMarkedContentIdCount:[["number"],"number"],FPDF_StructElement_GetObjType:[["number","number","number"],"number"],FPDF_StructElement_GetParent:[["number"],"number"],FPDF_StructElement_GetStringAttribute:[["number","string","number","number"],"number"],FPDF_StructElement_GetTitle:[["number","number","number"],"number"],FPDF_StructElement_GetType:[["number","number","number"],"number"],FPDF_StructTree_Close:[["number"],null],FPDF_StructTree_CountChildren:[["number"],"number"],FPDF_StructTree_GetChildAtIndex:[["number","number"],"number"],FPDF_StructTree_GetForPage:[["number"],"number"],FPDF_VIEWERREF_GetDuplex:[["number"],"number"],FPDF_VIEWERREF_GetName:[["number","string","number","number"],"number"],FPDF_VIEWERREF_GetNumCopies:[["number"],"number"],FPDF_VIEWERREF_GetPrintPageRange:[["number"],"number"],FPDF_VIEWERREF_GetPrintPageRangeCount:[["number"],"number"],FPDF_VIEWERREF_GetPrintPageRangeElement:[["number","number"],"number"],FPDF_VIEWERREF_GetPrintScaling:[["number"],"boolean"],FPDFAction_GetDest:[["number","number"],"number"],FPDFAction_GetFilePath:[["number","number","number"],"number"],FPDFAction_GetType:[["number"],"number"],FPDFAction_GetURIPath:[["number","number","number","number"],"number"],FPDFAnnot_AddFileAttachment:[["number","number"],"number"],FPDFAnnot_AddInkStroke:[["number","number","number"],"number"],FPDFAnnot_AppendAttachmentPoints:[["number","number"],"boolean"],FPDFAnnot_AppendObject:[["number","number"],"boolean"],FPDFAnnot_CountAttachmentPoints:[["number"],"number"],FPDFAnnot_GetAP:[["number","number","number","number"],"number"],FPDFAnnot_GetAttachmentPoints:[["number","number","number"],"boolean"],FPDFAnnot_GetBorder:[["number","number","number","number"],"boolean"],FPDFAnnot_GetColor:[["number","number","number","number","number","number"],"boolean"],FPDFAnnot_GetFileAttachment:[["number"],"number"],FPDFAnnot_GetFlags:[["number"],"number"],FPDFAnnot_GetFocusableSubtypes:[["number","number","number"],"boolean"],FPDFAnnot_GetFocusableSubtypesCount:[["number"],"number"],FPDFAnnot_GetFontColor:[["number","number","number","number","number"],"boolean"],FPDFAnnot_GetFontSize:[["number","number","number"],"boolean"],FPDFAnnot_GetFormAdditionalActionJavaScript:[["number","number","number","number","number"],"number"],FPDFAnnot_GetFormControlCount:[["number","number"],"number"],FPDFAnnot_GetFormControlIndex:[["number","number"],"number"],FPDFAnnot_GetFormFieldAlternateName:[["number","number","number","number"],"number"],FPDFAnnot_GetFormFieldAtPoint:[["number","number","number"],"number"],FPDFAnnot_GetFormFieldExportValue:[["number","number","number","number"],"number"],FPDFAnnot_GetFormFieldFlags:[["number","number"],"number"],FPDFAnnot_GetFormFieldName:[["number","number","number","number"],"number"],FPDFAnnot_GetFormFieldType:[["number","number"],"number"],FPDFAnnot_GetFormFieldValue:[["number","number","number","number"],"number"],FPDFAnnot_GetInkListCount:[["number"],"number"],FPDFAnnot_GetInkListPath:[["number","number","number","number"],"number"],FPDFAnnot_GetLine:[["number","number","number"],"boolean"],FPDFAnnot_GetLink:[["number"],"number"],FPDFAnnot_GetLinkedAnnot:[["number","string"],"number"],FPDFAnnot_GetNumberValue:[["number","string","number"],"boolean"],FPDFAnnot_GetObject:[["number","number"],"number"],FPDFAnnot_GetObjectCount:[["number"],"number"],FPDFAnnot_GetOptionCount:[["number","number"],"number"],FPDFAnnot_GetOptionLabel:[["number","number","number","number","number"],"number"],FPDFAnnot_GetRect:[["number","number"],"boolean"],FPDFAnnot_GetStringValue:[["number","string","number","number"],"number"],FPDFAnnot_GetSubtype:[["number"],"number"],FPDFAnnot_GetValueType:[["number","string"],"number"],FPDFAnnot_GetVertices:[["number","number","number"],"number"],FPDFAnnot_HasAttachmentPoints:[["number"],"boolean"],FPDFAnnot_HasKey:[["number","string"],"boolean"],FPDFAnnot_IsChecked:[["number","number"],"boolean"],FPDFAnnot_IsObjectSupportedSubtype:[["number"],"boolean"],FPDFAnnot_IsOptionSelected:[["number","number","number"],"boolean"],FPDFAnnot_IsSupportedSubtype:[["number"],"boolean"],FPDFAnnot_RemoveInkList:[["number"],"boolean"],FPDFAnnot_RemoveObject:[["number","number"],"boolean"],FPDFAnnot_SetAP:[["number","number","number"],"boolean"],FPDFAnnot_SetAttachmentPoints:[["number","number","number"],"boolean"],FPDFAnnot_SetBorder:[["number","number","number","number"],"boolean"],FPDFAnnot_SetColor:[["number","number","number","number","number","number"],"boolean"],FPDFAnnot_SetFlags:[["number","number"],"boolean"],FPDFAnnot_SetFocusableSubtypes:[["number","number","number"],"boolean"],FPDFAnnot_SetFontColor:[["number","number","number","number","number"],"boolean"],FPDFAnnot_SetFormFieldFlags:[["number","number","number"],"boolean"],FPDFAnnot_SetRect:[["number","number"],"boolean"],FPDFAnnot_SetStringValue:[["number","string","number"],"boolean"],FPDFAnnot_SetURI:[["number","number"],"boolean"],FPDFAnnot_UpdateObject:[["number","number"],"boolean"],FPDFAttachment_GetFile:[["number","number","number","number"],"boolean"],FPDFAttachment_GetName:[["number","number","number"],"number"],FPDFAttachment_GetStringValue:[["number","string","number","number"],"number"],FPDFAttachment_GetSubtype:[["number","number","number"],"number"],FPDFAttachment_GetValueType:[["number","string"],"number"],FPDFAttachment_HasKey:[["number","string"],"boolean"],FPDFAttachment_SetFile:[["number","number","number","number"],"boolean"],FPDFAttachment_SetStringValue:[["number","string","number"],"boolean"],FPDFAvail_Create:[["number","number"],"number"],FPDFAvail_Destroy:[["number"],null],FPDFAvail_GetDocument:[["number","string"],"number"],FPDFAvail_GetFirstPageNum:[["number"],"number"],FPDFAvail_IsDocAvail:[["number","number"],"number"],FPDFAvail_IsFormAvail:[["number","number"],"number"],FPDFAvail_IsLinearized:[["number"],"number"],FPDFAvail_IsPageAvail:[["number","number","number"],"number"],FPDFBitmap_Create:[["number","number","number"],"number"],FPDFBitmap_CreateEx:[["number","number","number","number","number"],"number"],FPDFBitmap_Destroy:[["number"],null],FPDFBitmap_FillRect:[["number","number","number","number","number","number"],"boolean"],FPDFBitmap_GetBuffer:[["number"],"number"],FPDFBitmap_GetFormat:[["number"],"number"],FPDFBitmap_GetHeight:[["number"],"number"],FPDFBitmap_GetStride:[["number"],"number"],FPDFBitmap_GetWidth:[["number"],"number"],FPDFBookmark_Find:[["number","number"],"number"],FPDFBookmark_GetAction:[["number"],"number"],FPDFBookmark_GetCount:[["number"],"number"],FPDFBookmark_GetDest:[["number","number"],"number"],FPDFBookmark_GetFirstChild:[["number","number"],"number"],FPDFBookmark_GetNextSibling:[["number","number"],"number"],FPDFBookmark_GetTitle:[["number","number","number"],"number"],FPDFCatalog_IsTagged:[["number"],"boolean"],FPDFCatalog_SetLanguage:[["number","string"],"boolean"],FPDFClipPath_CountPaths:[["number"],"number"],FPDFClipPath_CountPathSegments:[["number","number"],"number"],FPDFClipPath_GetPathSegment:[["number","number","number"],"number"],FPDFDest_GetDestPageIndex:[["number","number"],"number"],FPDFDest_GetLocationInPage:[["number","number","number","number","number","number","number"],"boolean"],FPDFDest_GetView:[["number","number","number"],"number"],FPDFDoc_AddAttachment:[["number","number"],"number"],FPDFDoc_CloseJavaScriptAction:[["number"],null],FPDFDoc_DeleteAttachment:[["number","number"],"boolean"],FPDFDOC_ExitFormFillEnvironment:[["number"],null],FPDFDoc_GetAttachment:[["number","number"],"number"],FPDFDoc_GetAttachmentCount:[["number"],"number"],FPDFDoc_GetJavaScriptAction:[["number","number"],"number"],FPDFDoc_GetJavaScriptActionCount:[["number"],"number"],FPDFDoc_GetPageMode:[["number"],"number"],FPDFDOC_InitFormFillEnvironment:[["number","number"],"number"],FPDFFont_Close:[["number"],null],FPDFFont_GetAscent:[["number","number","number"],"boolean"],FPDFFont_GetBaseFontName:[["number","number","number"],"number"],FPDFFont_GetDescent:[["number","number","number"],"boolean"],FPDFFont_GetFamilyName:[["number","number","number"],"number"],FPDFFont_GetFlags:[["number"],"number"],FPDFFont_GetFontData:[["number","number","number","number"],"boolean"],FPDFFont_GetGlyphPath:[["number","number","number"],"number"],FPDFFont_GetGlyphWidth:[["number","number","number","number"],"boolean"],FPDFFont_GetIsEmbedded:[["number"],"number"],FPDFFont_GetItalicAngle:[["number","number"],"boolean"],FPDFFont_GetWeight:[["number"],"number"],FPDFFormObj_CountObjects:[["number"],"number"],FPDFFormObj_GetObject:[["number","number"],"number"],FPDFFormObj_RemoveObject:[["number","number"],"boolean"],FPDFGlyphPath_CountGlyphSegments:[["number"],"number"],FPDFGlyphPath_GetGlyphPathSegment:[["number","number"],"number"],FPDFImageObj_GetBitmap:[["number"],"number"],FPDFImageObj_GetIccProfileDataDecoded:[["number","number","number","number","number"],"boolean"],FPDFImageObj_GetImageDataDecoded:[["number","number","number"],"number"],FPDFImageObj_GetImageDataRaw:[["number","number","number"],"number"],FPDFImageObj_GetImageFilter:[["number","number","number","number"],"number"],FPDFImageObj_GetImageFilterCount:[["number"],"number"],FPDFImageObj_GetImageMetadata:[["number","number","number"],"boolean"],FPDFImageObj_GetImagePixelSize:[["number","number","number"],"boolean"],FPDFImageObj_GetRenderedBitmap:[["number","number","number"],"number"],FPDFImageObj_LoadJpegFile:[["number","number","number","number"],"boolean"],FPDFImageObj_LoadJpegFileInline:[["number","number","number","number"],"boolean"],FPDFImageObj_SetBitmap:[["number","number","number","number"],"boolean"],FPDFImageObj_SetMatrix:[["number","number","number","number","number","number","number"],"boolean"],FPDFJavaScriptAction_GetName:[["number","number","number"],"number"],FPDFJavaScriptAction_GetScript:[["number","number","number"],"number"],FPDFLink_CloseWebLinks:[["number"],null],FPDFLink_CountQuadPoints:[["number"],"number"],FPDFLink_CountRects:[["number","number"],"number"],FPDFLink_CountWebLinks:[["number"],"number"],FPDFLink_Enumerate:[["number","number","number"],"boolean"],FPDFLink_GetAction:[["number"],"number"],FPDFLink_GetAnnot:[["number","number"],"number"],FPDFLink_GetAnnotRect:[["number","number"],"boolean"],FPDFLink_GetDest:[["number","number"],"number"],FPDFLink_GetLinkAtPoint:[["number","number","number"],"number"],FPDFLink_GetLinkZOrderAtPoint:[["number","number","number"],"number"],FPDFLink_GetQuadPoints:[["number","number","number"],"boolean"],FPDFLink_GetRect:[["number","number","number","number","number","number","number"],"boolean"],FPDFLink_GetTextRange:[["number","number","number","number"],"boolean"],FPDFLink_GetURL:[["number","number","number","number"],"number"],FPDFLink_LoadWebLinks:[["number"],"number"],FPDFPage_CloseAnnot:[["number"],null],FPDFPage_CountObjects:[["number"],"number"],FPDFPage_CreateAnnot:[["number","number"],"number"],FPDFPage_Delete:[["number","number"],null],FPDFPage_Flatten:[["number","number"],"number"],FPDFPage_FormFieldZOrderAtPoint:[["number","number","number","number"],"number"],FPDFPage_GenerateContent:[["number"],"boolean"],FPDFPage_GetAnnot:[["number","number"],"number"],FPDFPage_GetAnnotCount:[["number"],"number"],FPDFPage_GetAnnotIndex:[["number","number"],"number"],FPDFPage_GetArtBox:[["number","number","number","number","number"],"boolean"],FPDFPage_GetBleedBox:[["number","number","number","number","number"],"boolean"],FPDFPage_GetCropBox:[["number","number","number","number","number"],"boolean"],FPDFPage_GetDecodedThumbnailData:[["number","number","number"],"number"],FPDFPage_GetMediaBox:[["number","number","number","number","number"],"boolean"],FPDFPage_GetObject:[["number","number"],"number"],FPDFPage_GetRawThumbnailData:[["number","number","number"],"number"],FPDFPage_GetRotation:[["number"],"number"],FPDFPage_GetThumbnailAsBitmap:[["number"],"number"],FPDFPage_GetTrimBox:[["number","number","number","number","number"],"boolean"],FPDFPage_HasFormFieldAtPoint:[["number","number","number","number"],"number"],FPDFPage_HasTransparency:[["number"],"boolean"],FPDFPage_InsertClipPath:[["number","number"],null],FPDFPage_InsertObject:[["number","number"],null],FPDFPage_InsertObjectAtIndex:[["number","number","number"],"boolean"],FPDFPage_New:[["number","number","number","number"],"number"],FPDFPage_RemoveAnnot:[["number","number"],"boolean"],FPDFPage_RemoveObject:[["number","number"],"boolean"],FPDFPage_SetArtBox:[["number","number","number","number","number"],null],FPDFPage_SetBleedBox:[["number","number","number","number","number"],null],FPDFPage_SetCropBox:[["number","number","number","number","number"],null],FPDFPage_SetMediaBox:[["number","number","number","number","number"],null],FPDFPage_SetRotation:[["number","number"],null],FPDFPage_SetTrimBox:[["number","number","number","number","number"],null],FPDFPage_TransformAnnots:[["number","number","number","number","number","number","number"],null],FPDFPage_TransFormWithClip:[["number","number","number"],"boolean"],FPDFPageObj_AddMark:[["number","string"],"number"],FPDFPageObj_CountMarks:[["number"],"number"],FPDFPageObj_CreateNewPath:[["number","number"],"number"],FPDFPageObj_CreateNewRect:[["number","number","number","number"],"number"],FPDFPageObj_CreateTextObj:[["number","number","number"],"number"],FPDFPageObj_Destroy:[["number"],null],FPDFPageObj_GetBounds:[["number","number","number","number","number"],"boolean"],FPDFPageObj_GetClipPath:[["number"],"number"],FPDFPageObj_GetDashArray:[["number","number","number"],"boolean"],FPDFPageObj_GetDashCount:[["number"],"number"],FPDFPageObj_GetDashPhase:[["number","number"],"boolean"],FPDFPageObj_GetFillColor:[["number","number","number","number","number"],"boolean"],FPDFPageObj_GetIsActive:[["number","number"],"boolean"],FPDFPageObj_GetLineCap:[["number"],"number"],FPDFPageObj_GetLineJoin:[["number"],"number"],FPDFPageObj_GetMark:[["number","number"],"number"],FPDFPageObj_GetMarkedContentID:[["number"],"number"],FPDFPageObj_GetMatrix:[["number","number"],"boolean"],FPDFPageObj_GetRotatedBounds:[["number","number"],"boolean"],FPDFPageObj_GetStrokeColor:[["number","number","number","number","number"],"boolean"],FPDFPageObj_GetStrokeWidth:[["number","number"],"boolean"],FPDFPageObj_GetType:[["number"],"number"],FPDFPageObj_HasTransparency:[["number"],"boolean"],FPDFPageObj_NewImageObj:[["number"],"number"],FPDFPageObj_NewTextObj:[["number","string","number"],"number"],FPDFPageObj_RemoveMark:[["number","number"],"boolean"],FPDFPageObj_SetBlendMode:[["number","string"],null],FPDFPageObj_SetDashArray:[["number","number","number","number"],"boolean"],FPDFPageObj_SetDashPhase:[["number","number"],"boolean"],FPDFPageObj_SetFillColor:[["number","number","number","number","number"],"boolean"],FPDFPageObj_SetIsActive:[["number","boolean"],"boolean"],FPDFPageObj_SetLineCap:[["number","number"],"boolean"],FPDFPageObj_SetLineJoin:[["number","number"],"boolean"],FPDFPageObj_SetMatrix:[["number","number"],"boolean"],FPDFPageObj_SetStrokeColor:[["number","number","number","number","number"],"boolean"],FPDFPageObj_SetStrokeWidth:[["number","number"],"boolean"],FPDFPageObj_Transform:[["number","number","number","number","number","number","number"],null],FPDFPageObj_TransformClipPath:[["number","number","number","number","number","number","number"],null],FPDFPageObj_TransformF:[["number","number"],"boolean"],FPDFPageObjMark_CountParams:[["number"],"number"],FPDFPageObjMark_GetName:[["number","number","number","number"],"boolean"],FPDFPageObjMark_GetParamBlobValue:[["number","string","number","number","number"],"boolean"],FPDFPageObjMark_GetParamIntValue:[["number","string","number"],"boolean"],FPDFPageObjMark_GetParamKey:[["number","number","number","number","number"],"boolean"],FPDFPageObjMark_GetParamStringValue:[["number","string","number","number","number"],"boolean"],FPDFPageObjMark_GetParamValueType:[["number","string"],"number"],FPDFPageObjMark_RemoveParam:[["number","number","string"],"boolean"],FPDFPageObjMark_SetBlobParam:[["number","number","number","string","number","number"],"boolean"],FPDFPageObjMark_SetIntParam:[["number","number","number","string","number"],"boolean"],FPDFPageObjMark_SetStringParam:[["number","number","number","string","string"],"boolean"],FPDFPath_BezierTo:[["number","number","number","number","number","number","number"],"boolean"],FPDFPath_Close:[["number"],"boolean"],FPDFPath_CountSegments:[["number"],"number"],FPDFPath_GetDrawMode:[["number","number","number"],"boolean"],FPDFPath_GetPathSegment:[["number","number"],"number"],FPDFPath_LineTo:[["number","number","number"],"boolean"],FPDFPath_MoveTo:[["number","number","number"],"boolean"],FPDFPath_SetDrawMode:[["number","number","boolean"],"boolean"],FPDFPathSegment_GetClose:[["number"],"boolean"],FPDFPathSegment_GetPoint:[["number","number","number"],"boolean"],FPDFPathSegment_GetType:[["number"],"number"],FPDFSignatureObj_GetByteRange:[["number","number","number"],"number"],FPDFSignatureObj_GetContents:[["number","number","number"],"number"],FPDFSignatureObj_GetDocMDPPermission:[["number"],"number"],FPDFSignatureObj_GetReason:[["number","number","number"],"number"],FPDFSignatureObj_GetSubFilter:[["number","number","number"],"number"],FPDFSignatureObj_GetTime:[["number","number","number"],"number"],FPDFText_ClosePage:[["number"],null],FPDFText_CountChars:[["number"],"number"],FPDFText_CountRects:[["number","number","number"],"number"],FPDFText_FindClose:[["number"],null],FPDFText_FindNext:[["number"],"boolean"],FPDFText_FindPrev:[["number"],"boolean"],FPDFText_FindStart:[["number","number","number","number"],"number"],FPDFText_GetBoundedText:[["number","number","number","number","number","number","number"],"number"],FPDFText_GetCharAngle:[["number","number"],"number"],FPDFText_GetCharBox:[["number","number","number","number","number","number"],"boolean"],FPDFText_GetCharIndexAtPos:[["number","number","number","number","number"],"number"],FPDFText_GetCharIndexFromTextIndex:[["number","number"],"number"],FPDFText_GetCharOrigin:[["number","number","number","number"],"boolean"],FPDFText_GetFillColor:[["number","number","number","number","number","number"],"boolean"],FPDFText_GetFontInfo:[["number","number","number","number","number"],"number"],FPDFText_GetFontSize:[["number","number"],"number"],FPDFText_GetFontWeight:[["number","number"],"number"],FPDFText_GetLooseCharBox:[["number","number","number"],"boolean"],FPDFText_GetMatrix:[["number","number","number"],"boolean"],FPDFText_GetRect:[["number","number","number","number","number","number"],"boolean"],FPDFText_GetSchCount:[["number"],"number"],FPDFText_GetSchResultIndex:[["number"],"number"],FPDFText_GetStrokeColor:[["number","number","number","number","number","number"],"boolean"],FPDFText_GetText:[["number","number","number","number"],"number"],FPDFText_GetTextIndexFromCharIndex:[["number","number"],"number"],FPDFText_GetTextObject:[["number","number"],"number"],FPDFText_GetUnicode:[["number","number"],"number"],FPDFText_HasUnicodeMapError:[["number","number"],"number"],FPDFText_IsGenerated:[["number","number"],"number"],FPDFText_IsHyphen:[["number","number"],"number"],FPDFText_LoadCidType2Font:[["number","number","number","string","number","number"],"number"],FPDFText_LoadFont:[["number","number","number","number","boolean"],"number"],FPDFText_LoadPage:[["number"],"number"],FPDFText_LoadStandardFont:[["number","string"],"number"],FPDFText_SetCharcodes:[["number","number","number"],"boolean"],FPDFText_SetText:[["number","number"],"boolean"],FPDFTextObj_GetFont:[["number"],"number"],FPDFTextObj_GetFontSize:[["number","number"],"boolean"],FPDFTextObj_GetRenderedBitmap:[["number","number","number","number"],"number"],FPDFTextObj_GetText:[["number","number","number","number"],"number"],FPDFTextObj_GetTextRenderMode:[["number"],"number"],FPDFTextObj_SetTextRenderMode:[["number","number"],"boolean"],PDFiumExt_CloseFileWriter:[["number"],null],PDFiumExt_CloseFormFillInfo:[["number"],null],PDFiumExt_ExitFormFillEnvironment:[["number"],null],PDFiumExt_GetFileWriterData:[["number","number","number"],"number"],PDFiumExt_GetFileWriterSize:[["number"],"number"],PDFiumExt_Init:[[],null],PDFiumExt_InitFormFillEnvironment:[["number","number"],"number"],PDFiumExt_OpenFileWriter:[[],"number"],PDFiumExt_OpenFormFillInfo:[[],"number"],PDFiumExt_SaveAsCopy:[["number","number"],"number"]};async function N(e){return async function(e){const t={pdfium:e};for(const n in L){const r=n,o=L[r][0],a=L[r][1];t[r]=e.cwrap(n,a,o)}return t}(await B(e))}function V(e,t,n,r=100){let o=e.wasmExports.malloc(r);for(let t=0;t<r;t++)e.HEAP8[o+t]=0;const a=t(o,r);let i;if(a>r){e.wasmExports.free(o),o=e.wasmExports.malloc(a);for(let t=0;t<a;t++)e.HEAP8[o+t]=0;t(o,a),i=n(o)}else i=n(o);return e.wasmExports.free(o),i}function U(e,t){const n=t(0,0),r=e.wasmExports.malloc(n);t(r,n);const o=new ArrayBuffer(n),a=new DataView(o);for(let t=0;t<n;t++)a.setInt8(t,e.getValue(r+t,"i8"));return e.wasmExports.free(r),o}const W=new Set(["Title","Author","Subject","Keywords","Producer","Creator","CreationDate","ModDate","Trapped"]);function z(e){if(!e||e.length>127)return!1;if(W.has(e))return!1;if("/"===e[0])return!1;for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(n<32||n>126)return!1}return!0}const $={pageTtl:5e3,maxPagesPerDocument:10};class H{constructor(e,t,n={}){this.pdfium=e,this.memoryManager=t,this.docs=new Map,this.config={...$,...n}}setDocument(e,t,n){let r=this.docs.get(e);r||(r=new K(t,n,this.pdfium,this.memoryManager,this.config),this.docs.set(e,r))}getContext(e){return this.docs.get(e)}closeDocument(e){const t=this.docs.get(e);return!!t&&(t.dispose(),this.docs.delete(e),!0)}closeAllDocuments(){for(const e of this.docs.values())e.dispose();this.docs.clear()}updateConfig(e){Object.assign(this.config,e);for(const e of this.docs.values())e.updateConfig(this.config)}getCacheStats(){const e={};let t=0;for(const[n,r]of this.docs.entries()){const o=r.getCacheSize();e[n]=o,t+=o}return{documents:this.docs.size,totalPages:t,pagesByDocument:e}}}class K{constructor(e,t,n,r,o){this.filePtr=e,this.docPtr=t,this.memoryManager=r,this.pageCache=new X(n,t,o)}acquirePage(e){return this.pageCache.acquire(e)}borrowPage(e,t){return this.pageCache.borrowPage(e,t)}updateConfig(e){this.pageCache.updateConfig(e)}getCacheSize(){return this.pageCache.size()}dispose(){this.pageCache.forceReleaseAll(),this.pageCache.pdf.FPDF_CloseDocument(this.docPtr),this.memoryManager.free(this.filePtr)}}class X{constructor(e,t,n){this.pdf=e,this.docPtr=t,this.cache=new Map,this.accessOrder=[],this.config=n}acquire(e){let t=this.cache.get(e);if(!t){this.evictIfNeeded();const n=this.pdf.FPDF_LoadPage(this.docPtr,e);t=new Y(this.pdf,this.docPtr,e,n,this.config.pageTtl,()=>{this.cache.delete(e),this.removeFromAccessOrder(e)}),this.cache.set(e,t)}return this.updateAccessOrder(e),t.clearExpiryTimer(),t.bumpRefCount(),t}borrowPage(e,t){const n=this.cache.has(e),r=this.acquire(e);try{return t(r)}finally{n?r.release():r.disposeImmediate()}}forceReleaseAll(){for(const e of this.cache.values())e.disposeImmediate();this.cache.clear(),this.accessOrder.length=0}updateConfig(e){this.config=e;for(const t of this.cache.values())t.updateTtl(e.pageTtl);this.evictIfNeeded()}size(){return this.cache.size}evictIfNeeded(){for(;this.cache.size>=this.config.maxPagesPerDocument;){const e=this.accessOrder[0];if(void 0===e)break;{const t=this.cache.get(e);if(t){if(0!==t.getRefCount())break;t.disposeImmediate()}else this.removeFromAccessOrder(e)}}}updateAccessOrder(e){this.removeFromAccessOrder(e),this.accessOrder.push(e)}removeFromAccessOrder(e){const t=this.accessOrder.indexOf(e);t>-1&&this.accessOrder.splice(t,1)}}class Y{constructor(e,t,n,r,o,a){this.pdf=e,this.docPtr=t,this.pageIdx=n,this.pagePtr=r,this.onFinalDispose=a,this.refCount=0,this.disposed=!1,this.ttl=o}bumpRefCount(){if(this.disposed)throw new Error("Context already disposed");this.refCount++}getRefCount(){return this.refCount}clearExpiryTimer(){this.expiryTimer&&(clearTimeout(this.expiryTimer),this.expiryTimer=void 0)}updateTtl(e){this.ttl=e,this.expiryTimer&&0===this.refCount&&(this.clearExpiryTimer(),this.expiryTimer=setTimeout(()=>this.disposeImmediate(),this.ttl))}release(){this.disposed||(this.refCount--,0===this.refCount&&(this.expiryTimer=setTimeout(()=>this.disposeImmediate(),this.ttl)))}disposeImmediate(){this.disposed||(this.disposed=!0,this.clearExpiryTimer(),void 0!==this.textPagePtr&&this.pdf.FPDFText_ClosePage(this.textPagePtr),void 0!==this.formHandle&&(this.pdf.FORM_OnBeforeClosePage(this.pagePtr,this.formHandle),this.pdf.PDFiumExt_ExitFormFillEnvironment(this.formHandle)),void 0!==this.formInfoPtr&&this.pdf.PDFiumExt_CloseFormFillInfo(this.formInfoPtr),this.pdf.FPDF_ClosePage(this.pagePtr),this.onFinalDispose())}getTextPage(){return this.ensureAlive(),void 0===this.textPagePtr&&(this.textPagePtr=this.pdf.FPDFText_LoadPage(this.pagePtr)),this.textPagePtr}getFormHandle(){return this.ensureAlive(),void 0===this.formHandle&&(this.formInfoPtr=this.pdf.PDFiumExt_OpenFormFillInfo(),this.formHandle=this.pdf.PDFiumExt_InitFormFillEnvironment(this.docPtr,this.formInfoPtr),this.pdf.FORM_OnAfterLoadPage(this.pagePtr,this.formHandle)),this.formHandle}withAnnotation(e,t){this.ensureAlive();const n=this.pdf.FPDFPage_GetAnnot(this.pagePtr,e);try{return t(n)}finally{this.pdf.FPDFPage_CloseAnnot(n)}}ensureAlive(){if(this.disposed)throw new Error("PageContext already disposed")}}const J={MAX_TOTAL_MEMORY:2147483648},q="PDFiumEngine",Q="MemoryManager";class Z{constructor(e,t){this.pdfiumModule=e,this.logger=t,this.allocations=new Map,this.totalAllocated=0}malloc(e){if(this.totalAllocated+e>J.MAX_TOTAL_MEMORY)throw new Error(`Total memory usage would exceed limit: ${this.totalAllocated+e} > ${J.MAX_TOTAL_MEMORY}`);const t=this.pdfiumModule.pdfium.wasmExports.malloc(e);if(!t)throw new Error(`Failed to allocate ${e} bytes`);const n={ptr:t,size:e,timestamp:Date.now(),stack:this.logger.isEnabled("debug")?(new Error).stack:void 0};return this.allocations.set(t,n),this.totalAllocated+=e,t}free(e){const t=this.allocations.get(e);t?(this.totalAllocated-=t.size,this.allocations.delete(e)):this.logger.warn(q,Q,`Freeing untracked pointer: ${e}`),this.pdfiumModule.pdfium.wasmExports.free(e)}getStats(){return{totalAllocated:this.totalAllocated,allocationCount:this.allocations.size,allocations:this.logger.isEnabled("debug")?Array.from(this.allocations.values()):[]}}checkLeaks(){if(this.allocations.size>0){this.logger.warn(q,Q,`Potential memory leak: ${this.allocations.size} unfreed allocations`);for(const[e,t]of this.allocations)this.logger.warn(q,Q,` - ${e}: ${t.size} bytes`,t.stack)}}}const ee="PDFiumEngine",te="Engine";class ne{constructor(e,t={}){this.pdfiumModule=e,this.memoryLeakCheckInterval=null;const{logger:n=new O}=t;this.logger=n,this.memoryManager=new Z(this.pdfiumModule,this.logger),this.cache=new H(this.pdfiumModule,this.memoryManager),this.logger.isEnabled("debug")&&(this.memoryLeakCheckInterval=setInterval(()=>{this.memoryManager.checkLeaks()},1e4))}initialize(){return this.logger.debug(ee,te,"initialize"),this.logger.perf(ee,te,"Initialize","Begin","General"),this.pdfiumModule.PDFiumExt_Init(),this.logger.perf(ee,te,"Initialize","End","General"),e.resolve(!0)}destroy(){return this.logger.debug(ee,te,"destroy"),this.logger.perf(ee,te,"Destroy","Begin","General"),this.pdfiumModule.FPDF_DestroyLibrary(),this.memoryLeakCheckInterval&&(clearInterval(this.memoryLeakCheckInterval),this.memoryLeakCheckInterval=null),this.logger.perf(ee,te,"Destroy","End","General"),e.resolve(!0)}withWString(e,t){const n=2*(e.length+1),r=this.memoryManager.malloc(n);try{return this.pdfiumModule.pdfium.stringToUTF16(e,r,n),t(r)}finally{this.memoryManager.free(r)}}withFloatArray(e,t){const n=e??[],r=4*n.length,o=r?this.memoryManager.malloc(r):0;try{if(r)for(let e=0;e<n.length;e++)this.pdfiumModule.pdfium.setValue(o+4*e,n[e],"float");return t(o,n.length)}finally{r&&this.memoryManager.free(o)}}openDocumentBuffer(t,n){this.logger.debug(ee,te,"openDocumentBuffer",t,n),this.logger.perf(ee,te,"OpenDocumentBuffer","Begin",t.id);const r=new Uint8Array(t.content),o=r.length,a=this.memoryManager.malloc(o);this.pdfiumModule.pdfium.HEAPU8.set(r,a);const i=this.pdfiumModule.FPDF_LoadMemDocument(a,o,(null==n?void 0:n.password)??"");if(!i){const n=this.pdfiumModule.FPDF_GetLastError();return this.logger.error(ee,te,`FPDF_LoadMemDocument failed with ${n}`),this.memoryManager.free(a),this.logger.perf(ee,te,"OpenDocumentBuffer","End",t.id),e.reject({code:n,message:"FPDF_LoadMemDocument failed"})}const s=this.pdfiumModule.FPDF_GetPageCount(i),u=[],m=this.memoryManager.malloc(8);for(let n=0;n<s;n++){if(!this.pdfiumModule.FPDF_GetPageSizeByIndexF(i,n,m)){const n=this.pdfiumModule.FPDF_GetLastError();return this.logger.error(ee,te,`FPDF_GetPageSizeByIndexF failed with ${n}`),this.memoryManager.free(m),this.pdfiumModule.FPDF_CloseDocument(i),this.memoryManager.free(a),this.logger.perf(ee,te,"OpenDocumentBuffer","End",t.id),e.reject({code:n,message:"FPDF_GetPageSizeByIndexF failed"})}const r=this.pdfiumModule.EPDF_GetPageRotationByIndex(i,n),o={index:n,size:{width:this.pdfiumModule.pdfium.getValue(m,"float"),height:this.pdfiumModule.pdfium.getValue(m+4,"float")},rotation:r};u.push(o)}this.memoryManager.free(m);const F={id:t.id,pageCount:s,pages:u};return this.cache.setDocument(t.id,a,i),this.logger.perf(ee,te,"OpenDocumentBuffer","End",t.id),e.resolve(F)}getMetadata(r){this.logger.debug(ee,te,"getMetadata",r),this.logger.perf(ee,te,"GetMetadata","Begin",r.id);const o=this.cache.getContext(r.id);if(!o)return this.logger.perf(ee,te,"GetMetadata","End",r.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=this.readMetaText(o.docPtr,"CreationDate"),i=this.readMetaText(o.docPtr,"ModDate"),s={title:this.readMetaText(o.docPtr,"Title"),author:this.readMetaText(o.docPtr,"Author"),subject:this.readMetaText(o.docPtr,"Subject"),keywords:this.readMetaText(o.docPtr,"Keywords"),producer:this.readMetaText(o.docPtr,"Producer"),creator:this.readMetaText(o.docPtr,"Creator"),creationDate:a?n(a)??null:null,modificationDate:i?n(i)??null:null,trapped:this.getMetaTrapped(o.docPtr),custom:this.readAllMeta(o.docPtr,!0)};return this.logger.perf(ee,te,"GetMetadata","End",r.id),e.resolve(s)}setMetadata(n,r){this.logger.debug(ee,te,"setMetadata",n,r),this.logger.perf(ee,te,"SetMetadata","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"SetMetadata","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=[["title","Title"],["author","Author"],["subject","Subject"],["keywords","Keywords"],["producer","Producer"],["creator","Creator"]];let i=!0;for(const[e,t]of a){const n=r[e];if(void 0===n)continue;const a=null===n?null:n;this.setMetaText(o.docPtr,t,a)||(i=!1)}const s=(e,t)=>{const n=r[e];if(void 0===n)return;if(null===n)return void(this.setMetaText(o.docPtr,t,null)||(i=!1));const a=h(n);this.setMetaText(o.docPtr,t,a)||(i=!1)};if(s("creationDate","CreationDate"),s("modificationDate","ModDate"),void 0!==r.trapped&&(this.setMetaTrapped(o.docPtr,r.trapped??null)||(i=!1)),void 0!==r.custom)for(const[e,t]of Object.entries(r.custom))z(e)?this.setMetaText(o.docPtr,e,t??null)||(i=!1):this.logger.warn(ee,te,"Invalid custom metadata key skipped",e);return this.logger.perf(ee,te,"SetMetadata","End",n.id),i?e.resolve(!0):e.reject({code:t.Unknown,message:"one or more metadata fields could not be written"})}getDocPermissions(n){this.logger.debug(ee,te,"getDocPermissions",n),this.logger.perf(ee,te,"getDocPermissions","Begin",n.id);const r=this.cache.getContext(n.id);if(!r)return this.logger.perf(ee,te,"getDocPermissions","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const o=this.pdfiumModule.FPDF_GetDocPermissions(r.docPtr);return e.resolve(o)}getDocUserPermissions(n){this.logger.debug(ee,te,"getDocUserPermissions",n),this.logger.perf(ee,te,"getDocUserPermissions","Begin",n.id);const r=this.cache.getContext(n.id);if(!r)return this.logger.perf(ee,te,"getDocUserPermissions","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const o=this.pdfiumModule.FPDF_GetDocUserPermissions(r.docPtr);return e.resolve(o)}getSignatures(n){this.logger.debug(ee,te,"getSignatures",n),this.logger.perf(ee,te,"GetSignatures","Begin",n.id);const r=this.cache.getContext(n.id);if(!r)return this.logger.perf(ee,te,"GetSignatures","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const o=[],a=this.pdfiumModule.FPDF_GetSignatureCount(r.docPtr);for(let e=0;e<a;e++){const t=this.pdfiumModule.FPDF_GetSignatureObject(r.docPtr,e),n=U(this.pdfiumModule.pdfium,(e,n)=>this.pdfiumModule.FPDFSignatureObj_GetContents(t,e,n)),a=U(this.pdfiumModule.pdfium,(e,n)=>4*this.pdfiumModule.FPDFSignatureObj_GetByteRange(t,e,n)),i=U(this.pdfiumModule.pdfium,(e,n)=>this.pdfiumModule.FPDFSignatureObj_GetSubFilter(t,e,n)),s=V(this.pdfiumModule.pdfium,(e,n)=>this.pdfiumModule.FPDFSignatureObj_GetReason(t,e,n),this.pdfiumModule.pdfium.UTF16ToString),u=V(this.pdfiumModule.pdfium,(e,n)=>this.pdfiumModule.FPDFSignatureObj_GetTime(t,e,n),this.pdfiumModule.pdfium.UTF8ToString),m=this.pdfiumModule.FPDFSignatureObj_GetDocMDPPermission(t);o.push({contents:n,byteRange:a,subFilter:i,reason:s,time:u,docMDP:m})}return this.logger.perf(ee,te,"GetSignatures","End",n.id),e.resolve(o)}getBookmarks(n){this.logger.debug(ee,te,"getBookmarks",n),this.logger.perf(ee,te,"GetBookmarks","Begin",n.id);const r=this.cache.getContext(n.id);if(!r)return this.logger.perf(ee,te,"getBookmarks","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const o=this.readPdfBookmarks(r.docPtr,0);return this.logger.perf(ee,te,"GetBookmarks","End",n.id),e.resolve({bookmarks:o})}setBookmarks(n,r){this.logger.debug(ee,te,"setBookmarks",n,r),this.logger.perf(ee,te,"SetBookmarks","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"SetBookmarks","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});if(!this.pdfiumModule.EPDFBookmark_Clear(o.docPtr))return this.logger.perf(ee,te,"SetBookmarks","End",n.id),e.reject({code:t.Unknown,message:"failed to clear existing bookmarks"});const a=(e,t)=>{var n;for(const r of t){const t=this.withWString(r.title??"",t=>this.pdfiumModule.EPDFBookmark_AppendChild(o.docPtr,e,t));if(!t)return!1;if(r.target){if(!this.applyBookmarkTarget(o.docPtr,t,r.target))return!1}if(null==(n=r.children)?void 0:n.length){if(!a(t,r.children))return!1}}return!0},i=a(0,r);return this.logger.perf(ee,te,"SetBookmarks","End",n.id),i?e.resolve(!0):e.reject({code:t.Unknown,message:"failed to build bookmark tree"})}deleteBookmarks(n){this.logger.debug(ee,te,"deleteBookmarks",n),this.logger.perf(ee,te,"DeleteBookmarks","Begin",n.id);const r=this.cache.getContext(n.id);if(!r)return this.logger.perf(ee,te,"DeleteBookmarks","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const o=this.pdfiumModule.EPDFBookmark_Clear(r.docPtr);return this.logger.perf(ee,te,"DeleteBookmarks","End",n.id),o?e.resolve(!0):e.reject({code:t.Unknown,message:"failed to clear bookmarks"})}renderPageRaw(e,t,n){this.logger.debug(ee,te,"renderPage",e,t,n),this.logger.perf(ee,te,"RenderPage","Begin",`${e.id}-${t.index}`);const r={origin:{x:0,y:0},size:t.size},o=this.renderRectEncoded(e,t,r,n);return this.logger.perf(ee,te,"RenderPage","End",`${e.id}-${t.index}`),o}renderPageRect(e,t,n,r){this.logger.debug(ee,te,"renderPageRect",e,t,n,r),this.logger.perf(ee,te,"RenderPageRect","Begin",`${e.id}-${t.index}`);const o=this.renderRectEncoded(e,t,n,r);return this.logger.perf(ee,te,"RenderPageRect","End",`${e.id}-${t.index}`),o}getPageAnnotations(n,r){this.logger.debug(ee,te,"getPageAnnotations",n,r),this.logger.perf(ee,te,"GetPageAnnotations","Begin",`${n.id}-${r.index}`);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"GetPageAnnotations","End",`${n.id}-${r.index}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=this.readPageAnnotations(o,r);return this.logger.perf(ee,te,"GetPageAnnotations","End",`${n.id}-${r.index}`),this.logger.debug(ee,te,"GetPageAnnotations",`${n.id}-${r.index}`,a),e.resolve(a)}createPageAnnotation(n,i,s,u){this.logger.debug(ee,te,"createPageAnnotation",n,i,s),this.logger.perf(ee,te,"CreatePageAnnotation","Begin",`${n.id}-${i.index}`);const m=this.cache.getContext(n.id);if(!m)return this.logger.perf(ee,te,"CreatePageAnnotation","End",`${n.id}-${i.index}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const F=m.acquirePage(i.index),l=this.pdfiumModule.EPDFPage_CreateAnnot(F.pagePtr,s.type);if(!l)return this.logger.perf(ee,te,"CreatePageAnnotation","End",`${n.id}-${i.index}`),F.release(),e.reject({code:t.CantCreateAnnot,message:"can not create annotation with specified type"});if(r(s.id)||(s.id=o()),!this.setAnnotString(l,"NM",s.id))return this.pdfiumModule.FPDFPage_CloseAnnot(l),F.release(),e.reject({code:t.CantSetAnnotString,message:"can not set the name of the annotation"});if(!this.setPageAnnoRect(i,l,s.rect))return this.pdfiumModule.FPDFPage_CloseAnnot(l),F.release(),this.logger.perf(ee,te,"CreatePageAnnotation","End",`${n.id}-${i.index}`),e.reject({code:t.CantSetAnnotRect,message:"can not set the rect of the annotation"});let d=!1;switch(s.type){case a.INK:d=this.addInkStroke(i,F.pagePtr,l,s);break;case a.STAMP:d=this.addStampContent(m.docPtr,i,F.pagePtr,l,s,null==u?void 0:u.imageData);break;case a.TEXT:d=this.addTextContent(i,F.pagePtr,l,s);break;case a.FREETEXT:d=this.addFreeTextContent(i,F.pagePtr,l,s);break;case a.LINE:d=this.addLineContent(i,F.pagePtr,l,s);break;case a.POLYLINE:case a.POLYGON:d=this.addPolyContent(i,F.pagePtr,l,s);break;case a.CIRCLE:case a.SQUARE:d=this.addShapeContent(i,F.pagePtr,l,s);break;case a.UNDERLINE:case a.STRIKEOUT:case a.SQUIGGLY:case a.HIGHLIGHT:d=this.addTextMarkupContent(i,F.pagePtr,l,s)}return d?(void 0!==s.blendMode?this.pdfiumModule.EPDFAnnot_GenerateAppearanceWithBlend(l,s.blendMode):this.pdfiumModule.EPDFAnnot_GenerateAppearance(l),this.pdfiumModule.FPDFPage_GenerateContent(F.pagePtr),this.pdfiumModule.FPDFPage_CloseAnnot(l),F.release(),this.logger.perf(ee,te,"CreatePageAnnotation","End",`${n.id}-${i.index}`),e.resolve(s.id)):(this.pdfiumModule.FPDFPage_RemoveAnnot(F.pagePtr,l),F.release(),this.logger.perf(ee,te,"CreatePageAnnotation","End",`${n.id}-${i.index}`),e.reject({code:t.CantSetAnnotContent,message:"can not add content of the annotation"}))}updatePageAnnotation(n,r,o){this.logger.debug(ee,te,"updatePageAnnotation",n,r,o),this.logger.perf(ee,te,"UpdatePageAnnotation","Begin",`${n.id}-${r.index}`);const i=this.cache.getContext(n.id);if(!i)return this.logger.perf(ee,te,"UpdatePageAnnotation","End",`${n.id}-${r.index}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const s=i.acquirePage(r.index),u=this.getAnnotationByName(s.pagePtr,o.id);if(!u)return s.release(),this.logger.perf(ee,te,"UpdatePageAnnotation","End",`${n.id}-${r.index}`),e.reject({code:t.NotFound,message:"annotation not found"});if(!this.setPageAnnoRect(r,u,o.rect))return this.pdfiumModule.FPDFPage_CloseAnnot(u),s.release(),this.logger.perf(ee,te,"UpdatePageAnnotation","End",`${n.id}-${r.index}`),e.reject({code:t.CantSetAnnotRect,message:"failed to move annotation"});let m=!1;switch(o.type){case a.INK:if(!this.pdfiumModule.FPDFAnnot_RemoveInkList(u))break;m=this.addInkStroke(r,s.pagePtr,u,o);break;case a.STAMP:m=this.addStampContent(i.docPtr,r,s.pagePtr,u,o);break;case a.TEXT:m=this.addTextContent(r,s.pagePtr,u,o);break;case a.FREETEXT:m=this.addFreeTextContent(r,s.pagePtr,u,o);break;case a.CIRCLE:case a.SQUARE:m=this.addShapeContent(r,s.pagePtr,u,o);break;case a.LINE:m=this.addLineContent(r,s.pagePtr,u,o);break;case a.POLYGON:case a.POLYLINE:m=this.addPolyContent(r,s.pagePtr,u,o);break;case a.HIGHLIGHT:case a.UNDERLINE:case a.STRIKEOUT:case a.SQUIGGLY:m=this.addTextMarkupContent(r,s.pagePtr,u,o);break;default:m=!1}return m&&(void 0!==o.blendMode?this.pdfiumModule.EPDFAnnot_GenerateAppearanceWithBlend(u,o.blendMode):this.pdfiumModule.EPDFAnnot_GenerateAppearance(u),this.pdfiumModule.FPDFPage_GenerateContent(s.pagePtr)),this.pdfiumModule.FPDFPage_CloseAnnot(u),s.release(),this.logger.perf(ee,te,"UpdatePageAnnotation","End",`${n.id}-${r.index}`),m?e.resolve(!0):e.reject({code:t.CantSetAnnotContent,message:"failed to update annotation"})}removePageAnnotation(n,r,o){this.logger.debug(ee,te,"removePageAnnotation",n,r,o),this.logger.perf(ee,te,"RemovePageAnnotation","Begin",`${n.id}-${r.index}`);const a=this.cache.getContext(n.id);if(!a)return this.logger.perf(ee,te,"RemovePageAnnotation","End",`${n.id}-${r.index}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const i=a.acquirePage(r.index);let s=!1;return s=this.removeAnnotationByName(i.pagePtr,o.id),s?(s=this.pdfiumModule.FPDFPage_GenerateContent(i.pagePtr),s||this.logger.error(ee,te,"FPDFPage_GenerateContent Failed",`${n.id}-${r.index}`)):this.logger.error(ee,te,"FPDFPage_RemoveAnnot Failed",`${n.id}-${r.index}`),i.release(),this.logger.perf(ee,te,"RemovePageAnnotation","End",`${n.id}-${r.index}`),e.resolve(s)}getPageTextRects(n,r){this.logger.debug(ee,te,"getPageTextRects",n,r),this.logger.perf(ee,te,"GetPageTextRects","Begin",`${n.id}-${r.index}`);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"GetPageTextRects","End",`${n.id}-${r.index}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=o.acquirePage(r.index),i=this.pdfiumModule.FPDFText_LoadPage(a.pagePtr),s=this.readPageTextRects(r,a.docPtr,a.pagePtr,i);return this.pdfiumModule.FPDFText_ClosePage(i),a.release(),this.logger.perf(ee,te,"GetPageTextRects","End",`${n.id}-${r.index}`),e.resolve(s)}renderThumbnailRaw(n,r,o){const{scaleFactor:a=1,...i}=o??{};this.logger.debug(ee,te,"renderThumbnail",n,r,o),this.logger.perf(ee,te,"RenderThumbnail","Begin",`${n.id}-${r.index}`);if(!this.cache.getContext(n.id))return this.logger.perf(ee,te,"RenderThumbnail","End",`${n.id}-${r.index}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const s=this.renderPageRaw(n,r,{scaleFactor:Math.max(a,.5),...i});return this.logger.perf(ee,te,"RenderThumbnail","End",`${n.id}-${r.index}`),s}getAttachments(n){this.logger.debug(ee,te,"getAttachments",n),this.logger.perf(ee,te,"GetAttachments","Begin",n.id);const r=this.cache.getContext(n.id);if(!r)return this.logger.perf(ee,te,"GetAttachments","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const o=[],a=this.pdfiumModule.FPDFDoc_GetAttachmentCount(r.docPtr);for(let e=0;e<a;e++){const t=this.readPdfAttachment(r.docPtr,e);o.push(t)}return this.logger.perf(ee,te,"GetAttachments","End",n.id),e.resolve(o)}addAttachment(n,r){this.logger.debug(ee,te,"addAttachment",n,null==r?void 0:r.name),this.logger.perf(ee,te,"AddAttachment","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"AddAttachment","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const{name:a,description:i,mimeType:s,data:u}=r??{};if(!a)return this.logger.perf(ee,te,"AddAttachment","End",n.id),e.reject({code:t.NotFound,message:"attachment name is required"});if(!u||(Uint8Array,0===u.byteLength))return this.logger.perf(ee,te,"AddAttachment","End",n.id),e.reject({code:t.NotFound,message:"attachment data is empty"});const m=this.withWString(a,e=>this.pdfiumModule.FPDFDoc_AddAttachment(o.docPtr,e));if(!m)return this.logger.perf(ee,te,"AddAttachment","End",n.id),e.reject({code:t.Unknown,message:`An attachment named "${a}" already exists`});this.withWString(i,e=>this.pdfiumModule.EPDFAttachment_SetDescription(m,e)),this.pdfiumModule.EPDFAttachment_SetSubtype(m,s);const F=u instanceof Uint8Array?u:new Uint8Array(u),l=F.byteLength,d=this.memoryManager.malloc(l);try{this.pdfiumModule.pdfium.HEAPU8.set(F,d);if(!this.pdfiumModule.FPDFAttachment_SetFile(m,o.docPtr,d,l))return this.logger.perf(ee,te,"AddAttachment","End",n.id),e.reject({code:t.Unknown,message:"failed to write attachment bytes"})}finally{this.memoryManager.free(d)}return this.logger.perf(ee,te,"AddAttachment","End",n.id),e.resolve(!0)}removeAttachment(n,r){this.logger.debug(ee,te,"deleteAttachment",n,r),this.logger.perf(ee,te,"DeleteAttachment","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"DeleteAttachment","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=this.pdfiumModule.FPDFDoc_GetAttachmentCount(o.docPtr);if(r.index<0||r.index>=a)return this.logger.perf(ee,te,"DeleteAttachment","End",n.id),e.reject({code:t.Unknown,message:`attachment index ${r.index} out of range`});const i=this.pdfiumModule.FPDFDoc_DeleteAttachment(o.docPtr,r.index);return this.logger.perf(ee,te,"DeleteAttachment","End",n.id),i?e.resolve(!0):e.reject({code:t.Unknown,message:"failed to delete attachment"})}readAttachmentContent(n,r){this.logger.debug(ee,te,"readAttachmentContent",n,r),this.logger.perf(ee,te,"ReadAttachmentContent","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"ReadAttachmentContent","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=this.pdfiumModule.FPDFDoc_GetAttachment(o.docPtr,r.index),i=this.memoryManager.malloc(4);if(!this.pdfiumModule.FPDFAttachment_GetFile(a,0,0,i))return this.memoryManager.free(i),this.logger.perf(ee,te,"ReadAttachmentContent","End",n.id),e.reject({code:t.CantReadAttachmentSize,message:"can not read attachment size"});const s=this.pdfiumModule.pdfium.getValue(i,"i32")>>>0,u=this.memoryManager.malloc(s);if(!this.pdfiumModule.FPDFAttachment_GetFile(a,u,s,i))return this.memoryManager.free(i),this.memoryManager.free(u),this.logger.perf(ee,te,"ReadAttachmentContent","End",n.id),e.reject({code:t.CantReadAttachmentContent,message:"can not read attachment content"});const m=new ArrayBuffer(s),F=new DataView(m);for(let e=0;e<s;e++)F.setInt8(e,this.pdfiumModule.pdfium.getValue(u+e,"i8"));return this.memoryManager.free(i),this.memoryManager.free(u),this.logger.perf(ee,te,"ReadAttachmentContent","End",n.id),e.resolve(m)}setFormFieldValue(n,r,o,a){this.logger.debug(ee,te,"SetFormFieldValue",n,o,a),this.logger.perf(ee,te,"SetFormFieldValue","Begin",`${n.id}-${o.id}`);const i=this.cache.getContext(n.id);if(!i)return this.logger.debug(ee,te,"SetFormFieldValue","document is not opened"),this.logger.perf(ee,te,"SetFormFieldValue","End",`${n.id}-${o.id}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const s=this.pdfiumModule.PDFiumExt_OpenFormFillInfo(),u=this.pdfiumModule.PDFiumExt_InitFormFillEnvironment(i.docPtr,s),m=i.acquirePage(r.index);this.pdfiumModule.FORM_OnAfterLoadPage(m.pagePtr,u);const F=this.getAnnotationByName(m.pagePtr,o.id);if(!F)return m.release(),this.logger.perf(ee,te,"SetFormFieldValue","End",`${n.id}-${r.index}`),e.reject({code:t.NotFound,message:"annotation not found"});if(!this.pdfiumModule.FORM_SetFocusedAnnot(u,F))return this.logger.debug(ee,te,"SetFormFieldValue","failed to set focused annotation"),this.logger.perf(ee,te,"SetFormFieldValue","End",`${n.id}-${o.id}`),this.pdfiumModule.FPDFPage_CloseAnnot(F),this.pdfiumModule.FORM_OnBeforeClosePage(m.pagePtr,u),m.release(),this.pdfiumModule.PDFiumExt_ExitFormFillEnvironment(u),this.pdfiumModule.PDFiumExt_CloseFormFillInfo(s),e.reject({code:t.CantFocusAnnot,message:"failed to set focused annotation"});switch(a.kind){case"text":{if(!this.pdfiumModule.FORM_SelectAllText(u,m.pagePtr))return this.logger.debug(ee,te,"SetFormFieldValue","failed to select all text"),this.logger.perf(ee,te,"SetFormFieldValue","End",`${n.id}-${o.id}`),this.pdfiumModule.FORM_ForceToKillFocus(u),this.pdfiumModule.FPDFPage_CloseAnnot(F),this.pdfiumModule.FORM_OnBeforeClosePage(m.pagePtr,u),m.release(),this.pdfiumModule.PDFiumExt_ExitFormFillEnvironment(u),this.pdfiumModule.PDFiumExt_CloseFormFillInfo(s),e.reject({code:t.CantSelectText,message:"failed to select all text"});const r=2*(a.text.length+1),i=this.memoryManager.malloc(r);this.pdfiumModule.pdfium.stringToUTF16(a.text,i,r),this.pdfiumModule.FORM_ReplaceSelection(u,m.pagePtr,i),this.memoryManager.free(i)}break;case"selection":if(!this.pdfiumModule.FORM_SetIndexSelected(u,m.pagePtr,a.index,a.isSelected))return this.logger.debug(ee,te,"SetFormFieldValue","failed to set index selected"),this.logger.perf(ee,te,"SetFormFieldValue","End",`${n.id}-${o.id}`),this.pdfiumModule.FORM_ForceToKillFocus(u),this.pdfiumModule.FPDFPage_CloseAnnot(F),this.pdfiumModule.FORM_OnBeforeClosePage(m.pagePtr,u),m.release(),this.pdfiumModule.PDFiumExt_ExitFormFillEnvironment(u),this.pdfiumModule.PDFiumExt_CloseFormFillInfo(s),e.reject({code:t.CantSelectOption,message:"failed to set index selected"});break;case"checked":{const r=13;if(!this.pdfiumModule.FORM_OnChar(u,m.pagePtr,r,0))return this.logger.debug(ee,te,"SetFormFieldValue","failed to set field checked"),this.logger.perf(ee,te,"SetFormFieldValue","End",`${n.id}-${o.id}`),this.pdfiumModule.FORM_ForceToKillFocus(u),this.pdfiumModule.FPDFPage_CloseAnnot(F),this.pdfiumModule.FORM_OnBeforeClosePage(m.pagePtr,u),m.release(),this.pdfiumModule.PDFiumExt_ExitFormFillEnvironment(u),this.pdfiumModule.PDFiumExt_CloseFormFillInfo(s),e.reject({code:t.CantCheckField,message:"failed to set field checked"})}}return this.pdfiumModule.FORM_ForceToKillFocus(u),this.pdfiumModule.FPDFPage_CloseAnnot(F),this.pdfiumModule.FORM_OnBeforeClosePage(m.pagePtr,u),m.release(),this.pdfiumModule.PDFiumExt_ExitFormFillEnvironment(u),this.pdfiumModule.PDFiumExt_CloseFormFillInfo(s),e.resolve(!0)}flattenPage(n,r,o){const{flag:a=i.Display}=o??{};this.logger.debug(ee,te,"flattenPage",n,r,a),this.logger.perf(ee,te,"flattenPage","Begin",n.id);const s=this.cache.getContext(n.id);if(!s)return this.logger.perf(ee,te,"flattenPage","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const u=s.acquirePage(r.index),m=this.pdfiumModule.FPDFPage_Flatten(u.pagePtr,a);return u.release(),this.logger.perf(ee,te,"flattenPage","End",n.id),e.resolve(m)}extractPages(n,r){this.logger.debug(ee,te,"extractPages",n,r),this.logger.perf(ee,te,"ExtractPages","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"ExtractPages","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=this.pdfiumModule.FPDF_CreateNewDocument();if(!a)return this.logger.perf(ee,te,"ExtractPages","End",n.id),e.reject({code:t.CantCreateNewDoc,message:"can not create new document"});const i=this.memoryManager.malloc(4*r.length);for(let e=0;e<r.length;e++)this.pdfiumModule.pdfium.setValue(i+4*e,r[e],"i32");if(!this.pdfiumModule.FPDF_ImportPagesByIndex(a,o.docPtr,i,r.length,0))return this.pdfiumModule.FPDF_CloseDocument(a),this.logger.perf(ee,te,"ExtractPages","End",n.id),e.reject({code:t.CantImportPages,message:"can not import pages to new document"});const s=this.saveDocument(a);return this.pdfiumModule.FPDF_CloseDocument(a),this.logger.perf(ee,te,"ExtractPages","End",n.id),e.resolve(s)}extractText(n,r){this.logger.debug(ee,te,"extractText",n,r),this.logger.perf(ee,te,"ExtractText","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"ExtractText","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=[];for(let e=0;e<r.length;e++){const t=o.acquirePage(r[e]),n=this.pdfiumModule.FPDFText_LoadPage(t.pagePtr),i=this.pdfiumModule.FPDFText_CountChars(n),s=this.memoryManager.malloc(2*(i+1));this.pdfiumModule.FPDFText_GetText(n,0,i,s);const u=this.pdfiumModule.pdfium.UTF16ToString(s);this.memoryManager.free(s),a.push(u),this.pdfiumModule.FPDFText_ClosePage(n),t.release()}const i=a.join("\n\n");return this.logger.perf(ee,te,"ExtractText","End",n.id),e.resolve(i)}getTextSlices(n,r){if(this.logger.debug(ee,te,"getTextSlices",n,r),this.logger.perf(ee,te,"GetTextSlices","Begin",n.id),0===r.length)return this.logger.perf(ee,te,"GetTextSlices","End",n.id),e.resolve([]);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"GetTextSlices","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});try{const t=new Array(r.length),a=new Map;r.forEach((e,t)=>{(a.get(e.pageIndex)??a.set(e.pageIndex,[]).get(e.pageIndex)).push({slice:e,pos:t})});for(const[e,n]of a){const r=o.acquirePage(e),a=r.getTextPage();for(const{slice:e,pos:r}of n){const n=this.memoryManager.malloc(2*(e.charCount+1));this.pdfiumModule.FPDFText_GetText(a,e.charIndex,e.charCount,n),t[r]=s(this.pdfiumModule.pdfium.UTF16ToString(n)),this.memoryManager.free(n)}r.release()}return this.logger.perf(ee,te,"GetTextSlices","End",n.id),e.resolve(t)}catch(r){return this.logger.error(ee,te,"getTextSlices error",r),this.logger.perf(ee,te,"GetTextSlices","End",n.id),e.reject({code:t.Unknown,message:String(r)})}}merge(n){this.logger.debug(ee,te,"merge",n);const r=n.map(e=>e.id).join(".");this.logger.perf(ee,te,"Merge","Begin",r);const o=this.pdfiumModule.FPDF_CreateNewDocument();if(!o)return this.logger.perf(ee,te,"Merge","End",r),e.reject({code:t.CantCreateNewDoc,message:"can not create new document"});const a=[];for(const i of n.reverse()){const n=new Uint8Array(i.content),s=n.length,u=this.memoryManager.malloc(s);this.pdfiumModule.pdfium.HEAPU8.set(n,u);const m=this.pdfiumModule.FPDF_LoadMemDocument(u,s,"");if(!m){const t=this.pdfiumModule.FPDF_GetLastError();this.logger.error(ee,te,`FPDF_LoadMemDocument failed with ${t}`),this.memoryManager.free(u);for(const e of a)this.pdfiumModule.FPDF_CloseDocument(e.docPtr),this.memoryManager.free(e.filePtr);return this.logger.perf(ee,te,"Merge","End",r),e.reject({code:t,message:"FPDF_LoadMemDocument failed"})}if(a.push({filePtr:u,docPtr:m}),!this.pdfiumModule.FPDF_ImportPages(o,m,"",0)){this.pdfiumModule.FPDF_CloseDocument(o);for(const e of a)this.pdfiumModule.FPDF_CloseDocument(e.docPtr),this.memoryManager.free(e.filePtr);return this.logger.perf(ee,te,"Merge","End",r),e.reject({code:t.CantImportPages,message:"can not import pages to new document"})}}const i=this.saveDocument(o);this.pdfiumModule.FPDF_CloseDocument(o);for(const e of a)this.pdfiumModule.FPDF_CloseDocument(e.docPtr),this.memoryManager.free(e.filePtr);const s={id:`${Math.random()}`,content:i};return this.logger.perf(ee,te,"Merge","End",r),e.resolve(s)}mergePages(n){const r=n.map(e=>`${e.docId}:${e.pageIndices.join(",")}`).join("|");this.logger.debug(ee,te,"mergePages",n),this.logger.perf(ee,te,"MergePages","Begin",r);const o=this.pdfiumModule.FPDF_CreateNewDocument();if(!o)return this.logger.perf(ee,te,"MergePages","End",r),e.reject({code:t.CantCreateNewDoc,message:"Cannot create new document"});try{for(const e of[...n].reverse()){const t=this.cache.getContext(e.docId);if(!t){this.logger.warn(ee,te,`Document ${e.docId} is not open, skipping`);continue}const n=this.pdfiumModule.FPDF_GetPageCount(t.docPtr),r=e.pageIndices.filter(e=>e>=0&&e<n);if(0===r.length)continue;const a=r.map(e=>e+1).join(",");try{if(!this.pdfiumModule.FPDF_ImportPages(o,t.docPtr,a,0))throw new Error(`Failed to import pages ${a} from document ${e.docId}`)}finally{}}const t=this.saveDocument(o),a={id:`${Math.random()}`,content:t};return this.logger.perf(ee,te,"MergePages","End",r),e.resolve(a)}catch(n){return this.logger.error(ee,te,"mergePages failed",n),this.logger.perf(ee,te,"MergePages","End",r),e.reject({code:t.CantImportPages,message:n instanceof Error?n.message:"Failed to merge pages"})}finally{o&&this.pdfiumModule.FPDF_CloseDocument(o)}}saveAsCopy(n){this.logger.debug(ee,te,"saveAsCopy",n),this.logger.perf(ee,te,"SaveAsCopy","Begin",n.id);const r=this.cache.getContext(n.id);if(!r)return this.logger.perf(ee,te,"SaveAsCopy","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const o=this.saveDocument(r.docPtr);return this.logger.perf(ee,te,"SaveAsCopy","End",n.id),e.resolve(o)}closeDocument(t){this.logger.debug(ee,te,"closeDocument",t),this.logger.perf(ee,te,"CloseDocument","Begin",t.id);const n=this.cache.getContext(t.id);return n?(n.dispose(),this.logger.perf(ee,te,"CloseDocument","End",t.id),e.resolve(!0)):e.resolve(!0)}closeAllDocuments(){return this.logger.debug(ee,te,"closeAllDocuments"),this.logger.perf(ee,te,"CloseAllDocuments","Begin"),this.cache.closeAllDocuments(),this.logger.perf(ee,te,"CloseAllDocuments","End"),e.resolve(!0)}addTextContent(e,t,n,r){return!!this.setAnnotString(n,"Contents",r.contents??"")&&(!!this.setAnnotString(n,"T",r.author||"")&&(!(r.modified&&!this.setAnnotationDate(n,"M",r.modified))&&(!(r.created&&!this.setAnnotationDate(n,"CreationDate",r.created))&&(!(r.inReplyToId&&!this.setInReplyToId(t,n,r.inReplyToId))&&(!!this.setAnnotationIcon(n,r.icon||u.Comment)&&(!!this.setAnnotationFlags(n,r.flags||["print","noZoom","noRotate"])&&(!(r.state&&!this.setAnnotString(n,"State",r.state))&&!(r.stateModel&&!this.setAnnotString(n,"StateModel",r.stateModel)))))))))}addFreeTextContent(e,t,n,r){if(r.created&&!this.setAnnotationDate(n,"CreationDate",r.created))return!1;if(r.flags&&!this.setAnnotationFlags(n,r.flags))return!1;if(r.modified&&!this.setAnnotationDate(n,"M",r.modified))return!1;if(!this.setBorderStyle(n,m.SOLID,0))return!1;if(!this.setAnnotString(n,"Contents",r.contents??""))return!1;if(!this.setAnnotString(n,"T",r.author||""))return!1;if(!this.setAnnotationOpacity(n,r.opacity??1))return!1;if(!this.setAnnotationTextAlignment(n,r.textAlign))return!1;if(!this.setAnnotationVerticalAlignment(n,r.verticalAlign))return!1;if(!this.setAnnotationDefaultAppearance(n,r.fontFamily,r.fontSize,r.fontColor))return!1;if(r.intent&&!this.setAnnotIntent(n,r.intent))return!1;if(r.backgroundColor&&"transparent"!==r.backgroundColor){if(!this.setAnnotationColor(n,r.backgroundColor??"#FFFFFF",F.Color))return!1}else if(!this.pdfiumModule.EPDFAnnot_ClearColor(n,F.Color))return!1;return!0}addInkStroke(e,t,n,r){return!(r.created&&!this.setAnnotationDate(n,"CreationDate",r.created))&&(!(r.flags&&!this.setAnnotationFlags(n,r.flags))&&(!(r.modified&&!this.setAnnotationDate(n,"M",r.modified))&&(!!this.setAnnotString(n,"Contents",r.contents??"")&&(!!this.setBorderStyle(n,m.SOLID,r.strokeWidth)&&(!!this.setInkList(e,n,r.inkList)&&(!!this.setAnnotString(n,"T",r.author||"")&&(!!this.setAnnotationOpacity(n,r.opacity??1)&&!!this.setAnnotationColor(n,r.color??"#FFFF00",F.Color))))))))}addLineContent(e,t,n,r){var o,a;if(r.created&&!this.setAnnotationDate(n,"CreationDate",r.created))return!1;if(r.flags&&!this.setAnnotationFlags(n,r.flags))return!1;if(r.modified&&!this.setAnnotationDate(n,"M",r.modified))return!1;if(!this.setLinePoints(e,n,r.linePoints.start,r.linePoints.end))return!1;if(!this.setLineEndings(n,(null==(o=r.lineEndings)?void 0:o.start)??l.None,(null==(a=r.lineEndings)?void 0:a.end)??l.None))return!1;if(!this.setAnnotString(n,"Contents",r.contents??""))return!1;if(!this.setAnnotString(n,"T",r.author||""))return!1;if(!this.setBorderStyle(n,r.strokeStyle,r.strokeWidth))return!1;if(!this.setBorderDashPattern(n,r.strokeDashArray??[]))return!1;if(r.intent&&!this.setAnnotIntent(n,r.intent))return!1;if(r.color&&"transparent"!==r.color){if(!this.setAnnotationColor(n,r.color??"#FFFF00",F.InteriorColor))return!1}else if(!this.pdfiumModule.EPDFAnnot_ClearColor(n,F.InteriorColor))return!1;return!!this.setAnnotationOpacity(n,r.opacity??1)&&!!this.setAnnotationColor(n,r.strokeColor??"#FFFF00",F.Color)}addPolyContent(e,t,n,r){var o,i;if(r.created&&!this.setAnnotationDate(n,"CreationDate",r.created))return!1;if(r.modified&&!this.setAnnotationDate(n,"M",r.modified))return!1;if(r.flags&&!this.setAnnotationFlags(n,r.flags))return!1;if(r.type===a.POLYLINE&&!this.setLineEndings(n,(null==(o=r.lineEndings)?void 0:o.start)??l.None,(null==(i=r.lineEndings)?void 0:i.end)??l.None))return!1;if(!this.setPdfAnnoVertices(e,n,r.vertices))return!1;if(!this.setAnnotString(n,"Contents",r.contents??""))return!1;if(!this.setAnnotString(n,"T",r.author||""))return!1;if(!this.setBorderStyle(n,r.strokeStyle,r.strokeWidth))return!1;if(!this.setBorderDashPattern(n,r.strokeDashArray??[]))return!1;if(r.intent&&!this.setAnnotIntent(n,r.intent))return!1;if(r.color&&"transparent"!==r.color){if(!this.setAnnotationColor(n,r.color??"#FFFF00",F.InteriorColor))return!1}else if(!this.pdfiumModule.EPDFAnnot_ClearColor(n,F.InteriorColor))return!1;return!!this.setAnnotationOpacity(n,r.opacity??1)&&!!this.setAnnotationColor(n,r.strokeColor??"#FFFF00",F.Color)}addShapeContent(e,t,n,r){if(r.created&&!this.setAnnotationDate(n,"CreationDate",r.created))return!1;if(r.modified&&!this.setAnnotationDate(n,"M",r.modified))return!1;if(!this.setAnnotString(n,"Contents",r.contents??""))return!1;if(!this.setAnnotString(n,"T",r.author||""))return!1;if(!this.setBorderStyle(n,r.strokeStyle,r.strokeWidth))return!1;if(!this.setBorderDashPattern(n,r.strokeDashArray??[]))return!1;if(!this.setAnnotationFlags(n,r.flags))return!1;if(r.color&&"transparent"!==r.color){if(!this.setAnnotationColor(n,r.color??"#FFFF00",F.InteriorColor))return!1}else if(!this.pdfiumModule.EPDFAnnot_ClearColor(n,F.InteriorColor))return!1;return!!this.setAnnotationOpacity(n,r.opacity??1)&&!!this.setAnnotationColor(n,r.strokeColor??"#FFFF00",F.Color)}addTextMarkupContent(e,t,n,r){return!(r.created&&!this.setAnnotationDate(n,"CreationDate",r.created))&&(!(r.custom&&!this.setAnnotCustom(n,r.custom))&&(!(r.flags&&!this.setAnnotationFlags(n,r.flags))&&(!(r.modified&&!this.setAnnotationDate(n,"M",r.modified))&&(!!this.syncQuadPointsAnno(e,n,r.segmentRects)&&(!!this.setAnnotString(n,"Contents",r.contents??"")&&(!!this.setAnnotString(n,"T",r.author||"")&&(!!this.setAnnotationOpacity(n,r.opacity??1)&&!!this.setAnnotationColor(n,r.color??"#FFFF00",F.Color))))))))}addStampContent(e,t,n,r,o,a){if(o.created&&!this.setAnnotationDate(r,"CreationDate",o.created))return!1;if(o.flags&&!this.setAnnotationFlags(r,o.flags))return!1;if(o.modified&&!this.setAnnotationDate(r,"M",o.modified))return!1;if(o.icon&&!this.setAnnotationIcon(r,o.icon))return!1;if(o.subject&&!this.setAnnotString(r,"Subj",o.subject))return!1;if(!this.setAnnotString(r,"Contents",o.contents??""))return!1;if(a){for(let e=this.pdfiumModule.FPDFAnnot_GetObjectCount(r)-1;e>=0;e--)this.pdfiumModule.FPDFAnnot_RemoveObject(r,e);if(!this.addImageObject(e,t,n,r,o.rect,a))return!1}return!!this.pdfiumModule.EPDFAnnot_UpdateAppearanceToRect(r,d.Cover)}addImageObject(e,t,n,r,o,a){const i=a.width*a.height,s=this.memoryManager.malloc(4*i);if(!s)return!1;for(let e=0;e<i;e++){const t=a.data[4*e],n=a.data[4*e+1],r=a.data[4*e+2],o=a.data[4*e+3];this.pdfiumModule.pdfium.setValue(s+4*e,r,"i8"),this.pdfiumModule.pdfium.setValue(s+4*e+1,n,"i8"),this.pdfiumModule.pdfium.setValue(s+4*e+2,t,"i8"),this.pdfiumModule.pdfium.setValue(s+4*e+3,o,"i8")}const u=this.pdfiumModule.FPDFBitmap_CreateEx(a.width,a.height,4,s,0);if(!u)return this.memoryManager.free(s),!1;const m=this.pdfiumModule.FPDFPageObj_NewImageObj(e);if(!m)return this.pdfiumModule.FPDFBitmap_Destroy(u),this.memoryManager.free(s),!1;if(!this.pdfiumModule.FPDFImageObj_SetBitmap(n,0,m,u))return this.pdfiumModule.FPDFBitmap_Destroy(u),this.pdfiumModule.FPDFPageObj_Destroy(m),this.memoryManager.free(s),!1;const F=this.memoryManager.malloc(24);if(this.pdfiumModule.pdfium.setValue(F,a.width,"float"),this.pdfiumModule.pdfium.setValue(F+4,0,"float"),this.pdfiumModule.pdfium.setValue(F+8,0,"float"),this.pdfiumModule.pdfium.setValue(F+12,a.height,"float"),this.pdfiumModule.pdfium.setValue(F+16,0,"float"),this.pdfiumModule.pdfium.setValue(F+20,0,"float"),!this.pdfiumModule.FPDFPageObj_SetMatrix(m,F))return this.memoryManager.free(F),this.pdfiumModule.FPDFBitmap_Destroy(u),this.pdfiumModule.FPDFPageObj_Destroy(m),this.memoryManager.free(s),!1;this.memoryManager.free(F);const l=this.convertDevicePointToPagePoint(t,{x:o.origin.x,y:o.origin.y+a.height});return this.pdfiumModule.FPDFPageObj_Transform(m,1,0,0,1,l.x,l.y),this.pdfiumModule.FPDFAnnot_AppendObject(r,m)?(this.pdfiumModule.FPDFBitmap_Destroy(u),this.memoryManager.free(s),!0):(this.pdfiumModule.FPDFBitmap_Destroy(u),this.pdfiumModule.FPDFPageObj_Destroy(m),this.memoryManager.free(s),!1)}saveDocument(e){const t=this.pdfiumModule.PDFiumExt_OpenFileWriter();this.pdfiumModule.PDFiumExt_SaveAsCopy(e,t);const n=this.pdfiumModule.PDFiumExt_GetFileWriterSize(t),r=this.memoryManager.malloc(n);this.pdfiumModule.PDFiumExt_GetFileWriterData(t,r,n);const o=new ArrayBuffer(n),a=new DataView(o);for(let e=0;e<n;e++)a.setInt8(e,this.pdfiumModule.pdfium.getValue(r+e,"i8"));return this.memoryManager.free(r),this.pdfiumModule.PDFiumExt_CloseFileWriter(t),o}readCatalogLanguage(e){const t=this.pdfiumModule.EPDFCatalog_GetLanguage(e,0,0)>>>0;return 0===t?null:2===t?"":V(this.pdfiumModule.pdfium,(t,n)=>this.pdfiumModule.EPDFCatalog_GetLanguage(e,t,n),this.pdfiumModule.pdfium.UTF16ToString,t)}readMetaText(e,t){if(!!!this.pdfiumModule.EPDF_HasMetaText(e,t))return null;const n=this.pdfiumModule.FPDF_GetMetaText(e,t,0,0);return 2===n?"":V(this.pdfiumModule.pdfium,(n,r)=>this.pdfiumModule.FPDF_GetMetaText(e,t,n,r),this.pdfiumModule.pdfium.UTF16ToString,n)}setMetaText(e,t,n){if(null==n||0===n.length){return!!this.pdfiumModule.EPDF_SetMetaText(e,t,0)}const r=2*(n.length+1),o=this.memoryManager.malloc(r);try{this.pdfiumModule.pdfium.stringToUTF16(n,o,r);return!!this.pdfiumModule.EPDF_SetMetaText(e,t,o)}finally{this.memoryManager.free(o)}}getMetaTrapped(e){const t=Number(this.pdfiumModule.EPDF_GetMetaTrapped(e));switch(t){case _.NotSet:case _.True:case _.False:case _.Unknown:return t;default:return _.Unknown}}setMetaTrapped(e,t){const n=null==t||void 0===t?_.NotSet:t;return!(n!==_.NotSet&&n!==_.True&&n!==_.False&&n!==_.Unknown)&&!!this.pdfiumModule.EPDF_SetMetaTrapped(e,n)}getMetaKeyCount(e,t){return 0|Number(this.pdfiumModule.EPDF_GetMetaKeyCount(e,t))}getMetaKeyName(e,t,n){const r=this.pdfiumModule.EPDF_GetMetaKeyName(e,t,n,0,0);return r?V(this.pdfiumModule.pdfium,(r,o)=>this.pdfiumModule.EPDF_GetMetaKeyName(e,t,n,r,o),this.pdfiumModule.pdfium.UTF8ToString,r):null}readAllMeta(e,t=!0){const n=this.getMetaKeyCount(e,t),r={};for(let o=0;o<n;o++){const n=this.getMetaKeyName(e,o,t);n&&(r[n]=this.readMetaText(e,n))}return r}readPdfBookmarks(e,t=0){let n=this.pdfiumModule.FPDFBookmark_GetFirstChild(e,t);const r=[];for(;n;){const t=this.readPdfBookmark(e,n);r.push(t);n=this.pdfiumModule.FPDFBookmark_GetNextSibling(e,n)}return r}readPdfBookmark(e,t){const n=V(this.pdfiumModule.pdfium,(e,n)=>this.pdfiumModule.FPDFBookmark_GetTitle(t,e,n),this.pdfiumModule.pdfium.UTF16ToString),r=this.readPdfBookmarks(e,t);return{title:n,target:this.readPdfBookmarkTarget(e,()=>this.pdfiumModule.FPDFBookmark_GetAction(t),()=>this.pdfiumModule.FPDFBookmark_GetDest(e,t)),children:r}}readPageTextRects(e,t,n,r){const o=this.pdfiumModule.FPDFText_CountRects(r,0,-1),a=[];for(let t=0;t<o;t++){const o=this.memoryManager.malloc(8),i=this.memoryManager.malloc(8),s=this.memoryManager.malloc(8),u=this.memoryManager.malloc(8);if(!this.pdfiumModule.FPDFText_GetRect(r,t,i,o,s,u)){this.memoryManager.free(i),this.memoryManager.free(o),this.memoryManager.free(s),this.memoryManager.free(u);continue}const m=this.pdfiumModule.pdfium.getValue(i,"double"),F=this.pdfiumModule.pdfium.getValue(o,"double"),l=this.pdfiumModule.pdfium.getValue(s,"double"),d=this.pdfiumModule.pdfium.getValue(u,"double");this.memoryManager.free(i),this.memoryManager.free(o),this.memoryManager.free(s),this.memoryManager.free(u);const _=this.memoryManager.malloc(4),P=this.memoryManager.malloc(4);this.pdfiumModule.FPDF_PageToDevice(n,0,0,e.size.width,e.size.height,0,m,F,_,P);const c=this.pdfiumModule.pdfium.getValue(_,"i32"),g=this.pdfiumModule.pdfium.getValue(P,"i32");this.memoryManager.free(_),this.memoryManager.free(P);const h={origin:{x:c,y:g},size:{width:Math.ceil(Math.abs(l-m)),height:Math.ceil(Math.abs(F-d))}},D=this.pdfiumModule.FPDFText_GetBoundedText(r,m,F,l,d,0,0),b=2*(D+1),p=this.memoryManager.malloc(b);this.pdfiumModule.FPDFText_GetBoundedText(r,m,F,l,d,p,D);const f=this.pdfiumModule.pdfium.UTF16ToString(p);this.memoryManager.free(p);const A=this.pdfiumModule.FPDFText_GetCharIndexAtPos(r,m,F,2,2);let E="",M=h.size.height;if(A>=0){M=this.pdfiumModule.FPDFText_GetFontSize(r,A);const e=this.pdfiumModule.FPDFText_GetFontInfo(r,A,0,0,0)+1,t=this.memoryManager.malloc(e),n=this.memoryManager.malloc(4);this.pdfiumModule.FPDFText_GetFontInfo(r,A,t,e,n),E=this.pdfiumModule.pdfium.UTF8ToString(t),this.memoryManager.free(t),this.memoryManager.free(n)}const y={content:f,rect:h,font:{family:E,size:M}};a.push(y)}return a}getPageGeometry(n,r){const o="getPageGeometry";this.logger.perf(ee,te,o,"Begin",n.id);const a=this.cache.getContext(n.id);if(!a)return this.logger.perf(ee,te,o,"End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const i=a.acquirePage(r.index),s=i.getTextPage(),u=this.pdfiumModule.FPDFText_CountChars(s),m=[];for(let e=0;e<u;e++){const t=this.readGlyphInfo(r,i.pagePtr,s,e);m.push(t)}const F=this.buildRunsFromGlyphs(m,s);return i.release(),this.logger.perf(ee,te,o,"End",n.id),e.resolve({runs:F})}buildRunsFromGlyphs(e,t){const n=[];let r=null,o=null,a=null;for(let i=0;i<e.length;i++){const s=e[i],u=this.pdfiumModule.FPDFText_GetTextObject(t,i);if(u!==o&&(o=u,r={rect:{x:s.origin.x,y:s.origin.y,width:s.size.width,height:s.size.height},charStart:i,glyphs:[]},a={minX:s.origin.x,minY:s.origin.y,maxX:s.origin.x+s.size.width,maxY:s.origin.y+s.size.height},n.push(r)),r.glyphs.push({x:s.origin.x,y:s.origin.y,width:s.size.width,height:s.size.height,flags:s.isEmpty?2:s.isSpace?1:0}),s.isEmpty)continue;const m=s.origin.x+s.size.width,F=s.origin.y+s.size.height;a.minX=Math.min(a.minX,s.origin.x),a.minY=Math.min(a.minY,s.origin.y),a.maxX=Math.max(a.maxX,m),a.maxY=Math.max(a.maxY,F),r.rect.x=a.minX,r.rect.y=a.minY,r.rect.width=a.maxX-a.minX,r.rect.height=a.maxY-a.minY}return n}readGlyphInfo(e,t,n,r){const o=this.memoryManager.malloc(4),a=this.memoryManager.malloc(4),i=this.memoryManager.malloc(4),s=this.memoryManager.malloc(4),u=this.memoryManager.malloc(16);let m=0,F=0,l=0,d=0,_=!1;if(this.pdfiumModule.FPDFText_GetLooseCharBox(n,r,u)){const P=this.pdfiumModule.pdfium.getValue(u,"float"),c=this.pdfiumModule.pdfium.getValue(u+4,"float"),g=this.pdfiumModule.pdfium.getValue(u+8,"float"),h=this.pdfiumModule.pdfium.getValue(u+12,"float");if(P===g||c===h)return[u,o,a,i,s].forEach(e=>this.memoryManager.free(e)),{origin:{x:0,y:0},size:{width:0,height:0},isEmpty:!0};this.pdfiumModule.FPDF_PageToDevice(t,0,0,e.size.width,e.size.height,0,P,c,o,a),this.pdfiumModule.FPDF_PageToDevice(t,0,0,e.size.width,e.size.height,0,g,h,i,s);const D=this.pdfiumModule.pdfium.getValue(o,"i32"),b=this.pdfiumModule.pdfium.getValue(a,"i32"),p=this.pdfiumModule.pdfium.getValue(i,"i32"),f=this.pdfiumModule.pdfium.getValue(s,"i32");m=Math.min(D,p),F=Math.min(b,f),l=Math.max(1,Math.abs(p-D)),d=Math.max(1,Math.abs(f-b));_=32===this.pdfiumModule.FPDFText_GetUnicode(n,r)}return[u,o,a,i,s].forEach(e=>this.memoryManager.free(e)),{origin:{x:m,y:F},size:{width:l,height:d},..._&&{isSpace:_}}}getPageGlyphs(n,r){this.logger.debug(ee,te,"getPageGlyphs",n,r),this.logger.perf(ee,te,"getPageGlyphs","Begin",n.id);const o=this.cache.getContext(n.id);if(!o)return this.logger.perf(ee,te,"getPageGlyphs","End",n.id),e.reject({code:t.DocNotOpen,message:"document does not open"});const a=o.acquirePage(r.index),i=a.getTextPage(),s=this.pdfiumModule.FPDFText_CountChars(i),u=new Array(s);for(let e=0;e<s;e++){const t=this.readGlyphInfo(r,a.pagePtr,i,e);t.isEmpty||(u[e]={...t})}return a.release(),this.logger.perf(ee,te,"getPageGlyphs","End",n.id),e.resolve(u)}readCharBox(e,t,n,r){const o=this.memoryManager.malloc(8),a=this.memoryManager.malloc(8),i=this.memoryManager.malloc(8),s=this.memoryManager.malloc(8);let u=0,m=0,F=0,l=0;if(this.pdfiumModule.FPDFText_GetCharBox(n,r,a,s,i,o)){const n=this.pdfiumModule.pdfium.getValue(o,"double"),r=this.pdfiumModule.pdfium.getValue(a,"double"),d=this.pdfiumModule.pdfium.getValue(i,"double"),_=this.pdfiumModule.pdfium.getValue(s,"double"),P=this.memoryManager.malloc(4),c=this.memoryManager.malloc(4);this.pdfiumModule.FPDF_PageToDevice(t,0,0,e.size.width,e.size.height,0,r,n,P,c),u=this.pdfiumModule.pdfium.getValue(P,"i32"),m=this.pdfiumModule.pdfium.getValue(c,"i32"),this.memoryManager.free(P),this.memoryManager.free(c),F=Math.ceil(Math.abs(_-r)),l=Math.ceil(Math.abs(n-d))}return this.memoryManager.free(o),this.memoryManager.free(a),this.memoryManager.free(i),this.memoryManager.free(s),{origin:{x:u,y:m},size:{width:F,height:l}}}readPageAnnotations(e,t){return e.borrowPage(t.index,n=>{const r=this.pdfiumModule.FPDFPage_GetAnnotCount(n.pagePtr),o=[];for(let a=0;a<r;a++)n.withAnnotation(a,r=>{const a=this.readPageAnnotation(e.docPtr,t,r,n);a&&o.push(a)});return o})}readPageAnnotationsRaw(e,t){const n=this.pdfiumModule.EPDFPage_GetAnnotCountRaw(e.docPtr,t.index);if(n<=0)return[];const r=[];for(let o=0;o<n;++o){const n=this.pdfiumModule.EPDFPage_GetAnnotRaw(e.docPtr,t.index,o);if(n)try{const o=this.readPageAnnotation(e.docPtr,t,n);o&&r.push(o)}finally{this.pdfiumModule.FPDFPage_CloseAnnot(n)}}return r}getPageAnnotationsRaw(n,r){this.logger.debug(ee,te,"getPageAnnotationsRaw",n,r),this.logger.perf(ee,te,"GetPageAnnotationsRaw","Begin",`${n.id}-${r.index}`);const o=this.cache.getContext(n.id);if(!o)return e.reject({code:t.DocNotOpen,message:"document does not open"});const a=this.readPageAnnotationsRaw(o,r);return this.logger.perf(ee,te,"GetPageAnnotationsRaw","End",`${n.id}-${r.index}`),this.logger.debug(ee,te,"getPageAnnotationsRaw",`${n.id}-${r.index}`,a),e.resolve(a)}readPageAnnotation(e,t,n,i){let s=this.getAnnotString(n,"NM");s&&r(s)||(s=o(),this.setAnnotString(n,"NM",s));const u=this.pdfiumModule.FPDFAnnot_GetSubtype(n);let m;switch(u){case a.TEXT:m=this.readPdfTextAnno(t,n,s);break;case a.FREETEXT:m=this.readPdfFreeTextAnno(t,n,s);break;case a.LINK:m=this.readPdfLinkAnno(t,e,n,s);break;case a.WIDGET:if(i)return this.readPdfWidgetAnno(t,n,i.getFormHandle(),s);case a.FILEATTACHMENT:m=this.readPdfFileAttachmentAnno(t,n,s);break;case a.INK:m=this.readPdfInkAnno(t,n,s);break;case a.POLYGON:m=this.readPdfPolygonAnno(t,n,s);break;case a.POLYLINE:m=this.readPdfPolylineAnno(t,n,s);break;case a.LINE:m=this.readPdfLineAnno(t,n,s);break;case a.HIGHLIGHT:m=this.readPdfHighlightAnno(t,n,s);break;case a.STAMP:m=this.readPdfStampAnno(t,n,s);break;case a.SQUARE:m=this.readPdfSquareAnno(t,n,s);break;case a.CIRCLE:m=this.readPdfCircleAnno(t,n,s);break;case a.UNDERLINE:m=this.readPdfUnderlineAnno(t,n,s);break;case a.SQUIGGLY:m=this.readPdfSquigglyAnno(t,n,s);break;case a.STRIKEOUT:m=this.readPdfStrikeOutAnno(t,n,s);break;case a.CARET:m=this.readPdfCaretAnno(t,n,s);break;default:m=this.readPdfAnno(t,u,n,s)}return m}readAnnotationColor(e,t=F.Color){const n=this.memoryManager.malloc(4),r=this.memoryManager.malloc(4),o=this.memoryManager.malloc(4);let a;return this.pdfiumModule.EPDFAnnot_GetColor(e,t,n,r,o)&&(a={red:255&this.pdfiumModule.pdfium.getValue(n,"i32"),green:255&this.pdfiumModule.pdfium.getValue(r,"i32"),blue:255&this.pdfiumModule.pdfium.getValue(o,"i32")}),this.memoryManager.free(n),this.memoryManager.free(r),this.memoryManager.free(o),a}getAnnotationColor(e,t=F.Color){const n=this.readAnnotationColor(e,t);return n?P(n):void 0}setAnnotationColor(e,t,n=F.Color){const r=c(t);return this.pdfiumModule.EPDFAnnot_SetColor(e,n,255&r.red,255&r.green,255&r.blue)}getAnnotationOpacity(e){const t=this.memoryManager.malloc(4),n=this.pdfiumModule.EPDFAnnot_GetOpacity(e,t)?this.pdfiumModule.pdfium.getValue(t,"i32"):255;return this.memoryManager.free(t),g(n)}setAnnotationOpacity(e,t){const n=k(t);return this.pdfiumModule.EPDFAnnot_SetOpacity(e,255&n)}getAnnotationTextAlignment(e){return this.pdfiumModule.EPDFAnnot_GetTextAlignment(e)}setAnnotationTextAlignment(e,t){return!!this.pdfiumModule.EPDFAnnot_SetTextAlignment(e,t)}getAnnotationVerticalAlignment(e){return this.pdfiumModule.EPDFAnnot_GetVerticalAlignment(e)}setAnnotationVerticalAlignment(e,t){return!!this.pdfiumModule.EPDFAnnot_SetVerticalAlignment(e,t)}getAnnotationDefaultAppearance(e){const t=this.memoryManager.malloc(4),n=this.memoryManager.malloc(4),r=this.memoryManager.malloc(4),o=this.memoryManager.malloc(4),a=this.memoryManager.malloc(4);if(!!!this.pdfiumModule.EPDFAnnot_GetDefaultAppearance(e,t,n,r,o,a))return void[t,n,r,o,a].forEach(e=>this.memoryManager.free(e));const i=this.pdfiumModule.pdfium,s=i.getValue(t,"i32"),u=i.getValue(n,"float"),m=255&i.getValue(r,"i32"),F=255&i.getValue(o,"i32"),l=255&i.getValue(a,"i32");return[t,n,r,o,a].forEach(e=>this.memoryManager.free(e)),{fontFamily:s,fontSize:u,fontColor:P({red:m,green:F,blue:l})}}setAnnotationDefaultAppearance(e,t,n,r){const{red:o,green:a,blue:i}=c(r);return!!this.pdfiumModule.EPDFAnnot_SetDefaultAppearance(e,t,n,255&o,255&a,255&i)}getBorderStyle(e){const t=this.memoryManager.malloc(4);let n=0,r=m.UNKNOWN,o=!1;return r=this.pdfiumModule.EPDFAnnot_GetBorderStyle(e,t),n=this.pdfiumModule.pdfium.getValue(t,"float"),o=r!==m.UNKNOWN,this.memoryManager.free(t),{ok:o,style:r,width:n}}setBorderStyle(e,t,n){return this.pdfiumModule.EPDFAnnot_SetBorderStyle(e,t,n)}getAnnotationIcon(e){return this.pdfiumModule.EPDFAnnot_GetIcon(e)}setAnnotationIcon(e,t){return this.pdfiumModule.EPDFAnnot_SetIcon(e,t)}getBorderEffect(e){const t=this.memoryManager.malloc(4),n=!!this.pdfiumModule.EPDFAnnot_GetBorderEffect(e,t),r=n?this.pdfiumModule.pdfium.getValue(t,"float"):0;return this.memoryManager.free(t),{ok:n,intensity:r}}getRectangleDifferences(e){const t=this.memoryManager.malloc(4),n=this.memoryManager.malloc(4),r=this.memoryManager.malloc(4),o=this.memoryManager.malloc(4),a=!!this.pdfiumModule.EPDFAnnot_GetRectangleDifferences(e,t,n,r,o),i=this.pdfiumModule.pdfium,s=i.getValue(t,"float"),u=i.getValue(n,"float"),m=i.getValue(r,"float"),F=i.getValue(o,"float");return this.memoryManager.free(t),this.memoryManager.free(n),this.memoryManager.free(r),this.memoryManager.free(o),{ok:a,left:s,top:u,right:m,bottom:F}}getAnnotationDate(e,t){const r=this.getAnnotString(e,t);return r?n(r):void 0}setAnnotationDate(e,t,n){const r=h(n);return this.setAnnotString(e,t,r)}getAttachmentDate(e,t){const r=this.getAttachmentString(e,t);return r?n(r):void 0}setAttachmentDate(e,t,n){const r=h(n);return this.setAttachmentString(e,t,r)}getBorderDashPattern(e){const t=this.pdfiumModule.EPDFAnnot_GetBorderDashPatternCount(e);if(0===t)return{ok:!1,pattern:[]};const n=this.memoryManager.malloc(4*t),r=!!this.pdfiumModule.EPDFAnnot_GetBorderDashPattern(e,n,t),o=[];if(r){const e=this.pdfiumModule.pdfium;for(let r=0;r<t;r++)o.push(e.getValue(n+4*r,"float"))}return this.memoryManager.free(n),{ok:r,pattern:o}}setBorderDashPattern(e,t){if(!t||0===t.length)return this.pdfiumModule.EPDFAnnot_SetBorderDashPattern(e,0,0);const n=t.map(e=>Number.isFinite(e)&&e>0?e:0).filter(e=>e>0);if(0===n.length)return this.pdfiumModule.EPDFAnnot_SetBorderDashPattern(e,0,0);const r=4*n.length,o=this.memoryManager.malloc(r);for(let e=0;e<n.length;e++)this.pdfiumModule.pdfium.setValue(o+4*e,n[e],"float");const a=!!this.pdfiumModule.EPDFAnnot_SetBorderDashPattern(e,o,n.length);return this.memoryManager.free(o),a}getLineEndings(e){const t=this.memoryManager.malloc(4),n=this.memoryManager.malloc(4);if(!!!this.pdfiumModule.EPDFAnnot_GetLineEndings(e,t,n))return this.memoryManager.free(t),void this.memoryManager.free(n);const r=this.pdfiumModule.pdfium.getValue(t,"i32"),o=this.pdfiumModule.pdfium.getValue(n,"i32");return this.memoryManager.free(t),this.memoryManager.free(n),{start:r,end:o}}setLineEndings(e,t,n){return!!this.pdfiumModule.EPDFAnnot_SetLineEndings(e,t,n)}getLinePoints(e,t){const n=this.memoryManager.malloc(8),r=this.memoryManager.malloc(8);if(!this.pdfiumModule.FPDFAnnot_GetLine(t,n,r))return this.memoryManager.free(n),void this.memoryManager.free(r);const o=this.pdfiumModule.pdfium,a=o.getValue(n+0,"float"),i=o.getValue(n+4,"float"),s=o.getValue(r+0,"float"),u=o.getValue(r+4,"float");this.memoryManager.free(n),this.memoryManager.free(r);return{start:this.convertPagePointToDevicePoint(e,{x:a,y:i}),end:this.convertPagePointToDevicePoint(e,{x:s,y:u})}}setLinePoints(e,t,n,r){const o=this.convertDevicePointToPagePoint(e,n),a=this.convertDevicePointToPagePoint(e,r);if(!o||!a)return!1;const i=this.memoryManager.malloc(16),s=this.pdfiumModule.pdfium;s.setValue(i+0,o.x,"float"),s.setValue(i+4,o.y,"float"),s.setValue(i+8,a.x,"float"),s.setValue(i+12,a.y,"float");const u=this.pdfiumModule.EPDFAnnot_SetLine(t,i,i+8);return this.memoryManager.free(i),!!u}getQuadPointsAnno(e,t){const n=this.pdfiumModule.FPDFAnnot_CountAttachmentPoints(t);if(0===n)return[];const r=[];for(let o=0;o<n;o++){const n=this.memoryManager.malloc(32);if(this.pdfiumModule.FPDFAnnot_GetAttachmentPoints(t,o,n)){const t=[],o=[];for(let e=0;e<4;e++){const r=n+8*e;t.push(this.pdfiumModule.pdfium.getValue(r,"float")),o.push(this.pdfiumModule.pdfium.getValue(r+4,"float"))}const a=this.convertPagePointToDevicePoint(e,{x:t[0],y:o[0]}),i=this.convertPagePointToDevicePoint(e,{x:t[1],y:o[1]}),s=this.convertPagePointToDevicePoint(e,{x:t[2],y:o[2]}),u=this.convertPagePointToDevicePoint(e,{x:t[3],y:o[3]});r.push({p1:a,p2:i,p3:s,p4:u})}this.memoryManager.free(n)}return r.map(D)}syncQuadPointsAnno(e,t,n){const r=this.pdfiumModule.pdfium,o=this.pdfiumModule.FPDFAnnot_CountAttachmentPoints(t),a=this.memoryManager.malloc(32),i=t=>{const n=b(t),o=this.convertDevicePointToPagePoint(e,n.p1),i=this.convertDevicePointToPagePoint(e,n.p2),s=this.convertDevicePointToPagePoint(e,n.p3),u=this.convertDevicePointToPagePoint(e,n.p4);r.setValue(a+0,o.x,"float"),r.setValue(a+4,o.y,"float"),r.setValue(a+8,i.x,"float"),r.setValue(a+12,i.y,"float"),r.setValue(a+16,u.x,"float"),r.setValue(a+20,u.y,"float"),r.setValue(a+24,s.x,"float"),r.setValue(a+28,s.y,"float")},s=Math.min(o,n.length);for(let e=0;e<s;e++)if(i(n[e]),!this.pdfiumModule.FPDFAnnot_SetAttachmentPoints(t,e,a))return this.memoryManager.free(a),!1;for(let e=o;e<n.length;e++)if(i(n[e]),!this.pdfiumModule.FPDFAnnot_AppendAttachmentPoints(t,a))return this.memoryManager.free(a),!1;return this.memoryManager.free(a),!0}redactTextInRects(n,r,o,a){const{recurseForms:i=!0,drawBlackBoxes:s=!1}=a??{};this.logger.debug("PDFiumEngine","Engine","redactTextInQuads",n.id,r.index,o.length);const u="RedactTextInQuads";this.logger.perf("PDFiumEngine","Engine",u,"Begin",`${n.id}-${r.index}`);const m=this.cache.getContext(n.id);if(!m)return this.logger.perf("PDFiumEngine","Engine",u,"End",`${n.id}-${r.index}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const F=(o??[]).filter(e=>{var t,n,r,o;return e&&Number.isFinite(null==(t=e.origin)?void 0:t.x)&&Number.isFinite(null==(n=e.origin)?void 0:n.y)&&Number.isFinite(null==(r=e.size)?void 0:r.width)&&Number.isFinite(null==(o=e.size)?void 0:o.height)&&e.size.width>0&&e.size.height>0});if(0===F.length)return this.logger.perf("PDFiumEngine","Engine",u,"End",`${n.id}-${r.index}`),e.resolve(!1);const l=m.acquirePage(r.index),{ptr:d,count:_}=this.allocFSQuadsBufferFromRects(r,F);let P=!1;try{P=!!this.pdfiumModule.EPDFText_RedactInQuads(l.pagePtr,d,_,!!i,!!s)}finally{this.memoryManager.free(d)}return P&&(P=!!this.pdfiumModule.FPDFPage_GenerateContent(l.pagePtr)),l.disposeImmediate(),this.logger.perf("PDFiumEngine","Engine",u,"End",`${n.id}-${r.index}`),e.resolve(!!P)}allocFSQuadsBufferFromRects(e,t){const n=t.length,r=this.memoryManager.malloc(32*n),o=this.pdfiumModule.pdfium;for(let a=0;a<n;a++){const n=t[a],i=b(n),s=this.convertDevicePointToPagePoint(e,i.p1),u=this.convertDevicePointToPagePoint(e,i.p2),m=this.convertDevicePointToPagePoint(e,i.p3),F=this.convertDevicePointToPagePoint(e,i.p4),l=r+32*a;o.setValue(l+0,s.x,"float"),o.setValue(l+4,s.y,"float"),o.setValue(l+8,u.x,"float"),o.setValue(l+12,u.y,"float"),o.setValue(l+16,F.x,"float"),o.setValue(l+20,F.y,"float"),o.setValue(l+24,m.x,"float"),o.setValue(l+28,m.y,"float")}return{ptr:r,count:n}}getInkList(e,t){const n=[],r=this.pdfiumModule.FPDFAnnot_GetInkListCount(t);if(r<=0)return n;const o=this.pdfiumModule.pdfium;for(let a=0;a<r;a++){const r=[],i=this.pdfiumModule.FPDFAnnot_GetInkListPath(t,a,0,0);if(i>0){const n=this.memoryManager.malloc(8*i);this.pdfiumModule.FPDFAnnot_GetInkListPath(t,a,n,i);for(let t=0;t<i;t++){const a=n+8*t,i=o.getValue(a+0,"float"),s=o.getValue(a+4,"float"),u=this.convertPagePointToDevicePoint(e,{x:i,y:s});r.push({x:u.x,y:u.y})}this.memoryManager.free(n)}n.push({points:r})}return n}setInkList(e,t,n){const r=this.pdfiumModule.pdfium;for(const o of n){const n=o.points.length;if(0===n)continue;const a=this.memoryManager.malloc(8*n);for(let t=0;t<n;t++){const n=o.points[t],i=this.convertDevicePointToPagePoint(e,n);r.setValue(a+8*t+0,i.x,"float"),r.setValue(a+8*t+4,i.y,"float")}const i=this.pdfiumModule.FPDFAnnot_AddInkStroke(t,a,n);if(this.memoryManager.free(a),-1===i)return!1}return!0}readPdfTextAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getAnnotString(t,"Contents")||"",l=this.getAnnotString(t,"State"),d=this.getAnnotString(t,"StateModel"),_=this.getAnnotationColor(t),P=this.getAnnotationOpacity(t),c=this.getInReplyToId(t),g=this.getAnnotationFlags(t),h=this.getAnnotationIcon(t);return{pageIndex:e.index,custom:r,id:n,type:a.TEXT,flags:g,contents:F,color:_??"#FFFF00",opacity:P,rect:i,inReplyToId:c,author:s,modified:u,created:m,state:l,stateModel:d,icon:h}}readPdfFreeTextAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"Contents")||"",u=this.getAnnotString(t,"T"),m=this.getAnnotationDate(t,"M"),F=this.getAnnotationDate(t,"CreationDate"),l=this.getAnnotString(t,"DS"),d=this.getAnnotationDefaultAppearance(t),_=this.getAnnotationColor(t),P=this.getAnnotationTextAlignment(t),c=this.getAnnotationVerticalAlignment(t),g=this.getAnnotationOpacity(t),h=this.getAnnotRichContent(t),D=this.getAnnotationFlags(t);return{pageIndex:e.index,custom:r,id:n,type:a.FREETEXT,fontFamily:(null==d?void 0:d.fontFamily)??p.Unknown,fontSize:(null==d?void 0:d.fontSize)??12,fontColor:(null==d?void 0:d.fontColor)??"#000000",verticalAlign:c,backgroundColor:_,flags:D,opacity:g,textAlign:P,defaultStyle:l,richContent:h,contents:s,author:u,modified:m,created:F,rect:i}}readPdfLinkAnno(e,t,n,r){const o=this.getAnnotCustom(n),i=this.pdfiumModule.FPDFAnnot_GetLink(n);if(!i)return;const s=this.readPageAnnoRect(n),u=this.convertPageRectToDeviceRect(e,s),m=this.getAnnotString(n,"T"),F=this.getAnnotationDate(n,"M"),l=this.getAnnotationDate(n,"CreationDate"),d=this.getAnnotationFlags(n),_=this.readPdfLinkAnnoTarget(t,()=>this.pdfiumModule.FPDFLink_GetAction(i),()=>this.pdfiumModule.FPDFLink_GetDest(t,i));return{pageIndex:e.index,custom:o,id:r,type:a.LINK,flags:d,target:_,rect:u,author:m,modified:F,created:l}}readPdfWidgetAnno(e,t,n,r){const o=this.getAnnotCustom(t),i=this.readPageAnnoRect(t),s=this.convertPageRectToDeviceRect(e,i),u=this.getAnnotString(t,"T"),m=this.getAnnotationDate(t,"M"),F=this.getAnnotationDate(t,"CreationDate"),l=this.getAnnotationFlags(t),d=this.readPdfWidgetAnnoField(n,t);return{pageIndex:e.index,custom:o,id:r,type:a.WIDGET,flags:l,rect:s,field:d,author:u,modified:m,created:F}}readPdfFileAttachmentAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getAnnotationFlags(t);return{pageIndex:e.index,custom:r,id:n,type:a.FILEATTACHMENT,flags:F,rect:i,author:s,modified:u,created:m}}readPdfInkAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getAnnotationColor(t),l=this.getAnnotationOpacity(t),{width:d}=this.getBorderStyle(t),_=this.getInkList(e,t),P=this.pdfiumModule.EPDFAnnot_GetBlendMode(t),c=this.getAnnotIntent(t),g=this.getAnnotationFlags(t),h=this.getAnnotString(t,"Contents")||"";return{pageIndex:e.index,custom:r,id:n,type:a.INK,...c&&{intent:c},contents:h,blendMode:P,flags:g,color:F??"#FF0000",opacity:l,strokeWidth:0===d?1:d,rect:i,inkList:_,author:s,modified:u,created:m}}readPdfPolygonAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),l=this.getAnnotationDate(t,"CreationDate"),d=this.readPdfAnnoVertices(e,t),_=this.getAnnotString(t,"Contents")||"",P=this.getAnnotationFlags(t),c=this.getAnnotationColor(t),g=this.getAnnotationColor(t,F.InteriorColor),h=this.getAnnotationOpacity(t);let D,{style:b,width:p}=this.getBorderStyle(t);if(b===m.DASHED){const{ok:e,pattern:n}=this.getBorderDashPattern(t);e&&(D=n)}if(d.length>1){const e=d[0],t=d[d.length-1];e.x===t.x&&e.y===t.y&&d.pop()}return{pageIndex:e.index,custom:r,id:n,type:a.POLYGON,contents:_,flags:P,strokeColor:c??"#FF0000",color:g??"transparent",opacity:h,strokeWidth:0===p?1:p,strokeStyle:b,strokeDashArray:D,rect:i,vertices:d,author:s,modified:u,created:l}}readPdfPolylineAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),l=this.getAnnotationDate(t,"CreationDate"),d=this.readPdfAnnoVertices(e,t),_=this.getAnnotString(t,"Contents")||"",P=this.getAnnotationColor(t),c=this.getAnnotationFlags(t),g=this.getAnnotationColor(t,F.InteriorColor),h=this.getAnnotationOpacity(t);let D,{style:b,width:p}=this.getBorderStyle(t);if(b===m.DASHED){const{ok:e,pattern:n}=this.getBorderDashPattern(t);e&&(D=n)}const f=this.getLineEndings(t);return{pageIndex:e.index,custom:r,id:n,type:a.POLYLINE,contents:_,flags:c,strokeColor:P??"#FF0000",color:g??"transparent",opacity:h,strokeWidth:0===p?1:p,strokeStyle:b,strokeDashArray:D,lineEndings:f,rect:i,vertices:d,author:s,modified:u,created:l}}readPdfLineAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),d=this.getAnnotationDate(t,"CreationDate"),_=this.getLinePoints(e,t),P=this.getLineEndings(t),c=this.getAnnotString(t,"Contents")||"",g=this.getAnnotationColor(t),h=this.getAnnotationFlags(t),D=this.getAnnotationColor(t,F.InteriorColor),b=this.getAnnotationOpacity(t);let p,{style:f,width:A}=this.getBorderStyle(t);if(f===m.DASHED){const{ok:e,pattern:n}=this.getBorderDashPattern(t);e&&(p=n)}return{pageIndex:e.index,custom:r,id:n,type:a.LINE,flags:h,rect:i,contents:c,strokeWidth:0===A?1:A,strokeStyle:f,strokeDashArray:p,strokeColor:g??"#FF0000",color:D??"transparent",opacity:b,linePoints:_||{start:{x:0,y:0},end:{x:0,y:0}},lineEndings:P||{start:l.None,end:l.None},author:s,modified:u,created:d}}readPdfHighlightAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getQuadPointsAnno(e,t),u=this.getAnnotationColor(t),m=this.getAnnotationOpacity(t),F=this.pdfiumModule.EPDFAnnot_GetBlendMode(t),l=this.getAnnotString(t,"T"),d=this.getAnnotationDate(t,"M"),_=this.getAnnotationDate(t,"CreationDate"),P=this.getAnnotString(t,"Contents")||"",c=this.getAnnotationFlags(t);return{pageIndex:e.index,custom:r,id:n,blendMode:F,type:a.HIGHLIGHT,rect:i,flags:c,contents:P,segmentRects:s,color:u??"#FFFF00",opacity:m,author:l,modified:d,created:_}}readPdfUnderlineAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getQuadPointsAnno(e,t),l=this.getAnnotString(t,"Contents")||"",d=this.getAnnotationColor(t),_=this.getAnnotationOpacity(t),P=this.pdfiumModule.EPDFAnnot_GetBlendMode(t),c=this.getAnnotationFlags(t);return{pageIndex:e.index,custom:r,id:n,blendMode:P,type:a.UNDERLINE,rect:i,flags:c,contents:l,segmentRects:F,color:d??"#FF0000",opacity:_,author:s,modified:u,created:m}}readPdfStrikeOutAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getQuadPointsAnno(e,t),l=this.getAnnotString(t,"Contents")||"",d=this.getAnnotationColor(t),_=this.getAnnotationOpacity(t),P=this.pdfiumModule.EPDFAnnot_GetBlendMode(t),c=this.getAnnotationFlags(t);return{pageIndex:e.index,custom:r,id:n,blendMode:P,type:a.STRIKEOUT,flags:c,rect:i,contents:l,segmentRects:F,color:d??"#FF0000",opacity:_,author:s,modified:u,created:m}}readPdfSquigglyAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getQuadPointsAnno(e,t),l=this.getAnnotString(t,"Contents")||"",d=this.getAnnotationColor(t),_=this.getAnnotationOpacity(t),P=this.pdfiumModule.EPDFAnnot_GetBlendMode(t),c=this.getAnnotationFlags(t);return{pageIndex:e.index,custom:r,id:n,blendMode:P,type:a.SQUIGGLY,rect:i,flags:c,contents:l,segmentRects:F,color:d??"#FF0000",opacity:_,author:s,modified:u,created:m}}readPdfCaretAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getAnnotationFlags(t);return{pageIndex:e.index,custom:r,id:n,type:a.CARET,rect:i,flags:F,author:s,modified:u,created:m}}readPdfStampAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.readPageAnnoRect(t),i=this.convertPageRectToDeviceRect(e,o),s=this.getAnnotString(t,"T"),u=this.getAnnotationDate(t,"M"),m=this.getAnnotationDate(t,"CreationDate"),F=this.getAnnotationFlags(t),l=this.getAnnotString(t,"Contents")||"";return{pageIndex:e.index,custom:r,id:n,type:a.STAMP,contents:l,rect:i,author:s,modified:u,created:m,flags:F}}readPdfPageObject(e){switch(this.pdfiumModule.FPDFPageObj_GetType(e)){case f.PATH:return this.readPathObject(e);case f.IMAGE:return this.readImageObject(e);case f.FORM:return this.readFormObject(e)}}readPathObject(e){const t=this.pdfiumModule.FPDFPath_CountSegments(e),n=this.memoryManager.malloc(4),r=this.memoryManager.malloc(4),o=this.memoryManager.malloc(4),a=this.memoryManager.malloc(4);this.pdfiumModule.FPDFPageObj_GetBounds(e,n,r,o,a);const i={left:this.pdfiumModule.pdfium.getValue(n,"float"),bottom:this.pdfiumModule.pdfium.getValue(r,"float"),right:this.pdfiumModule.pdfium.getValue(o,"float"),top:this.pdfiumModule.pdfium.getValue(a,"float")};this.memoryManager.free(n),this.memoryManager.free(r),this.memoryManager.free(o),this.memoryManager.free(a);const s=[];for(let n=0;n<t;n++){const t=this.readPdfSegment(e,n);s.push(t)}const u=this.readPdfPageObjectTransformMatrix(e);return{type:f.PATH,bounds:i,segments:s,matrix:u}}readPdfSegment(e,t){const n=this.pdfiumModule.FPDFPath_GetPathSegment(e,t),r=this.pdfiumModule.FPDFPathSegment_GetType(n),o=this.pdfiumModule.FPDFPathSegment_GetClose(n),a=this.memoryManager.malloc(4),i=this.memoryManager.malloc(4);this.pdfiumModule.FPDFPathSegment_GetPoint(n,a,i);const s=this.pdfiumModule.pdfium.getValue(a,"float"),u=this.pdfiumModule.pdfium.getValue(i,"float");return this.memoryManager.free(a),this.memoryManager.free(i),{type:r,point:{x:s,y:u},isClosed:o}}readImageObject(e){const t=this.pdfiumModule.FPDFImageObj_GetBitmap(e),n=this.pdfiumModule.FPDFBitmap_GetBuffer(t),r=this.pdfiumModule.FPDFBitmap_GetWidth(t),o=this.pdfiumModule.FPDFBitmap_GetHeight(t),a=this.pdfiumModule.FPDFBitmap_GetFormat(t),i=r*o,s=new Uint8ClampedArray(4*i);for(let e=0;e<i;e++)if(2===a){const t=this.pdfiumModule.pdfium.getValue(n+3*e,"i8"),r=this.pdfiumModule.pdfium.getValue(n+3*e+1,"i8"),o=this.pdfiumModule.pdfium.getValue(n+3*e+2,"i8");s[4*e]=o,s[4*e+1]=r,s[4*e+2]=t,s[4*e+3]=100}const u=new ImageData(s,r,o),m=this.readPdfPageObjectTransformMatrix(e);return{type:f.IMAGE,imageData:u,matrix:m}}readFormObject(e){const t=this.pdfiumModule.FPDFFormObj_CountObjects(e),n=[];for(let r=0;r<t;r++){const t=this.pdfiumModule.FPDFFormObj_GetObject(e,r),o=this.readPdfPageObject(t);o&&n.push(o)}const r=this.readPdfPageObjectTransformMatrix(e);return{type:f.FORM,objects:n,matrix:r}}readPdfPageObjectTransformMatrix(e){const t=this.memoryManager.malloc(24);if(this.pdfiumModule.FPDFPageObj_GetMatrix(e,t)){const e=this.pdfiumModule.pdfium.getValue(t,"float"),n=this.pdfiumModule.pdfium.getValue(t+4,"float"),r=this.pdfiumModule.pdfium.getValue(t+8,"float"),o=this.pdfiumModule.pdfium.getValue(t+12,"float"),a=this.pdfiumModule.pdfium.getValue(t+16,"float"),i=this.pdfiumModule.pdfium.getValue(t+20,"float");return this.memoryManager.free(t),{a:e,b:n,c:r,d:o,e:a,f:i}}return this.memoryManager.free(t),{a:1,b:0,c:0,d:1,e:0,f:0}}readStampAnnotationContents(e){const t=[],n=this.pdfiumModule.FPDFAnnot_GetObjectCount(e);for(let r=0;r<n;r++){const n=this.pdfiumModule.FPDFAnnot_GetObject(e,r),o=this.readPdfPageObject(n);o&&t.push(o)}return t}getStrokeWidth(e){const t=this.memoryManager.malloc(4),n=this.memoryManager.malloc(4),r=this.memoryManager.malloc(4),o=this.pdfiumModule.FPDFAnnot_GetBorder(e,t,n,r)?this.pdfiumModule.pdfium.getValue(r,"float"):1;return this.memoryManager.free(t),this.memoryManager.free(n),this.memoryManager.free(r),o}getAnnotationFlags(e){const t=this.pdfiumModule.FPDFAnnot_GetFlags(e);return A(t)}setAnnotationFlags(e,t){const n=E(t);return this.pdfiumModule.FPDFAnnot_SetFlags(e,n)}readPdfCircleAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.getAnnotationFlags(t),i=this.readPageAnnoRect(t),s=this.convertPageRectToDeviceRect(e,i),u=this.getAnnotString(t,"T"),l=this.getAnnotationDate(t,"M"),d=this.getAnnotationDate(t,"CreationDate"),_=this.getAnnotString(t,"Contents")||"",P=this.getAnnotationColor(t,F.InteriorColor),c=this.getAnnotationColor(t),g=this.getAnnotationOpacity(t);let h,{style:D,width:b}=this.getBorderStyle(t);if(D===m.DASHED){const{ok:e,pattern:n}=this.getBorderDashPattern(t);e&&(h=n)}return{pageIndex:e.index,custom:r,id:n,type:a.CIRCLE,flags:o,color:P??"transparent",opacity:g,contents:_,strokeWidth:b,strokeColor:c??"#FF0000",strokeStyle:D,rect:s,author:u,modified:l,created:d,...void 0!==h&&{strokeDashArray:h}}}readPdfSquareAnno(e,t,n){const r=this.getAnnotCustom(t),o=this.getAnnotationFlags(t),i=this.readPageAnnoRect(t),s=this.convertPageRectToDeviceRect(e,i),u=this.getAnnotString(t,"T"),l=this.getAnnotationDate(t,"M"),d=this.getAnnotationDate(t,"CreationDate"),_=this.getAnnotString(t,"Contents")||"",P=this.getAnnotationColor(t,F.InteriorColor),c=this.getAnnotationColor(t),g=this.getAnnotationOpacity(t);let h,{style:D,width:b}=this.getBorderStyle(t);if(D===m.DASHED){const{ok:e,pattern:n}=this.getBorderDashPattern(t);e&&(h=n)}return{pageIndex:e.index,custom:r,id:n,type:a.SQUARE,flags:o,color:P??"transparent",opacity:g,contents:_,strokeColor:c??"#FF0000",strokeWidth:b,strokeStyle:D,rect:s,author:u,modified:l,created:d,...void 0!==h&&{strokeDashArray:h}}}readPdfAnno(e,t,n,r){const o=this.getAnnotCustom(n),a=this.readPageAnnoRect(n),i=this.convertPageRectToDeviceRect(e,a),s=this.getAnnotString(n,"T"),u=this.getAnnotationDate(n,"M"),m=this.getAnnotationDate(n,"CreationDate"),F=this.getAnnotationFlags(n);return{pageIndex:e.index,custom:o,id:r,flags:F,type:t,rect:i,author:s,modified:u,created:m}}getInReplyToId(e){const t=this.pdfiumModule.FPDFAnnot_GetLinkedAnnot(e,"IRT");if(t)return this.getAnnotString(t,"NM")}setInReplyToId(e,t,n){const r=this.getAnnotationByName(e,n);return!!r&&this.pdfiumModule.EPDFAnnot_SetLinkedAnnot(t,"IRT",r)}getAnnotString(e,t){const n=this.pdfiumModule.FPDFAnnot_GetStringValue(e,t,0,0);if(0===n)return;const r=2*(n+1),o=this.memoryManager.malloc(r);this.pdfiumModule.FPDFAnnot_GetStringValue(e,t,o,r);const a=this.pdfiumModule.pdfium.UTF16ToString(o);return this.memoryManager.free(o),a||void 0}getAttachmentString(e,t){const n=this.pdfiumModule.FPDFAttachment_GetStringValue(e,t,0,0);if(0===n)return;const r=2*(n+1),o=this.memoryManager.malloc(r);this.pdfiumModule.FPDFAttachment_GetStringValue(e,t,o,r);const a=this.pdfiumModule.pdfium.UTF16ToString(o);return this.memoryManager.free(o),a||void 0}getAttachmentNumber(e,t){const n=this.memoryManager.malloc(4);try{if(!this.pdfiumModule.EPDFAttachment_GetIntegerValue(e,t,n))return;return this.pdfiumModule.pdfium.getValue(n,"i32")>>>0}finally{this.memoryManager.free(n)}}getAnnotCustom(e){const t=this.getAnnotString(e,"EPDFCustom");if(t)try{return JSON.parse(t)}catch(e){return console.warn("Failed to parse annotation custom data as JSON:",e),void console.warn("Invalid JSON string:",t)}}setAnnotCustom(e,t){if(null==t)return this.setAnnotString(e,"EPDFCustom","");try{const n=JSON.stringify(t);return this.setAnnotString(e,"EPDFCustom",n)}catch(e){return console.warn("Failed to stringify annotation custom data as JSON:",e),console.warn("Invalid data object:",t),!1}}getAnnotIntent(e){const t=this.pdfiumModule.EPDFAnnot_GetIntent(e,0,0);if(0===t)return;const n=2*(t+1),r=this.memoryManager.malloc(n);this.pdfiumModule.EPDFAnnot_GetIntent(e,r,n);const o=this.pdfiumModule.pdfium.UTF16ToString(r);return this.memoryManager.free(r),o&&"undefined"!==o?o:void 0}setAnnotIntent(e,t){return this.pdfiumModule.EPDFAnnot_SetIntent(e,t)}getAnnotRichContent(e){const t=this.pdfiumModule.EPDFAnnot_GetRichContent(e,0,0);if(0===t)return;const n=2*(t+1),r=this.memoryManager.malloc(n);this.pdfiumModule.EPDFAnnot_GetRichContent(e,r,n);const o=this.pdfiumModule.pdfium.UTF16ToString(r);return this.memoryManager.free(r),o||void 0}getAnnotationByName(e,t){return this.withWString(t,t=>this.pdfiumModule.EPDFPage_GetAnnotByName(e,t))}removeAnnotationByName(e,t){return this.withWString(t,t=>this.pdfiumModule.EPDFPage_RemoveAnnotByName(e,t))}setAnnotString(e,t,n){return this.withWString(n,n=>this.pdfiumModule.FPDFAnnot_SetStringValue(e,t,n))}setAttachmentString(e,t,n){return this.withWString(n,n=>this.pdfiumModule.FPDFAttachment_SetStringValue(e,t,n))}readPdfAnnoVertices(e,t){const n=[],r=this.pdfiumModule.FPDFAnnot_GetVertices(t,0,0),o=this.memoryManager.malloc(8*r);this.pdfiumModule.FPDFAnnot_GetVertices(t,o,r);for(let t=0;t<r;t++){const r=this.pdfiumModule.pdfium.getValue(o+8*t,"float"),a=this.pdfiumModule.pdfium.getValue(o+8*t+4,"float"),{x:i,y:s}=this.convertPagePointToDevicePoint(e,{x:r,y:a}),u=n[n.length-1];u&&u.x===i&&u.y===s||n.push({x:i,y:s})}return this.memoryManager.free(o),n}setPdfAnnoVertices(e,t,n){const r=this.pdfiumModule.pdfium,o=this.memoryManager.malloc(8*n.length);n.forEach((t,n)=>{const a=this.convertDevicePointToPagePoint(e,t);r.setValue(o+8*n+0,a.x,"float"),r.setValue(o+8*n+4,a.y,"float")});const a=this.pdfiumModule.EPDFAnnot_SetVertices(t,o,n.length);return this.memoryManager.free(o),a}readPdfBookmarkTarget(e,t,n){const r=t();if(r){return{type:"action",action:this.readPdfAction(e,r)}}{const t=n();if(t){return{type:"destination",destination:this.readPdfDestination(e,t)}}}}readPdfWidgetAnnoField(e,t){const n=this.pdfiumModule.FPDFAnnot_GetFormFieldFlags(e,t),r=this.pdfiumModule.FPDFAnnot_GetFormFieldType(e,t),o=V(this.pdfiumModule.pdfium,(n,r)=>this.pdfiumModule.FPDFAnnot_GetFormFieldName(e,t,n,r),this.pdfiumModule.pdfium.UTF16ToString),a=V(this.pdfiumModule.pdfium,(n,r)=>this.pdfiumModule.FPDFAnnot_GetFormFieldAlternateName(e,t,n,r),this.pdfiumModule.pdfium.UTF16ToString),i=V(this.pdfiumModule.pdfium,(n,r)=>this.pdfiumModule.FPDFAnnot_GetFormFieldValue(e,t,n,r),this.pdfiumModule.pdfium.UTF16ToString),s=[];if(r===M.COMBOBOX||r===M.LISTBOX){const n=this.pdfiumModule.FPDFAnnot_GetOptionCount(e,t);for(let r=0;r<n;r++){const n=V(this.pdfiumModule.pdfium,(n,o)=>this.pdfiumModule.FPDFAnnot_GetOptionLabel(e,t,r,n,o),this.pdfiumModule.pdfium.UTF16ToString),o=this.pdfiumModule.FPDFAnnot_IsOptionSelected(e,t,r);s.push({label:n,isSelected:o})}}let u=!1;return r!==M.CHECKBOX&&r!==M.RADIOBUTTON||(u=this.pdfiumModule.FPDFAnnot_IsChecked(e,t)),{flag:n,type:r,name:o,alternateName:a,value:i,isChecked:u,options:s}}renderPageAnnotationRaw(n,r,o,a){const{scaleFactor:i=1,rotation:s=y.Degree0,dpr:u=1,mode:m=G.Normal}=a??{};this.logger.debug(ee,te,"renderPageAnnotation",n,r,o,a),this.logger.perf(ee,te,"RenderPageAnnotation","Begin",`${n.id}-${r.index}-${o.id}`);const F=new w,l=this.cache.getContext(n.id);if(!l)return this.logger.perf(ee,te,"RenderPageAnnotation","End",`${n.id}-${r.index}-${o.id}`),e.reject({code:t.DocNotOpen,message:"document does not open"});const d=l.acquirePage(r.index),_=this.getAnnotationByName(d.pagePtr,o.id);if(!_)return this.logger.perf(ee,te,"RenderPageAnnotation","End",`${n.id}-${r.index}-${o.id}`),d.release(),e.reject({code:t.NotFound,message:"annotation not found"});const P=Math.max(.01,i*u),c=S(o.rect),g=S(C(r.size,c,s,P)),h=Math.max(1,g.size.width),D=Math.max(1,g.size.height),b=4*h,p=b*D,f=this.memoryManager.malloc(p),A=this.pdfiumModule.FPDFBitmap_CreateEx(h,D,4,f,b);this.pdfiumModule.FPDFBitmap_FillRect(A,0,0,h,D,0);const E=T(c,s,h,D),M=this.memoryManager.malloc(24);new Float32Array(this.pdfiumModule.pdfium.HEAPF32.buffer,M,6).set([E.a,E.b,E.c,E.d,E.e,E.f]);let x=!1;try{x=!!this.pdfiumModule.EPDF_RenderAnnotBitmap(A,d.pagePtr,_,m,M,16)}finally{this.memoryManager.free(M),this.pdfiumModule.FPDFBitmap_Destroy(A),this.pdfiumModule.FPDFPage_CloseAnnot(_),d.release()}if(!x)return this.memoryManager.free(f),this.logger.perf(ee,te,"RenderPageAnnotation","End",`${n.id}-${r.index}-${o.id}`),e.reject({code:t.Unknown,message:"EPDF_RenderAnnotBitmap failed"});const v=this.pdfiumModule.pdfium.HEAPU8.subarray(f,f+p),O=new ImageData(new Uint8ClampedArray(v),h,D);return F.resolve(O),this.memoryManager.free(f),F}renderRectEncoded(n,r,o,a){const i=new w,s=(null==a?void 0:a.rotation)??y.Degree0,u=this.cache.getContext(n.id);if(!u)return e.reject({code:t.DocNotOpen,message:"document does not open"});const m=Math.max(.01,(null==a?void 0:a.scaleFactor)??1)*Math.max(1,(null==a?void 0:a.dpr)??1),F=o.size.width,l=o.size.height,d=!(1&~s),_=Math.max(1,Math.round((d?l:F)*m)),P=Math.max(1,Math.round((d?F:l)*m)),c=4*_,g=c*P,h=u.acquirePage(r.index),D=(null==a?void 0:a.withForms)??!1?h.getFormHandle():void 0,b=this.memoryManager.malloc(g),p=this.pdfiumModule.FPDFBitmap_CreateEx(_,P,4,b,c);this.pdfiumModule.FPDFBitmap_FillRect(p,0,0,_,P,4294967295);const f=T(o,s,_,P),A=this.memoryManager.malloc(24);new Float32Array(this.pdfiumModule.pdfium.HEAPF32.buffer,A,6).set([f.a,f.b,f.c,f.d,f.e,f.f]);const E=this.memoryManager.malloc(16);new Float32Array(this.pdfiumModule.pdfium.HEAPF32.buffer,E,4).set([0,0,_,P]);let M=16;(null==a?void 0:a.withAnnotations)&&(M|=1);try{if(this.pdfiumModule.FPDF_RenderPageBitmapWithMatrix(p,h.pagePtr,A,E,M),void 0!==D){const e=function(e,t,n,r){const o=t.origin.x,a=t.origin.y,i=o+t.size.width,s=a+t.size.height,u=n.width,m=n.height,F=Math.hypot(e.a,e.b),l=Math.hypot(e.c,e.d),d=!(1&~r),_=d?Math.max(1,Math.round(m*F)):Math.max(1,Math.round(u*F)),P=d?Math.max(1,Math.round(u*l)):Math.max(1,Math.round(m*l));let c,g;switch(r){case y.Degree0:c=-Math.round(o*F),g=-Math.round(a*l);break;case y.Degree90:c=Math.round((s-m)*F),g=-Math.round(o*l);break;case y.Degree180:c=Math.round((i-u)*F),g=Math.round((s-m)*l);break;case y.Degree270:c=-Math.round(a*F),g=Math.round((i-u)*l);break;default:c=-Math.round(o*F),g=-Math.round(a*l)}return{startX:c,startY:g,formsWidth:_,formsHeight:P,scaleX:F,scaleY:l}}(f,o,r.size,s),{startX:t,startY:n,formsWidth:a,formsHeight:i,scaleX:u,scaleY:m}=e;this.pdfiumModule.FPDF_FFLDraw(D,p,h.pagePtr,t,n,a,i,s,M)}}finally{h.release(),this.memoryManager.free(A),this.memoryManager.free(E)}this.logger.perf(ee,te,"RenderRectEncodedData","Begin",`${n.id}-${r.index}`);const G=this.pdfiumModule.pdfium.HEAPU8.subarray(b,b+g);this.logger.perf(ee,te,"RenderRectEncodedData","End",`${n.id}-${r.index}`),this.logger.perf(ee,te,"RenderRectEncodedImageData","Begin",`${n.id}-${r.index}`);const S=new ImageData(new Uint8ClampedArray(G),_,P);return this.logger.perf(ee,te,"RenderRectEncodedImageData","End",`${n.id}-${r.index}`),i.resolve(S),this.pdfiumModule.FPDFBitmap_Destroy(p),this.memoryManager.free(b),i}readPdfLinkAnnoTarget(e,t,n){const r=n();if(r){return{type:"destination",destination:this.readPdfDestination(e,r)}}{const n=t();if(n){return{type:"action",action:this.readPdfAction(e,n)}}}}createLocalDestPtr(e,t){var n,r;const o=this.pdfiumModule.FPDF_LoadPage(e,t.pageIndex);if(!o)return 0;try{if(t.zoom.mode===x.XYZ){const{x:e,y:n,zoom:r}=t.zoom.params;return this.pdfiumModule.EPDFDest_CreateXYZ(o,!0,e,!0,n,!0,r)}let e,a=[];switch(t.zoom.mode){case x.FitPage:e=x.FitPage;break;case x.FitHorizontal:e=x.FitHorizontal,a=[(null==(n=t.view)?void 0:n[0])??0];break;case x.FitVertical:e=x.FitVertical,a=[(null==(r=t.view)?void 0:r[0])??0];break;case x.FitRectangle:{const n=t.view??[];a=[n[0]??0,n[1]??0,n[2]??0,n[3]??0],e=x.FitRectangle}break;case x.Unknown:default:return 0}return this.withFloatArray(a,(t,n)=>this.pdfiumModule.EPDFDest_CreateView(o,e,t,n))}finally{this.pdfiumModule.FPDF_ClosePage(o)}}applyBookmarkTarget(e,t,n){if("destination"===n.type){const r=this.createLocalDestPtr(e,n.destination);if(!r)return!1;return!!this.pdfiumModule.EPDFBookmark_SetDest(e,t,r)}const r=n.action;switch(r.type){case v.Goto:{const n=this.createLocalDestPtr(e,r.destination);if(!n)return!1;const o=this.pdfiumModule.EPDFAction_CreateGoTo(e,n);return!!o&&!!this.pdfiumModule.EPDFBookmark_SetAction(e,t,o)}case v.URI:{const n=this.pdfiumModule.EPDFAction_CreateURI(e,r.uri);return!!n&&!!this.pdfiumModule.EPDFBookmark_SetAction(e,t,n)}case v.LaunchAppOrOpenFile:{const n=this.withWString(r.path,t=>this.pdfiumModule.EPDFAction_CreateLaunch(e,t));return!!n&&!!this.pdfiumModule.EPDFBookmark_SetAction(e,t,n)}case v.RemoteGoto:case v.Unsupported:default:return!1}}readPdfAction(e,t){let n;switch(this.pdfiumModule.FPDFAction_GetType(t)){case v.Unsupported:n={type:v.Unsupported};break;case v.Goto:{const r=this.pdfiumModule.FPDFAction_GetDest(e,t);if(r){const t=this.readPdfDestination(e,r);n={type:v.Goto,destination:t}}else n={type:v.Unsupported}}break;case v.RemoteGoto:n={type:v.Unsupported};break;case v.URI:{const r=V(this.pdfiumModule.pdfium,(n,r)=>this.pdfiumModule.FPDFAction_GetURIPath(e,t,n,r),this.pdfiumModule.pdfium.UTF8ToString);n={type:v.URI,uri:r}}break;case v.LaunchAppOrOpenFile:{const e=V(this.pdfiumModule.pdfium,(e,n)=>this.pdfiumModule.FPDFAction_GetFilePath(t,e,n),this.pdfiumModule.pdfium.UTF8ToString);n={type:v.LaunchAppOrOpenFile,path:e}}}return n}readPdfDestination(e,t){const n=this.pdfiumModule.FPDFDest_GetDestPageIndex(e,t),r=this.memoryManager.malloc(4),o=this.memoryManager.malloc(16),a=this.pdfiumModule.FPDFDest_GetView(t,r,o),i=this.pdfiumModule.pdfium.getValue(r,"i32"),s=[];for(let e=0;e<i;e++){const t=o+4*e;s.push(this.pdfiumModule.pdfium.getValue(t,"float"))}if(this.memoryManager.free(r),this.memoryManager.free(o),a===x.XYZ){const e=this.memoryManager.malloc(1),r=this.memoryManager.malloc(1),o=this.memoryManager.malloc(1),i=this.memoryManager.malloc(4),u=this.memoryManager.malloc(4),m=this.memoryManager.malloc(4);if(this.pdfiumModule.FPDFDest_GetLocationInPage(t,e,r,o,i,u,m)){const t=this.pdfiumModule.pdfium.getValue(e,"i8"),F=this.pdfiumModule.pdfium.getValue(r,"i8"),l=this.pdfiumModule.pdfium.getValue(o,"i8"),d=t?this.pdfiumModule.pdfium.getValue(i,"float"):0,_=F?this.pdfiumModule.pdfium.getValue(u,"float"):0,P=l?this.pdfiumModule.pdfium.getValue(m,"float"):0;return this.memoryManager.free(e),this.memoryManager.free(r),this.memoryManager.free(o),this.memoryManager.free(i),this.memoryManager.free(u),this.memoryManager.free(m),{pageIndex:n,zoom:{mode:a,params:{x:d,y:_,zoom:P}},view:s}}return this.memoryManager.free(e),this.memoryManager.free(r),this.memoryManager.free(o),this.memoryManager.free(i),this.memoryManager.free(u),this.memoryManager.free(m),{pageIndex:n,zoom:{mode:a,params:{x:0,y:0,zoom:0}},view:s}}return{pageIndex:n,zoom:{mode:a},view:s}}readPdfAttachment(e,t){const n=this.pdfiumModule.FPDFDoc_GetAttachment(e,t),r=V(this.pdfiumModule.pdfium,(e,t)=>this.pdfiumModule.FPDFAttachment_GetName(n,e,t),this.pdfiumModule.pdfium.UTF16ToString),o=V(this.pdfiumModule.pdfium,(e,t)=>this.pdfiumModule.EPDFAttachment_GetDescription(n,e,t),this.pdfiumModule.pdfium.UTF16ToString),a=V(this.pdfiumModule.pdfium,(e,t)=>this.pdfiumModule.FPDFAttachment_GetSubtype(n,e,t),this.pdfiumModule.pdfium.UTF16ToString),i=this.getAttachmentDate(n,"CreationDate"),s=V(this.pdfiumModule.pdfium,(e,t)=>this.pdfiumModule.FPDFAttachment_GetStringValue(n,"Checksum",e,t),this.pdfiumModule.pdfium.UTF16ToString);return{index:t,name:r,description:o,mimeType:a,size:this.getAttachmentNumber(n,"Size"),creationDate:i,checksum:s}}convertDevicePointToPagePoint(e,t){const n=e.size.width,r=e.size.height,o=3&e.rotation;return 0===o?{x:t.x,y:r-t.y}:1===o?{x:t.y,y:t.x}:2===o?{x:n-t.x,y:t.y}:{x:r-t.y,y:n-t.x}}convertPagePointToDevicePoint(e,t){const n=e.size.width,r=e.size.height,o=3&e.rotation;return 0===o?{x:t.x,y:r-t.y}:1===o?{x:t.y,y:t.x}:2===o?{x:n-t.x,y:t.y}:{x:n-t.y,y:r-t.x}}convertPageRectToDeviceRect(e,t){const{x:n,y:r}=this.convertPagePointToDevicePoint(e,{x:t.left,y:t.top});return{origin:{x:n,y:r},size:{width:Math.abs(t.right-t.left),height:Math.abs(t.top-t.bottom)}}}readPageAnnoAppearanceStreams(e){return{normal:this.readPageAnnoAppearanceStream(e,G.Normal),rollover:this.readPageAnnoAppearanceStream(e,G.Rollover),down:this.readPageAnnoAppearanceStream(e,G.Down)}}readPageAnnoAppearanceStream(e,t=G.Normal){const n=2*(this.pdfiumModule.FPDFAnnot_GetAP(e,t,0,0)+1),r=this.memoryManager.malloc(n);this.pdfiumModule.FPDFAnnot_GetAP(e,t,r,n);const o=this.pdfiumModule.pdfium.UTF16ToString(r);return this.memoryManager.free(r),o}setPageAnnoAppearanceStream(e,t=G.Normal,n){const r=2*(n.length+1),o=this.memoryManager.malloc(r);try{this.pdfiumModule.pdfium.stringToUTF16(n,o,r);return!!this.pdfiumModule.FPDFAnnot_SetAP(e,t,o)}finally{this.memoryManager.free(o)}}setPageAnnoRect(e,t,n){const r=Math.floor(n.origin.x),o=Math.floor(n.origin.y),a=Math.floor(n.origin.x+n.size.width),i=Math.floor(n.origin.y+n.size.height),s=this.convertDevicePointToPagePoint(e,{x:r,y:o}),u=this.convertDevicePointToPagePoint(e,{x:a,y:o}),m=this.convertDevicePointToPagePoint(e,{x:a,y:i}),F=this.convertDevicePointToPagePoint(e,{x:r,y:i});let l=Math.min(s.x,u.x,m.x,F.x),d=Math.max(s.x,u.x,m.x,F.x),_=Math.min(s.y,u.y,m.y,F.y),P=Math.max(s.y,u.y,m.y,F.y);l>d&&([l,d]=[d,l]),_>P&&([_,P]=[P,_]);const c=this.memoryManager.malloc(16),g=this.pdfiumModule.pdfium;g.setValue(c+0,l,"float"),g.setValue(c+4,P,"float"),g.setValue(c+8,d,"float"),g.setValue(c+12,_,"float");const h=this.pdfiumModule.FPDFAnnot_SetRect(t,c);return this.memoryManager.free(c),!!h}readPageAnnoRect(e){const t=this.memoryManager.malloc(16),n={left:0,top:0,right:0,bottom:0};return this.pdfiumModule.FPDFAnnot_GetRect(e,t)&&(n.left=this.pdfiumModule.pdfium.getValue(t,"float"),n.top=this.pdfiumModule.pdfium.getValue(t+4,"float"),n.right=this.pdfiumModule.pdfium.getValue(t+8,"float"),n.bottom=this.pdfiumModule.pdfium.getValue(t+12,"float")),this.memoryManager.free(t),n}getHighlightRects(e,t,n,r){const o=this.pdfiumModule.FPDFText_CountRects(t,n,r),a=[],i=this.memoryManager.malloc(8),s=this.memoryManager.malloc(8),u=this.memoryManager.malloc(8),m=this.memoryManager.malloc(8);for(let n=0;n<o;n++){if(!this.pdfiumModule.FPDFText_GetRect(t,n,i,s,u,m))continue;const r=this.pdfiumModule.pdfium.getValue(i,"double"),o=this.pdfiumModule.pdfium.getValue(s,"double"),F=this.pdfiumModule.pdfium.getValue(u,"double"),l=this.pdfiumModule.pdfium.getValue(m,"double"),d=this.convertPagePointToDevicePoint(e,{x:r,y:o}),_=this.convertPagePointToDevicePoint(e,{x:F,y:o}),P=this.convertPagePointToDevicePoint(e,{x:F,y:l}),c=this.convertPagePointToDevicePoint(e,{x:r,y:l}),g=[d.x,_.x,P.x,c.x],h=[d.y,_.y,P.y,c.y],D=Math.min(...g),b=Math.min(...h),p=Math.max(...g)-D,f=Math.max(...h)-b;a.push({origin:{x:D,y:b},size:{width:Math.ceil(p),height:Math.ceil(f)}})}return this.memoryManager.free(i),this.memoryManager.free(s),this.memoryManager.free(u),this.memoryManager.free(m),a}searchInPage(n,r,o,a){this.logger.debug(ee,te,"searchInPage",n,r,o,a),this.logger.perf(ee,te,"SearchInPage","Begin",`${n.id}-${r.index}`);const i=this.cache.getContext(n.id);if(!i)return this.logger.perf(ee,te,"PreparePrintDocument","End",n.id),e.reject({code:t.DocNotOpen,message:"Document is not open"});const s=2*(o.length+1),u=this.memoryManager.malloc(s);this.pdfiumModule.pdfium.stringToUTF16(o,u,s);try{const t=this.searchAllInPage(i,r,u,a);return e.resolve(t)}finally{this.memoryManager.free(u)}}getAnnotationsBatch(e,n){this.logger.debug(ee,te,"getAnnotationsBatch",e.id,n.length);const r=new w;return queueMicrotask(()=>{this.logger.perf(ee,te,"GetAnnotationsBatch","Begin",e.id);const o=this.cache.getContext(e.id);if(!o)return void r.reject({code:t.DocNotOpen,message:"Document is not open"});const a={},i=n.length;for(let e=0;e<n.length;e++){const t=n[e],s=this.readPageAnnotationsRaw(o,t);a[t.index]=s,r.progress({pageIndex:t.index,result:s,completed:e+1,total:i})}this.logger.perf(ee,te,"GetAnnotationsBatch","End",e.id),r.resolve(a)}),r}searchBatch(e,n,r,o){this.logger.debug(ee,te,"searchBatch",e.id,n.length,r);const a=new w;return queueMicrotask(()=>{this.logger.perf(ee,te,"SearchBatch","Begin",e.id);const i=this.cache.getContext(e.id);if(!i)return void a.reject({code:t.DocNotOpen,message:"Document is not open"});const s=2*(r.length+1),u=this.memoryManager.malloc(s);this.pdfiumModule.pdfium.stringToUTF16(r,u,s);try{const t={},r=n.length;for(let e=0;e<n.length;e++){const s=n[e],m=this.searchAllInPage(i,s,u,o);t[s.index]=m,a.progress({pageIndex:s.index,result:m,completed:e+1,total:r})}this.logger.perf(ee,te,"SearchBatch","End",e.id),a.resolve(t)}finally{this.memoryManager.free(u)}}),a}buildContext(e,t,n,r=30){const o=/[\s\u00A0.,;:!?()\[\]{}<>/\\\-"'`"”\u2013\u2014]/;let a=t;for(;a>0&&o.test(e[a-1]);)a--;let i=0;for(;a>0&&i<r;)a--,o.test(e[a])||i++;a=(t=>{for(;t>0&&!o.test(e[t-1]);)t--;return t})(a);let s=t+n;for(;s<e.length&&o.test(e[s]);)s++;for(i=0;s<e.length&&i<r;)o.test(e[s])||i++,s++;s=(t=>{for(;t<e.length&&!o.test(e[t]);)t++;return t})(s);const u=e.slice(a,t).replace(/\s+/g," ").trimStart(),m=e.slice(t,t+n),F=e.slice(t+n,s).replace(/\s+/g," ").trimEnd();return{before:this.tidy(u),match:this.tidy(m),after:this.tidy(F),truncatedLeft:a>0,truncatedRight:s<e.length}}tidy(e){return e.replace(/-\uFFFE\s*/g,"").replace(/[\uFFFE\u00AD\u200B\u2060\uFEFF]/g,"").replace(/\s+/g," ")}searchAllInPage(e,t,n,r){return e.borrowPage(t.index,e=>{const o=e.getTextPage(),a=this.pdfiumModule.FPDFText_CountChars(o),i=this.memoryManager.malloc(2*(a+1));this.pdfiumModule.FPDFText_GetText(o,0,a,i);const s=this.pdfiumModule.pdfium.UTF16ToString(i);this.memoryManager.free(i);const u=[],m=this.pdfiumModule.FPDFText_FindStart(o,n,r,0);for(;this.pdfiumModule.FPDFText_FindNext(m);){const e=this.pdfiumModule.FPDFText_GetSchResultIndex(m),n=this.pdfiumModule.FPDFText_GetSchCount(m),r=this.getHighlightRects(t,o,e,n),a=this.buildContext(s,e,n);u.push({pageIndex:t.index,charIndex:e,charCount:n,rects:r,context:a})}return this.pdfiumModule.FPDFText_FindClose(m),u})}preparePrintDocument(n,r){const{includeAnnotations:o=!0,pageRange:a=null}=r??{};this.logger.debug(ee,te,"preparePrintDocument",n,r),this.logger.perf(ee,te,"PreparePrintDocument","Begin",n.id);const i=this.cache.getContext(n.id);if(!i)return this.logger.perf(ee,te,"PreparePrintDocument","End",n.id),e.reject({code:t.DocNotOpen,message:"Document is not open"});const s=this.pdfiumModule.FPDF_CreateNewDocument();if(!s)return this.logger.perf(ee,te,"PreparePrintDocument","End",n.id),e.reject({code:t.CantCreateNewDoc,message:"Cannot create print document"});try{const r=this.sanitizePageRange(a,n.pageCount);if(!this.pdfiumModule.FPDF_ImportPages(s,i.docPtr,r??"",0))return this.pdfiumModule.FPDF_CloseDocument(s),this.logger.error(ee,te,"Failed to import pages for printing"),this.logger.perf(ee,te,"PreparePrintDocument","End",n.id),e.reject({code:t.CantImportPages,message:"Failed to import pages for printing"});if(!o){const r=this.removeAnnotationsFromPrintDocument(s);if(!r.success)return this.pdfiumModule.FPDF_CloseDocument(s),this.logger.error(ee,te,`Failed to remove annotations: ${r.error}`),this.logger.perf(ee,te,"PreparePrintDocument","End",n.id),e.reject({code:t.Unknown,message:`Failed to prepare print document: ${r.error}`});this.logger.debug(ee,te,`Removed ${r.annotationsRemoved} annotations from ${r.pagesProcessed} pages`)}const u=this.saveDocument(s);return this.pdfiumModule.FPDF_CloseDocument(s),this.logger.perf(ee,te,"PreparePrintDocument","End",n.id),e.resolve(u)}catch(r){return s&&this.pdfiumModule.FPDF_CloseDocument(s),this.logger.error(ee,te,"preparePrintDocument failed",r),this.logger.perf(ee,te,"PreparePrintDocument","End",n.id),e.reject({code:t.Unknown,message:r instanceof Error?r.message:"Failed to prepare print document"})}}removeAnnotationsFromPrintDocument(e){let t=0,n=0;try{const r=this.pdfiumModule.FPDF_GetPageCount(e);for(let o=0;o<r;o++){const r=this.pdfiumModule.EPDFPage_GetAnnotCountRaw(e,o);if(r<=0){n++;continue}let a=0;for(let n=r-1;n>=0;n--){this.pdfiumModule.EPDFPage_RemoveAnnotRaw(e,o,n)?(a++,t++):this.logger.warn(ee,te,`Failed to remove annotation ${n} from page ${o}`)}if(a>0){const t=this.pdfiumModule.FPDF_LoadPage(e,o);t&&(this.pdfiumModule.FPDFPage_GenerateContent(t),this.pdfiumModule.FPDF_ClosePage(t))}n++}return{success:!0,annotationsRemoved:t,pagesProcessed:n}}catch(e){return{success:!1,annotationsRemoved:t,pagesProcessed:n,error:e instanceof Error?e.message:"Unknown error during annotation removal"}}}sanitizePageRange(e,t){if(!e||""===e.trim())return null;try{const n=[],r=e.split(",");for(const e of r){const r=e.trim();if(r.includes("-")){const[e,o]=r.split("-").map(e=>e.trim()),a=parseInt(e,10),i=parseInt(o,10);if(isNaN(a)||isNaN(i)){this.logger.warn(ee,te,`Invalid range: ${r}`);continue}const s=Math.max(1,Math.min(a,t)),u=Math.max(1,Math.min(i,t));for(let e=s;e<=u;e++)n.includes(e)||n.push(e)}else{const e=parseInt(r,10);if(isNaN(e)){this.logger.warn(ee,te,`Invalid page number: ${r}`);continue}const o=Math.max(1,Math.min(e,t));n.includes(o)||n.push(o)}}if(0===n.length)return this.logger.warn(ee,te,"No valid pages in range, using all pages"),null;n.sort((e,t)=>e-t);const o=[];let a=n[0],i=n[0];for(let e=1;e<n.length;e++)n[e]===i+1||(a===i?o.push(a.toString()):i-a===1?(o.push(a.toString()),o.push(i.toString())):o.push(`${a}-${i}`),a=n[e]),i=n[e];a===i?o.push(a.toString()):i-a===1?(o.push(a.toString()),o.push(i.toString())):o.push(`${a}-${i}`);const s=o.join(",");return this.logger.debug(ee,te,`Sanitized page range: "${e}" -> "${s}"`),s}catch(e){return this.logger.error(ee,te,`Error sanitizing page range: ${e}`),null}}}async function re(e,t){const n=await fetch(e),r=await n.arrayBuffer(),o=await N({wasmBinary:r}),a=new ne(o,{logger:null==t?void 0:t.logger});return a.initialize(),new R(a,{imageConverter:I,logger:null==t?void 0:t.logger})}export{re as createPdfiumEngine};