{"version":3,"sources":["jsdelivr-header.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/shared/util.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/xfa_text.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/xfa_layer.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/display_utils.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/toolbar.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/tools.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/alt_text.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/comment.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/touch_manager.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/editor.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/shared/murmurhash3.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/annotation_storage.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/font_loader.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/shared/obj-bin-transform.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/api_utils.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/shared/message_handler.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/canvas_factory.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/cmap_reader_factory.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/filter_factory.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/standard_fontdata_factory.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/wasm_factory.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/node_utils.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/canvas_dependency_tracker.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/pattern_helper.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/shared/image_utils.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/canvas.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/worker_options.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/metadata.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/optional_content_config.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/shared/base_pdf_stream.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/transport_stream.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/network_utils.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/content_disposition.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/fetch_stream.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/network.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/node_stream.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/pdf_objects.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/text_layer.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/api.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/color_picker.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/shared/scripting_utils.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/svg_factory.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/annotation_layer.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/freetext.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/drawers/outline.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/drawers/freedraw.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/drawers/highlight.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/highlight.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/draw.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/drawers/inkdraw.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/ink.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/drawers/contour.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/drawers/signaturedraw.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/signature.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/stamp.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/editor/annotation_editor_layer.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/display/draw_layer.js","/npm/pdfjs-dist@5.5.207/build/webpack:/pdf.js/src/pdf.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,++tBCcA,MAAM,KAEe,iBAAZ,GACP,EAAU,IAAO,oBAChB,EAAQ,SAAS,IAChB,EAAQ,SAAS,UAAY,EAAQ,MAAyB,YAAjB,EAAQ,MAEnD,GAAuB,CAAC,KAAO,EAAG,EAAG,KAAO,EAAG,GAI/C,GAAc,KAkBd,GACC,EADD,GAEK,EAFL,GAGG,EAHH,GAKe,GALf,GAMiB,GANjB,GAOiB,GAPjB,GAQQ,IARR,GASI,IAGJ,GAAiB,CACrB,QAAS,EACT,OAAQ,EACR,aAAc,EACd,eAAgB,GAGZ,GAAyB,yBAEzB,GAAuB,CAC3B,SAAU,EACV,KAAM,EACN,SAAU,EACV,UAAW,EACX,MAAO,GACP,IAAK,GACL,MAAO,GACP,UAAW,IACX,QAAS,KAGL,G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B,OAAM,GACN,QAAO,GACP,mBAAkB,GAClB,oBAAmB,GACnB,UAAS,GACT,oBAAmB,GACnB,aAAY,GACZ,UAAS,GACT,oBAAmB,GACnB,QAAO,GACP,QAAO,GACP,QAAO,GACP,UAAS,GACT,cAAa,GACb,iBAAgB,GAChB,IAAG,GACH,YAAW,GACX,kBAAiB,GACjB,sBAAqB,GACrB,cAAa,GACb,UAAS,GACT,eAAc,GACd,cAAa,GACb,4BAA2B,GAC3B,eAAc,GACd,kBAAiB,GACjB,mBAAkB,GAClB,OAAM,GACN,mBAAkB,GAClB,UAAS,GACT,wBAAuB,GACvB,UAAS,GACT,aAAY,GACZ,cAAa,GACb,KAAI,GACJ,eAAc,GACd,QAAO,GACP,SAAQ,W","file":"/npm/pdfjs-dist@5.5.207/build/pdf.mjs/+esm","sourceRoot":"","sourcesContent":["/**\n * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.\n * Original file: /npm/pdfjs-dist@5.5.207/build/pdf.mjs\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/* globals process */\n\n// NW.js / Electron is a browser context, but copies some Node.js objects; see\n// http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context\n// https://www.electronjs.org/docs/api/process#processversionselectron-readonly\n// https://www.electronjs.org/docs/api/process#processtype-readonly\nconst isNodeJS =\n  (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"GENERIC\")) &&\n  typeof process === \"object\" &&\n  process + \"\" === \"[object process]\" &&\n  !process.versions.nw &&\n  !(process.versions.electron && process.type && process.type !== \"browser\");\n\nconst FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];\n\n// Represent the percentage of the height of a single-line field over\n// the font size. Acrobat seems to use this value.\nconst LINE_FACTOR = 1.35;\nconst LINE_DESCENT_FACTOR = 0.35;\nconst BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;\n\n/**\n * Refer to the `WorkerTransport.getRenderingIntent`-method in the API, to see\n * how these flags are being used:\n *  - ANY, DISPLAY, and PRINT are the normal rendering intents, note the\n *    `PDFPageProxy.{render, getOperatorList, getAnnotations}`-methods.\n *  - SAVE is used, on the worker-thread, when saving modified annotations.\n *  - ANNOTATIONS_FORMS, ANNOTATIONS_STORAGE, ANNOTATIONS_DISABLE control which\n *    annotations are rendered onto the canvas (i.e. by being included in the\n *    operatorList), note the `PDFPageProxy.{render, getOperatorList}`-methods\n *    and their `annotationMode`-option.\n *  - IS_EDITING is used when editing is active in the viewer.\n *  - OPLIST is used with the `PDFPageProxy.getOperatorList`-method, note the\n *    `OperatorList`-constructor (on the worker-thread).\n */\nconst RenderingIntentFlag = {\n  ANY: 0x01,\n  DISPLAY: 0x02,\n  PRINT: 0x04,\n  SAVE: 0x08,\n  ANNOTATIONS_FORMS: 0x10,\n  ANNOTATIONS_STORAGE: 0x20,\n  ANNOTATIONS_DISABLE: 0x40,\n  IS_EDITING: 0x80,\n  OPLIST: 0x100,\n};\n\nconst AnnotationMode = {\n  DISABLE: 0,\n  ENABLE: 1,\n  ENABLE_FORMS: 2,\n  ENABLE_STORAGE: 3,\n};\n\nconst AnnotationEditorPrefix = \"pdfjs_internal_editor_\";\n\nconst AnnotationEditorType = {\n  DISABLE: -1,\n  NONE: 0,\n  FREETEXT: 3,\n  HIGHLIGHT: 9,\n  STAMP: 13,\n  INK: 15,\n  POPUP: 16,\n  SIGNATURE: 101,\n  COMMENT: 102,\n};\n\nconst AnnotationEditorParamsType = {\n  RESIZE: 1,\n  CREATE: 2,\n  FREETEXT_SIZE: 11,\n  FREETEXT_COLOR: 12,\n  FREETEXT_OPACITY: 13,\n  INK_COLOR: 21,\n  INK_THICKNESS: 22,\n  INK_OPACITY: 23,\n  HIGHLIGHT_COLOR: 31,\n  HIGHLIGHT_THICKNESS: 32,\n  HIGHLIGHT_FREE: 33,\n  HIGHLIGHT_SHOW_ALL: 34,\n  DRAW_STEP: 41,\n};\n\n// Permission flags from Table 22, Section 7.6.3.2 of the PDF specification.\nconst PermissionFlag = {\n  PRINT: 0x04,\n  MODIFY_CONTENTS: 0x08,\n  COPY: 0x10,\n  MODIFY_ANNOTATIONS: 0x20,\n  FILL_INTERACTIVE_FORMS: 0x100,\n  COPY_FOR_ACCESSIBILITY: 0x200,\n  ASSEMBLE: 0x400,\n  PRINT_HIGH_QUALITY: 0x800,\n};\n\nconst MeshFigureType = {\n  TRIANGLES: 1,\n  LATTICE: 2,\n  PATCH: 3,\n};\n\nconst TextRenderingMode = {\n  FILL: 0,\n  STROKE: 1,\n  FILL_STROKE: 2,\n  INVISIBLE: 3,\n  FILL_ADD_TO_PATH: 4,\n  STROKE_ADD_TO_PATH: 5,\n  FILL_STROKE_ADD_TO_PATH: 6,\n  ADD_TO_PATH: 7,\n  FILL_STROKE_MASK: 3,\n  ADD_TO_PATH_FLAG: 4,\n};\n\nconst ImageKind = {\n  GRAYSCALE_1BPP: 1,\n  RGB_24BPP: 2,\n  RGBA_32BPP: 3,\n};\n\nconst AnnotationType = {\n  TEXT: 1,\n  LINK: 2,\n  FREETEXT: 3,\n  LINE: 4,\n  SQUARE: 5,\n  CIRCLE: 6,\n  POLYGON: 7,\n  POLYLINE: 8,\n  HIGHLIGHT: 9,\n  UNDERLINE: 10,\n  SQUIGGLY: 11,\n  STRIKEOUT: 12,\n  STAMP: 13,\n  CARET: 14,\n  INK: 15,\n  POPUP: 16,\n  FILEATTACHMENT: 17,\n  SOUND: 18,\n  MOVIE: 19,\n  WIDGET: 20,\n  SCREEN: 21,\n  PRINTERMARK: 22,\n  TRAPNET: 23,\n  WATERMARK: 24,\n  THREED: 25,\n  REDACT: 26,\n};\n\nconst AnnotationReplyType = {\n  GROUP: \"Group\",\n  REPLY: \"R\",\n};\n\nconst AnnotationFlag = {\n  INVISIBLE: 0x01,\n  HIDDEN: 0x02,\n  PRINT: 0x04,\n  NOZOOM: 0x08,\n  NOROTATE: 0x10,\n  NOVIEW: 0x20,\n  READONLY: 0x40,\n  LOCKED: 0x80,\n  TOGGLENOVIEW: 0x100,\n  LOCKEDCONTENTS: 0x200,\n};\n\nconst AnnotationFieldFlag = {\n  READONLY: 0x0000001,\n  REQUIRED: 0x0000002,\n  NOEXPORT: 0x0000004,\n  MULTILINE: 0x0001000,\n  PASSWORD: 0x0002000,\n  NOTOGGLETOOFF: 0x0004000,\n  RADIO: 0x0008000,\n  PUSHBUTTON: 0x0010000,\n  COMBO: 0x0020000,\n  EDIT: 0x0040000,\n  SORT: 0x0080000,\n  FILESELECT: 0x0100000,\n  MULTISELECT: 0x0200000,\n  DONOTSPELLCHECK: 0x0400000,\n  DONOTSCROLL: 0x0800000,\n  COMB: 0x1000000,\n  RICHTEXT: 0x2000000,\n  RADIOSINUNISON: 0x2000000,\n  COMMITONSELCHANGE: 0x4000000,\n};\n\nconst AnnotationBorderStyleType = {\n  SOLID: 1,\n  DASHED: 2,\n  BEVELED: 3,\n  INSET: 4,\n  UNDERLINE: 5,\n};\n\nconst AnnotationActionEventType = {\n  E: \"Mouse Enter\",\n  X: \"Mouse Exit\",\n  D: \"Mouse Down\",\n  U: \"Mouse Up\",\n  Fo: \"Focus\",\n  Bl: \"Blur\",\n  PO: \"PageOpen\",\n  PC: \"PageClose\",\n  PV: \"PageVisible\",\n  PI: \"PageInvisible\",\n  K: \"Keystroke\",\n  F: \"Format\",\n  V: \"Validate\",\n  C: \"Calculate\",\n};\n\nconst DocumentActionEventType = {\n  WC: \"WillClose\",\n  WS: \"WillSave\",\n  DS: \"DidSave\",\n  WP: \"WillPrint\",\n  DP: \"DidPrint\",\n};\n\nconst PageActionEventType = {\n  O: \"PageOpen\",\n  C: \"PageClose\",\n};\n\nconst VerbosityLevel = {\n  ERRORS: 0,\n  WARNINGS: 1,\n  INFOS: 5,\n};\n\n// All the possible operations for an operator list.\nconst OPS = {\n  // Intentionally start from 1 so it is easy to spot bad operators that will be\n  // 0's.\n  // PLEASE NOTE: We purposely keep any removed operators commented out, since\n  //              re-numbering the list would risk breaking third-party users.\n  dependency: 1,\n  setLineWidth: 2,\n  setLineCap: 3,\n  setLineJoin: 4,\n  setMiterLimit: 5,\n  setDash: 6,\n  setRenderingIntent: 7,\n  setFlatness: 8,\n  setGState: 9,\n  save: 10,\n  restore: 11,\n  transform: 12,\n  moveTo: 13,\n  lineTo: 14,\n  curveTo: 15,\n  curveTo2: 16,\n  curveTo3: 17,\n  closePath: 18,\n  rectangle: 19,\n  stroke: 20,\n  closeStroke: 21,\n  fill: 22,\n  eoFill: 23,\n  fillStroke: 24,\n  eoFillStroke: 25,\n  closeFillStroke: 26,\n  closeEOFillStroke: 27,\n  endPath: 28,\n  clip: 29,\n  eoClip: 30,\n  beginText: 31,\n  endText: 32,\n  setCharSpacing: 33,\n  setWordSpacing: 34,\n  setHScale: 35,\n  setLeading: 36,\n  setFont: 37,\n  setTextRenderingMode: 38,\n  setTextRise: 39,\n  moveText: 40,\n  setLeadingMoveText: 41,\n  setTextMatrix: 42,\n  nextLine: 43,\n  showText: 44,\n  showSpacedText: 45,\n  nextLineShowText: 46,\n  nextLineSetSpacingShowText: 47,\n  setCharWidth: 48,\n  setCharWidthAndBounds: 49,\n  setStrokeColorSpace: 50,\n  setFillColorSpace: 51,\n  setStrokeColor: 52,\n  setStrokeColorN: 53,\n  setFillColor: 54,\n  setFillColorN: 55,\n  setStrokeGray: 56,\n  setFillGray: 57,\n  setStrokeRGBColor: 58,\n  setFillRGBColor: 59,\n  setStrokeCMYKColor: 60,\n  setFillCMYKColor: 61,\n  shadingFill: 62,\n  beginInlineImage: 63,\n  beginImageData: 64,\n  endInlineImage: 65,\n  paintXObject: 66,\n  markPoint: 67,\n  markPointProps: 68,\n  beginMarkedContent: 69,\n  beginMarkedContentProps: 70,\n  endMarkedContent: 71,\n  beginCompat: 72,\n  endCompat: 73,\n  paintFormXObjectBegin: 74,\n  paintFormXObjectEnd: 75,\n  beginGroup: 76,\n  endGroup: 77,\n  // beginAnnotations: 78,\n  // endAnnotations: 79,\n  beginAnnotation: 80,\n  endAnnotation: 81,\n  // paintJpegXObject: 82,\n  paintImageMaskXObject: 83,\n  paintImageMaskXObjectGroup: 84,\n  paintImageXObject: 85,\n  paintInlineImageXObject: 86,\n  paintInlineImageXObjectGroup: 87,\n  paintImageXObjectRepeat: 88,\n  paintImageMaskXObjectRepeat: 89,\n  paintSolidColorImageMask: 90,\n  constructPath: 91,\n  setStrokeTransparent: 92,\n  setFillTransparent: 93,\n  rawFillPath: 94,\n};\n\n// In order to have a switch statement that is fast (i.e. which use a jump\n// table), we need to have the OPS in a contiguous range.\nconst DrawOPS = {\n  moveTo: 0,\n  lineTo: 1,\n  curveTo: 2,\n  quadraticCurveTo: 3,\n  closePath: 4,\n};\n\nconst PasswordResponses = {\n  NEED_PASSWORD: 1,\n  INCORRECT_PASSWORD: 2,\n};\n\nlet verbosity = VerbosityLevel.WARNINGS;\n\nfunction setVerbosityLevel(level) {\n  if (Number.isInteger(level)) {\n    verbosity = level;\n  }\n}\n\nfunction getVerbosityLevel() {\n  return verbosity;\n}\n\n// A notice for devs. These are good for things that are helpful to devs, such\n// as warning that Workers were disabled, which is important to devs but not\n// end users.\nfunction info(msg) {\n  if (verbosity >= VerbosityLevel.INFOS) {\n    // eslint-disable-next-line no-console\n    console.info(`Info: ${msg}`);\n  }\n}\n\n// Non-fatal warnings.\nfunction warn(msg) {\n  if (verbosity >= VerbosityLevel.WARNINGS) {\n    // eslint-disable-next-line no-console\n    console.warn(`Warning: ${msg}`);\n  }\n}\n\nfunction unreachable(msg) {\n  throw new Error(msg);\n}\n\nfunction assert(cond, msg) {\n  if (!cond) {\n    unreachable(msg);\n  }\n}\n\n// Checks if URLs use one of the allowed protocols, e.g. to avoid XSS.\nfunction _isValidProtocol(url) {\n  switch (url?.protocol) {\n    case \"http:\":\n    case \"https:\":\n    case \"ftp:\":\n    case \"mailto:\":\n    case \"tel:\":\n      return true;\n    default:\n      return false;\n  }\n}\n\n/**\n * Attempts to create a valid absolute URL.\n *\n * @param {URL|string} url - An absolute, or relative, URL.\n * @param {URL|string} [baseUrl] - An absolute URL.\n * @param {Object} [options]\n * @returns Either a valid {URL}, or `null` otherwise.\n */\nfunction createValidAbsoluteUrl(url, baseUrl = null, options = null) {\n  if (!url) {\n    return null;\n  }\n  if (options && typeof url === \"string\") {\n    // Let URLs beginning with \"www.\" default to using the \"http://\" protocol.\n    if (options.addDefaultProtocol && url.startsWith(\"www.\")) {\n      const dots = url.match(/\\./g);\n      // Avoid accidentally matching a *relative* URL pointing to a file named\n      // e.g. \"www.pdf\" or similar.\n      if (dots?.length >= 2) {\n        url = `http://${url}`;\n      }\n    }\n\n    // According to ISO 32000-1:2008, section 12.6.4.7, URIs should be encoded\n    // in 7-bit ASCII. Some bad PDFs use UTF-8 encoding; see bug 1122280.\n    if (options.tryConvertEncoding) {\n      try {\n        url = stringToUTF8String(url);\n      } catch {}\n    }\n  }\n\n  const absoluteUrl = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);\n  return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;\n}\n\n/**\n * Remove, or replace, the hash property of the URL.\n *\n * @param {URL|string} url - The absolute, or relative, URL.\n * @param {string} hash - The hash property (use an empty string to remove it).\n * @param {boolean} [allowRel] - Allow relative URLs.\n * @returns {string} The resulting URL string.\n */\nfunction updateUrlHash(url, hash, allowRel = false) {\n  const res = URL.parse(url);\n  if (res) {\n    res.hash = hash;\n    return res.href;\n  }\n  // Support well-formed relative URLs, necessary for `web/app.js` in GENERIC\n  // builds, by optionally falling back to string parsing.\n  if (allowRel && createValidAbsoluteUrl(url, \"http://example.com\")) {\n    return url.split(\"#\", 1)[0] + `${hash ? `#${hash}` : \"\"}`;\n  }\n  return \"\";\n}\n\n// Extract the final component from a path string.\nfunction stripPath(str) {\n  return str.substring(str.lastIndexOf(\"/\") + 1);\n}\n\nfunction shadow(obj, prop, value, nonSerializable = false) {\n  if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n    assert(\n      prop in obj,\n      `shadow: Property \"${prop && prop.toString()}\" not found in object.`\n    );\n  }\n  Object.defineProperty(obj, prop, {\n    value,\n    enumerable: !nonSerializable,\n    configurable: true,\n    writable: false,\n  });\n  return value;\n}\n\n/**\n * @type {any}\n */\nconst BaseException = (function BaseExceptionClosure() {\n  // eslint-disable-next-line no-shadow\n  function BaseException(message, name) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseException\n    ) {\n      unreachable(\"Cannot initialize BaseException.\");\n    }\n    this.message = message;\n    this.name = name;\n  }\n  BaseException.prototype = new Error();\n  BaseException.constructor = BaseException;\n\n  return BaseException;\n})();\n\nclass PasswordException extends BaseException {\n  constructor(msg, code) {\n    super(msg, \"PasswordException\");\n    this.code = code;\n  }\n}\n\nclass UnknownErrorException extends BaseException {\n  constructor(msg, details) {\n    super(msg, \"UnknownErrorException\");\n    this.details = details;\n  }\n}\n\nclass InvalidPDFException extends BaseException {\n  constructor(msg) {\n    super(msg, \"InvalidPDFException\");\n  }\n}\n\nclass ResponseException extends BaseException {\n  constructor(msg, status, missing) {\n    super(msg, \"ResponseException\");\n    this.status = status;\n    this.missing = missing;\n  }\n}\n\n/**\n * Error caused during parsing PDF data.\n */\nclass FormatError extends BaseException {\n  constructor(msg) {\n    super(msg, \"FormatError\");\n  }\n}\n\n/**\n * Error used to indicate task cancellation.\n */\nclass AbortException extends BaseException {\n  constructor(msg) {\n    super(msg, \"AbortException\");\n  }\n}\n\nfunction bytesToString(bytes) {\n  if (typeof bytes !== \"object\" || bytes?.length === undefined) {\n    unreachable(\"Invalid argument for bytesToString\");\n  }\n  const length = bytes.length;\n  const MAX_ARGUMENT_COUNT = 8192;\n  if (length < MAX_ARGUMENT_COUNT) {\n    return String.fromCharCode.apply(null, bytes);\n  }\n  const strBuf = [];\n  for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {\n    const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);\n    const chunk = bytes.subarray(i, chunkEnd);\n    strBuf.push(String.fromCharCode.apply(null, chunk));\n  }\n  return strBuf.join(\"\");\n}\n\nfunction stringToBytes(str) {\n  if (typeof str !== \"string\") {\n    unreachable(\"Invalid argument for stringToBytes\");\n  }\n  const length = str.length;\n  const bytes = new Uint8Array(length);\n  for (let i = 0; i < length; ++i) {\n    bytes[i] = str.charCodeAt(i) & 0xff;\n  }\n  return bytes;\n}\n\nfunction string32(value) {\n  if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n    assert(\n      typeof value === \"number\" && Math.abs(value) < 2 ** 32,\n      `string32: Unexpected input \"${value}\".`\n    );\n  }\n  return String.fromCharCode(\n    (value >> 24) & 0xff,\n    (value >> 16) & 0xff,\n    (value >> 8) & 0xff,\n    value & 0xff\n  );\n}\n\nfunction objectSize(obj) {\n  return Object.keys(obj).length;\n}\n\n// Checks the endianness of the platform.\nfunction isLittleEndian() {\n  const buffer8 = new Uint8Array(4);\n  buffer8[0] = 1;\n  const view32 = new Uint32Array(buffer8.buffer, 0, 1);\n  return view32[0] === 1;\n}\n\n// Checks if it's possible to eval JS expressions.\nfunction isEvalSupported() {\n  try {\n    new Function(\"\"); // eslint-disable-line no-new, no-new-func\n    return true;\n  } catch {\n    return false;\n  }\n}\n\nclass FeatureTest {\n  static get isLittleEndian() {\n    return shadow(this, \"isLittleEndian\", isLittleEndian());\n  }\n\n  static get isEvalSupported() {\n    return shadow(this, \"isEvalSupported\", isEvalSupported());\n  }\n\n  static get isOffscreenCanvasSupported() {\n    return shadow(\n      this,\n      \"isOffscreenCanvasSupported\",\n      typeof OffscreenCanvas !== \"undefined\"\n    );\n  }\n\n  static get isImageDecoderSupported() {\n    return shadow(\n      this,\n      \"isImageDecoderSupported\",\n      typeof ImageDecoder !== \"undefined\"\n    );\n  }\n\n  static get isFloat16ArraySupported() {\n    return shadow(\n      this,\n      \"isFloat16ArraySupported\",\n      typeof Float16Array !== \"undefined\"\n    );\n  }\n\n  static get isSanitizerSupported() {\n    return shadow(\n      this,\n      \"isSanitizerSupported\",\n      // eslint-disable-next-line no-undef\n      typeof Sanitizer !== \"undefined\"\n    );\n  }\n\n  static get platform() {\n    const { platform, userAgent } = navigator;\n\n    return shadow(this, \"platform\", {\n      isAndroid: userAgent.includes(\"Android\"),\n      isLinux: platform.includes(\"Linux\"),\n      isMac: platform.includes(\"Mac\"),\n      isWindows: platform.includes(\"Win\"),\n      isFirefox:\n        (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n        userAgent.includes(\"Firefox\"),\n    });\n  }\n\n  static get isCSSRoundSupported() {\n    return shadow(\n      this,\n      \"isCSSRoundSupported\",\n      globalThis.CSS?.supports?.(\"width: round(1.5px, 1px)\")\n    );\n  }\n}\n\nconst hexNumbers = Array.from(Array(256).keys(), n =>\n  n.toString(16).padStart(2, \"0\")\n);\n\nclass Util {\n  static makeHexColor(r, g, b) {\n    return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;\n  }\n\n  static domMatrixToTransform(dm) {\n    return [dm.a, dm.b, dm.c, dm.d, dm.e, dm.f];\n  }\n\n  // Apply a scaling matrix to some min/max values.\n  // If a scaling factor is negative then min and max must be\n  // swapped.\n  static scaleMinMax(transform, minMax) {\n    let temp;\n    if (transform[0]) {\n      if (transform[0] < 0) {\n        temp = minMax[0];\n        minMax[0] = minMax[2];\n        minMax[2] = temp;\n      }\n      minMax[0] *= transform[0];\n      minMax[2] *= transform[0];\n\n      if (transform[3] < 0) {\n        temp = minMax[1];\n        minMax[1] = minMax[3];\n        minMax[3] = temp;\n      }\n      minMax[1] *= transform[3];\n      minMax[3] *= transform[3];\n    } else {\n      temp = minMax[0];\n      minMax[0] = minMax[1];\n      minMax[1] = temp;\n      temp = minMax[2];\n      minMax[2] = minMax[3];\n      minMax[3] = temp;\n\n      if (transform[1] < 0) {\n        temp = minMax[1];\n        minMax[1] = minMax[3];\n        minMax[3] = temp;\n      }\n      minMax[1] *= transform[1];\n      minMax[3] *= transform[1];\n\n      if (transform[2] < 0) {\n        temp = minMax[0];\n        minMax[0] = minMax[2];\n        minMax[2] = temp;\n      }\n      minMax[0] *= transform[2];\n      minMax[2] *= transform[2];\n    }\n    minMax[0] += transform[4];\n    minMax[1] += transform[5];\n    minMax[2] += transform[4];\n    minMax[3] += transform[5];\n  }\n\n  // Concatenates two transformation matrices together and returns the result.\n  static transform(m1, m2) {\n    return [\n      m1[0] * m2[0] + m1[2] * m2[1],\n      m1[1] * m2[0] + m1[3] * m2[1],\n      m1[0] * m2[2] + m1[2] * m2[3],\n      m1[1] * m2[2] + m1[3] * m2[3],\n      m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n      m1[1] * m2[4] + m1[3] * m2[5] + m1[5],\n    ];\n  }\n\n  // Multiplies m (an array-based transform) by md (a DOMMatrix transform).\n  static multiplyByDOMMatrix(m, md) {\n    return [\n      m[0] * md.a + m[2] * md.b,\n      m[1] * md.a + m[3] * md.b,\n      m[0] * md.c + m[2] * md.d,\n      m[1] * md.c + m[3] * md.d,\n      m[0] * md.e + m[2] * md.f + m[4],\n      m[1] * md.e + m[3] * md.f + m[5],\n    ];\n  }\n\n  // For 2d affine transforms\n  static applyTransform(p, m, pos = 0) {\n    const p0 = p[pos];\n    const p1 = p[pos + 1];\n    p[pos] = p0 * m[0] + p1 * m[2] + m[4];\n    p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];\n  }\n\n  static applyTransformToBezier(p, transform, pos = 0) {\n    const m0 = transform[0];\n    const m1 = transform[1];\n    const m2 = transform[2];\n    const m3 = transform[3];\n    const m4 = transform[4];\n    const m5 = transform[5];\n    for (let i = 0; i < 6; i += 2) {\n      const pI = p[pos + i];\n      const pI1 = p[pos + i + 1];\n      p[pos + i] = pI * m0 + pI1 * m2 + m4;\n      p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;\n    }\n  }\n\n  static applyInverseTransform(p, m) {\n    const p0 = p[0];\n    const p1 = p[1];\n    const d = m[0] * m[3] - m[1] * m[2];\n    p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;\n    p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;\n  }\n\n  // Applies the transform to the rectangle and finds the minimum axially\n  // aligned bounding box.\n  static axialAlignedBoundingBox(rect, transform, output) {\n    const m0 = transform[0];\n    const m1 = transform[1];\n    const m2 = transform[2];\n    const m3 = transform[3];\n    const m4 = transform[4];\n    const m5 = transform[5];\n    const r0 = rect[0];\n    const r1 = rect[1];\n    const r2 = rect[2];\n    const r3 = rect[3];\n\n    let a0 = m0 * r0 + m4;\n    let a2 = a0;\n    let a1 = m0 * r2 + m4;\n    let a3 = a1;\n    let b0 = m3 * r1 + m5;\n    let b2 = b0;\n    let b1 = m3 * r3 + m5;\n    let b3 = b1;\n\n    if (m1 !== 0 || m2 !== 0) {\n      // Non-scaling matrix: shouldn't be frequent.\n      const m1r0 = m1 * r0;\n      const m1r2 = m1 * r2;\n      const m2r1 = m2 * r1;\n      const m2r3 = m2 * r3;\n      a0 += m2r1;\n      a3 += m2r1;\n      a1 += m2r3;\n      a2 += m2r3;\n      b0 += m1r0;\n      b3 += m1r0;\n      b1 += m1r2;\n      b2 += m1r2;\n    }\n\n    output[0] = Math.min(output[0], a0, a1, a2, a3);\n    output[1] = Math.min(output[1], b0, b1, b2, b3);\n    output[2] = Math.max(output[2], a0, a1, a2, a3);\n    output[3] = Math.max(output[3], b0, b1, b2, b3);\n  }\n\n  static inverseTransform(m) {\n    const d = m[0] * m[3] - m[1] * m[2];\n    return [\n      m[3] / d,\n      -m[1] / d,\n      -m[2] / d,\n      m[0] / d,\n      (m[2] * m[5] - m[4] * m[3]) / d,\n      (m[4] * m[1] - m[5] * m[0]) / d,\n    ];\n  }\n\n  // This calculation uses Singular Value Decomposition.\n  // The SVD can be represented with formula A = USV. We are interested in the\n  // matrix S here because it represents the scale values.\n  static singularValueDecompose2dScale(matrix, output) {\n    const m0 = matrix[0];\n    const m1 = matrix[1];\n    const m2 = matrix[2];\n    const m3 = matrix[3];\n    // Multiply matrix m with its transpose.\n    const a = m0 ** 2 + m1 ** 2;\n    const b = m0 * m2 + m1 * m3;\n    const c = m2 ** 2 + m3 ** 2;\n\n    // Solve the second degree polynomial to get roots.\n    const first = (a + c) / 2;\n    const second = Math.sqrt(first ** 2 - (a * c - b ** 2));\n    output[0] = Math.sqrt(first + second || 1);\n    output[1] = Math.sqrt(first - second || 1);\n  }\n\n  // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)\n  // For coordinate systems whose origin lies in the bottom-left, this\n  // means normalization to (BL,TR) ordering. For systems with origin in the\n  // top-left, this means (TL,BR) ordering.\n  static normalizeRect(rect) {\n    const r = rect.slice(0); // clone rect\n    if (rect[0] > rect[2]) {\n      r[0] = rect[2];\n      r[2] = rect[0];\n    }\n    if (rect[1] > rect[3]) {\n      r[1] = rect[3];\n      r[3] = rect[1];\n    }\n    return r;\n  }\n\n  // Returns a rectangle [x1, y1, x2, y2] corresponding to the\n  // intersection of rect1 and rect2. If no intersection, returns 'null'\n  // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]\n  static intersect(rect1, rect2) {\n    const xLow = Math.max(\n      Math.min(rect1[0], rect1[2]),\n      Math.min(rect2[0], rect2[2])\n    );\n    const xHigh = Math.min(\n      Math.max(rect1[0], rect1[2]),\n      Math.max(rect2[0], rect2[2])\n    );\n    if (xLow > xHigh) {\n      return null;\n    }\n    const yLow = Math.max(\n      Math.min(rect1[1], rect1[3]),\n      Math.min(rect2[1], rect2[3])\n    );\n    const yHigh = Math.min(\n      Math.max(rect1[1], rect1[3]),\n      Math.max(rect2[1], rect2[3])\n    );\n    if (yLow > yHigh) {\n      return null;\n    }\n\n    return [xLow, yLow, xHigh, yHigh];\n  }\n\n  static pointBoundingBox(x, y, minMax) {\n    minMax[0] = Math.min(minMax[0], x);\n    minMax[1] = Math.min(minMax[1], y);\n    minMax[2] = Math.max(minMax[2], x);\n    minMax[3] = Math.max(minMax[3], y);\n  }\n\n  static rectBoundingBox(x0, y0, x1, y1, minMax) {\n    minMax[0] = Math.min(minMax[0], x0, x1);\n    minMax[1] = Math.min(minMax[1], y0, y1);\n    minMax[2] = Math.max(minMax[2], x0, x1);\n    minMax[3] = Math.max(minMax[3], y0, y1);\n  }\n\n  static #getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {\n    if (t <= 0 || t >= 1) {\n      return;\n    }\n    const mt = 1 - t;\n    const tt = t * t;\n    const ttt = tt * t;\n    const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;\n    const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;\n    minMax[0] = Math.min(minMax[0], x);\n    minMax[1] = Math.min(minMax[1], y);\n    minMax[2] = Math.max(minMax[2], x);\n    minMax[3] = Math.max(minMax[3], y);\n  }\n\n  static #getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {\n    if (Math.abs(a) < 1e-12) {\n      if (Math.abs(b) >= 1e-12) {\n        this.#getExtremumOnCurve(\n          x0,\n          x1,\n          x2,\n          x3,\n          y0,\n          y1,\n          y2,\n          y3,\n          -c / b,\n          minMax\n        );\n      }\n      return;\n    }\n\n    const delta = b ** 2 - 4 * c * a;\n    if (delta < 0) {\n      return;\n    }\n    const sqrtDelta = Math.sqrt(delta);\n    const a2 = 2 * a;\n    this.#getExtremumOnCurve(\n      x0,\n      x1,\n      x2,\n      x3,\n      y0,\n      y1,\n      y2,\n      y3,\n      (-b + sqrtDelta) / a2,\n      minMax\n    );\n    this.#getExtremumOnCurve(\n      x0,\n      x1,\n      x2,\n      x3,\n      y0,\n      y1,\n      y2,\n      y3,\n      (-b - sqrtDelta) / a2,\n      minMax\n    );\n  }\n\n  // From https://github.com/adobe-webplatform/Snap.svg/blob/b365287722a72526000ac4bfcf0ce4cac2faa015/src/path.js#L852\n  static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {\n    minMax[0] = Math.min(minMax[0], x0, x3);\n    minMax[1] = Math.min(minMax[1], y0, y3);\n    minMax[2] = Math.max(minMax[2], x0, x3);\n    minMax[3] = Math.max(minMax[3], y0, y3);\n\n    this.#getExtremum(\n      x0,\n      x1,\n      x2,\n      x3,\n      y0,\n      y1,\n      y2,\n      y3,\n      3 * (-x0 + 3 * (x1 - x2) + x3),\n      6 * (x0 - 2 * x1 + x2),\n      3 * (x1 - x0),\n      minMax\n    );\n    this.#getExtremum(\n      x0,\n      x1,\n      x2,\n      x3,\n      y0,\n      y1,\n      y2,\n      y3,\n      3 * (-y0 + 3 * (y1 - y2) + y3),\n      6 * (y0 - 2 * y1 + y2),\n      3 * (y1 - y0),\n      minMax\n    );\n  }\n}\n\nconst PDFStringTranslateTable = [\n  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8,\n  0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n  0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192,\n  0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018,\n  0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d,\n  0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac,\n];\n\nfunction stringToPDFString(str, keepEscapeSequence = false) {\n  // See section 7.9.2.2 Text String Type.\n  // The string can contain some language codes bracketed with 0x1b,\n  // so we must remove them.\n  if (str[0] >= \"\\xEF\") {\n    let encoding;\n    if (str[0] === \"\\xFE\" && str[1] === \"\\xFF\") {\n      encoding = \"utf-16be\";\n      if (str.length % 2 === 1) {\n        str = str.slice(0, -1);\n      }\n    } else if (str[0] === \"\\xFF\" && str[1] === \"\\xFE\") {\n      encoding = \"utf-16le\";\n      if (str.length % 2 === 1) {\n        str = str.slice(0, -1);\n      }\n    } else if (str[0] === \"\\xEF\" && str[1] === \"\\xBB\" && str[2] === \"\\xBF\") {\n      encoding = \"utf-8\";\n    }\n\n    if (encoding) {\n      try {\n        const decoder = new TextDecoder(encoding, { fatal: true });\n        const buffer = stringToBytes(str);\n        const decoded = decoder.decode(buffer);\n        if (keepEscapeSequence || !decoded.includes(\"\\x1b\")) {\n          return decoded;\n        }\n        return decoded.replaceAll(/\\x1b[^\\x1b]*(?:\\x1b|$)/g, \"\");\n      } catch (ex) {\n        warn(`stringToPDFString: \"${ex}\".`);\n      }\n    }\n  }\n  // ISO Latin 1\n  const strBuf = [];\n  for (let i = 0, ii = str.length; i < ii; i++) {\n    const charCode = str.charCodeAt(i);\n    if (!keepEscapeSequence && charCode === 0x1b) {\n      // eslint-disable-next-line no-empty\n      while (++i < ii && str.charCodeAt(i) !== 0x1b) {}\n      continue;\n    }\n    const code = PDFStringTranslateTable[charCode];\n    strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));\n  }\n  return strBuf.join(\"\");\n}\n\nfunction stringToUTF8String(str) {\n  return decodeURIComponent(escape(str));\n}\n\nfunction utf8StringToString(str) {\n  return unescape(encodeURIComponent(str));\n}\n\nfunction isArrayEqual(arr1, arr2) {\n  if (arr1.length !== arr2.length) {\n    return false;\n  }\n  for (let i = 0, ii = arr1.length; i < ii; i++) {\n    if (arr1[i] !== arr2[i]) {\n      return false;\n    }\n  }\n  return true;\n}\n\nfunction getModificationDate(date = new Date()) {\n  if (!(date instanceof Date)) {\n    date = new Date(date);\n  }\n  const buffer = [\n    date.getUTCFullYear().toString(),\n    (date.getUTCMonth() + 1).toString().padStart(2, \"0\"),\n    date.getUTCDate().toString().padStart(2, \"0\"),\n    date.getUTCHours().toString().padStart(2, \"0\"),\n    date.getUTCMinutes().toString().padStart(2, \"0\"),\n    date.getUTCSeconds().toString().padStart(2, \"0\"),\n  ];\n\n  return buffer.join(\"\");\n}\n\nlet NormalizeRegex = null;\nlet NormalizationMap = null;\nfunction normalizeUnicode(str) {\n  if (!NormalizeRegex) {\n    // In order to generate the following regex:\n    //  - create a PDF containing all the chars in the range 0000-FFFF with\n    //    a NFKC which is different of the char.\n    //  - copy and paste all those chars and get the ones where NFKC is\n    //    required.\n    // It appears that most the chars here contain some ligatures.\n    NormalizeRegex =\n      /([\\u00a0\\u00b5\\u037e\\u0eb3\\u2000-\\u200a\\u202f\\u2126\\ufb00-\\ufb04\\ufb06\\ufb20-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40-\\ufb41\\ufb43-\\ufb44\\ufb46-\\ufba1\\ufba4-\\ufba9\\ufbae-\\ufbb1\\ufbd3-\\ufbdc\\ufbde-\\ufbe7\\ufbea-\\ufbf8\\ufbfc-\\ufbfd\\ufc00-\\ufc5d\\ufc64-\\ufcf1\\ufcf5-\\ufd3d\\ufd88\\ufdf4\\ufdfa-\\ufdfb\\ufe71\\ufe77\\ufe79\\ufe7b\\ufe7d]+)|(\\ufb05+)/gu;\n    NormalizationMap = new Map([[\"ﬅ\", \"ſt\"]]);\n  }\n  return str.replaceAll(NormalizeRegex, (_, p1, p2) =>\n    p1 ? p1.normalize(\"NFKC\") : NormalizationMap.get(p2)\n  );\n}\n\nfunction getUuid() {\n  if (\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n    typeof crypto.randomUUID === \"function\"\n  ) {\n    return crypto.randomUUID();\n  }\n  const buf = new Uint8Array(32);\n  crypto.getRandomValues(buf);\n  return bytesToString(buf);\n}\n\nconst AnnotationPrefix = \"pdfjs_internal_id_\";\n\nfunction _isValidExplicitDest(validRef, validName, dest) {\n  if (!Array.isArray(dest) || dest.length < 2) {\n    return false;\n  }\n  const [page, zoom, ...args] = dest;\n  if (!validRef(page) && !Number.isInteger(page)) {\n    return false;\n  }\n  if (!validName(zoom)) {\n    return false;\n  }\n  const argsLen = args.length;\n  let allowNull = true;\n  switch (zoom.name) {\n    case \"XYZ\":\n      if (argsLen < 2 || argsLen > 3) {\n        return false;\n      }\n      break;\n    case \"Fit\":\n    case \"FitB\":\n      return argsLen === 0;\n    case \"FitH\":\n    case \"FitBH\":\n    case \"FitV\":\n    case \"FitBV\":\n      if (argsLen > 1) {\n        return false;\n      }\n      break;\n    case \"FitR\":\n      if (argsLen !== 4) {\n        return false;\n      }\n      allowNull = false;\n      break;\n    default:\n      return false;\n  }\n  for (const arg of args) {\n    if (typeof arg === \"number\" || (allowNull && arg === null)) {\n      continue;\n    }\n    return false;\n  }\n  return true;\n}\n\n// Helpers for simple `Map.prototype.getOrInsertComputed()` invocations,\n// to avoid duplicate function creation.\nconst makeArr = () => [];\nconst makeMap = () => new Map();\nconst makeObj = () => Object.create(null);\n\n// TODO: Replace all occurrences of this function with `Math.clamp` once\n//       https://github.com/tc39/proposal-math-clamp/ is generally available.\nfunction MathClamp(v, min, max) {\n  return Math.min(Math.max(v, min), max);\n}\n\n// TODO: Remove this once `Math.sumPrecise` is generally available.\nif (\n  (typeof PDFJSDev === \"undefined\" ||\n    PDFJSDev.test(\"SKIP_BABEL && !MOZCENTRAL\")) &&\n  typeof Math.sumPrecise !== \"function\"\n) {\n  // Note that this isn't a \"proper\" polyfill, but since we're only using it to\n  // replace `Array.prototype.reduce()` invocations it should be fine.\n  Math.sumPrecise = function (numbers) {\n    return numbers.reduce((a, b) => a + b, 0);\n  };\n}\n\n// See https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes#browser_compatibility\nif (\n  typeof PDFJSDev !== \"undefined\" &&\n  !PDFJSDev.test(\"SKIP_BABEL\") &&\n  typeof Response.prototype.bytes !== \"function\"\n) {\n  Response.prototype.bytes = async function () {\n    return new Uint8Array(await this.arrayBuffer());\n  };\n}\n\n// TODO: Remove this once Safari 17.4 is the lowest supported version.\nif (\n  typeof PDFJSDev !== \"undefined\" &&\n  !PDFJSDev.test(\"SKIP_BABEL\") &&\n  typeof AbortSignal.any !== \"function\"\n) {\n  AbortSignal.any = function (iterable) {\n    const ac = new AbortController();\n    const { signal } = ac;\n\n    // Return immediately if any of the signals are already aborted.\n    for (const s of iterable) {\n      if (s.aborted) {\n        ac.abort(s.reason);\n        return signal;\n      }\n    }\n    // Register \"abort\" listeners for all signals.\n    for (const s of iterable) {\n      s.addEventListener(\n        \"abort\",\n        () => {\n          ac.abort(s.reason);\n        },\n        { signal } // Automatically remove the listener.\n      );\n    }\n\n    return signal;\n  };\n}\n\nexport {\n  _isValidExplicitDest,\n  AbortException,\n  AnnotationActionEventType,\n  AnnotationBorderStyleType,\n  AnnotationEditorParamsType,\n  AnnotationEditorPrefix,\n  AnnotationEditorType,\n  AnnotationFieldFlag,\n  AnnotationFlag,\n  AnnotationMode,\n  AnnotationPrefix,\n  AnnotationReplyType,\n  AnnotationType,\n  assert,\n  BaseException,\n  BASELINE_FACTOR,\n  bytesToString,\n  createValidAbsoluteUrl,\n  DocumentActionEventType,\n  DrawOPS,\n  FeatureTest,\n  FONT_IDENTITY_MATRIX,\n  FormatError,\n  getModificationDate,\n  getUuid,\n  getVerbosityLevel,\n  hexNumbers,\n  ImageKind,\n  info,\n  InvalidPDFException,\n  isArrayEqual,\n  isNodeJS,\n  LINE_DESCENT_FACTOR,\n  LINE_FACTOR,\n  makeArr,\n  makeMap,\n  makeObj,\n  MathClamp,\n  MeshFigureType,\n  normalizeUnicode,\n  objectSize,\n  OPS,\n  PageActionEventType,\n  PasswordException,\n  PasswordResponses,\n  PermissionFlag,\n  RenderingIntentFlag,\n  ResponseException,\n  setVerbosityLevel,\n  shadow,\n  string32,\n  stringToBytes,\n  stringToPDFString,\n  stringToUTF8String,\n  stripPath,\n  TextRenderingMode,\n  UnknownErrorException,\n  unreachable,\n  updateUrlHash,\n  utf8StringToString,\n  Util,\n  VerbosityLevel,\n  warn,\n};\n","/* Copyright 2021 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @typedef {import(\"./api\").TextContent} TextContent */\n\nclass XfaText {\n  /**\n   * Walk an XFA tree and create an array of text nodes that is compatible\n   * with a regular PDFs TextContent. Currently, only TextItem.str is supported,\n   * all other fields and styles haven't been implemented.\n   *\n   * @param {Object} xfa - An XFA fake DOM object.\n   *\n   * @returns {TextContent}\n   */\n  static textContent(xfa) {\n    const items = [];\n    const output = {\n      items,\n      styles: Object.create(null),\n    };\n    function walk(node) {\n      if (!node) {\n        return;\n      }\n      let str = null;\n      const name = node.name;\n      if (name === \"#text\") {\n        str = node.value;\n      } else if (!XfaText.shouldBuildText(name)) {\n        return;\n      } else if (node?.attributes?.textContent) {\n        str = node.attributes.textContent;\n      } else if (node.value) {\n        str = node.value;\n      }\n      if (str !== null) {\n        items.push({\n          str,\n        });\n      }\n      if (!node.children) {\n        return;\n      }\n      for (const child of node.children) {\n        walk(child);\n      }\n    }\n    walk(xfa);\n    return output;\n  }\n\n  /**\n   * @param {string} name - DOM node name. (lower case)\n   *\n   * @returns {boolean} true if the DOM node should have a corresponding text\n   * node.\n   */\n  static shouldBuildText(name) {\n    return !(\n      name === \"textarea\" ||\n      name === \"input\" ||\n      name === \"option\" ||\n      name === \"select\"\n    );\n  }\n}\n\nexport { XfaText };\n","/* Copyright 2021 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line max-len\n/** @typedef {import(\"./annotation_storage\").AnnotationStorage} AnnotationStorage */\n/** @typedef {import(\"./display_utils\").PageViewport} PageViewport */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../web/pdf_link_service.js\").PDFLinkService} PDFLinkService */\n\nimport { XfaText } from \"./xfa_text.js\";\n\n/**\n * @typedef {Object} XfaLayerParameters\n * @property {PageViewport} viewport\n * @property {HTMLDivElement} div\n * @property {Object} xfaHtml\n * @property {AnnotationStorage} [annotationStorage]\n * @property {PDFLinkService} linkService\n * @property {string} [intent] - (default value is 'display').\n */\n\nclass XfaLayer {\n  static setupStorage(html, id, element, storage, intent) {\n    const storedData = storage.getValue(id, { value: null });\n    switch (element.name) {\n      case \"textarea\":\n        if (storedData.value !== null) {\n          html.textContent = storedData.value;\n        }\n        if (intent === \"print\") {\n          break;\n        }\n        html.addEventListener(\"input\", event => {\n          storage.setValue(id, { value: event.target.value });\n        });\n        break;\n      case \"input\":\n        if (\n          element.attributes.type === \"radio\" ||\n          element.attributes.type === \"checkbox\"\n        ) {\n          if (storedData.value === element.attributes.xfaOn) {\n            html.setAttribute(\"checked\", true);\n          } else if (storedData.value === element.attributes.xfaOff) {\n            // The checked attribute may have been set when opening the file,\n            // unset through the UI and we're here because of printing.\n            html.removeAttribute(\"checked\");\n          }\n          if (intent === \"print\") {\n            break;\n          }\n          html.addEventListener(\"change\", event => {\n            storage.setValue(id, {\n              value: event.target.checked\n                ? event.target.getAttribute(\"xfaOn\")\n                : event.target.getAttribute(\"xfaOff\"),\n            });\n          });\n        } else {\n          if (storedData.value !== null) {\n            html.setAttribute(\"value\", storedData.value);\n          }\n          if (intent === \"print\") {\n            break;\n          }\n          html.addEventListener(\"input\", event => {\n            storage.setValue(id, { value: event.target.value });\n          });\n        }\n        break;\n      case \"select\":\n        if (storedData.value !== null) {\n          html.setAttribute(\"value\", storedData.value);\n          for (const option of element.children) {\n            if (option.attributes.value === storedData.value) {\n              option.attributes.selected = true;\n            } else if (option.attributes.hasOwnProperty(\"selected\")) {\n              delete option.attributes.selected;\n            }\n          }\n        }\n        html.addEventListener(\"input\", event => {\n          const options = event.target.options;\n          const value =\n            options.selectedIndex === -1\n              ? \"\"\n              : options[options.selectedIndex].value;\n          storage.setValue(id, { value });\n        });\n        break;\n    }\n  }\n\n  static setAttributes({ html, element, storage = null, intent, linkService }) {\n    const { attributes } = element;\n    const isHTMLAnchorElement = html instanceof HTMLAnchorElement;\n\n    if (attributes.type === \"radio\") {\n      // Avoid to have a radio group when printing with the same as one\n      // already displayed.\n      attributes.name = `${attributes.name}-${intent}`;\n    }\n    for (const [key, value] of Object.entries(attributes)) {\n      if (value === null || value === undefined) {\n        continue;\n      }\n\n      switch (key) {\n        case \"class\":\n          if (value.length) {\n            html.setAttribute(key, value.join(\" \"));\n          }\n          break;\n        case \"dataId\":\n          // We don't need to add dataId in the html object but it can\n          // be useful to know its value when writing printing tests:\n          // in this case, don't skip dataId to have its value.\n          break;\n        case \"id\":\n          html.setAttribute(\"data-element-id\", value);\n          break;\n        case \"style\":\n          Object.assign(html.style, value);\n          break;\n        case \"textContent\":\n          html.textContent = value;\n          break;\n        default:\n          if (!isHTMLAnchorElement || (key !== \"href\" && key !== \"newWindow\")) {\n            html.setAttribute(key, value);\n          }\n      }\n    }\n\n    if (isHTMLAnchorElement) {\n      linkService.addLinkAttributes(\n        html,\n        attributes.href,\n        attributes.newWindow\n      );\n    }\n\n    // Set the value after the others to be sure to overwrite any other values.\n    if (storage && attributes.dataId) {\n      this.setupStorage(html, attributes.dataId, element, storage);\n    }\n  }\n\n  /**\n   * Render the XFA layer.\n   *\n   * @param {XfaLayerParameters} parameters\n   */\n  static render(parameters) {\n    const storage = parameters.annotationStorage;\n    const linkService = parameters.linkService;\n    const root = parameters.xfaHtml;\n    const intent = parameters.intent || \"display\";\n    const rootHtml = document.createElement(root.name);\n    if (root.attributes) {\n      this.setAttributes({\n        html: rootHtml,\n        element: root,\n        intent,\n        linkService,\n      });\n    }\n\n    const isNotForRichText = intent !== \"richText\";\n    const rootDiv = parameters.div;\n    rootDiv.append(rootHtml);\n\n    if (parameters.viewport) {\n      const transform = `matrix(${parameters.viewport.transform.join(\",\")})`;\n      rootDiv.style.transform = transform;\n    }\n\n    // Set defaults.\n    if (isNotForRichText) {\n      rootDiv.setAttribute(\"class\", \"xfaLayer xfaFont\");\n    }\n\n    // Text nodes used for the text highlighter.\n    const textDivs = [];\n\n    // In the rich text context, it's possible to just have a text node without\n    // a root element, so we handle this case here (see issue 17215).\n    if (root.children.length === 0) {\n      if (root.value) {\n        const node = document.createTextNode(root.value);\n        rootHtml.append(node);\n        if (isNotForRichText && XfaText.shouldBuildText(root.name)) {\n          textDivs.push(node);\n        }\n      }\n      return { textDivs };\n    }\n\n    const stack = [[root, -1, rootHtml]];\n\n    while (stack.length > 0) {\n      const [parent, i, html] = stack.at(-1);\n      if (i + 1 === parent.children.length) {\n        stack.pop();\n        continue;\n      }\n\n      const child = parent.children[++stack.at(-1)[1]];\n      if (child === null) {\n        continue;\n      }\n\n      const { name } = child;\n      if (name === \"#text\") {\n        const node = document.createTextNode(child.value);\n        textDivs.push(node);\n        html.append(node);\n        continue;\n      }\n\n      const childHtml = child?.attributes?.xmlns\n        ? document.createElementNS(child.attributes.xmlns, name)\n        : document.createElement(name);\n\n      html.append(childHtml);\n      if (child.attributes) {\n        this.setAttributes({\n          html: childHtml,\n          element: child,\n          storage,\n          intent,\n          linkService,\n        });\n      }\n\n      if (child.children?.length > 0) {\n        stack.push([child, -1, childHtml]);\n      } else if (child.value) {\n        const node = document.createTextNode(child.value);\n        if (isNotForRichText && XfaText.shouldBuildText(name)) {\n          textDivs.push(node);\n        }\n        childHtml.append(node);\n      }\n    }\n\n    /**\n     * TODO: re-enable that stuff once we've JS implementation.\n     * See https://bugzilla.mozilla.org/show_bug.cgi?id=1719465.\n     *\n     * for (const el of rootDiv.querySelectorAll(\n     * \".xfaDisabled input, .xfaDisabled textarea\"\n     * )) {\n     * el.setAttribute(\"disabled\", true);\n     * }\n     * for (const el of rootDiv.querySelectorAll(\n     * \".xfaReadOnly input, .xfaReadOnly textarea\"\n     * )) {\n     * el.setAttribute(\"readOnly\", true);\n     * }\n     */\n\n    for (const el of rootDiv.querySelectorAll(\n      \".xfaNonInteractive input, .xfaNonInteractive textarea\"\n    )) {\n      el.setAttribute(\"readOnly\", true);\n    }\n\n    return {\n      textDivs,\n    };\n  }\n\n  /**\n   * Update the XFA layer.\n   *\n   * @param {XfaLayerParameters} parameters\n   */\n  static update(parameters) {\n    const transform = `matrix(${parameters.viewport.transform.join(\",\")})`;\n    parameters.div.style.transform = transform;\n    parameters.div.hidden = false;\n  }\n}\n\nexport { XfaLayer };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  BaseException,\n  DrawOPS,\n  FeatureTest,\n  MathClamp,\n  shadow,\n  stripPath,\n  Util,\n  warn,\n} from \"../shared/util.js\";\nimport { XfaLayer } from \"./xfa_layer.js\";\n\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\nclass PixelsPerInch {\n  static CSS = 96.0;\n\n  static PDF = 72.0;\n\n  static PDF_TO_CSS_UNITS = this.CSS / this.PDF;\n}\n\nasync function fetchData(url, type = \"text\") {\n  if (\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n    isValidFetchUrl(url, document.baseURI)\n  ) {\n    const response = await fetch(url);\n    if (!response.ok) {\n      throw new Error(response.statusText);\n    }\n    switch (type) {\n      case \"blob\":\n        return response.blob();\n      case \"bytes\":\n        return response.bytes();\n      case \"json\":\n        return response.json();\n    }\n    return response.text();\n  }\n\n  // The Fetch API is not supported.\n  return new Promise((resolve, reject) => {\n    const request = new XMLHttpRequest();\n    request.open(\"GET\", url, /* async = */ true);\n    request.responseType = type === \"bytes\" ? \"arraybuffer\" : type;\n\n    request.onreadystatechange = () => {\n      if (request.readyState !== XMLHttpRequest.DONE) {\n        return;\n      }\n      if (request.status === 200 || request.status === 0) {\n        switch (type) {\n          case \"bytes\":\n            resolve(new Uint8Array(request.response));\n            return;\n          case \"blob\":\n          case \"json\":\n            resolve(request.response);\n            return;\n        }\n        resolve(request.responseText);\n        return;\n      }\n      reject(new Error(request.statusText));\n    };\n\n    request.send(null);\n  });\n}\n\n/**\n * @typedef {Object} PageViewportParameters\n * @property {Array<number>} viewBox - The xMin, yMin, xMax and\n *   yMax coordinates.\n * @property {number} userUnit - The size of units.\n * @property {number} scale - The scale of the viewport.\n * @property {number} rotation - The rotation, in degrees, of the viewport.\n * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset. The\n *   default value is `0`.\n * @property {number} [offsetY] - The vertical, i.e. y-axis, offset. The\n *   default value is `0`.\n * @property {boolean} [dontFlip] - If true, the y-axis will not be flipped.\n *   The default value is `false`.\n */\n\n/**\n * @typedef {Object} PageViewportCloneParameters\n * @property {number} [scale] - The scale, overriding the one in the cloned\n *   viewport. The default value is `this.scale`.\n * @property {number} [rotation] - The rotation, in degrees, overriding the one\n *   in the cloned viewport. The default value is `this.rotation`.\n * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.\n *   The default value is `this.offsetX`.\n * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.\n *   The default value is `this.offsetY`.\n * @property {boolean} [dontFlip] - If true, the x-axis will not be flipped.\n *   The default value is `false`.\n */\n\n/**\n * PDF page viewport created based on scale, rotation and offset.\n */\nclass PageViewport {\n  /**\n   * @param {PageViewportParameters}\n   */\n  constructor({\n    viewBox,\n    userUnit,\n    scale,\n    rotation,\n    offsetX = 0,\n    offsetY = 0,\n    dontFlip = false,\n  }) {\n    this.viewBox = viewBox;\n    this.userUnit = userUnit;\n    this.scale = scale;\n    this.rotation = rotation;\n    this.offsetX = offsetX;\n    this.offsetY = offsetY;\n\n    scale *= userUnit; // Take the userUnit into account.\n\n    // creating transform to convert pdf coordinate system to the normal\n    // canvas like coordinates taking in account scale and rotation\n    const centerX = (viewBox[2] + viewBox[0]) / 2;\n    const centerY = (viewBox[3] + viewBox[1]) / 2;\n    let rotateA, rotateB, rotateC, rotateD;\n    // Normalize the rotation, by clamping it to the [0, 360) range.\n    rotation %= 360;\n    if (rotation < 0) {\n      rotation += 360;\n    }\n    switch (rotation) {\n      case 180:\n        rotateA = -1;\n        rotateB = 0;\n        rotateC = 0;\n        rotateD = 1;\n        break;\n      case 90:\n        rotateA = 0;\n        rotateB = 1;\n        rotateC = 1;\n        rotateD = 0;\n        break;\n      case 270:\n        rotateA = 0;\n        rotateB = -1;\n        rotateC = -1;\n        rotateD = 0;\n        break;\n      case 0:\n        rotateA = 1;\n        rotateB = 0;\n        rotateC = 0;\n        rotateD = -1;\n        break;\n      default:\n        throw new Error(\n          \"PageViewport: Invalid rotation, must be a multiple of 90 degrees.\"\n        );\n    }\n\n    if (dontFlip) {\n      rotateC = -rotateC;\n      rotateD = -rotateD;\n    }\n\n    let offsetCanvasX, offsetCanvasY;\n    let width, height;\n    if (rotateA === 0) {\n      offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;\n      offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;\n      width = (viewBox[3] - viewBox[1]) * scale;\n      height = (viewBox[2] - viewBox[0]) * scale;\n    } else {\n      offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;\n      offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;\n      width = (viewBox[2] - viewBox[0]) * scale;\n      height = (viewBox[3] - viewBox[1]) * scale;\n    }\n    // creating transform for the following operations:\n    // translate(-centerX, -centerY), rotate and flip vertically,\n    // scale, and translate(offsetCanvasX, offsetCanvasY)\n    this.transform = [\n      rotateA * scale,\n      rotateB * scale,\n      rotateC * scale,\n      rotateD * scale,\n      offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,\n      offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY,\n    ];\n\n    this.width = width;\n    this.height = height;\n  }\n\n  /**\n   * The original, un-scaled, viewport dimensions.\n   * @type {Object}\n   */\n  get rawDims() {\n    const dims = this.viewBox;\n\n    return shadow(this, \"rawDims\", {\n      pageWidth: dims[2] - dims[0],\n      pageHeight: dims[3] - dims[1],\n      pageX: dims[0],\n      pageY: dims[1],\n    });\n  }\n\n  /**\n   * Clones viewport, with optional additional properties.\n   * @param {PageViewportCloneParameters} [params]\n   * @returns {PageViewport} Cloned viewport.\n   */\n  clone({\n    scale = this.scale,\n    rotation = this.rotation,\n    offsetX = this.offsetX,\n    offsetY = this.offsetY,\n    dontFlip = false,\n  } = {}) {\n    return new PageViewport({\n      viewBox: this.viewBox.slice(),\n      userUnit: this.userUnit,\n      scale,\n      rotation,\n      offsetX,\n      offsetY,\n      dontFlip,\n    });\n  }\n\n  /**\n   * Converts PDF point to the viewport coordinates. For examples, useful for\n   * converting PDF location into canvas pixel coordinates.\n   * @param {number} x - The x-coordinate.\n   * @param {number} y - The y-coordinate.\n   * @returns {Array} Array containing `x`- and `y`-coordinates of the\n   *   point in the viewport coordinate space.\n   * @see {@link convertToPdfPoint}\n   * @see {@link convertToViewportRectangle}\n   */\n  convertToViewportPoint(x, y) {\n    const p = [x, y];\n    Util.applyTransform(p, this.transform);\n    return p;\n  }\n\n  /**\n   * Converts PDF rectangle to the viewport coordinates.\n   * @param {Array} rect - The xMin, yMin, xMax and yMax coordinates.\n   * @returns {Array} Array containing corresponding coordinates of the\n   *   rectangle in the viewport coordinate space.\n   * @see {@link convertToViewportPoint}\n   */\n  convertToViewportRectangle(rect) {\n    const topLeft = [rect[0], rect[1]];\n    Util.applyTransform(topLeft, this.transform);\n    const bottomRight = [rect[2], rect[3]];\n    Util.applyTransform(bottomRight, this.transform);\n    return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];\n  }\n\n  /**\n   * Converts viewport coordinates to the PDF location. For examples, useful\n   * for converting canvas pixel location into PDF one.\n   * @param {number} x - The x-coordinate.\n   * @param {number} y - The y-coordinate.\n   * @returns {Array} Array containing `x`- and `y`-coordinates of the\n   *   point in the PDF coordinate space.\n   * @see {@link convertToViewportPoint}\n   */\n  convertToPdfPoint(x, y) {\n    const p = [x, y];\n    Util.applyInverseTransform(p, this.transform);\n    return p;\n  }\n}\n\nclass RenderingCancelledException extends BaseException {\n  constructor(msg, extraDelay = 0) {\n    super(msg, \"RenderingCancelledException\");\n    this.extraDelay = extraDelay;\n  }\n}\n\nfunction isDataScheme(url) {\n  const ii = url.length;\n  let i = 0;\n  while (i < ii && url[i].trim() === \"\") {\n    i++;\n  }\n  return url.substring(i, i + 5).toLowerCase() === \"data:\";\n}\n\nfunction isPdfFile(filename) {\n  return typeof filename === \"string\" && /\\.pdf$/i.test(filename);\n}\n\n/**\n * Gets the filename from a given URL.\n * @param {string} url\n * @returns {string}\n */\nfunction getFilenameFromUrl(url) {\n  [url] = url.split(/[#?]/, 1);\n  return stripPath(url);\n}\n\n/**\n * Returns the filename or guessed filename from the url (see issue 3455).\n * @param {string} url - The original PDF location.\n * @param {string} defaultFilename - The value returned if the filename is\n *   unknown, or the protocol is unsupported.\n * @returns {string} Guessed PDF filename.\n */\nfunction getPdfFilenameFromUrl(url, defaultFilename = \"document.pdf\") {\n  if (typeof url !== \"string\") {\n    return defaultFilename;\n  }\n  if (isDataScheme(url)) {\n    warn('getPdfFilenameFromUrl: ignore \"data:\"-URL for performance reasons.');\n    return defaultFilename;\n  }\n\n  const getURL = urlString => {\n    try {\n      return new URL(urlString);\n    } catch {\n      try {\n        return new URL(decodeURIComponent(urlString));\n      } catch {\n        try {\n          // Attempt to parse the URL using the document's base URI.\n          return new URL(urlString, \"https://foo.bar\");\n        } catch {\n          try {\n            return new URL(decodeURIComponent(urlString), \"https://foo.bar\");\n          } catch {\n            return null;\n          }\n        }\n      }\n    }\n  };\n\n  const newURL = getURL(url);\n  if (!newURL) {\n    // If the URL is invalid, return the default filename.\n    return defaultFilename;\n  }\n\n  const decode = name => {\n    try {\n      let decoded = decodeURIComponent(name);\n      if (decoded.includes(\"/\")) {\n        decoded = stripPath(decoded);\n        if (/^\\.pdf$/i.test(decoded)) {\n          return name;\n        }\n      }\n      return decoded;\n    } catch {\n      return name;\n    }\n  };\n\n  const pdfRegex = /\\.pdf$/i;\n  const filename = stripPath(newURL.pathname);\n  if (pdfRegex.test(filename)) {\n    return decode(filename);\n  }\n\n  if (newURL.searchParams.size > 0) {\n    const getLast = iterator => [...iterator].findLast(v => pdfRegex.test(v));\n\n    // If any of the search parameters ends with \".pdf\", return it.\n    const name =\n      getLast(newURL.searchParams.values()) ??\n      getLast(newURL.searchParams.keys());\n    if (name) {\n      return decode(name);\n    }\n  }\n\n  if (newURL.hash) {\n    const reFilename = /[^/?#=]+\\.pdf\\b(?!.*\\.pdf\\b)/i;\n    const hashFilename = reFilename.exec(newURL.hash);\n    if (hashFilename) {\n      return decode(hashFilename[0]);\n    }\n  }\n\n  return defaultFilename;\n}\n\nclass StatTimer {\n  started = Object.create(null);\n\n  times = [];\n\n  time(name) {\n    if (name in this.started) {\n      warn(`Timer is already running for ${name}`);\n    }\n    this.started[name] = Date.now();\n  }\n\n  timeEnd(name) {\n    if (!(name in this.started)) {\n      warn(`Timer has not been started for ${name}`);\n    }\n    this.times.push({\n      name,\n      start: this.started[name],\n      end: Date.now(),\n    });\n    // Remove timer from started so it can be called again.\n    delete this.started[name];\n  }\n\n  toString() {\n    // Find the longest name for padding purposes.\n    const outBuf = [];\n    let longest = 0;\n    for (const { name } of this.times) {\n      longest = Math.max(name.length, longest);\n    }\n    for (const { name, start, end } of this.times) {\n      outBuf.push(`${name.padEnd(longest)} ${end - start}ms\\n`);\n    }\n    return outBuf.join(\"\");\n  }\n}\n\nfunction isValidFetchUrl(url, baseUrl) {\n  if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n    throw new Error(\"Not implemented: isValidFetchUrl\");\n  }\n  const res = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);\n  // The Fetch API only supports the http/https protocols, and not file/ftp.\n  return /https?:/.test(res?.protocol ?? \"\");\n}\n\n/**\n * Event handler to suppress context menu.\n */\nfunction noContextMenu(e) {\n  e.preventDefault();\n}\n\nfunction stopEvent(e) {\n  e.preventDefault();\n  e.stopPropagation();\n}\n\n// Deprecated API function -- display regardless of the `verbosity` setting.\nfunction deprecated(details) {\n  // eslint-disable-next-line no-console\n  console.log(\"Deprecated API usage: \" + details);\n}\n\nclass PDFDateString {\n  static #regex;\n\n  /**\n   * Convert a PDF date string to a JavaScript `Date` object.\n   *\n   * The PDF date string format is described in section 7.9.4 of the official\n   * PDF 32000-1:2008 specification. However, in the PDF 1.7 reference (sixth\n   * edition) Adobe describes the same format including a trailing apostrophe.\n   * This syntax in incorrect, but Adobe Acrobat creates PDF files that contain\n   * them. We ignore all apostrophes as they are not necessary for date parsing.\n   *\n   * Moreover, Adobe Acrobat doesn't handle changing the date to universal time\n   * and doesn't use the user's time zone (effectively ignoring the HH' and mm'\n   * parts of the date string).\n   *\n   * @param {string} input\n   * @returns {Date|null}\n   */\n  static toDateObject(input) {\n    if (input instanceof Date) {\n      return input;\n    }\n    if (!input || typeof input !== \"string\") {\n      return null;\n    }\n\n    // Lazily initialize the regular expression.\n    this.#regex ||= new RegExp(\n      \"^D:\" + // Prefix (required)\n        \"(\\\\d{4})\" + // Year (required)\n        \"(\\\\d{2})?\" + // Month (optional)\n        \"(\\\\d{2})?\" + // Day (optional)\n        \"(\\\\d{2})?\" + // Hour (optional)\n        \"(\\\\d{2})?\" + // Minute (optional)\n        \"(\\\\d{2})?\" + // Second (optional)\n        \"([Z|+|-])?\" + // Universal time relation (optional)\n        \"(\\\\d{2})?\" + // Offset hour (optional)\n        \"'?\" + // Splitting apostrophe (optional)\n        \"(\\\\d{2})?\" + // Offset minute (optional)\n        \"'?\" // Trailing apostrophe (optional)\n    );\n\n    // Optional fields that don't satisfy the requirements from the regular\n    // expression (such as incorrect digit counts or numbers that are out of\n    // range) will fall back the defaults from the specification.\n    const matches = this.#regex.exec(input);\n    if (!matches) {\n      return null;\n    }\n\n    // JavaScript's `Date` object expects the month to be between 0 and 11\n    // instead of 1 and 12, so we have to correct for that.\n    const year = parseInt(matches[1], 10);\n    let month = parseInt(matches[2], 10);\n    month = month >= 1 && month <= 12 ? month - 1 : 0;\n    let day = parseInt(matches[3], 10);\n    day = day >= 1 && day <= 31 ? day : 1;\n    let hour = parseInt(matches[4], 10);\n    hour = hour >= 0 && hour <= 23 ? hour : 0;\n    let minute = parseInt(matches[5], 10);\n    minute = minute >= 0 && minute <= 59 ? minute : 0;\n    let second = parseInt(matches[6], 10);\n    second = second >= 0 && second <= 59 ? second : 0;\n    const universalTimeRelation = matches[7] || \"Z\";\n    let offsetHour = parseInt(matches[8], 10);\n    offsetHour = offsetHour >= 0 && offsetHour <= 23 ? offsetHour : 0;\n    let offsetMinute = parseInt(matches[9], 10) || 0;\n    offsetMinute = offsetMinute >= 0 && offsetMinute <= 59 ? offsetMinute : 0;\n\n    // Universal time relation 'Z' means that the local time is equal to the\n    // universal time, whereas the relations '+'/'-' indicate that the local\n    // time is later respectively earlier than the universal time. Every date\n    // is normalized to universal time.\n    if (universalTimeRelation === \"-\") {\n      hour += offsetHour;\n      minute += offsetMinute;\n    } else if (universalTimeRelation === \"+\") {\n      hour -= offsetHour;\n      minute -= offsetMinute;\n    }\n\n    return new Date(Date.UTC(year, month, day, hour, minute, second));\n  }\n}\n\n/**\n * NOTE: This is (mostly) intended to support printing of XFA forms.\n */\nfunction getXfaPageViewport(xfaPage, { scale = 1, rotation = 0 }) {\n  const { width, height } = xfaPage.attributes.style;\n  const viewBox = [0, 0, parseInt(width), parseInt(height)];\n\n  return new PageViewport({\n    viewBox,\n    userUnit: 1,\n    scale,\n    rotation,\n  });\n}\n\nfunction getRGB(color) {\n  if (color.startsWith(\"#\")) {\n    const colorRGB = parseInt(color.slice(1), 16);\n    return [\n      (colorRGB & 0xff0000) >> 16,\n      (colorRGB & 0x00ff00) >> 8,\n      colorRGB & 0x0000ff,\n    ];\n  }\n\n  if (color.startsWith(\"rgb(\")) {\n    // getComputedStyle(...).color returns a `rgb(R, G, B)` color.\n    return color\n      .slice(/* \"rgb(\".length */ 4, -1) // Strip out \"rgb(\" and \")\".\n      .split(\",\")\n      .map(x => parseInt(x));\n  }\n\n  if (color.startsWith(\"rgba(\")) {\n    return color\n      .slice(/* \"rgba(\".length */ 5, -1) // Strip out \"rgba(\" and \")\".\n      .split(\",\")\n      .map(x => parseInt(x))\n      .slice(0, 3);\n  }\n\n  warn(`Not a valid color format: \"${color}\"`);\n  return [0, 0, 0];\n}\n\nfunction getColorValues(colors) {\n  const span = document.createElement(\"span\");\n  span.style.visibility = \"hidden\";\n  // NOTE: The following does *not* affect `forced-colors: active` mode.\n  span.style.colorScheme = \"only light\";\n  document.body.append(span);\n  for (const name of colors.keys()) {\n    span.style.color = name;\n    const computedColor = window.getComputedStyle(span).color;\n    colors.set(name, getRGB(computedColor));\n  }\n  span.remove();\n}\n\nfunction getCurrentTransform(ctx) {\n  const { a, b, c, d, e, f } = ctx.getTransform();\n  return [a, b, c, d, e, f];\n}\n\nfunction getCurrentTransformInverse(ctx) {\n  const { a, b, c, d, e, f } = ctx.getTransform().invertSelf();\n  return [a, b, c, d, e, f];\n}\n\n/**\n * @param {HTMLDivElement} div\n * @param {PageViewport} viewport\n * @param {boolean} mustFlip\n * @param {boolean} mustRotate\n */\nfunction setLayerDimensions(\n  div,\n  viewport,\n  mustFlip = false,\n  mustRotate = true\n) {\n  if (viewport instanceof PageViewport) {\n    const { pageWidth, pageHeight } = viewport.rawDims;\n    const { style } = div;\n    const useRound = FeatureTest.isCSSRoundSupported;\n\n    const w = `var(--total-scale-factor) * ${pageWidth}px`,\n      h = `var(--total-scale-factor) * ${pageHeight}px`;\n    const widthStr = useRound\n        ? `round(down, ${w}, var(--scale-round-x))`\n        : `calc(${w})`,\n      heightStr = useRound\n        ? `round(down, ${h}, var(--scale-round-y))`\n        : `calc(${h})`;\n\n    if (!mustFlip || viewport.rotation % 180 === 0) {\n      style.width = widthStr;\n      style.height = heightStr;\n    } else {\n      style.width = heightStr;\n      style.height = widthStr;\n    }\n  }\n\n  if (mustRotate) {\n    div.setAttribute(\"data-main-rotation\", viewport.rotation);\n  }\n}\n\n/**\n * Scale factors for the canvas, necessary with HiDPI displays.\n */\nclass OutputScale {\n  constructor() {\n    const { pixelRatio } = OutputScale;\n\n    /**\n     * @type {number} Horizontal scale.\n     */\n    this.sx = pixelRatio;\n\n    /**\n     * @type {number} Vertical scale.\n     */\n    this.sy = pixelRatio;\n  }\n\n  /**\n   * @type {boolean} Returns `true` when scaling is required, `false` otherwise.\n   */\n  get scaled() {\n    return this.sx !== 1 || this.sy !== 1;\n  }\n\n  /**\n   * @type {boolean} Returns `true` when scaling is symmetric,\n   *   `false` otherwise.\n   */\n  get symmetric() {\n    return this.sx === this.sy;\n  }\n\n  /**\n   * @returns {boolean} Returns `true` if scaling was limited,\n   *   `false` otherwise.\n   */\n  limitCanvas(width, height, maxPixels, maxDim, capAreaFactor = -1) {\n    let maxAreaScale = Infinity,\n      maxWidthScale = Infinity,\n      maxHeightScale = Infinity;\n\n    maxPixels = OutputScale.capPixels(maxPixels, capAreaFactor);\n    if (maxPixels > 0) {\n      maxAreaScale = Math.sqrt(maxPixels / (width * height));\n    }\n    if (maxDim !== -1) {\n      maxWidthScale = maxDim / width;\n      maxHeightScale = maxDim / height;\n    }\n    const maxScale = Math.min(maxAreaScale, maxWidthScale, maxHeightScale);\n\n    if (this.sx > maxScale || this.sy > maxScale) {\n      this.sx = maxScale;\n      this.sy = maxScale;\n      return true;\n    }\n    return false;\n  }\n\n  static get pixelRatio() {\n    return globalThis.devicePixelRatio || 1;\n  }\n\n  static capPixels(maxPixels, capAreaFactor) {\n    if (capAreaFactor >= 0) {\n      const winPixels = Math.ceil(\n        (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")\n          ? window.innerWidth * window.innerHeight\n          : window.screen.availWidth * window.screen.availHeight) *\n          this.pixelRatio ** 2 *\n          (1 + capAreaFactor / 100)\n      );\n      return maxPixels > 0 ? Math.min(maxPixels, winPixels) : winPixels;\n    }\n    return maxPixels;\n  }\n}\n\n// See https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types\n// to know which types are supported by the browser.\nconst SupportedImageMimeTypes = [\n  \"image/apng\",\n  \"image/avif\",\n  \"image/bmp\",\n  \"image/gif\",\n  \"image/jpeg\",\n  \"image/png\",\n  \"image/svg+xml\",\n  \"image/webp\",\n  \"image/x-icon\",\n];\n\nclass ColorScheme {\n  static get isDarkMode() {\n    return shadow(\n      this,\n      \"isDarkMode\",\n      !!window?.matchMedia?.(\"(prefers-color-scheme: dark)\").matches\n    );\n  }\n}\n\nclass CSSConstants {\n  static get commentForegroundColor() {\n    const element = document.createElement(\"span\");\n    element.classList.add(\"comment\", \"sidebar\");\n    const { style } = element;\n    style.width = style.height = \"0\";\n    style.display = \"none\";\n    style.color = \"var(--comment-fg-color)\";\n    document.body.append(element);\n    const { color } = window.getComputedStyle(element);\n    element.remove();\n    return shadow(this, \"commentForegroundColor\", getRGB(color));\n  }\n}\n\nfunction applyOpacity(r, g, b, opacity) {\n  opacity = MathClamp(opacity ?? 1, 0, 1);\n  const white = 255 * (1 - opacity);\n  r = Math.round(r * opacity + white);\n  g = Math.round(g * opacity + white);\n  b = Math.round(b * opacity + white);\n  return [r, g, b];\n}\n\nfunction RGBToHSL(rgb, output) {\n  const r = rgb[0] / 255;\n  const g = rgb[1] / 255;\n  const b = rgb[2] / 255;\n\n  const max = Math.max(r, g, b);\n  const min = Math.min(r, g, b);\n  const l = (max + min) / 2;\n\n  if (max === min) {\n    // achromatic\n    output[0] = output[1] = 0; // hue and saturation are 0\n  } else {\n    const d = max - min;\n    output[1] = l < 0.5 ? d / (max + min) : d / (2 - max - min);\n    // hue\n    switch (max) {\n      case r:\n        output[0] = ((g - b) / d + (g < b ? 6 : 0)) * 60;\n        break;\n      case g:\n        output[0] = ((b - r) / d + 2) * 60;\n        break;\n      case b:\n        output[0] = ((r - g) / d + 4) * 60;\n        break;\n    }\n  }\n  output[2] = l;\n}\n\nfunction HSLToRGB(hsl, output) {\n  const h = hsl[0];\n  const s = hsl[1];\n  const l = hsl[2];\n  const c = (1 - Math.abs(2 * l - 1)) * s; // chroma\n  const x = c * (1 - Math.abs(((h / 60) % 2) - 1));\n  const m = l - c / 2;\n\n  switch (Math.floor(h / 60)) {\n    case 0:\n      output[0] = c + m;\n      output[1] = x + m;\n      output[2] = m;\n      break;\n    case 1:\n      output[0] = x + m;\n      output[1] = c + m;\n      output[2] = m;\n      break;\n    case 2:\n      output[0] = m;\n      output[1] = c + m;\n      output[2] = x + m;\n      break;\n    case 3:\n      output[0] = m;\n      output[1] = x + m;\n      output[2] = c + m;\n      break;\n    case 4:\n      output[0] = x + m;\n      output[1] = m;\n      output[2] = c + m;\n      break;\n    case 5:\n    case 6:\n      output[0] = c + m;\n      output[1] = m;\n      output[2] = x + m;\n      break;\n  }\n}\n\nfunction computeLuminance(x) {\n  return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;\n}\n\nfunction contrastRatio(hsl1, hsl2, output) {\n  HSLToRGB(hsl1, output);\n  output.map(computeLuminance);\n  const lum1 = 0.2126 * output[0] + 0.7152 * output[1] + 0.0722 * output[2];\n  HSLToRGB(hsl2, output);\n  output.map(computeLuminance);\n  const lum2 = 0.2126 * output[0] + 0.7152 * output[1] + 0.0722 * output[2];\n  return lum1 > lum2\n    ? (lum1 + 0.05) / (lum2 + 0.05)\n    : (lum2 + 0.05) / (lum1 + 0.05);\n}\n\n// Cache for the findContrastColor function, to improve performance.\nconst contrastCache = new Map();\n\n/**\n * Find a color that has sufficient contrast against a fixed color.\n * The luminance (in HSL color space) of the base color is adjusted\n * until the contrast ratio between the base color and the fixed color\n * is at least the minimum contrast ratio required by WCAG 2.1.\n * @param {Array<number>} baseColor\n * @param {Array<number>} fixedColor\n * @returns {string}\n */\nfunction findContrastColor(baseColor, fixedColor) {\n  const key =\n    baseColor[0] +\n    baseColor[1] * 0x100 +\n    baseColor[2] * 0x10000 +\n    fixedColor[0] * 0x1000000 +\n    fixedColor[1] * 0x100000000 +\n    fixedColor[2] * 0x10000000000;\n  let cachedValue = contrastCache.get(key);\n  if (cachedValue) {\n    return cachedValue;\n  }\n  const array = new Float32Array(9);\n  const output = array.subarray(0, 3);\n  const baseHSL = array.subarray(3, 6);\n  RGBToHSL(baseColor, baseHSL);\n  const fixedHSL = array.subarray(6, 9);\n  RGBToHSL(fixedColor, fixedHSL);\n  const isFixedColorDark = fixedHSL[2] < 0.5;\n\n  // Use the contrast ratio requirements from WCAG 2.1.\n  // https://www.w3.org/TR/WCAG21/#contrast-minimum\n  // https://www.w3.org/TR/WCAG21/#contrast-enhanced\n  const minContrast = isFixedColorDark ? 12 : 4.5;\n\n  baseHSL[2] = isFixedColorDark\n    ? Math.sqrt(baseHSL[2])\n    : 1 - Math.sqrt(1 - baseHSL[2]);\n\n  if (contrastRatio(baseHSL, fixedHSL, output) < minContrast) {\n    let start, end;\n    if (isFixedColorDark) {\n      start = baseHSL[2];\n      end = 1;\n    } else {\n      start = 0;\n      end = baseHSL[2];\n    }\n    const PRECISION = 0.005;\n    while (end - start > PRECISION) {\n      const mid = (baseHSL[2] = (start + end) / 2);\n      if (\n        isFixedColorDark ===\n        contrastRatio(baseHSL, fixedHSL, output) < minContrast\n      ) {\n        start = mid;\n      } else {\n        end = mid;\n      }\n    }\n    baseHSL[2] = isFixedColorDark ? end : start;\n  }\n\n  HSLToRGB(baseHSL, output);\n  cachedValue = Util.makeHexColor(\n    Math.round(output[0] * 255),\n    Math.round(output[1] * 255),\n    Math.round(output[2] * 255)\n  );\n  contrastCache.set(key, cachedValue);\n  return cachedValue;\n}\n\nfunction renderRichText({ html, dir, className }, container) {\n  const fragment = document.createDocumentFragment();\n  if (typeof html === \"string\") {\n    const p = document.createElement(\"p\");\n    p.dir = dir || \"auto\";\n    const lines = html.split(/(?:\\r\\n?|\\n)/);\n    for (let i = 0, ii = lines.length; i < ii; ++i) {\n      const line = lines[i];\n      p.append(document.createTextNode(line));\n      if (i < ii - 1) {\n        p.append(document.createElement(\"br\"));\n      }\n    }\n    fragment.append(p);\n  } else {\n    XfaLayer.render({\n      xfaHtml: html,\n      div: fragment,\n      intent: \"richText\",\n    });\n  }\n  fragment.firstElementChild.classList.add(\"richText\", className);\n  container.append(fragment);\n}\n\nfunction makePathFromDrawOPS(data) {\n  // Using a SVG string is slightly slower than using the following loop.\n  const path = new Path2D();\n  if (!data) {\n    return path;\n  }\n  for (let i = 0, ii = data.length; i < ii; ) {\n    switch (data[i++]) {\n      case DrawOPS.moveTo:\n        path.moveTo(data[i++], data[i++]);\n        break;\n      case DrawOPS.lineTo:\n        path.lineTo(data[i++], data[i++]);\n        break;\n      case DrawOPS.curveTo:\n        path.bezierCurveTo(\n          data[i++],\n          data[i++],\n          data[i++],\n          data[i++],\n          data[i++],\n          data[i++]\n        );\n        break;\n      case DrawOPS.quadraticCurveTo:\n        path.quadraticCurveTo(data[i++], data[i++], data[i++], data[i++]);\n        break;\n      case DrawOPS.closePath:\n        path.closePath();\n        break;\n      default:\n        warn(`Unrecognized drawing path operator: ${data[i - 1]}`);\n        break;\n    }\n  }\n  return path;\n}\n\n/**\n * Maps between page IDs and page numbers, allowing bidirectional conversion\n * between the two representations. This is useful when the page numbering\n * in the PDF document doesn't match the default sequential ordering.\n */\nclass PagesMapper {\n  /**\n   * Maps page IDs to their corresponding page numbers.\n   * @type {Map<number, Array<number>>|null}\n   */\n  #idToPageNumber = null;\n\n  /**\n   * Maps page numbers to their corresponding page IDs.\n   * @type {Uint32Array|null}\n   */\n  #pageNumberToId = null;\n\n  /**\n   * Previous mapping of page IDs to page numbers.\n   * @type {Int32Array|null}\n   */\n  #prevPageNumbers = null;\n\n  /**\n   * The total number of pages.\n   * @type {number}\n   */\n  #pagesNumber = 0;\n\n  /**\n   * Listeners for page changes.\n   * @type {Array<function>}\n   */\n  #listeners = [];\n\n  /**\n   * Maps page numbers to their corresponding page IDs (used in copy\n   * operations).\n   * @type {Uint32Array|null}\n   */\n  #copiedPageIds = null;\n\n  /**\n   * Maps page IDs to their corresponding page numbers, used in copy operations.\n   * @type {Uint32Array|null}\n   */\n  #copiedPageNumbers = null;\n\n  /**\n   * Gets the total number of pages.\n   * @returns {number} The number of pages.\n   */\n  get pagesNumber() {\n    return this.#pagesNumber;\n  }\n\n  /**\n   * Sets the total number of pages and initializes default mappings\n   * where page IDs equal page numbers (1-indexed).\n   * @param {number} n - The total number of pages.\n   */\n  set pagesNumber(n) {\n    if (this.#pagesNumber === n) {\n      return;\n    }\n    this.#pagesNumber = n;\n    this.#reset();\n  }\n\n  /**\n   * Resets the page mappings to their default state, where page IDs equal page\n   * numbers (1-indexed). This is called when the number of pages changes, or\n   * when the current mapping matches the default mapping after a move\n   * operation.\n   */\n  #reset() {\n    this.#pageNumberToId = null;\n    this.#idToPageNumber = null;\n  }\n\n  /**\n   * Adds a listener function that will be called whenever the page mappings\n   * are updated.\n   * @param {function} listener\n   */\n  addListener(listener) {\n    this.#listeners.push(listener);\n  }\n\n  /**\n   * Removes a previously added listener function.\n   * @param {function} listener\n   */\n  removeListener(listener) {\n    const index = this.#listeners.indexOf(listener);\n    if (index >= 0) {\n      this.#listeners.splice(index, 1);\n    }\n  }\n\n  /**\n   * Calls all registered listener functions to notify them of changes to the\n   * page mappings.\n   * @param {Object} data - An object containing information about the update.\n   */\n  #updateListeners(data) {\n    for (const listener of this.#listeners) {\n      listener(data);\n    }\n  }\n\n  /**\n   * Initializes the page mappings if they haven't been initialized yet.\n   * @param {boolean} mustInit\n   */\n  #init(mustInit) {\n    if (this.#pageNumberToId) {\n      return;\n    }\n    const n = this.#pagesNumber;\n\n    const pageNumberToId = (this.#pageNumberToId = new Uint32Array(n));\n    this.#prevPageNumbers = new Int32Array(pageNumberToId);\n    const idToPageNumber = (this.#idToPageNumber = new Map());\n    if (mustInit) {\n      for (let i = 1; i <= n; i++) {\n        pageNumberToId[i - 1] = i;\n        idToPageNumber.set(i, [i]);\n      }\n    }\n  }\n\n  /**\n   * Updates the mapping from page IDs to page numbers based on the current\n   * mapping from page numbers to page IDs. This should be called after any\n   * changes to the page-number-to-ID mapping to keep the two mappings in sync.\n   */\n  #updateIdToPageNumber() {\n    const idToPageNumber = this.#idToPageNumber;\n    const pageNumberToId = this.#pageNumberToId;\n    idToPageNumber.clear();\n    for (let i = 0, ii = this.#pagesNumber; i < ii; i++) {\n      const id = pageNumberToId[i];\n      const pageNumbers = idToPageNumber.get(id);\n      if (pageNumbers) {\n        pageNumbers.push(i + 1);\n      } else {\n        idToPageNumber.set(id, [i + 1]);\n      }\n    }\n  }\n\n  /**\n   * Move a set of pages to a new position while keeping ID→number mappings in\n   * sync.\n   *\n   * @param {Set<number>} selectedPages - Page numbers being moved (1-indexed).\n   * @param {number[]} pagesToMove - Ordered list of page numbers to move.\n   * @param {number} index - Zero-based insertion index in the page-number list.\n   */\n  movePages(selectedPages, pagesToMove, index) {\n    this.#init(true);\n    const pageNumberToId = this.#pageNumberToId;\n    const idToPageNumber = this.#idToPageNumber;\n    const movedCount = pagesToMove.length;\n    const mappedPagesToMove = new Uint32Array(movedCount);\n    let removedBeforeTarget = 0;\n\n    for (let i = 0; i < movedCount; i++) {\n      const pageIndex = pagesToMove[i] - 1;\n      mappedPagesToMove[i] = pageNumberToId[pageIndex];\n      if (pageIndex < index) {\n        removedBeforeTarget += 1;\n      }\n    }\n\n    const pagesNumber = this.#pagesNumber;\n    // target index after removing elements that were before it\n    let adjustedTarget = index - removedBeforeTarget;\n    const remainingLen = pagesNumber - movedCount;\n    adjustedTarget = MathClamp(adjustedTarget, 0, remainingLen);\n\n    // Create the new mapping.\n    // First copy over the pages that are not being moved.\n    // Then insert the moved pages at the target position.\n    for (let i = 0, r = 0; i < pagesNumber; i++) {\n      if (!selectedPages.has(i + 1)) {\n        pageNumberToId[r++] = pageNumberToId[i];\n      }\n    }\n\n    // Shift the pages after the target position.\n    pageNumberToId.copyWithin(\n      adjustedTarget + movedCount,\n      adjustedTarget,\n      remainingLen\n    );\n    // Finally insert the moved pages.\n    pageNumberToId.set(mappedPagesToMove, adjustedTarget);\n\n    this.#setPrevPageNumbers(idToPageNumber, null);\n    this.#updateIdToPageNumber();\n    this.#updateListeners({ type: \"move\" });\n\n    if (pageNumberToId.every((id, i) => id === i + 1)) {\n      this.#reset();\n    }\n  }\n\n  /**\n   * Deletes a set of pages while keeping ID→number mappings in sync.\n   * @param {Array<number>} pagesToDelete - Page numbers to delete (1-indexed).\n   *  These must be unique and sorted in ascending order.\n   */\n  deletePages(pagesToDelete) {\n    this.#init(true);\n    const pageNumberToId = this.#pageNumberToId;\n    const prevIdToPageNumber = this.#idToPageNumber;\n\n    this.pagesNumber -= pagesToDelete.length;\n    this.#init(false);\n    const newPageNumberToId = this.#pageNumberToId;\n\n    let sourceIndex = 0;\n    let destIndex = 0;\n    for (const pageNumber of pagesToDelete) {\n      const pageIndex = pageNumber - 1;\n      if (pageIndex !== sourceIndex) {\n        newPageNumberToId.set(\n          pageNumberToId.subarray(sourceIndex, pageIndex),\n          destIndex\n        );\n        destIndex += pageIndex - sourceIndex;\n      }\n      sourceIndex = pageIndex + 1;\n    }\n    if (sourceIndex < pageNumberToId.length) {\n      newPageNumberToId.set(pageNumberToId.subarray(sourceIndex), destIndex);\n    }\n\n    this.#setPrevPageNumbers(prevIdToPageNumber, null);\n    this.#updateIdToPageNumber();\n    this.#updateListeners({ type: \"delete\", pageNumbers: pagesToDelete });\n  }\n\n  /**\n   * Copies a set of pages while keeping ID→number mappings in sync.\n   * @param {Uint32Array} pagesToCopy - Page numbers to copy (1-indexed).\n   */\n  copyPages(pagesToCopy) {\n    this.#init(true);\n    this.#copiedPageNumbers = pagesToCopy;\n    this.#copiedPageIds = pagesToCopy.map(\n      pageNumber => this.#pageNumberToId[pageNumber - 1]\n    );\n    this.#updateListeners({ type: \"copy\", pageNumbers: pagesToCopy });\n  }\n\n  /**\n   * Pastes a set of pages while keeping ID→number mappings in sync.\n   * @param {number} index - Zero-based insertion index in the page-number list.\n   */\n  pastePages(index) {\n    this.#init(true);\n    const pageNumberToId = this.#pageNumberToId;\n    const prevIdToPageNumber = this.#idToPageNumber;\n    const copiedPageNumbers = this.#copiedPageNumbers;\n\n    const copiedPageMapping = new Map();\n    let base = index;\n    for (const pageNumber of copiedPageNumbers) {\n      copiedPageMapping.set(++base, pageNumber);\n    }\n    this.pagesNumber += copiedPageNumbers.length;\n    this.#init(false);\n    const newPageNumberToId = this.#pageNumberToId;\n\n    newPageNumberToId.set(pageNumberToId.subarray(0, index), 0);\n    newPageNumberToId.set(this.#copiedPageIds, index);\n    newPageNumberToId.set(\n      pageNumberToId.subarray(index),\n      index + copiedPageNumbers.length\n    );\n\n    this.#setPrevPageNumbers(prevIdToPageNumber, copiedPageMapping);\n    this.#updateIdToPageNumber();\n    this.#updateListeners({ type: \"paste\" });\n\n    this.#copiedPageIds = null;\n  }\n\n  /**\n   * Updates the previous page numbers based on the current page-number-to-ID\n   * mapping and the provided previous ID-to-page-number mapping.\n   * This is used to keep track of the original page numbers for each page ID.\n   * @param {Map<number, Array<number>} prevIdToPageNumber\n   * @param {Map<number, number>|null} copiedPageMapping\n   */\n  #setPrevPageNumbers(prevIdToPageNumber, copiedPageMapping) {\n    const prevPageNumbers = this.#prevPageNumbers;\n    const newPageNumberToId = this.#pageNumberToId;\n    const idsIndices = new Map();\n    for (let i = 0, ii = this.#pagesNumber; i < ii; i++) {\n      const oldPageNumber = copiedPageMapping?.get(i + 1);\n      if (oldPageNumber) {\n        prevPageNumbers[i] = -oldPageNumber;\n        continue;\n      }\n      const id = newPageNumberToId[i];\n      const j = idsIndices.get(id) || 0;\n      prevPageNumbers[i] = prevIdToPageNumber.get(id)?.[j];\n      idsIndices.set(id, j + 1);\n    }\n  }\n\n  /**\n   * Checks if the page mappings have been altered from their initial state.\n   * @returns {boolean} True if the mappings have been altered, false otherwise.\n   */\n  hasBeenAltered() {\n    return this.#pageNumberToId !== null;\n  }\n\n  /**\n   * Gets the current page mapping suitable for saving.\n   * @returns {Object} An object containing the page indices.\n   */\n  getPageMappingForSaving() {\n    const idToPageNumber = this.#idToPageNumber;\n\n    // idToPageNumber maps used 1-based IDs to 1-based page numbers.\n    // For example if the final pdf contains page 3 twice and they are moved at\n    // page 1 and 4, then it contains:\n    //   pageNumberToId = [3, ., ., 3, ...,]\n    //   idToPageNumber = {3: [1, 4], ...}\n    // In such a case we need to take a page 3 from the original pdf and take\n    // page 3 from a \"copy\".\n    // So we need to pass to the api something like:\n    // [ {\n    //   document: null // this pdf\n    //   includePages: [ 2, ... ], // page 3 is at index 2\n    //   pageIndices: [0, ...], // page 3 will be at index 0 in the new pdf\n    // }, {\n    //   document: null // this pdf\n    //   includePages: [ 2, ... ], // page 3 is at index 2\n    //   pageIndices: [3, ...], // page 3 will be at index 3 in the new pdf\n    // }\n    // ]\n\n    let nCopy = 0;\n    for (const pageNumbers of idToPageNumber.values()) {\n      nCopy = Math.max(nCopy, pageNumbers.length);\n    }\n\n    const extractParams = new Array(nCopy);\n    for (let i = 0; i < nCopy; i++) {\n      extractParams[i] = {\n        document: null,\n        pageIndices: [],\n        includePages: [],\n      };\n    }\n\n    for (const [id, pageNumbers] of idToPageNumber) {\n      for (let i = 0, ii = pageNumbers.length; i < ii; i++) {\n        extractParams[i].includePages.push([id - 1, pageNumbers[i] - 1]);\n      }\n    }\n\n    for (const { includePages, pageIndices } of extractParams) {\n      includePages.sort((a, b) => a[0] - b[0]);\n      for (let i = 0, ii = includePages.length; i < ii; i++) {\n        pageIndices.push(includePages[i][1]);\n        includePages[i] = includePages[i][0];\n      }\n    }\n\n    return extractParams;\n  }\n\n  /**\n   * Gets the previous page number for a given page number.\n   * @param {number} pageNumber\n   * @returns {number} The previous page number for the given page number, or 0\n   *   if no mapping exists.\n   */\n  getPrevPageNumber(pageNumber) {\n    return this.#prevPageNumbers[pageNumber - 1] ?? 0;\n  }\n\n  /**\n   * Gets the page number for a given page ID.\n   * @param {number} id - The page ID (1-indexed).\n   * @returns {number} The page number, or 0 if no mapping exists.\n   */\n  getPageNumber(id) {\n    return this.#idToPageNumber ? (this.#idToPageNumber.get(id)?.[0] ?? 0) : id;\n  }\n\n  /**\n   * Gets the page ID for a given page number.\n   * @param {number} pageNumber - The page number (1-indexed).\n   * @returns {number} The page ID, or the page number itself if no mapping\n   * exists.\n   */\n  getPageId(pageNumber) {\n    return this.#pageNumberToId?.[pageNumber - 1] ?? pageNumber;\n  }\n\n  getMapping() {\n    return this.#pageNumberToId.subarray(0, this.pagesNumber);\n  }\n}\n\nexport {\n  applyOpacity,\n  ColorScheme,\n  CSSConstants,\n  deprecated,\n  fetchData,\n  findContrastColor,\n  getColorValues,\n  getCurrentTransform,\n  getCurrentTransformInverse,\n  getFilenameFromUrl,\n  getPdfFilenameFromUrl,\n  getRGB,\n  getXfaPageViewport,\n  isDataScheme,\n  isPdfFile,\n  isValidFetchUrl,\n  makePathFromDrawOPS,\n  noContextMenu,\n  OutputScale,\n  PagesMapper,\n  PageViewport,\n  PDFDateString,\n  PixelsPerInch,\n  RenderingCancelledException,\n  renderRichText,\n  setLayerDimensions,\n  StatTimer,\n  stopEvent,\n  SupportedImageMimeTypes,\n  SVG_NS,\n};\n","/* Copyright 2023 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { noContextMenu, stopEvent } from \"../display_utils.js\";\n\nclass EditorToolbar {\n  #toolbar = null;\n\n  #colorPicker = null;\n\n  #editor;\n\n  #buttons = null;\n\n  #altText = null;\n\n  #comment = null;\n\n  #commentButtonDivider = null;\n\n  #signatureDescriptionButton = null;\n\n  static #l10nRemove = null;\n\n  constructor(editor) {\n    this.#editor = editor;\n\n    EditorToolbar.#l10nRemove ||= Object.freeze({\n      freetext: \"pdfjs-editor-remove-freetext-button\",\n      highlight: \"pdfjs-editor-remove-highlight-button\",\n      ink: \"pdfjs-editor-remove-ink-button\",\n      stamp: \"pdfjs-editor-remove-stamp-button\",\n      signature: \"pdfjs-editor-remove-signature-button\",\n    });\n  }\n\n  render() {\n    const editToolbar = (this.#toolbar = document.createElement(\"div\"));\n    editToolbar.classList.add(\"editToolbar\", \"hidden\");\n    editToolbar.setAttribute(\"role\", \"toolbar\");\n\n    const signal = this.#editor._uiManager._signal;\n    if (signal instanceof AbortSignal && !signal.aborted) {\n      editToolbar.addEventListener(\"contextmenu\", noContextMenu, { signal });\n      editToolbar.addEventListener(\"pointerdown\", EditorToolbar.#pointerDown, {\n        signal,\n      });\n    }\n\n    const buttons = (this.#buttons = document.createElement(\"div\"));\n    buttons.className = \"buttons\";\n    editToolbar.append(buttons);\n\n    const position = this.#editor.toolbarPosition;\n    if (position) {\n      const { style } = editToolbar;\n      const x =\n        this.#editor._uiManager.direction === \"ltr\"\n          ? 1 - position[0]\n          : position[0];\n      style.insetInlineEnd = `${100 * x}%`;\n      style.top = `calc(${\n        100 * position[1]\n      }% + var(--editor-toolbar-vert-offset))`;\n    }\n\n    return editToolbar;\n  }\n\n  get div() {\n    return this.#toolbar;\n  }\n\n  static #pointerDown(e) {\n    e.stopPropagation();\n  }\n\n  #focusIn(e) {\n    this.#editor._focusEventsAllowed = false;\n    stopEvent(e);\n  }\n\n  #focusOut(e) {\n    this.#editor._focusEventsAllowed = true;\n    stopEvent(e);\n  }\n\n  #addListenersToElement(element) {\n    // If we're clicking on a button with the keyboard or with\n    // the mouse, we don't want to trigger any focus events on\n    // the editor.\n    const signal = this.#editor._uiManager._signal;\n    if (!(signal instanceof AbortSignal) || signal.aborted) {\n      return false;\n    }\n    element.addEventListener(\"focusin\", this.#focusIn.bind(this), {\n      capture: true,\n      signal,\n    });\n    element.addEventListener(\"focusout\", this.#focusOut.bind(this), {\n      capture: true,\n      signal,\n    });\n    element.addEventListener(\"contextmenu\", noContextMenu, { signal });\n    return true;\n  }\n\n  hide() {\n    this.#toolbar.classList.add(\"hidden\");\n    this.#colorPicker?.hideDropdown();\n  }\n\n  show() {\n    this.#toolbar.classList.remove(\"hidden\");\n    this.#altText?.shown();\n    this.#comment?.shown();\n  }\n\n  addDeleteButton() {\n    const { editorType, _uiManager } = this.#editor;\n\n    const button = document.createElement(\"button\");\n    button.classList.add(\"basic\", \"deleteButton\");\n    button.tabIndex = 0;\n    button.setAttribute(\"data-l10n-id\", EditorToolbar.#l10nRemove[editorType]);\n    if (this.#addListenersToElement(button)) {\n      button.addEventListener(\n        \"click\",\n        e => {\n          _uiManager.delete();\n        },\n        { signal: _uiManager._signal }\n      );\n    }\n    this.#buttons.append(button);\n  }\n\n  get #divider() {\n    const divider = document.createElement(\"div\");\n    divider.className = \"divider\";\n    return divider;\n  }\n\n  async addAltText(altText) {\n    const button = await altText.render();\n    this.#addListenersToElement(button);\n    this.#buttons.append(button, this.#divider);\n    this.#altText = altText;\n  }\n\n  addComment(comment, beforeElement = null) {\n    if (this.#comment) {\n      return;\n    }\n    const button = comment.renderForToolbar();\n    if (!button) {\n      return;\n    }\n    this.#addListenersToElement(button);\n    const divider = (this.#commentButtonDivider = this.#divider);\n    if (!beforeElement) {\n      this.#buttons.append(button, divider);\n    } else {\n      this.#buttons.insertBefore(button, beforeElement);\n      this.#buttons.insertBefore(divider, beforeElement);\n    }\n    this.#comment = comment;\n    comment.toolbar = this;\n  }\n\n  addColorPicker(colorPicker) {\n    if (this.#colorPicker) {\n      return;\n    }\n    this.#colorPicker = colorPicker;\n    const button = colorPicker.renderButton();\n    this.#addListenersToElement(button);\n    this.#buttons.append(button, this.#divider);\n  }\n\n  async addEditSignatureButton(signatureManager) {\n    const button = (this.#signatureDescriptionButton =\n      await signatureManager.renderEditButton(this.#editor));\n    this.#addListenersToElement(button);\n    this.#buttons.append(button, this.#divider);\n  }\n\n  removeButton(name) {\n    switch (name) {\n      case \"comment\":\n        this.#comment?.removeToolbarCommentButton();\n        this.#comment = null;\n        this.#commentButtonDivider?.remove();\n        this.#commentButtonDivider = null;\n        break;\n    }\n  }\n\n  async addButton(name, tool) {\n    switch (name) {\n      case \"colorPicker\":\n        if (tool) {\n          this.addColorPicker(tool);\n        }\n        break;\n      case \"altText\":\n        if (tool) {\n          await this.addAltText(tool);\n        }\n        break;\n      case \"editSignature\":\n        if (tool) {\n          await this.addEditSignatureButton(tool);\n        }\n        break;\n      case \"delete\":\n        this.addDeleteButton();\n        break;\n      case \"comment\":\n        if (tool) {\n          this.addComment(tool);\n        }\n        break;\n    }\n  }\n\n  async addButtonBefore(name, tool, beforeSelector) {\n    if (!tool && name === \"comment\") {\n      return;\n    }\n    const beforeElement = this.#buttons.querySelector(beforeSelector);\n    if (!beforeElement) {\n      return;\n    }\n    if (name === \"comment\") {\n      this.addComment(tool, beforeElement);\n    }\n  }\n\n  updateEditSignatureButton(description) {\n    if (this.#signatureDescriptionButton) {\n      this.#signatureDescriptionButton.title = description;\n    }\n  }\n\n  remove() {\n    this.#toolbar.remove();\n    this.#colorPicker?.destroy();\n    this.#colorPicker = null;\n  }\n}\n\nclass FloatingToolbar {\n  #buttons = null;\n\n  #toolbar = null;\n\n  #uiManager;\n\n  constructor(uiManager) {\n    this.#uiManager = uiManager;\n  }\n\n  #render() {\n    const editToolbar = (this.#toolbar = document.createElement(\"div\"));\n    editToolbar.className = \"editToolbar\";\n    editToolbar.setAttribute(\"role\", \"toolbar\");\n\n    const signal = this.#uiManager._signal;\n    if (signal instanceof AbortSignal && !signal.aborted) {\n      editToolbar.addEventListener(\"contextmenu\", noContextMenu, {\n        signal,\n      });\n    }\n\n    const buttons = (this.#buttons = document.createElement(\"div\"));\n    buttons.className = \"buttons\";\n    editToolbar.append(buttons);\n\n    if (this.#uiManager.hasCommentManager()) {\n      this.#makeButton(\n        \"commentButton\",\n        `pdfjs-comment-floating-button`,\n        \"pdfjs-comment-floating-button-label\",\n        () => {\n          this.#uiManager.commentSelection(\"floating_button\");\n        }\n      );\n    }\n\n    this.#makeButton(\n      \"highlightButton\",\n      `pdfjs-highlight-floating-button1`,\n      \"pdfjs-highlight-floating-button-label\",\n      () => {\n        this.#uiManager.highlightSelection(\"floating_button\");\n      }\n    );\n\n    return editToolbar;\n  }\n\n  #getLastPoint(boxes, isLTR) {\n    let lastY = 0;\n    let lastX = 0;\n    for (const box of boxes) {\n      const y = box.y + box.height;\n      if (y < lastY) {\n        continue;\n      }\n      const x = box.x + (isLTR ? box.width : 0);\n      if (y > lastY) {\n        lastX = x;\n        lastY = y;\n        continue;\n      }\n      if (isLTR) {\n        if (x > lastX) {\n          lastX = x;\n        }\n      } else if (x < lastX) {\n        lastX = x;\n      }\n    }\n    return [isLTR ? 1 - lastX : lastX, lastY];\n  }\n\n  show(parent, boxes, isLTR) {\n    const [x, y] = this.#getLastPoint(boxes, isLTR);\n    const { style } = (this.#toolbar ||= this.#render());\n    parent.append(this.#toolbar);\n    style.insetInlineEnd = `${100 * x}%`;\n    style.top = `calc(${100 * y}% + var(--editor-toolbar-vert-offset))`;\n  }\n\n  hide() {\n    this.#toolbar.remove();\n  }\n\n  #makeButton(buttonClass, l10nId, labelL10nId, clickHandler) {\n    const button = document.createElement(\"button\");\n    button.classList.add(\"basic\", buttonClass);\n    button.tabIndex = 0;\n    button.setAttribute(\"data-l10n-id\", l10nId);\n    const span = document.createElement(\"span\");\n    button.append(span);\n    span.className = \"visuallyHidden\";\n    span.setAttribute(\"data-l10n-id\", labelL10nId);\n    const signal = this.#uiManager._signal;\n    if (signal instanceof AbortSignal && !signal.aborted) {\n      button.addEventListener(\"contextmenu\", noContextMenu, { signal });\n      button.addEventListener(\"click\", clickHandler, { signal });\n    }\n    this.#buttons.append(button);\n  }\n}\n\nexport { EditorToolbar, FloatingToolbar };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @typedef {import(\"./editor.js\").AnnotationEditor} AnnotationEditor */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"./annotation_editor_layer.js\").AnnotationEditorLayer} AnnotationEditorLayer */\n\nimport {\n  AnnotationEditorParamsType,\n  AnnotationEditorPrefix,\n  AnnotationEditorType,\n  FeatureTest,\n  getUuid,\n  shadow,\n  Util,\n  warn,\n} from \"../../shared/util.js\";\nimport {\n  fetchData,\n  getColorValues,\n  getRGB,\n  PixelsPerInch,\n  stopEvent,\n} from \"../display_utils.js\";\nimport { FloatingToolbar } from \"./toolbar.js\";\n\nfunction bindEvents(obj, element, names) {\n  for (const name of names) {\n    element.addEventListener(name, obj[name].bind(obj));\n  }\n}\n\n/**\n * Class to store current pointers used by the editor to be able to handle\n * multiple pointers (e.g. two fingers, a pen, a mouse, ...).\n */\nclass CurrentPointers {\n  // To manage the pointer events.\n\n  // The pointerId  and pointerIds are used to keep track of\n  // the pointers with a same type (e.g. two fingers).\n  static #pointerId = NaN;\n\n  static #pointerIds = null;\n\n  // Track the timestamp to know if the touchmove event is used.\n  static #moveTimestamp = NaN;\n\n  // The pointerType is used to know if we are using a mouse, a pen or a touch.\n  static #pointerType = null;\n\n  static initializeAndAddPointerId(pointerId) {\n    // Store pointer ids. For example, the user is using a second finger.\n    (CurrentPointers.#pointerIds ||= new Set()).add(pointerId);\n  }\n\n  static setPointer(pointerType, pointerId) {\n    CurrentPointers.#pointerId ||= pointerId;\n    CurrentPointers.#pointerType ??= pointerType;\n  }\n\n  static setTimeStamp(timeStamp) {\n    CurrentPointers.#moveTimestamp = timeStamp;\n  }\n\n  static isSamePointerId(pointerId) {\n    return CurrentPointers.#pointerId === pointerId;\n  }\n\n  // Check if it's the same pointer id, otherwise remove it from the set.\n  static isSamePointerIdOrRemove(pointerId) {\n    if (CurrentPointers.#pointerId === pointerId) {\n      return true;\n    }\n\n    CurrentPointers.#pointerIds?.delete(pointerId);\n    return false;\n  }\n\n  static isSamePointerType(pointerType) {\n    return CurrentPointers.#pointerType === pointerType;\n  }\n\n  static isInitializedAndDifferentPointerType(pointerType) {\n    return (\n      CurrentPointers.#pointerType !== null &&\n      !CurrentPointers.isSamePointerType(pointerType)\n    );\n  }\n\n  static isSameTimeStamp(timeStamp) {\n    return CurrentPointers.#moveTimestamp === timeStamp;\n  }\n\n  static isUsingMultiplePointers() {\n    // Check if the user is using multiple fingers\n    return CurrentPointers.#pointerIds?.size >= 1;\n  }\n\n  static clearPointerType() {\n    CurrentPointers.#pointerType = null;\n  }\n\n  static clearPointerIds() {\n    CurrentPointers.#pointerId = NaN;\n    CurrentPointers.#pointerIds = null;\n  }\n\n  static clearTimeStamp() {\n    CurrentPointers.#moveTimestamp = NaN;\n  }\n}\n\n/**\n * Class to create some unique ids for the different editors.\n */\nclass IdManager {\n  #id = 0;\n\n  constructor() {\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n      Object.defineProperty(this, \"reset\", {\n        value: () => (this.#id = 0),\n      });\n      Object.defineProperty(this, \"getNextId\", {\n        value: () => this.#id,\n      });\n    }\n  }\n\n  /**\n   * Get a unique id.\n   * @returns {string}\n   */\n  get id() {\n    return `${AnnotationEditorPrefix}${this.#id++}`;\n  }\n}\n\n/**\n * Class to manage the images used by the editors.\n * The main idea is to try to minimize the memory used by the images.\n * The images are cached and reused when possible\n * We use a refCounter to know when an image is not used anymore but we need to\n * be able to restore an image after a remove+undo, so we keep a file reference\n * or an url one.\n */\nclass ImageManager {\n  #baseId = getUuid();\n\n  #id = 0;\n\n  #cache = null;\n\n  static get _isSVGFittingCanvas() {\n    // By default, Firefox doesn't rescale without preserving the aspect ratio\n    // when drawing an SVG image on a canvas, see https://bugzilla.mozilla.org/1547776.\n    // The \"workaround\" is to append \"svgView(preserveAspectRatio(none))\" to the\n    // url, but according to comment #15, it seems that it leads to unexpected\n    // behavior in Safari.\n    const svg = `data:image/svg+xml;charset=UTF-8,<svg viewBox=\"0 0 1 1\" width=\"1\" height=\"1\" xmlns=\"http://www.w3.org/2000/svg\"><rect width=\"1\" height=\"1\" style=\"fill:red;\"/></svg>`;\n    const canvas = new OffscreenCanvas(1, 3);\n    const ctx = canvas.getContext(\"2d\", { willReadFrequently: true });\n    const image = new Image();\n    image.src = svg;\n    const promise = image.decode().then(() => {\n      ctx.drawImage(image, 0, 0, 1, 1, 0, 0, 1, 3);\n      return new Uint32Array(ctx.getImageData(0, 0, 1, 1).data.buffer)[0] === 0;\n    });\n\n    return shadow(this, \"_isSVGFittingCanvas\", promise);\n  }\n\n  async #get(key, rawData) {\n    this.#cache ||= new Map();\n    let data = this.#cache.get(key);\n    if (data === null) {\n      // We already tried to load the image but it failed.\n      return null;\n    }\n    if (data?.bitmap) {\n      data.refCounter += 1;\n      return data;\n    }\n    try {\n      data ||= {\n        bitmap: null,\n        id: `image_${this.#baseId}_${this.#id++}`,\n        refCounter: 0,\n        isSvg: false,\n      };\n      let image;\n      if (typeof rawData === \"string\") {\n        data.url = rawData;\n        image = await fetchData(rawData, \"blob\");\n      } else if (rawData instanceof File) {\n        image = data.file = rawData;\n      } else if (rawData instanceof Blob) {\n        image = rawData;\n      }\n\n      if (image.type === \"image/svg+xml\") {\n        // Unfortunately, createImageBitmap doesn't work with SVG images.\n        // (see https://bugzilla.mozilla.org/1841972).\n        const mustRemoveAspectRatioPromise = ImageManager._isSVGFittingCanvas;\n        const fileReader = new FileReader();\n        const imageElement = new Image();\n        const imagePromise = new Promise((resolve, reject) => {\n          imageElement.onload = () => {\n            data.bitmap = imageElement;\n            data.isSvg = true;\n            resolve();\n          };\n          fileReader.onload = async () => {\n            const url = (data.svgUrl = fileReader.result);\n            // We need to set the preserveAspectRatio to none in order to let\n            // the image fits the canvas when resizing.\n            imageElement.src = (await mustRemoveAspectRatioPromise)\n              ? `${url}#svgView(preserveAspectRatio(none))`\n              : url;\n          };\n          imageElement.onerror = fileReader.onerror = reject;\n        });\n        fileReader.readAsDataURL(image);\n        await imagePromise;\n      } else {\n        data.bitmap = await createImageBitmap(image);\n      }\n      data.refCounter = 1;\n    } catch (e) {\n      warn(e);\n      data = null;\n    }\n    this.#cache.set(key, data);\n    if (data) {\n      this.#cache.set(data.id, data);\n    }\n    return data;\n  }\n\n  async getFromFile(file) {\n    const { lastModified, name, size, type } = file;\n    return this.#get(`${lastModified}_${name}_${size}_${type}`, file);\n  }\n\n  async getFromUrl(url) {\n    return this.#get(url, url);\n  }\n\n  async getFromBlob(id, blobPromise) {\n    const blob = await blobPromise;\n    return this.#get(id, blob);\n  }\n\n  async getFromId(id) {\n    this.#cache ||= new Map();\n    const data = this.#cache.get(id);\n    if (!data) {\n      return null;\n    }\n    if (data.bitmap) {\n      data.refCounter += 1;\n      return data;\n    }\n\n    if (data.file) {\n      return this.getFromFile(data.file);\n    }\n    if (data.blobPromise) {\n      const { blobPromise } = data;\n      delete data.blobPromise;\n      return this.getFromBlob(data.id, blobPromise);\n    }\n    return this.getFromUrl(data.url);\n  }\n\n  getFromCanvas(id, canvas) {\n    this.#cache ||= new Map();\n    let data = this.#cache.get(id);\n    if (data?.bitmap) {\n      data.refCounter += 1;\n      return data;\n    }\n    const offscreen = new OffscreenCanvas(canvas.width, canvas.height);\n    const ctx = offscreen.getContext(\"2d\");\n    ctx.drawImage(canvas, 0, 0);\n    data = {\n      bitmap: offscreen.transferToImageBitmap(),\n      id: `image_${this.#baseId}_${this.#id++}`,\n      refCounter: 1,\n      isSvg: false,\n    };\n    this.#cache.set(id, data);\n    this.#cache.set(data.id, data);\n    return data;\n  }\n\n  getSvgUrl(id) {\n    const data = this.#cache.get(id);\n    if (!data?.isSvg) {\n      return null;\n    }\n    return data.svgUrl;\n  }\n\n  deleteId(id) {\n    this.#cache ||= new Map();\n    const data = this.#cache.get(id);\n    if (!data) {\n      return;\n    }\n    data.refCounter -= 1;\n    if (data.refCounter !== 0) {\n      return;\n    }\n    const { bitmap } = data;\n    if (!data.url && !data.file) {\n      // The image has no way to be restored (ctrl+z) so we must fix that.\n      const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);\n      const ctx = canvas.getContext(\"bitmaprenderer\");\n      ctx.transferFromImageBitmap(bitmap);\n      data.blobPromise = canvas.convertToBlob();\n    }\n\n    bitmap.close?.();\n    data.bitmap = null;\n  }\n\n  // We can use the id only if it belongs this manager.\n  // We must take care of having the right manager because we can copy/paste\n  // some images from other documents, hence it'd be a pity to use an id from an\n  // other manager.\n  isValidId(id) {\n    return id.startsWith(`image_${this.#baseId}_`);\n  }\n}\n\n/**\n * Class to handle undo/redo.\n * Commands are just saved in a buffer.\n * If we hit some memory issues we could likely use a circular buffer.\n * It has to be used as a singleton.\n */\nclass CommandManager {\n  #commands = [];\n\n  #locked = false;\n\n  #maxSize;\n\n  #position = -1;\n\n  constructor(maxSize = 128) {\n    this.#maxSize = maxSize;\n  }\n\n  /**\n   * @typedef {Object} addOptions\n   * @property {function} cmd\n   * @property {function} undo\n   * @property {function} [post]\n   * @property {boolean} mustExec\n   * @property {number} type\n   * @property {boolean} overwriteIfSameType\n   * @property {boolean} keepUndo\n   */\n\n  /**\n   * Add a new couple of commands to be used in case of redo/undo.\n   * @param {addOptions} options\n   */\n  add({\n    cmd,\n    undo,\n    post,\n    mustExec,\n    type = NaN,\n    overwriteIfSameType = false,\n    keepUndo = false,\n  }) {\n    if (mustExec) {\n      cmd();\n    }\n\n    if (this.#locked) {\n      return;\n    }\n\n    const save = { cmd, undo, post, type };\n    if (this.#position === -1) {\n      if (this.#commands.length > 0) {\n        // All the commands have been undone and then a new one is added\n        // hence we clear the queue.\n        this.#commands.length = 0;\n      }\n      this.#position = 0;\n      this.#commands.push(save);\n      return;\n    }\n\n    if (overwriteIfSameType && this.#commands[this.#position].type === type) {\n      // For example when we change a color we don't want to\n      // be able to undo all the steps, hence we only want to\n      // keep the last undoable action in this sequence of actions.\n      if (keepUndo) {\n        save.undo = this.#commands[this.#position].undo;\n      }\n      this.#commands[this.#position] = save;\n      return;\n    }\n\n    const next = this.#position + 1;\n    if (next === this.#maxSize) {\n      this.#commands.splice(0, 1);\n    } else {\n      this.#position = next;\n      if (next < this.#commands.length) {\n        this.#commands.splice(next);\n      }\n    }\n\n    this.#commands.push(save);\n  }\n\n  /**\n   * Undo the last command.\n   */\n  undo() {\n    if (this.#position === -1) {\n      // Nothing to undo.\n      return;\n    }\n\n    // Avoid to insert something during the undo execution.\n    this.#locked = true;\n    const { undo, post } = this.#commands[this.#position];\n    undo();\n    post?.();\n    this.#locked = false;\n\n    this.#position -= 1;\n  }\n\n  /**\n   * Redo the last command.\n   */\n  redo() {\n    if (this.#position < this.#commands.length - 1) {\n      this.#position += 1;\n\n      // Avoid to insert something during the redo execution.\n      this.#locked = true;\n      const { cmd, post } = this.#commands[this.#position];\n      cmd();\n      post?.();\n      this.#locked = false;\n    }\n  }\n\n  /**\n   * Check if there is something to undo.\n   * @returns {boolean}\n   */\n  hasSomethingToUndo() {\n    return this.#position !== -1;\n  }\n\n  /**\n   * Check if there is something to redo.\n   * @returns {boolean}\n   */\n  hasSomethingToRedo() {\n    return this.#position < this.#commands.length - 1;\n  }\n\n  cleanType(type) {\n    if (this.#position === -1) {\n      return;\n    }\n    for (let i = this.#position; i >= 0; i--) {\n      if (this.#commands[i].type !== type) {\n        this.#commands.splice(i + 1, this.#position - i);\n        this.#position = i;\n        return;\n      }\n    }\n    this.#commands.length = 0;\n    this.#position = -1;\n  }\n\n  destroy() {\n    this.#commands = null;\n  }\n}\n\n/**\n * Class to handle the different keyboards shortcuts we can have on mac or\n * non-mac OSes.\n */\nclass KeyboardManager {\n  /**\n   * Create a new keyboard manager class.\n   * @param {Array<Array>} callbacks - an array containing an array of shortcuts\n   * and a callback to call.\n   * A shortcut is a string like `ctrl+c` or `mac+ctrl+c` for mac OS.\n   */\n  constructor(callbacks) {\n    this.buffer = [];\n    this.callbacks = new Map();\n    this.allKeys = new Set();\n\n    const { isMac } = FeatureTest.platform;\n    for (const [keys, callback, options = {}] of callbacks) {\n      for (const key of keys) {\n        const isMacKey = key.startsWith(\"mac+\");\n        if (isMac && isMacKey) {\n          this.callbacks.set(key.slice(4), { callback, options });\n          this.allKeys.add(key.split(\"+\").at(-1));\n        } else if (!isMac && !isMacKey) {\n          this.callbacks.set(key, { callback, options });\n          this.allKeys.add(key.split(\"+\").at(-1));\n        }\n      }\n    }\n  }\n\n  /**\n   * Serialize an event into a string in order to match a\n   * potential key for a callback.\n   * @param {KeyboardEvent} event\n   * @returns {string}\n   */\n  #serialize(event) {\n    if (event.altKey) {\n      this.buffer.push(\"alt\");\n    }\n    if (event.ctrlKey) {\n      this.buffer.push(\"ctrl\");\n    }\n    if (event.metaKey) {\n      this.buffer.push(\"meta\");\n    }\n    if (event.shiftKey) {\n      this.buffer.push(\"shift\");\n    }\n    this.buffer.push(event.key);\n    const str = this.buffer.join(\"+\");\n    this.buffer.length = 0;\n\n    return str;\n  }\n\n  /**\n   * Execute a callback, if any, for a given keyboard event.\n   * The self is used as `this` in the callback.\n   * @param {Object} self\n   * @param {KeyboardEvent} event\n   * @returns\n   */\n  exec(self, event) {\n    if (!this.allKeys.has(event.key)) {\n      return;\n    }\n    const info = this.callbacks.get(this.#serialize(event));\n    if (!info) {\n      return;\n    }\n    const {\n      callback,\n      options: { bubbles = false, args = [], checker = null },\n    } = info;\n\n    if (checker && !checker(self, event)) {\n      return;\n    }\n    callback.bind(self, ...args, event)();\n\n    // For example, ctrl+s in a FreeText must be handled by the viewer, hence\n    // the event must bubble.\n    if (!bubbles) {\n      stopEvent(event);\n    }\n  }\n}\n\nclass ColorManager {\n  static _colorsMapping = new Map([\n    [\"CanvasText\", [0, 0, 0]],\n    [\"Canvas\", [255, 255, 255]],\n  ]);\n\n  get _colors() {\n    if (\n      typeof PDFJSDev !== \"undefined\" &&\n      PDFJSDev.test(\"LIB\") &&\n      typeof document === \"undefined\"\n    ) {\n      return shadow(this, \"_colors\", ColorManager._colorsMapping);\n    }\n\n    const colors = new Map([\n      [\"CanvasText\", null],\n      [\"Canvas\", null],\n    ]);\n    getColorValues(colors);\n    return shadow(this, \"_colors\", colors);\n  }\n\n  /**\n   * In High Contrast Mode, the color on the screen is not always the\n   * real color used in the pdf.\n   * For example in some cases white can appear to be black but when saving\n   * we want to have white.\n   * @param {string} color\n   * @returns {Array<number>}\n   */\n  convert(color) {\n    const rgb = getRGB(color);\n    if (!window.matchMedia(\"(forced-colors: active)\").matches) {\n      return rgb;\n    }\n\n    for (const [name, RGB] of this._colors) {\n      if (RGB.every((x, i) => x === rgb[i])) {\n        return ColorManager._colorsMapping.get(name);\n      }\n    }\n    return rgb;\n  }\n\n  /**\n   * An input element must have its color value as a hex string\n   * and not as color name.\n   * So this function converts a name into an hex string.\n   * @param {string} name\n   * @returns {string}\n   */\n  getHexCode(name) {\n    const rgb = this._colors.get(name);\n    if (!rgb) {\n      return name;\n    }\n    return Util.makeHexColor(...rgb);\n  }\n}\n\n/**\n * A pdf has several pages and each of them when it will rendered\n * will have an AnnotationEditorLayer which will contain the some\n * new Annotations associated to an editor in order to modify them.\n *\n * This class is used to manage all the different layers, editors and\n * some action like copy/paste, undo/redo, ...\n */\nclass AnnotationEditorUIManager {\n  #abortController = new AbortController();\n\n  #activeEditor = null;\n\n  #allEditableAnnotations = null;\n\n  #allEditors = new Map();\n\n  #allLayers = new Map();\n\n  #altTextManager = null;\n\n  #annotationStorage = null;\n\n  #changedExistingAnnotations = null;\n\n  #commandManager = new CommandManager();\n\n  #commentManager = null;\n\n  #copyPasteAC = null;\n\n  #currentDrawingSession = null;\n\n  #currentPageIndex = 0;\n\n  #deletedAnnotationsElementIds = new Set();\n\n  #draggingEditors = null;\n\n  #editorTypes = null;\n\n  #editorsToRescale = new Set();\n\n  _editorUndoBar = null;\n\n  #enableHighlightFloatingButton = false;\n\n  #enableUpdatedAddImage = false;\n\n  #enableNewAltTextWhenAddingImage = false;\n\n  #filterFactory = null;\n\n  #focusMainContainerTimeoutId = null;\n\n  #focusManagerAC = null;\n\n  #highlightColors = null;\n\n  #highlightWhenShiftUp = false;\n\n  #floatingToolbar = null;\n\n  #idManager = new IdManager();\n\n  #isEnabled = false;\n\n  #isPointerDown = false;\n\n  #isWaiting = false;\n\n  #keyboardManagerAC = null;\n\n  #lastActiveElement = null;\n\n  #mainHighlightColorPicker = null;\n\n  #missingCanvases = null;\n\n  #mlManager = null;\n\n  #mode = AnnotationEditorType.NONE;\n\n  #selectedEditors = new Set();\n\n  #selectedTextNode = null;\n\n  #signatureManager = null;\n\n  #pageColors = null;\n\n  #showAllStates = null;\n\n  #pdfDocument = null;\n\n  #previousStates = {\n    isEditing: false,\n    isEmpty: true,\n    hasSomethingToUndo: false,\n    hasSomethingToRedo: false,\n    hasSelectedEditor: false,\n    hasSelectedText: false,\n  };\n\n  #translation = [0, 0];\n\n  #translationTimeoutId = null;\n\n  #container = null;\n\n  #viewer = null;\n\n  #viewerAlert = null;\n\n  #updateModeCapability = null;\n\n  static TRANSLATE_SMALL = 1; // page units.\n\n  static TRANSLATE_BIG = 10; // page units.\n\n  static get _keyboardManager() {\n    const proto = AnnotationEditorUIManager.prototype;\n\n    /**\n     * If the focused element is an input, we don't want to handle the arrow.\n     * For example, sliders can be controlled with the arrow keys.\n     */\n    const arrowChecker = self =>\n      self.#container.contains(document.activeElement) &&\n      document.activeElement.tagName !== \"BUTTON\" &&\n      self.hasSomethingToControl();\n\n    const textInputChecker = (_self, { target: el }) => {\n      if (el instanceof HTMLInputElement) {\n        const { type } = el;\n        return type !== \"text\" && type !== \"number\";\n      }\n      return true;\n    };\n\n    const small = this.TRANSLATE_SMALL;\n    const big = this.TRANSLATE_BIG;\n\n    return shadow(\n      this,\n      \"_keyboardManager\",\n      new KeyboardManager([\n        [\n          [\"ctrl+a\", \"mac+meta+a\"],\n          proto.selectAll,\n          { checker: textInputChecker },\n        ],\n        [[\"ctrl+z\", \"mac+meta+z\"], proto.undo, { checker: textInputChecker }],\n        [\n          // On mac, depending of the OS version, the event.key is either \"z\" or\n          // \"Z\" when the user presses \"meta+shift+z\".\n          [\n            \"ctrl+y\",\n            \"ctrl+shift+z\",\n            \"mac+meta+shift+z\",\n            \"ctrl+shift+Z\",\n            \"mac+meta+shift+Z\",\n          ],\n          proto.redo,\n          { checker: textInputChecker },\n        ],\n        [\n          [\n            \"Backspace\",\n            \"alt+Backspace\",\n            \"ctrl+Backspace\",\n            \"shift+Backspace\",\n            \"mac+Backspace\",\n            \"mac+alt+Backspace\",\n            \"mac+ctrl+Backspace\",\n            \"Delete\",\n            \"ctrl+Delete\",\n            \"shift+Delete\",\n            \"mac+Delete\",\n          ],\n          proto.delete,\n          { checker: textInputChecker },\n        ],\n        [\n          [\"Enter\", \"mac+Enter\"],\n          proto.addNewEditorFromKeyboard,\n          {\n            // Those shortcuts can be used in the toolbar for some other actions\n            // like zooming, hence we need to check if the container has the\n            // focus.\n            checker: (self, { target: el }) =>\n              !(el instanceof HTMLButtonElement) &&\n              self.#container.contains(el) &&\n              !self.isEnterHandled,\n          },\n        ],\n        [\n          [\" \", \"mac+ \"],\n          proto.addNewEditorFromKeyboard,\n          {\n            // Those shortcuts can be used in the toolbar for some other actions\n            // like zooming, hence we need to check if the container has the\n            // focus.\n            checker: (self, { target: el }) =>\n              !(el instanceof HTMLButtonElement) &&\n              self.#container.contains(document.activeElement),\n          },\n        ],\n        [[\"Escape\", \"mac+Escape\"], proto.unselectAll],\n        [\n          [\"ArrowLeft\", \"mac+ArrowLeft\"],\n          proto.translateSelectedEditors,\n          { args: [-small, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowLeft\", \"mac+shift+ArrowLeft\"],\n          proto.translateSelectedEditors,\n          { args: [-big, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ArrowRight\", \"mac+ArrowRight\"],\n          proto.translateSelectedEditors,\n          { args: [small, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowRight\", \"mac+shift+ArrowRight\"],\n          proto.translateSelectedEditors,\n          { args: [big, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ArrowUp\", \"mac+ArrowUp\"],\n          proto.translateSelectedEditors,\n          { args: [0, -small], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowUp\", \"mac+shift+ArrowUp\"],\n          proto.translateSelectedEditors,\n          { args: [0, -big], checker: arrowChecker },\n        ],\n        [\n          [\"ArrowDown\", \"mac+ArrowDown\"],\n          proto.translateSelectedEditors,\n          { args: [0, small], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowDown\", \"mac+shift+ArrowDown\"],\n          proto.translateSelectedEditors,\n          { args: [0, big], checker: arrowChecker },\n        ],\n      ])\n    );\n  }\n\n  constructor(\n    container,\n    viewer,\n    viewerAlert,\n    altTextManager,\n    commentManager,\n    signatureManager,\n    eventBus,\n    pdfDocument,\n    pageColors,\n    highlightColors,\n    enableHighlightFloatingButton,\n    enableUpdatedAddImage,\n    enableNewAltTextWhenAddingImage,\n    mlManager,\n    editorUndoBar,\n    supportsPinchToZoom\n  ) {\n    const signal = (this._signal = this.#abortController.signal);\n    this.#container = container;\n    this.#viewer = viewer;\n    this.#viewerAlert = viewerAlert;\n    this.#altTextManager = altTextManager;\n    this.#commentManager = commentManager;\n    this.#signatureManager = signatureManager;\n    this.#pdfDocument = pdfDocument;\n    this._eventBus = eventBus;\n    eventBus._on(\"editingaction\", this.onEditingAction.bind(this), { signal });\n    eventBus._on(\"pagechanging\", this.onPageChanging.bind(this), { signal });\n    eventBus._on(\"scalechanging\", this.onScaleChanging.bind(this), { signal });\n    eventBus._on(\"rotationchanging\", this.onRotationChanging.bind(this), {\n      signal,\n    });\n    eventBus._on(\"setpreference\", this.onSetPreference.bind(this), { signal });\n    eventBus._on(\n      \"switchannotationeditorparams\",\n      evt => this.updateParams(evt.type, evt.value),\n      { signal }\n    );\n    window.addEventListener(\n      \"pointerdown\",\n      () => {\n        this.#isPointerDown = true;\n      },\n      { capture: true, signal }\n    );\n    window.addEventListener(\n      \"pointerup\",\n      () => {\n        this.#isPointerDown = false;\n      },\n      { capture: true, signal }\n    );\n    window.addEventListener(\"beforeunload\", this.#beforeUnload.bind(this), {\n      capture: true,\n      signal,\n    });\n    this.#addSelectionListener();\n    this.#addDragAndDropListeners();\n    this.#addKeyboardManager();\n    this.#annotationStorage = pdfDocument.annotationStorage;\n    this.#filterFactory = pdfDocument.filterFactory;\n    this.#pageColors = pageColors;\n    this.#highlightColors = highlightColors || null;\n    this.#enableHighlightFloatingButton = enableHighlightFloatingButton;\n    this.#enableUpdatedAddImage = enableUpdatedAddImage;\n    this.#enableNewAltTextWhenAddingImage = enableNewAltTextWhenAddingImage;\n    this.#mlManager = mlManager || null;\n    this.viewParameters = {\n      realScale: PixelsPerInch.PDF_TO_CSS_UNITS,\n      rotation: 0,\n    };\n    this.isShiftKeyDown = false;\n    this._editorUndoBar = editorUndoBar || null;\n    this._supportsPinchToZoom = supportsPinchToZoom !== false;\n    commentManager?.setSidebarUiManager(this);\n\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n      Object.defineProperty(this, \"reset\", {\n        value: () => {\n          this.selectAll();\n          this.delete();\n          this.#idManager.reset();\n        },\n      });\n      Object.defineProperty(this, \"getNextEditorId\", {\n        value: () => this.#idManager.getNextId(),\n      });\n    }\n  }\n\n  destroy() {\n    this.#updateModeCapability?.resolve();\n    this.#updateModeCapability = null;\n\n    this.#abortController?.abort();\n    this.#abortController = null;\n    this._signal = null;\n\n    for (const layer of this.#allLayers.values()) {\n      layer.destroy();\n    }\n    this.#allLayers.clear();\n    this.#allEditors.clear();\n    this.#editorsToRescale.clear();\n    this.#missingCanvases?.clear();\n    this.#activeEditor = null;\n    this.#selectedEditors.clear();\n    this.#commandManager.destroy();\n    this.#altTextManager?.destroy();\n    this.#commentManager?.destroy();\n    this.#signatureManager?.destroy();\n    this.#floatingToolbar?.hide();\n    this.#floatingToolbar = null;\n    this.#mainHighlightColorPicker?.destroy();\n    this.#mainHighlightColorPicker = null;\n    this.#allEditableAnnotations = null;\n    if (this.#focusMainContainerTimeoutId) {\n      clearTimeout(this.#focusMainContainerTimeoutId);\n      this.#focusMainContainerTimeoutId = null;\n    }\n    if (this.#translationTimeoutId) {\n      clearTimeout(this.#translationTimeoutId);\n      this.#translationTimeoutId = null;\n    }\n    this._editorUndoBar?.destroy();\n    this.#pdfDocument = null;\n  }\n\n  combinedSignal(ac) {\n    return AbortSignal.any([this._signal, ac.signal]);\n  }\n\n  get mlManager() {\n    return this.#mlManager;\n  }\n\n  get useNewAltTextFlow() {\n    return this.#enableUpdatedAddImage;\n  }\n\n  get useNewAltTextWhenAddingImage() {\n    return this.#enableNewAltTextWhenAddingImage;\n  }\n\n  get hcmFilter() {\n    return shadow(\n      this,\n      \"hcmFilter\",\n      this.#pageColors\n        ? this.#filterFactory.addHCMFilter(\n            this.#pageColors.foreground,\n            this.#pageColors.background\n          )\n        : \"none\"\n    );\n  }\n\n  get direction() {\n    return shadow(\n      this,\n      \"direction\",\n      getComputedStyle(this.#container).direction\n    );\n  }\n\n  get _highlightColors() {\n    return shadow(\n      this,\n      \"_highlightColors\",\n      this.#highlightColors\n        ? new Map(\n            this.#highlightColors.split(\",\").map(pair => {\n              pair = pair.split(\"=\").map(x => x.trim());\n              pair[1] = pair[1].toUpperCase();\n              return pair;\n            })\n          )\n        : null\n    );\n  }\n\n  get highlightColors() {\n    const { _highlightColors } = this;\n    if (!_highlightColors) {\n      return shadow(this, \"highlightColors\", null);\n    }\n    const map = new Map();\n    const hasHCM = !!this.#pageColors;\n    for (const [name, color] of _highlightColors) {\n      const isNameForHCM = name.endsWith(\"_HCM\");\n      if (hasHCM && isNameForHCM) {\n        map.set(name.replace(\"_HCM\", \"\"), color);\n        continue;\n      }\n      if (!hasHCM && !isNameForHCM) {\n        map.set(name, color);\n      }\n    }\n    return shadow(this, \"highlightColors\", map);\n  }\n\n  get highlightColorNames() {\n    return shadow(\n      this,\n      \"highlightColorNames\",\n      this.highlightColors\n        ? new Map(Array.from(this.highlightColors, e => e.reverse()))\n        : null\n    );\n  }\n\n  getNonHCMColor(color) {\n    if (!this._highlightColors) {\n      return color;\n    }\n    const colorName = this.highlightColorNames.get(color);\n    return this._highlightColors.get(colorName) || color;\n  }\n\n  getNonHCMColorName(color) {\n    return this.highlightColorNames.get(color) || color;\n  }\n\n  /**\n   * Set the current drawing session.\n   * @param {AnnotationEditorLayer} layer\n   */\n  setCurrentDrawingSession(layer) {\n    if (layer) {\n      this.unselectAll();\n      this.disableUserSelect(true);\n    } else {\n      this.disableUserSelect(false);\n    }\n    this.#currentDrawingSession = layer;\n  }\n\n  setMainHighlightColorPicker(colorPicker) {\n    this.#mainHighlightColorPicker = colorPicker;\n  }\n\n  editAltText(editor, firstTime = false) {\n    this.#altTextManager?.editAltText(this, editor, firstTime);\n  }\n\n  hasCommentManager() {\n    return !!this.#commentManager;\n  }\n\n  editComment(editor, posX, posY, options) {\n    this.#commentManager?.showDialog(this, editor, posX, posY, options);\n  }\n\n  selectComment(pageIndex, uid) {\n    const layer = this.#allLayers.get(pageIndex);\n    const editor = layer?.getEditorByUID(uid);\n    editor?.toggleComment(/* isSelected */ true, /* visibility */ true);\n  }\n\n  updateComment(editor) {\n    this.#commentManager?.updateComment(editor.getData());\n  }\n\n  updatePopupColor(editor) {\n    this.#commentManager?.updatePopupColor(editor);\n  }\n\n  removeComment(editor) {\n    this.#commentManager?.removeComments([editor.uid]);\n  }\n\n  /**\n   * Delete a comment from an editor with undo support.\n   * @param {AnnotationEditor} editor - The editor whose comment to delete.\n   * @param {Object} savedData - The comment data to save for undo.\n   */\n  deleteComment(editor, savedData) {\n    const undo = () => {\n      editor.comment = savedData;\n    };\n    const cmd = () => {\n      this._editorUndoBar?.show(undo, \"comment\");\n      this.toggleComment(/* editor = */ null);\n      editor.comment = null;\n    };\n    this.addCommands({ cmd, undo, mustExec: true });\n  }\n\n  toggleComment(editor, isSelected, visibility = undefined) {\n    this.#commentManager?.toggleCommentPopup(editor, isSelected, visibility);\n  }\n\n  makeCommentColor(color, opacity) {\n    return (\n      (color && this.#commentManager?.makeCommentColor(color, opacity)) || null\n    );\n  }\n\n  getCommentDialogElement() {\n    return this.#commentManager?.dialogElement || null;\n  }\n\n  async waitForEditorsRendered(pageNumber) {\n    if (this.#allLayers.has(pageNumber - 1)) {\n      return;\n    }\n    const { resolve, promise } = Promise.withResolvers();\n    const onEditorsRendered = evt => {\n      if (evt.pageNumber === pageNumber) {\n        this._eventBus._off(\"editorsrendered\", onEditorsRendered);\n        resolve();\n      }\n    };\n    this._eventBus.on(\"editorsrendered\", onEditorsRendered);\n    await promise;\n  }\n\n  getSignature(editor) {\n    this.#signatureManager?.getSignature({ uiManager: this, editor });\n  }\n\n  get signatureManager() {\n    return this.#signatureManager;\n  }\n\n  switchToMode(mode, callback) {\n    // Switching to a mode can be asynchronous.\n    this._eventBus.on(\"annotationeditormodechanged\", callback, {\n      once: true,\n      signal: this._signal,\n    });\n    this._eventBus.dispatch(\"showannotationeditorui\", {\n      source: this,\n      mode,\n    });\n  }\n\n  setPreference(name, value) {\n    this._eventBus.dispatch(\"setpreference\", {\n      source: this,\n      name,\n      value,\n    });\n  }\n\n  onSetPreference({ name, value }) {\n    switch (name) {\n      case \"enableNewAltTextWhenAddingImage\":\n        this.#enableNewAltTextWhenAddingImage = value;\n        break;\n    }\n  }\n\n  onPageChanging({ pageNumber }) {\n    this.#currentPageIndex = pageNumber - 1;\n  }\n\n  deletePage(id) {\n    for (const editor of this.getEditors(id)) {\n      editor.remove();\n    }\n    this.#allLayers.delete(id);\n    if (this.#currentPageIndex === id) {\n      this.#currentPageIndex = 0;\n    }\n  }\n\n  focusMainContainer() {\n    this.#container.focus();\n  }\n\n  findParent(x, y) {\n    for (const layer of this.#allLayers.values()) {\n      const {\n        x: layerX,\n        y: layerY,\n        width,\n        height,\n      } = layer.div.getBoundingClientRect();\n      if (\n        x >= layerX &&\n        x <= layerX + width &&\n        y >= layerY &&\n        y <= layerY + height\n      ) {\n        return layer;\n      }\n    }\n    return null;\n  }\n\n  disableUserSelect(value = false) {\n    this.#viewer.classList.toggle(\"noUserSelect\", value);\n  }\n\n  addShouldRescale(editor) {\n    this.#editorsToRescale.add(editor);\n  }\n\n  removeShouldRescale(editor) {\n    this.#editorsToRescale.delete(editor);\n  }\n\n  onScaleChanging({ scale }) {\n    this.commitOrRemove();\n    this.viewParameters.realScale = scale * PixelsPerInch.PDF_TO_CSS_UNITS;\n    for (const editor of this.#editorsToRescale) {\n      editor.onScaleChanging();\n    }\n    this.#currentDrawingSession?.onScaleChanging();\n  }\n\n  onRotationChanging({ pagesRotation }) {\n    this.commitOrRemove();\n    this.viewParameters.rotation = pagesRotation;\n  }\n\n  #getAnchorElementForSelection({ anchorNode }) {\n    return anchorNode.nodeType === Node.TEXT_NODE\n      ? anchorNode.parentElement\n      : anchorNode;\n  }\n\n  #getLayerForTextLayer(textLayer) {\n    const { currentLayer } = this;\n    if (currentLayer.hasTextLayer(textLayer)) {\n      return currentLayer;\n    }\n    for (const layer of this.#allLayers.values()) {\n      if (layer.hasTextLayer(textLayer)) {\n        return layer;\n      }\n    }\n    return null;\n  }\n\n  highlightSelection(methodOfCreation = \"\", comment = false) {\n    const selection = document.getSelection();\n    if (!selection || selection.isCollapsed) {\n      return;\n    }\n    const { anchorNode, anchorOffset, focusNode, focusOffset } = selection;\n    const text = selection.toString();\n    const anchorElement = this.#getAnchorElementForSelection(selection);\n    const textLayer = anchorElement.closest(\".textLayer\");\n    const boxes = this.getSelectionBoxes(textLayer);\n    if (!boxes) {\n      return;\n    }\n    selection.empty();\n\n    const layer = this.#getLayerForTextLayer(textLayer);\n    const isNoneMode = this.#mode === AnnotationEditorType.NONE;\n    const callback = () => {\n      const editor = layer?.createAndAddNewEditor({ x: 0, y: 0 }, false, {\n        methodOfCreation,\n        boxes,\n        anchorNode,\n        anchorOffset,\n        focusNode,\n        focusOffset,\n        text,\n      });\n      if (isNoneMode) {\n        this.showAllEditors(\"highlight\", true, /* updateButton = */ true);\n      }\n      if (comment) {\n        editor?.editComment();\n      }\n    };\n    if (isNoneMode) {\n      this.switchToMode(AnnotationEditorType.HIGHLIGHT, callback);\n      return;\n    }\n    callback();\n  }\n\n  commentSelection(methodOfCreation = \"\") {\n    this.highlightSelection(methodOfCreation, /* comment */ true);\n  }\n\n  #beforeUnload(e) {\n    this.commitOrRemove();\n    this.currentLayer?.endDrawingSession(/* isAborted = */ false);\n  }\n\n  #displayFloatingToolbar() {\n    const selection = document.getSelection();\n    if (!selection || selection.isCollapsed) {\n      return;\n    }\n    const anchorElement = this.#getAnchorElementForSelection(selection);\n    const textLayer = anchorElement.closest(\".textLayer\");\n    const boxes = this.getSelectionBoxes(textLayer);\n    if (!boxes) {\n      return;\n    }\n    this.#floatingToolbar ||= new FloatingToolbar(this);\n    this.#floatingToolbar.show(textLayer, boxes, this.direction === \"ltr\");\n  }\n\n  /**\n   * Some annotations may have been modified in the annotation layer\n   * (e.g. comments added or modified).\n   * So this function retrieves the data from the storage and removes\n   * them from the storage in order to be able to save them later.\n   * @param {string} annotationId\n   * @returns {Object|null} The data associated to the annotation or null.\n   */\n  getAndRemoveDataFromAnnotationStorage(annotationId) {\n    if (!this.#annotationStorage) {\n      return null;\n    }\n    const key = `${AnnotationEditorPrefix}${annotationId}`;\n    const storedValue = this.#annotationStorage.getRawValue(key);\n    if (storedValue) {\n      this.#annotationStorage.remove(key);\n    }\n    return storedValue;\n  }\n\n  /**\n   * Add an editor in the annotation storage.\n   * @param {AnnotationEditor} editor\n   */\n  addToAnnotationStorage(editor) {\n    if (\n      !editor.isEmpty() &&\n      this.#annotationStorage &&\n      !this.#annotationStorage.has(editor.id)\n    ) {\n      this.#annotationStorage.setValue(editor.id, editor);\n    }\n  }\n\n  a11yAlert(messageId, args = null) {\n    const viewerAlert = this.#viewerAlert;\n    if (!viewerAlert) {\n      return;\n    }\n    viewerAlert.setAttribute(\"data-l10n-id\", messageId);\n    if (args) {\n      viewerAlert.setAttribute(\"data-l10n-args\", JSON.stringify(args));\n    } else {\n      viewerAlert.removeAttribute(\"data-l10n-args\");\n    }\n  }\n\n  #selectionChange() {\n    const selection = document.getSelection();\n    if (!selection || selection.isCollapsed) {\n      if (this.#selectedTextNode) {\n        this.#floatingToolbar?.hide();\n        this.#selectedTextNode = null;\n        this.#dispatchUpdateStates({\n          hasSelectedText: false,\n        });\n      }\n      return;\n    }\n    const { anchorNode } = selection;\n    if (anchorNode === this.#selectedTextNode) {\n      return;\n    }\n\n    const anchorElement = this.#getAnchorElementForSelection(selection);\n    const textLayer = anchorElement.closest(\".textLayer\");\n    if (!textLayer) {\n      if (this.#selectedTextNode) {\n        this.#floatingToolbar?.hide();\n        this.#selectedTextNode = null;\n        this.#dispatchUpdateStates({\n          hasSelectedText: false,\n        });\n      }\n      return;\n    }\n\n    this.#floatingToolbar?.hide();\n    this.#selectedTextNode = anchorNode;\n    this.#dispatchUpdateStates({\n      hasSelectedText: true,\n    });\n\n    if (\n      this.#mode !== AnnotationEditorType.HIGHLIGHT &&\n      this.#mode !== AnnotationEditorType.NONE\n    ) {\n      return;\n    }\n\n    if (this.#mode === AnnotationEditorType.HIGHLIGHT) {\n      this.showAllEditors(\"highlight\", true, /* updateButton = */ true);\n    }\n\n    this.#highlightWhenShiftUp = this.isShiftKeyDown;\n    if (!this.isShiftKeyDown) {\n      const activeLayer =\n        this.#mode === AnnotationEditorType.HIGHLIGHT\n          ? this.#getLayerForTextLayer(textLayer)\n          : null;\n      activeLayer?.toggleDrawing();\n\n      if (this.#isPointerDown) {\n        const ac = new AbortController();\n        const signal = this.combinedSignal(ac);\n\n        const pointerup = e => {\n          if (e.type === \"pointerup\" && e.button !== 0) {\n            // Do nothing on right click.\n            return;\n          }\n          ac.abort();\n          activeLayer?.toggleDrawing(true);\n          if (e.type === \"pointerup\") {\n            this.#onSelectEnd(\"main_toolbar\");\n          }\n        };\n        window.addEventListener(\"pointerup\", pointerup, { signal });\n        window.addEventListener(\"blur\", pointerup, { signal });\n      } else {\n        // Here neither the shift key nor the pointer is down and we've\n        // something in the selection: we can be in the case where the user is\n        // using a screen reader (see bug 1976597).\n        activeLayer?.toggleDrawing(true);\n        this.#onSelectEnd(\"main_toolbar\");\n      }\n    }\n  }\n\n  #onSelectEnd(methodOfCreation = \"\") {\n    if (this.#mode === AnnotationEditorType.HIGHLIGHT) {\n      this.highlightSelection(methodOfCreation);\n    } else if (this.#enableHighlightFloatingButton) {\n      this.#displayFloatingToolbar();\n    }\n  }\n\n  #addSelectionListener() {\n    document.addEventListener(\n      \"selectionchange\",\n      this.#selectionChange.bind(this),\n      { signal: this._signal }\n    );\n  }\n\n  #addFocusManager() {\n    if (this.#focusManagerAC) {\n      return;\n    }\n    this.#focusManagerAC = new AbortController();\n    const signal = this.combinedSignal(this.#focusManagerAC);\n\n    window.addEventListener(\"focus\", this.focus.bind(this), { signal });\n    window.addEventListener(\"blur\", this.blur.bind(this), { signal });\n  }\n\n  #removeFocusManager() {\n    this.#focusManagerAC?.abort();\n    this.#focusManagerAC = null;\n  }\n\n  blur() {\n    this.isShiftKeyDown = false;\n    if (this.#highlightWhenShiftUp) {\n      this.#highlightWhenShiftUp = false;\n      this.#onSelectEnd(\"main_toolbar\");\n    }\n    if (!this.hasSelection) {\n      return;\n    }\n    // When several editors are selected and the window loses focus, we want to\n    // keep the last active element in order to be able to focus it again when\n    // the window gets the focus back but we don't want to trigger any focus\n    // callbacks else only one editor will be selected.\n    const { activeElement } = document;\n    for (const editor of this.#selectedEditors) {\n      if (editor.div.contains(activeElement)) {\n        this.#lastActiveElement = [editor, activeElement];\n        editor._focusEventsAllowed = false;\n        break;\n      }\n    }\n  }\n\n  focus() {\n    if (!this.#lastActiveElement) {\n      return;\n    }\n    const [lastEditor, lastActiveElement] = this.#lastActiveElement;\n    this.#lastActiveElement = null;\n    lastActiveElement.addEventListener(\n      \"focusin\",\n      () => {\n        lastEditor._focusEventsAllowed = true;\n      },\n      { once: true, signal: this._signal }\n    );\n    lastActiveElement.focus();\n  }\n\n  #addKeyboardManager() {\n    if (this.#keyboardManagerAC) {\n      return;\n    }\n    this.#keyboardManagerAC = new AbortController();\n    const signal = this.combinedSignal(this.#keyboardManagerAC);\n\n    // The keyboard events are caught at the container level in order to be able\n    // to execute some callbacks even if the current page doesn't have focus.\n    window.addEventListener(\"keydown\", this.keydown.bind(this), { signal });\n    window.addEventListener(\"keyup\", this.keyup.bind(this), { signal });\n  }\n\n  #removeKeyboardManager() {\n    this.#keyboardManagerAC?.abort();\n    this.#keyboardManagerAC = null;\n  }\n\n  #addCopyPasteListeners() {\n    if (this.#copyPasteAC) {\n      return;\n    }\n    this.#copyPasteAC = new AbortController();\n    const signal = this.combinedSignal(this.#copyPasteAC);\n\n    document.addEventListener(\"copy\", this.copy.bind(this), { signal });\n    document.addEventListener(\"cut\", this.cut.bind(this), { signal });\n    document.addEventListener(\"paste\", this.paste.bind(this), { signal });\n  }\n\n  #removeCopyPasteListeners() {\n    this.#copyPasteAC?.abort();\n    this.#copyPasteAC = null;\n  }\n\n  #addDragAndDropListeners() {\n    const signal = this._signal;\n    document.addEventListener(\"dragover\", this.dragOver.bind(this), { signal });\n    document.addEventListener(\"drop\", this.drop.bind(this), { signal });\n  }\n\n  addEditListeners() {\n    this.#addKeyboardManager();\n    this.setEditingState(true);\n  }\n\n  removeEditListeners() {\n    this.#removeKeyboardManager();\n    this.setEditingState(false);\n  }\n\n  dragOver(event) {\n    for (const { type } of event.dataTransfer.items) {\n      for (const editorType of this.#editorTypes) {\n        if (editorType.isHandlingMimeForPasting(type)) {\n          event.dataTransfer.dropEffect = \"copy\";\n          event.preventDefault();\n          return;\n        }\n      }\n    }\n  }\n\n  /**\n   * Drop callback.\n   * @param {DragEvent} event\n   */\n  drop(event) {\n    for (const item of event.dataTransfer.items) {\n      for (const editorType of this.#editorTypes) {\n        if (editorType.isHandlingMimeForPasting(item.type)) {\n          editorType.paste(item, this.currentLayer);\n          event.preventDefault();\n          return;\n        }\n      }\n    }\n  }\n\n  /**\n   * Copy callback.\n   * @param {ClipboardEvent} event\n   */\n  copy(event) {\n    event.preventDefault();\n\n    // An editor is being edited so just commit it.\n    this.#activeEditor?.commitOrRemove();\n\n    if (!this.hasSelection) {\n      return;\n    }\n\n    const editors = [];\n    for (const editor of this.#selectedEditors) {\n      const serialized = editor.serialize(/* isForCopying = */ true);\n      if (serialized) {\n        editors.push(serialized);\n      }\n    }\n    if (editors.length === 0) {\n      return;\n    }\n\n    event.clipboardData.setData(\"application/pdfjs\", JSON.stringify(editors));\n  }\n\n  /**\n   * Cut callback.\n   * @param {ClipboardEvent} event\n   */\n  cut(event) {\n    this.copy(event);\n    this.delete();\n  }\n\n  /**\n   * Paste callback.\n   * @param {ClipboardEvent} event\n   */\n  async paste(event) {\n    event.preventDefault();\n    const { clipboardData } = event;\n    for (const item of clipboardData.items) {\n      for (const editorType of this.#editorTypes) {\n        if (editorType.isHandlingMimeForPasting(item.type)) {\n          editorType.paste(item, this.currentLayer);\n          return;\n        }\n      }\n    }\n\n    let data = clipboardData.getData(\"application/pdfjs\");\n    if (!data) {\n      return;\n    }\n\n    try {\n      data = JSON.parse(data);\n    } catch (ex) {\n      warn(`paste: \"${ex.message}\".`);\n      return;\n    }\n\n    if (!Array.isArray(data)) {\n      return;\n    }\n\n    this.unselectAll();\n    const layer = this.currentLayer;\n\n    try {\n      const newEditors = [];\n      for (const editor of data) {\n        const deserializedEditor = await layer.deserialize(editor);\n        if (!deserializedEditor) {\n          return;\n        }\n        newEditors.push(deserializedEditor);\n      }\n\n      const cmd = () => {\n        for (const editor of newEditors) {\n          this.#addEditorToLayer(editor);\n        }\n        this.#selectEditors(newEditors);\n      };\n      const undo = () => {\n        for (const editor of newEditors) {\n          editor.remove();\n        }\n      };\n      this.addCommands({ cmd, undo, mustExec: true });\n    } catch (ex) {\n      warn(`paste: \"${ex.message}\".`);\n    }\n  }\n\n  /**\n   * Keydown callback.\n   * @param {KeyboardEvent} event\n   */\n  keydown(event) {\n    if (!this.isShiftKeyDown && event.key === \"Shift\") {\n      this.isShiftKeyDown = true;\n    }\n    if (\n      this.#mode !== AnnotationEditorType.NONE &&\n      !this.isEditorHandlingKeyboard\n    ) {\n      AnnotationEditorUIManager._keyboardManager.exec(this, event);\n    }\n  }\n\n  /**\n   * Keyup callback.\n   * @param {KeyboardEvent} event\n   */\n  keyup(event) {\n    if (this.isShiftKeyDown && event.key === \"Shift\") {\n      this.isShiftKeyDown = false;\n      if (this.#highlightWhenShiftUp) {\n        this.#highlightWhenShiftUp = false;\n        this.#onSelectEnd(\"main_toolbar\");\n      }\n    }\n  }\n\n  /**\n   * Execute an action for a given name.\n   * For example, the user can click on the \"Undo\" entry in the context menu\n   * and it'll trigger the undo action.\n   */\n  onEditingAction({ name }) {\n    switch (name) {\n      case \"undo\":\n      case \"redo\":\n      case \"delete\":\n      case \"selectAll\":\n        this[name]();\n        break;\n      case \"highlightSelection\":\n        this.highlightSelection(\"context_menu\");\n        break;\n      case \"commentSelection\":\n        this.commentSelection(\"context_menu\");\n        break;\n    }\n  }\n\n  /**\n   * Update the different possible states of this manager, e.g. is there\n   * something to undo, redo, ...\n   * @param {Object} details\n   */\n  #dispatchUpdateStates(details) {\n    const hasChanged = Object.entries(details).some(\n      ([key, value]) => this.#previousStates[key] !== value\n    );\n\n    if (hasChanged) {\n      this._eventBus.dispatch(\"annotationeditorstateschanged\", {\n        source: this,\n        details: Object.assign(this.#previousStates, details),\n      });\n      // We could listen on our own event but it sounds like a bit weird and\n      // it's a way to simpler to handle that stuff here instead of having to\n      // add something in every place where an editor can be unselected.\n      if (\n        this.#mode === AnnotationEditorType.HIGHLIGHT &&\n        details.hasSelectedEditor === false\n      ) {\n        this.#dispatchUpdateUI([\n          [AnnotationEditorParamsType.HIGHLIGHT_FREE, true],\n        ]);\n      }\n    }\n  }\n\n  #dispatchUpdateUI(details) {\n    this._eventBus.dispatch(\"annotationeditorparamschanged\", {\n      source: this,\n      details,\n    });\n  }\n\n  /**\n   * Set the editing state.\n   * It can be useful to temporarily disable it when the user is editing a\n   * FreeText annotation.\n   * @param {boolean} isEditing\n   */\n  setEditingState(isEditing) {\n    if (isEditing) {\n      this.#addFocusManager();\n      this.#addCopyPasteListeners();\n      this.#dispatchUpdateStates({\n        isEditing: this.#mode !== AnnotationEditorType.NONE,\n        isEmpty: this.#isEmpty(),\n        hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),\n        hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),\n        hasSelectedEditor: false,\n      });\n    } else {\n      this.#removeFocusManager();\n      this.#removeCopyPasteListeners();\n      this.#dispatchUpdateStates({\n        isEditing: false,\n      });\n      this.disableUserSelect(false);\n    }\n  }\n\n  registerEditorTypes(types) {\n    if (this.#editorTypes) {\n      return;\n    }\n    this.#editorTypes = types;\n    for (const editorType of this.#editorTypes) {\n      this.#dispatchUpdateUI(editorType.defaultPropertiesToUpdate);\n    }\n  }\n\n  /**\n   * Get an id.\n   * @returns {string}\n   */\n  getId() {\n    return this.#idManager.id;\n  }\n\n  get currentLayer() {\n    return this.#allLayers.get(this.#currentPageIndex);\n  }\n\n  getLayer(pageIndex) {\n    return this.#allLayers.get(pageIndex);\n  }\n\n  get currentPageIndex() {\n    return this.#currentPageIndex;\n  }\n\n  /**\n   * Add a new layer for a page which will contains the editors.\n   * @param {AnnotationEditorLayer} layer\n   */\n  addLayer(layer) {\n    this.#allLayers.set(layer.pageIndex, layer);\n    if (this.#isEnabled) {\n      layer.enable();\n    } else {\n      layer.disable();\n    }\n  }\n\n  /**\n   * Remove a layer.\n   * @param {AnnotationEditorLayer} layer\n   */\n  removeLayer(layer) {\n    this.#allLayers.delete(layer.pageIndex);\n  }\n\n  /**\n   * Change the editor mode (None, FreeText, Ink, ...)\n   * @param {number} mode\n   * @param {string|null} editId\n   * @param {boolean} [isFromUser] - true if the mode change is due to a\n   *   user action.\n   * @param {boolean} [isFromKeyboard] - true if the mode change is due to a\n   *   keyboard action.\n   * @param {boolean} [mustEnterInEditMode] - true if the editor must enter in\n   *   edit mode.\n   * @param {boolean} [editComment] - true if the mode change is due to a\n   *   comment edit.\n   */\n  async updateMode(\n    mode,\n    editId = null,\n    isFromUser = false,\n    isFromKeyboard = false,\n    mustEnterInEditMode = false,\n    editComment = false\n  ) {\n    if (this.#mode === mode) {\n      return;\n    }\n\n    if (this.#updateModeCapability) {\n      await this.#updateModeCapability.promise;\n      if (!this.#updateModeCapability) {\n        // This ui manager has been destroyed.\n        return;\n      }\n    }\n\n    this.#updateModeCapability = Promise.withResolvers();\n    this.#currentDrawingSession?.commitOrRemove();\n\n    if (this.#mode === AnnotationEditorType.POPUP) {\n      this.#commentManager?.hideSidebar();\n    }\n    this.#commentManager?.destroyPopup();\n\n    this.#mode = mode;\n    if (mode === AnnotationEditorType.NONE) {\n      this.setEditingState(false);\n      this.#disableAll();\n      for (const editor of this.#allEditors.values()) {\n        editor.hideStandaloneCommentButton();\n      }\n\n      this._editorUndoBar?.hide();\n      this.toggleComment(/* editor = */ null);\n\n      this.#updateModeCapability.resolve();\n      return;\n    }\n\n    for (const editor of this.#allEditors.values()) {\n      editor.addStandaloneCommentButton();\n    }\n\n    if (mode === AnnotationEditorType.SIGNATURE) {\n      await this.#signatureManager?.loadSignatures();\n    }\n\n    if (isFromUser) {\n      // reinitialize the pointer type when the mode is changed by the user\n      CurrentPointers.clearPointerType();\n    }\n\n    this.setEditingState(true);\n    await this.#enableAll();\n    this.unselectAll();\n    for (const layer of this.#allLayers.values()) {\n      layer.updateMode(mode);\n    }\n\n    if (mode === AnnotationEditorType.POPUP) {\n      this.#allEditableAnnotations ||=\n        await this.#pdfDocument.getAnnotationsByType(\n          new Set(this.#editorTypes.map(editorClass => editorClass._editorType))\n        );\n      const elementIds = new Set();\n      const allComments = [];\n      for (const editor of this.#allEditors.values()) {\n        const { annotationElementId, hasComment, deleted } = editor;\n        if (annotationElementId) {\n          elementIds.add(annotationElementId);\n        }\n        if (hasComment && !deleted) {\n          allComments.push(editor.getData());\n        }\n      }\n      for (const annotation of this.#allEditableAnnotations) {\n        const { id, popupRef, contentsObj } = annotation;\n        if (\n          popupRef &&\n          contentsObj?.str &&\n          !elementIds.has(id) &&\n          !this.#deletedAnnotationsElementIds.has(id)\n        ) {\n          // The annotation exists in the PDF and has a comment but there\n          // is no editor for it (anymore).\n          allComments.push(annotation);\n        }\n      }\n      this.#commentManager?.showSidebar(allComments);\n    }\n\n    if (!editId) {\n      if (isFromKeyboard) {\n        this.addNewEditorFromKeyboard();\n      }\n\n      this.#updateModeCapability.resolve();\n      return;\n    }\n\n    for (const editor of this.#allEditors.values()) {\n      if (editor.uid === editId) {\n        this.setSelected(editor);\n        if (editComment) {\n          editor.editComment();\n        } else if (mustEnterInEditMode) {\n          editor.enterInEditMode();\n        } else {\n          editor.focus();\n        }\n      } else {\n        editor.unselect();\n      }\n    }\n\n    this.#updateModeCapability.resolve();\n  }\n\n  addNewEditorFromKeyboard() {\n    if (this.currentLayer.canCreateNewEmptyEditor()) {\n      this.currentLayer.addNewEditor();\n    }\n  }\n\n  /**\n   * Update the toolbar if it's required to reflect the tool currently used.\n   * @param {Object} options\n   * @param {number} mode\n   * @returns {undefined}\n   */\n  updateToolbar(options) {\n    if (options.mode === this.#mode) {\n      return;\n    }\n    this._eventBus.dispatch(\"switchannotationeditormode\", {\n      source: this,\n      ...options,\n    });\n  }\n\n  /**\n   * Update a parameter in the current editor or globally.\n   * @param {number} type\n   * @param {*} value\n   */\n  updateParams(type, value) {\n    if (!this.#editorTypes) {\n      return;\n    }\n\n    switch (type) {\n      case AnnotationEditorParamsType.CREATE:\n        this.currentLayer.addNewEditor(value);\n        return;\n      case AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:\n        this._eventBus.dispatch(\"reporttelemetry\", {\n          source: this,\n          details: {\n            type: \"editing\",\n            data: {\n              type: \"highlight\",\n              action: \"toggle_visibility\",\n            },\n          },\n        });\n        (this.#showAllStates ||= new Map()).set(type, value);\n        this.showAllEditors(\"highlight\", value);\n        break;\n    }\n\n    if (this.hasSelection) {\n      for (const editor of this.#selectedEditors) {\n        editor.updateParams(type, value);\n      }\n    } else {\n      for (const editorType of this.#editorTypes) {\n        editorType.updateDefaultParams(type, value);\n      }\n    }\n  }\n\n  showAllEditors(type, visible, updateButton = false) {\n    for (const editor of this.#allEditors.values()) {\n      if (editor.editorType === type) {\n        editor.show(visible);\n      }\n    }\n    const state =\n      this.#showAllStates?.get(AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL) ??\n      true;\n    if (state !== visible) {\n      this.#dispatchUpdateUI([\n        [AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL, visible],\n      ]);\n    }\n  }\n\n  enableWaiting(mustWait = false) {\n    if (this.#isWaiting === mustWait) {\n      return;\n    }\n    this.#isWaiting = mustWait;\n    for (const layer of this.#allLayers.values()) {\n      if (mustWait) {\n        layer.disableClick();\n      } else {\n        layer.enableClick();\n      }\n      layer.div.classList.toggle(\"waiting\", mustWait);\n    }\n  }\n\n  /**\n   * Enable all the layers.\n   */\n  async #enableAll() {\n    if (!this.#isEnabled) {\n      this.#isEnabled = true;\n      const promises = [];\n      for (const layer of this.#allLayers.values()) {\n        promises.push(layer.enable());\n      }\n      await Promise.all(promises);\n      for (const editor of this.#allEditors.values()) {\n        editor.enable();\n      }\n    }\n  }\n\n  /**\n   * Disable all the layers.\n   */\n  #disableAll() {\n    this.unselectAll();\n    if (this.#isEnabled) {\n      this.#isEnabled = false;\n      for (const layer of this.#allLayers.values()) {\n        layer.disable();\n      }\n      for (const editor of this.#allEditors.values()) {\n        editor.disable();\n      }\n    }\n  }\n\n  /**\n   * Get all the editors belonging to a given page.\n   * @param {number} pageIndex\n   * @yields {AnnotationEditor}\n   */\n  *getEditors(pageIndex) {\n    for (const editor of this.#allEditors.values()) {\n      if (editor.pageIndex === pageIndex) {\n        yield editor;\n      }\n    }\n  }\n\n  /**\n   * Get an editor with the given id.\n   * @param {string} id\n   * @returns {AnnotationEditor}\n   */\n  getEditor(id) {\n    return this.#allEditors.get(id);\n  }\n\n  /**\n   * Add a new editor.\n   * @param {AnnotationEditor} editor\n   */\n  addEditor(editor) {\n    this.#allEditors.set(editor.id, editor);\n  }\n\n  /**\n   * Remove an editor.\n   * @param {AnnotationEditor} editor\n   */\n  removeEditor(editor) {\n    if (editor.div.contains(document.activeElement)) {\n      if (this.#focusMainContainerTimeoutId) {\n        clearTimeout(this.#focusMainContainerTimeoutId);\n      }\n      this.#focusMainContainerTimeoutId = setTimeout(() => {\n        // When the div is removed from DOM the focus can move on the\n        // document.body, so we need to move it back to the main container.\n        this.focusMainContainer();\n        this.#focusMainContainerTimeoutId = null;\n      }, 0);\n    }\n    this.#allEditors.delete(editor.id);\n    if (editor.annotationElementId) {\n      this.#missingCanvases?.delete(editor.annotationElementId);\n    }\n    this.unselect(editor);\n    if (\n      !editor.annotationElementId ||\n      !this.#deletedAnnotationsElementIds.has(editor.annotationElementId)\n    ) {\n      this.#annotationStorage?.remove(editor.id);\n    }\n  }\n\n  /**\n   * The annotation element with the given id has been deleted.\n   * @param {AnnotationEditor} editor\n   */\n  addDeletedAnnotationElement(editor) {\n    this.#deletedAnnotationsElementIds.add(editor.annotationElementId);\n    this.addChangedExistingAnnotation(editor);\n    editor.deleted = true;\n  }\n\n  /**\n   * Check if the annotation element with the given id has been deleted.\n   * @param {string} annotationElementId\n   * @returns {boolean}\n   */\n  isDeletedAnnotationElement(annotationElementId) {\n    return this.#deletedAnnotationsElementIds.has(annotationElementId);\n  }\n\n  /**\n   * The annotation element with the given id have been restored.\n   * @param {AnnotationEditor} editor\n   */\n  removeDeletedAnnotationElement(editor) {\n    this.#deletedAnnotationsElementIds.delete(editor.annotationElementId);\n    this.removeChangedExistingAnnotation(editor);\n    editor.deleted = false;\n  }\n\n  /**\n   * Add an editor to the layer it belongs to or add it to the global map.\n   * @param {AnnotationEditor} editor\n   */\n  #addEditorToLayer(editor) {\n    const layer = this.#allLayers.get(editor.pageIndex);\n    if (layer) {\n      layer.addOrRebuild(editor);\n    } else {\n      this.addEditor(editor);\n      this.addToAnnotationStorage(editor);\n    }\n  }\n\n  /**\n   * Set the given editor as the active one.\n   * @param {AnnotationEditor} editor\n   */\n  setActiveEditor(editor) {\n    if (this.#activeEditor === editor) {\n      return;\n    }\n\n    this.#activeEditor = editor;\n    if (editor) {\n      this.#dispatchUpdateUI(editor.propertiesToUpdate);\n    }\n  }\n\n  get #lastSelectedEditor() {\n    let ed = null;\n    for (ed of this.#selectedEditors) {\n      // Iterate to get the last element.\n    }\n    return ed;\n  }\n\n  /**\n   * Update the UI of the active editor.\n   * @param {AnnotationEditor} editor\n   */\n  updateUI(editor) {\n    if (this.#lastSelectedEditor === editor) {\n      this.#dispatchUpdateUI(editor.propertiesToUpdate);\n    }\n  }\n\n  updateUIForDefaultProperties(editorType) {\n    this.#dispatchUpdateUI(editorType.defaultPropertiesToUpdate);\n  }\n\n  /**\n   * Add or remove an editor the current selection.\n   * @param {AnnotationEditor} editor\n   */\n  toggleSelected(editor) {\n    if (this.#selectedEditors.has(editor)) {\n      this.#selectedEditors.delete(editor);\n      editor.unselect();\n      this.#dispatchUpdateStates({\n        hasSelectedEditor: this.hasSelection,\n      });\n      return;\n    }\n    this.#selectedEditors.add(editor);\n    editor.select();\n    this.#dispatchUpdateUI(editor.propertiesToUpdate);\n    this.#dispatchUpdateStates({\n      hasSelectedEditor: true,\n    });\n  }\n\n  /**\n   * Set the last selected editor.\n   * @param {AnnotationEditor} editor\n   */\n  setSelected(editor) {\n    this.updateToolbar({\n      mode: editor.mode,\n      editId: editor.uid,\n    });\n\n    this.#currentDrawingSession?.commitOrRemove();\n    for (const ed of this.#selectedEditors) {\n      if (ed !== editor) {\n        ed.unselect();\n      }\n    }\n    this.#selectedEditors.clear();\n\n    this.#selectedEditors.add(editor);\n    editor.select();\n    this.#dispatchUpdateUI(editor.propertiesToUpdate);\n    this.#dispatchUpdateStates({\n      hasSelectedEditor: true,\n    });\n  }\n\n  /**\n   * Check if the editor is selected.\n   * @param {AnnotationEditor} editor\n   */\n  isSelected(editor) {\n    return this.#selectedEditors.has(editor);\n  }\n\n  get firstSelectedEditor() {\n    return this.#selectedEditors.values().next().value;\n  }\n\n  /**\n   * Unselect an editor.\n   * @param {AnnotationEditor} editor\n   */\n  unselect(editor) {\n    editor.unselect();\n    this.#selectedEditors.delete(editor);\n    this.#dispatchUpdateStates({\n      hasSelectedEditor: this.hasSelection,\n    });\n  }\n\n  get hasSelection() {\n    return this.#selectedEditors.size !== 0;\n  }\n\n  get isEnterHandled() {\n    return (\n      this.#selectedEditors.size === 1 &&\n      this.firstSelectedEditor.isEnterHandled\n    );\n  }\n\n  /**\n   * Undo the last command.\n   */\n  undo() {\n    this.#commandManager.undo();\n    this.#dispatchUpdateStates({\n      hasSomethingToUndo: this.#commandManager.hasSomethingToUndo(),\n      hasSomethingToRedo: true,\n      isEmpty: this.#isEmpty(),\n    });\n    this._editorUndoBar?.hide();\n  }\n\n  /**\n   * Redo the last undoed command.\n   */\n  redo() {\n    this.#commandManager.redo();\n    this.#dispatchUpdateStates({\n      hasSomethingToUndo: true,\n      hasSomethingToRedo: this.#commandManager.hasSomethingToRedo(),\n      isEmpty: this.#isEmpty(),\n    });\n  }\n\n  /**\n   * Add a command to execute (cmd) and another one to undo it.\n   * @param {Object} params\n   */\n  addCommands(params) {\n    this.#commandManager.add(params);\n    this.#dispatchUpdateStates({\n      hasSomethingToUndo: true,\n      hasSomethingToRedo: false,\n      isEmpty: this.#isEmpty(),\n    });\n  }\n\n  cleanUndoStack(type) {\n    this.#commandManager.cleanType(type);\n  }\n\n  #isEmpty() {\n    if (this.#allEditors.size === 0) {\n      return true;\n    }\n\n    if (this.#allEditors.size === 1) {\n      for (const editor of this.#allEditors.values()) {\n        return editor.isEmpty();\n      }\n    }\n\n    return false;\n  }\n\n  /**\n   * Delete the current editor or all.\n   */\n  delete() {\n    this.commitOrRemove();\n    const drawingEditor = this.currentLayer?.endDrawingSession(\n      /* isAborted = */ true\n    );\n    if (!this.hasSelection && !drawingEditor) {\n      return;\n    }\n\n    const editors = drawingEditor\n      ? [drawingEditor]\n      : [...this.#selectedEditors];\n    const cmd = () => {\n      this._editorUndoBar?.show(\n        undo,\n        editors.length === 1 ? editors[0].editorType : editors.length\n      );\n      for (const editor of editors) {\n        editor.remove();\n      }\n    };\n    const undo = () => {\n      for (const editor of editors) {\n        this.#addEditorToLayer(editor);\n      }\n    };\n\n    this.addCommands({ cmd, undo, mustExec: true });\n  }\n\n  commitOrRemove() {\n    // An editor is being edited so just commit it.\n    this.#activeEditor?.commitOrRemove();\n  }\n\n  hasSomethingToControl() {\n    return this.#activeEditor || this.hasSelection;\n  }\n\n  /**\n   * Select the editors.\n   * @param {Array<AnnotationEditor>} editors\n   */\n  #selectEditors(editors) {\n    for (const editor of this.#selectedEditors) {\n      editor.unselect();\n    }\n    this.#selectedEditors.clear();\n    for (const editor of editors) {\n      if (editor.isEmpty()) {\n        continue;\n      }\n      this.#selectedEditors.add(editor);\n      editor.select();\n    }\n    this.#dispatchUpdateStates({ hasSelectedEditor: this.hasSelection });\n  }\n\n  /**\n   * Select all the editors.\n   */\n  selectAll() {\n    for (const editor of this.#selectedEditors) {\n      editor.commit();\n    }\n    this.#selectEditors(this.#allEditors.values());\n  }\n\n  /**\n   * Unselect all the selected editors.\n   */\n  unselectAll() {\n    if (this.#activeEditor) {\n      // An editor is being edited so just commit it.\n      this.#activeEditor.commitOrRemove();\n      if (this.#mode !== AnnotationEditorType.NONE) {\n        // If the mode is NONE, we want to really unselect the editor, hence we\n        // mustn't return here.\n        return;\n      }\n    }\n\n    if (this.#currentDrawingSession?.commitOrRemove()) {\n      return;\n    }\n\n    if (!this.hasSelection) {\n      return;\n    }\n    for (const editor of this.#selectedEditors) {\n      editor.unselect();\n    }\n    this.#selectedEditors.clear();\n    this.#dispatchUpdateStates({\n      hasSelectedEditor: false,\n    });\n  }\n\n  translateSelectedEditors(x, y, noCommit = false) {\n    if (!noCommit) {\n      this.commitOrRemove();\n    }\n    if (!this.hasSelection) {\n      return;\n    }\n\n    this.#translation[0] += x;\n    this.#translation[1] += y;\n    const [totalX, totalY] = this.#translation;\n    const editors = [...this.#selectedEditors];\n\n    // We don't want to have an undo/redo for each translation so we wait a bit\n    // before adding the command to the command manager.\n    const TIME_TO_WAIT = 1000;\n\n    if (this.#translationTimeoutId) {\n      clearTimeout(this.#translationTimeoutId);\n    }\n\n    this.#translationTimeoutId = setTimeout(() => {\n      this.#translationTimeoutId = null;\n      this.#translation[0] = this.#translation[1] = 0;\n\n      this.addCommands({\n        cmd: () => {\n          for (const editor of editors) {\n            if (this.#allEditors.has(editor.id)) {\n              editor.translateInPage(totalX, totalY);\n              editor.translationDone();\n            }\n          }\n        },\n        undo: () => {\n          for (const editor of editors) {\n            if (this.#allEditors.has(editor.id)) {\n              editor.translateInPage(-totalX, -totalY);\n              editor.translationDone();\n            }\n          }\n        },\n        mustExec: false,\n      });\n    }, TIME_TO_WAIT);\n\n    for (const editor of editors) {\n      editor.translateInPage(x, y);\n      editor.translationDone();\n    }\n  }\n\n  /**\n   * Set up the drag session for moving the selected editors.\n   */\n  setUpDragSession() {\n    // Note: don't use any references to the editor's parent which can be null\n    // if the editor belongs to a destroyed page.\n    if (!this.hasSelection) {\n      return;\n    }\n    // Avoid to have spurious text selection in the text layer when dragging.\n    this.disableUserSelect(true);\n    this.#draggingEditors = new Map();\n    for (const editor of this.#selectedEditors) {\n      this.#draggingEditors.set(editor, {\n        savedX: editor.x,\n        savedY: editor.y,\n        savedPageIndex: editor.pageIndex,\n        newX: 0,\n        newY: 0,\n        newPageIndex: -1,\n      });\n    }\n  }\n\n  /**\n   * Ends the drag session.\n   * @returns {boolean} true if at least one editor has been moved.\n   */\n  endDragSession() {\n    if (!this.#draggingEditors) {\n      return false;\n    }\n    this.disableUserSelect(false);\n    const map = this.#draggingEditors;\n    this.#draggingEditors = null;\n    let mustBeAddedInUndoStack = false;\n\n    for (const [{ x, y, pageIndex }, value] of map) {\n      value.newX = x;\n      value.newY = y;\n      value.newPageIndex = pageIndex;\n      mustBeAddedInUndoStack ||=\n        x !== value.savedX ||\n        y !== value.savedY ||\n        pageIndex !== value.savedPageIndex;\n    }\n\n    if (!mustBeAddedInUndoStack) {\n      return false;\n    }\n\n    const move = (editor, x, y, pageIndex) => {\n      if (this.#allEditors.has(editor.id)) {\n        // The editor can be undone/redone on a page which is not visible (and\n        // which potentially has no annotation editor layer), hence we need to\n        // use the pageIndex instead of the parent.\n        const parent = this.#allLayers.get(pageIndex);\n        if (parent) {\n          editor._setParentAndPosition(parent, x, y);\n        } else {\n          editor.pageIndex = pageIndex;\n          editor.x = x;\n          editor.y = y;\n        }\n      }\n    };\n\n    this.addCommands({\n      cmd: () => {\n        for (const [editor, { newX, newY, newPageIndex }] of map) {\n          move(editor, newX, newY, newPageIndex);\n        }\n      },\n      undo: () => {\n        for (const [editor, { savedX, savedY, savedPageIndex }] of map) {\n          move(editor, savedX, savedY, savedPageIndex);\n        }\n      },\n      mustExec: true,\n    });\n\n    return true;\n  }\n\n  /**\n   * Drag the set of selected editors.\n   * @param {number} tx\n   * @param {number} ty\n   */\n  dragSelectedEditors(tx, ty) {\n    if (!this.#draggingEditors) {\n      return;\n    }\n    for (const editor of this.#draggingEditors.keys()) {\n      editor.drag(tx, ty);\n    }\n  }\n\n  /**\n   * Rebuild the editor (usually on undo/redo actions) on a potentially\n   * non-rendered page.\n   * @param {AnnotationEditor} editor\n   */\n  rebuild(editor) {\n    if (editor.parent === null) {\n      const parent = this.getLayer(editor.pageIndex);\n      if (parent) {\n        parent.changeParent(editor);\n        parent.addOrRebuild(editor);\n      } else {\n        this.addEditor(editor);\n        this.addToAnnotationStorage(editor);\n        editor.rebuild();\n      }\n    } else {\n      editor.parent.addOrRebuild(editor);\n    }\n  }\n\n  get isEditorHandlingKeyboard() {\n    return (\n      this.getActive()?.shouldGetKeyboardEvents() ||\n      (this.#selectedEditors.size === 1 &&\n        this.firstSelectedEditor.shouldGetKeyboardEvents())\n    );\n  }\n\n  /**\n   * Is the current editor the one passed as argument?\n   * @param {AnnotationEditor} editor\n   * @returns\n   */\n  isActive(editor) {\n    return this.#activeEditor === editor;\n  }\n\n  /**\n   * Get the current active editor.\n   * @returns {AnnotationEditor|null}\n   */\n  getActive() {\n    return this.#activeEditor;\n  }\n\n  /**\n   * Get the current editor mode.\n   * @returns {number}\n   */\n  getMode() {\n    return this.#mode;\n  }\n\n  isEditingMode() {\n    return this.#mode !== AnnotationEditorType.NONE;\n  }\n\n  get imageManager() {\n    return shadow(this, \"imageManager\", new ImageManager());\n  }\n\n  getSelectionBoxes(textLayer) {\n    if (!textLayer) {\n      return null;\n    }\n    const selection = document.getSelection();\n    for (let i = 0, ii = selection.rangeCount; i < ii; i++) {\n      if (\n        !textLayer.contains(selection.getRangeAt(i).commonAncestorContainer)\n      ) {\n        return null;\n      }\n    }\n\n    const {\n      x: layerX,\n      y: layerY,\n      width: parentWidth,\n      height: parentHeight,\n    } = textLayer.getBoundingClientRect();\n\n    // We must rotate the boxes because we want to have them in the non-rotated\n    // page coordinates.\n    let rotator;\n    switch (textLayer.getAttribute(\"data-main-rotation\")) {\n      case \"90\":\n        rotator = (x, y, w, h) => ({\n          x: (y - layerY) / parentHeight,\n          y: 1 - (x + w - layerX) / parentWidth,\n          width: h / parentHeight,\n          height: w / parentWidth,\n        });\n        break;\n      case \"180\":\n        rotator = (x, y, w, h) => ({\n          x: 1 - (x + w - layerX) / parentWidth,\n          y: 1 - (y + h - layerY) / parentHeight,\n          width: w / parentWidth,\n          height: h / parentHeight,\n        });\n        break;\n      case \"270\":\n        rotator = (x, y, w, h) => ({\n          x: 1 - (y + h - layerY) / parentHeight,\n          y: (x - layerX) / parentWidth,\n          width: h / parentHeight,\n          height: w / parentWidth,\n        });\n        break;\n      default:\n        rotator = (x, y, w, h) => ({\n          x: (x - layerX) / parentWidth,\n          y: (y - layerY) / parentHeight,\n          width: w / parentWidth,\n          height: h / parentHeight,\n        });\n        break;\n    }\n\n    const boxes = [];\n    for (let i = 0, ii = selection.rangeCount; i < ii; i++) {\n      const range = selection.getRangeAt(i);\n      if (range.collapsed) {\n        continue;\n      }\n      for (const { x, y, width, height } of range.getClientRects()) {\n        if (width === 0 || height === 0) {\n          continue;\n        }\n        boxes.push(rotator(x, y, width, height));\n      }\n    }\n    return boxes.length === 0 ? null : boxes;\n  }\n\n  addChangedExistingAnnotation({ annotationElementId, id }) {\n    (this.#changedExistingAnnotations ||= new Map()).set(\n      annotationElementId,\n      id\n    );\n  }\n\n  removeChangedExistingAnnotation({ annotationElementId }) {\n    this.#changedExistingAnnotations?.delete(annotationElementId);\n  }\n\n  renderAnnotationElement(annotation) {\n    const editorId = this.#changedExistingAnnotations?.get(annotation.data.id);\n    if (!editorId) {\n      return;\n    }\n    const editor = this.#annotationStorage.getRawValue(editorId);\n    if (!editor) {\n      return;\n    }\n    if (this.#mode === AnnotationEditorType.NONE && !editor.hasBeenModified) {\n      return;\n    }\n    editor.renderAnnotationElement(annotation);\n  }\n\n  setMissingCanvas(annotationId, annotationElementId, canvas) {\n    const editor = this.#missingCanvases?.get(annotationId);\n    if (!editor) {\n      return;\n    }\n    editor.setCanvas(annotationElementId, canvas);\n    this.#missingCanvases.delete(annotationId);\n  }\n\n  addMissingCanvas(annotationId, editor) {\n    (this.#missingCanvases ||= new Map()).set(annotationId, editor);\n  }\n}\n\nexport {\n  AnnotationEditorUIManager,\n  bindEvents,\n  ColorManager,\n  CommandManager,\n  CurrentPointers,\n  KeyboardManager,\n};\n","/* Copyright 2023 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { noContextMenu } from \"../display_utils.js\";\n\nclass AltText {\n  #altText = null;\n\n  #altTextDecorative = false;\n\n  #altTextButton = null;\n\n  #altTextButtonLabel = null;\n\n  #altTextTooltip = null;\n\n  #altTextTooltipTimeout = null;\n\n  #altTextWasFromKeyBoard = false;\n\n  #badge = null;\n\n  #editor = null;\n\n  #guessedText = null;\n\n  #textWithDisclaimer = null;\n\n  #useNewAltTextFlow = false;\n\n  static #l10nNewButton = null;\n\n  static _l10n = null;\n\n  constructor(editor) {\n    this.#editor = editor;\n    this.#useNewAltTextFlow = editor._uiManager.useNewAltTextFlow;\n\n    AltText.#l10nNewButton ||= Object.freeze({\n      added: \"pdfjs-editor-new-alt-text-added-button\",\n      \"added-label\": \"pdfjs-editor-new-alt-text-added-button-label\",\n      missing: \"pdfjs-editor-new-alt-text-missing-button\",\n      \"missing-label\": \"pdfjs-editor-new-alt-text-missing-button-label\",\n      review: \"pdfjs-editor-new-alt-text-to-review-button\",\n      \"review-label\": \"pdfjs-editor-new-alt-text-to-review-button-label\",\n    });\n  }\n\n  static initialize(l10n) {\n    AltText._l10n ??= l10n;\n  }\n\n  async render() {\n    const altText = (this.#altTextButton = document.createElement(\"button\"));\n    altText.className = \"altText\";\n    altText.tabIndex = \"0\";\n\n    const label = (this.#altTextButtonLabel = document.createElement(\"span\"));\n    altText.append(label);\n\n    if (this.#useNewAltTextFlow) {\n      altText.classList.add(\"new\");\n      altText.setAttribute(\"data-l10n-id\", AltText.#l10nNewButton.missing);\n      label.setAttribute(\n        \"data-l10n-id\",\n        AltText.#l10nNewButton[\"missing-label\"]\n      );\n    } else {\n      altText.setAttribute(\"data-l10n-id\", \"pdfjs-editor-alt-text-button\");\n      label.setAttribute(\"data-l10n-id\", \"pdfjs-editor-alt-text-button-label\");\n    }\n\n    const signal = this.#editor._uiManager._signal;\n    altText.addEventListener(\"contextmenu\", noContextMenu, { signal });\n    altText.addEventListener(\"pointerdown\", event => event.stopPropagation(), {\n      signal,\n    });\n\n    const onClick = event => {\n      event.preventDefault();\n      this.#editor._uiManager.editAltText(this.#editor);\n      if (this.#useNewAltTextFlow) {\n        this.#editor._reportTelemetry({\n          action: \"pdfjs.image.alt_text.image_status_label_clicked\",\n          data: { label: this.#label },\n        });\n      }\n    };\n    altText.addEventListener(\"click\", onClick, { capture: true, signal });\n    altText.addEventListener(\n      \"keydown\",\n      event => {\n        if (event.target === altText && event.key === \"Enter\") {\n          this.#altTextWasFromKeyBoard = true;\n          onClick(event);\n        }\n      },\n      { signal }\n    );\n    await this.#setState();\n\n    return altText;\n  }\n\n  get #label() {\n    return (\n      (this.#altText && \"added\") ||\n      (this.#altText === null && this.guessedText && \"review\") ||\n      \"missing\"\n    );\n  }\n\n  finish() {\n    if (!this.#altTextButton) {\n      return;\n    }\n    this.#altTextButton.focus({ focusVisible: this.#altTextWasFromKeyBoard });\n    this.#altTextWasFromKeyBoard = false;\n  }\n\n  isEmpty() {\n    if (this.#useNewAltTextFlow) {\n      return this.#altText === null;\n    }\n    return !this.#altText && !this.#altTextDecorative;\n  }\n\n  hasData() {\n    if (this.#useNewAltTextFlow) {\n      return this.#altText !== null || !!this.#guessedText;\n    }\n    return this.isEmpty();\n  }\n\n  get guessedText() {\n    return this.#guessedText;\n  }\n\n  async setGuessedText(guessedText) {\n    if (this.#altText !== null) {\n      // The user provided their own alt text, so we don't want to overwrite it.\n      return;\n    }\n    this.#guessedText = guessedText;\n    this.#textWithDisclaimer = await AltText._l10n.get(\n      \"pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer\",\n      { generatedAltText: guessedText }\n    );\n    this.#setState();\n  }\n\n  toggleAltTextBadge(visibility = false) {\n    if (!this.#useNewAltTextFlow || this.#altText) {\n      this.#badge?.remove();\n      this.#badge = null;\n      return;\n    }\n    if (!this.#badge) {\n      const badge = (this.#badge = document.createElement(\"div\"));\n      badge.className = \"noAltTextBadge\";\n      this.#editor.div.append(badge);\n    }\n    this.#badge.classList.toggle(\"hidden\", !visibility);\n  }\n\n  serialize(isForCopying) {\n    let altText = this.#altText;\n    if (!isForCopying && this.#guessedText === altText) {\n      altText = this.#textWithDisclaimer;\n    }\n    return {\n      altText,\n      decorative: this.#altTextDecorative,\n      guessedText: this.#guessedText,\n      textWithDisclaimer: this.#textWithDisclaimer,\n    };\n  }\n\n  get data() {\n    return {\n      altText: this.#altText,\n      decorative: this.#altTextDecorative,\n    };\n  }\n\n  /**\n   * Set the alt text data.\n   */\n  set data({\n    altText,\n    decorative,\n    guessedText,\n    textWithDisclaimer,\n    cancel = false,\n  }) {\n    if (guessedText) {\n      this.#guessedText = guessedText;\n      this.#textWithDisclaimer = textWithDisclaimer;\n    }\n    if (this.#altText === altText && this.#altTextDecorative === decorative) {\n      return;\n    }\n    if (!cancel) {\n      this.#altText = altText;\n      this.#altTextDecorative = decorative;\n    }\n    this.#setState();\n  }\n\n  toggle(enabled = false) {\n    if (!this.#altTextButton) {\n      return;\n    }\n    if (!enabled && this.#altTextTooltipTimeout) {\n      clearTimeout(this.#altTextTooltipTimeout);\n      this.#altTextTooltipTimeout = null;\n    }\n    this.#altTextButton.disabled = !enabled;\n  }\n\n  shown() {\n    this.#editor._reportTelemetry({\n      action: \"pdfjs.image.alt_text.image_status_label_displayed\",\n      data: { label: this.#label },\n    });\n  }\n\n  destroy() {\n    this.#altTextButton?.remove();\n    this.#altTextButton = null;\n    this.#altTextButtonLabel = null;\n    this.#altTextTooltip = null;\n    this.#badge?.remove();\n    this.#badge = null;\n  }\n\n  async #setState() {\n    const button = this.#altTextButton;\n    if (!button) {\n      return;\n    }\n\n    if (this.#useNewAltTextFlow) {\n      button.classList.toggle(\"done\", !!this.#altText);\n      button.setAttribute(\"data-l10n-id\", AltText.#l10nNewButton[this.#label]);\n\n      this.#altTextButtonLabel?.setAttribute(\n        \"data-l10n-id\",\n        AltText.#l10nNewButton[`${this.#label}-label`]\n      );\n      if (!this.#altText) {\n        this.#altTextTooltip?.remove();\n        return;\n      }\n    } else {\n      if (!this.#altText && !this.#altTextDecorative) {\n        button.classList.remove(\"done\");\n        this.#altTextTooltip?.remove();\n        return;\n      }\n      button.classList.add(\"done\");\n      button.setAttribute(\"data-l10n-id\", \"pdfjs-editor-alt-text-edit-button\");\n    }\n\n    let tooltip = this.#altTextTooltip;\n    if (!tooltip) {\n      this.#altTextTooltip = tooltip = document.createElement(\"span\");\n      tooltip.className = \"tooltip\";\n      tooltip.setAttribute(\"role\", \"tooltip\");\n      tooltip.id = `alt-text-tooltip-${this.#editor.id}`;\n\n      const DELAY_TO_SHOW_TOOLTIP = 100;\n      const signal = this.#editor._uiManager._signal;\n      signal.addEventListener(\n        \"abort\",\n        () => {\n          clearTimeout(this.#altTextTooltipTimeout);\n          this.#altTextTooltipTimeout = null;\n        },\n        { once: true }\n      );\n      button.addEventListener(\n        \"mouseenter\",\n        () => {\n          this.#altTextTooltipTimeout = setTimeout(() => {\n            this.#altTextTooltipTimeout = null;\n            this.#altTextTooltip.classList.add(\"show\");\n            this.#editor._reportTelemetry({\n              action: \"alt_text_tooltip\",\n            });\n          }, DELAY_TO_SHOW_TOOLTIP);\n        },\n        { signal }\n      );\n      button.addEventListener(\n        \"mouseleave\",\n        () => {\n          if (this.#altTextTooltipTimeout) {\n            clearTimeout(this.#altTextTooltipTimeout);\n            this.#altTextTooltipTimeout = null;\n          }\n          this.#altTextTooltip?.classList.remove(\"show\");\n        },\n        { signal }\n      );\n    }\n    if (this.#altTextDecorative) {\n      tooltip.setAttribute(\n        \"data-l10n-id\",\n        \"pdfjs-editor-alt-text-decorative-tooltip\"\n      );\n    } else {\n      tooltip.removeAttribute(\"data-l10n-id\");\n      tooltip.textContent = this.#altText;\n    }\n\n    if (!tooltip.parentNode) {\n      button.append(tooltip);\n    }\n\n    const element = this.#editor.getElementForAltText();\n    element?.setAttribute(\"aria-describedby\", tooltip.id);\n  }\n}\n\nexport { AltText };\n","/* Copyright 2025 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { noContextMenu, stopEvent } from \"../display_utils.js\";\n\nclass Comment {\n  #commentStandaloneButton = null;\n\n  #commentToolbarButton = null;\n\n  #commentWasFromKeyBoard = false;\n\n  #editor = null;\n\n  #initialText = null;\n\n  #richText = null;\n\n  #text = null;\n\n  #date = null;\n\n  #deleted = false;\n\n  #popupPosition = null;\n\n  constructor(editor) {\n    this.#editor = editor;\n  }\n\n  renderForToolbar() {\n    const button = (this.#commentToolbarButton =\n      document.createElement(\"button\"));\n    button.className = \"comment\";\n    return this.#render(button, false);\n  }\n\n  renderForStandalone() {\n    const button = (this.#commentStandaloneButton =\n      document.createElement(\"button\"));\n    button.className = \"annotationCommentButton\";\n\n    const position = this.#editor.commentButtonPosition;\n    if (position) {\n      const { style } = button;\n      style.insetInlineEnd = `calc(${\n        100 *\n        (this.#editor._uiManager.direction === \"ltr\"\n          ? 1 - position[0]\n          : position[0])\n      }% - var(--comment-button-dim))`;\n      style.top = `calc(${100 * position[1]}% - var(--comment-button-dim))`;\n      const color = this.#editor.commentButtonColor;\n      if (color) {\n        style.backgroundColor = color;\n      }\n    }\n\n    return this.#render(button, true);\n  }\n\n  focusButton() {\n    setTimeout(() => {\n      (this.#commentStandaloneButton ?? this.#commentToolbarButton)?.focus();\n    }, 0);\n  }\n\n  onUpdatedColor() {\n    if (!this.#commentStandaloneButton) {\n      return;\n    }\n    const color = this.#editor.commentButtonColor;\n    if (color) {\n      this.#commentStandaloneButton.style.backgroundColor = color;\n    }\n    this.#editor._uiManager.updatePopupColor(this.#editor);\n  }\n\n  get commentButtonWidth() {\n    return (\n      (this.#commentStandaloneButton?.getBoundingClientRect().width ?? 0) /\n      this.#editor.parent.boundingClientRect.width\n    );\n  }\n\n  get commentPopupPositionInLayer() {\n    if (this.#popupPosition) {\n      return this.#popupPosition;\n    }\n    if (!this.#commentStandaloneButton) {\n      return null;\n    }\n    const { x, y, height } =\n      this.#commentStandaloneButton.getBoundingClientRect();\n    const {\n      x: parentX,\n      y: parentY,\n      width: parentWidth,\n      height: parentHeight,\n    } = this.#editor.parent.boundingClientRect;\n    return [(x - parentX) / parentWidth, (y + height - parentY) / parentHeight];\n  }\n\n  set commentPopupPositionInLayer(pos) {\n    this.#popupPosition = pos;\n  }\n\n  hasDefaultPopupPosition() {\n    return this.#popupPosition === null;\n  }\n\n  removeStandaloneCommentButton() {\n    this.#commentStandaloneButton?.remove();\n    this.#commentStandaloneButton = null;\n  }\n\n  removeToolbarCommentButton() {\n    this.#commentToolbarButton?.remove();\n    this.#commentToolbarButton = null;\n  }\n\n  setCommentButtonStates({ selected, hasPopup }) {\n    if (!this.#commentStandaloneButton) {\n      return;\n    }\n    this.#commentStandaloneButton.classList.toggle(\"selected\", selected);\n    this.#commentStandaloneButton.ariaExpanded = hasPopup;\n  }\n\n  #render(comment, isStandalone) {\n    if (!this.#editor._uiManager.hasCommentManager()) {\n      return null;\n    }\n\n    comment.tabIndex = \"0\";\n    comment.ariaHasPopup = \"dialog\";\n\n    if (isStandalone) {\n      comment.ariaControls = \"commentPopup\";\n      comment.setAttribute(\"data-l10n-id\", \"pdfjs-show-comment-button\");\n    } else {\n      comment.ariaControlsElements = [\n        this.#editor._uiManager.getCommentDialogElement(),\n      ];\n      comment.setAttribute(\"data-l10n-id\", \"pdfjs-editor-add-comment-button\");\n    }\n\n    const signal = this.#editor._uiManager._signal;\n    if (!(signal instanceof AbortSignal) || signal.aborted) {\n      return comment;\n    }\n\n    comment.addEventListener(\"contextmenu\", noContextMenu, { signal });\n    if (isStandalone) {\n      comment.addEventListener(\n        \"focusin\",\n        e => {\n          this.#editor._focusEventsAllowed = false;\n          stopEvent(e);\n        },\n        {\n          capture: true,\n          signal,\n        }\n      );\n      comment.addEventListener(\n        \"focusout\",\n        e => {\n          this.#editor._focusEventsAllowed = true;\n          stopEvent(e);\n        },\n        {\n          capture: true,\n          signal,\n        }\n      );\n    }\n    comment.addEventListener(\"pointerdown\", event => event.stopPropagation(), {\n      signal,\n    });\n\n    const onClick = event => {\n      event.preventDefault();\n      if (comment === this.#commentToolbarButton) {\n        this.edit();\n      } else {\n        this.#editor.toggleComment(/* isSelected = */ true);\n      }\n    };\n    comment.addEventListener(\"click\", onClick, { capture: true, signal });\n    comment.addEventListener(\n      \"keydown\",\n      event => {\n        if (event.target === comment && event.key === \"Enter\") {\n          this.#commentWasFromKeyBoard = true;\n          onClick(event);\n        }\n      },\n      { signal }\n    );\n\n    comment.addEventListener(\n      \"pointerenter\",\n      () => {\n        this.#editor.toggleComment(\n          /* isSelected = */ false,\n          /* visibility = */ true\n        );\n      },\n      { signal }\n    );\n    comment.addEventListener(\n      \"pointerleave\",\n      () => {\n        this.#editor.toggleComment(\n          /* isSelected = */ false,\n          /* visibility = */ false\n        );\n      },\n      { signal }\n    );\n\n    return comment;\n  }\n\n  edit(options) {\n    const position = this.commentPopupPositionInLayer;\n    let posX, posY;\n    if (position) {\n      [posX, posY] = position;\n    } else {\n      // The position is in the editor coordinates.\n      [posX, posY] = this.#editor.commentButtonPosition;\n      const { width, height, x, y } = this.#editor;\n      posX = x + posX * width;\n      posY = y + posY * height;\n    }\n    const parentDimensions = this.#editor.parent.boundingClientRect;\n    const {\n      x: parentX,\n      y: parentY,\n      width: parentWidth,\n      height: parentHeight,\n    } = parentDimensions;\n    this.#editor._uiManager.editComment(\n      this.#editor,\n      parentX + posX * parentWidth,\n      parentY + posY * parentHeight,\n      { ...options, parentDimensions }\n    );\n  }\n\n  finish() {\n    if (!this.#commentToolbarButton) {\n      return;\n    }\n    this.#commentToolbarButton.focus({\n      focusVisible: this.#commentWasFromKeyBoard,\n    });\n    this.#commentWasFromKeyBoard = false;\n  }\n\n  isDeleted() {\n    return this.#deleted || this.#text === \"\";\n  }\n\n  isEmpty() {\n    return this.#text === null;\n  }\n\n  hasBeenEdited() {\n    return this.isDeleted() || this.#text !== this.#initialText;\n  }\n\n  serialize() {\n    return this.data;\n  }\n\n  get data() {\n    return {\n      text: this.#text,\n      richText: this.#richText,\n      date: this.#date,\n      deleted: this.isDeleted(),\n    };\n  }\n\n  /**\n   * Set the comment data.\n   */\n  set data(text) {\n    if (text !== this.#text) {\n      this.#richText = null;\n    }\n    if (text === null) {\n      this.#text = \"\";\n      this.#deleted = true;\n      return;\n    }\n    this.#text = text;\n    this.#date = new Date();\n    this.#deleted = false;\n  }\n\n  /**\n   * Restore the comment data (used for undo).\n   * @param {Object} data - The comment data to restore.\n   * @param {string} data.text - The comment text.\n   * @param {string|null} data.richText - The rich text content.\n   * @param {Date|null} data.date - The original date.\n   */\n  restoreData({ text, richText, date }) {\n    this.#text = text;\n    this.#richText = richText;\n    this.#date = date;\n    this.#deleted = false;\n  }\n\n  setInitialText(text, richText = null) {\n    this.#initialText = text;\n    this.data = text;\n    this.#date = null;\n    this.#richText = richText;\n  }\n\n  shown() {}\n\n  destroy() {\n    this.#commentToolbarButton?.remove();\n    this.#commentToolbarButton = null;\n    this.#commentStandaloneButton?.remove();\n    this.#commentStandaloneButton = null;\n    this.#text = \"\";\n    this.#richText = null;\n    this.#date = null;\n    this.#editor = null;\n    this.#commentWasFromKeyBoard = false;\n    this.#deleted = false;\n  }\n}\n\nexport { Comment };\n","/* Copyright 2024 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { OutputScale, stopEvent } from \"./display_utils.js\";\n\nclass TouchManager {\n  #container;\n\n  #isPinching = false;\n\n  #isPinchingStopped = null;\n\n  #isPinchingDisabled;\n\n  #onPinchStart;\n\n  #onPinching;\n\n  #onPinchEnd;\n\n  #pointerDownAC = null;\n\n  #signal;\n\n  #touchInfo = null;\n\n  #touchManagerAC;\n\n  #touchMoveAC = null;\n\n  constructor({\n    container,\n    isPinchingDisabled = null,\n    isPinchingStopped = null,\n    onPinchStart = null,\n    onPinching = null,\n    onPinchEnd = null,\n    signal,\n  }) {\n    this.#container = container;\n    this.#isPinchingStopped = isPinchingStopped;\n    this.#isPinchingDisabled = isPinchingDisabled;\n    this.#onPinchStart = onPinchStart;\n    this.#onPinching = onPinching;\n    this.#onPinchEnd = onPinchEnd;\n    this.#touchManagerAC = new AbortController();\n    this.#signal = AbortSignal.any([signal, this.#touchManagerAC.signal]);\n\n    container.addEventListener(\"touchstart\", this.#onTouchStart.bind(this), {\n      passive: false,\n      signal: this.#signal,\n    });\n  }\n\n  /**\n   * NOTE: Don't shadow this value since `devicePixelRatio` may change if the\n   * window resolution changes, e.g. if the viewer is moved to another monitor.\n   */\n  get MIN_TOUCH_DISTANCE_TO_PINCH() {\n    // The 35 is coming from:\n    //  https://searchfox.org/mozilla-central/source/gfx/layers/apz/src/GestureEventListener.cpp#36\n    //\n    // The properties TouchEvent::screenX/Y are in screen CSS pixels:\n    //  https://developer.mozilla.org/en-US/docs/Web/API/Touch/screenX#examples\n    // MIN_TOUCH_DISTANCE_TO_PINCH is in CSS pixels.\n    return 35 / OutputScale.pixelRatio;\n  }\n\n  #onTouchStart(evt) {\n    if (this.#isPinchingDisabled?.()) {\n      return;\n    }\n\n    if (evt.touches.length === 1) {\n      if (this.#pointerDownAC) {\n        return;\n      }\n      const pointerDownAC = (this.#pointerDownAC = new AbortController());\n      const signal = AbortSignal.any([this.#signal, pointerDownAC.signal]);\n      const container = this.#container;\n\n      // We want to have the events at the capture phase to make sure we can\n      // cancel them.\n      const opts = { capture: true, signal, passive: false };\n      const cancelPointerDown = e => {\n        if (e.pointerType === \"touch\") {\n          this.#pointerDownAC?.abort();\n          this.#pointerDownAC = null;\n        }\n      };\n      container.addEventListener(\n        \"pointerdown\",\n        e => {\n          if (e.pointerType === \"touch\") {\n            // This is the second finger so we don't want it select something\n            // or whatever.\n            stopEvent(e);\n            cancelPointerDown(e);\n          }\n        },\n        opts\n      );\n      container.addEventListener(\"pointerup\", cancelPointerDown, opts);\n      container.addEventListener(\"pointercancel\", cancelPointerDown, opts);\n      return;\n    }\n\n    if (!this.#touchMoveAC) {\n      this.#touchMoveAC = new AbortController();\n      const signal = AbortSignal.any([this.#signal, this.#touchMoveAC.signal]);\n      const container = this.#container;\n\n      const opt = { signal, capture: false, passive: false };\n      container.addEventListener(\n        \"touchmove\",\n        this.#onTouchMove.bind(this),\n        opt\n      );\n      const onTouchEnd = this.#onTouchEnd.bind(this);\n      container.addEventListener(\"touchend\", onTouchEnd, opt);\n      container.addEventListener(\"touchcancel\", onTouchEnd, opt);\n\n      opt.capture = true;\n      container.addEventListener(\"pointerdown\", stopEvent, opt);\n      container.addEventListener(\"pointermove\", stopEvent, opt);\n      container.addEventListener(\"pointercancel\", stopEvent, opt);\n      container.addEventListener(\"pointerup\", stopEvent, opt);\n      this.#onPinchStart?.();\n    }\n\n    stopEvent(evt);\n\n    if (evt.touches.length !== 2 || this.#isPinchingStopped?.()) {\n      this.#touchInfo = null;\n      return;\n    }\n\n    let [touch0, touch1] = evt.touches;\n    if (touch0.identifier > touch1.identifier) {\n      [touch0, touch1] = [touch1, touch0];\n    }\n    this.#touchInfo = {\n      touch0X: touch0.screenX,\n      touch0Y: touch0.screenY,\n      touch1X: touch1.screenX,\n      touch1Y: touch1.screenY,\n    };\n  }\n\n  #onTouchMove(evt) {\n    if (!this.#touchInfo || evt.touches.length !== 2) {\n      return;\n    }\n\n    stopEvent(evt);\n\n    let [touch0, touch1] = evt.touches;\n    if (touch0.identifier > touch1.identifier) {\n      [touch0, touch1] = [touch1, touch0];\n    }\n    const { screenX: screen0X, screenY: screen0Y } = touch0;\n    const { screenX: screen1X, screenY: screen1Y } = touch1;\n    const touchInfo = this.#touchInfo;\n    const {\n      touch0X: pTouch0X,\n      touch0Y: pTouch0Y,\n      touch1X: pTouch1X,\n      touch1Y: pTouch1Y,\n    } = touchInfo;\n\n    const prevGapX = pTouch1X - pTouch0X;\n    const prevGapY = pTouch1Y - pTouch0Y;\n    const currGapX = screen1X - screen0X;\n    const currGapY = screen1Y - screen0Y;\n\n    const distance = Math.hypot(currGapX, currGapY) || 1;\n    const pDistance = Math.hypot(prevGapX, prevGapY) || 1;\n    if (\n      !this.#isPinching &&\n      Math.abs(pDistance - distance) <= TouchManager.MIN_TOUCH_DISTANCE_TO_PINCH\n    ) {\n      return;\n    }\n\n    touchInfo.touch0X = screen0X;\n    touchInfo.touch0Y = screen0Y;\n    touchInfo.touch1X = screen1X;\n    touchInfo.touch1Y = screen1Y;\n\n    if (!this.#isPinching) {\n      // Start pinching.\n      this.#isPinching = true;\n\n      // We return here else the first pinch is a bit too much\n      return;\n    }\n\n    const origin = [(screen0X + screen1X) / 2, (screen0Y + screen1Y) / 2];\n    this.#onPinching?.(origin, pDistance, distance);\n  }\n\n  #onTouchEnd(evt) {\n    if (evt.touches.length >= 2) {\n      return;\n    }\n    // #touchMoveAC shouldn't be null but it seems that irl it can (see #19793).\n    if (this.#touchMoveAC) {\n      this.#touchMoveAC.abort();\n      this.#touchMoveAC = null;\n      this.#onPinchEnd?.();\n    }\n\n    if (!this.#touchInfo) {\n      return;\n    }\n    stopEvent(evt);\n    this.#touchInfo = null;\n    this.#isPinching = false;\n  }\n\n  destroy() {\n    this.#touchManagerAC?.abort();\n    this.#touchManagerAC = null;\n    this.#pointerDownAC?.abort();\n    this.#pointerDownAC = null;\n  }\n}\n\nexport { TouchManager };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line max-len\n/** @typedef {import(\"./annotation_editor_layer.js\").AnnotationEditorLayer} AnnotationEditorLayer */\n\nimport {\n  AnnotationEditorUIManager,\n  bindEvents,\n  ColorManager,\n  KeyboardManager,\n} from \"./tools.js\";\nimport {\n  FeatureTest,\n  MathClamp,\n  shadow,\n  unreachable,\n} from \"../../shared/util.js\";\nimport { noContextMenu, stopEvent } from \"../display_utils.js\";\nimport { AltText } from \"./alt_text.js\";\nimport { Comment } from \"./comment.js\";\nimport { EditorToolbar } from \"./toolbar.js\";\nimport { TouchManager } from \"../touch_manager.js\";\n\n/**\n * @typedef {Object} AnnotationEditorParameters\n * @property {AnnotationEditorUIManager} uiManager - the global manager\n * @property {AnnotationEditorLayer} parent - the layer containing this editor\n * @property {string} id - editor id\n * @property {number} x - x-coordinate\n * @property {number} y - y-coordinate\n */\n\n/**\n * Base class for editors.\n */\nclass AnnotationEditor {\n  #accessibilityData = null;\n\n  #allResizerDivs = null;\n\n  #altText = null;\n\n  #comment = null;\n\n  #commentStandaloneButton = null;\n\n  #disabled = false;\n\n  #dragPointerId = null;\n\n  #dragPointerType = \"\";\n\n  #resizersDiv = null;\n\n  #lastPointerCoords = null;\n\n  #savedDimensions = null;\n\n  #fakeAnnotation = null;\n\n  #focusAC = null;\n\n  #focusedResizerName = \"\";\n\n  #hasBeenClicked = false;\n\n  #initialRect = null;\n\n  #isEditing = false;\n\n  #isInEditMode = false;\n\n  #isResizerEnabledForKeyboard = false;\n\n  #moveInDOMTimeout = null;\n\n  #prevDragX = 0;\n\n  #prevDragY = 0;\n\n  #telemetryTimeouts = null;\n\n  #touchManager = null;\n\n  isSelected = false;\n\n  _isCopy = false;\n\n  _editToolbar = null;\n\n  _initialOptions = Object.create(null);\n\n  _initialData = null;\n\n  _isVisible = true;\n\n  _uiManager = null;\n\n  _focusEventsAllowed = true;\n\n  static _l10n = null;\n\n  static _l10nResizer = null;\n\n  #isDraggable = false;\n\n  #zIndex = AnnotationEditor._zIndex++;\n\n  static _borderLineWidth = -1;\n\n  static _colorManager = new ColorManager();\n\n  static _zIndex = 1;\n\n  // Time to wait (in ms) before sending the telemetry data.\n  // We wait a bit to avoid sending too many requests when changing something\n  // like the thickness of a line.\n  static _telemetryTimeout = 1000;\n\n  static get _resizerKeyboardManager() {\n    const resize = AnnotationEditor.prototype._resizeWithKeyboard;\n    const small = AnnotationEditorUIManager.TRANSLATE_SMALL;\n    const big = AnnotationEditorUIManager.TRANSLATE_BIG;\n\n    return shadow(\n      this,\n      \"_resizerKeyboardManager\",\n      new KeyboardManager([\n        [[\"ArrowLeft\", \"mac+ArrowLeft\"], resize, { args: [-small, 0] }],\n        [\n          [\"ctrl+ArrowLeft\", \"mac+shift+ArrowLeft\"],\n          resize,\n          { args: [-big, 0] },\n        ],\n        [[\"ArrowRight\", \"mac+ArrowRight\"], resize, { args: [small, 0] }],\n        [\n          [\"ctrl+ArrowRight\", \"mac+shift+ArrowRight\"],\n          resize,\n          { args: [big, 0] },\n        ],\n        [[\"ArrowUp\", \"mac+ArrowUp\"], resize, { args: [0, -small] }],\n        [[\"ctrl+ArrowUp\", \"mac+shift+ArrowUp\"], resize, { args: [0, -big] }],\n        [[\"ArrowDown\", \"mac+ArrowDown\"], resize, { args: [0, small] }],\n        [[\"ctrl+ArrowDown\", \"mac+shift+ArrowDown\"], resize, { args: [0, big] }],\n        [\n          [\"Escape\", \"mac+Escape\"],\n          AnnotationEditor.prototype._stopResizingWithKeyboard,\n        ],\n      ])\n    );\n  }\n\n  /**\n   * @param {AnnotationEditorParameters} parameters\n   */\n  constructor(parameters) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === AnnotationEditor\n    ) {\n      unreachable(\"Cannot initialize AnnotationEditor.\");\n    }\n\n    this.parent = parameters.parent;\n    this.id = parameters.id;\n    this.width = this.height = null;\n    this.pageIndex = parameters.parent.pageIndex;\n    this.name = parameters.name;\n    this.div = null;\n    this._uiManager = parameters.uiManager;\n    this.annotationElementId = null;\n    this._willKeepAspectRatio = false;\n    this._initialOptions.isCentered = parameters.isCentered;\n    this._structTreeParentId = null;\n    this.annotationElementId = parameters.annotationElementId || null;\n    this.creationDate = parameters.creationDate || new Date();\n    this.modificationDate = parameters.modificationDate || null;\n    this.canAddComment = true;\n\n    const {\n      rotation,\n      rawDims: { pageWidth, pageHeight, pageX, pageY },\n    } = this.parent.viewport;\n\n    this.rotation = rotation;\n    this.pageRotation =\n      (360 + rotation - this._uiManager.viewParameters.rotation) % 360;\n    this.pageDimensions = [pageWidth, pageHeight];\n    this.pageTranslation = [pageX, pageY];\n\n    const [width, height] = this.parentDimensions;\n    this.x = parameters.x / width;\n    this.y = parameters.y / height;\n\n    this.isAttachedToDOM = false;\n    this.deleted = false;\n  }\n\n  updatePageIndex(newPageIndex) {\n    this.pageIndex = newPageIndex;\n  }\n\n  get editorType() {\n    return Object.getPrototypeOf(this).constructor._type;\n  }\n\n  get mode() {\n    return Object.getPrototypeOf(this).constructor._editorType;\n  }\n\n  static get isDrawer() {\n    return false;\n  }\n\n  static get _defaultLineColor() {\n    return shadow(\n      this,\n      \"_defaultLineColor\",\n      this._colorManager.getHexCode(\"CanvasText\")\n    );\n  }\n\n  static deleteAnnotationElement(editor) {\n    const fakeEditor = new FakeEditor({\n      id: editor.parent.getNextId(),\n      parent: editor.parent,\n      uiManager: editor._uiManager,\n    });\n    fakeEditor.annotationElementId = editor.annotationElementId;\n    fakeEditor.deleted = true;\n    fakeEditor._uiManager.addToAnnotationStorage(fakeEditor);\n  }\n\n  /**\n   * Initialize the l10n stuff for this type of editor.\n   * @param {Object} l10n\n   */\n  static initialize(l10n, _uiManager) {\n    AnnotationEditor._l10n ??= l10n;\n\n    AnnotationEditor._l10nResizer ||= Object.freeze({\n      topLeft: \"pdfjs-editor-resizer-top-left\",\n      topMiddle: \"pdfjs-editor-resizer-top-middle\",\n      topRight: \"pdfjs-editor-resizer-top-right\",\n      middleRight: \"pdfjs-editor-resizer-middle-right\",\n      bottomRight: \"pdfjs-editor-resizer-bottom-right\",\n      bottomMiddle: \"pdfjs-editor-resizer-bottom-middle\",\n      bottomLeft: \"pdfjs-editor-resizer-bottom-left\",\n      middleLeft: \"pdfjs-editor-resizer-middle-left\",\n    });\n\n    if (AnnotationEditor._borderLineWidth !== -1) {\n      return;\n    }\n    const style = getComputedStyle(document.documentElement);\n    AnnotationEditor._borderLineWidth =\n      parseFloat(style.getPropertyValue(\"--outline-width\")) || 0;\n  }\n\n  /**\n   * Update the default parameters for this type of editor.\n   * @param {number} _type\n   * @param {*} _value\n   */\n  static updateDefaultParams(_type, _value) {}\n\n  /**\n   * Get the default properties to set in the UI for this type of editor.\n   * @returns {Array}\n   */\n  static get defaultPropertiesToUpdate() {\n    return [];\n  }\n\n  /**\n   * Check if this kind of editor is able to handle the given mime type for\n   * pasting.\n   * @param {string} mime\n   * @returns {boolean}\n   */\n  static isHandlingMimeForPasting(mime) {\n    return false;\n  }\n\n  /**\n   * Extract the data from the clipboard item and delegate the creation of the\n   * editor to the parent.\n   * @param {DataTransferItem} item\n   * @param {AnnotationEditorLayer} parent\n   */\n  static paste(item, parent) {\n    unreachable(\"Not implemented\");\n  }\n\n  /**\n   * Get the properties to update in the UI for this editor.\n   * @returns {Array}\n   */\n  get propertiesToUpdate() {\n    return [];\n  }\n\n  get _isDraggable() {\n    return this.#isDraggable;\n  }\n\n  set _isDraggable(value) {\n    this.#isDraggable = value;\n    this.div?.classList.toggle(\"draggable\", value);\n  }\n\n  get uid() {\n    return this.annotationElementId || this.id;\n  }\n\n  /**\n   * @returns {boolean} true if the editor handles the Enter key itself.\n   */\n  get isEnterHandled() {\n    return true;\n  }\n\n  center() {\n    const [pageWidth, pageHeight] = this.pageDimensions;\n    switch (this.parentRotation) {\n      case 90:\n        this.x -= (this.height * pageHeight) / (pageWidth * 2);\n        this.y += (this.width * pageWidth) / (pageHeight * 2);\n        break;\n      case 180:\n        this.x += this.width / 2;\n        this.y += this.height / 2;\n        break;\n      case 270:\n        this.x += (this.height * pageHeight) / (pageWidth * 2);\n        this.y -= (this.width * pageWidth) / (pageHeight * 2);\n        break;\n      default:\n        this.x -= this.width / 2;\n        this.y -= this.height / 2;\n        break;\n    }\n    this.fixAndSetPosition();\n  }\n\n  /**\n   * Add some commands into the CommandManager (undo/redo stuff).\n   * @param {Object} params\n   */\n  addCommands(params) {\n    this._uiManager.addCommands(params);\n  }\n\n  get currentLayer() {\n    return this._uiManager.currentLayer;\n  }\n\n  /**\n   * This editor will be behind the others.\n   */\n  setInBackground() {\n    this.div.style.zIndex = 0;\n  }\n\n  /**\n   * This editor will be in the foreground.\n   */\n  setInForeground() {\n    this.div.style.zIndex = this.#zIndex;\n  }\n\n  setParent(parent) {\n    if (parent !== null) {\n      this.pageIndex = parent.pageIndex;\n      this.pageDimensions = parent.pageDimensions;\n    } else {\n      // The editor is being removed from the DOM, so we need to stop resizing.\n      this.#stopResizing();\n\n      // Remove the fake annotation in the annotation layer.\n      this.#fakeAnnotation?.remove();\n      this.#fakeAnnotation = null;\n    }\n    this.parent = parent;\n  }\n\n  /**\n   * onfocus callback.\n   */\n  focusin(event) {\n    if (!this._focusEventsAllowed) {\n      return;\n    }\n    if (!this.#hasBeenClicked) {\n      this.parent.setSelected(this);\n    } else {\n      this.#hasBeenClicked = false;\n    }\n  }\n\n  /**\n   * onblur callback.\n   * @param {FocusEvent} event\n   */\n  focusout(event) {\n    if (!this._focusEventsAllowed) {\n      return;\n    }\n\n    if (!this.isAttachedToDOM) {\n      return;\n    }\n\n    // In case of focusout, the relatedTarget is the element which\n    // is grabbing the focus.\n    // So if the related target is an element under the div for this\n    // editor, then the editor isn't unactive.\n    const target = event.relatedTarget;\n    if (target?.closest(`#${this.id}`)) {\n      return;\n    }\n\n    event.preventDefault();\n\n    if (!this.parent?.isMultipleSelection) {\n      this.commitOrRemove();\n    }\n  }\n\n  commitOrRemove() {\n    if (this.isEmpty()) {\n      this.remove();\n    } else {\n      this.commit();\n    }\n  }\n\n  /**\n   * Commit the data contained in this editor.\n   */\n  commit() {\n    if (!this.isInEditMode()) {\n      return;\n    }\n    this.addToAnnotationStorage();\n  }\n\n  addToAnnotationStorage() {\n    this._uiManager.addToAnnotationStorage(this);\n  }\n\n  /**\n   * Set the editor position within its parent.\n   * @param {number} x\n   * @param {number} y\n   * @param {number} tx - x-translation in screen coordinates.\n   * @param {number} ty - y-translation in screen coordinates.\n   */\n  setAt(x, y, tx, ty) {\n    const [width, height] = this.parentDimensions;\n    [tx, ty] = this.screenToPageTranslation(tx, ty);\n\n    this.x = (x + tx) / width;\n    this.y = (y + ty) / height;\n\n    this.fixAndSetPosition();\n  }\n\n  _moveAfterPaste(baseX, baseY) {\n    const [parentWidth, parentHeight] = this.parentDimensions;\n    this.setAt(\n      baseX * parentWidth,\n      baseY * parentHeight,\n      this.width * parentWidth,\n      this.height * parentHeight\n    );\n    this._onTranslated();\n  }\n\n  #translate([width, height], x, y) {\n    [x, y] = this.screenToPageTranslation(x, y);\n\n    this.x += x / width;\n    this.y += y / height;\n\n    this._onTranslating(this.x, this.y);\n\n    this.fixAndSetPosition();\n  }\n\n  /**\n   * Translate the editor position within its parent.\n   * @param {number} x - x-translation in screen coordinates.\n   * @param {number} y - y-translation in screen coordinates.\n   */\n  translate(x, y) {\n    // We don't change the initial position because the move here hasn't been\n    // done by the user.\n    this.#translate(this.parentDimensions, x, y);\n  }\n\n  /**\n   * Translate the editor position within its page and adjust the scroll\n   * in order to have the editor in the view.\n   * @param {number} x - x-translation in page coordinates.\n   * @param {number} y - y-translation in page coordinates.\n   */\n  translateInPage(x, y) {\n    this.#initialRect ||= [this.x, this.y, this.width, this.height];\n    this.#translate(this.pageDimensions, x, y);\n    this.div.scrollIntoView({ block: \"nearest\" });\n  }\n\n  translationDone() {\n    this._onTranslated(this.x, this.y);\n  }\n\n  drag(tx, ty) {\n    this.#initialRect ||= [this.x, this.y, this.width, this.height];\n    const {\n      div,\n      parentDimensions: [parentWidth, parentHeight],\n    } = this;\n    this.x += tx / parentWidth;\n    this.y += ty / parentHeight;\n    if (this.parent && (this.x < 0 || this.x > 1 || this.y < 0 || this.y > 1)) {\n      // It's possible to not have a parent: for example, when the user is\n      // dragging all the selected editors but this one on a page which has been\n      // destroyed.\n      // It's why we need to check for it. In such a situation, it isn't really\n      // a problem to not find a new parent: it's something which is related to\n      // what the user is seeing, hence it depends on how pages are layed out.\n\n      // The element will be outside of its parent so change the parent.\n      const { x, y } = this.div.getBoundingClientRect();\n      if (this.parent.findNewParent(this, x, y)) {\n        this.x -= Math.floor(this.x);\n        this.y -= Math.floor(this.y);\n      }\n    }\n\n    // The editor can be moved wherever the user wants, so we don't need to fix\n    // the position: it'll be done when the user will release the mouse button.\n\n    let { x, y } = this;\n    const [bx, by] = this.getBaseTranslation();\n    x += bx;\n    y += by;\n\n    const { style } = div;\n    style.left = `${(100 * x).toFixed(2)}%`;\n    style.top = `${(100 * y).toFixed(2)}%`;\n\n    this._onTranslating(x, y);\n\n    div.scrollIntoView({ block: \"nearest\" });\n  }\n\n  /**\n   * Called when the editor is being translated.\n   * @param {number} x - in page coordinates.\n   * @param {number} y - in page coordinates.\n   */\n  _onTranslating(x, y) {}\n\n  /**\n   * Called when the editor has been translated.\n   * @param {number} x - in page coordinates.\n   * @param {number} y - in page coordinates.\n   */\n  _onTranslated(x, y) {}\n\n  get _hasBeenMoved() {\n    return (\n      !!this.#initialRect &&\n      (this.#initialRect[0] !== this.x || this.#initialRect[1] !== this.y)\n    );\n  }\n\n  get _hasBeenResized() {\n    return (\n      !!this.#initialRect &&\n      (this.#initialRect[2] !== this.width ||\n        this.#initialRect[3] !== this.height)\n    );\n  }\n\n  /**\n   * Get the translation to take into account the editor border.\n   * The CSS engine positions the element by taking the border into account so\n   * we must apply the opposite translation to have the editor in the right\n   * position.\n   * @returns {Array<number>}\n   */\n  getBaseTranslation() {\n    const [parentWidth, parentHeight] = this.parentDimensions;\n    const { _borderLineWidth } = AnnotationEditor;\n    const x = _borderLineWidth / parentWidth;\n    const y = _borderLineWidth / parentHeight;\n    switch (this.rotation) {\n      case 90:\n        return [-x, y];\n      case 180:\n        return [x, y];\n      case 270:\n        return [x, -y];\n      default:\n        return [-x, -y];\n    }\n  }\n\n  /**\n   * @returns {boolean} true if position must be fixed (i.e. make the x and y\n   * living in the page).\n   */\n  get _mustFixPosition() {\n    return true;\n  }\n\n  /**\n   * Fix the position of the editor in order to keep it inside its parent page.\n   * @param {number} [rotation] - the rotation of the page.\n   */\n  fixAndSetPosition(rotation = this.rotation) {\n    const {\n      div: { style },\n      pageDimensions: [pageWidth, pageHeight],\n    } = this;\n    let { x, y, width, height } = this;\n    width *= pageWidth;\n    height *= pageHeight;\n    x *= pageWidth;\n    y *= pageHeight;\n\n    if (this._mustFixPosition) {\n      switch (rotation) {\n        case 0:\n          x = MathClamp(x, 0, pageWidth - width);\n          y = MathClamp(y, 0, pageHeight - height);\n          break;\n        case 90:\n          x = MathClamp(x, 0, pageWidth - height);\n          y = MathClamp(y, width, pageHeight);\n          break;\n        case 180:\n          x = MathClamp(x, width, pageWidth);\n          y = MathClamp(y, height, pageHeight);\n          break;\n        case 270:\n          x = MathClamp(x, height, pageWidth);\n          y = MathClamp(y, 0, pageHeight - width);\n          break;\n      }\n    }\n\n    this.x = x /= pageWidth;\n    this.y = y /= pageHeight;\n\n    const [bx, by] = this.getBaseTranslation();\n    x += bx;\n    y += by;\n\n    style.left = `${(100 * x).toFixed(2)}%`;\n    style.top = `${(100 * y).toFixed(2)}%`;\n\n    this.moveInDOM();\n  }\n\n  static #rotatePoint(x, y, angle) {\n    switch (angle) {\n      case 90:\n        return [y, -x];\n      case 180:\n        return [-x, -y];\n      case 270:\n        return [-y, x];\n      default:\n        return [x, y];\n    }\n  }\n\n  /**\n   * Convert a screen translation into a page one.\n   * @param {number} x\n   * @param {number} y\n   */\n  screenToPageTranslation(x, y) {\n    return AnnotationEditor.#rotatePoint(x, y, this.parentRotation);\n  }\n\n  /**\n   * Convert a page translation into a screen one.\n   * @param {number} x\n   * @param {number} y\n   */\n  pageTranslationToScreen(x, y) {\n    return AnnotationEditor.#rotatePoint(x, y, 360 - this.parentRotation);\n  }\n\n  #getRotationMatrix(rotation) {\n    switch (rotation) {\n      case 90: {\n        const [pageWidth, pageHeight] = this.pageDimensions;\n        return [0, -pageWidth / pageHeight, pageHeight / pageWidth, 0];\n      }\n      case 180:\n        return [-1, 0, 0, -1];\n      case 270: {\n        const [pageWidth, pageHeight] = this.pageDimensions;\n        return [0, pageWidth / pageHeight, -pageHeight / pageWidth, 0];\n      }\n      default:\n        return [1, 0, 0, 1];\n    }\n  }\n\n  get parentScale() {\n    return this._uiManager.viewParameters.realScale;\n  }\n\n  get parentRotation() {\n    return (this._uiManager.viewParameters.rotation + this.pageRotation) % 360;\n  }\n\n  get parentDimensions() {\n    const {\n      parentScale,\n      pageDimensions: [pageWidth, pageHeight],\n    } = this;\n    return [pageWidth * parentScale, pageHeight * parentScale];\n  }\n\n  /**\n   * Set the dimensions of this editor.\n   */\n  setDims() {\n    const {\n      div: { style },\n      width,\n      height,\n    } = this;\n    style.width = `${(100 * width).toFixed(2)}%`;\n    style.height = `${(100 * height).toFixed(2)}%`;\n  }\n\n  /**\n   * Get the translation used to position this editor when it's created.\n   * @returns {Array<number>}\n   */\n  getInitialTranslation() {\n    return [0, 0];\n  }\n\n  #createResizers() {\n    if (this.#resizersDiv) {\n      return;\n    }\n    this.#resizersDiv = document.createElement(\"div\");\n    this.#resizersDiv.classList.add(\"resizers\");\n    // When the resizers are used with the keyboard, they're focusable, hence\n    // we want to have them in this order (top left, top middle, top right, ...)\n    // in the DOM to have the focus order correct.\n    const classes = this._willKeepAspectRatio\n      ? [\"topLeft\", \"topRight\", \"bottomRight\", \"bottomLeft\"]\n      : [\n          \"topLeft\",\n          \"topMiddle\",\n          \"topRight\",\n          \"middleRight\",\n          \"bottomRight\",\n          \"bottomMiddle\",\n          \"bottomLeft\",\n          \"middleLeft\",\n        ];\n    const signal = this._uiManager._signal;\n    for (const name of classes) {\n      const div = document.createElement(\"div\");\n      this.#resizersDiv.append(div);\n      div.classList.add(\"resizer\", name);\n      div.setAttribute(\"data-resizer-name\", name);\n      div.addEventListener(\n        \"pointerdown\",\n        this.#resizerPointerdown.bind(this, name),\n        { signal }\n      );\n      div.addEventListener(\"contextmenu\", noContextMenu, { signal });\n      div.tabIndex = -1;\n    }\n    this.div.prepend(this.#resizersDiv);\n  }\n\n  #resizerPointerdown(name, event) {\n    event.preventDefault();\n    const { isMac } = FeatureTest.platform;\n    if (event.button !== 0 || (event.ctrlKey && isMac)) {\n      return;\n    }\n\n    this.#altText?.toggle(false);\n\n    const savedDraggable = this._isDraggable;\n    this._isDraggable = false;\n    this.#lastPointerCoords = [event.screenX, event.screenY];\n\n    const ac = new AbortController();\n    const signal = this._uiManager.combinedSignal(ac);\n\n    this.parent.togglePointerEvents(false);\n    window.addEventListener(\n      \"pointermove\",\n      this.#resizerPointermove.bind(this, name),\n      { passive: true, capture: true, signal }\n    );\n    window.addEventListener(\n      \"touchmove\",\n      stopEvent /* Prevent the page from scrolling */,\n      { passive: false, signal }\n    );\n    window.addEventListener(\"contextmenu\", noContextMenu, { signal });\n    this.#savedDimensions = {\n      savedX: this.x,\n      savedY: this.y,\n      savedWidth: this.width,\n      savedHeight: this.height,\n    };\n    const savedParentCursor = this.parent.div.style.cursor;\n    const savedCursor = this.div.style.cursor;\n    this.div.style.cursor = this.parent.div.style.cursor =\n      window.getComputedStyle(event.target).cursor;\n\n    const pointerUpCallback = () => {\n      ac.abort();\n      this.parent.togglePointerEvents(true);\n      this.#altText?.toggle(true);\n      this._isDraggable = savedDraggable;\n      this.parent.div.style.cursor = savedParentCursor;\n      this.div.style.cursor = savedCursor;\n\n      this.#addResizeToUndoStack();\n    };\n    window.addEventListener(\"pointerup\", pointerUpCallback, { signal });\n    // If the user switches to another window (with alt+tab), then we end the\n    // resize session.\n    window.addEventListener(\"blur\", pointerUpCallback, { signal });\n  }\n\n  #resize(x, y, width, height) {\n    this.width = width;\n    this.height = height;\n    this.x = x;\n    this.y = y;\n    this.setDims();\n    this.fixAndSetPosition();\n    this._onResized();\n  }\n\n  /**\n   * Called when the editor has been resized.\n   */\n  _onResized() {}\n\n  #addResizeToUndoStack() {\n    if (!this.#savedDimensions) {\n      return;\n    }\n    const { savedX, savedY, savedWidth, savedHeight } = this.#savedDimensions;\n    this.#savedDimensions = null;\n\n    const newX = this.x;\n    const newY = this.y;\n    const newWidth = this.width;\n    const newHeight = this.height;\n    if (\n      newX === savedX &&\n      newY === savedY &&\n      newWidth === savedWidth &&\n      newHeight === savedHeight\n    ) {\n      return;\n    }\n\n    this.addCommands({\n      cmd: this.#resize.bind(this, newX, newY, newWidth, newHeight),\n      undo: this.#resize.bind(this, savedX, savedY, savedWidth, savedHeight),\n      mustExec: true,\n    });\n  }\n\n  static _round(x) {\n    // 10000 because we multiply by 100 and use toFixed(2) in fixAndSetPosition.\n    // Without rounding, the positions of the corners other than the top left\n    // one can be slightly wrong.\n    return Math.round(x * 10000) / 10000;\n  }\n\n  #resizerPointermove(name, event) {\n    const [parentWidth, parentHeight] = this.parentDimensions;\n    const savedX = this.x;\n    const savedY = this.y;\n    const savedWidth = this.width;\n    const savedHeight = this.height;\n    const minWidth = AnnotationEditor.MIN_SIZE / parentWidth;\n    const minHeight = AnnotationEditor.MIN_SIZE / parentHeight;\n\n    const rotationMatrix = this.#getRotationMatrix(this.rotation);\n    const transf = (x, y) => [\n      rotationMatrix[0] * x + rotationMatrix[2] * y,\n      rotationMatrix[1] * x + rotationMatrix[3] * y,\n    ];\n    const invRotationMatrix = this.#getRotationMatrix(360 - this.rotation);\n    const invTransf = (x, y) => [\n      invRotationMatrix[0] * x + invRotationMatrix[2] * y,\n      invRotationMatrix[1] * x + invRotationMatrix[3] * y,\n    ];\n    let getPoint;\n    let getOpposite;\n    let isDiagonal = false;\n    let isHorizontal = false;\n\n    switch (name) {\n      case \"topLeft\":\n        isDiagonal = true;\n        getPoint = (w, h) => [0, 0];\n        getOpposite = (w, h) => [w, h];\n        break;\n      case \"topMiddle\":\n        getPoint = (w, h) => [w / 2, 0];\n        getOpposite = (w, h) => [w / 2, h];\n        break;\n      case \"topRight\":\n        isDiagonal = true;\n        getPoint = (w, h) => [w, 0];\n        getOpposite = (w, h) => [0, h];\n        break;\n      case \"middleRight\":\n        isHorizontal = true;\n        getPoint = (w, h) => [w, h / 2];\n        getOpposite = (w, h) => [0, h / 2];\n        break;\n      case \"bottomRight\":\n        isDiagonal = true;\n        getPoint = (w, h) => [w, h];\n        getOpposite = (w, h) => [0, 0];\n        break;\n      case \"bottomMiddle\":\n        getPoint = (w, h) => [w / 2, h];\n        getOpposite = (w, h) => [w / 2, 0];\n        break;\n      case \"bottomLeft\":\n        isDiagonal = true;\n        getPoint = (w, h) => [0, h];\n        getOpposite = (w, h) => [w, 0];\n        break;\n      case \"middleLeft\":\n        isHorizontal = true;\n        getPoint = (w, h) => [0, h / 2];\n        getOpposite = (w, h) => [w, h / 2];\n        break;\n    }\n\n    const point = getPoint(savedWidth, savedHeight);\n    const oppositePoint = getOpposite(savedWidth, savedHeight);\n    let transfOppositePoint = transf(...oppositePoint);\n    const oppositeX = AnnotationEditor._round(savedX + transfOppositePoint[0]);\n    const oppositeY = AnnotationEditor._round(savedY + transfOppositePoint[1]);\n    let ratioX = 1;\n    let ratioY = 1;\n\n    let deltaX, deltaY;\n\n    if (!event.fromKeyboard) {\n      // We can't use event.movementX/Y because they're not reliable:\n      //  https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX\n      // (it was buggy on a laptop with a touch screen).\n      const { screenX, screenY } = event;\n      const [lastScreenX, lastScreenY] = this.#lastPointerCoords;\n      [deltaX, deltaY] = this.screenToPageTranslation(\n        screenX - lastScreenX,\n        screenY - lastScreenY\n      );\n      this.#lastPointerCoords[0] = screenX;\n      this.#lastPointerCoords[1] = screenY;\n    } else {\n      ({ deltaX, deltaY } = event);\n    }\n    [deltaX, deltaY] = invTransf(deltaX / parentWidth, deltaY / parentHeight);\n\n    if (isDiagonal) {\n      const oldDiag = Math.hypot(savedWidth, savedHeight);\n      ratioX = ratioY = Math.max(\n        Math.min(\n          Math.hypot(\n            oppositePoint[0] - point[0] - deltaX,\n            oppositePoint[1] - point[1] - deltaY\n          ) / oldDiag,\n          // Avoid the editor to be larger than the page.\n          1 / savedWidth,\n          1 / savedHeight\n        ),\n        // Avoid the editor to be smaller than the minimum size.\n        minWidth / savedWidth,\n        minHeight / savedHeight\n      );\n    } else if (isHorizontal) {\n      ratioX =\n        MathClamp(Math.abs(oppositePoint[0] - point[0] - deltaX), minWidth, 1) /\n        savedWidth;\n    } else {\n      ratioY =\n        MathClamp(\n          Math.abs(oppositePoint[1] - point[1] - deltaY),\n          minHeight,\n          1\n        ) / savedHeight;\n    }\n\n    const newWidth = AnnotationEditor._round(savedWidth * ratioX);\n    const newHeight = AnnotationEditor._round(savedHeight * ratioY);\n    transfOppositePoint = transf(...getOpposite(newWidth, newHeight));\n    const newX = oppositeX - transfOppositePoint[0];\n    const newY = oppositeY - transfOppositePoint[1];\n\n    this.#initialRect ||= [this.x, this.y, this.width, this.height];\n    this.width = newWidth;\n    this.height = newHeight;\n    this.x = newX;\n    this.y = newY;\n\n    this.setDims();\n    this.fixAndSetPosition();\n\n    this._onResizing();\n  }\n\n  /**\n   * Called when the editor is being resized.\n   */\n  _onResizing() {}\n\n  /**\n   * Called when the alt text dialog is closed.\n   */\n  altTextFinish() {\n    this.#altText?.finish();\n  }\n\n  /**\n   * Get the toolbar buttons for this editor.\n   * @returns {Array<Array<string|object|null>>|null}\n   */\n  get toolbarButtons() {\n    return null;\n  }\n\n  /**\n   * Add a toolbar for this editor.\n   * @returns {Promise<EditorToolbar|null>}\n   */\n  async addEditToolbar() {\n    if (this._editToolbar || this.#isInEditMode) {\n      return this._editToolbar;\n    }\n    this._editToolbar = new EditorToolbar(this);\n    this.div.append(this._editToolbar.render());\n    const { toolbarButtons } = this;\n    if (toolbarButtons) {\n      for (const [name, tool] of toolbarButtons) {\n        await this._editToolbar.addButton(name, tool);\n      }\n    }\n    if (!this.hasComment) {\n      this._editToolbar.addButton(\"comment\", this.addCommentButton());\n    }\n    this._editToolbar.addButton(\"delete\");\n\n    return this._editToolbar;\n  }\n\n  addCommentButtonInToolbar() {\n    this._editToolbar?.addButtonBefore(\n      \"comment\",\n      this.addCommentButton(),\n      \".deleteButton\"\n    );\n  }\n\n  removeCommentButtonFromToolbar() {\n    this._editToolbar?.removeButton(\"comment\");\n  }\n\n  removeEditToolbar() {\n    this._editToolbar?.remove();\n    this._editToolbar = null;\n\n    // We destroy the alt text but we don't null it because we want to be able\n    // to restore it in case the user undoes the deletion.\n    this.#altText?.destroy();\n  }\n\n  addContainer(container) {\n    const editToolbarDiv = this._editToolbar?.div;\n    if (editToolbarDiv) {\n      editToolbarDiv.before(container);\n    } else {\n      this.div.append(container);\n    }\n  }\n\n  getClientDimensions() {\n    return this.div.getBoundingClientRect();\n  }\n\n  /**\n   * Create the alt text for this editor.\n   * @returns {object}\n   */\n  createAltText() {\n    if (!this.#altText) {\n      AltText.initialize(AnnotationEditor._l10n);\n      this.#altText = new AltText(this);\n      if (this.#accessibilityData) {\n        this.#altText.data = this.#accessibilityData;\n        this.#accessibilityData = null;\n      }\n    }\n    return this.#altText;\n  }\n\n  get altTextData() {\n    return this.#altText?.data;\n  }\n\n  /**\n   * Set the alt text data.\n   */\n  set altTextData(data) {\n    if (!this.#altText) {\n      return;\n    }\n    this.#altText.data = data;\n  }\n\n  get guessedAltText() {\n    return this.#altText?.guessedText;\n  }\n\n  async setGuessedAltText(text) {\n    await this.#altText?.setGuessedText(text);\n  }\n\n  serializeAltText(isForCopying) {\n    return this.#altText?.serialize(isForCopying);\n  }\n\n  hasAltText() {\n    return !!this.#altText && !this.#altText.isEmpty();\n  }\n\n  hasAltTextData() {\n    return this.#altText?.hasData() ?? false;\n  }\n\n  focusCommentButton() {\n    this.#comment?.focusButton();\n  }\n\n  addCommentButton() {\n    return this.canAddComment ? (this.#comment ||= new Comment(this)) : null;\n  }\n\n  addStandaloneCommentButton() {\n    if (!this._uiManager.hasCommentManager()) {\n      return;\n    }\n    if (this.#commentStandaloneButton) {\n      if (this._uiManager.isEditingMode()) {\n        this.#commentStandaloneButton.classList.remove(\"hidden\");\n      }\n      return;\n    }\n    if (!this.hasComment) {\n      return;\n    }\n    this.#commentStandaloneButton = this.#comment.renderForStandalone();\n    this.div.append(this.#commentStandaloneButton);\n  }\n\n  removeStandaloneCommentButton() {\n    this.#comment.removeStandaloneCommentButton();\n    this.#commentStandaloneButton = null;\n  }\n\n  hideStandaloneCommentButton() {\n    this.#commentStandaloneButton?.classList.add(\"hidden\");\n  }\n\n  get comment() {\n    if (!this.#comment) {\n      return null;\n    }\n    const {\n      data: { richText, text, date, deleted },\n    } = this.#comment;\n    return {\n      text,\n      richText,\n      date,\n      deleted,\n      color: this.getNonHCMColor(),\n      opacity: this.opacity ?? 1,\n    };\n  }\n\n  set comment(value) {\n    this.#comment ||= new Comment(this);\n    if (typeof value === \"object\" && value !== null) {\n      // Restore full comment data (used for undo).\n      this.#comment.restoreData(value);\n    } else {\n      this.#comment.data = value;\n    }\n    if (this.hasComment) {\n      this.removeCommentButtonFromToolbar();\n      this.addStandaloneCommentButton();\n      this._uiManager.updateComment(this);\n    } else {\n      this.addCommentButtonInToolbar();\n      this.removeStandaloneCommentButton();\n      this._uiManager.removeComment(this);\n    }\n  }\n\n  setCommentData({ comment, popupRef, richText }) {\n    if (!popupRef) {\n      return;\n    }\n    this.#comment ||= new Comment(this);\n    this.#comment.setInitialText(comment, richText);\n\n    if (!this.annotationElementId) {\n      return;\n    }\n    const storedData = this._uiManager.getAndRemoveDataFromAnnotationStorage(\n      this.annotationElementId\n    );\n    if (storedData) {\n      this.updateFromAnnotationLayer(storedData);\n    }\n  }\n\n  get hasEditedComment() {\n    return this.#comment?.hasBeenEdited();\n  }\n\n  get hasDeletedComment() {\n    return this.#comment?.isDeleted();\n  }\n\n  get hasComment() {\n    return (\n      !!this.#comment && !this.#comment.isEmpty() && !this.#comment.isDeleted()\n    );\n  }\n\n  async editComment(options) {\n    this.#comment ||= new Comment(this);\n    this.#comment.edit(options);\n  }\n\n  toggleComment(isSelected, visibility = undefined) {\n    if (this.hasComment) {\n      this._uiManager.toggleComment(this, isSelected, visibility);\n    }\n  }\n\n  setSelectedCommentButton(selected) {\n    this.#comment.setSelectedButton(selected);\n  }\n\n  addComment(serialized) {\n    if (this.hasEditedComment) {\n      const DEFAULT_POPUP_WIDTH = 180;\n      const DEFAULT_POPUP_HEIGHT = 100;\n      const [, , , trY] = serialized.rect;\n      const [pageWidth] = this.pageDimensions;\n      const [pageX] = this.pageTranslation;\n      const blX = pageX + pageWidth + 1;\n      const blY = trY - DEFAULT_POPUP_HEIGHT;\n      const trX = blX + DEFAULT_POPUP_WIDTH;\n      serialized.popup = {\n        contents: this.comment.text,\n        deleted: this.comment.deleted,\n        rect: [blX, blY, trX, trY],\n      };\n    }\n  }\n\n  updateFromAnnotationLayer({ popup: { contents, deleted } }) {\n    this.#comment.data = deleted ? null : contents;\n  }\n\n  get parentBoundingClientRect() {\n    return this.parent.boundingClientRect;\n  }\n\n  /**\n   * Render this editor in a div.\n   * @returns {HTMLDivElement | null}\n   */\n  render() {\n    const div = (this.div = document.createElement(\"div\"));\n    div.setAttribute(\"data-editor-rotation\", (360 - this.rotation) % 360);\n    div.className = this.name;\n    div.setAttribute(\"id\", this.id);\n    div.tabIndex = this.#disabled ? -1 : 0;\n    div.setAttribute(\"role\", \"application\");\n    if (this.defaultL10nId) {\n      div.setAttribute(\"data-l10n-id\", this.defaultL10nId);\n    }\n    if (!this._isVisible) {\n      div.classList.add(\"hidden\");\n    }\n\n    this.setInForeground();\n    this.#addFocusListeners();\n\n    const [parentWidth, parentHeight] = this.parentDimensions;\n    if (this.parentRotation % 180 !== 0) {\n      div.style.maxWidth = `${((100 * parentHeight) / parentWidth).toFixed(\n        2\n      )}%`;\n      div.style.maxHeight = `${((100 * parentWidth) / parentHeight).toFixed(\n        2\n      )}%`;\n    }\n\n    const [tx, ty] = this.getInitialTranslation();\n    this.translate(tx, ty);\n\n    bindEvents(this, div, [\"keydown\", \"pointerdown\", \"dblclick\"]);\n\n    if (this.isResizable && this._uiManager._supportsPinchToZoom) {\n      this.#touchManager ||= new TouchManager({\n        container: div,\n        isPinchingDisabled: () => !this.isSelected,\n        onPinchStart: this.#touchPinchStartCallback.bind(this),\n        onPinching: this.#touchPinchCallback.bind(this),\n        onPinchEnd: this.#touchPinchEndCallback.bind(this),\n        signal: this._uiManager._signal,\n      });\n    }\n\n    this.addStandaloneCommentButton();\n    this._uiManager._editorUndoBar?.hide();\n\n    return div;\n  }\n\n  #touchPinchStartCallback() {\n    this.#savedDimensions = {\n      savedX: this.x,\n      savedY: this.y,\n      savedWidth: this.width,\n      savedHeight: this.height,\n    };\n    this.#altText?.toggle(false);\n    this.parent.togglePointerEvents(false);\n  }\n\n  #touchPinchCallback(_origin, prevDistance, distance) {\n    // Slightly slow down the zooming because the editor could be small and the\n    // user could have difficulties to rescale it as they want.\n    const slowDownFactor = 0.7;\n    let factor =\n      slowDownFactor * (distance / prevDistance) + 1 - slowDownFactor;\n    if (factor === 1) {\n      return;\n    }\n\n    const rotationMatrix = this.#getRotationMatrix(this.rotation);\n    const transf = (x, y) => [\n      rotationMatrix[0] * x + rotationMatrix[2] * y,\n      rotationMatrix[1] * x + rotationMatrix[3] * y,\n    ];\n\n    // The center of the editor is the fixed point.\n    const [parentWidth, parentHeight] = this.parentDimensions;\n    const savedX = this.x;\n    const savedY = this.y;\n    const savedWidth = this.width;\n    const savedHeight = this.height;\n\n    const minWidth = AnnotationEditor.MIN_SIZE / parentWidth;\n    const minHeight = AnnotationEditor.MIN_SIZE / parentHeight;\n    factor = Math.max(\n      Math.min(factor, 1 / savedWidth, 1 / savedHeight),\n      minWidth / savedWidth,\n      minHeight / savedHeight\n    );\n    const newWidth = AnnotationEditor._round(savedWidth * factor);\n    const newHeight = AnnotationEditor._round(savedHeight * factor);\n    if (newWidth === savedWidth && newHeight === savedHeight) {\n      return;\n    }\n\n    this.#initialRect ||= [savedX, savedY, savedWidth, savedHeight];\n    const transfCenterPoint = transf(savedWidth / 2, savedHeight / 2);\n    const centerX = AnnotationEditor._round(savedX + transfCenterPoint[0]);\n    const centerY = AnnotationEditor._round(savedY + transfCenterPoint[1]);\n    const newTransfCenterPoint = transf(newWidth / 2, newHeight / 2);\n\n    this.x = centerX - newTransfCenterPoint[0];\n    this.y = centerY - newTransfCenterPoint[1];\n    this.width = newWidth;\n    this.height = newHeight;\n\n    this.setDims();\n    this.fixAndSetPosition();\n\n    this._onResizing();\n  }\n\n  #touchPinchEndCallback() {\n    this.#altText?.toggle(true);\n    this.parent.togglePointerEvents(true);\n    this.#addResizeToUndoStack();\n  }\n\n  /**\n   * Onpointerdown callback.\n   * @param {PointerEvent} event\n   */\n  pointerdown(event) {\n    const { isMac } = FeatureTest.platform;\n    if (event.button !== 0 || (event.ctrlKey && isMac)) {\n      // Avoid to focus this editor because of a non-left click.\n      event.preventDefault();\n      return;\n    }\n    this.#hasBeenClicked = true;\n\n    if (this._isDraggable) {\n      this.#setUpDragSession(event);\n      return;\n    }\n\n    this.#selectOnPointerEvent(event);\n  }\n\n  #selectOnPointerEvent(event) {\n    const { isMac } = FeatureTest.platform;\n    if (\n      (event.ctrlKey && !isMac) ||\n      event.shiftKey ||\n      (event.metaKey && isMac)\n    ) {\n      this.parent.toggleSelected(this);\n    } else {\n      this.parent.setSelected(this);\n    }\n  }\n\n  #setUpDragSession(event) {\n    const { isSelected } = this;\n    this._uiManager.setUpDragSession();\n    let hasDraggingStarted = false;\n\n    const ac = new AbortController();\n    const signal = this._uiManager.combinedSignal(ac);\n    const opts = { capture: true, passive: false, signal };\n    const cancelDrag = e => {\n      ac.abort();\n\n      this.#dragPointerId = null;\n      this.#hasBeenClicked = false;\n      if (!this._uiManager.endDragSession()) {\n        this.#selectOnPointerEvent(e);\n      }\n      if (hasDraggingStarted) {\n        this._onStopDragging();\n      }\n    };\n\n    if (isSelected) {\n      this.#prevDragX = event.clientX;\n      this.#prevDragY = event.clientY;\n      this.#dragPointerId = event.pointerId;\n      this.#dragPointerType = event.pointerType;\n      window.addEventListener(\n        \"pointermove\",\n        e => {\n          if (!hasDraggingStarted) {\n            hasDraggingStarted = true;\n            this._uiManager.toggleComment(\n              this,\n              /* isSelected = */ true,\n              /* visibility = */ false\n            );\n            this._onStartDragging();\n          }\n          const { clientX: x, clientY: y, pointerId } = e;\n          if (pointerId !== this.#dragPointerId) {\n            stopEvent(e);\n            return;\n          }\n          const [tx, ty] = this.screenToPageTranslation(\n            x - this.#prevDragX,\n            y - this.#prevDragY\n          );\n          this.#prevDragX = x;\n          this.#prevDragY = y;\n          this._uiManager.dragSelectedEditors(tx, ty);\n        },\n        opts\n      );\n      window.addEventListener(\n        \"touchmove\",\n        stopEvent /* Prevent the page from scrolling */,\n        opts\n      );\n      window.addEventListener(\n        \"pointerdown\",\n        // If the user drags with one finger and then clicks with another.\n        e => {\n          if (e.pointerType === this.#dragPointerType) {\n            // We've a pinch to zoom session.\n            // We cannot have two primaries at the same time.\n            // It's possible to be in this state with Firefox and Gnome when\n            // trying to drag with three fingers (see bug 1933716).\n            if (this.#touchManager || e.isPrimary) {\n              cancelDrag(e);\n            }\n          }\n          stopEvent(e);\n        },\n        opts\n      );\n    }\n\n    const pointerUpCallback = e => {\n      if (!this.#dragPointerId || this.#dragPointerId === e.pointerId) {\n        cancelDrag(e);\n        return;\n      }\n      stopEvent(e);\n    };\n    window.addEventListener(\"pointerup\", pointerUpCallback, { signal });\n    // If the user is using alt+tab during the dragging session, the pointerup\n    // event could be not fired, but a blur event is fired so we can use it in\n    // order to interrupt the dragging session.\n    window.addEventListener(\"blur\", pointerUpCallback, { signal });\n  }\n\n  _onStartDragging() {}\n\n  _onStopDragging() {}\n\n  moveInDOM() {\n    // Moving the editor in the DOM can be expensive, so we wait a bit before.\n    // It's important to not block the UI (for example when changing the font\n    // size in a FreeText).\n    if (this.#moveInDOMTimeout) {\n      clearTimeout(this.#moveInDOMTimeout);\n    }\n    this.#moveInDOMTimeout = setTimeout(() => {\n      this.#moveInDOMTimeout = null;\n      this.parent?.moveEditorInDOM(this);\n      if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n        this._uiManager._eventBus.dispatch(\"editormovedindom\", {\n          source: this,\n        });\n      }\n    }, 0);\n  }\n\n  _setParentAndPosition(parent, x, y) {\n    parent.changeParent(this);\n    this.x = x;\n    this.y = y;\n    this.fixAndSetPosition();\n    this._onTranslated();\n  }\n\n  /**\n   * Convert the current rect into a page one.\n   * @param {number} tx - x-translation in screen coordinates.\n   * @param {number} ty - y-translation in screen coordinates.\n   * @param {number} [rotation] - the rotation of the page.\n   */\n  getRect(tx, ty, rotation = this.rotation) {\n    const scale = this.parentScale;\n    const [pageWidth, pageHeight] = this.pageDimensions;\n    const [pageX, pageY] = this.pageTranslation;\n    const shiftX = tx / scale;\n    const shiftY = ty / scale;\n    const x = this.x * pageWidth;\n    const y = this.y * pageHeight;\n    const width = this.width * pageWidth;\n    const height = this.height * pageHeight;\n\n    switch (rotation) {\n      case 0:\n        return [\n          x + shiftX + pageX,\n          pageHeight - y - shiftY - height + pageY,\n          x + shiftX + width + pageX,\n          pageHeight - y - shiftY + pageY,\n        ];\n      case 90:\n        return [\n          x + shiftY + pageX,\n          pageHeight - y + shiftX + pageY,\n          x + shiftY + height + pageX,\n          pageHeight - y + shiftX + width + pageY,\n        ];\n      case 180:\n        return [\n          x - shiftX - width + pageX,\n          pageHeight - y + shiftY + pageY,\n          x - shiftX + pageX,\n          pageHeight - y + shiftY + height + pageY,\n        ];\n      case 270:\n        return [\n          x - shiftY - height + pageX,\n          pageHeight - y - shiftX - width + pageY,\n          x - shiftY + pageX,\n          pageHeight - y - shiftX + pageY,\n        ];\n      default:\n        throw new Error(\"Invalid rotation\");\n    }\n  }\n\n  getRectInCurrentCoords(rect, pageHeight) {\n    const [x1, y1, x2, y2] = rect;\n\n    const width = x2 - x1;\n    const height = y2 - y1;\n\n    switch (this.rotation) {\n      case 0:\n        return [x1, pageHeight - y2, width, height];\n      case 90:\n        return [x1, pageHeight - y1, height, width];\n      case 180:\n        return [x2, pageHeight - y1, width, height];\n      case 270:\n        return [x2, pageHeight - y2, height, width];\n      default:\n        throw new Error(\"Invalid rotation\");\n    }\n  }\n\n  /**\n   * Get the rect in page coordinates without any translation.\n   * It's used when serializing the editor.\n   * @returns {Array<number>}\n   */\n  getPDFRect() {\n    return this.getRect(0, 0);\n  }\n\n  getNonHCMColor() {\n    return (\n      this.color &&\n      AnnotationEditor._colorManager.convert(\n        this._uiManager.getNonHCMColor(this.color)\n      )\n    );\n  }\n\n  /**\n   * The color has been changed.\n   */\n  onUpdatedColor() {\n    this.#comment?.onUpdatedColor();\n  }\n\n  getData() {\n    const {\n      comment: { text: str, color, date, opacity, deleted, richText },\n      uid: id,\n      pageIndex,\n      creationDate,\n      modificationDate,\n    } = this;\n    return {\n      id,\n      pageIndex,\n      rect: this.getPDFRect(),\n      richText,\n      contentsObj: { str },\n      creationDate,\n      modificationDate: date || modificationDate,\n      popupRef: !deleted,\n      color,\n      opacity,\n    };\n  }\n\n  /**\n   * Executed once this editor has been rendered.\n   * @param {boolean} focus - true if the editor should be focused.\n   */\n  onceAdded(focus) {}\n\n  /**\n   * Check if the editor contains something.\n   * @returns {boolean}\n   */\n  isEmpty() {\n    return false;\n  }\n\n  /**\n   * Enable edit mode.\n   * @returns {boolean} - true if the edit mode has been enabled.\n   */\n  enableEditMode() {\n    if (this.isInEditMode()) {\n      return false;\n    }\n    this.parent.setEditingState(false);\n    this.#isInEditMode = true;\n\n    return true;\n  }\n\n  /**\n   * Disable edit mode.\n   * @returns {boolean} - true if the edit mode has been disabled.\n   */\n  disableEditMode() {\n    if (!this.isInEditMode()) {\n      return false;\n    }\n    this.parent.setEditingState(true);\n    this.#isInEditMode = false;\n\n    return true;\n  }\n\n  /**\n   * Check if the editor is edited.\n   * @returns {boolean}\n   */\n  isInEditMode() {\n    return this.#isInEditMode;\n  }\n\n  /**\n   * If it returns true, then this editor handles the keyboard\n   * events itself.\n   * @returns {boolean}\n   */\n  shouldGetKeyboardEvents() {\n    return this.#isResizerEnabledForKeyboard;\n  }\n\n  /**\n   * Check if this editor needs to be rebuilt or not.\n   * @returns {boolean}\n   */\n  needsToBeRebuilt() {\n    return this.div && !this.isAttachedToDOM;\n  }\n\n  get isOnScreen() {\n    const { top, left, bottom, right } = this.getClientDimensions();\n    const { innerHeight, innerWidth } = window;\n    return left < innerWidth && right > 0 && top < innerHeight && bottom > 0;\n  }\n\n  #addFocusListeners() {\n    if (this.#focusAC || !this.div) {\n      return;\n    }\n    this.#focusAC = new AbortController();\n    const signal = this._uiManager.combinedSignal(this.#focusAC);\n\n    this.div.addEventListener(\"focusin\", this.focusin.bind(this), { signal });\n    this.div.addEventListener(\"focusout\", this.focusout.bind(this), { signal });\n  }\n\n  /**\n   * Rebuild the editor in case it has been removed on undo.\n   *\n   * To implement in subclasses.\n   */\n  rebuild() {\n    this.#addFocusListeners();\n  }\n\n  /**\n   * Rotate the editor when the page is rotated.\n   * @param {number} angle\n   */\n  rotate(_angle) {}\n\n  /**\n   * Resize the editor when the page is resized.\n   */\n  resize() {}\n\n  /**\n   * Serialize the editor when it has been deleted.\n   * @returns {Object}\n   */\n  serializeDeleted() {\n    return {\n      id: this.annotationElementId,\n      deleted: true,\n      pageIndex: this.pageIndex,\n      popupRef: this._initialData?.popupRef || \"\",\n    };\n  }\n\n  /**\n   * Serialize the editor.\n   * The result of the serialization will be used to construct a\n   * new annotation to add to the pdf document.\n   *\n   * To implement in subclasses.\n   * @param {boolean} [isForCopying]\n   * @param {Object | null} [context]\n   * @returns {Object | null}\n   */\n  serialize(isForCopying = false, context = null) {\n    return {\n      annotationType: this.mode,\n      pageIndex: this.pageIndex,\n      rect: this.getPDFRect(),\n      rotation: this.rotation,\n      structTreeParentId: this._structTreeParentId,\n      popupRef: this._initialData?.popupRef || \"\",\n    };\n  }\n\n  /**\n   * Deserialize the editor.\n   * The result of the deserialization is a new editor.\n   *\n   * @param {Object} data\n   * @param {AnnotationEditorLayer} parent\n   * @param {AnnotationEditorUIManager} uiManager\n   * @returns {Promise<AnnotationEditor | null>}\n   */\n  static async deserialize(data, parent, uiManager) {\n    const editor = new this.prototype.constructor({\n      parent,\n      id: parent.getNextId(),\n      uiManager,\n      annotationElementId: data.annotationElementId,\n      creationDate: data.creationDate,\n      modificationDate: data.modificationDate,\n    });\n    editor.rotation = data.rotation;\n    editor.#accessibilityData = data.accessibilityData;\n    editor._isCopy = data.isCopy || false;\n\n    const [pageWidth, pageHeight] = editor.pageDimensions;\n    const [x, y, width, height] = editor.getRectInCurrentCoords(\n      data.rect,\n      pageHeight\n    );\n\n    editor.x = x / pageWidth;\n    editor.y = y / pageHeight;\n    editor.width = width / pageWidth;\n    editor.height = height / pageHeight;\n\n    return editor;\n  }\n\n  /**\n   * Check if an existing annotation associated with this editor has been\n   * modified.\n   * @returns {boolean}\n   */\n  get hasBeenModified() {\n    return (\n      !!this.annotationElementId && (this.deleted || this.serialize() !== null)\n    );\n  }\n\n  /**\n   * Remove this editor.\n   * It's used on ctrl+backspace action.\n   */\n  remove() {\n    this.#focusAC?.abort();\n    this.#focusAC = null;\n\n    if (!this.isEmpty()) {\n      // The editor is removed but it can be back at some point thanks to\n      // undo/redo so we must commit it before.\n      this.commit();\n    }\n    if (this.parent) {\n      this.parent.remove(this);\n    } else {\n      this._uiManager.removeEditor(this);\n    }\n    this.hideCommentPopup();\n\n    if (this.#moveInDOMTimeout) {\n      clearTimeout(this.#moveInDOMTimeout);\n      this.#moveInDOMTimeout = null;\n    }\n    this.#stopResizing();\n    this.removeEditToolbar();\n    if (this.#telemetryTimeouts) {\n      for (const timeout of this.#telemetryTimeouts.values()) {\n        clearTimeout(timeout);\n      }\n      this.#telemetryTimeouts = null;\n    }\n    this.parent = null;\n    this.#touchManager?.destroy();\n    this.#touchManager = null;\n    this.#fakeAnnotation?.remove();\n    this.#fakeAnnotation = null;\n  }\n\n  /**\n   * @returns {boolean} true if this editor can be resized.\n   */\n  get isResizable() {\n    return false;\n  }\n\n  /**\n   * Add the resizers to this editor.\n   */\n  makeResizable() {\n    if (this.isResizable) {\n      this.#createResizers();\n      this.#resizersDiv.classList.remove(\"hidden\");\n    }\n  }\n\n  get toolbarPosition() {\n    return null;\n  }\n\n  /**\n   * Get the position of the comment button.\n   * @returns {Array<number>|null}\n   */\n  get commentButtonPosition() {\n    return this._uiManager.direction === \"ltr\" ? [1, 0] : [0, 0];\n  }\n\n  get commentButtonPositionInPage() {\n    const {\n      commentButtonPosition: [posX, posY],\n    } = this;\n    const [blX, blY, trX, trY] = this.getPDFRect();\n    return [\n      AnnotationEditor._round(blX + (trX - blX) * posX),\n      AnnotationEditor._round(blY + (trY - blY) * (1 - posY)),\n    ];\n  }\n\n  get commentButtonColor() {\n    return this._uiManager.makeCommentColor(\n      this.getNonHCMColor(),\n      this.opacity\n    );\n  }\n\n  get commentPopupPosition() {\n    return this.#comment.commentPopupPositionInLayer;\n  }\n\n  set commentPopupPosition(pos) {\n    this.#comment.commentPopupPositionInLayer = pos;\n  }\n\n  hasDefaultPopupPosition() {\n    return this.#comment.hasDefaultPopupPosition();\n  }\n\n  get commentButtonWidth() {\n    return this.#comment.commentButtonWidth;\n  }\n\n  get elementBeforePopup() {\n    return this.div;\n  }\n\n  setCommentButtonStates(options) {\n    this.#comment?.setCommentButtonStates(options);\n  }\n\n  /**\n   * onkeydown callback.\n   * @param {KeyboardEvent} event\n   */\n  keydown(event) {\n    if (\n      !this.isResizable ||\n      event.target !== this.div ||\n      event.key !== \"Enter\"\n    ) {\n      return;\n    }\n    this._uiManager.setSelected(this);\n    this.#savedDimensions = {\n      savedX: this.x,\n      savedY: this.y,\n      savedWidth: this.width,\n      savedHeight: this.height,\n    };\n    const children = this.#resizersDiv.children;\n    if (!this.#allResizerDivs) {\n      this.#allResizerDivs = Array.from(children);\n      const boundResizerKeydown = this.#resizerKeydown.bind(this);\n      const boundResizerBlur = this.#resizerBlur.bind(this);\n      const signal = this._uiManager._signal;\n      for (const div of this.#allResizerDivs) {\n        const name = div.getAttribute(\"data-resizer-name\");\n        div.setAttribute(\"role\", \"spinbutton\");\n        div.addEventListener(\"keydown\", boundResizerKeydown, { signal });\n        div.addEventListener(\"blur\", boundResizerBlur, { signal });\n        div.addEventListener(\"focus\", this.#resizerFocus.bind(this, name), {\n          signal,\n        });\n        div.setAttribute(\"data-l10n-id\", AnnotationEditor._l10nResizer[name]);\n      }\n    }\n\n    // We want to have the resizers in the visual order, so we move the first\n    // (top-left) to the right place.\n    const first = this.#allResizerDivs[0];\n    let firstPosition = 0;\n    for (const div of children) {\n      if (div === first) {\n        break;\n      }\n      firstPosition++;\n    }\n    const nextFirstPosition =\n      (((360 - this.rotation + this.parentRotation) % 360) / 90) *\n      (this.#allResizerDivs.length / 4);\n\n    if (nextFirstPosition !== firstPosition) {\n      // We need to reorder the resizers in the DOM in order to have the focus\n      // on the top-left one.\n      if (nextFirstPosition < firstPosition) {\n        for (let i = 0; i < firstPosition - nextFirstPosition; i++) {\n          this.#resizersDiv.append(this.#resizersDiv.firstElementChild);\n        }\n      } else if (nextFirstPosition > firstPosition) {\n        for (let i = 0; i < nextFirstPosition - firstPosition; i++) {\n          this.#resizersDiv.firstElementChild.before(\n            this.#resizersDiv.lastElementChild\n          );\n        }\n      }\n\n      let i = 0;\n      for (const child of children) {\n        const div = this.#allResizerDivs[i++];\n        const name = div.getAttribute(\"data-resizer-name\");\n        child.setAttribute(\"data-l10n-id\", AnnotationEditor._l10nResizer[name]);\n      }\n    }\n\n    this.#setResizerTabIndex(0);\n    this.#isResizerEnabledForKeyboard = true;\n    this.#resizersDiv.firstElementChild.focus({ focusVisible: true });\n    event.preventDefault();\n    event.stopImmediatePropagation();\n  }\n\n  #resizerKeydown(event) {\n    AnnotationEditor._resizerKeyboardManager.exec(this, event);\n  }\n\n  #resizerBlur(event) {\n    if (\n      this.#isResizerEnabledForKeyboard &&\n      event.relatedTarget?.parentNode !== this.#resizersDiv\n    ) {\n      this.#stopResizing();\n    }\n  }\n\n  #resizerFocus(name) {\n    this.#focusedResizerName = this.#isResizerEnabledForKeyboard ? name : \"\";\n  }\n\n  #setResizerTabIndex(value) {\n    if (!this.#allResizerDivs) {\n      return;\n    }\n    for (const div of this.#allResizerDivs) {\n      div.tabIndex = value;\n    }\n  }\n\n  _resizeWithKeyboard(x, y) {\n    if (!this.#isResizerEnabledForKeyboard) {\n      return;\n    }\n    this.#resizerPointermove(this.#focusedResizerName, {\n      deltaX: x,\n      deltaY: y,\n      fromKeyboard: true,\n    });\n  }\n\n  #stopResizing() {\n    this.#isResizerEnabledForKeyboard = false;\n    this.#setResizerTabIndex(-1);\n    this.#addResizeToUndoStack();\n  }\n\n  _stopResizingWithKeyboard() {\n    this.#stopResizing();\n    this.div.focus();\n  }\n\n  /**\n   * Select this editor.\n   */\n  select() {\n    if (this.isSelected && this._editToolbar) {\n      this._editToolbar.show();\n      return;\n    }\n    this.isSelected = true;\n    this.makeResizable();\n    this.div?.classList.add(\"selectedEditor\");\n    if (!this._editToolbar) {\n      this.addEditToolbar().then(() => {\n        if (this.div?.classList.contains(\"selectedEditor\")) {\n          // The editor can have been unselected while we were waiting for the\n          // edit toolbar to be created, hence we want to be sure that this\n          // editor is still selected.\n          this._editToolbar?.show();\n        }\n      });\n      return;\n    }\n    this._editToolbar?.show();\n    this.#altText?.toggleAltTextBadge(false);\n  }\n\n  focus() {\n    if (this.div && !this.div.contains(document.activeElement)) {\n      setTimeout(() => this.div?.focus({ preventScroll: true }), 0);\n    }\n  }\n\n  /**\n   * Unselect this editor.\n   */\n  unselect() {\n    if (!this.isSelected) {\n      return;\n    }\n    this.isSelected = false;\n    this.#resizersDiv?.classList.add(\"hidden\");\n    this.div?.classList.remove(\"selectedEditor\");\n    if (this.div?.contains(document.activeElement)) {\n      // Don't use this.div.blur() because we don't know where the focus will\n      // go.\n      this._uiManager.currentLayer.div.focus({\n        preventScroll: true,\n      });\n    }\n    this._editToolbar?.hide();\n    this.#altText?.toggleAltTextBadge(true);\n    this.hideCommentPopup();\n  }\n\n  hideCommentPopup() {\n    if (this.hasComment) {\n      this._uiManager.toggleComment(null);\n    }\n  }\n\n  /**\n   * Update some parameters which have been changed through the UI.\n   * @param {number} type\n   * @param {*} value\n   */\n  updateParams(type, value) {}\n\n  /**\n   * When the user disables the editing mode some editors can change some of\n   * their properties.\n   */\n  disableEditing() {}\n\n  /**\n   * When the user enables the editing mode some editors can change some of\n   * their properties.\n   */\n  enableEditing() {}\n\n  /**\n   * Check if the content of this editor can be changed.\n   * For example, a FreeText editor can be changed (the user can change the\n   * text), but a Stamp editor cannot.\n   * @returns {boolean}\n   */\n  get canChangeContent() {\n    return false;\n  }\n\n  /**\n   * The editor is about to be edited.\n   */\n  enterInEditMode() {\n    if (!this.canChangeContent) {\n      return;\n    }\n    this.enableEditMode();\n    this.div.focus();\n  }\n\n  /**\n   * ondblclick callback.\n   * @param {MouseEvent} event\n   */\n  dblclick(event) {\n    if (event.target.nodeName === \"BUTTON\") {\n      // Avoid entering in edit mode when clicking on the comment button.\n      return;\n    }\n    this.enterInEditMode();\n    this.parent.updateToolbar({\n      mode: this.constructor._editorType,\n      editId: this.uid,\n    });\n  }\n\n  /**\n   * @returns {HTMLElement | null} the element requiring an alt text.\n   */\n  getElementForAltText() {\n    return this.div;\n  }\n\n  /**\n   * Get the div which really contains the displayed content.\n   * @returns {HTMLDivElement | undefined}\n   */\n  get contentDiv() {\n    return this.div;\n  }\n\n  /**\n   * If true then the editor is currently edited.\n   * @type {boolean}\n   */\n  get isEditing() {\n    return this.#isEditing;\n  }\n\n  /**\n   * When set to true, it means that this editor is currently edited.\n   * @param {boolean} value\n   */\n  set isEditing(value) {\n    this.#isEditing = value;\n    if (!this.parent) {\n      return;\n    }\n    if (value) {\n      this.parent.setSelected(this);\n      this.parent.setActiveEditor(this);\n    } else {\n      this.parent.setActiveEditor(null);\n    }\n  }\n\n  static get MIN_SIZE() {\n    return 16;\n  }\n\n  static canCreateNewEmptyEditor() {\n    return true;\n  }\n\n  /**\n   * Get the data to report to the telemetry when the editor is added.\n   * @returns {Object}\n   */\n  get telemetryInitialData() {\n    return { action: \"added\" };\n  }\n\n  /**\n   * The telemetry data to use when saving/printing.\n   * @returns {Object|null}\n   */\n  get telemetryFinalData() {\n    return null;\n  }\n\n  _reportTelemetry(data, mustWait = false) {\n    if (mustWait) {\n      this.#telemetryTimeouts ||= new Map();\n      const { action } = data;\n      let timeout = this.#telemetryTimeouts.get(action);\n      if (timeout) {\n        clearTimeout(timeout);\n      }\n      timeout = setTimeout(() => {\n        this._reportTelemetry(data);\n        this.#telemetryTimeouts.delete(action);\n        if (this.#telemetryTimeouts.size === 0) {\n          this.#telemetryTimeouts = null;\n        }\n      }, AnnotationEditor._telemetryTimeout);\n      this.#telemetryTimeouts.set(action, timeout);\n      return;\n    }\n    data.type ||= this.editorType;\n    this._uiManager._eventBus.dispatch(\"reporttelemetry\", {\n      source: this,\n      details: {\n        type: \"editing\",\n        data,\n      },\n    });\n  }\n\n  /**\n   * Show or hide this editor.\n   * @param {boolean|undefined} visible\n   */\n  show(visible = this._isVisible) {\n    this.div.classList.toggle(\"hidden\", !visible);\n    this._isVisible = visible;\n  }\n\n  enable() {\n    if (this.div) {\n      this.div.tabIndex = 0;\n    }\n    this.#disabled = false;\n  }\n\n  disable() {\n    if (this.div) {\n      this.div.tabIndex = -1;\n    }\n    this.#disabled = true;\n  }\n\n  updateFakeAnnotationElement(annotationLayer) {\n    if (!this.#fakeAnnotation && !this.deleted) {\n      this.#fakeAnnotation = annotationLayer.addFakeAnnotation(this);\n      return;\n    }\n    if (this.deleted) {\n      this.#fakeAnnotation.remove();\n      this.#fakeAnnotation = null;\n      return;\n    }\n    if (this.hasEditedComment || this._hasBeenMoved || this._hasBeenResized) {\n      this.#fakeAnnotation.updateEdited({\n        rect: this.getPDFRect(),\n        popup: this.comment,\n      });\n    }\n  }\n\n  /**\n   * Render an annotation in the annotation layer.\n   * @param {Object} annotation\n   * @returns {HTMLElement|null}\n   */\n  renderAnnotationElement(annotation) {\n    if (this.deleted) {\n      annotation.hide();\n      return null;\n    }\n    let content = annotation.container.querySelector(\".annotationContent\");\n    if (!content) {\n      content = document.createElement(\"div\");\n      content.classList.add(\"annotationContent\", this.editorType);\n      annotation.container.prepend(content);\n    } else if (content.nodeName === \"CANVAS\") {\n      const canvas = content;\n      content = document.createElement(\"div\");\n      content.classList.add(\"annotationContent\", this.editorType);\n      canvas.before(content);\n    }\n\n    return content;\n  }\n\n  resetAnnotationElement(annotation) {\n    const { firstElementChild } = annotation.container;\n    if (\n      firstElementChild?.nodeName === \"DIV\" &&\n      firstElementChild.classList.contains(\"annotationContent\")\n    ) {\n      firstElementChild.remove();\n    }\n  }\n}\n\n// This class is used to fake an editor which has been deleted.\nclass FakeEditor extends AnnotationEditor {\n  constructor(params) {\n    super(params);\n    this.annotationElementId = params.annotationElementId;\n    this.deleted = true;\n  }\n\n  serialize() {\n    return this.serializeDeleted();\n  }\n}\n\nexport { AnnotationEditor };\n","/* Copyright 2014 Opera Software ASA\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n *\n * Based on https://code.google.com/p/smhasher/wiki/MurmurHash3.\n * Hashes roughly 100 KB per millisecond on i7 3.4 GHz.\n */\n\nconst SEED = 0xc3d2e1f0;\n// Workaround for missing math precision in JS.\nconst MASK_HIGH = 0xffff0000;\nconst MASK_LOW = 0xffff;\n\nclass MurmurHash3_64 {\n  constructor(seed) {\n    this.h1 = seed ? seed & 0xffffffff : SEED;\n    this.h2 = seed ? seed & 0xffffffff : SEED;\n  }\n\n  update(input) {\n    let data, length;\n    if (typeof input === \"string\") {\n      data = new Uint8Array(input.length * 2);\n      length = 0;\n      for (let i = 0, ii = input.length; i < ii; i++) {\n        const code = input.charCodeAt(i);\n        if (code <= 0xff) {\n          data[length++] = code;\n        } else {\n          data[length++] = code >>> 8;\n          data[length++] = code & 0xff;\n        }\n      }\n    } else if (ArrayBuffer.isView(input)) {\n      data = input.slice();\n      length = data.byteLength;\n    } else {\n      throw new Error(\"Invalid data format, must be a string or TypedArray.\");\n    }\n\n    const blockCounts = length >> 2;\n    const tailLength = length - blockCounts * 4;\n    // We don't care about endianness here.\n    const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);\n    let k1 = 0,\n      k2 = 0;\n    let h1 = this.h1,\n      h2 = this.h2;\n    const C1 = 0xcc9e2d51,\n      C2 = 0x1b873593;\n    const C1_LOW = C1 & MASK_LOW,\n      C2_LOW = C2 & MASK_LOW;\n\n    for (let i = 0; i < blockCounts; i++) {\n      if (i & 1) {\n        k1 = dataUint32[i];\n        k1 = ((k1 * C1) & MASK_HIGH) | ((k1 * C1_LOW) & MASK_LOW);\n        k1 = (k1 << 15) | (k1 >>> 17);\n        k1 = ((k1 * C2) & MASK_HIGH) | ((k1 * C2_LOW) & MASK_LOW);\n        h1 ^= k1;\n        h1 = (h1 << 13) | (h1 >>> 19);\n        h1 = h1 * 5 + 0xe6546b64;\n      } else {\n        k2 = dataUint32[i];\n        k2 = ((k2 * C1) & MASK_HIGH) | ((k2 * C1_LOW) & MASK_LOW);\n        k2 = (k2 << 15) | (k2 >>> 17);\n        k2 = ((k2 * C2) & MASK_HIGH) | ((k2 * C2_LOW) & MASK_LOW);\n        h2 ^= k2;\n        h2 = (h2 << 13) | (h2 >>> 19);\n        h2 = h2 * 5 + 0xe6546b64;\n      }\n    }\n\n    k1 = 0;\n\n    switch (tailLength) {\n      case 3:\n        k1 ^= data[blockCounts * 4 + 2] << 16;\n      /* falls through */\n      case 2:\n        k1 ^= data[blockCounts * 4 + 1] << 8;\n      /* falls through */\n      case 1:\n        k1 ^= data[blockCounts * 4];\n        /* falls through */\n\n        k1 = ((k1 * C1) & MASK_HIGH) | ((k1 * C1_LOW) & MASK_LOW);\n        k1 = (k1 << 15) | (k1 >>> 17);\n        k1 = ((k1 * C2) & MASK_HIGH) | ((k1 * C2_LOW) & MASK_LOW);\n        if (blockCounts & 1) {\n          h1 ^= k1;\n        } else {\n          h2 ^= k1;\n        }\n    }\n\n    this.h1 = h1;\n    this.h2 = h2;\n  }\n\n  hexdigest() {\n    let h1 = this.h1,\n      h2 = this.h2;\n\n    h1 ^= h2 >>> 1;\n    h1 = ((h1 * 0xed558ccd) & MASK_HIGH) | ((h1 * 0x8ccd) & MASK_LOW);\n    h2 =\n      ((h2 * 0xff51afd7) & MASK_HIGH) |\n      (((((h2 << 16) | (h1 >>> 16)) * 0xafd7ed55) & MASK_HIGH) >>> 16);\n    h1 ^= h2 >>> 1;\n    h1 = ((h1 * 0x1a85ec53) & MASK_HIGH) | ((h1 * 0xec53) & MASK_LOW);\n    h2 =\n      ((h2 * 0xc4ceb9fe) & MASK_HIGH) |\n      (((((h2 << 16) | (h1 >>> 16)) * 0xb9fe1a85) & MASK_HIGH) >>> 16);\n    h1 ^= h2 >>> 1;\n\n    return (\n      (h1 >>> 0).toString(16).padStart(8, \"0\") +\n      (h2 >>> 0).toString(16).padStart(8, \"0\")\n    );\n  }\n}\n\nexport { MurmurHash3_64 };\n","/* Copyright 2020 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { makeMap, shadow, unreachable } from \"../shared/util.js\";\nimport { AnnotationEditor } from \"./editor/editor.js\";\nimport { MurmurHash3_64 } from \"../shared/murmurhash3.js\";\n\nconst SerializableEmpty = Object.freeze({\n  map: null,\n  hash: \"\",\n  transfer: undefined,\n});\n\n/**\n * Key/value storage for annotation data in forms.\n */\nclass AnnotationStorage {\n  #modified = false;\n\n  #modifiedIds = null;\n\n  #editorsMap = null;\n\n  #storage = new Map();\n\n  // Callbacks to signal when the modification state is set or reset.\n  // This is used by the viewer to only bind on `beforeunload` if forms\n  // are actually edited to prevent doing so unconditionally since that\n  // can have undesirable effects.\n  onSetModified = null;\n\n  onResetModified = null;\n\n  onAnnotationEditor = null;\n\n  constructor() {\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      // For testing purposes.\n      Object.defineProperty(this, \"_setValues\", {\n        value: obj => {\n          for (const [key, val] of Object.entries(obj)) {\n            this.setValue(key, val);\n          }\n        },\n      });\n    }\n  }\n\n  /**\n   * Get the value for a given key if it exists, or return the default value.\n   * @param {string} key\n   * @param {Object} defaultValue\n   * @returns {Object}\n   */\n  getValue(key, defaultValue) {\n    const value = this.#storage.get(key);\n    if (value === undefined) {\n      return defaultValue;\n    }\n\n    return Object.assign(defaultValue, value);\n  }\n\n  /**\n   * Get the value for a given key.\n   * @param {string} key\n   * @returns {Object}\n   */\n  getRawValue(key) {\n    return this.#storage.get(key);\n  }\n\n  /**\n   * Remove a value from the storage.\n   * @param {string} key\n   */\n  remove(key) {\n    const storedValue = this.#storage.get(key);\n    if (storedValue === undefined) {\n      return;\n    }\n    if (storedValue instanceof AnnotationEditor) {\n      this.#editorsMap.delete(storedValue.annotationElementId);\n    }\n    this.#storage.delete(key);\n\n    if (this.#storage.size === 0) {\n      this.resetModified();\n    }\n\n    if (typeof this.onAnnotationEditor === \"function\") {\n      for (const value of this.#storage.values()) {\n        if (value instanceof AnnotationEditor) {\n          return;\n        }\n      }\n      this.onAnnotationEditor(null);\n    }\n  }\n\n  /**\n   * Set the value for a given key\n   * @param {string} key\n   * @param {Object} value\n   */\n  setValue(key, value) {\n    const obj = this.#storage.get(key);\n    let modified = false;\n    if (obj !== undefined) {\n      for (const [entry, val] of Object.entries(value)) {\n        if (obj[entry] !== val) {\n          modified = true;\n          obj[entry] = val;\n        }\n      }\n    } else {\n      modified = true;\n      this.#storage.set(key, value);\n    }\n    if (modified) {\n      this.#setModified();\n    }\n\n    if (value instanceof AnnotationEditor) {\n      (this.#editorsMap ||= new Map()).set(value.annotationElementId, value);\n      if (typeof this.onAnnotationEditor === \"function\") {\n        this.onAnnotationEditor(value.constructor._type);\n      }\n    }\n  }\n\n  /**\n   * Check if the storage contains the given key.\n   * @param {string} key\n   * @returns {boolean}\n   */\n  has(key) {\n    return this.#storage.has(key);\n  }\n\n  get size() {\n    return this.#storage.size;\n  }\n\n  #setModified() {\n    if (!this.#modified) {\n      this.#modified = true;\n      if (typeof this.onSetModified === \"function\") {\n        this.onSetModified();\n      }\n    }\n  }\n\n  resetModified() {\n    if (this.#modified) {\n      this.#modified = false;\n      if (typeof this.onResetModified === \"function\") {\n        this.onResetModified();\n      }\n    }\n  }\n\n  /**\n   * @returns {PrintAnnotationStorage}\n   */\n  get print() {\n    return new PrintAnnotationStorage(this);\n  }\n\n  /**\n   * PLEASE NOTE: Only intended for usage within the API itself.\n   * @ignore\n   */\n  get serializable() {\n    if (this.#storage.size === 0) {\n      return SerializableEmpty;\n    }\n    const map = new Map(),\n      hash = new MurmurHash3_64(),\n      transfer = [];\n    const context = Object.create(null);\n    let hasBitmap = false;\n\n    for (const [key, val] of this.#storage) {\n      const serialized =\n        val instanceof AnnotationEditor\n          ? val.serialize(/* isForCopying = */ false, context)\n          : val;\n      if (val.page) {\n        val.pageIndex = val.page._pageIndex;\n        delete val.page;\n      }\n      if (serialized) {\n        map.set(key, serialized);\n\n        hash.update(`${key}:${JSON.stringify(serialized)}`);\n        hasBitmap ||= !!serialized.bitmap;\n      }\n    }\n\n    if (hasBitmap) {\n      // We must transfer the bitmap data separately, since it can be changed\n      // during serialization with SVG images.\n      for (const value of map.values()) {\n        if (value.bitmap) {\n          transfer.push(value.bitmap);\n        }\n      }\n    }\n\n    return map.size > 0\n      ? { map, hash: hash.hexdigest(), transfer }\n      : SerializableEmpty;\n  }\n\n  get editorStats() {\n    let stats = null;\n    const typeToEditor = new Map();\n    let numberOfEditedComments = 0;\n    let numberOfDeletedComments = 0;\n    for (const value of this.#storage.values()) {\n      if (!(value instanceof AnnotationEditor)) {\n        if (value.popup) {\n          if (value.popup.deleted) {\n            numberOfDeletedComments += 1;\n          } else {\n            numberOfEditedComments += 1;\n          }\n        }\n        continue;\n      }\n      if (value.isCommentDeleted) {\n        numberOfDeletedComments += 1;\n      } else if (value.hasEditedComment) {\n        numberOfEditedComments += 1;\n      }\n      const editorStats = value.telemetryFinalData;\n      if (!editorStats) {\n        continue;\n      }\n      const { type } = editorStats;\n      if (!typeToEditor.has(type)) {\n        typeToEditor.set(type, Object.getPrototypeOf(value).constructor);\n      }\n      stats ||= Object.create(null);\n      const map = (stats[type] ||= new Map());\n      for (const [key, val] of Object.entries(editorStats)) {\n        if (key === \"type\") {\n          continue;\n        }\n        const counters = map.getOrInsertComputed(key, makeMap);\n        counters.set(val, (counters.get(val) ?? 0) + 1);\n      }\n    }\n    if (numberOfDeletedComments > 0 || numberOfEditedComments > 0) {\n      stats ||= Object.create(null);\n      stats.comments = {\n        deleted: numberOfDeletedComments,\n        edited: numberOfEditedComments,\n      };\n    }\n    if (!stats) {\n      return null;\n    }\n    for (const [type, editor] of typeToEditor) {\n      stats[type] = editor.computeTelemetryFinalData(stats[type]);\n    }\n    return stats;\n  }\n\n  resetModifiedIds() {\n    this.#modifiedIds = null;\n  }\n\n  updateEditor(annotationId, data) {\n    const value = this.#editorsMap?.get(annotationId);\n    if (value) {\n      value.updateFromAnnotationLayer(data);\n      return true;\n    }\n    return false;\n  }\n\n  getEditor(annotationId) {\n    return this.#editorsMap?.get(annotationId) || null;\n  }\n\n  /**\n   * @returns {{ids: Set<string>, hash: string}}\n   */\n  get modifiedIds() {\n    if (this.#modifiedIds) {\n      return this.#modifiedIds;\n    }\n    const ids = [];\n    if (this.#editorsMap) {\n      for (const value of this.#editorsMap.values()) {\n        if (!value.serialize()) {\n          continue;\n        }\n        ids.push(value.annotationElementId);\n      }\n    }\n    return (this.#modifiedIds = {\n      ids: new Set(ids),\n      hash: ids.join(\",\"),\n    });\n  }\n\n  [Symbol.iterator]() {\n    return this.#storage.entries();\n  }\n}\n\n/**\n * A special `AnnotationStorage` for use during printing, where the serializable\n * data is *frozen* upon initialization, to prevent scripting from modifying its\n * contents. (Necessary since printing is triggered synchronously in browsers.)\n */\nclass PrintAnnotationStorage extends AnnotationStorage {\n  #serializable = SerializableEmpty;\n\n  constructor(parent) {\n    super();\n\n    const { serializable } = parent;\n    if (serializable === SerializableEmpty) {\n      return;\n    }\n    const { map, hash, transfer } = serializable;\n    // Create a *copy* of the data, since Objects are passed by reference in JS.\n    const clone = structuredClone(map, transfer ? { transfer } : null);\n    // The `PrintAnnotationStorage` instance is re-used for all pages,\n    // hence we cannot transfer the data since that breaks printing.\n    this.#serializable = { map: clone, hash, transfer: [] };\n  }\n\n  /**\n   * @returns {PrintAnnotationStorage}\n   */\n  // eslint-disable-next-line getter-return\n  get print() {\n    unreachable(\"Should not call PrintAnnotationStorage.print\");\n  }\n\n  /**\n   * PLEASE NOTE: Only intended for usage within the API itself.\n   * @ignore\n   */\n  get serializable() {\n    return this.#serializable;\n  }\n\n  get modifiedIds() {\n    return shadow(this, \"modifiedIds\", {\n      ids: new Set(),\n      hash: \"\",\n    });\n  }\n}\n\nexport { AnnotationStorage, PrintAnnotationStorage, SerializableEmpty };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  assert,\n  FeatureTest,\n  isNodeJS,\n  shadow,\n  string32,\n  unreachable,\n  warn,\n} from \"../shared/util.js\";\nimport { makePathFromDrawOPS } from \"./display_utils.js\";\n\nclass FontLoader {\n  #systemFonts = new Set();\n\n  constructor({\n    ownerDocument = globalThis.document,\n    styleElement = null, // For testing only.\n  }) {\n    this._document = ownerDocument;\n\n    this.nativeFontFaces = new Set();\n    this.styleElement =\n      typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")\n        ? styleElement\n        : null;\n\n    if (typeof PDFJSDev === \"undefined\" || !PDFJSDev.test(\"MOZCENTRAL\")) {\n      this.loadingRequests = [];\n      this.loadTestFontId = 0;\n    }\n  }\n\n  addNativeFontFace(nativeFontFace) {\n    this.nativeFontFaces.add(nativeFontFace);\n    this._document.fonts.add(nativeFontFace);\n  }\n\n  removeNativeFontFace(nativeFontFace) {\n    this.nativeFontFaces.delete(nativeFontFace);\n    this._document.fonts.delete(nativeFontFace);\n  }\n\n  insertRule(rule) {\n    if (!this.styleElement) {\n      this.styleElement = this._document.createElement(\"style\");\n      this._document.documentElement\n        .getElementsByTagName(\"head\")[0]\n        .append(this.styleElement);\n    }\n    const styleSheet = this.styleElement.sheet;\n    styleSheet.insertRule(rule, styleSheet.cssRules.length);\n  }\n\n  clear() {\n    for (const nativeFontFace of this.nativeFontFaces) {\n      this._document.fonts.delete(nativeFontFace);\n    }\n    this.nativeFontFaces.clear();\n    this.#systemFonts.clear();\n\n    if (this.styleElement) {\n      // Note: ChildNode.remove doesn't throw if the parentNode is undefined.\n      this.styleElement.remove();\n      this.styleElement = null;\n    }\n  }\n\n  async loadSystemFont({\n    systemFontInfo: info,\n    disableFontFace,\n    _inspectFont,\n  }) {\n    if (!info || this.#systemFonts.has(info.loadedName)) {\n      return;\n    }\n    assert(\n      !disableFontFace,\n      \"loadSystemFont shouldn't be called when `disableFontFace` is set.\"\n    );\n\n    if (this.isFontLoadingAPISupported) {\n      const { loadedName, src, style } = info;\n      const fontFace = new FontFace(loadedName, src, style);\n      this.addNativeFontFace(fontFace);\n      try {\n        await fontFace.load();\n        this.#systemFonts.add(loadedName);\n        _inspectFont?.(info);\n      } catch {\n        warn(\n          `Cannot load system font: ${info.baseFontName}, installing it could help to improve PDF rendering.`\n        );\n\n        this.removeNativeFontFace(fontFace);\n      }\n      return;\n    }\n\n    unreachable(\n      \"Not implemented: loadSystemFont without the Font Loading API.\"\n    );\n  }\n\n  async bind(font) {\n    // Add the font to the DOM only once; skip if the font is already loaded.\n    if (font.attached || (font.missingFile && !font.systemFontInfo)) {\n      return;\n    }\n    font.attached = true;\n\n    if (font.systemFontInfo) {\n      await this.loadSystemFont(font);\n      return;\n    }\n\n    if (this.isFontLoadingAPISupported) {\n      const nativeFontFace = font.createNativeFontFace();\n      if (nativeFontFace) {\n        this.addNativeFontFace(nativeFontFace);\n        try {\n          await nativeFontFace.loaded;\n        } catch (ex) {\n          warn(`Failed to load font '${nativeFontFace.family}': '${ex}'.`);\n\n          // When font loading failed, fall back to the built-in font renderer.\n          font.disableFontFace = true;\n          throw ex;\n        }\n      }\n      return; // The font was, asynchronously, loaded.\n    }\n\n    // !this.isFontLoadingAPISupported\n    const rule = font.createFontFaceRule();\n    if (rule) {\n      this.insertRule(rule);\n\n      if (this.isSyncFontLoadingSupported) {\n        return; // The font was, synchronously, loaded.\n      }\n      if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n        throw new Error(\"Not implemented: async font loading\");\n      }\n      await new Promise(resolve => {\n        const request = this._queueLoadingCallback(resolve);\n        this._prepareFontLoadEvent(font, request);\n      });\n      // The font was, asynchronously, loaded.\n    }\n  }\n\n  get isFontLoadingAPISupported() {\n    const hasFonts = !!this._document?.fonts;\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      return shadow(\n        this,\n        \"isFontLoadingAPISupported\",\n        hasFonts && !this.styleElement\n      );\n    }\n    return shadow(this, \"isFontLoadingAPISupported\", hasFonts);\n  }\n\n  get isSyncFontLoadingSupported() {\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n      return shadow(this, \"isSyncFontLoadingSupported\", true);\n    }\n\n    // Node.js - we can pretend that sync font loading is supported.\n    // Firefox, from version 14, supports synchronous font loading.\n    return shadow(\n      this,\n      \"isSyncFontLoadingSupported\",\n      (typeof PDFJSDev === \"undefined\" || !PDFJSDev.test(\"CHROME\")) &&\n        (isNodeJS || FeatureTest.platform.isFirefox)\n    );\n  }\n\n  _queueLoadingCallback(callback) {\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n      throw new Error(\"Not implemented: _queueLoadingCallback\");\n    }\n\n    function completeRequest() {\n      assert(!request.done, \"completeRequest() cannot be called twice.\");\n      request.done = true;\n\n      // Sending all completed requests in order of how they were queued.\n      while (loadingRequests.length > 0 && loadingRequests[0].done) {\n        const otherRequest = loadingRequests.shift();\n        setTimeout(otherRequest.callback, 0);\n      }\n    }\n\n    const { loadingRequests } = this;\n    const request = {\n      done: false,\n      complete: completeRequest,\n      callback,\n    };\n    loadingRequests.push(request);\n    return request;\n  }\n\n  get _loadTestFont() {\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n      throw new Error(\"Not implemented: _loadTestFont\");\n    }\n\n    // This is a CFF font with 1 glyph for '.' that fills its entire width\n    // and height.\n    const testFont = atob(\n      \"T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA\" +\n        \"FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA\" +\n        \"ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA\" +\n        \"AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1\" +\n        \"AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD\" +\n        \"6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM\" +\n        \"AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D\" +\n        \"IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA\" +\n        \"AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA\" +\n        \"AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB\" +\n        \"AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY\" +\n        \"AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA\" +\n        \"AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\" +\n        \"AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\" +\n        \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\" +\n        \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\" +\n        \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\" +\n        \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA\" +\n        \"AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC\" +\n        \"AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3\" +\n        \"Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj\" +\n        \"FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==\"\n    );\n    return shadow(this, \"_loadTestFont\", testFont);\n  }\n\n  _prepareFontLoadEvent(font, request) {\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n      throw new Error(\"Not implemented: _prepareFontLoadEvent\");\n    }\n\n    /** Hack begin */\n    // There's currently no event when a font has finished downloading so the\n    // following code is a dirty hack to 'guess' when a font is ready.\n    // It's assumed fonts are loaded in order, so add a known test font after\n    // the desired fonts and then test for the loading of that test font.\n\n    function int32(data, offset) {\n      return (\n        (data.charCodeAt(offset) << 24) |\n        (data.charCodeAt(offset + 1) << 16) |\n        (data.charCodeAt(offset + 2) << 8) |\n        (data.charCodeAt(offset + 3) & 0xff)\n      );\n    }\n    function spliceString(s, offset, remove, insert) {\n      const chunk1 = s.substring(0, offset);\n      const chunk2 = s.substring(offset + remove);\n      return chunk1 + insert + chunk2;\n    }\n    let i, ii;\n\n    // The temporary canvas is used to determine if fonts are loaded.\n    const canvas = this._document.createElement(\"canvas\");\n    canvas.width = 1;\n    canvas.height = 1;\n    const ctx = canvas.getContext(\"2d\");\n\n    let called = 0;\n    function isFontReady(name, callback) {\n      // With setTimeout clamping this gives the font ~100ms to load.\n      if (++called > 30) {\n        warn(\"Load test font never loaded.\");\n        callback();\n        return;\n      }\n      ctx.font = \"30px \" + name;\n      ctx.fillText(\".\", 0, 20);\n      const imageData = ctx.getImageData(0, 0, 1, 1);\n      if (imageData.data[3] > 0) {\n        callback();\n        return;\n      }\n      setTimeout(isFontReady.bind(null, name, callback));\n    }\n\n    const loadTestFontId = `lt${Date.now()}${this.loadTestFontId++}`;\n    // Chromium seems to cache fonts based on a hash of the actual font data,\n    // so the font must be modified for each load test else it will appear to\n    // be loaded already.\n    // TODO: This could maybe be made faster by avoiding the btoa of the full\n    // font by splitting it in chunks before hand and padding the font id.\n    let data = this._loadTestFont;\n    const COMMENT_OFFSET = 976; // has to be on 4 byte boundary (for checksum)\n    data = spliceString(\n      data,\n      COMMENT_OFFSET,\n      loadTestFontId.length,\n      loadTestFontId\n    );\n    // CFF checksum is important for IE, adjusting it\n    const CFF_CHECKSUM_OFFSET = 16;\n    const XXXX_VALUE = 0x58585858; // the \"comment\" filled with 'X'\n    let checksum = int32(data, CFF_CHECKSUM_OFFSET);\n    for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {\n      checksum = (checksum - XXXX_VALUE + int32(loadTestFontId, i)) | 0;\n    }\n    if (i < loadTestFontId.length) {\n      // align to 4 bytes boundary\n      checksum = (checksum - XXXX_VALUE + int32(loadTestFontId + \"XXX\", i)) | 0;\n    }\n    data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));\n\n    const url = `url(data:font/opentype;base64,${btoa(data)});`;\n    const rule = `@font-face {font-family:\"${loadTestFontId}\";src:${url}}`;\n    this.insertRule(rule);\n\n    const div = this._document.createElement(\"div\");\n    div.style.visibility = \"hidden\";\n    div.style.width = div.style.height = \"10px\";\n    div.style.position = \"absolute\";\n    div.style.top = div.style.left = \"0px\";\n\n    for (const name of [font.loadedName, loadTestFontId]) {\n      const span = this._document.createElement(\"span\");\n      span.textContent = \"Hi\";\n      span.style.fontFamily = name;\n      div.append(span);\n    }\n    this._document.body.append(div);\n\n    isFontReady(loadTestFontId, () => {\n      div.remove();\n      request.complete();\n    });\n    /** Hack end */\n  }\n}\n\nclass FontFaceObject {\n  #fontData;\n\n  constructor(translatedData, inspectFont = null, extra, charProcOperatorList) {\n    this.compiledGlyphs = Object.create(null);\n    this.#fontData = translatedData;\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      if (typeof this.disableFontFace !== \"boolean\") {\n        unreachable(\"disableFontFace must be available.\");\n      }\n      if (typeof this.fontExtraProperties !== \"boolean\") {\n        unreachable(\"fontExtraProperties must be available.\");\n      }\n    }\n    this._inspectFont = inspectFont;\n    if (extra) {\n      Object.assign(this, extra);\n    }\n    if (charProcOperatorList) {\n      this.charProcOperatorList = charProcOperatorList;\n    }\n  }\n\n  createNativeFontFace() {\n    if (!this.data || this.disableFontFace) {\n      return null;\n    }\n    let nativeFontFace;\n    if (!this.cssFontInfo) {\n      nativeFontFace = new FontFace(this.loadedName, this.data, {});\n    } else {\n      const css = {\n        weight: this.cssFontInfo.fontWeight,\n      };\n      if (this.cssFontInfo.italicAngle) {\n        css.style = `oblique ${this.cssFontInfo.italicAngle}deg`;\n      }\n      nativeFontFace = new FontFace(\n        this.cssFontInfo.fontFamily,\n        this.data,\n        css\n      );\n    }\n\n    this._inspectFont?.(this);\n    return nativeFontFace;\n  }\n\n  createFontFaceRule() {\n    if (!this.data || this.disableFontFace) {\n      return null;\n    }\n    // Add the @font-face rule to the document.\n    const url = `url(data:${this.mimetype};base64,${this.data.toBase64()});`;\n    let rule;\n    if (!this.cssFontInfo) {\n      rule = `@font-face {font-family:\"${this.loadedName}\";src:${url}}`;\n    } else {\n      let css = `font-weight: ${this.cssFontInfo.fontWeight};`;\n      if (this.cssFontInfo.italicAngle) {\n        css += `font-style: oblique ${this.cssFontInfo.italicAngle}deg;`;\n      }\n      rule = `@font-face {font-family:\"${this.cssFontInfo.fontFamily}\";${css}src:${url}}`;\n    }\n\n    this._inspectFont?.(this, url);\n    return rule;\n  }\n\n  getPathGenerator(objs, character) {\n    if (this.compiledGlyphs[character] !== undefined) {\n      return this.compiledGlyphs[character];\n    }\n\n    const objId = this.loadedName + \"_path_\" + character;\n    let cmds;\n    try {\n      cmds = objs.get(objId);\n    } catch (ex) {\n      warn(`getPathGenerator - ignoring character: \"${ex}\".`);\n    }\n    const path = makePathFromDrawOPS(cmds?.path);\n\n    if (!this.fontExtraProperties) {\n      // Remove the raw path-string, since we don't need it anymore.\n      objs.delete(objId);\n    }\n    return (this.compiledGlyphs[character] = path);\n  }\n\n  get black() {\n    return this.#fontData.black;\n  }\n\n  get bold() {\n    return this.#fontData.bold;\n  }\n\n  get disableFontFace() {\n    return this.#fontData.disableFontFace ?? false;\n  }\n\n  set disableFontFace(value) {\n    shadow(this, \"disableFontFace\", !!value);\n  }\n\n  get fontExtraProperties() {\n    return this.#fontData.fontExtraProperties ?? false;\n  }\n\n  get isInvalidPDFjsFont() {\n    return this.#fontData.isInvalidPDFjsFont;\n  }\n\n  get isType3Font() {\n    return this.#fontData.isType3Font;\n  }\n\n  get italic() {\n    return this.#fontData.italic;\n  }\n\n  get missingFile() {\n    return this.#fontData.missingFile;\n  }\n\n  get remeasure() {\n    return this.#fontData.remeasure;\n  }\n\n  get vertical() {\n    return this.#fontData.vertical;\n  }\n\n  get ascent() {\n    return this.#fontData.ascent;\n  }\n\n  get defaultWidth() {\n    return this.#fontData.defaultWidth;\n  }\n\n  get descent() {\n    return this.#fontData.descent;\n  }\n\n  get bbox() {\n    return this.#fontData.bbox;\n  }\n\n  set bbox(bbox) {\n    shadow(this, \"bbox\", bbox);\n  }\n\n  get fontMatrix() {\n    return this.#fontData.fontMatrix;\n  }\n\n  get fallbackName() {\n    return this.#fontData.fallbackName;\n  }\n\n  get loadedName() {\n    return this.#fontData.loadedName;\n  }\n\n  get mimetype() {\n    return this.#fontData.mimetype;\n  }\n\n  get name() {\n    return this.#fontData.name;\n  }\n\n  get data() {\n    return this.#fontData.data;\n  }\n\n  clearData() {\n    this.#fontData.clearData();\n  }\n\n  get cssFontInfo() {\n    return this.#fontData.cssFontInfo;\n  }\n\n  get systemFontInfo() {\n    return this.#fontData.systemFontInfo;\n  }\n\n  get defaultVMetrics() {\n    return this.#fontData.defaultVMetrics;\n  }\n}\n\nexport { FontFaceObject, FontLoader };\n","/* Copyright 2025 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assert, FeatureTest, MeshFigureType } from \"./util.js\";\n\nclass CssFontInfo {\n  #buffer;\n\n  #view;\n\n  #decoder;\n\n  static strings = [\"fontFamily\", \"fontWeight\", \"italicAngle\"];\n\n  static write(info) {\n    const encoder = new TextEncoder();\n    const encodedStrings = {};\n    let stringsLength = 0;\n    for (const prop of CssFontInfo.strings) {\n      const encoded = encoder.encode(info[prop]);\n      encodedStrings[prop] = encoded;\n      stringsLength += 4 + encoded.length;\n    }\n\n    const buffer = new ArrayBuffer(stringsLength);\n    const data = new Uint8Array(buffer);\n    const view = new DataView(buffer);\n    let offset = 0;\n\n    for (const prop of CssFontInfo.strings) {\n      const encoded = encodedStrings[prop];\n      const length = encoded.length;\n      view.setUint32(offset, length);\n      data.set(encoded, offset + 4);\n      offset += 4 + length;\n    }\n    assert(offset === buffer.byteLength, \"CssFontInfo.write: Buffer overflow\");\n    return buffer;\n  }\n\n  constructor(buffer) {\n    this.#buffer = buffer;\n    this.#view = new DataView(this.#buffer);\n    this.#decoder = new TextDecoder();\n  }\n\n  #readString(index) {\n    assert(index < CssFontInfo.strings.length, \"Invalid string index\");\n    let offset = 0;\n    for (let i = 0; i < index; i++) {\n      offset += this.#view.getUint32(offset) + 4;\n    }\n    const length = this.#view.getUint32(offset);\n    return this.#decoder.decode(\n      new Uint8Array(this.#buffer, offset + 4, length)\n    );\n  }\n\n  get fontFamily() {\n    return this.#readString(0);\n  }\n\n  get fontWeight() {\n    return this.#readString(1);\n  }\n\n  get italicAngle() {\n    return this.#readString(2);\n  }\n}\n\nclass SystemFontInfo {\n  #buffer;\n\n  #view;\n\n  #decoder;\n\n  static strings = [\"css\", \"loadedName\", \"baseFontName\", \"src\"];\n\n  static write(info) {\n    const encoder = new TextEncoder();\n    const encodedStrings = {};\n    let stringsLength = 0;\n    for (const prop of SystemFontInfo.strings) {\n      const encoded = encoder.encode(info[prop]);\n      encodedStrings[prop] = encoded;\n      stringsLength += 4 + encoded.length;\n    }\n    stringsLength += 4;\n    let encodedStyleStyle,\n      encodedStyleWeight,\n      lengthEstimate = 1 + stringsLength;\n    if (info.style) {\n      encodedStyleStyle = encoder.encode(info.style.style);\n      encodedStyleWeight = encoder.encode(info.style.weight);\n      lengthEstimate +=\n        4 + encodedStyleStyle.length + 4 + encodedStyleWeight.length;\n    }\n\n    const buffer = new ArrayBuffer(lengthEstimate);\n    const data = new Uint8Array(buffer);\n    const view = new DataView(buffer);\n    let offset = 0;\n\n    view.setUint8(offset++, info.guessFallback ? 1 : 0);\n    view.setUint32(offset, 0);\n    offset += 4;\n    stringsLength = 0;\n    for (const prop of SystemFontInfo.strings) {\n      const encoded = encodedStrings[prop];\n      const length = encoded.length;\n      stringsLength += 4 + length;\n      view.setUint32(offset, length);\n      data.set(encoded, offset + 4);\n      offset += 4 + length;\n    }\n    view.setUint32(offset - stringsLength - 4, stringsLength);\n\n    if (info.style) {\n      view.setUint32(offset, encodedStyleStyle.length);\n      data.set(encodedStyleStyle, offset + 4);\n      offset += 4 + encodedStyleStyle.length;\n      view.setUint32(offset, encodedStyleWeight.length);\n      data.set(encodedStyleWeight, offset + 4);\n      offset += 4 + encodedStyleWeight.length;\n    }\n    assert(\n      offset <= buffer.byteLength,\n      \"SubstitionInfo.write: Buffer overflow\"\n    );\n    return buffer.transferToFixedLength(offset);\n  }\n\n  constructor(buffer) {\n    this.#buffer = buffer;\n    this.#view = new DataView(this.#buffer);\n    this.#decoder = new TextDecoder();\n  }\n\n  get guessFallback() {\n    return this.#view.getUint8(0) !== 0;\n  }\n\n  #readString(index) {\n    assert(index < SystemFontInfo.strings.length, \"Invalid string index\");\n    let offset = 5;\n    for (let i = 0; i < index; i++) {\n      offset += this.#view.getUint32(offset) + 4;\n    }\n    const length = this.#view.getUint32(offset);\n    return this.#decoder.decode(\n      new Uint8Array(this.#buffer, offset + 4, length)\n    );\n  }\n\n  get css() {\n    return this.#readString(0);\n  }\n\n  get loadedName() {\n    return this.#readString(1);\n  }\n\n  get baseFontName() {\n    return this.#readString(2);\n  }\n\n  get src() {\n    return this.#readString(3);\n  }\n\n  get style() {\n    let offset = 1;\n    offset += 4 + this.#view.getUint32(offset);\n    const styleLength = this.#view.getUint32(offset);\n    const style = this.#decoder.decode(\n      new Uint8Array(this.#buffer, offset + 4, styleLength)\n    );\n    offset += 4 + styleLength;\n    const weightLength = this.#view.getUint32(offset);\n    const weight = this.#decoder.decode(\n      new Uint8Array(this.#buffer, offset + 4, weightLength)\n    );\n    return { style, weight };\n  }\n}\n\nclass FontInfo {\n  static bools = [\n    \"black\",\n    \"bold\",\n    \"disableFontFace\",\n    \"fontExtraProperties\",\n    \"isInvalidPDFjsFont\",\n    \"isType3Font\",\n    \"italic\",\n    \"missingFile\",\n    \"remeasure\",\n    \"vertical\",\n  ];\n\n  static numbers = [\"ascent\", \"defaultWidth\", \"descent\"];\n\n  static strings = [\"fallbackName\", \"loadedName\", \"mimetype\", \"name\"];\n\n  static #OFFSET_NUMBERS = Math.ceil((this.bools.length * 2) / 8);\n\n  static #OFFSET_BBOX = this.#OFFSET_NUMBERS + this.numbers.length * 8;\n\n  static #OFFSET_FONT_MATRIX = this.#OFFSET_BBOX + 1 + 2 * 4;\n\n  static #OFFSET_DEFAULT_VMETRICS = this.#OFFSET_FONT_MATRIX + 1 + 8 * 6;\n\n  static #OFFSET_STRINGS = this.#OFFSET_DEFAULT_VMETRICS + 1 + 2 * 3;\n\n  #buffer;\n\n  #decoder;\n\n  #view;\n\n  constructor({ data, extra }) {\n    this.#buffer = data;\n    this.#decoder = new TextDecoder();\n    this.#view = new DataView(this.#buffer);\n    if (extra) {\n      Object.assign(this, extra);\n    }\n  }\n\n  #readBoolean(index) {\n    assert(index < FontInfo.bools.length, \"Invalid boolean index\");\n    const byteOffset = Math.floor(index / 4);\n    const bitOffset = (index * 2) % 8;\n    const value = (this.#view.getUint8(byteOffset) >> bitOffset) & 0x03;\n    return value === 0x00 ? undefined : value === 0x02;\n  }\n\n  get black() {\n    return this.#readBoolean(0);\n  }\n\n  get bold() {\n    return this.#readBoolean(1);\n  }\n\n  get disableFontFace() {\n    return this.#readBoolean(2);\n  }\n\n  get fontExtraProperties() {\n    return this.#readBoolean(3);\n  }\n\n  get isInvalidPDFjsFont() {\n    return this.#readBoolean(4);\n  }\n\n  get isType3Font() {\n    return this.#readBoolean(5);\n  }\n\n  get italic() {\n    return this.#readBoolean(6);\n  }\n\n  get missingFile() {\n    return this.#readBoolean(7);\n  }\n\n  get remeasure() {\n    return this.#readBoolean(8);\n  }\n\n  get vertical() {\n    return this.#readBoolean(9);\n  }\n\n  #readNumber(index) {\n    assert(index < FontInfo.numbers.length, \"Invalid number index\");\n    return this.#view.getFloat64(FontInfo.#OFFSET_NUMBERS + index * 8);\n  }\n\n  get ascent() {\n    return this.#readNumber(0);\n  }\n\n  get defaultWidth() {\n    return this.#readNumber(1);\n  }\n\n  get descent() {\n    return this.#readNumber(2);\n  }\n\n  get bbox() {\n    let offset = FontInfo.#OFFSET_BBOX;\n    const numCoords = this.#view.getUint8(offset);\n    if (numCoords === 0) {\n      return undefined;\n    }\n    offset += 1;\n    const bbox = [];\n    for (let i = 0; i < 4; i++) {\n      bbox.push(this.#view.getInt16(offset, true));\n      offset += 2;\n    }\n    return bbox;\n  }\n\n  get fontMatrix() {\n    let offset = FontInfo.#OFFSET_FONT_MATRIX;\n    const numPoints = this.#view.getUint8(offset);\n    if (numPoints === 0) {\n      return undefined;\n    }\n    offset += 1;\n    const fontMatrix = [];\n    for (let i = 0; i < 6; i++) {\n      fontMatrix.push(this.#view.getFloat64(offset, true));\n      offset += 8;\n    }\n    return fontMatrix;\n  }\n\n  get defaultVMetrics() {\n    let offset = FontInfo.#OFFSET_DEFAULT_VMETRICS;\n    const numMetrics = this.#view.getUint8(offset);\n    if (numMetrics === 0) {\n      return undefined;\n    }\n    offset += 1;\n    const defaultVMetrics = [];\n    for (let i = 0; i < 3; i++) {\n      defaultVMetrics.push(this.#view.getInt16(offset, true));\n      offset += 2;\n    }\n    return defaultVMetrics;\n  }\n\n  #readString(index) {\n    assert(index < FontInfo.strings.length, \"Invalid string index\");\n    let offset = FontInfo.#OFFSET_STRINGS + 4;\n    for (let i = 0; i < index; i++) {\n      offset += this.#view.getUint32(offset) + 4;\n    }\n    const length = this.#view.getUint32(offset);\n    const stringData = new Uint8Array(length);\n    stringData.set(new Uint8Array(this.#buffer, offset + 4, length));\n    return this.#decoder.decode(stringData);\n  }\n\n  get fallbackName() {\n    return this.#readString(0);\n  }\n\n  get loadedName() {\n    return this.#readString(1);\n  }\n\n  get mimetype() {\n    return this.#readString(2);\n  }\n\n  get name() {\n    return this.#readString(3);\n  }\n\n  get data() {\n    let offset = FontInfo.#OFFSET_STRINGS;\n    const stringsLength = this.#view.getUint32(offset);\n    offset += 4 + stringsLength;\n    const systemFontInfoLength = this.#view.getUint32(offset);\n    offset += 4 + systemFontInfoLength;\n    const cssFontInfoLength = this.#view.getUint32(offset);\n    offset += 4 + cssFontInfoLength;\n    const length = this.#view.getUint32(offset);\n    if (length === 0) {\n      return undefined;\n    }\n    return new Uint8Array(this.#buffer, offset + 4, length);\n  }\n\n  clearData() {\n    let offset = FontInfo.#OFFSET_STRINGS;\n    const stringsLength = this.#view.getUint32(offset);\n    offset += 4 + stringsLength;\n    const systemFontInfoLength = this.#view.getUint32(offset);\n    offset += 4 + systemFontInfoLength;\n    const cssFontInfoLength = this.#view.getUint32(offset);\n    offset += 4 + cssFontInfoLength;\n    const length = this.#view.getUint32(offset);\n    const data = new Uint8Array(this.#buffer, offset + 4, length);\n    data.fill(0);\n    this.#view.setUint32(offset, 0);\n    // this.#buffer.resize(offset);\n  }\n\n  get cssFontInfo() {\n    let offset = FontInfo.#OFFSET_STRINGS;\n    const stringsLength = this.#view.getUint32(offset);\n    offset += 4 + stringsLength;\n    const systemFontInfoLength = this.#view.getUint32(offset);\n    offset += 4 + systemFontInfoLength;\n    const cssFontInfoLength = this.#view.getUint32(offset);\n    if (cssFontInfoLength === 0) {\n      return null;\n    }\n    const cssFontInfoData = new Uint8Array(cssFontInfoLength);\n    cssFontInfoData.set(\n      new Uint8Array(this.#buffer, offset + 4, cssFontInfoLength)\n    );\n    return new CssFontInfo(cssFontInfoData.buffer);\n  }\n\n  get systemFontInfo() {\n    let offset = FontInfo.#OFFSET_STRINGS;\n    const stringsLength = this.#view.getUint32(offset);\n    offset += 4 + stringsLength;\n    const systemFontInfoLength = this.#view.getUint32(offset);\n    if (systemFontInfoLength === 0) {\n      return null;\n    }\n    const systemFontInfoData = new Uint8Array(systemFontInfoLength);\n    systemFontInfoData.set(\n      new Uint8Array(this.#buffer, offset + 4, systemFontInfoLength)\n    );\n    return new SystemFontInfo(systemFontInfoData.buffer);\n  }\n\n  static write(font) {\n    const systemFontInfoBuffer = font.systemFontInfo\n      ? SystemFontInfo.write(font.systemFontInfo)\n      : null;\n    const cssFontInfoBuffer = font.cssFontInfo\n      ? CssFontInfo.write(font.cssFontInfo)\n      : null;\n\n    const encoder = new TextEncoder();\n    const encodedStrings = {};\n    let stringsLength = 0;\n    for (const prop of FontInfo.strings) {\n      encodedStrings[prop] = encoder.encode(font[prop]);\n      stringsLength += 4 + encodedStrings[prop].length;\n    }\n\n    const lengthEstimate =\n      FontInfo.#OFFSET_STRINGS +\n      4 +\n      stringsLength +\n      4 +\n      (systemFontInfoBuffer ? systemFontInfoBuffer.byteLength : 0) +\n      4 +\n      (cssFontInfoBuffer ? cssFontInfoBuffer.byteLength : 0) +\n      4 +\n      (font.data ? font.data.length : 0);\n\n    const buffer = new ArrayBuffer(lengthEstimate);\n    const data = new Uint8Array(buffer);\n    const view = new DataView(buffer);\n    let offset = 0;\n\n    const numBools = FontInfo.bools.length;\n    let boolByte = 0,\n      boolBit = 0;\n    for (let i = 0; i < numBools; i++) {\n      const value = font[FontInfo.bools[i]];\n      // eslint-disable-next-line no-nested-ternary\n      const bits = value === undefined ? 0x00 : value ? 0x02 : 0x01;\n      boolByte |= bits << boolBit;\n      boolBit += 2;\n      if (boolBit === 8 || i === numBools - 1) {\n        view.setUint8(offset++, boolByte);\n        boolByte = 0;\n        boolBit = 0;\n      }\n    }\n    assert(\n      offset === FontInfo.#OFFSET_NUMBERS,\n      \"FontInfo.write: Boolean properties offset mismatch\"\n    );\n\n    for (const prop of FontInfo.numbers) {\n      view.setFloat64(offset, font[prop]);\n      offset += 8;\n    }\n    assert(\n      offset === FontInfo.#OFFSET_BBOX,\n      \"FontInfo.write: Number properties offset mismatch\"\n    );\n\n    if (font.bbox) {\n      view.setUint8(offset++, 4);\n      for (const coord of font.bbox) {\n        view.setInt16(offset, coord, true);\n        offset += 2;\n      }\n    } else {\n      view.setUint8(offset++, 0);\n      offset += 2 * 4; // TODO: optimize this padding away\n    }\n\n    assert(\n      offset === FontInfo.#OFFSET_FONT_MATRIX,\n      \"FontInfo.write: BBox properties offset mismatch\"\n    );\n\n    if (font.fontMatrix) {\n      view.setUint8(offset++, 6);\n      for (const point of font.fontMatrix) {\n        view.setFloat64(offset, point, true);\n        offset += 8;\n      }\n    } else {\n      view.setUint8(offset++, 0);\n      offset += 8 * 6; // TODO: optimize this padding away\n    }\n\n    assert(\n      offset === FontInfo.#OFFSET_DEFAULT_VMETRICS,\n      \"FontInfo.write: FontMatrix properties offset mismatch\"\n    );\n\n    if (font.defaultVMetrics) {\n      view.setUint8(offset++, 1);\n      for (const metric of font.defaultVMetrics) {\n        view.setInt16(offset, metric, true);\n        offset += 2;\n      }\n    } else {\n      view.setUint8(offset++, 0);\n      offset += 3 * 2; // TODO: optimize this padding away\n    }\n\n    assert(\n      offset === FontInfo.#OFFSET_STRINGS,\n      \"FontInfo.write: DefaultVMetrics properties offset mismatch\"\n    );\n\n    view.setUint32(FontInfo.#OFFSET_STRINGS, 0);\n    offset += 4;\n    for (const prop of FontInfo.strings) {\n      const encoded = encodedStrings[prop];\n      const length = encoded.length;\n      view.setUint32(offset, length);\n      data.set(encoded, offset + 4);\n      offset += 4 + length;\n    }\n    view.setUint32(\n      FontInfo.#OFFSET_STRINGS,\n      offset - FontInfo.#OFFSET_STRINGS - 4\n    );\n\n    if (!systemFontInfoBuffer) {\n      view.setUint32(offset, 0);\n      offset += 4;\n    } else {\n      const length = systemFontInfoBuffer.byteLength;\n      view.setUint32(offset, length);\n      assert(\n        offset + 4 + length <= buffer.byteLength,\n        \"FontInfo.write: Buffer overflow at systemFontInfo\"\n      );\n      data.set(new Uint8Array(systemFontInfoBuffer), offset + 4);\n      offset += 4 + length;\n    }\n\n    if (!cssFontInfoBuffer) {\n      view.setUint32(offset, 0);\n      offset += 4;\n    } else {\n      const length = cssFontInfoBuffer.byteLength;\n      view.setUint32(offset, length);\n      assert(\n        offset + 4 + length <= buffer.byteLength,\n        \"FontInfo.write: Buffer overflow at cssFontInfo\"\n      );\n      data.set(new Uint8Array(cssFontInfoBuffer), offset + 4);\n      offset += 4 + length;\n    }\n\n    if (font.data === undefined) {\n      view.setUint32(offset, 0);\n      offset += 4;\n    } else {\n      view.setUint32(offset, font.data.length);\n      data.set(font.data, offset + 4);\n      offset += 4 + font.data.length;\n    }\n\n    assert(offset <= buffer.byteLength, \"FontInfo.write: Buffer overflow\");\n    return buffer.transferToFixedLength(offset);\n  }\n}\n\nclass PatternInfo {\n  static #KIND = 0; // 1=axial, 2=radial, 3=mesh\n\n  static #HAS_BBOX = 1; // 0/1\n\n  static #HAS_BACKGROUND = 2; // 0/1 (background for mesh patterns)\n\n  static #SHADING_TYPE = 3; // shadingType (only for mesh patterns)\n\n  static #N_COORD = 4; // number of coordinate pairs\n\n  static #N_COLOR = 8; // number of rgb triplets\n\n  static #N_STOP = 12; // number of gradient stops\n\n  static #N_FIGURES = 16; // number of figures\n\n  constructor(buffer) {\n    this.buffer = buffer;\n    this.view = new DataView(buffer);\n    this.data = new Uint8Array(buffer);\n  }\n\n  static write(ir) {\n    let kind,\n      bbox = null,\n      coords = [],\n      colors = [],\n      colorStops = [],\n      figures = [],\n      shadingType = null, // only needed for mesh patterns\n      background = null; // background for mesh patterns\n\n    switch (ir[0]) {\n      case \"RadialAxial\":\n        kind = ir[1] === \"axial\" ? 1 : 2;\n        bbox = ir[2];\n        colorStops = ir[3];\n        if (kind === 1) {\n          coords.push(...ir[4], ...ir[5]);\n        } else {\n          coords.push(ir[4][0], ir[4][1], ir[6], ir[5][0], ir[5][1], ir[7]);\n        }\n        break;\n      case \"Mesh\":\n        kind = 3;\n        shadingType = ir[1];\n        coords = ir[2];\n        colors = ir[3];\n        figures = ir[4] || [];\n        bbox = ir[6];\n        background = ir[7];\n        break;\n      default:\n        throw new Error(`Unsupported pattern type: ${ir[0]}`);\n    }\n\n    const nCoord = Math.floor(coords.length / 2);\n    const nColor = Math.floor(colors.length / 3);\n    const nStop = colorStops.length;\n    const nFigures = figures.length;\n\n    let figuresSize = 0;\n    for (const figure of figures) {\n      figuresSize += 1;\n      figuresSize = Math.ceil(figuresSize / 4) * 4; // Ensure 4-byte alignment\n      figuresSize += 4 + figure.coords.length * 4;\n      figuresSize += 4 + figure.colors.length * 4;\n      if (figure.verticesPerRow !== undefined) {\n        figuresSize += 4;\n      }\n    }\n\n    const byteLen =\n      20 +\n      nCoord * 8 +\n      nColor * 3 +\n      nStop * 8 +\n      (bbox ? 16 : 0) +\n      (background ? 3 : 0) +\n      figuresSize;\n    const buffer = new ArrayBuffer(byteLen);\n    const dataView = new DataView(buffer);\n    const u8data = new Uint8Array(buffer);\n\n    dataView.setUint8(PatternInfo.#KIND, kind);\n    dataView.setUint8(PatternInfo.#HAS_BBOX, bbox ? 1 : 0);\n    dataView.setUint8(PatternInfo.#HAS_BACKGROUND, background ? 1 : 0);\n    dataView.setUint8(PatternInfo.#SHADING_TYPE, shadingType); // Only for mesh pattern, null otherwise\n    dataView.setUint32(PatternInfo.#N_COORD, nCoord, true);\n    dataView.setUint32(PatternInfo.#N_COLOR, nColor, true);\n    dataView.setUint32(PatternInfo.#N_STOP, nStop, true);\n    dataView.setUint32(PatternInfo.#N_FIGURES, nFigures, true);\n\n    let offset = 20;\n    const coordsView = new Float32Array(buffer, offset, nCoord * 2);\n    coordsView.set(coords);\n    offset += nCoord * 8;\n\n    u8data.set(colors, offset);\n    offset += nColor * 3;\n\n    for (const [pos, hex] of colorStops) {\n      dataView.setFloat32(offset, pos, true);\n      offset += 4;\n      dataView.setUint32(offset, parseInt(hex.slice(1), 16), true);\n      offset += 4;\n    }\n    if (bbox) {\n      for (const v of bbox) {\n        dataView.setFloat32(offset, v, true);\n        offset += 4;\n      }\n    }\n\n    if (background) {\n      u8data.set(background, offset);\n      offset += 3;\n    }\n\n    for (let i = 0; i < figures.length; i++) {\n      const figure = figures[i];\n      dataView.setUint8(offset, figure.type);\n      offset += 1;\n      // Ensure 4-byte alignment\n      offset = Math.ceil(offset / 4) * 4;\n      dataView.setUint32(offset, figure.coords.length, true);\n      offset += 4;\n      const figureCoordsView = new Int32Array(\n        buffer,\n        offset,\n        figure.coords.length\n      );\n      figureCoordsView.set(figure.coords);\n      offset += figure.coords.length * 4;\n      dataView.setUint32(offset, figure.colors.length, true);\n      offset += 4;\n      const colorsView = new Int32Array(buffer, offset, figure.colors.length);\n      colorsView.set(figure.colors);\n      offset += figure.colors.length * 4;\n\n      if (figure.verticesPerRow !== undefined) {\n        dataView.setUint32(offset, figure.verticesPerRow, true);\n        offset += 4;\n      }\n    }\n    return buffer;\n  }\n\n  getIR() {\n    const dataView = this.view;\n    const kind = this.data[PatternInfo.#KIND];\n    const hasBBox = !!this.data[PatternInfo.#HAS_BBOX];\n    const hasBackground = !!this.data[PatternInfo.#HAS_BACKGROUND];\n    const nCoord = dataView.getUint32(PatternInfo.#N_COORD, true);\n    const nColor = dataView.getUint32(PatternInfo.#N_COLOR, true);\n    const nStop = dataView.getUint32(PatternInfo.#N_STOP, true);\n    const nFigures = dataView.getUint32(PatternInfo.#N_FIGURES, true);\n\n    let offset = 20;\n    const coords = new Float32Array(this.buffer, offset, nCoord * 2);\n    offset += nCoord * 8;\n    const colors = new Uint8Array(this.buffer, offset, nColor * 3);\n    offset += nColor * 3;\n    const stops = [];\n    for (let i = 0; i < nStop; ++i) {\n      const p = dataView.getFloat32(offset, true);\n      offset += 4;\n      const rgb = dataView.getUint32(offset, true);\n      offset += 4;\n      stops.push([p, `#${rgb.toString(16).padStart(6, \"0\")}`]);\n    }\n    let bbox = null;\n    if (hasBBox) {\n      bbox = [];\n      for (let i = 0; i < 4; ++i) {\n        bbox.push(dataView.getFloat32(offset, true));\n        offset += 4;\n      }\n    }\n\n    let background = null;\n    if (hasBackground) {\n      background = new Uint8Array(this.buffer, offset, 3);\n      offset += 3;\n    }\n\n    const figures = [];\n    for (let i = 0; i < nFigures; ++i) {\n      const type = dataView.getUint8(offset);\n      offset += 1;\n      // Ensure 4-byte alignment\n      offset = Math.ceil(offset / 4) * 4;\n\n      const coordsLength = dataView.getUint32(offset, true);\n      offset += 4;\n      const figureCoords = new Int32Array(this.buffer, offset, coordsLength);\n      offset += coordsLength * 4;\n\n      const colorsLength = dataView.getUint32(offset, true);\n      offset += 4;\n      const figureColors = new Int32Array(this.buffer, offset, colorsLength);\n      offset += colorsLength * 4;\n\n      const figure = {\n        type,\n        coords: figureCoords,\n        colors: figureColors,\n      };\n\n      if (type === MeshFigureType.LATTICE) {\n        figure.verticesPerRow = dataView.getUint32(offset, true);\n        offset += 4;\n      }\n\n      figures.push(figure);\n    }\n\n    if (kind === 1) {\n      // axial\n      return [\n        \"RadialAxial\",\n        \"axial\",\n        bbox,\n        stops,\n        Array.from(coords.slice(0, 2)),\n        Array.from(coords.slice(2, 4)),\n        null,\n        null,\n      ];\n    }\n    if (kind === 2) {\n      return [\n        \"RadialAxial\",\n        \"radial\",\n        bbox,\n        stops,\n        [coords[0], coords[1]],\n        [coords[3], coords[4]],\n        coords[2],\n        coords[5],\n      ];\n    }\n    if (kind === 3) {\n      const shadingType = this.data[PatternInfo.#SHADING_TYPE];\n      let bounds = null;\n      if (coords.length > 0) {\n        let minX = coords[0],\n          maxX = coords[0];\n        let minY = coords[1],\n          maxY = coords[1];\n        for (let i = 0; i < coords.length; i += 2) {\n          const x = coords[i],\n            y = coords[i + 1];\n          minX = minX > x ? x : minX;\n          minY = minY > y ? y : minY;\n          maxX = maxX < x ? x : maxX;\n          maxY = maxY < y ? y : maxY;\n        }\n        bounds = [minX, minY, maxX, maxY];\n      }\n      return [\n        \"Mesh\",\n        shadingType,\n        coords,\n        colors,\n        figures,\n        bounds,\n        bbox,\n        background,\n      ];\n    }\n    throw new Error(`Unsupported pattern kind: ${kind}`);\n  }\n}\n\nclass FontPathInfo {\n  static write(path) {\n    let data;\n    let buffer;\n    if (\n      (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n      FeatureTest.isFloat16ArraySupported\n    ) {\n      buffer = new ArrayBuffer(path.length * 2);\n      data = new Float16Array(buffer);\n    } else {\n      buffer = new ArrayBuffer(path.length * 4);\n      data = new Float32Array(buffer);\n    }\n    data.set(path);\n    return buffer;\n  }\n\n  #buffer;\n\n  constructor(buffer) {\n    this.#buffer = buffer;\n  }\n\n  get path() {\n    if (\n      (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n      FeatureTest.isFloat16ArraySupported\n    ) {\n      return new Float16Array(this.#buffer);\n    }\n    return new Float32Array(this.#buffer);\n  }\n}\n\nexport { CssFontInfo, FontInfo, FontPathInfo, PatternInfo, SystemFontInfo };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  _isValidExplicitDest,\n  isNodeJS,\n  stringToBytes,\n  warn,\n} from \"../shared/util.js\";\n\nfunction getUrlProp(val) {\n  if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n    return null; // The 'url' is unused with `PDFDataRangeTransport`.\n  }\n  if (val instanceof URL) {\n    return val;\n  }\n  if (typeof val === \"string\") {\n    if (\n      typeof PDFJSDev !== \"undefined\" &&\n      PDFJSDev.test(\"GENERIC\") &&\n      isNodeJS\n    ) {\n      if (/^[a-z][a-z0-9\\-+.]+:/i.test(val)) {\n        return new URL(val);\n      }\n      // eslint-disable-next-line no-undef\n      const url = process.getBuiltinModule(\"url\");\n      return new URL(url.pathToFileURL(val));\n    }\n\n    // The full path is required in the 'url' field.\n    const url = URL.parse(val, window.location);\n    if (url) {\n      return url;\n    }\n  }\n  throw new Error(\n    \"Invalid PDF url data: \" +\n      \"either string or URL-object is expected in the url property.\"\n  );\n}\n\nfunction getDataProp(val) {\n  // Converting string or array-like data to Uint8Array.\n  if (\n    typeof PDFJSDev !== \"undefined\" &&\n    PDFJSDev.test(\"GENERIC\") &&\n    isNodeJS &&\n    typeof Buffer !== \"undefined\" && // eslint-disable-line no-undef\n    val instanceof Buffer // eslint-disable-line no-undef\n  ) {\n    throw new Error(\n      \"Please provide binary data as `Uint8Array`, rather than `Buffer`.\"\n    );\n  }\n  if (val instanceof Uint8Array && val.byteLength === val.buffer.byteLength) {\n    // Use the data as-is when it's already a Uint8Array that completely\n    // \"utilizes\" its underlying ArrayBuffer, to prevent any possible\n    // issues when transferring it to the worker-thread.\n    return val;\n  }\n  if (typeof val === \"string\") {\n    return stringToBytes(val);\n  }\n  if (\n    val instanceof ArrayBuffer ||\n    ArrayBuffer.isView(val) ||\n    (typeof val === \"object\" && !isNaN(val?.length))\n  ) {\n    return new Uint8Array(val);\n  }\n  throw new Error(\n    \"Invalid PDF binary data: either TypedArray, \" +\n      \"string, or array-like object is expected in the data property.\"\n  );\n}\n\nfunction getFactoryUrlProp(val) {\n  if (typeof val !== \"string\") {\n    return null;\n  }\n  if (val.endsWith(\"/\")) {\n    return val;\n  }\n  throw new Error(`Invalid factory url: \"${val}\" must include trailing slash.`);\n}\n\nconst isRefProxy = v =>\n  typeof v === \"object\" &&\n  Number.isInteger(v?.num) &&\n  v.num >= 0 &&\n  Number.isInteger(v?.gen) &&\n  v.gen >= 0;\n\nconst isNameProxy = v => typeof v === \"object\" && typeof v?.name === \"string\";\n\nconst isValidExplicitDest = _isValidExplicitDest.bind(\n  null,\n  /* validRef = */ isRefProxy,\n  /* validName = */ isNameProxy\n);\n\nclass LoopbackPort {\n  #listeners = new Map();\n\n  #deferred = Promise.resolve();\n\n  postMessage(obj, transfer) {\n    const event = {\n      data: structuredClone(obj, transfer ? { transfer } : null),\n    };\n\n    this.#deferred.then(() => {\n      for (const [listener] of this.#listeners) {\n        listener.call(this, event);\n      }\n    });\n  }\n\n  addEventListener(name, listener, options = null) {\n    let rmAbort = null;\n    if (options?.signal instanceof AbortSignal) {\n      const { signal } = options;\n      if (signal.aborted) {\n        warn(\"LoopbackPort - cannot use an `aborted` signal.\");\n        return;\n      }\n      const onAbort = () => this.removeEventListener(name, listener);\n      rmAbort = () => signal.removeEventListener(\"abort\", onAbort);\n\n      signal.addEventListener(\"abort\", onAbort);\n    }\n    this.#listeners.set(listener, rmAbort);\n  }\n\n  removeEventListener(name, listener) {\n    const rmAbort = this.#listeners.get(listener);\n    rmAbort?.();\n\n    this.#listeners.delete(listener);\n  }\n\n  terminate() {\n    for (const [, rmAbort] of this.#listeners) {\n      rmAbort?.();\n    }\n    this.#listeners.clear();\n  }\n}\n\nexport {\n  getDataProp,\n  getFactoryUrlProp,\n  getUrlProp,\n  isNameProxy,\n  isRefProxy,\n  isValidExplicitDest,\n  LoopbackPort,\n};\n","/* Copyright 2018 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  AbortException,\n  assert,\n  InvalidPDFException,\n  PasswordException,\n  ResponseException,\n  UnknownErrorException,\n  unreachable,\n} from \"./util.js\";\n\nconst CallbackKind = {\n  DATA: 1,\n  ERROR: 2,\n};\n\nconst StreamKind = {\n  CANCEL: 1,\n  CANCEL_COMPLETE: 2,\n  CLOSE: 3,\n  ENQUEUE: 4,\n  ERROR: 5,\n  PULL: 6,\n  PULL_COMPLETE: 7,\n  START_COMPLETE: 8,\n};\n\nfunction onFn() {}\n\nfunction wrapReason(ex) {\n  if (\n    ex instanceof AbortException ||\n    ex instanceof InvalidPDFException ||\n    ex instanceof PasswordException ||\n    ex instanceof ResponseException ||\n    ex instanceof UnknownErrorException\n  ) {\n    // Avoid re-creating the exception when its type is already correct.\n    return ex;\n  }\n\n  if (!(ex instanceof Error || (typeof ex === \"object\" && ex !== null))) {\n    unreachable(\n      'wrapReason: Expected \"reason\" to be a (possibly cloned) Error.'\n    );\n  }\n  switch (ex.name) {\n    case \"AbortException\":\n      return new AbortException(ex.message);\n    case \"InvalidPDFException\":\n      return new InvalidPDFException(ex.message);\n    case \"PasswordException\":\n      return new PasswordException(ex.message, ex.code);\n    case \"ResponseException\":\n      return new ResponseException(ex.message, ex.status, ex.missing);\n    case \"UnknownErrorException\":\n      return new UnknownErrorException(ex.message, ex.details);\n  }\n  return new UnknownErrorException(ex.message, ex.toString());\n}\n\nclass MessageHandler {\n  #messageAC = new AbortController();\n\n  constructor(sourceName, targetName, comObj) {\n    this.sourceName = sourceName;\n    this.targetName = targetName;\n    this.comObj = comObj;\n    this.callbackId = 1;\n    this.streamId = 1;\n    this.streamSinks = Object.create(null);\n    this.streamControllers = Object.create(null);\n    this.callbackCapabilities = Object.create(null);\n    this.actionHandler = Object.create(null);\n\n    comObj.addEventListener(\"message\", this.#onMessage.bind(this), {\n      signal: this.#messageAC.signal,\n    });\n  }\n\n  #onMessage({ data }) {\n    if (data.targetName !== this.sourceName) {\n      return;\n    }\n    if (data.stream) {\n      this.#processStreamMessage(data);\n      return;\n    }\n    if (data.callback) {\n      const callbackId = data.callbackId;\n      const capability = this.callbackCapabilities[callbackId];\n      if (!capability) {\n        throw new Error(`Cannot resolve callback ${callbackId}`);\n      }\n      delete this.callbackCapabilities[callbackId];\n\n      if (data.callback === CallbackKind.DATA) {\n        capability.resolve(data.data);\n      } else if (data.callback === CallbackKind.ERROR) {\n        capability.reject(wrapReason(data.reason));\n      } else {\n        throw new Error(\"Unexpected callback case\");\n      }\n      return;\n    }\n    const action = this.actionHandler[data.action];\n    if (!action) {\n      throw new Error(`Unknown action from worker: ${data.action}`);\n    }\n    if (data.callbackId) {\n      const sourceName = this.sourceName,\n        targetName = data.sourceName,\n        comObj = this.comObj;\n\n      Promise.try(action, data.data).then(\n        function (result) {\n          comObj.postMessage({\n            sourceName,\n            targetName,\n            callback: CallbackKind.DATA,\n            callbackId: data.callbackId,\n            data: result,\n          });\n        },\n        function (reason) {\n          comObj.postMessage({\n            sourceName,\n            targetName,\n            callback: CallbackKind.ERROR,\n            callbackId: data.callbackId,\n            reason: wrapReason(reason),\n          });\n        }\n      );\n      return;\n    }\n    if (data.streamId) {\n      this.#createStreamSink(data);\n      return;\n    }\n    action(data.data);\n  }\n\n  on(actionName, handler) {\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      assert(\n        typeof handler === \"function\",\n        'MessageHandler.on: Expected \"handler\" to be a function.'\n      );\n    }\n    const ah = this.actionHandler;\n    if (ah[actionName]) {\n      throw new Error(`There is already an actionName called \"${actionName}\"`);\n    }\n    ah[actionName] = handler;\n  }\n\n  /**\n   * Sends a message to the comObj to invoke the action with the supplied data.\n   * @param {string} actionName - Action to call.\n   * @param {JSON} data - JSON data to send.\n   * @param {Array} [transfers] - List of transfers/ArrayBuffers.\n   */\n  send(actionName, data, transfers) {\n    this.comObj.postMessage(\n      {\n        sourceName: this.sourceName,\n        targetName: this.targetName,\n        action: actionName,\n        data,\n      },\n      transfers\n    );\n  }\n\n  /**\n   * Sends a message to the comObj to invoke the action with the supplied data.\n   * Expects that the other side will callback with the response.\n   * @param {string} actionName - Action to call.\n   * @param {JSON} data - JSON data to send.\n   * @param {Array} [transfers] - List of transfers/ArrayBuffers.\n   * @returns {Promise} Promise to be resolved with response data.\n   */\n  sendWithPromise(actionName, data, transfers) {\n    const callbackId = this.callbackId++;\n    const capability = Promise.withResolvers();\n    this.callbackCapabilities[callbackId] = capability;\n    try {\n      this.comObj.postMessage(\n        {\n          sourceName: this.sourceName,\n          targetName: this.targetName,\n          action: actionName,\n          callbackId,\n          data,\n        },\n        transfers\n      );\n    } catch (ex) {\n      capability.reject(ex);\n    }\n    return capability.promise;\n  }\n\n  /**\n   * Sends a message to the comObj to invoke the action with the supplied data.\n   * Expect that the other side will callback to signal 'start_complete'.\n   * @param {string} actionName - Action to call.\n   * @param {JSON} data - JSON data to send.\n   * @param {Object} queueingStrategy - Strategy to signal backpressure based on\n   *                 internal queue.\n   * @param {Array} [transfers] - List of transfers/ArrayBuffers.\n   * @returns {ReadableStream} ReadableStream to read data in chunks.\n   */\n  sendWithStream(actionName, data, queueingStrategy, transfers) {\n    const streamId = this.streamId++,\n      sourceName = this.sourceName,\n      targetName = this.targetName,\n      comObj = this.comObj;\n\n    return new ReadableStream(\n      {\n        start: controller => {\n          const startCapability = Promise.withResolvers();\n          this.streamControllers[streamId] = {\n            controller,\n            startCall: startCapability,\n            pullCall: null,\n            cancelCall: null,\n            isClosed: false,\n          };\n          comObj.postMessage(\n            {\n              sourceName,\n              targetName,\n              action: actionName,\n              streamId,\n              data,\n              desiredSize: controller.desiredSize,\n            },\n            transfers\n          );\n          // Return Promise for Async process, to signal success/failure.\n          return startCapability.promise;\n        },\n\n        pull: controller => {\n          const pullCapability = Promise.withResolvers();\n          this.streamControllers[streamId].pullCall = pullCapability;\n          comObj.postMessage({\n            sourceName,\n            targetName,\n            stream: StreamKind.PULL,\n            streamId,\n            desiredSize: controller.desiredSize,\n          });\n          // Returning Promise will not call \"pull\"\n          // again until current pull is resolved.\n          return pullCapability.promise;\n        },\n\n        cancel: reason => {\n          assert(reason instanceof Error, \"cancel must have a valid reason\");\n          const cancelCapability = Promise.withResolvers();\n          this.streamControllers[streamId].cancelCall = cancelCapability;\n          this.streamControllers[streamId].isClosed = true;\n          comObj.postMessage({\n            sourceName,\n            targetName,\n            stream: StreamKind.CANCEL,\n            streamId,\n            reason: wrapReason(reason),\n          });\n          // Return Promise to signal success or failure.\n          return cancelCapability.promise;\n        },\n      },\n      queueingStrategy\n    );\n  }\n\n  #createStreamSink(data) {\n    const streamId = data.streamId,\n      sourceName = this.sourceName,\n      targetName = data.sourceName,\n      comObj = this.comObj;\n    const self = this,\n      action = this.actionHandler[data.action];\n\n    const streamSink = {\n      enqueue(chunk, size = 1, transfers) {\n        if (this.isCancelled) {\n          return;\n        }\n        const lastDesiredSize = this.desiredSize;\n        this.desiredSize -= size;\n        // Enqueue decreases the desiredSize property of sink,\n        // so when it changes from positive to negative,\n        // set ready as unresolved promise.\n        if (lastDesiredSize > 0 && this.desiredSize <= 0) {\n          this.sinkCapability = Promise.withResolvers();\n          this.ready = this.sinkCapability.promise;\n        }\n        comObj.postMessage(\n          {\n            sourceName,\n            targetName,\n            stream: StreamKind.ENQUEUE,\n            streamId,\n            chunk,\n          },\n          transfers\n        );\n      },\n\n      close() {\n        if (this.isCancelled) {\n          return;\n        }\n        this.isCancelled = true;\n        comObj.postMessage({\n          sourceName,\n          targetName,\n          stream: StreamKind.CLOSE,\n          streamId,\n        });\n        delete self.streamSinks[streamId];\n      },\n\n      error(reason) {\n        assert(reason instanceof Error, \"error must have a valid reason\");\n        if (this.isCancelled) {\n          return;\n        }\n        this.isCancelled = true;\n        comObj.postMessage({\n          sourceName,\n          targetName,\n          stream: StreamKind.ERROR,\n          streamId,\n          reason: wrapReason(reason),\n        });\n      },\n\n      sinkCapability: Promise.withResolvers(),\n      onPull: null,\n      onCancel: null,\n      isCancelled: false,\n      desiredSize: data.desiredSize,\n      ready: null,\n    };\n\n    streamSink.sinkCapability.resolve();\n    streamSink.ready = streamSink.sinkCapability.promise;\n    this.streamSinks[streamId] = streamSink;\n\n    Promise.try(action, data.data, streamSink).then(\n      function () {\n        comObj.postMessage({\n          sourceName,\n          targetName,\n          stream: StreamKind.START_COMPLETE,\n          streamId,\n          success: true,\n        });\n      },\n      function (reason) {\n        comObj.postMessage({\n          sourceName,\n          targetName,\n          stream: StreamKind.START_COMPLETE,\n          streamId,\n          reason: wrapReason(reason),\n        });\n      }\n    );\n  }\n\n  #processStreamMessage(data) {\n    const streamId = data.streamId,\n      sourceName = this.sourceName,\n      targetName = data.sourceName,\n      comObj = this.comObj;\n    const streamController = this.streamControllers[streamId],\n      streamSink = this.streamSinks[streamId];\n\n    switch (data.stream) {\n      case StreamKind.START_COMPLETE:\n        if (data.success) {\n          streamController.startCall.resolve();\n        } else {\n          streamController.startCall.reject(wrapReason(data.reason));\n        }\n        break;\n      case StreamKind.PULL_COMPLETE:\n        if (data.success) {\n          streamController.pullCall.resolve();\n        } else {\n          streamController.pullCall.reject(wrapReason(data.reason));\n        }\n        break;\n      case StreamKind.PULL:\n        // Ignore any pull after close is called.\n        if (!streamSink) {\n          comObj.postMessage({\n            sourceName,\n            targetName,\n            stream: StreamKind.PULL_COMPLETE,\n            streamId,\n            success: true,\n          });\n          break;\n        }\n        // Pull increases the desiredSize property of sink, so when it changes\n        // from negative to positive, set ready property as resolved promise.\n        if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {\n          streamSink.sinkCapability.resolve();\n        }\n        // Reset desiredSize property of sink on every pull.\n        streamSink.desiredSize = data.desiredSize;\n\n        Promise.try(streamSink.onPull || onFn).then(\n          function () {\n            comObj.postMessage({\n              sourceName,\n              targetName,\n              stream: StreamKind.PULL_COMPLETE,\n              streamId,\n              success: true,\n            });\n          },\n          function (reason) {\n            comObj.postMessage({\n              sourceName,\n              targetName,\n              stream: StreamKind.PULL_COMPLETE,\n              streamId,\n              reason: wrapReason(reason),\n            });\n          }\n        );\n        break;\n      case StreamKind.ENQUEUE:\n        assert(streamController, \"enqueue should have stream controller\");\n        if (streamController.isClosed) {\n          break;\n        }\n        streamController.controller.enqueue(data.chunk);\n        break;\n      case StreamKind.CLOSE:\n        assert(streamController, \"close should have stream controller\");\n        if (streamController.isClosed) {\n          break;\n        }\n        streamController.isClosed = true;\n        streamController.controller.close();\n        this.#deleteStreamController(streamController, streamId);\n        break;\n      case StreamKind.ERROR:\n        assert(streamController, \"error should have stream controller\");\n        streamController.controller.error(wrapReason(data.reason));\n        this.#deleteStreamController(streamController, streamId);\n        break;\n      case StreamKind.CANCEL_COMPLETE:\n        if (data.success) {\n          streamController.cancelCall.resolve();\n        } else {\n          streamController.cancelCall.reject(wrapReason(data.reason));\n        }\n        this.#deleteStreamController(streamController, streamId);\n        break;\n      case StreamKind.CANCEL:\n        if (!streamSink) {\n          break;\n        }\n        const dataReason = wrapReason(data.reason);\n\n        Promise.try(streamSink.onCancel || onFn, dataReason).then(\n          function () {\n            comObj.postMessage({\n              sourceName,\n              targetName,\n              stream: StreamKind.CANCEL_COMPLETE,\n              streamId,\n              success: true,\n            });\n          },\n          function (reason) {\n            comObj.postMessage({\n              sourceName,\n              targetName,\n              stream: StreamKind.CANCEL_COMPLETE,\n              streamId,\n              reason: wrapReason(reason),\n            });\n          }\n        );\n        streamSink.sinkCapability.reject(dataReason);\n        streamSink.isCancelled = true;\n        delete this.streamSinks[streamId];\n        break;\n      default:\n        throw new Error(\"Unexpected stream case\");\n    }\n  }\n\n  async #deleteStreamController(streamController, streamId) {\n    // Delete the `streamController` only when the start, pull, and cancel\n    // capabilities have settled, to prevent `TypeError`s.\n    await Promise.allSettled([\n      streamController.startCall?.promise,\n      streamController.pullCall?.promise,\n      streamController.cancelCall?.promise,\n    ]);\n    delete this.streamControllers[streamId];\n  }\n\n  destroy() {\n    this.#messageAC?.abort();\n    this.#messageAC = null;\n  }\n}\n\nexport { MessageHandler, wrapReason };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { unreachable } from \"../shared/util.js\";\n\nclass BaseCanvasFactory {\n  #enableHWA = false;\n\n  constructor({ enableHWA = false }) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseCanvasFactory\n    ) {\n      unreachable(\"Cannot initialize BaseCanvasFactory.\");\n    }\n    this.#enableHWA = enableHWA;\n  }\n\n  create(width, height) {\n    if (width <= 0 || height <= 0) {\n      throw new Error(\"Invalid canvas size\");\n    }\n    const canvas = this._createCanvas(width, height);\n    return {\n      canvas,\n      context: canvas.getContext(\"2d\", {\n        willReadFrequently: !this.#enableHWA,\n      }),\n    };\n  }\n\n  reset(canvasAndContext, width, height) {\n    if (!canvasAndContext.canvas) {\n      throw new Error(\"Canvas is not specified\");\n    }\n    if (width <= 0 || height <= 0) {\n      throw new Error(\"Invalid canvas size\");\n    }\n    canvasAndContext.canvas.width = width;\n    canvasAndContext.canvas.height = height;\n  }\n\n  destroy(canvasAndContext) {\n    if (!canvasAndContext.canvas) {\n      throw new Error(\"Canvas is not specified\");\n    }\n    // Zeroing the width and height cause Firefox to release graphics\n    // resources immediately, which can greatly reduce memory consumption.\n    canvasAndContext.canvas.width = 0;\n    canvasAndContext.canvas.height = 0;\n    canvasAndContext.canvas = null;\n    canvasAndContext.context = null;\n  }\n\n  /**\n   * @ignore\n   */\n  _createCanvas(width, height) {\n    unreachable(\"Abstract method `_createCanvas` called.\");\n  }\n}\n\nclass DOMCanvasFactory extends BaseCanvasFactory {\n  constructor({ ownerDocument = globalThis.document, enableHWA = false }) {\n    super({ enableHWA });\n    this._document = ownerDocument;\n  }\n\n  /**\n   * @ignore\n   */\n  _createCanvas(width, height) {\n    const canvas = this._document.createElement(\"canvas\");\n    canvas.width = width;\n    canvas.height = height;\n    return canvas;\n  }\n}\n\nexport { BaseCanvasFactory, DOMCanvasFactory };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { stringToBytes, unreachable } from \"../shared/util.js\";\nimport { fetchData } from \"./display_utils.js\";\n\nclass BaseCMapReaderFactory {\n  constructor({ baseUrl = null, isCompressed = true }) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseCMapReaderFactory\n    ) {\n      unreachable(\"Cannot initialize BaseCMapReaderFactory.\");\n    }\n    this.baseUrl = baseUrl;\n    this.isCompressed = isCompressed;\n  }\n\n  async fetch({ name }) {\n    if (!this.baseUrl) {\n      throw new Error(\n        \"Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.\"\n      );\n    }\n    if (!name) {\n      throw new Error(\"CMap name must be specified.\");\n    }\n    const url = this.baseUrl + name + (this.isCompressed ? \".bcmap\" : \"\");\n\n    return this._fetch(url)\n      .then(cMapData => ({ cMapData, isCompressed: this.isCompressed }))\n      .catch(reason => {\n        throw new Error(\n          `Unable to load ${this.isCompressed ? \"binary \" : \"\"}CMap at: ${url}`\n        );\n      });\n  }\n\n  /**\n   * @ignore\n   * @returns {Promise<Uint8Array>}\n   */\n  async _fetch(url) {\n    unreachable(\"Abstract method `_fetch` called.\");\n  }\n}\n\nclass DOMCMapReaderFactory extends BaseCMapReaderFactory {\n  /**\n   * @ignore\n   */\n  async _fetch(url) {\n    const data = await fetchData(\n      url,\n      /* type = */ this.isCompressed ? \"bytes\" : \"text\"\n    );\n    return data instanceof Uint8Array ? data : stringToBytes(data);\n  }\n}\n\nexport { BaseCMapReaderFactory, DOMCMapReaderFactory };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { getRGB, isDataScheme, SVG_NS } from \"./display_utils.js\";\nimport { unreachable, updateUrlHash, Util, warn } from \"../shared/util.js\";\n\nclass BaseFilterFactory {\n  constructor() {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseFilterFactory\n    ) {\n      unreachable(\"Cannot initialize BaseFilterFactory.\");\n    }\n  }\n\n  addFilter(maps) {\n    return \"none\";\n  }\n\n  addHCMFilter(fgColor, bgColor) {\n    return \"none\";\n  }\n\n  addAlphaFilter(map) {\n    return \"none\";\n  }\n\n  addLuminosityFilter(map) {\n    return \"none\";\n  }\n\n  addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {\n    return \"none\";\n  }\n\n  destroy(keepHCM = false) {}\n}\n\n/**\n * FilterFactory aims to create some SVG filters we can use when drawing an\n * image (or whatever) on a canvas.\n * Filters aren't applied with ctx.putImageData because it just overwrites the\n * underlying pixels.\n * With these filters, it's possible for example to apply some transfer maps on\n * an image without the need to apply them on the pixel arrays: the renderer\n * does the magic for us.\n */\nclass DOMFilterFactory extends BaseFilterFactory {\n  #baseUrl;\n\n  #_cache;\n\n  #_defs;\n\n  #docId;\n\n  #document;\n\n  #_hcmCache;\n\n  #id = 0;\n\n  constructor({ docId, ownerDocument = globalThis.document }) {\n    super();\n    this.#docId = docId;\n    this.#document = ownerDocument;\n  }\n\n  get #cache() {\n    return (this.#_cache ||= new Map());\n  }\n\n  get #hcmCache() {\n    return (this.#_hcmCache ||= new Map());\n  }\n\n  get #defs() {\n    if (!this.#_defs) {\n      const div = this.#document.createElement(\"div\");\n      const { style } = div;\n      style.visibility = \"hidden\";\n      style.contain = \"strict\";\n      style.width = style.height = 0;\n      style.position = \"absolute\";\n      style.top = style.left = 0;\n      style.zIndex = -1;\n\n      const svg = this.#document.createElementNS(SVG_NS, \"svg\");\n      svg.setAttribute(\"width\", 0);\n      svg.setAttribute(\"height\", 0);\n      this.#_defs = this.#document.createElementNS(SVG_NS, \"defs\");\n      div.append(svg);\n      svg.append(this.#_defs);\n      this.#document.body.append(div);\n    }\n    return this.#_defs;\n  }\n\n  #createTables(maps) {\n    if (maps.length === 1) {\n      const mapR = maps[0];\n      const buffer = new Array(256);\n      for (let i = 0; i < 256; i++) {\n        buffer[i] = mapR[i] / 255;\n      }\n\n      const table = buffer.join(\",\");\n      return [table, table, table];\n    }\n\n    const [mapR, mapG, mapB] = maps;\n    const bufferR = new Array(256);\n    const bufferG = new Array(256);\n    const bufferB = new Array(256);\n    for (let i = 0; i < 256; i++) {\n      bufferR[i] = mapR[i] / 255;\n      bufferG[i] = mapG[i] / 255;\n      bufferB[i] = mapB[i] / 255;\n    }\n    return [bufferR.join(\",\"), bufferG.join(\",\"), bufferB.join(\",\")];\n  }\n\n  #createUrl(id) {\n    if (this.#baseUrl === undefined) {\n      // Unless a `<base>`-element is present a relative URL should work.\n      this.#baseUrl = \"\";\n\n      const url = this.#document.URL;\n      if (url !== this.#document.baseURI) {\n        if (isDataScheme(url)) {\n          warn('#createUrl: ignore \"data:\"-URL for performance reasons.');\n        } else {\n          this.#baseUrl = updateUrlHash(url, \"\");\n        }\n      }\n    }\n    return `url(${this.#baseUrl}#${id})`;\n  }\n\n  addFilter(maps) {\n    if (!maps) {\n      return \"none\";\n    }\n\n    // When a page is zoomed the page is re-drawn but the maps are likely\n    // the same.\n    let value = this.#cache.get(maps);\n    if (value) {\n      return value;\n    }\n\n    const [tableR, tableG, tableB] = this.#createTables(maps);\n    const key = maps.length === 1 ? tableR : `${tableR}${tableG}${tableB}`;\n\n    value = this.#cache.get(key);\n    if (value) {\n      this.#cache.set(maps, value);\n      return value;\n    }\n\n    // We create a SVG filter: feComponentTransferElement\n    //  https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement\n\n    const id = `g_${this.#docId}_transfer_map_${this.#id++}`;\n    const url = this.#createUrl(id);\n    this.#cache.set(maps, url);\n    this.#cache.set(key, url);\n\n    const filter = this.#createFilter(id);\n    this.#addTransferMapConversion(tableR, tableG, tableB, filter);\n\n    return url;\n  }\n\n  addHCMFilter(fgColor, bgColor) {\n    const key = `${fgColor}-${bgColor}`;\n    const filterName = \"base\";\n    let info = this.#hcmCache.get(filterName);\n    if (info?.key === key) {\n      return info.url;\n    }\n\n    if (info) {\n      info.filter?.remove();\n      info.key = key;\n      info.url = \"none\";\n      info.filter = null;\n    } else {\n      info = {\n        key,\n        url: \"none\",\n        filter: null,\n      };\n      this.#hcmCache.set(filterName, info);\n    }\n\n    if (!fgColor || !bgColor) {\n      return info.url;\n    }\n\n    const fgRGB = this.#getRGB(fgColor);\n    fgColor = Util.makeHexColor(...fgRGB);\n    const bgRGB = this.#getRGB(bgColor);\n    bgColor = Util.makeHexColor(...bgRGB);\n    this.#defs.style.color = \"\";\n\n    if (\n      (fgColor === \"#000000\" && bgColor === \"#ffffff\") ||\n      fgColor === bgColor\n    ) {\n      return info.url;\n    }\n\n    // https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_Colors_and_Luminance\n    //\n    // Relative luminance:\n    // https://www.w3.org/TR/WCAG20/#relativeluminancedef\n    //\n    // We compute the rounded luminance of the default background color.\n    // Then for every color in the pdf, if its rounded luminance is the\n    // same as the background one then it's replaced by the new\n    // background color else by the foreground one.\n    const map = new Array(256);\n    for (let i = 0; i <= 255; i++) {\n      const x = i / 255;\n      map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;\n    }\n    const table = map.join(\",\");\n\n    const id = `g_${this.#docId}_hcm_filter`;\n    const filter = (info.filter = this.#createFilter(id));\n    this.#addTransferMapConversion(table, table, table, filter);\n    this.#addGrayConversion(filter);\n\n    const getSteps = (c, n) => {\n      const start = fgRGB[c] / 255;\n      const end = bgRGB[c] / 255;\n      const arr = new Array(n + 1);\n      for (let i = 0; i <= n; i++) {\n        arr[i] = start + (i / n) * (end - start);\n      }\n      return arr.join(\",\");\n    };\n    this.#addTransferMapConversion(\n      getSteps(0, 5),\n      getSteps(1, 5),\n      getSteps(2, 5),\n      filter\n    );\n\n    info.url = this.#createUrl(id);\n    return info.url;\n  }\n\n  addAlphaFilter(map) {\n    // When a page is zoomed the page is re-drawn but the maps are likely\n    // the same.\n    let value = this.#cache.get(map);\n    if (value) {\n      return value;\n    }\n\n    const [tableA] = this.#createTables([map]);\n    const key = `alpha_${tableA}`;\n\n    value = this.#cache.get(key);\n    if (value) {\n      this.#cache.set(map, value);\n      return value;\n    }\n\n    const id = `g_${this.#docId}_alpha_map_${this.#id++}`;\n    const url = this.#createUrl(id);\n    this.#cache.set(map, url);\n    this.#cache.set(key, url);\n\n    const filter = this.#createFilter(id);\n    this.#addTransferMapAlphaConversion(tableA, filter);\n\n    return url;\n  }\n\n  addLuminosityFilter(map) {\n    // When a page is zoomed the page is re-drawn but the maps are likely\n    // the same.\n    let value = this.#cache.get(map || \"luminosity\");\n    if (value) {\n      return value;\n    }\n\n    let tableA, key;\n    if (map) {\n      [tableA] = this.#createTables([map]);\n      key = `luminosity_${tableA}`;\n    } else {\n      key = \"luminosity\";\n    }\n\n    value = this.#cache.get(key);\n    if (value) {\n      this.#cache.set(map, value);\n      return value;\n    }\n\n    const id = `g_${this.#docId}_luminosity_map_${this.#id++}`;\n    const url = this.#createUrl(id);\n    this.#cache.set(map, url);\n    this.#cache.set(key, url);\n\n    const filter = this.#createFilter(id);\n    this.#addLuminosityConversion(filter);\n    if (map) {\n      this.#addTransferMapAlphaConversion(tableA, filter);\n    }\n\n    return url;\n  }\n\n  addHighlightHCMFilter(filterName, fgColor, bgColor, newFgColor, newBgColor) {\n    const key = `${fgColor}-${bgColor}-${newFgColor}-${newBgColor}`;\n    let info = this.#hcmCache.get(filterName);\n    if (info?.key === key) {\n      return info.url;\n    }\n\n    if (info) {\n      info.filter?.remove();\n      info.key = key;\n      info.url = \"none\";\n      info.filter = null;\n    } else {\n      info = {\n        key,\n        url: \"none\",\n        filter: null,\n      };\n      this.#hcmCache.set(filterName, info);\n    }\n\n    if (!fgColor || !bgColor) {\n      return info.url;\n    }\n\n    const [fgRGB, bgRGB] = [fgColor, bgColor].map(this.#getRGB.bind(this));\n    let fgGray = Math.round(\n      0.2126 * fgRGB[0] + 0.7152 * fgRGB[1] + 0.0722 * fgRGB[2]\n    );\n    let bgGray = Math.round(\n      0.2126 * bgRGB[0] + 0.7152 * bgRGB[1] + 0.0722 * bgRGB[2]\n    );\n    let [newFgRGB, newBgRGB] = [newFgColor, newBgColor].map(\n      this.#getRGB.bind(this)\n    );\n    if (bgGray < fgGray) {\n      [fgGray, bgGray, newFgRGB, newBgRGB] = [\n        bgGray,\n        fgGray,\n        newBgRGB,\n        newFgRGB,\n      ];\n    }\n    this.#defs.style.color = \"\";\n\n    // Now we can create the filters to highlight some canvas parts.\n    // The colors in the pdf will almost be Canvas and CanvasText, hence we\n    // want to filter them to finally get Highlight and HighlightText.\n    // Since we're in HCM the background color and the foreground color should\n    // be really different when converted to grayscale (if they're not then it\n    // means that we've a poor contrast). Once the canvas colors are converted\n    // to grayscale we can easily map them on their new colors.\n    // The grayscale step is important because if we've something like:\n    //   fgColor = #FF....\n    //   bgColor = #FF....\n    //   then we are enable to map the red component on the new red components\n    //   which can be different.\n\n    const getSteps = (fg, bg, n) => {\n      const arr = new Array(256);\n      const step = (bgGray - fgGray) / n;\n      const newStart = fg / 255;\n      const newStep = (bg - fg) / (255 * n);\n      let prev = 0;\n      for (let i = 0; i <= n; i++) {\n        const k = Math.round(fgGray + i * step);\n        const value = newStart + i * newStep;\n        for (let j = prev; j <= k; j++) {\n          arr[j] = value;\n        }\n        prev = k + 1;\n      }\n      for (let i = prev; i < 256; i++) {\n        arr[i] = arr[prev - 1];\n      }\n      return arr.join(\",\");\n    };\n\n    const id = `g_${this.#docId}_hcm_${filterName}_filter`;\n    const filter = (info.filter = this.#createFilter(id));\n\n    this.#addGrayConversion(filter);\n    this.#addTransferMapConversion(\n      getSteps(newFgRGB[0], newBgRGB[0], 5),\n      getSteps(newFgRGB[1], newBgRGB[1], 5),\n      getSteps(newFgRGB[2], newBgRGB[2], 5),\n      filter\n    );\n\n    info.url = this.#createUrl(id);\n    return info.url;\n  }\n\n  destroy(keepHCM = false) {\n    if (keepHCM && this.#_hcmCache?.size) {\n      return;\n    }\n    this.#_defs?.parentNode.parentNode.remove();\n    this.#_defs = null;\n\n    this.#_cache?.clear();\n    this.#_cache = null;\n\n    this.#_hcmCache?.clear();\n    this.#_hcmCache = null;\n\n    this.#id = 0;\n  }\n\n  #addLuminosityConversion(filter) {\n    const feColorMatrix = this.#document.createElementNS(\n      SVG_NS,\n      \"feColorMatrix\"\n    );\n    feColorMatrix.setAttribute(\"type\", \"matrix\");\n    feColorMatrix.setAttribute(\n      \"values\",\n      \"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0\"\n    );\n    filter.append(feColorMatrix);\n  }\n\n  #addGrayConversion(filter) {\n    const feColorMatrix = this.#document.createElementNS(\n      SVG_NS,\n      \"feColorMatrix\"\n    );\n    feColorMatrix.setAttribute(\"type\", \"matrix\");\n    feColorMatrix.setAttribute(\n      \"values\",\n      \"0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0\"\n    );\n    filter.append(feColorMatrix);\n  }\n\n  #createFilter(id) {\n    const filter = this.#document.createElementNS(SVG_NS, \"filter\");\n    filter.setAttribute(\"color-interpolation-filters\", \"sRGB\");\n    filter.setAttribute(\"id\", id);\n    this.#defs.append(filter);\n\n    return filter;\n  }\n\n  #appendFeFunc(feComponentTransfer, func, table) {\n    const feFunc = this.#document.createElementNS(SVG_NS, func);\n    feFunc.setAttribute(\"type\", \"discrete\");\n    feFunc.setAttribute(\"tableValues\", table);\n    feComponentTransfer.append(feFunc);\n  }\n\n  #addTransferMapConversion(rTable, gTable, bTable, filter) {\n    const feComponentTransfer = this.#document.createElementNS(\n      SVG_NS,\n      \"feComponentTransfer\"\n    );\n    filter.append(feComponentTransfer);\n    this.#appendFeFunc(feComponentTransfer, \"feFuncR\", rTable);\n    this.#appendFeFunc(feComponentTransfer, \"feFuncG\", gTable);\n    this.#appendFeFunc(feComponentTransfer, \"feFuncB\", bTable);\n  }\n\n  #addTransferMapAlphaConversion(aTable, filter) {\n    const feComponentTransfer = this.#document.createElementNS(\n      SVG_NS,\n      \"feComponentTransfer\"\n    );\n    filter.append(feComponentTransfer);\n    this.#appendFeFunc(feComponentTransfer, \"feFuncA\", aTable);\n  }\n\n  #getRGB(color) {\n    this.#defs.style.color = color;\n    return getRGB(getComputedStyle(this.#defs).getPropertyValue(\"color\"));\n  }\n}\n\nexport { BaseFilterFactory, DOMFilterFactory };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { fetchData } from \"./display_utils.js\";\nimport { unreachable } from \"../shared/util.js\";\n\nclass BaseStandardFontDataFactory {\n  constructor({ baseUrl = null }) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseStandardFontDataFactory\n    ) {\n      unreachable(\"Cannot initialize BaseStandardFontDataFactory.\");\n    }\n    this.baseUrl = baseUrl;\n  }\n\n  async fetch({ filename }) {\n    if (!this.baseUrl) {\n      throw new Error(\n        \"Ensure that the `standardFontDataUrl` API parameter is provided.\"\n      );\n    }\n    if (!filename) {\n      throw new Error(\"Font filename must be specified.\");\n    }\n    const url = `${this.baseUrl}${filename}`;\n\n    return this._fetch(url).catch(reason => {\n      throw new Error(`Unable to load font data at: ${url}`);\n    });\n  }\n\n  /**\n   * @ignore\n   * @returns {Promise<Uint8Array>}\n   */\n  async _fetch(url) {\n    unreachable(\"Abstract method `_fetch` called.\");\n  }\n}\n\nclass DOMStandardFontDataFactory extends BaseStandardFontDataFactory {\n  /**\n   * @ignore\n   */\n  async _fetch(url) {\n    return fetchData(url, /* type = */ \"bytes\");\n  }\n}\n\nexport { BaseStandardFontDataFactory, DOMStandardFontDataFactory };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { fetchData } from \"./display_utils.js\";\nimport { unreachable } from \"../shared/util.js\";\n\nclass BaseWasmFactory {\n  constructor({ baseUrl = null }) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseWasmFactory\n    ) {\n      unreachable(\"Cannot initialize BaseWasmFactory.\");\n    }\n    this.baseUrl = baseUrl;\n  }\n\n  async fetch({ filename }) {\n    if (!this.baseUrl) {\n      throw new Error(\"Ensure that the `wasmUrl` API parameter is provided.\");\n    }\n    if (!filename) {\n      throw new Error(\"Wasm filename must be specified.\");\n    }\n    const url = `${this.baseUrl}${filename}`;\n\n    return this._fetch(url).catch(reason => {\n      throw new Error(`Unable to load wasm data at: ${url}`);\n    });\n  }\n\n  /**\n   * @ignore\n   * @returns {Promise<Uint8Array>}\n   */\n  async _fetch(url) {\n    unreachable(\"Abstract method `_fetch` called.\");\n  }\n}\n\nclass DOMWasmFactory extends BaseWasmFactory {\n  /**\n   * @ignore\n   */\n  async _fetch(url) {\n    return fetchData(url, /* type = */ \"bytes\");\n  }\n}\n\nexport { BaseWasmFactory, DOMWasmFactory };\n","/* Copyright 2020 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/* globals process */\n\nimport { isNodeJS, warn } from \"../shared/util.js\";\nimport { BaseCanvasFactory } from \"./canvas_factory.js\";\nimport { BaseCMapReaderFactory } from \"./cmap_reader_factory.js\";\nimport { BaseFilterFactory } from \"./filter_factory.js\";\nimport { BaseStandardFontDataFactory } from \"./standard_fontdata_factory.js\";\nimport { BaseWasmFactory } from \"./wasm_factory.js\";\n\nif (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n  throw new Error(\n    'Module \"./node_utils.js\" shall not be used with MOZCENTRAL builds.'\n  );\n}\n\nif (isNodeJS) {\n  if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"SKIP_BABEL\")) {\n    warn(\"Please use the `legacy` build in Node.js environments.\");\n  } else {\n    let canvas;\n    try {\n      const require = process\n        .getBuiltinModule(\"module\")\n        .createRequire(import.meta.url);\n\n      try {\n        canvas = require(\"@napi-rs/canvas\");\n      } catch (ex) {\n        warn(`Cannot load \"@napi-rs/canvas\" package: \"${ex}\".`);\n      }\n    } catch (ex) {\n      warn(`Cannot access the \\`require\\` function: \"${ex}\".`);\n    }\n\n    if (!globalThis.DOMMatrix) {\n      if (canvas?.DOMMatrix) {\n        globalThis.DOMMatrix = canvas.DOMMatrix;\n      } else {\n        warn(\"Cannot polyfill `DOMMatrix`, rendering may be broken.\");\n      }\n    }\n    if (!globalThis.ImageData) {\n      if (canvas?.ImageData) {\n        globalThis.ImageData = canvas.ImageData;\n      } else {\n        warn(\"Cannot polyfill `ImageData`, rendering may be broken.\");\n      }\n    }\n    if (!globalThis.Path2D) {\n      if (canvas?.Path2D) {\n        globalThis.Path2D = canvas.Path2D;\n      } else {\n        warn(\"Cannot polyfill `Path2D`, rendering may be broken.\");\n      }\n    }\n    if (!globalThis.navigator?.language) {\n      globalThis.navigator = {\n        language: \"en-US\",\n        platform: \"\",\n        userAgent: \"\",\n      };\n    }\n  }\n}\n\nasync function fetchData(url) {\n  const fs = process.getBuiltinModule(\"fs\");\n  const data = await fs.promises.readFile(url);\n  return new Uint8Array(data);\n}\n\nclass NodeFilterFactory extends BaseFilterFactory {}\n\nclass NodeCanvasFactory extends BaseCanvasFactory {\n  /**\n   * @ignore\n   */\n  _createCanvas(width, height) {\n    const require = process\n      .getBuiltinModule(\"module\")\n      .createRequire(import.meta.url);\n    const canvas = require(\"@napi-rs/canvas\");\n    return canvas.createCanvas(width, height);\n  }\n}\n\nclass NodeCMapReaderFactory extends BaseCMapReaderFactory {\n  /**\n   * @ignore\n   */\n  async _fetch(url) {\n    return fetchData(url);\n  }\n}\n\nclass NodeStandardFontDataFactory extends BaseStandardFontDataFactory {\n  /**\n   * @ignore\n   */\n  async _fetch(url) {\n    return fetchData(url);\n  }\n}\n\nclass NodeWasmFactory extends BaseWasmFactory {\n  /**\n   * @ignore\n   */\n  async _fetch(url) {\n    return fetchData(url);\n  }\n}\n\nexport {\n  fetchData,\n  NodeCanvasFactory,\n  NodeCMapReaderFactory,\n  NodeFilterFactory,\n  NodeStandardFontDataFactory,\n  NodeWasmFactory,\n};\n","/* Copyright 2025 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Util } from \"../shared/util.js\";\n\nconst FORCED_DEPENDENCY_LABEL = \"__forcedDependency\";\n\nconst { floor, ceil } = Math;\n\nfunction expandBBox(array, index, minX, minY, maxX, maxY) {\n  array[index * 4 + 0] = Math.min(array[index * 4 + 0], minX);\n  array[index * 4 + 1] = Math.min(array[index * 4 + 1], minY);\n  array[index * 4 + 2] = Math.max(array[index * 4 + 2], maxX);\n  array[index * 4 + 3] = Math.max(array[index * 4 + 3], maxY);\n}\n\n// This is computed rathter than hard-coded to keep into\n// account the platform's endianess.\nconst EMPTY_BBOX = new Uint32Array(new Uint8Array([255, 255, 0, 0]).buffer)[0];\n\nclass BBoxReader {\n  #bboxes;\n\n  #coords;\n\n  constructor(bboxes, coords) {\n    this.#bboxes = bboxes;\n    this.#coords = coords;\n  }\n\n  get length() {\n    return this.#bboxes.length;\n  }\n\n  isEmpty(i) {\n    return this.#bboxes[i] === EMPTY_BBOX;\n  }\n\n  minX(i) {\n    return this.#coords[i * 4 + 0] / 256;\n  }\n\n  minY(i) {\n    return this.#coords[i * 4 + 1] / 256;\n  }\n\n  maxX(i) {\n    return (this.#coords[i * 4 + 2] + 1) / 256;\n  }\n\n  maxY(i) {\n    return (this.#coords[i * 4 + 3] + 1) / 256;\n  }\n}\n\nconst ensureDebugMetadata = (map, key) =>\n  map?.getOrInsertComputed(key, () => ({\n    dependencies: new Set(),\n    isRenderingOperation: false,\n  }));\n\n/**\n * @typedef {\"lineWidth\" | \"lineCap\" | \"lineJoin\" | \"miterLimit\" | \"dash\" |\n * \"strokeAlpha\" | \"fillColor\" | \"fillAlpha\" | \"globalCompositeOperation\" |\n * \"path\" | \"filter\" | \"font\" | \"fontObj\"} SimpleDependency\n */\n\n/**\n * @typedef {\"transform\" | \"moveText\" | \"sameLineText\"} IncrementalDependency\n */\n\n/**\n * @typedef {IncrementalDependency |\n * typeof FORCED_DEPENDENCY_LABEL} InternalIncrementalDependency\n */\nclass CanvasDependencyTracker {\n  /** @type {Record<SimpleDependency, number>} */\n  #simple = { __proto__: null };\n\n  /** @type {Record<InternalIncrementalDependency , number[]>} */\n  #incremental = {\n    __proto__: null,\n    transform: [],\n    moveText: [],\n    sameLineText: [],\n    [FORCED_DEPENDENCY_LABEL]: [],\n  };\n\n  #namedDependencies = new Map();\n\n  #savesStack = [];\n\n  #markedContentStack = [];\n\n  #baseTransformStack = [[1, 0, 0, 1, 0, 0]];\n\n  #clipBox = [-Infinity, -Infinity, Infinity, Infinity];\n\n  // Float32Array<minX, minY, maxX, maxY>\n  #pendingBBox = new Float64Array([Infinity, Infinity, -Infinity, -Infinity]);\n\n  #pendingBBoxIdx = -1;\n\n  #pendingDependencies = new Set();\n\n  #operations = new Map();\n\n  #fontBBoxTrustworthy = new Map();\n\n  #canvasWidth;\n\n  #canvasHeight;\n\n  // Uint8ClampedArray<minX, minY, maxX, maxY>\n  #bboxesCoords;\n\n  #bboxes;\n\n  #debugMetadata;\n\n  constructor(canvas, operationsCount, recordDebugMetadata = false) {\n    this.#canvasWidth = canvas.width;\n    this.#canvasHeight = canvas.height;\n    this.#initializeBBoxes(operationsCount);\n    if (recordDebugMetadata) {\n      this.#debugMetadata = new Map();\n    }\n  }\n\n  growOperationsCount(operationsCount) {\n    if (operationsCount >= this.#bboxes.length) {\n      this.#initializeBBoxes(operationsCount, this.#bboxes);\n    }\n  }\n\n  #initializeBBoxes(operationsCount, oldBBoxes) {\n    const buffer = new ArrayBuffer(operationsCount * 4);\n    this.#bboxesCoords = new Uint8ClampedArray(buffer);\n    this.#bboxes = new Uint32Array(buffer);\n    if (oldBBoxes && oldBBoxes.length > 0) {\n      this.#bboxes.set(oldBBoxes);\n      this.#bboxes.fill(EMPTY_BBOX, oldBBoxes.length);\n    } else {\n      this.#bboxes.fill(EMPTY_BBOX);\n    }\n  }\n\n  save(opIdx) {\n    this.#simple = { __proto__: this.#simple };\n    this.#incremental = {\n      __proto__: this.#incremental,\n      transform: { __proto__: this.#incremental.transform },\n      moveText: { __proto__: this.#incremental.moveText },\n      sameLineText: { __proto__: this.#incremental.sameLineText },\n      [FORCED_DEPENDENCY_LABEL]: {\n        __proto__: this.#incremental[FORCED_DEPENDENCY_LABEL],\n      },\n    };\n    this.#clipBox = { __proto__: this.#clipBox };\n    this.#savesStack.push(opIdx);\n\n    return this;\n  }\n\n  restore(opIdx) {\n    const previous = Object.getPrototypeOf(this.#simple);\n    if (previous === null) {\n      // Sometimes we call more .restore() than .save(), for\n      // example when using CanvasGraphics' #restoreInitialState()\n      return this;\n    }\n    this.#simple = previous;\n    this.#incremental = Object.getPrototypeOf(this.#incremental);\n    this.#clipBox = Object.getPrototypeOf(this.#clipBox);\n\n    const lastSave = this.#savesStack.pop();\n    if (lastSave !== undefined) {\n      ensureDebugMetadata(this.#debugMetadata, opIdx)?.dependencies.add(\n        lastSave\n      );\n      this.#bboxes[opIdx] = this.#bboxes[lastSave];\n    }\n\n    return this;\n  }\n\n  /**\n   * @param {number} idx\n   */\n  recordOpenMarker(idx) {\n    this.#savesStack.push(idx);\n    return this;\n  }\n\n  getOpenMarker() {\n    if (this.#savesStack.length === 0) {\n      return null;\n    }\n    return this.#savesStack.at(-1);\n  }\n\n  recordCloseMarker(opIdx) {\n    const lastSave = this.#savesStack.pop();\n    if (lastSave !== undefined) {\n      ensureDebugMetadata(this.#debugMetadata, opIdx)?.dependencies.add(\n        lastSave\n      );\n      this.#bboxes[opIdx] = this.#bboxes[lastSave];\n    }\n    return this;\n  }\n\n  // Marked content needs a separate stack from save/restore, because they\n  // form two independent trees.\n  beginMarkedContent(opIdx) {\n    this.#markedContentStack.push(opIdx);\n    return this;\n  }\n\n  endMarkedContent(opIdx) {\n    const lastSave = this.#markedContentStack.pop();\n    if (lastSave !== undefined) {\n      ensureDebugMetadata(this.#debugMetadata, opIdx)?.dependencies.add(\n        lastSave\n      );\n      this.#bboxes[opIdx] = this.#bboxes[lastSave];\n    }\n    return this;\n  }\n\n  pushBaseTransform(ctx) {\n    this.#baseTransformStack.push(\n      Util.multiplyByDOMMatrix(\n        this.#baseTransformStack.at(-1),\n        ctx.getTransform()\n      )\n    );\n    return this;\n  }\n\n  popBaseTransform() {\n    if (this.#baseTransformStack.length > 1) {\n      this.#baseTransformStack.pop();\n    }\n    return this;\n  }\n\n  /**\n   * @param {SimpleDependency} name\n   * @param {number} idx\n   */\n  recordSimpleData(name, idx) {\n    this.#simple[name] = idx;\n    return this;\n  }\n\n  /**\n   * @param {IncrementalDependency} name\n   * @param {number} idx\n   */\n  recordIncrementalData(name, idx) {\n    this.#incremental[name].push(idx);\n    return this;\n  }\n\n  /**\n   * @param {IncrementalDependency} name\n   * @param {number} idx\n   */\n  resetIncrementalData(name, idx) {\n    this.#incremental[name].length = 0;\n    return this;\n  }\n\n  recordNamedData(name, idx) {\n    this.#namedDependencies.set(name, idx);\n    return this;\n  }\n\n  /**\n   * @param {SimpleDependency} name\n   * @param {string} depName\n   * @param {number} fallbackIdx\n   */\n  recordSimpleDataFromNamed(name, depName, fallbackIdx) {\n    this.#simple[name] = this.#namedDependencies.get(depName) ?? fallbackIdx;\n  }\n\n  // All next operations, until the next .restore(), will depend on this\n  recordFutureForcedDependency(name, idx) {\n    this.recordIncrementalData(FORCED_DEPENDENCY_LABEL, idx);\n    return this;\n  }\n\n  // All next operations, until the next .restore(), will depend on all\n  // the already recorded data with the given names.\n  inheritSimpleDataAsFutureForcedDependencies(names) {\n    for (const name of names) {\n      if (name in this.#simple) {\n        this.recordFutureForcedDependency(name, this.#simple[name]);\n      }\n    }\n    return this;\n  }\n\n  inheritPendingDependenciesAsFutureForcedDependencies() {\n    for (const dep of this.#pendingDependencies) {\n      this.recordFutureForcedDependency(FORCED_DEPENDENCY_LABEL, dep);\n    }\n    return this;\n  }\n\n  resetBBox(idx) {\n    if (this.#pendingBBoxIdx !== idx) {\n      this.#pendingBBoxIdx = idx;\n      this.#pendingBBox[0] = Infinity;\n      this.#pendingBBox[1] = Infinity;\n      this.#pendingBBox[2] = -Infinity;\n      this.#pendingBBox[3] = -Infinity;\n    }\n    return this;\n  }\n\n  recordClipBox(idx, ctx, minX, maxX, minY, maxY) {\n    const transform = Util.multiplyByDOMMatrix(\n      this.#baseTransformStack.at(-1),\n      ctx.getTransform()\n    );\n    const clipBox = [Infinity, Infinity, -Infinity, -Infinity];\n    Util.axialAlignedBoundingBox([minX, minY, maxX, maxY], transform, clipBox);\n    const intersection = Util.intersect(this.#clipBox, clipBox);\n    if (intersection) {\n      this.#clipBox[0] = intersection[0];\n      this.#clipBox[1] = intersection[1];\n      this.#clipBox[2] = intersection[2];\n      this.#clipBox[3] = intersection[3];\n    } else {\n      this.#clipBox[0] = this.#clipBox[1] = Infinity;\n      this.#clipBox[2] = this.#clipBox[3] = -Infinity;\n    }\n    return this;\n  }\n\n  recordBBox(idx, ctx, minX, maxX, minY, maxY) {\n    const clipBox = this.#clipBox;\n    if (clipBox[0] === Infinity) {\n      return this;\n    }\n\n    const transform = Util.multiplyByDOMMatrix(\n      this.#baseTransformStack.at(-1),\n      ctx.getTransform()\n    );\n    if (clipBox[0] === -Infinity) {\n      Util.axialAlignedBoundingBox(\n        [minX, minY, maxX, maxY],\n        transform,\n        this.#pendingBBox\n      );\n      return this;\n    }\n\n    const bbox = [Infinity, Infinity, -Infinity, -Infinity];\n    Util.axialAlignedBoundingBox([minX, minY, maxX, maxY], transform, bbox);\n    this.#pendingBBox[0] = Math.min(\n      this.#pendingBBox[0],\n      Math.max(bbox[0], clipBox[0])\n    );\n    this.#pendingBBox[1] = Math.min(\n      this.#pendingBBox[1],\n      Math.max(bbox[1], clipBox[1])\n    );\n    this.#pendingBBox[2] = Math.max(\n      this.#pendingBBox[2],\n      Math.min(bbox[2], clipBox[2])\n    );\n    this.#pendingBBox[3] = Math.max(\n      this.#pendingBBox[3],\n      Math.min(bbox[3], clipBox[3])\n    );\n    return this;\n  }\n\n  recordCharacterBBox(idx, ctx, font, scale = 1, x = 0, y = 0, getMeasure) {\n    const fontBBox = font.bbox;\n    let isBBoxTrustworthy;\n    let computedBBox;\n\n    if (fontBBox) {\n      isBBoxTrustworthy =\n        // Only use the bounding box defined by the font if it\n        // has a non-empty area.\n        fontBBox[2] !== fontBBox[0] &&\n        fontBBox[3] !== fontBBox[1] &&\n        this.#fontBBoxTrustworthy.get(font);\n\n      if (isBBoxTrustworthy !== false) {\n        computedBBox = [0, 0, 0, 0];\n        Util.axialAlignedBoundingBox(fontBBox, font.fontMatrix, computedBBox);\n        if (scale !== 1 || x !== 0 || y !== 0) {\n          Util.scaleMinMax([scale, 0, 0, -scale, x, y], computedBBox);\n        }\n\n        if (isBBoxTrustworthy) {\n          return this.recordBBox(\n            idx,\n            ctx,\n            computedBBox[0],\n            computedBBox[2],\n            computedBBox[1],\n            computedBBox[3]\n          );\n        }\n      }\n    }\n\n    if (!getMeasure) {\n      // We have no way of telling how big this character actually is, record\n      // a full page bounding box.\n      return this.recordFullPageBBox(idx);\n    }\n\n    const measure = getMeasure();\n\n    if (fontBBox && computedBBox && isBBoxTrustworthy === undefined) {\n      // If it's the first time we can compare the font bbox with the actual\n      // bbox measured when drawing it, check if the one recorded in the font\n      // is large enough to cover the actual bbox. If it is, we assume that the\n      // font is well-formed and we can use the declared bbox without having to\n      // measure it again for every character.\n      isBBoxTrustworthy =\n        computedBBox[0] <= x - measure.actualBoundingBoxLeft &&\n        computedBBox[2] >= x + measure.actualBoundingBoxRight &&\n        computedBBox[1] <= y - measure.actualBoundingBoxAscent &&\n        computedBBox[3] >= y + measure.actualBoundingBoxDescent;\n      this.#fontBBoxTrustworthy.set(font, isBBoxTrustworthy);\n      if (isBBoxTrustworthy) {\n        return this.recordBBox(\n          idx,\n          ctx,\n          computedBBox[0],\n          computedBBox[2],\n          computedBBox[1],\n          computedBBox[3]\n        );\n      }\n    }\n\n    // The font has no bbox or it is not trustworthy, so we need to\n    // return the bounding box based on .measureText().\n    return this.recordBBox(\n      idx,\n      ctx,\n      x - measure.actualBoundingBoxLeft,\n      x + measure.actualBoundingBoxRight,\n      y - measure.actualBoundingBoxAscent,\n      y + measure.actualBoundingBoxDescent\n    );\n  }\n\n  recordFullPageBBox(idx) {\n    this.#pendingBBox[0] = Math.max(0, this.#clipBox[0]);\n    this.#pendingBBox[1] = Math.max(0, this.#clipBox[1]);\n    this.#pendingBBox[2] = Math.min(this.#canvasWidth, this.#clipBox[2]);\n    this.#pendingBBox[3] = Math.min(this.#canvasHeight, this.#clipBox[3]);\n\n    return this;\n  }\n\n  getSimpleIndex(dependencyName) {\n    return this.#simple[dependencyName];\n  }\n\n  recordDependencies(idx, dependencyNames) {\n    const pendingDependencies = this.#pendingDependencies;\n    const simple = this.#simple;\n    const incremental = this.#incremental;\n    for (const name of dependencyNames) {\n      if (name in this.#simple) {\n        pendingDependencies.add(simple[name]);\n      } else if (name in incremental) {\n        incremental[name].forEach(pendingDependencies.add, pendingDependencies);\n      }\n    }\n\n    return this;\n  }\n\n  recordNamedDependency(idx, name) {\n    if (this.#namedDependencies.has(name)) {\n      this.#pendingDependencies.add(this.#namedDependencies.get(name));\n    }\n\n    return this;\n  }\n\n  /**\n   * @param {number} idx\n   */\n  recordOperation(idx, preserve = false) {\n    this.recordDependencies(idx, [FORCED_DEPENDENCY_LABEL]);\n\n    if (this.#debugMetadata) {\n      const metadata = ensureDebugMetadata(this.#debugMetadata, idx);\n      const { dependencies } = metadata;\n      this.#pendingDependencies.forEach(dependencies.add, dependencies);\n      this.#savesStack.forEach(dependencies.add, dependencies);\n      this.#markedContentStack.forEach(dependencies.add, dependencies);\n      dependencies.delete(idx);\n      metadata.isRenderingOperation = true;\n    }\n\n    if (this.#pendingBBoxIdx === idx) {\n      const minX = floor((this.#pendingBBox[0] * 256) / this.#canvasWidth);\n      const minY = floor((this.#pendingBBox[1] * 256) / this.#canvasHeight);\n      const maxX = ceil((this.#pendingBBox[2] * 256) / this.#canvasWidth);\n      const maxY = ceil((this.#pendingBBox[3] * 256) / this.#canvasHeight);\n\n      expandBBox(this.#bboxesCoords, idx, minX, minY, maxX, maxY);\n      for (const depIdx of this.#pendingDependencies) {\n        if (depIdx !== idx) {\n          expandBBox(this.#bboxesCoords, depIdx, minX, minY, maxX, maxY);\n        }\n      }\n      for (const saveIdx of this.#savesStack) {\n        if (saveIdx !== idx) {\n          expandBBox(this.#bboxesCoords, saveIdx, minX, minY, maxX, maxY);\n        }\n      }\n      for (const saveIdx of this.#markedContentStack) {\n        if (saveIdx !== idx) {\n          expandBBox(this.#bboxesCoords, saveIdx, minX, minY, maxX, maxY);\n        }\n      }\n\n      if (!preserve) {\n        this.#pendingDependencies.clear();\n        this.#pendingBBoxIdx = -1;\n      }\n    }\n\n    return this;\n  }\n\n  recordShowTextOperation(idx, preserve = false) {\n    const deps = Array.from(this.#pendingDependencies);\n    this.recordOperation(idx, preserve);\n    this.recordIncrementalData(\"sameLineText\", idx);\n    for (const dep of deps) {\n      this.recordIncrementalData(\"sameLineText\", dep);\n    }\n    return this;\n  }\n\n  bboxToClipBoxDropOperation(idx, preserve = false) {\n    if (this.#pendingBBoxIdx === idx) {\n      this.#pendingBBoxIdx = -1;\n\n      this.#clipBox[0] = Math.max(this.#clipBox[0], this.#pendingBBox[0]);\n      this.#clipBox[1] = Math.max(this.#clipBox[1], this.#pendingBBox[1]);\n      this.#clipBox[2] = Math.min(this.#clipBox[2], this.#pendingBBox[2]);\n      this.#clipBox[3] = Math.min(this.#clipBox[3], this.#pendingBBox[3]);\n\n      if (!preserve) {\n        this.#pendingDependencies.clear();\n      }\n    }\n    return this;\n  }\n\n  _takePendingDependencies() {\n    const pendingDependencies = this.#pendingDependencies;\n    this.#pendingDependencies = new Set();\n    return pendingDependencies;\n  }\n\n  _extractOperation(idx) {\n    const operation = this.#operations.get(idx);\n    this.#operations.delete(idx);\n    return operation;\n  }\n\n  _pushPendingDependencies(dependencies) {\n    for (const dep of dependencies) {\n      this.#pendingDependencies.add(dep);\n    }\n  }\n\n  take() {\n    this.#fontBBoxTrustworthy.clear();\n    return new BBoxReader(this.#bboxes, this.#bboxesCoords);\n  }\n\n  takeDebugMetadata() {\n    return this.#debugMetadata;\n  }\n}\n\n/**\n * Used to track dependencies of nested operations list, that\n * should actually all map to the index of the operation that\n * contains the nested list.\n *\n * @implements {CanvasDependencyTracker}\n */\nclass CanvasNestedDependencyTracker {\n  /** @type {CanvasDependencyTracker} */\n  #dependencyTracker;\n\n  /** @type {number} */\n  #opIdx;\n\n  #ignoreBBoxes;\n\n  #nestingLevel = 0;\n\n  #savesLevel = 0;\n\n  constructor(dependencyTracker, opIdx, ignoreBBoxes) {\n    if (\n      dependencyTracker instanceof CanvasNestedDependencyTracker &&\n      dependencyTracker.#ignoreBBoxes === !!ignoreBBoxes\n    ) {\n      // The goal of CanvasNestedDependencyTracker is to collapse all operations\n      // into a single one. If we are already in a\n      // CanvasNestedDependencyTracker, that is already happening.\n      return dependencyTracker;\n    }\n\n    this.#dependencyTracker = dependencyTracker;\n    this.#opIdx = opIdx;\n    this.#ignoreBBoxes = !!ignoreBBoxes;\n  }\n\n  growOperationsCount() {\n    throw new Error(\"Unreachable\");\n  }\n\n  save(opIdx) {\n    this.#savesLevel++;\n    this.#dependencyTracker.save(this.#opIdx);\n    return this;\n  }\n\n  restore(opIdx) {\n    if (this.#savesLevel > 0) {\n      this.#dependencyTracker.restore(this.#opIdx);\n      this.#savesLevel--;\n    }\n    return this;\n  }\n\n  recordOpenMarker(idx) {\n    this.#nestingLevel++;\n    return this;\n  }\n\n  getOpenMarker() {\n    return this.#nestingLevel > 0\n      ? this.#opIdx\n      : this.#dependencyTracker.getOpenMarker();\n  }\n\n  recordCloseMarker(idx) {\n    this.#nestingLevel--;\n    return this;\n  }\n\n  beginMarkedContent(opIdx) {\n    return this;\n  }\n\n  endMarkedContent(opIdx) {\n    return this;\n  }\n\n  pushBaseTransform(ctx) {\n    this.#dependencyTracker.pushBaseTransform(ctx);\n    return this;\n  }\n\n  popBaseTransform() {\n    this.#dependencyTracker.popBaseTransform();\n    return this;\n  }\n\n  /**\n   * @param {SimpleDependency} name\n   * @param {number} idx\n   */\n  recordSimpleData(name, idx) {\n    this.#dependencyTracker.recordSimpleData(name, this.#opIdx);\n    return this;\n  }\n\n  /**\n   * @param {IncrementalDependency} name\n   * @param {number} idx\n   */\n  recordIncrementalData(name, idx) {\n    this.#dependencyTracker.recordIncrementalData(name, this.#opIdx);\n    return this;\n  }\n\n  /**\n   * @param {IncrementalDependency} name\n   * @param {number} idx\n   */\n  resetIncrementalData(name, idx) {\n    this.#dependencyTracker.resetIncrementalData(name, this.#opIdx);\n    return this;\n  }\n\n  recordNamedData(name, idx) {\n    // Nested dependencies are not visible to the outside.\n    return this;\n  }\n\n  /**\n   * @param {SimpleDependency} name\n   * @param {string} depName\n   * @param {number} fallbackIdx\n   */\n  recordSimpleDataFromNamed(name, depName, fallbackIdx) {\n    this.#dependencyTracker.recordSimpleDataFromNamed(\n      name,\n      depName,\n      this.#opIdx\n    );\n    return this;\n  }\n\n  // All next operations, until the next .restore(), will depend on this\n  recordFutureForcedDependency(name, idx) {\n    this.#dependencyTracker.recordFutureForcedDependency(name, this.#opIdx);\n    return this;\n  }\n\n  // All next operations, until the next .restore(), will depend on all\n  // the already recorded data with the given names.\n  inheritSimpleDataAsFutureForcedDependencies(names) {\n    this.#dependencyTracker.inheritSimpleDataAsFutureForcedDependencies(names);\n    return this;\n  }\n\n  inheritPendingDependenciesAsFutureForcedDependencies() {\n    this.#dependencyTracker.inheritPendingDependenciesAsFutureForcedDependencies();\n    return this;\n  }\n\n  resetBBox(idx) {\n    if (!this.#ignoreBBoxes) {\n      this.#dependencyTracker.resetBBox(this.#opIdx);\n    }\n    return this;\n  }\n\n  recordClipBox(idx, ctx, minX, maxX, minY, maxY) {\n    if (!this.#ignoreBBoxes) {\n      this.#dependencyTracker.recordClipBox(\n        this.#opIdx,\n        ctx,\n        minX,\n        maxX,\n        minY,\n        maxY\n      );\n    }\n    return this;\n  }\n\n  recordBBox(idx, ctx, minX, maxX, minY, maxY) {\n    if (!this.#ignoreBBoxes) {\n      this.#dependencyTracker.recordBBox(\n        this.#opIdx,\n        ctx,\n        minX,\n        maxX,\n        minY,\n        maxY\n      );\n    }\n    return this;\n  }\n\n  recordCharacterBBox(idx, ctx, font, scale, x, y, getMeasure) {\n    if (!this.#ignoreBBoxes) {\n      this.#dependencyTracker.recordCharacterBBox(\n        this.#opIdx,\n        ctx,\n        font,\n        scale,\n        x,\n        y,\n        getMeasure\n      );\n    }\n    return this;\n  }\n\n  recordFullPageBBox(idx) {\n    if (!this.#ignoreBBoxes) {\n      this.#dependencyTracker.recordFullPageBBox(this.#opIdx);\n    }\n    return this;\n  }\n\n  getSimpleIndex(dependencyName) {\n    return this.#dependencyTracker.getSimpleIndex(dependencyName);\n  }\n\n  recordDependencies(idx, dependencyNames) {\n    this.#dependencyTracker.recordDependencies(this.#opIdx, dependencyNames);\n    return this;\n  }\n\n  recordNamedDependency(idx, name) {\n    this.#dependencyTracker.recordNamedDependency(this.#opIdx, name);\n    return this;\n  }\n\n  /**\n   * @param {number} idx\n   * @param {SimpleDependency[]} dependencyNames\n   */\n  recordOperation(idx) {\n    this.#dependencyTracker.recordOperation(this.#opIdx, true);\n    return this;\n  }\n\n  recordShowTextOperation(idx) {\n    this.#dependencyTracker.recordShowTextOperation(this.#opIdx, true);\n    return this;\n  }\n\n  bboxToClipBoxDropOperation(idx) {\n    if (!this.#ignoreBBoxes) {\n      this.#dependencyTracker.bboxToClipBoxDropOperation(this.#opIdx, true);\n    }\n    return this;\n  }\n\n  take() {\n    throw new Error(\"Unreachable\");\n  }\n\n  takeDebugMetadata() {\n    throw new Error(\"Unreachable\");\n  }\n}\n\n/** @satisfies {Record<string, SimpleDependency | IncrementalDependency>} */\nconst Dependencies = {\n  stroke: [\n    \"path\",\n    \"transform\",\n    \"filter\",\n    \"strokeColor\",\n    \"strokeAlpha\",\n    \"lineWidth\",\n    \"lineCap\",\n    \"lineJoin\",\n    \"miterLimit\",\n    \"dash\",\n  ],\n  fill: [\n    \"path\",\n    \"transform\",\n    \"filter\",\n    \"fillColor\",\n    \"fillAlpha\",\n    \"globalCompositeOperation\",\n    \"SMask\",\n  ],\n  imageXObject: [\n    \"transform\",\n    \"SMask\",\n    \"filter\",\n    \"fillAlpha\",\n    \"strokeAlpha\",\n    \"globalCompositeOperation\",\n  ],\n  rawFillPath: [\"filter\", \"fillColor\", \"fillAlpha\"],\n  showText: [\n    \"transform\",\n    \"leading\",\n    \"charSpacing\",\n    \"wordSpacing\",\n    \"hScale\",\n    \"textRise\",\n    \"moveText\",\n    \"textMatrix\",\n    \"font\",\n    \"fontObj\",\n    \"filter\",\n    \"fillColor\",\n    \"textRenderingMode\",\n    \"SMask\",\n    \"fillAlpha\",\n    \"strokeAlpha\",\n    \"globalCompositeOperation\",\n\n    \"sameLineText\",\n  ],\n  transform: [\"transform\"],\n  transformAndFill: [\"transform\", \"fillColor\"],\n};\n\nexport { CanvasDependencyTracker, CanvasNestedDependencyTracker, Dependencies };\n","/* Copyright 2014 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  FormatError,\n  info,\n  MeshFigureType,\n  unreachable,\n  Util,\n} from \"../shared/util.js\";\nimport { getCurrentTransform } from \"./display_utils.js\";\n\nconst PathType = {\n  FILL: \"Fill\",\n  STROKE: \"Stroke\",\n  SHADING: \"Shading\",\n};\n\nfunction applyBoundingBox(ctx, bbox) {\n  if (!bbox) {\n    return;\n  }\n  const width = bbox[2] - bbox[0];\n  const height = bbox[3] - bbox[1];\n  const region = new Path2D();\n  region.rect(bbox[0], bbox[1], width, height);\n  ctx.clip(region);\n}\n\nclass BaseShadingPattern {\n  constructor() {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseShadingPattern\n    ) {\n      unreachable(\"Cannot initialize BaseShadingPattern.\");\n    }\n  }\n\n  isModifyingCurrentTransform() {\n    return false;\n  }\n\n  getPattern() {\n    unreachable(\"Abstract method `getPattern` called.\");\n  }\n}\n\nclass RadialAxialShadingPattern extends BaseShadingPattern {\n  constructor(IR) {\n    super();\n    this._type = IR[1];\n    this._bbox = IR[2];\n    this._colorStops = IR[3];\n    this._p0 = IR[4];\n    this._p1 = IR[5];\n    this._r0 = IR[6];\n    this._r1 = IR[7];\n    this.matrix = null;\n  }\n\n  isOriginBased() {\n    return (\n      this._p0[0] === 0 &&\n      this._p0[1] === 0 &&\n      (!this.isRadial() || (this._p1[0] === 0 && this._p1[1] === 0))\n    );\n  }\n\n  isRadial() {\n    return this._type === \"radial\";\n  }\n\n  _createGradient(ctx, transform = null) {\n    let grad;\n    let firstPoint = this._p0;\n    let secondPoint = this._p1;\n    if (transform) {\n      firstPoint = firstPoint.slice();\n      secondPoint = secondPoint.slice();\n      Util.applyTransform(firstPoint, transform);\n      Util.applyTransform(secondPoint, transform);\n    }\n    if (this._type === \"axial\") {\n      grad = ctx.createLinearGradient(\n        firstPoint[0],\n        firstPoint[1],\n        secondPoint[0],\n        secondPoint[1]\n      );\n    } else if (this._type === \"radial\") {\n      let r0 = this._r0;\n      let r1 = this._r1;\n      if (transform) {\n        const scale = new Float32Array(2);\n        Util.singularValueDecompose2dScale(transform, scale);\n        r0 *= scale[0];\n        r1 *= scale[0];\n      }\n      grad = ctx.createRadialGradient(\n        firstPoint[0],\n        firstPoint[1],\n        r0,\n        secondPoint[0],\n        secondPoint[1],\n        r1\n      );\n    }\n\n    for (const colorStop of this._colorStops) {\n      grad.addColorStop(colorStop[0], colorStop[1]);\n    }\n    return grad;\n  }\n\n  getPattern(ctx, owner, inverse, pathType) {\n    let pattern;\n    if (pathType === PathType.STROKE || pathType === PathType.FILL) {\n      if (this.isOriginBased()) {\n        let transf = Util.transform(inverse, owner.baseTransform);\n        if (this.matrix) {\n          transf = Util.transform(transf, this.matrix);\n        }\n        const precision = 1e-3;\n        const n1 = Math.hypot(transf[0], transf[1]);\n        const n2 = Math.hypot(transf[2], transf[3]);\n        const ps = (transf[0] * transf[2] + transf[1] * transf[3]) / (n1 * n2);\n        if (Math.abs(ps) < precision) {\n          // The images of the basis vectors are orthogonal.\n          if (this.isRadial()) {\n            // If the images of the basis vectors are a square then the\n            // circles are transformed to circles and we can use a gradient\n            // directly.\n            if (Math.abs(n1 - n2) < precision) {\n              return this._createGradient(ctx, transf);\n            }\n          } else {\n            // The rectangles are transformed to rectangles and we can use a\n            // gradient directly.\n            return this._createGradient(ctx, transf);\n          }\n        }\n      }\n\n      const ownerBBox = owner.current.getClippedPathBoundingBox(\n        pathType,\n        getCurrentTransform(ctx)\n      ) || [0, 0, 0, 0];\n      // Create a canvas that is only as big as the current path. This doesn't\n      // allow us to cache the pattern, but it generally creates much smaller\n      // canvases and saves memory use. See bug 1722807 for an example.\n      const width = Math.ceil(ownerBBox[2] - ownerBBox[0]) || 1;\n      const height = Math.ceil(ownerBBox[3] - ownerBBox[1]) || 1;\n\n      const tmpCanvas = owner.cachedCanvases.getCanvas(\n        \"pattern\",\n        width,\n        height\n      );\n\n      const tmpCtx = tmpCanvas.context;\n      tmpCtx.clearRect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);\n      tmpCtx.beginPath();\n      tmpCtx.rect(0, 0, tmpCtx.canvas.width, tmpCtx.canvas.height);\n      // Non shading fill patterns are positioned relative to the base transform\n      // (usually the page's initial transform), but we may have created a\n      // smaller canvas based on the path, so we must account for the shift.\n      tmpCtx.translate(-ownerBBox[0], -ownerBBox[1]);\n      inverse = Util.transform(inverse, [\n        1,\n        0,\n        0,\n        1,\n        ownerBBox[0],\n        ownerBBox[1],\n      ]);\n\n      tmpCtx.transform(...owner.baseTransform);\n      if (this.matrix) {\n        tmpCtx.transform(...this.matrix);\n      }\n      applyBoundingBox(tmpCtx, this._bbox);\n\n      tmpCtx.fillStyle = this._createGradient(tmpCtx);\n      tmpCtx.fill();\n\n      pattern = ctx.createPattern(tmpCanvas.canvas, \"no-repeat\");\n      const domMatrix = new DOMMatrix(inverse);\n      pattern.setTransform(domMatrix);\n    } else {\n      // Shading fills are applied relative to the current matrix which is also\n      // how canvas gradients work, so there's no need to do anything special\n      // here.\n      applyBoundingBox(ctx, this._bbox);\n      pattern = this._createGradient(ctx);\n    }\n    return pattern;\n  }\n}\n\nfunction drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {\n  // Very basic Gouraud-shaded triangle rasterization algorithm.\n  const coords = context.coords,\n    colors = context.colors;\n  const bytes = data.data,\n    rowSize = data.width * 4;\n  let tmp;\n  if (coords[p1 + 1] > coords[p2 + 1]) {\n    tmp = p1;\n    p1 = p2;\n    p2 = tmp;\n    tmp = c1;\n    c1 = c2;\n    c2 = tmp;\n  }\n  if (coords[p2 + 1] > coords[p3 + 1]) {\n    tmp = p2;\n    p2 = p3;\n    p3 = tmp;\n    tmp = c2;\n    c2 = c3;\n    c3 = tmp;\n  }\n  if (coords[p1 + 1] > coords[p2 + 1]) {\n    tmp = p1;\n    p1 = p2;\n    p2 = tmp;\n    tmp = c1;\n    c1 = c2;\n    c2 = tmp;\n  }\n  const x1 = (coords[p1] + context.offsetX) * context.scaleX;\n  const y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;\n  const x2 = (coords[p2] + context.offsetX) * context.scaleX;\n  const y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;\n  const x3 = (coords[p3] + context.offsetX) * context.scaleX;\n  const y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;\n  if (y1 >= y3) {\n    return;\n  }\n  const c1r = colors[c1],\n    c1g = colors[c1 + 1],\n    c1b = colors[c1 + 2];\n  const c2r = colors[c2],\n    c2g = colors[c2 + 1],\n    c2b = colors[c2 + 2];\n  const c3r = colors[c3],\n    c3g = colors[c3 + 1],\n    c3b = colors[c3 + 2];\n\n  const minY = Math.round(y1),\n    maxY = Math.round(y3);\n  let xa, car, cag, cab;\n  let xb, cbr, cbg, cbb;\n  for (let y = minY; y <= maxY; y++) {\n    if (y < y2) {\n      const k = y < y1 ? 0 : (y1 - y) / (y1 - y2);\n      xa = x1 - (x1 - x2) * k;\n      car = c1r - (c1r - c2r) * k;\n      cag = c1g - (c1g - c2g) * k;\n      cab = c1b - (c1b - c2b) * k;\n    } else {\n      let k;\n      if (y > y3) {\n        k = 1;\n      } else if (y2 === y3) {\n        k = 0;\n      } else {\n        k = (y2 - y) / (y2 - y3);\n      }\n      xa = x2 - (x2 - x3) * k;\n      car = c2r - (c2r - c3r) * k;\n      cag = c2g - (c2g - c3g) * k;\n      cab = c2b - (c2b - c3b) * k;\n    }\n\n    let k;\n    if (y < y1) {\n      k = 0;\n    } else if (y > y3) {\n      k = 1;\n    } else {\n      k = (y1 - y) / (y1 - y3);\n    }\n    xb = x1 - (x1 - x3) * k;\n    cbr = c1r - (c1r - c3r) * k;\n    cbg = c1g - (c1g - c3g) * k;\n    cbb = c1b - (c1b - c3b) * k;\n    const x1_ = Math.round(Math.min(xa, xb));\n    const x2_ = Math.round(Math.max(xa, xb));\n    let j = rowSize * y + x1_ * 4;\n    for (let x = x1_; x <= x2_; x++) {\n      k = (xa - x) / (xa - xb);\n      if (k < 0) {\n        k = 0;\n      } else if (k > 1) {\n        k = 1;\n      }\n      bytes[j++] = (car - (car - cbr) * k) | 0;\n      bytes[j++] = (cag - (cag - cbg) * k) | 0;\n      bytes[j++] = (cab - (cab - cbb) * k) | 0;\n      bytes[j++] = 255;\n    }\n  }\n}\n\nfunction drawFigure(data, figure, context) {\n  const ps = figure.coords;\n  const cs = figure.colors;\n  let i, ii;\n  switch (figure.type) {\n    case MeshFigureType.LATTICE:\n      const verticesPerRow = figure.verticesPerRow;\n      const rows = Math.floor(ps.length / verticesPerRow) - 1;\n      const cols = verticesPerRow - 1;\n      for (i = 0; i < rows; i++) {\n        let q = i * verticesPerRow;\n        for (let j = 0; j < cols; j++, q++) {\n          drawTriangle(\n            data,\n            context,\n            ps[q],\n            ps[q + 1],\n            ps[q + verticesPerRow],\n            cs[q],\n            cs[q + 1],\n            cs[q + verticesPerRow]\n          );\n          drawTriangle(\n            data,\n            context,\n            ps[q + verticesPerRow + 1],\n            ps[q + 1],\n            ps[q + verticesPerRow],\n            cs[q + verticesPerRow + 1],\n            cs[q + 1],\n            cs[q + verticesPerRow]\n          );\n        }\n      }\n      break;\n    case MeshFigureType.TRIANGLES:\n      for (i = 0, ii = ps.length; i < ii; i += 3) {\n        drawTriangle(\n          data,\n          context,\n          ps[i],\n          ps[i + 1],\n          ps[i + 2],\n          cs[i],\n          cs[i + 1],\n          cs[i + 2]\n        );\n      }\n      break;\n    default:\n      throw new Error(\"illegal figure\");\n  }\n}\n\nclass MeshShadingPattern extends BaseShadingPattern {\n  constructor(IR) {\n    super();\n    this._coords = IR[2];\n    this._colors = IR[3];\n    this._figures = IR[4];\n    this._bounds = IR[5];\n    this._bbox = IR[6];\n    this._background = IR[7];\n    this.matrix = null;\n  }\n\n  _createMeshCanvas(combinedScale, backgroundColor, cachedCanvases) {\n    // we will increase scale on some weird factor to let antialiasing take\n    // care of \"rough\" edges\n    const EXPECTED_SCALE = 1.1;\n    // MAX_PATTERN_SIZE is used to avoid OOM situation.\n    const MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough\n    // We need to keep transparent border around our pattern for fill():\n    // createPattern with 'no-repeat' will bleed edges across entire area.\n    const BORDER_SIZE = 2;\n\n    const offsetX = Math.floor(this._bounds[0]);\n    const offsetY = Math.floor(this._bounds[1]);\n    const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;\n    const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;\n\n    const width = Math.min(\n      Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)),\n      MAX_PATTERN_SIZE\n    );\n    const height = Math.min(\n      Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)),\n      MAX_PATTERN_SIZE\n    );\n    const scaleX = boundsWidth / width;\n    const scaleY = boundsHeight / height;\n\n    const context = {\n      coords: this._coords,\n      colors: this._colors,\n      offsetX: -offsetX,\n      offsetY: -offsetY,\n      scaleX: 1 / scaleX,\n      scaleY: 1 / scaleY,\n    };\n\n    const paddedWidth = width + BORDER_SIZE * 2;\n    const paddedHeight = height + BORDER_SIZE * 2;\n\n    const tmpCanvas = cachedCanvases.getCanvas(\n      \"mesh\",\n      paddedWidth,\n      paddedHeight\n    );\n    const tmpCtx = tmpCanvas.context;\n\n    const data = tmpCtx.createImageData(width, height);\n    if (backgroundColor) {\n      const bytes = data.data;\n      for (let i = 0, ii = bytes.length; i < ii; i += 4) {\n        bytes[i] = backgroundColor[0];\n        bytes[i + 1] = backgroundColor[1];\n        bytes[i + 2] = backgroundColor[2];\n        bytes[i + 3] = 255;\n      }\n    }\n    for (const figure of this._figures) {\n      drawFigure(data, figure, context);\n    }\n    tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);\n    const canvas = tmpCanvas.canvas;\n\n    return {\n      canvas,\n      offsetX: offsetX - BORDER_SIZE * scaleX,\n      offsetY: offsetY - BORDER_SIZE * scaleY,\n      scaleX,\n      scaleY,\n    };\n  }\n\n  isModifyingCurrentTransform() {\n    return true;\n  }\n\n  getPattern(ctx, owner, inverse, pathType) {\n    applyBoundingBox(ctx, this._bbox);\n    const scale = new Float32Array(2);\n    if (pathType === PathType.SHADING) {\n      Util.singularValueDecompose2dScale(getCurrentTransform(ctx), scale);\n    } else if (this.matrix) {\n      // Obtain scale from matrix and current transformation matrix.\n      Util.singularValueDecompose2dScale(this.matrix, scale);\n      const [matrixScaleX, matrixScaleY] = scale;\n      Util.singularValueDecompose2dScale(owner.baseTransform, scale);\n      scale[0] *= matrixScaleX;\n      scale[1] *= matrixScaleY;\n    } else {\n      Util.singularValueDecompose2dScale(owner.baseTransform, scale);\n    }\n\n    // Rasterizing on the main thread since sending/queue large canvases\n    // might cause OOM.\n    const temporaryPatternCanvas = this._createMeshCanvas(\n      scale,\n      pathType === PathType.SHADING ? null : this._background,\n      owner.cachedCanvases\n    );\n\n    if (pathType !== PathType.SHADING) {\n      ctx.setTransform(...owner.baseTransform);\n      if (this.matrix) {\n        ctx.transform(...this.matrix);\n      }\n    }\n\n    ctx.translate(\n      temporaryPatternCanvas.offsetX,\n      temporaryPatternCanvas.offsetY\n    );\n    ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);\n\n    return ctx.createPattern(temporaryPatternCanvas.canvas, \"no-repeat\");\n  }\n}\n\nclass DummyShadingPattern extends BaseShadingPattern {\n  getPattern() {\n    return \"hotpink\";\n  }\n}\n\nfunction getShadingPattern(IR) {\n  switch (IR[0]) {\n    case \"RadialAxial\":\n      return new RadialAxialShadingPattern(IR);\n    case \"Mesh\":\n      return new MeshShadingPattern(IR);\n    case \"Dummy\":\n      return new DummyShadingPattern();\n  }\n  throw new Error(`Unknown IR type: ${IR[0]}`);\n}\n\nconst PaintType = {\n  COLORED: 1,\n  UNCOLORED: 2,\n};\n\nclass TilingPattern {\n  // 10in @ 300dpi shall be enough.\n  static MAX_PATTERN_SIZE = 3000;\n\n  constructor(IR, ctx, canvasGraphicsFactory, baseTransform) {\n    this.color = IR[1];\n    this.operatorList = IR[2];\n    this.matrix = IR[3];\n    this.bbox = IR[4];\n    this.xstep = IR[5];\n    this.ystep = IR[6];\n    this.paintType = IR[7];\n    this.tilingType = IR[8];\n    this.ctx = ctx;\n    this.canvasGraphicsFactory = canvasGraphicsFactory;\n    this.baseTransform = baseTransform;\n  }\n\n  createPatternCanvas(owner, opIdx) {\n    const {\n      bbox,\n      operatorList,\n      paintType,\n      tilingType,\n      color,\n      canvasGraphicsFactory,\n    } = this;\n    let { xstep, ystep } = this;\n    xstep = Math.abs(xstep);\n    ystep = Math.abs(ystep);\n\n    info(\"TilingType: \" + tilingType);\n\n    // A tiling pattern as defined by PDF spec 8.7.2 is a cell whose size is\n    // described by bbox, and may repeat regularly by shifting the cell by\n    // xstep and ystep.\n    // Because the HTML5 canvas API does not support pattern repetition with\n    // gaps in between, we use the xstep/ystep instead of the bbox's size.\n    //\n    // This has the following consequences (similarly for ystep):\n    //\n    // - If xstep is the same as bbox, then there is no observable difference.\n    //\n    // - If xstep is larger than bbox, then the pattern canvas is partially\n    //   empty: the area bounded by bbox is painted, the outside area is void.\n    //\n    // - If xstep is smaller than bbox, then the pixels between xstep and the\n    //   bbox boundary will be missing. This is INCORRECT behavior.\n    //   \"Figures on adjacent tiles should not overlap\" (PDF spec 8.7.3.1),\n    //   but overlapping cells without common pixels are still valid.\n\n    const x0 = bbox[0],\n      y0 = bbox[1],\n      x1 = bbox[2],\n      y1 = bbox[3];\n    const width = x1 - x0;\n    const height = y1 - y0;\n\n    // Obtain scale from matrix and current transformation matrix.\n    const scale = new Float32Array(2);\n    Util.singularValueDecompose2dScale(this.matrix, scale);\n    const [matrixScaleX, matrixScaleY] = scale;\n    Util.singularValueDecompose2dScale(this.baseTransform, scale);\n    const combinedScaleX = matrixScaleX * scale[0];\n    const combinedScaleY = matrixScaleY * scale[1];\n\n    let canvasWidth = width,\n      canvasHeight = height,\n      redrawHorizontally = false,\n      redrawVertically = false;\n\n    const xScaledStep = Math.ceil(xstep * combinedScaleX);\n    const yScaledStep = Math.ceil(ystep * combinedScaleY);\n    const xScaledWidth = Math.ceil(width * combinedScaleX);\n    const yScaledHeight = Math.ceil(height * combinedScaleY);\n\n    if (xScaledStep >= xScaledWidth) {\n      canvasWidth = xstep;\n    } else {\n      redrawHorizontally = true;\n    }\n    if (yScaledStep >= yScaledHeight) {\n      canvasHeight = ystep;\n    } else {\n      redrawVertically = true;\n    }\n\n    // Use width and height values that are as close as possible to the end\n    // result when the pattern is used. Too low value makes the pattern look\n    // blurry. Too large value makes it look too crispy.\n    const dimx = this.getSizeAndScale(\n      canvasWidth,\n      this.ctx.canvas.width,\n      combinedScaleX\n    );\n    const dimy = this.getSizeAndScale(\n      canvasHeight,\n      this.ctx.canvas.height,\n      combinedScaleY\n    );\n\n    const tmpCanvas = owner.cachedCanvases.getCanvas(\n      \"pattern\",\n      dimx.size,\n      dimy.size\n    );\n    const tmpCtx = tmpCanvas.context;\n    const graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx, opIdx);\n    graphics.groupLevel = owner.groupLevel;\n\n    this.setFillAndStrokeStyleToContext(graphics, paintType, color);\n\n    tmpCtx.translate(-dimx.scale * x0, -dimy.scale * y0);\n    graphics.transform(\n      // We pass 0 as the 'opIdx' argument, but the value is irrelevant.\n      // We know that we are in a 'CanvasNestedDependencyTracker' that captures\n      // all the sub-operations needed to create this pattern canvas and uses\n      // the top-level operation index as their index.\n      0,\n      dimx.scale,\n      0,\n      0,\n      dimy.scale,\n      0,\n      0\n    );\n\n    // To match CanvasGraphics beginDrawing we must save the context here or\n    // else we end up with unbalanced save/restores.\n    tmpCtx.save();\n    graphics.dependencyTracker?.save();\n\n    this.clipBbox(graphics, x0, y0, x1, y1);\n\n    graphics.baseTransform = getCurrentTransform(graphics.ctx);\n\n    graphics.executeOperatorList(operatorList);\n\n    graphics.endDrawing();\n\n    graphics.dependencyTracker?.restore();\n    tmpCtx.restore();\n\n    if (redrawHorizontally || redrawVertically) {\n      // The tile is overlapping itself, so we create a new tile with\n      // dimensions xstep * ystep.\n      // Then we draw the overlapping parts of the original tile on the new\n      // tile.\n      // Just as a side note, the code here works correctly even if we don't\n      // have to redraw the tile horizontally or vertically. In that case, the\n      // original tile is drawn on the new tile only once, but it's useless.\n      const image = tmpCanvas.canvas;\n      if (redrawHorizontally) {\n        canvasWidth = xstep;\n      }\n      if (redrawVertically) {\n        canvasHeight = ystep;\n      }\n\n      const dimx2 = this.getSizeAndScale(\n        canvasWidth,\n        this.ctx.canvas.width,\n        combinedScaleX\n      );\n      const dimy2 = this.getSizeAndScale(\n        canvasHeight,\n        this.ctx.canvas.height,\n        combinedScaleY\n      );\n\n      const xSize = dimx2.size;\n      const ySize = dimy2.size;\n      const tmpCanvas2 = owner.cachedCanvases.getCanvas(\n        \"pattern-workaround\",\n        xSize,\n        ySize\n      );\n      const tmpCtx2 = tmpCanvas2.context;\n      const ii = redrawHorizontally ? Math.floor(width / xstep) : 0;\n      const jj = redrawVertically ? Math.floor(height / ystep) : 0;\n\n      // Draw the overlapping parts of the original tile on the new tile.\n      for (let i = 0; i <= ii; i++) {\n        for (let j = 0; j <= jj; j++) {\n          tmpCtx2.drawImage(\n            image,\n            xSize * i,\n            ySize * j,\n            xSize,\n            ySize,\n            0,\n            0,\n            xSize,\n            ySize\n          );\n        }\n      }\n      return {\n        canvas: tmpCanvas2.canvas,\n        scaleX: dimx2.scale,\n        scaleY: dimy2.scale,\n        offsetX: x0,\n        offsetY: y0,\n      };\n    }\n\n    return {\n      canvas: tmpCanvas.canvas,\n      scaleX: dimx.scale,\n      scaleY: dimy.scale,\n      offsetX: x0,\n      offsetY: y0,\n    };\n  }\n\n  getSizeAndScale(step, realOutputSize, scale) {\n    // MAX_PATTERN_SIZE is used to avoid OOM situation.\n    // Use the destination canvas's size if it is bigger than the hard-coded\n    // limit of MAX_PATTERN_SIZE to avoid clipping patterns that cover the\n    // whole canvas.\n    const maxSize = Math.max(TilingPattern.MAX_PATTERN_SIZE, realOutputSize);\n    let size = Math.ceil(step * scale);\n    if (size >= maxSize) {\n      size = maxSize;\n    } else {\n      scale = size / step;\n    }\n    return { scale, size };\n  }\n\n  clipBbox(graphics, x0, y0, x1, y1) {\n    const bboxWidth = x1 - x0;\n    const bboxHeight = y1 - y0;\n    graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);\n    Util.axialAlignedBoundingBox(\n      [x0, y0, x1, y1],\n      getCurrentTransform(graphics.ctx),\n      graphics.current.minMax\n    );\n    graphics.clip();\n    graphics.endPath();\n  }\n\n  setFillAndStrokeStyleToContext(graphics, paintType, color) {\n    const context = graphics.ctx,\n      current = graphics.current;\n    switch (paintType) {\n      case PaintType.COLORED:\n        const { fillStyle, strokeStyle } = this.ctx;\n        context.fillStyle = current.fillColor = fillStyle;\n        context.strokeStyle = current.strokeColor = strokeStyle;\n        break;\n      case PaintType.UNCOLORED:\n        context.fillStyle = context.strokeStyle = color;\n        // Set color needed by image masks (fixes issues 3226 and 8741).\n        current.fillColor = current.strokeColor = color;\n        break;\n      default:\n        throw new FormatError(`Unsupported paint type: ${paintType}`);\n    }\n  }\n\n  isModifyingCurrentTransform() {\n    return false;\n  }\n\n  getPattern(ctx, owner, inverse, pathType, opIdx) {\n    // PDF spec 8.7.2 NOTE 1: pattern's matrix is relative to initial matrix.\n    let matrix = inverse;\n    if (pathType !== PathType.SHADING) {\n      matrix = Util.transform(matrix, owner.baseTransform);\n      if (this.matrix) {\n        matrix = Util.transform(matrix, this.matrix);\n      }\n    }\n\n    const temporaryPatternCanvas = this.createPatternCanvas(owner, opIdx);\n\n    let domMatrix = new DOMMatrix(matrix);\n    // Rescale and so that the ctx.createPattern call generates a pattern with\n    // the desired size.\n    domMatrix = domMatrix.translate(\n      temporaryPatternCanvas.offsetX,\n      temporaryPatternCanvas.offsetY\n    );\n    domMatrix = domMatrix.scale(\n      1 / temporaryPatternCanvas.scaleX,\n      1 / temporaryPatternCanvas.scaleY\n    );\n\n    const pattern = ctx.createPattern(temporaryPatternCanvas.canvas, \"repeat\");\n    pattern.setTransform(domMatrix);\n\n    return pattern;\n  }\n}\n\nexport { getShadingPattern, PathType, TilingPattern };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FeatureTest, ImageKind } from \"./util.js\";\n\nfunction convertToRGBA(params) {\n  switch (params.kind) {\n    case ImageKind.GRAYSCALE_1BPP:\n      return convertBlackAndWhiteToRGBA(params);\n    case ImageKind.RGB_24BPP:\n      return convertRGBToRGBA(params);\n  }\n\n  return null;\n}\n\nfunction convertBlackAndWhiteToRGBA({\n  src,\n  srcPos = 0,\n  dest,\n  width,\n  height,\n  nonBlackColor = 0xffffffff,\n  inverseDecode = false,\n}) {\n  const black = FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;\n  const [zeroMapping, oneMapping] = inverseDecode\n    ? [nonBlackColor, black]\n    : [black, nonBlackColor];\n  const widthInSource = width >> 3;\n  const widthRemainder = width & 7;\n  const xorMask = zeroMapping ^ oneMapping;\n  const srcLength = src.length;\n  dest = new Uint32Array(dest.buffer);\n  let destPos = 0;\n\n  for (let i = 0; i < height; ++i) {\n    for (\n      const max = srcPos + widthInSource;\n      srcPos < max;\n      ++srcPos, destPos += 8\n    ) {\n      const elem = src[srcPos];\n      dest[destPos] = zeroMapping ^ (-((elem >> 7) & 1) & xorMask);\n      dest[destPos + 1] = zeroMapping ^ (-((elem >> 6) & 1) & xorMask);\n      dest[destPos + 2] = zeroMapping ^ (-((elem >> 5) & 1) & xorMask);\n      dest[destPos + 3] = zeroMapping ^ (-((elem >> 4) & 1) & xorMask);\n      dest[destPos + 4] = zeroMapping ^ (-((elem >> 3) & 1) & xorMask);\n      dest[destPos + 5] = zeroMapping ^ (-((elem >> 2) & 1) & xorMask);\n      dest[destPos + 6] = zeroMapping ^ (-((elem >> 1) & 1) & xorMask);\n      dest[destPos + 7] = zeroMapping ^ (-(elem & 1) & xorMask);\n    }\n    if (widthRemainder === 0) {\n      continue;\n    }\n    const elem = srcPos < srcLength ? src[srcPos++] : 255;\n    for (let j = 0; j < widthRemainder; ++j, ++destPos) {\n      dest[destPos] = zeroMapping ^ (-((elem >> (7 - j)) & 1) & xorMask);\n    }\n  }\n\n  return { srcPos, destPos };\n}\n\nfunction convertRGBToRGBA({\n  src,\n  srcPos = 0,\n  dest,\n  destPos = 0,\n  width,\n  height,\n}) {\n  let i = 0;\n  const len = width * height * 3;\n  const len32 = len >> 2;\n  const src32 = new Uint32Array(src.buffer, srcPos, len32);\n  const alphaMask = FeatureTest.isLittleEndian ? 0xff000000 : 0xff;\n\n  if (FeatureTest.isLittleEndian) {\n    // It's a way faster to do the shuffle manually instead of working\n    // component by component with some Uint8 arrays.\n    for (; i < len32 - 2; i += 3, destPos += 4) {\n      const s1 = src32[i], // R2B1G1R1\n        s2 = src32[i + 1], // G3R3B2G2\n        s3 = src32[i + 2]; // B4G4R4B3\n\n      dest[destPos] = s1 | alphaMask;\n      dest[destPos + 1] = (s1 >>> 24) | (s2 << 8) | alphaMask;\n      dest[destPos + 2] = (s2 >>> 16) | (s3 << 16) | alphaMask;\n      dest[destPos + 3] = (s3 >>> 8) | alphaMask;\n    }\n\n    for (let j = i * 4, jj = srcPos + len; j < jj; j += 3) {\n      dest[destPos++] =\n        src[j] | (src[j + 1] << 8) | (src[j + 2] << 16) | alphaMask;\n    }\n  } else {\n    for (; i < len32 - 2; i += 3, destPos += 4) {\n      const s1 = src32[i], // R1G1B1R2\n        s2 = src32[i + 1], // G2B2R3G3\n        s3 = src32[i + 2]; // B3R4G4B4\n\n      dest[destPos] = s1 | alphaMask;\n      dest[destPos + 1] = (s1 << 24) | (s2 >>> 8) | alphaMask;\n      dest[destPos + 2] = (s2 << 16) | (s3 >>> 16) | alphaMask;\n      dest[destPos + 3] = (s3 << 8) | alphaMask;\n    }\n\n    for (let j = i * 4, jj = srcPos + len; j < jj; j += 3) {\n      dest[destPos++] =\n        (src[j] << 24) | (src[j + 1] << 16) | (src[j + 2] << 8) | alphaMask;\n    }\n  }\n\n  return { srcPos: srcPos + len, destPos };\n}\n\nfunction grayToRGBA(src, dest) {\n  if (FeatureTest.isLittleEndian) {\n    for (let i = 0, ii = src.length; i < ii; i++) {\n      dest[i] = (src[i] * 0x10101) | 0xff000000;\n    }\n  } else {\n    for (let i = 0, ii = src.length; i < ii; i++) {\n      dest[i] = (src[i] * 0x1010100) | 0x000000ff;\n    }\n  }\n}\n\nexport { convertBlackAndWhiteToRGBA, convertToRGBA, grayToRGBA };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  CanvasNestedDependencyTracker,\n  Dependencies,\n} from \"./canvas_dependency_tracker.js\";\nimport {\n  FeatureTest,\n  FONT_IDENTITY_MATRIX,\n  ImageKind,\n  info,\n  makeMap,\n  OPS,\n  shadow,\n  TextRenderingMode,\n  unreachable,\n  Util,\n  warn,\n} from \"../shared/util.js\";\nimport {\n  getCurrentTransform,\n  getCurrentTransformInverse,\n  makePathFromDrawOPS,\n  OutputScale,\n  PixelsPerInch,\n} from \"./display_utils.js\";\nimport {\n  getShadingPattern,\n  PathType,\n  TilingPattern,\n} from \"./pattern_helper.js\";\nimport { convertBlackAndWhiteToRGBA } from \"../shared/image_utils.js\";\n\n// <canvas> contexts store most of the state we need natively.\n// However, PDF needs a bit more state, which we store here.\n// Minimal font size that would be used during canvas fillText operations.\nconst MIN_FONT_SIZE = 16;\n// Maximum font size that would be used during canvas fillText operations.\nconst MAX_FONT_SIZE = 100;\n\n// Defines the time the `executeOperatorList`-method is going to be executing\n// before it stops and schedules a continue of execution.\nconst EXECUTION_TIME = 15; // ms\n// Defines the number of steps before checking the execution time.\nconst EXECUTION_STEPS = 10;\n\nconst FULL_CHUNK_HEIGHT = 16;\n\n// Only used in rescaleAndStroke. The goal is to avoid\n// creating a new DOMMatrix object each time we need it.\nconst SCALE_MATRIX = new DOMMatrix();\n\n// Used to get some coordinates.\nconst XY = new Float32Array(2);\n\n// Initial rectangle values for the minMax array.\nconst MIN_MAX_INIT = new Float32Array([\n  Infinity,\n  Infinity,\n  -Infinity,\n  -Infinity,\n]);\n\n/**\n * Overrides certain methods on a 2d ctx so that when they are called they\n * will also call the same method on the destCtx. The methods that are\n * overridden are all the transformation state modifiers, path creation, and\n * save/restore. We only forward these specific methods because they are the\n * only state modifiers that we cannot copy over when we switch contexts.\n *\n * To remove mirroring call `ctx._removeMirroring()`.\n *\n * @param {Object} ctx - The 2d canvas context that will duplicate its calls on\n *   the destCtx.\n * @param {Object} destCtx - The 2d canvas context that will receive the\n *   forwarded calls.\n */\nfunction mirrorContextOperations(ctx, destCtx) {\n  if (ctx._removeMirroring) {\n    throw new Error(\"Context is already forwarding operations.\");\n  }\n  ctx.__originalSave = ctx.save;\n  ctx.__originalRestore = ctx.restore;\n  ctx.__originalRotate = ctx.rotate;\n  ctx.__originalScale = ctx.scale;\n  ctx.__originalTranslate = ctx.translate;\n  ctx.__originalTransform = ctx.transform;\n  ctx.__originalSetTransform = ctx.setTransform;\n  ctx.__originalResetTransform = ctx.resetTransform;\n  ctx.__originalClip = ctx.clip;\n  ctx.__originalMoveTo = ctx.moveTo;\n  ctx.__originalLineTo = ctx.lineTo;\n  ctx.__originalBezierCurveTo = ctx.bezierCurveTo;\n  ctx.__originalRect = ctx.rect;\n  ctx.__originalClosePath = ctx.closePath;\n  ctx.__originalBeginPath = ctx.beginPath;\n\n  ctx._removeMirroring = () => {\n    ctx.save = ctx.__originalSave;\n    ctx.restore = ctx.__originalRestore;\n    ctx.rotate = ctx.__originalRotate;\n    ctx.scale = ctx.__originalScale;\n    ctx.translate = ctx.__originalTranslate;\n    ctx.transform = ctx.__originalTransform;\n    ctx.setTransform = ctx.__originalSetTransform;\n    ctx.resetTransform = ctx.__originalResetTransform;\n\n    ctx.clip = ctx.__originalClip;\n    ctx.moveTo = ctx.__originalMoveTo;\n    ctx.lineTo = ctx.__originalLineTo;\n    ctx.bezierCurveTo = ctx.__originalBezierCurveTo;\n    ctx.rect = ctx.__originalRect;\n    ctx.closePath = ctx.__originalClosePath;\n    ctx.beginPath = ctx.__originalBeginPath;\n    delete ctx._removeMirroring;\n  };\n\n  ctx.save = function () {\n    destCtx.save();\n    this.__originalSave();\n  };\n\n  ctx.restore = function () {\n    destCtx.restore();\n    this.__originalRestore();\n  };\n\n  ctx.translate = function (x, y) {\n    destCtx.translate(x, y);\n    this.__originalTranslate(x, y);\n  };\n\n  ctx.scale = function (x, y) {\n    destCtx.scale(x, y);\n    this.__originalScale(x, y);\n  };\n\n  ctx.transform = function (a, b, c, d, e, f) {\n    destCtx.transform(a, b, c, d, e, f);\n    this.__originalTransform(a, b, c, d, e, f);\n  };\n\n  ctx.setTransform = function (a, b, c, d, e, f) {\n    destCtx.setTransform(a, b, c, d, e, f);\n    this.__originalSetTransform(a, b, c, d, e, f);\n  };\n\n  ctx.resetTransform = function () {\n    destCtx.resetTransform();\n    this.__originalResetTransform();\n  };\n\n  ctx.rotate = function (angle) {\n    destCtx.rotate(angle);\n    this.__originalRotate(angle);\n  };\n\n  ctx.clip = function (rule) {\n    destCtx.clip(rule);\n    this.__originalClip(rule);\n  };\n\n  ctx.moveTo = function (x, y) {\n    destCtx.moveTo(x, y);\n    this.__originalMoveTo(x, y);\n  };\n\n  ctx.lineTo = function (x, y) {\n    destCtx.lineTo(x, y);\n    this.__originalLineTo(x, y);\n  };\n\n  ctx.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {\n    destCtx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);\n    this.__originalBezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);\n  };\n\n  ctx.rect = function (x, y, width, height) {\n    destCtx.rect(x, y, width, height);\n    this.__originalRect(x, y, width, height);\n  };\n\n  ctx.closePath = function () {\n    destCtx.closePath();\n    this.__originalClosePath();\n  };\n\n  ctx.beginPath = function () {\n    destCtx.beginPath();\n    this.__originalBeginPath();\n  };\n}\n\nclass CachedCanvases {\n  constructor(canvasFactory) {\n    this.canvasFactory = canvasFactory;\n    this.cache = Object.create(null);\n  }\n\n  getCanvas(id, width, height) {\n    let canvasEntry;\n    if (this.cache[id] !== undefined) {\n      canvasEntry = this.cache[id];\n      this.canvasFactory.reset(canvasEntry, width, height);\n    } else {\n      canvasEntry = this.canvasFactory.create(width, height);\n      this.cache[id] = canvasEntry;\n    }\n    return canvasEntry;\n  }\n\n  delete(id) {\n    delete this.cache[id];\n  }\n\n  clear() {\n    for (const id in this.cache) {\n      const canvasEntry = this.cache[id];\n      this.canvasFactory.destroy(canvasEntry);\n      delete this.cache[id];\n    }\n  }\n}\n\nfunction drawImageAtIntegerCoords(\n  ctx,\n  srcImg,\n  srcX,\n  srcY,\n  srcW,\n  srcH,\n  destX,\n  destY,\n  destW,\n  destH\n) {\n  const [a, b, c, d, tx, ty] = getCurrentTransform(ctx);\n  if (b === 0 && c === 0) {\n    // top-left corner is at (X, Y) and\n    // bottom-right one is at (X + width, Y + height).\n\n    // If leftX is 4.321 then it's rounded to 4.\n    // If width is 10.432 then it's rounded to 11 because\n    // rightX = leftX + width = 14.753 which is rounded to 15\n    // so after rounding the total width is 11 (15 - 4).\n    // It's why we can't just floor/ceil uniformly, it just depends\n    // on the values we've.\n\n    const tlX = destX * a + tx;\n    const rTlX = Math.round(tlX);\n    const tlY = destY * d + ty;\n    const rTlY = Math.round(tlY);\n    const brX = (destX + destW) * a + tx;\n\n    // Some pdf contains images with 1x1 images so in case of 0-width after\n    // scaling we must fallback on 1 to be sure there is something.\n    const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;\n    const brY = (destY + destH) * d + ty;\n    const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;\n\n    // We must apply a transformation in order to apply it on the image itself.\n    // For example if a == 1 && d == -1, it means that the image itself is\n    // mirrored w.r.t. the x-axis.\n    ctx.setTransform(Math.sign(a), 0, 0, Math.sign(d), rTlX, rTlY);\n    ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rWidth, rHeight);\n    ctx.setTransform(a, b, c, d, tx, ty);\n\n    return [rWidth, rHeight];\n  }\n\n  if (a === 0 && d === 0) {\n    // This path is taken in issue9462.pdf (page 3).\n    const tlX = destY * c + tx;\n    const rTlX = Math.round(tlX);\n    const tlY = destX * b + ty;\n    const rTlY = Math.round(tlY);\n    const brX = (destY + destH) * c + tx;\n    const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;\n    const brY = (destX + destW) * b + ty;\n    const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;\n\n    ctx.setTransform(0, Math.sign(b), Math.sign(c), 0, rTlX, rTlY);\n    ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rHeight, rWidth);\n    ctx.setTransform(a, b, c, d, tx, ty);\n\n    return [rHeight, rWidth];\n  }\n\n  // Not a scale matrix so let the render handle the case without rounding.\n  ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH);\n\n  const scaleX = Math.hypot(a, b);\n  const scaleY = Math.hypot(c, d);\n  return [scaleX * destW, scaleY * destH];\n}\n\nclass CanvasExtraState {\n  // Are soft masks and alpha values shapes or opacities?\n  alphaIsShape = false;\n\n  fontSize = 0;\n\n  fontSizeScale = 1;\n\n  textMatrix = null;\n\n  textMatrixScale = 1;\n\n  fontMatrix = FONT_IDENTITY_MATRIX;\n\n  leading = 0;\n\n  // Current point (in user coordinates)\n  x = 0;\n\n  y = 0;\n\n  // Start of text line (in text coordinates)\n  lineX = 0;\n\n  lineY = 0;\n\n  // Character and word spacing\n  charSpacing = 0;\n\n  wordSpacing = 0;\n\n  textHScale = 1;\n\n  textRenderingMode = TextRenderingMode.FILL;\n\n  textRise = 0;\n\n  // Default fore and background colors\n  fillColor = \"#000000\";\n\n  strokeColor = \"#000000\";\n\n  patternFill = false;\n\n  patternStroke = false;\n\n  // Note: fill alpha applies to all non-stroking operations\n  fillAlpha = 1;\n\n  strokeAlpha = 1;\n\n  lineWidth = 1;\n\n  activeSMask = null;\n\n  transferMaps = \"none\";\n\n  constructor(width, height, preInit) {\n    preInit?.(this);\n\n    this.clipBox = new Float32Array([0, 0, width, height]);\n    this.minMax = MIN_MAX_INIT.slice();\n  }\n\n  clone() {\n    const clone = Object.create(this);\n    clone.clipBox = this.clipBox.slice();\n    clone.minMax = this.minMax.slice();\n    return clone;\n  }\n\n  getPathBoundingBox(pathType = PathType.FILL, transform = null) {\n    const box = this.minMax.slice();\n    if (pathType === PathType.STROKE) {\n      if (!transform) {\n        unreachable(\"Stroke bounding box must include transform.\");\n      }\n      // Stroked paths can be outside of the path bounding box by 1/2 the line\n      // width.\n      Util.singularValueDecompose2dScale(transform, XY);\n      const xStrokePad = (XY[0] * this.lineWidth) / 2;\n      const yStrokePad = (XY[1] * this.lineWidth) / 2;\n      box[0] -= xStrokePad;\n      box[1] -= yStrokePad;\n      box[2] += xStrokePad;\n      box[3] += yStrokePad;\n    }\n    return box;\n  }\n\n  updateClipFromPath() {\n    const intersect = Util.intersect(this.clipBox, this.getPathBoundingBox());\n    this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);\n  }\n\n  isEmptyClip() {\n    return this.minMax[0] === Infinity;\n  }\n\n  startNewPathAndClipBox(box) {\n    this.clipBox.set(box, 0);\n    this.minMax.set(MIN_MAX_INIT, 0);\n  }\n\n  getClippedPathBoundingBox(pathType = PathType.FILL, transform = null) {\n    return Util.intersect(\n      this.clipBox,\n      this.getPathBoundingBox(pathType, transform)\n    );\n  }\n}\n\nfunction putBinaryImageData(ctx, imgData) {\n  if (imgData instanceof ImageData) {\n    ctx.putImageData(imgData, 0, 0);\n    return;\n  }\n\n  // Put the image data to the canvas in chunks, rather than putting the\n  // whole image at once.  This saves JS memory, because the ImageData object\n  // is smaller. It also possibly saves C++ memory within the implementation\n  // of putImageData(). (E.g. in Firefox we make two short-lived copies of\n  // the data passed to putImageData()). |n| shouldn't be too small, however,\n  // because too many putImageData() calls will slow things down.\n  //\n  // Note: as written, if the last chunk is partial, the putImageData() call\n  // will (conceptually) put pixels past the bounds of the canvas.  But\n  // that's ok; any such pixels are ignored.\n\n  const height = imgData.height,\n    width = imgData.width;\n  const partialChunkHeight = height % FULL_CHUNK_HEIGHT;\n  const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;\n  const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;\n\n  const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);\n  let srcPos = 0,\n    destPos;\n  const src = imgData.data;\n  const dest = chunkImgData.data;\n  let i, j, thisChunkHeight, elemsInThisChunk;\n\n  // There are multiple forms in which the pixel data can be passed, and\n  // imgData.kind tells us which one this is.\n  if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {\n    // Grayscale, 1 bit per pixel (i.e. black-and-white).\n    const srcLength = src.byteLength;\n    const dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);\n    const dest32DataLength = dest32.length;\n    const fullSrcDiff = (width + 7) >> 3;\n    const white = 0xffffffff;\n    const black = FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;\n\n    for (i = 0; i < totalChunks; i++) {\n      thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;\n      destPos = 0;\n      for (j = 0; j < thisChunkHeight; j++) {\n        const srcDiff = srcLength - srcPos;\n        let k = 0;\n        const kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;\n        const kEndUnrolled = kEnd & ~7;\n        let mask = 0;\n        let srcByte = 0;\n        for (; k < kEndUnrolled; k += 8) {\n          srcByte = src[srcPos++];\n          dest32[destPos++] = srcByte & 128 ? white : black;\n          dest32[destPos++] = srcByte & 64 ? white : black;\n          dest32[destPos++] = srcByte & 32 ? white : black;\n          dest32[destPos++] = srcByte & 16 ? white : black;\n          dest32[destPos++] = srcByte & 8 ? white : black;\n          dest32[destPos++] = srcByte & 4 ? white : black;\n          dest32[destPos++] = srcByte & 2 ? white : black;\n          dest32[destPos++] = srcByte & 1 ? white : black;\n        }\n        for (; k < kEnd; k++) {\n          if (mask === 0) {\n            srcByte = src[srcPos++];\n            mask = 128;\n          }\n\n          dest32[destPos++] = srcByte & mask ? white : black;\n          mask >>= 1;\n        }\n      }\n      // We ran out of input. Make all remaining pixels transparent.\n      while (destPos < dest32DataLength) {\n        dest32[destPos++] = 0;\n      }\n\n      ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);\n    }\n  } else if (imgData.kind === ImageKind.RGBA_32BPP) {\n    // RGBA, 32-bits per pixel.\n    j = 0;\n    elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;\n    for (i = 0; i < fullChunks; i++) {\n      dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));\n      srcPos += elemsInThisChunk;\n\n      ctx.putImageData(chunkImgData, 0, j);\n      j += FULL_CHUNK_HEIGHT;\n    }\n    if (i < totalChunks) {\n      elemsInThisChunk = width * partialChunkHeight * 4;\n      dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));\n\n      ctx.putImageData(chunkImgData, 0, j);\n    }\n  } else if (imgData.kind === ImageKind.RGB_24BPP) {\n    // RGB, 24-bits per pixel.\n    thisChunkHeight = FULL_CHUNK_HEIGHT;\n    elemsInThisChunk = width * thisChunkHeight;\n    for (i = 0; i < totalChunks; i++) {\n      if (i >= fullChunks) {\n        thisChunkHeight = partialChunkHeight;\n        elemsInThisChunk = width * thisChunkHeight;\n      }\n\n      destPos = 0;\n      for (j = elemsInThisChunk; j--; ) {\n        dest[destPos++] = src[srcPos++];\n        dest[destPos++] = src[srcPos++];\n        dest[destPos++] = src[srcPos++];\n        dest[destPos++] = 255;\n      }\n\n      ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);\n    }\n  } else {\n    throw new Error(`bad image kind: ${imgData.kind}`);\n  }\n}\n\nfunction putBinaryImageMask(ctx, imgData) {\n  if (imgData.bitmap) {\n    // The bitmap has been created in the worker.\n    ctx.drawImage(imgData.bitmap, 0, 0);\n    return;\n  }\n\n  // Slow path: OffscreenCanvas isn't available in the worker.\n  const height = imgData.height,\n    width = imgData.width;\n  const partialChunkHeight = height % FULL_CHUNK_HEIGHT;\n  const fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;\n  const totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;\n\n  const chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);\n  let srcPos = 0;\n  const src = imgData.data;\n  const dest = chunkImgData.data;\n\n  for (let i = 0; i < totalChunks; i++) {\n    const thisChunkHeight =\n      i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;\n\n    // Expand the mask so it can be used by the canvas.  Any required\n    // inversion has already been handled.\n\n    ({ srcPos } = convertBlackAndWhiteToRGBA({\n      src,\n      srcPos,\n      dest,\n      width,\n      height: thisChunkHeight,\n      nonBlackColor: 0,\n    }));\n\n    ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);\n  }\n}\n\nfunction copyCtxState(sourceCtx, destCtx) {\n  const properties = [\n    \"strokeStyle\",\n    \"fillStyle\",\n    \"fillRule\",\n    \"globalAlpha\",\n    \"lineWidth\",\n    \"lineCap\",\n    \"lineJoin\",\n    \"miterLimit\",\n    \"globalCompositeOperation\",\n    \"font\",\n    \"filter\",\n  ];\n  for (const property of properties) {\n    if (sourceCtx[property] !== undefined) {\n      destCtx[property] = sourceCtx[property];\n    }\n  }\n  if (sourceCtx.setLineDash !== undefined) {\n    destCtx.setLineDash(sourceCtx.getLineDash());\n    destCtx.lineDashOffset = sourceCtx.lineDashOffset;\n  }\n}\n\nfunction resetCtxToDefault(ctx) {\n  ctx.strokeStyle = ctx.fillStyle = \"#000000\";\n  ctx.fillRule = \"nonzero\";\n  ctx.globalAlpha = 1;\n  ctx.lineWidth = 1;\n  ctx.lineCap = \"butt\";\n  ctx.lineJoin = \"miter\";\n  ctx.miterLimit = 10;\n  ctx.globalCompositeOperation = \"source-over\";\n  ctx.font = \"10px sans-serif\";\n  if (ctx.setLineDash !== undefined) {\n    ctx.setLineDash([]);\n    ctx.lineDashOffset = 0;\n  }\n  const { filter } = ctx;\n  if (filter !== \"none\" && filter !== \"\") {\n    ctx.filter = \"none\";\n  }\n}\n\nfunction getImageSmoothingEnabled(transform, interpolate) {\n  // In section 8.9.5.3 of the PDF spec, it's mentioned that the interpolate\n  // flag should be used when the image is upscaled.\n  // In Firefox, smoothing is always used when downscaling images (bug 1360415).\n\n  if (interpolate) {\n    return true;\n  }\n\n  Util.singularValueDecompose2dScale(transform, XY);\n  // Round to a 32bit float so that `<=` check below will pass for numbers that\n  // are very close, but not exactly the same 64bit floats.\n  const actualScale = Math.fround(\n    OutputScale.pixelRatio * PixelsPerInch.PDF_TO_CSS_UNITS\n  );\n  // `XY` is a Float32Array.\n  return XY[0] <= actualScale && XY[1] <= actualScale;\n}\n\nconst LINE_CAP_STYLES = [\"butt\", \"round\", \"square\"];\nconst LINE_JOIN_STYLES = [\"miter\", \"round\", \"bevel\"];\nconst NORMAL_CLIP = {};\nconst EO_CLIP = {};\n\nclass CanvasGraphics {\n  constructor(\n    canvasCtx,\n    commonObjs,\n    objs,\n    canvasFactory,\n    filterFactory,\n    { optionalContentConfig, markedContentStack = null },\n    annotationCanvasMap,\n    pageColors,\n    dependencyTracker\n  ) {\n    this.ctx = canvasCtx;\n    this.current = new CanvasExtraState(\n      this.ctx.canvas.width,\n      this.ctx.canvas.height\n    );\n    this.stateStack = [];\n    this.pendingClip = null;\n    this.pendingEOFill = false;\n    this.commonObjs = commonObjs;\n    this.objs = objs;\n    this.canvasFactory = canvasFactory;\n    this.filterFactory = filterFactory;\n    this.groupStack = [];\n    // Patterns are painted relative to the initial page/form transform, see\n    // PDF spec 8.7.2 NOTE 1.\n    this.baseTransform = null;\n    this.baseTransformStack = [];\n    this.groupLevel = 0;\n    this.smaskStack = [];\n    this.smaskCounter = 0;\n    this.tempSMask = null;\n    this.suspendedCtx = null;\n    this.contentVisible = true;\n    this.markedContentStack = markedContentStack || [];\n    this.optionalContentConfig = optionalContentConfig;\n    this.cachedCanvases = new CachedCanvases(this.canvasFactory);\n    this.cachedPatterns = new Map();\n    this.annotationCanvasMap = annotationCanvasMap;\n    this.viewportScale = 1;\n    this.outputScaleX = 1;\n    this.outputScaleY = 1;\n    this.pageColors = pageColors;\n\n    this._cachedScaleForStroking = [-1, 0];\n    this._cachedGetSinglePixelWidth = null;\n    this._cachedBitmapsMap = new Map();\n\n    this.dependencyTracker = dependencyTracker ?? null;\n  }\n\n  getObject(opIdx, data, fallback = null) {\n    if (typeof data === \"string\") {\n      this.dependencyTracker?.recordNamedDependency(opIdx, data);\n      return data.startsWith(\"g_\")\n        ? this.commonObjs.get(data)\n        : this.objs.get(data);\n    }\n    return fallback;\n  }\n\n  beginDrawing({\n    transform,\n    viewport,\n    transparency = false,\n    background = null,\n  }) {\n    // For pdfs that use blend modes we have to clear the canvas else certain\n    // blend modes can look wrong since we'd be blending with a white\n    // backdrop. The problem with a transparent backdrop though is we then\n    // don't get sub pixel anti aliasing on text, creating temporary\n    // transparent canvas when we have blend modes.\n    const width = this.ctx.canvas.width;\n    const height = this.ctx.canvas.height;\n\n    const savedFillStyle = this.ctx.fillStyle;\n    this.ctx.fillStyle = background || \"#ffffff\";\n    this.ctx.fillRect(0, 0, width, height);\n    this.ctx.fillStyle = savedFillStyle;\n\n    if (transparency) {\n      const transparentCanvas = this.cachedCanvases.getCanvas(\n        \"transparent\",\n        width,\n        height\n      );\n      this.compositeCtx = this.ctx;\n      this.transparentCanvas = transparentCanvas.canvas;\n      this.ctx = transparentCanvas.context;\n      this.ctx.save();\n      // The transform can be applied before rendering, transferring it to\n      // the new canvas.\n      this.ctx.transform(...getCurrentTransform(this.compositeCtx));\n    }\n\n    this.ctx.save();\n    resetCtxToDefault(this.ctx);\n    if (transform) {\n      this.ctx.transform(...transform);\n      this.outputScaleX = transform[0];\n      this.outputScaleY = transform[0];\n    }\n    this.ctx.transform(...viewport.transform);\n    this.viewportScale = viewport.scale;\n\n    this.baseTransform = getCurrentTransform(this.ctx);\n  }\n\n  executeOperatorList(\n    operatorList,\n    executionStartIdx,\n    continueCallback,\n    stepper,\n    operationsFilter\n  ) {\n    const argsArray = operatorList.argsArray;\n    const fnArray = operatorList.fnArray;\n    let i = executionStartIdx || 0;\n    const argsArrayLen = argsArray.length;\n\n    // Sometimes the OperatorList to execute is empty.\n    if (argsArrayLen === i) {\n      return i;\n    }\n\n    const chunkOperations =\n      argsArrayLen - i > EXECUTION_STEPS &&\n      typeof continueCallback === \"function\";\n    const endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;\n    let steps = 0;\n\n    const commonObjs = this.commonObjs;\n    const objs = this.objs;\n    let fnId, fnArgs;\n\n    while (true) {\n      if (stepper !== undefined && i === stepper.nextBreakPoint) {\n        stepper.breakIt(i, continueCallback);\n        return i;\n      }\n\n      if (!operationsFilter || operationsFilter(i)) {\n        fnId = fnArray[i];\n        // TODO: There is a `undefined` coming from somewhere.\n        fnArgs = argsArray[i] ?? null;\n\n        if (fnId !== OPS.dependency) {\n          if (fnArgs === null) {\n            this[fnId](i);\n          } else {\n            this[fnId](i, ...fnArgs);\n          }\n        } else {\n          for (const depObjId of fnArgs) {\n            this.dependencyTracker?.recordNamedData(depObjId, i);\n            const objsPool = depObjId.startsWith(\"g_\") ? commonObjs : objs;\n\n            // If the promise isn't resolved yet, add the continueCallback\n            // to the promise and bail out.\n            if (!objsPool.has(depObjId)) {\n              objsPool.get(depObjId, continueCallback);\n              return i;\n            }\n          }\n        }\n      }\n\n      i++;\n\n      // If the entire operatorList was executed, stop as were done.\n      if (i === argsArrayLen) {\n        return i;\n      }\n\n      // If the execution took longer then a certain amount of time and\n      // `continueCallback` is specified, interrupt the execution.\n      if (chunkOperations && ++steps > EXECUTION_STEPS) {\n        if (Date.now() > endTime) {\n          continueCallback();\n          return i;\n        }\n        steps = 0;\n      }\n\n      // If the operatorList isn't executed completely yet OR the execution\n      // time was short enough, do another execution round.\n    }\n  }\n\n  #restoreInitialState() {\n    // Finishing all opened operations such as SMask group painting.\n    while (this.stateStack.length || this.inSMaskMode) {\n      this.restore();\n    }\n\n    this.current.activeSMask = null;\n    this.ctx.restore();\n\n    if (this.transparentCanvas) {\n      this.ctx = this.compositeCtx;\n      this.ctx.save();\n      this.ctx.setTransform(1, 0, 0, 1, 0, 0); // Avoid apply transform twice\n      this.ctx.drawImage(this.transparentCanvas, 0, 0);\n      this.ctx.restore();\n      this.transparentCanvas = null;\n    }\n  }\n\n  endDrawing() {\n    this.#restoreInitialState();\n\n    this.cachedCanvases.clear();\n    this.cachedPatterns.clear();\n\n    for (const cache of this._cachedBitmapsMap.values()) {\n      for (const canvas of cache.values()) {\n        if (\n          typeof HTMLCanvasElement !== \"undefined\" &&\n          canvas instanceof HTMLCanvasElement\n        ) {\n          canvas.width = canvas.height = 0;\n        }\n      }\n      cache.clear();\n    }\n    this._cachedBitmapsMap.clear();\n    this.#drawFilter();\n  }\n\n  #drawFilter() {\n    if (this.pageColors) {\n      const hcmFilterId = this.filterFactory.addHCMFilter(\n        this.pageColors.foreground,\n        this.pageColors.background\n      );\n      if (hcmFilterId !== \"none\") {\n        const savedFilter = this.ctx.filter;\n        this.ctx.filter = hcmFilterId;\n        this.ctx.drawImage(this.ctx.canvas, 0, 0);\n        this.ctx.filter = savedFilter;\n      }\n    }\n  }\n\n  _scaleImage(img, inverseTransform) {\n    // Vertical or horizontal scaling shall not be more than 2 to not lose the\n    // pixels during drawImage operation, painting on the temporary canvas(es)\n    // that are twice smaller in size.\n\n    // displayWidth and displayHeight are used for VideoFrame.\n    const width = img.width ?? img.displayWidth;\n    const height = img.height ?? img.displayHeight;\n    let widthScale = Math.max(\n      Math.hypot(inverseTransform[0], inverseTransform[1]),\n      1\n    );\n    let heightScale = Math.max(\n      Math.hypot(inverseTransform[2], inverseTransform[3]),\n      1\n    );\n\n    let paintWidth = width,\n      paintHeight = height;\n    let tmpCanvasId = \"prescale1\";\n    let tmpCanvas, tmpCtx;\n    while (\n      (widthScale > 2 && paintWidth > 1) ||\n      (heightScale > 2 && paintHeight > 1)\n    ) {\n      let newWidth = paintWidth,\n        newHeight = paintHeight;\n      if (widthScale > 2 && paintWidth > 1) {\n        // See bug 1820511 (Windows specific bug).\n        // TODO: once the above bug is fixed we could revert to:\n        // newWidth = Math.ceil(paintWidth / 2);\n        newWidth =\n          paintWidth >= 16384\n            ? Math.floor(paintWidth / 2) - 1 || 1\n            : Math.ceil(paintWidth / 2);\n        widthScale /= paintWidth / newWidth;\n      }\n      if (heightScale > 2 && paintHeight > 1) {\n        // TODO: see the comment above.\n        newHeight =\n          paintHeight >= 16384\n            ? Math.floor(paintHeight / 2) - 1 || 1\n            : Math.ceil(paintHeight) / 2;\n        heightScale /= paintHeight / newHeight;\n      }\n      tmpCanvas = this.cachedCanvases.getCanvas(\n        tmpCanvasId,\n        newWidth,\n        newHeight\n      );\n      tmpCtx = tmpCanvas.context;\n      tmpCtx.clearRect(0, 0, newWidth, newHeight);\n      tmpCtx.drawImage(\n        img,\n        0,\n        0,\n        paintWidth,\n        paintHeight,\n        0,\n        0,\n        newWidth,\n        newHeight\n      );\n      img = tmpCanvas.canvas;\n      paintWidth = newWidth;\n      paintHeight = newHeight;\n      tmpCanvasId = tmpCanvasId === \"prescale1\" ? \"prescale2\" : \"prescale1\";\n    }\n    return {\n      img,\n      paintWidth,\n      paintHeight,\n    };\n  }\n\n  _createMaskCanvas(opIdx, img) {\n    const ctx = this.ctx;\n    const { width, height } = img;\n    const fillColor = this.current.fillColor;\n    const isPatternFill = this.current.patternFill;\n    const currentTransform = getCurrentTransform(ctx);\n\n    let cache, cacheKey, scaled, maskCanvas;\n    if ((img.bitmap || img.data) && img.count > 1) {\n      const mainKey = img.bitmap || img.data.buffer;\n      // We're reusing the same image several times, so we can cache it.\n      // In case we've a pattern fill we just keep the scaled version of\n      // the image.\n      // Only the scaling part matters, the translation part is just used\n      // to compute offsets (but not when filling patterns see #15573).\n      // TODO: handle the case of a pattern fill if it's possible.\n      cacheKey = JSON.stringify(\n        isPatternFill\n          ? currentTransform\n          : [currentTransform.slice(0, 4), fillColor]\n      );\n\n      cache = this._cachedBitmapsMap.getOrInsertComputed(mainKey, makeMap);\n      const cachedImage = cache.get(cacheKey);\n      if (cachedImage && !isPatternFill) {\n        const offsetX = Math.round(\n          Math.min(currentTransform[0], currentTransform[2]) +\n            currentTransform[4]\n        );\n        const offsetY = Math.round(\n          Math.min(currentTransform[1], currentTransform[3]) +\n            currentTransform[5]\n        );\n\n        this.dependencyTracker?.recordDependencies(\n          opIdx,\n          Dependencies.transformAndFill\n        );\n        return {\n          canvas: cachedImage,\n          offsetX,\n          offsetY,\n        };\n      }\n      scaled = cachedImage;\n    }\n\n    if (!scaled) {\n      maskCanvas = this.cachedCanvases.getCanvas(\"maskCanvas\", width, height);\n      putBinaryImageMask(maskCanvas.context, img);\n    }\n\n    // Create the mask canvas at the size it will be drawn at and also set\n    // its transform to match the current transform so if there are any\n    // patterns applied they will be applied relative to the correct\n    // transform.\n\n    let maskToCanvas = Util.transform(currentTransform, [\n      1 / width,\n      0,\n      0,\n      -1 / height,\n      0,\n      0,\n    ]);\n    maskToCanvas = Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);\n    const minMax = MIN_MAX_INIT.slice();\n    Util.axialAlignedBoundingBox([0, 0, width, height], maskToCanvas, minMax);\n    const [minX, minY, maxX, maxY] = minMax;\n    const drawnWidth = Math.round(maxX - minX) || 1;\n    const drawnHeight = Math.round(maxY - minY) || 1;\n    const fillCanvas = this.cachedCanvases.getCanvas(\n      \"fillCanvas\",\n      drawnWidth,\n      drawnHeight\n    );\n    const fillCtx = fillCanvas.context;\n\n    // The offset will be the top-left coordinate mask.\n    // If objToCanvas is [a,b,c,d,e,f] then:\n    //   - offsetX = min(a, c) + e\n    //   - offsetY = min(b, d) + f\n    const offsetX = minX;\n    const offsetY = minY;\n    fillCtx.translate(-offsetX, -offsetY);\n    fillCtx.transform(...maskToCanvas);\n\n    if (!scaled) {\n      // Pre-scale if needed to improve image smoothing.\n      scaled = this._scaleImage(\n        maskCanvas.canvas,\n        getCurrentTransformInverse(fillCtx)\n      );\n      scaled = scaled.img;\n      if (cache && isPatternFill) {\n        cache.set(cacheKey, scaled);\n      }\n    }\n\n    fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled(\n      getCurrentTransform(fillCtx),\n      img.interpolate\n    );\n\n    drawImageAtIntegerCoords(\n      fillCtx,\n      scaled,\n      0,\n      0,\n      scaled.width,\n      scaled.height,\n      0,\n      0,\n      width,\n      height\n    );\n    fillCtx.globalCompositeOperation = \"source-in\";\n\n    const inverse = Util.transform(getCurrentTransformInverse(fillCtx), [\n      1,\n      0,\n      0,\n      1,\n      -offsetX,\n      -offsetY,\n    ]);\n    fillCtx.fillStyle = isPatternFill\n      ? fillColor.getPattern(ctx, this, inverse, PathType.FILL, opIdx)\n      : fillColor;\n\n    fillCtx.fillRect(0, 0, width, height);\n\n    if (cache && !isPatternFill) {\n      // The fill canvas is put in the cache associated to the mask image\n      // so we must remove from the cached canvas: it mustn't be used again.\n      this.cachedCanvases.delete(\"fillCanvas\");\n      cache.set(cacheKey, fillCanvas.canvas);\n    }\n\n    this.dependencyTracker?.recordDependencies(\n      opIdx,\n      Dependencies.transformAndFill\n    );\n\n    // Round the offsets to avoid drawing fractional pixels.\n    return {\n      canvas: fillCanvas.canvas,\n      offsetX: Math.round(offsetX),\n      offsetY: Math.round(offsetY),\n    };\n  }\n\n  // Graphics state\n  setLineWidth(opIdx, width) {\n    this.dependencyTracker?.recordSimpleData(\"lineWidth\", opIdx);\n    if (width !== this.current.lineWidth) {\n      this._cachedScaleForStroking[0] = -1;\n    }\n    this.current.lineWidth = width;\n    this.ctx.lineWidth = width;\n  }\n\n  setLineCap(opIdx, style) {\n    this.dependencyTracker?.recordSimpleData(\"lineCap\", opIdx);\n    this.ctx.lineCap = LINE_CAP_STYLES[style];\n  }\n\n  setLineJoin(opIdx, style) {\n    this.dependencyTracker?.recordSimpleData(\"lineJoin\", opIdx);\n    this.ctx.lineJoin = LINE_JOIN_STYLES[style];\n  }\n\n  setMiterLimit(opIdx, limit) {\n    this.dependencyTracker?.recordSimpleData(\"miterLimit\", opIdx);\n    this.ctx.miterLimit = limit;\n  }\n\n  setDash(opIdx, dashArray, dashPhase) {\n    this.dependencyTracker?.recordSimpleData(\"dash\", opIdx);\n    const ctx = this.ctx;\n    if (ctx.setLineDash !== undefined) {\n      ctx.setLineDash(dashArray);\n      ctx.lineDashOffset = dashPhase;\n    }\n  }\n\n  setRenderingIntent(opIdx, intent) {\n    // This operation is ignored since we haven't found a use case for it yet.\n  }\n\n  setFlatness(opIdx, flatness) {\n    // This operation is ignored since we haven't found a use case for it yet.\n  }\n\n  setGState(opIdx, states) {\n    for (const [key, value] of states) {\n      switch (key) {\n        case \"LW\":\n          this.setLineWidth(opIdx, value);\n          break;\n        case \"LC\":\n          this.setLineCap(opIdx, value);\n          break;\n        case \"LJ\":\n          this.setLineJoin(opIdx, value);\n          break;\n        case \"ML\":\n          this.setMiterLimit(opIdx, value);\n          break;\n        case \"D\":\n          this.setDash(opIdx, value[0], value[1]);\n          break;\n        case \"RI\":\n          this.setRenderingIntent(opIdx, value);\n          break;\n        case \"FL\":\n          this.setFlatness(opIdx, value);\n          break;\n        case \"Font\":\n          this.setFont(opIdx, value[0], value[1]);\n          break;\n        case \"CA\":\n          this.dependencyTracker?.recordSimpleData(\"strokeAlpha\", opIdx);\n          this.current.strokeAlpha = value;\n          break;\n        case \"ca\":\n          this.dependencyTracker?.recordSimpleData(\"fillAlpha\", opIdx);\n          this.ctx.globalAlpha = this.current.fillAlpha = value;\n          break;\n        case \"BM\":\n          this.dependencyTracker?.recordSimpleData(\n            \"globalCompositeOperation\",\n            opIdx\n          );\n          this.ctx.globalCompositeOperation = value;\n          break;\n        case \"SMask\":\n          this.dependencyTracker?.recordSimpleData(\"SMask\", opIdx);\n          this.current.activeSMask = value ? this.tempSMask : null;\n          this.tempSMask = null;\n          this.checkSMaskState();\n          break;\n        case \"TR\":\n          this.dependencyTracker?.recordSimpleData(\"filter\", opIdx);\n          this.ctx.filter = this.current.transferMaps =\n            this.filterFactory.addFilter(value);\n          break;\n      }\n    }\n  }\n\n  get inSMaskMode() {\n    return !!this.suspendedCtx;\n  }\n\n  checkSMaskState() {\n    const inSMaskMode = this.inSMaskMode;\n    if (this.current.activeSMask && !inSMaskMode) {\n      this.beginSMaskMode();\n    } else if (!this.current.activeSMask && inSMaskMode) {\n      this.endSMaskMode();\n    }\n    // Else, the state is okay and nothing needs to be done.\n  }\n\n  /**\n   * Soft mask mode takes the current main drawing canvas and replaces it with\n   * a temporary canvas. Any drawing operations that happen on the temporary\n   * canvas need to be composed with the main canvas that was suspended (see\n   * `compose()`). The temporary canvas also duplicates many of its operations\n   * on the suspended canvas to keep them in sync, so that when the soft mask\n   * mode ends any clipping paths or transformations will still be active and in\n   * the right order on the canvas' graphics state stack.\n   */\n  beginSMaskMode(opIdx) {\n    if (this.inSMaskMode) {\n      throw new Error(\"beginSMaskMode called while already in smask mode\");\n    }\n    const drawnWidth = this.ctx.canvas.width;\n    const drawnHeight = this.ctx.canvas.height;\n    const cacheId = \"smaskGroupAt\" + this.groupLevel;\n    const scratchCanvas = this.cachedCanvases.getCanvas(\n      cacheId,\n      drawnWidth,\n      drawnHeight\n    );\n    this.suspendedCtx = this.ctx;\n    const ctx = (this.ctx = scratchCanvas.context);\n    ctx.setTransform(this.suspendedCtx.getTransform());\n    copyCtxState(this.suspendedCtx, ctx);\n    mirrorContextOperations(ctx, this.suspendedCtx);\n\n    this.setGState(opIdx, [[\"BM\", \"source-over\"]]);\n  }\n\n  endSMaskMode() {\n    if (!this.inSMaskMode) {\n      throw new Error(\"endSMaskMode called while not in smask mode\");\n    }\n    // The soft mask is done, now restore the suspended canvas as the main\n    // drawing canvas.\n    this.ctx._removeMirroring();\n    copyCtxState(this.ctx, this.suspendedCtx);\n    this.ctx = this.suspendedCtx;\n\n    this.suspendedCtx = null;\n  }\n\n  compose(dirtyBox) {\n    if (!this.current.activeSMask) {\n      return;\n    }\n\n    if (!dirtyBox) {\n      dirtyBox = [0, 0, this.ctx.canvas.width, this.ctx.canvas.height];\n    } else {\n      dirtyBox[0] = Math.floor(dirtyBox[0]);\n      dirtyBox[1] = Math.floor(dirtyBox[1]);\n      dirtyBox[2] = Math.ceil(dirtyBox[2]);\n      dirtyBox[3] = Math.ceil(dirtyBox[3]);\n    }\n    const smask = this.current.activeSMask;\n    const suspendedCtx = this.suspendedCtx;\n\n    this.composeSMask(suspendedCtx, smask, this.ctx, dirtyBox);\n    // Whatever was drawn has been moved to the suspended canvas, now clear it\n    // out of the current canvas.\n    this.ctx.save();\n    this.ctx.setTransform(1, 0, 0, 1, 0, 0);\n    this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);\n    this.ctx.restore();\n  }\n\n  composeSMask(ctx, smask, layerCtx, layerBox) {\n    const layerOffsetX = layerBox[0];\n    const layerOffsetY = layerBox[1];\n    const layerWidth = layerBox[2] - layerOffsetX;\n    const layerHeight = layerBox[3] - layerOffsetY;\n    if (layerWidth === 0 || layerHeight === 0) {\n      return;\n    }\n    this.genericComposeSMask(\n      smask.context,\n      layerCtx,\n      layerWidth,\n      layerHeight,\n      smask.subtype,\n      smask.backdrop,\n      smask.transferMap,\n      layerOffsetX,\n      layerOffsetY,\n      smask.offsetX,\n      smask.offsetY\n    );\n    ctx.save();\n    ctx.globalAlpha = 1;\n    ctx.globalCompositeOperation = \"source-over\";\n    ctx.setTransform(1, 0, 0, 1, 0, 0);\n    ctx.drawImage(layerCtx.canvas, 0, 0);\n    ctx.restore();\n  }\n\n  genericComposeSMask(\n    maskCtx,\n    layerCtx,\n    width,\n    height,\n    subtype,\n    backdrop,\n    transferMap,\n    layerOffsetX,\n    layerOffsetY,\n    maskOffsetX,\n    maskOffsetY\n  ) {\n    let maskCanvas = maskCtx.canvas;\n    let maskX = layerOffsetX - maskOffsetX;\n    let maskY = layerOffsetY - maskOffsetY;\n\n    if (backdrop) {\n      if (\n        maskX < 0 ||\n        maskY < 0 ||\n        maskX + width > maskCanvas.width ||\n        maskY + height > maskCanvas.height\n      ) {\n        const canvas = this.cachedCanvases.getCanvas(\n          \"maskExtension\",\n          width,\n          height\n        );\n        const ctx = canvas.context;\n        ctx.drawImage(maskCanvas, -maskX, -maskY);\n        ctx.globalCompositeOperation = \"destination-atop\";\n        ctx.fillStyle = backdrop;\n        ctx.fillRect(0, 0, width, height);\n        ctx.globalCompositeOperation = \"source-over\";\n\n        maskCanvas = canvas.canvas;\n        maskX = maskY = 0;\n      } else {\n        maskCtx.save();\n        maskCtx.globalAlpha = 1;\n        maskCtx.setTransform(1, 0, 0, 1, 0, 0);\n        const clip = new Path2D();\n        clip.rect(maskX, maskY, width, height);\n        maskCtx.clip(clip);\n        maskCtx.globalCompositeOperation = \"destination-atop\";\n        maskCtx.fillStyle = backdrop;\n        maskCtx.fillRect(maskX, maskY, width, height);\n        maskCtx.restore();\n      }\n    }\n\n    layerCtx.save();\n    layerCtx.globalAlpha = 1;\n    layerCtx.setTransform(1, 0, 0, 1, 0, 0);\n\n    if (subtype === \"Alpha\" && transferMap) {\n      layerCtx.filter = this.filterFactory.addAlphaFilter(transferMap);\n    } else if (subtype === \"Luminosity\") {\n      layerCtx.filter = this.filterFactory.addLuminosityFilter(transferMap);\n    }\n\n    const clip = new Path2D();\n    clip.rect(layerOffsetX, layerOffsetY, width, height);\n    layerCtx.clip(clip);\n    layerCtx.globalCompositeOperation = \"destination-in\";\n    layerCtx.drawImage(\n      maskCanvas,\n      maskX,\n      maskY,\n      width,\n      height,\n      layerOffsetX,\n      layerOffsetY,\n      width,\n      height\n    );\n    layerCtx.restore();\n  }\n\n  save(opIdx) {\n    if (this.inSMaskMode) {\n      // SMask mode may be turned on/off causing us to lose graphics state.\n      // Copy the temporary canvas state to the main(suspended) canvas to keep\n      // it in sync.\n      copyCtxState(this.ctx, this.suspendedCtx);\n    }\n    this.ctx.save();\n    const old = this.current;\n    this.stateStack.push(old);\n    this.current = old.clone();\n    this.dependencyTracker?.save(opIdx);\n  }\n\n  restore(opIdx) {\n    this.dependencyTracker?.restore(opIdx);\n\n    if (this.stateStack.length === 0) {\n      if (this.inSMaskMode) {\n        this.endSMaskMode();\n      }\n      return;\n    }\n\n    this.current = this.stateStack.pop();\n    this.ctx.restore();\n    if (this.inSMaskMode) {\n      // Graphics state is stored on the main(suspended) canvas. Restore its\n      // state then copy it over to the temporary canvas.\n      copyCtxState(this.suspendedCtx, this.ctx);\n    }\n    this.checkSMaskState();\n\n    // Ensure that the clipping path is reset (fixes issue6413.pdf).\n    this.pendingClip = null;\n\n    this._cachedScaleForStroking[0] = -1;\n    this._cachedGetSinglePixelWidth = null;\n  }\n\n  transform(opIdx, a, b, c, d, e, f) {\n    this.dependencyTracker?.recordIncrementalData(\"transform\", opIdx);\n    this.ctx.transform(a, b, c, d, e, f);\n\n    this._cachedScaleForStroking[0] = -1;\n    this._cachedGetSinglePixelWidth = null;\n  }\n\n  // Path\n  constructPath(opIdx, op, data, minMax) {\n    let [path] = data;\n    if (!minMax) {\n      // The path is empty, so no need to update the current minMax.\n      path ||= data[0] = new Path2D();\n      this[op](opIdx, path);\n      return;\n    }\n\n    if (this.dependencyTracker !== null) {\n      const outerExtraSize = op === OPS.stroke ? this.current.lineWidth / 2 : 0;\n      this.dependencyTracker\n        .resetBBox(opIdx)\n        .recordBBox(\n          opIdx,\n          this.ctx,\n          minMax[0] - outerExtraSize,\n          minMax[2] + outerExtraSize,\n          minMax[1] - outerExtraSize,\n          minMax[3] + outerExtraSize\n        )\n        .recordDependencies(opIdx, [\"transform\"]);\n    }\n\n    if (!(path instanceof Path2D)) {\n      path = data[0] = makePathFromDrawOPS(path);\n    }\n    Util.axialAlignedBoundingBox(\n      minMax,\n      getCurrentTransform(this.ctx),\n      this.current.minMax\n    );\n    this[op](opIdx, path);\n\n    this._pathStartIdx = opIdx;\n  }\n\n  closePath(opIdx) {\n    this.ctx.closePath();\n  }\n\n  stroke(opIdx, path, consumePath = true) {\n    const ctx = this.ctx;\n    const strokeColor = this.current.strokeColor;\n    // For stroke we want to temporarily change the global alpha to the\n    // stroking alpha.\n    ctx.globalAlpha = this.current.strokeAlpha;\n    if (this.contentVisible) {\n      if (typeof strokeColor === \"object\" && strokeColor?.getPattern) {\n        const baseTransform = strokeColor.isModifyingCurrentTransform()\n          ? ctx.getTransform()\n          : null;\n        ctx.save();\n        ctx.strokeStyle = strokeColor.getPattern(\n          ctx,\n          this,\n          getCurrentTransformInverse(ctx),\n          PathType.STROKE,\n          opIdx\n        );\n        if (baseTransform) {\n          const newPath = new Path2D();\n          newPath.addPath(\n            path,\n            ctx.getTransform().invertSelf().multiplySelf(baseTransform)\n          );\n          path = newPath;\n        }\n        this.rescaleAndStroke(path, /* saveRestore */ false);\n        ctx.restore();\n      } else {\n        this.rescaleAndStroke(path, /* saveRestore */ true);\n      }\n    }\n\n    this.dependencyTracker?.recordDependencies(opIdx, Dependencies.stroke);\n\n    if (consumePath) {\n      this.consumePath(\n        opIdx,\n        path,\n        this.current.getClippedPathBoundingBox(\n          PathType.STROKE,\n          getCurrentTransform(this.ctx)\n        )\n      );\n    }\n\n    // Restore the global alpha to the fill alpha\n    ctx.globalAlpha = this.current.fillAlpha;\n  }\n\n  closeStroke(opIdx, path) {\n    this.stroke(opIdx, path);\n  }\n\n  fill(opIdx, path, consumePath = true) {\n    const ctx = this.ctx;\n    const fillColor = this.current.fillColor;\n    const isPatternFill = this.current.patternFill;\n    let needRestore = false;\n\n    if (isPatternFill) {\n      const baseTransform = fillColor.isModifyingCurrentTransform()\n        ? ctx.getTransform()\n        : null;\n      this.dependencyTracker?.save(opIdx);\n      ctx.save();\n      ctx.fillStyle = fillColor.getPattern(\n        ctx,\n        this,\n        getCurrentTransformInverse(ctx),\n        PathType.FILL,\n        opIdx\n      );\n      if (baseTransform) {\n        const newPath = new Path2D();\n        newPath.addPath(\n          path,\n          ctx.getTransform().invertSelf().multiplySelf(baseTransform)\n        );\n        path = newPath;\n      }\n      needRestore = true;\n    }\n\n    const intersect = this.current.getClippedPathBoundingBox();\n    if (this.contentVisible && intersect !== null) {\n      if (this.pendingEOFill) {\n        ctx.fill(path, \"evenodd\");\n        this.pendingEOFill = false;\n      } else {\n        ctx.fill(path);\n      }\n    }\n\n    this.dependencyTracker?.recordDependencies(opIdx, Dependencies.fill);\n\n    if (needRestore) {\n      ctx.restore();\n      this.dependencyTracker?.restore(opIdx);\n    }\n    if (consumePath) {\n      this.consumePath(opIdx, path, intersect);\n    }\n  }\n\n  eoFill(opIdx, path) {\n    this.pendingEOFill = true;\n    this.fill(opIdx, path);\n  }\n\n  fillStroke(opIdx, path) {\n    this.fill(opIdx, path, false);\n    this.stroke(opIdx, path, false);\n\n    this.consumePath(opIdx, path);\n  }\n\n  eoFillStroke(opIdx, path) {\n    this.pendingEOFill = true;\n    this.fillStroke(opIdx, path);\n  }\n\n  closeFillStroke(opIdx, path) {\n    this.fillStroke(opIdx, path);\n  }\n\n  closeEOFillStroke(opIdx, path) {\n    this.pendingEOFill = true;\n    this.fillStroke(opIdx, path);\n  }\n\n  endPath(opIdx, path) {\n    this.consumePath(opIdx, path);\n  }\n\n  rawFillPath(opIdx, path) {\n    this.ctx.fill(path);\n    this.dependencyTracker\n      ?.recordDependencies(opIdx, Dependencies.rawFillPath)\n      .recordOperation(opIdx);\n  }\n\n  // Clipping\n  clip(opIdx) {\n    this.dependencyTracker?.recordFutureForcedDependency(\"clipMode\", opIdx);\n    this.pendingClip = NORMAL_CLIP;\n  }\n\n  eoClip(opIdx) {\n    this.dependencyTracker?.recordFutureForcedDependency(\"clipMode\", opIdx);\n    this.pendingClip = EO_CLIP;\n  }\n\n  // Text\n  beginText(opIdx) {\n    this.current.textMatrix = null;\n    this.current.textMatrixScale = 1;\n    this.current.x = this.current.lineX = 0;\n    this.current.y = this.current.lineY = 0;\n\n    this.dependencyTracker\n      ?.recordOpenMarker(opIdx)\n      .resetIncrementalData(\"sameLineText\")\n      .resetIncrementalData(\"moveText\", opIdx);\n  }\n\n  endText(opIdx) {\n    const paths = this.pendingTextPaths;\n    const ctx = this.ctx;\n\n    if (this.dependencyTracker) {\n      const { dependencyTracker } = this;\n      if (paths !== undefined) {\n        dependencyTracker\n          .recordFutureForcedDependency(\n            \"textClip\",\n            dependencyTracker.getOpenMarker()\n          )\n          .recordFutureForcedDependency(\"textClip\", opIdx);\n      }\n      dependencyTracker.recordCloseMarker(opIdx);\n    }\n\n    if (paths !== undefined) {\n      const newPath = new Path2D();\n      const invTransf = ctx.getTransform().invertSelf();\n      for (const { transform, x, y, fontSize, path } of paths) {\n        if (!path) {\n          continue; // Skip empty paths.\n        }\n        newPath.addPath(\n          path,\n          new DOMMatrix(transform)\n            .preMultiplySelf(invTransf)\n            .translate(x, y)\n            .scale(fontSize, -fontSize)\n        );\n      }\n\n      ctx.clip(newPath);\n    }\n    delete this.pendingTextPaths;\n  }\n\n  setCharSpacing(opIdx, spacing) {\n    this.dependencyTracker?.recordSimpleData(\"charSpacing\", opIdx);\n    this.current.charSpacing = spacing;\n  }\n\n  setWordSpacing(opIdx, spacing) {\n    this.dependencyTracker?.recordSimpleData(\"wordSpacing\", opIdx);\n    this.current.wordSpacing = spacing;\n  }\n\n  setHScale(opIdx, scale) {\n    this.dependencyTracker?.recordSimpleData(\"hScale\", opIdx);\n    this.current.textHScale = scale / 100;\n  }\n\n  setLeading(opIdx, leading) {\n    this.dependencyTracker?.recordSimpleData(\"leading\", opIdx);\n    this.current.leading = -leading;\n  }\n\n  setFont(opIdx, fontRefName, size) {\n    this.dependencyTracker\n      ?.recordSimpleData(\"font\", opIdx)\n      .recordSimpleDataFromNamed(\"fontObj\", fontRefName, opIdx);\n    const fontObj = this.commonObjs.get(fontRefName);\n    const current = this.current;\n\n    if (!fontObj) {\n      throw new Error(`Can't find font for ${fontRefName}`);\n    }\n    current.fontMatrix = fontObj.fontMatrix || FONT_IDENTITY_MATRIX;\n\n    // A valid matrix needs all main diagonal elements to be non-zero\n    // This also ensures we bypass FF bugzilla bug #719844.\n    if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {\n      warn(\"Invalid font matrix for font \" + fontRefName);\n    }\n\n    // The spec for Tf (setFont) says that 'size' specifies the font 'scale',\n    // and in some docs this can be negative (inverted x-y axes).\n    if (size < 0) {\n      size = -size;\n      current.fontDirection = -1;\n    } else {\n      current.fontDirection = 1;\n    }\n\n    this.current.font = fontObj;\n    this.current.fontSize = size;\n\n    if (fontObj.isType3Font) {\n      return; // we don't need ctx.font for Type3 fonts\n    }\n\n    const name = fontObj.loadedName || \"sans-serif\";\n    const typeface =\n      fontObj.systemFontInfo?.css || `\"${name}\", ${fontObj.fallbackName}`;\n\n    let bold = \"normal\";\n    if (fontObj.black) {\n      bold = \"900\";\n    } else if (fontObj.bold) {\n      bold = \"bold\";\n    }\n    const italic = fontObj.italic ? \"italic\" : \"normal\";\n\n    // Some font backends cannot handle fonts below certain size.\n    // Keeping the font at minimal size and using the fontSizeScale to change\n    // the current transformation matrix before the fillText/strokeText.\n    // See https://bugzilla.mozilla.org/show_bug.cgi?id=726227\n    let browserFontSize = size;\n    if (size < MIN_FONT_SIZE) {\n      browserFontSize = MIN_FONT_SIZE;\n    } else if (size > MAX_FONT_SIZE) {\n      browserFontSize = MAX_FONT_SIZE;\n    }\n    this.current.fontSizeScale = size / browserFontSize;\n\n    this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;\n  }\n\n  setTextRenderingMode(opIdx, mode) {\n    this.dependencyTracker?.recordSimpleData(\"textRenderingMode\", opIdx);\n    this.current.textRenderingMode = mode;\n  }\n\n  setTextRise(opIdx, rise) {\n    this.dependencyTracker?.recordSimpleData(\"textRise\", opIdx);\n    this.current.textRise = rise;\n  }\n\n  moveText(opIdx, x, y) {\n    this.dependencyTracker\n      ?.resetIncrementalData(\"sameLineText\")\n      .recordIncrementalData(\"moveText\", opIdx);\n    this.current.x = this.current.lineX += x;\n    this.current.y = this.current.lineY += y;\n  }\n\n  setLeadingMoveText(opIdx, x, y) {\n    this.setLeading(opIdx, -y);\n    this.moveText(opIdx, x, y);\n  }\n\n  setTextMatrix(opIdx, matrix) {\n    this.dependencyTracker\n      ?.resetIncrementalData(\"sameLineText\")\n      .recordSimpleData(\"textMatrix\", opIdx);\n    const { current } = this;\n    current.textMatrix = matrix;\n    current.textMatrixScale = Math.hypot(matrix[0], matrix[1]);\n\n    current.x = current.lineX = 0;\n    current.y = current.lineY = 0;\n  }\n\n  nextLine(opIdx) {\n    this.moveText(opIdx, 0, this.current.leading);\n\n    this.dependencyTracker?.recordIncrementalData(\n      \"moveText\",\n      // 'leading' affects 'nextLine' operations. Rather than dealing\n      // with transitive dependencies, just mark everything that depends on\n      // the 'moveText' operation as depending on the 'leading' value.\n      this.dependencyTracker.getSimpleIndex(\"leading\") ?? opIdx\n    );\n  }\n\n  #getScaledPath(path, currentTransform, transform) {\n    const newPath = new Path2D();\n    newPath.addPath(\n      path,\n      new DOMMatrix(transform).invertSelf().multiplySelf(currentTransform)\n    );\n    return newPath;\n  }\n\n  paintChar(\n    opIdx,\n    character,\n    x,\n    y,\n    patternFillTransform,\n    patternStrokeTransform\n  ) {\n    const ctx = this.ctx;\n    const current = this.current;\n    const font = current.font;\n    const textRenderingMode = current.textRenderingMode;\n    const fontSize = current.fontSize / current.fontSizeScale;\n    const fillStrokeMode =\n      textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;\n    const isAddToPathSet = !!(\n      textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG\n    );\n    const patternFill = current.patternFill && !font.missingFile;\n    const patternStroke = current.patternStroke && !font.missingFile;\n\n    let path;\n    if (\n      (font.disableFontFace ||\n        isAddToPathSet ||\n        patternFill ||\n        patternStroke) &&\n      !font.missingFile\n    ) {\n      path = font.getPathGenerator(this.commonObjs, character);\n    }\n\n    if (path && (font.disableFontFace || patternFill || patternStroke)) {\n      ctx.save();\n      ctx.translate(x, y);\n      ctx.scale(fontSize, -fontSize);\n\n      this.dependencyTracker?.recordCharacterBBox(opIdx, ctx, font);\n\n      let currentTransform;\n      if (\n        fillStrokeMode === TextRenderingMode.FILL ||\n        fillStrokeMode === TextRenderingMode.FILL_STROKE\n      ) {\n        if (patternFillTransform) {\n          currentTransform = ctx.getTransform();\n          ctx.setTransform(...patternFillTransform);\n          const scaledPath = this.#getScaledPath(\n            path,\n            currentTransform,\n            patternFillTransform\n          );\n          ctx.fill(scaledPath);\n        } else {\n          ctx.fill(path);\n        }\n      }\n      if (\n        fillStrokeMode === TextRenderingMode.STROKE ||\n        fillStrokeMode === TextRenderingMode.FILL_STROKE\n      ) {\n        if (patternStrokeTransform) {\n          currentTransform ||= ctx.getTransform();\n          ctx.setTransform(...patternStrokeTransform);\n          const { a, b, c, d } = currentTransform;\n          const invPatternTransform = Util.inverseTransform(\n            patternStrokeTransform\n          );\n          const transf = Util.transform(\n            [a, b, c, d, 0, 0],\n            invPatternTransform\n          );\n          Util.singularValueDecompose2dScale(transf, XY);\n\n          // Cancel the pattern scaling of the line width.\n          // If sx and sy are different, unfortunately we can't do anything and\n          // we'll have a rendering bug.\n          ctx.lineWidth *= Math.max(XY[0], XY[1]) / fontSize;\n          ctx.stroke(\n            this.#getScaledPath(path, currentTransform, patternStrokeTransform)\n          );\n        } else {\n          ctx.lineWidth /= fontSize;\n          ctx.stroke(path);\n        }\n      }\n      ctx.restore();\n    } else {\n      if (\n        fillStrokeMode === TextRenderingMode.FILL ||\n        fillStrokeMode === TextRenderingMode.FILL_STROKE\n      ) {\n        ctx.fillText(character, x, y);\n        this.dependencyTracker?.recordCharacterBBox(\n          opIdx,\n          ctx,\n          font,\n          fontSize,\n          x,\n          y,\n          () => ctx.measureText(character)\n        );\n      }\n      if (\n        fillStrokeMode === TextRenderingMode.STROKE ||\n        fillStrokeMode === TextRenderingMode.FILL_STROKE\n      ) {\n        if (this.dependencyTracker) {\n          this.dependencyTracker\n            ?.recordCharacterBBox(opIdx, ctx, font, fontSize, x, y, () =>\n              ctx.measureText(character)\n            )\n            .recordDependencies(opIdx, Dependencies.stroke);\n        }\n        ctx.strokeText(character, x, y);\n      }\n    }\n\n    if (isAddToPathSet) {\n      const paths = (this.pendingTextPaths ||= []);\n      paths.push({\n        transform: getCurrentTransform(ctx),\n        x,\n        y,\n        fontSize,\n        path,\n      });\n      this.dependencyTracker?.recordCharacterBBox(\n        opIdx,\n        ctx,\n        font,\n        fontSize,\n        x,\n        y\n      );\n    }\n  }\n\n  get isFontSubpixelAAEnabled() {\n    // Checks if anti-aliasing is enabled when scaled text is painted.\n    // On Windows GDI scaled fonts looks bad.\n    const { context: ctx } = this.cachedCanvases.getCanvas(\n      \"isFontSubpixelAAEnabled\",\n      10,\n      10\n    );\n    ctx.scale(1.5, 1);\n    ctx.fillText(\"I\", 0, 10);\n    const data = ctx.getImageData(0, 0, 10, 10).data;\n    let enabled = false;\n    for (let i = 3; i < data.length; i += 4) {\n      if (data[i] > 0 && data[i] < 255) {\n        enabled = true;\n        break;\n      }\n    }\n    return shadow(this, \"isFontSubpixelAAEnabled\", enabled);\n  }\n\n  showText(opIdx, glyphs) {\n    if (this.dependencyTracker) {\n      this.dependencyTracker\n        .recordDependencies(opIdx, Dependencies.showText)\n        .resetBBox(opIdx);\n      if (this.current.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG) {\n        this.dependencyTracker\n          .recordFutureForcedDependency(\"textClip\", opIdx)\n          .inheritPendingDependenciesAsFutureForcedDependencies();\n      }\n    }\n\n    const current = this.current;\n    const font = current.font;\n    if (font.isType3Font) {\n      this.showType3Text(opIdx, glyphs);\n      this.dependencyTracker?.recordShowTextOperation(opIdx);\n      return undefined;\n    }\n\n    const fontSize = current.fontSize;\n    if (fontSize === 0) {\n      this.dependencyTracker?.recordOperation(opIdx);\n      return undefined;\n    }\n\n    const ctx = this.ctx;\n    const fontSizeScale = current.fontSizeScale;\n    const charSpacing = current.charSpacing;\n    const wordSpacing = current.wordSpacing;\n    const fontDirection = current.fontDirection;\n    const textHScale = current.textHScale * fontDirection;\n    const glyphsLength = glyphs.length;\n    const vertical = font.vertical;\n    const spacingDir = vertical ? 1 : -1;\n    const defaultVMetrics = font.defaultVMetrics;\n    const widthAdvanceScale = fontSize * current.fontMatrix[0];\n\n    const simpleFillText =\n      current.textRenderingMode === TextRenderingMode.FILL &&\n      !font.disableFontFace &&\n      !current.patternFill;\n\n    ctx.save();\n    if (current.textMatrix) {\n      ctx.transform(...current.textMatrix);\n    }\n    ctx.translate(current.x, current.y + current.textRise);\n\n    if (fontDirection > 0) {\n      ctx.scale(textHScale, -1);\n    } else {\n      ctx.scale(textHScale, 1);\n    }\n\n    let patternFillTransform, patternStrokeTransform;\n\n    // Only compute pattern transforms if the text rendering mode actually\n    // uses fill/stroke. This avoids expensive pattern calculations each call\n    // when a patternFill/patternStroke is set, but unused.\n    const fillStrokeMode =\n      current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;\n    const needsFill =\n      fillStrokeMode === TextRenderingMode.FILL ||\n      fillStrokeMode === TextRenderingMode.FILL_STROKE;\n    const needsStroke =\n      fillStrokeMode === TextRenderingMode.STROKE ||\n      fillStrokeMode === TextRenderingMode.FILL_STROKE;\n\n    if (needsFill && current.patternFill) {\n      ctx.save();\n      const pattern = current.fillColor.getPattern(\n        ctx,\n        this,\n        getCurrentTransformInverse(ctx),\n        PathType.FILL,\n        opIdx\n      );\n      patternFillTransform = getCurrentTransform(ctx);\n      ctx.restore();\n      ctx.fillStyle = pattern;\n    }\n\n    if (needsStroke && current.patternStroke) {\n      ctx.save();\n      const pattern = current.strokeColor.getPattern(\n        ctx,\n        this,\n        getCurrentTransformInverse(ctx),\n        PathType.STROKE,\n        opIdx\n      );\n      patternStrokeTransform = getCurrentTransform(ctx);\n      ctx.restore();\n      ctx.strokeStyle = pattern;\n    }\n\n    let lineWidth = current.lineWidth;\n    const scale = current.textMatrixScale;\n    if (scale === 0 || lineWidth === 0) {\n      if (needsStroke) {\n        lineWidth = this.getSinglePixelWidth();\n      }\n    } else {\n      lineWidth /= scale;\n    }\n\n    if (fontSizeScale !== 1.0) {\n      ctx.scale(fontSizeScale, fontSizeScale);\n      lineWidth /= fontSizeScale;\n    }\n\n    ctx.lineWidth = lineWidth;\n\n    if (font.isInvalidPDFjsFont) {\n      const chars = [];\n      let width = 0;\n      for (const glyph of glyphs) {\n        chars.push(glyph.unicode);\n        width += glyph.width;\n      }\n      const joinedChars = chars.join(\"\");\n      ctx.fillText(joinedChars, 0, 0);\n      if (this.dependencyTracker !== null) {\n        const measure = ctx.measureText(joinedChars);\n        this.dependencyTracker\n          .recordBBox(\n            opIdx,\n            this.ctx,\n            -measure.actualBoundingBoxLeft,\n            measure.actualBoundingBoxRight,\n            -measure.actualBoundingBoxAscent,\n            measure.actualBoundingBoxDescent\n          )\n          .recordShowTextOperation(opIdx);\n      }\n      current.x += width * widthAdvanceScale * textHScale;\n      ctx.restore();\n      this.compose();\n      return undefined;\n    }\n\n    let x = 0,\n      i;\n    for (i = 0; i < glyphsLength; ++i) {\n      const glyph = glyphs[i];\n      if (typeof glyph === \"number\") {\n        x += (spacingDir * glyph * fontSize) / 1000;\n        continue;\n      }\n\n      let restoreNeeded = false;\n      const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;\n      const character = glyph.fontChar;\n      const accent = glyph.accent;\n      let scaledX, scaledY;\n      let width = glyph.width;\n      if (vertical) {\n        const vmetric = glyph.vmetric || defaultVMetrics;\n        const vx =\n          -(glyph.vmetric ? vmetric[1] : width * 0.5) * widthAdvanceScale;\n        const vy = vmetric[2] * widthAdvanceScale;\n\n        width = vmetric ? -vmetric[0] : width;\n        scaledX = vx / fontSizeScale;\n        scaledY = (x + vy) / fontSizeScale;\n      } else {\n        scaledX = x / fontSizeScale;\n        scaledY = 0;\n      }\n\n      let measure;\n\n      if (font.remeasure && width > 0) {\n        measure = ctx.measureText(character);\n\n        // Some standard fonts may not have the exact width: rescale per\n        // character if measured width is greater than expected glyph width\n        // and subpixel-aa is enabled, otherwise just center the glyph.\n        const measuredWidth =\n          ((measure.width * 1000) / fontSize) * fontSizeScale;\n        if (width < measuredWidth && this.isFontSubpixelAAEnabled) {\n          const characterScaleX = width / measuredWidth;\n          restoreNeeded = true;\n          ctx.save();\n          ctx.scale(characterScaleX, 1);\n          scaledX /= characterScaleX;\n        } else if (width !== measuredWidth) {\n          scaledX +=\n            (((width - measuredWidth) / 2000) * fontSize) / fontSizeScale;\n        }\n      }\n\n      // Only attempt to draw the glyph if it is actually in the embedded font\n      // file or if there isn't a font file so the fallback font is shown.\n      if (this.contentVisible && (glyph.isInFont || font.missingFile)) {\n        if (simpleFillText && !accent) {\n          // common case\n          ctx.fillText(character, scaledX, scaledY);\n\n          this.dependencyTracker?.recordCharacterBBox(\n            opIdx,\n            ctx,\n            // If we already measured the character, force usage of that\n            measure ? { bbox: null } : font,\n            fontSize / fontSizeScale,\n            scaledX,\n            scaledY,\n            () => measure ?? ctx.measureText(character)\n          );\n        } else {\n          this.paintChar(\n            opIdx,\n            character,\n            scaledX,\n            scaledY,\n            patternFillTransform,\n            patternStrokeTransform\n          );\n          if (accent) {\n            const scaledAccentX =\n              scaledX + (fontSize * accent.offset.x) / fontSizeScale;\n            const scaledAccentY =\n              scaledY - (fontSize * accent.offset.y) / fontSizeScale;\n            this.paintChar(\n              opIdx,\n              accent.fontChar,\n              scaledAccentX,\n              scaledAccentY,\n              patternFillTransform,\n              patternStrokeTransform\n            );\n          }\n        }\n      }\n\n      const charWidth = vertical\n        ? width * widthAdvanceScale - spacing * fontDirection\n        : width * widthAdvanceScale + spacing * fontDirection;\n      x += charWidth;\n\n      if (restoreNeeded) {\n        ctx.restore();\n      }\n    }\n    if (vertical) {\n      current.y -= x;\n    } else {\n      current.x += x * textHScale;\n    }\n    ctx.restore();\n    this.compose();\n\n    this.dependencyTracker?.recordShowTextOperation(opIdx);\n    return undefined;\n  }\n\n  showType3Text(opIdx, glyphs) {\n    // Type3 fonts - each glyph is a \"mini-PDF\"\n    const ctx = this.ctx;\n    const current = this.current;\n    const font = current.font;\n    const fontSize = current.fontSize;\n    const fontDirection = current.fontDirection;\n    const spacingDir = font.vertical ? 1 : -1;\n    const charSpacing = current.charSpacing;\n    const wordSpacing = current.wordSpacing;\n    const textHScale = current.textHScale * fontDirection;\n    const fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;\n    const glyphsLength = glyphs.length;\n    const isTextInvisible =\n      current.textRenderingMode === TextRenderingMode.INVISIBLE;\n    let i, glyph, width, spacingLength;\n\n    if (isTextInvisible || fontSize === 0) {\n      return;\n    }\n    this._cachedScaleForStroking[0] = -1;\n    this._cachedGetSinglePixelWidth = null;\n\n    ctx.save();\n    if (current.textMatrix) {\n      ctx.transform(...current.textMatrix);\n    }\n    ctx.translate(current.x, current.y + current.textRise);\n\n    ctx.scale(textHScale, fontDirection);\n\n    // Type3 fonts have their own operator list. Avoid mixing it up with the\n    // dependency tracker of the main operator list.\n    const dependencyTracker = this.dependencyTracker;\n    this.dependencyTracker = dependencyTracker\n      ? new CanvasNestedDependencyTracker(dependencyTracker, opIdx)\n      : null;\n\n    for (i = 0; i < glyphsLength; ++i) {\n      glyph = glyphs[i];\n      if (typeof glyph === \"number\") {\n        spacingLength = (spacingDir * glyph * fontSize) / 1000;\n        this.ctx.translate(spacingLength, 0);\n        current.x += spacingLength * textHScale;\n        continue;\n      }\n\n      const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;\n      const operatorList = font.charProcOperatorList[glyph.operatorListId];\n      if (!operatorList) {\n        warn(`Type3 character \"${glyph.operatorListId}\" is not available.`);\n      } else if (this.contentVisible) {\n        this.save();\n        ctx.scale(fontSize, fontSize);\n        ctx.transform(...fontMatrix);\n        this.executeOperatorList(operatorList);\n        this.restore();\n      }\n\n      const p = [glyph.width, 0];\n      Util.applyTransform(p, fontMatrix);\n      width = p[0] * fontSize + spacing;\n\n      ctx.translate(width, 0);\n      current.x += width * textHScale;\n    }\n    ctx.restore();\n    if (dependencyTracker) {\n      this.dependencyTracker = dependencyTracker;\n    }\n  }\n\n  // Type3 fonts\n  setCharWidth(opIdx, xWidth, yWidth) {\n    // We can safely ignore this since the width should be the same\n    // as the width in the Widths array.\n  }\n\n  setCharWidthAndBounds(opIdx, xWidth, yWidth, llx, lly, urx, ury) {\n    const clip = new Path2D();\n    clip.rect(llx, lly, urx - llx, ury - lly);\n    this.ctx.clip(clip);\n    this.dependencyTracker\n      ?.recordBBox(opIdx, this.ctx, llx, urx, lly, ury)\n      .recordClipBox(opIdx, this.ctx, llx, urx, lly, ury);\n    this.endPath(opIdx);\n  }\n\n  // Color\n  getColorN_Pattern(opIdx, IR) {\n    let pattern;\n    if (IR[0] === \"TilingPattern\") {\n      const baseTransform = this.baseTransform || getCurrentTransform(this.ctx);\n      const canvasGraphicsFactory = {\n        createCanvasGraphics: (ctx, renderingOpIdx) =>\n          new CanvasGraphics(\n            ctx,\n            this.commonObjs,\n            this.objs,\n            this.canvasFactory,\n            this.filterFactory,\n            {\n              optionalContentConfig: this.optionalContentConfig,\n              markedContentStack: this.markedContentStack,\n            },\n            undefined,\n            undefined,\n            this.dependencyTracker\n              ? new CanvasNestedDependencyTracker(\n                  this.dependencyTracker,\n                  renderingOpIdx,\n                  /* ignoreBBoxes */ true\n                )\n              : null\n          ),\n      };\n      pattern = new TilingPattern(\n        IR,\n        this.ctx,\n        canvasGraphicsFactory,\n        baseTransform\n      );\n    } else {\n      pattern = this._getPattern(opIdx, IR[1], IR[2]);\n    }\n    return pattern;\n  }\n\n  setStrokeColorN(opIdx, ...args) {\n    this.dependencyTracker?.recordSimpleData(\"strokeColor\", opIdx);\n    this.current.strokeColor = this.getColorN_Pattern(opIdx, args);\n    this.current.patternStroke = true;\n  }\n\n  setFillColorN(opIdx, ...args) {\n    this.dependencyTracker?.recordSimpleData(\"fillColor\", opIdx);\n    this.current.fillColor = this.getColorN_Pattern(opIdx, args);\n    this.current.patternFill = true;\n  }\n\n  setStrokeRGBColor(opIdx, color) {\n    this.dependencyTracker?.recordSimpleData(\"strokeColor\", opIdx);\n    this.ctx.strokeStyle = this.current.strokeColor = color;\n    this.current.patternStroke = false;\n  }\n\n  setStrokeTransparent(opIdx) {\n    this.dependencyTracker?.recordSimpleData(\"strokeColor\", opIdx);\n    this.ctx.strokeStyle = this.current.strokeColor = \"transparent\";\n    this.current.patternStroke = false;\n  }\n\n  setFillRGBColor(opIdx, color) {\n    this.dependencyTracker?.recordSimpleData(\"fillColor\", opIdx);\n    this.ctx.fillStyle = this.current.fillColor = color;\n    this.current.patternFill = false;\n  }\n\n  setFillTransparent(opIdx) {\n    this.dependencyTracker?.recordSimpleData(\"fillColor\", opIdx);\n    this.ctx.fillStyle = this.current.fillColor = \"transparent\";\n    this.current.patternFill = false;\n  }\n\n  _getPattern(opIdx, objId, matrix = null) {\n    let pattern;\n    if (this.cachedPatterns.has(objId)) {\n      pattern = this.cachedPatterns.get(objId);\n    } else {\n      pattern = getShadingPattern(this.getObject(opIdx, objId));\n      this.cachedPatterns.set(objId, pattern);\n    }\n    if (matrix) {\n      pattern.matrix = matrix;\n    }\n    return pattern;\n  }\n\n  shadingFill(opIdx, objId) {\n    if (!this.contentVisible) {\n      return;\n    }\n    const ctx = this.ctx;\n\n    this.save(opIdx);\n    const pattern = this._getPattern(opIdx, objId);\n    ctx.fillStyle = pattern.getPattern(\n      ctx,\n      this,\n      getCurrentTransformInverse(ctx),\n      PathType.SHADING,\n      opIdx\n    );\n\n    const inv = getCurrentTransformInverse(ctx);\n    if (inv) {\n      const { width, height } = ctx.canvas;\n      const minMax = MIN_MAX_INIT.slice();\n      Util.axialAlignedBoundingBox([0, 0, width, height], inv, minMax);\n      const [x0, y0, x1, y1] = minMax;\n\n      this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);\n    } else {\n      // HACK to draw the gradient onto an infinite rectangle.\n      // PDF gradients are drawn across the entire image while\n      // Canvas only allows gradients to be drawn in a rectangle\n      // The following bug should allow us to remove this.\n      // https://bugzilla.mozilla.org/show_bug.cgi?id=664884\n\n      this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);\n    }\n\n    this.dependencyTracker\n      ?.resetBBox(opIdx)\n      // TODO: Track proper bbox\n      .recordFullPageBBox(opIdx)\n      .recordDependencies(opIdx, Dependencies.transform)\n      .recordDependencies(opIdx, Dependencies.fill)\n      .recordOperation(opIdx);\n\n    this.compose(this.current.getClippedPathBoundingBox());\n    this.restore(opIdx);\n  }\n\n  // Images\n  beginInlineImage() {\n    unreachable(\"Should not call beginInlineImage\");\n  }\n\n  beginImageData() {\n    unreachable(\"Should not call beginImageData\");\n  }\n\n  paintFormXObjectBegin(opIdx, matrix, bbox) {\n    if (!this.contentVisible) {\n      return;\n    }\n    this.save(opIdx);\n    this.baseTransformStack.push(this.baseTransform);\n\n    if (matrix) {\n      this.transform(opIdx, ...matrix);\n    }\n    this.baseTransform = getCurrentTransform(this.ctx);\n\n    if (bbox) {\n      Util.axialAlignedBoundingBox(\n        bbox,\n        this.baseTransform,\n        this.current.minMax\n      );\n      const [x0, y0, x1, y1] = bbox;\n      const clip = new Path2D();\n      clip.rect(x0, y0, x1 - x0, y1 - y0);\n      this.ctx.clip(clip);\n      this.dependencyTracker?.recordClipBox(opIdx, this.ctx, x0, x1, y0, y1);\n      this.endPath(opIdx);\n    }\n  }\n\n  paintFormXObjectEnd(opIdx) {\n    if (!this.contentVisible) {\n      return;\n    }\n    this.restore(opIdx);\n    this.baseTransform = this.baseTransformStack.pop();\n  }\n\n  beginGroup(opIdx, group) {\n    if (!this.contentVisible) {\n      return;\n    }\n\n    this.save(opIdx);\n    // If there's an active soft mask we don't want it enabled for the group, so\n    // clear it out. The mask and suspended canvas will be restored in endGroup.\n    if (this.inSMaskMode) {\n      this.endSMaskMode();\n      this.current.activeSMask = null;\n    }\n\n    const currentCtx = this.ctx;\n    // TODO non-isolated groups - according to Rik at adobe non-isolated\n    // group results aren't usually that different and they even have tools\n    // that ignore this setting. Notes from Rik on implementing:\n    // - When you encounter an transparency group, create a new canvas with\n    // the dimensions of the bbox\n    // - copy the content from the previous canvas to the new canvas\n    // - draw as usual\n    // - remove the backdrop alpha:\n    // alphaNew = 1 - (1 - alpha)/(1 - alphaBackdrop) with 'alpha' the alpha\n    // value of your transparency group and 'alphaBackdrop' the alpha of the\n    // backdrop\n    // - remove background color:\n    // colorNew = color - alphaNew *colorBackdrop /(1 - alphaNew)\n    if (!group.isolated) {\n      info(\"TODO: Support non-isolated groups.\");\n    }\n\n    // TODO knockout - supposedly possible with the clever use of compositing\n    // modes.\n    if (group.knockout) {\n      warn(\"Knockout groups not supported.\");\n    }\n\n    const currentTransform = getCurrentTransform(currentCtx);\n    if (group.matrix) {\n      currentCtx.transform(...group.matrix);\n    }\n    if (!group.bbox) {\n      throw new Error(\"Bounding box is required.\");\n    }\n\n    // Based on the current transform figure out how big the bounding box\n    // will actually be.\n    let bounds = MIN_MAX_INIT.slice();\n    Util.axialAlignedBoundingBox(\n      group.bbox,\n      getCurrentTransform(currentCtx),\n      bounds\n    );\n\n    // Clip the bounding box to the current canvas.\n    const canvasBounds = [\n      0,\n      0,\n      currentCtx.canvas.width,\n      currentCtx.canvas.height,\n    ];\n    bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];\n    // Use ceil in case we're between sizes so we don't create canvas that is\n    // too small and make the canvas at least 1x1 pixels.\n    const offsetX = Math.floor(bounds[0]);\n    const offsetY = Math.floor(bounds[1]);\n    const drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);\n    const drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);\n\n    this.current.startNewPathAndClipBox([0, 0, drawnWidth, drawnHeight]);\n\n    let cacheId = \"groupAt\" + this.groupLevel;\n    if (group.smask) {\n      // Using two cache entries is case if masks are used one after another.\n      cacheId += \"_smask_\" + (this.smaskCounter++ % 2);\n    }\n    const scratchCanvas = this.cachedCanvases.getCanvas(\n      cacheId,\n      drawnWidth,\n      drawnHeight\n    );\n    const groupCtx = scratchCanvas.context;\n\n    // Since we created a new canvas that is just the size of the bounding box\n    // we have to translate the group ctx.\n    groupCtx.translate(-offsetX, -offsetY);\n    groupCtx.transform(...currentTransform);\n\n    // Apply the bbox to the group context.\n    let clip = new Path2D();\n    const [x0, y0, x1, y1] = group.bbox;\n    clip.rect(x0, y0, x1 - x0, y1 - y0);\n    if (group.matrix) {\n      const path = new Path2D();\n      path.addPath(clip, new DOMMatrix(group.matrix));\n      clip = path;\n    }\n    groupCtx.clip(clip);\n\n    if (group.smask) {\n      // Saving state and cached mask to be used in setGState.\n      this.smaskStack.push({\n        canvas: scratchCanvas.canvas,\n        context: groupCtx,\n        offsetX,\n        offsetY,\n        subtype: group.smask.subtype,\n        backdrop: group.smask.backdrop,\n        transferMap: group.smask.transferMap || null,\n        startTransformInverse: null, // used during suspend operation\n      });\n    }\n    if (\n      !group.smask ||\n      // When this is not an SMask group, we only need to update the current\n      // transform if recording operations bboxes, so they the bboxes have the\n      // correct transform applied.\n      this.dependencyTracker\n    ) {\n      // Setup the current ctx so when the group is popped we draw it at the\n      // right location.\n      currentCtx.setTransform(1, 0, 0, 1, 0, 0);\n      currentCtx.translate(offsetX, offsetY);\n      currentCtx.save();\n    }\n    // The transparency group inherits all off the current graphics state\n    // except the blend mode, soft mask, and alpha constants.\n    copyCtxState(currentCtx, groupCtx);\n    this.ctx = groupCtx;\n    this.dependencyTracker\n      ?.inheritSimpleDataAsFutureForcedDependencies([\n        \"fillAlpha\",\n        \"strokeAlpha\",\n        \"globalCompositeOperation\",\n      ])\n      .pushBaseTransform(currentCtx);\n    this.setGState(opIdx, [\n      [\"BM\", \"source-over\"],\n      [\"ca\", 1],\n      [\"CA\", 1],\n      [\"TR\", null],\n    ]);\n    this.groupStack.push(currentCtx);\n    this.groupLevel++;\n  }\n\n  endGroup(opIdx, group) {\n    if (!this.contentVisible) {\n      return;\n    }\n    this.groupLevel--;\n    const groupCtx = this.ctx;\n    const ctx = this.groupStack.pop();\n    this.ctx = ctx;\n    // Turn off image smoothing to avoid sub pixel interpolation which can\n    // look kind of blurry for some pdfs.\n    this.ctx.imageSmoothingEnabled = false;\n\n    this.dependencyTracker?.popBaseTransform();\n\n    if (group.smask) {\n      this.tempSMask = this.smaskStack.pop();\n      this.restore(opIdx);\n      if (this.dependencyTracker) {\n        this.ctx.restore();\n      }\n    } else {\n      this.ctx.restore();\n      const currentMtx = getCurrentTransform(this.ctx);\n      this.restore(opIdx);\n      this.ctx.save();\n      this.ctx.setTransform(...currentMtx);\n      const dirtyBox = MIN_MAX_INIT.slice();\n      Util.axialAlignedBoundingBox(\n        [0, 0, groupCtx.canvas.width, groupCtx.canvas.height],\n        currentMtx,\n        dirtyBox\n      );\n      this.ctx.drawImage(groupCtx.canvas, 0, 0);\n      this.ctx.restore();\n      this.compose(dirtyBox);\n    }\n  }\n\n  beginAnnotation(opIdx, id, rect, transform, matrix, hasOwnCanvas) {\n    // The annotations are drawn just after the page content.\n    // The page content drawing can potentially have set a transform,\n    // a clipping path, whatever...\n    // So in order to have something clean, we restore the initial state.\n    this.#restoreInitialState();\n    resetCtxToDefault(this.ctx);\n\n    this.ctx.save();\n    this.save(opIdx);\n\n    if (this.baseTransform) {\n      this.ctx.setTransform(...this.baseTransform);\n    }\n\n    if (rect) {\n      const width = rect[2] - rect[0];\n      const height = rect[3] - rect[1];\n\n      if (hasOwnCanvas && this.annotationCanvasMap) {\n        transform = transform.slice();\n        transform[4] -= rect[0];\n        transform[5] -= rect[1];\n\n        rect = rect.slice();\n        rect[0] = rect[1] = 0;\n        rect[2] = width;\n        rect[3] = height;\n\n        Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx), XY);\n        const { viewportScale } = this;\n        const canvasWidth = Math.ceil(\n          width * this.outputScaleX * viewportScale\n        );\n        const canvasHeight = Math.ceil(\n          height * this.outputScaleY * viewportScale\n        );\n\n        this.annotationCanvas = this.canvasFactory.create(\n          canvasWidth,\n          canvasHeight\n        );\n        const { canvas, context } = this.annotationCanvas;\n        this.annotationCanvasMap.set(id, canvas);\n        this.annotationCanvas.savedCtx = this.ctx;\n        this.ctx = context;\n        this.ctx.save();\n        this.ctx.setTransform(XY[0], 0, 0, -XY[1], 0, height * XY[1]);\n\n        resetCtxToDefault(this.ctx);\n      } else {\n        resetCtxToDefault(this.ctx);\n\n        // Consume a potential path before clipping.\n        this.endPath(opIdx);\n\n        const clip = new Path2D();\n        clip.rect(rect[0], rect[1], width, height);\n        this.ctx.clip(clip);\n      }\n    }\n\n    this.current = new CanvasExtraState(\n      this.ctx.canvas.width,\n      this.ctx.canvas.height\n    );\n\n    this.transform(opIdx, ...transform);\n    this.transform(opIdx, ...matrix);\n  }\n\n  endAnnotation(opIdx) {\n    if (this.annotationCanvas) {\n      this.ctx.restore();\n      this.#drawFilter();\n\n      this.ctx = this.annotationCanvas.savedCtx;\n      delete this.annotationCanvas.savedCtx;\n      delete this.annotationCanvas;\n    }\n  }\n\n  paintImageMaskXObject(opIdx, img) {\n    if (!this.contentVisible) {\n      return;\n    }\n\n    const count = img.count;\n    img = this.getObject(opIdx, img.data, img);\n    img.count = count;\n\n    const ctx = this.ctx;\n    const mask = this._createMaskCanvas(opIdx, img);\n    const maskCanvas = mask.canvas;\n\n    ctx.save();\n    // The mask is drawn with the transform applied. Reset the current\n    // transform to draw to the identity.\n    ctx.setTransform(1, 0, 0, 1, 0, 0);\n    ctx.drawImage(maskCanvas, mask.offsetX, mask.offsetY);\n    this.dependencyTracker\n      ?.resetBBox(opIdx)\n      .recordBBox(\n        opIdx,\n        this.ctx,\n        mask.offsetX,\n        mask.offsetX + maskCanvas.width,\n        mask.offsetY,\n        mask.offsetY + maskCanvas.height\n      )\n      .recordOperation(opIdx);\n    ctx.restore();\n    this.compose();\n  }\n\n  paintImageMaskXObjectRepeat(\n    opIdx,\n    img,\n    scaleX,\n    skewX = 0,\n    skewY = 0,\n    scaleY,\n    positions\n  ) {\n    if (!this.contentVisible) {\n      return;\n    }\n\n    img = this.getObject(opIdx, img.data, img);\n\n    const ctx = this.ctx;\n    ctx.save();\n    const currentTransform = getCurrentTransform(ctx);\n    ctx.transform(scaleX, skewX, skewY, scaleY, 0, 0);\n    const mask = this._createMaskCanvas(opIdx, img);\n\n    ctx.setTransform(\n      1,\n      0,\n      0,\n      1,\n      mask.offsetX - currentTransform[4],\n      mask.offsetY - currentTransform[5]\n    );\n    this.dependencyTracker?.resetBBox(opIdx);\n    for (let i = 0, ii = positions.length; i < ii; i += 2) {\n      const trans = Util.transform(currentTransform, [\n        scaleX,\n        skewX,\n        skewY,\n        scaleY,\n        positions[i],\n        positions[i + 1],\n      ]);\n\n      // Here we want to apply the transform at the origin,\n      // hence no additional computation is necessary.\n      ctx.drawImage(mask.canvas, trans[4], trans[5]);\n      this.dependencyTracker?.recordBBox(\n        opIdx,\n        this.ctx,\n        trans[4],\n        trans[4] + mask.canvas.width,\n        trans[5],\n        trans[5] + mask.canvas.height\n      );\n    }\n    ctx.restore();\n    this.compose();\n\n    this.dependencyTracker?.recordOperation(opIdx);\n  }\n\n  paintImageMaskXObjectGroup(opIdx, images) {\n    if (!this.contentVisible) {\n      return;\n    }\n    const ctx = this.ctx;\n\n    const fillColor = this.current.fillColor;\n    const isPatternFill = this.current.patternFill;\n\n    this.dependencyTracker\n      ?.resetBBox(opIdx)\n      .recordDependencies(opIdx, Dependencies.transformAndFill);\n\n    for (const image of images) {\n      const { data, width, height, transform } = image;\n\n      const maskCanvas = this.cachedCanvases.getCanvas(\n        \"maskCanvas\",\n        width,\n        height\n      );\n      const maskCtx = maskCanvas.context;\n      maskCtx.save();\n\n      const img = this.getObject(opIdx, data, image);\n      putBinaryImageMask(maskCtx, img);\n\n      maskCtx.globalCompositeOperation = \"source-in\";\n\n      maskCtx.fillStyle = isPatternFill\n        ? fillColor.getPattern(\n            maskCtx,\n            this,\n            getCurrentTransformInverse(ctx),\n            PathType.FILL,\n            opIdx\n          )\n        : fillColor;\n      maskCtx.fillRect(0, 0, width, height);\n\n      maskCtx.restore();\n\n      ctx.save();\n      ctx.transform(...transform);\n      ctx.scale(1, -1);\n      drawImageAtIntegerCoords(\n        ctx,\n        maskCanvas.canvas,\n        0,\n        0,\n        width,\n        height,\n        0,\n        -1,\n        1,\n        1\n      );\n\n      this.dependencyTracker?.recordBBox(opIdx, ctx, 0, width, 0, height);\n      ctx.restore();\n    }\n    this.compose();\n    this.dependencyTracker?.recordOperation(opIdx);\n  }\n\n  paintImageXObject(opIdx, objId) {\n    if (!this.contentVisible) {\n      return;\n    }\n    const imgData = this.getObject(opIdx, objId);\n    if (!imgData) {\n      warn(\"Dependent image isn't ready yet\");\n      return;\n    }\n\n    this.paintInlineImageXObject(opIdx, imgData);\n  }\n\n  paintImageXObjectRepeat(opIdx, objId, scaleX, scaleY, positions) {\n    if (!this.contentVisible) {\n      return;\n    }\n    const imgData = this.getObject(opIdx, objId);\n    if (!imgData) {\n      warn(\"Dependent image isn't ready yet\");\n      return;\n    }\n\n    const width = imgData.width;\n    const height = imgData.height;\n    const map = [];\n    for (let i = 0, ii = positions.length; i < ii; i += 2) {\n      map.push({\n        transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]],\n        x: 0,\n        y: 0,\n        w: width,\n        h: height,\n      });\n    }\n    this.paintInlineImageXObjectGroup(opIdx, imgData, map);\n  }\n\n  applyTransferMapsToCanvas(ctx) {\n    if (this.current.transferMaps !== \"none\") {\n      ctx.filter = this.current.transferMaps;\n      ctx.drawImage(ctx.canvas, 0, 0);\n      ctx.filter = \"none\";\n    }\n    return ctx.canvas;\n  }\n\n  applyTransferMapsToBitmap(imgData) {\n    if (this.current.transferMaps === \"none\") {\n      return imgData.bitmap;\n    }\n    const { bitmap, width, height } = imgData;\n    const tmpCanvas = this.cachedCanvases.getCanvas(\n      \"inlineImage\",\n      width,\n      height\n    );\n    const tmpCtx = tmpCanvas.context;\n    tmpCtx.filter = this.current.transferMaps;\n    tmpCtx.drawImage(bitmap, 0, 0);\n    tmpCtx.filter = \"none\";\n\n    return tmpCanvas.canvas;\n  }\n\n  paintInlineImageXObject(opIdx, imgData) {\n    if (!this.contentVisible) {\n      return;\n    }\n    const width = imgData.width;\n    const height = imgData.height;\n    const ctx = this.ctx;\n\n    this.save(opIdx);\n\n    // The filter, if any, will be applied in applyTransferMapsToBitmap.\n    // It must be applied to the image before rescaling else some artifacts\n    // could appear.\n    // The final restore will reset it to its value.\n    const { filter } = ctx;\n    if (filter !== \"none\" && filter !== \"\") {\n      ctx.filter = \"none\";\n    }\n\n    // scale the image to the unit square\n    ctx.scale(1 / width, -1 / height);\n\n    let imgToPaint;\n    if (imgData.bitmap) {\n      imgToPaint = this.applyTransferMapsToBitmap(imgData);\n    } else if (\n      (typeof HTMLElement === \"function\" && imgData instanceof HTMLElement) ||\n      !imgData.data\n    ) {\n      // typeof check is needed due to node.js support, see issue #8489\n      imgToPaint = imgData;\n    } else {\n      const tmpCanvas = this.cachedCanvases.getCanvas(\n        \"inlineImage\",\n        width,\n        height\n      );\n      const tmpCtx = tmpCanvas.context;\n      putBinaryImageData(tmpCtx, imgData);\n      imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);\n    }\n\n    const scaled = this._scaleImage(\n      imgToPaint,\n      getCurrentTransformInverse(ctx)\n    );\n    ctx.imageSmoothingEnabled = getImageSmoothingEnabled(\n      getCurrentTransform(ctx),\n      imgData.interpolate\n    );\n\n    this.dependencyTracker\n      ?.resetBBox(opIdx)\n      .recordBBox(opIdx, ctx, 0, width, -height, 0)\n      .recordDependencies(opIdx, Dependencies.imageXObject)\n      .recordOperation(opIdx);\n\n    drawImageAtIntegerCoords(\n      ctx,\n      scaled.img,\n      0,\n      0,\n      scaled.paintWidth,\n      scaled.paintHeight,\n      0,\n      -height,\n      width,\n      height\n    );\n    this.compose();\n    this.restore(opIdx);\n  }\n\n  paintInlineImageXObjectGroup(opIdx, imgData, map) {\n    if (!this.contentVisible) {\n      return;\n    }\n    const ctx = this.ctx;\n    let imgToPaint;\n    if (imgData.bitmap) {\n      imgToPaint = imgData.bitmap;\n    } else {\n      const w = imgData.width;\n      const h = imgData.height;\n\n      const tmpCanvas = this.cachedCanvases.getCanvas(\"inlineImage\", w, h);\n      const tmpCtx = tmpCanvas.context;\n      putBinaryImageData(tmpCtx, imgData);\n      imgToPaint = this.applyTransferMapsToCanvas(tmpCtx);\n    }\n\n    this.dependencyTracker?.resetBBox(opIdx);\n\n    for (const entry of map) {\n      ctx.save();\n      ctx.transform(...entry.transform);\n      ctx.scale(1, -1);\n      drawImageAtIntegerCoords(\n        ctx,\n        imgToPaint,\n        entry.x,\n        entry.y,\n        entry.w,\n        entry.h,\n        0,\n        -1,\n        1,\n        1\n      );\n      this.dependencyTracker?.recordBBox(opIdx, ctx, 0, 1, -1, 0);\n      ctx.restore();\n    }\n    this.dependencyTracker?.recordOperation(opIdx);\n    this.compose();\n  }\n\n  paintSolidColorImageMask(opIdx) {\n    if (!this.contentVisible) {\n      return;\n    }\n    this.dependencyTracker\n      ?.resetBBox(opIdx)\n      .recordBBox(opIdx, this.ctx, 0, 1, 0, 1)\n      .recordDependencies(opIdx, Dependencies.fill)\n      .recordOperation(opIdx);\n    this.ctx.fillRect(0, 0, 1, 1);\n    this.compose();\n  }\n\n  // Marked content\n\n  markPoint(opIdx, tag) {\n    // TODO Marked content.\n  }\n\n  markPointProps(opIdx, tag, properties) {\n    // TODO Marked content.\n  }\n\n  beginMarkedContent(opIdx, tag) {\n    this.dependencyTracker?.beginMarkedContent(opIdx);\n    this.markedContentStack.push({\n      visible: true,\n    });\n  }\n\n  beginMarkedContentProps(opIdx, tag, properties) {\n    this.dependencyTracker?.beginMarkedContent(opIdx);\n    if (tag === \"OC\") {\n      this.markedContentStack.push({\n        visible: this.optionalContentConfig.isVisible(properties),\n      });\n    } else {\n      this.markedContentStack.push({\n        visible: true,\n      });\n    }\n    this.contentVisible = this.isContentVisible();\n  }\n\n  endMarkedContent(opIdx) {\n    this.dependencyTracker?.endMarkedContent(opIdx);\n    this.markedContentStack.pop();\n    this.contentVisible = this.isContentVisible();\n  }\n\n  // Compatibility\n\n  beginCompat(opIdx) {\n    // TODO ignore undefined operators (should we do that anyway?)\n  }\n\n  endCompat(opIdx) {\n    // TODO stop ignoring undefined operators\n  }\n\n  // Helper functions\n\n  consumePath(opIdx, path, clipBox) {\n    const isEmpty = this.current.isEmptyClip();\n    if (this.pendingClip) {\n      this.current.updateClipFromPath();\n    }\n    if (!this.pendingClip) {\n      this.compose(clipBox);\n    }\n    const ctx = this.ctx;\n    if (this.pendingClip) {\n      if (!isEmpty) {\n        if (this.pendingClip === EO_CLIP) {\n          ctx.clip(path, \"evenodd\");\n        } else {\n          ctx.clip(path);\n        }\n      }\n      this.pendingClip = null;\n      this.dependencyTracker\n        ?.bboxToClipBoxDropOperation(opIdx)\n        .recordFutureForcedDependency(\"clipPath\", opIdx);\n    } else {\n      this.dependencyTracker?.recordOperation(opIdx);\n    }\n\n    this.current.startNewPathAndClipBox(this.current.clipBox);\n  }\n\n  getSinglePixelWidth() {\n    if (!this._cachedGetSinglePixelWidth) {\n      const m = getCurrentTransform(this.ctx);\n      if (m[1] === 0 && m[2] === 0) {\n        // Fast path\n        this._cachedGetSinglePixelWidth =\n          1 / Math.min(Math.abs(m[0]), Math.abs(m[3]));\n      } else {\n        const absDet = Math.abs(m[0] * m[3] - m[2] * m[1]);\n        const normX = Math.hypot(m[0], m[2]);\n        const normY = Math.hypot(m[1], m[3]);\n        this._cachedGetSinglePixelWidth = Math.max(normX, normY) / absDet;\n      }\n    }\n    return this._cachedGetSinglePixelWidth;\n  }\n\n  getScaleForStroking() {\n    // A pixel has thicknessX = thicknessY = 1;\n    // A transformed pixel is a parallelogram and the thicknesses\n    // corresponds to the heights.\n    // The goal of this function is to rescale before setting the\n    // lineWidth in order to have both thicknesses greater or equal\n    // to 1 after transform.\n    if (this._cachedScaleForStroking[0] === -1) {\n      const { lineWidth } = this.current;\n      const { a, b, c, d } = this.ctx.getTransform();\n      let scaleX, scaleY;\n\n      if (b === 0 && c === 0) {\n        // Fast path\n        const normX = Math.abs(a);\n        const normY = Math.abs(d);\n        if (normX === normY) {\n          if (lineWidth === 0) {\n            scaleX = scaleY = 1 / normX;\n          } else {\n            const scaledLineWidth = normX * lineWidth;\n            scaleX = scaleY = scaledLineWidth < 1 ? 1 / scaledLineWidth : 1;\n          }\n        } else if (lineWidth === 0) {\n          scaleX = 1 / normX;\n          scaleY = 1 / normY;\n        } else {\n          const scaledXLineWidth = normX * lineWidth;\n          const scaledYLineWidth = normY * lineWidth;\n          scaleX = scaledXLineWidth < 1 ? 1 / scaledXLineWidth : 1;\n          scaleY = scaledYLineWidth < 1 ? 1 / scaledYLineWidth : 1;\n        }\n      } else {\n        // A pixel (base (x, y)) is transformed by M into a parallelogram:\n        //  - its area is |det(M)|;\n        //  - heightY (orthogonal to Mx) has a length: |det(M)| / norm(Mx);\n        //  - heightX (orthogonal to My) has a length: |det(M)| / norm(My).\n        // heightX and heightY are the thicknesses of the transformed pixel\n        // and they must be both greater or equal to 1.\n        const absDet = Math.abs(a * d - b * c);\n        const normX = Math.hypot(a, b);\n        const normY = Math.hypot(c, d);\n        if (lineWidth === 0) {\n          scaleX = normY / absDet;\n          scaleY = normX / absDet;\n        } else {\n          const baseArea = lineWidth * absDet;\n          scaleX = normY > baseArea ? normY / baseArea : 1;\n          scaleY = normX > baseArea ? normX / baseArea : 1;\n        }\n      }\n      this._cachedScaleForStroking[0] = scaleX;\n      this._cachedScaleForStroking[1] = scaleY;\n    }\n    return this._cachedScaleForStroking;\n  }\n\n  // Rescale before stroking in order to have a final lineWidth\n  // with both thicknesses greater or equal to 1.\n  rescaleAndStroke(path, saveRestore) {\n    const {\n      ctx,\n      current: { lineWidth },\n    } = this;\n    const [scaleX, scaleY] = this.getScaleForStroking();\n\n    if (scaleX === scaleY) {\n      ctx.lineWidth = (lineWidth || 1) * scaleX;\n      ctx.stroke(path);\n      return;\n    }\n\n    const dashes = ctx.getLineDash();\n    if (saveRestore) {\n      ctx.save();\n    }\n\n    ctx.scale(scaleX, scaleY);\n    SCALE_MATRIX.a = 1 / scaleX;\n    SCALE_MATRIX.d = 1 / scaleY;\n    const newPath = new Path2D();\n    newPath.addPath(path, SCALE_MATRIX);\n\n    // How the dashed line is rendered depends on the current transform...\n    // so we added a rescale to handle too thin lines and consequently\n    // the way the line is dashed will be modified.\n    // If scaleX === scaleY, the dashed lines will be rendered correctly\n    // else we'll have some bugs (but only with too thin lines).\n    // Here we take the max... why not taking the min... or something else.\n    // Anyway, as said it's buggy when scaleX !== scaleY.\n    if (dashes.length > 0) {\n      const scale = Math.max(scaleX, scaleY);\n      ctx.setLineDash(dashes.map(x => x / scale));\n      ctx.lineDashOffset /= scale;\n    }\n\n    ctx.lineWidth = lineWidth || 1;\n    ctx.stroke(newPath);\n\n    if (saveRestore) {\n      ctx.restore();\n    }\n  }\n\n  isContentVisible() {\n    for (let i = this.markedContentStack.length - 1; i >= 0; i--) {\n      if (!this.markedContentStack[i].visible) {\n        return false;\n      }\n    }\n    return true;\n  }\n}\n\nfor (const op in OPS) {\n  if (CanvasGraphics.prototype[op] !== undefined) {\n    CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];\n  }\n}\n\nexport { CanvasGraphics };\n","/* Copyright 2018 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass GlobalWorkerOptions {\n  static #port = null;\n\n  static #src = \"\";\n\n  /**\n   * @type {Worker | null}\n   */\n  static get workerPort() {\n    return this.#port;\n  }\n\n  /**\n   * @param {Worker | null} workerPort - Defines global port for worker process.\n   *   Overrides the `workerSrc` option.\n   */\n  static set workerPort(val) {\n    if (\n      !(typeof Worker !== \"undefined\" && val instanceof Worker) &&\n      val !== null\n    ) {\n      throw new Error(\"Invalid `workerPort` type.\");\n    }\n    this.#port = val;\n  }\n\n  /**\n   * @type {string}\n   */\n  static get workerSrc() {\n    return this.#src;\n  }\n\n  /**\n   * @param {string} workerSrc - A string containing the path and filename of\n   *   the worker file.\n   *\n   *   NOTE: The `workerSrc` option should always be set, in order to prevent\n   *         any issues when using the PDF.js library.\n   */\n  static set workerSrc(val) {\n    if (typeof val !== \"string\") {\n      throw new Error(\"Invalid `workerSrc` type.\");\n    }\n    this.#src = val;\n  }\n}\n\nexport { GlobalWorkerOptions };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nclass Metadata {\n  #map;\n\n  #data;\n\n  constructor({ parsedData, rawData }) {\n    this.#map = parsedData;\n    this.#data = rawData;\n  }\n\n  getRaw() {\n    return this.#data;\n  }\n\n  get(name) {\n    return this.#map.get(name) ?? null;\n  }\n\n  [Symbol.iterator]() {\n    return this.#map.entries();\n  }\n}\n\nexport { Metadata };\n","/* Copyright 2020 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  info,\n  RenderingIntentFlag,\n  unreachable,\n  warn,\n} from \"../shared/util.js\";\nimport { MurmurHash3_64 } from \"../shared/murmurhash3.js\";\n\nconst INTERNAL = Symbol(\"INTERNAL\");\n\nclass OptionalContentGroup {\n  #isDisplay = false;\n\n  #isPrint = false;\n\n  #userSet = false;\n\n  #visible = true;\n\n  constructor(renderingIntent, { name, intent, usage, rbGroups }) {\n    this.#isDisplay = !!(renderingIntent & RenderingIntentFlag.DISPLAY);\n    this.#isPrint = !!(renderingIntent & RenderingIntentFlag.PRINT);\n\n    this.name = name;\n    this.intent = intent;\n    this.usage = usage;\n    this.rbGroups = rbGroups;\n  }\n\n  /**\n   * @type {boolean}\n   */\n  get visible() {\n    if (this.#userSet) {\n      return this.#visible;\n    }\n    if (!this.#visible) {\n      return false;\n    }\n    const { print, view } = this.usage;\n\n    if (this.#isDisplay) {\n      return view?.viewState !== \"OFF\";\n    } else if (this.#isPrint) {\n      return print?.printState !== \"OFF\";\n    }\n    return true;\n  }\n\n  /**\n   * @ignore\n   */\n  _setVisible(internal, visible, userSet = false) {\n    if (internal !== INTERNAL) {\n      unreachable(\"Internal method `_setVisible` called.\");\n    }\n    this.#userSet = userSet;\n    this.#visible = visible;\n  }\n}\n\nclass OptionalContentConfig {\n  #cachedGetHash = null;\n\n  #groups = new Map();\n\n  #initialHash = null;\n\n  #order = null;\n\n  constructor(data, renderingIntent = RenderingIntentFlag.DISPLAY) {\n    this.renderingIntent = renderingIntent;\n\n    this.name = null;\n    this.creator = null;\n\n    if (data === null) {\n      return;\n    }\n    this.name = data.name;\n    this.creator = data.creator;\n    this.#order = data.order;\n    for (const group of data.groups) {\n      this.#groups.set(\n        group.id,\n        new OptionalContentGroup(renderingIntent, group)\n      );\n    }\n\n    if (data.baseState === \"OFF\") {\n      for (const group of this.#groups.values()) {\n        group._setVisible(INTERNAL, false);\n      }\n    }\n\n    for (const on of data.on) {\n      this.#groups.get(on)._setVisible(INTERNAL, true);\n    }\n\n    for (const off of data.off) {\n      this.#groups.get(off)._setVisible(INTERNAL, false);\n    }\n\n    // The following code must always run *last* in the constructor.\n    this.#initialHash = this.getHash();\n  }\n\n  #evaluateVisibilityExpression(array) {\n    const length = array.length;\n    if (length < 2) {\n      return true;\n    }\n    const operator = array[0];\n    for (let i = 1; i < length; i++) {\n      const element = array[i];\n      let state;\n      if (Array.isArray(element)) {\n        state = this.#evaluateVisibilityExpression(element);\n      } else if (this.#groups.has(element)) {\n        state = this.#groups.get(element).visible;\n      } else {\n        warn(`Optional content group not found: ${element}`);\n        return true;\n      }\n      switch (operator) {\n        case \"And\":\n          if (!state) {\n            return false;\n          }\n          break;\n        case \"Or\":\n          if (state) {\n            return true;\n          }\n          break;\n        case \"Not\":\n          return !state;\n        default:\n          return true;\n      }\n    }\n    return operator === \"And\";\n  }\n\n  isVisible(group) {\n    if (this.#groups.size === 0) {\n      return true;\n    }\n    if (!group) {\n      info(\"Optional content group not defined.\");\n      return true;\n    }\n    if (group.type === \"OCG\") {\n      if (!this.#groups.has(group.id)) {\n        warn(`Optional content group not found: ${group.id}`);\n        return true;\n      }\n      return this.#groups.get(group.id).visible;\n    } else if (group.type === \"OCMD\") {\n      // Per the spec, the expression should be preferred if available.\n      if (group.expression) {\n        return this.#evaluateVisibilityExpression(group.expression);\n      }\n      if (!group.policy || group.policy === \"AnyOn\") {\n        // Default\n        for (const id of group.ids) {\n          if (!this.#groups.has(id)) {\n            warn(`Optional content group not found: ${id}`);\n            return true;\n          }\n          if (this.#groups.get(id).visible) {\n            return true;\n          }\n        }\n        return false;\n      } else if (group.policy === \"AllOn\") {\n        for (const id of group.ids) {\n          if (!this.#groups.has(id)) {\n            warn(`Optional content group not found: ${id}`);\n            return true;\n          }\n          if (!this.#groups.get(id).visible) {\n            return false;\n          }\n        }\n        return true;\n      } else if (group.policy === \"AnyOff\") {\n        for (const id of group.ids) {\n          if (!this.#groups.has(id)) {\n            warn(`Optional content group not found: ${id}`);\n            return true;\n          }\n          if (!this.#groups.get(id).visible) {\n            return true;\n          }\n        }\n        return false;\n      } else if (group.policy === \"AllOff\") {\n        for (const id of group.ids) {\n          if (!this.#groups.has(id)) {\n            warn(`Optional content group not found: ${id}`);\n            return true;\n          }\n          if (this.#groups.get(id).visible) {\n            return false;\n          }\n        }\n        return true;\n      }\n      warn(`Unknown optional content policy ${group.policy}.`);\n      return true;\n    }\n    warn(`Unknown group type ${group.type}.`);\n    return true;\n  }\n\n  setVisibility(id, visible = true, preserveRB = true) {\n    const group = this.#groups.get(id);\n    if (!group) {\n      warn(`Optional content group not found: ${id}`);\n      return;\n    }\n\n    // If the visibility is about to be set to `true` and the group belongs to\n    // any radiobutton groups, hide all other OCGs in these radiobutton groups,\n    // provided that radiobutton state relationships are to be preserved.\n    if (preserveRB && visible && group.rbGroups.length) {\n      for (const rbGroup of group.rbGroups) {\n        for (const otherId of rbGroup) {\n          if (otherId !== id) {\n            this.#groups.get(otherId)?._setVisible(INTERNAL, false, true);\n          }\n        }\n      }\n    }\n\n    group._setVisible(INTERNAL, !!visible, /* userSet = */ true);\n\n    this.#cachedGetHash = null;\n  }\n\n  setOCGState({ state, preserveRB }) {\n    let operator;\n\n    for (const elem of state) {\n      switch (elem) {\n        case \"ON\":\n        case \"OFF\":\n        case \"Toggle\":\n          operator = elem;\n          continue;\n      }\n\n      const group = this.#groups.get(elem);\n      if (!group) {\n        continue;\n      }\n      switch (operator) {\n        case \"ON\":\n          this.setVisibility(elem, true, preserveRB);\n          break;\n        case \"OFF\":\n          this.setVisibility(elem, false, preserveRB);\n          break;\n        case \"Toggle\":\n          this.setVisibility(elem, !group.visible, preserveRB);\n          break;\n      }\n    }\n\n    this.#cachedGetHash = null;\n  }\n\n  get hasInitialVisibility() {\n    return this.#initialHash === null || this.getHash() === this.#initialHash;\n  }\n\n  getOrder() {\n    if (!this.#groups.size) {\n      return null;\n    }\n    if (this.#order) {\n      return this.#order.slice();\n    }\n    return [...this.#groups.keys()];\n  }\n\n  getGroup(id) {\n    return this.#groups.get(id) || null;\n  }\n\n  getHash() {\n    if (this.#cachedGetHash !== null) {\n      return this.#cachedGetHash;\n    }\n    const hash = new MurmurHash3_64();\n\n    for (const [id, group] of this.#groups) {\n      hash.update(`${id}:${group.visible}`);\n    }\n    return (this.#cachedGetHash = hash.hexdigest());\n  }\n\n  [Symbol.iterator]() {\n    return this.#groups.entries();\n  }\n}\n\nexport { OptionalContentConfig };\n","/* Copyright 2018 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assert, unreachable } from \"./util.js\";\n\n/**\n * Interface that represents PDF data transport. If possible, it allows\n * progressively load entire or fragment of the PDF binary data.\n */\nclass BasePDFStream {\n  #PDFStreamReader = null;\n\n  #PDFStreamRangeReader = null;\n\n  _fullReader = null;\n\n  _rangeReaders = new Set();\n\n  _source = null;\n\n  constructor(source, PDFStreamReader, PDFStreamRangeReader) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BasePDFStream\n    ) {\n      unreachable(\"Cannot initialize BasePDFStream.\");\n    }\n    this._source = source;\n\n    this.#PDFStreamReader = PDFStreamReader;\n    this.#PDFStreamRangeReader = PDFStreamRangeReader;\n  }\n\n  get _progressiveDataLength() {\n    return this._fullReader?._loaded ?? 0;\n  }\n\n  /**\n   * Gets a reader for the entire PDF data.\n   * @returns {BasePDFStreamReader}\n   */\n  getFullReader() {\n    assert(\n      !this._fullReader,\n      \"BasePDFStream.getFullReader can only be called once.\"\n    );\n    return (this._fullReader = new this.#PDFStreamReader(this));\n  }\n\n  /**\n   * Gets a reader for the range of the PDF data.\n   *\n   * NOTE: Currently this method is only expected to be invoked *after*\n   * the `BasePDFStreamReader.prototype.headersReady` promise has resolved.\n   *\n   * @param {number} begin - the start offset of the data.\n   * @param {number} end - the end offset of the data.\n   * @returns {BasePDFStreamRangeReader}\n   */\n  getRangeReader(begin, end) {\n    if (end <= this._progressiveDataLength) {\n      return null;\n    }\n    const reader = new this.#PDFStreamRangeReader(this, begin, end);\n    this._rangeReaders.add(reader);\n    return reader;\n  }\n\n  /**\n   * Cancels all opened reader and closes all their opened requests.\n   * @param {Object} reason - the reason for cancelling\n   */\n  cancelAllRequests(reason) {\n    this._fullReader?.cancel(reason);\n\n    // Always create a copy of the rangeReaders.\n    for (const reader of new Set(this._rangeReaders)) {\n      reader.cancel(reason);\n    }\n  }\n}\n\n/**\n * Interface for a PDF binary data reader.\n */\nclass BasePDFStreamReader {\n  /**\n   * Sets or gets the progress callback. The callback can be useful when the\n   * isStreamingSupported property of the object is defined as false.\n   * The callback is called with one parameter: an object with the loaded and\n   * total properties.\n   */\n  onProgress = null;\n\n  _contentLength = 0;\n\n  _filename = null;\n\n  _headersCapability = Promise.withResolvers();\n\n  _isRangeSupported = false;\n\n  _isStreamingSupported = false;\n\n  _loaded = 0;\n\n  _stream = null;\n\n  constructor(stream) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BasePDFStreamReader\n    ) {\n      unreachable(\"Cannot initialize BasePDFStreamReader.\");\n    }\n    this._stream = stream;\n  }\n\n  _callOnProgress() {\n    this.onProgress?.({ loaded: this._loaded, total: this._contentLength });\n  }\n\n  /**\n   * Gets a promise that is resolved when the headers and other metadata of\n   * the PDF data stream are available.\n   * @type {Promise}\n   */\n  get headersReady() {\n    return this._headersCapability.promise;\n  }\n\n  /**\n   * Gets the Content-Disposition filename. It is defined after the headersReady\n   * promise is resolved.\n   * @type {string|null} The filename, or `null` if the Content-Disposition\n   *                     header is missing/invalid.\n   */\n  get filename() {\n    return this._filename;\n  }\n\n  /**\n   * Gets PDF binary data length. It is defined after the headersReady promise\n   * is resolved.\n   * @type {number} The data length (or 0 if unknown).\n   */\n  get contentLength() {\n    return this._contentLength;\n  }\n\n  /**\n   * Gets ability of the stream to handle range requests. It is defined after\n   * the headersReady promise is resolved. Rejected when the reader is cancelled\n   * or an error occurs.\n   * @type {boolean}\n   */\n  get isRangeSupported() {\n    return this._isRangeSupported;\n  }\n\n  /**\n   * Gets ability of the stream to progressively load binary data. It is defined\n   * after the headersReady promise is resolved.\n   * @type {boolean}\n   */\n  get isStreamingSupported() {\n    return this._isStreamingSupported;\n  }\n\n  /**\n   * Requests a chunk of the binary data. The method returns the promise, which\n   * is resolved into object with properties \"value\" and \"done\". If the done\n   * is set to true, then the stream has reached its end, otherwise the value\n   * contains binary data. Cancelled requests will be resolved with the done is\n   * set to true.\n   * @returns {Promise}\n   */\n  async read() {\n    unreachable(\"Abstract method `read` called\");\n  }\n\n  /**\n   * Cancels all pending read requests and closes the stream.\n   * @param {Object} reason\n   */\n  cancel(reason) {\n    unreachable(\"Abstract method `cancel` called\");\n  }\n}\n\n/**\n * Interface for a PDF binary data fragment reader.\n */\nclass BasePDFStreamRangeReader {\n  _stream = null;\n\n  constructor(stream, begin, end) {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BasePDFStreamRangeReader\n    ) {\n      unreachable(\"Cannot initialize BasePDFStreamRangeReader.\");\n    }\n    this._stream = stream;\n  }\n\n  /**\n   * Requests a chunk of the binary data. The method returns the promise, which\n   * is resolved into object with properties \"value\" and \"done\". If the done\n   * is set to true, then the stream has reached its end, otherwise the value\n   * contains binary data. Cancelled requests will be resolved with the done is\n   * set to true.\n   * @returns {Promise}\n   */\n  async read() {\n    unreachable(\"Abstract method `read` called\");\n  }\n\n  /**\n   * Cancels all pending read requests and closes the stream.\n   * @param {Object} reason\n   */\n  cancel(reason) {\n    unreachable(\"Abstract method `cancel` called\");\n  }\n}\n\nexport { BasePDFStream, BasePDFStreamRangeReader, BasePDFStreamReader };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  BasePDFStream,\n  BasePDFStreamRangeReader,\n  BasePDFStreamReader,\n} from \"../shared/base_pdf_stream.js\";\nimport { assert } from \"../shared/util.js\";\nimport { isPdfFile } from \"./display_utils.js\";\n\nfunction getArrayBuffer(val) {\n  // Prevent any possible issues by only transferring a Uint8Array that\n  // completely \"utilizes\" its underlying ArrayBuffer.\n  return val instanceof Uint8Array && val.byteLength === val.buffer.byteLength\n    ? val.buffer\n    : new Uint8Array(val).buffer;\n}\n\nfunction endRequests() {\n  for (const capability of this._requests) {\n    capability.resolve({ value: undefined, done: true });\n  }\n  this._requests.length = 0;\n}\n\nclass PDFDataTransportStream extends BasePDFStream {\n  _progressiveDone = false;\n\n  _queuedChunks = [];\n\n  constructor(source) {\n    super(\n      source,\n      PDFDataTransportStreamReader,\n      PDFDataTransportStreamRangeReader\n    );\n    const { pdfDataRangeTransport } = source;\n    const { initialData, progressiveDone } = pdfDataRangeTransport;\n\n    if (initialData?.length > 0) {\n      const buffer = getArrayBuffer(initialData);\n      this._queuedChunks.push(buffer);\n    }\n    this._progressiveDone = progressiveDone;\n\n    pdfDataRangeTransport.addRangeListener((begin, chunk) => {\n      this.#onReceiveData(begin, chunk);\n    });\n\n    pdfDataRangeTransport.addProgressiveReadListener(chunk => {\n      this.#onReceiveData(/* begin = */ undefined, chunk);\n    });\n\n    pdfDataRangeTransport.addProgressiveDoneListener(() => {\n      this._fullReader?.progressiveDone();\n      this._progressiveDone = true;\n    });\n\n    pdfDataRangeTransport.transportReady();\n  }\n\n  #onReceiveData(begin, chunk) {\n    const buffer = getArrayBuffer(chunk);\n\n    if (begin === undefined) {\n      if (this._fullReader) {\n        this._fullReader._enqueue(buffer);\n      } else {\n        this._queuedChunks.push(buffer);\n      }\n    } else {\n      const rangeReader = this._rangeReaders\n        .keys()\n        .find(r => r._begin === begin);\n\n      assert(\n        rangeReader,\n        \"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.\"\n      );\n      rangeReader._enqueue(buffer);\n    }\n  }\n\n  getFullReader() {\n    const reader = super.getFullReader();\n    this._queuedChunks = null;\n    return reader;\n  }\n\n  getRangeReader(begin, end) {\n    const reader = super.getRangeReader(begin, end);\n\n    if (reader) {\n      reader.onDone = () => this._rangeReaders.delete(reader);\n\n      this._source.pdfDataRangeTransport.requestDataRange(begin, end);\n    }\n    return reader;\n  }\n\n  cancelAllRequests(reason) {\n    super.cancelAllRequests(reason);\n\n    this._source.pdfDataRangeTransport.abort();\n  }\n}\n\nclass PDFDataTransportStreamReader extends BasePDFStreamReader {\n  #endRequests = endRequests.bind(this);\n\n  _done = false;\n\n  _queuedChunks = null;\n\n  _requests = [];\n\n  constructor(stream) {\n    super(stream);\n    const { pdfDataRangeTransport, disableRange, disableStream } =\n      stream._source;\n    const { length, contentDispositionFilename } = pdfDataRangeTransport;\n\n    this._queuedChunks = stream._queuedChunks || [];\n    for (const chunk of this._queuedChunks) {\n      this._loaded += chunk.byteLength;\n    }\n    this._done = stream._progressiveDone;\n\n    this._contentLength = length;\n    this._isStreamingSupported = !disableStream;\n    this._isRangeSupported = !disableRange;\n\n    if (isPdfFile(contentDispositionFilename)) {\n      this._filename = contentDispositionFilename;\n    }\n    this._headersCapability.resolve();\n\n    // Report loading progress when there is `initialData`, and `_enqueue` has\n    // not been invoked, but with a small delay to give an `onProgress` callback\n    // a chance to be registered first.\n    const loaded = this._loaded;\n    Promise.resolve().then(() => {\n      if (loaded > 0 && this._loaded === loaded) {\n        this._callOnProgress();\n      }\n    });\n  }\n\n  _enqueue(chunk) {\n    if (this._done) {\n      return; // Ignore new data.\n    }\n    if (this._requests.length > 0) {\n      const capability = this._requests.shift();\n      capability.resolve({ value: chunk, done: false });\n    } else {\n      this._queuedChunks.push(chunk);\n    }\n    this._loaded += chunk.byteLength;\n    this._callOnProgress();\n  }\n\n  async read() {\n    if (this._queuedChunks.length > 0) {\n      const chunk = this._queuedChunks.shift();\n      return { value: chunk, done: false };\n    }\n    if (this._done) {\n      return { value: undefined, done: true };\n    }\n    const capability = Promise.withResolvers();\n    this._requests.push(capability);\n    return capability.promise;\n  }\n\n  cancel(reason) {\n    this._done = true;\n    this.#endRequests();\n  }\n\n  progressiveDone() {\n    this._done ||= true;\n\n    if (this._queuedChunks.length === 0) {\n      this.#endRequests();\n    }\n  }\n}\n\nclass PDFDataTransportStreamRangeReader extends BasePDFStreamRangeReader {\n  #endRequests = endRequests.bind(this);\n\n  onDone = null;\n\n  _begin = -1;\n\n  _done = false;\n\n  _queuedChunk = null;\n\n  _requests = [];\n\n  constructor(stream, begin, end) {\n    super(stream, begin, end);\n    this._begin = begin;\n  }\n\n  _enqueue(chunk) {\n    if (this._done) {\n      return; // ignore new data\n    }\n    if (this._requests.length === 0) {\n      this._queuedChunk = chunk;\n    } else {\n      const capability = this._requests.shift();\n      capability.resolve({ value: chunk, done: false });\n\n      this.#endRequests();\n    }\n    this._done = true;\n    this.onDone?.();\n  }\n\n  async read() {\n    if (this._queuedChunk) {\n      const chunk = this._queuedChunk;\n      this._queuedChunk = null;\n      return { value: chunk, done: false };\n    }\n    if (this._done) {\n      return { value: undefined, done: true };\n    }\n    const capability = Promise.withResolvers();\n    this._requests.push(capability);\n    return capability.promise;\n  }\n\n  cancel(reason) {\n    this._done = true;\n    this.#endRequests();\n    this.onDone?.();\n  }\n}\n\nexport { endRequests, PDFDataTransportStream };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assert, ResponseException } from \"../shared/util.js\";\nimport { getFilenameFromContentDispositionHeader } from \"./content_disposition.js\";\nimport { isPdfFile } from \"./display_utils.js\";\n\nfunction createHeaders(isHttp, httpHeaders) {\n  const headers = new Headers();\n\n  if (!isHttp || !httpHeaders || typeof httpHeaders !== \"object\") {\n    return headers;\n  }\n  for (const key in httpHeaders) {\n    const val = httpHeaders[key];\n    if (val !== undefined) {\n      headers.append(key, val);\n    }\n  }\n  return headers;\n}\n\nfunction getResponseOrigin(url) {\n  // Notably, null is distinct from \"null\" string (e.g. from file:-URLs).\n  return URL.parse(url)?.origin ?? null;\n}\n\nfunction validateRangeRequestCapabilities({\n  responseHeaders,\n  isHttp,\n  rangeChunkSize,\n  disableRange,\n}) {\n  if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n    assert(\n      Number.isInteger(rangeChunkSize) && rangeChunkSize > 0,\n      \"rangeChunkSize must be an integer larger than zero.\"\n    );\n  }\n  const returnValues = {\n    allowRangeRequests: false,\n    suggestedLength: undefined,\n  };\n\n  const length = parseInt(responseHeaders.get(\"Content-Length\"), 10);\n  if (!Number.isInteger(length)) {\n    return returnValues;\n  }\n\n  returnValues.suggestedLength = length;\n\n  if (length <= 2 * rangeChunkSize) {\n    // The file size is smaller than the size of two chunks, so it does not\n    // make any sense to abort the request and retry with a range request.\n    return returnValues;\n  }\n\n  if (disableRange || !isHttp) {\n    return returnValues;\n  }\n  if (responseHeaders.get(\"Accept-Ranges\") !== \"bytes\") {\n    return returnValues;\n  }\n\n  const contentEncoding = responseHeaders.get(\"Content-Encoding\") || \"identity\";\n  if (contentEncoding !== \"identity\") {\n    return returnValues;\n  }\n\n  returnValues.allowRangeRequests = true;\n  return returnValues;\n}\n\nfunction extractFilenameFromHeader(responseHeaders) {\n  const contentDisposition = responseHeaders.get(\"Content-Disposition\");\n  if (contentDisposition) {\n    let filename = getFilenameFromContentDispositionHeader(contentDisposition);\n    if (filename.includes(\"%\")) {\n      try {\n        filename = decodeURIComponent(filename);\n      } catch {}\n    }\n    if (isPdfFile(filename)) {\n      return filename;\n    }\n  }\n  return null;\n}\n\nfunction createResponseError(status, url) {\n  return new ResponseException(\n    `Unexpected server response (${status}) while retrieving PDF \"${url.href}\".`,\n    status,\n    /* missing = */ status === 404 || (status === 0 && url.protocol === \"file:\")\n  );\n}\n\nfunction ensureResponseOrigin(rangeOrigin, origin) {\n  if (rangeOrigin !== origin) {\n    throw new Error(\n      `Expected range response-origin \"${rangeOrigin}\" to match \"${origin}\".`\n    );\n  }\n}\n\nexport {\n  createHeaders,\n  createResponseError,\n  ensureResponseOrigin,\n  extractFilenameFromHeader,\n  getResponseOrigin,\n  validateRangeRequestCapabilities,\n};\n","/* Copyright 2017 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { stringToBytes } from \"../shared/util.js\";\n\n// This getFilenameFromContentDispositionHeader function is adapted from\n// https://github.com/Rob--W/open-in-browser/blob/7e2e35a38b8b4e981b11da7b2f01df0149049e92/extension/content-disposition.js\n// with the following changes:\n// - Modified to conform to PDF.js's coding style.\n// - Move return to the end of the function to prevent Babel from dropping the\n//   function declarations.\n\n/**\n * Extract file name from the Content-Disposition HTTP response header.\n *\n * @param {string} contentDisposition\n * @returns {string} Filename, if found in the Content-Disposition header.\n */\nfunction getFilenameFromContentDispositionHeader(contentDisposition) {\n  let needsEncodingFixup = true;\n\n  // filename*=ext-value (\"ext-value\" from RFC 5987, referenced by RFC 6266).\n  let tmp = toParamRegExp(\"filename\\\\*\", \"i\").exec(contentDisposition);\n  if (tmp) {\n    tmp = tmp[1];\n    let filename = rfc2616unquote(tmp);\n    filename = unescape(filename);\n    filename = rfc5987decode(filename);\n    filename = rfc2047decode(filename);\n    return fixupEncoding(filename);\n  }\n\n  // Continuations (RFC 2231 section 3, referenced by RFC 5987 section 3.1).\n  // filename*n*=part\n  // filename*n=part\n  tmp = rfc2231getparam(contentDisposition);\n  if (tmp) {\n    // RFC 2047, section\n    const filename = rfc2047decode(tmp);\n    return fixupEncoding(filename);\n  }\n\n  // filename=value (RFC 5987, section 4.1).\n  tmp = toParamRegExp(\"filename\", \"i\").exec(contentDisposition);\n  if (tmp) {\n    tmp = tmp[1];\n    let filename = rfc2616unquote(tmp);\n    filename = rfc2047decode(filename);\n    return fixupEncoding(filename);\n  }\n\n  // After this line there are only function declarations. We cannot put\n  // \"return\" here for readability because babel would then drop the function\n  // declarations...\n  function toParamRegExp(attributePattern, flags) {\n    return new RegExp(\n      \"(?:^|;)\\\\s*\" +\n        attributePattern +\n        \"\\\\s*=\\\\s*\" +\n        // Captures: value = token | quoted-string\n        // (RFC 2616, section 3.6 and referenced by RFC 6266 4.1)\n        \"(\" +\n        '[^\";\\\\s][^;\\\\s]*' +\n        \"|\" +\n        '\"(?:[^\"\\\\\\\\]|\\\\\\\\\"?)+\"?' +\n        \")\",\n      flags\n    );\n  }\n  function textdecode(encoding, value) {\n    if (encoding) {\n      if (!/^[\\x00-\\xFF]+$/.test(value)) {\n        return value;\n      }\n      try {\n        const decoder = new TextDecoder(encoding, { fatal: true });\n        const buffer = stringToBytes(value);\n        value = decoder.decode(buffer);\n        needsEncodingFixup = false;\n      } catch {\n        // TextDecoder constructor threw - unrecognized encoding.\n      }\n    }\n    return value;\n  }\n  function fixupEncoding(value) {\n    if (needsEncodingFixup && /[\\x80-\\xff]/.test(value)) {\n      // Maybe multi-byte UTF-8.\n      value = textdecode(\"utf-8\", value);\n      if (needsEncodingFixup) {\n        // Try iso-8859-1 encoding.\n        value = textdecode(\"iso-8859-1\", value);\n      }\n    }\n    return value;\n  }\n  function rfc2231getparam(contentDispositionStr) {\n    const matches = [];\n    let match;\n    // Iterate over all filename*n= and filename*n*= with n being an integer\n    // of at least zero. Any non-zero number must not start with '0'.\n    const iter = toParamRegExp(\"filename\\\\*((?!0\\\\d)\\\\d+)(\\\\*?)\", \"ig\");\n    while ((match = iter.exec(contentDispositionStr)) !== null) {\n      let [, n, quot, part] = match; // eslint-disable-line prefer-const\n      n = parseInt(n, 10);\n      if (n in matches) {\n        // Ignore anything after the invalid second filename*0.\n        if (n === 0) {\n          break;\n        }\n        continue;\n      }\n      matches[n] = [quot, part];\n    }\n    const parts = [];\n    for (let n = 0; n < matches.length; ++n) {\n      if (!(n in matches)) {\n        // Numbers must be consecutive. Truncate when there is a hole.\n        break;\n      }\n      let [quot, part] = matches[n]; // eslint-disable-line prefer-const\n      part = rfc2616unquote(part);\n      if (quot) {\n        part = unescape(part);\n        if (n === 0) {\n          part = rfc5987decode(part);\n        }\n      }\n      parts.push(part);\n    }\n    return parts.join(\"\");\n  }\n  function rfc2616unquote(value) {\n    if (value.startsWith('\"')) {\n      const parts = value.slice(1).split('\\\\\"');\n      // Find the first unescaped \" and terminate there.\n      for (let i = 0; i < parts.length; ++i) {\n        const quotindex = parts[i].indexOf('\"');\n        if (quotindex !== -1) {\n          parts[i] = parts[i].slice(0, quotindex);\n          parts.length = i + 1; // Truncates and stop the iteration.\n        }\n        parts[i] = parts[i].replaceAll(/\\\\(.)/g, \"$1\");\n      }\n      value = parts.join('\"');\n    }\n    return value;\n  }\n  function rfc5987decode(extvalue) {\n    // Decodes \"ext-value\" from RFC 5987.\n    const encodingend = extvalue.indexOf(\"'\");\n    if (encodingend === -1) {\n      // Some servers send \"filename*=\" without encoding 'language' prefix,\n      // e.g. in https://github.com/Rob--W/open-in-browser/issues/26\n      // Let's accept the value like Firefox (57) (Chrome 62 rejects it).\n      return extvalue;\n    }\n    const encoding = extvalue.slice(0, encodingend);\n    const langvalue = extvalue.slice(encodingend + 1);\n    // Ignore language (RFC 5987 section 3.2.1, and RFC 6266 section 4.1 ).\n    const value = langvalue.replace(/^[^']*'/, \"\");\n    return textdecode(encoding, value);\n  }\n  function rfc2047decode(value) {\n    // RFC 2047-decode the result. Firefox tried to drop support for it, but\n    // backed out because some servers use it - https://bugzil.la/875615\n    // Firefox's condition for decoding is here: https://searchfox.org/mozilla-central/rev/4a590a5a15e35d88a3b23dd6ac3c471cf85b04a8/netwerk/mime/nsMIMEHeaderParamImpl.cpp#742-748\n\n    // We are more strict and only recognize RFC 2047-encoding if the value\n    // starts with \"=?\", since then it is likely that the full value is\n    // RFC 2047-encoded.\n\n    // Firefox also decodes words even where RFC 2047 section 5 states:\n    // \"An 'encoded-word' MUST NOT appear within a 'quoted-string'.\"\n    if (!value.startsWith(\"=?\") || /[\\x00-\\x19\\x80-\\xff]/.test(value)) {\n      return value;\n    }\n    // RFC 2047, section 2.4\n    // encoded-word = \"=?\" charset \"?\" encoding \"?\" encoded-text \"?=\"\n    // charset = token (but let's restrict to characters that denote a\n    //       possibly valid encoding).\n    // encoding = q or b\n    // encoded-text = any printable ASCII character other than ? or space.\n    //        ... but Firefox permits ? and space.\n    return value.replaceAll(\n      /=\\?([\\w-]*)\\?([QqBb])\\?((?:[^?]|\\?(?!=))*)\\?=/g,\n      function (matches, charset, encoding, text) {\n        if (encoding === \"q\" || encoding === \"Q\") {\n          // RFC 2047 section 4.2.\n          text = text.replaceAll(\"_\", \" \");\n          text = text.replaceAll(/=([0-9a-fA-F]{2})/g, function (match, hex) {\n            return String.fromCharCode(parseInt(hex, 16));\n          });\n          return textdecode(charset, text);\n        } // else encoding is b or B - base64 (RFC 2047 section 4.1)\n        try {\n          text = atob(text);\n        } catch {}\n        return textdecode(charset, text);\n      }\n    );\n  }\n\n  return \"\";\n}\n\nexport { getFilenameFromContentDispositionHeader };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AbortException, assert } from \"../shared/util.js\";\nimport {\n  BasePDFStream,\n  BasePDFStreamRangeReader,\n  BasePDFStreamReader,\n} from \"../shared/base_pdf_stream.js\";\nimport {\n  createHeaders,\n  createResponseError,\n  ensureResponseOrigin,\n  extractFilenameFromHeader,\n  getResponseOrigin,\n  validateRangeRequestCapabilities,\n} from \"./network_utils.js\";\n\nif (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n  throw new Error(\n    'Module \"./fetch_stream.js\" shall not be used with MOZCENTRAL builds.'\n  );\n}\n\nfunction fetchUrl(url, headers, withCredentials, abortController) {\n  return fetch(url, {\n    method: \"GET\",\n    headers,\n    signal: abortController.signal,\n    mode: \"cors\",\n    credentials: withCredentials ? \"include\" : \"same-origin\",\n    redirect: \"follow\",\n  });\n}\n\nfunction ensureResponseStatus(status, url) {\n  if (status !== 200 && status !== 206) {\n    throw createResponseError(status, url);\n  }\n}\n\nfunction getArrayBuffer(val) {\n  if (val instanceof Uint8Array) {\n    return val.buffer;\n  }\n  if (val instanceof ArrayBuffer) {\n    return val;\n  }\n  throw new Error(`getArrayBuffer - unexpected data: ${val}`);\n}\n\nclass PDFFetchStream extends BasePDFStream {\n  _responseOrigin = null;\n\n  constructor(source) {\n    super(source, PDFFetchStreamReader, PDFFetchStreamRangeReader);\n    const { httpHeaders, url } = source;\n\n    assert(\n      /https?:/.test(url.protocol),\n      \"PDFFetchStream only supports http(s):// URLs.\"\n    );\n    this.headers = createHeaders(/* isHttp = */ true, httpHeaders);\n  }\n}\n\nclass PDFFetchStreamReader extends BasePDFStreamReader {\n  _abortController = new AbortController();\n\n  _reader = null;\n\n  constructor(stream) {\n    super(stream);\n    const {\n      disableRange,\n      disableStream,\n      length,\n      rangeChunkSize,\n      url,\n      withCredentials,\n    } = stream._source;\n\n    this._contentLength = length;\n    this._isStreamingSupported = !disableStream;\n    this._isRangeSupported = !disableRange;\n    // Always create a copy of the headers.\n    const headers = new Headers(stream.headers);\n\n    fetchUrl(url, headers, withCredentials, this._abortController)\n      .then(response => {\n        stream._responseOrigin = getResponseOrigin(response.url);\n\n        ensureResponseStatus(response.status, url);\n        this._reader = response.body.getReader();\n\n        const responseHeaders = response.headers;\n\n        const { allowRangeRequests, suggestedLength } =\n          validateRangeRequestCapabilities({\n            responseHeaders,\n            isHttp: true,\n            rangeChunkSize,\n            disableRange,\n          });\n\n        this._isRangeSupported = allowRangeRequests;\n        // Setting right content length.\n        this._contentLength = suggestedLength || this._contentLength;\n\n        this._filename = extractFilenameFromHeader(responseHeaders);\n\n        // We need to stop reading when range is supported and streaming is\n        // disabled.\n        if (!this._isStreamingSupported && this._isRangeSupported) {\n          this.cancel(new AbortException(\"Streaming is disabled.\"));\n        }\n\n        this._headersCapability.resolve();\n      })\n      .catch(this._headersCapability.reject);\n  }\n\n  async read() {\n    await this._headersCapability.promise;\n    const { value, done } = await this._reader.read();\n    if (done) {\n      return { value, done };\n    }\n    this._loaded += value.byteLength;\n    this._callOnProgress();\n\n    return { value: getArrayBuffer(value), done: false };\n  }\n\n  cancel(reason) {\n    this._reader?.cancel(reason);\n    this._abortController.abort();\n  }\n}\n\nclass PDFFetchStreamRangeReader extends BasePDFStreamRangeReader {\n  _abortController = new AbortController();\n\n  _readCapability = Promise.withResolvers();\n\n  _reader = null;\n\n  constructor(stream, begin, end) {\n    super(stream, begin, end);\n    const { url, withCredentials } = stream._source;\n\n    // Always create a copy of the headers.\n    const headers = new Headers(stream.headers);\n    headers.append(\"Range\", `bytes=${begin}-${end - 1}`);\n\n    fetchUrl(url, headers, withCredentials, this._abortController)\n      .then(response => {\n        const responseOrigin = getResponseOrigin(response.url);\n\n        ensureResponseOrigin(responseOrigin, stream._responseOrigin);\n        ensureResponseStatus(response.status, url);\n        this._reader = response.body.getReader();\n\n        this._readCapability.resolve();\n      })\n      .catch(this._readCapability.reject);\n  }\n\n  async read() {\n    await this._readCapability.promise;\n    const { value, done } = await this._reader.read();\n    if (done) {\n      return { value, done };\n    }\n    return { value: getArrayBuffer(value), done: false };\n  }\n\n  cancel(reason) {\n    this._reader?.cancel(reason);\n    this._abortController.abort();\n  }\n}\n\nexport { getArrayBuffer, PDFFetchStream };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { assert, stringToBytes, warn } from \"../shared/util.js\";\nimport {\n  BasePDFStream,\n  BasePDFStreamRangeReader,\n  BasePDFStreamReader,\n} from \"../shared/base_pdf_stream.js\";\nimport {\n  createHeaders,\n  createResponseError,\n  ensureResponseOrigin,\n  extractFilenameFromHeader,\n  getResponseOrigin,\n  validateRangeRequestCapabilities,\n} from \"./network_utils.js\";\nimport { endRequests } from \"./transport_stream.js\";\n\nif (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n  throw new Error(\n    'Module \"./network.js\" shall not be used with MOZCENTRAL builds.'\n  );\n}\n\nconst OK_RESPONSE = 200;\nconst PARTIAL_CONTENT_RESPONSE = 206;\n\nfunction getArrayBuffer(val) {\n  return typeof val !== \"string\" ? val : stringToBytes(val).buffer;\n}\n\nclass PDFNetworkStream extends BasePDFStream {\n  #pendingRequests = new WeakMap();\n\n  _responseOrigin = null;\n\n  constructor(source) {\n    super(source, PDFNetworkStreamReader, PDFNetworkStreamRangeReader);\n    const { httpHeaders, url } = source;\n\n    this.url = url;\n    this.isHttp = /https?:/.test(url.protocol);\n    this.headers = createHeaders(this.isHttp, httpHeaders);\n  }\n\n  /**\n   * @ignore\n   */\n  _request(args) {\n    const xhr = new XMLHttpRequest();\n    const pendingRequest = {\n      validateStatus: null,\n      onHeadersReceived: args.onHeadersReceived,\n      onDone: args.onDone,\n      onError: args.onError,\n      onProgress: args.onProgress,\n    };\n    this.#pendingRequests.set(xhr, pendingRequest);\n\n    xhr.open(\"GET\", this.url);\n    xhr.withCredentials = this._source.withCredentials;\n    for (const [key, val] of this.headers) {\n      xhr.setRequestHeader(key, val);\n    }\n    if (this.isHttp && \"begin\" in args && \"end\" in args) {\n      xhr.setRequestHeader(\"Range\", `bytes=${args.begin}-${args.end - 1}`);\n\n      // From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2:\n      // \"A server MAY ignore the Range header\". This means it's possible to\n      // get a 200 rather than a 206 response from a range request.\n      pendingRequest.validateStatus = status =>\n        status === PARTIAL_CONTENT_RESPONSE || status === OK_RESPONSE;\n    } else {\n      pendingRequest.validateStatus = status => status === OK_RESPONSE;\n    }\n    xhr.responseType = \"arraybuffer\";\n\n    assert(args.onError, \"Expected `onError` callback to be provided.\");\n    xhr.onerror = () => args.onError(xhr.status);\n    xhr.onreadystatechange = this.#onStateChange.bind(this, xhr);\n    xhr.onprogress = this.#onProgress.bind(this, xhr);\n\n    xhr.send(null);\n\n    return xhr;\n  }\n\n  #onProgress(xhr, evt) {\n    const pendingRequest = this.#pendingRequests.get(xhr);\n    pendingRequest?.onProgress?.(evt);\n  }\n\n  #onStateChange(xhr, evt) {\n    const pendingRequest = this.#pendingRequests.get(xhr);\n    if (!pendingRequest) {\n      return; // Maybe abortRequest was called...\n    }\n\n    if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {\n      pendingRequest.onHeadersReceived();\n      delete pendingRequest.onHeadersReceived;\n    }\n\n    if (xhr.readyState !== 4) {\n      return;\n    }\n\n    if (!this.#pendingRequests.has(xhr)) {\n      // The XHR request might have been aborted in onHeadersReceived()\n      // callback, in which case we should abort request.\n      return;\n    }\n    this.#pendingRequests.delete(xhr);\n\n    // Success status == 0 can be on ftp, file and other protocols.\n    if (xhr.status === 0 && this.isHttp) {\n      pendingRequest.onError(xhr.status);\n      return;\n    }\n    const xhrStatus = xhr.status || OK_RESPONSE;\n\n    if (!pendingRequest.validateStatus(xhrStatus)) {\n      pendingRequest.onError(xhr.status);\n      return;\n    }\n\n    const chunk = getArrayBuffer(xhr.response);\n    if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {\n      const rangeHeader = xhr.getResponseHeader(\"Content-Range\");\n      if (/bytes (\\d+)-(\\d+)\\/(\\d+)/.test(rangeHeader)) {\n        pendingRequest.onDone(chunk);\n      } else {\n        warn(`Missing or invalid \"Content-Range\" header.`);\n        pendingRequest.onError(0);\n      }\n    } else if (chunk) {\n      pendingRequest.onDone(chunk);\n    } else {\n      pendingRequest.onError(xhr.status);\n    }\n  }\n\n  /**\n   * Abort the request, if it's pending.\n   * @ignore\n   */\n  _abortRequest(xhr) {\n    if (this.#pendingRequests.has(xhr)) {\n      this.#pendingRequests.delete(xhr);\n      xhr.abort();\n    }\n  }\n\n  getRangeReader(begin, end) {\n    const reader = super.getRangeReader(begin, end);\n\n    if (reader) {\n      reader.onClosed = () => this._rangeReaders.delete(reader);\n    }\n    return reader;\n  }\n}\n\nclass PDFNetworkStreamReader extends BasePDFStreamReader {\n  #endRequests = endRequests.bind(this);\n\n  _cachedChunks = [];\n\n  _done = false;\n\n  _requests = [];\n\n  _storedError = null;\n\n  constructor(stream) {\n    super(stream);\n    const { length } = stream._source;\n\n    this._contentLength = length;\n    // Note that `XMLHttpRequest` doesn't support streaming, and range requests\n    // will be enabled (if supported) in `this.#onHeadersReceived` below.\n\n    this._fullRequestXhr = stream._request({\n      onHeadersReceived: this.#onHeadersReceived.bind(this),\n      onDone: this.#onDone.bind(this),\n      onError: this.#onError.bind(this),\n      onProgress: this.#onProgress.bind(this),\n    });\n  }\n\n  #onHeadersReceived() {\n    const stream = this._stream;\n    const { disableRange, rangeChunkSize } = stream._source;\n    const fullRequestXhr = this._fullRequestXhr;\n\n    stream._responseOrigin = getResponseOrigin(fullRequestXhr.responseURL);\n\n    const rawResponseHeaders = fullRequestXhr.getAllResponseHeaders();\n    const responseHeaders = new Headers(\n      rawResponseHeaders\n        ? rawResponseHeaders\n            .trimStart()\n            .replace(/[^\\S ]+$/, \"\") // Not `trimEnd`, to keep regular spaces.\n            .split(/[\\r\\n]+/)\n            .map(x => {\n              const [key, ...val] = x.split(\": \");\n              return [key, val.join(\": \")];\n            })\n        : []\n    );\n\n    const { allowRangeRequests, suggestedLength } =\n      validateRangeRequestCapabilities({\n        responseHeaders,\n        isHttp: stream.isHttp,\n        rangeChunkSize,\n        disableRange,\n      });\n\n    if (allowRangeRequests) {\n      this._isRangeSupported = true;\n    }\n    // Setting right content length.\n    this._contentLength = suggestedLength || this._contentLength;\n\n    this._filename = extractFilenameFromHeader(responseHeaders);\n\n    if (this._isRangeSupported) {\n      // NOTE: by cancelling the full request, and then issuing range\n      // requests, there will be an issue for sites where you can only\n      // request the pdf once. However, if this is the case, then the\n      // server should not be returning that it can support range requests.\n      stream._abortRequest(fullRequestXhr);\n    }\n\n    this._headersCapability.resolve();\n  }\n\n  #onDone(chunk) {\n    if (this._requests.length > 0) {\n      const capability = this._requests.shift();\n      capability.resolve({ value: chunk, done: false });\n    } else {\n      this._cachedChunks.push(chunk);\n    }\n    this._done = true;\n    if (this._cachedChunks.length === 0) {\n      this.#endRequests();\n    }\n  }\n\n  #onError(status) {\n    this._storedError = createResponseError(status, this._stream.url);\n    this._headersCapability.reject(this._storedError);\n    for (const capability of this._requests) {\n      capability.reject(this._storedError);\n    }\n    this._requests.length = 0;\n    this._cachedChunks.length = 0;\n  }\n\n  #onProgress(evt) {\n    this.onProgress?.({\n      loaded: evt.loaded,\n      total: evt.lengthComputable ? evt.total : this._contentLength,\n    });\n  }\n\n  async read() {\n    await this._headersCapability.promise;\n\n    if (this._storedError) {\n      throw this._storedError;\n    }\n    if (this._cachedChunks.length > 0) {\n      const chunk = this._cachedChunks.shift();\n      return { value: chunk, done: false };\n    }\n    if (this._done) {\n      return { value: undefined, done: true };\n    }\n    const capability = Promise.withResolvers();\n    this._requests.push(capability);\n    return capability.promise;\n  }\n\n  cancel(reason) {\n    this._done = true;\n    this._headersCapability.reject(reason);\n    this.#endRequests();\n\n    this._stream._abortRequest(this._fullRequestXhr);\n    this._fullRequestXhr = null;\n  }\n}\n\nclass PDFNetworkStreamRangeReader extends BasePDFStreamRangeReader {\n  #endRequests = endRequests.bind(this);\n\n  onClosed = null;\n\n  _done = false;\n\n  _queuedChunk = null;\n\n  _requests = [];\n\n  _storedError = null;\n\n  constructor(stream, begin, end) {\n    super(stream, begin, end);\n\n    this._requestXhr = stream._request({\n      begin,\n      end,\n      onHeadersReceived: this.#onHeadersReceived.bind(this),\n      onDone: this.#onDone.bind(this),\n      onError: this.#onError.bind(this),\n      onProgress: null,\n    });\n  }\n\n  #onHeadersReceived() {\n    const responseOrigin = getResponseOrigin(this._requestXhr?.responseURL);\n    try {\n      ensureResponseOrigin(responseOrigin, this._stream._responseOrigin);\n    } catch (ex) {\n      this._storedError = ex;\n      this.#onError(0);\n    }\n  }\n\n  #onDone(chunk) {\n    if (this._requests.length > 0) {\n      const capability = this._requests.shift();\n      capability.resolve({ value: chunk, done: false });\n    } else {\n      this._queuedChunk = chunk;\n    }\n    this._done = true;\n    this.#endRequests();\n    this.onClosed?.();\n  }\n\n  #onError(status) {\n    this._storedError ??= createResponseError(status, this._stream.url);\n    for (const capability of this._requests) {\n      capability.reject(this._storedError);\n    }\n    this._requests.length = 0;\n    this._queuedChunk = null;\n  }\n\n  async read() {\n    if (this._storedError) {\n      throw this._storedError;\n    }\n    if (this._queuedChunk !== null) {\n      const chunk = this._queuedChunk;\n      this._queuedChunk = null;\n      return { value: chunk, done: false };\n    }\n    if (this._done) {\n      return { value: undefined, done: true };\n    }\n    const capability = Promise.withResolvers();\n    this._requests.push(capability);\n    return capability.promise;\n  }\n\n  cancel(reason) {\n    this._done = true;\n    this.#endRequests();\n\n    this._stream._abortRequest(this._requestXhr);\n    this.onClosed?.();\n  }\n}\n\nexport { PDFNetworkStream };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/* globals process */\n\nimport { AbortException, assert } from \"../shared/util.js\";\nimport {\n  BasePDFStream,\n  BasePDFStreamRangeReader,\n  BasePDFStreamReader,\n} from \"../shared/base_pdf_stream.js\";\nimport { createResponseError } from \"./network_utils.js\";\nimport { getArrayBuffer } from \"./fetch_stream.js\";\n\nif (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n  throw new Error(\n    'Module \"./node_stream.js\" shall not be used with MOZCENTRAL builds.'\n  );\n}\n\nfunction getReadableStream(readStream) {\n  const { Readable } = process.getBuiltinModule(\"stream\");\n\n  if (typeof Readable.toWeb === \"function\") {\n    // See https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options\n    return Readable.toWeb(readStream);\n  }\n  // Fallback to support Node.js versions older than `24.0.0` and `22.17.0`.\n  const require = process\n    .getBuiltinModule(\"module\")\n    .createRequire(import.meta.url);\n\n  const polyfill = require(\"node-readable-to-web-readable-stream\");\n  return polyfill.makeDefaultReadableStreamFromNodeReadable(readStream);\n}\n\nclass PDFNodeStream extends BasePDFStream {\n  constructor(source) {\n    super(source, PDFNodeStreamReader, PDFNodeStreamRangeReader);\n    const { url } = source;\n\n    assert(\n      url.protocol === \"file:\",\n      \"PDFNodeStream only supports file:// URLs.\"\n    );\n  }\n}\n\nclass PDFNodeStreamReader extends BasePDFStreamReader {\n  _reader = null;\n\n  constructor(stream) {\n    super(stream);\n    const { disableRange, disableStream, length, rangeChunkSize, url } =\n      stream._source;\n\n    this._contentLength = length;\n    this._isStreamingSupported = !disableStream;\n    this._isRangeSupported = !disableRange;\n\n    const fs = process.getBuiltinModule(\"fs\");\n    fs.promises\n      .lstat(url)\n      .then(stat => {\n        const readStream = fs.createReadStream(url);\n        const readableStream = getReadableStream(readStream);\n\n        this._reader = readableStream.getReader();\n\n        const { size } = stat;\n        if (size <= 2 * rangeChunkSize) {\n          // The file size is smaller than the size of two chunks, so it doesn't\n          // make any sense to abort the request and retry with a range request.\n          this._isRangeSupported = false;\n        }\n        // Setting right content length.\n        this._contentLength = size;\n\n        // We need to stop reading when range is supported and streaming is\n        // disabled.\n        if (!this._isStreamingSupported && this._isRangeSupported) {\n          this.cancel(new AbortException(\"Streaming is disabled.\"));\n        }\n\n        this._headersCapability.resolve();\n      })\n      .catch(error => {\n        if (error.code === \"ENOENT\") {\n          error = createResponseError(/* status = */ 0, url);\n        }\n        this._headersCapability.reject(error);\n      });\n  }\n\n  async read() {\n    await this._headersCapability.promise;\n    const { value, done } = await this._reader.read();\n    if (done) {\n      return { value, done };\n    }\n    this._loaded += value.byteLength;\n    this._callOnProgress();\n\n    return { value: getArrayBuffer(value), done: false };\n  }\n\n  cancel(reason) {\n    this._reader?.cancel(reason);\n  }\n}\n\nclass PDFNodeStreamRangeReader extends BasePDFStreamRangeReader {\n  _readCapability = Promise.withResolvers();\n\n  _reader = null;\n\n  constructor(stream, begin, end) {\n    super(stream, begin, end);\n    const { url } = stream._source;\n\n    const fs = process.getBuiltinModule(\"fs\");\n    try {\n      const readStream = fs.createReadStream(url, {\n        start: begin,\n        end: end - 1,\n      });\n      const readableStream = getReadableStream(readStream);\n\n      this._reader = readableStream.getReader();\n\n      this._readCapability.resolve();\n    } catch (error) {\n      this._readCapability.reject(error);\n    }\n  }\n\n  async read() {\n    await this._readCapability.promise;\n    const { value, done } = await this._reader.read();\n    if (done) {\n      return { value, done };\n    }\n    return { value: getArrayBuffer(value), done: false };\n  }\n\n  cancel(reason) {\n    this._reader?.cancel(reason);\n  }\n}\n\nexport { PDFNodeStream };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst INITIAL_DATA = Symbol(\"INITIAL_DATA\");\n\nconst dataObj = () => ({\n  ...Promise.withResolvers(),\n  data: INITIAL_DATA,\n});\n\n/**\n * A PDF document and page is built of many objects. E.g. there are objects for\n * fonts, images, rendering code, etc. These objects may get processed inside of\n * a worker. This class implements some basic methods to manage these objects.\n */\nclass PDFObjects {\n  #objs = new Map();\n\n  /**\n   * Ensures there is an object defined for `objId`.\n   *\n   * @param {string} objId\n   * @returns {Object}\n   */\n  #ensureObj(objId) {\n    return this.#objs.getOrInsertComputed(objId, dataObj);\n  }\n\n  /**\n   * If called *without* callback, this returns the data of `objId` but the\n   * object needs to be resolved. If it isn't, this method throws.\n   *\n   * If called *with* a callback, the callback is called with the data of the\n   * object once the object is resolved. That means, if you call this method\n   * and the object is already resolved, the callback gets called right away.\n   *\n   * @param {string} objId\n   * @param {function} [callback]\n   * @returns {any}\n   */\n  get(objId, callback = null) {\n    // If there is a callback, then the get can be async and the object is\n    // not required to be resolved right now.\n    if (callback) {\n      const obj = this.#ensureObj(objId);\n      obj.promise.then(() => callback(obj.data));\n      return null;\n    }\n    // If there isn't a callback, the user expects to get the resolved data\n    // directly.\n    const obj = this.#objs.get(objId);\n    // If there isn't an object yet or the object isn't resolved, then the\n    // data isn't ready yet!\n    if (!obj || obj.data === INITIAL_DATA) {\n      throw new Error(`Requesting object that isn't resolved yet ${objId}.`);\n    }\n    return obj.data;\n  }\n\n  /**\n   * @param {string} objId\n   * @returns {boolean}\n   */\n  has(objId) {\n    const obj = this.#objs.get(objId);\n    return !!obj && obj.data !== INITIAL_DATA;\n  }\n\n  /**\n   * @param {string} objId\n   * @returns {boolean}\n   */\n  delete(objId) {\n    const obj = this.#objs.get(objId);\n    if (!obj || obj.data === INITIAL_DATA) {\n      // Only allow removing the object *after* it's been resolved.\n      return false;\n    }\n    this.#objs.delete(objId);\n    return true;\n  }\n\n  /**\n   * Resolves the object `objId` with optional `data`.\n   *\n   * @param {string} objId\n   * @param {any} [data]\n   */\n  resolve(objId, data = null) {\n    const obj = this.#ensureObj(objId);\n    obj.data = data;\n    obj.resolve();\n  }\n\n  clear() {\n    for (const { data } of this.#objs.values()) {\n      data?.bitmap?.close(); // Release any `ImageBitmap` data.\n    }\n    this.#objs.clear();\n  }\n\n  *[Symbol.iterator]() {\n    for (const [objId, { data }] of this.#objs) {\n      if (data !== INITIAL_DATA) {\n        yield [objId, data];\n      }\n    }\n  }\n}\n\nexport { PDFObjects };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @typedef {import(\"./display_utils\").PageViewport} PageViewport */\n/** @typedef {import(\"./api\").TextContent} TextContent */\n\nimport {\n  AbortException,\n  FeatureTest,\n  shadow,\n  Util,\n  warn,\n} from \"../shared/util.js\";\nimport { OutputScale, setLayerDimensions } from \"./display_utils.js\";\n\n/**\n * @typedef {Object} TextLayerParameters\n * @property {ReadableStream | TextContent} textContentSource - Text content to\n *   render, i.e. the value returned by the page's `streamTextContent` or\n *   `getTextContent` method.\n * @property {HTMLElement} container - The DOM node that will contain the text\n *   runs.\n * @property {PageViewport} viewport - The target viewport to properly layout\n *   the text runs.\n */\n\n/**\n * @typedef {Object} TextLayerUpdateParameters\n * @property {PageViewport} viewport - The target viewport to properly layout\n *   the text runs.\n * @property {function} [onBefore] - Callback invoked before the textLayer is\n *   updated in the DOM.\n */\n\nconst MAX_TEXT_DIVS_TO_RENDER = 100000;\nconst DEFAULT_FONT_SIZE = 30;\n\nclass TextLayer {\n  #capability = Promise.withResolvers();\n\n  #container = null;\n\n  #disableProcessItems = false;\n\n  #fontInspectorEnabled = !!globalThis.FontInspector?.enabled;\n\n  #lang = null;\n\n  #layoutTextParams = null;\n\n  #pageHeight = 0;\n\n  #pageWidth = 0;\n\n  #reader = null;\n\n  #rootContainer = null;\n\n  #rotation = 0;\n\n  #scale = 0;\n\n  #styleCache = Object.create(null);\n\n  #textContentItemsStr = [];\n\n  #textContentSource = null;\n\n  #textDivs = [];\n\n  #textDivProperties = new WeakMap();\n\n  #transform = null;\n\n  static #ascentCache = new Map();\n\n  static #canvasContexts = new Map();\n\n  static #canvasCtxFonts = new WeakMap();\n\n  static #minFontSize = null;\n\n  static #pendingTextLayers = new Set();\n\n  /**\n   * @param {TextLayerParameters} options\n   */\n  constructor({ textContentSource, container, viewport }) {\n    if (textContentSource instanceof ReadableStream) {\n      this.#textContentSource = textContentSource;\n    } else if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"GENERIC\")) &&\n      typeof textContentSource === \"object\"\n    ) {\n      this.#textContentSource = new ReadableStream({\n        start(controller) {\n          controller.enqueue(textContentSource);\n          controller.close();\n        },\n      });\n    } else {\n      throw new Error('No \"textContentSource\" parameter specified.');\n    }\n    this.#container = this.#rootContainer = container;\n\n    this.#scale = viewport.scale * OutputScale.pixelRatio;\n    this.#rotation = viewport.rotation;\n    this.#layoutTextParams = {\n      div: null,\n      properties: null,\n      ctx: null,\n    };\n    const { pageWidth, pageHeight, pageX, pageY } = viewport.rawDims;\n    this.#transform = [1, 0, 0, -1, -pageX, pageY + pageHeight];\n    this.#pageWidth = pageWidth;\n    this.#pageHeight = pageHeight;\n\n    TextLayer.#ensureMinFontSizeComputed();\n    container.style.setProperty(\"--min-font-size\", TextLayer.#minFontSize);\n\n    setLayerDimensions(container, viewport);\n\n    // Always clean-up the temporary canvas once rendering is no longer pending.\n    this.#capability.promise\n      .finally(() => {\n        TextLayer.#pendingTextLayers.delete(this);\n        this.#layoutTextParams = null;\n        this.#styleCache = null;\n      })\n      .catch(() => {\n        // Avoid \"Uncaught promise\" messages in the console.\n      });\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      // For testing purposes.\n      Object.defineProperty(this, \"pageWidth\", {\n        get() {\n          return this.#pageWidth;\n        },\n      });\n      Object.defineProperty(this, \"pageHeight\", {\n        get() {\n          return this.#pageHeight;\n        },\n      });\n    }\n  }\n\n  static get fontFamilyMap() {\n    const { isWindows, isFirefox } = FeatureTest.platform;\n    return shadow(\n      this,\n      \"fontFamilyMap\",\n      new Map([\n        [\n          \"sans-serif\",\n          `${isWindows && isFirefox ? \"Calibri, \" : \"\"}sans-serif`,\n        ],\n        [\n          \"monospace\",\n          `${isWindows && isFirefox ? \"Lucida Console, \" : \"\"}monospace`,\n        ],\n      ])\n    );\n  }\n\n  /**\n   * Render the textLayer.\n   * @returns {Promise}\n   */\n  render() {\n    const pump = () => {\n      this.#reader.read().then(({ value, done }) => {\n        if (done) {\n          this.#capability.resolve();\n          return;\n        }\n        this.#lang ??= value.lang;\n        Object.assign(this.#styleCache, value.styles);\n        this.#processItems(value.items);\n        pump();\n      }, this.#capability.reject);\n    };\n    this.#reader = this.#textContentSource.getReader();\n    TextLayer.#pendingTextLayers.add(this);\n    pump();\n\n    return this.#capability.promise;\n  }\n\n  /**\n   * Update a previously rendered textLayer, if necessary.\n   * @param {TextLayerUpdateParameters} options\n   * @returns {undefined}\n   */\n  update({ viewport, onBefore = null }) {\n    const scale = viewport.scale * OutputScale.pixelRatio;\n    const rotation = viewport.rotation;\n\n    if (rotation !== this.#rotation) {\n      onBefore?.();\n      this.#rotation = rotation;\n      setLayerDimensions(this.#rootContainer, { rotation });\n    }\n\n    if (scale !== this.#scale) {\n      onBefore?.();\n      this.#scale = scale;\n      const params = {\n        div: null,\n        properties: null,\n        ctx: TextLayer.#getCtx(this.#lang),\n      };\n      for (const div of this.#textDivs) {\n        params.properties = this.#textDivProperties.get(div);\n        params.div = div;\n        this.#layout(params);\n      }\n    }\n  }\n\n  /**\n   * Cancel rendering of the textLayer.\n   * @returns {undefined}\n   */\n  cancel() {\n    const abortEx = new AbortException(\"TextLayer task cancelled.\");\n\n    this.#reader?.cancel(abortEx).catch(() => {\n      // Avoid \"Uncaught promise\" messages in the console.\n    });\n    this.#reader = null;\n\n    this.#capability.reject(abortEx);\n  }\n\n  /**\n   * @type {Array<HTMLElement>} HTML elements that correspond to the text items\n   *   of the textContent input.\n   *   This is output and will initially be set to an empty array.\n   */\n  get textDivs() {\n    return this.#textDivs;\n  }\n\n  /**\n   * @type {Array<string>} Strings that correspond to the `str` property of\n   *   the text items of the textContent input.\n   *   This is output and will initially be set to an empty array\n   */\n  get textContentItemsStr() {\n    return this.#textContentItemsStr;\n  }\n\n  #processItems(items) {\n    if (this.#disableProcessItems) {\n      return;\n    }\n    this.#layoutTextParams.ctx ??= TextLayer.#getCtx(this.#lang);\n\n    const textDivs = this.#textDivs,\n      textContentItemsStr = this.#textContentItemsStr;\n\n    for (const item of items) {\n      // No point in rendering many divs as it would make the browser\n      // unusable even after the divs are rendered.\n      if (textDivs.length > MAX_TEXT_DIVS_TO_RENDER) {\n        warn(\"Ignoring additional textDivs for performance reasons.\");\n\n        this.#disableProcessItems = true; // Avoid multiple warnings for one page.\n        return;\n      }\n\n      if (item.str === undefined) {\n        if (\n          item.type === \"beginMarkedContentProps\" ||\n          item.type === \"beginMarkedContent\"\n        ) {\n          const parent = this.#container;\n          this.#container = document.createElement(\"span\");\n          this.#container.classList.add(\"markedContent\");\n          if (item.id) {\n            this.#container.setAttribute(\"id\", `${item.id}`);\n          }\n          if (item.tag === \"Artifact\") {\n            this.#container.ariaHidden = true;\n          }\n          parent.append(this.#container);\n        } else if (item.type === \"endMarkedContent\") {\n          this.#container = this.#container.parentNode;\n        }\n        continue;\n      }\n      textContentItemsStr.push(item.str);\n      this.#appendText(item);\n    }\n  }\n\n  #appendText(geom) {\n    // Initialize all used properties to keep the caches monomorphic.\n    const textDiv = document.createElement(\"span\");\n    const textDivProperties = {\n      angle: 0,\n      canvasWidth: 0,\n      hasText: geom.str !== \"\",\n      hasEOL: geom.hasEOL,\n      fontSize: 0,\n    };\n    this.#textDivs.push(textDiv);\n\n    const tx = Util.transform(this.#transform, geom.transform);\n    let angle = Math.atan2(tx[1], tx[0]);\n    const style = this.#styleCache[geom.fontName];\n    if (style.vertical) {\n      angle += Math.PI / 2;\n    }\n\n    let fontFamily =\n      (this.#fontInspectorEnabled && style.fontSubstitution) ||\n      style.fontFamily;\n\n    // Workaround for bug 1922063.\n    fontFamily = TextLayer.fontFamilyMap.get(fontFamily) || fontFamily;\n    const fontHeight = Math.hypot(tx[2], tx[3]);\n    const fontAscent =\n      fontHeight * TextLayer.#getAscent(fontFamily, style, this.#lang);\n\n    let left, top;\n    if (angle === 0) {\n      left = tx[4];\n      top = tx[5] - fontAscent;\n    } else {\n      left = tx[4] + fontAscent * Math.sin(angle);\n      top = tx[5] - fontAscent * Math.cos(angle);\n    }\n\n    const divStyle = textDiv.style;\n    // Setting the style properties individually, rather than all at once,\n    // should be OK since the `textDiv` isn't appended to the document yet.\n    divStyle.left = `${((100 * left) / this.#pageWidth).toFixed(2)}%`;\n    divStyle.top = `${((100 * top) / this.#pageHeight).toFixed(2)}%`;\n    divStyle.setProperty(\"--font-height\", `${fontHeight.toFixed(2)}px`);\n    divStyle.fontFamily = fontFamily;\n\n    textDivProperties.fontSize = fontHeight;\n\n    // Keeps screen readers from pausing on every new text span.\n    textDiv.setAttribute(\"role\", \"presentation\");\n\n    textDiv.textContent = geom.str;\n    // geom.dir may be 'ttb' for vertical texts.\n    textDiv.dir = geom.dir;\n\n    // `fontName` is only used by the FontInspector, and we only use `dataset`\n    // here to make the font name available in the debugger.\n    if (this.#fontInspectorEnabled) {\n      textDiv.dataset.fontName =\n        style.fontSubstitutionLoadedName || geom.fontName;\n    }\n    if (angle !== 0) {\n      textDivProperties.angle = angle * (180 / Math.PI);\n    }\n    // We don't bother scaling single-char text divs, because it has very\n    // little effect on text highlighting. This makes scrolling on docs with\n    // lots of such divs a lot faster.\n    let shouldScaleText = false;\n    if (geom.str.length > 1) {\n      shouldScaleText = true;\n    } else if (geom.str !== \" \" && geom.transform[0] !== geom.transform[3]) {\n      const absScaleX = Math.abs(geom.transform[0]),\n        absScaleY = Math.abs(geom.transform[3]);\n      // When the horizontal/vertical scaling differs significantly, also scale\n      // even single-char text to improve highlighting (fixes issue11713.pdf).\n      if (\n        absScaleX !== absScaleY &&\n        Math.max(absScaleX, absScaleY) / Math.min(absScaleX, absScaleY) > 1.5\n      ) {\n        shouldScaleText = true;\n      }\n    }\n    if (shouldScaleText) {\n      textDivProperties.canvasWidth = style.vertical ? geom.height : geom.width;\n    }\n    this.#textDivProperties.set(textDiv, textDivProperties);\n\n    // Finally, layout and append the text to the DOM.\n    this.#layoutTextParams.div = textDiv;\n    this.#layoutTextParams.properties = textDivProperties;\n    this.#layout(this.#layoutTextParams);\n\n    if (textDivProperties.hasText) {\n      this.#container.append(textDiv);\n    }\n    if (textDivProperties.hasEOL) {\n      const br = document.createElement(\"br\");\n      br.setAttribute(\"role\", \"presentation\");\n      this.#container.append(br);\n    }\n  }\n\n  #layout(params) {\n    const { div, properties, ctx } = params;\n    const { style } = div;\n\n    if (properties.canvasWidth !== 0 && properties.hasText) {\n      const { fontFamily } = style;\n      const { canvasWidth, fontSize } = properties;\n\n      TextLayer.#ensureCtxFont(ctx, fontSize * this.#scale, fontFamily);\n      // Only measure the width for multi-char text divs, see `appendText`.\n      const { width } = ctx.measureText(div.textContent);\n\n      if (width > 0) {\n        style.setProperty(\"--scale-x\", (canvasWidth * this.#scale) / width);\n      }\n    }\n    if (properties.angle !== 0) {\n      style.setProperty(\"--rotate\", `${properties.angle}deg`);\n    }\n  }\n\n  /**\n   * Clean-up global textLayer data.\n   * @returns {undefined}\n   */\n  static cleanup() {\n    if (this.#pendingTextLayers.size > 0) {\n      return;\n    }\n    this.#ascentCache.clear();\n\n    for (const { canvas } of this.#canvasContexts.values()) {\n      canvas.remove();\n    }\n    this.#canvasContexts.clear();\n  }\n\n  static #getCtx(lang = null) {\n    let ctx = this.#canvasContexts.get((lang ||= \"\"));\n    if (!ctx) {\n      // We don't use an OffscreenCanvas here because we use serif/sans serif\n      // fonts with it and they depends on the locale.\n      // In Firefox, the <html> element get a lang attribute that depends on\n      // what Fluent returns for the locale and the OffscreenCanvas uses\n      // the OS locale.\n      // Those two locales can be different and consequently the used fonts will\n      // be different (see bug 1869001).\n      // Ideally, we should use in the text layer the fonts we've in the pdf (or\n      // their replacements when they aren't embedded) and then we can use an\n      // OffscreenCanvas.\n      const canvas = document.createElement(\"canvas\");\n      canvas.className = \"hiddenCanvasElement\";\n      canvas.lang = lang;\n      document.body.append(canvas);\n      ctx = canvas.getContext(\"2d\", {\n        alpha: false,\n        willReadFrequently: true,\n      });\n      this.#canvasContexts.set(lang, ctx);\n\n      // Also, initialize state for the `#ensureCtxFont` method.\n      this.#canvasCtxFonts.set(ctx, { size: 0, family: \"\" });\n    }\n    return ctx;\n  }\n\n  static #ensureCtxFont(ctx, size, family) {\n    const cached = this.#canvasCtxFonts.get(ctx);\n    if (size === cached.size && family === cached.family) {\n      return; // The font is already set.\n    }\n    ctx.font = `${size}px ${family}`;\n    cached.size = size;\n    cached.family = family;\n  }\n\n  /**\n   * Compute the minimum font size enforced by the browser.\n   */\n  static #ensureMinFontSizeComputed() {\n    if (this.#minFontSize !== null) {\n      return;\n    }\n    const div = document.createElement(\"div\");\n    div.style.opacity = 0;\n    div.style.lineHeight = 1;\n    div.style.fontSize = \"1px\";\n    div.style.position = \"absolute\";\n    div.textContent = \"X\";\n    document.body.append(div);\n    // In `display:block` elements contain a single line of text,\n    // the height matches the line height (which, when set to 1,\n    // matches the actual font size).\n    this.#minFontSize = div.getBoundingClientRect().height;\n    div.remove();\n  }\n\n  static #getAscent(fontFamily, style, lang) {\n    const cachedAscent = this.#ascentCache.get(fontFamily);\n    if (cachedAscent) {\n      return cachedAscent;\n    }\n    const ctx = this.#getCtx(lang);\n\n    ctx.canvas.width = ctx.canvas.height = DEFAULT_FONT_SIZE;\n    this.#ensureCtxFont(ctx, DEFAULT_FONT_SIZE, fontFamily);\n    const metrics = ctx.measureText(\"\");\n\n    const ascent = metrics.fontBoundingBoxAscent;\n    const descent = Math.abs(metrics.fontBoundingBoxDescent);\n\n    ctx.canvas.width = ctx.canvas.height = 0;\n    let ratio = 0.8; // DEFAULT_FONT_ASCENT\n\n    if (ascent) {\n      ratio = ascent / (ascent + descent);\n    } else {\n      if (\n        (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n        FeatureTest.platform.isFirefox\n      ) {\n        warn(\n          \"Enable the `dom.textMetrics.fontBoundingBox.enabled` preference \" +\n            \"in `about:config` to improve TextLayer rendering.\"\n        );\n      }\n      if (style.ascent) {\n        ratio = style.ascent;\n      } else if (style.descent) {\n        ratio = 1 + style.descent;\n      }\n    }\n\n    this.#ascentCache.set(fontFamily, ratio);\n    return ratio;\n  }\n}\n\nexport { TextLayer };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * @module pdfjsLib\n */\n\nimport {\n  AbortException,\n  AnnotationMode,\n  assert,\n  FeatureTest,\n  getVerbosityLevel,\n  info,\n  isNodeJS,\n  makeObj,\n  MathClamp,\n  RenderingIntentFlag,\n  setVerbosityLevel,\n  shadow,\n  unreachable,\n  warn,\n} from \"../shared/util.js\";\nimport {\n  AnnotationStorage,\n  PrintAnnotationStorage,\n  SerializableEmpty,\n} from \"./annotation_storage.js\";\nimport {\n  deprecated,\n  isDataScheme,\n  isValidFetchUrl,\n  PagesMapper,\n  PageViewport,\n  RenderingCancelledException,\n  StatTimer,\n} from \"./display_utils.js\";\nimport { FontFaceObject, FontLoader } from \"./font_loader.js\";\nimport {\n  FontInfo,\n  FontPathInfo,\n  PatternInfo,\n} from \"../shared/obj-bin-transform.js\";\nimport {\n  getDataProp,\n  getFactoryUrlProp,\n  getUrlProp,\n  isRefProxy,\n  LoopbackPort,\n} from \"./api_utils.js\";\nimport { MessageHandler, wrapReason } from \"../shared/message_handler.js\";\nimport {\n  NodeCanvasFactory,\n  NodeCMapReaderFactory,\n  NodeFilterFactory,\n  NodeStandardFontDataFactory,\n  NodeWasmFactory,\n} from \"display-node_utils\";\nimport { CanvasDependencyTracker } from \"./canvas_dependency_tracker.js\";\nimport { CanvasGraphics } from \"./canvas.js\";\nimport { DOMCanvasFactory } from \"./canvas_factory.js\";\nimport { DOMCMapReaderFactory } from \"display-cmap_reader_factory\";\nimport { DOMFilterFactory } from \"./filter_factory.js\";\nimport { DOMStandardFontDataFactory } from \"display-standard_fontdata_factory\";\nimport { DOMWasmFactory } from \"display-wasm_factory\";\nimport { GlobalWorkerOptions } from \"./worker_options.js\";\nimport { Metadata } from \"./metadata.js\";\nimport { OptionalContentConfig } from \"./optional_content_config.js\";\nimport { PDFDataTransportStream } from \"./transport_stream.js\";\nimport { PDFFetchStream } from \"display-fetch_stream\";\nimport { PDFNetworkStream } from \"display-network\";\nimport { PDFNodeStream } from \"display-node_stream\";\nimport { PDFObjects } from \"./pdf_objects.js\";\nimport { TextLayer } from \"./text_layer.js\";\nimport { XfaText } from \"./xfa_text.js\";\n\nconst RENDERING_CANCELLED_TIMEOUT = 100; // ms\n\n/**\n * @typedef { Int8Array | Uint8Array | Uint8ClampedArray |\n *            Int16Array | Uint16Array |\n *            Int32Array | Uint32Array | Float32Array |\n *            Float64Array\n * } TypedArray\n */\n\n/**\n * @typedef {Object} RefProxy\n * @property {number} num\n * @property {number} gen\n */\n\n/**\n * Document initialization / loading parameters object.\n *\n * @typedef {Object} DocumentInitParameters\n * @property {string | URL} [url] - The URL of the PDF.\n * @property {TypedArray | ArrayBuffer | Array<number> | string} [data] -\n *   Binary PDF data.\n *   Use TypedArrays (Uint8Array) to improve the memory usage. If PDF data is\n *   BASE64-encoded, use `atob()` to convert it to a binary string first.\n *\n *   NOTE: If TypedArrays are used they will generally be transferred to the\n *   worker-thread. This will help reduce main-thread memory usage, however\n *   it will take ownership of the TypedArrays.\n * @property {Object} [httpHeaders] - Basic authentication headers.\n * @property {boolean} [withCredentials] - Indicates whether or not\n *   cross-site Access-Control requests should be made using credentials such\n *   as cookies or authorization headers. The default is `false`.\n * @property {string} [password] - For decrypting password-protected PDFs.\n * @property {number} [length] - The PDF file length. It's used for progress\n *   reports and range requests operations.\n * @property {PDFDataRangeTransport} [range] - Allows for using a custom range\n *   transport implementation.\n * @property {number} [rangeChunkSize] - Specify maximum number of bytes fetched\n *   per range request. The default value is 65536 (= 2^16).\n * @property {PDFWorker} [worker] - The worker that will be used for loading and\n *   parsing the PDF data.\n * @property {number} [verbosity] - Controls the logging level; the constants\n *   from {@link VerbosityLevel} should be used.\n * @property {string} [docBaseUrl] - The base URL of the document, used when\n *   attempting to recover valid absolute URLs for annotations, and outline\n *   items, that (incorrectly) only specify relative URLs.\n * @property {string} [cMapUrl] - The URL where the predefined Adobe CMaps are\n *   located. Include the trailing slash.\n * @property {boolean} [cMapPacked] - Specifies if the Adobe CMaps are binary\n *   packed or not. The default value is `true`.\n * @property {Object} [CMapReaderFactory] - The factory that will be used when\n *   reading built-in CMap files.\n *   The default value is {DOMCMapReaderFactory}.\n * @property {string} [iccUrl] - The URL where the predefined ICC profiles are\n *   located. Include the trailing slash.\n * @property {boolean} [useSystemFonts] - When `true`, fonts that aren't\n *   embedded in the PDF document will fallback to a system font.\n *   The default value is `true` in web environments and `false` in Node.js;\n *   unless `disableFontFace === true` in which case this defaults to `false`\n *   regardless of the environment (to prevent completely broken fonts).\n * @property {string} [standardFontDataUrl] - The URL where the standard font\n *   files are located. Include the trailing slash.\n * @property {Object} [StandardFontDataFactory] - The factory that will be used\n *   when reading the standard font files.\n *   The default value is {DOMStandardFontDataFactory}.\n * @property {string} [wasmUrl] - The URL where the wasm files are located.\n *   Include the trailing slash.\n * @property {Object} [WasmFactory] - The factory that will be used\n *   when reading the wasm files.\n *   The default value is {DOMWasmFactory}.\n * @property {boolean} [useWorkerFetch] - Enable using the Fetch API in the\n *   worker-thread when reading CMap and standard font files. When `true`,\n *   the `CMapReaderFactory`, `StandardFontDataFactory`, and `WasmFactory`\n *   options are ignored.\n *   The default value is `true` in web environments and `false` in Node.js.\n * @property {boolean} [useWasm] - Attempt to use WebAssembly in order to\n *    improve e.g. image decoding performance.\n *    The default value is `true`.\n * @property {boolean} [stopAtErrors] - Reject certain promises, e.g.\n *   `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated\n *   PDF data cannot be successfully parsed, instead of attempting to recover\n *   whatever possible of the data. The default value is `false`.\n * @property {number} [maxImageSize] - The maximum allowed image size in total\n *   pixels, i.e. width * height. Images above this value will not be rendered.\n *   Use -1 for no limit, which is also the default value.\n * @property {boolean} [isEvalSupported] - Determines if we can evaluate strings\n *   as JavaScript. Primarily used to improve performance of PDF functions.\n *   The default value is `true`.\n * @property {boolean} [isOffscreenCanvasSupported] - Determines if we can use\n *   `OffscreenCanvas` in the worker. Primarily used to improve performance of\n *   image conversion/rendering.\n *   The default value is `true` in web environments and `false` in Node.js.\n * @property {boolean} [isImageDecoderSupported] - Determines if we can use\n *   `ImageDecoder` in the worker. Primarily used to improve performance of\n *   image conversion/rendering.\n *   The default value is `true` in web environments and `false` in Node.js.\n *\n *   NOTE: Also temporarily disabled in Chromium browsers, until we no longer\n *   support the affected browser versions, because of various bugs:\n *\n *    - Crashes when using the BMP decoder with huge images, e.g. issue6741.pdf;\n *      see https://issues.chromium.org/issues/374807001\n *\n *    - Broken images when using the JPEG decoder with images that have custom\n *      colour profiles, e.g. GitHub discussion 19030;\n *      see https://issues.chromium.org/issues/378869810\n *\n * @property {number} [canvasMaxAreaInBytes] - The integer value is used to\n *   know when an image must be resized (uses `OffscreenCanvas` in the worker).\n *   If it's -1 then a possibly slow algorithm is used to guess the max value.\n * @property {boolean} [disableFontFace] - By default fonts are converted to\n *   OpenType fonts and loaded via the Font Loading API or `@font-face` rules.\n *   If disabled, fonts will be rendered using a built-in font renderer that\n *   constructs the glyphs with primitive path commands.\n *   The default value is `false` in web environments and `true` in Node.js.\n * @property {boolean} [fontExtraProperties] - Include additional properties,\n *   which are unused during rendering of PDF documents, when exporting the\n *   parsed font data from the worker-thread. This may be useful for debugging\n *   purposes (and backwards compatibility), but note that it will lead to\n *   increased memory usage. The default value is `false`.\n * @property {boolean} [enableXfa] - Render Xfa forms if any.\n *   The default value is `false`.\n * @property {HTMLDocument} [ownerDocument] - Specify an explicit document\n *   context to create elements with and to load resources, such as fonts,\n *   into. Defaults to the current document.\n * @property {boolean} [disableRange] - Disable range request loading of PDF\n *   files. When enabled, and if the server supports partial content requests,\n *   then the PDF will be fetched in chunks. The default value is `false`.\n * @property {boolean} [disableStream] - Disable streaming of PDF file data.\n *   By default PDF.js attempts to load PDF files in chunks. The default value\n *   is `false`.\n * @property {boolean} [disableAutoFetch] - Disable pre-fetching of PDF file\n *   data. When range requests are enabled PDF.js will automatically keep\n *   fetching more data even if it isn't needed to display the current page.\n *   The default value is `false`.\n *\n *   NOTE: It is also necessary to disable streaming, see above, in order for\n *   disabling of pre-fetching to work correctly.\n * @property {boolean} [pdfBug] - Enables special hooks for debugging PDF.js\n *   (see `web/debugger.js`). The default value is `false`.\n * @property {Object} [CanvasFactory] - The factory that will be used when\n *    creating canvases. The default value is {DOMCanvasFactory}.\n * @property {Object} [FilterFactory] - The factory that will be used to\n *    create SVG filters when rendering some images on the main canvas.\n *    The default value is {DOMFilterFactory}.\n * @property {boolean} [enableHWA] - Enables hardware acceleration for\n *   rendering. The default value is `false`.\n * @property {Object} [pagesMapper] - The pages mapper that will be used to map\n *   page ids and page numbers. It's used when the page order is changed or some\n *   pages are removed, cloned, etc.\n */\n\n/**\n * This is the main entry point for loading a PDF and interacting with it.\n *\n * NOTE: If a URL is used to fetch the PDF data a standard Fetch API call (or\n * XHR as fallback) is used, which means it must follow same origin rules,\n * e.g. no cross-domain requests without CORS.\n *\n * @param {string | URL | TypedArray | ArrayBuffer | DocumentInitParameters}\n *   src - Can be a URL where a PDF file is located, a typed array (Uint8Array)\n *         already populated with data, or a parameter object.\n * @returns {PDFDocumentLoadingTask}\n */\nfunction getDocument(src = {}) {\n  if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"GENERIC\")) {\n    if (typeof src === \"string\" || src instanceof URL) {\n      src = { url: src };\n    } else if (src instanceof ArrayBuffer || ArrayBuffer.isView(src)) {\n      src = { data: src };\n    }\n  }\n  const task = new PDFDocumentLoadingTask();\n  const { docId } = task;\n\n  const url = src.url ? getUrlProp(src.url) : null;\n  const data = src.data ? getDataProp(src.data) : null;\n  const httpHeaders = src.httpHeaders || null;\n  const withCredentials = src.withCredentials === true;\n  const password = src.password ?? null;\n  const rangeTransport =\n    src.range instanceof PDFDataRangeTransport ? src.range : null;\n  const rangeChunkSize =\n    Number.isInteger(src.rangeChunkSize) && src.rangeChunkSize > 0\n      ? src.rangeChunkSize\n      : 2 ** 16;\n  let worker = src.worker instanceof PDFWorker ? src.worker : null;\n  const verbosity = src.verbosity;\n  // Ignore \"data:\"-URLs, since they can't be used to recover valid absolute\n  // URLs anyway. We want to avoid sending them to the worker-thread, since\n  // they contain the *entire* PDF document and can thus be arbitrarily long.\n  const docBaseUrl =\n    typeof src.docBaseUrl === \"string\" && !isDataScheme(src.docBaseUrl)\n      ? src.docBaseUrl\n      : null;\n  const cMapUrl = getFactoryUrlProp(src.cMapUrl);\n  const cMapPacked = src.cMapPacked !== false;\n  const CMapReaderFactory =\n    src.CMapReaderFactory ||\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"GENERIC\") && isNodeJS\n      ? NodeCMapReaderFactory\n      : DOMCMapReaderFactory);\n  const iccUrl = getFactoryUrlProp(src.iccUrl);\n  const standardFontDataUrl = getFactoryUrlProp(src.standardFontDataUrl);\n  const StandardFontDataFactory =\n    src.StandardFontDataFactory ||\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"GENERIC\") && isNodeJS\n      ? NodeStandardFontDataFactory\n      : DOMStandardFontDataFactory);\n  const wasmUrl = getFactoryUrlProp(src.wasmUrl);\n  const WasmFactory =\n    src.WasmFactory ||\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"GENERIC\") && isNodeJS\n      ? NodeWasmFactory\n      : DOMWasmFactory);\n  const ignoreErrors = src.stopAtErrors !== true;\n  const maxImageSize =\n    Number.isInteger(src.maxImageSize) && src.maxImageSize > -1\n      ? src.maxImageSize\n      : -1;\n  const isEvalSupported = src.isEvalSupported !== false;\n  const isOffscreenCanvasSupported =\n    typeof src.isOffscreenCanvasSupported === \"boolean\"\n      ? src.isOffscreenCanvasSupported\n      : !isNodeJS;\n  const isImageDecoderSupported =\n    // eslint-disable-next-line no-nested-ternary\n    typeof src.isImageDecoderSupported === \"boolean\"\n      ? src.isImageDecoderSupported\n      : // eslint-disable-next-line no-nested-ternary\n        typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")\n        ? true\n        : typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"CHROME\")\n          ? false\n          : !isNodeJS && (FeatureTest.platform.isFirefox || !globalThis.chrome);\n  const canvasMaxAreaInBytes = Number.isInteger(src.canvasMaxAreaInBytes)\n    ? src.canvasMaxAreaInBytes\n    : -1;\n  const disableFontFace =\n    typeof src.disableFontFace === \"boolean\" ? src.disableFontFace : isNodeJS;\n  const fontExtraProperties = src.fontExtraProperties === true;\n  const enableXfa = src.enableXfa === true;\n  const ownerDocument = src.ownerDocument || globalThis.document;\n  const disableRange = src.disableRange === true;\n  const disableStream = src.disableStream === true;\n  const disableAutoFetch = src.disableAutoFetch === true;\n  const pdfBug = src.pdfBug === true;\n  const CanvasFactory =\n    src.CanvasFactory ||\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"GENERIC\") && isNodeJS\n      ? NodeCanvasFactory\n      : DOMCanvasFactory);\n  const FilterFactory =\n    src.FilterFactory ||\n    (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"GENERIC\") && isNodeJS\n      ? NodeFilterFactory\n      : DOMFilterFactory);\n  const enableHWA = src.enableHWA === true;\n  const useWasm = src.useWasm !== false;\n  const pagesMapper = src.pagesMapper || new PagesMapper();\n\n  // Parameters whose default values depend on other parameters.\n  const length = rangeTransport ? rangeTransport.length : (src.length ?? NaN);\n  const useSystemFonts =\n    typeof src.useSystemFonts === \"boolean\"\n      ? src.useSystemFonts\n      : !isNodeJS && !disableFontFace;\n  const useWorkerFetch =\n    typeof src.useWorkerFetch === \"boolean\"\n      ? src.useWorkerFetch\n      : (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n        !!(\n          CMapReaderFactory === DOMCMapReaderFactory &&\n          StandardFontDataFactory === DOMStandardFontDataFactory &&\n          WasmFactory === DOMWasmFactory &&\n          cMapUrl &&\n          standardFontDataUrl &&\n          wasmUrl &&\n          isValidFetchUrl(cMapUrl, document.baseURI) &&\n          isValidFetchUrl(standardFontDataUrl, document.baseURI) &&\n          isValidFetchUrl(wasmUrl, document.baseURI)\n        );\n\n  // Parameters only intended for development/testing purposes.\n  const styleElement =\n    typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")\n      ? src.styleElement\n      : null;\n\n  // Set the main-thread verbosity level.\n  setVerbosityLevel(verbosity);\n\n  // Ensure that the various factories can be initialized, when necessary,\n  // since the user may provide *custom* ones.\n  const transportFactory = {\n    canvasFactory: new CanvasFactory({ ownerDocument, enableHWA }),\n    filterFactory: new FilterFactory({ docId, ownerDocument }),\n    cMapReaderFactory:\n      (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n      useWorkerFetch\n        ? null\n        : new CMapReaderFactory({ baseUrl: cMapUrl, isCompressed: cMapPacked }),\n    standardFontDataFactory:\n      (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n      useWorkerFetch\n        ? null\n        : new StandardFontDataFactory({ baseUrl: standardFontDataUrl }),\n    wasmFactory:\n      (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) ||\n      useWorkerFetch\n        ? null\n        : new WasmFactory({ baseUrl: wasmUrl }),\n  };\n\n  if (!worker) {\n    // Worker was not provided -- creating and owning our own. If message port\n    // is specified in global worker options, using it.\n    worker = PDFWorker.create({\n      verbosity,\n      port: GlobalWorkerOptions.workerPort,\n    });\n    task._worker = worker;\n  }\n\n  const docParams = {\n    docId,\n    apiVersion:\n      typeof PDFJSDev !== \"undefined\" && !PDFJSDev.test(\"TESTING\")\n        ? PDFJSDev.eval(\"BUNDLE_VERSION\")\n        : null,\n    data,\n    password,\n    disableAutoFetch,\n    rangeChunkSize,\n    length,\n    docBaseUrl,\n    enableXfa,\n    evaluatorOptions: {\n      maxImageSize,\n      disableFontFace,\n      ignoreErrors,\n      isEvalSupported,\n      isOffscreenCanvasSupported,\n      isImageDecoderSupported,\n      canvasMaxAreaInBytes,\n      fontExtraProperties,\n      useSystemFonts,\n      useWasm,\n      useWorkerFetch,\n      cMapUrl,\n      iccUrl,\n      standardFontDataUrl,\n      wasmUrl,\n    },\n  };\n  const transportParams = {\n    ownerDocument,\n    pdfBug,\n    styleElement,\n    enableHWA,\n    loadingParams: {\n      disableAutoFetch,\n      enableXfa,\n    },\n  };\n\n  worker.promise\n    .then(function () {\n      if (task.destroyed) {\n        throw new Error(\"Loading aborted\");\n      }\n      if (worker.destroyed) {\n        throw new Error(\"Worker was destroyed\");\n      }\n\n      const workerIdPromise = worker.messageHandler.sendWithPromise(\n        \"GetDocRequest\",\n        docParams,\n        data ? [data.buffer] : null\n      );\n\n      let networkStream;\n      if (rangeTransport) {\n        networkStream = new PDFDataTransportStream({\n          pdfDataRangeTransport: rangeTransport,\n          disableRange,\n          disableStream,\n        });\n      } else if (!data) {\n        if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n          throw new Error(\"Not implemented: NetworkStream\");\n        }\n        if (!url) {\n          throw new Error(\"getDocument - no `url` parameter provided.\");\n        }\n        // eslint-disable-next-line no-nested-ternary\n        const NetworkStream = isValidFetchUrl(url)\n          ? PDFFetchStream\n          : typeof PDFJSDev !== \"undefined\" &&\n              PDFJSDev.test(\"GENERIC\") &&\n              isNodeJS\n            ? PDFNodeStream\n            : PDFNetworkStream;\n\n        networkStream = new NetworkStream({\n          url,\n          length,\n          httpHeaders,\n          withCredentials,\n          rangeChunkSize,\n          disableRange,\n          disableStream,\n        });\n      }\n\n      return workerIdPromise.then(workerId => {\n        if (task.destroyed) {\n          throw new Error(\"Loading aborted\");\n        }\n        if (worker.destroyed) {\n          throw new Error(\"Worker was destroyed\");\n        }\n\n        const messageHandler = new MessageHandler(docId, workerId, worker.port);\n        const transport = new WorkerTransport(\n          messageHandler,\n          task,\n          networkStream,\n          transportParams,\n          transportFactory,\n          pagesMapper\n        );\n        task._transport = transport;\n        messageHandler.send(\"Ready\", null);\n      });\n    })\n    .catch(task._capability.reject);\n\n  return task;\n}\n\n/**\n * @typedef {Object} OnProgressParameters\n * @property {number} loaded - Currently loaded number of bytes.\n * @property {number} total - Total number of bytes in the PDF file.\n * @property {number} percent - Currently loaded percentage, as an integer value\n *   in the [0, 100] range. If `total` is undefined, the percentage is `NaN`.\n */\n\n/**\n * The loading task controls the operations required to load a PDF document\n * (such as network requests) and provides a way to listen for completion,\n * after which individual pages can be rendered.\n */\nclass PDFDocumentLoadingTask {\n  static #docId = 0;\n\n  /**\n   * @private\n   */\n  _capability = Promise.withResolvers();\n\n  /**\n   * @private\n   */\n  _transport = null;\n\n  /**\n   * @private\n   */\n  _worker = null;\n\n  /**\n   * Unique identifier for the document loading task.\n   * @type {string}\n   */\n  docId = `d${PDFDocumentLoadingTask.#docId++}`;\n\n  /**\n   * Whether the loading task is destroyed or not.\n   * @type {boolean}\n   */\n  destroyed = false;\n\n  /**\n   * Callback to request a password if a wrong or no password was provided.\n   * The callback receives two parameters: a function that should be called\n   * with the new password, and a reason (see {@link PasswordResponses}).\n   * @type {function}\n   */\n  onPassword = null;\n\n  /**\n   * Callback to be able to monitor the loading progress of the PDF file\n   * (necessary to implement e.g. a loading bar).\n   * The callback receives an {@link OnProgressParameters} argument.\n   * @type {function}\n   */\n  onProgress = null;\n\n  /**\n   * Promise for document loading task completion.\n   * @type {Promise<PDFDocumentProxy>}\n   */\n  get promise() {\n    return this._capability.promise;\n  }\n\n  /**\n   * Abort all network requests and destroy the worker.\n   * @returns {Promise<void>} A promise that is resolved when destruction is\n   *   completed.\n   */\n  async destroy() {\n    this.destroyed = true;\n\n    try {\n      if (this._worker?.port) {\n        this._worker._pendingDestroy = true;\n      }\n      await this._transport?.destroy();\n    } catch (ex) {\n      if (this._worker?.port) {\n        delete this._worker._pendingDestroy;\n      }\n      throw ex;\n    }\n    this._transport = null;\n\n    this._worker?.destroy();\n    this._worker = null;\n  }\n\n  /**\n   * Attempt to fetch the raw data of the PDF document, when e.g.\n   *  - An exception was thrown during document initialization.\n   *  - An `onPassword` callback is delaying initialization.\n   * @returns {Promise<Uint8Array>}\n   */\n  async getData() {\n    return this._transport.getData();\n  }\n}\n\n/**\n * Abstract class to support range requests file loading.\n *\n * NOTE: The TypedArrays passed to the constructor and relevant methods below\n * will generally be transferred to the worker-thread. This will help reduce\n * main-thread memory usage, however it will take ownership of the TypedArrays.\n */\nclass PDFDataRangeTransport {\n  #capability = Promise.withResolvers();\n\n  #progressiveDoneListeners = [];\n\n  #progressiveReadListeners = [];\n\n  #rangeListeners = [];\n\n  /**\n   * @param {number} length\n   * @param {Uint8Array|null} initialData\n   * @param {boolean} [progressiveDone]\n   * @param {string} [contentDispositionFilename]\n   */\n  constructor(\n    length,\n    initialData,\n    progressiveDone = false,\n    contentDispositionFilename = null\n  ) {\n    this.length = length;\n    this.initialData = initialData;\n    this.progressiveDone = progressiveDone;\n    this.contentDispositionFilename = contentDispositionFilename;\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"GENERIC\")) {\n      Object.defineProperty(this, \"onDataProgress\", {\n        value: () => {\n          deprecated(\n            \"`PDFDataRangeTransport.prototype.onDataProgress` - method was \" +\n              \"removed, since loading progress is now reported automatically \" +\n              \"through the `PDFDataTransportStream` class (and related code).\"\n          );\n        },\n      });\n    }\n  }\n\n  /**\n   * @param {function} listener\n   */\n  addRangeListener(listener) {\n    this.#rangeListeners.push(listener);\n  }\n\n  /**\n   * @param {function} listener\n   */\n  addProgressiveReadListener(listener) {\n    this.#progressiveReadListeners.push(listener);\n  }\n\n  /**\n   * @param {function} listener\n   */\n  addProgressiveDoneListener(listener) {\n    this.#progressiveDoneListeners.push(listener);\n  }\n\n  /**\n   * @param {number} begin\n   * @param {Uint8Array|null} chunk\n   */\n  onDataRange(begin, chunk) {\n    for (const listener of this.#rangeListeners) {\n      listener(begin, chunk);\n    }\n  }\n\n  /**\n   * @param {Uint8Array|null} chunk\n   */\n  onDataProgressiveRead(chunk) {\n    this.#capability.promise.then(() => {\n      for (const listener of this.#progressiveReadListeners) {\n        listener(chunk);\n      }\n    });\n  }\n\n  onDataProgressiveDone() {\n    this.#capability.promise.then(() => {\n      for (const listener of this.#progressiveDoneListeners) {\n        listener();\n      }\n    });\n  }\n\n  transportReady() {\n    this.#capability.resolve();\n  }\n\n  /**\n   * @param {number} begin\n   * @param {number} end\n   */\n  requestDataRange(begin, end) {\n    unreachable(\"Abstract method PDFDataRangeTransport.requestDataRange\");\n  }\n\n  abort() {}\n}\n\n/**\n * Proxy to a `PDFDocument` in the worker thread.\n */\nclass PDFDocumentProxy {\n  constructor(pdfInfo, transport) {\n    this._pdfInfo = pdfInfo;\n    this._transport = transport;\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      // For testing purposes.\n      Object.defineProperty(this, \"getNetworkStreamName\", {\n        value: () => this._transport.getNetworkStreamName(),\n      });\n      Object.defineProperty(this, \"getXFADatasets\", {\n        value: () => this._transport.getXFADatasets(),\n      });\n      Object.defineProperty(this, \"getStartXRefPos\", {\n        value: () => this._transport.getStartXRefPos(),\n      });\n      Object.defineProperty(this, \"getAnnotArray\", {\n        value: pageIndex => this._transport.getAnnotArray(pageIndex),\n      });\n    }\n  }\n\n  /**\n   * @type {PagesMapper} The pages mapper instance.\n   */\n  get pagesMapper() {\n    return this._transport.pagesMapper;\n  }\n\n  /**\n   * @type {AnnotationStorage} Storage for annotation data in forms.\n   */\n  get annotationStorage() {\n    return this._transport.annotationStorage;\n  }\n\n  /**\n   * @type {Object} The canvas factory instance.\n   */\n  get canvasFactory() {\n    return this._transport.canvasFactory;\n  }\n\n  /**\n   * @type {Object} The filter factory instance.\n   */\n  get filterFactory() {\n    return this._transport.filterFactory;\n  }\n\n  /**\n   * @type {number} Total number of pages in the PDF file.\n   */\n  get numPages() {\n    return this._pdfInfo.numPages;\n  }\n\n  /**\n   * @type {Array<string | null>} A (not guaranteed to be) unique ID to identify\n   *   the PDF document.\n   *   NOTE: The first element will always be defined for all PDF documents,\n   *   whereas the second element is only defined for *modified* PDF documents.\n   */\n  get fingerprints() {\n    return this._pdfInfo.fingerprints;\n  }\n\n  /**\n   * @type {boolean} True if only XFA form.\n   */\n  get isPureXfa() {\n    return shadow(this, \"isPureXfa\", !!this._transport._htmlForXfa);\n  }\n\n  /**\n   * NOTE: This is (mostly) intended to support printing of XFA forms.\n   *\n   * @type {Object | null} An object representing a HTML tree structure\n   *   to render the XFA, or `null` when no XFA form exists.\n   */\n  get allXfaHtml() {\n    return this._transport._htmlForXfa;\n  }\n\n  /**\n   * @param {number} pageNumber - The page number to get. The first page is 1.\n   * @returns {Promise<PDFPageProxy>} A promise that is resolved with\n   *   a {@link PDFPageProxy} object.\n   */\n  getPage(pageNumber) {\n    return this._transport.getPage(pageNumber);\n  }\n\n  /**\n   * @param {RefProxy} ref - The page reference.\n   * @returns {Promise<number>} A promise that is resolved with the page index,\n   *   starting from zero, that is associated with the reference.\n   */\n  getPageIndex(ref) {\n    return this._transport.getPageIndex(ref);\n  }\n\n  /**\n   * @returns {Promise<Object<string, Array<any>>>} A promise that is resolved\n   *   with a mapping from named destinations to references.\n   *\n   * This can be slow for large documents. Use `getDestination` instead.\n   */\n  getDestinations() {\n    return this._transport.getDestinations();\n  }\n\n  /**\n   * @param {string} id - The named destination to get.\n   * @returns {Promise<Array<any> | null>} A promise that is resolved with all\n   *   information of the given named destination, or `null` when the named\n   *   destination is not present in the PDF file.\n   */\n  getDestination(id) {\n    return this._transport.getDestination(id);\n  }\n\n  /**\n   * @returns {Promise<Array<string> | null>} A promise that is resolved with\n   *   an {Array} containing the page labels that correspond to the page\n   *   indexes, or `null` when no page labels are present in the PDF file.\n   */\n  getPageLabels() {\n    return this._transport.getPageLabels();\n  }\n\n  /**\n   * @returns {Promise<string>} A promise that is resolved with a {string}\n   *   containing the page layout name.\n   */\n  getPageLayout() {\n    return this._transport.getPageLayout();\n  }\n\n  /**\n   * @returns {Promise<string>} A promise that is resolved with a {string}\n   *   containing the page mode name.\n   */\n  getPageMode() {\n    return this._transport.getPageMode();\n  }\n\n  /**\n   * @returns {Promise<Object | null>} A promise that is resolved with an\n   *   {Object} containing the viewer preferences, or `null` when no viewer\n   *   preferences are present in the PDF file.\n   */\n  getViewerPreferences() {\n    return this._transport.getViewerPreferences();\n  }\n\n  /**\n   * @returns {Promise<any | null>} A promise that is resolved with an {Array}\n   *   containing the destination, or `null` when no open action is present\n   *   in the PDF.\n   */\n  getOpenAction() {\n    return this._transport.getOpenAction();\n  }\n\n  /**\n   * @returns {Promise<any>} A promise that is resolved with a lookup table\n   *   for mapping named attachments to their content.\n   */\n  getAttachments() {\n    return this._transport.getAttachments();\n  }\n\n  /**\n   * @param {Set<number>} types - The annotation types to retrieve.\n   * @param {Set<number>} pageIndexesToSkip\n   * @returns {Promise<Array<Object>>} A promise that is resolved with a list of\n   *   annotations data.\n   */\n  getAnnotationsByType(types, pageIndexesToSkip) {\n    return this._transport.getAnnotationsByType(types, pageIndexesToSkip);\n  }\n\n  /**\n   * @returns {Promise<Object | null>} A promise that is resolved with\n   *   an {Object} with the JavaScript actions:\n   *     - from the name tree.\n   *     - from A or AA entries in the catalog dictionary.\n   *   , or `null` if no JavaScript exists.\n   */\n  getJSActions() {\n    return this._transport.getDocJSActions();\n  }\n\n  /**\n   * @typedef {Object} OutlineNode\n   * @property {string} title\n   * @property {boolean} bold\n   * @property {boolean} italic\n   * @property {Uint8ClampedArray} color - The color in RGB format to use for\n   *   display purposes.\n   * @property {string | Array<any> | null} dest\n   * @property {string | null} url\n   * @property {string | undefined} unsafeUrl\n   * @property {boolean | undefined} newWindow\n   * @property {number | undefined} count\n   * @property {Array<OutlineNode>} items\n   */\n\n  /**\n   * @returns {Promise<Array<OutlineNode>>} A promise that is resolved with an\n   *   {Array} that is a tree outline (if it has one) of the PDF file.\n   */\n  getOutline() {\n    return this._transport.getOutline();\n  }\n\n  /**\n   * @typedef {Object} GetOptionalContentConfigParameters\n   * @property {string} [intent] - Determines the optional content groups that\n   *   are visible by default; valid values are:\n   *    - 'display' (viewable groups).\n   *    - 'print' (printable groups).\n   *    - 'any' (all groups).\n   *   The default value is 'display'.\n   */\n\n  /**\n   * @param {GetOptionalContentConfigParameters} [params] - Optional content\n   *   config parameters.\n   * @returns {Promise<OptionalContentConfig>} A promise that is resolved with\n   *   an {@link OptionalContentConfig} that contains all the optional content\n   *   groups (assuming that the document has any).\n   */\n  getOptionalContentConfig({ intent = \"display\" } = {}) {\n    const { renderingIntent } = this._transport.getRenderingIntent(intent);\n\n    return this._transport.getOptionalContentConfig(renderingIntent);\n  }\n\n  /**\n   * @returns {Promise<Array<number> | null>} A promise that is resolved with\n   *   an {Array} that contains the permission flags for the PDF document, or\n   *   `null` when no permissions are present in the PDF file.\n   */\n  getPermissions() {\n    return this._transport.getPermissions();\n  }\n\n  /**\n   * @returns {Promise<{ info: Object, metadata: Metadata }>} A promise that is\n   *   resolved with an {Object} that has `info` and `metadata` properties.\n   *   `info` is an {Object} filled with anything available in the information\n   *   dictionary and similarly `metadata` is a {Metadata} object with\n   *   information from the metadata section of the PDF.\n   */\n  getMetadata() {\n    return this._transport.getMetadata();\n  }\n\n  /**\n   * @typedef {Object} MarkInfo\n   * Properties correspond to Table 321 of the PDF 32000-1:2008 spec.\n   * @property {boolean} Marked\n   * @property {boolean} UserProperties\n   * @property {boolean} Suspects\n   */\n\n  /**\n   * @returns {Promise<MarkInfo | null>} A promise that is resolved with\n   *   a {MarkInfo} object that contains the MarkInfo flags for the PDF\n   *   document, or `null` when no MarkInfo values are present in the PDF file.\n   */\n  getMarkInfo() {\n    return this._transport.getMarkInfo();\n  }\n\n  /**\n   * @returns {Promise<Uint8Array>} A promise that is resolved with a\n   *   {Uint8Array} containing the raw data of the PDF document.\n   */\n  getData() {\n    return this._transport.getData();\n  }\n\n  /**\n   * @returns {Promise<Uint8Array>} A promise that is resolved with a\n   *   {Uint8Array} containing the full data of the saved document.\n   */\n  saveDocument() {\n    return this._transport.saveDocument();\n  }\n\n  /**\n   * @typedef {Object} PageInfo\n   * @property {null|Uint8Array} document\n   * @property {Array<Array<number>|number>} [includePages]\n   *  included ranges or indices.\n   * @property {Array<Array<number>|number>} [excludePages]\n   *  excluded ranges or indices.\n   */\n\n  /**\n   * @param {Array<PageInfo>} pageInfos - The pages to extract.\n   * @returns {Promise<Uint8Array>} A promise that is resolved with a\n   *   {Uint8Array} containing the full data of the saved document.\n   */\n  extractPages(pageInfos) {\n    return this._transport.extractPages(pageInfos);\n  }\n\n  /**\n   * @returns {Promise<{ length: number }>} A promise that is resolved when the\n   *   document's data is loaded. It is resolved with an {Object} that contains\n   *   the `length` property that indicates size of the PDF data in bytes.\n   */\n  getDownloadInfo() {\n    return this._transport.downloadInfoCapability.promise;\n  }\n\n  /**\n   * Cleans up resources allocated by the document on both the main and worker\n   * threads.\n   *\n   * NOTE: Do not, under any circumstances, call this method when rendering is\n   * currently ongoing since that may lead to rendering errors.\n   *\n   * @param {boolean} [keepLoadedFonts] - Let fonts remain attached to the DOM.\n   *   NOTE: This will increase persistent memory usage, hence don't use this\n   *   option unless absolutely necessary. The default value is `false`.\n   * @returns {Promise} A promise that is resolved when clean-up has finished.\n   */\n  cleanup(keepLoadedFonts = false) {\n    return this._transport.startCleanup(keepLoadedFonts || this.isPureXfa);\n  }\n\n  /**\n   * Destroys the current document instance and terminates the worker.\n   */\n  destroy() {\n    return this.loadingTask.destroy();\n  }\n\n  /**\n   * @param {RefProxy} ref - The page reference.\n   * @returns {number | null} The page number, if it's cached.\n   */\n  cachedPageNumber(ref) {\n    return this._transport.cachedPageNumber(ref);\n  }\n\n  /**\n   * @type {DocumentInitParameters} A subset of the current\n   *   {DocumentInitParameters}, which are needed in the viewer.\n   */\n  get loadingParams() {\n    return this._transport.loadingParams;\n  }\n\n  /**\n   * @type {PDFDocumentLoadingTask} The loadingTask for the current document.\n   */\n  get loadingTask() {\n    return this._transport.loadingTask;\n  }\n\n  /**\n   * @returns {Promise<Object<string, Array<Object>> | null>} A promise that is\n   *   resolved with an {Object} containing /AcroForm field data for the JS\n   *   sandbox, or `null` when no field data is present in the PDF file.\n   */\n  getFieldObjects() {\n    return this._transport.getFieldObjects();\n  }\n\n  /**\n   * @returns {Promise<boolean>} A promise that is resolved with `true`\n   *   if some /AcroForm fields have JavaScript actions.\n   */\n  hasJSActions() {\n    return this._transport.hasJSActions();\n  }\n\n  /**\n   * @returns {Promise<Array<string> | null>} A promise that is resolved with an\n   *   {Array<string>} containing IDs of annotations that have a calculation\n   *   action, or `null` when no such annotations are present in the PDF file.\n   */\n  getCalculationOrderIds() {\n    return this._transport.getCalculationOrderIds();\n  }\n}\n\n/**\n * Page getViewport parameters.\n *\n * @typedef {Object} GetViewportParameters\n * @property {number} scale - The desired scale of the viewport.\n * @property {number} [rotation] - The desired rotation, in degrees, of\n *   the viewport. If omitted it defaults to the page rotation.\n * @property {number} [offsetX] - The horizontal, i.e. x-axis, offset.\n *   The default value is `0`.\n * @property {number} [offsetY] - The vertical, i.e. y-axis, offset.\n *   The default value is `0`.\n * @property {boolean} [dontFlip] - If true, the y-axis will not be\n *   flipped. The default value is `false`.\n */\n\n/**\n * Page getTextContent parameters.\n *\n * @typedef {Object} getTextContentParameters\n * @property {boolean} [includeMarkedContent] - When true include marked\n *   content items in the items array of TextContent. The default is `false`.\n * @property {boolean} [disableNormalization] - When true the text is *not*\n *   normalized in the worker-thread. The default is `false`.\n */\n\n/**\n * Page text content.\n *\n * @typedef {Object} TextContent\n * @property {Array<TextItem | TextMarkedContent>} items - Array of\n *   {@link TextItem} and {@link TextMarkedContent} objects. TextMarkedContent\n *   items are included when includeMarkedContent is true.\n * @property {Object<string, TextStyle>} styles - {@link TextStyle} objects,\n *   indexed by font name.\n * @property {string | null} lang - The document /Lang attribute.\n */\n\n/**\n * Page text content part.\n *\n * @typedef {Object} TextItem\n * @property {string} str - Text content.\n * @property {string} dir - Text direction: 'ttb', 'ltr' or 'rtl'.\n * @property {Array<any>} transform - Transformation matrix.\n * @property {number} width - Width in device space.\n * @property {number} height - Height in device space.\n * @property {string} fontName - Font name used by PDF.js for converted font.\n * @property {boolean} hasEOL - Indicating if the text content is followed by a\n *   line-break.\n */\n\n/**\n * Page text marked content part.\n *\n * @typedef {Object} TextMarkedContent\n * @property {string} type - Either 'beginMarkedContent',\n *   'beginMarkedContentProps', or 'endMarkedContent'.\n * @property {string} id - The marked content identifier. Only used for type\n *   'beginMarkedContentProps'.\n */\n\n/**\n * Text style.\n *\n * @typedef {Object} TextStyle\n * @property {number} ascent - Font ascent.\n * @property {number} descent - Font descent.\n * @property {boolean} vertical - Whether or not the text is in vertical mode.\n * @property {string} fontFamily - The possible font family.\n */\n\n/**\n * Page annotation parameters.\n *\n * @typedef {Object} GetAnnotationsParameters\n * @property {string} [intent] - Determines the annotations that are fetched,\n *   can be 'display' (viewable annotations), 'print' (printable annotations),\n *   or 'any' (all annotations). The default value is 'display'.\n */\n\n/**\n * Page render parameters.\n *\n * @typedef {Object} RenderParameters\n * @property {HTMLCanvasElement|null} canvas - A DOM Canvas object. The default\n *   value is the canvas associated with the `canvasContext` parameter if no\n *   value is provided explicitly.\n * @property {PageViewport} viewport - Rendering viewport obtained by calling\n *   the `PDFPageProxy.getViewport` method.\n * @property {CanvasRenderingContext2D} [canvasContext] - 2D context of a DOM\n *   Canvas object for backwards compatibility; it is recommended to use the\n *   `canvas` parameter instead.\n *   If the context must absolutely be used to render the page, the canvas must\n *   be null.\n * @property {string} [intent] - Rendering intent, can be 'display', 'print',\n *   or 'any'. The default value is 'display'.\n * @property {number} [annotationMode] Controls which annotations are rendered\n *   onto the canvas, for annotations with appearance-data; the values from\n *   {@link AnnotationMode} should be used. The following values are supported:\n *    - `AnnotationMode.DISABLE`, which disables all annotations.\n *    - `AnnotationMode.ENABLE`, which includes all possible annotations (thus\n *      it also depends on the `intent`-option, see above).\n *    - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain\n *      interactive form elements (those will be rendered in the display layer).\n *    - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations\n *      (as above) but where interactive form elements are updated with data\n *      from the {@link AnnotationStorage}-instance; useful e.g. for printing.\n *   The default value is `AnnotationMode.ENABLE`.\n * @property {Array<any>} [transform] - Additional transform, applied just\n *   before viewport transform.\n * @property {CanvasGradient | CanvasPattern | string} [background] - Background\n *   to use for the canvas.\n *   Any valid `canvas.fillStyle` can be used: a `DOMString` parsed as CSS\n *   <color> value, a `CanvasGradient` object (a linear or radial gradient) or\n *   a `CanvasPattern` object (a repetitive image). The default value is\n *   'rgb(255,255,255)'.\n *\n *   NOTE: This option may be partially, or completely, ignored when the\n *   `pageColors`-option is used.\n * @property {Object} [pageColors] - Overwrites background and foreground colors\n *   with user defined ones in order to improve readability in high contrast\n *   mode.\n * @property {Promise<OptionalContentConfig>} [optionalContentConfigPromise] -\n *   A promise that should resolve with an {@link OptionalContentConfig}\n *   created from `PDFDocumentProxy.getOptionalContentConfig`. If `null`,\n *   the configuration will be fetched automatically with the default visibility\n *   states set.\n * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap] - Map some\n *   annotation ids with canvases used to render them.\n * @property {PrintAnnotationStorage} [printAnnotationStorage]\n * @property {boolean} [isEditing] - Render the page in editing mode.\n * @property {boolean} [recordOperations] - Record the dependencies and bounding\n *   boxes of all PDF operations that render onto the canvas.\n * @property {OperationsFilter} [operationsFilter] - If provided, only\n *   run for which this function returns `true`.\n */\n\n/**\n * @callback OperationsFilter\n * @param {number} index - The index of the operation.\n * @returns {boolean} If false, the operation is ignored.\n */\n\n/**\n * Page getOperatorList parameters.\n *\n * @typedef {Object} GetOperatorListParameters\n * @property {string} [intent] - Rendering intent, can be 'display', 'print',\n *   or 'any'. The default value is 'display'.\n * @property {number} [annotationMode] Controls which annotations are included\n *   in the operatorList, for annotations with appearance-data; the values from\n *   {@link AnnotationMode} should be used. The following values are supported:\n *    - `AnnotationMode.DISABLE`, which disables all annotations.\n *    - `AnnotationMode.ENABLE`, which includes all possible annotations (thus\n *      it also depends on the `intent`-option, see above).\n *    - `AnnotationMode.ENABLE_FORMS`, which excludes annotations that contain\n *      interactive form elements (those will be rendered in the display layer).\n *    - `AnnotationMode.ENABLE_STORAGE`, which includes all possible annotations\n *      (as above) but where interactive form elements are updated with data\n *      from the {@link AnnotationStorage}-instance; useful e.g. for printing.\n *   The default value is `AnnotationMode.ENABLE`.\n * @property {PrintAnnotationStorage} [printAnnotationStorage]\n * @property {boolean} [isEditing] - Render the page in editing mode.\n */\n\n/**\n * Structure tree node. The root node will have a role \"Root\".\n *\n * @typedef {Object} StructTreeNode\n * @property {Array<StructTreeNode | StructTreeContent>} children - Array of\n *   {@link StructTreeNode} and {@link StructTreeContent} objects.\n * @property {string} role - element's role, already mapped if a role map exists\n * in the PDF.\n */\n\n/**\n * Structure tree content.\n *\n * @typedef {Object} StructTreeContent\n * @property {string} type - either \"content\" for page and stream structure\n *   elements or \"object\" for object references.\n * @property {string} id - unique id that will map to the text layer.\n */\n\n/**\n * PDF page operator list.\n *\n * @typedef {Object} PDFOperatorList\n * @property {Array<number>} fnArray - Array containing the operator functions.\n * @property {Array<any>} argsArray - Array containing the arguments of the\n *   functions.\n */\n\n/**\n * Proxy to a `PDFPage` in the worker thread.\n */\nclass PDFPageProxy {\n  #pendingCleanup = false;\n\n  #pagesMapper = null;\n\n  constructor(pageIndex, pageInfo, transport, pagesMapper, pdfBug = false) {\n    this._pageIndex = pageIndex;\n    this._pageInfo = pageInfo;\n    this._transport = transport;\n    this._stats = pdfBug ? new StatTimer() : null;\n    this._pdfBug = pdfBug;\n    /** @type {PDFObjects} */\n    this.commonObjs = transport.commonObjs;\n    this.objs = new PDFObjects();\n\n    this._intentStates = new Map();\n    this.destroyed = false;\n    this.recordedBBoxes = null;\n    this.#pagesMapper = pagesMapper;\n  }\n\n  /**\n   * @type {number} Page number of the page. First page is 1.\n   */\n  get pageNumber() {\n    return this._pageIndex + 1;\n  }\n\n  /**\n   * @param {number} value - The page number to set. First page is 1.\n   */\n  set pageNumber(value) {\n    this._pageIndex = value - 1;\n  }\n\n  /**\n   * @type {number} The number of degrees the page is rotated clockwise.\n   */\n  get rotate() {\n    return this._pageInfo.rotate;\n  }\n\n  /**\n   * @type {RefProxy | null} The reference that points to this page.\n   */\n  get ref() {\n    return this._pageInfo.ref;\n  }\n\n  /**\n   * @type {number} The default size of units in 1/72nds of an inch.\n   */\n  get userUnit() {\n    return this._pageInfo.userUnit;\n  }\n\n  /**\n   * @type {Array<number>} An array of the visible portion of the PDF page in\n   *   user space units [x1, y1, x2, y2].\n   */\n  get view() {\n    return this._pageInfo.view;\n  }\n\n  /**\n   * @param {GetViewportParameters} params - Viewport parameters.\n   * @returns {PageViewport} Contains 'width' and 'height' properties\n   *   along with transforms required for rendering.\n   */\n  getViewport({\n    scale,\n    rotation = this.rotate,\n    offsetX = 0,\n    offsetY = 0,\n    dontFlip = false,\n  } = {}) {\n    return new PageViewport({\n      viewBox: this.view,\n      userUnit: this.userUnit,\n      scale,\n      rotation,\n      offsetX,\n      offsetY,\n      dontFlip,\n    });\n  }\n\n  /**\n   * @param {GetAnnotationsParameters} [params] - Annotation parameters.\n   * @returns {Promise<Array<any>>} A promise that is resolved with an\n   *   {Array} of the annotation objects.\n   */\n  getAnnotations({ intent = \"display\" } = {}) {\n    const { renderingIntent } = this._transport.getRenderingIntent(intent);\n\n    return this._transport.getAnnotations(this._pageIndex, renderingIntent);\n  }\n\n  /**\n   * @returns {Promise<Object>} A promise that is resolved with an\n   *   {Object} with JS actions.\n   */\n  getJSActions() {\n    return this._transport.getPageJSActions(this._pageIndex);\n  }\n\n  /**\n   * @type {Object} The filter factory instance.\n   */\n  get filterFactory() {\n    return this._transport.filterFactory;\n  }\n\n  /**\n   * @type {boolean} True if only XFA form.\n   */\n  get isPureXfa() {\n    return shadow(this, \"isPureXfa\", !!this._transport._htmlForXfa);\n  }\n\n  /**\n   * @returns {Promise<Object | null>} A promise that is resolved with\n   *   an {Object} with a fake DOM object (a tree structure where elements\n   *   are {Object} with a name, attributes (class, style, ...), value and\n   *   children, very similar to a HTML DOM tree), or `null` if no XFA exists.\n   */\n  async getXfa() {\n    return this._transport._htmlForXfa?.children[this._pageIndex] || null;\n  }\n\n  /**\n   * Begins the process of rendering a page to the desired context.\n   *\n   * @param {RenderParameters} params - Page render parameters.\n   * @returns {RenderTask} An object that contains a promise that is\n   *   resolved when the page finishes rendering.\n   */\n  render({\n    canvasContext,\n    canvas = canvasContext.canvas,\n    viewport,\n    intent = \"display\",\n    annotationMode = AnnotationMode.ENABLE,\n    transform = null,\n    background = null,\n    optionalContentConfigPromise = null,\n    annotationCanvasMap = null,\n    pageColors = null,\n    printAnnotationStorage = null,\n    isEditing = false,\n    recordOperations = false,\n    operationsFilter = null,\n  }) {\n    this._stats?.time(\"Overall\");\n\n    const intentArgs = this._transport.getRenderingIntent(\n      intent,\n      annotationMode,\n      printAnnotationStorage,\n      isEditing\n    );\n    const { renderingIntent, cacheKey } = intentArgs;\n    // If there was a pending destroy, cancel it so no cleanup happens during\n    // this call to render.\n    this.#pendingCleanup = false;\n\n    optionalContentConfigPromise ||=\n      this._transport.getOptionalContentConfig(renderingIntent);\n\n    const intentState = this._intentStates.getOrInsertComputed(\n      cacheKey,\n      makeObj\n    );\n    // Ensure that a pending `streamReader` cancel timeout is always aborted.\n    if (intentState.streamReaderCancelTimeout) {\n      clearTimeout(intentState.streamReaderCancelTimeout);\n      intentState.streamReaderCancelTimeout = null;\n    }\n\n    const intentPrint = !!(renderingIntent & RenderingIntentFlag.PRINT);\n\n    // If there's no displayReadyCapability yet, then the operatorList\n    // was never requested before. Make the request and create the promise.\n    if (!intentState.displayReadyCapability) {\n      intentState.displayReadyCapability = Promise.withResolvers();\n      intentState.operatorList = {\n        fnArray: [],\n        argsArray: [],\n        lastChunk: false,\n        separateAnnots: null,\n      };\n\n      this._stats?.time(\"Page Request\");\n      this._pumpOperatorList(intentArgs);\n    }\n\n    const recordForDebugger = Boolean(\n      this._pdfBug && globalThis.StepperManager?.enabled\n    );\n\n    const shouldRecordOperations =\n      !this.recordedBBoxes && (recordOperations || recordForDebugger);\n\n    const complete = error => {\n      intentState.renderTasks.delete(internalRenderTask);\n\n      if (shouldRecordOperations) {\n        const recordedBBoxes = internalRenderTask.gfx?.dependencyTracker.take();\n        if (recordedBBoxes) {\n          if (internalRenderTask.stepper) {\n            internalRenderTask.stepper.setOperatorBBoxes(\n              recordedBBoxes,\n              internalRenderTask.gfx.dependencyTracker.takeDebugMetadata()\n            );\n          }\n          if (recordOperations) {\n            this.recordedBBoxes = recordedBBoxes;\n          }\n        }\n      }\n\n      // Attempt to reduce memory usage during *printing*, by always running\n      // cleanup immediately once rendering has finished.\n      if (intentPrint) {\n        this.#pendingCleanup = true;\n      }\n      this.#tryCleanup();\n\n      if (error) {\n        internalRenderTask.capability.reject(error);\n\n        this._abortOperatorList({\n          intentState,\n          reason: error instanceof Error ? error : new Error(error),\n        });\n      } else {\n        internalRenderTask.capability.resolve();\n      }\n\n      if (this._stats) {\n        this._stats.timeEnd(\"Rendering\");\n        this._stats.timeEnd(\"Overall\");\n\n        if (globalThis.Stats?.enabled) {\n          globalThis.Stats.add(this.pageNumber, this._stats);\n        }\n      }\n    };\n\n    const internalRenderTask = new InternalRenderTask({\n      callback: complete,\n      // Only include the required properties, and *not* the entire object.\n      params: {\n        canvas,\n        canvasContext,\n        dependencyTracker: shouldRecordOperations\n          ? new CanvasDependencyTracker(\n              canvas,\n              intentState.operatorList.length,\n              recordForDebugger\n            )\n          : null,\n        viewport,\n        transform,\n        background,\n      },\n      objs: this.objs,\n      commonObjs: this.commonObjs,\n      annotationCanvasMap,\n      operatorList: intentState.operatorList,\n      pageIndex: this._pageIndex,\n      canvasFactory: this._transport.canvasFactory,\n      filterFactory: this._transport.filterFactory,\n      useRequestAnimationFrame: !intentPrint,\n      pdfBug: this._pdfBug,\n      pageColors,\n      enableHWA: this._transport.enableHWA,\n      operationsFilter,\n    });\n\n    (intentState.renderTasks ||= new Set()).add(internalRenderTask);\n    const renderTask = internalRenderTask.task;\n\n    Promise.all([\n      intentState.displayReadyCapability.promise,\n      optionalContentConfigPromise,\n    ])\n      .then(([transparency, optionalContentConfig]) => {\n        if (this.destroyed) {\n          complete();\n          return;\n        }\n        this._stats?.time(\"Rendering\");\n\n        if (!(optionalContentConfig.renderingIntent & renderingIntent)) {\n          throw new Error(\n            \"Must use the same `intent`-argument when calling the `PDFPageProxy.render` \" +\n              \"and `PDFDocumentProxy.getOptionalContentConfig` methods.\"\n          );\n        }\n        internalRenderTask.initializeGraphics({\n          transparency,\n          optionalContentConfig,\n        });\n        internalRenderTask.operatorListChanged();\n      })\n      .catch(complete);\n\n    return renderTask;\n  }\n\n  /**\n   * @param {GetOperatorListParameters} params - Page getOperatorList\n   *   parameters.\n   * @returns {Promise<PDFOperatorList>} A promise resolved with an\n   *   {@link PDFOperatorList} object that represents the page's operator list.\n   */\n  getOperatorList({\n    intent = \"display\",\n    annotationMode = AnnotationMode.ENABLE,\n    printAnnotationStorage = null,\n    isEditing = false,\n  } = {}) {\n    if (typeof PDFJSDev !== \"undefined\" && !PDFJSDev.test(\"GENERIC\")) {\n      throw new Error(\"Not implemented: getOperatorList\");\n    }\n    function operatorListChanged() {\n      if (intentState.operatorList.lastChunk) {\n        intentState.opListReadCapability.resolve(intentState.operatorList);\n\n        intentState.renderTasks.delete(opListTask);\n      }\n    }\n\n    const intentArgs = this._transport.getRenderingIntent(\n      intent,\n      annotationMode,\n      printAnnotationStorage,\n      isEditing,\n      /* isOpList = */ true\n    );\n    const intentState = this._intentStates.getOrInsertComputed(\n      intentArgs.cacheKey,\n      makeObj\n    );\n    let opListTask;\n\n    if (!intentState.opListReadCapability) {\n      opListTask = Object.create(null);\n      opListTask.operatorListChanged = operatorListChanged;\n      intentState.opListReadCapability = Promise.withResolvers();\n      (intentState.renderTasks ||= new Set()).add(opListTask);\n      intentState.operatorList = {\n        fnArray: [],\n        argsArray: [],\n        lastChunk: false,\n        separateAnnots: null,\n      };\n\n      this._stats?.time(\"Page Request\");\n      this._pumpOperatorList(intentArgs);\n    }\n    return intentState.opListReadCapability.promise;\n  }\n\n  /**\n   * NOTE: All occurrences of whitespace will be replaced by\n   * standard spaces (0x20).\n   *\n   * @param {getTextContentParameters} params - getTextContent parameters.\n   * @returns {ReadableStream} Stream for reading text content chunks.\n   */\n  streamTextContent({\n    includeMarkedContent = false,\n    disableNormalization = false,\n  } = {}) {\n    const TEXT_CONTENT_CHUNK_SIZE = 100;\n\n    return this._transport.messageHandler.sendWithStream(\n      \"GetTextContent\",\n      {\n        pageId: this.#pagesMapper.getPageId(this._pageIndex + 1) - 1,\n        pageIndex: this._pageIndex,\n        includeMarkedContent: includeMarkedContent === true,\n        disableNormalization: disableNormalization === true,\n      },\n      {\n        highWaterMark: TEXT_CONTENT_CHUNK_SIZE,\n        size(textContent) {\n          return textContent.items.length;\n        },\n      }\n    );\n  }\n\n  /**\n   * NOTE: All occurrences of whitespace will be replaced by\n   * standard spaces (0x20).\n   *\n   * @param {getTextContentParameters} params - getTextContent parameters.\n   * @returns {Promise<TextContent>} A promise that is resolved with a\n   *   {@link TextContent} object that represents the page's text content.\n   */\n  async getTextContent(params = {}) {\n    if (this._transport._htmlForXfa) {\n      // TODO: We need to revisit this once the XFA foreground patch lands and\n      // only do this for non-foreground XFA.\n      return this.getXfa().then(xfa => XfaText.textContent(xfa));\n    }\n    const readableStream = this.streamTextContent(params);\n\n    const textContent = {\n      items: [],\n      styles: Object.create(null),\n      lang: null,\n    };\n\n    for await (const value of readableStream) {\n      textContent.lang ??= value.lang;\n      Object.assign(textContent.styles, value.styles);\n      textContent.items.push(...value.items);\n    }\n    return textContent;\n  }\n\n  /**\n   * @returns {Promise<StructTreeNode>} A promise that is resolved with a\n   *   {@link StructTreeNode} object that represents the page's structure tree,\n   *   or `null` when no structure tree is present for the current page.\n   */\n  getStructTree() {\n    return this._transport.getStructTree(this._pageIndex);\n  }\n\n  /**\n   * Destroys the page object.\n   * @private\n   */\n  _destroy() {\n    this.destroyed = true;\n\n    const waitOn = [];\n    for (const intentState of this._intentStates.values()) {\n      this._abortOperatorList({\n        intentState,\n        reason: new Error(\"Page was destroyed.\"),\n        force: true,\n      });\n\n      if (intentState.opListReadCapability) {\n        // Avoid errors below, since the renderTasks are just stubs.\n        continue;\n      }\n      for (const internalRenderTask of intentState.renderTasks) {\n        waitOn.push(internalRenderTask.completed);\n        internalRenderTask.cancel();\n      }\n    }\n    this.objs.clear();\n    this.#pendingCleanup = false;\n\n    return Promise.all(waitOn);\n  }\n\n  /**\n   * Cleans up resources allocated by the page.\n   *\n   * @param {boolean} [resetStats] - Reset page stats, if enabled.\n   *   The default value is `false`.\n   * @returns {boolean} Indicates if clean-up was successfully run.\n   */\n  cleanup(resetStats = false) {\n    this.#pendingCleanup = true;\n    const success = this.#tryCleanup();\n\n    if (resetStats && success) {\n      this._stats &&= new StatTimer();\n    }\n    return success;\n  }\n\n  /**\n   * Attempts to clean up if rendering is in a state where that's possible.\n   * @returns {boolean} Indicates if clean-up was successfully run.\n   */\n  #tryCleanup() {\n    if (!this.#pendingCleanup || this.destroyed) {\n      return false;\n    }\n    for (const { renderTasks, operatorList } of this._intentStates.values()) {\n      if (renderTasks.size > 0 || !operatorList.lastChunk) {\n        return false;\n      }\n    }\n    this._intentStates.clear();\n    this.objs.clear();\n    this.#pendingCleanup = false;\n    return true;\n  }\n\n  /**\n   * @private\n   */\n  _startRenderPage(transparency, cacheKey) {\n    const intentState = this._intentStates.get(cacheKey);\n    if (!intentState) {\n      return; // Rendering was cancelled.\n    }\n    this._stats?.timeEnd(\"Page Request\");\n\n    // TODO Refactor RenderPageRequest to separate rendering\n    // and operator list logic\n    intentState.displayReadyCapability?.resolve(transparency);\n  }\n\n  /**\n   * @private\n   */\n  _renderPageChunk(operatorListChunk, intentState) {\n    // Add the new chunk to the current operator list.\n    for (let i = 0, ii = operatorListChunk.length; i < ii; i++) {\n      intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);\n      intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);\n    }\n    intentState.operatorList.lastChunk = operatorListChunk.lastChunk;\n    intentState.operatorList.separateAnnots = operatorListChunk.separateAnnots;\n\n    // Notify all the rendering tasks there are more operators to be consumed.\n    for (const internalRenderTask of intentState.renderTasks) {\n      internalRenderTask.operatorListChanged();\n    }\n\n    if (operatorListChunk.lastChunk) {\n      this.#tryCleanup();\n    }\n  }\n\n  /**\n   * @private\n   */\n  _pumpOperatorList({\n    renderingIntent,\n    cacheKey,\n    annotationStorageSerializable,\n    modifiedIds,\n  }) {\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      assert(\n        Number.isInteger(renderingIntent) && renderingIntent > 0,\n        '_pumpOperatorList: Expected valid \"renderingIntent\" argument.'\n      );\n    }\n    const { map, transfer } = annotationStorageSerializable;\n\n    const readableStream = this._transport.messageHandler.sendWithStream(\n      \"GetOperatorList\",\n      {\n        pageId: this.#pagesMapper.getPageId(this._pageIndex + 1) - 1,\n        pageIndex: this._pageIndex,\n        intent: renderingIntent,\n        cacheKey,\n        annotationStorage: map,\n        modifiedIds,\n      },\n      /* queueingStrategy = */ undefined,\n      transfer\n    );\n    const reader = readableStream.getReader();\n\n    const intentState = this._intentStates.get(cacheKey);\n    intentState.streamReader = reader;\n\n    const pump = () => {\n      reader.read().then(\n        ({ value, done }) => {\n          if (done) {\n            intentState.streamReader = null;\n            return;\n          }\n          if (this._transport.destroyed) {\n            return; // Ignore any pending requests if the worker was terminated.\n          }\n          this._renderPageChunk(value, intentState);\n          pump();\n        },\n        reason => {\n          intentState.streamReader = null;\n\n          if (this._transport.destroyed) {\n            return; // Ignore any pending requests if the worker was terminated.\n          }\n          if (intentState.operatorList) {\n            // Mark operator list as complete.\n            intentState.operatorList.lastChunk = true;\n\n            for (const internalRenderTask of intentState.renderTasks) {\n              internalRenderTask.operatorListChanged();\n            }\n            this.#tryCleanup();\n          }\n\n          if (intentState.displayReadyCapability) {\n            intentState.displayReadyCapability.reject(reason);\n          } else if (intentState.opListReadCapability) {\n            intentState.opListReadCapability.reject(reason);\n          } else {\n            throw reason;\n          }\n        }\n      );\n    };\n    pump();\n  }\n\n  /**\n   * @private\n   */\n  _abortOperatorList({ intentState, reason, force = false }) {\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      assert(\n        reason instanceof Error,\n        '_abortOperatorList: Expected valid \"reason\" argument.'\n      );\n    }\n\n    if (!intentState.streamReader) {\n      return;\n    }\n    // Ensure that a pending `streamReader` cancel timeout is always aborted.\n    if (intentState.streamReaderCancelTimeout) {\n      clearTimeout(intentState.streamReaderCancelTimeout);\n      intentState.streamReaderCancelTimeout = null;\n    }\n\n    if (!force) {\n      // Ensure that an Error occurring in *only* one `InternalRenderTask`, e.g.\n      // multiple render() calls on the same canvas, won't break all rendering.\n      if (intentState.renderTasks.size > 0) {\n        return;\n      }\n      // Don't immediately abort parsing on the worker-thread when rendering is\n      // cancelled, since that will unnecessarily delay re-rendering when (for\n      // partially parsed pages) e.g. zooming/rotation occurs in the viewer.\n      if (reason instanceof RenderingCancelledException) {\n        let delay = RENDERING_CANCELLED_TIMEOUT;\n        if (reason.extraDelay > 0 && reason.extraDelay < /* ms = */ 1000) {\n          // Above, we prevent the total delay from becoming arbitrarily large.\n          delay += reason.extraDelay;\n        }\n\n        intentState.streamReaderCancelTimeout = setTimeout(() => {\n          intentState.streamReaderCancelTimeout = null;\n          this._abortOperatorList({ intentState, reason, force: true });\n        }, delay);\n        return;\n      }\n    }\n    intentState.streamReader\n      .cancel(new AbortException(reason.message))\n      .catch(() => {\n        // Avoid \"Uncaught promise\" messages in the console.\n      });\n    intentState.streamReader = null;\n\n    if (this._transport.destroyed) {\n      return; // Ignore any pending requests if the worker was terminated.\n    }\n    // Remove the current `intentState`, since a cancelled `getOperatorList`\n    // call on the worker-thread cannot be re-started...\n    for (const [curCacheKey, curIntentState] of this._intentStates) {\n      if (curIntentState === intentState) {\n        this._intentStates.delete(curCacheKey);\n        break;\n      }\n    }\n    // ... and force clean-up to ensure that any old state is always removed.\n    this.cleanup();\n  }\n\n  /**\n   * @type {StatTimer | null} Returns page stats, if enabled; returns `null`\n   *   otherwise.\n   */\n  get stats() {\n    return this._stats;\n  }\n}\n\n/**\n * @typedef {Object} PDFWorkerParameters\n * @property {string} [name] - The name of the worker.\n * @property {Worker} [port] - The `workerPort` object.\n * @property {number} [verbosity] - Controls the logging level;\n *   the constants from {@link VerbosityLevel} should be used.\n */\n\n/**\n * PDF.js web worker abstraction that controls the instantiation of PDF\n * documents. Message handlers are used to pass information from the main\n * thread to the worker thread and vice versa. If the creation of a web\n * worker is not possible, a \"fake\" worker will be used instead.\n *\n * @param {PDFWorkerParameters} params - The worker initialization parameters.\n */\nclass PDFWorker {\n  #capability = Promise.withResolvers();\n\n  #messageHandler = null;\n\n  #port = null;\n\n  #webWorker = null;\n\n  static #fakeWorkerId = 0;\n\n  static #isWorkerDisabled = false;\n\n  static #workerPorts = new WeakMap();\n\n  static {\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"GENERIC\")) {\n      if (isNodeJS) {\n        // Workers aren't supported in Node.js, force-disabling them there.\n        this.#isWorkerDisabled = true;\n\n        GlobalWorkerOptions.workerSrc ||= PDFJSDev.test(\"LIB\")\n          ? \"../pdf.worker.js\"\n          : \"./pdf.worker.mjs\";\n      }\n\n      // Check if URLs have the same origin. For non-HTTP based URLs, returns\n      // false.\n      this._isSameOrigin = (baseUrl, otherUrl) => {\n        const base = URL.parse(baseUrl);\n        if (!base?.origin || base.origin === \"null\") {\n          return false; // non-HTTP url\n        }\n        const other = new URL(otherUrl, base);\n        return base.origin === other.origin;\n      };\n\n      this._createCDNWrapper = url => {\n        // We will rely on blob URL's property to specify origin.\n        // We want this function to fail in case if createObjectURL or Blob do\n        // not exist or fail for some reason -- our Worker creation will fail\n        // anyway.\n        const wrapper = `await import(\"${url}\");`;\n        return URL.createObjectURL(\n          new Blob([wrapper], { type: \"text/javascript\" })\n        );\n      };\n\n      this.fromPort = params => {\n        deprecated(\n          \"`PDFWorker.fromPort` - please use `PDFWorker.create` instead.\"\n        );\n        if (!params?.port) {\n          throw new Error(\"PDFWorker.fromPort - invalid method signature.\");\n        }\n        return this.create(params);\n      };\n    }\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      this._resetGlobalState = () => {\n        this.#isWorkerDisabled = false;\n        delete globalThis.pdfjsWorker;\n      };\n    }\n  }\n\n  constructor({\n    name = null,\n    port = null,\n    verbosity = getVerbosityLevel(),\n  } = {}) {\n    this.name = name;\n    this.destroyed = false;\n    this.verbosity = verbosity;\n\n    if (port) {\n      if (PDFWorker.#workerPorts.has(port)) {\n        throw new Error(\"Cannot use more than one PDFWorker per port.\");\n      }\n      PDFWorker.#workerPorts.set(port, this);\n      this.#initializeFromPort(port);\n    } else {\n      this.#initialize();\n    }\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      // For testing purposes.\n      Object.defineProperty(this, \"_webWorker\", {\n        get() {\n          return this.#webWorker;\n        },\n      });\n    }\n  }\n\n  /**\n   * Promise for worker initialization completion.\n   * @type {Promise<void>}\n   */\n  get promise() {\n    return this.#capability.promise;\n  }\n\n  #resolve() {\n    this.#capability.resolve();\n    // Send global setting, e.g. verbosity level.\n    this.#messageHandler.send(\"configure\", {\n      verbosity: this.verbosity,\n    });\n  }\n\n  /**\n   * The current `workerPort`, when it exists.\n   * @type {Worker}\n   */\n  get port() {\n    return this.#port;\n  }\n\n  /**\n   * The current MessageHandler-instance.\n   * @type {MessageHandler}\n   */\n  get messageHandler() {\n    return this.#messageHandler;\n  }\n\n  #initializeFromPort(port) {\n    this.#port = port;\n    this.#messageHandler = new MessageHandler(\"main\", \"worker\", port);\n    this.#messageHandler.on(\"ready\", () => {\n      // Ignoring \"ready\" event -- MessageHandler should already be initialized\n      // and ready to accept messages.\n    });\n    this.#resolve();\n  }\n\n  #initialize() {\n    // If worker support isn't disabled explicit and the browser has worker\n    // support, create a new web worker and test if it/the browser fulfills\n    // all requirements to run parts of pdf.js in a web worker.\n    // Right now, the requirement is, that an Uint8Array is still an\n    // Uint8Array as it arrives on the worker.\n    if (\n      PDFWorker.#isWorkerDisabled ||\n      PDFWorker.#mainThreadWorkerMessageHandler\n    ) {\n      this.#setupFakeWorker();\n      return;\n    }\n    let { workerSrc } = PDFWorker;\n\n    try {\n      // Wraps workerSrc path into blob URL, if the former does not belong\n      // to the same origin.\n      if (\n        typeof PDFJSDev !== \"undefined\" &&\n        PDFJSDev.test(\"GENERIC\") &&\n        !PDFWorker._isSameOrigin(window.location, workerSrc)\n      ) {\n        workerSrc = PDFWorker._createCDNWrapper(\n          new URL(workerSrc, window.location).href\n        );\n      }\n\n      const worker = new Worker(workerSrc, { type: \"module\" });\n      const messageHandler = new MessageHandler(\"main\", \"worker\", worker);\n      const terminateEarly = () => {\n        ac.abort();\n        messageHandler.destroy();\n        worker.terminate();\n        if (this.destroyed) {\n          this.#capability.reject(new Error(\"Worker was destroyed\"));\n        } else {\n          // Fall back to fake worker if the termination is caused by an\n          // error (e.g. NetworkError / SecurityError).\n          this.#setupFakeWorker();\n        }\n      };\n\n      const ac = new AbortController();\n      worker.addEventListener(\n        \"error\",\n        () => {\n          if (!this.#webWorker) {\n            // Worker failed to initialize due to an error. Clean up and fall\n            // back to the fake worker.\n            terminateEarly();\n          }\n        },\n        { signal: ac.signal }\n      );\n\n      messageHandler.on(\"test\", data => {\n        ac.abort();\n        if (this.destroyed || !data) {\n          terminateEarly();\n          return;\n        }\n        this.#messageHandler = messageHandler;\n        this.#port = worker;\n        this.#webWorker = worker;\n\n        this.#resolve();\n      });\n\n      messageHandler.on(\"ready\", data => {\n        ac.abort();\n        if (this.destroyed) {\n          terminateEarly();\n          return;\n        }\n        try {\n          sendTest();\n        } catch {\n          // We need fallback to a faked worker.\n          this.#setupFakeWorker();\n        }\n      });\n\n      const sendTest = () => {\n        const testObj = new Uint8Array();\n        // Ensure that we can use `postMessage` transfers.\n        messageHandler.send(\"test\", testObj, [testObj.buffer]);\n      };\n\n      // It might take time for the worker to initialize. We will try to send\n      // the \"test\" message immediately, and once the \"ready\" message arrives.\n      // The worker shall process only the first received \"test\" message.\n      sendTest();\n      return;\n    } catch {\n      info(\"The worker has been disabled.\");\n    }\n    // Either workers are not supported or have thrown an exception.\n    // Thus, we fallback to a faked worker.\n    this.#setupFakeWorker();\n  }\n\n  #setupFakeWorker() {\n    if (!PDFWorker.#isWorkerDisabled) {\n      warn(\"Setting up fake worker.\");\n      PDFWorker.#isWorkerDisabled = true;\n    }\n\n    PDFWorker._setupFakeWorkerGlobal\n      .then(WorkerMessageHandler => {\n        if (this.destroyed) {\n          this.#capability.reject(new Error(\"Worker was destroyed\"));\n          return;\n        }\n        const port = new LoopbackPort();\n        this.#port = port;\n\n        // All fake workers use the same port, making id unique.\n        const id = `fake${PDFWorker.#fakeWorkerId++}`;\n\n        // If the main thread is our worker, setup the handling for the\n        // messages -- the main thread sends to it self.\n        const workerHandler = new MessageHandler(id + \"_worker\", id, port);\n        WorkerMessageHandler.setup(workerHandler, port);\n\n        this.#messageHandler = new MessageHandler(id, id + \"_worker\", port);\n        this.#resolve();\n      })\n      .catch(reason => {\n        this.#capability.reject(\n          new Error(`Setting up fake worker failed: \"${reason.message}\".`)\n        );\n      });\n  }\n\n  /**\n   * Destroys the worker instance.\n   */\n  destroy() {\n    this.destroyed = true;\n\n    // We need to terminate only web worker created resource.\n    this.#webWorker?.terminate();\n    this.#webWorker = null;\n\n    PDFWorker.#workerPorts.delete(this.#port);\n    this.#port = null;\n\n    this.#messageHandler?.destroy();\n    this.#messageHandler = null;\n  }\n\n  /**\n   * @param {PDFWorkerParameters} params - The worker initialization parameters.\n   * @returns {PDFWorker}\n   */\n  static create(params) {\n    const cachedPort = this.#workerPorts.get(params?.port);\n    if (cachedPort) {\n      if (cachedPort._pendingDestroy) {\n        throw new Error(\n          \"PDFWorker.create - the worker is being destroyed.\\n\" +\n            \"Please remember to await `PDFDocumentLoadingTask.destroy()`-calls.\"\n        );\n      }\n      return cachedPort;\n    }\n    return new PDFWorker(params);\n  }\n\n  /**\n   * The current `workerSrc`, when it exists.\n   * @type {string}\n   */\n  static get workerSrc() {\n    if (GlobalWorkerOptions.workerSrc) {\n      return GlobalWorkerOptions.workerSrc;\n    }\n    throw new Error('No \"GlobalWorkerOptions.workerSrc\" specified.');\n  }\n\n  static get #mainThreadWorkerMessageHandler() {\n    try {\n      return globalThis.pdfjsWorker?.WorkerMessageHandler || null;\n    } catch {\n      return null;\n    }\n  }\n\n  // Loads worker code into the main-thread.\n  static get _setupFakeWorkerGlobal() {\n    const loader = async () => {\n      if (this.#mainThreadWorkerMessageHandler) {\n        // The worker was already loaded using e.g. a `<script>` tag.\n        return this.#mainThreadWorkerMessageHandler;\n      }\n      const worker =\n        typeof PDFJSDev === \"undefined\"\n          ? await import(\"pdfjs/pdf.worker.js\")\n          : await __raw_import__(this.workerSrc);\n      return worker.WorkerMessageHandler;\n    };\n\n    return shadow(this, \"_setupFakeWorkerGlobal\", loader());\n  }\n}\n\n/**\n * For internal use only.\n * @ignore\n */\nclass WorkerTransport {\n  downloadInfoCapability = Promise.withResolvers();\n\n  #fullReader = null;\n\n  #methodPromises = new Map();\n\n  #networkStream = null;\n\n  #pageCache = new Map();\n\n  #pagePromises = new Map();\n\n  #pageRefCache = new Map();\n\n  #passwordCapability = null;\n\n  #copiedPageInfo = null;\n\n  constructor(\n    messageHandler,\n    loadingTask,\n    networkStream,\n    params,\n    factory,\n    pagesMapper\n  ) {\n    this.messageHandler = messageHandler;\n    this.loadingTask = loadingTask;\n    this.#networkStream = networkStream;\n\n    this.commonObjs = new PDFObjects();\n    this.fontLoader = new FontLoader({\n      ownerDocument: params.ownerDocument,\n      styleElement: params.styleElement,\n    });\n    this.enableHWA = params.enableHWA;\n    this.loadingParams = params.loadingParams;\n    this._params = params;\n\n    this.canvasFactory = factory.canvasFactory;\n    this.filterFactory = factory.filterFactory;\n    this.cMapReaderFactory = factory.cMapReaderFactory;\n    this.standardFontDataFactory = factory.standardFontDataFactory;\n    this.wasmFactory = factory.wasmFactory;\n\n    this.destroyed = false;\n    this.destroyCapability = null;\n\n    this.setupMessageHandler();\n\n    this.pagesMapper = pagesMapper;\n    this.pagesMapper.addListener(this.#updateCaches.bind(this));\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      // For testing purposes.\n      Object.defineProperty(this, \"getNetworkStreamName\", {\n        value: () => networkStream?.constructor?.name || null,\n      });\n      Object.defineProperty(this, \"getXFADatasets\", {\n        value: () =>\n          this.messageHandler.sendWithPromise(\"GetXFADatasets\", null),\n      });\n      Object.defineProperty(this, \"getXRefPrevValue\", {\n        value: () =>\n          this.messageHandler.sendWithPromise(\"GetXRefPrevValue\", null),\n      });\n      Object.defineProperty(this, \"getStartXRefPos\", {\n        value: () =>\n          this.messageHandler.sendWithPromise(\"GetStartXRefPos\", null),\n      });\n      Object.defineProperty(this, \"getAnnotArray\", {\n        value: pageIndex =>\n          this.messageHandler.sendWithPromise(\"GetAnnotArray\", { pageIndex }),\n      });\n    }\n  }\n\n  #updateCaches({ type, pageNumbers }) {\n    if (type === \"copy\") {\n      this.#copiedPageInfo = new Map();\n      for (const pageNum of pageNumbers) {\n        this.#copiedPageInfo.set(pageNum, {\n          proxy: this.#pageCache.get(pageNum - 1) || null,\n          promise: this.#pagePromises.get(pageNum - 1) || null,\n        });\n      }\n      return;\n    }\n\n    if (type === \"delete\") {\n      for (const pageNum of pageNumbers) {\n        this.#pageCache.delete(pageNum - 1);\n        this.#pagePromises.delete(pageNum - 1);\n      }\n    }\n\n    const newPageCache = new Map();\n    const newPromiseCache = new Map();\n    const { pagesMapper } = this;\n    for (let i = 0, ii = pagesMapper.pagesNumber; i < ii; i++) {\n      const prevPageNumber = pagesMapper.getPrevPageNumber(i + 1);\n      if (prevPageNumber < 0) {\n        const { proxy, promise } =\n          this.#copiedPageInfo?.get(-prevPageNumber) || {};\n        if (proxy) {\n          newPageCache.set(i, proxy);\n        }\n        if (promise) {\n          newPromiseCache.set(i, promise);\n        }\n        continue;\n      }\n      const prevPageIndex = prevPageNumber - 1;\n      const page = this.#pageCache.get(prevPageIndex);\n      if (page) {\n        newPageCache.set(i, page);\n      }\n      const promise = this.#pagePromises.get(prevPageIndex);\n      if (promise) {\n        newPromiseCache.set(i, promise);\n      }\n    }\n    this.#pageCache = newPageCache;\n    this.#pagePromises = newPromiseCache;\n  }\n\n  #cacheSimpleMethod(name, data = null) {\n    return this.#methodPromises.getOrInsertComputed(name, () =>\n      this.messageHandler.sendWithPromise(name, data)\n    );\n  }\n\n  #onProgress({ loaded, total }) {\n    this.loadingTask.onProgress?.({\n      loaded,\n      total,\n      percent: MathClamp(Math.round((loaded / total) * 100), 0, 100),\n    });\n  }\n\n  get annotationStorage() {\n    return shadow(this, \"annotationStorage\", new AnnotationStorage());\n  }\n\n  getRenderingIntent(\n    intent,\n    annotationMode = AnnotationMode.ENABLE,\n    printAnnotationStorage = null,\n    isEditing = false,\n    isOpList = false\n  ) {\n    let renderingIntent = RenderingIntentFlag.DISPLAY; // Default value.\n    let annotationStorageSerializable = SerializableEmpty;\n\n    switch (intent) {\n      case \"any\":\n        renderingIntent = RenderingIntentFlag.ANY;\n        break;\n      case \"display\":\n        break;\n      case \"print\":\n        renderingIntent = RenderingIntentFlag.PRINT;\n        break;\n      default:\n        warn(`getRenderingIntent - invalid intent: ${intent}`);\n    }\n\n    const annotationStorage =\n      renderingIntent & RenderingIntentFlag.PRINT &&\n      printAnnotationStorage instanceof PrintAnnotationStorage\n        ? printAnnotationStorage\n        : this.annotationStorage;\n\n    switch (annotationMode) {\n      case AnnotationMode.DISABLE:\n        renderingIntent += RenderingIntentFlag.ANNOTATIONS_DISABLE;\n        break;\n      case AnnotationMode.ENABLE:\n        break;\n      case AnnotationMode.ENABLE_FORMS:\n        renderingIntent += RenderingIntentFlag.ANNOTATIONS_FORMS;\n        break;\n      case AnnotationMode.ENABLE_STORAGE:\n        renderingIntent += RenderingIntentFlag.ANNOTATIONS_STORAGE;\n\n        annotationStorageSerializable = annotationStorage.serializable;\n        break;\n      default:\n        warn(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);\n    }\n\n    if (isEditing) {\n      renderingIntent += RenderingIntentFlag.IS_EDITING;\n    }\n    if (isOpList) {\n      renderingIntent += RenderingIntentFlag.OPLIST;\n    }\n\n    const { ids: modifiedIds, hash: modifiedIdsHash } =\n      annotationStorage.modifiedIds;\n\n    const cacheKeyBuf = [\n      renderingIntent,\n      annotationStorageSerializable.hash,\n      modifiedIdsHash,\n    ];\n\n    return {\n      renderingIntent,\n      cacheKey: cacheKeyBuf.join(\"_\"),\n      annotationStorageSerializable,\n      modifiedIds,\n    };\n  }\n\n  destroy() {\n    if (this.destroyCapability) {\n      return this.destroyCapability.promise;\n    }\n\n    this.destroyed = true;\n    this.destroyCapability = Promise.withResolvers();\n\n    this.#passwordCapability?.reject(\n      new Error(\"Worker was destroyed during onPassword callback\")\n    );\n\n    const waitOn = [];\n    // We need to wait for all renderings to be completed, e.g.\n    // timeout/rAF can take a long time.\n    for (const page of this.#pageCache.values()) {\n      waitOn.push(page._destroy());\n    }\n    this.#pageCache.clear();\n    this.#pagePromises.clear();\n    this.#pageRefCache.clear();\n    // Allow `AnnotationStorage`-related clean-up when destroying the document.\n    if (this.hasOwnProperty(\"annotationStorage\")) {\n      this.annotationStorage.resetModified();\n    }\n    // We also need to wait for the worker to finish its long running tasks.\n    const terminated = this.messageHandler.sendWithPromise(\"Terminate\", null);\n    waitOn.push(terminated);\n\n    Promise.all(waitOn).then(() => {\n      this.commonObjs.clear();\n      this.fontLoader.clear();\n      this.#methodPromises.clear();\n      this.filterFactory.destroy();\n      TextLayer.cleanup();\n\n      this.#networkStream?.cancelAllRequests(\n        new AbortException(\"Worker was terminated.\")\n      );\n\n      this.messageHandler?.destroy();\n      this.messageHandler = null;\n\n      this.destroyCapability.resolve();\n    }, this.destroyCapability.reject);\n    return this.destroyCapability.promise;\n  }\n\n  setupMessageHandler() {\n    const { messageHandler, loadingTask } = this;\n\n    messageHandler.on(\"GetReader\", (data, sink) => {\n      assert(\n        this.#networkStream,\n        \"GetReader - no `BasePDFStream` instance available.\"\n      );\n      this.#fullReader = this.#networkStream.getFullReader();\n      // If stream or range turn out to be disabled, once `headersReady` is\n      // resolved, this is our only way to report loading progress.\n      this.#fullReader.onProgress = evt => this.#onProgress(evt);\n\n      sink.onPull = () => {\n        this.#fullReader\n          .read()\n          .then(function ({ value, done }) {\n            if (done) {\n              sink.close();\n              return;\n            }\n            assert(\n              value instanceof ArrayBuffer,\n              \"GetReader - expected an ArrayBuffer.\"\n            );\n            // Enqueue data chunk into sink, and transfer it\n            // to other side as `Transferable` object.\n            sink.enqueue(new Uint8Array(value), 1, [value]);\n          })\n          .catch(reason => {\n            sink.error(reason);\n          });\n      };\n\n      sink.onCancel = reason => {\n        this.#fullReader.cancel(reason);\n\n        sink.ready.catch(readyReason => {\n          if (this.destroyed) {\n            return; // Ignore any pending requests if the worker was terminated.\n          }\n          throw readyReason;\n        });\n      };\n    });\n\n    messageHandler.on(\"ReaderHeadersReady\", async data => {\n      await this.#fullReader.headersReady;\n\n      const { isStreamingSupported, isRangeSupported, contentLength } =\n        this.#fullReader;\n\n      if (isStreamingSupported && isRangeSupported) {\n        this.#fullReader.onProgress = null; // See comment in \"GetReader\" above.\n      }\n      return { isStreamingSupported, isRangeSupported, contentLength };\n    });\n\n    messageHandler.on(\"GetRangeReader\", (data, sink) => {\n      assert(\n        this.#networkStream,\n        \"GetRangeReader - no `BasePDFStream` instance available.\"\n      );\n      const rangeReader = this.#networkStream.getRangeReader(\n        data.begin,\n        data.end\n      );\n\n      // When streaming is enabled, it's possible that the data requested here\n      // has already been fetched via the `#fullReader` implementation.\n      // However, given that the PDF data is loaded asynchronously on the\n      // main-thread and then sent via `postMessage` to the worker-thread,\n      // it may not have been available during parsing (hence the attempt to\n      // use range requests here).\n      //\n      // To avoid wasting time and resources here, we'll thus *not* dispatch\n      // range requests if the data was already loaded but has not been sent to\n      // the worker-thread yet (which will happen via the `#fullReader`).\n      if (!rangeReader) {\n        sink.close();\n        return;\n      }\n\n      sink.onPull = () => {\n        rangeReader\n          .read()\n          .then(function ({ value, done }) {\n            if (done) {\n              sink.close();\n              return;\n            }\n            assert(\n              value instanceof ArrayBuffer,\n              \"GetRangeReader - expected an ArrayBuffer.\"\n            );\n            sink.enqueue(new Uint8Array(value), 1, [value]);\n          })\n          .catch(reason => {\n            sink.error(reason);\n          });\n      };\n\n      sink.onCancel = reason => {\n        rangeReader.cancel(reason);\n\n        sink.ready.catch(readyReason => {\n          if (this.destroyed) {\n            return; // Ignore any pending requests if the worker was terminated.\n          }\n          throw readyReason;\n        });\n      };\n    });\n\n    messageHandler.on(\"GetDoc\", ({ pdfInfo }) => {\n      this.pagesMapper.pagesNumber = pdfInfo.numPages;\n      this._numPages = pdfInfo.numPages;\n      this._htmlForXfa = pdfInfo.htmlForXfa;\n      delete pdfInfo.htmlForXfa;\n      loadingTask._capability.resolve(new PDFDocumentProxy(pdfInfo, this));\n    });\n\n    messageHandler.on(\"DocException\", ex => {\n      loadingTask._capability.reject(wrapReason(ex));\n    });\n\n    messageHandler.on(\"PasswordRequest\", ex => {\n      this.#passwordCapability = Promise.withResolvers();\n\n      try {\n        if (!loadingTask.onPassword) {\n          throw wrapReason(ex);\n        }\n\n        const updatePassword = password => {\n          if (password instanceof Error) {\n            this.#passwordCapability.reject(password);\n          } else {\n            this.#passwordCapability.resolve({ password });\n          }\n        };\n        loadingTask.onPassword(updatePassword, ex.code);\n      } catch (err) {\n        this.#passwordCapability.reject(err);\n      }\n      return this.#passwordCapability.promise;\n    });\n\n    messageHandler.on(\"DataLoaded\", data => {\n      // For consistency: Ensure that progress is always reported when the\n      // entire PDF file has been loaded, regardless of how it was fetched.\n      this.#onProgress({ loaded: data.length, total: data.length });\n\n      this.downloadInfoCapability.resolve(data);\n    });\n\n    messageHandler.on(\"StartRenderPage\", data => {\n      if (this.destroyed) {\n        return; // Ignore any pending requests if the worker was terminated.\n      }\n\n      const page = this.#pageCache.get(data.pageIndex);\n      page._startRenderPage(data.transparency, data.cacheKey);\n    });\n\n    messageHandler.on(\"commonobj\", ([id, type, exportedData]) => {\n      if (this.destroyed) {\n        return null; // Ignore any pending requests if the worker was terminated.\n      }\n\n      if (this.commonObjs.has(id)) {\n        return null;\n      }\n\n      switch (type) {\n        case \"Font\":\n          if (\"error\" in exportedData) {\n            const exportedError = exportedData.error;\n            warn(`Error during font loading: ${exportedError}`);\n            this.commonObjs.resolve(id, exportedError);\n            break;\n          }\n\n          const fontData = new FontInfo(exportedData);\n          const inspectFont =\n            this._params.pdfBug && globalThis.FontInspector?.enabled\n              ? (font, url) => globalThis.FontInspector.fontAdded(font, url)\n              : null;\n          const font = new FontFaceObject(\n            fontData,\n            inspectFont,\n            exportedData.extra,\n            exportedData.charProcOperatorList\n          );\n\n          this.fontLoader\n            .bind(font)\n            .catch(() => messageHandler.sendWithPromise(\"FontFallback\", { id }))\n            .finally(() => {\n              if (!font.fontExtraProperties && font.data) {\n                // Immediately release the `font.data` property once the font\n                // has been attached to the DOM, since it's no longer needed,\n                // rather than waiting for a `PDFDocumentProxy.cleanup` call.\n                // Since `font.data` could be very large, e.g. in some cases\n                // multiple megabytes, this will help reduce memory usage.\n                font.clearData();\n              }\n              this.commonObjs.resolve(id, font);\n            });\n          break;\n        case \"CopyLocalImage\":\n          const { imageRef } = exportedData;\n          assert(imageRef, \"The imageRef must be defined.\");\n\n          for (const pageProxy of this.#pageCache.values()) {\n            for (const [, data] of pageProxy.objs) {\n              if (data?.ref !== imageRef) {\n                continue;\n              }\n              if (!data.dataLen) {\n                return null;\n              }\n              this.commonObjs.resolve(id, structuredClone(data));\n              return data.dataLen;\n            }\n          }\n          break;\n        case \"FontPath\":\n          this.commonObjs.resolve(id, new FontPathInfo(exportedData));\n          break;\n        case \"Image\":\n          this.commonObjs.resolve(id, exportedData);\n          break;\n        case \"Pattern\":\n          const pattern = new PatternInfo(exportedData);\n          this.commonObjs.resolve(id, pattern.getIR());\n          break;\n        default:\n          throw new Error(`Got unknown common object type ${type}`);\n      }\n\n      return null;\n    });\n\n    messageHandler.on(\"obj\", ([id, pageIndex, type, imageData]) => {\n      if (this.destroyed) {\n        // Ignore any pending requests if the worker was terminated.\n        return;\n      }\n\n      const pageProxy = this.#pageCache.get(pageIndex);\n      if (pageProxy.objs.has(id)) {\n        return;\n      }\n      // Don't store data *after* cleanup has successfully run, see bug 1854145.\n      if (pageProxy._intentStates.size === 0) {\n        imageData?.bitmap?.close(); // Release any `ImageBitmap` data.\n        return;\n      }\n\n      switch (type) {\n        case \"Image\":\n        case \"Pattern\":\n          pageProxy.objs.resolve(id, imageData);\n          break;\n        default:\n          throw new Error(`Got unknown object type ${type}`);\n      }\n    });\n\n    messageHandler.on(\"DocProgress\", data => {\n      if (this.destroyed) {\n        return; // Ignore any pending requests if the worker was terminated.\n      }\n      this.#onProgress(data);\n    });\n\n    messageHandler.on(\"FetchBinaryData\", async data => {\n      if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"MOZCENTRAL\")) {\n        throw new Error(\"Not implemented: FetchBinaryData\");\n      }\n      if (this.destroyed) {\n        throw new Error(\"Worker was destroyed.\");\n      }\n      const factory = this[data.type];\n\n      if (!factory) {\n        throw new Error(\n          `${data.type} not initialized, see the \\`useWorkerFetch\\` parameter.`\n        );\n      }\n      return factory.fetch(data);\n    });\n  }\n\n  getData() {\n    return this.messageHandler.sendWithPromise(\"GetData\", null);\n  }\n\n  saveDocument() {\n    if (this.annotationStorage.size <= 0) {\n      warn(\n        \"saveDocument called while `annotationStorage` is empty, \" +\n          \"please use the getData-method instead.\"\n      );\n    }\n    const { map, transfer } = this.annotationStorage.serializable;\n\n    return this.messageHandler\n      .sendWithPromise(\n        \"SaveDocument\",\n        {\n          isPureXfa: !!this._htmlForXfa,\n          numPages: this._numPages,\n          annotationStorage: map,\n          filename: this.#fullReader?.filename ?? null,\n        },\n        transfer\n      )\n      .finally(() => {\n        this.annotationStorage.resetModified();\n      });\n  }\n\n  extractPages(pageInfos) {\n    return this.messageHandler.sendWithPromise(\"ExtractPages\", { pageInfos });\n  }\n\n  getPage(pageNumber) {\n    if (\n      !Number.isInteger(pageNumber) ||\n      pageNumber <= 0 ||\n      pageNumber > this.pagesMapper.pagesNumber\n    ) {\n      return Promise.reject(new Error(\"Invalid page request.\"));\n    }\n    const pageIndex = pageNumber - 1;\n    const newPageIndex = this.pagesMapper.getPageId(pageNumber) - 1;\n\n    const cachedPromise = this.#pagePromises.get(pageIndex);\n    if (cachedPromise) {\n      return cachedPromise;\n    }\n    const promise = this.messageHandler\n      .sendWithPromise(\"GetPage\", {\n        pageIndex: newPageIndex,\n      })\n      .then(pageInfo => {\n        if (this.destroyed) {\n          throw new Error(\"Transport destroyed\");\n        }\n        if (pageInfo.refStr) {\n          this.#pageRefCache.set(pageInfo.refStr, newPageIndex);\n        }\n\n        const page = new PDFPageProxy(\n          pageIndex,\n          pageInfo,\n          this,\n          this.pagesMapper,\n          this._params.pdfBug\n        );\n        this.#pageCache.set(pageIndex, page);\n        return page;\n      });\n    this.#pagePromises.set(pageIndex, promise);\n    return promise;\n  }\n\n  async getPageIndex(ref) {\n    if (!isRefProxy(ref)) {\n      throw new Error(\"Invalid pageIndex request.\");\n    }\n    const index = await this.messageHandler.sendWithPromise(\"GetPageIndex\", {\n      num: ref.num,\n      gen: ref.gen,\n    });\n    const pageNumber = this.pagesMapper.getPageNumber(index + 1);\n    if (pageNumber === 0) {\n      throw new Error(\"GetPageIndex: page has been removed.\");\n    }\n    return pageNumber - 1;\n  }\n\n  getAnnotations(pageIndex, intent) {\n    return this.messageHandler.sendWithPromise(\"GetAnnotations\", {\n      pageIndex: this.pagesMapper.getPageId(pageIndex + 1) - 1,\n      intent,\n    });\n  }\n\n  getFieldObjects() {\n    return this.#cacheSimpleMethod(\"GetFieldObjects\");\n  }\n\n  hasJSActions() {\n    return this.#cacheSimpleMethod(\"HasJSActions\");\n  }\n\n  getCalculationOrderIds() {\n    return this.messageHandler.sendWithPromise(\"GetCalculationOrderIds\", null);\n  }\n\n  getDestinations() {\n    return this.messageHandler.sendWithPromise(\"GetDestinations\", null);\n  }\n\n  getDestination(id) {\n    if (typeof id !== \"string\") {\n      return Promise.reject(new Error(\"Invalid destination request.\"));\n    }\n    return this.messageHandler.sendWithPromise(\"GetDestination\", {\n      id,\n    });\n  }\n\n  getPageLabels() {\n    return this.messageHandler.sendWithPromise(\"GetPageLabels\", null);\n  }\n\n  getPageLayout() {\n    return this.messageHandler.sendWithPromise(\"GetPageLayout\", null);\n  }\n\n  getPageMode() {\n    return this.messageHandler.sendWithPromise(\"GetPageMode\", null);\n  }\n\n  getViewerPreferences() {\n    return this.messageHandler.sendWithPromise(\"GetViewerPreferences\", null);\n  }\n\n  getOpenAction() {\n    return this.messageHandler.sendWithPromise(\"GetOpenAction\", null);\n  }\n\n  getAttachments() {\n    return this.messageHandler.sendWithPromise(\"GetAttachments\", null);\n  }\n\n  getAnnotationsByType(types, pageIndexesToSkip) {\n    return this.messageHandler.sendWithPromise(\"GetAnnotationsByType\", {\n      types,\n      pageIndexesToSkip,\n    });\n  }\n\n  getDocJSActions() {\n    return this.#cacheSimpleMethod(\"GetDocJSActions\");\n  }\n\n  getPageJSActions(pageIndex) {\n    return this.messageHandler.sendWithPromise(\"GetPageJSActions\", {\n      pageIndex: this.pagesMapper.getPageId(pageIndex + 1) - 1,\n    });\n  }\n\n  getStructTree(pageIndex) {\n    return this.messageHandler.sendWithPromise(\"GetStructTree\", {\n      pageIndex: this.pagesMapper.getPageId(pageIndex + 1) - 1,\n    });\n  }\n\n  getOutline() {\n    return this.messageHandler.sendWithPromise(\"GetOutline\", null);\n  }\n\n  getOptionalContentConfig(renderingIntent) {\n    return this.#cacheSimpleMethod(\"GetOptionalContentConfig\").then(\n      data => new OptionalContentConfig(data, renderingIntent)\n    );\n  }\n\n  getPermissions() {\n    return this.messageHandler.sendWithPromise(\"GetPermissions\", null);\n  }\n\n  getMetadata() {\n    const name = \"GetMetadata\";\n\n    return this.#methodPromises.getOrInsertComputed(name, () =>\n      this.messageHandler.sendWithPromise(name, null).then(results => ({\n        info: results[0],\n        metadata: results[1] ? new Metadata(results[1]) : null,\n        contentDispositionFilename: this.#fullReader?.filename ?? null,\n        contentLength: this.#fullReader?.contentLength ?? null,\n        hasStructTree: results[2],\n      }))\n    );\n  }\n\n  getMarkInfo() {\n    return this.messageHandler.sendWithPromise(\"GetMarkInfo\", null);\n  }\n\n  async startCleanup(keepLoadedFonts = false) {\n    if (this.destroyed) {\n      return; // No need to manually clean-up when destruction has started.\n    }\n    await this.messageHandler.sendWithPromise(\"Cleanup\", null);\n\n    for (const page of this.#pageCache.values()) {\n      const cleanupSuccessful = page.cleanup();\n\n      if (!cleanupSuccessful) {\n        throw new Error(\n          `startCleanup: Page ${page.pageNumber} is currently rendering.`\n        );\n      }\n    }\n    this.commonObjs.clear();\n    if (!keepLoadedFonts) {\n      this.fontLoader.clear();\n    }\n    this.#methodPromises.clear();\n    this.filterFactory.destroy(/* keepHCM = */ true);\n    TextLayer.cleanup();\n  }\n\n  cachedPageNumber(ref) {\n    if (!isRefProxy(ref)) {\n      return null;\n    }\n    const refStr = ref.gen === 0 ? `${ref.num}R` : `${ref.num}R${ref.gen}`;\n    const pageIndex = this.#pageRefCache.get(refStr);\n    if (pageIndex >= 0) {\n      const pageNumber = this.pagesMapper.getPageNumber(pageIndex + 1);\n      if (pageNumber !== 0) {\n        return pageNumber;\n      }\n    }\n    return null;\n  }\n}\n\n/**\n * Allows controlling of the rendering tasks.\n */\nclass RenderTask {\n  _internalRenderTask = null;\n\n  /**\n   * Callback for incremental rendering -- a function that will be called\n   * each time the rendering is paused.  To continue rendering call the\n   * function that is the first argument to the callback.\n   * @type {function}\n   */\n  onContinue = null;\n\n  /**\n   * A function that will be synchronously called when the rendering tasks\n   * finishes with an error (either because of an actual error, or because the\n   * rendering is cancelled).\n   *\n   * @type {function}\n   * @param {Error} error\n   */\n  onError = null;\n\n  constructor(internalRenderTask) {\n    this._internalRenderTask = internalRenderTask;\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      // For testing purposes.\n      Object.defineProperty(this, \"getOperatorList\", {\n        value: () => this._internalRenderTask.operatorList,\n      });\n    }\n  }\n\n  /**\n   * Promise for rendering task completion.\n   * @type {Promise<void>}\n   */\n  get promise() {\n    return this._internalRenderTask.capability.promise;\n  }\n\n  /**\n   * Cancels the rendering task. If the task is currently rendering it will\n   * not be cancelled until graphics pauses with a timeout. The promise that\n   * this object extends will be rejected when cancelled.\n   *\n   * @param {number} [extraDelay]\n   */\n  cancel(extraDelay = 0) {\n    this._internalRenderTask.cancel(/* error = */ null, extraDelay);\n  }\n\n  /**\n   * Whether form fields are rendered separately from the main operatorList.\n   * @type {boolean}\n   */\n  get separateAnnots() {\n    const { separateAnnots } = this._internalRenderTask.operatorList;\n    if (!separateAnnots) {\n      return false;\n    }\n    const { annotationCanvasMap } = this._internalRenderTask;\n    return (\n      separateAnnots.form ||\n      (separateAnnots.canvas && annotationCanvasMap?.size > 0)\n    );\n  }\n}\n\n/**\n * For internal use only.\n * @ignore\n */\nclass InternalRenderTask {\n  #rAF = null;\n\n  static #canvasInUse = new WeakSet();\n\n  constructor({\n    callback,\n    params,\n    objs,\n    commonObjs,\n    annotationCanvasMap,\n    operatorList,\n    pageIndex,\n    canvasFactory,\n    filterFactory,\n    useRequestAnimationFrame = false,\n    pdfBug = false,\n    pageColors = null,\n    enableHWA = false,\n    operationsFilter = null,\n  }) {\n    this.callback = callback;\n    this.params = params;\n    this.objs = objs;\n    this.commonObjs = commonObjs;\n    this.annotationCanvasMap = annotationCanvasMap;\n    this.operatorListIdx = null;\n    this.operatorList = operatorList;\n    this._pageIndex = pageIndex;\n    this.canvasFactory = canvasFactory;\n    this.filterFactory = filterFactory;\n    this._pdfBug = pdfBug;\n    this.pageColors = pageColors;\n\n    this.running = false;\n    this.graphicsReadyCallback = null;\n    this.graphicsReady = false;\n    this._useRequestAnimationFrame =\n      useRequestAnimationFrame === true && typeof window !== \"undefined\";\n    this.cancelled = false;\n    this.capability = Promise.withResolvers();\n    this.task = new RenderTask(this);\n    // caching this-bound methods\n    this._cancelBound = this.cancel.bind(this);\n    this._continueBound = this._continue.bind(this);\n    this._scheduleNextBound = this._scheduleNext.bind(this);\n    this._nextBound = this._next.bind(this);\n    this._canvas = params.canvas;\n    this._canvasContext = params.canvas ? null : params.canvasContext;\n    this._enableHWA = enableHWA;\n    this._dependencyTracker = params.dependencyTracker;\n    this._operationsFilter = operationsFilter;\n  }\n\n  get completed() {\n    return this.capability.promise.catch(function () {\n      // Ignoring errors, since we only want to know when rendering is\n      // no longer pending.\n    });\n  }\n\n  initializeGraphics({ transparency = false, optionalContentConfig }) {\n    if (this.cancelled) {\n      return;\n    }\n    if (this._canvas) {\n      if (InternalRenderTask.#canvasInUse.has(this._canvas)) {\n        throw new Error(\n          \"Cannot use the same canvas during multiple render() operations. \" +\n            \"Use different canvas or ensure previous operations were \" +\n            \"cancelled or completed.\"\n        );\n      }\n      InternalRenderTask.#canvasInUse.add(this._canvas);\n    }\n\n    if (this._pdfBug && globalThis.StepperManager?.enabled) {\n      this.stepper = globalThis.StepperManager.create(this._pageIndex);\n      this.stepper.init(this.operatorList);\n      this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();\n    }\n    const { viewport, transform, background, dependencyTracker } = this.params;\n\n    // When printing in Firefox, we get a specific context in mozPrintCallback\n    // which cannot be created from the canvas itself.\n    const canvasContext =\n      this._canvasContext ||\n      this._canvas.getContext(\"2d\", {\n        alpha: false,\n        willReadFrequently: !this._enableHWA,\n      });\n\n    this.gfx = new CanvasGraphics(\n      canvasContext,\n      this.commonObjs,\n      this.objs,\n      this.canvasFactory,\n      this.filterFactory,\n      { optionalContentConfig },\n      this.annotationCanvasMap,\n      this.pageColors,\n      dependencyTracker\n    );\n    this.gfx.beginDrawing({\n      transform,\n      viewport,\n      transparency,\n      background,\n    });\n    this.operatorListIdx = 0;\n    this.graphicsReady = true;\n    this.graphicsReadyCallback?.();\n  }\n\n  cancel(error = null, extraDelay = 0) {\n    this.running = false;\n    this.cancelled = true;\n    this.gfx?.endDrawing();\n    if (this.#rAF) {\n      window.cancelAnimationFrame(this.#rAF);\n      this.#rAF = null;\n    }\n    InternalRenderTask.#canvasInUse.delete(this._canvas);\n\n    error ||= new RenderingCancelledException(\n      `Rendering cancelled, page ${this._pageIndex + 1}`,\n      extraDelay\n    );\n    this.callback(error);\n\n    this.task.onError?.(error);\n  }\n\n  operatorListChanged() {\n    if (!this.graphicsReady) {\n      this.graphicsReadyCallback ||= this._continueBound;\n      return;\n    }\n    this.gfx.dependencyTracker?.growOperationsCount(\n      this.operatorList.fnArray.length\n    );\n    this.stepper?.updateOperatorList(this.operatorList);\n\n    if (this.running) {\n      return;\n    }\n    this._continue();\n  }\n\n  _continue() {\n    this.running = true;\n    if (this.cancelled) {\n      return;\n    }\n    if (this.task.onContinue) {\n      this.task.onContinue(this._scheduleNextBound);\n    } else {\n      this._scheduleNext();\n    }\n  }\n\n  _scheduleNext() {\n    if (this._useRequestAnimationFrame) {\n      this.#rAF = window.requestAnimationFrame(() => {\n        this.#rAF = null;\n        this._nextBound().catch(this._cancelBound);\n      });\n    } else {\n      Promise.resolve().then(this._nextBound).catch(this._cancelBound);\n    }\n  }\n\n  async _next() {\n    if (this.cancelled) {\n      return;\n    }\n    this.operatorListIdx = this.gfx.executeOperatorList(\n      this.operatorList,\n      this.operatorListIdx,\n      this._continueBound,\n      this.stepper,\n      this._operationsFilter\n    );\n    if (this.operatorListIdx === this.operatorList.argsArray.length) {\n      this.running = false;\n      if (this.operatorList.lastChunk) {\n        this.gfx.endDrawing();\n        InternalRenderTask.#canvasInUse.delete(this._canvas);\n        this.callback();\n      }\n    }\n  }\n}\n\n/** @type {string} */\nconst version =\n  typeof PDFJSDev !== \"undefined\" ? PDFJSDev.eval(\"BUNDLE_VERSION\") : null;\n/** @type {string} */\nconst build =\n  typeof PDFJSDev !== \"undefined\" ? PDFJSDev.eval(\"BUNDLE_BUILD\") : null;\n\nexport {\n  build,\n  getDocument,\n  PDFDataRangeTransport,\n  PDFDocumentLoadingTask,\n  PDFDocumentProxy,\n  PDFPageProxy,\n  PDFWorker,\n  RenderTask,\n  version,\n};\n","/* Copyright 2023 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AnnotationEditorParamsType, shadow } from \"../../shared/util.js\";\nimport { KeyboardManager } from \"./tools.js\";\nimport { noContextMenu } from \"../display_utils.js\";\n\n/**\n * ColorPicker class provides a color picker for the annotation editor.\n * It displays a dropdown with some predefined colors and allows the user\n * to select a color for the annotation.\n */\nclass ColorPicker {\n  #button = null;\n\n  #buttonSwatch = null;\n\n  #defaultColor;\n\n  #dropdown = null;\n\n  #dropdownWasFromKeyboard = false;\n\n  #isMainColorPicker = false;\n\n  #editor = null;\n\n  #eventBus;\n\n  #openDropdownAC = null;\n\n  #uiManager = null;\n\n  static #l10nColor = null;\n\n  static get _keyboardManager() {\n    return shadow(\n      this,\n      \"_keyboardManager\",\n      new KeyboardManager([\n        [\n          [\"Escape\", \"mac+Escape\"],\n          ColorPicker.prototype._hideDropdownFromKeyboard,\n        ],\n        [[\" \", \"mac+ \"], ColorPicker.prototype._colorSelectFromKeyboard],\n        [\n          [\"ArrowDown\", \"ArrowRight\", \"mac+ArrowDown\", \"mac+ArrowRight\"],\n          ColorPicker.prototype._moveToNext,\n        ],\n        [\n          [\"ArrowUp\", \"ArrowLeft\", \"mac+ArrowUp\", \"mac+ArrowLeft\"],\n          ColorPicker.prototype._moveToPrevious,\n        ],\n        [[\"Home\", \"mac+Home\"], ColorPicker.prototype._moveToBeginning],\n        [[\"End\", \"mac+End\"], ColorPicker.prototype._moveToEnd],\n      ])\n    );\n  }\n\n  constructor({ editor = null, uiManager = null }) {\n    if (editor) {\n      this.#isMainColorPicker = false;\n      this.#editor = editor;\n    } else {\n      this.#isMainColorPicker = true;\n    }\n    this.#uiManager = editor?._uiManager || uiManager;\n    this.#eventBus = this.#uiManager._eventBus;\n    this.#defaultColor =\n      editor?.color?.toUpperCase() ||\n      this.#uiManager?.highlightColors.values().next().value ||\n      \"#FFFF98\";\n\n    ColorPicker.#l10nColor ||= Object.freeze({\n      blue: \"pdfjs-editor-colorpicker-blue\",\n      green: \"pdfjs-editor-colorpicker-green\",\n      pink: \"pdfjs-editor-colorpicker-pink\",\n      red: \"pdfjs-editor-colorpicker-red\",\n      yellow: \"pdfjs-editor-colorpicker-yellow\",\n    });\n  }\n\n  renderButton() {\n    const button = (this.#button = document.createElement(\"button\"));\n    button.className = \"colorPicker\";\n    button.tabIndex = \"0\";\n    button.setAttribute(\"data-l10n-id\", \"pdfjs-editor-colorpicker-button\");\n    button.ariaHasPopup = \"true\";\n    if (this.#editor) {\n      button.ariaControls = `${this.#editor.id}_colorpicker_dropdown`;\n    }\n    const signal = this.#uiManager._signal;\n    button.addEventListener(\"click\", this.#openDropdown.bind(this), { signal });\n    button.addEventListener(\"keydown\", this.#keyDown.bind(this), { signal });\n    const swatch = (this.#buttonSwatch = document.createElement(\"span\"));\n    swatch.className = \"swatch\";\n    swatch.ariaHidden = \"true\";\n    swatch.style.backgroundColor = this.#defaultColor;\n    button.append(swatch);\n    return button;\n  }\n\n  renderMainDropdown() {\n    const dropdown = (this.#dropdown = this.#getDropdownRoot());\n    dropdown.ariaOrientation = \"horizontal\";\n    dropdown.ariaLabelledBy = \"highlightColorPickerLabel\";\n\n    return dropdown;\n  }\n\n  #getDropdownRoot() {\n    const div = document.createElement(\"div\");\n    const signal = this.#uiManager._signal;\n    div.addEventListener(\"contextmenu\", noContextMenu, { signal });\n    div.className = \"dropdown\";\n    div.role = \"listbox\";\n    div.ariaMultiSelectable = \"false\";\n    div.ariaOrientation = \"vertical\";\n    div.setAttribute(\"data-l10n-id\", \"pdfjs-editor-colorpicker-dropdown\");\n    if (this.#editor) {\n      div.id = `${this.#editor.id}_colorpicker_dropdown`;\n    }\n    for (const [name, color] of this.#uiManager.highlightColors) {\n      const button = document.createElement(\"button\");\n      button.tabIndex = \"0\";\n      button.role = \"option\";\n      button.setAttribute(\"data-color\", color);\n      button.title = name;\n      button.setAttribute(\"data-l10n-id\", ColorPicker.#l10nColor[name]);\n      const swatch = document.createElement(\"span\");\n      button.append(swatch);\n      swatch.className = \"swatch\";\n      swatch.style.backgroundColor = color;\n      button.ariaSelected = color === this.#defaultColor;\n      button.addEventListener(\"click\", this.#colorSelect.bind(this, color), {\n        signal,\n      });\n      div.append(button);\n    }\n\n    div.addEventListener(\"keydown\", this.#keyDown.bind(this), { signal });\n\n    return div;\n  }\n\n  #colorSelect(color, event) {\n    event.stopPropagation();\n    this.#eventBus.dispatch(\"switchannotationeditorparams\", {\n      source: this,\n      type: AnnotationEditorParamsType.HIGHLIGHT_COLOR,\n      value: color,\n    });\n    this.updateColor(color);\n  }\n\n  _colorSelectFromKeyboard(event) {\n    if (event.target === this.#button) {\n      this.#openDropdown(event);\n      return;\n    }\n    const color = event.target.getAttribute(\"data-color\");\n    if (!color) {\n      return;\n    }\n    this.#colorSelect(color, event);\n  }\n\n  _moveToNext(event) {\n    if (!this.#isDropdownVisible) {\n      this.#openDropdown(event);\n      return;\n    }\n    if (event.target === this.#button) {\n      this.#dropdown.firstElementChild?.focus();\n      return;\n    }\n    event.target.nextSibling?.focus();\n  }\n\n  _moveToPrevious(event) {\n    if (\n      event.target === this.#dropdown?.firstElementChild ||\n      event.target === this.#button\n    ) {\n      if (this.#isDropdownVisible) {\n        this._hideDropdownFromKeyboard();\n      }\n      return;\n    }\n    if (!this.#isDropdownVisible) {\n      this.#openDropdown(event);\n    }\n    event.target.previousSibling?.focus();\n  }\n\n  _moveToBeginning(event) {\n    if (!this.#isDropdownVisible) {\n      this.#openDropdown(event);\n      return;\n    }\n    this.#dropdown.firstElementChild?.focus();\n  }\n\n  _moveToEnd(event) {\n    if (!this.#isDropdownVisible) {\n      this.#openDropdown(event);\n      return;\n    }\n    this.#dropdown.lastElementChild?.focus();\n  }\n\n  #keyDown(event) {\n    ColorPicker._keyboardManager.exec(this, event);\n  }\n\n  #openDropdown(event) {\n    if (this.#isDropdownVisible) {\n      this.hideDropdown();\n      return;\n    }\n    this.#dropdownWasFromKeyboard = event.detail === 0;\n\n    if (!this.#openDropdownAC) {\n      this.#openDropdownAC = new AbortController();\n\n      window.addEventListener(\"pointerdown\", this.#pointerDown.bind(this), {\n        signal: this.#uiManager.combinedSignal(this.#openDropdownAC),\n      });\n    }\n    this.#button.ariaExpanded = \"true\";\n    if (this.#dropdown) {\n      this.#dropdown.classList.remove(\"hidden\");\n      return;\n    }\n    const root = (this.#dropdown = this.#getDropdownRoot());\n    this.#button.append(root);\n  }\n\n  #pointerDown(event) {\n    if (this.#dropdown?.contains(event.target)) {\n      return;\n    }\n    this.hideDropdown();\n  }\n\n  hideDropdown() {\n    this.#dropdown?.classList.add(\"hidden\");\n    this.#button.ariaExpanded = \"false\";\n    this.#openDropdownAC?.abort();\n    this.#openDropdownAC = null;\n  }\n\n  get #isDropdownVisible() {\n    return this.#dropdown && !this.#dropdown.classList.contains(\"hidden\");\n  }\n\n  _hideDropdownFromKeyboard() {\n    if (this.#isMainColorPicker) {\n      return;\n    }\n    if (!this.#isDropdownVisible) {\n      // The user pressed Escape with no dropdown visible, so we must\n      // unselect it.\n      this.#editor?.unselect();\n      return;\n    }\n    this.hideDropdown();\n    this.#button.focus({\n      preventScroll: true,\n      focusVisible: this.#dropdownWasFromKeyboard,\n    });\n  }\n\n  updateColor(color) {\n    if (this.#buttonSwatch) {\n      this.#buttonSwatch.style.backgroundColor = color;\n    }\n    if (!this.#dropdown) {\n      return;\n    }\n\n    const i = this.#uiManager.highlightColors.values();\n    for (const child of this.#dropdown.children) {\n      child.ariaSelected = i.next().value === color.toUpperCase();\n    }\n  }\n\n  destroy() {\n    this.#button?.remove();\n    this.#button = null;\n    this.#buttonSwatch = null;\n    this.#dropdown?.remove();\n    this.#dropdown = null;\n  }\n}\n\n/**\n * BasicColorPicker class provides a simple color picker.\n * It displays an input element (with type=\"color\") that allows the user\n * to select a color for the annotation.\n */\nclass BasicColorPicker {\n  #input = null;\n\n  #editor = null;\n\n  #uiManager = null;\n\n  static #l10nColor = null;\n\n  constructor(editor) {\n    this.#editor = editor;\n    this.#uiManager = editor._uiManager;\n\n    BasicColorPicker.#l10nColor ||= Object.freeze({\n      freetext: \"pdfjs-editor-color-picker-free-text-input\",\n      ink: \"pdfjs-editor-color-picker-ink-input\",\n    });\n  }\n\n  renderButton() {\n    if (this.#input) {\n      return this.#input;\n    }\n    const { editorType, colorType, color } = this.#editor;\n    const input = (this.#input = document.createElement(\"input\"));\n    input.type = \"color\";\n    input.value = color || \"#000000\";\n    input.className = \"basicColorPicker\";\n    input.tabIndex = 0;\n    input.setAttribute(\"data-l10n-id\", BasicColorPicker.#l10nColor[editorType]);\n    input.addEventListener(\n      \"input\",\n      () => {\n        this.#uiManager.updateParams(colorType, input.value);\n      },\n      { signal: this.#uiManager._signal }\n    );\n    return input;\n  }\n\n  update(value) {\n    if (!this.#input) {\n      return;\n    }\n    this.#input.value = value;\n  }\n\n  destroy() {\n    this.#input?.remove();\n    this.#input = null;\n  }\n\n  hideDropdown() {}\n}\n\nexport { BasicColorPicker, ColorPicker };\n","/* Copyright 2020 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * PLEASE NOTE: This file is currently imported in both the `../display/` and\n *              `../scripting_api/` folders, hence be EXTREMELY careful about\n *              introducing any dependencies here since that can lead to an\n *              unexpected/unnecessary size increase of the *built* files.\n */\n\nfunction makeColorComp(n) {\n  return Math.floor(Math.max(0, Math.min(1, n)) * 255)\n    .toString(16)\n    .padStart(2, \"0\");\n}\n\nfunction scaleAndClamp(x) {\n  return Math.max(0, Math.min(255, 255 * x));\n}\n\n// PDF specifications section 10.3\nclass ColorConverters {\n  static CMYK_G([c, y, m, k]) {\n    return [\"G\", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];\n  }\n\n  static G_CMYK([g]) {\n    return [\"CMYK\", 0, 0, 0, 1 - g];\n  }\n\n  static G_RGB([g]) {\n    return [\"RGB\", g, g, g];\n  }\n\n  static G_rgb([g]) {\n    g = scaleAndClamp(g);\n    return [g, g, g];\n  }\n\n  static G_HTML([g]) {\n    const G = makeColorComp(g);\n    return `#${G}${G}${G}`;\n  }\n\n  static RGB_G([r, g, b]) {\n    return [\"G\", 0.3 * r + 0.59 * g + 0.11 * b];\n  }\n\n  static RGB_rgb(color) {\n    return color.map(scaleAndClamp);\n  }\n\n  static RGB_HTML(color) {\n    return `#${color.map(makeColorComp).join(\"\")}`;\n  }\n\n  static T_HTML() {\n    return \"#00000000\";\n  }\n\n  static T_rgb() {\n    return [null];\n  }\n\n  static CMYK_RGB([c, y, m, k]) {\n    return [\n      \"RGB\",\n      1 - Math.min(1, c + k),\n      1 - Math.min(1, m + k),\n      1 - Math.min(1, y + k),\n    ];\n  }\n\n  static CMYK_rgb([c, y, m, k]) {\n    return [\n      scaleAndClamp(1 - Math.min(1, c + k)),\n      scaleAndClamp(1 - Math.min(1, m + k)),\n      scaleAndClamp(1 - Math.min(1, y + k)),\n    ];\n  }\n\n  static CMYK_HTML(components) {\n    const rgb = this.CMYK_RGB(components).slice(1);\n    return this.RGB_HTML(rgb);\n  }\n\n  static RGB_CMYK([r, g, b]) {\n    const c = 1 - r;\n    const m = 1 - g;\n    const y = 1 - b;\n    const k = Math.min(c, m, y);\n    return [\"CMYK\", c, m, y, k];\n  }\n}\n\nconst DateFormats = [\n  \"m/d\",\n  \"m/d/yy\",\n  \"mm/dd/yy\",\n  \"mm/yy\",\n  \"d-mmm\",\n  \"d-mmm-yy\",\n  \"dd-mmm-yy\",\n  \"yy-mm-dd\",\n  \"mmm-yy\",\n  \"mmmm-yy\",\n  \"mmm d, yyyy\",\n  \"mmmm d, yyyy\",\n  \"m/d/yy h:MM tt\",\n  \"m/d/yy HH:MM\",\n];\nconst TimeFormats = [\"HH:MM\", \"h:MM tt\", \"HH:MM:ss\", \"h:MM:ss tt\"];\n\nexport { ColorConverters, DateFormats, TimeFormats };\n","/* Copyright 2015 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SVG_NS } from \"./display_utils.js\";\nimport { unreachable } from \"../shared/util.js\";\n\nclass BaseSVGFactory {\n  constructor() {\n    if (\n      (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) &&\n      this.constructor === BaseSVGFactory\n    ) {\n      unreachable(\"Cannot initialize BaseSVGFactory.\");\n    }\n  }\n\n  create(width, height, skipDimensions = false) {\n    if (width <= 0 || height <= 0) {\n      throw new Error(\"Invalid SVG dimensions\");\n    }\n    const svg = this._createSVG(\"svg:svg\");\n    svg.setAttribute(\"version\", \"1.1\");\n\n    if (!skipDimensions) {\n      svg.setAttribute(\"width\", `${width}px`);\n      svg.setAttribute(\"height\", `${height}px`);\n    }\n\n    svg.setAttribute(\"preserveAspectRatio\", \"none\");\n    svg.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n\n    return svg;\n  }\n\n  createElement(type) {\n    if (typeof type !== \"string\") {\n      throw new Error(\"Invalid SVG element type\");\n    }\n    return this._createSVG(type);\n  }\n\n  /**\n   * @ignore\n   */\n  _createSVG(type) {\n    unreachable(\"Abstract method `_createSVG` called.\");\n  }\n}\n\nclass DOMSVGFactory extends BaseSVGFactory {\n  /**\n   * @ignore\n   */\n  _createSVG(type) {\n    return document.createElementNS(SVG_NS, type);\n  }\n}\n\nexport { BaseSVGFactory, DOMSVGFactory };\n","/* Copyright 2014 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/** @typedef {import(\"./api\").PDFPageProxy} PDFPageProxy */\n/** @typedef {import(\"./display_utils\").PageViewport} PageViewport */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../web/text_accessibility.js\").TextAccessibilityManager} TextAccessibilityManager */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../src/display/editor/tools.js\").AnnotationEditorUIManager} AnnotationEditorUIManager */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../web/struct_tree_layer_builder.js\").StructTreeLayerBuilder} StructTreeLayerBuilder */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../web/comment_manager.js\").CommentManager} CommentManager */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../web/pdf_link_service.js\").PDFLinkService} PDFLinkService */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../web/base_download_manager.js\").BaseDownloadManager} BaseDownloadManager */\n\nimport {\n  AnnotationBorderStyleType,\n  AnnotationEditorPrefix,\n  AnnotationEditorType,\n  AnnotationPrefix,\n  AnnotationType,\n  FeatureTest,\n  LINE_FACTOR,\n  makeArr,\n  shadow,\n  unreachable,\n  Util,\n  warn,\n} from \"../shared/util.js\";\nimport {\n  PDFDateString,\n  renderRichText,\n  setLayerDimensions,\n} from \"./display_utils.js\";\nimport { AnnotationStorage } from \"./annotation_storage.js\";\nimport { ColorConverters } from \"../shared/scripting_utils.js\";\nimport { DOMSVGFactory } from \"./svg_factory.js\";\n\nconst DEFAULT_FONT_SIZE = 9;\nconst GetElementsByNameSet = new WeakSet();\nconst TIMEZONE_OFFSET = new Date().getTimezoneOffset() * 60 * 1000;\n\n/**\n * @typedef {Object} AnnotationElementParameters\n * @property {Object} data\n * @property {HTMLDivElement} layer\n * @property {PDFLinkService} linkService\n * @property {BaseDownloadManager} [downloadManager]\n * @property {AnnotationStorage} [annotationStorage]\n * @property {string} [imageResourcesPath] - Path for image resources, mainly\n *   for annotation icons. Include trailing slash.\n * @property {boolean} renderForms\n * @property {Object} svgFactory\n * @property {boolean} [enableScripting]\n * @property {boolean} [hasJSActions]\n * @property {Object} [fieldObjects]\n */\n\nclass AnnotationElementFactory {\n  /**\n   * @param {AnnotationElementParameters} parameters\n   * @returns {AnnotationElement}\n   */\n  static create(parameters) {\n    const subtype = parameters.data.annotationType;\n\n    switch (subtype) {\n      case AnnotationType.LINK:\n        return new LinkAnnotationElement(parameters);\n\n      case AnnotationType.TEXT:\n        return new TextAnnotationElement(parameters);\n\n      case AnnotationType.WIDGET:\n        const fieldType = parameters.data.fieldType;\n\n        switch (fieldType) {\n          case \"Tx\":\n            return new TextWidgetAnnotationElement(parameters);\n          case \"Btn\":\n            if (parameters.data.radioButton) {\n              return new RadioButtonWidgetAnnotationElement(parameters);\n            } else if (parameters.data.checkBox) {\n              return new CheckboxWidgetAnnotationElement(parameters);\n            }\n            return new PushButtonWidgetAnnotationElement(parameters);\n          case \"Ch\":\n            return new ChoiceWidgetAnnotationElement(parameters);\n          case \"Sig\":\n            return new SignatureWidgetAnnotationElement(parameters);\n        }\n        return new WidgetAnnotationElement(parameters);\n\n      case AnnotationType.POPUP:\n        return new PopupAnnotationElement(parameters);\n\n      case AnnotationType.FREETEXT:\n        return new FreeTextAnnotationElement(parameters);\n\n      case AnnotationType.LINE:\n        return new LineAnnotationElement(parameters);\n\n      case AnnotationType.SQUARE:\n        return new SquareAnnotationElement(parameters);\n\n      case AnnotationType.CIRCLE:\n        return new CircleAnnotationElement(parameters);\n\n      case AnnotationType.POLYLINE:\n        return new PolylineAnnotationElement(parameters);\n\n      case AnnotationType.CARET:\n        return new CaretAnnotationElement(parameters);\n\n      case AnnotationType.INK:\n        return new InkAnnotationElement(parameters);\n\n      case AnnotationType.POLYGON:\n        return new PolygonAnnotationElement(parameters);\n\n      case AnnotationType.HIGHLIGHT:\n        return new HighlightAnnotationElement(parameters);\n\n      case AnnotationType.UNDERLINE:\n        return new UnderlineAnnotationElement(parameters);\n\n      case AnnotationType.SQUIGGLY:\n        return new SquigglyAnnotationElement(parameters);\n\n      case AnnotationType.STRIKEOUT:\n        return new StrikeOutAnnotationElement(parameters);\n\n      case AnnotationType.STAMP:\n        return new StampAnnotationElement(parameters);\n\n      case AnnotationType.FILEATTACHMENT:\n        return new FileAttachmentAnnotationElement(parameters);\n\n      default:\n        return new AnnotationElement(parameters);\n    }\n  }\n}\n\nclass AnnotationElement {\n  #updates = null;\n\n  #hasBorder = false;\n\n  #popupElement = null;\n\n  constructor(\n    parameters,\n    {\n      isRenderable = false,\n      ignoreBorder = false,\n      createQuadrilaterals = false,\n    } = {}\n  ) {\n    this.isRenderable = isRenderable;\n    this.data = parameters.data;\n    this.layer = parameters.layer;\n    this.linkService = parameters.linkService;\n    this.downloadManager = parameters.downloadManager;\n    this.imageResourcesPath = parameters.imageResourcesPath;\n    this.renderForms = parameters.renderForms;\n    this.svgFactory = parameters.svgFactory;\n    this.annotationStorage = parameters.annotationStorage;\n    this.enableComment = parameters.enableComment;\n    this.enableScripting = parameters.enableScripting;\n    this.hasJSActions = parameters.hasJSActions;\n    this._fieldObjects = parameters.fieldObjects;\n    this.parent = parameters.parent;\n    this.hasOwnCommentButton = false;\n\n    if (isRenderable) {\n      this.contentElement = this.container =\n        this._createContainer(ignoreBorder);\n    }\n    if (createQuadrilaterals) {\n      this._createQuadrilaterals();\n    }\n  }\n\n  static _hasPopupData({ contentsObj, richText }) {\n    return !!(contentsObj?.str || richText?.str);\n  }\n\n  get _isEditable() {\n    return this.data.isEditable;\n  }\n\n  get hasPopupData() {\n    return (\n      AnnotationElement._hasPopupData(this.data) ||\n      (this.enableComment && !!this.commentText)\n    );\n  }\n\n  get commentData() {\n    const { data } = this;\n    const editor = this.annotationStorage?.getEditor(data.id);\n    if (editor) {\n      return editor.getData();\n    }\n    return data;\n  }\n\n  get hasCommentButton() {\n    return this.enableComment && this.hasPopupElement;\n  }\n\n  get commentButtonPosition() {\n    const editor = this.annotationStorage?.getEditor(this.data.id);\n    if (editor) {\n      return editor.commentButtonPositionInPage;\n    }\n    const { quadPoints, inkLists, rect } = this.data;\n    let maxX = -Infinity;\n    let maxY = -Infinity;\n    if (quadPoints?.length >= 8) {\n      for (let i = 0; i < quadPoints.length; i += 8) {\n        if (quadPoints[i + 1] > maxY) {\n          maxY = quadPoints[i + 1];\n          maxX = quadPoints[i + 2];\n        } else if (quadPoints[i + 1] === maxY) {\n          maxX = Math.max(maxX, quadPoints[i + 2]);\n        }\n      }\n      return [maxX, maxY];\n    }\n    if (inkLists?.length >= 1) {\n      for (const inkList of inkLists) {\n        for (let i = 0, ii = inkList.length; i < ii; i += 2) {\n          if (inkList[i + 1] > maxY) {\n            maxY = inkList[i + 1];\n            maxX = inkList[i];\n          } else if (inkList[i + 1] === maxY) {\n            maxX = Math.max(maxX, inkList[i]);\n          }\n        }\n      }\n      if (maxX !== Infinity) {\n        return [maxX, maxY];\n      }\n    }\n    if (rect) {\n      return [rect[2], rect[3]];\n    }\n    return null;\n  }\n\n  _normalizePoint(point) {\n    const {\n      page: { view },\n      viewport: {\n        rawDims: { pageWidth, pageHeight, pageX, pageY },\n      },\n    } = this.parent;\n    point[1] = view[3] - point[1] + view[1];\n    point[0] = (100 * (point[0] - pageX)) / pageWidth;\n    point[1] = (100 * (point[1] - pageY)) / pageHeight;\n    return point;\n  }\n\n  get commentText() {\n    const { data } = this;\n    return (\n      this.annotationStorage.getRawValue(`${AnnotationEditorPrefix}${data.id}`)\n        ?.popup?.contents ||\n      data.contentsObj?.str ||\n      \"\"\n    );\n  }\n\n  set commentText(text) {\n    const { data } = this;\n    const popup = { deleted: !text, contents: text || \"\" };\n    if (!this.annotationStorage.updateEditor(data.id, { popup })) {\n      this.annotationStorage.setValue(`${AnnotationEditorPrefix}${data.id}`, {\n        id: data.id,\n        annotationType: data.annotationType,\n        page: this.parent.page,\n        popup,\n        popupRef: data.popupRef,\n        modificationDate: new Date(),\n      });\n    }\n    if (!text) {\n      this.removePopup();\n    }\n  }\n\n  removePopup() {\n    (this.#popupElement?.popup || this.popup)?.remove();\n    this.#popupElement = this.popup = null;\n  }\n\n  updateEdited(params) {\n    if (!this.container) {\n      return;\n    }\n\n    if (params.rect) {\n      this.#updates ||= {\n        rect: this.data.rect.slice(0),\n      };\n    }\n\n    const { rect, popup: newPopup } = params;\n\n    if (rect) {\n      this.#setRectEdited(rect);\n    }\n\n    let popup = this.#popupElement?.popup || this.popup;\n    if (!popup && newPopup?.text) {\n      this._createPopup(newPopup);\n      popup = this.#popupElement.popup;\n    }\n    if (!popup) {\n      return;\n    }\n    popup.updateEdited(params);\n    if (newPopup?.deleted) {\n      popup.remove();\n      this.#popupElement = null;\n      this.popup = null;\n    }\n  }\n\n  resetEdited() {\n    if (!this.#updates) {\n      return;\n    }\n    this.#setRectEdited(this.#updates.rect);\n    this.#popupElement?.popup.resetEdited();\n    this.#updates = null;\n  }\n\n  #setRectEdited(rect) {\n    const {\n      container: { style },\n      data: { rect: currentRect, rotation },\n      parent: {\n        viewport: {\n          rawDims: { pageWidth, pageHeight, pageX, pageY },\n        },\n      },\n    } = this;\n    currentRect?.splice(0, 4, ...rect);\n    style.left = `${(100 * (rect[0] - pageX)) / pageWidth}%`;\n    style.top = `${(100 * (pageHeight - rect[3] + pageY)) / pageHeight}%`;\n    if (rotation === 0) {\n      style.width = `${(100 * /* width = */ (rect[2] - rect[0])) / pageWidth}%`;\n      style.height = `${(100 * /* height = */ (rect[3] - rect[1])) / pageHeight}%`;\n    } else {\n      this.setRotation(rotation);\n    }\n  }\n\n  /**\n   * Create an empty container for the annotation's HTML element.\n   *\n   * @private\n   * @param {boolean} ignoreBorder\n   * @memberof AnnotationElement\n   * @returns {HTMLElement} A section element.\n   */\n  _createContainer(ignoreBorder) {\n    const {\n      data,\n      parent: { page, viewport },\n    } = this;\n\n    const container = document.createElement(\"section\");\n    container.setAttribute(\"data-annotation-id\", data.id);\n    if (\n      !(this instanceof WidgetAnnotationElement) &&\n      !(this instanceof LinkAnnotationElement)\n    ) {\n      container.tabIndex = 0;\n    }\n    const { style } = container;\n\n    // The accessibility manager will move the annotation in the DOM in\n    // order to match the visual ordering.\n    // But if an annotation is above an other one, then we must draw it\n    // after the other one whatever the order is in the DOM, hence the\n    // use of the z-index.\n    style.zIndex = this.parent.zIndex;\n    // Keep zIndex + 1 for stuff we want to add on top of this annotation.\n    this.parent.zIndex += 2;\n\n    if (data.alternativeText) {\n      container.title = data.alternativeText;\n    }\n\n    if (data.noRotate) {\n      container.classList.add(\"norotate\");\n    }\n\n    if (!data.rect || this instanceof PopupAnnotationElement) {\n      const { rotation } = data;\n      if (!data.hasOwnCanvas && rotation !== 0) {\n        this.setRotation(rotation, container);\n      }\n      return container;\n    }\n    const { width, height } = this;\n\n    if (!ignoreBorder && data.borderStyle.width > 0) {\n      style.borderWidth = `${data.borderStyle.width}px`;\n\n      const horizontalRadius = data.borderStyle.horizontalCornerRadius;\n      const verticalRadius = data.borderStyle.verticalCornerRadius;\n      if (horizontalRadius > 0 || verticalRadius > 0) {\n        const radius = `calc(${horizontalRadius}px * var(--total-scale-factor)) / calc(${verticalRadius}px * var(--total-scale-factor))`;\n        style.borderRadius = radius;\n      } else if (this instanceof RadioButtonWidgetAnnotationElement) {\n        const radius = `calc(${width}px * var(--total-scale-factor)) / calc(${height}px * var(--total-scale-factor))`;\n        style.borderRadius = radius;\n      }\n\n      switch (data.borderStyle.style) {\n        case AnnotationBorderStyleType.SOLID:\n          style.borderStyle = \"solid\";\n          break;\n\n        case AnnotationBorderStyleType.DASHED:\n          style.borderStyle = \"dashed\";\n          break;\n\n        case AnnotationBorderStyleType.BEVELED:\n          warn(\"Unimplemented border style: beveled\");\n          break;\n\n        case AnnotationBorderStyleType.INSET:\n          warn(\"Unimplemented border style: inset\");\n          break;\n\n        case AnnotationBorderStyleType.UNDERLINE:\n          style.borderBottomStyle = \"solid\";\n          break;\n\n        default:\n          break;\n      }\n\n      const borderColor = data.borderColor || null;\n      if (borderColor) {\n        this.#hasBorder = true;\n        style.borderColor = Util.makeHexColor(\n          borderColor[0] | 0,\n          borderColor[1] | 0,\n          borderColor[2] | 0\n        );\n      } else {\n        // Transparent (invisible) border, so do not draw it at all.\n        style.borderWidth = 0;\n      }\n    }\n\n    // Do *not* modify `data.rect`, since that will corrupt the annotation\n    // position on subsequent calls to `_createContainer` (see issue 6804).\n    const rect = Util.normalizeRect([\n      data.rect[0],\n      page.view[3] - data.rect[1] + page.view[1],\n      data.rect[2],\n      page.view[3] - data.rect[3] + page.view[1],\n    ]);\n    const { pageWidth, pageHeight, pageX, pageY } = viewport.rawDims;\n\n    style.left = `${(100 * (rect[0] - pageX)) / pageWidth}%`;\n    style.top = `${(100 * (rect[1] - pageY)) / pageHeight}%`;\n\n    const { rotation } = data;\n    if (data.hasOwnCanvas || rotation === 0) {\n      style.width = `${(100 * width) / pageWidth}%`;\n      style.height = `${(100 * height) / pageHeight}%`;\n    } else {\n      this.setRotation(rotation, container);\n    }\n\n    return container;\n  }\n\n  setRotation(angle, container = this.container) {\n    if (!this.data.rect) {\n      return;\n    }\n    const { pageWidth, pageHeight } = this.parent.viewport.rawDims;\n    let { width, height } = this;\n\n    if (angle % 180 !== 0) {\n      [width, height] = [height, width];\n    }\n    container.style.width = `${(100 * width) / pageWidth}%`;\n    container.style.height = `${(100 * height) / pageHeight}%`;\n\n    container.setAttribute(\"data-main-rotation\", (360 - angle) % 360);\n  }\n\n  get _commonActions() {\n    const setColor = (jsName, styleName, event) => {\n      const color = event.detail[jsName];\n      const colorType = color[0];\n      const colorArray = color.slice(1);\n      event.target.style[styleName] =\n        ColorConverters[`${colorType}_HTML`](colorArray);\n      this.annotationStorage.setValue(this.data.id, {\n        [styleName]: ColorConverters[`${colorType}_rgb`](colorArray),\n      });\n    };\n\n    return shadow(this, \"_commonActions\", {\n      display: event => {\n        const { display } = event.detail;\n        // See scripting/constants.js for the values of `Display`.\n        // 0 = visible, 1 = hidden, 2 = noPrint and 3 = noView.\n        const hidden = display % 2 === 1;\n        this.container.style.visibility = hidden ? \"hidden\" : \"visible\";\n        this.annotationStorage.setValue(this.data.id, {\n          noView: hidden,\n          noPrint: display === 1 || display === 2,\n        });\n      },\n      print: event => {\n        this.annotationStorage.setValue(this.data.id, {\n          noPrint: !event.detail.print,\n        });\n      },\n      hidden: event => {\n        const { hidden } = event.detail;\n        this.container.style.visibility = hidden ? \"hidden\" : \"visible\";\n        this.annotationStorage.setValue(this.data.id, {\n          noPrint: hidden,\n          noView: hidden,\n        });\n      },\n      focus: event => {\n        setTimeout(() => event.target.focus({ preventScroll: false }), 0);\n      },\n      userName: event => {\n        // tooltip\n        event.target.title = event.detail.userName;\n      },\n      readonly: event => {\n        event.target.disabled = event.detail.readonly;\n      },\n      required: event => {\n        this._setRequired(event.target, event.detail.required);\n      },\n      bgColor: event => {\n        setColor(\"bgColor\", \"backgroundColor\", event);\n      },\n      fillColor: event => {\n        setColor(\"fillColor\", \"backgroundColor\", event);\n      },\n      fgColor: event => {\n        setColor(\"fgColor\", \"color\", event);\n      },\n      textColor: event => {\n        setColor(\"textColor\", \"color\", event);\n      },\n      borderColor: event => {\n        setColor(\"borderColor\", \"borderColor\", event);\n      },\n      strokeColor: event => {\n        setColor(\"strokeColor\", \"borderColor\", event);\n      },\n      rotation: event => {\n        const angle = event.detail.rotation;\n        this.setRotation(angle);\n        this.annotationStorage.setValue(this.data.id, {\n          rotation: angle,\n        });\n      },\n    });\n  }\n\n  _dispatchEventFromSandbox(actions, jsEvent) {\n    const commonActions = this._commonActions;\n    for (const name of Object.keys(jsEvent.detail)) {\n      const action = actions[name] || commonActions[name];\n      action?.(jsEvent);\n    }\n  }\n\n  _setDefaultPropertiesFromJS(element) {\n    if (!this.enableScripting) {\n      return;\n    }\n\n    // Some properties may have been updated thanks to JS.\n    const storedData = this.annotationStorage.getRawValue(this.data.id);\n    if (!storedData) {\n      return;\n    }\n\n    const commonActions = this._commonActions;\n    for (const [actionName, detail] of Object.entries(storedData)) {\n      const action = commonActions[actionName];\n      if (action) {\n        const eventProxy = {\n          detail: {\n            [actionName]: detail,\n          },\n          target: element,\n        };\n        action(eventProxy);\n        // The action has been consumed: no need to keep it.\n        delete storedData[actionName];\n      }\n    }\n  }\n\n  /**\n   * Create quadrilaterals from the annotation's quadpoints.\n   *\n   * @private\n   * @memberof AnnotationElement\n   */\n  _createQuadrilaterals() {\n    if (!this.container) {\n      return;\n    }\n    const { quadPoints } = this.data;\n    if (!quadPoints) {\n      return;\n    }\n\n    const [rectBlX, rectBlY, rectTrX, rectTrY] = this.data.rect.map(x =>\n      Math.fround(x)\n    );\n\n    if (quadPoints.length === 8) {\n      const [trX, trY, blX, blY] = quadPoints.subarray(2, 6);\n      if (\n        rectTrX === trX &&\n        rectTrY === trY &&\n        rectBlX === blX &&\n        rectBlY === blY\n      ) {\n        // The quadpoints cover the whole annotation rectangle, so no need to\n        // create a quadrilateral.\n        return;\n      }\n    }\n\n    const { style } = this.container;\n    let svgBuffer;\n    if (this.#hasBorder) {\n      const { borderColor, borderWidth } = style;\n      style.borderWidth = 0;\n      svgBuffer = [\n        \"url('data:image/svg+xml;utf8,\",\n        `<svg xmlns=\"http://www.w3.org/2000/svg\"`,\n        ` preserveAspectRatio=\"none\" viewBox=\"0 0 1 1\">`,\n        `<g fill=\"transparent\" stroke=\"${borderColor}\" stroke-width=\"${borderWidth}\">`,\n      ];\n      this.container.classList.add(\"hasBorder\");\n    }\n\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n      this.container.classList.add(\"hasClipPath\");\n    }\n\n    const width = rectTrX - rectBlX;\n    const height = rectTrY - rectBlY;\n\n    const { svgFactory } = this;\n    const svg = svgFactory.createElement(\"svg\");\n    svg.classList.add(\"quadrilateralsContainer\");\n    svg.setAttribute(\"width\", 0);\n    svg.setAttribute(\"height\", 0);\n    svg.role = \"none\";\n    const defs = svgFactory.createElement(\"defs\");\n    svg.append(defs);\n    const clipPath = svgFactory.createElement(\"clipPath\");\n    const id = `clippath_${this.data.id}`;\n    clipPath.setAttribute(\"id\", id);\n    clipPath.setAttribute(\"clipPathUnits\", \"objectBoundingBox\");\n    defs.append(clipPath);\n\n    for (let i = 2, ii = quadPoints.length; i < ii; i += 8) {\n      const trX = quadPoints[i];\n      const trY = quadPoints[i + 1];\n      const blX = quadPoints[i + 2];\n      const blY = quadPoints[i + 3];\n      const rect = svgFactory.createElement(\"rect\");\n      const x = (blX - rectBlX) / width;\n      const y = (rectTrY - trY) / height;\n      const rectWidth = (trX - blX) / width;\n      const rectHeight = (trY - blY) / height;\n      rect.setAttribute(\"x\", x);\n      rect.setAttribute(\"y\", y);\n      rect.setAttribute(\"width\", rectWidth);\n      rect.setAttribute(\"height\", rectHeight);\n      clipPath.append(rect);\n      svgBuffer?.push(\n        `<rect vector-effect=\"non-scaling-stroke\" x=\"${x}\" y=\"${y}\" width=\"${rectWidth}\" height=\"${rectHeight}\"/>`\n      );\n    }\n\n    if (this.#hasBorder) {\n      svgBuffer.push(`</g></svg>')`);\n      style.backgroundImage = svgBuffer.join(\"\");\n    }\n\n    this.container.append(svg);\n    this.container.style.clipPath = `url(#${id})`;\n  }\n\n  /**\n   * Create a popup for the annotation's HTML element. This is used for\n   * annotations that do not have a Popup entry in the dictionary, but\n   * are of a type that works with popups (such as Highlight annotations).\n   *\n   * @param {Object} [popupData] - The data for the popup, if any.\n   *\n   * @private\n   * @memberof AnnotationElement\n   */\n  _createPopup(popupData = null) {\n    const { data } = this;\n\n    let contentsObj, modificationDate;\n    if (popupData) {\n      contentsObj = {\n        str: popupData.text,\n      };\n      modificationDate = popupData.date;\n    } else {\n      contentsObj = data.contentsObj;\n      modificationDate = data.modificationDate;\n    }\n    this.#popupElement = new PopupAnnotationElement({\n      data: {\n        color: data.color,\n        titleObj: data.titleObj,\n        modificationDate,\n        contentsObj,\n        richText: data.richText,\n        parentRect: data.rect,\n        borderStyle: 0,\n        id: `popup_${data.id}`,\n        rotation: data.rotation,\n        noRotate: true,\n      },\n      linkService: this.linkService,\n      parent: this.parent,\n      elements: [this],\n    });\n  }\n\n  get hasPopupElement() {\n    return !!(this.#popupElement || this.popup || this.data.popupRef);\n  }\n\n  get extraPopupElement() {\n    return this.#popupElement;\n  }\n\n  /**\n   * Render the annotation's HTML element(s).\n   *\n   * @public\n   * @memberof AnnotationElement\n   */\n  render() {\n    unreachable(\"Abstract method `AnnotationElement.render` called\");\n  }\n\n  /**\n   * @private\n   * @returns {Array}\n   */\n  _getElementsByName(name, skipId = null) {\n    const fields = [];\n\n    if (this._fieldObjects) {\n      const fieldObj = this._fieldObjects[name];\n      if (fieldObj) {\n        for (const { page, id, exportValues } of fieldObj) {\n          if (page === -1) {\n            continue;\n          }\n          if (id === skipId) {\n            continue;\n          }\n          const exportValue =\n            typeof exportValues === \"string\" ? exportValues : null;\n\n          const domElement = document.querySelector(\n            `[data-element-id=\"${id}\"]`\n          );\n          if (domElement && !GetElementsByNameSet.has(domElement)) {\n            warn(`_getElementsByName - element not allowed: ${id}`);\n            continue;\n          }\n          fields.push({ id, exportValue, domElement });\n        }\n      }\n      return fields;\n    }\n    // Fallback to a regular DOM lookup, to ensure that the standalone\n    // viewer components won't break.\n    for (const domElement of document.getElementsByName(name)) {\n      const { exportValue } = domElement;\n      const id = domElement.getAttribute(\"data-element-id\");\n      if (id === skipId) {\n        continue;\n      }\n      if (!GetElementsByNameSet.has(domElement)) {\n        continue;\n      }\n      fields.push({ id, exportValue, domElement });\n    }\n    return fields;\n  }\n\n  show() {\n    if (this.container) {\n      this.container.hidden = false;\n    }\n    this.popup?.maybeShow();\n  }\n\n  hide() {\n    if (this.container) {\n      this.container.hidden = true;\n    }\n    this.popup?.forceHide();\n  }\n\n  /**\n   * Get the HTML element(s) which can trigger a popup when clicked or hovered.\n   *\n   * @public\n   * @memberof AnnotationElement\n   * @returns {Array<HTMLElement>|HTMLElement} An array of elements or an\n   *          element.\n   */\n  getElementsToTriggerPopup() {\n    return this.container;\n  }\n\n  addHighlightArea() {\n    const triggers = this.getElementsToTriggerPopup();\n    if (Array.isArray(triggers)) {\n      for (const element of triggers) {\n        element.classList.add(\"highlightArea\");\n      }\n    } else {\n      triggers.classList.add(\"highlightArea\");\n    }\n  }\n\n  _editOnDoubleClick() {\n    if (!this._isEditable) {\n      return;\n    }\n    const {\n      annotationEditorType: mode,\n      data: { id: editId },\n    } = this;\n    this.container.addEventListener(\"dblclick\", () => {\n      this.linkService.eventBus?.dispatch(\"switchannotationeditormode\", {\n        source: this,\n        mode,\n        editId,\n        mustEnterInEditMode: true,\n      });\n    });\n  }\n\n  get width() {\n    return this.data.rect[2] - this.data.rect[0];\n  }\n\n  get height() {\n    return this.data.rect[3] - this.data.rect[1];\n  }\n}\n\nclass EditorAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n    this.editor = parameters.editor;\n  }\n\n  render() {\n    this.container.className = \"editorAnnotation\";\n    return this.container;\n  }\n\n  createOrUpdatePopup() {\n    const { editor } = this;\n    if (!editor.hasComment) {\n      return;\n    }\n    this._createPopup(editor.comment);\n  }\n\n  get hasCommentButton() {\n    return this.enableComment && this.editor.hasComment;\n  }\n\n  get commentButtonPosition() {\n    return this.editor.commentButtonPositionInPage;\n  }\n\n  get commentText() {\n    return this.editor.comment.text;\n  }\n\n  set commentText(text) {\n    this.editor.comment = text;\n    if (!text) {\n      this.removePopup();\n    }\n  }\n\n  get commentData() {\n    return this.editor.getData();\n  }\n\n  remove() {\n    this.parent.removeAnnotation(this.data.id);\n    this.container.remove();\n    this.container = null;\n    this.removePopup();\n  }\n}\n\nclass LinkAnnotationElement extends AnnotationElement {\n  constructor(parameters, options = null) {\n    super(parameters, {\n      isRenderable: true,\n      ignoreBorder: !!options?.ignoreBorder,\n      createQuadrilaterals: true,\n    });\n    this.isTooltipOnly = parameters.data.isTooltipOnly;\n  }\n\n  render() {\n    const { data, linkService } = this;\n    const link = document.createElement(\"a\");\n    link.setAttribute(\"data-element-id\", data.id);\n    let isBound = false;\n\n    if (data.url) {\n      linkService.addLinkAttributes(link, data.url, data.newWindow);\n      isBound = true;\n    } else if (data.action) {\n      this._bindNamedAction(link, data.action, data.overlaidText);\n      isBound = true;\n    } else if (data.attachment) {\n      this.#bindAttachment(\n        link,\n        data.attachment,\n        data.overlaidText,\n        data.attachmentDest\n      );\n      isBound = true;\n    } else if (data.setOCGState) {\n      this.#bindSetOCGState(link, data.setOCGState, data.overlaidText);\n      isBound = true;\n    } else if (data.dest) {\n      this._bindLink(link, data.dest, data.overlaidText);\n      isBound = true;\n    } else {\n      if (\n        data.actions &&\n        (data.actions.Action ||\n          data.actions[\"Mouse Up\"] ||\n          data.actions[\"Mouse Down\"]) &&\n        this.enableScripting &&\n        this.hasJSActions\n      ) {\n        this._bindJSAction(link, data);\n        isBound = true;\n      }\n\n      if (data.resetForm) {\n        this._bindResetFormAction(link, data.resetForm);\n        isBound = true;\n      } else if (this.isTooltipOnly && !isBound) {\n        this._bindLink(link, \"\");\n        isBound = true;\n      }\n    }\n\n    this.container.classList.add(\"linkAnnotation\");\n    if (isBound) {\n      this.contentElement = link;\n      this.container.append(link);\n    }\n\n    return this.container;\n  }\n\n  #setInternalLink() {\n    this.container.setAttribute(\"data-internal-link\", \"\");\n  }\n\n  /**\n   * Bind internal links to the link element.\n   *\n   * @private\n   * @param {Object} link\n   * @param {Object} destination\n   * @param {string} [overlaidText]\n   * @memberof LinkAnnotationElement\n   */\n  _bindLink(link, destination, overlaidText = \"\") {\n    link.href = this.linkService.getDestinationHash(destination);\n    link.onclick = () => {\n      if (destination) {\n        this.linkService.goToDestination(destination);\n      }\n      return false;\n    };\n    if (destination || destination === /* isTooltipOnly = */ \"\") {\n      this.#setInternalLink();\n    }\n    if (overlaidText) {\n      link.title = overlaidText;\n    }\n  }\n\n  /**\n   * Bind named actions to the link element.\n   *\n   * @private\n   * @param {Object} link\n   * @param {Object} action\n   * @param {string} [overlaidText]\n   * @memberof LinkAnnotationElement\n   */\n  _bindNamedAction(link, action, overlaidText = \"\") {\n    link.href = this.linkService.getAnchorUrl(\"\");\n    link.onclick = () => {\n      this.linkService.executeNamedAction(action);\n      return false;\n    };\n    if (overlaidText) {\n      link.title = overlaidText;\n    }\n    this.#setInternalLink();\n  }\n\n  /**\n   * Bind attachments to the link element.\n   * @param {Object} link\n   * @param {Object} attachment\n   * @param {string} [overlaidText]\n   * @param {string} [dest]\n   */\n  #bindAttachment(link, attachment, overlaidText = \"\", dest = null) {\n    link.href = this.linkService.getAnchorUrl(\"\");\n    if (attachment.description) {\n      link.title = attachment.description;\n    } else if (overlaidText) {\n      link.title = overlaidText;\n    }\n    link.onclick = () => {\n      this.downloadManager?.openOrDownloadData(\n        attachment.content,\n        attachment.filename,\n        dest\n      );\n      return false;\n    };\n    this.#setInternalLink();\n  }\n\n  /**\n   * Bind SetOCGState actions to the link element.\n   * @param {Object} link\n   * @param {Object} action\n   * @param {string} [overlaidText]\n   */\n  #bindSetOCGState(link, action, overlaidText = \"\") {\n    link.href = this.linkService.getAnchorUrl(\"\");\n    link.onclick = () => {\n      this.linkService.executeSetOCGState(action);\n      return false;\n    };\n    if (overlaidText) {\n      link.title = overlaidText;\n    }\n    this.#setInternalLink();\n  }\n\n  /**\n   * Bind JS actions to the link element.\n   *\n   * @private\n   * @param {Object} link\n   * @param {Object} data\n   * @memberof LinkAnnotationElement\n   */\n  _bindJSAction(link, data) {\n    link.href = this.linkService.getAnchorUrl(\"\");\n    const map = new Map([\n      [\"Action\", \"onclick\"],\n      [\"Mouse Up\", \"onmouseup\"],\n      [\"Mouse Down\", \"onmousedown\"],\n    ]);\n    for (const name of Object.keys(data.actions)) {\n      const jsName = map.get(name);\n      if (!jsName) {\n        continue;\n      }\n      link[jsName] = () => {\n        this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n          source: this,\n          detail: {\n            id: data.id,\n            name,\n          },\n        });\n        return false;\n      };\n    }\n    if (data.overlaidText) {\n      link.title = data.overlaidText;\n    }\n\n    if (!link.onclick) {\n      link.onclick = () => false;\n    }\n    this.#setInternalLink();\n  }\n\n  _bindResetFormAction(link, resetForm) {\n    const otherClickAction = link.onclick;\n    if (!otherClickAction) {\n      link.href = this.linkService.getAnchorUrl(\"\");\n    }\n    this.#setInternalLink();\n\n    if (!this._fieldObjects) {\n      warn(\n        `_bindResetFormAction - \"resetForm\" action not supported, ` +\n          \"ensure that the `fieldObjects` parameter is provided.\"\n      );\n      if (!otherClickAction) {\n        link.onclick = () => false;\n      }\n      return;\n    }\n\n    link.onclick = () => {\n      otherClickAction?.();\n\n      const {\n        fields: resetFormFields,\n        refs: resetFormRefs,\n        include,\n      } = resetForm;\n\n      const allFields = [];\n      if (resetFormFields.length !== 0 || resetFormRefs.length !== 0) {\n        const fieldIds = new Set(resetFormRefs);\n        for (const fieldName of resetFormFields) {\n          const fields = this._fieldObjects[fieldName] || [];\n          for (const { id } of fields) {\n            fieldIds.add(id);\n          }\n        }\n        for (const fields of Object.values(this._fieldObjects)) {\n          for (const field of fields) {\n            if (fieldIds.has(field.id) === include) {\n              allFields.push(field);\n            }\n          }\n        }\n      } else {\n        for (const fields of Object.values(this._fieldObjects)) {\n          allFields.push(...fields);\n        }\n      }\n\n      const storage = this.annotationStorage;\n      const allIds = [];\n      for (const field of allFields) {\n        const { id } = field;\n        allIds.push(id);\n        switch (field.type) {\n          case \"text\": {\n            const value = field.defaultValue || \"\";\n            storage.setValue(id, { value });\n            break;\n          }\n          case \"checkbox\":\n          case \"radiobutton\": {\n            const value = field.defaultValue === field.exportValues;\n            storage.setValue(id, { value });\n            break;\n          }\n          case \"combobox\":\n          case \"listbox\": {\n            const value = field.defaultValue || \"\";\n            storage.setValue(id, { value });\n            break;\n          }\n          default:\n            continue;\n        }\n\n        const domElement = document.querySelector(`[data-element-id=\"${id}\"]`);\n        if (!domElement) {\n          continue;\n        } else if (!GetElementsByNameSet.has(domElement)) {\n          warn(`_bindResetFormAction - element not allowed: ${id}`);\n          continue;\n        }\n        domElement.dispatchEvent(new Event(\"resetform\"));\n      }\n\n      if (this.enableScripting) {\n        // Update the values in the sandbox.\n        this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n          source: this,\n          detail: {\n            id: \"app\",\n            ids: allIds,\n            name: \"ResetForm\",\n          },\n        });\n      }\n\n      return false;\n    };\n  }\n}\n\nclass TextAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: true });\n  }\n\n  render() {\n    this.container.classList.add(\"textAnnotation\");\n\n    const image = document.createElement(\"img\");\n    image.src =\n      this.imageResourcesPath +\n      \"annotation-\" +\n      this.data.name.toLowerCase() +\n      \".svg\";\n    image.setAttribute(\"data-l10n-id\", \"pdfjs-text-annotation-type\");\n    image.setAttribute(\n      \"data-l10n-args\",\n      JSON.stringify({ type: this.data.name })\n    );\n\n    if (!this.data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    this.container.append(image);\n    return this.container;\n  }\n}\n\nclass WidgetAnnotationElement extends AnnotationElement {\n  render() {\n    // Show only the container for unsupported field types.\n    return this.container;\n  }\n\n  showElementAndHideCanvas(element) {\n    if (this.data.hasOwnCanvas) {\n      if (element.previousSibling?.nodeName === \"CANVAS\") {\n        element.previousSibling.hidden = true;\n      }\n      element.hidden = false;\n    }\n  }\n\n  _getKeyModifier(event) {\n    return FeatureTest.platform.isMac ? event.metaKey : event.ctrlKey;\n  }\n\n  _setEventListener(element, elementData, baseName, eventName, valueGetter) {\n    if (baseName.includes(\"mouse\")) {\n      // Mouse events\n      element.addEventListener(baseName, event => {\n        this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n          source: this,\n          detail: {\n            id: this.data.id,\n            name: eventName,\n            value: valueGetter(event),\n            shift: event.shiftKey,\n            modifier: this._getKeyModifier(event),\n          },\n        });\n      });\n    } else {\n      // Non-mouse events\n      element.addEventListener(baseName, event => {\n        if (baseName === \"blur\") {\n          if (!elementData.focused || !event.relatedTarget) {\n            return;\n          }\n          elementData.focused = false;\n        } else if (baseName === \"focus\") {\n          if (elementData.focused) {\n            return;\n          }\n          elementData.focused = true;\n        }\n\n        if (!valueGetter) {\n          return;\n        }\n\n        this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n          source: this,\n          detail: {\n            id: this.data.id,\n            name: eventName,\n            value: valueGetter(event),\n          },\n        });\n      });\n    }\n  }\n\n  _setEventListeners(element, elementData, names, getter) {\n    for (const [baseName, eventName] of names) {\n      if (eventName === \"Action\" || this.data.actions?.[eventName]) {\n        if (eventName === \"Focus\" || eventName === \"Blur\") {\n          elementData ||= { focused: false };\n        }\n        this._setEventListener(\n          element,\n          elementData,\n          baseName,\n          eventName,\n          getter\n        );\n        if (eventName === \"Focus\" && !this.data.actions?.Blur) {\n          // Ensure that elementData will have the correct value.\n          this._setEventListener(element, elementData, \"blur\", \"Blur\", null);\n        } else if (eventName === \"Blur\" && !this.data.actions?.Focus) {\n          this._setEventListener(element, elementData, \"focus\", \"Focus\", null);\n        }\n      }\n    }\n  }\n\n  _setBackgroundColor(element) {\n    const color = this.data.backgroundColor || null;\n    element.style.backgroundColor =\n      color === null\n        ? \"transparent\"\n        : Util.makeHexColor(color[0], color[1], color[2]);\n  }\n\n  /**\n   * Apply text styles to the text in the element.\n   *\n   * @private\n   * @param {HTMLDivElement} element\n   * @memberof TextWidgetAnnotationElement\n   */\n  _setTextStyle(element) {\n    const TEXT_ALIGNMENT = [\"left\", \"center\", \"right\"];\n    const { fontColor } = this.data.defaultAppearanceData;\n    const fontSize =\n      this.data.defaultAppearanceData.fontSize || DEFAULT_FONT_SIZE;\n\n    const style = element.style;\n\n    // TODO: If the font-size is zero, calculate it based on the height and\n    //       width of the element.\n    // Not setting `style.fontSize` will use the default font-size for now.\n\n    // We don't use the font, as specified in the PDF document, for the <input>\n    // element. Hence using the original `fontSize` could look bad, which is why\n    // it's instead based on the field height.\n    // If the height is \"big\" then it could lead to a too big font size\n    // so in this case use the one we've in the pdf (hence the min).\n    let computedFontSize;\n    const BORDER_SIZE = 2;\n    const roundToOneDecimal = x => Math.round(10 * x) / 10;\n    if (this.data.multiLine) {\n      const height = Math.abs(\n        this.data.rect[3] - this.data.rect[1] - BORDER_SIZE\n      );\n      const numberOfLines = Math.round(height / (LINE_FACTOR * fontSize)) || 1;\n      const lineHeight = height / numberOfLines;\n      computedFontSize = Math.min(\n        fontSize,\n        roundToOneDecimal(lineHeight / LINE_FACTOR)\n      );\n    } else {\n      const height = Math.abs(\n        this.data.rect[3] - this.data.rect[1] - BORDER_SIZE\n      );\n      computedFontSize = Math.min(\n        fontSize,\n        roundToOneDecimal(height / LINE_FACTOR)\n      );\n    }\n    style.fontSize = `calc(${computedFontSize}px * var(--total-scale-factor))`;\n\n    style.color = Util.makeHexColor(fontColor[0], fontColor[1], fontColor[2]);\n\n    if (this.data.textAlignment !== null) {\n      style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];\n    }\n  }\n\n  _setRequired(element, isRequired) {\n    if (isRequired) {\n      element.setAttribute(\"required\", true);\n    } else {\n      element.removeAttribute(\"required\");\n    }\n    element.setAttribute(\"aria-required\", isRequired);\n  }\n}\n\nclass TextWidgetAnnotationElement extends WidgetAnnotationElement {\n  constructor(parameters) {\n    const isRenderable =\n      parameters.renderForms ||\n      parameters.data.hasOwnCanvas ||\n      (!parameters.data.hasAppearance && !!parameters.data.fieldValue);\n    super(parameters, { isRenderable });\n  }\n\n  setPropertyOnSiblings(base, key, value, keyInStorage) {\n    const storage = this.annotationStorage;\n    for (const element of this._getElementsByName(\n      base.name,\n      /* skipId = */ base.id\n    )) {\n      if (element.domElement) {\n        element.domElement[key] = value;\n      }\n      storage.setValue(element.id, { [keyInStorage]: value });\n    }\n  }\n\n  render() {\n    const storage = this.annotationStorage;\n    const id = this.data.id;\n\n    this.container.classList.add(\"textWidgetAnnotation\");\n\n    let element = null;\n    if (this.renderForms) {\n      // NOTE: We cannot set the values using `element.value` below, since it\n      //       prevents the AnnotationLayer rasterizer in `test/driver.js`\n      //       from parsing the elements correctly for the reference tests.\n      const storedData = storage.getValue(id, {\n        value: this.data.fieldValue,\n      });\n      let textContent = storedData.value || \"\";\n      const maxLen = storage.getValue(id, {\n        charLimit: this.data.maxLen,\n      }).charLimit;\n      if (maxLen && textContent.length > maxLen) {\n        textContent = textContent.slice(0, maxLen);\n      }\n\n      let fieldFormattedValues =\n        storedData.formattedValue || this.data.textContent?.join(\"\\n\") || null;\n      if (fieldFormattedValues && this.data.comb) {\n        fieldFormattedValues = fieldFormattedValues.replaceAll(/\\s+/g, \"\");\n      }\n\n      const elementData = {\n        userValue: textContent,\n        formattedValue: fieldFormattedValues,\n        lastCommittedValue: null,\n        commitKey: 1,\n        focused: false,\n      };\n\n      if (this.data.multiLine) {\n        element = document.createElement(\"textarea\");\n        element.textContent = fieldFormattedValues ?? textContent;\n        if (this.data.doNotScroll) {\n          element.style.overflowY = \"hidden\";\n        }\n      } else {\n        element = document.createElement(\"input\");\n        element.type = this.data.password ? \"password\" : \"text\";\n        element.setAttribute(\"value\", fieldFormattedValues ?? textContent);\n        if (this.data.doNotScroll) {\n          element.style.overflowX = \"hidden\";\n        }\n      }\n      if (this.data.hasOwnCanvas) {\n        element.hidden = true;\n      }\n      GetElementsByNameSet.add(element);\n      this.contentElement = element;\n      element.setAttribute(\"data-element-id\", id);\n\n      element.disabled = this.data.readOnly;\n      element.name = this.data.fieldName;\n      element.tabIndex = 0;\n      const { datetimeFormat, datetimeType, timeStep } = this.data;\n      const hasDateOrTime = !!datetimeType && this.enableScripting;\n      if (datetimeFormat) {\n        element.title = datetimeFormat;\n      }\n\n      this._setRequired(element, this.data.required);\n\n      if (maxLen) {\n        element.maxLength = maxLen;\n      }\n\n      element.addEventListener(\"input\", event => {\n        storage.setValue(id, { value: event.target.value });\n        this.setPropertyOnSiblings(\n          element,\n          \"value\",\n          event.target.value,\n          \"value\"\n        );\n        elementData.formattedValue = null;\n      });\n\n      element.addEventListener(\"resetform\", event => {\n        const defaultValue = this.data.defaultFieldValue ?? \"\";\n        element.value = elementData.userValue = defaultValue;\n        elementData.formattedValue = null;\n      });\n\n      let blurListener = event => {\n        const { formattedValue } = elementData;\n        if (formattedValue !== null && formattedValue !== undefined) {\n          event.target.value = formattedValue;\n        }\n        // Reset the cursor position to the start of the field (issue 12359).\n        event.target.scrollLeft = 0;\n      };\n\n      if (this.enableScripting && this.hasJSActions) {\n        element.addEventListener(\"focus\", event => {\n          if (elementData.focused) {\n            return;\n          }\n          const { target } = event;\n          if (hasDateOrTime) {\n            target.type = datetimeType;\n            if (timeStep) {\n              target.step = timeStep;\n            }\n          }\n\n          if (elementData.userValue) {\n            const value = elementData.userValue;\n            if (hasDateOrTime) {\n              if (datetimeType === \"time\") {\n                const date = new Date(value);\n                const parts = [\n                  date.getHours(),\n                  date.getMinutes(),\n                  date.getSeconds(),\n                ];\n                target.value = parts\n                  .map(v => v.toString().padStart(2, \"0\"))\n                  .join(\":\");\n              } else {\n                target.value = new Date(value - TIMEZONE_OFFSET)\n                  .toISOString()\n                  .split(datetimeType === \"date\" ? \"T\" : \".\", 1)[0];\n              }\n            } else {\n              target.value = value;\n            }\n          }\n          elementData.lastCommittedValue = target.value;\n          elementData.commitKey = 1;\n          if (!this.data.actions?.Focus) {\n            elementData.focused = true;\n          }\n        });\n\n        element.addEventListener(\"updatefromsandbox\", jsEvent => {\n          this.showElementAndHideCanvas(jsEvent.target);\n          const actions = {\n            value(event) {\n              elementData.userValue = event.detail.value ?? \"\";\n              if (!hasDateOrTime) {\n                storage.setValue(id, {\n                  value: elementData.userValue.toString(),\n                });\n              }\n              event.target.value = elementData.userValue;\n            },\n            formattedValue(event) {\n              const { formattedValue } = event.detail;\n              elementData.formattedValue = formattedValue;\n              if (\n                formattedValue !== null &&\n                formattedValue !== undefined &&\n                event.target !== document.activeElement\n              ) {\n                // Input hasn't the focus so display formatted string\n                event.target.value = formattedValue;\n              }\n              const data = {\n                formattedValue,\n              };\n              if (hasDateOrTime) {\n                // If the field is a date or time, we store the formatted value\n                // in the `value` property, so that it can be used by the\n                // `Keystroke` action.\n                data.value = formattedValue;\n              }\n              storage.setValue(id, data);\n            },\n            selRange(event) {\n              event.target.setSelectionRange(...event.detail.selRange);\n            },\n            charLimit: event => {\n              const { charLimit } = event.detail;\n              const { target } = event;\n              if (charLimit === 0) {\n                target.removeAttribute(\"maxLength\");\n                return;\n              }\n\n              target.setAttribute(\"maxLength\", charLimit);\n              let value = elementData.userValue;\n              if (!value || value.length <= charLimit) {\n                return;\n              }\n              value = value.slice(0, charLimit);\n              target.value = elementData.userValue = value;\n              storage.setValue(id, { value });\n\n              this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n                source: this,\n                detail: {\n                  id,\n                  name: \"Keystroke\",\n                  value,\n                  willCommit: true,\n                  commitKey: 1,\n                  selStart: target.selectionStart,\n                  selEnd: target.selectionEnd,\n                },\n              });\n            },\n          };\n          this._dispatchEventFromSandbox(actions, jsEvent);\n        });\n\n        // Even if the field hasn't any actions\n        // leaving it can still trigger some actions with Calculate\n        element.addEventListener(\"keydown\", event => {\n          elementData.commitKey = 1;\n          // If the key is one of Escape, Enter then the data are committed.\n          // If we've a Tab then data will be committed on blur.\n          let commitKey = -1;\n          if (event.key === \"Escape\") {\n            commitKey = 0;\n          } else if (event.key === \"Enter\" && !this.data.multiLine) {\n            // When we've a multiline field, \"Enter\" key is a key as the other\n            // hence we don't commit the data (Acrobat behaves the same way)\n            // (see issue #15627).\n            commitKey = 2;\n          } else if (event.key === \"Tab\") {\n            elementData.commitKey = 3;\n          }\n          if (commitKey === -1) {\n            return;\n          }\n          const { value } = event.target;\n          if (elementData.lastCommittedValue === value) {\n            return;\n          }\n          elementData.lastCommittedValue = value;\n          // Save the entered value\n          elementData.userValue = value;\n          this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n            source: this,\n            detail: {\n              id,\n              name: \"Keystroke\",\n              value,\n              willCommit: true,\n              commitKey,\n              selStart: event.target.selectionStart,\n              selEnd: event.target.selectionEnd,\n            },\n          });\n        });\n        const _blurListener = blurListener;\n        blurListener = null;\n        element.addEventListener(\"blur\", event => {\n          if (!elementData.focused || !event.relatedTarget) {\n            return;\n          }\n          if (!this.data.actions?.Blur) {\n            elementData.focused = false;\n          }\n          const { target } = event;\n          let { value } = target;\n          if (hasDateOrTime) {\n            if (value && datetimeType === \"time\") {\n              const parts = value.split(\":\").map(v => parseInt(v, 10));\n              value = new Date(\n                2000,\n                0,\n                1,\n                parts[0],\n                parts[1],\n                parts[2] || 0\n              ).valueOf();\n              target.step = \"\";\n            } else {\n              // Unfortunately, when the date is \"2025-09-23\", the parser\n              // converts it to UTC time which may lead to the date being off by\n              // one day depending on the timezone. To workaround this, we\n              // append \"T00:00\" to the date so that it's parsed as local\n              // time (bug 1989874).\n              if (!value.includes(\"T\")) {\n                value = `${value}T00:00`;\n              }\n              value = new Date(value).valueOf();\n            }\n            target.type = \"text\";\n          }\n          elementData.userValue = value;\n          if (elementData.lastCommittedValue !== value) {\n            this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n              source: this,\n              detail: {\n                id,\n                name: \"Keystroke\",\n                value,\n                willCommit: true,\n                commitKey: elementData.commitKey,\n                selStart: event.target.selectionStart,\n                selEnd: event.target.selectionEnd,\n              },\n            });\n          }\n          _blurListener(event);\n        });\n\n        if (this.data.actions?.Keystroke) {\n          element.addEventListener(\"beforeinput\", event => {\n            elementData.lastCommittedValue = null;\n            const { data, target } = event;\n            const { value, selectionStart, selectionEnd } = target;\n\n            let selStart = selectionStart,\n              selEnd = selectionEnd;\n\n            switch (event.inputType) {\n              // https://rawgit.com/w3c/input-events/v1/index.html#interface-InputEvent-Attributes\n              case \"deleteWordBackward\": {\n                const match = value\n                  .substring(0, selectionStart)\n                  .match(/\\w*[^\\w]*$/);\n                if (match) {\n                  selStart -= match[0].length;\n                }\n                break;\n              }\n              case \"deleteWordForward\": {\n                const match = value\n                  .substring(selectionStart)\n                  .match(/^[^\\w]*\\w*/);\n                if (match) {\n                  selEnd += match[0].length;\n                }\n                break;\n              }\n              case \"deleteContentBackward\":\n                if (selectionStart === selectionEnd) {\n                  selStart -= 1;\n                }\n                break;\n              case \"deleteContentForward\":\n                if (selectionStart === selectionEnd) {\n                  selEnd += 1;\n                }\n                break;\n            }\n\n            // We handle the event ourselves.\n            event.preventDefault();\n            this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n              source: this,\n              detail: {\n                id,\n                name: \"Keystroke\",\n                value,\n                change: data || \"\",\n                willCommit: false,\n                selStart,\n                selEnd,\n              },\n            });\n          });\n        }\n\n        this._setEventListeners(\n          element,\n          elementData,\n          [\n            [\"focus\", \"Focus\"],\n            [\"blur\", \"Blur\"],\n            [\"mousedown\", \"Mouse Down\"],\n            [\"mouseenter\", \"Mouse Enter\"],\n            [\"mouseleave\", \"Mouse Exit\"],\n            [\"mouseup\", \"Mouse Up\"],\n          ],\n          event => event.target.value\n        );\n      }\n\n      if (blurListener) {\n        element.addEventListener(\"blur\", blurListener);\n      }\n\n      if (this.data.comb) {\n        const fieldWidth = this.data.rect[2] - this.data.rect[0];\n        const combWidth = fieldWidth / maxLen;\n\n        element.classList.add(\"comb\");\n        element.style.letterSpacing = `calc(${combWidth}px * var(--total-scale-factor) - 1ch)`;\n      }\n    } else {\n      element = document.createElement(\"div\");\n      element.textContent = this.data.fieldValue;\n      element.style.verticalAlign = \"middle\";\n      element.style.display = \"table-cell\";\n\n      if (this.data.hasOwnCanvas) {\n        element.hidden = true;\n      }\n    }\n\n    this._setTextStyle(element);\n    this._setBackgroundColor(element);\n    this._setDefaultPropertiesFromJS(element);\n\n    this.container.append(element);\n    return this.container;\n  }\n}\n\nclass SignatureWidgetAnnotationElement extends WidgetAnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: !!parameters.data.hasOwnCanvas });\n  }\n}\n\nclass CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: parameters.renderForms });\n  }\n\n  render() {\n    const storage = this.annotationStorage;\n    const data = this.data;\n    const id = data.id;\n    let value = storage.getValue(id, {\n      value: data.exportValue === data.fieldValue,\n    }).value;\n    if (typeof value === \"string\") {\n      // The value has been changed through js and set in annotationStorage.\n      value = value !== \"Off\";\n      storage.setValue(id, { value });\n    }\n\n    this.container.classList.add(\"buttonWidgetAnnotation\", \"checkBox\");\n\n    const element = document.createElement(\"input\");\n    GetElementsByNameSet.add(element);\n    element.setAttribute(\"data-element-id\", id);\n\n    element.disabled = data.readOnly;\n    this._setRequired(element, this.data.required);\n    element.type = \"checkbox\";\n    element.name = data.fieldName;\n    if (value) {\n      element.setAttribute(\"checked\", true);\n    }\n    element.setAttribute(\"exportValue\", data.exportValue);\n    element.tabIndex = 0;\n\n    element.addEventListener(\"change\", event => {\n      const { name, checked } = event.target;\n      for (const checkbox of this._getElementsByName(name, /* skipId = */ id)) {\n        const curChecked = checked && checkbox.exportValue === data.exportValue;\n        if (checkbox.domElement) {\n          checkbox.domElement.checked = curChecked;\n        }\n        storage.setValue(checkbox.id, { value: curChecked });\n      }\n      storage.setValue(id, { value: checked });\n    });\n\n    element.addEventListener(\"resetform\", event => {\n      const defaultValue = data.defaultFieldValue || \"Off\";\n      event.target.checked = defaultValue === data.exportValue;\n    });\n\n    if (this.enableScripting && this.hasJSActions) {\n      element.addEventListener(\"updatefromsandbox\", jsEvent => {\n        const actions = {\n          value(event) {\n            event.target.checked = event.detail.value !== \"Off\";\n            storage.setValue(id, { value: event.target.checked });\n          },\n        };\n        this._dispatchEventFromSandbox(actions, jsEvent);\n      });\n\n      this._setEventListeners(\n        element,\n        null,\n        [\n          [\"change\", \"Validate\"],\n          [\"change\", \"Action\"],\n          [\"focus\", \"Focus\"],\n          [\"blur\", \"Blur\"],\n          [\"mousedown\", \"Mouse Down\"],\n          [\"mouseenter\", \"Mouse Enter\"],\n          [\"mouseleave\", \"Mouse Exit\"],\n          [\"mouseup\", \"Mouse Up\"],\n        ],\n        event => event.target.checked\n      );\n    }\n\n    this._setBackgroundColor(element);\n    this._setDefaultPropertiesFromJS(element);\n\n    this.container.append(element);\n    return this.container;\n  }\n}\n\nclass RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: parameters.renderForms });\n  }\n\n  render() {\n    this.container.classList.add(\"buttonWidgetAnnotation\", \"radioButton\");\n    const storage = this.annotationStorage;\n    const data = this.data;\n    const id = data.id;\n    let value = storage.getValue(id, {\n      value: data.fieldValue === data.buttonValue,\n    }).value;\n    if (typeof value === \"string\") {\n      // The value has been changed through js and set in annotationStorage.\n      value = value !== data.buttonValue;\n      storage.setValue(id, { value });\n    }\n\n    if (value) {\n      // It's possible that multiple radio buttons are checked.\n      // So if this one is checked we just reset the other ones.\n      // (see bug 1864136). Then when the other ones will be rendered they will\n      // unchecked (because of their value in the storage).\n      // Consequently, the first checked radio button will be the only checked\n      // one.\n      for (const radio of this._getElementsByName(\n        data.fieldName,\n        /* skipId = */ id\n      )) {\n        storage.setValue(radio.id, { value: false });\n      }\n    }\n\n    const element = document.createElement(\"input\");\n    GetElementsByNameSet.add(element);\n    element.setAttribute(\"data-element-id\", id);\n\n    element.disabled = data.readOnly;\n    this._setRequired(element, this.data.required);\n    element.type = \"radio\";\n    element.name = data.fieldName;\n    if (value) {\n      element.setAttribute(\"checked\", true);\n    }\n    element.tabIndex = 0;\n\n    element.addEventListener(\"change\", event => {\n      const { name, checked } = event.target;\n      for (const radio of this._getElementsByName(name, /* skipId = */ id)) {\n        storage.setValue(radio.id, { value: false });\n      }\n      storage.setValue(id, { value: checked });\n    });\n\n    element.addEventListener(\"resetform\", event => {\n      const defaultValue = data.defaultFieldValue;\n      event.target.checked =\n        defaultValue !== null &&\n        defaultValue !== undefined &&\n        defaultValue === data.buttonValue;\n    });\n\n    if (this.enableScripting && this.hasJSActions) {\n      const pdfButtonValue = data.buttonValue;\n      element.addEventListener(\"updatefromsandbox\", jsEvent => {\n        const actions = {\n          value: event => {\n            const checked = pdfButtonValue === event.detail.value;\n            for (const radio of this._getElementsByName(event.target.name)) {\n              const curChecked = checked && radio.id === id;\n              if (radio.domElement) {\n                radio.domElement.checked = curChecked;\n              }\n              storage.setValue(radio.id, { value: curChecked });\n            }\n          },\n        };\n        this._dispatchEventFromSandbox(actions, jsEvent);\n      });\n\n      this._setEventListeners(\n        element,\n        null,\n        [\n          [\"change\", \"Validate\"],\n          [\"change\", \"Action\"],\n          [\"focus\", \"Focus\"],\n          [\"blur\", \"Blur\"],\n          [\"mousedown\", \"Mouse Down\"],\n          [\"mouseenter\", \"Mouse Enter\"],\n          [\"mouseleave\", \"Mouse Exit\"],\n          [\"mouseup\", \"Mouse Up\"],\n        ],\n        event => event.target.checked\n      );\n    }\n\n    this._setBackgroundColor(element);\n    this._setDefaultPropertiesFromJS(element);\n\n    this.container.append(element);\n    return this.container;\n  }\n}\n\nclass PushButtonWidgetAnnotationElement extends LinkAnnotationElement {\n  constructor(parameters) {\n    super(parameters, { ignoreBorder: parameters.data.hasAppearance });\n  }\n\n  render() {\n    // The rendering and functionality of a push button widget annotation is\n    // equal to that of a link annotation, but may have more functionality, such\n    // as performing actions on form fields (resetting, submitting, et cetera).\n    const container = super.render();\n    container.classList.add(\"buttonWidgetAnnotation\", \"pushButton\");\n\n    const linkElement = container.lastChild;\n    if (this.enableScripting && this.hasJSActions && linkElement) {\n      this._setDefaultPropertiesFromJS(linkElement);\n\n      linkElement.addEventListener(\"updatefromsandbox\", jsEvent => {\n        this._dispatchEventFromSandbox({}, jsEvent);\n      });\n    }\n\n    return container;\n  }\n}\n\nclass ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: parameters.renderForms });\n  }\n\n  render() {\n    this.container.classList.add(\"choiceWidgetAnnotation\");\n    const storage = this.annotationStorage;\n    const id = this.data.id;\n\n    const storedData = storage.getValue(id, {\n      value: this.data.fieldValue,\n    });\n\n    const selectElement = document.createElement(\"select\");\n    GetElementsByNameSet.add(selectElement);\n    selectElement.setAttribute(\"data-element-id\", id);\n\n    selectElement.disabled = this.data.readOnly;\n    this._setRequired(selectElement, this.data.required);\n    selectElement.name = this.data.fieldName;\n    selectElement.tabIndex = 0;\n\n    let addAnEmptyEntry = this.data.combo && this.data.options.length > 0;\n\n    if (!this.data.combo) {\n      // List boxes have a size and (optionally) multiple selection.\n      selectElement.size = this.data.options.length;\n      if (this.data.multiSelect) {\n        selectElement.multiple = true;\n      }\n    }\n\n    selectElement.addEventListener(\"resetform\", event => {\n      const defaultValue = this.data.defaultFieldValue;\n      for (const option of selectElement.options) {\n        option.selected = option.value === defaultValue;\n      }\n    });\n\n    // Insert the options into the choice field.\n    for (const option of this.data.options) {\n      const optionElement = document.createElement(\"option\");\n      optionElement.textContent = option.displayValue;\n      optionElement.value = option.exportValue;\n      if (storedData.value.includes(option.exportValue)) {\n        optionElement.setAttribute(\"selected\", true);\n        addAnEmptyEntry = false;\n      }\n      selectElement.append(optionElement);\n    }\n\n    let removeEmptyEntry = null;\n    if (addAnEmptyEntry) {\n      const noneOptionElement = document.createElement(\"option\");\n      noneOptionElement.value = \" \";\n      noneOptionElement.setAttribute(\"hidden\", true);\n      noneOptionElement.setAttribute(\"selected\", true);\n      selectElement.prepend(noneOptionElement);\n\n      removeEmptyEntry = () => {\n        noneOptionElement.remove();\n        selectElement.removeEventListener(\"input\", removeEmptyEntry);\n        removeEmptyEntry = null;\n      };\n      selectElement.addEventListener(\"input\", removeEmptyEntry);\n    }\n\n    const getValue = isExport => {\n      const name = isExport ? \"value\" : \"textContent\";\n      const { options, multiple } = selectElement;\n      if (!multiple) {\n        return options.selectedIndex === -1\n          ? null\n          : options[options.selectedIndex][name];\n      }\n      return Array.prototype.filter\n        .call(options, option => option.selected)\n        .map(option => option[name]);\n    };\n\n    let selectedValues = getValue(/* isExport */ false);\n\n    const getItems = event => {\n      const options = event.target.options;\n      return Array.prototype.map.call(options, option => ({\n        displayValue: option.textContent,\n        exportValue: option.value,\n      }));\n    };\n\n    if (this.enableScripting && this.hasJSActions) {\n      selectElement.addEventListener(\"updatefromsandbox\", jsEvent => {\n        const actions = {\n          value(event) {\n            removeEmptyEntry?.();\n            const value = event.detail.value;\n            const values = new Set(Array.isArray(value) ? value : [value]);\n            for (const option of selectElement.options) {\n              option.selected = values.has(option.value);\n            }\n            storage.setValue(id, {\n              value: getValue(/* isExport */ true),\n            });\n            selectedValues = getValue(/* isExport */ false);\n          },\n          multipleSelection(event) {\n            selectElement.multiple = true;\n          },\n          remove(event) {\n            const options = selectElement.options;\n            const index = event.detail.remove;\n            options[index].selected = false;\n            selectElement.remove(index);\n            if (options.length > 0) {\n              const i = Array.prototype.findIndex.call(\n                options,\n                option => option.selected\n              );\n              if (i === -1) {\n                options[0].selected = true;\n              }\n            }\n            storage.setValue(id, {\n              value: getValue(/* isExport */ true),\n              items: getItems(event),\n            });\n            selectedValues = getValue(/* isExport */ false);\n          },\n          clear(event) {\n            while (selectElement.length !== 0) {\n              selectElement.remove(0);\n            }\n            storage.setValue(id, { value: null, items: [] });\n            selectedValues = getValue(/* isExport */ false);\n          },\n          insert(event) {\n            const { index, displayValue, exportValue } = event.detail.insert;\n            const selectChild = selectElement.children[index];\n            const optionElement = document.createElement(\"option\");\n            optionElement.textContent = displayValue;\n            optionElement.value = exportValue;\n\n            if (selectChild) {\n              selectChild.before(optionElement);\n            } else {\n              selectElement.append(optionElement);\n            }\n            storage.setValue(id, {\n              value: getValue(/* isExport */ true),\n              items: getItems(event),\n            });\n            selectedValues = getValue(/* isExport */ false);\n          },\n          items(event) {\n            const { items } = event.detail;\n            while (selectElement.length !== 0) {\n              selectElement.remove(0);\n            }\n            for (const item of items) {\n              const { displayValue, exportValue } = item;\n              const optionElement = document.createElement(\"option\");\n              optionElement.textContent = displayValue;\n              optionElement.value = exportValue;\n              selectElement.append(optionElement);\n            }\n            if (selectElement.options.length > 0) {\n              selectElement.options[0].selected = true;\n            }\n            storage.setValue(id, {\n              value: getValue(/* isExport */ true),\n              items: getItems(event),\n            });\n            selectedValues = getValue(/* isExport */ false);\n          },\n          indices(event) {\n            const indices = new Set(event.detail.indices);\n            for (const option of event.target.options) {\n              option.selected = indices.has(option.index);\n            }\n            storage.setValue(id, {\n              value: getValue(/* isExport */ true),\n            });\n            selectedValues = getValue(/* isExport */ false);\n          },\n          editable(event) {\n            event.target.disabled = !event.detail.editable;\n          },\n        };\n        this._dispatchEventFromSandbox(actions, jsEvent);\n      });\n\n      selectElement.addEventListener(\"input\", event => {\n        const exportValue = getValue(/* isExport */ true);\n        const change = getValue(/* isExport */ false);\n        storage.setValue(id, { value: exportValue });\n\n        event.preventDefault();\n\n        this.linkService.eventBus?.dispatch(\"dispatcheventinsandbox\", {\n          source: this,\n          detail: {\n            id,\n            name: \"Keystroke\",\n            value: selectedValues,\n            change,\n            changeEx: exportValue,\n            willCommit: false,\n            commitKey: 1,\n            keyDown: false,\n          },\n        });\n      });\n\n      this._setEventListeners(\n        selectElement,\n        null,\n        [\n          [\"focus\", \"Focus\"],\n          [\"blur\", \"Blur\"],\n          [\"mousedown\", \"Mouse Down\"],\n          [\"mouseenter\", \"Mouse Enter\"],\n          [\"mouseleave\", \"Mouse Exit\"],\n          [\"mouseup\", \"Mouse Up\"],\n          [\"input\", \"Action\"],\n          [\"input\", \"Validate\"],\n        ],\n        event => event.target.value\n      );\n    } else {\n      selectElement.addEventListener(\"input\", function (event) {\n        storage.setValue(id, { value: getValue(/* isExport */ true) });\n      });\n    }\n\n    if (this.data.combo) {\n      this._setTextStyle(selectElement);\n    } else {\n      // Just use the default font size...\n      // it's a bit hard to guess what is a good size.\n    }\n    this._setBackgroundColor(selectElement);\n    this._setDefaultPropertiesFromJS(selectElement);\n\n    this.container.append(selectElement);\n    return this.container;\n  }\n}\n\nclass PopupAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    const { data, elements, parent } = parameters;\n    const hasCommentManager = !!parent._commentManager;\n    super(parameters, {\n      isRenderable: !hasCommentManager && AnnotationElement._hasPopupData(data),\n    });\n    this.elements = elements;\n    if (hasCommentManager && AnnotationElement._hasPopupData(data)) {\n      const popup = (this.popup = this.#createPopup());\n      for (const element of elements) {\n        element.popup = popup;\n      }\n    } else {\n      this.popup = null;\n    }\n  }\n\n  #createPopup() {\n    return new PopupElement({\n      container: this.container,\n      color: this.data.color,\n      titleObj: this.data.titleObj,\n      modificationDate: this.data.modificationDate || this.data.creationDate,\n      contentsObj: this.data.contentsObj,\n      richText: this.data.richText,\n      rect: this.data.rect,\n      parentRect: this.data.parentRect || null,\n      parent: this.parent,\n      elements: this.elements,\n      open: this.data.open,\n      commentManager: this.parent._commentManager,\n    });\n  }\n\n  render() {\n    const { container } = this;\n    container.classList.add(\"popupAnnotation\");\n    container.role = \"comment\";\n\n    const popup = (this.popup = this.#createPopup());\n\n    const elementIds = [];\n    for (const element of this.elements) {\n      element.popup = popup;\n      element.container.ariaHasPopup = \"dialog\";\n      elementIds.push(element.data.id);\n      element.addHighlightArea();\n    }\n\n    this.container.setAttribute(\n      \"aria-controls\",\n      elementIds.map(id => `${AnnotationPrefix}${id}`).join(\",\")\n    );\n\n    return this.container;\n  }\n}\n\nclass PopupElement {\n  #commentManager = null;\n\n  #boundKeyDown = this.#keyDown.bind(this);\n\n  #boundHide = this.#hide.bind(this);\n\n  #boundShow = this.#show.bind(this);\n\n  #boundToggle = this.#toggle.bind(this);\n\n  #color = null;\n\n  #container = null;\n\n  #contentsObj = null;\n\n  #dateObj = null;\n\n  #elements = null;\n\n  #parent = null;\n\n  #parentRect = null;\n\n  #pinned = false;\n\n  #popup = null;\n\n  #popupAbortController = null;\n\n  #position = null;\n\n  #commentButton = null;\n\n  #commentButtonPosition = null;\n\n  #popupPosition = null;\n\n  #rect = null;\n\n  #richText = null;\n\n  #titleObj = null;\n\n  #updates = null;\n\n  #wasVisible = false;\n\n  #firstElement = null;\n\n  #commentText = null;\n\n  constructor({\n    container,\n    color,\n    elements,\n    titleObj,\n    modificationDate,\n    contentsObj,\n    richText,\n    parent,\n    rect,\n    parentRect,\n    open,\n    commentManager = null,\n  }) {\n    this.#container = container;\n    this.#titleObj = titleObj;\n    this.#contentsObj = contentsObj;\n    this.#richText = richText;\n    this.#parent = parent;\n    this.#color = color;\n    this.#rect = rect;\n    this.#parentRect = parentRect;\n    this.#elements = elements;\n    this.#commentManager = commentManager;\n    this.#firstElement = elements[0];\n\n    // The modification date is shown in the popup instead of the creation\n    // date if it is available and can be parsed correctly, which is\n    // consistent with other viewers such as Adobe Acrobat.\n    this.#dateObj = PDFDateString.toDateObject(modificationDate);\n\n    // The elements that will trigger the popup.\n    this.trigger = elements.flatMap(e => e.getElementsToTriggerPopup());\n\n    if (!commentManager) {\n      this.#addEventListeners();\n\n      this.#container.hidden = true;\n      if (open) {\n        this.#toggle();\n      }\n\n      if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n        // Since the popup is lazily created, we need to ensure that it'll be\n        // created and displayed during reference tests.\n        this.#parent.popupShow.push(async () => {\n          if (this.#container.hidden) {\n            this.#show();\n          }\n        });\n      }\n    }\n  }\n\n  #addEventListeners() {\n    if (this.#popupAbortController) {\n      return;\n    }\n    this.#popupAbortController = new AbortController();\n    const { signal } = this.#popupAbortController;\n\n    // Attach the event listeners to the trigger element.\n    for (const element of this.trigger) {\n      element.addEventListener(\"click\", this.#boundToggle, { signal });\n      element.addEventListener(\"pointerenter\", this.#boundShow, { signal });\n      element.addEventListener(\"pointerleave\", this.#boundHide, { signal });\n      element.classList.add(\"popupTriggerArea\");\n    }\n\n    // Attach the event listener to toggle the popup with the keyboard.\n    for (const element of this.#elements) {\n      element.container?.addEventListener(\"keydown\", this.#boundKeyDown, {\n        signal,\n      });\n    }\n  }\n\n  #setCommentButtonPosition() {\n    const element = this.#elements.find(e => e.hasCommentButton);\n    if (!element) {\n      return;\n    }\n    this.#commentButtonPosition = element._normalizePoint(\n      element.commentButtonPosition\n    );\n  }\n\n  renderCommentButton() {\n    if (this.#commentButton) {\n      if (!this.#commentButton.parentNode) {\n        this.#firstElement.container.after(this.#commentButton);\n      }\n      return;\n    }\n\n    if (!this.#commentButtonPosition) {\n      this.#setCommentButtonPosition();\n    }\n\n    if (!this.#commentButtonPosition) {\n      return;\n    }\n\n    const { signal } = (this.#popupAbortController = new AbortController());\n    const hasOwnButton = this.#firstElement.hasOwnCommentButton;\n    const togglePopup = () => {\n      this.#commentManager.toggleCommentPopup(\n        this,\n        /* isSelected = */ true,\n        /* visibility = */ undefined,\n        /* isEditable = */ !hasOwnButton\n      );\n    };\n    const showPopup = () => {\n      this.#commentManager.toggleCommentPopup(\n        this,\n        /* isSelected = */ false,\n        /* visibility = */ true,\n        /* isEditable = */ !hasOwnButton\n      );\n    };\n    const hidePopup = () => {\n      this.#commentManager.toggleCommentPopup(\n        this,\n        /* isSelected = */ false,\n        /* visibility = */ false\n      );\n    };\n\n    if (!hasOwnButton) {\n      const button = (this.#commentButton = document.createElement(\"button\"));\n      button.className = \"annotationCommentButton\";\n      const parentContainer = this.#firstElement.container;\n      button.style.zIndex = parentContainer.style.zIndex + 1;\n      button.tabIndex = 0;\n      button.ariaHasPopup = \"dialog\";\n      button.ariaControls = \"commentPopup\";\n      button.setAttribute(\"data-l10n-id\", \"pdfjs-show-comment-button\");\n      this.#updateColor();\n      this.#updateCommentButtonPosition();\n      button.addEventListener(\"keydown\", this.#boundKeyDown, { signal });\n      button.addEventListener(\"click\", togglePopup, { signal });\n      button.addEventListener(\"pointerenter\", showPopup, { signal });\n      button.addEventListener(\"pointerleave\", hidePopup, { signal });\n      parentContainer.after(button);\n    } else {\n      this.#commentButton = this.#firstElement.container;\n      for (const element of this.trigger) {\n        element.ariaHasPopup = \"dialog\";\n        element.ariaControls = \"commentPopup\";\n        element.addEventListener(\"keydown\", this.#boundKeyDown, { signal });\n        element.addEventListener(\"click\", togglePopup, { signal });\n        element.addEventListener(\"pointerenter\", showPopup, { signal });\n        element.addEventListener(\"pointerleave\", hidePopup, { signal });\n        element.classList.add(\"popupTriggerArea\");\n      }\n    }\n  }\n\n  #updateCommentButtonPosition() {\n    if (this.#firstElement.extraPopupElement && !this.#firstElement.editor) {\n      // If there's no editor associated with the annotation then the comment\n      // button position can't be changed.\n      return;\n    }\n    if (!this.#commentButton) {\n      this.renderCommentButton();\n    }\n    const [x, y] = this.#commentButtonPosition;\n    const { style } = this.#commentButton;\n    style.left = `calc(${x}%)`;\n    style.top = `calc(${y}% - var(--comment-button-dim))`;\n  }\n\n  #updateColor() {\n    if (this.#firstElement.extraPopupElement) {\n      return;\n    }\n    if (!this.#commentButton) {\n      this.renderCommentButton();\n    }\n    this.#commentButton.style.backgroundColor = this.commentButtonColor || \"\";\n  }\n\n  get commentButtonColor() {\n    const { color, opacity } = this.#firstElement.commentData;\n    if (!color) {\n      return null;\n    }\n    return this.#parent._commentManager.makeCommentColor(color, opacity);\n  }\n\n  focusCommentButton() {\n    setTimeout(() => {\n      this.#commentButton?.focus();\n    }, 0);\n  }\n\n  getData() {\n    const { richText, color, opacity, creationDate, modificationDate } =\n      this.#firstElement.commentData;\n    return {\n      contentsObj: { str: this.comment },\n      richText,\n      color,\n      opacity,\n      creationDate,\n      modificationDate,\n    };\n  }\n\n  get elementBeforePopup() {\n    return this.#commentButton;\n  }\n\n  get comment() {\n    this.#commentText ||= this.#firstElement.commentText;\n    return this.#commentText;\n  }\n\n  set comment(text) {\n    if (text === this.comment) {\n      return;\n    }\n    this.#firstElement.commentText = this.#commentText = text;\n  }\n\n  focus() {\n    this.#firstElement.container?.focus();\n  }\n\n  get parentBoundingClientRect() {\n    return this.#firstElement.layer.getBoundingClientRect();\n  }\n\n  setCommentButtonStates({ selected, hasPopup }) {\n    if (!this.#commentButton) {\n      return;\n    }\n    this.#commentButton.classList.toggle(\"selected\", selected);\n    this.#commentButton.ariaExpanded = hasPopup;\n  }\n\n  setSelectedCommentButton(selected) {\n    this.#commentButton.classList.toggle(\"selected\", selected);\n  }\n\n  get commentPopupPosition() {\n    if (this.#popupPosition) {\n      return this.#popupPosition;\n    }\n    const { x, y, height } = this.#commentButton.getBoundingClientRect();\n    const {\n      x: parentX,\n      y: parentY,\n      width: parentWidth,\n      height: parentHeight,\n    } = this.#firstElement.layer.getBoundingClientRect();\n    return [(x - parentX) / parentWidth, (y + height - parentY) / parentHeight];\n  }\n\n  set commentPopupPosition(pos) {\n    this.#popupPosition = pos;\n  }\n\n  hasDefaultPopupPosition() {\n    return this.#popupPosition === null;\n  }\n\n  get commentButtonPosition() {\n    return this.#commentButtonPosition;\n  }\n\n  get commentButtonWidth() {\n    return (\n      this.#commentButton.getBoundingClientRect().width /\n      this.parentBoundingClientRect.width\n    );\n  }\n\n  editComment(options) {\n    const [posX, posY] =\n      this.#popupPosition || this.commentButtonPosition.map(x => x / 100);\n    const parentDimensions = this.parentBoundingClientRect;\n    const {\n      x: parentX,\n      y: parentY,\n      width: parentWidth,\n      height: parentHeight,\n    } = parentDimensions;\n    this.#commentManager.showDialog(\n      null,\n      this,\n      parentX + posX * parentWidth,\n      parentY + posY * parentHeight,\n      { ...options, parentDimensions }\n    );\n  }\n\n  render() {\n    if (this.#popup) {\n      return;\n    }\n\n    const popup = (this.#popup = document.createElement(\"div\"));\n    popup.className = \"popup\";\n\n    if (this.#color) {\n      const baseColor = (popup.style.outlineColor = Util.makeHexColor(\n        ...this.#color\n      ));\n      popup.style.backgroundColor = `color-mix(in srgb, ${baseColor} 30%, white)`;\n    }\n\n    const header = document.createElement(\"span\");\n    header.className = \"header\";\n    if (this.#titleObj?.str) {\n      const title = document.createElement(\"span\");\n      title.className = \"title\";\n      header.append(title);\n      ({ dir: title.dir, str: title.textContent } = this.#titleObj);\n    }\n    popup.append(header);\n\n    if (this.#dateObj) {\n      const modificationDate = document.createElement(\"time\");\n      modificationDate.className = \"popupDate\";\n      modificationDate.setAttribute(\n        \"data-l10n-id\",\n        \"pdfjs-annotation-date-time-string\"\n      );\n      modificationDate.setAttribute(\n        \"data-l10n-args\",\n        JSON.stringify({ dateObj: this.#dateObj.valueOf() })\n      );\n      modificationDate.dateTime = this.#dateObj.toISOString();\n      header.append(modificationDate);\n    }\n\n    renderRichText(\n      {\n        html: this.#html || this.#contentsObj.str,\n        dir: this.#contentsObj?.dir,\n        className: \"popupContent\",\n      },\n      popup\n    );\n\n    this.#container.append(popup);\n  }\n\n  get #html() {\n    const richText = this.#richText;\n    const contentsObj = this.#contentsObj;\n    if (\n      richText?.str &&\n      (!contentsObj?.str || contentsObj.str === richText.str)\n    ) {\n      return this.#richText.html || null;\n    }\n    return null;\n  }\n\n  get #fontSize() {\n    return this.#html?.attributes?.style?.fontSize || 0;\n  }\n\n  get #fontColor() {\n    return this.#html?.attributes?.style?.color || null;\n  }\n\n  #makePopupContent(text) {\n    const popupLines = [];\n    const popupContent = {\n      str: text,\n      html: {\n        name: \"div\",\n        attributes: {\n          dir: \"auto\",\n        },\n        children: [\n          {\n            name: \"p\",\n            children: popupLines,\n          },\n        ],\n      },\n    };\n    const lineAttributes = {\n      style: {\n        color: this.#fontColor,\n        fontSize: this.#fontSize\n          ? `calc(${this.#fontSize}px * var(--total-scale-factor))`\n          : \"\",\n      },\n    };\n    for (const line of text.split(\"\\n\")) {\n      popupLines.push({\n        name: \"span\",\n        value: line,\n        attributes: lineAttributes,\n      });\n    }\n    return popupContent;\n  }\n\n  #keyDown(event) {\n    if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {\n      return;\n    }\n\n    if (event.key === \"Enter\" || (event.key === \"Escape\" && this.#pinned)) {\n      this.#toggle();\n    }\n  }\n\n  updateEdited({ rect, popup, deleted }) {\n    if (this.#commentManager) {\n      if (deleted) {\n        this.remove();\n        this.#commentText = null;\n      } else if (popup) {\n        if (popup.deleted) {\n          this.remove();\n        } else {\n          this.#updateColor();\n          this.#commentText = popup.text;\n        }\n      }\n      if (rect) {\n        this.#commentButtonPosition = null;\n        this.#setCommentButtonPosition();\n        this.#updateCommentButtonPosition();\n      }\n      return;\n    }\n    if (deleted || popup?.deleted) {\n      this.remove();\n      return;\n    }\n    this.#addEventListeners();\n    this.#updates ||= {\n      contentsObj: this.#contentsObj,\n      richText: this.#richText,\n    };\n    if (rect) {\n      this.#position = null;\n    }\n    if (popup && popup.text) {\n      this.#richText = this.#makePopupContent(popup.text);\n      this.#dateObj = PDFDateString.toDateObject(popup.date);\n      this.#contentsObj = null;\n    }\n    this.#popup?.remove();\n    this.#popup = null;\n  }\n\n  resetEdited() {\n    if (!this.#updates) {\n      return;\n    }\n    ({ contentsObj: this.#contentsObj, richText: this.#richText } =\n      this.#updates);\n    this.#updates = null;\n    this.#popup?.remove();\n    this.#popup = null;\n    this.#position = null;\n  }\n\n  remove() {\n    this.#popupAbortController?.abort();\n    this.#popupAbortController = null;\n    this.#popup?.remove();\n    this.#popup = null;\n    this.#wasVisible = false;\n    this.#pinned = false;\n    this.#commentButton?.remove();\n    this.#commentButton = null;\n    if (this.trigger) {\n      for (const element of this.trigger) {\n        element.classList.remove(\"popupTriggerArea\");\n      }\n    }\n  }\n\n  #setPosition() {\n    if (this.#position !== null) {\n      return;\n    }\n    const {\n      page: { view },\n      viewport: {\n        rawDims: { pageWidth, pageHeight, pageX, pageY },\n      },\n    } = this.#parent;\n\n    let useParentRect = !!this.#parentRect;\n    let rect = useParentRect ? this.#parentRect : this.#rect;\n    for (const element of this.#elements) {\n      if (!rect || Util.intersect(element.data.rect, rect) !== null) {\n        rect = element.data.rect;\n        useParentRect = true;\n        break;\n      }\n    }\n\n    const normalizedRect = Util.normalizeRect([\n      rect[0],\n      view[3] - rect[1] + view[1],\n      rect[2],\n      view[3] - rect[3] + view[1],\n    ]);\n\n    const HORIZONTAL_SPACE_AFTER_ANNOTATION = 5;\n    const parentWidth = useParentRect\n      ? rect[2] - rect[0] + HORIZONTAL_SPACE_AFTER_ANNOTATION\n      : 0;\n    const popupLeft = normalizedRect[0] + parentWidth;\n    const popupTop = normalizedRect[1];\n    this.#position = [\n      (100 * (popupLeft - pageX)) / pageWidth,\n      (100 * (popupTop - pageY)) / pageHeight,\n    ];\n\n    const { style } = this.#container;\n    style.left = `${this.#position[0]}%`;\n    style.top = `${this.#position[1]}%`;\n  }\n\n  /**\n   * Toggle the visibility of the popup.\n   */\n  #toggle() {\n    if (this.#commentManager) {\n      this.#commentManager.toggleCommentPopup(this, /* isSelected = */ false);\n      return;\n    }\n\n    this.#pinned = !this.#pinned;\n    if (this.#pinned) {\n      this.#show();\n      this.#container.addEventListener(\"click\", this.#boundToggle);\n      this.#container.addEventListener(\"keydown\", this.#boundKeyDown);\n    } else {\n      this.#hide();\n      this.#container.removeEventListener(\"click\", this.#boundToggle);\n      this.#container.removeEventListener(\"keydown\", this.#boundKeyDown);\n    }\n  }\n\n  /**\n   * Show the popup.\n   */\n  #show() {\n    if (!this.#popup) {\n      this.render();\n    }\n    if (!this.isVisible) {\n      this.#setPosition();\n      this.#container.hidden = false;\n      this.#container.style.zIndex =\n        parseInt(this.#container.style.zIndex) + 1000;\n    } else if (this.#pinned) {\n      this.#container.classList.add(\"focused\");\n    }\n  }\n\n  /**\n   * Hide the popup.\n   */\n  #hide() {\n    this.#container.classList.remove(\"focused\");\n    if (this.#pinned || !this.isVisible) {\n      return;\n    }\n    this.#container.hidden = true;\n    this.#container.style.zIndex =\n      parseInt(this.#container.style.zIndex) - 1000;\n  }\n\n  forceHide() {\n    this.#wasVisible = this.isVisible;\n    if (!this.#wasVisible) {\n      return;\n    }\n    this.#container.hidden = true;\n  }\n\n  maybeShow() {\n    if (this.#commentManager) {\n      return;\n    }\n    this.#addEventListeners();\n    if (!this.#wasVisible) {\n      return;\n    }\n    if (!this.#popup) {\n      this.#show();\n    }\n    this.#wasVisible = false;\n    this.#container.hidden = false;\n  }\n\n  get isVisible() {\n    if (this.#commentManager) {\n      return false;\n    }\n    return this.#container.hidden === false;\n  }\n}\n\nclass FreeTextAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n    this.textContent = parameters.data.textContent;\n    this.textPosition = parameters.data.textPosition;\n    this.annotationEditorType = AnnotationEditorType.FREETEXT;\n  }\n\n  render() {\n    this.container.classList.add(\"freeTextAnnotation\");\n\n    if (this.textContent) {\n      const content = (this.contentElement = document.createElement(\"div\"));\n      content.classList.add(\"annotationTextContent\");\n      content.setAttribute(\"role\", \"comment\");\n      for (const line of this.textContent) {\n        const lineSpan = document.createElement(\"span\");\n        lineSpan.textContent = line;\n        content.append(lineSpan);\n      }\n      this.container.append(content);\n    }\n\n    if (!this.data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    this._editOnDoubleClick();\n\n    return this.container;\n  }\n}\n\nclass LineAnnotationElement extends AnnotationElement {\n  #line = null;\n\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n  }\n\n  render() {\n    this.container.classList.add(\"lineAnnotation\");\n\n    // Create an invisible line with the same starting and ending coordinates\n    // that acts as the trigger for the popup. Only the line itself should\n    // trigger the popup, not the entire container.\n    const { data, width, height } = this;\n    const svg = this.svgFactory.create(\n      width,\n      height,\n      /* skipDimensions = */ true\n    );\n\n    // PDF coordinates are calculated from a bottom left origin, so transform\n    // the line coordinates to a top left origin for the SVG element.\n    const line = (this.#line = this.svgFactory.createElement(\"svg:line\"));\n    line.setAttribute(\"x1\", data.rect[2] - data.lineCoordinates[0]);\n    line.setAttribute(\"y1\", data.rect[3] - data.lineCoordinates[1]);\n    line.setAttribute(\"x2\", data.rect[2] - data.lineCoordinates[2]);\n    line.setAttribute(\"y2\", data.rect[3] - data.lineCoordinates[3]);\n    // Ensure that the 'stroke-width' is always non-zero, since otherwise it\n    // won't be possible to open/close the popup (note e.g. issue 11122).\n    line.setAttribute(\"stroke-width\", data.borderStyle.width || 1);\n    line.setAttribute(\"stroke\", \"transparent\");\n    line.setAttribute(\"fill\", \"transparent\");\n\n    svg.append(line);\n    this.container.append(svg);\n\n    // Create the popup ourselves so that we can bind it to the line instead\n    // of to the entire container (which is the default).\n    if (!data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    return this.container;\n  }\n\n  getElementsToTriggerPopup() {\n    return this.#line;\n  }\n\n  addHighlightArea() {\n    this.container.classList.add(\"highlightArea\");\n  }\n}\n\nclass SquareAnnotationElement extends AnnotationElement {\n  #square = null;\n\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n  }\n\n  render() {\n    this.container.classList.add(\"squareAnnotation\");\n\n    // Create an invisible square with the same rectangle that acts as the\n    // trigger for the popup. Only the square itself should trigger the\n    // popup, not the entire container.\n    const { data, width, height } = this;\n    const svg = this.svgFactory.create(\n      width,\n      height,\n      /* skipDimensions = */ true\n    );\n\n    // The browser draws half of the borders inside the square and half of\n    // the borders outside the square by default. This behavior cannot be\n    // changed programmatically, so correct for that here.\n    const borderWidth = data.borderStyle.width;\n    const square = (this.#square = this.svgFactory.createElement(\"svg:rect\"));\n    square.setAttribute(\"x\", borderWidth / 2);\n    square.setAttribute(\"y\", borderWidth / 2);\n    square.setAttribute(\"width\", width - borderWidth);\n    square.setAttribute(\"height\", height - borderWidth);\n    // Ensure that the 'stroke-width' is always non-zero, since otherwise it\n    // won't be possible to open/close the popup (note e.g. issue 11122).\n    square.setAttribute(\"stroke-width\", borderWidth || 1);\n    square.setAttribute(\"stroke\", \"transparent\");\n    square.setAttribute(\"fill\", \"transparent\");\n\n    svg.append(square);\n    this.container.append(svg);\n\n    // Create the popup ourselves so that we can bind it to the square instead\n    // of to the entire container (which is the default).\n    if (!data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    return this.container;\n  }\n\n  getElementsToTriggerPopup() {\n    return this.#square;\n  }\n\n  addHighlightArea() {\n    this.container.classList.add(\"highlightArea\");\n  }\n}\n\nclass CircleAnnotationElement extends AnnotationElement {\n  #circle = null;\n\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n  }\n\n  render() {\n    this.container.classList.add(\"circleAnnotation\");\n\n    // Create an invisible circle with the same ellipse that acts as the\n    // trigger for the popup. Only the circle itself should trigger the\n    // popup, not the entire container.\n    const { data, width, height } = this;\n    const svg = this.svgFactory.create(\n      width,\n      height,\n      /* skipDimensions = */ true\n    );\n\n    // The browser draws half of the borders inside the circle and half of\n    // the borders outside the circle by default. This behavior cannot be\n    // changed programmatically, so correct for that here.\n    const borderWidth = data.borderStyle.width;\n    const circle = (this.#circle =\n      this.svgFactory.createElement(\"svg:ellipse\"));\n    circle.setAttribute(\"cx\", width / 2);\n    circle.setAttribute(\"cy\", height / 2);\n    circle.setAttribute(\"rx\", width / 2 - borderWidth / 2);\n    circle.setAttribute(\"ry\", height / 2 - borderWidth / 2);\n    // Ensure that the 'stroke-width' is always non-zero, since otherwise it\n    // won't be possible to open/close the popup (note e.g. issue 11122).\n    circle.setAttribute(\"stroke-width\", borderWidth || 1);\n    circle.setAttribute(\"stroke\", \"transparent\");\n    circle.setAttribute(\"fill\", \"transparent\");\n\n    svg.append(circle);\n    this.container.append(svg);\n\n    // Create the popup ourselves so that we can bind it to the circle instead\n    // of to the entire container (which is the default).\n    if (!data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    return this.container;\n  }\n\n  getElementsToTriggerPopup() {\n    return this.#circle;\n  }\n\n  addHighlightArea() {\n    this.container.classList.add(\"highlightArea\");\n  }\n}\n\nclass PolylineAnnotationElement extends AnnotationElement {\n  #polyline = null;\n\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n\n    this.containerClassName = \"polylineAnnotation\";\n    this.svgElementName = \"svg:polyline\";\n  }\n\n  render() {\n    this.container.classList.add(this.containerClassName);\n\n    // Create an invisible polyline with the same points that acts as the\n    // trigger for the popup. Only the polyline itself should trigger the\n    // popup, not the entire container.\n    const {\n      data: { rect, vertices, borderStyle, popupRef },\n      width,\n      height,\n    } = this;\n    if (!vertices) {\n      return this.container;\n    }\n    const svg = this.svgFactory.create(\n      width,\n      height,\n      /* skipDimensions = */ true\n    );\n\n    // Convert the vertices array to a single points string that the SVG\n    // polyline element expects (\"x1,y1 x2,y2 ...\"). PDF coordinates are\n    // calculated from a bottom left origin, so transform the polyline\n    // coordinates to a top left origin for the SVG element.\n    let points = [];\n    for (let i = 0, ii = vertices.length; i < ii; i += 2) {\n      const x = vertices[i] - rect[0];\n      const y = rect[3] - vertices[i + 1];\n      points.push(`${x},${y}`);\n    }\n    points = points.join(\" \");\n\n    const polyline = (this.#polyline = this.svgFactory.createElement(\n      this.svgElementName\n    ));\n    polyline.setAttribute(\"points\", points);\n    // Ensure that the 'stroke-width' is always non-zero, since otherwise it\n    // won't be possible to open/close the popup (note e.g. issue 11122).\n    polyline.setAttribute(\"stroke-width\", borderStyle.width || 1);\n    polyline.setAttribute(\"stroke\", \"transparent\");\n    polyline.setAttribute(\"fill\", \"transparent\");\n\n    svg.append(polyline);\n    this.container.append(svg);\n\n    // Create the popup ourselves so that we can bind it to the polyline\n    // instead of to the entire container (which is the default).\n    if (!popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    return this.container;\n  }\n\n  getElementsToTriggerPopup() {\n    return this.#polyline;\n  }\n\n  addHighlightArea() {\n    this.container.classList.add(\"highlightArea\");\n  }\n}\n\nclass PolygonAnnotationElement extends PolylineAnnotationElement {\n  constructor(parameters) {\n    // Polygons are specific forms of polylines, so reuse their logic.\n    super(parameters);\n\n    this.containerClassName = \"polygonAnnotation\";\n    this.svgElementName = \"svg:polygon\";\n  }\n}\n\nclass CaretAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n  }\n\n  render() {\n    this.container.classList.add(\"caretAnnotation\");\n\n    if (!this.data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n    return this.container;\n  }\n}\n\nclass InkAnnotationElement extends AnnotationElement {\n  #polylinesGroupElement = null;\n\n  #polylines = [];\n\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n\n    this.containerClassName = \"inkAnnotation\";\n\n    // Use the polyline SVG element since it allows us to use coordinates\n    // directly and to draw both straight lines and curves.\n    this.svgElementName = \"svg:polyline\";\n\n    this.annotationEditorType =\n      this.data.it === \"InkHighlight\"\n        ? AnnotationEditorType.HIGHLIGHT\n        : AnnotationEditorType.INK;\n  }\n\n  #getTransform(rotation, rect) {\n    // PDF coordinates are calculated from a bottom left origin, so\n    // transform the polyline coordinates to a top left origin for the\n    // SVG element.\n    switch (rotation) {\n      case 90:\n        return {\n          transform: `rotate(90) translate(${-rect[0]},${rect[1]}) scale(1,-1)`,\n          width: rect[3] - rect[1],\n          height: rect[2] - rect[0],\n        };\n      case 180:\n        return {\n          transform: `rotate(180) translate(${-rect[2]},${rect[1]}) scale(1,-1)`,\n          width: rect[2] - rect[0],\n          height: rect[3] - rect[1],\n        };\n      case 270:\n        return {\n          transform: `rotate(270) translate(${-rect[2]},${rect[3]}) scale(1,-1)`,\n          width: rect[3] - rect[1],\n          height: rect[2] - rect[0],\n        };\n      default:\n        return {\n          transform: `translate(${-rect[0]},${rect[3]}) scale(1,-1)`,\n          width: rect[2] - rect[0],\n          height: rect[3] - rect[1],\n        };\n    }\n  }\n\n  render() {\n    this.container.classList.add(this.containerClassName);\n\n    // Create an invisible polyline with the same points that acts as the\n    // trigger for the popup.\n    const {\n      data: { rect, rotation, inkLists, borderStyle, popupRef },\n    } = this;\n    const { transform, width, height } = this.#getTransform(rotation, rect);\n\n    const svg = this.svgFactory.create(\n      width,\n      height,\n      /* skipDimensions = */ true\n    );\n    const g = (this.#polylinesGroupElement =\n      this.svgFactory.createElement(\"svg:g\"));\n    svg.append(g);\n    // Ensure that the 'stroke-width' is always non-zero, since otherwise it\n    // won't be possible to open/close the popup (note e.g. issue 11122).\n    g.setAttribute(\"stroke-width\", borderStyle.width || 1);\n    g.setAttribute(\"stroke-linecap\", \"round\");\n    g.setAttribute(\"stroke-linejoin\", \"round\");\n    g.setAttribute(\"stroke-miterlimit\", 10);\n    g.setAttribute(\"stroke\", \"transparent\");\n    g.setAttribute(\"fill\", \"transparent\");\n    g.setAttribute(\"transform\", transform);\n\n    for (let i = 0, ii = inkLists.length; i < ii; i++) {\n      const polyline = this.svgFactory.createElement(this.svgElementName);\n      this.#polylines.push(polyline);\n      polyline.setAttribute(\"points\", inkLists[i].join(\",\"));\n      g.append(polyline);\n    }\n\n    if (!popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    this.container.append(svg);\n    this._editOnDoubleClick();\n\n    return this.container;\n  }\n\n  updateEdited(params) {\n    super.updateEdited(params);\n    const { thickness, points, rect } = params;\n    const g = this.#polylinesGroupElement;\n    if (thickness >= 0) {\n      g.setAttribute(\"stroke-width\", thickness || 1);\n    }\n    if (points) {\n      for (let i = 0, ii = this.#polylines.length; i < ii; i++) {\n        this.#polylines[i].setAttribute(\"points\", points[i].join(\",\"));\n      }\n    }\n    if (rect) {\n      const { transform, width, height } = this.#getTransform(\n        this.data.rotation,\n        rect\n      );\n      const root = g.parentElement;\n      root.setAttribute(\"viewBox\", `0 0 ${width} ${height}`);\n      g.setAttribute(\"transform\", transform);\n    }\n  }\n\n  getElementsToTriggerPopup() {\n    return this.#polylines;\n  }\n\n  addHighlightArea() {\n    this.container.classList.add(\"highlightArea\");\n  }\n}\n\nclass HighlightAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, {\n      isRenderable: true,\n      ignoreBorder: true,\n      createQuadrilaterals: true,\n    });\n    this.annotationEditorType = AnnotationEditorType.HIGHLIGHT;\n  }\n\n  render() {\n    const {\n      data: { overlaidText, popupRef },\n    } = this;\n    if (!popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    this.container.classList.add(\"highlightAnnotation\");\n    this._editOnDoubleClick();\n\n    if (overlaidText) {\n      const mark = document.createElement(\"mark\");\n      mark.classList.add(\"overlaidText\");\n      mark.textContent = overlaidText;\n      this.container.append(mark);\n    }\n\n    return this.container;\n  }\n}\n\nclass UnderlineAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, {\n      isRenderable: true,\n      ignoreBorder: true,\n      createQuadrilaterals: true,\n    });\n  }\n\n  render() {\n    const {\n      data: { overlaidText, popupRef },\n    } = this;\n    if (!popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    this.container.classList.add(\"underlineAnnotation\");\n\n    if (overlaidText) {\n      const underline = document.createElement(\"u\");\n      underline.classList.add(\"overlaidText\");\n      underline.textContent = overlaidText;\n      this.container.append(underline);\n    }\n\n    return this.container;\n  }\n}\n\nclass SquigglyAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, {\n      isRenderable: true,\n      ignoreBorder: true,\n      createQuadrilaterals: true,\n    });\n  }\n\n  render() {\n    const {\n      data: { overlaidText, popupRef },\n    } = this;\n    if (!popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    this.container.classList.add(\"squigglyAnnotation\");\n\n    if (overlaidText) {\n      const underline = document.createElement(\"u\");\n      underline.classList.add(\"overlaidText\");\n      underline.textContent = overlaidText;\n      this.container.append(underline);\n    }\n\n    return this.container;\n  }\n}\n\nclass StrikeOutAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, {\n      isRenderable: true,\n      ignoreBorder: true,\n      createQuadrilaterals: true,\n    });\n  }\n\n  render() {\n    const {\n      data: { overlaidText, popupRef },\n    } = this;\n    if (!popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n\n    this.container.classList.add(\"strikeoutAnnotation\");\n\n    if (overlaidText) {\n      const strikeout = document.createElement(\"s\");\n      strikeout.classList.add(\"overlaidText\");\n      strikeout.textContent = overlaidText;\n      this.container.append(strikeout);\n    }\n\n    return this.container;\n  }\n}\n\nclass StampAnnotationElement extends AnnotationElement {\n  constructor(parameters) {\n    super(parameters, { isRenderable: true, ignoreBorder: true });\n    this.annotationEditorType = AnnotationEditorType.STAMP;\n  }\n\n  render() {\n    this.container.classList.add(\"stampAnnotation\");\n    this.container.setAttribute(\"role\", \"img\");\n\n    if (!this.data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    }\n    this._editOnDoubleClick();\n\n    return this.container;\n  }\n}\n\nclass FileAttachmentAnnotationElement extends AnnotationElement {\n  #trigger = null;\n\n  constructor(parameters) {\n    super(parameters, { isRenderable: true });\n\n    const { file } = this.data;\n    this.filename = file.filename;\n    this.content = file.content;\n\n    this.linkService.eventBus?.dispatch(\"fileattachmentannotation\", {\n      source: this,\n      ...file,\n    });\n  }\n\n  render() {\n    this.container.classList.add(\"fileAttachmentAnnotation\");\n\n    const { container, data } = this;\n    let trigger;\n    if (data.hasAppearance || data.fillAlpha === 0) {\n      trigger = document.createElement(\"div\");\n    } else {\n      // Unfortunately it seems that it's not clearly specified exactly what\n      // names are actually valid, since Table 184 contains:\n      //   Conforming readers shall provide predefined icon appearances for at\n      //   least the following standard names: GraphPushPin, PaperclipTag.\n      //   Additional names may be supported as well. Default value: PushPin.\n      trigger = document.createElement(\"img\");\n      trigger.src = `${this.imageResourcesPath}annotation-${\n        /paperclip/i.test(data.name) ? \"paperclip\" : \"pushpin\"\n      }.svg`;\n\n      if (data.fillAlpha && data.fillAlpha < 1) {\n        trigger.style = `filter: opacity(${Math.round(\n          data.fillAlpha * 100\n        )}%);`;\n\n        if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n          this.container.classList.add(\"hasFillAlpha\");\n        }\n      }\n    }\n    trigger.addEventListener(\"dblclick\", this.#download.bind(this));\n    this.#trigger = trigger;\n\n    const { isMac } = FeatureTest.platform;\n    container.addEventListener(\"keydown\", evt => {\n      if (evt.key === \"Enter\" && (isMac ? evt.metaKey : evt.ctrlKey)) {\n        this.#download();\n      }\n    });\n\n    if (!data.popupRef && this.hasPopupData) {\n      this.hasOwnCommentButton = true;\n      this._createPopup();\n    } else {\n      trigger.classList.add(\"popupTriggerArea\");\n    }\n\n    container.append(trigger);\n    return container;\n  }\n\n  getElementsToTriggerPopup() {\n    return this.#trigger;\n  }\n\n  addHighlightArea() {\n    this.container.classList.add(\"highlightArea\");\n  }\n\n  /**\n   * Download the file attachment associated with this annotation.\n   */\n  #download() {\n    this.downloadManager?.openOrDownloadData(this.content, this.filename);\n  }\n}\n\n/**\n * @typedef {Object} AnnotationLayerParameters\n * @property {PageViewport} viewport\n * @property {HTMLDivElement} div\n * @property {Array} annotations\n * @property {PDFPageProxy} page\n * @property {PDFLinkService} linkService\n * @property {BaseDownloadManager} [downloadManager]\n * @property {AnnotationStorage} [annotationStorage]\n * @property {string} [imageResourcesPath] - Path for image resources, mainly\n *   for annotation icons. Include trailing slash.\n * @property {boolean} renderForms\n * @property {boolean} [enableScripting] - Enable embedded script execution.\n * @property {boolean} [hasJSActions] - Some fields have JS actions.\n *   The default value is `false`.\n * @property {Object<string, Array<Object>> | null} [fieldObjects]\n * @property {Map<string, HTMLCanvasElement>} [annotationCanvasMap]\n * @property {TextAccessibilityManager} [accessibilityManager]\n * @property {AnnotationEditorUIManager} [annotationEditorUIManager]\n * @property {StructTreeLayerBuilder} [structTreeLayer]\n * @property {CommentManager} [commentManager] - The comment manager instance.\n */\n\n/**\n * Manage the layer containing all the annotations.\n */\nclass AnnotationLayer {\n  #accessibilityManager = null;\n\n  #annotationCanvasMap = null;\n\n  #annotationStorage = null;\n\n  #editableAnnotations = new Map();\n\n  #structTreeLayer = null;\n\n  #linkService = null;\n\n  #elements = [];\n\n  #hasAriaAttributesFromStructTree = false;\n\n  constructor({\n    div,\n    accessibilityManager,\n    annotationCanvasMap,\n    annotationEditorUIManager,\n    page,\n    viewport,\n    structTreeLayer,\n    commentManager,\n    linkService,\n    annotationStorage,\n  }) {\n    this.div = div;\n    this.#accessibilityManager = accessibilityManager;\n    this.#annotationCanvasMap = annotationCanvasMap;\n    this.#structTreeLayer = structTreeLayer || null;\n    this.#linkService = linkService || null;\n    this.#annotationStorage = annotationStorage || new AnnotationStorage();\n    this.page = page;\n    this.viewport = viewport;\n    this.zIndex = 0;\n    this._annotationEditorUIManager = annotationEditorUIManager;\n    this._commentManager = commentManager || null;\n\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n      // For testing purposes.\n      Object.defineProperty(this, \"showPopups\", {\n        value: async () => {\n          for (const show of this.popupShow) {\n            await show();\n          }\n        },\n      });\n      this.popupShow = [];\n    }\n  }\n\n  hasEditableAnnotations() {\n    return this.#editableAnnotations.size > 0;\n  }\n\n  /**\n   * Render a new annotation layer with all annotation elements.\n   *\n   * @param {AnnotationLayerParameters} params\n   * @memberof AnnotationLayer\n   */\n  async render(params) {\n    const { annotations } = params;\n    const layer = this.div;\n    setLayerDimensions(layer, this.viewport);\n\n    const popupToElements = new Map();\n    const popupAnnotations = [];\n    const elementParams = {\n      data: null,\n      layer,\n      linkService: this.#linkService,\n      downloadManager: params.downloadManager,\n      imageResourcesPath: params.imageResourcesPath || \"\",\n      renderForms: params.renderForms !== false,\n      svgFactory: new DOMSVGFactory(),\n      annotationStorage: this.#annotationStorage,\n      enableComment: params.enableComment === true,\n      enableScripting: params.enableScripting === true,\n      hasJSActions: params.hasJSActions,\n      fieldObjects: params.fieldObjects,\n      parent: this,\n      elements: null,\n    };\n\n    for (const data of annotations) {\n      if (data.noHTML) {\n        continue;\n      }\n      const isPopupAnnotation = data.annotationType === AnnotationType.POPUP;\n      if (!isPopupAnnotation) {\n        if (data.rect[2] === data.rect[0] || data.rect[3] === data.rect[1]) {\n          continue; // Ignore empty annotations.\n        }\n      } else {\n        const elements = popupToElements.get(data.id);\n        if (!elements) {\n          // Ignore popup annotations without a corresponding annotation.\n          continue;\n        }\n        if (!this._commentManager) {\n          popupAnnotations.push(data);\n          continue;\n        }\n        elementParams.elements = elements;\n      }\n      elementParams.data = data;\n      const element = AnnotationElementFactory.create(elementParams);\n\n      if (!element.isRenderable) {\n        continue;\n      }\n\n      if (!isPopupAnnotation) {\n        this.#elements.push(element);\n\n        if (data.popupRef) {\n          popupToElements\n            .getOrInsertComputed(data.popupRef, makeArr)\n            .push(element);\n        }\n      }\n\n      const rendered = element.render();\n      if (data.hidden) {\n        rendered.style.visibility = \"hidden\";\n      }\n\n      if (element._isEditable) {\n        this.#editableAnnotations.set(element.data.id, element);\n        this._annotationEditorUIManager?.renderAnnotationElement(element);\n      }\n    }\n\n    await this.#addElementsToDOM();\n\n    for (const data of popupAnnotations) {\n      const elements = (elementParams.elements = popupToElements.get(data.id));\n      elementParams.data = data;\n      const element = AnnotationElementFactory.create(elementParams);\n      if (!element.isRenderable) {\n        continue;\n      }\n      const rendered = element.render();\n      element.contentElement.id = `${AnnotationPrefix}${data.id}`;\n      if (data.hidden) {\n        rendered.style.visibility = \"hidden\";\n      }\n      elements.at(-1).container.after(rendered);\n    }\n\n    this.#setAnnotationCanvasMap();\n  }\n\n  async #addElementsToDOM() {\n    if (this.#elements.length === 0) {\n      return;\n    }\n    // Clear the existing annotations in order to make sure comment buttons\n    // don't have a parent any longer.\n    this.div.replaceChildren();\n\n    const promises = [];\n    if (!this.#hasAriaAttributesFromStructTree) {\n      this.#hasAriaAttributesFromStructTree = true;\n      for (const {\n        contentElement,\n        data: { id },\n      } of this.#elements) {\n        const annotationId = (contentElement.id = `${AnnotationPrefix}${id}`);\n        promises.push(\n          this.#structTreeLayer\n            ?.getAriaAttributes(annotationId)\n            .then(ariaAttributes => {\n              if (ariaAttributes) {\n                for (const [key, value] of ariaAttributes) {\n                  contentElement.setAttribute(key, value);\n                }\n              }\n            })\n        );\n      }\n    }\n    this.#elements.sort(\n      (\n        {\n          data: {\n            rect: [a0, a1, a2, a3],\n          },\n        },\n        {\n          data: {\n            rect: [b0, b1, b2, b3],\n          },\n        }\n      ) => {\n        // We are in page coordinates, which has the origin at the\n        // bottom left.\n        if (a0 === a2 && a1 === a3) {\n          return +1;\n        }\n\n        if (b0 === b2 && b1 === b3) {\n          return -1;\n        }\n\n        const top1 = a3;\n        const bot1 = a1;\n        const mid1 = (a1 + a3) / 2;\n\n        const top2 = b3;\n        const bot2 = b1;\n        const mid2 = (b1 + b3) / 2;\n\n        if (mid1 >= top2 && mid2 <= bot1) {\n          return -1;\n        }\n\n        if (mid2 >= top1 && mid1 <= bot2) {\n          return +1;\n        }\n\n        const centerX1 = (a0 + a2) / 2;\n        const centerX2 = (b0 + b2) / 2;\n\n        return centerX1 - centerX2;\n      }\n    );\n\n    const fragment = document.createDocumentFragment();\n    for (const element of this.#elements) {\n      fragment.append(element.container);\n      if (this._commentManager) {\n        (\n          element.extraPopupElement?.popup || element.popup\n        )?.renderCommentButton();\n      } else if (element.extraPopupElement) {\n        fragment.append(element.extraPopupElement.render());\n      }\n    }\n    this.div.append(fragment);\n    await Promise.all(promises);\n    if (this.#accessibilityManager) {\n      for (const element of this.#elements) {\n        this.#accessibilityManager.addPointerInTextLayer(\n          element.contentElement,\n          /* isRemovable = */ false\n        );\n      }\n    }\n  }\n\n  /**\n   * Add link annotations to the annotation layer.\n   *\n   * @param {Array<Object>} annotations\n   */\n  async addLinkAnnotations(annotations) {\n    const elementParams = {\n      data: null,\n      layer: this.div,\n      linkService: this.#linkService,\n      svgFactory: new DOMSVGFactory(),\n      parent: this,\n    };\n    for (const data of annotations) {\n      data.borderStyle ||= AnnotationLayer._defaultBorderStyle;\n\n      elementParams.data = data;\n      const element = AnnotationElementFactory.create(elementParams);\n\n      if (!element.isRenderable) {\n        continue;\n      }\n      element.render();\n      element.contentElement.id = `${AnnotationPrefix}${data.id}`;\n      this.#elements.push(element);\n    }\n    await this.#addElementsToDOM();\n  }\n\n  /**\n   * Update the annotation elements on existing annotation layer.\n   *\n   * @param {AnnotationLayerParameters} viewport\n   * @memberof AnnotationLayer\n   */\n  update({ viewport }) {\n    const layer = this.div;\n    this.viewport = viewport;\n    setLayerDimensions(layer, { rotation: viewport.rotation });\n\n    this.#setAnnotationCanvasMap();\n    layer.hidden = false;\n  }\n\n  #setAnnotationCanvasMap() {\n    if (!this.#annotationCanvasMap) {\n      return;\n    }\n    const layer = this.div;\n    for (const [id, canvas] of this.#annotationCanvasMap) {\n      const element = layer.querySelector(`[data-annotation-id=\"${id}\"]`);\n      if (!element) {\n        continue;\n      }\n\n      canvas.className = \"annotationContent\";\n      const { firstChild } = element;\n      if (!firstChild) {\n        element.append(canvas);\n      } else if (firstChild.nodeName === \"CANVAS\") {\n        firstChild.replaceWith(canvas);\n      } else if (!firstChild.classList.contains(\"annotationContent\")) {\n        firstChild.before(canvas);\n      } else {\n        firstChild.after(canvas);\n      }\n\n      const editableAnnotation = this.#editableAnnotations.get(id);\n      if (!editableAnnotation) {\n        continue;\n      }\n      if (editableAnnotation._hasNoCanvas) {\n        // The canvas wasn't available when the annotation was created.\n        this._annotationEditorUIManager?.setMissingCanvas(\n          id,\n          element.id,\n          canvas\n        );\n        editableAnnotation._hasNoCanvas = false;\n      } else {\n        editableAnnotation.canvas = canvas;\n      }\n    }\n    this.#annotationCanvasMap.clear();\n  }\n\n  getEditableAnnotations() {\n    return Array.from(this.#editableAnnotations.values());\n  }\n\n  getEditableAnnotation(id) {\n    return this.#editableAnnotations.get(id);\n  }\n\n  addFakeAnnotation(editor) {\n    const { div } = this;\n    const { id, rotation } = editor;\n    const element = new EditorAnnotationElement({\n      data: {\n        id,\n        rect: editor.getPDFRect(),\n        rotation,\n      },\n      editor,\n      layer: div,\n      parent: this,\n      enableComment: !!this._commentManager,\n      linkService: this.#linkService,\n      annotationStorage: this.#annotationStorage,\n    });\n    element.render();\n    element.contentElement.id = `${AnnotationPrefix}${id}`;\n    element.createOrUpdatePopup();\n    this.#elements.push(element);\n    return element;\n  }\n\n  removeAnnotation(id) {\n    const index = this.#elements.findIndex(el => el.data.id === id);\n    if (index < 0) {\n      return;\n    }\n    const [element] = this.#elements.splice(index, 1);\n    this.#accessibilityManager?.removePointerInTextLayer(\n      element.contentElement\n    );\n  }\n\n  updateFakeAnnotations(editors) {\n    if (editors.length === 0) {\n      return;\n    }\n    for (const editor of editors) {\n      editor.updateFakeAnnotationElement(this);\n    }\n    this.#addElementsToDOM();\n  }\n\n  togglePointerEvents(enabled = false) {\n    this.div.classList.toggle(\"disabled\", !enabled);\n  }\n\n  /**\n   * @private\n   */\n  static get _defaultBorderStyle() {\n    return shadow(\n      this,\n      \"_defaultBorderStyle\",\n      Object.freeze({\n        width: 1,\n        rawWidth: 1,\n        style: AnnotationBorderStyleType.SOLID,\n        dashArray: [3],\n        horizontalCornerRadius: 0,\n        verticalCornerRadius: 0,\n      })\n    );\n  }\n}\n\nexport {\n  AnnotationLayer,\n  FreeTextAnnotationElement,\n  HighlightAnnotationElement,\n  InkAnnotationElement,\n  StampAnnotationElement,\n};\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line max-len\n/** @typedef {import(\"./annotation_editor_layer.js\").AnnotationEditorLayer} AnnotationEditorLayer */\n\nimport {\n  AnnotationEditorParamsType,\n  AnnotationEditorType,\n  assert,\n  LINE_FACTOR,\n  shadow,\n  Util,\n} from \"../../shared/util.js\";\nimport { AnnotationEditorUIManager, KeyboardManager } from \"./tools.js\";\nimport { AnnotationEditor } from \"./editor.js\";\nimport { BasicColorPicker } from \"./color_picker.js\";\nimport { FreeTextAnnotationElement } from \"../annotation_layer.js\";\n\nconst EOL_PATTERN = /\\r\\n?|\\n/g;\n\n/**\n * Basic text editor in order to create a FreeTex annotation.\n */\nclass FreeTextEditor extends AnnotationEditor {\n  #content = \"\";\n\n  #editorDivId = `${this.id}-editor`;\n\n  #editModeAC = null;\n\n  #fontSize;\n\n  _colorPicker = null;\n\n  static _freeTextDefaultContent = \"\";\n\n  static _internalPadding = 0;\n\n  static _defaultColor = null;\n\n  static _defaultFontSize = 10;\n\n  static get _keyboardManager() {\n    const proto = FreeTextEditor.prototype;\n\n    const arrowChecker = self => self.isEmpty();\n\n    const small = AnnotationEditorUIManager.TRANSLATE_SMALL;\n    const big = AnnotationEditorUIManager.TRANSLATE_BIG;\n\n    return shadow(\n      this,\n      \"_keyboardManager\",\n      new KeyboardManager([\n        [\n          // Commit the text in case the user use ctrl+s to save the document.\n          // The event must bubble in order to be caught by the viewer.\n          // See bug 1831574.\n          [\"ctrl+s\", \"mac+meta+s\", \"ctrl+p\", \"mac+meta+p\"],\n          proto.commitOrRemove,\n          { bubbles: true },\n        ],\n        [\n          [\"ctrl+Enter\", \"mac+meta+Enter\", \"Escape\", \"mac+Escape\"],\n          proto.commitOrRemove,\n        ],\n        [\n          [\"ArrowLeft\", \"mac+ArrowLeft\"],\n          proto._translateEmpty,\n          { args: [-small, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowLeft\", \"mac+shift+ArrowLeft\"],\n          proto._translateEmpty,\n          { args: [-big, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ArrowRight\", \"mac+ArrowRight\"],\n          proto._translateEmpty,\n          { args: [small, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowRight\", \"mac+shift+ArrowRight\"],\n          proto._translateEmpty,\n          { args: [big, 0], checker: arrowChecker },\n        ],\n        [\n          [\"ArrowUp\", \"mac+ArrowUp\"],\n          proto._translateEmpty,\n          { args: [0, -small], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowUp\", \"mac+shift+ArrowUp\"],\n          proto._translateEmpty,\n          { args: [0, -big], checker: arrowChecker },\n        ],\n        [\n          [\"ArrowDown\", \"mac+ArrowDown\"],\n          proto._translateEmpty,\n          { args: [0, small], checker: arrowChecker },\n        ],\n        [\n          [\"ctrl+ArrowDown\", \"mac+shift+ArrowDown\"],\n          proto._translateEmpty,\n          { args: [0, big], checker: arrowChecker },\n        ],\n      ])\n    );\n  }\n\n  static _type = \"freetext\";\n\n  static _editorType = AnnotationEditorType.FREETEXT;\n\n  constructor(params) {\n    super({ ...params, name: \"freeTextEditor\" });\n    this.color =\n      params.color ||\n      FreeTextEditor._defaultColor ||\n      AnnotationEditor._defaultLineColor;\n    this.#fontSize = params.fontSize || FreeTextEditor._defaultFontSize;\n    if (!this.annotationElementId) {\n      this._uiManager.a11yAlert(\"pdfjs-editor-freetext-added-alert\");\n    }\n    this.canAddComment = false;\n  }\n\n  /** @inheritdoc */\n  static initialize(l10n, uiManager) {\n    AnnotationEditor.initialize(l10n, uiManager);\n    const style = getComputedStyle(document.documentElement);\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      const lineHeight = parseFloat(\n        style.getPropertyValue(\"--freetext-line-height\")\n      );\n      assert(\n        lineHeight === LINE_FACTOR,\n        \"Update the CSS variable to agree with the constant.\"\n      );\n    }\n\n    this._internalPadding = parseFloat(\n      style.getPropertyValue(\"--freetext-padding\")\n    );\n  }\n\n  /** @inheritdoc */\n  static updateDefaultParams(type, value) {\n    switch (type) {\n      case AnnotationEditorParamsType.FREETEXT_SIZE:\n        FreeTextEditor._defaultFontSize = value;\n        break;\n      case AnnotationEditorParamsType.FREETEXT_COLOR:\n        FreeTextEditor._defaultColor = value;\n        break;\n    }\n  }\n\n  /** @inheritdoc */\n  updateParams(type, value) {\n    switch (type) {\n      case AnnotationEditorParamsType.FREETEXT_SIZE:\n        this.#updateFontSize(value);\n        break;\n      case AnnotationEditorParamsType.FREETEXT_COLOR:\n        this.#updateColor(value);\n        break;\n    }\n  }\n\n  /** @inheritdoc */\n  static get defaultPropertiesToUpdate() {\n    return [\n      [\n        AnnotationEditorParamsType.FREETEXT_SIZE,\n        FreeTextEditor._defaultFontSize,\n      ],\n      [\n        AnnotationEditorParamsType.FREETEXT_COLOR,\n        FreeTextEditor._defaultColor || AnnotationEditor._defaultLineColor,\n      ],\n    ];\n  }\n\n  /** @inheritdoc */\n  get propertiesToUpdate() {\n    return [\n      [AnnotationEditorParamsType.FREETEXT_SIZE, this.#fontSize],\n      [AnnotationEditorParamsType.FREETEXT_COLOR, this.color],\n    ];\n  }\n\n  /** @inheritdoc */\n  get toolbarButtons() {\n    this._colorPicker ||= new BasicColorPicker(this);\n    return [[\"colorPicker\", this._colorPicker]];\n  }\n\n  get colorType() {\n    return AnnotationEditorParamsType.FREETEXT_COLOR;\n  }\n\n  /**\n   * Update the font size and make this action as undoable.\n   * @param {number} fontSize\n   */\n  #updateFontSize(fontSize) {\n    const setFontsize = size => {\n      this.editorDiv.style.fontSize = `calc(${size}px * var(--total-scale-factor))`;\n      this.translate(0, -(size - this.#fontSize) * this.parentScale);\n      this.#fontSize = size;\n      this.#setEditorDimensions();\n    };\n    const savedFontsize = this.#fontSize;\n    this.addCommands({\n      cmd: setFontsize.bind(this, fontSize),\n      undo: setFontsize.bind(this, savedFontsize),\n      post: this._uiManager.updateUI.bind(this._uiManager, this),\n      mustExec: true,\n      type: AnnotationEditorParamsType.FREETEXT_SIZE,\n      overwriteIfSameType: true,\n      keepUndo: true,\n    });\n  }\n\n  /** @inheritdoc */\n  onUpdatedColor() {\n    this.editorDiv.style.color = this.color;\n    this._colorPicker?.update(this.color);\n    super.onUpdatedColor();\n  }\n\n  /**\n   * Update the color and make this action undoable.\n   * @param {string} color\n   */\n  #updateColor(color) {\n    const setColor = col => {\n      this.color = col;\n      this.onUpdatedColor();\n    };\n    const savedColor = this.color;\n    this.addCommands({\n      cmd: setColor.bind(this, color),\n      undo: setColor.bind(this, savedColor),\n      post: this._uiManager.updateUI.bind(this._uiManager, this),\n      mustExec: true,\n      type: AnnotationEditorParamsType.FREETEXT_COLOR,\n      overwriteIfSameType: true,\n      keepUndo: true,\n    });\n  }\n\n  /**\n   * Helper to translate the editor with the keyboard when it's empty.\n   * @param {number} x in page units.\n   * @param {number} y in page units.\n   */\n  _translateEmpty(x, y) {\n    this._uiManager.translateSelectedEditors(x, y, /* noCommit = */ true);\n  }\n\n  /** @inheritdoc */\n  getInitialTranslation() {\n    // The start of the base line is where the user clicked.\n    const scale = this.parentScale;\n    return [\n      -FreeTextEditor._internalPadding * scale,\n      -(FreeTextEditor._internalPadding + this.#fontSize) * scale,\n    ];\n  }\n\n  /** @inheritdoc */\n  rebuild() {\n    if (!this.parent) {\n      return;\n    }\n    super.rebuild();\n    if (this.div === null) {\n      return;\n    }\n\n    if (!this.isAttachedToDOM) {\n      // At some point this editor was removed and we're rebuilting it,\n      // hence we must add it to its parent.\n      this.parent.add(this);\n    }\n  }\n\n  /** @inheritdoc */\n  enableEditMode() {\n    if (!super.enableEditMode()) {\n      return false;\n    }\n\n    this.overlayDiv.classList.remove(\"enabled\");\n    this.editorDiv.contentEditable = true;\n    this._isDraggable = false;\n    this.div.removeAttribute(\"aria-activedescendant\");\n\n    if (typeof PDFJSDev === \"undefined\" || PDFJSDev.test(\"TESTING\")) {\n      assert(\n        !this.#editModeAC,\n        \"No `this.#editModeAC` AbortController should exist.\"\n      );\n    }\n    this.#editModeAC = new AbortController();\n    const signal = this._uiManager.combinedSignal(this.#editModeAC);\n\n    this.editorDiv.addEventListener(\n      \"keydown\",\n      this.editorDivKeydown.bind(this),\n      { signal }\n    );\n    this.editorDiv.addEventListener(\"focus\", this.editorDivFocus.bind(this), {\n      signal,\n    });\n    this.editorDiv.addEventListener(\"blur\", this.editorDivBlur.bind(this), {\n      signal,\n    });\n    this.editorDiv.addEventListener(\"input\", this.editorDivInput.bind(this), {\n      signal,\n    });\n    this.editorDiv.addEventListener(\"paste\", this.editorDivPaste.bind(this), {\n      signal,\n    });\n\n    return true;\n  }\n\n  /** @inheritdoc */\n  disableEditMode() {\n    if (!super.disableEditMode()) {\n      return false;\n    }\n\n    this.overlayDiv.classList.add(\"enabled\");\n    this.editorDiv.contentEditable = false;\n    this.div.setAttribute(\"aria-activedescendant\", this.#editorDivId);\n    this._isDraggable = true;\n\n    this.#editModeAC?.abort();\n    this.#editModeAC = null;\n\n    // On Chrome, the focus is given to <body> when contentEditable is set to\n    // false, hence we focus the div.\n    this.div.focus({\n      preventScroll: true /* See issue #15744 */,\n    });\n\n    // In case the blur callback hasn't been called.\n    this.isEditing = false;\n    this.parent.div.classList.add(\"freetextEditing\");\n\n    return true;\n  }\n\n  /** @inheritdoc */\n  focusin(event) {\n    if (!this._focusEventsAllowed) {\n      return;\n    }\n    super.focusin(event);\n    if (event.target !== this.editorDiv) {\n      this.editorDiv.focus();\n    }\n  }\n\n  /** @inheritdoc */\n  onceAdded(focus) {\n    if (this.width) {\n      // The editor was created in using ctrl+c.\n      return;\n    }\n    this.enableEditMode();\n    if (focus) {\n      this.editorDiv.focus();\n    }\n    if (this._initialOptions?.isCentered) {\n      this.center();\n    }\n    this._initialOptions = null;\n  }\n\n  /** @inheritdoc */\n  isEmpty() {\n    return !this.editorDiv || this.editorDiv.innerText.trim() === \"\";\n  }\n\n  /** @inheritdoc */\n  remove() {\n    this.isEditing = false;\n    if (this.parent) {\n      this.parent.setEditingState(true);\n      this.parent.div.classList.add(\"freetextEditing\");\n    }\n    super.remove();\n  }\n\n  /**\n   * Extract the text from this editor.\n   * @returns {string}\n   */\n  #extractText() {\n    // We don't use innerText because there are some bugs with line breaks.\n    const buffer = [];\n    this.editorDiv.normalize();\n    let prevChild = null;\n    for (const child of this.editorDiv.childNodes) {\n      if (prevChild?.nodeType === Node.TEXT_NODE && child.nodeName === \"BR\") {\n        // It can happen if the user uses shift+enter to add a new line.\n        // If we don't skip it, we'll end up with an extra line (one for the\n        // text and one for the br element).\n        continue;\n      }\n      buffer.push(FreeTextEditor.#getNodeContent(child));\n      prevChild = child;\n    }\n    return buffer.join(\"\\n\");\n  }\n\n  #setEditorDimensions() {\n    const [parentWidth, parentHeight] = this.parentDimensions;\n\n    let rect;\n    if (this.isAttachedToDOM) {\n      rect = this.div.getBoundingClientRect();\n    } else {\n      // This editor isn't on screen but we need to get its dimensions, so\n      // we just insert it in the DOM, get its bounding box and then remove it.\n      const { currentLayer, div } = this;\n      const savedDisplay = div.style.display;\n      const savedVisibility = div.classList.contains(\"hidden\");\n      div.classList.remove(\"hidden\");\n      div.style.display = \"hidden\";\n      currentLayer.div.append(this.div);\n      rect = div.getBoundingClientRect();\n      div.remove();\n      div.style.display = savedDisplay;\n      div.classList.toggle(\"hidden\", savedVisibility);\n    }\n\n    // The dimensions are relative to the rotation of the page, hence we need to\n    // take that into account (see issue #16636).\n    if (this.rotation % 180 === this.parentRotation % 180) {\n      this.width = rect.width / parentWidth;\n      this.height = rect.height / parentHeight;\n    } else {\n      this.width = rect.height / parentWidth;\n      this.height = rect.width / parentHeight;\n    }\n    this.fixAndSetPosition();\n  }\n\n  /**\n   * Commit the content we have in this editor.\n   * @returns {undefined}\n   */\n  commit() {\n    if (!this.isInEditMode()) {\n      return;\n    }\n\n    super.commit();\n    this.disableEditMode();\n    const savedText = this.#content;\n    const newText = (this.#content = this.#extractText().trimEnd());\n    if (savedText === newText) {\n      return;\n    }\n\n    const setText = text => {\n      this.#content = text;\n      if (!text) {\n        this.remove();\n        return;\n      }\n      this.#setContent();\n      this._uiManager.rebuild(this);\n      this.#setEditorDimensions();\n    };\n    this.addCommands({\n      cmd: () => {\n        setText(newText);\n      },\n      undo: () => {\n        setText(savedText);\n      },\n      mustExec: false,\n    });\n    this.#setEditorDimensions();\n  }\n\n  /** @inheritdoc */\n  shouldGetKeyboardEvents() {\n    return this.isInEditMode();\n  }\n\n  /** @inheritdoc */\n  enterInEditMode() {\n    this.enableEditMode();\n    this.editorDiv.focus();\n  }\n\n  /** @inheritdoc */\n  keydown(event) {\n    if (event.target === this.div && event.key === \"Enter\") {\n      this.enterInEditMode();\n      // Avoid to add an unwanted new line.\n      event.preventDefault();\n    }\n  }\n\n  editorDivKeydown(event) {\n    FreeTextEditor._keyboardManager.exec(this, event);\n  }\n\n  editorDivFocus(event) {\n    this.isEditing = true;\n  }\n\n  editorDivBlur(event) {\n    this.isEditing = false;\n  }\n\n  editorDivInput(event) {\n    this.parent.div.classList.toggle(\"freetextEditing\", this.isEmpty());\n  }\n\n  /** @inheritdoc */\n  disableEditing() {\n    this.editorDiv.setAttribute(\"role\", \"comment\");\n    this.editorDiv.removeAttribute(\"aria-multiline\");\n  }\n\n  /** @inheritdoc */\n  enableEditing() {\n    this.editorDiv.setAttribute(\"role\", \"textbox\");\n    this.editorDiv.setAttribute(\"aria-multiline\", true);\n  }\n\n  /** @inheritdoc */\n  get canChangeContent() {\n    return true;\n  }\n\n  /** @inheritdoc */\n  render() {\n    if (this.div) {\n      return this.div;\n    }\n\n    let baseX, baseY;\n    if (this._isCopy || this.annotationElementId) {\n      baseX = this.x;\n      baseY = this.y;\n    }\n\n    super.render();\n    this.editorDiv = document.createElement(\"div\");\n    this.editorDiv.className = \"internal\";\n\n    this.editorDiv.setAttribute(\"id\", this.#editorDivId);\n    this.editorDiv.setAttribute(\"data-l10n-id\", \"pdfjs-free-text2\");\n    this.editorDiv.setAttribute(\"data-l10n-attrs\", \"default-content\");\n    this.enableEditing();\n\n    this.editorDiv.contentEditable = true;\n\n    const { style } = this.editorDiv;\n    style.fontSize = `calc(${this.#fontSize}px * var(--total-scale-factor))`;\n    style.color = this.color;\n\n    this.div.append(this.editorDiv);\n\n    this.overlayDiv = document.createElement(\"div\");\n    this.overlayDiv.classList.add(\"overlay\", \"enabled\");\n    this.div.append(this.overlayDiv);\n\n    if (this._isCopy || this.annotationElementId) {\n      // This editor was created in using copy (ctrl+c).\n      const [parentWidth, parentHeight] = this.parentDimensions;\n      if (this.annotationElementId) {\n        // This stuff is hard to test: if something is changed here, please\n        // test with the following PDF file:\n        //  - freetexts.pdf\n        //  - rotated_freetexts.pdf\n        // Only small variations between the original annotation and its editor\n        // are allowed.\n\n        // position is the position of the first glyph in the annotation\n        // and it's relative to its container.\n        const { position } = this._initialData;\n        let [tx, ty] = this.getInitialTranslation();\n        [tx, ty] = this.pageTranslationToScreen(tx, ty);\n        const [pageWidth, pageHeight] = this.pageDimensions;\n        const [pageX, pageY] = this.pageTranslation;\n        let posX, posY;\n        switch (this.rotation) {\n          case 0:\n            posX = baseX + (position[0] - pageX) / pageWidth;\n            posY = baseY + this.height - (position[1] - pageY) / pageHeight;\n            break;\n          case 90:\n            posX = baseX + (position[0] - pageX) / pageWidth;\n            posY = baseY - (position[1] - pageY) / pageHeight;\n            [tx, ty] = [ty, -tx];\n            break;\n          case 180:\n            posX = baseX - this.width + (position[0] - pageX) / pageWidth;\n            posY = baseY - (position[1] - pageY) / pageHeight;\n            [tx, ty] = [-tx, -ty];\n            break;\n          case 270:\n            posX =\n              baseX +\n              (position[0] - pageX - this.height * pageHeight) / pageWidth;\n            posY =\n              baseY +\n              (position[1] - pageY - this.width * pageWidth) / pageHeight;\n            [tx, ty] = [-ty, tx];\n            break;\n        }\n        this.setAt(posX * parentWidth, posY * parentHeight, tx, ty);\n      } else {\n        this._moveAfterPaste(baseX, baseY);\n      }\n\n      this.#setContent();\n      this._isDraggable = true;\n      this.editorDiv.contentEditable = false;\n    } else {\n      this._isDraggable = false;\n      this.editorDiv.contentEditable = true;\n    }\n\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n      this.div.setAttribute(\"annotation-id\", this.annotationElementId);\n    }\n\n    return this.div;\n  }\n\n  static #getNodeContent(node) {\n    return (\n      node.nodeType === Node.TEXT_NODE ? node.nodeValue : node.innerText\n    ).replaceAll(EOL_PATTERN, \"\");\n  }\n\n  editorDivPaste(event) {\n    const clipboardData = event.clipboardData || window.clipboardData;\n    const { types } = clipboardData;\n    if (types.length === 1 && types[0] === \"text/plain\") {\n      return;\n    }\n\n    event.preventDefault();\n    const paste = FreeTextEditor.#deserializeContent(\n      clipboardData.getData(\"text\") || \"\"\n    ).replaceAll(EOL_PATTERN, \"\\n\");\n    if (!paste) {\n      return;\n    }\n    const selection = window.getSelection();\n    if (!selection.rangeCount) {\n      return;\n    }\n    this.editorDiv.normalize();\n    selection.deleteFromDocument();\n    const range = selection.getRangeAt(0);\n    if (!paste.includes(\"\\n\")) {\n      range.insertNode(document.createTextNode(paste));\n      this.editorDiv.normalize();\n      selection.collapseToStart();\n      return;\n    }\n\n    // Collect the text before and after the caret.\n    const { startContainer, startOffset } = range;\n    const bufferBefore = [];\n    const bufferAfter = [];\n    if (startContainer.nodeType === Node.TEXT_NODE) {\n      const parent = startContainer.parentElement;\n      bufferAfter.push(\n        startContainer.nodeValue.slice(startOffset).replaceAll(EOL_PATTERN, \"\")\n      );\n      if (parent !== this.editorDiv) {\n        let buffer = bufferBefore;\n        for (const child of this.editorDiv.childNodes) {\n          if (child === parent) {\n            buffer = bufferAfter;\n            continue;\n          }\n          buffer.push(FreeTextEditor.#getNodeContent(child));\n        }\n      }\n      bufferBefore.push(\n        startContainer.nodeValue\n          .slice(0, startOffset)\n          .replaceAll(EOL_PATTERN, \"\")\n      );\n    } else if (startContainer === this.editorDiv) {\n      let buffer = bufferBefore;\n      let i = 0;\n      for (const child of this.editorDiv.childNodes) {\n        if (i++ === startOffset) {\n          buffer = bufferAfter;\n        }\n        buffer.push(FreeTextEditor.#getNodeContent(child));\n      }\n    }\n    this.#content = `${bufferBefore.join(\"\\n\")}${paste}${bufferAfter.join(\"\\n\")}`;\n    this.#setContent();\n\n    // Set the caret at the right position.\n    const newRange = new Range();\n    let beforeLength = Math.sumPrecise(bufferBefore.map(line => line.length));\n    for (const { firstChild } of this.editorDiv.childNodes) {\n      // Each child is either a div with a text node or a br element.\n      if (firstChild.nodeType === Node.TEXT_NODE) {\n        const length = firstChild.nodeValue.length;\n        if (beforeLength <= length) {\n          newRange.setStart(firstChild, beforeLength);\n          newRange.setEnd(firstChild, beforeLength);\n          break;\n        }\n        beforeLength -= length;\n      }\n    }\n    selection.removeAllRanges();\n    selection.addRange(newRange);\n  }\n\n  #setContent() {\n    this.editorDiv.replaceChildren();\n    if (!this.#content) {\n      return;\n    }\n    for (const line of this.#content.split(\"\\n\")) {\n      const div = document.createElement(\"div\");\n      div.append(\n        line ? document.createTextNode(line) : document.createElement(\"br\")\n      );\n      this.editorDiv.append(div);\n    }\n  }\n\n  #serializeContent() {\n    return this.#content.replaceAll(\"\\xa0\", \" \");\n  }\n\n  static #deserializeContent(content) {\n    return content.replaceAll(\" \", \"\\xa0\");\n  }\n\n  /** @inheritdoc */\n  get contentDiv() {\n    return this.editorDiv;\n  }\n\n  /** @inheritdoc */\n  getPDFRect() {\n    const padding = FreeTextEditor._internalPadding * this.parentScale;\n    return this.getRect(padding, padding);\n  }\n\n  /** @inheritdoc */\n  static async deserialize(data, parent, uiManager) {\n    let initialData = null;\n    if (data instanceof FreeTextAnnotationElement) {\n      const {\n        data: {\n          defaultAppearanceData: { fontSize, fontColor },\n          rect,\n          rotation,\n          id,\n          popupRef,\n          richText,\n          contentsObj,\n          creationDate,\n          modificationDate,\n        },\n        textContent,\n        textPosition,\n        parent: {\n          page: { pageNumber },\n        },\n      } = data;\n      // textContent is supposed to be an array of strings containing each line\n      // of text. However, it can be null or empty.\n      if (!textContent || textContent.length === 0) {\n        // Empty annotation.\n        return null;\n      }\n      initialData = data = {\n        annotationType: AnnotationEditorType.FREETEXT,\n        color: Array.from(fontColor),\n        fontSize,\n        value: textContent.join(\"\\n\"),\n        position: textPosition,\n        pageIndex: pageNumber - 1,\n        rect: rect.slice(0),\n        rotation,\n        annotationElementId: id,\n        id,\n        deleted: false,\n        popupRef,\n        comment: contentsObj?.str || null,\n        richText,\n        creationDate,\n        modificationDate,\n      };\n    }\n    const editor = await super.deserialize(data, parent, uiManager);\n    editor.#fontSize = data.fontSize;\n    editor.color = Util.makeHexColor(...data.color);\n    editor.#content = FreeTextEditor.#deserializeContent(data.value);\n    editor._initialData = initialData;\n    if (data.comment) {\n      editor.setCommentData(data);\n    }\n\n    return editor;\n  }\n\n  /** @inheritdoc */\n  serialize(isForCopying = false) {\n    if (this.isEmpty()) {\n      return null;\n    }\n\n    if (this.deleted) {\n      return this.serializeDeleted();\n    }\n\n    const color = AnnotationEditor._colorManager.convert(\n      this.isAttachedToDOM ? getComputedStyle(this.editorDiv).color : this.color\n    );\n    const serialized = Object.assign(super.serialize(isForCopying), {\n      color,\n      fontSize: this.#fontSize,\n      value: this.#serializeContent(),\n    });\n    this.addComment(serialized);\n\n    if (isForCopying) {\n      // Don't add the id when copying because the pasted editor mustn't be\n      // linked to an existing annotation.\n      serialized.isCopy = true;\n      return serialized;\n    }\n\n    if (this.annotationElementId && !this.#hasElementChanged(serialized)) {\n      return null;\n    }\n\n    serialized.id = this.annotationElementId;\n\n    return serialized;\n  }\n\n  #hasElementChanged(serialized) {\n    const { value, fontSize, color, pageIndex } = this._initialData;\n\n    return (\n      this.hasEditedComment ||\n      this._hasBeenMoved ||\n      serialized.value !== value ||\n      serialized.fontSize !== fontSize ||\n      serialized.color.some((c, i) => c !== color[i]) ||\n      serialized.pageIndex !== pageIndex\n    );\n  }\n\n  /** @inheritdoc */\n  renderAnnotationElement(annotation) {\n    const content = super.renderAnnotationElement(annotation);\n    if (!content) {\n      return null;\n    }\n    const { style } = content;\n    style.fontSize = `calc(${this.#fontSize}px * var(--total-scale-factor))`;\n    style.color = this.color;\n\n    content.replaceChildren();\n    for (const line of this.#content.split(\"\\n\")) {\n      const div = document.createElement(\"div\");\n      div.append(\n        line ? document.createTextNode(line) : document.createElement(\"br\")\n      );\n      content.append(div);\n    }\n\n    annotation.updateEdited({\n      rect: this.getPDFRect(),\n      popup:\n        this._uiManager.hasCommentManager() || this.hasEditedComment\n          ? this.comment\n          : { text: this.#content },\n    });\n\n    return content;\n  }\n\n  resetAnnotationElement(annotation) {\n    super.resetAnnotationElement(annotation);\n    annotation.resetEdited();\n  }\n}\n\nexport { FreeTextEditor };\n","/* Copyright 2023 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { unreachable } from \"../../../shared/util.js\";\n\nclass Outline {\n  static PRECISION = 1e-4;\n\n  /**\n   * @returns {string} The SVG path of the outline.\n   */\n  toSVGPath() {\n    unreachable(\"Abstract method `toSVGPath` must be implemented.\");\n  }\n\n  /**\n   * @type {Object|null} The bounding box of the outline.\n   */\n  // eslint-disable-next-line getter-return\n  get box() {\n    unreachable(\"Abstract getter `box` must be implemented.\");\n  }\n\n  serialize(_bbox, _rotation) {\n    unreachable(\"Abstract method `serialize` must be implemented.\");\n  }\n\n  static _rescale(src, tx, ty, sx, sy, dest) {\n    dest ||= new Float32Array(src.length);\n    for (let i = 0, ii = src.length; i < ii; i += 2) {\n      dest[i] = tx + src[i] * sx;\n      dest[i + 1] = ty + src[i + 1] * sy;\n    }\n    return dest;\n  }\n\n  static _rescaleAndSwap(src, tx, ty, sx, sy, dest) {\n    dest ||= new Float32Array(src.length);\n    for (let i = 0, ii = src.length; i < ii; i += 2) {\n      dest[i] = tx + src[i + 1] * sx;\n      dest[i + 1] = ty + src[i] * sy;\n    }\n    return dest;\n  }\n\n  static _translate(src, tx, ty, dest) {\n    dest ||= new Float32Array(src.length);\n    for (let i = 0, ii = src.length; i < ii; i += 2) {\n      dest[i] = tx + src[i];\n      dest[i + 1] = ty + src[i + 1];\n    }\n    return dest;\n  }\n\n  static svgRound(x) {\n    // 0.1234 will be 1234 and this way we economize 2 bytes per number.\n    // Of course, it makes sense only when the viewBox is [0 0 10000 10000].\n    // And it helps to avoid bugs like:\n    //  https://bugzilla.mozilla.org/show_bug.cgi?id=1929340\n    return Math.round(x * 10000);\n  }\n\n  static _normalizePoint(x, y, parentWidth, parentHeight, rotation) {\n    switch (rotation) {\n      case 90:\n        return [1 - y / parentWidth, x / parentHeight];\n      case 180:\n        return [1 - x / parentWidth, 1 - y / parentHeight];\n      case 270:\n        return [y / parentWidth, 1 - x / parentHeight];\n      default:\n        return [x / parentWidth, y / parentHeight];\n    }\n  }\n\n  static _normalizePagePoint(x, y, rotation) {\n    switch (rotation) {\n      case 90:\n        return [1 - y, x];\n      case 180:\n        return [1 - x, 1 - y];\n      case 270:\n        return [y, 1 - x];\n      default:\n        return [x, y];\n    }\n  }\n\n  static createBezierPoints(x1, y1, x2, y2, x3, y3) {\n    return [\n      (x1 + 5 * x2) / 6,\n      (y1 + 5 * y2) / 6,\n      (5 * x2 + x3) / 6,\n      (5 * y2 + y3) / 6,\n      (x2 + x3) / 2,\n      (y2 + y3) / 2,\n    ];\n  }\n}\n\nexport { Outline };\n","/* Copyright 2024 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Outline } from \"./outline.js\";\nimport { Util } from \"../../../shared/util.js\";\n\nclass FreeDrawOutliner {\n  #box;\n\n  #bottom = [];\n\n  #innerMargin;\n\n  #isLTR;\n\n  #top = [];\n\n  // The first 6 elements are the last 3 points of the top part of the outline.\n  // The next 6 elements are the last 3 points of the line.\n  // The next 6 elements are the last 3 points of the bottom part of the\n  // outline.\n  // We track the last 3 points in order to be able to:\n  //  - compute the normal of the line,\n  //  - compute the control points of the quadratic Bézier curve.\n  #last = new Float32Array(18);\n\n  #lastX;\n\n  #lastY;\n\n  #min;\n\n  #min_dist;\n\n  #scaleFactor;\n\n  #thickness;\n\n  #points = [];\n\n  static #MIN_DIST = 8;\n\n  static #MIN_DIFF = 2;\n\n  static #MIN = FreeDrawOutliner.#MIN_DIST + FreeDrawOutliner.#MIN_DIFF;\n\n  constructor({ x, y }, box, scaleFactor, thickness, isLTR, innerMargin = 0) {\n    this.#box = box;\n    this.#thickness = thickness * scaleFactor;\n    this.#isLTR = isLTR;\n    this.#last.set([NaN, NaN, NaN, NaN, x, y], 6);\n    this.#innerMargin = innerMargin;\n    this.#min_dist = FreeDrawOutliner.#MIN_DIST * scaleFactor;\n    this.#min = FreeDrawOutliner.#MIN * scaleFactor;\n    this.#scaleFactor = scaleFactor;\n    this.#points.push(x, y);\n  }\n\n  isEmpty() {\n    // When we add a second point then this.#last.slice(6) will be something\n    // like [NaN, NaN, firstX, firstY, secondX, secondY,...] so having a NaN\n    // at index 8 means that we've only one point.\n    return isNaN(this.#last[8]);\n  }\n\n  #getLastCoords() {\n    const lastTop = this.#last.subarray(4, 6);\n    const lastBottom = this.#last.subarray(16, 18);\n    const [x, y, width, height] = this.#box;\n\n    return [\n      (this.#lastX + (lastTop[0] - lastBottom[0]) / 2 - x) / width,\n      (this.#lastY + (lastTop[1] - lastBottom[1]) / 2 - y) / height,\n      (this.#lastX + (lastBottom[0] - lastTop[0]) / 2 - x) / width,\n      (this.#lastY + (lastBottom[1] - lastTop[1]) / 2 - y) / height,\n    ];\n  }\n\n  add({ x, y }) {\n    this.#lastX = x;\n    this.#lastY = y;\n    const [layerX, layerY, layerWidth, layerHeight] = this.#box;\n    let [x1, y1, x2, y2] = this.#last.subarray(8, 12);\n    const diffX = x - x2;\n    const diffY = y - y2;\n    const d = Math.hypot(diffX, diffY);\n    if (d < this.#min) {\n      // The idea is to avoid garbage points around the last point.\n      // When the points are too close, it just leads to bad normal vectors and\n      // control points.\n      return false;\n    }\n    const diffD = d - this.#min_dist;\n    const K = diffD / d;\n    const shiftX = K * diffX;\n    const shiftY = K * diffY;\n\n    // We update the last 3 points of the line.\n    let x0 = x1;\n    let y0 = y1;\n    x1 = x2;\n    y1 = y2;\n    x2 += shiftX;\n    y2 += shiftY;\n\n    // We keep track of the points in order to be able to compute the focus\n    // outline.\n    this.#points?.push(x, y);\n\n    // Create the normal unit vector.\n    // |(shiftX, shiftY)| = |K| * |(diffX, diffY)| = |K| * d = diffD.\n    const nX = -shiftY / diffD;\n    const nY = shiftX / diffD;\n    const thX = nX * this.#thickness;\n    const thY = nY * this.#thickness;\n    this.#last.set(this.#last.subarray(2, 8), 0);\n    this.#last.set([x2 + thX, y2 + thY], 4);\n    this.#last.set(this.#last.subarray(14, 18), 12);\n    this.#last.set([x2 - thX, y2 - thY], 16);\n\n    if (isNaN(this.#last[6])) {\n      if (this.#top.length === 0) {\n        this.#last.set([x1 + thX, y1 + thY], 2);\n        this.#top.push(\n          NaN,\n          NaN,\n          NaN,\n          NaN,\n          (x1 + thX - layerX) / layerWidth,\n          (y1 + thY - layerY) / layerHeight\n        );\n        this.#last.set([x1 - thX, y1 - thY], 14);\n        this.#bottom.push(\n          NaN,\n          NaN,\n          NaN,\n          NaN,\n          (x1 - thX - layerX) / layerWidth,\n          (y1 - thY - layerY) / layerHeight\n        );\n      }\n      this.#last.set([x0, y0, x1, y1, x2, y2], 6);\n      return !this.isEmpty();\n    }\n\n    this.#last.set([x0, y0, x1, y1, x2, y2], 6);\n\n    const angle = Math.abs(\n      Math.atan2(y0 - y1, x0 - x1) - Math.atan2(shiftY, shiftX)\n    );\n    if (angle < Math.PI / 2) {\n      // In order to avoid some possible artifacts, we're going to use the a\n      // straight line instead of a quadratic Bézier curve.\n      [x1, y1, x2, y2] = this.#last.subarray(2, 6);\n      this.#top.push(\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        ((x1 + x2) / 2 - layerX) / layerWidth,\n        ((y1 + y2) / 2 - layerY) / layerHeight\n      );\n      [x1, y1, x0, y0] = this.#last.subarray(14, 18);\n      this.#bottom.push(\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        ((x0 + x1) / 2 - layerX) / layerWidth,\n        ((y0 + y1) / 2 - layerY) / layerHeight\n      );\n      return true;\n    }\n\n    // Control points and the final point for the quadratic Bézier curve.\n    [x0, y0, x1, y1, x2, y2] = this.#last.subarray(0, 6);\n    this.#top.push(\n      ((x0 + 5 * x1) / 6 - layerX) / layerWidth,\n      ((y0 + 5 * y1) / 6 - layerY) / layerHeight,\n      ((5 * x1 + x2) / 6 - layerX) / layerWidth,\n      ((5 * y1 + y2) / 6 - layerY) / layerHeight,\n      ((x1 + x2) / 2 - layerX) / layerWidth,\n      ((y1 + y2) / 2 - layerY) / layerHeight\n    );\n    [x2, y2, x1, y1, x0, y0] = this.#last.subarray(12, 18);\n    this.#bottom.push(\n      ((x0 + 5 * x1) / 6 - layerX) / layerWidth,\n      ((y0 + 5 * y1) / 6 - layerY) / layerHeight,\n      ((5 * x1 + x2) / 6 - layerX) / layerWidth,\n      ((5 * y1 + y2) / 6 - layerY) / layerHeight,\n      ((x1 + x2) / 2 - layerX) / layerWidth,\n      ((y1 + y2) / 2 - layerY) / layerHeight\n    );\n    return true;\n  }\n\n  toSVGPath() {\n    if (this.isEmpty()) {\n      // We've only one point.\n      return \"\";\n    }\n    const top = this.#top;\n    const bottom = this.#bottom;\n\n    if (isNaN(this.#last[6]) && !this.isEmpty()) {\n      // We've only two points.\n      return this.#toSVGPathTwoPoints();\n    }\n\n    const buffer = [];\n    buffer.push(`M${top[4]} ${top[5]}`);\n    for (let i = 6; i < top.length; i += 6) {\n      if (isNaN(top[i])) {\n        buffer.push(`L${top[i + 4]} ${top[i + 5]}`);\n      } else {\n        buffer.push(\n          `C${top[i]} ${top[i + 1]} ${top[i + 2]} ${top[i + 3]} ${top[i + 4]} ${\n            top[i + 5]\n          }`\n        );\n      }\n    }\n\n    this.#toSVGPathEnd(buffer);\n\n    for (let i = bottom.length - 6; i >= 6; i -= 6) {\n      if (isNaN(bottom[i])) {\n        buffer.push(`L${bottom[i + 4]} ${bottom[i + 5]}`);\n      } else {\n        buffer.push(\n          `C${bottom[i]} ${bottom[i + 1]} ${bottom[i + 2]} ${bottom[i + 3]} ${\n            bottom[i + 4]\n          } ${bottom[i + 5]}`\n        );\n      }\n    }\n\n    this.#toSVGPathStart(buffer);\n\n    return buffer.join(\" \");\n  }\n\n  #toSVGPathTwoPoints() {\n    const [x, y, width, height] = this.#box;\n    const [lastTopX, lastTopY, lastBottomX, lastBottomY] =\n      this.#getLastCoords();\n\n    return `M${(this.#last[2] - x) / width} ${\n      (this.#last[3] - y) / height\n    } L${(this.#last[4] - x) / width} ${(this.#last[5] - y) / height} L${lastTopX} ${lastTopY} L${lastBottomX} ${lastBottomY} L${\n      (this.#last[16] - x) / width\n    } ${(this.#last[17] - y) / height} L${(this.#last[14] - x) / width} ${\n      (this.#last[15] - y) / height\n    } Z`;\n  }\n\n  #toSVGPathStart(buffer) {\n    const bottom = this.#bottom;\n    buffer.push(`L${bottom[4]} ${bottom[5]} Z`);\n  }\n\n  #toSVGPathEnd(buffer) {\n    const [x, y, width, height] = this.#box;\n    const lastTop = this.#last.subarray(4, 6);\n    const lastBottom = this.#last.subarray(16, 18);\n    const [lastTopX, lastTopY, lastBottomX, lastBottomY] =\n      this.#getLastCoords();\n\n    buffer.push(\n      `L${(lastTop[0] - x) / width} ${(lastTop[1] - y) / height} L${lastTopX} ${lastTopY} L${lastBottomX} ${lastBottomY} L${\n        (lastBottom[0] - x) / width\n      } ${(lastBottom[1] - y) / height}`\n    );\n  }\n\n  newFreeDrawOutline(outline, points, box, scaleFactor, innerMargin, isLTR) {\n    return new FreeDrawOutline(\n      outline,\n      points,\n      box,\n      scaleFactor,\n      innerMargin,\n      isLTR\n    );\n  }\n\n  getOutlines() {\n    const top = this.#top;\n    const bottom = this.#bottom;\n    const last = this.#last;\n    const [layerX, layerY, layerWidth, layerHeight] = this.#box;\n\n    const points = new Float32Array((this.#points?.length ?? 0) + 2);\n    for (let i = 0, ii = points.length - 2; i < ii; i += 2) {\n      points[i] = (this.#points[i] - layerX) / layerWidth;\n      points[i + 1] = (this.#points[i + 1] - layerY) / layerHeight;\n    }\n    points[points.length - 2] = (this.#lastX - layerX) / layerWidth;\n    points[points.length - 1] = (this.#lastY - layerY) / layerHeight;\n\n    if (isNaN(last[6]) && !this.isEmpty()) {\n      // We've only two points.\n      return this.#getOutlineTwoPoints(points);\n    }\n\n    const outline = new Float32Array(\n      this.#top.length + 24 + this.#bottom.length\n    );\n    let N = top.length;\n    for (let i = 0; i < N; i += 2) {\n      if (isNaN(top[i])) {\n        outline[i] = outline[i + 1] = NaN;\n        continue;\n      }\n      outline[i] = top[i];\n      outline[i + 1] = top[i + 1];\n    }\n\n    N = this.#getOutlineEnd(outline, N);\n\n    for (let i = bottom.length - 6; i >= 6; i -= 6) {\n      for (let j = 0; j < 6; j += 2) {\n        if (isNaN(bottom[i + j])) {\n          outline[N] = outline[N + 1] = NaN;\n          N += 2;\n          continue;\n        }\n        outline[N] = bottom[i + j];\n        outline[N + 1] = bottom[i + j + 1];\n        N += 2;\n      }\n    }\n\n    this.#getOutlineStart(outline, N);\n\n    return this.newFreeDrawOutline(\n      outline,\n      points,\n      this.#box,\n      this.#scaleFactor,\n      this.#innerMargin,\n      this.#isLTR\n    );\n  }\n\n  #getOutlineTwoPoints(points) {\n    const last = this.#last;\n    const [layerX, layerY, layerWidth, layerHeight] = this.#box;\n    const [lastTopX, lastTopY, lastBottomX, lastBottomY] =\n      this.#getLastCoords();\n    const outline = new Float32Array(36);\n    outline.set(\n      [\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        (last[2] - layerX) / layerWidth,\n        (last[3] - layerY) / layerHeight,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        (last[4] - layerX) / layerWidth,\n        (last[5] - layerY) / layerHeight,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        lastTopX,\n        lastTopY,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        lastBottomX,\n        lastBottomY,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        (last[16] - layerX) / layerWidth,\n        (last[17] - layerY) / layerHeight,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        (last[14] - layerX) / layerWidth,\n        (last[15] - layerY) / layerHeight,\n      ],\n      0\n    );\n    return this.newFreeDrawOutline(\n      outline,\n      points,\n      this.#box,\n      this.#scaleFactor,\n      this.#innerMargin,\n      this.#isLTR\n    );\n  }\n\n  #getOutlineStart(outline, pos) {\n    const bottom = this.#bottom;\n    outline.set([NaN, NaN, NaN, NaN, bottom[4], bottom[5]], pos);\n    return (pos += 6);\n  }\n\n  #getOutlineEnd(outline, pos) {\n    const lastTop = this.#last.subarray(4, 6);\n    const lastBottom = this.#last.subarray(16, 18);\n    const [layerX, layerY, layerWidth, layerHeight] = this.#box;\n    const [lastTopX, lastTopY, lastBottomX, lastBottomY] =\n      this.#getLastCoords();\n    outline.set(\n      [\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        (lastTop[0] - layerX) / layerWidth,\n        (lastTop[1] - layerY) / layerHeight,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        lastTopX,\n        lastTopY,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        lastBottomX,\n        lastBottomY,\n        NaN,\n        NaN,\n        NaN,\n        NaN,\n        (lastBottom[0] - layerX) / layerWidth,\n        (lastBottom[1] - layerY) / layerHeight,\n      ],\n      pos\n    );\n    return (pos += 24);\n  }\n}\n\nclass FreeDrawOutline extends Outline {\n  #box;\n\n  #bbox = new Float32Array(4);\n\n  #innerMargin;\n\n  #isLTR;\n\n  #points;\n\n  #scaleFactor;\n\n  #outline;\n\n  constructor(outline, points, box, scaleFactor, innerMargin, isLTR) {\n    super();\n    this.#outline = outline;\n    this.#points = points;\n    this.#box = box;\n    this.#scaleFactor = scaleFactor;\n    this.#innerMargin = innerMargin;\n    this.#isLTR = isLTR;\n    this.firstPoint = [NaN, NaN];\n    this.lastPoint = [NaN, NaN];\n    this.#computeMinMax(isLTR);\n\n    const [x, y, width, height] = this.#bbox;\n    for (let i = 0, ii = outline.length; i < ii; i += 2) {\n      outline[i] = (outline[i] - x) / width;\n      outline[i + 1] = (outline[i + 1] - y) / height;\n    }\n    for (let i = 0, ii = points.length; i < ii; i += 2) {\n      points[i] = (points[i] - x) / width;\n      points[i + 1] = (points[i + 1] - y) / height;\n    }\n  }\n\n  toSVGPath() {\n    const buffer = [`M${this.#outline[4]} ${this.#outline[5]}`];\n    for (let i = 6, ii = this.#outline.length; i < ii; i += 6) {\n      if (isNaN(this.#outline[i])) {\n        buffer.push(`L${this.#outline[i + 4]} ${this.#outline[i + 5]}`);\n        continue;\n      }\n      buffer.push(\n        `C${this.#outline[i]} ${this.#outline[i + 1]} ${this.#outline[i + 2]} ${\n          this.#outline[i + 3]\n        } ${this.#outline[i + 4]} ${this.#outline[i + 5]}`\n      );\n    }\n    buffer.push(\"Z\");\n    return buffer.join(\" \");\n  }\n\n  serialize([blX, blY, trX, trY], rotation) {\n    const width = trX - blX;\n    const height = trY - blY;\n    let outline;\n    let points;\n    switch (rotation) {\n      case 0:\n        outline = Outline._rescale(this.#outline, blX, trY, width, -height);\n        points = Outline._rescale(this.#points, blX, trY, width, -height);\n        break;\n      case 90:\n        outline = Outline._rescaleAndSwap(\n          this.#outline,\n          blX,\n          blY,\n          width,\n          height\n        );\n        points = Outline._rescaleAndSwap(this.#points, blX, blY, width, height);\n        break;\n      case 180:\n        outline = Outline._rescale(this.#outline, trX, blY, -width, height);\n        points = Outline._rescale(this.#points, trX, blY, -width, height);\n        break;\n      case 270:\n        outline = Outline._rescaleAndSwap(\n          this.#outline,\n          trX,\n          trY,\n          -width,\n          -height\n        );\n        points = Outline._rescaleAndSwap(\n          this.#points,\n          trX,\n          trY,\n          -width,\n          -height\n        );\n        break;\n    }\n    return { outline: Array.from(outline), points: [Array.from(points)] };\n  }\n\n  #computeMinMax(isLTR) {\n    const outline = this.#outline;\n    let lastX = outline[4];\n    let lastY = outline[5];\n    const minMax = [lastX, lastY, lastX, lastY];\n    let firstPointX = lastX;\n    let firstPointY = lastY;\n    let lastPointX = lastX;\n    let lastPointY = lastY;\n    const ltrCallback = isLTR ? Math.max : Math.min;\n    const bezierBbox = new Float32Array(4);\n\n    for (let i = 6, ii = outline.length; i < ii; i += 6) {\n      const x = outline[i + 4],\n        y = outline[i + 5];\n\n      if (isNaN(outline[i])) {\n        Util.pointBoundingBox(x, y, minMax);\n\n        if (firstPointY > y) {\n          firstPointX = x;\n          firstPointY = y;\n        } else if (firstPointY === y) {\n          firstPointX = ltrCallback(firstPointX, x);\n        }\n        if (lastPointY < y) {\n          lastPointX = x;\n          lastPointY = y;\n        } else if (lastPointY === y) {\n          lastPointX = ltrCallback(lastPointX, x);\n        }\n      } else {\n        bezierBbox[0] = bezierBbox[1] = Infinity;\n        bezierBbox[2] = bezierBbox[3] = -Infinity;\n        Util.bezierBoundingBox(\n          lastX,\n          lastY,\n          ...outline.slice(i, i + 6),\n          bezierBbox\n        );\n\n        Util.rectBoundingBox(\n          bezierBbox[0],\n          bezierBbox[1],\n          bezierBbox[2],\n          bezierBbox[3],\n          minMax\n        );\n\n        if (firstPointY > bezierBbox[1]) {\n          firstPointX = bezierBbox[0];\n          firstPointY = bezierBbox[1];\n        } else if (firstPointY === bezierBbox[1]) {\n          firstPointX = ltrCallback(firstPointX, bezierBbox[0]);\n        }\n        if (lastPointY < bezierBbox[3]) {\n          lastPointX = bezierBbox[2];\n          lastPointY = bezierBbox[3];\n        } else if (lastPointY === bezierBbox[3]) {\n          lastPointX = ltrCallback(lastPointX, bezierBbox[2]);\n        }\n      }\n      lastX = x;\n      lastY = y;\n    }\n\n    const bbox = this.#bbox;\n    bbox[0] = minMax[0] - this.#innerMargin;\n    bbox[1] = minMax[1] - this.#innerMargin;\n    bbox[2] = minMax[2] - minMax[0] + 2 * this.#innerMargin;\n    bbox[3] = minMax[3] - minMax[1] + 2 * this.#innerMargin;\n    this.firstPoint = [firstPointX, firstPointY];\n    this.lastPoint = [lastPointX, lastPointY];\n  }\n\n  get box() {\n    return this.#bbox;\n  }\n\n  newOutliner(point, box, scaleFactor, thickness, isLTR, innerMargin = 0) {\n    return new FreeDrawOutliner(\n      point,\n      box,\n      scaleFactor,\n      thickness,\n      isLTR,\n      innerMargin\n    );\n  }\n\n  getNewOutline(thickness, innerMargin) {\n    // Build the outline of the highlight to use as the focus outline.\n    const [x, y, width, height] = this.#bbox;\n    const [layerX, layerY, layerWidth, layerHeight] = this.#box;\n    const sx = width * layerWidth;\n    const sy = height * layerHeight;\n    const tx = x * layerWidth + layerX;\n    const ty = y * layerHeight + layerY;\n    const outliner = this.newOutliner(\n      {\n        x: this.#points[0] * sx + tx,\n        y: this.#points[1] * sy + ty,\n      },\n      this.#box,\n      this.#scaleFactor,\n      thickness,\n      this.#isLTR,\n      innerMargin ?? this.#innerMargin\n    );\n    for (let i = 2; i < this.#points.length; i += 2) {\n      outliner.add({\n        x: this.#points[i] * sx + tx,\n        y: this.#points[i + 1] * sy + ty,\n      });\n    }\n    return outliner.getOutlines();\n  }\n}\n\nexport { FreeDrawOutline, FreeDrawOutliner };\n","/* Copyright 2023 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { FreeDrawOutline, FreeDrawOutliner } from \"./freedraw.js\";\nimport { Outline } from \"./outline.js\";\nimport { Util } from \"../../../shared/util.js\";\n\nclass HighlightOutliner {\n  #box;\n\n  #firstPoint;\n\n  #lastPoint;\n\n  #verticalEdges = [];\n\n  #intervals = [];\n\n  /**\n   * Construct an outliner.\n   * @param {Array<Object>} boxes - An array of axis-aligned rectangles.\n   * @param {number} borderWidth - The width of the border of the boxes, it\n   *   allows to make the boxes bigger (or smaller).\n   * @param {number} innerMargin - The margin between the boxes and the\n   *   outlines. It's important to not have a null innerMargin when we want to\n   *   draw the outline else the stroked outline could be clipped because of its\n   *   width.\n   * @param {boolean} isLTR - true if we're in LTR mode. It's used to determine\n   *   the last point of the boxes.\n   */\n  constructor(boxes, borderWidth = 0, innerMargin = 0, isLTR = true) {\n    const minMax = [Infinity, Infinity, -Infinity, -Infinity];\n\n    // We round the coordinates to slightly reduce the number of edges in the\n    // final outlines.\n    const NUMBER_OF_DIGITS = 4;\n    const EPSILON = 10 ** -NUMBER_OF_DIGITS;\n\n    // The coordinates of the boxes are in the page coordinate system.\n    for (const { x, y, width, height } of boxes) {\n      const x1 = Math.floor((x - borderWidth) / EPSILON) * EPSILON;\n      const x2 = Math.ceil((x + width + borderWidth) / EPSILON) * EPSILON;\n      const y1 = Math.floor((y - borderWidth) / EPSILON) * EPSILON;\n      const y2 = Math.ceil((y + height + borderWidth) / EPSILON) * EPSILON;\n      const left = [x1, y1, y2, true];\n      const right = [x2, y1, y2, false];\n      this.#verticalEdges.push(left, right);\n\n      Util.rectBoundingBox(x1, y1, x2, y2, minMax);\n    }\n\n    const bboxWidth = minMax[2] - minMax[0] + 2 * innerMargin;\n    const bboxHeight = minMax[3] - minMax[1] + 2 * innerMargin;\n    const shiftedMinX = minMax[0] - innerMargin;\n    const shiftedMinY = minMax[1] - innerMargin;\n    let firstPointX = isLTR ? -Infinity : Infinity;\n    let firstPointY = Infinity;\n    const lastEdge = this.#verticalEdges.at(isLTR ? -1 : -2);\n    const lastPoint = [lastEdge[0], lastEdge[2]];\n\n    // Convert the coordinates of the edges into box coordinates.\n    for (const edge of this.#verticalEdges) {\n      const [x, y1, y2, left] = edge;\n      if (!left && isLTR) {\n        if (y1 < firstPointY) {\n          firstPointY = y1;\n          firstPointX = x;\n        } else if (y1 === firstPointY) {\n          firstPointX = Math.max(firstPointX, x);\n        }\n      } else if (left && !isLTR) {\n        if (y1 < firstPointY) {\n          firstPointY = y1;\n          firstPointX = x;\n        } else if (y1 === firstPointY) {\n          firstPointX = Math.min(firstPointX, x);\n        }\n      }\n\n      edge[0] = (x - shiftedMinX) / bboxWidth;\n      edge[1] = (y1 - shiftedMinY) / bboxHeight;\n      edge[2] = (y2 - shiftedMinY) / bboxHeight;\n    }\n\n    this.#box = new Float32Array([\n      shiftedMinX,\n      shiftedMinY,\n      bboxWidth,\n      bboxHeight,\n    ]);\n    this.#firstPoint = [firstPointX, firstPointY];\n    this.#lastPoint = lastPoint;\n  }\n\n  getOutlines() {\n    // We begin to sort lexicographically the vertical edges by their abscissa,\n    // and then by their ordinate.\n    this.#verticalEdges.sort(\n      (a, b) => a[0] - b[0] || a[1] - b[1] || a[2] - b[2]\n    );\n\n    // We're now using a sweep line algorithm to find the outlines.\n    // We start with the leftmost vertical edge, and we're going to iterate\n    // over all the vertical edges from left to right.\n    // Each time we encounter a left edge, we're going to insert the interval\n    // [y1, y2] in the set of intervals.\n    // This set of intervals is used to break the vertical edges into chunks:\n    // we only take the part of the vertical edge that isn't in the union of\n    // the intervals.\n    const outlineVerticalEdges = [];\n    for (const edge of this.#verticalEdges) {\n      if (edge[3]) {\n        // Left edge.\n        outlineVerticalEdges.push(...this.#breakEdge(edge));\n        this.#insert(edge);\n      } else {\n        // Right edge.\n        this.#remove(edge);\n        outlineVerticalEdges.push(...this.#breakEdge(edge));\n      }\n    }\n    return this.#getOutlines(outlineVerticalEdges);\n  }\n\n  #getOutlines(outlineVerticalEdges) {\n    const edges = [];\n    const allEdges = new Set();\n\n    for (const edge of outlineVerticalEdges) {\n      const [x, y1, y2] = edge;\n      edges.push([x, y1, edge], [x, y2, edge]);\n    }\n\n    // We sort lexicographically the vertices of each edge by their ordinate and\n    // by their abscissa.\n    // Every pair (v_2i, v_{2i + 1}) of vertices defines a horizontal edge.\n    // So for every vertical edge, we're going to add the two vertical edges\n    // which are connected to it through a horizontal edge.\n    edges.sort((a, b) => a[1] - b[1] || a[0] - b[0]);\n    for (let i = 0, ii = edges.length; i < ii; i += 2) {\n      const edge1 = edges[i][2];\n      const edge2 = edges[i + 1][2];\n      edge1.push(edge2);\n      edge2.push(edge1);\n      allEdges.add(edge1);\n      allEdges.add(edge2);\n    }\n    const outlines = [];\n    let outline;\n\n    while (allEdges.size > 0) {\n      const edge = allEdges.values().next().value;\n      let [x, y1, y2, edge1, edge2] = edge;\n      allEdges.delete(edge);\n      let lastPointX = x;\n      let lastPointY = y1;\n\n      outline = [x, y2];\n      outlines.push(outline);\n\n      while (true) {\n        let e;\n        if (allEdges.has(edge1)) {\n          e = edge1;\n        } else if (allEdges.has(edge2)) {\n          e = edge2;\n        } else {\n          break;\n        }\n\n        allEdges.delete(e);\n        [x, y1, y2, edge1, edge2] = e;\n\n        if (lastPointX !== x) {\n          outline.push(lastPointX, lastPointY, x, lastPointY === y1 ? y1 : y2);\n          lastPointX = x;\n        }\n        lastPointY = lastPointY === y1 ? y2 : y1;\n      }\n      outline.push(lastPointX, lastPointY);\n    }\n    return new HighlightOutline(\n      outlines,\n      this.#box,\n      this.#firstPoint,\n      this.#lastPoint\n    );\n  }\n\n  #binarySearch(y) {\n    const array = this.#intervals;\n    let start = 0;\n    let end = array.length - 1;\n\n    while (start <= end) {\n      const middle = (start + end) >> 1;\n      const y1 = array[middle][0];\n      if (y1 === y) {\n        return middle;\n      }\n      if (y1 < y) {\n        start = middle + 1;\n      } else {\n        end = middle - 1;\n      }\n    }\n    return end + 1;\n  }\n\n  #insert([, y1, y2]) {\n    const index = this.#binarySearch(y1);\n    this.#intervals.splice(index, 0, [y1, y2]);\n  }\n\n  #remove([, y1, y2]) {\n    const index = this.#binarySearch(y1);\n    for (let i = index; i < this.#intervals.length; i++) {\n      const [start, end] = this.#intervals[i];\n      if (start !== y1) {\n        break;\n      }\n      if (start === y1 && end === y2) {\n        this.#intervals.splice(i, 1);\n        return;\n      }\n    }\n    for (let i = index - 1; i >= 0; i--) {\n      const [start, end] = this.#intervals[i];\n      if (start !== y1) {\n        break;\n      }\n      if (start === y1 && end === y2) {\n        this.#intervals.splice(i, 1);\n        return;\n      }\n    }\n  }\n\n  #breakEdge(edge) {\n    const [x, y1, y2] = edge;\n    const results = [[x, y1, y2]];\n    const index = this.#binarySearch(y2);\n    for (let i = 0; i < index; i++) {\n      const [start, end] = this.#intervals[i];\n      for (let j = 0, jj = results.length; j < jj; j++) {\n        const [, y3, y4] = results[j];\n        if (end <= y3 || y4 <= start) {\n          // There is no intersection between the interval and the edge, hence\n          // we keep it as is.\n          continue;\n        }\n        if (y3 >= start) {\n          if (y4 > end) {\n            results[j][1] = end;\n          } else {\n            if (jj === 1) {\n              return [];\n            }\n            // The edge is included in the interval, hence we remove it.\n            results.splice(j, 1);\n            j--;\n            jj--;\n          }\n          continue;\n        }\n        results[j][2] = start;\n        if (y4 > end) {\n          results.push([x, end, y4]);\n        }\n      }\n    }\n    return results;\n  }\n}\n\nclass HighlightOutline extends Outline {\n  #box;\n\n  #outlines;\n\n  constructor(outlines, box, firstPoint, lastPoint) {\n    super();\n    this.#outlines = outlines;\n    this.#box = box;\n    this.firstPoint = firstPoint;\n    this.lastPoint = lastPoint;\n  }\n\n  toSVGPath() {\n    const buffer = [];\n    for (const polygon of this.#outlines) {\n      let [prevX, prevY] = polygon;\n      buffer.push(`M${prevX} ${prevY}`);\n      for (let i = 2; i < polygon.length; i += 2) {\n        const x = polygon[i];\n        const y = polygon[i + 1];\n        if (x === prevX) {\n          buffer.push(`V${y}`);\n          prevY = y;\n        } else if (y === prevY) {\n          buffer.push(`H${x}`);\n          prevX = x;\n        }\n      }\n      buffer.push(\"Z\");\n    }\n    return buffer.join(\" \");\n  }\n\n  /**\n   * Serialize the outlines into the PDF page coordinate system.\n   * @param {Array<number>} _bbox - the bounding box of the annotation.\n   * @param {number} _rotation - the rotation of the annotation.\n   * @returns {Array<Array<number>>}\n   */\n  serialize([blX, blY, trX, trY], _rotation) {\n    const outlines = [];\n    const width = trX - blX;\n    const height = trY - blY;\n    for (const outline of this.#outlines) {\n      const points = new Array(outline.length);\n      for (let i = 0; i < outline.length; i += 2) {\n        points[i] = blX + outline[i] * width;\n        points[i + 1] = trY - outline[i + 1] * height;\n      }\n      outlines.push(points);\n    }\n    return outlines;\n  }\n\n  get box() {\n    return this.#box;\n  }\n\n  get classNamesForOutlining() {\n    return [\"highlightOutline\"];\n  }\n}\n\nclass FreeHighlightOutliner extends FreeDrawOutliner {\n  newFreeDrawOutline(outline, points, box, scaleFactor, innerMargin, isLTR) {\n    return new FreeHighlightOutline(\n      outline,\n      points,\n      box,\n      scaleFactor,\n      innerMargin,\n      isLTR\n    );\n  }\n}\n\nclass FreeHighlightOutline extends FreeDrawOutline {\n  newOutliner(point, box, scaleFactor, thickness, isLTR, innerMargin = 0) {\n    return new FreeHighlightOutliner(\n      point,\n      box,\n      scaleFactor,\n      thickness,\n      isLTR,\n      innerMargin\n    );\n  }\n}\n\nexport { FreeHighlightOutliner, HighlightOutliner };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  AnnotationEditorParamsType,\n  AnnotationEditorType,\n  shadow,\n  Util,\n} from \"../../shared/util.js\";\nimport { bindEvents, KeyboardManager } from \"./tools.js\";\nimport {\n  FreeHighlightOutliner,\n  HighlightOutliner,\n} from \"./drawers/highlight.js\";\nimport {\n  HighlightAnnotationElement,\n  InkAnnotationElement,\n} from \"../annotation_layer.js\";\nimport { noContextMenu, stopEvent } from \"../display_utils.js\";\nimport { AnnotationEditor } from \"./editor.js\";\nimport { ColorPicker } from \"./color_picker.js\";\n\n/**\n * Basic draw editor in order to generate an Highlight annotation.\n */\nclass HighlightEditor extends AnnotationEditor {\n  #anchorNode = null;\n\n  #anchorOffset = 0;\n\n  #boxes;\n\n  #clipPathId = null;\n\n  #colorPicker = null;\n\n  #focusOutlines = null;\n\n  #focusNode = null;\n\n  #focusOffset = 0;\n\n  #highlightDiv = null;\n\n  #highlightOutlines = null;\n\n  #id = null;\n\n  #isFreeHighlight = false;\n\n  #firstPoint = null;\n\n  #lastPoint = null;\n\n  #outlineId = null;\n\n  #text = \"\";\n\n  #thickness;\n\n  #methodOfCreation = \"\";\n\n  static _defaultColor = null;\n\n  static _defaultOpacity = 1;\n\n  static _defaultThickness = 12;\n\n  static _type = \"highlight\";\n\n  static _editorType = AnnotationEditorType.HIGHLIGHT;\n\n  static _freeHighlightId = -1;\n\n  static _freeHighlight = null;\n\n  static _freeHighlightClipId = \"\";\n\n  static get _keyboardManager() {\n    const proto = HighlightEditor.prototype;\n    return shadow(\n      this,\n      \"_keyboardManager\",\n      new KeyboardManager([\n        [[\"ArrowLeft\", \"mac+ArrowLeft\"], proto._moveCaret, { args: [0] }],\n        [[\"ArrowRight\", \"mac+ArrowRight\"], proto._moveCaret, { args: [1] }],\n        [[\"ArrowUp\", \"mac+ArrowUp\"], proto._moveCaret, { args: [2] }],\n        [[\"ArrowDown\", \"mac+ArrowDown\"], proto._moveCaret, { args: [3] }],\n      ])\n    );\n  }\n\n  constructor(params) {\n    super({ ...params, name: \"highlightEditor\" });\n    this.color = params.color || HighlightEditor._defaultColor;\n    this.#thickness = params.thickness || HighlightEditor._defaultThickness;\n    this.opacity = params.opacity || HighlightEditor._defaultOpacity;\n    this.#boxes = params.boxes || null;\n    this.#methodOfCreation = params.methodOfCreation || \"\";\n    this.#text = params.text || \"\";\n    this._isDraggable = false;\n    this.defaultL10nId = \"pdfjs-editor-highlight-editor\";\n\n    if (params.highlightId > -1) {\n      this.#isFreeHighlight = true;\n      this.#createFreeOutlines(params);\n      this.#addToDrawLayer();\n    } else if (this.#boxes) {\n      this.#anchorNode = params.anchorNode;\n      this.#anchorOffset = params.anchorOffset;\n      this.#focusNode = params.focusNode;\n      this.#focusOffset = params.focusOffset;\n      this.#createOutlines();\n      this.#addToDrawLayer();\n      this.rotate(this.rotation);\n    }\n\n    if (!this.annotationElementId) {\n      this._uiManager.a11yAlert(\"pdfjs-editor-highlight-added-alert\");\n    }\n  }\n\n  /** @inheritdoc */\n  get telemetryInitialData() {\n    return {\n      action: \"added\",\n      type: this.#isFreeHighlight ? \"free_highlight\" : \"highlight\",\n      color: this._uiManager.getNonHCMColorName(this.color),\n      thickness: this.#thickness,\n      methodOfCreation: this.#methodOfCreation,\n    };\n  }\n\n  /** @inheritdoc */\n  get telemetryFinalData() {\n    return {\n      type: \"highlight\",\n      color: this._uiManager.getNonHCMColorName(this.color),\n    };\n  }\n\n  static computeTelemetryFinalData(data) {\n    // We want to know how many colors have been used.\n    return { numberOfColors: data.get(\"color\").size };\n  }\n\n  #createOutlines() {\n    const outliner = new HighlightOutliner(\n      this.#boxes,\n      /* borderWidth = */ 0.001\n    );\n    this.#highlightOutlines = outliner.getOutlines();\n    [this.x, this.y, this.width, this.height] = this.#highlightOutlines.box;\n\n    const outlinerForOutline = new HighlightOutliner(\n      this.#boxes,\n      /* borderWidth = */ 0.0025,\n      /* innerMargin = */ 0.001,\n      this._uiManager.direction === \"ltr\"\n    );\n    this.#focusOutlines = outlinerForOutline.getOutlines();\n\n    const { firstPoint } = this.#highlightOutlines;\n    this.#firstPoint = [\n      (firstPoint[0] - this.x) / this.width,\n      (firstPoint[1] - this.y) / this.height,\n    ];\n    // The last point is in the pages coordinate system.\n    const { lastPoint } = this.#focusOutlines;\n    this.#lastPoint = [\n      (lastPoint[0] - this.x) / this.width,\n      (lastPoint[1] - this.y) / this.height,\n    ];\n  }\n\n  #createFreeOutlines({ highlightOutlines, highlightId, clipPathId }) {\n    this.#highlightOutlines = highlightOutlines;\n    const extraThickness = 1.5;\n    this.#focusOutlines = highlightOutlines.getNewOutline(\n      /* Slightly bigger than the highlight in order to have a little\n         space between the highlight and the outline. */\n      this.#thickness / 2 + extraThickness,\n      /* innerMargin = */ 0.0025\n    );\n\n    if (highlightId >= 0) {\n      this.#id = highlightId;\n      this.#clipPathId = clipPathId;\n      // We need to redraw the highlight because we change the coordinates to be\n      // in the box coordinate system.\n      this.parent.drawLayer.finalizeDraw(highlightId, {\n        bbox: highlightOutlines.box,\n        path: {\n          d: highlightOutlines.toSVGPath(),\n        },\n      });\n      this.#outlineId = this.parent.drawLayer.drawOutline(\n        {\n          rootClass: {\n            highlightOutline: true,\n            free: true,\n          },\n          bbox: this.#focusOutlines.box,\n          path: {\n            d: this.#focusOutlines.toSVGPath(),\n          },\n        },\n        /* mustRemoveSelfIntersections = */ true\n      );\n    } else if (this.parent) {\n      const angle = this.parent.viewport.rotation;\n      this.parent.drawLayer.updateProperties(this.#id, {\n        bbox: HighlightEditor.#rotateBbox(\n          this.#highlightOutlines.box,\n          (angle - this.rotation + 360) % 360\n        ),\n        path: {\n          d: highlightOutlines.toSVGPath(),\n        },\n      });\n      this.parent.drawLayer.updateProperties(this.#outlineId, {\n        bbox: HighlightEditor.#rotateBbox(this.#focusOutlines.box, angle),\n        path: {\n          d: this.#focusOutlines.toSVGPath(),\n        },\n      });\n    }\n    const [x, y, width, height] = highlightOutlines.box;\n    switch (this.rotation) {\n      case 0:\n        this.x = x;\n        this.y = y;\n        this.width = width;\n        this.height = height;\n        break;\n      case 90: {\n        const [pageWidth, pageHeight] = this.parentDimensions;\n        this.x = y;\n        this.y = 1 - x;\n        this.width = (width * pageHeight) / pageWidth;\n        this.height = (height * pageWidth) / pageHeight;\n        break;\n      }\n      case 180:\n        this.x = 1 - x;\n        this.y = 1 - y;\n        this.width = width;\n        this.height = height;\n        break;\n      case 270: {\n        const [pageWidth, pageHeight] = this.parentDimensions;\n        this.x = 1 - y;\n        this.y = x;\n        this.width = (width * pageHeight) / pageWidth;\n        this.height = (height * pageWidth) / pageHeight;\n        break;\n      }\n    }\n\n    const { firstPoint } = highlightOutlines;\n    this.#firstPoint = [\n      (firstPoint[0] - x) / width,\n      (firstPoint[1] - y) / height,\n    ];\n    const { lastPoint } = this.#focusOutlines;\n    this.#lastPoint = [(lastPoint[0] - x) / width, (lastPoint[1] - y) / height];\n  }\n\n  /** @inheritdoc */\n  static initialize(l10n, uiManager) {\n    AnnotationEditor.initialize(l10n, uiManager);\n    HighlightEditor._defaultColor ||=\n      uiManager.highlightColors?.values().next().value || \"#fff066\";\n  }\n\n  /** @inheritdoc */\n  static updateDefaultParams(type, value) {\n    switch (type) {\n      case AnnotationEditorParamsType.HIGHLIGHT_COLOR:\n        HighlightEditor._defaultColor = value;\n        break;\n      case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:\n        HighlightEditor._defaultThickness = value;\n        break;\n    }\n  }\n\n  /** @inheritdoc */\n  translateInPage(x, y) {}\n\n  /** @inheritdoc */\n  get toolbarPosition() {\n    return this.#lastPoint;\n  }\n\n  /** @inheritdoc */\n  get commentButtonPosition() {\n    return this.#firstPoint;\n  }\n\n  /** @inheritdoc */\n  updateParams(type, value) {\n    switch (type) {\n      case AnnotationEditorParamsType.HIGHLIGHT_COLOR:\n        this.#updateColor(value);\n        break;\n      case AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:\n        this.#updateThickness(value);\n        break;\n    }\n  }\n\n  static get defaultPropertiesToUpdate() {\n    return [\n      [\n        AnnotationEditorParamsType.HIGHLIGHT_COLOR,\n        HighlightEditor._defaultColor,\n      ],\n      [\n        AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,\n        HighlightEditor._defaultThickness,\n      ],\n    ];\n  }\n\n  /** @inheritdoc */\n  get propertiesToUpdate() {\n    return [\n      [\n        AnnotationEditorParamsType.HIGHLIGHT_COLOR,\n        this.color || HighlightEditor._defaultColor,\n      ],\n      [\n        AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,\n        this.#thickness || HighlightEditor._defaultThickness,\n      ],\n      [AnnotationEditorParamsType.HIGHLIGHT_FREE, this.#isFreeHighlight],\n    ];\n  }\n\n  /** @inheritdoc */\n  onUpdatedColor() {\n    this.parent?.drawLayer.updateProperties(this.#id, {\n      root: {\n        fill: this.color,\n        \"fill-opacity\": this.opacity,\n      },\n    });\n    this.#colorPicker?.updateColor(this.color);\n    super.onUpdatedColor();\n  }\n\n  /**\n   * Update the color and make this action undoable.\n   * @param {string} color\n   */\n  #updateColor(color) {\n    const setColorAndOpacity = (col, opa) => {\n      this.color = col;\n      this.opacity = opa;\n      this.onUpdatedColor();\n    };\n    const savedColor = this.color;\n    const savedOpacity = this.opacity;\n    this.addCommands({\n      cmd: setColorAndOpacity.bind(\n        this,\n        color,\n        HighlightEditor._defaultOpacity\n      ),\n      undo: setColorAndOpacity.bind(this, savedColor, savedOpacity),\n      post: this._uiManager.updateUI.bind(this._uiManager, this),\n      mustExec: true,\n      type: AnnotationEditorParamsType.HIGHLIGHT_COLOR,\n      overwriteIfSameType: true,\n      keepUndo: true,\n    });\n\n    this._reportTelemetry(\n      {\n        action: \"color_changed\",\n        color: this._uiManager.getNonHCMColorName(color),\n      },\n      /* mustWait = */ true\n    );\n  }\n\n  /**\n   * Update the thickness and make this action undoable.\n   * @param {number} thickness\n   */\n  #updateThickness(thickness) {\n    const savedThickness = this.#thickness;\n    const setThickness = th => {\n      this.#thickness = th;\n      this.#changeThickness(th);\n    };\n    this.addCommands({\n      cmd: setThickness.bind(this, thickness),\n      undo: setThickness.bind(this, savedThickness),\n      post: this._uiManager.updateUI.bind(this._uiManager, this),\n      mustExec: true,\n      type: AnnotationEditorParamsType.INK_THICKNESS,\n      overwriteIfSameType: true,\n      keepUndo: true,\n    });\n    this._reportTelemetry(\n      { action: \"thickness_changed\", thickness },\n      /* mustWait = */ true\n    );\n  }\n\n  /** @inheritdoc */\n  get toolbarButtons() {\n    if (this._uiManager.highlightColors) {\n      const colorPicker = (this.#colorPicker = new ColorPicker({\n        editor: this,\n      }));\n      return [[\"colorPicker\", colorPicker]];\n    }\n    return super.toolbarButtons;\n  }\n\n  /** @inheritdoc */\n  disableEditing() {\n    super.disableEditing();\n    this.div.classList.toggle(\"disabled\", true);\n  }\n\n  /** @inheritdoc */\n  enableEditing() {\n    super.enableEditing();\n    this.div.classList.toggle(\"disabled\", false);\n  }\n\n  /** @inheritdoc */\n  fixAndSetPosition() {\n    return super.fixAndSetPosition(this.#getRotation());\n  }\n\n  /** @inheritdoc */\n  getBaseTranslation() {\n    // The editor itself doesn't have any CSS border (we're drawing one\n    // ourselves in using SVG).\n    return [0, 0];\n  }\n\n  /** @inheritdoc */\n  getRect(tx, ty) {\n    return super.getRect(tx, ty, this.#getRotation());\n  }\n\n  /** @inheritdoc */\n  onceAdded(focus) {\n    if (!this.annotationElementId) {\n      this.parent.addUndoableEditor(this);\n    }\n    if (focus) {\n      this.div.focus();\n    }\n  }\n\n  /** @inheritdoc */\n  remove() {\n    this.#cleanDrawLayer();\n    this._reportTelemetry({\n      action: \"deleted\",\n    });\n    super.remove();\n  }\n\n  /** @inheritdoc */\n  rebuild() {\n    if (!this.parent) {\n      return;\n    }\n    super.rebuild();\n    if (this.div === null) {\n      return;\n    }\n\n    this.#addToDrawLayer();\n\n    if (!this.isAttachedToDOM) {\n      // At some point this editor was removed and we're rebuilding it,\n      // hence we must add it to its parent.\n      this.parent.add(this);\n    }\n  }\n\n  setParent(parent) {\n    let mustBeSelected = false;\n    if (this.parent && !parent) {\n      this.#cleanDrawLayer();\n    } else if (parent) {\n      this.#addToDrawLayer(parent);\n      // If mustBeSelected is true it means that this editor was selected\n      // when its parent has been destroyed, hence we must select it again.\n      mustBeSelected =\n        !this.parent && this.div?.classList.contains(\"selectedEditor\");\n    }\n    super.setParent(parent);\n    this.show(this._isVisible);\n    if (mustBeSelected) {\n      // We select it after the parent has been set.\n      this.select();\n    }\n  }\n\n  #changeThickness(thickness) {\n    if (!this.#isFreeHighlight) {\n      return;\n    }\n    this.#createFreeOutlines({\n      highlightOutlines: this.#highlightOutlines.getNewOutline(thickness / 2),\n    });\n    this.fixAndSetPosition();\n    this.setDims();\n  }\n\n  #cleanDrawLayer() {\n    if (this.#id === null || !this.parent) {\n      return;\n    }\n    this.parent.drawLayer.remove(this.#id);\n    this.#id = null;\n    this.parent.drawLayer.remove(this.#outlineId);\n    this.#outlineId = null;\n  }\n\n  #addToDrawLayer(parent = this.parent) {\n    if (this.#id !== null) {\n      return;\n    }\n    ({ id: this.#id, clipPathId: this.#clipPathId } = parent.drawLayer.draw(\n      {\n        bbox: this.#highlightOutlines.box,\n        root: {\n          viewBox: \"0 0 1 1\",\n          fill: this.color,\n          \"fill-opacity\": this.opacity,\n        },\n        rootClass: {\n          highlight: true,\n          free: this.#isFreeHighlight,\n        },\n        path: {\n          d: this.#highlightOutlines.toSVGPath(),\n        },\n      },\n      /* isPathUpdatable = */ false,\n      /* hasClip = */ true\n    ));\n    this.#outlineId = parent.drawLayer.drawOutline(\n      {\n        rootClass: {\n          highlightOutline: true,\n          free: this.#isFreeHighlight,\n        },\n        bbox: this.#focusOutlines.box,\n        path: {\n          d: this.#focusOutlines.toSVGPath(),\n        },\n      },\n      /* mustRemoveSelfIntersections = */ this.#isFreeHighlight\n    );\n\n    if (this.#highlightDiv) {\n      this.#highlightDiv.style.clipPath = this.#clipPathId;\n    }\n  }\n\n  static #rotateBbox([x, y, width, height], angle) {\n    switch (angle) {\n      case 90:\n        return [1 - y - height, x, height, width];\n      case 180:\n        return [1 - x - width, 1 - y - height, width, height];\n      case 270:\n        return [y, 1 - x - width, height, width];\n    }\n    return [x, y, width, height];\n  }\n\n  /** @inheritdoc */\n  rotate(angle) {\n    // We need to rotate the svgs because of the coordinates system.\n    const { drawLayer } = this.parent;\n    let box;\n    if (this.#isFreeHighlight) {\n      angle = (angle - this.rotation + 360) % 360;\n      box = HighlightEditor.#rotateBbox(this.#highlightOutlines.box, angle);\n    } else {\n      // An highlight annotation is always drawn horizontally.\n      box = HighlightEditor.#rotateBbox(\n        [this.x, this.y, this.width, this.height],\n        angle\n      );\n    }\n    drawLayer.updateProperties(this.#id, {\n      bbox: box,\n      root: {\n        \"data-main-rotation\": angle,\n      },\n    });\n    drawLayer.updateProperties(this.#outlineId, {\n      bbox: HighlightEditor.#rotateBbox(this.#focusOutlines.box, angle),\n      root: {\n        \"data-main-rotation\": angle,\n      },\n    });\n  }\n\n  /** @inheritdoc */\n  render() {\n    if (this.div) {\n      return this.div;\n    }\n\n    const div = super.render();\n    if (this.#text) {\n      div.setAttribute(\"aria-label\", this.#text);\n      div.setAttribute(\"role\", \"mark\");\n    }\n    if (this.#isFreeHighlight) {\n      div.classList.add(\"free\");\n    } else {\n      this.div.addEventListener(\"keydown\", this.#keydown.bind(this), {\n        signal: this._uiManager._signal,\n      });\n    }\n    const highlightDiv = (this.#highlightDiv = document.createElement(\"div\"));\n    div.append(highlightDiv);\n    highlightDiv.setAttribute(\"aria-hidden\", \"true\");\n    highlightDiv.className = \"internal\";\n    highlightDiv.style.clipPath = this.#clipPathId;\n    this.setDims();\n\n    bindEvents(this, this.#highlightDiv, [\"pointerover\", \"pointerleave\"]);\n    this.enableEditing();\n\n    return div;\n  }\n\n  pointerover() {\n    if (!this.isSelected) {\n      this.parent?.drawLayer.updateProperties(this.#outlineId, {\n        rootClass: {\n          hovered: true,\n        },\n      });\n    }\n  }\n\n  pointerleave() {\n    if (!this.isSelected) {\n      this.parent?.drawLayer.updateProperties(this.#outlineId, {\n        rootClass: {\n          hovered: false,\n        },\n      });\n    }\n  }\n\n  #keydown(event) {\n    HighlightEditor._keyboardManager.exec(this, event);\n  }\n\n  _moveCaret(direction) {\n    this.parent.unselect(this);\n    switch (direction) {\n      case 0 /* left */:\n      case 2 /* up */:\n        this.#setCaret(/* start = */ true);\n        break;\n      case 1 /* right */:\n      case 3 /* down */:\n        this.#setCaret(/* start = */ false);\n        break;\n    }\n  }\n\n  #setCaret(start) {\n    if (!this.#anchorNode) {\n      return;\n    }\n    const selection = window.getSelection();\n    if (start) {\n      selection.setPosition(this.#anchorNode, this.#anchorOffset);\n    } else {\n      selection.setPosition(this.#focusNode, this.#focusOffset);\n    }\n  }\n\n  /** @inheritdoc */\n  select() {\n    super.select();\n    if (!this.#outlineId) {\n      return;\n    }\n    this.parent?.drawLayer.updateProperties(this.#outlineId, {\n      rootClass: {\n        hovered: false,\n        selected: true,\n      },\n    });\n  }\n\n  /** @inheritdoc */\n  unselect() {\n    super.unselect();\n    if (!this.#outlineId) {\n      return;\n    }\n    this.parent?.drawLayer.updateProperties(this.#outlineId, {\n      rootClass: {\n        selected: false,\n      },\n    });\n    if (!this.#isFreeHighlight) {\n      this.#setCaret(/* start = */ false);\n    }\n  }\n\n  /** @inheritdoc */\n  get _mustFixPosition() {\n    return !this.#isFreeHighlight;\n  }\n\n  /** @inheritdoc */\n  show(visible = this._isVisible) {\n    super.show(visible);\n    if (this.parent) {\n      this.parent.drawLayer.updateProperties(this.#id, {\n        rootClass: {\n          hidden: !visible,\n        },\n      });\n      this.parent.drawLayer.updateProperties(this.#outlineId, {\n        rootClass: {\n          hidden: !visible,\n        },\n      });\n    }\n  }\n\n  #getRotation() {\n    // Highlight annotations are always drawn horizontally but if\n    // a free highlight annotation can be rotated.\n    return this.#isFreeHighlight ? this.rotation : 0;\n  }\n\n  #serializeBoxes() {\n    if (this.#isFreeHighlight) {\n      return null;\n    }\n    const [pageWidth, pageHeight] = this.pageDimensions;\n    const [pageX, pageY] = this.pageTranslation;\n    const boxes = this.#boxes;\n    const quadPoints = new Float32Array(boxes.length * 8);\n    let i = 0;\n    for (const { x, y, width, height } of boxes) {\n      const sx = x * pageWidth + pageX;\n      const sy = (1 - y) * pageHeight + pageY;\n      // Serializes the rectangle in the Adobe Acrobat format.\n      // The rectangle's coordinates (b = bottom, t = top, L = left, R = right)\n      // are ordered as follows: tL, tR, bL, bR (bL origin).\n      quadPoints[i] = quadPoints[i + 4] = sx;\n      quadPoints[i + 1] = quadPoints[i + 3] = sy;\n      quadPoints[i + 2] = quadPoints[i + 6] = sx + width * pageWidth;\n      quadPoints[i + 5] = quadPoints[i + 7] = sy - height * pageHeight;\n      i += 8;\n    }\n    return quadPoints;\n  }\n\n  #serializeOutlines(rect) {\n    return this.#highlightOutlines.serialize(rect, this.#getRotation());\n  }\n\n  static startHighlighting(parent, isLTR, { target: textLayer, x, y }) {\n    const {\n      x: layerX,\n      y: layerY,\n      width: parentWidth,\n      height: parentHeight,\n    } = textLayer.getBoundingClientRect();\n\n    const ac = new AbortController();\n    const signal = parent.combinedSignal(ac);\n\n    const pointerUpCallback = e => {\n      ac.abort();\n      this.#endHighlight(parent, e);\n    };\n    window.addEventListener(\"blur\", pointerUpCallback, { signal });\n    window.addEventListener(\"pointerup\", pointerUpCallback, { signal });\n    window.addEventListener(\n      \"pointerdown\",\n      stopEvent /* Avoid to have undesired clicks during the drawing. */,\n      {\n        capture: true,\n        passive: false,\n        signal,\n      }\n    );\n    window.addEventListener(\"contextmenu\", noContextMenu, { signal });\n\n    textLayer.addEventListener(\n      \"pointermove\",\n      this.#highlightMove.bind(this, parent),\n      { signal }\n    );\n    this._freeHighlight = new FreeHighlightOutliner(\n      { x, y },\n      [layerX, layerY, parentWidth, parentHeight],\n      parent.scale,\n      this._defaultThickness / 2,\n      isLTR,\n      /* innerMargin = */ 0.001\n    );\n    ({ id: this._freeHighlightId, clipPathId: this._freeHighlightClipId } =\n      parent.drawLayer.draw(\n        {\n          bbox: [0, 0, 1, 1],\n          root: {\n            viewBox: \"0 0 1 1\",\n            fill: this._defaultColor,\n            \"fill-opacity\": this._defaultOpacity,\n          },\n          rootClass: {\n            highlight: true,\n            free: true,\n          },\n          path: {\n            d: this._freeHighlight.toSVGPath(),\n          },\n        },\n        /* isPathUpdatable = */ true,\n        /* hasClip = */ true\n      ));\n  }\n\n  static #highlightMove(parent, event) {\n    if (this._freeHighlight.add(event)) {\n      // Redraw only if the point has been added.\n      parent.drawLayer.updateProperties(this._freeHighlightId, {\n        path: {\n          d: this._freeHighlight.toSVGPath(),\n        },\n      });\n    }\n  }\n\n  static #endHighlight(parent, event) {\n    if (!this._freeHighlight.isEmpty()) {\n      parent.createAndAddNewEditor(event, false, {\n        highlightId: this._freeHighlightId,\n        highlightOutlines: this._freeHighlight.getOutlines(),\n        clipPathId: this._freeHighlightClipId,\n        methodOfCreation: \"main_toolbar\",\n      });\n    } else {\n      parent.drawLayer.remove(this._freeHighlightId);\n    }\n    this._freeHighlightId = -1;\n    this._freeHighlight = null;\n    this._freeHighlightClipId = \"\";\n  }\n\n  /** @inheritdoc */\n  static async deserialize(data, parent, uiManager) {\n    let initialData = null;\n    if (data instanceof HighlightAnnotationElement) {\n      const {\n        data: {\n          quadPoints,\n          rect,\n          rotation,\n          id,\n          color,\n          opacity,\n          popupRef,\n          richText,\n          contentsObj,\n          creationDate,\n          modificationDate,\n        },\n        parent: {\n          page: { pageNumber },\n        },\n      } = data;\n      initialData = data = {\n        annotationType: AnnotationEditorType.HIGHLIGHT,\n        color: Array.from(color),\n        opacity,\n        quadPoints,\n        boxes: null,\n        pageIndex: pageNumber - 1,\n        rect: rect.slice(0),\n        rotation,\n        annotationElementId: id,\n        id,\n        deleted: false,\n        popupRef,\n        richText,\n        comment: contentsObj?.str || null,\n        creationDate,\n        modificationDate,\n      };\n    } else if (data instanceof InkAnnotationElement) {\n      const {\n        data: {\n          inkLists,\n          rect,\n          rotation,\n          id,\n          color,\n          borderStyle: { rawWidth: thickness },\n          popupRef,\n          richText,\n          contentsObj,\n          creationDate,\n          modificationDate,\n        },\n        parent: {\n          page: { pageNumber },\n        },\n      } = data;\n      initialData = data = {\n        annotationType: AnnotationEditorType.HIGHLIGHT,\n        color: Array.from(color),\n        thickness,\n        inkLists,\n        boxes: null,\n        pageIndex: pageNumber - 1,\n        rect: rect.slice(0),\n        rotation,\n        annotationElementId: id,\n        id,\n        deleted: false,\n        popupRef,\n        richText,\n        comment: contentsObj?.str || null,\n        creationDate,\n        modificationDate,\n      };\n    }\n\n    const { color, quadPoints, inkLists, opacity } = data;\n    const editor = await super.deserialize(data, parent, uiManager);\n\n    editor.color = Util.makeHexColor(...color);\n    editor.opacity = opacity || 1;\n    if (inkLists) {\n      editor.#thickness = data.thickness;\n    }\n    editor._initialData = initialData;\n    if (data.comment) {\n      editor.setCommentData(data);\n    }\n\n    const [pageWidth, pageHeight] = editor.pageDimensions;\n    const [pageX, pageY] = editor.pageTranslation;\n\n    if (quadPoints) {\n      const boxes = (editor.#boxes = []);\n      for (let i = 0; i < quadPoints.length; i += 8) {\n        boxes.push({\n          x: (quadPoints[i] - pageX) / pageWidth,\n          y: 1 - (quadPoints[i + 1] - pageY) / pageHeight,\n          width: (quadPoints[i + 2] - quadPoints[i]) / pageWidth,\n          height: (quadPoints[i + 1] - quadPoints[i + 5]) / pageHeight,\n        });\n      }\n      editor.#createOutlines();\n      editor.#addToDrawLayer();\n      editor.rotate(editor.rotation);\n    } else if (inkLists) {\n      editor.#isFreeHighlight = true;\n      const points = inkLists[0];\n      const point = {\n        x: points[0] - pageX,\n        y: pageHeight - (points[1] - pageY),\n      };\n      const outliner = new FreeHighlightOutliner(\n        point,\n        [0, 0, pageWidth, pageHeight],\n        1,\n        editor.#thickness / 2,\n        true,\n        0.001\n      );\n      for (let i = 0, ii = points.length; i < ii; i += 2) {\n        point.x = points[i] - pageX;\n        point.y = pageHeight - (points[i + 1] - pageY);\n        outliner.add(point);\n      }\n      const { id, clipPathId } = parent.drawLayer.draw(\n        {\n          bbox: [0, 0, 1, 1],\n          root: {\n            viewBox: \"0 0 1 1\",\n            fill: editor.color,\n            \"fill-opacity\": editor._defaultOpacity,\n          },\n          rootClass: {\n            highlight: true,\n            free: true,\n          },\n          path: {\n            d: outliner.toSVGPath(),\n          },\n        },\n        /* isPathUpdatable = */ true,\n        /* hasClip = */ true\n      );\n      editor.#createFreeOutlines({\n        highlightOutlines: outliner.getOutlines(),\n        highlightId: id,\n        clipPathId,\n      });\n      editor.#addToDrawLayer();\n      editor.rotate(editor.parentRotation);\n    }\n\n    return editor;\n  }\n\n  /** @inheritdoc */\n  serialize(isForCopying = false) {\n    // It doesn't make sense to copy/paste a highlight annotation.\n    if (this.isEmpty() || isForCopying) {\n      return null;\n    }\n\n    if (this.deleted) {\n      return this.serializeDeleted();\n    }\n\n    const color = AnnotationEditor._colorManager.convert(\n      this._uiManager.getNonHCMColor(this.color)\n    );\n    const serialized = super.serialize(isForCopying);\n    Object.assign(serialized, {\n      color,\n      opacity: this.opacity,\n      thickness: this.#thickness,\n      quadPoints: this.#serializeBoxes(),\n      outlines: this.#serializeOutlines(serialized.rect),\n    });\n    this.addComment(serialized);\n\n    if (this.annotationElementId && !this.#hasElementChanged(serialized)) {\n      return null;\n    }\n\n    serialized.id = this.annotationElementId;\n    return serialized;\n  }\n\n  #hasElementChanged(serialized) {\n    const { color } = this._initialData;\n    return (\n      this.hasEditedComment || serialized.color.some((c, i) => c !== color[i])\n    );\n  }\n\n  /** @inheritdoc */\n  renderAnnotationElement(annotation) {\n    if (this.deleted) {\n      annotation.hide();\n      return null;\n    }\n    annotation.updateEdited({\n      rect: this.getPDFRect(),\n      popup: this.comment,\n    });\n\n    return null;\n  }\n\n  static canCreateNewEmptyEditor() {\n    return false;\n  }\n}\n\nexport { HighlightEditor };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AnnotationEditorParamsType, unreachable } from \"../../shared/util.js\";\nimport { noContextMenu, stopEvent } from \"../display_utils.js\";\nimport { AnnotationEditor } from \"./editor.js\";\nimport { CurrentPointers } from \"./tools.js\";\n\nclass DrawingOptions {\n  #svgProperties = Object.create(null);\n\n  updateProperty(name, value) {\n    this[name] = value;\n    this.updateSVGProperty(name, value);\n  }\n\n  updateProperties(properties) {\n    if (!properties) {\n      return;\n    }\n    for (const [name, value] of Object.entries(properties)) {\n      if (!name.startsWith(\"_\")) {\n        this.updateProperty(name, value);\n      }\n    }\n  }\n\n  updateSVGProperty(name, value) {\n    this.#svgProperties[name] = value;\n  }\n\n  toSVGProperties() {\n    const root = this.#svgProperties;\n    this.#svgProperties = Object.create(null);\n    return { root };\n  }\n\n  reset() {\n    this.#svgProperties = Object.create(null);\n  }\n\n  updateAll(options = this) {\n    this.updateProperties(options);\n  }\n\n  clone() {\n    unreachable(\"Not implemented\");\n  }\n}\n\n/**\n * Basic draw editor.\n */\nclass DrawingEditor extends AnnotationEditor {\n  #drawOutlines = null;\n\n  #mustBeCommitted;\n\n  _colorPicker = null;\n\n  _drawId = null;\n\n  static _currentDrawId = -1;\n\n  static _currentParent = null;\n\n  static #currentDraw = null;\n\n  static #currentDrawingAC = null;\n\n  static #currentDrawingOptions = null;\n\n  static _INNER_MARGIN = 3;\n\n  constructor(params) {\n    super(params);\n    this.#mustBeCommitted = params.mustBeCommitted || false;\n\n    this._addOutlines(params);\n  }\n\n  /** @inheritdoc */\n  onUpdatedColor() {\n    this._colorPicker?.update(this.color);\n    super.onUpdatedColor();\n  }\n\n  _addOutlines(params) {\n    if (params.drawOutlines) {\n      this.#createDrawOutlines(params);\n      this.#addToDrawLayer();\n    }\n  }\n\n  #createDrawOutlines({ drawOutlines, drawId, drawingOptions }) {\n    this.#drawOutlines = drawOutlines;\n    this._drawingOptions ||= drawingOptions;\n    if (!this.annotationElementId) {\n      this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`);\n    }\n\n    if (drawId >= 0) {\n      this._drawId = drawId;\n      // We need to redraw the drawing because we changed the coordinates to be\n      // in the box coordinate system.\n      this.parent.drawLayer.finalizeDraw(\n        drawId,\n        drawOutlines.defaultProperties\n      );\n    } else {\n      // We create a new drawing.\n      this._drawId = this.#createDrawing(drawOutlines, this.parent);\n    }\n\n    this.#updateBbox(drawOutlines.box);\n  }\n\n  #createDrawing(drawOutlines, parent) {\n    const { id } = parent.drawLayer.draw(\n      DrawingEditor._mergeSVGProperties(\n        this._drawingOptions.toSVGProperties(),\n        drawOutlines.defaultSVGProperties\n      ),\n      /* isPathUpdatable = */ false,\n      /* hasClip = */ false\n    );\n    return id;\n  }\n\n  static _mergeSVGProperties(p1, p2) {\n    const p1Keys = new Set(Object.keys(p1));\n\n    for (const [key, value] of Object.entries(p2)) {\n      if (p1Keys.has(key)) {\n        Object.assign(p1[key], value);\n      } else {\n        p1[key] = value;\n      }\n    }\n    return p1;\n  }\n\n  /**\n   * @param {Object} options\n   * @return {DrawingOptions} the default options to use for a new editor.\n   */\n  static getDefaultDrawingOptions(_options) {\n    unreachable(\"Not implemented\");\n  }\n\n  /**\n   * @return {Map<AnnotationEditorParamsType, string>} a map between the\n   *   parameter types and the name of the options.\n   */\n  // eslint-disable-next-line getter-return\n  static get typesMap() {\n    unreachable(\"Not implemented\");\n  }\n\n  static get isDrawer() {\n    return true;\n  }\n\n  /**\n   * @returns {boolean} `true` if several drawings can be added to the\n   * annotation.\n   */\n  static get supportMultipleDrawings() {\n    return false;\n  }\n\n  /** @inheritdoc */\n  static updateDefaultParams(type, value) {\n    const propertyName = this.typesMap.get(type);\n    if (propertyName) {\n      this._defaultDrawingOptions.updateProperty(propertyName, value);\n    }\n    if (this._currentParent) {\n      DrawingEditor.#currentDraw.updateProperty(propertyName, value);\n      this._currentParent.drawLayer.updateProperties(\n        this._currentDrawId,\n        this._defaultDrawingOptions.toSVGProperties()\n      );\n    }\n  }\n\n  /** @inheritdoc */\n  updateParams(type, value) {\n    const propertyName = this.constructor.typesMap.get(type);\n    if (propertyName) {\n      this._updateProperty(type, propertyName, value);\n    }\n  }\n\n  /** @inheritdoc */\n  static get defaultPropertiesToUpdate() {\n    const properties = [];\n    const options = this._defaultDrawingOptions;\n    for (const [type, name] of this.typesMap) {\n      properties.push([type, options[name]]);\n    }\n    return properties;\n  }\n\n  /** @inheritdoc */\n  get propertiesToUpdate() {\n    const properties = [];\n    const { _drawingOptions } = this;\n    for (const [type, name] of this.constructor.typesMap) {\n      properties.push([type, _drawingOptions[name]]);\n    }\n    return properties;\n  }\n\n  /**\n   * Update a property and make this action undoable.\n   * @param {string} color\n   */\n  _updateProperty(type, name, value) {\n    const options = this._drawingOptions;\n    const savedValue = options[name];\n    const setter = val => {\n      options.updateProperty(name, val);\n      const bbox = this.#drawOutlines.updateProperty(name, val);\n      if (bbox) {\n        this.#updateBbox(bbox);\n      }\n      this.parent?.drawLayer.updateProperties(\n        this._drawId,\n        options.toSVGProperties()\n      );\n      if (type === this.colorType) {\n        this.onUpdatedColor();\n      }\n    };\n    this.addCommands({\n      cmd: setter.bind(this, value),\n      undo: setter.bind(this, savedValue),\n      post: this._uiManager.updateUI.bind(this._uiManager, this),\n      mustExec: true,\n      type,\n      overwriteIfSameType: true,\n      keepUndo: true,\n    });\n  }\n\n  /** @inheritdoc */\n  _onResizing() {\n    this.parent?.drawLayer.updateProperties(\n      this._drawId,\n      DrawingEditor._mergeSVGProperties(\n        this.#drawOutlines.getPathResizingSVGProperties(\n          this.#convertToDrawSpace()\n        ),\n        {\n          bbox: this.#rotateBox(),\n        }\n      )\n    );\n  }\n\n  /** @inheritdoc */\n  _onResized() {\n    this.parent?.drawLayer.updateProperties(\n      this._drawId,\n      DrawingEditor._mergeSVGProperties(\n        this.#drawOutlines.getPathResizedSVGProperties(\n          this.#convertToDrawSpace()\n        ),\n        {\n          bbox: this.#rotateBox(),\n        }\n      )\n    );\n  }\n\n  /** @inheritdoc */\n  _onTranslating(_x, _y) {\n    this.parent?.drawLayer.updateProperties(this._drawId, {\n      bbox: this.#rotateBox(),\n    });\n  }\n\n  /** @inheritdoc */\n  _onTranslated() {\n    this.parent?.drawLayer.updateProperties(\n      this._drawId,\n      DrawingEditor._mergeSVGProperties(\n        this.#drawOutlines.getPathTranslatedSVGProperties(\n          this.#convertToDrawSpace(),\n          this.parentDimensions\n        ),\n        {\n          bbox: this.#rotateBox(),\n        }\n      )\n    );\n  }\n\n  _onStartDragging() {\n    this.parent?.drawLayer.updateProperties(this._drawId, {\n      rootClass: {\n        moving: true,\n      },\n    });\n  }\n\n  _onStopDragging() {\n    this.parent?.drawLayer.updateProperties(this._drawId, {\n      rootClass: {\n        moving: false,\n      },\n    });\n  }\n\n  /** @inheritdoc */\n  commit() {\n    super.commit();\n\n    this.disableEditMode();\n    this.disableEditing();\n  }\n\n  /** @inheritdoc */\n  disableEditing() {\n    super.disableEditing();\n    this.div.classList.toggle(\"disabled\", true);\n  }\n\n  /** @inheritdoc */\n  enableEditing() {\n    super.enableEditing();\n    this.div.classList.toggle(\"disabled\", false);\n  }\n\n  /** @inheritdoc */\n  getBaseTranslation() {\n    // The editor itself doesn't have any CSS border (we're drawing one\n    // ourselves in using SVG).\n    return [0, 0];\n  }\n\n  /** @inheritdoc */\n  get isResizable() {\n    return true;\n  }\n\n  /** @inheritdoc */\n  onceAdded(focus) {\n    if (!this.annotationElementId) {\n      this.parent.addUndoableEditor(this);\n    }\n    this._isDraggable = true;\n    if (this.#mustBeCommitted) {\n      this.#mustBeCommitted = false;\n      this.commit();\n      this.parent.setSelected(this);\n      if (focus && this.isOnScreen) {\n        this.div.focus();\n      }\n    }\n  }\n\n  /** @inheritdoc */\n  remove() {\n    this.#cleanDrawLayer();\n    super.remove();\n  }\n\n  /** @inheritdoc */\n  rebuild() {\n    if (!this.parent) {\n      return;\n    }\n    super.rebuild();\n    if (this.div === null) {\n      return;\n    }\n\n    this.#addToDrawLayer();\n    this.#updateBbox(this.#drawOutlines.box);\n\n    if (!this.isAttachedToDOM) {\n      // At some point this editor was removed and we're rebuilding it,\n      // hence we must add it to its parent.\n      this.parent.add(this);\n    }\n  }\n\n  setParent(parent) {\n    let mustBeSelected = false;\n    if (this.parent && !parent) {\n      this._uiManager.removeShouldRescale(this);\n      this.#cleanDrawLayer();\n    } else if (parent) {\n      this._uiManager.addShouldRescale(this);\n      this.#addToDrawLayer(parent);\n      // If mustBeSelected is true it means that this editor was selected\n      // when its parent has been destroyed, hence we must select it again.\n      mustBeSelected =\n        !this.parent && this.div?.classList.contains(\"selectedEditor\");\n    }\n    super.setParent(parent);\n    if (mustBeSelected) {\n      // We select it after the parent has been set.\n      this.select();\n    }\n  }\n\n  #cleanDrawLayer() {\n    if (this._drawId === null || !this.parent) {\n      return;\n    }\n    this.parent.drawLayer.remove(this._drawId);\n    this._drawId = null;\n\n    // All the SVG properties must be reset in order to make it possible to\n    // undo.\n    this._drawingOptions.reset();\n  }\n\n  #addToDrawLayer(parent = this.parent) {\n    if (this._drawId !== null && this.parent === parent) {\n      return;\n    }\n    if (this._drawId !== null) {\n      // The parent has changed, we need to move the drawing to the new parent.\n      this.parent.drawLayer.updateParent(this._drawId, parent.drawLayer);\n      return;\n    }\n    this._drawingOptions.updateAll();\n    this._drawId = this.#createDrawing(this.#drawOutlines, parent);\n  }\n\n  #convertToParentSpace([x, y, width, height]) {\n    const {\n      parentDimensions: [pW, pH],\n      rotation,\n    } = this;\n    switch (rotation) {\n      case 90:\n        return [y, 1 - x, width * (pH / pW), height * (pW / pH)];\n      case 180:\n        return [1 - x, 1 - y, width, height];\n      case 270:\n        return [1 - y, x, width * (pH / pW), height * (pW / pH)];\n      default:\n        return [x, y, width, height];\n    }\n  }\n\n  #convertToDrawSpace() {\n    const {\n      x,\n      y,\n      width,\n      height,\n      parentDimensions: [pW, pH],\n      rotation,\n    } = this;\n    switch (rotation) {\n      case 90:\n        return [1 - y, x, width * (pW / pH), height * (pH / pW)];\n      case 180:\n        return [1 - x, 1 - y, width, height];\n      case 270:\n        return [y, 1 - x, width * (pW / pH), height * (pH / pW)];\n      default:\n        return [x, y, width, height];\n    }\n  }\n\n  #updateBbox(bbox) {\n    [this.x, this.y, this.width, this.height] =\n      this.#convertToParentSpace(bbox);\n    if (this.div) {\n      this.fixAndSetPosition();\n      this.setDims();\n    }\n    this._onResized();\n  }\n\n  #rotateBox() {\n    // We've to deal with two rotations: the rotation of the annotation and the\n    // rotation of the parent page.\n    // When the page is rotated, all the layers are just rotated thanks to CSS\n    // but there is a notable exception: the canvas wrapper.\n    // The canvas wrapper is not rotated but the dimensions are (or not) swapped\n    // and the page is redrawn with the rotation applied to the canvas.\n    // The drawn layer is under the canvas wrapper and is not rotated so we have\n    // to \"manually\" rotate the coordinates.\n    //\n    // The coordinates (this.x, this.y) correspond to the top-left corner of\n    // the editor after it has been rotated in the page coordinate system.\n\n    const {\n      x,\n      y,\n      width,\n      height,\n      rotation,\n      parentRotation,\n      parentDimensions: [pW, pH],\n    } = this;\n    switch ((rotation * 4 + parentRotation) / 90) {\n      case 1:\n        // 0 -> 90\n        return [1 - y - height, x, height, width];\n      case 2:\n        // 0 -> 180\n        return [1 - x - width, 1 - y - height, width, height];\n      case 3:\n        // 0 -> 270\n        return [y, 1 - x - width, height, width];\n      case 4:\n        // 90 -> 0\n        return [\n          x,\n          y - width * (pW / pH),\n          height * (pH / pW),\n          width * (pW / pH),\n        ];\n      case 5:\n        // 90 -> 90\n        return [1 - y, x, width * (pW / pH), height * (pH / pW)];\n      case 6:\n        // 90 -> 180\n        return [\n          1 - x - height * (pH / pW),\n          1 - y,\n          height * (pH / pW),\n          width * (pW / pH),\n        ];\n      case 7:\n        // 90 -> 270\n        return [\n          y - width * (pW / pH),\n          1 - x - height * (pH / pW),\n          width * (pW / pH),\n          height * (pH / pW),\n        ];\n      case 8:\n        // 180 -> 0\n        return [x - width, y - height, width, height];\n      case 9:\n        // 180 -> 90\n        return [1 - y, x - width, height, width];\n      case 10:\n        // 180 -> 180\n        return [1 - x, 1 - y, width, height];\n      case 11:\n        // 180 -> 270\n        return [y - height, 1 - x, height, width];\n      case 12:\n        // 270 -> 0\n        return [\n          x - height * (pH / pW),\n          y,\n          height * (pH / pW),\n          width * (pW / pH),\n        ];\n      case 13:\n        // 270 -> 90\n        return [\n          1 - y - width * (pW / pH),\n          x - height * (pH / pW),\n          width * (pW / pH),\n          height * (pH / pW),\n        ];\n      case 14:\n        // 270 -> 180\n        return [\n          1 - x,\n          1 - y - width * (pW / pH),\n          height * (pH / pW),\n          width * (pW / pH),\n        ];\n      case 15:\n        // 270 -> 270\n        return [y, 1 - x, width * (pW / pH), height * (pH / pW)];\n      default:\n        // 0 -> 0\n        return [x, y, width, height];\n    }\n  }\n\n  /** @inheritdoc */\n  rotate() {\n    if (!this.parent) {\n      return;\n    }\n    this.parent.drawLayer.updateProperties(\n      this._drawId,\n      DrawingEditor._mergeSVGProperties(\n        {\n          bbox: this.#rotateBox(),\n        },\n        this.#drawOutlines.updateRotation(\n          (this.parentRotation - this.rotation + 360) % 360\n        )\n      )\n    );\n  }\n\n  onScaleChanging() {\n    if (!this.parent) {\n      return;\n    }\n    this.#updateBbox(\n      this.#drawOutlines.updateParentDimensions(\n        this.parentDimensions,\n        this.parent.scale\n      )\n    );\n  }\n\n  static onScaleChangingWhenDrawing() {}\n\n  /** @inheritdoc */\n  render() {\n    if (this.div) {\n      return this.div;\n    }\n\n    let baseX, baseY;\n    if (this._isCopy) {\n      baseX = this.x;\n      baseY = this.y;\n    }\n\n    const div = super.render();\n    div.classList.add(\"draw\");\n\n    const drawDiv = document.createElement(\"div\");\n    div.append(drawDiv);\n    drawDiv.setAttribute(\"aria-hidden\", \"true\");\n    drawDiv.className = \"internal\";\n    this.setDims();\n    this._uiManager.addShouldRescale(this);\n    this.disableEditing();\n\n    if (this._isCopy) {\n      this._moveAfterPaste(baseX, baseY);\n    }\n\n    return div;\n  }\n\n  /**\n   * Create a new drawer instance.\n   * @param {number} x - The x coordinate of the event.\n   * @param {number} y - The y coordinate of the event.\n   * @param {number} parentWidth - The parent width.\n   * @param {number} parentHeight - The parent height.\n   * @param {number} rotation - The parent rotation.\n   */\n  static createDrawerInstance(_x, _y, _parentWidth, _parentHeight, _rotation) {\n    unreachable(\"Not implemented\");\n  }\n\n  static startDrawing(parent, uiManager, _isLTR, event) {\n    // The pointerType of CurrentPointer is set when the user starts an empty\n    // drawing session. If, in the same drawing session, the user starts using a\n    // different type of pointer (e.g. a pen and then a finger), we just return.\n    //\n    // If the user starts to draw with a finger and then uses a second finger,\n    // we just stop the current drawing and let the user zoom the document.\n\n    const { target, offsetX: x, offsetY: y, pointerId, pointerType } = event;\n    if (CurrentPointers.isInitializedAndDifferentPointerType(pointerType)) {\n      return;\n    }\n\n    const {\n      viewport: { rotation },\n    } = parent;\n    const { width: parentWidth, height: parentHeight } =\n      target.getBoundingClientRect();\n\n    const ac = (DrawingEditor.#currentDrawingAC = new AbortController());\n    const signal = parent.combinedSignal(ac);\n\n    CurrentPointers.setPointer(pointerType, pointerId);\n\n    window.addEventListener(\n      \"pointerup\",\n      e => {\n        if (CurrentPointers.isSamePointerIdOrRemove(e.pointerId)) {\n          this._endDraw(e);\n        }\n      },\n      { signal }\n    );\n    window.addEventListener(\n      \"pointercancel\",\n      e => {\n        if (CurrentPointers.isSamePointerIdOrRemove(e.pointerId)) {\n          this._currentParent.endDrawingSession();\n        }\n      },\n      { signal }\n    );\n    window.addEventListener(\n      \"pointerdown\",\n      e => {\n        if (!CurrentPointers.isSamePointerType(e.pointerType)) {\n          // For example, we started with a pen and the user\n          // is now using a finger.\n          return;\n        }\n\n        // For example, the user is using a second finger.\n        CurrentPointers.initializeAndAddPointerId(e.pointerId);\n\n        // The first finger created a first point and a second finger just\n        // started, so we stop the drawing and remove this only point.\n        if (DrawingEditor.#currentDraw.isCancellable()) {\n          DrawingEditor.#currentDraw.removeLastElement();\n          if (DrawingEditor.#currentDraw.isEmpty()) {\n            this._currentParent.endDrawingSession(/* isAborted = */ true);\n          } else {\n            this._endDraw(null);\n          }\n        }\n      },\n      {\n        capture: true,\n        passive: false,\n        signal,\n      }\n    );\n    window.addEventListener(\"contextmenu\", noContextMenu, { signal });\n    target.addEventListener(\"pointermove\", this._drawMove.bind(this), {\n      signal,\n    });\n    target.addEventListener(\n      \"touchmove\",\n      e => {\n        if (CurrentPointers.isSameTimeStamp(e.timeStamp)) {\n          // This move event is used to draw so we don't want to scroll.\n          stopEvent(e);\n        }\n      },\n      { signal }\n    );\n    parent.toggleDrawing();\n    uiManager._editorUndoBar?.hide();\n\n    if (DrawingEditor.#currentDraw) {\n      parent.drawLayer.updateProperties(\n        this._currentDrawId,\n        DrawingEditor.#currentDraw.startNew(\n          x,\n          y,\n          parentWidth,\n          parentHeight,\n          rotation\n        )\n      );\n      return;\n    }\n\n    uiManager.updateUIForDefaultProperties(this);\n\n    DrawingEditor.#currentDraw = this.createDrawerInstance(\n      x,\n      y,\n      parentWidth,\n      parentHeight,\n      rotation\n    );\n    DrawingEditor.#currentDrawingOptions = this.getDefaultDrawingOptions();\n    this._currentParent = parent;\n\n    ({ id: this._currentDrawId } = parent.drawLayer.draw(\n      this._mergeSVGProperties(\n        DrawingEditor.#currentDrawingOptions.toSVGProperties(),\n        DrawingEditor.#currentDraw.defaultSVGProperties\n      ),\n      /* isPathUpdatable = */ true,\n      /* hasClip = */ false\n    ));\n  }\n\n  static _drawMove(event) {\n    CurrentPointers.isSameTimeStamp(event.timeStamp);\n    if (!DrawingEditor.#currentDraw) {\n      return;\n    }\n    const { offsetX, offsetY, pointerId } = event;\n\n    if (!CurrentPointers.isSamePointerId(pointerId)) {\n      return;\n    }\n    if (CurrentPointers.isUsingMultiplePointers()) {\n      // The user is using multiple fingers and the first one is moving.\n      this._endDraw(event);\n      return;\n    }\n    this._currentParent.drawLayer.updateProperties(\n      this._currentDrawId,\n      DrawingEditor.#currentDraw.add(offsetX, offsetY)\n    );\n    // We track the timestamp to know if the touchmove event is used to draw.\n    CurrentPointers.setTimeStamp(event.timeStamp);\n    stopEvent(event);\n  }\n\n  static _cleanup(all) {\n    if (all) {\n      this._currentDrawId = -1;\n      this._currentParent = null;\n      DrawingEditor.#currentDraw = null;\n      DrawingEditor.#currentDrawingOptions = null;\n      CurrentPointers.clearTimeStamp();\n    }\n\n    if (DrawingEditor.#currentDrawingAC) {\n      DrawingEditor.#currentDrawingAC.abort();\n      DrawingEditor.#currentDrawingAC = null;\n      CurrentPointers.clearPointerIds();\n    }\n  }\n\n  static _endDraw(event) {\n    const parent = this._currentParent;\n    if (!parent) {\n      return;\n    }\n\n    parent.toggleDrawing(true);\n    this._cleanup(false);\n\n    if (event?.target === parent.div) {\n      parent.drawLayer.updateProperties(\n        this._currentDrawId,\n        DrawingEditor.#currentDraw.end(event.offsetX, event.offsetY)\n      );\n    }\n    if (this.supportMultipleDrawings) {\n      const draw = DrawingEditor.#currentDraw;\n      const drawId = this._currentDrawId;\n      const lastElement = draw.getLastElement();\n      parent.addCommands({\n        cmd: () => {\n          parent.drawLayer.updateProperties(\n            drawId,\n            draw.setLastElement(lastElement)\n          );\n        },\n        undo: () => {\n          parent.drawLayer.updateProperties(drawId, draw.removeLastElement());\n        },\n        mustExec: false,\n        type: AnnotationEditorParamsType.DRAW_STEP,\n      });\n\n      return;\n    }\n\n    this.endDrawing(/* isAborted = */ false);\n  }\n\n  static endDrawing(isAborted) {\n    const parent = this._currentParent;\n    if (!parent) {\n      return null;\n    }\n    parent.toggleDrawing(true);\n    parent.cleanUndoStack(AnnotationEditorParamsType.DRAW_STEP);\n\n    if (!DrawingEditor.#currentDraw.isEmpty()) {\n      const {\n        pageDimensions: [pageWidth, pageHeight],\n        scale,\n      } = parent;\n\n      const editor = parent.createAndAddNewEditor(\n        { offsetX: 0, offsetY: 0 },\n        false,\n        {\n          drawId: this._currentDrawId,\n          drawOutlines: DrawingEditor.#currentDraw.getOutlines(\n            pageWidth * scale,\n            pageHeight * scale,\n            scale,\n            this._INNER_MARGIN\n          ),\n          drawingOptions: DrawingEditor.#currentDrawingOptions,\n          mustBeCommitted: !isAborted,\n        }\n      );\n      this._cleanup(true);\n      return editor;\n    }\n\n    parent.drawLayer.remove(this._currentDrawId);\n    this._cleanup(true);\n    return null;\n  }\n\n  /**\n   * Create the drawing options.\n   * @param {Object} _data\n   */\n  createDrawingOptions(_data) {}\n\n  /**\n   * Deserialize the drawing outlines.\n   * @param {number} pageX - The x coordinate of the page.\n   * @param {number} pageY - The y coordinate of the page.\n   * @param {number} pageWidth - The width of the page.\n   * @param {number} pageHeight - The height of the page.\n   * @param {number} innerWidth - The inner width.\n   * @param {Object} data - The data to deserialize.\n   * @returns {Object} The deserialized outlines.\n   */\n  static deserializeDraw(\n    _pageX,\n    _pageY,\n    _pageWidth,\n    _pageHeight,\n    _innerWidth,\n    _data\n  ) {\n    unreachable(\"Not implemented\");\n  }\n\n  /** @inheritdoc */\n  static async deserialize(data, parent, uiManager) {\n    const {\n      rawDims: { pageWidth, pageHeight, pageX, pageY },\n    } = parent.viewport;\n    const drawOutlines = this.deserializeDraw(\n      pageX,\n      pageY,\n      pageWidth,\n      pageHeight,\n      this._INNER_MARGIN,\n      data\n    );\n    const editor = await super.deserialize(data, parent, uiManager);\n    editor.createDrawingOptions(data);\n    editor.#createDrawOutlines({ drawOutlines });\n    editor.#addToDrawLayer();\n    editor.onScaleChanging();\n    editor.rotate();\n\n    return editor;\n  }\n\n  serializeDraw(isForCopying) {\n    const [pageX, pageY] = this.pageTranslation;\n    const [pageWidth, pageHeight] = this.pageDimensions;\n    return this.#drawOutlines.serialize(\n      [pageX, pageY, pageWidth, pageHeight],\n      isForCopying\n    );\n  }\n\n  /** @inheritdoc */\n  renderAnnotationElement(annotation) {\n    annotation.updateEdited({\n      rect: this.getPDFRect(),\n    });\n\n    return null;\n  }\n\n  static canCreateNewEmptyEditor() {\n    return false;\n  }\n}\n\nexport { DrawingEditor, DrawingOptions };\n","/* Copyright 2024 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MathClamp, Util } from \"../../../shared/util.js\";\nimport { Outline } from \"./outline.js\";\n\nclass InkDrawOutliner {\n  // The last 3 points of the line.\n  #last = new Float64Array(6);\n\n  #line;\n\n  #lines;\n\n  #rotation;\n\n  #thickness;\n\n  #points;\n\n  #lastSVGPath = \"\";\n\n  #lastIndex = 0;\n\n  #outlines = new InkDrawOutline();\n\n  #parentWidth;\n\n  #parentHeight;\n\n  constructor(x, y, parentWidth, parentHeight, rotation, thickness) {\n    this.#parentWidth = parentWidth;\n    this.#parentHeight = parentHeight;\n    this.#rotation = rotation;\n    this.#thickness = thickness;\n\n    [x, y] = this.#normalizePoint(x, y);\n\n    const line = (this.#line = [NaN, NaN, NaN, NaN, x, y]);\n    this.#points = [x, y];\n    this.#lines = [{ line, points: this.#points }];\n    this.#last.set(line, 0);\n  }\n\n  updateProperty(name, value) {\n    if (name === \"stroke-width\") {\n      this.#thickness = value;\n    }\n  }\n\n  #normalizePoint(x, y) {\n    return Outline._normalizePoint(\n      x,\n      y,\n      this.#parentWidth,\n      this.#parentHeight,\n      this.#rotation\n    );\n  }\n\n  isEmpty() {\n    return !this.#lines || this.#lines.length === 0;\n  }\n\n  isCancellable() {\n    // The user a second finger after drawing 5 points: it's small enough\n    // to not be a real drawing.\n    return this.#points.length <= 10;\n  }\n\n  add(x, y) {\n    // The point is in canvas coordinates which means that there is no rotation.\n    // It's the same as parent coordinates.\n    [x, y] = this.#normalizePoint(x, y);\n    const [x1, y1, x2, y2] = this.#last.subarray(2, 6);\n    const diffX = x - x2;\n    const diffY = y - y2;\n    const d = Math.hypot(this.#parentWidth * diffX, this.#parentHeight * diffY);\n    if (d <= 2) {\n      // The idea is to avoid garbage points around the last point.\n      // When the points are too close, it just leads to bad normal vectors and\n      // control points.\n      return null;\n    }\n\n    this.#points.push(x, y);\n\n    if (isNaN(x1)) {\n      // We've only one point.\n      this.#last.set([x2, y2, x, y], 2);\n      this.#line.push(NaN, NaN, NaN, NaN, x, y);\n      return {\n        path: {\n          d: this.toSVGPath(),\n        },\n      };\n    }\n\n    if (isNaN(this.#last[0])) {\n      // We've only two points.\n      this.#line.splice(6, 6);\n    }\n\n    this.#last.set([x1, y1, x2, y2, x, y], 0);\n    this.#line.push(...Outline.createBezierPoints(x1, y1, x2, y2, x, y));\n\n    return {\n      path: {\n        d: this.toSVGPath(),\n      },\n    };\n  }\n\n  end(x, y) {\n    const change = this.add(x, y);\n    if (change) {\n      return change;\n    }\n    if (this.#points.length === 2) {\n      // We've only one point.\n      return {\n        path: {\n          d: this.toSVGPath(),\n        },\n      };\n    }\n    return null;\n  }\n\n  startNew(x, y, parentWidth, parentHeight, rotation) {\n    this.#parentWidth = parentWidth;\n    this.#parentHeight = parentHeight;\n    this.#rotation = rotation;\n\n    [x, y] = this.#normalizePoint(x, y);\n\n    const line = (this.#line = [NaN, NaN, NaN, NaN, x, y]);\n    this.#points = [x, y];\n    const last = this.#lines.at(-1);\n    if (last) {\n      last.line = new Float32Array(last.line);\n      last.points = new Float32Array(last.points);\n    }\n    this.#lines.push({ line, points: this.#points });\n    this.#last.set(line, 0);\n    this.#lastIndex = 0;\n    this.toSVGPath();\n\n    return null;\n  }\n\n  getLastElement() {\n    return this.#lines.at(-1);\n  }\n\n  setLastElement(element) {\n    if (!this.#lines) {\n      return this.#outlines.setLastElement(element);\n    }\n    this.#lines.push(element);\n    this.#line = element.line;\n    this.#points = element.points;\n    this.#lastIndex = 0;\n    return {\n      path: {\n        d: this.toSVGPath(),\n      },\n    };\n  }\n\n  removeLastElement() {\n    if (!this.#lines) {\n      return this.#outlines.removeLastElement();\n    }\n    this.#lines.pop();\n    this.#lastSVGPath = \"\";\n    for (let i = 0, ii = this.#lines.length; i < ii; i++) {\n      const { line, points } = this.#lines[i];\n      this.#line = line;\n      this.#points = points;\n      this.#lastIndex = 0;\n      this.toSVGPath();\n    }\n\n    return {\n      path: {\n        d: this.#lastSVGPath,\n      },\n    };\n  }\n\n  toSVGPath() {\n    const firstX = Outline.svgRound(this.#line[4]);\n    const firstY = Outline.svgRound(this.#line[5]);\n    if (this.#points.length === 2) {\n      this.#lastSVGPath = `${this.#lastSVGPath} M ${firstX} ${firstY} Z`;\n      return this.#lastSVGPath;\n    }\n\n    if (this.#points.length <= 6) {\n      // We've 2 or 3 points.\n      const i = this.#lastSVGPath.lastIndexOf(\"M\");\n      this.#lastSVGPath = `${this.#lastSVGPath.slice(0, i)} M ${firstX} ${firstY}`;\n      this.#lastIndex = 6;\n    }\n\n    if (this.#points.length === 4) {\n      const secondX = Outline.svgRound(this.#line[10]);\n      const secondY = Outline.svgRound(this.#line[11]);\n      this.#lastSVGPath = `${this.#lastSVGPath} L ${secondX} ${secondY}`;\n      this.#lastIndex = 12;\n      return this.#lastSVGPath;\n    }\n\n    const buffer = [];\n    if (this.#lastIndex === 0) {\n      buffer.push(`M ${firstX} ${firstY}`);\n      this.#lastIndex = 6;\n    }\n\n    for (let i = this.#lastIndex, ii = this.#line.length; i < ii; i += 6) {\n      const [c1x, c1y, c2x, c2y, x, y] = this.#line\n        .slice(i, i + 6)\n        .map(Outline.svgRound);\n      buffer.push(`C${c1x} ${c1y} ${c2x} ${c2y} ${x} ${y}`);\n    }\n    this.#lastSVGPath += buffer.join(\" \");\n    this.#lastIndex = this.#line.length;\n\n    return this.#lastSVGPath;\n  }\n\n  getOutlines(parentWidth, parentHeight, scale, innerMargin) {\n    const last = this.#lines.at(-1);\n    last.line = new Float32Array(last.line);\n    last.points = new Float32Array(last.points);\n\n    this.#outlines.build(\n      this.#lines,\n      parentWidth,\n      parentHeight,\n      scale,\n      this.#rotation,\n      this.#thickness,\n      innerMargin\n    );\n\n    // We reset everything: the drawing is done.\n    this.#last = null;\n    this.#line = null;\n    this.#lines = null;\n    this.#lastSVGPath = null;\n\n    return this.#outlines;\n  }\n\n  get defaultSVGProperties() {\n    return {\n      root: {\n        viewBox: \"0 0 10000 10000\",\n      },\n      rootClass: {\n        draw: true,\n      },\n      bbox: [0, 0, 1, 1],\n    };\n  }\n}\n\nclass InkDrawOutline extends Outline {\n  #bbox;\n\n  #currentRotation = 0;\n\n  #innerMargin;\n\n  #lines;\n\n  #parentWidth;\n\n  #parentHeight;\n\n  #parentScale;\n\n  #rotation;\n\n  #thickness;\n\n  build(\n    lines,\n    parentWidth,\n    parentHeight,\n    parentScale,\n    rotation,\n    thickness,\n    innerMargin\n  ) {\n    this.#parentWidth = parentWidth;\n    this.#parentHeight = parentHeight;\n    this.#parentScale = parentScale;\n    this.#rotation = rotation;\n    this.#thickness = thickness;\n    this.#innerMargin = innerMargin ?? 0;\n    this.#lines = lines;\n\n    this.#computeBbox();\n  }\n\n  get thickness() {\n    return this.#thickness;\n  }\n\n  setLastElement(element) {\n    this.#lines.push(element);\n    return {\n      path: {\n        d: this.toSVGPath(),\n      },\n    };\n  }\n\n  removeLastElement() {\n    this.#lines.pop();\n    return {\n      path: {\n        d: this.toSVGPath(),\n      },\n    };\n  }\n\n  toSVGPath() {\n    const buffer = [];\n    for (const { line } of this.#lines) {\n      buffer.push(`M${Outline.svgRound(line[4])} ${Outline.svgRound(line[5])}`);\n      if (line.length === 6) {\n        buffer.push(\"Z\");\n        continue;\n      }\n      if (line.length === 12 && isNaN(line[6])) {\n        buffer.push(\n          `L${Outline.svgRound(line[10])} ${Outline.svgRound(line[11])}`\n        );\n        continue;\n      }\n      for (let i = 6, ii = line.length; i < ii; i += 6) {\n        const [c1x, c1y, c2x, c2y, x, y] = line\n          .subarray(i, i + 6)\n          .map(Outline.svgRound);\n        buffer.push(`C${c1x} ${c1y} ${c2x} ${c2y} ${x} ${y}`);\n      }\n    }\n    return buffer.join(\"\");\n  }\n\n  serialize([pageX, pageY, pageWidth, pageHeight], isForCopying) {\n    const serializedLines = [];\n    const serializedPoints = [];\n    const [x, y, width, height] = this.#getBBoxWithNoMargin();\n    let tx, ty, sx, sy, x1, y1, x2, y2, rescaleFn;\n\n    switch (this.#rotation) {\n      case 0:\n        rescaleFn = Outline._rescale;\n        tx = pageX;\n        ty = pageY + pageHeight;\n        sx = pageWidth;\n        sy = -pageHeight;\n        x1 = pageX + x * pageWidth;\n        y1 = pageY + (1 - y - height) * pageHeight;\n        x2 = pageX + (x + width) * pageWidth;\n        y2 = pageY + (1 - y) * pageHeight;\n        break;\n      case 90:\n        rescaleFn = Outline._rescaleAndSwap;\n        tx = pageX;\n        ty = pageY;\n        sx = pageWidth;\n        sy = pageHeight;\n        x1 = pageX + y * pageWidth;\n        y1 = pageY + x * pageHeight;\n        x2 = pageX + (y + height) * pageWidth;\n        y2 = pageY + (x + width) * pageHeight;\n        break;\n      case 180:\n        rescaleFn = Outline._rescale;\n        tx = pageX + pageWidth;\n        ty = pageY;\n        sx = -pageWidth;\n        sy = pageHeight;\n        x1 = pageX + (1 - x - width) * pageWidth;\n        y1 = pageY + y * pageHeight;\n        x2 = pageX + (1 - x) * pageWidth;\n        y2 = pageY + (y + height) * pageHeight;\n        break;\n      case 270:\n        rescaleFn = Outline._rescaleAndSwap;\n        tx = pageX + pageWidth;\n        ty = pageY + pageHeight;\n        sx = -pageWidth;\n        sy = -pageHeight;\n        x1 = pageX + (1 - y - height) * pageWidth;\n        y1 = pageY + (1 - x - width) * pageHeight;\n        x2 = pageX + (1 - y) * pageWidth;\n        y2 = pageY + (1 - x) * pageHeight;\n        break;\n    }\n\n    for (const { line, points } of this.#lines) {\n      serializedLines.push(\n        rescaleFn(\n          line,\n          tx,\n          ty,\n          sx,\n          sy,\n          isForCopying ? new Array(line.length) : null\n        )\n      );\n      serializedPoints.push(\n        rescaleFn(\n          points,\n          tx,\n          ty,\n          sx,\n          sy,\n          isForCopying ? new Array(points.length) : null\n        )\n      );\n    }\n\n    return {\n      lines: serializedLines,\n      points: serializedPoints,\n      rect: [x1, y1, x2, y2],\n    };\n  }\n\n  static deserialize(\n    pageX,\n    pageY,\n    pageWidth,\n    pageHeight,\n    innerMargin,\n    { paths: { lines, points }, rotation, thickness }\n  ) {\n    const newLines = [];\n    let tx, ty, sx, sy, rescaleFn;\n    switch (rotation) {\n      case 0:\n        rescaleFn = Outline._rescale;\n        tx = -pageX / pageWidth;\n        ty = pageY / pageHeight + 1;\n        sx = 1 / pageWidth;\n        sy = -1 / pageHeight;\n        break;\n      case 90:\n        rescaleFn = Outline._rescaleAndSwap;\n        tx = -pageY / pageHeight;\n        ty = -pageX / pageWidth;\n        sx = 1 / pageHeight;\n        sy = 1 / pageWidth;\n        break;\n      case 180:\n        rescaleFn = Outline._rescale;\n        tx = pageX / pageWidth + 1;\n        ty = -pageY / pageHeight;\n        sx = -1 / pageWidth;\n        sy = 1 / pageHeight;\n        break;\n      case 270:\n        rescaleFn = Outline._rescaleAndSwap;\n        tx = pageY / pageHeight + 1;\n        ty = pageX / pageWidth + 1;\n        sx = -1 / pageHeight;\n        sy = -1 / pageWidth;\n        break;\n    }\n\n    if (!lines) {\n      lines = [];\n      for (const point of points) {\n        const len = point.length;\n        if (len === 2) {\n          lines.push(\n            new Float32Array([NaN, NaN, NaN, NaN, point[0], point[1]])\n          );\n          continue;\n        }\n        if (len === 4) {\n          lines.push(\n            new Float32Array([\n              NaN,\n              NaN,\n              NaN,\n              NaN,\n              point[0],\n              point[1],\n              NaN,\n              NaN,\n              NaN,\n              NaN,\n              point[2],\n              point[3],\n            ])\n          );\n          continue;\n        }\n        const line = new Float32Array(3 * (len - 2));\n        lines.push(line);\n        let [x1, y1, x2, y2] = point.subarray(0, 4);\n        line.set([NaN, NaN, NaN, NaN, x1, y1], 0);\n        for (let i = 4; i < len; i += 2) {\n          const x = point[i];\n          const y = point[i + 1];\n          line.set(\n            Outline.createBezierPoints(x1, y1, x2, y2, x, y),\n            (i - 2) * 3\n          );\n          [x1, y1, x2, y2] = [x2, y2, x, y];\n        }\n      }\n    }\n\n    for (let i = 0, ii = lines.length; i < ii; i++) {\n      newLines.push({\n        line: rescaleFn(\n          lines[i].map(x => x ?? NaN),\n          tx,\n          ty,\n          sx,\n          sy\n        ),\n        points: rescaleFn(\n          points[i].map(x => x ?? NaN),\n          tx,\n          ty,\n          sx,\n          sy\n        ),\n      });\n    }\n\n    const outlines = new this.prototype.constructor();\n    outlines.build(\n      newLines,\n      pageWidth,\n      pageHeight,\n      1,\n      rotation,\n      thickness,\n      innerMargin\n    );\n\n    return outlines;\n  }\n\n  #getMarginComponents(thickness = this.#thickness) {\n    const margin = this.#innerMargin + (thickness / 2) * this.#parentScale;\n    return this.#rotation % 180 === 0\n      ? [margin / this.#parentWidth, margin / this.#parentHeight]\n      : [margin / this.#parentHeight, margin / this.#parentWidth];\n  }\n\n  #getBBoxWithNoMargin() {\n    const [x, y, width, height] = this.#bbox;\n    const [marginX, marginY] = this.#getMarginComponents(0);\n\n    return [\n      x + marginX,\n      y + marginY,\n      width - 2 * marginX,\n      height - 2 * marginY,\n    ];\n  }\n\n  #computeBbox() {\n    const bbox = (this.#bbox = new Float32Array([\n      Infinity,\n      Infinity,\n      -Infinity,\n      -Infinity,\n    ]));\n\n    for (const { line } of this.#lines) {\n      if (line.length <= 12) {\n        // We've only one or two points => no bezier curve.\n        for (let i = 4, ii = line.length; i < ii; i += 6) {\n          Util.pointBoundingBox(line[i], line[i + 1], bbox);\n        }\n        continue;\n      }\n      let lastX = line[4],\n        lastY = line[5];\n      for (let i = 6, ii = line.length; i < ii; i += 6) {\n        const [c1x, c1y, c2x, c2y, x, y] = line.subarray(i, i + 6);\n        Util.bezierBoundingBox(lastX, lastY, c1x, c1y, c2x, c2y, x, y, bbox);\n        lastX = x;\n        lastY = y;\n      }\n    }\n\n    const [marginX, marginY] = this.#getMarginComponents();\n    bbox[0] = MathClamp(bbox[0] - marginX, 0, 1);\n    bbox[1] = MathClamp(bbox[1] - marginY, 0, 1);\n    bbox[2] = MathClamp(bbox[2] + marginX, 0, 1);\n    bbox[3] = MathClamp(bbox[3] + marginY, 0, 1);\n\n    bbox[2] -= bbox[0];\n    bbox[3] -= bbox[1];\n  }\n\n  get box() {\n    return this.#bbox;\n  }\n\n  updateProperty(name, value) {\n    if (name === \"stroke-width\") {\n      return this.#updateThickness(value);\n    }\n    return null;\n  }\n\n  #updateThickness(thickness) {\n    const [oldMarginX, oldMarginY] = this.#getMarginComponents();\n    this.#thickness = thickness;\n    const [newMarginX, newMarginY] = this.#getMarginComponents();\n    const [diffMarginX, diffMarginY] = [\n      newMarginX - oldMarginX,\n      newMarginY - oldMarginY,\n    ];\n    const bbox = this.#bbox;\n    bbox[0] -= diffMarginX;\n    bbox[1] -= diffMarginY;\n    bbox[2] += 2 * diffMarginX;\n    bbox[3] += 2 * diffMarginY;\n\n    return bbox;\n  }\n\n  updateParentDimensions([width, height], scale) {\n    const [oldMarginX, oldMarginY] = this.#getMarginComponents();\n    this.#parentWidth = width;\n    this.#parentHeight = height;\n    this.#parentScale = scale;\n    const [newMarginX, newMarginY] = this.#getMarginComponents();\n    const diffMarginX = newMarginX - oldMarginX;\n    const diffMarginY = newMarginY - oldMarginY;\n\n    const bbox = this.#bbox;\n    bbox[0] -= diffMarginX;\n    bbox[1] -= diffMarginY;\n    bbox[2] += 2 * diffMarginX;\n    bbox[3] += 2 * diffMarginY;\n\n    return bbox;\n  }\n\n  updateRotation(rotation) {\n    this.#currentRotation = rotation;\n    return {\n      path: {\n        transform: this.rotationTransform,\n      },\n    };\n  }\n\n  get viewBox() {\n    return this.#bbox.map(Outline.svgRound).join(\" \");\n  }\n\n  get defaultProperties() {\n    const [x, y] = this.#bbox;\n    return {\n      root: {\n        viewBox: this.viewBox,\n      },\n      path: {\n        \"transform-origin\": `${Outline.svgRound(x)} ${Outline.svgRound(y)}`,\n      },\n    };\n  }\n\n  get rotationTransform() {\n    const [, , width, height] = this.#bbox;\n    let a = 0,\n      b = 0,\n      c = 0,\n      d = 0,\n      e = 0,\n      f = 0;\n    switch (this.#currentRotation) {\n      case 90:\n        b = height / width;\n        c = -width / height;\n        e = width;\n        break;\n      case 180:\n        a = -1;\n        d = -1;\n        e = width;\n        f = height;\n        break;\n      case 270:\n        b = -height / width;\n        c = width / height;\n        f = height;\n        break;\n      default:\n        return \"\";\n    }\n    return `matrix(${a} ${b} ${c} ${d} ${Outline.svgRound(e)} ${Outline.svgRound(f)})`;\n  }\n\n  getPathResizingSVGProperties([newX, newY, newWidth, newHeight]) {\n    const [marginX, marginY] = this.#getMarginComponents();\n    const [x, y, width, height] = this.#bbox;\n\n    if (\n      Math.abs(width - marginX) <= Outline.PRECISION ||\n      Math.abs(height - marginY) <= Outline.PRECISION\n    ) {\n      // Center the path in the new bounding box.\n      const tx = newX + newWidth / 2 - (x + width / 2);\n      const ty = newY + newHeight / 2 - (y + height / 2);\n      return {\n        path: {\n          \"transform-origin\": `${Outline.svgRound(newX)} ${Outline.svgRound(newY)}`,\n          transform: `${this.rotationTransform} translate(${tx} ${ty})`,\n        },\n      };\n    }\n\n    // We compute the following transform:\n    //  1. Translate the path to the origin (-marginX, -marginY).\n    //  2. Scale the path to the new size:\n    //   ((newWidth - 2*marginX) / (bbox.width - 2*marginX),\n    //   (newHeight - 2*marginY) / (bbox.height - 2*marginY)).\n    //  3. Translate the path back to its original position\n    //   (marginX, marginY).\n    //  4. Scale the inverse of bbox scaling:\n    //   (bbox.width / newWidth, bbox.height / newHeight).\n\n    const s1x = (newWidth - 2 * marginX) / (width - 2 * marginX);\n    const s1y = (newHeight - 2 * marginY) / (height - 2 * marginY);\n    const s2x = width / newWidth;\n    const s2y = height / newHeight;\n\n    return {\n      path: {\n        \"transform-origin\": `${Outline.svgRound(x)} ${Outline.svgRound(y)}`,\n        transform:\n          `${this.rotationTransform} scale(${s2x} ${s2y}) ` +\n          `translate(${Outline.svgRound(marginX)} ${Outline.svgRound(marginY)}) scale(${s1x} ${s1y}) ` +\n          `translate(${Outline.svgRound(-marginX)} ${Outline.svgRound(-marginY)})`,\n      },\n    };\n  }\n\n  getPathResizedSVGProperties([newX, newY, newWidth, newHeight]) {\n    const [marginX, marginY] = this.#getMarginComponents();\n    const bbox = this.#bbox;\n    const [x, y, width, height] = bbox;\n\n    bbox[0] = newX;\n    bbox[1] = newY;\n    bbox[2] = newWidth;\n    bbox[3] = newHeight;\n\n    if (\n      Math.abs(width - marginX) <= Outline.PRECISION ||\n      Math.abs(height - marginY) <= Outline.PRECISION\n    ) {\n      // Center the path in the new bounding box.\n      const tx = newX + newWidth / 2 - (x + width / 2);\n      const ty = newY + newHeight / 2 - (y + height / 2);\n      for (const { line, points } of this.#lines) {\n        Outline._translate(line, tx, ty, line);\n        Outline._translate(points, tx, ty, points);\n      }\n      return {\n        root: {\n          viewBox: this.viewBox,\n        },\n        path: {\n          \"transform-origin\": `${Outline.svgRound(newX)} ${Outline.svgRound(newY)}`,\n          transform: this.rotationTransform || null,\n          d: this.toSVGPath(),\n        },\n      };\n    }\n\n    // We compute the following transform:\n    //  1. Translate the path to the origin (-(x + marginX), -(y + marginY)).\n    //  2. Scale the path to the new size:\n    //   ((newWidth - 2*marginX) / (bbox.width - 2*marginX),\n    //   (newHeight - 2*marginY) / (bbox.height - 2*marginY)).\n    //  3. Translate the path back to its new position\n    //     (newX + marginX,y newY + marginY).\n\n    const s1x = (newWidth - 2 * marginX) / (width - 2 * marginX);\n    const s1y = (newHeight - 2 * marginY) / (height - 2 * marginY);\n    const tx = -s1x * (x + marginX) + newX + marginX;\n    const ty = -s1y * (y + marginY) + newY + marginY;\n\n    if (s1x !== 1 || s1y !== 1 || tx !== 0 || ty !== 0) {\n      for (const { line, points } of this.#lines) {\n        Outline._rescale(line, tx, ty, s1x, s1y, line);\n        Outline._rescale(points, tx, ty, s1x, s1y, points);\n      }\n    }\n\n    return {\n      root: {\n        viewBox: this.viewBox,\n      },\n      path: {\n        \"transform-origin\": `${Outline.svgRound(newX)} ${Outline.svgRound(newY)}`,\n        transform: this.rotationTransform || null,\n        d: this.toSVGPath(),\n      },\n    };\n  }\n\n  getPathTranslatedSVGProperties([newX, newY], parentDimensions) {\n    const [newParentWidth, newParentHeight] = parentDimensions;\n    const bbox = this.#bbox;\n    const tx = newX - bbox[0];\n    const ty = newY - bbox[1];\n\n    if (\n      this.#parentWidth === newParentWidth &&\n      this.#parentHeight === newParentHeight\n    ) {\n      // We don't change the parent dimensions so it's a simple translation.\n      for (const { line, points } of this.#lines) {\n        Outline._translate(line, tx, ty, line);\n        Outline._translate(points, tx, ty, points);\n      }\n    } else {\n      const sx = this.#parentWidth / newParentWidth;\n      const sy = this.#parentHeight / newParentHeight;\n      this.#parentWidth = newParentWidth;\n      this.#parentHeight = newParentHeight;\n\n      for (const { line, points } of this.#lines) {\n        Outline._rescale(line, tx, ty, sx, sy, line);\n        Outline._rescale(points, tx, ty, sx, sy, points);\n      }\n      bbox[2] *= sx;\n      bbox[3] *= sy;\n    }\n    bbox[0] = newX;\n    bbox[1] = newY;\n\n    return {\n      root: {\n        viewBox: this.viewBox,\n      },\n      path: {\n        d: this.toSVGPath(),\n        \"transform-origin\": `${Outline.svgRound(newX)} ${Outline.svgRound(newY)}`,\n      },\n    };\n  }\n\n  get defaultSVGProperties() {\n    const bbox = this.#bbox;\n    return {\n      root: {\n        viewBox: this.viewBox,\n      },\n      rootClass: {\n        draw: true,\n      },\n      path: {\n        d: this.toSVGPath(),\n        \"transform-origin\": `${Outline.svgRound(bbox[0])} ${Outline.svgRound(bbox[1])}`,\n        transform: this.rotationTransform || null,\n      },\n      bbox,\n    };\n  }\n}\n\nexport { InkDrawOutline, InkDrawOutliner };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n  AnnotationEditorParamsType,\n  AnnotationEditorType,\n  shadow,\n  Util,\n} from \"../../shared/util.js\";\nimport { DrawingEditor, DrawingOptions } from \"./draw.js\";\nimport { InkDrawOutline, InkDrawOutliner } from \"./drawers/inkdraw.js\";\nimport { AnnotationEditor } from \"./editor.js\";\nimport { BasicColorPicker } from \"./color_picker.js\";\nimport { InkAnnotationElement } from \"../annotation_layer.js\";\n\nclass InkDrawingOptions extends DrawingOptions {\n  constructor(viewerParameters) {\n    super();\n    this._viewParameters = viewerParameters;\n\n    super.updateProperties({\n      fill: \"none\",\n      stroke: AnnotationEditor._defaultLineColor,\n      \"stroke-opacity\": 1,\n      \"stroke-width\": 1,\n      \"stroke-linecap\": \"round\",\n      \"stroke-linejoin\": \"round\",\n      \"stroke-miterlimit\": 10,\n    });\n  }\n\n  updateSVGProperty(name, value) {\n    if (name === \"stroke-width\") {\n      value ??= this[\"stroke-width\"];\n      value *= this._viewParameters.realScale;\n    }\n    super.updateSVGProperty(name, value);\n  }\n\n  clone() {\n    const clone = new InkDrawingOptions(this._viewParameters);\n    clone.updateAll(this);\n    return clone;\n  }\n}\n\n/**\n * Basic draw editor in order to generate an Ink annotation.\n */\nclass InkEditor extends DrawingEditor {\n  static _type = \"ink\";\n\n  static _editorType = AnnotationEditorType.INK;\n\n  static _defaultDrawingOptions = null;\n\n  constructor(params) {\n    super({ ...params, name: \"inkEditor\" });\n    this._willKeepAspectRatio = true;\n    this.defaultL10nId = \"pdfjs-editor-ink-editor\";\n  }\n\n  /** @inheritdoc */\n  static initialize(l10n, uiManager) {\n    AnnotationEditor.initialize(l10n, uiManager);\n    this._defaultDrawingOptions = new InkDrawingOptions(\n      uiManager.viewParameters\n    );\n  }\n\n  /** @inheritdoc */\n  static getDefaultDrawingOptions(options) {\n    const clone = this._defaultDrawingOptions.clone();\n    clone.updateProperties(options);\n    return clone;\n  }\n\n  /** @inheritdoc */\n  static get supportMultipleDrawings() {\n    return true;\n  }\n\n  /** @inheritdoc */\n  static get typesMap() {\n    return shadow(\n      this,\n      \"typesMap\",\n      new Map([\n        [AnnotationEditorParamsType.INK_THICKNESS, \"stroke-width\"],\n        [AnnotationEditorParamsType.INK_COLOR, \"stroke\"],\n        [AnnotationEditorParamsType.INK_OPACITY, \"stroke-opacity\"],\n      ])\n    );\n  }\n\n  /** @inheritdoc */\n  static createDrawerInstance(x, y, parentWidth, parentHeight, rotation) {\n    return new InkDrawOutliner(\n      x,\n      y,\n      parentWidth,\n      parentHeight,\n      rotation,\n      this._defaultDrawingOptions[\"stroke-width\"]\n    );\n  }\n\n  /** @inheritdoc */\n  static deserializeDraw(\n    pageX,\n    pageY,\n    pageWidth,\n    pageHeight,\n    innerMargin,\n    data\n  ) {\n    return InkDrawOutline.deserialize(\n      pageX,\n      pageY,\n      pageWidth,\n      pageHeight,\n      innerMargin,\n      data\n    );\n  }\n\n  /** @inheritdoc */\n  static async deserialize(data, parent, uiManager) {\n    let initialData = null;\n    if (data instanceof InkAnnotationElement) {\n      const {\n        data: {\n          inkLists,\n          rect,\n          rotation,\n          id,\n          color,\n          opacity,\n          borderStyle: { rawWidth: thickness },\n          popupRef,\n          richText,\n          contentsObj,\n          creationDate,\n          modificationDate,\n        },\n        parent: {\n          page: { pageNumber },\n        },\n      } = data;\n      initialData = data = {\n        annotationType: AnnotationEditorType.INK,\n        color: Array.from(color),\n        thickness,\n        opacity,\n        paths: { points: inkLists },\n        boxes: null,\n        pageIndex: pageNumber - 1,\n        rect: rect.slice(0),\n        rotation,\n        annotationElementId: id,\n        id,\n        deleted: false,\n        popupRef,\n        richText,\n        comment: contentsObj?.str || null,\n        creationDate,\n        modificationDate,\n      };\n    }\n\n    const editor = await super.deserialize(data, parent, uiManager);\n    editor._initialData = initialData;\n    if (data.comment) {\n      editor.setCommentData(data);\n    }\n\n    return editor;\n  }\n\n  /** @inheritdoc */\n  get toolbarButtons() {\n    this._colorPicker ||= new BasicColorPicker(this);\n    return [[\"colorPicker\", this._colorPicker]];\n  }\n\n  get colorType() {\n    return AnnotationEditorParamsType.INK_COLOR;\n  }\n\n  get color() {\n    return this._drawingOptions.stroke;\n  }\n\n  get opacity() {\n    return this._drawingOptions[\"stroke-opacity\"];\n  }\n\n  /** @inheritdoc */\n  onScaleChanging() {\n    if (!this.parent) {\n      return;\n    }\n    super.onScaleChanging();\n    const { _drawId, _drawingOptions, parent } = this;\n    _drawingOptions.updateSVGProperty(\"stroke-width\");\n    parent.drawLayer.updateProperties(\n      _drawId,\n      _drawingOptions.toSVGProperties()\n    );\n  }\n\n  static onScaleChangingWhenDrawing() {\n    const parent = this._currentParent;\n    if (!parent) {\n      return;\n    }\n    super.onScaleChangingWhenDrawing();\n    this._defaultDrawingOptions.updateSVGProperty(\"stroke-width\");\n    parent.drawLayer.updateProperties(\n      this._currentDrawId,\n      this._defaultDrawingOptions.toSVGProperties()\n    );\n  }\n\n  /** @inheritdoc */\n  createDrawingOptions({ color, thickness, opacity }) {\n    this._drawingOptions = InkEditor.getDefaultDrawingOptions({\n      stroke: Util.makeHexColor(...color),\n      \"stroke-width\": thickness,\n      \"stroke-opacity\": opacity,\n    });\n  }\n\n  /** @inheritdoc */\n  serialize(isForCopying = false) {\n    if (this.isEmpty()) {\n      return null;\n    }\n\n    if (this.deleted) {\n      return this.serializeDeleted();\n    }\n\n    const { lines, points } = this.serializeDraw(isForCopying);\n    const {\n      _drawingOptions: {\n        stroke,\n        \"stroke-opacity\": opacity,\n        \"stroke-width\": thickness,\n      },\n    } = this;\n    const serialized = Object.assign(super.serialize(isForCopying), {\n      color: AnnotationEditor._colorManager.convert(stroke),\n      opacity,\n      thickness,\n      paths: {\n        lines,\n        points,\n      },\n    });\n    this.addComment(serialized);\n\n    if (isForCopying) {\n      serialized.isCopy = true;\n      return serialized;\n    }\n\n    if (this.annotationElementId && !this.#hasElementChanged(serialized)) {\n      return null;\n    }\n\n    serialized.id = this.annotationElementId;\n    return serialized;\n  }\n\n  #hasElementChanged(serialized) {\n    const { color, thickness, opacity, pageIndex } = this._initialData;\n    return (\n      this.hasEditedComment ||\n      this._hasBeenMoved ||\n      this._hasBeenResized ||\n      serialized.color.some((c, i) => c !== color[i]) ||\n      serialized.thickness !== thickness ||\n      serialized.opacity !== opacity ||\n      serialized.pageIndex !== pageIndex\n    );\n  }\n\n  /** @inheritdoc */\n  renderAnnotationElement(annotation) {\n    if (this.deleted) {\n      annotation.hide();\n      return null;\n    }\n    const { points, rect } = this.serializeDraw(/* isForCopying = */ false);\n    annotation.updateEdited({\n      rect,\n      thickness: this._drawingOptions[\"stroke-width\"],\n      points,\n      popup: this.comment,\n    });\n\n    return null;\n  }\n}\n\nexport { InkDrawingOptions, InkEditor };\n","/* Copyright 2024 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { InkDrawOutline } from \"./inkdraw.js\";\n\nclass ContourDrawOutline extends InkDrawOutline {\n  toSVGPath() {\n    let path = super.toSVGPath();\n    if (!path.endsWith(\"Z\")) {\n      path += \"Z\";\n    }\n    return path;\n  }\n}\n\nexport { ContourDrawOutline };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ContourDrawOutline } from \"./contour.js\";\nimport { InkDrawOutline } from \"./inkdraw.js\";\nimport { Outline } from \"./outline.js\";\nimport { warn } from \"../../../shared/util.js\";\n\nconst BASE_HEADER_LENGTH = 8;\nconst POINTS_PROPERTIES_NUMBER = 3;\n\n/**\n * Basic text editor in order to create a Signature annotation.\n */\nclass SignatureExtractor {\n  static #PARAMETERS = {\n    maxDim: 512,\n    sigmaSFactor: 0.02,\n    sigmaR: 25,\n    kernelSize: 16,\n  };\n\n  static #neighborIndexToId(i0, j0, i, j) {\n    /*\n      The idea is to map the neighbors of a pixel into a unique id.\n        3 2 1\n        4 X 0\n        5 6 7\n    */\n\n    i -= i0;\n    j -= j0;\n\n    if (i === 0) {\n      return j > 0 ? 0 : 4;\n    }\n\n    if (i === 1) {\n      return j + 6;\n    }\n\n    return 2 - j;\n  }\n\n  static #neighborIdToIndex = new Int32Array([\n    0, 1, -1, 1, -1, 0, -1, -1, 0, -1, 1, -1, 1, 0, 1, 1,\n  ]);\n\n  static #clockwiseNonZero(buf, width, i0, j0, i, j, offset) {\n    const id = this.#neighborIndexToId(i0, j0, i, j);\n    for (let k = 0; k < 8; k++) {\n      const kk = (-k + id - offset + 16) % 8;\n      const shiftI = this.#neighborIdToIndex[2 * kk];\n      const shiftJ = this.#neighborIdToIndex[2 * kk + 1];\n      if (buf[(i0 + shiftI) * width + (j0 + shiftJ)] !== 0) {\n        return kk;\n      }\n    }\n    return -1;\n  }\n\n  static #counterClockwiseNonZero(buf, width, i0, j0, i, j, offset) {\n    const id = this.#neighborIndexToId(i0, j0, i, j);\n    for (let k = 0; k < 8; k++) {\n      const kk = (k + id + offset + 16) % 8;\n      const shiftI = this.#neighborIdToIndex[2 * kk];\n      const shiftJ = this.#neighborIdToIndex[2 * kk + 1];\n      if (buf[(i0 + shiftI) * width + (j0 + shiftJ)] !== 0) {\n        return kk;\n      }\n    }\n    return -1;\n  }\n\n  static #findContours(buf, width, height, threshold) {\n    // Based on the Suzuki's algorithm:\n    //  https://web.archive.org/web/20231213161741/https://www.nevis.columbia.edu/~vgenty/public/suzuki_et_al.pdf\n\n    const N = buf.length;\n    const types = new Int32Array(N);\n    for (let i = 0; i < N; i++) {\n      types[i] = buf[i] <= threshold ? 1 : 0;\n    }\n\n    for (let i = 1; i < height - 1; i++) {\n      types[i * width] = types[i * width + width - 1] = 0;\n    }\n    for (let i = 0; i < width; i++) {\n      types[i] = types[width * height - 1 - i] = 0;\n    }\n\n    let nbd = 1;\n    let lnbd;\n    const contours = [];\n\n    for (let i = 1; i < height - 1; i++) {\n      lnbd = 1;\n      for (let j = 1; j < width - 1; j++) {\n        const ij = i * width + j;\n        const pix = types[ij];\n        if (pix === 0) {\n          continue;\n        }\n\n        let i2 = i;\n        let j2 = j;\n\n        if (pix === 1 && types[ij - 1] === 0) {\n          // Outer border.\n          nbd += 1;\n          j2 -= 1;\n        } else if (pix >= 1 && types[ij + 1] === 0) {\n          // Hole border.\n          nbd += 1;\n          j2 += 1;\n          if (pix > 1) {\n            lnbd = pix;\n          }\n        } else {\n          if (pix !== 1) {\n            lnbd = Math.abs(pix);\n          }\n          continue;\n        }\n\n        const points = [j, i];\n        const isHole = j2 === j + 1;\n        const contour = {\n          isHole,\n          points,\n          id: nbd,\n          parent: 0,\n        };\n        contours.push(contour);\n\n        let contour0;\n        for (const c of contours) {\n          if (c.id === lnbd) {\n            contour0 = c;\n            break;\n          }\n        }\n\n        if (!contour0) {\n          contour.parent = isHole ? lnbd : 0;\n        } else if (contour0.isHole) {\n          contour.parent = isHole ? contour0.parent : lnbd;\n        } else {\n          contour.parent = isHole ? lnbd : contour0.parent;\n        }\n\n        const k = this.#clockwiseNonZero(types, width, i, j, i2, j2, 0);\n        if (k === -1) {\n          types[ij] = -nbd;\n          if (types[ij] !== 1) {\n            lnbd = Math.abs(types[ij]);\n          }\n          continue;\n        }\n\n        let shiftI = this.#neighborIdToIndex[2 * k];\n        let shiftJ = this.#neighborIdToIndex[2 * k + 1];\n        const i1 = i + shiftI;\n        const j1 = j + shiftJ;\n        i2 = i1;\n        j2 = j1;\n        let i3 = i;\n        let j3 = j;\n\n        while (true) {\n          const kk = this.#counterClockwiseNonZero(\n            types,\n            width,\n            i3,\n            j3,\n            i2,\n            j2,\n            1\n          );\n          shiftI = this.#neighborIdToIndex[2 * kk];\n          shiftJ = this.#neighborIdToIndex[2 * kk + 1];\n          const i4 = i3 + shiftI;\n          const j4 = j3 + shiftJ;\n          points.push(j4, i4);\n          const ij3 = i3 * width + j3;\n          if (types[ij3 + 1] === 0) {\n            types[ij3] = -nbd;\n          } else if (types[ij3] === 1) {\n            types[ij3] = nbd;\n          }\n\n          if (i4 === i && j4 === j && i3 === i1 && j3 === j1) {\n            if (types[ij] !== 1) {\n              lnbd = Math.abs(types[ij]);\n            }\n            break;\n          } else {\n            i2 = i3;\n            j2 = j3;\n            i3 = i4;\n            j3 = j4;\n          }\n        }\n      }\n    }\n    return contours;\n  }\n\n  static #douglasPeuckerHelper(points, start, end, output) {\n    // Based on the Douglas-Peucker algorithm:\n    //  https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm\n    if (end - start <= 4) {\n      for (let i = start; i < end - 2; i += 2) {\n        output.push(points[i], points[i + 1]);\n      }\n      return;\n    }\n\n    const ax = points[start];\n    const ay = points[start + 1];\n    const abx = points[end - 4] - ax;\n    const aby = points[end - 3] - ay;\n    const dist = Math.hypot(abx, aby);\n    const nabx = abx / dist;\n    const naby = aby / dist;\n    const aa = nabx * ay - naby * ax;\n\n    // Guessing the epsilon value.\n    // See \"A novel framework for making dominant point detection methods\n    // non-parametric\".\n    const m = aby / abx;\n    const invS = 1 / dist;\n    const phi = Math.atan(m);\n    const cosPhi = Math.cos(phi);\n    const sinPhi = Math.sin(phi);\n    const tmax = invS * (Math.abs(cosPhi) + Math.abs(sinPhi));\n    const poly = invS * (1 - tmax + tmax ** 2);\n    const partialPhi = Math.max(\n      Math.atan(Math.abs(sinPhi + cosPhi) * poly),\n      Math.atan(Math.abs(sinPhi - cosPhi) * poly)\n    );\n\n    let dmax = 0;\n    let index = start;\n    for (let i = start + 2; i < end - 2; i += 2) {\n      const d = Math.abs(aa - nabx * points[i + 1] + naby * points[i]);\n      if (d > dmax) {\n        index = i;\n        dmax = d;\n      }\n    }\n\n    if (dmax > (dist * partialPhi) ** 2) {\n      this.#douglasPeuckerHelper(points, start, index + 2, output);\n      this.#douglasPeuckerHelper(points, index, end, output);\n    } else {\n      output.push(ax, ay);\n    }\n  }\n\n  static #douglasPeucker(points) {\n    const output = [];\n    const len = points.length;\n    this.#douglasPeuckerHelper(points, 0, len, output);\n    output.push(points[len - 2], points[len - 1]);\n    return output.length <= 4 ? null : output;\n  }\n\n  static #bilateralFilter(buf, width, height, sigmaS, sigmaR, kernelSize) {\n    // The bilateral filter is a nonlinear filter that does spatial averaging.\n    // Its main interest is to preserve edges while removing noise.\n    // See https://en.wikipedia.org/wiki/Bilateral_filter for more details.\n    // sigmaS is the standard deviation of the spatial gaussian.\n    // sigmaR is the standard deviation of the range (in term of pixel\n    // intensity) gaussian.\n\n    // Create a gaussian kernel\n    const kernel = new Float32Array(kernelSize ** 2);\n    const sigmaS2 = -2 * sigmaS ** 2;\n    const halfSize = kernelSize >> 1;\n\n    for (let i = 0; i < kernelSize; i++) {\n      const x = (i - halfSize) ** 2;\n      for (let j = 0; j < kernelSize; j++) {\n        kernel[i * kernelSize + j] = Math.exp(\n          (x + (j - halfSize) ** 2) / sigmaS2\n        );\n      }\n    }\n\n    // Create the range values to be used with the distance between pixels.\n    // It's a way faster with a lookup table than computing the exponential.\n    const rangeValues = new Float32Array(256);\n    const sigmaR2 = -2 * sigmaR ** 2;\n    for (let i = 0; i < 256; i++) {\n      rangeValues[i] = Math.exp(i ** 2 / sigmaR2);\n    }\n\n    const N = buf.length;\n    const out = new Uint8Array(N);\n\n    // We compute the histogram here instead of doing it later: it's slightly\n    // faster.\n    const histogram = new Uint32Array(256);\n    for (let i = 0; i < height; i++) {\n      for (let j = 0; j < width; j++) {\n        const ij = i * width + j;\n        const center = buf[ij];\n        let sum = 0;\n        let norm = 0;\n\n        for (let k = 0; k < kernelSize; k++) {\n          const y = i + k - halfSize;\n          if (y < 0 || y >= height) {\n            continue;\n          }\n          for (let l = 0; l < kernelSize; l++) {\n            const x = j + l - halfSize;\n            if (x < 0 || x >= width) {\n              continue;\n            }\n            const neighbour = buf[y * width + x];\n            const w =\n              kernel[k * kernelSize + l] *\n              rangeValues[Math.abs(neighbour - center)];\n            sum += neighbour * w;\n            norm += w;\n          }\n        }\n\n        const pix = (out[ij] = Math.round(sum / norm));\n        histogram[pix]++;\n      }\n    }\n\n    return [out, histogram];\n  }\n\n  static #getHistogram(buf) {\n    const histogram = new Uint32Array(256);\n    for (const g of buf) {\n      histogram[g]++;\n    }\n    return histogram;\n  }\n\n  static #toUint8(buf) {\n    // We have a RGBA buffer, containing a grayscale image.\n    // We want to convert it into a basic G buffer.\n    // Also, we want to normalize the values between 0 and 255 in order to\n    // increase the contrast.\n    const N = buf.length;\n    const out = new Uint8ClampedArray(N >> 2);\n    let max = -Infinity;\n    let min = Infinity;\n    for (let i = 0, ii = out.length; i < ii; i++) {\n      const pix = (out[i] = buf[i << 2]);\n      max = Math.max(max, pix);\n      min = Math.min(min, pix);\n    }\n    const ratio = 255 / (max - min);\n    for (let i = 0, ii = out.length; i < ii; i++) {\n      out[i] = (out[i] - min) * ratio;\n    }\n\n    return out;\n  }\n\n  static #guessThreshold(histogram) {\n    // We want to find the threshold that will separate the background from the\n    // foreground.\n    // We could have used Otsu's method, but unfortunately it doesn't work well\n    // when the background has too much shade of greys.\n    // So the idea is to find a maximum in the black part of the histogram and\n    // figure out the value which will be the first one of the white part.\n\n    let i;\n    let M = -Infinity;\n    let L = -Infinity;\n    const min = histogram.findIndex(v => v !== 0);\n    let pos = min;\n    let spos = min;\n    for (i = min; i < 256; i++) {\n      const v = histogram[i];\n      if (v > M) {\n        if (i - pos > L) {\n          L = i - pos;\n          spos = i - 1;\n        }\n        M = v;\n        pos = i;\n      }\n    }\n    for (i = spos - 1; i >= 0; i--) {\n      if (histogram[i] > histogram[i + 1]) {\n        break;\n      }\n    }\n\n    return i;\n  }\n\n  static #getGrayPixels(bitmap) {\n    const originalBitmap = bitmap;\n    const { width, height } = bitmap;\n    const { maxDim } = this.#PARAMETERS;\n    let newWidth = width;\n    let newHeight = height;\n\n    if (width > maxDim || height > maxDim) {\n      let prevWidth = width;\n      let prevHeight = height;\n\n      let steps = Math.log2(Math.max(width, height) / maxDim);\n      const isteps = Math.floor(steps);\n      steps = steps === isteps ? isteps - 1 : isteps;\n      for (let i = 0; i < steps; i++) {\n        newWidth = Math.ceil(prevWidth / 2);\n        newHeight = Math.ceil(prevHeight / 2);\n\n        const offscreen = new OffscreenCanvas(newWidth, newHeight);\n        const ctx = offscreen.getContext(\"2d\");\n        ctx.drawImage(\n          bitmap,\n          0,\n          0,\n          prevWidth,\n          prevHeight,\n          0,\n          0,\n          newWidth,\n          newHeight\n        );\n        prevWidth = newWidth;\n        prevHeight = newHeight;\n\n        // Release the resources associated with the bitmap.\n        if (bitmap !== originalBitmap) {\n          bitmap.close();\n        }\n        bitmap = offscreen.transferToImageBitmap();\n      }\n\n      const ratio = Math.min(maxDim / newWidth, maxDim / newHeight);\n      newWidth = Math.round(newWidth * ratio);\n      newHeight = Math.round(newHeight * ratio);\n    }\n    const offscreen = new OffscreenCanvas(newWidth, newHeight);\n    const ctx = offscreen.getContext(\"2d\", { willReadFrequently: true });\n    ctx.fillStyle = \"white\";\n    ctx.fillRect(0, 0, newWidth, newHeight);\n    ctx.filter = \"grayscale(1)\";\n    ctx.drawImage(\n      bitmap,\n      0,\n      0,\n      bitmap.width,\n      bitmap.height,\n      0,\n      0,\n      newWidth,\n      newHeight\n    );\n    const grayImage = ctx.getImageData(0, 0, newWidth, newHeight).data;\n    const uint8Buf = this.#toUint8(grayImage);\n\n    return [uint8Buf, newWidth, newHeight];\n  }\n\n  static extractContoursFromText(\n    text,\n    { fontFamily, fontStyle, fontWeight },\n    pageWidth,\n    pageHeight,\n    rotation,\n    innerMargin\n  ) {\n    let canvas = new OffscreenCanvas(1, 1);\n    let ctx = canvas.getContext(\"2d\", { alpha: false });\n    const fontSize = 200;\n    const font =\n      (ctx.font = `${fontStyle} ${fontWeight} ${fontSize}px ${fontFamily}`);\n    const {\n      actualBoundingBoxLeft,\n      actualBoundingBoxRight,\n      actualBoundingBoxAscent,\n      actualBoundingBoxDescent,\n      fontBoundingBoxAscent,\n      fontBoundingBoxDescent,\n      width,\n    } = ctx.measureText(text);\n\n    // We rescale the canvas to make \"sure\" the text fits.\n    const SCALE = 1.5;\n    const canvasWidth = Math.ceil(\n      Math.max(\n        Math.abs(actualBoundingBoxLeft) + Math.abs(actualBoundingBoxRight) || 0,\n        width\n      ) * SCALE\n    );\n    const canvasHeight = Math.ceil(\n      Math.max(\n        Math.abs(actualBoundingBoxAscent) +\n          Math.abs(actualBoundingBoxDescent) || fontSize,\n        Math.abs(fontBoundingBoxAscent) + Math.abs(fontBoundingBoxDescent) ||\n          fontSize\n      ) * SCALE\n    );\n    canvas = new OffscreenCanvas(canvasWidth, canvasHeight);\n    ctx = canvas.getContext(\"2d\", { alpha: true, willReadFrequently: true });\n    ctx.font = font;\n    ctx.filter = \"grayscale(1)\";\n    ctx.fillStyle = \"white\";\n    ctx.fillRect(0, 0, canvasWidth, canvasHeight);\n    ctx.fillStyle = \"black\";\n    ctx.fillText(\n      text,\n      (canvasWidth * (SCALE - 1)) / 2,\n      (canvasHeight * (3 - SCALE)) / 2\n    );\n\n    const uint8Buf = this.#toUint8(\n      ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n    );\n    const histogram = this.#getHistogram(uint8Buf);\n    const threshold = this.#guessThreshold(histogram);\n\n    const contourList = this.#findContours(\n      uint8Buf,\n      canvasWidth,\n      canvasHeight,\n      threshold\n    );\n\n    return this.processDrawnLines({\n      lines: { curves: contourList, width: canvasWidth, height: canvasHeight },\n      pageWidth,\n      pageHeight,\n      rotation,\n      innerMargin,\n      mustSmooth: true,\n      areContours: true,\n    });\n  }\n\n  static process(bitmap, pageWidth, pageHeight, rotation, innerMargin) {\n    const [uint8Buf, width, height] = this.#getGrayPixels(bitmap);\n    const [buffer, histogram] = this.#bilateralFilter(\n      uint8Buf,\n      width,\n      height,\n      Math.hypot(width, height) * this.#PARAMETERS.sigmaSFactor,\n      this.#PARAMETERS.sigmaR,\n      this.#PARAMETERS.kernelSize\n    );\n\n    const threshold = this.#guessThreshold(histogram);\n    const contourList = this.#findContours(buffer, width, height, threshold);\n\n    return this.processDrawnLines({\n      lines: { curves: contourList, width, height },\n      pageWidth,\n      pageHeight,\n      rotation,\n      innerMargin,\n      mustSmooth: true,\n      areContours: true,\n    });\n  }\n\n  static processDrawnLines({\n    lines,\n    pageWidth,\n    pageHeight,\n    rotation,\n    innerMargin,\n    mustSmooth,\n    areContours,\n  }) {\n    if (rotation % 180 !== 0) {\n      [pageWidth, pageHeight] = [pageHeight, pageWidth];\n    }\n\n    const { curves, width, height } = lines;\n    const thickness = lines.thickness ?? 0;\n    const linesAndPoints = [];\n    const ratio = Math.min(pageWidth / width, pageHeight / height);\n    const xScale = ratio / pageWidth;\n    const yScale = ratio / pageHeight;\n    const newCurves = [];\n\n    for (const { points } of curves) {\n      const reducedPoints = mustSmooth ? this.#douglasPeucker(points) : points;\n      if (!reducedPoints) {\n        continue;\n      }\n      newCurves.push(reducedPoints);\n\n      const len = reducedPoints.length;\n      const newPoints = new Float32Array(len);\n      const line = new Float32Array(3 * (len === 2 ? 2 : len - 2));\n      linesAndPoints.push({ line, points: newPoints });\n\n      if (len === 2) {\n        newPoints[0] = reducedPoints[0] * xScale;\n        newPoints[1] = reducedPoints[1] * yScale;\n        line.set([NaN, NaN, NaN, NaN, newPoints[0], newPoints[1]], 0);\n        continue;\n      }\n\n      let [x1, y1, x2, y2] = reducedPoints;\n      x1 *= xScale;\n      y1 *= yScale;\n      x2 *= xScale;\n      y2 *= yScale;\n      newPoints.set([x1, y1, x2, y2], 0);\n\n      line.set([NaN, NaN, NaN, NaN, x1, y1], 0);\n      for (let i = 4; i < len; i += 2) {\n        const x = (newPoints[i] = reducedPoints[i] * xScale);\n        const y = (newPoints[i + 1] = reducedPoints[i + 1] * yScale);\n        line.set(Outline.createBezierPoints(x1, y1, x2, y2, x, y), (i - 2) * 3);\n        [x1, y1, x2, y2] = [x2, y2, x, y];\n      }\n    }\n\n    if (linesAndPoints.length === 0) {\n      return null;\n    }\n\n    const outline = areContours\n      ? new ContourDrawOutline()\n      : new InkDrawOutline();\n\n    outline.build(\n      linesAndPoints,\n      pageWidth,\n      pageHeight,\n      1,\n      rotation,\n      areContours ? 0 : thickness,\n      innerMargin\n    );\n\n    return { outline, newCurves, areContours, thickness, width, height };\n  }\n\n  static async compressSignature({\n    outlines,\n    areContours,\n    thickness,\n    width,\n    height,\n  }) {\n    // We create a single array containing all the outlines.\n    // The format is the following:\n    // - 4 bytes: data length.\n    // - 4 bytes: version.\n    // - 4 bytes: width.\n    // - 4 bytes: height.\n    // - 4 bytes: 0 if it's a contour, 1 if it's an ink.\n    // - 4 bytes: thickness.\n    // - 4 bytes: number of drawings.\n    // - 4 bytes: size of the buffer containing the diff of the coordinates.\n    // - 4 bytes: number of points in the first drawing.\n    // - 4 bytes: x coordinate of the first point.\n    // - 4 bytes: y coordinate of the first point.\n    // - 4 bytes: number of points in the second drawing.\n    // - 4 bytes: x coordinate of the first point.\n    // - 4 bytes: y coordinate of the first point.\n    // - ...\n    // - The buffer containing the diff of the coordinates.\n\n    // The coordinates are supposed to be positive integers.\n\n    // We also compute the min and max difference between two points.\n    // This will help us to determine the type of the buffer (Int8, Int16 or\n    // Int32) in order to minimize the amount of data we have.\n    let minDiff = Infinity;\n    let maxDiff = -Infinity;\n    let outlinesLength = 0;\n    for (const points of outlines) {\n      outlinesLength += points.length;\n      for (let i = 2, ii = points.length; i < ii; i++) {\n        const dx = points[i] - points[i - 2];\n        minDiff = Math.min(minDiff, dx);\n        maxDiff = Math.max(maxDiff, dx);\n      }\n    }\n\n    let bufferType;\n    if (minDiff >= -128 && maxDiff <= 127) {\n      bufferType = Int8Array;\n    } else if (minDiff >= -32768 && maxDiff <= 32767) {\n      bufferType = Int16Array;\n    } else {\n      bufferType = Int32Array;\n    }\n\n    const len = outlines.length;\n    const headerLength = BASE_HEADER_LENGTH + POINTS_PROPERTIES_NUMBER * len;\n    const header = new Uint32Array(headerLength);\n\n    let offset = 0;\n    header[offset++] =\n      headerLength * Uint32Array.BYTES_PER_ELEMENT +\n      (outlinesLength - 2 * len) * bufferType.BYTES_PER_ELEMENT;\n    header[offset++] = 0; // Version.\n    header[offset++] = width;\n    header[offset++] = height;\n    header[offset++] = areContours ? 0 : 1;\n    header[offset++] = Math.max(0, Math.floor(thickness ?? 0));\n    header[offset++] = len;\n    header[offset++] = bufferType.BYTES_PER_ELEMENT;\n    for (const points of outlines) {\n      header[offset++] = points.length - 2;\n      header[offset++] = points[0];\n      header[offset++] = points[1];\n    }\n\n    const cs = new CompressionStream(\"deflate-raw\");\n    const writer = cs.writable.getWriter();\n    await writer.ready;\n\n    writer.write(header);\n    const BufferCtor = bufferType.prototype.constructor;\n    for (const points of outlines) {\n      const diffs = new BufferCtor(points.length - 2);\n      for (let i = 2, ii = points.length; i < ii; i++) {\n        diffs[i - 2] = points[i] - points[i - 2];\n      }\n      writer.write(diffs);\n    }\n\n    writer.close();\n\n    const buf = await new Response(cs.readable).arrayBuffer();\n    const bytes = new Uint8Array(buf);\n\n    return bytes.toBase64();\n  }\n\n  static async decompressSignature(signatureData) {\n    try {\n      const bytes = Uint8Array.fromBase64(signatureData);\n      const { readable, writable } = new DecompressionStream(\"deflate-raw\");\n      const writer = writable.getWriter();\n      await writer.ready;\n\n      // We can't await writer.write() because it'll block until the reader\n      // starts which happens few lines below.\n      writer\n        .write(bytes)\n        .then(async () => {\n          await writer.ready;\n          await writer.close();\n        })\n        .catch(() => {});\n\n      let data = null;\n      let offset = 0;\n      for await (const chunk of readable) {\n        data ||= new Uint8Array(new Uint32Array(chunk.buffer, 0, 4)[0]);\n        data.set(chunk, offset);\n        offset += chunk.length;\n      }\n\n      // We take a bit too much data for the header but it's fine.\n      const header = new Uint32Array(data.buffer, 0, data.length >> 2);\n      const version = header[1];\n      if (version !== 0) {\n        throw new Error(`Invalid version: ${version}`);\n      }\n      const width = header[2];\n      const height = header[3];\n      const areContours = header[4] === 0;\n      const thickness = header[5];\n      const numberOfDrawings = header[6];\n      const bufferType = header[7];\n      const outlines = [];\n      const diffsOffset =\n        (BASE_HEADER_LENGTH + POINTS_PROPERTIES_NUMBER * numberOfDrawings) *\n        Uint32Array.BYTES_PER_ELEMENT;\n      let diffs;\n\n      switch (bufferType) {\n        case Int8Array.BYTES_PER_ELEMENT:\n          diffs = new Int8Array(data.buffer, diffsOffset);\n          break;\n        case Int16Array.BYTES_PER_ELEMENT:\n          diffs = new Int16Array(data.buffer, diffsOffset);\n          break;\n        case Int32Array.BYTES_PER_ELEMENT:\n          diffs = new Int32Array(data.buffer, diffsOffset);\n          break;\n      }\n\n      offset = 0;\n      for (let i = 0; i < numberOfDrawings; i++) {\n        const len = header[POINTS_PROPERTIES_NUMBER * i + BASE_HEADER_LENGTH];\n        const points = new Float32Array(len + 2);\n        outlines.push(points);\n\n        for (let j = 0; j < POINTS_PROPERTIES_NUMBER - 1; j++) {\n          points[j] =\n            header[POINTS_PROPERTIES_NUMBER * i + BASE_HEADER_LENGTH + j + 1];\n        }\n        for (let j = 0; j < len; j++) {\n          points[j + 2] = points[j] + diffs[offset++];\n        }\n      }\n\n      return {\n        areContours,\n        thickness,\n        outlines,\n        width,\n        height,\n      };\n    } catch (e) {\n      warn(`decompressSignature: ${e}`);\n      return null;\n    }\n  }\n}\n\nexport { SignatureExtractor };\n","/* Copyright 2025 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AnnotationEditorType, shadow } from \"../../shared/util.js\";\nimport { DrawingEditor, DrawingOptions } from \"./draw.js\";\nimport { AnnotationEditor } from \"./editor.js\";\nimport { ContourDrawOutline } from \"./drawers/contour.js\";\nimport { InkDrawingOptions } from \"./ink.js\";\nimport { InkDrawOutline } from \"./drawers/inkdraw.js\";\nimport { SignatureExtractor } from \"./drawers/signaturedraw.js\";\n\nclass SignatureOptions extends DrawingOptions {\n  constructor() {\n    super();\n\n    super.updateProperties({\n      fill: AnnotationEditor._defaultLineColor,\n      \"stroke-width\": 0,\n    });\n  }\n\n  clone() {\n    const clone = new SignatureOptions();\n    clone.updateAll(this);\n    return clone;\n  }\n}\n\nclass DrawnSignatureOptions extends InkDrawingOptions {\n  constructor(viewerParameters) {\n    super(viewerParameters);\n\n    super.updateProperties({\n      stroke: AnnotationEditor._defaultLineColor,\n      \"stroke-width\": 1,\n    });\n  }\n\n  clone() {\n    const clone = new DrawnSignatureOptions(this._viewParameters);\n    clone.updateAll(this);\n    return clone;\n  }\n}\n\n/**\n * Basic editor in order to generate an Stamp annotation annotation containing\n * a signature drawing.\n */\nclass SignatureEditor extends DrawingEditor {\n  #isExtracted = false;\n\n  #description = null;\n\n  #signatureData = null;\n\n  #signatureUUID = null;\n\n  static _type = \"signature\";\n\n  static _editorType = AnnotationEditorType.SIGNATURE;\n\n  static _defaultDrawingOptions = null;\n\n  constructor(params) {\n    super({ ...params, mustBeCommitted: true, name: \"signatureEditor\" });\n    this._willKeepAspectRatio = true;\n    this.#signatureData = params.signatureData || null;\n    this.#description = null;\n    this.defaultL10nId = \"pdfjs-editor-signature-editor1\";\n  }\n\n  /** @inheritdoc */\n  static initialize(l10n, uiManager) {\n    AnnotationEditor.initialize(l10n, uiManager);\n\n    this._defaultDrawingOptions = new SignatureOptions();\n    this._defaultDrawnSignatureOptions = new DrawnSignatureOptions(\n      uiManager.viewParameters\n    );\n  }\n\n  /** @inheritdoc */\n  static getDefaultDrawingOptions(options) {\n    const clone = this._defaultDrawingOptions.clone();\n    clone.updateProperties(options);\n    return clone;\n  }\n\n  /** @inheritdoc */\n  static get supportMultipleDrawings() {\n    return false;\n  }\n\n  static get typesMap() {\n    return shadow(this, \"typesMap\", new Map());\n  }\n\n  static get isDrawer() {\n    return false;\n  }\n\n  /** @inheritdoc */\n  get telemetryFinalData() {\n    return {\n      type: \"signature\",\n      hasDescription: !!this.#description,\n    };\n  }\n\n  static computeTelemetryFinalData(data) {\n    const hasDescriptionStats = data.get(\"hasDescription\");\n    return {\n      hasAltText: hasDescriptionStats.get(true) ?? 0,\n      hasNoAltText: hasDescriptionStats.get(false) ?? 0,\n    };\n  }\n\n  /** @inheritdoc */\n  get isResizable() {\n    return true;\n  }\n\n  /** @inheritdoc */\n  onScaleChanging() {\n    if (this._drawId === null) {\n      return;\n    }\n    super.onScaleChanging();\n  }\n\n  /** @inheritdoc */\n  render() {\n    if (this.div) {\n      return this.div;\n    }\n\n    let baseX, baseY;\n    const { _isCopy } = this;\n    if (_isCopy) {\n      // No need to adjust the position when rendering in DrawingEditor.\n      this._isCopy = false;\n      baseX = this.x;\n      baseY = this.y;\n    }\n\n    super.render();\n\n    if (this._drawId === null) {\n      if (this.#signatureData) {\n        const {\n          lines,\n          mustSmooth,\n          areContours,\n          description,\n          uuid,\n          heightInPage,\n        } = this.#signatureData;\n        const {\n          rawDims: { pageWidth, pageHeight },\n          rotation,\n        } = this.parent.viewport;\n        const outline = SignatureExtractor.processDrawnLines({\n          lines,\n          pageWidth,\n          pageHeight,\n          rotation,\n          innerMargin: SignatureEditor._INNER_MARGIN,\n          mustSmooth,\n          areContours,\n        });\n        this.addSignature(outline, heightInPage, description, uuid);\n      } else {\n        // Avoid Firefox crashing (with a local build) because the description\n        // parameter is missing.\n        this.div.setAttribute(\n          \"data-l10n-args\",\n          JSON.stringify({ description: \"\" })\n        );\n        this.div.hidden = true;\n        this._uiManager.getSignature(this);\n      }\n    } else {\n      this.div.setAttribute(\n        \"data-l10n-args\",\n        JSON.stringify({ description: this.#description || \"\" })\n      );\n    }\n\n    if (_isCopy) {\n      this._isCopy = true;\n      this._moveAfterPaste(baseX, baseY);\n    }\n\n    return this.div;\n  }\n\n  setUuid(uuid) {\n    this.#signatureUUID = uuid;\n    this.addEditToolbar();\n  }\n\n  getUuid() {\n    return this.#signatureUUID;\n  }\n\n  get description() {\n    return this.#description;\n  }\n\n  set description(description) {\n    this.#description = description;\n    if (!this.div) {\n      return;\n    }\n    this.div.setAttribute(\"data-l10n-args\", JSON.stringify({ description }));\n    super.addEditToolbar().then(toolbar => {\n      toolbar?.updateEditSignatureButton(description);\n    });\n  }\n\n  getSignaturePreview() {\n    const { newCurves, areContours, thickness, width, height } =\n      this.#signatureData;\n    const maxDim = Math.max(width, height);\n    const outlineData = SignatureExtractor.processDrawnLines({\n      lines: {\n        curves: newCurves.map(points => ({ points })),\n        thickness,\n        width,\n        height,\n      },\n      pageWidth: maxDim,\n      pageHeight: maxDim,\n      rotation: 0,\n      innerMargin: 0,\n      mustSmooth: false,\n      areContours,\n    });\n    return { areContours, outline: outlineData.outline };\n  }\n\n  /** @inheritdoc */\n  get toolbarButtons() {\n    if (this._uiManager.signatureManager) {\n      return [[\"editSignature\", this._uiManager.signatureManager]];\n    }\n    return super.toolbarButtons;\n  }\n\n  addSignature(data, heightInPage, description, uuid) {\n    const { x: savedX, y: savedY } = this;\n    const { outline } = (this.#signatureData = data);\n    this.#isExtracted = outline instanceof ContourDrawOutline;\n    this.description = description;\n    let drawingOptions;\n    if (this.#isExtracted) {\n      drawingOptions = SignatureEditor.getDefaultDrawingOptions();\n    } else {\n      drawingOptions = SignatureEditor._defaultDrawnSignatureOptions.clone();\n      drawingOptions.updateProperties({ \"stroke-width\": outline.thickness });\n    }\n    this._addOutlines({\n      drawOutlines: outline,\n      drawingOptions,\n    });\n    const [, pageHeight] = this.pageDimensions;\n    let newHeight = heightInPage / pageHeight;\n    // Ensure the signature doesn't exceed the page height.\n    // If the signature is too big, we scale it down to 50% of the page height.\n    newHeight = newHeight >= 1 ? 0.5 : newHeight;\n\n    this.width *= newHeight / this.height;\n    if (this.width >= 1) {\n      newHeight *= 0.9 / this.width;\n      this.width = 0.9;\n    }\n\n    this.height = newHeight;\n    this.setDims();\n    this.x = savedX;\n    this.y = savedY;\n    this.center();\n\n    this._onResized();\n    this.onScaleChanging();\n    this.rotate();\n    this._uiManager.addToAnnotationStorage(this);\n    this.setUuid(uuid);\n\n    this._reportTelemetry({\n      action: \"pdfjs.signature.inserted\",\n      data: {\n        hasBeenSaved: !!uuid,\n        hasDescription: !!description,\n      },\n    });\n\n    this.div.hidden = false;\n  }\n\n  getFromImage(bitmap) {\n    const {\n      rawDims: { pageWidth, pageHeight },\n      rotation,\n    } = this.parent.viewport;\n    return SignatureExtractor.process(\n      bitmap,\n      pageWidth,\n      pageHeight,\n      rotation,\n      SignatureEditor._INNER_MARGIN\n    );\n  }\n\n  getFromText(text, fontInfo) {\n    const {\n      rawDims: { pageWidth, pageHeight },\n      rotation,\n    } = this.parent.viewport;\n    return SignatureExtractor.extractContoursFromText(\n      text,\n      fontInfo,\n      pageWidth,\n      pageHeight,\n      rotation,\n      SignatureEditor._INNER_MARGIN\n    );\n  }\n\n  getDrawnSignature(curves) {\n    const {\n      rawDims: { pageWidth, pageHeight },\n      rotation,\n    } = this.parent.viewport;\n    return SignatureExtractor.processDrawnLines({\n      lines: curves,\n      pageWidth,\n      pageHeight,\n      rotation,\n      innerMargin: SignatureEditor._INNER_MARGIN,\n      mustSmooth: false,\n      areContours: false,\n    });\n  }\n\n  /** @inheritdoc */\n  createDrawingOptions({ areContours, thickness }) {\n    if (areContours) {\n      this._drawingOptions = SignatureEditor.getDefaultDrawingOptions();\n    } else {\n      this._drawingOptions =\n        SignatureEditor._defaultDrawnSignatureOptions.clone();\n      this._drawingOptions.updateProperties({ \"stroke-width\": thickness });\n    }\n  }\n\n  /** @inheritdoc */\n  serialize(isForCopying = false) {\n    if (this.isEmpty()) {\n      return null;\n    }\n\n    const { lines, points } = this.serializeDraw(isForCopying);\n    const {\n      _drawingOptions: { \"stroke-width\": thickness },\n    } = this;\n    const serialized = Object.assign(super.serialize(isForCopying), {\n      isSignature: true,\n      areContours: this.#isExtracted,\n      color: [0, 0, 0],\n      thickness: this.#isExtracted ? 0 : thickness,\n    });\n    this.addComment(serialized);\n    if (isForCopying) {\n      serialized.paths = { lines, points };\n      serialized.uuid = this.#signatureUUID;\n      serialized.isCopy = true;\n    } else {\n      serialized.lines = lines;\n    }\n    if (this.#description) {\n      serialized.accessibilityData = { type: \"Figure\", alt: this.#description };\n    }\n    return serialized;\n  }\n\n  /** @inheritdoc */\n  static deserializeDraw(\n    pageX,\n    pageY,\n    pageWidth,\n    pageHeight,\n    innerMargin,\n    data\n  ) {\n    if (data.areContours) {\n      return ContourDrawOutline.deserialize(\n        pageX,\n        pageY,\n        pageWidth,\n        pageHeight,\n        innerMargin,\n        data\n      );\n    }\n\n    return InkDrawOutline.deserialize(\n      pageX,\n      pageY,\n      pageWidth,\n      pageHeight,\n      innerMargin,\n      data\n    );\n  }\n\n  /** @inheritdoc */\n  static async deserialize(data, parent, uiManager) {\n    const editor = await super.deserialize(data, parent, uiManager);\n    editor.#isExtracted = data.areContours;\n    editor.description = data.accessibilityData?.alt || \"\";\n    editor.#signatureUUID = data.uuid;\n    return editor;\n  }\n}\n\nexport { SignatureEditor };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AnnotationEditorType, AnnotationPrefix } from \"../../shared/util.js\";\nimport {\n  ColorScheme,\n  OutputScale,\n  PixelsPerInch,\n  SupportedImageMimeTypes,\n} from \"../display_utils.js\";\nimport { AnnotationEditor } from \"./editor.js\";\nimport { StampAnnotationElement } from \"../annotation_layer.js\";\n\n/**\n * Basic text editor in order to create a FreeTex annotation.\n */\nclass StampEditor extends AnnotationEditor {\n  #bitmap = null;\n\n  #bitmapId = null;\n\n  #bitmapPromise = null;\n\n  #bitmapUrl = null;\n\n  #bitmapFile = null;\n\n  #bitmapFileName = \"\";\n\n  #canvas = null;\n\n  #missingCanvas = false;\n\n  #resizeTimeoutId = null;\n\n  #isSvg = false;\n\n  #hasBeenAddedInUndoStack = false;\n\n  static _type = \"stamp\";\n\n  static _editorType = AnnotationEditorType.STAMP;\n\n  constructor(params) {\n    super({ ...params, name: \"stampEditor\" });\n    this.#bitmapUrl = params.bitmapUrl;\n    this.#bitmapFile = params.bitmapFile;\n    this.defaultL10nId = \"pdfjs-editor-stamp-editor\";\n  }\n\n  /** @inheritdoc */\n  static initialize(l10n, uiManager) {\n    AnnotationEditor.initialize(l10n, uiManager);\n  }\n\n  /** @inheritdoc */\n  static isHandlingMimeForPasting(mime) {\n    return SupportedImageMimeTypes.includes(mime);\n  }\n\n  /** @inheritdoc */\n  static paste(item, parent) {\n    parent.pasteEditor(\n      { mode: AnnotationEditorType.STAMP },\n      { bitmapFile: item.getAsFile() }\n    );\n  }\n\n  /** @inheritdoc */\n  altTextFinish() {\n    if (this._uiManager.useNewAltTextFlow) {\n      this.div.hidden = false;\n    }\n    super.altTextFinish();\n  }\n\n  /** @inheritdoc */\n  get telemetryFinalData() {\n    return {\n      type: \"stamp\",\n      hasAltText: !!this.altTextData?.altText,\n    };\n  }\n\n  static computeTelemetryFinalData(data) {\n    const hasAltTextStats = data.get(\"hasAltText\");\n    return {\n      hasAltText: hasAltTextStats.get(true) ?? 0,\n      hasNoAltText: hasAltTextStats.get(false) ?? 0,\n    };\n  }\n\n  #getBitmapFetched(data, fromId = false) {\n    if (!data) {\n      this.remove();\n      return;\n    }\n    this.#bitmap = data.bitmap;\n    if (!fromId) {\n      this.#bitmapId = data.id;\n      this.#isSvg = data.isSvg;\n    }\n    if (data.file) {\n      this.#bitmapFileName = data.file.name;\n    }\n    this.#createCanvas();\n  }\n\n  #getBitmapDone() {\n    this.#bitmapPromise = null;\n    this._uiManager.enableWaiting(false);\n    if (!this.#canvas) {\n      return;\n    }\n    if (\n      this._uiManager.useNewAltTextWhenAddingImage &&\n      this._uiManager.useNewAltTextFlow &&\n      this.#bitmap\n    ) {\n      this.addEditToolbar().then(() => {\n        this._editToolbar.hide();\n        this._uiManager.editAltText(this, /* firstTime = */ true);\n      });\n      return;\n    }\n\n    if (\n      !this._uiManager.useNewAltTextWhenAddingImage &&\n      this._uiManager.useNewAltTextFlow &&\n      this.#bitmap\n    ) {\n      this._reportTelemetry({\n        action: \"pdfjs.image.image_added\",\n        data: { alt_text_modal: false, alt_text_type: \"empty\" },\n      });\n      try {\n        // The alt-text dialog isn't opened but we still want to guess the alt\n        // text.\n        this.mlGuessAltText();\n      } catch {}\n    }\n\n    this.div.focus();\n  }\n\n  async mlGuessAltText(imageData = null, updateAltTextData = true) {\n    if (this.hasAltTextData()) {\n      return null;\n    }\n\n    const { mlManager } = this._uiManager;\n    if (!mlManager) {\n      throw new Error(\"No ML.\");\n    }\n    if (!(await mlManager.isEnabledFor(\"altText\"))) {\n      throw new Error(\"ML isn't enabled for alt text.\");\n    }\n    const { data, width, height } =\n      imageData ||\n      this.copyCanvas(null, null, /* createImageData = */ true).imageData;\n    const response = await mlManager.guess({\n      name: \"altText\",\n      request: {\n        data,\n        width,\n        height,\n        channels: data.length / (width * height),\n      },\n    });\n    if (!response) {\n      throw new Error(\"No response from the AI service.\");\n    }\n    if (response.error) {\n      throw new Error(\"Error from the AI service.\");\n    }\n    if (response.cancel) {\n      return null;\n    }\n    if (!response.output) {\n      throw new Error(\"No valid response from the AI service.\");\n    }\n    const altText = response.output;\n    await this.setGuessedAltText(altText);\n    if (updateAltTextData && !this.hasAltTextData()) {\n      this.altTextData = { alt: altText, decorative: false };\n    }\n    return altText;\n  }\n\n  #getBitmap() {\n    if (this.#bitmapId) {\n      this._uiManager.enableWaiting(true);\n      this._uiManager.imageManager\n        .getFromId(this.#bitmapId)\n        .then(data => this.#getBitmapFetched(data, /* fromId = */ true))\n        .finally(() => this.#getBitmapDone());\n      return;\n    }\n\n    if (this.#bitmapUrl) {\n      const url = this.#bitmapUrl;\n      this.#bitmapUrl = null;\n      this._uiManager.enableWaiting(true);\n      this.#bitmapPromise = this._uiManager.imageManager\n        .getFromUrl(url)\n        .then(data => this.#getBitmapFetched(data))\n        .finally(() => this.#getBitmapDone());\n      return;\n    }\n\n    if (this.#bitmapFile) {\n      const file = this.#bitmapFile;\n      this.#bitmapFile = null;\n      this._uiManager.enableWaiting(true);\n      this.#bitmapPromise = this._uiManager.imageManager\n        .getFromFile(file)\n        .then(data => this.#getBitmapFetched(data))\n        .finally(() => this.#getBitmapDone());\n      return;\n    }\n\n    const input = document.createElement(\"input\");\n    if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n      input.hidden = true;\n      input.id = \"stampEditorFileInput\";\n      document.body.append(input);\n    }\n    input.type = \"file\";\n    input.accept = SupportedImageMimeTypes.join(\",\");\n    const signal = this._uiManager._signal;\n    this.#bitmapPromise = new Promise(resolve => {\n      input.addEventListener(\n        \"change\",\n        async () => {\n          if (!input.files || input.files.length === 0) {\n            this.remove();\n          } else {\n            this._uiManager.enableWaiting(true);\n            const data = await this._uiManager.imageManager.getFromFile(\n              input.files[0]\n            );\n            this._reportTelemetry({\n              action: \"pdfjs.image.image_selected\",\n              data: { alt_text_modal: this._uiManager.useNewAltTextFlow },\n            });\n            this.#getBitmapFetched(data);\n          }\n          if (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING\")) {\n            input.remove();\n          }\n          resolve();\n        },\n        { signal }\n      );\n      input.addEventListener(\n        \"cancel\",\n        () => {\n          this.remove();\n          resolve();\n        },\n        { signal }\n      );\n    }).finally(() => this.#getBitmapDone());\n    if (typeof PDFJSDev === \"undefined\" || !PDFJSDev.test(\"TESTING\")) {\n      input.click();\n    }\n  }\n\n  /** @inheritdoc */\n  remove() {\n    if (this.#bitmapId) {\n      this.#bitmap = null;\n      this._uiManager.imageManager.deleteId(this.#bitmapId);\n      this.#canvas?.remove();\n      this.#canvas = null;\n      if (this.#resizeTimeoutId) {\n        clearTimeout(this.#resizeTimeoutId);\n        this.#resizeTimeoutId = null;\n      }\n    }\n    super.remove();\n  }\n\n  /** @inheritdoc */\n  rebuild() {\n    if (!this.parent) {\n      // It's possible to have to rebuild an editor which is not on a visible\n      // page.\n      if (this.#bitmapId) {\n        this.#getBitmap();\n      }\n      return;\n    }\n    super.rebuild();\n    if (this.div === null) {\n      return;\n    }\n\n    if (this.#bitmapId && this.#canvas === null) {\n      this.#getBitmap();\n    }\n\n    if (!this.isAttachedToDOM) {\n      // At some point this editor was removed and we're rebuilting it,\n      // hence we must add it to its parent.\n      this.parent.add(this);\n    }\n  }\n\n  /** @inheritdoc */\n  onceAdded(focus) {\n    this._isDraggable = true;\n    if (focus) {\n      this.div.focus();\n    }\n  }\n\n  /** @inheritdoc */\n  isEmpty() {\n    return !(\n      this.#bitmapPromise ||\n      this.#bitmap ||\n      this.#bitmapUrl ||\n      this.#bitmapFile ||\n      this.#bitmapId ||\n      this.#missingCanvas\n    );\n  }\n\n  /** @inheritdoc */\n  get toolbarButtons() {\n    return [[\"altText\", this.createAltText()]];\n  }\n\n  /** @inheritdoc */\n  get isResizable() {\n    return true;\n  }\n\n  /** @inheritdoc */\n  render() {\n    if (this.div) {\n      return this.div;\n    }\n\n    let baseX, baseY;\n    if (this._isCopy) {\n      baseX = this.x;\n      baseY = this.y;\n    }\n\n    super.render();\n    this.div.hidden = true;\n\n    this.createAltText();\n\n    if (!this.#missingCanvas) {\n      if (this.#bitmap) {\n        this.#createCanvas();\n      } else {\n        this.#getBitmap();\n      }\n    }\n\n    if (this._isCopy) {\n      this._moveAfterPaste(baseX, baseY);\n    }\n\n    this._uiManager.addShouldRescale(this);\n\n    return this.div;\n  }\n\n  setCanvas(annotationElementId, canvas) {\n    const { id: bitmapId, bitmap } = this._uiManager.imageManager.getFromCanvas(\n      annotationElementId,\n      canvas\n    );\n    canvas.remove();\n    if (bitmapId && this._uiManager.imageManager.isValidId(bitmapId)) {\n      this.#bitmapId = bitmapId;\n      if (bitmap) {\n        this.#bitmap = bitmap;\n      }\n      this.#missingCanvas = false;\n      this.#createCanvas();\n    }\n  }\n\n  /** @inheritdoc */\n  _onResized() {\n    // We used a CSS-zoom during the resizing, but now it's resized we can\n    // rescale correctly the bitmap to fit the new dimensions.\n    this.onScaleChanging();\n  }\n\n  onScaleChanging() {\n    if (!this.parent) {\n      return;\n    }\n    if (this.#resizeTimeoutId !== null) {\n      clearTimeout(this.#resizeTimeoutId);\n    }\n    // The user's zooming the page, there is no need to redraw the bitmap at\n    // each step, hence we wait a bit before redrawing it.\n    const TIME_TO_WAIT = 200;\n    this.#resizeTimeoutId = setTimeout(() => {\n      this.#resizeTimeoutId = null;\n      this.#drawBitmap();\n    }, TIME_TO_WAIT);\n  }\n\n  #createCanvas() {\n    const { div } = this;\n    let { width, height } = this.#bitmap;\n    const [pageWidth, pageHeight] = this.pageDimensions;\n    const MAX_RATIO = 0.75;\n    if (this.width) {\n      width = this.width * pageWidth;\n      height = this.height * pageHeight;\n    } else if (\n      width > MAX_RATIO * pageWidth ||\n      height > MAX_RATIO * pageHeight\n    ) {\n      // If the image is too big compared to the page dimensions\n      // (more than MAX_RATIO) then we scale it down.\n      const factor = Math.min(\n        (MAX_RATIO * pageWidth) / width,\n        (MAX_RATIO * pageHeight) / height\n      );\n      width *= factor;\n      height *= factor;\n    }\n\n    this._uiManager.enableWaiting(false);\n    const canvas = (this.#canvas = document.createElement(\"canvas\"));\n    canvas.setAttribute(\"role\", \"img\");\n    this.addContainer(canvas);\n\n    this.width = width / pageWidth;\n    this.height = height / pageHeight;\n    this.setDims();\n\n    if (this._initialOptions?.isCentered) {\n      this.center();\n    } else {\n      this.fixAndSetPosition();\n    }\n    this._initialOptions = null;\n\n    if (\n      !this._uiManager.useNewAltTextWhenAddingImage ||\n      !this._uiManager.useNewAltTextFlow ||\n      this.annotationElementId\n    ) {\n      div.hidden = false;\n    }\n    this.#drawBitmap();\n    if (!this.#hasBeenAddedInUndoStack) {\n      this.parent.addUndoableEditor(this);\n      this.#hasBeenAddedInUndoStack = true;\n    }\n\n    // There are multiple ways to add an image to the page, so here we just\n    // count the number of times an image is added to the page whatever the way\n    // is.\n    this._reportTelemetry({\n      action: \"inserted_image\",\n    });\n    if (this.#bitmapFileName) {\n      this.div.setAttribute(\"aria-description\", this.#bitmapFileName);\n    }\n    if (!this.annotationElementId) {\n      this._uiManager.a11yAlert(\"pdfjs-editor-stamp-added-alert\");\n    }\n  }\n\n  copyCanvas(maxDataDimension, maxPreviewDimension, createImageData = false) {\n    if (!maxDataDimension) {\n      // TODO: get this value from Firefox\n      //   (https://bugzilla.mozilla.org/show_bug.cgi?id=1908184)\n      // It's the maximum dimension that the AI can handle.\n      maxDataDimension = 224;\n    }\n\n    const { width: bitmapWidth, height: bitmapHeight } = this.#bitmap;\n    const outputScale = new OutputScale();\n\n    let bitmap = this.#bitmap;\n    let width = bitmapWidth,\n      height = bitmapHeight;\n    let canvas = null;\n\n    if (maxPreviewDimension) {\n      if (\n        bitmapWidth > maxPreviewDimension ||\n        bitmapHeight > maxPreviewDimension\n      ) {\n        const ratio = Math.min(\n          maxPreviewDimension / bitmapWidth,\n          maxPreviewDimension / bitmapHeight\n        );\n        width = Math.floor(bitmapWidth * ratio);\n        height = Math.floor(bitmapHeight * ratio);\n      }\n\n      canvas = document.createElement(\"canvas\");\n      const scaledWidth = (canvas.width = Math.ceil(width * outputScale.sx));\n      const scaledHeight = (canvas.height = Math.ceil(height * outputScale.sy));\n\n      if (!this.#isSvg) {\n        bitmap = this.#scaleBitmap(scaledWidth, scaledHeight);\n      }\n\n      const ctx = canvas.getContext(\"2d\");\n      ctx.filter = this._uiManager.hcmFilter;\n\n      // Add a checkerboard pattern as a background in case the image has some\n      // transparency.\n      let white = \"white\",\n        black = \"#cfcfd8\";\n      if (this._uiManager.hcmFilter !== \"none\") {\n        black = \"black\";\n      } else if (ColorScheme.isDarkMode) {\n        white = \"#8f8f9d\";\n        black = \"#42414d\";\n      }\n      const boxDim = 15;\n      const boxDimWidth = boxDim * outputScale.sx;\n      const boxDimHeight = boxDim * outputScale.sy;\n      const pattern = new OffscreenCanvas(boxDimWidth * 2, boxDimHeight * 2);\n      const patternCtx = pattern.getContext(\"2d\");\n      patternCtx.fillStyle = white;\n      patternCtx.fillRect(0, 0, boxDimWidth * 2, boxDimHeight * 2);\n      patternCtx.fillStyle = black;\n      patternCtx.fillRect(0, 0, boxDimWidth, boxDimHeight);\n      patternCtx.fillRect(boxDimWidth, boxDimHeight, boxDimWidth, boxDimHeight);\n      ctx.fillStyle = ctx.createPattern(pattern, \"repeat\");\n      ctx.fillRect(0, 0, scaledWidth, scaledHeight);\n      ctx.drawImage(\n        bitmap,\n        0,\n        0,\n        bitmap.width,\n        bitmap.height,\n        0,\n        0,\n        scaledWidth,\n        scaledHeight\n      );\n    }\n\n    let imageData = null;\n    if (createImageData) {\n      let dataWidth, dataHeight;\n      if (\n        outputScale.symmetric &&\n        bitmap.width < maxDataDimension &&\n        bitmap.height < maxDataDimension\n      ) {\n        dataWidth = bitmap.width;\n        dataHeight = bitmap.height;\n      } else {\n        bitmap = this.#bitmap;\n        if (bitmapWidth > maxDataDimension || bitmapHeight > maxDataDimension) {\n          const ratio = Math.min(\n            maxDataDimension / bitmapWidth,\n            maxDataDimension / bitmapHeight\n          );\n          dataWidth = Math.floor(bitmapWidth * ratio);\n          dataHeight = Math.floor(bitmapHeight * ratio);\n\n          if (!this.#isSvg) {\n            bitmap = this.#scaleBitmap(dataWidth, dataHeight);\n          }\n        }\n      }\n\n      const offscreen = new OffscreenCanvas(dataWidth, dataHeight);\n      const offscreenCtx = offscreen.getContext(\"2d\", {\n        willReadFrequently: true,\n      });\n      offscreenCtx.drawImage(\n        bitmap,\n        0,\n        0,\n        bitmap.width,\n        bitmap.height,\n        0,\n        0,\n        dataWidth,\n        dataHeight\n      );\n      imageData = {\n        width: dataWidth,\n        height: dataHeight,\n        data: offscreenCtx.getImageData(0, 0, dataWidth, dataHeight).data,\n      };\n    }\n\n    return { canvas, width, height, imageData };\n  }\n\n  #scaleBitmap(width, height) {\n    const { width: bitmapWidth, height: bitmapHeight } = this.#bitmap;\n\n    let newWidth = bitmapWidth;\n    let newHeight = bitmapHeight;\n    let bitmap = this.#bitmap;\n    while (newWidth > 2 * width || newHeight > 2 * height) {\n      const prevWidth = newWidth;\n      const prevHeight = newHeight;\n\n      if (newWidth > 2 * width) {\n        // See bug 1820511 (Windows specific bug).\n        // TODO: once the above bug is fixed we could revert to:\n        // newWidth = Math.ceil(newWidth / 2);\n        newWidth =\n          newWidth >= 16384\n            ? Math.floor(newWidth / 2) - 1\n            : Math.ceil(newWidth / 2);\n      }\n      if (newHeight > 2 * height) {\n        newHeight =\n          newHeight >= 16384\n            ? Math.floor(newHeight / 2) - 1\n            : Math.ceil(newHeight / 2);\n      }\n\n      const offscreen = new OffscreenCanvas(newWidth, newHeight);\n      const ctx = offscreen.getContext(\"2d\");\n      ctx.drawImage(\n        bitmap,\n        0,\n        0,\n        prevWidth,\n        prevHeight,\n        0,\n        0,\n        newWidth,\n        newHeight\n      );\n      bitmap = offscreen.transferToImageBitmap();\n    }\n\n    return bitmap;\n  }\n\n  #drawBitmap() {\n    const [parentWidth, parentHeight] = this.parentDimensions;\n    const { width, height } = this;\n    const outputScale = new OutputScale();\n    const scaledWidth = Math.ceil(width * parentWidth * outputScale.sx);\n    const scaledHeight = Math.ceil(height * parentHeight * outputScale.sy);\n    const canvas = this.#canvas;\n\n    if (\n      !canvas ||\n      (canvas.width === scaledWidth && canvas.height === scaledHeight)\n    ) {\n      return;\n    }\n\n    canvas.width = scaledWidth;\n    canvas.height = scaledHeight;\n\n    const bitmap = this.#isSvg\n      ? this.#bitmap\n      : this.#scaleBitmap(scaledWidth, scaledHeight);\n\n    const ctx = canvas.getContext(\"2d\");\n    ctx.filter = this._uiManager.hcmFilter;\n    ctx.drawImage(\n      bitmap,\n      0,\n      0,\n      bitmap.width,\n      bitmap.height,\n      0,\n      0,\n      scaledWidth,\n      scaledHeight\n    );\n  }\n\n  #serializeBitmap(toUrl) {\n    if (toUrl) {\n      if (this.#isSvg) {\n        const url = this._uiManager.imageManager.getSvgUrl(this.#bitmapId);\n        if (url) {\n          return url;\n        }\n      }\n      // We convert to a data url because it's sync and the url can live in the\n      // clipboard.\n      const canvas = document.createElement(\"canvas\");\n      ({ width: canvas.width, height: canvas.height } = this.#bitmap);\n      const ctx = canvas.getContext(\"2d\");\n      ctx.drawImage(this.#bitmap, 0, 0);\n\n      return canvas.toDataURL();\n    }\n\n    if (this.#isSvg) {\n      const [pageWidth, pageHeight] = this.pageDimensions;\n      // Multiply by PixelsPerInch.PDF_TO_CSS_UNITS in order to increase the\n      // image resolution when rasterizing it.\n      const width = Math.round(\n        this.width * pageWidth * PixelsPerInch.PDF_TO_CSS_UNITS\n      );\n      const height = Math.round(\n        this.height * pageHeight * PixelsPerInch.PDF_TO_CSS_UNITS\n      );\n      const offscreen = new OffscreenCanvas(width, height);\n      const ctx = offscreen.getContext(\"2d\");\n      ctx.drawImage(\n        this.#bitmap,\n        0,\n        0,\n        this.#bitmap.width,\n        this.#bitmap.height,\n        0,\n        0,\n        width,\n        height\n      );\n      return offscreen.transferToImageBitmap();\n    }\n\n    return structuredClone(this.#bitmap);\n  }\n\n  /** @inheritdoc */\n  static async deserialize(data, parent, uiManager) {\n    let initialData = null;\n    let missingCanvas = false;\n    if (data instanceof StampAnnotationElement) {\n      const {\n        data: {\n          rect,\n          rotation,\n          id,\n          structParent,\n          popupRef,\n          richText,\n          contentsObj,\n          creationDate,\n          modificationDate,\n        },\n        container,\n        parent: {\n          page: { pageNumber },\n        },\n        canvas,\n      } = data;\n      let bitmapId, bitmap;\n      if (canvas) {\n        delete data.canvas;\n        ({ id: bitmapId, bitmap } = uiManager.imageManager.getFromCanvas(\n          container.id,\n          canvas\n        ));\n        canvas.remove();\n      } else {\n        missingCanvas = true;\n        data._hasNoCanvas = true;\n      }\n\n      // When switching to edit mode, we wait for the structure tree to be\n      // ready (see pdf_viewer.js), so it's fine to use getAriaAttributesSync.\n      const altText =\n        (\n          await parent._structTree.getAriaAttributes(`${AnnotationPrefix}${id}`)\n        )?.get(\"aria-label\") || \"\";\n\n      initialData = data = {\n        annotationType: AnnotationEditorType.STAMP,\n        bitmapId,\n        bitmap,\n        pageIndex: pageNumber - 1,\n        rect: rect.slice(0),\n        rotation,\n        annotationElementId: id,\n        id,\n        deleted: false,\n        accessibilityData: {\n          decorative: false,\n          altText,\n        },\n        isSvg: false,\n        structParent,\n        popupRef,\n        richText,\n        comment: contentsObj?.str || null,\n        creationDate,\n        modificationDate,\n      };\n    }\n    const editor = await super.deserialize(data, parent, uiManager);\n    const { rect, bitmap, bitmapUrl, bitmapId, isSvg, accessibilityData } =\n      data;\n    if (missingCanvas) {\n      uiManager.addMissingCanvas(data.id, editor);\n      editor.#missingCanvas = true;\n    } else if (bitmapId && uiManager.imageManager.isValidId(bitmapId)) {\n      editor.#bitmapId = bitmapId;\n      if (bitmap) {\n        editor.#bitmap = bitmap;\n      }\n    } else {\n      editor.#bitmapUrl = bitmapUrl;\n    }\n    editor.#isSvg = isSvg;\n\n    const [parentWidth, parentHeight] = editor.pageDimensions;\n    editor.width = (rect[2] - rect[0]) / parentWidth;\n    editor.height = (rect[3] - rect[1]) / parentHeight;\n\n    if (accessibilityData) {\n      editor.altTextData = accessibilityData;\n    }\n    editor._initialData = initialData;\n    if (data.comment) {\n      editor.setCommentData(data);\n    }\n    // No need to be add in the undo stack if the editor is created from an\n    // existing one.\n    editor.#hasBeenAddedInUndoStack = !!initialData;\n\n    return editor;\n  }\n\n  /** @inheritdoc */\n  serialize(isForCopying = false, context = null) {\n    if (this.isEmpty()) {\n      return null;\n    }\n\n    if (this.deleted) {\n      return this.serializeDeleted();\n    }\n\n    const serialized = Object.assign(super.serialize(isForCopying), {\n      bitmapId: this.#bitmapId,\n      isSvg: this.#isSvg,\n    });\n    this.addComment(serialized);\n\n    if (isForCopying) {\n      // We don't know what's the final destination (this pdf or another one)\n      // of this annotation and the clipboard doesn't support ImageBitmaps,\n      // hence we serialize the bitmap to a data url.\n      serialized.bitmapUrl = this.#serializeBitmap(/* toUrl = */ true);\n      serialized.accessibilityData = this.serializeAltText(true);\n      serialized.isCopy = true;\n      return serialized;\n    }\n\n    const { decorative, altText } = this.serializeAltText(false);\n    if (!decorative && altText) {\n      serialized.accessibilityData = { type: \"Figure\", alt: altText };\n    }\n    if (this.annotationElementId) {\n      const changes = this.#hasElementChanged(serialized);\n      if (changes.isSame) {\n        // Nothing has been changed.\n        return null;\n      }\n      if (changes.isSameAltText) {\n        delete serialized.accessibilityData;\n      } else {\n        serialized.accessibilityData.structParent =\n          this._initialData.structParent ?? -1;\n      }\n      serialized.id = this.annotationElementId;\n      delete serialized.bitmapId;\n      return serialized;\n    }\n\n    if (context === null) {\n      return serialized;\n    }\n\n    context.stamps ||= new Map();\n    const area = this.#isSvg\n      ? (serialized.rect[2] - serialized.rect[0]) *\n        (serialized.rect[3] - serialized.rect[1])\n      : null;\n    if (!context.stamps.has(this.#bitmapId)) {\n      // We don't want to have multiple copies of the same bitmap in the\n      // annotationMap, hence we only add the bitmap the first time we meet it.\n      context.stamps.set(this.#bitmapId, { area, serialized });\n      serialized.bitmap = this.#serializeBitmap(/* toUrl = */ false);\n    } else if (this.#isSvg) {\n      // If we have multiple copies of the same svg but with different sizes,\n      // then we want to keep the biggest one.\n      const prevData = context.stamps.get(this.#bitmapId);\n      if (area > prevData.area) {\n        prevData.area = area;\n        prevData.serialized.bitmap.close();\n        prevData.serialized.bitmap = this.#serializeBitmap(/* toUrl = */ false);\n      }\n    }\n    return serialized;\n  }\n\n  #hasElementChanged(serialized) {\n    const {\n      pageIndex,\n      accessibilityData: { altText },\n    } = this._initialData;\n\n    const isSamePageIndex = serialized.pageIndex === pageIndex;\n    const isSameAltText = (serialized.accessibilityData?.alt || \"\") === altText;\n\n    return {\n      isSame:\n        !this.hasEditedComment &&\n        !this._hasBeenMoved &&\n        !this._hasBeenResized &&\n        isSamePageIndex &&\n        isSameAltText,\n      isSameAltText,\n    };\n  }\n\n  /** @inheritdoc */\n  renderAnnotationElement(annotation) {\n    if (this.deleted) {\n      annotation.hide();\n      return null;\n    }\n    annotation.updateEdited({\n      rect: this.getPDFRect(),\n      popup: this.comment,\n    });\n\n    return null;\n  }\n}\n\nexport { StampEditor };\n","/* Copyright 2022 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line max-len\n/** @typedef {import(\"./tools.js\").AnnotationEditorUIManager} AnnotationEditorUIManager */\n/** @typedef {import(\"../display_utils.js\").PageViewport} PageViewport */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../../web/text_accessibility.js\").TextAccessibilityManager} TextAccessibilityManager */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../annotation_layer.js\").AnnotationLayer} AnnotationLayer */\n/** @typedef {import(\"../draw_layer.js\").DrawLayer} DrawLayer */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"../../../web/struct_tree_layer_builder.js\").StructTreeLayerBuilder} StructTreeLayerBuilder */\n/** @typedef {import(\"../../../web/l10n.js\").L10n} L10n */\n\nimport {\n  AnnotationEditorPrefix,\n  AnnotationEditorType,\n  FeatureTest,\n} from \"../../shared/util.js\";\nimport { AnnotationEditor } from \"./editor.js\";\nimport { FreeTextEditor } from \"./freetext.js\";\nimport { HighlightEditor } from \"./highlight.js\";\nimport { InkEditor } from \"./ink.js\";\nimport { setLayerDimensions } from \"../display_utils.js\";\nimport { SignatureEditor } from \"./signature.js\";\nimport { StampEditor } from \"./stamp.js\";\n\n/**\n * @typedef {Object} AnnotationEditorLayerOptions\n * @property {Object} mode\n * @property {HTMLDivElement} div\n * @property {StructTreeLayerBuilder} structTreeLayer\n * @property {AnnotationEditorUIManager} uiManager\n * @property {boolean} enabled\n * @property {TextAccessibilityManager} [accessibilityManager]\n * @property {number} pageIndex\n * @property {L10n} l10n\n * @property {AnnotationLayer} [annotationLayer]\n * @property {HTMLDivElement} [textLayer]\n * @property {DrawLayer} drawLayer\n * @property {PageViewport} viewport\n */\n\n/**\n * @typedef {Object} RenderEditorLayerOptions\n * @property {PageViewport} viewport\n */\n\n/**\n * Manage all the different editors on a page.\n */\nclass AnnotationEditorLayer {\n  #accessibilityManager;\n\n  #allowClick = false;\n\n  #annotationLayer = null;\n\n  #clickAC = null;\n\n  #editorFocusTimeoutId = null;\n\n  #editors = new Map();\n\n  #hadPointerDown = false;\n\n  #isDisabling = false;\n\n  #isEnabling = false;\n\n  #drawingAC = null;\n\n  #focusedElement = null;\n\n  #textLayer = null;\n\n  #textSelectionAC = null;\n\n  #textLayerDblClickAC = null;\n\n  #lastPointerDownTimestamp = -1;\n\n  #uiManager;\n\n  static _initialized = false;\n\n  static #editorTypes = new Map(\n    [\n      FreeTextEditor,\n      InkEditor,\n      StampEditor,\n      HighlightEditor,\n      SignatureEditor,\n    ].map(type => [type._editorType, type])\n  );\n\n  /**\n   * @param {AnnotationEditorLayerOptions} options\n   */\n  constructor({\n    uiManager,\n    pageIndex,\n    div,\n    structTreeLayer,\n    accessibilityManager,\n    annotationLayer,\n    drawLayer,\n    textLayer,\n    viewport,\n    l10n,\n  }) {\n    const editorTypes = [...AnnotationEditorLayer.#editorTypes.values()];\n    if (!AnnotationEditorLayer._initialized) {\n      AnnotationEditorLayer._initialized = true;\n      for (const editorType of editorTypes) {\n        editorType.initialize(l10n, uiManager);\n      }\n    }\n    uiManager.registerEditorTypes(editorTypes);\n\n    this.#uiManager = uiManager;\n    this.pageIndex = pageIndex;\n    this.div = div;\n    this.#accessibilityManager = accessibilityManager;\n    this.#annotationLayer = annotationLayer;\n    this.viewport = viewport;\n    this.#textLayer = textLayer;\n    this.drawLayer = drawLayer;\n    this._structTree = structTreeLayer;\n\n    this.#uiManager.addLayer(this);\n  }\n\n  updatePageIndex(newPageIndex) {\n    for (const editor of this.#allEditorsIterator) {\n      editor.updatePageIndex(newPageIndex);\n    }\n\n    this.pageIndex = newPageIndex;\n    this.#uiManager.addLayer(this);\n  }\n\n  /**\n   * Clones all annotation editors from another layer into this layer.\n   * This is typically used when duplicating a page - the editors from the\n   * source page are serialized and then deserialized into the new page's layer.\n   *\n   * @param {AnnotationEditorLayer} clonedFrom - The source annotation editor\n   *   layer to clone editors from. If null or undefined, no action is taken.\n   * @returns {Promise<void>} A promise that resolves when all editors have been\n   *   cloned and added to this layer.\n   */\n  async setClonedFrom(clonedFrom) {\n    if (!clonedFrom) {\n      return;\n    }\n    const promises = [];\n    for (const editor of clonedFrom.#allEditorsIterator) {\n      const serialized = editor.serialize(/* isForCopying = */ true);\n      if (!serialized) {\n        continue;\n      }\n      serialized.isCopy = false;\n      promises.push(\n        this.deserialize(serialized).then(deserialized => {\n          if (deserialized) {\n            this.addOrRebuild(deserialized);\n          }\n        })\n      );\n    }\n    await Promise.all(promises);\n  }\n\n  get isEmpty() {\n    return this.#editors.size === 0;\n  }\n\n  get isInvisible() {\n    return (\n      this.isEmpty && this.#uiManager.getMode() === AnnotationEditorType.NONE\n    );\n  }\n\n  /**\n   * Update the toolbar if it's required to reflect the tool currently used.\n   * @param {Object} options\n   */\n  updateToolbar(options) {\n    this.#uiManager.updateToolbar(options);\n  }\n\n  /**\n   * The mode has changed: it must be updated.\n   * @param {number} mode\n   */\n  updateMode(mode = this.#uiManager.getMode()) {\n    this.#cleanup();\n    switch (mode) {\n      case AnnotationEditorType.NONE:\n        this.div.classList.toggle(\"nonEditing\", true);\n        this.disableTextSelection();\n        this.togglePointerEvents(false);\n        this.toggleAnnotationLayerPointerEvents(true);\n        this.disableClick();\n        return;\n      case AnnotationEditorType.INK:\n        this.disableTextSelection();\n        this.togglePointerEvents(true);\n        this.enableClick();\n        break;\n      case AnnotationEditorType.HIGHLIGHT:\n        this.enableTextSelection();\n        this.togglePointerEvents(false);\n        this.disableClick();\n        break;\n      default:\n        this.disableTextSelection();\n        this.togglePointerEvents(true);\n        this.enableClick();\n    }\n\n    this.toggleAnnotationLayerPointerEvents(false);\n    const { classList } = this.div;\n    classList.toggle(\"nonEditing\", false);\n    if (mode === AnnotationEditorType.POPUP) {\n      classList.toggle(\"commentEditing\", true);\n    } else {\n      classList.toggle(\"commentEditing\", false);\n      for (const editorType of AnnotationEditorLayer.#editorTypes.values()) {\n        classList.toggle(\n          `${editorType._type}Editing`,\n          mode === editorType._editorType\n        );\n      }\n    }\n    this.div.hidden = false;\n  }\n\n  hasTextLayer(textLayer) {\n    return textLayer === this.#textLayer?.div;\n  }\n\n  /**\n   * Set the editing state.\n   * @param {boolean} isEditing\n   */\n  setEditingState(isEditing) {\n    this.#uiManager.setEditingState(isEditing);\n  }\n\n  /**\n   * Add some commands into the CommandManager (undo/redo stuff).\n   * @param {Object} params\n   */\n  addCommands(params) {\n    this.#uiManager.addCommands(params);\n  }\n\n  cleanUndoStack(type) {\n    this.#uiManager.cleanUndoStack(type);\n  }\n\n  toggleDrawing(enabled = false) {\n    this.div.classList.toggle(\"drawing\", !enabled);\n  }\n\n  togglePointerEvents(enabled = false) {\n    this.div.classList.toggle(\"disabled\", !enabled);\n  }\n\n  toggleAnnotationLayerPointerEvents(enabled = false) {\n    this.#annotationLayer?.togglePointerEvents(enabled);\n  }\n\n  get #allEditorsIterator() {\n    return this.#editors.size !== 0\n      ? this.#editors.values()\n      : this.#uiManager.getEditors(this.pageIndex);\n  }\n\n  /**\n   * Enable pointer events on the main div in order to enable\n   * editor creation.\n   */\n  async enable() {\n    this.#isEnabling = true;\n    this.div.tabIndex = 0;\n    this.togglePointerEvents(true);\n    this.div.classList.toggle(\"nonEditing\", false);\n    this.#textLayerDblClickAC?.abort();\n    this.#textLayerDblClickAC = null;\n    const annotationElementIds = new Set();\n    for (const editor of this.#allEditorsIterator) {\n      editor.enableEditing();\n      editor.show(true);\n      if (editor.annotationElementId) {\n        this.#uiManager.removeChangedExistingAnnotation(editor);\n        annotationElementIds.add(editor.annotationElementId);\n      }\n    }\n\n    const annotationLayer = this.#annotationLayer;\n    if (annotationLayer) {\n      for (const editable of annotationLayer.getEditableAnnotations()) {\n        // The element must be hidden whatever its state is.\n        editable.hide();\n        if (this.#uiManager.isDeletedAnnotationElement(editable.data.id)) {\n          continue;\n        }\n        if (annotationElementIds.has(editable.data.id)) {\n          continue;\n        }\n        const editor = await this.deserialize(editable);\n        if (!editor) {\n          continue;\n        }\n        this.addOrRebuild(editor);\n        editor.enableEditing();\n      }\n    }\n    this.#isEnabling = false;\n    this.#uiManager._eventBus.dispatch(\"editorsrendered\", {\n      source: this,\n      pageNumber: this.pageIndex + 1,\n    });\n  }\n\n  /**\n   * Disable editor creation.\n   */\n  disable() {\n    this.#isDisabling = true;\n    this.div.tabIndex = -1;\n    this.togglePointerEvents(false);\n    this.div.classList.toggle(\"nonEditing\", true);\n    if (this.#textLayer && !this.#textLayerDblClickAC) {\n      this.#textLayerDblClickAC = new AbortController();\n      const signal = this.#uiManager.combinedSignal(this.#textLayerDblClickAC);\n      this.#textLayer.div.addEventListener(\n        \"pointerdown\",\n        e => {\n          // It's the default value in Fenix:\n          // https://searchfox.org/mozilla-central/rev/beba5cde846f944c4d709e75cbe499d17af880a4/modules/libpref/init/StaticPrefList.yaml#19064\n          // and in Chrome and Windows:\n          // https://source.chromium.org/chromium/chromium/src/+/main:ui/events/event_constants.h;drc=f0f5f3ceebb00da9363ccc7a1e2c0f17b6b383ba;l=115\n          const DBL_CLICK_THRESHOLD = 500;\n          const { clientX, clientY, timeStamp } = e;\n          const lastPointerDownTimestamp = this.#lastPointerDownTimestamp;\n          if (timeStamp - lastPointerDownTimestamp > DBL_CLICK_THRESHOLD) {\n            this.#lastPointerDownTimestamp = timeStamp;\n            return;\n          }\n          this.#lastPointerDownTimestamp = -1;\n          const { classList } = this.div;\n          classList.toggle(\"getElements\", true);\n          const elements = document.elementsFromPoint(clientX, clientY);\n          classList.toggle(\"getElements\", false);\n          if (!this.div.contains(elements[0])) {\n            return;\n          }\n          let id;\n          const regex = new RegExp(`^${AnnotationEditorPrefix}[0-9]+$`);\n          for (const element of elements) {\n            if (regex.test(element.id)) {\n              id = element.id;\n              break;\n            }\n          }\n          if (!id) {\n            return;\n          }\n          const editor = this.#editors.get(id);\n          if (editor?.annotationElementId === null) {\n            e.stopPropagation();\n            e.preventDefault();\n            editor.dblclick(e);\n          }\n        },\n        { signal, capture: true }\n      );\n    }\n\n    const annotationLayer = this.#annotationLayer;\n    const needFakeAnnotation = [];\n    if (annotationLayer) {\n      const changedAnnotations = new Map();\n      const resetAnnotations = new Map();\n      for (const editor of this.#allEditorsIterator) {\n        editor.disableEditing();\n        if (!editor.annotationElementId) {\n          needFakeAnnotation.push(editor);\n          continue;\n        }\n        if (editor.serialize() !== null) {\n          changedAnnotations.set(editor.annotationElementId, editor);\n          continue;\n        } else {\n          resetAnnotations.set(editor.annotationElementId, editor);\n        }\n        this.getEditableAnnotation(editor.annotationElementId)?.show();\n        editor.remove();\n      }\n\n      // Show the annotations that were hidden in enable().\n      const editables = annotationLayer.getEditableAnnotations();\n      for (const editable of editables) {\n        const { id } = editable.data;\n        if (this.#uiManager.isDeletedAnnotationElement(id)) {\n          editable.updateEdited({ deleted: true });\n          continue;\n        }\n        let editor = resetAnnotations.get(id);\n        if (editor) {\n          editor.resetAnnotationElement(editable);\n          editor.show(false);\n          editable.show();\n          continue;\n        }\n\n        editor = changedAnnotations.get(id);\n        if (editor) {\n          this.#uiManager.addChangedExistingAnnotation(editor);\n          if (editor.renderAnnotationElement(editable)) {\n            // Content has changed, so we need to hide the editor.\n            editor.show(false);\n          }\n        }\n        editable.show();\n      }\n    }\n\n    this.#cleanup();\n    if (this.isEmpty) {\n      this.div.hidden = true;\n    }\n    const { classList } = this.div;\n    for (const editorType of AnnotationEditorLayer.#editorTypes.values()) {\n      classList.remove(`${editorType._type}Editing`);\n    }\n    this.disableTextSelection();\n    this.toggleAnnotationLayerPointerEvents(true);\n    annotationLayer?.updateFakeAnnotations(needFakeAnnotation);\n\n    this.#isDisabling = false;\n  }\n\n  getEditableAnnotation(id) {\n    return this.#annotationLayer?.getEditableAnnotation(id) || null;\n  }\n\n  /**\n   * Set the current editor.\n   * @param {AnnotationEditor} editor\n   */\n  setActiveEditor(editor) {\n    const currentActive = this.#uiManager.getActive();\n    if (currentActive === editor) {\n      return;\n    }\n\n    this.#uiManager.setActiveEditor(editor);\n  }\n\n  enableTextSelection() {\n    this.div.tabIndex = -1;\n    if (this.#textLayer?.div && !this.#textSelectionAC) {\n      this.#textSelectionAC = new AbortController();\n      const signal = this.#uiManager.combinedSignal(this.#textSelectionAC);\n\n      this.#textLayer.div.addEventListener(\n        \"pointerdown\",\n        this.#textLayerPointerDown.bind(this),\n        { signal }\n      );\n      this.#textLayer.div.classList.add(\"highlighting\");\n    }\n  }\n\n  disableTextSelection() {\n    this.div.tabIndex = 0;\n    if (this.#textLayer?.div && this.#textSelectionAC) {\n      this.#textSelectionAC.abort();\n      this.#textSelectionAC = null;\n\n      this.#textLayer.div.classList.remove(\"highlighting\");\n    }\n  }\n\n  #textLayerPointerDown(event) {\n    // Unselect all the editors in order to let the user select some text\n    // without being annoyed by an editor toolbar.\n    this.#uiManager.unselectAll();\n    const { target } = event;\n    if (\n      target === this.#textLayer.div ||\n      ((target.getAttribute(\"role\") === \"img\" ||\n        target.classList.contains(\"endOfContent\")) &&\n        this.#textLayer.div.contains(target))\n    ) {\n      const { isMac } = FeatureTest.platform;\n      if (event.button !== 0 || (event.ctrlKey && isMac)) {\n        // Do nothing on right click.\n        return;\n      }\n      this.#uiManager.showAllEditors(\n        \"highlight\",\n        true,\n        /* updateButton = */ true\n      );\n      this.#textLayer.div.classList.add(\"free\");\n      this.toggleDrawing();\n      HighlightEditor.startHighlighting(\n        this,\n        this.#uiManager.direction === \"ltr\",\n        { target: this.#textLayer.div, x: event.x, y: event.y }\n      );\n      this.#textLayer.div.addEventListener(\n        \"pointerup\",\n        () => {\n          this.#textLayer.div.classList.remove(\"free\");\n          this.toggleDrawing(true);\n        },\n        { once: true, signal: this.#uiManager._signal }\n      );\n      event.preventDefault();\n    }\n  }\n\n  enableClick() {\n    if (this.#clickAC) {\n      return;\n    }\n    this.#clickAC = new AbortController();\n    const signal = this.#uiManager.combinedSignal(this.#clickAC);\n\n    this.div.addEventListener(\"pointerdown\", this.pointerdown.bind(this), {\n      signal,\n    });\n    const pointerup = this.pointerup.bind(this);\n    this.div.addEventListener(\"pointerup\", pointerup, { signal });\n    this.div.addEventListener(\"pointercancel\", pointerup, { signal });\n  }\n\n  disableClick() {\n    this.#clickAC?.abort();\n    this.#clickAC = null;\n  }\n\n  attach(editor) {\n    this.#editors.set(editor.id, editor);\n    const { annotationElementId } = editor;\n    if (\n      annotationElementId &&\n      this.#uiManager.isDeletedAnnotationElement(annotationElementId)\n    ) {\n      this.#uiManager.removeDeletedAnnotationElement(editor);\n    }\n  }\n\n  detach(editor) {\n    this.#editors.delete(editor.id);\n    this.#accessibilityManager?.removePointerInTextLayer(editor.contentDiv);\n\n    if (!this.#isDisabling && editor.annotationElementId) {\n      this.#uiManager.addDeletedAnnotationElement(editor);\n    }\n  }\n\n  /**\n   * Remove an editor.\n   * @param {AnnotationEditor} editor\n   */\n  remove(editor) {\n    this.detach(editor);\n    this.#uiManager.removeEditor(editor);\n    editor.div.remove();\n    editor.isAttachedToDOM = false;\n  }\n\n  /**\n   * An editor can have a different parent, for example after having\n   * being dragged and dropped from a page to another.\n   * @param {AnnotationEditor} editor\n   */\n  changeParent(editor) {\n    if (editor.parent === this) {\n      return;\n    }\n\n    if (editor.parent && editor.annotationElementId) {\n      this.#uiManager.addDeletedAnnotationElement(editor);\n      AnnotationEditor.deleteAnnotationElement(editor);\n      editor.annotationElementId = null;\n    }\n\n    this.attach(editor);\n    editor.parent?.detach(editor);\n    editor.setParent(this);\n    if (editor.div && editor.isAttachedToDOM) {\n      editor.div.remove();\n      this.div.append(editor.div);\n    }\n  }\n\n  /**\n   * Add a new editor in the current view.\n   * @param {AnnotationEditor} editor\n   */\n  add(editor) {\n    if (editor.parent === this && editor.isAttachedToDOM) {\n      return;\n    }\n    this.changeParent(editor);\n    this.#uiManager.addEditor(editor);\n    this.attach(editor);\n\n    if (!editor.isAttachedToDOM) {\n      const div = editor.render();\n      this.div.append(div);\n      editor.isAttachedToDOM = true;\n    }\n\n    // The editor will be correctly moved into the DOM (see fixAndSetPosition).\n    editor.fixAndSetPosition();\n    editor.onceAdded(/* focus = */ !this.#isEnabling);\n    this.#uiManager.addToAnnotationStorage(editor);\n    editor._reportTelemetry(editor.telemetryInitialData);\n  }\n\n  moveEditorInDOM(editor) {\n    if (!editor.isAttachedToDOM) {\n      return;\n    }\n\n    const { activeElement } = document;\n    if (editor.div.contains(activeElement) && !this.#editorFocusTimeoutId) {\n      // When the div is moved in the DOM the focus can move somewhere else,\n      // so we want to be sure that the focus will stay on the editor but we\n      // don't want to call any focus callbacks, hence we disable them and only\n      // re-enable them when the editor has the focus.\n      editor._focusEventsAllowed = false;\n      this.#editorFocusTimeoutId = setTimeout(() => {\n        this.#editorFocusTimeoutId = null;\n        if (!editor.div.contains(document.activeElement)) {\n          editor.div.addEventListener(\n            \"focusin\",\n            () => {\n              editor._focusEventsAllowed = true;\n            },\n            { once: true, signal: this.#uiManager._signal }\n          );\n          activeElement.focus();\n        } else {\n          editor._focusEventsAllowed = true;\n        }\n      }, 0);\n    }\n\n    editor._structTreeParentId = this.#accessibilityManager?.moveElementInDOM(\n      this.div,\n      editor.div,\n      editor.contentDiv,\n      /* isRemovable = */ true\n    );\n  }\n\n  /**\n   * Add or rebuild depending if it has been removed or not.\n   * @param {AnnotationEditor} editor\n   */\n  addOrRebuild(editor) {\n    if (editor.needsToBeRebuilt()) {\n      editor.parent ||= this;\n      editor.rebuild();\n      editor.show();\n    } else {\n      this.add(editor);\n    }\n  }\n\n  /**\n   * Add a new editor and make this addition undoable.\n   * @param {AnnotationEditor} editor\n   */\n  addUndoableEditor(editor) {\n    const cmd = () => editor._uiManager.rebuild(editor);\n    const undo = () => {\n      editor.remove();\n    };\n\n    this.addCommands({ cmd, undo, mustExec: false });\n  }\n\n  getEditorByUID(uid) {\n    for (const editor of this.#editors.values()) {\n      if (editor.uid === uid) {\n        return editor;\n      }\n    }\n    return null;\n  }\n\n  /**\n   * Get an id for an editor.\n   * @returns {string}\n   */\n  getNextId() {\n    return this.#uiManager.getId();\n  }\n\n  get #currentEditorType() {\n    return AnnotationEditorLayer.#editorTypes.get(this.#uiManager.getMode());\n  }\n\n  combinedSignal(ac) {\n    return this.#uiManager.combinedSignal(ac);\n  }\n\n  /**\n   * Create a new editor\n   * @param {Object} params\n   * @returns {AnnotationEditor}\n   */\n  #createNewEditor(params) {\n    const editorType = this.#currentEditorType;\n    return editorType ? new editorType.prototype.constructor(params) : null;\n  }\n\n  canCreateNewEmptyEditor() {\n    return this.#currentEditorType?.canCreateNewEmptyEditor();\n  }\n\n  /**\n   * Paste some content into a new editor.\n   * @param {Object} options\n   * @param {Object} params\n   */\n  async pasteEditor(options, params) {\n    this.updateToolbar(options);\n    await this.#uiManager.updateMode(options.mode);\n\n    const { offsetX, offsetY } = this.#getCenterPoint();\n    const id = this.getNextId();\n    const editor = this.#createNewEditor({\n      parent: this,\n      id,\n      x: offsetX,\n      y: offsetY,\n      uiManager: this.#uiManager,\n      isCentered: true,\n      ...params,\n    });\n    if (editor) {\n      this.add(editor);\n    }\n  }\n\n  /**\n   * Create a new editor\n   * @param {Object} data\n   * @returns {Promise<AnnotationEditor | null>}\n   */\n  async deserialize(data) {\n    return (\n      (await AnnotationEditorLayer.#editorTypes\n        .get(data.annotationType ?? data.annotationEditorType)\n        ?.deserialize(data, this, this.#uiManager)) || null\n    );\n  }\n\n  /**\n   * Create and add a new editor.\n   * @param {PointerEvent} event\n   * @param {boolean} isCentered\n   * @param [Object] data\n   * @returns {AnnotationEditor}\n   */\n  createAndAddNewEditor(event, isCentered, data = {}) {\n    const id = this.getNextId();\n    const editor = this.#createNewEditor({\n      parent: this,\n      id,\n      x: event.offsetX,\n      y: event.offsetY,\n      uiManager: this.#uiManager,\n      isCentered,\n      ...data,\n    });\n    if (editor) {\n      this.add(editor);\n    }\n\n    return editor;\n  }\n\n  get boundingClientRect() {\n    return this.div.getBoundingClientRect();\n  }\n\n  #getCenterPoint() {\n    const { x, y, width, height } = this.boundingClientRect;\n    const tlX = Math.max(0, x);\n    const tlY = Math.max(0, y);\n    const brX = Math.min(window.innerWidth, x + width);\n    const brY = Math.min(window.innerHeight, y + height);\n    const centerX = (tlX + brX) / 2 - x;\n    const centerY = (tlY + brY) / 2 - y;\n    const [offsetX, offsetY] =\n      this.viewport.rotation % 180 === 0\n        ? [centerX, centerY]\n        : [centerY, centerX];\n\n    return { offsetX, offsetY };\n  }\n\n  /**\n   * Create and add a new editor.\n   */\n  addNewEditor(data = {}) {\n    this.createAndAddNewEditor(\n      this.#getCenterPoint(),\n      /* isCentered = */ true,\n      data\n    );\n  }\n\n  /**\n   * Set the last selected editor.\n   * @param {AnnotationEditor} editor\n   */\n  setSelected(editor) {\n    this.#uiManager.setSelected(editor);\n  }\n\n  /**\n   * Add or remove an editor the current selection.\n   * @param {AnnotationEditor} editor\n   */\n  toggleSelected(editor) {\n    this.#uiManager.toggleSelected(editor);\n  }\n\n  /**\n   * Unselect an editor.\n   * @param {AnnotationEditor} editor\n   */\n  unselect(editor) {\n    this.#uiManager.unselect(editor);\n  }\n\n  /**\n   * Pointerup callback.\n   * @param {PointerEvent} event\n   */\n  pointerup(event) {\n    const { isMac } = FeatureTest.platform;\n    if (event.button !== 0 || (event.ctrlKey && isMac)) {\n      // Don't create an editor on right click.\n      return;\n    }\n\n    if (event.target !== this.div) {\n      return;\n    }\n\n    if (!this.#hadPointerDown) {\n      // It can happen when the user starts a drag inside a text editor\n      // and then releases the mouse button outside of it. In such a case\n      // we don't want to create a new editor, hence we check that a pointerdown\n      // occurred on this div previously.\n      return;\n    }\n    this.#hadPointerDown = false;\n\n    if (\n      this.#currentEditorType?.isDrawer &&\n      this.#currentEditorType.supportMultipleDrawings\n    ) {\n      return;\n    }\n\n    if (!this.#allowClick) {\n      this.#allowClick = true;\n      return;\n    }\n\n    const currentMode = this.#uiManager.getMode();\n    if (\n      currentMode === AnnotationEditorType.STAMP ||\n      currentMode === AnnotationEditorType.SIGNATURE\n    ) {\n      this.#uiManager.unselectAll();\n      return;\n    }\n\n    this.createAndAddNewEditor(event, /* isCentered = */ false);\n  }\n\n  /**\n   * Pointerdown callback.\n   * @param {PointerEvent} event\n   */\n  pointerdown(event) {\n    if (this.#uiManager.getMode() === AnnotationEditorType.HIGHLIGHT) {\n      this.enableTextSelection();\n    }\n    if (this.#hadPointerDown) {\n      // It's possible to have a second pointerdown event before a pointerup one\n      // when the user puts a finger on a touchscreen and then add a second one\n      // to start a pinch-to-zoom gesture.\n      // That said, in case it's possible to have two pointerdown events with\n      // a mouse, we don't want to create a new editor in such a case either.\n      this.#hadPointerDown = false;\n      return;\n    }\n    const { isMac } = FeatureTest.platform;\n    if (event.button !== 0 || (event.ctrlKey && isMac)) {\n      // Do nothing on right click.\n      return;\n    }\n\n    if (event.target !== this.div) {\n      return;\n    }\n\n    this.#hadPointerDown = true;\n\n    if (this.#currentEditorType?.isDrawer) {\n      this.startDrawingSession(event);\n      return;\n    }\n\n    const editor = this.#uiManager.getActive();\n    this.#allowClick = !editor || editor.isEmpty();\n  }\n\n  startDrawingSession(event) {\n    this.div.focus({\n      preventScroll: true,\n    });\n    if (this.#drawingAC) {\n      this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);\n      return;\n    }\n\n    this.#uiManager.setCurrentDrawingSession(this);\n    this.#drawingAC = new AbortController();\n    const signal = this.#uiManager.combinedSignal(this.#drawingAC);\n    this.div.addEventListener(\n      \"blur\",\n      ({ relatedTarget }) => {\n        if (relatedTarget && !this.div.contains(relatedTarget)) {\n          this.#focusedElement = null;\n          this.commitOrRemove();\n        }\n      },\n      { signal }\n    );\n    this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);\n  }\n\n  pause(on) {\n    if (on) {\n      const { activeElement } = document;\n      if (this.div.contains(activeElement)) {\n        this.#focusedElement = activeElement;\n      }\n      return;\n    }\n    if (this.#focusedElement) {\n      setTimeout(() => {\n        this.#focusedElement?.focus();\n        this.#focusedElement = null;\n      }, 0);\n    }\n  }\n\n  endDrawingSession(isAborted = false) {\n    if (!this.#drawingAC) {\n      return null;\n    }\n    this.#uiManager.setCurrentDrawingSession(null);\n    this.#drawingAC.abort();\n    this.#drawingAC = null;\n    this.#focusedElement = null;\n    return this.#currentEditorType.endDrawing(isAborted);\n  }\n\n  /**\n   *\n   * @param {AnnotationEditor} editor\n   * @param {number} x\n   * @param {number} y\n   * @returns\n   */\n  findNewParent(editor, x, y) {\n    const layer = this.#uiManager.findParent(x, y);\n    if (layer === null || layer === this) {\n      return false;\n    }\n    layer.changeParent(editor);\n    return true;\n  }\n\n  commitOrRemove() {\n    if (this.#drawingAC) {\n      this.endDrawingSession();\n      return true;\n    }\n    return false;\n  }\n\n  onScaleChanging() {\n    if (!this.#drawingAC) {\n      return;\n    }\n    this.#currentEditorType.onScaleChangingWhenDrawing(this);\n  }\n\n  /**\n   * Destroy the main editor.\n   */\n  destroy() {\n    this.commitOrRemove();\n    if (this.#uiManager.getActive()?.parent === this) {\n      // We need to commit the current editor before destroying the layer.\n      this.#uiManager.commitOrRemove();\n      this.#uiManager.setActiveEditor(null);\n    }\n\n    if (this.#editorFocusTimeoutId) {\n      clearTimeout(this.#editorFocusTimeoutId);\n      this.#editorFocusTimeoutId = null;\n    }\n\n    for (const editor of this.#editors.values()) {\n      this.#accessibilityManager?.removePointerInTextLayer(editor.contentDiv);\n      editor.setParent(null);\n      editor.isAttachedToDOM = false;\n      editor.div.remove();\n    }\n    this.div = null;\n    this.#editors.clear();\n    this.#uiManager.removeLayer(this);\n  }\n\n  #cleanup() {\n    // When we're cleaning up, some editors are removed but we don't want\n    // to add a new one which will induce an addition in this.#editors, hence\n    // an infinite loop.\n    for (const editor of this.#editors.values()) {\n      if (editor.isEmpty()) {\n        editor.remove();\n      }\n    }\n  }\n\n  /**\n   * Render the main editor.\n   * @param {RenderEditorLayerOptions} parameters\n   */\n  render({ viewport }) {\n    this.viewport = viewport;\n    setLayerDimensions(this.div, viewport);\n    for (const editor of this.#uiManager.getEditors(this.pageIndex)) {\n      this.add(editor);\n      editor.rebuild();\n    }\n    // We're maybe rendering a layer which was invisible when we started to edit\n    // so we must set the different callbacks for it.\n    this.updateMode();\n  }\n\n  /**\n   * Update the main editor.\n   * @param {RenderEditorLayerOptions} parameters\n   */\n  update({ viewport }) {\n    // Editors have their dimensions/positions in percent so to avoid any\n    // issues (see #15582), we must commit the current one before changing\n    // the viewport.\n    this.#uiManager.commitOrRemove();\n    this.#cleanup();\n\n    const oldRotation = this.viewport.rotation;\n    const rotation = viewport.rotation;\n\n    this.viewport = viewport;\n    setLayerDimensions(this.div, { rotation });\n    if (oldRotation !== rotation) {\n      for (const editor of this.#editors.values()) {\n        editor.rotate(rotation);\n      }\n    }\n  }\n\n  /**\n   * Get page dimensions.\n   * @returns {Object} dimensions.\n   */\n  get pageDimensions() {\n    const { pageWidth, pageHeight } = this.viewport.rawDims;\n    return [pageWidth, pageHeight];\n  }\n\n  get scale() {\n    return this.#uiManager.viewParameters.realScale;\n  }\n}\n\nexport { AnnotationEditorLayer };\n","/* Copyright 2023 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DOMSVGFactory } from \"./svg_factory.js\";\nimport { shadow } from \"../shared/util.js\";\n\n/**\n * Manage the SVGs drawn on top of the page canvas.\n * It's important to have them directly on top of the canvas because we want to\n * be able to use mix-blend-mode for some of them.\n */\nclass DrawLayer {\n  #parent = null;\n\n  #mapping = new Map();\n\n  #toUpdate = new Map();\n\n  static #id = 0;\n\n  setParent(parent) {\n    if (!this.#parent) {\n      this.#parent = parent;\n      return;\n    }\n\n    if (this.#parent !== parent) {\n      if (this.#mapping.size > 0) {\n        for (const root of this.#mapping.values()) {\n          root.remove();\n          parent.append(root);\n        }\n      }\n      this.#parent = parent;\n    }\n  }\n\n  static get _svgFactory() {\n    return shadow(this, \"_svgFactory\", new DOMSVGFactory());\n  }\n\n  static #setBox(element, [x, y, width, height]) {\n    const { style } = element;\n    style.top = `${100 * y}%`;\n    style.left = `${100 * x}%`;\n    style.width = `${100 * width}%`;\n    style.height = `${100 * height}%`;\n  }\n\n  #createSVG() {\n    const svg = DrawLayer._svgFactory.create(1, 1, /* skipDimensions = */ true);\n    this.#parent.append(svg);\n    svg.setAttribute(\"aria-hidden\", true);\n\n    return svg;\n  }\n\n  #createClipPath(defs, pathId) {\n    const clipPath = DrawLayer._svgFactory.createElement(\"clipPath\");\n    defs.append(clipPath);\n    const clipPathId = `clip_${pathId}`;\n    clipPath.setAttribute(\"id\", clipPathId);\n    clipPath.setAttribute(\"clipPathUnits\", \"objectBoundingBox\");\n    const clipPathUse = DrawLayer._svgFactory.createElement(\"use\");\n    clipPath.append(clipPathUse);\n    clipPathUse.setAttribute(\"href\", `#${pathId}`);\n    clipPathUse.classList.add(\"clip\");\n\n    return clipPathId;\n  }\n\n  #updateProperties(element, properties) {\n    for (const [key, value] of Object.entries(properties)) {\n      if (value === null) {\n        element.removeAttribute(key);\n      } else {\n        element.setAttribute(key, value);\n      }\n    }\n  }\n\n  draw(properties, isPathUpdatable = false, hasClip = false) {\n    const id = DrawLayer.#id++;\n    const root = this.#createSVG();\n\n    const defs = DrawLayer._svgFactory.createElement(\"defs\");\n    root.append(defs);\n    const path = DrawLayer._svgFactory.createElement(\"path\");\n    defs.append(path);\n    const pathId = `path_${id}`;\n    path.setAttribute(\"id\", pathId);\n    path.setAttribute(\"vector-effect\", \"non-scaling-stroke\");\n\n    if (isPathUpdatable) {\n      this.#toUpdate.set(id, path);\n    }\n\n    // Create the clipping path for the editor div.\n    const clipPathId = hasClip ? this.#createClipPath(defs, pathId) : null;\n\n    const use = DrawLayer._svgFactory.createElement(\"use\");\n    root.append(use);\n    use.setAttribute(\"href\", `#${pathId}`);\n    this.updateProperties(root, properties);\n\n    this.#mapping.set(id, root);\n\n    return { id, clipPathId: `url(#${clipPathId})` };\n  }\n\n  drawOutline(properties, mustRemoveSelfIntersections) {\n    // We cannot draw the outline directly in the SVG for highlights because\n    // it composes with its parent with mix-blend-mode: multiply.\n    // But the outline has a different mix-blend-mode, so we need to draw it in\n    // its own SVG.\n    const id = DrawLayer.#id++;\n    const root = this.#createSVG();\n    const defs = DrawLayer._svgFactory.createElement(\"defs\");\n    root.append(defs);\n    const path = DrawLayer._svgFactory.createElement(\"path\");\n    defs.append(path);\n    const pathId = `path_${id}`;\n    path.setAttribute(\"id\", pathId);\n    path.setAttribute(\"vector-effect\", \"non-scaling-stroke\");\n\n    let maskId;\n    if (mustRemoveSelfIntersections) {\n      const mask = DrawLayer._svgFactory.createElement(\"mask\");\n      defs.append(mask);\n      maskId = `mask_${id}`;\n      mask.setAttribute(\"id\", maskId);\n      mask.setAttribute(\"maskUnits\", \"objectBoundingBox\");\n      const rect = DrawLayer._svgFactory.createElement(\"rect\");\n      mask.append(rect);\n      rect.setAttribute(\"width\", \"1\");\n      rect.setAttribute(\"height\", \"1\");\n      rect.setAttribute(\"fill\", \"white\");\n      const use = DrawLayer._svgFactory.createElement(\"use\");\n      mask.append(use);\n      use.setAttribute(\"href\", `#${pathId}`);\n      use.setAttribute(\"stroke\", \"none\");\n      use.setAttribute(\"fill\", \"black\");\n      use.setAttribute(\"fill-rule\", \"nonzero\");\n      use.classList.add(\"mask\");\n    }\n\n    const use1 = DrawLayer._svgFactory.createElement(\"use\");\n    root.append(use1);\n    use1.setAttribute(\"href\", `#${pathId}`);\n    if (maskId) {\n      use1.setAttribute(\"mask\", `url(#${maskId})`);\n    }\n    const use2 = use1.cloneNode();\n    root.append(use2);\n    use1.classList.add(\"mainOutline\");\n    use2.classList.add(\"secondaryOutline\");\n\n    this.updateProperties(root, properties);\n\n    this.#mapping.set(id, root);\n\n    return id;\n  }\n\n  finalizeDraw(id, properties) {\n    this.#toUpdate.delete(id);\n    this.updateProperties(id, properties);\n  }\n\n  updateProperties(elementOrId, properties) {\n    if (!properties) {\n      return;\n    }\n    const { root, bbox, rootClass, path } = properties;\n    const element =\n      typeof elementOrId === \"number\"\n        ? this.#mapping.get(elementOrId)\n        : elementOrId;\n    if (!element) {\n      return;\n    }\n    if (root) {\n      this.#updateProperties(element, root);\n    }\n    if (bbox) {\n      DrawLayer.#setBox(element, bbox);\n    }\n    if (rootClass) {\n      const { classList } = element;\n      for (const [className, value] of Object.entries(rootClass)) {\n        classList.toggle(className, value);\n      }\n    }\n    if (path) {\n      const defs = element.firstElementChild;\n      const pathElement = defs.firstElementChild;\n      this.#updateProperties(pathElement, path);\n    }\n  }\n\n  updateParent(id, layer) {\n    if (layer === this) {\n      return;\n    }\n    const root = this.#mapping.get(id);\n    if (!root) {\n      return;\n    }\n    layer.#parent.append(root);\n    this.#mapping.delete(id);\n    layer.#mapping.set(id, root);\n  }\n\n  remove(id) {\n    this.#toUpdate.delete(id);\n    if (this.#parent === null) {\n      return;\n    }\n    this.#mapping.get(id).remove();\n    this.#mapping.delete(id);\n  }\n\n  destroy() {\n    this.#parent = null;\n    for (const root of this.#mapping.values()) {\n      root.remove();\n    }\n    this.#mapping.clear();\n    this.#toUpdate.clear();\n  }\n}\n\nexport { DrawLayer };\n","/* Copyright 2012 Mozilla Foundation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line max-len\n/** @typedef {import(\"./display/api\").OnProgressParameters} OnProgressParameters */\n// eslint-disable-next-line max-len\n/** @typedef {import(\"./display/api\").PDFDocumentLoadingTask} PDFDocumentLoadingTask */\n/** @typedef {import(\"./display/api\").PDFDocumentProxy} PDFDocumentProxy */\n/** @typedef {import(\"./display/api\").PDFPageProxy} PDFPageProxy */\n/** @typedef {import(\"./display/api\").RenderTask} RenderTask */\n/** @typedef {import(\"./display/display_utils\").PageViewport} PageViewport */\n\nimport {\n  AbortException,\n  AnnotationEditorParamsType,\n  AnnotationEditorType,\n  AnnotationMode,\n  AnnotationType,\n  createValidAbsoluteUrl,\n  FeatureTest,\n  getUuid,\n  ImageKind,\n  InvalidPDFException,\n  makeArr,\n  makeMap,\n  makeObj,\n  MathClamp,\n  normalizeUnicode,\n  OPS,\n  PasswordResponses,\n  PermissionFlag,\n  ResponseException,\n  shadow,\n  updateUrlHash,\n  Util,\n  VerbosityLevel,\n} from \"./shared/util.js\";\nimport {\n  applyOpacity,\n  CSSConstants,\n  fetchData,\n  findContrastColor,\n  getFilenameFromUrl,\n  getPdfFilenameFromUrl,\n  getRGB,\n  getXfaPageViewport,\n  isDataScheme,\n  isPdfFile,\n  noContextMenu,\n  OutputScale,\n  PDFDateString,\n  PixelsPerInch,\n  RenderingCancelledException,\n  renderRichText,\n  setLayerDimensions,\n  stopEvent,\n  SupportedImageMimeTypes,\n} from \"./display/display_utils.js\";\nimport {\n  build,\n  getDocument,\n  PDFDataRangeTransport,\n  PDFWorker,\n  version,\n} from \"./display/api.js\";\nimport { AnnotationEditorLayer } from \"./display/editor/annotation_editor_layer.js\";\nimport { AnnotationEditorUIManager } from \"./display/editor/tools.js\";\nimport { AnnotationLayer } from \"./display/annotation_layer.js\";\nimport { ColorPicker } from \"./display/editor/color_picker.js\";\nimport { DOMSVGFactory } from \"./display/svg_factory.js\";\nimport { DrawLayer } from \"./display/draw_layer.js\";\nimport { GlobalWorkerOptions } from \"./display/worker_options.js\";\nimport { HighlightOutliner } from \"./display/editor/drawers/highlight.js\";\nimport { isValidExplicitDest } from \"./display/api_utils.js\";\nimport { SignatureExtractor } from \"./display/editor/drawers/signaturedraw.js\";\nimport { TextLayer } from \"./display/text_layer.js\";\nimport { TouchManager } from \"./display/touch_manager.js\";\nimport { XfaLayer } from \"./display/xfa_layer.js\";\n\nif (typeof PDFJSDev !== \"undefined\" && PDFJSDev.test(\"TESTING || GENERIC\")) {\n  globalThis._pdfjsTestingUtils = {\n    HighlightOutliner,\n  };\n}\n\nglobalThis.pdfjsLib = {\n  AbortException,\n  AnnotationEditorLayer,\n  AnnotationEditorParamsType,\n  AnnotationEditorType,\n  AnnotationEditorUIManager,\n  AnnotationLayer,\n  AnnotationMode,\n  AnnotationType,\n  applyOpacity,\n  build,\n  ColorPicker,\n  createValidAbsoluteUrl,\n  CSSConstants,\n  DOMSVGFactory,\n  DrawLayer,\n  FeatureTest,\n  fetchData,\n  findContrastColor,\n  getDocument,\n  getFilenameFromUrl,\n  getPdfFilenameFromUrl,\n  getRGB,\n  getUuid,\n  getXfaPageViewport,\n  GlobalWorkerOptions,\n  ImageKind,\n  InvalidPDFException,\n  isDataScheme,\n  isPdfFile,\n  isValidExplicitDest,\n  makeArr,\n  makeMap,\n  makeObj,\n  MathClamp,\n  noContextMenu,\n  normalizeUnicode,\n  OPS,\n  OutputScale,\n  PasswordResponses,\n  PDFDataRangeTransport,\n  PDFDateString,\n  PDFWorker,\n  PermissionFlag,\n  PixelsPerInch,\n  RenderingCancelledException,\n  renderRichText,\n  ResponseException,\n  setLayerDimensions,\n  shadow,\n  SignatureExtractor,\n  stopEvent,\n  SupportedImageMimeTypes,\n  TextLayer,\n  TouchManager,\n  updateUrlHash,\n  Util,\n  VerbosityLevel,\n  version,\n  XfaLayer,\n};\n\nexport {\n  AbortException,\n  AnnotationEditorLayer,\n  AnnotationEditorParamsType,\n  AnnotationEditorType,\n  AnnotationEditorUIManager,\n  AnnotationLayer,\n  AnnotationMode,\n  AnnotationType,\n  applyOpacity,\n  build,\n  ColorPicker,\n  createValidAbsoluteUrl,\n  CSSConstants,\n  DOMSVGFactory,\n  DrawLayer,\n  FeatureTest,\n  fetchData,\n  findContrastColor,\n  getDocument,\n  getFilenameFromUrl,\n  getPdfFilenameFromUrl,\n  getRGB,\n  getUuid,\n  getXfaPageViewport,\n  GlobalWorkerOptions,\n  ImageKind,\n  InvalidPDFException,\n  isDataScheme,\n  isPdfFile,\n  isValidExplicitDest,\n  makeArr,\n  makeMap,\n  makeObj,\n  MathClamp,\n  noContextMenu,\n  normalizeUnicode,\n  OPS,\n  OutputScale,\n  PasswordResponses,\n  PDFDataRangeTransport,\n  PDFDateString,\n  PDFWorker,\n  PermissionFlag,\n  PixelsPerInch,\n  RenderingCancelledException,\n  renderRichText,\n  ResponseException,\n  setLayerDimensions,\n  shadow,\n  SignatureExtractor,\n  stopEvent,\n  SupportedImageMimeTypes,\n  TextLayer,\n  TouchManager,\n  updateUrlHash,\n  Util,\n  VerbosityLevel,\n  version,\n  XfaLayer,\n};\n"]}