PageSourceSearch

https://orijins.ai/assets/pdf.worker-CPbhI6B3.mjs

js orijins.ai collected 2026-10-05 15:18:49 UTC 2,206,299 bytes, 64,390 lines download raw bytes

1/**
2 * @licstart The following is the entire license notice for the
3 * JavaScript code in this page
4 *
5 * Copyright 2024 Mozilla Foundation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *     http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @licend The above is the entire license notice for the
20 * JavaScript code in this page
21 */
22
23/**
24 * pdfjsVersion = 6.1.200
25 * pdfjsBuild = 6353acefe
vendor: 10,069 bytes, lines 25-483
25
26 */
27
28;// ./src/shared/util.js
29const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
30const BBOX_INIT = [Infinity, Infinity, -Infinity, -Infinity];
31const F32_BBOX_INIT = new Float32Array(BBOX_INIT);
32const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
33const LINE_FACTOR = 1.35;
34const LINE_DESCENT_FACTOR = 0.35;
35const BASELINE_FACTOR = LINE_DESCENT_FACTOR / LINE_FACTOR;
36const SVG_NS = "http://www.w3.org/2000/svg";
37const RenderingIntentFlag = {
38  ANY: 0x01,
39  DISPLAY: 0x02,
40  PRINT: 0x04,
41  SAVE: 0x08,
42  ANNOTATIONS_FORMS: 0x10,
43  ANNOTATIONS_STORAGE: 0x20,
44  ANNOTATIONS_DISABLE: 0x40,
45  IS_EDITING: 0x80,
46  OPLIST: 0x100
47};
48const AnnotationMode = (/* unused pure expression or super */ null && ({
49  DISABLE: 0,
50  ENABLE: 1,
51  ENABLE_FORMS: 2,
52  ENABLE_STORAGE: 3
53}));
54const AnnotationPrefix = "pdfjs_internal_id_";
55const AnnotationEditorPrefix = "pdfjs_internal_editor_";
56const AnnotationEditorType = {
57  DISABLE: -1,
58  NONE: 0,
59  FREETEXT: 3,
60  HIGHLIGHT: 9,
61  STAMP: 13,
62  INK: 15,
63  POPUP: 16,
64  SIGNATURE: 101,
65  COMMENT: 102
66};
67const AnnotationEditorParamsType = (/* unused pure expression or super */ null && ({
68  RESIZE: 1,
69  CREATE: 2,
70  FREETEXT_SIZE: 11,
71  FREETEXT_COLOR: 12,
72  FREETEXT_OPACITY: 13,
73  INK_COLOR: 21,
74  INK_THICKNESS: 22,
75  INK_OPACITY: 23,
76  INK_COLOR_AND_OPACITY: 24,
77  HIGHLIGHT_COLOR: 31,
78  HIGHLIGHT_THICKNESS: 32,
79  HIGHLIGHT_FREE: 33,
80  HIGHLIGHT_SHOW_ALL: 34,
81  DRAW_STEP: 41
82}));
83const PermissionFlag = {
84  PRINT: 0x04,
85  MODIFY_CONTENTS: 0x08,
86  COPY: 0x10,
87  MODIFY_ANNOTATIONS: 0x20,
88  FILL_INTERACTIVE_FORMS: 0x100,
89  COPY_FOR_ACCESSIBILITY: 0x200,
90  ASSEMBLE: 0x400,
91  PRINT_HIGH_QUALITY: 0x800
92};
93const MeshFigureType = {
94  TRIANGLES: 1,
95  LATTICE: 2,
96  PATCH: 3
97};
98const TextRenderingMode = {
99  FILL: 0,
100  STROKE: 1,
101  FILL_STROKE: 2,
102  INVISIBLE: 3,
103  FILL_ADD_TO_PATH: 4,
104  STROKE_ADD_TO_PATH: 5,
105  FILL_STROKE_ADD_TO_PATH: 6,
106  ADD_TO_PATH: 7,
107  FILL_STROKE_MASK: 3,
108  ADD_TO_PATH_FLAG: 4
109};
110const ImageKind = {
111  GRAYSCALE_1BPP: 1,
112  RGB_24BPP: 2,
113  RGBA_32BPP: 3
114};
115const AnnotationType = {
116  TEXT: 1,
117  LINK: 2,
118  FREETEXT: 3,
119  LINE: 4,
120  SQUARE: 5,
121  CIRCLE: 6,
122  POLYGON: 7,
123  POLYLINE: 8,
124  HIGHLIGHT: 9,
125  UNDERLINE: 10,
126  SQUIGGLY: 11,
127  STRIKEOUT: 12,
128  STAMP: 13,
129  CARET: 14,
130  INK: 15,
131  POPUP: 16,
132  FILEATTACHMENT: 17,
133  SOUND: 18,
134  MOVIE: 19,
135  WIDGET: 20,
136  SCREEN: 21,
137  PRINTERMARK: 22,
138  TRAPNET: 23,
139  WATERMARK: 24,
140  THREED: 25,
141  REDACT: 26,
142  RICHMEDIA: 27
143};
144const AnnotationReplyType = {
145  GROUP: "Group",
146  REPLY: "R"
147};
148const AnnotationRenditionOperation = {
149  PLAY_OR_RESUME: 0,
150  STOP: 1,
151  PAUSE: 2,
152  RESUME: 3,
153  PLAY: 4
154};
155const AnnotationFlag = {
156  INVISIBLE: 0x01,
157  HIDDEN: 0x02,
158  PRINT: 0x04,
159  NOZOOM: 0x08,
160  NOROTATE: 0x10,
161  NOVIEW: 0x20,
162  READONLY: 0x40,
163  LOCKED: 0x80,
164  TOGGLENOVIEW: 0x100,
165  LOCKEDCONTENTS: 0x200
166};
167const AnnotationFieldFlag = {
168  READONLY: 0x0000001,
169  REQUIRED: 0x0000002,
170  NOEXPORT: 0x0000004,
171  MULTILINE: 0x0001000,
172  PASSWORD: 0x0002000,
173  NOTOGGLETOOFF: 0x0004000,
174  RADIO: 0x0008000,
175  PUSHBUTTON: 0x0010000,
176  COMBO: 0x0020000,
177  EDIT: 0x0040000,
178  SORT: 0x0080000,
179  FILESELECT: 0x0100000,
180  MULTISELECT: 0x0200000,
181  DONOTSPELLCHECK: 0x0400000,
182  DONOTSCROLL: 0x0800000,
183  COMB: 0x1000000,
184  RICHTEXT: 0x2000000,
185  RADIOSINUNISON: 0x2000000,
186  COMMITONSELCHANGE: 0x4000000
187};
188const AnnotationBorderStyleType = {
189  SOLID: 1,
190  DASHED: 2,
191  BEVELED: 3,
192  INSET: 4,
193  UNDERLINE: 5
194};
195const AnnotationActionEventType = {
196  E: "Mouse Enter",
197  X: "Mouse Exit",
198  D: "Mouse Down",
199  U: "Mouse Up",
200  Fo: "Focus",
201  Bl: "Blur",
202  PO: "PageOpen",
203  PC: "PageClose",
204  PV: "PageVisible",
205  PI: "PageInvisible",
206  K: "Keystroke",
207  F: "Format",
208  V: "Validate",
209  C: "Calculate"
210};
211const DocumentActionEventType = {
212  WC: "WillClose",
213  WS: "WillSave",
214  DS: "DidSave",
215  WP: "WillPrint",
216  DP: "DidPrint"
217};
218const PageActionEventType = {
219  O: "PageOpen",
220  C: "PageClose"
221};
222const VerbosityLevel = {
223  ERRORS: 0,
224  WARNINGS: 1,
225  INFOS: 5
226};
227const OPS = {
228  dependency: 1,
229  setLineWidth: 2,
230  setLineCap: 3,
231  setLineJoin: 4,
232  setMiterLimit: 5,
233  setDash: 6,
234  setRenderingIntent: 7,
235  setFlatness: 8,
236  setGState: 9,
237  save: 10,
238  restore: 11,
239  transform: 12,
240  moveTo: 13,
241  lineTo: 14,
242  curveTo: 15,
243  curveTo2: 16,
244  curveTo3: 17,
245  closePath: 18,
246  rectangle: 19,
247  stroke: 20,
248  closeStroke: 21,
249  fill: 22,
250  eoFill: 23,
251  fillStroke: 24,
252  eoFillStroke: 25,
253  closeFillStroke: 26,
254  closeEOFillStroke: 27,
255  endPath: 28,
256  clip: 29,
257  eoClip: 30,
258  beginText: 31,
259  endText: 32,
260  setCharSpacing: 33,
261  setWordSpacing: 34,
262  setHScale: 35,
263  setLeading: 36,
264  setFont: 37,
265  setTextRenderingMode: 38,
266  setTextRise: 39,
267  moveText: 40,
268  setLeadingMoveText: 41,
269  setTextMatrix: 42,
270  nextLine: 43,
271  showText: 44,
272  showSpacedText: 45,
273  nextLineShowText: 46,
274  nextLineSetSpacingShowText: 47,
275  setCharWidth: 48,
276  setCharWidthAndBounds: 49,
277  setStrokeColorSpace: 50,
278  setFillColorSpace: 51,
279  setStrokeColor: 52,
280  setStrokeColorN: 53,
281  setFillColor: 54,
282  setFillColorN: 55,
283  setStrokeGray: 56,
284  setFillGray: 57,
285  setStrokeRGBColor: 58,
286  setFillRGBColor: 59,
287  setStrokeCMYKColor: 60,
288  setFillCMYKColor: 61,
289  shadingFill: 62,
290  beginInlineImage: 63,
291  beginImageData: 64,
292  endInlineImage: 65,
293  paintXObject: 66,
294  markPoint: 67,
295  markPointProps: 68,
296  beginMarkedContent: 69,
297  beginMarkedContentProps: 70,
298  endMarkedContent: 71,
299  beginCompat: 72,
300  endCompat: 73,
301  paintFormXObjectBegin: 74,
302  paintFormXObjectEnd: 75,
303  beginGroup: 76,
304  endGroup: 77,
305  beginAnnotation: 80,
306  endAnnotation: 81,
307  paintImageMaskXObject: 83,
308  paintImageMaskXObjectGroup: 84,
309  paintImageXObject: 85,
310  paintInlineImageXObject: 86,
311  paintInlineImageXObjectGroup: 87,
312  paintImageXObjectRepeat: 88,
313  paintImageMaskXObjectRepeat: 89,
314  paintSolidColorImageMask: 90,
315  constructPath: 91,
316  setStrokeTransparent: 92,
317  setFillTransparent: 93,
318  rawFillPath: 94
319};
320const DrawOPS = {
321  moveTo: 0,
322  lineTo: 1,
323  curveTo: 2,
324  quadraticCurveTo: 3,
325  closePath: 4
326};
327const PasswordResponses = {
328  NEED_PASSWORD: 1,
329  INCORRECT_PASSWORD: 2
330};
331let verbosity = VerbosityLevel.WARNINGS;
332function setVerbosityLevel(level) {
333  if (Number.isInteger(level)) {
334    verbosity = level;
335  }
336}
337function getVerbosityLevel() {
338  return verbosity;
339}
340function info(msg) {
341  if (verbosity >= VerbosityLevel.INFOS) {
342    console.info(`Info: ${msg}`);
343  }
344}
345function warn(msg) {
346  if (verbosity >= VerbosityLevel.WARNINGS) {
347    console.warn(`Warning: ${msg}`);
348  }
349}
350function unreachable(msg) {
351  throw new Error(msg);
352}
353function assert(cond, msg) {
354  if (!cond) {
355    unreachable(msg);
356  }
357}
358function _isValidProtocol(url) {
359  switch (url?.protocol) {
360    case "http:":
361    case "https:":
362    case "ftp:":
363    case "mailto:":
364    case "tel:":
365      return true;
366    default:
367      return false;
368  }
369}
370function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
371  if (!url) {
372    return null;
373  }
374  if (options && typeof url === "string") {
375    if (options.addDefaultProtocol && url.startsWith("www.")) {
376      const dots = url.match(/\./g);
377      if (dots?.length >= 2) {
378        url = `http://${url}`;
379      }
380    }
381    if (options.tryConvertEncoding) {
382      try {
383        url = stringToUTF8String(url);
384      } catch {}
385    }
386  }
387  const absoluteUrl = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);
388  return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;
389}
390function updateUrlHash(url, hash, allowRel = false) {
391  const res = URL.parse(url);
392  if (res) {
393    res.hash = hash;
394    return res.href;
395  }
396  if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {
397    return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;
398  }
399  return "";
400}
401function stripPath(str) {
402  return str.substring(str.lastIndexOf("/") + 1);
403}
404function shadow(obj, prop, value, nonSerializable = false) {
405  Object.defineProperty(obj, prop, {
406    value,
407    enumerable: !nonSerializable,
408    configurable: true,
409    writable: false
410  });
411  return value;
412}
413const BaseException = function BaseExceptionClosure() {
414  function BaseException(message, name) {
415    this.message = message;
416    this.name = name;
417  }
418  BaseException.prototype = new Error();
419  BaseException.constructor = BaseException;
420  return BaseException;
421}();
422class PasswordException extends BaseException {
423  constructor(msg, code) {
424    super(msg, "PasswordException");
425    this.code = code;
426  }
427}
428class UnknownErrorException extends BaseException {
429  constructor(msg, details) {
430    super(msg, "UnknownErrorException");
431    this.details = details;
432  }
433}
434class InvalidPDFException extends BaseException {
435  constructor(msg) {
436    super(msg, "InvalidPDFException");
437  }
438}
439class ResponseException extends BaseException {
440  constructor(msg, status, missing) {
441    super(msg, "ResponseException");
442    this.status = status;
443    this.missing = missing;
444  }
445}
446class FormatError extends BaseException {
447  constructor(msg) {
448    super(msg, "FormatError");
449  }
450}
451class AbortException extends BaseException {
452  constructor(msg) {
453    super(msg, "AbortException");
454  }
455}
456function bytesToString(bytes) {
457  if (typeof bytes !== "object" || bytes?.length === undefined) {
458    unreachable("Invalid argument for bytesToString");
459  }
460  const length = bytes.length;
461  const MAX_ARGUMENT_COUNT = 8192;
462  if (length < MAX_ARGUMENT_COUNT) {
463    return String.fromCharCode.apply(null, bytes);
464  }
465  const strBuf = [];
466  for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
467    const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
468    const chunk = bytes.subarray(i, chunkEnd);
469    strBuf.push(String.fromCharCode.apply(null, chunk));
470  }
471  return strBuf.join("");
472}
473function stringToBytes(str) {
474  if (typeof str !== "string") {
475    unreachable("Invalid argument for stringToBytes");
476  }
477  const length = str.length;
478  const bytes = new Uint8Array(length);
479  for (let i = 0; i < length; ++i) {
480    bytes[i] = str.charCodeAt(i) & 0xff;
481  }
482  return bytes;
483}
vendor: 1,232 bytes, lines 484-519
484function objectSize(obj) {
485  return Object.keys(obj).length;
486}
487class FeatureTest {
488  static get isLittleEndian() {
489    const buffer8 = new Uint8Array(4);
490    buffer8[0] = 1;
491    const view32 = new Uint32Array(buffer8.buffer, 0, 1);
492    return shadow(this, "isLittleEndian", view32[0] === 1);
493  }
494  static get isOffscreenCanvasSupported() {
495    return shadow(this, "isOffscreenCanvasSupported", typeof OffscreenCanvas !== "undefined");
496  }
497  static get isImageDecoderSupported() {
498    return shadow(this, "isImageDecoderSupported", typeof ImageDecoder !== "undefined");
499  }
500  static get isFloat16ArraySupported() {
501    return shadow(this, "isFloat16ArraySupported", typeof Float16Array !== "undefined");
502  }
503  static get isSanitizerSupported() {
504    return shadow(this, "isSanitizerSupported", typeof Sanitizer !== "undefined");
505  }
506  static get platform() {
507    const {
508      platform,
509      userAgent
510    } = navigator;
511    return shadow(this, "platform", {
512      isAndroid: userAgent.includes("Android"),
513      isLinux: platform.includes("Linux"),
514      isMac: platform.includes("Mac"),
515      isWindows: platform.includes("Win"),
516      isFirefox: userAgent.includes("Firefox")
517    });
518  }
519  static get isCanvasFilterSupported() {
vendor: 14,083 bytes, lines 520-998
520    let ctx;
521    if (this.isOffscreenCanvasSupported) {
522      ctx = new OffscreenCanvas(1, 1).getContext("2d");
523    }
524    return shadow(this, "isCanvasFilterSupported", ctx?.filter !== undefined);
525  }
526  static get isAlphaColorInputSupported() {
527    return shadow(this, "isAlphaColorInputSupported", false);
528  }
529  static get isBackdropFilterSupported() {
530    return shadow(this, "isBackdropFilterSupported", typeof CSS !== "undefined" && CSS.supports("backdrop-filter", "blur(1px)"));
531  }
532}
533class Util {
534  static get hexNums() {
535    return shadow(this, "hexNums", Array.from(Array(256).keys(), n => n.toString(16).padStart(2, "0")));
536  }
537  static makeHexColor(r, g, b) {
538    return `#${this.hexNums[r]}${this.hexNums[g]}${this.hexNums[b]}`;
539  }
540  static transform(m1, m2) {
541    return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
542  }
543  static multiplyByDOMMatrix(m, md) {
544    return [m[0] * md.a + m[2] * md.b, m[1] * md.a + m[3] * md.b, m[0] * md.c + m[2] * md.d, m[1] * md.c + m[3] * md.d, m[0] * md.e + m[2] * md.f + m[4], m[1] * md.e + m[3] * md.f + m[5]];
545  }
546  static applyTransform(p, m, pos = 0) {
547    const p0 = p[pos];
548    const p1 = p[pos + 1];
549    p[pos] = p0 * m[0] + p1 * m[2] + m[4];
550    p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];
551  }
552  static applyTransformToBezier(p, transform, pos = 0) {
553    const m0 = transform[0];
554    const m1 = transform[1];
555    const m2 = transform[2];
556    const m3 = transform[3];
557    const m4 = transform[4];
558    const m5 = transform[5];
559    for (let i = 0; i < 6; i += 2) {
560      const pI = p[pos + i];
561      const pI1 = p[pos + i + 1];
562      p[pos + i] = pI * m0 + pI1 * m2 + m4;
563      p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;
564    }
565  }
566  static applyInverseTransform(p, m) {
567    const p0 = p[0];
568    const p1 = p[1];
569    const d = m[0] * m[3] - m[1] * m[2];
570    p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
571    p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
572  }
573  static axialAlignedBoundingBox(rect, transform, output) {
574    const m0 = transform[0];
575    const m1 = transform[1];
576    const m2 = transform[2];
577    const m3 = transform[3];
578    const m4 = transform[4];
579    const m5 = transform[5];
580    const r0 = rect[0];
581    const r1 = rect[1];
582    const r2 = rect[2];
583    const r3 = rect[3];
584    let a0 = m0 * r0 + m4;
585    let a2 = a0;
586    let a1 = m0 * r2 + m4;
587    let a3 = a1;
588    let b0 = m3 * r1 + m5;
589    let b2 = b0;
590    let b1 = m3 * r3 + m5;
591    let b3 = b1;
592    if (m1 !== 0 || m2 !== 0) {
593      const m1r0 = m1 * r0;
594      const m1r2 = m1 * r2;
595      const m2r1 = m2 * r1;
596      const m2r3 = m2 * r3;
597      a0 += m2r1;
598      a3 += m2r1;
599      a1 += m2r3;
600      a2 += m2r3;
601      b0 += m1r0;
602      b3 += m1r0;
603      b1 += m1r2;
604      b2 += m1r2;
605    }
606    output[0] = Math.min(output[0], a0, a1, a2, a3);
607    output[1] = Math.min(output[1], b0, b1, b2, b3);
608    output[2] = Math.max(output[2], a0, a1, a2, a3);
609    output[3] = Math.max(output[3], b0, b1, b2, b3);
610  }
611  static inverseTransform(m) {
612    const d = m[0] * m[3] - m[1] * m[2];
613    return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
614  }
615  static singularValueDecompose2dScale(matrix, output) {
616    const m0 = matrix[0];
617    const m1 = matrix[1];
618    const m2 = matrix[2];
619    const m3 = matrix[3];
620    const a = m0 ** 2 + m1 ** 2;
621    const b = m0 * m2 + m1 * m3;
622    const c = m2 ** 2 + m3 ** 2;
623    const first = (a + c) / 2;
624    const second = Math.sqrt(first ** 2 - (a * c - b ** 2));
625    output[0] = Math.sqrt(first + second || 1);
626    output[1] = Math.sqrt(first - second || 1);
627  }
628  static normalizeRect(rect) {
629    const r = rect.slice(0);
630    if (rect[0] > rect[2]) {
631      r[0] = rect[2];
632      r[2] = rect[0];
633    }
634    if (rect[1] > rect[3]) {
635      r[1] = rect[3];
636      r[3] = rect[1];
637    }
638    return r;
639  }
640  static intersect(rect1, rect2) {
641    const xLow = Math.max(Math.min(rect1[0], rect1[2]), Math.min(rect2[0], rect2[2]));
642    const xHigh = Math.min(Math.max(rect1[0], rect1[2]), Math.max(rect2[0], rect2[2]));
643    if (xLow > xHigh) {
644      return null;
645    }
646    const yLow = Math.max(Math.min(rect1[1], rect1[3]), Math.min(rect2[1], rect2[3]));
647    const yHigh = Math.min(Math.max(rect1[1], rect1[3]), Math.max(rect2[1], rect2[3]));
648    if (yLow > yHigh) {
649      return null;
650    }
651    return [xLow, yLow, xHigh, yHigh];
652  }
653  static pointBoundingBox(x, y, minMax) {
654    minMax[0] = Math.min(minMax[0], x);
655    minMax[1] = Math.min(minMax[1], y);
656    minMax[2] = Math.max(minMax[2], x);
657    minMax[3] = Math.max(minMax[3], y);
658  }
659  static rectBoundingBox(x0, y0, x1, y1, minMax) {
660    minMax[0] = Math.min(minMax[0], x0, x1);
661    minMax[1] = Math.min(minMax[1], y0, y1);
662    minMax[2] = Math.max(minMax[2], x0, x1);
663    minMax[3] = Math.max(minMax[3], y0, y1);
664  }
665  static #getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, t, minMax) {
666    if (t <= 0 || t >= 1) {
667      return;
668    }
669    const mt = 1 - t;
670    const tt = t * t;
671    const ttt = tt * t;
672    const x = mt * (mt * (mt * x0 + 3 * t * x1) + 3 * tt * x2) + ttt * x3;
673    const y = mt * (mt * (mt * y0 + 3 * t * y1) + 3 * tt * y2) + ttt * y3;
674    minMax[0] = Math.min(minMax[0], x);
675    minMax[1] = Math.min(minMax[1], y);
676    minMax[2] = Math.max(minMax[2], x);
677    minMax[3] = Math.max(minMax[3], y);
678  }
679  static #getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
680    if (Math.abs(a) < 1e-12) {
681      if (Math.abs(b) >= 1e-12) {
682        this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, -c / b, minMax);
683      }
684      return;
685    }
686    const delta = b ** 2 - 4 * c * a;
687    if (delta < 0) {
688      return;
689    }
690    const sqrtDelta = Math.sqrt(delta);
691    const a2 = 2 * a;
692    this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
693    this.#getExtremumOnCurve(x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
694  }
695  static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
696    minMax[0] = Math.min(minMax[0], x0, x3);
697    minMax[1] = Math.min(minMax[1], y0, y3);
698    minMax[2] = Math.max(minMax[2], x0, x3);
699    minMax[3] = Math.max(minMax[3], y0, y3);
700    this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);
701    this.#getExtremum(x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);
702  }
703}
704function stringToUTF8String(str) {
705  return decodeURIComponent(escape(str));
706}
707function utf8StringToString(str) {
708  return unescape(encodeURIComponent(str));
709}
710function isArrayEqual(arr1, arr2) {
711  if (arr1.length !== arr2.length) {
712    return false;
713  }
714  for (let i = 0, ii = arr1.length; i < ii; i++) {
715    if (arr1[i] !== arr2[i]) {
716      return false;
717    }
718  }
719  return true;
720}
721let NormalizeRegex = null;
722let NormalizationMap = null;
723function normalizeUnicode(str) {
724  if (!NormalizeRegex) {
725    NormalizeRegex = /([\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;
726    NormalizationMap = new Map([["ſt", "ſt"]]);
727  }
728  return str.replaceAll(NormalizeRegex, (_, p1, p2) => p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2));
729}
730function getUuid() {
731  if (typeof crypto.randomUUID === "function") {
732    return crypto.randomUUID();
733  }
734  const buf = new Uint8Array(32);
735  crypto.getRandomValues(buf);
736  return bytesToString(buf);
737}
738function _isValidExplicitDest(validRef, validName, dest) {
739  if (!Array.isArray(dest) || dest.length < 2) {
740    return false;
741  }
742  const [page, zoom, ...args] = dest;
743  if (!validRef(page) && !Number.isInteger(page)) {
744    return false;
745  }
746  if (!validName(zoom)) {
747    return false;
748  }
749  const argsLen = args.length;
750  let allowNull = true;
751  switch (zoom.name) {
752    case "XYZ":
753      if (argsLen < 2 || argsLen > 3) {
754        return false;
755      }
756      break;
757    case "Fit":
758    case "FitB":
759      return argsLen === 0;
760    case "FitH":
761    case "FitBH":
762    case "FitV":
763    case "FitBV":
764      if (argsLen > 1) {
765        return false;
766      }
767      break;
768    case "FitR":
769      if (argsLen !== 4) {
770        return false;
771      }
772      allowNull = false;
773      break;
774    default:
775      return false;
776  }
777  for (const arg of args) {
778    if (typeof arg === "number" || allowNull && arg === null) {
779      continue;
780    }
781    return false;
782  }
783  return true;
784}
785const makeArr = () => [];
786const makeMap = () => new Map();
787const makeObj = () => Object.create(null);
788
789;// ./src/core/primitives.js
790
791const CIRCULAR_REF = Symbol("CIRCULAR_REF");
792const EOF = Symbol("EOF");
793let CmdCache = Object.create(null);
794let NameCache = Object.create(null);
795let RefCache = Object.create(null);
796function clearPrimitiveCaches() {
797  CmdCache = Object.create(null);
798  NameCache = Object.create(null);
799  RefCache = Object.create(null);
800}
801class Name {
802  constructor(name) {
803    this.name = name;
804  }
805  static get(name) {
806    return NameCache[name] ||= new Name(name);
807  }
808}
809class Cmd {
810  constructor(cmd) {
811    this.cmd = cmd;
812  }
813  static get(cmd) {
814    return CmdCache[cmd] ||= new Cmd(cmd);
815  }
816}
817const nonSerializable = function nonSerializableClosure() {
818  return nonSerializable;
819};
820class Dict {
821  __nonSerializable__ = nonSerializable;
822  #map = new Map();
823  objId = null;
824  suppressEncryption = false;
825  xref;
826  constructor(xref = null) {
827    this.xref = xref;
828  }
829  assignXref(newXref) {
830    this.xref = newXref;
831  }
832  get size() {
833    return this.#map.size;
834  }
835  #getValue(isAsync, key1, key2, key3) {
836    let value = this.#map.get(key1);
837    if (value === undefined && key2 !== undefined) {
838      value = this.#map.get(key2);
839      if (value === undefined && key3 !== undefined) {
840        value = this.#map.get(key3);
841      }
842    }
843    if (value instanceof Ref && this.xref) {
844      return isAsync ? this.xref.fetchAsync(value, this.suppressEncryption) : this.xref.fetch(value, this.suppressEncryption);
845    }
846    return value;
847  }
848  get(key1, key2, key3) {
849    return this.#getValue(false, key1, key2, key3);
850  }
851  async getAsync(key1, key2, key3) {
852    return this.#getValue(true, key1, key2, key3);
853  }
854  getArray(key1, key2, key3) {
855    let value = this.#getValue(false, key1, key2, key3);
856    if (Array.isArray(value)) {
857      value = value.slice();
858      for (let i = 0, ii = value.length; i < ii; i++) {
859        if (value[i] instanceof Ref && this.xref) {
860          value[i] = this.xref.fetch(value[i], this.suppressEncryption);
861        }
862      }
863    }
864    return value;
865  }
866  getRaw(key) {
867    return this.#map.get(key);
868  }
869  getKeys() {
870    return this.#map.keys();
871  }
872  getRawValues() {
873    return this.#map.values();
874  }
875  getRawEntries() {
876    return this.#map.entries();
877  }
878  set(key, value) {
879    this.#map.set(key, value);
880  }
881  setIfNotExists(key, value) {
882    if (!this.has(key)) {
883      this.set(key, value);
884    }
885  }
886  setIfNumber(key, value) {
887    if (typeof value === "number") {
888      this.set(key, value);
889    }
890  }
891  setIfArray(key, value) {
892    if (Array.isArray(value) || ArrayBuffer.isView(value)) {
893      this.set(key, value);
894    }
895  }
896  setIfDefined(key, value) {
897    if (value !== undefined && value !== null) {
898      this.set(key, value);
899    }
900  }
901  setIfName(key, value) {
902    if (typeof value === "string") {
903      this.set(key, Name.get(value));
904    } else if (value instanceof Name) {
905      this.set(key, value);
906    }
907  }
908  setIfDict(key, value) {
909    if (value instanceof Dict) {
910      this.set(key, value);
911    }
912  }
913  has(key) {
914    return this.#map.has(key);
915  }
916  *[Symbol.iterator]() {
917    for (const [key, value] of this.#map) {
918      yield [key, value instanceof Ref && this.xref ? this.xref.fetch(value, this.suppressEncryption) : value];
919    }
920  }
921  static get empty() {
922    const emptyDict = new Dict(null);
923    emptyDict.set = (key, value) => {
924      unreachable("Should not call `set` on the empty dictionary.");
925    };
926    return shadow(this, "empty", emptyDict);
927  }
928  static merge({
929    xref,
930    dictArray,
931    mergeSubDicts = false
932  }) {
933    const mergedDict = new Dict(xref),
934      properties = new Map();
935    for (const dict of dictArray) {
936      if (!(dict instanceof Dict)) {
937        continue;
938      }
939      for (const [key, value] of dict.getRawEntries()) {
940        const property = properties.getOrInsertComputed(key, makeArr);
941        if (property.length && !(mergeSubDicts && value instanceof Dict)) {
942          continue;
943        }
944        property.push(value);
945      }
946    }
947    for (const [name, values] of properties) {
948      if (values.length === 1 || !(values[0] instanceof Dict)) {
949        mergedDict.set(name, values[0]);
950        continue;
951      }
952      const subDict = new Dict(xref);
953      for (const dict of values) {
954        for (const [key, value] of dict.getRawEntries()) {
955          subDict.setIfNotExists(key, value);
956        }
957      }
958      if (subDict.size > 0) {
959        mergedDict.set(name, subDict);
960      }
961    }
962    properties.clear();
963    return mergedDict.size > 0 ? mergedDict : Dict.empty;
964  }
965  clone() {
966    const dict = new Dict(this.xref);
967    for (const [key, value] of this.#map) {
968      dict.set(key, value);
969    }
970    return dict;
971  }
972  delete(key) {
973    this.#map.delete(key);
974  }
975}
976class Ref {
977  constructor(num, gen) {
978    this.num = num;
979    this.gen = gen;
980  }
981  toString() {
982    if (this.gen === 0) {
983      return `${this.num}R`;
984    }
985    return `${this.num}R${this.gen}`;
986  }
987  static fromString(str) {
988    const ref = RefCache[str];
989    if (ref) {
990      return ref;
991    }
992    const m = /^(\d+)R(\d*)$/.exec(str);
993    if (!m || m[1] === "0") {
994      return null;
995    }
996    return RefCache[str] = new Ref(parseInt(m[1], 10), !m[2] ? 0 : parseInt(m[2], 10));
997  }
998  static get(num, gen) {
999    const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
1000    return RefCache[key] ||= new Ref(num, gen);
1001  }
1002}
1003class RefSet {
1004  constructor(parent = null) {
1005    this._set = new Set(parent?._set);
1006  }
1007  has(ref) {
1008    return this._set.has(ref.toString());
1009  }
1010  put(ref) {
1011    this._set.add(ref.toString());
1012  }
1013  remove(ref) {
1014    this._set.delete(ref.toString());
1015  }
1016  [Symbol.iterator]() {
1017    return this._set.values();
1018  }
1019  clear() {
1020    this._set.clear();
1021  }
1022}
1023class RefSetCache {
1024  _map = new Map();
1025  get size() {
1026    return this._map.size;
1027  }
1028  get(ref) {
1029    return this._map.get(ref.toString());
1030  }
1031  has(ref) {
1032    return this._map.has(ref.toString());
1033  }
1034  put(ref, obj) {
1035    this._map.set(ref.toString(), obj);
1036  }
1037  putAlias(ref, aliasRef) {
1038    this._map.set(ref.toString(), this.get(aliasRef));
1039  }
1040  [Symbol.iterator]() {
1041    return this._map.values();
1042  }
1043  clear() {
1044    this._map.clear();
1045  }
1046  *values() {
1047    yield* this._map.values();
1048  }
1049  *items() {
1050    for (const [ref, value] of this._map) {
1051      yield [Ref.fromString(ref), value];
1052    }
1053  }
1054  *keys() {
1055    for (const ref of this._map.keys()) {
1056      yield Ref.fromString(ref);
1057    }
1058  }
1059}
1060function isName(v, name) {
1061  return v instanceof Name && (name === undefined || v.name === name);
1062}
1063function isCmd(v, cmd) {
1064  return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
1065}
1066function isDict(v, type) {
1067  return v instanceof Dict && (type === undefined || isName(v.get("Type"), type));
1068}
1069function isRefsEqual(v1, v2) {
1070  return v1.num === v2.num && v1.gen === v2.gen;
1071}
1072
1073;// ./src/core/base_stream.js
1074
1075class BaseStream {
1076  get length() {
1077    unreachable("Abstract getter `length` accessed");
1078  }
1079  get isEmpty() {
1080    unreachable("Abstract getter `isEmpty` accessed");
1081  }
1082  get isDataLoaded() {
1083    return shadow(this, "isDataLoaded", true);
1084  }
1085  getByte() {
1086    unreachable("Abstract method `getByte` called");
1087  }
1088  getBytes(length) {
1089    unreachable("Abstract method `getBytes` called");
1090  }
1091  async getImageData(length, decoderOptions) {
1092    return this.getBytes(length, decoderOptions);
1093  }
1094  async asyncGetBytes() {
1095    unreachable("Abstract method `asyncGetBytes` called");
1096  }
1097  get isAsync() {
1098    return false;
1099  }
1100  get isAsyncDecoder() {
1101    return false;
1102  }
1103  get isImageStream() {
1104    return false;
1105  }
1106  get canAsyncDecodeImageFromBuffer() {
1107    return false;
1108  }
1109  async getTransferableImage() {
1110    return null;
1111  }
1112  peekByte() {
1113    const peekedByte = this.getByte();
1114    if (peekedByte !== -1) {
1115      this.pos--;
1116    }
1117    return peekedByte;
1118  }
1119  peekBytes(length) {
1120    const bytes = this.getBytes(length);
1121    this.pos -= bytes.length;
1122    return bytes;
1123  }
1124  getUint16() {
1125    const b0 = this.getByte();
1126    const b1 = this.getByte();
1127    if (b0 === -1 || b1 === -1) {
1128      return -1;
1129    }
1130    return (b0 << 8) + b1;
1131  }
1132  getInt32() {
1133    const b0 = this.getByte();
1134    const b1 = this.getByte();
1135    const b2 = this.getByte();
1136    const b3 = this.getByte();
1137    return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
1138  }
1139  getByteRange(begin, end) {
1140    unreachable("Abstract method `getByteRange` called");
1141  }
1142  getString(length) {
1143    return bytesToString(this.getBytes(length));
1144  }
1145  skip(n) {
1146    this.pos += n || 1;
1147  }
1148  reset() {
1149    unreachable("Abstract method `reset` called");
1150  }
1151  moveStart() {
1152    unreachable("Abstract method `moveStart` called");
1153  }
1154  makeSubStream(start, length, dict = null) {
1155    unreachable("Abstract method `makeSubStream` called");
1156  }
1157  clone() {
1158    unreachable("Abstract method `clone` called");
1159  }
1160  getBaseStreams() {
1161    return null;
1162  }
1163  getOriginalStream() {
1164    return this.stream?.getOriginalStream() || this;
1165  }
1166}
1167
1168;// ./src/core/string_utils.js
1169
1170function isAscii(str) {
1171  return typeof str === "string" && (!str || /^[\x00-\x7F]*$/.test(str));
1172}
1173function stringToAsciiOrUTF16BE(str) {
1174  if (str === null || str === undefined) {
1175    return str;
1176  }
1177  return isAscii(str) ? str : stringToUTF16String(str, true);
1178}
1179function stringToUTF16HexString(str) {
1180  const buf = [];
1181  for (let i = 0, ii = str.length; i < ii; i++) {
1182    const char = str.charCodeAt(i);
1183    buf.push(Util.hexNums[char >> 8 & 0xff], Util.hexNums[char & 0xff]);
1184  }
1185  return buf.join("");
1186}
1187function stringToUTF16String(str, bigEndian = false) {
1188  const buf = [];
1189  if (bigEndian) {
1190    buf.push("\xFE\xFF");
1191  }
1192  for (let i = 0, ii = str.length; i < ii; i++) {
1193    const char = str.charCodeAt(i);
1194    buf.push(String.fromCharCode(char >> 8 & 0xff), String.fromCharCode(char & 0xff));
1195  }
1196  return buf.join("");
1197}
1198const PDFStringTranslateTable = [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, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 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, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac];
1199function stringToPDFString(str, keepEscapeSequence = false) {
1200  if (str[0] >= "\xEF") {
1201    let encoding;
1202    if (str[0] === "\xFE" && str[1] === "\xFF") {
1203      encoding = "utf-16be";
1204      if (str.length % 2 === 1) {
1205        str = str.slice(0, -1);
1206      }
1207    } else if (str[0] === "\xFF" && str[1] === "\xFE") {
1208      encoding = "utf-16le";
1209      if (str.length % 2 === 1) {
1210        str = str.slice(0, -1);
1211      }
1212    } else if (str[0] === "\xEF" && str[1] === "\xBB" && str[2] === "\xBF") {
1213      encoding = "utf-8";
1214    }
1215    if (encoding) {
vendor: 4,222 bytes, lines 1216-1379
1216      try {
1217        const decoder = new TextDecoder(encoding, {
1218          fatal: true
1219        });
1220        const buffer = stringToBytes(str);
1221        const decoded = decoder.decode(buffer);
1222        if (keepEscapeSequence || !decoded.includes("\x1b")) {
1223          return decoded;
1224        }
1225        return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
1226      } catch (ex) {
1227        warn(`stringToPDFString: "${ex}".`);
1228      }
1229    }
1230  }
1231  const strBuf = [];
1232  for (let i = 0, ii = str.length; i < ii; i++) {
1233    const charCode = str.charCodeAt(i);
1234    if (!keepEscapeSequence && charCode === 0x1b) {
1235      while (++i < ii && str.charCodeAt(i) !== 0x1b) {}
1236      continue;
1237    }
1238    const code = PDFStringTranslateTable[charCode];
1239    strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
1240  }
1241  return strBuf.join("");
1242}
1243
1244;// ./src/core/core_utils.js
1245
1246
1247
1248
1249const PDF_VERSION_REGEXP = /^[1-9]\.\d$/;
1250const MAX_INT_32 = 2 ** 31 - 1;
1251const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
1252const RESOURCES_KEYS_OPERATOR_LIST = ["ColorSpace", "ExtGState", "Font", "Pattern", "Properties", "Shading", "XObject"];
1253const RESOURCES_KEYS_TEXT_CONTENT = ["ExtGState", "Font", "Properties", "XObject"];
1254function getLookupTableFactory(initializer) {
1255  let lookup;
1256  return function () {
1257    if (initializer) {
1258      lookup = Object.create(null);
1259      initializer(lookup);
1260      initializer = null;
1261    }
1262    return lookup;
1263  };
1264}
1265class MissingDataException extends BaseException {
1266  constructor(begin, end) {
1267    super(`Missing data [${begin}, ${end})`, "MissingDataException");
1268    this.begin = begin;
1269    this.end = end;
1270  }
1271}
1272class ParserEOFException extends BaseException {
1273  constructor(msg) {
1274    super(msg, "ParserEOFException");
1275  }
1276}
1277class XRefEntryException extends BaseException {
1278  constructor(msg) {
1279    super(msg, "XRefEntryException");
1280  }
1281}
1282class XRefParseException extends BaseException {
1283  constructor(msg) {
1284    super(msg, "XRefParseException");
1285  }
1286}
1287function arrayBuffersToBytes(arr) {
1288  const length = arr.length;
1289  if (length === 0) {
1290    return new Uint8Array(0);
1291  }
1292  if (length === 1) {
1293    return new Uint8Array(arr[0]);
1294  }
1295  let dataLength = 0;
1296  for (let i = 0; i < length; i++) {
1297    dataLength += arr[i].byteLength;
1298  }
1299  const data = new Uint8Array(dataLength);
1300  let pos = 0;
1301  for (let i = 0; i < length; i++) {
1302    const item = new Uint8Array(arr[i]);
1303    data.set(item, pos);
1304    pos += item.byteLength;
1305  }
1306  return data;
1307}
1308async function fetchBinaryData(url) {
1309  const response = await fetch(url);
1310  if (!response.ok) {
1311    throw new Error(`Failed to fetch file "${url}" with "${response.statusText}".`);
1312  }
1313  return response.bytes();
1314}
1315function getInheritableProperty({
1316  dict,
1317  key,
1318  getArray = false,
1319  stopWhenFound = true
1320}) {
1321  let values;
1322  const visited = new RefSet();
1323  while (dict instanceof Dict && !(dict.objId && visited.has(dict.objId))) {
1324    if (dict.objId) {
1325      visited.put(dict.objId);
1326    }
1327    const value = getArray ? dict.getArray(key) : dict.get(key);
1328    if (value !== undefined) {
1329      if (stopWhenFound) {
1330        return value;
1331      }
1332      (values ||= []).push(value);
1333    }
1334    dict = dict.get("Parent");
1335  }
1336  return values;
1337}
1338function getParentToUpdate(dict, ref, xref) {
1339  const visited = new RefSet();
1340  const firstDict = dict;
1341  const result = {
1342    dict: null,
1343    ref: null
1344  };
1345  while (dict instanceof Dict && !visited.has(ref)) {
1346    visited.put(ref);
1347    if (dict.has("T")) {
1348      break;
1349    }
1350    ref = dict.getRaw("Parent");
1351    if (!(ref instanceof Ref)) {
1352      return result;
1353    }
1354    dict = xref.fetch(ref);
1355  }
1356  if (dict instanceof Dict && dict !== firstDict) {
1357    result.dict = dict;
1358    result.ref = ref;
1359  }
1360  return result;
1361}
1362function deepCompare(a, b) {
1363  if (a === b) {
1364    return true;
1365  }
1366  if (a instanceof Ref && b instanceof Ref) {
1367    return isRefsEqual(a, b);
1368  }
1369  if (a instanceof Name && b instanceof Name) {
1370    return a.name === b.name;
1371  }
1372  if (a instanceof Dict && b instanceof Dict) {
1373    if (a.size !== b.size) {
1374      return false;
1375    }
1376    for (const [key, value1] of a.getRawEntries()) {
1377      const value2 = b.getRaw(key);
1378      if (value2 === undefined || !deepCompare(value1, value2)) {
1379        return false;
vendor: 10,547 bytes, lines 1380-1733
1380      }
1381    }
1382    return true;
1383  }
1384  if (Array.isArray(a) && Array.isArray(b)) {
1385    if (a.length !== b.length) {
1386      return false;
1387    }
1388    for (let i = 0, ii = a.length; i < ii; i++) {
1389      if (!deepCompare(a[i], b[i])) {
1390        return false;
1391      }
1392    }
1393    return true;
1394  }
1395  return false;
1396}
1397const ROMAN_NUMBER_MAP = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM", "", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC", "", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
1398function toRomanNumerals(number, lowerCase = false) {
1399  assert(Number.isInteger(number) && number > 0, "The number should be a positive integer.");
1400  const roman = "M".repeat(number / 1000 | 0) + ROMAN_NUMBER_MAP[number % 1000 / 100 | 0] + ROMAN_NUMBER_MAP[10 + (number % 100 / 10 | 0)] + ROMAN_NUMBER_MAP[20 + number % 10];
1401  return lowerCase ? roman.toLowerCase() : roman;
1402}
1403function isWhiteSpace(ch) {
1404  return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
1405}
1406function isBooleanArray(arr, len) {
1407  return Array.isArray(arr) && (len === null || arr.length === len) && arr.every(x => typeof x === "boolean");
1408}
1409function isNumberArray(arr, len) {
1410  if (Array.isArray(arr)) {
1411    return (len === null || arr.length === len) && arr.every(x => typeof x === "number");
1412  }
1413  return ArrayBuffer.isView(arr) && !(arr instanceof BigInt64Array || arr instanceof BigUint64Array) && (len === null || arr.length === len);
1414}
1415function lookupMatrix(arr, fallback) {
1416  return isNumberArray(arr, 6) ? arr : fallback;
1417}
1418function lookupRect(arr, fallback) {
1419  return isNumberArray(arr, 4) ? arr : fallback;
1420}
1421function lookupNormalRect(arr, fallback) {
1422  return isNumberArray(arr, 4) ? Util.normalizeRect(arr) : fallback;
1423}
1424function parseXFAPath(path) {
1425  const positionPattern = /(.+)\[(\d+)\]$/;
1426  return path.split(".").map(component => {
1427    const m = component.match(positionPattern);
1428    if (m) {
1429      return {
1430        name: m[1],
1431        pos: parseInt(m[2], 10)
1432      };
1433    }
1434    return {
1435      name: component,
1436      pos: 0
1437    };
1438  });
1439}
1440function escapePDFName(str) {
1441  const buffer = [];
1442  let start = 0;
1443  for (let i = 0, ii = str.length; i < ii; i++) {
1444    const char = str.charCodeAt(i);
1445    if (char < 0x21 || char > 0x7e || char === 0x23 || char === 0x28 || char === 0x29 || char === 0x3c || char === 0x3e || char === 0x5b || char === 0x5d || char === 0x7b || char === 0x7d || char === 0x2f || char === 0x25) {
1446      if (start < i) {
1447        buffer.push(str.substring(start, i));
1448      }
1449      buffer.push(`#${char.toString(16)}`);
1450      start = i + 1;
1451    }
1452  }
1453  if (buffer.length === 0) {
1454    return str;
1455  }
1456  if (start < str.length) {
1457    buffer.push(str.substring(start));
1458  }
1459  return buffer.join("");
1460}
1461function escapeString(str) {
1462  return str.replaceAll(/([()\\\n\r])/g, match => {
1463    if (match === "\n") {
1464      return "\\n";
1465    } else if (match === "\r") {
1466      return "\\r";
1467    }
1468    return `\\${match}`;
1469  });
1470}
1471function _collectJS(entry, xref, list, parents) {
1472  if (!entry) {
1473    return;
1474  }
1475  let parent = null;
1476  if (entry instanceof Ref) {
1477    if (parents.has(entry)) {
1478      return;
1479    }
1480    parent = entry;
1481    parents.put(parent);
1482    entry = xref.fetch(entry);
1483  }
1484  if (Array.isArray(entry)) {
1485    for (const element of entry) {
1486      _collectJS(element, xref, list, parents);
1487    }
1488  } else if (entry instanceof Dict) {
1489    if (isName(entry.get("S"), "JavaScript")) {
1490      const js = entry.get("JS");
1491      let code;
1492      if (js instanceof BaseStream) {
1493        code = js.getString();
1494      } else if (typeof js === "string") {
1495        code = js;
1496      }
1497      code &&= stringToPDFString(code, true).replaceAll("\x00", "");
1498      if (code) {
1499        list.push(code.trim());
1500      }
1501    }
1502    _collectJS(entry.getRaw("Next"), xref, list, parents);
1503  }
1504  if (parent) {
1505    parents.remove(parent);
1506  }
1507}
1508function collectActions(xref, dict, eventType) {
1509  const actions = Object.create(null);
1510  const additionalActionsDicts = getInheritableProperty({
1511    dict,
1512    key: "AA",
1513    stopWhenFound: false
1514  });
1515  if (additionalActionsDicts) {
1516    for (let i = additionalActionsDicts.length - 1; i >= 0; i--) {
1517      const additionalActions = additionalActionsDicts[i];
1518      if (!(additionalActions instanceof Dict)) {
1519        continue;
1520      }
1521      for (const [key, rawActionDict] of additionalActions.getRawEntries()) {
1522        const action = eventType[key];
1523        if (!action) {
1524          continue;
1525        }
1526        const parents = new RefSet();
1527        const list = [];
1528        _collectJS(rawActionDict, xref, list, parents);
1529        if (list.length > 0) {
1530          actions[action] = list;
1531        }
1532      }
1533    }
1534  }
1535  if (dict.has("A")) {
1536    const actionDict = dict.get("A");
1537    const parents = new RefSet();
1538    const list = [];
1539    _collectJS(actionDict, xref, list, parents);
1540    if (list.length > 0) {
1541      actions.Action = list;
1542    }
1543  }
1544  return objectSize(actions) > 0 ? actions : null;
1545}
1546const XMLEntities = {
1547  0x3c: "&lt;",
1548  0x3e: "&gt;",
1549  0x26: "&amp;",
1550  0x22: "&quot;",
1551  0x27: "&apos;"
1552};
1553function* codePointIter(str) {
1554  for (let i = 0, ii = str.length; i < ii; i++) {
1555    const char = str.codePointAt(i);
1556    if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
1557      i++;
1558    }
1559    yield char;
1560  }
1561}
1562function encodeToXmlString(str) {
1563  const buffer = [];
1564  let start = 0;
1565  for (let i = 0, ii = str.length; i < ii; i++) {
1566    const char = str.codePointAt(i);
1567    if (0x20 <= char && char <= 0x7e) {
1568      const entity = XMLEntities[char];
1569      if (entity) {
1570        if (start < i) {
1571          buffer.push(str.substring(start, i));
1572        }
1573        buffer.push(entity);
1574        start = i + 1;
1575      }
1576    } else {
1577      if (start < i) {
1578        buffer.push(str.substring(start, i));
1579      }
1580      buffer.push(`&#x${char.toString(16).toUpperCase()};`);
1581      if (char > 0xd7ff && (char < 0xe000 || char > 0xfffd)) {
1582        i++;
1583      }
1584      start = i + 1;
1585    }
1586  }
1587  if (buffer.length === 0) {
1588    return str;
1589  }
1590  if (start < str.length) {
1591    buffer.push(str.substring(start));
1592  }
1593  return buffer.join("");
1594}
1595function validateFontName(fontFamily, mustWarn = false) {
1596  const m = /^("|').*("|')$/.exec(fontFamily);
1597  if (m && m[1] === m[2]) {
1598    const re = new RegExp(`[^\\\\]${m[1]}`);
1599    if (re.test(fontFamily.slice(1, -1))) {
1600      if (mustWarn) {
1601        warn(`FontFamily contains unescaped ${m[1]}: ${fontFamily}.`);
1602      }
1603      return false;
1604    }
1605  } else {
1606    for (const ident of fontFamily.split(/[ \t]+/)) {
1607      if (/^(?:\d|-[\d-])/.test(ident) || !/^[\w\\-]+$/.test(ident)) {
1608        if (mustWarn) {
1609          warn(`FontFamily contains invalid <custom-ident>: ${fontFamily}.`);
1610        }
1611        return false;
1612      }
1613    }
1614  }
1615  return true;
1616}
1617function validateCSSFont(cssFontInfo) {
1618  const DEFAULT_CSS_FONT_OBLIQUE = "14";
1619  const DEFAULT_CSS_FONT_WEIGHT = "400";
1620  const CSS_FONT_WEIGHT_VALUES = new Set(["100", "200", "300", "400", "500", "600", "700", "800", "900", "1000", "normal", "bold", "bolder", "lighter"]);
1621  const {
1622    fontFamily,
1623    fontWeight,
1624    italicAngle
1625  } = cssFontInfo;
1626  if (!validateFontName(fontFamily, true)) {
1627    return false;
1628  }
1629  const weight = fontWeight ? fontWeight.toString() : "";
1630  cssFontInfo.fontWeight = CSS_FONT_WEIGHT_VALUES.has(weight) ? weight : DEFAULT_CSS_FONT_WEIGHT;
1631  const angle = parseFloat(italicAngle);
1632  cssFontInfo.italicAngle = isNaN(angle) || angle < -90 || angle > 90 ? DEFAULT_CSS_FONT_OBLIQUE : italicAngle.toString();
1633  return true;
1634}
1635function recoverJsURL(str) {
1636  const URL_OPEN_METHODS = ["app.launchURL", "window.open", "xfa.host.gotoURL"];
1637  const regex = new RegExp("^\\s*(" + URL_OPEN_METHODS.join("|").replaceAll(".", "\\.") + ")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))", "i");
1638  const jsUrl = regex.exec(str);
1639  if (jsUrl?.[2]) {
1640    return {
1641      url: jsUrl[2],
1642      newWindow: jsUrl[1] === "app.launchURL" && jsUrl[3] === "true"
1643    };
1644  }
1645  return null;
1646}
1647function numberToString(value) {
1648  if (Number.isInteger(value)) {
1649    return value.toString();
1650  }
1651  const roundedValue = Math.round(value * 100);
1652  if (roundedValue % 100 === 0) {
1653    return (roundedValue / 100).toString();
1654  }
1655  if (roundedValue % 10 === 0) {
1656    return value.toFixed(1);
1657  }
1658  return value.toFixed(2);
1659}
1660function getNewAnnotationsMap(annotationStorage) {
1661  if (!annotationStorage) {
1662    return null;
1663  }
1664  const newAnnotationsByPage = new Map();
1665  for (const [key, value] of annotationStorage) {
1666    if (!key.startsWith(AnnotationEditorPrefix)) {
1667      continue;
1668    }
1669    newAnnotationsByPage.getOrInsertComputed(value.pageIndex, makeArr).push(value);
1670  }
1671  return newAnnotationsByPage.size > 0 ? newAnnotationsByPage : null;
1672}
1673function getModificationDate(date = new Date()) {
1674  if (!(date instanceof Date)) {
1675    date = new Date(date);
1676  }
1677  const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
1678  return buffer.join("");
1679}
1680function getRotationMatrix(rotation, width, height) {
1681  switch (rotation) {
1682    case 90:
1683      return [0, 1, -1, 0, width, 0];
1684    case 180:
1685      return [-1, 0, 0, -1, width, height];
1686    case 270:
1687      return [0, -1, 1, 0, 0, height];
1688    default:
1689      throw new Error("Invalid rotation");
1690  }
1691}
1692function getSizeInBytes(x) {
1693  return Math.ceil(Math.ceil(Math.log2(1 + x)) / 8);
1694}
1695
1696;// ./external/qcms/qcms_utils.js
1697class QCMS {
1698  static #memoryArray = null;
1699  static _memory = null;
1700  static _mustAddAlpha = false;
1701  static _destBuffer = null;
1702  static _destOffset = 0;
1703  static _destLength = 0;
1704  static _cssColor = "";
1705  static _makeHexColor = null;
1706  static get _memoryArray() {
1707    const array = this.#memoryArray;
1708    if (array?.byteLength) {
1709      return array;
1710    }
1711    return this.#memoryArray = new Uint8Array(this._memory.buffer);
1712  }
1713}
1714function copy_result(ptr, len) {
1715  const {
1716    _mustAddAlpha,
1717    _destBuffer,
1718    _destOffset,
1719    _destLength,
1720    _memoryArray
1721  } = QCMS;
1722  if (len === _destLength) {
1723    _destBuffer.set(_memoryArray.subarray(ptr, ptr + len), _destOffset);
1724    return;
1725  }
1726  if (_mustAddAlpha) {
1727    for (let i = ptr, ii = ptr + len, j = _destOffset; i < ii; i += 3, j += 4) {
1728      _destBuffer[j] = _memoryArray[i];
1729      _destBuffer[j + 1] = _memoryArray[i + 1];
1730      _destBuffer[j + 2] = _memoryArray[i + 2];
1731      _destBuffer[j + 3] = 255;
1732    }
1733  } else {
1734    for (let i = ptr, ii = ptr + len, j = _destOffset; i < ii; i += 3, j += 4) {
1735      _destBuffer[j] = _memoryArray[i];
1736      _destBuffer[j + 1] = _memoryArray[i + 1];
1737      _destBuffer[j + 2] = _memoryArray[i + 2];
1738    }
1739  }
1740}
1741function copy_rgb(ptr) {
1742  const {
1743    _destBuffer,
1744    _destOffset,
1745    _memoryArray
1746  } = QCMS;
1747  _destBuffer[_destOffset] = _memoryArray[ptr];
1748  _destBuffer[_destOffset + 1] = _memoryArray[ptr + 1];
1749  _destBuffer[_destOffset + 2] = _memoryArray[ptr + 2];
1750}
1751function make_cssRGB(ptr) {
1752  const {
1753    _memoryArray
1754  } = QCMS;
1755  QCMS._cssColor = QCMS._makeHexColor(_memoryArray[ptr], _memoryArray[ptr + 1], _memoryArray[ptr + 2]);
1756}
1757
1758;// ./external/qcms/qcms.js
1759
1760const DataType = Object.freeze({
1761  RGB8: 0,
1762  "0": "RGB8",
1763  RGBA8: 1,
1764  "1": "RGBA8",
1765  BGRA8: 2,
1766  "2": "BGRA8",
1767  Gray8: 3,
1768  "3": "Gray8",
1769  GrayA8: 4,
1770  "4": "GrayA8",
1771  CMYK: 5,
1772  "5": "CMYK"
1773});
1774const Intent = Object.freeze({
1775  Perceptual: 0,
1776  "0": "Perceptual",
1777  RelativeColorimetric: 1,
1778  "1": "RelativeColorimetric",
1779  Saturation: 2,
1780  "2": "Saturation",
1781  AbsoluteColorimetric: 3,
1782  "3": "AbsoluteColorimetric"
1783});
1784function qcms_convert_array(transformer, src) {
1785  const ptr0 = passArray8ToWasm0(src, wasm.__wbindgen_malloc);
1786  const len0 = WASM_VECTOR_LEN;
1787  wasm.qcms_convert_array(transformer, ptr0, len0);
1788}
1789function qcms_convert_four(transformer, src1, src2, src3, src4, css) {
1790  wasm.qcms_convert_four(transformer, src1, src2, src3, src4, css);
1791}
1792function qcms_convert_one(transformer, src, css) {
1793  wasm.qcms_convert_one(transformer, src, css);
1794}
1795function qcms_convert_three(transformer, src1, src2, src3, css) {
1796  wasm.qcms_convert_three(transformer, src1, src2, src3, css);
1797}
1798function qcms_drop_transformer(transformer) {
1799  wasm.qcms_drop_transformer(transformer);
1800}
1801function qcms_transformer_from_memory(mem, in_type, intent) {
1802  const ptr0 = passArray8ToWasm0(mem, wasm.__wbindgen_malloc);
1803  const len0 = WASM_VECTOR_LEN;
1804  const ret = wasm.qcms_transformer_from_memory(ptr0, len0, in_type, intent);
1805  return ret >>> 0;
1806}
1807function __wbg_get_imports() {
1808  const import0 = {
1809    __proto__: null,
1810    __wbg___wbindgen_throw_6b64449b9b9ed33c: function (arg0, arg1) {
1811      throw new Error(getStringFromWasm0(arg0, arg1));
1812    },
1813    __wbg_copy_result_0d15f3bf9d9012ae: function (arg0, arg1) {
1814      copy_result(arg0 >>> 0, arg1 >>> 0);
1815    },
1816    __wbg_copy_rgb_0106d9d9464fce43: function (arg0) {
1817      copy_rgb(arg0 >>> 0);
1818    },
1819    __wbg_make_cssRGB_8e24b34f71f5363e: function (arg0) {
1820      make_cssRGB(arg0 >>> 0);
1821    },
1822    __wbindgen_init_externref_table: function () {
1823      const table = wasm.__wbindgen_externrefs;
1824      const offset = table.grow(4);
1825      table.set(0, undefined);
1826      table.set(offset + 0, undefined);
1827      table.set(offset + 1, null);
1828      table.set(offset + 2, true);
1829      table.set(offset + 3, false);
1830    }
1831  };
1832  return {
1833    __proto__: null,
1834    "./qcms_bg.js": import0
1835  };
1836}
1837function getStringFromWasm0(ptr, len) {
1838  ptr = ptr >>> 0;
1839  return decodeText(ptr, len);
1840}
1841let cachedUint8ArrayMemory0 = null;
1842function getUint8ArrayMemory0() {
1843  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1844    cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1845  }
1846  return cachedUint8ArrayMemory0;
1847}
1848function passArray8ToWasm0(arg, malloc) {
1849  const ptr = malloc(arg.length * 1, 1) >>> 0;
1850  getUint8ArrayMemory0().set(arg, ptr / 1);
1851  WASM_VECTOR_LEN = arg.length;
1852  return ptr;
1853}
1854let cachedTextDecoder = new TextDecoder('utf-8', {
1855  ignoreBOM: true,
1856  fatal: true
1857});
1858cachedTextDecoder.decode();
1859const MAX_SAFARI_DECODE_BYTES = 2146435072;
1860let numBytesDecoded = 0;
1861function decodeText(ptr, len) {
1862  numBytesDecoded += len;
1863  if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1864    cachedTextDecoder = new TextDecoder('utf-8', {
1865      ignoreBOM: true,
1866      fatal: true
1867    });
1868    cachedTextDecoder.decode();
1869    numBytesDecoded = len;
1870  }
1871  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1872}
1873let WASM_VECTOR_LEN = 0;
1874let wasmModule, wasm;
1875function __wbg_finalize_init(instance, module) {
vendor: 6,337 bytes, lines 1875-2078
1875
1876  wasm = instance.exports;
1877  wasmModule = module;
1878  cachedUint8ArrayMemory0 = null;
1879  wasm.__wbindgen_start();
1880  return wasm;
1881}
1882async function __wbg_load(module, imports) {
1883  if (typeof Response === 'function' && module instanceof Response) {
1884    if (typeof WebAssembly.instantiateStreaming === 'function') {
1885      try {
1886        return await WebAssembly.instantiateStreaming(module, imports);
1887      } catch (e) {
1888        const validResponse = module.ok && expectedResponseType(module.type);
1889        if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1890          console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1891        } else {
1892          throw e;
1893        }
1894      }
1895    }
1896    const bytes = await module.arrayBuffer();
1897    return await WebAssembly.instantiate(bytes, imports);
1898  } else {
1899    const instance = await WebAssembly.instantiate(module, imports);
1900    if (instance instanceof WebAssembly.Instance) {
1901      return {
1902        instance,
1903        module
1904      };
1905    } else {
1906      return instance;
1907    }
1908  }
1909  function expectedResponseType(type) {
1910    switch (type) {
1911      case 'basic':
1912      case 'cors':
1913      case 'default':
1914        return true;
1915    }
1916    return false;
1917  }
1918}
1919function initSync(module) {
1920  if (wasm !== undefined) return wasm;
1921  if (module !== undefined) {
1922    if (Object.getPrototypeOf(module) === Object.prototype) {
1923      ({
1924        module
1925      } = module);
1926    } else {
1927      console.warn('using deprecated parameters for `initSync()`; pass a single object instead');
1928    }
1929  }
1930  const imports = __wbg_get_imports();
1931  if (!(module instanceof WebAssembly.Module)) {
1932    module = new WebAssembly.Module(module);
1933  }
1934  const instance = new WebAssembly.Instance(module, imports);
1935  return __wbg_finalize_init(instance, module);
1936}
1937async function __wbg_init(module_or_path) {
1938  if (wasm !== undefined) return wasm;
1939  if (module_or_path !== undefined) {
1940    if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1941      ({
1942        module_or_path
1943      } = module_or_path);
1944    } else {
1945      console.warn('using deprecated parameters for the initialization function; pass a single object instead');
1946    }
1947  }
1948  const imports = __wbg_get_imports();
1949  if (typeof module_or_path === 'string' || typeof Request === 'function' && module_or_path instanceof Request || typeof URL === 'function' && module_or_path instanceof URL) {
1950    module_or_path = fetch(module_or_path);
1951  }
1952  const {
1953    instance,
1954    module
1955  } = await __wbg_load(await module_or_path, imports);
1956  return __wbg_finalize_init(instance, module);
1957}
1958
1959;// ./src/shared/math_clamp.js
1960function MathClamp(v, min, max) {
1961  return Math.min(Math.max(v, min), max);
1962}
1963
1964;// ./src/core/colorspace.js
1965
1966
1967
1968function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
1969  const COMPONENTS = 3;
1970  alpha01 = alpha01 !== 1 ? 0 : alpha01;
1971  const xRatio = w1 / w2;
1972  const yRatio = h1 / h2;
1973  let newIndex = 0,
1974    oldIndex;
1975  const xScaled = new Uint16Array(w2);
1976  const w1Scanline = w1 * COMPONENTS;
1977  for (let i = 0; i < w2; i++) {
1978    xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
1979  }
1980  for (let i = 0; i < h2; i++) {
1981    const py = Math.floor(i * yRatio) * w1Scanline;
1982    for (let j = 0; j < w2; j++) {
1983      oldIndex = py + xScaled[j];
1984      dest[newIndex++] = src[oldIndex++];
1985      dest[newIndex++] = src[oldIndex++];
1986      dest[newIndex++] = src[oldIndex++];
1987      newIndex += alpha01;
1988    }
1989  }
1990}
1991function resizeRgbaImage(src, dest, w1, h1, w2, h2, alpha01) {
1992  const xRatio = w1 / w2;
1993  const yRatio = h1 / h2;
1994  let newIndex = 0;
1995  const xScaled = new Uint16Array(w2);
1996  if (alpha01 === 1) {
1997    for (let i = 0; i < w2; i++) {
1998      xScaled[i] = Math.floor(i * xRatio);
1999    }
2000    const src32 = new Uint32Array(src.buffer);
2001    const dest32 = new Uint32Array(dest.buffer);
2002    const rgbMask = FeatureTest.isLittleEndian ? 0x00ffffff : 0xffffff00;
2003    for (let i = 0; i < h2; i++) {
2004      const buf = src32.subarray(Math.floor(i * yRatio) * w1);
2005      for (let j = 0; j < w2; j++) {
2006        dest32[newIndex++] |= buf[xScaled[j]] & rgbMask;
2007      }
2008    }
2009  } else {
2010    const COMPONENTS = 4;
2011    const w1Scanline = w1 * COMPONENTS;
2012    for (let i = 0; i < w2; i++) {
2013      xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
2014    }
2015    for (let i = 0; i < h2; i++) {
2016      const buf = src.subarray(Math.floor(i * yRatio) * w1Scanline);
2017      for (let j = 0; j < w2; j++) {
2018        const oldIndex = xScaled[j];
2019        dest[newIndex++] = buf[oldIndex];
2020        dest[newIndex++] = buf[oldIndex + 1];
2021        dest[newIndex++] = buf[oldIndex + 2];
2022      }
2023    }
2024  }
2025}
2026function copyRgbaImage(src, dest, alpha01) {
2027  if (alpha01 === 1) {
2028    const src32 = new Uint32Array(src.buffer);
2029    const dest32 = new Uint32Array(dest.buffer);
2030    const rgbMask = FeatureTest.isLittleEndian ? 0x00ffffff : 0xffffff00;
2031    for (let i = 0, ii = src32.length; i < ii; i++) {
2032      dest32[i] |= src32[i] & rgbMask;
2033    }
2034  } else {
2035    let j = 0;
2036    for (let i = 0, ii = src.length; i < ii; i += 4) {
2037      dest[j++] = src[i];
2038      dest[j++] = src[i + 1];
2039      dest[j++] = src[i + 2];
2040    }
2041  }
2042}
2043function isDefaultDecodeHelper(decode, expectedLen) {
2044  if (!Array.isArray(decode)) {
2045    return true;
2046  }
2047  const decodeLen = decode.length;
2048  if (decodeLen < expectedLen) {
2049    warn("Decode map length is too short.");
2050    return true;
2051  }
2052  if (decodeLen > expectedLen) {
2053    info("Truncating too long decode map.");
2054    decode.length = expectedLen;
2055  }
2056  return false;
2057}
2058class ColorSpace {
2059  static #rgbBuf = new Uint8ClampedArray(3);
2060  constructor(name, numComps) {
2061    this.name = name;
2062    this.numComps = numComps;
2063  }
2064  getRgb(src, srcOffset, output = new Uint8ClampedArray(3)) {
2065    this.getRgbItem(src, srcOffset, output, 0);
2066    return output;
2067  }
2068  getRgbHex(src, srcOffset) {
2069    const buffer = this.getRgb(src, srcOffset, ColorSpace.#rgbBuf);
2070    return Util.makeHexColor(buffer[0], buffer[1], buffer[2]);
2071  }
2072  getRgbItem(src, srcOffset, dest, destOffset) {
2073    unreachable("Should not call ColorSpace.getRgbItem");
2074  }
2075  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2076    unreachable("Should not call ColorSpace.getRgbBuffer");
2077  }
2078  get
vendor: 3,544 bytes, lines 2078-2174
2078OutputLength(inputLength, alpha01) {
2079    unreachable("Should not call ColorSpace.getOutputLength");
2080  }
2081  isPassthrough(bits) {
2082    return false;
2083  }
2084  isDefaultDecode(decode, bpc) {
2085    return ColorSpace.isDefaultDecode(decode, this.numComps);
2086  }
2087  fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
2088    const count = originalWidth * originalHeight;
2089    let rgbBuf = null;
2090    const numComponentColors = 1 << bpc;
2091    const needsResizing = originalHeight !== height || originalWidth !== width;
2092    if (this.isPassthrough(bpc)) {
2093      rgbBuf = comps;
2094    } else if (this.numComps === 1 && count > numComponentColors && this.name !== "DeviceGray" && this.name !== "DeviceRGB") {
2095      const allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
2096      for (let i = 0; i < numComponentColors; i++) {
2097        allColors[i] = i;
2098      }
2099      const colorMap = new Uint8ClampedArray(numComponentColors * 3);
2100      this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
2101      if (!needsResizing) {
2102        let destPos = 0;
2103        for (let i = 0; i < count; ++i) {
2104          const key = comps[i] * 3;
2105          dest[destPos++] = colorMap[key];
2106          dest[destPos++] = colorMap[key + 1];
2107          dest[destPos++] = colorMap[key + 2];
2108          destPos += alpha01;
2109        }
2110      } else {
2111        rgbBuf = new Uint8Array(count * 3);
2112        let rgbPos = 0;
2113        for (let i = 0; i < count; ++i) {
2114          const key = comps[i] * 3;
2115          rgbBuf[rgbPos++] = colorMap[key];
2116          rgbBuf[rgbPos++] = colorMap[key + 1];
2117          rgbBuf[rgbPos++] = colorMap[key + 2];
2118        }
2119      }
2120    } else if (!needsResizing) {
2121      this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
2122    } else {
2123      rgbBuf = new Uint8ClampedArray(count * 3);
2124      this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
2125    }
2126    if (rgbBuf) {
2127      if (needsResizing) {
2128        resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
2129      } else {
2130        let destPos = 0,
2131          rgbPos = 0;
2132        for (let i = 0, ii = width * actualHeight; i < ii; i++) {
2133          dest[destPos++] = rgbBuf[rgbPos++];
2134          dest[destPos++] = rgbBuf[rgbPos++];
2135          dest[destPos++] = rgbBuf[rgbPos++];
2136          destPos += alpha01;
2137        }
2138      }
2139    }
2140  }
2141  get usesZeroToOneRange() {
2142    return shadow(this, "usesZeroToOneRange", true);
2143  }
2144  static isDefaultDecode(decode, numComps) {
2145    if (isDefaultDecodeHelper(decode, numComps * 2)) {
2146      return true;
2147    }
2148    for (let i = 0, ii = decode.length; i < ii; i += 2) {
2149      if (decode[i] !== 0 || decode[i + 1] !== 1) {
2150        return false;
2151      }
2152    }
2153    return true;
2154  }
2155}
2156class AlternateCS extends ColorSpace {
2157  constructor(numComps, base, tintFn) {
2158    super("Alternate", numComps);
2159    this.base = base;
2160    this.tintFn = tintFn;
2161    this.tmpBuf = new Float32Array(base.numComps);
2162  }
2163  getRgbItem(src, srcOffset, dest, destOffset) {
2164    const tmpBuf = this.tmpBuf;
2165    this.tintFn(src, srcOffset, tmpBuf, 0);
2166    this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
2167  }
2168  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2169    const tintFn = this.tintFn;
2170    const base = this.base;
2171    const scale = 1 / ((1 << bits) - 1);
2172    const baseNumComps = base.numComps;
2173    const usesZeroToOneRange = base.usesZeroToOneRange;
2174    const isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
vendor: 20,882 bytes, lines 2175-2729
2175    let pos = isPassthrough ? destOffset : 0;
2176    const baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
2177    const numComps = this.numComps;
2178    const scaled = new Float32Array(numComps);
2179    const tinted = new Float32Array(baseNumComps);
2180    let i, j;
2181    for (i = 0; i < count; i++) {
2182      for (j = 0; j < numComps; j++) {
2183        scaled[j] = src[srcOffset++] * scale;
2184      }
2185      tintFn(scaled, 0, tinted, 0);
2186      if (usesZeroToOneRange) {
2187        for (j = 0; j < baseNumComps; j++) {
2188          baseBuf[pos++] = tinted[j] * 255;
2189        }
2190      } else {
2191        base.getRgbItem(tinted, 0, baseBuf, pos);
2192        pos += baseNumComps;
2193      }
2194    }
2195    if (!isPassthrough) {
2196      base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
2197    }
2198  }
2199  getOutputLength(inputLength, alpha01) {
2200    return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
2201  }
2202}
2203class PatternCS extends ColorSpace {
2204  constructor(baseCS) {
2205    super("Pattern", null);
2206    this.base = baseCS;
2207  }
2208  isDefaultDecode(decode, bpc) {
2209    unreachable("Should not call PatternCS.isDefaultDecode");
2210  }
2211}
2212class IndexedCS extends ColorSpace {
2213  constructor(base, highVal, lookup) {
2214    super("Indexed", 1);
2215    this.base = base;
2216    this.highVal = highVal;
2217    const length = base.numComps * (highVal + 1);
2218    this.lookup = new Uint8Array(length);
2219    if (lookup instanceof BaseStream) {
2220      const bytes = lookup.getBytes(length);
2221      this.lookup.set(bytes);
2222    } else if (typeof lookup === "string") {
2223      for (let i = 0; i < length; ++i) {
2224        this.lookup[i] = lookup.charCodeAt(i) & 0xff;
2225      }
2226    } else {
2227      throw new FormatError(`IndexedCS - unrecognized lookup table: ${lookup}`);
2228    }
2229  }
2230  getRgbItem(src, srcOffset, dest, destOffset) {
2231    const {
2232      base,
2233      highVal,
2234      lookup
2235    } = this;
2236    const start = MathClamp(Math.round(src[srcOffset]), 0, highVal) * base.numComps;
2237    base.getRgbBuffer(lookup, start, 1, dest, destOffset, 8, 0);
2238  }
2239  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2240    const {
2241      base,
2242      highVal,
2243      lookup
2244    } = this;
2245    const {
2246      numComps
2247    } = base;
2248    const outputDelta = base.getOutputLength(numComps, alpha01);
2249    for (let i = 0; i < count; ++i) {
2250      const lookupPos = MathClamp(Math.round(src[srcOffset++]), 0, highVal) * numComps;
2251      base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
2252      destOffset += outputDelta;
2253    }
2254  }
2255  getOutputLength(inputLength, alpha01) {
2256    return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
2257  }
2258  isDefaultDecode(decode, bpc) {
2259    if (isDefaultDecodeHelper(decode, 2)) {
2260      return true;
2261    }
2262    if (!Number.isInteger(bpc) || bpc < 1) {
2263      warn("Bits per component is not correct");
2264      return true;
2265    }
2266    return decode[0] === 0 && decode[1] === (1 << bpc) - 1;
2267  }
2268}
2269class DeviceGrayCS extends ColorSpace {
2270  constructor() {
2271    super("DeviceGray", 1);
2272  }
2273  getRgbItem(src, srcOffset, dest, destOffset) {
2274    const c = src[srcOffset] * 255;
2275    dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
2276  }
2277  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2278    const scale = 255 / ((1 << bits) - 1);
2279    let j = srcOffset,
2280      q = destOffset;
2281    for (let i = 0; i < count; ++i) {
2282      const c = scale * src[j++];
2283      dest[q++] = c;
2284      dest[q++] = c;
2285      dest[q++] = c;
2286      q += alpha01;
2287    }
2288  }
2289  getOutputLength(inputLength, alpha01) {
2290    return inputLength * (3 + alpha01);
2291  }
2292}
2293class DeviceRgbCS extends ColorSpace {
2294  constructor() {
2295    super("DeviceRGB", 3);
2296  }
2297  getRgbItem(src, srcOffset, dest, destOffset) {
2298    dest[destOffset] = src[srcOffset] * 255;
2299    dest[destOffset + 1] = src[srcOffset + 1] * 255;
2300    dest[destOffset + 2] = src[srcOffset + 2] * 255;
2301  }
2302  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2303    if (bits === 8 && alpha01 === 0) {
2304      dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
2305      return;
2306    }
2307    const scale = 255 / ((1 << bits) - 1);
2308    let j = srcOffset,
2309      q = destOffset;
2310    for (let i = 0; i < count; ++i) {
2311      dest[q++] = scale * src[j++];
2312      dest[q++] = scale * src[j++];
2313      dest[q++] = scale * src[j++];
2314      q += alpha01;
2315    }
2316  }
2317  getOutputLength(inputLength, alpha01) {
2318    return inputLength * (3 + alpha01) / 3 | 0;
2319  }
2320  isPassthrough(bits) {
2321    return bits === 8;
2322  }
2323}
2324class DeviceRgbaCS extends ColorSpace {
2325  constructor() {
2326    super("DeviceRGBA", 4);
2327  }
2328  getOutputLength(inputLength, _alpha01) {
2329    return inputLength * 4;
2330  }
2331  isPassthrough(bits) {
2332    return bits === 8;
2333  }
2334  fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
2335    if (originalHeight !== height || originalWidth !== width) {
2336      resizeRgbaImage(comps, dest, originalWidth, originalHeight, width, height, alpha01);
2337    } else {
2338      copyRgbaImage(comps, dest, alpha01);
2339    }
2340  }
2341}
2342class DeviceCmykCS extends ColorSpace {
2343  constructor() {
2344    super("DeviceCMYK", 4);
2345  }
2346  #toRgb(src, srcOffset, srcScale, dest, destOffset) {
2347    const c = src[srcOffset] * srcScale;
2348    const m = src[srcOffset + 1] * srcScale;
2349    const y = src[srcOffset + 2] * srcScale;
2350    const k = src[srcOffset + 3] * srcScale;
2351    dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
2352    dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
2353    dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
2354  }
2355  getRgbItem(src, srcOffset, dest, destOffset) {
2356    this.#toRgb(src, srcOffset, 1, dest, destOffset);
2357  }
2358  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2359    const scale = 1 / ((1 << bits) - 1);
2360    for (let i = 0; i < count; i++) {
2361      this.#toRgb(src, srcOffset, scale, dest, destOffset);
2362      srcOffset += 4;
2363      destOffset += 3 + alpha01;
2364    }
2365  }
2366  getOutputLength(inputLength, alpha01) {
2367    return inputLength / 4 * (3 + alpha01) | 0;
2368  }
2369}
2370class CalGrayCS extends ColorSpace {
2371  constructor(whitePoint, blackPoint, gamma) {
2372    super("CalGray", 1);
2373    if (!whitePoint) {
2374      throw new FormatError("WhitePoint missing - required for color space CalGray");
2375    }
2376    [this.XW, this.YW, this.ZW] = whitePoint;
2377    [this.XB, this.YB, this.ZB] = blackPoint || [0, 0, 0];
2378    this.G = gamma || 1;
2379    if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
2380      throw new FormatError(`Invalid WhitePoint components for ${this.name}, no fallback available`);
2381    }
2382    if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
2383      info(`Invalid BlackPoint for ${this.name}, falling back to default.`);
2384      this.XB = this.YB = this.ZB = 0;
2385    }
2386    if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
2387      warn(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ` + `ZB: ${this.ZB}, only default values are supported.`);
2388    }
2389    if (this.G < 1) {
2390      info(`Invalid Gamma: ${this.G} for ${this.name}, falling back to default.`);
2391      this.G = 1;
2392    }
2393  }
2394  #toRgb(src, srcOffset, dest, destOffset, scale) {
2395    const A = src[srcOffset] * scale;
2396    const AG = A ** this.G;
2397    const L = this.YW * AG;
2398    const val = Math.max(295.8 * L ** 0.3333333333333333 - 40.8, 0);
2399    dest[destOffset] = val;
2400    dest[destOffset + 1] = val;
2401    dest[destOffset + 2] = val;
2402  }
2403  getRgbItem(src, srcOffset, dest, destOffset) {
2404    this.#toRgb(src, srcOffset, dest, destOffset, 1);
2405  }
2406  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2407    const scale = 1 / ((1 << bits) - 1);
2408    for (let i = 0; i < count; ++i) {
2409      this.#toRgb(src, srcOffset, dest, destOffset, scale);
2410      srcOffset += 1;
2411      destOffset += 3 + alpha01;
2412    }
2413  }
2414  getOutputLength(inputLength, alpha01) {
2415    return inputLength * (3 + alpha01);
2416  }
2417}
2418class CalRGBCS extends ColorSpace {
2419  static #BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
2420  static #BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
2421  static #SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
2422  static #FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
2423  static #tempNormalizeMatrix = new Float32Array(3);
2424  static #tempConvertMatrix1 = new Float32Array(3);
2425  static #tempConvertMatrix2 = new Float32Array(3);
2426  static #DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;
2427  constructor(whitePoint, blackPoint, gamma, matrix) {
2428    super("CalRGB", 3);
2429    if (!whitePoint) {
2430      throw new FormatError("WhitePoint missing - required for color space CalRGB");
2431    }
2432    const [XW, YW, ZW] = this.whitePoint = whitePoint;
2433    const [XB, YB, ZB] = this.blackPoint = blackPoint || new Float32Array(3);
2434    [this.GR, this.GG, this.GB] = gamma || new Float32Array([1, 1, 1]);
2435    [this.MXA, this.MYA, this.MZA, this.MXB, this.MYB, this.MZB, this.MXC, this.MYC, this.MZC] = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
2436    if (XW < 0 || ZW < 0 || YW !== 1) {
2437      throw new FormatError(`Invalid WhitePoint components for ${this.name}, no fallback available`);
2438    }
2439    if (XB < 0 || YB < 0 || ZB < 0) {
2440      info(`Invalid BlackPoint for ${this.name} [${XB}, ${YB}, ${ZB}], ` + "falling back to default.");
2441      this.blackPoint = new Float32Array(3);
2442    }
2443    if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
2444      info(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ` + `${this.name}, falling back to default.`);
2445      this.GR = this.GG = this.GB = 1;
2446    }
2447  }
2448  #matrixProduct(a, b, result) {
2449    result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
2450    result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
2451    result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
2452  }
2453  #toFlat(sourceWhitePoint, LMS, result) {
2454    result[0] = LMS[0] * 1 / sourceWhitePoint[0];
2455    result[1] = LMS[1] * 1 / sourceWhitePoint[1];
2456    result[2] = LMS[2] * 1 / sourceWhitePoint[2];
2457  }
2458  #toD65(sourceWhitePoint, LMS, result) {
2459    const D65X = 0.95047;
2460    const D65Y = 1;
2461    const D65Z = 1.08883;
2462    result[0] = LMS[0] * D65X / sourceWhitePoint[0];
2463    result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
2464    result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
2465  }
2466  #sRGBTransferFunction(color) {
2467    if (color <= 0.0031308) {
2468      return MathClamp(12.92 * color, 0, 1);
2469    }
2470    if (color >= 0.99554525) {
2471      return 1;
2472    }
2473    return MathClamp((1 + 0.055) * color ** (1 / 2.4) - 0.055, 0, 1);
2474  }
2475  #decodeL(L) {
2476    if (L < 0) {
2477      return -this.#decodeL(-L);
2478    }
2479    if (L > 8.0) {
2480      return ((L + 16) / 116) ** 3;
2481    }
2482    return L * CalRGBCS.#DECODE_L_CONSTANT;
2483  }
2484  #compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
2485    if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
2486      result[0] = XYZ_Flat[0];
2487      result[1] = XYZ_Flat[1];
2488      result[2] = XYZ_Flat[2];
2489      return;
2490    }
2491    const zeroDecodeL = this.#decodeL(0);
2492    const X_DST = zeroDecodeL;
2493    const X_SRC = this.#decodeL(sourceBlackPoint[0]);
2494    const Y_DST = zeroDecodeL;
2495    const Y_SRC = this.#decodeL(sourceBlackPoint[1]);
2496    const Z_DST = zeroDecodeL;
2497    const Z_SRC = this.#decodeL(sourceBlackPoint[2]);
2498    const X_Scale = (1 - X_DST) / (1 - X_SRC);
2499    const X_Offset = 1 - X_Scale;
2500    const Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
2501    const Y_Offset = 1 - Y_Scale;
2502    const Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
2503    const Z_Offset = 1 - Z_Scale;
2504    result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
2505    result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
2506    result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
2507  }
2508  #normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
2509    if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
2510      result[0] = XYZ_In[0];
2511      result[1] = XYZ_In[1];
2512      result[2] = XYZ_In[2];
2513      return;
2514    }
2515    const LMS = result;
2516    this.#matrixProduct(CalRGBCS.#BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
2517    const LMS_Flat = CalRGBCS.#tempNormalizeMatrix;
2518    this.#toFlat(sourceWhitePoint, LMS, LMS_Flat);
2519    this.#matrixProduct(CalRGBCS.#BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
2520  }
2521  #normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
2522    const LMS = result;
2523    this.#matrixProduct(CalRGBCS.#BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
2524    const LMS_D65 = CalRGBCS.#tempNormalizeMatrix;
2525    this.#toD65(sourceWhitePoint, LMS, LMS_D65);
2526    this.#matrixProduct(CalRGBCS.#BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
2527  }
2528  #toRgb(src, srcOffset, dest, destOffset, scale) {
2529    const A = MathClamp(src[srcOffset] * scale, 0, 1);
2530    const B = MathClamp(src[srcOffset + 1] * scale, 0, 1);
2531    const C = MathClamp(src[srcOffset + 2] * scale, 0, 1);
2532    const AGR = A === 1 ? 1 : A ** this.GR;
2533    const BGG = B === 1 ? 1 : B ** this.GG;
2534    const CGB = C === 1 ? 1 : C ** this.GB;
2535    const X = this.MXA * AGR + this.MXB * BGG + this.MXC * CGB;
2536    const Y = this.MYA * AGR + this.MYB * BGG + this.MYC * CGB;
2537    const Z = this.MZA * AGR + this.MZB * BGG + this.MZC * CGB;
2538    const XYZ = CalRGBCS.#tempConvertMatrix1;
2539    XYZ[0] = X;
2540    XYZ[1] = Y;
2541    XYZ[2] = Z;
2542    const XYZ_Flat = CalRGBCS.#tempConvertMatrix2;
2543    this.#normalizeWhitePointToFlat(this.whitePoint, XYZ, XYZ_Flat);
2544    const XYZ_Black = CalRGBCS.#tempConvertMatrix1;
2545    this.#compensateBlackPoint(this.blackPoint, XYZ_Flat, XYZ_Black);
2546    const XYZ_D65 = CalRGBCS.#tempConvertMatrix2;
2547    this.#normalizeWhitePointToD65(CalRGBCS.#FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
2548    const SRGB = CalRGBCS.#tempConvertMatrix1;
2549    this.#matrixProduct(CalRGBCS.#SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
2550    dest[destOffset] = this.#sRGBTransferFunction(SRGB[0]) * 255;
2551    dest[destOffset + 1] = this.#sRGBTransferFunction(SRGB[1]) * 255;
2552    dest[destOffset + 2] = this.#sRGBTransferFunction(SRGB[2]) * 255;
2553  }
2554  getRgbItem(src, srcOffset, dest, destOffset) {
2555    this.#toRgb(src, srcOffset, dest, destOffset, 1);
2556  }
2557  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2558    const scale = 1 / ((1 << bits) - 1);
2559    for (let i = 0; i < count; ++i) {
2560      this.#toRgb(src, srcOffset, dest, destOffset, scale);
2561      srcOffset += 3;
2562      destOffset += 3 + alpha01;
2563    }
2564  }
2565  getOutputLength(inputLength, alpha01) {
2566    return inputLength * (3 + alpha01) / 3 | 0;
2567  }
2568}
2569class LabCS extends ColorSpace {
2570  constructor(whitePoint, blackPoint, range) {
2571    super("Lab", 3);
2572    if (!whitePoint) {
2573      throw new FormatError("WhitePoint missing - required for color space Lab");
2574    }
2575    [this.XW, this.YW, this.ZW] = whitePoint;
2576    [this.amin, this.amax, this.bmin, this.bmax] = range || [-100, 100, -100, 100];
2577    [this.XB, this.YB, this.ZB] = blackPoint || [0, 0, 0];
2578    if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
2579      throw new FormatError("Invalid WhitePoint components, no fallback available");
2580    }
2581    if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
2582      info("Invalid BlackPoint, falling back to default");
2583      this.XB = this.YB = this.ZB = 0;
2584    }
2585    if (this.amin > this.amax || this.bmin > this.bmax) {
2586      info("Invalid Range, falling back to defaults");
2587      this.amin = -100;
2588      this.amax = 100;
2589      this.bmin = -100;
2590      this.bmax = 100;
2591    }
2592  }
2593  #fn_g(x) {
2594    return x >= 6 / 29 ? x ** 3 : 108 / 841 * (x - 4 / 29);
2595  }
2596  #decode(value, high1, low2, high2) {
2597    return low2 + value * (high2 - low2) / high1;
2598  }
2599  #toRgb(src, srcOffset, maxVal, dest, destOffset) {
2600    let Ls = src[srcOffset];
2601    let as = src[srcOffset + 1];
2602    let bs = src[srcOffset + 2];
2603    if (maxVal !== false) {
2604      Ls = this.#decode(Ls, maxVal, 0, 100);
2605      as = this.#decode(as, maxVal, this.amin, this.amax);
2606      bs = this.#decode(bs, maxVal, this.bmin, this.bmax);
2607    }
2608    if (as > this.amax) {
2609      as = this.amax;
2610    } else if (as < this.amin) {
2611      as = this.amin;
2612    }
2613    if (bs > this.bmax) {
2614      bs = this.bmax;
2615    } else if (bs < this.bmin) {
2616      bs = this.bmin;
2617    }
2618    const M = (Ls + 16) / 116;
2619    const L = M + as / 500;
2620    const N = M - bs / 200;
2621    const X = this.XW * this.#fn_g(L);
2622    const Y = this.YW * this.#fn_g(M);
2623    const Z = this.ZW * this.#fn_g(N);
2624    let r, g, b;
2625    if (this.ZW < 1) {
2626      r = X * 3.1339 + Y * -1.617 + Z * -0.4906;
2627      g = X * -0.9785 + Y * 1.916 + Z * 0.0333;
2628      b = X * 0.072 + Y * -0.229 + Z * 1.4057;
2629    } else {
2630      r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
2631      g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
2632      b = X * 0.0557 + Y * -0.204 + Z * 1.057;
2633    }
2634    dest[destOffset] = Math.sqrt(r) * 255;
2635    dest[destOffset + 1] = Math.sqrt(g) * 255;
2636    dest[destOffset + 2] = Math.sqrt(b) * 255;
2637  }
2638  getRgbItem(src, srcOffset, dest, destOffset) {
2639    this.#toRgb(src, srcOffset, false, dest, destOffset);
2640  }
2641  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2642    const maxVal = (1 << bits) - 1;
2643    for (let i = 0; i < count; i++) {
2644      this.#toRgb(src, srcOffset, maxVal, dest, destOffset);
2645      srcOffset += 3;
2646      destOffset += 3 + alpha01;
2647    }
2648  }
2649  getOutputLength(inputLength, alpha01) {
2650    return inputLength * (3 + alpha01) / 3 | 0;
2651  }
2652  isDefaultDecode(decode, bpc) {
2653    return true;
2654  }
2655  get usesZeroToOneRange() {
2656    return shadow(this, "usesZeroToOneRange", false);
2657  }
2658}
2659
2660;// ./src/core/icc_colorspace.js
2661
2662
2663
2664
2665function fetchSync(url) {
2666  const xhr = new XMLHttpRequest();
2667  xhr.open("GET", url, false);
2668  xhr.responseType = "arraybuffer";
2669  xhr.send(null);
2670  return xhr.response;
2671}
2672class IccColorSpace extends ColorSpace {
2673  #transformer;
2674  #convertPixel;
2675  static #useWasm = true;
2676  static #wasmUrl = null;
2677  static #finalizer = null;
2678  constructor(iccProfile, name, numComps) {
2679    if (!IccColorSpace.isUsable) {
2680      throw new Error("No ICC color space support");
2681    }
2682    super(name, numComps);
2683    let inType;
2684    switch (numComps) {
2685      case 1:
2686        inType = DataType.Gray8;
2687        this.#convertPixel = (src, srcOffset, css) => qcms_convert_one(this.#transformer, src[srcOffset] * 255, css);
2688        break;
2689      case 3:
2690        inType = DataType.RGB8;
2691        this.#convertPixel = (src, srcOffset, css) => qcms_convert_three(this.#transformer, src[srcOffset] * 255, src[srcOffset + 1] * 255, src[srcOffset + 2] * 255, css);
2692        break;
2693      case 4:
2694        inType = DataType.CMYK;
2695        this.#convertPixel = (src, srcOffset, css) => qcms_convert_four(this.#transformer, src[srcOffset] * 255, src[srcOffset + 1] * 255, src[srcOffset + 2] * 255, src[srcOffset + 3] * 255, css);
2696        break;
2697      default:
2698        throw new Error(`Unsupported number of components: ${numComps}`);
2699    }
2700    this.#transformer = qcms_transformer_from_memory(iccProfile, inType, Intent.Perceptual);
2701    if (!this.#transformer) {
2702      throw new Error("Failed to create ICC color space");
2703    }
2704    IccColorSpace.#finalizer ||= new FinalizationRegistry(transformer => {
2705      qcms_drop_transformer(transformer);
2706    });
2707    IccColorSpace.#finalizer.register(this, this.#transformer);
2708  }
2709  getRgbHex(src, srcOffset) {
2710    this.#convertPixel(src, srcOffset, true);
2711    return QCMS._cssColor;
2712  }
2713  getRgbItem(src, srcOffset, dest, destOffset) {
2714    QCMS._destBuffer = dest;
2715    QCMS._destOffset = destOffset;
2716    QCMS._destLength = 3;
2717    this.#convertPixel(src, srcOffset, false);
2718    QCMS._destBuffer = null;
2719  }
2720  getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
2721    src = src.subarray(srcOffset, srcOffset + count * this.numComps);
2722    if (bits !== 8) {
2723      const scale = 255 / ((1 << bits) - 1);
2724      for (let i = 0, ii = src.length; i < ii; i++) {
2725        src[i] *= scale;
2726      }
2727    }
2728    QCMS._mustAddAlpha = alpha01 && dest.buffer === src.buffer;
2729    QCMS._destBuffer = dest;
vendor: 7,600 bytes, lines 2730-3006
2730    QCMS._destOffset = destOffset;
2731    QCMS._destLength = count * (3 + alpha01);
2732    qcms_convert_array(this.#transformer, src);
2733    QCMS._mustAddAlpha = false;
2734    QCMS._destBuffer = null;
2735  }
2736  getOutputLength(inputLength, alpha01) {
2737    return inputLength / this.numComps * (3 + alpha01) | 0;
2738  }
2739  static setOptions({
2740    useWasm,
2741    useWorkerFetch,
2742    wasmUrl
2743  }) {
2744    if (!useWorkerFetch) {
2745      this.#useWasm = false;
2746      return;
2747    }
2748    this.#useWasm = useWasm;
2749    this.#wasmUrl = wasmUrl;
2750  }
2751  static get isUsable() {
2752    let isUsable = false;
2753    if (this.#useWasm) {
2754      if (this.#wasmUrl) {
2755        try {
2756          this._module = initSync({
2757            module: fetchSync(`${this.#wasmUrl}qcms_bg.wasm`)
2758          });
2759          isUsable = !!this._module;
2760          QCMS._memory = this._module.memory;
2761          QCMS._makeHexColor = Util.makeHexColor.bind(Util);
2762        } catch (e) {
2763          warn(`ICCBased color space: "${e}".`);
2764        }
2765      } else {
2766        warn("No ICC color space support due to missing `wasmUrl` API option");
2767      }
2768    }
2769    return shadow(this, "isUsable", isUsable);
2770  }
2771}
2772class CmykICCBasedCS extends IccColorSpace {
2773  static #iccUrl;
2774  constructor() {
2775    const iccProfile = new Uint8Array(fetchSync(`${CmykICCBasedCS.#iccUrl}CGATS001Compat-v2-micro.icc`));
2776    super(iccProfile, "DeviceCMYK", 4);
2777  }
2778  static setOptions({
2779    iccUrl
2780  }) {
2781    this.#iccUrl = iccUrl;
2782  }
2783  static get isUsable() {
2784    let isUsable = false;
2785    if (IccColorSpace.isUsable) {
2786      if (this.#iccUrl) {
2787        isUsable = true;
2788      } else {
2789        warn("No CMYK ICC profile support due to missing `iccUrl` API option");
2790      }
2791    }
2792    return shadow(this, "isUsable", isUsable);
2793  }
2794}
2795
2796;// ./src/core/stream.js
2797
2798
2799class Stream extends BaseStream {
2800  constructor(arrayBuffer, start, length, dict) {
2801    super();
2802    this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
2803    this.start = start || 0;
2804    this.pos = this.start;
2805    this.end = start + length || this.bytes.length;
2806    this.dict = dict;
2807  }
2808  get length() {
2809    return this.end - this.start;
2810  }
2811  get isEmpty() {
2812    return this.length === 0;
2813  }
2814  getByte() {
2815    if (this.pos >= this.end) {
2816      return -1;
2817    }
2818    return this.bytes[this.pos++];
2819  }
2820  getBytes(length) {
2821    const pos = this.pos;
2822    const endPos = !length ? this.end : Math.min(pos + length, this.end);
2823    this.pos = endPos;
2824    return this.bytes.subarray(pos, endPos);
2825  }
2826  getByteRange(begin, end) {
2827    if (begin < 0) {
2828      begin = 0;
2829    }
2830    if (end > this.end) {
2831      end = this.end;
2832    }
2833    return this.bytes.subarray(begin, end);
2834  }
2835  reset() {
2836    this.pos = this.start;
2837  }
2838  moveStart() {
2839    this.start = this.pos;
2840  }
2841  makeSubStream(start, length, dict = null) {
2842    return new Stream(this.bytes.buffer, start, length, dict);
2843  }
2844  clone() {
2845    return new Stream(this.bytes.buffer, this.start, this.length, this.dict?.clone());
2846  }
2847}
2848class StringStream extends Stream {
2849  constructor(str, dict = null) {
2850    super(stringToBytes(str), NaN, NaN, dict);
2851  }
2852}
2853class NullStream extends Stream {
2854  constructor() {
2855    super(new Uint8Array(0));
2856  }
2857}
2858
2859;// ./src/core/chunked_stream.js
2860
2861
2862
2863
2864class ChunkedStream extends Stream {
2865  progressiveDataLength = 0;
2866  _lastSuccessfulEnsureByteChunk = -1;
2867  _loadedChunks = new Set();
2868  constructor(length, chunkSize, manager) {
2869    super(new Uint8Array(length), 0, length, null);
2870    this.chunkSize = chunkSize;
2871    this.numChunks = Math.ceil(length / chunkSize);
2872    this.manager = manager;
2873  }
2874  getMissingChunks() {
2875    const chunks = [];
2876    for (let chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
2877      if (!this._loadedChunks.has(chunk)) {
2878        chunks.push(chunk);
2879      }
2880    }
2881    return chunks;
2882  }
2883  get numChunksLoaded() {
2884    return this._loadedChunks.size;
2885  }
2886  get isDataLoaded() {
2887    return this.numChunksLoaded === this.numChunks;
2888  }
2889  onReceiveData(begin, chunk) {
2890    const chunkSize = this.chunkSize;
2891    if (begin % chunkSize !== 0) {
2892      throw new Error(`Bad begin offset: ${begin}`);
2893    }
2894    const end = begin + chunk.byteLength;
2895    if (end % chunkSize !== 0 && end !== this.bytes.length) {
2896      throw new Error(`Bad end offset: ${end}`);
2897    }
2898    this.bytes.set(new Uint8Array(chunk), begin);
2899    const beginChunk = Math.floor(begin / chunkSize);
2900    const endChunk = Math.floor((end - 1) / chunkSize) + 1;
2901    for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
2902      this._loadedChunks.add(curChunk);
2903    }
2904  }
2905  onReceiveProgressiveData(data) {
2906    let position = this.progressiveDataLength;
2907    const beginChunk = Math.floor(position / this.chunkSize);
2908    this.bytes.set(new Uint8Array(data), position);
2909    position += data.byteLength;
2910    this.progressiveDataLength = position;
2911    const endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
2912    for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
2913      this._loadedChunks.add(curChunk);
2914    }
2915  }
2916  ensureByte(pos) {
2917    if (pos < this.progressiveDataLength) {
2918      return;
2919    }
2920    const chunk = Math.floor(pos / this.chunkSize);
2921    if (chunk > this.numChunks) {
2922      return;
2923    }
2924    if (chunk === this._lastSuccessfulEnsureByteChunk) {
2925      return;
2926    }
2927    if (!this._loadedChunks.has(chunk)) {
2928      throw new MissingDataException(pos, pos + 1);
2929    }
2930    this._lastSuccessfulEnsureByteChunk = chunk;
2931  }
2932  ensureRange(begin, end) {
2933    if (begin >= end) {
2934      return;
2935    }
2936    if (end <= this.progressiveDataLength) {
2937      return;
2938    }
2939    const beginChunk = Math.floor(begin / this.chunkSize);
2940    if (beginChunk > this.numChunks) {
2941      return;
2942    }
2943    const endChunk = Math.min(Math.floor((end - 1) / this.chunkSize) + 1, this.numChunks);
2944    for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
2945      if (!this._loadedChunks.has(chunk)) {
2946        throw new MissingDataException(begin, end);
2947      }
2948    }
2949  }
2950  nextEmptyChunk(beginChunk) {
2951    const numChunks = this.numChunks;
2952    for (let i = 0; i < numChunks; ++i) {
2953      const chunk = (beginChunk + i) % numChunks;
2954      if (!this._loadedChunks.has(chunk)) {
2955        return chunk;
2956      }
2957    }
2958    return null;
2959  }
2960  hasChunk(chunk) {
2961    return this._loadedChunks.has(chunk);
2962  }
2963  getByte() {
2964    const pos = this.pos;
2965    if (pos >= this.end) {
2966      return -1;
2967    }
2968    if (pos >= this.progressiveDataLength) {
2969      this.ensureByte(pos);
2970    }
2971    return this.bytes[this.pos++];
2972  }
2973  getBytes(length) {
2974    const pos = this.pos;
2975    const endPos = !length ? this.end : Math.min(pos + length, this.end);
2976    if (endPos > this.progressiveDataLength) {
2977      this.ensureRange(pos, endPos);
2978    }
2979    this.pos = endPos;
2980    return this.bytes.subarray(pos, endPos);
2981  }
2982  getByteRange(begin, end) {
2983    if (begin < 0) {
2984      begin = 0;
2985    }
2986    if (end > this.end) {
2987      end = this.end;
2988    }
2989    if (end > this.progressiveDataLength) {
2990      this.ensureRange(begin, end);
2991    }
2992    return this.bytes.subarray(begin, end);
2993  }
2994  makeSubStream(start, length, dict = null) {
2995    if (length) {
2996      if (start + length > this.progressiveDataLength) {
2997        this.ensureRange(start, start + length);
2998      }
2999    } else if (start >= this.progressiveDataLength) {
3000      this.ensureByte(start);
3001    }
3002    function ChunkedStreamSubstream() {}
3003    ChunkedStreamSubstream.prototype = Object.create(this);
3004    ChunkedStreamSubstream.prototype.getMissingChunks = function () {
3005      const chunkSize = this.chunkSize;
3006      const beginChunk = Math.floor(this.start / chunkSize);
3007      const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
3008      const missingChunks = [];
3009      for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
3010        if (!this._loadedChunks.has(chunk)) {
3011          missingChunks.push(chunk);
3012        }
3013      }
3014      return missingChunks;
3015    };
3016    Object.defineProperty(ChunkedStreamSubstream.prototype, "isDataLoaded", {
3017      get() {
3018        if (this.numChunksLoaded === this.numChunks) {
3019          return true;
3020        }
3021        return
vendor: 11,701 bytes, lines 3021-3404
3021 this.getMissingChunks().length === 0;
3022      },
3023      configurable: true
3024    });
3025    const subStream = new ChunkedStreamSubstream();
3026    subStream.pos = subStream.start = start;
3027    subStream.end = start + length || this.end;
3028    subStream.dict = dict;
3029    return subStream;
3030  }
3031  getBaseStreams() {
3032    return [this];
3033  }
3034}
3035class ChunkedStreamManager {
3036  #aborted = false;
3037  currRequestId = 0;
3038  _chunksNeededByRequest = new Map();
3039  #loadedStreamCapability = Promise.withResolvers();
3040  _promisesByRequest = new Map();
3041  _requestsByChunk = new Map();
3042  constructor(pdfStream, args) {
3043    this.length = args.length;
3044    this.chunkSize = args.rangeChunkSize;
3045    this.stream = new ChunkedStream(this.length, this.chunkSize, this);
3046    this.pdfStream = pdfStream;
3047    this.disableAutoFetch = args.disableAutoFetch;
3048    this.msgHandler = args.msgHandler;
3049  }
3050  async sendRequest(begin, end) {
3051    const rangeReader = this.pdfStream.getRangeReader(begin, end);
3052    let chunks = [];
3053    while (true) {
3054      const {
3055        value,
3056        done
3057      } = await rangeReader.read();
3058      if (this.#aborted) {
3059        chunks = null;
3060        return;
3061      }
3062      if (done) {
3063        break;
3064      }
3065      chunks.push(value);
3066    }
3067    if (chunks.length === 0 && this.disableAutoFetch) {
3068      return;
3069    }
3070    const data = arrayBuffersToBytes(chunks);
3071    chunks = null;
3072    this.onReceiveData({
3073      chunk: data.buffer,
3074      begin
3075    });
3076  }
3077  requestAllChunks(noFetch = false) {
3078    if (!noFetch) {
3079      const missingChunks = this.stream.getMissingChunks();
3080      this._requestChunks(missingChunks);
3081    }
3082    return this.#loadedStreamCapability.promise;
3083  }
3084  _requestChunks(chunks) {
3085    const requestId = this.currRequestId++;
3086    const chunksNeeded = new Set();
3087    this._chunksNeededByRequest.set(requestId, chunksNeeded);
3088    for (const chunk of chunks) {
3089      if (!this.stream.hasChunk(chunk)) {
3090        chunksNeeded.add(chunk);
3091      }
3092    }
3093    if (chunksNeeded.size === 0) {
3094      return Promise.resolve();
3095    }
3096    const capability = Promise.withResolvers();
3097    this._promisesByRequest.set(requestId, capability);
3098    const chunksToRequest = [];
3099    for (const chunk of chunksNeeded) {
3100      const requestIds = this._requestsByChunk.getOrInsertComputed(chunk, () => {
3101        chunksToRequest.push(chunk);
3102        return [];
3103      });
3104      requestIds.push(requestId);
3105    }
3106    if (chunksToRequest.length > 0) {
3107      const groupedChunksToRequest = this.groupChunks(chunksToRequest);
3108      for (const groupedChunk of groupedChunksToRequest) {
3109        const begin = groupedChunk.beginChunk * this.chunkSize;
3110        const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
3111        this.sendRequest(begin, end).catch(capability.reject);
3112      }
3113    }
3114    return capability.promise.catch(reason => {
3115      if (this.#aborted) {
3116        return;
3117      }
3118      throw reason;
3119    });
3120  }
3121  getStream() {
3122    return this.stream;
3123  }
3124  requestRange(begin, end) {
3125    end = Math.min(end, this.length);
3126    const beginChunk = this.getBeginChunk(begin);
3127    const endChunk = this.getEndChunk(end);
3128    const chunks = [];
3129    for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
3130      chunks.push(chunk);
3131    }
3132    return this._requestChunks(chunks);
3133  }
3134  requestRanges(ranges = []) {
3135    const chunksToRequest = [];
3136    for (const range of ranges) {
3137      const beginChunk = this.getBeginChunk(range.begin);
3138      const endChunk = this.getEndChunk(range.end);
3139      for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
3140        if (!chunksToRequest.includes(chunk)) {
3141          chunksToRequest.push(chunk);
3142        }
3143      }
3144    }
3145    chunksToRequest.sort((a, b) => a - b);
3146    return this._requestChunks(chunksToRequest);
3147  }
3148  groupChunks(chunks) {
3149    const groupedChunks = [];
3150    let beginChunk = -1;
3151    let prevChunk = -1;
3152    for (let i = 0, ii = chunks.length; i < ii; ++i) {
3153      const chunk = chunks[i];
3154      if (beginChunk < 0) {
3155        beginChunk = chunk;
3156      }
3157      if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
3158        groupedChunks.push({
3159          beginChunk,
3160          endChunk: prevChunk + 1
3161        });
3162        beginChunk = chunk;
3163      }
3164      if (i + 1 === chunks.length) {
3165        groupedChunks.push({
3166          beginChunk,
3167          endChunk: chunk + 1
3168        });
3169      }
3170      prevChunk = chunk;
3171    }
3172    return groupedChunks;
3173  }
3174  onReceiveData(args) {
3175    const {
3176      chunkSize,
3177      length,
3178      stream
3179    } = this;
3180    const chunk = args.chunk;
3181    const isProgressive = args.begin === undefined;
3182    const begin = isProgressive ? stream.progressiveDataLength : args.begin;
3183    const end = begin + chunk.byteLength;
3184    const beginChunk = Math.floor(begin / chunkSize);
3185    const endChunk = end < length ? Math.floor(end / chunkSize) : Math.ceil(end / chunkSize);
3186    if (isProgressive) {
3187      stream.onReceiveProgressiveData(chunk);
3188    } else {
3189      stream.onReceiveData(begin, chunk);
3190    }
3191    if (stream.isDataLoaded) {
3192      this.#loadedStreamCapability.resolve(stream);
3193    }
3194    const loadedRequests = [];
3195    for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
3196      const requestIds = this._requestsByChunk.get(curChunk);
3197      if (!requestIds) {
3198        continue;
3199      }
3200      this._requestsByChunk.delete(curChunk);
3201      for (const requestId of requestIds) {
3202        const chunksNeeded = this._chunksNeededByRequest.get(requestId);
3203        if (chunksNeeded.has(curChunk)) {
3204          chunksNeeded.delete(curChunk);
3205        }
3206        if (chunksNeeded.size > 0) {
3207          continue;
3208        }
3209        loadedRequests.push(requestId);
3210      }
3211    }
3212    if (!this.disableAutoFetch && this._requestsByChunk.size === 0) {
3213      let nextEmptyChunk;
3214      if (stream.numChunksLoaded === 1) {
3215        const lastChunk = stream.numChunks - 1;
3216        if (!stream.hasChunk(lastChunk)) {
3217          nextEmptyChunk = lastChunk;
3218        }
3219      } else {
3220        nextEmptyChunk = stream.nextEmptyChunk(endChunk);
3221      }
3222      if (Number.isInteger(nextEmptyChunk)) {
3223        this._requestChunks([nextEmptyChunk]);
3224      }
3225    }
3226    for (const requestId of loadedRequests) {
3227      const capability = this._promisesByRequest.get(requestId);
3228      this._promisesByRequest.delete(requestId);
3229      capability.resolve();
3230    }
3231    this.msgHandler.send("DocProgress", {
3232      loaded: MathClamp(stream.numChunksLoaded * chunkSize, stream.progressiveDataLength, length),
3233      total: length
3234    });
3235  }
3236  getBeginChunk(begin) {
3237    return Math.floor(begin / this.chunkSize);
3238  }
3239  getEndChunk(end) {
3240    return Math.floor((end - 1) / this.chunkSize) + 1;
3241  }
3242  abort(reason) {
3243    this.#aborted = true;
3244    this.pdfStream?.cancelAllRequests(reason);
3245    for (const capability of this._promisesByRequest.values()) {
3246      capability.reject(reason);
3247    }
3248    this.#loadedStreamCapability.reject(reason);
3249  }
3250}
3251
3252;// ./src/shared/image_utils.js
3253
3254function convertToRGBA(params) {
3255  switch (params.kind) {
3256    case ImageKind.GRAYSCALE_1BPP:
3257      return convertBlackAndWhiteToRGBA(params);
3258    case ImageKind.RGB_24BPP:
3259      return convertRGBToRGBA(params);
3260  }
3261  return null;
3262}
3263function convertBlackAndWhiteToRGBA({
3264  src,
3265  srcPos = 0,
3266  dest,
3267  width,
3268  height,
3269  nonBlackColor = 0xffffffff,
3270  inverseDecode = false
3271}) {
3272  const black = FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff;
3273  const [zeroMapping, oneMapping] = inverseDecode ? [nonBlackColor, black] : [black, nonBlackColor];
3274  const widthInSource = width >> 3;
3275  const widthRemainder = width & 7;
3276  const xorMask = zeroMapping ^ oneMapping;
3277  const srcLength = src.length;
3278  dest = new Uint32Array(dest.buffer);
3279  let destPos = 0;
3280  for (let i = 0; i < height; ++i) {
3281    for (const max = srcPos + widthInSource; srcPos < max; ++srcPos, destPos += 8) {
3282      const elem = src[srcPos];
3283      dest[destPos] = zeroMapping ^ -(elem >> 7 & 1) & xorMask;
3284      dest[destPos + 1] = zeroMapping ^ -(elem >> 6 & 1) & xorMask;
3285      dest[destPos + 2] = zeroMapping ^ -(elem >> 5 & 1) & xorMask;
3286      dest[destPos + 3] = zeroMapping ^ -(elem >> 4 & 1) & xorMask;
3287      dest[destPos + 4] = zeroMapping ^ -(elem >> 3 & 1) & xorMask;
3288      dest[destPos + 5] = zeroMapping ^ -(elem >> 2 & 1) & xorMask;
3289      dest[destPos + 6] = zeroMapping ^ -(elem >> 1 & 1) & xorMask;
3290      dest[destPos + 7] = zeroMapping ^ -(elem & 1) & xorMask;
3291    }
3292    if (widthRemainder === 0) {
3293      continue;
3294    }
3295    const elem = srcPos < srcLength ? src[srcPos++] : 255;
3296    for (let j = 0; j < widthRemainder; ++j, ++destPos) {
3297      dest[destPos] = zeroMapping ^ -(elem >> 7 - j & 1) & xorMask;
3298    }
3299  }
3300  return {
3301    srcPos,
3302    destPos
3303  };
3304}
3305function convertRGBToRGBA({
3306  src,
3307  srcPos = 0,
3308  dest,
3309  destPos = 0,
3310  width,
3311  height
3312}) {
3313  let i = 0;
3314  const len = width * height * 3;
3315  const len32 = len >> 2;
3316  const src32 = new Uint32Array(src.buffer, srcPos, len32);
3317  const alphaMask = FeatureTest.isLittleEndian ? 0xff000000 : 0xff;
3318  if (FeatureTest.isLittleEndian) {
3319    for (; i < len32 - 2; i += 3, destPos += 4) {
3320      const s1 = src32[i],
3321        s2 = src32[i + 1],
3322        s3 = src32[i + 2];
3323      dest[destPos] = s1 | alphaMask;
3324      dest[destPos + 1] = s1 >>> 24 | s2 << 8 | alphaMask;
3325      dest[destPos + 2] = s2 >>> 16 | s3 << 16 | alphaMask;
3326      dest[destPos + 3] = s3 >>> 8 | alphaMask;
3327    }
3328    for (let j = i * 4, jj = srcPos + len; j < jj; j += 3) {
3329      dest[destPos++] = src[j] | src[j + 1] << 8 | src[j + 2] << 16 | alphaMask;
3330    }
3331  } else {
3332    for (; i < len32 - 2; i += 3, destPos += 4) {
3333      const s1 = src32[i],
3334        s2 = src32[i + 1],
3335        s3 = src32[i + 2];
3336      dest[destPos] = s1 | alphaMask;
3337      dest[destPos + 1] = s1 << 24 | s2 >>> 8 | alphaMask;
3338      dest[destPos + 2] = s2 << 16 | s3 >>> 16 | alphaMask;
3339      dest[destPos + 3] = s3 << 8 | alphaMask;
3340    }
3341    for (let j = i * 4, jj = srcPos + len; j < jj; j += 3) {
3342      dest[destPos++] = src[j] << 24 | src[j + 1] << 16 | src[j + 2] << 8 | alphaMask;
3343    }
3344  }
3345  return {
3346    srcPos: srcPos + len,
3347    destPos
3348  };
3349}
3350function grayToRGBA(src, dest) {
3351  if (FeatureTest.isLittleEndian) {
3352    for (let i = 0, ii = src.length; i < ii; i++) {
3353      dest[i] = src[i] * 0x10101 | 0xff000000;
3354    }
3355  } else {
3356    for (let i = 0, ii = src.length; i < ii; i++) {
3357      dest[i] = src[i] * 0x1010100 | 0x000000ff;
3358    }
3359  }
3360}
3361
3362;// ./src/core/image_resizer.js
3363
3364
3365
3366const MIN_IMAGE_DIM = 2048;
3367const MAX_IMAGE_DIM = 32768;
3368const MAX_ERROR = 128;
3369class ImageResizer {
3370  static #goodSquareLength = MIN_IMAGE_DIM;
3371  static #isImageDecoderSupported = FeatureTest.isImageDecoderSupported;
3372  constructor(imgData, isMask) {
3373    this._imgData = imgData;
3374    this._isMask = isMask;
3375  }
3376  static get canUseImageDecoder() {
3377    return shadow(this, "canUseImageDecoder", this.#isImageDecoderSupported ? ImageDecoder.isTypeSupported("image/bmp") : Promise.resolve(false));
3378  }
3379  static needsToBeResized(width, height) {
3380    if (width <= this.#goodSquareLength && height <= this.#goodSquareLength) {
3381      return false;
3382    }
3383    const {
3384      MAX_DIM
3385    } = this;
3386    if (width > MAX_DIM || height > MAX_DIM) {
3387      return true;
3388    }
3389    const area = width * height;
3390    if (this._hasMaxArea) {
3391      return area > this.MAX_AREA;
3392    }
3393    if (area < this.#goodSquareLength ** 2) {
3394      return false;
3395    }
3396    if (this._areGoodDims(width, height)) {
3397      this.#goodSquareLength = Math.max(this.#goodSquareLength, Math.floor(Math.sqrt(width * height)));
3398      return false;
3399    }
3400    this.#goodSquareLength = this._guessMax(this.#goodSquareLength, MAX_DIM, MAX_ERROR, 0);
3401    const maxArea = this.MAX_AREA = this.#goodSquareLength ** 2;
3402    return area > maxArea;
3403  }
3404  static getReducePower
vendor: 6,535 bytes, lines 3404-3622
3404ForJPX(width, height, componentsCount) {
3405    const area = width * height;
3406    const maxJPXArea = 2 ** 30 / (componentsCount * 4);
3407    if (!this.needsToBeResized(width, height)) {
3408      if (area > maxJPXArea) {
3409        return Math.ceil(Math.log2(area / maxJPXArea));
3410      }
3411      return 0;
3412    }
3413    const {
3414      MAX_DIM,
3415      MAX_AREA
3416    } = this;
3417    const minFactor = Math.max(width / MAX_DIM, height / MAX_DIM, Math.sqrt(area / Math.min(maxJPXArea, MAX_AREA)));
3418    return Math.ceil(Math.log2(minFactor));
3419  }
3420  static get MAX_DIM() {
3421    return shadow(this, "MAX_DIM", this._guessMax(MIN_IMAGE_DIM, MAX_IMAGE_DIM, 0, 1));
3422  }
3423  static get MAX_AREA() {
3424    this._hasMaxArea = true;
3425    return shadow(this, "MAX_AREA", this._guessMax(this.#goodSquareLength, this.MAX_DIM, MAX_ERROR, 0) ** 2);
3426  }
3427  static set MAX_AREA(area) {
3428    if (area >= 0) {
3429      this._hasMaxArea = true;
3430      shadow(this, "MAX_AREA", area);
3431    }
3432  }
3433  static setOptions({
3434    canvasMaxAreaInBytes = -1,
3435    isImageDecoderSupported = false
3436  }) {
3437    if (!this._hasMaxArea) {
3438      this.MAX_AREA = canvasMaxAreaInBytes >> 2;
3439    }
3440    this.#isImageDecoderSupported = isImageDecoderSupported;
3441  }
3442  static _areGoodDims(width, height) {
3443    try {
3444      const canvas = new OffscreenCanvas(width, height);
3445      const ctx = canvas.getContext("2d");
3446      ctx.fillRect(0, 0, 1, 1);
3447      const opacity = ctx.getImageData(0, 0, 1, 1).data[3];
3448      canvas.width = canvas.height = 1;
3449      return opacity !== 0;
3450    } catch {
3451      return false;
3452    }
3453  }
3454  static _guessMax(start, end, tolerance, defaultHeight) {
3455    while (start + tolerance + 1 < end) {
3456      const middle = Math.floor((start + end) / 2);
3457      const height = defaultHeight || middle;
3458      if (this._areGoodDims(middle, height)) {
3459        start = middle;
3460      } else {
3461        end = middle;
3462      }
3463    }
3464    return start;
3465  }
3466  static async createImage(imgData, isMask = false) {
3467    return new ImageResizer(imgData, isMask)._createImage();
3468  }
3469  async _createImage() {
3470    const {
3471      _imgData: imgData
3472    } = this;
3473    const {
3474      width,
3475      height
3476    } = imgData;
3477    if (width * height * 4 > MAX_INT_32) {
3478      const result = this.#rescaleImageData();
3479      if (result) {
3480        return result;
3481      }
3482    }
3483    const data = this._encodeBMP();
3484    let decoder, imagePromise;
3485    if (await ImageResizer.canUseImageDecoder) {
3486      decoder = new ImageDecoder({
3487        data,
3488        type: "image/bmp",
3489        preferAnimation: false,
3490        transfer: [data.buffer]
3491      });
3492      imagePromise = decoder.decode().catch(reason => {
3493        warn(`BMP image decoding failed: ${reason}`);
3494        return createImageBitmap(new Blob([this._encodeBMP().buffer], {
3495          type: "image/bmp"
3496        }));
3497      }).finally(() => {
3498        decoder.close();
3499      });
3500    } else {
3501      imagePromise = createImageBitmap(new Blob([data.buffer], {
3502        type: "image/bmp"
3503      }));
3504    }
3505    const {
3506      MAX_AREA,
3507      MAX_DIM
3508    } = ImageResizer;
3509    const minFactor = Math.max(width / MAX_DIM, height / MAX_DIM, Math.sqrt(width * height / MAX_AREA));
3510    const firstFactor = Math.max(minFactor, 2);
3511    const factor = Math.round(10 * (minFactor + 1.25)) / 10 / firstFactor;
3512    const N = Math.floor(Math.log2(factor));
3513    const steps = new Array(N + 2).fill(2);
3514    steps[0] = firstFactor;
3515    steps.splice(-1, 1, factor / (1 << N));
3516    let newWidth = width;
3517    let newHeight = height;
3518    const result = await imagePromise;
3519    let bitmap = result.image || result;
3520    for (const step of steps) {
3521      const prevWidth = newWidth;
3522      const prevHeight = newHeight;
3523      newWidth = Math.floor(newWidth / step);
3524      newHeight = Math.floor(newHeight / step);
3525      const canvas = new OffscreenCanvas(newWidth, newHeight);
3526      const ctx = canvas.getContext("2d");
3527      ctx.drawImage(bitmap, 0, 0, prevWidth, prevHeight, 0, 0, newWidth, newHeight);
3528      bitmap.close();
3529      bitmap = canvas.transferToImageBitmap();
3530    }
3531    imgData.data = null;
3532    imgData.bitmap = bitmap;
3533    imgData.width = newWidth;
3534    imgData.height = newHeight;
3535    return imgData;
3536  }
3537  #rescaleImageData() {
3538    const {
3539      _imgData: imgData
3540    } = this;
3541    const {
3542      data,
3543      width,
3544      height,
3545      kind
3546    } = imgData;
3547    const rgbaSize = width * height * 4;
3548    const K = Math.ceil(Math.log2(rgbaSize / MAX_INT_32));
3549    const newWidth = width >> K;
3550    const newHeight = height >> K;
3551    let rgbaData;
3552    let maxHeight = height;
3553    try {
3554      rgbaData = new Uint8Array(rgbaSize);
3555    } catch {
3556      let n = Math.floor(Math.log2(rgbaSize + 1));
3557      while (true) {
3558        try {
3559          rgbaData = new Uint8Array(2 ** n - 1);
3560          break;
3561        } catch {
3562          n -= 1;
3563        }
3564      }
3565      maxHeight = Math.floor((2 ** n - 1) / (width * 4));
3566      const newSize = width * maxHeight * 4;
3567      if (newSize < rgbaData.length) {
3568        rgbaData = new Uint8Array(newSize);
3569      }
3570    }
3571    const src32 = new Uint32Array(rgbaData.buffer);
3572    const dest32 = new Uint32Array(newWidth * newHeight);
3573    let srcPos = 0;
3574    let newIndex = 0;
3575    const step = Math.ceil(height / maxHeight);
3576    const remainder = height % maxHeight === 0 ? height : height % maxHeight;
3577    for (let k = 0; k < step; k++) {
3578      const h = k < step - 1 ? maxHeight : remainder;
3579      ({
3580        srcPos
3581      } = convertToRGBA({
3582        kind,
3583        src: data,
3584        dest: src32,
3585        width,
3586        height: h,
3587        inverseDecode: this._isMask,
3588        srcPos
3589      }));
3590      for (let i = 0, ii = h >> K; i < ii; i++) {
3591        const buf = src32.subarray((i << K) * width);
3592        for (let j = 0; j < newWidth; j++) {
3593          dest32[newIndex++] = buf[j << K];
3594        }
3595      }
3596    }
3597    if (ImageResizer.needsToBeResized(newWidth, newHeight)) {
3598      imgData.data = dest32;
3599      imgData.width = newWidth;
3600      imgData.height = newHeight;
3601      imgData.kind = ImageKind.RGBA_32BPP;
3602      return null;
3603    }
3604    const canvas = new OffscreenCanvas(newWidth, newHeight);
3605    const ctx = canvas.getContext("2d", {
3606      willReadFrequently: true
3607    });
3608    ctx.putImageData(new ImageData(new Uint8ClampedArray(dest32.buffer), newWidth, newHeight), 0, 0);
3609    imgData.data = null;
3610    imgData.bitmap = canvas.transferToImageBitmap();
3611    imgData.width = newWidth;
3612    imgData.height = newHeight;
3613    return imgData;
3614  }
3615  _encodeBMP() {
3616    const {
3617      width,
3618      height,
3619      kind
3620    } = this._imgData;
3621    let data = this._imgData.data;
3622    let bitPerPixel;
vendor: 14,058 bytes, lines 3623-4114
3623    let colorTable = new Uint8Array(0);
3624    let maskTable = colorTable;
3625    let compression = 0;
3626    switch (kind) {
3627      case ImageKind.GRAYSCALE_1BPP:
3628        {
3629          bitPerPixel = 1;
3630          colorTable = new Uint8Array(this._isMask ? [255, 255, 255, 255, 0, 0, 0, 0] : [0, 0, 0, 0, 255, 255, 255, 255]);
3631          const rowLen = width + 7 >> 3;
3632          const rowSize = rowLen + 3 & -4;
3633          if (rowLen !== rowSize) {
3634            const newData = new Uint8Array(rowSize * height);
3635            let k = 0;
3636            for (let i = 0, ii = height * rowLen; i < ii; i += rowLen, k += rowSize) {
3637              newData.set(data.subarray(i, i + rowLen), k);
3638            }
3639            data = newData;
3640          }
3641          break;
3642        }
3643      case ImageKind.RGB_24BPP:
3644        {
3645          bitPerPixel = 24;
3646          if (width & 3) {
3647            const rowLen = 3 * width;
3648            const rowSize = rowLen + 3 & -4;
3649            const extraLen = rowSize - rowLen;
3650            const newData = new Uint8Array(rowSize * height);
3651            let k = 0;
3652            for (let i = 0, ii = height * rowLen; i < ii; i += rowLen) {
3653              const row = data.subarray(i, i + rowLen);
3654              for (let j = 0; j < rowLen; j += 3) {
3655                newData[k++] = row[j + 2];
3656                newData[k++] = row[j + 1];
3657                newData[k++] = row[j];
3658              }
3659              k += extraLen;
3660            }
3661            data = newData;
3662          } else {
3663            for (let i = 0, ii = data.length; i < ii; i += 3) {
3664              const tmp = data[i];
3665              data[i] = data[i + 2];
3666              data[i + 2] = tmp;
3667            }
3668          }
3669          break;
3670        }
3671      case ImageKind.RGBA_32BPP:
3672        bitPerPixel = 32;
3673        compression = 3;
3674        maskTable = new Uint8Array(4 + 4 + 4 + 4 + 52);
3675        const view = new DataView(maskTable.buffer);
3676        if (FeatureTest.isLittleEndian) {
3677          view.setUint32(0, 0x000000ff, true);
3678          view.setUint32(4, 0x0000ff00, true);
3679          view.setUint32(8, 0x00ff0000, true);
3680          view.setUint32(12, 0xff000000, true);
3681        } else {
3682          view.setUint32(0, 0xff000000, true);
3683          view.setUint32(4, 0x00ff0000, true);
3684          view.setUint32(8, 0x0000ff00, true);
3685          view.setUint32(12, 0x000000ff, true);
3686        }
3687        break;
3688      default:
3689        throw new Error("invalid format");
3690    }
3691    let i = 0;
3692    const headerLength = 40 + maskTable.length;
3693    const fileLength = 14 + headerLength + colorTable.length + data.length;
3694    const bmpData = new Uint8Array(fileLength);
3695    const view = new DataView(bmpData.buffer);
3696    view.setUint16(i, 0x4d42, true);
3697    i += 2;
3698    view.setUint32(i, fileLength, true);
3699    i += 4;
3700    view.setUint32(i, 0, true);
3701    i += 4;
3702    view.setUint32(i, 14 + headerLength + colorTable.length, true);
3703    i += 4;
3704    view.setUint32(i, headerLength, true);
3705    i += 4;
3706    view.setInt32(i, width, true);
3707    i += 4;
3708    view.setInt32(i, -height, true);
3709    i += 4;
3710    view.setUint16(i, 1, true);
3711    i += 2;
3712    view.setUint16(i, bitPerPixel, true);
3713    i += 2;
3714    view.setUint32(i, compression, true);
3715    i += 4;
3716    view.setUint32(i, 0, true);
3717    i += 4;
3718    view.setInt32(i, 0, true);
3719    i += 4;
3720    view.setInt32(i, 0, true);
3721    i += 4;
3722    view.setUint32(i, colorTable.length / 4, true);
3723    i += 4;
3724    view.setUint32(i, 0, true);
3725    i += 4;
3726    bmpData.set(maskTable, i);
3727    i += maskTable.length;
3728    bmpData.set(colorTable, i);
3729    i += colorTable.length;
3730    bmpData.set(data, i);
3731    return bmpData;
3732  }
3733}
3734
3735;// ./src/core/decode_stream.js
3736
3737
3738
3739const emptyBuffer = new Uint8Array(0);
3740class DecodeStream extends BaseStream {
3741  buffer = emptyBuffer;
3742  bufferLength = 0;
3743  eof = false;
3744  minBufferLength = 512;
3745  pos = 0;
3746  constructor(maybeMinBufferLength) {
3747    super();
3748    this._rawMinBufferLength = maybeMinBufferLength || 0;
3749    if (maybeMinBufferLength) {
3750      while (this.minBufferLength < maybeMinBufferLength) {
3751        this.minBufferLength *= 2;
3752      }
3753    }
3754  }
3755  readBlock() {
3756    unreachable("Abstract method `readBlock` called");
3757  }
3758  get isEmpty() {
3759    while (!this.eof && this.bufferLength === 0) {
3760      this.readBlock();
3761    }
3762    return this.bufferLength === 0;
3763  }
3764  ensureBuffer(requested) {
3765    const buffer = this.buffer;
3766    if (requested <= buffer.byteLength) {
3767      return buffer;
3768    }
3769    let size = this.minBufferLength;
3770    while (size < requested) {
3771      size *= 2;
3772    }
3773    const buffer2 = new Uint8Array(size);
3774    buffer2.set(buffer);
3775    return this.buffer = buffer2;
3776  }
3777  getByte() {
3778    const pos = this.pos;
3779    while (this.bufferLength <= pos) {
3780      if (this.eof) {
3781        return -1;
3782      }
3783      this.readBlock();
3784    }
3785    return this.buffer[this.pos++];
3786  }
3787  getBytes(length, decoderOptions = null) {
3788    const pos = this.pos;
3789    let end;
3790    if (length) {
3791      this.ensureBuffer(pos + length);
3792      end = pos + length;
3793      while (!this.eof && this.bufferLength < end) {
3794        this.readBlock(decoderOptions);
3795      }
3796      const bufEnd = this.bufferLength;
3797      if (end > bufEnd) {
3798        end = bufEnd;
3799      }
3800    } else {
3801      while (!this.eof) {
3802        this.readBlock(decoderOptions);
3803      }
3804      end = this.bufferLength;
3805    }
3806    this.pos = end;
3807    return this.buffer.subarray(pos, end);
3808  }
3809  async getImageData(length, decoderOptions) {
3810    if (!this.canAsyncDecodeImageFromBuffer) {
3811      if (this.isAsyncDecoder) {
3812        return this.decodeImage(null, length, decoderOptions);
3813      }
3814      return this.getBytes(length, decoderOptions);
3815    }
3816    const data = await this.stream.asyncGetBytes();
3817    return this.decodeImage(data, length, decoderOptions);
3818  }
3819  async asyncGetBytesFromDecompressionStream(name) {
3820    this.stream.reset();
3821    const bytes = this.stream.isAsync ? await this.stream.asyncGetBytes() : this.stream.getBytes();
3822    try {
3823      const {
3824        readable,
3825        writable
3826      } = new DecompressionStream(name);
3827      const writer = writable.getWriter();
3828      await writer.ready;
3829      writer.write(bytes).then(async () => {
3830        await writer.ready;
3831        await writer.close();
3832      }).catch(() => {});
3833      const chunks = [];
3834      let totalLength = 0;
3835      for await (const chunk of readable) {
3836        chunks.push(chunk);
3837        totalLength += chunk.byteLength;
3838      }
3839      const data = new Uint8Array(totalLength);
3840      let offset = 0;
3841      for (const chunk of chunks) {
3842        data.set(chunk, offset);
3843        offset += chunk.byteLength;
3844      }
3845      return {
3846        decompressed: data,
3847        compressed: bytes
3848      };
3849    } catch {
3850      return {
3851        decompressed: null,
3852        compressed: bytes
3853      };
3854    }
3855  }
3856  reset() {
3857    this.pos = 0;
3858  }
3859  makeSubStream(start, length, dict = null) {
3860    if (length === undefined) {
3861      while (!this.eof) {
3862        this.readBlock();
3863      }
3864    } else {
3865      const end = start + length;
3866      while (this.bufferLength <= end && !this.eof) {
3867        this.readBlock();
3868      }
3869    }
3870    return new Stream(this.buffer, start, length, dict);
3871  }
3872  clone() {
3873    while (!this.eof) {
3874      this.readBlock();
3875    }
3876    return new Stream(this.buffer, 0, this.bufferLength, this.dict?.clone());
3877  }
3878  getBaseStreams() {
3879    return this.stream ? this.stream.getBaseStreams() : null;
3880  }
3881}
3882class StreamsSequenceStream extends DecodeStream {
3883  constructor(streams, onError = null) {
3884    streams = streams.filter(s => s instanceof BaseStream && !s.isImageStream);
3885    let maybeLength = 0;
3886    for (const stream of streams) {
3887      maybeLength += stream instanceof DecodeStream ? stream._rawMinBufferLength : stream.length;
3888    }
3889    super(maybeLength);
3890    this.streams = streams;
3891    this._onError = onError;
3892  }
3893  readBlock() {
3894    const streams = this.streams;
3895    if (streams.length === 0) {
3896      this.eof = true;
3897      return;
3898    }
3899    const stream = streams.shift();
3900    let chunk;
3901    try {
3902      chunk = stream.getBytes();
3903    } catch (reason) {
3904      if (this._onError) {
3905        this._onError(reason, stream.dict?.objId);
3906        return;
3907      }
3908      throw reason;
3909    }
3910    const bufferLength = this.bufferLength;
3911    const newLength = bufferLength + chunk.length;
3912    const buffer = this.ensureBuffer(newLength);
3913    buffer.set(chunk, bufferLength);
3914    this.bufferLength = newLength;
3915  }
3916  getBaseStreams() {
3917    const baseStreamsBuf = [];
3918    for (const stream of this.streams) {
3919      const baseStreams = stream.getBaseStreams();
3920      if (baseStreams) {
3921        baseStreamsBuf.push(...baseStreams);
3922      }
3923    }
3924    return baseStreamsBuf.length > 0 ? baseStreamsBuf : null;
3925  }
3926}
3927
3928;// ./src/core/colorspace_utils.js
3929
3930
3931
3932
3933
3934
3935class ColorSpaceUtils {
3936  static parse({
3937    cs,
3938    xref,
3939    resources = null,
3940    pdfFunctionFactory,
3941    globalColorSpaceCache,
3942    localColorSpaceCache,
3943    asyncIfNotCached = false
3944  }) {
3945    const options = {
3946      xref,
3947      resources,
3948      pdfFunctionFactory,
3949      globalColorSpaceCache,
3950      localColorSpaceCache
3951    };
3952    let csName, csRef, parsedCS;
3953    if (cs instanceof Ref) {
3954      csRef = cs;
3955      const cachedCS = globalColorSpaceCache.getByRef(csRef) || localColorSpaceCache.getByRef(csRef);
3956      if (cachedCS) {
3957        return cachedCS;
3958      }
3959      cs = xref.fetch(cs);
3960    }
3961    if (cs instanceof Name) {
3962      csName = cs.name;
3963      const cachedCS = localColorSpaceCache.getByName(csName);
3964      if (cachedCS) {
3965        return cachedCS;
3966      }
3967    }
3968    try {
3969      parsedCS = this.#parse(cs, options);
3970    } catch (ex) {
3971      if (asyncIfNotCached && !(ex instanceof MissingDataException)) {
3972        return Promise.reject(ex);
3973      }
3974      throw ex;
3975    }
3976    if (csName || csRef) {
3977      localColorSpaceCache.set(csName, csRef, parsedCS);
3978      if (csRef) {
3979        globalColorSpaceCache.set(null, csRef, parsedCS);
3980      }
3981    }
3982    return asyncIfNotCached ? Promise.resolve(parsedCS) : parsedCS;
3983  }
3984  static #subParse(cs, options) {
3985    const {
3986      globalColorSpaceCache
3987    } = options;
3988    let csRef;
3989    if (cs instanceof Ref) {
3990      csRef = cs;
3991      const cachedCS = globalColorSpaceCache.getByRef(csRef);
3992      if (cachedCS) {
3993        return cachedCS;
3994      }
3995    }
3996    const parsedCS = this.#parse(cs, options);
3997    if (csRef) {
3998      globalColorSpaceCache.set(null, csRef, parsedCS);
3999    }
4000    return parsedCS;
4001  }
4002  static #parse(cs, options) {
4003    const {
4004      xref,
4005      resources,
4006      pdfFunctionFactory,
4007      globalColorSpaceCache
4008    } = options;
4009    cs = xref.fetchIfRef(cs);
4010    if (cs instanceof Name) {
4011      switch (cs.name) {
4012        case "G":
4013        case "DeviceGray":
4014          return this.gray;
4015        case "RGB":
4016        case "DeviceRGB":
4017          return this.rgb;
4018        case "DeviceRGBA":
4019          return this.rgba;
4020        case "CMYK":
4021        case "DeviceCMYK":
4022          return this.cmyk;
4023        case "Pattern":
4024          return new PatternCS(null);
4025        default:
4026          if (resources instanceof Dict) {
4027            const colorSpaces = resources.get("ColorSpace");
4028            if (colorSpaces instanceof Dict) {
4029              const resourcesCS = colorSpaces.get(cs.name);
4030              if (resourcesCS) {
4031                if (resourcesCS instanceof Name) {
4032                  return this.#parse(resourcesCS, options);
4033                }
4034                cs = resourcesCS;
4035                break;
4036              }
4037            }
4038          }
4039          warn(`Unrecognized ColorSpace: ${cs.name}`);
4040          return this.gray;
4041      }
4042    }
4043    if (Array.isArray(cs)) {
4044      const mode = xref.fetchIfRef(cs[0]).name;
4045      let params, numComps, baseCS, whitePoint, blackPoint, gamma;
4046      switch (mode) {
4047        case "G":
4048        case "DeviceGray":
4049          return this.gray;
4050        case "RGB":
4051        case "DeviceRGB":
4052          return this.rgb;
4053        case "CMYK":
4054        case "DeviceCMYK":
4055          return this.cmyk;
4056        case "CalGray":
4057          params = xref.fetchIfRef(cs[1]);
4058          whitePoint = params.getArray("WhitePoint");
4059          blackPoint = params.getArray("BlackPoint");
4060          gamma = params.get("Gamma");
4061          return new CalGrayCS(whitePoint, blackPoint, gamma);
4062        case "CalRGB":
4063          params = xref.fetchIfRef(cs[1]);
4064          whitePoint = params.getArray("WhitePoint");
4065          blackPoint = params.getArray("BlackPoint");
4066          gamma = params.getArray("Gamma");
4067          const matrix = params.getArray("Matrix");
4068          return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
4069        case "ICCBased":
4070          const isRef = cs[1] instanceof Ref;
4071          if (isRef) {
4072            const cachedCS = globalColorSpaceCache.getByRef(cs[1]);
4073            if (cachedCS) {
4074              return cachedCS;
4075            }
4076          }
4077          const stream = xref.fetchIfRef(cs[1]);
4078          const dict = stream.dict;
4079          numComps = dict.get("N");
4080          if (IccColorSpace.isUsable) {
4081            try {
4082              const iccCS = new IccColorSpace(stream.getBytes(), "ICCBased", numComps);
4083              if (isRef) {
4084                globalColorSpaceCache.set(null, cs[1], iccCS);
4085              }
4086              return iccCS;
4087            } catch (ex) {
4088              if (ex instanceof MissingDataException) {
4089                throw ex;
4090              }
4091              warn(`ICCBased color space (${cs[1]}): "${ex}".`);
4092            }
4093          }
4094          const altRaw = dict.getRaw("Alternate");
4095          if (altRaw) {
4096            const altCS = this.#subParse(altRaw, options);
4097            if (altCS.numComps === numComps) {
4098              return altCS;
4099            }
4100            warn("ICCBased color space: Ignoring incorrect /Alternate entry.");
4101          }
4102          if (numComps === 1) {
4103            return this.gray;
4104          } else if (numComps === 3) {
4105            return this.rgb;
4106          } else if (numComps === 4) {
4107            return this.cmyk;
4108          }
4109          break;
4110        case "Pattern":
4111          baseCS = cs[1] || null;
4112          if (baseCS) {
4113            baseCS = this.#subParse(baseCS, options);
4114          }
vendor: 13,407 bytes, lines 4114-4564
4114
4115          return new PatternCS(baseCS);
4116        case "I":
4117        case "Indexed":
4118          baseCS = this.#subParse(cs[1], options);
4119          const hiVal = MathClamp(xref.fetchIfRef(cs[2]), 0, 255);
4120          const lookup = xref.fetchIfRef(cs[3]);
4121          return new IndexedCS(baseCS, hiVal, lookup);
4122        case "Separation":
4123        case "DeviceN":
4124          const name = xref.fetchIfRef(cs[1]);
4125          numComps = Array.isArray(name) ? name.length : 1;
4126          baseCS = this.#subParse(cs[2], options);
4127          const tintFn = pdfFunctionFactory.create(cs[3]);
4128          return new AlternateCS(numComps, baseCS, tintFn);
4129        case "Lab":
4130          params = xref.fetchIfRef(cs[1]);
4131          whitePoint = params.getArray("WhitePoint");
4132          blackPoint = params.getArray("BlackPoint");
4133          const range = params.getArray("Range");
4134          return new LabCS(whitePoint, blackPoint, range);
4135        default:
4136          warn(`Unimplemented ColorSpace object: ${mode}`);
4137          return this.gray;
4138      }
4139    }
4140    warn(`Unrecognized ColorSpace object: ${cs}`);
4141    return this.gray;
4142  }
4143  static get gray() {
4144    return shadow(this, "gray", new DeviceGrayCS());
4145  }
4146  static get rgb() {
4147    return shadow(this, "rgb", new DeviceRgbCS());
4148  }
4149  static get rgba() {
4150    return shadow(this, "rgba", new DeviceRgbaCS());
4151  }
4152  static get cmyk() {
4153    if (CmykICCBasedCS.isUsable) {
4154      try {
4155        return shadow(this, "cmyk", new CmykICCBasedCS());
4156      } catch {
4157        warn("CMYK fallback: DeviceCMYK");
4158      }
4159    }
4160    return shadow(this, "cmyk", new DeviceCmykCS());
4161  }
4162}
4163
4164;// ./src/core/jpg.js
4165
4166
4167
4168
4169class JpegError extends BaseException {
4170  constructor(msg) {
4171    super(msg, "JpegError");
4172  }
4173}
4174class DNLMarkerError extends BaseException {
4175  constructor(message, scanLines) {
4176    super(message, "DNLMarkerError");
4177    this.scanLines = scanLines;
4178  }
4179}
4180class EOIMarkerError extends BaseException {
4181  constructor(msg) {
4182    super(msg, "EOIMarkerError");
4183  }
4184}
4185const dctZigZag = new Uint8Array([0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63]);
4186const dctCos1 = 4017;
4187const dctSin1 = 799;
4188const dctCos3 = 3406;
4189const dctSin3 = 2276;
4190const dctCos6 = 1567;
4191const dctSin6 = 3784;
4192const dctSqrt2 = 5793;
4193const dctSqrt1d2 = 2896;
4194function buildHuffmanTable(codeLengths, values) {
4195  let k = 0,
4196    i,
4197    j,
4198    length = 16;
4199  while (length > 0 && !codeLengths[length - 1]) {
4200    length--;
4201  }
4202  const code = [{
4203    children: [],
4204    index: 0
4205  }];
4206  let p = code[0],
4207    q;
4208  for (i = 0; i < length; i++) {
4209    for (j = 0; j < codeLengths[i]; j++) {
4210      p = code.pop();
4211      p.children[p.index] = values[k];
4212      while (p.index > 0) {
4213        p = code.pop();
4214      }
4215      p.index++;
4216      code.push(p);
4217      while (code.length <= i) {
4218        code.push(q = {
4219          children: [],
4220          index: 0
4221        });
4222        p.children[p.index] = q.children;
4223        p = q;
4224      }
4225      k++;
4226    }
4227    if (i + 1 < length) {
4228      code.push(q = {
4229        children: [],
4230        index: 0
4231      });
4232      p.children[p.index] = q.children;
4233      p = q;
4234    }
4235  }
4236  return code[0].children;
4237}
4238function getBlockBufferOffset(component, row, col) {
4239  return 64 * ((component.blocksPerLine + 1) * row + col);
4240}
4241function decodeScan(data, view, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive, parseDNLMarker = false) {
4242  const mcusPerLine = frame.mcusPerLine;
4243  const progressive = frame.progressive;
4244  const startOffset = offset;
4245  let bitsData = 0,
4246    bitsCount = 0;
4247  function readBit() {
4248    if (bitsCount > 0) {
4249      bitsCount--;
4250      return bitsData >> bitsCount & 1;
4251    }
4252    bitsData = data[offset++];
4253    if (bitsData === 0xff) {
4254      const nextByte = data[offset++];
4255      if (nextByte) {
4256        if (nextByte === 0xdc && parseDNLMarker) {
4257          offset += 2;
4258          const scanLines = view.getUint16(offset);
4259          offset += 2;
4260          if (scanLines > 0 && scanLines !== frame.scanLines) {
4261            throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data", scanLines);
4262          }
4263        } else if (nextByte === 0xd9) {
4264          if (parseDNLMarker) {
4265            const maybeScanLines = blockRow * (frame.precision === 8 ? 8 : 0);
4266            if (maybeScanLines > 0 && Math.round(frame.scanLines / maybeScanLines) >= 5) {
4267              throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, " + "possibly caused by incorrect `scanLines` parameter", maybeScanLines);
4268            }
4269          }
4270          throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data");
4271        }
4272        throw new JpegError(`unexpected marker ${(bitsData << 8 | nextByte).toString(16)}`);
4273      }
4274    }
4275    bitsCount = 7;
4276    return bitsData >>> 7;
4277  }
4278  function decodeHuffman(tree) {
4279    let node = tree;
4280    while (true) {
4281      node = node[readBit()];
4282      switch (typeof node) {
4283        case "number":
4284          return node;
4285        case "object":
4286          continue;
4287      }
4288      throw new JpegError("invalid huffman sequence");
4289    }
4290  }
4291  function receive(length) {
4292    let n = 0;
4293    while (length > 0) {
4294      n = n << 1 | readBit();
4295      length--;
4296    }
4297    return n;
4298  }
4299  function receiveAndExtend(length) {
4300    if (length === 1) {
4301      return readBit() === 1 ? 1 : -1;
4302    }
4303    const n = receive(length);
4304    if (n >= 1 << length - 1) {
4305      return n;
4306    }
4307    return n + (-1 << length) + 1;
4308  }
4309  function decodeBaseline(component, blockOffset) {
4310    const t = decodeHuffman(component.huffmanTableDC);
4311    const diff = t === 0 ? 0 : receiveAndExtend(t);
4312    component.blockData[blockOffset] = component.pred += diff;
4313    let k = 1;
4314    while (k < 64) {
4315      const rs = decodeHuffman(component.huffmanTableAC);
4316      const s = rs & 15,
4317        r = rs >> 4;
4318      if (s === 0) {
4319        if (r < 15) {
4320          break;
4321        }
4322        k += 16;
4323        continue;
4324      }
4325      k += r;
4326      const z = dctZigZag[k];
4327      component.blockData[blockOffset + z] = receiveAndExtend(s);
4328      k++;
4329    }
4330  }
4331  function decodeDCFirst(component, blockOffset) {
4332    const t = decodeHuffman(component.huffmanTableDC);
4333    const diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
4334    component.blockData[blockOffset] = component.pred += diff;
4335  }
4336  function decodeDCSuccessive(component, blockOffset) {
4337    component.blockData[blockOffset] |= readBit() << successive;
4338  }
4339  let eobrun = 0;
4340  function decodeACFirst(component, blockOffset) {
4341    if (eobrun > 0) {
4342      eobrun--;
4343      return;
4344    }
4345    let k = spectralStart;
4346    const e = spectralEnd;
4347    while (k <= e) {
4348      const rs = decodeHuffman(component.huffmanTableAC);
4349      const s = rs & 15,
4350        r = rs >> 4;
4351      if (s === 0) {
4352        if (r < 15) {
4353          eobrun = receive(r) + (1 << r) - 1;
4354          break;
4355        }
4356        k += 16;
4357        continue;
4358      }
4359      k += r;
4360      const z = dctZigZag[k];
4361      component.blockData[blockOffset + z] = receiveAndExtend(s) * (1 << successive);
4362      k++;
4363    }
4364  }
4365  let successiveACState = 0,
4366    successiveACNextValue;
4367  function decodeACSuccessive(component, blockOffset) {
4368    let k = spectralStart;
4369    const e = spectralEnd;
4370    let r = 0;
4371    let s;
4372    let rs;
4373    while (k <= e) {
4374      const offsetZ = blockOffset + dctZigZag[k];
4375      const sign = component.blockData[offsetZ] < 0 ? -1 : 1;
4376      switch (successiveACState) {
4377        case 0:
4378          rs = decodeHuffman(component.huffmanTableAC);
4379          s = rs & 15;
4380          r = rs >> 4;
4381          if (s === 0) {
4382            if (r < 15) {
4383              eobrun = receive(r) + (1 << r);
4384              successiveACState = 4;
4385            } else {
4386              r = 16;
4387              successiveACState = 1;
4388            }
4389          } else {
4390            if (s !== 1) {
4391              throw new JpegError("invalid ACn encoding");
4392            }
4393            successiveACNextValue = receiveAndExtend(s);
4394            successiveACState = r ? 2 : 3;
4395          }
4396          continue;
4397        case 1:
4398        case 2:
4399          if (component.blockData[offsetZ]) {
4400            component.blockData[offsetZ] += sign * (readBit() << successive);
4401          } else {
4402            r--;
4403            if (r === 0) {
4404              successiveACState = successiveACState === 2 ? 3 : 0;
4405            }
4406          }
4407          break;
4408        case 3:
4409          if (component.blockData[offsetZ]) {
4410            component.blockData[offsetZ] += sign * (readBit() << successive);
4411          } else {
4412            component.blockData[offsetZ] = successiveACNextValue << successive;
4413            successiveACState = 0;
4414          }
4415          break;
4416        case 4:
4417          if (component.blockData[offsetZ]) {
4418            component.blockData[offsetZ] += sign * (readBit() << successive);
4419          }
4420          break;
4421      }
4422      k++;
4423    }
4424    if (successiveACState === 4) {
4425      eobrun--;
4426      if (eobrun === 0) {
4427        successiveACState = 0;
4428      }
4429    }
4430  }
4431  let blockRow = 0;
4432  function decodeMcu(component, decode, mcu, row, col) {
4433    const mcuRow = mcu / mcusPerLine | 0;
4434    const mcuCol = mcu % mcusPerLine;
4435    blockRow = mcuRow * component.v + row;
4436    const blockCol = mcuCol * component.h + col;
4437    const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
4438    decode(component, blockOffset);
4439  }
4440  function decodeBlock(component, decode, mcu) {
4441    blockRow = mcu / component.blocksPerLine | 0;
4442    const blockCol = mcu % component.blocksPerLine;
4443    const blockOffset = getBlockBufferOffset(component, blockRow, blockCol);
4444    decode(component, blockOffset);
4445  }
4446  const componentsLength = components.length;
4447  let component, i, j, k, n;
4448  let decodeFn;
4449  if (progressive) {
4450    if (spectralStart === 0) {
4451      decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
4452    } else {
4453      decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
4454    }
4455  } else {
4456    decodeFn = decodeBaseline;
4457  }
4458  let mcu = 0,
4459    fileMarker;
4460  const mcuExpected = componentsLength === 1 ? components[0].blocksPerLine * components[0].blocksPerColumn : mcusPerLine * frame.mcusPerColumn;
4461  let h, v;
4462  while (mcu <= mcuExpected) {
4463    const mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
4464    if (mcuToRead > 0) {
4465      for (i = 0; i < componentsLength; i++) {
4466        components[i].pred = 0;
4467      }
4468      eobrun = 0;
4469      if (componentsLength === 1) {
4470        component = components[0];
4471        for (n = 0; n < mcuToRead; n++) {
4472          decodeBlock(component, decodeFn, mcu);
4473          mcu++;
4474        }
4475      } else {
4476        for (n = 0; n < mcuToRead; n++) {
4477          for (i = 0; i < componentsLength; i++) {
4478            component = components[i];
4479            h = component.h;
4480            v = component.v;
4481            for (j = 0; j < v; j++) {
4482              for (k = 0; k < h; k++) {
4483                decodeMcu(component, decodeFn, mcu, j, k);
4484              }
4485            }
4486          }
4487          mcu++;
4488        }
4489      }
4490    }
4491    bitsCount = 0;
4492    fileMarker = findNextFileMarker(data, view, offset);
4493    if (!fileMarker) {
4494      break;
4495    }
4496    if (fileMarker.invalid) {
4497      const partialMsg = mcuToRead > 0 ? "unexpected" : "excessive";
4498      warn(`decodeScan - ${partialMsg} MCU data, current marker is: ${fileMarker.invalid}`);
4499      offset = fileMarker.offset;
4500    }
4501    if (fileMarker.marker >= 0xffd0 && fileMarker.marker <= 0xffd7) {
4502      offset += 2;
4503    } else {
4504      break;
4505    }
4506  }
4507  return offset - startOffset;
4508}
4509function quantizeAndInverse(component, blockBufferOffset, p) {
4510  const qt = component.quantizationTable,
4511    blockData = component.blockData;
4512  let v0, v1, v2, v3, v4, v5, v6, v7;
4513  let p0, p1, p2, p3, p4, p5, p6, p7;
4514  let t;
4515  if (!qt) {
4516    throw new JpegError("missing required Quantization Table.");
4517  }
4518  for (let row = 0; row < 64; row += 8) {
4519    p0 = blockData[blockBufferOffset + row];
4520    p1 = blockData[blockBufferOffset + row + 1];
4521    p2 = blockData[blockBufferOffset + row + 2];
4522    p3 = blockData[blockBufferOffset + row + 3];
4523    p4 = blockData[blockBufferOffset + row + 4];
4524    p5 = blockData[blockBufferOffset + row + 5];
4525    p6 = blockData[blockBufferOffset + row + 6];
4526    p7 = blockData[blockBufferOffset + row + 7];
4527    p0 *= qt[row];
4528    if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
4529      t = dctSqrt2 * p0 + 512 >> 10;
4530      p[row] = t;
4531      p[row + 1] = t;
4532      p[row + 2] = t;
4533      p[row + 3] = t;
4534      p[row + 4] = t;
4535      p[row + 5] = t;
4536      p[row + 6] = t;
4537      p[row + 7] = t;
4538      continue;
4539    }
4540    p1 *= qt[row + 1];
4541    p2 *= qt[row + 2];
4542    p3 *= qt[row + 3];
4543    p4 *= qt[row + 4];
4544    p5 *= qt[row + 5];
4545    p6 *= qt[row + 6];
4546    p7 *= qt[row + 7];
4547    v0 = dctSqrt2 * p0 + 128 >> 8;
4548    v1 = dctSqrt2 * p4 + 128 >> 8;
4549    v2 = p2;
4550    v3 = p6;
4551    v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
4552    v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
4553    v5 = p3 << 4;
4554    v6 = p5 << 4;
4555    v0 = v0 + v1 + 1 >> 1;
4556    v1 = v0 - v1;
4557    t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
4558    v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
4559    v3 = t;
4560    v4 = v4 + v6 + 1 >> 1;
4561    v6 = v4 - v6;
4562    v7 = v7 + v5 + 1 >> 1;
4563    v5 = v7 - v5;
4564    v0 = v0 + v3 + 1 >> 1;
vendor: 1,964 bytes, lines 4565-4632
4565    v3 = v0 - v3;
4566    v1 = v1 + v2 + 1 >> 1;
4567    v2 = v1 - v2;
4568    t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
4569    v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
4570    v7 = t;
4571    t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
4572    v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
4573    v6 = t;
4574    p[row] = v0 + v7;
4575    p[row + 7] = v0 - v7;
4576    p[row + 1] = v1 + v6;
4577    p[row + 6] = v1 - v6;
4578    p[row + 2] = v2 + v5;
4579    p[row + 5] = v2 - v5;
4580    p[row + 3] = v3 + v4;
4581    p[row + 4] = v3 - v4;
4582  }
4583  for (let col = 0; col < 8; ++col) {
4584    p0 = p[col];
4585    p1 = p[col + 8];
4586    p2 = p[col + 16];
4587    p3 = p[col + 24];
4588    p4 = p[col + 32];
4589    p5 = p[col + 40];
4590    p6 = p[col + 48];
4591    p7 = p[col + 56];
4592    if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
4593      t = dctSqrt2 * p0 + 8192 >> 14;
4594      if (t < -2040) {
4595        t = 0;
4596      } else if (t >= 2024) {
4597        t = 255;
4598      } else {
4599        t = t + 2056 >> 4;
4600      }
4601      blockData[blockBufferOffset + col] = t;
4602      blockData[blockBufferOffset + col + 8] = t;
4603      blockData[blockBufferOffset + col + 16] = t;
4604      blockData[blockBufferOffset + col + 24] = t;
4605      blockData[blockBufferOffset + col + 32] = t;
4606      blockData[blockBufferOffset + col + 40] = t;
4607      blockData[blockBufferOffset + col + 48] = t;
4608      blockData[blockBufferOffset + col + 56] = t;
4609      continue;
4610    }
4611    v0 = dctSqrt2 * p0 + 2048 >> 12;
4612    v1 = dctSqrt2 * p4 + 2048 >> 12;
4613    v2 = p2;
4614    v3 = p6;
4615    v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
4616    v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
4617    v5 = p3;
4618    v6 = p5;
4619    v0 = (v0 + v1 + 1 >> 1) + 4112;
4620    v1 = v0 - v1;
4621    t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
4622    v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
4623    v3 = t;
4624    v4 = v4 + v6 + 1 >> 1;
4625    v6 = v4 - v6;
4626    v7 = v7 + v5 + 1 >> 1;
4627    v5 = v7 - v5;
4628    v0 = v0 + v3 + 1 >> 1;
4629    v3 = v0 - v3;
4630    v1 = v1 + v2 + 1 >> 1;
4631    v2 = v1 - v2;
4632    t = v4 * dctSin3 + v7 * dctCos3 + 2048 >>
vendor: 4,581 bytes, lines 4632-4794
4632 12;
4633    v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
4634    v7 = t;
4635    t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
4636    v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
4637    v6 = t;
4638    p0 = v0 + v7;
4639    p7 = v0 - v7;
4640    p1 = v1 + v6;
4641    p6 = v1 - v6;
4642    p2 = v2 + v5;
4643    p5 = v2 - v5;
4644    p3 = v3 + v4;
4645    p4 = v3 - v4;
4646    if (p0 < 16) {
4647      p0 = 0;
4648    } else if (p0 >= 4080) {
4649      p0 = 255;
4650    } else {
4651      p0 >>= 4;
4652    }
4653    if (p1 < 16) {
4654      p1 = 0;
4655    } else if (p1 >= 4080) {
4656      p1 = 255;
4657    } else {
4658      p1 >>= 4;
4659    }
4660    if (p2 < 16) {
4661      p2 = 0;
4662    } else if (p2 >= 4080) {
4663      p2 = 255;
4664    } else {
4665      p2 >>= 4;
4666    }
4667    if (p3 < 16) {
4668      p3 = 0;
4669    } else if (p3 >= 4080) {
4670      p3 = 255;
4671    } else {
4672      p3 >>= 4;
4673    }
4674    if (p4 < 16) {
4675      p4 = 0;
4676    } else if (p4 >= 4080) {
4677      p4 = 255;
4678    } else {
4679      p4 >>= 4;
4680    }
4681    if (p5 < 16) {
4682      p5 = 0;
4683    } else if (p5 >= 4080) {
4684      p5 = 255;
4685    } else {
4686      p5 >>= 4;
4687    }
4688    if (p6 < 16) {
4689      p6 = 0;
4690    } else if (p6 >= 4080) {
4691      p6 = 255;
4692    } else {
4693      p6 >>= 4;
4694    }
4695    if (p7 < 16) {
4696      p7 = 0;
4697    } else if (p7 >= 4080) {
4698      p7 = 255;
4699    } else {
4700      p7 >>= 4;
4701    }
4702    blockData[blockBufferOffset + col] = p0;
4703    blockData[blockBufferOffset + col + 8] = p1;
4704    blockData[blockBufferOffset + col + 16] = p2;
4705    blockData[blockBufferOffset + col + 24] = p3;
4706    blockData[blockBufferOffset + col + 32] = p4;
4707    blockData[blockBufferOffset + col + 40] = p5;
4708    blockData[blockBufferOffset + col + 48] = p6;
4709    blockData[blockBufferOffset + col + 56] = p7;
4710  }
4711}
4712function buildComponentData(frame, component) {
4713  const blocksPerLine = component.blocksPerLine;
4714  const blocksPerColumn = component.blocksPerColumn;
4715  const computationBuffer = new Int16Array(64);
4716  for (let blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
4717    for (let blockCol = 0; blockCol < blocksPerLine; blockCol++) {
4718      const offset = getBlockBufferOffset(component, blockRow, blockCol);
4719      quantizeAndInverse(component, offset, computationBuffer);
4720    }
4721  }
4722  return component.blockData;
4723}
4724function findNextFileMarker(data, view, currentPos, startPos = currentPos) {
4725  const maxPos = data.length - 1;
4726  let newPos = startPos < currentPos ? startPos : currentPos;
4727  if (currentPos >= maxPos) {
4728    return null;
4729  }
4730  const currentMarker = view.getUint16(currentPos);
4731  if (currentMarker >= 0xffc0 && currentMarker <= 0xfffe) {
4732    return {
4733      invalid: null,
4734      marker: currentMarker,
4735      offset: currentPos
4736    };
4737  }
4738  let newMarker = view.getUint16(newPos);
4739  while (!(newMarker >= 0xffc0 && newMarker <= 0xfffe)) {
4740    if (++newPos >= maxPos) {
4741      return null;
4742    }
4743    newMarker = view.getUint16(newPos);
4744  }
4745  return {
4746    invalid: currentMarker.toString(16),
4747    marker: newMarker,
4748    offset: newPos
4749  };
4750}
4751function prepareComponents(frame) {
4752  const mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
4753  const mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
4754  for (const component of frame.components) {
4755    const blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
4756    const blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
4757    const blocksPerLineForMcu = mcusPerLine * component.h;
4758    const blocksPerColumnForMcu = mcusPerColumn * component.v;
4759    const blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
4760    component.blockData = new Int16Array(blocksBufferSize);
4761    component.blocksPerLine = blocksPerLine;
4762    component.blocksPerColumn = blocksPerColumn;
4763  }
4764  frame.mcusPerLine = mcusPerLine;
4765  frame.mcusPerColumn = mcusPerColumn;
4766}
4767function readDataBlock(data, view, offset) {
4768  const length = view.getUint16(offset);
4769  offset += 2;
4770  let endOffset = offset + length - 2;
4771  const fileMarker = findNextFileMarker(data, view, endOffset, offset);
4772  if (fileMarker?.invalid) {
4773    warn("readDataBlock - incorrect length, current marker is: " + fileMarker.invalid);
4774    endOffset = fileMarker.offset;
4775  }
4776  const array = data.subarray(offset, endOffset);
4777  return {
4778    appData: array,
4779    oldOffset: offset,
4780    newOffset: offset + array.length
4781  };
4782}
4783function skipData(data, view, offset) {
4784  const length = view.getUint16(offset);
4785  offset += 2;
4786  const endOffset = offset + length - 2;
4787  const fileMarker = findNextFileMarker(data, view, endOffset, offset);
4788  if (fileMarker?.invalid) {
4789    return fileMarker.offset;
4790  }
4791  return endOffset;
4792}
4793class JpegImage {
4794  constructor(
4794{
4795    decodeTransform = null,
4796    colorTransform = -1
4797  } = {}) {
4798    this._decodeTransform = decodeTransform;
4799    this._colorTransform = colorTransform;
4800  }
4801  static canUseImageDecoder(data, colorTransform = -1) {
4802    const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
4803    let exifOffsets = null;
4804    let offset = 0;
4805    let numComponents = null;
4806    let fileMarker = view.getUint16(offset);
4807    offset += 2;
4808    if (fileMarker !== 0xffd8) {
4809      throw new JpegError("SOI not found");
4810    }
4811    fileMarker = view.getUint16(offset);
4812    offset += 2;
4813    markerLoop: while (fileMarker !== 0xffd9) {
4814      switch (fileMarker) {
4815        case 0xffe1:
4816          const {
4817            appData,
4818            oldOffset,
4819            newOffset
4820          } = readDataBlock(data, view, offset);
4821          offset = newOffset;
4822          if (appData[0] === 0x45 && appData[1] === 0x78 && appData[2] === 0x69 && appData[3] === 0x66 && appData[4] === 0 && appData[5] === 0) {
4823            if (exifOffsets) {
vendor: 15,849 bytes, lines 4824-5296
4824              throw new JpegError("Duplicate EXIF-blocks found.");
4825            }
4826            exifOffsets = {
4827              exifStart: oldOffset + 6,
4828              exifEnd: newOffset
4829            };
4830          }
4831          fileMarker = view.getUint16(offset);
4832          offset += 2;
4833          continue;
4834        case 0xffc0:
4835        case 0xffc1:
4836        case 0xffc2:
4837          numComponents = data[offset + (2 + 1 + 2 + 2)];
4838          break markerLoop;
4839        case 0xffff:
4840          if (data[offset] !== 0xff) {
4841            offset--;
4842          }
4843          break;
4844      }
4845      offset = skipData(data, view, offset);
4846      fileMarker = view.getUint16(offset);
4847      offset += 2;
4848    }
4849    if (numComponents === 4) {
4850      return null;
4851    }
4852    if (numComponents === 3 && colorTransform === 0) {
4853      return null;
4854    }
4855    return exifOffsets || {};
4856  }
4857  parse(data, {
4858    dnlScanLines = null
4859  } = {}) {
4860    const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
4861    const maxOffset = data.length - 1;
4862    let offset = 0;
4863    let jfif = null;
4864    let adobe = null;
4865    let frame, resetInterval;
4866    let numSOSMarkers = 0;
4867    const quantizationTables = [];
4868    const huffmanTablesAC = [],
4869      huffmanTablesDC = [];
4870    let fileMarker = view.getUint16(offset);
4871    offset += 2;
4872    if (fileMarker !== 0xffd8) {
4873      throw new JpegError("SOI not found");
4874    }
4875    fileMarker = view.getUint16(offset);
4876    offset += 2;
4877    markerLoop: while (fileMarker !== 0xffd9) {
4878      let i, j, l;
4879      switch (fileMarker) {
4880        case 0xffe0:
4881        case 0xffe1:
4882        case 0xffe2:
4883        case 0xffe3:
4884        case 0xffe4:
4885        case 0xffe5:
4886        case 0xffe6:
4887        case 0xffe7:
4888        case 0xffe8:
4889        case 0xffe9:
4890        case 0xffea:
4891        case 0xffeb:
4892        case 0xffec:
4893        case 0xffed:
4894        case 0xffee:
4895        case 0xffef:
4896        case 0xfffe:
4897          const {
4898            appData,
4899            newOffset
4900          } = readDataBlock(data, view, offset);
4901          offset = newOffset;
4902          if (fileMarker === 0xffe0) {
4903            if (appData[0] === 0x4a && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
4904              jfif = {
4905                version: {
4906                  major: appData[5],
4907                  minor: appData[6]
4908                },
4909                densityUnits: appData[7],
4910                xDensity: appData[8] << 8 | appData[9],
4911                yDensity: appData[10] << 8 | appData[11],
4912                thumbWidth: appData[12],
4913                thumbHeight: appData[13],
4914                thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
4915              };
4916            }
4917          }
4918          if (fileMarker === 0xffee) {
4919            if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6f && appData[3] === 0x62 && appData[4] === 0x65) {
4920              adobe = {
4921                version: appData[5] << 8 | appData[6],
4922                flags0: appData[7] << 8 | appData[8],
4923                flags1: appData[9] << 8 | appData[10],
4924                transformCode: appData[11]
4925              };
4926            }
4927          }
4928          break;
4929        case 0xffdb:
4930          const quantizationTablesLength = view.getUint16(offset);
4931          offset += 2;
4932          const quantizationTablesEnd = quantizationTablesLength + offset - 2;
4933          let z;
4934          while (offset < quantizationTablesEnd) {
4935            const quantizationTableSpec = data[offset++];
4936            const tableData = new Uint16Array(64);
4937            if (quantizationTableSpec >> 4 === 0) {
4938              for (j = 0; j < 64; j++) {
4939                z = dctZigZag[j];
4940                tableData[z] = data[offset++];
4941              }
4942            } else if (quantizationTableSpec >> 4 === 1) {
4943              for (j = 0; j < 64; j++) {
4944                z = dctZigZag[j];
4945                tableData[z] = view.getUint16(offset);
4946                offset += 2;
4947              }
4948            } else {
4949              throw new JpegError("DQT - invalid table spec");
4950            }
4951            quantizationTables[quantizationTableSpec & 15] = tableData;
4952          }
4953          break;
4954        case 0xffc0:
4955        case 0xffc1:
4956        case 0xffc2:
4957          if (frame) {
4958            throw new JpegError("Only single frame JPEGs supported");
4959          }
4960          offset += 2;
4961          frame = {};
4962          frame.extended = fileMarker === 0xffc1;
4963          frame.progressive = fileMarker === 0xffc2;
4964          frame.precision = data[offset++];
4965          const sofScanLines = view.getUint16(offset);
4966          offset += 2;
4967          frame.scanLines = dnlScanLines || sofScanLines;
4968          frame.samplesPerLine = view.getUint16(offset);
4969          offset += 2;
4970          frame.components = [];
4971          frame.componentIds = {};
4972          const componentsCount = data[offset++];
4973          let maxH = 0,
4974            maxV = 0;
4975          for (i = 0; i < componentsCount; i++) {
4976            const componentId = data[offset];
4977            const h = data[offset + 1] >> 4;
4978            const v = data[offset + 1] & 15;
4979            if (maxH < h) {
4980              maxH = h;
4981            }
4982            if (maxV < v) {
4983              maxV = v;
4984            }
4985            const qId = data[offset + 2];
4986            l = frame.components.push({
4987              h,
4988              v,
4989              quantizationId: qId,
4990              quantizationTable: null
4991            });
4992            frame.componentIds[componentId] = l - 1;
4993            offset += 3;
4994          }
4995          frame.maxH = maxH;
4996          frame.maxV = maxV;
4997          prepareComponents(frame);
4998          break;
4999        case 0xffc4:
5000          const huffmanLength = view.getUint16(offset);
5001          offset += 2;
5002          for (i = 2; i < huffmanLength;) {
5003            const huffmanTableSpec = data[offset++];
5004            const codeLengths = new Uint8Array(16);
5005            let codeLengthSum = 0;
5006            for (j = 0; j < 16; j++, offset++) {
5007              codeLengthSum += codeLengths[j] = data[offset];
5008            }
5009            const huffmanValues = new Uint8Array(codeLengthSum);
5010            for (j = 0; j < codeLengthSum; j++, offset++) {
5011              huffmanValues[j] = data[offset];
5012            }
5013            i += 17 + codeLengthSum;
5014            (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
5015          }
5016          break;
5017        case 0xffdd:
5018          offset += 2;
5019          resetInterval = view.getUint16(offset);
5020          offset += 2;
5021          break;
5022        case 0xffda:
5023          const parseDNLMarker = ++numSOSMarkers === 1 && !dnlScanLines;
5024          offset += 2;
5025          const selectorsCount = data[offset++],
5026            components = [];
5027          for (i = 0; i < selectorsCount; i++) {
5028            const index = data[offset++];
5029            const componentIndex = frame.componentIds[index];
5030            const component = frame.components[componentIndex];
5031            component.index = index;
5032            const tableSpec = data[offset++];
5033            component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
5034            component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
5035            components.push(component);
5036          }
5037          const spectralStart = data[offset++],
5038            spectralEnd = data[offset++],
5039            successiveApproximation = data[offset++];
5040          try {
5041            const processed = decodeScan(data, view, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15, parseDNLMarker);
5042            offset += processed;
5043          } catch (ex) {
5044            if (ex instanceof DNLMarkerError) {
5045              warn(`${ex.message} -- attempting to re-parse the JPEG image.`);
5046              return this.parse(data, {
5047                dnlScanLines: ex.scanLines
5048              });
5049            } else if (ex instanceof EOIMarkerError) {
5050              warn(`${ex.message} -- ignoring the rest of the image data.`);
5051              break markerLoop;
5052            }
5053            throw ex;
5054          }
5055          break;
5056        case 0xffdc:
5057          offset += 4;
5058          break;
5059        case 0xffff:
5060          if (data[offset] !== 0xff) {
5061            offset--;
5062          }
5063          break;
5064        default:
5065          const nextFileMarker = findNextFileMarker(data, view, offset - 2, offset - 3);
5066          if (nextFileMarker?.invalid) {
5067            warn("JpegImage.parse - unexpected data, current marker is: " + nextFileMarker.invalid);
5068            offset = nextFileMarker.offset;
5069            break;
5070          }
5071          if (!nextFileMarker || offset >= maxOffset) {
5072            warn("JpegImage.parse - reached the end of the image data " + "without finding an EOI marker (0xFFD9).");
5073            break markerLoop;
5074          }
5075          throw new JpegError("JpegImage.parse - unknown marker: " + fileMarker.toString(16));
5076      }
5077      if (offset < maxOffset) {
5078        fileMarker = view.getUint16(offset);
5079        offset += 2;
5080      } else {
5081        fileMarker = 0;
5082      }
5083    }
5084    if (!frame) {
5085      throw new JpegError("JpegImage.parse - no frame data found.");
5086    }
5087    this.width = frame.samplesPerLine;
5088    this.height = frame.scanLines;
5089    this.jfif = jfif;
5090    this.adobe = adobe;
5091    this.components = [];
5092    for (const component of frame.components) {
5093      const quantizationTable = quantizationTables[component.quantizationId];
5094      if (quantizationTable) {
5095        component.quantizationTable = quantizationTable;
5096      }
5097      this.components.push({
5098        index: component.index,
5099        output: buildComponentData(frame, component),
5100        scaleX: component.h / frame.maxH,
5101        scaleY: component.v / frame.maxV,
5102        blocksPerLine: component.blocksPerLine,
5103        blocksPerColumn: component.blocksPerColumn
5104      });
5105    }
5106    this.numComponents = this.components.length;
5107    return undefined;
5108  }
5109  #getLinearizedBlockData(width, height, isSourcePDF) {
5110    const scaleX = this.width / width,
5111      scaleY = this.height / height;
5112    let component, componentScaleX, componentScaleY, blocksPerScanline;
5113    let x, y, i, j, k;
5114    let index;
5115    let offset = 0;
5116    let output;
5117    const numComponents = this.components.length;
5118    const dataLength = width * height * numComponents;
5119    const data = new Uint8ClampedArray(dataLength);
5120    const xScaleBlockOffset = new Uint32Array(width);
5121    const mask3LSB = 0xfffffff8;
5122    let lastComponentScaleX;
5123    for (i = 0; i < numComponents; i++) {
5124      component = this.components[i];
5125      componentScaleX = component.scaleX * scaleX;
5126      componentScaleY = component.scaleY * scaleY;
5127      offset = i;
5128      output = component.output;
5129      blocksPerScanline = component.blocksPerLine + 1 << 3;
5130      if (componentScaleX !== lastComponentScaleX) {
5131        for (x = 0; x < width; x++) {
5132          j = 0 | x * componentScaleX;
5133          xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
5134        }
5135        lastComponentScaleX = componentScaleX;
5136      }
5137      for (y = 0; y < height; y++) {
5138        j = 0 | y * componentScaleY;
5139        index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
5140        for (x = 0; x < width; x++) {
5141          data[offset] = output[index + xScaleBlockOffset[x]];
5142          offset += numComponents;
5143        }
5144      }
5145    }
5146    let transform = this._decodeTransform;
5147    if (transform) {
5148      for (i = 0; i < dataLength;) {
5149        for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
5150          data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
5151        }
5152      }
5153    }
5154    return data;
5155  }
5156  get _isColorConversionNeeded() {
5157    if (this.adobe) {
5158      return !!this.adobe.transformCode;
5159    }
5160    if (this.numComponents === 3) {
5161      if (this._colorTransform === 0) {
5162        return false;
5163      } else if (this.components[0].index === 0x52 && this.components[1].index === 0x47 && this.components[2].index === 0x42) {
5164        return false;
5165      }
5166      return true;
5167    }
5168    if (this._colorTransform === 1) {
5169      return true;
5170    }
5171    return false;
5172  }
5173  _convertYccToRgb(data) {
5174    let Y, Cb, Cr;
5175    for (let i = 0, ii = data.length; i < ii; i += 3) {
5176      Y = data[i];
5177      Cb = data[i + 1];
5178      Cr = data[i + 2];
5179      data[i] = Y - 179.456 + 1.402 * Cr;
5180      data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
5181      data[i + 2] = Y - 226.816 + 1.772 * Cb;
5182    }
5183    return data;
5184  }
5185  _convertYccToRgba(data, out) {
5186    for (let i = 0, j = 0, ii = data.length; i < ii; i += 3, j += 4) {
5187      const Y = data[i];
5188      const Cb = data[i + 1];
5189      const Cr = data[i + 2];
5190      out[j] = Y - 179.456 + 1.402 * Cr;
5191      out[j + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
5192      out[j + 2] = Y - 226.816 + 1.772 * Cb;
5193      out[j + 3] = 255;
5194    }
5195    return out;
5196  }
5197  _convertYcckToRgb(data) {
5198    this._convertYcckToCmyk(data);
5199    return this._convertCmykToRgb(data);
5200  }
5201  _convertYcckToRgba(data) {
5202    this._convertYcckToCmyk(data);
5203    return this._convertCmykToRgba(data);
5204  }
5205  _convertYcckToCmyk(data) {
5206    let Y, Cb, Cr;
5207    for (let i = 0, ii = data.length; i < ii; i += 4) {
5208      Y = data[i];
5209      Cb = data[i + 1];
5210      Cr = data[i + 2];
5211      data[i] = 434.456 - Y - 1.402 * Cr;
5212      data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
5213      data[i + 2] = 481.816 - Y - 1.772 * Cb;
5214    }
5215    return data;
5216  }
5217  _convertCmykToRgb(data) {
5218    const count = data.length / 4;
5219    ColorSpaceUtils.cmyk.getRgbBuffer(data, 0, count, data, 0, 8, 0);
5220    return data.subarray(0, count * 3);
5221  }
5222  _convertCmykToRgba(data) {
5223    ColorSpaceUtils.cmyk.getRgbBuffer(data, 0, data.length / 4, data, 0, 8, 1);
5224    if (ColorSpaceUtils.cmyk instanceof DeviceCmykCS) {
5225      for (let i = 3, ii = data.length; i < ii; i += 4) {
5226        data[i] = 255;
5227      }
5228    }
5229    return data;
5230  }
5231  getData({
5232    width,
5233    height,
5234    forceRGBA = false,
5235    forceRGB = false,
5236    isSourcePDF = true
5237  }) {
5238    if (this.numComponents > 4) {
5239      throw new JpegError("Unsupported color mode");
5240    }
5241    const data = this.#getLinearizedBlockData(width, height, isSourcePDF);
5242    if (this.numComponents === 1 && (forceRGBA || forceRGB)) {
5243      const len = data.length * (forceRGBA ? 4 : 3);
5244      const rgbaData = new Uint8ClampedArray(len);
5245      let offset = 0;
5246      if (forceRGBA) {
5247        grayToRGBA(data, new Uint32Array(rgbaData.buffer));
5248      } else {
5249        for (const grayColor of data) {
5250          rgbaData[offset++] = grayColor;
5251          rgbaData[offset++] = grayColor;
5252          rgbaData[offset++] = grayColor;
5253        }
5254      }
5255      return rgbaData;
5256    } else if (this.numComponents === 3 && this._isColorConversionNeeded) {
5257      if (forceRGBA) {
5258        const rgbaData = new Uint8ClampedArray(data.length / 3 * 4);
5259        return this._convertYccToRgba(data, rgbaData);
5260      }
5261      return this._convertYccToRgb(data);
5262    } else if (this.numComponents === 4) {
5263      if (this._isColorConversionNeeded) {
5264        if (forceRGBA) {
5265          return this._convertYcckToRgba(data);
5266        }
5267        if (forceRGB) {
5268          return this._convertYcckToRgb(data);
5269        }
5270        return this._convertYcckToCmyk(data);
5271      } else if (forceRGBA) {
5272        return this._convertCmykToRgba(data);
5273      } else if (forceRGB) {
5274        return this._convertCmykToRgb(data);
5275      }
5276    }
5277    return data;
5278  }
5279}
5280
5281;// ./src/core/jpeg_stream.js
5282
5283
5284
5285
5286class JpegStream extends DecodeStream {
5287  static #isImageDecoderSupported = FeatureTest.isImageDecoderSupported;
5288  constructor(stream, maybeLength, params) {
5289    super(maybeLength);
5290    this.stream = stream;
5291    this.dict = stream.dict;
5292    this.maybeLength = maybeLength;
5293    this.params = params;
5294  }
5295  static get canUseImageDecoder() {
5296    return shadow(this, "canUseImageDecoder", this.#isImageDecoderSupported ? ImageDecoder.isTypeSupp
vendor: 3,217 bytes, lines 5296-5400
5296orted("image/jpeg") : Promise.resolve(false));
5297  }
5298  static setOptions({
5299    isImageDecoderSupported = false
5300  }) {
5301    this.#isImageDecoderSupported = isImageDecoderSupported;
5302  }
5303  get bytes() {
5304    return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
5305  }
5306  ensureBuffer(requested) {}
5307  readBlock() {
5308    this.decodeImage();
5309  }
5310  get jpegOptions() {
5311    const jpegOptions = {
5312      decodeTransform: undefined,
5313      colorTransform: undefined
5314    };
5315    const decodeArr = this.dict.getArray("D", "Decode");
5316    if ((this.forceRGBA || this.forceRGB) && Array.isArray(decodeArr)) {
5317      const bitsPerComponent = this.dict.get("BPC", "BitsPerComponent") || 8;
5318      const decodeArrLength = decodeArr.length;
5319      const transform = new Int32Array(decodeArrLength);
5320      let transformNeeded = false;
5321      const maxValue = (1 << bitsPerComponent) - 1;
5322      for (let i = 0; i < decodeArrLength; i += 2) {
5323        transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
5324        transform[i + 1] = decodeArr[i] * maxValue | 0;
5325        if (transform[i] !== 256 || transform[i + 1] !== 0) {
5326          transformNeeded = true;
5327        }
5328      }
5329      if (transformNeeded) {
5330        jpegOptions.decodeTransform = transform;
5331      }
5332    }
5333    if (this.params instanceof Dict) {
5334      const colorTransform = this.params.get("ColorTransform");
5335      if (Number.isInteger(colorTransform)) {
5336        jpegOptions.colorTransform = colorTransform;
5337      }
5338    }
5339    return shadow(this, "jpegOptions", jpegOptions);
5340  }
5341  #skipUselessBytes(data) {
5342    for (let i = 0, ii = data.length - 1; i < ii; i++) {
5343      if (data[i] === 0xff && data[i + 1] === 0xd8) {
5344        if (i > 0) {
5345          data = data.subarray(i);
5346        }
5347        break;
5348      }
5349    }
5350    return data;
5351  }
5352  decodeImage(bytes) {
5353    if (this.eof) {
5354      return this.buffer;
5355    }
5356    bytes = this.#skipUselessBytes(bytes || this.bytes);
5357    const jpegImage = new JpegImage(this.jpegOptions);
5358    jpegImage.parse(bytes);
5359    const data = jpegImage.getData({
5360      width: this.drawWidth,
5361      height: this.drawHeight,
5362      forceRGBA: this.forceRGBA,
5363      forceRGB: this.forceRGB
5364    });
5365    this.buffer = data;
5366    this.bufferLength = data.length;
5367    this.eof = true;
5368    return this.buffer;
5369  }
5370  get canAsyncDecodeImageFromBuffer() {
5371    return this.stream.isAsync;
5372  }
5373  async getTransferableImage() {
5374    if (!(await JpegStream.canUseImageDecoder)) {
5375      return null;
5376    }
5377    const jpegOptions = this.jpegOptions;
5378    if (jpegOptions.decodeTransform) {
5379      return null;
5380    }
5381    let decoder;
5382    try {
5383      const bytes = this.canAsyncDecodeImageFromBuffer && (await this.stream.asyncGetBytes()) || this.bytes;
5384      if (!bytes) {
5385        return null;
5386      }
5387      let data = this.#skipUselessBytes(bytes);
5388      const useImageDecoder = JpegImage.canUseImageDecoder(data, jpegOptions.colorTransform);
5389      if (!useImageDecoder) {
5390        return null;
5391      }
5392      if (useImageDecoder.exifStart) {
5393        data = data.slice();
5394        data.fill(0x00, useImageDecoder.exifStart, useImageDecoder.exifEnd);
5395      }
5396      decoder = new ImageDecoder({
5397        data,
5398        type: "image/jpeg",
5399        preferAnimation: false
5400      }
vendor: 21,009 bytes, lines 5400-6051
5400);
5401      return (await decoder.decode()).image;
5402    } catch (reason) {
5403      warn(`getTransferableImage - failed: "${reason}".`);
5404      return null;
5405    } finally {
5406      decoder?.close();
5407    }
5408  }
5409  get isImageStream() {
5410    return true;
5411  }
5412}
5413
5414;// ./src/core/operator_list.js
5415
5416function addState(parentState, pattern, checkFn, iterateFn, processFn) {
5417  let state = parentState;
5418  for (let i = 0, ii = pattern.length - 1; i < ii; i++) {
5419    const item = pattern[i];
5420    state = state[item] ||= [];
5421  }
5422  state[pattern.at(-1)] = {
5423    checkFn,
5424    iterateFn,
5425    processFn
5426  };
5427}
5428const InitialState = [];
5429addState(InitialState, [OPS.save, OPS.transform, OPS.paintInlineImageXObject, OPS.restore], null, function iterateInlineImageGroup(context, i) {
5430  const fnArray = context.fnArray;
5431  const iFirstSave = context.iCurr - 3;
5432  const pos = (i - iFirstSave) % 4;
5433  switch (pos) {
5434    case 0:
5435      return fnArray[i] === OPS.save;
5436    case 1:
5437      return fnArray[i] === OPS.transform;
5438    case 2:
5439      return fnArray[i] === OPS.paintInlineImageXObject;
5440    case 3:
5441      return fnArray[i] === OPS.restore;
5442  }
5443  throw new Error(`iterateInlineImageGroup - invalid pos: ${pos}`);
5444}, function foundInlineImageGroup(context, i) {
5445  const MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
5446  const MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
5447  const MAX_WIDTH = 1000;
5448  const IMAGE_PADDING = 1;
5449  const fnArray = context.fnArray,
5450    argsArray = context.argsArray;
5451  const curr = context.iCurr;
5452  const iFirstSave = curr - 3;
5453  const iFirstTransform = curr - 2;
5454  const iFirstPIIXO = curr - 1;
5455  const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
5456  if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
5457    return i - (i - iFirstSave) % 4;
5458  }
5459  let maxX = 0;
5460  const map = [];
5461  let maxLineHeight = 0;
5462  let currentX = IMAGE_PADDING,
5463    currentY = IMAGE_PADDING;
5464  for (let q = 0; q < count; q++) {
5465    const transform = argsArray[iFirstTransform + (q << 2)];
5466    const img = argsArray[iFirstPIIXO + (q << 2)][0];
5467    if (currentX + img.width > MAX_WIDTH) {
5468      maxX = Math.max(maxX, currentX);
5469      currentY += maxLineHeight + 2 * IMAGE_PADDING;
5470      currentX = 0;
5471      maxLineHeight = 0;
5472    }
5473    map.push({
5474      transform,
5475      x: currentX,
5476      y: currentY,
5477      w: img.width,
5478      h: img.height
5479    });
5480    currentX += img.width + 2 * IMAGE_PADDING;
5481    maxLineHeight = Math.max(maxLineHeight, img.height);
5482  }
5483  const imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
5484  const imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
5485  const imgData = new Uint8Array(imgWidth * imgHeight * 4);
5486  const imgRowSize = imgWidth << 2;
5487  for (let q = 0; q < count; q++) {
5488    const data = argsArray[iFirstPIIXO + (q << 2)][0].data;
5489    const rowSize = map[q].w << 2;
5490    let dataOffset = 0;
5491    let offset = map[q].x + map[q].y * imgWidth << 2;
5492    imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
5493    for (let k = 0, kk = map[q].h; k < kk; k++) {
5494      imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
5495      dataOffset += rowSize;
5496      offset += imgRowSize;
5497    }
5498    imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
5499    while (offset >= 0) {
5500      data[offset - 4] = data[offset];
5501      data[offset - 3] = data[offset + 1];
5502      data[offset - 2] = data[offset + 2];
5503      data[offset - 1] = data[offset + 3];
5504      data[offset + rowSize] = data[offset + rowSize - 4];
5505      data[offset + rowSize + 1] = data[offset + rowSize - 3];
5506      data[offset + rowSize + 2] = data[offset + rowSize - 2];
5507      data[offset + rowSize + 3] = data[offset + rowSize - 1];
5508      offset -= imgRowSize;
5509    }
5510  }
5511  const img = {
5512    width: imgWidth,
5513    height: imgHeight
5514  };
5515  if (context.isOffscreenCanvasSupported) {
5516    const canvas = new OffscreenCanvas(imgWidth, imgHeight);
5517    const ctx = canvas.getContext("2d");
5518    ctx.putImageData(new ImageData(new Uint8ClampedArray(imgData.buffer), imgWidth, imgHeight), 0, 0);
5519    img.bitmap = canvas.transferToImageBitmap();
5520    img.data = null;
5521  } else {
5522    img.kind = ImageKind.RGBA_32BPP;
5523    img.data = imgData;
5524  }
5525  fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
5526  argsArray.splice(iFirstSave, count * 4, [img, map]);
5527  return iFirstSave + 1;
5528});
5529addState(InitialState, [OPS.save, OPS.transform, OPS.paintImageMaskXObject, OPS.restore], null, function iterateImageMaskGroup(context, i) {
5530  const fnArray = context.fnArray;
5531  const iFirstSave = context.iCurr - 3;
5532  const pos = (i - iFirstSave) % 4;
5533  switch (pos) {
5534    case 0:
5535      return fnArray[i] === OPS.save;
5536    case 1:
5537      return fnArray[i] === OPS.transform;
5538    case 2:
5539      return fnArray[i] === OPS.paintImageMaskXObject;
5540    case 3:
5541      return fnArray[i] === OPS.restore;
5542  }
5543  throw new Error(`iterateImageMaskGroup - invalid pos: ${pos}`);
5544}, function foundImageMaskGroup(context, i) {
5545  const MIN_IMAGES_IN_MASKS_BLOCK = 10;
5546  const MAX_IMAGES_IN_MASKS_BLOCK = 100;
5547  const MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
5548  const fnArray = context.fnArray,
5549    argsArray = context.argsArray;
5550  const curr = context.iCurr;
5551  const iFirstSave = curr - 3;
5552  const iFirstTransform = curr - 2;
5553  const iFirstPIMXO = curr - 1;
5554  let count = Math.floor((i - iFirstSave) / 4);
5555  if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
5556    return i - (i - iFirstSave) % 4;
5557  }
5558  let isSameImage = false;
5559  let iTransform, transformArgs;
5560  const firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
5561  const firstTransformArg0 = argsArray[iFirstTransform][0],
5562    firstTransformArg1 = argsArray[iFirstTransform][1],
5563    firstTransformArg2 = argsArray[iFirstTransform][2],
5564    firstTransformArg3 = argsArray[iFirstTransform][3];
5565  if (firstTransformArg1 === firstTransformArg2) {
5566    isSameImage = true;
5567    iTransform = iFirstTransform + 4;
5568    let iPIMXO = iFirstPIMXO + 4;
5569    for (let q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
5570      transformArgs = argsArray[iTransform];
5571      if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== firstTransformArg1 || transformArgs[2] !== firstTransformArg2 || transformArgs[3] !== firstTransformArg3) {
5572        if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
5573          isSameImage = false;
5574        } else {
5575          count = q;
5576        }
5577        break;
5578      }
5579    }
5580  }
5581  if (isSameImage) {
5582    count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
5583    const positions = new Float32Array(count * 2);
5584    iTransform = iFirstTransform;
5585    for (let q = 0; q < count; q++, iTransform += 4) {
5586      transformArgs = argsArray[iTransform];
5587      positions[q << 1] = transformArgs[4];
5588      positions[(q << 1) + 1] = transformArgs[5];
5589    }
5590    fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
5591    argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg1, firstTransformArg2, firstTransformArg3, positions]);
5592  } else {
5593    count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
5594    const images = [];
5595    for (let q = 0; q < count; q++) {
5596      transformArgs = argsArray[iFirstTransform + (q << 2)];
5597      const maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
5598      images.push({
5599        data: maskParams.data,
5600        width: maskParams.width,
5601        height: maskParams.height,
5602        interpolate: maskParams.interpolate,
5603        count: maskParams.count,
5604        transform: transformArgs
5605      });
5606    }
5607    fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
5608    argsArray.splice(iFirstSave, count * 4, [images]);
5609  }
5610  return iFirstSave + 1;
5611});
5612addState(InitialState, [OPS.save, OPS.transform, OPS.paintImageXObject, OPS.restore], function (context) {
5613  const argsArray = context.argsArray;
5614  const iFirstTransform = context.iCurr - 2;
5615  return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
5616}, function iterateImageGroup(context, i) {
5617  const fnArray = context.fnArray,
5618    argsArray = context.argsArray;
5619  const iFirstSave = context.iCurr - 3;
5620  const pos = (i - iFirstSave) % 4;
5621  switch (pos) {
5622    case 0:
5623      return fnArray[i] === OPS.save;
5624    case 1:
5625      if (fnArray[i] !== OPS.transform) {
5626        return false;
5627      }
5628      const iFirstTransform = context.iCurr - 2;
5629      const firstTransformArg0 = argsArray[iFirstTransform][0];
5630      const firstTransformArg3 = argsArray[iFirstTransform][3];
5631      if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {
5632        return false;
5633      }
5634      return true;
5635    case 2:
5636      if (fnArray[i] !== OPS.paintImageXObject) {
5637        return false;
5638      }
5639      const iFirstPIXO = context.iCurr - 1;
5640      const firstPIXOArg0 = argsArray[iFirstPIXO][0];
5641      if (argsArray[i][0] !== firstPIXOArg0) {
5642        return false;
5643      }
5644      return true;
5645    case 3:
5646      return fnArray[i] === OPS.restore;
5647  }
5648  throw new Error(`iterateImageGroup - invalid pos: ${pos}`);
5649}, function (context, i) {
5650  const MIN_IMAGES_IN_BLOCK = 3;
5651  const MAX_IMAGES_IN_BLOCK = 1000;
5652  const fnArray = context.fnArray,
5653    argsArray = context.argsArray;
5654  const curr = context.iCurr;
5655  const iFirstSave = curr - 3;
5656  const iFirstTransform = curr - 2;
5657  const iFirstPIXO = curr - 1;
5658  const firstPIXOArg0 = argsArray[iFirstPIXO][0];
5659  const firstTransformArg0 = argsArray[iFirstTransform][0];
5660  const firstTransformArg3 = argsArray[iFirstTransform][3];
5661  const count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
5662  if (count < MIN_IMAGES_IN_BLOCK) {
5663    return i - (i - iFirstSave) % 4;
5664  }
5665  const positions = new Float32Array(count * 2);
5666  let iTransform = iFirstTransform;
5667  for (let q = 0; q < count; q++, iTransform += 4) {
5668    const transformArgs = argsArray[iTransform];
5669    positions[q << 1] = transformArgs[4];
5670    positions[(q << 1) + 1] = transformArgs[5];
5671  }
5672  const args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
5673  fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
5674  argsArray.splice(iFirstSave, count * 4, args);
5675  return iFirstSave + 1;
5676});
5677addState(InitialState, [OPS.beginText, OPS.setFont, OPS.setTextMatrix, OPS.showText, OPS.endText], null, function iterateShowTextGroup(context, i) {
5678  const fnArray = context.fnArray,
5679    argsArray = context.argsArray;
5680  const iFirstSave = context.iCurr - 4;
5681  const pos = (i - iFirstSave) % 5;
5682  switch (pos) {
5683    case 0:
5684      return fnArray[i] === OPS.beginText;
5685    case 1:
5686      return fnArray[i] === OPS.setFont;
5687    case 2:
5688      return fnArray[i] === OPS.setTextMatrix;
5689    case 3:
5690      if (fnArray[i] !== OPS.showText) {
5691        return false;
5692      }
5693      const iFirstSetFont = context.iCurr - 3;
5694      const firstSetFontArg0 = argsArray[iFirstSetFont][0];
5695      const firstSetFontArg1 = argsArray[iFirstSetFont][1];
5696      if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {
5697        return false;
5698      }
5699      return true;
5700    case 4:
5701      return fnArray[i] === OPS.endText;
5702  }
5703  throw new Error(`iterateShowTextGroup - invalid pos: ${pos}`);
5704}, function (context, i) {
5705  const MIN_CHARS_IN_BLOCK = 3;
5706  const MAX_CHARS_IN_BLOCK = 1000;
5707  const fnArray = context.fnArray,
5708    argsArray = context.argsArray;
5709  const curr = context.iCurr;
5710  const iFirstBeginText = curr - 4;
5711  const iFirstSetFont = curr - 3;
5712  const iFirstSetTextMatrix = curr - 2;
5713  const iFirstShowText = curr - 1;
5714  const iFirstEndText = curr;
5715  const firstSetFontArg0 = argsArray[iFirstSetFont][0];
5716  const firstSetFontArg1 = argsArray[iFirstSetFont][1];
5717  let count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
5718  if (count < MIN_CHARS_IN_BLOCK) {
5719    return i - (i - iFirstBeginText) % 5;
5720  }
5721  let iFirst = iFirstBeginText;
5722  if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
5723    count++;
5724    iFirst -= 5;
5725  }
5726  let iEndText = iFirst + 4;
5727  for (let q = 1; q < count; q++) {
5728    fnArray.splice(iEndText, 3);
5729    argsArray.splice(iEndText, 3);
5730    iEndText += 2;
5731  }
5732  return iEndText + 1;
5733});
5734addState(InitialState, [OPS.save, OPS.transform, OPS.constructPath, OPS.restore], context => {
5735  const argsArray = context.argsArray;
5736  const iFirstConstructPath = context.iCurr - 1;
5737  const op = argsArray[iFirstConstructPath][0];
5738  if (op !== OPS.stroke && op !== OPS.closeStroke && op !== OPS.fillStroke && op !== OPS.eoFillStroke && op !== OPS.closeFillStroke && op !== OPS.closeEOFillStroke) {
5739    return true;
5740  }
5741  const iFirstTransform = context.iCurr - 2;
5742  const transform = argsArray[iFirstTransform];
5743  return transform[0] === 1 && transform[1] === 0 && transform[2] === 0 && transform[3] === 1;
5744}, () => false, (context, i) => {
5745  const {
5746    fnArray,
5747    argsArray
5748  } = context;
5749  const curr = context.iCurr;
5750  const iFirstSave = curr - 3;
5751  const iFirstTransform = curr - 2;
5752  const iFirstConstructPath = curr - 1;
5753  const args = argsArray[iFirstConstructPath];
5754  const transform = argsArray[iFirstTransform];
5755  const [, [buffer], minMax] = args;
5756  if (minMax) {
5757    const newBBox = F32_BBOX_INIT.slice();
5758    Util.axialAlignedBoundingBox(minMax, transform, newBBox);
5759    minMax.set(newBBox);
5760    for (let k = 0, kk = buffer.length; k < kk;) {
5761      switch (buffer[k++]) {
5762        case DrawOPS.moveTo:
5763        case DrawOPS.lineTo:
5764          Util.applyTransform(buffer, transform, k);
5765          k += 2;
5766          break;
5767        case DrawOPS.curveTo:
5768          Util.applyTransformToBezier(buffer, transform, k);
5769          k += 6;
5770          break;
5771      }
5772    }
5773  }
5774  fnArray.splice(iFirstSave, 4, OPS.constructPath);
5775  argsArray.splice(iFirstSave, 4, args);
5776  return iFirstSave + 1;
5777});
5778class NullOptimizer {
5779  constructor(queue) {
5780    this.queue = queue;
5781  }
5782  _optimize() {}
5783  push(fn, args) {
5784    this.queue.fnArray.push(fn);
5785    this.queue.argsArray.push(args);
5786    this._optimize();
5787  }
5788  flush() {}
5789  reset() {}
5790}
5791class QueueOptimizer extends NullOptimizer {
5792  constructor(queue) {
5793    super(queue);
5794    this.state = null;
5795    this.context = {
5796      iCurr: 0,
5797      fnArray: queue.fnArray,
5798      argsArray: queue.argsArray,
5799      isOffscreenCanvasSupported: OperatorList.isOffscreenCanvasSupported
5800    };
5801    this.match = null;
5802    this.lastProcessed = 0;
5803  }
5804  _optimize() {
5805    const fnArray = this.queue.fnArray;
5806    let i = this.lastProcessed,
5807      ii = fnArray.length;
5808    let state = this.state;
5809    let match = this.match;
5810    if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) {
5811      this.lastProcessed = ii;
5812      return;
5813    }
5814    const context = this.context;
5815    while (i < ii) {
5816      if (match) {
5817        const iterate = (0, match.iterateFn)(context, i);
5818        if (iterate) {
5819          i++;
5820          continue;
5821        }
5822        i = (0, match.processFn)(context, i + 1);
5823        ii = fnArray.length;
5824        match = null;
5825        state = null;
5826        if (i >= ii) {
5827          break;
5828        }
5829      }
5830      state = (state || InitialState)[fnArray[i]];
5831      if (!state || Array.isArray(state)) {
5832        i++;
5833        continue;
5834      }
5835      context.iCurr = i;
5836      i++;
5837      if (state.checkFn && !(0, state.checkFn)(context)) {
5838        state = null;
5839        continue;
5840      }
5841      match = state;
5842      state = null;
5843    }
5844    this.state = state;
5845    this.match = match;
5846    this.lastProcessed = i;
5847  }
5848  flush() {
5849    while (this.match) {
5850      const length = this.queue.fnArray.length;
5851      this.lastProcessed = (0, this.match.processFn)(this.context, length);
5852      this.match = null;
5853      this.state = null;
5854      this._optimize();
5855    }
5856  }
5857  reset() {
5858    this.state = null;
5859    this.match = null;
5860    this.lastProcessed = 0;
5861  }
5862}
5863class OperatorList {
5864  static CHUNK_SIZE = 1000;
5865  static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
5866  static isOffscreenCanvasSupported = false;
5867  constructor(intent = 0, streamSink) {
5868    this._streamSink = streamSink;
5869    this.fnArray = [];
5870    this.argsArray = [];
5871    this.optimizer = streamSink && !(intent & RenderingIntentFlag.OPLIST) ? new QueueOptimizer(this) : new NullOptimizer(this);
5872    this.dependencies = new Set();
5873    this._totalLength = 0;
5874    this.weight = 0;
5875    this._resolved = streamSink ? null : Promise.resolve();
5876  }
5877  static setOptions({
5878    isOffscreenCanvasSupported
5879  }) {
5880    this.isOffscreenCanvasSupported = isOffscreenCanvasSupported;
5881  }
5882  get length() {
5883    return this.argsArray.length;
5884  }
5885  get ready() {
5886    return this._resolved || this._streamSink.ready;
5887  }
5888  get totalLength() {
5889    return this._totalLength + this.length;
5890  }
5891  addOp(fn, args) {
5892    this.optimizer.push(fn, args);
5893    this.weight++;
5894    if (this._streamSink) {
5895      if (this.weight >= OperatorList.CHUNK_SIZE) {
5896        this.flush();
5897      } else if (this.weight >= OperatorList.CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
5898        this.flush();
5899      }
5900    }
5901  }
5902  addImageOps(fn, args, optionalContent, hasMask = false) {
5903    if (hasMask) {
5904      this.addOp(OPS.save);
5905      this.addOp(OPS.setGState, [[["SMask", false]]]);
5906    }
5907    if (optionalContent !== undefined) {
5908      this.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]);
5909    }
5910    this.addOp(fn, args);
5911    if (optionalContent !== undefined) {
5912      this.addOp(OPS.endMarkedContent, []);
5913    }
5914    if (hasMask) {
5915      this.addOp(OPS.restore);
5916    }
5917  }
5918  addDependency(dependency) {
5919    if (this.dependencies.has(dependency)) {
5920      return;
5921    }
5922    this.dependencies.add(dependency);
5923    this.addOp(OPS.dependency, [dependency]);
5924  }
5925  addDependencies(dependencies) {
5926    for (const dependency of dependencies) {
5927      this.addDependency(dependency);
5928    }
5929  }
5930  addOpList(opList) {
5931    if (!(opList instanceof OperatorList)) {
5932      warn('addOpList - ignoring invalid "opList" parameter.');
5933      return;
5934    }
5935    for (const dependency of opList.dependencies) {
5936      this.dependencies.add(dependency);
5937    }
5938    for (let i = 0, ii = opList.length; i < ii; i++) {
5939      this.addOp(opList.fnArray[i], opList.argsArray[i]);
5940    }
5941  }
5942  getIR() {
5943    return {
5944      fnArray: this.fnArray,
5945      argsArray: this.argsArray,
5946      length: this.length
5947    };
5948  }
5949  get _transfers() {
5950    const transfers = [];
5951    const {
5952      fnArray,
5953      argsArray,
5954      length
5955    } = this;
5956    for (let i = 0; i < length; i++) {
5957      switch (fnArray[i]) {
5958        case OPS.paintInlineImageXObject:
5959        case OPS.paintInlineImageXObjectGroup:
5960        case OPS.paintImageMaskXObject:
5961          {
5962            const {
5963              bitmap,
5964              data
5965            } = argsArray[i][0];
5966            if (bitmap || data?.buffer) {
5967              transfers.push(bitmap || data.buffer);
5968            }
5969            break;
5970          }
5971        case OPS.constructPath:
5972          {
5973            const [, [data], minMax] = argsArray[i];
5974            if (data) {
5975              transfers.push(data.buffer, minMax.buffer);
5976            }
5977            break;
5978          }
5979        case OPS.paintFormXObjectBegin:
5980          const [matrix, bbox] = argsArray[i];
5981          if (matrix) {
5982            transfers.push(matrix.buffer);
5983          }
5984          if (bbox) {
5985            transfers.push(bbox.buffer);
5986          }
5987          break;
5988        case OPS.setTextMatrix:
5989          transfers.push(argsArray[i][0].buffer);
5990          break;
5991      }
5992    }
5993    return transfers;
5994  }
5995  flush(lastChunk = false, separateAnnots = null) {
5996    this.optimizer.flush();
5997    const length = this.length;
5998    this._totalLength += length;
5999    this._streamSink.enqueue({
6000      fnArray: this.fnArray,
6001      argsArray: this.argsArray,
6002      lastChunk,
6003      separateAnnots,
6004      length
6005    }, 1, this._transfers);
6006    this.dependencies.clear();
6007    this.fnArray.length = 0;
6008    this.argsArray.length = 0;
6009    this.weight = 0;
6010    this.optimizer.reset();
6011  }
6012}
6013class CheckedOperatorList extends OperatorList {
6014  needsIsolation = false;
6015  hasSoftMask = false;
6016  addOp(fn, args) {
6017    if (!this.needsIsolation || !this.hasSoftMask) {
6018      if (fn === OPS.beginGroup) {
6019        this.needsIsolation ||= args[0].needsIsolation;
6020        this.hasSoftMask ||= args[0].hasSoftMask;
6021      } else if (fn === OPS.setGState) {
6022        for (const [key, val] of args[0]) {
6023          if (key === "BM" && val !== "source-over") {
6024            this.needsIsolation = true;
6025          } else if (key === "SMask" && val !== false) {
6026            this.needsIsolation = true;
6027            this.hasSoftMask = true;
6028          }
6029        }
6030      }
6031    }
6032    super.addOp(fn, args);
6033  }
6034}
6035
6036;// ./src/core/pattern.js
6037
6038
6039
6040
6041
6042const ShadingType = {
6043  FUNCTION_BASED: 1,
6044  AXIAL: 2,
6045  RADIAL: 3,
6046  FREE_FORM_MESH: 4,
6047  LATTICE_FORM_MESH: 5,
6048  COONS_PATCH_MESH: 6,
6049  TENSOR_PATCH_MESH: 7
6050};
6051c
vendor: 1,662 bytes, lines 6051-6097
6051lass Pattern {
6052  static #hasGPU = false;
6053  constructor() {
6054    unreachable("Cannot initialize Pattern.");
6055  }
6056  static setOptions({
6057    hasGPU
6058  }) {
6059    this.#hasGPU = hasGPU;
6060  }
6061  static parseShading(shading, xref, res, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache) {
6062    const dict = shading instanceof BaseStream ? shading.dict : shading;
6063    const type = dict.get("ShadingType");
6064    try {
6065      switch (type) {
6066        case ShadingType.FUNCTION_BASED:
6067          return new FunctionBasedShading(dict, xref, res, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache);
6068        case ShadingType.AXIAL:
6069        case ShadingType.RADIAL:
6070          return new RadialAxialShading(dict, xref, res, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache);
6071        case ShadingType.FREE_FORM_MESH:
6072        case ShadingType.LATTICE_FORM_MESH:
6073        case ShadingType.COONS_PATCH_MESH:
6074        case ShadingType.TENSOR_PATCH_MESH:
6075          return new MeshShading(shading, xref, res, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache);
6076        default:
6077          throw new FormatError("Unsupported ShadingType: " + type);
6078      }
6079    } catch (ex) {
6080      if (ex instanceof MissingDataException) {
6081        throw ex;
6082      }
6083      warn(ex);
6084      return new DummyShading();
6085    }
6086  }
6087}
6088class BaseShading {
6089  static SMALL_NUMBER = 1e-6;
6090  getIR() {
6091    unreachable("Abstract method `getIR` called.");
6092  }
6093}
6094class RadialAxialShading extends BaseShading {
6095  constructor(dict, xref, resources, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache) {
6096    super();
6097    this.shadingType = dict.get("ShadingType");
vendor: 2,277 bytes, lines 6098-6164
6098    let coordsLen = 0;
6099    if (this.shadingType === ShadingType.AXIAL) {
6100      coordsLen = 4;
6101    } else if (this.shadingType === ShadingType.RADIAL) {
6102      coordsLen = 6;
6103    }
6104    this.coordsArr = dict.getArray("Coords");
6105    if (!isNumberArray(this.coordsArr, coordsLen)) {
6106      throw new FormatError("RadialAxialShading: Invalid /Coords array.");
6107    }
6108    const cs = ColorSpaceUtils.parse({
6109      cs: dict.getRaw("CS") || dict.getRaw("ColorSpace"),
6110      xref,
6111      resources,
6112      pdfFunctionFactory,
6113      globalColorSpaceCache,
6114      localColorSpaceCache
6115    });
6116    this.bbox = lookupNormalRect(dict.getArray("BBox"), null);
6117    let t0 = 0.0,
6118      t1 = 1.0;
6119    const domainArr = dict.getArray("Domain");
6120    if (isNumberArray(domainArr, 2)) {
6121      [t0, t1] = domainArr;
6122    }
6123    let extendStart = false,
6124      extendEnd = false;
6125    const extendArr = dict.getArray("Extend");
6126    if (isBooleanArray(extendArr, 2)) {
6127      [extendStart, extendEnd] = extendArr;
6128    }
6129    this.extendStart = extendStart;
6130    this.extendEnd = extendEnd;
6131    const fnObj = dict.getRaw("Function");
6132    const fn = pdfFunctionFactory.create(fnObj, true);
6133    const NUMBER_OF_SAMPLES = 840;
6134    const step = (t1 - t0) / NUMBER_OF_SAMPLES;
6135    const colorStops = this.colorStops = [];
6136    if (t0 >= t1 || step <= 0) {
6137      info("Bad shading domain.");
6138      return;
6139    }
6140    const color = new Float32Array(cs.numComps),
6141      ratio = new Float32Array(1);
6142    let iBase = 0;
6143    ratio[0] = t0;
6144    fn(ratio, 0, color, 0);
6145    const rgbBuffer = new Uint8ClampedArray(3);
6146    cs.getRgb(color, 0, rgbBuffer);
6147    let [rBase, gBase, bBase] = rgbBuffer;
6148    colorStops.push([0, Util.makeHexColor(rBase, gBase, bBase)]);
6149    let iPrev = 1;
6150    ratio[0] = t0 + step;
6151    fn(ratio, 0, color, 0);
6152    cs.getRgb(color, 0, rgbBuffer);
6153    let [rPrev, gPrev, bPrev] = rgbBuffer;
6154    let maxSlopeR = rPrev - rBase + 1;
6155    let maxSlopeG = gPrev - gBase + 1;
6156    let maxSlopeB = bPrev - bBase + 1;
6157    let minSlopeR = rPrev - rBase - 1;
6158    let minSlopeG = gPrev - gBase - 1;
6159    let minSlopeB = bPrev - bBase - 1;
6160    for (let i = 2; i < NUMBER_OF_SAMPLES; i++) {
6161      ratio[0] = t0 + i * step;
6162      fn(ratio, 0, color, 0);
6163      cs.getRgb(color, 0, rgbBuffer);
6164      const [r, g, b] = rgbBuffer
vendor: 6,580 bytes, lines 6164-6351
6164;
6165      const run = i - iBase;
6166      maxSlopeR = Math.min(maxSlopeR, (r - rBase + 1) / run);
6167      maxSlopeG = Math.min(maxSlopeG, (g - gBase + 1) / run);
6168      maxSlopeB = Math.min(maxSlopeB, (b - bBase + 1) / run);
6169      minSlopeR = Math.max(minSlopeR, (r - rBase - 1) / run);
6170      minSlopeG = Math.max(minSlopeG, (g - gBase - 1) / run);
6171      minSlopeB = Math.max(minSlopeB, (b - bBase - 1) / run);
6172      const slopesExist = minSlopeR <= maxSlopeR && minSlopeG <= maxSlopeG && minSlopeB <= maxSlopeB;
6173      if (!slopesExist) {
6174        const cssColor = Util.makeHexColor(rPrev, gPrev, bPrev);
6175        colorStops.push([iPrev / NUMBER_OF_SAMPLES, cssColor]);
6176        maxSlopeR = r - rPrev + 1;
6177        maxSlopeG = g - gPrev + 1;
6178        maxSlopeB = b - bPrev + 1;
6179        minSlopeR = r - rPrev - 1;
6180        minSlopeG = g - gPrev - 1;
6181        minSlopeB = b - bPrev - 1;
6182        iBase = iPrev;
6183        rBase = rPrev;
6184        gBase = gPrev;
6185        bBase = bPrev;
6186      }
6187      iPrev = i;
6188      rPrev = r;
6189      gPrev = g;
6190      bPrev = b;
6191    }
6192    colorStops.push([1, Util.makeHexColor(rPrev, gPrev, bPrev)]);
6193    const background = dict.has("Background") ? cs.getRgbHex(dict.get("Background"), 0) : "transparent";
6194    if (!extendStart) {
6195      colorStops.unshift([0, background]);
6196      colorStops[1][0] += BaseShading.SMALL_NUMBER;
6197    }
6198    if (!extendEnd) {
6199      colorStops.at(-1)[0] -= BaseShading.SMALL_NUMBER;
6200      colorStops.push([1, background]);
6201    }
6202    this.colorStops = colorStops;
6203  }
6204  getIR() {
6205    const {
6206      coordsArr,
6207      shadingType
6208    } = this;
6209    let type, p0, p1, r0, r1;
6210    if (shadingType === ShadingType.AXIAL) {
6211      p0 = [coordsArr[0], coordsArr[1]];
6212      p1 = [coordsArr[2], coordsArr[3]];
6213      r0 = null;
6214      r1 = null;
6215      type = "axial";
6216    } else if (shadingType === ShadingType.RADIAL) {
6217      p0 = [coordsArr[0], coordsArr[1]];
6218      p1 = [coordsArr[3], coordsArr[4]];
6219      r0 = coordsArr[2];
6220      r1 = coordsArr[5];
6221      type = "radial";
6222    } else {
6223      unreachable(`getPattern type unknown: ${shadingType}`);
6224    }
6225    return ["RadialAxial", type, this.bbox, this.colorStops, p0, p1, r0, r1];
6226  }
6227}
6228function meshUpdateBounds(self) {
6229  let minX = self.coords[0][0],
6230    minY = self.coords[0][1],
6231    maxX = minX,
6232    maxY = minY;
6233  for (let i = 1, ii = self.coords.length; i < ii; i++) {
6234    const x = self.coords[i][0],
6235      y = self.coords[i][1];
6236    minX = minX > x ? x : minX;
6237    minY = minY > y ? y : minY;
6238    maxX = maxX < x ? x : maxX;
6239    maxY = maxY < y ? y : maxY;
6240  }
6241  self.bounds = [minX, minY, maxX, maxY];
6242}
6243function meshPackData(self) {
6244  let i, j, ii;
6245  const coords = self.coords;
6246  const coordsPacked = new Float32Array(coords.length * 2);
6247  for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
6248    const xy = coords[i];
6249    coordsPacked[j++] = xy[0];
6250    coordsPacked[j++] = xy[1];
6251  }
6252  self.coords = coordsPacked;
6253  const colors = self.colors;
6254  const colorsPacked = new Uint8Array(colors.length * 4);
6255  for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
6256    const c = colors[i];
6257    colorsPacked[j++] = c[0];
6258    colorsPacked[j++] = c[1];
6259    colorsPacked[j++] = c[2];
6260    j++;
6261  }
6262  self.colors = colorsPacked;
6263  for (const figure of self.figures) {
6264    figure.coords = new Uint32Array(figure.coords);
6265    figure.colors = new Uint32Array(figure.colors);
6266  }
6267}
6268function buildMeshVertexData(coords, colors, figures) {
6269  let vertexCount = 0;
6270  for (const figure of figures) {
6271    if (figure.type === MeshFigureType.TRIANGLES) {
6272      vertexCount += figure.coords.length;
6273    } else if (figure.type === MeshFigureType.LATTICE) {
6274      const vpr = figure.verticesPerRow;
6275      vertexCount += (Math.floor(figure.coords.length / vpr) - 1) * (vpr - 1) * 6;
6276    }
6277  }
6278  const posData = new Float32Array(vertexCount * 2);
6279  const colData = new Uint8Array(vertexCount * 4);
6280  let pOff = 0,
6281    cOff = 0;
6282  const addVertex = (pi, ci) => {
6283    posData[pOff++] = coords[pi * 2];
6284    posData[pOff++] = coords[pi * 2 + 1];
6285    colData[cOff++] = colors[ci * 4];
6286    colData[cOff++] = colors[ci * 4 + 1];
6287    colData[cOff++] = colors[ci * 4 + 2];
6288    cOff++;
6289  };
6290  for (const figure of figures) {
6291    const ps = figure.coords;
6292    const cs = figure.colors;
6293    if (figure.type === MeshFigureType.TRIANGLES) {
6294      for (let i = 0, ii = ps.length; i < ii; i++) {
6295        addVertex(ps[i], cs[i]);
6296      }
6297    } else if (figure.type === MeshFigureType.LATTICE) {
6298      const vpr = figure.verticesPerRow;
6299      const rows = Math.floor(ps.length / vpr) - 1;
6300      const cols = vpr - 1;
6301      for (let i = 0; i < rows; i++) {
6302        let q = i * vpr;
6303        for (let j = 0; j < cols; j++, q++) {
6304          addVertex(ps[q], cs[q]);
6305          addVertex(ps[q + 1], cs[q + 1]);
6306          addVertex(ps[q + vpr], cs[q + vpr]);
6307          addVertex(ps[q + vpr + 1], cs[q + vpr + 1]);
6308          addVertex(ps[q + 1], cs[q + 1]);
6309          addVertex(ps[q + vpr], cs[q + vpr]);
6310        }
6311      }
6312    }
6313  }
6314  return {
6315    posData,
6316    colData,
6317    vertexCount
6318  };
6319}
6320class FunctionBasedShading extends BaseShading {
6321  static MAX_STEP_COUNT = 512;
6322  constructor(dict, xref, resources, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache) {
6323    super();
6324    this.bbox = lookupNormalRect(dict.getArray("BBox"), null);
6325    const cs = ColorSpaceUtils.parse({
6326      cs: dict.getRaw("CS") || dict.getRaw("ColorSpace"),
6327      xref,
6328      resources,
6329      pdfFunctionFactory,
6330      globalColorSpaceCache,
6331      localColorSpaceCache
6332    });
6333    this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
6334    const fnObj = dict.getRaw("Function");
6335    if (!fnObj) {
6336      throw new FormatError("FunctionBasedShading: missing /Function");
6337    }
6338    const fn = pdfFunctionFactory.create(fnObj, true);
6339    const [x0, x1, y0, y1] = lookupRect(dict.getArray("Domain"), [0, 1, 0, 1]);
6340    const matrix = lookupMatrix(dict.getArray("Matrix"), IDENTITY_MATRIX);
6341    this.bounds = BBOX_INIT.slice();
6342    Util.axialAlignedBoundingBox([x0, y0, x1, y1], matrix, this.bounds);
6343    const bboxW = this.bounds[2] - this.bounds[0];
6344    const bboxH = this.bounds[3] - this.bounds[1];
6345    const stepsX = MathClamp(Math.ceil(bboxW), 1, FunctionBasedShading.MAX_STEP_COUNT);
6346    const stepsY = MathClamp(Math.ceil(bboxH), 1, FunctionBasedShading.MAX_STEP_COUNT);
6347    const verticesPerRow = stepsX + 1;
6348    const totalVertices = (stepsY + 1) * verticesPerRow;
6349    const coords = this.coords = new Float32Array(totalVertices * 2);
6350    const colors = this.colors = new Uint8ClampedArray(totalVertices * 4);
6351    const 
6351xyBuf = new Float32Array(2);
6352    const colorBuf = new Float32Array(cs.numComps);
6353    const rangeX = (x1 - x0) / stepsX;
6354    const rangeY = (y1 - y0) / stepsY;
6355    const halfStepX = rangeX / 2;
6356    const halfStepY = rangeY / 2;
6357    let coordOffset = 0;
6358    let colorOffset = 0;
6359    for (let row = 0; row <= stepsY; row++) {
6360      const yDomain = y0 + rangeY * row;
6361      xyBuf[1] = row === stepsY ? yDomain - halfStepY : yDomain;
6362      for (let col = 0; col <= stepsX; col++) {
6363        const xDomain = x0 + rangeX * col;
6364        xyBuf[0] = col === stepsX ? xDomain - halfStepX : xDomain;
6365        fn(xyBuf, 0, colorBuf, 0);
6366        coords[coordOffset] = xDomain;
6367        coords[coordOffset + 1] = yDomain;
6368        Util.applyTransform(coords, matrix, coordOffset);
6369        coordOffset += 2;
6370        cs.getRgbItem(colorBuf, 0, colors, colorOffset);
6371        colorOffset += 4;
6372      }
6373    }
6374    const ps = new Uint32Array(totalVertices);
6375    for (let i = 0; i < totalVertices; i++) {
6376      ps[i] = i;
6377    }
6378    this.figures = [{
6379      type: MeshFigureType.LATTICE,
6380      coords: ps,
6381      colors: new Uint32Array(ps),
6382      verticesPerRow
6383    }];
6384  }
6385  getIR() {
6386    const {
6387      posData,
6388      colData,
6389      vertexCount
6390    } = buildMeshVertexData(this.coords, this.colors, this.figures);
6391    return ["Mesh", ShadingType.FUNCTION_BASED, posData, colData, vertexCount, this.bounds, this.bbox, this.background];
6392  }
6393}
6394class MeshStreamReader {
6395  constructor(stream, context) {
6396    this.stream = stream;
6397    this.context = context;
6398    this.buffer = 0;
6399    this.bufferLength = 0;
6400    const numComps = context.numComps;
6401    this.tmpCompsBuf = new Float32Array(numComps);
6402    const csNumComps = context.colorSpace.numComps;
6403    this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
6404  }
6405  get hasData() {
6406    if (this.stream.end) {
6407      return this.stream.pos < this.stream.end;
6408    }
6409    if (this.bufferLength > 0) {
6410      return true;
6411    }
6412    const nextByte = this.stream.getByte();
6413    if (nextByte < 0) {
6414      return false;
6415    }
6416    this.buffer = nextByte;
6417    this.bufferLength = 8;
6418    return true;
6419  }
6420  readBits(n) {
6421    const {
6422      stream
6423    } = this;
6424    let {
6425      buffer,
6426      bufferLength
6427    } = this;
6428    if (n === 32) {
6429      if (bufferLength === 0) {
6430        return stream.getInt32() >>> 0;
6431      }
6432      buffer = buffer << 24 | stream.getByte() << 16 | stream.getByte() << 8 | stream.getByte();
6433      const nextByte = stream.getByte();
6434      this.buffer = nextByte & (1 << bufferLength) - 1;
6435      return (buffer << 8 - bufferLength | (nextByte & 0xff) >> bufferLength) >>> 0;
6436    }
6437    if (n === 8 && bufferLength === 0) {
6438      return stream.getByte();
6439    }
6440    while (bufferLength < n) {
6441      buffer = buffer << 8 | stream.getByte();
6442      bufferLength += 8;
6443    }
6444    bufferLength -= n;
6445    this.bufferLength = bufferLength;
6446    this.buffer = buffer & (1 << bufferLength) - 1;
6447    return buffer >> bufferLength;
6448  }
6449  align() {
6450    this.buffer = 0;
6451    this.bufferLength = 0;
6452  }
6453  readFlag() {
6454    return this.readBits(this.context.bitsPerFlag);
6455  }
6456  readCoordinate() {
6457    const {
6458      bitsPerCoordinate,
6459      decode
6460    } = this.context;
6461    const xi = this.readBits(bitsPerCoordinate);
6462    const yi = this.readBits(bitsPerCoordinate);
6463    const scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
6464    return [xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2]];
6465  }
6466  readComponents() {
6467    const {
6468      bitsPerComponent,
6469      colorFn,
6470      colorSpace,
6471      decode,
6472      numComps
6473    } = this.context;
6474    const scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
6475    const components = this.tmpCompsBuf;
6476    for (let i = 0, j = 4; i < numComps; i++, j += 2) {
6477      const ci = this.readBits(bitsPerComponent);
6478      components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
6479    }
6480    const color = this.tmpCsCompsBuf;
6481    colorFn?.(components, 0, color, 0);
6482    return colorSpace.getRgb(color, 0);
6483  }
6484}
6485let bCache = Object.create(null);
6486function buildB(count) {
6487  const lut = [];
6488  for (let i = 0; i <= count; i++) {
6489    const t = i / count,
6490      t_ = 1 - t;
6491    lut.push(new Float32Array([t_ ** 3, 3 * t * t_ ** 2, 3 * t ** 2 * t_, t ** 3]));
6492  }
6493  return lut;
6494}
6495function getB(count) {
6496  return bCache[count] ||= buildB(count);
6497}
6498function clearPatternCaches() {
6499  bCache = Object.create(null
vendor: 178,011 bytes, lines 6499-9194
6499);
6500}
6501class MeshShading extends BaseShading {
6502  static MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
6503  static MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
6504  static TRIANGLE_DENSITY = 20;
6505  constructor(stream, xref, resources, pdfFunctionFactory, globalColorSpaceCache, localColorSpaceCache) {
6506    super();
6507    if (!(stream instanceof BaseStream)) {
6508      throw new FormatError("Mesh data is not a stream");
6509    }
6510    const dict = stream.dict;
6511    this.shadingType = dict.get("ShadingType");
6512    this.bbox = lookupNormalRect(dict.getArray("BBox"), null);
6513    const cs = ColorSpaceUtils.parse({
6514      cs: dict.getRaw("CS") || dict.getRaw("ColorSpace"),
6515      xref,
6516      resources,
6517      pdfFunctionFactory,
6518      globalColorSpaceCache,
6519      localColorSpaceCache
6520    });
6521    this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
6522    const fnObj = dict.getRaw("Function");
6523    const fn = fnObj ? pdfFunctionFactory.create(fnObj, true) : null;
6524    this.coords = [];
6525    this.colors = [];
6526    this.figures = [];
6527    const decodeContext = {
6528      bitsPerCoordinate: dict.get("BitsPerCoordinate"),
6529      bitsPerComponent: dict.get("BitsPerComponent"),
6530      bitsPerFlag: dict.get("BitsPerFlag"),
6531      decode: dict.getArray("Decode"),
6532      colorFn: fn,
6533      colorSpace: cs,
6534      numComps: fn ? 1 : cs.numComps
6535    };
6536    const reader = new MeshStreamReader(stream, decodeContext);
6537    let patchMesh = false;
6538    switch (this.shadingType) {
6539      case ShadingType.FREE_FORM_MESH:
6540        this._decodeType4Shading(reader);
6541        break;
6542      case ShadingType.LATTICE_FORM_MESH:
6543        const verticesPerRow = dict.get("VerticesPerRow") | 0;
6544        if (verticesPerRow < 2) {
6545          throw new FormatError("Invalid VerticesPerRow");
6546        }
6547        this._decodeType5Shading(reader, verticesPerRow);
6548        break;
6549      case ShadingType.COONS_PATCH_MESH:
6550        this._decodeType6Shading(reader);
6551        patchMesh = true;
6552        break;
6553      case ShadingType.TENSOR_PATCH_MESH:
6554        this._decodeType7Shading(reader);
6555        patchMesh = true;
6556        break;
6557      default:
6558        unreachable("Unsupported mesh type.");
6559        break;
6560    }
6561    if (patchMesh) {
6562      this._updateBounds();
6563      for (let i = 0, ii = this.figures.length; i < ii; i++) {
6564        this._buildFigureFromPatch(i);
6565      }
6566    }
6567    this._updateBounds();
6568    this._packData();
6569  }
6570  _decodeType4Shading(reader) {
6571    const coords = this.coords;
6572    const colors = this.colors;
6573    const operators = [];
6574    const ps = [];
6575    let verticesLeft = 0;
6576    while (reader.hasData) {
6577      const f = reader.readFlag();
6578      const coord = reader.readCoordinate();
6579      const color = reader.readComponents();
6580      if (verticesLeft === 0) {
6581        if (!(0 <= f && f <= 2)) {
6582          throw new FormatError("Unknown type4 flag");
6583        }
6584        switch (f) {
6585          case 0:
6586            verticesLeft = 3;
6587            break;
6588          case 1:
6589            ps.push(ps.at(-2), ps.at(-1));
6590            verticesLeft = 1;
6591            break;
6592          case 2:
6593            ps.push(ps.at(-3), ps.at(-1));
6594            verticesLeft = 1;
6595            break;
6596        }
6597        operators.push(f);
6598      }
6599      ps.push(coords.length);
6600      coords.push(coord);
6601      colors.push(color);
6602      verticesLeft--;
6603      reader.align();
6604    }
6605    this.figures.push({
6606      type: MeshFigureType.TRIANGLES,
6607      coords: new Int32Array(ps),
6608      colors: new Int32Array(ps)
6609    });
6610  }
6611  _decodeType5Shading(reader, verticesPerRow) {
6612    const coords = this.coords;
6613    const colors = this.colors;
6614    const ps = [];
6615    while (reader.hasData) {
6616      const coord = reader.readCoordinate();
6617      const color = reader.readComponents();
6618      ps.push(coords.length);
6619      coords.push(coord);
6620      colors.push(color);
6621    }
6622    this.figures.push({
6623      type: MeshFigureType.LATTICE,
6624      coords: new Int32Array(ps),
6625      colors: new Int32Array(ps),
6626      verticesPerRow
6627    });
6628  }
6629  _decodeType6Shading(reader) {
6630    const coords = this.coords;
6631    const colors = this.colors;
6632    const ps = new Int32Array(16);
6633    const cs = new Int32Array(4);
6634    while (reader.hasData) {
6635      const f = reader.readFlag();
6636      if (!(0 <= f && f <= 3)) {
6637        throw new FormatError("Unknown type6 flag");
6638      }
6639      const pi = coords.length;
6640      for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
6641        coords.push(reader.readCoordinate());
6642      }
6643      const ci = colors.length;
6644      for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
6645        colors.push(reader.readComponents());
6646      }
6647      let tmp1, tmp2, tmp3, tmp4;
6648      switch (f) {
6649        case 0:
6650          ps[12] = pi + 3;
6651          ps[13] = pi + 4;
6652          ps[14] = pi + 5;
6653          ps[15] = pi + 6;
6654          ps[8] = pi + 2;
6655          ps[11] = pi + 7;
6656          ps[4] = pi + 1;
6657          ps[7] = pi + 8;
6658          ps[0] = pi;
6659          ps[1] = pi + 11;
6660          ps[2] = pi + 10;
6661          ps[3] = pi + 9;
6662          cs[2] = ci + 1;
6663          cs[3] = ci + 2;
6664          cs[0] = ci;
6665          cs[1] = ci + 3;
6666          break;
6667        case 1:
6668          tmp1 = ps[12];
6669          tmp2 = ps[13];
6670          tmp3 = ps[14];
6671          tmp4 = ps[15];
6672          ps[12] = tmp4;
6673          ps[13] = pi + 0;
6674          ps[14] = pi + 1;
6675          ps[15] = pi + 2;
6676          ps[8] = tmp3;
6677          ps[11] = pi + 3;
6678          ps[4] = tmp2;
6679          ps[7] = pi + 4;
6680          ps[0] = tmp1;
6681          ps[1] = pi + 7;
6682          ps[2] = pi + 6;
6683          ps[3] = pi + 5;
6684          tmp1 = cs[2];
6685          tmp2 = cs[3];
6686          cs[2] = tmp2;
6687          cs[3] = ci;
6688          cs[0] = tmp1;
6689          cs[1] = ci + 1;
6690          break;
6691        case 2:
6692          tmp1 = ps[15];
6693          tmp2 = ps[11];
6694          ps[12] = ps[3];
6695          ps[13] = pi + 0;
6696          ps[14] = pi + 1;
6697          ps[15] = pi + 2;
6698          ps[8] = ps[7];
6699          ps[11] = pi + 3;
6700          ps[4] = tmp2;
6701          ps[7] = pi + 4;
6702          ps[0] = tmp1;
6703          ps[1] = pi + 7;
6704          ps[2] = pi + 6;
6705          ps[3] = pi + 5;
6706          tmp1 = cs[3];
6707          cs[2] = cs[1];
6708          cs[3] = ci;
6709          cs[0] = tmp1;
6710          cs[1] = ci + 1;
6711          break;
6712        case 3:
6713          ps[12] = ps[0];
6714          ps[13] = pi + 0;
6715          ps[14] = pi + 1;
6716          ps[15] = pi + 2;
6717          ps[8] = ps[1];
6718          ps[11] = pi + 3;
6719          ps[4] = ps[2];
6720          ps[7] = pi + 4;
6721          ps[0] = ps[3];
6722          ps[1] = pi + 7;
6723          ps[2] = pi + 6;
6724          ps[3] = pi + 5;
6725          cs[2] = cs[0];
6726          cs[3] = ci;
6727          cs[0] = cs[1];
6728          cs[1] = ci + 1;
6729          break;
6730      }
6731      ps[5] = coords.length;
6732      coords.push([(-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9, (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9]);
6733      ps[6] = coords.length;
6734      coords.push([(-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9, (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9]);
6735      ps[9] = coords.length;
6736      coords.push([(-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9, (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9]);
6737      ps[10] = coords.length;
6738      coords.push([(-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9, (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9]);
6739      this.figures.push({
6740        type: MeshFigureType.PATCH,
6741        coords: new Int32Array(ps),
6742        colors: new Int32Array(cs)
6743      });
6744    }
6745  }
6746  _decodeType7Shading(reader) {
6747    const coords = this.coords;
6748    const colors = this.colors;
6749    const ps = new Int32Array(16);
6750    const cs = new Int32Array(4);
6751    while (reader.hasData) {
6752      const f = reader.readFlag();
6753      if (!(0 <= f && f <= 3)) {
6754        throw new FormatError("Unknown type7 flag");
6755      }
6756      const pi = coords.length;
6757      for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
6758        coords.push(reader.readCoordinate());
6759      }
6760      const ci = colors.length;
6761      for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
6762        colors.push(reader.readComponents());
6763      }
6764      let tmp1, tmp2, tmp3, tmp4;
6765      switch (f) {
6766        case 0:
6767          ps[12] = pi + 3;
6768          ps[13] = pi + 4;
6769          ps[14] = pi + 5;
6770          ps[15] = pi + 6;
6771          ps[8] = pi + 2;
6772          ps[9] = pi + 13;
6773          ps[10] = pi + 14;
6774          ps[11] = pi + 7;
6775          ps[4] = pi + 1;
6776          ps[5] = pi + 12;
6777          ps[6] = pi + 15;
6778          ps[7] = pi + 8;
6779          ps[0] = pi;
6780          ps[1] = pi + 11;
6781          ps[2] = pi + 10;
6782          ps[3] = pi + 9;
6783          cs[2] = ci + 1;
6784          cs[3] = ci + 2;
6785          cs[0] = ci;
6786          cs[1] = ci + 3;
6787          break;
6788        case 1:
6789          tmp1 = ps[12];
6790          tmp2 = ps[13];
6791          tmp3 = ps[14];
6792          tmp4 = ps[15];
6793          ps[12] = tmp4;
6794          ps[13] = pi + 0;
6795          ps[14] = pi + 1;
6796          ps[15] = pi + 2;
6797          ps[8] = tmp3;
6798          ps[9] = pi + 9;
6799          ps[10] = pi + 10;
6800          ps[11] = pi + 3;
6801          ps[4] = tmp2;
6802          ps[5] = pi + 8;
6803          ps[6] = pi + 11;
6804          ps[7] = pi + 4;
6805          ps[0] = tmp1;
6806          ps[1] = pi + 7;
6807          ps[2] = pi + 6;
6808          ps[3] = pi + 5;
6809          tmp1 = cs[2];
6810          tmp2 = cs[3];
6811          cs[2] = tmp2;
6812          cs[3] = ci;
6813          cs[0] = tmp1;
6814          cs[1] = ci + 1;
6815          break;
6816        case 2:
6817          tmp1 = ps[15];
6818          tmp2 = ps[11];
6819          ps[12] = ps[3];
6820          ps[13] = pi + 0;
6821          ps[14] = pi + 1;
6822          ps[15] = pi + 2;
6823          ps[8] = ps[7];
6824          ps[9] = pi + 9;
6825          ps[10] = pi + 10;
6826          ps[11] = pi + 3;
6827          ps[4] = tmp2;
6828          ps[5] = pi + 8;
6829          ps[6] = pi + 11;
6830          ps[7] = pi + 4;
6831          ps[0] = tmp1;
6832          ps[1] = pi + 7;
6833          ps[2] = pi + 6;
6834          ps[3] = pi + 5;
6835          tmp1 = cs[3];
6836          cs[2] = cs[1];
6837          cs[3] = ci;
6838          cs[0] = tmp1;
6839          cs[1] = ci + 1;
6840          break;
6841        case 3:
6842          ps[12] = ps[0];
6843          ps[13] = pi + 0;
6844          ps[14] = pi + 1;
6845          ps[15] = pi + 2;
6846          ps[8] = ps[1];
6847          ps[9] = pi + 9;
6848          ps[10] = pi + 10;
6849          ps[11] = pi + 3;
6850          ps[4] = ps[2];
6851          ps[5] = pi + 8;
6852          ps[6] = pi + 11;
6853          ps[7] = pi + 4;
6854          ps[0] = ps[3];
6855          ps[1] = pi + 7;
6856          ps[2] = pi + 6;
6857          ps[3] = pi + 5;
6858          cs[2] = cs[0];
6859          cs[3] = ci;
6860          cs[0] = cs[1];
6861          cs[1] = ci + 1;
6862          break;
6863      }
6864      this.figures.push({
6865        type: MeshFigureType.PATCH,
6866        coords: new Int32Array(ps),
6867        colors: new Int32Array(cs)
6868      });
6869    }
6870  }
6871  _buildFigureFromPatch(index) {
6872    const figure = this.figures[index];
6873    assert(figure.type === MeshFigureType.PATCH, "Unexpected patch mesh figure");
6874    const coords = this.coords,
6875      colors = this.colors;
6876    const pi = figure.coords;
6877    const ci = figure.colors;
6878    const figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
6879    const figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
6880    const figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
6881    const figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
6882    let splitXBy = Math.ceil((figureMaxX - figureMinX) * MeshShading.TRIANGLE_DENSITY / (this.bounds[2] - this.bounds[0]));
6883    splitXBy = MathClamp(splitXBy, MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT);
6884    let splitYBy = Math.ceil((figureMaxY - figureMinY) * MeshShading.TRIANGLE_DENSITY / (this.bounds[3] - this.bounds[1]));
6885    splitYBy = MathClamp(splitYBy, MeshShading.MIN_SPLIT_PATCH_CHUNKS_AMOUNT, MeshShading.MAX_SPLIT_PATCH_CHUNKS_AMOUNT);
6886    const verticesPerRow = splitXBy + 1;
6887    const figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
6888    const figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
6889    let k = 0;
6890    const cl = new Uint8Array(3),
6891      cr = new Uint8Array(3);
6892    const c0 = colors[ci[0]],
6893      c1 = colors[ci[1]],
6894      c2 = colors[ci[2]],
6895      c3 = colors[ci[3]];
6896    const bRow = getB(splitYBy),
6897      bCol = getB(splitXBy);
6898    for (let row = 0; row <= splitYBy; row++) {
6899      cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
6900      cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
6901      cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
6902      cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
6903      cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
6904      cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
6905      for (let col = 0; col <= splitXBy; col++, k++) {
6906        if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
6907          continue;
6908        }
6909        let x = 0,
6910          y = 0;
6911        let q = 0;
6912        for (let i = 0; i <= 3; i++) {
6913          for (let j = 0; j <= 3; j++, q++) {
6914            const m = bRow[row][i] * bCol[col][j];
6915            x += coords[pi[q]][0] * m;
6916            y += coords[pi[q]][1] * m;
6917          }
6918        }
6919        figureCoords[k] = coords.length;
6920        coords.push([x, y]);
6921        figureColors[k] = colors.length;
6922        const newColor = new Uint8Array(3);
6923        newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
6924        newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
6925        newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
6926        colors.push(newColor);
6927      }
6928    }
6929    figureCoords[0] = pi[0];
6930    figureColors[0] = ci[0];
6931    figureCoords[splitXBy] = pi[3];
6932    figureColors[splitXBy] = ci[1];
6933    figureCoords[verticesPerRow * splitYBy] = pi[12];
6934    figureColors[verticesPerRow * splitYBy] = ci[2];
6935    figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
6936    figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
6937    this.figures[index] = {
6938      type: MeshFigureType.LATTICE,
6939      coords: figureCoords,
6940      colors: figureColors,
6941      verticesPerRow
6942    };
6943  }
6944  _updateBounds() {
6945    meshUpdateBounds(this);
6946  }
6947  _packData() {
6948    meshPackData(this);
6949  }
6950  getIR() {
6951    const {
6952      posData,
6953      colData,
6954      vertexCount
6955    } = buildMeshVertexData(this.coords, this.colors, this.figures);
6956    return ["Mesh", this.shadingType, posData, colData, vertexCount, this.bounds, this.bbox, this.background];
6957  }
6958}
6959class DummyShading extends BaseShading {
6960  getIR() {
6961    return ["Dummy"];
6962  }
6963}
6964function getTilingPatternIR(operatorList, dict, color, needsIsolation = true) {
6965  const matrix = lookupMatrix(dict.getArray("Matrix"), IDENTITY_MATRIX);
6966  const bbox = lookupNormalRect(dict.getArray("BBox"), null);
6967  if (!bbox || bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
6968    throw new FormatError(`Invalid getTilingPatternIR /BBox array.`);
6969  }
6970  const xstep = dict.get("XStep");
6971  if (typeof xstep !== "number") {
6972    throw new FormatError(`Invalid getTilingPatternIR /XStep value.`);
6973  }
6974  const ystep = dict.get("YStep");
6975  if (typeof ystep !== "number") {
6976    throw new FormatError(`Invalid getTilingPatternIR /YStep value.`);
6977  }
6978  const paintType = dict.get("PaintType");
6979  if (!Number.isInteger(paintType)) {
6980    throw new FormatError(`Invalid getTilingPatternIR /PaintType value.`);
6981  }
6982  const tilingType = dict.get("TilingType");
6983  if (!Number.isInteger(tilingType)) {
6984    throw new FormatError(`Invalid getTilingPatternIR /TilingType value.`);
6985  }
6986  return ["TilingPattern", color, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType, needsIsolation];
6987}
6988
6989;// ./src/core/binary_cmap.js
6990
6991
6992function hexToInt(a, size) {
6993  let n = 0;
6994  for (let i = 0; i <= size; i++) {
6995    n = n << 8 | a[i];
6996  }
6997  return n >>> 0;
6998}
6999function hexToStr(a, size) {
7000  if (size === 1) {
7001    return String.fromCharCode(a[0], a[1]);
7002  }
7003  if (size === 3) {
7004    return String.fromCharCode(a[0], a[1], a[2], a[3]);
7005  }
7006  return String.fromCharCode(...a.subarray(0, size + 1));
7007}
7008function addHex(a, b, size) {
7009  let c = 0;
7010  for (let i = size; i >= 0; i--) {
7011    c += a[i] + b[i];
7012    a[i] = c & 255;
7013    c >>= 8;
7014  }
7015}
7016function incHex(a, size) {
7017  let c = 1;
7018  for (let i = size; i >= 0 && c > 0; i--) {
7019    c += a[i];
7020    a[i] = c & 255;
7021    c >>= 8;
7022  }
7023}
7024const MAX_NUM_SIZE = 16;
7025const MAX_ENCODED_NUM_SIZE = 19;
7026class BinaryCMapStream extends Stream {
7027  tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
7028  constructor(data) {
7029    super(data, 0, data.length, null);
7030  }
7031  readNumber() {
7032    let n = 0;
7033    let last;
7034    do {
7035      const b = this.getByte();
7036      if (b < 0) {
7037        throw new FormatError("unexpected EOF in bcmap");
7038      }
7039      last = !(b & 0x80);
7040      n = n << 7 | b & 0x7f;
7041    } while (!last);
7042    return n;
7043  }
7044  readSigned() {
7045    const n = this.readNumber();
7046    return n & 1 ? ~(n >>> 1) : n >>> 1;
7047  }
7048  readHex(num, size) {
7049    num.set(this.getBytes(size + 1));
7050  }
7051  readHexNumber(num, size) {
7052    let last;
7053    const stack = this.tmpBuf;
7054    let sp = 0;
7055    do {
7056      const b = this.getByte();
7057      if (b < 0) {
7058        throw new FormatError("unexpected EOF in bcmap");
7059      }
7060      last = !(b & 0x80);
7061      stack[sp++] = b & 0x7f;
7062    } while (!last);
7063    let i = size,
7064      buffer = 0,
7065      bufferSize = 0;
7066    while (i >= 0) {
7067      while (bufferSize < 8 && stack.length > 0) {
7068        buffer |= stack[--sp] << bufferSize;
7069        bufferSize += 7;
7070      }
7071      num[i] = buffer & 255;
7072      i--;
7073      buffer >>= 8;
7074      bufferSize -= 8;
7075    }
7076  }
7077  readHexSigned(num, size) {
7078    this.readHexNumber(num, size);
7079    const sign = num[size] & 1 ? 255 : 0;
7080    let c = 0;
7081    for (let i = 0; i <= size; i++) {
7082      c = (c & 1) << 8 | num[i];
7083      num[i] = c >> 1 ^ sign;
7084    }
7085  }
7086  readString() {
7087    const len = this.readNumber(),
7088      buf = new Array(len);
7089    for (let i = 0; i < len; i++) {
7090      buf[i] = this.readNumber();
7091    }
7092    return String.fromCharCode(...buf);
7093  }
7094}
7095class BinaryCMapReader {
7096  async process(data, cMap, extend) {
7097    const stream = new BinaryCMapStream(data);
7098    const header = stream.getByte();
7099    cMap.vertical = !!(header & 1);
7100    let useCMap = null;
7101    const start = new Uint8Array(MAX_NUM_SIZE);
7102    const end = new Uint8Array(MAX_NUM_SIZE);
7103    const char = new Uint8Array(MAX_NUM_SIZE);
7104    const charCode = new Uint8Array(MAX_NUM_SIZE);
7105    const tmp = new Uint8Array(MAX_NUM_SIZE);
7106    let code;
7107    let b;
7108    while ((b = stream.getByte()) >= 0) {
7109      const type = b >> 5;
7110      if (type === 7) {
7111        switch (b & 0x1f) {
7112          case 0:
7113            stream.readString();
7114            break;
7115          case 1:
7116            useCMap = stream.readString();
7117            break;
7118        }
7119        continue;
7120      }
7121      const sequence = !!(b & 0x10);
7122      const dataSize = b & 15;
7123      if (dataSize + 1 > MAX_NUM_SIZE) {
7124        throw new Error("BinaryCMapReader.process: Invalid dataSize.");
7125      }
7126      const ucs2DataSize = 1;
7127      const subitemsCount = stream.readNumber();
7128      switch (type) {
7129        case 0:
7130          stream.readHex(start, dataSize);
7131          stream.readHexNumber(end, dataSize);
7132          addHex(end, start, dataSize);
7133          cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
7134          for (let i = 1; i < subitemsCount; i++) {
7135            incHex(end, dataSize);
7136            stream.readHexNumber(start, dataSize);
7137            addHex(start, end, dataSize);
7138            stream.readHexNumber(end, dataSize);
7139            addHex(end, start, dataSize);
7140            cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
7141          }
7142          break;
7143        case 1:
7144          stream.readHex(start, dataSize);
7145          stream.readHexNumber(end, dataSize);
7146          addHex(end, start, dataSize);
7147          stream.readNumber();
7148          for (let i = 1; i < subitemsCount; i++) {
7149            incHex(end, dataSize);
7150            stream.readHexNumber(start, dataSize);
7151            addHex(start, end, dataSize);
7152            stream.readHexNumber(end, dataSize);
7153            addHex(end, start, dataSize);
7154            stream.readNumber();
7155          }
7156          break;
7157        case 2:
7158          stream.readHex(char, dataSize);
7159          code = stream.readNumber();
7160          cMap.mapOne(hexToInt(char, dataSize), code);
7161          for (let i = 1; i < subitemsCount; i++) {
7162            incHex(char, dataSize);
7163            if (!sequence) {
7164              stream.readHexNumber(tmp, dataSize);
7165              addHex(char, tmp, dataSize);
7166            }
7167            code = stream.readSigned() + (code + 1);
7168            cMap.mapOne(hexToInt(char, dataSize), code);
7169          }
7170          break;
7171        case 3:
7172          stream.readHex(start, dataSize);
7173          stream.readHexNumber(end, dataSize);
7174          addHex(end, start, dataSize);
7175          code = stream.readNumber();
7176          cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
7177          for (let i = 1; i < subitemsCount; i++) {
7178            incHex(end, dataSize);
7179            if (!sequence) {
7180              stream.readHexNumber(start, dataSize);
7181              addHex(start, end, dataSize);
7182            } else {
7183              start.set(end);
7184            }
7185            stream.readHexNumber(end, dataSize);
7186            addHex(end, start, dataSize);
7187            code = stream.readNumber();
7188            cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
7189          }
7190          break;
7191        case 4:
7192          stream.readHex(char, ucs2DataSize);
7193          stream.readHex(charCode, dataSize);
7194          cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
7195          for (let i = 1; i < subitemsCount; i++) {
7196            incHex(char, ucs2DataSize);
7197            if (!sequence) {
7198              stream.readHexNumber(tmp, ucs2DataSize);
7199              addHex(char, tmp, ucs2DataSize);
7200            }
7201            incHex(charCode, dataSize);
7202            stream.readHexSigned(tmp, dataSize);
7203            addHex(charCode, tmp, dataSize);
7204            cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
7205          }
7206          break;
7207        case 5:
7208          stream.readHex(start, ucs2DataSize);
7209          stream.readHexNumber(end, ucs2DataSize);
7210          addHex(end, start, ucs2DataSize);
7211          stream.readHex(charCode, dataSize);
7212          cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
7213          for (let i = 1; i < subitemsCount; i++) {
7214            incHex(end, ucs2DataSize);
7215            if (!sequence) {
7216              stream.readHexNumber(start, ucs2DataSize);
7217              addHex(start, end, ucs2DataSize);
7218            } else {
7219              start.set(end);
7220            }
7221            stream.readHexNumber(end, ucs2DataSize);
7222            addHex(end, start, ucs2DataSize);
7223            stream.readHex(charCode, dataSize);
7224            cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
7225          }
7226          break;
7227        default:
7228          throw new Error(`BinaryCMapReader.process - unknown type: ${type}`);
7229      }
7230    }
7231    if (useCMap) {
7232      return extend(useCMap);
7233    }
7234    return cMap;
7235  }
7236}
7237
7238;// ./src/core/ascii_85_stream.js
7239
7240
7241class Ascii85Stream extends DecodeStream {
7242  #input = new Uint8Array(5);
7243  constructor(str, maybeLength) {
7244    if (maybeLength) {
7245      maybeLength *= 0.8;
7246    }
7247    super(maybeLength);
7248    this.stream = str;
7249    this.dict = str.dict;
7250  }
7251  readBlock() {
7252    const TILDA_CHAR = 0x7e;
7253    const Z_LOWER_CHAR = 0x7a;
7254    const EOF = -1;
7255    const str = this.stream;
7256    let c = str.getByte();
7257    while (isWhiteSpace(c)) {
7258      c = str.getByte();
7259    }
7260    if (c === EOF || c === TILDA_CHAR) {
7261      this.eof = true;
7262      return;
7263    }
7264    const bufferLength = this.bufferLength;
7265    let buffer, i;
7266    if (c === Z_LOWER_CHAR) {
7267      buffer = this.ensureBuffer(bufferLength + 4);
7268      buffer.fill(0, bufferLength, bufferLength + 4);
7269      this.bufferLength += 4;
7270    } else {
7271      const input = this.#input;
7272      input[0] = c;
7273      for (i = 1; i < 5; ++i) {
7274        c = str.getByte();
7275        while (isWhiteSpace(c)) {
7276          c = str.getByte();
7277        }
7278        input[i] = c;
7279        if (c === EOF || c === TILDA_CHAR) {
7280          break;
7281        }
7282      }
7283      buffer = this.ensureBuffer(bufferLength + i - 1);
7284      this.bufferLength += i - 1;
7285      if (i < 5) {
7286        input.fill(0x21 + 84, i, 5);
7287        this.eof = true;
7288      }
7289      let t = 0;
7290      for (i = 0; i < 5; ++i) {
7291        t = t * 85 + (input[i] - 0x21);
7292      }
7293      for (i = 3; i >= 0; --i) {
7294        buffer[bufferLength + i] = t & 0xff;
7295        t >>= 8;
7296      }
7297    }
7298  }
7299}
7300
7301;// ./src/core/ascii_hex_stream.js
7302
7303class AsciiHexStream extends DecodeStream {
7304  constructor(str, maybeLength) {
7305    if (maybeLength) {
7306      maybeLength *= 0.5;
7307    }
7308    super(maybeLength);
7309    this.stream = str;
7310    this.dict = str.dict;
7311    this.firstDigit = -1;
7312  }
7313  readBlock() {
7314    const UPSTREAM_BLOCK_SIZE = 8000;
7315    const bytes = this.stream.getBytes(UPSTREAM_BLOCK_SIZE);
7316    if (!bytes.length) {
7317      this.eof = true;
7318      return;
7319    }
7320    const maxDecodeLength = bytes.length + 1 >> 1;
7321    const buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
7322    let bufferLength = this.bufferLength;
7323    let firstDigit = this.firstDigit;
7324    for (const ch of bytes) {
7325      let digit;
7326      if (ch >= 0x30 && ch <= 0x39) {
7327        digit = ch & 0x0f;
7328      } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
7329        digit = (ch & 0x0f) + 9;
7330      } else if (ch === 0x3e) {
7331        this.eof = true;
7332        break;
7333      } else {
7334        continue;
7335      }
7336      if (firstDigit < 0) {
7337        firstDigit = digit;
7338      } else {
7339        buffer[bufferLength++] = firstDigit << 4 | digit;
7340        firstDigit = -1;
7341      }
7342    }
7343    if (firstDigit >= 0 && this.eof) {
7344      buffer[bufferLength++] = firstDigit << 4;
7345      firstDigit = -1;
7346    }
7347    this.firstDigit = firstDigit;
7348    this.bufferLength = bufferLength;
7349  }
7350}
7351
7352;// ./external/brotli/decode.js
7353let Options;
7354let makeBrotliDecode = () => {
7355  const MAX_HUFFMAN_TABLE_SIZE = Int32Array.from([256, 402, 436, 468, 500, 534, 566, 598, 630, 662, 694, 726, 758, 790, 822, 854, 886, 920, 952, 984, 1016, 1048, 1080]);
7356  const CODE_LENGTH_CODE_ORDER = Int32Array.from([1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
7357  const DISTANCE_SHORT_CODE_INDEX_OFFSET = Int32Array.from([0, 3, 2, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3]);
7358  const DISTANCE_SHORT_CODE_VALUE_OFFSET = Int32Array.from([0, 0, 0, 0, -1, 1, -2, 2, -3, 3, -1, 1, -2, 2, -3, 3]);
7359  const FIXED_TABLE = Int32Array.from([0x020000, 0x020004, 0x020003, 0x030002, 0x020000, 0x020004, 0x020003, 0x040001, 0x020000, 0x020004, 0x020003, 0x030002, 0x020000, 0x020004, 0x020003, 0x040005]);
7360  const BLOCK_LENGTH_OFFSET = Int32Array.from([1, 5, 9, 13, 17, 25, 33, 41, 49, 65, 81, 97, 113, 145, 177, 209, 241, 305, 369, 497, 753, 1265, 2289, 4337, 8433, 16625]);
7361  const BLOCK_LENGTH_N_BITS = Int32Array.from([2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 24]);
7362  const INSERT_LENGTH_N_BITS = Int16Array.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0C, 0x0E, 0x18]);
7363  const COPY_LENGTH_N_BITS = Int16Array.from([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x18]);
7364  const CMD_LOOKUP = new Int16Array(2816);
7365  unpackCommandLookupTable(CMD_LOOKUP);
7366  function log2floor(i) {
7367    let result = -1;
7368    let step = 16;
7369    let v = i;
7370    while (step > 0) {
7371      let next = v >> step;
7372      if (next !== 0) {
7373        result += step;
7374        v = next;
7375      }
7376      step = step >> 1;
7377    }
7378    return result + v;
7379  }
7380  function calculateDistanceAlphabetSize(npostfix, ndirect, maxndistbits) {
7381    return 16 + ndirect + 2 * (maxndistbits << npostfix);
7382  }
7383  function calculateDistanceAlphabetLimit(s, maxDistance, npostfix, ndirect) {
7384    if (maxDistance < ndirect + (2 << npostfix)) {
7385      return makeError(s, -23);
7386    }
7387    const offset = (maxDistance - ndirect >> npostfix) + 4;
7388    const ndistbits = log2floor(offset) - 1;
7389    const group = ndistbits - 1 << 1 | offset >> ndistbits & 1;
7390    return (group - 1 << npostfix) + (1 << npostfix) + ndirect + 16;
7391  }
7392  function unpackCommandLookupTable(cmdLookup) {
7393    const insertLengthOffsets = new Int32Array(24);
7394    const copyLengthOffsets = new Int32Array(24);
7395    copyLengthOffsets[0] = 2;
7396    for (let i = 0; i < 23; ++i) {
7397      insertLengthOffsets[i + 1] = insertLengthOffsets[i] + (1 << INSERT_LENGTH_N_BITS[i]);
7398      copyLengthOffsets[i + 1] = copyLengthOffsets[i] + (1 << COPY_LENGTH_N_BITS[i]);
7399    }
7400    for (let cmdCode = 0; cmdCode < 704; ++cmdCode) {
7401      let rangeIdx = cmdCode >> 6;
7402      let distanceContextOffset = -4;
7403      if (rangeIdx >= 2) {
7404        rangeIdx -= 2;
7405        distanceContextOffset = 0;
7406      }
7407      const insertCode = (0x29850 >> rangeIdx * 2 & 0x3) << 3 | cmdCode >> 3 & 7;
7408      const copyCode = (0x26244 >> rangeIdx * 2 & 0x3) << 3 | cmdCode & 7;
7409      const copyLengthOffset = copyLengthOffsets[copyCode];
7410      const distanceContext = distanceContextOffset + Math.min(copyLengthOffset, 5) - 2;
7411      const index = cmdCode * 4;
7412      cmdLookup[index] = INSERT_LENGTH_N_BITS[insertCode] | COPY_LENGTH_N_BITS[copyCode] << 8;
7413      cmdLookup[index + 1] = insertLengthOffsets[insertCode];
7414      cmdLookup[index + 2] = copyLengthOffsets[copyCode];
7415      cmdLookup[index + 3] = distanceContext;
7416    }
7417  }
7418  function decodeWindowBits(s) {
7419    const largeWindowEnabled = s.isLargeWindow;
7420    s.isLargeWindow = 0;
7421    if (s.bitOffset >= 16) {
7422      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7423      s.bitOffset -= 16;
7424    }
7425    if (readFewBits(s, 1) === 0) {
7426      return 16;
7427    }
7428    let n = readFewBits(s, 3);
7429    if (n !== 0) {
7430      return 17 + n;
7431    }
7432    n = readFewBits(s, 3);
7433    if (n !== 0) {
7434      if (n === 1) {
7435        if (largeWindowEnabled === 0) {
7436          return -1;
7437        }
7438        s.isLargeWindow = 1;
7439        if (readFewBits(s, 1) === 1) {
7440          return -1;
7441        }
7442        n = readFewBits(s, 6);
7443        if (n < 10 || n > 30) {
7444          return -1;
7445        }
7446        return n;
7447      }
7448      return 8 + n;
7449    }
7450    return 17;
7451  }
7452  function attachDictionaryChunk(s, data) {
7453    if (s.runningState !== 1) {
7454      return makeError(s, -24);
7455    }
7456    if (s.cdNumChunks === 0) {
7457      s.cdChunks = new Array(16);
7458      s.cdChunkOffsets = new Int32Array(16);
7459      s.cdBlockBits = -1;
7460    }
7461    if (s.cdNumChunks === 15) {
7462      return makeError(s, -27);
7463    }
7464    s.cdChunks[s.cdNumChunks] = data;
7465    s.cdNumChunks++;
7466    s.cdTotalSize += data.length;
7467    s.cdChunkOffsets[s.cdNumChunks] = s.cdTotalSize;
7468    return 0;
7469  }
7470  function initState(s) {
7471    if (s.runningState !== 0) {
7472      return makeError(s, -26);
7473    }
7474    s.blockTrees = new Int32Array(3091);
7475    s.blockTrees[0] = 7;
7476    s.distRbIdx = 3;
7477    let result = calculateDistanceAlphabetLimit(s, 0x7FFFFFFC, 3, 120);
7478    if (result < 0) {
7479      return result;
7480    }
7481    const maxDistanceAlphabetLimit = result;
7482    s.distExtraBits = new Int8Array(maxDistanceAlphabetLimit);
7483    s.distOffset = new Int32Array(maxDistanceAlphabetLimit);
7484    result = initBitReader(s);
7485    if (result < 0) {
7486      return result;
7487    }
7488    s.runningState = 1;
7489    return 0;
7490  }
7491  function close(s) {
7492    if (s.runningState === 0) {
7493      return makeError(s, -25);
7494    }
7495    if (s.runningState > 0) {
7496      s.runningState = 11;
7497    }
7498    return 0;
7499  }
7500  function decodeVarLenUnsignedByte(s) {
7501    if (s.bitOffset >= 16) {
7502      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7503      s.bitOffset -= 16;
7504    }
7505    if (readFewBits(s, 1) !== 0) {
7506      const n = readFewBits(s, 3);
7507      if (n === 0) {
7508        return 1;
7509      }
7510      return readFewBits(s, n) + (1 << n);
7511    }
7512    return 0;
7513  }
7514  function decodeMetaBlockLength(s) {
7515    if (s.bitOffset >= 16) {
7516      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7517      s.bitOffset -= 16;
7518    }
7519    s.inputEnd = readFewBits(s, 1);
7520    s.metaBlockLength = 0;
7521    s.isUncompressed = 0;
7522    s.isMetadata = 0;
7523    if (s.inputEnd !== 0 && readFewBits(s, 1) !== 0) {
7524      return 0;
7525    }
7526    const sizeNibbles = readFewBits(s, 2) + 4;
7527    if (sizeNibbles === 7) {
7528      s.isMetadata = 1;
7529      if (readFewBits(s, 1) !== 0) {
7530        return makeError(s, -6);
7531      }
7532      const sizeBytes = readFewBits(s, 2);
7533      if (sizeBytes === 0) {
7534        return 0;
7535      }
7536      for (let i = 0; i < sizeBytes; ++i) {
7537        if (s.bitOffset >= 16) {
7538          s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7539          s.bitOffset -= 16;
7540        }
7541        const bits = readFewBits(s, 8);
7542        if (bits === 0 && i + 1 === sizeBytes && sizeBytes > 1) {
7543          return makeError(s, -8);
7544        }
7545        s.metaBlockLength += bits << i * 8;
7546      }
7547    } else {
7548      for (let i = 0; i < sizeNibbles; ++i) {
7549        if (s.bitOffset >= 16) {
7550          s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7551          s.bitOffset -= 16;
7552        }
7553        const bits = readFewBits(s, 4);
7554        if (bits === 0 && i + 1 === sizeNibbles && sizeNibbles > 4) {
7555          return makeError(s, -8);
7556        }
7557        s.metaBlockLength += bits << i * 4;
7558      }
7559    }
7560    s.metaBlockLength++;
7561    if (s.inputEnd === 0) {
7562      s.isUncompressed = readFewBits(s, 1);
7563    }
7564    return 0;
7565  }
7566  function readSymbol(tableGroup, tableIdx, s) {
7567    let offset = tableGroup[tableIdx];
7568    const v = s.accumulator32 >>> s.bitOffset;
7569    offset += v & 0xFF;
7570    const bits = tableGroup[offset] >> 16;
7571    const sym = tableGroup[offset] & 0xFFFF;
7572    if (bits <= 8) {
7573      s.bitOffset += bits;
7574      return sym;
7575    }
7576    offset += sym;
7577    const mask = (1 << bits) - 1;
7578    offset += (v & mask) >>> 8;
7579    s.bitOffset += (tableGroup[offset] >> 16) + 8;
7580    return tableGroup[offset] & 0xFFFF;
7581  }
7582  function readBlockLength(tableGroup, tableIdx, s) {
7583    if (s.bitOffset >= 16) {
7584      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7585      s.bitOffset -= 16;
7586    }
7587    const code = readSymbol(tableGroup, tableIdx, s);
7588    const n = BLOCK_LENGTH_N_BITS[code];
7589    if (s.bitOffset >= 16) {
7590      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7591      s.bitOffset -= 16;
7592    }
7593    return BLOCK_LENGTH_OFFSET[code] + (n <= 16 ? readFewBits(s, n) : readManyBits(s, n));
7594  }
7595  function moveToFront(v, index) {
7596    let i = index;
7597    const value = v[i];
7598    while (i > 0) {
7599      v[i] = v[i - 1];
7600      i--;
7601    }
7602    v[0] = value;
7603  }
7604  function inverseMoveToFrontTransform(v, vLen) {
7605    const mtf = new Int32Array(256);
7606    for (let i = 0; i < 256; ++i) {
7607      mtf[i] = i;
7608    }
7609    for (let i = 0; i < vLen; ++i) {
7610      const index = v[i] & 0xFF;
7611      v[i] = mtf[index];
7612      if (index !== 0) {
7613        moveToFront(mtf, index);
7614      }
7615    }
7616  }
7617  function readHuffmanCodeLengths(codeLengthCodeLengths, numSymbols, codeLengths, s) {
7618    let symbol = 0;
7619    let prevCodeLen = 8;
7620    let repeat = 0;
7621    let repeatCodeLen = 0;
7622    let space = 32768;
7623    const table = new Int32Array(33);
7624    const tableIdx = table.length - 1;
7625    buildHuffmanTable(table, tableIdx, 5, codeLengthCodeLengths, 18);
7626    while (symbol < numSymbols && space > 0) {
7627      if (s.halfOffset > 2030) {
7628        const result = readMoreInput(s);
7629        if (result < 0) {
7630          return result;
7631        }
7632      }
7633      if (s.bitOffset >= 16) {
7634        s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7635        s.bitOffset -= 16;
7636      }
7637      const p = s.accumulator32 >>> s.bitOffset & 31;
7638      s.bitOffset += table[p] >> 16;
7639      const codeLen = table[p] & 0xFFFF;
7640      if (codeLen < 16) {
7641        repeat = 0;
7642        codeLengths[symbol++] = codeLen;
7643        if (codeLen !== 0) {
7644          prevCodeLen = codeLen;
7645          space -= 32768 >> codeLen;
7646        }
7647      } else {
7648        const extraBits = codeLen - 14;
7649        let newLen = 0;
7650        if (codeLen === 16) {
7651          newLen = prevCodeLen;
7652        }
7653        if (repeatCodeLen !== newLen) {
7654          repeat = 0;
7655          repeatCodeLen = newLen;
7656        }
7657        const oldRepeat = repeat;
7658        if (repeat > 0) {
7659          repeat -= 2;
7660          repeat = repeat << extraBits;
7661        }
7662        if (s.bitOffset >= 16) {
7663          s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7664          s.bitOffset -= 16;
7665        }
7666        repeat += readFewBits(s, extraBits) + 3;
7667        const repeatDelta = repeat - oldRepeat;
7668        if (symbol + repeatDelta > numSymbols) {
7669          return makeError(s, -2);
7670        }
7671        for (let i = 0; i < repeatDelta; ++i) {
7672          codeLengths[symbol++] = repeatCodeLen;
7673        }
7674        if (repeatCodeLen !== 0) {
7675          space -= repeatDelta << 15 - repeatCodeLen;
7676        }
7677      }
7678    }
7679    if (space !== 0) {
7680      return makeError(s, -18);
7681    }
7682    codeLengths.fill(0, symbol, numSymbols);
7683    return 0;
7684  }
7685  function checkDupes(s, symbols, length) {
7686    for (let i = 0; i < length - 1; ++i) {
7687      for (let j = i + 1; j < length; ++j) {
7688        if (symbols[i] === symbols[j]) {
7689          return makeError(s, -7);
7690        }
7691      }
7692    }
7693    return 0;
7694  }
7695  function readSimpleHuffmanCode(alphabetSizeMax, alphabetSizeLimit, tableGroup, tableIdx, s) {
7696    const codeLengths = new Int32Array(alphabetSizeLimit);
7697    const symbols = new Int32Array(4);
7698    const maxBits = 1 + log2floor(alphabetSizeMax - 1);
7699    const numSymbols = readFewBits(s, 2) + 1;
7700    for (let i = 0; i < numSymbols; ++i) {
7701      if (s.bitOffset >= 16) {
7702        s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7703        s.bitOffset -= 16;
7704      }
7705      const symbol = readFewBits(s, maxBits);
7706      if (symbol >= alphabetSizeLimit) {
7707        return makeError(s, -15);
7708      }
7709      symbols[i] = symbol;
7710    }
7711    const result = checkDupes(s, symbols, numSymbols);
7712    if (result < 0) {
7713      return result;
7714    }
7715    let histogramId = numSymbols;
7716    if (numSymbols === 4) {
7717      histogramId += readFewBits(s, 1);
7718    }
7719    switch (histogramId) {
7720      case 1:
7721        codeLengths[symbols[0]] = 1;
7722        break;
7723      case 2:
7724        codeLengths[symbols[0]] = 1;
7725        codeLengths[symbols[1]] = 1;
7726        break;
7727      case 3:
7728        codeLengths[symbols[0]] = 1;
7729        codeLengths[symbols[1]] = 2;
7730        codeLengths[symbols[2]] = 2;
7731        break;
7732      case 4:
7733        codeLengths[symbols[0]] = 2;
7734        codeLengths[symbols[1]] = 2;
7735        codeLengths[symbols[2]] = 2;
7736        codeLengths[symbols[3]] = 2;
7737        break;
7738      case 5:
7739        codeLengths[symbols[0]] = 1;
7740        codeLengths[symbols[1]] = 2;
7741        codeLengths[symbols[2]] = 3;
7742        codeLengths[symbols[3]] = 3;
7743        break;
7744      default:
7745        break;
7746    }
7747    return buildHuffmanTable(tableGroup, tableIdx, 8, codeLengths, alphabetSizeLimit);
7748  }
7749  function readComplexHuffmanCode(alphabetSizeLimit, skip, tableGroup, tableIdx, s) {
7750    const codeLengths = new Int32Array(alphabetSizeLimit);
7751    const codeLengthCodeLengths = new Int32Array(18);
7752    let space = 32;
7753    let numCodes = 0;
7754    for (let i = skip; i < 18; ++i) {
7755      const codeLenIdx = CODE_LENGTH_CODE_ORDER[i];
7756      if (s.bitOffset >= 16) {
7757        s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7758        s.bitOffset -= 16;
7759      }
7760      const p = s.accumulator32 >>> s.bitOffset & 15;
7761      s.bitOffset += FIXED_TABLE[p] >> 16;
7762      const v = FIXED_TABLE[p] & 0xFFFF;
7763      codeLengthCodeLengths[codeLenIdx] = v;
7764      if (v !== 0) {
7765        space -= 32 >> v;
7766        numCodes++;
7767        if (space <= 0) {
7768          break;
7769        }
7770      }
7771    }
7772    if (space !== 0 && numCodes !== 1) {
7773      return makeError(s, -4);
7774    }
7775    const result = readHuffmanCodeLengths(codeLengthCodeLengths, alphabetSizeLimit, codeLengths, s);
7776    if (result < 0) {
7777      return result;
7778    }
7779    return buildHuffmanTable(tableGroup, tableIdx, 8, codeLengths, alphabetSizeLimit);
7780  }
7781  function readHuffmanCode(alphabetSizeMax, alphabetSizeLimit, tableGroup, tableIdx, s) {
7782    if (s.halfOffset > 2030) {
7783      const result = readMoreInput(s);
7784      if (result < 0) {
7785        return result;
7786      }
7787    }
7788    if (s.bitOffset >= 16) {
7789      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7790      s.bitOffset -= 16;
7791    }
7792    const simpleCodeOrSkip = readFewBits(s, 2);
7793    if (simpleCodeOrSkip === 1) {
7794      return readSimpleHuffmanCode(alphabetSizeMax, alphabetSizeLimit, tableGroup, tableIdx, s);
7795    }
7796    return readComplexHuffmanCode(alphabetSizeLimit, simpleCodeOrSkip, tableGroup, tableIdx, s);
7797  }
7798  function decodeContextMap(contextMapSize, contextMap, s) {
7799    let result;
7800    if (s.halfOffset > 2030) {
7801      result = readMoreInput(s);
7802      if (result < 0) {
7803        return result;
7804      }
7805    }
7806    const numTrees = decodeVarLenUnsignedByte(s) + 1;
7807    if (numTrees === 1) {
7808      contextMap.fill(0, 0, contextMapSize);
7809      return numTrees;
7810    }
7811    if (s.bitOffset >= 16) {
7812      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7813      s.bitOffset -= 16;
7814    }
7815    const useRleForZeros = readFewBits(s, 1);
7816    let maxRunLengthPrefix = 0;
7817    if (useRleForZeros !== 0) {
7818      maxRunLengthPrefix = readFewBits(s, 4) + 1;
7819    }
7820    const alphabetSize = numTrees + maxRunLengthPrefix;
7821    const tableSize = MAX_HUFFMAN_TABLE_SIZE[alphabetSize + 31 >> 5];
7822    const table = new Int32Array(tableSize + 1);
7823    const tableIdx = table.length - 1;
7824    result = readHuffmanCode(alphabetSize, alphabetSize, table, tableIdx, s);
7825    if (result < 0) {
7826      return result;
7827    }
7828    let i = 0;
7829    while (i < contextMapSize) {
7830      if (s.halfOffset > 2030) {
7831        result = readMoreInput(s);
7832        if (result < 0) {
7833          return result;
7834        }
7835      }
7836      if (s.bitOffset >= 16) {
7837        s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7838        s.bitOffset -= 16;
7839      }
7840      const code = readSymbol(table, tableIdx, s);
7841      if (code === 0) {
7842        contextMap[i] = 0;
7843        i++;
7844      } else if (code <= maxRunLengthPrefix) {
7845        if (s.bitOffset >= 16) {
7846          s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7847          s.bitOffset -= 16;
7848        }
7849        let reps = (1 << code) + readFewBits(s, code);
7850        while (reps !== 0) {
7851          if (i >= contextMapSize) {
7852            return makeError(s, -3);
7853          }
7854          contextMap[i] = 0;
7855          i++;
7856          reps--;
7857        }
7858      } else {
7859        contextMap[i] = code - maxRunLengthPrefix;
7860        i++;
7861      }
7862    }
7863    if (s.bitOffset >= 16) {
7864      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7865      s.bitOffset -= 16;
7866    }
7867    if (readFewBits(s, 1) === 1) {
7868      inverseMoveToFrontTransform(contextMap, contextMapSize);
7869    }
7870    return numTrees;
7871  }
7872  function decodeBlockTypeAndLength(s, treeType, numBlockTypes) {
7873    const ringBuffers = s.rings;
7874    const offset = 4 + treeType * 2;
7875    if (s.bitOffset >= 16) {
7876      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
7877      s.bitOffset -= 16;
7878    }
7879    let blockType = readSymbol(s.blockTrees, 2 * treeType, s);
7880    const result = readBlockLength(s.blockTrees, 2 * treeType + 1, s);
7881    if (blockType === 1) {
7882      blockType = ringBuffers[offset + 1] + 1;
7883    } else if (blockType === 0) {
7884      blockType = ringBuffers[offset];
7885    } else {
7886      blockType -= 2;
7887    }
7888    if (blockType >= numBlockTypes) {
7889      blockType -= numBlockTypes;
7890    }
7891    ringBuffers[offset] = ringBuffers[offset + 1];
7892    ringBuffers[offset + 1] = blockType;
7893    return result;
7894  }
7895  function decodeLiteralBlockSwitch(s) {
7896    s.literalBlockLength = decodeBlockTypeAndLength(s, 0, s.numLiteralBlockTypes);
7897    const literalBlockType = s.rings[5];
7898    s.contextMapSlice = literalBlockType << 6;
7899    s.literalTreeIdx = s.contextMap[s.contextMapSlice] & 0xFF;
7900    const contextMode = s.contextModes[literalBlockType];
7901    s.contextLookupOffset1 = contextMode << 9;
7902    s.contextLookupOffset2 = s.contextLookupOffset1 + 256;
7903  }
7904  function decodeCommandBlockSwitch(s) {
7905    s.commandBlockLength = decodeBlockTypeAndLength(s, 1, s.numCommandBlockTypes);
7906    s.commandTreeIdx = s.rings[7];
7907  }
7908  function decodeDistanceBlockSwitch(s) {
7909    s.distanceBlockLength = decodeBlockTypeAndLength(s, 2, s.numDistanceBlockTypes);
7910    s.distContextMapSlice = s.rings[9] << 2;
7911  }
7912  function maybeReallocateRingBuffer(s) {
7913    let newSize = s.maxRingBufferSize;
7914    if (newSize > s.expectedTotalSize) {
7915      const minimalNewSize = s.expectedTotalSize;
7916      while (newSize >> 1 > minimalNewSize) {
7917        newSize = newSize >> 1;
7918      }
7919      if (s.inputEnd === 0 && newSize < 16384 && s.maxRingBufferSize >= 16384) {
7920        newSize = 16384;
7921      }
7922    }
7923    if (newSize <= s.ringBufferSize) {
7924      return;
7925    }
7926    const ringBufferSizeWithSlack = newSize + 37;
7927    const newBuffer = new Int8Array(ringBufferSizeWithSlack);
7928    const oldBuffer = s.ringBuffer;
7929    if (oldBuffer.length !== 0) {
7930      newBuffer.set(oldBuffer.subarray(0, s.ringBufferSize), 0);
7931    }
7932    s.ringBuffer = newBuffer;
7933    s.ringBufferSize = newSize;
7934  }
7935  function readNextMetablockHeader(s) {
7936    if (s.inputEnd !== 0) {
7937      s.nextRunningState = 10;
7938      s.runningState = 12;
7939      return 0;
7940    }
7941    s.literalTreeGroup = new Int32Array(0);
7942    s.commandTreeGroup = new Int32Array(0);
7943    s.distanceTreeGroup = new Int32Array(0);
7944    let result;
7945    if (s.halfOffset > 2030) {
7946      result = readMoreInput(s);
7947      if (result < 0) {
7948        return result;
7949      }
7950    }
7951    result = decodeMetaBlockLength(s);
7952    if (result < 0) {
7953      return result;
7954    }
7955    if (s.metaBlockLength === 0 && s.isMetadata === 0) {
7956      return 0;
7957    }
7958    if (s.isUncompressed !== 0 || s.isMetadata !== 0) {
7959      result = jumpToByteBoundary(s);
7960      if (result < 0) {
7961        return result;
7962      }
7963      if (s.isMetadata === 0) {
7964        s.runningState = 6;
7965      } else {
7966        s.runningState = 5;
7967      }
7968    } else {
7969      s.runningState = 3;
7970    }
7971    if (s.isMetadata !== 0) {
7972      return 0;
7973    }
7974    s.expectedTotalSize += s.metaBlockLength;
7975    if (s.expectedTotalSize > 1 << 30) {
7976      s.expectedTotalSize = 1 << 30;
7977    }
7978    if (s.ringBufferSize < s.maxRingBufferSize) {
7979      maybeReallocateRingBuffer(s);
7980    }
7981    return 0;
7982  }
7983  function readMetablockPartition(s, treeType, numBlockTypes) {
7984    let offset = s.blockTrees[2 * treeType];
7985    if (numBlockTypes <= 1) {
7986      s.blockTrees[2 * treeType + 1] = offset;
7987      s.blockTrees[2 * treeType + 2] = offset;
7988      return 1 << 28;
7989    }
7990    const blockTypeAlphabetSize = numBlockTypes + 2;
7991    let result = readHuffmanCode(blockTypeAlphabetSize, blockTypeAlphabetSize, s.blockTrees, 2 * treeType, s);
7992    if (result < 0) {
7993      return result;
7994    }
7995    offset += result;
7996    s.blockTrees[2 * treeType + 1] = offset;
7997    const blockLengthAlphabetSize = 26;
7998    result = readHuffmanCode(blockLengthAlphabetSize, blockLengthAlphabetSize, s.blockTrees, 2 * treeType + 1, s);
7999    if (result < 0) {
8000      return result;
8001    }
8002    offset += result;
8003    s.blockTrees[2 * treeType + 2] = offset;
8004    return readBlockLength(s.blockTrees, 2 * treeType + 1, s);
8005  }
8006  function calculateDistanceLut(s, alphabetSizeLimit) {
8007    const distExtraBits = s.distExtraBits;
8008    const distOffset = s.distOffset;
8009    const npostfix = s.distancePostfixBits;
8010    const ndirect = s.numDirectDistanceCodes;
8011    const postfix = 1 << npostfix;
8012    let bits = 1;
8013    let half = 0;
8014    let i = 16;
8015    for (let j = 0; j < ndirect; ++j) {
8016      distExtraBits[i] = 0;
8017      distOffset[i] = j + 1;
8018      ++i;
8019    }
8020    while (i < alphabetSizeLimit) {
8021      const base = ndirect + ((2 + half << bits) - 4 << npostfix) + 1;
8022      for (let j = 0; j < postfix; ++j) {
8023        distExtraBits[i] = bits;
8024        distOffset[i] = base + j;
8025        ++i;
8026      }
8027      bits = bits + half;
8028      half = half ^ 1;
8029    }
8030  }
8031  function readMetablockHuffmanCodesAndContextMaps(s) {
8032    s.numLiteralBlockTypes = decodeVarLenUnsignedByte(s) + 1;
8033    let result = readMetablockPartition(s, 0, s.numLiteralBlockTypes);
8034    if (result < 0) {
8035      return result;
8036    }
8037    s.literalBlockLength = result;
8038    s.numCommandBlockTypes = decodeVarLenUnsignedByte(s) + 1;
8039    result = readMetablockPartition(s, 1, s.numCommandBlockTypes);
8040    if (result < 0) {
8041      return result;
8042    }
8043    s.commandBlockLength = result;
8044    s.numDistanceBlockTypes = decodeVarLenUnsignedByte(s) + 1;
8045    result = readMetablockPartition(s, 2, s.numDistanceBlockTypes);
8046    if (result < 0) {
8047      return result;
8048    }
8049    s.distanceBlockLength = result;
8050    if (s.halfOffset > 2030) {
8051      result = readMoreInput(s);
8052      if (result < 0) {
8053        return result;
8054      }
8055    }
8056    if (s.bitOffset >= 16) {
8057      s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8058      s.bitOffset -= 16;
8059    }
8060    s.distancePostfixBits = readFewBits(s, 2);
8061    s.numDirectDistanceCodes = readFewBits(s, 4) << s.distancePostfixBits;
8062    s.contextModes = new Int8Array(s.numLiteralBlockTypes);
8063    let i = 0;
8064    while (i < s.numLiteralBlockTypes) {
8065      const limit = Math.min(i + 96, s.numLiteralBlockTypes);
8066      while (i < limit) {
8067        if (s.bitOffset >= 16) {
8068          s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8069          s.bitOffset -= 16;
8070        }
8071        s.contextModes[i] = readFewBits(s, 2);
8072        i++;
8073      }
8074      if (s.halfOffset > 2030) {
8075        result = readMoreInput(s);
8076        if (result < 0) {
8077          return result;
8078        }
8079      }
8080    }
8081    const contextMapLength = s.numLiteralBlockTypes << 6;
8082    s.contextMap = new Int8Array(contextMapLength);
8083    result = decodeContextMap(contextMapLength, s.contextMap, s);
8084    if (result < 0) {
8085      return result;
8086    }
8087    const numLiteralTrees = result;
8088    s.trivialLiteralContext = 1;
8089    for (let j = 0; j < contextMapLength; ++j) {
8090      if (s.contextMap[j] !== j >> 6) {
8091        s.trivialLiteralContext = 0;
8092        break;
8093      }
8094    }
8095    s.distContextMap = new Int8Array(s.numDistanceBlockTypes << 2);
8096    result = decodeContextMap(s.numDistanceBlockTypes << 2, s.distContextMap, s);
8097    if (result < 0) {
8098      return result;
8099    }
8100    const numDistTrees = result;
8101    s.literalTreeGroup = new Int32Array(huffmanTreeGroupAllocSize(256, numLiteralTrees));
8102    result = decodeHuffmanTreeGroup(256, 256, numLiteralTrees, s, s.literalTreeGroup);
8103    if (result < 0) {
8104      return result;
8105    }
8106    s.commandTreeGroup = new Int32Array(huffmanTreeGroupAllocSize(704, s.numCommandBlockTypes));
8107    result = decodeHuffmanTreeGroup(704, 704, s.numCommandBlockTypes, s, s.commandTreeGroup);
8108    if (result < 0) {
8109      return result;
8110    }
8111    let distanceAlphabetSizeMax = calculateDistanceAlphabetSize(s.distancePostfixBits, s.numDirectDistanceCodes, 24);
8112    let distanceAlphabetSizeLimit = distanceAlphabetSizeMax;
8113    if (s.isLargeWindow === 1) {
8114      distanceAlphabetSizeMax = calculateDistanceAlphabetSize(s.distancePostfixBits, s.numDirectDistanceCodes, 62);
8115      result = calculateDistanceAlphabetLimit(s, 0x7FFFFFFC, s.distancePostfixBits, s.numDirectDistanceCodes);
8116      if (result < 0) {
8117        return result;
8118      }
8119      distanceAlphabetSizeLimit = result;
8120    }
8121    s.distanceTreeGroup = new Int32Array(huffmanTreeGroupAllocSize(distanceAlphabetSizeLimit, numDistTrees));
8122    result = decodeHuffmanTreeGroup(distanceAlphabetSizeMax, distanceAlphabetSizeLimit, numDistTrees, s, s.distanceTreeGroup);
8123    if (result < 0) {
8124      return result;
8125    }
8126    calculateDistanceLut(s, distanceAlphabetSizeLimit);
8127    s.contextMapSlice = 0;
8128    s.distContextMapSlice = 0;
8129    s.contextLookupOffset1 = s.contextModes[0] * 512;
8130    s.contextLookupOffset2 = s.contextLookupOffset1 + 256;
8131    s.literalTreeIdx = 0;
8132    s.commandTreeIdx = 0;
8133    s.rings[4] = 1;
8134    s.rings[5] = 0;
8135    s.rings[6] = 1;
8136    s.rings[7] = 0;
8137    s.rings[8] = 1;
8138    s.rings[9] = 0;
8139    return 0;
8140  }
8141  function copyUncompressedData(s) {
8142    const ringBuffer = s.ringBuffer;
8143    let result;
8144    if (s.metaBlockLength <= 0) {
8145      result = reload(s);
8146      if (result < 0) {
8147        return result;
8148      }
8149      s.runningState = 2;
8150      return 0;
8151    }
8152    const chunkLength = Math.min(s.ringBufferSize - s.pos, s.metaBlockLength);
8153    result = copyRawBytes(s, ringBuffer, s.pos, chunkLength);
8154    if (result < 0) {
8155      return result;
8156    }
8157    s.metaBlockLength -= chunkLength;
8158    s.pos += chunkLength;
8159    if (s.pos === s.ringBufferSize) {
8160      s.nextRunningState = 6;
8161      s.runningState = 12;
8162      return 0;
8163    }
8164    result = reload(s);
8165    if (result < 0) {
8166      return result;
8167    }
8168    s.runningState = 2;
8169    return 0;
8170  }
8171  function writeRingBuffer(s) {
8172    const toWrite = Math.min(s.outputLength - s.outputUsed, s.ringBufferBytesReady - s.ringBufferBytesWritten);
8173    if (toWrite !== 0) {
8174      s.output.set(s.ringBuffer.subarray(s.ringBufferBytesWritten, s.ringBufferBytesWritten + toWrite), s.outputOffset + s.outputUsed);
8175      s.outputUsed += toWrite;
8176      s.ringBufferBytesWritten += toWrite;
8177    }
8178    if (s.outputUsed < s.outputLength) {
8179      return 0;
8180    }
8181    return 2;
8182  }
8183  function huffmanTreeGroupAllocSize(alphabetSizeLimit, n) {
8184    const maxTableSize = MAX_HUFFMAN_TABLE_SIZE[alphabetSizeLimit + 31 >> 5];
8185    return n + n * maxTableSize;
8186  }
8187  function decodeHuffmanTreeGroup(alphabetSizeMax, alphabetSizeLimit, n, s, group) {
8188    let next = n;
8189    for (let i = 0; i < n; ++i) {
8190      group[i] = next;
8191      const result = readHuffmanCode(alphabetSizeMax, alphabetSizeLimit, group, i, s);
8192      if (result < 0) {
8193        return result;
8194      }
8195      next += result;
8196    }
8197    return 0;
8198  }
8199  function calculateFence(s) {
8200    let result = s.ringBufferSize;
8201    if (s.isEager !== 0) {
8202      result = Math.min(result, s.ringBufferBytesWritten + s.outputLength - s.outputUsed);
8203    }
8204    return result;
8205  }
8206  function doUseDictionary(s, fence) {
8207    if (s.distance > 0x7FFFFFFC) {
8208      return makeError(s, -9);
8209    }
8210    const address = s.distance - s.maxDistance - 1 - s.cdTotalSize;
8211    if (address < 0) {
8212      const result = initializeCompoundDictionaryCopy(s, -address - 1, s.copyLength);
8213      if (result < 0) {
8214        return result;
8215      }
8216      s.runningState = 14;
8217    } else {
8218      const dictionaryData = data;
8219      const wordLength = s.copyLength;
8220      if (wordLength > 31) {
8221        return makeError(s, -9);
8222      }
8223      const shift = sizeBits[wordLength];
8224      if (shift === 0) {
8225        return makeError(s, -9);
8226      }
8227      let offset = offsets[wordLength];
8228      const mask = (1 << shift) - 1;
8229      const wordIdx = address & mask;
8230      const transformIdx = address >> shift;
8231      offset += wordIdx * wordLength;
8232      const transforms = RFC_TRANSFORMS;
8233      if (transformIdx >= transforms.numTransforms) {
8234        return makeError(s, -9);
8235      }
8236      const len = transformDictionaryWord(s.ringBuffer, s.pos, dictionaryData, offset, wordLength, transforms, transformIdx);
8237      s.pos += len;
8238      s.metaBlockLength -= len;
8239      if (s.pos >= fence) {
8240        s.nextRunningState = 4;
8241        s.runningState = 12;
8242        return 0;
8243      }
8244      s.runningState = 4;
8245    }
8246    return 0;
8247  }
8248  function initializeCompoundDictionary(s) {
8249    s.cdBlockMap = new Int8Array(256);
8250    let blockBits = 8;
8251    while (s.cdTotalSize - 1 >> blockBits !== 0) {
8252      blockBits++;
8253    }
8254    blockBits -= 8;
8255    s.cdBlockBits = blockBits;
8256    let cursor = 0;
8257    let index = 0;
8258    while (cursor < s.cdTotalSize) {
8259      while (s.cdChunkOffsets[index + 1] < cursor) {
8260        index++;
8261      }
8262      s.cdBlockMap[cursor >> blockBits] = index;
8263      cursor += 1 << blockBits;
8264    }
8265  }
8266  function initializeCompoundDictionaryCopy(s, address, length) {
8267    if (s.cdBlockBits === -1) {
8268      initializeCompoundDictionary(s);
8269    }
8270    let index = s.cdBlockMap[address >> s.cdBlockBits];
8271    while (address >= s.cdChunkOffsets[index + 1]) {
8272      index++;
8273    }
8274    if (s.cdTotalSize > address + length) {
8275      return makeError(s, -9);
8276    }
8277    s.distRbIdx = s.distRbIdx + 1 & 0x3;
8278    s.rings[s.distRbIdx] = s.distance;
8279    s.metaBlockLength -= length;
8280    s.cdBrIndex = index;
8281    s.cdBrOffset = address - s.cdChunkOffsets[index];
8282    s.cdBrLength = length;
8283    s.cdBrCopied = 0;
8284    return 0;
8285  }
8286  function copyFromCompoundDictionary(s, fence) {
8287    let pos = s.pos;
8288    const origPos = pos;
8289    while (s.cdBrLength !== s.cdBrCopied) {
8290      const space = fence - pos;
8291      const chunkLength = s.cdChunkOffsets[s.cdBrIndex + 1] - s.cdChunkOffsets[s.cdBrIndex];
8292      const remChunkLength = chunkLength - s.cdBrOffset;
8293      let length = s.cdBrLength - s.cdBrCopied;
8294      if (length > remChunkLength) {
8295        length = remChunkLength;
8296      }
8297      if (length > space) {
8298        length = space;
8299      }
8300      s.ringBuffer.set(s.cdChunks[s.cdBrIndex].subarray(s.cdBrOffset, s.cdBrOffset + length), pos);
8301      pos += length;
8302      s.cdBrOffset += length;
8303      s.cdBrCopied += length;
8304      if (length === remChunkLength) {
8305        s.cdBrIndex++;
8306        s.cdBrOffset = 0;
8307      }
8308      if (pos >= fence) {
8309        break;
8310      }
8311    }
8312    return pos - origPos;
8313  }
8314  function decompress(s) {
8315    let result;
8316    if (s.runningState === 0) {
8317      return makeError(s, -25);
8318    }
8319    if (s.runningState < 0) {
8320      return makeError(s, -28);
8321    }
8322    if (s.runningState === 11) {
8323      return makeError(s, -22);
8324    }
8325    if (s.runningState === 1) {
8326      const windowBits = decodeWindowBits(s);
8327      if (windowBits === -1) {
8328        return makeError(s, -11);
8329      }
8330      s.maxRingBufferSize = 1 << windowBits;
8331      s.maxBackwardDistance = s.maxRingBufferSize - 16;
8332      s.runningState = 2;
8333    }
8334    let fence = calculateFence(s);
8335    let ringBufferMask = s.ringBufferSize - 1;
8336    let ringBuffer = s.ringBuffer;
8337    while (s.runningState !== 10) {
8338      switch (s.runningState) {
8339        case 2:
8340          if (s.metaBlockLength < 0) {
8341            return makeError(s, -10);
8342          }
8343          result = readNextMetablockHeader(s);
8344          if (result < 0) {
8345            return result;
8346          }
8347          fence = calculateFence(s);
8348          ringBufferMask = s.ringBufferSize - 1;
8349          ringBuffer = s.ringBuffer;
8350          continue;
8351        case 3:
8352          result = readMetablockHuffmanCodesAndContextMaps(s);
8353          if (result < 0) {
8354            return result;
8355          }
8356          s.runningState = 4;
8357          continue;
8358        case 4:
8359          if (s.metaBlockLength <= 0) {
8360            s.runningState = 2;
8361            continue;
8362          }
8363          if (s.halfOffset > 2030) {
8364            result = readMoreInput(s);
8365            if (result < 0) {
8366              return result;
8367            }
8368          }
8369          if (s.commandBlockLength === 0) {
8370            decodeCommandBlockSwitch(s);
8371          }
8372          s.commandBlockLength--;
8373          if (s.bitOffset >= 16) {
8374            s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8375            s.bitOffset -= 16;
8376          }
8377          const cmdCode = readSymbol(s.commandTreeGroup, s.commandTreeIdx, s) << 2;
8378          const insertAndCopyExtraBits = CMD_LOOKUP[cmdCode];
8379          const insertLengthOffset = CMD_LOOKUP[cmdCode + 1];
8380          const copyLengthOffset = CMD_LOOKUP[cmdCode + 2];
8381          s.distanceCode = CMD_LOOKUP[cmdCode + 3];
8382          if (s.bitOffset >= 16) {
8383            s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8384            s.bitOffset -= 16;
8385          }
8386          const insertLengthExtraBits = insertAndCopyExtraBits & 0xFF;
8387          s.insertLength = insertLengthOffset + (insertLengthExtraBits <= 16 ? readFewBits(s, insertLengthExtraBits) : readManyBits(s, insertLengthExtraBits));
8388          if (s.bitOffset >= 16) {
8389            s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8390            s.bitOffset -= 16;
8391          }
8392          const copyLengthExtraBits = insertAndCopyExtraBits >> 8;
8393          s.copyLength = copyLengthOffset + (copyLengthExtraBits <= 16 ? readFewBits(s, copyLengthExtraBits) : readManyBits(s, copyLengthExtraBits));
8394          s.j = 0;
8395          s.runningState = 7;
8396          continue;
8397        case 7:
8398          if (s.trivialLiteralContext !== 0) {
8399            while (s.j < s.insertLength) {
8400              if (s.halfOffset > 2030) {
8401                result = readMoreInput(s);
8402                if (result < 0) {
8403                  return result;
8404                }
8405              }
8406              if (s.literalBlockLength === 0) {
8407                decodeLiteralBlockSwitch(s);
8408              }
8409              s.literalBlockLength--;
8410              if (s.bitOffset >= 16) {
8411                s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8412                s.bitOffset -= 16;
8413              }
8414              ringBuffer[s.pos] = readSymbol(s.literalTreeGroup, s.literalTreeIdx, s);
8415              s.pos++;
8416              s.j++;
8417              if (s.pos >= fence) {
8418                s.nextRunningState = 7;
8419                s.runningState = 12;
8420                break;
8421              }
8422            }
8423          } else {
8424            let prevByte1 = ringBuffer[s.pos - 1 & ringBufferMask] & 0xFF;
8425            let prevByte2 = ringBuffer[s.pos - 2 & ringBufferMask] & 0xFF;
8426            while (s.j < s.insertLength) {
8427              if (s.halfOffset > 2030) {
8428                result = readMoreInput(s);
8429                if (result < 0) {
8430                  return result;
8431                }
8432              }
8433              if (s.literalBlockLength === 0) {
8434                decodeLiteralBlockSwitch(s);
8435              }
8436              const literalContext = LOOKUP[s.contextLookupOffset1 + prevByte1] | LOOKUP[s.contextLookupOffset2 + prevByte2];
8437              const literalTreeIdx = s.contextMap[s.contextMapSlice + literalContext] & 0xFF;
8438              s.literalBlockLength--;
8439              prevByte2 = prevByte1;
8440              if (s.bitOffset >= 16) {
8441                s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8442                s.bitOffset -= 16;
8443              }
8444              prevByte1 = readSymbol(s.literalTreeGroup, literalTreeIdx, s);
8445              ringBuffer[s.pos] = prevByte1;
8446              s.pos++;
8447              s.j++;
8448              if (s.pos >= fence) {
8449                s.nextRunningState = 7;
8450                s.runningState = 12;
8451                break;
8452              }
8453            }
8454          }
8455          if (s.runningState !== 7) {
8456            continue;
8457          }
8458          s.metaBlockLength -= s.insertLength;
8459          if (s.metaBlockLength <= 0) {
8460            s.runningState = 4;
8461            continue;
8462          }
8463          let distanceCode = s.distanceCode;
8464          if (distanceCode < 0) {
8465            s.distance = s.rings[s.distRbIdx];
8466          } else {
8467            if (s.halfOffset > 2030) {
8468              result = readMoreInput(s);
8469              if (result < 0) {
8470                return result;
8471              }
8472            }
8473            if (s.distanceBlockLength === 0) {
8474              decodeDistanceBlockSwitch(s);
8475            }
8476            s.distanceBlockLength--;
8477            if (s.bitOffset >= 16) {
8478              s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8479              s.bitOffset -= 16;
8480            }
8481            const distTreeIdx = s.distContextMap[s.distContextMapSlice + distanceCode] & 0xFF;
8482            distanceCode = readSymbol(s.distanceTreeGroup, distTreeIdx, s);
8483            if (distanceCode < 16) {
8484              const index = s.distRbIdx + DISTANCE_SHORT_CODE_INDEX_OFFSET[distanceCode] & 0x3;
8485              s.distance = s.rings[index] + DISTANCE_SHORT_CODE_VALUE_OFFSET[distanceCode];
8486              if (s.distance < 0) {
8487                return makeError(s, -12);
8488              }
8489            } else {
8490              const extraBits = s.distExtraBits[distanceCode];
8491              let bits;
8492              if (s.bitOffset + extraBits <= 32) {
8493                bits = readFewBits(s, extraBits);
8494              } else {
8495                if (s.bitOffset >= 16) {
8496                  s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8497                  s.bitOffset -= 16;
8498                }
8499                bits = extraBits <= 16 ? readFewBits(s, extraBits) : readManyBits(s, extraBits);
8500              }
8501              s.distance = s.distOffset[distanceCode] + (bits << s.distancePostfixBits);
8502            }
8503          }
8504          if (s.maxDistance !== s.maxBackwardDistance && s.pos < s.maxBackwardDistance) {
8505            s.maxDistance = s.pos;
8506          } else {
8507            s.maxDistance = s.maxBackwardDistance;
8508          }
8509          if (s.distance > s.maxDistance) {
8510            s.runningState = 9;
8511            continue;
8512          }
8513          if (distanceCode > 0) {
8514            s.distRbIdx = s.distRbIdx + 1 & 0x3;
8515            s.rings[s.distRbIdx] = s.distance;
8516          }
8517          if (s.copyLength > s.metaBlockLength) {
8518            return makeError(s, -9);
8519          }
8520          s.j = 0;
8521          s.runningState = 8;
8522          continue;
8523        case 8:
8524          let src = s.pos - s.distance & ringBufferMask;
8525          let dst = s.pos;
8526          const copyLength = s.copyLength - s.j;
8527          const srcEnd = src + copyLength;
8528          const dstEnd = dst + copyLength;
8529          if (srcEnd < ringBufferMask && dstEnd < ringBufferMask) {
8530            if (copyLength < 12 || srcEnd > dst && dstEnd > src) {
8531              const numQuads = copyLength + 3 >> 2;
8532              for (let k = 0; k < numQuads; ++k) {
8533                ringBuffer[dst++] = ringBuffer[src++];
8534                ringBuffer[dst++] = ringBuffer[src++];
8535                ringBuffer[dst++] = ringBuffer[src++];
8536                ringBuffer[dst++] = ringBuffer[src++];
8537              }
8538            } else {
8539              ringBuffer.copyWithin(dst, src, srcEnd);
8540            }
8541            s.j += copyLength;
8542            s.metaBlockLength -= copyLength;
8543            s.pos += copyLength;
8544          } else {
8545            while (s.j < s.copyLength) {
8546              ringBuffer[s.pos] = ringBuffer[s.pos - s.distance & ringBufferMask];
8547              s.metaBlockLength--;
8548              s.pos++;
8549              s.j++;
8550              if (s.pos >= fence) {
8551                s.nextRunningState = 8;
8552                s.runningState = 12;
8553                break;
8554              }
8555            }
8556          }
8557          if (s.runningState === 8) {
8558            s.runningState = 4;
8559          }
8560          continue;
8561        case 9:
8562          result = doUseDictionary(s, fence);
8563          if (result < 0) {
8564            return result;
8565          }
8566          continue;
8567        case 14:
8568          s.pos += copyFromCompoundDictionary(s, fence);
8569          if (s.pos >= fence) {
8570            s.nextRunningState = 14;
8571            s.runningState = 12;
8572            return 2;
8573          }
8574          s.runningState = 4;
8575          continue;
8576        case 5:
8577          while (s.metaBlockLength > 0) {
8578            if (s.halfOffset > 2030) {
8579              result = readMoreInput(s);
8580              if (result < 0) {
8581                return result;
8582              }
8583            }
8584            if (s.bitOffset >= 16) {
8585              s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8586              s.bitOffset -= 16;
8587            }
8588            readFewBits(s, 8);
8589            s.metaBlockLength--;
8590          }
8591          s.runningState = 2;
8592          continue;
8593        case 6:
8594          result = copyUncompressedData(s);
8595          if (result < 0) {
8596            return result;
8597          }
8598          continue;
8599        case 12:
8600          s.ringBufferBytesReady = Math.min(s.pos, s.ringBufferSize);
8601          s.runningState = 13;
8602          continue;
8603        case 13:
8604          result = writeRingBuffer(s);
8605          if (result !== 0) {
8606            return result;
8607          }
8608          if (s.pos >= s.maxBackwardDistance) {
8609            s.maxDistance = s.maxBackwardDistance;
8610          }
8611          if (s.pos >= s.ringBufferSize) {
8612            if (s.pos > s.ringBufferSize) {
8613              ringBuffer.copyWithin(0, s.ringBufferSize, s.pos);
8614            }
8615            s.pos = s.pos & ringBufferMask;
8616            s.ringBufferBytesWritten = 0;
8617          }
8618          s.runningState = s.nextRunningState;
8619          continue;
8620        default:
8621          return makeError(s, -28);
8622      }
8623    }
8624    if (s.runningState !== 10) {
8625      return makeError(s, -29);
8626    }
8627    if (s.metaBlockLength < 0) {
8628      return makeError(s, -10);
8629    }
8630    result = jumpToByteBoundary(s);
8631    if (result !== 0) {
8632      return result;
8633    }
8634    result = checkHealth(s, 1);
8635    if (result !== 0) {
8636      return result;
8637    }
8638    return 1;
8639  }
8640  function Transforms(numTransforms, prefixSuffixLen, prefixSuffixCount) {
8641    this.numTransforms = 0;
8642    this.triplets = new Int32Array(0);
8643    this.prefixSuffixStorage = new Int8Array(0);
8644    this.prefixSuffixHeads = new Int32Array(0);
8645    this.params = new Int16Array(0);
8646    this.numTransforms = numTransforms;
8647    this.triplets = new Int32Array(numTransforms * 3);
8648    this.params = new Int16Array(numTransforms);
8649    this.prefixSuffixStorage = new Int8Array(prefixSuffixLen);
8650    this.prefixSuffixHeads = new Int32Array(prefixSuffixCount + 1);
8651  }
8652  const RFC_TRANSFORMS = new Transforms(121, 167, 50);
8653  function unpackTransforms(prefixSuffix, prefixSuffixHeads, transforms, prefixSuffixSrc, transformsSrc) {
8654    const prefixSuffixBytes = toUtf8Runes(prefixSuffixSrc);
8655    const n = prefixSuffixBytes.length;
8656    let index = 1;
8657    let j = 0;
8658    for (let i = 0; i < n; ++i) {
8659      const c = prefixSuffixBytes[i];
8660      if (c === 35) {
8661        prefixSuffixHeads[index++] = j;
8662      } else {
8663        prefixSuffix[j++] = c;
8664      }
8665    }
8666    for (let i = 0; i < 363; ++i) {
8667      transforms[i] = transformsSrc.charCodeAt(i) - 32;
8668    }
8669  }
8670  unpackTransforms(RFC_TRANSFORMS.prefixSuffixStorage, RFC_TRANSFORMS.prefixSuffixHeads, RFC_TRANSFORMS.triplets, "# #s #, #e #.# the #.com/#\xC2\xA0# of # and # in # to #\"#\">#\n#]# for # a # that #. # with #'# from # by #. The # on # as # is #ing #\n\t#:#ed #(# at #ly #=\"# of the #. This #,# not #er #al #='#ful #ive #less #est #ize #ous #", "     !! ! ,  *!  &!  \" !  ) *   * -  ! # !  #!*!  +  ,$ !  -  %  .  / #   0  1 .  \"   2  3!*   4%  ! # /   5  6  7  8 0  1 &   $   9 +   :  ;  < '  !=  >  ?! 4  @ 4  2  &   A *# (   B  C& ) %  ) !*# *-% A +! *.  D! %'  & E *6  F  G% ! *A *%  H! D  I!+!  J!+   K +- *4! A  L!*4  M  N +6  O!*% +.! K *G  P +%(  ! G *D +D  Q +# *K!*G!+D!+# +G +A +4!+% +K!+4!*D!+K!*K");
8671  function transformDictionaryWord(dst, dstOffset, src, srcOffset, wordLen, transforms, transformIndex) {
8672    let offset = dstOffset;
8673    const triplets = transforms.triplets;
8674    const prefixSuffixStorage = transforms.prefixSuffixStorage;
8675    const prefixSuffixHeads = transforms.prefixSuffixHeads;
8676    const transformOffset = 3 * transformIndex;
8677    const prefixIdx = triplets[transformOffset];
8678    const transformType = triplets[transformOffset + 1];
8679    const suffixIdx = triplets[transformOffset + 2];
8680    let prefix = prefixSuffixHeads[prefixIdx];
8681    const prefixEnd = prefixSuffixHeads[prefixIdx + 1];
8682    let suffix = prefixSuffixHeads[suffixIdx];
8683    const suffixEnd = prefixSuffixHeads[suffixIdx + 1];
8684    let omitFirst = transformType - 11;
8685    let omitLast = transformType;
8686    if (omitFirst < 1 || omitFirst > 9) {
8687      omitFirst = 0;
8688    }
8689    if (omitLast < 1 || omitLast > 9) {
8690      omitLast = 0;
8691    }
8692    while (prefix !== prefixEnd) {
8693      dst[offset++] = prefixSuffixStorage[prefix++];
8694    }
8695    let len = wordLen;
8696    if (omitFirst > len) {
8697      omitFirst = len;
8698    }
8699    let dictOffset = srcOffset + omitFirst;
8700    len -= omitFirst;
8701    len -= omitLast;
8702    let i = len;
8703    while (i > 0) {
8704      dst[offset++] = src[dictOffset++];
8705      i--;
8706    }
8707    if (transformType === 10 || transformType === 11) {
8708      let uppercaseOffset = offset - len;
8709      if (transformType === 10) {
8710        len = 1;
8711      }
8712      while (len > 0) {
8713        const c0 = dst[uppercaseOffset] & 0xFF;
8714        if (c0 < 0xC0) {
8715          if (c0 >= 97 && c0 <= 122) {
8716            dst[uppercaseOffset] = dst[uppercaseOffset] ^ 32;
8717          }
8718          uppercaseOffset += 1;
8719          len -= 1;
8720        } else if (c0 < 0xE0) {
8721          dst[uppercaseOffset + 1] = dst[uppercaseOffset + 1] ^ 32;
8722          uppercaseOffset += 2;
8723          len -= 2;
8724        } else {
8725          dst[uppercaseOffset + 2] = dst[uppercaseOffset + 2] ^ 5;
8726          uppercaseOffset += 3;
8727          len -= 3;
8728        }
8729      }
8730    } else if (transformType === 21 || transformType === 22) {
8731      let shiftOffset = offset - len;
8732      const param = transforms.params[transformIndex];
8733      let scalar = (param & 0x7FFF) + (0x1000000 - (param & 0x8000));
8734      while (len > 0) {
8735        let step = 1;
8736        const c0 = dst[shiftOffset] & 0xFF;
8737        if (c0 < 0x80) {
8738          scalar += c0;
8739          dst[shiftOffset] = scalar & 0x7F;
8740        } else if (c0 < 0xC0) {} else if (c0 < 0xE0) {
8741          if (len >= 2) {
8742            const c1 = dst[shiftOffset + 1];
8743            scalar += c1 & 0x3F | (c0 & 0x1F) << 6;
8744            dst[shiftOffset] = 0xC0 | scalar >> 6 & 0x1F;
8745            dst[shiftOffset + 1] = c1 & 0xC0 | scalar & 0x3F;
8746            step = 2;
8747          } else {
8748            step = len;
8749          }
8750        } else if (c0 < 0xF0) {
8751          if (len >= 3) {
8752            const c1 = dst[shiftOffset + 1];
8753            const c2 = dst[shiftOffset + 2];
8754            scalar += c2 & 0x3F | (c1 & 0x3F) << 6 | (c0 & 0x0F) << 12;
8755            dst[shiftOffset] = 0xE0 | scalar >> 12 & 0x0F;
8756            dst[shiftOffset + 1] = c1 & 0xC0 | scalar >> 6 & 0x3F;
8757            dst[shiftOffset + 2] = c2 & 0xC0 | scalar & 0x3F;
8758            step = 3;
8759          } else {
8760            step = len;
8761          }
8762        } else if (c0 < 0xF8) {
8763          if (len >= 4) {
8764            const c1 = dst[shiftOffset + 1];
8765            const c2 = dst[shiftOffset + 2];
8766            const c3 = dst[shiftOffset + 3];
8767            scalar += c3 & 0x3F | (c2 & 0x3F) << 6 | (c1 & 0x3F) << 12 | (c0 & 0x07) << 18;
8768            dst[shiftOffset] = 0xF0 | scalar >> 18 & 0x07;
8769            dst[shiftOffset + 1] = c1 & 0xC0 | scalar >> 12 & 0x3F;
8770            dst[shiftOffset + 2] = c2 & 0xC0 | scalar >> 6 & 0x3F;
8771            dst[shiftOffset + 3] = c3 & 0xC0 | scalar & 0x3F;
8772            step = 4;
8773          } else {
8774            step = len;
8775          }
8776        }
8777        shiftOffset += step;
8778        len -= step;
8779        if (transformType === 21) {
8780          len = 0;
8781        }
8782      }
8783    }
8784    while (suffix !== suffixEnd) {
8785      dst[offset++] = prefixSuffixStorage[suffix++];
8786    }
8787    return offset - dstOffset;
8788  }
8789  function getNextKey(key, len) {
8790    let step = 1 << len - 1;
8791    while ((key & step) !== 0) {
8792      step = step >> 1;
8793    }
8794    return (key & step - 1) + step;
8795  }
8796  function replicateValue(table, offset, step, end, item) {
8797    let pos = end;
8798    while (pos > 0) {
8799      pos -= step;
8800      table[offset + pos] = item;
8801    }
8802  }
8803  function nextTableBitSize(count, len, rootBits) {
8804    let bits = len;
8805    let left = 1 << bits - rootBits;
8806    while (bits < 15) {
8807      left -= count[bits];
8808      if (left <= 0) {
8809        break;
8810      }
8811      bits++;
8812      left = left << 1;
8813    }
8814    return bits - rootBits;
8815  }
8816  function buildHuffmanTable(tableGroup, tableIdx, rootBits, codeLengths, codeLengthsSize) {
8817    const tableOffset = tableGroup[tableIdx];
8818    const sorted = new Int32Array(codeLengthsSize);
8819    const count = new Int32Array(16);
8820    const offset = new Int32Array(16);
8821    for (let sym = 0; sym < codeLengthsSize; ++sym) {
8822      count[codeLengths[sym]]++;
8823    }
8824    offset[1] = 0;
8825    for (let len = 1; len < 15; ++len) {
8826      offset[len + 1] = offset[len] + count[len];
8827    }
8828    for (let sym = 0; sym < codeLengthsSize; ++sym) {
8829      if (codeLengths[sym] !== 0) {
8830        sorted[offset[codeLengths[sym]]++] = sym;
8831      }
8832    }
8833    let tableBits = rootBits;
8834    let tableSize = 1 << tableBits;
8835    let totalSize = tableSize;
8836    if (offset[15] === 1) {
8837      for (let k = 0; k < totalSize; ++k) {
8838        tableGroup[tableOffset + k] = sorted[0];
8839      }
8840      return totalSize;
8841    }
8842    let key = 0;
8843    let symbol = 0;
8844    let step = 1;
8845    for (let len = 1; len <= rootBits; ++len) {
8846      step = step << 1;
8847      while (count[len] > 0) {
8848        replicateValue(tableGroup, tableOffset + key, step, tableSize, len << 16 | sorted[symbol++]);
8849        key = getNextKey(key, len);
8850        count[len]--;
8851      }
8852    }
8853    const mask = totalSize - 1;
8854    let low = -1;
8855    let currentOffset = tableOffset;
8856    step = 1;
8857    for (let len = rootBits + 1; len <= 15; ++len) {
8858      step = step << 1;
8859      while (count[len] > 0) {
8860        if ((key & mask) !== low) {
8861          currentOffset += tableSize;
8862          tableBits = nextTableBitSize(count, len, rootBits);
8863          tableSize = 1 << tableBits;
8864          totalSize += tableSize;
8865          low = key & mask;
8866          tableGroup[tableOffset + low] = tableBits + rootBits << 16 | currentOffset - tableOffset - low;
8867        }
8868        replicateValue(tableGroup, currentOffset + (key >> rootBits), step, tableSize, len - rootBits << 16 | sorted[symbol++]);
8869        key = getNextKey(key, len);
8870        count[len]--;
8871      }
8872    }
8873    return totalSize;
8874  }
8875  function readMoreInput(s) {
8876    if (s.endOfStreamReached !== 0) {
8877      if (halfAvailable(s) >= -2) {
8878        return 0;
8879      }
8880      return makeError(s, -16);
8881    }
8882    const readOffset = s.halfOffset << 1;
8883    let bytesInBuffer = 4096 - readOffset;
8884    s.byteBuffer.copyWithin(0, readOffset, 4096);
8885    s.halfOffset = 0;
8886    while (bytesInBuffer < 4096) {
8887      const spaceLeft = 4096 - bytesInBuffer;
8888      const len = readInput(s, s.byteBuffer, bytesInBuffer, spaceLeft);
8889      if (len < -1) {
8890        return len;
8891      }
8892      if (len <= 0) {
8893        s.endOfStreamReached = 1;
8894        s.tailBytes = bytesInBuffer;
8895        bytesInBuffer += 1;
8896        break;
8897      }
8898      bytesInBuffer += len;
8899    }
8900    bytesToNibbles(s, bytesInBuffer);
8901    return 0;
8902  }
8903  function checkHealth(s, endOfStream) {
8904    if (s.endOfStreamReached === 0) {
8905      return 0;
8906    }
8907    const byteOffset = (s.halfOffset << 1) + (s.bitOffset + 7 >> 3) - 4;
8908    if (byteOffset > s.tailBytes) {
8909      return makeError(s, -13);
8910    }
8911    if (endOfStream !== 0 && byteOffset !== s.tailBytes) {
8912      return makeError(s, -17);
8913    }
8914    return 0;
8915  }
8916  function readFewBits(s, n) {
8917    const v = s.accumulator32 >>> s.bitOffset & (1 << n) - 1;
8918    s.bitOffset += n;
8919    return v;
8920  }
8921  function readManyBits(s, n) {
8922    const low = readFewBits(s, 16);
8923    s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8924    s.bitOffset -= 16;
8925    return low | readFewBits(s, n - 16) << 16;
8926  }
8927  function initBitReader(s) {
8928    s.byteBuffer = new Int8Array(4160);
8929    s.accumulator32 = 0;
8930    s.shortBuffer = new Int16Array(2080);
8931    s.bitOffset = 32;
8932    s.halfOffset = 2048;
8933    s.endOfStreamReached = 0;
8934    return prepare(s);
8935  }
8936  function prepare(s) {
8937    if (s.halfOffset > 2030) {
8938      const result = readMoreInput(s);
8939      if (result !== 0) {
8940        return result;
8941      }
8942    }
8943    let health = checkHealth(s, 0);
8944    if (health !== 0) {
8945      return health;
8946    }
8947    s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8948    s.bitOffset -= 16;
8949    s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
8950    s.bitOffset -= 16;
8951    return 0;
8952  }
8953  function reload(s) {
8954    if (s.bitOffset === 32) {
8955      return prepare(s);
8956    }
8957    return 0;
8958  }
8959  function jumpToByteBoundary(s) {
8960    const padding = 32 - s.bitOffset & 7;
8961    if (padding !== 0) {
8962      const paddingBits = readFewBits(s, padding);
8963      if (paddingBits !== 0) {
8964        return makeError(s, -5);
8965      }
8966    }
8967    return 0;
8968  }
8969  function halfAvailable(s) {
8970    let limit = 2048;
8971    if (s.endOfStreamReached !== 0) {
8972      limit = s.tailBytes + 1 >> 1;
8973    }
8974    return limit - s.halfOffset;
8975  }
8976  function copyRawBytes(s, data, offset, length) {
8977    let pos = offset;
8978    let len = length;
8979    if ((s.bitOffset & 7) !== 0) {
8980      return makeError(s, -30);
8981    }
8982    while (s.bitOffset !== 32 && len !== 0) {
8983      data[pos++] = s.accumulator32 >>> s.bitOffset;
8984      s.bitOffset += 8;
8985      len--;
8986    }
8987    if (len === 0) {
8988      return 0;
8989    }
8990    const copyNibbles = Math.min(halfAvailable(s), len >> 1);
8991    if (copyNibbles > 0) {
8992      const readOffset = s.halfOffset << 1;
8993      const delta = copyNibbles << 1;
8994      data.set(s.byteBuffer.subarray(readOffset, readOffset + delta), pos);
8995      pos += delta;
8996      len -= delta;
8997      s.halfOffset += copyNibbles;
8998    }
8999    if (len === 0) {
9000      return 0;
9001    }
9002    if (halfAvailable(s) > 0) {
9003      if (s.bitOffset >= 16) {
9004        s.accumulator32 = s.shortBuffer[s.halfOffset++] << 16 | s.accumulator32 >>> 16;
9005        s.bitOffset -= 16;
9006      }
9007      while (len !== 0) {
9008        data[pos++] = s.accumulator32 >>> s.bitOffset;
9009        s.bitOffset += 8;
9010        len--;
9011      }
9012      return checkHealth(s, 0);
9013    }
9014    while (len > 0) {
9015      const chunkLen = readInput(s, data, pos, len);
9016      if (chunkLen < -1) {
9017        return chunkLen;
9018      }
9019      if (chunkLen <= 0) {
9020        return makeError(s, -16);
9021      }
9022      pos += chunkLen;
9023      len -= chunkLen;
9024    }
9025    return 0;
9026  }
9027  function bytesToNibbles(s, byteLen) {
9028    const byteBuffer = s.byteBuffer;
9029    const halfLen = byteLen >> 1;
9030    const shortBuffer = s.shortBuffer;
9031    for (let i = 0; i < halfLen; ++i) {
9032      shortBuffer[i] = byteBuffer[i * 2] & 0xFF | (byteBuffer[i * 2 + 1] & 0xFF) << 8;
9033    }
9034  }
9035  const LOOKUP = new Int32Array(2048);
9036  function unpackLookupTable(lookup, utfMap, utfRle) {
9037    for (let i = 0; i < 256; ++i) {
9038      lookup[i] = i & 0x3F;
9039      lookup[512 + i] = i >> 2;
9040      lookup[1792 + i] = 2 + (i >> 6);
9041    }
9042    for (let i = 0; i < 128; ++i) {
9043      lookup[1024 + i] = 4 * (utfMap.charCodeAt(i) - 32);
9044    }
9045    for (let i = 0; i < 64; ++i) {
9046      lookup[1152 + i] = i & 1;
9047      lookup[1216 + i] = 2 + (i & 1);
9048    }
9049    let offset = 1280;
9050    for (let k = 0; k < 19; ++k) {
9051      const value = k & 3;
9052      const rep = utfRle.charCodeAt(k) - 32;
9053      for (let i = 0; i < rep; ++i) {
9054        lookup[offset++] = value;
9055      }
9056    }
9057    for (let i = 0; i < 16; ++i) {
9058      lookup[1792 + i] = 1;
9059      lookup[2032 + i] = 6;
9060    }
9061    lookup[1792] = 0;
9062    lookup[2047] = 7;
9063    for (let i = 0; i < 256; ++i) {
9064      lookup[1536 + i] = lookup[1792 + i] << 3;
9065    }
9066  }
9067  unpackLookupTable(LOOKUP, "         !!  !                  \"#$##%#$&'##(#)#++++++++++((&*'##,---,---,-----,-----,-----&#'###.///.///./////./////./////&#'# ", "A/*  ':  & : $  \x81 @");
9068  function State() {
9069    this.ringBuffer = new Int8Array(0);
9070    this.contextModes = new Int8Array(0);
9071    this.contextMap = new Int8Array(0);
9072    this.distContextMap = new Int8Array(0);
9073    this.distExtraBits = new Int8Array(0);
9074    this.output = new Int8Array(0);
9075    this.byteBuffer = new Int8Array(0);
9076    this.shortBuffer = new Int16Array(0);
9077    this.intBuffer = new Int32Array(0);
9078    this.rings = new Int32Array(0);
9079    this.blockTrees = new Int32Array(0);
9080    this.literalTreeGroup = new Int32Array(0);
9081    this.commandTreeGroup = new Int32Array(0);
9082    this.distanceTreeGroup = new Int32Array(0);
9083    this.distOffset = new Int32Array(0);
9084    this.accumulator64 = 0;
9085    this.runningState = 0;
9086    this.nextRunningState = 0;
9087    this.accumulator32 = 0;
9088    this.bitOffset = 0;
9089    this.halfOffset = 0;
9090    this.tailBytes = 0;
9091    this.endOfStreamReached = 0;
9092    this.metaBlockLength = 0;
9093    this.inputEnd = 0;
9094    this.isUncompressed = 0;
9095    this.isMetadata = 0;
9096    this.literalBlockLength = 0;
9097    this.numLiteralBlockTypes = 0;
9098    this.commandBlockLength = 0;
9099    this.numCommandBlockTypes = 0;
9100    this.distanceBlockLength = 0;
9101    this.numDistanceBlockTypes = 0;
9102    this.pos = 0;
9103    this.maxDistance = 0;
9104    this.distRbIdx = 0;
9105    this.trivialLiteralContext = 0;
9106    this.literalTreeIdx = 0;
9107    this.commandTreeIdx = 0;
9108    this.j = 0;
9109    this.insertLength = 0;
9110    this.contextMapSlice = 0;
9111    this.distContextMapSlice = 0;
9112    this.contextLookupOffset1 = 0;
9113    this.contextLookupOffset2 = 0;
9114    this.distanceCode = 0;
9115    this.numDirectDistanceCodes = 0;
9116    this.distancePostfixBits = 0;
9117    this.distance = 0;
9118    this.copyLength = 0;
9119    this.maxBackwardDistance = 0;
9120    this.maxRingBufferSize = 0;
9121    this.ringBufferSize = 0;
9122    this.expectedTotalSize = 0;
9123    this.outputOffset = 0;
9124    this.outputLength = 0;
9125    this.outputUsed = 0;
9126    this.ringBufferBytesWritten = 0;
9127    this.ringBufferBytesReady = 0;
9128    this.isEager = 0;
9129    this.isLargeWindow = 0;
9130    this.cdNumChunks = 0;
9131    this.cdTotalSize = 0;
9132    this.cdBrIndex = 0;
9133    this.cdBrOffset = 0;
9134    this.cdBrLength = 0;
9135    this.cdBrCopied = 0;
9136    this.cdChunks = new Array(0);
9137    this.cdChunkOffsets = new Int32Array(0);
9138    this.cdBlockBits = 0;
9139    this.cdBlockMap = new Int8Array(0);
9140    this.input = new InputStream(new Int8Array(0));
9141    this.ringBuffer = new Int8Array(0);
9142    this.rings = new Int32Array(10);
9143    this.rings[0] = 16;
9144    this.rings[1] = 15;
9145    this.rings[2] = 11;
9146    this.rings[3] = 4;
9147  }
9148  let data = new Int8Array(0);
9149  const offsets = new Int32Array(32);
9150  const sizeBits = new Int32Array(32);
9151  function setData(newData, newSizeBits) {
9152    const dictionaryOffsets = offsets;
9153    const dictionarySizeBits = sizeBits;
9154    for (let i = 0; i < newSizeBits.length; ++i) {
9155      dictionarySizeBits[i] = newSizeBits[i];
9156    }
9157    let pos = 0;
9158    for (let i = 0; i < newSizeBits.length; ++i) {
9159      dictionaryOffsets[i] = pos;
9160      const bits = dictionarySizeBits[i];
9161      if (bits !== 0) {
9162        pos += i << (bits & 31);
9163      }
9164    }
9165    for (let i = newSizeBits.length; i < 32; ++i) {
9166      dictionaryOffsets[i] = pos;
9167    }
9168    data = newData;
9169  }
9170  function unpackDictionaryData(dictionary, data0, data1, skipFlip, sizeBits, sizeBitsData) {
9171    const dict = toUsAsciiBytes(data0 + data1);
9172    const skipFlipRunes = toUtf8Runes(skipFlip);
9173    let offset = 0;
9174    const n = skipFlipRunes.length >> 1;
9175    for (let i = 0; i < n; ++i) {
9176      const skip = skipFlipRunes[2 * i] - 36;
9177      const flip = skipFlipRunes[2 * i + 1] - 36;
9178      for (let j = 0; j < skip; ++j) {
9179        dict[offset] = dict[offset] ^ 3;
9180        offset++;
9181      }
9182      for (let j = 0; j < flip; ++j) {
9183        dict[offset] = dict[offset] ^ 236;
9184        offset++;
9185      }
9186    }
9187    for (let i = 0; i < sizeBitsData.length; ++i) {
9188      sizeBits[i] = sizeBitsData.charCodeAt(i) - 65;
9189    }
9190    dictionary.set(dict);
9191  }
9192  const dictionaryData = new Int8Array(122784);
9193  const dictionarySizeBits = new Int32Array(25);
9194  unpackDictionaryData(dictionaryData, "wjnfgltmojefofewab`h`lgfgbwbpkltlmozpjwf`jwzlsfmivpwojhfeqfftlqhwf{wzfbqlufqalgzolufelqnallhsobzojufojmfkfosklnfpjgfnlqftlqgolmdwkfnujftejmgsbdfgbzpevookfbgwfqnfb`kbqfbeqlnwqvfnbqhbaofvslmkjdkgbwfobmgmftpfufmmf{w`bpfalwkslpwvpfgnbgfkbmgkfqftkbwmbnfOjmhaoldpjyfabpfkfognbhfnbjmvpfq$*#(klogfmgptjwkMftpqfbgtfqfpjdmwbhfkbufdbnfpffm`boosbwktfoosovpnfmvejonsbqwiljmwkjpojpwdllgmffgtbzptfpwilapnjmgboploldlqj`kvpfpobpwwfbnbqnzellghjmdtjoofbpwtbqgafpwejqfSbdfhmltbtbz-smdnlufwkbmolbgdjufpfoemlwfnv`keffgnbmzql`hj`lmlm`follhkjgfgjfgKlnfqvofklpwbib{jmel`ovaobtpofppkboeplnfpv`kylmf233&lmfp`bqfWjnfqb`faovfelvqtffheb`fklsfdbufkbqgolpwtkfmsbqhhfswsbpppkjsqllnKWNOsobmWzsfglmfpbufhffseobdojmhplogejufwllhqbwfwltmivnswkvpgbqh`bqgejofefbqpwbzhjoowkbweboobvwlfufq-`lnwbohpklsulwfgffsnlgfqfpwwvqmalqmabmgefooqlpfvqo+phjmqlof`lnfb`wpbdfpnffwdlog-isdjwfnubqzefowwkfmpfmggqlsUjft`lsz2-3!?,b=pwlsfopfojfpwlvqsb`h-djesbpw`pp<dqbznfbm%dw8qjgfpklwobwfpbjgqlbgubq#effoilkmqj`hslqwebpw$VB.gfbg?,a=sllqajoowzsfV-P-tllgnvpw1s{8JmelqbmhtjgftbmwtbooofbgX3^8sbvotbufpvqf'+$ tbjwnbppbqnpdlfpdbjmobmdsbjg\"..#ol`hvmjwqllwtbohejqntjef{no!plmdwfpw13s{hjmgqltpwlloelmwnbjopbefpwbqnbsp`lqfqbjmeoltabazpsbmpbzp7s{85s{8bqwpellwqfbotjhjkfbwpwfswqjslqd,obhftfbhwlogElqn`bpwebmpabmhufqzqvmpivozwbph2s{8dlbodqftpoltfgdfjg>!pfwp6s{8-ip<73s{je#+pllmpfbwmlmfwvafyfqlpfmwqffgeb`wjmwldjewkbqn2;s{`bnfkjooalogyllnuljgfbpzqjmdejoosfbhjmjw`lpw0s{8ib`hwbdpajwpqloofgjwhmftmfbq?\"..dqltIPLMgvwzMbnfpbofzlv#olwpsbjmibyy`logfzfpejpkttt-qjphwbapsqfu23s{qjpf16s{Aovfgjmd033/abooelqgfbqmtjogal{-ebjqob`hufqpsbjqivmfwf`kje+\"sj`hfujo'+! tbqnolqgglfpsvoo/333jgfbgqbtkvdfpslwevmgavqmkqfe`foohfzpwj`hklvqolppevfo21s{pvjwgfboQPP!bdfgdqfzDFW!fbpfbjnpdjqobjgp;s{8mbuzdqjgwjsp :::tbqpobgz`bqp*8#~sks<kfoowbootklnyk9\t),\x0E\t#233kboo-\t\tB4s{8svpk`kbw3s{8`qft),?,kbpk46s{eobwqbqf#%%#wfoo`bnslmwlobjgnjppphjswfmwejmfnbofdfwpsolw733/\x0E\t\x0E\t`lloeffw-sks?aq=fqj`nlpwdvjgafoogfp`kbjqnbwkbwln,jnd% ;1ov`h`fmw3338wjmzdlmfkwnopfoogqvdEQFFmlgfmj`h<jg>olpfmvooubpwtjmgQPP#tfbqqfozaffmpbnfgvhfmbpb`bsftjpkdvoeW109kjwppolwdbwfhj`haovqwkfz26s{$$*8*8!=npjftjmpajqgplqwafwbpffhW2;9lqgpwqffnboo53s{ebqn\x0ElupalzpX3^-$*8!SLPWafbqhjgp*8~~nbqzwfmg+VH*rvbgyk9\n.pjy....sqls$*8\x0EojewW2:9uj`fbmgzgfaw=QPPsllomf`haoltW259gllqfuboW249ofwpebjolqbosloomlub`lopdfmf#\x0Elxplewqlnfwjooqlpp?k0=slvqebgfsjmh?wq=njmj*\x7F\"+njmfyk9\x04abqpkfbq33*8njoh#..=jqlmeqfggjphtfmwpljosvwp,ip,klozW119JPAMW139bgbnpffp?k1=iplm$/#$`lmwW129#QPPollsbpjbnllm?,s=plvoOJMFelqw`bqwW279?k2=;3s{\"..?:s{8W379njhf975Ymj`fjm`kZlqhqj`fyk9\b$**8svqfnbdfsbqbwlmfalmg904Y\\le\\$^*8333/yk9\x0Bwbmhzbqgaltoavpk965YIbub03s{\t\x7F~\t&@0&907YifeeF[SJ`bpkujpbdloepmltyk9\x05rvfq-`pppj`hnfbwnjm-ajmggfookjqfsj`pqfmw905YKWWS.132elwltloeFMG#{al{967YALGZgj`h8\t~\tf{jw906Yubqpafbw$~*8gjfw:::8bmmf~~?,Xj^-Obmdhn.^tjqfwlzpbggppfbobof{8\t\n~f`klmjmf-lqd336*wlmziftppbmgofdpqlle333*#133tjmfdfbqgldpallwdbqz`vwpwzofwfnswjlm-{no`l`hdbmd'+$-63s{Sk-Gnjp`bobmolbmgfphnjofqzbmvmj{gjp`*8~\tgvpw`ojs*-\t\t43s{.133GUGp4^=?wbsfgfnlj((*tbdffvqlskjolswpklofEBRpbpjm.15WobapsfwpVQO#avoh`llh8~\x0E\tKFBGX3^*baaqivbm+2:;ofpkwtjm?,j=plmzdvzpev`hsjsf\x7F.\t\"331*mgltX2^8X^8\tOld#pbow\x0E\t\n\nabmdwqjnabwk*x\x0E\t33s{\t~*8hl9\0effpbg=\x0Ep9,,#X^8wloosovd+*x\tx\x0E\t#-ip$133sgvboalbw-ISD*8\t~rvlw*8\t\t$*8\t\x0E\t~\x0E1327132613251324132;132:13131312131113101317131613151314131;131:130313021301130013071306130513041320132113221323133:133;133413351336133713301331133213332:::2::;2::42::52::62::72::02::12::22::32:;:2:;;2:;42:;52:;62:;72:;02:;12:;22:;32:4:2:4;2:442:452:462:472:402:412:422:432:5:2:5;2:542:552:562:572:502:512:522:532:6:2:6;2:642:652:662:672:602:612:622:632333231720:73333::::`lnln/Mpfpwffpwbsfqlwlglkb`f`bgbb/]lajfmg/Abbp/Aujgb`bpllwqlelqlplollwqb`vbogjilpjgldqbmwjslwfnbgfafbodlrv/Efpwlmbgbwqfpsl`l`bpbabilwlgbpjmlbdvbsvfpvmlpbmwfgj`fovjpfoobnbzlylmbbnlqsjpllaqb`oj`foolgjlpklqb`bpj<[<\\<Q<\\<R<P=l<\\=l=o=n<\\<Q<Y<S<R<R=n<T<[<Q<R<X<R=n<R<Z<Y<R<Q<T=i<q<\\<Y<Y<]=g<P=g<~=g=m<R<^=g<^<R<q<R<R<]<s<R<W<T<Q<T<L<H<q<Y<p=g=n=g<r<Q<T<P<X<\\<{<\\<x<\\<q=o<r<]=n<Y<t<[<Y<U<Q=o<P<P<N=g=o<Z5m5f4O5j5i4K5i4U5o5h4O5d4]4C5f4K5m5e5k5d5h5i5h5o4K5d5h5k4D4_4K5h4I5j5k5f4O5f5n4C5k5h4G5i4D5k5h5d5h5f4D5h4K5f4D5o4X5f4K5i4O5i5j4F4D5f5h5j4A4D5k5i5i4X5d4Xejqpwujgflojdkwtlqognfgjbtkjwf`olpfaob`hqjdkwpnbooallhpsob`fnvpj`ejfoglqgfqsljmwubovfofufowbaofalbqgklvpfdqlvstlqhpzfbqppwbwfwlgbztbwfqpwbqwpwzofgfbwksltfqsklmfmjdkwfqqlqjmsvwbalvwwfqnpwjwofwllopfufmwol`bowjnfpobqdftlqgpdbnfppklqwpsb`fel`vp`ofbqnlgfoaol`hdvjgfqbgjlpkbqftlnfmbdbjmnlmfzjnbdfmbnfpzlvmdojmfpobwfq`lolqdqffmeqlmw%bns8tbw`kelq`fsqj`fqvofpafdjmbewfqujpjwjppvfbqfbpafoltjmgf{wlwboklvqpobafosqjmwsqfppavjowojmhppsffgpwvgzwqbgfelvmgpfmpfvmgfqpkltmelqnpqbmdfbggfgpwjoonlufgwbhfmbalufeobpkej{fglewfmlwkfqujftp`kf`hofdboqjufqjwfnprvj`hpkbsfkvnbmf{jpwdljmdnlujfwkjqgabpj`sfb`fpwbdftjgwkoldjmjgfbptqlwfsbdfpvpfqpgqjufpwlqfaqfbhplvwkulj`fpjwfpnlmwktkfqfavjogtkj`kfbqwkelqvnwkqffpslqwsbqwz@oj`holtfqojufp`obppobzfqfmwqzpwlqzvpbdfplvmg`lvqwzlvq#ajqwkslsvswzsfpbssozJnbdfafjmdvssfqmlwfpfufqzpkltpnfbmpf{wqbnbw`kwqb`hhmltmfbqozafdbmpvsfqsbsfqmlqwkofbqmdjufmmbnfgfmgfgWfqnpsbqwpDqlvsaqbmgvpjmdtlnbmebopfqfbgzbvgjlwbhfptkjof-`ln,ojufg`bpfpgbjoz`kjogdqfbwivgdfwklpfvmjwpmfufqaqlbg`lbpw`lufqbssofejofp`z`ofp`fmfsobmp`oj`htqjwfrvffmsjf`ffnbjoeqbnflogfqsklwlojnjw`b`kf`jujop`boffmwfqwkfnfwkfqfwlv`kalvmgqlzbobphfgtklofpjm`fpwl`h#mbnfebjwkkfbqwfnswzleefqp`lsfltmfgnjdkwboavnwkjmhaollgbqqbznbilqwqvpw`bmlmvmjlm`lvmwubojgpwlmfPwzofOldjmkbsszl``vqofew9eqfpkrvjwfejonpdqbgfmffgpvqabmejdkwabpjpklufqbvwl8qlvwf-kwnonj{fgejmboZlvq#pojgfwlsj`aqltmbolmfgqbtmpsojwqfb`kQjdkwgbwfpnbq`krvlwfdllgpOjmhpglvawbpzm`wkvnaboolt`kjfezlvwkmlufo23s{8pfqufvmwjokbmgp@kf`hPsb`frvfqzibnfpfrvbowtj`f3/333Pwbqwsbmfoplmdpqlvmgfjdkwpkjewtlqwkslpwpofbgptffhpbuljgwkfpfnjofpsobmfpnbqwboskbsobmwnbqhpqbwfpsobzp`objnpbofpwf{wppwbqptqlmd?,k0=wkjmd-lqd,nvowjkfbqgSltfqpwbmgwlhfmplojg+wkjpaqjmdpkjsppwbeewqjfg`boopevoozeb`wpbdfmwWkjp#,,..=bgnjmfdzswFufmw26s{8Fnbjowqvf!`qlpppsfmwaoldpal{!=mlwfgofbuf`kjmbpjyfpdvfpw?,k7=qlalwkfbuzwqvf/pfufmdqbmg`qjnfpjdmpbtbqfgbm`fskbpf=?\"..fm\\VP% 0:8133s{\\mbnfobwjmfmilzbib{-bwjlmpnjwkV-P-#klogpsfwfqjmgjbmbu!=`kbjmp`lqf`lnfpgljmdsqjlqPkbqf2::3pqlnbmojpwpibsbmeboopwqjboltmfqbdqff?,k1=bavpfbofqwlsfqb!.,,T`bqgpkjoopwfbnpSklwlwqvwk`ofbm-sks<pbjmwnfwboolvjpnfbmwsqlleaqjfeqlt!=dfmqfwqv`hollhpUbovfEqbnf-mfw,..=\t?wqz#x\tubq#nbhfp`lpwpsobjmbgvowrvfpwwqbjmobalqkfosp`bvpfnbdj`nlwlqwkfjq163s{ofbpwpwfsp@lvmw`lvogdobpppjgfpevmgpklwfobtbqgnlvwknlufpsbqjpdjufpgvw`kwf{bpeqvjwmvoo/\x7F\x7FX^8wls!=\t?\"..SLPW!l`fbm?aq,=eollqpsfbhgfswk#pjyfabmhp`bw`k`kbqw13s{8bojdmgfboptlvog63s{8vqo>!sbqhpnlvpfNlpw#---?,bnlmdaqbjmalgz#mlmf8abpfg`bqqzgqbewqfefqsbdf\\klnf-nfwfqgfobzgqfbnsqlufiljmw?,wq=gqvdp?\"..#bsqjojgfboboofmf{b`welqwk`lgfpoldj`Ujft#pffnpaobmhslqwp#+133pbufg\\ojmhdlbopdqbmwdqffhklnfpqjmdpqbwfg03s{8tklpfsbqpf+*8!#Aol`hojmv{ilmfpsj{fo$*8!=*8je+.ofewgbujgklqpfEl`vpqbjpfal{fpWqb`hfnfmw?,fn=abq!=-pq`>wltfqbow>!`baofkfmqz17s{8pfwvsjwbozpkbqsnjmlqwbpwftbmwpwkjp-qfpfwtkffodjqop,`pp,233&8`ovappwveeajaofulwfp#2333hlqfb~*8\x0E\tabmgprvfvf>#x~8;3s{8`hjmdx\x0E\t\n\nbkfbg`ol`hjqjpkojhf#qbwjlpwbwpElqn!zbkll*X3^8Balvwejmgp?,k2=gfavdwbphpVQO#>`foop~*+*821s{8sqjnfwfoopwvqmp3{533-isd!psbjmafb`kwb{fpnj`qlbmdfo..=?,djewppwfuf.ojmhalgz-~*8\t\nnlvmw#+2::EBR?,qldfqeqbmh@obpp1;s{8effgp?k2=?p`lwwwfpwp11s{8gqjmh*#\x7F\x7F#oftjppkboo 30:8#elq#olufgtbpwf33s{8ib9\x0Fnpjnlm?elmwqfsoznffwpvmwfq`kfbswjdkwAqbmg*#\">#gqfpp`ojspqllnplmhfznlajonbjm-Mbnf#sobwfevmmzwqffp`ln,!2-isdtnlgfsbqbnPWBQWofew#jggfm/#132*8\t~\telqn-ujqvp`kbjqwqbmptlqpwSbdfpjwjlmsbw`k?\"..\tl.`b`ejqnpwlvqp/333#bpjbmj((*xbglaf$*X3^jg>23alwk8nfmv#-1-nj-smd!hfujm`lb`k@kjogaqv`f1-isdVQO*(-isd\x7Fpvjwfpoj`fkbqqz213!#ptffwwq=\x0E\tmbnf>gjfdlsbdf#ptjpp..=\t\t eee8!=Old-`ln!wqfbwpkffw*#%%#27s{8poffsmwfmwejofgib9\x0Fojg>!`Mbnf!tlqpfpklwp.al{.gfowb\t%ow8afbqp97;Y?gbwb.qvqbo?,b=#psfmgabhfqpklsp>#!!8sks!=`wjlm20s{8aqjbmkfoolpjyf>l>&1E#iljmnbzaf?jnd#jnd!=/#eipjnd!#!*X3^NWlsAWzsf!mftozGbmph`yf`kwqbjohmltp?,k6=ebr!=yk.`m23*8\t.2!*8wzsf>aovfpwqvozgbujp-ip$8=\x0E\t?\"pwffo#zlv#k1=\x0E\telqn#ifpvp233&#nfmv-\x0E\t\n\x0E\ttbofpqjphpvnfmwggjmda.ojhwfb`kdje!#ufdbpgbmphffpwjpkrjspvlnjplaqfgfpgffmwqfwlglpsvfgfb/]lpfpw/Mwjfmfkbpwblwqlpsbqwfglmgfmvfulkb`fqelqnbnjpnlnfilqnvmglbrv/Ag/Abpp/_olbzvgbef`kbwlgbpwbmwlnfmlpgbwlplwqbppjwjlnv`klbklqbovdbqnbzlqfpwlpklqbpwfmfqbmwfpelwlpfpwbpsb/Apmvfubpbovgelqlpnfgjlrvjfmnfpfpslgfq`kjofpfq/Muf`fpgf`jqilp/Efpwbqufmwbdqvslkf`klfoolpwfmdlbnjdl`lpbpmjufodfmwfnjpnbbjqfpivojlwfnbpkb`jbebulqivmjlojaqfsvmwlavfmlbvwlqbaqjoavfmbwf{wlnbqylpbafqojpwbovfdl`/_nlfmfqlivfdlsfq/Vkbafqfpwlzmvm`bnvifqubolqevfqbojaqldvpwbjdvboulwlp`bplpdv/Absvfglplnlpbujplvpwfggfafmml`kfavp`bebowbfvqlppfqjfgj`kl`vqpl`obuf`bpbpof/_msobylobqdllaqbpujpwbbslzlivmwlwqbwbujpwl`qfbq`bnslkfnlp`jm`l`bqdlsjplplqgfmkb`fm/Mqfbgjp`lsfgql`fq`bsvfgbsbsfonfmlq/Vwjo`obqlilqdf`boofslmfqwbqgfmbgjfnbq`bpjdvffoobppjdol`l`kfnlwlpnbgqf`obpfqfpwlmj/]lrvfgbsbpbqabm`lkjilpujbifsbaol/Epwfujfmfqfjmlgfibqelmgl`bmbomlqwfofwqb`bvpbwlnbqnbmlpovmfpbvwlpujoobufmglsfpbqwjslpwfmdbnbq`loofubsbgqfvmjglubnlpylmbpbnalpabmgbnbqjbbavplnv`kbpvajqqjlibujujqdqbgl`kj`bboo/Ailufmgj`kbfpwbmwbofppbojqpvfolsfplpejmfpoobnbavp`l/Epwboofdbmfdqlsobybkvnlqsbdbqivmwbglaofjpobpalopbab/]lkbaobov`kb/mqfbgj`fmivdbqmlwbpuboofboo/M`bqdbglolqbabilfpw/Edvpwlnfmwfnbqjlejqnb`lpwlej`kbsobwbkldbqbqwfpofzfpbrvfonvpflabpfpsl`lpnjwbg`jfol`kj`lnjfgldbmbqpbmwlfwbsbgfafpsobzbqfgfppjfwf`lqwf`lqfbgvgbpgfpflujfilgfpfbbdvbp%rvlw8glnbjm`lnnlmpwbwvpfufmwpnbpwfqpzpwfnb`wjlmabmmfqqfnlufp`qloovsgbwfdolabonfgjvnejowfqmvnafq`kbmdfqfpvowsvaoj`p`qffm`kllpfmlqnbowqbufojppvfpplvq`fwbqdfwpsqjmdnlgvofnlajofptjw`ksklwlpalqgfqqfdjlmjwpfoepl`jbob`wjuf`lovnmqf`lqgelooltwjwof=fjwkfqofmdwkebnjozeqjfmgobzlvwbvwklq`qfbwfqfujftpvnnfqpfqufqsobzfgsobzfqf{sbmgsloj`zelqnbwglvaofsljmwppfqjfpsfqplmojujmdgfpjdmnlmwkpelq`fpvmjrvftfjdkwsflsoffmfqdzmbwvqfpfbq`kejdvqfkbujmd`vpwlnleepfwofwwfqtjmgltpvanjwqfmgfqdqlvspvsolbgkfbowknfwklgujgflpp`klloevwvqfpkbgltgfabwfubovfpLaif`wlwkfqpqjdkwpofbdvf`kqlnfpjnsofmlwj`fpkbqfgfmgjmdpfbplmqfslqwlmojmfprvbqfavwwlmjnbdfpfmbaofnlujmdobwfpwtjmwfqEqbm`fsfqjlgpwqlmdqfsfbwOlmglmgfwbjoelqnfggfnbmgpf`vqfsbppfgwlddofsob`fpgfuj`fpwbwj``jwjfppwqfbnzfooltbwwb`hpwqffweojdkwkjggfmjmel!=lsfmfgvpfevouboofz`bvpfpofbgfqpf`qfwpf`lmggbnbdfpslqwpf{`fswqbwjmdpjdmfgwkjmdpfeef`wejfogppwbwfpleej`fujpvbofgjwlqulovnfQfslqwnvpfvnnlujfpsbqfmwb``fppnlpwoznlwkfq!#jg>!nbqhfwdqlvmg`kbm`fpvqufzafelqfpznalonlnfmwpsff`knlwjlmjmpjgfnbwwfq@fmwfqlaif`wf{jpwpnjggofFvqlsfdqltwkofdb`znbmmfqfmlvdk`bqffqbmptfqlqjdjmslqwbo`ojfmwpfof`wqbmgln`olpfgwlsj`p`lnjmdebwkfqlswjlmpjnsozqbjpfgfp`bsf`klpfm`kvq`kgfejmfqfbplm`lqmfqlvwsvwnfnlqzjeqbnfsloj`fnlgfopMvnafqgvqjmdleefqppwzofphjoofgojpwfg`boofgpjoufqnbqdjmgfofwfafwwfqaqltpfojnjwpDolabopjmdoftjgdfw`fmwfqavgdfwmltqbs`qfgjw`objnpfmdjmfpbefwz`klj`fpsjqjw.pwzofpsqfbgnbhjmdmffgfgqvppjbsofbpff{wfmwP`qjswaqlhfmbooltp`kbqdfgjujgfeb`wlqnfnafq.abpfgwkflqz`lmejdbqlvmgtlqhfgkfosfg@kvq`kjnsb`wpklvogbotbzpoldl!#alwwlnojpw!=*xubq#sqfej{lqbmdfKfbgfq-svpk+`lvsofdbqgfmaqjgdfobvm`kQfujftwbhjmdujpjlmojwwofgbwjmdAvwwlmafbvwzwkfnfpelqdlwPfbq`kbm`klqbonlpwolbgfg@kbmdfqfwvqmpwqjmdqfolbgNlajofjm`lnfpvssozPlvq`flqgfqpujftfg%maps8`lvqpfBalvw#jpobmg?kwno#`llhjfmbnf>!bnbylmnlgfqmbguj`fjm?,b=9#Wkf#gjboldklvpfpAFDJM#Nf{j`lpwbqwp`fmwqfkfjdkwbggjmdJpobmgbppfwpFnsjqfP`kllofeelqwgjqf`wmfbqoznbmvboPfof`w-\t\tLmfiljmfgnfmv!=SkjojsbtbqgpkbmgofjnslqwLeej`fqfdbqgphjoopmbwjlmPslqwpgfdqfftffhoz#+f-d-afkjmggl`wlqolddfgvmjwfg?,a=?,afdjmpsobmwpbppjpwbqwjpwjppvfg033s{\x7F`bmbgbbdfm`zp`kfnfqfnbjmAqbyjopbnsofoldl!=afzlmg.p`bofb``fswpfqufgnbqjmfEllwfq`bnfqb?,k2=\t\\elqn!ofbufppwqfpp!#,=\x0E\t-dje!#lmolbgolbgfqL{elqgpjpwfqpvqujuojpwfmefnbofGfpjdmpjyf>!bssfbowf{w!=ofufopwkbmhpkjdkfqelq`fgbmjnbobmzlmfBeqj`bbdqffgqf`fmwSflsof?aq#,=tlmgfqsqj`fpwvqmfg\x7F\x7F#x~8nbjm!=jmojmfpvmgbztqbs!=ebjofg`fmpvpnjmvwfafb`lmrvlwfp263s{\x7Ffpwbwfqfnlwffnbjo!ojmhfgqjdkw8pjdmboelqnbo2-kwnopjdmvssqjm`feolbw9-smd!#elqvn-B``fppsbsfqpplvmgpf{wfmgKfjdkwpojgfqVWE.;!%bns8#Afelqf-#TjwkpwvgjlltmfqpnbmbdfsqlejwiRvfqzbmmvbosbqbnpalvdkwebnlvpdlldofolmdfqj((*#xjpqbfopbzjmdgf`jgfklnf!=kfbgfqfmpvqfaqbm`ksjf`fpaol`h8pwbwfgwls!=?qb`jmdqfpjyf..%dw8sb`jwzpf{vboavqfbv-isd!#23/333lawbjmwjwofpbnlvmw/#Jm`-`lnfgznfmv!#ozqj`pwlgbz-jmgffg`lvmwz\\oldl-EbnjozollhfgNbqhfwopf#jeSobzfqwvqhfz*8ubq#elqfpwdjujmdfqqlqpGlnbjm~fopfxjmpfqwAold?,ellwfqoldjm-ebpwfqbdfmwp?algz#23s{#3sqbdnbeqjgbzivmjlqgloobqsob`fg`lufqpsovdjm6/333#sbdf!=alpwlm-wfpw+bubwbqwfpwfg\\`lvmwelqvnpp`kfnbjmgf{/ejoofgpkbqfpqfbgfqbofqw+bssfbqPvanjwojmf!=algz!=\t)#WkfWklvdkpffjmdifqpfzMftp?,ufqjezf{sfqwjmivqztjgwk>@llhjfPWBQW#b`qlpp\\jnbdfwkqfbgmbwjufsl`hfwal{!=\tPzpwfn#Gbujg`bm`fqwbaofpsqlufgBsqjo#qfboozgqjufqjwfn!=nlqf!=albqgp`lolqp`bnsvpejqpw#\x7F\x7F#X^8nfgjb-dvjwbqejmjpktjgwk9pkltfgLwkfq#-sks!#bppvnfobzfqptjoplmpwlqfpqfojfeptfgfm@vpwlnfbpjoz#zlvq#Pwqjmd\t\tTkjowbzolq`ofbq9qfplqweqfm`kwklvdk!*#(#!?algz=avzjmdaqbmgpNfnafqmbnf!=lssjmdpf`wlq6s{8!=upsb`fslpwfqnbilq#`leeffnbqwjmnbwvqfkbssfm?,mbu=hbmpbpojmh!=Jnbdfp>ebopftkjof#kpsb`f3%bns8#\t\tJm##sltfqSlophj.`lolqilqgbmAlwwlnPwbqw#.`lvmw1-kwnomftp!=32-isdLmojmf.qjdkwnjoofqpfmjlqJPAM#33/333#dvjgfpubovf*f`wjlmqfsbjq-{no!##qjdkwp-kwno.aol`hqfdF{s9klufqtjwkjmujqdjmsklmfp?,wq=\x0Evpjmd#\t\nubq#=$*8\t\n?,wg=\t?,wq=\tabkbpbaqbpjodbofdlnbdzbqslophjpqsphj4]4C5d\bTA\nzk\x0BBl\bQ\x7F\x0BUm\x05Gx\bSM\nmC\bTA\twQ\nd}\bW@\bTl\bTF\ti@\tcT\x0BBM\x0B|j\x04BV\tqw\tcC\bWI\npa\tfM\n{Z\x05{X\bTF\bVV\bVK\t\x7Fm\x04kF\t[]\bPm\bTv\nsI\x0Bpg\t[I\bQp\x04mx\x0B_W\n^M\npe\x0BQ}\x0BGu\nel\npe\x04Ch\x04BV\bTA\tSo\nzk\x0BGL\x0BxD\nd[\x05Jz\x05MY\bQp\x04li\nfl\npC\x05{B\x05Nt\x0BwT\ti_\bTg\x04QQ\n|p\x0BXN\bQS\x0BxD\x04QC\bWZ\tpD\x0BVS\bTW\x05Nt\x04Yh\nzu\x04Kj\x05N}\twr\tHa\n_D\tj`\x0BQ}\x0BWp\nxZ\x04{c\tji\tBU\nbD\x04a|\tTn\tpV\nZd\nmC\x0BEV\x05{X\tc}\tTo\bWl\bUd\tIQ\tcg\x0Bxs\nXW\twR\x0Bek\tc}\t]y\tJn\nrp\neg\npV\nz\\\x05{W\npl\nz\\\nzU\tPc\t`{\bV@\nc|\bRw\ti_\bVb\nwX\tHv\x04Su\bTF\x0B_W\x0BWs\x0BsI\x05m\x7F\nTT\ndc\tUS\t}f\tiZ\bWz\tc}\x04MD\tBe\tiD\x0B@@\bTl\bPv\t}t\x04Sw\x04M`\x0BnU\tkW\x0Bed\nqo\x0BxY\tA|\bTz\x0By`\x04BR\x04BM\tia\x04XU\nyu\x04n^\tfL\tiI\nXW\tfD\bWz\bW@\tyj\t\x7Fm\tav\tBN\x0Bb\\\tpD\bTf\nY[\tJn\bQy\t[^\x0BWc\x0Byu\x04Dl\x04CJ\x0BWj\x0BHR\t`V\x0BuW\tQy\np@\x0BGu\x05pl\x04Jm\bW[\nLP\nxC\n`m\twQ\x05ui\x05\x7FR\nbI\twQ\tBZ\tWV\x04BR\npg\tcg\x05ti\x04CW\n_y\tRg\bQa\x0BQB\x0BWc\nYb\x05le\ngE\x04Su\nL[\tQ\x7F\tea\tdj\x0B]W\nb~\x04M`\twL\bTV\bVH\nt\x7F\npl\t|b\x05s_\bU|\bTa\x04oQ\x05lv\x04Sk\x04M`\bTv\x0BK}\nfl\tcC\x04oQ\x04BR\tHk\t|d\bQp\tHK\tBZ\x0BHR\bPv\x0BLx\x0BEZ\bT\x7F\bTv\tiD\x05oD\x05MU\x0BwB\x04Su\x05k`\x04St\ntC\tPl\tKg\noi\tjY\x0BxY\x04h}\nzk\bWZ\t\x7Fm\x0Be`\tTB\tfE\nzk\t`z\x04Yh\nV|\tHK\tAJ\tAJ\bUL\tp\\\tql\nYc\x04Kd\nfy\x04Yh\t[I\x0BDg\x04Jm\n]n\nlb\bUd\n{Z\tlu\tfs\x04oQ\bTW\x04Jm\x0BwB\tea\x04Yh\x04BC\tsb\tTn\nzU\n_y\x0BxY\tQ]\ngw\x04mt\tO\\\ntb\bWW\bQy\tmI\tV[\ny\\\naB\x0BRb\twQ\n]Q\x04QJ\bWg\x0BWa\bQj\ntC\bVH\nYm\x0Bxs\bVK\nel\bWI\x0BxY\x04Cq\ntR\x0BHV\bTl\bVw\tay\bQa\bVV\t}t\tdj\nr|\tp\\\twR\n{i\nTT\t[I\ti[\tAJ\x0Bxs\x0B_W\td{\x0BQ}\tcg\tTz\tA|\tCj\x0BLm\x05N}\x05m\x7F\nbK\tdZ\tp\\\t`V\tsV\np@\tiD\twQ\x0BQ}\bTf\x05ka\x04Jm\x0B@@\bV`\tzp\n@N\x04Sw\tiI\tcg\noi\x04Su\bVw\x04lo\x04Cy\tc}\x0Bb\\\tsU\x04BA\bWI\bTf\nxS\tVp\nd|\bTV\x0BbC\tNo\x05Ju\nTC\t|`\n{Z\tD]\bU|\tc}\x05lm\bTl\tBv\tPl\tc}\bQp\t\x7Fm\nLk\tkj\n@N\x04Sb\x04KO\tj_\tp\\\nzU\bTl\bTg\bWI\tcf\x04XO\bWW\ndz\x04li\tBN\nd[\bWO\x04MD\x0BKC\tdj\tI_\bVV\ny\\\x0BLm\x05xl\txB\tkV\x0Bb\\\x0BJW\x0BVS\tVx\x0BxD\td{\x04MD\bTa\t|`\x0BPz\x04R}\x0BWs\x04BM\nsI\x04CN\bTa\x04Jm\npe\ti_\npV\nrh\tRd\tHv\n~A\nxR\x0BWh\x0BWk\nxS\x0BAz\x0BwX\nbI\x04oQ\tfw\nqI\nV|\nun\x05z\x7F\x0Bpg\td\\\x0BoA\x05{D\ti_\x05xB\bT\x7F\t`V\x05qr\tTT\x04g]\x04CA\x0BuR\tVJ\tT`\npw\x0BRb\tI_\nCx\x04Ro\x0BsI\x04Cj\x04Kh\tBv\tWV\x04BB\x05oD\x05{D\nhc\x04Km\x0B^R\tQE\n{I\np@\nc|\x05Gt\tc}\x04Dl\nzU\x05qN\tsV\x05k}\tHh\x0B|j\nqo\x05u|\tQ]\x0Bek\x05\x7FZ\x04M`\x04St\npe\tdj\bVG\x0BeE\t\x7Fm\x0BWc\x04|I\n[W\tfL\bT\x7F\tBZ\x04Su\x0BKa\x04Cq\x05Nt\x04Y[\nqI\bTv\tfM\ti@\t}f\x04B\\\tQy\x0BBl\bWg\x04XD\x05kc\x0Bx[\bVV\tQ]\t\x7Fa\tPy\x0BxD\nfI\t}f\x05oD\tdj\tSG\x05ls\t~D\x04CN\n{Z\t\\v\n_D\nhc\x0Bx_\x04C[\tAJ\nLM\tVx\x04CI\tbj\tc^\tcF\ntC\x04Sx\twr\x04XA\bU\\\t|a\x0BK\\\bTV\bVj\nd|\tfs\x04CX\ntb\bRw\tVx\tAE\tA|\bT\x7F\x05Nt\x0BDg\tVc\bTl\x04d@\npo\t\x7FM\tcF\npe\tiZ\tBo\bSq\nfH\x04l`\bTx\bWf\tHE\x0BF{\tcO\tfD\nlm\x0BfZ\nlm\x0BeU\tdG\x04BH\bTV\tSi\x05MW\nwX\nz\\\t\\c\x04CX\nd}\tl}\bQp\bTV\tF~\bQ\x7F\t`i\ng@\x05nO\bUd\bTl\nL[\twQ\tji\ntC\t|J\nLU\naB\x0BxY\x04Kj\tAJ\x05uN\ti[\npe\x04Sk\x0BDg\x0Bx]\bVb\bVV\nea\tkV\nqI\bTa\x04Sk\nAO\tpD\ntb\nts\nyi\bVg\ti_\x0B_W\nLk\x05Nt\tyj\tfM\x04R\x7F\tiI\bTl\x0BwX\tsV\x0BMl\nyu\tAJ\bVj\x04KO\tWV\x0BA}\x0BW\x7F\nrp\tiD\x0B|o\x05lv\x0BsI\x04BM\td~\tCU\bVb\x04eV\npC\x0BwT\tj`\tc}\x0Bxs\x0Bps\x0Bvh\tWV\x0BGg\x0BAe\x0BVK\x0B]W\trg\x0BWc\x05F`\tBr\x0Bb\\\tdZ\bQp\nqI\x04kF\nLk\x0BAR\bWI\bTg\tbs\tdw\n{L\n_y\tiZ\bTA\tlg\bVV\bTl\tdk\n`k\ta{\ti_\x05{A\x05wj\twN\x0B@@\bTe\ti_\n_D\twL\nAH\x0BiK\x0Bek\n[]\tp_\tyj\bTv\tUS\t[r\n{I\nps\x05Gt\x0BVK\npl\x04S}\x0BWP\t|d\x04MD\x0BHV\bT\x7F\x04R}\x04M`\bTV\bVH\x05lv\x04Ch\bW[\x04Ke\tR{\x0B^R\tab\tBZ\tVA\tB`\nd|\nhs\x04Ke\tBe\x04Oi\tR{\td\\\x05nB\bWZ\tdZ\tVJ\x05Os\t\x7Fm\x04uQ\x0BhZ\x04Q@\x04QQ\nfI\bW[\x04B\\\x04li\nzU\nMd\x04M`\nxS\bVV\n\\}\x0BxD\t\x7Fm\bTp\x04IS\nc|\tkV\x05i~\tV{\x0BhZ\t|b\bWt\n@R\x0BoA\x0BnU\bWI\tea\tB`\tiD\tc}\tTz\x04BR\x0BQB\x05Nj\tCP\t[I\bTv\t`W\x05uN\x0Bpg\x0Bpg\x0BWc\tiT\tbs\twL\tU_\tc\\\t|h\x0BKa\tNr\tfL\nq|\nzu\nz\\\tNr\bUg\t|b\x04m`\bTv\nyd\nrp\bWf\tUX\x04BV\nzk\nd}\twQ\t}f\x04Ce\x0Bed\bTW\bSB\nxU\tcn\bTb\ne\x7F\ta\\\tSG\bU|\npV\nN\\\x04Kn\x0BnU\tAt\tpD\x0B^R\x0BIr\x04b[\tR{\tdE\x0BxD\x0BWK\x0BWA\bQL\bW@\x04Su\bUd\nDM\tPc\x04CA\x04Dl\x04oQ\tHs\x05wi\x04ub\n\x7Fa\bQp\x05Ob\nLP\bTl\x04Y[\x0BK}\tAJ\bQ\x7F\x04n^\x0BsA\bSM\nqM\bWZ\n^W\x0Bz{\x04S|\tfD\bVK\bTv\bPv\x04BB\tCP\x04dF\tid\x0Bxs\x04mx\x0Bws\tcC\ntC\tyc\x05M`\x0BW\x7F\nrh\bQp\x0BxD\x04\\o\nsI\x04_k\nzu\x04kF\tfD\x04Xs\x04XO\tjp\bTv\x04BS\x05{B\tBr\nzQ\nbI\tc{\x04BD\x04BV\x05nO\bTF\tca\x05Jd\tfL\tPV\tI_\nlK\x04`o\twX\npa\tgu\bP}\x05{^\bWf\n{I\tBN\npa\x04Kl\x0Bpg\tcn\tfL\x0Bvh\x04Cq\bTl\x0BnU\bSq\x04Cm\twR\bUJ\npe\nyd\nYg\x04Cy\x0BKW\tfD\nea\x04oQ\tj_\tBv\x04nM\x0BID\bTa\nzA\x05pl\n]n\bTa\tR{\tfr\n_y\bUg\x05{X\x05kk\x0BxD\x04|I\x05xl\nfy\x04Ce\x0BwB\nLk\x0Bd]\noi\n}h\tQ]\npe\bVw\x04Hk\x04OQ\nzk\tAJ\npV\bPv\ny\\\tA{\x04Oi\bSB\x04XA\x0BeE\tjp\nq}\tiD\x05qN\x0B^R\t\x7Fm\tiZ\tBr\bVg\noi\n\\X\tU_\nc|\x0BHV\bTf\tTn\x04\\N\x04\\N\nuB\x05lv\nyu\tTd\bTf\bPL\x0B]W\tdG\nA`\nw^\ngI\npe\tdw\nz\\\x05ia\bWZ\tcF\x04Jm\n{Z\bWO\x04_k\x04Df\x04RR\td\\\bVV\x0Bxs\x04BN\x05ti\x04lm\tTd\t]y\x0BHV\tSo\x0B|j\x04XX\tA|\x0BZ^\x0BGu\bTW\x05M`\x04kF\x0BhZ\x0BVK\tdG\x0BBl\tay\nxU\x05qE\x05nO\bVw\nqI\x04CX\ne\x7F\tPl\bWO\x0BLm\tdL\x05uH\x04Cm\tdT\x04fn\x0BwB\x05ka\x0BnU\n@M\nyT\tHv\t\\}\x04Kh\td~\x04Yh\x05k}\neR\td\\\bWI\t|b\tHK\tiD\bTW\x05MY\npl\bQ_\twr\x0BAx\tHE\bTg\bSq\x05vp\x0Bb\\\bWO\nOl\nsI\nfy\x0BID\t\\c\n{Z\n^~\npe\nAO\tTT\x0Bxv\x04k_\bWO\x0B|j\x0BwB\tQy\ti@\tPl\tHa\tdZ\x05k}\x04ra\tUT\x0BJc\x0Bed\np@\tQN\nd|\tkj\tHk\x04M`\noi\twr\td\\\nlq\no_\nlb\nL[\tac\x04BB\x04BH\x04Cm\npl\tIQ\bVK\x0Bxs\n`e\x0BiK\npa\x04Oi\tUS\bTp\tfD\nPG\x05kk\x04XA\nz\\\neg\x0BWh\twR\x05qN\nqS\tcn\x04lo\nxS\n^W\tBU\nt\x7F\tHE\tp\\\tfF\tfw\bVV\bW@\tak\x0BVK\x05ls\tVJ\bVV\x0BeE\x04\\o\nyX\nYm\x04M`\x05lL\nd|\nzk\tA{\x05sE\twQ\x04XT\nt\x7F\tPl\t]y\x0BwT\x05{p\x04MD\x0Bb\\\tQ]\x04Kj\tJn\nAH\x0BRb\tBU\tHK\t\\c\nfI\x05m\x7F\nqM\n@R\tSo\noi\x04BT\tHv\n_y\x04Kh\tBZ\t]i\bUJ\tV{\x04Sr\nbI\x0BGg\ta_\bTR\nfI\nfl\t[K\tII\x04S|\x0BuW\tiI\bWI\nqI\x0B|j\x04BV\bVg\bWZ\x04kF\x0Bx]\bTA\tab\tfr\ti@\tJd\tJd\x0Bps\nAO\bTa\x05xu\tiD\nzk\t|d\t|`\bW[\tlP\tdG\bVV\x0Bw}\x0BqO\ti[\bQ\x7F\bTz\x0BVF\twN\x05ts\tdw\bTv\neS\ngi\tNr\x05yS\npe\bVV\bSq\n`m\tyj\tBZ\x0BWX\bSB\tc\\\nUR\t[J\tc_\x04nM\bWQ\x0BAx\nMd\tBr\x05ui\x0BxY\bSM\x0BWc\x0B|j\x0Bxs\t}Q\tBO\bPL\bWW\tfM\nAO\tPc\x0BeU\x04e^\bTg\nqI\tac\bPv\tcF\x04oQ\tQ\x7F\x0BhZ\x05ka\nz\\\tiK\tBU\n`k\tCP\x04S|\x04M`\n{I\tS{\x04_O\tBZ\x04Zi\x04Sk\tps\tp\\\nYu\n]s\nxC\bWt\nbD\tkV\x0BGu\x05yS\nqA\t[r\neK\x04M`\tdZ\x05lL\bUg\bTl\nbD\tUS\x0Bb\\\tpV\ncc\x04S\\\tct\t`z\bPL\x0BWs\nA`\neg\bSq\x05uE\x04CR\x0BDg\t`W\x0Bz{\x0BWc\x04Sk\x04Sk\tbW\bUg\tea\nxZ\tiI\tUX\tVJ\nqn\tS{\x0BRb\bTQ\npl\x05Gt\x0BuW\x05uj\npF\nqI\tfL\t[I\tia\x04XO\nyu\x0BDg\x0Bed\tq{\x04VG\bQ\x7F\x05ka\tVj\tkV\txB\nd|\np@\tQN\tPc\tps\x04]j\tkV\toU\bTp\nzU\x05nB\x0BB]\ta{\bV@\n]n\x04m`\tcz\tR{\x04m`\bQa\x0BwT\bSM\x05MY\x05qN\tdj\x05~s\x0BQ}\x05MY\x0BMB\tBv\twR\bRg\x0BQ}\tql\x0BKC\nrm\x05xu\x04CC\x0BwB\x0Bvh\tBq\x04Xq\npV\ti_\x05Ob\x05uE\nbd\nqo\x0B{i\nC~\tBL\x0BeE\x05uH\bVj\x04Ey\x04Gz\x0BzR\x0B{i\tcf\n{Z\n]n\x04XA\x0BGu\x0BnU\thS\x0BGI\nCc\tHE\bTA\tHB\x04BH\x04Cj\nCc\bTF\tHE\nXI\tA{\bQ\x7F\tc\\\x0BmO\x0BWX\nfH\np@\x05MY\bTF\nlK\tBt\nzU\tTT\x04Km\x0BwT\npV\ndt\x0ByI\tVx\tQ\x7F\tRg\tTd\nzU\bRS\nLM\twA\x04nM\tTn\ndS\t]g\nLc\x0BwB\t}t\t[I\tCP\x04kX\x0BFm\x0BhZ\x05m\x7F\ti[\np@\x0BQ}\x0BW\x7F\t|d\nMO\nMd\tf_\tfD\tcJ\tHz\x0BRb\tio\tPy\x04Y[\nxU\tct\x0B@@\tww\bPv\x04BM\x04FF\ntb\x05v|\x0BKm\tBq\tBq\x04Kh\x04`o\nZd\x04XU\ti]\t|`\tSt\x04B\\\bQ\x7F\x0B_W\tTJ\nqI\t|a\tA{\x0BuP\x04MD\tPl\nxR\tfL\x0Bws\tc{\td\\\bV`\neg\tHK\x05kc\nd|\bVV\ny\\\x05kc\ti]\bVG\t`V\tss\tI_\tAE\tbs\tdu\nel\tpD\x0BW\x7F\nqs\x05lv\bSM\x04Zi\x0BVK\x05ia\x0BQB\tQ\x7F\n{Z\bPt\x0BKl\nlK\nhs\ndS\bVK\x05mf\nd^\tkV\tcO\nc|\bVH\t\\]\bTv\bSq\tmI\x0BDg\tVJ\tcn\ny\\\bVg\bTv\nyX\bTF\t]]\bTp\noi\nhs\x0BeU\nBf\tdj\x05Mr\n|p\t\\g\t]r\bVb\x05{D\nd[\x04XN\tfM\tO\\\x05s_\tcf\tiZ\x04XN\x0BWc\tqv\n`m\tU^\x05oD\nd|\x0BGg\tdE\x0Bwf\x04lo\x04u}\nd|\x05oQ\t`i\x04Oi\x0BxD\ndZ\nCx\x04Yw\nzk\ntb\ngw\tyj\tB`\nyX\x0Bps\ntC\x0BpP\x0Bqw\bPu\bPX\tDm\npw\x05Nj\tss\taG\x0Bxs\bPt\noL\x04Gz\tOk\ti@\ti]\x04eC\tIQ\tii\tdj\x0B@J\t|d\x05uh\bWZ\x0BeU\x0BnU\bTa\tcC\x04g]\nzk\x04Yh\bVK\nLU\np@\ntb\ntR\tCj\x0BNP\ti@\bP{\n\\}\n{c\nwX\tfL\bVG\tc{\t|`\tAJ\t|C\tfD\x05ln\t|d\tbs\nqI\x05{B\x0BAx\np@\nzk\x0BRb\x05Os\x0BWS\x04e^\x0BD_\tBv\x0BWd\bVb\x0Bxs\x0BeE\bRw\n]n\n|p\x0Bg|\tfw\x05kc\bTI\x05ka\n\\T\x04Sp\tju\x0Bps\npe\x05u|\x0BGr\bVe\tCU\x04]M\x04XU\x0BxD\bTa\tIQ\x0BWq\tCU\tam\tdj\bSo\x04Sw\x0BnU\x04Ch\tQ]\x05s_\bPt\tfS\bTa\t\\}\n@O\x04Yc\tUZ\bTx\npe\x0BnU\nzU\t|}\tiD\nz\\\bSM\x0BxD\x04BR\nzQ\tQN\x04]M\x04Yh\nLP\x0BFm\x0BLX\x05vc\x0Bql\x05ka\tHK\bVb\ntC\nCy\bTv\nuV\x04oQ\t`z\t[I\tB`\x0BRb\tyj\tsb\x0BWs\bTl\tkV\x0Bed\ne\x7F\x05lL\x0BxN\t\x7Fm\nJn\tjY\x0BxD\bVb\bSq\x0Byu\twL\x0BXL\bTA\tpg\tAt\tnD\x04XX\twR\npl\nhw\x05yS\nps\tcO\bW[\x0B|j\x04XN\tsV\tp\\\tBe\nb~\nAJ\n]e\x05k`\x05qN\tdw\tWV\tHE\x0BEV\x05Jz\tid\tB`\tzh\x05E]\tfD\bTg\x05qN\bTa\tja\x04Cv\bSM\nhc\bUe\x05t_\tie\x04g]\twQ\nPn\bVB\tjw\bVg\x0BbE\tBZ\x0BRH\bP{\tjp\n\\}\ta_\tcC\t|a\x0BD]\tBZ\ti[\tfD\x0BxW\no_\td\\\n_D\ntb\t\\c\tAJ\nlK\x04oQ\x04lo\x0BLx\x0BM@\bWZ\x04Kn\x0Bpg\nTi\nIv\n|r\x0B@}\x05Jz\x05Lm\x05Wh\x05k}\x05ln\x0BxD\n]s\x04gc\x0Bps\tBr\bTW\x0BBM\x05tZ\nBY\x04DW\tjf\x0BSW\x04C}\nqo\tdE\tmv\tIQ\bPP\bUb\x05lv\x04BC\nzQ\t[I\x0Bgl\nig\bUs\x04BT\x0BbC\bSq\tsU\tiW\nJn\tSY\tHK\trg\npV\x0BID\x0B|j\x04KO\t`S\t|a`vbmglfmujbqnbgqjgavp`bqjmj`jlwjfnslslqrvf`vfmwbfpwbglsvfgfmivfdlp`lmwqbfpw/Mmmlnaqfwjfmfmsfqejonbmfqbbnjdlp`jvgbg`fmwqlbvmrvfsvfgfpgfmwqlsqjnfqsqf`jlpfd/Vmavfmlpuloufqsvmwlppfnbmbkba/Abbdlpwlmvfulpvmjglp`bqolpfrvjslmj/]lpnv`klpbodvmb`lqqfljnbdfmsbqwjqbqqjabnbq/Abklnaqffnsoflufqgbg`bnajlnv`kbpevfqlmsbpbglo/Amfbsbqf`fmvfubp`vqplpfpwbabrvjfqlojaqlp`vbmwlb``fplnjdvfoubqjlp`vbwqlwjfmfpdqvslppfq/Mmfvqlsbnfgjlpeqfmwfb`fq`bgfn/Mplefqwb`l`kfpnlgfoljwbojbofwqbpbod/Vm`lnsqb`vbofpf{jpwf`vfqslpjfmglsqfmpboofdbqujbifpgjmfqlnvq`jbslgq/Msvfpwlgjbqjlsvfaolrvjfqfnbmvfosqlsjl`qjpjp`jfqwlpfdvqlnvfqwfevfmwf`fqqbqdqbmgffef`wlsbqwfpnfgjgbsqlsjbleqf`fwjfqqbf.nbjoubqjbpelqnbpevwvqllaifwlpfdvjqqjfpdlmlqnbpnjpnlp/Vmj`l`bnjmlpjwjlpqby/_mgfajglsqvfabwlofglwfm/Abifp/Vpfpsfql`l`jmblqjdfmwjfmgb`jfmwl`/Mgjykbaobqpfq/Abobwjmbevfqybfpwjoldvfqqbfmwqbq/E{jwlo/_sfybdfmgbu/Agflfujwbqsbdjmbnfwqlpibujfqsbgqfpe/M`jo`bafyb/Mqfbppbojgbfmu/Alibs/_mbavplpajfmfpwf{wlpoofubqsvfgbmevfqwf`ln/Vm`obpfpkvnbmlwfmjglajoablvmjgbgfpw/Mpfgjwbq`qfbgl<X<W=c=k=n<R<V<\\<V<T<W<T=a=n<R<^=m<Y<Y<_<R<S=l<T=n<\\<V<Y=e<Y=o<Z<Y<v<\\<V<]<Y<[<]=g<W<R<Q<T<~=m<Y<S<R<X<A=n<R=n<R<P=k<Y<P<Q<Y=n<W<Y=n=l<\\<[<R<Q<\\<_<X<Y<P<Q<Y<x<W=c<s=l<T<Q<\\=m<Q<T=i=n<Y<P<V=n<R<_<R<X<^<R=n=n<\\<P<M<D<|<P<\\=c<K=n<R<^<\\=m<^<\\<P<Y<P=o<N<\\<V<X<^<\\<Q<\\<P=a=n<T=a=n=o<~<\\<P=n<Y=i<S=l<R=n=o=n<Q<\\<X<X<Q=c<~<R=n=n=l<T<Q<Y<U<~<\\=m<Q<T<P=m<\\<P=n<R=n=l=o<]<r<Q<T<P<T=l<Q<Y<Y<r<r<r<W<T=j=a=n<\\<r<Q<\\<Q<Y<P<X<R<P<P<R<U<X<^<Y<R<Q<R=m=o<X\fHy\fIk\fHU\fId\fHy\fIl\fHT\fIk\fHy\fHR\fHy\fIg\fHx\fH\\\fHF\fH\\\fHD\fIk\fHc\fHy\fHy\fHS\fHA\fIl\fHk\fHT\fHy\fH\\\fHH\fIg\fHU\fIg\fHj\fHF\fHU\fIl\fHC\fHU\fHC\fHR\fHH\fHy\fHI\fHRibdqbm\fHj\fHp\fHp\fIg\fHi\fH@\fHJ\fIg\fH{\fHd\fHp\fHR\fH{\fHc\fHU\fHB\fHk\fHD\fHY\fHU\fHC\fIk\fHI\fIk\fHI\fIl\fHt\fH\\\fHp\fH@\fHJ\fIl\fHy\fHd\fHp\fIl\fHY\fIk\fHD\fHd\fHD\fHc\fHU\fH\\\fHe\fHT\fHB\fIk\fHy\fHB\fHY\fIg\fH^\fIk\fHT\fH@\fHB\fHd\fHJ\fIk\fH\x7F\fH\\\fHj\fHB\fH@\fHT\fHA\fH\\\fH@\fHD\fHv\fH^\fHB\fHD\fHj\fH{\fHT\fIl\fH^\fIl4U5h5e4I5h5e5k4\\4K4N4B4]4U4C4C4K5h5e5k4\\5k4Y5d4]4V5f4]5o4K5j5d5h4K4D5f5j4U4]4Z4\\5h5o5k5j4K5f5d5i5n4K5h4U5h5f4K5j4K5h5o5j4A4F5e5n4D5h5d4A4E4K4B4]5m5n4[4U4D4C4]5o5j4I4\\4K5o5i4K4K4A4C4I5h4K5m5f5k4D4U4Z5o5f5m4D4A4G5d5i5j5d5k5d4O5j4K4@4C4K5h5k4K4_5h5i4U5j4C5h5f4_4U4D4]4Y5h5e5i5j4\\4D5k4K4O5j5k5i4G5h5o5j4F4K5h4K4A5f4G5i4Y4]4X4]4A4A5d5h5d5m5f4K4\\4K5h5o5h5i4]4E4K5j4F4K5h5m4O4D5d4B4K4Y4O5j4F4K5j5k4K5h5f4U4Z5d5d5n4C4K4D5j4B5f4]4D5j4F5h5o5i4X4K4M5d5k5f4K4D5d5n4Y4Y5d5i4K4]5n5i4O4A4C5j4A5j4U4C5i4]4O5f4K4A4E5o4F4D4C5d5j5f4@4D5i5j5k4F4A4F4@5k4E4_5j4E5f4F5i5o4]4E4V4^4E5j5m4_4D5f4F5h5h5k5h5j4K4F5h5o5n5h4D5h5i4K4U5j5k4O5d5h4X5f4M5j5d4]4O5i4K5m5f5o4D5o5h4\\4K4F4]4F4D4D4O5j5k5i4_4K5j5o4D5f4U5m5n4C4A4_5j5h5k5i4X4U4]4O5k5h4X5k4]5n4[4]4[5h4Dsqlejofpfquj`fgfebvowkjnpfoegfwbjop`lmwfmwpvsslqwpwbqwfgnfppbdfpv``fppebpkjlm?wjwof=`lvmwqzb``lvmw`qfbwfgpwlqjfpqfpvowpqvmmjmdsql`fpptqjwjmdlaif`wpujpjaoftfo`lnfbqwj`ofvmhmltmmfwtlqh`lnsbmzgzmbnj`aqltpfqsqjub`zsqlaofnPfquj`fqfpsf`wgjpsobzqfrvfpwqfpfquftfapjwfkjpwlqzeqjfmgplswjlmptlqhjmdufqpjlmnjoojlm`kbmmfotjmglt-bggqfppujpjwfgtfbwkfq`lqqf`wsqlgv`wfgjqf`welqtbqgzlv#`bmqfnlufgpvaif`w`lmwqlobq`kjuf`vqqfmwqfbgjmdojaqbqzojnjwfgnbmbdfqevqwkfqpvnnbqznb`kjmfnjmvwfpsqjubwf`lmwf{wsqldqbnpl`jfwzmvnafqptqjwwfmfmbaofgwqjddfqplvq`fpolbgjmdfofnfmwsbqwmfqejmboozsfqef`wnfbmjmdpzpwfnphffsjmd`vowvqf%rvlw8/ilvqmbosqlif`wpvqeb`fp%rvlw8f{sjqfpqfujftpabobm`fFmdojpk@lmwfmwwkqlvdkSofbpf#lsjmjlm`lmwb`wbufqbdfsqjnbqzujoobdfPsbmjpkdboofqzgf`ojmfnffwjmdnjppjlmslsvobqrvbojwznfbpvqfdfmfqbopsf`jfppfppjlmpf`wjlmtqjwfqp`lvmwfqjmjwjboqfslqwpejdvqfpnfnafqpklogjmdgjpsvwffbqojfqf{sqfppgjdjwbosj`wvqfBmlwkfqnbqqjfgwqbeej`ofbgjmd`kbmdfg`fmwqbouj`wlqzjnbdfp,qfbplmppwvgjfpefbwvqfojpwjmdnvpw#afp`kllopUfqpjlmvpvboozfsjplgfsobzjmddqltjmdlaujlvplufqobzsqfpfmwb`wjlmp?,vo=\x0E\ttqbssfqboqfbgz`fqwbjmqfbojwzpwlqbdfbmlwkfqgfphwlsleefqfgsbwwfqmvmvpvboGjdjwbo`bsjwboTfapjwfebjovqf`lmmf`wqfgv`fgBmgqljggf`bgfpqfdvobq#%bns8#bmjnbopqfofbpfBvwlnbwdfwwjmdnfwklgpmlwkjmdSlsvobq`bswjlmofwwfqp`bswvqfp`jfm`foj`fmpf`kbmdfpFmdobmg>2%bns8Kjpwlqz#>#mft#@fmwqbovsgbwfgPsf`jboMfwtlqhqfrvjqf`lnnfmwtbqmjmd@loofdfwlloabqqfnbjmpaf`bvpffof`wfgGfvwp`kejmbm`ftlqhfqprvj`hozafwtffmf{b`wozpfwwjmdgjpfbpfPl`jfwztfbslmpf{kjajw%ow8\"..@lmwqlo`obppfp`lufqfglvwojmfbwwb`hpgfuj`fp+tjmgltsvqslpfwjwof>!Nlajof#hjoojmdpkltjmdJwbojbmgqlssfgkfbujozfeef`wp.2$^*8\t`lmejqn@vqqfmwbgubm`fpkbqjmdlsfmjmdgqbtjmdajoojlmlqgfqfgDfqnbmzqfobwfg?,elqn=jm`ovgftkfwkfqgfejmfgP`jfm`f`bwboldBqwj`ofavwwlmpobqdfpwvmjelqnilvqmfzpjgfabq@kj`bdlklojgbzDfmfqbosbppbdf/%rvlw8bmjnbwfeffojmdbqqjufgsbppjmdmbwvqboqlvdkoz-\t\tWkf#avw#mlwgfmpjwzAqjwbjm@kjmfpfob`h#lewqjavwfJqfobmg!#gbwb.eb`wlqpqf`fjufwkbw#jpOjaqbqzkvpabmgjm#eb`wbeebjqp@kbqofpqbgj`boaqlvdkwejmgjmdobmgjmd9obmd>!qfwvqm#ofbgfqpsobmmfgsqfnjvnsb`hbdfBnfqj`bFgjwjlm^%rvlw8Nfppbdfmffg#wlubovf>!`lnsof{ollhjmdpwbwjlmafojfufpnboofq.nlajofqf`lqgptbmw#wlhjmg#leEjqfel{zlv#bqfpjnjobqpwvgjfgnb{jnvnkfbgjmdqbsjgoz`ojnbwfhjmdglnfnfqdfgbnlvmwpelvmgfgsjlmffqelqnvobgzmbpwzklt#wl#Pvsslqwqfufmvff`lmlnzQfpvowpaqlwkfqplogjfqobqdfoz`boojmd-%rvlw8B``lvmwFgtbqg#pfdnfmwQlafqw#feelqwpSb`jej`ofbqmfgvs#tjwkkfjdkw9tf#kbufBmdfofpmbwjlmp\\pfbq`kbssojfgb`rvjqfnbppjufdqbmwfg9#ebopfwqfbwfgajddfpwafmfejwgqjujmdPwvgjfpnjmjnvnsfqkbspnlqmjmdpfoojmdjp#vpfgqfufqpfubqjbmw#qlof>!njppjmdb`kjfufsqlnlwfpwvgfmwplnflmff{wqfnfqfpwlqfalwwln9fuloufgboo#wkfpjwfnbsfmdojpktbz#wl##Bvdvpwpznalop@lnsbmznbwwfqpnvpj`bobdbjmpwpfqujmd~*+*8\x0E\tsbznfmwwqlvaof`lm`fsw`lnsbqfsbqfmwpsobzfqpqfdjlmpnlmjwlq#$$Wkf#tjmmjmdf{solqfbgbswfgDboofqzsqlgv`fbajojwzfmkbm`f`bqffqp*-#Wkf#`loof`wPfbq`k#bm`jfmwf{jpwfgellwfq#kbmgofqsqjmwfg`lmplofFbpwfqmf{slqwptjmgltp@kbmmfojoofdbomfvwqbopvddfpw\\kfbgfqpjdmjmd-kwno!=pfwwofgtfpwfqm`bvpjmd.tfahjw`objnfgIvpwj`f`kbswfquj`wjnpWklnbp#nlyjoobsqlnjpfsbqwjfpfgjwjlmlvwpjgf9ebopf/kvmgqfgLoznsj`\\avwwlmbvwklqpqfb`kfg`kqlmj`gfnbmgppf`lmgpsqlwf`wbglswfgsqfsbqfmfjwkfqdqfbwozdqfbwfqlufqboojnsqluf`lnnbmgpsf`jbopfbq`k-tlqpkjsevmgjmdwklvdkwkjdkfpwjmpwfbgvwjojwzrvbqwfq@vowvqfwfpwjmd`ofbqozf{slpfgAqltpfqojafqbo~#`bw`kSqlif`wf{bnsofkjgf+*8EolqjgbbmptfqpbooltfgFnsfqlqgfefmpfpfqjlvpeqffglnPfufqbo.avwwlmEvqwkfqlvw#le#\">#mvoowqbjmfgGfmnbqhuljg+3*,boo-ipsqfufmwQfrvfpwPwfskfm\t\tTkfm#lapfquf?,k1=\x0E\tNlgfqm#sqlujgf!#bow>!alqgfqp-\t\tElq#\t\tNbmz#bqwjpwpsltfqfgsfqelqnej`wjlmwzsf#lenfgj`bowj`hfwplsslpfg@lvm`jotjwmfppivpwj`fDflqdf#Afodjvn---?,b=wtjwwfqmlwbaoztbjwjmdtbqebqf#Lwkfq#qbmhjmdskqbpfpnfmwjlmpvqujufp`klobq?,s=\x0E\t#@lvmwqzjdmlqfgolpp#leivpw#bpDflqdjbpwqbmdf?kfbg=?pwlssfg2$^*8\x0E\tjpobmgpmlwbaofalqgfq9ojpw#le`bqqjfg233/333?,k0=\t#pfufqboaf`lnfppfof`w#tfggjmd33-kwnonlmbq`klee#wkfwfb`kfqkjdkoz#ajloldzojef#lelq#fufmqjpf#le%qbrvl8sovplmfkvmwjmd+wklvdkGlvdobpiljmjmd`jq`ofpElq#wkfBm`jfmwUjfwmbnufkj`ofpv`k#bp`qzpwboubovf#>Tjmgltpfmilzfgb#pnboobppvnfg?b#jg>!elqfjdm#Boo#qjklt#wkfGjpsobzqfwjqfgkltfufqkjggfm8abwwofppffhjmd`bajmfwtbp#mlwollh#bw`lmgv`wdfw#wkfIbmvbqzkbssfmpwvqmjmdb9klufqLmojmf#Eqfm`k#ob`hjmdwzsj`bof{wqb`wfmfnjfpfufm#jedfmfqbwgf`jgfgbqf#mlw,pfbq`kafojfep.jnbdf9ol`bwfgpwbwj`-oldjm!=`lmufqwujlofmwfmwfqfgejqpw!=`jq`vjwEjmobmg`kfnjpwpkf#tbp23s{8!=bp#pv`kgjujgfg?,psbm=tjoo#afojmf#leb#dqfbwnzpwfqz,jmgf{-eboojmdgvf#wl#qbjotbz`loofdfnlmpwfqgfp`fmwjw#tjwkmv`ofbqIftjpk#sqlwfpwAqjwjpkeoltfqpsqfgj`wqfelqnpavwwlm#tkl#tbpof`wvqfjmpwbmwpvj`jgfdfmfqj`sfqjlgpnbqhfwpPl`jbo#ejpkjmd`lnajmfdqbskj`tjmmfqp?aq#,=?az#wkf#MbwvqboSqjub`z`llhjfplvw`lnfqfploufPtfgjpkaqjfeozSfqpjbmpl#nv`k@fmwvqzgfsj`wp`lovnmpklvpjmdp`qjswpmf{w#wlafbqjmdnbssjmdqfujpfgiRvfqz+.tjgwk9wjwof!=wllowjsPf`wjlmgfpjdmpWvqhjpkzlvmdfq-nbw`k+~*+*8\t\tavqmjmdlsfqbwfgfdqffpplvq`f>Qj`kbqg`olpfozsobpwj`fmwqjfp?,wq=\x0E\t`lolq9 vo#jg>!slppfppqloojmdskzpj`pebjojmdf{f`vwf`lmwfpwojmh#wlGfebvow?aq#,=\t9#wqvf/`kbqwfqwlvqjpn`obppj`sql`ffgf{sobjm?,k2=\x0E\tlmojmf-<{no#ufkfosjmdgjbnlmgvpf#wkfbjqojmffmg#..=*-bwwq+qfbgfqpklpwjmd eeeeeeqfbojyfUjm`fmwpjdmbop#pq`>!,Sqlgv`wgfpsjwfgjufqpfwfoojmdSvaoj`#kfog#jmIlpfsk#wkfbwqfbeef`wp?pwzof=b#obqdfglfpm$wobwfq/#Fofnfmwebuj`lm`qfbwlqKvmdbqzBjqslqwpff#wkfpl#wkbwNj`kbfoPzpwfnpSqldqbnp/#bmg##tjgwk>f%rvlw8wqbgjmdofew!=\tsfqplmpDlogfm#Beebjqpdqbnnbqelqnjmdgfpwqlzjgfb#le`bpf#lelogfpw#wkjp#jp-pq`#>#`bqwllmqfdjpwq@lnnlmpNvpojnpTkbw#jpjm#nbmznbqhjmdqfufbopJmgffg/frvbooz,pklt\\blvwgllqfp`bsf+Bvpwqjbdfmfwj`pzpwfn/Jm#wkf#pjwwjmdKf#boplJpobmgpB`bgfnz\t\n\n?\"..Gbmjfo#ajmgjmdaol`h!=jnslpfgvwjojyfBaqbkbn+f{`fswxtjgwk9svwwjmd*-kwno+\x7F\x7F#X^8\tGBWBX#)hjw`kfmnlvmwfgb`wvbo#gjbof`wnbjmoz#\\aobmh$jmpwboof{sfqwpje+wzsfJw#bopl%`lsz8#!=Wfqnpalqm#jmLswjlmpfbpwfqmwbohjmd`lm`fqmdbjmfg#lmdljmdivpwjez`qjwj`peb`wlqzjwp#ltmbppbvowjmujwfgobpwjmdkjp#ltmkqfe>!,!#qfo>!gfufols`lm`fqwgjbdqbngloobqp`ovpwfqsks<jg>bo`lklo*8~*+*8vpjmd#b=?psbm=ufppfopqfujuboBggqfppbnbwfvqbmgqljgboofdfgjoomfpptbohjmd`fmwfqprvbojeznbw`kfpvmjejfgf{wjm`wGfefmpfgjfg#jm\t\n?\"..#`vpwlnpojmhjmdOjwwof#Allh#lefufmjmdnjm-ip<bqf#wkfhlmwbhwwlgbz$p-kwno!#wbqdfw>tfbqjmdBoo#Qjd8\t~*+*8qbjpjmd#Bopl/#`qv`jbobalvw!=gf`obqf..=\t?p`ejqfel{bp#nv`kbssojfpjmgf{/#p/#avw#wzsf#>#\t\x0E\t?\"..wltbqgpQf`lqgpSqjubwfElqfjdmSqfnjfq`klj`fpUjqwvboqfwvqmp@lnnfmwSltfqfgjmojmf8slufqwz`kbnafqOjujmd#ulovnfpBmwklmzoldjm!#QfobwfgF`lmlnzqfb`kfp`vwwjmddqbujwzojef#[email protected]?,wg=\x0E\t#qfwvqmpwbgjvntjgdfwpubqzjmdwqbufopkfog#aztkl#bqftlqh#jmeb`vowzbmdvobqtkl#kbgbjqslqwwltm#le\t\tPlnf#$`oj`h$`kbqdfphfztlqgjw#tjoo`jwz#le+wkjp*8Bmgqft#vmjrvf#`kf`hfglq#nlqf033s{8#qfwvqm8qpjlm>!sovdjmptjwkjm#kfqpfoePwbwjlmEfgfqboufmwvqfsvaojpkpfmw#wlwfmpjlmb`wqfpp`lnf#wlejmdfqpGvhf#lesflsof/f{soljwtkbw#jpkbqnlmzb#nbilq!9!kwwsjm#kjp#nfmv!=\tnlmwkozleej`fq`lvm`jodbjmjmdfufm#jmPvnnbqzgbwf#leolzbowzejwmfppbmg#tbpfnsfqlqpvsqfnfPf`lmg#kfbqjmdQvppjbmolmdfpwBoafqwbobwfqbopfw#le#pnboo!=-bssfmggl#tjwkefgfqboabmh#leafmfbwkGfpsjwf@bsjwbodqlvmgp*/#bmg#sfq`fmwjw#eqln`olpjmd`lmwbjmJmpwfbgejewffmbp#tfoo-zbkll-qfpslmgejdkwfqlap`vqfqfeof`wlqdbmj`>#Nbwk-fgjwjmdlmojmf#sbggjmdb#tkloflmfqqlqzfbq#lefmg#le#abqqjfqtkfm#jwkfbgfq#klnf#leqfpvnfgqfmbnfgpwqlmd=kfbwjmdqfwbjmp`olvgeqtbz#le#Nbq`k#2hmltjmdjm#sbqwAfwtffmofpplmp`olpfpwujqwvboojmhp!=`qlppfgFMG#..=ebnlvp#btbqgfgOj`fmpfKfbowk#ebjqoz#tfbowkznjmjnboBeqj`bm`lnsfwfobafo!=pjmdjmdebqnfqpAqbpjo*gjp`vppqfsob`fDqfdlqzelmw#`lsvqpvfgbssfbqpnbhf#vsqlvmgfgalwk#leaol`hfgpbt#wkfleej`fp`lolvqpje+gl`vtkfm#kffmelq`fsvpk+evBvdvpw#VWE.;!=Ebmwbpzjm#nlpwjmivqfgVpvboozebqnjmd`olpvqflaif`w#gfefm`fvpf#le#Nfgj`bo?algz=\tfujgfmwaf#vpfghfz@lgfpj{wffmJpobnj` 333333fmwjqf#tjgfoz#b`wjuf#+wzsflelmf#`bm`lolq#>psfbhfqf{wfmgpSkzpj`pwfqqbjm?walgz=evmfqboujftjmdnjggof#`qj`hfwsqlskfwpkjewfggl`wlqpQvppfoo#wbqdfw`lnsb`wbodfaqbpl`jbo.avoh#lenbm#bmg?,wg=\t#kf#ofew*-ubo+*ebopf*8oldj`boabmhjmdklnf#wlmbnjmd#Bqjylmb`qfgjwp*8\t~*8\telvmgfqjm#wvqm@loojmpafelqf#Avw#wkf`kbqdfgWjwof!=@bswbjmpsfoofgdlggfppWbd#..=Bggjmd9avw#tbpQf`fmw#sbwjfmwab`h#jm>ebopf%Ojm`lomtf#hmlt@lvmwfqIvgbjpnp`qjsw#bowfqfg$^*8\t##kbp#wkfvm`ofbqFufmw$/alwk#jmmlw#boo\t\t?\"..#sob`jmdkbqg#wl#`fmwfqplqw#le`ojfmwppwqffwpAfqmbqgbppfqwpwfmg#wlebmwbpzgltm#jmkbqalvqEqffglniftfoqz,balvw--pfbq`kofdfmgpjp#nbgfnlgfqm#lmoz#lmlmoz#wljnbdf!#ojmfbq#sbjmwfqbmg#mlwqbqfoz#b`qlmzngfojufqpklqwfq33%bns8bp#nbmztjgwk>!,)#?\"X@wjwof#>le#wkf#oltfpw#sj`hfg#fp`bsfgvpfp#lesflsofp#Svaoj`Nbwwkftwb`wj`pgbnbdfgtbz#elqobtp#lefbpz#wl#tjmgltpwqlmd##pjnsof~`bw`k+pfufmwkjmelal{tfmw#wlsbjmwfg`jwjyfmJ#glm$wqfwqfbw-#Plnf#tt-!*8\talnajmdnbjowl9nbgf#jm-#Nbmz#`bqqjfp\x7F\x7Fx~8tjtlqh#lepzmlmzngfefbwpebulqfglswj`bosbdfWqbvmofpp#pfmgjmdofew!=?`lnP`lqBoo#wkfiRvfqz-wlvqjpw@obppj`ebopf!#Tjokfonpvavqapdfmvjmfajpklsp-psojw+dolabo#elooltpalgz#lemlnjmbo@lmwb`wpf`vobqofew#wl`kjfeoz.kjggfm.abmmfq?,oj=\t\t-#Tkfm#jm#alwkgjpnjppF{solqfbotbzp#ujb#wkfpsb/]lotfoebqfqvojmd#bqqbmdf`bswbjmkjp#plmqvof#lekf#wllhjwpfoe/>3%bns8+`boofgpbnsofpwl#nbhf`ln,sbdNbqwjm#Hfmmfgzb``fswpevoo#lekbmgofgAfpjgfp,,..=?,baof#wlwbqdfwpfppfm`fkjn#wl#jwp#az#`lnnlm-njmfqbowl#wbhftbzp#wlp-lqd,obgujpfgsfmbowzpjnsof9je#wkfzOfwwfqpb#pklqwKfqafqwpwqjhfp#dqlvsp-ofmdwkeojdkwplufqobspoltoz#ofppfq#pl`jbo#?,s=\t\n\njw#jmwlqbmhfg#qbwf#levo=\x0E\t##bwwfnswsbjq#lenbhf#jwHlmwbhwBmwlmjlkbujmd#qbwjmdp#b`wjufpwqfbnpwqbssfg!*-`pp+klpwjofofbg#wlojwwof#dqlvsp/Sj`wvqf..=\x0E\t\x0E\t#qltp>!#laif`wjmufqpf?ellwfq@vpwlnU=?_,p`qploujmd@kbnafqpobufqztlvmgfgtkfqfbp\">#$vmgelq#boosbqwoz#.qjdkw9Bqbajbmab`hfg#`fmwvqzvmjw#lenlajof.Fvqlsf/jp#klnfqjph#legfpjqfg@ojmwlm`lpw#lebdf#le#af`lnf#mlmf#les%rvlw8Njggof#fbg$*X3@qjwj`ppwvgjlp=%`lsz8dqlvs!=bppfnaonbhjmd#sqfppfgtjgdfw-sp9!#<#qfavjowaz#plnfElqnfq#fgjwlqpgfobzfg@bmlmj`kbg#wkfsvpkjmd`obpp>!avw#bqfsbqwjboAbazolmalwwln#`bqqjfq@lnnbmgjwp#vpfBp#tjwk`lvqpfpb#wkjqggfmlwfpbopl#jmKlvpwlm13s{8!=b``vpfgglvaof#dlbo#leEbnlvp#*-ajmg+sqjfpwp#Lmojmfjm#Ivozpw#(#!d`lmpvowgf`jnbokfosevoqfujufgjp#ufqzq$($jswolpjmd#efnbofpjp#boplpwqjmdpgbzp#lebqqjuboevwvqf#?laif`welq`jmdPwqjmd+!#,=\t\n\nkfqf#jpfm`lgfg-##Wkf#aboollmglmf#az,`lnnlmad`lolqobt#le#Jmgjbmbbuljgfgavw#wkf1s{#0s{irvfqz-bewfq#bsloj`z-nfm#bmgellwfq.>#wqvf8elq#vpfp`qffm-Jmgjbm#jnbdf#>ebnjoz/kwws9,,#%maps8gqjufqpfwfqmbopbnf#bpmlwj`fgujftfqp~*+*8\t#jp#nlqfpfbplmpelqnfq#wkf#mftjp#ivpw`lmpfmw#Pfbq`ktbp#wkftkz#wkfpkjssfgaq=?aq=tjgwk9#kfjdkw>nbgf#le`vjpjmfjp#wkbwb#ufqz#Bgnjqbo#ej{fg8mlqnbo#NjppjlmSqfpp/#lmwbqjl`kbqpfwwqz#wl#jmubgfg>!wqvf!psb`jmdjp#nlpwb#nlqf#wlwboozeboo#le~*8\x0E\t##jnnfmpfwjnf#jmpfw#lvwpbwjpezwl#ejmggltm#wlolw#le#Sobzfqpjm#Ivmfrvbmwvnmlw#wkfwjnf#wlgjpwbmwEjmmjpkpq`#>#+pjmdof#kfos#leDfqnbm#obt#bmgobafofgelqfpwp`llhjmdpsb`f!=kfbgfq.tfoo#bpPwbmofzaqjgdfp,dolabo@qlbwjb#Balvw#X3^8\t##jw/#bmgdqlvsfgafjmd#b*xwkqltkf#nbgfojdkwfqfwkj`boEEEEEE!alwwln!ojhf#b#fnsolzpojuf#jmbp#pffmsqjmwfqnlpw#leva.ojmhqfif`wpbmg#vpfjnbdf!=pv``ffgeffgjmdMv`ofbqjmelqnbwl#kfosTlnfm$pMfjwkfqNf{j`bmsqlwfjm?wbaof#az#nbmzkfbowkzobtpvjwgfujpfg-svpk+xpfoofqppjnsoz#Wkqlvdk-`llhjf#Jnbdf+logfq!=vp-ip!=#Pjm`f#vmjufqpobqdfq#lsfm#wl\"..#fmgojfp#jm$^*8\x0E\t##nbqhfwtkl#jp#+!GLN@lnbmbdfglmf#elqwzsfle#Hjmdglnsqlejwpsqlslpfwl#pklt`fmwfq8nbgf#jwgqfppfgtfqf#jmnj{wvqfsqf`jpfbqjpjmdpq`#>#$nbhf#b#pf`vqfgAbswjpwulwjmd#\t\n\nubq#Nbq`k#1dqft#vs@ojnbwf-qfnlufphjoofgtbz#wkf?,kfbg=eb`f#leb`wjmd#qjdkw!=wl#tlqhqfgv`fpkbp#kbgfqf`wfgpklt+*8b`wjlm>allh#lebm#bqfb>>#!kww?kfbgfq\t?kwno=`lmelqneb`jmd#`llhjf-qfoz#lmklpwfg#-`vpwlnkf#tfmwavw#elqpsqfbg#Ebnjoz#b#nfbmplvw#wkfelqvnp-ellwbdf!=Nlajo@ofnfmwp!#jg>!bp#kjdkjmwfmpf..=?\"..efnbof#jp#pffmjnsojfgpfw#wkfb#pwbwfbmg#kjpebpwfpwafpjgfpavwwlm\\alvmgfg!=?jnd#Jmelal{fufmwp/b#zlvmdbmg#bqfMbwjuf#`kfbsfqWjnflvwbmg#kbpfmdjmfptlm#wkf+nlpwozqjdkw9#ejmg#b#.alwwlnSqjm`f#bqfb#lenlqf#lepfbq`k\\mbwvqf/ofdboozsfqjlg/obmg#lelq#tjwkjmgv`fgsqlujmdnjppjofol`boozBdbjmpwwkf#tbzh%rvlw8s{8!=\x0E\tsvpkfg#babmglmmvnfqbo@fqwbjmJm#wkjpnlqf#jmlq#plnfmbnf#jpbmg/#jm`qltmfgJPAM#3.`qfbwfpL`wlafqnbz#mlw`fmwfq#obwf#jmGfefm`ffmb`wfgtjpk#wlaqlbgoz`llojmdlmolbg>jw-#Wkfqf`lufqNfnafqpkfjdkw#bppvnfp?kwno=\tsflsof-jm#lmf#>tjmgltellwfq\\b#dllg#qfhobnblwkfqp/wl#wkjp\\`llhjfsbmfo!=Olmglm/gfejmfp`qvpkfgabswjpn`lbpwbopwbwvp#wjwof!#nluf#wlolpw#jmafwwfq#jnsojfpqjuboqzpfqufqp#PzpwfnSfqkbspfp#bmg#`lmwfmgeoltjmdobpwfg#qjpf#jmDfmfpjpujft#leqjpjmd#pffn#wlavw#jm#ab`hjmdkf#tjoodjufm#bdjujmd#`jwjfp-eolt#le#Obwfq#boo#avwKjdktbzlmoz#azpjdm#lekf#glfpgjeefqpabwwfqz%bns8obpjmdofpwkqfbwpjmwfdfqwbhf#lmqfevpfg`boofg#>VP%bnsPff#wkfmbwjufpaz#wkjppzpwfn-kfbg#le9klufq/ofpajbmpvqmbnfbmg#boo`lnnlm,kfbgfq\\\\sbqbnpKbqubqg,sj{fo-qfnlubopl#olmdqlof#leiljmwozphzp`qbVmj`lgfaq#,=\x0E\tBwobmwbmv`ofvp@lvmwz/svqfoz#`lvmw!=fbpjoz#avjog#blm`oj`hb#djufmsljmwfqk%rvlw8fufmwp#fopf#x\tgjwjlmpmlt#wkf/#tjwk#nbm#tkllqd,Tfalmf#bmg`buboqzKf#gjfgpfbwwof33/333#xtjmgltkbuf#wlje+tjmgbmg#jwpplofoz#n%rvlw8qfmftfgGfwqljwbnlmdpwfjwkfq#wkfn#jmPfmbwlqVp?,b=?Hjmd#leEqbm`jp.sqlgv`kf#vpfgbqw#bmgkjn#bmgvpfg#azp`lqjmdbw#klnfwl#kbufqfobwfpjajojwzeb`wjlmAveebolojmh!=?tkbw#kfeqff#wl@jwz#le`lnf#jmpf`wlqp`lvmwfglmf#gbzmfqulvpprvbqf#~8je+dljm#tkbwjnd!#bojp#lmozpfbq`k,wvfpgbzollpfozPlolnlmpf{vbo#.#?b#kqnfgjvn!GL#MLW#Eqbm`f/tjwk#b#tbq#bmgpf`lmg#wbhf#b#=\x0E\t\x0E\t\x0E\tnbqhfw-kjdktbzglmf#jm`wjujwz!obpw!=laojdfgqjpf#wl!vmgfejnbgf#wl#Fbqoz#sqbjpfgjm#jwp#elq#kjpbwkofwfIvsjwfqZbkll\"#wfqnfg#pl#nbmzqfbooz#p-#Wkf#b#tlnbm<ubovf>gjqf`w#qjdkw!#aj`z`ofb`jmd>!gbz#bmgpwbwjmdQbwkfq/kjdkfq#Leej`f#bqf#mltwjnfp/#tkfm#b#sbz#elqlm#wkjp.ojmh!=8alqgfqbqlvmg#bmmvbo#wkf#Mftsvw#wkf-`ln!#wbhjm#wlb#aqjfe+jm#wkfdqlvsp-8#tjgwkfmyznfppjnsof#jm#obwfxqfwvqmwkfqbszb#sljmwabmmjmdjmhp!=\t+*8!#qfb#sob`f_v330@bbalvw#bwq=\x0E\t\n\n``lvmw#djufp#b?P@QJSWQbjotbzwkfnfp,wlloal{AzJg+!{kvnbmp/tbw`kfpjm#plnf#je#+tj`lnjmd#elqnbwp#Vmgfq#avw#kbpkbmgfg#nbgf#azwkbm#jmefbq#legfmlwfg,jeqbnfofew#jmulowbdfjm#fb`kb%rvlw8abpf#leJm#nbmzvmgfqdlqfdjnfpb`wjlm#?,s=\x0E\t?vpwlnUb8%dw8?,jnslqwplq#wkbwnlpwoz#%bns8qf#pjyf>!?,b=?,kb#`obppsbppjufKlpw#>#TkfwkfqefqwjofUbqjlvp>X^8+ev`bnfqbp,=?,wg=b`wp#bpJm#plnf=\x0E\t\x0E\t?\"lqdbmjp#?aq#,=Afjijmd`bwbo/Lgfvwp`kfvqlsfvfvphbqbdbfjodfpufmphbfpsb/]bnfmpbifvpvbqjlwqbabiln/E{j`ls/Mdjmbpjfnsqfpjpwfnbl`wvaqfgvqbmwfb/]bgjqfnsqfpbnlnfmwlmvfpwqlsqjnfqbwqbu/Epdqb`jbpmvfpwqbsql`fplfpwbglp`bojgbgsfqplmbm/Vnfqlb`vfqgln/Vpj`bnjfnaqllefqwbpbodvmlpsb/Apfpfifnsolgfqf`klbgfn/Mpsqjubglbdqfdbqfmob`fpslpjaofklwfofppfujoobsqjnfql/Vowjnlfufmwlpbq`kjul`vowvqbnvifqfpfmwqbgbbmvm`jlfnabqdlnfq`bgldqbmgfpfpwvgjlnfilqfpefaqfqlgjpf/]lwvqjpnl`/_gjdlslqwbgbfpsb`jlebnjojbbmwlmjlsfqnjwfdvbqgbqbodvmbpsqf`jlpbodvjfmpfmwjglujpjwbpw/Awvol`lml`fqpfdvmgl`lmpfileqbm`jbnjmvwlppfdvmgbwfmfnlpfef`wlpn/Mobdbpfpj/_mqfujpwbdqbmbgb`lnsqbqjmdqfpldbq`/Abb``j/_mf`vbglqrvjfmfpjm`ovplgfafq/Mnbwfqjbklnaqfpnvfpwqbslgq/Abnb/]bmb/Vowjnbfpwbnlplej`jbowbnajfmmjmd/Vmpbovglpslgfnlpnfilqbqslpjwjlmavpjmfppklnfsbdfpf`vqjwzobmdvbdfpwbmgbqg`bnsbjdmefbwvqfp`bwfdlqzf{wfqmbo`kjogqfmqfpfqufgqfpfbq`kf{`kbmdfebulqjwfwfnsobwfnjojwbqzjmgvpwqzpfquj`fpnbwfqjbosqlgv`wpy.jmgf{9`lnnfmwpplewtbqf`lnsofwf`bofmgbqsobwelqnbqwj`ofpqfrvjqfgnlufnfmwrvfpwjlmavjogjmdslojwj`pslppjaofqfojdjlmskzpj`boeffgab`hqfdjpwfqsj`wvqfpgjpbaofgsqlwl`lobvgjfm`fpfwwjmdpb`wjujwzfofnfmwpofbqmjmdbmzwkjmdbapwqb`wsqldqfpplufqujftnbdbyjmff`lmlnj`wqbjmjmdsqfppvqfubqjlvp#?pwqlmd=sqlsfqwzpklssjmdwldfwkfqbgubm`fgafkbujlqgltmolbgefbwvqfgellwaboopfof`wfgObmdvbdfgjpwbm`fqfnfnafqwqb`hjmdsbpptlqgnlgjejfgpwvgfmwpgjqf`wozejdkwjmdmlqwkfqmgbwbabpfefpwjuboaqfbhjmdol`bwjlmjmwfqmfwgqlsgltmsqb`wj`ffujgfm`fevm`wjlmnbqqjbdfqfpslmpfsqlaofnpmfdbwjufsqldqbnpbmbozpjpqfofbpfgabmmfq!=svq`kbpfsloj`jfpqfdjlmbo`qfbwjufbqdvnfmwallhnbqhqfefqqfq`kfnj`bogjujpjlm`booab`hpfsbqbwfsqlif`wp`lmeoj`wkbqgtbqfjmwfqfpwgfojufqznlvmwbjmlawbjmfg>#ebopf8elq+ubq#b``fswfg`bsb`jwz`lnsvwfqjgfmwjwzbjq`qbewfnsolzfgsqlslpfgglnfpwj`jm`ovgfpsqlujgfgklpsjwboufqwj`bo`loobspfbssqlb`ksbqwmfqpoldl!=?bgbvdkwfqbvwklq!#`vowvqboebnjojfp,jnbdfp,bppfnaozsltfqevowfb`kjmdejmjpkfggjpwqj`w`qjwj`bo`dj.ajm,svqslpfpqfrvjqfpfof`wjlmaf`lnjmdsqlujgfpb`bgfnj`f{fq`jpfb`wvbooznfgj`jmf`lmpwbmwb``jgfmwNbdbyjmfgl`vnfmwpwbqwjmdalwwln!=lapfqufg9#%rvlw8f{wfmgfgsqfujlvpPlewtbqf`vpwlnfqgf`jpjlmpwqfmdwkgfwbjofgpojdkwozsobmmjmdwf{wbqfb`vqqfm`zfufqzlmfpwqbjdkwwqbmpefqslpjwjufsqlgv`fgkfqjwbdfpkjssjmdbaplovwfqf`fjufgqfofubmwavwwlm!#ujlofm`fbmztkfqfafmfejwpobvm`kfgqf`fmwozboojbm`felooltfgnvowjsofavoofwjmjm`ovgfgl``vqqfgjmwfqmbo'+wkjp*-qfsvaoj`=?wq=?wg`lmdqfppqf`lqgfgvowjnbwfplovwjlm?vo#jg>!gjp`lufqKlnf?,b=tfapjwfpmfwtlqhpbowklvdkfmwjqfoznfnlqjbonfppbdfp`lmwjmvfb`wjuf!=plnftkbwuj`wlqjbTfpwfqm##wjwof>!Ol`bwjlm`lmwqb`wujpjwlqpGltmolbgtjwklvw#qjdkw!=\tnfbpvqfptjgwk#>#ubqjbaofjmuloufgujqdjmjbmlqnboozkbssfmfgb``lvmwppwbmgjmdmbwjlmboQfdjpwfqsqfsbqfg`lmwqlopb``vqbwfajqwkgbzpwqbwfdzleej`jbodqbskj`p`qjnjmboslppjaoz`lmpvnfqSfqplmbopsfbhjmdubojgbwfb`kjfufg-isd!#,=nb`kjmfp?,k1=\t##hfztlqgpeqjfmgozaqlwkfqp`lnajmfglqjdjmbo`lnslpfgf{sf`wfgbgfrvbwfsbhjpwbmeloolt!#ubovbaof?,obafo=qfobwjufaqjmdjmdjm`qfbpfdlufqmlqsovdjmp,Ojpw#le#Kfbgfq!=!#mbnf>!#+%rvlw8dqbgvbwf?,kfbg=\t`lnnfq`fnbobzpjbgjqf`wlqnbjmwbjm8kfjdkw9p`kfgvof`kbmdjmdab`h#wl#`bwkloj`sbwwfqmp`lolq9# dqfbwfpwpvssojfpqfojbaof?,vo=\t\n\n?pfof`w#`jwjyfmp`olwkjmdtbw`kjmd?oj#jg>!psf`jej``bqqzjmdpfmwfm`f?`fmwfq=`lmwqbpwwkjmhjmd`bw`k+f*plvwkfqmNj`kbfo#nfq`kbmw`bqlvpfosbggjmd9jmwfqjlq-psojw+!ojybwjlmL`wlafq#*xqfwvqmjnsqlufg..%dw8\t\t`lufqbdf`kbjqnbm-smd!#,=pvaif`wpQj`kbqg#tkbwfufqsqlabaozqf`lufqzabpfabooivgdnfmw`lmmf`w--`pp!#,=#tfapjwfqfslqwfggfebvow!,=?,b=\x0E\tfof`wqj`p`lwobmg`qfbwjlmrvbmwjwz-#JPAM#3gjg#mlw#jmpwbm`f.pfbq`k.!#obmd>!psfbhfqp@lnsvwfq`lmwbjmpbq`kjufpnjmjpwfqqfb`wjlmgjp`lvmwJwbojbml`qjwfqjbpwqlmdoz9#$kwws9$p`qjsw$`lufqjmdleefqjmdbssfbqfgAqjwjpk#jgfmwjezEb`fallhmvnfqlvpufkj`ofp`lm`fqmpBnfqj`bmkbmgojmdgju#jg>!Tjoojbn#sqlujgfq\\`lmwfmwb``vqb`zpf`wjlm#bmgfqplmeof{jaof@bwfdlqzobtqfm`f?p`qjsw=obzlvw>!bssqlufg#nb{jnvnkfbgfq!=?,wbaof=Pfquj`fpkbnjowlm`vqqfmw#`bmbgjbm`kbmmfop,wkfnfp,,bqwj`oflswjlmboslqwvdboubovf>!!jmwfqubotjqfofppfmwjwofgbdfm`jfpPfbq`k!#nfbpvqfgwklvpbmgpsfmgjmd%kfoojs8mft#Gbwf!#pjyf>!sbdfMbnfnjggof!#!#,=?,b=kjggfm!=pfrvfm`fsfqplmbolufqeoltlsjmjlmpjoojmljpojmhp!=\t\n?wjwof=ufqpjlmppbwvqgbzwfqnjmbojwfnsqlsfmdjmffqpf`wjlmpgfpjdmfqsqlslpbo>!ebopf!Fpsb/]loqfofbpfppvanjw!#fq%rvlw8bggjwjlmpznswlnplqjfmwfgqfplvq`fqjdkw!=?sofbpvqfpwbwjlmpkjpwlqz-ofbujmd##alqgfq>`lmwfmwp`fmwfq!=-\t\tPlnf#gjqf`wfgpvjwbaofavodbqjb-pklt+*8gfpjdmfgDfmfqbo#`lm`fswpF{bnsofptjoojbnpLqjdjmbo!=?psbm=pfbq`k!=lsfqbwlqqfrvfpwpb#%rvlw8booltjmdGl`vnfmwqfujpjlm-#\t\tWkf#zlvqpfoe@lmwb`w#nj`kjdbmFmdojpk#`lovnajbsqjlqjwzsqjmwjmdgqjmhjmdeb`jojwzqfwvqmfg@lmwfmw#leej`fqpQvppjbm#dfmfqbwf.;;6:.2!jmgj`bwfebnjojbq#rvbojwznbqdjm93#`lmwfmwujftslqw`lmwb`wp.wjwof!=slqwbaof-ofmdwk#fojdjaofjmuloufpbwobmwj`lmolbg>!gfebvow-pvssojfgsbznfmwpdolppbqz\t\tBewfq#dvjgbm`f?,wg=?wgfm`lgjmdnjggof!=`bnf#wl#gjpsobzpp`lwwjpkilmbwkbmnbilqjwztjgdfwp-`ojmj`bowkbjobmgwfb`kfqp?kfbg=\t\nbeef`wfgpvsslqwpsljmwfq8wlPwqjmd?,pnboo=lhobklnbtjoo#af#jmufpwlq3!#bow>!klojgbzpQfplvq`foj`fmpfg#+tkj`k#-#Bewfq#`lmpjgfqujpjwjmdf{solqfqsqjnbqz#pfbq`k!#bmgqljg!rvj`hoz#nffwjmdpfpwjnbwf8qfwvqm#8`lolq9 #kfjdkw>bssqlubo/#%rvlw8#`kf`hfg-njm-ip!nbdmfwj`=?,b=?,kelqf`bpw-#Tkjof#wkvqpgbzgufqwjpf%fb`vwf8kbp@obppfubovbwflqgfqjmdf{jpwjmdsbwjfmwp#Lmojmf#`lolqbglLswjlmp!`bnsafoo?\"..#fmg?,psbm=??aq#,=\x0E\t\\slsvsp\x7Fp`jfm`fp/%rvlw8#rvbojwz#Tjmgltp#bppjdmfgkfjdkw9#?a#`obppof%rvlw8#ubovf>!#@lnsbmzf{bnsofp?jeqbnf#afojfufpsqfpfmwpnbqpkboosbqw#le#sqlsfqoz*-\t\tWkf#wb{lmlnznv`k#le#?,psbm=\t!#gbwb.pqwvdv/Fpp`qlooWl#sqlif`w?kfbg=\x0E\tbwwlqmfzfnskbpjppslmplqpebm`zal{tlqog$p#tjogojef`kf`hfg>pfppjlmpsqldqbnns{8elmw.#Sqlif`wilvqmbopafojfufgub`bwjlmwklnsplmojdkwjmdbmg#wkf#psf`jbo#alqgfq>3`kf`hjmd?,walgz=?avwwlm#@lnsofwf`ofbqej{\t?kfbg=\tbqwj`of#?pf`wjlmejmgjmdpqlof#jm#slsvobq##L`wlafqtfapjwf#f{slpvqfvpfg#wl##`kbmdfplsfqbwfg`oj`hjmdfmwfqjmd`lnnbmgpjmelqnfg#mvnafqp##?,gju=`qfbwjmdlmPvanjwnbqzobmg`loofdfpbmbozwj`ojpwjmdp`lmwb`w-olddfgJmbgujplqzpjaojmdp`lmwfmw!p%rvlw8*p-#Wkjp#sb`hbdfp`kf`hal{pvddfpwpsqfdmbmwwlnlqqltpsb`jmd>j`lm-smdibsbmfpf`lgfabpfavwwlm!=dbnaojmdpv`k#bp#/#tkjof#?,psbm=#njpplvqjpslqwjmdwls92s{#-?,psbm=wfmpjlmptjgwk>!1obyzolbgmlufnafqvpfg#jm#kfjdkw>!`qjsw!=\t%maps8?,?wq=?wg#kfjdkw91,sqlgv`w`lvmwqz#jm`ovgf#ellwfq!#%ow8\"..#wjwof!=?,irvfqz-?,elqn=\t+\x0BBl\bQ\x7F*+\x0BUm\x05Gx*kqubwphjjwbojbmlqln/Nm(ow/Pqh/Kf4K4]4C5dwbnaj/Emmlwj`jbpnfmpbifpsfqplmbpgfqf`klpmb`jlmbopfquj`jl`lmwb`wlvpvbqjlpsqldqbnbdlajfqmlfnsqfpbpbmvm`jlpubofm`jb`lolnajbgfpsv/Epgfslqwfpsqlzf`wlsqlgv`wls/Vaoj`lmlplwqlpkjpwlqjbsqfpfmwfnjoolmfpnfgjbmwfsqfdvmwbbmwfqjlqqf`vqplpsqlaofnbpbmwjbdlmvfpwqlplsjmj/_mjnsqjnjqnjfmwqbpbn/Eqj`bufmgfglqpl`jfgbgqfpsf`wlqfbojybqqfdjpwqlsbobaqbpjmwfq/Epfmwlm`fpfpsf`jbonjfnaqlpqfbojgbg`/_qglabybqbdlybs/Mdjmbppl`jbofpaolrvfbqdfpwj/_mborvjofqpjpwfnbp`jfm`jbp`lnsofwlufqpj/_m`lnsofwbfpwvgjlps/Vaoj`blaifwjulboj`bmwfavp`bglq`bmwjgbgfmwqbgbpb``jlmfpbq`kjulppvsfqjlqnbzlq/Abbofnbmjbevm`j/_m/Vowjnlpkb`jfmglbrvfoolpfgj`j/_mefqmbmglbnajfmwfeb`fallhmvfpwqbp`ojfmwfpsql`fplpabpwbmwfsqfpfmwbqfslqwbq`lmdqfplsvaoj`bq`lnfq`jl`lmwqbwli/_ufmfpgjpwqjwlw/E`mj`b`lmivmwlfmfqd/Abwqbabibqbpwvqjbpqf`jfmwfvwjojybqalofw/Ampboubglq`lqqf`wbwqbabilpsqjnfqlpmfdl`jlpojafqwbggfwboofpsbmwboobsq/_{jnlbonfq/Abbmjnbofprvj/Emfp`lqby/_mpf``j/_mavp`bmglls`jlmfpf{wfqjlq`lm`fswlwlgbu/Abdbofq/Abfp`qjajqnfgj`jmboj`fm`jb`lmpvowbbpsf`wlp`q/Awj`bg/_obqfpivpwj`jbgfafq/Mmsfq/Alglmf`fpjwbnbmwfmfqsfrvf/]lqf`jajgbwqjavmbowfmfqjef`bm`j/_m`bmbqjbpgfp`bqdbgjufqplpnboolq`bqfrvjfqfw/E`mj`lgfafq/Abujujfmgbejmbmybpbgfobmwfevm`jlmb`lmpfilpgje/A`jo`jvgbgfpbmwjdvbpbubmybgbw/Eqnjmlvmjgbgfpp/Mm`kfy`bnsb/]bplewlmj`qfujpwbp`lmwjfmfpf`wlqfpnlnfmwlpeb`vowbg`q/Egjwlgjufqpbppvsvfpwleb`wlqfppfdvmglpsfrvf/]b<_<R<X<\\<Y=m<W<T<Y=m=n=`<]=g<W<R<]=g=n=`=a=n<R<P<y=m<W<T=n<R<_<R<P<Y<Q=c<^=m<Y=i=a=n<R<U<X<\\<Z<Y<]=g<W<T<_<R<X=o<X<Y<Q=`=a=n<R=n<]=g<W<\\=m<Y<]=c<R<X<T<Q=m<Y<]<Y<Q<\\<X<R=m<\\<U=n=h<R=n<R<Q<Y<_<R=m<^<R<T=m<^<R<U<T<_=l=g=n<R<Z<Y<^=m<Y<P=m<^<R=b<W<T=d=`=a=n<T=i<S<R<V<\\<X<Q<Y<U<X<R<P<\\<P<T=l<\\<W<T<]<R=n<Y<P=o=i<R=n=c<X<^=o=i=m<Y=n<T<W=b<X<T<X<Y<W<R<P<T=l<Y=n<Y<]=c=m<^<R<Y<^<T<X<Y=k<Y<_<R=a=n<T<P=m=k<Y=n=n<Y<P=g=j<Y<Q=g=m=n<\\<W<^<Y<X=`=n<Y<P<Y<^<R<X=g=n<Y<]<Y<^=g=d<Y<Q<\\<P<T=n<T<S<\\=n<R<P=o<S=l<\\<^<W<T=j<\\<R<X<Q<\\<_<R<X=g<[<Q<\\=b<P<R<_=o<X=l=o<_<^=m<Y<U<T<X<Y=n<V<T<Q<R<R<X<Q<R<X<Y<W<\\<X<Y<W<Y=m=l<R<V<T=b<Q=c<^<Y=m=`<y=m=n=`=l<\\<[<\\<Q<\\=d<T4K5h5h5k4K5h4F5f4@5i5f4U4B4K4Y4E4K5h4\\5f4U5h5f5k4@4C5f4C4K5h4N5j4K5h4]4C4F4A5o5i4Y5m4A4E5o4K5j4F4K5h5h5f5f5o5d5j4X4D5o4E5m5f5k4K4D5j4K4F4A5d4K4M4O5o4G4]4B5h4K5h4K5h4A4D4C5h5f5h4C4]5d4_4K4Z4V4[4F5o5d5j5k5j4K5o4_4K4A4E5j4K4C5f4K5h4[4D4U5h5f5o4X5o4]4K5f5i5o5j5i5j5k4K4X4]5o4E4]4J5f4_5j4X5f4[5i4K4\\4K4K5h5m5j4X4D4K4D4F4U4D4]4]4A5i4E5o4K5m4E5f5n5d5h5i4]5o4^5o5h5i4E4O4A5i4C5n5h4D5f5f4U5j5f4Y5d4]4E4[4]5f5n4X4K4]5o4@5d4K5h4O4B4]5e5i4U5j4K4K4D4A4G4U4]5d4Z4D4X5o5h5i4_4@5h4D5j4K5j4B4K5h4C5o4F4K4D5o5h5f4E4D4C5d5j4O5f4Z4K5f5d4@4C5m4]5f5n5o4F4D4F4O5m4Z5h5i4[4D4B4K5o4G4]4D4K4]5o4K5m4Z5h4K4A5h5e5j5m4_5k4O5f4K5i4]4C5d4C4O5j5k4K4C5f5j4K4K5h4K5j5i4U4]4Z4F4U5h5i4C4K4B5h5i5i5o5j\x03\x03\x03\x03\x03\x03\x03\x03\x02\x03\x02\x03\x02\x03\x02\x03\x01\x03\x01\x03\x01\x03\x01\x03\x07\x03\x07\x03\x07\x03\x07\x03\x03\x02\x01\0\x07\x06\x05\x04\x04\x05\x06\x07\0\x01\x02\x03\x0B\n\t\b\x0F\x0E\r\f\f\r\x0E\x0F\b\t\n\x0B\x13\x12\x11\x10\x17\x16\x15\x14\x14\x15\x16\x17\x10\x11\x12\x13\x1B\x1A\x19\x18\x1F\x1E\x1D\x1C\x1C\x1D\x1E\x1F\x18\x19\x1A\x1B\x13\x13\x13\x13\x03\x03\x03\x03\x03\x03\x03\x03\x13\x13\x13\x13\x02\x03\x03\x03\x01\x03\x03\x03\x01\x03\x03\x03\x02\x03\x03\x03\x02\x03\x03\x03\0\x03\x03\x03\x13\x13\x03\x02\x03\x03\x03\x02\x03\x03\x13\x13\x03\x02\x03\x03\x03\x0B\x03\x0B\x03\x0B\x03\x0B\x03\x03\x03\x02\x03\x01\x03\0\x03\x07\x03\x06\x03\x05\x03\x04qfplvq`fp`lvmwqjfprvfpwjlmpfrvjsnfmw`lnnvmjwzbubjobaofkjdkojdkwGWG,{kwnonbqhfwjmdhmltofgdfplnfwkjmd`lmwbjmfqgjqf`wjlmpvap`qjafbgufqwjpf`kbqb`wfq!#ubovf>!?,pfof`w=Bvpwqbojb!#`obpp>!pjwvbwjlmbvwklqjwzelooltjmdsqjnbqjozlsfqbwjlm`kboofmdfgfufolsfgbmlmznlvpevm`wjlm#evm`wjlmp`lnsbmjfppwqv`wvqfbdqffnfmw!#wjwof>!slwfmwjbofgv`bwjlmbqdvnfmwppf`lmgbqz`lszqjdkwobmdvbdfpf{`ovpjuf`lmgjwjlm?,elqn=\x0E\tpwbwfnfmwbwwfmwjlmAjldqbskz~#fopf#x\tplovwjlmptkfm#wkf#Bmbozwj`pwfnsobwfpgbmdfqlvppbwfoojwfgl`vnfmwpsvaojpkfqjnslqwbmwsqlwlwzsfjmeovfm`f%qbrvl8?,feef`wjufdfmfqboozwqbmpelqnafbvwjevowqbmpslqwlqdbmjyfgsvaojpkfgsqlnjmfmwvmwjo#wkfwkvnambjoMbwjlmbo#-el`vp+*8lufq#wkf#njdqbwjlmbmmlvm`fgellwfq!=\tf{`fswjlmofpp#wkbmf{sfmpjufelqnbwjlmeqbnftlqhwfqqjwlqzmgj`bwjlm`vqqfmwoz`obppMbnf`qjwj`jpnwqbgjwjlmfopftkfqfBof{bmgfqbssljmwfgnbwfqjbopaqlbg`bpwnfmwjlmfgbeejojbwf?,lswjlm=wqfbwnfmwgjeefqfmw,gfebvow-Sqfpjgfmwlm`oj`h>!ajldqbskzlwkfqtjpfsfqnbmfmwEqbm/KbjpKlooztllgf{sbmpjlmpwbmgbqgp?,pwzof=\tqfgv`wjlmGf`fnafq#sqfefqqfg@bnaqjgdflsslmfmwpAvpjmfpp#`lmevpjlm=\t?wjwof=sqfpfmwfgf{sobjmfgglfp#mlw#tlqogtjgfjmwfqeb`fslpjwjlmpmftpsbsfq?,wbaof=\tnlvmwbjmpojhf#wkf#fppfmwjboejmbm`jbopfof`wjlmb`wjlm>!,babmglmfgFgv`bwjlmsbqpfJmw+pwbajojwzvmbaof#wl?,wjwof=\tqfobwjlmpMlwf#wkbwfeej`jfmwsfqelqnfgwtl#zfbqpPjm`f#wkfwkfqfelqftqbssfq!=bowfqmbwfjm`qfbpfgAbwwof#lesfq`fjufgwqzjmd#wlmf`fppbqzslqwqbzfgfof`wjlmpFojybafwk?,jeqbnf=gjp`lufqzjmpvqbm`fp-ofmdwk8ofdfmgbqzDfldqbskz`bmgjgbwf`lqslqbwfplnfwjnfppfquj`fp-jmkfqjwfg?,pwqlmd=@lnnvmjwzqfojdjlvpol`bwjlmp@lnnjwwffavjogjmdpwkf#tlqogml#olmdfqafdjmmjmdqfefqfm`f`bmmlw#afeqfrvfm`zwzsj`boozjmwl#wkf#qfobwjuf8qf`lqgjmdsqfpjgfmwjmjwjboozwf`kmjrvfwkf#lwkfqjw#`bm#aff{jpwfm`fvmgfqojmfwkjp#wjnfwfofsklmfjwfnp`lsfsqb`wj`fpbgubmwbdf*8qfwvqm#Elq#lwkfqsqlujgjmdgfnl`qb`zalwk#wkf#f{wfmpjufpveefqjmdpvsslqwfg`lnsvwfqp#evm`wjlmsqb`wj`bopbjg#wkbwjw#nbz#afFmdojpk?,eqln#wkf#p`kfgvofggltmolbgp?,obafo=\tpvpsf`wfgnbqdjm9#3psjqjwvbo?,kfbg=\t\tnj`qlplewdqbgvboozgjp`vppfgkf#af`bnff{f`vwjufirvfqz-ipklvpfklog`lmejqnfgsvq`kbpfgojwfqboozgfpwqlzfgvs#wl#wkfubqjbwjlmqfnbjmjmdjw#jp#mlw`fmwvqjfpIbsbmfpf#bnlmd#wkf`lnsofwfgbodlqjwknjmwfqfpwpqfafoojlmvmgfejmfgfm`lvqbdfqfpjybaofjmuloujmdpfmpjwjufvmjufqpbosqlujpjlm+bowklvdkefbwvqjmd`lmgv`wfg*/#tkj`k#`lmwjmvfg.kfbgfq!=Efaqvbqz#mvnfqlvp#lufqeolt9`lnslmfmweqbdnfmwpf{`foofmw`lopsbm>!wf`kmj`bomfbq#wkf#Bgubm`fg#plvq`f#lef{sqfppfgKlmd#Hlmd#Eb`fallhnvowjsof#nf`kbmjpnfofubwjlmleefmpjuf?,elqn=\t\npslmplqfggl`vnfmw-lq#%rvlw8wkfqf#bqfwklpf#tklnlufnfmwpsql`fppfpgjeej`vowpvanjwwfgqf`lnnfmg`lmujm`fgsqlnlwjmd!#tjgwk>!-qfsob`f+`obppj`bo`lbojwjlmkjp#ejqpwgf`jpjlmpbppjpwbmwjmgj`bwfgfulovwjlm.tqbssfq!fmlvdk#wlbolmd#wkfgfojufqfg..=\x0E\t?\"..Bnfqj`bm#sqlwf`wfgMlufnafq#?,pwzof=?evqmjwvqfJmwfqmfw##lmaovq>!pvpsfmgfgqf`jsjfmwabpfg#lm#Nlqflufq/balojpkfg`loof`wfgtfqf#nbgffnlwjlmbofnfqdfm`zmbqqbwjufbgul`bwfps{8alqgfq`lnnjwwfggjq>!owq!fnsolzffpqfpfbq`k-#pfof`wfgpv``fpplq`vpwlnfqpgjpsobzfgPfswfnafqbgg@obpp+Eb`fallh#pvddfpwfgbmg#obwfqlsfqbwjmdfobalqbwfPlnfwjnfpJmpwjwvwf`fqwbjmozjmpwboofgelooltfqpIfqvpbofnwkfz#kbuf`lnsvwjmddfmfqbwfgsqlujm`fpdvbqbmwffbqajwqbqzqf`ldmjyftbmwfg#wls{8tjgwk9wkflqz#leafkbujlvqTkjof#wkffpwjnbwfgafdbm#wl#jw#af`bnfnbdmjwvgfnvpw#kbufnlqf#wkbmGjqf`wlqzf{wfmpjlmpf`qfwbqzmbwvqboozl``vqqjmdubqjbaofpdjufm#wkfsobwelqn-?,obafo=?ebjofg#wl`lnslvmgphjmgp#le#pl`jfwjfpbolmdpjgf#..%dw8\t\tplvwktfpwwkf#qjdkwqbgjbwjlmnbz#kbuf#vmfp`bsf+pslhfm#jm!#kqfe>!,sqldqbnnflmoz#wkf#`lnf#eqlngjqf`wlqzavqjfg#jmb#pjnjobqwkfz#tfqf?,elmw=?,Mlqtfdjbmpsf`jejfgsqlgv`jmdsbppfmdfq+mft#Gbwfwfnslqbqzej`wjlmboBewfq#wkffrvbwjlmpgltmolbg-qfdvobqozgfufolsfqbaluf#wkfojmhfg#wlskfmlnfmbsfqjlg#lewllowjs!=pvapwbm`fbvwlnbwj`bpsf`w#leBnlmd#wkf`lmmf`wfgfpwjnbwfpBjq#Elq`fpzpwfn#lelaif`wjufjnnfgjbwfnbhjmd#jwsbjmwjmdp`lmrvfqfgbqf#pwjoosql`fgvqfdqltwk#lekfbgfg#azFvqlsfbm#gjujpjlmpnlof`vofpeqbm`kjpfjmwfmwjlmbwwqb`wfg`kjogkllgbopl#vpfggfgj`bwfgpjmdbslqfgfdqff#leebwkfq#le`lmeoj`wp?,b=?,s=\t`bnf#eqlntfqf#vpfgmlwf#wkbwqf`fjujmdF{f`vwjuffufm#nlqfb``fpp#wl`lnnbmgfqSlojwj`bonvpj`jbmpgfoj`jlvpsqjplmfqpbgufmw#leVWE.;!#,=?\"X@GBWBX!=@lmwb`wPlvwkfqm#ad`lolq>!pfqjfp#le-#Jw#tbp#jm#Fvqlsfsfqnjwwfgubojgbwf-bssfbqjmdleej`jboppfqjlvpoz.obmdvbdfjmjwjbwfgf{wfmgjmdolmd.wfqnjmeobwjlmpv`k#wkbwdfw@llhjfnbqhfg#az?,avwwlm=jnsofnfmwavw#jw#jpjm`qfbpfpgltm#wkf#qfrvjqjmdgfsfmgfmw..=\t?\"..#jmwfqujftTjwk#wkf#`lsjfp#le`lmpfmpvptbp#avjowUfmfyvfob+elqnfqozwkf#pwbwfsfqplmmfopwqbwfdj`ebulvq#lejmufmwjlmTjhjsfgjb`lmwjmfmwujqwvbooztkj`k#tbpsqjm`jsof@lnsofwf#jgfmwj`bopklt#wkbwsqjnjwjufbtbz#eqlnnlof`vobqsqf`jpfozgjpploufgVmgfq#wkfufqpjlm>!=%maps8?,Jw#jp#wkf#Wkjp#jp#tjoo#kbuflqdbmjpnpplnf#wjnfEqjfgqj`ktbp#ejqpwwkf#lmoz#eb`w#wkbwelqn#jg>!sqf`fgjmdWf`kmj`boskzpj`jpwl``vqp#jmmbujdbwlqpf`wjlm!=psbm#jg>!plvdkw#wlafolt#wkfpvqujujmd~?,pwzof=kjp#gfbwkbp#jm#wkf`bvpfg#azsbqwjboozf{jpwjmd#vpjmd#wkftbp#djufmb#ojpw#leofufop#lemlwjlm#leLeej`jbo#gjpnjppfgp`jfmwjpwqfpfnaofpgvsoj`bwff{solpjufqf`lufqfgboo#lwkfqdboofqjfpxsbggjmd9sflsof#leqfdjlm#lebggqfppfpbppl`jbwfjnd#bow>!jm#nlgfqmpklvog#afnfwklg#leqfslqwjmdwjnfpwbnsmffgfg#wlwkf#Dqfbwqfdbqgjmdpffnfg#wlujftfg#bpjnsb`w#lmjgfb#wkbwwkf#Tlqogkfjdkw#lef{sbmgjmdWkfpf#bqf`vqqfmw!=`bqfevooznbjmwbjmp`kbqdf#le@obppj`bobggqfppfgsqfgj`wfgltmfqpkjs?gju#jg>!qjdkw!=\x0E\tqfpjgfm`fofbuf#wkf`lmwfmw!=bqf#lewfm##~*+*8\x0E\tsqlabaoz#Sqlefpplq.avwwlm!#qfpslmgfgpbzp#wkbwkbg#wl#afsob`fg#jmKvmdbqjbmpwbwvp#lepfqufp#bpVmjufqpbof{f`vwjlmbddqfdbwfelq#tkj`kjmef`wjlmbdqffg#wlkltfufq/#slsvobq!=sob`fg#lm`lmpwqv`wfof`wlqbopznalo#lejm`ovgjmdqfwvqm#wlbq`kjwf`w@kqjpwjbmsqfujlvp#ojujmd#jmfbpjfq#wlsqlefpplq\t%ow8\"..#feef`w#lebmbozwj`ptbp#wbhfmtkfqf#wkfwllh#lufqafojfe#jmBeqjhbbmpbp#ebq#bpsqfufmwfgtlqh#tjwkb#psf`jbo?ejfogpfw@kqjpwnbpQfwqjfufg\t\tJm#wkf#ab`h#jmwlmlqwkfbpwnbdbyjmfp=?pwqlmd=`lnnjwwffdlufqmjmddqlvsp#lepwlqfg#jmfpwbaojpkb#dfmfqbojwp#ejqpwwkfjq#ltmslsvobwfgbm#laif`w@bqjaafbmboolt#wkfgjpwqj`wptjp`lmpjmol`bwjlm-8#tjgwk9#jmkbajwfgPl`jbojpwIbmvbqz#2?,ellwfq=pjnjobqoz`klj`f#lewkf#pbnf#psf`jej`#avpjmfpp#Wkf#ejqpw-ofmdwk8#gfpjqf#wlgfbo#tjwkpjm`f#wkfvpfqBdfmw`lm`fjufgjmgf{-sksbp#%rvlw8fmdbdf#jmqf`fmwoz/eft#zfbqptfqf#bopl\t?kfbg=\t?fgjwfg#azbqf#hmltm`jwjfp#jmb``fpphfz`lmgfnmfgbopl#kbufpfquj`fp/ebnjoz#leP`kllo#le`lmufqwfgmbwvqf#le#obmdvbdfnjmjpwfqp?,laif`w=wkfqf#jp#b#slsvobqpfrvfm`fpbgul`bwfgWkfz#tfqfbmz#lwkfqol`bwjlm>fmwfq#wkfnv`k#nlqfqfeof`wfgtbp#mbnfglqjdjmbo#b#wzsj`botkfm#wkfzfmdjmffqp`lvog#mlwqfpjgfmwptfgmfpgbzwkf#wkjqg#sqlgv`wpIbmvbqz#1tkbw#wkfzb#`fqwbjmqfb`wjlmpsql`fpplqbewfq#kjpwkf#obpw#`lmwbjmfg!=?,gju=\t?,b=?,wg=gfsfmg#lmpfbq`k!=\tsjf`fp#le`lnsfwjmdQfefqfm`fwfmmfppfftkj`k#kbp#ufqpjlm>?,psbm=#??,kfbgfq=djufp#wkfkjpwlqjbmubovf>!!=sbggjmd93ujft#wkbwwldfwkfq/wkf#nlpw#tbp#elvmgpvapfw#lebwwb`h#lm`kjogqfm/sljmwp#lesfqplmbo#slpjwjlm9boofdfgoz@ofufobmgtbp#obwfqbmg#bewfqbqf#djufmtbp#pwjoop`qloojmdgfpjdm#lenbhfp#wkfnv`k#ofppBnfqj`bmp-\t\tBewfq#/#avw#wkfNvpfvn#leolvjpjbmb+eqln#wkfnjmmfplwbsbqwj`ofpb#sql`fppGlnjmj`bmulovnf#leqfwvqmjmdgfefmpjuf33s{\x7Fqjdknbgf#eqlnnlvpflufq!#pwzof>!pwbwfp#le+tkj`k#jp`lmwjmvfpEqbm`jp`lavjogjmd#tjwklvw#btjwk#plnftkl#tlvogb#elqn#leb#sbqw#leafelqf#jwhmltm#bp##Pfquj`fpol`bwjlm#bmg#lewfmnfbpvqjmdbmg#jw#jpsbsfqab`hubovfp#le\x0E\t?wjwof=>#tjmglt-gfwfqnjmffq%rvlw8#sobzfg#azbmg#fbqoz?,`fmwfq=eqln#wkjpwkf#wkqffsltfq#bmgle#%rvlw8jmmfqKWNO?b#kqfe>!z9jmojmf8@kvq`k#lewkf#fufmwufqz#kjdkleej`jbo#.kfjdkw9#`lmwfmw>!,`dj.ajm,wl#`qfbwfbeqjhbbmpfpsfqbmwleqbm/Kbjpobwujf)Mvojfwvuj)_(`f)Mwjmb(af)Mwjmb\fUh\fT{\fTN\n{I\np@\x04Fr\x0BBl\bQ\x7F\tA{\x0BUm\x05Gx\tA{\x01yp\x06YA\0zX\bTV\bWl\bUd\x04BM\x0BB{\npV\x0B@x\x04B\\\np@\x04Db\x04Gz\tal\npa\tfM\tuD\bV~\x04mx\x0BQ}\ndS\tp\\\bVK\bS]\bU|\x05oD\tkV\x0Bed\x0BHR\nb~\x04M`\nJp\x05oD\x04|Q\nLP\x04Sw\bTl\nAI\nxC\bWt\tBq\x05F`\x04Cm\x0BLm\tKx\t}t\bPv\ny\\\naB\tV\x7F\nZd\x04XU\x04li\tfr\ti@\tBH\x04BD\x04BV\t`V\n[]\tp_\tTn\n~A\nxR\tuD\t`{\bV@\tTn\tHK\tAJ\x0Bxs\x04Zf\nqI\x04Zf\x0BBM\x0B|j\t}t\bSM\nmC\x0BQ}pfquj`jlpbqw/A`volbqdfmwjmbabq`folmb`vborvjfqsvaoj`bglsqlgv`wlpslo/Awj`bqfpsvfpwbtjhjsfgjbpjdvjfmwfa/Vprvfgb`lnvmjgbgpfdvqjgbgsqjm`jsbosqfdvmwbp`lmwfmjglqfpslmgfqufmfyvfobsqlaofnbpgj`jfnaqfqfob`j/_mmlujfnaqfpjnjobqfpsqlzf`wlpsqldqbnbpjmpwjwvwlb`wjujgbgfm`vfmwqbf`lmln/Abjn/Mdfmfp`lmwb`wbqgfp`bqdbqmf`fpbqjlbwfm`j/_mwfo/Eelml`lnjpj/_m`bm`jlmfp`bsb`jgbgfm`lmwqbqbm/Mojpjpebulqjwlpw/Eqnjmlpsqlujm`jbfwjrvfwbpfofnfmwlpevm`jlmfpqfpvowbgl`bq/M`wfqsqlsjfgbgsqjm`jsjlmf`fpjgbgnvmj`jsbo`qfb`j/_mgfp`bqdbpsqfpfm`jb`lnfq`jbolsjmjlmfpfifq`j`jlfgjwlqjbopbobnbm`bdlmy/Mofygl`vnfmwlsfo/A`vobqf`jfmwfpdfmfqbofpwbqqbdlmbsq/M`wj`bmlufgbgfpsqlsvfpwbsb`jfmwfpw/E`mj`bplaifwjulp`lmwb`wlp\fHB\fIk\fHn\fH^\fHS\fHc\fHU\fId\fHn\fH{\fHC\fHR\fHT\fHR\fHI\fHc\fHY\fHn\fH\\\fHU\fIk\fHy\fIg\fHd\fHy\fIm\fHw\fH\\\fHU\fHR\fH@\fHR\fHJ\fHy\fHU\fHR\fHT\fHA\fIl\fHU\fIm\fHc\fH\\\fHU\fIl\fHB\fId\fHn\fHJ\fHS\fHD\fH@\fHR\fHHgjsolgl`p\fHT\fHB\fHC\fH\\\fIn\fHF\fHD\fHR\fHB\fHF\fHH\fHR\fHG\fHS\fH\\\fHx\fHT\fHH\fHH\fH\\\fHU\fH^\fIg\fH{\fHU\fIm\fHj\fH@\fHR\fH\\\fHJ\fIk\fHZ\fHU\fIm\fHd\fHz\fIk\fH^\fHC\fHJ\fHS\fHy\fHR\fHB\fHY\fIk\fH@\fHH\fIl\fHD\fH@\fIl\fHv\fHB\fI`\fHH\fHT\fHR\fH^\fH^\fIk\fHz\fHp\fIe\fH@\fHB\fHJ\fHJ\fHH\fHI\fHR\fHD\fHU\fIl\fHZ\fHU\fH\\\fHi\fH^\fH{\fHy\fHA\fIl\fHD\fH{\fH\\\fHF\fHR\fHT\fH\\\fHR\fHH\fHy\fHS\fHc\fHe\fHT\fIk\fH{\fHC\fIl\fHU\fIn\fHm\fHj\fH{\fIk\fHs\fIl\fHB\fHz\fIg\fHp\fHy\fHR\fH\\\fHi\fHA\fIl\fH{\fHC\fIk\fHH\fIm\fHB\fHY\fIg\fHs\fHJ\fIk\fHn\fHi\fH{\fH\\\fH|\fHT\fIk\fHB\fIk\fH^\fH^\fH{\fHR\fHU\fHR\fH^\fHf\fHF\fH\\\fHv\fHR\fH\\\fH|\fHT\fHR\fHJ\fIk\fH\\\fHp\fHS\fHT\fHJ\fHS\fH^\fH@\fHn\fHJ\fH@\fHD\fHR\fHU\fIn\fHn\fH^\fHR\fHz\fHp\fIl\fHH\fH@\fHs\fHD\fHB\fHS\fH^\fHk\fHT\fIk\fHj\fHD\fIk\fHD\fHC\fHR\fHy\fIm\fH^\fH^\fIe\fH{\fHA\fHR\fH{\fH\\\fIk\fH^\fHp\fH{\fHU\fH\\\fHR\fHB\fH^\fH{\fIk\fHF\fIk\fHp\fHU\fHR\fHI\fHk\fHT\fIl\fHT\fHU\fIl\fHy\fH^\fHR\fHL\fIl\fHy\fHU\fHR\fHm\fHJ\fIn\fH\\\fHH\fHU\fHH\fHT\fHR\fHH\fHC\fHR\fHJ\fHj\fHC\fHR\fHF\fHR\fHy\fHy\fI`\fHD\fHZ\fHR\fHB\fHJ\fIk\fHz\fHC\fHU\fIl\fH\\\fHR\fHC\fHz\fIm\fHJ\fH^\fH{\fIl`bwfdlqjfpf{sfqjfm`f?,wjwof=\x0E\t@lszqjdkw#ibubp`qjsw`lmgjwjlmpfufqzwkjmd?s#`obpp>!wf`kmloldzab`hdqlvmg?b#`obpp>!nbmbdfnfmw%`lsz8#132ibubP`qjsw`kbqb`wfqpaqfbg`qvnawkfnpfoufpklqjylmwbodlufqmnfmw@bojelqmjbb`wjujwjfpgjp`lufqfgMbujdbwjlmwqbmpjwjlm`lmmf`wjlmmbujdbwjlmbssfbqbm`f?,wjwof=?n`kf`hal{!#wf`kmjrvfpsqlwf`wjlmbssbqfmwozbp#tfoo#bpvmw$/#$VB.qfplovwjlmlsfqbwjlmpwfofujpjlmwqbmpobwfgTbpkjmdwlmmbujdbwlq-#>#tjmglt-jnsqfppjlm%ow8aq%dw8ojwfqbwvqfslsvobwjlmad`lolq>! fpsf`jbooz#`lmwfmw>!sqlgv`wjlmmftpofwwfqsqlsfqwjfpgfejmjwjlmofbgfqpkjsWf`kmloldzSbqojbnfmw`lnsbqjplmvo#`obpp>!-jmgf{Le+!`lm`ovpjlmgjp`vppjlm`lnslmfmwpajloldj`boQfulovwjlm\\`lmwbjmfqvmgfqpwllgmlp`qjsw=?sfqnjppjlmfb`k#lwkfqbwnlpskfqf#lmel`vp>!?elqn#jg>!sql`fppjmdwkjp-ubovfdfmfqbwjlm@lmefqfm`fpvapfrvfmwtfoo.hmltmubqjbwjlmpqfsvwbwjlmskfmlnfmlmgjp`jsojmfoldl-smd!#+gl`vnfmw/alvmgbqjfpf{sqfppjlmpfwwofnfmwAb`hdqlvmglvw#le#wkffmwfqsqjpf+!kwwsp9!#vmfp`bsf+!sbpptlqg!#gfnl`qbwj`?b#kqfe>!,tqbssfq!=\tnfnafqpkjsojmdvjpwj`s{8sbggjmdskjolplskzbppjpwbm`fvmjufqpjwzeb`jojwjfpqf`ldmjyfgsqfefqfm`fje#+wzsflenbjmwbjmfgul`bavobqzkzslwkfpjp-pvanjw+*8%bns8maps8bmmlwbwjlmafkjmg#wkfElvmgbwjlmsvaojpkfq!bppvnswjlmjmwqlgv`fg`lqqvswjlmp`jfmwjpwpf{soj`jwozjmpwfbg#legjnfmpjlmp#lm@oj`h>!`lmpjgfqfggfsbqwnfmwl``vsbwjlmpllm#bewfqjmufpwnfmwsqlmlvm`fgjgfmwjejfgf{sfqjnfmwNbmbdfnfmwdfldqbskj`!#kfjdkw>!ojmh#qfo>!-qfsob`f+,gfsqfppjlm`lmefqfm`fsvmjpknfmwfojnjmbwfgqfpjpwbm`fbgbswbwjlmlsslpjwjlmtfoo#hmltmpvssofnfmwgfwfqnjmfgk2#`obpp>!3s{8nbqdjmnf`kbmj`bopwbwjpwj`p`fofaqbwfgDlufqmnfmw\t\tGvqjmd#wgfufolsfqpbqwjej`jbofrvjubofmwlqjdjmbwfg@lnnjppjlmbwwb`knfmw?psbm#jg>!wkfqf#tfqfMfgfqobmgpafzlmg#wkfqfdjpwfqfgilvqmbojpweqfrvfmwozboo#le#wkfobmd>!fm!#?,pwzof=\x0E\tbaplovwf8#pvsslqwjmdf{wqfnfoz#nbjmpwqfbn?,pwqlmd=#slsvobqjwzfnsolznfmw?,wbaof=\x0E\t#`lopsbm>!?,elqn=\t##`lmufqpjlmbalvw#wkf#?,s=?,gju=jmwfdqbwfg!#obmd>!fmSlqwvdvfpfpvapwjwvwfjmgjujgvbojnslppjaofnvowjnfgjbbonlpw#boos{#plojg# bsbqw#eqlnpvaif`w#wljm#Fmdojpk`qjwj`jyfgf{`fsw#elqdvjgfojmfplqjdjmboozqfnbqhbaofwkf#pf`lmgk1#`obpp>!?b#wjwof>!+jm`ovgjmdsbqbnfwfqpsqlkjajwfg>#!kwws9,,gj`wjlmbqzsfq`fswjlmqfulovwjlmelvmgbwjlms{8kfjdkw9pv``fppevopvsslqwfqpnjoofmmjvnkjp#ebwkfqwkf#%rvlw8ml.qfsfbw8`lnnfq`jbojmgvpwqjbofm`lvqbdfgbnlvmw#le#vmleej`jbofeej`jfm`zQfefqfm`fp`llqgjmbwfgjp`objnfqf{sfgjwjlmgfufolsjmd`bo`vobwfgpjnsojejfgofdjwjnbwfpvapwqjmd+3!#`obpp>!`lnsofwfozjoovpwqbwfejuf#zfbqpjmpwqvnfmwSvaojpkjmd2!#`obpp>!spz`kloldz`lmejgfm`fmvnafq#le#bapfm`f#leel`vpfg#lmiljmfg#wkfpwqv`wvqfpsqfujlvpoz=?,jeqbnf=lm`f#bdbjmavw#qbwkfqjnnjdqbmwple#`lvqpf/b#dqlvs#leOjwfqbwvqfVmojhf#wkf?,b=%maps8\tevm`wjlm#jw#tbp#wkf@lmufmwjlmbvwlnlajofSqlwfpwbmwbddqfppjufbewfq#wkf#Pjnjobqoz/!#,=?,gju=`loof`wjlm\x0E\tevm`wjlmujpjajojwzwkf#vpf#leulovmwffqpbwwqb`wjlmvmgfq#wkf#wkqfbwfmfg)?\"X@GBWBXjnslqwbm`fjm#dfmfqbowkf#obwwfq?,elqn=\t?,-jmgf{Le+$j#>#38#j#?gjeefqfm`fgfulwfg#wlwqbgjwjlmppfbq`k#elqvowjnbwfozwlvqmbnfmwbwwqjavwfppl.`boofg#~\t?,pwzof=fubovbwjlmfnskbpjyfgb``fppjaof?,pf`wjlm=pv``fppjlmbolmd#tjwkNfbmtkjof/jmgvpwqjfp?,b=?aq#,=kbp#af`lnfbpsf`wp#leWfofujpjlmpveej`jfmwabphfwabooalwk#pjgfp`lmwjmvjmdbm#bqwj`of?jnd#bow>!bgufmwvqfpkjp#nlwkfqnbm`kfpwfqsqjm`jsofpsbqwj`vobq`lnnfmwbqzfeef`wp#legf`jgfg#wl!=?pwqlmd=svaojpkfqpIlvqmbo#legjeej`vowzeb`jojwbwfb``fswbaofpwzof-`pp!\nevm`wjlm#jmmlubwjlm=@lszqjdkwpjwvbwjlmptlvog#kbufavpjmfppfpGj`wjlmbqzpwbwfnfmwplewfm#vpfgsfqpjpwfmwjm#Ibmvbqz`lnsqjpjmd?,wjwof=\t\ngjsolnbwj``lmwbjmjmdsfqelqnjmdf{wfmpjlmpnbz#mlw#af`lm`fsw#le#lm`oj`h>!Jw#jp#boplejmbm`jbo#nbhjmd#wkfOv{fnalvqdbggjwjlmbobqf#`boofgfmdbdfg#jm!p`qjsw!*8avw#jw#tbpfof`wqlmj`lmpvanjw>!\t?\"..#Fmg#fof`wqj`boleej`jboozpvddfpwjlmwls#le#wkfvmojhf#wkfBvpwqbojbmLqjdjmboozqfefqfm`fp\t?,kfbg=\x0E\tqf`ldmjpfgjmjwjbojyfojnjwfg#wlBof{bmgqjbqfwjqfnfmwBgufmwvqfpelvq#zfbqp\t\t%ow8\"..#jm`qfbpjmdgf`lqbwjlmk0#`obpp>!lqjdjmp#lelaojdbwjlmqfdvobwjlm`obppjejfg+evm`wjlm+bgubmwbdfpafjmd#wkf#kjpwlqjbmp?abpf#kqfeqfsfbwfgoztjoojmd#wl`lnsbqbaofgfpjdmbwfgmlnjmbwjlmevm`wjlmbojmpjgf#wkfqfufobwjlmfmg#le#wkfp#elq#wkf#bvwklqjyfgqfevpfg#wlwbhf#sob`fbvwlmlnlvp`lnsqlnjpfslojwj`bo#qfpwbvqbmwwtl#le#wkfEfaqvbqz#1rvbojwz#leptelaif`w-vmgfqpwbmgmfbqoz#bootqjwwfm#azjmwfqujftp!#tjgwk>!2tjwkgqbtboeolbw9ofewjp#vpvbooz`bmgjgbwfpmftpsbsfqpnzpwfqjlvpGfsbqwnfmwafpw#hmltmsbqojbnfmwpvssqfppfg`lmufmjfmwqfnfnafqfggjeefqfmw#pzpwfnbwj`kbp#ofg#wlsqlsbdbmgb`lmwqloofgjmeovfm`fp`fqfnlmjbosql`objnfgSqlwf`wjlmoj#`obpp>!P`jfmwjej``obpp>!ml.wqbgfnbqhpnlqf#wkbm#tjgfpsqfbgOjafqbwjlmwllh#sob`fgbz#le#wkfbp#olmd#bpjnsqjplmfgBggjwjlmbo\t?kfbg=\t?nObalqbwlqzMlufnafq#1f{`fswjlmpJmgvpwqjboubqjfwz#leeolbw9#ofeGvqjmd#wkfbppfppnfmwkbuf#affm#gfbop#tjwkPwbwjpwj`pl``vqqfm`f,vo=?,gju=`ofbqej{!=wkf#svaoj`nbmz#zfbqptkj`k#tfqflufq#wjnf/pzmlmznlvp`lmwfmw!=\tsqfpvnbaozkjp#ebnjozvpfqBdfmw-vmf{sf`wfgjm`ovgjmd#`kboofmdfgb#njmlqjwzvmgfejmfg!afolmdp#wlwbhfm#eqlnjm#L`wlafqslpjwjlm9#pbjg#wl#afqfojdjlvp#Efgfqbwjlm#qltpsbm>!lmoz#b#eftnfbmw#wkbwofg#wl#wkf..=\x0E\t?gju#?ejfogpfw=Bq`kajpkls#`obpp>!mlafjmd#vpfgbssqlb`kfpsqjujofdfpmlp`qjsw=\tqfpvowp#jmnbz#af#wkfFbpwfq#fddnf`kbmjpnpqfbplmbaofSlsvobwjlm@loof`wjlmpfof`wfg!=mlp`qjsw=\x0E,jmgf{-sksbqqjubo#le.ippgh$**8nbmbdfg#wljm`lnsofwf`bpvbowjfp`lnsofwjlm@kqjpwjbmpPfswfnafq#bqjwknfwj`sql`fgvqfpnjdkw#kbufSqlgv`wjlmjw#bssfbqpSkjolplskzeqjfmgpkjsofbgjmd#wldjujmd#wkfwltbqg#wkfdvbqbmwffggl`vnfmwfg`lolq9 333ujgfl#dbnf`lnnjppjlmqfeof`wjmd`kbmdf#wkfbppl`jbwfgpbmp.pfqjelmhfzsqfpp8#sbggjmd9Kf#tbp#wkfvmgfqozjmdwzsj`booz#/#bmg#wkf#pq`Fofnfmwpv``fppjufpjm`f#wkf#pklvog#af#mfwtlqhjmdb``lvmwjmdvpf#le#wkfoltfq#wkbmpkltp#wkbw?,psbm=\t\n\n`lnsobjmwp`lmwjmvlvprvbmwjwjfpbpwqlmlnfqkf#gjg#mlwgvf#wl#jwpbssojfg#wlbm#bufqbdffeelqwp#wlwkf#evwvqfbwwfnsw#wlWkfqfelqf/`bsbajojwzQfsvaoj`bmtbp#elqnfgFof`wqlmj`hjolnfwfqp`kboofmdfpsvaojpkjmdwkf#elqnfqjmgjdfmlvpgjqf`wjlmppvapjgjbqz`lmpsjqb`zgfwbjop#lebmg#jm#wkfbeelqgbaofpvapwbm`fpqfbplm#elq`lmufmwjlmjwfnwzsf>!baplovwfozpvsslpfgozqfnbjmfg#bbwwqb`wjufwqbufoojmdpfsbqbwfozel`vpfp#lmfofnfmwbqzbssoj`baofelvmg#wkbwpwzofpkffwnbmvp`qjswpwbmgp#elq#ml.qfsfbw+plnfwjnfp@lnnfq`jbojm#Bnfqj`bvmgfqwbhfmrvbqwfq#lebm#f{bnsofsfqplmboozjmgf{-sks<?,avwwlm=\tsfq`fmwbdfafpw.hmltm`qfbwjmd#b!#gjq>!owqOjfvwfmbmw\t?gju#jg>!wkfz#tlvogbajojwz#lenbgf#vs#lemlwfg#wkbw`ofbq#wkbwbqdvf#wkbwwl#bmlwkfq`kjogqfm$psvqslpf#leelqnvobwfgabpfg#vslmwkf#qfdjlmpvaif`w#lesbppfmdfqpslppfppjlm-\t\tJm#wkf#Afelqf#wkfbewfqtbqgp`vqqfmwoz#b`qlpp#wkfp`jfmwjej``lnnvmjwz-`bsjwbojpnjm#Dfqnbmzqjdkw.tjmdwkf#pzpwfnPl`jfwz#leslojwj`jbmgjqf`wjlm9tfmw#lm#wlqfnlubo#le#Mft#Zlqh#bsbqwnfmwpjmgj`bwjlmgvqjmd#wkfvmofpp#wkfkjpwlqj`bokbg#affm#bgfejmjwjufjmdqfgjfmwbwwfmgbm`f@fmwfq#elqsqlnjmfm`fqfbgzPwbwfpwqbwfdjfpavw#jm#wkfbp#sbqw#le`lmpwjwvwf`objn#wkbwobalqbwlqz`lnsbwjaofebjovqf#le/#pv`k#bp#afdbm#tjwkvpjmd#wkf#wl#sqlujgfefbwvqf#leeqln#tkj`k,!#`obpp>!dfloldj`bopfufqbo#legfojafqbwfjnslqwbmw#klogp#wkbwjmd%rvlw8#ubojdm>wlswkf#Dfqnbmlvwpjgf#lemfdlwjbwfgkjp#`bqffqpfsbqbwjlmjg>!pfbq`ktbp#`boofgwkf#elvqwkqf`qfbwjlmlwkfq#wkbmsqfufmwjlmtkjof#wkf#fgv`bwjlm/`lmmf`wjmdb``vqbwfoztfqf#avjowtbp#hjoofgbdqffnfmwpnv`k#nlqf#Gvf#wl#wkftjgwk9#233plnf#lwkfqHjmdgln#lewkf#fmwjqfebnlvp#elqwl#`lmmf`wlaif`wjufpwkf#Eqfm`ksflsof#bmgefbwvqfg!=jp#pbjg#wlpwqv`wvqboqfefqfmgvnnlpw#lewfmb#pfsbqbwf.=\t?gju#jg#Leej`jbo#tlqogtjgf-bqjb.obafowkf#sobmfwbmg#jw#tbpg!#ubovf>!ollhjmd#bwafmfej`jbobqf#jm#wkfnlmjwlqjmdqfslqwfgozwkf#nlgfqmtlqhjmd#lmbooltfg#wltkfqf#wkf#jmmlubwjuf?,b=?,gju=plvmgwqb`hpfbq`kElqnwfmg#wl#afjmsvw#jg>!lsfmjmd#leqfpwqj`wfgbglswfg#azbggqfppjmdwkfloldjbmnfwklgp#leubqjbmw#le@kqjpwjbm#ufqz#obqdfbvwlnlwjufaz#ebq#wkfqbmdf#eqlnsvqpvjw#leeloolt#wkfaqlvdkw#wljm#Fmdobmgbdqff#wkbwb``vpfg#le`lnfp#eqlnsqfufmwjmdgju#pwzof>kjp#lq#kfqwqfnfmglvpeqffgln#le`lm`fqmjmd3#2fn#2fn8Abphfwaboo,pwzof-`ppbm#fbqojfqfufm#bewfq,!#wjwof>!-`ln,jmgf{wbhjmd#wkfsjwwpavqdk`lmwfmw!=\x0E?p`qjsw=+ewvqmfg#lvwkbujmd#wkf?,psbm=\x0E\t#l``bpjlmboaf`bvpf#jwpwbqwfg#wlskzpj`booz=?,gju=\t##`qfbwfg#az@vqqfmwoz/#ad`lolq>!wbajmgf{>!gjpbpwqlvpBmbozwj`p#bopl#kbp#b=?gju#jg>!?,pwzof=\t?`boofg#elqpjmdfq#bmg-pq`#>#!,,ujlobwjlmpwkjp#sljmw`lmpwbmwozjp#ol`bwfgqf`lqgjmdpg#eqln#wkfmfgfqobmgpslqwvdv/Fp;N;};D;u;F5m4K4]4_7`gfpbqqlool`lnfmwbqjlfgv`b`j/_mpfswjfnaqfqfdjpwqbglgjqf``j/_mvaj`b`j/_msvaoj`jgbgqfpsvfpwbpqfpvowbglpjnslqwbmwfqfpfqubglpbqw/A`volpgjefqfmwfppjdvjfmwfpqfs/Vaoj`bpjwvb`j/_mnjmjpwfqjlsqjub`jgbggjqf`wlqjlelqnb`j/_mslaob`j/_msqfpjgfmwf`lmw", "fmjglpb``fplqjlpwf`kmlqbwjsfqplmbofp`bwfdlq/Abfpsf`jbofpgjpslmjaofb`wvbojgbgqfefqfm`jbuboobglojgajaojlwf`bqfob`jlmfp`bofmgbqjlslo/Awj`bpbmwfqjlqfpgl`vnfmwlpmbwvqbofybnbwfqjbofpgjefqfm`jbf`lm/_nj`bwqbmpslqwfqlgq/Advfysbqwj`jsbqfm`vfmwqbmgjp`vpj/_mfpwqv`wvqbevmgb`j/_meqf`vfmwfpsfqnbmfmwfwlwbonfmwf<P<R<Z<Q<R<]=o<X<Y=n<P<R<Z<Y=n<^=l<Y<P=c=n<\\<V<Z<Y=k=n<R<]=g<]<R<W<Y<Y<R=k<Y<Q=`=a=n<R<_<R<V<R<_<X<\\<S<R=m<W<Y<^=m<Y<_<R=m<\\<U=n<Y=k<Y=l<Y<[<P<R<_=o=n=m<\\<U=n<\\<Z<T<[<Q<T<P<Y<Z<X=o<]=o<X=o=n<s<R<T=m<V<[<X<Y=m=`<^<T<X<Y<R=m<^=c<[<T<Q=o<Z<Q<R=m<^<R<Y<U<W=b<X<Y<U<S<R=l<Q<R<P<Q<R<_<R<X<Y=n<Y<U=m<^<R<T=i<S=l<\\<^<\\=n<\\<V<R<U<P<Y=m=n<R<T<P<Y<Y=n<Z<T<[<Q=`<R<X<Q<R<U<W=o=k=d<Y<S<Y=l<Y<X=k<\\=m=n<T=k<\\=m=n=`=l<\\<]<R=n<Q<R<^=g=i<S=l<\\<^<R=m<R<]<R<U<S<R=n<R<P<P<Y<Q<Y<Y=k<T=m<W<Y<Q<R<^=g<Y=o=m<W=o<_<R<V<R<W<R<Q<\\<[<\\<X=n<\\<V<R<Y=n<R<_<X<\\<S<R=k=n<T<s<R=m<W<Y=n<\\<V<T<Y<Q<R<^=g<U=m=n<R<T=n=n<\\<V<T=i=m=l<\\<[=o<M<\\<Q<V=n=h<R=l=o<P<v<R<_<X<\\<V<Q<T<_<T=m<W<R<^<\\<Q<\\=d<Y<U<Q<\\<U=n<T=m<^<R<T<P=m<^=c<[=`<W=b<]<R<U=k<\\=m=n<R=m=l<Y<X<T<v=l<R<P<Y<H<R=l=o<P=l=g<Q<V<Y=m=n<\\<W<T<S<R<T=m<V=n=g=m=c=k<P<Y=m=c=j=j<Y<Q=n=l=n=l=o<X<\\=m<\\<P=g=i=l=g<Q<V<\\<q<R<^=g<U=k<\\=m<R<^<P<Y=m=n<\\=h<T<W=`<P<P<\\=l=n<\\=m=n=l<\\<Q<P<Y=m=n<Y=n<Y<V=m=n<Q<\\=d<T=i<P<T<Q=o=n<T<P<Y<Q<T<T<P<Y=b=n<Q<R<P<Y=l<_<R=l<R<X=m<\\<P<R<P=a=n<R<P=o<V<R<Q=j<Y=m<^<R<Y<P<V<\\<V<R<U<|=l=i<T<^5i5j4F4C5e4I4]4_4K5h4]4_4K5h4E4K5h4U4K5i5o4F4D5k4K4D4]4K5i4@4K5h5f5d5i4K5h4Y5d4]4@4C5f4C4E4K5h4U4Z5d4I4Z4K5m4E4K5h5n4_5i4K5h4U4K4D4F4A5i5f5h5i5h5m4K4F5i5h4F5n5e4F4U4C5f5h4K5h4X4U4]4O4B4D4K4]4F4[5d5f4]4U5h5f5o5i4I4]5m4K5n4[5h4D4K4F4K5h5h4V4E4F4]4F5f4D4K5h5j4K4_4K5h4X5f4B5i5j4F4C5f4K5h4U4]4D4K5h5n4Y4Y4K5m5h4K5i4U5h5f5k4K4F4A4C5f4G4K5h5h5k5i4K5h4U5i5h5i5o4F4D4E5f5i5o5j5o4K5h4[5m5h5m5f4C5f5d4I4C4K4]4E4F4K4]5f4B4K5h4Y4A4E4F4_4@5f5h4K5h5d5n4F4U5j4C5i4K5i4C5f5j4E4F4Y5i5f5i4O4]4X5f5m4K5h4\\5f5j4U4]4D5f4E4D5d4K4D4E4O5h4U4K4D4K5h4_5m4]5i4X4K5o5h4F4U4K5h5e4K5h4O5d5h4K5h4_5j4E4@4K5i4U4E4K5h4Y4A5m4K5h4C5f5j5o5h5i4K4F4K5h4B4K4Y4K5h5i5h5m4O4U4Z4K4M5o4F4K4D4E4K5h4B5f4]4]4_4K4J5h4K5h5n5h4D4K5h4O4C4D5i5n4K4[4U5i4]4K4_5h5i5j4[5n4E4K5h5o4F4D4K5h4]4@5h4K4X4F4]5o4K5h5n4C5i5f4U4[5f5opAzWbdMbnf+-isd!#bow>!2s{#plojg# -dje!#bow>!wqbmpsbqfmwjmelqnbwjlmbssoj`bwjlm!#lm`oj`h>!fpwbaojpkfgbgufqwjpjmd-smd!#bow>!fmujqlmnfmwsfqelqnbm`fbssqlsqjbwf%bns8ngbpk8jnnfgjbwfoz?,pwqlmd=?,qbwkfq#wkbmwfnsfqbwvqfgfufolsnfmw`lnsfwjwjlmsob`fklogfqujpjajojwz9`lszqjdkw!=3!#kfjdkw>!fufm#wklvdkqfsob`fnfmwgfpwjmbwjlm@lqslqbwjlm?vo#`obpp>!Bppl`jbwjlmjmgjujgvbopsfqpsf`wjufpfwWjnflvw+vqo+kwws9,,nbwkfnbwj`pnbqdjm.wls9fufmwvbooz#gfp`qjswjlm*#ml.qfsfbw`loof`wjlmp-ISD\x7Fwkvna\x7Fsbqwj`jsbwf,kfbg=?algzeolbw9ofew8?oj#`obpp>!kvmgqfgp#le\t\tKltfufq/#`lnslpjwjlm`ofbq9alwk8`llsfqbwjlmtjwkjm#wkf#obafo#elq>!alqgfq.wls9Mft#Yfbobmgqf`lnnfmgfgsklwldqbskzjmwfqfpwjmd%ow8pvs%dw8`lmwqlufqpzMfwkfqobmgpbowfqmbwjufnb{ofmdwk>!ptjwyfqobmgGfufolsnfmwfppfmwjbooz\t\tBowklvdk#?,wf{wbqfb=wkvmgfqajqgqfsqfpfmwfg%bns8mgbpk8psf`vobwjlm`lnnvmjwjfpofdjpobwjlmfof`wqlmj`p\t\n?gju#jg>!joovpwqbwfgfmdjmffqjmdwfqqjwlqjfpbvwklqjwjfpgjpwqjavwfg5!#kfjdkw>!pbmp.pfqje8`bsbaof#le#gjpbssfbqfgjmwfqb`wjufollhjmd#elqjw#tlvog#afBedkbmjpwbmtbp#`qfbwfgNbwk-eollq+pvqqlvmgjmd`bm#bopl#aflapfqubwjlmnbjmwfmbm`ffm`lvmwfqfg?k1#`obpp>!nlqf#qf`fmwjw#kbp#affmjmubpjlm#le*-dfwWjnf+*evmgbnfmwboGfpsjwf#wkf!=?gju#jg>!jmpsjqbwjlmf{bnjmbwjlmsqfsbqbwjlmf{sobmbwjlm?jmsvw#jg>!?,b=?,psbm=ufqpjlmp#lejmpwqvnfmwpafelqf#wkf##>#$kwws9,,Gfp`qjswjlmqfobwjufoz#-pvapwqjmd+fb`k#le#wkff{sfqjnfmwpjmeovfmwjbojmwfdqbwjlmnbmz#sflsofgvf#wl#wkf#`lnajmbwjlmgl#mlw#kbufNjggof#Fbpw?mlp`qjsw=?`lszqjdkw!#sfqkbsp#wkfjmpwjwvwjlmjm#Gf`fnafqbqqbmdfnfmwnlpw#ebnlvpsfqplmbojwz`qfbwjlm#leojnjwbwjlmpf{`ovpjufozplufqfjdmwz.`lmwfmw!=\t?wg#`obpp>!vmgfqdqlvmgsbqboofo#wlgl`wqjmf#lel``vsjfg#azwfqnjmloldzQfmbjppbm`fb#mvnafq#lepvsslqw#elqf{solqbwjlmqf`ldmjwjlmsqfgf`fpplq?jnd#pq`>!,?k2#`obpp>!svaoj`bwjlmnbz#bopl#afpsf`jbojyfg?,ejfogpfw=sqldqfppjufnjoojlmp#lepwbwfp#wkbwfmelq`fnfmwbqlvmg#wkf#lmf#bmlwkfq-sbqfmwMlgfbdqj`vowvqfBowfqmbwjufqfpfbq`kfqpwltbqgp#wkfNlpw#le#wkfnbmz#lwkfq#+fpsf`jbooz?wg#tjgwk>!8tjgwk9233&jmgfsfmgfmw?k0#`obpp>!#lm`kbmdf>!*-bgg@obpp+jmwfqb`wjlmLmf#le#wkf#gbvdkwfq#leb``fpplqjfpaqbm`kfp#le\x0E\t?gju#jg>!wkf#obqdfpwgf`obqbwjlmqfdvobwjlmpJmelqnbwjlmwqbmpobwjlmgl`vnfmwbqzjm#lqgfq#wl!=\t?kfbg=\t?!#kfjdkw>!2b`qlpp#wkf#lqjfmwbwjlm*8?,p`qjsw=jnsofnfmwfg`bm#af#pffmwkfqf#tbp#bgfnlmpwqbwf`lmwbjmfq!=`lmmf`wjlmpwkf#Aqjwjpktbp#tqjwwfm\"jnslqwbmw8s{8#nbqdjm.elooltfg#azbajojwz#wl#`lnsoj`bwfggvqjmd#wkf#jnnjdqbwjlmbopl#`boofg?k7#`obpp>!gjpwjm`wjlmqfsob`fg#azdlufqmnfmwpol`bwjlm#lejm#Mlufnafqtkfwkfq#wkf?,s=\t?,gju=b`rvjpjwjlm`boofg#wkf#sfqpf`vwjlmgfpjdmbwjlmxelmw.pjyf9bssfbqfg#jmjmufpwjdbwff{sfqjfm`fgnlpw#ojhfoztjgfoz#vpfggjp`vppjlmpsqfpfm`f#le#+gl`vnfmw-f{wfmpjufozJw#kbp#affmjw#glfp#mlw`lmwqbqz#wljmkbajwbmwpjnsqlufnfmwp`klobqpkjs`lmpvnswjlmjmpwqv`wjlmelq#f{bnsoflmf#lq#nlqfs{8#sbggjmdwkf#`vqqfmwb#pfqjfp#lebqf#vpvboozqlof#jm#wkfsqfujlvpoz#gfqjubwjufpfujgfm`f#lef{sfqjfm`fp`lolqp`kfnfpwbwfg#wkbw`fqwjej`bwf?,b=?,gju=\t#pfof`wfg>!kjdk#p`klloqfpslmpf#wl`lnelqwbaofbglswjlm#lewkqff#zfbqpwkf#`lvmwqzjm#Efaqvbqzpl#wkbw#wkfsflsof#tkl#sqlujgfg#az?sbqbn#mbnfbeef`wfg#azjm#wfqnp#lebssljmwnfmwJPL.;;6:.2!tbp#alqm#jmkjpwlqj`bo#qfdbqgfg#bpnfbpvqfnfmwjp#abpfg#lm#bmg#lwkfq#9#evm`wjlm+pjdmjej`bmw`fofaqbwjlmwqbmpnjwwfg,ip,irvfqz-jp#hmltm#bpwkflqfwj`bo#wbajmgf{>!jw#`lvog#af?mlp`qjsw=\tkbujmd#affm\x0E\t?kfbg=\x0E\t?#%rvlw8Wkf#`lnsjobwjlmkf#kbg#affmsqlgv`fg#azskjolplskfq`lmpwqv`wfgjmwfmgfg#wlbnlmd#lwkfq`lnsbqfg#wlwl#pbz#wkbwFmdjmffqjmdb#gjeefqfmwqfefqqfg#wlgjeefqfm`fpafojfe#wkbwsklwldqbskpjgfmwjezjmdKjpwlqz#le#Qfsvaoj`#lemf`fppbqjozsqlabajojwzwf`kmj`boozofbujmd#wkfpsf`wb`vobqeqb`wjlm#lefof`wqj`jwzkfbg#le#wkfqfpwbvqbmwpsbqwmfqpkjsfnskbpjp#lmnlpw#qf`fmwpkbqf#tjwk#pbzjmd#wkbwejoofg#tjwkgfpjdmfg#wljw#jp#lewfm!=?,jeqbnf=bp#elooltp9nfqdfg#tjwkwkqlvdk#wkf`lnnfq`jbo#sljmwfg#lvwlsslqwvmjwzujft#le#wkfqfrvjqfnfmwgjujpjlm#lesqldqbnnjmdkf#qf`fjufgpfwJmwfqubo!=?,psbm=?,jm#Mft#Zlqhbggjwjlmbo#`lnsqfppjlm\t\t?gju#jg>!jm`lqslqbwf8?,p`qjsw=?bwwb`kFufmwaf`bnf#wkf#!#wbqdfw>!\\`bqqjfg#lvwPlnf#le#wkfp`jfm`f#bmgwkf#wjnf#le@lmwbjmfq!=nbjmwbjmjmd@kqjpwlskfqNv`k#le#wkftqjwjmdp#le!#kfjdkw>!1pjyf#le#wkfufqpjlm#le#nj{wvqf#le#afwtffm#wkfF{bnsofp#lefgv`bwjlmbo`lnsfwjwjuf#lmpvanjw>!gjqf`wlq#legjpwjm`wjuf,GWG#[KWNO#qfobwjmd#wlwfmgfm`z#wlsqlujm`f#letkj`k#tlvoggfpsjwf#wkfp`jfmwjej`#ofdjpobwvqf-jmmfqKWNO#boofdbwjlmpBdqj`vowvqftbp#vpfg#jmbssqlb`k#wljmwfoojdfmwzfbqp#obwfq/pbmp.pfqjegfwfqnjmjmdSfqelqnbm`fbssfbqbm`fp/#tkj`k#jp#elvmgbwjlmpbaaqfujbwfgkjdkfq#wkbmp#eqln#wkf#jmgjujgvbo#`lnslpfg#lepvsslpfg#wl`objnp#wkbwbwwqjavwjlmelmw.pjyf92fofnfmwp#leKjpwlqj`bo#kjp#aqlwkfqbw#wkf#wjnfbmmjufqpbqzdlufqmfg#azqfobwfg#wl#vowjnbwfoz#jmmlubwjlmpjw#jp#pwjoo`bm#lmoz#afgfejmjwjlmpwlDNWPwqjmdB#mvnafq#lejnd#`obpp>!Fufmwvbooz/tbp#`kbmdfgl``vqqfg#jmmfjdkalqjmdgjpwjmdvjpktkfm#kf#tbpjmwqlgv`jmdwfqqfpwqjboNbmz#le#wkfbqdvfp#wkbwbm#Bnfqj`bm`lmrvfpw#letjgfpsqfbg#tfqf#hjoofgp`qffm#bmg#Jm#lqgfq#wlf{sf`wfg#wlgfp`fmgbmwpbqf#ol`bwfgofdjpobwjufdfmfqbwjlmp#ab`hdqlvmgnlpw#sflsofzfbqp#bewfqwkfqf#jp#mlwkf#kjdkfpweqfrvfmwoz#wkfz#gl#mlwbqdvfg#wkbwpkltfg#wkbwsqfglnjmbmwwkfloldj`boaz#wkf#wjnf`lmpjgfqjmdpklqw.ojufg?,psbm=?,b=`bm#af#vpfgufqz#ojwwoflmf#le#wkf#kbg#boqfbgzjmwfqsqfwfg`lnnvmj`bwfefbwvqfp#ledlufqmnfmw/?,mlp`qjsw=fmwfqfg#wkf!#kfjdkw>!0Jmgfsfmgfmwslsvobwjlmpobqdf.p`bof-#Bowklvdk#vpfg#jm#wkfgfpwqv`wjlmslppjajojwzpwbqwjmd#jmwtl#lq#nlqff{sqfppjlmppvalqgjmbwfobqdfq#wkbmkjpwlqz#bmg?,lswjlm=\x0E\t@lmwjmfmwbofojnjmbwjmdtjoo#mlw#afsqb`wj`f#lejm#eqlmw#lepjwf#le#wkffmpvqf#wkbwwl#`qfbwf#bnjppjppjssjslwfmwjboozlvwpwbmgjmdafwwfq#wkbmtkbw#jp#mltpjwvbwfg#jmnfwb#mbnf>!WqbgjwjlmbopvddfpwjlmpWqbmpobwjlmwkf#elqn#lebwnlpskfqj`jgfloldj`bofmwfqsqjpfp`bo`vobwjmdfbpw#le#wkfqfnmbmwp#lesovdjmpsbdf,jmgf{-sks<qfnbjmfg#jmwqbmpelqnfgKf#tbp#bopltbp#boqfbgzpwbwjpwj`bojm#ebulq#leNjmjpwqz#lenlufnfmw#leelqnvobwjlmjp#qfrvjqfg?ojmh#qfo>!Wkjp#jp#wkf#?b#kqfe>!,slsvobqjyfgjmuloufg#jmbqf#vpfg#wlbmg#pfufqbonbgf#az#wkfpffnp#wl#afojhfoz#wkbwSbofpwjmjbmmbnfg#bewfqjw#kbg#affmnlpw#`lnnlmwl#qfefq#wlavw#wkjp#jp`lmpf`vwjufwfnslqbqjozJm#dfmfqbo/`lmufmwjlmpwbhfp#sob`fpvagjujpjlmwfqqjwlqjbolsfqbwjlmbosfqnbmfmwoztbp#obqdfozlvwaqfbh#lejm#wkf#sbpwelooltjmd#b#{nomp9ld>!=?b#`obpp>!`obpp>!wf{w@lmufqpjlm#nbz#af#vpfgnbmveb`wvqfbewfq#afjmd`ofbqej{!=\trvfpwjlm#letbp#fof`wfgwl#af`lnf#baf`bvpf#le#plnf#sflsofjmpsjqfg#azpv``fppevo#b#wjnf#tkfmnlqf#`lnnlmbnlmdpw#wkfbm#leej`jbotjgwk9233&8wf`kmloldz/tbp#bglswfgwl#hffs#wkfpfwwofnfmwpojuf#ajqwkpjmgf{-kwno!@lmmf`wj`vwbppjdmfg#wl%bns8wjnfp8b``lvmw#elqbojdm>qjdkwwkf#`lnsbmzbotbzp#affmqfwvqmfg#wljmuloufnfmwAf`bvpf#wkfwkjp#sfqjlg!#mbnf>!r!#`lmejmfg#wlb#qfpvow#leubovf>!!#,=jp#b`wvboozFmujqlmnfmw\x0E\t?,kfbg=\x0E\t@lmufqpfoz/=\t?gju#jg>!3!#tjgwk>!2jp#sqlabaozkbuf#af`lnf`lmwqloojmdwkf#sqlaofn`jwjyfmp#leslojwj`jbmpqfb`kfg#wkfbp#fbqoz#bp9mlmf8#lufq?wbaof#`fooubojgjwz#legjqf`woz#wllmnlvpfgltmtkfqf#jw#jptkfm#jw#tbpnfnafqp#le#qfobwjlm#wlb``lnnlgbwfbolmd#tjwk#Jm#wkf#obwfwkf#Fmdojpkgfoj`jlvp!=wkjp#jp#mlwwkf#sqfpfmwje#wkfz#bqfbmg#ejmboozb#nbwwfq#le\x0E\t\n?,gju=\x0E\t\x0E\t?,p`qjsw=ebpwfq#wkbmnbilqjwz#lebewfq#tkj`k`lnsbqbwjufwl#nbjmwbjmjnsqluf#wkfbtbqgfg#wkffq!#`obpp>!eqbnfalqgfqqfpwlqbwjlmjm#wkf#pbnfbmbozpjp#lewkfjq#ejqpwGvqjmd#wkf#`lmwjmfmwbopfrvfm`f#leevm`wjlm+*xelmw.pjyf9#tlqh#lm#wkf?,p`qjsw=\t?afdjmp#tjwkibubp`qjsw9`lmpwjwvfmwtbp#elvmgfgfrvjojaqjvnbppvnf#wkbwjp#djufm#azmffgp#wl#af`llqgjmbwfpwkf#ubqjlvpbqf#sbqw#lelmoz#jm#wkfpf`wjlmp#lejp#b#`lnnlmwkflqjfp#legjp`lufqjfpbppl`jbwjlmfgdf#le#wkfpwqfmdwk#leslpjwjlm#jmsqfpfmw.gbzvmjufqpboozwl#elqn#wkfavw#jmpwfbg`lqslqbwjlmbwwb`kfg#wljp#`lnnlmozqfbplmp#elq#%rvlw8wkf#`bm#af#nbgftbp#baof#wltkj`k#nfbmpavw#gjg#mlwlmNlvpfLufqbp#slppjaoflsfqbwfg#az`lnjmd#eqlnwkf#sqjnbqzbggjwjlm#leelq#pfufqbowqbmpefqqfgb#sfqjlg#lebqf#baof#wlkltfufq/#jwpklvog#kbufnv`k#obqdfq\t\n?,p`qjsw=bglswfg#wkfsqlsfqwz#legjqf`wfg#azfeef`wjufoztbp#aqlvdkw`kjogqfm#leSqldqbnnjmdolmdfq#wkbmnbmvp`qjswptbq#bdbjmpwaz#nfbmp#lebmg#nlpw#lepjnjobq#wl#sqlsqjfwbqzlqjdjmbwjmdsqfpwjdjlvpdqbnnbwj`bof{sfqjfm`f-wl#nbhf#wkfJw#tbp#bopljp#elvmg#jm`lnsfwjwlqpjm#wkf#V-P-qfsob`f#wkfaqlvdkw#wkf`bo`vobwjlmeboo#le#wkfwkf#dfmfqbosqb`wj`boozjm#klmlq#leqfofbpfg#jmqfpjgfmwjbobmg#plnf#lehjmd#le#wkfqfb`wjlm#wl2pw#Fbqo#le`vowvqf#bmgsqjm`jsbooz?,wjwof=\t##wkfz#`bm#afab`h#wl#wkfplnf#le#kjpf{slpvqf#wlbqf#pjnjobqelqn#le#wkfbggEbulqjwf`jwjyfmpkjssbqw#jm#wkfsflsof#tjwkjm#sqb`wj`fwl#`lmwjmvf%bns8njmvp8bssqlufg#az#wkf#ejqpw#booltfg#wkfbmg#elq#wkfevm`wjlmjmdsobzjmd#wkfplovwjlm#wlkfjdkw>!3!#jm#kjp#allhnlqf#wkbm#belooltp#wkf`qfbwfg#wkfsqfpfm`f#jm%maps8?,wg=mbwjlmbojpwwkf#jgfb#leb#`kbqb`wfqtfqf#elq`fg#`obpp>!awmgbzp#le#wkfefbwvqfg#jmpkltjmd#wkfjmwfqfpw#jmjm#sob`f#lewvqm#le#wkfwkf#kfbg#leOlqg#le#wkfslojwj`boozkbp#jwp#ltmFgv`bwjlmbobssqlubo#leplnf#le#wkffb`k#lwkfq/afkbujlq#lebmg#af`bvpfbmg#bmlwkfqbssfbqfg#lmqf`lqgfg#jmaob`h%rvlw8nbz#jm`ovgfwkf#tlqog$p`bm#ofbg#wlqfefqp#wl#balqgfq>!3!#dlufqmnfmw#tjmmjmd#wkfqfpvowfg#jm#tkjof#wkf#Tbpkjmdwlm/wkf#pvaif`w`jwz#jm#wkf=?,gju=\x0E\t\n\nqfeof`w#wkfwl#`lnsofwfaf`bnf#nlqfqbgjlb`wjufqfif`wfg#aztjwklvw#bmzkjp#ebwkfq/tkj`k#`lvog`lsz#le#wkfwl#jmgj`bwfb#slojwj`bob``lvmwp#le`lmpwjwvwfptlqhfg#tjwkfq?,b=?,oj=le#kjp#ojefb``lnsbmjfg`ojfmwTjgwksqfufmw#wkfOfdjpobwjufgjeefqfmwozwldfwkfq#jmkbp#pfufqboelq#bmlwkfqwf{w#le#wkfelvmgfg#wkff#tjwk#wkf#jp#vpfg#elq`kbmdfg#wkfvpvbooz#wkfsob`f#tkfqftkfqfbp#wkf=#?b#kqfe>!!=?b#kqfe>!wkfnpfoufp/bowklvdk#kfwkbw#`bm#afwqbgjwjlmboqlof#le#wkfbp#b#qfpvowqfnluf@kjoggfpjdmfg#aztfpw#le#wkfPlnf#sflsofsqlgv`wjlm/pjgf#le#wkfmftpofwwfqpvpfg#az#wkfgltm#wl#wkfb``fswfg#azojuf#jm#wkfbwwfnswp#wllvwpjgf#wkfeqfrvfm`jfpKltfufq/#jmsqldqbnnfqpbw#ofbpw#jmbssql{jnbwfbowklvdk#jwtbp#sbqw#lebmg#ubqjlvpDlufqmlq#lewkf#bqwj`ofwvqmfg#jmwl=?b#kqfe>!,wkf#f`lmlnzjp#wkf#nlpwnlpw#tjgfoztlvog#obwfqbmg#sfqkbspqjpf#wl#wkfl``vqp#tkfmvmgfq#tkj`k`lmgjwjlmp-wkf#tfpwfqmwkflqz#wkbwjp#sqlgv`fgwkf#`jwz#lejm#tkj`k#kfpffm#jm#wkfwkf#`fmwqboavjogjmd#lenbmz#le#kjpbqfb#le#wkfjp#wkf#lmoznlpw#le#wkfnbmz#le#wkfwkf#TfpwfqmWkfqf#jp#mlf{wfmgfg#wlPwbwjpwj`bo`lopsbm>1#\x7Fpklqw#pwlqzslppjaof#wlwlsloldj`bo`qjwj`bo#leqfslqwfg#wlb#@kqjpwjbmgf`jpjlm#wljp#frvbo#wlsqlaofnp#leWkjp#`bm#afnfq`kbmgjpfelq#nlpw#leml#fujgfm`ffgjwjlmp#lefofnfmwp#jm%rvlw8-#Wkf`ln,jnbdfp,tkj`k#nbhfpwkf#sql`fppqfnbjmp#wkfojwfqbwvqf/jp#b#nfnafqwkf#slsvobqwkf#bm`jfmwsqlaofnp#jmwjnf#le#wkfgfefbwfg#azalgz#le#wkfb#eft#zfbqpnv`k#le#wkfwkf#tlqh#le@bojelqmjb/pfqufg#bp#bdlufqmnfmw-`lm`fswp#lenlufnfmw#jm\n\n?gju#jg>!jw!#ubovf>!obmdvbdf#lebp#wkfz#bqfsqlgv`fg#jmjp#wkbw#wkff{sobjm#wkfgju=?,gju=\tKltfufq#wkfofbg#wl#wkf\n?b#kqfe>!,tbp#dqbmwfgsflsof#kbuf`lmwjmvbooztbp#pffm#bpbmg#qfobwfgwkf#qlof#lesqlslpfg#azle#wkf#afpwfb`k#lwkfq-@lmpwbmwjmfsflsof#eqlngjbof`wp#lewl#qfujpjlmtbp#qfmbnfgb#plvq`f#lewkf#jmjwjboobvm`kfg#jmsqlujgf#wkfwl#wkf#tfpwtkfqf#wkfqfbmg#pjnjobqafwtffm#wtljp#bopl#wkfFmdojpk#bmg`lmgjwjlmp/wkbw#jw#tbpfmwjwofg#wlwkfnpfoufp-rvbmwjwz#leqbmpsbqfm`zwkf#pbnf#bpwl#iljm#wkf`lvmwqz#bmgwkjp#jp#wkfWkjp#ofg#wlb#pwbwfnfmw`lmwqbpw#wlobpwJmgf{Lewkqlvdk#kjpjp#gfpjdmfgwkf#wfqn#jpjp#sqlujgfgsqlwf`w#wkfmd?,b=?,oj=Wkf#`vqqfmwwkf#pjwf#lepvapwbmwjbof{sfqjfm`f/jm#wkf#Tfpwwkfz#pklvogpolufm(ajmb`lnfmwbqjlpvmjufqpjgbg`lmgj`jlmfpb`wjujgbgfpf{sfqjfm`jbwf`mlold/Absqlgv``j/_msvmwvb`j/_mbsoj`b`j/_m`lmwqbpf/]b`bwfdlq/Abpqfdjpwqbqpfsqlefpjlmbowqbwbnjfmwlqfd/Apwqbwfpf`qfwbq/Absqjm`jsbofpsqlwf``j/_mjnslqwbmwfpjnslqwbm`jbslpjajojgbgjmwfqfpbmwf`qf`jnjfmwlmf`fpjgbgfppvp`qjajqpfbpl`jb`j/_mgjpslmjaofpfubovb`j/_mfpwvgjbmwfpqfpslmpbaofqfplov`j/_mdvbgbobibqbqfdjpwqbglplslqwvmjgbg`lnfq`jbofpelwldqbe/Abbvwlqjgbgfpjmdfmjfq/Abwfofujpj/_m`lnsfwfm`jblsfqb`jlmfpfpwbaof`jglpjnsofnfmwfb`wvbonfmwfmbufdb`j/_m`lmelqnjgbgojmf.kfjdkw9elmw.ebnjoz9!#9#!kwws9,,bssoj`bwjlmpojmh!#kqfe>!psf`jej`booz,,?\"X@GBWBX\tLqdbmjybwjlmgjpwqjavwjlm3s{8#kfjdkw9qfobwjlmpkjsgfuj`f.tjgwk?gju#`obpp>!?obafo#elq>!qfdjpwqbwjlm?,mlp`qjsw=\t,jmgf{-kwno!tjmglt-lsfm+#\"jnslqwbmw8bssoj`bwjlm,jmgfsfmgfm`f,,ttt-dlldoflqdbmjybwjlmbvwl`lnsofwfqfrvjqfnfmwp`lmpfqubwjuf?elqn#mbnf>!jmwfoof`wvbonbqdjm.ofew92;wk#`fmwvqzbm#jnslqwbmwjmpwjwvwjlmpbaaqfujbwjlm?jnd#`obpp>!lqdbmjpbwjlm`jujojybwjlm2:wk#`fmwvqzbq`kjwf`wvqfjm`lqslqbwfg13wk#`fmwvqz.`lmwbjmfq!=nlpw#mlwbaoz,=?,b=?,gju=mlwjej`bwjlm$vmgfejmfg$*Evqwkfqnlqf/afojfuf#wkbwjmmfqKWNO#>#sqjlq#wl#wkfgqbnbwj`boozqfefqqjmd#wlmfdlwjbwjlmpkfbgrvbqwfqpPlvwk#Beqj`bvmpv``fppevoSfmmpzoubmjbBp#b#qfpvow/?kwno#obmd>!%ow8,pvs%dw8gfbojmd#tjwkskjobgfoskjbkjpwlqj`booz*8?,p`qjsw=\tsbggjmd.wls9f{sfqjnfmwbodfwBwwqjavwfjmpwqv`wjlmpwf`kmloldjfpsbqw#le#wkf#>evm`wjlm+*xpvap`qjswjlmo-gwg!=\x0E\t?kwdfldqbskj`bo@lmpwjwvwjlm$/#evm`wjlm+pvsslqwfg#azbdqj`vowvqbo`lmpwqv`wjlmsvaoj`bwjlmpelmw.pjyf9#2b#ubqjfwz#le?gju#pwzof>!Fm`z`olsfgjbjeqbnf#pq`>!gfnlmpwqbwfgb``lnsojpkfgvmjufqpjwjfpGfnldqbskj`p*8?,p`qjsw=?gfgj`bwfg#wlhmltofgdf#lepbwjpeb`wjlmsbqwj`vobqoz?,gju=?,gju=Fmdojpk#+VP*bssfmg@kjog+wqbmpnjppjlmp-#Kltfufq/#jmwfoojdfm`f!#wbajmgf{>!eolbw9qjdkw8@lnnlmtfbowkqbmdjmd#eqlnjm#tkj`k#wkfbw#ofbpw#lmfqfsqlgv`wjlmfm`z`olsfgjb8elmw.pjyf92ivqjpgj`wjlmbw#wkbw#wjnf!=?b#`obpp>!Jm#bggjwjlm/gfp`qjswjlm(`lmufqpbwjlm`lmwb`w#tjwkjp#dfmfqboozq!#`lmwfmw>!qfsqfpfmwjmd%ow8nbwk%dw8sqfpfmwbwjlml``bpjlmbooz?jnd#tjgwk>!mbujdbwjlm!=`lnsfmpbwjlm`kbnsjlmpkjsnfgjb>!boo!#ujlobwjlm#leqfefqfm`f#wlqfwvqm#wqvf8Pwqj`w,,FM!#wqbmpb`wjlmpjmwfqufmwjlmufqjej`bwjlmJmelqnbwjlm#gjeej`vowjfp@kbnsjlmpkjs`bsbajojwjfp?\"Xfmgje^..=~\t?,p`qjsw=\t@kqjpwjbmjwzelq#f{bnsof/Sqlefppjlmboqfpwqj`wjlmppvddfpw#wkbwtbp#qfofbpfg+pv`k#bp#wkfqfnluf@obpp+vmfnsolznfmwwkf#Bnfqj`bmpwqv`wvqf#le,jmgf{-kwno#svaojpkfg#jmpsbm#`obpp>!!=?b#kqfe>!,jmwqlgv`wjlmafolmdjmd#wl`objnfg#wkbw`lmpfrvfm`fp?nfwb#mbnf>!Dvjgf#wl#wkflufqtkfonjmdbdbjmpw#wkf#`lm`fmwqbwfg/\t-mlmwlv`k#lapfqubwjlmp?,b=\t?,gju=\te#+gl`vnfmw-alqgfq9#2s{#xelmw.pjyf92wqfbwnfmw#le3!#kfjdkw>!2nlgjej`bwjlmJmgfsfmgfm`fgjujgfg#jmwldqfbwfq#wkbmb`kjfufnfmwpfpwbaojpkjmdIbubP`qjsw!#mfufqwkfofpppjdmjej`bm`fAqlbg`bpwjmd=%maps8?,wg=`lmwbjmfq!=\tpv`k#bp#wkf#jmeovfm`f#leb#sbqwj`vobqpq`>$kwws9,,mbujdbwjlm!#kboe#le#wkf#pvapwbmwjbo#%maps8?,gju=bgubmwbdf#legjp`lufqz#leevmgbnfmwbo#nfwqlslojwbmwkf#lsslpjwf!#{no9obmd>!gfojafqbwfozbojdm>`fmwfqfulovwjlm#lesqfpfqubwjlmjnsqlufnfmwpafdjmmjmd#jmIfpvp#@kqjpwSvaoj`bwjlmpgjpbdqffnfmwwf{w.bojdm9q/#evm`wjlm+*pjnjobqjwjfpalgz=?,kwno=jp#`vqqfmwozboskbafwj`bojp#plnfwjnfpwzsf>!jnbdf,nbmz#le#wkf#eolt9kjggfm8bubjobaof#jmgfp`qjaf#wkff{jpwfm`f#leboo#lufq#wkfwkf#Jmwfqmfw\n?vo#`obpp>!jmpwboobwjlmmfjdkalqkllgbqnfg#elq`fpqfgv`jmd#wkf`lmwjmvfp#wlMlmfwkfofpp/wfnsfqbwvqfp\t\n\n?b#kqfe>!`olpf#wl#wkff{bnsofp#le#jp#balvw#wkf+pff#afolt*-!#jg>!pfbq`ksqlefppjlmbojp#bubjobaofwkf#leej`jbo\n\n?,p`qjsw=\t\t\n\n?gju#jg>!b``fofqbwjlmwkqlvdk#wkf#Kboo#le#Ebnfgfp`qjswjlmpwqbmpobwjlmpjmwfqefqfm`f#wzsf>$wf{w,qf`fmw#zfbqpjm#wkf#tlqogufqz#slsvobqxab`hdqlvmg9wqbgjwjlmbo#plnf#le#wkf#`lmmf`wfg#wlf{soljwbwjlmfnfqdfm`f#le`lmpwjwvwjlmB#Kjpwlqz#lepjdmjej`bmw#nbmveb`wvqfgf{sf`wbwjlmp=?mlp`qjsw=?`bm#af#elvmgaf`bvpf#wkf#kbp#mlw#affmmfjdkalvqjmdtjwklvw#wkf#bggfg#wl#wkf\n?oj#`obpp>!jmpwqvnfmwboPlujfw#Vmjlmb`hmltofgdfgtkj`k#`bm#afmbnf#elq#wkfbwwfmwjlm#wlbwwfnswp#wl#gfufolsnfmwpJm#eb`w/#wkf?oj#`obpp>!bjnsoj`bwjlmppvjwbaof#elqnv`k#le#wkf#`lolmjybwjlmsqfpjgfmwjbo`bm`foAvaaof#Jmelqnbwjlmnlpw#le#wkf#jp#gfp`qjafgqfpw#le#wkf#nlqf#lq#ofppjm#PfswfnafqJmwfoojdfm`fpq`>!kwws9,,s{8#kfjdkw9#bubjobaof#wlnbmveb`wvqfqkvnbm#qjdkwpojmh#kqfe>!,bubjobajojwzsqlslqwjlmbolvwpjgf#wkf#bpwqlmlnj`bokvnbm#afjmdpmbnf#le#wkf#bqf#elvmg#jmbqf#abpfg#lmpnboofq#wkbmb#sfqplm#tklf{sbmpjlm#lebqdvjmd#wkbwmlt#hmltm#bpJm#wkf#fbqozjmwfqnfgjbwfgfqjufg#eqlnP`bmgjmbujbm?,b=?,gju=\x0E\t`lmpjgfq#wkfbm#fpwjnbwfgwkf#Mbwjlmbo?gju#jg>!sbdqfpvowjmd#jm`lnnjppjlmfgbmboldlvp#wlbqf#qfrvjqfg,vo=\t?,gju=\ttbp#abpfg#lmbmg#af`bnf#b%maps8%maps8w!#ubovf>!!#tbp#`bswvqfgml#nlqf#wkbmqfpsf`wjufoz`lmwjmvf#wl#=\x0E\t?kfbg=\x0E\t?tfqf#`qfbwfgnlqf#dfmfqbojmelqnbwjlm#vpfg#elq#wkfjmgfsfmgfmw#wkf#Jnsfqjbo`lnslmfmw#lewl#wkf#mlqwkjm`ovgf#wkf#@lmpwqv`wjlmpjgf#le#wkf#tlvog#mlw#afelq#jmpwbm`fjmufmwjlm#lenlqf#`lnsof{`loof`wjufozab`hdqlvmg9#wf{w.bojdm9#jwp#lqjdjmbojmwl#b``lvmwwkjp#sql`fppbm#f{wfmpjufkltfufq/#wkfwkfz#bqf#mlwqfif`wfg#wkf`qjwj`jpn#legvqjmd#tkj`ksqlabaoz#wkfwkjp#bqwj`of+evm`wjlm+*xJw#pklvog#afbm#bdqffnfmwb``jgfmwboozgjeefqp#eqlnBq`kjwf`wvqfafwwfq#hmltmbqqbmdfnfmwpjmeovfm`f#lmbwwfmgfg#wkfjgfmwj`bo#wlplvwk#le#wkfsbpp#wkqlvdk{no!#wjwof>!tfjdkw9alog8`qfbwjmd#wkfgjpsobz9mlmfqfsob`fg#wkf?jnd#pq`>!,jkwwsp9,,ttt-Tlqog#Tbq#JJwfpwjnlmjbopelvmg#jm#wkfqfrvjqfg#wl#bmg#wkbw#wkfafwtffm#wkf#tbp#gfpjdmfg`lmpjpwp#le#`lmpjgfqbaozsvaojpkfg#azwkf#obmdvbdf@lmpfqubwjlm`lmpjpwfg#leqfefq#wl#wkfab`h#wl#wkf#`pp!#nfgjb>!Sflsof#eqln#bubjobaof#lmsqlufg#wl#afpvddfpwjlmp!tbp#hmltm#bpubqjfwjfp#leojhfoz#wl#af`lnsqjpfg#lepvsslqw#wkf#kbmgp#le#wkf`lvsofg#tjwk`lmmf`w#bmg#alqgfq9mlmf8sfqelqnbm`fpafelqf#afjmdobwfq#af`bnf`bo`vobwjlmplewfm#`boofgqfpjgfmwp#lenfbmjmd#wkbw=?oj#`obpp>!fujgfm`f#elqf{sobmbwjlmpfmujqlmnfmwp!=?,b=?,gju=tkj`k#booltpJmwqlgv`wjlmgfufolsfg#azb#tjgf#qbmdflm#afkboe#leubojdm>!wls!sqjm`jsof#lebw#wkf#wjnf/?,mlp`qjsw=\x0Epbjg#wl#kbufjm#wkf#ejqpwtkjof#lwkfqpkzslwkfwj`boskjolplskfqpsltfq#le#wkf`lmwbjmfg#jmsfqelqnfg#azjmbajojwz#wltfqf#tqjwwfmpsbm#pwzof>!jmsvw#mbnf>!wkf#rvfpwjlmjmwfmgfg#elqqfif`wjlm#lejnsojfp#wkbwjmufmwfg#wkfwkf#pwbmgbqgtbp#sqlabaozojmh#afwtffmsqlefpplq#lejmwfqb`wjlmp`kbmdjmd#wkfJmgjbm#L`fbm#`obpp>!obpwtlqhjmd#tjwk$kwws9,,ttt-zfbqp#afelqfWkjp#tbp#wkfqf`qfbwjlmbofmwfqjmd#wkfnfbpvqfnfmwpbm#f{wqfnfozubovf#le#wkfpwbqw#le#wkf\t?,p`qjsw=\t\tbm#feelqw#wljm`qfbpf#wkfwl#wkf#plvwkpsb`jmd>!3!=pveej`jfmwozwkf#Fvqlsfbm`lmufqwfg#wl`ofbqWjnflvwgjg#mlw#kbuf`lmpfrvfmwozelq#wkf#mf{wf{wfmpjlm#lef`lmlnj`#bmgbowklvdk#wkfbqf#sqlgv`fgbmg#tjwk#wkfjmpveej`jfmwdjufm#az#wkfpwbwjmd#wkbwf{sfmgjwvqfp?,psbm=?,b=\twklvdkw#wkbwlm#wkf#abpjp`foosbggjmd>jnbdf#le#wkfqfwvqmjmd#wljmelqnbwjlm/pfsbqbwfg#azbppbppjmbwfgp!#`lmwfmw>!bvwklqjwz#lemlqwktfpwfqm?,gju=\t?gju#!=?,gju=\x0E\t##`lmpvowbwjlm`lnnvmjwz#lewkf#mbwjlmbojw#pklvog#afsbqwj`jsbmwp#bojdm>!ofewwkf#dqfbwfpwpfof`wjlm#lepvsfqmbwvqbogfsfmgfmw#lmjp#nfmwjlmfgbooltjmd#wkftbp#jmufmwfgb``lnsbmzjmdkjp#sfqplmbobubjobaof#bwpwvgz#le#wkflm#wkf#lwkfqf{f`vwjlm#leKvnbm#Qjdkwpwfqnp#le#wkfbppl`jbwjlmpqfpfbq`k#bmgpv``ffgfg#azgfefbwfg#wkfbmg#eqln#wkfavw#wkfz#bqf`lnnbmgfq#lepwbwf#le#wkfzfbqp#le#bdfwkf#pwvgz#le?vo#`obpp>!psob`f#jm#wkftkfqf#kf#tbp?oj#`obpp>!ewkfqf#bqf#mltkj`k#af`bnfkf#svaojpkfgf{sqfppfg#jmwl#tkj`k#wkf`lnnjppjlmfqelmw.tfjdkw9wfqqjwlqz#lef{wfmpjlmp!=Qlnbm#Fnsjqffrvbo#wl#wkfJm#`lmwqbpw/kltfufq/#bmgjp#wzsj`boozbmg#kjp#tjef+bopl#`boofg=?vo#`obpp>!feef`wjufoz#fuloufg#jmwlpffn#wl#kbuftkj`k#jp#wkfwkfqf#tbp#mlbm#f{`foofmwboo#le#wkfpfgfp`qjafg#azJm#sqb`wj`f/aqlbg`bpwjmd`kbqdfg#tjwkqfeof`wfg#jmpvaif`wfg#wlnjojwbqz#bmgwl#wkf#sljmwf`lmlnj`boozpfwWbqdfwjmdbqf#b`wvboozuj`wlqz#lufq+*8?,p`qjsw=`lmwjmvlvpozqfrvjqfg#elqfulovwjlmbqzbm#feef`wjufmlqwk#le#wkf/#tkj`k#tbp#eqlmw#le#wkflq#lwkfqtjpfplnf#elqn#lekbg#mlw#affmdfmfqbwfg#azjmelqnbwjlm-sfqnjwwfg#wljm`ovgfp#wkfgfufolsnfmw/fmwfqfg#jmwlwkf#sqfujlvp`lmpjpwfmwozbqf#hmltm#bpwkf#ejfog#lewkjp#wzsf#ledjufm#wl#wkfwkf#wjwof#le`lmwbjmp#wkfjmpwbm`fp#lejm#wkf#mlqwkgvf#wl#wkfjqbqf#gfpjdmfg`lqslqbwjlmptbp#wkbw#wkflmf#le#wkfpfnlqf#slsvobqpv``ffgfg#jmpvsslqw#eqlnjm#gjeefqfmwglnjmbwfg#azgfpjdmfg#elqltmfqpkjs#lebmg#slppjaozpwbmgbqgjyfgqfpslmpfWf{wtbp#jmwfmgfgqf`fjufg#wkfbppvnfg#wkbwbqfbp#le#wkfsqjnbqjoz#jmwkf#abpjp#lejm#wkf#pfmpfb``lvmwp#elqgfpwqlzfg#azbw#ofbpw#wtltbp#gf`obqfg`lvog#mlw#afPf`qfwbqz#lebssfbq#wl#afnbqdjm.wls92,]_p(\x7F_p(',df*xwkqlt#f~8wkf#pwbqw#lewtl#pfsbqbwfobmdvbdf#bmgtkl#kbg#affmlsfqbwjlm#legfbwk#le#wkfqfbo#mvnafqp\n?ojmh#qfo>!sqlujgfg#wkfwkf#pwlqz#le`lnsfwjwjlmpfmdojpk#+VH*fmdojpk#+VP*<p<R<Q<_<R<W<M=l<S=m<V<T=m=l<S=m<V<T=m=l<S=m<V<R5h4U4]4D5f4E\nAO\x05Gx\bTA\nzk\x0BBl\bQ\x7F\bTA\nzk\x0BUm\bQ\x7F\bTA\nzk\npe\x05u|\ti@\tcT\bVV\n\\}\nxS\tVp\x05tS\x05k`\t[X\t[X\x0BHR\bPv\bTW\bUe\n\x7Fa\bQp\x0B_W\x0BWs\nxS\x0BAz\n_y\x04Khjmelqnb`j/_mkfqqbnjfmwbpfof`wq/_mj`lgfp`qjs`j/_m`obpjej`bglp`lml`jnjfmwlsvaoj`b`j/_mqfob`jlmbgbpjmelqn/Mwj`bqfob`jlmbglpgfsbqwbnfmwlwqbabibglqfpgjqf`wbnfmwfbzvmwbnjfmwlnfq`bglOjaqf`lmw/M`wfmlpkbajwb`jlmfp`vnsojnjfmwlqfpwbvqbmwfpgjpslpj`j/_m`lmpf`vfm`jbfof`wq/_mj`bbsoj`b`jlmfpgfp`lmf`wbgljmpwbob`j/_mqfbojyb`j/_mvwjojyb`j/_mfm`j`olsfgjbfmefqnfgbgfpjmpwqvnfmwlpf{sfqjfm`jbpjmpwjwv`j/_msbqwj`vobqfppva`bwfdlqjb=n<R<W=`<V<R<L<R=m=m<T<T=l<\\<]<R=n=g<]<R<W=`=d<Y<S=l<R=m=n<R<P<R<Z<Y=n<Y<X=l=o<_<T=i=m<W=o=k<\\<Y=m<Y<U=k<\\=m<^=m<Y<_<X<\\<L<R=m=m<T=c<p<R=m<V<^<Y<X=l=o<_<T<Y<_<R=l<R<X<\\<^<R<S=l<R=m<X<\\<Q<Q=g=i<X<R<W<Z<Q=g<T<P<Y<Q<Q<R<p<R=m<V<^=g=l=o<]<W<Y<U<p<R=m<V<^<\\=m=n=l<\\<Q=g<Q<T=k<Y<_<R=l<\\<]<R=n<Y<X<R<W<Z<Y<Q=o=m<W=o<_<T=n<Y<S<Y=l=`<r<X<Q<\\<V<R<S<R=n<R<P=o=l<\\<]<R=n=o<\\<S=l<Y<W=c<^<R<R<]=e<Y<R<X<Q<R<_<R=m<^<R<Y<_<R=m=n<\\=n=`<T<X=l=o<_<R<U=h<R=l=o<P<Y=i<R=l<R=d<R<S=l<R=n<T<^=m=m=g<W<V<\\<V<\\<Z<X=g<U<^<W<\\=m=n<T<_=l=o<S<S=g<^<P<Y=m=n<Y=l<\\<]<R=n<\\=m<V<\\<[<\\<W<S<Y=l<^=g<U<X<Y<W<\\=n=`<X<Y<Q=`<_<T<S<Y=l<T<R<X<]<T<[<Q<Y=m<R=m<Q<R<^<Y<P<R<P<Y<Q=n<V=o<S<T=n=`<X<R<W<Z<Q<\\=l<\\<P<V<\\=i<Q<\\=k<\\<W<R<L<\\<]<R=n<\\<N<R<W=`<V<R=m<R<^=m<Y<P<^
vendor: 4,592 bytes, line 9194
9194=n<R=l<R<U<Q<\\=k<\\<W<\\=m<S<T=m<R<V=m<W=o<Z<]=g=m<T=m=n<Y<P<S<Y=k<\\=n<T<Q<R<^<R<_<R<S<R<P<R=e<T=m<\\<U=n<R<^<S<R=k<Y<P=o<S<R<P<R=e=`<X<R<W<Z<Q<R=m=m=g<W<V<T<]=g=m=n=l<R<X<\\<Q<Q=g<Y<P<Q<R<_<T<Y<S=l<R<Y<V=n<M<Y<U=k<\\=m<P<R<X<Y<W<T=n<\\<V<R<_<R<R<Q<W<\\<U<Q<_<R=l<R<X<Y<^<Y=l=m<T=c=m=n=l<\\<Q<Y=h<T<W=`<P=g=o=l<R<^<Q=c=l<\\<[<Q=g=i<T=m<V<\\=n=`<Q<Y<X<Y<W=b=c<Q<^<\\=l=c<P<Y<Q=`=d<Y<P<Q<R<_<T=i<X<\\<Q<Q<R<U<[<Q<\\=k<T=n<Q<Y<W=`<[=c=h<R=l=o<P<\\<N<Y<S<Y=l=`<P<Y=m=c=j<\\<[<\\=e<T=n=g<w=o=k=d<T<Y\fHD\fHU\fIl\fHn\fHy\fH\\\fHD\fIk\fHi\fHF\fHD\fIk\fHy\fHS\fHC\fHR\fHy\fH\\\fIk\fHn\fHi\fHD\fIa\fHC\fHy\fIa\fHC\fHR\fH{\fHR\fHk\fHM\fH@\fHR\fH\\\fIk\fHy\fHS\fHT\fIl\fHJ\fHS\fHC\fHR\fHF\fHU\fH^\fIk\fHT\fHS\fHn\fHU\fHA\fHR\fH\\\fHH\fHi\fHF\fHD\fIl\fHY\fHR\fH^\fIk\fHT\fIk\fHY\fHR\fHy\fH\\\fHH\fIk\fHB\fIk\fH\\\fIk\fHU\fIg\fHD\fIk\fHT\fHy\fHH\fIk\fH@\fHU\fIm\fHH\fHT\fHR\fHk\fHs\fHU\fIg\fH{\fHR\fHp\fHR\fHD\fIk\fHB\fHS\fHD\fHs\fHy\fH\\\fHH\fHR\fHy\fH\\\fHD\fHR\fHe\fHD\fHy\fIk\fHC\fHU\fHR\fHm\fHT\fH@\fHT\fIk\fHA\fHR\fH[\fHR\fHj\fHF\fHy\fIk\fH^\fHS\fHC\fIk\fHZ\fIm\fH\\\fIn\fHk\fHT\fHy\fIk\fHt\fHn\fHs\fIk\fHB\fIk\fH\\\fIl\fHT\fHy\fHH\fHR\fHB\fIk\fH\\\fHR\fH^\fIk\fHy\fH\\\fHi\fHK\fHS\fHy\fHi\fHF\fHD\fHR\fHT\fHB\fHR\fHp\fHB\fIm\fHq\fIk\fHy\fHR\fH\\\fHO\fHU\fIg\fHH\fHR\fHy\fHM\fHP\fIl\fHC\fHU\fHR\fHn\fHU\fIg\fHs\fH^\fHZ\fH@\fIa\fHJ\fH^\fHS\fHC\fHR\fHp\fIl\fHY\fHD\fHp\fHR\fHH\fHR\fHy\fId\fHT\fIk\fHj\fHF\fHy\fHR\fHY\fHR\fH^\fIl\fHJ\fIk\fHD\fIk\fHF\fIn\fH\\\fIl\fHF\fHR\fHD\fIl\fHe\fHT\fHy\fIk\fHU\fIg\fH{\fIl\fH@\fId\fHL\fHy\fHj\fHF\fHy\fIl\fHY\fH\\\fIa\fH[\fH{\fHR\fHn\fHY\fHj\fHF\fHy\fIg\fHp\fHS\fH^\fHR\fHp\fHR\fHD\fHR\fHT\fHU\fHB\fHH\fHU\fHB\fIk\fHn\fHe\fHD\fHy\fIl\fHC\fHR\fHU\fIn\fHJ\fH\\\fIa\fHp\fHT\fIn\fHv\fIl\fHF\fHT\fHn\fHJ\fHT\fHY\fHR\fH^\fHU\fIg\fHD\fHR\fHU\fIg\fHH\fIl\fHp\fId\fHT\fIk\fHY\fHR\fHF\fHT\fHp\fHD\fHH\fHR\fHD\fIk\fHH\fHR\fHp\fHR\fH\\\fIl\fHt\fHR\fHC\fH^\fHp\fHS\fH^\fIk\fHD\fIl\fHv\fIk\fHp\fHR\fHn\fHv\fHF\fHH\fIa\fH\\\fH{\fIn\fH{\fH^\fHp\fHR\fHH\fIk\fH@\fHR\fHU\fH\\\fHj\fHF\fHD\fIk\fHY\fHR\fHU\fHD\fHk\fHT\fHy\fHR\fHT\fIm\fH@\fHU\fH\\\fHU\fHD\fIk\fHk\fHT\fHT\fIk\fHT\fHU\fHS\fHH\fH@\fHM\fHP\fIk\fHt\fHs\fHD\fHR\fHH\fH^\fHR\fHZ\fHF\fHR\fHn\fHv\fHZ\fIa\fH\\\fIl\fH@\fHM\fHP\fIl\fHU\fIg\fHH\fIk\fHT\fHR\fHd\fHs\fHZ\fHR\fHC\fHJ\fHT\fHy\fHH\fIl\fHp\fHR\fHH\fIl\fHY\fHR\fH^\fHR\fHU\fHp\fHR\fH\\\fHF\fHs\fHD\fHR\fH\\\fHz\fHD\fIk\fHT\fHM\fHP\fHy\fHB\fHS\fH^\fHR\fHe\fHT\fHy\fIl\fHy\fIk\fHY\fH^\fH^\fH{\fHH\fHR\fHz\fHR\fHD\fHR\fHi\fH\\\fIa\fHI\fHp\fHU\fHR\fHn\fHJ\fIk\fHz\fHR\fHF\fHU\fH^\fIl\fHD\fHS\fHC\fHB\fH@\fHS\fHD\fHR\fH@\fId\fHn\fHy\fHy\fHU\fIl\fHn\fHy\fHU\fHD\fHR\fHJ\fIk\fHH\fHR\fHU\fHB\fH^\fIk\fHy\fHR\fHG\fIl\fHp\fH@\fHy\fHS\fHH\fIm\fH\\\fHH\fHB\fHR\fHn\fH{\fHY\fHU\fIl\fHn\fH\\\fIg\fHp\fHP\fHB\fHS\fH^\fIl\fHj\fH\\\fIg\fHF\fHT\fIk\fHD\fHR\fHC\fHR\fHJ\fHY\fH^\fIk\fHD\fIk\fHz\fHR\fHH\fHR\fHy\fH\\\fIl\fH@\fHe\fHD\fHy\fHR\fHp\fHY\fHR\fH@\fHF\fIn\fH\\\fHR\fH@\fHM\fHP\fHR\fHT\fI`\fHJ\fHR\fHZ\fIk\fHC\fH\\\fHy\fHS\fHC\fIk\fHy\fHU\fHR\fHn\fHi\fHy\fHT\fH\\\fH@\fHD\fHR\fHc\fHY\fHU\fHR\fHn\fHT\fIa\fHI\fH^\fHB\fHS\fH^\fIk\fH^\fIk\fHz\fHy\fHY\fHS\fH[\fHC\fHy\fIa\fH\\\fHn\fHT\fHB\fIn\fHU\fHI\fHR\fHD\fHR4F4_4F4[5f4U5i4X4K4]5o4E4D5d4K4_4[4E4K5h4Y5m4A4E5i5d4K4Z5f4U4K5h4B4K4Y4E4K5h5i4^5f4C4K5h4U4K5i4E4K5h5o4K4F4D4K5h4]4C5d4C4D4]5j4K5i4@4K5h4C5d5h4E4K5h4U4K5h5i4K5h5i5d5n4U4K5h4U4]4D5f4K5h4_4]5f4U4K5h4@5d4K5h4K5h4\\5k4K4D4K5h4A5f4K4E4K5h4A5n5d5n4K5h5o4]5f5i4K5h4U4]4K5n5i4A5m5d4T4E4K5h4G4K5j5f5i4X4K5k4C4E4K5h5i4]4O4E4K5h5n4]4N5j4K5h4X4D4K4D4K5h4A5d4K4]4K5h4@4C5f4C4K5h4O4_4]4E4K5h4U5h5d5i5i4@5i5d4U4E4K5h4]4A5i5j4K5h5j5n4K4[5m5h4_4[5f5j4K5h5o5d5f4F4K5h4C5j5f4K4D4]5o4K4F5k4K5h4]5f4K4Z4F4A5f4K4F5f4D4F5d5n5f4F4K5h4O5d5h5e4K5h4D4]5f4C4K5h5o5h4K5i4K5h4]4K4D4[4K5h4X4B4Y5f4_5f4K4]4K4F4K5h4G4K5h4G4K5h4Y5h4K4E4K5h4A4C5f4G4K5h4^5d4K4]4K5h4B5h5f4@4K5h4@5i5f4U4K5h4U4K5i5k4K5h4@5i4K5h4K5h4_4K4U4E5i4X4K5k4C5k4K5h4]4J5f4_4K5h4C4B5d5h4K5h5m5j5f4E4K5h5o4F4K4D4K5h4C5d4]5f4K5h4C4]5d4_4K4_4F4V4]5n4F4Y4K5i5f5i4K5h4D5j4K4F4K5h4U4T5f5ifmwfqwbjmnfmwvmgfqpwbmgjmd#>#evm`wjlm+*-isd!#tjgwk>!`lmejdvqbwjlm-smd!#tjgwk>!?algz#`obpp>!Nbwk-qbmgln+*`lmwfnslqbqz#Vmjwfg#Pwbwfp`jq`vnpwbm`fp-bssfmg@kjog+lqdbmjybwjlmp?psbm#`obpp>!!=?jnd#pq`>!,gjpwjmdvjpkfgwklvpbmgp#le#`lnnvmj`bwjlm`ofbq!=?,gju=jmufpwjdbwjlmebuj`lm-j`l!#nbqdjm.qjdkw9abpfg#lm#wkf#Nbppb`kvpfwwpwbaof#alqgfq>jmwfqmbwjlmbobopl#hmltm#bpsqlmvm`jbwjlmab`hdqlvmg9 esbggjmd.ofew9Elq#f{bnsof/#njp`foobmflvp%ow8,nbwk%dw8spz`kloldj`bojm#sbqwj`vobqfbq`k!#wzsf>!elqn#nfwklg>!bp#lsslpfg#wlPvsqfnf#@lvqwl``bpjlmbooz#Bggjwjlmbooz/Mlqwk#Bnfqj`bs{8ab`hdqlvmglsslqwvmjwjfpFmwfqwbjmnfmw-wlOltfq@bpf+nbmveb`wvqjmdsqlefppjlmbo#`lnajmfg#tjwkElq#jmpwbm`f/`lmpj
vendor: 55,168 bytes, lines 9194-9816
9194pwjmd#le!#nb{ofmdwk>!qfwvqm#ebopf8`lmp`jlvpmfppNfgjwfqqbmfbmf{wqblqgjmbqzbppbppjmbwjlmpvapfrvfmwoz#avwwlm#wzsf>!wkf#mvnafq#lewkf#lqjdjmbo#`lnsqfkfmpjufqfefqp#wl#wkf?,vo=\t?,gju=\tskjolplskj`bool`bwjlm-kqfetbp#svaojpkfgPbm#Eqbm`jp`l+evm`wjlm+*x\t?gju#jg>!nbjmplskjpwj`bwfgnbwkfnbwj`bo#,kfbg=\x0E\t?algzpvddfpwp#wkbwgl`vnfmwbwjlm`lm`fmwqbwjlmqfobwjlmpkjspnbz#kbuf#affm+elq#f{bnsof/Wkjp#bqwj`of#jm#plnf#`bpfpsbqwp#le#wkf#gfejmjwjlm#leDqfbw#Aqjwbjm#`foosbggjmd>frvjubofmw#wlsob`fklogfq>!8#elmw.pjyf9#ivpwjej`bwjlmafojfufg#wkbwpveefqfg#eqlnbwwfnswfg#wl#ofbgfq#le#wkf`qjsw!#pq`>!,+evm`wjlm+*#xbqf#bubjobaof\t\n?ojmh#qfo>!#pq`>$kwws9,,jmwfqfpwfg#jm`lmufmwjlmbo#!#bow>!!#,=?,bqf#dfmfqboozkbp#bopl#affmnlpw#slsvobq#`lqqfpslmgjmd`qfgjwfg#tjwkwzof>!alqgfq9?,b=?,psbm=?,-dje!#tjgwk>!?jeqbnf#pq`>!wbaof#`obpp>!jmojmf.aol`h8b``lqgjmd#wl#wldfwkfq#tjwkbssql{jnbwfozsbqojbnfmwbqznlqf#bmg#nlqfgjpsobz9mlmf8wqbgjwjlmboozsqfglnjmbmwoz%maps8\x7F%maps8%maps8?,psbm=#`foopsb`jmd>?jmsvw#mbnf>!lq!#`lmwfmw>!`lmwqlufqpjbosqlsfqwz>!ld9,{.pkl`htbuf.gfnlmpwqbwjlmpvqqlvmgfg#azMfufqwkfofpp/tbp#wkf#ejqpw`lmpjgfqbaof#Bowklvdk#wkf#`loobalqbwjlmpklvog#mlw#afsqlslqwjlm#le?psbm#pwzof>!hmltm#bp#wkf#pklqwoz#bewfqelq#jmpwbm`f/gfp`qjafg#bp#,kfbg=\t?algz#pwbqwjmd#tjwkjm`qfbpjmdoz#wkf#eb`w#wkbwgjp`vppjlm#lenjggof#le#wkfbm#jmgjujgvbogjeej`vow#wl#sljmw#le#ujftklnlpf{vbojwzb``fswbm`f#le?,psbm=?,gju=nbmveb`wvqfqplqjdjm#le#wkf`lnnlmoz#vpfgjnslqwbm`f#legfmlnjmbwjlmpab`hdqlvmg9# ofmdwk#le#wkfgfwfqnjmbwjlmb#pjdmjej`bmw!#alqgfq>!3!=qfulovwjlmbqzsqjm`jsofp#lejp#`lmpjgfqfgtbp#gfufolsfgJmgl.Fvqlsfbmuvomfqbaof#wlsqlslmfmwp#lebqf#plnfwjnfp`olpfq#wl#wkfMft#Zlqh#@jwz#mbnf>!pfbq`kbwwqjavwfg#wl`lvqpf#le#wkfnbwkfnbwj`jbmaz#wkf#fmg#lebw#wkf#fmg#le!#alqgfq>!3!#wf`kmloldj`bo-qfnluf@obpp+aqbm`k#le#wkffujgfm`f#wkbw\"Xfmgje^..=\x0E\tJmpwjwvwf#le#jmwl#b#pjmdofqfpsf`wjufoz-bmg#wkfqfelqfsqlsfqwjfp#lejp#ol`bwfg#jmplnf#le#tkj`kWkfqf#jp#bopl`lmwjmvfg#wl#bssfbqbm`f#le#%bns8mgbpk8#gfp`qjafp#wkf`lmpjgfqbwjlmbvwklq#le#wkfjmgfsfmgfmwozfrvjssfg#tjwkglfp#mlw#kbuf?,b=?b#kqfe>!`lmevpfg#tjwk?ojmh#kqfe>!,bw#wkf#bdf#lebssfbq#jm#wkfWkfpf#jm`ovgfqfdbqgofpp#le`lvog#af#vpfg#pwzof>%rvlw8pfufqbo#wjnfpqfsqfpfmw#wkfalgz=\t?,kwno=wklvdkw#wl#afslsvobwjlm#leslppjajojwjfpsfq`fmwbdf#leb``fpp#wl#wkfbm#bwwfnsw#wlsqlgv`wjlm#leirvfqz,irvfqzwtl#gjeefqfmwafolmd#wl#wkffpwbaojpknfmwqfsob`jmd#wkfgfp`qjswjlm!#gfwfqnjmf#wkfbubjobaof#elqB``lqgjmd#wl#tjgf#qbmdf#le\n?gju#`obpp>!nlqf#`lnnlmozlqdbmjpbwjlmpevm`wjlmbojwztbp#`lnsofwfg#%bns8ngbpk8#sbqwj`jsbwjlmwkf#`kbqb`wfqbm#bggjwjlmbobssfbqp#wl#afeb`w#wkbw#wkfbm#f{bnsof#lepjdmjej`bmwozlmnlvpflufq>!af`bvpf#wkfz#bpzm`#>#wqvf8sqlaofnp#tjwkpffnp#wl#kbufwkf#qfpvow#le#pq`>!kwws9,,ebnjojbq#tjwkslppfppjlm#leevm`wjlm#+*#xwllh#sob`f#jmbmg#plnfwjnfppvapwbmwjbooz?psbm=?,psbm=jp#lewfm#vpfgjm#bm#bwwfnswdqfbw#gfbo#leFmujqlmnfmwbopv``fppevooz#ujqwvbooz#boo13wk#`fmwvqz/sqlefppjlmbopmf`fppbqz#wl#gfwfqnjmfg#az`lnsbwjajojwzaf`bvpf#jw#jpGj`wjlmbqz#lenlgjej`bwjlmpWkf#elooltjmdnbz#qfefq#wl9@lmpfrvfmwoz/Jmwfqmbwjlmbobowklvdk#plnfwkbw#tlvog#aftlqog$p#ejqpw`obppjejfg#bpalwwln#le#wkf+sbqwj`vobqozbojdm>!ofew!#nlpw#`lnnlmozabpjp#elq#wkfelvmgbwjlm#le`lmwqjavwjlmpslsvobqjwz#le`fmwfq#le#wkfwl#qfgv`f#wkfivqjpgj`wjlmpbssql{jnbwjlm#lmnlvpflvw>!Mft#Wfpwbnfmw`loof`wjlm#le?,psbm=?,b=?,jm#wkf#Vmjwfgejon#gjqf`wlq.pwqj`w-gwg!=kbp#affm#vpfgqfwvqm#wl#wkfbowklvdk#wkjp`kbmdf#jm#wkfpfufqbo#lwkfqavw#wkfqf#bqfvmsqf`fgfmwfgjp#pjnjobq#wlfpsf`jbooz#jmtfjdkw9#alog8jp#`boofg#wkf`lnsvwbwjlmbojmgj`bwf#wkbwqfpwqj`wfg#wl\n?nfwb#mbnf>!bqf#wzsj`booz`lmeoj`w#tjwkKltfufq/#wkf#Bm#f{bnsof#le`lnsbqfg#tjwkrvbmwjwjfp#leqbwkfq#wkbm#b`lmpwfoobwjlmmf`fppbqz#elqqfslqwfg#wkbwpsf`jej`bwjlmslojwj`bo#bmg%maps8%maps8?qfefqfm`fp#wlwkf#pbnf#zfbqDlufqmnfmw#ledfmfqbwjlm#lekbuf#mlw#affmpfufqbo#zfbqp`lnnjwnfmw#wl\n\n?vo#`obpp>!ujpvbojybwjlm2:wk#`fmwvqz/sqb`wjwjlmfqpwkbw#kf#tlvogbmg#`lmwjmvfgl``vsbwjlm#lejp#gfejmfg#bp`fmwqf#le#wkfwkf#bnlvmw#le=?gju#pwzof>!frvjubofmw#legjeefqfmwjbwfaqlvdkw#balvwnbqdjm.ofew9#bvwlnbwj`boozwklvdkw#le#bpPlnf#le#wkfpf\t?gju#`obpp>!jmsvw#`obpp>!qfsob`fg#tjwkjp#lmf#le#wkffgv`bwjlm#bmgjmeovfm`fg#azqfsvwbwjlm#bp\t?nfwb#mbnf>!b``lnnlgbwjlm?,gju=\t?,gju=obqdf#sbqw#leJmpwjwvwf#elqwkf#pl.`boofg#bdbjmpw#wkf#Jm#wkjp#`bpf/tbp#bssljmwfg`objnfg#wl#afKltfufq/#wkjpGfsbqwnfmw#lewkf#qfnbjmjmdfeef`w#lm#wkfsbqwj`vobqoz#gfbo#tjwk#wkf\t?gju#pwzof>!bonlpw#botbzpbqf#`vqqfmwozf{sqfppjlm#leskjolplskz#leelq#nlqf#wkbm`jujojybwjlmplm#wkf#jpobmgpfof`wfgJmgf{`bm#qfpvow#jm!#ubovf>!!#,=wkf#pwqv`wvqf#,=?,b=?,gju=Nbmz#le#wkfpf`bvpfg#az#wkfle#wkf#Vmjwfgpsbm#`obpp>!n`bm#af#wqb`fgjp#qfobwfg#wlaf`bnf#lmf#lejp#eqfrvfmwozojujmd#jm#wkfwkflqfwj`boozElooltjmd#wkfQfulovwjlmbqzdlufqmnfmw#jmjp#gfwfqnjmfgwkf#slojwj`bojmwqlgv`fg#jmpveej`jfmw#wlgfp`qjswjlm!=pklqw#pwlqjfppfsbqbwjlm#lebp#wl#tkfwkfqhmltm#elq#jwptbp#jmjwjboozgjpsobz9aol`hjp#bm#f{bnsofwkf#sqjm`jsbo`lmpjpwp#le#bqf`ldmjyfg#bp,algz=?,kwno=b#pvapwbmwjboqf`lmpwqv`wfgkfbg#le#pwbwfqfpjpwbm`f#wlvmgfqdqbgvbwfWkfqf#bqf#wtldqbujwbwjlmbobqf#gfp`qjafgjmwfmwjlmboozpfqufg#bp#wkf`obpp>!kfbgfqlsslpjwjlm#wlevmgbnfmwboozglnjmbwfg#wkfbmg#wkf#lwkfqboojbm`f#tjwktbp#elq`fg#wlqfpsf`wjufoz/bmg#slojwj`bojm#pvsslqw#lesflsof#jm#wkf13wk#`fmwvqz-bmg#svaojpkfgolbg@kbqwafbwwl#vmgfqpwbmgnfnafq#pwbwfpfmujqlmnfmwboejqpw#kboe#le`lvmwqjfp#bmgbq`kjwf`wvqboaf#`lmpjgfqfg`kbqb`wfqjyfg`ofbqJmwfqubobvwklqjwbwjufEfgfqbwjlm#letbp#pv``ffgfgbmg#wkfqf#bqfb#`lmpfrvfm`fwkf#Sqfpjgfmwbopl#jm`ovgfgeqff#plewtbqfpv``fppjlm#legfufolsfg#wkftbp#gfpwqlzfgbtbz#eqln#wkf8\t?,p`qjsw=\t?bowklvdk#wkfzelooltfg#az#bnlqf#sltfqevoqfpvowfg#jm#bVmjufqpjwz#leKltfufq/#nbmzwkf#sqfpjgfmwKltfufq/#plnfjp#wklvdkw#wlvmwjo#wkf#fmgtbp#bmmlvm`fgbqf#jnslqwbmwbopl#jm`ovgfp=?jmsvw#wzsf>wkf#`fmwfq#le#GL#MLW#BOWFQvpfg#wl#qfefqwkfnfp,<plqw>wkbw#kbg#affmwkf#abpjp#elqkbp#gfufolsfgjm#wkf#pvnnfq`lnsbqbwjufozgfp`qjafg#wkfpv`k#bp#wklpfwkf#qfpvowjmdjp#jnslppjaofubqjlvp#lwkfqPlvwk#Beqj`bmkbuf#wkf#pbnffeef`wjufmfppjm#tkj`k#`bpf8#wf{w.bojdm9pwqv`wvqf#bmg8#ab`hdqlvmg9qfdbqgjmd#wkfpvsslqwfg#wkfjp#bopl#hmltmpwzof>!nbqdjmjm`ovgjmd#wkfabkbpb#Nfobzvmlqph#alhn/Iomlqph#mzmlqphpolufm)M(ajmbjmwfqmb`jlmbo`bojej`b`j/_m`lnvmj`b`j/_m`lmpwqv``j/_m!=?gju#`obpp>!gjpbnajdvbwjlmGlnbjmMbnf$/#$bgnjmjpwqbwjlmpjnvowbmflvpozwqbmpslqwbwjlmJmwfqmbwjlmbo#nbqdjm.alwwln9qfpslmpjajojwz?\"Xfmgje^..=\t?,=?nfwb#mbnf>!jnsofnfmwbwjlmjmeqbpwqv`wvqfqfsqfpfmwbwjlmalqgfq.alwwln9?,kfbg=\t?algz=>kwws&0B&1E&1E?elqn#nfwklg>!nfwklg>!slpw!#,ebuj`lm-j`l!#~*8\t?,p`qjsw=\t-pfwBwwqjavwf+Bgnjmjpwqbwjlm>#mft#Bqqbz+*8?\"Xfmgje^..=\x0E\tgjpsobz9aol`h8Vmelqwvmbwfoz/!=%maps8?,gju=,ebuj`lm-j`l!=>$pwzofpkffw$#jgfmwjej`bwjlm/#elq#f{bnsof/?oj=?b#kqfe>!,bm#bowfqmbwjufbp#b#qfpvow#lesw!=?,p`qjsw=\twzsf>!pvanjw!#\t+evm`wjlm+*#xqf`lnnfmgbwjlmelqn#b`wjlm>!,wqbmpelqnbwjlmqf`lmpwqv`wjlm-pwzof-gjpsobz#B``lqgjmd#wl#kjggfm!#mbnf>!bolmd#tjwk#wkfgl`vnfmw-algz-bssql{jnbwfoz#@lnnvmj`bwjlmpslpw!#b`wjlm>!nfbmjmd#%rvlw8..?\"Xfmgje^..=Sqjnf#Njmjpwfq`kbqb`wfqjpwj`?,b=#?b#`obpp>wkf#kjpwlqz#le#lmnlvpflufq>!wkf#dlufqmnfmwkqfe>!kwwsp9,,tbp#lqjdjmbooztbp#jmwqlgv`fg`obppjej`bwjlmqfsqfpfmwbwjufbqf#`lmpjgfqfg?\"Xfmgje^..=\t\tgfsfmgp#lm#wkfVmjufqpjwz#le#jm#`lmwqbpw#wl#sob`fklogfq>!jm#wkf#`bpf#lejmwfqmbwjlmbo#`lmpwjwvwjlmbopwzof>!alqgfq.9#evm`wjlm+*#xAf`bvpf#le#wkf.pwqj`w-gwg!=\t?wbaof#`obpp>!b``lnsbmjfg#azb``lvmw#le#wkf?p`qjsw#pq`>!,mbwvqf#le#wkf#wkf#sflsof#jm#jm#bggjwjlm#wlp*8#ip-jg#>#jg!#tjgwk>!233&!qfdbqgjmd#wkf#Qlnbm#@bwkloj`bm#jmgfsfmgfmwelooltjmd#wkf#-dje!#tjgwk>!2wkf#elooltjmd#gjp`qjnjmbwjlmbq`kbfloldj`bosqjnf#njmjpwfq-ip!=?,p`qjsw=`lnajmbwjlm#le#nbqdjmtjgwk>!`qfbwfFofnfmw+t-bwwb`kFufmw+?,b=?,wg=?,wq=pq`>!kwwsp9,,bJm#sbqwj`vobq/#bojdm>!ofew!#@yf`k#Qfsvaoj`Vmjwfg#Hjmdgln`lqqfpslmgfm`f`lm`ovgfg#wkbw-kwno!#wjwof>!+evm`wjlm#+*#x`lnfp#eqln#wkfbssoj`bwjlm#le?psbm#`obpp>!pafojfufg#wl#affnfmw+$p`qjsw$?,b=\t?,oj=\t?ojufqz#gjeefqfmw=?psbm#`obpp>!lswjlm#ubovf>!+bopl#hmltm#bp\n?oj=?b#kqfe>!=?jmsvw#mbnf>!pfsbqbwfg#eqlnqfefqqfg#wl#bp#ubojdm>!wls!=elvmgfq#le#wkfbwwfnswjmd#wl#`bqalm#gjl{jgf\t\t?gju#`obpp>!`obpp>!pfbq`k.,algz=\t?,kwno=lsslqwvmjwz#wl`lnnvmj`bwjlmp?,kfbg=\x0E\t?algz#pwzof>!tjgwk9Wj\rVSmd#Uj\rWkw`kbmdfp#jm#wkfalqgfq.`lolq9 3!#alqgfq>!3!#?,psbm=?,gju=?tbp#gjp`lufqfg!#wzsf>!wf{w!#*8\t?,p`qjsw=\t\tGfsbqwnfmw#le#f``ofpjbpwj`bowkfqf#kbp#affmqfpvowjmd#eqln?,algz=?,kwno=kbp#mfufq#affmwkf#ejqpw#wjnfjm#qfpslmpf#wlbvwlnbwj`booz#?,gju=\t\t?gju#jtbp#`lmpjgfqfgsfq`fmw#le#wkf!#,=?,b=?,gju=`loof`wjlm#le#gfp`fmgfg#eqlnpf`wjlm#le#wkfb``fsw.`kbqpfwwl#af#`lmevpfgnfnafq#le#wkf#sbggjmd.qjdkw9wqbmpobwjlm#lejmwfqsqfwbwjlm#kqfe>$kwws9,,tkfwkfq#lq#mlwWkfqf#bqf#boplwkfqf#bqf#nbmzb#pnboo#mvnafqlwkfq#sbqwp#lejnslppjaof#wl##`obpp>!avwwlmol`bwfg#jm#wkf-#Kltfufq/#wkfbmg#fufmwvboozBw#wkf#fmg#le#af`bvpf#le#jwpqfsqfpfmwp#wkf?elqn#b`wjlm>!#nfwklg>!slpw!jw#jp#slppjaofnlqf#ojhfoz#wlbm#jm`qfbpf#jmkbuf#bopl#affm`lqqfpslmgp#wlbmmlvm`fg#wkbwbojdm>!qjdkw!=nbmz#`lvmwqjfpelq#nbmz#zfbqpfbqojfpw#hmltmaf`bvpf#jw#tbpsw!=?,p`qjsw=\x0E#ubojdm>!wls!#jmkbajwbmwp#leelooltjmd#zfbq\x0E\t?gju#`obpp>!njoojlm#sflsof`lmwqlufqpjbo#`lm`fqmjmd#wkfbqdvf#wkbw#wkfdlufqmnfmw#bmgb#qfefqfm`f#wlwqbmpefqqfg#wlgfp`qjajmd#wkf#pwzof>!`lolq9bowklvdk#wkfqfafpw#hmltm#elqpvanjw!#mbnf>!nvowjsoj`bwjlmnlqf#wkbm#lmf#qf`ldmjwjlm#le@lvm`jo#le#wkffgjwjlm#le#wkf##?nfwb#mbnf>!Fmwfqwbjmnfmw#btbz#eqln#wkf#8nbqdjm.qjdkw9bw#wkf#wjnf#lejmufpwjdbwjlmp`lmmf`wfg#tjwkbmg#nbmz#lwkfqbowklvdk#jw#jpafdjmmjmd#tjwk#?psbm#`obpp>!gfp`fmgbmwp#le?psbm#`obpp>!j#bojdm>!qjdkw!?,kfbg=\t?algz#bpsf`wp#le#wkfkbp#pjm`f#affmFvqlsfbm#Vmjlmqfnjmjp`fmw#lenlqf#gjeej`vowUj`f#Sqfpjgfmw`lnslpjwjlm#lesbppfg#wkqlvdknlqf#jnslqwbmwelmw.pjyf922s{f{sobmbwjlm#lewkf#`lm`fsw#letqjwwfm#jm#wkf\n?psbm#`obpp>!jp#lmf#le#wkf#qfpfnaobm`f#wllm#wkf#dqlvmgptkj`k#`lmwbjmpjm`ovgjmd#wkf#gfejmfg#az#wkfsvaoj`bwjlm#lenfbmp#wkbw#wkflvwpjgf#le#wkfpvsslqw#le#wkf?jmsvw#`obpp>!?psbm#`obpp>!w+Nbwk-qbmgln+*nlpw#sqlnjmfmwgfp`qjswjlm#le@lmpwbmwjmlsoftfqf#svaojpkfg?gju#`obpp>!pfbssfbqp#jm#wkf2!#kfjdkw>!2!#nlpw#jnslqwbmwtkj`k#jm`ovgfptkj`k#kbg#affmgfpwqv`wjlm#lewkf#slsvobwjlm\t\n?gju#`obpp>!slppjajojwz#leplnfwjnfp#vpfgbssfbq#wl#kbufpv``fpp#le#wkfjmwfmgfg#wl#afsqfpfmw#jm#wkfpwzof>!`ofbq9a\x0E\t?,p`qjsw=\x0E\t?tbp#elvmgfg#jmjmwfqujft#tjwk\\jg!#`lmwfmw>!`bsjwbo#le#wkf\x0E\t?ojmh#qfo>!pqfofbpf#le#wkfsljmw#lvw#wkbw{NOKwwsQfrvfpwbmg#pvapfrvfmwpf`lmg#obqdfpwufqz#jnslqwbmwpsf`jej`bwjlmppvqeb`f#le#wkfbssojfg#wl#wkfelqfjdm#sloj`z\\pfwGlnbjmMbnffpwbaojpkfg#jmjp#afojfufg#wlJm#bggjwjlm#wlnfbmjmd#le#wkfjp#mbnfg#bewfqwl#sqlwf`w#wkfjp#qfsqfpfmwfgGf`obqbwjlm#lenlqf#feej`jfmw@obppjej`bwjlmlwkfq#elqnp#lekf#qfwvqmfg#wl?psbm#`obpp>!`sfqelqnbm`f#le+evm`wjlm+*#x\x0Eje#bmg#lmoz#jeqfdjlmp#le#wkfofbgjmd#wl#wkfqfobwjlmp#tjwkVmjwfg#Mbwjlmppwzof>!kfjdkw9lwkfq#wkbm#wkfzsf!#`lmwfmw>!Bppl`jbwjlm#le\t?,kfbg=\t?algzol`bwfg#lm#wkfjp#qfefqqfg#wl+jm`ovgjmd#wkf`lm`fmwqbwjlmpwkf#jmgjujgvbobnlmd#wkf#nlpwwkbm#bmz#lwkfq,=\t?ojmh#qfo>!#qfwvqm#ebopf8wkf#svqslpf#lewkf#bajojwz#wl8`lolq9 eee~\t-\t?psbm#`obpp>!wkf#pvaif`w#legfejmjwjlmp#le=\x0E\t?ojmh#qfo>!`objn#wkbw#wkfkbuf#gfufolsfg?wbaof#tjgwk>!`fofaqbwjlm#leElooltjmd#wkf#wl#gjpwjmdvjpk?psbm#`obpp>!awbhfp#sob`f#jmvmgfq#wkf#mbnfmlwfg#wkbw#wkf=?\"Xfmgje^..=\tpwzof>!nbqdjm.jmpwfbg#le#wkfjmwqlgv`fg#wkfwkf#sql`fpp#lejm`qfbpjmd#wkfgjeefqfm`fp#jmfpwjnbwfg#wkbwfpsf`jbooz#wkf,gju=?gju#jg>!tbp#fufmwvboozwkqlvdklvw#kjpwkf#gjeefqfm`fplnfwkjmd#wkbwpsbm=?,psbm=?,pjdmjej`bmwoz#=?,p`qjsw=\x0E\t\x0E\tfmujqlmnfmwbo#wl#sqfufmw#wkfkbuf#affm#vpfgfpsf`jbooz#elqvmgfqpwbmg#wkfjp#fppfmwjbooztfqf#wkf#ejqpwjp#wkf#obqdfpwkbuf#affm#nbgf!#pq`>!kwws9,,jmwfqsqfwfg#bppf`lmg#kboe#le`qloojmd>!ml!#jp#`lnslpfg#leJJ/#Kloz#Qlnbmjp#f{sf`wfg#wlkbuf#wkfjq#ltmgfejmfg#bp#wkfwqbgjwjlmbooz#kbuf#gjeefqfmwbqf#lewfm#vpfgwl#fmpvqf#wkbwbdqffnfmw#tjwk`lmwbjmjmd#wkfbqf#eqfrvfmwozjmelqnbwjlm#lmf{bnsof#jp#wkfqfpvowjmd#jm#b?,b=?,oj=?,vo=#`obpp>!ellwfqbmg#fpsf`jboozwzsf>!avwwlm!#?,psbm=?,psbm=tkj`k#jm`ovgfg=\t?nfwb#mbnf>!`lmpjgfqfg#wkf`bqqjfg#lvw#azKltfufq/#jw#jpaf`bnf#sbqw#lejm#qfobwjlm#wlslsvobq#jm#wkfwkf#`bsjwbo#letbp#leej`jbooztkj`k#kbp#affmwkf#Kjpwlqz#lebowfqmbwjuf#wlgjeefqfmw#eqlnwl#pvsslqw#wkfpvddfpwfg#wkbwjm#wkf#sql`fpp##?gju#`obpp>!wkf#elvmgbwjlmaf`bvpf#le#kjp`lm`fqmfg#tjwkwkf#vmjufqpjwzlsslpfg#wl#wkfwkf#`lmwf{w#le?psbm#`obpp>!swf{w!#mbnf>!r!\n\n?gju#`obpp>!wkf#p`jfmwjej`qfsqfpfmwfg#aznbwkfnbwj`jbmpfof`wfg#az#wkfwkbw#kbuf#affm=?gju#`obpp>!`gju#jg>!kfbgfqjm#sbqwj`vobq/`lmufqwfg#jmwl*8\t?,p`qjsw=\t?skjolplskj`bo#pqsphlkqubwphjwj\rVSmd#Uj\rWkw<L=o=m=m<V<T<U=l=o=m=m<V<T<Ujmufpwjdb`j/_msbqwj`jsb`j/_m<V<R=n<R=l=g<Y<R<]<W<\\=m=n<T<V<R=n<R=l=g<U=k<Y<W<R<^<Y<V=m<T=m=n<Y<P=g<q<R<^<R=m=n<T<V<R=n<R=l=g=i<R<]<W<\\=m=n=`<^=l<Y<P<Y<Q<T<V<R=n<R=l<\\=c=m<Y<_<R<X<Q=c=m<V<\\=k<\\=n=`<Q<R<^<R=m=n<T<O<V=l<\\<T<Q=g<^<R<S=l<R=m=g<V<R=n<R=l<R<U=m<X<Y<W<\\=n=`<S<R<P<R=e=`=b=m=l<Y<X=m=n<^<R<]=l<\\<[<R<P=m=n<R=l<R<Q=g=o=k<\\=m=n<T<Y=n<Y=k<Y<Q<T<Y<\x7F<W<\\<^<Q<\\=c<T=m=n<R=l<T<T=m<T=m=n<Y<P<\\=l<Y=d<Y<Q<T=c<M<V<\\=k<\\=n=`<S<R=a=n<R<P=o=m<W<Y<X=o<Y=n=m<V<\\<[<\\=n=`=n<R<^<\\=l<R<^<V<R<Q<Y=k<Q<R=l<Y=d<Y<Q<T<Y<V<R=n<R=l<R<Y<R=l<_<\\<Q<R<^<V<R=n<R=l<R<P<L<Y<V<W<\\<P<\\4K5h5i5j4F4C5e5i5j4F4C5f4K4F4K5h5i5d4Z5d4U4K5h4D4]4K5i4@4K5h5i5d4K5n4U4K5h4]4_4K4J5h5i4X4K4]5o4K4F4K5h4O4U4Z4K4M4K5h4]5f4K4Z4E4K5h4F4Y5i5f5i4K5h4K4U4Z4K4M4K5h5j4F4K4J4@4K5h4O5h4U4K4D4K5h4F4_4@5f5h4K5h4O5n4_4K5i4K5h4Z4V4[4K4F4K5h5m5f4C5f5d4K5h4F4]4A5f4D4K5h4@4C5f4C4E4K5h4F4U5h5f5i4K5h4O4B4D4K4]4K5h4K5m5h4K5i4K5h4O5m5h4K5i4K5h4F4K4]5f4B4K5h4F5n5j5f4E4K5h4K5h4U4K4D4K5h4B5d4K4[4]4K5h5i4@4F5i4U4K5h4C5f5o5d4]4K5h4_5f4K4A4E4U4D4C4K5h5h5k4K5h4F4]4D5f4E4K5h4]5d4K4D4[4K5h4O4C4D5f4E4K5h4K4B4D4K4]4K5h5i4F4A4C4E4K5h4K4V4K5j5f`vqplq9sljmwfq8?,wjwof=\t?nfwb#!#kqfe>!kwws9,,!=?psbm#`obpp>!nfnafqp#le#wkf#tjmglt-ol`bwjlmufqwj`bo.bojdm9,b=#\x7F#?b#kqfe>!?\"gl`wzsf#kwno=nfgjb>!p`qffm!#?lswjlm#ubovf>!ebuj`lm-j`l!#,=\t\n\n?gju#`obpp>!`kbqb`wfqjpwj`p!#nfwklg>!dfw!#,algz=\t?,kwno=\tpklqw`vw#j`lm!#gl`vnfmw-tqjwf+sbggjmd.alwwln9qfsqfpfmwbwjufppvanjw!#ubovf>!bojdm>!`fmwfq!#wkqlvdklvw#wkf#p`jfm`f#ej`wjlm\t##?gju#`obpp>!pvanjw!#`obpp>!lmf#le#wkf#nlpw#ubojdm>!wls!=?tbp#fpwbaojpkfg*8\x0E\t?,p`qjsw=\x0E\tqfwvqm#ebopf8!=*-pwzof-gjpsobzaf`bvpf#le#wkf#gl`vnfmw-`llhjf?elqn#b`wjlm>!,~algzxnbqdjm938Fm`z`olsfgjb#leufqpjlm#le#wkf#-`qfbwfFofnfmw+mbnf!#`lmwfmw>!?,gju=\t?,gju=\t\tbgnjmjpwqbwjuf#?,algz=\t?,kwno=kjpwlqz#le#wkf#!=?jmsvw#wzsf>!slqwjlm#le#wkf#bp#sbqw#le#wkf#%maps8?b#kqfe>!lwkfq#`lvmwqjfp!=\t?gju#`obpp>!?,psbm=?,psbm=?Jm#lwkfq#tlqgp/gjpsobz9#aol`h8`lmwqlo#le#wkf#jmwqlgv`wjlm#le,=\t?nfwb#mbnf>!bp#tfoo#bp#wkf#jm#qf`fmw#zfbqp\x0E\t\n?gju#`obpp>!?,gju=\t\n?,gju=\tjmpsjqfg#az#wkfwkf#fmg#le#wkf#`lnsbwjaof#tjwkaf`bnf#hmltm#bp#pwzof>!nbqdjm9-ip!=?,p`qjsw=?#Jmwfqmbwjlmbo#wkfqf#kbuf#affmDfqnbm#obmdvbdf#pwzof>!`lolq9 @lnnvmjpw#Sbqwz`lmpjpwfmw#tjwkalqgfq>!3!#`foo#nbqdjmkfjdkw>!wkf#nbilqjwz#le!#bojdm>!`fmwfqqfobwfg#wl#wkf#nbmz#gjeefqfmw#Lqwklgl{#@kvq`kpjnjobq#wl#wkf#,=\t?ojmh#qfo>!ptbp#lmf#le#wkf#vmwjo#kjp#gfbwk~*+*8\t?,p`qjsw=lwkfq#obmdvbdfp`lnsbqfg#wl#wkfslqwjlmp#le#wkfwkf#Mfwkfqobmgpwkf#nlpw#`lnnlmab`hdqlvmg9vqo+bqdvfg#wkbw#wkfp`qloojmd>!ml!#jm`ovgfg#jm#wkfMlqwk#Bnfqj`bm#wkf#mbnf#le#wkfjmwfqsqfwbwjlmpwkf#wqbgjwjlmbogfufolsnfmw#le#eqfrvfmwoz#vpfgb#`loof`wjlm#leufqz#pjnjobq#wlpvqqlvmgjmd#wkff{bnsof#le#wkjpbojdm>!`fmwfq!=tlvog#kbuf#affmjnbdf\\`bswjlm#>bwwb`kfg#wl#wkfpvddfpwjmd#wkbwjm#wkf#elqn#le#jmuloufg#jm#wkfjp#gfqjufg#eqlnmbnfg#bewfq#wkfJmwqlgv`wjlm#wlqfpwqj`wjlmp#lm#pwzof>!tjgwk9#`bm#af#vpfg#wl#wkf#`qfbwjlm#lenlpw#jnslqwbmw#jmelqnbwjlm#bmgqfpvowfg#jm#wkf`loobspf#le#wkfWkjp#nfbmp#wkbwfofnfmwp#le#wkftbp#qfsob`fg#azbmbozpjp#le#wkfjmpsjqbwjlm#elqqfdbqgfg#bp#wkfnlpw#pv``fppevohmltm#bp#%rvlw8b#`lnsqfkfmpjufKjpwlqz#le#wkf#tfqf#`lmpjgfqfgqfwvqmfg#wl#wkfbqf#qfefqqfg#wlVmplvq`fg#jnbdf=\t\n?gju#`obpp>!`lmpjpwp#le#wkfpwlsSqlsbdbwjlmjmwfqfpw#jm#wkfbubjobajojwz#lebssfbqp#wl#kbuffof`wqlnbdmfwj`fmbaofPfquj`fp+evm`wjlm#le#wkfJw#jp#jnslqwbmw?,p`qjsw=?,gju=evm`wjlm+*xubq#qfobwjuf#wl#wkfbp#b#qfpvow#le#wkf#slpjwjlm#leElq#f{bnsof/#jm#nfwklg>!slpw!#tbp#elooltfg#az%bns8ngbpk8#wkfwkf#bssoj`bwjlmip!=?,p`qjsw=\x0E\tvo=?,gju=?,gju=bewfq#wkf#gfbwktjwk#qfpsf`w#wlpwzof>!sbggjmd9jp#sbqwj`vobqozgjpsobz9jmojmf8#wzsf>!pvanjw!#jp#gjujgfg#jmwl\bTA\nzk#+\x0BBl\bQ\x7F*qfpslmpbajojgbgbgnjmjpwqb`j/_mjmwfqmb`jlmbofp`lqqfpslmgjfmwf\fHe\fHF\fHC\fIg\fH{\fHF\fIn\fH\\\fIa\fHY\fHU\fHB\fHR\fH\\\fIk\fH^\fIg\fH{\fIg\fHn\fHv\fIm\fHD\fHR\fHY\fH^\fIk\fHy\fHS\fHD\fHT\fH\\\fHy\fHR\fH\\\fHF\fIm\fH^\fHS\fHT\fHz\fIg\fHp\fIk\fHn\fHv\fHR\fHU\fHS\fHc\fHA\fIk\fHp\fIk\fHn\fHZ\fHR\fHB\fHS\fH^\fHU\fHB\fHR\fH\\\fIl\fHp\fHR\fH{\fH\\\fHO\fH@\fHD\fHR\fHD\fIk\fHy\fIm\fHB\fHR\fH\\\fH@\fIa\fH^\fIe\fH{\fHB\fHR\fH^\fHS\fHy\fHB\fHU\fHS\fH^\fHR\fHF\fIo\fH[\fIa\fHL\fH@\fHN\fHP\fHH\fIk\fHA\fHR\fHp\fHF\fHR\fHy\fIa\fH^\fHS\fHy\fHs\fIa\fH\\\fIk\fHD\fHz\fHS\fH^\fHR\fHG\fHJ\fI`\fH\\\fHR\fHD\fHB\fHR\fHB\fH^\fIk\fHB\fHH\fHJ\fHR\fHD\fH@\fHR\fHp\fHR\fH\\\fHY\fHS\fHy\fHR\fHT\fHy\fIa\fHC\fIg\fHn\fHv\fHR\fHU\fHH\fIk\fHF\fHU\fIm\fHm\fHv\fH@\fHH\fHR\fHC\fHR\fHT\fHn\fHY\fHR\fHJ\fHJ\fIk\fHz\fHD\fIk\fHF\fHS\fHw\fH^\fIk\fHY\fHS\fHZ\fIk\fH[\fH\\\fHR\fHp\fIa\fHC\fHe\fHH\fIa\fHH\fH\\\fHB\fIm\fHn\fH@\fHd\fHJ\fIg\fHD\fIg\fHn\fHe\fHF\fHy\fH\\\fHO\fHF\fHN\fHP\fIk\fHn\fHT\fIa\fHI\fHS\fHH\fHG\fHS\fH^\fIa\fHB\fHB\fIm\fHz\fIa\fHC\fHi\fHv\fIa\fHw\fHR\fHw\fIn\fHs\fHH\fIl\fHT\fHn\fH{\fIl\fHH\fHp\fHR\fHc\fH{\fHR\fHY\fHS\fHA\fHR\fH{\fHt\fHO\fIa\fHs\fIk\fHJ\fIn\fHT\fH\\\fIk\fHJ\fHS\fHD\fIg\fHn\fHU\fHH\fIa\fHC\fHR\fHT\fIk\fHy\fIa\fHT\fH{\fHR\fHn\fHK\fIl\fHY\fHS\fHZ\fIa\fHY\fH\\\fHR\fHH\fIk\fHn\fHJ\fId\fHs\fIa\fHT\fHD\fHy\fIa\fHZ\fHR\fHT\fHR\fHB\fHD\fIk\fHi\fHJ\fHR\fH^\fHH\fH@\fHS\fHp\fH^\fIl\fHF\fIm\fH\\\fIn\fH[\fHU\fHS\fHn\fHJ\fIl\fHB\fHS\fHH\fIa\fH\\\fHy\fHY\fHS\fHH\fHR\fH\\\fIm\fHF\fHC\fIk\fHT\fIa\fHI\fHR\fHD\fHy\fH\\\fIg\fHM\fHP\fHB\fIm\fHy\fIa\fHH\fHC\fIg\fHp\fHD\fHR\fHy\fIo\fHF\fHC\fHR\fHF\fIg\fHT\fIa\fHs\fHt\fH\\\fIk\fH^\fIn\fHy\fHR\fH\\\fIa\fHC\fHY\fHS\fHv\fHR\fH\\\fHT\fIn\fHv\fHD\fHR\fHB\fIn\fH^\fIa\fHC\fHJ\fIk\fHz\fIk\fHn\fHU\fHB\fIk\fHZ\fHR\fHT\fIa\fHy\fIn\fH^\fHB\fId\fHn\fHD\fIk\fHH\fId\fHC\fHR\fH\\\fHp\fHS\fHT\fHy\fIkqpp({no!#wjwof>!.wzsf!#`lmwfmw>!wjwof!#`lmwfmw>!bw#wkf#pbnf#wjnf-ip!=?,p`qjsw=\t?!#nfwklg>!slpw!#?,psbm=?,b=?,oj=ufqwj`bo.bojdm9w,irvfqz-njm-ip!=-`oj`h+evm`wjlm+#pwzof>!sbggjmd.~*+*8\t?,p`qjsw=\t?,psbm=?b#kqfe>!?b#kqfe>!kwws9,,*8#qfwvqm#ebopf8wf{w.gf`lqbwjlm9#p`qloojmd>!ml!#alqgfq.`loobspf9bppl`jbwfg#tjwk#Abkbpb#JmglmfpjbFmdojpk#obmdvbdf?wf{w#{no9psb`f>-dje!#alqgfq>!3!?,algz=\t?,kwno=\tlufqeolt9kjggfm8jnd#pq`>!kwws9,,bggFufmwOjpwfmfqqfpslmpjaof#elq#p-ip!=?,p`qjsw=\t,ebuj`lm-j`l!#,=lsfqbwjmd#pzpwfn!#pwzof>!tjgwk92wbqdfw>!\\aobmh!=Pwbwf#Vmjufqpjwzwf{w.bojdm9ofew8\tgl`vnfmw-tqjwf+/#jm`ovgjmd#wkf#bqlvmg#wkf#tlqog*8\x0E\t?,p`qjsw=\x0E\t?!#pwzof>!kfjdkw98lufqeolt9kjggfmnlqf#jmelqnbwjlmbm#jmwfqmbwjlmbob#nfnafq#le#wkf#lmf#le#wkf#ejqpw`bm#af#elvmg#jm#?,gju=\t\n\n?,gju=\tgjpsobz9#mlmf8!=!#,=\t?ojmh#qfo>!\t##+evm`wjlm+*#xwkf#26wk#`fmwvqz-sqfufmwGfebvow+obqdf#mvnafq#le#Azybmwjmf#Fnsjqf-isd\x7Fwkvna\x7Fofew\x7Fubpw#nbilqjwz#lenbilqjwz#le#wkf##bojdm>!`fmwfq!=Vmjufqpjwz#Sqfppglnjmbwfg#az#wkfPf`lmg#Tlqog#Tbqgjpwqjavwjlm#le#pwzof>!slpjwjlm9wkf#qfpw#le#wkf#`kbqb`wfqjyfg#az#qfo>!mleloolt!=gfqjufp#eqln#wkfqbwkfq#wkbm#wkf#b#`lnajmbwjlm#lepwzof>!tjgwk9233Fmdojpk.psfbhjmd`lnsvwfq#p`jfm`falqgfq>!3!#bow>!wkf#f{jpwfm`f#leGfnl`qbwj`#Sbqwz!#pwzof>!nbqdjm.Elq#wkjp#qfbplm/-ip!=?,p`qjsw=\t\npAzWbdMbnf+p*X3^ip!=?,p`qjsw=\x0E\t?-ip!=?,p`qjsw=\x0E\tojmh#qfo>!j`lm!#$#bow>$$#`obpp>$elqnbwjlm#le#wkfufqpjlmp#le#wkf#?,b=?,gju=?,gju=,sbdf=\t##?sbdf=\t?gju#`obpp>!`lmwaf`bnf#wkf#ejqpwabkbpb#Jmglmfpjbfmdojpk#+pjnsof*\"y\"W\"W\"[\"Q\"U\"V\"@=i=l<^<\\=n=m<V<T<V<R<P<S<\\<Q<T<T=c<^<W=c<Y=n=m=c<x<R<]<\\<^<T=n=`=k<Y<W<R<^<Y<V<\\=l<\\<[<^<T=n<T=c<t<Q=n<Y=l<Q<Y=n<r=n<^<Y=n<T=n=`<Q<\\<S=l<T<P<Y=l<T<Q=n<Y=l<Q<Y=n<V<R=n<R=l<R<_<R=m=n=l<\\<Q<T=j=g<V<\\=k<Y=m=n<^<Y=o=m<W<R<^<T=c=i<S=l<R<]<W<Y<P=g<S<R<W=o=k<T=n=`=c<^<W=c=b=n=m=c<Q<\\<T<]<R<W<Y<Y<V<R<P<S<\\<Q<T=c<^<Q<T<P<\\<Q<T<Y=m=l<Y<X=m=n<^<\\4K5h5i5d4K4Z5f4U4K5h4]4J5f4_5f4E4K5h4K5j4F5n4K5h5i4X4K4]5o4K4F5o4K5h4_5f4K4]4K4F4K5h5i5o4F5d4D4E4K5h4_4U5d4C5f4E4K4A4Y4K4J5f4K4F4K5h4U4K5h5i5f4E4K5h4Y5d4F5f4K4F4K5h4K5j4F4]5j4F4K5h4F4Y4K5i5f5i4K5h4I4_5h4K5i5f4K5h5i4X4K4]5o4E4K5h5i4]4J5f4K4Fqlalwp!#`lmwfmw>!?gju#jg>!ellwfq!=wkf#Vmjwfg#Pwbwfp?jnd#pq`>!kwws9,,-isd\x7Fqjdkw\x7Fwkvna\x7F-ip!=?,p`qjsw=\x0E\t?ol`bwjlm-sqlwl`loeqbnfalqgfq>!3!#p!#,=\t?nfwb#mbnf>!?,b=?,gju=?,gju=?elmw.tfjdkw9alog8%rvlw8#bmg#%rvlw8gfsfmgjmd#lm#wkf#nbqdjm938sbggjmd9!#qfo>!mleloolt!#Sqfpjgfmw#le#wkf#wtfmwjfwk#`fmwvqzfujpjlm=\t##?,sbdfJmwfqmfw#F{solqfqb-bpzm`#>#wqvf8\x0E\tjmelqnbwjlm#balvw?gju#jg>!kfbgfq!=!#b`wjlm>!kwws9,,?b#kqfe>!kwwsp9,,?gju#jg>!`lmwfmw!?,gju=\x0E\t?,gju=\x0E\t?gfqjufg#eqln#wkf#?jnd#pq`>$kwws9,,b``lqgjmd#wl#wkf#\t?,algz=\t?,kwno=\tpwzof>!elmw.pjyf9p`qjsw#obmdvbdf>!Bqjbo/#Kfoufwj`b/?,b=?psbm#`obpp>!?,p`qjsw=?p`qjsw#slojwj`bo#sbqwjfpwg=?,wq=?,wbaof=?kqfe>!kwws9,,ttt-jmwfqsqfwbwjlm#leqfo>!pwzofpkffw!#gl`vnfmw-tqjwf+$?`kbqpfw>!vwe.;!=\tafdjmmjmd#le#wkf#qfufbofg#wkbw#wkfwfofujpjlm#pfqjfp!#qfo>!mleloolt!=#wbqdfw>!\\aobmh!=`objnjmd#wkbw#wkfkwws&0B&1E&1Ettt-nbmjefpwbwjlmp#leSqjnf#Njmjpwfq#lejmeovfm`fg#az#wkf`obpp>!`ofbqej{!=,gju=\x0E\t?,gju=\x0E\t\x0E\twkqff.gjnfmpjlmbo@kvq`k#le#Fmdobmgle#Mlqwk#@bqlojmbprvbqf#hjolnfwqfp-bggFufmwOjpwfmfqgjpwjm`w#eqln#wkf`lnnlmoz#hmltm#bpSklmfwj`#Boskbafwgf`obqfg#wkbw#wkf`lmwqloofg#az#wkfAfmibnjm#Eqbmhojmqlof.sobzjmd#dbnfwkf#Vmjufqpjwz#lejm#Tfpwfqm#Fvqlsfsfqplmbo#`lnsvwfqSqlif`w#Dvwfmafqdqfdbqgofpp#le#wkfkbp#affm#sqlslpfgwldfwkfq#tjwk#wkf=?,oj=?oj#`obpp>!jm#plnf#`lvmwqjfpnjm-ip!=?,p`qjsw=le#wkf#slsvobwjlmleej`jbo#obmdvbdf?jnd#pq`>!jnbdfp,jgfmwjejfg#az#wkfmbwvqbo#qfplvq`fp`obppjej`bwjlm#le`bm#af#`lmpjgfqfgrvbmwvn#nf`kbmj`pMfufqwkfofpp/#wkfnjoojlm#zfbqp#bdl?,algz=\x0E\t?,kwno=\x0E\"y\"W\"W\"[\"Q\"U\"V\"@\twbhf#bgubmwbdf#lebmg/#b``lqgjmd#wlbwwqjavwfg#wl#wkfNj`qlplew#Tjmgltpwkf#ejqpw#`fmwvqzvmgfq#wkf#`lmwqlogju#`obpp>!kfbgfqpklqwoz#bewfq#wkfmlwbaof#f{`fswjlmwfmp#le#wklvpbmgppfufqbo#gjeefqfmwbqlvmg#wkf#tlqog-qfb`kjmd#njojwbqzjplobwfg#eqln#wkflsslpjwjlm#wl#wkfwkf#Log#WfpwbnfmwBeqj`bm#Bnfqj`bmpjmpfqwfg#jmwl#wkfpfsbqbwf#eqln#wkfnfwqlslojwbm#bqfbnbhfp#jw#slppjaofb`hmltofgdfg#wkbwbqdvbaoz#wkf#nlpwwzsf>!wf{w,`pp!=\twkf#JmwfqmbwjlmboB``lqgjmd#wl#wkf#sf>!wf{w,`pp!#,=\t`ljm`jgf#tjwk#wkfwtl.wkjqgp#le#wkfGvqjmd#wkjp#wjnf/gvqjmd#wkf#sfqjlgbmmlvm`fg#wkbw#kfwkf#jmwfqmbwjlmbobmg#nlqf#qf`fmwozafojfufg#wkbw#wkf`lmp`jlvpmfpp#bmgelqnfqoz#hmltm#bppvqqlvmgfg#az#wkfejqpw#bssfbqfg#jml``bpjlmbooz#vpfgslpjwjlm9baplovwf8!#wbqdfw>!\\aobmh!#slpjwjlm9qfobwjuf8wf{w.bojdm9`fmwfq8ib{,ojap,irvfqz,2-ab`hdqlvmg.`lolq9 wzsf>!bssoj`bwjlm,bmdvbdf!#`lmwfmw>!?nfwb#kwws.frvju>!Sqjub`z#Sloj`z?,b=f+!&0@p`qjsw#pq`>$!#wbqdfw>!\\aobmh!=Lm#wkf#lwkfq#kbmg/-isd\x7Fwkvna\x7Fqjdkw\x7F1?,gju=?gju#`obpp>!?gju#pwzof>!eolbw9mjmfwffmwk#`fmwvqz?,algz=\x0E\t?,kwno=\x0E\t?jnd#pq`>!kwws9,,p8wf{w.bojdm9`fmwfqelmw.tfjdkw9#alog8#B``lqgjmd#wl#wkf#gjeefqfm`f#afwtffm!#eqbnfalqgfq>!3!#!#pwzof>!slpjwjlm9ojmh#kqfe>!kwws9,,kwno7,ollpf-gwg!=\tgvqjmd#wkjp#sfqjlg?,wg=?,wq=?,wbaof=`olpfoz#qfobwfg#wlelq#wkf#ejqpw#wjnf8elmw.tfjdkw9alog8jmsvw#wzsf>!wf{w!#?psbm#pwzof>!elmw.lmqfbgzpwbwf`kbmdf\n?gju#`obpp>!`ofbqgl`vnfmw-ol`bwjlm-#Elq#f{bnsof/#wkf#b#tjgf#ubqjfwz#le#?\"GL@WZSF#kwno=\x0E\t?%maps8%maps8%maps8!=?b#kqfe>!kwws9,,pwzof>!eolbw9ofew8`lm`fqmfg#tjwk#wkf>kwws&0B&1E&1Ettt-jm#slsvobq#`vowvqfwzsf>!wf{w,`pp!#,=jw#jp#slppjaof#wl#Kbqubqg#Vmjufqpjwzwzofpkffw!#kqfe>!,wkf#nbjm#`kbqb`wfqL{elqg#Vmjufqpjwz##mbnf>!hfztlqgp!#`pwzof>!wf{w.bojdm9wkf#Vmjwfg#Hjmdglnefgfqbo#dlufqmnfmw?gju#pwzof>!nbqdjm#gfsfmgjmd#lm#wkf#gfp`qjswjlm#le#wkf?gju#`obpp>!kfbgfq-njm-ip!=?,p`qjsw=gfpwqv`wjlm#le#wkfpojdkwoz#gjeefqfmwjm#b``lqgbm`f#tjwkwfof`lnnvmj`bwjlmpjmgj`bwfp#wkbw#wkfpklqwoz#wkfqfbewfqfpsf`jbooz#jm#wkf#Fvqlsfbm#`lvmwqjfpKltfufq/#wkfqf#bqfpq`>!kwws9,,pwbwj`pvddfpwfg#wkbw#wkf!#pq`>!kwws9,,ttt-b#obqdf#mvnafq#le#Wfof`lnnvmj`bwjlmp!#qfo>!mleloolt!#wKloz#Qlnbm#Fnsfqlqbonlpw#f{`ovpjufoz!#alqgfq>!3!#bow>!Pf`qfwbqz#le#Pwbwf`vonjmbwjmd#jm#wkf@JB#Tlqog#Eb`wallhwkf#nlpw#jnslqwbmwbmmjufqpbqz#le#wkfpwzof>!ab`hdqlvmg.?oj=?fn=?b#kqfe>!,wkf#Bwobmwj`#L`fbmpwqj`woz#psfbhjmd/pklqwoz#afelqf#wkfgjeefqfmw#wzsfp#lewkf#Lwwlnbm#Fnsjqf=?jnd#pq`>!kwws9,,Bm#Jmwqlgv`wjlm#wl`lmpfrvfm`f#le#wkfgfsbqwvqf#eqln#wkf@lmefgfqbwf#Pwbwfpjmgjdfmlvp#sflsofpSql`ffgjmdp#le#wkfjmelqnbwjlm#lm#wkfwkflqjfp#kbuf#affmjmuloufnfmw#jm#wkfgjujgfg#jmwl#wkqffbgib`fmw#`lvmwqjfpjp#qfpslmpjaof#elqgjpplovwjlm#le#wkf`loobalqbwjlm#tjwktjgfoz#qfdbqgfg#bpkjp#`lmwfnslqbqjfpelvmgjmd#nfnafq#leGlnjmj`bm#Qfsvaoj`dfmfqbooz#b``fswfgwkf#slppjajojwz#lebqf#bopl#bubjobaofvmgfq#`lmpwqv`wjlmqfpwlqbwjlm#le#wkfwkf#dfmfqbo#svaoj`jp#bonlpw#fmwjqfozsbppfp#wkqlvdk#wkfkbp#affm#pvddfpwfg`lnsvwfq#bmg#ujgflDfqnbmj`#obmdvbdfp#b``lqgjmd#wl#wkf#gjeefqfmw#eqln#wkfpklqwoz#bewfqtbqgpkqfe>!kwwsp9,,ttt-qf`fmw#gfufolsnfmwAlbqg#le#Gjqf`wlqp?gju#`obpp>!pfbq`k\x7F#?b#kqfe>!kwws9,,Jm#sbqwj`vobq/#wkfNvowjsof#ellwmlwfplq#lwkfq#pvapwbm`fwklvpbmgp#le#zfbqpwqbmpobwjlm#le#wkf?,gju=\x0E\t?,gju=\x0E\t\x0E\t?b#kqfe>!jmgf{-skstbp#fpwbaojpkfg#jmnjm-ip!=?,p`qjsw=\tsbqwj`jsbwf#jm#wkfb#pwqlmd#jmeovfm`fpwzof>!nbqdjm.wls9qfsqfpfmwfg#az#wkfdqbgvbwfg#eqln#wkfWqbgjwjlmbooz/#wkfFofnfmw+!p`qjsw!*8Kltfufq/#pjm`f#wkf,gju=\t?,gju=\t?gju#ofew8#nbqdjm.ofew9sqlwf`wjlm#bdbjmpw38#ufqwj`bo.bojdm9Vmelqwvmbwfoz/#wkfwzsf>!jnbdf,{.j`lm,gju=\t?gju#`obpp>!#`obpp>!`ofbqej{!=?gju#`obpp>!ellwfq\n\n?,gju=\t\n\n?,gju=\twkf#nlwjlm#sj`wvqf<}=f<W<_<\\=l=m<V<T<]=f<W<_<\\=l=m<V<T<H<Y<X<Y=l<\\=j<T<T<Q<Y=m<V<R<W=`<V<R=m<R<R<]=e<Y<Q<T<Y=m<R<R<]=e<Y<Q<T=c<S=l<R<_=l<\\<P<P=g<r=n<S=l<\\<^<T=n=`<]<Y=m<S<W<\\=n<Q<R<P<\\=n<Y=l<T<\\<W=g<S<R<[<^<R<W=c<Y=n<S<R=m<W<Y<X<Q<T<Y=l<\\<[<W<T=k<Q=g=i<S=l<R<X=o<V=j<T<T<S=l<R<_=l<\\<P<P<\\<S<R<W<Q<R=m=n=`=b<Q<\\=i<R<X<T=n=m=c<T<[<]=l<\\<Q<Q<R<Y<Q<\\=m<Y<W<Y<Q<T=c<T<[<P<Y<Q<Y<Q<T=c<V<\\=n<Y<_<R=l<T<T<|<W<Y<V=m<\\<Q<X=l\fHJ\fIa\fHY\fHR\fH\\\fHR\fHB\fId\fHD\fIm\fHi\fH^\fHF\fIa\fH\\\fHJ\fHR\fHD\fHA\fHR\fH\\\fHH\fIl\fHC\fHi\fHD\fIm\fHJ\fIk\fHZ\fHU\fHS\fHD\fIa\fHJ\fIl\fHk\fHn\fHM\fHS\fHC\fHR\fHJ\fHS\fH^\fIa\fH^\fIl\fHi\fHK\fHS\fHy\fHR\fH\\\fHY\fIl\fHM\fHS\fHC\fIg\fHv\fHS\fHs\fIa\fHL\fIk\fHT\fHB\fHR\fHv\fHR\fH\\\fHp\fHn\fHy\fIa\fHZ\fHD\fHJ\fIm\fHD\fHS\fHC\fHR\fHF\fIa\fH\\\fHC\fIg\fH{\fHi\fHD\fIm\fHT\fHR\fH\\\fH}\fHD\fH^\fHR\fHk\fHD\fHF\fHR\fH\\\fIa\fHs\fIl\fHZ\fH\\\fIa\fHH\fIg\fHn\fH^\fIg\fHy\fHT\fHA\fHR\fHG\fHP\fIa\fH^\fId\fHZ\fHZ\fH\\\fIa\fHH\fIk\fHn\fHF\fIa\fH\\\fHJ\fIk\fHZ\fHF\fIa\fH^\fIk\fHC\fH\\\fHy\fIk\fHn\fHJ\fIa\fH\\\fHT\fIa\fHI\fHS\fHH\fHS\fHe\fHH\fIa\fHF\fHR\fHJ\fHe\fHD\fIa\fHU\fIk\fHn\fHv\fHS\fHs\fIa\fHL\fHR\fHC\fHR\fHH\fIa\fH\\\fHR\fHp\fIa\fHC\fHR\fHJ\fHR\fHF\fIm\fH\\\fHR\fHD\fIk\fHp\fIg\fHM\fHP\fIk\fHn\fHi\fHD\fIm\fHY\fHR\fHJ\fHZ\fIa\fH\\\fIk\fHO\fIl\fHZ\fHS\fHy\fIa\fH[\fHR\fHT\fH\\\fHy\fHR\fH\\\fIl\fHT\fHn\fH{\fIa\fH\\\fHU\fHF\fH\\\fHS\fHO\fHR\fHB\fH@\fIa\fH\\\fHR\fHn\fHM\fH@\fHv\fIa\fHv\fIg\fHn\fHe\fHF\fH^\fH@\fIa\fHK\fHB\fHn\fHH\fIa\fH\\\fIl\fHT\fHn\fHF\fH\\\fIa\fHy\fHe\fHB\fIa\fHB\fIl\fHJ\fHB\fHR\fHK\fIa\fHC\fHB\fHT\fHU\fHR\fHC\fHH\fHR\fHZ\fH@\fIa\fHJ\fIg\fHn\fHB\fIl\fHM\fHS\fHC\fHR\fHj\fHd\fHF\fIl\fHc\fH^\fHB\fIg\fH@\fHR\fHk\fH^\fHT\fHn\fHz\fIa\fHC\fHR\fHj\fHF\fH\\\fIk\fHZ\fHD\fHi\fHD\fIm\fH@\fHn\fHK\fH@\fHR\fHp\fHP\fHR\fH\\\fHD\fHY\fIl\fHD\fHH\fHB\fHF\fIa\fH\\\fHB\fIm\fHz\fHF\fIa\fH\\\fHZ\fIa\fHD\fHF\fH\\\fHS\fHY\fHR\fH\\\fHD\fIm\fHy\fHT\fHR\fHD\fHT\fHB\fH\\\fIa\fHI\fHD\fHj\fHC\fIg\fHp\fHS\fHH\fHT\fIg\fHB\fHY\fHR\fH\\4K5h5i4X4K4]5o4K4F4K5h5i5j4F4C5f4K4F4K5h5o5i4D5f5d4F4]4K5h5i4X4K5k4C4K4F4U4C4C4K5h4^5d4K4]4U4C4C4K5h4]4C5d4C4K5h4I4_5h4K5i5f4E4K5h5m5d4F5d4X5d4D4K5h5i4_4K4D5n4K4F4K5h5i4U5h5d5i4K4F4K5h5i4_5h4_5h4K4F4K5h4@4]4K5m5f5o4_4K5h4K4_5h4K5i5f4E4K5h4K4F4Y4K5h4K4Fhfztlqgp!#`lmwfmw>!t0-lqd,2:::,{kwno!=?b#wbqdfw>!\\aobmh!#wf{w,kwno8#`kbqpfw>!#wbqdfw>!\\aobmh!=?wbaof#`foosbggjmd>!bvwl`lnsofwf>!lee!#wf{w.bojdm9#`fmwfq8wl#obpw#ufqpjlm#az#ab`hdqlvmg.`lolq9# !#kqfe>!kwws9,,ttt-,gju=?,gju=?gju#jg>?b#kqfe>! !#`obpp>!!=?jnd#pq`>!kwws9,,`qjsw!#pq`>!kwws9,,\t?p`qjsw#obmdvbdf>!,,FM!#!kwws9,,ttt-tfm`lgfVQJ@lnslmfmw+!#kqfe>!ibubp`qjsw9?gju#`obpp>!`lmwfmwgl`vnfmw-tqjwf+$?p`slpjwjlm9#baplovwf8p`qjsw#pq`>!kwws9,,#pwzof>!nbqdjm.wls9-njm-ip!=?,p`qjsw=\t?,gju=\t?gju#`obpp>!t0-lqd,2:::,{kwno!#\t\x0E\t?,algz=\x0E\t?,kwno=gjpwjm`wjlm#afwtffm,!#wbqdfw>!\\aobmh!=?ojmh#kqfe>!kwws9,,fm`lgjmd>!vwe.;!<=\tt-bggFufmwOjpwfmfq<b`wjlm>!kwws9,,ttt-j`lm!#kqfe>!kwws9,,#pwzof>!ab`hdqlvmg9wzsf>!wf{w,`pp!#,=\tnfwb#sqlsfqwz>!ld9w?jmsvw#wzsf>!wf{w!##pwzof>!wf{w.bojdm9wkf#gfufolsnfmw#le#wzofpkffw!#wzsf>!wfkwno8#`kbqpfw>vwe.;jp#`lmpjgfqfg#wl#afwbaof#tjgwk>!233&!#Jm#bggjwjlm#wl#wkf#`lmwqjavwfg#wl#wkf#gjeefqfm`fp#afwtffmgfufolsnfmw#le#wkf#Jw#jp#jnslqwbmw#wl#?,p`qjsw=\t\t?p`qjsw##pwzof>!elmw.pjyf92=?,psbm=?psbm#jg>daOjaqbqz#le#@lmdqfpp?jnd#pq`>!kwws9,,jnFmdojpk#wqbmpobwjlmB`bgfnz#le#P`jfm`fpgju#pwzof>!gjpsobz9`lmpwqv`wjlm#le#wkf-dfwFofnfmwAzJg+jg*jm#`lmivm`wjlm#tjwkFofnfmw+$p`qjsw$*8#?nfwb#sqlsfqwz>!ld9<}=f<W<_<\\=l=m<V<T\t#wzsf>!wf{w!#mbnf>!=Sqjub`z#Sloj`z?,b=bgnjmjpwfqfg#az#wkffmbaofPjmdofQfrvfpwpwzof>%rvlw8nbqdjm9?,gju=?,gju=?,gju=?=?jnd#pq`>!kwws9,,j#pwzof>%rvlw8eolbw9qfefqqfg#wl#bp#wkf#wlwbo#slsvobwjlm#lejm#Tbpkjmdwlm/#G-@-#pwzof>!ab`hdqlvmg.bnlmd#lwkfq#wkjmdp/lqdbmjybwjlm#le#wkfsbqwj`jsbwfg#jm#wkfwkf#jmwqlgv`wjlm#lejgfmwjejfg#tjwk#wkfej`wjlmbo#`kbqb`wfq#L{elqg#Vmjufqpjwz#njpvmgfqpwbmgjmd#leWkfqf#bqf/#kltfufq/pwzofpkffw!#kqfe>!,@lovnajb#Vmjufqpjwzf{sbmgfg#wl#jm`ovgfvpvbooz#qfefqqfg#wljmgj`bwjmd#wkbw#wkfkbuf#pvddfpwfg#wkbwbeejojbwfg#tjwk#wkf`lqqfobwjlm#afwtffmmvnafq#le#gjeefqfmw=?,wg=?,wq=?,wbaof=Qfsvaoj`#le#Jqfobmg\t?,p`qjsw=\t?p`qjsw#vmgfq#wkf#jmeovfm`f`lmwqjavwjlm#wl#wkfLeej`jbo#tfapjwf#lekfbgrvbqwfqp#le#wkf`fmwfqfg#bqlvmg#wkfjnsoj`bwjlmp#le#wkfkbuf#affm#gfufolsfgEfgfqbo#Qfsvaoj`#leaf`bnf#jm`qfbpjmdoz`lmwjmvbwjlm#le#wkfMlwf/#kltfufq/#wkbwpjnjobq#wl#wkbw#le#`bsbajojwjfp#le#wkfb``lqgbm`f#tjwk#wkfsbqwj`jsbmwp#jm#wkfevqwkfq#gfufolsnfmwvmgfq#wkf#gjqf`wjlmjp#lewfm#`lmpjgfqfgkjp#zlvmdfq#aqlwkfq?,wg=?,wq=?,wbaof=?b#kwws.frvju>![.VB.skzpj`bo#sqlsfqwjfple#Aqjwjpk#@lovnajbkbp#affm#`qjwj`jyfg+tjwk#wkf#f{`fswjlmrvfpwjlmp#balvw#wkfsbppjmd#wkqlvdk#wkf3!#`foosbggjmd>!3!#wklvpbmgp#le#sflsofqfgjqf`wp#kfqf-#Elqkbuf#`kjogqfm#vmgfq&0F&0@,p`qjsw&0F!**8?b#kqfe>!kwws9,,ttt-?oj=?b#kqfe>!kwws9,,pjwf\\mbnf!#`lmwfmw>!wf{w.gf`lqbwjlm9mlmfpwzof>!gjpsobz9#mlmf?nfwb#kwws.frvju>![.mft#Gbwf+*-dfwWjnf+*#wzsf>!jnbdf,{.j`lm!?,psbm=?psbm#`obpp>!obmdvbdf>!ibubp`qjswtjmglt-ol`bwjlm-kqfe?b#kqfe>!ibubp`qjsw9..=\x0E\t?p`qjsw#wzsf>!w?b#kqfe>$kwws9,,ttt-klqw`vw#j`lm!#kqfe>!?,gju=\x0E\t?gju#`obpp>!?p`qjsw#pq`>!kwws9,,!#qfo>!pwzofpkffw!#w?,gju=\t?p`qjsw#wzsf>,b=#?b#kqfe>!kwws9,,#booltWqbmpsbqfm`z>![.VB.@lnsbwjaof!#`lmqfobwjlmpkjs#afwtffm\t?,p`qjsw=\x0E\t?p`qjsw#?,b=?,oj=?,vo=?,gju=bppl`jbwfg#tjwk#wkf#sqldqbnnjmd#obmdvbdf?,b=?b#kqfe>!kwws9,,?,b=?,oj=?oj#`obpp>!elqn#b`wjlm>!kwws9,,?gju#pwzof>!gjpsobz9wzsf>!wf{w!#mbnf>!r!?wbaof#tjgwk>!233&!#ab`hdqlvmg.slpjwjlm9!#alqgfq>!3!#tjgwk>!qfo>!pklqw`vw#j`lm!#k5=?vo=?oj=?b#kqfe>!##?nfwb#kwws.frvju>!`pp!#nfgjb>!p`qffm!#qfpslmpjaof#elq#wkf#!#wzsf>!bssoj`bwjlm,!#pwzof>!ab`hdqlvmg.kwno8#`kbqpfw>vwe.;!#booltwqbmpsbqfm`z>!pwzofpkffw!#wzsf>!wf\x0E\t?nfwb#kwws.frvju>!=?,psbm=?psbm#`obpp>!3!#`foopsb`jmd>!3!=8\t?,p`qjsw=\t?p`qjsw#plnfwjnfp#`boofg#wkfglfp#mlw#mf`fppbqjozElq#nlqf#jmelqnbwjlmbw#wkf#afdjmmjmd#le#?\"GL@WZSF#kwno=?kwnosbqwj`vobqoz#jm#wkf#wzsf>!kjggfm!#mbnf>!ibubp`qjsw9uljg+3*8!feef`wjufmfpp#le#wkf#bvwl`lnsofwf>!lee!#dfmfqbooz#`lmpjgfqfg=?jmsvw#wzsf>!wf{w!#!=?,p`qjsw=\x0E\t?p`qjswwkqlvdklvw#wkf#tlqog`lnnlm#njp`lm`fswjlmbppl`jbwjlm#tjwk#wkf?,gju=\t?,gju=\t?gju#`gvqjmd#kjp#ojefwjnf/`lqqfpslmgjmd#wl#wkfwzsf>!jnbdf,{.j`lm!#bm#jm`qfbpjmd#mvnafqgjsolnbwj`#qfobwjlmpbqf#lewfm#`lmpjgfqfgnfwb#`kbqpfw>!vwe.;!#?jmsvw#wzsf>!wf{w!#f{bnsofp#jm`ovgf#wkf!=?jnd#pq`>!kwws9,,jsbqwj`jsbwjlm#jm#wkfwkf#fpwbaojpknfmw#le\t?,gju=\t?gju#`obpp>!%bns8maps8%bns8maps8wl#gfwfqnjmf#tkfwkfqrvjwf#gjeefqfmw#eqlnnbqhfg#wkf#afdjmmjmdgjpwbm`f#afwtffm#wkf`lmwqjavwjlmp#wl#wkf`lmeoj`w#afwtffm#wkftjgfoz#`lmpjgfqfg#wltbp#lmf#le#wkf#ejqpwtjwk#ubqzjmd#gfdqffpkbuf#psf`vobwfg#wkbw+gl`vnfmw-dfwFofnfmwsbqwj`jsbwjmd#jm#wkflqjdjmbooz#gfufolsfgfwb#`kbqpfw>!vwe.;!=#wzsf>!wf{w,`pp!#,=\tjmwfq`kbmdfbaoz#tjwknlqf#`olpfoz#qfobwfgpl`jbo#bmg#slojwj`bowkbw#tlvog#lwkfqtjpfsfqsfmgj`vobq#wl#wkfpwzof#wzsf>!wf{w,`ppwzsf>!pvanjw!#mbnf>!ebnjojfp#qfpjgjmd#jmgfufolsjmd#`lvmwqjfp`lnsvwfq#sqldqbnnjmdf`lmlnj`#gfufolsnfmwgfwfqnjmbwjlm#le#wkfelq#nlqf#jmelqnbwjlmlm#pfufqbo#l``bpjlmpslqwvdv/Fp#+Fvqlsfv*<O<V=l<\\={<Q=m=`<V<\\=o<V=l<\\={<Q=m=`<V<\\<L<R=m=m<T<U=m<V<R<U<P<\\=n<Y=l<T<\\<W<R<^<T<Q=h<R=l<P<\\=j<T<T=o<S=l<\\<^<W<Y<Q<T=c<Q<Y<R<]=i<R<X<T<P<R<T<Q=h<R=l<P<\\=j<T=c<t<Q=h<R=l<P<\\=j<T=c<L<Y=m<S=o<]<W<T<V<T<V<R<W<T=k<Y=m=n<^<R<T<Q=h<R=l<P<\\=j<T=b=n<Y=l=l<T=n<R=l<T<T<X<R=m=n<\\=n<R=k<Q<R4K5h5i4F5d4K4@4C5d5j4K5h4K4X4F4]4K5o4K4F4K5h4K5n4F4]4K4A4K4Fkwno8#`kbqpfw>VWE.;!#pfwWjnflvw+evm`wjlm+*gjpsobz9jmojmf.aol`h8?jmsvw#wzsf>!pvanjw!#wzsf#>#$wf{w,ibubp`qj?jnd#pq`>!kwws9,,ttt-!#!kwws9,,ttt-t0-lqd,pklqw`vw#j`lm!#kqfe>!!#bvwl`lnsofwf>!lee!#?,b=?,gju=?gju#`obpp>?,b=?,oj=\t?oj#`obpp>!`pp!#wzsf>!wf{w,`pp!#?elqn#b`wjlm>!kwws9,,{w,`pp!#kqfe>!kwws9,,ojmh#qfo>!bowfqmbwf!#\x0E\t?p`qjsw#wzsf>!wf{w,#lm`oj`h>!ibubp`qjsw9+mft#Gbwf*-dfwWjnf+*~kfjdkw>!2!#tjgwk>!2!#Sflsof$p#Qfsvaoj`#le##?b#kqfe>!kwws9,,ttt-wf{w.gf`lqbwjlm9vmgfqwkf#afdjmmjmd#le#wkf#?,gju=\t?,gju=\t?,gju=\tfpwbaojpknfmw#le#wkf#?,gju=?,gju=?,gju=?,g ujftslqwxnjm.kfjdkw9\t?p`qjsw#pq`>!kwws9,,lswjlm=?lswjlm#ubovf>lewfm#qfefqqfg#wl#bp#,lswjlm=\t?lswjlm#ubov?\"GL@WZSF#kwno=\t?\"..XJmwfqmbwjlmbo#Bjqslqw=\t?b#kqfe>!kwws9,,ttt?,b=?b#kqfe>!kwws9,,t\fTL\fT^\fTE\fT^\fUh\fT{\fTN\roI\ro|\roL\ro{\roO\rov\rot\nAO\x05Gx\bTA\nzk#+\x0BUm\x05Gx*\fHD\fHS\fH\\\fIa\fHJ\fIk\fHZ\fHM\fHR\fHe\fHD\fH^\fIg\fHM\fHy\fIa\fH[\fIk\fHH\fIa\fH\\\fHp\fHR\fHD\fHy\fHR\fH\\\fIl\fHT\fHn\fH@\fHn\fHK\fHS\fHH\fHT\fIa\fHI\fHR\fHF\fHD\fHR\fHT\fIa\fHY\fIl\fHy\fHR\fH\\\fHT\fHn\fHT\fIa\fHy\fH\\\fHO\fHT\fHR\fHB\fH{\fIa\fH\\\fIl\fHv\fHS\fHs\fIa\fHL\fIg\fHn\fHY\fHS\fHp\fIa\fHr\fHR\fHD\fHi\fHB\fIk\fH\\\fHS\fHy\fHR\fHY\fHS\fHA\fHS\fHD\fIa\fHD\fH{\fHR\fHM\fHS\fHC\fHR\fHm\fHy\fIa\fHC\fIg\fHn\fHy\fHS\fHT\fIm\fH\\\fHy\fIa\fH[\fHR\fHF\fHU\fIm\fHm\fHv\fHH\fIl\fHF\fIa\fH\\\fH@\fHn\fHK\fHD\fHs\fHS\fHF\fIa\fHF\fHO\fIl\fHy\fIa\fH\\\fHS\fHy\fIk\fHs\fHF\fIa\fH\\\fHR\fH\\\fHn\fHA\fHF\fIa\fH\\\fHR\fHF\fIa\fHH\fHB\fHR\fH^\fHS\fHy\fIg\fHn\fH\\\fHG\fHP\fIa\fHH\fHR\fH\\\fHD\fHS\fH\\\fIa\fHB\fHR\fHO\fH^\fHS\fHB\fHS\fHs\fIk\fHMgfp`qjswjlm!#`lmwfmw>!gl`vnfmw-ol`bwjlm-sqlw-dfwFofnfmwpAzWbdMbnf+?\"GL@WZSF#kwno=\t?kwno#?nfwb#`kbqpfw>!vwe.;!=9vqo!#`lmwfmw>!kwws9,,-`pp!#qfo>!pwzofpkffw!pwzof#wzsf>!wf{w,`pp!=wzsf>!wf{w,`pp!#kqfe>!t0-lqd,2:::,{kwno!#{nowzsf>!wf{w,ibubp`qjsw!#nfwklg>!dfw!#b`wjlm>!ojmh#qfo>!pwzofpkffw!##>#gl`vnfmw-dfwFofnfmwwzsf>!jnbdf,{.j`lm!#,=`foosbggjmd>!3!#`foops-`pp!#wzsf>!wf{w,`pp!#?,b=?,oj=?oj=?b#kqfe>!!#tjgwk>!2!#kfjdkw>!2!!=?b#kqfe>!kwws9,,ttt-pwzof>!gjpsobz9mlmf8!=bowfqmbwf!#wzsf>!bssoj.,,T0@,,GWG#[KWNO#2-3#foopsb`jmd>!3!#`foosbg#wzsf>!kjggfm!#ubovf>!,b=%maps8?psbm#qlof>!p\t?jmsvw#wzsf>!kjggfm!#obmdvbdf>!IbubP`qjsw!##gl`vnfmw-dfwFofnfmwpAd>!3!#`foopsb`jmd>!3!#zsf>!wf{w,`pp!#nfgjb>!wzsf>$wf{w,ibubp`qjsw$tjwk#wkf#f{`fswjlm#le#zsf>!wf{w,`pp!#qfo>!pw#kfjdkw>!2!#tjgwk>!2!#>$(fm`lgfVQJ@lnslmfmw+?ojmh#qfo>!bowfqmbwf!#\talgz/#wq/#jmsvw/#wf{wnfwb#mbnf>!qlalwp!#`lmnfwklg>!slpw!#b`wjlm>!=\t?b#kqfe>!kwws9,,ttt-`pp!#qfo>!pwzofpkffw!#?,gju=?,gju=?gju#`obppobmdvbdf>!ibubp`qjsw!=bqjb.kjggfm>!wqvf!=.[?qjsw!#wzsf>!wf{w,ibubpo>38~*+*8\t+evm`wjlm+*xab`hdqlvmg.jnbdf9#vqo+,b=?,oj=?oj=?b#kqfe>!k\n\n?oj=?b#kqfe>!kwws9,,bwlq!#bqjb.kjggfm>!wqv=#?b#kqfe>!kwws9,,ttt-obmdvbdf>!ibubp`qjsw!#,lswjlm=\t?lswjlm#ubovf,gju=?,gju=?gju#`obpp>qbwlq!#bqjb.kjggfm>!wqf>+mft#Gbwf*-dfwWjnf+*slqwvdv/Fp#+gl#Aqbpjo*<R=l<_<\\<Q<T<[<\\=j<T<T<^<R<[<P<R<Z<Q<R=m=n=`<R<]=l<\\<[<R<^<\\<Q<T=c=l<Y<_<T=m=n=l<\\=j<T<T<^<R<[<P<R<Z<Q<R=m=n<T<R<]=c<[<\\=n<Y<W=`<Q<\\?\"GL@WZSF#kwno#SVAOJ@#!mw.Wzsf!#`lmwfmw>!wf{w,?nfwb#kwws.frvju>!@lmwfqbmpjwjlmbo,,FM!#!kwws9?kwno#{nomp>!kwws9,,ttt.,,T0@,,GWG#[KWNO#2-3#WGWG,{kwno2.wqbmpjwjlmbo,,ttt-t0-lqd,WQ,{kwno2,sf#>#$wf{w,ibubp`qjsw$8?nfwb#mbnf>!gfp`qjswjlmsbqfmwMlgf-jmpfqwAfelqf?jmsvw#wzsf>!kjggfm!#mbip!#wzsf>!wf{w,ibubp`qj+gl`vnfmw*-qfbgz+evm`wjp`qjsw#wzsf>!wf{w,ibubpjnbdf!#`lmwfmw>!kwws9,,VB.@lnsbwjaof!#`lmwfmw>wno8#`kbqpfw>vwe.;!#,=\tojmh#qfo>!pklqw`vw#j`lm?ojmh#qfo>!pwzofpkffw!#?,p`qjsw=\t?p`qjsw#wzsf>>#gl`vnfmw-`qfbwfFofnfm?b#wbqdfw>!\\aobmh!#kqfe>#gl`vnfmw-dfwFofnfmwpAjmsvw#wzsf>!wf{w!#mbnf>b-wzsf#>#$wf{w,ibubp`qjmsvw#wzsf>!kjggfm!#mbnfkwno8#`kbqpfw>vwe.;!#,=gwg!=\t?kwno#{nomp>!kwws.,,T0@,,GWG#KWNO#7-32#WfmwpAzWbdMbnf+$p`qjsw$*jmsvw#wzsf>!kjggfm!#mbn?p`qjsw#wzsf>!wf{w,ibubp!#pwzof>!gjpsobz9mlmf8!=gl`vnfmw-dfwFofnfmwAzJg+>gl`vnfmw-`qfbwfFofnfmw+$#wzsf>$wf{w,ibubp`qjsw$jmsvw#wzsf>!wf{w!#mbnf>!g-dfwFofnfmwpAzWbdMbnf+pmj`bo!#kqfe>!kwws9,,ttt-@,,GWG#KWNO#7-32#Wqbmpjw?pwzof#wzsf>!wf{w,`pp!=\t\t?pwzof#wzsf>!wf{w,`pp!=jlmbo-gwg!=\t?kwno#{nomp>kwws.frvju>[email protected]>!3!#`foopsb`jmd>!3!kwno8#`kbqpfw>vwe.;!#,=\t#pwzof>!gjpsobz9mlmf8!=??oj=?b#kqfe>!kwws9,,ttt-#wzsf>$wf{w,ibubp`qjsw$=<X<Y=c=n<Y<W=`<Q<R=m=n<T=m<R<R=n<^<Y=n=m=n<^<T<T<S=l<R<T<[<^<R<X=m=n<^<\\<]<Y<[<R<S<\\=m<Q<R=m=n<T\fHF\fIm\fHT\fIa\fHH\fHS\fHy\fHR\fHy\fHR\fHn\fH{\fIa\fH\\\fIk\fHT\fHe\fHD\fIa\fHU\fIg\fHn\fHD\fIk\fHY\fHS\fHK\fHR\fHD\fHT\fHA\fHR\fHG\fHS\fHy\fIa\fHT\fHS\fHn\fH{\fHT\fIm\fH\\\fHy\fIa\fH[\fHS\fHH\fHy\fIe\fHF\fIl\fH\\\fHR\fHk\fHs\fHY\fHS\fHp\fIa\fHr\fHR\fHF\fHD\fHy\fHR\fH\\\fIa\fH\\\fHY\fHR\fHd\fHT\fHy\fIa\fH\\\fHS\fHC\fHH\fHR", "\u06F7%\u018C'T%\x85'W%\xD7%O%g%\xA6&\u0193%\u01E5&>&*&'&^&\x88\u0178\u0C3E&\u01AD&\u0192&)&^&%&'&\x82&P&1&\xB1&3&]&m&u&E&t&C&\xCF&V&V&/&>&6&\u0F76\u177Co&p&@&E&M&P&x&@&F&e&\xCC&7&:&(&D&0&C&)&.&F&-&1&(&L&F&1\u025E*\u03EA\u21F3&\u1372&K&;&)&E&H&P&0&?&9&V&\x81&-&v&a&,&E&)&?&=&'&'&B&\u0D2E&\u0503&\u0316*&*8&%&%&&&%,)&\x9A&>&\x86&7&]&F&2&>&J&6&n&2&%&?&\x8E&2&6&J&g&-&0&,&*&J&*&O&)&6&(&<&B&N&.&P&@&2&.&W&M&%\u053C\x84(,(<&,&\u03DA&\u18C7&-&,(%&(&%&(\u013B0&X&D&\x81&j&'&J&(&.&B&3&Z&R&h&3&E&E&<\xC6-\u0360\u1EF3&%8?&@&,&Z&@&0&J&,&^&x&_&6&C&6&C\u072C\u2A25&f&-&-&-&-&,&J&2&8&z&8&C&Y&8&-&d&\u1E78\xCC-&7&1&F&7&t&W&7&I&.&.&^&=\u0F9C\u19D3&8(>&/&/&\u077B')'\u1065')'%@/&0&%\u043E\u09C0*&*@&C\u053D\u05D4\u0274\u05EB4\u0DD7\u071A\u04D16\u0D84&/\u0178\u0303Z&*%\u0246\u03FF&\u0134&1\xA8\u04B4\u0174", dictionarySizeBits, "AAAAKKLLKKKKKJJIHHIHHGGFF");
9195  setData(dictionaryData, dictionarySizeBits);
9196  function InputStream(data) {
9197    this.data = new Int8Array(0);
9198    this.offset = 0;
9199    this.data = data;
9200  }
9201  function readInput(s, dst, offset, length) {
9202    if (s.input === null) {
9203      return -1;
9204    }
9205    const src = s.input;
9206    const end = Math.min(src.offset + length, src.data.length);
9207    const bytesRead = end - src.offset;
9208    dst.set(src.data.subarray(src.offset, end), offset);
9209    src.offset += bytesRead;
9210    return bytesRead;
9211  }
9212  function closeInput(s) {
9213    s.input = new InputStream(new Int8Array(0));
9214  }
9215  function toUsAsciiBytes(src) {
9216    const n = src.length;
9217    const result = new Int8Array(n);
9218    for (let i = 0; i < n; ++i) {
9219      result[i] = src.charCodeAt(i);
9220    }
9221    return result;
9222  }
9223  function toUtf8Runes(src) {
9224    const n = src.length;
9225    const result = new Int32Array(n);
9226    for (let i = 0; i < n; ++i) {
9227      result[i] = src.charCodeAt(i);
9228    }
9229    return result;
9230  }
9231  function makeError(s, code) {
9232    if (code >= 0) {
9233      return code;
9234    }
9235    if (s.runningState >= 0) {
9236      s.runningState = code;
9237    }
9238    throw new Error("Brotli error code: " + code);
9239  }
9240  let ByteBuffer;
9241  function decode(bytes, options) {
9242    let s = new State();
9243    s.input = new InputStream(bytes);
9244    initState(s);
9245    if (options) {
9246      let customDictionary = options["customDictionary"];
9247      if (customDictionary) attachDictionaryChunk(s, customDictionary);
9248    }
9249    let totalOutput = 0;
9250    let chunks = [];
9251    while (true) {
9252      let chunk = new Int8Array(16384);
9253      chunks.push(chunk);
9254      s.output = chunk;
9255      s.outputOffset = 0;
9256      s.outputLength = 16384;
9257      s.outputUsed = 0;
9258      decompress(s);
9259      totalOutput += s.outputUsed;
9260      if (s.outputUsed < 16384) break;
9261    }
9262    close(s);
9263    closeInput(s);
9264    let result = new Int8Array(totalOutput);
9265    let offset = 0;
9266    for (let i = 0; i < chunks.length; ++i) {
9267      let chunk = chunks[i];
9268      let end = Math.min(totalOutput, offset + 16384);
9269      let len = end - offset;
9270      if (len < 16384) {
9271        result.set(chunk.subarray(0, len), offset);
9272      } else {
9273        result.set(chunk, offset);
9274      }
9275      offset += len;
9276    }
9277    return result;
9278  }
9279  return decode;
9280};
9281let BrotliDecode = makeBrotliDecode();
9282;// ./src/core/brotli_stream.js
9283
9284
9285
9286class BrotliStream extends DecodeStream {
9287  #isAsync = true;
9288  constructor(stream, maybeLength) {
9289    super(maybeLength);
9290    this.stream = stream;
9291    this.dict = stream.dict;
9292  }
9293  readBlock() {
9294    const bytes = this.stream.getBytes();
9295    const decodedData = BrotliDecode(new Int8Array(bytes.buffer, bytes.byteOffset, bytes.length));
9296    this.buffer = new Uint8Array(decodedData.buffer, decodedData.byteOffset, decodedData.length);
9297    this.bufferLength = this.buffer.length;
9298    this.eof = true;
9299  }
9300  async getImageData(length, _decoderOptions) {
9301    const data = await this.asyncGetBytes();
9302    if (!data) {
9303      return this.getBytes(length);
9304    }
9305    if (data.length <= length) {
9306      return data;
9307    }
9308    return data.subarray(0, length);
9309  }
9310  async asyncGetBytes() {
9311    const {
9312      decompressed,
9313      compressed
9314    } = await this.asyncGetBytesFromDecompressionStream("brotli");
9315    if (decompressed) {
9316      return decompressed;
9317    }
9318    this.#isAsync = false;
9319    this.stream = new Stream(compressed, 0, compressed.length, this.stream.dict);
9320    this.reset();
9321    return null;
9322  }
9323  get isAsync() {
9324    return this.#isAsync;
9325  }
9326}
9327
9328;// ./external/jbig2/jbig2.js
9329async function JBig2(moduleArg = {}) {
9330  var moduleRtn;
9331  var Module = moduleArg;
9332  var ENVIRONMENT_IS_WEB = true;
9333  var ENVIRONMENT_IS_WORKER = false;
9334  var arguments_ = [];
9335  var thisProgram = "./this.program";
9336  var quit_ = (status, toThrow) => {
9337    throw toThrow;
9338  };
9339  var _scriptName = import.meta.url;
9340  var scriptDirectory = "";
9341  var readAsync, readBinary;
9342  if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
9343    try {
9344      scriptDirectory = new URL(".", _scriptName).href;
9345    } catch {}
9346    readAsync = async url => {
9347      var response = await fetch(url, {
9348        credentials: "same-origin"
9349      });
9350      if (response.ok) {
9351        return response.arrayBuffer();
9352      }
9353      throw new Error(response.status + " : " + response.url);
9354    };
9355  } else {}
9356  var out = console.log.bind(console);
9357  var err = console.error.bind(console);
9358  var wasmBinary;
9359  var ABORT = false;
9360  var EXITSTATUS;
9361  var readyPromiseResolve, readyPromiseReject;
9362  var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;
9363  var HEAP64, HEAPU64;
9364  var runtimeInitialized = false;
9365  function updateMemoryViews() {
9366    var b = wasmMemory.buffer;
9367    HEAP8 = new Int8Array(b);
9368    HEAP16 = new Int16Array(b);
9369    HEAPU8 = new Uint8Array(b);
9370    HEAPU16 = new Uint16Array(b);
9371    HEAP32 = new Int32Array(b);
9372    HEAPU32 = new Uint32Array(b);
9373    HEAPF32 = new Float32Array(b);
9374    HEAPF64 = new Float64Array(b);
9375    HEAP64 = new BigInt64Array(b);
9376    HEAPU64 = new BigUint64Array(b);
9377  }
9378  function preRun() {
9379    if (Module["preRun"]) {
9380      if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
9381      while (Module["preRun"].length) {
9382        addOnPreRun(Module["preRun"].shift());
9383      }
9384    }
9385    callRuntimeCallbacks(onPreRuns);
9386  }
9387  function initRuntime() {
9388    runtimeInitialized = true;
9389    wasmExports["j"]();
9390  }
9391  function postRun() {
9392    if (Module["postRun"]) {
9393      if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
9394      while (Module["postRun"].length) {
9395        addOnPostRun(Module["postRun"].shift());
9396      }
9397    }
9398    callRuntimeCallbacks(onPostRuns);
9399  }
9400  function abort(what) {
9401    Module["onAbort"]?.(what);
9402    what = "Aborted(" + what + ")";
9403    err(what);
9404    ABORT = true;
9405    what += ". Build with -sASSERTIONS for more info.";
9406    var e = new WebAssembly.RuntimeError(what);
9407    readyPromiseReject?.(e);
9408    throw e;
9409  }
9410  var wasmBinaryFile;
9411  function getWasmImports() {
9412    var imports = {
9413      a: wasmImports
9414    };
9415    return imports;
9416  }
9417  async function createWasm() {
9418    function receiveInstance(instance, module) {
9419      wasmExports = instance.exports;
9420      assignWasmExports(wasmExports);
9421      updateMemoryViews();
9422      return wasmExports;
9423    }
9424    var info = getWasmImports();
9425    return new Promise((resolve, reject) => {
9426      Module["instantiateWasm"](info, (inst, mod) => {
9427        resolve(receiveInstance(inst, mod));
9428      });
9429    });
9430  }
9431  class ExitStatus {
9432    name = "ExitStatus";
9433    constructor(status) {
9434      this.message = `Program terminated with exit(${status})`;
9435      this.status = status;
9436    }
9437  }
9438  var callRuntimeCallbacks = callbacks => {
9439    while (callbacks.length > 0) {
9440      callbacks.shift()(Module);
9441    }
9442  };
9443  var onPostRuns = [];
9444  var addOnPostRun = cb => onPostRuns.push(cb);
9445  var onPreRuns = [];
9446  var addOnPreRun = cb => onPreRuns.push(cb);
9447  var noExitRuntime = true;
9448  var __abort_js = () => abort("");
9449  var runtimeKeepaliveCounter = 0;
9450  var __emscripten_runtime_keepalive_clear = () => {
9451    noExitRuntime = false;
9452    runtimeKeepaliveCounter = 0;
9453  };
9454  var timers = {};
9455  var handleException = e => {
9456    if (e instanceof ExitStatus || e == "unwind") {
9457      return EXITSTATUS;
9458    }
9459    quit_(1, e);
9460  };
9461  var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
9462  var _proc_exit = code => {
9463    EXITSTATUS = code;
9464    if (!keepRuntimeAlive()) {
9465      Module["onExit"]?.(code);
9466      ABORT = true;
9467    }
9468    quit_(code, new ExitStatus(code));
9469  };
9470  var exitJS = (status, implicit) => {
9471    EXITSTATUS = status;
9472    _proc_exit(status);
9473  };
9474  var _exit = exitJS;
9475  var maybeExit = () => {
9476    if (!keepRuntimeAlive()) {
9477      try {
9478        _exit(EXITSTATUS);
9479      } catch (e) {
9480        handleException(e);
9481      }
9482    }
9483  };
9484  var callUserCallback = func => {
9485    if (ABORT) {
9486      return;
9487    }
9488    try {
9489      return func();
9490    } catch (e) {
9491      handleException(e);
9492    } finally {
9493      maybeExit();
9494    }
9495  };
9496  var _emscripten_get_now = () => performance.now();
9497  var __setitimer_js = (which, timeout_ms) => {
9498    if (timers[which]) {
9499      clearTimeout(timers[which].id);
9500      delete timers[which];
9501    }
9502    if (!timeout_ms) return 0;
9503    var id = setTimeout(() => {
9504      delete timers[which];
9505      callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now()));
9506    }, timeout_ms);
9507    timers[which] = {
9508      id,
9509      timeout_ms
9510    };
9511    return 0;
9512  };
9513  function _createImageData(size) {
9514    Module.imageData = new Uint8Array(size);
9515  }
9516  var getHeapMax = () => 2147483648;
9517  var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
9518  var growMemory = size => {
9519    var oldHeapSize = wasmMemory.buffer.byteLength;
9520    var pages = (size - oldHeapSize + 65535) / 65536 | 0;
9521    try {
9522      wasmMemory.grow(pages);
9523      updateMemoryViews();
9524      return 1;
9525    } catch (e) {}
9526  };
9527  var _emscripten_resize_heap = requestedSize => {
9528    var oldSize = HEAPU8.length;
9529    requestedSize >>>= 0;
9530    var maxHeapSize = getHeapMax();
9531    if (requestedSize > maxHeapSize) {
9532      return false;
9533    }
9534    for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
9535      var overGrownHeapSize = oldSize * (1 + .2 / cutDown);
9536      overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
9537      var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
9538      var replacement = growMemory(newSize);
9539      if (replacement) {
9540        return true;
9541      }
9542    }
9543    return false;
9544  };
9545  function _setImageData(array_ptr, pitch8, pitch32, height) {
9546    if (pitch32 === pitch8) {
9547      Module.imageData = new Uint8ClampedArray(HEAPU8.subarray(array_ptr, array_ptr + pitch32 * height));
9548      return;
9549    }
9550    const destSize = pitch8 * height;
9551    const imageData = Module.imageData = new Uint8ClampedArray(destSize);
9552    for (let srcStart = array_ptr, destStart = 0; destStart < destSize; srcStart += pitch32, destStart += pitch8) {
9553      imageData.set(HEAPU8.subarray(srcStart, srcStart + pitch8), destStart);
9554    }
9555  }
9556  function _setLineData(line_ptr, pitch8, offset) {
9557    Module.imageData.set(HEAPU8.subarray(line_ptr, line_ptr + pitch8), offset);
9558  }
9559  var writeArrayToMemory = (array, buffer) => {
9560    HEAP8.set(array, buffer);
9561  };
9562  if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
9563  if (Module["print"]) out = Module["print"];
9564  if (Module["printErr"]) err = Module["printErr"];
9565  if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
9566  if (Module["arguments"]) arguments_ = Module["arguments"];
9567  if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
9568  if (Module["preInit"]) {
9569    if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
9570    while (Module["preInit"].length > 0) {
9571      Module["preInit"].shift()();
9572    }
9573  }
9574  Module["writeArrayToMemory"] = writeArrayToMemory;
9575  var _malloc, _free, _jbig2_decode, _ccitt_decode, __emscripten_timeout, memory, __indirect_function_table, wasmMemory;
9576  function assignWasmExports(wasmExports) {
9577    _malloc = Module["_malloc"] = wasmExports["k"];
9578    _free = Module["_free"] = wasmExports["l"];
9579    _jbig2_decode = Module["_jbig2_decode"] = wasmExports["m"];
9580    _ccitt_decode = Module["_ccitt_decode"] = wasmExports["n"];
9581    __emscripten_timeout = wasmExports["o"];
9582    memory = wasmMemory = wasmExports["i"];
9583    __indirect_function_table = wasmExports["__indirect_function_table"];
9584  }
9585  var wasmImports = {
9586    e: __abort_js,
9587    b: __emscripten_runtime_keepalive_clear,
9588    c: __setitimer_js,
9589    g: _createImageData,
9590    d: _emscripten_resize_heap,
9591    a: _proc_exit,
9592    h: _setImageData,
9593    f: _setLineData
9594  };
9595  function run() {
9596    preRun();
9597    function doRun() {
9598      Module["calledRun"] = true;
9599      if (ABORT) return;
9600      initRuntime();
9601      readyPromiseResolve?.(Module);
9602      Module["onRuntimeInitialized"]?.();
9603      postRun();
9604    }
9605    if (Module["setStatus"]) {
9606      Module["setStatus"]("Running...");
9607      setTimeout(() => {
9608        setTimeout(() => Module["setStatus"](""), 1);
9609        doRun();
9610      }, 1);
9611    } else {
9612      doRun();
9613    }
9614  }
9615  var wasmExports;
9616  wasmExports = await createWasm();
9617  run();
9618  if (runtimeInitialized) {
9619    moduleRtn = Module;
9620  } else {
9621    moduleRtn = new Promise((resolve, reject) => {
9622      readyPromiseResolve = resolve;
9623      readyPromiseReject = reject;
9624    });
9625  }
9626  return moduleRtn;
9627}
9628/* harmony default export */ const jbig2 = (JBig2);
9629;// ./src/core/wasm_image.js
9630
9631
9632class WasmImage {
9633  static #handler = null;
9634  static #instances = new Set();
9635  static #useWasm = true;
9636  static #useWorkerFetch = true;
9637  static #wasmUrl = null;
9638  #buffer = null;
9639  #modulePromise = null;
9640  _filename = null;
9641  _noWasmFilename = null;
9642  static setOptions({
9643    handler,
9644    useWasm,
9645    useWorkerFetch,
9646    wasmUrl
9647  }) {
9648    WasmImage.#useWasm = useWasm;
9649    WasmImage.#useWorkerFetch = useWorkerFetch;
9650    WasmImage.#wasmUrl = wasmUrl;
9651    if (!useWorkerFetch) {
9652      WasmImage.#handler = handler;
9653    }
9654  }
9655  static get instance() {
9656    unreachable("Abstract getter `instance` accessed");
9657  }
9658  static cleanup() {
9659    for (const instance of WasmImage.#instances) {
9660      instance.#modulePromise = null;
9661    }
9662  }
9663  constructor(trackInstance = false) {
9664    if (trackInstance) {
9665      WasmImage.#instances.add(this);
9666    }
9667  }
9668  async #getJsModule(fallbackCallback) {
9669    let instance = null;
9670    try {
9671      const mod = await import(
9672      /*webpackIgnore: true*/
9673      /*@vite-ignore*/
9674      `${WasmImage.#wasmUrl}${this._noWasmFilename}`);
9675      instance = mod.default();
9676    } catch (ex) {
9677      warn(`#getJsModule: ${ex}`);
9678    }
9679    fallbackCallback(instance);
9680  }
9681  async #instantiateWasm(fallbackCallback, imports, successCallback) {
9682    try {
9683      if (!this.#buffer) {
9684        if (WasmImage.#useWorkerFetch) {
9685          this.#buffer = await fetchBinaryData(`${WasmImage.#wasmUrl}${this._filename}`);
9686        } else {
9687          this.#buffer = await WasmImage.#handler.sendWithPromise("FetchBinaryData", {
9688            kind: "wasmUrl",
9689            filename: this._filename
9690          });
9691        }
9692      }
9693      const results = await WebAssembly.instantiate(this.#buffer, imports);
9694      return successCallback(results.instance);
9695    } catch (ex) {
9696      warn(`#instantiateWasm: ${ex}`);
9697      this.#getJsModule(fallbackCallback);
9698      return null;
9699    }
9700  }
9701  _getModule(ImageDecoder) {
9702    if (!this.#modulePromise) {
9703      const {
9704        promise,
9705        resolve
9706      } = Promise.withResolvers();
9707      const promises = [promise];
9708      if (!WasmImage.#useWasm) {
9709        this.#getJsModule(resolve);
9710      } else {
9711        promises.push(ImageDecoder({
9712          warn: warn,
9713          instantiateWasm: this.#instantiateWasm.bind(this, resolve)
9714        }));
9715      }
9716      this.#modulePromise = Promise.race(promises);
9717    }
9718    return this.#modulePromise;
9719  }
9720  async decode(bytes, _params) {
9721    unreachable("Abstract method `decode` called");
9722  }
9723}
9724
9725;// ./src/core/jbig2_ccittFax.js
9726
9727
9728
9729class Jbig2Error extends BaseException {
9730  constructor(msg) {
9731    super(msg, "Jbig2Error");
9732  }
9733}
9734class JBig2CCITTFaxImage extends WasmImage {
9735  _filename = "jbig2.wasm";
9736  _noWasmFilename = "jbig2_nowasm_fallback.js";
9737  static get instance() {
9738    return shadow(this, "instance", new JBig2CCITTFaxImage(true));
9739  }
9740  async decode(bytes, width, height, globals, CCITTOptions) {
9741    const module = await this._getModule(jbig2);
9742    if (!module) {
9743      throw new Jbig2Error("JBig2 failed to initialize");
9744    }
9745    let ptr, globalsPtr;
9746    try {
9747      const size = bytes.length;
9748      ptr = module._malloc(size);
9749      module.writeArrayToMemory(bytes, ptr);
9750      if (CCITTOptions) {
9751        module._ccitt_decode(ptr, size, width, height, CCITTOptions.K, CCITTOptions.EndOfLine ? 1 : 0, CCITTOptions.EncodedByteAlign ? 1 : 0, CCITTOptions.BlackIs1 ? 1 : 0, CCITTOptions.Columns, CCITTOptions.Rows);
9752      } else {
9753        const globalsSize = globals ? globals.length : 0;
9754        if (globalsSize > 0) {
9755          globalsPtr = module._malloc(globalsSize);
9756          module.writeArrayToMemory(globals, globalsPtr);
9757        }
9758        module._jbig2_decode(ptr, size, width, height, globalsPtr, globalsSize);
9759      }
9760      if (!module.imageData) {
9761        throw new Jbig2Error("Unknown error");
9762      }
9763      const {
9764        imageData
9765      } = module;
9766      module.imageData = null;
9767      return imageData;
9768    } finally {
9769      if (ptr) {
9770        module._free(ptr);
9771      }
9772      if (globalsPtr) {
9773        module._free(globalsPtr);
9774      }
9775    }
9776  }
9777}
9778
9779;// ./src/core/ccitt_stream.js
9780
9781
9782
9783
9784class CCITTFaxStream extends DecodeStream {
9785  constructor(str, maybeLength, params) {
9786    super(maybeLength);
9787    this.stream = str;
9788    this.maybeLength = maybeLength;
9789    this.dict = str.dict;
9790    if (!(params instanceof Dict)) {
9791      params = Dict.empty;
9792    }
9793    this.params = {
9794      K: params.get("K") || 0,
9795      EndOfLine: !!params.get("EndOfLine"),
9796      EncodedByteAlign: !!params.get("EncodedByteAlign"),
9797      Columns: params.get("Columns") || 1728,
9798      Rows: params.get("Rows") || 0,
9799      EndOfBlock: !!(params.get("EndOfBlock") ?? true),
9800      BlackIs1: !!params.get("BlackIs1")
9801    };
9802  }
9803  get bytes() {
9804    return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
9805  }
9806  get isImageStream() {
9807    return true;
9808  }
9809  get isAsyncDecoder() {
9810    return true;
9811  }
9812  async decodeImage(bytes, length, _decoderOptions) {
9813    if (this.eof) {
9814      return this.buffer;
9815    }
9816    
9816if (!bytes) {
9817      bytes = this.stream.isAsync ? (await this.stream.asyncGetBytes()) || this.bytes : this.bytes;
9818    }
vendor: 36,758 bytes, lines 9818-10871
9818
9819    this.buffer = await JBig2CCITTFaxImage.instance.decode(bytes, this.dict.get("W", "Width"), this.dict.get("H", "Height"), null, this.params);
9820    this.bufferLength = this.buffer.length;
9821    this.eof = true;
9822    return this.buffer;
9823  }
9824}
9825
9826;// ./src/core/flate_stream.js
9827
9828
9829
9830const codeLenCodeMap = new Int32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
9831const lengthDecode = new Int32Array([0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a, 0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f, 0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073, 0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102]);
9832const distDecode = new Int32Array([0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d, 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1, 0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01, 0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001]);
9833const fixedLitCodeTab = [new Int32Array([0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0, 0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0, 0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0, 0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8, 0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8, 0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8, 0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4, 0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4, 0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4, 0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc, 0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec, 0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc, 0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2, 0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2, 0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2, 0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca, 0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea, 0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da, 0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6, 0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6, 0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6, 0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce, 0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee, 0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de, 0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe, 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1, 0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1, 0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1, 0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9, 0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9, 0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9, 0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5, 0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5, 0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5, 0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd, 0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed, 0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd, 0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3, 0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3, 0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3, 0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb, 0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb, 0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db, 0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7, 0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7, 0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7, 0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf, 0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef, 0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df, 0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff]), 9];
9834const fixedDistCodeTab = [new Int32Array([0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c, 0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000, 0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d, 0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000]), 5];
9835class FlateStream extends DecodeStream {
9836  #isAsync = true;
9837  constructor(str, maybeLength) {
9838    super(maybeLength);
9839    this.stream = str;
9840    this.dict = str.dict;
9841    const cmf = str.getByte();
9842    const flg = str.getByte();
9843    if (cmf === -1 || flg === -1) {
9844      throw new FormatError(`Invalid header in flate stream: ${cmf}, ${flg}`);
9845    }
9846    if ((cmf & 0x0f) !== 0x08) {
9847      throw new FormatError(`Unknown compression method in flate stream: ${cmf}, ${flg}`);
9848    }
9849    if (((cmf << 8) + flg) % 31 !== 0) {
9850      throw new FormatError(`Bad FCHECK in flate stream: ${cmf}, ${flg}`);
9851    }
9852    if (flg & 0x20) {
9853      throw new FormatError(`FDICT bit set in flate stream: ${cmf}, ${flg}`);
9854    }
9855    this.codeSize = 0;
9856    this.codeBuf = 0;
9857  }
9858  async getImageData(length, _decoderOptions) {
9859    const data = await this.asyncGetBytes();
9860    if (!data) {
9861      return this.getBytes(length);
9862    }
9863    if (data.length <= length) {
9864      return data;
9865    }
9866    return data.subarray(0, length);
9867  }
9868  async asyncGetBytes() {
9869    const {
9870      decompressed,
9871      compressed
9872    } = await this.asyncGetBytesFromDecompressionStream("deflate");
9873    if (decompressed) {
9874      return decompressed;
9875    }
9876    this.#isAsync = false;
9877    this.stream = new Stream(compressed, 2, compressed.length, this.stream.dict);
9878    this.reset();
9879    return null;
9880  }
9881  get isAsync() {
9882    return this.#isAsync;
9883  }
9884  getBits(bits) {
9885    const str = this.stream;
9886    let codeSize = this.codeSize;
9887    let codeBuf = this.codeBuf;
9888    let b;
9889    while (codeSize < bits) {
9890      if ((b = str.getByte()) === -1) {
9891        throw new FormatError("Bad encoding in flate stream");
9892      }
9893      codeBuf |= b << codeSize;
9894      codeSize += 8;
9895    }
9896    b = codeBuf & (1 << bits) - 1;
9897    this.codeBuf = codeBuf >> bits;
9898    this.codeSize = codeSize -= bits;
9899    return b;
9900  }
9901  getCode(table) {
9902    const str = this.stream;
9903    const codes = table[0];
9904    const maxLen = table[1];
9905    let codeSize = this.codeSize;
9906    let codeBuf = this.codeBuf;
9907    let b;
9908    while (codeSize < maxLen) {
9909      if ((b = str.getByte()) === -1) {
9910        break;
9911      }
9912      codeBuf |= b << codeSize;
9913      codeSize += 8;
9914    }
9915    const code = codes[codeBuf & (1 << maxLen) - 1];
9916    const codeLen = code >> 16;
9917    const codeVal = code & 0xffff;
9918    if (codeLen < 1 || codeSize < codeLen) {
9919      throw new FormatError("Bad encoding in flate stream");
9920    }
9921    this.codeBuf = codeBuf >> codeLen;
9922    this.codeSize = codeSize - codeLen;
9923    return codeVal;
9924  }
9925  generateHuffmanTable(lengths) {
9926    const n = lengths.length;
9927    let maxLen = 0;
9928    let i;
9929    for (i = 0; i < n; ++i) {
9930      if (lengths[i] > maxLen) {
9931        maxLen = lengths[i];
9932      }
9933    }
9934    const size = 1 << maxLen;
9935    const codes = new Int32Array(size);
9936    for (let len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
9937      for (let val = 0; val < n; ++val) {
9938        if (lengths[val] === len) {
9939          let code2 = 0;
9940          let t = code;
9941          for (i = 0; i < len; ++i) {
9942            code2 = code2 << 1 | t & 1;
9943            t >>= 1;
9944          }
9945          for (i = code2; i < size; i += skip) {
9946            codes[i] = len << 16 | val;
9947          }
9948          ++code;
9949        }
9950      }
9951    }
9952    return [codes, maxLen];
9953  }
9954  #endsStreamOnError(err) {
9955    info(err);
9956    this.eof = true;
9957  }
9958  readBlock() {
9959    let buffer, hdr, len;
9960    const str = this.stream;
9961    try {
9962      hdr = this.getBits(3);
9963    } catch (ex) {
9964      this.#endsStreamOnError(ex.message);
9965      return;
9966    }
9967    if (hdr & 1) {
9968      this.eof = true;
9969    }
9970    hdr >>= 1;
9971    if (hdr === 0) {
9972      let b;
9973      if ((b = str.getByte()) === -1) {
9974        this.#endsStreamOnError("Bad block header in flate stream");
9975        return;
9976      }
9977      let blockLen = b;
9978      if ((b = str.getByte()) === -1) {
9979        this.#endsStreamOnError("Bad block header in flate stream");
9980        return;
9981      }
9982      blockLen |= b << 8;
9983      if ((b = str.getByte()) === -1) {
9984        this.#endsStreamOnError("Bad block header in flate stream");
9985        return;
9986      }
9987      let check = b;
9988      if ((b = str.getByte()) === -1) {
9989        this.#endsStreamOnError("Bad block header in flate stream");
9990        return;
9991      }
9992      check |= b << 8;
9993      if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
9994        throw new FormatError("Bad uncompressed block length in flate stream");
9995      }
9996      this.codeBuf = 0;
9997      this.codeSize = 0;
9998      const bufferLength = this.bufferLength,
9999        end = bufferLength + blockLen;
10000      buffer = this.ensureBuffer(end);
10001      this.bufferLength = end;
10002      if (blockLen === 0) {
10003        if (str.peekByte() === -1) {
10004          this.eof = true;
10005        }
10006      } else {
10007        const block = str.getBytes(blockLen);
10008        buffer.set(block, bufferLength);
10009        if (block.length < blockLen) {
10010          this.eof = true;
10011        }
10012      }
10013      return;
10014    }
10015    let litCodeTable;
10016    let distCodeTable;
10017    if (hdr === 1) {
10018      litCodeTable = fixedLitCodeTab;
10019      distCodeTable = fixedDistCodeTab;
10020    } else if (hdr === 2) {
10021      const numLitCodes = this.getBits(5) + 257;
10022      const numDistCodes = this.getBits(5) + 1;
10023      const numCodeLenCodes = this.getBits(4) + 4;
10024      const codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
10025      let i;
10026      for (i = 0; i < numCodeLenCodes; ++i) {
10027        codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
10028      }
10029      const codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
10030      len = 0;
10031      i = 0;
10032      const codes = numLitCodes + numDistCodes;
10033      const codeLengths = new Uint8Array(codes);
10034      let bitsLength, bitsOffset, what;
10035      while (i < codes) {
10036        const code = this.getCode(codeLenCodeTab);
10037        if (code === 16) {
10038          bitsLength = 2;
10039          bitsOffset = 3;
10040          what = len;
10041        } else if (code === 17) {
10042          bitsLength = 3;
10043          bitsOffset = 3;
10044          what = len = 0;
10045        } else if (code === 18) {
10046          bitsLength = 7;
10047          bitsOffset = 11;
10048          what = len = 0;
10049        } else {
10050          codeLengths[i++] = len = code;
10051          continue;
10052        }
10053        let repeatLength = this.getBits(bitsLength) + bitsOffset;
10054        while (repeatLength-- > 0) {
10055          codeLengths[i++] = what;
10056        }
10057      }
10058      litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
10059      distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
10060    } else {
10061      throw new FormatError("Unknown block type in flate stream");
10062    }
10063    buffer = this.buffer;
10064    let limit = buffer ? buffer.length : 0;
10065    let pos = this.bufferLength;
10066    while (true) {
10067      let code1 = this.getCode(litCodeTable);
10068      if (code1 < 256) {
10069        if (pos + 1 >= limit) {
10070          buffer = this.ensureBuffer(pos + 1);
10071          limit = buffer.length;
10072        }
10073        buffer[pos++] = code1;
10074        continue;
10075      }
10076      if (code1 === 256) {
10077        this.bufferLength = pos;
10078        return;
10079      }
10080      code1 -= 257;
10081      code1 = lengthDecode[code1];
10082      let code2 = code1 >> 16;
10083      if (code2 > 0) {
10084        code2 = this.getBits(code2);
10085      }
10086      len = (code1 & 0xffff) + code2;
10087      code1 = this.getCode(distCodeTable);
10088      code1 = distDecode[code1];
10089      code2 = code1 >> 16;
10090      if (code2 > 0) {
10091        code2 = this.getBits(code2);
10092      }
10093      const dist = (code1 & 0xffff) + code2;
10094      if (pos + len >= limit) {
10095        buffer = this.ensureBuffer(pos + len);
10096        limit = buffer.length;
10097      }
10098      for (let k = 0; k < len; ++k, ++pos) {
10099        buffer[pos] = buffer[pos - dist];
10100      }
10101    }
10102  }
10103}
10104
10105;// ./src/core/jbig2_stream.js
10106
10107
10108
10109
10110
10111class Jbig2Stream extends DecodeStream {
10112  constructor(stream, maybeLength, params) {
10113    super(maybeLength);
10114    this.stream = stream;
10115    this.dict = stream.dict;
10116    this.maybeLength = maybeLength;
10117    this.params = params;
10118  }
10119  get bytes() {
10120    return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
10121  }
10122  ensureBuffer(requested) {}
10123  get isAsyncDecoder() {
10124    return true;
10125  }
10126  get isImageStream() {
10127    return true;
10128  }
10129  static stripFileHeader(bytes) {
10130    if (bytes.length >= 9 && bytes[0] === 0x97 && bytes[1] === 0x4a && bytes[2] === 0x42 && bytes[3] === 0x32 && bytes[4] === 0x0d && bytes[5] === 0x0a && bytes[6] === 0x1a && bytes[7] === 0x0a) {
10131      const headerLength = (bytes[8] & 2) === 0 ? 13 : 9;
10132      return bytes.subarray(headerLength);
10133    }
10134    return bytes;
10135  }
10136  async decodeImage(bytes, length, _decoderOptions) {
10137    if (this.eof) {
10138      return this.buffer;
10139    }
10140    bytes = Jbig2Stream.stripFileHeader(bytes || this.bytes);
10141    let globals = null;
10142    if (this.params instanceof Dict) {
10143      const globalsStream = this.params.get("JBIG2Globals");
10144      if (globalsStream instanceof BaseStream) {
10145        globals = Jbig2Stream.stripFileHeader(globalsStream.getBytes());
10146      }
10147    }
10148    this.buffer = await JBig2CCITTFaxImage.instance.decode(bytes, this.dict.get("Width"), this.dict.get("Height"), globals);
10149    this.bufferLength = this.buffer.length;
10150    this.eof = true;
10151    return this.buffer;
10152  }
10153  get canAsyncDecodeImageFromBuffer() {
10154    return this.stream.isAsync;
10155  }
10156}
10157
10158;// ./external/openjpeg/openjpeg.js
10159async function OpenJPEG(moduleArg = {}) {
10160  var moduleRtn;
10161  var Module = moduleArg;
10162  var ENVIRONMENT_IS_WEB = true;
10163  var ENVIRONMENT_IS_WORKER = false;
10164  var arguments_ = [];
10165  var thisProgram = "./this.program";
10166  var quit_ = (status, toThrow) => {
10167    throw toThrow;
10168  };
10169  var _scriptName = import.meta.url;
10170  var scriptDirectory = "";
10171  var readAsync, readBinary;
10172  if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
10173    try {
10174      scriptDirectory = new URL(".", _scriptName).href;
10175    } catch {}
10176    readAsync = async url => {
10177      var response = await fetch(url, {
10178        credentials: "same-origin"
10179      });
10180      if (response.ok) {
10181        return response.arrayBuffer();
10182      }
10183      throw new Error(response.status + " : " + response.url);
10184    };
10185  } else {}
10186  var out = console.log.bind(console);
10187  var err = console.error.bind(console);
10188  var wasmBinary;
10189  var ABORT = false;
10190  var EXITSTATUS;
10191  class EmscriptenEH {}
10192  class EmscriptenSjLj extends EmscriptenEH {}
10193  var readyPromiseResolve, readyPromiseReject;
10194  var runtimeInitialized = false;
10195  function updateMemoryViews() {
10196    var b = wasmMemory.buffer;
10197    HEAP8 = new Int8Array(b);
10198    HEAP16 = new Int16Array(b);
10199    HEAPU8 = new Uint8Array(b);
10200    HEAPU16 = new Uint16Array(b);
10201    HEAP32 = new Int32Array(b);
10202    HEAPU32 = new Uint32Array(b);
10203    HEAPF32 = new Float32Array(b);
10204    HEAPF64 = new Float64Array(b);
10205    HEAP64 = new BigInt64Array(b);
10206    HEAPU64 = new BigUint64Array(b);
10207  }
10208  function preRun() {
10209    if (Module["preRun"]) {
10210      if (typeof Module["preRun"] == "function") Module["preRun"] = [Module["preRun"]];
10211      while (Module["preRun"].length) {
10212        addOnPreRun(Module["preRun"].shift());
10213      }
10214    }
10215    callRuntimeCallbacks(onPreRuns);
10216  }
10217  function initRuntime() {
10218    runtimeInitialized = true;
10219    wasmExports["s"]();
10220  }
10221  function postRun() {
10222    if (Module["postRun"]) {
10223      if (typeof Module["postRun"] == "function") Module["postRun"] = [Module["postRun"]];
10224      while (Module["postRun"].length) {
10225        addOnPostRun(Module["postRun"].shift());
10226      }
10227    }
10228    callRuntimeCallbacks(onPostRuns);
10229  }
10230  function abort(what) {
10231    Module["onAbort"]?.(what);
10232    what = `Aborted(${what})`;
10233    err(what);
10234    ABORT = true;
10235    what += ". Build with -sASSERTIONS for more info.";
10236    var e = new WebAssembly.RuntimeError(what);
10237    readyPromiseReject?.(e);
10238    throw e;
10239  }
10240  var wasmBinaryFile;
10241  function getWasmImports() {
10242    var imports = {
10243      a: wasmImports
10244    };
10245    return imports;
10246  }
10247  async function createWasm() {
10248    function receiveInstance(instance, module) {
10249      wasmExports = instance.exports;
10250      assignWasmExports(wasmExports);
10251      updateMemoryViews();
10252      return wasmExports;
10253    }
10254    var info = getWasmImports();
10255    return new Promise((resolve, reject) => {
10256      Module["instantiateWasm"](info, (inst, mod) => {
10257        resolve(receiveInstance(inst, mod));
10258      });
10259    });
10260  }
10261  class ExitStatus {
10262    name = "ExitStatus";
10263    constructor(status) {
10264      this.message = `Program terminated with exit(${status})`;
10265      this.status = status;
10266    }
10267  }
10268  var HEAP16;
10269  var HEAP32;
10270  var HEAP64;
10271  var HEAP8;
10272  var HEAPF32;
10273  var HEAPF64;
10274  var HEAPU16;
10275  var HEAPU32;
10276  var HEAPU64;
10277  var HEAPU8;
10278  var callRuntimeCallbacks = callbacks => {
10279    while (callbacks.length > 0) {
10280      callbacks.shift()(Module);
10281    }
10282  };
10283  var onPostRuns = [];
10284  var addOnPostRun = cb => onPostRuns.push(cb);
10285  var onPreRuns = [];
10286  var addOnPreRun = cb => onPreRuns.push(cb);
10287  var noExitRuntime = true;
10288  var __abort_js = () => abort("");
10289  var runtimeKeepaliveCounter = 0;
10290  var __emscripten_runtime_keepalive_clear = () => {
10291    noExitRuntime = false;
10292    runtimeKeepaliveCounter = 0;
10293  };
10294  var timers = {};
10295  var handleException = e => {
10296    if (e instanceof ExitStatus || e == "unwind") {
10297      return EXITSTATUS;
10298    }
10299    quit_(1, e);
10300  };
10301  var keepRuntimeAlive = () => noExitRuntime || runtimeKeepaliveCounter > 0;
10302  var _proc_exit = code => {
10303    EXITSTATUS = code;
10304    if (!keepRuntimeAlive()) {
10305      Module["onExit"]?.(code);
10306      ABORT = true;
10307    }
10308    quit_(code, new ExitStatus(code));
10309  };
10310  var exitJS = (status, implicit) => {
10311    EXITSTATUS = status;
10312    _proc_exit(status);
10313  };
10314  var _exit = exitJS;
10315  var maybeExit = () => {
10316    if (!keepRuntimeAlive()) {
10317      try {
10318        _exit(EXITSTATUS);
10319      } catch (e) {
10320        handleException(e);
10321      }
10322    }
10323  };
10324  var callUserCallback = func => {
10325    if (ABORT) {
10326      return;
10327    }
10328    try {
10329      return func();
10330    } catch (e) {
10331      handleException(e);
10332    } finally {
10333      maybeExit();
10334    }
10335  };
10336  var _emscripten_get_now = () => performance.now();
10337  var __setitimer_js = (which, timeout_ms) => {
10338    if (timers[which]) {
10339      clearTimeout(timers[which].id);
10340      delete timers[which];
10341    }
10342    if (!timeout_ms) return 0;
10343    var id = setTimeout(() => {
10344      delete timers[which];
10345      callUserCallback(() => __emscripten_timeout(which, _emscripten_get_now()));
10346    }, timeout_ms);
10347    timers[which] = {
10348      id,
10349      timeout_ms
10350    };
10351    return 0;
10352  };
10353  function _copy_pixels_1(compG_ptr, nb_pixels) {
10354    compG_ptr >>= 2;
10355    const imageData = Module.imageData = new Uint8ClampedArray(nb_pixels);
10356    const compG = HEAP32.subarray(compG_ptr, compG_ptr + nb_pixels);
10357    imageData.set(compG);
10358  }
10359  function _copy_pixels_3(compR_ptr, compG_ptr, compB_ptr, nb_pixels) {
10360    compR_ptr >>= 2;
10361    compG_ptr >>= 2;
10362    compB_ptr >>= 2;
10363    const imageData = Module.imageData = new Uint8ClampedArray(nb_pixels * 3);
10364    const compR = HEAP32.subarray(compR_ptr, compR_ptr + nb_pixels);
10365    const compG = HEAP32.subarray(compG_ptr, compG_ptr + nb_pixels);
10366    const compB = HEAP32.subarray(compB_ptr, compB_ptr + nb_pixels);
10367    for (let i = 0; i < nb_pixels; i++) {
10368      imageData[3 * i] = compR[i];
10369      imageData[3 * i + 1] = compG[i];
10370      imageData[3 * i + 2] = compB[i];
10371    }
10372  }
10373  function _copy_pixels_4(compR_ptr, compG_ptr, compB_ptr, compA_ptr, nb_pixels) {
10374    compR_ptr >>= 2;
10375    compG_ptr >>= 2;
10376    compB_ptr >>= 2;
10377    compA_ptr >>= 2;
10378    const imageData = Module.imageData = new Uint8ClampedArray(nb_pixels * 4);
10379    const compR = HEAP32.subarray(compR_ptr, compR_ptr + nb_pixels);
10380    const compG = HEAP32.subarray(compG_ptr, compG_ptr + nb_pixels);
10381    const compB = HEAP32.subarray(compB_ptr, compB_ptr + nb_pixels);
10382    const compA = HEAP32.subarray(compA_ptr, compA_ptr + nb_pixels);
10383    for (let i = 0; i < nb_pixels; i++) {
10384      imageData[4 * i] = compR[i];
10385      imageData[4 * i + 1] = compG[i];
10386      imageData[4 * i + 2] = compB[i];
10387      imageData[4 * i + 3] = compA[i];
10388    }
10389  }
10390  var getHeapMax = () => 2147483648;
10391  var alignMemory = (size, alignment) => Math.ceil(size / alignment) * alignment;
10392  var growMemory = size => {
10393    var oldHeapSize = wasmMemory.buffer.byteLength;
10394    var pages = (size - oldHeapSize + 65535) / 65536 | 0;
10395    try {
10396      wasmMemory.grow(pages);
10397      updateMemoryViews();
10398      return 1;
10399    } catch (e) {}
10400  };
10401  var _emscripten_resize_heap = requestedSize => {
10402    var oldSize = HEAPU8.length;
10403    requestedSize >>>= 0;
10404    var maxHeapSize = getHeapMax();
10405    if (requestedSize > maxHeapSize) {
10406      return false;
10407    }
10408    for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
10409      var overGrownHeapSize = oldSize * (1 + .2 / cutDown);
10410      overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
10411      var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
10412      var replacement = growMemory(newSize);
10413      if (replacement) {
10414        return true;
10415      }
10416    }
10417    return false;
10418  };
10419  var ENV = {};
10420  var getExecutableName = () => thisProgram || "./this.program";
10421  var getEnvStrings = () => {
10422    if (!getEnvStrings.strings) {
10423      var lang = (globalThis.navigator?.language ?? "C").replace("-", "_") + ".UTF-8";
10424      var env = {
10425        USER: "web_user",
10426        LOGNAME: "web_user",
10427        PATH: "/",
10428        PWD: "/",
10429        HOME: "/home/web_user",
10430        LANG: lang,
10431        _: getExecutableName()
10432      };
10433      for (var x in ENV) {
10434        if (ENV[x] === undefined) delete env[x];else env[x] = ENV[x];
10435      }
10436      var strings = [];
10437      for (var x in env) {
10438        strings.push(`${x}=${env[x]}`);
10439      }
10440      getEnvStrings.strings = strings;
10441    }
10442    return getEnvStrings.strings;
10443  };
10444  var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
10445    if (!(maxBytesToWrite > 0)) return 0;
10446    var startIdx = outIdx;
10447    var endIdx = outIdx + maxBytesToWrite - 1;
10448    for (var i = 0; i < str.length; ++i) {
10449      var u = str.codePointAt(i);
10450      if (u <= 127) {
10451        if (outIdx >= endIdx) break;
10452        heap[outIdx++] = u;
10453      } else if (u <= 2047) {
10454        if (outIdx + 1 >= endIdx) break;
10455        heap[outIdx++] = 192 | u >> 6;
10456        heap[outIdx++] = 128 | u & 63;
10457      } else if (u <= 65535) {
10458        if (outIdx + 2 >= endIdx) break;
10459        heap[outIdx++] = 224 | u >> 12;
10460        heap[outIdx++] = 128 | u >> 6 & 63;
10461        heap[outIdx++] = 128 | u & 63;
10462      } else {
10463        if (outIdx + 3 >= endIdx) break;
10464        heap[outIdx++] = 240 | u >> 18;
10465        heap[outIdx++] = 128 | u >> 12 & 63;
10466        heap[outIdx++] = 128 | u >> 6 & 63;
10467        heap[outIdx++] = 128 | u & 63;
10468        i++;
10469      }
10470    }
10471    heap[outIdx] = 0;
10472    return outIdx - startIdx;
10473  };
10474  var stringToUTF8 = (str, outPtr, maxBytesToWrite) => stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
10475  var _environ_get = (__environ, environ_buf) => {
10476    var bufSize = 0;
10477    var envp = 0;
10478    for (var string of getEnvStrings()) {
10479      var ptr = environ_buf + bufSize;
10480      HEAPU32[__environ + envp >> 2] = ptr;
10481      bufSize += stringToUTF8(string, ptr, Infinity) + 1;
10482      envp += 4;
10483    }
10484    return 0;
10485  };
10486  var lengthBytesUTF8 = str => {
10487    var len = 0;
10488    for (var i = 0; i < str.length; ++i) {
10489      var c = str.charCodeAt(i);
10490      if (c <= 127) {
10491        len++;
10492      } else if (c <= 2047) {
10493        len += 2;
10494      } else if (c >= 55296 && c <= 57343) {
10495        len += 4;
10496        ++i;
10497      } else {
10498        len += 3;
10499      }
10500    }
10501    return len;
10502  };
10503  var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
10504    var strings = getEnvStrings();
10505    HEAPU32[penviron_count >> 2] = strings.length;
10506    var bufSize = 0;
10507    for (var string of strings) {
10508      bufSize += lengthBytesUTF8(string) + 1;
10509    }
10510    HEAPU32[penviron_buf_size >> 2] = bufSize;
10511    return 0;
10512  };
10513  var INT53_MAX = 9007199254740992;
10514  var INT53_MIN = -9007199254740992;
10515  var bigintToI53Checked = num => num < INT53_MIN || num > INT53_MAX ? NaN : Number(num);
10516  function _fd_seek(fd, offset, whence, newOffset) {
10517    offset = bigintToI53Checked(offset);
10518    return 70;
10519  }
10520  var printCharBuffers = [null, [], []];
10521  var UTF8Decoder = globalThis.TextDecoder && new TextDecoder();
10522  var findStringEnd = (heapOrArray, idx, maxBytesToRead, ignoreNul) => {
10523    var maxIdx = idx + maxBytesToRead;
10524    if (ignoreNul) return maxIdx;
10525    while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
10526    return idx;
10527  };
10528  var UTF8ArrayToString = (heapOrArray, idx = 0, maxBytesToRead, ignoreNul) => {
10529    var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
10530    if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
10531      return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
10532    }
10533    var str = "";
10534    while (idx < endPtr) {
10535      var u0 = heapOrArray[idx++];
10536      if (!(u0 & 128)) {
10537        str += String.fromCharCode(u0);
10538        continue;
10539      }
10540      var u1 = heapOrArray[idx++] & 63;
10541      if ((u0 & 224) == 192) {
10542        str += String.fromCharCode((u0 & 31) << 6 | u1);
10543        continue;
10544      }
10545      var u2 = heapOrArray[idx++] & 63;
10546      if ((u0 & 240) == 224) {
10547        u0 = (u0 & 15) << 12 | u1 << 6 | u2;
10548      } else {
10549        u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
10550      }
10551      if (u0 < 65536) {
10552        str += String.fromCharCode(u0);
10553      } else {
10554        var ch = u0 - 65536;
10555        str += String.fromCharCode(55296 | ch >> 10, 56320 | ch & 1023);
10556      }
10557    }
10558    return str;
10559  };
10560  var printChar = (stream, curr) => {
10561    var buffer = printCharBuffers[stream];
10562    if (curr === 0 || curr === 10) {
10563      (stream === 1 ? out : err)(UTF8ArrayToString(buffer));
10564      buffer.length = 0;
10565    } else {
10566      buffer.push(curr);
10567    }
10568  };
10569  var UTF8ToString = (ptr, maxBytesToRead, ignoreNul) => ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : "";
10570  var _fd_write = (fd, iov, iovcnt, pnum) => {
10571    var num = 0;
10572    for (var i = 0; i < iovcnt; i++) {
10573      var ptr = HEAPU32[iov >> 2];
10574      var len = HEAPU32[iov + 4 >> 2];
10575      iov += 8;
10576      for (var j = 0; j < len; j++) {
10577        printChar(fd, HEAPU8[ptr + j]);
10578      }
10579      num += len;
10580    }
10581    HEAPU32[pnum >> 2] = num;
10582    return 0;
10583  };
10584  function _gray_to_rgba(compG_ptr, nb_pixels) {
10585    compG_ptr >>= 2;
10586    const imageData = Module.imageData = new Uint8ClampedArray(nb_pixels * 4);
10587    const compG = HEAP32.subarray(compG_ptr, compG_ptr + nb_pixels);
10588    for (let i = 0; i < nb_pixels; i++) {
10589      imageData[4 * i] = imageData[4 * i + 1] = imageData[4 * i + 2] = compG[i];
10590      imageData[4 * i + 3] = 255;
10591    }
10592  }
10593  function _graya_to_rgba(compG_ptr, compA_ptr, nb_pixels) {
10594    compG_ptr >>= 2;
10595    compA_ptr >>= 2;
10596    const imageData = Module.imageData = new Uint8ClampedArray(nb_pixels * 4);
10597    const compG = HEAP32.subarray(compG_ptr, compG_ptr + nb_pixels);
10598    const compA = HEAP32.subarray(compA_ptr, compA_ptr + nb_pixels);
10599    for (let i = 0; i < nb_pixels; i++) {
10600      imageData[4 * i] = imageData[4 * i + 1] = imageData[4 * i + 2] = compG[i];
10601      imageData[4 * i + 3] = compA[i];
10602    }
10603  }
10604  function _jsPrintWarning(message_ptr) {
10605    const message = UTF8ToString(message_ptr);
10606    (Module.warn || console.warn)(`OpenJPEG: ${message}`);
10607  }
10608  function _rgb_to_rgba(compR_ptr, compG_ptr, compB_ptr, nb_pixels) {
10609    compR_ptr >>= 2;
10610    compG_ptr >>= 2;
10611    compB_ptr >>= 2;
10612    const imageData = Module.imageData = new Uint8ClampedArray(nb_pixels * 4);
10613    const compR = HEAP32.subarray(compR_ptr, compR_ptr + nb_pixels);
10614    const compG = HEAP32.subarray(compG_ptr, compG_ptr + nb_pixels);
10615    const compB = HEAP32.subarray(compB_ptr, compB_ptr + nb_pixels);
10616    for (let i = 0; i < nb_pixels; i++) {
10617      imageData[4 * i] = compR[i];
10618      imageData[4 * i + 1] = compG[i];
10619      imageData[4 * i + 2] = compB[i];
10620      imageData[4 * i + 3] = 255;
10621    }
10622  }
10623  function _storeErrorMessage(message_ptr) {
10624    const message = UTF8ToString(message_ptr);
10625    if (!Module.errorMessages) {
10626      Module.errorMessages = message;
10627    } else {
10628      Module.errorMessages += "\n" + message;
10629    }
10630  }
10631  var writeArrayToMemory = (array, buffer) => {
10632    HEAP8.set(array, buffer);
10633  };
10634  if (Module["noExitRuntime"]) noExitRuntime = Module["noExitRuntime"];
10635  if (Module["print"]) out = Module["print"];
10636  if (Module["printErr"]) err = Module["printErr"];
10637  if (Module["wasmBinary"]) wasmBinary = Module["wasmBinary"];
10638  if (Module["arguments"]) arguments_ = Module["arguments"];
10639  if (Module["thisProgram"]) thisProgram = Module["thisProgram"];
10640  if (Module["preInit"]) {
10641    if (typeof Module["preInit"] == "function") Module["preInit"] = [Module["preInit"]];
10642    while (Module["preInit"].length > 0) {
10643      Module["preInit"].shift()();
10644    }
10645  }
10646  Module["writeArrayToMemory"] = writeArrayToMemory;
10647  var _malloc, _free, _jp2_decode, __emscripten_timeout, memory, __indirect_function_table, wasmMemory;
10648  function assignWasmExports(wasmExports) {
10649    _malloc = Module["_malloc"] = wasmExports["t"];
10650    _free = Module["_free"] = wasmExports["u"];
10651    _jp2_decode = Module["_jp2_decode"] = wasmExports["v"];
10652    __emscripten_timeout = wasmExports["w"];
10653    memory = wasmMemory = wasmExports["r"];
10654    __indirect_function_table = wasmExports["__indirect_function_table"];
10655  }
10656  var wasmImports = {
10657    m: __abort_js,
10658    l: __emscripten_runtime_keepalive_clear,
10659    i: __setitimer_js,
10660    f: _copy_pixels_1,
10661    e: _copy_pixels_3,
10662    d: _copy_pixels_4,
10663    j: _emscripten_resize_heap,
10664    o: _environ_get,
10665    p: _environ_sizes_get,
10666    n: _fd_seek,
10667    b: _fd_write,
10668    q: _gray_to_rgba,
10669    h: _graya_to_rgba,
10670    c: _jsPrintWarning,
10671    k: _proc_exit,
10672    g: _rgb_to_rgba,
10673    a: _storeErrorMessage
10674  };
10675  function run() {
10676    preRun();
10677    function doRun() {
10678      Module["calledRun"] = true;
10679      if (ABORT) return;
10680      initRuntime();
10681      readyPromiseResolve?.(Module);
10682      Module["onRuntimeInitialized"]?.();
10683      postRun();
10684    }
10685    if (Module["setStatus"]) {
10686      Module["setStatus"]("Running...");
10687      setTimeout(() => {
10688        setTimeout(() => Module["setStatus"](""), 1);
10689        doRun();
10690      }, 1);
10691    } else {
10692      doRun();
10693    }
10694  }
10695  var wasmExports;
10696  wasmExports = await createWasm();
10697  run();
10698  if (runtimeInitialized) {
10699    moduleRtn = Module;
10700  } else {
10701    moduleRtn = new Promise((resolve, reject) => {
10702      readyPromiseResolve = resolve;
10703      readyPromiseReject = reject;
10704    });
10705  }
10706  return moduleRtn;
10707}
10708/* harmony default export */ const openjpeg = (OpenJPEG);
10709;// ./src/core/jpx.js
10710
10711
10712
10713
10714class JpxError extends BaseException {
10715  constructor(msg) {
10716    super(msg, "JpxError");
10717  }
10718}
10719class JpxImage extends WasmImage {
10720  _filename = "openjpeg.wasm";
10721  _noWasmFilename = "openjpeg_nowasm_fallback.js";
10722  static get instance() {
10723    return shadow(this, "instance", new JpxImage(true));
10724  }
10725  async decode(bytes, {
10726    numComponents = 4,
10727    isIndexedColormap = false,
10728    smaskInData = false,
10729    reducePower = 0
10730  } = {}) {
10731    const module = await this._getModule(openjpeg);
10732    if (!module) {
10733      throw new JpxError("OpenJPEG failed to initialize");
10734    }
10735    let ptr;
10736    try {
10737      const size = bytes.length;
10738      ptr = module._malloc(size);
10739      module.writeArrayToMemory(bytes, ptr);
10740      const ret = module._jp2_decode(ptr, size, numComponents > 0 ? numComponents : 0, !!isIndexedColormap, !!smaskInData, reducePower);
10741      if (ret) {
10742        const {
10743          errorMessages
10744        } = module;
10745        if (errorMessages) {
10746          delete module.errorMessages;
10747          throw new JpxError(errorMessages);
10748        }
10749        throw new JpxError("Unknown error");
10750      }
10751      const {
10752        imageData
10753      } = module;
10754      module.imageData = null;
10755      return imageData;
10756    } finally {
10757      if (ptr) {
10758        module._free(ptr);
10759      }
10760    }
10761  }
10762  static parseImageProperties(stream) {
10763    let newByte = stream.getByte();
10764    while (newByte >= 0) {
10765      const oldByte = newByte;
10766      newByte = stream.getByte();
10767      const code = oldByte << 8 | newByte;
10768      if (code === 0xff51) {
10769        stream.skip(4);
10770        const Xsiz = stream.getInt32() >>> 0;
10771        const Ysiz = stream.getInt32() >>> 0;
10772        const XOsiz = stream.getInt32() >>> 0;
10773        const YOsiz = stream.getInt32() >>> 0;
10774        stream.skip(16);
10775        const Csiz = stream.getUint16();
10776        return {
10777          width: Xsiz - XOsiz,
10778          height: Ysiz - YOsiz,
10779          bitsPerComponent: 8,
10780          componentsCount: Csiz
10781        };
10782      }
10783    }
10784    throw new JpxError("No size marker found in JPX stream");
10785  }
10786}
10787
10788;// ./src/core/jpx_stream.js
10789
10790
10791
10792class JpxStream extends DecodeStream {
10793  constructor(stream, maybeLength) {
10794    super(maybeLength);
10795    this.stream = stream;
10796    this.dict = stream.dict;
10797    this.maybeLength = maybeLength;
10798  }
10799  get bytes() {
10800    return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
10801  }
10802  ensureBuffer(requested) {}
10803  get isAsyncDecoder() {
10804    return true;
10805  }
10806  async decodeImage(bytes, _length, decoderOptions) {
10807    if (this.eof) {
10808      return this.buffer;
10809    }
10810    bytes ||= this.bytes;
10811    this.buffer = await JpxImage.instance.decode(bytes, decoderOptions);
10812    this.bufferLength = this.buffer.length;
10813    this.eof = true;
10814    return this.buffer;
10815  }
10816  get canAsyncDecodeImageFromBuffer() {
10817    return this.stream.isAsync;
10818  }
10819  get isImageStream() {
10820    return true;
10821  }
10822}
10823
10824;// ./src/core/lzw_stream.js
10825
10826class LZWStream extends DecodeStream {
10827  constructor(str, maybeLength, earlyChange) {
10828    super(maybeLength);
10829    this.stream = str;
10830    this.dict = str.dict;
10831    this.cachedData = 0;
10832    this.bitsCached = 0;
10833    const maxLzwDictionarySize = 4096;
10834    const lzwState = {
10835      earlyChange,
10836      codeLength: 9,
10837      nextCode: 258,
10838      dictionaryValues: new Uint8Array(maxLzwDictionarySize),
10839      dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
10840      dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
10841      currentSequence: new Uint8Array(maxLzwDictionarySize),
10842      currentSequenceLength: 0
10843    };
10844    for (let i = 0; i < 256; ++i) {
10845      lzwState.dictionaryValues[i] = i;
10846      lzwState.dictionaryLengths[i] = 1;
10847    }
10848    this.lzwState = lzwState;
10849  }
10850  readBits(n) {
10851    let bitsCached = this.bitsCached;
10852    let cachedData = this.cachedData;
10853    while (bitsCached < n) {
10854      const c = this.stream.getByte();
10855      if (c === -1) {
10856        this.eof = true;
10857        return null;
10858      }
10859      cachedData = cachedData << 8 | c;
10860      bitsCached += 8;
10861    }
10862    this.bitsCached = bitsCached -= n;
10863    this.cachedData = cachedData;
10864    return cachedData >>> bitsCached & (1 << n) - 1;
10865  }
10866  readBlock() {
10867    const blockSize = 512,
10868      decodedSizeDelta = blockSize;
10869    let estimatedDecodedSize = blockSize * 2;
10870    let i, j, q;
10871    const 
10871lzwState = this.lzwState;
10872    if (!lzwState) {
10873      return;
10874    }
vendor: 8,343 bytes, lines 10874-11137
10874
10875    const earlyChange = lzwState.earlyChange;
10876    let nextCode = lzwState.nextCode;
10877    const dictionaryValues = lzwState.dictionaryValues;
10878    const dictionaryLengths = lzwState.dictionaryLengths;
10879    const dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
10880    let codeLength = lzwState.codeLength;
10881    let prevCode = lzwState.prevCode;
10882    const currentSequence = lzwState.currentSequence;
10883    let currentSequenceLength = lzwState.currentSequenceLength;
10884    let decodedLength = 0;
10885    let currentBufferLength = this.bufferLength;
10886    let buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
10887    for (i = 0; i < blockSize; i++) {
10888      const code = this.readBits(codeLength);
10889      const hasPrev = currentSequenceLength > 0;
10890      if (code < 256) {
10891        currentSequence[0] = code;
10892        currentSequenceLength = 1;
10893      } else if (code >= 258) {
10894        if (code < nextCode) {
10895          currentSequenceLength = dictionaryLengths[code];
10896          for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
10897            currentSequence[j] = dictionaryValues[q];
10898            q = dictionaryPrevCodes[q];
10899          }
10900        } else {
10901          currentSequence[currentSequenceLength++] = currentSequence[0];
10902        }
10903      } else if (code === 256) {
10904        codeLength = 9;
10905        nextCode = 258;
10906        currentSequenceLength = 0;
10907        continue;
10908      } else {
10909        this.eof = true;
10910        delete this.lzwState;
10911        break;
10912      }
10913      if (hasPrev) {
10914        dictionaryPrevCodes[nextCode] = prevCode;
10915        dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
10916        dictionaryValues[nextCode] = currentSequence[0];
10917        nextCode++;
10918        codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
10919      }
10920      prevCode = code;
10921      decodedLength += currentSequenceLength;
10922      if (estimatedDecodedSize < decodedLength) {
10923        do {
10924          estimatedDecodedSize += decodedSizeDelta;
10925        } while (estimatedDecodedSize < decodedLength);
10926        buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
10927      }
10928      for (j = 0; j < currentSequenceLength; j++) {
10929        buffer[currentBufferLength++] = currentSequence[j];
10930      }
10931    }
10932    lzwState.nextCode = nextCode;
10933    lzwState.codeLength = codeLength;
10934    lzwState.prevCode = prevCode;
10935    lzwState.currentSequenceLength = currentSequenceLength;
10936    this.bufferLength = currentBufferLength;
10937  }
10938}
10939
10940;// ./src/core/predictor_stream.js
10941
10942
10943
10944class PredictorStream extends DecodeStream {
10945  constructor(str, maybeLength, params) {
10946    super(maybeLength);
10947    if (!(params instanceof Dict)) {
10948      return str;
10949    }
10950    const predictor = this.predictor = params.get("Predictor") || 1;
10951    if (predictor <= 1) {
10952      return str;
10953    }
10954    if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
10955      throw new FormatError(`Unsupported predictor: ${predictor}`);
10956    }
10957    this.readBlock = predictor === 2 ? this.readBlockTiff : this.readBlockPng;
10958    this.stream = str;
10959    this.dict = str.dict;
10960    const colors = this.colors = params.get("Colors") || 1;
10961    const bits = this.bits = params.get("BPC", "BitsPerComponent") || 8;
10962    const columns = this.columns = params.get("Columns") || 1;
10963    this.pixBytes = colors * bits + 7 >> 3;
10964    this.rowBytes = columns * colors * bits + 7 >> 3;
10965    return this;
10966  }
10967  readBlockTiff() {
10968    const rowBytes = this.rowBytes;
10969    const bufferLength = this.bufferLength;
10970    const buffer = this.ensureBuffer(bufferLength + rowBytes);
10971    const bits = this.bits;
10972    const colors = this.colors;
10973    const rawBytes = this.stream.getBytes(rowBytes);
10974    this.eof = !rawBytes.length;
10975    if (this.eof) {
10976      return;
10977    }
10978    let inbuf = 0,
10979      outbuf = 0;
10980    let inbits = 0,
10981      outbits = 0;
10982    let pos = bufferLength;
10983    let i;
10984    if (bits === 1 && colors === 1) {
10985      for (i = 0; i < rowBytes; ++i) {
10986        let c = rawBytes[i] ^ inbuf;
10987        c ^= c >> 1;
10988        c ^= c >> 2;
10989        c ^= c >> 4;
10990        inbuf = (c & 1) << 7;
10991        buffer[pos++] = c;
10992      }
10993    } else if (bits === 8) {
10994      for (i = 0; i < colors; ++i) {
10995        buffer[pos++] = rawBytes[i];
10996      }
10997      for (; i < rowBytes; ++i) {
10998        buffer[pos] = buffer[pos - colors] + rawBytes[i];
10999        pos++;
11000      }
11001    } else if (bits === 16) {
11002      const bytesPerPixel = colors * 2;
11003      for (i = 0; i < bytesPerPixel; ++i) {
11004        buffer[pos++] = rawBytes[i];
11005      }
11006      for (; i < rowBytes; i += 2) {
11007        const sum = ((rawBytes[i] & 0xff) << 8) + (rawBytes[i + 1] & 0xff) + ((buffer[pos - bytesPerPixel] & 0xff) << 8) + (buffer[pos - bytesPerPixel + 1] & 0xff);
11008        buffer[pos++] = sum >> 8 & 0xff;
11009        buffer[pos++] = sum & 0xff;
11010      }
11011    } else {
11012      const compArray = new Uint8Array(colors + 1);
11013      const bitMask = (1 << bits) - 1;
11014      let j = 0,
11015        k = bufferLength;
11016      const columns = this.columns;
11017      for (i = 0; i < columns; ++i) {
11018        for (let kk = 0; kk < colors; ++kk) {
11019          if (inbits < bits) {
11020            inbuf = inbuf << 8 | rawBytes[j++] & 0xff;
11021            inbits += 8;
11022          }
11023          compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
11024          inbits -= bits;
11025          outbuf = outbuf << bits | compArray[kk];
11026          outbits += bits;
11027          if (outbits >= 8) {
11028            buffer[k++] = outbuf >> outbits - 8 & 0xff;
11029            outbits -= 8;
11030          }
11031        }
11032      }
11033      if (outbits > 0) {
11034        buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
11035      }
11036    }
11037    this.bufferLength += rowBytes;
11038  }
11039  readBlockPng() {
11040    const rowBytes = this.rowBytes;
11041    const pixBytes = this.pixBytes;
11042    const predictor = this.stream.getByte();
11043    const rawBytes = this.stream.getBytes(rowBytes);
11044    this.eof = !rawBytes.length;
11045    if (this.eof) {
11046      return;
11047    }
11048    const bufferLength = this.bufferLength;
11049    const buffer = this.ensureBuffer(bufferLength + rowBytes);
11050    let prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
11051    if (prevRow.length === 0) {
11052      prevRow = new Uint8Array(rowBytes);
11053    }
11054    let i,
11055      j = bufferLength,
11056      up,
11057      c;
11058    switch (predictor) {
11059      case 0:
11060        for (i = 0; i < rowBytes; ++i) {
11061          buffer[j++] = rawBytes[i];
11062        }
11063        break;
11064      case 1:
11065        for (i = 0; i < pixBytes; ++i) {
11066          buffer[j++] = rawBytes[i];
11067        }
11068        for (; i < rowBytes; ++i) {
11069          buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xff;
11070          j++;
11071        }
11072        break;
11073      case 2:
11074        for (i = 0; i < rowBytes; ++i) {
11075          buffer[j++] = prevRow[i] + rawBytes[i] & 0xff;
11076        }
11077        break;
11078      case 3:
11079        for (i = 0; i < pixBytes; ++i) {
11080          buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
11081        }
11082        for (; i < rowBytes; ++i) {
11083          buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xff;
11084          j++;
11085        }
11086        break;
11087      case 4:
11088        for (i = 0; i < pixBytes; ++i) {
11089          up = prevRow[i];
11090          c = rawBytes[i];
11091          buffer[j++] = up + c;
11092        }
11093        for (; i < rowBytes; ++i) {
11094          up = prevRow[i];
11095          const upLeft = prevRow[i - pixBytes];
11096          const left = buffer[j - pixBytes];
11097          const p = left + up - upLeft;
11098          let pa = p - left;
11099          if (pa < 0) {
11100            pa = -pa;
11101          }
11102          let pb = p - up;
11103          if (pb < 0) {
11104            pb = -pb;
11105          }
11106          let pc = p - upLeft;
11107          if (pc < 0) {
11108            pc = -pc;
11109          }
11110          c = rawBytes[i];
11111          if (pa <= pb && pa <= pc) {
11112            buffer[j++] = left + c;
11113          } else if (pb <= pc) {
11114            buffer[j++] = up + c;
11115          } else {
11116            buffer[j++] = upLeft + c;
11117          }
11118        }
11119        break;
11120      default:
11121        throw new FormatError(`Unsupported predictor: ${predictor}`);
11122    }
11123    this.bufferLength += rowBytes;
11124  }
11125}
11126
11127;// ./src/core/run_length_stream.js
11128
11129class RunLengthStream extends DecodeStream {
11130  constructor(str, maybeLength) {
11131    super(maybeLength);
11132    this.stream = str;
11133    this.dict = str.dict;
11134  }
11135  readBlock() {
11136    const repeatHeader = this.stream.getBytes(2);
11137    if (
vendor: 724 bytes, lines 11137-11162
11137!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
11138      this.eof = true;
11139      return;
11140    }
11141    let buffer;
11142    let bufferLength = this.bufferLength;
11143    let n = repeatHeader[0];
11144    if (n < 128) {
11145      buffer = this.ensureBuffer(bufferLength + n + 1);
11146      buffer[bufferLength++] = repeatHeader[1];
11147      if (n > 0) {
11148        const source = this.stream.getBytes(n);
11149        buffer.set(source, bufferLength);
11150        bufferLength += n;
11151      }
11152    } else {
11153      n = 257 - n;
11154      buffer = this.ensureBuffer(bufferLength + n + 1);
11155      buffer.fill(repeatHeader[1], bufferLength, bufferLength + n);
11156      bufferLength += n;
11157    }
11158    this.bufferLength = bufferLength;
11159  }
11160}
11161
11162;// ./src/core/parser.js
vendor: 9,996 bytes, lines 11162-11551
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178const MAX_LENGTH_TO_CACHE = 1000;
11179function getInlineImageCacheKey(bytes) {
11180  const strBuf = [],
11181    ii = bytes.length;
11182  let i = 0;
11183  while (i < ii - 1) {
11184    strBuf.push(bytes[i++] << 8 | bytes[i++]);
11185  }
11186  if (i < ii) {
11187    strBuf.push(bytes[i]);
11188  }
11189  return ii + "_" + String.fromCharCode.apply(null, strBuf);
11190}
11191class Parser {
11192  constructor({
11193    lexer,
11194    xref,
11195    allowStreams = false,
11196    recoveryMode = false
11197  }) {
11198    this.lexer = lexer;
11199    this.xref = xref;
11200    this.allowStreams = allowStreams;
11201    this.recoveryMode = recoveryMode;
11202    this.imageCache = Object.create(null);
11203    this._imageId = 0;
11204    this.refill();
11205  }
11206  refill() {
11207    this.buf1 = this.lexer.getObj();
11208    this.buf2 = this.lexer.getObj();
11209  }
11210  shift() {
11211    if (this.buf2 instanceof Cmd && this.buf2.cmd === "ID") {
11212      this.buf1 = this.buf2;
11213      this.buf2 = null;
11214    } else {
11215      this.buf1 = this.buf2;
11216      this.buf2 = this.lexer.getObj();
11217    }
11218  }
11219  tryShift() {
11220    try {
11221      this.shift();
11222      return true;
11223    } catch (e) {
11224      if (e instanceof MissingDataException) {
11225        throw e;
11226      }
11227      return false;
11228    }
11229  }
11230  getObj(cipherTransform = null) {
11231    const buf1 = this.buf1;
11232    this.shift();
11233    if (buf1 instanceof Cmd) {
11234      switch (buf1.cmd) {
11235        case "BI":
11236          return this.makeInlineImage(cipherTransform);
11237        case "[":
11238          const array = [];
11239          while (!isCmd(this.buf1, "]") && this.buf1 !== EOF) {
11240            array.push(this.getObj(cipherTransform));
11241          }
11242          if (this.buf1 === EOF) {
11243            if (this.recoveryMode) {
11244              return array;
11245            }
11246            throw new ParserEOFException("End of file inside array.");
11247          }
11248          this.shift();
11249          return array;
11250        case "<<":
11251          const dict = new Dict(this.xref);
11252          while (!isCmd(this.buf1, ">>") && this.buf1 !== EOF) {
11253            if (!(this.buf1 instanceof Name)) {
11254              info("Malformed dictionary: key must be a name object");
11255              this.shift();
11256              continue;
11257            }
11258            const key = this.buf1.name;
11259            this.shift();
11260            if (this.buf1 === EOF) {
11261              break;
11262            }
11263            dict.set(key, this.getObj(cipherTransform));
11264          }
11265          if (this.buf1 === EOF) {
11266            if (this.recoveryMode) {
11267              return dict;
11268            }
11269            throw new ParserEOFException("End of file inside dictionary.");
11270          }
11271          if (isCmd(this.buf2, "stream")) {
11272            return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
11273          }
11274          this.shift();
11275          return dict;
11276        default:
11277          return buf1;
11278      }
11279    }
11280    if (Number.isInteger(buf1)) {
11281      if (Number.isInteger(this.buf1) && isCmd(this.buf2, "R")) {
11282        const ref = Ref.get(buf1, this.buf1);
11283        this.shift();
11284        this.shift();
11285        return ref;
11286      }
11287      return buf1;
11288    }
11289    if (typeof buf1 === "string") {
11290      if (cipherTransform) {
11291        return cipherTransform.decryptString(buf1);
11292      }
11293      return buf1;
11294    }
11295    return buf1;
11296  }
11297  findDefaultInlineStreamEnd(stream) {
11298    const E = 0x45,
11299      I = 0x49,
11300      SPACE = 0x20,
11301      LF = 0xa,
11302      CR = 0xd,
11303      NUL = 0x0;
11304    const {
11305        knownCommands
11306      } = this.lexer,
11307      startPos = stream.pos,
11308      n = 15;
11309    let state = 0,
11310      ch,
11311      maybeEIPos;
11312    while ((ch = stream.getByte()) !== -1) {
11313      if (state === 0) {
11314        state = ch === E ? 1 : 0;
11315      } else if (state === 1) {
11316        state = ch === I ? 2 : 0;
11317      } else {
11318        if (ch === SPACE || ch === LF || ch === CR) {
11319          maybeEIPos = stream.pos;
11320          const followingBytes = stream.peekBytes(n);
11321          const ii = followingBytes.length;
11322          if (ii === 0) {
11323            break;
11324          }
11325          for (let i = 0; i < ii; i++) {
11326            ch = followingBytes[i];
11327            if (ch === NUL && followingBytes[i + 1] !== NUL) {
11328              continue;
11329            }
11330            if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7f)) {
11331              state = 0;
11332              break;
11333            }
11334          }
11335          if (state !== 2) {
11336            continue;
11337          }
11338          if (!knownCommands) {
11339            warn("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");
11340            continue;
11341          }
11342          const tmpLexer = new Lexer(new Stream(stream.peekBytes(5 * n)), knownCommands);
11343          tmpLexer._hexStringWarn = () => {};
11344          let numArgs = 0;
11345          while (true) {
11346            const nextObj = tmpLexer.getObj();
11347            if (nextObj === EOF) {
11348              state = 0;
11349              break;
11350            }
11351            if (nextObj instanceof Cmd) {
11352              const knownCommand = knownCommands[nextObj.cmd];
11353              if (!knownCommand) {
11354                state = 0;
11355                break;
11356              } else if (knownCommand.variableArgs ? numArgs <= knownCommand.numArgs : numArgs === knownCommand.numArgs) {
11357                break;
11358              }
11359              numArgs = 0;
11360              continue;
11361            }
11362            numArgs++;
11363          }
11364          if (state === 2) {
11365            break;
11366          }
11367        } else {
11368          state = 0;
11369        }
11370      }
11371    }
11372    if (ch === -1) {
11373      warn("findDefaultInlineStreamEnd: " + "Reached the end of the stream without finding a valid EI marker");
11374      if (maybeEIPos) {
11375        warn('... trying to recover by using the last "EI" occurrence.');
11376        stream.skip(-(stream.pos - maybeEIPos));
11377      }
11378    }
11379    let endOffset = 4;
11380    stream.skip(-endOffset);
11381    ch = stream.peekByte();
11382    stream.skip(endOffset);
11383    if (!isWhiteSpace(ch)) {
11384      endOffset--;
11385    }
11386    return stream.pos - endOffset - startPos;
11387  }
11388  findDCTDecodeInlineStreamEnd(stream) {
11389    const startPos = stream.pos;
11390    let foundEOI = false,
11391      b,
11392      markerLength;
11393    while ((b = stream.getByte()) !== -1) {
11394      if (b !== 0xff) {
11395        continue;
11396      }
11397      switch (stream.getByte()) {
11398        case 0x00:
11399          break;
11400        case 0xff:
11401          stream.skip(-1);
11402          break;
11403        case 0xd9:
11404          foundEOI = true;
11405          break;
11406        case 0xc0:
11407        case 0xc1:
11408        case 0xc2:
11409        case 0xc3:
11410        case 0xc5:
11411        case 0xc6:
11412        case 0xc7:
11413        case 0xc9:
11414        case 0xca:
11415        case 0xcb:
11416        case 0xcd:
11417        case 0xce:
11418        case 0xcf:
11419        case 0xc4:
11420        case 0xcc:
11421        case 0xda:
11422        case 0xdb:
11423        case 0xdc:
11424        case 0xdd:
11425        case 0xde:
11426        case 0xdf:
11427        case 0xe0:
11428        case 0xe1:
11429        case 0xe2:
11430        case 0xe3:
11431        case 0xe4:
11432        case 0xe5:
11433        case 0xe6:
11434        case 0xe7:
11435        case 0xe8:
11436        case 0xe9:
11437        case 0xea:
11438        case 0xeb:
11439        case 0xec:
11440        case 0xed:
11441        case 0xee:
11442        case 0xef:
11443        case 0xfe:
11444          markerLength = stream.getUint16();
11445          if (markerLength > 2) {
11446            stream.skip(markerLength - 2);
11447          } else {
11448            stream.skip(-2);
11449          }
11450          break;
11451      }
11452      if (foundEOI) {
11453        break;
11454      }
11455    }
11456    const length = stream.pos - startPos;
11457    if (b === -1) {
11458      warn("Inline DCTDecode image stream: " + "EOI marker not found, searching for /EI/ instead.");
11459      stream.skip(-length);
11460      return this.findDefaultInlineStreamEnd(stream);
11461    }
11462    this.inlineStreamSkipEI(stream);
11463    return length;
11464  }
11465  findASCII85DecodeInlineStreamEnd(stream) {
11466    const TILDE = 0x7e,
11467      GT = 0x3e;
11468    const startPos = stream.pos;
11469    let ch;
11470    while ((ch = stream.getByte()) !== -1) {
11471      if (ch === TILDE) {
11472        const tildePos = stream.pos;
11473        ch = stream.peekByte();
11474        while (isWhiteSpace(ch)) {
11475          stream.skip();
11476          ch = stream.peekByte();
11477        }
11478        if (ch === GT) {
11479          stream.skip();
11480          break;
11481        }
11482        if (stream.pos > tildePos) {
11483          const maybeEI = stream.peekBytes(2);
11484          if (maybeEI[0] === 0x45 && maybeEI[1] === 0x49) {
11485            break;
11486          }
11487        }
11488      }
11489    }
11490    const length = stream.pos - startPos;
11491    if (ch === -1) {
11492      warn("Inline ASCII85Decode image stream: " + "EOD marker not found, searching for /EI/ instead.");
11493      stream.skip(-length);
11494      return this.findDefaultInlineStreamEnd(stream);
11495    }
11496    this.inlineStreamSkipEI(stream);
11497    return length;
11498  }
11499  findASCIIHexDecodeInlineStreamEnd(stream) {
11500    const GT = 0x3e;
11501    const startPos = stream.pos;
11502    let ch;
11503    while ((ch = stream.getByte()) !== -1) {
11504      if (ch === GT) {
11505        break;
11506      }
11507    }
11508    const length = stream.pos - startPos;
11509    if (ch === -1) {
11510      warn("Inline ASCIIHexDecode image stream: " + "EOD marker not found, searching for /EI/ instead.");
11511      stream.skip(-length);
11512      return this.findDefaultInlineStreamEnd(stream);
11513    }
11514    this.inlineStreamSkipEI(stream);
11515    return length;
11516  }
11517  inlineStreamSkipEI(stream) {
11518    const E = 0x45,
11519      I = 0x49;
11520    let state = 0,
11521      ch;
11522    while ((ch = stream.getByte()) !== -1) {
11523      if (state === 0) {
11524        state = ch === E ? 1 : 0;
11525      } else if (state === 1) {
11526        state = ch === I ? 2 : 0;
11527      } else if (state === 2) {
11528        break;
11529      }
11530    }
11531  }
11532  makeInlineImage(cipherTransform) {
11533    const lexer = this.lexer;
11534    const stream = lexer.stream;
11535    const dictMap = Object.create(null);
11536    let dictLength;
11537    while (!isCmd(this.buf1, "ID") && this.buf1 !== EOF) {
11538      if (!(this.buf1 instanceof Name)) {
11539        throw new FormatError("Dictionary key must be a name object");
11540      }
11541      const key = this.buf1.name;
11542      this.shift();
11543      if (this.buf1 === EOF) {
11544        break;
11545      }
11546      dictMap[key] = this.getObj(cipherTransform);
11547    }
11548    if (lexer.beginInlineImagePos !== -1) {
11549      dictLength = stream.pos - lexer.beginInlineImagePos;
11550    }
11551    const filter = this.
11551#fetchIfRef(dictMap.F || dictMap.Filter);
11552    let filterName;
11553    if (filter instanceof Name) {
11554      filterName = filter.name;
11555    } else if (Array.isArray(filter)) {
11556      const filterZero = this.#fetchIfRef(filter[0]);
11557      if (filterZero instanceof Name) {
11558        filterName = filterZero.name;
11559      }
11560    }
11561    const startPos = stream.pos;
11562    let length;
11563    switch (filterName) {
11564      case "DCT":
11565      case "DCTDecode":
11566        length = this.findDCTDecodeInlineStreamEnd(stream);
11567        break;
11568      case "A85":
11569      case "ASCII85Decode":
11570        length = this.findASCII85DecodeInlineStreamEnd(stream);
11571        break;
11572      case "AHx":
11573      case "ASCIIHexDecode":
11574        length = this.findASCIIHexDecodeInlineStreamEnd(stream);
11575        break;
11576      default:
11577        length = this.findDefaultInlineStreamEnd(stream);
11578    }
11579    let cacheKey;
11580    if (length < MAX_LENGTH_TO_CACHE && dictLength > 0) {
11581      const initialStreamPos = stream.pos;
11582      stream.pos = lexer.beginInlineImagePos;
11583      cacheKey = getInlineImageCacheKey(stream.getBytes(dictLength + length));
11584      stream.pos = initialStreamPos;
11585      const cacheEntry = this.imageCache[cacheKey];
11586      if (cacheEntry !== undefined) {
11587        this.buf2 = Cmd.get("EI");
11588        this.shift();
11589        cacheEntry.reset();
11590        return cacheEntry;
11591      }
11592    }
11593    const dict = new Dict(this.xref);
11594    for (const key in dictMap) {
11595      dict.set(key, dictMap[key]);
11596    }
11597    let imageStream = stream.makeSubStream(startPos, length, dict);
11598    if (cipherTransform && !this.#hasCryptFilter(filter)) {
11599      imageStream = cipherTransform.createStream(imageStream, length);
11600    }
11601    imageStream = this.filter(imageStream, dict, length, cipherTransform);
11602    imageStream.dict = dict;
11603    if (cacheKey !== undefined) {
11604      imageStream.cacheKey = `inline_img_${++this._imageId}`;
11605      this.imageCache[cacheKey] = imageStream;
11606    }
11607    this.buf2 = Cmd.get("EI");
11608    this.shift();
11609    return imageStream;
11610  }
11611  #fetchIfRef(obj) {
11612    return this.xref ? this.xref.fetchIfRef(obj) : obj;
11613  }
11614  #hasCryptFilter(filter) {
11615    if (!Array.isArray(filter)) {
11616      return isName(filter, "Crypt");
11617    }
11618    for (const f of filter) {
11619      if (isName(this.#fetchIfRef(f), "Crypt")) {
11620        return true;
11621      }
11622    }
11623    return false
vendor: 21,671 bytes, lines 11623-12255
11623;
11624  }
11625  #findStreamLength(startPos) {
11626    const {
11627      stream
11628    } = this.lexer;
11629    stream.pos = startPos;
11630    const SCAN_BLOCK_LENGTH = 2048;
11631    const signatureLength = "endstream".length;
11632    const END_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64]);
11633    const endLength = END_SIGNATURE.length;
11634    const PARTIAL_SIGNATURE = [new Uint8Array([0x73, 0x74, 0x72, 0x65, 0x61, 0x6d]), new Uint8Array([0x73, 0x74, 0x65, 0x61, 0x6d]), new Uint8Array([0x73, 0x74, 0x72, 0x65, 0x61])];
11635    const normalLength = signatureLength - endLength;
11636    while (stream.pos < stream.end) {
11637      const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
11638      const scanLength = scanBytes.length - signatureLength;
11639      if (scanLength <= 0) {
11640        break;
11641      }
11642      let pos = 0;
11643      while (pos < scanLength) {
11644        let j = 0;
11645        while (j < endLength && scanBytes[pos + j] === END_SIGNATURE[j]) {
11646          j++;
11647        }
11648        if (j >= endLength) {
11649          let found = false;
11650          for (const part of PARTIAL_SIGNATURE) {
11651            const partLen = part.length;
11652            let k = 0;
11653            while (k < partLen && scanBytes[pos + j + k] === part[k]) {
11654              k++;
11655            }
11656            if (k >= normalLength) {
11657              found = true;
11658              break;
11659            }
11660            if (k >= partLen) {
11661              const lastByte = scanBytes[pos + j + k];
11662              if (isWhiteSpace(lastByte)) {
11663                info(`Found "${bytesToString([...END_SIGNATURE, ...part])}" when ` + "searching for endstream command.");
11664                found = true;
11665              }
11666              break;
11667            }
11668          }
11669          if (found) {
11670            stream.pos += pos;
11671            return stream.pos - startPos;
11672          }
11673        }
11674        pos++;
11675      }
11676      stream.pos += scanLength;
11677    }
11678    return -1;
11679  }
11680  makeStream(dict, cipherTransform) {
11681    const lexer = this.lexer;
11682    let stream = lexer.stream;
11683    lexer.skipToNextLine();
11684    const startPos = stream.pos - 1;
11685    let length = dict.get("Length");
11686    if (!Number.isInteger(length)) {
11687      info(`Bad length "${length && length.toString()}" in stream.`);
11688      length = 0;
11689    }
11690    stream.pos = startPos + length;
11691    lexer.nextChar();
11692    if (this.tryShift() && isCmd(this.buf2, "endstream")) {
11693      this.shift();
11694    } else {
11695      length = this.#findStreamLength(startPos);
11696      if (length < 0) {
11697        throw new FormatError("Missing endstream command.");
11698      }
11699      lexer.nextChar();
11700      this.shift();
11701      this.shift();
11702    }
11703    this.shift();
11704    stream = stream.makeSubStream(startPos, length, dict);
11705    const filter = dict.get("F", "Filter");
11706    if (cipherTransform && !this.#hasCryptFilter(filter)) {
11707      stream = cipherTransform.createStream(stream, length);
11708    }
11709    stream = this.filter(stream, dict, length, cipherTransform);
11710    stream.dict = dict;
11711    return stream;
11712  }
11713  filter(stream, dict, length, cipherTransform = null) {
11714    let filter = dict.get("F", "Filter");
11715    let params = dict.get("DP", "DecodeParms");
11716    if (filter instanceof Name) {
11717      if (Array.isArray(params)) {
11718        warn("/DecodeParms should not be an Array, when /Filter is a Name.");
11719      }
11720      return this.makeFilter(stream, filter.name, length, params, cipherTransform);
11721    }
11722    let maybeLength = length;
11723    if (Array.isArray(filter)) {
11724      const filterArray = filter;
11725      const paramsArray = params;
11726      for (let i = 0, ii = filterArray.length; i < ii; ++i) {
11727        filter = this.#fetchIfRef(filterArray[i]);
11728        if (!(filter instanceof Name)) {
11729          throw new FormatError(`Bad filter name "${filter}"`);
11730        }
11731        params = null;
11732        if (Array.isArray(paramsArray) && i in paramsArray) {
11733          params = this.#fetchIfRef(paramsArray[i]);
11734        }
11735        stream = this.makeFilter(stream, filter.name, maybeLength, params, cipherTransform);
11736        maybeLength = null;
11737      }
11738    }
11739    return stream;
11740  }
11741  makeFilter(stream, name, maybeLength, params, cipherTransform = null) {
11742    if (maybeLength === 0) {
11743      warn(`Empty "${name}" stream.`);
11744      return new NullStream();
11745    }
11746    try {
11747      switch (name) {
11748        case "Fl":
11749        case "FlateDecode":
11750          if (params) {
11751            return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
11752          }
11753          return new FlateStream(stream, maybeLength);
11754        case "LZW":
11755        case "LZWDecode":
11756          let earlyChange = 1;
11757          if (params) {
11758            if (params.has("EarlyChange")) {
11759              earlyChange = params.get("EarlyChange");
11760            }
11761            return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
11762          }
11763          return new LZWStream(stream, maybeLength, earlyChange);
11764        case "DCT":
11765        case "DCTDecode":
11766          return new JpegStream(stream, maybeLength, params);
11767        case "JPX":
11768        case "JPXDecode":
11769          return new JpxStream(stream, maybeLength);
11770        case "A85":
11771        case "ASCII85Decode":
11772          return new Ascii85Stream(stream, maybeLength);
11773        case "AHx":
11774        case "ASCIIHexDecode":
11775          return new AsciiHexStream(stream, maybeLength);
11776        case "CCF":
11777        case "CCITTFaxDecode":
11778          return new CCITTFaxStream(stream, maybeLength, params);
11779        case "RL":
11780        case "RunLengthDecode":
11781          return new RunLengthStream(stream, maybeLength);
11782        case "JBIG2Decode":
11783          return new Jbig2Stream(stream, maybeLength, params);
11784        case "BrotliDecode":
11785          return new BrotliStream(stream, maybeLength);
11786        case "Crypt":
11787          {
11788            if (!cipherTransform) {
11789              warn('Filter "Crypt" is missing a cipher transform.');
11790              return stream;
11791            }
11792            const param = params instanceof Dict ? params.get("Name") : null;
11793            const cryptName = param instanceof Name ? param : Name.get("Identity");
11794            return cipherTransform.createStream(stream, maybeLength, cryptName);
11795          }
11796      }
11797      warn(`Filter "${name}" is not supported.`);
11798      return stream;
11799    } catch (ex) {
11800      if (ex instanceof MissingDataException) {
11801        throw ex;
11802      }
11803      warn(`Invalid stream: "${ex}"`);
11804      return new NullStream();
11805    }
11806  }
11807}
11808const specialChars = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 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, 0, 0, 2, 0, 2, 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, 0, 0, 0, 2, 0, 2, 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, 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, 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, 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, 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];
11809function toHexDigit(ch) {
11810  if (ch >= 0x30 && ch <= 0x39) {
11811    return ch & 0x0f;
11812  }
11813  if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
11814    return (ch & 0x0f) + 9;
11815  }
11816  return -1;
11817}
11818class Lexer {
11819  constructor(stream, knownCommands = null) {
11820    this.stream = stream;
11821    this.nextChar();
11822    this.strBuf = [];
11823    this.knownCommands = knownCommands;
11824    this._hexStringNumWarn = 0;
11825    this.beginInlineImagePos = -1;
11826  }
11827  nextChar() {
11828    return this.currentChar = this.stream.getByte();
11829  }
11830  peekChar() {
11831    return this.stream.peekByte();
11832  }
11833  getNumber() {
11834    let ch = this.currentChar;
11835    let divideBy = 0;
11836    let sign = 1;
11837    if (ch === 0x2d) {
11838      sign = -1;
11839      ch = this.nextChar();
11840      if (ch === 0x2d) {
11841        ch = this.nextChar();
11842      }
11843    } else if (ch === 0x2b) {
11844      ch = this.nextChar();
11845    }
11846    if (ch === 0x0a || ch === 0x0d) {
11847      do {
11848        ch = this.nextChar();
11849      } while (ch === 0x0a || ch === 0x0d);
11850    }
11851    if (ch === 0x2e) {
11852      divideBy = 10;
11853      ch = this.nextChar();
11854    }
11855    if (ch < 0x30 || ch > 0x39) {
11856      const msg = `Invalid number: ${String.fromCharCode(ch)} (charCode ${ch})`;
11857      if (isWhiteSpace(ch) || ch === 0x28 || ch === 0x3c || ch === -1) {
11858        info(`Lexer.getNumber - "${msg}".`);
11859        return 0;
11860      }
11861      throw new FormatError(msg);
11862    }
11863    let baseValue = ch - 0x30;
11864    while ((ch = this.nextChar()) >= 0) {
11865      if (ch >= 0x30 && ch <= 0x39) {
11866        const currentDigit = ch - 0x30;
11867        if (divideBy !== 0) {
11868          divideBy *= 10;
11869        }
11870        baseValue = baseValue * 10 + currentDigit;
11871      } else if (ch === 0x2e) {
11872        if (divideBy === 0) {
11873          divideBy = 1;
11874        } else {
11875          break;
11876        }
11877      } else if (ch === 0x2d) {
11878        warn("Badly formatted number: minus sign in the middle");
11879      } else {
11880        break;
11881      }
11882    }
11883    if (divideBy !== 0) {
11884      baseValue /= divideBy;
11885    }
11886    return sign * baseValue;
11887  }
11888  getString() {
11889    let numParen = 1;
11890    let done = false;
11891    const strBuf = this.strBuf;
11892    strBuf.length = 0;
11893    let ch = this.nextChar();
11894    while (true) {
11895      let charBuffered = false;
11896      switch (ch | 0) {
11897        case -1:
11898          warn("Unterminated string");
11899          done = true;
11900          break;
11901        case 0x28:
11902          ++numParen;
11903          strBuf.push("(");
11904          break;
11905        case 0x29:
11906          if (--numParen === 0) {
11907            this.nextChar();
11908            done = true;
11909          } else {
11910            strBuf.push(")");
11911          }
11912          break;
11913        case 0x5c:
11914          ch = this.nextChar();
11915          switch (ch) {
11916            case -1:
11917              warn("Unterminated string");
11918              done = true;
11919              break;
11920            case 0x6e:
11921              strBuf.push("\n");
11922              break;
11923            case 0x72:
11924              strBuf.push("\r");
11925              break;
11926            case 0x74:
11927              strBuf.push("\t");
11928              break;
11929            case 0x62:
11930              strBuf.push("\b");
11931              break;
11932            case 0x66:
11933              strBuf.push("\f");
11934              break;
11935            case 0x5c:
11936            case 0x28:
11937            case 0x29:
11938              strBuf.push(String.fromCharCode(ch));
11939              break;
11940            case 0x30:
11941            case 0x31:
11942            case 0x32:
11943            case 0x33:
11944            case 0x34:
11945            case 0x35:
11946            case 0x36:
11947            case 0x37:
11948              let x = ch & 0x0f;
11949              ch = this.nextChar();
11950              charBuffered = true;
11951              if (ch >= 0x30 && ch <= 0x37) {
11952                x = (x << 3) + (ch & 0x0f);
11953                ch = this.nextChar();
11954                if (ch >= 0x30 && ch <= 0x37) {
11955                  charBuffered = false;
11956                  x = (x << 3) + (ch & 0x0f);
11957                }
11958              }
11959              strBuf.push(String.fromCharCode(x));
11960              break;
11961            case 0x0d:
11962              if (this.peekChar() === 0x0a) {
11963                this.nextChar();
11964              }
11965              break;
11966            case 0x0a:
11967              break;
11968            default:
11969              strBuf.push(String.fromCharCode(ch));
11970              break;
11971          }
11972          break;
11973        default:
11974          strBuf.push(String.fromCharCode(ch));
11975          break;
11976      }
11977      if (done) {
11978        break;
11979      }
11980      if (!charBuffered) {
11981        ch = this.nextChar();
11982      }
11983    }
11984    return strBuf.join("");
11985  }
11986  getName() {
11987    let ch, previousCh;
11988    const strBuf = this.strBuf;
11989    strBuf.length = 0;
11990    while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
11991      if (ch === 0x23) {
11992        ch = this.nextChar();
11993        if (specialChars[ch]) {
11994          warn("Lexer_getName: " + "NUMBER SIGN (#) should be followed by a hexadecimal number.");
11995          strBuf.push("#");
11996          break;
11997        }
11998        const x = toHexDigit(ch);
11999        if (x !== -1) {
12000          previousCh = ch;
12001          ch = this.nextChar();
12002          const x2 = toHexDigit(ch);
12003          if (x2 === -1) {
12004            warn(`Lexer_getName: Illegal digit (${String.fromCharCode(ch)}) ` + "in hexadecimal number.");
12005            strBuf.push("#", String.fromCharCode(previousCh));
12006            if (specialChars[ch]) {
12007              break;
12008            }
12009            strBuf.push(String.fromCharCode(ch));
12010            continue;
12011          }
12012          strBuf.push(String.fromCharCode(x << 4 | x2));
12013        } else {
12014          strBuf.push("#", String.fromCharCode(ch));
12015        }
12016      } else {
12017        strBuf.push(String.fromCharCode(ch));
12018      }
12019    }
12020    if (strBuf.length > 127) {
12021      warn(`Name token is longer than allowed by the spec: ${strBuf.length}`);
12022    }
12023    return Name.get(strBuf.join(""));
12024  }
12025  _hexStringWarn(ch) {
12026    const MAX_HEX_STRING_NUM_WARN = 5;
12027    if (this._hexStringNumWarn++ === MAX_HEX_STRING_NUM_WARN) {
12028      warn("getHexString - ignoring additional invalid characters.");
12029      return;
12030    }
12031    if (this._hexStringNumWarn > MAX_HEX_STRING_NUM_WARN) {
12032      return;
12033    }
12034    warn(`getHexString - ignoring invalid character: ${ch}`);
12035  }
12036  getHexString() {
12037    const strBuf = this.strBuf;
12038    strBuf.length = 0;
12039    let ch = this.currentChar;
12040    let firstDigit = -1,
12041      digit = -1;
12042    this._hexStringNumWarn = 0;
12043    while (true) {
12044      if (ch < 0) {
12045        warn("Unterminated hex string");
12046        break;
12047      } else if (ch === 0x3e) {
12048        this.nextChar();
12049        break;
12050      } else if (specialChars[ch] === 1) {
12051        ch = this.nextChar();
12052        continue;
12053      } else {
12054        digit = toHexDigit(ch);
12055        if (digit === -1) {
12056          this._hexStringWarn(ch);
12057        } else if (firstDigit === -1) {
12058          firstDigit = digit;
12059        } else {
12060          strBuf.push(String.fromCharCode(firstDigit << 4 | digit));
12061          firstDigit = -1;
12062        }
12063        ch = this.nextChar();
12064      }
12065    }
12066    if (firstDigit !== -1) {
12067      strBuf.push(String.fromCharCode(firstDigit << 4));
12068    }
12069    return strBuf.join("");
12070  }
12071  getObj() {
12072    let comment = false;
12073    let ch = this.currentChar;
12074    while (true) {
12075      if (ch < 0) {
12076        return EOF;
12077      }
12078      if (comment) {
12079        if (ch === 0x0a || ch === 0x0d) {
12080          comment = false;
12081        }
12082      } else if (ch === 0x25) {
12083        comment = true;
12084      } else if (specialChars[ch] !== 1) {
12085        break;
12086      }
12087      ch = this.nextChar();
12088    }
12089    switch (ch | 0) {
12090      case 0x30:
12091      case 0x31:
12092      case 0x32:
12093      case 0x33:
12094      case 0x34:
12095      case 0x35:
12096      case 0x36:
12097      case 0x37:
12098      case 0x38:
12099      case 0x39:
12100      case 0x2b:
12101      case 0x2d:
12102      case 0x2e:
12103        return this.getNumber();
12104      case 0x28:
12105        return this.getString();
12106      case 0x2f:
12107        return this.getName();
12108      case 0x5b:
12109        this.nextChar();
12110        return Cmd.get("[");
12111      case 0x5d:
12112        this.nextChar();
12113        return Cmd.get("]");
12114      case 0x3c:
12115        ch = this.nextChar();
12116        if (ch === 0x3c) {
12117          this.nextChar();
12118          return Cmd.get("<<");
12119        }
12120        return this.getHexString();
12121      case 0x3e:
12122        ch = this.nextChar();
12123        if (ch === 0x3e) {
12124          this.nextChar();
12125          return Cmd.get(">>");
12126        }
12127        return Cmd.get(">");
12128      case 0x7b:
12129        this.nextChar();
12130        return Cmd.get("{");
12131      case 0x7d:
12132        this.nextChar();
12133        return Cmd.get("}");
12134      case 0x29:
12135        this.nextChar();
12136        throw new FormatError(`Illegal character: ${ch}`);
12137    }
12138    let str = String.fromCharCode(ch);
12139    if (ch < 0x20 || ch > 0x7f) {
12140      const nextCh = this.peekChar();
12141      if (nextCh >= 0x20 && nextCh <= 0x7f) {
12142        this.nextChar();
12143        return Cmd.get(str);
12144      }
12145    }
12146    const knownCommands = this.knownCommands;
12147    let knownCommandFound = knownCommands?.[str] !== undefined;
12148    while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
12149      const possibleCommand = str + String.fromCharCode(ch);
12150      if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
12151        break;
12152      }
12153      if (str.length === 128) {
12154        throw new FormatError(`Command token too long: ${str.length}`);
12155      }
12156      str = possibleCommand;
12157      knownCommandFound = knownCommands?.[str] !== undefined;
12158    }
12159    if (str === "true") {
12160      return true;
12161    }
12162    if (str === "false") {
12163      return false;
12164    }
12165    if (str === "null") {
12166      return null;
12167    }
12168    if (str === "BI") {
12169      this.beginInlineImagePos = this.stream.pos;
12170    }
12171    return Cmd.get(str);
12172  }
12173  skipToNextLine() {
12174    let ch = this.currentChar;
12175    while (ch >= 0) {
12176      if (ch === 0x0d) {
12177        ch = this.nextChar();
12178        if (ch === 0x0a) {
12179          this.nextChar();
12180        }
12181        break;
12182      } else if (ch === 0x0a) {
12183        this.nextChar();
12184        break;
12185      }
12186      ch = this.nextChar();
12187    }
12188  }
12189}
12190class Linearization {
12191  static create(stream) {
12192    function getInt(linDict, name, allowZeroValue = false) {
12193      const obj = linDict.get(name);
12194      if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
12195        return obj;
12196      }
12197      throw new Error(`The "${name}" parameter in the linearization ` + "dictionary is invalid.");
12198    }
12199    function getHints(linDict) {
12200      const hints = linDict.get("H");
12201      let hintsLength;
12202      if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
12203        for (let index = 0; index < hintsLength; index++) {
12204          const hint = hints[index];
12205          if (!(Number.isInteger(hint) && hint > 0)) {
12206            throw new Error(`Hint (${index}) in the linearization dictionary is invalid.`);
12207          }
12208        }
12209        return hints;
12210      }
12211      throw new Error("Hint array in the linearization dictionary is invalid.");
12212    }
12213    const parser = new Parser({
12214      lexer: new Lexer(stream),
12215      xref: null
12216    });
12217    const obj1 = parser.getObj();
12218    const obj2 = parser.getObj();
12219    const obj3 = parser.getObj();
12220    const linDict = parser.getObj();
12221    let obj, length;
12222    if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && isCmd(obj3, "obj") && linDict instanceof Dict && typeof (obj = linDict.get("Linearized")) === "number" && obj > 0)) {
12223      return null;
12224    } else if ((length = getInt(linDict, "L")) !== stream.length) {
12225      throw new Error('The "L" parameter in the linearization dictionary ' + "does not equal the stream length.");
12226    }
12227    return {
12228      length,
12229      hints: getHints(linDict),
12230      objectNumberFirst: getInt(linDict, "O"),
12231      endFirst: getInt(linDict, "E"),
12232      numPages: getInt(linDict, "N"),
12233      mainXRefEntriesOffset: getInt(linDict, "T"),
12234      pageFirst: linDict.has("P") ? getInt(linDict, "P", true) : 0
12235    };
12236  }
12237}
12238
12239;// ./src/core/cmap.js
12240
12241
12242
12243
12244
12245
12246
12247const BUILT_IN_CMAPS = ["Adobe-GB1-UCS2", "Adobe-CNS1-UCS2", "Adobe-Japan1-UCS2", "Adobe-Korea1-UCS2", "78-EUC-H", "78-EUC-V", "78-H", "78-RKSJ-H", "78-RKSJ-V", "78-V", "78ms-RKSJ-H", "78ms-RKSJ-V", "83pv-RKSJ-H", "90ms-RKSJ-H", "90ms-RKSJ-V", "90msp-RKSJ-H", "90msp-RKSJ-V", "90pv-RKSJ-H", "90pv-RKSJ-V", "Add-H", "Add-RKSJ-H", "Add-RKSJ-V", "Add-V", "Adobe-CNS1-0", "Adobe-CNS1-1", "Adobe-CNS1-2", "Adobe-CNS1-3", "Adobe-CNS1-4", "Adobe-CNS1-5", "Adobe-CNS1-6", "Adobe-GB1-0", "Adobe-GB1-1", "Adobe-GB1-2", "Adobe-GB1-3", "Adobe-GB1-4", "Adobe-GB1-5", "Adobe-Japan1-0", "Adobe-Japan1-1", "Adobe-Japan1-2", "Adobe-Japan1-3", "Adobe-Japan1-4", "Adobe-Japan1-5", "Adobe-Japan1-6", "Adobe-Korea1-0", "Adobe-Korea1-1", "Adobe-Korea1-2", "B5-H", "B5-V", "B5pc-H", "B5pc-V", "CNS-EUC-H", "CNS-EUC-V", "CNS1-H", "CNS1-V", "CNS2-H", "CNS2-V", "ETHK-B5-H", "ETHK-B5-V", "ETen-B5-H", "ETen-B5-V", "ETenms-B5-H", "ETenms-B5-V", "EUC-H", "EUC-V", "Ext-H", "Ext-RKSJ-H", "Ext-RKSJ-V", "Ext-V", "GB-EUC-H", "GB-EUC-V", "GB-H", "GB-V", "GBK-EUC-H", "GBK-EUC-V", "GBK2K-H", "GBK2K-V", "GBKp-EUC-H", "GBKp-EUC-V", "GBT-EUC-H", "GBT-EUC-V", "GBT-H", "GBT-V", "GBTpc-EUC-H", "GBTpc-EUC-V", "GBpc-EUC-H", "GBpc-EUC-V", "H", "HKdla-B5-H", "HKdla-B5-V", "HKdlb-B5-H", "HKdlb-B5-V", "HKgccs-B5-H", "HKgccs-B5-V", "HKm314-B5-H", "HKm314-B5-V", "HKm471-B5-H", "HKm471-B5-V", "HKscs-B5-H", "HKscs-B5-V", "Hankaku", "Hiragana", "KSC-EUC-H", "KSC-EUC-V", "KSC-H", "KSC-Johab-H", "KSC-Johab-V", "KSC-V", "KSCms-UHC-H", "KSCms-UHC-HW-H", "KSCms-UHC-HW-V", "KSCms-UHC-V", "KSCpc-EUC-H", "KSCpc-EUC-V", "Katakana", "NWP-H", "NWP-V", "RKSJ-H", "RKSJ-V", "Roman", "UniCNS-UCS2-H", "UniCNS-UCS2-V", "UniCNS-UTF16-H", "UniCNS-UTF16-V", "UniCNS-UTF32-H", "UniCNS-UTF32-V", "UniCNS-UTF8-H", "UniCNS-UTF8-V", "UniGB-UCS2-H", "UniGB-UCS2-V", "UniGB-UTF16-H", "UniGB-UTF16-V", "UniGB-UTF32-H", "UniGB-UTF32-V", "UniGB-UTF8-H", "UniGB-UTF8-V", "UniJIS-UCS2-H", "UniJIS-UCS2-HW-H", "UniJIS-UCS2-HW-V", "UniJIS-UCS2-V", "UniJIS-UTF16-H", "UniJIS-UTF16-V", "UniJIS-UTF32-H", "UniJIS-UTF32-V", "UniJIS-UTF8-H", "UniJIS-UTF8-V", "UniJIS2004-UTF16-H", "UniJIS2004-UTF16-V", "UniJIS2004-UTF32-H", "UniJIS2004-UTF32-V", "UniJIS2004-UTF8-H", "UniJIS2004-UTF8-V", "UniJISPro-UCS2-HW-V", "UniJISPro-UCS2-V", "UniJISPro-UTF8-V", "UniJISX0213-UTF32-H", "UniJISX0213-UTF32-V", "UniJISX02132004-UTF32-H", "UniJISX02132004-UTF32-V", "UniKS-UCS2-H", "UniKS-UCS2-V", "UniKS-UTF16-H", "UniKS-UTF16-V", "UniKS-UTF32-H", "UniKS-UTF32-V", "UniKS-UTF8-H", "UniKS-UTF8-V", "V", "WP-Symbol"];
12248const MAX_MAP_RANGE = 2 ** 24 - 1;
12249class CMap {
12250  constructor(builtInCMap = false) {
12251    this.codespaceRanges = [[], [], [], []];
12252    this.numCodespaceRanges = 0;
12253    this._map = [];
12254    this.name = "";
12255    this.vertical = false;
vendor: 2,526 bytes, lines 12256-12345
12256    this.useCMap = null;
12257    this.builtInCMap = builtInCMap;
12258  }
12259  addCodespaceRange(n, low, high) {
12260    this.codespaceRanges[n - 1].push(low, high);
12261    this.numCodespaceRanges++;
12262  }
12263  mapCidRange(low, high, dstLow) {
12264    if (high - low > MAX_MAP_RANGE) {
12265      throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
12266    }
12267    while (low <= high) {
12268      this._map[low++] = dstLow++;
12269    }
12270  }
12271  mapBfRange(low, high, dstLow) {
12272    if (high - low > MAX_MAP_RANGE) {
12273      throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
12274    }
12275    const lastByte = dstLow.length - 1;
12276    while (low <= high) {
12277      this._map[low++] = dstLow;
12278      const nextCharCode = dstLow.charCodeAt(lastByte) + 1;
12279      if (nextCharCode > 0xff) {
12280        dstLow = dstLow.substring(0, lastByte - 1) + String.fromCharCode(dstLow.charCodeAt(lastByte - 1) + 1) + "\x00";
12281        continue;
12282      }
12283      dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(nextCharCode);
12284    }
12285  }
12286  mapBfRangeToArray(low, high, array) {
12287    if (high - low > MAX_MAP_RANGE) {
12288      throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
12289    }
12290    const ii = array.length;
12291    let i = 0;
12292    while (low <= high && i < ii) {
12293      this._map[low] = array[i++];
12294      ++low;
12295    }
12296  }
12297  mapOne(src, dst) {
12298    this._map[src] = dst;
12299  }
12300  lookup(code) {
12301    return this._map[code];
12302  }
12303  contains(code) {
12304    return this._map[code] !== undefined;
12305  }
12306  forEach(callback) {
12307    const map = this._map;
12308    const length = map.length;
12309    if (length <= 0x10000) {
12310      for (let i = 0; i < length; i++) {
12311        if (map[i] !== undefined) {
12312          callback(i, map[i]);
12313        }
12314      }
12315    } else {
12316      for (const i in map) {
12317        callback(i, map[i]);
12318      }
12319    }
12320  }
12321  charCodeOf(value) {
12322    const map = this._map;
12323    if (map.length <= 0x10000) {
12324      return map.indexOf(value);
12325    }
12326    for (const charCode in map) {
12327      if (map[charCode] === value) {
12328        return charCode | 0;
12329      }
12330    }
12331    return -1;
12332  }
12333  getMap() {
12334    return this._map;
12335  }
12336  readCharCode(str, offset, out) {
12337    let c = 0;
12338    const codespaceRanges = this.codespaceRanges;
12339    for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
12340      c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
12341      const codespaceRange = codespaceRanges[n];
12342      for (let k = 0, kk = codespaceRange.length; k < kk;) {
12343        const low = codespaceRange[k++];
12344        const high = codespaceRange[k++];
12345        if (c >= low && c <= high) {
vendor: 8,779 bytes, lines 12346-12690
12346          out.charcode = c;
12347          out.length = n + 1;
12348          return;
12349        }
12350      }
12351    }
12352    out.charcode = 0;
12353    out.length = 1;
12354  }
12355  getCharCodeLength(charCode) {
12356    const codespaceRanges = this.codespaceRanges;
12357    for (let n = 0, nn = codespaceRanges.length; n < nn; n++) {
12358      const codespaceRange = codespaceRanges[n];
12359      for (let k = 0, kk = codespaceRange.length; k < kk;) {
12360        const low = codespaceRange[k++];
12361        const high = codespaceRange[k++];
12362        if (charCode >= low && charCode <= high) {
12363          return n + 1;
12364        }
12365      }
12366    }
12367    return 1;
12368  }
12369  get length() {
12370    return this._map.length;
12371  }
12372  get isIdentityCMap() {
12373    if (!(this.name === "Identity-H" || this.name === "Identity-V")) {
12374      return false;
12375    }
12376    if (this._map.length !== 0x10000) {
12377      return false;
12378    }
12379    for (let i = 0; i < 0x10000; i++) {
12380      if (this._map[i] !== i) {
12381        return false;
12382      }
12383    }
12384    return true;
12385  }
12386}
12387class IdentityCMap extends CMap {
12388  constructor(vertical, n) {
12389    super();
12390    this.vertical = vertical;
12391    this.addCodespaceRange(n, 0, 0xffff);
12392  }
12393  mapCidRange(low, high, dstLow) {
12394    unreachable("should not call mapCidRange");
12395  }
12396  mapBfRange(low, high, dstLow) {
12397    unreachable("should not call mapBfRange");
12398  }
12399  mapBfRangeToArray(low, high, array) {
12400    unreachable("should not call mapBfRangeToArray");
12401  }
12402  mapOne(src, dst) {
12403    unreachable("should not call mapCidOne");
12404  }
12405  lookup(code) {
12406    return Number.isInteger(code) && code <= 0xffff ? code : undefined;
12407  }
12408  contains(code) {
12409    return Number.isInteger(code) && code <= 0xffff;
12410  }
12411  forEach(callback) {
12412    for (let i = 0; i <= 0xffff; i++) {
12413      callback(i, i);
12414    }
12415  }
12416  charCodeOf(value) {
12417    return Number.isInteger(value) && value <= 0xffff ? value : -1;
12418  }
12419  getMap() {
12420    const map = new Array(0x10000);
12421    for (let i = 0; i <= 0xffff; i++) {
12422      map[i] = i;
12423    }
12424    return map;
12425  }
12426  get length() {
12427    return 0x10000;
12428  }
12429  get isIdentityCMap() {
12430    unreachable("should not access .isIdentityCMap");
12431  }
12432}
12433function strToInt(str) {
12434  let a = 0;
12435  for (let i = 0; i < str.length; i++) {
12436    a = a << 8 | str.charCodeAt(i);
12437  }
12438  return a >>> 0;
12439}
12440function expectString(obj) {
12441  if (typeof obj !== "string") {
12442    throw new FormatError("Malformed CMap: expected string.");
12443  }
12444}
12445function expectInt(obj) {
12446  if (!Number.isInteger(obj)) {
12447    throw new FormatError("Malformed CMap: expected int.");
12448  }
12449}
12450function parseBfChar(cMap, lexer) {
12451  while (true) {
12452    let obj = lexer.getObj();
12453    if (obj === EOF) {
12454      break;
12455    }
12456    if (isCmd(obj, "endbfchar")) {
12457      return;
12458    }
12459    expectString(obj);
12460    const src = strToInt(obj);
12461    obj = lexer.getObj();
12462    expectString(obj);
12463    const dst = obj;
12464    cMap.mapOne(src, dst);
12465  }
12466}
12467function parseBfRange(cMap, lexer) {
12468  while (true) {
12469    let obj = lexer.getObj();
12470    if (obj === EOF) {
12471      break;
12472    }
12473    if (isCmd(obj, "endbfrange")) {
12474      return;
12475    }
12476    expectString(obj);
12477    const low = strToInt(obj);
12478    obj = lexer.getObj();
12479    expectString(obj);
12480    const high = strToInt(obj);
12481    obj = lexer.getObj();
12482    if (Number.isInteger(obj) || typeof obj === "string") {
12483      const dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
12484      cMap.mapBfRange(low, high, dstLow);
12485    } else if (isCmd(obj, "[")) {
12486      obj = lexer.getObj();
12487      const array = [];
12488      while (!isCmd(obj, "]") && obj !== EOF) {
12489        array.push(obj);
12490        obj = lexer.getObj();
12491      }
12492      cMap.mapBfRangeToArray(low, high, array);
12493    } else {
12494      break;
12495    }
12496  }
12497  throw new FormatError("Invalid bf range.");
12498}
12499function parseCidChar(cMap, lexer) {
12500  while (true) {
12501    let obj = lexer.getObj();
12502    if (obj === EOF) {
12503      break;
12504    }
12505    if (isCmd(obj, "endcidchar")) {
12506      return;
12507    }
12508    expectString(obj);
12509    const src = strToInt(obj);
12510    obj = lexer.getObj();
12511    expectInt(obj);
12512    const dst = obj;
12513    cMap.mapOne(src, dst);
12514  }
12515}
12516function parseCidRange(cMap, lexer) {
12517  while (true) {
12518    let obj = lexer.getObj();
12519    if (obj === EOF) {
12520      break;
12521    }
12522    if (isCmd(obj, "endcidrange")) {
12523      return;
12524    }
12525    expectString(obj);
12526    const low = strToInt(obj);
12527    obj = lexer.getObj();
12528    expectString(obj);
12529    const high = strToInt(obj);
12530    obj = lexer.getObj();
12531    expectInt(obj);
12532    const dstLow = obj;
12533    cMap.mapCidRange(low, high, dstLow);
12534  }
12535}
12536function parseCodespaceRange(cMap, lexer) {
12537  while (true) {
12538    let obj = lexer.getObj();
12539    if (obj === EOF) {
12540      break;
12541    }
12542    if (isCmd(obj, "endcodespacerange")) {
12543      return;
12544    }
12545    if (typeof obj !== "string") {
12546      break;
12547    }
12548    const low = strToInt(obj);
12549    obj = lexer.getObj();
12550    if (typeof obj !== "string") {
12551      break;
12552    }
12553    const high = strToInt(obj);
12554    cMap.addCodespaceRange(obj.length, low, high);
12555  }
12556  throw new FormatError("Invalid codespace range.");
12557}
12558function parseWMode(cMap, lexer) {
12559  const obj = lexer.getObj();
12560  if (Number.isInteger(obj)) {
12561    cMap.vertical = !!obj;
12562  }
12563}
12564function parseCMapName(cMap, lexer) {
12565  const obj = lexer.getObj();
12566  if (obj instanceof Name) {
12567    cMap.name = obj.name;
12568  }
12569}
12570async function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
12571  let previous, embeddedUseCMap;
12572  objLoop: while (true) {
12573    try {
12574      const obj = lexer.getObj();
12575      if (obj === EOF) {
12576        break;
12577      } else if (obj instanceof Name) {
12578        if (obj.name === "WMode") {
12579          parseWMode(cMap, lexer);
12580        } else if (obj.name === "CMapName") {
12581          parseCMapName(cMap, lexer);
12582        }
12583        previous = obj;
12584      } else if (obj instanceof Cmd) {
12585        switch (obj.cmd) {
12586          case "endcmap":
12587            break objLoop;
12588          case "usecmap":
12589            if (previous instanceof Name) {
12590              embeddedUseCMap = previous.name;
12591            }
12592            break;
12593          case "begincodespacerange":
12594            parseCodespaceRange(cMap, lexer);
12595            break;
12596          case "beginbfchar":
12597            parseBfChar(cMap, lexer);
12598            break;
12599          case "begincidchar":
12600            parseCidChar(cMap, lexer);
12601            break;
12602          case "beginbfrange":
12603            parseBfRange(cMap, lexer);
12604            break;
12605          case "begincidrange":
12606            parseCidRange(cMap, lexer);
12607            break;
12608        }
12609      }
12610    } catch (ex) {
12611      if (ex instanceof MissingDataException) {
12612        throw ex;
12613      }
12614      warn("Invalid cMap data: " + ex);
12615      continue;
12616    }
12617  }
12618  if (!useCMap && embeddedUseCMap) {
12619    useCMap = embeddedUseCMap;
12620  }
12621  if (useCMap) {
12622    return extendCMap(cMap, fetchBuiltInCMap, useCMap);
12623  }
12624  return cMap;
12625}
12626async function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
12627  cMap.useCMap = await createBuiltInCMap(useCMap, fetchBuiltInCMap);
12628  if (cMap.numCodespaceRanges === 0) {
12629    const useCodespaceRanges = cMap.useCMap.codespaceRanges;
12630    for (let i = 0; i < useCodespaceRanges.length; i++) {
12631      cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
12632    }
12633    cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
12634  }
12635  cMap.useCMap.forEach(function (key, value) {
12636    if (!cMap.contains(key)) {
12637      cMap.mapOne(key, value);
12638    }
12639  });
12640  return cMap;
12641}
12642async function createBuiltInCMap(name, fetchBuiltInCMap) {
12643  if (name === "Identity-H") {
12644    return new IdentityCMap(false, 2);
12645  } else if (name === "Identity-V") {
12646    return new IdentityCMap(true, 2);
12647  }
12648  if (!BUILT_IN_CMAPS.includes(name)) {
12649    throw new Error("Unknown CMap name: " + name);
12650  }
12651  if (!fetchBuiltInCMap) {
12652    throw new Error("Built-in CMap parameters are not provided.");
12653  }
12654  const {
12655    cMapData,
12656    isCompressed
12657  } = await fetchBuiltInCMap(name);
12658  const cMap = new CMap(true);
12659  if (isCompressed) {
12660    return new BinaryCMapReader().process(cMapData, cMap, useCMap => extendCMap(cMap, fetchBuiltInCMap, useCMap));
12661  }
12662  const lexer = new Lexer(new Stream(cMapData));
12663  return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
12664}
12665class CMapFactory {
12666  static async create({
12667    encoding,
12668    fetchBuiltInCMap,
12669    useCMap
12670  }) {
12671    if (encoding instanceof Name) {
12672      return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
12673    } else if (encoding instanceof BaseStream) {
12674      if (encoding.isAsync) {
12675        const bytes = await encoding.asyncGetBytes();
12676        if (bytes) {
12677          encoding = new Stream(bytes, 0, bytes.length, encoding.dict);
12678        }
12679      }
12680      const parsedCMap = await parseCMap(new CMap(), new Lexer(encoding), fetchBuiltInCMap, useCMap);
12681      if (parsedCMap.isIdentityCMap) {
12682        return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
12683      }
12684      return parsedCMap;
12685    }
12686    throw new Error("Encoding required.");
12687  }
12688}
12689
12690;// ./src/
vendor: 9,745 bytes, lines 12690-12968
12690shared/obj_bin_transform_utils.js
12691class CSS_FONT_INFO {
12692  static strings = ["fontFamily", "fontWeight", "italicAngle"];
12693}
12694class SYSTEM_FONT_INFO {
12695  static strings = ["css", "loadedName", "baseFontName", "src"];
12696}
12697class FONT_INFO {
12698  static bools = ["black", "bold", "disableFontFace", "fontExtraProperties", "isInvalidPDFjsFont", "isType3Font", "italic", "missingFile", "remeasure", "vertical"];
12699  static numbers = ["ascent", "defaultWidth", "descent"];
12700  static strings = ["fallbackName", "loadedName", "mimetype", "name"];
12701  static OFFSET_NUMBERS = Math.ceil(this.bools.length * 2 / 8);
12702  static OFFSET_BBOX = this.OFFSET_NUMBERS + this.numbers.length * 8;
12703  static OFFSET_FONT_MATRIX = this.OFFSET_BBOX + 1 + 2 * 4;
12704  static OFFSET_DEFAULT_VMETRICS = this.OFFSET_FONT_MATRIX + 1 + 8 * 6;
12705  static OFFSET_STRINGS = this.OFFSET_DEFAULT_VMETRICS + 1 + 2 * 3;
12706}
12707class PATTERN_INFO {
12708  static KIND = 0;
12709  static HAS_BBOX = 1;
12710  static HAS_BACKGROUND = 2;
12711  static SHADING_TYPE = 3;
12712  static N_COORD = 4;
12713  static N_COLOR = 8;
12714  static N_STOP = 12;
12715  static N_FIGURES = 16;
12716}
12717
12718;// ./src/core/obj_bin_transform_core.js
12719
12720
12721function compileCssFontInfo(info) {
12722  const encoder = new TextEncoder();
12723  const encodedStrings = {};
12724  let stringsLength = 0;
12725  for (const prop of CSS_FONT_INFO.strings) {
12726    const encoded = encoder.encode(info[prop]);
12727    encodedStrings[prop] = encoded;
12728    stringsLength += 4 + encoded.length;
12729  }
12730  const buffer = new ArrayBuffer(stringsLength);
12731  const data = new Uint8Array(buffer);
12732  const view = new DataView(buffer);
12733  let offset = 0;
12734  for (const prop of CSS_FONT_INFO.strings) {
12735    const encoded = encodedStrings[prop];
12736    const length = encoded.length;
12737    view.setUint32(offset, length);
12738    data.set(encoded, offset + 4);
12739    offset += 4 + length;
12740  }
12741  assert(offset === buffer.byteLength, "compileCssFontInfo: Buffer overflow");
12742  return buffer;
12743}
12744function compileSystemFontInfo(info) {
12745  const encoder = new TextEncoder();
12746  const encodedStrings = {};
12747  let stringsLength = 0;
12748  for (const prop of SYSTEM_FONT_INFO.strings) {
12749    const encoded = encoder.encode(info[prop]);
12750    encodedStrings[prop] = encoded;
12751    stringsLength += 4 + encoded.length;
12752  }
12753  stringsLength += 4;
12754  let encodedStyleStyle,
12755    encodedStyleWeight,
12756    lengthEstimate = 1 + stringsLength;
12757  if (info.style) {
12758    encodedStyleStyle = encoder.encode(info.style.style);
12759    encodedStyleWeight = encoder.encode(info.style.weight);
12760    lengthEstimate += 4 + encodedStyleStyle.length + 4 + encodedStyleWeight.length;
12761  }
12762  const buffer = new ArrayBuffer(lengthEstimate);
12763  const data = new Uint8Array(buffer);
12764  const view = new DataView(buffer);
12765  let offset = 0;
12766  view.setUint8(offset++, info.guessFallback ? 1 : 0);
12767  view.setUint32(offset, 0);
12768  offset += 4;
12769  stringsLength = 0;
12770  for (const prop of SYSTEM_FONT_INFO.strings) {
12771    const encoded = encodedStrings[prop];
12772    const length = encoded.length;
12773    stringsLength += 4 + length;
12774    view.setUint32(offset, length);
12775    data.set(encoded, offset + 4);
12776    offset += 4 + length;
12777  }
12778  view.setUint32(offset - stringsLength - 4, stringsLength);
12779  if (info.style) {
12780    view.setUint32(offset, encodedStyleStyle.length);
12781    data.set(encodedStyleStyle, offset + 4);
12782    offset += 4 + encodedStyleStyle.length;
12783    view.setUint32(offset, encodedStyleWeight.length);
12784    data.set(encodedStyleWeight, offset + 4);
12785    offset += 4 + encodedStyleWeight.length;
12786  }
12787  assert(offset <= buffer.byteLength, "compileSystemFontInfo: Buffer overflow");
12788  return buffer.transferToFixedLength(offset);
12789}
12790function compileFontInfo(font) {
12791  const systemFontInfoBuffer = font.systemFontInfo ? compileSystemFontInfo(font.systemFontInfo) : null;
12792  const cssFontInfoBuffer = font.cssFontInfo ? compileCssFontInfo(font.cssFontInfo) : null;
12793  const encoder = new TextEncoder();
12794  const encodedStrings = {};
12795  let stringsLength = 0;
12796  for (const prop of FONT_INFO.strings) {
12797    encodedStrings[prop] = encoder.encode(font[prop]);
12798    stringsLength += 4 + encodedStrings[prop].length;
12799  }
12800  const lengthEstimate = FONT_INFO.OFFSET_STRINGS + 4 + stringsLength + 4 + (systemFontInfoBuffer?.byteLength ?? 0) + 4 + (cssFontInfoBuffer?.byteLength ?? 0) + 4 + (font.data?.length ?? 0);
12801  const buffer = new ArrayBuffer(lengthEstimate);
12802  const data = new Uint8Array(buffer);
12803  const view = new DataView(buffer);
12804  let offset = 0;
12805  const numBools = FONT_INFO.bools.length;
12806  let boolByte = 0,
12807    boolBit = 0;
12808  for (let i = 0; i < numBools; i++) {
12809    const value = font[FONT_INFO.bools[i]];
12810    const bits = value === undefined ? 0x00 : value ? 0x02 : 0x01;
12811    boolByte |= bits << boolBit;
12812    boolBit += 2;
12813    if (boolBit === 8 || i === numBools - 1) {
12814      view.setUint8(offset++, boolByte);
12815      boolByte = 0;
12816      boolBit = 0;
12817    }
12818  }
12819  assert(offset === FONT_INFO.OFFSET_NUMBERS, "compileFontInfo: Boolean properties offset mismatch");
12820  for (const prop of FONT_INFO.numbers) {
12821    view.setFloat64(offset, font[prop]);
12822    offset += 8;
12823  }
12824  assert(offset === FONT_INFO.OFFSET_BBOX, "compileFontInfo: Number properties offset mismatch");
12825  if (font.bbox) {
12826    view.setUint8(offset++, 4);
12827    for (const coord of font.bbox) {
12828      view.setInt16(offset, coord, true);
12829      offset += 2;
12830    }
12831  } else {
12832    view.setUint8(offset++, 0);
12833    offset += 2 * 4;
12834  }
12835  assert(offset === FONT_INFO.OFFSET_FONT_MATRIX, "compileFontInfo: BBox properties offset mismatch");
12836  if (font.fontMatrix) {
12837    view.setUint8(offset++, 6);
12838    for (const point of font.fontMatrix) {
12839      view.setFloat64(offset, point, true);
12840      offset += 8;
12841    }
12842  } else {
12843    view.setUint8(offset++, 0);
12844    offset += 8 * 6;
12845  }
12846  assert(offset === FONT_INFO.OFFSET_DEFAULT_VMETRICS, "compileFontInfo: FontMatrix properties offset mismatch");
12847  if (font.defaultVMetrics) {
12848    view.setUint8(offset++, 3);
12849    for (const metric of font.defaultVMetrics) {
12850      view.setInt16(offset, metric, true);
12851      offset += 2;
12852    }
12853  } else {
12854    view.setUint8(offset++, 0);
12855    offset += 3 * 2;
12856  }
12857  assert(offset === FONT_INFO.OFFSET_STRINGS, "compileFontInfo: DefaultVMetrics properties offset mismatch");
12858  view.setUint32(FONT_INFO.OFFSET_STRINGS, 0);
12859  offset += 4;
12860  for (const prop of FONT_INFO.strings) {
12861    const encoded = encodedStrings[prop];
12862    const length = encoded.length;
12863    view.setUint32(offset, length);
12864    data.set(encoded, offset + 4);
12865    offset += 4 + length;
12866  }
12867  view.setUint32(FONT_INFO.OFFSET_STRINGS, offset - FONT_INFO.OFFSET_STRINGS - 4);
12868  if (!systemFontInfoBuffer) {
12869    view.setUint32(offset, 0);
12870    offset += 4;
12871  } else {
12872    const length = systemFontInfoBuffer.byteLength;
12873    view.setUint32(offset, length);
12874    assert(offset + 4 + length <= buffer.byteLength, "compileFontInfo: Buffer overflow at systemFontInfo");
12875    data.set(new Uint8Array(systemFontInfoBuffer), offset + 4);
12876    offset += 4 + length;
12877  }
12878  if (!cssFontInfoBuffer) {
12879    view.setUint32(offset, 0);
12880    offset += 4;
12881  } else {
12882    const length = cssFontInfoBuffer.byteLength;
12883    view.setUint32(offset, length);
12884    assert(offset + 4 + length <= buffer.byteLength, "compileFontInfo: Buffer overflow at cssFontInfo");
12885    data.set(new Uint8Array(cssFontInfoBuffer), offset + 4);
12886    offset += 4 + length;
12887  }
12888  if (font.data === undefined) {
12889    view.setUint32(offset, 0);
12890    offset += 4;
12891  } else {
12892    view.setUint32(offset, font.data.length);
12893    data.set(font.data, offset + 4);
12894    offset += 4 + font.data.length;
12895  }
12896  assert(offset <= buffer.byteLength, "compileFontInfo: Buffer overflow");
12897  return buffer.transferToFixedLength(offset);
12898}
12899function compilePatternInfo(ir) {
12900  let kind,
12901    bbox = null,
12902    coords = [],
12903    colors = [],
12904    colorStops = [],
12905    shadingType = null,
12906    background = null;
12907  switch (ir[0]) {
12908    case "RadialAxial":
12909      kind = ir[1] === "axial" ? 1 : 2;
12910      bbox = ir[2];
12911      colorStops = ir[3];
12912      if (kind === 1) {
12913        coords.push(...ir[4], ...ir[5]);
12914      } else {
12915        coords.push(ir[4][0], ir[4][1], ir[6], ir[5][0], ir[5][1], ir[7]);
12916      }
12917      break;
12918    case "Mesh":
12919      kind = 3;
12920      shadingType = ir[1];
12921      coords = ir[2];
12922      colors = ir[3];
12923      bbox = ir[6];
12924      background = ir[7];
12925      break;
12926    default:
12927      throw new Error(`Unsupported pattern type: ${ir[0]}`);
12928  }
12929  const nCoord = Math.floor(coords.length / 2);
12930  const nColor = Math.floor(colors.length / 4);
12931  const nStop = colorStops.length;
12932  const byteLen = 20 + nCoord * 8 + nColor * 4 + nStop * 8 + (bbox ? 16 : 0) + (background ? 3 : 0);
12933  const buffer = new ArrayBuffer(byteLen);
12934  const dataView = new DataView(buffer);
12935  const u8data = new Uint8Array(buffer);
12936  dataView.setUint8(PATTERN_INFO.KIND, kind);
12937  dataView.setUint8(PATTERN_INFO.HAS_BBOX, bbox ? 1 : 0);
12938  dataView.setUint8(PATTERN_INFO.HAS_BACKGROUND, background ? 1 : 0);
12939  dataView.setUint8(PATTERN_INFO.SHADING_TYPE, shadingType);
12940  dataView.setUint32(PATTERN_INFO.N_COORD, nCoord, true);
12941  dataView.setUint32(PATTERN_INFO.N_COLOR, nColor, true);
12942  dataView.setUint32(PATTERN_INFO.N_STOP, nStop, true);
12943  dataView.setUint32(PATTERN_INFO.N_FIGURES, 0, true);
12944  let offset = 20;
12945  const coordsView = new Float32Array(buffer, offset, nCoord * 2);
12946  coordsView.set(coords);
12947  offset += nCoord * 8;
12948  u8data.set(colors, offset);
12949  offset += nColor * 4;
12950  for (const [pos, hex] of colorStops) {
12951    dataView.setFloat32(offset, pos, true);
12952    offset += 4;
12953    dataView.setUint32(offset, parseInt(hex.slice(1), 16), true);
12954    offset += 4;
12955  }
12956  if (bbox) {
12957    for (const v of bbox) {
12958      dataView.setFloat32(offset, v, true);
12959      offset += 4;
12960    }
12961  }
12962  if (background) {
12963    u8data.set(background, offset);
12964  }
12965  return buffer;
12966}
12967function compileFontPathInfo(path) {
12968  return path.slice().buffer;
vendor: 136,506 bytes, lines 12968-17547
12968
12969}
12970
12971;// ./src/core/encodings.js
12972const ExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "", "", "", "isuperior", "", "", "lsuperior", "msuperior", "nsuperior", "osuperior", "", "", "rsuperior", "ssuperior", "tsuperior", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdownsmall", "centoldstyle", "Lslashsmall", "", "", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "", "Dotaccentsmall", "", "", "Macronsmall", "", "", "figuredash", "hypheninferior", "", "", "Ogoneksmall", "Ringsmall", "Cedillasmall", "", "", "", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
12973const MacExpertEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclamsmall", "Hungarumlautsmall", "centoldstyle", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "", "threequartersemdash", "", "questionsmall", "", "", "", "", "Ethsmall", "", "", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "", "", "", "", "", "", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "", "parenrightinferior", "Circumflexsmall", "hypheninferior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "", "", "asuperior", "centsuperior", "", "", "", "", "Aacutesmall", "Agravesmall", "Acircumflexsmall", "Adieresissmall", "Atildesmall", "Aringsmall", "Ccedillasmall", "Eacutesmall", "Egravesmall", "Ecircumflexsmall", "Edieresissmall", "Iacutesmall", "Igravesmall", "Icircumflexsmall", "Idieresissmall", "Ntildesmall", "Oacutesmall", "Ogravesmall", "Ocircumflexsmall", "Odieresissmall", "Otildesmall", "Uacutesmall", "Ugravesmall", "Ucircumflexsmall", "Udieresissmall", "", "eightsuperior", "fourinferior", "threeinferior", "sixinferior", "eightinferior", "seveninferior", "Scaronsmall", "", "centinferior", "twoinferior", "", "Dieresissmall", "", "Caronsmall", "osuperior", "fiveinferior", "", "commainferior", "periodinferior", "Yacutesmall", "", "dollarinferior", "", "", "Thornsmall", "", "nineinferior", "zeroinferior", "Zcaronsmall", "AEsmall", "Oslashsmall", "questiondownsmall", "oneinferior", "Lslashsmall", "", "", "", "", "", "", "Cedillasmall", "", "", "", "", "", "OEsmall", "figuredash", "hyphensuperior", "", "", "", "", "exclamdownsmall", "", "Ydieresissmall", "", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "ninesuperior", "zerosuperior", "", "esuperior", "rsuperior", "tsuperior", "", "", "isuperior", "ssuperior", "dsuperior", "", "", "", "", "", "lsuperior", "Ogoneksmall", "Brevesmall", "Macronsmall", "bsuperior", "nsuperior", "msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall", "Ringsmall", "", "", "", ""];
12974const MacRomanEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "space", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron"];
12975const StandardEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "", "endash", "dagger", "daggerdbl", "periodcentered", "", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "", "questiondown", "", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "", "ring", "cedilla", "", "hungarumlaut", "ogonek", "caron", "emdash", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "AE", "", "ordfeminine", "", "", "", "", "Lslash", "Oslash", "OE", "ordmasculine", "", "", "", "", "", "ae", "", "", "", "dotlessi", "", "", "lslash", "oslash", "oe", "germandbls", "", "", "", ""];
12976const WinAnsiEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "bullet", "Euro", "bullet", "quotesinglbase", "florin", "quotedblbase", "ellipsis", "dagger", "daggerdbl", "circumflex", "perthousand", "Scaron", "guilsinglleft", "OE", "bullet", "Zcaron", "bullet", "bullet", "quoteleft", "quoteright", "quotedblleft", "quotedblright", "bullet", "endash", "emdash", "tilde", "trademark", "scaron", "guilsinglright", "oe", "bullet", "zcaron", "Ydieresis", "space", "exclamdown", "cent", "sterling", "currency", "yen", "brokenbar", "section", "dieresis", "copyright", "ordfeminine", "guillemotleft", "logicalnot", "hyphen", "registered", "macron", "degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu", "paragraph", "periodcentered", "cedilla", "onesuperior", "ordmasculine", "guillemotright", "onequarter", "onehalf", "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex", "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute", "Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex", "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex", "Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute", "Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave", "aacute", "acircumflex", "atilde", "adieresis", "aring", "ae", "ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave", "iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis"];
12977const SymbolSetEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "universal", "numbersign", "existential", "percent", "ampersand", "suchthat", "parenleft", "parenright", "asteriskmath", "plus", "comma", "minus", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "congruent", "Alpha", "Beta", "Chi", "Delta", "Epsilon", "Phi", "Gamma", "Eta", "Iota", "theta1", "Kappa", "Lambda", "Mu", "Nu", "Omicron", "Pi", "Theta", "Rho", "Sigma", "Tau", "Upsilon", "sigma1", "Omega", "Xi", "Psi", "Zeta", "bracketleft", "therefore", "bracketright", "perpendicular", "underscore", "radicalex", "alpha", "beta", "chi", "delta", "epsilon", "phi", "gamma", "eta", "iota", "phi1", "kappa", "lambda", "mu", "nu", "omicron", "pi", "theta", "rho", "sigma", "tau", "upsilon", "omega1", "omega", "xi", "psi", "zeta", "braceleft", "bar", "braceright", "similar", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Euro", "Upsilon1", "minute", "lessequal", "fraction", "infinity", "florin", "club", "diamond", "heart", "spade", "arrowboth", "arrowleft", "arrowup", "arrowright", "arrowdown", "degree", "plusminus", "second", "greaterequal", "multiply", "proportional", "partialdiff", "bullet", "divide", "notequal", "equivalence", "approxequal", "ellipsis", "arrowvertex", "arrowhorizex", "carriagereturn", "aleph", "Ifraktur", "Rfraktur", "weierstrass", "circlemultiply", "circleplus", "emptyset", "intersection", "union", "propersuperset", "reflexsuperset", "notsubset", "propersubset", "reflexsubset", "element", "notelement", "angle", "gradient", "registerserif", "copyrightserif", "trademarkserif", "product", "radical", "dotmath", "logicalnot", "logicaland", "logicalor", "arrowdblboth", "arrowdblleft", "arrowdblup", "arrowdblright", "arrowdbldown", "lozenge", "angleleft", "registersans", "copyrightsans", "trademarksans", "summation", "parenlefttp", "parenleftex", "parenleftbt", "bracketlefttp", "bracketleftex", "bracketleftbt", "bracelefttp", "braceleftmid", "braceleftbt", "braceex", "", "angleright", "integral", "integraltp", "integralex", "integralbt", "parenrighttp", "parenrightex", "parenrightbt", "bracketrighttp", "bracketrightex", "bracketrightbt", "bracerighttp", "bracerightmid", "bracerightbt", ""];
12978const ZapfDingbatsEncoding = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "a1", "a2", "a202", "a3", "a4", "a5", "a119", "a118", "a117", "a11", "a12", "a13", "a14", "a15", "a16", "a105", "a17", "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26", "a27", "a28", "a6", "a7", "a8", "a9", "a10", "a29", "a30", "a31", "a32", "a33", "a34", "a35", "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44", "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53", "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61", "a62", "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71", "a72", "a73", "a74", "a203", "a75", "a204", "a76", "a77", "a78", "a79", "a81", "a82", "a83", "a84", "a97", "a98", "a99", "a100", "", "a89", "a90", "a93", "a94", "a91", "a92", "a205", "a85", "a206", "a86", "a87", "a88", "a95", "a96", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "a101", "a102", "a103", "a104", "a106", "a107", "a108", "a112", "a111", "a110", "a109", "a120", "a121", "a122", "a123", "a124", "a125", "a126", "a127", "a128", "a129", "a130", "a131", "a132", "a133", "a134", "a135", "a136", "a137", "a138", "a139", "a140", "a141", "a142", "a143", "a144", "a145", "a146", "a147", "a148", "a149", "a150", "a151", "a152", "a153", "a154", "a155", "a156", "a157", "a158", "a159", "a160", "a161", "a163", "a164", "a196", "a165", "a192", "a166", "a167", "a168", "a169", "a170", "a171", "a172", "a173", "a162", "a174", "a175", "a176", "a177", "a178", "a179", "a193", "a180", "a199", "a181", "a200", "a182", "", "a201", "a183", "a184", "a197", "a185", "a194", "a198", "a186", "a195", "a187", "a188", "a189", "a190", "a191", ""];
12979function getEncoding(encodingName) {
12980  switch (encodingName) {
12981    case "WinAnsiEncoding":
12982      return WinAnsiEncoding;
12983    case "StandardEncoding":
12984      return StandardEncoding;
12985    case "MacRomanEncoding":
12986      return MacRomanEncoding;
12987    case "SymbolSetEncoding":
12988      return SymbolSetEncoding;
12989    case "ZapfDingbatsEncoding":
12990      return ZapfDingbatsEncoding;
12991    case "ExpertEncoding":
12992      return ExpertEncoding;
12993    case "MacExpertEncoding":
12994      return MacExpertEncoding;
12995    default:
12996      return null;
12997  }
12998}
12999
13000;// ./src/core/glyphlist.js
13001
13002const getGlyphsUnicode = getLookupTableFactory(function (t) {
13003  t.A = 0x0041;
13004  t.AE = 0x00c6;
13005  t.AEacute = 0x01fc;
13006  t.AEmacron = 0x01e2;
13007  t.AEsmall = 0xf7e6;
13008  t.Aacute = 0x00c1;
13009  t.Aacutesmall = 0xf7e1;
13010  t.Abreve = 0x0102;
13011  t.Abreveacute = 0x1eae;
13012  t.Abrevecyrillic = 0x04d0;
13013  t.Abrevedotbelow = 0x1eb6;
13014  t.Abrevegrave = 0x1eb0;
13015  t.Abrevehookabove = 0x1eb2;
13016  t.Abrevetilde = 0x1eb4;
13017  t.Acaron = 0x01cd;
13018  t.Acircle = 0x24b6;
13019  t.Acircumflex = 0x00c2;
13020  t.Acircumflexacute = 0x1ea4;
13021  t.Acircumflexdotbelow = 0x1eac;
13022  t.Acircumflexgrave = 0x1ea6;
13023  t.Acircumflexhookabove = 0x1ea8;
13024  t.Acircumflexsmall = 0xf7e2;
13025  t.Acircumflextilde = 0x1eaa;
13026  t.Acute = 0xf6c9;
13027  t.Acutesmall = 0xf7b4;
13028  t.Acyrillic = 0x0410;
13029  t.Adblgrave = 0x0200;
13030  t.Adieresis = 0x00c4;
13031  t.Adieresiscyrillic = 0x04d2;
13032  t.Adieresismacron = 0x01de;
13033  t.Adieresissmall = 0xf7e4;
13034  t.Adotbelow = 0x1ea0;
13035  t.Adotmacron = 0x01e0;
13036  t.Agrave = 0x00c0;
13037  t.Agravesmall = 0xf7e0;
13038  t.Ahookabove = 0x1ea2;
13039  t.Aiecyrillic = 0x04d4;
13040  t.Ainvertedbreve = 0x0202;
13041  t.Alpha = 0x0391;
13042  t.Alphatonos = 0x0386;
13043  t.Amacron = 0x0100;
13044  t.Amonospace = 0xff21;
13045  t.Aogonek = 0x0104;
13046  t.Aring = 0x00c5;
13047  t.Aringacute = 0x01fa;
13048  t.Aringbelow = 0x1e00;
13049  t.Aringsmall = 0xf7e5;
13050  t.Asmall = 0xf761;
13051  t.Atilde = 0x00c3;
13052  t.Atildesmall = 0xf7e3;
13053  t.Aybarmenian = 0x0531;
13054  t.B = 0x0042;
13055  t.Bcircle = 0x24b7;
13056  t.Bdotaccent = 0x1e02;
13057  t.Bdotbelow = 0x1e04;
13058  t.Becyrillic = 0x0411;
13059  t.Benarmenian = 0x0532;
13060  t.Beta = 0x0392;
13061  t.Bhook = 0x0181;
13062  t.Blinebelow = 0x1e06;
13063  t.Bmonospace = 0xff22;
13064  t.Brevesmall = 0xf6f4;
13065  t.Bsmall = 0xf762;
13066  t.Btopbar = 0x0182;
13067  t.C = 0x0043;
13068  t.Caarmenian = 0x053e;
13069  t.Cacute = 0x0106;
13070  t.Caron = 0xf6ca;
13071  t.Caronsmall = 0xf6f5;
13072  t.Ccaron = 0x010c;
13073  t.Ccedilla = 0x00c7;
13074  t.Ccedillaacute = 0x1e08;
13075  t.Ccedillasmall = 0xf7e7;
13076  t.Ccircle = 0x24b8;
13077  t.Ccircumflex = 0x0108;
13078  t.Cdot = 0x010a;
13079  t.Cdotaccent = 0x010a;
13080  t.Cedillasmall = 0xf7b8;
13081  t.Chaarmenian = 0x0549;
13082  t.Cheabkhasiancyrillic = 0x04bc;
13083  t.Checyrillic = 0x0427;
13084  t.Chedescenderabkhasiancyrillic = 0x04be;
13085  t.Chedescendercyrillic = 0x04b6;
13086  t.Chedieresiscyrillic = 0x04f4;
13087  t.Cheharmenian = 0x0543;
13088  t.Chekhakassiancyrillic = 0x04cb;
13089  t.Cheverticalstrokecyrillic = 0x04b8;
13090  t.Chi = 0x03a7;
13091  t.Chook = 0x0187;
13092  t.Circumflexsmall = 0xf6f6;
13093  t.Cmonospace = 0xff23;
13094  t.Coarmenian = 0x0551;
13095  t.Csmall = 0xf763;
13096  t.D = 0x0044;
13097  t.DZ = 0x01f1;
13098  t.DZcaron = 0x01c4;
13099  t.Daarmenian = 0x0534;
13100  t.Dafrican = 0x0189;
13101  t.Dcaron = 0x010e;
13102  t.Dcedilla = 0x1e10;
13103  t.Dcircle = 0x24b9;
13104  t.Dcircumflexbelow = 0x1e12;
13105  t.Dcroat = 0x0110;
13106  t.Ddotaccent = 0x1e0a;
13107  t.Ddotbelow = 0x1e0c;
13108  t.Decyrillic = 0x0414;
13109  t.Deicoptic = 0x03ee;
13110  t.Delta = 0x2206;
13111  t.Deltagreek = 0x0394;
13112  t.Dhook = 0x018a;
13113  t.Dieresis = 0xf6cb;
13114  t.DieresisAcute = 0xf6cc;
13115  t.DieresisGrave = 0xf6cd;
13116  t.Dieresissmall = 0xf7a8;
13117  t.Digammagreek = 0x03dc;
13118  t.Djecyrillic = 0x0402;
13119  t.Dlinebelow = 0x1e0e;
13120  t.Dmonospace = 0xff24;
13121  t.Dotaccentsmall = 0xf6f7;
13122  t.Dslash = 0x0110;
13123  t.Dsmall = 0xf764;
13124  t.Dtopbar = 0x018b;
13125  t.Dz = 0x01f2;
13126  t.Dzcaron = 0x01c5;
13127  t.Dzeabkhasiancyrillic = 0x04e0;
13128  t.Dzecyrillic = 0x0405;
13129  t.Dzhecyrillic = 0x040f;
13130  t.E = 0x0045;
13131  t.Eacute = 0x00c9;
13132  t.Eacutesmall = 0xf7e9;
13133  t.Ebreve = 0x0114;
13134  t.Ecaron = 0x011a;
13135  t.Ecedillabreve = 0x1e1c;
13136  t.Echarmenian = 0x0535;
13137  t.Ecircle = 0x24ba;
13138  t.Ecircumflex = 0x00ca;
13139  t.Ecircumflexacute = 0x1ebe;
13140  t.Ecircumflexbelow = 0x1e18;
13141  t.Ecircumflexdotbelow = 0x1ec6;
13142  t.Ecircumflexgrave = 0x1ec0;
13143  t.Ecircumflexhookabove = 0x1ec2;
13144  t.Ecircumflexsmall = 0xf7ea;
13145  t.Ecircumflextilde = 0x1ec4;
13146  t.Ecyrillic = 0x0404;
13147  t.Edblgrave = 0x0204;
13148  t.Edieresis = 0x00cb;
13149  t.Edieresissmall = 0xf7eb;
13150  t.Edot = 0x0116;
13151  t.Edotaccent = 0x0116;
13152  t.Edotbelow = 0x1eb8;
13153  t.Efcyrillic = 0x0424;
13154  t.Egrave = 0x00c8;
13155  t.Egravesmall = 0xf7e8;
13156  t.Eharmenian = 0x0537;
13157  t.Ehookabove = 0x1eba;
13158  t.Eightroman = 0x2167;
13159  t.Einvertedbreve = 0x0206;
13160  t.Eiotifiedcyrillic = 0x0464;
13161  t.Elcyrillic = 0x041b;
13162  t.Elevenroman = 0x216a;
13163  t.Emacron = 0x0112;
13164  t.Emacronacute = 0x1e16;
13165  t.Emacrongrave = 0x1e14;
13166  t.Emcyrillic = 0x041c;
13167  t.Emonospace = 0xff25;
13168  t.Encyrillic = 0x041d;
13169  t.Endescendercyrillic = 0x04a2;
13170  t.Eng = 0x014a;
13171  t.Enghecyrillic = 0x04a4;
13172  t.Enhookcyrillic = 0x04c7;
13173  t.Eogonek = 0x0118;
13174  t.Eopen = 0x0190;
13175  t.Epsilon = 0x0395;
13176  t.Epsilontonos = 0x0388;
13177  t.Ercyrillic = 0x0420;
13178  t.Ereversed = 0x018e;
13179  t.Ereversedcyrillic = 0x042d;
13180  t.Escyrillic = 0x0421;
13181  t.Esdescendercyrillic = 0x04aa;
13182  t.Esh = 0x01a9;
13183  t.Esmall = 0xf765;
13184  t.Eta = 0x0397;
13185  t.Etarmenian = 0x0538;
13186  t.Etatonos = 0x0389;
13187  t.Eth = 0x00d0;
13188  t.Ethsmall = 0xf7f0;
13189  t.Etilde = 0x1ebc;
13190  t.Etildebelow = 0x1e1a;
13191  t.Euro = 0x20ac;
13192  t.Ezh = 0x01b7;
13193  t.Ezhcaron = 0x01ee;
13194  t.Ezhreversed = 0x01b8;
13195  t.F = 0x0046;
13196  t.Fcircle = 0x24bb;
13197  t.Fdotaccent = 0x1e1e;
13198  t.Feharmenian = 0x0556;
13199  t.Feicoptic = 0x03e4;
13200  t.Fhook = 0x0191;
13201  t.Fitacyrillic = 0x0472;
13202  t.Fiveroman = 0x2164;
13203  t.Fmonospace = 0xff26;
13204  t.Fourroman = 0x2163;
13205  t.Fsmall = 0xf766;
13206  t.G = 0x0047;
13207  t.GBsquare = 0x3387;
13208  t.Gacute = 0x01f4;
13209  t.Gamma = 0x0393;
13210  t.Gammaafrican = 0x0194;
13211  t.Gangiacoptic = 0x03ea;
13212  t.Gbreve = 0x011e;
13213  t.Gcaron = 0x01e6;
13214  t.Gcedilla = 0x0122;
13215  t.Gcircle = 0x24bc;
13216  t.Gcircumflex = 0x011c;
13217  t.Gcommaaccent = 0x0122;
13218  t.Gdot = 0x0120;
13219  t.Gdotaccent = 0x0120;
13220  t.Gecyrillic = 0x0413;
13221  t.Ghadarmenian = 0x0542;
13222  t.Ghemiddlehookcyrillic = 0x0494;
13223  t.Ghestrokecyrillic = 0x0492;
13224  t.Gheupturncyrillic = 0x0490;
13225  t.Ghook = 0x0193;
13226  t.Gimarmenian = 0x0533;
13227  t.Gjecyrillic = 0x0403;
13228  t.Gmacron = 0x1e20;
13229  t.Gmonospace = 0xff27;
13230  t.Grave = 0xf6ce;
13231  t.Gravesmall = 0xf760;
13232  t.Gsmall = 0xf767;
13233  t.Gsmallhook = 0x029b;
13234  t.Gstroke = 0x01e4;
13235  t.H = 0x0048;
13236  t.H18533 = 0x25cf;
13237  t.H18543 = 0x25aa;
13238  t.H18551 = 0x25ab;
13239  t.H22073 = 0x25a1;
13240  t.HPsquare = 0x33cb;
13241  t.Haabkhasiancyrillic = 0x04a8;
13242  t.Hadescendercyrillic = 0x04b2;
13243  t.Hardsigncyrillic = 0x042a;
13244  t.Hbar = 0x0126;
13245  t.Hbrevebelow = 0x1e2a;
13246  t.Hcedilla = 0x1e28;
13247  t.Hcircle = 0x24bd;
13248  t.Hcircumflex = 0x0124;
13249  t.Hdieresis = 0x1e26;
13250  t.Hdotaccent = 0x1e22;
13251  t.Hdotbelow = 0x1e24;
13252  t.Hmonospace = 0xff28;
13253  t.Hoarmenian = 0x0540;
13254  t.Horicoptic = 0x03e8;
13255  t.Hsmall = 0xf768;
13256  t.Hungarumlaut = 0xf6cf;
13257  t.Hungarumlautsmall = 0xf6f8;
13258  t.Hzsquare = 0x3390;
13259  t.I = 0x0049;
13260  t.IAcyrillic = 0x042f;
13261  t.IJ = 0x0132;
13262  t.IUcyrillic = 0x042e;
13263  t.Iacute = 0x00cd;
13264  t.Iacutesmall = 0xf7ed;
13265  t.Ibreve = 0x012c;
13266  t.Icaron = 0x01cf;
13267  t.Icircle = 0x24be;
13268  t.Icircumflex = 0x00ce;
13269  t.Icircumflexsmall = 0xf7ee;
13270  t.Icyrillic = 0x0406;
13271  t.Idblgrave = 0x0208;
13272  t.Idieresis = 0x00cf;
13273  t.Idieresisacute = 0x1e2e;
13274  t.Idieresiscyrillic = 0x04e4;
13275  t.Idieresissmall = 0xf7ef;
13276  t.Idot = 0x0130;
13277  t.Idotaccent = 0x0130;
13278  t.Idotbelow = 0x1eca;
13279  t.Iebrevecyrillic = 0x04d6;
13280  t.Iecyrillic = 0x0415;
13281  t.Ifraktur = 0x2111;
13282  t.Igrave = 0x00cc;
13283  t.Igravesmall = 0xf7ec;
13284  t.Ihookabove = 0x1ec8;
13285  t.Iicyrillic = 0x0418;
13286  t.Iinvertedbreve = 0x020a;
13287  t.Iishortcyrillic = 0x0419;
13288  t.Imacron = 0x012a;
13289  t.Imacroncyrillic = 0x04e2;
13290  t.Imonospace = 0xff29;
13291  t.Iniarmenian = 0x053b;
13292  t.Iocyrillic = 0x0401;
13293  t.Iogonek = 0x012e;
13294  t.Iota = 0x0399;
13295  t.Iotaafrican = 0x0196;
13296  t.Iotadieresis = 0x03aa;
13297  t.Iotatonos = 0x038a;
13298  t.Ismall = 0xf769;
13299  t.Istroke = 0x0197;
13300  t.Itilde = 0x0128;
13301  t.Itildebelow = 0x1e2c;
13302  t.Izhitsacyrillic = 0x0474;
13303  t.Izhitsadblgravecyrillic = 0x0476;
13304  t.J = 0x004a;
13305  t.Jaarmenian = 0x0541;
13306  t.Jcircle = 0x24bf;
13307  t.Jcircumflex = 0x0134;
13308  t.Jecyrillic = 0x0408;
13309  t.Jheharmenian = 0x054b;
13310  t.Jmonospace = 0xff2a;
13311  t.Jsmall = 0xf76a;
13312  t.K = 0x004b;
13313  t.KBsquare = 0x3385;
13314  t.KKsquare = 0x33cd;
13315  t.Kabashkircyrillic = 0x04a0;
13316  t.Kacute = 0x1e30;
13317  t.Kacyrillic = 0x041a;
13318  t.Kadescendercyrillic = 0x049a;
13319  t.Kahookcyrillic = 0x04c3;
13320  t.Kappa = 0x039a;
13321  t.Kastrokecyrillic = 0x049e;
13322  t.Kaverticalstrokecyrillic = 0x049c;
13323  t.Kcaron = 0x01e8;
13324  t.Kcedilla = 0x0136;
13325  t.Kcircle = 0x24c0;
13326  t.Kcommaaccent = 0x0136;
13327  t.Kdotbelow = 0x1e32;
13328  t.Keharmenian = 0x0554;
13329  t.Kenarmenian = 0x053f;
13330  t.Khacyrillic = 0x0425;
13331  t.Kheicoptic = 0x03e6;
13332  t.Khook = 0x0198;
13333  t.Kjecyrillic = 0x040c;
13334  t.Klinebelow = 0x1e34;
13335  t.Kmonospace = 0xff2b;
13336  t.Koppacyrillic = 0x0480;
13337  t.Koppagreek = 0x03de;
13338  t.Ksicyrillic = 0x046e;
13339  t.Ksmall = 0xf76b;
13340  t.L = 0x004c;
13341  t.LJ = 0x01c7;
13342  t.LL = 0xf6bf;
13343  t.Lacute = 0x0139;
13344  t.Lambda = 0x039b;
13345  t.Lcaron = 0x013d;
13346  t.Lcedilla = 0x013b;
13347  t.Lcircle = 0x24c1;
13348  t.Lcircumflexbelow = 0x1e3c;
13349  t.Lcommaaccent = 0x013b;
13350  t.Ldot = 0x013f;
13351  t.Ldotaccent = 0x013f;
13352  t.Ldotbelow = 0x1e36;
13353  t.Ldotbelowmacron = 0x1e38;
13354  t.Liwnarmenian = 0x053c;
13355  t.Lj = 0x01c8;
13356  t.Ljecyrillic = 0x0409;
13357  t.Llinebelow = 0x1e3a;
13358  t.Lmonospace = 0xff2c;
13359  t.Lslash = 0x0141;
13360  t.Lslashsmall = 0xf6f9;
13361  t.Lsmall = 0xf76c;
13362  t.M = 0x004d;
13363  t.MBsquare = 0x3386;
13364  t.Macron = 0xf6d0;
13365  t.Macronsmall = 0xf7af;
13366  t.Macute = 0x1e3e;
13367  t.Mcircle = 0x24c2;
13368  t.Mdotaccent = 0x1e40;
13369  t.Mdotbelow = 0x1e42;
13370  t.Menarmenian = 0x0544;
13371  t.Mmonospace = 0xff2d;
13372  t.Msmall = 0xf76d;
13373  t.Mturned = 0x019c;
13374  t.Mu = 0x039c;
13375  t.N = 0x004e;
13376  t.NJ = 0x01ca;
13377  t.Nacute = 0x0143;
13378  t.Ncaron = 0x0147;
13379  t.Ncedilla = 0x0145;
13380  t.Ncircle = 0x24c3;
13381  t.Ncircumflexbelow = 0x1e4a;
13382  t.Ncommaaccent = 0x0145;
13383  t.Ndotaccent = 0x1e44;
13384  t.Ndotbelow = 0x1e46;
13385  t.Nhookleft = 0x019d;
13386  t.Nineroman = 0x2168;
13387  t.Nj = 0x01cb;
13388  t.Njecyrillic = 0x040a;
13389  t.Nlinebelow = 0x1e48;
13390  t.Nmonospace = 0xff2e;
13391  t.Nowarmenian = 0x0546;
13392  t.Nsmall = 0xf76e;
13393  t.Ntilde = 0x00d1;
13394  t.Ntildesmall = 0xf7f1;
13395  t.Nu = 0x039d;
13396  t.O = 0x004f;
13397  t.OE = 0x0152;
13398  t.OEsmall = 0xf6fa;
13399  t.Oacute = 0x00d3;
13400  t.Oacutesmall = 0xf7f3;
13401  t.Obarredcyrillic = 0x04e8;
13402  t.Obarreddieresiscyrillic = 0x04ea;
13403  t.Obreve = 0x014e;
13404  t.Ocaron = 0x01d1;
13405  t.Ocenteredtilde = 0x019f;
13406  t.Ocircle = 0x24c4;
13407  t.Ocircumflex = 0x00d4;
13408  t.Ocircumflexacute = 0x1ed0;
13409  t.Ocircumflexdotbelow = 0x1ed8;
13410  t.Ocircumflexgrave = 0x1ed2;
13411  t.Ocircumflexhookabove = 0x1ed4;
13412  t.Ocircumflexsmall = 0xf7f4;
13413  t.Ocircumflextilde = 0x1ed6;
13414  t.Ocyrillic = 0x041e;
13415  t.Odblacute = 0x0150;
13416  t.Odblgrave = 0x020c;
13417  t.Odieresis = 0x00d6;
13418  t.Odieresiscyrillic = 0x04e6;
13419  t.Odieresissmall = 0xf7f6;
13420  t.Odotbelow = 0x1ecc;
13421  t.Ogoneksmall = 0xf6fb;
13422  t.Ograve = 0x00d2;
13423  t.Ogravesmall = 0xf7f2;
13424  t.Oharmenian = 0x0555;
13425  t.Ohm = 0x2126;
13426  t.Ohookabove = 0x1ece;
13427  t.Ohorn = 0x01a0;
13428  t.Ohornacute = 0x1eda;
13429  t.Ohorndotbelow = 0x1ee2;
13430  t.Ohorngrave = 0x1edc;
13431  t.Ohornhookabove = 0x1ede;
13432  t.Ohorntilde = 0x1ee0;
13433  t.Ohungarumlaut = 0x0150;
13434  t.Oi = 0x01a2;
13435  t.Oinvertedbreve = 0x020e;
13436  t.Omacron = 0x014c;
13437  t.Omacronacute = 0x1e52;
13438  t.Omacrongrave = 0x1e50;
13439  t.Omega = 0x2126;
13440  t.Omegacyrillic = 0x0460;
13441  t.Omegagreek = 0x03a9;
13442  t.Omegaroundcyrillic = 0x047a;
13443  t.Omegatitlocyrillic = 0x047c;
13444  t.Omegatonos = 0x038f;
13445  t.Omicron = 0x039f;
13446  t.Omicrontonos = 0x038c;
13447  t.Omonospace = 0xff2f;
13448  t.Oneroman = 0x2160;
13449  t.Oogonek = 0x01ea;
13450  t.Oogonekmacron = 0x01ec;
13451  t.Oopen = 0x0186;
13452  t.Oslash = 0x00d8;
13453  t.Oslashacute = 0x01fe;
13454  t.Oslashsmall = 0xf7f8;
13455  t.Osmall = 0xf76f;
13456  t.Ostrokeacute = 0x01fe;
13457  t.Otcyrillic = 0x047e;
13458  t.Otilde = 0x00d5;
13459  t.Otildeacute = 0x1e4c;
13460  t.Otildedieresis = 0x1e4e;
13461  t.Otildesmall = 0xf7f5;
13462  t.P = 0x0050;
13463  t.Pacute = 0x1e54;
13464  t.Pcircle = 0x24c5;
13465  t.Pdotaccent = 0x1e56;
13466  t.Pecyrillic = 0x041f;
13467  t.Peharmenian = 0x054a;
13468  t.Pemiddlehookcyrillic = 0x04a6;
13469  t.Phi = 0x03a6;
13470  t.Phook = 0x01a4;
13471  t.Pi = 0x03a0;
13472  t.Piwrarmenian = 0x0553;
13473  t.Pmonospace = 0xff30;
13474  t.Psi = 0x03a8;
13475  t.Psicyrillic = 0x0470;
13476  t.Psmall = 0xf770;
13477  t.Q = 0x0051;
13478  t.Qcircle = 0x24c6;
13479  t.Qmonospace = 0xff31;
13480  t.Qsmall = 0xf771;
13481  t.R = 0x0052;
13482  t.Raarmenian = 0x054c;
13483  t.Racute = 0x0154;
13484  t.Rcaron = 0x0158;
13485  t.Rcedilla = 0x0156;
13486  t.Rcircle = 0x24c7;
13487  t.Rcommaaccent = 0x0156;
13488  t.Rdblgrave = 0x0210;
13489  t.Rdotaccent = 0x1e58;
13490  t.Rdotbelow = 0x1e5a;
13491  t.Rdotbelowmacron = 0x1e5c;
13492  t.Reharmenian = 0x0550;
13493  t.Rfraktur = 0x211c;
13494  t.Rho = 0x03a1;
13495  t.Ringsmall = 0xf6fc;
13496  t.Rinvertedbreve = 0x0212;
13497  t.Rlinebelow = 0x1e5e;
13498  t.Rmonospace = 0xff32;
13499  t.Rsmall = 0xf772;
13500  t.Rsmallinverted = 0x0281;
13501  t.Rsmallinvertedsuperior = 0x02b6;
13502  t.S = 0x0053;
13503  t.SF010000 = 0x250c;
13504  t.SF020000 = 0x2514;
13505  t.SF030000 = 0x2510;
13506  t.SF040000 = 0x2518;
13507  t.SF050000 = 0x253c;
13508  t.SF060000 = 0x252c;
13509  t.SF070000 = 0x2534;
13510  t.SF080000 = 0x251c;
13511  t.SF090000 = 0x2524;
13512  t.SF100000 = 0x2500;
13513  t.SF110000 = 0x2502;
13514  t.SF190000 = 0x2561;
13515  t.SF200000 = 0x2562;
13516  t.SF210000 = 0x2556;
13517  t.SF220000 = 0x2555;
13518  t.SF230000 = 0x2563;
13519  t.SF240000 = 0x2551;
13520  t.SF250000 = 0x2557;
13521  t.SF260000 = 0x255d;
13522  t.SF270000 = 0x255c;
13523  t.SF280000 = 0x255b;
13524  t.SF360000 = 0x255e;
13525  t.SF370000 = 0x255f;
13526  t.SF380000 = 0x255a;
13527  t.SF390000 = 0x2554;
13528  t.SF400000 = 0x2569;
13529  t.SF410000 = 0x2566;
13530  t.SF420000 = 0x2560;
13531  t.SF430000 = 0x2550;
13532  t.SF440000 = 0x256c;
13533  t.SF450000 = 0x2567;
13534  t.SF460000 = 0x2568;
13535  t.SF470000 = 0x2564;
13536  t.SF480000 = 0x2565;
13537  t.SF490000 = 0x2559;
13538  t.SF500000 = 0x2558;
13539  t.SF510000 = 0x2552;
13540  t.SF520000 = 0x2553;
13541  t.SF530000 = 0x256b;
13542  t.SF540000 = 0x256a;
13543  t.Sacute = 0x015a;
13544  t.Sacutedotaccent = 0x1e64;
13545  t.Sampigreek = 0x03e0;
13546  t.Scaron = 0x0160;
13547  t.Scarondotaccent = 0x1e66;
13548  t.Scaronsmall = 0xf6fd;
13549  t.Scedilla = 0x015e;
13550  t.Schwa = 0x018f;
13551  t.Schwacyrillic = 0x04d8;
13552  t.Schwadieresiscyrillic = 0x04da;
13553  t.Scircle = 0x24c8;
13554  t.Scircumflex = 0x015c;
13555  t.Scommaaccent = 0x0218;
13556  t.Sdotaccent = 0x1e60;
13557  t.Sdotbelow = 0x1e62;
13558  t.Sdotbelowdotaccent = 0x1e68;
13559  t.Seharmenian = 0x054d;
13560  t.Sevenroman = 0x2166;
13561  t.Shaarmenian = 0x0547;
13562  t.Shacyrillic = 0x0428;
13563  t.Shchacyrillic = 0x0429;
13564  t.Sheicoptic = 0x03e2;
13565  t.Shhacyrillic = 0x04ba;
13566  t.Shimacoptic = 0x03ec;
13567  t.Sigma = 0x03a3;
13568  t.Sixroman = 0x2165;
13569  t.Smonospace = 0xff33;
13570  t.Softsigncyrillic = 0x042c;
13571  t.Ssmall = 0xf773;
13572  t.Stigmagreek = 0x03da;
13573  t.T = 0x0054;
13574  t.Tau = 0x03a4;
13575  t.Tbar = 0x0166;
13576  t.Tcaron = 0x0164;
13577  t.Tcedilla = 0x0162;
13578  t.Tcircle = 0x24c9;
13579  t.Tcircumflexbelow = 0x1e70;
13580  t.Tcommaaccent = 0x0162;
13581  t.Tdotaccent = 0x1e6a;
13582  t.Tdotbelow = 0x1e6c;
13583  t.Tecyrillic = 0x0422;
13584  t.Tedescendercyrillic = 0x04ac;
13585  t.Tenroman = 0x2169;
13586  t.Tetsecyrillic = 0x04b4;
13587  t.Theta = 0x0398;
13588  t.Thook = 0x01ac;
13589  t.Thorn = 0x00de;
13590  t.Thornsmall = 0xf7fe;
13591  t.Threeroman = 0x2162;
13592  t.Tildesmall = 0xf6fe;
13593  t.Tiwnarmenian = 0x054f;
13594  t.Tlinebelow = 0x1e6e;
13595  t.Tmonospace = 0xff34;
13596  t.Toarmenian = 0x0539;
13597  t.Tonefive = 0x01bc;
13598  t.Tonesix = 0x0184;
13599  t.Tonetwo = 0x01a7;
13600  t.Tretroflexhook = 0x01ae;
13601  t.Tsecyrillic = 0x0426;
13602  t.Tshecyrillic = 0x040b;
13603  t.Tsmall = 0xf774;
13604  t.Twelveroman = 0x216b;
13605  t.Tworoman = 0x2161;
13606  t.U = 0x0055;
13607  t.Uacute = 0x00da;
13608  t.Uacutesmall = 0xf7fa;
13609  t.Ubreve = 0x016c;
13610  t.Ucaron = 0x01d3;
13611  t.Ucircle = 0x24ca;
13612  t.Ucircumflex = 0x00db;
13613  t.Ucircumflexbelow = 0x1e76;
13614  t.Ucircumflexsmall = 0xf7fb;
13615  t.Ucyrillic = 0x0423;
13616  t.Udblacute = 0x0170;
13617  t.Udblgrave = 0x0214;
13618  t.Udieresis = 0x00dc;
13619  t.Udieresisacute = 0x01d7;
13620  t.Udieresisbelow = 0x1e72;
13621  t.Udieresiscaron = 0x01d9;
13622  t.Udieresiscyrillic = 0x04f0;
13623  t.Udieresisgrave = 0x01db;
13624  t.Udieresismacron = 0x01d5;
13625  t.Udieresissmall = 0xf7fc;
13626  t.Udotbelow = 0x1ee4;
13627  t.Ugrave = 0x00d9;
13628  t.Ugravesmall = 0xf7f9;
13629  t.Uhookabove = 0x1ee6;
13630  t.Uhorn = 0x01af;
13631  t.Uhornacute = 0x1ee8;
13632  t.Uhorndotbelow = 0x1ef0;
13633  t.Uhorngrave = 0x1eea;
13634  t.Uhornhookabove = 0x1eec;
13635  t.Uhorntilde = 0x1eee;
13636  t.Uhungarumlaut = 0x0170;
13637  t.Uhungarumlautcyrillic = 0x04f2;
13638  t.Uinvertedbreve = 0x0216;
13639  t.Ukcyrillic = 0x0478;
13640  t.Umacron = 0x016a;
13641  t.Umacroncyrillic = 0x04ee;
13642  t.Umacrondieresis = 0x1e7a;
13643  t.Umonospace = 0xff35;
13644  t.Uogonek = 0x0172;
13645  t.Upsilon = 0x03a5;
13646  t.Upsilon1 = 0x03d2;
13647  t.Upsilonacutehooksymbolgreek = 0x03d3;
13648  t.Upsilonafrican = 0x01b1;
13649  t.Upsilondieresis = 0x03ab;
13650  t.Upsilondieresishooksymbolgreek = 0x03d4;
13651  t.Upsilonhooksymbol = 0x03d2;
13652  t.Upsilontonos = 0x038e;
13653  t.Uring = 0x016e;
13654  t.Ushortcyrillic = 0x040e;
13655  t.Usmall = 0xf775;
13656  t.Ustraightcyrillic = 0x04ae;
13657  t.Ustraightstrokecyrillic = 0x04b0;
13658  t.Utilde = 0x0168;
13659  t.Utildeacute = 0x1e78;
13660  t.Utildebelow = 0x1e74;
13661  t.V = 0x0056;
13662  t.Vcircle = 0x24cb;
13663  t.Vdotbelow = 0x1e7e;
13664  t.Vecyrillic = 0x0412;
13665  t.Vewarmenian = 0x054e;
13666  t.Vhook = 0x01b2;
13667  t.Vmonospace = 0xff36;
13668  t.Voarmenian = 0x0548;
13669  t.Vsmall = 0xf776;
13670  t.Vtilde = 0x1e7c;
13671  t.W = 0x0057;
13672  t.Wacute = 0x1e82;
13673  t.Wcircle = 0x24cc;
13674  t.Wcircumflex = 0x0174;
13675  t.Wdieresis = 0x1e84;
13676  t.Wdotaccent = 0x1e86;
13677  t.Wdotbelow = 0x1e88;
13678  t.Wgrave = 0x1e80;
13679  t.Wmonospace = 0xff37;
13680  t.Wsmall = 0xf777;
13681  t.X = 0x0058;
13682  t.Xcircle = 0x24cd;
13683  t.Xdieresis = 0x1e8c;
13684  t.Xdotaccent = 0x1e8a;
13685  t.Xeharmenian = 0x053d;
13686  t.Xi = 0x039e;
13687  t.Xmonospace = 0xff38;
13688  t.Xsmall = 0xf778;
13689  t.Y = 0x0059;
13690  t.Yacute = 0x00dd;
13691  t.Yacutesmall = 0xf7fd;
13692  t.Yatcyrillic = 0x0462;
13693  t.Ycircle = 0x24ce;
13694  t.Ycircumflex = 0x0176;
13695  t.Ydieresis = 0x0178;
13696  t.Ydieresissmall = 0xf7ff;
13697  t.Ydotaccent = 0x1e8e;
13698  t.Ydotbelow = 0x1ef4;
13699  t.Yericyrillic = 0x042b;
13700  t.Yerudieresiscyrillic = 0x04f8;
13701  t.Ygrave = 0x1ef2;
13702  t.Yhook = 0x01b3;
13703  t.Yhookabove = 0x1ef6;
13704  t.Yiarmenian = 0x0545;
13705  t.Yicyrillic = 0x0407;
13706  t.Yiwnarmenian = 0x0552;
13707  t.Ymonospace = 0xff39;
13708  t.Ysmall = 0xf779;
13709  t.Ytilde = 0x1ef8;
13710  t.Yusbigcyrillic = 0x046a;
13711  t.Yusbigiotifiedcyrillic = 0x046c;
13712  t.Yuslittlecyrillic = 0x0466;
13713  t.Yuslittleiotifiedcyrillic = 0x0468;
13714  t.Z = 0x005a;
13715  t.Zaarmenian = 0x0536;
13716  t.Zacute = 0x0179;
13717  t.Zcaron = 0x017d;
13718  t.Zcaronsmall = 0xf6ff;
13719  t.Zcircle = 0x24cf;
13720  t.Zcircumflex = 0x1e90;
13721  t.Zdot = 0x017b;
13722  t.Zdotaccent = 0x017b;
13723  t.Zdotbelow = 0x1e92;
13724  t.Zecyrillic = 0x0417;
13725  t.Zedescendercyrillic = 0x0498;
13726  t.Zedieresiscyrillic = 0x04de;
13727  t.Zeta = 0x0396;
13728  t.Zhearmenian = 0x053a;
13729  t.Zhebrevecyrillic = 0x04c1;
13730  t.Zhecyrillic = 0x0416;
13731  t.Zhedescendercyrillic = 0x0496;
13732  t.Zhedieresiscyrillic = 0x04dc;
13733  t.Zlinebelow = 0x1e94;
13734  t.Zmonospace = 0xff3a;
13735  t.Zsmall = 0xf77a;
13736  t.Zstroke = 0x01b5;
13737  t.a = 0x0061;
13738  t.aabengali = 0x0986;
13739  t.aacute = 0x00e1;
13740  t.aadeva = 0x0906;
13741  t.aagujarati = 0x0a86;
13742  t.aagurmukhi = 0x0a06;
13743  t.aamatragurmukhi = 0x0a3e;
13744  t.aarusquare = 0x3303;
13745  t.aavowelsignbengali = 0x09be;
13746  t.aavowelsigndeva = 0x093e;
13747  t.aavowelsigngujarati = 0x0abe;
13748  t.abbreviationmarkarmenian = 0x055f;
13749  t.abbreviationsigndeva = 0x0970;
13750  t.abengali = 0x0985;
13751  t.abopomofo = 0x311a;
13752  t.abreve = 0x0103;
13753  t.abreveacute = 0x1eaf;
13754  t.abrevecyrillic = 0x04d1;
13755  t.abrevedotbelow = 0x1eb7;
13756  t.abrevegrave = 0x1eb1;
13757  t.abrevehookabove = 0x1eb3;
13758  t.abrevetilde = 0x1eb5;
13759  t.acaron = 0x01ce;
13760  t.acircle = 0x24d0;
13761  t.acircumflex = 0x00e2;
13762  t.acircumflexacute = 0x1ea5;
13763  t.acircumflexdotbelow = 0x1ead;
13764  t.acircumflexgrave = 0x1ea7;
13765  t.acircumflexhookabove = 0x1ea9;
13766  t.acircumflextilde = 0x1eab;
13767  t.acute = 0x00b4;
13768  t.acutebelowcmb = 0x0317;
13769  t.acutecmb = 0x0301;
13770  t.acutecomb = 0x0301;
13771  t.acutedeva = 0x0954;
13772  t.acutelowmod = 0x02cf;
13773  t.acutetonecmb = 0x0341;
13774  t.acyrillic = 0x0430;
13775  t.adblgrave = 0x0201;
13776  t.addakgurmukhi = 0x0a71;
13777  t.adeva = 0x0905;
13778  t.adieresis = 0x00e4;
13779  t.adieresiscyrillic = 0x04d3;
13780  t.adieresismacron = 0x01df;
13781  t.adotbelow = 0x1ea1;
13782  t.adotmacron = 0x01e1;
13783  t.ae = 0x00e6;
13784  t.aeacute = 0x01fd;
13785  t.aekorean = 0x3150;
13786  t.aemacron = 0x01e3;
13787  t.afii00208 = 0x2015;
13788  t.afii08941 = 0x20a4;
13789  t.afii10017 = 0x0410;
13790  t.afii10018 = 0x0411;
13791  t.afii10019 = 0x0412;
13792  t.afii10020 = 0x0413;
13793  t.afii10021 = 0x0414;
13794  t.afii10022 = 0x0415;
13795  t.afii10023 = 0x0401;
13796  t.afii10024 = 0x0416;
13797  t.afii10025 = 0x0417;
13798  t.afii10026 = 0x0418;
13799  t.afii10027 = 0x0419;
13800  t.afii10028 = 0x041a;
13801  t.afii10029 = 0x041b;
13802  t.afii10030 = 0x041c;
13803  t.afii10031 = 0x041d;
13804  t.afii10032 = 0x041e;
13805  t.afii10033 = 0x041f;
13806  t.afii10034 = 0x0420;
13807  t.afii10035 = 0x0421;
13808  t.afii10036 = 0x0422;
13809  t.afii10037 = 0x0423;
13810  t.afii10038 = 0x0424;
13811  t.afii10039 = 0x0425;
13812  t.afii10040 = 0x0426;
13813  t.afii10041 = 0x0427;
13814  t.afii10042 = 0x0428;
13815  t.afii10043 = 0x0429;
13816  t.afii10044 = 0x042a;
13817  t.afii10045 = 0x042b;
13818  t.afii10046 = 0x042c;
13819  t.afii10047 = 0x042d;
13820  t.afii10048 = 0x042e;
13821  t.afii10049 = 0x042f;
13822  t.afii10050 = 0x0490;
13823  t.afii10051 = 0x0402;
13824  t.afii10052 = 0x0403;
13825  t.afii10053 = 0x0404;
13826  t.afii10054 = 0x0405;
13827  t.afii10055 = 0x0406;
13828  t.afii10056 = 0x0407;
13829  t.afii10057 = 0x0408;
13830  t.afii10058 = 0x0409;
13831  t.afii10059 = 0x040a;
13832  t.afii10060 = 0x040b;
13833  t.afii10061 = 0x040c;
13834  t.afii10062 = 0x040e;
13835  t.afii10063 = 0xf6c4;
13836  t.afii10064 = 0xf6c5;
13837  t.afii10065 = 0x0430;
13838  t.afii10066 = 0x0431;
13839  t.afii10067 = 0x0432;
13840  t.afii10068 = 0x0433;
13841  t.afii10069 = 0x0434;
13842  t.afii10070 = 0x0435;
13843  t.afii10071 = 0x0451;
13844  t.afii10072 = 0x0436;
13845  t.afii10073 = 0x0437;
13846  t.afii10074 = 0x0438;
13847  t.afii10075 = 0x0439;
13848  t.afii10076 = 0x043a;
13849  t.afii10077 = 0x043b;
13850  t.afii10078 = 0x043c;
13851  t.afii10079 = 0x043d;
13852  t.afii10080 = 0x043e;
13853  t.afii10081 = 0x043f;
13854  t.afii10082 = 0x0440;
13855  t.afii10083 = 0x0441;
13856  t.afii10084 = 0x0442;
13857  t.afii10085 = 0x0443;
13858  t.afii10086 = 0x0444;
13859  t.afii10087 = 0x0445;
13860  t.afii10088 = 0x0446;
13861  t.afii10089 = 0x0447;
13862  t.afii10090 = 0x0448;
13863  t.afii10091 = 0x0449;
13864  t.afii10092 = 0x044a;
13865  t.afii10093 = 0x044b;
13866  t.afii10094 = 0x044c;
13867  t.afii10095 = 0x044d;
13868  t.afii10096 = 0x044e;
13869  t.afii10097 = 0x044f;
13870  t.afii10098 = 0x0491;
13871  t.afii10099 = 0x0452;
13872  t.afii10100 = 0x0453;
13873  t.afii10101 = 0x0454;
13874  t.afii10102 = 0x0455;
13875  t.afii10103 = 0x0456;
13876  t.afii10104 = 0x0457;
13877  t.afii10105 = 0x0458;
13878  t.afii10106 = 0x0459;
13879  t.afii10107 = 0x045a;
13880  t.afii10108 = 0x045b;
13881  t.afii10109 = 0x045c;
13882  t.afii10110 = 0x045e;
13883  t.afii10145 = 0x040f;
13884  t.afii10146 = 0x0462;
13885  t.afii10147 = 0x0472;
13886  t.afii10148 = 0x0474;
13887  t.afii10192 = 0xf6c6;
13888  t.afii10193 = 0x045f;
13889  t.afii10194 = 0x0463;
13890  t.afii10195 = 0x0473;
13891  t.afii10196 = 0x0475;
13892  t.afii10831 = 0xf6c7;
13893  t.afii10832 = 0xf6c8;
13894  t.afii10846 = 0x04d9;
13895  t.afii299 = 0x200e;
13896  t.afii300 = 0x200f;
13897  t.afii301 = 0x200d;
13898  t.afii57381 = 0x066a;
13899  t.afii57388 = 0x060c;
13900  t.afii57392 = 0x0660;
13901  t.afii57393 = 0x0661;
13902  t.afii57394 = 0x0662;
13903  t.afii57395 = 0x0663;
13904  t.afii57396 = 0x0664;
13905  t.afii57397 = 0x0665;
13906  t.afii57398 = 0x0666;
13907  t.afii57399 = 0x0667;
13908  t.afii57400 = 0x0668;
13909  t.afii57401 = 0x0669;
13910  t.afii57403 = 0x061b;
13911  t.afii57407 = 0x061f;
13912  t.afii57409 = 0x0621;
13913  t.afii57410 = 0x0622;
13914  t.afii57411 = 0x0623;
13915  t.afii57412 = 0x0624;
13916  t.afii57413 = 0x0625;
13917  t.afii57414 = 0x0626;
13918  t.afii57415 = 0x0627;
13919  t.afii57416 = 0x0628;
13920  t.afii57417 = 0x0629;
13921  t.afii57418 = 0x062a;
13922  t.afii57419 = 0x062b;
13923  t.afii57420 = 0x062c;
13924  t.afii57421 = 0x062d;
13925  t.afii57422 = 0x062e;
13926  t.afii57423 = 0x062f;
13927  t.afii57424 = 0x0630;
13928  t.afii57425 = 0x0631;
13929  t.afii57426 = 0x0632;
13930  t.afii57427 = 0x0633;
13931  t.afii57428 = 0x0634;
13932  t.afii57429 = 0x0635;
13933  t.afii57430 = 0x0636;
13934  t.afii57431 = 0x0637;
13935  t.afii57432 = 0x0638;
13936  t.afii57433 = 0x0639;
13937  t.afii57434 = 0x063a;
13938  t.afii57440 = 0x0640;
13939  t.afii57441 = 0x0641;
13940  t.afii57442 = 0x0642;
13941  t.afii57443 = 0x0643;
13942  t.afii57444 = 0x0644;
13943  t.afii57445 = 0x0645;
13944  t.afii57446 = 0x0646;
13945  t.afii57448 = 0x0648;
13946  t.afii57449 = 0x0649;
13947  t.afii57450 = 0x064a;
13948  t.afii57451 = 0x064b;
13949  t.afii57452 = 0x064c;
13950  t.afii57453 = 0x064d;
13951  t.afii57454 = 0x064e;
13952  t.afii57455 = 0x064f;
13953  t.afii57456 = 0x0650;
13954  t.afii57457 = 0x0651;
13955  t.afii57458 = 0x0652;
13956  t.afii57470 = 0x0647;
13957  t.afii57505 = 0x06a4;
13958  t.afii57506 = 0x067e;
13959  t.afii57507 = 0x0686;
13960  t.afii57508 = 0x0698;
13961  t.afii57509 = 0x06af;
13962  t.afii57511 = 0x0679;
13963  t.afii57512 = 0x0688;
13964  t.afii57513 = 0x0691;
13965  t.afii57514 = 0x06ba;
13966  t.afii57519 = 0x06d2;
13967  t.afii57534 = 0x06d5;
13968  t.afii57636 = 0x20aa;
13969  t.afii57645 = 0x05be;
13970  t.afii57658 = 0x05c3;
13971  t.afii57664 = 0x05d0;
13972  t.afii57665 = 0x05d1;
13973  t.afii57666 = 0x05d2;
13974  t.afii57667 = 0x05d3;
13975  t.afii57668 = 0x05d4;
13976  t.afii57669 = 0x05d5;
13977  t.afii57670 = 0x05d6;
13978  t.afii57671 = 0x05d7;
13979  t.afii57672 = 0x05d8;
13980  t.afii57673 = 0x05d9;
13981  t.afii57674 = 0x05da;
13982  t.afii57675 = 0x05db;
13983  t.afii57676 = 0x05dc;
13984  t.afii57677 = 0x05dd;
13985  t.afii57678 = 0x05de;
13986  t.afii57679 = 0x05df;
13987  t.afii57680 = 0x05e0;
13988  t.afii57681 = 0x05e1;
13989  t.afii57682 = 0x05e2;
13990  t.afii57683 = 0x05e3;
13991  t.afii57684 = 0x05e4;
13992  t.afii57685 = 0x05e5;
13993  t.afii57686 = 0x05e6;
13994  t.afii57687 = 0x05e7;
13995  t.afii57688 = 0x05e8;
13996  t.afii57689 = 0x05e9;
13997  t.afii57690 = 0x05ea;
13998  t.afii57694 = 0xfb2a;
13999  t.afii57695 = 0xfb2b;
14000  t.afii57700 = 0xfb4b;
14001  t.afii57705 = 0xfb1f;
14002  t.afii57716 = 0x05f0;
14003  t.afii57717 = 0x05f1;
14004  t.afii57718 = 0x05f2;
14005  t.afii57723 = 0xfb35;
14006  t.afii57793 = 0x05b4;
14007  t.afii57794 = 0x05b5;
14008  t.afii57795 = 0x05b6;
14009  t.afii57796 = 0x05bb;
14010  t.afii57797 = 0x05b8;
14011  t.afii57798 = 0x05b7;
14012  t.afii57799 = 0x05b0;
14013  t.afii57800 = 0x05b2;
14014  t.afii57801 = 0x05b1;
14015  t.afii57802 = 0x05b3;
14016  t.afii57803 = 0x05c2;
14017  t.afii57804 = 0x05c1;
14018  t.afii57806 = 0x05b9;
14019  t.afii57807 = 0x05bc;
14020  t.afii57839 = 0x05bd;
14021  t.afii57841 = 0x05bf;
14022  t.afii57842 = 0x05c0;
14023  t.afii57929 = 0x02bc;
14024  t.afii61248 = 0x2105;
14025  t.afii61289 = 0x2113;
14026  t.afii61352 = 0x2116;
14027  t.afii61573 = 0x202c;
14028  t.afii61574 = 0x202d;
14029  t.afii61575 = 0x202e;
14030  t.afii61664 = 0x200c;
14031  t.afii63167 = 0x066d;
14032  t.afii64937 = 0x02bd;
14033  t.agrave = 0x00e0;
14034  t.agujarati = 0x0a85;
14035  t.agurmukhi = 0x0a05;
14036  t.ahiragana = 0x3042;
14037  t.ahookabove = 0x1ea3;
14038  t.aibengali = 0x0990;
14039  t.aibopomofo = 0x311e;
14040  t.aideva = 0x0910;
14041  t.aiecyrillic = 0x04d5;
14042  t.aigujarati = 0x0a90;
14043  t.aigurmukhi = 0x0a10;
14044  t.aimatragurmukhi = 0x0a48;
14045  t.ainarabic = 0x0639;
14046  t.ainfinalarabic = 0xfeca;
14047  t.aininitialarabic = 0xfecb;
14048  t.ainmedialarabic = 0xfecc;
14049  t.ainvertedbreve = 0x0203;
14050  t.aivowelsignbengali = 0x09c8;
14051  t.aivowelsigndeva = 0x0948;
14052  t.aivowelsigngujarati = 0x0ac8;
14053  t.akatakana = 0x30a2;
14054  t.akatakanahalfwidth = 0xff71;
14055  t.akorean = 0x314f;
14056  t.alef = 0x05d0;
14057  t.alefarabic = 0x0627;
14058  t.alefdageshhebrew = 0xfb30;
14059  t.aleffinalarabic = 0xfe8e;
14060  t.alefhamzaabovearabic = 0x0623;
14061  t.alefhamzaabovefinalarabic = 0xfe84;
14062  t.alefhamzabelowarabic = 0x0625;
14063  t.alefhamzabelowfinalarabic = 0xfe88;
14064  t.alefhebrew = 0x05d0;
14065  t.aleflamedhebrew = 0xfb4f;
14066  t.alefmaddaabovearabic = 0x0622;
14067  t.alefmaddaabovefinalarabic = 0xfe82;
14068  t.alefmaksuraarabic = 0x0649;
14069  t.alefmaksurafinalarabic = 0xfef0;
14070  t.alefmaksurainitialarabic = 0xfef3;
14071  t.alefmaksuramedialarabic = 0xfef4;
14072  t.alefpatahhebrew = 0xfb2e;
14073  t.alefqamatshebrew = 0xfb2f;
14074  t.aleph = 0x2135;
14075  t.allequal = 0x224c;
14076  t.alpha = 0x03b1;
14077  t.alphatonos = 0x03ac;
14078  t.amacron = 0x0101;
14079  t.amonospace = 0xff41;
14080  t.ampersand = 0x0026;
14081  t.ampersandmonospace = 0xff06;
14082  t.ampersandsmall = 0xf726;
14083  t.amsquare = 0x33c2;
14084  t.anbopomofo = 0x3122;
14085  t.angbopomofo = 0x3124;
14086  t.angbracketleft = 0x3008;
14087  t.angbracketright = 0x3009;
14088  t.angkhankhuthai = 0x0e5a;
14089  t.angle = 0x2220;
14090  t.anglebracketleft = 0x3008;
14091  t.anglebracketleftvertical = 0xfe3f;
14092  t.anglebracketright = 0x3009;
14093  t.anglebracketrightvertical = 0xfe40;
14094  t.angleleft = 0x2329;
14095  t.angleright = 0x232a;
14096  t.angstrom = 0x212b;
14097  t.anoteleia = 0x0387;
14098  t.anudattadeva = 0x0952;
14099  t.anusvarabengali = 0x0982;
14100  t.anusvaradeva = 0x0902;
14101  t.anusvaragujarati = 0x0a82;
14102  t.aogonek = 0x0105;
14103  t.apaatosquare = 0x3300;
14104  t.aparen = 0x249c;
14105  t.apostrophearmenian = 0x055a;
14106  t.apostrophemod = 0x02bc;
14107  t.apple = 0xf8ff;
14108  t.approaches = 0x2250;
14109  t.approxequal = 0x2248;
14110  t.approxequalorimage = 0x2252;
14111  t.approximatelyequal = 0x2245;
14112  t.araeaekorean = 0x318e;
14113  t.araeakorean = 0x318d;
14114  t.arc = 0x2312;
14115  t.arighthalfring = 0x1e9a;
14116  t.aring = 0x00e5;
14117  t.aringacute = 0x01fb;
14118  t.aringbelow = 0x1e01;
14119  t.arrowboth = 0x2194;
14120  t.arrowdashdown = 0x21e3;
14121  t.arrowdashleft = 0x21e0;
14122  t.arrowdashright = 0x21e2;
14123  t.arrowdashup = 0x21e1;
14124  t.arrowdblboth = 0x21d4;
14125  t.arrowdbldown = 0x21d3;
14126  t.arrowdblleft = 0x21d0;
14127  t.arrowdblright = 0x21d2;
14128  t.arrowdblup = 0x21d1;
14129  t.arrowdown = 0x2193;
14130  t.arrowdownleft = 0x2199;
14131  t.arrowdownright = 0x2198;
14132  t.arrowdownwhite = 0x21e9;
14133  t.arrowheaddownmod = 0x02c5;
14134  t.arrowheadleftmod = 0x02c2;
14135  t.arrowheadrightmod = 0x02c3;
14136  t.arrowheadupmod = 0x02c4;
14137  t.arrowhorizex = 0xf8e7;
14138  t.arrowleft = 0x2190;
14139  t.arrowleftdbl = 0x21d0;
14140  t.arrowleftdblstroke = 0x21cd;
14141  t.arrowleftoverright = 0x21c6;
14142  t.arrowleftwhite = 0x21e6;
14143  t.arrowright = 0x2192;
14144  t.arrowrightdblstroke = 0x21cf;
14145  t.arrowrightheavy = 0x279e;
14146  t.arrowrightoverleft = 0x21c4;
14147  t.arrowrightwhite = 0x21e8;
14148  t.arrowtableft = 0x21e4;
14149  t.arrowtabright = 0x21e5;
14150  t.arrowup = 0x2191;
14151  t.arrowupdn = 0x2195;
14152  t.arrowupdnbse = 0x21a8;
14153  t.arrowupdownbase = 0x21a8;
14154  t.arrowupleft = 0x2196;
14155  t.arrowupleftofdown = 0x21c5;
14156  t.arrowupright = 0x2197;
14157  t.arrowupwhite = 0x21e7;
14158  t.arrowvertex = 0xf8e6;
14159  t.asciicircum = 0x005e;
14160  t.asciicircummonospace = 0xff3e;
14161  t.asciitilde = 0x007e;
14162  t.asciitildemonospace = 0xff5e;
14163  t.ascript = 0x0251;
14164  t.ascriptturned = 0x0252;
14165  t.asmallhiragana = 0x3041;
14166  t.asmallkatakana = 0x30a1;
14167  t.asmallkatakanahalfwidth = 0xff67;
14168  t.asterisk = 0x002a;
14169  t.asteriskaltonearabic = 0x066d;
14170  t.asteriskarabic = 0x066d;
14171  t.asteriskmath = 0x2217;
14172  t.asteriskmonospace = 0xff0a;
14173  t.asterisksmall = 0xfe61;
14174  t.asterism = 0x2042;
14175  t.asuperior = 0xf6e9;
14176  t.asymptoticallyequal = 0x2243;
14177  t.at = 0x0040;
14178  t.atilde = 0x00e3;
14179  t.atmonospace = 0xff20;
14180  t.atsmall = 0xfe6b;
14181  t.aturned = 0x0250;
14182  t.aubengali = 0x0994;
14183  t.aubopomofo = 0x3120;
14184  t.audeva = 0x0914;
14185  t.augujarati = 0x0a94;
14186  t.augurmukhi = 0x0a14;
14187  t.aulengthmarkbengali = 0x09d7;
14188  t.aumatragurmukhi = 0x0a4c;
14189  t.auvowelsignbengali = 0x09cc;
14190  t.auvowelsigndeva = 0x094c;
14191  t.auvowelsigngujarati = 0x0acc;
14192  t.avagrahadeva = 0x093d;
14193  t.aybarmenian = 0x0561;
14194  t.ayin = 0x05e2;
14195  t.ayinaltonehebrew = 0xfb20;
14196  t.ayinhebrew = 0x05e2;
14197  t.b = 0x0062;
14198  t.babengali = 0x09ac;
14199  t.backslash = 0x005c;
14200  t.backslashmonospace = 0xff3c;
14201  t.badeva = 0x092c;
14202  t.bagujarati = 0x0aac;
14203  t.bagurmukhi = 0x0a2c;
14204  t.bahiragana = 0x3070;
14205  t.bahtthai = 0x0e3f;
14206  t.bakatakana = 0x30d0;
14207  t.bar = 0x007c;
14208  t.barmonospace = 0xff5c;
14209  t.bbopomofo = 0x3105;
14210  t.bcircle = 0x24d1;
14211  t.bdotaccent = 0x1e03;
14212  t.bdotbelow = 0x1e05;
14213  t.beamedsixteenthnotes = 0x266c;
14214  t.because = 0x2235;
14215  t.becyrillic = 0x0431;
14216  t.beharabic = 0x0628;
14217  t.behfinalarabic = 0xfe90;
14218  t.behinitialarabic = 0xfe91;
14219  t.behiragana = 0x3079;
14220  t.behmedialarabic = 0xfe92;
14221  t.behmeeminitialarabic = 0xfc9f;
14222  t.behmeemisolatedarabic = 0xfc08;
14223  t.behnoonfinalarabic = 0xfc6d;
14224  t.bekatakana = 0x30d9;
14225  t.benarmenian = 0x0562;
14226  t.bet = 0x05d1;
14227  t.beta = 0x03b2;
14228  t.betasymbolgreek = 0x03d0;
14229  t.betdagesh = 0xfb31;
14230  t.betdageshhebrew = 0xfb31;
14231  t.bethebrew = 0x05d1;
14232  t.betrafehebrew = 0xfb4c;
14233  t.bhabengali = 0x09ad;
14234  t.bhadeva = 0x092d;
14235  t.bhagujarati = 0x0aad;
14236  t.bhagurmukhi = 0x0a2d;
14237  t.bhook = 0x0253;
14238  t.bihiragana = 0x3073;
14239  t.bikatakana = 0x30d3;
14240  t.bilabialclick = 0x0298;
14241  t.bindigurmukhi = 0x0a02;
14242  t.birusquare = 0x3331;
14243  t.blackcircle = 0x25cf;
14244  t.blackdiamond = 0x25c6;
14245  t.blackdownpointingtriangle = 0x25bc;
14246  t.blackleftpointingpointer = 0x25c4;
14247  t.blackleftpointingtriangle = 0x25c0;
14248  t.blacklenticularbracketleft = 0x3010;
14249  t.blacklenticularbracketleftvertical = 0xfe3b;
14250  t.blacklenticularbracketright = 0x3011;
14251  t.blacklenticularbracketrightvertical = 0xfe3c;
14252  t.blacklowerlefttriangle = 0x25e3;
14253  t.blacklowerrighttriangle = 0x25e2;
14254  t.blackrectangle = 0x25ac;
14255  t.blackrightpointingpointer = 0x25ba;
14256  t.blackrightpointingtriangle = 0x25b6;
14257  t.blacksmallsquare = 0x25aa;
14258  t.blacksmilingface = 0x263b;
14259  t.blacksquare = 0x25a0;
14260  t.blackstar = 0x2605;
14261  t.blackupperlefttriangle = 0x25e4;
14262  t.blackupperrighttriangle = 0x25e5;
14263  t.blackuppointingsmalltriangle = 0x25b4;
14264  t.blackuppointingtriangle = 0x25b2;
14265  t.blank = 0x2423;
14266  t.blinebelow = 0x1e07;
14267  t.block = 0x2588;
14268  t.bmonospace = 0xff42;
14269  t.bobaimaithai = 0x0e1a;
14270  t.bohiragana = 0x307c;
14271  t.bokatakana = 0x30dc;
14272  t.bparen = 0x249d;
14273  t.bqsquare = 0x33c3;
14274  t.braceex = 0xf8f4;
14275  t.braceleft = 0x007b;
14276  t.braceleftbt = 0xf8f3;
14277  t.braceleftmid = 0xf8f2;
14278  t.braceleftmonospace = 0xff5b;
14279  t.braceleftsmall = 0xfe5b;
14280  t.bracelefttp = 0xf8f1;
14281  t.braceleftvertical = 0xfe37;
14282  t.braceright = 0x007d;
14283  t.bracerightbt = 0xf8fe;
14284  t.bracerightmid = 0xf8fd;
14285  t.bracerightmonospace = 0xff5d;
14286  t.bracerightsmall = 0xfe5c;
14287  t.bracerighttp = 0xf8fc;
14288  t.bracerightvertical = 0xfe38;
14289  t.bracketleft = 0x005b;
14290  t.bracketleftbt = 0xf8f0;
14291  t.bracketleftex = 0xf8ef;
14292  t.bracketleftmonospace = 0xff3b;
14293  t.bracketlefttp = 0xf8ee;
14294  t.bracketright = 0x005d;
14295  t.bracketrightbt = 0xf8fb;
14296  t.bracketrightex = 0xf8fa;
14297  t.bracketrightmonospace = 0xff3d;
14298  t.bracketrighttp = 0xf8f9;
14299  t.breve = 0x02d8;
14300  t.brevebelowcmb = 0x032e;
14301  t.brevecmb = 0x0306;
14302  t.breveinvertedbelowcmb = 0x032f;
14303  t.breveinvertedcmb = 0x0311;
14304  t.breveinverteddoublecmb = 0x0361;
14305  t.bridgebelowcmb = 0x032a;
14306  t.bridgeinvertedbelowcmb = 0x033a;
14307  t.brokenbar = 0x00a6;
14308  t.bstroke = 0x0180;
14309  t.bsuperior = 0xf6ea;
14310  t.btopbar = 0x0183;
14311  t.buhiragana = 0x3076;
14312  t.bukatakana = 0x30d6;
14313  t.bullet = 0x2022;
14314  t.bulletinverse = 0x25d8;
14315  t.bulletoperator = 0x2219;
14316  t.bullseye = 0x25ce;
14317  t.c = 0x0063;
14318  t.caarmenian = 0x056e;
14319  t.cabengali = 0x099a;
14320  t.cacute = 0x0107;
14321  t.cadeva = 0x091a;
14322  t.cagujarati = 0x0a9a;
14323  t.cagurmukhi = 0x0a1a;
14324  t.calsquare = 0x3388;
14325  t.candrabindubengali = 0x0981;
14326  t.candrabinducmb = 0x0310;
14327  t.candrabindudeva = 0x0901;
14328  t.candrabindugujarati = 0x0a81;
14329  t.capslock = 0x21ea;
14330  t.careof = 0x2105;
14331  t.caron = 0x02c7;
14332  t.caronbelowcmb = 0x032c;
14333  t.caroncmb = 0x030c;
14334  t.carriagereturn = 0x21b5;
14335  t.cbopomofo = 0x3118;
14336  t.ccaron = 0x010d;
14337  t.ccedilla = 0x00e7;
14338  t.ccedillaacute = 0x1e09;
14339  t.ccircle = 0x24d2;
14340  t.ccircumflex = 0x0109;
14341  t.ccurl = 0x0255;
14342  t.cdot = 0x010b;
14343  t.cdotaccent = 0x010b;
14344  t.cdsquare = 0x33c5;
14345  t.cedilla = 0x00b8;
14346  t.cedillacmb = 0x0327;
14347  t.cent = 0x00a2;
14348  t.centigrade = 0x2103;
14349  t.centinferior = 0xf6df;
14350  t.centmonospace = 0xffe0;
14351  t.centoldstyle = 0xf7a2;
14352  t.centsuperior = 0xf6e0;
14353  t.chaarmenian = 0x0579;
14354  t.chabengali = 0x099b;
14355  t.chadeva = 0x091b;
14356  t.chagujarati = 0x0a9b;
14357  t.chagurmukhi = 0x0a1b;
14358  t.chbopomofo = 0x3114;
14359  t.cheabkhasiancyrillic = 0x04bd;
14360  t.checkmark = 0x2713;
14361  t.checyrillic = 0x0447;
14362  t.chedescenderabkhasiancyrillic = 0x04bf;
14363  t.chedescendercyrillic = 0x04b7;
14364  t.chedieresiscyrillic = 0x04f5;
14365  t.cheharmenian = 0x0573;
14366  t.chekhakassiancyrillic = 0x04cc;
14367  t.cheverticalstrokecyrillic = 0x04b9;
14368  t.chi = 0x03c7;
14369  t.chieuchacirclekorean = 0x3277;
14370  t.chieuchaparenkorean = 0x3217;
14371  t.chieuchcirclekorean = 0x3269;
14372  t.chieuchkorean = 0x314a;
14373  t.chieuchparenkorean = 0x3209;
14374  t.chochangthai = 0x0e0a;
14375  t.chochanthai = 0x0e08;
14376  t.chochingthai = 0x0e09;
14377  t.chochoethai = 0x0e0c;
14378  t.chook = 0x0188;
14379  t.cieucacirclekorean = 0x3276;
14380  t.cieucaparenkorean = 0x3216;
14381  t.cieuccirclekorean = 0x3268;
14382  t.cieuckorean = 0x3148;
14383  t.cieucparenkorean = 0x3208;
14384  t.cieucuparenkorean = 0x321c;
14385  t.circle = 0x25cb;
14386  t.circlecopyrt = 0x00a9;
14387  t.circlemultiply = 0x2297;
14388  t.circleot = 0x2299;
14389  t.circleplus = 0x2295;
14390  t.circlepostalmark = 0x3036;
14391  t.circlewithlefthalfblack = 0x25d0;
14392  t.circlewithrighthalfblack = 0x25d1;
14393  t.circumflex = 0x02c6;
14394  t.circumflexbelowcmb = 0x032d;
14395  t.circumflexcmb = 0x0302;
14396  t.clear = 0x2327;
14397  t.clickalveolar = 0x01c2;
14398  t.clickdental = 0x01c0;
14399  t.clicklateral = 0x01c1;
14400  t.clickretroflex = 0x01c3;
14401  t.club = 0x2663;
14402  t.clubsuitblack = 0x2663;
14403  t.clubsuitwhite = 0x2667;
14404  t.cmcubedsquare = 0x33a4;
14405  t.cmonospace = 0xff43;
14406  t.cmsquaredsquare = 0x33a0;
14407  t.coarmenian = 0x0581;
14408  t.colon = 0x003a;
14409  t.colonmonetary = 0x20a1;
14410  t.colonmonospace = 0xff1a;
14411  t.colonsign = 0x20a1;
14412  t.colonsmall = 0xfe55;
14413  t.colontriangularhalfmod = 0x02d1;
14414  t.colontriangularmod = 0x02d0;
14415  t.comma = 0x002c;
14416  t.commaabovecmb = 0x0313;
14417  t.commaaboverightcmb = 0x0315;
14418  t.commaaccent = 0xf6c3;
14419  t.commaarabic = 0x060c;
14420  t.commaarmenian = 0x055d;
14421  t.commainferior = 0xf6e1;
14422  t.commamonospace = 0xff0c;
14423  t.commareversedabovecmb = 0x0314;
14424  t.commareversedmod = 0x02bd;
14425  t.commasmall = 0xfe50;
14426  t.commasuperior = 0xf6e2;
14427  t.commaturnedabovecmb = 0x0312;
14428  t.commaturnedmod = 0x02bb;
14429  t.compass = 0x263c;
14430  t.congruent = 0x2245;
14431  t.contourintegral = 0x222e;
14432  t.control = 0x2303;
14433  t.controlACK = 0x0006;
14434  t.controlBEL = 0x0007;
14435  t.controlBS = 0x0008;
14436  t.controlCAN = 0x0018;
14437  t.controlCR = 0x000d;
14438  t.controlDC1 = 0x0011;
14439  t.controlDC2 = 0x0012;
14440  t.controlDC3 = 0x0013;
14441  t.controlDC4 = 0x0014;
14442  t.controlDEL = 0x007f;
14443  t.controlDLE = 0x0010;
14444  t.controlEM = 0x0019;
14445  t.controlENQ = 0x0005;
14446  t.controlEOT = 0x0004;
14447  t.controlESC = 0x001b;
14448  t.controlETB = 0x0017;
14449  t.controlETX = 0x0003;
14450  t.controlFF = 0x000c;
14451  t.controlFS = 0x001c;
14452  t.controlGS = 0x001d;
14453  t.controlHT = 0x0009;
14454  t.controlLF = 0x000a;
14455  t.controlNAK = 0x0015;
14456  t.controlNULL = 0x0000;
14457  t.controlRS = 0x001e;
14458  t.controlSI = 0x000f;
14459  t.controlSO = 0x000e;
14460  t.controlSOT = 0x0002;
14461  t.controlSTX = 0x0001;
14462  t.controlSUB = 0x001a;
14463  t.controlSYN = 0x0016;
14464  t.controlUS = 0x001f;
14465  t.controlVT = 0x000b;
14466  t.copyright = 0x00a9;
14467  t.copyrightsans = 0xf8e9;
14468  t.copyrightserif = 0xf6d9;
14469  t.cornerbracketleft = 0x300c;
14470  t.cornerbracketlefthalfwidth = 0xff62;
14471  t.cornerbracketleftvertical = 0xfe41;
14472  t.cornerbracketright = 0x300d;
14473  t.cornerbracketrighthalfwidth = 0xff63;
14474  t.cornerbracketrightvertical = 0xfe42;
14475  t.corporationsquare = 0x337f;
14476  t.cosquare = 0x33c7;
14477  t.coverkgsquare = 0x33c6;
14478  t.cparen = 0x249e;
14479  t.cruzeiro = 0x20a2;
14480  t.cstretched = 0x0297;
14481  t.curlyand = 0x22cf;
14482  t.curlyor = 0x22ce;
14483  t.currency = 0x00a4;
14484  t.cyrBreve = 0xf6d1;
14485  t.cyrFlex = 0xf6d2;
14486  t.cyrbreve = 0xf6d4;
14487  t.cyrflex = 0xf6d5;
14488  t.d = 0x0064;
14489  t.daarmenian = 0x0564;
14490  t.dabengali = 0x09a6;
14491  t.dadarabic = 0x0636;
14492  t.dadeva = 0x0926;
14493  t.dadfinalarabic = 0xfebe;
14494  t.dadinitialarabic = 0xfebf;
14495  t.dadmedialarabic = 0xfec0;
14496  t.dagesh = 0x05bc;
14497  t.dageshhebrew = 0x05bc;
14498  t.dagger = 0x2020;
14499  t.daggerdbl = 0x2021;
14500  t.dagujarati = 0x0aa6;
14501  t.dagurmukhi = 0x0a26;
14502  t.dahiragana = 0x3060;
14503  t.dakatakana = 0x30c0;
14504  t.dalarabic = 0x062f;
14505  t.dalet = 0x05d3;
14506  t.daletdagesh = 0xfb33;
14507  t.daletdageshhebrew = 0xfb33;
14508  t.dalethebrew = 0x05d3;
14509  t.dalfinalarabic = 0xfeaa;
14510  t.dammaarabic = 0x064f;
14511  t.dammalowarabic = 0x064f;
14512  t.dammatanaltonearabic = 0x064c;
14513  t.dammatanarabic = 0x064c;
14514  t.danda = 0x0964;
14515  t.dargahebrew = 0x05a7;
14516  t.dargalefthebrew = 0x05a7;
14517  t.dasiapneumatacyrilliccmb = 0x0485;
14518  t.dblGrave = 0xf6d3;
14519  t.dblanglebracketleft = 0x300a;
14520  t.dblanglebracketleftvertical = 0xfe3d;
14521  t.dblanglebracketright = 0x300b;
14522  t.dblanglebracketrightvertical = 0xfe3e;
14523  t.dblarchinvertedbelowcmb = 0x032b;
14524  t.dblarrowleft = 0x21d4;
14525  t.dblarrowright = 0x21d2;
14526  t.dbldanda = 0x0965;
14527  t.dblgrave = 0xf6d6;
14528  t.dblgravecmb = 0x030f;
14529  t.dblintegral = 0x222c;
14530  t.dbllowline = 0x2017;
14531  t.dbllowlinecmb = 0x0333;
14532  t.dbloverlinecmb = 0x033f;
14533  t.dblprimemod = 0x02ba;
14534  t.dblverticalbar = 0x2016;
14535  t.dblverticallineabovecmb = 0x030e;
14536  t.dbopomofo = 0x3109;
14537  t.dbsquare = 0x33c8;
14538  t.dcaron = 0x010f;
14539  t.dcedilla = 0x1e11;
14540  t.dcircle = 0x24d3;
14541  t.dcircumflexbelow = 0x1e13;
14542  t.dcroat = 0x0111;
14543  t.ddabengali = 0x09a1;
14544  t.ddadeva = 0x0921;
14545  t.ddagujarati = 0x0aa1;
14546  t.ddagurmukhi = 0x0a21;
14547  t.ddalarabic = 0x0688;
14548  t.ddalfinalarabic = 0xfb89;
14549  t.dddhadeva = 0x095c;
14550  t.ddhabengali = 0x09a2;
14551  t.ddhadeva = 0x0922;
14552  t.ddhagujarati = 0x0aa2;
14553  t.ddhagurmukhi = 0x0a22;
14554  t.ddotaccent = 0x1e0b;
14555  t.ddotbelow = 0x1e0d;
14556  t.decimalseparatorarabic = 0x066b;
14557  t.decimalseparatorpersian = 0x066b;
14558  t.decyrillic = 0x0434;
14559  t.degree = 0x00b0;
14560  t.dehihebrew = 0x05ad;
14561  t.dehiragana = 0x3067;
14562  t.deicoptic = 0x03ef;
14563  t.dekatakana = 0x30c7;
14564  t.deleteleft = 0x232b;
14565  t.deleteright = 0x2326;
14566  t.delta = 0x03b4;
14567  t.deltaturned = 0x018d;
14568  t.denominatorminusonenumeratorbengali = 0x09f8;
14569  t.dezh = 0x02a4;
14570  t.dhabengali = 0x09a7;
14571  t.dhadeva = 0x0927;
14572  t.dhagujarati = 0x0aa7;
14573  t.dhagurmukhi = 0x0a27;
14574  t.dhook = 0x0257;
14575  t.dialytikatonos = 0x0385;
14576  t.dialytikatonoscmb = 0x0344;
14577  t.diamond = 0x2666;
14578  t.diamondsuitwhite = 0x2662;
14579  t.dieresis = 0x00a8;
14580  t.dieresisacute = 0xf6d7;
14581  t.dieresisbelowcmb = 0x0324;
14582  t.dieresiscmb = 0x0308;
14583  t.dieresisgrave = 0xf6d8;
14584  t.dieresistonos = 0x0385;
14585  t.dihiragana = 0x3062;
14586  t.dikatakana = 0x30c2;
14587  t.dittomark = 0x3003;
14588  t.divide = 0x00f7;
14589  t.divides = 0x2223;
14590  t.divisionslash = 0x2215;
14591  t.djecyrillic = 0x0452;
14592  t.dkshade = 0x2593;
14593  t.dlinebelow = 0x1e0f;
14594  t.dlsquare = 0x3397;
14595  t.dmacron = 0x0111;
14596  t.dmonospace = 0xff44;
14597  t.dnblock = 0x2584;
14598  t.dochadathai = 0x0e0e;
14599  t.dodekthai = 0x0e14;
14600  t.dohiragana = 0x3069;
14601  t.dokatakana = 0x30c9;
14602  t.dollar = 0x0024;
14603  t.dollarinferior = 0xf6e3;
14604  t.dollarmonospace = 0xff04;
14605  t.dollaroldstyle = 0xf724;
14606  t.dollarsmall = 0xfe69;
14607  t.dollarsuperior = 0xf6e4;
14608  t.dong = 0x20ab;
14609  t.dorusquare = 0x3326;
14610  t.dotaccent = 0x02d9;
14611  t.dotaccentcmb = 0x0307;
14612  t.dotbelowcmb = 0x0323;
14613  t.dotbelowcomb = 0x0323;
14614  t.dotkatakana = 0x30fb;
14615  t.dotlessi = 0x0131;
14616  t.dotlessj = 0xf6be;
14617  t.dotlessjstrokehook = 0x0284;
14618  t.dotmath = 0x22c5;
14619  t.dottedcircle = 0x25cc;
14620  t.doubleyodpatah = 0xfb1f;
14621  t.doubleyodpatahhebrew = 0xfb1f;
14622  t.downtackbelowcmb = 0x031e;
14623  t.downtackmod = 0x02d5;
14624  t.dparen = 0x249f;
14625  t.dsuperior = 0xf6eb;
14626  t.dtail = 0x0256;
14627  t.dtopbar = 0x018c;
14628  t.duhiragana = 0x3065;
14629  t.dukatakana = 0x30c5;
14630  t.dz = 0x01f3;
14631  t.dzaltone = 0x02a3;
14632  t.dzcaron = 0x01c6;
14633  t.dzcurl = 0x02a5;
14634  t.dzeabkhasiancyrillic = 0x04e1;
14635  t.dzecyrillic = 0x0455;
14636  t.dzhecyrillic = 0x045f;
14637  t.e = 0x0065;
14638  t.eacute = 0x00e9;
14639  t.earth = 0x2641;
14640  t.ebengali = 0x098f;
14641  t.ebopomofo = 0x311c;
14642  t.ebreve = 0x0115;
14643  t.ecandradeva = 0x090d;
14644  t.ecandragujarati = 0x0a8d;
14645  t.ecandravowelsigndeva = 0x0945;
14646  t.ecandravowelsigngujarati = 0x0ac5;
14647  t.ecaron = 0x011b;
14648  t.ecedillabreve = 0x1e1d;
14649  t.echarmenian = 0x0565;
14650  t.echyiwnarmenian = 0x0587;
14651  t.ecircle = 0x24d4;
14652  t.ecircumflex = 0x00ea;
14653  t.ecircumflexacute = 0x1ebf;
14654  t.ecircumflexbelow = 0x1e19;
14655  t.ecircumflexdotbelow = 0x1ec7;
14656  t.ecircumflexgrave = 0x1ec1;
14657  t.ecircumflexhookabove = 0x1ec3;
14658  t.ecircumflextilde = 0x1ec5;
14659  t.ecyrillic = 0x0454;
14660  t.edblgrave = 0x0205;
14661  t.edeva = 0x090f;
14662  t.edieresis = 0x00eb;
14663  t.edot = 0x0117;
14664  t.edotaccent = 0x0117;
14665  t.edotbelow = 0x1eb9;
14666  t.eegurmukhi = 0x0a0f;
14667  t.eematragurmukhi = 0x0a47;
14668  t.efcyrillic = 0x0444;
14669  t.egrave = 0x00e8;
14670  t.egujarati = 0x0a8f;
14671  t.eharmenian = 0x0567;
14672  t.ehbopomofo = 0x311d;
14673  t.ehiragana = 0x3048;
14674  t.ehookabove = 0x1ebb;
14675  t.eibopomofo = 0x311f;
14676  t.eight = 0x0038;
14677  t.eightarabic = 0x0668;
14678  t.eightbengali = 0x09ee;
14679  t.eightcircle = 0x2467;
14680  t.eightcircleinversesansserif = 0x2791;
14681  t.eightdeva = 0x096e;
14682  t.eighteencircle = 0x2471;
14683  t.eighteenparen = 0x2485;
14684  t.eighteenperiod = 0x2499;
14685  t.eightgujarati = 0x0aee;
14686  t.eightgurmukhi = 0x0a6e;
14687  t.eighthackarabic = 0x0668;
14688  t.eighthangzhou = 0x3028;
14689  t.eighthnotebeamed = 0x266b;
14690  t.eightideographicparen = 0x3227;
14691  t.eightinferior = 0x2088;
14692  t.eightmonospace = 0xff18;
14693  t.eightoldstyle = 0xf738;
14694  t.eightparen = 0x247b;
14695  t.eightperiod = 0x248f;
14696  t.eightpersian = 0x06f8;
14697  t.eightroman = 0x2177;
14698  t.eightsuperior = 0x2078;
14699  t.eightthai = 0x0e58;
14700  t.einvertedbreve = 0x0207;
14701  t.eiotifiedcyrillic = 0x0465;
14702  t.ekatakana = 0x30a8;
14703  t.ekatakanahalfwidth = 0xff74;
14704  t.ekonkargurmukhi = 0x0a74;
14705  t.ekorean = 0x3154;
14706  t.elcyrillic = 0x043b;
14707  t.element = 0x2208;
14708  t.elevencircle = 0x246a;
14709  t.elevenparen = 0x247e;
14710  t.elevenperiod = 0x2492;
14711  t.elevenroman = 0x217a;
14712  t.ellipsis = 0x2026;
14713  t.ellipsisvertical = 0x22ee;
14714  t.emacron = 0x0113;
14715  t.emacronacute = 0x1e17;
14716  t.emacrongrave = 0x1e15;
14717  t.emcyrillic = 0x043c;
14718  t.emdash = 0x2014;
14719  t.emdashvertical = 0xfe31;
14720  t.emonospace = 0xff45;
14721  t.emphasismarkarmenian = 0x055b;
14722  t.emptyset = 0x2205;
14723  t.enbopomofo = 0x3123;
14724  t.encyrillic = 0x043d;
14725  t.endash = 0x2013;
14726  t.endashvertical = 0xfe32;
14727  t.endescendercyrillic = 0x04a3;
14728  t.eng = 0x014b;
14729  t.engbopomofo = 0x3125;
14730  t.enghecyrillic = 0x04a5;
14731  t.enhookcyrillic = 0x04c8;
14732  t.enspace = 0x2002;
14733  t.eogonek = 0x0119;
14734  t.eokorean = 0x3153;
14735  t.eopen = 0x025b;
14736  t.eopenclosed = 0x029a;
14737  t.eopenreversed = 0x025c;
14738  t.eopenreversedclosed = 0x025e;
14739  t.eopenreversedhook = 0x025d;
14740  t.eparen = 0x24a0;
14741  t.epsilon = 0x03b5;
14742  t.epsilontonos = 0x03ad;
14743  t.equal = 0x003d;
14744  t.equalmonospace = 0xff1d;
14745  t.equalsmall = 0xfe66;
14746  t.equalsuperior = 0x207c;
14747  t.equivalence = 0x2261;
14748  t.erbopomofo = 0x3126;
14749  t.ercyrillic = 0x0440;
14750  t.ereversed = 0x0258;
14751  t.ereversedcyrillic = 0x044d;
14752  t.escyrillic = 0x0441;
14753  t.esdescendercyrillic = 0x04ab;
14754  t.esh = 0x0283;
14755  t.eshcurl = 0x0286;
14756  t.eshortdeva = 0x090e;
14757  t.eshortvowelsigndeva = 0x0946;
14758  t.eshreversedloop = 0x01aa;
14759  t.eshsquatreversed = 0x0285;
14760  t.esmallhiragana = 0x3047;
14761  t.esmallkatakana = 0x30a7;
14762  t.esmallkatakanahalfwidth = 0xff6a;
14763  t.estimated = 0x212e;
14764  t.esuperior = 0xf6ec;
14765  t.eta = 0x03b7;
14766  t.etarmenian = 0x0568;
14767  t.etatonos = 0x03ae;
14768  t.eth = 0x00f0;
14769  t.etilde = 0x1ebd;
14770  t.etildebelow = 0x1e1b;
14771  t.etnahtafoukhhebrew = 0x0591;
14772  t.etnahtafoukhlefthebrew = 0x0591;
14773  t.etnahtahebrew = 0x0591;
14774  t.etnahtalefthebrew = 0x0591;
14775  t.eturned = 0x01dd;
14776  t.eukorean = 0x3161;
14777  t.euro = 0x20ac;
14778  t.evowelsignbengali = 0x09c7;
14779  t.evowelsigndeva = 0x0947;
14780  t.evowelsigngujarati = 0x0ac7;
14781  t.exclam = 0x0021;
14782  t.exclamarmenian = 0x055c;
14783  t.exclamdbl = 0x203c;
14784  t.exclamdown = 0x00a1;
14785  t.exclamdownsmall = 0xf7a1;
14786  t.exclammonospace = 0xff01;
14787  t.exclamsmall = 0xf721;
14788  t.existential = 0x2203;
14789  t.ezh = 0x0292;
14790  t.ezhcaron = 0x01ef;
14791  t.ezhcurl = 0x0293;
14792  t.ezhreversed = 0x01b9;
14793  t.ezhtail = 0x01ba;
14794  t.f = 0x0066;
14795  t.fadeva = 0x095e;
14796  t.fagurmukhi = 0x0a5e;
14797  t.fahrenheit = 0x2109;
14798  t.fathaarabic = 0x064e;
14799  t.fathalowarabic = 0x064e;
14800  t.fathatanarabic = 0x064b;
14801  t.fbopomofo = 0x3108;
14802  t.fcircle = 0x24d5;
14803  t.fdotaccent = 0x1e1f;
14804  t.feharabic = 0x0641;
14805  t.feharmenian = 0x0586;
14806  t.fehfinalarabic = 0xfed2;
14807  t.fehinitialarabic = 0xfed3;
14808  t.fehmedialarabic = 0xfed4;
14809  t.feicoptic = 0x03e5;
14810  t.female = 0x2640;
14811  t.ff = 0xfb00;
14812  t.f_f = 0xfb00;
14813  t.ffi = 0xfb03;
14814  t.f_f_i = 0xfb03;
14815  t.ffl = 0xfb04;
14816  t.f_f_l = 0xfb04;
14817  t.fi = 0xfb01;
14818  t.f_i = 0xfb01;
14819  t.fifteencircle = 0x246e;
14820  t.fifteenparen = 0x2482;
14821  t.fifteenperiod = 0x2496;
14822  t.figuredash = 0x2012;
14823  t.filledbox = 0x25a0;
14824  t.filledrect = 0x25ac;
14825  t.finalkaf = 0x05da;
14826  t.finalkafdagesh = 0xfb3a;
14827  t.finalkafdageshhebrew = 0xfb3a;
14828  t.finalkafhebrew = 0x05da;
14829  t.finalmem = 0x05dd;
14830  t.finalmemhebrew = 0x05dd;
14831  t.finalnun = 0x05df;
14832  t.finalnunhebrew = 0x05df;
14833  t.finalpe = 0x05e3;
14834  t.finalpehebrew = 0x05e3;
14835  t.finaltsadi = 0x05e5;
14836  t.finaltsadihebrew = 0x05e5;
14837  t.firsttonechinese = 0x02c9;
14838  t.fisheye = 0x25c9;
14839  t.fitacyrillic = 0x0473;
14840  t.five = 0x0035;
14841  t.fivearabic = 0x0665;
14842  t.fivebengali = 0x09eb;
14843  t.fivecircle = 0x2464;
14844  t.fivecircleinversesansserif = 0x278e;
14845  t.fivedeva = 0x096b;
14846  t.fiveeighths = 0x215d;
14847  t.fivegujarati = 0x0aeb;
14848  t.fivegurmukhi = 0x0a6b;
14849  t.fivehackarabic = 0x0665;
14850  t.fivehangzhou = 0x3025;
14851  t.fiveideographicparen = 0x3224;
14852  t.fiveinferior = 0x2085;
14853  t.fivemonospace = 0xff15;
14854  t.fiveoldstyle = 0xf735;
14855  t.fiveparen = 0x2478;
14856  t.fiveperiod = 0x248c;
14857  t.fivepersian = 0x06f5;
14858  t.fiveroman = 0x2174;
14859  t.fivesuperior = 0x2075;
14860  t.fivethai = 0x0e55;
14861  t.fl = 0xfb02;
14862  t.f_l = 0xfb02;
14863  t.florin = 0x0192;
14864  t.fmonospace = 0xff46;
14865  t.fmsquare = 0x3399;
14866  t.fofanthai = 0x0e1f;
14867  t.fofathai = 0x0e1d;
14868  t.fongmanthai = 0x0e4f;
14869  t.forall = 0x2200;
14870  t.four = 0x0034;
14871  t.fourarabic = 0x0664;
14872  t.fourbengali = 0x09ea;
14873  t.fourcircle = 0x2463;
14874  t.fourcircleinversesansserif = 0x278d;
14875  t.fourdeva = 0x096a;
14876  t.fourgujarati = 0x0aea;
14877  t.fourgurmukhi = 0x0a6a;
14878  t.fourhackarabic = 0x0664;
14879  t.fourhangzhou = 0x3024;
14880  t.fourideographicparen = 0x3223;
14881  t.fourinferior = 0x2084;
14882  t.fourmonospace = 0xff14;
14883  t.fournumeratorbengali = 0x09f7;
14884  t.fouroldstyle = 0xf734;
14885  t.fourparen = 0x2477;
14886  t.fourperiod = 0x248b;
14887  t.fourpersian = 0x06f4;
14888  t.fourroman = 0x2173;
14889  t.foursuperior = 0x2074;
14890  t.fourteencircle = 0x246d;
14891  t.fourteenparen = 0x2481;
14892  t.fourteenperiod = 0x2495;
14893  t.fourthai = 0x0e54;
14894  t.fourthtonechinese = 0x02cb;
14895  t.fparen = 0x24a1;
14896  t.fraction = 0x2044;
14897  t.franc = 0x20a3;
14898  t.g = 0x0067;
14899  t.gabengali = 0x0997;
14900  t.gacute = 0x01f5;
14901  t.gadeva = 0x0917;
14902  t.gafarabic = 0x06af;
14903  t.gaffinalarabic = 0xfb93;
14904  t.gafinitialarabic = 0xfb94;
14905  t.gafmedialarabic = 0xfb95;
14906  t.gagujarati = 0x0a97;
14907  t.gagurmukhi = 0x0a17;
14908  t.gahiragana = 0x304c;
14909  t.gakatakana = 0x30ac;
14910  t.gamma = 0x03b3;
14911  t.gammalatinsmall = 0x0263;
14912  t.gammasuperior = 0x02e0;
14913  t.gangiacoptic = 0x03eb;
14914  t.gbopomofo = 0x310d;
14915  t.gbreve = 0x011f;
14916  t.gcaron = 0x01e7;
14917  t.gcedilla = 0x0123;
14918  t.gcircle = 0x24d6;
14919  t.gcircumflex = 0x011d;
14920  t.gcommaaccent = 0x0123;
14921  t.gdot = 0x0121;
14922  t.gdotaccent = 0x0121;
14923  t.gecyrillic = 0x0433;
14924  t.gehiragana = 0x3052;
14925  t.gekatakana = 0x30b2;
14926  t.geometricallyequal = 0x2251;
14927  t.gereshaccenthebrew = 0x059c;
14928  t.gereshhebrew = 0x05f3;
14929  t.gereshmuqdamhebrew = 0x059d;
14930  t.germandbls = 0x00df;
14931  t.gershayimaccenthebrew = 0x059e;
14932  t.gershayimhebrew = 0x05f4;
14933  t.getamark = 0x3013;
14934  t.ghabengali = 0x0998;
14935  t.ghadarmenian = 0x0572;
14936  t.ghadeva = 0x0918;
14937  t.ghagujarati = 0x0a98;
14938  t.ghagurmukhi = 0x0a18;
14939  t.ghainarabic = 0x063a;
14940  t.ghainfinalarabic = 0xfece;
14941  t.ghaininitialarabic = 0xfecf;
14942  t.ghainmedialarabic = 0xfed0;
14943  t.ghemiddlehookcyrillic = 0x0495;
14944  t.ghestrokecyrillic = 0x0493;
14945  t.gheupturncyrillic = 0x0491;
14946  t.ghhadeva = 0x095a;
14947  t.ghhagurmukhi = 0x0a5a;
14948  t.ghook = 0x0260;
14949  t.ghzsquare = 0x3393;
14950  t.gihiragana = 0x304e;
14951  t.gikatakana = 0x30ae;
14952  t.gimarmenian = 0x0563;
14953  t.gimel = 0x05d2;
14954  t.gimeldagesh = 0xfb32;
14955  t.gimeldageshhebrew = 0xfb32;
14956  t.gimelhebrew = 0x05d2;
14957  t.gjecyrillic = 0x0453;
14958  t.glottalinvertedstroke = 0x01be;
14959  t.glottalstop = 0x0294;
14960  t.glottalstopinverted = 0x0296;
14961  t.glottalstopmod = 0x02c0;
14962  t.glottalstopreversed = 0x0295;
14963  t.glottalstopreversedmod = 0x02c1;
14964  t.glottalstopreversedsuperior = 0x02e4;
14965  t.glottalstopstroke = 0x02a1;
14966  t.glottalstopstrokereversed = 0x02a2;
14967  t.gmacron = 0x1e21;
14968  t.gmonospace = 0xff47;
14969  t.gohiragana = 0x3054;
14970  t.gokatakana = 0x30b4;
14971  t.gparen = 0x24a2;
14972  t.gpasquare = 0x33ac;
14973  t.gradient = 0x2207;
14974  t.grave = 0x0060;
14975  t.gravebelowcmb = 0x0316;
14976  t.gravecmb = 0x0300;
14977  t.gravecomb = 0x0300;
14978  t.gravedeva = 0x0953;
14979  t.gravelowmod = 0x02ce;
14980  t.gravemonospace = 0xff40;
14981  t.gravetonecmb = 0x0340;
14982  t.greater = 0x003e;
14983  t.greaterequal = 0x2265;
14984  t.greaterequalorless = 0x22db;
14985  t.greatermonospace = 0xff1e;
14986  t.greaterorequivalent = 0x2273;
14987  t.greaterorless = 0x2277;
14988  t.greateroverequal = 0x2267;
14989  t.greatersmall = 0xfe65;
14990  t.gscript = 0x0261;
14991  t.gstroke = 0x01e5;
14992  t.guhiragana = 0x3050;
14993  t.guillemotleft = 0x00ab;
14994  t.guillemotright = 0x00bb;
14995  t.guilsinglleft = 0x2039;
14996  t.guilsinglright = 0x203a;
14997  t.gukatakana = 0x30b0;
14998  t.guramusquare = 0x3318;
14999  t.gysquare = 0x33c9;
15000  t.h = 0x0068;
15001  t.haabkhasiancyrillic = 0x04a9;
15002  t.haaltonearabic = 0x06c1;
15003  t.habengali = 0x09b9;
15004  t.hadescendercyrillic = 0x04b3;
15005  t.hadeva = 0x0939;
15006  t.hagujarati = 0x0ab9;
15007  t.hagurmukhi = 0x0a39;
15008  t.haharabic = 0x062d;
15009  t.hahfinalarabic = 0xfea2;
15010  t.hahinitialarabic = 0xfea3;
15011  t.hahiragana = 0x306f;
15012  t.hahmedialarabic = 0xfea4;
15013  t.haitusquare = 0x332a;
15014  t.hakatakana = 0x30cf;
15015  t.hakatakanahalfwidth = 0xff8a;
15016  t.halantgurmukhi = 0x0a4d;
15017  t.hamzaarabic = 0x0621;
15018  t.hamzalowarabic = 0x0621;
15019  t.hangulfiller = 0x3164;
15020  t.hardsigncyrillic = 0x044a;
15021  t.harpoonleftbarbup = 0x21bc;
15022  t.harpoonrightbarbup = 0x21c0;
15023  t.hasquare = 0x33ca;
15024  t.hatafpatah = 0x05b2;
15025  t.hatafpatah16 = 0x05b2;
15026  t.hatafpatah23 = 0x05b2;
15027  t.hatafpatah2f = 0x05b2;
15028  t.hatafpatahhebrew = 0x05b2;
15029  t.hatafpatahnarrowhebrew = 0x05b2;
15030  t.hatafpatahquarterhebrew = 0x05b2;
15031  t.hatafpatahwidehebrew = 0x05b2;
15032  t.hatafqamats = 0x05b3;
15033  t.hatafqamats1b = 0x05b3;
15034  t.hatafqamats28 = 0x05b3;
15035  t.hatafqamats34 = 0x05b3;
15036  t.hatafqamatshebrew = 0x05b3;
15037  t.hatafqamatsnarrowhebrew = 0x05b3;
15038  t.hatafqamatsquarterhebrew = 0x05b3;
15039  t.hatafqamatswidehebrew = 0x05b3;
15040  t.hatafsegol = 0x05b1;
15041  t.hatafsegol17 = 0x05b1;
15042  t.hatafsegol24 = 0x05b1;
15043  t.hatafsegol30 = 0x05b1;
15044  t.hatafsegolhebrew = 0x05b1;
15045  t.hatafsegolnarrowhebrew = 0x05b1;
15046  t.hatafsegolquarterhebrew = 0x05b1;
15047  t.hatafsegolwidehebrew = 0x05b1;
15048  t.hbar = 0x0127;
15049  t.hbopomofo = 0x310f;
15050  t.hbrevebelow = 0x1e2b;
15051  t.hcedilla = 0x1e29;
15052  t.hcircle = 0x24d7;
15053  t.hcircumflex = 0x0125;
15054  t.hdieresis = 0x1e27;
15055  t.hdotaccent = 0x1e23;
15056  t.hdotbelow = 0x1e25;
15057  t.he = 0x05d4;
15058  t.heart = 0x2665;
15059  t.heartsuitblack = 0x2665;
15060  t.heartsuitwhite = 0x2661;
15061  t.hedagesh = 0xfb34;
15062  t.hedageshhebrew = 0xfb34;
15063  t.hehaltonearabic = 0x06c1;
15064  t.heharabic = 0x0647;
15065  t.hehebrew = 0x05d4;
15066  t.hehfinalaltonearabic = 0xfba7;
15067  t.hehfinalalttwoarabic = 0xfeea;
15068  t.hehfinalarabic = 0xfeea;
15069  t.hehhamzaabovefinalarabic = 0xfba5;
15070  t.hehhamzaaboveisolatedarabic = 0xfba4;
15071  t.hehinitialaltonearabic = 0xfba8;
15072  t.hehinitialarabic = 0xfeeb;
15073  t.hehiragana = 0x3078;
15074  t.hehmedialaltonearabic = 0xfba9;
15075  t.hehmedialarabic = 0xfeec;
15076  t.heiseierasquare = 0x337b;
15077  t.hekatakana = 0x30d8;
15078  t.hekatakanahalfwidth = 0xff8d;
15079  t.hekutaarusquare = 0x3336;
15080  t.henghook = 0x0267;
15081  t.herutusquare = 0x3339;
15082  t.het = 0x05d7;
15083  t.hethebrew = 0x05d7;
15084  t.hhook = 0x0266;
15085  t.hhooksuperior = 0x02b1;
15086  t.hieuhacirclekorean = 0x327b;
15087  t.hieuhaparenkorean = 0x321b;
15088  t.hieuhcirclekorean = 0x326d;
15089  t.hieuhkorean = 0x314e;
15090  t.hieuhparenkorean = 0x320d;
15091  t.hihiragana = 0x3072;
15092  t.hikatakana = 0x30d2;
15093  t.hikatakanahalfwidth = 0xff8b;
15094  t.hiriq = 0x05b4;
15095  t.hiriq14 = 0x05b4;
15096  t.hiriq21 = 0x05b4;
15097  t.hiriq2d = 0x05b4;
15098  t.hiriqhebrew = 0x05b4;
15099  t.hiriqnarrowhebrew = 0x05b4;
15100  t.hiriqquarterhebrew = 0x05b4;
15101  t.hiriqwidehebrew = 0x05b4;
15102  t.hlinebelow = 0x1e96;
15103  t.hmonospace = 0xff48;
15104  t.hoarmenian = 0x0570;
15105  t.hohipthai = 0x0e2b;
15106  t.hohiragana = 0x307b;
15107  t.hokatakana = 0x30db;
15108  t.hokatakanahalfwidth = 0xff8e;
15109  t.holam = 0x05b9;
15110  t.holam19 = 0x05b9;
15111  t.holam26 = 0x05b9;
15112  t.holam32 = 0x05b9;
15113  t.holamhebrew = 0x05b9;
15114  t.holamnarrowhebrew = 0x05b9;
15115  t.holamquarterhebrew = 0x05b9;
15116  t.holamwidehebrew = 0x05b9;
15117  t.honokhukthai = 0x0e2e;
15118  t.hookabovecomb = 0x0309;
15119  t.hookcmb = 0x0309;
15120  t.hookpalatalizedbelowcmb = 0x0321;
15121  t.hookretroflexbelowcmb = 0x0322;
15122  t.hoonsquare = 0x3342;
15123  t.horicoptic = 0x03e9;
15124  t.horizontalbar = 0x2015;
15125  t.horncmb = 0x031b;
15126  t.hotsprings = 0x2668;
15127  t.house = 0x2302;
15128  t.hparen = 0x24a3;
15129  t.hsuperior = 0x02b0;
15130  t.hturned = 0x0265;
15131  t.huhiragana = 0x3075;
15132  t.huiitosquare = 0x3333;
15133  t.hukatakana = 0x30d5;
15134  t.hukatakanahalfwidth = 0xff8c;
15135  t.hungarumlaut = 0x02dd;
15136  t.hungarumlautcmb = 0x030b;
15137  t.hv = 0x0195;
15138  t.hyphen = 0x002d;
15139  t.hypheninferior = 0xf6e5;
15140  t.hyphenmonospace = 0xff0d;
15141  t.hyphensmall = 0xfe63;
15142  t.hyphensuperior = 0xf6e6;
15143  t.hyphentwo = 0x2010;
15144  t.i = 0x0069;
15145  t.iacute = 0x00ed;
15146  t.iacyrillic = 0x044f;
15147  t.ibengali = 0x0987;
15148  t.ibopomofo = 0x3127;
15149  t.ibreve = 0x012d;
15150  t.icaron = 0x01d0;
15151  t.icircle = 0x24d8;
15152  t.icircumflex = 0x00ee;
15153  t.icyrillic = 0x0456;
15154  t.idblgrave = 0x0209;
15155  t.ideographearthcircle = 0x328f;
15156  t.ideographfirecircle = 0x328b;
15157  t.ideographicallianceparen = 0x323f;
15158  t.ideographiccallparen = 0x323a;
15159  t.ideographiccentrecircle = 0x32a5;
15160  t.ideographicclose = 0x3006;
15161  t.ideographiccomma = 0x3001;
15162  t.ideographiccommaleft = 0xff64;
15163  t.ideographiccongratulationparen = 0x3237;
15164  t.ideographiccorrectcircle = 0x32a3;
15165  t.ideographicearthparen = 0x322f;
15166  t.ideographicenterpriseparen = 0x323d;
15167  t.ideographicexcellentcircle = 0x329d;
15168  t.ideographicfestivalparen = 0x3240;
15169  t.ideographicfinancialcircle = 0x3296;
15170  t.ideographicfinancialparen = 0x3236;
15171  t.ideographicfireparen = 0x322b;
15172  t.ideographichaveparen = 0x3232;
15173  t.ideographichighcircle = 0x32a4;
15174  t.ideographiciterationmark = 0x3005;
15175  t.ideographiclaborcircle = 0x3298;
15176  t.ideographiclaborparen = 0x3238;
15177  t.ideographicleftcircle = 0x32a7;
15178  t.ideographiclowcircle = 0x32a6;
15179  t.ideographicmedicinecircle = 0x32a9;
15180  t.ideographicmetalparen = 0x322e;
15181  t.ideographicmoonparen = 0x322a;
15182  t.ideographicnameparen = 0x3234;
15183  t.ideographicperiod = 0x3002;
15184  t.ideographicprintcircle = 0x329e;
15185  t.ideographicreachparen = 0x3243;
15186  t.ideographicrepresentparen = 0x3239;
15187  t.ideographicresourceparen = 0x323e;
15188  t.ideographicrightcircle = 0x32a8;
15189  t.ideographicsecretcircle = 0x3299;
15190  t.ideographicselfparen = 0x3242;
15191  t.ideographicsocietyparen = 0x3233;
15192  t.ideographicspace = 0x3000;
15193  t.ideographicspecialparen = 0x3235;
15194  t.ideographicstockparen = 0x3231;
15195  t.ideographicstudyparen = 0x323b;
15196  t.ideographicsunparen = 0x3230;
15197  t.ideographicsuperviseparen = 0x323c;
15198  t.ideographicwaterparen = 0x322c;
15199  t.ideographicwoodparen = 0x322d;
15200  t.ideographiczero = 0x3007;
15201  t.ideographmetalcircle = 0x328e;
15202  t.ideographmooncircle = 0x328a;
15203  t.ideographnamecircle = 0x3294;
15204  t.ideographsuncircle = 0x3290;
15205  t.ideographwatercircle = 0x328c;
15206  t.ideographwoodcircle = 0x328d;
15207  t.ideva = 0x0907;
15208  t.idieresis = 0x00ef;
15209  t.idieresisacute = 0x1e2f;
15210  t.idieresiscyrillic = 0x04e5;
15211  t.idotbelow = 0x1ecb;
15212  t.iebrevecyrillic = 0x04d7;
15213  t.iecyrillic = 0x0435;
15214  t.ieungacirclekorean = 0x3275;
15215  t.ieungaparenkorean = 0x3215;
15216  t.ieungcirclekorean = 0x3267;
15217  t.ieungkorean = 0x3147;
15218  t.ieungparenkorean = 0x3207;
15219  t.igrave = 0x00ec;
15220  t.igujarati = 0x0a87;
15221  t.igurmukhi = 0x0a07;
15222  t.ihiragana = 0x3044;
15223  t.ihookabove = 0x1ec9;
15224  t.iibengali = 0x0988;
15225  t.iicyrillic = 0x0438;
15226  t.iideva = 0x0908;
15227  t.iigujarati = 0x0a88;
15228  t.iigurmukhi = 0x0a08;
15229  t.iimatragurmukhi = 0x0a40;
15230  t.iinvertedbreve = 0x020b;
15231  t.iishortcyrillic = 0x0439;
15232  t.iivowelsignbengali = 0x09c0;
15233  t.iivowelsigndeva = 0x0940;
15234  t.iivowelsigngujarati = 0x0ac0;
15235  t.ij = 0x0133;
15236  t.ikatakana = 0x30a4;
15237  t.ikatakanahalfwidth = 0xff72;
15238  t.ikorean = 0x3163;
15239  t.ilde = 0x02dc;
15240  t.iluyhebrew = 0x05ac;
15241  t.imacron = 0x012b;
15242  t.imacroncyrillic = 0x04e3;
15243  t.imageorapproximatelyequal = 0x2253;
15244  t.imatragurmukhi = 0x0a3f;
15245  t.imonospace = 0xff49;
15246  t.increment = 0x2206;
15247  t.infinity = 0x221e;
15248  t.iniarmenian = 0x056b;
15249  t.integral = 0x222b;
15250  t.integralbottom = 0x2321;
15251  t.integralbt = 0x2321;
15252  t.integralex = 0xf8f5;
15253  t.integraltop = 0x2320;
15254  t.integraltp = 0x2320;
15255  t.intersection = 0x2229;
15256  t.intisquare = 0x3305;
15257  t.invbullet = 0x25d8;
15258  t.invcircle = 0x25d9;
15259  t.invsmileface = 0x263b;
15260  t.iocyrillic = 0x0451;
15261  t.iogonek = 0x012f;
15262  t.iota = 0x03b9;
15263  t.iotadieresis = 0x03ca;
15264  t.iotadieresistonos = 0x0390;
15265  t.iotalatin = 0x0269;
15266  t.iotatonos = 0x03af;
15267  t.iparen = 0x24a4;
15268  t.irigurmukhi = 0x0a72;
15269  t.ismallhiragana = 0x3043;
15270  t.ismallkatakana = 0x30a3;
15271  t.ismallkatakanahalfwidth = 0xff68;
15272  t.issharbengali = 0x09fa;
15273  t.istroke = 0x0268;
15274  t.isuperior = 0xf6ed;
15275  t.iterationhiragana = 0x309d;
15276  t.iterationkatakana = 0x30fd;
15277  t.itilde = 0x0129;
15278  t.itildebelow = 0x1e2d;
15279  t.iubopomofo = 0x3129;
15280  t.iucyrillic = 0x044e;
15281  t.ivowelsignbengali = 0x09bf;
15282  t.ivowelsigndeva = 0x093f;
15283  t.ivowelsigngujarati = 0x0abf;
15284  t.izhitsacyrillic = 0x0475;
15285  t.izhitsadblgravecyrillic = 0x0477;
15286  t.j = 0x006a;
15287  t.jaarmenian = 0x0571;
15288  t.jabengali = 0x099c;
15289  t.jadeva = 0x091c;
15290  t.jagujarati = 0x0a9c;
15291  t.jagurmukhi = 0x0a1c;
15292  t.jbopomofo = 0x3110;
15293  t.jcaron = 0x01f0;
15294  t.jcircle = 0x24d9;
15295  t.jcircumflex = 0x0135;
15296  t.jcrossedtail = 0x029d;
15297  t.jdotlessstroke = 0x025f;
15298  t.jecyrillic = 0x0458;
15299  t.jeemarabic = 0x062c;
15300  t.jeemfinalarabic = 0xfe9e;
15301  t.jeeminitialarabic = 0xfe9f;
15302  t.jeemmedialarabic = 0xfea0;
15303  t.jeharabic = 0x0698;
15304  t.jehfinalarabic = 0xfb8b;
15305  t.jhabengali = 0x099d;
15306  t.jhadeva = 0x091d;
15307  t.jhagujarati = 0x0a9d;
15308  t.jhagurmukhi = 0x0a1d;
15309  t.jheharmenian = 0x057b;
15310  t.jis = 0x3004;
15311  t.jmonospace = 0xff4a;
15312  t.jparen = 0x24a5;
15313  t.jsuperior = 0x02b2;
15314  t.k = 0x006b;
15315  t.kabashkircyrillic = 0x04a1;
15316  t.kabengali = 0x0995;
15317  t.kacute = 0x1e31;
15318  t.kacyrillic = 0x043a;
15319  t.kadescendercyrillic = 0x049b;
15320  t.kadeva = 0x0915;
15321  t.kaf = 0x05db;
15322  t.kafarabic = 0x0643;
15323  t.kafdagesh = 0xfb3b;
15324  t.kafdageshhebrew = 0xfb3b;
15325  t.kaffinalarabic = 0xfeda;
15326  t.kafhebrew = 0x05db;
15327  t.kafinitialarabic = 0xfedb;
15328  t.kafmedialarabic = 0xfedc;
15329  t.kafrafehebrew = 0xfb4d;
15330  t.kagujarati = 0x0a95;
15331  t.kagurmukhi = 0x0a15;
15332  t.kahiragana = 0x304b;
15333  t.kahookcyrillic = 0x04c4;
15334  t.kakatakana = 0x30ab;
15335  t.kakatakanahalfwidth = 0xff76;
15336  t.kappa = 0x03ba;
15337  t.kappasymbolgreek = 0x03f0;
15338  t.kapyeounmieumkorean = 0x3171;
15339  t.kapyeounphieuphkorean = 0x3184;
15340  t.kapyeounpieupkorean = 0x3178;
15341  t.kapyeounssangpieupkorean = 0x3179;
15342  t.karoriisquare = 0x330d;
15343  t.kashidaautoarabic = 0x0640;
15344  t.kashidaautonosidebearingarabic = 0x0640;
15345  t.kasmallkatakana = 0x30f5;
15346  t.kasquare = 0x3384;
15347  t.kasraarabic = 0x0650;
15348  t.kasratanarabic = 0x064d;
15349  t.kastrokecyrillic = 0x049f;
15350  t.katahiraprolongmarkhalfwidth = 0xff70;
15351  t.kaverticalstrokecyrillic = 0x049d;
15352  t.kbopomofo = 0x310e;
15353  t.kcalsquare = 0x3389;
15354  t.kcaron = 0x01e9;
15355  t.kcedilla = 0x0137;
15356  t.kcircle = 0x24da;
15357  t.kcommaaccent = 0x0137;
15358  t.kdotbelow = 0x1e33;
15359  t.keharmenian = 0x0584;
15360  t.kehiragana = 0x3051;
15361  t.kekatakana = 0x30b1;
15362  t.kekatakanahalfwidth = 0xff79;
15363  t.kenarmenian = 0x056f;
15364  t.kesmallkatakana = 0x30f6;
15365  t.kgreenlandic = 0x0138;
15366  t.khabengali = 0x0996;
15367  t.khacyrillic = 0x0445;
15368  t.khadeva = 0x0916;
15369  t.khagujarati = 0x0a96;
15370  t.khagurmukhi = 0x0a16;
15371  t.khaharabic = 0x062e;
15372  t.khahfinalarabic = 0xfea6;
15373  t.khahinitialarabic = 0xfea7;
15374  t.khahmedialarabic = 0xfea8;
15375  t.kheicoptic = 0x03e7;
15376  t.khhadeva = 0x0959;
15377  t.khhagurmukhi = 0x0a59;
15378  t.khieukhacirclekorean = 0x3278;
15379  t.khieukhaparenkorean = 0x3218;
15380  t.khieukhcirclekorean = 0x326a;
15381  t.khieukhkorean = 0x314b;
15382  t.khieukhparenkorean = 0x320a;
15383  t.khokhaithai = 0x0e02;
15384  t.khokhonthai = 0x0e05;
15385  t.khokhuatthai = 0x0e03;
15386  t.khokhwaithai = 0x0e04;
15387  t.khomutthai = 0x0e5b;
15388  t.khook = 0x0199;
15389  t.khorakhangthai = 0x0e06;
15390  t.khzsquare = 0x3391;
15391  t.kihiragana = 0x304d;
15392  t.kikatakana = 0x30ad;
15393  t.kikatakanahalfwidth = 0xff77;
15394  t.kiroguramusquare = 0x3315;
15395  t.kiromeetorusquare = 0x3316;
15396  t.kirosquare = 0x3314;
15397  t.kiyeokacirclekorean = 0x326e;
15398  t.kiyeokaparenkorean = 0x320e;
15399  t.kiyeokcirclekorean = 0x3260;
15400  t.kiyeokkorean = 0x3131;
15401  t.kiyeokparenkorean = 0x3200;
15402  t.kiyeoksioskorean = 0x3133;
15403  t.kjecyrillic = 0x045c;
15404  t.klinebelow = 0x1e35;
15405  t.klsquare = 0x3398;
15406  t.kmcubedsquare = 0x33a6;
15407  t.kmonospace = 0xff4b;
15408  t.kmsquaredsquare = 0x33a2;
15409  t.kohiragana = 0x3053;
15410  t.kohmsquare = 0x33c0;
15411  t.kokaithai = 0x0e01;
15412  t.kokatakana = 0x30b3;
15413  t.kokatakanahalfwidth = 0xff7a;
15414  t.kooposquare = 0x331e;
15415  t.koppacyrillic = 0x0481;
15416  t.koreanstandardsymbol = 0x327f;
15417  t.koroniscmb = 0x0343;
15418  t.kparen = 0x24a6;
15419  t.kpasquare = 0x33aa;
15420  t.ksicyrillic = 0x046f;
15421  t.ktsquare = 0x33cf;
15422  t.kturned = 0x029e;
15423  t.kuhiragana = 0x304f;
15424  t.kukatakana = 0x30af;
15425  t.kukatakanahalfwidth = 0xff78;
15426  t.kvsquare = 0x33b8;
15427  t.kwsquare = 0x33be;
15428  t.l = 0x006c;
15429  t.labengali = 0x09b2;
15430  t.lacute = 0x013a;
15431  t.ladeva = 0x0932;
15432  t.lagujarati = 0x0ab2;
15433  t.lagurmukhi = 0x0a32;
15434  t.lakkhangyaothai = 0x0e45;
15435  t.lamaleffinalarabic = 0xfefc;
15436  t.lamalefhamzaabovefinalarabic = 0xfef8;
15437  t.lamalefhamzaaboveisolatedarabic = 0xfef7;
15438  t.lamalefhamzabelowfinalarabic = 0xfefa;
15439  t.lamalefhamzabelowisolatedarabic = 0xfef9;
15440  t.lamalefisolatedarabic = 0xfefb;
15441  t.lamalefmaddaabovefinalarabic = 0xfef6;
15442  t.lamalefmaddaaboveisolatedarabic = 0xfef5;
15443  t.lamarabic = 0x0644;
15444  t.lambda = 0x03bb;
15445  t.lambdastroke = 0x019b;
15446  t.lamed = 0x05dc;
15447  t.lameddagesh = 0xfb3c;
15448  t.lameddageshhebrew = 0xfb3c;
15449  t.lamedhebrew = 0x05dc;
15450  t.lamfinalarabic = 0xfede;
15451  t.lamhahinitialarabic = 0xfcca;
15452  t.laminitialarabic = 0xfedf;
15453  t.lamjeeminitialarabic = 0xfcc9;
15454  t.lamkhahinitialarabic = 0xfccb;
15455  t.lamlamhehisolatedarabic = 0xfdf2;
15456  t.lammedialarabic = 0xfee0;
15457  t.lammeemhahinitialarabic = 0xfd88;
15458  t.lammeeminitialarabic = 0xfccc;
15459  t.largecircle = 0x25ef;
15460  t.lbar = 0x019a;
15461  t.lbelt = 0x026c;
15462  t.lbopomofo = 0x310c;
15463  t.lcaron = 0x013e;
15464  t.lcedilla = 0x013c;
15465  t.lcircle = 0x24db;
15466  t.lcircumflexbelow = 0x1e3d;
15467  t.lcommaaccent = 0x013c;
15468  t.ldot = 0x0140;
15469  t.ldotaccent = 0x0140;
15470  t.ldotbelow = 0x1e37;
15471  t.ldotbelowmacron = 0x1e39;
15472  t.leftangleabovecmb = 0x031a;
15473  t.lefttackbelowcmb = 0x0318;
15474  t.less = 0x003c;
15475  t.lessequal = 0x2264;
15476  t.lessequalorgreater = 0x22da;
15477  t.lessmonospace = 0xff1c;
15478  t.lessorequivalent = 0x2272;
15479  t.lessorgreater = 0x2276;
15480  t.lessoverequal = 0x2266;
15481  t.lesssmall = 0xfe64;
15482  t.lezh = 0x026e;
15483  t.lfblock = 0x258c;
15484  t.lhookretroflex = 0x026d;
15485  t.lira = 0x20a4;
15486  t.liwnarmenian = 0x056c;
15487  t.lj = 0x01c9;
15488  t.ljecyrillic = 0x0459;
15489  t.ll = 0xf6c0;
15490  t.lladeva = 0x0933;
15491  t.llagujarati = 0x0ab3;
15492  t.llinebelow = 0x1e3b;
15493  t.llladeva = 0x0934;
15494  t.llvocalicbengali = 0x09e1;
15495  t.llvocalicdeva = 0x0961;
15496  t.llvocalicvowelsignbengali = 0x09e3;
15497  t.llvocalicvowelsigndeva = 0x0963;
15498  t.lmiddletilde = 0x026b;
15499  t.lmonospace = 0xff4c;
15500  t.lmsquare = 0x33d0;
15501  t.lochulathai = 0x0e2c;
15502  t.logicaland = 0x2227;
15503  t.logicalnot = 0x00ac;
15504  t.logicalnotreversed = 0x2310;
15505  t.logicalor = 0x2228;
15506  t.lolingthai = 0x0e25;
15507  t.longs = 0x017f;
15508  t.lowlinecenterline = 0xfe4e;
15509  t.lowlinecmb = 0x0332;
15510  t.lowlinedashed = 0xfe4d;
15511  t.lozenge = 0x25ca;
15512  t.lparen = 0x24a7;
15513  t.lslash = 0x0142;
15514  t.lsquare = 0x2113;
15515  t.lsuperior = 0xf6ee;
15516  t.ltshade = 0x2591;
15517  t.luthai = 0x0e26;
15518  t.lvocalicbengali = 0x098c;
15519  t.lvocalicdeva = 0x090c;
15520  t.lvocalicvowelsignbengali = 0x09e2;
15521  t.lvocalicvowelsigndeva = 0x0962;
15522  t.lxsquare = 0x33d3;
15523  t.m = 0x006d;
15524  t.mabengali = 0x09ae;
15525  t.macron = 0x00af;
15526  t.macronbelowcmb = 0x0331;
15527  t.macroncmb = 0x0304;
15528  t.macronlowmod = 0x02cd;
15529  t.macronmonospace = 0xffe3;
15530  t.macute = 0x1e3f;
15531  t.madeva = 0x092e;
15532  t.magujarati = 0x0aae;
15533  t.magurmukhi = 0x0a2e;
15534  t.mahapakhhebrew = 0x05a4;
15535  t.mahapakhlefthebrew = 0x05a4;
15536  t.mahiragana = 0x307e;
15537  t.maichattawalowleftthai = 0xf895;
15538  t.maichattawalowrightthai = 0xf894;
15539  t.maichattawathai = 0x0e4b;
15540  t.maichattawaupperleftthai = 0xf893;
15541  t.maieklowleftthai = 0xf88c;
15542  t.maieklowrightthai = 0xf88b;
15543  t.maiekthai = 0x0e48;
15544  t.maiekupperleftthai = 0xf88a;
15545  t.maihanakatleftthai = 0xf884;
15546  t.maihanakatthai = 0x0e31;
15547  t.maitaikhuleftthai = 0xf889;
15548  t.maitaikhuthai = 0x0e47;
15549  t.maitholowleftthai = 0xf88f;
15550  t.maitholowrightthai = 0xf88e;
15551  t.maithothai = 0x0e49;
15552  t.maithoupperleftthai = 0xf88d;
15553  t.maitrilowleftthai = 0xf892;
15554  t.maitrilowrightthai = 0xf891;
15555  t.maitrithai = 0x0e4a;
15556  t.maitriupperleftthai = 0xf890;
15557  t.maiyamokthai = 0x0e46;
15558  t.makatakana = 0x30de;
15559  t.makatakanahalfwidth = 0xff8f;
15560  t.male = 0x2642;
15561  t.mansyonsquare = 0x3347;
15562  t.maqafhebrew = 0x05be;
15563  t.mars = 0x2642;
15564  t.masoracirclehebrew = 0x05af;
15565  t.masquare = 0x3383;
15566  t.mbopomofo = 0x3107;
15567  t.mbsquare = 0x33d4;
15568  t.mcircle = 0x24dc;
15569  t.mcubedsquare = 0x33a5;
15570  t.mdotaccent = 0x1e41;
15571  t.mdotbelow = 0x1e43;
15572  t.meemarabic = 0x0645;
15573  t.meemfinalarabic = 0xfee2;
15574  t.meeminitialarabic = 0xfee3;
15575  t.meemmedialarabic = 0xfee4;
15576  t.meemmeeminitialarabic = 0xfcd1;
15577  t.meemmeemisolatedarabic = 0xfc48;
15578  t.meetorusquare = 0x334d;
15579  t.mehiragana = 0x3081;
15580  t.meizierasquare = 0x337e;
15581  t.mekatakana = 0x30e1;
15582  t.mekatakanahalfwidth = 0xff92;
15583  t.mem = 0x05de;
15584  t.memdagesh = 0xfb3e;
15585  t.memdageshhebrew = 0xfb3e;
15586  t.memhebrew = 0x05de;
15587  t.menarmenian = 0x0574;
15588  t.merkhahebrew = 0x05a5;
15589  t.merkhakefulahebrew = 0x05a6;
15590  t.merkhakefulalefthebrew = 0x05a6;
15591  t.merkhalefthebrew = 0x05a5;
15592  t.mhook = 0x0271;
15593  t.mhzsquare = 0x3392;
15594  t.middledotkatakanahalfwidth = 0xff65;
15595  t.middot = 0x00b7;
15596  t.mieumacirclekorean = 0x3272;
15597  t.mieumaparenkorean = 0x3212;
15598  t.mieumcirclekorean = 0x3264;
15599  t.mieumkorean = 0x3141;
15600  t.mieumpansioskorean = 0x3170;
15601  t.mieumparenkorean = 0x3204;
15602  t.mieumpieupkorean = 0x316e;
15603  t.mieumsioskorean = 0x316f;
15604  t.mihiragana = 0x307f;
15605  t.mikatakana = 0x30df;
15606  t.mikatakanahalfwidth = 0xff90;
15607  t.minus = 0x2212;
15608  t.minusbelowcmb = 0x0320;
15609  t.minuscircle = 0x2296;
15610  t.minusmod = 0x02d7;
15611  t.minusplus = 0x2213;
15612  t.minute = 0x2032;
15613  t.miribaarusquare = 0x334a;
15614  t.mirisquare = 0x3349;
15615  t.mlonglegturned = 0x0270;
15616  t.mlsquare = 0x3396;
15617  t.mmcubedsquare = 0x33a3;
15618  t.mmonospace = 0xff4d;
15619  t.mmsquaredsquare = 0x339f;
15620  t.mohiragana = 0x3082;
15621  t.mohmsquare = 0x33c1;
15622  t.mokatakana = 0x30e2;
15623  t.mokatakanahalfwidth = 0xff93;
15624  t.molsquare = 0x33d6;
15625  t.momathai = 0x0e21;
15626  t.moverssquare = 0x33a7;
15627  t.moverssquaredsquare = 0x33a8;
15628  t.mparen = 0x24a8;
15629  t.mpasquare = 0x33ab;
15630  t.mssquare = 0x33b3;
15631  t.msuperior = 0xf6ef;
15632  t.mturned = 0x026f;
15633  t.mu = 0x00b5;
15634  t.mu1 = 0x00b5;
15635  t.muasquare = 0x3382;
15636  t.muchgreater = 0x226b;
15637  t.muchless = 0x226a;
15638  t.mufsquare = 0x338c;
15639  t.mugreek = 0x03bc;
15640  t.mugsquare = 0x338d;
15641  t.muhiragana = 0x3080;
15642  t.mukatakana = 0x30e0;
15643  t.mukatakanahalfwidth = 0xff91;
15644  t.mulsquare = 0x3395;
15645  t.multiply = 0x00d7;
15646  t.mumsquare = 0x339b;
15647  t.munahhebrew = 0x05a3;
15648  t.munahlefthebrew = 0x05a3;
15649  t.musicalnote = 0x266a;
15650  t.musicalnotedbl = 0x266b;
15651  t.musicflatsign = 0x266d;
15652  t.musicsharpsign = 0x266f;
15653  t.mussquare = 0x33b2;
15654  t.muvsquare = 0x33b6;
15655  t.muwsquare = 0x33bc;
15656  t.mvmegasquare = 0x33b9;
15657  t.mvsquare = 0x33b7;
15658  t.mwmegasquare = 0x33bf;
15659  t.mwsquare = 0x33bd;
15660  t.n = 0x006e;
15661  t.nabengali = 0x09a8;
15662  t.nabla = 0x2207;
15663  t.nacute = 0x0144;
15664  t.nadeva = 0x0928;
15665  t.nagujarati = 0x0aa8;
15666  t.nagurmukhi = 0x0a28;
15667  t.nahiragana = 0x306a;
15668  t.nakatakana = 0x30ca;
15669  t.nakatakanahalfwidth = 0xff85;
15670  t.napostrophe = 0x0149;
15671  t.nasquare = 0x3381;
15672  t.nbopomofo = 0x310b;
15673  t.nbspace = 0x00a0;
15674  t.ncaron = 0x0148;
15675  t.ncedilla = 0x0146;
15676  t.ncircle = 0x24dd;
15677  t.ncircumflexbelow = 0x1e4b;
15678  t.ncommaaccent = 0x0146;
15679  t.ndotaccent = 0x1e45;
15680  t.ndotbelow = 0x1e47;
15681  t.nehiragana = 0x306d;
15682  t.nekatakana = 0x30cd;
15683  t.nekatakanahalfwidth = 0xff88;
15684  t.newsheqelsign = 0x20aa;
15685  t.nfsquare = 0x338b;
15686  t.ngabengali = 0x0999;
15687  t.ngadeva = 0x0919;
15688  t.ngagujarati = 0x0a99;
15689  t.ngagurmukhi = 0x0a19;
15690  t.ngonguthai = 0x0e07;
15691  t.nhiragana = 0x3093;
15692  t.nhookleft = 0x0272;
15693  t.nhookretroflex = 0x0273;
15694  t.nieunacirclekorean = 0x326f;
15695  t.nieunaparenkorean = 0x320f;
15696  t.nieuncieuckorean = 0x3135;
15697  t.nieuncirclekorean = 0x3261;
15698  t.nieunhieuhkorean = 0x3136;
15699  t.nieunkorean = 0x3134;
15700  t.nieunpansioskorean = 0x3168;
15701  t.nieunparenkorean = 0x3201;
15702  t.nieunsioskorean = 0x3167;
15703  t.nieuntikeutkorean = 0x3166;
15704  t.nihiragana = 0x306b;
15705  t.nikatakana = 0x30cb;
15706  t.nikatakanahalfwidth = 0xff86;
15707  t.nikhahitleftthai = 0xf899;
15708  t.nikhahitthai = 0x0e4d;
15709  t.nine = 0x0039;
15710  t.ninearabic = 0x0669;
15711  t.ninebengali = 0x09ef;
15712  t.ninecircle = 0x2468;
15713  t.ninecircleinversesansserif = 0x2792;
15714  t.ninedeva = 0x096f;
15715  t.ninegujarati = 0x0aef;
15716  t.ninegurmukhi = 0x0a6f;
15717  t.ninehackarabic = 0x0669;
15718  t.ninehangzhou = 0x3029;
15719  t.nineideographicparen = 0x3228;
15720  t.nineinferior = 0x2089;
15721  t.ninemonospace = 0xff19;
15722  t.nineoldstyle = 0xf739;
15723  t.nineparen = 0x247c;
15724  t.nineperiod = 0x2490;
15725  t.ninepersian = 0x06f9;
15726  t.nineroman = 0x2178;
15727  t.ninesuperior = 0x2079;
15728  t.nineteencircle = 0x2472;
15729  t.nineteenparen = 0x2486;
15730  t.nineteenperiod = 0x249a;
15731  t.ninethai = 0x0e59;
15732  t.nj = 0x01cc;
15733  t.njecyrillic = 0x045a;
15734  t.nkatakana = 0x30f3;
15735  t.nkatakanahalfwidth = 0xff9d;
15736  t.nlegrightlong = 0x019e;
15737  t.nlinebelow = 0x1e49;
15738  t.nmonospace = 0xff4e;
15739  t.nmsquare = 0x339a;
15740  t.nnabengali = 0x09a3;
15741  t.nnadeva = 0x0923;
15742  t.nnagujarati = 0x0aa3;
15743  t.nnagurmukhi = 0x0a23;
15744  t.nnnadeva = 0x0929;
15745  t.nohiragana = 0x306e;
15746  t.nokatakana = 0x30ce;
15747  t.nokatakanahalfwidth = 0xff89;
15748  t.nonbreakingspace = 0x00a0;
15749  t.nonenthai = 0x0e13;
15750  t.nonuthai = 0x0e19;
15751  t.noonarabic = 0x0646;
15752  t.noonfinalarabic = 0xfee6;
15753  t.noonghunnaarabic = 0x06ba;
15754  t.noonghunnafinalarabic = 0xfb9f;
15755  t.nooninitialarabic = 0xfee7;
15756  t.noonjeeminitialarabic = 0xfcd2;
15757  t.noonjeemisolatedarabic = 0xfc4b;
15758  t.noonmedialarabic = 0xfee8;
15759  t.noonmeeminitialarabic = 0xfcd5;
15760  t.noonmeemisolatedarabic = 0xfc4e;
15761  t.noonnoonfinalarabic = 0xfc8d;
15762  t.notcontains = 0x220c;
15763  t.notelement = 0x2209;
15764  t.notelementof = 0x2209;
15765  t.notequal = 0x2260;
15766  t.notgreater = 0x226f;
15767  t.notgreaternorequal = 0x2271;
15768  t.notgreaternorless = 0x2279;
15769  t.notidentical = 0x2262;
15770  t.notless = 0x226e;
15771  t.notlessnorequal = 0x2270;
15772  t.notparallel = 0x2226;
15773  t.notprecedes = 0x2280;
15774  t.notsubset = 0x2284;
15775  t.notsucceeds = 0x2281;
15776  t.notsuperset = 0x2285;
15777  t.nowarmenian = 0x0576;
15778  t.nparen = 0x24a9;
15779  t.nssquare = 0x33b1;
15780  t.nsuperior = 0x207f;
15781  t.ntilde = 0x00f1;
15782  t.nu = 0x03bd;
15783  t.nuhiragana = 0x306c;
15784  t.nukatakana = 0x30cc;
15785  t.nukatakanahalfwidth = 0xff87;
15786  t.nuktabengali = 0x09bc;
15787  t.nuktadeva = 0x093c;
15788  t.nuktagujarati = 0x0abc;
15789  t.nuktagurmukhi = 0x0a3c;
15790  t.numbersign = 0x0023;
15791  t.numbersignmonospace = 0xff03;
15792  t.numbersignsmall = 0xfe5f;
15793  t.numeralsigngreek = 0x0374;
15794  t.numeralsignlowergreek = 0x0375;
15795  t.numero = 0x2116;
15796  t.nun = 0x05e0;
15797  t.nundagesh = 0xfb40;
15798  t.nundageshhebrew = 0xfb40;
15799  t.nunhebrew = 0x05e0;
15800  t.nvsquare = 0x33b5;
15801  t.nwsquare = 0x33bb;
15802  t.nyabengali = 0x099e;
15803  t.nyadeva = 0x091e;
15804  t.nyagujarati = 0x0a9e;
15805  t.nyagurmukhi = 0x0a1e;
15806  t.o = 0x006f;
15807  t.oacute = 0x00f3;
15808  t.oangthai = 0x0e2d;
15809  t.obarred = 0x0275;
15810  t.obarredcyrillic = 0x04e9;
15811  t.obarreddieresiscyrillic = 0x04eb;
15812  t.obengali = 0x0993;
15813  t.obopomofo = 0x311b;
15814  t.obreve = 0x014f;
15815  t.ocandradeva = 0x0911;
15816  t.ocandragujarati = 0x0a91;
15817  t.ocandravowelsigndeva = 0x0949;
15818  t.ocandravowelsigngujarati = 0x0ac9;
15819  t.ocaron = 0x01d2;
15820  t.ocircle = 0x24de;
15821  t.ocircumflex = 0x00f4;
15822  t.ocircumflexacute = 0x1ed1;
15823  t.ocircumflexdotbelow = 0x1ed9;
15824  t.ocircumflexgrave = 0x1ed3;
15825  t.ocircumflexhookabove = 0x1ed5;
15826  t.ocircumflextilde = 0x1ed7;
15827  t.ocyrillic = 0x043e;
15828  t.odblacute = 0x0151;
15829  t.odblgrave = 0x020d;
15830  t.odeva = 0x0913;
15831  t.odieresis = 0x00f6;
15832  t.odieresiscyrillic = 0x04e7;
15833  t.odotbelow = 0x1ecd;
15834  t.oe = 0x0153;
15835  t.oekorean = 0x315a;
15836  t.ogonek = 0x02db;
15837  t.ogonekcmb = 0x0328;
15838  t.ograve = 0x00f2;
15839  t.ogujarati = 0x0a93;
15840  t.oharmenian = 0x0585;
15841  t.ohiragana = 0x304a;
15842  t.ohookabove = 0x1ecf;
15843  t.ohorn = 0x01a1;
15844  t.ohornacute = 0x1edb;
15845  t.ohorndotbelow = 0x1ee3;
15846  t.ohorngrave = 0x1edd;
15847  t.ohornhookabove = 0x1edf;
15848  t.ohorntilde = 0x1ee1;
15849  t.ohungarumlaut = 0x0151;
15850  t.oi = 0x01a3;
15851  t.oinvertedbreve = 0x020f;
15852  t.okatakana = 0x30aa;
15853  t.okatakanahalfwidth = 0xff75;
15854  t.okorean = 0x3157;
15855  t.olehebrew = 0x05ab;
15856  t.omacron = 0x014d;
15857  t.omacronacute = 0x1e53;
15858  t.omacrongrave = 0x1e51;
15859  t.omdeva = 0x0950;
15860  t.omega = 0x03c9;
15861  t.omega1 = 0x03d6;
15862  t.omegacyrillic = 0x0461;
15863  t.omegalatinclosed = 0x0277;
15864  t.omegaroundcyrillic = 0x047b;
15865  t.omegatitlocyrillic = 0x047d;
15866  t.omegatonos = 0x03ce;
15867  t.omgujarati = 0x0ad0;
15868  t.omicron = 0x03bf;
15869  t.omicrontonos = 0x03cc;
15870  t.omonospace = 0xff4f;
15871  t.one = 0x0031;
15872  t.onearabic = 0x0661;
15873  t.onebengali = 0x09e7;
15874  t.onecircle = 0x2460;
15875  t.onecircleinversesansserif = 0x278a;
15876  t.onedeva = 0x0967;
15877  t.onedotenleader = 0x2024;
15878  t.oneeighth = 0x215b;
15879  t.onefitted = 0xf6dc;
15880  t.onegujarati = 0x0ae7;
15881  t.onegurmukhi = 0x0a67;
15882  t.onehackarabic = 0x0661;
15883  t.onehalf = 0x00bd;
15884  t.onehangzhou = 0x3021;
15885  t.oneideographicparen = 0x3220;
15886  t.oneinferior = 0x2081;
15887  t.onemonospace = 0xff11;
15888  t.onenumeratorbengali = 0x09f4;
15889  t.oneoldstyle = 0xf731;
15890  t.oneparen = 0x2474;
15891  t.oneperiod = 0x2488;
15892  t.onepersian = 0x06f1;
15893  t.onequarter = 0x00bc;
15894  t.oneroman = 0x2170;
15895  t.onesuperior = 0x00b9;
15896  t.onethai = 0x0e51;
15897  t.onethird = 0x2153;
15898  t.oogonek = 0x01eb;
15899  t.oogonekmacron = 0x01ed;
15900  t.oogurmukhi = 0x0a13;
15901  t.oomatragurmukhi = 0x0a4b;
15902  t.oopen = 0x0254;
15903  t.oparen = 0x24aa;
15904  t.openbullet = 0x25e6;
15905  t.option = 0x2325;
15906  t.ordfeminine = 0x00aa;
15907  t.ordmasculine = 0x00ba;
15908  t.orthogonal = 0x221f;
15909  t.oshortdeva = 0x0912;
15910  t.oshortvowelsigndeva = 0x094a;
15911  t.oslash = 0x00f8;
15912  t.oslashacute = 0x01ff;
15913  t.osmallhiragana = 0x3049;
15914  t.osmallkatakana = 0x30a9;
15915  t.osmallkatakanahalfwidth = 0xff6b;
15916  t.ostrokeacute = 0x01ff;
15917  t.osuperior = 0xf6f0;
15918  t.otcyrillic = 0x047f;
15919  t.otilde = 0x00f5;
15920  t.otildeacute = 0x1e4d;
15921  t.otildedieresis = 0x1e4f;
15922  t.oubopomofo = 0x3121;
15923  t.overline = 0x203e;
15924  t.overlinecenterline = 0xfe4a;
15925  t.overlinecmb = 0x0305;
15926  t.overlinedashed = 0xfe49;
15927  t.overlinedblwavy = 0xfe4c;
15928  t.overlinewavy = 0xfe4b;
15929  t.overscore = 0x00af;
15930  t.ovowelsignbengali = 0x09cb;
15931  t.ovowelsigndeva = 0x094b;
15932  t.ovowelsigngujarati = 0x0acb;
15933  t.p = 0x0070;
15934  t.paampssquare = 0x3380;
15935  t.paasentosquare = 0x332b;
15936  t.pabengali = 0x09aa;
15937  t.pacute = 0x1e55;
15938  t.padeva = 0x092a;
15939  t.pagedown = 0x21df;
15940  t.pageup = 0x21de;
15941  t.pagujarati = 0x0aaa;
15942  t.pagurmukhi = 0x0a2a;
15943  t.pahiragana = 0x3071;
15944  t.paiyannoithai = 0x0e2f;
15945  t.pakatakana = 0x30d1;
15946  t.palatalizationcyrilliccmb = 0x0484;
15947  t.palochkacyrillic = 0x04c0;
15948  t.pansioskorean = 0x317f;
15949  t.paragraph = 0x00b6;
15950  t.parallel = 0x2225;
15951  t.parenleft = 0x0028;
15952  t.parenleftaltonearabic = 0xfd3e;
15953  t.parenleftbt = 0xf8ed;
15954  t.parenleftex = 0xf8ec;
15955  t.parenleftinferior = 0x208d;
15956  t.parenleftmonospace = 0xff08;
15957  t.parenleftsmall = 0xfe59;
15958  t.parenleftsuperior = 0x207d;
15959  t.parenlefttp = 0xf8eb;
15960  t.parenleftvertical = 0xfe35;
15961  t.parenright = 0x0029;
15962  t.parenrightaltonearabic = 0xfd3f;
15963  t.parenrightbt = 0xf8f8;
15964  t.parenrightex = 0xf8f7;
15965  t.parenrightinferior = 0x208e;
15966  t.parenrightmonospace = 0xff09;
15967  t.parenrightsmall = 0xfe5a;
15968  t.parenrightsuperior = 0x207e;
15969  t.parenrighttp = 0xf8f6;
15970  t.parenrightvertical = 0xfe36;
15971  t.partialdiff = 0x2202;
15972  t.paseqhebrew = 0x05c0;
15973  t.pashtahebrew = 0x0599;
15974  t.pasquare = 0x33a9;
15975  t.patah = 0x05b7;
15976  t.patah11 = 0x05b7;
15977  t.patah1d = 0x05b7;
15978  t.patah2a = 0x05b7;
15979  t.patahhebrew = 0x05b7;
15980  t.patahnarrowhebrew = 0x05b7;
15981  t.patahquarterhebrew = 0x05b7;
15982  t.patahwidehebrew = 0x05b7;
15983  t.pazerhebrew = 0x05a1;
15984  t.pbopomofo = 0x3106;
15985  t.pcircle = 0x24df;
15986  t.pdotaccent = 0x1e57;
15987  t.pe = 0x05e4;
15988  t.pecyrillic = 0x043f;
15989  t.pedagesh = 0xfb44;
15990  t.pedageshhebrew = 0xfb44;
15991  t.peezisquare = 0x333b;
15992  t.pefinaldageshhebrew = 0xfb43;
15993  t.peharabic = 0x067e;
15994  t.peharmenian = 0x057a;
15995  t.pehebrew = 0x05e4;
15996  t.pehfinalarabic = 0xfb57;
15997  t.pehinitialarabic = 0xfb58;
15998  t.pehiragana = 0x307a;
15999  t.pehmedialarabic = 0xfb59;
16000  t.pekatakana = 0x30da;
16001  t.pemiddlehookcyrillic = 0x04a7;
16002  t.perafehebrew = 0xfb4e;
16003  t.percent = 0x0025;
16004  t.percentarabic = 0x066a;
16005  t.percentmonospace = 0xff05;
16006  t.percentsmall = 0xfe6a;
16007  t.period = 0x002e;
16008  t.periodarmenian = 0x0589;
16009  t.periodcentered = 0x00b7;
16010  t.periodhalfwidth = 0xff61;
16011  t.periodinferior = 0xf6e7;
16012  t.periodmonospace = 0xff0e;
16013  t.periodsmall = 0xfe52;
16014  t.periodsuperior = 0xf6e8;
16015  t.perispomenigreekcmb = 0x0342;
16016  t.perpendicular = 0x22a5;
16017  t.perthousand = 0x2030;
16018  t.peseta = 0x20a7;
16019  t.pfsquare = 0x338a;
16020  t.phabengali = 0x09ab;
16021  t.phadeva = 0x092b;
16022  t.phagujarati = 0x0aab;
16023  t.phagurmukhi = 0x0a2b;
16024  t.phi = 0x03c6;
16025  t.phi1 = 0x03d5;
16026  t.phieuphacirclekorean = 0x327a;
16027  t.phieuphaparenkorean = 0x321a;
16028  t.phieuphcirclekorean = 0x326c;
16029  t.phieuphkorean = 0x314d;
16030  t.phieuphparenkorean = 0x320c;
16031  t.philatin = 0x0278;
16032  t.phinthuthai = 0x0e3a;
16033  t.phisymbolgreek = 0x03d5;
16034  t.phook = 0x01a5;
16035  t.phophanthai = 0x0e1e;
16036  t.phophungthai = 0x0e1c;
16037  t.phosamphaothai = 0x0e20;
16038  t.pi = 0x03c0;
16039  t.pieupacirclekorean = 0x3273;
16040  t.pieupaparenkorean = 0x3213;
16041  t.pieupcieuckorean = 0x3176;
16042  t.pieupcirclekorean = 0x3265;
16043  t.pieupkiyeokkorean = 0x3172;
16044  t.pieupkorean = 0x3142;
16045  t.pieupparenkorean = 0x3205;
16046  t.pieupsioskiyeokkorean = 0x3174;
16047  t.pieupsioskorean = 0x3144;
16048  t.pieupsiostikeutkorean = 0x3175;
16049  t.pieupthieuthkorean = 0x3177;
16050  t.pieuptikeutkorean = 0x3173;
16051  t.pihiragana = 0x3074;
16052  t.pikatakana = 0x30d4;
16053  t.pisymbolgreek = 0x03d6;
16054  t.piwrarmenian = 0x0583;
16055  t.planckover2pi = 0x210f;
16056  t.planckover2pi1 = 0x210f;
16057  t.plus = 0x002b;
16058  t.plusbelowcmb = 0x031f;
16059  t.pluscircle = 0x2295;
16060  t.plusminus = 0x00b1;
16061  t.plusmod = 0x02d6;
16062  t.plusmonospace = 0xff0b;
16063  t.plussmall = 0xfe62;
16064  t.plussuperior = 0x207a;
16065  t.pmonospace = 0xff50;
16066  t.pmsquare = 0x33d8;
16067  t.pohiragana = 0x307d;
16068  t.pointingindexdownwhite = 0x261f;
16069  t.pointingindexleftwhite = 0x261c;
16070  t.pointingindexrightwhite = 0x261e;
16071  t.pointingindexupwhite = 0x261d;
16072  t.pokatakana = 0x30dd;
16073  t.poplathai = 0x0e1b;
16074  t.postalmark = 0x3012;
16075  t.postalmarkface = 0x3020;
16076  t.pparen = 0x24ab;
16077  t.precedes = 0x227a;
16078  t.prescription = 0x211e;
16079  t.primemod = 0x02b9;
16080  t.primereversed = 0x2035;
16081  t.product = 0x220f;
16082  t.projective = 0x2305;
16083  t.prolongedkana = 0x30fc;
16084  t.propellor = 0x2318;
16085  t.propersubset = 0x2282;
16086  t.propersuperset = 0x2283;
16087  t.proportion = 0x2237;
16088  t.proportional = 0x221d;
16089  t.psi = 0x03c8;
16090  t.psicyrillic = 0x0471;
16091  t.psilipneumatacyrilliccmb = 0x0486;
16092  t.pssquare = 0x33b0;
16093  t.puhiragana = 0x3077;
16094  t.pukatakana = 0x30d7;
16095  t.pvsquare = 0x33b4;
16096  t.pwsquare = 0x33ba;
16097  t.q = 0x0071;
16098  t.qadeva = 0x0958;
16099  t.qadmahebrew = 0x05a8;
16100  t.qafarabic = 0x0642;
16101  t.qaffinalarabic = 0xfed6;
16102  t.qafinitialarabic = 0xfed7;
16103  t.qafmedialarabic = 0xfed8;
16104  t.qamats = 0x05b8;
16105  t.qamats10 = 0x05b8;
16106  t.qamats1a = 0x05b8;
16107  t.qamats1c = 0x05b8;
16108  t.qamats27 = 0x05b8;
16109  t.qamats29 = 0x05b8;
16110  t.qamats33 = 0x05b8;
16111  t.qamatsde = 0x05b8;
16112  t.qamatshebrew = 0x05b8;
16113  t.qamatsnarrowhebrew = 0x05b8;
16114  t.qamatsqatanhebrew = 0x05b8;
16115  t.qamatsqatannarrowhebrew = 0x05b8;
16116  t.qamatsqatanquarterhebrew = 0x05b8;
16117  t.qamatsqatanwidehebrew = 0x05b8;
16118  t.qamatsquarterhebrew = 0x05b8;
16119  t.qamatswidehebrew = 0x05b8;
16120  t.qarneyparahebrew = 0x059f;
16121  t.qbopomofo = 0x3111;
16122  t.qcircle = 0x24e0;
16123  t.qhook = 0x02a0;
16124  t.qmonospace = 0xff51;
16125  t.qof = 0x05e7;
16126  t.qofdagesh = 0xfb47;
16127  t.qofdageshhebrew = 0xfb47;
16128  t.qofhebrew = 0x05e7;
16129  t.qparen = 0x24ac;
16130  t.quarternote = 0x2669;
16131  t.qubuts = 0x05bb;
16132  t.qubuts18 = 0x05bb;
16133  t.qubuts25 = 0x05bb;
16134  t.qubuts31 = 0x05bb;
16135  t.qubutshebrew = 0x05bb;
16136  t.qubutsnarrowhebrew = 0x05bb;
16137  t.qubutsquarterhebrew = 0x05bb;
16138  t.qubutswidehebrew = 0x05bb;
16139  t.question = 0x003f;
16140  t.questionarabic = 0x061f;
16141  t.questionarmenian = 0x055e;
16142  t.questiondown = 0x00bf;
16143  t.questiondownsmall = 0xf7bf;
16144  t.questiongreek = 0x037e;
16145  t.questionmonospace = 0xff1f;
16146  t.questionsmall = 0xf73f;
16147  t.quotedbl = 0x0022;
16148  t.quotedblbase = 0x201e;
16149  t.quotedblleft = 0x201c;
16150  t.quotedblmonospace = 0xff02;
16151  t.quotedblprime = 0x301e;
16152  t.quotedblprimereversed = 0x301d;
16153  t.quotedblright = 0x201d;
16154  t.quoteleft = 0x2018;
16155  t.quoteleftreversed = 0x201b;
16156  t.quotereversed = 0x201b;
16157  t.quoteright = 0x2019;
16158  t.quoterightn = 0x0149;
16159  t.quotesinglbase = 0x201a;
16160  t.quotesingle = 0x0027;
16161  t.quotesinglemonospace = 0xff07;
16162  t.r = 0x0072;
16163  t.raarmenian = 0x057c;
16164  t.rabengali = 0x09b0;
16165  t.racute = 0x0155;
16166  t.radeva = 0x0930;
16167  t.radical = 0x221a;
16168  t.radicalex = 0xf8e5;
16169  t.radoverssquare = 0x33ae;
16170  t.radoverssquaredsquare = 0x33af;
16171  t.radsquare = 0x33ad;
16172  t.rafe = 0x05bf;
16173  t.rafehebrew = 0x05bf;
16174  t.ragujarati = 0x0ab0;
16175  t.ragurmukhi = 0x0a30;
16176  t.rahiragana = 0x3089;
16177  t.rakatakana = 0x30e9;
16178  t.rakatakanahalfwidth = 0xff97;
16179  t.ralowerdiagonalbengali = 0x09f1;
16180  t.ramiddlediagonalbengali = 0x09f0;
16181  t.ramshorn = 0x0264;
16182  t.ratio = 0x2236;
16183  t.rbopomofo = 0x3116;
16184  t.rcaron = 0x0159;
16185  t.rcedilla = 0x0157;
16186  t.rcircle = 0x24e1;
16187  t.rcommaaccent = 0x0157;
16188  t.rdblgrave = 0x0211;
16189  t.rdotaccent = 0x1e59;
16190  t.rdotbelow = 0x1e5b;
16191  t.rdotbelowmacron = 0x1e5d;
16192  t.referencemark = 0x203b;
16193  t.reflexsubset = 0x2286;
16194  t.reflexsuperset = 0x2287;
16195  t.registered = 0x00ae;
16196  t.registersans = 0xf8e8;
16197  t.registerserif = 0xf6da;
16198  t.reharabic = 0x0631;
16199  t.reharmenian = 0x0580;
16200  t.rehfinalarabic = 0xfeae;
16201  t.rehiragana = 0x308c;
16202  t.rekatakana = 0x30ec;
16203  t.rekatakanahalfwidth = 0xff9a;
16204  t.resh = 0x05e8;
16205  t.reshdageshhebrew = 0xfb48;
16206  t.reshhebrew = 0x05e8;
16207  t.reversedtilde = 0x223d;
16208  t.reviahebrew = 0x0597;
16209  t.reviamugrashhebrew = 0x0597;
16210  t.revlogicalnot = 0x2310;
16211  t.rfishhook = 0x027e;
16212  t.rfishhookreversed = 0x027f;
16213  t.rhabengali = 0x09dd;
16214  t.rhadeva = 0x095d;
16215  t.rho = 0x03c1;
16216  t.rhook = 0x027d;
16217  t.rhookturned = 0x027b;
16218  t.rhookturnedsuperior = 0x02b5;
16219  t.rhosymbolgreek = 0x03f1;
16220  t.rhotichookmod = 0x02de;
16221  t.rieulacirclekorean = 0x3271;
16222  t.rieulaparenkorean = 0x3211;
16223  t.rieulcirclekorean = 0x3263;
16224  t.rieulhieuhkorean = 0x3140;
16225  t.rieulkiyeokkorean = 0x313a;
16226  t.rieulkiyeoksioskorean = 0x3169;
16227  t.rieulkorean = 0x3139;
16228  t.rieulmieumkorean = 0x313b;
16229  t.rieulpansioskorean = 0x316c;
16230  t.rieulparenkorean = 0x3203;
16231  t.rieulphieuphkorean = 0x313f;
16232  t.rieulpieupkorean = 0x313c;
16233  t.rieulpieupsioskorean = 0x316b;
16234  t.rieulsioskorean = 0x313d;
16235  t.rieulthieuthkorean = 0x313e;
16236  t.rieultikeutkorean = 0x316a;
16237  t.rieulyeorinhieuhkorean = 0x316d;
16238  t.rightangle = 0x221f;
16239  t.righttackbelowcmb = 0x0319;
16240  t.righttriangle = 0x22bf;
16241  t.rihiragana = 0x308a;
16242  t.rikatakana = 0x30ea;
16243  t.rikatakanahalfwidth = 0xff98;
16244  t.ring = 0x02da;
16245  t.ringbelowcmb = 0x0325;
16246  t.ringcmb = 0x030a;
16247  t.ringhalfleft = 0x02bf;
16248  t.ringhalfleftarmenian = 0x0559;
16249  t.ringhalfleftbelowcmb = 0x031c;
16250  t.ringhalfleftcentered = 0x02d3;
16251  t.ringhalfright = 0x02be;
16252  t.ringhalfrightbelowcmb = 0x0339;
16253  t.ringhalfrightcentered = 0x02d2;
16254  t.rinvertedbreve = 0x0213;
16255  t.rittorusquare = 0x3351;
16256  t.rlinebelow = 0x1e5f;
16257  t.rlongleg = 0x027c;
16258  t.rlonglegturned = 0x027a;
16259  t.rmonospace = 0xff52;
16260  t.rohiragana = 0x308d;
16261  t.rokatakana = 0x30ed;
16262  t.rokatakanahalfwidth = 0xff9b;
16263  t.roruathai = 0x0e23;
16264  t.rparen = 0x24ad;
16265  t.rrabengali = 0x09dc;
16266  t.rradeva = 0x0931;
16267  t.rragurmukhi = 0x0a5c;
16268  t.rreharabic = 0x0691;
16269  t.rrehfinalarabic = 0xfb8d;
16270  t.rrvocalicbengali = 0x09e0;
16271  t.rrvocalicdeva = 0x0960;
16272  t.rrvocalicgujarati = 0x0ae0;
16273  t.rrvocalicvowelsignbengali = 0x09c4;
16274  t.rrvocalicvowelsigndeva = 0x0944;
16275  t.rrvocalicvowelsigngujarati = 0x0ac4;
16276  t.rsuperior = 0xf6f1;
16277  t.rtblock = 0x2590;
16278  t.rturned = 0x0279;
16279  t.rturnedsuperior = 0x02b4;
16280  t.ruhiragana = 0x308b;
16281  t.rukatakana = 0x30eb;
16282  t.rukatakanahalfwidth = 0xff99;
16283  t.rupeemarkbengali = 0x09f2;
16284  t.rupeesignbengali = 0x09f3;
16285  t.rupiah = 0xf6dd;
16286  t.ruthai = 0x0e24;
16287  t.rvocalicbengali = 0x098b;
16288  t.rvocalicdeva = 0x090b;
16289  t.rvocalicgujarati = 0x0a8b;
16290  t.rvocalicvowelsignbengali = 0x09c3;
16291  t.rvocalicvowelsigndeva = 0x0943;
16292  t.rvocalicvowelsigngujarati = 0x0ac3;
16293  t.s = 0x0073;
16294  t.sabengali = 0x09b8;
16295  t.sacute = 0x015b;
16296  t.sacutedotaccent = 0x1e65;
16297  t.sadarabic = 0x0635;
16298  t.sadeva = 0x0938;
16299  t.sadfinalarabic = 0xfeba;
16300  t.sadinitialarabic = 0xfebb;
16301  t.sadmedialarabic = 0xfebc;
16302  t.sagujarati = 0x0ab8;
16303  t.sagurmukhi = 0x0a38;
16304  t.sahiragana = 0x3055;
16305  t.sakatakana = 0x30b5;
16306  t.sakatakanahalfwidth = 0xff7b;
16307  t.sallallahoualayhewasallamarabic = 0xfdfa;
16308  t.samekh = 0x05e1;
16309  t.samekhdagesh = 0xfb41;
16310  t.samekhdageshhebrew = 0xfb41;
16311  t.samekhhebrew = 0x05e1;
16312  t.saraaathai = 0x0e32;
16313  t.saraaethai = 0x0e41;
16314  t.saraaimaimalaithai = 0x0e44;
16315  t.saraaimaimuanthai = 0x0e43;
16316  t.saraamthai = 0x0e33;
16317  t.saraathai = 0x0e30;
16318  t.saraethai = 0x0e40;
16319  t.saraiileftthai = 0xf886;
16320  t.saraiithai = 0x0e35;
16321  t.saraileftthai = 0xf885;
16322  t.saraithai = 0x0e34;
16323  t.saraothai = 0x0e42;
16324  t.saraueeleftthai = 0xf888;
16325  t.saraueethai = 0x0e37;
16326  t.saraueleftthai = 0xf887;
16327  t.sarauethai = 0x0e36;
16328  t.sarauthai = 0x0e38;
16329  t.sarauuthai = 0x0e39;
16330  t.sbopomofo = 0x3119;
16331  t.scaron = 0x0161;
16332  t.scarondotaccent = 0x1e67;
16333  t.scedilla = 0x015f;
16334  t.schwa = 0x0259;
16335  t.schwacyrillic = 0x04d9;
16336  t.schwadieresiscyrillic = 0x04db;
16337  t.schwahook = 0x025a;
16338  t.scircle = 0x24e2;
16339  t.scircumflex = 0x015d;
16340  t.scommaaccent = 0x0219;
16341  t.sdotaccent = 0x1e61;
16342  t.sdotbelow = 0x1e63;
16343  t.sdotbelowdotaccent = 0x1e69;
16344  t.seagullbelowcmb = 0x033c;
16345  t.second = 0x2033;
16346  t.secondtonechinese = 0x02ca;
16347  t.section = 0x00a7;
16348  t.seenarabic = 0x0633;
16349  t.seenfinalarabic = 0xfeb2;
16350  t.seeninitialarabic = 0xfeb3;
16351  t.seenmedialarabic = 0xfeb4;
16352  t.segol = 0x05b6;
16353  t.segol13 = 0x05b6;
16354  t.segol1f = 0x05b6;
16355  t.segol2c = 0x05b6;
16356  t.segolhebrew = 0x05b6;
16357  t.segolnarrowhebrew = 0x05b6;
16358  t.segolquarterhebrew = 0x05b6;
16359  t.segoltahebrew = 0x0592;
16360  t.segolwidehebrew = 0x05b6;
16361  t.seharmenian = 0x057d;
16362  t.sehiragana = 0x305b;
16363  t.sekatakana = 0x30bb;
16364  t.sekatakanahalfwidth = 0xff7e;
16365  t.semicolon = 0x003b;
16366  t.semicolonarabic = 0x061b;
16367  t.semicolonmonospace = 0xff1b;
16368  t.semicolonsmall = 0xfe54;
16369  t.semivoicedmarkkana = 0x309c;
16370  t.semivoicedmarkkanahalfwidth = 0xff9f;
16371  t.sentisquare = 0x3322;
16372  t.sentosquare = 0x3323;
16373  t.seven = 0x0037;
16374  t.sevenarabic = 0x0667;
16375  t.sevenbengali = 0x09ed;
16376  t.sevencircle = 0x2466;
16377  t.sevencircleinversesansserif = 0x2790;
16378  t.sevendeva = 0x096d;
16379  t.seveneighths = 0x215e;
16380  t.sevengujarati = 0x0aed;
16381  t.sevengurmukhi = 0x0a6d;
16382  t.sevenhackarabic = 0x0667;
16383  t.sevenhangzhou = 0x3027;
16384  t.sevenideographicparen = 0x3226;
16385  t.seveninferior = 0x2087;
16386  t.sevenmonospace = 0xff17;
16387  t.sevenoldstyle = 0xf737;
16388  t.sevenparen = 0x247a;
16389  t.sevenperiod = 0x248e;
16390  t.sevenpersian = 0x06f7;
16391  t.sevenroman = 0x2176;
16392  t.sevensuperior = 0x2077;
16393  t.seventeencircle = 0x2470;
16394  t.seventeenparen = 0x2484;
16395  t.seventeenperiod = 0x2498;
16396  t.seventhai = 0x0e57;
16397  t.sfthyphen = 0x00ad;
16398  t.shaarmenian = 0x0577;
16399  t.shabengali = 0x09b6;
16400  t.shacyrillic = 0x0448;
16401  t.shaddaarabic = 0x0651;
16402  t.shaddadammaarabic = 0xfc61;
16403  t.shaddadammatanarabic = 0xfc5e;
16404  t.shaddafathaarabic = 0xfc60;
16405  t.shaddakasraarabic = 0xfc62;
16406  t.shaddakasratanarabic = 0xfc5f;
16407  t.shade = 0x2592;
16408  t.shadedark = 0x2593;
16409  t.shadelight = 0x2591;
16410  t.shademedium = 0x2592;
16411  t.shadeva = 0x0936;
16412  t.shagujarati = 0x0ab6;
16413  t.shagurmukhi = 0x0a36;
16414  t.shalshelethebrew = 0x0593;
16415  t.shbopomofo = 0x3115;
16416  t.shchacyrillic = 0x0449;
16417  t.sheenarabic = 0x0634;
16418  t.sheenfinalarabic = 0xfeb6;
16419  t.sheeninitialarabic = 0xfeb7;
16420  t.sheenmedialarabic = 0xfeb8;
16421  t.sheicoptic = 0x03e3;
16422  t.sheqel = 0x20aa;
16423  t.sheqelhebrew = 0x20aa;
16424  t.sheva = 0x05b0;
16425  t.sheva115 = 0x05b0;
16426  t.sheva15 = 0x05b0;
16427  t.sheva22 = 0x05b0;
16428  t.sheva2e = 0x05b0;
16429  t.shevahebrew = 0x05b0;
16430  t.shevanarrowhebrew = 0x05b0;
16431  t.shevaquarterhebrew = 0x05b0;
16432  t.shevawidehebrew = 0x05b0;
16433  t.shhacyrillic = 0x04bb;
16434  t.shimacoptic = 0x03ed;
16435  t.shin = 0x05e9;
16436  t.shindagesh = 0xfb49;
16437  t.shindageshhebrew = 0xfb49;
16438  t.shindageshshindot = 0xfb2c;
16439  t.shindageshshindothebrew = 0xfb2c;
16440  t.shindageshsindot = 0xfb2d;
16441  t.shindageshsindothebrew = 0xfb2d;
16442  t.shindothebrew = 0x05c1;
16443  t.shinhebrew = 0x05e9;
16444  t.shinshindot = 0xfb2a;
16445  t.shinshindothebrew = 0xfb2a;
16446  t.shinsindot = 0xfb2b;
16447  t.shinsindothebrew = 0xfb2b;
16448  t.shook = 0x0282;
16449  t.sigma = 0x03c3;
16450  t.sigma1 = 0x03c2;
16451  t.sigmafinal = 0x03c2;
16452  t.sigmalunatesymbolgreek = 0x03f2;
16453  t.sihiragana = 0x3057;
16454  t.sikatakana = 0x30b7;
16455  t.sikatakanahalfwidth = 0xff7c;
16456  t.siluqhebrew = 0x05bd;
16457  t.siluqlefthebrew = 0x05bd;
16458  t.similar = 0x223c;
16459  t.sindothebrew = 0x05c2;
16460  t.siosacirclekorean = 0x3274;
16461  t.siosaparenkorean = 0x3214;
16462  t.sioscieuckorean = 0x317e;
16463  t.sioscirclekorean = 0x3266;
16464  t.sioskiyeokkorean = 0x317a;
16465  t.sioskorean = 0x3145;
16466  t.siosnieunkorean = 0x317b;
16467  t.siosparenkorean = 0x3206;
16468  t.siospieupkorean = 0x317d;
16469  t.siostikeutkorean = 0x317c;
16470  t.six = 0x0036;
16471  t.sixarabic = 0x0666;
16472  t.sixbengali = 0x09ec;
16473  t.sixcircle = 0x2465;
16474  t.sixcircleinversesansserif = 0x278f;
16475  t.sixdeva = 0x096c;
16476  t.sixgujarati = 0x0aec;
16477  t.sixgurmukhi = 0x0a6c;
16478  t.sixhackarabic = 0x0666;
16479  t.sixhangzhou = 0x3026;
16480  t.sixideographicparen = 0x3225;
16481  t.sixinferior = 0x2086;
16482  t.sixmonospace = 0xff16;
16483  t.sixoldstyle = 0xf736;
16484  t.sixparen = 0x2479;
16485  t.sixperiod = 0x248d;
16486  t.sixpersian = 0x06f6;
16487  t.sixroman = 0x2175;
16488  t.sixsuperior = 0x2076;
16489  t.sixteencircle = 0x246f;
16490  t.sixteencurrencydenominatorbengali = 0x09f9;
16491  t.sixteenparen = 0x2483;
16492  t.sixteenperiod = 0x2497;
16493  t.sixthai = 0x0e56;
16494  t.slash = 0x002f;
16495  t.slashmonospace = 0xff0f;
16496  t.slong = 0x017f;
16497  t.slongdotaccent = 0x1e9b;
16498  t.smileface = 0x263a;
16499  t.smonospace = 0xff53;
16500  t.sofpasuqhebrew = 0x05c3;
16501  t.softhyphen = 0x00ad;
16502  t.softsigncyrillic = 0x044c;
16503  t.sohiragana = 0x305d;
16504  t.sokatakana = 0x30bd;
16505  t.sokatakanahalfwidth = 0xff7f;
16506  t.soliduslongoverlaycmb = 0x0338;
16507  t.solidusshortoverlaycmb = 0x0337;
16508  t.sorusithai = 0x0e29;
16509  t.sosalathai = 0x0e28;
16510  t.sosothai = 0x0e0b;
16511  t.sosuathai = 0x0e2a;
16512  t.space = 0x0020;
16513  t.spacehackarabic = 0x0020;
16514  t.spade = 0x2660;
16515  t.spadesuitblack = 0x2660;
16516  t.spadesuitwhite = 0x2664;
16517  t.sparen = 0x24ae;
16518  t.squarebelowcmb = 0x033b;
16519  t.squarecc = 0x33c4;
16520  t.squarecm = 0x339d;
16521  t.squarediagonalcrosshatchfill = 0x25a9;
16522  t.squarehorizontalfill = 0x25a4;
16523  t.squarekg = 0x338f;
16524  t.squarekm = 0x339e;
16525  t.squarekmcapital = 0x33ce;
16526  t.squareln = 0x33d1;
16527  t.squarelog = 0x33d2;
16528  t.squaremg = 0x338e;
16529  t.squaremil = 0x33d5;
16530  t.squaremm = 0x339c;
16531  t.squaremsquared = 0x33a1;
16532  t.squareorthogonalcrosshatchfill = 0x25a6;
16533  t.squareupperlefttolowerrightfill = 0x25a7;
16534  t.squareupperrighttolowerleftfill = 0x25a8;
16535  t.squareverticalfill = 0x25a5;
16536  t.squarewhitewithsmallblack = 0x25a3;
16537  t.srsquare = 0x33db;
16538  t.ssabengali = 0x09b7;
16539  t.ssadeva = 0x0937;
16540  t.ssagujarati = 0x0ab7;
16541  t.ssangcieuckorean = 0x3149;
16542  t.ssanghieuhkorean = 0x3185;
16543  t.ssangieungkorean = 0x3180;
16544  t.ssangkiyeokkorean = 0x3132;
16545  t.ssangnieunkorean = 0x3165;
16546  t.ssangpieupkorean = 0x3143;
16547  t.ssangsioskorean = 0x3146;
16548  t.ssangtikeutkorean = 0x3138;
16549  t.ssuperior = 0xf6f2;
16550  t.sterling = 0x00a3;
16551  t.sterlingmonospace = 0xffe1;
16552  t.strokelongoverlaycmb = 0x0336;
16553  t.strokeshortoverlaycmb = 0x0335;
16554  t.subset = 0x2282;
16555  t.subsetnotequal = 0x228a;
16556  t.subsetorequal = 0x2286;
16557  t.succeeds = 0x227b;
16558  t.suchthat = 0x220b;
16559  t.suhiragana = 0x3059;
16560  t.sukatakana = 0x30b9;
16561  t.sukatakanahalfwidth = 0xff7d;
16562  t.sukunarabic = 0x0652;
16563  t.summation = 0x2211;
16564  t.sun = 0x263c;
16565  t.superset = 0x2283;
16566  t.supersetnotequal = 0x228b;
16567  t.supersetorequal = 0x2287;
16568  t.svsquare = 0x33dc;
16569  t.syouwaerasquare = 0x337c;
16570  t.t = 0x0074;
16571  t.tabengali = 0x09a4;
16572  t.tackdown = 0x22a4;
16573  t.tackleft = 0x22a3;
16574  t.tadeva = 0x0924;
16575  t.tagujarati = 0x0aa4;
16576  t.tagurmukhi = 0x0a24;
16577  t.taharabic = 0x0637;
16578  t.tahfinalarabic = 0xfec2;
16579  t.tahinitialarabic = 0xfec3;
16580  t.tahiragana = 0x305f;
16581  t.tahmedialarabic = 0xfec4;
16582  t.taisyouerasquare = 0x337d;
16583  t.takatakana = 0x30bf;
16584  t.takatakanahalfwidth = 0xff80;
16585  t.tatweelarabic = 0x0640;
16586  t.tau = 0x03c4;
16587  t.tav = 0x05ea;
16588  t.tavdages = 0xfb4a;
16589  t.tavdagesh = 0xfb4a;
16590  t.tavdageshhebrew = 0xfb4a;
16591  t.tavhebrew = 0x05ea;
16592  t.tbar = 0x0167;
16593  t.tbopomofo = 0x310a;
16594  t.tcaron = 0x0165;
16595  t.tccurl = 0x02a8;
16596  t.tcedilla = 0x0163;
16597  t.tcheharabic = 0x0686;
16598  t.tchehfinalarabic = 0xfb7b;
16599  t.tchehinitialarabic = 0xfb7c;
16600  t.tchehmedialarabic = 0xfb7d;
16601  t.tcircle = 0x24e3;
16602  t.tcircumflexbelow = 0x1e71;
16603  t.tcommaaccent = 0x0163;
16604  t.tdieresis = 0x1e97;
16605  t.tdotaccent = 0x1e6b;
16606  t.tdotbelow = 0x1e6d;
16607  t.tecyrillic = 0x0442;
16608  t.tedescendercyrillic = 0x04ad;
16609  t.teharabic = 0x062a;
16610  t.tehfinalarabic = 0xfe96;
16611  t.tehhahinitialarabic = 0xfca2;
16612  t.tehhahisolatedarabic = 0xfc0c;
16613  t.tehinitialarabic = 0xfe97;
16614  t.tehiragana = 0x3066;
16615  t.tehjeeminitialarabic = 0xfca1;
16616  t.tehjeemisolatedarabic = 0xfc0b;
16617  t.tehmarbutaarabic = 0x0629;
16618  t.tehmarbutafinalarabic = 0xfe94;
16619  t.tehmedialarabic = 0xfe98;
16620  t.tehmeeminitialarabic = 0xfca4;
16621  t.tehmeemisolatedarabic = 0xfc0e;
16622  t.tehnoonfinalarabic = 0xfc73;
16623  t.tekatakana = 0x30c6;
16624  t.tekatakanahalfwidth = 0xff83;
16625  t.telephone = 0x2121;
16626  t.telephoneblack = 0x260e;
16627  t.telishagedolahebrew = 0x05a0;
16628  t.telishaqetanahebrew = 0x05a9;
16629  t.tencircle = 0x2469;
16630  t.tenideographicparen = 0x3229;
16631  t.tenparen = 0x247d;
16632  t.tenperiod = 0x2491;
16633  t.tenroman = 0x2179;
16634  t.tesh = 0x02a7;
16635  t.tet = 0x05d8;
16636  t.tetdagesh = 0xfb38;
16637  t.tetdageshhebrew = 0xfb38;
16638  t.tethebrew = 0x05d8;
16639  t.tetsecyrillic = 0x04b5;
16640  t.tevirhebrew = 0x059b;
16641  t.tevirlefthebrew = 0x059b;
16642  t.thabengali = 0x09a5;
16643  t.thadeva = 0x0925;
16644  t.thagujarati = 0x0aa5;
16645  t.thagurmukhi = 0x0a25;
16646  t.thalarabic = 0x0630;
16647  t.thalfinalarabic = 0xfeac;
16648  t.thanthakhatlowleftthai = 0xf898;
16649  t.thanthakhatlowrightthai = 0xf897;
16650  t.thanthakhatthai = 0x0e4c;
16651  t.thanthakhatupperleftthai = 0xf896;
16652  t.theharabic = 0x062b;
16653  t.thehfinalarabic = 0xfe9a;
16654  t.thehinitialarabic = 0xfe9b;
16655  t.thehmedialarabic = 0xfe9c;
16656  t.thereexists = 0x2203;
16657  t.therefore = 0x2234;
16658  t.theta = 0x03b8;
16659  t.theta1 = 0x03d1;
16660  t.thetasymbolgreek = 0x03d1;
16661  t.thieuthacirclekorean = 0x3279;
16662  t.thieuthaparenkorean = 0x3219;
16663  t.thieuthcirclekorean = 0x326b;
16664  t.thieuthkorean = 0x314c;
16665  t.thieuthparenkorean = 0x320b;
16666  t.thirteencircle = 0x246c;
16667  t.thirteenparen = 0x2480;
16668  t.thirteenperiod = 0x2494;
16669  t.thonangmonthothai = 0x0e11;
16670  t.thook = 0x01ad;
16671  t.thophuthaothai = 0x0e12;
16672  t.thorn = 0x00fe;
16673  t.thothahanthai = 0x0e17;
16674  t.thothanthai = 0x0e10;
16675  t.thothongthai = 0x0e18;
16676  t.thothungthai = 0x0e16;
16677  t.thousandcyrillic = 0x0482;
16678  t.thousandsseparatorarabic = 0x066c;
16679  t.thousandsseparatorpersian = 0x066c;
16680  t.three = 0x0033;
16681  t.threearabic = 0x0663;
16682  t.threebengali = 0x09e9;
16683  t.threecircle = 0x2462;
16684  t.threecircleinversesansserif = 0x278c;
16685  t.threedeva = 0x0969;
16686  t.threeeighths = 0x215c;
16687  t.threegujarati = 0x0ae9;
16688  t.threegurmukhi = 0x0a69;
16689  t.threehackarabic = 0x0663;
16690  t.threehangzhou = 0x3023;
16691  t.threeideographicparen = 0x3222;
16692  t.threeinferior = 0x2083;
16693  t.threemonospace = 0xff13;
16694  t.threenumeratorbengali = 0x09f6;
16695  t.threeoldstyle = 0xf733;
16696  t.threeparen = 0x2476;
16697  t.threeperiod = 0x248a;
16698  t.threepersian = 0x06f3;
16699  t.threequarters = 0x00be;
16700  t.threequartersemdash = 0xf6de;
16701  t.threeroman = 0x2172;
16702  t.threesuperior = 0x00b3;
16703  t.threethai = 0x0e53;
16704  t.thzsquare = 0x3394;
16705  t.tihiragana = 0x3061;
16706  t.tikatakana = 0x30c1;
16707  t.tikatakanahalfwidth = 0xff81;
16708  t.tikeutacirclekorean = 0x3270;
16709  t.tikeutaparenkorean = 0x3210;
16710  t.tikeutcirclekorean = 0x3262;
16711  t.tikeutkorean = 0x3137;
16712  t.tikeutparenkorean = 0x3202;
16713  t.tilde = 0x02dc;
16714  t.tildebelowcmb = 0x0330;
16715  t.tildecmb = 0x0303;
16716  t.tildecomb = 0x0303;
16717  t.tildedoublecmb = 0x0360;
16718  t.tildeoperator = 0x223c;
16719  t.tildeoverlaycmb = 0x0334;
16720  t.tildeverticalcmb = 0x033e;
16721  t.timescircle = 0x2297;
16722  t.tipehahebrew = 0x0596;
16723  t.tipehalefthebrew = 0x0596;
16724  t.tippigurmukhi = 0x0a70;
16725  t.titlocyrilliccmb = 0x0483;
16726  t.tiwnarmenian = 0x057f;
16727  t.tlinebelow = 0x1e6f;
16728  t.tmonospace = 0xff54;
16729  t.toarmenian = 0x0569;
16730  t.tohiragana = 0x3068;
16731  t.tokatakana = 0x30c8;
16732  t.tokatakanahalfwidth = 0xff84;
16733  t.tonebarextrahighmod = 0x02e5;
16734  t.tonebarextralowmod = 0x02e9;
16735  t.tonebarhighmod = 0x02e6;
16736  t.tonebarlowmod = 0x02e8;
16737  t.tonebarmidmod = 0x02e7;
16738  t.tonefive = 0x01bd;
16739  t.tonesix = 0x0185;
16740  t.tonetwo = 0x01a8;
16741  t.tonos = 0x0384;
16742  t.tonsquare = 0x3327;
16743  t.topatakthai = 0x0e0f;
16744  t.tortoiseshellbracketleft = 0x3014;
16745  t.tortoiseshellbracketleftsmall = 0xfe5d;
16746  t.tortoiseshellbracketleftvertical = 0xfe39;
16747  t.tortoiseshellbracketright = 0x3015;
16748  t.tortoiseshellbracketrightsmall = 0xfe5e;
16749  t.tortoiseshellbracketrightvertical = 0xfe3a;
16750  t.totaothai = 0x0e15;
16751  t.tpalatalhook = 0x01ab;
16752  t.tparen = 0x24af;
16753  t.trademark = 0x2122;
16754  t.trademarksans = 0xf8ea;
16755  t.trademarkserif = 0xf6db;
16756  t.tretroflexhook = 0x0288;
16757  t.triagdn = 0x25bc;
16758  t.triaglf = 0x25c4;
16759  t.triagrt = 0x25ba;
16760  t.triagup = 0x25b2;
16761  t.ts = 0x02a6;
16762  t.tsadi = 0x05e6;
16763  t.tsadidagesh = 0xfb46;
16764  t.tsadidageshhebrew = 0xfb46;
16765  t.tsadihebrew = 0x05e6;
16766  t.tsecyrillic = 0x0446;
16767  t.tsere = 0x05b5;
16768  t.tsere12 = 0x05b5;
16769  t.tsere1e = 0x05b5;
16770  t.tsere2b = 0x05b5;
16771  t.tserehebrew = 0x05b5;
16772  t.tserenarrowhebrew = 0x05b5;
16773  t.tserequarterhebrew = 0x05b5;
16774  t.tserewidehebrew = 0x05b5;
16775  t.tshecyrillic = 0x045b;
16776  t.tsuperior = 0xf6f3;
16777  t.ttabengali = 0x099f;
16778  t.ttadeva = 0x091f;
16779  t.ttagujarati = 0x0a9f;
16780  t.ttagurmukhi = 0x0a1f;
16781  t.tteharabic = 0x0679;
16782  t.ttehfinalarabic = 0xfb67;
16783  t.ttehinitialarabic = 0xfb68;
16784  t.ttehmedialarabic = 0xfb69;
16785  t.tthabengali = 0x09a0;
16786  t.tthadeva = 0x0920;
16787  t.tthagujarati = 0x0aa0;
16788  t.tthagurmukhi = 0x0a20;
16789  t.tturned = 0x0287;
16790  t.tuhiragana = 0x3064;
16791  t.tukatakana = 0x30c4;
16792  t.tukatakanahalfwidth = 0xff82;
16793  t.tusmallhiragana = 0x3063;
16794  t.tusmallkatakana = 0x30c3;
16795  t.tusmallkatakanahalfwidth = 0xff6f;
16796  t.twelvecircle = 0x246b;
16797  t.twelveparen = 0x247f;
16798  t.twelveperiod = 0x2493;
16799  t.twelveroman = 0x217b;
16800  t.twentycircle = 0x2473;
16801  t.twentyhangzhou = 0x5344;
16802  t.twentyparen = 0x2487;
16803  t.twentyperiod = 0x249b;
16804  t.two = 0x0032;
16805  t.twoarabic = 0x0662;
16806  t.twobengali = 0x09e8;
16807  t.twocircle = 0x2461;
16808  t.twocircleinversesansserif = 0x278b;
16809  t.twodeva = 0x0968;
16810  t.twodotenleader = 0x2025;
16811  t.twodotleader = 0x2025;
16812  t.twodotleadervertical = 0xfe30;
16813  t.twogujarati = 0x0ae8;
16814  t.twogurmukhi = 0x0a68;
16815  t.twohackarabic = 0x0662;
16816  t.twohangzhou = 0x3022;
16817  t.twoideographicparen = 0x3221;
16818  t.twoinferior = 0x2082;
16819  t.twomonospace = 0xff12;
16820  t.twonumeratorbengali = 0x09f5;
16821  t.twooldstyle = 0xf732;
16822  t.twoparen = 0x2475;
16823  t.twoperiod = 0x2489;
16824  t.twopersian = 0x06f2;
16825  t.tworoman = 0x2171;
16826  t.twostroke = 0x01bb;
16827  t.twosuperior = 0x00b2;
16828  t.twothai = 0x0e52;
16829  t.twothirds = 0x2154;
16830  t.u = 0x0075;
16831  t.uacute = 0x00fa;
16832  t.ubar = 0x0289;
16833  t.ubengali = 0x0989;
16834  t.ubopomofo = 0x3128;
16835  t.ubreve = 0x016d;
16836  t.ucaron = 0x01d4;
16837  t.ucircle = 0x24e4;
16838  t.ucircumflex = 0x00fb;
16839  t.ucircumflexbelow = 0x1e77;
16840  t.ucyrillic = 0x0443;
16841  t.udattadeva = 0x0951;
16842  t.udblacute = 0x0171;
16843  t.udblgrave = 0x0215;
16844  t.udeva = 0x0909;
16845  t.udieresis = 0x00fc;
16846  t.udieresisacute = 0x01d8;
16847  t.udieresisbelow = 0x1e73;
16848  t.udieresiscaron = 0x01da;
16849  t.udieresiscyrillic = 0x04f1;
16850  t.udieresisgrave = 0x01dc;
16851  t.udieresismacron = 0x01d6;
16852  t.udotbelow = 0x1ee5;
16853  t.ugrave = 0x00f9;
16854  t.ugujarati = 0x0a89;
16855  t.ugurmukhi = 0x0a09;
16856  t.uhiragana = 0x3046;
16857  t.uhookabove = 0x1ee7;
16858  t.uhorn = 0x01b0;
16859  t.uhornacute = 0x1ee9;
16860  t.uhorndotbelow = 0x1ef1;
16861  t.uhorngrave = 0x1eeb;
16862  t.uhornhookabove = 0x1eed;
16863  t.uhorntilde = 0x1eef;
16864  t.uhungarumlaut = 0x0171;
16865  t.uhungarumlautcyrillic = 0x04f3;
16866  t.uinvertedbreve = 0x0217;
16867  t.ukatakana = 0x30a6;
16868  t.ukatakanahalfwidth = 0xff73;
16869  t.ukcyrillic = 0x0479;
16870  t.ukorean = 0x315c;
16871  t.umacron = 0x016b;
16872  t.umacroncyrillic = 0x04ef;
16873  t.umacrondieresis = 0x1e7b;
16874  t.umatragurmukhi = 0x0a41;
16875  t.umonospace = 0xff55;
16876  t.underscore = 0x005f;
16877  t.underscoredbl = 0x2017;
16878  t.underscoremonospace = 0xff3f;
16879  t.underscorevertical = 0xfe33;
16880  t.underscorewavy = 0xfe4f;
16881  t.union = 0x222a;
16882  t.universal = 0x2200;
16883  t.uogonek = 0x0173;
16884  t.uparen = 0x24b0;
16885  t.upblock = 0x2580;
16886  t.upperdothebrew = 0x05c4;
16887  t.upsilon = 0x03c5;
16888  t.upsilondieresis = 0x03cb;
16889  t.upsilondieresistonos = 0x03b0;
16890  t.upsilonlatin = 0x028a;
16891  t.upsilontonos = 0x03cd;
16892  t.uptackbelowcmb = 0x031d;
16893  t.uptackmod = 0x02d4;
16894  t.uragurmukhi = 0x0a73;
16895  t.uring = 0x016f;
16896  t.ushortcyrillic = 0x045e;
16897  t.usmallhiragana = 0x3045;
16898  t.usmallkatakana = 0x30a5;
16899  t.usmallkatakanahalfwidth = 0xff69;
16900  t.ustraightcyrillic = 0x04af;
16901  t.ustraightstrokecyrillic = 0x04b1;
16902  t.utilde = 0x0169;
16903  t.utildeacute = 0x1e79;
16904  t.utildebelow = 0x1e75;
16905  t.uubengali = 0x098a;
16906  t.uudeva = 0x090a;
16907  t.uugujarati = 0x0a8a;
16908  t.uugurmukhi = 0x0a0a;
16909  t.uumatragurmukhi = 0x0a42;
16910  t.uuvowelsignbengali = 0x09c2;
16911  t.uuvowelsigndeva = 0x0942;
16912  t.uuvowelsigngujarati = 0x0ac2;
16913  t.uvowelsignbengali = 0x09c1;
16914  t.uvowelsigndeva = 0x0941;
16915  t.uvowelsigngujarati = 0x0ac1;
16916  t.v = 0x0076;
16917  t.vadeva = 0x0935;
16918  t.vagujarati = 0x0ab5;
16919  t.vagurmukhi = 0x0a35;
16920  t.vakatakana = 0x30f7;
16921  t.vav = 0x05d5;
16922  t.vavdagesh = 0xfb35;
16923  t.vavdagesh65 = 0xfb35;
16924  t.vavdageshhebrew = 0xfb35;
16925  t.vavhebrew = 0x05d5;
16926  t.vavholam = 0xfb4b;
16927  t.vavholamhebrew = 0xfb4b;
16928  t.vavvavhebrew = 0x05f0;
16929  t.vavyodhebrew = 0x05f1;
16930  t.vcircle = 0x24e5;
16931  t.vdotbelow = 0x1e7f;
16932  t.vecyrillic = 0x0432;
16933  t.veharabic = 0x06a4;
16934  t.vehfinalarabic = 0xfb6b;
16935  t.vehinitialarabic = 0xfb6c;
16936  t.vehmedialarabic = 0xfb6d;
16937  t.vekatakana = 0x30f9;
16938  t.venus = 0x2640;
16939  t.verticalbar = 0x007c;
16940  t.verticallineabovecmb = 0x030d;
16941  t.verticallinebelowcmb = 0x0329;
16942  t.verticallinelowmod = 0x02cc;
16943  t.verticallinemod = 0x02c8;
16944  t.vewarmenian = 0x057e;
16945  t.vhook = 0x028b;
16946  t.vikatakana = 0x30f8;
16947  t.viramabengali = 0x09cd;
16948  t.viramadeva = 0x094d;
16949  t.viramagujarati = 0x0acd;
16950  t.visargabengali = 0x0983;
16951  t.visargadeva = 0x0903;
16952  t.visargagujarati = 0x0a83;
16953  t.vmonospace = 0xff56;
16954  t.voarmenian = 0x0578;
16955  t.voicediterationhiragana = 0x309e;
16956  t.voicediterationkatakana = 0x30fe;
16957  t.voicedmarkkana = 0x309b;
16958  t.voicedmarkkanahalfwidth = 0xff9e;
16959  t.vokatakana = 0x30fa;
16960  t.vparen = 0x24b1;
16961  t.vtilde = 0x1e7d;
16962  t.vturned = 0x028c;
16963  t.vuhiragana = 0x3094;
16964  t.vukatakana = 0x30f4;
16965  t.w = 0x0077;
16966  t.wacute = 0x1e83;
16967  t.waekorean = 0x3159;
16968  t.wahiragana = 0x308f;
16969  t.wakatakana = 0x30ef;
16970  t.wakatakanahalfwidth = 0xff9c;
16971  t.wakorean = 0x3158;
16972  t.wasmallhiragana = 0x308e;
16973  t.wasmallkatakana = 0x30ee;
16974  t.wattosquare = 0x3357;
16975  t.wavedash = 0x301c;
16976  t.wavyunderscorevertical = 0xfe34;
16977  t.wawarabic = 0x0648;
16978  t.wawfinalarabic = 0xfeee;
16979  t.wawhamzaabovearabic = 0x0624;
16980  t.wawhamzaabovefinalarabic = 0xfe86;
16981  t.wbsquare = 0x33dd;
16982  t.wcircle = 0x24e6;
16983  t.wcircumflex = 0x0175;
16984  t.wdieresis = 0x1e85;
16985  t.wdotaccent = 0x1e87;
16986  t.wdotbelow = 0x1e89;
16987  t.wehiragana = 0x3091;
16988  t.weierstrass = 0x2118;
16989  t.wekatakana = 0x30f1;
16990  t.wekorean = 0x315e;
16991  t.weokorean = 0x315d;
16992  t.wgrave = 0x1e81;
16993  t.whitebullet = 0x25e6;
16994  t.whitecircle = 0x25cb;
16995  t.whitecircleinverse = 0x25d9;
16996  t.whitecornerbracketleft = 0x300e;
16997  t.whitecornerbracketleftvertical = 0xfe43;
16998  t.whitecornerbracketright = 0x300f;
16999  t.whitecornerbracketrightvertical = 0xfe44;
17000  t.whitediamond = 0x25c7;
17001  t.whitediamondcontainingblacksmalldiamond = 0x25c8;
17002  t.whitedownpointingsmalltriangle = 0x25bf;
17003  t.whitedownpointingtriangle = 0x25bd;
17004  t.whiteleftpointingsmalltriangle = 0x25c3;
17005  t.whiteleftpointingtriangle = 0x25c1;
17006  t.whitelenticularbracketleft = 0x3016;
17007  t.whitelenticularbracketright = 0x3017;
17008  t.whiterightpointingsmalltriangle = 0x25b9;
17009  t.whiterightpointingtriangle = 0x25b7;
17010  t.whitesmallsquare = 0x25ab;
17011  t.whitesmilingface = 0x263a;
17012  t.whitesquare = 0x25a1;
17013  t.whitestar = 0x2606;
17014  t.whitetelephone = 0x260f;
17015  t.whitetortoiseshellbracketleft = 0x3018;
17016  t.whitetortoiseshellbracketright = 0x3019;
17017  t.whiteuppointingsmalltriangle = 0x25b5;
17018  t.whiteuppointingtriangle = 0x25b3;
17019  t.wihiragana = 0x3090;
17020  t.wikatakana = 0x30f0;
17021  t.wikorean = 0x315f;
17022  t.wmonospace = 0xff57;
17023  t.wohiragana = 0x3092;
17024  t.wokatakana = 0x30f2;
17025  t.wokatakanahalfwidth = 0xff66;
17026  t.won = 0x20a9;
17027  t.wonmonospace = 0xffe6;
17028  t.wowaenthai = 0x0e27;
17029  t.wparen = 0x24b2;
17030  t.wring = 0x1e98;
17031  t.wsuperior = 0x02b7;
17032  t.wturned = 0x028d;
17033  t.wynn = 0x01bf;
17034  t.x = 0x0078;
17035  t.xabovecmb = 0x033d;
17036  t.xbopomofo = 0x3112;
17037  t.xcircle = 0x24e7;
17038  t.xdieresis = 0x1e8d;
17039  t.xdotaccent = 0x1e8b;
17040  t.xeharmenian = 0x056d;
17041  t.xi = 0x03be;
17042  t.xmonospace = 0xff58;
17043  t.xparen = 0x24b3;
17044  t.xsuperior = 0x02e3;
17045  t.y = 0x0079;
17046  t.yaadosquare = 0x334e;
17047  t.yabengali = 0x09af;
17048  t.yacute = 0x00fd;
17049  t.yadeva = 0x092f;
17050  t.yaekorean = 0x3152;
17051  t.yagujarati = 0x0aaf;
17052  t.yagurmukhi = 0x0a2f;
17053  t.yahiragana = 0x3084;
17054  t.yakatakana = 0x30e4;
17055  t.yakatakanahalfwidth = 0xff94;
17056  t.yakorean = 0x3151;
17057  t.yamakkanthai = 0x0e4e;
17058  t.yasmallhiragana = 0x3083;
17059  t.yasmallkatakana = 0x30e3;
17060  t.yasmallkatakanahalfwidth = 0xff6c;
17061  t.yatcyrillic = 0x0463;
17062  t.ycircle = 0x24e8;
17063  t.ycircumflex = 0x0177;
17064  t.ydieresis = 0x00ff;
17065  t.ydotaccent = 0x1e8f;
17066  t.ydotbelow = 0x1ef5;
17067  t.yeharabic = 0x064a;
17068  t.yehbarreearabic = 0x06d2;
17069  t.yehbarreefinalarabic = 0xfbaf;
17070  t.yehfinalarabic = 0xfef2;
17071  t.yehhamzaabovearabic = 0x0626;
17072  t.yehhamzaabovefinalarabic = 0xfe8a;
17073  t.yehhamzaaboveinitialarabic = 0xfe8b;
17074  t.yehhamzaabovemedialarabic = 0xfe8c;
17075  t.yehinitialarabic = 0xfef3;
17076  t.yehmedialarabic = 0xfef4;
17077  t.yehmeeminitialarabic = 0xfcdd;
17078  t.yehmeemisolatedarabic = 0xfc58;
17079  t.yehnoonfinalarabic = 0xfc94;
17080  t.yehthreedotsbelowarabic = 0x06d1;
17081  t.yekorean = 0x3156;
17082  t.yen = 0x00a5;
17083  t.yenmonospace = 0xffe5;
17084  t.yeokorean = 0x3155;
17085  t.yeorinhieuhkorean = 0x3186;
17086  t.yerahbenyomohebrew = 0x05aa;
17087  t.yerahbenyomolefthebrew = 0x05aa;
17088  t.yericyrillic = 0x044b;
17089  t.yerudieresiscyrillic = 0x04f9;
17090  t.yesieungkorean = 0x3181;
17091  t.yesieungpansioskorean = 0x3183;
17092  t.yesieungsioskorean = 0x3182;
17093  t.yetivhebrew = 0x059a;
17094  t.ygrave = 0x1ef3;
17095  t.yhook = 0x01b4;
17096  t.yhookabove = 0x1ef7;
17097  t.yiarmenian = 0x0575;
17098  t.yicyrillic = 0x0457;
17099  t.yikorean = 0x3162;
17100  t.yinyang = 0x262f;
17101  t.yiwnarmenian = 0x0582;
17102  t.ymonospace = 0xff59;
17103  t.yod = 0x05d9;
17104  t.yoddagesh = 0xfb39;
17105  t.yoddageshhebrew = 0xfb39;
17106  t.yodhebrew = 0x05d9;
17107  t.yodyodhebrew = 0x05f2;
17108  t.yodyodpatahhebrew = 0xfb1f;
17109  t.yohiragana = 0x3088;
17110  t.yoikorean = 0x3189;
17111  t.yokatakana = 0x30e8;
17112  t.yokatakanahalfwidth = 0xff96;
17113  t.yokorean = 0x315b;
17114  t.yosmallhiragana = 0x3087;
17115  t.yosmallkatakana = 0x30e7;
17116  t.yosmallkatakanahalfwidth = 0xff6e;
17117  t.yotgreek = 0x03f3;
17118  t.yoyaekorean = 0x3188;
17119  t.yoyakorean = 0x3187;
17120  t.yoyakthai = 0x0e22;
17121  t.yoyingthai = 0x0e0d;
17122  t.yparen = 0x24b4;
17123  t.ypogegrammeni = 0x037a;
17124  t.ypogegrammenigreekcmb = 0x0345;
17125  t.yr = 0x01a6;
17126  t.yring = 0x1e99;
17127  t.ysuperior = 0x02b8;
17128  t.ytilde = 0x1ef9;
17129  t.yturned = 0x028e;
17130  t.yuhiragana = 0x3086;
17131  t.yuikorean = 0x318c;
17132  t.yukatakana = 0x30e6;
17133  t.yukatakanahalfwidth = 0xff95;
17134  t.yukorean = 0x3160;
17135  t.yusbigcyrillic = 0x046b;
17136  t.yusbigiotifiedcyrillic = 0x046d;
17137  t.yuslittlecyrillic = 0x0467;
17138  t.yuslittleiotifiedcyrillic = 0x0469;
17139  t.yusmallhiragana = 0x3085;
17140  t.yusmallkatakana = 0x30e5;
17141  t.yusmallkatakanahalfwidth = 0xff6d;
17142  t.yuyekorean = 0x318b;
17143  t.yuyeokorean = 0x318a;
17144  t.yyabengali = 0x09df;
17145  t.yyadeva = 0x095f;
17146  t.z = 0x007a;
17147  t.zaarmenian = 0x0566;
17148  t.zacute = 0x017a;
17149  t.zadeva = 0x095b;
17150  t.zagurmukhi = 0x0a5b;
17151  t.zaharabic = 0x0638;
17152  t.zahfinalarabic = 0xfec6;
17153  t.zahinitialarabic = 0xfec7;
17154  t.zahiragana = 0x3056;
17155  t.zahmedialarabic = 0xfec8;
17156  t.zainarabic = 0x0632;
17157  t.zainfinalarabic = 0xfeb0;
17158  t.zakatakana = 0x30b6;
17159  t.zaqefgadolhebrew = 0x0595;
17160  t.zaqefqatanhebrew = 0x0594;
17161  t.zarqahebrew = 0x0598;
17162  t.zayin = 0x05d6;
17163  t.zayindagesh = 0xfb36;
17164  t.zayindageshhebrew = 0xfb36;
17165  t.zayinhebrew = 0x05d6;
17166  t.zbopomofo = 0x3117;
17167  t.zcaron = 0x017e;
17168  t.zcircle = 0x24e9;
17169  t.zcircumflex = 0x1e91;
17170  t.zcurl = 0x0291;
17171  t.zdot = 0x017c;
17172  t.zdotaccent = 0x017c;
17173  t.zdotbelow = 0x1e93;
17174  t.zecyrillic = 0x0437;
17175  t.zedescendercyrillic = 0x0499;
17176  t.zedieresiscyrillic = 0x04df;
17177  t.zehiragana = 0x305c;
17178  t.zekatakana = 0x30bc;
17179  t.zero = 0x0030;
17180  t.zeroarabic = 0x0660;
17181  t.zerobengali = 0x09e6;
17182  t.zerodeva = 0x0966;
17183  t.zerogujarati = 0x0ae6;
17184  t.zerogurmukhi = 0x0a66;
17185  t.zerohackarabic = 0x0660;
17186  t.zeroinferior = 0x2080;
17187  t.zeromonospace = 0xff10;
17188  t.zerooldstyle = 0xf730;
17189  t.zeropersian = 0x06f0;
17190  t.zerosuperior = 0x2070;
17191  t.zerothai = 0x0e50;
17192  t.zerowidthjoiner = 0xfeff;
17193  t.zerowidthnonjoiner = 0x200c;
17194  t.zerowidthspace = 0x200b;
17195  t.zeta = 0x03b6;
17196  t.zhbopomofo = 0x3113;
17197  t.zhearmenian = 0x056a;
17198  t.zhebrevecyrillic = 0x04c2;
17199  t.zhecyrillic = 0x0436;
17200  t.zhedescendercyrillic = 0x0497;
17201  t.zhedieresiscyrillic = 0x04dd;
17202  t.zihiragana = 0x3058;
17203  t.zikatakana = 0x30b8;
17204  t.zinorhebrew = 0x05ae;
17205  t.zlinebelow = 0x1e95;
17206  t.zmonospace = 0xff5a;
17207  t.zohiragana = 0x305e;
17208  t.zokatakana = 0x30be;
17209  t.zparen = 0x24b5;
17210  t.zretroflexhook = 0x0290;
17211  t.zstroke = 0x01b6;
17212  t.zuhiragana = 0x305a;
17213  t.zukatakana = 0x30ba;
17214  t[".notdef"] = 0x0000;
17215  t.angbracketleftbig = 0x2329;
17216  t.angbracketleftBig = 0x2329;
17217  t.angbracketleftbigg = 0x2329;
17218  t.angbracketleftBigg = 0x2329;
17219  t.angbracketrightBig = 0x232a;
17220  t.angbracketrightbig = 0x232a;
17221  t.angbracketrightBigg = 0x232a;
17222  t.angbracketrightbigg = 0x232a;
17223  t.arrowhookleft = 0x21aa;
17224  t.arrowhookright = 0x21a9;
17225  t.arrowlefttophalf = 0x21bc;
17226  t.arrowleftbothalf = 0x21bd;
17227  t.arrownortheast = 0x2197;
17228  t.arrownorthwest = 0x2196;
17229  t.arrowrighttophalf = 0x21c0;
17230  t.arrowrightbothalf = 0x21c1;
17231  t.arrowsoutheast = 0x2198;
17232  t.arrowsouthwest = 0x2199;
17233  t.backslashbig = 0x2216;
17234  t.backslashBig = 0x2216;
17235  t.backslashBigg = 0x2216;
17236  t.backslashbigg = 0x2216;
17237  t.bardbl = 0x2016;
17238  t.bracehtipdownleft = 0xfe37;
17239  t.bracehtipdownright = 0xfe37;
17240  t.bracehtipupleft = 0xfe38;
17241  t.bracehtipupright = 0xfe38;
17242  t.braceleftBig = 0x007b;
17243  t.braceleftbig = 0x007b;
17244  t.braceleftbigg = 0x007b;
17245  t.braceleftBigg = 0x007b;
17246  t.bracerightBig = 0x007d;
17247  t.bracerightbig = 0x007d;
17248  t.bracerightbigg = 0x007d;
17249  t.bracerightBigg = 0x007d;
17250  t.bracketleftbig = 0x005b;
17251  t.bracketleftBig = 0x005b;
17252  t.bracketleftbigg = 0x005b;
17253  t.bracketleftBigg = 0x005b;
17254  t.bracketrightBig = 0x005d;
17255  t.bracketrightbig = 0x005d;
17256  t.bracketrightbigg = 0x005d;
17257  t.bracketrightBigg = 0x005d;
17258  t.ceilingleftbig = 0x2308;
17259  t.ceilingleftBig = 0x2308;
17260  t.ceilingleftBigg = 0x2308;
17261  t.ceilingleftbigg = 0x2308;
17262  t.ceilingrightbig = 0x2309;
17263  t.ceilingrightBig = 0x2309;
17264  t.ceilingrightbigg = 0x2309;
17265  t.ceilingrightBigg = 0x2309;
17266  t.circledotdisplay = 0x2299;
17267  t.circledottext = 0x2299;
17268  t.circlemultiplydisplay = 0x2297;
17269  t.circlemultiplytext = 0x2297;
17270  t.circleplusdisplay = 0x2295;
17271  t.circleplustext = 0x2295;
17272  t.contintegraldisplay = 0x222e;
17273  t.contintegraltext = 0x222e;
17274  t.coproductdisplay = 0x2210;
17275  t.coproducttext = 0x2210;
17276  t.floorleftBig = 0x230a;
17277  t.floorleftbig = 0x230a;
17278  t.floorleftbigg = 0x230a;
17279  t.floorleftBigg = 0x230a;
17280  t.floorrightbig = 0x230b;
17281  t.floorrightBig = 0x230b;
17282  t.floorrightBigg = 0x230b;
17283  t.floorrightbigg = 0x230b;
17284  t.hatwide = 0x0302;
17285  t.hatwider = 0x0302;
17286  t.hatwidest = 0x0302;
17287  t.intercal = 0x1d40;
17288  t.integraldisplay = 0x222b;
17289  t.integraltext = 0x222b;
17290  t.intersectiondisplay = 0x22c2;
17291  t.intersectiontext = 0x22c2;
17292  t.logicalanddisplay = 0x2227;
17293  t.logicalandtext = 0x2227;
17294  t.logicalordisplay = 0x2228;
17295  t.logicalortext = 0x2228;
17296  t.parenleftBig = 0x0028;
17297  t.parenleftbig = 0x0028;
17298  t.parenleftBigg = 0x0028;
17299  t.parenleftbigg = 0x0028;
17300  t.parenrightBig = 0x0029;
17301  t.parenrightbig = 0x0029;
17302  t.parenrightBigg = 0x0029;
17303  t.parenrightbigg = 0x0029;
17304  t.prime = 0x2032;
17305  t.productdisplay = 0x220f;
17306  t.producttext = 0x220f;
17307  t.radicalbig = 0x221a;
17308  t.radicalBig = 0x221a;
17309  t.radicalBigg = 0x221a;
17310  t.radicalbigg = 0x221a;
17311  t.radicalbt = 0x221a;
17312  t.radicaltp = 0x221a;
17313  t.radicalvertex = 0x221a;
17314  t.slashbig = 0x002f;
17315  t.slashBig = 0x002f;
17316  t.slashBigg = 0x002f;
17317  t.slashbigg = 0x002f;
17318  t.summationdisplay = 0x2211;
17319  t.summationtext = 0x2211;
17320  t.tildewide = 0x02dc;
17321  t.tildewider = 0x02dc;
17322  t.tildewidest = 0x02dc;
17323  t.uniondisplay = 0x22c3;
17324  t.unionmultidisplay = 0x228e;
17325  t.unionmultitext = 0x228e;
17326  t.unionsqdisplay = 0x2294;
17327  t.unionsqtext = 0x2294;
17328  t.uniontext = 0x22c3;
17329  t.vextenddouble = 0x2225;
17330  t.vextendsingle = 0x2223;
17331});
17332const getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
17333  t.space = 0x0020;
17334  t.a1 = 0x2701;
17335  t.a2 = 0x2702;
17336  t.a202 = 0x2703;
17337  t.a3 = 0x2704;
17338  t.a4 = 0x260e;
17339  t.a5 = 0x2706;
17340  t.a119 = 0x2707;
17341  t.a118 = 0x2708;
17342  t.a117 = 0x2709;
17343  t.a11 = 0x261b;
17344  t.a12 = 0x261e;
17345  t.a13 = 0x270c;
17346  t.a14 = 0x270d;
17347  t.a15 = 0x270e;
17348  t.a16 = 0x270f;
17349  t.a105 = 0x2710;
17350  t.a17 = 0x2711;
17351  t.a18 = 0x2712;
17352  t.a19 = 0x2713;
17353  t.a20 = 0x2714;
17354  t.a21 = 0x2715;
17355  t.a22 = 0x2716;
17356  t.a23 = 0x2717;
17357  t.a24 = 0x2718;
17358  t.a25 = 0x2719;
17359  t.a26 = 0x271a;
17360  t.a27 = 0x271b;
17361  t.a28 = 0x271c;
17362  t.a6 = 0x271d;
17363  t.a7 = 0x271e;
17364  t.a8 = 0x271f;
17365  t.a9 = 0x2720;
17366  t.a10 = 0x2721;
17367  t.a29 = 0x2722;
17368  t.a30 = 0x2723;
17369  t.a31 = 0x2724;
17370  t.a32 = 0x2725;
17371  t.a33 = 0x2726;
17372  t.a34 = 0x2727;
17373  t.a35 = 0x2605;
17374  t.a36 = 0x2729;
17375  t.a37 = 0x272a;
17376  t.a38 = 0x272b;
17377  t.a39 = 0x272c;
17378  t.a40 = 0x272d;
17379  t.a41 = 0x272e;
17380  t.a42 = 0x272f;
17381  t.a43 = 0x2730;
17382  t.a44 = 0x2731;
17383  t.a45 = 0x2732;
17384  t.a46 = 0x2733;
17385  t.a47 = 0x2734;
17386  t.a48 = 0x2735;
17387  t.a49 = 0x2736;
17388  t.a50 = 0x2737;
17389  t.a51 = 0x2738;
17390  t.a52 = 0x2739;
17391  t.a53 = 0x273a;
17392  t.a54 = 0x273b;
17393  t.a55 = 0x273c;
17394  t.a56 = 0x273d;
17395  t.a57 = 0x273e;
17396  t.a58 = 0x273f;
17397  t.a59 = 0x2740;
17398  t.a60 = 0x2741;
17399  t.a61 = 0x2742;
17400  t.a62 = 0x2743;
17401  t.a63 = 0x2744;
17402  t.a64 = 0x2745;
17403  t.a65 = 0x2746;
17404  t.a66 = 0x2747;
17405  t.a67 = 0x2748;
17406  t.a68 = 0x2749;
17407  t.a69 = 0x274a;
17408  t.a70 = 0x274b;
17409  t.a71 = 0x25cf;
17410  t.a72 = 0x274d;
17411  t.a73 = 0x25a0;
17412  t.a74 = 0x274f;
17413  t.a203 = 0x2750;
17414  t.a75 = 0x2751;
17415  t.a204 = 0x2752;
17416  t.a76 = 0x25b2;
17417  t.a77 = 0x25bc;
17418  t.a78 = 0x25c6;
17419  t.a79 = 0x2756;
17420  t.a81 = 0x25d7;
17421  t.a82 = 0x2758;
17422  t.a83 = 0x2759;
17423  t.a84 = 0x275a;
17424  t.a97 = 0x275b;
17425  t.a98 = 0x275c;
17426  t.a99 = 0x275d;
17427  t.a100 = 0x275e;
17428  t.a101 = 0x2761;
17429  t.a102 = 0x2762;
17430  t.a103 = 0x2763;
17431  t.a104 = 0x2764;
17432  t.a106 = 0x2765;
17433  t.a107 = 0x2766;
17434  t.a108 = 0x2767;
17435  t.a112 = 0x2663;
17436  t.a111 = 0x2666;
17437  t.a110 = 0x2665;
17438  t.a109 = 0x2660;
17439  t.a120 = 0x2460;
17440  t.a121 = 0x2461;
17441  t.a122 = 0x2462;
17442  t.a123 = 0x2463;
17443  t.a124 = 0x2464;
17444  t.a125 = 0x2465;
17445  t.a126 = 0x2466;
17446  t.a127 = 0x2467;
17447  t.a128 = 0x2468;
17448  t.a129 = 0x2469;
17449  t.a130 = 0x2776;
17450  t.a131 = 0x2777;
17451  t.a132 = 0x2778;
17452  t.a133 = 0x2779;
17453  t.a134 = 0x277a;
17454  t.a135 = 0x277b;
17455  t.a136 = 0x277c;
17456  t.a137 = 0x277d;
17457  t.a138 = 0x277e;
17458  t.a139 = 0x277f;
17459  t.a140 = 0x2780;
17460  t.a141 = 0x2781;
17461  t.a142 = 0x2782;
17462  t.a143 = 0x2783;
17463  t.a144 = 0x2784;
17464  t.a145 = 0x2785;
17465  t.a146 = 0x2786;
17466  t.a147 = 0x2787;
17467  t.a148 = 0x2788;
17468  t.a149 = 0x2789;
17469  t.a150 = 0x278a;
17470  t.a151 = 0x278b;
17471  t.a152 = 0x278c;
17472  t.a153 = 0x278d;
17473  t.a154 = 0x278e;
17474  t.a155 = 0x278f;
17475  t.a156 = 0x2790;
17476  t.a157 = 0x2791;
17477  t.a158 = 0x2792;
17478  t.a159 = 0x2793;
17479  t.a160 = 0x2794;
17480  t.a161 = 0x2192;
17481  t.a163 = 0x2194;
17482  t.a164 = 0x2195;
17483  t.a196 = 0x2798;
17484  t.a165 = 0x2799;
17485  t.a192 = 0x279a;
17486  t.a166 = 0x279b;
17487  t.a167 = 0x279c;
17488  t.a168 = 0x279d;
17489  t.a169 = 0x279e;
17490  t.a170 = 0x279f;
17491  t.a171 = 0x27a0;
17492  t.a172 = 0x27a1;
17493  t.a173 = 0x27a2;
17494  t.a162 = 0x27a3;
17495  t.a174 = 0x27a4;
17496  t.a175 = 0x27a5;
17497  t.a176 = 0x27a6;
17498  t.a177 = 0x27a7;
17499  t.a178 = 0x27a8;
17500  t.a179 = 0x27a9;
17501  t.a193 = 0x27aa;
17502  t.a180 = 0x27ab;
17503  t.a199 = 0x27ac;
17504  t.a181 = 0x27ad;
17505  t.a200 = 0x27ae;
17506  t.a182 = 0x27af;
17507  t.a201 = 0x27b1;
17508  t.a183 = 0x27b2;
17509  t.a184 = 0x27b3;
17510  t.a197 = 0x27b4;
17511  t.a185 = 0x27b5;
17512  t.a194 = 0x27b6;
17513  t.a198 = 0x27b7;
17514  t.a186 = 0x27b8;
17515  t.a195 = 0x27b9;
17516  t.a187 = 0x27ba;
17517  t.a188 = 0x27bb;
17518  t.a189 = 0x27bc;
17519  t.a190 = 0x27bd;
17520  t.a191 = 0x27be;
17521  t.a89 = 0x2768;
17522  t.a90 = 0x2769;
17523  t.a93 = 0x276a;
17524  t.a94 = 0x276b;
17525  t.a91 = 0x276c;
17526  t.a92 = 0x276d;
17527  t.a205 = 0x276e;
17528  t.a85 = 0x276f;
17529  t.a206 = 0x2770;
17530  t.a86 = 0x2771;
17531  t.a87 = 0x2772;
17532  t.a88 = 0x2773;
17533  t.a95 = 0x2774;
17534  t.a96 = 0x2775;
17535  t[".notdef"] = 0x0000;
17536});
17537
17538;// ./src/core/unicode.js
17539
17540const getSpecialPUASymbols = getLookupTableFactory(function (t) {
17541  t[63721] = 0x00a9;
17542  t[63193] = 0x00a9;
17543  t[63720] = 0x00ae;
17544  t[63194] = 0x00ae;
17545  t[63722] = 0x2122;
17546  t[63195] = 0x2122;
17547  t[637
vendor: 7,525 bytes, lines 17547-17661
1754729] = 0x23a7;
17548  t[63730] = 0x23a8;
17549  t[63731] = 0x23a9;
17550  t[63740] = 0x23ab;
17551  t[63741] = 0x23ac;
17552  t[63742] = 0x23ad;
17553  t[63726] = 0x23a1;
17554  t[63727] = 0x23a2;
17555  t[63728] = 0x23a3;
17556  t[63737] = 0x23a4;
17557  t[63738] = 0x23a5;
17558  t[63739] = 0x23a6;
17559  t[63723] = 0x239b;
17560  t[63724] = 0x239c;
17561  t[63725] = 0x239d;
17562  t[63734] = 0x239e;
17563  t[63735] = 0x239f;
17564  t[63736] = 0x23a0;
17565});
17566function mapSpecialUnicodeValues(code) {
17567  if (code >= 0xfff0 && code <= 0xffff) {
17568    return 0;
17569  } else if (code >= 0xf600 && code <= 0xf8ff) {
17570    return getSpecialPUASymbols()[code] || code;
17571  } else if (code === 0x00ad) {
17572    return 0x002d;
17573  }
17574  return code;
17575}
17576function getUnicodeForGlyph(name, glyphsUnicodeMap) {
17577  let unicode = glyphsUnicodeMap[name];
17578  if (unicode !== undefined) {
17579    return unicode;
17580  }
17581  if (!name) {
17582    return -1;
17583  }
17584  if (name[0] === "u") {
17585    const nameLen = name.length;
17586    let hexStr;
17587    if (nameLen === 7 && name[1] === "n" && name[2] === "i") {
17588      hexStr = name.substring(3);
17589    } else if (nameLen >= 5 && nameLen <= 7) {
17590      hexStr = name.substring(1);
17591    } else {
17592      return -1;
17593    }
17594    if (hexStr === hexStr.toUpperCase()) {
17595      unicode = parseInt(hexStr, 16);
17596      if (unicode >= 0) {
17597        return unicode;
17598      }
17599    }
17600  }
17601  return -1;
17602}
17603const UnicodeRanges = [[0x0000, 0x007f], [0x0080, 0x00ff], [0x0100, 0x017f], [0x0180, 0x024f], [0x0250, 0x02af, 0x1d00, 0x1d7f, 0x1d80, 0x1dbf], [0x02b0, 0x02ff, 0xa700, 0xa71f], [0x0300, 0x036f, 0x1dc0, 0x1dff], [0x0370, 0x03ff], [0x2c80, 0x2cff], [0x0400, 0x04ff, 0x0500, 0x052f, 0x2de0, 0x2dff, 0xa640, 0xa69f], [0x0530, 0x058f], [0x0590, 0x05ff], [0xa500, 0xa63f], [0x0600, 0x06ff, 0x0750, 0x077f], [0x07c0, 0x07ff], [0x0900, 0x097f], [0x0980, 0x09ff], [0x0a00, 0x0a7f], [0x0a80, 0x0aff], [0x0b00, 0x0b7f], [0x0b80, 0x0bff], [0x0c00, 0x0c7f], [0x0c80, 0x0cff], [0x0d00, 0x0d7f], [0x0e00, 0x0e7f], [0x0e80, 0x0eff], [0x10a0, 0x10ff, 0x2d00, 0x2d2f], [0x1b00, 0x1b7f], [0x1100, 0x11ff], [0x1e00, 0x1eff, 0x2c60, 0x2c7f, 0xa720, 0xa7ff], [0x1f00, 0x1fff], [0x2000, 0x206f, 0x2e00, 0x2e7f], [0x2070, 0x209f], [0x20a0, 0x20cf], [0x20d0, 0x20ff], [0x2100, 0x214f], [0x2150, 0x218f], [0x2190, 0x21ff, 0x27f0, 0x27ff, 0x2900, 0x297f, 0x2b00, 0x2bff], [0x2200, 0x22ff, 0x2a00, 0x2aff, 0x27c0, 0x27ef, 0x2980, 0x29ff], [0x2300, 0x23ff], [0x2400, 0x243f], [0x2440, 0x245f], [0x2460, 0x24ff], [0x2500, 0x257f], [0x2580, 0x259f], [0x25a0, 0x25ff], [0x2600, 0x26ff], [0x2700, 0x27bf], [0x3000, 0x303f], [0x3040, 0x309f], [0x30a0, 0x30ff, 0x31f0, 0x31ff], [0x3100, 0x312f, 0x31a0, 0x31bf], [0x3130, 0x318f], [0xa840, 0xa87f], [0x3200, 0x32ff], [0x3300, 0x33ff], [0xac00, 0xd7af], [0xd800, 0xdfff], [0x10900, 0x1091f], [0x4e00, 0x9fff, 0x2e80, 0x2eff, 0x2f00, 0x2fdf, 0x2ff0, 0x2fff, 0x3400, 0x4dbf, 0x20000, 0x2a6df, 0x3190, 0x319f], [0xe000, 0xf8ff], [0x31c0, 0x31ef, 0xf900, 0xfaff, 0x2f800, 0x2fa1f], [0xfb00, 0xfb4f], [0xfb50, 0xfdff], [0xfe20, 0xfe2f], [0xfe10, 0xfe1f], [0xfe50, 0xfe6f], [0xfe70, 0xfeff], [0xff00, 0xffef], [0xfff0, 0xffff], [0x0f00, 0x0fff], [0x0700, 0x074f], [0x0780, 0x07bf], [0x0d80, 0x0dff], [0x1000, 0x109f], [0x1200, 0x137f, 0x1380, 0x139f, 0x2d80, 0x2ddf], [0x13a0, 0x13ff], [0x1400, 0x167f], [0x1680, 0x169f], [0x16a0, 0x16ff], [0x1780, 0x17ff], [0x1800, 0x18af], [0x2800, 0x28ff], [0xa000, 0xa48f], [0x1700, 0x171f, 0x1720, 0x173f, 0x1740, 0x175f, 0x1760, 0x177f], [0x10300, 0x1032f], [0x10330, 0x1034f], [0x10400, 0x1044f], [0x1d000, 0x1d0ff, 0x1d100, 0x1d1ff, 0x1d200, 0x1d24f], [0x1d400, 0x1d7ff], [0xff000, 0xffffd], [0xfe00, 0xfe0f, 0xe0100, 0xe01ef], [0xe0000, 0xe007f], [0x1900, 0x194f], [0x1950, 0x197f], [0x1980, 0x19df], [0x1a00, 0x1a1f], [0x2c00, 0x2c5f], [0x2d30, 0x2d7f], [0x4dc0, 0x4dff], [0xa800, 0xa82f], [0x10000, 0x1007f, 0x10080, 0x100ff, 0x10100, 0x1013f], [0x10140, 0x1018f], [0x10380, 0x1039f], [0x103a0, 0x103df], [0x10450, 0x1047f], [0x10480, 0x104af], [0x10800, 0x1083f], [0x10a00, 0x10a5f], [0x1d300, 0x1d35f], [0x12000, 0x123ff, 0x12400, 0x1247f], [0x1d360, 0x1d37f], [0x1b80, 0x1bbf], [0x1c00, 0x1c4f], [0x1c50, 0x1c7f], [0xa880, 0xa8df], [0xa900, 0xa92f], [0xa930, 0xa95f], [0xaa00, 0xaa5f], [0x10190, 0x101cf], [0x101d0, 0x101ff], [0x102a0, 0x102df, 0x10280, 0x1029f, 0x10920, 0x1093f], [0x1f030, 0x1f09f, 0x1f000, 0x1f02f]];
17604function getUnicodeRangeFor(value, lastPosition = -1) {
17605  if (lastPosition !== -1) {
17606    const range = UnicodeRanges[lastPosition];
17607    for (let i = 0, ii = range.length; i < ii; i += 2) {
17608      if (value >= range[i] && value <= range[i + 1]) {
17609        return lastPosition;
17610      }
17611    }
17612  }
17613  for (let i = 0, ii = UnicodeRanges.length; i < ii; i++) {
17614    const range = UnicodeRanges[i];
17615    for (let j = 0, jj = range.length; j < jj; j += 2) {
17616      if (value >= range[j] && value <= range[j + 1]) {
17617        return i;
17618      }
17619    }
17620  }
17621  return -1;
17622}
17623const SpecialCharRegExp = /^(\s)|(\p{Mn})|(\p{Cf})$/u;
17624const CategoryCache = new Map();
17625function getCharUnicodeCategory(char) {
17626  const cachedCategory = CategoryCache.get(char);
17627  if (cachedCategory) {
17628    return cachedCategory;
17629  }
17630  const groups = char.match(SpecialCharRegExp);
17631  const category = {
17632    isWhitespace: !!groups?.[1],
17633    isZeroWidthDiacritic: !!groups?.[2],
17634    isInvisibleFormatMark: !!groups?.[3]
17635  };
17636  CategoryCache.set(char, category);
17637  return category;
17638}
17639function clearUnicodeCaches() {
17640  CategoryCache.clear();
17641}
17642
17643;// ./src/core/fonts_utils.js
17644
17645
17646
17647
17648
17649const SEAC_ANALYSIS_ENABLED = true;
17650const FontFlags = {
17651  FixedPitch: 1,
17652  Serif: 2,
17653  Symbolic: 4,
17654  Script: 8,
17655  Nonsymbolic: 32,
17656  Italic: 64,
17657  AllCap: 65536,
17658  SmallCap: 131072,
17659  ForceBold: 262144
17660};
17661const MacStandardGlyphOrdering = [".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodce
vendor: 2,670 bytes, lines 17661-17713
17661ntered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dcroat"];
17662function recoverGlyphName(name, glyphsUnicodeMap) {
17663  if (glyphsUnicodeMap[name] !== undefined) {
17664    return name;
17665  }
17666  const unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
17667  if (unicode !== -1) {
17668    for (const key in glyphsUnicodeMap) {
17669      if (glyphsUnicodeMap[key] === unicode) {
17670        return key;
17671      }
17672    }
17673  }
17674  info("Unable to recover a standard glyph name for: " + name);
17675  return name;
17676}
17677function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
17678  const charCodeToGlyphId = Object.create(null);
17679  let glyphId, charCode, baseEncoding;
17680  const isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
17681  if (properties.isInternalFont) {
17682    baseEncoding = builtInEncoding;
17683    for (charCode = 0; charCode < baseEncoding.length; charCode++) {
17684      glyphId = glyphNames.indexOf(baseEncoding[charCode]);
17685      charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
17686    }
17687  } else if (properties.baseEncodingName) {
17688    baseEncoding = getEncoding(properties.baseEncodingName);
17689    for (charCode = 0; charCode < baseEncoding.length; charCode++) {
17690      glyphId = glyphNames.indexOf(baseEncoding[charCode]);
17691      charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
17692    }
17693  } else if (isSymbolicFont) {
17694    for (charCode in builtInEncoding) {
17695      charCodeToGlyphId[charCode] = builtInEncoding[charCode];
17696    }
17697  } else {
17698    baseEncoding = StandardEncoding;
17699    for (charCode = 0; charCode < baseEncoding.length; charCode++) {
17700      glyphId = glyphNames.indexOf(baseEncoding[charCode]);
17701      charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
17702    }
17703  }
17704  const differences = properties.differences;
17705  let glyphsUnicodeMap;
17706  if (differences) {
17707    for (charCode in differences) {
17708      const glyphName = differences[charCode];
17709      glyphId = glyphNames.indexOf(glyphName);
17710      if (glyphId === -1) {
17711        if (!glyphsUnicodeMap) {
17712          glyphsUnicodeMap = getGlyphsUnicode();
17713        }
vendor: 34,471 bytes, lines 17713-18610
17713
17714        const standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
17715        if (standardGlyphName !== glyphName) {
17716          glyphId = glyphNames.indexOf(standardGlyphName);
17717        }
17718      }
17719      charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : 0;
17720    }
17721  }
17722  return charCodeToGlyphId;
17723}
17724function normalizeFontName(name) {
17725  return name.replaceAll(/[,_]/g, "-").replaceAll(/\s/g, "");
17726}
17727const getVerticalPresentationForm = getLookupTableFactory(t => {
17728  t[0x2013] = 0xfe32;
17729  t[0x2014] = 0xfe31;
17730  t[0x2025] = 0xfe30;
17731  t[0x2026] = 0xfe19;
17732  t[0x3001] = 0xfe11;
17733  t[0x3002] = 0xfe12;
17734  t[0x3008] = 0xfe3f;
17735  t[0x3009] = 0xfe40;
17736  t[0x300a] = 0xfe3d;
17737  t[0x300b] = 0xfe3e;
17738  t[0x300c] = 0xfe41;
17739  t[0x300d] = 0xfe42;
17740  t[0x300e] = 0xfe43;
17741  t[0x300f] = 0xfe44;
17742  t[0x3010] = 0xfe3b;
17743  t[0x3011] = 0xfe3c;
17744  t[0x3014] = 0xfe39;
17745  t[0x3015] = 0xfe3a;
17746  t[0x3016] = 0xfe17;
17747  t[0x3017] = 0xfe18;
17748  t[0xfe4f] = 0xfe34;
17749  t[0xff01] = 0xfe15;
17750  t[0xff08] = 0xfe35;
17751  t[0xff09] = 0xfe36;
17752  t[0xff0c] = 0xfe10;
17753  t[0xff1a] = 0xfe13;
17754  t[0xff1b] = 0xfe14;
17755  t[0xff1f] = 0xfe16;
17756  t[0xff3b] = 0xfe47;
17757  t[0xff3d] = 0xfe48;
17758  t[0xff3f] = 0xfe33;
17759  t[0xff5b] = 0xfe37;
17760  t[0xff5d] = 0xfe38;
17761});
17762const MAX_SIZE_TO_COMPILE = 1000;
17763function compileType3Glyph({
17764  data: img,
17765  width,
17766  height
17767}) {
17768  if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
17769    return null;
17770  }
17771  const POINT_TO_PROCESS_LIMIT = 1000;
17772  const POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
17773  const width1 = width + 1;
17774  const points = new Uint8Array(width1 * (height + 1));
17775  let i, j, j0;
17776  const lineSize = width + 7 & ~7;
17777  const data = new Uint8Array(lineSize * height);
17778  let pos = 0;
17779  for (const elem of img) {
17780    let mask = 128;
17781    while (mask > 0) {
17782      data[pos++] = elem & mask ? 0 : 255;
17783      mask >>= 1;
17784    }
17785  }
17786  let count = 0;
17787  pos = 0;
17788  if (data[pos] !== 0) {
17789    points[0] = 1;
17790    ++count;
17791  }
17792  for (j = 1; j < width; j++) {
17793    if (data[pos] !== data[pos + 1]) {
17794      points[j] = data[pos] ? 2 : 1;
17795      ++count;
17796    }
17797    pos++;
17798  }
17799  if (data[pos] !== 0) {
17800    points[j] = 2;
17801    ++count;
17802  }
17803  for (i = 1; i < height; i++) {
17804    pos = i * lineSize;
17805    j0 = i * width1;
17806    if (data[pos - lineSize] !== data[pos]) {
17807      points[j0] = data[pos] ? 1 : 8;
17808      ++count;
17809    }
17810    let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
17811    for (j = 1; j < width; j++) {
17812      sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
17813      if (POINT_TYPES[sum]) {
17814        points[j0 + j] = POINT_TYPES[sum];
17815        ++count;
17816      }
17817      pos++;
17818    }
17819    if (data[pos - lineSize] !== data[pos]) {
17820      points[j0 + j] = data[pos] ? 2 : 4;
17821      ++count;
17822    }
17823    if (count > POINT_TO_PROCESS_LIMIT) {
17824      return null;
17825    }
17826  }
17827  pos = lineSize * (height - 1);
17828  j0 = i * width1;
17829  if (data[pos] !== 0) {
17830    points[j0] = 8;
17831    ++count;
17832  }
17833  for (j = 1; j < width; j++) {
17834    if (data[pos] !== data[pos + 1]) {
17835      points[j0 + j] = data[pos] ? 4 : 8;
17836      ++count;
17837    }
17838    pos++;
17839  }
17840  if (data[pos] !== 0) {
17841    points[j0 + j] = 4;
17842    ++count;
17843  }
17844  if (count > POINT_TO_PROCESS_LIMIT) {
17845    return null;
17846  }
17847  const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
17848  const pathBuf = [];
17849  const {
17850    a,
17851    b,
17852    c,
17853    d,
17854    e,
17855    f
17856  } = new DOMMatrix().scaleSelf(1 / width, -1 / height).translateSelf(0, -height);
17857  for (i = 0; count && i <= height; i++) {
17858    let p = i * width1;
17859    const end = p + width;
17860    while (p < end && !points[p]) {
17861      p++;
17862    }
17863    if (p === end) {
17864      continue;
17865    }
17866    let x = p % width1;
17867    let y = i;
17868    pathBuf.push(DrawOPS.moveTo, a * x + c * y + e, b * x + d * y + f);
17869    const p0 = p;
17870    let type = points[p];
17871    do {
17872      const step = steps[type];
17873      do {
17874        p += step;
17875      } while (!points[p]);
17876      const pp = points[p];
17877      if (pp !== 5 && pp !== 10) {
17878        type = pp;
17879        points[p] = 0;
17880      } else {
17881        type = pp & 0x33 * type >> 4;
17882        points[p] &= type >> 2 | type << 2;
17883      }
17884      x = p % width1;
17885      y = p / width1 | 0;
17886      pathBuf.push(DrawOPS.lineTo, a * x + c * y + e, b * x + d * y + f);
17887      if (!points[p]) {
17888        --count;
17889      }
17890    } while (p0 !== p);
17891    --i;
17892  }
17893  return [OPS.rawFillPath, [new Float32Array(pathBuf)], new Float32Array([0, 0, width, height])];
17894}
17895
17896;// ./src/core/charsets.js
17897const ISOAdobeCharset = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron"];
17898const ExpertCharset = [".notdef", "space", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
17899const ExpertSubsetCharset = [".notdef", "space", "dollaroldstyle", "dollarsuperior", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "hyphensuperior", "colonmonetary", "onefitted", "rupiah", "centoldstyle", "figuredash", "hypheninferior", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior"];
17900
17901;// ./src/core/data_builder.js
17902
17903
17904class DataBuilder {
17905  #buf;
17906  #bufLength = 1024;
17907  #hasExactLength = false;
17908  #pos = 0;
17909  #view;
17910  constructor({
17911    exactLength = 0,
17912    minLength = 0
17913  }) {
17914    this.#hasExactLength = !!exactLength;
17915    this.#initBuf(exactLength || minLength);
17916  }
17917  #initBuf(minLength) {
17918    if (this.#hasExactLength) {
17919      this.#bufLength = minLength;
17920    } else {
17921      while (this.#bufLength < minLength) {
17922        this.#bufLength *= 2;
17923      }
17924    }
17925    const newBuf = new Uint8Array(this.#bufLength);
17926    if (this.#buf) {
17927      newBuf.set(this.#buf, 0);
17928    }
17929    this.#buf = newBuf;
17930    this.#view = new DataView(newBuf.buffer);
17931  }
17932  get data() {
17933    return this.#buf.subarray(0, this.#pos);
17934  }
17935  get length() {
17936    return this.#pos;
17937  }
17938  skip(n) {
17939    this.#pos += n;
17940  }
17941  setArray(arr) {
17942    const newPos = this.#pos + arr.length;
17943    if (!this.#hasExactLength && newPos > this.#bufLength) {
17944      this.#initBuf(newPos);
17945    }
17946    this.#buf.set(arr, this.#pos);
17947    this.#pos = newPos;
17948  }
17949  setInt16(val) {
17950    const newPos = this.#pos + 2;
17951    if (!this.#hasExactLength && newPos > this.#bufLength) {
17952      this.#initBuf(newPos);
17953    }
17954    this.#view.setInt16(this.#pos, val);
17955    this.#pos = newPos;
17956  }
17957  setSafeInt16(val) {
17958    const newPos = this.#pos + 2;
17959    if (!this.#hasExactLength && newPos > this.#bufLength) {
17960      this.#initBuf(newPos);
17961    }
17962    this.#view.setInt16(this.#pos, MathClamp(val, -0x8000, 0x7fff));
17963    this.#pos = newPos;
17964  }
17965  setInt32(val) {
17966    const newPos = this.#pos + 4;
17967    if (!this.#hasExactLength && newPos > this.#bufLength) {
17968      this.#initBuf(newPos);
17969    }
17970    this.#view.setInt32(this.#pos, val);
17971    this.#pos = newPos;
17972  }
17973}
17974
17975;// ./src/core/cff_parser.js
17976
17977
17978
17979
17980
17981const MAX_SUBR_NESTING = 10;
17982function looksLikeUnsigned16BitNegative(coord) {
17983  return coord > 0x7fff && coord <= 0xffff;
17984}
17985function recoverSigned16BitBBox(bbox, onlyLowerLeft = false) {
17986  return Util.normalizeRect(bbox.map((coord, i) => (!onlyLowerLeft || i < 2) && looksLikeUnsigned16BitNegative(coord) ? coord - 0x10000 : coord));
17987}
17988const CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
17989const NUM_STANDARD_CFF_STRINGS = 391;
17990const DEFAULT_BLUE_SCALE = 0.039625;
17991const DEFAULT_BLUE_SHIFT = 7;
17992const DEFAULT_BLUE_FUZZ = 1;
17993const DEFAULT_EXPANSION_FACTOR = 0.06;
17994const CharstringValidationData = [null, {
17995  id: "hstem",
17996  min: 2,
17997  stackClearing: true,
17998  stem: true
17999}, null, {
18000  id: "vstem",
18001  min: 2,
18002  stackClearing: true,
18003  stem: true
18004}, {
18005  id: "vmoveto",
18006  min: 1,
18007  stackClearing: true
18008}, {
18009  id: "rlineto",
18010  min: 2,
18011  resetStack: true
18012}, {
18013  id: "hlineto",
18014  min: 1,
18015  resetStack: true
18016}, {
18017  id: "vlineto",
18018  min: 1,
18019  resetStack: true
18020}, {
18021  id: "rrcurveto",
18022  min: 6,
18023  resetStack: true
18024}, null, {
18025  id: "callsubr",
18026  min: 1
18027}, {
18028  id: "return",
18029  min: 0
18030}, null, null, {
18031  id: "endchar",
18032  min: 0,
18033  stackClearing: true
18034}, null, null, null, {
18035  id: "hstemhm",
18036  min: 2,
18037  stackClearing: true,
18038  stem: true
18039}, {
18040  id: "hintmask",
18041  min: 0,
18042  stackClearing: true
18043}, {
18044  id: "cntrmask",
18045  min: 0,
18046  stackClearing: true
18047}, {
18048  id: "rmoveto",
18049  min: 2,
18050  stackClearing: true
18051}, {
18052  id: "hmoveto",
18053  min: 1,
18054  stackClearing: true
18055}, {
18056  id: "vstemhm",
18057  min: 2,
18058  stackClearing: true,
18059  stem: true
18060}, {
18061  id: "rcurveline",
18062  min: 8,
18063  resetStack: true
18064}, {
18065  id: "rlinecurve",
18066  min: 8,
18067  resetStack: true
18068}, {
18069  id: "vvcurveto",
18070  min: 4,
18071  resetStack: true
18072}, {
18073  id: "hhcurveto",
18074  min: 4,
18075  resetStack: true
18076}, null, {
18077  id: "callgsubr",
18078  min: 1
18079}, {
18080  id: "vhcurveto",
18081  min: 4,
18082  resetStack: true
18083}, {
18084  id: "hvcurveto",
18085  min: 4,
18086  resetStack: true
18087}];
18088const CharstringValidationData12 = [null, null, null, {
18089  id: "and",
18090  min: 2,
18091  stackDelta: -1
18092}, {
18093  id: "or",
18094  min: 2,
18095  stackDelta: -1
18096}, {
18097  id: "not",
18098  min: 1,
18099  stackDelta: 0
18100}, null, null, null, {
18101  id: "abs",
18102  min: 1,
18103  stackDelta: 0
18104}, {
18105  id: "add",
18106  min: 2,
18107  stackDelta: -1,
18108  stackFn(stack, index) {
18109    stack[index - 2] = stack[index - 2] + stack[index - 1];
18110  }
18111}, {
18112  id: "sub",
18113  min: 2,
18114  stackDelta: -1,
18115  stackFn(stack, index) {
18116    stack[index - 2] = stack[index - 2] - stack[index - 1];
18117  }
18118}, {
18119  id: "div",
18120  min: 2,
18121  stackDelta: -1,
18122  stackFn(stack, index) {
18123    stack[index - 2] = stack[index - 2] / stack[index - 1];
18124  }
18125}, null, {
18126  id: "neg",
18127  min: 1,
18128  stackDelta: 0,
18129  stackFn(stack, index) {
18130    stack[index - 1] = -stack[index - 1];
18131  }
18132}, {
18133  id: "eq",
18134  min: 2,
18135  stackDelta: -1
18136}, null, null, {
18137  id: "drop",
18138  min: 1,
18139  stackDelta: -1
18140}, null, {
18141  id: "put",
18142  min: 2,
18143  stackDelta: -2
18144}, {
18145  id: "get",
18146  min: 1,
18147  stackDelta: 0
18148}, {
18149  id: "ifelse",
18150  min: 4,
18151  stackDelta: -3
18152}, {
18153  id: "random",
18154  min: 0,
18155  stackDelta: 1
18156}, {
18157  id: "mul",
18158  min: 2,
18159  stackDelta: -1,
18160  stackFn(stack, index) {
18161    stack[index - 2] = stack[index - 2] * stack[index - 1];
18162  }
18163}, null, {
18164  id: "sqrt",
18165  min: 1,
18166  stackDelta: 0
18167}, {
18168  id: "dup",
18169  min: 1,
18170  stackDelta: 1
18171}, {
18172  id: "exch",
18173  min: 2,
18174  stackDelta: 0
18175}, {
18176  id: "index",
18177  min: 2,
18178  stackDelta: 0
18179}, {
18180  id: "roll",
18181  min: 3,
18182  stackDelta: -2
18183}, null, null, null, {
18184  id: "hflex",
18185  min: 7,
18186  resetStack: true
18187}, {
18188  id: "flex",
18189  min: 13,
18190  resetStack: true
18191}, {
18192  id: "hflex1",
18193  min: 9,
18194  resetStack: true
18195}, {
18196  id: "flex1",
18197  min: 11,
18198  resetStack: true
18199}];
18200class CFFParser {
18201  constructor(file, properties, seacAnalysisEnabled) {
18202    this.bytes = file.getBytes();
18203    this.properties = properties;
18204    this.seacAnalysisEnabled = !!seacAnalysisEnabled;
18205  }
18206  parse() {
18207    const properties = this.properties;
18208    const cff = new CFF(this.bytes.length);
18209    this.cff = cff;
18210    const header = this.parseHeader();
18211    const nameIndex = this.parseIndex(header.endPos);
18212    const topDictIndex = this.parseIndex(nameIndex.endPos);
18213    const stringIndex = this.parseIndex(topDictIndex.endPos);
18214    const globalSubrIndex = this.parseIndex(stringIndex.endPos);
18215    const topDictParsed = this.parseDict(topDictIndex.obj.get(0));
18216    const topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
18217    cff.header = header.obj;
18218    cff.names = this.parseNameIndex(nameIndex.obj);
18219    cff.strings = this.parseStringIndex(stringIndex.obj);
18220    cff.topDict = topDict;
18221    cff.globalSubrIndex = globalSubrIndex.obj;
18222    this.parsePrivateDict(cff.topDict);
18223    cff.isCIDFont = topDict.hasName("ROS");
18224    const charStringOffset = topDict.getByName("CharStrings");
18225    const charStringIndex = this.parseIndex(charStringOffset).obj;
18226    cff.charStringCount = charStringIndex.count;
18227    const fontMatrix = topDict.getByName("FontMatrix");
18228    if (fontMatrix) {
18229      properties.fontMatrix = fontMatrix;
18230    }
18231    let fontBBox = topDict.getByName("FontBBox");
18232    const descriptorBBox = properties.bbox?.some(coord => coord !== 0) ? recoverSigned16BitBBox(properties.bbox) : null;
18233    const cffBBoxHasUnsignedLowerLeft = fontBBox?.slice(0, 2).some(looksLikeUnsigned16BitNegative);
18234    const cffBBoxHasUnsignedCoords = fontBBox?.some(looksLikeUnsigned16BitNegative);
18235    if (fontBBox?.every(coord => coord === 0) && descriptorBBox) {
18236      fontBBox = descriptorBBox;
18237      topDict.setByName("FontBBox", fontBBox);
18238    } else if (cffBBoxHasUnsignedCoords) {
18239      const recoveredFontBBox = recoverSigned16BitBBox(fontBBox);
18240      const descriptorCorroborates = descriptorBBox && properties.bbox.some(coord => coord < 0) && !properties.bbox.some(looksLikeUnsigned16BitNegative) && isArrayEqual(recoveredFontBBox, descriptorBBox);
18241      if (descriptorCorroborates || cffBBoxHasUnsignedLowerLeft) {
18242        fontBBox = descriptorCorroborates ? recoveredFontBBox : recoverSigned16BitBBox(fontBBox, true);
18243        topDict.setByName("FontBBox", fontBBox);
18244      }
18245    }
18246    if (fontBBox?.some(coord => coord !== 0)) {
18247      properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
18248      properties.descent = Math.min(fontBBox[1], fontBBox[3]);
18249      properties.ascentScaled = true;
18250    }
18251    let charset, encoding;
18252    if (cff.isCIDFont) {
18253      const fdArrayIndex = this.parseIndex(topDict.getByName("FDArray")).obj;
18254      for (let i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
18255        const dictRaw = fdArrayIndex.get(i);
18256        const fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
18257        this.parsePrivateDict(fontDict);
18258        cff.fdArray.push(fontDict);
18259      }
18260      encoding = null;
18261      charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, true);
18262      cff.fdSelect = this.parseFDSelect(topDict.getByName("FDSelect"), charStringIndex.count);
18263    } else {
18264      charset = this.parseCharsets(topDict.getByName("charset"), charStringIndex.count, cff.strings, false);
18265      encoding = this.parseEncoding(topDict.getByName("Encoding"), properties, cff.strings, charset.charset);
18266    }
18267    cff.charset = charset;
18268    cff.encoding = encoding;
18269    const charStringsAndSeacs = this.parseCharStrings({
18270      charStrings: charStringIndex,
18271      localSubrIndex: topDict.privateDict.subrsIndex,
18272      globalSubrIndex: globalSubrIndex.obj,
18273      fdSelect: cff.fdSelect,
18274      fdArray: cff.fdArray,
18275      privateDict: topDict.privateDict
18276    });
18277    cff.charStrings = charStringsAndSeacs.charStrings;
18278    cff.seacs = charStringsAndSeacs.seacs;
18279    cff.widths = charStringsAndSeacs.widths;
18280    return cff;
18281  }
18282  parseHeader() {
18283    let bytes = this.bytes;
18284    const bytesLength = bytes.length;
18285    let offset = 0;
18286    while (offset < bytesLength && bytes[offset] !== 1) {
18287      ++offset;
18288    }
18289    if (offset >= bytesLength) {
18290      throw new FormatError("Invalid CFF header");
18291    }
18292    if (offset !== 0) {
18293      info("cff data is shifted");
18294      bytes = bytes.subarray(offset);
18295      this.bytes = bytes;
18296    }
18297    const major = bytes[0];
18298    const minor = bytes[1];
18299    const hdrSize = bytes[2];
18300    const offSize = bytes[3];
18301    const header = new CFFHeader(major, minor, hdrSize, offSize);
18302    return {
18303      obj: header,
18304      endPos: hdrSize
18305    };
18306  }
18307  parseDict(dict) {
18308    const view = new DataView(dict.buffer, dict.byteOffset, dict.bytesLength);
18309    let pos = 0;
18310    function parseOperand() {
18311      let value = dict[pos++];
18312      if (value === 30) {
18313        return parseFloatOperand();
18314      } else if (value === 28) {
18315        value = view.getInt16(pos);
18316        pos += 2;
18317        return value;
18318      } else if (value === 29) {
18319        value = view.getInt32(pos);
18320        pos += 4;
18321        return value;
18322      } else if (value >= 32 && value <= 246) {
18323        return value - 139;
18324      } else if (value >= 247 && value <= 250) {
18325        return (value - 247) * 256 + dict[pos++] + 108;
18326      } else if (value >= 251 && value <= 254) {
18327        return -((value - 251) * 256) - dict[pos++] - 108;
18328      }
18329      warn(`CFFParser.parseDict: "${value}" is a reserved command.`);
18330      return NaN;
18331    }
18332    function parseFloatOperand() {
18333      let str = "";
18334      const eof = 15;
18335      const lookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ".", "E", "E-", null, "-"];
18336      const length = dict.length;
18337      while (pos < length) {
18338        const b = dict[pos++];
18339        const b1 = b >> 4;
18340        const b2 = b & 15;
18341        if (b1 === eof) {
18342          break;
18343        }
18344        str += lookup[b1];
18345        if (b2 === eof) {
18346          break;
18347        }
18348        str += lookup[b2];
18349      }
18350      return parseFloat(str);
18351    }
18352    let operands = [];
18353    const entries = [];
18354    pos = 0;
18355    const end = dict.length;
18356    while (pos < end) {
18357      let b = dict[pos];
18358      if (b <= 21) {
18359        if (b === 12) {
18360          b = b << 8 | dict[++pos];
18361        }
18362        entries.push([b, operands]);
18363        operands = [];
18364        ++pos;
18365      } else {
18366        operands.push(parseOperand());
18367      }
18368    }
18369    return entries;
18370  }
18371  parseIndex(pos) {
18372    const cffIndex = new CFFIndex();
18373    const bytes = this.bytes;
18374    const count = bytes[pos++] << 8 | bytes[pos++];
18375    const offsets = [];
18376    let end = pos;
18377    let i, ii;
18378    if (count !== 0) {
18379      const offsetSize = bytes[pos++];
18380      const startPos = pos + (count + 1) * offsetSize - 1;
18381      for (i = 0, ii = count + 1; i < ii; ++i) {
18382        let offset = 0;
18383        for (let j = 0; j < offsetSize; ++j) {
18384          offset <<= 8;
18385          offset += bytes[pos++];
18386        }
18387        offsets.push(startPos + offset);
18388      }
18389      end = offsets[count];
18390    }
18391    for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
18392      const offsetStart = offsets[i];
18393      const offsetEnd = offsets[i + 1];
18394      cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
18395    }
18396    return {
18397      obj: cffIndex,
18398      endPos: end
18399    };
18400  }
18401  parseNameIndex(index) {
18402    const names = [];
18403    for (let i = 0, ii = index.count; i < ii; ++i) {
18404      const name = index.get(i);
18405      names.push(bytesToString(name));
18406    }
18407    return names;
18408  }
18409  parseStringIndex(index) {
18410    const strings = new CFFStrings();
18411    for (let i = 0, ii = index.count; i < ii; ++i) {
18412      const data = index.get(i);
18413      strings.add(bytesToString(data));
18414    }
18415    return strings;
18416  }
18417  createDict(Type, dict, strings) {
18418    const cffDict = new Type(strings);
18419    for (const [key, value] of dict) {
18420      cffDict.setByKey(key, value);
18421    }
18422    return cffDict;
18423  }
18424  parseCharString(state, data, localSubrIndex, globalSubrIndex) {
18425    if (!data || state.callDepth > MAX_SUBR_NESTING) {
18426      return false;
18427    }
18428    const view = new DataView(data.buffer, data.byteOffset, data.bytesLength);
18429    let stackSize = state.stackSize;
18430    const stack = state.stack;
18431    let length = data.length;
18432    for (let j = 0; j < length;) {
18433      const value = data[j++];
18434      let validationCommand = null;
18435      if (value === 12) {
18436        const q = data[j++];
18437        if (q === 0) {
18438          data[j - 2] = 139;
18439          data[j - 1] = 22;
18440          stackSize = 0;
18441        } else {
18442          validationCommand = CharstringValidationData12[q];
18443        }
18444      } else if (value === 28) {
18445        stack[stackSize] = view.getInt16(j);
18446        j += 2;
18447        stackSize++;
18448      } else if (value === 14) {
18449        if (stackSize >= 4) {
18450          stackSize -= 4;
18451          if (this.seacAnalysisEnabled) {
18452            state.seac = stack.slice(stackSize, stackSize + 4);
18453            return false;
18454          }
18455        }
18456        validationCommand = CharstringValidationData[value];
18457      } else if (value >= 32 && value <= 246) {
18458        stack[stackSize] = value - 139;
18459        stackSize++;
18460      } else if (value >= 247 && value <= 254) {
18461        stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
18462        j++;
18463        stackSize++;
18464      } else if (value === 255) {
18465        stack[stackSize] = view.getInt32(j) / 65536;
18466        j += 4;
18467        stackSize++;
18468      } else if (value === 19 || value === 20) {
18469        state.hints += stackSize >> 1;
18470        if (state.hints === 0) {
18471          data.copyWithin(j - 1, j, -1);
18472          j -= 1;
18473          length -= 1;
18474          continue;
18475        }
18476        j += state.hints + 7 >> 3;
18477        stackSize %= 2;
18478        validationCommand = CharstringValidationData[value];
18479      } else if (value === 10 || value === 29) {
18480        const subrsIndex = value === 10 ? localSubrIndex : globalSubrIndex;
18481        if (!subrsIndex) {
18482          validationCommand = CharstringValidationData[value];
18483          warn("Missing subrsIndex for " + validationCommand.id);
18484          return false;
18485        }
18486        let bias = 32768;
18487        if (subrsIndex.count < 1240) {
18488          bias = 107;
18489        } else if (subrsIndex.count < 33900) {
18490          bias = 1131;
18491        }
18492        const subrNumber = stack[--stackSize] + bias;
18493        if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
18494          validationCommand = CharstringValidationData[value];
18495          warn("Out of bounds subrIndex for " + validationCommand.id);
18496          return false;
18497        }
18498        state.stackSize = stackSize;
18499        state.callDepth++;
18500        const valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
18501        if (!valid) {
18502          return false;
18503        }
18504        state.callDepth--;
18505        stackSize = state.stackSize;
18506        continue;
18507      } else if (value === 11) {
18508        state.stackSize = stackSize;
18509        return true;
18510      } else if (value === 0 && j === data.length) {
18511        data[j - 1] = 14;
18512        validationCommand = CharstringValidationData[14];
18513      } else if (value === 9) {
18514        data.copyWithin(j - 1, j, -1);
18515        j -= 1;
18516        length -= 1;
18517        continue;
18518      } else {
18519        validationCommand = CharstringValidationData[value];
18520      }
18521      if (validationCommand) {
18522        if (validationCommand.stem) {
18523          state.hints += stackSize >> 1;
18524          if (value === 3 || value === 23) {
18525            state.hasVStems = true;
18526          } else if (state.hasVStems && (value === 1 || value === 18)) {
18527            warn("CFF stem hints are in wrong order");
18528            data[j - 1] = value === 1 ? 3 : 23;
18529          }
18530        }
18531        if (stackSize < validationCommand.min) {
18532          warn("Not enough parameters for " + validationCommand.id + "; actual: " + stackSize + ", expected: " + validationCommand.min);
18533          if (stackSize === 0) {
18534            data[j - 1] = 14;
18535            return true;
18536          }
18537          return false;
18538        }
18539        if (state.firstStackClearing && validationCommand.stackClearing) {
18540          state.firstStackClearing = false;
18541          stackSize -= validationCommand.min;
18542          if (stackSize >= 2 && validationCommand.stem) {
18543            stackSize %= 2;
18544          } else if (stackSize > 1) {
18545            warn("Found too many parameters for stack-clearing command");
18546          }
18547          if (stackSize > 0) {
18548            state.width = stack[stackSize - 1];
18549          }
18550        }
18551        if ("stackDelta" in validationCommand) {
18552          if ("stackFn" in validationCommand) {
18553            validationCommand.stackFn(stack, stackSize);
18554          }
18555          stackSize += validationCommand.stackDelta;
18556        } else if (validationCommand.stackClearing || validationCommand.resetStack) {
18557          stackSize = 0;
18558        }
18559      }
18560    }
18561    if (length < data.length) {
18562      data.fill(14, length);
18563    }
18564    state.stackSize = stackSize;
18565    return true;
18566  }
18567  parseCharStrings({
18568    charStrings,
18569    localSubrIndex,
18570    globalSubrIndex,
18571    fdSelect,
18572    fdArray,
18573    privateDict
18574  }) {
18575    const seacs = [];
18576    const widths = [];
18577    const count = charStrings.count;
18578    for (let i = 0; i < count; i++) {
18579      const charstring = charStrings.get(i);
18580      const state = {
18581        callDepth: 0,
18582        stackSize: 0,
18583        stack: [],
18584        hints: 0,
18585        firstStackClearing: true,
18586        seac: null,
18587        width: null,
18588        hasVStems: false
18589      };
18590      let valid = true;
18591      let localSubrToUse = null;
18592      let privateDictToUse = privateDict;
18593      if (fdSelect && fdArray.length) {
18594        const fdIndex = fdSelect.getFDIndex(i);
18595        if (fdIndex === -1) {
18596          warn("Glyph index is not in fd select.");
18597          valid = false;
18598        }
18599        if (fdIndex >= fdArray.length) {
18600          warn("Invalid fd index for glyph index.");
18601          valid = false;
18602        }
18603        if (valid) {
18604          privateDictToUse = fdArray[fdIndex].privateDict;
18605          localSubrToUse = privateDictToUse.subrsIndex;
18606        }
18607      } else if (localSubrIndex) {
18608        localSubrToUse = localSubrIndex;
18609      }
18610      
18610if (valid) {
18611        valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
18612      }
vendor: 15,243 bytes, lines 18612-19059
18612
18613      if (state.width !== null) {
18614        const nominalWidth = privateDictToUse.getByName("nominalWidthX");
18615        widths[i] = nominalWidth + state.width;
18616      } else {
18617        const defaultWidth = privateDictToUse.getByName("defaultWidthX");
18618        widths[i] = defaultWidth;
18619      }
18620      if (state.seac !== null) {
18621        seacs[i] = state.seac;
18622      }
18623      if (!valid) {
18624        charStrings.set(i, new Uint8Array([14]));
18625      }
18626    }
18627    return {
18628      charStrings,
18629      seacs,
18630      widths
18631    };
18632  }
18633  emptyPrivateDictionary(parentDict) {
18634    const privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
18635    parentDict.setByKey(18, [0, 0]);
18636    parentDict.privateDict = privateDict;
18637  }
18638  parsePrivateDict(parentDict) {
18639    if (!parentDict.hasName("Private")) {
18640      this.emptyPrivateDictionary(parentDict);
18641      return;
18642    }
18643    const privateOffset = parentDict.getByName("Private");
18644    if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
18645      parentDict.removeByName("Private");
18646      return;
18647    }
18648    const size = privateOffset[0];
18649    const offset = privateOffset[1];
18650    if (size === 0 || offset >= this.bytes.length) {
18651      this.emptyPrivateDictionary(parentDict);
18652      return;
18653    }
18654    if (offset + size > this.bytes.length) {
18655      throw new FormatError("CFF Private DICT extends past end of font");
18656    }
18657    const privateDictEnd = offset + size;
18658    const dictData = this.bytes.subarray(offset, privateDictEnd);
18659    const dict = this.parseDict(dictData);
18660    const privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
18661    parentDict.privateDict = privateDict;
18662    const blueScale = privateDict.getByName("BlueScale");
18663    const blueShift = privateDict.getByName("BlueShift");
18664    const blueFuzz = privateDict.getByName("BlueFuzz");
18665    const expansionFactor = privateDict.getByName("ExpansionFactor");
18666    if (blueScale === 0 && blueShift === 0 && blueFuzz === 0 && expansionFactor === 0) {
18667      privateDict.setByName("BlueScale", DEFAULT_BLUE_SCALE);
18668      privateDict.setByName("BlueShift", DEFAULT_BLUE_SHIFT);
18669      privateDict.setByName("BlueFuzz", DEFAULT_BLUE_FUZZ);
18670    }
18671    if (expansionFactor === 0) {
18672      privateDict.setByName("ExpansionFactor", DEFAULT_EXPANSION_FACTOR);
18673    }
18674    if (blueScale > 0) {
18675      let maxZoneHeight = 0;
18676      for (const zones of [privateDict.getByName("BlueValues"), privateDict.getByName("OtherBlues")]) {
18677        if (!zones) {
18678          continue;
18679        }
18680        for (let i = 1; i < zones.length; i += 2) {
18681          if (zones[i] > maxZoneHeight) {
18682            maxZoneHeight = zones[i];
18683          }
18684        }
18685      }
18686      if (maxZoneHeight > 0) {
18687        const PRECISION = 1e5;
18688        const lowerBound = 0.5 / maxZoneHeight;
18689        const minBlueScale = lowerBound <= DEFAULT_BLUE_SCALE ? Math.ceil(lowerBound * PRECISION) / PRECISION : -Infinity;
18690        const maxBlueScale = Math.floor(PRECISION / maxZoneHeight) / PRECISION;
18691        const clamped = MathClamp(blueScale, minBlueScale, maxBlueScale);
18692        if (clamped !== blueScale) {
18693          privateDict.setByName("BlueScale", clamped);
18694        }
18695      }
18696    }
18697    if (!privateDict.getByName("Subrs")) {
18698      return;
18699    }
18700    const subrsOffset = privateDict.getByName("Subrs");
18701    const relativeOffset = offset + subrsOffset;
18702    if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
18703      this.emptyPrivateDictionary(parentDict);
18704      return;
18705    }
18706    const subrsIndex = this.parseIndex(relativeOffset);
18707    privateDict.subrsIndex = subrsIndex.obj;
18708  }
18709  parseCharsets(pos, length, strings, cid) {
18710    if (pos === 0) {
18711      return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
18712    } else if (pos === 1) {
18713      return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
18714    } else if (pos === 2) {
18715      return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
18716    }
18717    const {
18718      bytes
18719    } = this;
18720    const format = bytes[pos++];
18721    const charset = [cid ? 0 : ".notdef"];
18722    let id, count, i;
18723    length -= 1;
18724    switch (format) {
18725      case 0:
18726        for (i = 0; i < length; i++) {
18727          id = bytes[pos++] << 8 | bytes[pos++];
18728          charset.push(cid ? id : strings.get(id));
18729        }
18730        break;
18731      case 1:
18732        while (charset.length <= length) {
18733          id = bytes[pos++] << 8 | bytes[pos++];
18734          count = bytes[pos++];
18735          for (i = 0; i <= count; i++) {
18736            charset.push(cid ? id++ : strings.get(id++));
18737          }
18738        }
18739        break;
18740      case 2:
18741        while (charset.length <= length) {
18742          id = bytes[pos++] << 8 | bytes[pos++];
18743          count = bytes[pos++] << 8 | bytes[pos++];
18744          for (i = 0; i <= count; i++) {
18745            charset.push(cid ? id++ : strings.get(id++));
18746          }
18747        }
18748        break;
18749      default:
18750        throw new FormatError("Unknown charset format");
18751    }
18752    return new CFFCharset(false, format, charset);
18753  }
18754  parseEncoding(pos, properties, strings, charset) {
18755    const encoding = Object.create(null);
18756    const bytes = this.bytes;
18757    let predefined = false;
18758    let format, i, ii;
18759    let raw = null;
18760    function readSupplement() {
18761      const supplementsCount = bytes[pos++];
18762      for (i = 0; i < supplementsCount; i++) {
18763        const code = bytes[pos++];
18764        const sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
18765        encoding[code] = charset.indexOf(strings.get(sid));
18766      }
18767    }
18768    if (pos === 0 || pos === 1) {
18769      predefined = true;
18770      format = pos;
18771      const baseEncoding = pos ? ExpertEncoding : StandardEncoding;
18772      for (i = 0, ii = charset.length; i < ii; i++) {
18773        const index = baseEncoding.indexOf(charset[i]);
18774        if (index !== -1) {
18775          encoding[index] = i;
18776        }
18777      }
18778    } else {
18779      const dataStart = pos;
18780      format = bytes[pos++];
18781      switch (format & 0x7f) {
18782        case 0:
18783          const glyphsCount = bytes[pos++];
18784          for (i = 1; i <= glyphsCount; i++) {
18785            encoding[bytes[pos++]] = i;
18786          }
18787          break;
18788        case 1:
18789          const rangesCount = bytes[pos++];
18790          let gid = 1;
18791          for (i = 0; i < rangesCount; i++) {
18792            const start = bytes[pos++];
18793            const left = bytes[pos++];
18794            for (let j = start; j <= start + left; j++) {
18795              encoding[j] = gid++;
18796            }
18797          }
18798          break;
18799        default:
18800          throw new FormatError(`Unknown encoding format: ${format} in CFF`);
18801      }
18802      const dataEnd = pos;
18803      if (format & 0x80) {
18804        bytes[dataStart] &= 0x7f;
18805        readSupplement();
18806      }
18807      raw = bytes.subarray(dataStart, dataEnd);
18808    }
18809    format &= 0x7f;
18810    return new CFFEncoding(predefined, format, encoding, raw);
18811  }
18812  parseFDSelect(pos, length) {
18813    const bytes = this.bytes;
18814    const format = bytes[pos++];
18815    const fdSelect = [];
18816    let i;
18817    switch (format) {
18818      case 0:
18819        for (i = 0; i < length; ++i) {
18820          const id = bytes[pos++];
18821          fdSelect.push(id);
18822        }
18823        break;
18824      case 3:
18825        const rangesCount = bytes[pos++] << 8 | bytes[pos++];
18826        for (i = 0; i < rangesCount; ++i) {
18827          let first = bytes[pos++] << 8 | bytes[pos++];
18828          if (i === 0 && first !== 0) {
18829            warn("parseFDSelect: The first range must have a first GID of 0" + " -- trying to recover.");
18830            first = 0;
18831          }
18832          const fdIndex = bytes[pos++];
18833          const next = bytes[pos] << 8 | bytes[pos + 1];
18834          for (let j = first; j < next; ++j) {
18835            fdSelect.push(fdIndex);
18836          }
18837        }
18838        pos += 2;
18839        break;
18840      default:
18841        throw new FormatError(`parseFDSelect: Unknown format "${format}".`);
18842    }
18843    if (fdSelect.length !== length) {
18844      throw new FormatError("parseFDSelect: Invalid font data.");
18845    }
18846    return new CFFFDSelect(format, fdSelect);
18847  }
18848}
18849class CFF {
18850  header = null;
18851  names = [];
18852  topDict = null;
18853  strings = new CFFStrings();
18854  globalSubrIndex = null;
18855  encoding = null;
18856  charset = null;
18857  charStrings = null;
18858  fdArray = [];
18859  fdSelect = null;
18860  isCIDFont = false;
18861  charStringCount = 0;
18862  constructor(rawFileLength = 0) {
18863    this.rawFileLength = rawFileLength;
18864  }
18865  duplicateFirstGlyph() {
18866    if (this.charStrings.count >= 65535) {
18867      warn("Not enough space in charstrings to duplicate first glyph.");
18868      return;
18869    }
18870    const glyphZero = this.charStrings.get(0);
18871    this.charStrings.add(glyphZero);
18872    if (this.isCIDFont) {
18873      this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0]);
18874    }
18875  }
18876  hasGlyphId(id) {
18877    if (id < 0 || id >= this.charStrings.count) {
18878      return false;
18879    }
18880    const glyph = this.charStrings.get(id);
18881    return glyph.length > 0;
18882  }
18883}
18884class CFFHeader {
18885  constructor(major, minor, hdrSize, offSize) {
18886    this.major = major;
18887    this.minor = minor;
18888    this.hdrSize = hdrSize;
18889    this.offSize = offSize;
18890  }
18891}
18892class CFFStrings {
18893  strings = [];
18894  get(index) {
18895    if (index >= 0 && index <= NUM_STANDARD_CFF_STRINGS - 1) {
18896      return CFFStandardStrings[index];
18897    }
18898    if (index - NUM_STANDARD_CFF_STRINGS <= this.strings.length) {
18899      return this.strings[index - NUM_STANDARD_CFF_STRINGS];
18900    }
18901    return CFFStandardStrings[0];
18902  }
18903  getSID(str) {
18904    let index = CFFStandardStrings.indexOf(str);
18905    if (index !== -1) {
18906      return index;
18907    }
18908    index = this.strings.indexOf(str);
18909    if (index !== -1) {
18910      return index + NUM_STANDARD_CFF_STRINGS;
18911    }
18912    return -1;
18913  }
18914  add(value) {
18915    this.strings.push(value);
18916  }
18917  get count() {
18918    return this.strings.length;
18919  }
18920}
18921class CFFIndex {
18922  objects = [];
18923  length = 0;
18924  add(data) {
18925    this.length += data.length;
18926    this.objects.push(data);
18927  }
18928  set(index, data) {
18929    this.length += data.length - this.objects[index].length;
18930    this.objects[index] = data;
18931  }
18932  get(index) {
18933    return this.objects[index];
18934  }
18935  get count() {
18936    return this.objects.length;
18937  }
18938}
18939class CFFDict {
18940  constructor(tables, strings) {
18941    this.keyToNameMap = tables.keyToNameMap;
18942    this.nameToKeyMap = tables.nameToKeyMap;
18943    this.defaults = tables.defaults;
18944    this.types = tables.types;
18945    this.opcodes = tables.opcodes;
18946    this.order = tables.order;
18947    this.strings = strings;
18948    this.values = Object.create(null);
18949  }
18950  setByKey(key, value) {
18951    if (!(key in this.keyToNameMap)) {
18952      return false;
18953    }
18954    if (value.length === 0) {
18955      return true;
18956    }
18957    for (const val of value) {
18958      if (isNaN(val)) {
18959        warn(`Invalid CFFDict value: "${value}" for key "${key}".`);
18960        return true;
18961      }
18962    }
18963    const type = this.types[key];
18964    if (type === "num" || type === "sid" || type === "offset") {
18965      value = value[0];
18966    }
18967    this.values[key] = value;
18968    return true;
18969  }
18970  setByName(name, value) {
18971    if (!(name in this.nameToKeyMap)) {
18972      throw new FormatError(`Invalid dictionary name "${name}"`);
18973    }
18974    this.values[this.nameToKeyMap[name]] = value;
18975  }
18976  hasName(name) {
18977    return this.nameToKeyMap[name] in this.values;
18978  }
18979  getByName(name) {
18980    if (!(name in this.nameToKeyMap)) {
18981      throw new FormatError(`Invalid dictionary name ${name}"`);
18982    }
18983    const key = this.nameToKeyMap[name];
18984    if (!(key in this.values)) {
18985      return this.defaults[key];
18986    }
18987    return this.values[key];
18988  }
18989  removeByName(name) {
18990    delete this.values[this.nameToKeyMap[name]];
18991  }
18992  static createTables(layout) {
18993    const tables = {
18994      keyToNameMap: {},
18995      nameToKeyMap: {},
18996      defaults: {},
18997      types: {},
18998      opcodes: {},
18999      order: []
19000    };
19001    for (const entry of layout) {
19002      const key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
19003      tables.keyToNameMap[key] = entry[1];
19004      tables.nameToKeyMap[entry[1]] = key;
19005      tables.types[key] = entry[2];
19006      tables.defaults[key] = entry[3];
19007      tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];
19008      tables.order.push(key);
19009    }
19010    return tables;
19011  }
19012}
19013const CFFTopDictLayout = [[[12, 30], "ROS", ["sid", "sid", "num"], null], [[12, 20], "SyntheticBase", "num", null], [0, "version", "sid", null], [1, "Notice", "sid", null], [[12, 0], "Copyright", "sid", null], [2, "FullName", "sid", null], [3, "FamilyName", "sid", null], [4, "Weight", "sid", null], [[12, 1], "isFixedPitch", "num", 0], [[12, 2], "ItalicAngle", "num", 0], [[12, 3], "UnderlinePosition", "num", -100], [[12, 4], "UnderlineThickness", "num", 50], [[12, 5], "PaintType", "num", 0], [[12, 6], "CharstringType", "num", 2], [[12, 7], "FontMatrix", ["num", "num", "num", "num", "num", "num"], [0.001, 0, 0, 0.001, 0, 0]], [13, "UniqueID", "num", null], [5, "FontBBox", ["num", "num", "num", "num"], [0, 0, 0, 0]], [[12, 8], "StrokeWidth", "num", 0], [14, "XUID", "array", null], [15, "charset", "offset", 0], [16, "Encoding", "offset", 0], [17, "CharStrings", "offset", 0], [18, "Private", ["offset", "offset"], null], [[12, 21], "PostScript", "sid", null], [[12, 22], "BaseFontName", "sid", null], [[12, 23], "BaseFontBlend", "delta", null], [[12, 31], "CIDFontVersion", "num", 0], [[12, 32], "CIDFontRevision", "num", 0], [[12, 33], "CIDFontType", "num", 0], [[12, 34], "CIDCount", "num", 8720], [[12, 35], "UIDBase", "num", null], [[12, 37], "FDSelect", "offset", null], [[12, 36], "FDArray", "offset", null], [[12, 38], "FontName", "sid", null]];
19014class CFFTopDict extends CFFDict {
19015  static get tables() {
19016    return shadow(this, "tables", this.createTables(CFFTopDictLayout));
19017  }
19018  constructor(strings) {
19019    super(CFFTopDict.tables, strings);
19020    this.privateDict = null;
19021  }
19022}
19023const CFFPrivateDictLayout = [[6, "BlueValues", "delta", null], [7, "OtherBlues", "delta", null], [8, "FamilyBlues", "delta", null], [9, "FamilyOtherBlues", "delta", null], [[12, 9], "BlueScale", "num", DEFAULT_BLUE_SCALE], [[12, 10], "BlueShift", "num", DEFAULT_BLUE_SHIFT], [[12, 11], "BlueFuzz", "num", DEFAULT_BLUE_FUZZ], [10, "StdHW", "num", null], [11, "StdVW", "num", null], [[12, 12], "StemSnapH", "delta", null], [[12, 13], "StemSnapV", "delta", null], [[12, 14], "ForceBold", "num", 0], [[12, 17], "LanguageGroup", "num", 0], [[12, 18], "ExpansionFactor", "num", DEFAULT_EXPANSION_FACTOR], [[12, 19], "initialRandomSeed", "num", 0], [20, "defaultWidthX", "num", 0], [21, "nominalWidthX", "num", 0], [19, "Subrs", "offset", null]];
19024class CFFPrivateDict extends CFFDict {
19025  static get tables() {
19026    return shadow(this, "tables", this.createTables(CFFPrivateDictLayout));
19027  }
19028  constructor(strings) {
19029    super(CFFPrivateDict.tables, strings);
19030    this.subrsIndex = null;
19031  }
19032}
19033const CFFCharsetPredefinedTypes = {
19034  ISO_ADOBE: 0,
19035  EXPERT: 1,
19036  EXPERT_SUBSET: 2
19037};
19038class CFFCharset {
19039  constructor(predefined, format, charset) {
19040    this.predefined = predefined;
19041    this.format = format;
19042    this.charset = charset;
19043  }
19044}
19045class CFFEncoding {
19046  constructor(predefined, format, encoding, raw) {
19047    this.predefined = predefined;
19048    this.format = format;
19049    this.encoding = encoding;
19050    this.raw = raw;
19051  }
19052}
19053class CFFFDSelect {
19054  constructor(format, fdSelect) {
19055    this.format = format;
19056    this.fdSelect = fdSelect;
19057  }
19058  getFDIndex(glyphIndex) {
19059    
19059if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
19060      return -1;
19061    }
19062    return
vendor: 18,928 bytes, lines 19062-19591
19062 this.fdSelect[glyphIndex];
19063  }
19064}
19065class CFFOffsetTracker {
19066  offsets = Object.create(null);
19067  isTracking(key) {
19068    return key in this.offsets;
19069  }
19070  track(key, location) {
19071    if (key in this.offsets) {
19072      throw new FormatError(`Already tracking location of ${key}`);
19073    }
19074    this.offsets[key] = location;
19075  }
19076  offset(value) {
19077    for (const key in this.offsets) {
19078      this.offsets[key] += value;
19079    }
19080  }
19081  setEntryLocation(key, values, output) {
19082    if (!(key in this.offsets)) {
19083      throw new FormatError(`Not tracking location of ${key}`);
19084    }
19085    const data = output.data;
19086    const dataOffset = this.offsets[key];
19087    const size = 5;
19088    for (let i = 0, ii = values.length; i < ii; ++i) {
19089      const offset0 = i * size + dataOffset;
19090      const offset1 = offset0 + 1;
19091      const offset2 = offset0 + 2;
19092      const offset3 = offset0 + 3;
19093      const offset4 = offset0 + 4;
19094      if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
19095        throw new FormatError("writing to an offset that is not empty");
19096      }
19097      const value = values[i];
19098      data[offset0] = 0x1d;
19099      data[offset1] = value >> 24 & 0xff;
19100      data[offset2] = value >> 16 & 0xff;
19101      data[offset3] = value >> 8 & 0xff;
19102      data[offset4] = value & 0xff;
19103    }
19104  }
19105}
19106class CFFCompiler {
19107  constructor(cff) {
19108    this.cff = cff;
19109  }
19110  compile() {
19111    const cff = this.cff;
19112    const output = new DataBuilder({
19113      minLength: cff.rawFileLength
19114    });
19115    const header = this.compileHeader(cff.header);
19116    output.setArray(header);
19117    const nameIndex = this.compileNameIndex(cff.names);
19118    output.setArray(nameIndex);
19119    if (cff.isCIDFont) {
19120      if (cff.topDict.hasName("FontMatrix")) {
19121        const base = cff.topDict.getByName("FontMatrix");
19122        cff.topDict.removeByName("FontMatrix");
19123        for (const subDict of cff.fdArray) {
19124          let matrix = base.slice(0);
19125          if (subDict.hasName("FontMatrix")) {
19126            matrix = Util.transform(matrix, subDict.getByName("FontMatrix"));
19127          }
19128          subDict.setByName("FontMatrix", matrix);
19129        }
19130      }
19131    }
19132    const xuid = cff.topDict.getByName("XUID");
19133    if (xuid?.length > 16) {
19134      cff.topDict.removeByName("XUID");
19135    }
19136    cff.topDict.setByName("charset", 0);
19137    let compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
19138    output.setArray(compiled.output);
19139    const topDictTracker = compiled.trackers[0];
19140    const stringIndex = this.compileStringIndex(cff.strings.strings);
19141    output.setArray(stringIndex);
19142    const globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
19143    output.setArray(globalSubrIndex);
19144    if (cff.encoding && cff.topDict.hasName("Encoding")) {
19145      if (cff.encoding.predefined) {
19146        topDictTracker.setEntryLocation("Encoding", [cff.encoding.format], output);
19147      } else {
19148        const encoding = this.compileEncoding(cff.encoding);
19149        topDictTracker.setEntryLocation("Encoding", [output.length], output);
19150        output.setArray(encoding);
19151      }
19152    }
19153    const charset = this.compileCharset(cff.charset, cff.charStrings.count, cff.strings, cff.isCIDFont);
19154    topDictTracker.setEntryLocation("charset", [output.length], output);
19155    output.setArray(charset);
19156    const charStrings = this.compileCharStrings(cff.charStrings);
19157    topDictTracker.setEntryLocation("CharStrings", [output.length], output);
19158    output.setArray(charStrings);
19159    if (cff.isCIDFont) {
19160      topDictTracker.setEntryLocation("FDSelect", [output.length], output);
19161      const fdSelect = this.compileFDSelect(cff.fdSelect);
19162      output.setArray(fdSelect);
19163      compiled = this.compileTopDicts(cff.fdArray, output.length, true);
19164      topDictTracker.setEntryLocation("FDArray", [output.length], output);
19165      output.setArray(compiled.output);
19166      const fontDictTrackers = compiled.trackers;
19167      this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
19168    }
19169    this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
19170    output.setArray([0]);
19171    return output.data;
19172  }
19173  encodeNumber(value) {
19174    if (Number.isInteger(value)) {
19175      return this.encodeInteger(value);
19176    }
19177    return this.encodeFloat(value);
19178  }
19179  static get EncodeFloatRegExp() {
19180    return shadow(this, "EncodeFloatRegExp", /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/);
19181  }
19182  encodeFloat(num) {
19183    let value = num.toString();
19184    const m = CFFCompiler.EncodeFloatRegExp.exec(value);
19185    if (m) {
19186      const epsilon = parseFloat("1e" + ((m[2] ? +m[2] : 0) + m[1].length));
19187      value = (Math.round(num * epsilon) / epsilon).toString();
19188    }
19189    let nibbles = "";
19190    let i, ii;
19191    for (i = 0, ii = value.length; i < ii; ++i) {
19192      const a = value[i];
19193      if (a === "e") {
19194        nibbles += value[++i] === "-" ? "c" : "b";
19195      } else if (a === ".") {
19196        nibbles += "a";
19197      } else if (a === "-") {
19198        nibbles += "e";
19199      } else {
19200        nibbles += a;
19201      }
19202    }
19203    nibbles += nibbles.length & 1 ? "f" : "ff";
19204    const out = [30];
19205    for (i = 0, ii = nibbles.length; i < ii; i += 2) {
19206      out.push(parseInt(nibbles.substring(i, i + 2), 16));
19207    }
19208    return out;
19209  }
19210  encodeInteger(value) {
19211    let code;
19212    if (value >= -107 && value <= 107) {
19213      code = [value + 139];
19214    } else if (value >= 108 && value <= 1131) {
19215      value -= 108;
19216      code = [(value >> 8) + 247, value & 0xff];
19217    } else if (value >= -1131 && value <= -108) {
19218      value = -value - 108;
19219      code = [(value >> 8) + 251, value & 0xff];
19220    } else if (value >= -32768 && value <= 32767) {
19221      code = [0x1c, value >> 8 & 0xff, value & 0xff];
19222    } else {
19223      code = [0x1d, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff];
19224    }
19225    return code;
19226  }
19227  compileHeader(header) {
19228    return [header.major, header.minor, 4, header.offSize];
19229  }
19230  compileNameIndex(names) {
19231    const nameIndex = new CFFIndex();
19232    for (const name of names) {
19233      const length = Math.min(name.length, 127);
19234      let sanitizedName = new Array(length);
19235      for (let j = 0; j < length; j++) {
19236        let char = name[j];
19237        if (char < "!" || char > "~" || char === "[" || char === "]" || char === "(" || char === ")" || char === "{" || char === "}" || char === "<" || char === ">" || char === "/" || char === "%") {
19238          char = "_";
19239        }
19240        sanitizedName[j] = char;
19241      }
19242      sanitizedName = sanitizedName.join("");
19243      if (sanitizedName === "") {
19244        sanitizedName = "Bad_Font_Name";
19245      }
19246      nameIndex.add(stringToBytes(sanitizedName));
19247    }
19248    return this.compileIndex(nameIndex);
19249  }
19250  compileTopDicts(dicts, length, removeCidKeys) {
19251    const fontDictTrackers = [];
19252    let fdArrayIndex = new CFFIndex();
19253    for (const fontDict of dicts) {
19254      if (removeCidKeys) {
19255        fontDict.removeByName("CIDFontVersion");
19256        fontDict.removeByName("CIDFontRevision");
19257        fontDict.removeByName("CIDFontType");
19258        fontDict.removeByName("CIDCount");
19259        fontDict.removeByName("UIDBase");
19260      }
19261      const fontDictTracker = new CFFOffsetTracker();
19262      const fontDictData = this.compileDict(fontDict, fontDictTracker);
19263      fontDictTrackers.push(fontDictTracker);
19264      fdArrayIndex.add(fontDictData);
19265      fontDictTracker.offset(length);
19266    }
19267    fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
19268    return {
19269      trackers: fontDictTrackers,
19270      output: fdArrayIndex
19271    };
19272  }
19273  compilePrivateDicts(dicts, trackers, output) {
19274    for (let i = 0, ii = dicts.length; i < ii; ++i) {
19275      const fontDict = dicts[i];
19276      const privateDict = fontDict.privateDict;
19277      if (!privateDict || !fontDict.hasName("Private")) {
19278        throw new FormatError("There must be a private dictionary.");
19279      }
19280      const privateDictTracker = new CFFOffsetTracker();
19281      const privateDictData = this.compileDict(privateDict, privateDictTracker);
19282      let outputLength = output.length;
19283      privateDictTracker.offset(outputLength);
19284      if (!privateDictData.length) {
19285        outputLength = 0;
19286      }
19287      trackers[i].setEntryLocation("Private", [privateDictData.length, outputLength], output);
19288      output.setArray(privateDictData);
19289      if (privateDict.subrsIndex && privateDict.hasName("Subrs")) {
19290        const subrs = this.compileIndex(privateDict.subrsIndex);
19291        privateDictTracker.setEntryLocation("Subrs", [privateDictData.length], output);
19292        output.setArray(subrs);
19293      }
19294    }
19295  }
19296  compileDict(dict, offsetTracker) {
19297    const out = [];
19298    for (const key of dict.order) {
19299      if (!(key in dict.values)) {
19300        continue;
19301      }
19302      let values = dict.values[key];
19303      let types = dict.types[key];
19304      if (!Array.isArray(types)) {
19305        types = [types];
19306      }
19307      if (!Array.isArray(values)) {
19308        values = [values];
19309      }
19310      if (values.length === 0) {
19311        continue;
19312      }
19313      for (let j = 0, jj = types.length; j < jj; ++j) {
19314        const type = types[j];
19315        const value = values[j];
19316        switch (type) {
19317          case "num":
19318          case "sid":
19319            out.push(...this.encodeNumber(value));
19320            break;
19321          case "offset":
19322            const name = dict.keyToNameMap[key];
19323            if (!offsetTracker.isTracking(name)) {
19324              offsetTracker.track(name, out.length);
19325            }
19326            out.push(0x1d, 0, 0, 0, 0);
19327            break;
19328          case "array":
19329          case "delta":
19330            out.push(...this.encodeNumber(value));
19331            for (let k = 1, kk = values.length; k < kk; ++k) {
19332              out.push(...this.encodeNumber(values[k]));
19333            }
19334            break;
19335          default:
19336            throw new FormatError(`Unknown data type of ${type}`);
19337        }
19338      }
19339      out.push(...dict.opcodes[key]);
19340    }
19341    return out;
19342  }
19343  compileStringIndex(strings) {
19344    const stringIndex = new CFFIndex();
19345    for (const string of strings) {
19346      stringIndex.add(stringToBytes(string));
19347    }
19348    return this.compileIndex(stringIndex);
19349  }
19350  compileCharStrings(charStrings) {
19351    const charStringsIndex = new CFFIndex();
19352    for (let i = 0; i < charStrings.count; i++) {
19353      const glyph = charStrings.get(i);
19354      if (glyph.length === 0) {
19355        charStringsIndex.add(new Uint8Array([0x8b, 0x0e]));
19356        continue;
19357      }
19358      charStringsIndex.add(glyph);
19359    }
19360    return this.compileIndex(charStringsIndex);
19361  }
19362  compileCharset(charset, numGlyphs, strings, isCIDFont) {
19363    let out;
19364    const numGlyphsLessNotDef = numGlyphs - 1;
19365    if (isCIDFont) {
19366      const nLeft = numGlyphsLessNotDef - 1;
19367      out = new Uint8Array([2, 0, 1, nLeft >> 8 & 0xff, nLeft & 0xff]);
19368    } else {
19369      const length = 1 + numGlyphsLessNotDef * 2;
19370      out = new Uint8Array(length);
19371      let charsetIndex = 0;
19372      const numCharsets = charset.charset.length;
19373      let warned = false;
19374      for (let i = 1; i < out.length; i += 2) {
19375        let sid = 0;
19376        if (charsetIndex < numCharsets) {
19377          const name = charset.charset[charsetIndex++];
19378          sid = strings.getSID(name);
19379          if (sid === -1) {
19380            sid = 0;
19381            if (!warned) {
19382              warned = true;
19383              warn(`Couldn't find ${name} in CFF strings`);
19384            }
19385          }
19386        }
19387        out[i] = sid >> 8 & 0xff;
19388        out[i + 1] = sid & 0xff;
19389      }
19390    }
19391    return out;
19392  }
19393  compileEncoding(encoding) {
19394    return encoding.raw;
19395  }
19396  compileFDSelect(fdSelect) {
19397    const format = fdSelect.format;
19398    let out, i;
19399    switch (format) {
19400      case 0:
19401        out = new Uint8Array(1 + fdSelect.fdSelect.length);
19402        out[0] = format;
19403        out.set(fdSelect.fdSelect, 1);
19404        break;
19405      case 3:
19406        const start = 0;
19407        let lastFD = fdSelect.fdSelect[0];
19408        const ranges = [format, 0, 0, start >> 8 & 0xff, start & 0xff, lastFD];
19409        for (i = 1; i < fdSelect.fdSelect.length; i++) {
19410          const currentFD = fdSelect.fdSelect[i];
19411          if (currentFD !== lastFD) {
19412            ranges.push(i >> 8 & 0xff, i & 0xff, currentFD);
19413            lastFD = currentFD;
19414          }
19415        }
19416        const numRanges = (ranges.length - 3) / 3;
19417        ranges[1] = numRanges >> 8 & 0xff;
19418        ranges[2] = numRanges & 0xff;
19419        ranges.push(i >> 8 & 0xff, i & 0xff);
19420        out = new Uint8Array(ranges);
19421        break;
19422    }
19423    return out;
19424  }
19425  compileIndex(index, trackers = []) {
19426    const objects = index.objects;
19427    const count = objects.length;
19428    if (count === 0) {
19429      return new Uint8Array(2);
19430    }
19431    let lastOffset = 1,
19432      i;
19433    for (i = 0; i < count; ++i) {
19434      lastOffset += objects[i].length;
19435    }
19436    let offsetSize;
19437    if (lastOffset < 0x100) {
19438      offsetSize = 1;
19439    } else if (lastOffset < 0x10000) {
19440      offsetSize = 2;
19441    } else if (lastOffset < 0x1000000) {
19442      offsetSize = 3;
19443    } else {
19444      offsetSize = 4;
19445    }
19446    const data = new Uint8Array(2 + offsetSize * (count + 1) + lastOffset);
19447    let pos = 0;
19448    data[pos++] = count >> 8 & 0xff;
19449    data[pos++] = count & 0xff;
19450    data[pos++] = offsetSize;
19451    let relativeOffset = 1;
19452    for (i = 0; i < count + 1; i++) {
19453      if (offsetSize === 1) {
19454        data[pos++] = relativeOffset & 0xff;
19455      } else if (offsetSize === 2) {
19456        data[pos++] = relativeOffset >> 8 & 0xff;
19457        data[pos++] = relativeOffset & 0xff;
19458      } else if (offsetSize === 3) {
19459        data[pos++] = relativeOffset >> 16 & 0xff;
19460        data[pos++] = relativeOffset >> 8 & 0xff;
19461        data[pos++] = relativeOffset & 0xff;
19462      } else {
19463        data[pos++] = relativeOffset >>> 24 & 0xff;
19464        data[pos++] = relativeOffset >> 16 & 0xff;
19465        data[pos++] = relativeOffset >> 8 & 0xff;
19466        data[pos++] = relativeOffset & 0xff;
19467      }
19468      if (objects[i]) {
19469        relativeOffset += objects[i].length;
19470      }
19471    }
19472    for (i = 0; i < count; i++) {
19473      trackers[i]?.offset(pos);
19474      data.set(objects[i], pos);
19475      pos += objects[i].length;
19476    }
19477    return data;
19478  }
19479}
19480
19481;// ./src/core/standard_fonts.js
19482
19483
19484const getStdFontMap = getLookupTableFactory(function (t) {
19485  t["Times-Roman"] = "Times-Roman";
19486  t.Helvetica = "Helvetica";
19487  t.Courier = "Courier";
19488  t.Symbol = "Symbol";
19489  t["Times-Bold"] = "Times-Bold";
19490  t["Helvetica-Bold"] = "Helvetica-Bold";
19491  t["Courier-Bold"] = "Courier-Bold";
19492  t.ZapfDingbats = "ZapfDingbats";
19493  t["Times-Italic"] = "Times-Italic";
19494  t["Helvetica-Oblique"] = "Helvetica-Oblique";
19495  t["Courier-Oblique"] = "Courier-Oblique";
19496  t["Times-BoldItalic"] = "Times-BoldItalic";
19497  t["Helvetica-BoldOblique"] = "Helvetica-BoldOblique";
19498  t["Courier-BoldOblique"] = "Courier-BoldOblique";
19499  t.ArialNarrow = "Helvetica";
19500  t["ArialNarrow-Bold"] = "Helvetica-Bold";
19501  t["ArialNarrow-BoldItalic"] = "Helvetica-BoldOblique";
19502  t["ArialNarrow-Italic"] = "Helvetica-Oblique";
19503  t.ArialBlack = "Helvetica";
19504  t["ArialBlack-Bold"] = "Helvetica-Bold";
19505  t["ArialBlack-BoldItalic"] = "Helvetica-BoldOblique";
19506  t["ArialBlack-Italic"] = "Helvetica-Oblique";
19507  t["Arial-Black"] = "Helvetica";
19508  t["Arial-Black-Bold"] = "Helvetica-Bold";
19509  t["Arial-Black-BoldItalic"] = "Helvetica-BoldOblique";
19510  t["Arial-Black-Italic"] = "Helvetica-Oblique";
19511  t.Arial = "Helvetica";
19512  t["Arial-Bold"] = "Helvetica-Bold";
19513  t["Arial-BoldItalic"] = "Helvetica-BoldOblique";
19514  t["Arial-Italic"] = "Helvetica-Oblique";
19515  t.ArialMT = "Helvetica";
19516  t["Arial-BoldItalicMT"] = "Helvetica-BoldOblique";
19517  t["Arial-BoldMT"] = "Helvetica-Bold";
19518  t["Arial-ItalicMT"] = "Helvetica-Oblique";
19519  t["Arial-BoldItalicMT-BoldItalic"] = "Helvetica-BoldOblique";
19520  t["Arial-BoldMT-Bold"] = "Helvetica-Bold";
19521  t["Arial-ItalicMT-Italic"] = "Helvetica-Oblique";
19522  t.ArialUnicodeMS = "Helvetica";
19523  t["ArialUnicodeMS-Bold"] = "Helvetica-Bold";
19524  t["ArialUnicodeMS-BoldItalic"] = "Helvetica-BoldOblique";
19525  t["ArialUnicodeMS-Italic"] = "Helvetica-Oblique";
19526  t["Courier-BoldItalic"] = "Courier-BoldOblique";
19527  t["Courier-Italic"] = "Courier-Oblique";
19528  t.CourierNew = "Courier";
19529  t["CourierNew-Bold"] = "Courier-Bold";
19530  t["CourierNew-BoldItalic"] = "Courier-BoldOblique";
19531  t["CourierNew-Italic"] = "Courier-Oblique";
19532  t["CourierNewPS-BoldItalicMT"] = "Courier-BoldOblique";
19533  t["CourierNewPS-BoldMT"] = "Courier-Bold";
19534  t["CourierNewPS-ItalicMT"] = "Courier-Oblique";
19535  t.CourierNewPSMT = "Courier";
19536  t["Helvetica-BoldItalic"] = "Helvetica-BoldOblique";
19537  t["Helvetica-Italic"] = "Helvetica-Oblique";
19538  t["HelveticaLTStd-Bold"] = "Helvetica-Bold";
19539  t["Symbol-Bold"] = "Symbol";
19540  t["Symbol-BoldItalic"] = "Symbol";
19541  t["Symbol-Italic"] = "Symbol";
19542  t.TimesNewRoman = "Times-Roman";
19543  t["TimesNewRoman-Bold"] = "Times-Bold";
19544  t["TimesNewRoman-BoldItalic"] = "Times-BoldItalic";
19545  t["TimesNewRoman-Italic"] = "Times-Italic";
19546  t.TimesNewRomanPS = "Times-Roman";
19547  t["TimesNewRomanPS-Bold"] = "Times-Bold";
19548  t["TimesNewRomanPS-BoldItalic"] = "Times-BoldItalic";
19549  t["TimesNewRomanPS-BoldItalicMT"] = "Times-BoldItalic";
19550  t["TimesNewRomanPS-BoldMT"] = "Times-Bold";
19551  t["TimesNewRomanPS-Italic"] = "Times-Italic";
19552  t["TimesNewRomanPS-ItalicMT"] = "Times-Italic";
19553  t.TimesNewRomanPSMT = "Times-Roman";
19554  t["TimesNewRomanPSMT-Bold"] = "Times-Bold";
19555  t["TimesNewRomanPSMT-BoldItalic"] = "Times-BoldItalic";
19556  t["TimesNewRomanPSMT-Italic"] = "Times-Italic";
19557});
19558const getFontNameToFileMap = getLookupTableFactory(function (t) {
19559  t.Courier = "FoxitFixed.pfb";
19560  t["Courier-Bold"] = "FoxitFixedBold.pfb";
19561  t["Courier-BoldOblique"] = "FoxitFixedBoldItalic.pfb";
19562  t["Courier-Oblique"] = "FoxitFixedItalic.pfb";
19563  t.Helvetica = "LiberationSans-Regular.ttf";
19564  t["Helvetica-Bold"] = "LiberationSans-Bold.ttf";
19565  t["Helvetica-BoldOblique"] = "LiberationSans-BoldItalic.ttf";
19566  t["Helvetica-Oblique"] = "LiberationSans-Italic.ttf";
19567  t["Times-Roman"] = "FoxitSerif.pfb";
19568  t["Times-Bold"] = "FoxitSerifBold.pfb";
19569  t["Times-BoldItalic"] = "FoxitSerifBoldItalic.pfb";
19570  t["Times-Italic"] = "FoxitSerifItalic.pfb";
19571  t.Symbol = "FoxitSymbol.pfb";
19572  t.ZapfDingbats = "FoxitDingbats.pfb";
19573  t["LiberationSans-Regular"] = "LiberationSans-Regular.ttf";
19574  t["LiberationSans-Bold"] = "LiberationSans-Bold.ttf";
19575  t["LiberationSans-Italic"] = "LiberationSans-Italic.ttf";
19576  t["LiberationSans-BoldItalic"] = "LiberationSans-BoldItalic.ttf";
19577});
19578const getNonStdFontMap = getLookupTableFactory(function (t) {
19579  t.Calibri = "Helvetica";
19580  t["Calibri-Bold"] = "Helvetica-Bold";
19581  t["Calibri-BoldItalic"] = "Helvetica-BoldOblique";
19582  t["Calibri-Italic"] = "Helvetica-Oblique";
19583  t.CenturyGothic = "Helvetica";
19584  t["CenturyGothic-Bold"] = "Helvetica-Bold";
19585  t["CenturyGothic-BoldItalic"] = "Helvetica-BoldOblique";
19586  t["CenturyGothic-Italic"] = "Helvetica-Oblique";
19587  t.ComicSansMS = "Comic Sans MS";
19588  t["ComicSansMS-Bold"] = "Comic Sans MS-Bold";
19589  t["ComicSansMS-BoldItalic"] = "Comic Sans MS-BoldItalic";
19590  t["ComicSansMS-Italic"] = "Comic Sans MS-Italic";
19591  t.GillSansMT = "Helvetica";
vendor: 8,875 bytes, lines 19592-20022
19592  t["GillSansMT-Bold"] = "Helvetica-Bold";
19593  t["GillSansMT-BoldItalic"] = "Helvetica-BoldOblique";
19594  t["GillSansMT-Italic"] = "Helvetica-Oblique";
19595  t.Impact = "Helvetica";
19596  t["ItcSymbol-Bold"] = "Helvetica-Bold";
19597  t["ItcSymbol-BoldItalic"] = "Helvetica-BoldOblique";
19598  t["ItcSymbol-Book"] = "Helvetica";
19599  t["ItcSymbol-BookItalic"] = "Helvetica-Oblique";
19600  t["ItcSymbol-Medium"] = "Helvetica";
19601  t["ItcSymbol-MediumItalic"] = "Helvetica-Oblique";
19602  t.LucidaConsole = "Courier";
19603  t["LucidaConsole-Bold"] = "Courier-Bold";
19604  t["LucidaConsole-BoldItalic"] = "Courier-BoldOblique";
19605  t["LucidaConsole-Italic"] = "Courier-Oblique";
19606  t["LucidaSans-Demi"] = "Helvetica-Bold";
19607  t["MS-Gothic"] = "MS Gothic";
19608  t["MS-Gothic-Bold"] = "MS Gothic-Bold";
19609  t["MS-Gothic-BoldItalic"] = "MS Gothic-BoldItalic";
19610  t["MS-Gothic-Italic"] = "MS Gothic-Italic";
19611  t["MS-Mincho"] = "MS Mincho";
19612  t["MS-Mincho-Bold"] = "MS Mincho-Bold";
19613  t["MS-Mincho-BoldItalic"] = "MS Mincho-BoldItalic";
19614  t["MS-Mincho-Italic"] = "MS Mincho-Italic";
19615  t["MS-PGothic"] = "MS PGothic";
19616  t["MS-PGothic-Bold"] = "MS PGothic-Bold";
19617  t["MS-PGothic-BoldItalic"] = "MS PGothic-BoldItalic";
19618  t["MS-PGothic-Italic"] = "MS PGothic-Italic";
19619  t["MS-PMincho"] = "MS PMincho";
19620  t["MS-PMincho-Bold"] = "MS PMincho-Bold";
19621  t["MS-PMincho-BoldItalic"] = "MS PMincho-BoldItalic";
19622  t["MS-PMincho-Italic"] = "MS PMincho-Italic";
19623  t.NuptialScript = "Times-Italic";
19624  t.SegoeUISymbol = "Helvetica";
19625});
19626const getSerifFonts = getLookupTableFactory(function (t) {
19627  t["Adobe Jenson"] = true;
19628  t["Adobe Text"] = true;
19629  t.Albertus = true;
19630  t.Aldus = true;
19631  t.Alexandria = true;
19632  t.Algerian = true;
19633  t["American Typewriter"] = true;
19634  t.Antiqua = true;
19635  t.Apex = true;
19636  t.Arno = true;
19637  t.Aster = true;
19638  t.Aurora = true;
19639  t.Baskerville = true;
19640  t.Bell = true;
19641  t.Bembo = true;
19642  t["Bembo Schoolbook"] = true;
19643  t.Benguiat = true;
19644  t["Berkeley Old Style"] = true;
19645  t["Bernhard Modern"] = true;
19646  t["Berthold City"] = true;
19647  t.Bodoni = true;
19648  t["Bauer Bodoni"] = true;
19649  t["Book Antiqua"] = true;
19650  t.Bookman = true;
19651  t["Bordeaux Roman"] = true;
19652  t["Californian FB"] = true;
19653  t.Calisto = true;
19654  t.Calvert = true;
19655  t.Capitals = true;
19656  t.Cambria = true;
19657  t.Cartier = true;
19658  t.Caslon = true;
19659  t.Catull = true;
19660  t.Centaur = true;
19661  t["Century Old Style"] = true;
19662  t["Century Schoolbook"] = true;
19663  t.Chaparral = true;
19664  t["Charis SIL"] = true;
19665  t.Cheltenham = true;
19666  t["Cholla Slab"] = true;
19667  t.Clarendon = true;
19668  t.Clearface = true;
19669  t.Cochin = true;
19670  t.Colonna = true;
19671  t["Computer Modern"] = true;
19672  t["Concrete Roman"] = true;
19673  t.Constantia = true;
19674  t["Cooper Black"] = true;
19675  t.Corona = true;
19676  t.Ecotype = true;
19677  t.Egyptienne = true;
19678  t.Elephant = true;
19679  t.Excelsior = true;
19680  t.Fairfield = true;
19681  t["FF Scala"] = true;
19682  t.Folkard = true;
19683  t.Footlight = true;
19684  t.FreeSerif = true;
19685  t["Friz Quadrata"] = true;
19686  t.Garamond = true;
19687  t.Gentium = true;
19688  t.Georgia = true;
19689  t.Gloucester = true;
19690  t["Goudy Old Style"] = true;
19691  t["Goudy Schoolbook"] = true;
19692  t["Goudy Pro Font"] = true;
19693  t.Granjon = true;
19694  t["Guardian Egyptian"] = true;
19695  t.Heather = true;
19696  t.Hercules = true;
19697  t["High Tower Text"] = true;
19698  t.Hiroshige = true;
19699  t["Hoefler Text"] = true;
19700  t["Humana Serif"] = true;
19701  t.Imprint = true;
19702  t["Ionic No. 5"] = true;
19703  t.Janson = true;
19704  t.Joanna = true;
19705  t.Korinna = true;
19706  t.Lexicon = true;
19707  t.LiberationSerif = true;
19708  t["Liberation Serif"] = true;
19709  t["Linux Libertine"] = true;
19710  t.Literaturnaya = true;
19711  t.Lucida = true;
19712  t["Lucida Bright"] = true;
19713  t.Melior = true;
19714  t.Memphis = true;
19715  t.Miller = true;
19716  t.Minion = true;
19717  t.Modern = true;
19718  t["Mona Lisa"] = true;
19719  t["Mrs Eaves"] = true;
19720  t["MS Serif"] = true;
19721  t["Museo Slab"] = true;
19722  t["New York"] = true;
19723  t["Nimbus Roman"] = true;
19724  t["NPS Rawlinson Roadway"] = true;
19725  t.NuptialScript = true;
19726  t.Palatino = true;
19727  t.Perpetua = true;
19728  t.Plantin = true;
19729  t["Plantin Schoolbook"] = true;
19730  t.Playbill = true;
19731  t["Poor Richard"] = true;
19732  t["Rawlinson Roadway"] = true;
19733  t.Renault = true;
19734  t.Requiem = true;
19735  t.Rockwell = true;
19736  t.Roman = true;
19737  t["Rotis Serif"] = true;
19738  t.Sabon = true;
19739  t.Scala = true;
19740  t.Seagull = true;
19741  t.Sistina = true;
19742  t.Souvenir = true;
19743  t.STIX = true;
19744  t["Stone Informal"] = true;
19745  t["Stone Serif"] = true;
19746  t.Sylfaen = true;
19747  t.Times = true;
19748  t.Trajan = true;
19749  t["Trinité"] = true;
19750  t["Trump Mediaeval"] = true;
19751  t.Utopia = true;
19752  t["Vale Type"] = true;
19753  t["Bitstream Vera"] = true;
19754  t["Vera Serif"] = true;
19755  t.Versailles = true;
19756  t.Wanted = true;
19757  t.Weiss = true;
19758  t["Wide Latin"] = true;
19759  t.Windsor = true;
19760  t.XITS = true;
19761});
19762const getSymbolsFonts = getLookupTableFactory(function (t) {
19763  t.Dingbats = true;
19764  t.Symbol = true;
19765  t.ZapfDingbats = true;
19766  t.Wingdings = true;
19767  t["Wingdings-Bold"] = true;
19768  t["Wingdings-Regular"] = true;
19769});
19770const getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
19771  t[2] = 10;
19772  t[3] = 32;
19773  t[4] = 33;
19774  t[5] = 34;
19775  t[6] = 35;
19776  t[7] = 36;
19777  t[8] = 37;
19778  t[9] = 38;
19779  t[10] = 39;
19780  t[11] = 40;
19781  t[12] = 41;
19782  t[13] = 42;
19783  t[14] = 43;
19784  t[15] = 44;
19785  t[16] = 45;
19786  t[17] = 46;
19787  t[18] = 47;
19788  t[19] = 48;
19789  t[20] = 49;
19790  t[21] = 50;
19791  t[22] = 51;
19792  t[23] = 52;
19793  t[24] = 53;
19794  t[25] = 54;
19795  t[26] = 55;
19796  t[27] = 56;
19797  t[28] = 57;
19798  t[29] = 58;
19799  t[30] = 894;
19800  t[31] = 60;
19801  t[32] = 61;
19802  t[33] = 62;
19803  t[34] = 63;
19804  t[35] = 64;
19805  t[36] = 65;
19806  t[37] = 66;
19807  t[38] = 67;
19808  t[39] = 68;
19809  t[40] = 69;
19810  t[41] = 70;
19811  t[42] = 71;
19812  t[43] = 72;
19813  t[44] = 73;
19814  t[45] = 74;
19815  t[46] = 75;
19816  t[47] = 76;
19817  t[48] = 77;
19818  t[49] = 78;
19819  t[50] = 79;
19820  t[51] = 80;
19821  t[52] = 81;
19822  t[53] = 82;
19823  t[54] = 83;
19824  t[55] = 84;
19825  t[56] = 85;
19826  t[57] = 86;
19827  t[58] = 87;
19828  t[59] = 88;
19829  t[60] = 89;
19830  t[61] = 90;
19831  t[62] = 91;
19832  t[63] = 92;
19833  t[64] = 93;
19834  t[65] = 94;
19835  t[66] = 95;
19836  t[67] = 96;
19837  t[68] = 97;
19838  t[69] = 98;
19839  t[70] = 99;
19840  t[71] = 100;
19841  t[72] = 101;
19842  t[73] = 102;
19843  t[74] = 103;
19844  t[75] = 104;
19845  t[76] = 105;
19846  t[77] = 106;
19847  t[78] = 107;
19848  t[79] = 108;
19849  t[80] = 109;
19850  t[81] = 110;
19851  t[82] = 111;
19852  t[83] = 112;
19853  t[84] = 113;
19854  t[85] = 114;
19855  t[86] = 115;
19856  t[87] = 116;
19857  t[88] = 117;
19858  t[89] = 118;
19859  t[90] = 119;
19860  t[91] = 120;
19861  t[92] = 121;
19862  t[93] = 122;
19863  t[94] = 123;
19864  t[95] = 124;
19865  t[96] = 125;
19866  t[97] = 126;
19867  t[98] = 196;
19868  t[99] = 197;
19869  t[100] = 199;
19870  t[101] = 201;
19871  t[102] = 209;
19872  t[103] = 214;
19873  t[104] = 220;
19874  t[105] = 225;
19875  t[106] = 224;
19876  t[107] = 226;
19877  t[108] = 228;
19878  t[109] = 227;
19879  t[110] = 229;
19880  t[111] = 231;
19881  t[112] = 233;
19882  t[113] = 232;
19883  t[114] = 234;
19884  t[115] = 235;
19885  t[116] = 237;
19886  t[117] = 236;
19887  t[118] = 238;
19888  t[119] = 239;
19889  t[120] = 241;
19890  t[121] = 243;
19891  t[122] = 242;
19892  t[123] = 244;
19893  t[124] = 246;
19894  t[125] = 245;
19895  t[126] = 250;
19896  t[127] = 249;
19897  t[128] = 251;
19898  t[129] = 252;
19899  t[130] = 8224;
19900  t[131] = 176;
19901  t[132] = 162;
19902  t[133] = 163;
19903  t[134] = 167;
19904  t[135] = 8226;
19905  t[136] = 182;
19906  t[137] = 223;
19907  t[138] = 174;
19908  t[139] = 169;
19909  t[140] = 8482;
19910  t[141] = 180;
19911  t[142] = 168;
19912  t[143] = 8800;
19913  t[144] = 198;
19914  t[145] = 216;
19915  t[146] = 8734;
19916  t[147] = 177;
19917  t[148] = 8804;
19918  t[149] = 8805;
19919  t[150] = 165;
19920  t[151] = 181;
19921  t[152] = 8706;
19922  t[153] = 8721;
19923  t[154] = 8719;
19924  t[156] = 8747;
19925  t[157] = 170;
19926  t[158] = 186;
19927  t[159] = 8486;
19928  t[160] = 230;
19929  t[161] = 248;
19930  t[162] = 191;
19931  t[163] = 161;
19932  t[164] = 172;
19933  t[165] = 8730;
19934  t[166] = 402;
19935  t[167] = 8776;
19936  t[168] = 8710;
19937  t[169] = 171;
19938  t[170] = 187;
19939  t[171] = 8230;
19940  t[179] = 8220;
19941  t[180] = 8221;
19942  t[181] = 8216;
19943  t[182] = 8217;
19944  t[200] = 193;
19945  t[203] = 205;
19946  t[207] = 211;
19947  t[210] = 218;
19948  t[223] = 711;
19949  t[224] = 321;
19950  t[225] = 322;
19951  t[226] = 352;
19952  t[227] = 353;
19953  t[228] = 381;
19954  t[229] = 382;
19955  t[233] = 221;
19956  t[234] = 253;
19957  t[252] = 263;
19958  t[253] = 268;
19959  t[254] = 269;
19960  t[258] = 258;
19961  t[260] = 260;
19962  t[261] = 261;
19963  t[265] = 280;
19964  t[266] = 281;
19965  t[267] = 282;
19966  t[268] = 283;
19967  t[269] = 313;
19968  t[275] = 323;
19969  t[276] = 324;
19970  t[278] = 328;
19971  t[283] = 344;
19972  t[284] = 345;
19973  t[285] = 346;
19974  t[286] = 347;
19975  t[292] = 367;
19976  t[295] = 377;
19977  t[296] = 378;
19978  t[298] = 380;
19979  t[305] = 963;
19980  t[306] = 964;
19981  t[307] = 966;
19982  t[308] = 8215;
19983  t[309] = 8252;
19984  t[310] = 8319;
19985  t[311] = 8359;
19986  t[312] = 8592;
19987  t[313] = 8593;
19988  t[337] = 9552;
19989  t[493] = 1039;
19990  t[494] = 1040;
19991  t[570] = 1040;
19992  t[571] = 1041;
19993  t[572] = 1042;
19994  t[573] = 1043;
19995  t[574] = 1044;
19996  t[575] = 1045;
19997  t[576] = 1046;
19998  t[577] = 1047;
19999  t[578] = 1048;
20000  t[579] = 1049;
20001  t[580] = 1050;
20002  t[581] = 1051;
20003  t[582] = 1052;
20004  t[583] = 1053;
20005  t[584] = 1054;
20006  t[585] = 1055;
20007  t[586] = 1056;
20008  t[587] = 1057;
20009  t[588] = 1058;
20010  t[589] = 1059;
20011  t[590] = 1060;
20012  t[591] = 1061;
20013  t[592] = 1062;
20014  t[593] = 1063;
20015  t[594] = 1064;
20016  t[595] = 1065;
20017  t[596] = 1066;
20018  t[597] = 1067;
20019  t[598] = 1068;
20020  t[599] = 1069;
20021  t[600] = 1070;
20022  t[6
2002201] = 1071;
20023  t[602] = 1072;
20024  t[603] = 1073;
20025  t[604] = 1074;
20026  t[605] = 1075;
20027  t[606] = 1076;
20028  t[607] = 1077;
20029  t[608] = 1078;
20030  t[609] = 1079;
20031  t[610] = 1080;
20032  t[611] = 1081;
20033  t[612] = 1082;
20034  t[613] = 1083;
20035  t[614] = 1084;
20036  t[615] = 1085;
20037  t[616] = 1086;
20038  t[617] = 1087;
20039  t[618] = 1088;
20040  t[619] = 1089;
20041  t[620] = 1090;
20042  t[621] = 1091;
20043  t[622] = 1092;
20044  t[623] = 1093;
20045  t[624] = 1094;
20046  t[625] = 1095;
20047  t[626] = 1096;
20048  t[627] = 1097;
20049  t[628] = 1098;
20050  t[629] = 1099;
20051  t[630] = 1100;
20052  t[631] = 1101;
20053  t[632] = 1102;
20054  t[633] = 1103
vendor: 6,147 bytes, lines 20054-20402
20054;
20055  t[672] = 1488;
20056  t[673] = 1489;
20057  t[674] = 1490;
20058  t[675] = 1491;
20059  t[676] = 1492;
20060  t[677] = 1493;
20061  t[678] = 1494;
20062  t[679] = 1495;
20063  t[680] = 1496;
20064  t[681] = 1497;
20065  t[682] = 1498;
20066  t[683] = 1499;
20067  t[684] = 1500;
20068  t[685] = 1501;
20069  t[686] = 1502;
20070  t[687] = 1503;
20071  t[688] = 1504;
20072  t[689] = 1505;
20073  t[690] = 1506;
20074  t[691] = 1507;
20075  t[692] = 1508;
20076  t[693] = 1509;
20077  t[694] = 1510;
20078  t[695] = 1511;
20079  t[696] = 1512;
20080  t[697] = 1513;
20081  t[698] = 1514;
20082  t[705] = 1524;
20083  t[706] = 8362;
20084  t[710] = 64288;
20085  t[711] = 64298;
20086  t[759] = 1617;
20087  t[761] = 1776;
20088  t[763] = 1778;
20089  t[775] = 1652;
20090  t[777] = 1764;
20091  t[778] = 1780;
20092  t[779] = 1781;
20093  t[780] = 1782;
20094  t[782] = 771;
20095  t[783] = 64726;
20096  t[786] = 8363;
20097  t[788] = 8532;
20098  t[790] = 768;
20099  t[791] = 769;
20100  t[792] = 768;
20101  t[795] = 803;
20102  t[797] = 64336;
20103  t[798] = 64337;
20104  t[799] = 64342;
20105  t[800] = 64343;
20106  t[801] = 64344;
20107  t[802] = 64345;
20108  t[803] = 64362;
20109  t[804] = 64363;
20110  t[805] = 64364;
20111  t[2424] = 7821;
20112  t[2425] = 7822;
20113  t[2426] = 7823;
20114  t[2427] = 7824;
20115  t[2428] = 7825;
20116  t[2429] = 7826;
20117  t[2430] = 7827;
20118  t[2433] = 7682;
20119  t[2678] = 8045;
20120  t[2679] = 8046;
20121  t[2830] = 1552;
20122  t[2838] = 686;
20123  t[2840] = 751;
20124  t[2842] = 753;
20125  t[2843] = 754;
20126  t[2844] = 755;
20127  t[2846] = 757;
20128  t[2856] = 767;
20129  t[2857] = 848;
20130  t[2858] = 849;
20131  t[2862] = 853;
20132  t[2863] = 854;
20133  t[2864] = 855;
20134  t[2865] = 861;
20135  t[2866] = 862;
20136  t[2906] = 7460;
20137  t[2908] = 7462;
20138  t[2909] = 7463;
20139  t[2910] = 7464;
20140  t[2912] = 7466;
20141  t[2913] = 7467;
20142  t[2914] = 7468;
20143  t[2916] = 7470;
20144  t[2917] = 7471;
20145  t[2918] = 7472;
20146  t[2920] = 7474;
20147  t[2921] = 7475;
20148  t[2922] = 7476;
20149  t[2924] = 7478;
20150  t[2925] = 7479;
20151  t[2926] = 7480;
20152  t[2928] = 7482;
20153  t[2929] = 7483;
20154  t[2930] = 7484;
20155  t[2932] = 7486;
20156  t[2933] = 7487;
20157  t[2934] = 7488;
20158  t[2936] = 7490;
20159  t[2937] = 7491;
20160  t[2938] = 7492;
20161  t[2940] = 7494;
20162  t[2941] = 7495;
20163  t[2942] = 7496;
20164  t[2944] = 7498;
20165  t[2946] = 7500;
20166  t[2948] = 7502;
20167  t[2950] = 7504;
20168  t[2951] = 7505;
20169  t[2952] = 7506;
20170  t[2954] = 7508;
20171  t[2955] = 7509;
20172  t[2956] = 7510;
20173  t[2958] = 7512;
20174  t[2959] = 7513;
20175  t[2960] = 7514;
20176  t[2962] = 7516;
20177  t[2963] = 7517;
20178  t[2964] = 7518;
20179  t[2966] = 7520;
20180  t[2967] = 7521;
20181  t[2968] = 7522;
20182  t[2970] = 7524;
20183  t[2971] = 7525;
20184  t[2972] = 7526;
20185  t[2974] = 7528;
20186  t[2975] = 7529;
20187  t[2976] = 7530;
20188  t[2978] = 1537;
20189  t[2979] = 1538;
20190  t[2980] = 1539;
20191  t[2982] = 1549;
20192  t[2983] = 1551;
20193  t[2984] = 1552;
20194  t[2986] = 1554;
20195  t[2987] = 1555;
20196  t[2988] = 1556;
20197  t[2990] = 1623;
20198  t[2991] = 1624;
20199  t[2995] = 1775;
20200  t[2999] = 1791;
20201  t[3002] = 64290;
20202  t[3003] = 64291;
20203  t[3004] = 64292;
20204  t[3006] = 64294;
20205  t[3007] = 64295;
20206  t[3008] = 64296;
20207  t[3011] = 1900;
20208  t[3014] = 8223;
20209  t[3015] = 8244;
20210  t[3017] = 7532;
20211  t[3018] = 7533;
20212  t[3019] = 7534;
20213  t[3075] = 7590;
20214  t[3076] = 7591;
20215  t[3079] = 7594;
20216  t[3080] = 7595;
20217  t[3083] = 7598;
20218  t[3084] = 7599;
20219  t[3087] = 7602;
20220  t[3088] = 7603;
20221  t[3091] = 7606;
20222  t[3092] = 7607;
20223  t[3095] = 7610;
20224  t[3096] = 7611;
20225  t[3099] = 7614;
20226  t[3100] = 7615;
20227  t[3103] = 7618;
20228  t[3104] = 7619;
20229  t[3107] = 8337;
20230  t[3108] = 8338;
20231  t[3116] = 1884;
20232  t[3119] = 1885;
20233  t[3120] = 1885;
20234  t[3123] = 1886;
20235  t[3124] = 1886;
20236  t[3127] = 1887;
20237  t[3128] = 1887;
20238  t[3131] = 1888;
20239  t[3132] = 1888;
20240  t[3135] = 1889;
20241  t[3136] = 1889;
20242  t[3139] = 1890;
20243  t[3140] = 1890;
20244  t[3143] = 1891;
20245  t[3144] = 1891;
20246  t[3147] = 1892;
20247  t[3148] = 1892;
20248  t[3153] = 580;
20249  t[3154] = 581;
20250  t[3157] = 584;
20251  t[3158] = 585;
20252  t[3161] = 588;
20253  t[3162] = 589;
20254  t[3165] = 891;
20255  t[3166] = 892;
20256  t[3169] = 1274;
20257  t[3170] = 1275;
20258  t[3173] = 1278;
20259  t[3174] = 1279;
20260  t[3181] = 7622;
20261  t[3182] = 7623;
20262  t[3282] = 11799;
20263  t[3316] = 578;
20264  t[3379] = 42785;
20265  t[3393] = 1159;
20266  t[3416] = 8377;
20267});
20268const getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
20269  t[227] = 322;
20270  t[264] = 261;
20271  t[291] = 346;
20272});
20273const getSupplementalGlyphMapForCalibri = getLookupTableFactory(function (t) {
20274  t[1] = 32;
20275  t[4] = 65;
20276  t[5] = 192;
20277  t[6] = 193;
20278  t[9] = 196;
20279  t[17] = 66;
20280  t[18] = 67;
20281  t[21] = 268;
20282  t[24] = 68;
20283  t[28] = 69;
20284  t[29] = 200;
20285  t[30] = 201;
20286  t[32] = 282;
20287  t[38] = 70;
20288  t[39] = 71;
20289  t[44] = 72;
20290  t[47] = 73;
20291  t[48] = 204;
20292  t[49] = 205;
20293  t[58] = 74;
20294  t[60] = 75;
20295  t[62] = 76;
20296  t[68] = 77;
20297  t[69] = 78;
20298  t[75] = 79;
20299  t[76] = 210;
20300  t[80] = 214;
20301  t[87] = 80;
20302  t[89] = 81;
20303  t[90] = 82;
20304  t[92] = 344;
20305  t[94] = 83;
20306  t[97] = 352;
20307  t[100] = 84;
20308  t[104] = 85;
20309  t[109] = 220;
20310  t[115] = 86;
20311  t[116] = 87;
20312  t[121] = 88;
20313  t[122] = 89;
20314  t[124] = 221;
20315  t[127] = 90;
20316  t[129] = 381;
20317  t[258] = 97;
20318  t[259] = 224;
20319  t[260] = 225;
20320  t[263] = 228;
20321  t[268] = 261;
20322  t[271] = 98;
20323  t[272] = 99;
20324  t[273] = 263;
20325  t[275] = 269;
20326  t[282] = 100;
20327  t[286] = 101;
20328  t[287] = 232;
20329  t[288] = 233;
20330  t[290] = 283;
20331  t[295] = 281;
20332  t[296] = 102;
20333  t[336] = 103;
20334  t[346] = 104;
20335  t[349] = 105;
20336  t[350] = 236;
20337  t[351] = 237;
20338  t[361] = 106;
20339  t[364] = 107;
20340  t[367] = 108;
20341  t[371] = 322;
20342  t[373] = 109;
20343  t[374] = 110;
20344  t[381] = 111;
20345  t[382] = 242;
20346  t[383] = 243;
20347  t[386] = 246;
20348  t[393] = 112;
20349  t[395] = 113;
20350  t[396] = 114;
20351  t[398] = 345;
20352  t[400] = 115;
20353  t[401] = 347;
20354  t[403] = 353;
20355  t[410] = 116;
20356  t[437] = 117;
20357  t[442] = 252;
20358  t[448] = 118;
20359  t[449] = 119;
20360  t[454] = 120;
20361  t[455] = 121;
20362  t[457] = 253;
20363  t[460] = 122;
20364  t[462] = 382;
20365  t[463] = 380;
20366  t[853] = 44;
20367  t[855] = 58;
20368  t[856] = 46;
20369  t[876] = 47;
20370  t[878] = 45;
20371  t[882] = 45;
20372  t[894] = 40;
20373  t[895] = 41;
20374  t[896] = 91;
20375  t[897] = 93;
20376  t[923] = 64;
20377  t[940] = 163;
20378  t[1004] = 48;
20379  t[1005] = 49;
20380  t[1006] = 50;
20381  t[1007] = 51;
20382  t[1008] = 52;
20383  t[1009] = 53;
20384  t[1010] = 54;
20385  t[1011] = 55;
20386  t[1012] = 56;
20387  t[1013] = 57;
20388  t[1081] = 37;
20389  t[1085] = 43;
20390  t[1086] = 45;
20391});
20392function getStandardFontName(name) {
20393  const fontName = normalizeFontName(name);
20394  const stdFontMap = getStdFontMap();
20395  return stdFontMap[fontName];
20396}
20397function isKnownFontName(name) {
20398  const fontName = normalizeFontName(name);
20399  return !!(getStdFontMap()[fontName] || getNonStdFontMap()[fontName] || getSerifFonts()[fontName] || getSymbolsFonts()[fontName]);
20400}
20401
20402;// ./src/core/
vendor: 18,908 bytes, lines 20402-21053
20402glyf.js
20403const ON_CURVE_POINT = 1 << 0;
20404const X_SHORT_VECTOR = 1 << 1;
20405const Y_SHORT_VECTOR = 1 << 2;
20406const REPEAT_FLAG = 1 << 3;
20407const X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR = 1 << 4;
20408const Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR = 1 << 5;
20409const OVERLAP_SIMPLE = 1 << 6;
20410const ARG_1_AND_2_ARE_WORDS = 1 << 0;
20411const ARGS_ARE_XY_VALUES = 1 << 1;
20412const WE_HAVE_A_SCALE = 1 << 3;
20413const MORE_COMPONENTS = 1 << 5;
20414const WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6;
20415const WE_HAVE_A_TWO_BY_TWO = 1 << 7;
20416const WE_HAVE_INSTRUCTIONS = 1 << 8;
20417const GLYPH_HEADER_SIZE = 10;
20418class GlyfTable {
20419  constructor({
20420    glyfTable,
20421    isGlyphLocationsLong,
20422    locaTable,
20423    numGlyphs
20424  }) {
20425    this.glyphs = [];
20426    const loca = new DataView(locaTable.buffer, locaTable.byteOffset, locaTable.byteLength);
20427    const glyf = new DataView(glyfTable.buffer, glyfTable.byteOffset, glyfTable.byteLength);
20428    const offsetSize = isGlyphLocationsLong ? 4 : 2;
20429    let prev = isGlyphLocationsLong ? loca.getUint32(0) : 2 * loca.getUint16(0);
20430    let pos = 0;
20431    for (let i = 0; i < numGlyphs; i++) {
20432      pos += offsetSize;
20433      const next = isGlyphLocationsLong ? loca.getUint32(pos) : 2 * loca.getUint16(pos);
20434      if (next === prev) {
20435        this.glyphs.push(new Glyph({}));
20436        continue;
20437      }
20438      const glyph = Glyph.parse(prev, glyf);
20439      this.glyphs.push(glyph);
20440      prev = next;
20441    }
20442  }
20443  getSize() {
20444    return Math.sumPrecise(this.glyphs.map(g => g.getSize() + 3 & ~3));
20445  }
20446  write() {
20447    const totalSize = this.getSize();
20448    const glyfTable = new DataView(new ArrayBuffer(totalSize));
20449    const isLocationLong = totalSize > 0x1fffe;
20450    const offsetSize = isLocationLong ? 4 : 2;
20451    const locaTable = new DataView(new ArrayBuffer((this.glyphs.length + 1) * offsetSize));
20452    if (isLocationLong) {
20453      locaTable.setUint32(0, 0);
20454    } else {
20455      locaTable.setUint16(0, 0);
20456    }
20457    let pos = 0;
20458    let locaIndex = 0;
20459    for (const glyph of this.glyphs) {
20460      pos += glyph.write(pos, glyfTable);
20461      pos = pos + 3 & ~3;
20462      locaIndex += offsetSize;
20463      if (isLocationLong) {
20464        locaTable.setUint32(locaIndex, pos);
20465      } else {
20466        locaTable.setUint16(locaIndex, pos >> 1);
20467      }
20468    }
20469    return {
20470      isLocationLong,
20471      loca: new Uint8Array(locaTable.buffer),
20472      glyf: new Uint8Array(glyfTable.buffer)
20473    };
20474  }
20475  scale(factors) {
20476    for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
20477      this.glyphs[i].scale(factors[i]);
20478    }
20479  }
20480}
20481class Glyph {
20482  constructor({
20483    header = null,
20484    simple = null,
20485    composites = null
20486  }) {
20487    this.header = header;
20488    this.simple = simple;
20489    this.composites = composites;
20490  }
20491  static parse(pos, glyf) {
20492    const [read, header] = GlyphHeader.parse(pos, glyf);
20493    pos += read;
20494    if (header.numberOfContours < 0) {
20495      const composites = [];
20496      while (true) {
20497        const [n, composite] = CompositeGlyph.parse(pos, glyf);
20498        pos += n;
20499        composites.push(composite);
20500        if (!(composite.flags & MORE_COMPONENTS)) {
20501          break;
20502        }
20503      }
20504      return new Glyph({
20505        header,
20506        composites
20507      });
20508    }
20509    const simple = SimpleGlyph.parse(pos, glyf, header.numberOfContours);
20510    return new Glyph({
20511      header,
20512      simple
20513    });
20514  }
20515  getSize() {
20516    if (!this.header) {
20517      return 0;
20518    }
20519    const size = this.simple ? this.simple.getSize() : Math.sumPrecise(this.composites.map(c => c.getSize()));
20520    return this.header.getSize() + size;
20521  }
20522  write(pos, buf) {
20523    if (!this.header) {
20524      return 0;
20525    }
20526    const spos = pos;
20527    pos += this.header.write(pos, buf);
20528    if (this.simple) {
20529      pos += this.simple.write(pos, buf);
20530    } else {
20531      for (const composite of this.composites) {
20532        pos += composite.write(pos, buf);
20533      }
20534    }
20535    return pos - spos;
20536  }
20537  scale(factor) {
20538    if (!this.header) {
20539      return;
20540    }
20541    const xMiddle = (this.header.xMin + this.header.xMax) / 2;
20542    this.header.scale(xMiddle, factor);
20543    if (this.simple) {
20544      this.simple.scale(xMiddle, factor);
20545    } else {
20546      for (const composite of this.composites) {
20547        composite.scale(xMiddle, factor);
20548      }
20549    }
20550  }
20551}
20552class GlyphHeader {
20553  constructor({
20554    numberOfContours,
20555    xMin,
20556    yMin,
20557    xMax,
20558    yMax
20559  }) {
20560    this.numberOfContours = numberOfContours;
20561    this.xMin = xMin;
20562    this.yMin = yMin;
20563    this.xMax = xMax;
20564    this.yMax = yMax;
20565  }
20566  static parse(pos, glyf) {
20567    return [GLYPH_HEADER_SIZE, new GlyphHeader({
20568      numberOfContours: glyf.getInt16(pos),
20569      xMin: glyf.getInt16(pos + 2),
20570      yMin: glyf.getInt16(pos + 4),
20571      xMax: glyf.getInt16(pos + 6),
20572      yMax: glyf.getInt16(pos + 8)
20573    })];
20574  }
20575  getSize() {
20576    return GLYPH_HEADER_SIZE;
20577  }
20578  write(pos, buf) {
20579    buf.setInt16(pos, this.numberOfContours);
20580    buf.setInt16(pos + 2, this.xMin);
20581    buf.setInt16(pos + 4, this.yMin);
20582    buf.setInt16(pos + 6, this.xMax);
20583    buf.setInt16(pos + 8, this.yMax);
20584    return GLYPH_HEADER_SIZE;
20585  }
20586  scale(x, factor) {
20587    this.xMin = Math.round(x + (this.xMin - x) * factor);
20588    this.xMax = Math.round(x + (this.xMax - x) * factor);
20589  }
20590}
20591class Contour {
20592  constructor({
20593    flags,
20594    xCoordinates,
20595    yCoordinates
20596  }) {
20597    this.xCoordinates = xCoordinates;
20598    this.yCoordinates = yCoordinates;
20599    this.flags = flags;
20600  }
20601}
20602class SimpleGlyph {
20603  constructor({
20604    contours,
20605    instructions
20606  }) {
20607    this.contours = contours;
20608    this.instructions = instructions;
20609  }
20610  static parse(pos, glyf, numberOfContours) {
20611    const endPtsOfContours = [];
20612    for (let i = 0; i < numberOfContours; i++) {
20613      const endPt = glyf.getUint16(pos);
20614      pos += 2;
20615      endPtsOfContours.push(endPt);
20616    }
20617    const numberOfPt = endPtsOfContours[numberOfContours - 1] + 1;
20618    const instructionLength = glyf.getUint16(pos);
20619    pos += 2;
20620    const instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
20621    pos += instructionLength;
20622    const flags = [];
20623    for (let i = 0; i < numberOfPt; pos++, i++) {
20624      let flag = glyf.getUint8(pos);
20625      flags.push(flag);
20626      if (flag & REPEAT_FLAG) {
20627        const count = glyf.getUint8(++pos);
20628        flag ^= REPEAT_FLAG;
20629        for (let m = 0; m < count; m++) {
20630          flags.push(flag);
20631        }
20632        i += count;
20633      }
20634    }
20635    const allXCoordinates = [];
20636    let xCoordinates = [];
20637    let yCoordinates = [];
20638    let pointFlags = [];
20639    const contours = [];
20640    let endPtsOfContoursIndex = 0;
20641    let lastCoordinate = 0;
20642    for (let i = 0; i < numberOfPt; i++) {
20643      const flag = flags[i];
20644      if (flag & X_SHORT_VECTOR) {
20645        const x = glyf.getUint8(pos++);
20646        lastCoordinate += flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR ? x : -x;
20647        xCoordinates.push(lastCoordinate);
20648      } else if (flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR) {
20649        xCoordinates.push(lastCoordinate);
20650      } else {
20651        lastCoordinate += glyf.getInt16(pos);
20652        pos += 2;
20653        xCoordinates.push(lastCoordinate);
20654      }
20655      if (endPtsOfContours[endPtsOfContoursIndex] === i) {
20656        endPtsOfContoursIndex++;
20657        allXCoordinates.push(xCoordinates);
20658        xCoordinates = [];
20659      }
20660    }
20661    lastCoordinate = 0;
20662    endPtsOfContoursIndex = 0;
20663    for (let i = 0; i < numberOfPt; i++) {
20664      const flag = flags[i];
20665      if (flag & Y_SHORT_VECTOR) {
20666        const y = glyf.getUint8(pos++);
20667        lastCoordinate += flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR ? y : -y;
20668        yCoordinates.push(lastCoordinate);
20669      } else if (flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR) {
20670        yCoordinates.push(lastCoordinate);
20671      } else {
20672        lastCoordinate += glyf.getInt16(pos);
20673        pos += 2;
20674        yCoordinates.push(lastCoordinate);
20675      }
20676      pointFlags.push(flag & ON_CURVE_POINT | flag & OVERLAP_SIMPLE);
20677      if (endPtsOfContours[endPtsOfContoursIndex] === i) {
20678        xCoordinates = allXCoordinates[endPtsOfContoursIndex];
20679        endPtsOfContoursIndex++;
20680        contours.push(new Contour({
20681          flags: pointFlags,
20682          xCoordinates,
20683          yCoordinates
20684        }));
20685        yCoordinates = [];
20686        pointFlags = [];
20687      }
20688    }
20689    return new SimpleGlyph({
20690      contours,
20691      instructions
20692    });
20693  }
20694  getSize() {
20695    let size = this.contours.length * 2 + 2 + this.instructions.length;
20696    let lastX = 0;
20697    let lastY = 0;
20698    for (const contour of this.contours) {
20699      size += contour.flags.length;
20700      for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
20701        const x = contour.xCoordinates[i];
20702        const y = contour.yCoordinates[i];
20703        let abs = Math.abs(x - lastX);
20704        if (abs > 255) {
20705          size += 2;
20706        } else if (abs > 0) {
20707          size += 1;
20708        }
20709        lastX = x;
20710        abs = Math.abs(y - lastY);
20711        if (abs > 255) {
20712          size += 2;
20713        } else if (abs > 0) {
20714          size += 1;
20715        }
20716        lastY = y;
20717      }
20718    }
20719    return size;
20720  }
20721  write(pos, buf) {
20722    const spos = pos;
20723    const xCoordinates = [];
20724    const yCoordinates = [];
20725    const flags = [];
20726    let lastX = 0;
20727    let lastY = 0;
20728    for (const contour of this.contours) {
20729      for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
20730        let flag = contour.flags[i];
20731        const x = contour.xCoordinates[i];
20732        let delta = x - lastX;
20733        if (delta === 0) {
20734          flag |= X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;
20735          xCoordinates.push(0);
20736        } else {
20737          const abs = Math.abs(delta);
20738          if (abs <= 255) {
20739            flag |= delta >= 0 ? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR : X_SHORT_VECTOR;
20740            xCoordinates.push(abs);
20741          } else {
20742            xCoordinates.push(delta);
20743          }
20744        }
20745        lastX = x;
20746        const y = contour.yCoordinates[i];
20747        delta = y - lastY;
20748        if (delta === 0) {
20749          flag |= Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;
20750          yCoordinates.push(0);
20751        } else {
20752          const abs = Math.abs(delta);
20753          if (abs <= 255) {
20754            flag |= delta >= 0 ? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR : Y_SHORT_VECTOR;
20755            yCoordinates.push(abs);
20756          } else {
20757            yCoordinates.push(delta);
20758          }
20759        }
20760        lastY = y;
20761        flags.push(flag);
20762      }
20763      buf.setUint16(pos, xCoordinates.length - 1);
20764      pos += 2;
20765    }
20766    buf.setUint16(pos, this.instructions.length);
20767    pos += 2;
20768    if (this.instructions.length) {
20769      new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
20770      pos += this.instructions.length;
20771    }
20772    for (const flag of flags) {
20773      buf.setUint8(pos++, flag);
20774    }
20775    for (let i = 0, ii = xCoordinates.length; i < ii; i++) {
20776      const x = xCoordinates[i];
20777      const flag = flags[i];
20778      if (flag & X_SHORT_VECTOR) {
20779        buf.setUint8(pos++, x);
20780      } else if (!(flag & X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR)) {
20781        buf.setInt16(pos, x);
20782        pos += 2;
20783      }
20784    }
20785    for (let i = 0, ii = yCoordinates.length; i < ii; i++) {
20786      const y = yCoordinates[i];
20787      const flag = flags[i];
20788      if (flag & Y_SHORT_VECTOR) {
20789        buf.setUint8(pos++, y);
20790      } else if (!(flag & Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR)) {
20791        buf.setInt16(pos, y);
20792        pos += 2;
20793      }
20794    }
20795    return pos - spos;
20796  }
20797  scale(x, factor) {
20798    for (const contour of this.contours) {
20799      if (contour.xCoordinates.length === 0) {
20800        continue;
20801      }
20802      for (let i = 0, ii = contour.xCoordinates.length; i < ii; i++) {
20803        contour.xCoordinates[i] = Math.round(x + (contour.xCoordinates[i] - x) * factor);
20804      }
20805    }
20806  }
20807}
20808class CompositeGlyph {
20809  constructor({
20810    flags,
20811    glyphIndex,
20812    argument1,
20813    argument2,
20814    transf,
20815    instructions
20816  }) {
20817    this.flags = flags;
20818    this.glyphIndex = glyphIndex;
20819    this.argument1 = argument1;
20820    this.argument2 = argument2;
20821    this.transf = transf;
20822    this.instructions = instructions;
20823  }
20824  static parse(pos, glyf) {
20825    const spos = pos;
20826    const transf = [];
20827    let flags = glyf.getUint16(pos);
20828    const glyphIndex = glyf.getUint16(pos + 2);
20829    pos += 4;
20830    let argument1, argument2;
20831    if (flags & ARG_1_AND_2_ARE_WORDS) {
20832      if (flags & ARGS_ARE_XY_VALUES) {
20833        argument1 = glyf.getInt16(pos);
20834        argument2 = glyf.getInt16(pos + 2);
20835      } else {
20836        argument1 = glyf.getUint16(pos);
20837        argument2 = glyf.getUint16(pos + 2);
20838      }
20839      pos += 4;
20840      flags ^= ARG_1_AND_2_ARE_WORDS;
20841    } else {
20842      if (flags & ARGS_ARE_XY_VALUES) {
20843        argument1 = glyf.getInt8(pos);
20844        argument2 = glyf.getInt8(pos + 1);
20845      } else {
20846        argument1 = glyf.getUint8(pos);
20847        argument2 = glyf.getUint8(pos + 1);
20848      }
20849      pos += 2;
20850    }
20851    if (flags & WE_HAVE_A_SCALE) {
20852      transf.push(glyf.getUint16(pos));
20853      pos += 2;
20854    } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
20855      transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2));
20856      pos += 4;
20857    } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
20858      transf.push(glyf.getUint16(pos), glyf.getUint16(pos + 2), glyf.getUint16(pos + 4), glyf.getUint16(pos + 6));
20859      pos += 8;
20860    }
20861    let instructions = null;
20862    if (flags & WE_HAVE_INSTRUCTIONS) {
20863      const instructionLength = glyf.getUint16(pos);
20864      pos += 2;
20865      instructions = new Uint8Array(glyf).slice(pos, pos + instructionLength);
20866      pos += instructionLength;
20867    }
20868    return [pos - spos, new CompositeGlyph({
20869      flags,
20870      glyphIndex,
20871      argument1,
20872      argument2,
20873      transf,
20874      instructions
20875    })];
20876  }
20877  getSize() {
20878    let size = 2 + 2 + this.transf.length * 2;
20879    if (this.flags & WE_HAVE_INSTRUCTIONS) {
20880      size += 2 + this.instructions.length;
20881    }
20882    size += 2;
20883    if (this.flags & 2) {
20884      if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
20885        size += 2;
20886      }
20887    } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
20888      size += 2;
20889    }
20890    return size;
20891  }
20892  write(pos, buf) {
20893    const spos = pos;
20894    if (this.flags & ARGS_ARE_XY_VALUES) {
20895      if (!(this.argument1 >= -128 && this.argument1 <= 127 && this.argument2 >= -128 && this.argument2 <= 127)) {
20896        this.flags |= ARG_1_AND_2_ARE_WORDS;
20897      }
20898    } else if (!(this.argument1 >= 0 && this.argument1 <= 255 && this.argument2 >= 0 && this.argument2 <= 255)) {
20899      this.flags |= ARG_1_AND_2_ARE_WORDS;
20900    }
20901    buf.setUint16(pos, this.flags);
20902    buf.setUint16(pos + 2, this.glyphIndex);
20903    pos += 4;
20904    if (this.flags & ARG_1_AND_2_ARE_WORDS) {
20905      if (this.flags & ARGS_ARE_XY_VALUES) {
20906        buf.setInt16(pos, this.argument1);
20907        buf.setInt16(pos + 2, this.argument2);
20908      } else {
20909        buf.setUint16(pos, this.argument1);
20910        buf.setUint16(pos + 2, this.argument2);
20911      }
20912      pos += 4;
20913    } else {
20914      buf.setUint8(pos, this.argument1);
20915      buf.setUint8(pos + 1, this.argument2);
20916      pos += 2;
20917    }
20918    if (this.flags & WE_HAVE_INSTRUCTIONS) {
20919      buf.setUint16(pos, this.instructions.length);
20920      pos += 2;
20921      if (this.instructions.length) {
20922        new Uint8Array(buf.buffer, 0, buf.buffer.byteLength).set(this.instructions, pos);
20923        pos += this.instructions.length;
20924      }
20925    }
20926    return pos - spos;
20927  }
20928  scale(x, factor) {}
20929}
20930function pruneCompositeGlyphCycles(glyfTable, locaEntries, numGlyphs) {
20931  const glyf = new DataView(glyfTable.buffer, glyfTable.byteOffset, glyfTable.byteLength);
20932  const components = new Array(numGlyphs);
20933  for (let i = 0; i < numGlyphs; i++) {
20934    const offset = locaEntries[i].offset;
20935    const endOffset = Math.min(locaEntries[i].endOffset, glyf.byteLength);
20936    if (endOffset - offset <= GLYPH_HEADER_SIZE || glyf.getInt16(offset) >= 0) {
20937      continue;
20938    }
20939    const comps = [];
20940    let p = offset + GLYPH_HEADER_SIZE;
20941    while (p + 4 <= endOffset) {
20942      const flags = glyf.getUint16(p);
20943      const gid = glyf.getUint16(p + 2);
20944      let size = 4 + (flags & ARG_1_AND_2_ARE_WORDS ? 4 : 2);
20945      if (flags & WE_HAVE_A_SCALE) {
20946        size += 2;
20947      } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
20948        size += 4;
20949      } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
20950        size += 8;
20951      }
20952      comps.push({
20953        gid,
20954        offset: p,
20955        size,
20956        flags
20957      });
20958      p += size;
20959      if (!(flags & MORE_COMPONENTS)) {
20960        break;
20961      }
20962    }
20963    if (comps.length) {
20964      components[i] = comps;
20965    }
20966  }
20967  const WHITE = 0,
20968    GRAY = 1,
20969    BLACK = 2;
20970  const state = new Uint8Array(numGlyphs);
20971  const backEdges = new Map();
20972  for (let start = 0; start < numGlyphs; start++) {
20973    if (state[start] !== WHITE || !components[start]) {
20974      continue;
20975    }
20976    const stack = [{
20977      node: start,
20978      idx: 0
20979    }];
20980    state[start] = GRAY;
20981    while (stack.length > 0) {
20982      const top = stack.at(-1);
20983      const comps = components[top.node];
20984      if (!comps || top.idx >= comps.length) {
20985        state[top.node] = BLACK;
20986        stack.pop();
20987        continue;
20988      }
20989      const compIdx = top.idx++;
20990      const next = comps[compIdx].gid;
20991      if (next >= numGlyphs || state[next] === BLACK) {
20992        continue;
20993      }
20994      if (state[next] === WHITE) {
20995        state[next] = GRAY;
20996        stack.push({
20997          node: next,
20998          idx: 0
20999        });
21000        continue;
21001      }
21002      let removeSet = backEdges.get(top.node);
21003      if (!removeSet) {
21004        removeSet = new Set();
21005        backEdges.set(top.node, removeSet);
21006      }
21007      removeSet.add(compIdx);
21008    }
21009  }
21010  const droppedGlyphs = new Set();
21011  for (const [gIdx, removeSet] of backEdges) {
21012    const comps = components[gIdx];
21013    const remaining = [];
21014    for (let ci = 0; ci < comps.length; ci++) {
21015      if (!removeSet.has(ci)) {
21016        remaining.push(comps[ci]);
21017      }
21018    }
21019    if (remaining.length === 0) {
21020      droppedGlyphs.add(gIdx);
21021      continue;
21022    }
21023    const start = locaEntries[gIdx].offset;
21024    const endOffset = Math.min(locaEntries[gIdx].endOffset, glyf.byteLength);
21025    let writePos = start + GLYPH_HEADER_SIZE;
21026    for (let ci = 0; ci < remaining.length; ci++) {
21027      const c = remaining[ci];
21028      const isLast = ci === remaining.length - 1;
21029      let newFlags = c.flags & ~WE_HAVE_INSTRUCTIONS;
21030      newFlags = isLast ? newFlags & ~MORE_COMPONENTS : newFlags | MORE_COMPONENTS;
21031      if (writePos !== c.offset) {
21032        glyfTable.copyWithin(writePos, c.offset, c.offset + c.size);
21033      }
21034      glyf.setUint16(writePos, newFlags);
21035      writePos += c.size;
21036    }
21037    if (writePos < endOffset) {
21038      glyfTable.fill(0, writePos, endOffset);
21039    }
21040  }
21041  return droppedGlyphs;
21042}
21043
21044;// ./src/core/to_unicode_map.js
21045
21046class ToUnicodeMap {
21047  constructor(cmap = []) {
21048    this._map = cmap;
21049  }
21050  get length() {
21051    return this._map.length;
21052  }
21053  forEach(callback) {
vendor: 4,121 bytes, lines 21054-21215
21054    for (const charCode in this._map) {
21055      callback(charCode, this._map[charCode].codePointAt(0));
21056    }
21057  }
21058  has(i) {
21059    return this._map[i] !== undefined;
21060  }
21061  get(i) {
21062    return this._map[i];
21063  }
21064  charCodeOf(value) {
21065    const map = this._map;
21066    if (map.length <= 0x10000) {
21067      return map.indexOf(value);
21068    }
21069    for (const charCode in map) {
21070      if (map[charCode] === value) {
21071        return charCode | 0;
21072      }
21073    }
21074    return -1;
21075  }
21076  amend(map) {
21077    for (const charCode in map) {
21078      this._map[charCode] = map[charCode];
21079    }
21080  }
21081}
21082class IdentityToUnicodeMap {
21083  constructor(firstChar, lastChar) {
21084    this.firstChar = firstChar;
21085    this.lastChar = lastChar;
21086  }
21087  get length() {
21088    return this.lastChar + 1 - this.firstChar;
21089  }
21090  forEach(callback) {
21091    for (let i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
21092      callback(i, i);
21093    }
21094  }
21095  has(i) {
21096    return this.firstChar <= i && i <= this.lastChar;
21097  }
21098  get(i) {
21099    if (this.firstChar <= i && i <= this.lastChar) {
21100      return String.fromCharCode(i);
21101    }
21102    return undefined;
21103  }
21104  charCodeOf(v) {
21105    return Number.isInteger(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
21106  }
21107  amend(map) {
21108    unreachable("Should not call amend()");
21109  }
21110}
21111
21112;// ./src/core/cff_font.js
21113
21114
21115
21116class CFFFont {
21117  constructor(file, properties) {
21118    this.properties = properties;
21119    const parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
21120    this.cff = parser.parse();
21121    this.cff.duplicateFirstGlyph();
21122    const compiler = new CFFCompiler(this.cff);
21123    this.seacs = this.cff.seacs;
21124    try {
21125      this.data = compiler.compile();
21126    } catch (ex) {
21127      warn(`Failed to compile font "${properties.loadedName}": "${ex}".`);
21128      file.reset();
21129      this.data = file.getBytes();
21130    }
21131    this._createBuiltInEncoding();
21132  }
21133  get numGlyphs() {
21134    return this.cff.charStrings.count;
21135  }
21136  getCharset() {
21137    return this.cff.charset.charset;
21138  }
21139  getGlyphMapping() {
21140    const cff = this.cff;
21141    const properties = this.properties;
21142    const {
21143      cidToGidMap,
21144      cMap
21145    } = properties;
21146    const charsets = cff.charset.charset;
21147    let charCodeToGlyphId;
21148    let glyphId;
21149    if (properties.composite) {
21150      let invCidToGidMap;
21151      if (cidToGidMap?.length > 0) {
21152        invCidToGidMap = Object.create(null);
21153        for (let i = 0, ii = cidToGidMap.length; i < ii; i++) {
21154          const gid = cidToGidMap[i];
21155          if (gid !== undefined) {
21156            invCidToGidMap[gid] = i;
21157          }
21158        }
21159      }
21160      charCodeToGlyphId = Object.create(null);
21161      let charCode;
21162      if (cff.isCIDFont) {
21163        for (glyphId = 0; glyphId < charsets.length; glyphId++) {
21164          const cid = charsets[glyphId];
21165          charCode = cMap.charCodeOf(cid);
21166          if (invCidToGidMap?.[charCode] !== undefined) {
21167            charCode = invCidToGidMap[charCode];
21168          }
21169          charCodeToGlyphId[charCode] = glyphId;
21170        }
21171      } else {
21172        for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
21173          charCode = cMap.charCodeOf(glyphId);
21174          charCodeToGlyphId[charCode] = glyphId;
21175        }
21176      }
21177      return charCodeToGlyphId;
21178    }
21179    let encoding = cff.encoding ? cff.encoding.encoding : null;
21180    if (properties.isInternalFont) {
21181      encoding = properties.defaultEncoding;
21182    }
21183    charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
21184    return charCodeToGlyphId;
21185  }
21186  hasGlyphId(id) {
21187    return this.cff.hasGlyphId(id);
21188  }
21189  _createBuiltInEncoding() {
21190    const {
21191      charset,
21192      encoding
21193    } = this.cff;
21194    if (!charset || !encoding) {
21195      return;
21196    }
21197    const charsets = charset.charset,
21198      encodings = encoding.encoding;
21199    const map = [];
21200    for (const charCode in encodings) {
21201      const glyphId = encodings[charCode];
21202      if (glyphId >= 0) {
21203        const glyphName = charsets[glyphId];
21204        if (glyphName) {
21205          map[charCode] = glyphName;
21206        }
21207      }
21208    }
21209    if (map.length > 0) {
21210      this.properties.builtInEncoding = map;
21211    }
21212  }
21213}
21214
21215;// ./src/core/font_renderer.js
vendor: 19,818 bytes, lines 21215-21898
21215
21216
21217
21218
21219
21220
21221
21222function getFloat214(view, offset) {
21223  return view.getInt16(offset) / 16384;
21224}
21225function getSubroutineBias(subrs) {
21226  const numSubrs = subrs.length;
21227  if (numSubrs >= 33900) {
21228    return 32768;
21229  }
21230  return numSubrs < 1240 ? 107 : 1131;
21231}
21232function parseCmap(data, start, end) {
21233  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
21234  const offset = view.getUint16(start + 2) === 1 ? view.getUint32(start + 8) : view.getUint32(start + 16);
21235  const format = view.getUint16(start + offset);
21236  let ranges, p, i;
21237  if (format === 4) {
21238    const segCount = view.getUint16(start + offset + 6) >> 1;
21239    p = start + offset + 14;
21240    ranges = [];
21241    for (i = 0; i < segCount; i++, p += 2) {
21242      ranges[i] = {
21243        end: view.getUint16(p)
21244      };
21245    }
21246    p += 2;
21247    for (i = 0; i < segCount; i++, p += 2) {
21248      ranges[i].start = view.getUint16(p);
21249    }
21250    for (i = 0; i < segCount; i++, p += 2) {
21251      ranges[i].idDelta = view.getUint16(p);
21252    }
21253    for (i = 0; i < segCount; i++, p += 2) {
21254      let idOffset = view.getUint16(p);
21255      if (idOffset === 0) {
21256        continue;
21257      }
21258      ranges[i].ids = [];
21259      for (let j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
21260        ranges[i].ids[j] = view.getUint16(p + idOffset);
21261        idOffset += 2;
21262      }
21263    }
21264    return ranges;
21265  } else if (format === 12) {
21266    const groups = view.getUint32(start + offset + 12);
21267    p = start + offset + 16;
21268    ranges = [];
21269    for (i = 0; i < groups; i++) {
21270      start = view.getUint32(p);
21271      ranges.push({
21272        start,
21273        end: view.getUint32(p + 4),
21274        idDelta: view.getUint32(p + 8) - start
21275      });
21276      p += 12;
21277    }
21278    return ranges;
21279  }
21280  throw new FormatError(`unsupported cmap: ${format}`);
21281}
21282function parseCff(data, start, end, seacAnalysisEnabled) {
21283  const properties = {};
21284  const parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
21285  const cff = parser.parse();
21286  return {
21287    glyphs: cff.charStrings.objects,
21288    subrs: cff.topDict.privateDict?.subrsIndex?.objects,
21289    gsubrs: cff.globalSubrIndex?.objects,
21290    isCFFCIDFont: cff.isCIDFont,
21291    fdSelect: cff.fdSelect,
21292    fdArray: cff.fdArray
21293  };
21294}
21295function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
21296  const view = new DataView(loca.buffer, loca.byteOffset, loca.byteLength);
21297  let itemSize, itemDecode;
21298  if (isGlyphLocationsLong) {
21299    itemSize = 4;
21300    itemDecode = (dv, offset) => dv.getUint32(offset);
21301  } else {
21302    itemSize = 2;
21303    itemDecode = (dv, offset) => 2 * dv.getUint16(offset);
21304  }
21305  const glyphs = [];
21306  let startOffset = itemDecode(view, 0);
21307  for (let j = itemSize; j < loca.length; j += itemSize) {
21308    const endOffset = itemDecode(view, j);
21309    glyphs.push(glyf.subarray(startOffset, endOffset));
21310    startOffset = endOffset;
21311  }
21312  return glyphs;
21313}
21314function lookupCmap(ranges, unicode) {
21315  const code = unicode.codePointAt(0);
21316  let gid = 0,
21317    l = 0,
21318    r = ranges.length - 1;
21319  while (l < r) {
21320    const c = l + r + 1 >> 1;
21321    if (code < ranges[c].start) {
21322      r = c - 1;
21323    } else {
21324      l = c;
21325    }
21326  }
21327  if (ranges[l].start <= code && code <= ranges[l].end) {
21328    gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xffff;
21329  }
21330  return {
21331    charCode: code,
21332    glyphId: gid
21333  };
21334}
21335function compileGlyf(code, cmds, font, visitedGlyphs = new Set()) {
21336  if (!code?.length) {
21337    return;
21338  }
21339  if (visitedGlyphs.has(code)) {
21340    warn("compileGlyf: skipping recursive composite glyph reference.");
21341    return;
21342  }
21343  visitedGlyphs.add(code);
21344  function moveTo(x, y) {
21345    if (firstPoint) {
21346      cmds.add(DrawOPS.lineTo, firstPoint);
21347    }
21348    firstPoint = [x, y];
21349    cmds.add(DrawOPS.moveTo, [x, y]);
21350  }
21351  function lineTo(x, y) {
21352    cmds.add(DrawOPS.lineTo, [x, y]);
21353  }
21354  function quadraticCurveTo(xa, ya, x, y) {
21355    cmds.add(DrawOPS.quadraticCurveTo, [xa, ya, x, y]);
21356  }
21357  const view = new DataView(code.buffer, code.byteOffset, code.byteLength);
21358  let i = 0;
21359  const numberOfContours = view.getInt16(i);
21360  let flags;
21361  let firstPoint = null;
21362  let x = 0,
21363    y = 0;
21364  i += 10;
21365  if (numberOfContours < 0) {
21366    do {
21367      flags = view.getUint16(i);
21368      const glyphIndex = view.getUint16(i + 2);
21369      i += 4;
21370      let arg1, arg2;
21371      if (flags & 0x01) {
21372        if (flags & 0x02) {
21373          arg1 = view.getInt16(i);
21374          arg2 = view.getInt16(i + 2);
21375        } else {
21376          arg1 = view.getUint16(i);
21377          arg2 = view.getUint16(i + 2);
21378        }
21379        i += 4;
21380      } else if (flags & 0x02) {
21381        arg1 = view.getInt8(i++);
21382        arg2 = view.getInt8(i++);
21383      } else {
21384        arg1 = code[i++];
21385        arg2 = code[i++];
21386      }
21387      if (flags & 0x02) {
21388        x = arg1;
21389        y = arg2;
21390      } else {
21391        x = 0;
21392        y = 0;
21393      }
21394      let scaleX = 1,
21395        scaleY = 1,
21396        scale01 = 0,
21397        scale10 = 0;
21398      if (flags & 0x08) {
21399        scaleX = scaleY = getFloat214(view, i);
21400        i += 2;
21401      } else if (flags & 0x40) {
21402        scaleX = getFloat214(view, i);
21403        scaleY = getFloat214(view, i + 2);
21404        i += 4;
21405      } else if (flags & 0x80) {
21406        scaleX = getFloat214(view, i);
21407        scale01 = getFloat214(view, i + 2);
21408        scale10 = getFloat214(view, i + 4);
21409        scaleY = getFloat214(view, i + 6);
21410        i += 8;
21411      }
21412      const subglyph = font.glyphs[glyphIndex];
21413      if (subglyph) {
21414        cmds.save();
21415        cmds.transform([scaleX, scale01, scale10, scaleY, x, y]);
21416        if (!(flags & 0x02)) {}
21417        compileGlyf(subglyph, cmds, font, visitedGlyphs);
21418        cmds.restore();
21419      }
21420    } while (flags & 0x20);
21421  } else {
21422    const endPtsOfContours = [];
21423    let j, jj;
21424    for (j = 0; j < numberOfContours; j++) {
21425      endPtsOfContours.push(view.getUint16(i));
21426      i += 2;
21427    }
21428    const instructionLength = view.getUint16(i);
21429    i += 2 + instructionLength;
21430    const numberOfPoints = endPtsOfContours.at(-1) + 1;
21431    const points = [];
21432    while (points.length < numberOfPoints) {
21433      flags = code[i++];
21434      let repeat = 1;
21435      if (flags & 0x08) {
21436        repeat += code[i++];
21437      }
21438      while (repeat-- > 0) {
21439        points.push({
21440          flags
21441        });
21442      }
21443    }
21444    for (j = 0; j < numberOfPoints; j++) {
21445      switch (points[j].flags & 0x12) {
21446        case 0x00:
21447          x += view.getInt16(i);
21448          i += 2;
21449          break;
21450        case 0x02:
21451          x -= code[i++];
21452          break;
21453        case 0x12:
21454          x += code[i++];
21455          break;
21456      }
21457      points[j].x = x;
21458    }
21459    for (j = 0; j < numberOfPoints; j++) {
21460      switch (points[j].flags & 0x24) {
21461        case 0x00:
21462          y += view.getInt16(i);
21463          i += 2;
21464          break;
21465        case 0x04:
21466          y -= code[i++];
21467          break;
21468        case 0x24:
21469          y += code[i++];
21470          break;
21471      }
21472      points[j].y = y;
21473    }
21474    let startPoint = 0;
21475    for (i = 0; i < numberOfContours; i++) {
21476      const endPoint = endPtsOfContours[i];
21477      const contour = points.slice(startPoint, endPoint + 1);
21478      if (contour[0].flags & 1) {
21479        contour.push(contour[0]);
21480      } else if (contour.at(-1).flags & 1) {
21481        contour.unshift(contour.at(-1));
21482      } else {
21483        const p = {
21484          flags: 1,
21485          x: (contour[0].x + contour.at(-1).x) / 2,
21486          y: (contour[0].y + contour.at(-1).y) / 2
21487        };
21488        contour.unshift(p);
21489        contour.push(p);
21490      }
21491      moveTo(contour[0].x, contour[0].y);
21492      for (j = 1, jj = contour.length; j < jj; j++) {
21493        if (contour[j].flags & 1) {
21494          lineTo(contour[j].x, contour[j].y);
21495        } else if (contour[j + 1].flags & 1) {
21496          quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
21497          j++;
21498        } else {
21499          quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
21500        }
21501      }
21502      startPoint = endPoint + 1;
21503    }
21504  }
21505  visitedGlyphs.delete(code);
21506}
21507function compileCharString(charStringCode, cmds, font, glyphId) {
21508  function moveTo(x, y) {
21509    if (firstPoint) {
21510      cmds.add(DrawOPS.lineTo, firstPoint);
21511    }
21512    firstPoint = [x, y];
21513    cmds.add(DrawOPS.moveTo, [x, y]);
21514  }
21515  function lineTo(x, y) {
21516    cmds.add(DrawOPS.lineTo, [x, y]);
21517  }
21518  function bezierCurveTo(x1, y1, x2, y2, x, y) {
21519    cmds.add(DrawOPS.curveTo, [x1, y1, x2, y2, x, y]);
21520  }
21521  const stack = [];
21522  let x = 0,
21523    y = 0;
21524  let stems = 0;
21525  let firstPoint = null;
21526  function parse(code) {
21527    const view = new DataView(code.buffer, code.byteOffset, code.byteLength);
21528    let i = 0;
21529    while (i < code.length) {
21530      let stackClean = false;
21531      let v = code[i++];
21532      let xa, xb, ya, yb, y1, y2, y3, n, subrCode;
21533      switch (v) {
21534        case 1:
21535          stems += stack.length >> 1;
21536          stackClean = true;
21537          break;
21538        case 3:
21539          stems += stack.length >> 1;
21540          stackClean = true;
21541          break;
21542        case 4:
21543          y += stack.pop();
21544          moveTo(x, y);
21545          stackClean = true;
21546          break;
21547        case 5:
21548          while (stack.length > 0) {
21549            x += stack.shift();
21550            y += stack.shift();
21551            lineTo(x, y);
21552          }
21553          break;
21554        case 6:
21555          while (stack.length > 0) {
21556            x += stack.shift();
21557            lineTo(x, y);
21558            if (stack.length === 0) {
21559              break;
21560            }
21561            y += stack.shift();
21562            lineTo(x, y);
21563          }
21564          break;
21565        case 7:
21566          while (stack.length > 0) {
21567            y += stack.shift();
21568            lineTo(x, y);
21569            if (stack.length === 0) {
21570              break;
21571            }
21572            x += stack.shift();
21573            lineTo(x, y);
21574          }
21575          break;
21576        case 8:
21577          while (stack.length > 0) {
21578            xa = x + stack.shift();
21579            ya = y + stack.shift();
21580            xb = xa + stack.shift();
21581            yb = ya + stack.shift();
21582            x = xb + stack.shift();
21583            y = yb + stack.shift();
21584            bezierCurveTo(xa, ya, xb, yb, x, y);
21585          }
21586          break;
21587        case 10:
21588          n = stack.pop();
21589          subrCode = null;
21590          if (font.isCFFCIDFont) {
21591            const fdIndex = font.fdSelect.getFDIndex(glyphId);
21592            if (fdIndex >= 0 && fdIndex < font.fdArray.length) {
21593              const fontDict = font.fdArray[fdIndex];
21594              let subrs;
21595              if (fontDict.privateDict?.subrsIndex) {
21596                subrs = fontDict.privateDict.subrsIndex.objects;
21597              }
21598              if (subrs) {
21599                n += getSubroutineBias(subrs);
21600                subrCode = subrs[n];
21601              }
21602            } else {
21603              warn("Invalid fd index for glyph index.");
21604            }
21605          } else {
21606            subrCode = font.subrs[n + font.subrsBias];
21607          }
21608          if (subrCode) {
21609            parse(subrCode);
21610          }
21611          break;
21612        case 11:
21613          return;
21614        case 12:
21615          v = code[i++];
21616          switch (v) {
21617            case 34:
21618              xa = x + stack.shift();
21619              xb = xa + stack.shift();
21620              y1 = y + stack.shift();
21621              x = xb + stack.shift();
21622              bezierCurveTo(xa, y, xb, y1, x, y1);
21623              xa = x + stack.shift();
21624              xb = xa + stack.shift();
21625              x = xb + stack.shift();
21626              bezierCurveTo(xa, y1, xb, y, x, y);
21627              break;
21628            case 35:
21629              xa = x + stack.shift();
21630              ya = y + stack.shift();
21631              xb = xa + stack.shift();
21632              yb = ya + stack.shift();
21633              x = xb + stack.shift();
21634              y = yb + stack.shift();
21635              bezierCurveTo(xa, ya, xb, yb, x, y);
21636              xa = x + stack.shift();
21637              ya = y + stack.shift();
21638              xb = xa + stack.shift();
21639              yb = ya + stack.shift();
21640              x = xb + stack.shift();
21641              y = yb + stack.shift();
21642              bezierCurveTo(xa, ya, xb, yb, x, y);
21643              stack.pop();
21644              break;
21645            case 36:
21646              xa = x + stack.shift();
21647              y1 = y + stack.shift();
21648              xb = xa + stack.shift();
21649              y2 = y1 + stack.shift();
21650              x = xb + stack.shift();
21651              bezierCurveTo(xa, y1, xb, y2, x, y2);
21652              xa = x + stack.shift();
21653              xb = xa + stack.shift();
21654              y3 = y2 + stack.shift();
21655              x = xb + stack.shift();
21656              bezierCurveTo(xa, y2, xb, y3, x, y);
21657              break;
21658            case 37:
21659              const x0 = x,
21660                y0 = y;
21661              xa = x + stack.shift();
21662              ya = y + stack.shift();
21663              xb = xa + stack.shift();
21664              yb = ya + stack.shift();
21665              x = xb + stack.shift();
21666              y = yb + stack.shift();
21667              bezierCurveTo(xa, ya, xb, yb, x, y);
21668              xa = x + stack.shift();
21669              ya = y + stack.shift();
21670              xb = xa + stack.shift();
21671              yb = ya + stack.shift();
21672              x = xb;
21673              y = yb;
21674              if (Math.abs(x - x0) > Math.abs(y - y0)) {
21675                x += stack.shift();
21676              } else {
21677                y += stack.shift();
21678              }
21679              bezierCurveTo(xa, ya, xb, yb, x, y);
21680              break;
21681            default:
21682              throw new FormatError(`unknown operator: 12 ${v}`);
21683          }
21684          break;
21685        case 14:
21686          if (stack.length >= 4) {
21687            const achar = stack.pop();
21688            const bchar = stack.pop();
21689            y = stack.pop();
21690            x = stack.pop();
21691            cmds.save();
21692            cmds.translate(x, y);
21693            let cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
21694            compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
21695            cmds.restore();
21696            cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
21697            compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId);
21698          }
21699          return;
21700        case 18:
21701          stems += stack.length >> 1;
21702          stackClean = true;
21703          break;
21704        case 19:
21705          stems += stack.length >> 1;
21706          i += stems + 7 >> 3;
21707          stackClean = true;
21708          break;
21709        case 20:
21710          stems += stack.length >> 1;
21711          i += stems + 7 >> 3;
21712          stackClean = true;
21713          break;
21714        case 21:
21715          y += stack.pop();
21716          x += stack.pop();
21717          moveTo(x, y);
21718          stackClean = true;
21719          break;
21720        case 22:
21721          x += stack.pop();
21722          moveTo(x, y);
21723          stackClean = true;
21724          break;
21725        case 23:
21726          stems += stack.length >> 1;
21727          stackClean = true;
21728          break;
21729        case 24:
21730          while (stack.length > 2) {
21731            xa = x + stack.shift();
21732            ya = y + stack.shift();
21733            xb = xa + stack.shift();
21734            yb = ya + stack.shift();
21735            x = xb + stack.shift();
21736            y = yb + stack.shift();
21737            bezierCurveTo(xa, ya, xb, yb, x, y);
21738          }
21739          x += stack.shift();
21740          y += stack.shift();
21741          lineTo(x, y);
21742          break;
21743        case 25:
21744          while (stack.length > 6) {
21745            x += stack.shift();
21746            y += stack.shift();
21747            lineTo(x, y);
21748          }
21749          xa = x + stack.shift();
21750          ya = y + stack.shift();
21751          xb = xa + stack.shift();
21752          yb = ya + stack.shift();
21753          x = xb + stack.shift();
21754          y = yb + stack.shift();
21755          bezierCurveTo(xa, ya, xb, yb, x, y);
21756          break;
21757        case 26:
21758          if (stack.length % 2) {
21759            x += stack.shift();
21760          }
21761          while (stack.length > 0) {
21762            xa = x;
21763            ya = y + stack.shift();
21764            xb = xa + stack.shift();
21765            yb = ya + stack.shift();
21766            x = xb;
21767            y = yb + stack.shift();
21768            bezierCurveTo(xa, ya, xb, yb, x, y);
21769          }
21770          break;
21771        case 27:
21772          if (stack.length % 2) {
21773            y += stack.shift();
21774          }
21775          while (stack.length > 0) {
21776            xa = x + stack.shift();
21777            ya = y;
21778            xb = xa + stack.shift();
21779            yb = ya + stack.shift();
21780            x = xb + stack.shift();
21781            y = yb;
21782            bezierCurveTo(xa, ya, xb, yb, x, y);
21783          }
21784          break;
21785        case 28:
21786          stack.push(view.getInt16(i));
21787          i += 2;
21788          break;
21789        case 29:
21790          n = stack.pop() + font.gsubrsBias;
21791          subrCode = font.gsubrs[n];
21792          if (subrCode) {
21793            parse(subrCode);
21794          }
21795          break;
21796        case 30:
21797          while (stack.length > 0) {
21798            xa = x;
21799            ya = y + stack.shift();
21800            xb = xa + stack.shift();
21801            yb = ya + stack.shift();
21802            x = xb + stack.shift();
21803            y = yb + (stack.length === 1 ? stack.shift() : 0);
21804            bezierCurveTo(xa, ya, xb, yb, x, y);
21805            if (stack.length === 0) {
21806              break;
21807            }
21808            xa = x + stack.shift();
21809            ya = y;
21810            xb = xa + stack.shift();
21811            yb = ya + stack.shift();
21812            y = yb + stack.shift();
21813            x = xb + (stack.length === 1 ? stack.shift() : 0);
21814            bezierCurveTo(xa, ya, xb, yb, x, y);
21815          }
21816          break;
21817        case 31:
21818          while (stack.length > 0) {
21819            xa = x + stack.shift();
21820            ya = y;
21821            xb = xa + stack.shift();
21822            yb = ya + stack.shift();
21823            y = yb + stack.shift();
21824            x = xb + (stack.length === 1 ? stack.shift() : 0);
21825            bezierCurveTo(xa, ya, xb, yb, x, y);
21826            if (stack.length === 0) {
21827              break;
21828            }
21829            xa = x;
21830            ya = y + stack.shift();
21831            xb = xa + stack.shift();
21832            yb = ya + stack.shift();
21833            x = xb + stack.shift();
21834            y = yb + (stack.length === 1 ? stack.shift() : 0);
21835            bezierCurveTo(xa, ya, xb, yb, x, y);
21836          }
21837          break;
21838        default:
21839          if (v < 32) {
21840            throw new FormatError(`unknown operator: ${v}`);
21841          }
21842          if (v < 247) {
21843            stack.push(v - 139);
21844          } else if (v < 251) {
21845            stack.push((v - 247) * 256 + code[i++] + 108);
21846          } else if (v < 255) {
21847            stack.push(-(v - 251) * 256 - code[i++] - 108);
21848          } else {
21849            stack.push(view.getInt32(i) / 65536);
21850            i += 4;
21851          }
21852          break;
21853      }
21854      if (stackClean) {
21855        stack.length = 0;
21856      }
21857    }
21858  }
21859  parse(charStringCode);
21860}
21861class Commands {
21862  cmds = [];
21863  transformStack = [];
21864  currentTransform = [1, 0, 0, 1, 0, 0];
21865  add(cmd, args) {
21866    if (args) {
21867      const {
21868        currentTransform
21869      } = this;
21870      for (let i = 0, ii = args.length; i < ii; i += 2) {
21871        Util.applyTransform(args, currentTransform, i);
21872      }
21873      this.cmds.push(cmd, ...args);
21874    } else {
21875      this.cmds.push(cmd);
21876    }
21877  }
21878  transform(transf) {
21879    this.currentTransform = Util.transform(this.currentTransform, transf);
21880  }
21881  translate(x, y) {
21882    this.transform([1, 0, 0, 1, x, y]);
21883  }
21884  save() {
21885    this.transformStack.push(this.currentTransform.slice());
21886  }
21887  restore() {
21888    this.currentTransform = this.transformStack.pop() || [1, 0, 0, 1, 0, 0];
21889  }
21890  getPath() {
21891    if (FeatureTest.isFloat16ArraySupported) {
21892      return new Float16Array(this.cmds);
21893    }
21894    return new Float32Array(this.cmds);
21895  }
21896}
21897class CompiledFont {
21898  
21898constructor(fontMatrix) {
21899    this.fontMatrix = fontMatrix;
21900    this.compiledGlyphs = Object.create(null);
21901    this.compiledCharCodeToGlyphId = Object.create(null);
21902  }
21903  static get NOOP() {
21904    return shadow(this, "NOOP", FeatureTest.isFloat16ArraySupported ? new Float16Array(0) : new Float32Array(0));
21905  }
21906  getPathJs(unicode) {
21907    const {
21908      charCode,
21909      glyphId
21910    } = lookupCmap(this.cmap, unicode);
21911    let fn = this.compiledGlyphs[glyphId],
21912      compileEx;
21913    if (fn === undefined) {
21914      try {
21915        fn = this.compileGlyph(this.glyphs[glyphId], glyphId);
21916      } catch (ex) {
21917        fn = CompiledFont.NOOP;
21918        compileEx = ex;
21919      }
21920      this.compiledGlyphs[glyphId] = fn;
21921    }
21922    this.compiledCharCodeToGlyphId[charCode] ??= glyphId;
21923    if (compileEx) {
21924      throw compileEx;
21925    }
21926    return fn;
21927  }
21928  compileGlyph(code, glyphId) {
21929    if (!code?.length || code[0] === 14) {
21930      return CompiledFont.NOOP;
21931    }
21932    let fontMatrix = this.fontMatrix;
21933    if (this.isCFFCIDFont) {
21934      const fdIndex = this.fdSelect.getFDIndex(glyphId);
21935      if (fdIndex >= 0 && fdIndex < this.fdArray.length) {
21936        const fontDict = this.fdArray[fdIndex];
21937        fontMatrix = fontDict.getByName("FontMatrix") || FONT_IDENTITY_MATRIX;
21938      } else {
21939        warn("Invalid fd index for glyph index.");
21940      }
21941    }
21942    assert(isNumberArray(fontMatrix, 6), "Expected a valid fontMatrix.");
21943    const cmds = new Commands();
21944    cmds.transform(fontMatrix.slice());
21945    this.compileGlyphImpl(code, cmds, glyphId);
21946    cmds.add(DrawOPS.closePath);
21947    return cmds.getPath();
21948  }
21949  compileGlyphImpl() {
21950    unreachable("Children classes should implement this.");
21951  }
21952  hasBuiltPath(unicode) {
21953    const {
21954      charCode,
21955      glyphId
21956    } = lookupCmap(this.cmap, unicode);
21957    return this.compiledGlyphs[glyphId] !== undefined && this.compiledCharCodeToGlyphId[charCode] !== undefined;
21958  }
21959}
21960class TrueTypeCompiled extends CompiledFont {
21961  constructor(glyphs, cmap, fontMatrix) {
21962    super(fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0]);
21963    this.glyphs = glyphs;
21964    this.cmap = cmap;
21965  }
21966  compileGlyphImpl(code, cmds) {
21967    compileGlyf(code, cmds, this);
21968  }
21969}
21970class Type2Compiled extends CompiledFont {
21971  constructor(cffInfo, cmap, fontMatrix) {
21972    super(fontMatrix || [0.001, 0, 0, 0.001, 0, 0]);
21973    this.glyphs = cffInfo.glyphs;
21974    this.gsubrs = cffInfo.gsubrs || [];
21975    this.subrs = cffInfo.subrs || [];
21976    this.cmap = cmap;
21977    this.glyphNameMap = getGlyphsUnicode();
21978    this.gsubrsBias = getSubroutineBias(this.gsubrs);
21979    this.subrsBias = getSubroutineBias(this.subrs);
21980    this.isCFFCIDFont = cffInfo.isCFFCIDFont;
21981    this.fdSelect = cffInfo.fdSelect;
21982    this.fdArray = cffInfo.fdArray;
21983  }
21984  compileGlyphImpl(code, cmds, glyphId) {
21985    compileCharString(code, cmds, this, glyphId);
21986  }
21987}
21988class FontRendererFactory {
21989  static create(font, seacAnalysisEnabled) {
21990    const data = new Uint8Array(font.data),
21991      view = new DataView(data.buffer);
vendor: 1,413 bytes, lines 21992-22032
21992    let cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
21993    const numTables = view.getUint16(4);
21994    for (let i = 0, p = 12; i < numTables; i++, p += 16) {
21995      const tag = bytesToString(data.subarray(p, p + 4));
21996      const offset = view.getUint32(p + 8);
21997      const length = view.getUint32(p + 12);
21998      switch (tag) {
21999        case "cmap":
22000          cmap = parseCmap(data, offset, offset + length);
22001          break;
22002        case "glyf":
22003          glyf = data.subarray(offset, offset + length);
22004          break;
22005        case "loca":
22006          loca = data.subarray(offset, offset + length);
22007          break;
22008        case "head":
22009          unitsPerEm = view.getUint16(offset + 18);
22010          indexToLocFormat = view.getUint16(offset + 50);
22011          break;
22012        case "CFF ":
22013          cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
22014          break;
22015      }
22016    }
22017    if (glyf) {
22018      const fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
22019      return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
22020    }
22021    return new Type2Compiled(cff, cmap, font.fontMatrix);
22022  }
22023}
22024
22025;// ./src/core/metrics.js
22026
22027const getMetrics = getLookupTableFactory(function (t) {
22028  t.Courier = 600;
22029  t["Courier-Bold"] = 600;
22030  t["Courier-BoldOblique"] = 600;
22031  t["Courier-Oblique"] = 600;
22032  t.Helvetica = getLookupTableFactory
vendor: 5,719 bytes, lines 22032-22312
22032(function (t) {
22033    t.space = 278;
22034    t.exclam = 278;
22035    t.quotedbl = 355;
22036    t.numbersign = 556;
22037    t.dollar = 556;
22038    t.percent = 889;
22039    t.ampersand = 667;
22040    t.quoteright = 222;
22041    t.parenleft = 333;
22042    t.parenright = 333;
22043    t.asterisk = 389;
22044    t.plus = 584;
22045    t.comma = 278;
22046    t.hyphen = 333;
22047    t.period = 278;
22048    t.slash = 278;
22049    t.zero = 556;
22050    t.one = 556;
22051    t.two = 556;
22052    t.three = 556;
22053    t.four = 556;
22054    t.five = 556;
22055    t.six = 556;
22056    t.seven = 556;
22057    t.eight = 556;
22058    t.nine = 556;
22059    t.colon = 278;
22060    t.semicolon = 278;
22061    t.less = 584;
22062    t.equal = 584;
22063    t.greater = 584;
22064    t.question = 556;
22065    t.at = 1015;
22066    t.A = 667;
22067    t.B = 667;
22068    t.C = 722;
22069    t.D = 722;
22070    t.E = 667;
22071    t.F = 611;
22072    t.G = 778;
22073    t.H = 722;
22074    t.I = 278;
22075    t.J = 500;
22076    t.K = 667;
22077    t.L = 556;
22078    t.M = 833;
22079    t.N = 722;
22080    t.O = 778;
22081    t.P = 667;
22082    t.Q = 778;
22083    t.R = 722;
22084    t.S = 667;
22085    t.T = 611;
22086    t.U = 722;
22087    t.V = 667;
22088    t.W = 944;
22089    t.X = 667;
22090    t.Y = 667;
22091    t.Z = 611;
22092    t.bracketleft = 278;
22093    t.backslash = 278;
22094    t.bracketright = 278;
22095    t.asciicircum = 469;
22096    t.underscore = 556;
22097    t.quoteleft = 222;
22098    t.a = 556;
22099    t.b = 556;
22100    t.c = 500;
22101    t.d = 556;
22102    t.e = 556;
22103    t.f = 278;
22104    t.g = 556;
22105    t.h = 556;
22106    t.i = 222;
22107    t.j = 222;
22108    t.k = 500;
22109    t.l = 222;
22110    t.m = 833;
22111    t.n = 556;
22112    t.o = 556;
22113    t.p = 556;
22114    t.q = 556;
22115    t.r = 333;
22116    t.s = 500;
22117    t.t = 278;
22118    t.u = 556;
22119    t.v = 500;
22120    t.w = 722;
22121    t.x = 500;
22122    t.y = 500;
22123    t.z = 500;
22124    t.braceleft = 334;
22125    t.bar = 260;
22126    t.braceright = 334;
22127    t.asciitilde = 584;
22128    t.exclamdown = 333;
22129    t.cent = 556;
22130    t.sterling = 556;
22131    t.fraction = 167;
22132    t.yen = 556;
22133    t.florin = 556;
22134    t.section = 556;
22135    t.currency = 556;
22136    t.quotesingle = 191;
22137    t.quotedblleft = 333;
22138    t.guillemotleft = 556;
22139    t.guilsinglleft = 333;
22140    t.guilsinglright = 333;
22141    t.fi = 500;
22142    t.fl = 500;
22143    t.endash = 556;
22144    t.dagger = 556;
22145    t.daggerdbl = 556;
22146    t.periodcentered = 278;
22147    t.paragraph = 537;
22148    t.bullet = 350;
22149    t.quotesinglbase = 222;
22150    t.quotedblbase = 333;
22151    t.quotedblright = 333;
22152    t.guillemotright = 556;
22153    t.ellipsis = 1000;
22154    t.perthousand = 1000;
22155    t.questiondown = 611;
22156    t.grave = 333;
22157    t.acute = 333;
22158    t.circumflex = 333;
22159    t.tilde = 333;
22160    t.macron = 333;
22161    t.breve = 333;
22162    t.dotaccent = 333;
22163    t.dieresis = 333;
22164    t.ring = 333;
22165    t.cedilla = 333;
22166    t.hungarumlaut = 333;
22167    t.ogonek = 333;
22168    t.caron = 333;
22169    t.emdash = 1000;
22170    t.AE = 1000;
22171    t.ordfeminine = 370;
22172    t.Lslash = 556;
22173    t.Oslash = 778;
22174    t.OE = 1000;
22175    t.ordmasculine = 365;
22176    t.ae = 889;
22177    t.dotlessi = 278;
22178    t.lslash = 222;
22179    t.oslash = 611;
22180    t.oe = 944;
22181    t.germandbls = 611;
22182    t.Idieresis = 278;
22183    t.eacute = 556;
22184    t.abreve = 556;
22185    t.uhungarumlaut = 556;
22186    t.ecaron = 556;
22187    t.Ydieresis = 667;
22188    t.divide = 584;
22189    t.Yacute = 667;
22190    t.Acircumflex = 667;
22191    t.aacute = 556;
22192    t.Ucircumflex = 722;
22193    t.yacute = 500;
22194    t.scommaaccent = 500;
22195    t.ecircumflex = 556;
22196    t.Uring = 722;
22197    t.Udieresis = 722;
22198    t.aogonek = 556;
22199    t.Uacute = 722;
22200    t.uogonek = 556;
22201    t.Edieresis = 667;
22202    t.Dcroat = 722;
22203    t.commaaccent = 250;
22204    t.copyright = 737;
22205    t.Emacron = 667;
22206    t.ccaron = 500;
22207    t.aring = 556;
22208    t.Ncommaaccent = 722;
22209    t.lacute = 222;
22210    t.agrave = 556;
22211    t.Tcommaaccent = 611;
22212    t.Cacute = 722;
22213    t.atilde = 556;
22214    t.Edotaccent = 667;
22215    t.scaron = 500;
22216    t.scedilla = 500;
22217    t.iacute = 278;
22218    t.lozenge = 471;
22219    t.Rcaron = 722;
22220    t.Gcommaaccent = 778;
22221    t.ucircumflex = 556;
22222    t.acircumflex = 556;
22223    t.Amacron = 667;
22224    t.rcaron = 333;
22225    t.ccedilla = 500;
22226    t.Zdotaccent = 611;
22227    t.Thorn = 667;
22228    t.Omacron = 778;
22229    t.Racute = 722;
22230    t.Sacute = 667;
22231    t.dcaron = 643;
22232    t.Umacron = 722;
22233    t.uring = 556;
22234    t.threesuperior = 333;
22235    t.Ograve = 778;
22236    t.Agrave = 667;
22237    t.Abreve = 667;
22238    t.multiply = 584;
22239    t.uacute = 556;
22240    t.Tcaron = 611;
22241    t.partialdiff = 476;
22242    t.ydieresis = 500;
22243    t.Nacute = 722;
22244    t.icircumflex = 278;
22245    t.Ecircumflex = 667;
22246    t.adieresis = 556;
22247    t.edieresis = 556;
22248    t.cacute = 500;
22249    t.nacute = 556;
22250    t.umacron = 556;
22251    t.Ncaron = 722;
22252    t.Iacute = 278;
22253    t.plusminus = 584;
22254    t.brokenbar = 260;
22255    t.registered = 737;
22256    t.Gbreve = 778;
22257    t.Idotaccent = 278;
22258    t.summation = 600;
22259    t.Egrave = 667;
22260    t.racute = 333;
22261    t.omacron = 556;
22262    t.Zacute = 611;
22263    t.Zcaron = 611;
22264    t.greaterequal = 549;
22265    t.Eth = 722;
22266    t.Ccedilla = 722;
22267    t.lcommaaccent = 222;
22268    t.tcaron = 317;
22269    t.eogonek = 556;
22270    t.Uogonek = 722;
22271    t.Aacute = 667;
22272    t.Adieresis = 667;
22273    t.egrave = 556;
22274    t.zacute = 500;
22275    t.iogonek = 222;
22276    t.Oacute = 778;
22277    t.oacute = 556;
22278    t.amacron = 556;
22279    t.sacute = 500;
22280    t.idieresis = 278;
22281    t.Ocircumflex = 778;
22282    t.Ugrave = 722;
22283    t.Delta = 612;
22284    t.thorn = 556;
22285    t.twosuperior = 333;
22286    t.Odieresis = 778;
22287    t.mu = 556;
22288    t.igrave = 278;
22289    t.ohungarumlaut = 556;
22290    t.Eogonek = 667;
22291    t.dcroat = 556;
22292    t.threequarters = 834;
22293    t.Scedilla = 667;
22294    t.lcaron = 299;
22295    t.Kcommaaccent = 667;
22296    t.Lacute = 556;
22297    t.trademark = 1000;
22298    t.edotaccent = 556;
22299    t.Igrave = 278;
22300    t.Imacron = 278;
22301    t.Lcaron = 556;
22302    t.onehalf = 834;
22303    t.lessequal = 549;
22304    t.ocircumflex = 556;
22305    t.ntilde = 556;
22306    t.Uhungarumlaut = 722;
22307    t.Eacute = 667;
22308    t.emacron = 556;
22309    t.gbreve = 556;
22310    t.onequarter = 834;
22311    t.Scaron = 667;
22312    t.Scommaaccent = 667;
vendor: 14,768 bytes, lines 22313-23028
22313    t.Ohungarumlaut = 778;
22314    t.degree = 400;
22315    t.ograve = 556;
22316    t.Ccaron = 722;
22317    t.ugrave = 556;
22318    t.radical = 453;
22319    t.Dcaron = 722;
22320    t.rcommaaccent = 333;
22321    t.Ntilde = 722;
22322    t.otilde = 556;
22323    t.Rcommaaccent = 722;
22324    t.Lcommaaccent = 556;
22325    t.Atilde = 667;
22326    t.Aogonek = 667;
22327    t.Aring = 667;
22328    t.Otilde = 778;
22329    t.zdotaccent = 500;
22330    t.Ecaron = 667;
22331    t.Iogonek = 278;
22332    t.kcommaaccent = 500;
22333    t.minus = 584;
22334    t.Icircumflex = 278;
22335    t.ncaron = 556;
22336    t.tcommaaccent = 278;
22337    t.logicalnot = 584;
22338    t.odieresis = 556;
22339    t.udieresis = 556;
22340    t.notequal = 549;
22341    t.gcommaaccent = 556;
22342    t.eth = 556;
22343    t.zcaron = 500;
22344    t.ncommaaccent = 556;
22345    t.onesuperior = 333;
22346    t.imacron = 278;
22347    t.Euro = 556;
22348  });
22349  t["Helvetica-Bold"] = getLookupTableFactory(function (t) {
22350    t.space = 278;
22351    t.exclam = 333;
22352    t.quotedbl = 474;
22353    t.numbersign = 556;
22354    t.dollar = 556;
22355    t.percent = 889;
22356    t.ampersand = 722;
22357    t.quoteright = 278;
22358    t.parenleft = 333;
22359    t.parenright = 333;
22360    t.asterisk = 389;
22361    t.plus = 584;
22362    t.comma = 278;
22363    t.hyphen = 333;
22364    t.period = 278;
22365    t.slash = 278;
22366    t.zero = 556;
22367    t.one = 556;
22368    t.two = 556;
22369    t.three = 556;
22370    t.four = 556;
22371    t.five = 556;
22372    t.six = 556;
22373    t.seven = 556;
22374    t.eight = 556;
22375    t.nine = 556;
22376    t.colon = 333;
22377    t.semicolon = 333;
22378    t.less = 584;
22379    t.equal = 584;
22380    t.greater = 584;
22381    t.question = 611;
22382    t.at = 975;
22383    t.A = 722;
22384    t.B = 722;
22385    t.C = 722;
22386    t.D = 722;
22387    t.E = 667;
22388    t.F = 611;
22389    t.G = 778;
22390    t.H = 722;
22391    t.I = 278;
22392    t.J = 556;
22393    t.K = 722;
22394    t.L = 611;
22395    t.M = 833;
22396    t.N = 722;
22397    t.O = 778;
22398    t.P = 667;
22399    t.Q = 778;
22400    t.R = 722;
22401    t.S = 667;
22402    t.T = 611;
22403    t.U = 722;
22404    t.V = 667;
22405    t.W = 944;
22406    t.X = 667;
22407    t.Y = 667;
22408    t.Z = 611;
22409    t.bracketleft = 333;
22410    t.backslash = 278;
22411    t.bracketright = 333;
22412    t.asciicircum = 584;
22413    t.underscore = 556;
22414    t.quoteleft = 278;
22415    t.a = 556;
22416    t.b = 611;
22417    t.c = 556;
22418    t.d = 611;
22419    t.e = 556;
22420    t.f = 333;
22421    t.g = 611;
22422    t.h = 611;
22423    t.i = 278;
22424    t.j = 278;
22425    t.k = 556;
22426    t.l = 278;
22427    t.m = 889;
22428    t.n = 611;
22429    t.o = 611;
22430    t.p = 611;
22431    t.q = 611;
22432    t.r = 389;
22433    t.s = 556;
22434    t.t = 333;
22435    t.u = 611;
22436    t.v = 556;
22437    t.w = 778;
22438    t.x = 556;
22439    t.y = 556;
22440    t.z = 500;
22441    t.braceleft = 389;
22442    t.bar = 280;
22443    t.braceright = 389;
22444    t.asciitilde = 584;
22445    t.exclamdown = 333;
22446    t.cent = 556;
22447    t.sterling = 556;
22448    t.fraction = 167;
22449    t.yen = 556;
22450    t.florin = 556;
22451    t.section = 556;
22452    t.currency = 556;
22453    t.quotesingle = 238;
22454    t.quotedblleft = 500;
22455    t.guillemotleft = 556;
22456    t.guilsinglleft = 333;
22457    t.guilsinglright = 333;
22458    t.fi = 611;
22459    t.fl = 611;
22460    t.endash = 556;
22461    t.dagger = 556;
22462    t.daggerdbl = 556;
22463    t.periodcentered = 278;
22464    t.paragraph = 556;
22465    t.bullet = 350;
22466    t.quotesinglbase = 278;
22467    t.quotedblbase = 500;
22468    t.quotedblright = 500;
22469    t.guillemotright = 556;
22470    t.ellipsis = 1000;
22471    t.perthousand = 1000;
22472    t.questiondown = 611;
22473    t.grave = 333;
22474    t.acute = 333;
22475    t.circumflex = 333;
22476    t.tilde = 333;
22477    t.macron = 333;
22478    t.breve = 333;
22479    t.dotaccent = 333;
22480    t.dieresis = 333;
22481    t.ring = 333;
22482    t.cedilla = 333;
22483    t.hungarumlaut = 333;
22484    t.ogonek = 333;
22485    t.caron = 333;
22486    t.emdash = 1000;
22487    t.AE = 1000;
22488    t.ordfeminine = 370;
22489    t.Lslash = 611;
22490    t.Oslash = 778;
22491    t.OE = 1000;
22492    t.ordmasculine = 365;
22493    t.ae = 889;
22494    t.dotlessi = 278;
22495    t.lslash = 278;
22496    t.oslash = 611;
22497    t.oe = 944;
22498    t.germandbls = 611;
22499    t.Idieresis = 278;
22500    t.eacute = 556;
22501    t.abreve = 556;
22502    t.uhungarumlaut = 611;
22503    t.ecaron = 556;
22504    t.Ydieresis = 667;
22505    t.divide = 584;
22506    t.Yacute = 667;
22507    t.Acircumflex = 722;
22508    t.aacute = 556;
22509    t.Ucircumflex = 722;
22510    t.yacute = 556;
22511    t.scommaaccent = 556;
22512    t.ecircumflex = 556;
22513    t.Uring = 722;
22514    t.Udieresis = 722;
22515    t.aogonek = 556;
22516    t.Uacute = 722;
22517    t.uogonek = 611;
22518    t.Edieresis = 667;
22519    t.Dcroat = 722;
22520    t.commaaccent = 250;
22521    t.copyright = 737;
22522    t.Emacron = 667;
22523    t.ccaron = 556;
22524    t.aring = 556;
22525    t.Ncommaaccent = 722;
22526    t.lacute = 278;
22527    t.agrave = 556;
22528    t.Tcommaaccent = 611;
22529    t.Cacute = 722;
22530    t.atilde = 556;
22531    t.Edotaccent = 667;
22532    t.scaron = 556;
22533    t.scedilla = 556;
22534    t.iacute = 278;
22535    t.lozenge = 494;
22536    t.Rcaron = 722;
22537    t.Gcommaaccent = 778;
22538    t.ucircumflex = 611;
22539    t.acircumflex = 556;
22540    t.Amacron = 722;
22541    t.rcaron = 389;
22542    t.ccedilla = 556;
22543    t.Zdotaccent = 611;
22544    t.Thorn = 667;
22545    t.Omacron = 778;
22546    t.Racute = 722;
22547    t.Sacute = 667;
22548    t.dcaron = 743;
22549    t.Umacron = 722;
22550    t.uring = 611;
22551    t.threesuperior = 333;
22552    t.Ograve = 778;
22553    t.Agrave = 722;
22554    t.Abreve = 722;
22555    t.multiply = 584;
22556    t.uacute = 611;
22557    t.Tcaron = 611;
22558    t.partialdiff = 494;
22559    t.ydieresis = 556;
22560    t.Nacute = 722;
22561    t.icircumflex = 278;
22562    t.Ecircumflex = 667;
22563    t.adieresis = 556;
22564    t.edieresis = 556;
22565    t.cacute = 556;
22566    t.nacute = 611;
22567    t.umacron = 611;
22568    t.Ncaron = 722;
22569    t.Iacute = 278;
22570    t.plusminus = 584;
22571    t.brokenbar = 280;
22572    t.registered = 737;
22573    t.Gbreve = 778;
22574    t.Idotaccent = 278;
22575    t.summation = 600;
22576    t.Egrave = 667;
22577    t.racute = 389;
22578    t.omacron = 611;
22579    t.Zacute = 611;
22580    t.Zcaron = 611;
22581    t.greaterequal = 549;
22582    t.Eth = 722;
22583    t.Ccedilla = 722;
22584    t.lcommaaccent = 278;
22585    t.tcaron = 389;
22586    t.eogonek = 556;
22587    t.Uogonek = 722;
22588    t.Aacute = 722;
22589    t.Adieresis = 722;
22590    t.egrave = 556;
22591    t.zacute = 500;
22592    t.iogonek = 278;
22593    t.Oacute = 778;
22594    t.oacute = 611;
22595    t.amacron = 556;
22596    t.sacute = 556;
22597    t.idieresis = 278;
22598    t.Ocircumflex = 778;
22599    t.Ugrave = 722;
22600    t.Delta = 612;
22601    t.thorn = 611;
22602    t.twosuperior = 333;
22603    t.Odieresis = 778;
22604    t.mu = 611;
22605    t.igrave = 278;
22606    t.ohungarumlaut = 611;
22607    t.Eogonek = 667;
22608    t.dcroat = 611;
22609    t.threequarters = 834;
22610    t.Scedilla = 667;
22611    t.lcaron = 400;
22612    t.Kcommaaccent = 722;
22613    t.Lacute = 611;
22614    t.trademark = 1000;
22615    t.edotaccent = 556;
22616    t.Igrave = 278;
22617    t.Imacron = 278;
22618    t.Lcaron = 611;
22619    t.onehalf = 834;
22620    t.lessequal = 549;
22621    t.ocircumflex = 611;
22622    t.ntilde = 611;
22623    t.Uhungarumlaut = 722;
22624    t.Eacute = 667;
22625    t.emacron = 556;
22626    t.gbreve = 611;
22627    t.onequarter = 834;
22628    t.Scaron = 667;
22629    t.Scommaaccent = 667;
22630    t.Ohungarumlaut = 778;
22631    t.degree = 400;
22632    t.ograve = 611;
22633    t.Ccaron = 722;
22634    t.ugrave = 611;
22635    t.radical = 549;
22636    t.Dcaron = 722;
22637    t.rcommaaccent = 389;
22638    t.Ntilde = 722;
22639    t.otilde = 611;
22640    t.Rcommaaccent = 722;
22641    t.Lcommaaccent = 611;
22642    t.Atilde = 722;
22643    t.Aogonek = 722;
22644    t.Aring = 722;
22645    t.Otilde = 778;
22646    t.zdotaccent = 500;
22647    t.Ecaron = 667;
22648    t.Iogonek = 278;
22649    t.kcommaaccent = 556;
22650    t.minus = 584;
22651    t.Icircumflex = 278;
22652    t.ncaron = 611;
22653    t.tcommaaccent = 333;
22654    t.logicalnot = 584;
22655    t.odieresis = 611;
22656    t.udieresis = 611;
22657    t.notequal = 549;
22658    t.gcommaaccent = 611;
22659    t.eth = 611;
22660    t.zcaron = 500;
22661    t.ncommaaccent = 611;
22662    t.onesuperior = 333;
22663    t.imacron = 278;
22664    t.Euro = 556;
22665  });
22666  t["Helvetica-BoldOblique"] = getLookupTableFactory(function (t) {
22667    t.space = 278;
22668    t.exclam = 333;
22669    t.quotedbl = 474;
22670    t.numbersign = 556;
22671    t.dollar = 556;
22672    t.percent = 889;
22673    t.ampersand = 722;
22674    t.quoteright = 278;
22675    t.parenleft = 333;
22676    t.parenright = 333;
22677    t.asterisk = 389;
22678    t.plus = 584;
22679    t.comma = 278;
22680    t.hyphen = 333;
22681    t.period = 278;
22682    t.slash = 278;
22683    t.zero = 556;
22684    t.one = 556;
22685    t.two = 556;
22686    t.three = 556;
22687    t.four = 556;
22688    t.five = 556;
22689    t.six = 556;
22690    t.seven = 556;
22691    t.eight = 556;
22692    t.nine = 556;
22693    t.colon = 333;
22694    t.semicolon = 333;
22695    t.less = 584;
22696    t.equal = 584;
22697    t.greater = 584;
22698    t.question = 611;
22699    t.at = 975;
22700    t.A = 722;
22701    t.B = 722;
22702    t.C = 722;
22703    t.D = 722;
22704    t.E = 667;
22705    t.F = 611;
22706    t.G = 778;
22707    t.H = 722;
22708    t.I = 278;
22709    t.J = 556;
22710    t.K = 722;
22711    t.L = 611;
22712    t.M = 833;
22713    t.N = 722;
22714    t.O = 778;
22715    t.P = 667;
22716    t.Q = 778;
22717    t.R = 722;
22718    t.S = 667;
22719    t.T = 611;
22720    t.U = 722;
22721    t.V = 667;
22722    t.W = 944;
22723    t.X = 667;
22724    t.Y = 667;
22725    t.Z = 611;
22726    t.bracketleft = 333;
22727    t.backslash = 278;
22728    t.bracketright = 333;
22729    t.asciicircum = 584;
22730    t.underscore = 556;
22731    t.quoteleft = 278;
22732    t.a = 556;
22733    t.b = 611;
22734    t.c = 556;
22735    t.d = 611;
22736    t.e = 556;
22737    t.f = 333;
22738    t.g = 611;
22739    t.h = 611;
22740    t.i = 278;
22741    t.j = 278;
22742    t.k = 556;
22743    t.l = 278;
22744    t.m = 889;
22745    t.n = 611;
22746    t.o = 611;
22747    t.p = 611;
22748    t.q = 611;
22749    t.r = 389;
22750    t.s = 556;
22751    t.t = 333;
22752    t.u = 611;
22753    t.v = 556;
22754    t.w = 778;
22755    t.x = 556;
22756    t.y = 556;
22757    t.z = 500;
22758    t.braceleft = 389;
22759    t.bar = 280;
22760    t.braceright = 389;
22761    t.asciitilde = 584;
22762    t.exclamdown = 333;
22763    t.cent = 556;
22764    t.sterling = 556;
22765    t.fraction = 167;
22766    t.yen = 556;
22767    t.florin = 556;
22768    t.section = 556;
22769    t.currency = 556;
22770    t.quotesingle = 238;
22771    t.quotedblleft = 500;
22772    t.guillemotleft = 556;
22773    t.guilsinglleft = 333;
22774    t.guilsinglright = 333;
22775    t.fi = 611;
22776    t.fl = 611;
22777    t.endash = 556;
22778    t.dagger = 556;
22779    t.daggerdbl = 556;
22780    t.periodcentered = 278;
22781    t.paragraph = 556;
22782    t.bullet = 350;
22783    t.quotesinglbase = 278;
22784    t.quotedblbase = 500;
22785    t.quotedblright = 500;
22786    t.guillemotright = 556;
22787    t.ellipsis = 1000;
22788    t.perthousand = 1000;
22789    t.questiondown = 611;
22790    t.grave = 333;
22791    t.acute = 333;
22792    t.circumflex = 333;
22793    t.tilde = 333;
22794    t.macron = 333;
22795    t.breve = 333;
22796    t.dotaccent = 333;
22797    t.dieresis = 333;
22798    t.ring = 333;
22799    t.cedilla = 333;
22800    t.hungarumlaut = 333;
22801    t.ogonek = 333;
22802    t.caron = 333;
22803    t.emdash = 1000;
22804    t.AE = 1000;
22805    t.ordfeminine = 370;
22806    t.Lslash = 611;
22807    t.Oslash = 778;
22808    t.OE = 1000;
22809    t.ordmasculine = 365;
22810    t.ae = 889;
22811    t.dotlessi = 278;
22812    t.lslash = 278;
22813    t.oslash = 611;
22814    t.oe = 944;
22815    t.germandbls = 611;
22816    t.Idieresis = 278;
22817    t.eacute = 556;
22818    t.abreve = 556;
22819    t.uhungarumlaut = 611;
22820    t.ecaron = 556;
22821    t.Ydieresis = 667;
22822    t.divide = 584;
22823    t.Yacute = 667;
22824    t.Acircumflex = 722;
22825    t.aacute = 556;
22826    t.Ucircumflex = 722;
22827    t.yacute = 556;
22828    t.scommaaccent = 556;
22829    t.ecircumflex = 556;
22830    t.Uring = 722;
22831    t.Udieresis = 722;
22832    t.aogonek = 556;
22833    t.Uacute = 722;
22834    t.uogonek = 611;
22835    t.Edieresis = 667;
22836    t.Dcroat = 722;
22837    t.commaaccent = 250;
22838    t.copyright = 737;
22839    t.Emacron = 667;
22840    t.ccaron = 556;
22841    t.aring = 556;
22842    t.Ncommaaccent = 722;
22843    t.lacute = 278;
22844    t.agrave = 556;
22845    t.Tcommaaccent = 611;
22846    t.Cacute = 722;
22847    t.atilde = 556;
22848    t.Edotaccent = 667;
22849    t.scaron = 556;
22850    t.scedilla = 556;
22851    t.iacute = 278;
22852    t.lozenge = 494;
22853    t.Rcaron = 722;
22854    t.Gcommaaccent = 778;
22855    t.ucircumflex = 611;
22856    t.acircumflex = 556;
22857    t.Amacron = 722;
22858    t.rcaron = 389;
22859    t.ccedilla = 556;
22860    t.Zdotaccent = 611;
22861    t.Thorn = 667;
22862    t.Omacron = 778;
22863    t.Racute = 722;
22864    t.Sacute = 667;
22865    t.dcaron = 743;
22866    t.Umacron = 722;
22867    t.uring = 611;
22868    t.threesuperior = 333;
22869    t.Ograve = 778;
22870    t.Agrave = 722;
22871    t.Abreve = 722;
22872    t.multiply = 584;
22873    t.uacute = 611;
22874    t.Tcaron = 611;
22875    t.partialdiff = 494;
22876    t.ydieresis = 556;
22877    t.Nacute = 722;
22878    t.icircumflex = 278;
22879    t.Ecircumflex = 667;
22880    t.adieresis = 556;
22881    t.edieresis = 556;
22882    t.cacute = 556;
22883    t.nacute = 611;
22884    t.umacron = 611;
22885    t.Ncaron = 722;
22886    t.Iacute = 278;
22887    t.plusminus = 584;
22888    t.brokenbar = 280;
22889    t.registered = 737;
22890    t.Gbreve = 778;
22891    t.Idotaccent = 278;
22892    t.summation = 600;
22893    t.Egrave = 667;
22894    t.racute = 389;
22895    t.omacron = 611;
22896    t.Zacute = 611;
22897    t.Zcaron = 611;
22898    t.greaterequal = 549;
22899    t.Eth = 722;
22900    t.Ccedilla = 722;
22901    t.lcommaaccent = 278;
22902    t.tcaron = 389;
22903    t.eogonek = 556;
22904    t.Uogonek = 722;
22905    t.Aacute = 722;
22906    t.Adieresis = 722;
22907    t.egrave = 556;
22908    t.zacute = 500;
22909    t.iogonek = 278;
22910    t.Oacute = 778;
22911    t.oacute = 611;
22912    t.amacron = 556;
22913    t.sacute = 556;
22914    t.idieresis = 278;
22915    t.Ocircumflex = 778;
22916    t.Ugrave = 722;
22917    t.Delta = 612;
22918    t.thorn = 611;
22919    t.twosuperior = 333;
22920    t.Odieresis = 778;
22921    t.mu = 611;
22922    t.igrave = 278;
22923    t.ohungarumlaut = 611;
22924    t.Eogonek = 667;
22925    t.dcroat = 611;
22926    t.threequarters = 834;
22927    t.Scedilla = 667;
22928    t.lcaron = 400;
22929    t.Kcommaaccent = 722;
22930    t.Lacute = 611;
22931    t.trademark = 1000;
22932    t.edotaccent = 556;
22933    t.Igrave = 278;
22934    t.Imacron = 278;
22935    t.Lcaron = 611;
22936    t.onehalf = 834;
22937    t.lessequal = 549;
22938    t.ocircumflex = 611;
22939    t.ntilde = 611;
22940    t.Uhungarumlaut = 722;
22941    t.Eacute = 667;
22942    t.emacron = 556;
22943    t.gbreve = 611;
22944    t.onequarter = 834;
22945    t.Scaron = 667;
22946    t.Scommaaccent = 667;
22947    t.Ohungarumlaut = 778;
22948    t.degree = 400;
22949    t.ograve = 611;
22950    t.Ccaron = 722;
22951    t.ugrave = 611;
22952    t.radical = 549;
22953    t.Dcaron = 722;
22954    t.rcommaaccent = 389;
22955    t.Ntilde = 722;
22956    t.otilde = 611;
22957    t.Rcommaaccent = 722;
22958    t.Lcommaaccent = 611;
22959    t.Atilde = 722;
22960    t.Aogonek = 722;
22961    t.Aring = 722;
22962    t.Otilde = 778;
22963    t.zdotaccent = 500;
22964    t.Ecaron = 667;
22965    t.Iogonek = 278;
22966    t.kcommaaccent = 556;
22967    t.minus = 584;
22968    t.Icircumflex = 278;
22969    t.ncaron = 611;
22970    t.tcommaaccent = 333;
22971    t.logicalnot = 584;
22972    t.odieresis = 611;
22973    t.udieresis = 611;
22974    t.notequal = 549;
22975    t.gcommaaccent = 611;
22976    t.eth = 611;
22977    t.zcaron = 500;
22978    t.ncommaaccent = 611;
22979    t.onesuperior = 333;
22980    t.imacron = 278;
22981    t.Euro = 556;
22982  });
22983  t["Helvetica-Oblique"] = getLookupTableFactory(function (t) {
22984    t.space = 278;
22985    t.exclam = 278;
22986    t.quotedbl = 355;
22987    t.numbersign = 556;
22988    t.dollar = 556;
22989    t.percent = 889;
22990    t.ampersand = 667;
22991    t.quoteright = 222;
22992    t.parenleft = 333;
22993    t.parenright = 333;
22994    t.asterisk = 389;
22995    t.plus = 584;
22996    t.comma = 278;
22997    t.hyphen = 333;
22998    t.period = 278;
22999    t.slash = 278;
23000    t.zero = 556;
23001    t.one = 556;
23002    t.two = 556;
23003    t.three = 556;
23004    t.four = 556;
23005    t.five = 556;
23006    t.six = 556;
23007    t.seven = 556;
23008    t.eight = 556;
23009    t.nine = 556;
23010    t.colon = 278;
23011    t.semicolon = 278;
23012    t.less = 584;
23013    t.equal = 584;
23014    t.greater = 584;
23015    t.question = 556;
23016    t.at = 1015;
23017    t.A = 667;
23018    t.B = 667;
23019    t.C = 722;
23020    t.D = 722;
23021    t.E = 667;
23022    t.F = 611;
23023    t.G = 778;
23024    t.H = 722;
23025    t.I = 278;
23026    t.J = 500;
23027    t.K = 667;
23028    t.L = 556;
vendor: 4,866 bytes, lines 23029-23263
23029    t.M = 833;
23030    t.N = 722;
23031    t.O = 778;
23032    t.P = 667;
23033    t.Q = 778;
23034    t.R = 722;
23035    t.S = 667;
23036    t.T = 611;
23037    t.U = 722;
23038    t.V = 667;
23039    t.W = 944;
23040    t.X = 667;
23041    t.Y = 667;
23042    t.Z = 611;
23043    t.bracketleft = 278;
23044    t.backslash = 278;
23045    t.bracketright = 278;
23046    t.asciicircum = 469;
23047    t.underscore = 556;
23048    t.quoteleft = 222;
23049    t.a = 556;
23050    t.b = 556;
23051    t.c = 500;
23052    t.d = 556;
23053    t.e = 556;
23054    t.f = 278;
23055    t.g = 556;
23056    t.h = 556;
23057    t.i = 222;
23058    t.j = 222;
23059    t.k = 500;
23060    t.l = 222;
23061    t.m = 833;
23062    t.n = 556;
23063    t.o = 556;
23064    t.p = 556;
23065    t.q = 556;
23066    t.r = 333;
23067    t.s = 500;
23068    t.t = 278;
23069    t.u = 556;
23070    t.v = 500;
23071    t.w = 722;
23072    t.x = 500;
23073    t.y = 500;
23074    t.z = 500;
23075    t.braceleft = 334;
23076    t.bar = 260;
23077    t.braceright = 334;
23078    t.asciitilde = 584;
23079    t.exclamdown = 333;
23080    t.cent = 556;
23081    t.sterling = 556;
23082    t.fraction = 167;
23083    t.yen = 556;
23084    t.florin = 556;
23085    t.section = 556;
23086    t.currency = 556;
23087    t.quotesingle = 191;
23088    t.quotedblleft = 333;
23089    t.guillemotleft = 556;
23090    t.guilsinglleft = 333;
23091    t.guilsinglright = 333;
23092    t.fi = 500;
23093    t.fl = 500;
23094    t.endash = 556;
23095    t.dagger = 556;
23096    t.daggerdbl = 556;
23097    t.periodcentered = 278;
23098    t.paragraph = 537;
23099    t.bullet = 350;
23100    t.quotesinglbase = 222;
23101    t.quotedblbase = 333;
23102    t.quotedblright = 333;
23103    t.guillemotright = 556;
23104    t.ellipsis = 1000;
23105    t.perthousand = 1000;
23106    t.questiondown = 611;
23107    t.grave = 333;
23108    t.acute = 333;
23109    t.circumflex = 333;
23110    t.tilde = 333;
23111    t.macron = 333;
23112    t.breve = 333;
23113    t.dotaccent = 333;
23114    t.dieresis = 333;
23115    t.ring = 333;
23116    t.cedilla = 333;
23117    t.hungarumlaut = 333;
23118    t.ogonek = 333;
23119    t.caron = 333;
23120    t.emdash = 1000;
23121    t.AE = 1000;
23122    t.ordfeminine = 370;
23123    t.Lslash = 556;
23124    t.Oslash = 778;
23125    t.OE = 1000;
23126    t.ordmasculine = 365;
23127    t.ae = 889;
23128    t.dotlessi = 278;
23129    t.lslash = 222;
23130    t.oslash = 611;
23131    t.oe = 944;
23132    t.germandbls = 611;
23133    t.Idieresis = 278;
23134    t.eacute = 556;
23135    t.abreve = 556;
23136    t.uhungarumlaut = 556;
23137    t.ecaron = 556;
23138    t.Ydieresis = 667;
23139    t.divide = 584;
23140    t.Yacute = 667;
23141    t.Acircumflex = 667;
23142    t.aacute = 556;
23143    t.Ucircumflex = 722;
23144    t.yacute = 500;
23145    t.scommaaccent = 500;
23146    t.ecircumflex = 556;
23147    t.Uring = 722;
23148    t.Udieresis = 722;
23149    t.aogonek = 556;
23150    t.Uacute = 722;
23151    t.uogonek = 556;
23152    t.Edieresis = 667;
23153    t.Dcroat = 722;
23154    t.commaaccent = 250;
23155    t.copyright = 737;
23156    t.Emacron = 667;
23157    t.ccaron = 500;
23158    t.aring = 556;
23159    t.Ncommaaccent = 722;
23160    t.lacute = 222;
23161    t.agrave = 556;
23162    t.Tcommaaccent = 611;
23163    t.Cacute = 722;
23164    t.atilde = 556;
23165    t.Edotaccent = 667;
23166    t.scaron = 500;
23167    t.scedilla = 500;
23168    t.iacute = 278;
23169    t.lozenge = 471;
23170    t.Rcaron = 722;
23171    t.Gcommaaccent = 778;
23172    t.ucircumflex = 556;
23173    t.acircumflex = 556;
23174    t.Amacron = 667;
23175    t.rcaron = 333;
23176    t.ccedilla = 500;
23177    t.Zdotaccent = 611;
23178    t.Thorn = 667;
23179    t.Omacron = 778;
23180    t.Racute = 722;
23181    t.Sacute = 667;
23182    t.dcaron = 643;
23183    t.Umacron = 722;
23184    t.uring = 556;
23185    t.threesuperior = 333;
23186    t.Ograve = 778;
23187    t.Agrave = 667;
23188    t.Abreve = 667;
23189    t.multiply = 584;
23190    t.uacute = 556;
23191    t.Tcaron = 611;
23192    t.partialdiff = 476;
23193    t.ydieresis = 500;
23194    t.Nacute = 722;
23195    t.icircumflex = 278;
23196    t.Ecircumflex = 667;
23197    t.adieresis = 556;
23198    t.edieresis = 556;
23199    t.cacute = 500;
23200    t.nacute = 556;
23201    t.umacron = 556;
23202    t.Ncaron = 722;
23203    t.Iacute = 278;
23204    t.plusminus = 584;
23205    t.brokenbar = 260;
23206    t.registered = 737;
23207    t.Gbreve = 778;
23208    t.Idotaccent = 278;
23209    t.summation = 600;
23210    t.Egrave = 667;
23211    t.racute = 333;
23212    t.omacron = 556;
23213    t.Zacute = 611;
23214    t.Zcaron = 611;
23215    t.greaterequal = 549;
23216    t.Eth = 722;
23217    t.Ccedilla = 722;
23218    t.lcommaaccent = 222;
23219    t.tcaron = 317;
23220    t.eogonek = 556;
23221    t.Uogonek = 722;
23222    t.Aacute = 667;
23223    t.Adieresis = 667;
23224    t.egrave = 556;
23225    t.zacute = 500;
23226    t.iogonek = 222;
23227    t.Oacute = 778;
23228    t.oacute = 556;
23229    t.amacron = 556;
23230    t.sacute = 500;
23231    t.idieresis = 278;
23232    t.Ocircumflex = 778;
23233    t.Ugrave = 722;
23234    t.Delta = 612;
23235    t.thorn = 556;
23236    t.twosuperior = 333;
23237    t.Odieresis = 778;
23238    t.mu = 556;
23239    t.igrave = 278;
23240    t.ohungarumlaut = 556;
23241    t.Eogonek = 667;
23242    t.dcroat = 556;
23243    t.threequarters = 834;
23244    t.Scedilla = 667;
23245    t.lcaron = 299;
23246    t.Kcommaaccent = 667;
23247    t.Lacute = 556;
23248    t.trademark = 1000;
23249    t.edotaccent = 556;
23250    t.Igrave = 278;
23251    t.Imacron = 278;
23252    t.Lcaron = 556;
23253    t.onehalf = 834;
23254    t.lessequal = 549;
23255    t.ocircumflex = 556;
23256    t.ntilde = 556;
23257    t.Uhungarumlaut = 722;
23258    t.Eacute = 667;
23259    t.emacron = 556;
23260    t.gbreve = 556;
23261    t.onequarter = 834;
23262    t.Scaron = 667;
23263    t.Scommaaccent = 667;
vendor: 25,462 bytes, lines 23264-24488
23264    t.Ohungarumlaut = 778;
23265    t.degree = 400;
23266    t.ograve = 556;
23267    t.Ccaron = 722;
23268    t.ugrave = 556;
23269    t.radical = 453;
23270    t.Dcaron = 722;
23271    t.rcommaaccent = 333;
23272    t.Ntilde = 722;
23273    t.otilde = 556;
23274    t.Rcommaaccent = 722;
23275    t.Lcommaaccent = 556;
23276    t.Atilde = 667;
23277    t.Aogonek = 667;
23278    t.Aring = 667;
23279    t.Otilde = 778;
23280    t.zdotaccent = 500;
23281    t.Ecaron = 667;
23282    t.Iogonek = 278;
23283    t.kcommaaccent = 500;
23284    t.minus = 584;
23285    t.Icircumflex = 278;
23286    t.ncaron = 556;
23287    t.tcommaaccent = 278;
23288    t.logicalnot = 584;
23289    t.odieresis = 556;
23290    t.udieresis = 556;
23291    t.notequal = 549;
23292    t.gcommaaccent = 556;
23293    t.eth = 556;
23294    t.zcaron = 500;
23295    t.ncommaaccent = 556;
23296    t.onesuperior = 333;
23297    t.imacron = 278;
23298    t.Euro = 556;
23299  });
23300  t.Symbol = getLookupTableFactory(function (t) {
23301    t.space = 250;
23302    t.exclam = 333;
23303    t.universal = 713;
23304    t.numbersign = 500;
23305    t.existential = 549;
23306    t.percent = 833;
23307    t.ampersand = 778;
23308    t.suchthat = 439;
23309    t.parenleft = 333;
23310    t.parenright = 333;
23311    t.asteriskmath = 500;
23312    t.plus = 549;
23313    t.comma = 250;
23314    t.minus = 549;
23315    t.period = 250;
23316    t.slash = 278;
23317    t.zero = 500;
23318    t.one = 500;
23319    t.two = 500;
23320    t.three = 500;
23321    t.four = 500;
23322    t.five = 500;
23323    t.six = 500;
23324    t.seven = 500;
23325    t.eight = 500;
23326    t.nine = 500;
23327    t.colon = 278;
23328    t.semicolon = 278;
23329    t.less = 549;
23330    t.equal = 549;
23331    t.greater = 549;
23332    t.question = 444;
23333    t.congruent = 549;
23334    t.Alpha = 722;
23335    t.Beta = 667;
23336    t.Chi = 722;
23337    t.Delta = 612;
23338    t.Epsilon = 611;
23339    t.Phi = 763;
23340    t.Gamma = 603;
23341    t.Eta = 722;
23342    t.Iota = 333;
23343    t.theta1 = 631;
23344    t.Kappa = 722;
23345    t.Lambda = 686;
23346    t.Mu = 889;
23347    t.Nu = 722;
23348    t.Omicron = 722;
23349    t.Pi = 768;
23350    t.Theta = 741;
23351    t.Rho = 556;
23352    t.Sigma = 592;
23353    t.Tau = 611;
23354    t.Upsilon = 690;
23355    t.sigma1 = 439;
23356    t.Omega = 768;
23357    t.Xi = 645;
23358    t.Psi = 795;
23359    t.Zeta = 611;
23360    t.bracketleft = 333;
23361    t.therefore = 863;
23362    t.bracketright = 333;
23363    t.perpendicular = 658;
23364    t.underscore = 500;
23365    t.radicalex = 500;
23366    t.alpha = 631;
23367    t.beta = 549;
23368    t.chi = 549;
23369    t.delta = 494;
23370    t.epsilon = 439;
23371    t.phi = 521;
23372    t.gamma = 411;
23373    t.eta = 603;
23374    t.iota = 329;
23375    t.phi1 = 603;
23376    t.kappa = 549;
23377    t.lambda = 549;
23378    t.mu = 576;
23379    t.nu = 521;
23380    t.omicron = 549;
23381    t.pi = 549;
23382    t.theta = 521;
23383    t.rho = 549;
23384    t.sigma = 603;
23385    t.tau = 439;
23386    t.upsilon = 576;
23387    t.omega1 = 713;
23388    t.omega = 686;
23389    t.xi = 493;
23390    t.psi = 686;
23391    t.zeta = 494;
23392    t.braceleft = 480;
23393    t.bar = 200;
23394    t.braceright = 480;
23395    t.similar = 549;
23396    t.Euro = 750;
23397    t.Upsilon1 = 620;
23398    t.minute = 247;
23399    t.lessequal = 549;
23400    t.fraction = 167;
23401    t.infinity = 713;
23402    t.florin = 500;
23403    t.club = 753;
23404    t.diamond = 753;
23405    t.heart = 753;
23406    t.spade = 753;
23407    t.arrowboth = 1042;
23408    t.arrowleft = 987;
23409    t.arrowup = 603;
23410    t.arrowright = 987;
23411    t.arrowdown = 603;
23412    t.degree = 400;
23413    t.plusminus = 549;
23414    t.second = 411;
23415    t.greaterequal = 549;
23416    t.multiply = 549;
23417    t.proportional = 713;
23418    t.partialdiff = 494;
23419    t.bullet = 460;
23420    t.divide = 549;
23421    t.notequal = 549;
23422    t.equivalence = 549;
23423    t.approxequal = 549;
23424    t.ellipsis = 1000;
23425    t.arrowvertex = 603;
23426    t.arrowhorizex = 1000;
23427    t.carriagereturn = 658;
23428    t.aleph = 823;
23429    t.Ifraktur = 686;
23430    t.Rfraktur = 795;
23431    t.weierstrass = 987;
23432    t.circlemultiply = 768;
23433    t.circleplus = 768;
23434    t.emptyset = 823;
23435    t.intersection = 768;
23436    t.union = 768;
23437    t.propersuperset = 713;
23438    t.reflexsuperset = 713;
23439    t.notsubset = 713;
23440    t.propersubset = 713;
23441    t.reflexsubset = 713;
23442    t.element = 713;
23443    t.notelement = 713;
23444    t.angle = 768;
23445    t.gradient = 713;
23446    t.registerserif = 790;
23447    t.copyrightserif = 790;
23448    t.trademarkserif = 890;
23449    t.product = 823;
23450    t.radical = 549;
23451    t.dotmath = 250;
23452    t.logicalnot = 713;
23453    t.logicaland = 603;
23454    t.logicalor = 603;
23455    t.arrowdblboth = 1042;
23456    t.arrowdblleft = 987;
23457    t.arrowdblup = 603;
23458    t.arrowdblright = 987;
23459    t.arrowdbldown = 603;
23460    t.lozenge = 494;
23461    t.angleleft = 329;
23462    t.registersans = 790;
23463    t.copyrightsans = 790;
23464    t.trademarksans = 786;
23465    t.summation = 713;
23466    t.parenlefttp = 384;
23467    t.parenleftex = 384;
23468    t.parenleftbt = 384;
23469    t.bracketlefttp = 384;
23470    t.bracketleftex = 384;
23471    t.bracketleftbt = 384;
23472    t.bracelefttp = 494;
23473    t.braceleftmid = 494;
23474    t.braceleftbt = 494;
23475    t.braceex = 494;
23476    t.angleright = 329;
23477    t.integral = 274;
23478    t.integraltp = 686;
23479    t.integralex = 686;
23480    t.integralbt = 686;
23481    t.parenrighttp = 384;
23482    t.parenrightex = 384;
23483    t.parenrightbt = 384;
23484    t.bracketrighttp = 384;
23485    t.bracketrightex = 384;
23486    t.bracketrightbt = 384;
23487    t.bracerighttp = 494;
23488    t.bracerightmid = 494;
23489    t.bracerightbt = 494;
23490    t.apple = 790;
23491  });
23492  t["Times-Roman"] = getLookupTableFactory(function (t) {
23493    t.space = 250;
23494    t.exclam = 333;
23495    t.quotedbl = 408;
23496    t.numbersign = 500;
23497    t.dollar = 500;
23498    t.percent = 833;
23499    t.ampersand = 778;
23500    t.quoteright = 333;
23501    t.parenleft = 333;
23502    t.parenright = 333;
23503    t.asterisk = 500;
23504    t.plus = 564;
23505    t.comma = 250;
23506    t.hyphen = 333;
23507    t.period = 250;
23508    t.slash = 278;
23509    t.zero = 500;
23510    t.one = 500;
23511    t.two = 500;
23512    t.three = 500;
23513    t.four = 500;
23514    t.five = 500;
23515    t.six = 500;
23516    t.seven = 500;
23517    t.eight = 500;
23518    t.nine = 500;
23519    t.colon = 278;
23520    t.semicolon = 278;
23521    t.less = 564;
23522    t.equal = 564;
23523    t.greater = 564;
23524    t.question = 444;
23525    t.at = 921;
23526    t.A = 722;
23527    t.B = 667;
23528    t.C = 667;
23529    t.D = 722;
23530    t.E = 611;
23531    t.F = 556;
23532    t.G = 722;
23533    t.H = 722;
23534    t.I = 333;
23535    t.J = 389;
23536    t.K = 722;
23537    t.L = 611;
23538    t.M = 889;
23539    t.N = 722;
23540    t.O = 722;
23541    t.P = 556;
23542    t.Q = 722;
23543    t.R = 667;
23544    t.S = 556;
23545    t.T = 611;
23546    t.U = 722;
23547    t.V = 722;
23548    t.W = 944;
23549    t.X = 722;
23550    t.Y = 722;
23551    t.Z = 611;
23552    t.bracketleft = 333;
23553    t.backslash = 278;
23554    t.bracketright = 333;
23555    t.asciicircum = 469;
23556    t.underscore = 500;
23557    t.quoteleft = 333;
23558    t.a = 444;
23559    t.b = 500;
23560    t.c = 444;
23561    t.d = 500;
23562    t.e = 444;
23563    t.f = 333;
23564    t.g = 500;
23565    t.h = 500;
23566    t.i = 278;
23567    t.j = 278;
23568    t.k = 500;
23569    t.l = 278;
23570    t.m = 778;
23571    t.n = 500;
23572    t.o = 500;
23573    t.p = 500;
23574    t.q = 500;
23575    t.r = 333;
23576    t.s = 389;
23577    t.t = 278;
23578    t.u = 500;
23579    t.v = 500;
23580    t.w = 722;
23581    t.x = 500;
23582    t.y = 500;
23583    t.z = 444;
23584    t.braceleft = 480;
23585    t.bar = 200;
23586    t.braceright = 480;
23587    t.asciitilde = 541;
23588    t.exclamdown = 333;
23589    t.cent = 500;
23590    t.sterling = 500;
23591    t.fraction = 167;
23592    t.yen = 500;
23593    t.florin = 500;
23594    t.section = 500;
23595    t.currency = 500;
23596    t.quotesingle = 180;
23597    t.quotedblleft = 444;
23598    t.guillemotleft = 500;
23599    t.guilsinglleft = 333;
23600    t.guilsinglright = 333;
23601    t.fi = 556;
23602    t.fl = 556;
23603    t.endash = 500;
23604    t.dagger = 500;
23605    t.daggerdbl = 500;
23606    t.periodcentered = 250;
23607    t.paragraph = 453;
23608    t.bullet = 350;
23609    t.quotesinglbase = 333;
23610    t.quotedblbase = 444;
23611    t.quotedblright = 444;
23612    t.guillemotright = 500;
23613    t.ellipsis = 1000;
23614    t.perthousand = 1000;
23615    t.questiondown = 444;
23616    t.grave = 333;
23617    t.acute = 333;
23618    t.circumflex = 333;
23619    t.tilde = 333;
23620    t.macron = 333;
23621    t.breve = 333;
23622    t.dotaccent = 333;
23623    t.dieresis = 333;
23624    t.ring = 333;
23625    t.cedilla = 333;
23626    t.hungarumlaut = 333;
23627    t.ogonek = 333;
23628    t.caron = 333;
23629    t.emdash = 1000;
23630    t.AE = 889;
23631    t.ordfeminine = 276;
23632    t.Lslash = 611;
23633    t.Oslash = 722;
23634    t.OE = 889;
23635    t.ordmasculine = 310;
23636    t.ae = 667;
23637    t.dotlessi = 278;
23638    t.lslash = 278;
23639    t.oslash = 500;
23640    t.oe = 722;
23641    t.germandbls = 500;
23642    t.Idieresis = 333;
23643    t.eacute = 444;
23644    t.abreve = 444;
23645    t.uhungarumlaut = 500;
23646    t.ecaron = 444;
23647    t.Ydieresis = 722;
23648    t.divide = 564;
23649    t.Yacute = 722;
23650    t.Acircumflex = 722;
23651    t.aacute = 444;
23652    t.Ucircumflex = 722;
23653    t.yacute = 500;
23654    t.scommaaccent = 389;
23655    t.ecircumflex = 444;
23656    t.Uring = 722;
23657    t.Udieresis = 722;
23658    t.aogonek = 444;
23659    t.Uacute = 722;
23660    t.uogonek = 500;
23661    t.Edieresis = 611;
23662    t.Dcroat = 722;
23663    t.commaaccent = 250;
23664    t.copyright = 760;
23665    t.Emacron = 611;
23666    t.ccaron = 444;
23667    t.aring = 444;
23668    t.Ncommaaccent = 722;
23669    t.lacute = 278;
23670    t.agrave = 444;
23671    t.Tcommaaccent = 611;
23672    t.Cacute = 667;
23673    t.atilde = 444;
23674    t.Edotaccent = 611;
23675    t.scaron = 389;
23676    t.scedilla = 389;
23677    t.iacute = 278;
23678    t.lozenge = 471;
23679    t.Rcaron = 667;
23680    t.Gcommaaccent = 722;
23681    t.ucircumflex = 500;
23682    t.acircumflex = 444;
23683    t.Amacron = 722;
23684    t.rcaron = 333;
23685    t.ccedilla = 444;
23686    t.Zdotaccent = 611;
23687    t.Thorn = 556;
23688    t.Omacron = 722;
23689    t.Racute = 667;
23690    t.Sacute = 556;
23691    t.dcaron = 588;
23692    t.Umacron = 722;
23693    t.uring = 500;
23694    t.threesuperior = 300;
23695    t.Ograve = 722;
23696    t.Agrave = 722;
23697    t.Abreve = 722;
23698    t.multiply = 564;
23699    t.uacute = 500;
23700    t.Tcaron = 611;
23701    t.partialdiff = 476;
23702    t.ydieresis = 500;
23703    t.Nacute = 722;
23704    t.icircumflex = 278;
23705    t.Ecircumflex = 611;
23706    t.adieresis = 444;
23707    t.edieresis = 444;
23708    t.cacute = 444;
23709    t.nacute = 500;
23710    t.umacron = 500;
23711    t.Ncaron = 722;
23712    t.Iacute = 333;
23713    t.plusminus = 564;
23714    t.brokenbar = 200;
23715    t.registered = 760;
23716    t.Gbreve = 722;
23717    t.Idotaccent = 333;
23718    t.summation = 600;
23719    t.Egrave = 611;
23720    t.racute = 333;
23721    t.omacron = 500;
23722    t.Zacute = 611;
23723    t.Zcaron = 611;
23724    t.greaterequal = 549;
23725    t.Eth = 722;
23726    t.Ccedilla = 667;
23727    t.lcommaaccent = 278;
23728    t.tcaron = 326;
23729    t.eogonek = 444;
23730    t.Uogonek = 722;
23731    t.Aacute = 722;
23732    t.Adieresis = 722;
23733    t.egrave = 444;
23734    t.zacute = 444;
23735    t.iogonek = 278;
23736    t.Oacute = 722;
23737    t.oacute = 500;
23738    t.amacron = 444;
23739    t.sacute = 389;
23740    t.idieresis = 278;
23741    t.Ocircumflex = 722;
23742    t.Ugrave = 722;
23743    t.Delta = 612;
23744    t.thorn = 500;
23745    t.twosuperior = 300;
23746    t.Odieresis = 722;
23747    t.mu = 500;
23748    t.igrave = 278;
23749    t.ohungarumlaut = 500;
23750    t.Eogonek = 611;
23751    t.dcroat = 500;
23752    t.threequarters = 750;
23753    t.Scedilla = 556;
23754    t.lcaron = 344;
23755    t.Kcommaaccent = 722;
23756    t.Lacute = 611;
23757    t.trademark = 980;
23758    t.edotaccent = 444;
23759    t.Igrave = 333;
23760    t.Imacron = 333;
23761    t.Lcaron = 611;
23762    t.onehalf = 750;
23763    t.lessequal = 549;
23764    t.ocircumflex = 500;
23765    t.ntilde = 500;
23766    t.Uhungarumlaut = 722;
23767    t.Eacute = 611;
23768    t.emacron = 444;
23769    t.gbreve = 500;
23770    t.onequarter = 750;
23771    t.Scaron = 556;
23772    t.Scommaaccent = 556;
23773    t.Ohungarumlaut = 722;
23774    t.degree = 400;
23775    t.ograve = 500;
23776    t.Ccaron = 667;
23777    t.ugrave = 500;
23778    t.radical = 453;
23779    t.Dcaron = 722;
23780    t.rcommaaccent = 333;
23781    t.Ntilde = 722;
23782    t.otilde = 500;
23783    t.Rcommaaccent = 667;
23784    t.Lcommaaccent = 611;
23785    t.Atilde = 722;
23786    t.Aogonek = 722;
23787    t.Aring = 722;
23788    t.Otilde = 722;
23789    t.zdotaccent = 444;
23790    t.Ecaron = 611;
23791    t.Iogonek = 333;
23792    t.kcommaaccent = 500;
23793    t.minus = 564;
23794    t.Icircumflex = 333;
23795    t.ncaron = 500;
23796    t.tcommaaccent = 278;
23797    t.logicalnot = 564;
23798    t.odieresis = 500;
23799    t.udieresis = 500;
23800    t.notequal = 549;
23801    t.gcommaaccent = 500;
23802    t.eth = 500;
23803    t.zcaron = 444;
23804    t.ncommaaccent = 500;
23805    t.onesuperior = 300;
23806    t.imacron = 278;
23807    t.Euro = 500;
23808  });
23809  t["Times-Bold"] = getLookupTableFactory(function (t) {
23810    t.space = 250;
23811    t.exclam = 333;
23812    t.quotedbl = 555;
23813    t.numbersign = 500;
23814    t.dollar = 500;
23815    t.percent = 1000;
23816    t.ampersand = 833;
23817    t.quoteright = 333;
23818    t.parenleft = 333;
23819    t.parenright = 333;
23820    t.asterisk = 500;
23821    t.plus = 570;
23822    t.comma = 250;
23823    t.hyphen = 333;
23824    t.period = 250;
23825    t.slash = 278;
23826    t.zero = 500;
23827    t.one = 500;
23828    t.two = 500;
23829    t.three = 500;
23830    t.four = 500;
23831    t.five = 500;
23832    t.six = 500;
23833    t.seven = 500;
23834    t.eight = 500;
23835    t.nine = 500;
23836    t.colon = 333;
23837    t.semicolon = 333;
23838    t.less = 570;
23839    t.equal = 570;
23840    t.greater = 570;
23841    t.question = 500;
23842    t.at = 930;
23843    t.A = 722;
23844    t.B = 667;
23845    t.C = 722;
23846    t.D = 722;
23847    t.E = 667;
23848    t.F = 611;
23849    t.G = 778;
23850    t.H = 778;
23851    t.I = 389;
23852    t.J = 500;
23853    t.K = 778;
23854    t.L = 667;
23855    t.M = 944;
23856    t.N = 722;
23857    t.O = 778;
23858    t.P = 611;
23859    t.Q = 778;
23860    t.R = 722;
23861    t.S = 556;
23862    t.T = 667;
23863    t.U = 722;
23864    t.V = 722;
23865    t.W = 1000;
23866    t.X = 722;
23867    t.Y = 722;
23868    t.Z = 667;
23869    t.bracketleft = 333;
23870    t.backslash = 278;
23871    t.bracketright = 333;
23872    t.asciicircum = 581;
23873    t.underscore = 500;
23874    t.quoteleft = 333;
23875    t.a = 500;
23876    t.b = 556;
23877    t.c = 444;
23878    t.d = 556;
23879    t.e = 444;
23880    t.f = 333;
23881    t.g = 500;
23882    t.h = 556;
23883    t.i = 278;
23884    t.j = 333;
23885    t.k = 556;
23886    t.l = 278;
23887    t.m = 833;
23888    t.n = 556;
23889    t.o = 500;
23890    t.p = 556;
23891    t.q = 556;
23892    t.r = 444;
23893    t.s = 389;
23894    t.t = 333;
23895    t.u = 556;
23896    t.v = 500;
23897    t.w = 722;
23898    t.x = 500;
23899    t.y = 500;
23900    t.z = 444;
23901    t.braceleft = 394;
23902    t.bar = 220;
23903    t.braceright = 394;
23904    t.asciitilde = 520;
23905    t.exclamdown = 333;
23906    t.cent = 500;
23907    t.sterling = 500;
23908    t.fraction = 167;
23909    t.yen = 500;
23910    t.florin = 500;
23911    t.section = 500;
23912    t.currency = 500;
23913    t.quotesingle = 278;
23914    t.quotedblleft = 500;
23915    t.guillemotleft = 500;
23916    t.guilsinglleft = 333;
23917    t.guilsinglright = 333;
23918    t.fi = 556;
23919    t.fl = 556;
23920    t.endash = 500;
23921    t.dagger = 500;
23922    t.daggerdbl = 500;
23923    t.periodcentered = 250;
23924    t.paragraph = 540;
23925    t.bullet = 350;
23926    t.quotesinglbase = 333;
23927    t.quotedblbase = 500;
23928    t.quotedblright = 500;
23929    t.guillemotright = 500;
23930    t.ellipsis = 1000;
23931    t.perthousand = 1000;
23932    t.questiondown = 500;
23933    t.grave = 333;
23934    t.acute = 333;
23935    t.circumflex = 333;
23936    t.tilde = 333;
23937    t.macron = 333;
23938    t.breve = 333;
23939    t.dotaccent = 333;
23940    t.dieresis = 333;
23941    t.ring = 333;
23942    t.cedilla = 333;
23943    t.hungarumlaut = 333;
23944    t.ogonek = 333;
23945    t.caron = 333;
23946    t.emdash = 1000;
23947    t.AE = 1000;
23948    t.ordfeminine = 300;
23949    t.Lslash = 667;
23950    t.Oslash = 778;
23951    t.OE = 1000;
23952    t.ordmasculine = 330;
23953    t.ae = 722;
23954    t.dotlessi = 278;
23955    t.lslash = 278;
23956    t.oslash = 500;
23957    t.oe = 722;
23958    t.germandbls = 556;
23959    t.Idieresis = 389;
23960    t.eacute = 444;
23961    t.abreve = 500;
23962    t.uhungarumlaut = 556;
23963    t.ecaron = 444;
23964    t.Ydieresis = 722;
23965    t.divide = 570;
23966    t.Yacute = 722;
23967    t.Acircumflex = 722;
23968    t.aacute = 500;
23969    t.Ucircumflex = 722;
23970    t.yacute = 500;
23971    t.scommaaccent = 389;
23972    t.ecircumflex = 444;
23973    t.Uring = 722;
23974    t.Udieresis = 722;
23975    t.aogonek = 500;
23976    t.Uacute = 722;
23977    t.uogonek = 556;
23978    t.Edieresis = 667;
23979    t.Dcroat = 722;
23980    t.commaaccent = 250;
23981    t.copyright = 747;
23982    t.Emacron = 667;
23983    t.ccaron = 444;
23984    t.aring = 500;
23985    t.Ncommaaccent = 722;
23986    t.lacute = 278;
23987    t.agrave = 500;
23988    t.Tcommaaccent = 667;
23989    t.Cacute = 722;
23990    t.atilde = 500;
23991    t.Edotaccent = 667;
23992    t.scaron = 389;
23993    t.scedilla = 389;
23994    t.iacute = 278;
23995    t.lozenge = 494;
23996    t.Rcaron = 722;
23997    t.Gcommaaccent = 778;
23998    t.ucircumflex = 556;
23999    t.acircumflex = 500;
24000    t.Amacron = 722;
24001    t.rcaron = 444;
24002    t.ccedilla = 444;
24003    t.Zdotaccent = 667;
24004    t.Thorn = 611;
24005    t.Omacron = 778;
24006    t.Racute = 722;
24007    t.Sacute = 556;
24008    t.dcaron = 672;
24009    t.Umacron = 722;
24010    t.uring = 556;
24011    t.threesuperior = 300;
24012    t.Ograve = 778;
24013    t.Agrave = 722;
24014    t.Abreve = 722;
24015    t.multiply = 570;
24016    t.uacute = 556;
24017    t.Tcaron = 667;
24018    t.partialdiff = 494;
24019    t.ydieresis = 500;
24020    t.Nacute = 722;
24021    t.icircumflex = 278;
24022    t.Ecircumflex = 667;
24023    t.adieresis = 500;
24024    t.edieresis = 444;
24025    t.cacute = 444;
24026    t.nacute = 556;
24027    t.umacron = 556;
24028    t.Ncaron = 722;
24029    t.Iacute = 389;
24030    t.plusminus = 570;
24031    t.brokenbar = 220;
24032    t.registered = 747;
24033    t.Gbreve = 778;
24034    t.Idotaccent = 389;
24035    t.summation = 600;
24036    t.Egrave = 667;
24037    t.racute = 444;
24038    t.omacron = 500;
24039    t.Zacute = 667;
24040    t.Zcaron = 667;
24041    t.greaterequal = 549;
24042    t.Eth = 722;
24043    t.Ccedilla = 722;
24044    t.lcommaaccent = 278;
24045    t.tcaron = 416;
24046    t.eogonek = 444;
24047    t.Uogonek = 722;
24048    t.Aacute = 722;
24049    t.Adieresis = 722;
24050    t.egrave = 444;
24051    t.zacute = 444;
24052    t.iogonek = 278;
24053    t.Oacute = 778;
24054    t.oacute = 500;
24055    t.amacron = 500;
24056    t.sacute = 389;
24057    t.idieresis = 278;
24058    t.Ocircumflex = 778;
24059    t.Ugrave = 722;
24060    t.Delta = 612;
24061    t.thorn = 556;
24062    t.twosuperior = 300;
24063    t.Odieresis = 778;
24064    t.mu = 556;
24065    t.igrave = 278;
24066    t.ohungarumlaut = 500;
24067    t.Eogonek = 667;
24068    t.dcroat = 556;
24069    t.threequarters = 750;
24070    t.Scedilla = 556;
24071    t.lcaron = 394;
24072    t.Kcommaaccent = 778;
24073    t.Lacute = 667;
24074    t.trademark = 1000;
24075    t.edotaccent = 444;
24076    t.Igrave = 389;
24077    t.Imacron = 389;
24078    t.Lcaron = 667;
24079    t.onehalf = 750;
24080    t.lessequal = 549;
24081    t.ocircumflex = 500;
24082    t.ntilde = 556;
24083    t.Uhungarumlaut = 722;
24084    t.Eacute = 667;
24085    t.emacron = 444;
24086    t.gbreve = 500;
24087    t.onequarter = 750;
24088    t.Scaron = 556;
24089    t.Scommaaccent = 556;
24090    t.Ohungarumlaut = 778;
24091    t.degree = 400;
24092    t.ograve = 500;
24093    t.Ccaron = 722;
24094    t.ugrave = 556;
24095    t.radical = 549;
24096    t.Dcaron = 722;
24097    t.rcommaaccent = 444;
24098    t.Ntilde = 722;
24099    t.otilde = 500;
24100    t.Rcommaaccent = 722;
24101    t.Lcommaaccent = 667;
24102    t.Atilde = 722;
24103    t.Aogonek = 722;
24104    t.Aring = 722;
24105    t.Otilde = 778;
24106    t.zdotaccent = 444;
24107    t.Ecaron = 667;
24108    t.Iogonek = 389;
24109    t.kcommaaccent = 556;
24110    t.minus = 570;
24111    t.Icircumflex = 389;
24112    t.ncaron = 556;
24113    t.tcommaaccent = 333;
24114    t.logicalnot = 570;
24115    t.odieresis = 500;
24116    t.udieresis = 556;
24117    t.notequal = 549;
24118    t.gcommaaccent = 500;
24119    t.eth = 500;
24120    t.zcaron = 444;
24121    t.ncommaaccent = 556;
24122    t.onesuperior = 300;
24123    t.imacron = 278;
24124    t.Euro = 500;
24125  });
24126  t["Times-BoldItalic"] = getLookupTableFactory(function (t) {
24127    t.space = 250;
24128    t.exclam = 389;
24129    t.quotedbl = 555;
24130    t.numbersign = 500;
24131    t.dollar = 500;
24132    t.percent = 833;
24133    t.ampersand = 778;
24134    t.quoteright = 333;
24135    t.parenleft = 333;
24136    t.parenright = 333;
24137    t.asterisk = 500;
24138    t.plus = 570;
24139    t.comma = 250;
24140    t.hyphen = 333;
24141    t.period = 250;
24142    t.slash = 278;
24143    t.zero = 500;
24144    t.one = 500;
24145    t.two = 500;
24146    t.three = 500;
24147    t.four = 500;
24148    t.five = 500;
24149    t.six = 500;
24150    t.seven = 500;
24151    t.eight = 500;
24152    t.nine = 500;
24153    t.colon = 333;
24154    t.semicolon = 333;
24155    t.less = 570;
24156    t.equal = 570;
24157    t.greater = 570;
24158    t.question = 500;
24159    t.at = 832;
24160    t.A = 667;
24161    t.B = 667;
24162    t.C = 667;
24163    t.D = 722;
24164    t.E = 667;
24165    t.F = 667;
24166    t.G = 722;
24167    t.H = 778;
24168    t.I = 389;
24169    t.J = 500;
24170    t.K = 667;
24171    t.L = 611;
24172    t.M = 889;
24173    t.N = 722;
24174    t.O = 722;
24175    t.P = 611;
24176    t.Q = 722;
24177    t.R = 667;
24178    t.S = 556;
24179    t.T = 611;
24180    t.U = 722;
24181    t.V = 667;
24182    t.W = 889;
24183    t.X = 667;
24184    t.Y = 611;
24185    t.Z = 611;
24186    t.bracketleft = 333;
24187    t.backslash = 278;
24188    t.bracketright = 333;
24189    t.asciicircum = 570;
24190    t.underscore = 500;
24191    t.quoteleft = 333;
24192    t.a = 500;
24193    t.b = 500;
24194    t.c = 444;
24195    t.d = 500;
24196    t.e = 444;
24197    t.f = 333;
24198    t.g = 500;
24199    t.h = 556;
24200    t.i = 278;
24201    t.j = 278;
24202    t.k = 500;
24203    t.l = 278;
24204    t.m = 778;
24205    t.n = 556;
24206    t.o = 500;
24207    t.p = 500;
24208    t.q = 500;
24209    t.r = 389;
24210    t.s = 389;
24211    t.t = 278;
24212    t.u = 556;
24213    t.v = 444;
24214    t.w = 667;
24215    t.x = 500;
24216    t.y = 444;
24217    t.z = 389;
24218    t.braceleft = 348;
24219    t.bar = 220;
24220    t.braceright = 348;
24221    t.asciitilde = 570;
24222    t.exclamdown = 389;
24223    t.cent = 500;
24224    t.sterling = 500;
24225    t.fraction = 167;
24226    t.yen = 500;
24227    t.florin = 500;
24228    t.section = 500;
24229    t.currency = 500;
24230    t.quotesingle = 278;
24231    t.quotedblleft = 500;
24232    t.guillemotleft = 500;
24233    t.guilsinglleft = 333;
24234    t.guilsinglright = 333;
24235    t.fi = 556;
24236    t.fl = 556;
24237    t.endash = 500;
24238    t.dagger = 500;
24239    t.daggerdbl = 500;
24240    t.periodcentered = 250;
24241    t.paragraph = 500;
24242    t.bullet = 350;
24243    t.quotesinglbase = 333;
24244    t.quotedblbase = 500;
24245    t.quotedblright = 500;
24246    t.guillemotright = 500;
24247    t.ellipsis = 1000;
24248    t.perthousand = 1000;
24249    t.questiondown = 500;
24250    t.grave = 333;
24251    t.acute = 333;
24252    t.circumflex = 333;
24253    t.tilde = 333;
24254    t.macron = 333;
24255    t.breve = 333;
24256    t.dotaccent = 333;
24257    t.dieresis = 333;
24258    t.ring = 333;
24259    t.cedilla = 333;
24260    t.hungarumlaut = 333;
24261    t.ogonek = 333;
24262    t.caron = 333;
24263    t.emdash = 1000;
24264    t.AE = 944;
24265    t.ordfeminine = 266;
24266    t.Lslash = 611;
24267    t.Oslash = 722;
24268    t.OE = 944;
24269    t.ordmasculine = 300;
24270    t.ae = 722;
24271    t.dotlessi = 278;
24272    t.lslash = 278;
24273    t.oslash = 500;
24274    t.oe = 722;
24275    t.germandbls = 500;
24276    t.Idieresis = 389;
24277    t.eacute = 444;
24278    t.abreve = 500;
24279    t.uhungarumlaut = 556;
24280    t.ecaron = 444;
24281    t.Ydieresis = 611;
24282    t.divide = 570;
24283    t.Yacute = 611;
24284    t.Acircumflex = 667;
24285    t.aacute = 500;
24286    t.Ucircumflex = 722;
24287    t.yacute = 444;
24288    t.scommaaccent = 389;
24289    t.ecircumflex = 444;
24290    t.Uring = 722;
24291    t.Udieresis = 722;
24292    t.aogonek = 500;
24293    t.Uacute = 722;
24294    t.uogonek = 556;
24295    t.Edieresis = 667;
24296    t.Dcroat = 722;
24297    t.commaaccent = 250;
24298    t.copyright = 747;
24299    t.Emacron = 667;
24300    t.ccaron = 444;
24301    t.aring = 500;
24302    t.Ncommaaccent = 722;
24303    t.lacute = 278;
24304    t.agrave = 500;
24305    t.Tcommaaccent = 611;
24306    t.Cacute = 667;
24307    t.atilde = 500;
24308    t.Edotaccent = 667;
24309    t.scaron = 389;
24310    t.scedilla = 389;
24311    t.iacute = 278;
24312    t.lozenge = 494;
24313    t.Rcaron = 667;
24314    t.Gcommaaccent = 722;
24315    t.ucircumflex = 556;
24316    t.acircumflex = 500;
24317    t.Amacron = 667;
24318    t.rcaron = 389;
24319    t.ccedilla = 444;
24320    t.Zdotaccent = 611;
24321    t.Thorn = 611;
24322    t.Omacron = 722;
24323    t.Racute = 667;
24324    t.Sacute = 556;
24325    t.dcaron = 608;
24326    t.Umacron = 722;
24327    t.uring = 556;
24328    t.threesuperior = 300;
24329    t.Ograve = 722;
24330    t.Agrave = 667;
24331    t.Abreve = 667;
24332    t.multiply = 570;
24333    t.uacute = 556;
24334    t.Tcaron = 611;
24335    t.partialdiff = 494;
24336    t.ydieresis = 444;
24337    t.Nacute = 722;
24338    t.icircumflex = 278;
24339    t.Ecircumflex = 667;
24340    t.adieresis = 500;
24341    t.edieresis = 444;
24342    t.cacute = 444;
24343    t.nacute = 556;
24344    t.umacron = 556;
24345    t.Ncaron = 722;
24346    t.Iacute = 389;
24347    t.plusminus = 570;
24348    t.brokenbar = 220;
24349    t.registered = 747;
24350    t.Gbreve = 722;
24351    t.Idotaccent = 389;
24352    t.summation = 600;
24353    t.Egrave = 667;
24354    t.racute = 389;
24355    t.omacron = 500;
24356    t.Zacute = 611;
24357    t.Zcaron = 611;
24358    t.greaterequal = 549;
24359    t.Eth = 722;
24360    t.Ccedilla = 667;
24361    t.lcommaaccent = 278;
24362    t.tcaron = 366;
24363    t.eogonek = 444;
24364    t.Uogonek = 722;
24365    t.Aacute = 667;
24366    t.Adieresis = 667;
24367    t.egrave = 444;
24368    t.zacute = 389;
24369    t.iogonek = 278;
24370    t.Oacute = 722;
24371    t.oacute = 500;
24372    t.amacron = 500;
24373    t.sacute = 389;
24374    t.idieresis = 278;
24375    t.Ocircumflex = 722;
24376    t.Ugrave = 722;
24377    t.Delta = 612;
24378    t.thorn = 500;
24379    t.twosuperior = 300;
24380    t.Odieresis = 722;
24381    t.mu = 576;
24382    t.igrave = 278;
24383    t.ohungarumlaut = 500;
24384    t.Eogonek = 667;
24385    t.dcroat = 500;
24386    t.threequarters = 750;
24387    t.Scedilla = 556;
24388    t.lcaron = 382;
24389    t.Kcommaaccent = 667;
24390    t.Lacute = 611;
24391    t.trademark = 1000;
24392    t.edotaccent = 444;
24393    t.Igrave = 389;
24394    t.Imacron = 389;
24395    t.Lcaron = 611;
24396    t.onehalf = 750;
24397    t.lessequal = 549;
24398    t.ocircumflex = 500;
24399    t.ntilde = 556;
24400    t.Uhungarumlaut = 722;
24401    t.Eacute = 667;
24402    t.emacron = 444;
24403    t.gbreve = 500;
24404    t.onequarter = 750;
24405    t.Scaron = 556;
24406    t.Scommaaccent = 556;
24407    t.Ohungarumlaut = 722;
24408    t.degree = 400;
24409    t.ograve = 500;
24410    t.Ccaron = 667;
24411    t.ugrave = 556;
24412    t.radical = 549;
24413    t.Dcaron = 722;
24414    t.rcommaaccent = 389;
24415    t.Ntilde = 722;
24416    t.otilde = 500;
24417    t.Rcommaaccent = 667;
24418    t.Lcommaaccent = 611;
24419    t.Atilde = 667;
24420    t.Aogonek = 667;
24421    t.Aring = 667;
24422    t.Otilde = 722;
24423    t.zdotaccent = 389;
24424    t.Ecaron = 667;
24425    t.Iogonek = 389;
24426    t.kcommaaccent = 500;
24427    t.minus = 606;
24428    t.Icircumflex = 389;
24429    t.ncaron = 556;
24430    t.tcommaaccent = 278;
24431    t.logicalnot = 606;
24432    t.odieresis = 500;
24433    t.udieresis = 556;
24434    t.notequal = 549;
24435    t.gcommaaccent = 500;
24436    t.eth = 500;
24437    t.zcaron = 389;
24438    t.ncommaaccent = 556;
24439    t.onesuperior = 300;
24440    t.imacron = 278;
24441    t.Euro = 500;
24442  });
24443  t["Times-Italic"] = getLookupTableFactory(function (t) {
24444    t.space = 250;
24445    t.exclam = 333;
24446    t.quotedbl = 420;
24447    t.numbersign = 500;
24448    t.dollar = 500;
24449    t.percent = 833;
24450    t.ampersand = 778;
24451    t.quoteright = 333;
24452    t.parenleft = 333;
24453    t.parenright = 333;
24454    t.asterisk = 500;
24455    t.plus = 675;
24456    t.comma = 250;
24457    t.hyphen = 333;
24458    t.period = 250;
24459    t.slash = 278;
24460    t.zero = 500;
24461    t.one = 500;
24462    t.two = 500;
24463    t.three = 500;
24464    t.four = 500;
24465    t.five = 500;
24466    t.six = 500;
24467    t.seven = 500;
24468    t.eight = 500;
24469    t.nine = 500;
24470    t.colon = 333;
24471    t.semicolon = 333;
24472    t.less = 675;
24473    t.equal = 675;
24474    t.greater = 675;
24475    t.question = 500;
24476    t.at = 920;
24477    t.A = 611;
24478    t.B = 611;
24479    t.C = 667;
24480    t.D = 722;
24481    t.E = 611;
24482    t.F = 611;
24483    t.G = 722;
24484    t.H = 722;
24485    t.I = 333;
24486    t.J = 444;
24487    t.K = 667;
24488    t.L = 556;
vendor: 4,861 bytes, lines 24489-24723
24489    t.M = 833;
24490    t.N = 667;
24491    t.O = 722;
24492    t.P = 611;
24493    t.Q = 722;
24494    t.R = 611;
24495    t.S = 500;
24496    t.T = 556;
24497    t.U = 722;
24498    t.V = 611;
24499    t.W = 833;
24500    t.X = 611;
24501    t.Y = 556;
24502    t.Z = 556;
24503    t.bracketleft = 389;
24504    t.backslash = 278;
24505    t.bracketright = 389;
24506    t.asciicircum = 422;
24507    t.underscore = 500;
24508    t.quoteleft = 333;
24509    t.a = 500;
24510    t.b = 500;
24511    t.c = 444;
24512    t.d = 500;
24513    t.e = 444;
24514    t.f = 278;
24515    t.g = 500;
24516    t.h = 500;
24517    t.i = 278;
24518    t.j = 278;
24519    t.k = 444;
24520    t.l = 278;
24521    t.m = 722;
24522    t.n = 500;
24523    t.o = 500;
24524    t.p = 500;
24525    t.q = 500;
24526    t.r = 389;
24527    t.s = 389;
24528    t.t = 278;
24529    t.u = 500;
24530    t.v = 444;
24531    t.w = 667;
24532    t.x = 444;
24533    t.y = 444;
24534    t.z = 389;
24535    t.braceleft = 400;
24536    t.bar = 275;
24537    t.braceright = 400;
24538    t.asciitilde = 541;
24539    t.exclamdown = 389;
24540    t.cent = 500;
24541    t.sterling = 500;
24542    t.fraction = 167;
24543    t.yen = 500;
24544    t.florin = 500;
24545    t.section = 500;
24546    t.currency = 500;
24547    t.quotesingle = 214;
24548    t.quotedblleft = 556;
24549    t.guillemotleft = 500;
24550    t.guilsinglleft = 333;
24551    t.guilsinglright = 333;
24552    t.fi = 500;
24553    t.fl = 500;
24554    t.endash = 500;
24555    t.dagger = 500;
24556    t.daggerdbl = 500;
24557    t.periodcentered = 250;
24558    t.paragraph = 523;
24559    t.bullet = 350;
24560    t.quotesinglbase = 333;
24561    t.quotedblbase = 556;
24562    t.quotedblright = 556;
24563    t.guillemotright = 500;
24564    t.ellipsis = 889;
24565    t.perthousand = 1000;
24566    t.questiondown = 500;
24567    t.grave = 333;
24568    t.acute = 333;
24569    t.circumflex = 333;
24570    t.tilde = 333;
24571    t.macron = 333;
24572    t.breve = 333;
24573    t.dotaccent = 333;
24574    t.dieresis = 333;
24575    t.ring = 333;
24576    t.cedilla = 333;
24577    t.hungarumlaut = 333;
24578    t.ogonek = 333;
24579    t.caron = 333;
24580    t.emdash = 889;
24581    t.AE = 889;
24582    t.ordfeminine = 276;
24583    t.Lslash = 556;
24584    t.Oslash = 722;
24585    t.OE = 944;
24586    t.ordmasculine = 310;
24587    t.ae = 667;
24588    t.dotlessi = 278;
24589    t.lslash = 278;
24590    t.oslash = 500;
24591    t.oe = 667;
24592    t.germandbls = 500;
24593    t.Idieresis = 333;
24594    t.eacute = 444;
24595    t.abreve = 500;
24596    t.uhungarumlaut = 500;
24597    t.ecaron = 444;
24598    t.Ydieresis = 556;
24599    t.divide = 675;
24600    t.Yacute = 556;
24601    t.Acircumflex = 611;
24602    t.aacute = 500;
24603    t.Ucircumflex = 722;
24604    t.yacute = 444;
24605    t.scommaaccent = 389;
24606    t.ecircumflex = 444;
24607    t.Uring = 722;
24608    t.Udieresis = 722;
24609    t.aogonek = 500;
24610    t.Uacute = 722;
24611    t.uogonek = 500;
24612    t.Edieresis = 611;
24613    t.Dcroat = 722;
24614    t.commaaccent = 250;
24615    t.copyright = 760;
24616    t.Emacron = 611;
24617    t.ccaron = 444;
24618    t.aring = 500;
24619    t.Ncommaaccent = 667;
24620    t.lacute = 278;
24621    t.agrave = 500;
24622    t.Tcommaaccent = 556;
24623    t.Cacute = 667;
24624    t.atilde = 500;
24625    t.Edotaccent = 611;
24626    t.scaron = 389;
24627    t.scedilla = 389;
24628    t.iacute = 278;
24629    t.lozenge = 471;
24630    t.Rcaron = 611;
24631    t.Gcommaaccent = 722;
24632    t.ucircumflex = 500;
24633    t.acircumflex = 500;
24634    t.Amacron = 611;
24635    t.rcaron = 389;
24636    t.ccedilla = 444;
24637    t.Zdotaccent = 556;
24638    t.Thorn = 611;
24639    t.Omacron = 722;
24640    t.Racute = 611;
24641    t.Sacute = 500;
24642    t.dcaron = 544;
24643    t.Umacron = 722;
24644    t.uring = 500;
24645    t.threesuperior = 300;
24646    t.Ograve = 722;
24647    t.Agrave = 611;
24648    t.Abreve = 611;
24649    t.multiply = 675;
24650    t.uacute = 500;
24651    t.Tcaron = 556;
24652    t.partialdiff = 476;
24653    t.ydieresis = 444;
24654    t.Nacute = 667;
24655    t.icircumflex = 278;
24656    t.Ecircumflex = 611;
24657    t.adieresis = 500;
24658    t.edieresis = 444;
24659    t.cacute = 444;
24660    t.nacute = 500;
24661    t.umacron = 500;
24662    t.Ncaron = 667;
24663    t.Iacute = 333;
24664    t.plusminus = 675;
24665    t.brokenbar = 275;
24666    t.registered = 760;
24667    t.Gbreve = 722;
24668    t.Idotaccent = 333;
24669    t.summation = 600;
24670    t.Egrave = 611;
24671    t.racute = 389;
24672    t.omacron = 500;
24673    t.Zacute = 556;
24674    t.Zcaron = 556;
24675    t.greaterequal = 549;
24676    t.Eth = 722;
24677    t.Ccedilla = 667;
24678    t.lcommaaccent = 278;
24679    t.tcaron = 300;
24680    t.eogonek = 444;
24681    t.Uogonek = 722;
24682    t.Aacute = 611;
24683    t.Adieresis = 611;
24684    t.egrave = 444;
24685    t.zacute = 389;
24686    t.iogonek = 278;
24687    t.Oacute = 722;
24688    t.oacute = 500;
24689    t.amacron = 500;
24690    t.sacute = 389;
24691    t.idieresis = 278;
24692    t.Ocircumflex = 722;
24693    t.Ugrave = 722;
24694    t.Delta = 612;
24695    t.thorn = 500;
24696    t.twosuperior = 300;
24697    t.Odieresis = 722;
24698    t.mu = 500;
24699    t.igrave = 278;
24700    t.ohungarumlaut = 500;
24701    t.Eogonek = 611;
24702    t.dcroat = 500;
24703    t.threequarters = 750;
24704    t.Scedilla = 500;
24705    t.lcaron = 300;
24706    t.Kcommaaccent = 667;
24707    t.Lacute = 556;
24708    t.trademark = 980;
24709    t.edotaccent = 444;
24710    t.Igrave = 333;
24711    t.Imacron = 333;
24712    t.Lcaron = 611;
24713    t.onehalf = 750;
24714    t.lessequal = 549;
24715    t.ocircumflex = 500;
24716    t.ntilde = 500;
24717    t.Uhungarumlaut = 722;
24718    t.Eacute = 611;
24719    t.emacron = 444;
24720    t.gbreve = 500;
24721    t.onequarter = 750;
24722    t.Scaron = 500;
24723    t.Scommaaccent = 500;
vendor: 9,095 bytes, lines 24724-25169
24724    t.Ohungarumlaut = 722;
24725    t.degree = 400;
24726    t.ograve = 500;
24727    t.Ccaron = 667;
24728    t.ugrave = 500;
24729    t.radical = 453;
24730    t.Dcaron = 722;
24731    t.rcommaaccent = 389;
24732    t.Ntilde = 667;
24733    t.otilde = 500;
24734    t.Rcommaaccent = 611;
24735    t.Lcommaaccent = 556;
24736    t.Atilde = 611;
24737    t.Aogonek = 611;
24738    t.Aring = 611;
24739    t.Otilde = 722;
24740    t.zdotaccent = 389;
24741    t.Ecaron = 611;
24742    t.Iogonek = 333;
24743    t.kcommaaccent = 444;
24744    t.minus = 675;
24745    t.Icircumflex = 333;
24746    t.ncaron = 500;
24747    t.tcommaaccent = 278;
24748    t.logicalnot = 675;
24749    t.odieresis = 500;
24750    t.udieresis = 500;
24751    t.notequal = 549;
24752    t.gcommaaccent = 500;
24753    t.eth = 500;
24754    t.zcaron = 389;
24755    t.ncommaaccent = 500;
24756    t.onesuperior = 300;
24757    t.imacron = 278;
24758    t.Euro = 500;
24759  });
24760  t.ZapfDingbats = getLookupTableFactory(function (t) {
24761    t.space = 278;
24762    t.a1 = 974;
24763    t.a2 = 961;
24764    t.a202 = 974;
24765    t.a3 = 980;
24766    t.a4 = 719;
24767    t.a5 = 789;
24768    t.a119 = 790;
24769    t.a118 = 791;
24770    t.a117 = 690;
24771    t.a11 = 960;
24772    t.a12 = 939;
24773    t.a13 = 549;
24774    t.a14 = 855;
24775    t.a15 = 911;
24776    t.a16 = 933;
24777    t.a105 = 911;
24778    t.a17 = 945;
24779    t.a18 = 974;
24780    t.a19 = 755;
24781    t.a20 = 846;
24782    t.a21 = 762;
24783    t.a22 = 761;
24784    t.a23 = 571;
24785    t.a24 = 677;
24786    t.a25 = 763;
24787    t.a26 = 760;
24788    t.a27 = 759;
24789    t.a28 = 754;
24790    t.a6 = 494;
24791    t.a7 = 552;
24792    t.a8 = 537;
24793    t.a9 = 577;
24794    t.a10 = 692;
24795    t.a29 = 786;
24796    t.a30 = 788;
24797    t.a31 = 788;
24798    t.a32 = 790;
24799    t.a33 = 793;
24800    t.a34 = 794;
24801    t.a35 = 816;
24802    t.a36 = 823;
24803    t.a37 = 789;
24804    t.a38 = 841;
24805    t.a39 = 823;
24806    t.a40 = 833;
24807    t.a41 = 816;
24808    t.a42 = 831;
24809    t.a43 = 923;
24810    t.a44 = 744;
24811    t.a45 = 723;
24812    t.a46 = 749;
24813    t.a47 = 790;
24814    t.a48 = 792;
24815    t.a49 = 695;
24816    t.a50 = 776;
24817    t.a51 = 768;
24818    t.a52 = 792;
24819    t.a53 = 759;
24820    t.a54 = 707;
24821    t.a55 = 708;
24822    t.a56 = 682;
24823    t.a57 = 701;
24824    t.a58 = 826;
24825    t.a59 = 815;
24826    t.a60 = 789;
24827    t.a61 = 789;
24828    t.a62 = 707;
24829    t.a63 = 687;
24830    t.a64 = 696;
24831    t.a65 = 689;
24832    t.a66 = 786;
24833    t.a67 = 787;
24834    t.a68 = 713;
24835    t.a69 = 791;
24836    t.a70 = 785;
24837    t.a71 = 791;
24838    t.a72 = 873;
24839    t.a73 = 761;
24840    t.a74 = 762;
24841    t.a203 = 762;
24842    t.a75 = 759;
24843    t.a204 = 759;
24844    t.a76 = 892;
24845    t.a77 = 892;
24846    t.a78 = 788;
24847    t.a79 = 784;
24848    t.a81 = 438;
24849    t.a82 = 138;
24850    t.a83 = 277;
24851    t.a84 = 415;
24852    t.a97 = 392;
24853    t.a98 = 392;
24854    t.a99 = 668;
24855    t.a100 = 668;
24856    t.a89 = 390;
24857    t.a90 = 390;
24858    t.a93 = 317;
24859    t.a94 = 317;
24860    t.a91 = 276;
24861    t.a92 = 276;
24862    t.a205 = 509;
24863    t.a85 = 509;
24864    t.a206 = 410;
24865    t.a86 = 410;
24866    t.a87 = 234;
24867    t.a88 = 234;
24868    t.a95 = 334;
24869    t.a96 = 334;
24870    t.a101 = 732;
24871    t.a102 = 544;
24872    t.a103 = 544;
24873    t.a104 = 910;
24874    t.a106 = 667;
24875    t.a107 = 760;
24876    t.a108 = 760;
24877    t.a112 = 776;
24878    t.a111 = 595;
24879    t.a110 = 694;
24880    t.a109 = 626;
24881    t.a120 = 788;
24882    t.a121 = 788;
24883    t.a122 = 788;
24884    t.a123 = 788;
24885    t.a124 = 788;
24886    t.a125 = 788;
24887    t.a126 = 788;
24888    t.a127 = 788;
24889    t.a128 = 788;
24890    t.a129 = 788;
24891    t.a130 = 788;
24892    t.a131 = 788;
24893    t.a132 = 788;
24894    t.a133 = 788;
24895    t.a134 = 788;
24896    t.a135 = 788;
24897    t.a136 = 788;
24898    t.a137 = 788;
24899    t.a138 = 788;
24900    t.a139 = 788;
24901    t.a140 = 788;
24902    t.a141 = 788;
24903    t.a142 = 788;
24904    t.a143 = 788;
24905    t.a144 = 788;
24906    t.a145 = 788;
24907    t.a146 = 788;
24908    t.a147 = 788;
24909    t.a148 = 788;
24910    t.a149 = 788;
24911    t.a150 = 788;
24912    t.a151 = 788;
24913    t.a152 = 788;
24914    t.a153 = 788;
24915    t.a154 = 788;
24916    t.a155 = 788;
24917    t.a156 = 788;
24918    t.a157 = 788;
24919    t.a158 = 788;
24920    t.a159 = 788;
24921    t.a160 = 894;
24922    t.a161 = 838;
24923    t.a163 = 1016;
24924    t.a164 = 458;
24925    t.a196 = 748;
24926    t.a165 = 924;
24927    t.a192 = 748;
24928    t.a166 = 918;
24929    t.a167 = 927;
24930    t.a168 = 928;
24931    t.a169 = 928;
24932    t.a170 = 834;
24933    t.a171 = 873;
24934    t.a172 = 828;
24935    t.a173 = 924;
24936    t.a162 = 924;
24937    t.a174 = 917;
24938    t.a175 = 930;
24939    t.a176 = 931;
24940    t.a177 = 463;
24941    t.a178 = 883;
24942    t.a179 = 836;
24943    t.a193 = 836;
24944    t.a180 = 867;
24945    t.a199 = 867;
24946    t.a181 = 696;
24947    t.a200 = 696;
24948    t.a182 = 874;
24949    t.a201 = 874;
24950    t.a183 = 760;
24951    t.a184 = 946;
24952    t.a197 = 771;
24953    t.a185 = 865;
24954    t.a194 = 771;
24955    t.a198 = 888;
24956    t.a186 = 967;
24957    t.a195 = 888;
24958    t.a187 = 831;
24959    t.a188 = 873;
24960    t.a189 = 927;
24961    t.a190 = 970;
24962    t.a191 = 918;
24963  });
24964});
24965const getFontBasicMetrics = getLookupTableFactory(function (t) {
24966  t.Courier = {
24967    ascent: 629,
24968    descent: -157,
24969    capHeight: 562,
24970    xHeight: -426
24971  };
24972  t["Courier-Bold"] = {
24973    ascent: 629,
24974    descent: -157,
24975    capHeight: 562,
24976    xHeight: 439
24977  };
24978  t["Courier-Oblique"] = {
24979    ascent: 629,
24980    descent: -157,
24981    capHeight: 562,
24982    xHeight: 426
24983  };
24984  t["Courier-BoldOblique"] = {
24985    ascent: 629,
24986    descent: -157,
24987    capHeight: 562,
24988    xHeight: 426
24989  };
24990  t.Helvetica = {
24991    ascent: 718,
24992    descent: -207,
24993    capHeight: 718,
24994    xHeight: 523
24995  };
24996  t["Helvetica-Bold"] = {
24997    ascent: 718,
24998    descent: -207,
24999    capHeight: 718,
25000    xHeight: 532
25001  };
25002  t["Helvetica-Oblique"] = {
25003    ascent: 718,
25004    descent: -207,
25005    capHeight: 718,
25006    xHeight: 523
25007  };
25008  t["Helvetica-BoldOblique"] = {
25009    ascent: 718,
25010    descent: -207,
25011    capHeight: 718,
25012    xHeight: 532
25013  };
25014  t["Times-Roman"] = {
25015    ascent: 683,
25016    descent: -217,
25017    capHeight: 662,
25018    xHeight: 450
25019  };
25020  t["Times-Bold"] = {
25021    ascent: 683,
25022    descent: -217,
25023    capHeight: 676,
25024    xHeight: 461
25025  };
25026  t["Times-Italic"] = {
25027    ascent: 683,
25028    descent: -217,
25029    capHeight: 653,
25030    xHeight: 441
25031  };
25032  t["Times-BoldItalic"] = {
25033    ascent: 683,
25034    descent: -217,
25035    capHeight: 669,
25036    xHeight: 462
25037  };
25038  t.Symbol = {
25039    ascent: Math.NaN,
25040    descent: Math.NaN,
25041    capHeight: Math.NaN,
25042    xHeight: Math.NaN
25043  };
25044  t.ZapfDingbats = {
25045    ascent: Math.NaN,
25046    descent: Math.NaN,
25047    capHeight: Math.NaN,
25048    xHeight: Math.NaN
25049  };
25050});
25051
25052;// ./src/core/opentype_file_builder.js
25053
25054const OTF_HEADER_SIZE = 12;
25055const OTF_TABLE_ENTRY_SIZE = 16;
25056class OpenTypeFileBuilder {
25057  #tables = new Map();
25058  constructor(sfnt) {
25059    this.sfnt = sfnt;
25060  }
25061  static getSearchParams(entriesCount, entrySize) {
25062    let maxPower2 = 1,
25063      log2 = 0;
25064    while ((maxPower2 ^ entriesCount) > maxPower2) {
25065      maxPower2 <<= 1;
25066      log2++;
25067    }
25068    const searchRange = maxPower2 * entrySize;
25069    return {
25070      range: searchRange,
25071      entry: log2,
25072      rangeShift: entrySize * entriesCount - searchRange
25073    };
25074  }
25075  toArray() {
25076    let sfnt = this.sfnt;
25077    const tables = this.#tables;
25078    const tablesNames = [...tables.keys()].sort();
25079    const numTables = tablesNames.length;
25080    let offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
25081    const tableOffsets = [offset];
25082    for (let i = 0; i < numTables; i++) {
25083      const table = tables.get(tablesNames[i]);
25084      const paddedLength = (table.length + 3 & ~3) >>> 0;
25085      offset += paddedLength;
25086      tableOffsets.push(offset);
25087    }
25088    const file = new Uint8Array(offset),
25089      view = new DataView(file.buffer);
25090    for (let i = 0; i < numTables; i++) {
25091      const table = tables.get(tablesNames[i]);
25092      file.set(table, tableOffsets[i]);
25093    }
25094    if (sfnt === "true") {
25095      sfnt = "\x00\x01\x00\x00";
25096    }
25097    file.set(stringToBytes(sfnt), 0);
25098    view.setInt16(4, numTables);
25099    const searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
25100    view.setInt16(6, searchParams.range);
25101    view.setInt16(8, searchParams.entry);
25102    view.setInt16(10, searchParams.rangeShift);
25103    offset = OTF_HEADER_SIZE;
25104    for (let i = 0; i < numTables; i++) {
25105      const tableName = tablesNames[i];
25106      file.set(stringToBytes(tableName), offset);
25107      let checksum = 0;
25108      for (let j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
25109        const quad = view.getUint32(j);
25110        checksum = checksum + quad >>> 0;
25111      }
25112      view.setInt32(offset + 4, checksum);
25113      view.setInt32(offset + 8, tableOffsets[i]);
25114      view.setInt32(offset + 12, tables.get(tableName).length);
25115      offset += OTF_TABLE_ENTRY_SIZE;
25116    }
25117    this.#tables.clear();
25118    return file;
25119  }
25120  addTable(tag, data) {
25121    if (this.#tables.has(tag)) {
25122      throw new Error(`Table ${tag} already exists`);
25123    }
25124    this.#tables.set(tag, data);
25125  }
25126}
25127
25128;// ./src/core/type1_parser.js
25129
25130
25131
25132
25133const HINTING_ENABLED = false;
25134const COMMAND_MAP = {
25135  hstem: [1],
25136  vstem: [3],
25137  vmoveto: [4],
25138  rlineto: [5],
25139  hlineto: [6],
25140  vlineto: [7],
25141  rrcurveto: [8],
25142  callsubr: [10],
25143  flex: [12, 35],
25144  drop: [12, 18],
25145  endchar: [14],
25146  rmoveto: [21],
25147  hmoveto: [22],
25148  vhcurveto: [30],
25149  hvcurveto: [31]
25150};
25151class Type1CharString {
25152  width = 0;
25153  lsb = 0;
25154  flexing = false;
25155  output = [];
25156  stack = [];
25157  convert(encoded, subrs, seacAnalysisEnabled) {
25158    const count = encoded.length;
25159    let error = false;
25160    let wx, sbx, subrNumber;
25161    for (let i = 0; i < count; i++) {
25162      let value = encoded[i];
25163      if (value < 32) {
25164        if (value === 12) {
25165          value = (value << 8) + encoded[++i];
25166        }
25167        switch (value) {
25168          case 1:
25169            if (
vendor: 3,023 bytes, lines 25169-25268
25169!HINTING_ENABLED) {
25170              this.stack = [];
25171              break;
25172            }
25173            error = this.executeCommand(2, COMMAND_MAP.hstem);
25174            break;
25175          case 3:
25176            if (!HINTING_ENABLED) {
25177              this.stack = [];
25178              break;
25179            }
25180            error = this.executeCommand(2, COMMAND_MAP.vstem);
25181            break;
25182          case 4:
25183            if (this.flexing) {
25184              if (this.stack.length < 1) {
25185                error = true;
25186                break;
25187              }
25188              const dy = this.stack.pop();
25189              this.stack.push(0, dy);
25190              break;
25191            }
25192            error = this.executeCommand(1, COMMAND_MAP.vmoveto);
25193            break;
25194          case 5:
25195            error = this.executeCommand(2, COMMAND_MAP.rlineto);
25196            break;
25197          case 6:
25198            error = this.executeCommand(1, COMMAND_MAP.hlineto);
25199            break;
25200          case 7:
25201            error = this.executeCommand(1, COMMAND_MAP.vlineto);
25202            break;
25203          case 8:
25204            error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
25205            break;
25206          case 9:
25207            this.stack = [];
25208            break;
25209          case 10:
25210            if (this.stack.length < 1) {
25211              error = true;
25212              break;
25213            }
25214            subrNumber = this.stack.pop();
25215            if (!subrs[subrNumber]) {
25216              error = true;
25217              break;
25218            }
25219            error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
25220            break;
25221          case 11:
25222            return error;
25223          case 13:
25224            if (this.stack.length < 2) {
25225              error = true;
25226              break;
25227            }
25228            wx = this.stack.pop();
25229            sbx = this.stack.pop();
25230            this.lsb = sbx;
25231            this.width = wx;
25232            this.stack.push(wx, sbx);
25233            error = this.executeCommand(2, COMMAND_MAP.hmoveto);
25234            break;
25235          case 14:
25236            this.output.push(COMMAND_MAP.endchar[0]);
25237            break;
25238          case 21:
25239            if (this.flexing) {
25240              break;
25241            }
25242            error = this.executeCommand(2, COMMAND_MAP.rmoveto);
25243            break;
25244          case 22:
25245            if (this.flexing) {
25246              this.stack.push(0);
25247              break;
25248            }
25249            error = this.executeCommand(1, COMMAND_MAP.hmoveto);
25250            break;
25251          case 30:
25252            error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
25253            break;
25254          case 31:
25255            error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
25256            break;
25257          case (12 << 8) + 0:
25258            this.stack = [];
25259            break;
25260          case (12 << 8) + 1:
25261            if (!HINTING_ENABLED) {
25262              this.stack = [];
25263              break;
25264            }
25265            error = this.executeCommand(2, COMMAND_MAP.vstem);
25266            break;
25267          case (12 << 8) + 2:
25268            if (!HINTING_ENABLED
vendor: 7,654 bytes, lines 25268-25518
25268) {
25269              this.stack = [];
25270              break;
25271            }
25272            error = this.executeCommand(2, COMMAND_MAP.hstem);
25273            break;
25274          case (12 << 8) + 6:
25275            if (seacAnalysisEnabled) {
25276              const asb = this.stack.at(-5);
25277              this.seac = this.stack.splice(-4, 4);
25278              this.seac[0] += this.lsb - asb;
25279              error = this.executeCommand(0, COMMAND_MAP.endchar);
25280            } else {
25281              error = this.executeCommand(4, COMMAND_MAP.endchar);
25282            }
25283            break;
25284          case (12 << 8) + 7:
25285            if (this.stack.length < 4) {
25286              error = true;
25287              break;
25288            }
25289            this.stack.pop();
25290            wx = this.stack.pop();
25291            const sby = this.stack.pop();
25292            sbx = this.stack.pop();
25293            this.lsb = sbx;
25294            this.width = wx;
25295            this.stack.push(wx, sbx, sby);
25296            error = this.executeCommand(3, COMMAND_MAP.rmoveto);
25297            break;
25298          case (12 << 8) + 12:
25299            if (this.stack.length < 2) {
25300              error = true;
25301              break;
25302            }
25303            const num2 = this.stack.pop();
25304            const num1 = this.stack.pop();
25305            this.stack.push(num1 / num2);
25306            break;
25307          case (12 << 8) + 16:
25308            if (this.stack.length < 2) {
25309              error = true;
25310              break;
25311            }
25312            subrNumber = this.stack.pop();
25313            const numArgs = this.stack.pop();
25314            if (subrNumber === 0 && numArgs === 3) {
25315              const flexArgs = this.stack.splice(-17, 17);
25316              this.stack.push(flexArgs[2] + flexArgs[0], flexArgs[3] + flexArgs[1], flexArgs[4], flexArgs[5], flexArgs[6], flexArgs[7], flexArgs[8], flexArgs[9], flexArgs[10], flexArgs[11], flexArgs[12], flexArgs[13], flexArgs[14]);
25317              error = this.executeCommand(13, COMMAND_MAP.flex, true);
25318              this.flexing = false;
25319              this.stack.push(flexArgs[15], flexArgs[16]);
25320            } else if (subrNumber === 1 && numArgs === 0) {
25321              this.flexing = true;
25322            }
25323            break;
25324          case (12 << 8) + 17:
25325            break;
25326          case (12 << 8) + 33:
25327            this.stack = [];
25328            break;
25329          default:
25330            warn('Unknown type 1 charstring command of "' + value + '"');
25331            break;
25332        }
25333        if (error) {
25334          break;
25335        }
25336        continue;
25337      } else if (value <= 246) {
25338        value -= 139;
25339      } else if (value <= 250) {
25340        value = (value - 247) * 256 + encoded[++i] + 108;
25341      } else if (value <= 254) {
25342        value = -((value - 251) * 256) - encoded[++i] - 108;
25343      } else {
25344        value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
25345      }
25346      this.stack.push(value);
25347    }
25348    return error;
25349  }
25350  executeCommand(howManyArgs, command, keepStack) {
25351    const stackLength = this.stack.length;
25352    if (howManyArgs > stackLength) {
25353      return true;
25354    }
25355    const start = stackLength - howManyArgs;
25356    for (let i = start; i < stackLength; i++) {
25357      let value = this.stack[i];
25358      if (Number.isInteger(value)) {
25359        this.output.push(28, value >> 8 & 0xff, value & 0xff);
25360      } else {
25361        value = 65536 * value | 0;
25362        this.output.push(255, value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
25363      }
25364    }
25365    this.output.push(...command);
25366    if (keepStack) {
25367      this.stack.splice(start, howManyArgs);
25368    } else {
25369      this.stack.length = 0;
25370    }
25371    return false;
25372  }
25373}
25374const EEXEC_ENCRYPT_KEY = 55665;
25375const CHAR_STRS_ENCRYPT_KEY = 4330;
25376function isHexDigit(code) {
25377  return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
25378}
25379function decrypt(data, key, discardNumber) {
25380  if (discardNumber >= data.length) {
25381    return new Uint8Array(0);
25382  }
25383  const c1 = 52845,
25384    c2 = 22719;
25385  let r = key | 0,
25386    i,
25387    j;
25388  for (i = 0; i < discardNumber; i++) {
25389    r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
25390  }
25391  const count = data.length - discardNumber;
25392  const decrypted = new Uint8Array(count);
25393  for (i = discardNumber, j = 0; j < count; i++, j++) {
25394    const value = data[i];
25395    decrypted[j] = value ^ r >> 8;
25396    r = (value + r) * c1 + c2 & (1 << 16) - 1;
25397  }
25398  return decrypted;
25399}
25400function decryptAscii(data, key, discardNumber) {
25401  const c1 = 52845,
25402    c2 = 22719;
25403  let r = key | 0;
25404  const count = data.length,
25405    maybeLength = count >>> 1;
25406  const decrypted = new Uint8Array(maybeLength);
25407  let i, j;
25408  for (i = 0, j = 0; i < count; i++) {
25409    const digit1 = data[i];
25410    if (!isHexDigit(digit1)) {
25411      continue;
25412    }
25413    i++;
25414    let digit2;
25415    while (i < count && !isHexDigit(digit2 = data[i])) {
25416      i++;
25417    }
25418    if (i < count) {
25419      const value = parseInt(String.fromCharCode(digit1, digit2), 16);
25420      decrypted[j++] = value ^ r >> 8;
25421      r = (value + r) * c1 + c2 & (1 << 16) - 1;
25422    }
25423  }
25424  return decrypted.slice(discardNumber, j);
25425}
25426function isSpecial(c) {
25427  return c === 0x2f || c === 0x5b || c === 0x5d || c === 0x7b || c === 0x7d || c === 0x28 || c === 0x29;
25428}
25429class Type1Parser {
25430  constructor(stream, encrypted, seacAnalysisEnabled) {
25431    if (encrypted) {
25432      const data = stream.getBytes();
25433      const isBinary = !((isHexDigit(data[0]) || isWhiteSpace(data[0])) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]) && isHexDigit(data[4]) && isHexDigit(data[5]) && isHexDigit(data[6]) && isHexDigit(data[7]));
25434      stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
25435    }
25436    this.seacAnalysisEnabled = !!seacAnalysisEnabled;
25437    this.stream = stream;
25438    this.nextChar();
25439  }
25440  readNumberArray() {
25441    this.getToken();
25442    const array = [];
25443    while (true) {
25444      const token = this.getToken();
25445      if (token === null || token === "]" || token === "}") {
25446        break;
25447      }
25448      array.push(parseFloat(token || 0));
25449    }
25450    return array;
25451  }
25452  readNumber() {
25453    const token = this.getToken();
25454    return parseFloat(token || 0);
25455  }
25456  readInt() {
25457    const token = this.getToken();
25458    return parseInt(token || 0, 10) | 0;
25459  }
25460  readBoolean() {
25461    const token = this.getToken();
25462    return token === "true" ? 1 : 0;
25463  }
25464  nextChar() {
25465    return this.currentChar = this.stream.getByte();
25466  }
25467  prevChar() {
25468    this.stream.skip(-2);
25469    return this.currentChar = this.stream.getByte();
25470  }
25471  getToken() {
25472    let comment = false;
25473    let ch = this.currentChar;
25474    while (true) {
25475      if (ch === -1) {
25476        return null;
25477      }
25478      if (comment) {
25479        if (ch === 0x0a || ch === 0x0d) {
25480          comment = false;
25481        }
25482      } else if (ch === 0x25) {
25483        comment = true;
25484      } else if (!isWhiteSpace(ch)) {
25485        break;
25486      }
25487      ch = this.nextChar();
25488    }
25489    if (isSpecial(ch)) {
25490      this.nextChar();
25491      return String.fromCharCode(ch);
25492    }
25493    let token = "";
25494    do {
25495      token += String.fromCharCode(ch);
25496      ch = this.nextChar();
25497    } while (ch >= 0 && !isWhiteSpace(ch) && !isSpecial(ch));
25498    return token;
25499  }
25500  readCharStrings(bytes, lenIV) {
25501    if (lenIV === -1) {
25502      return bytes;
25503    }
25504    return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
25505  }
25506  extractFontProgram(properties) {
25507    const stream = this.stream;
25508    const subrs = [],
25509      charstrings = [];
25510    const privateData = new Map([["lenIV", 4]]);
25511    const program = {
25512      subrs: [],
25513      charstrings: [],
25514      properties: {
25515        privateData
25516      }
25517    };
25518    let token, length, data
25518, lenIV;
25519    let subrsParsed = false;
25520    let charStringsParsed = false;
25521    while ((token = this.getToken()) !== null) {
25522      if (token !== "/") {
25523        continue;
25524      }
25525      token = this.getToken();
25526      switch (token) {
25527        case "CharStrings":
25528          if (charStringsParsed) {
25529            break;
25530          }
25531          charStringsParsed = true;
25532          this.getToken();
25533          this.getToken();
25534          this.getToken();
25535          this.getToken();
25536          while (true) {
25537            token = this.getToken();
25538            if (token === null || token === "end") {
25539              break;
25540            }
25541            if (token !== "/") {
25542              continue;
25543            }
25544            const glyph = this.getToken();
25545            length = this.readInt();
25546            this.getToken();
25547            data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
25548            lenIV = privateData.get("lenIV");
25549            const encoded = this.readCharStrings(data, lenIV);
25550            this.nextChar();
25551            token = this.getToken();
25552            if (token === "noaccess") {
25553              this.getToken();
25554            } else if (token === "/") {
25555              this.prevChar();
25556            }
25557            charstrings.push({
25558              glyph,
25559              encoded
25560            });
25561          }
25562          break;
25563        case "Subrs":
25564          if (subrsParsed) {
25565            break;
25566          }
25567          subrsParsed = true;
25568          this.readInt();
25569          this.getToken();
25570          while (this.getToken() === "dup") {
25571            const index = this.readInt();
25572            length = this.readInt();
25573            this.getToken();
25574            data = length > 0 ? stream.getBytes(length) : new Uint8Array(0);
25575            lenIV = privateData.get("lenIV");
25576            const encoded = this.readCharStrings(data, lenIV);
25577            this.nextChar();
25578            token = this.getToken();
25579            if (token === "noaccess") {
25580              this.getToken();
25581            }
25582            subrs[index] = encoded;
25583          }
25584          break;
25585        case "BlueValues":
25586        case "OtherBlues":
25587        case "FamilyBlues":
25588        case "FamilyOtherBlues":
25589          const blueArray = this.readNumberArray();
25590          if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
25591            privateData.set(token, blueArray);
25592          
vendor: 13,861 bytes, lines 25592-26031
25592}
25593          break;
25594        case "StemSnapH":
25595        case "StemSnapV":
25596          privateData.set(token, this.readNumberArray());
25597          break;
25598        case "StdHW":
25599        case "StdVW":
25600          privateData.set(token, this.readNumberArray()[0]);
25601          break;
25602        case "BlueShift":
25603        case "lenIV":
25604        case "BlueFuzz":
25605        case "BlueScale":
25606        case "LanguageGroup":
25607          privateData.set(token, this.readNumber());
25608          break;
25609        case "ExpansionFactor":
25610          privateData.set(token, this.readNumber() || 0.06);
25611          break;
25612        case "ForceBold":
25613          privateData.set(token, this.readBoolean());
25614          break;
25615      }
25616    }
25617    for (const {
25618      encoded,
25619      glyph
25620    } of charstrings) {
25621      const charString = new Type1CharString();
25622      const error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
25623      const output = !error ? charString.output : [14];
25624      const charStringObject = {
25625        glyphName: glyph,
25626        charstring: output,
25627        width: charString.width,
25628        lsb: charString.lsb,
25629        seac: charString.seac
25630      };
25631      if (glyph === ".notdef") {
25632        program.charstrings.unshift(charStringObject);
25633      } else {
25634        program.charstrings.push(charStringObject);
25635      }
25636      if (properties.builtInEncoding) {
25637        const index = properties.builtInEncoding.indexOf(glyph);
25638        if (index > -1 && properties.widths[index] === undefined && index >= properties.firstChar && index <= properties.lastChar) {
25639          properties.widths[index] = charString.width;
25640        }
25641      }
25642    }
25643    return program;
25644  }
25645  extractCidKeyedFontProgram(properties) {
25646    const stream = this.stream;
25647    const privateData = new Map([["lenIV", 4]]);
25648    const program = {
25649      subrs: [],
25650      charstrings: [],
25651      properties: {
25652        privateData
25653      }
25654    };
25655    let cidCount = 0;
25656    let cidMapOffset = -1;
25657    let fdBytes = 1;
25658    let gdBytes = 0;
25659    let subrMapOffset = -1;
25660    let sdBytes = 0;
25661    let subrCount = 0;
25662    let startDataLength = 0;
25663    let startDataIsHex = false;
25664    let foundStartData = false;
25665    const previousTokens = [];
25666    function rememberToken(value) {
25667      previousTokens.push(value);
25668      if (previousTokens.length > 4) {
25669        previousTokens.shift();
25670      }
25671    }
25672    let token;
25673    while ((token = this.getToken()) !== null) {
25674      if (token === "StartData") {
25675        const dataType = previousTokens.at(-3);
25676        const dataLength = previousTokens.at(-1);
25677        if (previousTokens.at(-4) !== "(" || previousTokens.at(-2) !== ")" || dataType !== "Binary" && dataType !== "Hex" || !/^\d+$/.test(dataLength)) {
25678          return null;
25679        }
25680        startDataLength = parseInt(dataLength, 10);
25681        if (startDataLength <= 0) {
25682          return null;
25683        }
25684        startDataIsHex = dataType === "Hex";
25685        foundStartData = true;
25686        break;
25687      }
25688      rememberToken(token);
25689      if (token !== "/") {
25690        continue;
25691      }
25692      token = this.getToken();
25693      rememberToken(token);
25694      switch (token) {
25695        case "FontMatrix":
25696          properties.fontMatrix = this.readNumberArray();
25697          break;
25698        case "FontBBox":
25699          const fontBBox = this.readNumberArray();
25700          properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
25701          properties.descent = Math.min(fontBBox[1], fontBBox[3]);
25702          properties.ascentScaled = true;
25703          break;
25704        case "CIDCount":
25705          cidCount = this.readInt();
25706          break;
25707        case "CIDMapOffset":
25708          cidMapOffset = this.readInt();
25709          break;
25710        case "FDBytes":
25711          fdBytes = this.readInt();
25712          break;
25713        case "GDBytes":
25714          gdBytes = this.readInt();
25715          break;
25716        case "SubrMapOffset":
25717          subrMapOffset = this.readInt();
25718          break;
25719        case "SDBytes":
25720          sdBytes = this.readInt();
25721          break;
25722        case "SubrCount":
25723          subrCount = this.readInt();
25724          break;
25725        case "BlueValues":
25726        case "OtherBlues":
25727        case "FamilyBlues":
25728        case "FamilyOtherBlues":
25729          this.readNumberArray();
25730          break;
25731        case "StemSnapH":
25732        case "StemSnapV":
25733          privateData.set(token, this.readNumberArray());
25734          break;
25735        case "StdHW":
25736        case "StdVW":
25737          privateData.set(token, this.readNumberArray()[0]);
25738          break;
25739        case "BlueShift":
25740        case "lenIV":
25741        case "BlueFuzz":
25742        case "BlueScale":
25743        case "LanguageGroup":
25744          privateData.set(token, this.readNumber());
25745          break;
25746        case "ExpansionFactor":
25747          privateData.set(token, this.readNumber() || 0.06);
25748          break;
25749        case "ForceBold":
25750          privateData.set(token, this.readBoolean());
25751          break;
25752      }
25753    }
25754    if (!foundStartData || cidCount <= 0 || cidMapOffset < 0 || fdBytes < 0 || fdBytes > 4 || gdBytes < 1 || gdBytes > 4) {
25755      return null;
25756    }
25757    const maxLength = stream.end - stream.pos;
25758    if (startDataLength > maxLength) {
25759      if (!startDataIsHex) {
25760        startDataLength = maxLength;
25761      } else if (startDataLength > 2 * maxLength) {
25762        return null;
25763      }
25764    }
25765    let binary = stream.getBytes(startDataIsHex ? undefined : startDataLength);
25766    if (startDataIsHex) {
25767      const decoded = new Uint8Array(startDataLength);
25768      let digit1 = -1,
25769        j = 0;
25770      for (let i = 0, ii = binary.length; i < ii && j < startDataLength; i++) {
25771        const digit = binary[i];
25772        if (!isHexDigit(digit)) {
25773          continue;
25774        }
25775        if (digit1 < 0) {
25776          digit1 = digit;
25777          continue;
25778        }
25779        decoded[j++] = parseInt(String.fromCharCode(digit1, digit), 16);
25780        digit1 = -1;
25781      }
25782      if (j !== startDataLength) {
25783        return null;
25784      }
25785      binary = decoded;
25786    }
25787    const lenIV = privateData.get("lenIV");
25788    const cidEntrySize = fdBytes + gdBytes;
25789    const subrs = [];
25790    function readUint(offset, byteCount) {
25791      let n = 0;
25792      for (let i = 0; i < byteCount; i++) {
25793        n = n << 8 | binary[offset + i];
25794      }
25795      return n >>> 0;
25796    }
25797    if (cidMapOffset + (cidCount + 1) * cidEntrySize > binary.length || subrCount > 0 && (subrMapOffset < 0 || sdBytes < 1 || sdBytes > 4 || subrMapOffset + (subrCount + 1) * sdBytes > binary.length)) {
25798      return null;
25799    }
25800    if (fdBytes > 0) {
25801      for (let cid = 0; cid < cidCount; cid++) {
25802        if (readUint(cidMapOffset + cid * cidEntrySize, fdBytes) !== 0) {
25803          return null;
25804        }
25805      }
25806    }
25807    if (subrCount > 0) {
25808      const subrOffsets = new Array(subrCount + 1);
25809      for (let i = 0; i <= subrCount; i++) {
25810        subrOffsets[i] = readUint(subrMapOffset + i * sdBytes, sdBytes);
25811      }
25812      for (let i = 0; i < subrCount; i++) {
25813        const start = subrOffsets[i];
25814        const end = subrOffsets[i + 1];
25815        if (end > binary.length || end < start) {
25816          subrs[i] = new Uint8Array(0);
25817          continue;
25818        }
25819        subrs[i] = this.readCharStrings(binary.subarray(start, end), lenIV);
25820      }
25821    }
25822    const charstrings = [];
25823    let prevOffset = readUint(cidMapOffset + fdBytes, gdBytes);
25824    for (let cid = 0; cid < cidCount; cid++) {
25825      const nextOffset = readUint(cidMapOffset + (cid + 1) * cidEntrySize + fdBytes, gdBytes);
25826      const glyphName = cid === 0 ? ".notdef" : `cid${cid}`;
25827      if (nextOffset > prevOffset && nextOffset <= binary.length) {
25828        const encoded = this.readCharStrings(binary.subarray(prevOffset, nextOffset), lenIV);
25829        const charString = new Type1CharString();
25830        const error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
25831        charstrings.push({
25832          glyphName,
25833          charstring: error ? [14] : charString.output,
25834          width: charString.width,
25835          lsb: charString.lsb,
25836          seac: charString.seac
25837        });
25838      } else {
25839        const notDef = charstrings[0];
25840        charstrings.push({
25841          glyphName,
25842          charstring: notDef?.charstring.slice() || [0x8b, 0x0e],
25843          width: notDef?.width || 0,
25844          lsb: notDef?.lsb || 0
25845        });
25846      }
25847      prevOffset = nextOffset;
25848    }
25849    program.subrs = subrs;
25850    program.charstrings = charstrings;
25851    return program;
25852  }
25853  extractFontHeader(properties) {
25854    let token;
25855    while ((token = this.getToken()) !== null) {
25856      if (token !== "/") {
25857        continue;
25858      }
25859      token = this.getToken();
25860      switch (token) {
25861        case "FontMatrix":
25862          const matrix = this.readNumberArray();
25863          properties.fontMatrix = matrix;
25864          break;
25865        case "Encoding":
25866          const encodingArg = this.getToken();
25867          let encoding;
25868          if (!/^\d+$/.test(encodingArg)) {
25869            encoding = getEncoding(encodingArg);
25870          } else {
25871            encoding = [];
25872            const size = parseInt(encodingArg, 10) | 0;
25873            this.getToken();
25874            for (let j = 0; j < size; j++) {
25875              token = this.getToken();
25876              while (token !== "dup" && token !== "def") {
25877                token = this.getToken();
25878                if (token === null) {
25879                  return;
25880                }
25881              }
25882              if (token === "def") {
25883                break;
25884              }
25885              const index = this.readInt();
25886              this.getToken();
25887              const glyph = this.getToken();
25888              encoding[index] = glyph;
25889              this.getToken();
25890            }
25891          }
25892          properties.builtInEncoding = encoding;
25893          break;
25894        case "FontBBox":
25895          const fontBBox = this.readNumberArray();
25896          properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
25897          properties.descent = Math.min(fontBBox[1], fontBBox[3]);
25898          properties.ascentScaled = true;
25899          break;
25900      }
25901    }
25902  }
25903}
25904
25905;// ./src/core/type1_font.js
25906
25907
25908
25909
25910
25911
25912function findBlock(streamBytes, signature, startIndex) {
25913  const streamBytesLength = streamBytes.length;
25914  const signatureLength = signature.length;
25915  const scanLength = streamBytesLength - signatureLength;
25916  let i = startIndex,
25917    found = false;
25918  while (i < scanLength) {
25919    let j = 0;
25920    while (j < signatureLength && streamBytes[i + j] === signature[j]) {
25921      j++;
25922    }
25923    if (j >= signatureLength) {
25924      i += j;
25925      while (i < streamBytesLength && isWhiteSpace(streamBytes[i])) {
25926        i++;
25927      }
25928      found = true;
25929      break;
25930    }
25931    i++;
25932  }
25933  return {
25934    found,
25935    length: i
25936  };
25937}
25938function getHeaderBlock(stream, suggestedLength) {
25939  const EEXEC_SIGNATURE = [0x65, 0x65, 0x78, 0x65, 0x63];
25940  const streamStartPos = stream.pos;
25941  let headerBytes, headerBytesLength, block;
25942  try {
25943    headerBytes = stream.getBytes(suggestedLength);
25944    headerBytesLength = headerBytes.length;
25945  } catch {}
25946  if (headerBytesLength === suggestedLength) {
25947    block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
25948    if (block.found && block.length === suggestedLength) {
25949      return {
25950        stream: new Stream(headerBytes),
25951        length: suggestedLength
25952      };
25953    }
25954  }
25955  warn('Invalid "Length1" property in Type1 font -- trying to recover.');
25956  stream.pos = streamStartPos;
25957  const SCAN_BLOCK_LENGTH = 2048;
25958  let actualLength;
25959  while (true) {
25960    const scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
25961    block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
25962    if (block.length === 0) {
25963      break;
25964    }
25965    stream.pos += block.length;
25966    if (block.found) {
25967      actualLength = stream.pos - streamStartPos;
25968      break;
25969    }
25970  }
25971  stream.pos = streamStartPos;
25972  if (actualLength) {
25973    return {
25974      stream: new Stream(stream.getBytes(actualLength)),
25975      length: actualLength
25976    };
25977  }
25978  warn('Unable to recover "Length1" property in Type1 font -- using as is.');
25979  return {
25980    stream: new Stream(stream.getBytes(suggestedLength)),
25981    length: suggestedLength
25982  };
25983}
25984function getEexecBlock(stream, suggestedLength) {
25985  const eexecBytes = stream.getBytes();
25986  if (eexecBytes.length === 0) {
25987    throw new FormatError("getEexecBlock - no font program found.");
25988  }
25989  return {
25990    stream: new Stream(eexecBytes),
25991    length: eexecBytes.length
25992  };
25993}
25994function isCidKeyedType1File(file) {
25995  const sample = file.peekBytes(2048);
25996  if (sample.length < 2 || sample[0] !== 0x25 || sample[1] !== 0x21) {
25997    return false;
25998  }
25999  const text = bytesToString(sample);
26000  return text.includes("Resource-CIDFont") || /\/CIDFontType\s+0\b/.test(text);
26001}
26002class Type1Font {
26003  #rawFileLength;
26004  constructor(name, file, properties) {
26005    let data;
26006    if (properties.composite && isCidKeyedType1File(file)) {
26007      data = this.#parseCidKeyedType1(file, properties);
26008    }
26009    data ||= this.#parseType1(file, properties);
26010    for (const key in data.properties) {
26011      properties[key] = data.properties[key];
26012    }
26013    const charstrings = data.charstrings;
26014    const type2Charstrings = this.getType2Charstrings(charstrings);
26015    const subrs = this.getType2Subrs(data.subrs);
26016    this.charstrings = charstrings;
26017    this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
26018    this.seacs = this.getSeacs(data.charstrings);
26019  }
26020  #parseType1(file, properties) {
26021    const PFB_HEADER_SIZE = 6;
26022    let headerBlockLength = properties.length1;
26023    let eexecBlockLength = properties.length2;
26024    let pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
26025    const pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
26026    if (pfbHeaderPresent) {
26027      file.skip(PFB_HEADER_SIZE);
26028      headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
26029    }
26030    const headerBlock = getHeaderBlock(file, headerBlockLength);
26031    const headerBlockParser = new Type1Parser(headerBlock.stream, false, 
26031SEAC_ANALYSIS_ENABLED);
26032    headerBlockParser.extractFontHeader(properties);
26033    if (pfbHeaderPresent) {
26034      pfbHeader = file.getBytes(PFB_HEADER_SIZE);
26035      eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
26036    }
26037    const eexecBlock = getEexecBlock(file, eexecBlockLength);
26038    const eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
26039    const data = eexecBlockParser.extractFontProgram(properties);
26040    this.#rawFileLength = headerBlock.length + eexecBlock.length;
26041    return data;
26042  }
26043  #parseCidKeyedType1(file, properties) {
26044    const fileStart = file.pos;
26045    const length = file.end - fileStart;
26046    const parser = new Type1Parser(file, false, SEAC_ANALYSIS_ENABLED);
26047    const data = parser.extractCidKeyedFontProgram(properties);
26048    if (!data) {
26049      file.pos = fileStart;
26050      warn("Type1Font: unable to parse CID-keyed Type 1 font.");
26051      return null;
26052    }
26053    this.#rawFileLength = length;
26054    return data;
26055  }
26056  get numGlyphs() {
26057    return this.charstrings.length + 1;
26058  }
26059  getCharset() {
26060    const charset = [".notdef"];
26061    for (const {
26062      glyphName
26063    } of this.charstrings) {
26064      charset.push(glyphName);
26065    }
26066    return charset;
26067  }
26068  getGlyphMapping(properties) {
26069    const charstrings = this.charstrings;
26070    if (properties.composite) {
vendor: 10,703 bytes, lines 26071-26436
26071      const charCodeToGlyphId = Object.create(null);
26072      for (let glyphId = 0, charstringsLen = charstrings.length; glyphId < charstringsLen; glyphId++) {
26073        const charCode = properties.cMap.charCodeOf(glyphId);
26074        charCodeToGlyphId[charCode] = glyphId + 1;
26075      }
26076      return charCodeToGlyphId;
26077    }
26078    const glyphNames = [".notdef"];
26079    let builtInEncoding, glyphId;
26080    for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
26081      glyphNames.push(charstrings[glyphId].glyphName);
26082    }
26083    const encoding = properties.builtInEncoding;
26084    if (encoding) {
26085      builtInEncoding = Object.create(null);
26086      for (const charCode in encoding) {
26087        glyphId = glyphNames.indexOf(encoding[charCode]);
26088        if (glyphId >= 0) {
26089          builtInEncoding[charCode] = glyphId;
26090        }
26091      }
26092    }
26093    return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
26094  }
26095  hasGlyphId(id) {
26096    if (id < 0 || id >= this.numGlyphs) {
26097      return false;
26098    }
26099    if (id === 0) {
26100      return true;
26101    }
26102    const glyph = this.charstrings[id - 1];
26103    return glyph.charstring.length > 0;
26104  }
26105  getSeacs(charstrings) {
26106    const seacMap = [];
26107    for (let i = 0, ii = charstrings.length; i < ii; i++) {
26108      const charstring = charstrings[i];
26109      if (charstring.seac) {
26110        seacMap[i + 1] = charstring.seac;
26111      }
26112    }
26113    return seacMap;
26114  }
26115  getType2Charstrings(type1Charstrings) {
26116    const type2Charstrings = [];
26117    for (const type1Charstring of type1Charstrings) {
26118      type2Charstrings.push(type1Charstring.charstring);
26119    }
26120    return type2Charstrings;
26121  }
26122  getType2Subrs(type1Subrs) {
26123    let bias = 0;
26124    const count = type1Subrs.length;
26125    if (count < 1133) {
26126      bias = 107;
26127    } else if (count < 33769) {
26128      bias = 1131;
26129    } else {
26130      bias = 32768;
26131    }
26132    const type2Subrs = [];
26133    let i;
26134    for (i = 0; i < bias; i++) {
26135      type2Subrs.push([0x0b]);
26136    }
26137    for (i = 0; i < count; i++) {
26138      type2Subrs.push(type1Subrs[i]);
26139    }
26140    return type2Subrs;
26141  }
26142  wrap(name, glyphs, charstrings, subrs, properties) {
26143    const cff = new CFF(this.#rawFileLength);
26144    cff.header = new CFFHeader(1, 0, 4, 4);
26145    cff.names = [name];
26146    const topDict = new CFFTopDict();
26147    topDict.setByName("version", 391);
26148    topDict.setByName("Notice", 392);
26149    topDict.setByName("FullName", 393);
26150    topDict.setByName("FamilyName", 394);
26151    topDict.setByName("Weight", 395);
26152    topDict.setByName("Encoding", null);
26153    topDict.setByName("FontMatrix", properties.fontMatrix);
26154    topDict.setByName("FontBBox", properties.bbox);
26155    topDict.setByName("charset", null);
26156    topDict.setByName("CharStrings", null);
26157    topDict.setByName("Private", null);
26158    cff.topDict = topDict;
26159    const strings = new CFFStrings();
26160    strings.add("Version 0.11");
26161    strings.add("See original notice");
26162    strings.add(name);
26163    strings.add(name);
26164    strings.add("Medium");
26165    cff.strings = strings;
26166    cff.globalSubrIndex = new CFFIndex();
26167    const count = glyphs.length;
26168    const charsetArray = [".notdef"];
26169    for (let i = 0; i < count; i++) {
26170      const {
26171        glyphName
26172      } = charstrings[i];
26173      const index = CFFStandardStrings.indexOf(glyphName);
26174      if (index === -1) {
26175        strings.add(glyphName);
26176      }
26177      charsetArray.push(glyphName);
26178    }
26179    cff.charset = new CFFCharset(false, 0, charsetArray);
26180    const charStringsIndex = new CFFIndex();
26181    charStringsIndex.add([0x8b, 0x0e]);
26182    for (let i = 0; i < count; i++) {
26183      charStringsIndex.add(glyphs[i]);
26184    }
26185    cff.charStrings = charStringsIndex;
26186    const privateDict = new CFFPrivateDict();
26187    privateDict.setByName("Subrs", null);
26188    const fields = ["BlueValues", "OtherBlues", "FamilyBlues", "FamilyOtherBlues", "StemSnapH", "StemSnapV", "BlueShift", "BlueFuzz", "BlueScale", "LanguageGroup", "ExpansionFactor", "ForceBold", "StdHW", "StdVW"];
26189    for (const field of fields) {
26190      if (!properties.privateData.has(field)) {
26191        continue;
26192      }
26193      const value = properties.privateData.get(field);
26194      if (Array.isArray(value)) {
26195        for (let j = value.length - 1; j > 0; j--) {
26196          value[j] -= value[j - 1];
26197        }
26198      }
26199      privateDict.setByName(field, value);
26200    }
26201    cff.topDict.privateDict = privateDict;
26202    const subrIndex = new CFFIndex();
26203    for (const subr of subrs) {
26204      subrIndex.add(subr);
26205    }
26206    privateDict.subrsIndex = subrIndex;
26207    const compiler = new CFFCompiler(cff);
26208    return compiler.compile();
26209  }
26210}
26211
26212;// ./src/core/fonts.js
26213
26214
26215
26216
26217
26218
26219
26220
26221
26222
26223
26224
26225
26226
26227
26228
26229
26230const PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
26231const PDF_GLYPH_SPACE_UNITS = 1000;
26232const EXPORT_DATA_PROPERTIES = ["ascent", "bbox", "black", "bold", "cssFontInfo", "data", "defaultVMetrics", "defaultWidth", "descent", "disableFontFace", "fallbackName", "fontExtraProperties", "fontMatrix", "isInvalidPDFjsFont", "isType3Font", "italic", "loadedName", "mimetype", "missingFile", "name", "remeasure", "systemFontInfo", "vertical"];
26233const EXPORT_DATA_EXTRA_PROPERTIES = ["cMap", "composite", "defaultEncoding", "differences", "isMonospace", "isSerifFont", "isSymbolicFont", "seacMap", "subtype", "toFontChar", "toUnicode", "type", "vmetrics", "widths"];
26234function adjustWidths(properties) {
26235  if (!properties.fontMatrix) {
26236    return;
26237  }
26238  if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
26239    return;
26240  }
26241  const scale = 0.001 / properties.fontMatrix[0];
26242  const glyphsWidths = properties.widths;
26243  for (const glyph in glyphsWidths) {
26244    glyphsWidths[glyph] *= scale;
26245  }
26246  properties.defaultWidth *= scale;
26247}
26248function adjustTrueTypeToUnicode(properties, isSymbolicFont, nameRecords) {
26249  if (properties.isInternalFont) {
26250    return;
26251  }
26252  if (properties.hasIncludedToUnicodeMap) {
26253    return;
26254  }
26255  if (properties.hasEncoding) {
26256    return;
26257  }
26258  if (properties.toUnicode instanceof IdentityToUnicodeMap) {
26259    return;
26260  }
26261  if (!isSymbolicFont) {
26262    return;
26263  }
26264  if (nameRecords.length === 0) {
26265    return;
26266  }
26267  if (properties.defaultEncoding === WinAnsiEncoding) {
26268    return;
26269  }
26270  for (const r of nameRecords) {
26271    if (!isWinNameRecord(r)) {
26272      return;
26273    }
26274  }
26275  const encoding = WinAnsiEncoding;
26276  const toUnicode = [],
26277    glyphsUnicodeMap = getGlyphsUnicode();
26278  for (const charCode in encoding) {
26279    const glyphName = encoding[charCode];
26280    if (glyphName === "") {
26281      continue;
26282    }
26283    const unicode = glyphsUnicodeMap[glyphName];
26284    if (unicode === undefined) {
26285      continue;
26286    }
26287    toUnicode[charCode] = String.fromCharCode(unicode);
26288  }
26289  if (toUnicode.length > 0) {
26290    properties.toUnicode.amend(toUnicode);
26291  }
26292}
26293function adjustType1ToUnicode(properties, builtInEncoding) {
26294  if (properties.isInternalFont) {
26295    return;
26296  }
26297  if (properties.hasIncludedToUnicodeMap) {
26298    return;
26299  }
26300  if (builtInEncoding === properties.defaultEncoding) {
26301    return;
26302  }
26303  if (properties.toUnicode instanceof IdentityToUnicodeMap) {
26304    return;
26305  }
26306  const toUnicode = [],
26307    glyphsUnicodeMap = getGlyphsUnicode();
26308  for (const charCode in builtInEncoding) {
26309    if (properties.hasEncoding) {
26310      if (properties.baseEncodingName || properties.differences[charCode] !== undefined) {
26311        continue;
26312      }
26313    }
26314    const glyphName = builtInEncoding[charCode];
26315    const unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
26316    if (unicode !== -1) {
26317      toUnicode[charCode] = String.fromCharCode(unicode);
26318    }
26319  }
26320  if (toUnicode.length > 0) {
26321    properties.toUnicode.amend(toUnicode);
26322  }
26323}
26324function amendFallbackToUnicode(properties) {
26325  if (!properties.fallbackToUnicode) {
26326    return;
26327  }
26328  if (properties.toUnicode instanceof IdentityToUnicodeMap) {
26329    return;
26330  }
26331  const toUnicode = [];
26332  for (const charCode in properties.fallbackToUnicode) {
26333    if (properties.toUnicode.has(charCode)) {
26334      continue;
26335    }
26336    toUnicode[charCode] = properties.fallbackToUnicode[charCode];
26337  }
26338  if (toUnicode.length > 0) {
26339    properties.toUnicode.amend(toUnicode);
26340  }
26341}
26342class fonts_Glyph {
26343  constructor(originalCharCode, fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
26344    this.originalCharCode = originalCharCode;
26345    this.fontChar = fontChar;
26346    this.unicode = unicode;
26347    this.accent = accent;
26348    this.width = width;
26349    this.vmetric = vmetric;
26350    this.operatorListId = operatorListId;
26351    this.isSpace = isSpace;
26352    this.isInFont = isInFont;
26353  }
26354  get category() {
26355    return shadow(this, "category", getCharUnicodeCategory(this.unicode), true);
26356  }
26357}
26358function int16(b0, b1) {
26359  return (b0 << 8) + b1;
26360}
26361function writeSignedInt16(bytes, index, value) {
26362  bytes[index + 1] = value;
26363  bytes[index] = value >>> 8;
26364}
26365function signedInt16(b0, b1) {
26366  const value = (b0 << 8) + b1;
26367  return value & 1 << 15 ? value - 0x10000 : value;
26368}
26369function writeUint32(bytes, index, value) {
26370  bytes[index + 3] = value & 0xff;
26371  bytes[index + 2] = value >>> 8;
26372  bytes[index + 1] = value >>> 16;
26373  bytes[index] = value >>> 24;
26374}
26375function isTrueTypeFile(file) {
26376  const header = file.peekBytes(4),
26377    str = bytesToString(header);
26378  return str === "\x00\x01\x00\x00" || str === "true";
26379}
26380function isTrueTypeCollectionFile(file) {
26381  const header = file.peekBytes(4);
26382  return bytesToString(header) === "ttcf";
26383}
26384function isOpenTypeFile(file) {
26385  const header = file.peekBytes(4);
26386  return bytesToString(header) === "OTTO";
26387}
26388function isType1File(file) {
26389  const header = file.peekBytes(2);
26390  if (header[0] === 0x25 && header[1] === 0x21) {
26391    return true;
26392  }
26393  if (header[0] === 0x80 && header[1] === 0x01) {
26394    return true;
26395  }
26396  return false;
26397}
26398function isCFFFile(file) {
26399  const header = file.peekBytes(4);
26400  if (header[0] >= 1 && header[3] >= 1 && header[3] <= 4) {
26401    return true;
26402  }
26403  return false;
26404}
26405function getFontFileType(file, {
26406  type,
26407  subtype,
26408  composite
26409}) {
26410  let fileType, fileSubtype;
26411  if (isTrueTypeFile(file) || isTrueTypeCollectionFile(file)) {
26412    fileType = composite ? "CIDFontType2" : "TrueType";
26413  } else if (isOpenTypeFile(file)) {
26414    fileType = composite ? "CIDFontType2" : "OpenType";
26415  } else if (isType1File(file)) {
26416    if (composite) {
26417      fileType = "CIDFontType0";
26418    } else {
26419      fileType = type === "MMType1" ? "MMType1" : "Type1";
26420    }
26421  } else if (isCFFFile(file)) {
26422    if (composite) {
26423      fileType = "CIDFontType0";
26424      fileSubtype = "CIDFontType0C";
26425    } else {
26426      fileType = type === "MMType1" ? "MMType1" : "Type1";
26427      fileSubtype = "Type1C";
26428    }
26429  } else {
26430    warn("getFontFileType: Unable to detect correct font file Type/Subtype.");
26431    fileType = type;
26432    fileSubtype = subtype;
26433  }
26434  return [fileType, fileSubtype];
26435}
26436function applyStandardFontGlyphMap(map, glyphMap) {
26437  for (const charCode in glyphMap) {
26438    map[+charCode] = glyphMap[charCode];
26439  }
26440}
vendor: 13,850 bytes, lines 26440-26873
26440
26441function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
26442  const toFontChar = [];
26443  let unicode;
26444  for (let i = 0, ii = encoding.length; i < ii; i++) {
26445    unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
26446    if (unicode !== -1) {
26447      toFontChar[i] = unicode;
26448    }
26449  }
26450  for (const charCode in differences) {
26451    unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
26452    if (unicode !== -1) {
26453      toFontChar[+charCode] = unicode;
26454    }
26455  }
26456  return toFontChar;
26457}
26458function isMacNameRecord(r) {
26459  return r.platform === 1 && r.encoding === 0 && r.language === 0;
26460}
26461function isWinNameRecord(r) {
26462  return r.platform === 3 && r.encoding === 1 && r.language === 0x409;
26463}
26464function convertCidString(charCode, cid, shouldThrow = false) {
26465  switch (cid.length) {
26466    case 1:
26467      return cid.charCodeAt(0);
26468    case 2:
26469      return cid.charCodeAt(0) << 8 | cid.charCodeAt(1);
26470  }
26471  const msg = `Unsupported CID string (charCode ${charCode}): "${cid}".`;
26472  if (shouldThrow) {
26473    throw new FormatError(msg);
26474  }
26475  warn(msg);
26476  return cid;
26477}
26478function adjustMapping(charCodeToGlyphId, hasGlyph, newGlyphZeroId, toUnicode) {
26479  const newMap = Object.create(null);
26480  const toUnicodeExtraMap = new Map();
26481  const toFontChar = [];
26482  const usedGlyphIds = new Set();
26483  let privateUseAreaIndex = 0;
26484  const privateUseOffetStart = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
26485  let nextAvailableFontCharCode = privateUseOffetStart;
26486  let privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
26487  const isInPrivateArea = code => PRIVATE_USE_AREAS[0][0] <= code && code <= PRIVATE_USE_AREAS[0][1] || PRIVATE_USE_AREAS[1][0] <= code && code <= PRIVATE_USE_AREAS[1][1];
26488  let LIGATURE_TO_UNICODE = null;
26489  for (const originalCharCode in charCodeToGlyphId) {
26490    let glyphId = charCodeToGlyphId[originalCharCode];
26491    if (!hasGlyph(glyphId)) {
26492      continue;
26493    }
26494    if (nextAvailableFontCharCode > privateUseOffetEnd) {
26495      privateUseAreaIndex++;
26496      if (privateUseAreaIndex >= PRIVATE_USE_AREAS.length) {
26497        warn("Ran out of space in font private use area.");
26498        break;
26499      }
26500      nextAvailableFontCharCode = PRIVATE_USE_AREAS[privateUseAreaIndex][0];
26501      privateUseOffetEnd = PRIVATE_USE_AREAS[privateUseAreaIndex][1];
26502    }
26503    const fontCharCode = nextAvailableFontCharCode++;
26504    if (glyphId === 0) {
26505      glyphId = newGlyphZeroId;
26506    }
26507    let unicode = toUnicode.get(originalCharCode);
26508    if (typeof unicode === "string") {
26509      if (unicode.length === 1) {
26510        unicode = unicode.codePointAt(0);
26511      } else {
26512        if (!LIGATURE_TO_UNICODE) {
26513          LIGATURE_TO_UNICODE = new Map();
26514          for (let i = 0xfb00; i <= 0xfb4f; i++) {
26515            const normalized = String.fromCharCode(i).normalize("NFKD");
26516            if (normalized.length > 1) {
26517              LIGATURE_TO_UNICODE.set(normalized, i);
26518            }
26519          }
26520        }
26521        unicode = LIGATURE_TO_UNICODE.get(unicode) || unicode.codePointAt(0);
26522      }
26523    }
26524    if (unicode && !isInPrivateArea(unicode) && !usedGlyphIds.has(glyphId)) {
26525      toUnicodeExtraMap.set(unicode, glyphId);
26526      usedGlyphIds.add(glyphId);
26527    }
26528    newMap[fontCharCode] = glyphId;
26529    toFontChar[originalCharCode] = fontCharCode;
26530  }
26531  return {
26532    toFontChar,
26533    charCodeToGlyphId: newMap,
26534    toUnicodeExtraMap,
26535    nextAvailableFontCharCode
26536  };
26537}
26538function getRanges(glyphs, toUnicodeExtraMap, numGlyphs) {
26539  const codes = [];
26540  for (const charCode in glyphs) {
26541    if (glyphs[charCode] >= numGlyphs) {
26542      continue;
26543    }
26544    codes.push({
26545      fontCharCode: charCode | 0,
26546      glyphId: glyphs[charCode]
26547    });
26548  }
26549  if (toUnicodeExtraMap) {
26550    for (const [unicode, glyphId] of toUnicodeExtraMap) {
26551      if (glyphId >= numGlyphs) {
26552        continue;
26553      }
26554      codes.push({
26555        fontCharCode: unicode,
26556        glyphId
26557      });
26558    }
26559  }
26560  if (codes.length === 0) {
26561    codes.push({
26562      fontCharCode: 0,
26563      glyphId: 0
26564    });
26565  }
26566  codes.sort((a, b) => a.fontCharCode - b.fontCharCode);
26567  const ranges = [];
26568  const length = codes.length;
26569  for (let n = 0; n < length;) {
26570    const start = codes[n].fontCharCode;
26571    const codeIndices = [codes[n].glyphId];
26572    ++n;
26573    let end = start;
26574    while (n < length && end + 1 === codes[n].fontCharCode) {
26575      codeIndices.push(codes[n].glyphId);
26576      ++end;
26577      ++n;
26578      if (end === 0xffff) {
26579        break;
26580      }
26581    }
26582    ranges.push([start, end, codeIndices]);
26583  }
26584  return ranges;
26585}
26586function createCmapTable(glyphs, toUnicodeExtraMap, numGlyphs) {
26587  const ranges = getRanges(glyphs, toUnicodeExtraMap, numGlyphs);
26588  const hasNonBmp = ranges.at(-1)[1] > 0xffff;
26589  let i, ii, j, jj;
26590  for (i = ranges.length - 1; i >= 0; --i) {
26591    if (ranges[i][0] <= 0xffff) {
26592      break;
26593    }
26594  }
26595  const bmpLength = i + 1;
26596  if (ranges[i][0] < 0xffff && ranges[i][1] === 0xffff) {
26597    ranges[i][1] = 0xfffe;
26598  }
26599  const trailingRangesCount = ranges[i][1] < 0xffff ? 1 : 0;
26600  const segCount = bmpLength + trailingRangesCount;
26601  const searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
26602  const segmentsLength = bmpLength * 2 + trailingRangesCount * 2;
26603  const startCount = new DataBuilder({
26604      exactLength: segmentsLength
26605    }),
26606    endCount = new DataBuilder({
26607      exactLength: segmentsLength
26608    }),
26609    idDeltas = new DataBuilder({
26610      exactLength: segmentsLength
26611    }),
26612    idRangeOffsets = new DataBuilder({
26613      exactLength: segmentsLength
26614    }),
26615    glyphsIds = new DataBuilder({});
26616  let bias = 0;
26617  let format4Overflow = false;
26618  for (i = 0, ii = bmpLength; i < ii; i++) {
26619    const [start, end, codes] = ranges[i];
26620    startCount.setInt16(start);
26621    endCount.setInt16(end);
26622    let contiguous = true;
26623    for (j = 1, jj = codes.length; j < jj; ++j) {
26624      if (codes[j] !== codes[j - 1] + 1) {
26625        contiguous = false;
26626        break;
26627      }
26628    }
26629    if (!contiguous) {
26630      const offset = (segCount - i) * 2 + bias * 2;
26631      bias += end - start + 1;
26632      idDeltas.skip(2);
26633      if (offset > 0xffff) {
26634        format4Overflow = true;
26635        idRangeOffsets.skip(2);
26636      } else {
26637        idRangeOffsets.setInt16(offset);
26638      }
26639      for (j = 0, jj = codes.length; j < jj; ++j) {
26640        glyphsIds.setInt16(codes[j]);
26641      }
26642    } else {
26643      const startCode = codes[0];
26644      idDeltas.setInt16(startCode - start & 0xffff);
26645      idRangeOffsets.skip(2);
26646    }
26647  }
26648  if (trailingRangesCount > 0) {
26649    endCount.setArray([0xff, 0xff]);
26650    startCount.setArray([0xff, 0xff]);
26651    idDeltas.setArray([0x00, 0x01]);
26652    idRangeOffsets.skip(2);
26653  }
26654  const format314 = new DataBuilder({
26655    exactLength: 12 + startCount.length + endCount.length + idDeltas.length + idRangeOffsets.length + glyphsIds.length
26656  });
26657  format314.skip(2);
26658  format314.setInt16(2 * segCount);
26659  format314.setInt16(searchParams.range);
26660  format314.setInt16(searchParams.entry);
26661  format314.setInt16(searchParams.rangeShift);
26662  format314.setArray(endCount.data);
26663  format314.skip(2);
26664  format314.setArray(startCount.data);
26665  format314.setArray(idDeltas.data);
26666  format314.setArray(idRangeOffsets.data);
26667  format314.setArray(glyphsIds.data);
26668  const useFormat4 = !format4Overflow && format314.length + 4 <= 0xffff;
26669  const useFormat12 = hasNonBmp || !useFormat4;
26670  const numTables = (useFormat4 ? 1 : 0) + (useFormat12 ? 1 : 0);
26671  let format31012 = null,
26672    header31012 = null;
26673  if (useFormat12) {
26674    format31012 = new DataBuilder({});
26675    for (const range of ranges) {
26676      let start = range[0];
26677      const codes = range[2];
26678      let code = codes[0];
26679      for (j = 1, jj = codes.length; j < jj; ++j) {
26680        if (codes[j] !== codes[j - 1] + 1) {
26681          const end = range[0] + j - 1;
26682          format31012.setInt32(start);
26683          format31012.setInt32(end);
26684          format31012.setInt32(code);
26685          start = end + 1;
26686          code = codes[j];
26687        }
26688      }
26689      format31012.setInt32(start);
26690      format31012.setInt32(range[1]);
26691      format31012.setInt32(code);
26692    }
26693    header31012 = new DataBuilder({
26694      exactLength: 16
26695    });
26696    header31012.setArray([0x00, 0x0c]);
26697    header31012.skip(2);
26698    header31012.setInt32(format31012.length + 16);
26699    header31012.skip(4);
26700    header31012.setInt32(format31012.length / 12);
26701  }
26702  const headerLength = 4 + numTables * 8;
26703  const format4Length = useFormat4 ? 4 + format314.length : 0;
26704  const cmap = new DataBuilder({
26705    exactLength: headerLength
26706  });
26707  cmap.skip(2);
26708  cmap.setInt16(numTables);
26709  let tableOffset = headerLength;
26710  if (useFormat4) {
26711    cmap.setArray([0x00, 0x03]);
26712    cmap.setArray([0x00, 0x01]);
26713    cmap.setInt32(tableOffset);
26714    tableOffset += format4Length;
26715  }
26716  if (useFormat12) {
26717    cmap.setArray([0x00, 0x03]);
26718    cmap.setArray([0x00, 0x0a]);
26719    cmap.setInt32(tableOffset);
26720  }
26721  const table = new DataBuilder({
26722    exactLength: cmap.length + format4Length + (header31012?.length ?? 0) + (format31012?.length ?? 0)
26723  });
26724  table.setArray(cmap.data);
26725  if (useFormat4) {
26726    table.setArray([0x00, 0x04]);
26727    table.setInt16(format314.length + 4);
26728    table.setArray(format314.data);
26729  }
26730  if (useFormat12) {
26731    table.setArray(header31012.data);
26732    table.setArray(format31012.data);
26733  }
26734  return table.data;
26735}
26736function validateOS2Table(os2, file) {
26737  file.pos = (file.start || 0) + os2.offset;
26738  const version = file.getUint16();
26739  const minLength = [78, 86, 96, 96, 96, 100][version];
26740  if (minLength === undefined || os2.length < minLength) {
26741    return false;
26742  }
26743  file.skip(60);
26744  const selection = file.getUint16();
26745  if (version < 4 && selection & 0x0300) {
26746    return false;
26747  }
26748  const firstChar = file.getUint16();
26749  const lastChar = file.getUint16();
26750  if (firstChar > lastChar) {
26751    return false;
26752  }
26753  file.skip(6);
26754  const usWinAscent = file.getUint16();
26755  if (usWinAscent === 0) {
26756    return false;
26757  }
26758  os2.data[8] = os2.data[9] = 0;
26759  return true;
26760}
26761function createOS2Table(properties, charstrings, override) {
26762  override ||= {
26763    unitsPerEm: 0,
26764    yMax: 0,
26765    yMin: 0,
26766    ascent: 0,
26767    descent: 0
26768  };
26769  let ulUnicodeRange1 = 0;
26770  let ulUnicodeRange2 = 0;
26771  let ulUnicodeRange3 = 0;
26772  let ulUnicodeRange4 = 0;
26773  let firstCharIndex = null;
26774  let lastCharIndex = 0;
26775  let position = -1;
26776  if (charstrings) {
26777    for (let code in charstrings) {
26778      code |= 0;
26779      if (firstCharIndex > code || !firstCharIndex) {
26780        firstCharIndex = code;
26781      }
26782      if (lastCharIndex < code) {
26783        lastCharIndex = code;
26784      }
26785      position = getUnicodeRangeFor(code, position);
26786      if (position < 32) {
26787        ulUnicodeRange1 |= 1 << position;
26788      } else if (position < 64) {
26789        ulUnicodeRange2 |= 1 << position - 32;
26790      } else if (position < 96) {
26791        ulUnicodeRange3 |= 1 << position - 64;
26792      } else if (position < 123) {
26793        ulUnicodeRange4 |= 1 << position - 96;
26794      } else {
26795        throw new FormatError("Unicode ranges Bits > 123 are reserved for internal usage");
26796      }
26797    }
26798    if (lastCharIndex > 0xffff) {
26799      lastCharIndex = 0xffff;
26800    }
26801  } else {
26802    firstCharIndex = 0;
26803    lastCharIndex = 255;
26804  }
26805  const bbox = properties.bbox || [0, 0, 0, 0];
26806  const unitsPerEm = override.unitsPerEm || (properties.fontMatrix ? 1 / Math.max(...properties.fontMatrix.slice(0, 4).map(Math.abs)) : 1000);
26807  const scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
26808  const typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
26809  let typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
26810  if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
26811    typoDescent = -typoDescent;
26812  }
26813  const winAscent = override.yMax || typoAscent;
26814  const winDescent = -override.yMin || -typoDescent;
26815  const os2 = new DataBuilder({
26816    exactLength: 96
26817  });
26818  os2.setArray([0x00, 0x03]);
26819  os2.setArray([0x02, 0x24]);
26820  os2.setArray([0x01, 0xf4]);
26821  os2.setArray([0x00, 0x05]);
26822  os2.skip(2);
26823  os2.setArray([0x02, 0x8a]);
26824  os2.setArray([0x02, 0xbb]);
26825  os2.skip(2);
26826  os2.setArray([0x00, 0x8c]);
26827  os2.setArray([0x02, 0x8a]);
26828  os2.setArray([0x02, 0xbb]);
26829  os2.skip(2);
26830  os2.setArray([0x01, 0xdf]);
26831  os2.setArray([0x00, 0x31]);
26832  os2.setArray([0x01, 0x02]);
26833  os2.skip(2);
26834  os2.setArray([0x00, 0x00, 0x06, properties.fixedPitch ? 0x09 : 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]);
26835  os2.setInt32(ulUnicodeRange1);
26836  os2.setInt32(ulUnicodeRange2);
26837  os2.setInt32(ulUnicodeRange3);
26838  os2.setInt32(ulUnicodeRange4);
26839  os2.setArray([0x2a, 0x32, 0x31, 0x2a]);
26840  os2.setInt16(properties.italicAngle ? 1 : 0);
26841  os2.setInt16(firstCharIndex || properties.firstChar);
26842  os2.setInt16(lastCharIndex || properties.lastChar);
26843  os2.setInt16(typoAscent);
26844  os2.setInt16(typoDescent);
26845  os2.setArray([0x00, 0x64]);
26846  os2.setInt16(winAscent);
26847  os2.setInt16(winDescent);
26848  os2.skip(4 + 4);
26849  os2.setInt16(properties.xHeight);
26850  os2.setInt16(properties.capHeight);
26851  os2.skip(2);
26852  os2.setInt16(firstCharIndex || properties.firstChar);
26853  os2.setArray([0x00, 0x03]);
26854  return os2.data;
26855}
26856function createPostTable(properties) {
26857  const post = new DataBuilder({
26858    exactLength: 32
26859  });
26860  post.setArray([0x00, 0x03, 0x00, 0x00]);
26861  post.setInt32(Math.floor(properties.italicAngle * 2 ** 16));
26862  post.skip(2 + 2);
26863  post.setInt32(properties.fixedPitch ? 1 : 0);
26864  post.skip(4 + 4 + 4 + 4);
26865  return post.data;
26866}
26867function createPostscriptName(name) {
26868  return name.replaceAll(/[^\x21-\x7E]|[[\](){}<>/%]/g, "").slice(0, 63);
26869}
26870function createNameTable(name, proto) {
26871  proto ||= [[], []];
26872  const strings = [proto[0][0] || "Original licence", proto[0][1] || name, proto[0][2] || "Unknown", proto[0][3] || "uniqueID", proto[0][4] || name, proto[0][5] || "Version 0.11", proto[0][6] || createPostscriptName(name), proto[0][7] || "Unknown", proto[0][8] || "Unknown", proto[0][9] || "Unknown"];
26873  const stringsBytes = strings.map(s
vendor: 8,536 bytes, lines 26873-27106
26873 => stringToBytes(s));
26874  const stringsUnicodeBytes = new Array(strings.length);
26875  let i, ii, j, jj, str;
26876  for (i = 0, ii = strings.length; i < ii; i++) {
26877    str = proto[1][i] || strings[i];
26878    const strUnicode = new DataBuilder({
26879      exactLength: str.length * 2
26880    });
26881    for (j = 0, jj = str.length; j < jj; j++) {
26882      strUnicode.setInt16(str.charCodeAt(j));
26883    }
26884    stringsUnicodeBytes[i] = strUnicode.data;
26885  }
26886  const namesBytes = [stringsBytes, stringsUnicodeBytes];
26887  const platformsBytes = [[0x00, 0x01], [0x00, 0x03]];
26888  const encodingsBytes = [[0x00, 0x00], [0x00, 0x01]];
26889  const languagesBytes = [[0x00, 0x00], [0x04, 0x09]];
26890  const nameRecords = [];
26891  let strOffset = 0;
26892  for (i = 0, ii = platformsBytes.length; i < ii; i++) {
26893    const strs = namesBytes[i];
26894    for (j = 0, jj = strs.length; j < jj; j++) {
26895      str = strs[j];
26896      const nameRecord = new DataBuilder({
26897        exactLength: 6 + platformsBytes[i].length + encodingsBytes[i].length + languagesBytes[i].length
26898      });
26899      nameRecord.setArray(platformsBytes[i]);
26900      nameRecord.setArray(encodingsBytes[i]);
26901      nameRecord.setArray(languagesBytes[i]);
26902      nameRecord.setInt16(j);
26903      nameRecord.setInt16(str.length);
26904      nameRecord.setInt16(strOffset);
26905      nameRecords.push(nameRecord.data);
26906      strOffset += str.length;
26907    }
26908  }
26909  const namesRecordCount = stringsBytes.length * platformsBytes.length;
26910  const nameTable = new DataBuilder({
26911    exactLength: 6 + Math.sumPrecise(nameRecords.map(arr => arr.length)) + Math.sumPrecise(stringsBytes.map(arr => arr.length)) + Math.sumPrecise(stringsUnicodeBytes.map(arr => arr.length))
26912  });
26913  nameTable.skip(2);
26914  nameTable.setInt16(namesRecordCount);
26915  nameTable.setInt16(namesRecordCount * 12 + 6);
26916  for (const arr of nameRecords) {
26917    nameTable.setArray(arr);
26918  }
26919  for (const arr of stringsBytes) {
26920    nameTable.setArray(arr);
26921  }
26922  for (const arr of stringsUnicodeBytes) {
26923    nameTable.setArray(arr);
26924  }
26925  return nameTable.data;
26926}
26927class Font {
26928  #charsCache = new Map();
26929  #glyphCache = new Map();
26930  charProcOperatorList;
26931  constructor(name, file, properties, evaluatorOptions) {
26932    this.name = name;
26933    this.psName = null;
26934    this.mimetype = null;
26935    this.disableFontFace = evaluatorOptions.disableFontFace;
26936    this.fontExtraProperties = evaluatorOptions.fontExtraProperties;
26937    this.loadedName = properties.loadedName;
26938    this.isType3Font = properties.isType3Font;
26939    this.missingFile = false;
26940    this.cssFontInfo = properties.cssFontInfo;
26941    let isSerifFont = !!(properties.flags & FontFlags.Serif);
26942    if (!isSerifFont && !properties.isSimulatedFlags) {
26943      const stdFontMap = getStdFontMap(),
26944        nonStdFontMap = getNonStdFontMap(),
26945        serifFonts = getSerifFonts();
26946      for (const namePart of name.split("+")) {
26947        let fontName = normalizeFontName(namePart);
26948        fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
26949        fontName = fontName.split("-", 1)[0];
26950        if (serifFonts[fontName]) {
26951          isSerifFont = true;
26952          break;
26953        }
26954      }
26955    }
26956    this.isSerifFont = isSerifFont;
26957    this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
26958    this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
26959    let {
26960      type,
26961      subtype
26962    } = properties;
26963    this.type = type;
26964    this.subtype = subtype;
26965    this.systemFontInfo = properties.systemFontInfo;
26966    const matches = name.match(/^InvalidPDFjsFont_(.*)_\d+$/);
26967    this.isInvalidPDFjsFont = !!matches;
26968    if (this.isInvalidPDFjsFont) {
26969      this.fallbackName = matches[1];
26970    } else if (this.isMonospace) {
26971      this.fallbackName = "monospace";
26972    } else if (this.isSerifFont) {
26973      this.fallbackName = "serif";
26974    } else {
26975      this.fallbackName = "sans-serif";
26976    }
26977    if (this.systemFontInfo?.guessFallback) {
26978      this.systemFontInfo.guessFallback = false;
26979      this.systemFontInfo.css += `,${this.fallbackName}`;
26980    }
26981    this.differences = properties.differences;
26982    this.widths = properties.widths;
26983    this.defaultWidth = properties.defaultWidth;
26984    this.composite = properties.composite;
26985    this.cMap = properties.cMap;
26986    this.capHeight = properties.capHeight / PDF_GLYPH_SPACE_UNITS;
26987    this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
26988    this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
26989    this.lineHeight = this.ascent - this.descent;
26990    this.fontMatrix = properties.fontMatrix;
26991    this.bbox = properties.bbox;
26992    this.defaultEncoding = properties.defaultEncoding;
26993    this.toUnicode = properties.toUnicode;
26994    this.toFontChar = [];
26995    if (properties.type === "Type3") {
26996      for (let charCode = 0; charCode < 256; charCode++) {
26997        this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
26998      }
26999      return;
27000    }
27001    this.cidEncoding = properties.cidEncoding || "";
27002    this.vertical = !!properties.vertical;
27003    if (this.vertical) {
27004      this.vmetrics = properties.vmetrics;
27005      this.defaultVMetrics = properties.defaultVMetrics;
27006    }
27007    if (!file || file.isEmpty) {
27008      if (file) {
27009        warn('Font file is empty in "' + name + '" (' + this.loadedName + ")");
27010      }
27011      this.fallbackToSystemFont(properties);
27012      return;
27013    }
27014    [type, subtype] = getFontFileType(file, properties);
27015    if (type !== this.type || subtype !== this.subtype) {
27016      info("Inconsistent font file Type/SubType, expected: " + `${this.type}/${this.subtype} but found: ${type}/${subtype}.`);
27017    }
27018    let data;
27019    try {
27020      switch (type) {
27021        case "MMType1":
27022          info("MMType1 font (" + name + "), falling back to Type1.");
27023        case "Type1":
27024        case "CIDFontType0":
27025          this.mimetype = "font/opentype";
27026          const cff = subtype === "Type1C" || subtype === "CIDFontType0C" ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
27027          adjustWidths(properties);
27028          data = this.convert(name, cff, properties);
27029          break;
27030        case "OpenType":
27031        case "TrueType":
27032        case "CIDFontType2":
27033          this.mimetype = "font/opentype";
27034          data = this.checkAndRepair(name, file, properties);
27035          adjustWidths(properties);
27036          if (this.isOpenType) {
27037            type = "OpenType";
27038          }
27039          break;
27040        default:
27041          throw new FormatError(`Font ${type} is not supported`);
27042      }
27043    } catch (e) {
27044      warn(e);
27045      this.fallbackToSystemFont(properties);
27046      return;
27047    }
27048    amendFallbackToUnicode(properties);
27049    this.data = data;
27050    this.type = type;
27051    this.subtype = subtype;
27052    this.fontMatrix = properties.fontMatrix;
27053    this.widths = properties.widths;
27054    this.defaultWidth = properties.defaultWidth;
27055    this.toUnicode = properties.toUnicode;
27056    this.seacMap = properties.seacMap;
27057  }
27058  get renderer() {
27059    const renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
27060    return shadow(this, "renderer", renderer);
27061  }
27062  #getExportData(props) {
27063    const data = Object.create(null);
27064    for (const prop of props) {
27065      const value = this[prop];
27066      if (value !== undefined) {
27067        data[prop] = value;
27068      }
27069    }
27070    return data;
27071  }
27072  exportData() {
27073    return {
27074      buffer: compileFontInfo(this.#getExportData(EXPORT_DATA_PROPERTIES)),
27075      charProcOperatorList: this.charProcOperatorList,
27076      extra: this.fontExtraProperties ? this.#getExportData(EXPORT_DATA_EXTRA_PROPERTIES) : undefined
27077    };
27078  }
27079  fallbackToSystemFont(properties) {
27080    this.missingFile = true;
27081    const {
27082      name,
27083      type
27084    } = this;
27085    let fontName = normalizeFontName(name);
27086    const stdFontMap = getStdFontMap(),
27087      nonStdFontMap = getNonStdFontMap();
27088    const isStandardFont = !!stdFontMap[fontName];
27089    const isMappedToStandardFont = !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
27090    fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
27091    const fontBasicMetricsMap = getFontBasicMetrics();
27092    const metrics = fontBasicMetricsMap[fontName];
27093    if (metrics) {
27094      if (isNaN(this.ascent)) {
27095        this.ascent = metrics.ascent / PDF_GLYPH_SPACE_UNITS;
27096      }
27097      if (isNaN(this.descent)) {
27098        this.descent = metrics.descent / PDF_GLYPH_SPACE_UNITS;
27099      }
27100      if (isNaN(this.capHeight)) {
27101        this.capHeight = metrics.capHeight / PDF_GLYPH_SPACE_UNITS;
27102      }
27103    }
27104    this.bold = /bold/i.test(fontName);
27105    this.italic = /oblique|italic/i.test(fontName);
27106    this.black = /Black/.test(name);
vendor: 6,625 bytes, lines 27107-27278
27107    const isNarrow = /Narrow/.test(name);
27108    this.remeasure = (!isStandardFont || isNarrow) && Object.keys(this.widths).length > 0;
27109    if ((isStandardFont || isMappedToStandardFont) && type === "CIDFontType2" && this.cidEncoding.startsWith("Identity-")) {
27110      const cidToGidMap = properties.cidToGidMap;
27111      const map = [];
27112      applyStandardFontGlyphMap(map, getGlyphMapForStandardFonts());
27113      if (/Arial-?Black/i.test(name)) {
27114        applyStandardFontGlyphMap(map, getSupplementalGlyphMapForArialBlack());
27115      } else if (/Calibri/i.test(name)) {
27116        applyStandardFontGlyphMap(map, getSupplementalGlyphMapForCalibri());
27117      }
27118      if (cidToGidMap) {
27119        for (const charCode in map) {
27120          const cid = map[charCode];
27121          if (cidToGidMap[cid] !== undefined) {
27122            map[+charCode] = cidToGidMap[cid];
27123          }
27124        }
27125        if (cidToGidMap.length !== this.toUnicode.length && properties.hasIncludedToUnicodeMap && this.toUnicode instanceof IdentityToUnicodeMap) {
27126          this.toUnicode.forEach(function (charCode, unicodeCharCode) {
27127            const cid = map[charCode];
27128            if (cidToGidMap[cid] === undefined) {
27129              map[+charCode] = unicodeCharCode;
27130            }
27131          });
27132        }
27133      }
27134      if (!(this.toUnicode instanceof IdentityToUnicodeMap)) {
27135        this.toUnicode.forEach(function (charCode, unicodeCharCode) {
27136          map[+charCode] = unicodeCharCode;
27137        });
27138      }
27139      this.toFontChar = map;
27140      this.toUnicode = new ToUnicodeMap(map);
27141    } else if (/Symbol/i.test(fontName)) {
27142      this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), this.differences);
27143    } else if (/Dingbats/i.test(fontName)) {
27144      this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), this.differences);
27145    } else if (isStandardFont || isMappedToStandardFont) {
27146      const map = buildToFontChar(this.defaultEncoding, getGlyphsUnicode(), this.differences);
27147      if (type === "CIDFontType2" && !this.cidEncoding.startsWith("Identity-") && !(this.toUnicode instanceof IdentityToUnicodeMap)) {
27148        this.toUnicode.forEach(function (charCode, unicodeCharCode) {
27149          map[+charCode] = unicodeCharCode;
27150        });
27151      }
27152      this.toFontChar = map;
27153    } else {
27154      const glyphsUnicodeMap = getGlyphsUnicode();
27155      const map = [];
27156      this.toUnicode.forEach((charCode, unicodeCharCode) => {
27157        if (!this.composite) {
27158          const glyphName = this.differences[charCode] || this.defaultEncoding[charCode];
27159          const unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
27160          if (unicode !== -1) {
27161            unicodeCharCode = unicode;
27162          }
27163        }
27164        map[+charCode] = unicodeCharCode;
27165      });
27166      if (this.composite && this.toUnicode instanceof IdentityToUnicodeMap) {
27167        if (/Tahoma|Verdana/i.test(name)) {
27168          applyStandardFontGlyphMap(map, getGlyphMapForStandardFonts());
27169        }
27170      }
27171      this.toFontChar = map;
27172    }
27173    amendFallbackToUnicode(properties);
27174    this.loadedName = fontName.split("-", 1)[0];
27175  }
27176  checkAndRepair(name, font, properties) {
27177    const VALID_TABLES = ["OS/2", "cmap", "head", "hhea", "hmtx", "maxp", "name", "post", "loca", "glyf", "fpgm", "prep", "cvt ", "CFF "];
27178    function readTables(file, numTables) {
27179      const tables = Object.create(null);
27180      tables["OS/2"] = null;
27181      tables.cmap = null;
27182      tables.head = null;
27183      tables.hhea = null;
27184      tables.hmtx = null;
27185      tables.maxp = null;
27186      tables.name = null;
27187      tables.post = null;
27188      for (let i = 0; i < numTables; i++) {
27189        const table = readTableEntry(file);
27190        if (!VALID_TABLES.includes(table.tag)) {
27191          continue;
27192        }
27193        if (table.length === 0) {
27194          continue;
27195        }
27196        tables[table.tag] = table;
27197      }
27198      return tables;
27199    }
27200    function readTableEntry(file) {
27201      const tag = file.getString(4);
27202      const checksum = file.getInt32() >>> 0;
27203      const offset = file.getInt32() >>> 0;
27204      const length = file.getInt32() >>> 0;
27205      const previousPosition = file.pos;
27206      file.pos = file.start || 0;
27207      file.skip(offset);
27208      const data = file.getBytes(length);
27209      file.pos = previousPosition;
27210      if (tag === "head") {
27211        data[8] = data[9] = data[10] = data[11] = 0;
27212        data[17] |= 0x20;
27213      }
27214      const view = tag === "CFF " ? null : new DataView(data.buffer, data.byteOffset, data.byteLength);
27215      return {
27216        tag,
27217        checksum,
27218        length,
27219        offset,
27220        data,
27221        view
27222      };
27223    }
27224    function readOpenTypeHeader(ttf) {
27225      return {
27226        version: ttf.getString(4),
27227        numTables: ttf.getUint16(),
27228        searchRange: ttf.getUint16(),
27229        entrySelector: ttf.getUint16(),
27230        rangeShift: ttf.getUint16()
27231      };
27232    }
27233    function readTrueTypeCollectionHeader(ttc) {
27234      const ttcTag = ttc.getString(4);
27235      assert(ttcTag === "ttcf", "Must be a TrueType Collection font.");
27236      const majorVersion = ttc.getUint16();
27237      const minorVersion = ttc.getUint16();
27238      const numFonts = ttc.getInt32() >>> 0;
27239      const offsetTable = [];
27240      for (let i = 0; i < numFonts; i++) {
27241        offsetTable.push(ttc.getInt32() >>> 0);
27242      }
27243      const header = {
27244        ttcTag,
27245        majorVersion,
27246        minorVersion,
27247        numFonts,
27248        offsetTable
27249      };
27250      switch (majorVersion) {
27251        case 1:
27252          return header;
27253        case 2:
27254          header.dsigTag = ttc.getInt32() >>> 0;
27255          header.dsigLength = ttc.getInt32() >>> 0;
27256          header.dsigOffset = ttc.getInt32() >>> 0;
27257          return header;
27258      }
27259      throw new FormatError(`Invalid TrueType Collection majorVersion: ${majorVersion}.`);
27260    }
27261    function readTrueTypeCollectionData(ttc, fontName) {
27262      const {
27263        numFonts,
27264        offsetTable
27265      } = readTrueTypeCollectionHeader(ttc);
27266      const fontNameParts = fontName.split("+");
27267      let fallbackData;
27268      for (let i = 0; i < numFonts; i++) {
27269        ttc.pos = (ttc.start || 0) + offsetTable[i];
27270        const potentialHeader = readOpenTypeHeader(ttc);
27271        const potentialTables = readTables(ttc, potentialHeader.numTables);
27272        if (!potentialTables.name) {
27273          throw new FormatError('TrueType Collection font must contain a "name" table.');
27274        }
27275        const [nameTable] = readNameTable(potentialTables.name);
27276        for (let j = 0, jj = nameTable.length; j < jj; j++) {
27277          for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
27278            const nameEntry = nameTable[j][k]
vendor: 31,196 bytes, lines 27278-28202
27278?.replaceAll(/\s/g, "");
27279            if (!nameEntry) {
27280              continue;
27281            }
27282            if (nameEntry === fontName) {
27283              return {
27284                header: potentialHeader,
27285                tables: potentialTables
27286              };
27287            }
27288            if (fontNameParts.length < 2) {
27289              continue;
27290            }
27291            for (const part of fontNameParts) {
27292              if (nameEntry === part) {
27293                fallbackData = {
27294                  name: part,
27295                  header: potentialHeader,
27296                  tables: potentialTables
27297                };
27298              }
27299            }
27300          }
27301        }
27302      }
27303      if (fallbackData) {
27304        warn(`TrueType Collection does not contain "${fontName}" font, ` + `falling back to "${fallbackData.name}" font instead.`);
27305        return {
27306          header: fallbackData.header,
27307          tables: fallbackData.tables
27308        };
27309      }
27310      throw new FormatError(`TrueType Collection does not contain "${fontName}" font.`);
27311    }
27312    function readCmapTable(cmap, file, isSymbolicFont, hasEncoding) {
27313      if (!cmap) {
27314        warn("No cmap table available.");
27315        return {
27316          platformId: -1,
27317          encodingId: -1,
27318          mappings: [],
27319          hasShortCmap: false
27320        };
27321      }
27322      let segment;
27323      let start = (file.start || 0) + cmap.offset;
27324      file.pos = start;
27325      file.skip(2);
27326      const numTables = file.getUint16();
27327      let potentialTable;
27328      let canBreak = false;
27329      for (let i = 0; i < numTables; i++) {
27330        const platformId = file.getUint16();
27331        const encodingId = file.getUint16();
27332        const offset = file.getInt32() >>> 0;
27333        let useTable = false;
27334        if (potentialTable?.platformId === platformId && potentialTable?.encodingId === encodingId) {
27335          continue;
27336        }
27337        if (platformId === 0 && (encodingId === 0 || encodingId === 1 || encodingId === 3)) {
27338          useTable = true;
27339        } else if (platformId === 1 && encodingId === 0) {
27340          useTable = true;
27341        } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
27342          useTable = true;
27343          if (!isSymbolicFont) {
27344            canBreak = true;
27345          }
27346        } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
27347          useTable = true;
27348          let correctlySorted = true;
27349          if (i < numTables - 1) {
27350            const nextBytes = file.peekBytes(2),
27351              nextPlatformId = int16(nextBytes[0], nextBytes[1]);
27352            if (nextPlatformId < platformId) {
27353              correctlySorted = false;
27354            }
27355          }
27356          if (correctlySorted) {
27357            canBreak = true;
27358          }
27359        }
27360        if (useTable) {
27361          potentialTable = {
27362            platformId,
27363            encodingId,
27364            offset
27365          };
27366        }
27367        if (canBreak) {
27368          break;
27369        }
27370      }
27371      if (potentialTable) {
27372        file.pos = start + potentialTable.offset;
27373      }
27374      if (!potentialTable || file.peekByte() === -1) {
27375        warn("Could not find a preferred cmap table.");
27376        return {
27377          platformId: -1,
27378          encodingId: -1,
27379          mappings: [],
27380          hasShortCmap: false
27381        };
27382      }
27383      const format = file.getUint16();
27384      let hasShortCmap = false;
27385      const mappings = [];
27386      let j, glyphId;
27387      if (format === 0) {
27388        file.skip(2 + 2);
27389        for (j = 0; j < 256; j++) {
27390          const index = file.getByte();
27391          if (!index) {
27392            continue;
27393          }
27394          mappings.push({
27395            charCode: j,
27396            glyphId: index
27397          });
27398        }
27399        hasShortCmap = true;
27400      } else if (format === 2) {
27401        file.skip(2 + 2);
27402        const subHeaderKeys = [];
27403        let maxSubHeaderKey = 0;
27404        for (let i = 0; i < 256; i++) {
27405          const subHeaderKey = file.getUint16() >> 3;
27406          subHeaderKeys.push(subHeaderKey);
27407          maxSubHeaderKey = Math.max(subHeaderKey, maxSubHeaderKey);
27408        }
27409        const subHeaders = [];
27410        for (let i = 0; i <= maxSubHeaderKey; i++) {
27411          subHeaders.push({
27412            firstCode: file.getUint16(),
27413            entryCount: file.getUint16(),
27414            idDelta: signedInt16(file.getByte(), file.getByte()),
27415            idRangePos: file.pos + file.getUint16()
27416          });
27417        }
27418        for (let i = 0; i < 256; i++) {
27419          if (subHeaderKeys[i] === 0) {
27420            file.pos = subHeaders[0].idRangePos + 2 * i;
27421            glyphId = file.getUint16();
27422            mappings.push({
27423              charCode: i,
27424              glyphId
27425            });
27426          } else {
27427            const s = subHeaders[subHeaderKeys[i]];
27428            for (j = 0; j < s.entryCount; j++) {
27429              const charCode = (i << 8) + j + s.firstCode;
27430              file.pos = s.idRangePos + 2 * j;
27431              glyphId = file.getUint16();
27432              if (glyphId !== 0) {
27433                glyphId = (glyphId + s.idDelta) % 65536;
27434              }
27435              mappings.push({
27436                charCode,
27437                glyphId
27438              });
27439            }
27440          }
27441        }
27442      } else if (format === 4) {
27443        file.skip(2 + 2);
27444        const segCount = file.getUint16() >> 1;
27445        file.skip(6);
27446        const segments = [];
27447        let segIndex;
27448        for (segIndex = 0; segIndex < segCount; segIndex++) {
27449          segments.push({
27450            end: file.getUint16()
27451          });
27452        }
27453        file.skip(2);
27454        for (segIndex = 0; segIndex < segCount; segIndex++) {
27455          segments[segIndex].start = file.getUint16();
27456        }
27457        for (segIndex = 0; segIndex < segCount; segIndex++) {
27458          segments[segIndex].delta = file.getUint16();
27459        }
27460        let offsetsCount = 0,
27461          offsetIndex;
27462        for (segIndex = 0; segIndex < segCount; segIndex++) {
27463          segment = segments[segIndex];
27464          const rangeOffset = file.getUint16();
27465          if (!rangeOffset) {
27466            segment.offsetIndex = -1;
27467            continue;
27468          }
27469          offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
27470          segment.offsetIndex = offsetIndex;
27471          offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
27472        }
27473        const offsets = [];
27474        for (j = 0; j < offsetsCount; j++) {
27475          offsets.push(file.getUint16());
27476        }
27477        for (segIndex = 0; segIndex < segCount; segIndex++) {
27478          segment = segments[segIndex];
27479          start = segment.start;
27480          const end = segment.end;
27481          const delta = segment.delta;
27482          offsetIndex = segment.offsetIndex;
27483          for (j = start; j <= end; j++) {
27484            if (j === 0xffff) {
27485              continue;
27486            }
27487            glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
27488            glyphId = glyphId + delta & 0xffff;
27489            mappings.push({
27490              charCode: j,
27491              glyphId
27492            });
27493          }
27494        }
27495      } else if (format === 6) {
27496        file.skip(2 + 2);
27497        const firstCode = file.getUint16();
27498        const entryCount = file.getUint16();
27499        for (j = 0; j < entryCount; j++) {
27500          glyphId = file.getUint16();
27501          const charCode = firstCode + j;
27502          mappings.push({
27503            charCode,
27504            glyphId
27505          });
27506        }
27507      } else if (format === 12) {
27508        file.skip(2 + 4 + 4);
27509        const nGroups = file.getInt32() >>> 0;
27510        for (j = 0; j < nGroups; j++) {
27511          const startCharCode = file.getInt32() >>> 0;
27512          const endCharCode = file.getInt32() >>> 0;
27513          let glyphCode = file.getInt32() >>> 0;
27514          for (let charCode = startCharCode; charCode <= endCharCode; charCode++) {
27515            mappings.push({
27516              charCode,
27517              glyphId: glyphCode++
27518            });
27519          }
27520        }
27521      } else {
27522        warn("cmap table has unsupported format: " + format);
27523        return {
27524          platformId: -1,
27525          encodingId: -1,
27526          mappings: [],
27527          hasShortCmap: false
27528        };
27529      }
27530      const finalMappings = [],
27531        seenCharCodes = new Set();
27532      for (const map of mappings) {
27533        const {
27534          charCode
27535        } = map;
27536        if (seenCharCodes.has(charCode)) {
27537          continue;
27538        }
27539        seenCharCodes.add(charCode);
27540        finalMappings.push(map);
27541      }
27542      return {
27543        platformId: potentialTable.platformId,
27544        encodingId: potentialTable.encodingId,
27545        mappings: finalMappings.sort((a, b) => a.charCode - b.charCode),
27546        hasShortCmap
27547      };
27548    }
27549    function sanitizeMetrics(file, header, metrics, headTable, numGlyphs, dupFirstEntry) {
27550      if (!header) {
27551        if (metrics) {
27552          metrics.data = null;
27553        }
27554        return;
27555      }
27556      file.pos = (file.start || 0) + header.offset;
27557      file.pos += 4;
27558      file.pos += 2;
27559      file.pos += 2;
27560      file.pos += 2;
27561      file.pos += 2;
27562      file.pos += 2;
27563      file.pos += 2;
27564      file.pos += 2;
27565      file.pos += 2;
27566      file.pos += 2;
27567      const caretOffset = file.getUint16();
27568      file.pos += 8;
27569      file.pos += 2;
27570      let numOfMetrics = file.getUint16();
27571      if (caretOffset !== 0) {
27572        const macStyle = int16(headTable.data[44], headTable.data[45]);
27573        if (!(macStyle & 2)) {
27574          header.data[22] = 0;
27575          header.data[23] = 0;
27576        }
27577      }
27578      if (numOfMetrics > numGlyphs) {
27579        info(`The numOfMetrics (${numOfMetrics}) should not be ` + `greater than the numGlyphs (${numGlyphs}).`);
27580        numOfMetrics = numGlyphs;
27581        header.data[34] = (numOfMetrics & 0xff00) >> 8;
27582        header.data[35] = numOfMetrics & 0x00ff;
27583      }
27584      const numOfSidebearings = numGlyphs - numOfMetrics;
27585      const numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
27586      if (numMissing > 0) {
27587        const entries = new Uint8Array(metrics.length + numMissing * 2);
27588        entries.set(metrics.data);
27589        if (dupFirstEntry) {
27590          entries[metrics.length] = metrics.data[2];
27591          entries[metrics.length + 1] = metrics.data[3];
27592        }
27593        metrics.data = entries;
27594      }
27595    }
27596    function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
27597      const glyphProfile = {
27598        length: 0,
27599        sizeOfInstructions: 0
27600      };
27601      if (sourceStart < 0 || sourceStart >= source.length || sourceEnd > source.length || sourceEnd - sourceStart <= 12) {
27602        return glyphProfile;
27603      }
27604      const glyf = source.subarray(sourceStart, sourceEnd);
27605      const xMin = signedInt16(glyf[2], glyf[3]);
27606      const yMin = signedInt16(glyf[4], glyf[5]);
27607      const xMax = signedInt16(glyf[6], glyf[7]);
27608      const yMax = signedInt16(glyf[8], glyf[9]);
27609      if (xMin > xMax) {
27610        writeSignedInt16(glyf, 2, xMax);
27611        writeSignedInt16(glyf, 6, xMin);
27612      }
27613      if (yMin > yMax) {
27614        writeSignedInt16(glyf, 4, yMax);
27615        writeSignedInt16(glyf, 8, yMin);
27616      }
27617      const contoursCount = signedInt16(glyf[0], glyf[1]);
27618      if (contoursCount < 0) {
27619        if (contoursCount < -1) {
27620          return glyphProfile;
27621        }
27622        dest.set(glyf, destStart);
27623        glyphProfile.length = glyf.length;
27624        return glyphProfile;
27625      }
27626      let i,
27627        j = 10,
27628        flagsCount = 0;
27629      for (i = 0; i < contoursCount; i++) {
27630        const endPoint = glyf[j] << 8 | glyf[j + 1];
27631        flagsCount = endPoint + 1;
27632        j += 2;
27633      }
27634      const instructionsStart = j;
27635      const instructionsLength = glyf[j] << 8 | glyf[j + 1];
27636      glyphProfile.sizeOfInstructions = instructionsLength;
27637      j += 2 + instructionsLength;
27638      const instructionsEnd = j;
27639      let coordinatesLength = 0;
27640      for (i = 0; i < flagsCount; i++) {
27641        const flag = glyf[j++];
27642        if (flag & 0xc0) {
27643          glyf[j - 1] = flag & 0x3f;
27644        }
27645        let xLength = 2;
27646        if (flag & 2) {
27647          xLength = 1;
27648        } else if (flag & 16) {
27649          xLength = 0;
27650        }
27651        let yLength = 2;
27652        if (flag & 4) {
27653          yLength = 1;
27654        } else if (flag & 32) {
27655          yLength = 0;
27656        }
27657        const xyLength = xLength + yLength;
27658        coordinatesLength += xyLength;
27659        if (flag & 8) {
27660          const repeat = glyf[j++];
27661          if (repeat === 0) {
27662            glyf[j - 1] ^= 8;
27663          }
27664          i += repeat;
27665          coordinatesLength += repeat * xyLength;
27666        }
27667      }
27668      if (coordinatesLength === 0) {
27669        return glyphProfile;
27670      }
27671      let glyphDataLength = j + coordinatesLength;
27672      if (glyphDataLength > glyf.length) {
27673        return glyphProfile;
27674      }
27675      if (!hintsValid && instructionsLength > 0) {
27676        dest.set(glyf.subarray(0, instructionsStart), destStart);
27677        dest.set([0, 0], destStart + instructionsStart);
27678        dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
27679        glyphDataLength -= instructionsLength;
27680        if (glyf.length - glyphDataLength > 3) {
27681          glyphDataLength = glyphDataLength + 3 & ~3;
27682        }
27683        glyphProfile.length = glyphDataLength;
27684        return glyphProfile;
27685      }
27686      if (glyf.length - glyphDataLength > 3) {
27687        glyphDataLength = glyphDataLength + 3 & ~3;
27688        dest.set(glyf.subarray(0, glyphDataLength), destStart);
27689        glyphProfile.length = glyphDataLength;
27690        return glyphProfile;
27691      }
27692      dest.set(glyf, destStart);
27693      glyphProfile.length = glyf.length;
27694      return glyphProfile;
27695    }
27696    function sanitizeHead(head, numGlyphs, locaLength) {
27697      const {
27698        data,
27699        view
27700      } = head;
27701      const version = view.getInt32(0);
27702      if (version >> 16 !== 1) {
27703        info("Attempting to fix invalid version in head table: " + version);
27704        view.setInt32(0, 0x00010000);
27705      }
27706      const indexToLocFormat = signedInt16(data[50], data[51]);
27707      if (indexToLocFormat < 0 || indexToLocFormat > 1) {
27708        info("Attempting to fix invalid indexToLocFormat in head table: " + indexToLocFormat);
27709        const numGlyphsPlusOne = numGlyphs + 1;
27710        if (locaLength === numGlyphsPlusOne << 1) {
27711          data[50] = 0;
27712          data[51] = 0;
27713        } else if (locaLength === numGlyphsPlusOne << 2) {
27714          data[50] = 0;
27715          data[51] = 1;
27716        } else {
27717          throw new FormatError("Could not fix indexToLocFormat: " + indexToLocFormat);
27718        }
27719      }
27720    }
27721    function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions) {
27722      let itemSize, itemDecode, itemEncode;
27723      if (isGlyphLocationsLong) {
27724        itemSize = 4;
27725        itemDecode = function fontItemDecodeLong(data, offset) {
27726          return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
27727        };
27728        itemEncode = function fontItemEncodeLong(data, offset, value) {
27729          data[offset] = value >>> 24 & 0xff;
27730          data[offset + 1] = value >> 16 & 0xff;
27731          data[offset + 2] = value >> 8 & 0xff;
27732          data[offset + 3] = value & 0xff;
27733        };
27734      } else {
27735        itemSize = 2;
27736        itemDecode = function fontItemDecode(data, offset) {
27737          return data[offset] << 9 | data[offset + 1] << 1;
27738        };
27739        itemEncode = function fontItemEncode(data, offset, value) {
27740          data[offset] = value >> 9 & 0xff;
27741          data[offset + 1] = value >> 1 & 0xff;
27742        };
27743      }
27744      const numGlyphsOut = dupFirstEntry ? numGlyphs + 1 : numGlyphs;
27745      const locaDataSize = itemSize * (1 + numGlyphsOut);
27746      const locaData = new Uint8Array(locaDataSize);
27747      locaData.set(loca.data.subarray(0, locaDataSize));
27748      loca.data = locaData;
27749      const oldGlyfData = glyf.data;
27750      const oldGlyfDataLength = oldGlyfData.length;
27751      const newGlyfData = new Uint8Array(oldGlyfDataLength);
27752      let i, j;
27753      const locaEntries = [];
27754      for (i = 0, j = 0; i < numGlyphs + 1; i++, j += itemSize) {
27755        let offset = itemDecode(locaData, j);
27756        if (offset > oldGlyfDataLength) {
27757          offset = oldGlyfDataLength;
27758        }
27759        locaEntries.push({
27760          index: i,
27761          offset,
27762          endOffset: 0
27763        });
27764      }
27765      locaEntries.sort((a, b) => a.offset - b.offset);
27766      for (i = 0; i < numGlyphs; i++) {
27767        locaEntries[i].endOffset = locaEntries[i + 1].offset;
27768      }
27769      locaEntries.sort((a, b) => a.index - b.index);
27770      for (i = 0; i < numGlyphs; i++) {
27771        const {
27772          offset,
27773          endOffset
27774        } = locaEntries[i];
27775        if (offset !== 0 || endOffset !== 0) {
27776          break;
27777        }
27778        const nextOffset = locaEntries[i + 1].offset;
27779        if (nextOffset === 0) {
27780          continue;
27781        }
27782        locaEntries[i].endOffset = nextOffset;
27783        break;
27784      }
27785      const last = locaEntries.at(-2);
27786      if (last.offset !== 0 && last.endOffset === 0) {
27787        last.endOffset = oldGlyfDataLength;
27788      }
27789      const droppedGlyphs = pruneCompositeGlyphCycles(oldGlyfData, locaEntries, numGlyphs);
27790      const missingGlyphs = Object.create(null);
27791      let writeOffset = 0;
27792      itemEncode(locaData, 0, writeOffset);
27793      for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
27794        const glyphProfile = droppedGlyphs.has(i) ? {
27795          length: 0,
27796          sizeOfInstructions: 0
27797        } : sanitizeGlyph(oldGlyfData, locaEntries[i].offset, locaEntries[i].endOffset, newGlyfData, writeOffset, hintsValid);
27798        const newLength = glyphProfile.length;
27799        if (newLength === 0) {
27800          missingGlyphs[i] = true;
27801        }
27802        if (glyphProfile.sizeOfInstructions > maxSizeOfInstructions) {
27803          maxSizeOfInstructions = glyphProfile.sizeOfInstructions;
27804        }
27805        writeOffset += newLength;
27806        itemEncode(locaData, j, writeOffset);
27807      }
27808      if (writeOffset === 0) {
27809        const simpleGlyph = new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
27810        for (i = 0, j = itemSize; i < numGlyphsOut; i++, j += itemSize) {
27811          itemEncode(locaData, j, simpleGlyph.length);
27812        }
27813        glyf.data = simpleGlyph;
27814      } else if (dupFirstEntry) {
27815        const firstEntryLength = itemDecode(locaData, itemSize);
27816        if (newGlyfData.length > firstEntryLength + writeOffset) {
27817          glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
27818        } else {
27819          glyf.data = new Uint8Array(firstEntryLength + writeOffset);
27820          glyf.data.set(newGlyfData.subarray(0, writeOffset));
27821        }
27822        glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
27823        itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
27824      } else {
27825        glyf.data = newGlyfData.subarray(0, writeOffset);
27826      }
27827      return {
27828        missingGlyphs,
27829        maxSizeOfInstructions
27830      };
27831    }
27832    function readPostScriptTable(post, propertiesObj, maxpNumGlyphs) {
27833      const start = (font.start || 0) + post.offset;
27834      font.pos = start;
27835      const length = post.length,
27836        end = start + length;
27837      const version = font.getInt32();
27838      font.skip(28);
27839      let glyphNames;
27840      let valid = true;
27841      let i;
27842      switch (version) {
27843        case 0x00010000:
27844          glyphNames = MacStandardGlyphOrdering;
27845          break;
27846        case 0x00020000:
27847          const numGlyphs = font.getUint16();
27848          if (numGlyphs !== maxpNumGlyphs) {
27849            valid = false;
27850            break;
27851          }
27852          const glyphNameIndexes = [];
27853          for (i = 0; i < numGlyphs; ++i) {
27854            const index = font.getUint16();
27855            if (index >= 32768) {
27856              valid = false;
27857              break;
27858            }
27859            glyphNameIndexes.push(index);
27860          }
27861          if (!valid) {
27862            break;
27863          }
27864          const customNames = [];
27865          while (font.pos < end) {
27866            const strLen = font.getByte(),
27867              str = font.getString(strLen);
27868            customNames.push(str);
27869          }
27870          glyphNames = [];
27871          for (i = 0; i < numGlyphs; ++i) {
27872            const j = glyphNameIndexes[i];
27873            if (j < 258) {
27874              glyphNames.push(MacStandardGlyphOrdering[j]);
27875              continue;
27876            }
27877            glyphNames.push(customNames[j - 258]);
27878          }
27879          break;
27880        case 0x00030000:
27881          break;
27882        default:
27883          warn("Unknown/unsupported post table version " + version);
27884          valid = false;
27885          if (propertiesObj.defaultEncoding) {
27886            glyphNames = propertiesObj.defaultEncoding;
27887          }
27888          break;
27889      }
27890      propertiesObj.glyphNames = glyphNames;
27891      return valid;
27892    }
27893    function readNameTable(nameTable) {
27894      const start = (font.start || 0) + nameTable.offset;
27895      font.pos = start;
27896      const names = [[], []],
27897        records = [];
27898      const length = nameTable.length,
27899        end = start + length;
27900      const format = font.getUint16();
27901      const FORMAT_0_HEADER_LENGTH = 6;
27902      if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
27903        return [names, records];
27904      }
27905      const numRecords = font.getUint16();
27906      const stringsStart = font.getUint16();
27907      const NAME_RECORD_LENGTH = 12;
27908      let i, ii;
27909      for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
27910        const r = {
27911          platform: font.getUint16(),
27912          encoding: font.getUint16(),
27913          language: font.getUint16(),
27914          name: font.getUint16(),
27915          length: font.getUint16(),
27916          offset: font.getUint16()
27917        };
27918        if (isMacNameRecord(r) || isWinNameRecord(r)) {
27919          records.push(r);
27920        }
27921      }
27922      for (i = 0, ii = records.length; i < ii; i++) {
27923        const record = records[i];
27924        if (record.length <= 0) {
27925          continue;
27926        }
27927        const pos = start + stringsStart + record.offset;
27928        if (pos + record.length > end) {
27929          continue;
27930        }
27931        font.pos = pos;
27932        const nameIndex = record.name;
27933        if (record.encoding) {
27934          let str = "";
27935          for (let j = 0, jj = record.length; j < jj; j += 2) {
27936            str += String.fromCharCode(font.getUint16());
27937          }
27938          names[1][nameIndex] = str;
27939        } else {
27940          names[0][nameIndex] = font.getString(record.length);
27941        }
27942      }
27943      return [names, records];
27944    }
27945    const TTOpsStackDeltas = [0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1, 1, -1, -999, 0, 1, 0, -1, -2, 0, -1, -2, -1, -1, 0, -1, -1, 0, 0, -999, -999, -1, -1, -1, -1, -2, -999, -2, -2, -999, 0, -2, -2, 0, 0, -2, 0, -2, 0, 0, 0, -2, -1, -1, 1, 1, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -999, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -999, -999, -999, -999, -999, -1, -1, -2, -2, 0, 0, 0, 0, -1, -1, -999, -2, -2, 0, 0, -1, -2, -2, 0, 0, 0, -1, -1, -1, -2];
27946    function sanitizeTTProgram(table, ttContext) {
27947      let data = table.data;
27948      let i = 0,
27949        j,
27950        n,
27951        b,
27952        funcId,
27953        pc,
27954        lastEndf = 0,
27955        lastDeff = 0;
27956      const stack = [];
27957      const callstack = [];
27958      const functionsCalled = [];
27959      let tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
27960      let inFDEF = false,
27961        ifLevel = 0,
27962        inELSE = 0;
27963      for (let ii = data.length; i < ii;) {
27964        const op = data[i++];
27965        if (op === 0x40) {
27966          n = data[i++];
27967          if (inFDEF || inELSE) {
27968            i += n;
27969          } else {
27970            for (j = 0; j < n; j++) {
27971              stack.push(data[i++]);
27972            }
27973          }
27974        } else if (op === 0x41) {
27975          n = data[i++];
27976          if (inFDEF || inELSE) {
27977            i += n * 2;
27978          } else {
27979            for (j = 0; j < n; j++) {
27980              b = data[i++];
27981              stack.push(signedInt16(b, data[i++]));
27982            }
27983          }
27984        } else if ((op & 0xf8) === 0xb0) {
27985          n = op - 0xb0 + 1;
27986          if (inFDEF || inELSE) {
27987            i += n;
27988          } else {
27989            for (j = 0; j < n; j++) {
27990              stack.push(data[i++]);
27991            }
27992          }
27993        } else if ((op & 0xf8) === 0xb8) {
27994          n = op - 0xb8 + 1;
27995          if (inFDEF || inELSE) {
27996            i += n * 2;
27997          } else {
27998            for (j = 0; j < n; j++) {
27999              b = data[i++];
28000              stack.push(signedInt16(b, data[i++]));
28001            }
28002          }
28003        } else if (op === 0x2b && !tooComplexToFollowFunctions) {
28004          if (!inFDEF && !inELSE) {
28005            funcId = stack.at(-1);
28006            if (isNaN(funcId)) {
28007              info("TT: CALL empty stack (or invalid entry).");
28008            } else {
28009              ttContext.functionsUsed[funcId] = true;
28010              if (funcId in ttContext.functionsStackDeltas) {
28011                const newStackLength = stack.length + ttContext.functionsStackDeltas[funcId];
28012                if (newStackLength < 0) {
28013                  warn("TT: CALL invalid functions stack delta.");
28014                  ttContext.hintsValid = false;
28015                  return;
28016                }
28017                stack.length = newStackLength;
28018              } else if (funcId in ttContext.functionsDefined && !functionsCalled.includes(funcId)) {
28019                callstack.push({
28020                  data,
28021                  i,
28022                  stackTop: stack.length - 1
28023                });
28024                functionsCalled.push(funcId);
28025                pc = ttContext.functionsDefined[funcId];
28026                if (!pc) {
28027                  warn("TT: CALL non-existent function");
28028                  ttContext.hintsValid = false;
28029                  return;
28030                }
28031                data = pc.data;
28032                i = pc.i;
28033              }
28034            }
28035          }
28036        } else if (op === 0x2c && !tooComplexToFollowFunctions) {
28037          if (inFDEF || inELSE) {
28038            warn("TT: nested FDEFs not allowed");
28039            tooComplexToFollowFunctions = true;
28040          }
28041          inFDEF = true;
28042          lastDeff = i;
28043          funcId = stack.pop();
28044          ttContext.functionsDefined[funcId] = {
28045            data,
28046            i
28047          };
28048        } else if (op === 0x2d) {
28049          if (inFDEF) {
28050            inFDEF = false;
28051            lastEndf = i;
28052          } else {
28053            pc = callstack.pop();
28054            if (!pc) {
28055              warn("TT: ENDF bad stack");
28056              ttContext.hintsValid = false;
28057              return;
28058            }
28059            funcId = functionsCalled.pop();
28060            data = pc.data;
28061            i = pc.i;
28062            ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
28063          }
28064        } else if (op === 0x89) {
28065          if (inFDEF || inELSE) {
28066            warn("TT: nested IDEFs not allowed");
28067            tooComplexToFollowFunctions = true;
28068          }
28069          inFDEF = true;
28070          lastDeff = i;
28071        } else if (op === 0x58) {
28072          ++ifLevel;
28073        } else if (op === 0x1b) {
28074          inELSE = ifLevel;
28075        } else if (op === 0x59) {
28076          if (inELSE === ifLevel) {
28077            inELSE = 0;
28078          }
28079          --ifLevel;
28080        } else if (op === 0x1c) {
28081          if (!inFDEF && !inELSE) {
28082            const offset = stack.at(-1);
28083            if (offset > 0) {
28084              i += offset - 1;
28085            }
28086          }
28087        }
28088        if (!inFDEF && !inELSE) {
28089          let stackDelta = 0;
28090          if (op <= 0x8e) {
28091            stackDelta = TTOpsStackDeltas[op];
28092          } else if (op >= 0xc0 && op <= 0xdf) {
28093            stackDelta = -1;
28094          } else if (op >= 0xe0) {
28095            stackDelta = -2;
28096          }
28097          if (op >= 0x71 && op <= 0x75) {
28098            n = stack.pop();
28099            if (!isNaN(n)) {
28100              stackDelta = -n * 2;
28101            }
28102          }
28103          while (stackDelta < 0 && stack.length > 0) {
28104            stack.pop();
28105            stackDelta++;
28106          }
28107          while (stackDelta > 0) {
28108            stack.push(NaN);
28109            stackDelta--;
28110          }
28111        }
28112      }
28113      ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
28114      const content = [data];
28115      if (i > data.length) {
28116        content.push(new Uint8Array(i - data.length));
28117      }
28118      if (lastDeff > lastEndf) {
28119        warn("TT: complementing a missing function tail");
28120        content.push(new Uint8Array([0x22, 0x2d]));
28121      }
28122      foldTTTable(table, content);
28123    }
28124    function checkInvalidFunctions(ttContext, maxFunctionDefs) {
28125      if (ttContext.tooComplexToFollowFunctions) {
28126        return;
28127      }
28128      if (ttContext.functionsDefined.length > maxFunctionDefs) {
28129        warn("TT: more functions defined than expected");
28130        ttContext.hintsValid = false;
28131        return;
28132      }
28133      for (let j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
28134        if (j > maxFunctionDefs) {
28135          warn("TT: invalid function id: " + j);
28136          ttContext.hintsValid = false;
28137          return;
28138        }
28139        if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
28140          warn("TT: undefined function: " + j);
28141          ttContext.hintsValid = false;
28142          return;
28143        }
28144      }
28145    }
28146    function foldTTTable(table, content) {
28147      if (content.length > 1) {
28148        let newLength = 0;
28149        let j, jj;
28150        for (j = 0, jj = content.length; j < jj; j++) {
28151          newLength += content[j].length;
28152        }
28153        newLength = newLength + 3 & ~3;
28154        const result = new Uint8Array(newLength);
28155        let pos = 0;
28156        for (j = 0, jj = content.length; j < jj; j++) {
28157          result.set(content[j], pos);
28158          pos += content[j].length;
28159        }
28160        table.data = result;
28161        table.length = newLength;
28162      }
28163    }
28164    function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
28165      const ttContext = {
28166        functionsDefined: [],
28167        functionsUsed: [],
28168        functionsStackDeltas: [],
28169        tooComplexToFollowFunctions: false,
28170        hintsValid: true
28171      };
28172      if (fpgm) {
28173        sanitizeTTProgram(fpgm, ttContext);
28174      }
28175      if (prep) {
28176        sanitizeTTProgram(prep, ttContext);
28177      }
28178      if (fpgm) {
28179        checkInvalidFunctions(ttContext, maxFunctionDefs);
28180      }
28181      if (cvt && cvt.length & 1) {
28182        const cvtData = new Uint8Array(cvt.length + 1);
28183        cvtData.set(cvt.data);
28184        cvt.data = cvtData;
28185      }
28186      return ttContext.hintsValid;
28187    }
28188    font = new Stream(new Uint8Array(font.getBytes()));
28189    let header, tables;
28190    if (isTrueTypeCollectionFile(font)) {
28191      const ttcData = readTrueTypeCollectionData(font, this.name);
28192      header = ttcData.header;
28193      tables = ttcData.tables;
28194    } else {
28195      header = readOpenTypeHeader(font);
28196      tables = readTables(font, header.numTables);
28197    }
28198    const isTrueType = !tables["CFF "];
28199    let parsedCff = null;
28200    if (!isTrueType) {
28201      try {
28202        parsedCff = new CFFParser(new Stream(tables["CFF "].data), properties, 
28202SEAC_ANALYSIS_ENABLED
vendor: 14,856 bytes, lines 28202-28579
28202).parse();
28203      } catch {
28204        warn("Failed to parse font " + properties.loadedName);
28205      }
28206      if (header.version === "OTTO" && (!properties.composite || properties.fontFileN === "FontFile3" && parsedCff?.isCIDFont) || !tables.head || !tables.hhea || !tables.maxp || !tables.post) {
28207        return this.convert(name, new CFFFont(new Stream(tables["CFF "].data), properties), properties);
28208      }
28209      delete tables.glyf;
28210      delete tables.loca;
28211      delete tables.fpgm;
28212      delete tables.prep;
28213      delete tables["cvt "];
28214      this.isOpenType = true;
28215    } else {
28216      if (!tables.loca) {
28217        throw new FormatError('Required "loca" table is not found');
28218      }
28219      if (!tables.glyf) {
28220        warn('Required "glyf" table is not found -- trying to recover.');
28221        tables.glyf = {
28222          tag: "glyf",
28223          data: new Uint8Array(0)
28224        };
28225      }
28226      this.isOpenType = false;
28227    }
28228    if (!tables.maxp) {
28229      throw new FormatError('Required "maxp" table is not found');
28230    }
28231    let numGlyphsFromCFF;
28232    if (parsedCff) {
28233      try {
28234        parsedCff.duplicateFirstGlyph();
28235        tables["CFF "].data = new CFFCompiler(parsedCff).compile();
28236        numGlyphsFromCFF = parsedCff.charStringCount;
28237      } catch {
28238        warn("Failed to compile font " + properties.loadedName);
28239      }
28240    }
28241    font.pos = (font.start || 0) + tables.maxp.offset;
28242    let version = font.getInt32();
28243    const numGlyphs = numGlyphsFromCFF ?? font.getUint16();
28244    if (version === 0x00005000 && tables.maxp.length !== 6) {
28245      tables.maxp.data = tables.maxp.data.subarray(0, 6);
28246      tables.maxp.length = 6;
28247    }
28248    if (version !== 0x00010000 && version !== 0x00005000) {
28249      if (tables.maxp.length === 6) {
28250        version = 0x0005000;
28251      } else if (tables.maxp.length >= 32) {
28252        version = 0x00010000;
28253      } else {
28254        throw new FormatError(`"maxp" table has a wrong version number`);
28255      }
28256      writeUint32(tables.maxp.data, 0, version);
28257    }
28258    let isGlyphLocationsLong = int16(tables.head.data[50], tables.head.data[51]);
28259    if (tables.loca) {
28260      const locaLength = isGlyphLocationsLong ? (numGlyphs + 1) * 4 : (numGlyphs + 1) * 2;
28261      if (tables.loca.length !== locaLength) {
28262        warn("Incorrect 'loca' table length -- attempting to fix it.");
28263        const sortedTables = Object.values(tables).filter(Boolean).sort((a, b) => a.offset - b.offset);
28264        const locaIndex = sortedTables.indexOf(tables.loca);
28265        const nextTable = sortedTables[locaIndex + 1] || null;
28266        if (nextTable && tables.loca.offset + locaLength < nextTable.offset) {
28267          const previousPos = font.pos;
28268          font.pos = font.start || 0;
28269          font.skip(tables.loca.offset);
28270          tables.loca.data = font.getBytes(locaLength);
28271          tables.loca.length = locaLength;
28272          font.pos = previousPos;
28273        }
28274      }
28275    }
28276    if (properties.scaleFactors?.length === numGlyphs && isTrueType) {
28277      const {
28278        scaleFactors
28279      } = properties;
28280      const glyphs = new GlyfTable({
28281        glyfTable: tables.glyf.data,
28282        isGlyphLocationsLong,
28283        locaTable: tables.loca.data,
28284        numGlyphs
28285      });
28286      glyphs.scale(scaleFactors);
28287      const {
28288        glyf,
28289        loca,
28290        isLocationLong
28291      } = glyphs.write();
28292      tables.glyf.data = glyf;
28293      tables.loca.data = loca;
28294      if (isLocationLong !== !!isGlyphLocationsLong) {
28295        tables.head.data[50] = 0;
28296        isGlyphLocationsLong = tables.head.data[51] = isLocationLong ? 1 : 0;
28297      }
28298      const metrics = tables.hmtx.data;
28299      for (let i = 0; i < numGlyphs; i++) {
28300        const j = 4 * i;
28301        const advanceWidth = Math.round(scaleFactors[i] * int16(metrics[j], metrics[j + 1]));
28302        metrics[j] = advanceWidth >> 8 & 0xff;
28303        metrics[j + 1] = advanceWidth & 0xff;
28304        const lsb = Math.round(scaleFactors[i] * signedInt16(metrics[j + 2], metrics[j + 3]));
28305        writeSignedInt16(metrics, j + 2, lsb);
28306      }
28307    }
28308    let numGlyphsOut = numGlyphs + 1;
28309    let dupFirstEntry = true;
28310    if (numGlyphsOut > 0xffff) {
28311      dupFirstEntry = false;
28312      numGlyphsOut = numGlyphs;
28313      warn("Not enough space in glyfs to duplicate first glyph.");
28314    }
28315    let maxFunctionDefs = 0;
28316    let maxSizeOfInstructions = 0;
28317    if (version >= 0x00010000 && tables.maxp.length >= 32) {
28318      font.pos += 8;
28319      const maxZones = font.getUint16();
28320      if (maxZones > 2) {
28321        tables.maxp.data[14] = 0;
28322        tables.maxp.data[15] = 2;
28323      }
28324      font.pos += 4;
28325      maxFunctionDefs = font.getUint16();
28326      font.pos += 4;
28327      maxSizeOfInstructions = font.getUint16();
28328    } else if (isTrueType && version === 0x00005000) {
28329      const newMaxp = new Uint8Array(32);
28330      writeUint32(newMaxp, 0, 0x00010000);
28331      newMaxp[4] = numGlyphs >> 8 & 0xff;
28332      newMaxp[5] = numGlyphs & 0xff;
28333      newMaxp.fill(0xff, 6, 14);
28334      newMaxp[15] = 2;
28335      newMaxp[28] = 0xff;
28336      newMaxp[29] = 0xff;
28337      newMaxp[31] = 0x10;
28338      tables.maxp.data = newMaxp;
28339      tables.maxp.length = 32;
28340      version = 0x00010000;
28341    }
28342    tables.maxp.data[4] = numGlyphsOut >> 8;
28343    tables.maxp.data[5] = numGlyphsOut & 255;
28344    const hintsValid = sanitizeTTPrograms(tables.fpgm, tables.prep, tables["cvt "], maxFunctionDefs);
28345    if (!hintsValid) {
28346      delete tables.fpgm;
28347      delete tables.prep;
28348      delete tables["cvt "];
28349    }
28350    sanitizeMetrics(font, tables.hhea, tables.hmtx, tables.head, numGlyphsOut, dupFirstEntry);
28351    if (!tables.head) {
28352      throw new FormatError('Required "head" table is not found');
28353    }
28354    sanitizeHead(tables.head, numGlyphs, isTrueType ? tables.loca.length : 0);
28355    let missingGlyphs = Object.create(null);
28356    if (isTrueType) {
28357      const glyphsInfo = sanitizeGlyphLocations(tables.loca, tables.glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions);
28358      missingGlyphs = glyphsInfo.missingGlyphs;
28359      if (version >= 0x00010000 && tables.maxp.length >= 32) {
28360        tables.maxp.data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
28361        tables.maxp.data[27] = glyphsInfo.maxSizeOfInstructions & 255;
28362      }
28363    }
28364    if (!tables.hhea) {
28365      throw new FormatError('Required "hhea" table is not found');
28366    }
28367    if (tables.hhea.data[10] === 0 && tables.hhea.data[11] === 0) {
28368      tables.hhea.data[10] = 0xff;
28369      tables.hhea.data[11] = 0xff;
28370    }
28371    const metricsOverride = {
28372      unitsPerEm: int16(tables.head.data[18], tables.head.data[19]),
28373      yMax: signedInt16(tables.head.data[42], tables.head.data[43]),
28374      yMin: signedInt16(tables.head.data[38], tables.head.data[39]),
28375      ascent: signedInt16(tables.hhea.data[4], tables.hhea.data[5]),
28376      descent: signedInt16(tables.hhea.data[6], tables.hhea.data[7]),
28377      lineGap: signedInt16(tables.hhea.data[8], tables.hhea.data[9])
28378    };
28379    this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
28380    this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
28381    this.lineGap = metricsOverride.lineGap / metricsOverride.unitsPerEm;
28382    if (this.cssFontInfo?.lineHeight) {
28383      this.lineHeight = this.cssFontInfo.metrics.lineHeight;
28384      this.lineGap = this.cssFontInfo.metrics.lineGap;
28385    } else {
28386      this.lineHeight = this.ascent - this.descent + this.lineGap;
28387    }
28388    if (tables.post) {
28389      readPostScriptTable(tables.post, properties, numGlyphs);
28390    }
28391    tables.post = {
28392      tag: "post",
28393      data: createPostTable(properties)
28394    };
28395    const charCodeToGlyphId = Object.create(null);
28396    function hasGlyph(glyphId) {
28397      return !missingGlyphs[glyphId];
28398    }
28399    if (properties.composite) {
28400      const cidToGidMap = properties.cidToGidMap || [];
28401      const isCidToGidMapEmpty = cidToGidMap.length === 0;
28402      properties.cMap.forEach(function (charCode, cid) {
28403        if (typeof cid === "string") {
28404          cid = convertCidString(charCode, cid, true);
28405        }
28406        if (cid > 0xffff) {
28407          throw new FormatError("Max size of CID is 65,535");
28408        }
28409        let glyphId = -1;
28410        if (isCidToGidMapEmpty) {
28411          glyphId = cid;
28412        } else if (cidToGidMap[cid] !== undefined) {
28413          glyphId = cidToGidMap[cid];
28414        }
28415        if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId)) {
28416          charCodeToGlyphId[charCode] = glyphId;
28417        }
28418      });
28419    } else {
28420      const cmapTable = readCmapTable(tables.cmap, font, this.isSymbolicFont, properties.hasEncoding);
28421      const cmapPlatformId = cmapTable.platformId;
28422      const cmapEncodingId = cmapTable.encodingId;
28423      const cmapMappings = cmapTable.mappings;
28424      let baseEncoding = [],
28425        forcePostTable = false;
28426      if (properties.hasEncoding && (properties.baseEncodingName === "MacRomanEncoding" || properties.baseEncodingName === "WinAnsiEncoding")) {
28427        baseEncoding = getEncoding(properties.baseEncodingName);
28428      }
28429      if (properties.hasEncoding && !this.isSymbolicFont && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0)) {
28430        const glyphsUnicodeMap = getGlyphsUnicode();
28431        for (let charCode = 0; charCode < 256; charCode++) {
28432          let glyphName;
28433          if (this.differences[charCode] !== undefined) {
28434            glyphName = this.differences[charCode];
28435          } else if (baseEncoding.length && baseEncoding[charCode] !== "") {
28436            glyphName = baseEncoding[charCode];
28437          } else {
28438            glyphName = StandardEncoding[charCode];
28439          }
28440          if (!glyphName) {
28441            continue;
28442          }
28443          const standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
28444          let unicodeOrCharCode;
28445          if (cmapPlatformId === 3 && cmapEncodingId === 1) {
28446            unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
28447          } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
28448            unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
28449          }
28450          if (unicodeOrCharCode === undefined) {
28451            if (!properties.glyphNames && properties.hasIncludedToUnicodeMap && !(this.toUnicode instanceof IdentityToUnicodeMap)) {
28452              const unicode = this.toUnicode.get(charCode);
28453              if (unicode) {
28454                unicodeOrCharCode = unicode.codePointAt(0);
28455              }
28456            }
28457            if (unicodeOrCharCode === undefined) {
28458              continue;
28459            }
28460          }
28461          for (const mapping of cmapMappings) {
28462            if (mapping.charCode !== unicodeOrCharCode) {
28463              continue;
28464            }
28465            charCodeToGlyphId[charCode] = mapping.glyphId;
28466            break;
28467          }
28468        }
28469      } else if (cmapPlatformId === 0) {
28470        for (const mapping of cmapMappings) {
28471          charCodeToGlyphId[mapping.charCode] = mapping.glyphId;
28472        }
28473        forcePostTable = true;
28474      } else if (cmapPlatformId === 3 && cmapEncodingId === 0) {
28475        for (const mapping of cmapMappings) {
28476          let charCode = mapping.charCode;
28477          if (charCode >= 0xf000 && charCode <= 0xf0ff) {
28478            charCode &= 0xff;
28479          }
28480          charCodeToGlyphId[charCode] = mapping.glyphId;
28481        }
28482      } else {
28483        for (const mapping of cmapMappings) {
28484          charCodeToGlyphId[mapping.charCode] = mapping.glyphId;
28485        }
28486      }
28487      if (properties.glyphNames && (baseEncoding.length || this.differences.length)) {
28488        for (let i = 0; i < 256; ++i) {
28489          if (!forcePostTable && charCodeToGlyphId[i] !== undefined) {
28490            continue;
28491          }
28492          const glyphName = this.differences[i] || baseEncoding[i];
28493          if (!glyphName) {
28494            continue;
28495          }
28496          const glyphId = properties.glyphNames.indexOf(glyphName);
28497          if (glyphId > 0 && hasGlyph(glyphId)) {
28498            charCodeToGlyphId[i] = glyphId;
28499          }
28500        }
28501      }
28502      if (!properties.isInternalFont && charCodeToGlyphId[0] === undefined && hasGlyph(0)) {
28503        charCodeToGlyphId[0] = 0;
28504      }
28505    }
28506    if (charCodeToGlyphId.length === 0) {
28507      charCodeToGlyphId[0] = 0;
28508    }
28509    const glyphZeroId = dupFirstEntry ? numGlyphsOut - 1 : 0;
28510    if (!properties.cssFontInfo) {
28511      const newMapping = adjustMapping(charCodeToGlyphId, hasGlyph, glyphZeroId, this.toUnicode);
28512      this.toFontChar = newMapping.toFontChar;
28513      tables.cmap = {
28514        tag: "cmap",
28515        data: createCmapTable(newMapping.charCodeToGlyphId, newMapping.toUnicodeExtraMap, numGlyphsOut)
28516      };
28517      if (!tables["OS/2"] || !validateOS2Table(tables["OS/2"], font)) {
28518        tables["OS/2"] = {
28519          tag: "OS/2",
28520          data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
28521        };
28522      }
28523    }
28524    if (!tables.name) {
28525      tables.name = {
28526        tag: "name",
28527        data: createNameTable(this.name)
28528      };
28529    } else {
28530      const [namePrototype, nameRecords] = readNameTable(tables.name);
28531      tables.name.data = createNameTable(name, namePrototype);
28532      this.psName = namePrototype[0][6] || null;
28533      if (!properties.composite) {
28534        adjustTrueTypeToUnicode(properties, this.isSymbolicFont, nameRecords);
28535      }
28536    }
28537    const builder = new OpenTypeFileBuilder(header.version);
28538    for (const tableTag in tables) {
28539      builder.addTable(tableTag, tables[tableTag].data);
28540    }
28541    return builder.toArray();
28542  }
28543  convert(fontName, font, properties) {
28544    properties.fixedPitch = false;
28545    if (properties.builtInEncoding) {
28546      adjustType1ToUnicode(properties, properties.builtInEncoding);
28547    }
28548    const glyphZeroId = font instanceof CFFFont ? font.numGlyphs - 1 : 1;
28549    const mapping = font.getGlyphMapping(properties);
28550    let newMapping = null;
28551    let newCharCodeToGlyphId = mapping;
28552    let toUnicodeExtraMap = null;
28553    if (!properties.cssFontInfo) {
28554      newMapping = adjustMapping(mapping, font.hasGlyphId.bind(font), glyphZeroId, this.toUnicode);
28555      this.toFontChar = newMapping.toFontChar;
28556      newCharCodeToGlyphId = newMapping.charCodeToGlyphId;
28557      toUnicodeExtraMap = newMapping.toUnicodeExtraMap;
28558    }
28559    const numGlyphs = font.numGlyphs;
28560    function getCharCodes(charCodeToGlyphId, glyphId) {
28561      let charCodes = null;
28562      for (const charCode in charCodeToGlyphId) {
28563        if (glyphId === charCodeToGlyphId[charCode]) {
28564          (charCodes ||= []).push(charCode | 0);
28565        }
28566      }
28567      return charCodes;
28568    }
28569    function createCharCode(charCodeToGlyphId, glyphId) {
28570      for (const charCode in charCodeToGlyphId) {
28571        if (glyphId === charCodeToGlyphId[charCode]) {
28572          return charCode | 0;
28573        }
28574      }
28575      newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
28576      return newMapping.nextAvailableFontCharCode++;
28577    }
28578    const seacs = font.seacs;
28579    if (newMapping && 
28579SEAC_ANALYSIS_ENABLED
vendor: 9,224 bytes, lines 28579-28842
28579 && seacs?.length) {
28580      const matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
28581      const charset = font.getCharset();
28582      const seacMap = Object.create(null);
28583      for (let glyphId in seacs) {
28584        glyphId |= 0;
28585        const seac = seacs[glyphId];
28586        const baseGlyphName = StandardEncoding[seac[2]];
28587        const accentGlyphName = StandardEncoding[seac[3]];
28588        const baseGlyphId = charset.indexOf(baseGlyphName);
28589        const accentGlyphId = charset.indexOf(accentGlyphName);
28590        if (baseGlyphId < 0 || accentGlyphId < 0) {
28591          continue;
28592        }
28593        const accentOffset = {
28594          x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
28595          y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
28596        };
28597        const charCodes = getCharCodes(mapping, glyphId);
28598        if (!charCodes) {
28599          continue;
28600        }
28601        for (const charCode of charCodes) {
28602          const charCodeToGlyphId = newMapping.charCodeToGlyphId;
28603          const baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
28604          const accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
28605          seacMap[charCode] = {
28606            baseFontCharCode,
28607            accentFontCharCode,
28608            accentOffset
28609          };
28610        }
28611      }
28612      properties.seacMap = seacMap;
28613    }
28614    const unitsPerEm = properties.fontMatrix ? 1 / Math.max(...properties.fontMatrix.slice(0, 4).map(Math.abs)) : 1000;
28615    const builder = new OpenTypeFileBuilder("\x4F\x54\x54\x4F");
28616    builder.addTable("CFF ", font.data);
28617    builder.addTable("OS/2", createOS2Table(properties, newCharCodeToGlyphId));
28618    builder.addTable("cmap", createCmapTable(newCharCodeToGlyphId, toUnicodeExtraMap, numGlyphs));
28619    builder.addTable("head", function fontTableHead() {
28620      const dateArr = [0x00, 0x00, 0x00, 0x00, 0x9e, 0x0b, 0x7e, 0x27];
28621      const head = new DataBuilder({
28622        exactLength: 54
28623      });
28624      head.setArray([0x00, 0x01, 0x00, 0x00]);
28625      head.setArray([0x00, 0x00, 0x10, 0x00]);
28626      head.skip(4);
28627      head.setArray([0x5f, 0x0f, 0x3c, 0xf5]);
28628      head.skip(2);
28629      head.setSafeInt16(unitsPerEm);
28630      head.setArray(dateArr);
28631      head.setArray(dateArr);
28632      head.skip(2);
28633      head.setSafeInt16(properties.descent);
28634      head.setArray([0x0f, 0xff]);
28635      head.setSafeInt16(properties.ascent);
28636      head.setInt16(properties.italicAngle ? 2 : 0);
28637      head.setArray([0x00, 0x11]);
28638      head.skip(2 + 2 + 2);
28639      return head.data;
28640    }());
28641    builder.addTable("hhea", function fontTableHhea() {
28642      const hhea = new DataBuilder({
28643        exactLength: 36
28644      });
28645      hhea.setArray([0x00, 0x01, 0x00, 0x00]);
28646      hhea.setSafeInt16(properties.ascent);
28647      hhea.setSafeInt16(properties.descent);
28648      hhea.skip(2);
28649      hhea.setArray([0xff, 0xff]);
28650      hhea.skip(2 + 2 + 2);
28651      hhea.setSafeInt16(properties.capHeight);
28652      hhea.setSafeInt16(Math.tan(properties.italicAngle) * properties.xHeight);
28653      hhea.skip(2 + 2 + 2 + 2 + 2 + 2);
28654      hhea.setInt16(numGlyphs);
28655      return hhea.data;
28656    }());
28657    builder.addTable("hmtx", function fontTableHmtx() {
28658      const charstrings = font.charstrings;
28659      const cffWidths = font.cff?.widths ?? null;
28660      const hmtx = new DataBuilder({
28661        exactLength: numGlyphs * 4
28662      });
28663      hmtx.skip(4);
28664      for (let i = 1, ii = numGlyphs; i < ii; i++) {
28665        let width = 0;
28666        if (charstrings) {
28667          width = charstrings[i - 1].width || 0;
28668        } else if (cffWidths) {
28669          width = Math.ceil(cffWidths[i] || 0);
28670        }
28671        hmtx.setInt16(width);
28672        hmtx.skip(2);
28673      }
28674      return hmtx.data;
28675    }());
28676    builder.addTable("maxp", function fontTableMaxp() {
28677      const maxp = new DataBuilder({
28678        exactLength: 6
28679      });
28680      maxp.setArray([0x00, 0x00, 0x50, 0x00]);
28681      maxp.setInt16(numGlyphs);
28682      return maxp.data;
28683    }());
28684    builder.addTable("name", createNameTable(fontName));
28685    builder.addTable("post", createPostTable(properties));
28686    return builder.toArray();
28687  }
28688  get _spaceWidth() {
28689    const possibleSpaceReplacements = ["space", "minus", "one", "i", "I"];
28690    let width;
28691    for (const glyphName of possibleSpaceReplacements) {
28692      if (glyphName in this.widths) {
28693        width = this.widths[glyphName];
28694        break;
28695      }
28696      const glyphsUnicodeMap = getGlyphsUnicode();
28697      const glyphUnicode = glyphsUnicodeMap[glyphName];
28698      let charcode = 0;
28699      if (this.composite && this.cMap.contains(glyphUnicode)) {
28700        charcode = this.cMap.lookup(glyphUnicode);
28701        if (typeof charcode === "string") {
28702          charcode = convertCidString(glyphUnicode, charcode);
28703        }
28704      }
28705      if (!charcode && this.toUnicode) {
28706        charcode = this.toUnicode.charCodeOf(glyphUnicode);
28707      }
28708      if (charcode <= 0) {
28709        charcode = glyphUnicode;
28710      }
28711      width = this.widths[charcode];
28712      if (width) {
28713        break;
28714      }
28715    }
28716    return shadow(this, "_spaceWidth", width || this.defaultWidth);
28717  }
28718  _charToGlyph(charcode, isSpace = false) {
28719    let glyph = this.#glyphCache.get(charcode);
28720    if (glyph?.isSpace === isSpace) {
28721      return glyph;
28722    }
28723    let fontCharCode, width, operatorListId;
28724    let widthCode = charcode;
28725    if (this.cMap?.contains(charcode)) {
28726      widthCode = this.cMap.lookup(charcode);
28727      if (typeof widthCode === "string") {
28728        widthCode = convertCidString(charcode, widthCode);
28729      }
28730    }
28731    width = this.widths[widthCode];
28732    if (typeof width !== "number") {
28733      width = this.defaultWidth;
28734    }
28735    const vmetric = this.vmetrics?.[widthCode] || this.defaultVMetrics;
28736    let unicode = this.toUnicode.get(charcode) || charcode;
28737    if (typeof unicode === "number") {
28738      unicode = String.fromCharCode(unicode);
28739    }
28740    let isInFont = this.toFontChar[charcode] !== undefined;
28741    fontCharCode = this.toFontChar[charcode] || charcode;
28742    if (this.missingFile) {
28743      const glyphName = this.differences[charcode] || this.defaultEncoding[charcode];
28744      if ((glyphName === ".notdef" || glyphName === "") && this.type === "Type1") {
28745        fontCharCode = 0x20;
28746        if (glyphName === "") {
28747          width ||= this._spaceWidth;
28748          unicode = String.fromCharCode(fontCharCode);
28749        }
28750      }
28751      fontCharCode = mapSpecialUnicodeValues(fontCharCode);
28752    }
28753    if (this.isType3Font) {
28754      operatorListId = fontCharCode;
28755    }
28756    let accent = null;
28757    if (this.seacMap?.[charcode]) {
28758      isInFont = true;
28759      const seac = this.seacMap[charcode];
28760      fontCharCode = seac.baseFontCharCode;
28761      accent = {
28762        fontChar: String.fromCodePoint(seac.accentFontCharCode),
28763        offset: seac.accentOffset
28764      };
28765    }
28766    let fontChar = "";
28767    if (typeof fontCharCode === "number") {
28768      if (fontCharCode <= 0x10ffff) {
28769        fontChar = String.fromCodePoint(fontCharCode);
28770      } else {
28771        warn(`charToGlyph - invalid fontCharCode: ${fontCharCode}`);
28772      }
28773    }
28774    if (this.missingFile && this.vertical && fontChar.length === 1) {
28775      const vertical = getVerticalPresentationForm()[fontChar.charCodeAt(0)];
28776      if (vertical) {
28777        fontChar = unicode = String.fromCharCode(vertical);
28778      }
28779    }
28780    glyph = new fonts_Glyph(charcode, fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
28781    this.#glyphCache.set(charcode, glyph);
28782    return glyph;
28783  }
28784  charsToGlyphs(chars) {
28785    let glyphs = this.#charsCache.get(chars);
28786    if (glyphs) {
28787      return glyphs;
28788    }
28789    glyphs = [];
28790    if (this.cMap) {
28791      const c = Object.create(null),
28792        ii = chars.length;
28793      let i = 0;
28794      while (i < ii) {
28795        this.cMap.readCharCode(chars, i, c);
28796        const {
28797          charcode,
28798          length
28799        } = c;
28800        i += length;
28801        const glyph = this._charToGlyph(charcode, length === 1 && chars.charCodeAt(i - 1) === 0x20);
28802        glyphs.push(glyph);
28803      }
28804    } else {
28805      for (let i = 0, ii = chars.length; i < ii; ++i) {
28806        const charcode = chars.charCodeAt(i);
28807        const glyph = this._charToGlyph(charcode, charcode === 0x20);
28808        glyphs.push(glyph);
28809      }
28810    }
28811    this.#charsCache.set(chars, glyphs);
28812    return glyphs;
28813  }
28814  getCharPositions(chars) {
28815    const positions = [];
28816    if (this.cMap) {
28817      const c = Object.create(null);
28818      let i = 0;
28819      while (i < chars.length) {
28820        this.cMap.readCharCode(chars, i, c);
28821        const length = c.length;
28822        positions.push([i, i + length]);
28823        i += length;
28824      }
28825    } else {
28826      for (let i = 0, ii = chars.length; i < ii; ++i) {
28827        positions.push([i, i + 1]);
28828      }
28829    }
28830    return positions;
28831  }
28832  get glyphCacheValues() {
28833    return this.#glyphCache.values();
28834  }
28835  encodeString(str) {
28836    const buffers = [];
28837    const currentBuf = [];
28838    const hasCurrentBufErrors = () => buffers.length % 2 === 1;
28839    const getCharCode = this.toUnicode instanceof IdentityToUnicodeMap ? unicode => this.toUnicode.charCodeOf(unicode) : unicode => this.toUnicode.charCodeOf(String.fromCodePoint(unicode));
28840    for (let i = 0, ii = str.length; i < ii; i++) {
28841      const unicode = str.codePointAt(i);
28842      if (unicode > 0x
28842d7ff && (unicode < 0xe000 || unicode > 0xfffd)
vendor: 1,652 bytes, lines 28842-28889
28842) {
28843        i++;
28844      }
28845      if (this.toUnicode) {
28846        const charCode = getCharCode(unicode);
28847        if (charCode !== -1) {
28848          if (hasCurrentBufErrors()) {
28849            buffers.push(currentBuf.join(""));
28850            currentBuf.length = 0;
28851          }
28852          const charCodeLength = this.cMap ? this.cMap.getCharCodeLength(charCode) : 1;
28853          for (let j = charCodeLength - 1; j >= 0; j--) {
28854            currentBuf.push(String.fromCharCode(charCode >> 8 * j & 0xff));
28855          }
28856          continue;
28857        }
28858      }
28859      if (!hasCurrentBufErrors()) {
28860        buffers.push(currentBuf.join(""));
28861        currentBuf.length = 0;
28862      }
28863      currentBuf.push(String.fromCodePoint(unicode));
28864    }
28865    buffers.push(currentBuf.join(""));
28866    return buffers;
28867  }
28868}
28869class ErrorFont {
28870  constructor(error) {
28871    this.error = error;
28872    this.loadedName = "g_font_error";
28873    this.missingFile = true;
28874  }
28875  charsToGlyphs() {
28876    return [];
28877  }
28878  encodeString(chars) {
28879    return [chars];
28880  }
28881  exportData() {
28882    return {
28883      error: this.error
28884    };
28885  }
28886}
28887
28888;// ./src/core/calibri_factors.js
28889const CalibriBoldFactors = [1.3877, 1, 1, 1, 0.97801, 0.92482, 0.89552, 0.91133, 0.81988, 0.97566, 0.98152, 0.93548, 0.93548, 1.2798, 0.85284, 0.92794, 1, 0.96134, 1.54657, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.82845, 0.82845, 0.85284, 0.85284, 0.85284, 0.75859, 0.92138, 0.83908, 0.7762, 0.73293, 0.87289, 0.73133, 0.7514, 0.81921, 0.87356, 0.95958, 0.59526, 0.75727, 0.69225, 1.04924, 0.9121, 0.86943, 0.79795, 0.88198, 0.77958, 0.70864, 0.81055, 0.90399, 0.88653, 0.96017, 0.82577, 0.77892, 
vendor: 2,638 bytes, line 28889
288890.78257, 0.97507, 1.54657, 0.97507, 0.85284, 0.89552, 0.90176, 0.88762, 0.8785, 0.75241, 0.8785, 0.90518, 0.95015, 0.77618, 0.8785, 0.88401, 0.91916, 0.86304, 0.88401, 0.91488, 0.8785, 0.8801, 0.8785, 0.8785, 0.91343, 0.7173, 1.04106, 0.8785, 0.85075, 0.95794, 0.82616, 0.85162, 0.79492, 0.88331, 1.69808, 0.88331, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.7801, 0.89552, 1.24487, 1.13254, 1.12401, 0.96839, 0.85284, 0.68787, 0.70645, 0.85592, 0.90747, 1.01466, 1.0088, 0.90323, 1, 1.07463, 1, 0.91056, 0.75806, 1.19118, 0.96839, 0.78864, 0.82845, 0.84133, 0.75859, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.77539, 0.73293, 0.73133, 0.73133, 0.73133, 0.73133, 0.95958, 0.95958, 0.95958, 0.95958, 0.88506, 0.9121, 0.86943, 0.86943, 0.86943, 0.86943, 0.86943, 0.85284, 0.87508, 0.90399, 0.90399, 0.90399, 0.90399, 0.77892, 0.79795, 0.90807, 0.88762, 0.88762, 0.88762, 0.88762, 0.88762, 0.88762, 0.8715, 0.75241, 0.90518, 0.90518, 0.90518, 0.90518, 0.88401, 0.88401, 0.88401, 0.88401, 0.8785, 0.8785, 0.8801, 0.8801, 0.8801, 0.8801, 0.8801, 0.90747, 0.89049, 0.8785, 0.8785, 0.8785, 0.8785, 0.85162, 0.8785, 0.85162, 0.83908, 0.88762, 0.83908, 0.88762, 0.83908, 0.88762, 0.73293, 0.75241, 0.73293, 0.75241, 0.73293, 0.75241, 0.73293, 0.75241, 0.87289, 0.83016, 0.88506, 0.93125, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.73133, 0.90518, 0.81921, 0.77618, 0.81921, 0.77618, 0.81921, 0.77618, 1, 1, 0.87356, 0.8785, 0.91075, 0.89608, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.76229, 0.90167, 0.59526, 0.91916, 1, 1, 0.86304, 0.69225, 0.88401, 1, 1, 0.70424, 0.79468, 0.91926, 0.88175, 0.70823, 0.94903, 0.9121, 0.8785, 1, 1, 0.9121, 0.8785, 0.87802, 0.88656, 0.8785, 0.86943, 0.8801, 0.86943, 0.8801, 0.86943, 0.8801, 0.87402, 0.89291, 0.77958, 0.91343, 1, 1, 0.77958, 0.91343, 0.70864, 0.7173, 0.70864, 0.7173, 0.70864, 0.7173, 0.70864, 0.7173, 1, 1, 0.81055, 0.75841, 0.81055, 1.06452, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.90399, 0.8785, 0.96017, 0.95794, 0.77892, 0.85162, 0.77892, 0.78257, 0.79492, 0.78257, 0.79492, 0.78257, 0.79492, 0.9297, 0.56892, 0.83908, 0.88762, 0.77539, 0.8715, 0.87508, 0.89049, 1, 1, 0.81055, 1.04106, 1.20528, 1.20528, 1, 1.15543, 0.70674, 0.98387, 0.94721, 1.33431, 1.45894, 0.95161, 1.06303, 0.83908, 0.80352, 0.57184, 0.6965, 0.56289, 0.82001, 0.56029, 0.81235, 1.02988, 0.83908, 0.7762, 0.68156, 0.80367, 0.73133, 0.78257, 0.87356, 0.86943, 0.95958, 0.75727, 0.89019, 1.04924, 0.9121, 0.7648, 0.86943, 0.87356, 0.79795, 0.78275, 0.81055, 0.77892, 
vendor: 2,277 bytes, lines 28889-28894
288890.9762, 0.82577, 0.99819, 0.84896, 0.95958, 0.77892, 0.96108, 1.01407, 0.89049, 1.02988, 0.94211, 0.96108, 0.8936, 0.84021, 0.87842, 0.96399, 0.79109, 0.89049, 1.00813, 1.02988, 0.86077, 0.87445, 0.92099, 0.84723, 0.86513, 0.8801, 0.75638, 0.85714, 0.78216, 0.79586, 0.87965, 0.94211, 0.97747, 0.78287, 0.97926, 0.84971, 1.02988, 0.94211, 0.8801, 0.94211, 0.84971, 0.73133, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90264, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90518, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90548, 1, 1, 1, 1, 1, 1, 0.96017, 0.95794, 0.96017, 0.95794, 0.96017, 0.95794, 0.77892, 0.85162, 1, 1, 0.89552, 0.90527, 1, 0.90363, 0.92794, 0.92794, 0.92794, 0.92794, 0.87012, 0.87012, 0.87012, 0.89552, 0.89552, 1.42259, 0.71143, 1.06152, 1, 1, 1.03372, 1.03372, 0.97171, 1.4956, 2.2807, 0.93835, 0.83406, 0.91133, 0.84107, 0.91133, 1, 1, 1, 0.72021, 1, 1.23108, 0.83489, 0.88525, 0.88525, 0.81499, 0.90527, 1.81055, 0.90527, 1.81055, 1.31006, 1.53711, 0.94434, 1.08696, 1, 0.95018, 0.77192, 0.85284, 0.90747, 1.17534, 0.69825, 0.9716, 1.37077, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.08004, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90727, 0.90727, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28890const CalibriBoldMetrics = {
28891  lineHeight: 1.2207,
28892  lineGap: 0.2207
28893};
28894const CalibriBoldItalicFactors = [1.3877, 1, 1, 1, 0.97801, 0.92482, 0.89552, 0.91133, 0.81988, 0.97566, 0.98152, 0.93548, 0.93548, 1.2798, 0.85284, 0.92794, 1, 0.96134, 1.56239, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.82845, 0.82845, 0.85284, 0.85284, 0.85284, 0.75859, 0.92138, 0.83908, 0.7762, 0.71805, 0.87289, 0.73133, 0.7514, 0.81921, 0.87356, 0.95958, 0.59526, 0.75727, 0.69225, 1.04924, 0.90872, 0.85938, 0.79795, 0.87068, 0.77958, 0.69766, 0.81055, 0.90399, 0.88653, 0.96068, 0.82577, 0.77892, 
vendor: 1,685 bytes, line 28894
288940.78257, 0.97507, 1.529, 0.97507, 0.85284, 0.89552, 0.90176, 0.94908, 0.86411, 0.74012, 0.86411, 0.88323, 0.95015, 0.86411, 0.86331, 0.88401, 0.91916, 0.86304, 0.88401, 0.9039, 0.86331, 0.86331, 0.86411, 0.86411, 0.90464, 0.70852, 1.04106, 0.86331, 0.84372, 0.95794, 0.82616, 0.84548, 0.79492, 0.88331, 1.69808, 0.88331, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.7801, 0.89552, 1.24487, 1.13254, 1.19129, 0.96839, 0.85284, 0.68787, 0.70645, 0.85592, 0.90747, 1.01466, 1.0088, 0.90323, 1, 1.07463, 1, 0.91056, 0.75806, 1.19118, 0.96839, 0.78864, 0.82845, 0.84133, 0.75859, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.83908, 0.77539, 0.71805, 0.73133, 0.73133, 0.73133, 0.73133, 0.95958, 0.95958, 0.95958, 0.95958, 0.88506, 0.90872, 0.85938, 0.85938, 0.85938, 0.85938, 0.85938, 0.85284, 0.87068, 0.90399, 0.90399, 0.90399, 0.90399, 0.77892, 0.79795, 0.90807, 0.94908, 0.94908, 0.94908, 0.94908, 0.94908, 0.94908, 0.85887, 0.74012, 0.88323, 0.88323, 0.88323, 0.88323, 0.88401, 0.88401, 0.88401, 0.88401, 0.8785, 0.86331, 0.86331, 0.86331, 0.86331, 0.86331, 0.86331, 0.90747, 0.89049, 0.86331, 0.86331, 0.86331, 0.86331, 0.84548, 0.86411, 0.84548, 0.83908, 0.94908, 0.83908, 0.94908, 0.83908, 0.94908, 0.71805, 0.74012, 0.71805, 0.74012, 0.71805, 0.74012, 0.71805, 0.74012, 0.87289, 0.79538, 0.88506, 0.92726, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.73133, 0.88323, 0.81921, 0.86411, 0.81921, 0.86411, 0.81921, 0.86411, 1, 1, 0.87356, 0.86331, 0.91075, 0.8777, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.95958, 0.88401, 0.76467, 0.90167, 0.59526, 0.91916, 1, 1, 0.86304, 0.69225, 0.88401, 1, 1, 0.70424, 0.7
vendor: 3,143 bytes, lines 28894-28899
288947312, 0.91926, 0.88175, 0.70823, 0.94903, 0.90872, 0.86331, 1, 1, 0.90872, 0.86331, 0.86906, 0.88116, 0.86331, 0.85938, 0.86331, 0.85938, 0.86331, 0.85938, 0.86331, 0.87402, 0.86549, 0.77958, 0.90464, 1, 1, 0.77958, 0.90464, 0.69766, 0.70852, 0.69766, 0.70852, 0.69766, 0.70852, 0.69766, 0.70852, 1, 1, 0.81055, 0.75841, 0.81055, 1.06452, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.90399, 0.86331, 0.96068, 0.95794, 0.77892, 0.84548, 0.77892, 0.78257, 0.79492, 0.78257, 0.79492, 0.78257, 0.79492, 0.9297, 0.56892, 0.83908, 0.94908, 0.77539, 0.85887, 0.87068, 0.89049, 1, 1, 0.81055, 1.04106, 1.20528, 1.20528, 1, 1.15543, 0.70088, 0.98387, 0.94721, 1.33431, 1.45894, 0.95161, 1.48387, 0.83908, 0.80352, 0.57118, 0.6965, 0.56347, 0.79179, 0.55853, 0.80346, 1.02988, 0.83908, 0.7762, 0.67174, 0.86036, 0.73133, 0.78257, 0.87356, 0.86441, 0.95958, 0.75727, 0.89019, 1.04924, 0.90872, 0.74889, 0.85938, 0.87891, 0.79795, 0.7957, 0.81055, 0.77892, 0.97447, 0.82577, 0.97466, 0.87179, 0.95958, 0.77892, 0.94252, 0.95612, 0.8753, 1.02988, 0.92733, 0.94252, 0.87411, 0.84021, 0.8728, 0.95612, 0.74081, 0.8753, 1.02189, 1.02988, 0.84814, 0.87445, 0.91822, 0.84723, 0.85668, 0.86331, 0.81344, 0.87581, 0.76422, 0.82046, 0.96057, 0.92733, 0.99375, 0.78022, 0.95452, 0.86015, 1.02988, 0.92733, 0.86331, 0.92733, 0.86015, 0.73133, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90631, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.88323, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.85174, 1, 1, 1, 1, 1, 1, 0.96068, 0.95794, 0.96068, 0.95794, 0.96068, 0.95794, 0.77892, 0.84548, 1, 1, 0.89552, 0.90527, 1, 0.90363, 0.92794, 0.92794, 0.92794, 0.89807, 0.87012, 0.87012, 0.87012, 0.89552, 0.89552, 1.42259, 0.71094, 1.06152, 1, 1, 1.03372, 1.03372, 0.97171, 1.4956, 2.2807, 0.92972, 0.83406, 0.91133, 0.83326, 0.91133, 1, 1, 1, 0.72021, 1, 1.23108, 0.83489, 0.88525, 0.88525, 0.81499, 0.90616, 1.81055, 0.90527, 1.81055, 1.3107, 1.53711, 0.94434, 1.08696, 1, 0.95018, 0.77192, 0.85284, 0.90747, 1.17534, 0.69825, 0.9716, 1.37077, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.08004, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90727, 0.90727, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28895const CalibriBoldItalicMetrics = {
28896  lineHeight: 1.2207,
28897  lineGap: 0.2207
28898};
28899const CalibriItalicFactors = [1.3877, 1, 1, 1, 1.17223, 1.1293, 0.89552, 0.91133, 0.80395, 1.02269, 1.15601, 0.91056, 0.91056, 1.2798, 0.85284, 0.89807, 1, 0.90861, 1.39543, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.96309, 0.96309, 0.85284, 0.85284, 0.85284, 0.83319, 0.88071, 0.8675, 0.81552, 0.72346, 0.85193, 0.73206, 0.7522, 0.81105, 0.86275, 0.90685, 0.6377, 0.77892, 
vendor: 3,657 bytes, line 28899
288990.75593, 1.02638, 0.89249, 0.84118, 0.77452, 0.85374, 0.75186, 0.67789, 0.79776, 0.88844, 0.85066, 0.94309, 0.77818, 0.7306, 0.76659, 1.10369, 1.38313, 1.10369, 1.06139, 0.89552, 0.8739, 0.9245, 0.9245, 0.83203, 0.9245, 0.85865, 1.09842, 0.9245, 0.9245, 1.03297, 1.07692, 0.90918, 1.03297, 0.94959, 0.9245, 0.92274, 0.9245, 0.9245, 1.02933, 0.77832, 1.20562, 0.9245, 0.8916, 0.98986, 0.86621, 0.89453, 0.79004, 0.94152, 1.77256, 0.94152, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.91729, 0.89552, 1.17889, 1.13254, 1.16359, 0.92098, 0.85284, 0.68787, 0.71353, 0.84737, 0.90747, 1.0088, 1.0044, 0.87683, 1, 1.09091, 1, 0.92229, 0.739, 1.15642, 0.92098, 0.76288, 0.80504, 0.80972, 0.75859, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.76318, 0.72346, 0.73206, 0.73206, 0.73206, 0.73206, 0.90685, 0.90685, 0.90685, 0.90685, 0.86477, 0.89249, 0.84118, 0.84118, 0.84118, 0.84118, 0.84118, 0.85284, 0.84557, 0.88844, 0.88844, 0.88844, 0.88844, 0.7306, 0.77452, 0.86331, 0.9245, 0.9245, 0.9245, 0.9245, 0.9245, 0.9245, 0.84843, 0.83203, 0.85865, 0.85865, 0.85865, 0.85865, 0.82601, 0.82601, 0.82601, 0.82601, 0.94469, 0.9245, 0.92274, 0.92274, 0.92274, 0.92274, 0.92274, 0.90747, 0.86651, 0.9245, 0.9245, 0.9245, 0.9245, 0.89453, 0.9245, 0.89453, 0.8675, 0.9245, 0.8675, 0.9245, 0.8675, 0.9245, 0.72346, 0.83203, 0.72346, 0.83203, 0.72346, 0.83203, 0.72346, 0.83203, 0.85193, 0.8875, 0.86477, 0.99034, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.73206, 0.85865, 0.81105, 0.9245, 0.81105, 0.9245, 0.81105, 0.9245, 1, 1, 0.86275, 0.9245, 0.90872, 0.93591, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 1.03297, 0.90685, 0.82601, 0.77896, 1.05611, 0.6377, 1.07692, 1, 1, 0.90918, 0.75593, 1.03297, 1, 1, 0.76032, 0.9375, 0.98156, 0.93407, 0.77261, 1.11429, 0.89249, 0.9245, 1, 1, 0.89249, 0.9245, 0.92534, 0.86698, 0.9245, 0.84118, 0.92274, 0.84118, 0.92274, 0.84118, 0.92274, 0.8667, 0.86291, 0.75186, 1.02933, 1, 1, 0.75186, 1.02933, 0.67789, 0.77832, 0.67789, 0.77832, 0.67789, 0.77832, 0.67789, 0.77832, 1, 1, 0.79776, 0.97655, 0.79776, 1.23023, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.88844, 0.9245, 0.94309, 0.98986, 0.7306, 0.89453, 0.7306, 0.76659, 0.79004, 0.76659, 0.79004, 0.76659, 0.79004, 1.09231, 0.54873, 0.8675, 0.9245, 0.76318, 0.84843, 0.84557, 0.86651, 1, 1, 0.79776, 1.20562, 1.18622, 1.18622, 1, 1.1437, 0.67009, 0.96334, 0.93695, 1.35191, 1.40909, 0.95161, 1.48387, 0.8675, 0.90861, 0.6192, 0.7363, 0.64824, 0.82411, 0.56321, 0.85696, 1.23516, 0.8675, 0.81552, 0.7286, 0.84134, 0.73206, 0.76659, 0.86275, 0.84369, 0.90685, 0.77892, 0.85871, 1.02638, 0.89249, 0.75828, 0.84118, 0.85984, 0.77452, 0.76466, 0.79776, 0.7306, 0.90782, 0.77818, 0.903, 0.87291, 0.90685, 0.7306, 0.99058, 1.03667, 0.94635, 1.23516, 0.9849, 0.99058, 0.92393, 0.8916, 0.942, 1.03667, 0.75026, 0.94635, 1.0297, 1.23516, 0.90918, 0.94048, 0.98217, 0.89746, 0.84153, 0.92274, 0.82507, 0.88832, 0.84438, 0.88178, 1.03525, 0.9849, 1.00225, 0.78086, 0.97248, 0.89404, 1.23516, 0.9849, 0.92274, 0.9849, 0.89404, 0.73206, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89693, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.85865, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.90933, 1, 1, 1, 1, 1, 1, 0.94309, 0.98986, 0.94309, 0.98986, 0.94309, 0.98986, 0.7306, 0.89453, 1, 1, 0.89552, 0.90527, 1, 0.90186, 1.12308, 1.12308, 1.12308, 1.12308, 1.2566, 1.2566, 1.2566, 0.89552, 0.89552, 1.42259, 0.68994, 1.03809, 1, 1, 1.0176, 1.01
vendor: 1,221 bytes, lines 28899-28904
2889976, 1.11523, 1.4956, 2.01462, 0.97858, 0.82616, 0.91133, 0.83437, 0.91133, 1, 1, 1, 0.70508, 1, 1.23108, 0.79801, 0.84426, 0.84426, 0.774, 0.90572, 1.81055, 0.90749, 1.81055, 1.28809, 1.55469, 0.94434, 1.07806, 1, 0.97094, 0.7589, 0.85284, 0.90747, 1.19658, 0.69825, 0.97622, 1.33512, 0.90747, 0.90747, 0.85284, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.0336, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05859, 1.05859, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28900const CalibriItalicMetrics = {
28901  lineHeight: 1.2207,
28902  lineGap: 0.2207
28903};
28904const CalibriRegularFactors = [1.3877, 1, 1, 1, 1.17223, 1.1293, 0.89552, 0.91133, 0.80395, 1.02269, 1.15601, 0.91056, 0.91056, 1.2798, 0.85284, 0.89807, 1, 0.90861, 1.39016, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.91133, 0.96309, 0.96309, 0.85284, 0.85284, 0.85284, 0.83319, 0.88071, 0.8675, 0.81552, 0.73834, 0.85193, 0.73206, 0.7522, 0.81105, 0.86275, 0.90685, 0.6377, 0.77892, 
vendor: 3,690 bytes, line 28904
289040.75593, 1.02638, 0.89385, 0.85122, 0.77452, 0.86503, 0.75186, 0.68887, 0.79776, 0.88844, 0.85066, 0.94258, 0.77818, 0.7306, 0.76659, 1.10369, 1.39016, 1.10369, 1.06139, 0.89552, 0.8739, 0.86128, 0.94469, 0.8457, 0.94469, 0.89464, 1.09842, 0.84636, 0.94469, 1.03297, 1.07692, 0.90918, 1.03297, 0.95897, 0.94469, 0.9482, 0.94469, 0.94469, 1.04692, 0.78223, 1.20562, 0.94469, 0.90332, 0.98986, 0.86621, 0.90527, 0.79004, 0.94152, 1.77256, 0.94152, 0.85284, 0.97801, 0.89552, 0.91133, 0.89552, 0.91133, 1.91729, 0.89552, 1.17889, 1.13254, 1.08707, 0.92098, 0.85284, 0.68787, 0.71353, 0.84737, 0.90747, 1.0088, 1.0044, 0.87683, 1, 1.09091, 1, 0.92229, 0.739, 1.15642, 0.92098, 0.76288, 0.80504, 0.80972, 0.75859, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.8675, 0.76318, 0.73834, 0.73206, 0.73206, 0.73206, 0.73206, 0.90685, 0.90685, 0.90685, 0.90685, 0.86477, 0.89385, 0.85122, 0.85122, 0.85122, 0.85122, 0.85122, 0.85284, 0.85311, 0.88844, 0.88844, 0.88844, 0.88844, 0.7306, 0.77452, 0.86331, 0.86128, 0.86128, 0.86128, 0.86128, 0.86128, 0.86128, 0.8693, 0.8457, 0.89464, 0.89464, 0.89464, 0.89464, 0.82601, 0.82601, 0.82601, 0.82601, 0.94469, 0.94469, 0.9482, 0.9482, 0.9482, 0.9482, 0.9482, 0.90747, 0.86651, 0.94469, 0.94469, 0.94469, 0.94469, 0.90527, 0.94469, 0.90527, 0.8675, 0.86128, 0.8675, 0.86128, 0.8675, 0.86128, 0.73834, 0.8457, 0.73834, 0.8457, 0.73834, 0.8457, 0.73834, 0.8457, 0.85193, 0.92454, 0.86477, 0.9921, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.73206, 0.89464, 0.81105, 0.84636, 0.81105, 0.84636, 0.81105, 0.84636, 1, 1, 0.86275, 0.94469, 0.90872, 0.95786, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 0.82601, 0.90685, 1.03297, 0.90685, 0.82601, 0.77741, 1.05611, 0.6377, 1.07692, 1, 1, 0.90918, 0.75593, 1.03297, 1, 1, 0.76032, 0.90452, 0.98156, 1.11842, 0.77261, 1.11429, 0.89385, 0.94469, 1, 1, 0.89385, 0.94469, 0.95877, 0.86901, 0.94469, 0.85122, 0.9482, 0.85122, 0.9482, 0.85122, 0.9482, 0.8667, 0.90016, 0.75186, 1.04692, 1, 1, 0.75186, 1.04692, 0.68887, 0.78223, 0.68887, 0.78223, 0.68887, 0.78223, 0.68887, 0.78223, 1, 1, 0.79776, 0.92188, 0.79776, 1.23023, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.88844, 0.94469, 0.94258, 0.98986, 0.7306, 0.90527, 0.7306, 0.76659, 0.79004, 0.76659, 0.79004, 0.76659, 0.79004, 1.09231, 0.54873, 0.8675, 0.86128, 0.76318, 0.8693, 0.85311, 0.86651, 1, 1, 0.79776, 1.20562, 1.18622, 1.18622, 1, 1.1437, 0.67742, 0.96334, 0.93695, 1.35191, 1.40909, 0.95161, 1.48387, 0.86686, 0.90861, 0.62267, 0.74359, 0.65649, 0.85498, 0.56963, 0.88254, 1.23516, 0.8675, 0.81552, 0.75443, 0.84503, 0.73206, 0.76659, 0.86275, 0.85122, 0.90685, 0.77892, 0.85746, 1.02638, 0.89385, 0.75657, 0.85122, 0.86275, 0.77452, 0.74171, 0.79776, 0.7306, 0.95165, 0.77818, 0.89772, 0.88831, 0.90685, 0.7306, 0.98142, 1.02191, 0.96576, 1.23516, 0.99018, 0.98142, 0.9236, 0.89258, 0.94035, 1.02191, 0.78848, 0.96576, 0.9561, 1.23516, 0.90918, 0.92578, 0.95424, 0.89746, 0.83969, 0.9482, 0.80113, 0.89442, 0.85208, 0.86155, 0.98022, 0.99018, 1.00452, 0.81209, 0.99247, 0.89181, 1.23516, 0.99018, 0.9482, 0.99018, 0.89181, 0.73206, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.88844, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89464, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.96766, 1, 1, 1, 1, 1, 1, 0.94258, 0.98986, 0.94258, 0.98986, 0.94258, 0.98986, 0.7306, 0.90527, 1, 1, 0.89552, 0.90527, 1, 0.90186, 1.12308, 1.12308, 1.12308, 1.12308, 1.2566, 1.2566, 1.2566, 0.89552, 0.89552, 1.42259, 0.69043, 1.03809, 1, 1, 1.0176, 1.01
vendor: 56,964 bytes, lines 28904-28948
2890476, 1.11523, 1.4956, 2.01462, 0.99331, 0.82616, 0.91133, 0.84286, 0.91133, 1, 1, 1, 0.70508, 1, 1.23108, 0.79801, 0.84426, 0.84426, 0.774, 0.90527, 1.81055, 0.90527, 1.81055, 1.28809, 1.55469, 0.94434, 1.07806, 1, 0.97094, 0.7589, 0.85284, 0.90747, 1.19658, 0.69825, 0.97622, 1.33512, 0.90747, 0.90747, 0.85356, 0.90747, 0.90747, 1.44947, 0.85284, 0.8941, 0.8941, 0.70572, 0.8, 0.70572, 0.70572, 0.70572, 0.70572, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.99862, 0.99862, 1, 1, 1, 1, 1, 1.0336, 0.91027, 1, 1, 1, 0.99862, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05859, 1.05859, 1, 1, 1, 1.07185, 0.99413, 0.96334, 1.08065, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28905const CalibriRegularMetrics = {
28906  lineHeight: 1.2207,
28907  lineGap: 0.2207
28908};
28909
28910;// ./src/core/helvetica_factors.js
28911const HelveticaBoldFactors = [0.76116, 1, 1, 1.0006, 0.99998, 0.99974, 0.99973, 0.99973, 0.99982, 0.99977, 1.00087, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.00003, 1.00003, 1.00003, 1.00026, 0.9999, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 0.99973, 0.99977, 1.00026, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 0.99998, 1.0006, 0.99998, 1.00003, 0.99973, 0.99998, 0.99973, 1.00026, 0.99973, 1.00026, 0.99973, 0.99998, 1.00026, 1.00026, 1.0006, 1.0006, 0.99973, 1.0006, 0.99982, 1.00026, 1.00026, 1.00026, 1.00026, 0.99959, 0.99973, 0.99998, 1.00026, 0.99973, 1.00022, 0.99973, 0.99973, 1, 0.99959, 1.00077, 0.99959, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.00077, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.99973, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.06409, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 0.99973, 1.00026, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 1.03374, 0.99977, 1.00026, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.00042, 0.99973, 0.99973, 1.0006, 0.99977, 0.99973, 0.99973, 1.00026, 1.0006, 1.00026, 1.0006, 1.00026, 1.03828, 1.00026, 0.99999, 1.00026, 1.0006, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.9993, 0.9998, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1, 1.00016, 0.99977, 0.99959, 0.99977, 0.99959, 0.99977, 0.99959, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00026, 0.99998, 1.00026, 0.8121, 1.00026, 0.99998, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.00016, 1.00022, 1.00001, 0.99973, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 1.0006, 0.99973, 0.99977, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 0.99973, 1.00026, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 1.00034, 0.99977, 1, 0.99997, 1.00026, 1.00078, 1.00036, 0.99973, 1.00013, 1.0006, 0.99977, 0.99977, 0.99988, 0.85148, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 0.99977, 1.00001, 0.99999, 0.99977, 1.00069, 1.00022, 0.99977, 1.00001, 0.99984, 1.00026, 1.00001, 1.00024, 1.00001, 0.9999, 1, 1.0006, 1.00001, 1.00041, 0.99962, 1.00026, 1.0006, 0.99995, 1.00041, 0.99942, 0.99973, 0.99927, 1.00082, 0.99902, 1.00026, 1.00087, 1.0006, 1.00069, 0.99973, 0.99867, 0.99973, 0.9993, 1.00026, 1.00049, 1.00056, 1, 0.99988, 0.99935, 0.99995, 0.99954, 1.00055, 0.99945, 1.00032, 1.0006, 0.99995, 1.00026, 0.99995, 1.00032, 1.00001, 1.00008, 0.99971, 1.00019, 0.9994, 1.00001, 1.0006, 1.00044, 0.99973, 1.00023, 1.00047, 1, 0.99942, 0.99561, 0.99989, 1.00035, 0.99977, 1.00035, 0.99977, 1.00019, 0.99944, 1.00001, 1.00021, 0.99926, 1.00035, 1.00035, 0.99942, 1.00048, 0.99999, 0.99977, 1.00022, 1.00035, 1.00001, 0.99977, 1.00026, 0.99989, 1.00057, 1.00001, 0.99936, 1.00052, 1.00012, 0.99996, 1.00043, 1, 1.00035, 0.9994, 0.99976, 1.00035, 0.99973, 1.00052, 1.00041, 1.00119, 1.00037, 0.99973, 1.00002, 0.99986, 1.00041, 1.00041, 0.99902, 0.9996, 1.00034, 0.99999, 1.00026, 0.99999, 1.00026, 0.99973, 1.00052, 0.99973, 1, 0.99973, 1.00041, 1.00075, 0.9994, 1.0003, 0.99999, 1, 1.00041, 0.99955, 1, 0.99915, 0.99973, 0.99973, 1.00026, 1.00119, 0.99955, 0.99973, 1.0006, 0.99911, 1.0006, 1.00026, 0.99972, 1.00026, 0.99902, 1.00041, 0.99973, 0.99999, 1, 1, 1.00038, 1.0005, 1.00016, 1.00022, 1.00016, 1.00022, 1.00016, 1.00022, 1.00001, 0.99973, 1, 1, 0.99973, 1, 1, 0.99955, 1.0006, 1.0006, 1.0006, 1.0006, 1, 1, 1, 0.99973, 0.99973, 0.99972, 1, 1, 1.00106, 0.99999, 0.99998, 0.99998, 0.99999, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 0.99971, 1.00047, 1.00023, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1, 1, 1, 1, 1, 1, 1, 0.99972, 1, 1.20985, 1.39713, 1.00003, 1.00031, 1.00015, 1, 0.99561, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.99972, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28912const HelveticaBoldMetrics = {
28913  lineHeight: 1.2,
28914  lineGap: 0.2
28915};
28916const HelveticaBoldItalicFactors = [0.76116, 1, 1, 1.0006, 0.99998, 0.99974, 0.99973, 0.99973, 0.99982, 0.99977, 1.00087, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.00003, 1.00003, 1.00003, 1.00026, 0.9999, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 0.99973, 0.99977, 1.00026, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 0.99998, 1.0006, 0.99998, 1.00003, 0.99973, 0.99998, 0.99973, 1.00026, 0.99973, 1.00026, 0.99973, 0.99998, 1.00026, 1.00026, 1.0006, 1.0006, 0.99973, 1.0006, 0.99982, 1.00026, 1.00026, 1.00026, 1.00026, 0.99959, 0.99973, 0.99998, 1.00026, 0.99973, 1.00022, 0.99973, 0.99973, 1, 0.99959, 1.00077, 0.99959, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.00077, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.99973, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 0.99977, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 1.06409, 1.00026, 1.00026, 1.00026, 1.00026, 1.00026, 0.99973, 1.00026, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 1.0044, 0.99977, 1.00026, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99971, 0.99973, 0.99973, 1.0006, 0.99977, 0.99973, 0.99973, 1.00026, 1.0006, 1.00026, 1.0006, 1.00026, 1.01011, 1.00026, 0.99999, 1.00026, 1.0006, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.9993, 0.9998, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1.00022, 1.00026, 1, 1.00016, 0.99977, 0.99959, 0.99977, 0.99959, 0.99977, 0.99959, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00026, 0.99998, 1.00026, 0.8121, 1.00026, 0.99998, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 0.99977, 1.00026, 1.00016, 1.00022, 1.00001, 0.99973, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 1.0006, 0.99973, 0.99977, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 0.99973, 1.00026, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99977, 1, 1, 1.00026, 0.99969, 0.99972, 0.99981, 0.9998, 1.0006, 0.99977, 0.99977, 1.00022, 0.91155, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 0.99977, 1.00001, 0.99999, 0.99977, 0.99966, 1.00022, 1.00032, 1.00001, 0.99944, 1.00026, 1.00001, 0.99968, 1.00001, 1.00047, 1, 1.0006, 1.00001, 0.99981, 1.00101, 1.00026, 1.0006, 0.99948, 0.99981, 1.00064, 0.99973, 0.99942, 1.00101, 1.00061, 1.00026, 1.00069, 1.0006, 1.00014, 0.99973, 1.01322, 0.99973, 1.00065, 1.00026, 1.00012, 0.99923, 1, 1.00064, 1.00076, 0.99948, 1.00055, 1.00063, 1.00007, 0.99943, 1.0006, 0.99948, 1.00026, 0.99948, 0.99943, 1.00001, 1.00001, 1.00029, 1.00038, 1.00035, 1.00001, 1.0006, 1.0006, 0.99973, 0.99978, 1.00001, 1.00057, 0.99989, 0.99967, 0.99964, 0.99967, 0.99977, 0.99999, 0.99977, 1.00038, 0.99977, 1.00001, 0.99973, 1.00066, 0.99967, 0.99967, 1.00041, 0.99998, 0.99999, 0.99977, 1.00022, 0.99967, 1.00001, 0.99977, 1.00026, 0.99964, 1.00031, 1.00001, 0.99999, 0.99999, 1, 1.00023, 1, 1, 0.99999, 1.00035, 1.00001, 0.99999, 0.99973, 0.99977, 0.99999, 1.00058, 0.99973, 0.99973, 0.99955, 0.9995, 1.00026, 1.00026, 1.00032, 0.99989, 1.00034, 0.99999, 1.00026, 1.00026, 1.00026, 0.99973, 0.45998, 0.99973, 1.00026, 0.99973, 1.00001, 0.99999, 0.99982, 0.99994, 0.99996, 1, 1.00042, 1.00044, 1.00029, 1.00023, 0.99973, 0.99973, 1.00026, 0.99949, 1.00002, 0.99973, 1.0006, 1.0006, 1.0006, 0.99975, 1.00026, 1.00026, 1.00032, 0.98685, 0.99973, 1.00026, 1, 1, 0.99966, 1.00044, 1.00016, 1.00022, 1.00016, 1.00022, 1.00016, 1.00022, 1.00001, 0.99973, 1, 1, 0.99973, 1, 1, 0.99955, 1.0006, 1.0006, 1.0006, 1.0006, 1, 1, 1, 0.99973, 0.99973, 0.99972, 1, 1, 1.00106, 0.99999, 0.99998, 0.99998, 0.99999, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1, 0.99973, 0.99971, 0.99978, 1, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1.00098, 1, 1, 1, 1.00049, 1, 1, 0.99972, 1, 1.20985, 1.39713, 1.00003, 1.00031, 1.00015, 1, 0.99561, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.99972, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28917const HelveticaBoldItalicMetrics = {
28918  lineHeight: 1.35,
28919  lineGap: 0.2
28920};
28921const HelveticaItalicFactors = [0.76116, 1, 1, 1.0006, 1.0006, 1.00006, 0.99973, 0.99973, 0.99982, 1.00001, 1.00043, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1, 1.00003, 1.00003, 1.00003, 0.99973, 0.99987, 1.00001, 1.00001, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 1, 1.00001, 0.99973, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 1.0006, 1.0006, 1.0006, 0.99949, 0.99973, 0.99998, 0.99973, 0.99973, 1, 0.99973, 0.99973, 1.0006, 0.99973, 0.99973, 0.99924, 0.99924, 1, 0.99924, 0.99999, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.0006, 0.99973, 1, 0.99977, 1, 1, 1, 1.00005, 1.0009, 1.00005, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.0009, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.9998, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 1, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.06409, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 1, 0.99973, 1, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1.0288, 0.99977, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99924, 1.0006, 1.0006, 0.99946, 1.00034, 1, 0.99924, 1.00001, 1, 1, 0.99973, 0.99924, 0.99973, 0.99924, 0.99973, 1.06311, 0.99973, 1.00024, 0.99973, 0.99924, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00041, 0.9998, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1, 1.00016, 0.99977, 0.99998, 0.99977, 0.99998, 0.99977, 0.99998, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00026, 1.0006, 1.00026, 0.89547, 1.00026, 1.0006, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00016, 0.99977, 1.00001, 1, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 0.99924, 0.99973, 1.00001, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 1, 1.00026, 1.0006, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 1.00001, 1, 1.00054, 0.99977, 1.00084, 1.00007, 0.99973, 1.00013, 0.99924, 1.00001, 1.00001, 0.99945, 0.91221, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 1.00001, 1.00001, 0.99999, 0.99977, 0.99933, 1.00022, 1.00054, 1.00001, 1.00065, 1.00026, 1.00001, 1.0001, 1.00001, 1.00052, 1, 1.0006, 1.00001, 0.99945, 0.99897, 0.99968, 0.99924, 1.00036, 0.99945, 0.99949, 1, 1.0006, 0.99897, 0.99918, 0.99968, 0.99911, 0.99924, 1, 0.99962, 1.01487, 1, 1.0005, 0.99973, 1.00012, 1.00043, 1, 0.99995, 0.99994, 1.00036, 0.99947, 1.00019, 1.00063, 1.00025, 0.99924, 1.00036, 0.99973, 1.00036, 1.00025, 1.00001, 1.00001, 1.00027, 1.0001, 1.00068, 1.00001, 1.0006, 1.0006, 1, 1.00008, 0.99957, 0.99972, 0.9994, 0.99954, 0.99975, 1.00051, 1.00001, 1.00019, 1.00001, 1.0001, 0.99986, 1.00001, 1.00001, 1.00038, 0.99954, 0.99954, 0.9994, 1.00066, 0.99999, 0.99977, 1.00022, 1.00054, 1.00001, 0.99977, 1.00026, 0.99975, 1.0001, 1.00001, 0.99993, 0.9995, 0.99955, 1.00016, 0.99978, 0.99974, 1.00019, 1.00022, 0.99955, 1.00053, 0.99973, 1.00089, 1.00005, 0.99967, 1.00048, 0.99973, 1.00002, 1.00034, 0.99973, 0.99973, 0.99964, 1.00006, 1.00066, 0.99947, 0.99973, 0.98894, 0.99973, 1, 0.44898, 1, 0.99946, 1, 1.00039, 1.00082, 0.99991, 0.99991, 0.99985, 1.00022, 1.00023, 1.00061, 1.00006, 0.99966, 0.99973, 0.99973, 0.99973, 1.00019, 1.0008, 1, 0.99924, 0.99924, 0.99924, 0.99983, 1.00044, 0.99973, 0.99964, 0.98332, 1, 0.99973, 1, 1, 0.99962, 0.99895, 1.00016, 0.99977, 1.00016, 0.99977, 1.00016, 0.99977, 1.00001, 1, 1, 1, 0.99973, 1, 1, 0.99955, 0.99924, 0.99924, 0.99924, 0.99924, 0.99998, 0.99998, 0.99998, 0.99973, 0.99973, 0.99972, 1, 1, 1.00267, 0.99999, 0.99998, 0.99998, 1, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 1.00423, 0.99925, 0.99999, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1.00049, 1, 1.00245, 1, 1, 1, 1, 0.96329, 1, 1.20985, 1.39713, 1.00003, 0.8254, 1.00015, 1, 1.00035, 1.00027, 1.00031, 1.00031, 1.00003, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.95317, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 0.99998, 0.99998, 0.99998, 0.99998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28922const HelveticaItalicMetrics = {
28923  lineHeight: 1.35,
28924  lineGap: 0.2
28925};
28926const HelveticaRegularFactors = [0.76116, 1, 1, 1.0006, 1.0006, 1.00006, 0.99973, 0.99973, 0.99982, 1.00001, 1.00043, 0.99998, 0.99998, 0.99959, 1.00003, 1.0006, 0.99998, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1, 1.00003, 1.00003, 1.00003, 0.99973, 0.99987, 1.00001, 1.00001, 0.99977, 0.99977, 1.00001, 1.00026, 1.00022, 0.99977, 1.0006, 1, 1.00001, 0.99973, 0.99999, 0.99977, 1.00022, 1.00001, 1.00022, 0.99977, 1.00001, 1.00026, 0.99977, 1.00001, 1.00016, 1.00001, 1.00001, 1.00026, 1.0006, 1.0006, 1.0006, 0.99949, 0.99973, 0.99998, 0.99973, 0.99973, 1, 0.99973, 0.99973, 1.0006, 0.99973, 0.99973, 0.99924, 0.99924, 1, 0.99924, 0.99999, 0.99973, 0.99973, 0.99973, 0.99973, 0.99998, 1, 1.0006, 0.99973, 1, 0.99977, 1, 1, 1, 1.00005, 1.0009, 1.00005, 1.00003, 0.99998, 0.99973, 0.99973, 0.99973, 0.99973, 1.0009, 0.99973, 0.99998, 1.00025, 0.99968, 0.99973, 1.00003, 1.00025, 0.60299, 1.00024, 1.06409, 1, 1, 0.99998, 1, 0.9998, 1.0006, 0.99998, 1, 0.99936, 0.99973, 1.00002, 1.00002, 1.00002, 1.00026, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1.00001, 1, 0.99977, 1.00001, 1.00001, 1.00001, 1.00001, 1.0006, 1.0006, 1.0006, 1.0006, 0.99977, 0.99977, 1.00022, 1.00022, 1.00022, 1.00022, 1.00022, 1.00003, 1.00022, 0.99977, 0.99977, 0.99977, 0.99977, 1.00001, 1.00001, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99982, 1, 0.99973, 0.99973, 0.99973, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 0.99973, 1.06409, 1.00026, 0.99973, 0.99973, 0.99973, 0.99973, 1, 0.99973, 1, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1, 0.99977, 1.04596, 0.99977, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00001, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 1.0006, 0.99924, 1.0006, 1.0006, 1.00019, 1.00034, 1, 0.99924, 1.00001, 1, 1, 0.99973, 0.99924, 0.99973, 0.99924, 0.99973, 1.02572, 0.99973, 1.00005, 0.99973, 0.99924, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99999, 0.9998, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1.00022, 0.99973, 1, 1.00016, 0.99977, 0.99998, 0.99977, 0.99998, 0.99977, 0.99998, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00001, 1, 1.00026, 1.0006, 1.00026, 0.84533, 1.00026, 1.0006, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 0.99977, 0.99973, 1.00016, 0.99977, 1.00001, 1, 1.00001, 1.00026, 1, 1.00026, 1, 1.00026, 1, 0.99924, 0.99973, 1.00001, 0.99973, 1, 0.99982, 1.00022, 1.00026, 1.00001, 1, 1.00026, 1.0006, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99998, 0.99928, 1, 0.99977, 1.00013, 1.00055, 0.99947, 0.99945, 0.99941, 0.99924, 1.00001, 1.00001, 1.0004, 0.91621, 1.00001, 1.00026, 0.99977, 1.00022, 1.0006, 1.00001, 1.00005, 0.99999, 0.99977, 1.00015, 1.00022, 0.99977, 1.00001, 0.99973, 1.00026, 1.00001, 1.00019, 1.00001, 0.99946, 1, 1.0006, 1.00001, 0.99978, 1.00045, 0.99973, 0.99924, 1.00023, 0.99978, 0.99966, 1, 1.00065, 1.00045, 1.00019, 0.99973, 0.99973, 0.99924, 1, 1, 0.96499, 1, 1.00055, 0.99973, 1.00008, 1.00027, 1, 0.9997, 0.99995, 1.00023, 0.99933, 1.00019, 1.00015, 1.00031, 0.99924, 1.00023, 0.99973, 1.00023, 1.00031, 1.00001, 0.99928, 1.00029, 1.00092, 1.00035, 1.00001, 1.0006, 1.0006, 1, 0.99988, 0.99975, 1, 1.00082, 0.99561, 0.9996, 1.00035, 1.00001, 0.99962, 1.00001, 1.00092, 0.99964, 1.00001, 0.99963, 0.99999, 1.00035, 1.00035, 1.00082, 0.99962, 0.99999, 0.99977, 1.00022, 1.00035, 1.00001, 0.99977, 1.00026, 0.9996, 0.99967, 1.00001, 1.00034, 1.00074, 1.00054, 1.00053, 1.00063, 0.99971, 0.99962, 1.00035, 0.99975, 0.99977, 0.99973, 1.00043, 0.99953, 1.0007, 0.99915, 0.99973, 1.00008, 0.99892, 1.00073, 1.00073, 1.00114, 0.99915, 1.00073, 0.99955, 0.99973, 1.00092, 0.99973, 1, 0.99998, 1, 1.0003, 1, 1.00043, 1.00001, 0.99969, 1.0003, 1, 1.00035, 1.00001, 0.9995, 1, 1.00092, 0.99973, 0.99973, 0.99973, 1.0007, 0.9995, 1, 0.99924, 1.0006, 0.99924, 0.99972, 1.00062, 0.99973, 1.00114, 1.00073, 1, 0.99955, 1, 1, 1.00047, 0.99968, 1.00016, 0.99977, 1.00016, 0.99977, 1.00016, 0.99977, 1.00001, 1, 1, 1, 0.99973, 1, 1, 0.99955, 0.99924, 0.99924, 0.99924, 0.99924, 0.99998, 0.99998, 0.99998, 0.99973, 0.99973, 0.99972, 1, 1, 1.00267, 0.99999, 0.99998, 0.99998, 1, 0.99998, 1.66475, 1, 0.99973, 0.99973, 1.00023, 0.99973, 0.99971, 0.99925, 1.00023, 1, 0.99991, 0.99984, 1.00002, 1.00002, 1.00002, 1.00002, 1, 1, 1, 1, 1, 1, 1, 0.96329, 1, 1.20985, 1.39713, 1.00003, 0.8254, 1.00015, 1, 1.00035, 1.00027, 1.00031, 1.00031, 0.99915, 1.00031, 1.00031, 0.99999, 1.00003, 0.99999, 0.99999, 1.41144, 1.6, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.41144, 1.40579, 1.40579, 1.36625, 0.99999, 1, 0.99861, 0.99861, 1, 1.00026, 1.00026, 1.00026, 1.00026, 0.95317, 0.99999, 0.99999, 0.99999, 0.99999, 1.40483, 1, 0.99977, 1.00054, 1, 1, 0.99953, 0.99962, 1.00042, 0.9995, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28927const HelveticaRegularMetrics = {
28928  lineHeight: 1.2,
28929  lineGap: 0.2
28930};
28931
28932;// ./src/core/liberationsans_widths.js
28933const LiberationSansBoldWidths = [365, 0, 333, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 549, 611, 611, 611, 611, 611, 556, 611, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 719, 722, 611, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 611, 778, 611, 778, 611, 778, 611, 722, 611, 722, 611, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 785, 556, 556, 278, 722, 556, 556, 611, 278, 611, 278, 611, 385, 611, 479, 611, 278, 722, 611, 722, 611, 722, 611, 708, 723, 611, 778, 611, 778, 611, 778, 611, 1000, 944, 722, 389, 722, 389, 722, 389, 667, 556, 667, 556, 667, 556, 667, 556, 611, 333, 611, 479, 611, 333, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 944, 778, 667, 556, 667, 611, 500, 611, 500, 611, 500, 278, 556, 722, 556, 1000, 889, 778, 611, 667, 556, 611, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 465, 722, 333, 853, 906, 474, 825, 927, 838, 278, 722, 722, 601, 719, 667, 611, 722, 778, 278, 722, 667, 833, 722, 644, 778, 722, 667, 600, 611, 667, 821, 667, 809, 802, 278, 667, 615, 451, 611, 278, 582, 615, 610, 556, 606, 475, 460, 611, 541, 278, 558, 556, 612, 556, 445, 611, 766, 619, 520, 684, 446, 582, 715, 576, 753, 845, 278, 582, 611, 582, 845, 667, 669, 885, 567, 711, 667, 278, 276, 556, 1094, 1062, 875, 610, 722, 622, 719, 722, 719, 722, 567, 712, 667, 904, 626, 719, 719, 610, 702, 833, 722, 778, 719, 667, 722, 611, 622, 854, 667, 730, 703, 1005, 1019, 870, 979, 719, 711, 1031, 719, 556, 618, 615, 417, 635, 556, 709, 497, 615, 615, 500, 635, 740, 604, 611, 604, 611, 556, 490, 556, 875, 556, 615, 581, 833, 844, 729, 854, 615, 552, 854, 583, 556, 556, 611, 417, 552, 556, 278, 281, 278, 969, 906, 611, 500, 615, 556, 604, 778, 611, 487, 447, 944, 778, 944, 778, 944, 778, 667, 556, 333, 333, 556, 1000, 1000, 552, 278, 278, 278, 278, 500, 500, 500, 556, 556, 350, 1000, 1000, 240, 479, 333, 333, 604, 333, 167, 396, 556, 556, 1094, 556, 885, 489, 1115, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 722, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 611, 611, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 333, 333, 333, 333, 333, 333, 333, 333];
28934const LiberationSansBoldMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
28935const LiberationSansBoldItalicWidths = [365, 0, 333, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 333, 556, 556, 556, 556, 280, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611, 611, 611, 611, 549, 611, 611, 611, 611, 611, 556, 611, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 740, 722, 611, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 611, 778, 611, 778, 611, 778, 611, 722, 611, 722, 611, 278, 278, 278, 278, 278, 278, 278, 278, 278, 278, 782, 556, 556, 278, 722, 556, 556, 611, 278, 611, 278, 611, 396, 611, 479, 611, 278, 722, 611, 722, 611, 722, 611, 708, 723, 611, 778, 611, 778, 611, 778, 611, 1000, 944, 722, 389, 722, 389, 722, 389, 667, 556, 667, 556, 667, 556, 667, 556, 611, 333, 611, 479, 611, 333, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 722, 611, 944, 778, 667, 556, 667, 611, 500, 611, 500, 611, 500, 278, 556, 722, 556, 1000, 889, 778, 611, 667, 556, 611, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 722, 333, 854, 906, 473, 844, 930, 847, 278, 722, 722, 610, 671, 667, 611, 722, 778, 278, 722, 667, 833, 722, 657, 778, 718, 667, 590, 611, 667, 822, 667, 829, 781, 278, 667, 620, 479, 611, 278, 591, 620, 621, 556, 610, 479, 492, 611, 558, 278, 566, 556, 603, 556, 450, 611, 712, 605, 532, 664, 409, 591, 704, 578, 773, 834, 278, 591, 611, 591, 834, 667, 667, 886, 614, 719, 667, 278, 278, 556, 1094, 1042, 854, 622, 719, 677, 719, 722, 708, 722, 614, 722, 667, 927, 643, 719, 719, 615, 687, 833, 722, 778, 719, 667, 722, 611, 677, 781, 667, 729, 708, 979, 989, 854, 1000, 708, 719, 1042, 729, 556, 619, 604, 534, 618, 556, 736, 510, 611, 611, 507, 622, 740, 604, 611, 611, 611, 556, 889, 556, 885, 556, 646, 583, 889, 935, 707, 854, 594, 552, 865, 589, 556, 556, 611, 469, 563, 556, 278, 278, 278, 969, 906, 611, 507, 619, 556, 611, 778, 611, 575, 467, 944, 778, 944, 778, 944, 778, 667, 556, 333, 333, 556, 1000, 1000, 552, 278, 278, 278, 278, 500, 500, 500, 556, 556, 350, 1000, 1000, 240, 479, 333, 333, 604, 333, 167, 396, 556, 556, 1104, 556, 885, 516, 1146, 1000, 768, 600, 834, 834, 834, 834, 999, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 722, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 611, 611, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 333, 333, 333, 333, 333, 333, 333, 333];
28936const LiberationSansBoldItalicMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
28937const LiberationSansItalicWidths = [365, 0, 333, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 549, 611, 556, 556, 556, 556, 500, 556, 500, 667, 556, 667, 556, 667, 556, 722, 500, 722, 500, 722, 500, 722, 500, 722, 625, 722, 556, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 556, 778, 556, 778, 556, 778, 556, 722, 556, 722, 556, 278, 278, 278, 278, 278, 278, 278, 222, 278, 278, 733, 444, 500, 222, 667, 500, 500, 556, 222, 556, 222, 556, 281, 556, 400, 556, 222, 722, 556, 722, 556, 722, 556, 615, 723, 556, 778, 556, 778, 556, 778, 556, 1000, 944, 722, 333, 722, 333, 722, 333, 667, 500, 667, 500, 667, 500, 667, 500, 611, 278, 611, 354, 611, 278, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 944, 722, 667, 500, 667, 611, 500, 611, 500, 611, 500, 222, 556, 667, 556, 1000, 889, 778, 611, 667, 500, 611, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667, 278, 789, 846, 389, 794, 865, 775, 222, 667, 667, 570, 671, 667, 611, 722, 778, 278, 667, 667, 833, 722, 648, 778, 725, 667, 600, 611, 667, 837, 667, 831, 761, 278, 667, 570, 439, 555, 222, 550, 570, 571, 500, 556, 439, 463, 555, 542, 222, 500, 492, 548, 500, 447, 556, 670, 573, 486, 603, 374, 550, 652, 546, 728, 779, 222, 550, 556, 550, 779, 667, 667, 843, 544, 708, 667, 278, 278, 500, 1066, 982, 844, 589, 715, 639, 724, 667, 651, 667, 544, 704, 667, 917, 614, 715, 715, 589, 686, 833, 722, 778, 725, 667, 722, 611, 639, 795, 667, 727, 673, 920, 923, 805, 886, 651, 694, 1022, 682, 556, 562, 522, 493, 553, 556, 688, 465, 556, 556, 472, 564, 686, 550, 556, 556, 556, 500, 833, 500, 835, 500, 572, 518, 830, 851, 621, 736, 526, 492, 752, 534, 556, 556, 556, 378, 496, 500, 222, 222, 222, 910, 828, 556, 472, 565, 500, 556, 778, 556, 492, 339, 944, 722, 944, 722, 944, 722, 667, 500, 333, 333, 556, 1000, 1000, 552, 222, 222, 222, 222, 333, 333, 333, 556, 556, 350, 1000, 1000, 188, 354, 333, 333, 500, 333, 167, 365, 556, 556, 1094, 556, 885, 323, 1083, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 998, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 719, 274, 549, 549, 584, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 500, 500, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 294, 294, 324, 324, 316, 328, 398, 285];
28938const LiberationSansItalicMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
28939const LiberationSansRegularWidths = [365, 0, 333, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 333, 556, 556, 556, 556, 260, 556, 333, 737, 370, 556, 584, 737, 552, 400, 549, 333, 333, 333, 576, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667, 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556, 556, 556, 556, 556, 549, 611, 556, 556, 556, 556, 500, 556, 500, 667, 556, 667, 556, 667, 556, 722, 500, 722, 500, 722, 500, 722, 500, 722, 615, 722, 556, 667, 556, 667, 556, 667, 556, 667, 556, 667, 556, 778, 556, 778, 556, 778, 556, 778, 556, 722, 556, 722, 556, 278, 278, 278, 278, 278, 278, 278, 222, 278, 278, 735, 444, 500, 222, 667, 500, 500, 556, 222, 556, 222, 556, 292, 556, 334, 556, 222, 722, 556, 722, 556, 722, 556, 604, 723, 556, 778, 556, 778, 556, 778, 556, 1000, 944, 722, 333, 722, 333, 722, 333, 667, 500, 667, 500, 667, 500, 667, 500, 611, 278, 611, 375, 611, 278, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 722, 556, 944, 722, 667, 500, 667, 611, 500, 611, 500, 611, 500, 222, 556, 667, 556, 1000, 889, 778, 611, 667, 500, 611, 278, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 667, 278, 784, 838, 384, 774, 855, 752, 222, 667, 667, 551, 668, 667, 611, 722, 778, 278, 667, 668, 833, 722, 650, 778, 722, 667, 618, 611, 667, 798, 667, 835, 748, 278, 667, 578, 446, 556, 222, 547, 578, 575, 500, 557, 446, 441, 556, 556, 222, 500, 500, 576, 500, 448, 556, 690, 569, 482, 617, 395, 547, 648, 525, 713, 781, 222, 547, 556, 547, 781, 667, 667, 865, 542, 719, 667, 278, 278, 500, 1057, 1010, 854, 583, 722, 635, 719, 667, 656, 667, 542, 677, 667, 923, 604, 719, 719, 583, 656, 833, 722, 778, 719, 667, 722, 611, 635, 760, 667, 740, 667, 917, 938, 792, 885, 656, 719, 1010, 722, 556, 573, 531, 365, 583, 556, 669, 458, 559, 559, 438, 583, 688, 552, 556, 542, 556, 500, 458, 500, 823, 500, 573, 521, 802, 823, 625, 719, 521, 510, 750, 542, 556, 556, 556, 365, 510, 500, 222, 278, 222, 906, 812, 556, 438, 559, 500, 552, 778, 556, 489, 411, 944, 722, 944, 722, 944, 722, 667, 500, 333, 333, 556, 1000, 1000, 552, 222, 222, 222, 222, 333, 333, 333, 556, 556, 350, 1000, 1000, 188, 354, 333, 333, 500, 333, 167, 365, 556, 556, 1094, 556, 885, 323, 1073, 1000, 768, 600, 834, 834, 834, 834, 1000, 500, 1000, 500, 1000, 500, 500, 494, 612, 823, 713, 584, 549, 713, 979, 719, 274, 549, 549, 583, 549, 549, 604, 584, 604, 604, 708, 625, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 708, 729, 604, 604, 354, 354, 1000, 990, 990, 990, 990, 494, 604, 604, 604, 604, 354, 1021, 1052, 917, 750, 750, 531, 656, 594, 510, 500, 750, 750, 500, 500, 333, 333, 333, 333, 333, 333, 333, 333, 222, 222, 294, 294, 324, 324, 316, 328, 398, 285];
28940const LiberationSansRegularMapping = [-1, -1, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 402, 506, 507, 508, 509, 510, 511, 536, 537, 538, 539, 710, 711, 713, 728, 729, 730, 731, 732, 733, 900, 901, 902, 903, 904, 905, 906, 908, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1138, 1139, 1168, 1169, 7808, 7809, 7810, 7811, 7812, 7813, 7922, 7923, 8208, 8209, 8211, 8212, 8213, 8215, 8216, 8217, 8218, 8219, 8220, 8221, 8222, 8224, 8225, 8226, 8230, 8240, 8242, 8243, 8249, 8250, 8252, 8254, 8260, 8319, 8355, 8356, 8359, 8364, 8453, 8467, 8470, 8482, 8486, 8494, 8539, 8540, 8541, 8542, 8592, 8593, 8594, 8595, 8596, 8597, 8616, 8706, 8710, 8719, 8721, 8722, 8730, 8734, 8735, 8745, 8747, 8776, 8800, 8801, 8804, 8805, 8962, 8976, 8992, 8993, 9472, 9474, 9484, 9488, 9492, 9496, 9500, 9508, 9516, 9524, 9532, 9552, 9553, 9554, 9555, 9556, 9557, 9558, 9559, 9560, 9561, 9562, 9563, 9564, 9565, 9566, 9567, 9568, 9569, 9570, 9571, 9572, 9573, 9574, 9575, 9576, 9577, 9578, 9579, 9580, 9600, 9604, 9608, 9612, 9616, 9617, 9618, 9619, 9632, 9633, 9642, 9643, 9644, 9650, 9658, 9660, 9668, 9674, 9675, 9679, 9688, 9689, 9702, 9786, 9787, 9788, 9792, 9794, 9824, 9827, 9829, 9830, 9834, 9835, 9836, 61441, 61442, 61445, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
28941
28942;// ./src/core/myriadpro_factors.js
28943const MyriadProBoldFactors = [1.36898, 1, 1, 0.72706, 0.80479, 0.83734, 0.98894, 0.99793, 0.9897, 0.93884, 0.86209, 0.94292, 0.94292, 1.16661, 1.02058, 0.93582, 0.96694, 0.93582, 1.19137, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.99793, 0.78076, 0.78076, 1.02058, 1.02058, 1.02058, 0.72851, 0.78966, 0.90838, 0.83637, 0.82391, 0.96376, 0.80061, 0.86275, 0.8768, 0.95407, 1.0258, 0.73901, 0.85022, 0.83655, 1.0156, 0.95546, 0.92179, 0.87107, 0.92179, 0.82114, 0.8096, 0.89713, 0.94438, 0.95353, 0.94083, 0.91905, 0.90406, 0.9446, 0.94292, 1.18777, 0.94292, 1.02058, 0.89903, 0.90088, 0.94938, 0.97898, 0.81093, 0.97571, 0.94938, 1.024, 0.9577, 0.95933, 0.98621, 1.0474, 0.97455, 0.98981, 0.9672, 0.95933, 0.9446, 0.97898, 0.97407, 0.97646, 0.78036, 1.10208, 0.95442, 0.95298, 0.97579, 0.9332, 0.94039, 0.938, 0.80687, 1.01149, 0.80687, 1.02058, 0.80479, 0.99793, 0.99793, 0.99793, 0.99793, 1.01149, 1.00872, 0.90088, 0.91882, 1.0213, 0.8361, 1.02058, 0.62295, 0.54324, 0.89022, 1.08595, 1, 1, 0.90088, 1, 0.97455, 0.93582, 0.90088, 1, 1.05686, 0.8361, 0.99642, 0.99642, 0.99642, 0.72851, 0.90838, 0.90838, 0.90838, 0.90838, 0.90838, 0.90838, 0.868, 0.82391, 0.80061, 0.80061, 0.80061, 0.80061, 1.0258, 1.0258, 1.0258, 1.0258, 0.97484, 0.95546, 0.92179, 0.92179, 0.92179, 0.92179, 0.92179, 1.02058, 0.92179, 0.94438, 0.94438, 0.94438, 0.94438, 0.90406, 0.86958, 0.98225, 0.94938, 0.94938, 0.94938, 0.94938, 0.94938, 0.94938, 0.9031, 0.81093, 0.94938, 0.94938, 0.94938, 0.94938, 0.98621, 0.98621, 0.98621, 0.98621, 0.93969, 0.95933, 0.9446, 0.9446, 0.9446, 0.9446, 0.9446, 1.08595, 0.9446, 0.95442, 0.95442, 0.95442, 0.95442, 0.94039, 0.97898, 0.94039, 0.90838, 0.94938, 0.90838, 0.94938, 0.90838, 0.94938, 0.82391, 0.81093, 0.82391, 0.81093, 0.82391, 0.81093, 0.82391, 0.81093, 0.96376, 0.84313, 0.97484, 0.97571, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.80061, 0.94938, 0.8768, 0.9577, 0.8768, 0.9577, 0.8768, 0.9577, 1, 1, 0.95407, 0.95933, 0.97069, 0.95933, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 1.0258, 0.98621, 0.887, 1.01591, 0.73901, 1.0474, 1, 1, 0.97455, 0.83655, 0.98981, 1, 1, 0.83655, 0.73977, 0.83655, 0.73903, 0.84638, 1.033, 0.95546, 0.95933, 1, 1, 0.95546, 0.95933, 0.8271, 0.95417, 0.95933, 0.92179, 0.9446, 0.92179, 0.9446, 0.92179, 0.9446, 0.936, 0.91964, 0.82114, 0.97646, 1, 1, 0.82114, 0.97646, 0.8096, 0.78036, 0.8096, 0.78036, 1, 1, 0.8096, 0.78036, 1, 1, 0.89713, 0.77452, 0.89713, 1.10208, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94438, 0.95442, 0.94083, 0.97579, 0.90406, 0.94039, 0.90406, 0.9446, 0.938, 0.9446, 0.938, 0.9446, 0.938, 1, 0.99793, 0.90838, 0.94938, 0.868, 0.9031, 0.92179, 0.9446, 1, 1, 0.89713, 1.10208, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90989, 0.9358, 0.91945, 0.83181, 0.75261, 0.87992, 0.82976, 0.96034, 0.83689, 0.97268, 1.0078, 0.90838, 0.83637, 0.8019, 0.90157, 0.80061, 0.9446, 0.95407, 0.92436, 1.0258, 0.85022, 0.97153, 1.0156, 0.95546, 0.89192, 0.92179, 0.92361, 0.87107, 0.96318, 0.89713, 0.93704, 0.95638, 0.91905, 0.91709, 0.92796, 1.0258, 0.93704, 0.94836, 1.0373, 0.95933, 1.0078, 0.95871, 0.94836, 0.96174, 0.92601, 0.9498, 0.98607, 0.95776, 0.95933, 1.05453, 1.0078, 0.98275, 0.9314, 0.95617, 0.91701, 1.05993, 0.9446, 0.78367, 0.9553, 1, 0.86832, 1.0128, 0.95871, 0.99394, 0.87548, 0.96361, 0.86774, 1.0078, 0.95871, 0.9446, 0.95871, 0.86774, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.94083, 0.97579, 0.94083, 0.97579, 0.94083, 0.97579, 0.90406, 0.94039, 0.96694, 1, 0.89903, 1, 1, 1, 0.93582, 0.93582, 0.93582, 1, 0.908, 0.908, 0.918, 0.94219, 0.94219, 0.96544, 1, 1.285, 1, 1, 0.81079, 0.81079, 1, 1, 0.74854, 1, 1, 1, 1, 0.99793, 1, 1, 1, 0.65, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.17173, 1, 0.80535, 0.76169, 1.02058, 1.0732, 1.05486, 1, 1, 1.30692, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.16161, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28944const MyriadProBoldMetrics = {
28945  lineHeight: 1.2,
28946  lineGap: 0.2
28947};
28948const MyriadProBoldItalicFactors = [1.36898, 1, 1, 0.66227, 0.80779, 0.81625, 0.97276, 0.97276, 0.97733, 0.92222, 0.83266, 0.94292, 0.94292, 1.16148, 1.02058, 0.93582, 0.96694, 0.93582, 1.17337, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.97276, 0.78076, 0.78076, 1.02058, 1.02058, 1.02058, 0.71541, 0.76813, 0.85576, 0.80591, 0.80729, 0.94299, 0.77512, 0.83655, 0.86523, 0.92222, 0.9862
vendor: 1,447 bytes, line 28948
289481, 0.71743, 0.81698, 0.79726, 0.98558, 0.92222, 0.90637, 0.83809, 0.90637, 0.80729, 0.76463, 0.86275, 0.90699, 0.91605, 0.9154, 0.85308, 0.85458, 0.90531, 0.94292, 1.21296, 0.94292, 1.02058, 0.89903, 1.18616, 0.99613, 0.91677, 0.78216, 0.91677, 0.90083, 0.98796, 0.9135, 0.92168, 0.95381, 0.98981, 0.95298, 0.95381, 0.93459, 0.92168, 0.91513, 0.92004, 0.91677, 0.95077, 0.748, 1.04502, 0.91677, 0.92061, 0.94236, 0.89544, 0.89364, 0.9, 0.80687, 0.8578, 0.80687, 1.02058, 0.80779, 0.97276, 0.97276, 0.97276, 0.97276, 0.8578, 0.99973, 1.18616, 0.91339, 1.08074, 0.82891, 1.02058, 0.55509, 0.71526, 0.89022, 1.08595, 1, 1, 1.18616, 1, 0.96736, 0.93582, 1.18616, 1, 1.04864, 0.82711, 0.99043, 0.99043, 0.99043, 0.71541, 0.85576, 0.85576, 0.85576, 0.85576, 0.85576, 0.85576, 0.845, 0.80729, 0.77512, 0.77512, 0.77512, 0.77512, 0.98621, 0.98621, 0.98621, 0.98621, 0.95961, 0.92222, 0.90637, 0.90637, 0.90637, 0.90637, 0.90637, 1.02058, 0.90251, 0.90699, 0.90699, 0.90699, 0.90699, 0.85458, 0.83659, 0.94951, 0.99613, 0.99613, 0.99613, 0.99613, 0.99613, 0.99613, 0.85811, 0.78216, 0.90083, 0.90083, 0.90083, 0.90083, 0.95381, 0.95381, 0.95381, 0.95381, 0.9135, 0.92168, 0.91513, 0.91513, 0.91513, 0.91513, 0.91513, 1.08595, 0.91677, 0.91677, 0.91677, 0.91677, 0.91677, 0.89364, 0.92332, 0.89364, 0.85576, 0.99613, 0.85576, 0.99613, 0.85576, 0.99613, 0.80729, 0.78216, 0.80729, 0.78216, 0.80729, 0.78216, 0.80729, 0.78216, 0.94299, 0.76783, 0.95961, 0.916
vendor: 39,631 bytes, lines 28948-29268
2894877, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.77512, 0.90083, 0.86523, 0.9135, 0.86523, 0.9135, 0.86523, 0.9135, 1, 1, 0.92222, 0.92168, 0.92222, 0.92168, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.98621, 0.95381, 0.86036, 0.97096, 0.71743, 0.98981, 1, 1, 0.95298, 0.79726, 0.95381, 1, 1, 0.79726, 0.6894, 0.79726, 0.74321, 0.81691, 1.0006, 0.92222, 0.92168, 1, 1, 0.92222, 0.92168, 0.79464, 0.92098, 0.92168, 0.90637, 0.91513, 0.90637, 0.91513, 0.90637, 0.91513, 0.909, 0.87514, 0.80729, 0.95077, 1, 1, 0.80729, 0.95077, 0.76463, 0.748, 0.76463, 0.748, 1, 1, 0.76463, 0.748, 1, 1, 0.86275, 0.72651, 0.86275, 1.04502, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.90699, 0.91677, 0.9154, 0.94236, 0.85458, 0.89364, 0.85458, 0.90531, 0.9, 0.90531, 0.9, 0.90531, 0.9, 1, 0.97276, 0.85576, 0.99613, 0.845, 0.85811, 0.90251, 0.91677, 1, 1, 0.86275, 1.04502, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.18616, 1.00899, 1.30628, 0.85576, 0.80178, 0.66862, 0.7927, 0.69323, 0.88127, 0.72459, 0.89711, 0.95381, 0.85576, 0.80591, 0.7805, 0.94729, 0.77512, 0.90531, 0.92222, 0.90637, 0.98621, 0.81698, 0.92655, 0.98558, 0.92222, 0.85359, 0.90637, 0.90976, 0.83809, 0.94523, 0.86275, 0.83509, 0.93157, 0.85308, 0.83392, 0.92346, 0.98621, 0.83509, 0.92886, 0.91324, 0.92168, 0.95381, 0.90646, 0.92886, 0.90557, 0.86847, 0.90276, 0.91324, 0.86842, 0.92168, 0.99531, 0.95381, 0.9224, 0.85408, 0.92699, 0.86847, 1.0051, 0.91513, 0.80487, 0.93481, 1, 0.88159, 1.05214, 0.90646, 0.97355, 0.81539, 0.89398, 0.85923, 0.95381, 0.90646, 0.91513, 0.90646, 0.85923, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9154, 0.94236, 0.9154, 0.94236, 0.9154, 0.94236, 0.85458, 0.89364, 0.96694, 1, 0.89903, 1, 1, 1, 0.91782, 0.91782, 0.91782, 1, 0.896, 0.896, 0.896, 0.9332, 0.9332, 0.95973, 1, 1.26, 1, 1, 0.80479, 0.80178, 1, 1, 0.85633, 1, 1, 1, 1, 0.97276, 1, 1, 1, 0.698, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.14542, 1, 0.79199, 0.78694, 1.02058, 1.03493, 1.05486, 1, 1, 1.23026, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.20006, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28949const MyriadProBoldItalicMetrics = {
28950  lineHeight: 1.2,
28951  lineGap: 0.2
28952};
28953const MyriadProItalicFactors = [1.36898, 1, 1, 0.65507, 0.84943, 0.85639, 0.88465, 0.88465, 0.86936, 0.88307, 0.86948, 0.85283, 0.85283, 1.06383, 1.02058, 0.75945, 0.9219, 0.75945, 1.17337, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.88465, 0.75945, 0.75945, 1.02058, 1.02058, 1.02058, 0.69046, 0.70926, 0.85158, 0.77812, 0.76852, 0.89591, 0.70466, 0.76125, 0.80094, 0.86822, 0.83864, 0.728, 0.77212, 0.79475, 0.93637, 0.87514, 0.8588, 0.76013, 0.8588, 0.72421, 0.69866, 0.77598, 0.85991, 0.80811, 0.87832, 0.78112, 0.77512, 0.8562, 1.0222, 1.18417, 1.0222, 1.27014, 0.89903, 1.15012, 0.93859, 0.94399, 0.846, 0.94399, 0.81453, 1.0186, 0.94219, 0.96017, 1.03075, 1.02175, 0.912, 1.03075, 0.96998, 0.96017, 0.93859, 0.94399, 0.94399, 0.95493, 0.746, 1.12658, 0.94578, 0.91, 0.979, 0.882, 0.882, 0.83, 0.85034, 0.83537, 0.85034, 1.02058, 0.70869, 0.88465, 0.88465, 0.88465, 0.88465, 0.83537, 0.90083, 1.15012, 0.9161, 0.94565, 0.73541, 1.02058, 0.53609, 0.69353, 0.79519, 1.08595, 1, 1, 1.15012, 1, 0.91974, 0.75945, 1.15012, 1, 0.9446, 0.73361, 0.9005, 0.9005, 0.9005, 0.62864, 0.85158, 0.85158, 0.85158, 0.85158, 0.85158, 0.85158, 0.773, 0.76852, 0.70466, 0.70466, 0.70466, 0.70466, 0.83864, 0.83864, 0.83864, 0.83864, 0.90561, 0.87514, 0.8588, 0.8588, 0.8588, 0.8588, 0.8588, 1.02058, 0.85751, 0.85991, 0.85991, 0.85991, 0.85991, 0.77512, 0.76013, 0.88075, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 0.8075, 0.846, 0.81453, 0.81453, 0.81453, 0.81453, 0.82424, 0.82424, 0.82424, 0.82424, 0.9278, 0.96017, 0.93859, 0.93859, 0.93859, 0.93859, 0.93859, 1.08595, 0.8562, 0.94578, 0.94578, 0.94578, 0.94578, 0.882, 0.94578, 0.882, 0.85158, 0.93859, 0.85158, 0.93859, 0.85158, 0.93859, 0.76852, 0.846, 0.76852, 0.846, 0.76852, 0.846, 0.76852, 0.846, 0.89591, 0.8544, 0.90561, 0.94399, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.70466, 0.81453, 0.80094, 0.94219, 0.80094, 0.94219, 0.80094, 0.94219, 1, 1, 0.86822, 0.96017, 0.86822, 0.96017, 0.83864, 0.82424, 0.83864, 0.82424, 0.83864, 0.82424, 0.83864, 1.03075, 0.83864, 0.82424, 0.81402, 1.02738, 0.728, 1.02175, 1, 1, 0.912, 0.79475, 1.03075, 1, 1, 0.79475, 0.83911, 0.79475, 0.66266, 0.80553, 1.06676, 0.87514, 0.96017, 1, 1, 0.87514, 0.96017, 0.86865, 0.87396, 0.96017, 0.8588, 0.93859, 0.8588, 0.93859, 0.8588, 0.93859, 0.867, 0.84759, 0.72421, 0.95493, 1, 1, 0.72421, 0.95493, 0.69866, 0.746, 0.69866, 0.746, 1, 1, 0.69866, 0.746, 1, 1, 0.77598, 0.88417, 0.77598, 1.12658, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.85991, 0.94578, 0.87832, 0.979, 0.77512, 0.882, 0.77512, 0.8562, 0.83, 0.8562, 0.83, 0.8562, 0.83, 1, 0.88465, 0.85158, 0.93859, 0.773, 0.8075, 0.85751, 0.8562, 1, 1, 0.77598, 1.12658, 1.15012, 1.15012, 1.15012, 1.15012, 1.15012, 1.15313, 1.15012, 1.15012, 1.15012, 1.08106, 1.03901, 0.85158, 0.77025, 0.62264, 0.7646, 0.65351, 0.86026, 0.69461, 0.89947, 1.03075, 0.85158, 0.77812, 0.76449, 0.88836, 0.70466, 0.8562, 0.86822, 0.8588, 0.83864, 0.77212, 0.85308, 0.93637, 0.87514, 0.82352, 0.8588, 0.85701, 0.76013, 0.89058, 0.77598, 0.8156, 0.82565, 0.78112, 0.77899, 0.89386, 0.83864, 0.8156, 0.9486, 0.92388, 0.96186, 1.03075, 0.91123, 0.9486, 0.93298, 0.878, 0.93942, 0.92388, 0.84596, 0.96186, 0.95119, 1.03075, 0.922, 0.88787, 0.95829, 0.88, 0.93559, 0.93859, 0.78815, 0.93758, 1, 0.89217, 1.03737, 0.91123, 0.93969, 0.77487, 0.85769, 0.86799, 1.03075, 0.91123, 0.93859, 0.91123, 0.86799, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.87832, 0.979, 0.87832, 0.979, 0.87832, 0.979, 0.77512, 0.882, 0.9219, 1, 0.89903, 1, 1, 1, 0.87321, 0.87321, 0.87321, 1, 1.027, 1.027, 1.027, 0.86847, 0.86847, 0.79121, 1, 1.124, 1, 1, 0.73572, 0.73572, 1, 1, 0.85034, 1, 1, 1, 1, 0.88465, 1, 1, 1, 0.669, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.04828, 1, 0.74948, 0.75187, 1.02058, 0.98391, 1.02119, 1, 1, 1.06233, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05233, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28954const MyriadProItalicMetrics = {
28955  lineHeight: 1.2,
28956  lineGap: 0.2
28957};
28958const MyriadProRegularFactors = [1.36898, 1, 1, 0.76305, 0.82784, 0.94935, 0.89364, 0.92241, 0.89073, 0.90706, 0.98472, 0.85283, 0.85283, 1.0664, 1.02058, 0.74505, 0.9219, 0.74505, 1.23456, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.92241, 0.74505, 0.74505, 1.02058, 1.02058, 1.02058, 0.73002, 0.72601, 0.91755, 0.8126, 0.80314, 0.92222, 0.73764, 0.79726, 0.83051, 0.90284, 0.86023, 0.74, 0.8126, 0.84869, 0.96518, 0.91115, 0.8858, 0.79761, 0.8858, 0.74498, 0.73914, 0.81363, 0.89591, 0.83659, 0.89633, 0.85608, 0.8111, 0.90531, 1.0222, 1.22736, 1.0222, 1.27014, 0.89903, 0.90088, 0.86667, 1.0231, 0.896, 1.01411, 0.90083, 1.05099, 1.00512, 0.99793, 1.05326, 1.09377, 0.938, 1.06226, 1.00119, 0.99793, 0.98714, 1.0231, 1.01231, 0.98196, 0.792, 1.19137, 0.99074, 0.962, 1.01915, 0.926, 0.942, 0.856, 0.85034, 0.92006, 0.85034, 1.02058, 0.69067, 0.92241, 0.92241, 0.92241, 0.92241, 0.92006, 0.9332, 0.90088, 0.91882, 0.93484, 0.75339, 1.02058, 0.56866, 0.54324, 0.79519, 1.08595, 1, 1, 0.90088, 1, 0.95325, 0.74505, 0.90088, 1, 0.97198, 0.75339, 0.91009, 0.91009, 0.91009, 0.66466, 0.91755, 0.91755, 0.91755, 0.91755, 0.91755, 0.91755, 0.788, 0.80314, 0.73764, 0.73764, 0.73764, 0.73764, 0.86023, 0.86023, 0.86023, 0.86023, 0.92915, 0.91115, 0.8858, 0.8858, 0.8858, 0.8858, 0.8858, 1.02058, 0.8858, 0.89591, 0.89591, 0.89591, 0.89591, 0.8111, 0.79611, 0.89713, 0.86667, 0.86667, 0.86667, 0.86667, 0.86667, 0.86667, 0.86936, 0.896, 0.90083, 0.90083, 0.90083, 0.90083, 0.84224, 0.84224, 0.84224, 0.84224, 0.97276, 0.99793, 0.98714, 0.98714, 0.98714, 0.98714, 0.98714, 1.08595, 0.89876, 0.99074, 0.99074, 0.99074, 0.99074, 0.942, 1.0231, 0.942, 0.91755, 0.86667, 0.91755, 0.86667, 0.91755, 0.86667, 0.80314, 0.896, 0.80314, 0.896, 0.80314, 0.896, 0.80314, 0.896, 0.92222, 0.93372, 0.92915, 1.01411, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.73764, 0.90083, 0.83051, 1.00512, 0.83051, 1.00512, 0.83051, 1.00512, 1, 1, 0.90284, 0.99793, 0.90976, 0.99793, 0.86023, 0.84224, 0.86023, 0.84224, 0.86023, 0.84224, 0.86023, 1.05326, 0.86023, 0.84224, 0.82873, 1.07469, 0.74, 1.09377, 1, 1, 0.938, 0.84869, 1.06226, 1, 1, 0.84869, 0.83704, 0.84869, 0.81441, 0.85588, 1.08927, 0.91115, 0.99793, 1, 1, 0.91115, 0.99793, 0.91887, 0.90991, 0.99793, 0.8858, 0.98714, 0.8858, 0.98714, 0.8858, 0.98714, 0.894, 0.91434, 0.74498, 0.98196, 1, 1, 0.74498, 0.98196, 0.73914, 0.792, 0.73914, 0.792, 1, 1, 0.73914, 0.792, 1, 1, 0.81363, 0.904, 0.81363, 1.19137, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89591, 0.99074, 0.89633, 1.01915, 0.8111, 0.942, 0.8111, 0.90531, 0.856, 0.90531, 0.856, 0.90531, 0.856, 1, 0.92241, 0.91755, 0.86667, 0.788, 0.86936, 0.8858, 0.89876, 1, 1, 0.81363, 1.19137, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90088, 0.90388, 1.03901, 0.92138, 0.78105, 0.7154, 0.86169, 0.80513, 0.94007, 0.82528, 0.98612, 1.06226, 0.91755, 0.8126, 0.81884, 0.92819, 0.73764, 0.90531, 0.90284, 0.8858, 0.86023, 0.8126, 0.91172, 0.96518, 0.91115, 0.83089, 0.8858, 0.87791, 0.79761, 0.89297, 0.81363, 0.88157, 0.89992, 0.85608, 0.81992, 0.94307, 0.86023, 0.88157, 0.95308, 0.98699, 0.99793, 1.06226, 0.95817, 0.95308, 0.97358, 0.928, 0.98088, 0.98699, 0.92761, 0.99793, 0.96017, 1.06226, 0.986, 0.944, 0.95978, 0.938, 0.96705, 0.98714, 0.80442, 0.98972, 1, 0.89762, 1.04552, 0.95817, 0.99007, 0.87064, 0.91879, 0.88888, 1.06226, 0.95817, 0.98714, 0.95817, 0.88888, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.89633, 1.01915, 0.89633, 1.01915, 0.89633, 1.01915, 0.8111, 0.942, 0.9219, 1, 0.89903, 1, 1, 1, 0.93173, 0.93173, 0.93173, 1, 1.06304, 1.06304, 1.06904, 0.89903, 0.89903, 0.80549, 1, 1.156, 1, 1, 0.76575, 0.76575, 1, 1, 0.72458, 1, 1, 1, 1, 0.92241, 1, 1, 1, 0.619, 1, 1.36145, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.07257, 1, 0.74705, 0.71119, 1.02058, 1.024, 1.02119, 1, 1, 1.1536, 1.08595, 1.08595, 1, 1.08595, 1.08595, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.05638, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28959const MyriadProRegularMetrics = {
28960  lineHeight: 1.2,
28961  lineGap: 0.2
28962};
28963
28964;// ./src/core/segoeui_factors.js
28965const SegoeuiBoldFactors = [1.76738, 1, 1, 0.99297, 0.9824, 1.04016, 1.06497, 1.03424, 0.97529, 1.17647, 1.23203, 1.1085, 1.1085, 1.16939, 1.2107, 0.9754, 1.21408, 0.9754, 1.59578, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 1.03424, 0.81378, 0.81378, 1.2107, 1.2107, 1.2107, 0.71703, 0.97847, 0.97363, 0.88776, 0.8641, 1.02096, 0.79795, 0.85132, 0.914, 1.06085, 1.1406, 0.8007, 0.89858, 0.83693, 1.14889, 1.09398, 0.97489, 0.92094, 0.97489, 0.90399, 0.84041, 0.95923, 1.00135, 1, 1.06467, 0.98243, 0.90996, 0.99361, 1.1085, 1.56942, 1.1085, 1.2107, 0.74627, 0.94282, 0.96752, 1.01519, 0.86304, 1.01359, 0.97278, 1.15103, 1.01359, 0.98561, 1.02285, 1.02285, 1.00527, 1.02285, 1.0302, 0.99041, 1.0008, 1.01519, 1.01359, 1.02258, 0.79104, 1.16862, 0.99041, 0.97454, 1.02511, 0.99298, 0.96752, 0.95801, 0.94856, 1.16579, 0.94856, 1.2107, 0.9824, 1.03424, 1.03424, 1, 1.03424, 1.16579, 0.8727, 1.3871, 1.18622, 1.10818, 1.04478, 1.2107, 1.18622, 0.75155, 0.94994, 1.28826, 1.21408, 1.21408, 0.91056, 1, 0.91572, 0.9754, 0.64663, 1.18328, 1.24866, 1.04478, 1.14169, 1.15749, 1.17389, 0.71703, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.93506, 0.8641, 0.79795, 0.79795, 0.79795, 0.79795, 1.1406, 1.1406, 1.1406, 1.1406, 1.02096, 1.09398, 0.97426, 0.97426, 0.97426, 0.97426, 0.97426, 1.2107, 0.97489, 1.00135, 1.00135, 1.00135, 1.00135, 0.90996, 0.92094, 1.02798, 0.96752, 0.96752, 0.96752, 0.96752, 0.96752, 0.96752, 0.93136, 0.86304, 0.97278, 0.97278, 0.97278, 0.97278, 1.02285, 1.02285, 1.02285, 1.02285, 0.97122, 0.99041, 1, 1, 1, 1, 1, 1.28826, 1.0008, 0.99041, 0.99041, 0.99041, 0.99041, 0.96752, 1.01519, 0.96752, 0.97363, 0.96752, 0.97363, 0.96752, 0.97363, 0.96752, 0.8641, 0.86304, 0.8641, 0.86304, 0.8641, 0.86304, 0.8641, 0.86304, 1.02096, 1.03057, 1.02096, 1.03517, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.79795, 0.97278, 0.914, 1.01359, 0.914, 1.01359, 0.914, 1.01359, 1, 1, 1.06085, 0.98561, 1.06085, 1.00879, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 1.1406, 1.02285, 0.97138, 1.08692, 0.8007, 1.02285, 1, 1, 1.00527, 0.83693, 1.02285, 1, 1, 0.83693, 0.9455, 0.83693, 0.90418, 0.83693, 1.13005, 1.09398, 0.99041, 1, 1, 1.09398, 0.99041, 0.96692, 1.09251, 0.99041, 0.97489, 1.0008, 0.97489, 1.0008, 0.97489, 1.0008, 0.93994, 0.97931, 0.90399, 1.02258, 1, 1, 0.90399, 1.02258, 0.84041, 0.79104, 0.84041, 0.79104, 0.84041, 0.79104, 0.84041, 0.79104, 1, 1, 0.95923, 1.07034, 0.95923, 1.16862, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.00135, 0.99041, 1.06467, 1.02511, 0.90996, 0.96752, 0.90996, 0.99361, 0.95801, 0.99361, 0.95801, 0.99361, 0.95801, 1.07733, 1.03424, 0.97363, 0.96752, 0.93506, 0.93136, 0.97489, 1.0008, 1, 1, 0.95923, 1.16862, 1.15103, 1.15103, 1.01173, 1.03959, 0.75953, 0.81378, 0.79912, 1.15103, 1.21994, 0.95161, 0.87815, 1.01149, 0.81525, 0.7676, 0.98167, 1.01134, 1.02546, 0.84097, 1.03089, 1.18102, 0.97363, 0.88776, 0.85134, 0.97826, 0.79795, 0.99361, 1.06085, 0.97489, 1.1406, 0.89858, 1.0388, 1.14889, 1.09398, 0.86039, 0.97489, 1.0595, 0.92094, 0.94793, 0.95923, 0.90996, 0.99346, 0.98243, 1.02112, 0.95493, 1.1406, 0.90996, 1.03574, 1.02597, 1.0008, 1.18102, 1.06628, 1.03574, 1.0192, 1.01932, 1.00886, 0.97531, 1.0106, 1.0008, 1.13189, 1.18102, 1.02277, 0.98683, 1.0016, 0.99561, 1.07237, 1.0008, 0.90434, 0.99921, 0.93803, 0.8965, 1.23085, 1.06628, 1.04983, 0.96268, 1.0499, 0.98439, 1.18102, 1.06628, 1.0008, 1.06628, 0.98439, 0.79795, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.09466, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.97278, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.02065, 1, 1, 1, 1, 1, 1, 1.06467, 1.02511, 1.06467, 1.02511, 1.06467, 1.02511, 0.90996, 0.96752, 1, 1.21408, 0.89903, 1, 1, 0.75155, 1.04394, 1.04394, 1.04394, 1.04394, 0.98633, 0.98633, 0.98633, 0.73047, 0.73047, 1.20642, 0.91211, 1.25635, 1.222, 1.02956, 1.03372, 1.03372, 0.96039, 1.24633, 1, 1.12454, 0.93503, 1.03424, 1.19687, 1.03424, 1, 1, 1, 0.771, 1, 1, 1.15749, 1.15749, 1.15749, 1.10948, 0.86279, 0.94434, 0.86279, 0.94434, 0.86182, 1, 1, 1.16897, 1, 0.96085, 0.90137, 1.2107, 1.18416, 1.13973, 0.69825, 0.9716, 2.10339, 1.29004, 1.29004, 1.21172, 1.29004, 1.29004, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18874, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.09193, 1.09193, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28966const SegoeuiBoldMetrics = {
28967  lineHeight: 1.33008,
28968  lineGap: 0
28969};
28970const SegoeuiBoldItalicFactors = [1.76738, 1, 1, 0.98946, 1.03959, 1.04016, 1.02809, 1.036, 0.97639, 1.10953, 1.23203, 1.11144, 1.11144, 1.16939, 1.21237, 0.9754, 1.21261, 0.9754, 1.59754, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 1.036, 0.81378, 0.81378, 1.21237, 1.21237, 1.21237, 0.73541, 0.97847, 0.97363, 0.89723, 0.87897, 1.0426, 0.79429, 0.85292, 0.91149, 1.05815, 1.1406, 0.79631, 0.90128, 0.83853, 1.04396, 1.10615, 0.97552, 0.94436, 0.97552, 0.88641, 0.80527, 0.96083, 1.00135, 1, 1.06777, 0.9817, 0.91142, 0.99361, 1.11144, 1.57293, 1.11144, 1.21237, 0.74627, 1.31818, 1.06585, 0.97042, 0.83055, 0.97042, 0.93503, 1.1261, 0.97042, 0.97922, 1.14236, 0.94552, 1.01054, 1.14236, 1.02471, 0.97922, 0.94165, 0.97042, 0.97042, 1.0276, 0.78929, 1.1261, 0.97922, 0.95874, 1.02197, 0.98507, 0.96752, 0.97168, 0.95107, 1.16579, 0.95107, 1.21237, 1.03959, 1.036, 1.036, 1, 1.036, 1.16579, 0.87357, 1.31818, 1.18754, 1.26781, 1.05356, 1.21237, 1.18622, 0.79487, 0.94994, 1.29004, 1.24047, 1.24047, 1.31818, 1, 0.91484, 0.9754, 1.31818, 1.1349, 1.24866, 1.05356, 1.13934, 1.15574, 1.17389, 0.73541, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.97363, 0.94385, 0.87897, 0.79429, 0.79429, 0.79429, 0.79429, 1.1406, 1.1406, 1.1406, 1.1406, 1.0426, 1.10615, 0.97552, 0.97552, 0.97552, 0.97552, 0.97552, 1.21237, 0.97552, 1.00135, 1.00135, 1.00135, 1.00135, 0.91142, 0.94436, 0.98721, 1.06585, 1.06585, 1.06585, 1.06585, 1.06585, 1.06585, 0.96705, 0.83055, 0.93503, 0.93503, 0.93503, 0.93503, 1.14236, 1.14236, 1.14236, 1.14236, 0.93125, 0.97922, 0.94165, 0.94165, 0.94165, 0.94165, 0.94165, 1.29004, 0.94165, 0.97922, 0.97922, 0.97922, 0.97922, 0.96752, 0.97042, 0.96752, 0.97363, 1.06585, 0.97363, 1.06585, 0.97363, 1.06585, 0.87897, 0.83055, 0.87897, 0.83055, 0.87897, 0.83055, 0.87897, 0.83055, 1.0426, 1.0033, 1.0426, 0.97042, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.79429, 0.93503, 0.91149, 0.97042, 0.91149, 0.97042, 0.91149, 0.97042, 1, 1, 1.05815, 0.97922, 1.05815, 0.97922, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 1.1406, 1.14236, 0.97441, 1.04302, 0.79631, 1.01582, 1, 1, 1.01054, 0.83853, 1.14236, 1, 1, 0.83853, 1.09125, 0.83853, 0.90418, 0.83853, 1.19508, 1.10615, 0.97922, 1, 1, 1.10615, 0.97922, 1.01034, 1.10466, 0.97922, 0.97552, 0.94165, 0.97552, 0.94165, 0.97552, 0.94165, 0.91602, 0.91981, 0.88641, 1.0276, 1, 1, 0.88641, 1.0276, 0.80527, 0.78929, 0.80527, 0.78929, 0.80527, 0.78929, 0.80527, 0.78929, 1, 1, 0.96083, 1.05403, 0.95923, 1.16862, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.00135, 0.97922, 1.06777, 1.02197, 0.91142, 0.96752, 0.91142, 0.99361, 0.97168, 0.99361, 0.97168, 0.99361, 0.97168, 1.23199, 1.036, 0.97363, 1.06585, 0.94385, 0.96705, 0.97552, 0.94165, 1, 1, 0.96083, 1.1261, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 1.31818, 0.95161, 1.27126, 1.00811, 0.83284, 0.77702, 0.99137, 0.95253, 1.0347, 0.86142, 1.07205, 1.14236, 0.97363, 0.89723, 0.86869, 1.09818, 0.79429, 0.99361, 1.05815, 0.97552, 1.1406, 0.90128, 1.06662, 1.04396, 1.10615, 0.84918, 0.97552, 1.04694, 0.94436, 0.98015, 0.96083, 0.91142, 1.00356, 0.9817, 1.01945, 0.98999, 1.1406, 0.91142, 1.04961, 0.9898, 1.00639, 1.14236, 1.07514, 1.04961, 0.99607, 1.02897, 1.008, 0.9898, 0.95134, 1.00639, 1.11121, 1.14236, 1.00518, 0.97981, 1.02186, 1, 1.08578, 0.94165, 0.99314, 0.98387, 0.93028, 0.93377, 1.35125, 1.07514, 1.10687, 0.93491, 1.04232, 1.00351, 1.14236, 1.07514, 0.94165, 1.07514, 1.00351, 0.79429, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.09097, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.93503, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.96609, 1, 1, 1, 1, 1, 1, 1.06777, 1.02197, 1.06777, 1.02197, 1.06777, 1.02197, 0.91142, 0.96752, 1, 1.21261, 0.89903, 1, 1, 0.75155, 1.04745, 1.04745, 1.04745, 1.04394, 0.98633, 0.98633, 0.98633, 0.72959, 0.72959, 1.20502, 0.91406, 1.26514, 1.222, 1.02956, 1.03372, 1.03372, 0.96039, 1.24633, 1, 1.09125, 0.93327, 1.03336, 1.16541, 1.036, 1, 1, 1, 0.771, 1, 1, 1.15574, 1.15574, 1.15574, 1.15574, 0.86364, 0.94434, 0.86279, 0.94434, 0.86224, 1, 1, 1.16798, 1, 0.96085, 0.90068, 1.21237, 1.18416, 1.13904, 0.69825, 0.9716, 2.10339, 1.29004, 1.29004, 1.21339, 1.29004, 1.29004, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18775, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.13269, 1.13269, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28971const SegoeuiBoldItalicMetrics = {
28972  lineHeight: 1.33008,
28973  lineGap: 0
28974};
28975const SegoeuiItalicFactors = [1.76738, 1, 1, 0.98946, 1.14763, 1.05365, 1.06234, 0.96927, 0.92586, 1.15373, 1.18414, 0.91349, 0.91349, 1.07403, 1.17308, 0.78383, 1.20088, 0.78383, 1.42531, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.78383, 0.78383, 1.17308, 1.17308, 1.17308, 0.77349, 0.94565, 0.94729, 0.85944, 0.88506, 0.9858, 0.74817, 0.80016, 0.88449, 0.98039, 0.95782, 0.69238, 0.89898, 0.83231, 0.98183, 1.03989, 0.96924, 0.86237, 0.96924, 0.80595, 0.74524, 0.86091, 0.95402, 0.94143, 0.98448, 0.8858, 0.83089, 0.93285, 1.0949, 1.39016, 1.0949, 1.45994, 0.74627, 1.04839, 0.97454, 0.97454, 0.87207, 0.97454, 0.87533, 1.06151, 0.97454, 1.00176, 1.16484, 1.08132, 0.98047, 1.16484, 1.02989, 1.01054, 0.96225, 0.97454, 0.97454, 1.06598, 0.79004, 1.16344, 1.00351, 0.94629, 0.9973, 0.91016, 0.96777, 0.9043, 0.91082, 0.92481, 0.91082, 1.17308, 0.95748, 0.96927, 0.96927, 1, 0.96927, 0.92481, 0.80597, 1.04839, 1.23393, 1.1781, 0.9245, 1.17308, 1.20808, 0.63218, 0.94261, 1.24822, 1.09971, 1.09971, 1.04839, 1, 0.85273, 0.78032, 1.04839, 1.09971, 1.22326, 0.9245, 1.09836, 1.13525, 1.15222, 0.70424, 0.94729, 0.94729, 0.94729, 0.94729, 0.94729, 0.94729, 0.85498, 0.88506, 0.74817, 0.74817, 0.74817, 0.74817, 0.95782, 0.95782, 0.95782, 0.95782, 0.9858, 1.03989, 0.96924, 0.96924, 0.96924, 0.96924, 0.96924, 1.17308, 0.96924, 0.95402, 0.95402, 0.95402, 0.95402, 0.83089, 0.86237, 0.88409, 0.97454, 0.97454, 0.97454, 0.97454, 0.97454, 0.97454, 0.92916, 0.87207, 0.87533, 0.87533, 0.87533, 0.87533, 0.93146, 0.93146, 0.93146, 0.93146, 0.93854, 1.01054, 0.96225, 0.96225, 0.96225, 0.96225, 0.96225, 1.24822, 0.8761, 1.00351, 1.00351, 1.00351, 1.00351, 0.96777, 0.97454, 0.96777, 0.94729, 0.97454, 0.94729, 0.97454, 0.94729, 0.97454, 0.88506, 0.87207, 0.88506, 0.87207, 0.88506, 0.87207, 0.88506, 0.87207, 0.9858, 0.95391, 0.9858, 0.97454, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.74817, 0.87533, 0.88449, 0.97454, 0.88449, 0.97454, 0.88449, 0.97454, 1, 1, 0.98039, 1.00176, 0.98039, 1.00176, 0.95782, 0.93146, 0.95782, 0.93146, 0.95782, 0.93146, 0.95782, 1.16484, 0.95782, 0.93146, 0.84421, 1.12761, 0.69238, 1.08132, 1, 1, 0.98047, 0.83231, 1.16484, 1, 1, 0.84723, 1.04861, 0.84723, 0.78755, 0.83231, 1.23736, 1.03989, 1.01054, 1, 1, 1.03989, 1.01054, 0.9857, 1.03849, 1.01054, 0.96924, 0.96225, 0.96924, 0.96225, 0.96924, 0.96225, 0.92383, 0.90171, 0.80595, 1.06598, 1, 1, 0.80595, 1.06598, 0.74524, 0.79004, 0.74524, 0.79004, 0.74524, 0.79004, 0.74524, 0.79004, 1, 1, 0.86091, 1.02759, 0.85771, 1.16344, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.95402, 1.00351, 0.98448, 0.9973, 0.83089, 0.96777, 0.83089, 0.93285, 0.9043, 0.93285, 0.9043, 0.93285, 0.9043, 1.31868, 0.96927, 0.94729, 0.97454, 0.85498, 0.92916, 0.96924, 0.8761, 1, 1, 0.86091, 1.16344, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 1.04839, 0.81965, 0.81965, 0.94729, 0.78032, 0.71022, 0.90883, 0.84171, 0.99877, 0.77596, 1.05734, 1.2, 0.94729, 0.85944, 0.82791, 0.9607, 0.74817, 0.93285, 0.98039, 0.96924, 0.95782, 0.89898, 0.98316, 0.98183, 1.03989, 0.78614, 0.96924, 0.97642, 0.86237, 0.86075, 0.86091, 0.83089, 0.90082, 0.8858, 0.97296, 1.01284, 0.95782, 0.83089, 1.0976, 1.04, 1.03342, 1.2, 1.0675, 1.0976, 0.98205, 1.03809, 1.05097, 1.04, 0.95364, 1.03342, 1.05401, 1.2, 1.02148, 1.0119, 1.04724, 1.0127, 1.02732, 0.96225, 0.8965, 0.97783, 0.93574, 0.94818, 1.30679, 1.0675, 1.11826, 0.99821, 1.0557, 1.0326, 1.2, 1.0675, 0.96225, 1.0675, 1.0326, 0.74817, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.03754, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.87533, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.98705, 1, 1, 1, 1, 1, 1, 0.98448, 0.9973, 0.98448, 0.9973, 0.98448, 0.9973, 0.83089, 0.96777, 1, 1.20088, 0.89903, 1, 1, 0.75155, 0.94945, 0.94945, 0.94945, 0.94945, 1.12317, 1.12317, 1.12317, 0.67603, 0.67603, 1.15621, 0.73584, 1.21191, 1.22135, 1.06483, 0.94868, 0.94868, 0.95996, 1.24633, 1, 1.07497, 0.87709, 0.96927, 1.01473, 0.96927, 1, 1, 1, 0.77295, 1, 1, 1.09836, 1.09836, 1.09836, 1.01522, 0.86321, 0.94434, 0.8649, 0.94434, 0.86182, 1, 1, 1.083, 1, 0.91578, 0.86438, 1.17308, 1.18416, 1.14589, 0.69825, 0.97622, 1.96791, 1.24822, 1.24822, 1.17308, 1.24822, 1.24822, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.17984, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.10742, 1.10742, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28976const SegoeuiItalicMetrics = {
28977  lineHeight: 1.33008,
28978  lineGap: 0
28979};
28980const SegoeuiRegularFactors = [1.76738, 1, 1, 0.98594, 1.02285, 1.10454, 1.06234, 0.96927, 0.92037, 1.19985, 1.2046, 0.90616, 0.90616, 1.07152, 1.1714, 0.78032, 1.20088, 0.78032, 1.40246, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.96927, 0.78032, 0.78032, 1.1714, 1.1714, 1.1714, 0.80597, 0.94084, 0.96706, 0.85944, 0.85734, 0.97093, 0.75842, 0.79936, 0.88198, 0.9831, 0.95782, 0.71387, 0.86969, 0.84636, 1.07796, 1.03584, 0.96924, 0.83968, 0.96924, 0.82826, 0.79649, 0.85771, 0.95132, 0.93119, 0.98965, 0.88433, 0.8287, 0.93365, 1.08612, 1.3638, 1.08612, 1.45786, 0.74627, 0.80499, 0.91484, 1.05707, 0.92383, 1.05882, 0.9403, 1.12654, 1.05882, 1.01756, 1.09011, 1.09011, 0.99414, 1.09011, 1.034, 1.01756, 1.05356, 1.05707, 1.05882, 1.04399, 0.84863, 1.21968, 1.01756, 0.95801, 1.00068, 0.91797, 0.96777, 0.9043, 0.90351, 0.92105, 0.90351, 1.1714, 0.85337, 0.96927, 0.96927, 0.99912, 0.96927, 0.92105, 0.80597, 1.2434, 1.20808, 1.05937, 0.90957, 1.1714, 1.20808, 0.75155, 0.94261, 1.24644, 1.09971, 1.09971, 0.84751, 1, 0.85273, 0.78032, 0.61584, 1.05425, 1.17914, 0.90957, 1.08665, 1.11593, 1.14169, 0.73381, 0.96706, 0.96706, 0.96706, 0.96706, 0.96706, 0.96706, 0.86035, 0.85734, 0.75842, 0.75842, 0.75842, 0.75842, 0.95782, 0.95782, 0.95782, 0.95782, 0.97093, 1.03584, 0.96924, 0.96924, 0.96924, 0.96924, 0.96924, 1.1714, 0.96924, 0.95132, 0.95132, 0.95132, 0.95132, 0.8287, 0.83968, 0.89049, 0.91484, 0.91484, 0.91484, 0.91484, 0.91484, 0.91484, 0.93575, 0.92383, 0.9403, 0.9403, 0.9403, 0.9403, 0.8717, 0.8717, 0.8717, 0.8717, 1.00527, 1.01756, 1.05356, 1.05356, 1.05356, 1.05356, 1.05356, 1.24644, 0.95923, 1.01756, 1.01756, 1.01756, 1.01756, 0.96777, 1.05707, 0.96777, 0.96706, 0.91484, 0.96706, 0.91484, 0.96706, 0.91484, 0.85734, 0.92383, 0.85734, 0.92383, 0.85734, 0.92383, 0.85734, 0.92383, 0.97093, 1.0969, 0.97093, 1.05882, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.75842, 0.9403, 0.88198, 1.05882, 0.88198, 1.05882, 0.88198, 1.05882, 1, 1, 0.9831, 1.01756, 0.9831, 1.01756, 0.95782, 0.8717, 0.95782, 0.8717, 0.95782, 0.8717, 0.95782, 1.09011, 0.95782, 0.8717, 0.84784, 1.11551, 0.71387, 1.09011, 1, 1, 0.99414, 0.84636, 1.09011, 1, 1, 0.84636, 1.0536, 0.84636, 0.94298, 0.84636, 1.23297, 1.03584, 1.01756, 1, 1, 1.03584, 1.01756, 1.00323, 1.03444, 1.01756, 0.96924, 1.05356, 0.96924, 1.05356, 0.96924, 1.05356, 0.93066, 0.98293, 0.82826, 1.04399, 1, 1, 0.82826, 1.04399, 0.79649, 0.84863, 0.79649, 0.84863, 0.79649, 0.84863, 0.79649, 0.84863, 1, 1, 0.85771, 1.17318, 0.85771, 1.21968, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.95132, 1.01756, 0.98965, 1.00068, 0.8287, 0.96777, 0.8287, 0.93365, 0.9043, 0.93365, 0.9043, 0.93365, 0.9043, 1.08571, 0.96927, 0.96706, 0.91484, 0.86035, 0.93575, 0.96924, 0.95923, 1, 1, 0.85771, 1.21968, 1.11437, 1.11437, 0.93109, 0.91202, 0.60411, 0.84164, 0.55572, 1.01173, 0.97361, 0.81818, 0.81818, 0.96635, 0.78032, 0.72727, 0.92366, 0.98601, 1.03405, 0.77968, 1.09799, 1.2, 0.96706, 0.85944, 0.85638, 0.96491, 0.75842, 0.93365, 0.9831, 0.96924, 0.95782, 0.86969, 0.94152, 1.07796, 1.03584, 0.78437, 0.96924, 0.98715, 0.83968, 0.83491, 0.85771, 0.8287, 0.94492, 0.88433, 0.9287, 1.0098, 0.95782, 0.8287, 1.0625, 0.98248, 1.03424, 1.2, 1.01071, 1.0625, 0.95246, 1.03809, 1.04912, 0.98248, 1.00221, 1.03424, 1.05443, 1.2, 1.04785, 0.99609, 1.00169, 1.05176, 0.99346, 1.05356, 0.9087, 1.03004, 0.95542, 0.93117, 1.23362, 1.01071, 1.07831, 1.02512, 1.05205, 1.03502, 1.2, 1.01071, 1.05356, 1.01071, 1.03502, 0.75842, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.03719, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9403, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.04021, 1, 1, 1, 1, 1, 1, 0.98965, 1.00068, 0.98965, 1.00068, 0.98965, 1.00068, 0.8287, 0.96777, 1, 1.20088, 0.89903, 1, 1, 0.75155, 1.03077, 1.03077, 1.03077, 1.03077, 1.13196, 1.13196, 1.13196, 0.67428, 0.67428, 1.16039, 0.73291, 1.20996, 1.22135, 1.06483, 0.94868, 0.94868, 0.95996, 1.24633, 1, 1.07497, 0.87796, 0.96927, 1.01518, 0.96927, 1, 1, 1, 0.77295, 1, 1, 1.10539, 1.10539, 1.11358, 1.06967, 0.86279, 0.94434, 0.86279, 0.94434, 0.86182, 1, 1, 1.083, 1, 0.91578, 0.86507, 1.1714, 1.18416, 1.14589, 0.69825, 0.97622, 1.9697, 1.24822, 1.24822, 1.17238, 1.24822, 1.24822, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.42603, 1, 0.99862, 0.99862, 1, 0.87025, 0.87025, 0.87025, 0.87025, 1.18083, 1.42603, 1, 1.42603, 1.42603, 0.99862, 1, 1, 1, 1, 1, 1.2886, 1.04315, 1.15296, 1.34163, 1, 1, 1, 1.10938, 1.10938, 1, 1, 1, 1.05425, 1.09971, 1.09971, 1.09971, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
28981const SegoeuiRegularMetrics = {
28982  lineHeight: 1.33008,
28983  lineGap: 0
28984};
28985
28986;// ./src/core/xfa_fonts.js
28987
28988
28989
28990
28991
28992
28993
28994
28995const getXFAFontMap = getLookupTableFactory(function (t) {
28996  t["MyriadPro-Regular"] = t["PdfJS-Fallback-Regular"] = {
28997    name: "LiberationSans-Regular",
28998    factors: MyriadProRegularFactors,
28999    baseWidths: LiberationSansRegularWidths,
29000    baseMapping: LiberationSansRegularMapping,
29001    metrics: MyriadProRegularMetrics
29002  };
29003  t["MyriadPro-Bold"] = t["PdfJS-Fallback-Bold"] = {
29004    name: "LiberationSans-Bold",
29005    factors: MyriadProBoldFactors,
29006    baseWidths: LiberationSansBoldWidths,
29007    baseMapping: LiberationSansBoldMapping,
29008    metrics: MyriadProBoldMetrics
29009  };
29010  t["MyriadPro-It"] = t["MyriadPro-Italic"] = t["PdfJS-Fallback-Italic"] = {
29011    name: "LiberationSans-Italic",
29012    factors: MyriadProItalicFactors,
29013    baseWidths: LiberationSansItalicWidths,
29014    baseMapping: LiberationSansItalicMapping,
29015    metrics: MyriadProItalicMetrics
29016  };
29017  t["MyriadPro-BoldIt"] = t["MyriadPro-BoldItalic"] = t["PdfJS-Fallback-BoldItalic"] = {
29018    name: "LiberationSans-BoldItalic",
29019    factors: MyriadProBoldItalicFactors,
29020    baseWidths: LiberationSansBoldItalicWidths,
29021    baseMapping: LiberationSansBoldItalicMapping,
29022    metrics: MyriadProBoldItalicMetrics
29023  };
29024  t.ArialMT = t.Arial = t["Arial-Regular"] = {
29025    name: "LiberationSans-Regular",
29026    baseWidths: LiberationSansRegularWidths,
29027    baseMapping: LiberationSansRegularMapping
29028  };
29029  t["Arial-BoldMT"] = t["Arial-Bold"] = {
29030    name: "LiberationSans-Bold",
29031    baseWidths: LiberationSansBoldWidths,
29032    baseMapping: LiberationSansBoldMapping
29033  };
29034  t["Arial-ItalicMT"] = t["Arial-Italic"] = {
29035    name: "LiberationSans-Italic",
29036    baseWidths: LiberationSansItalicWidths,
29037    baseMapping: LiberationSansItalicMapping
29038  };
29039  t["Arial-BoldItalicMT"] = t["Arial-BoldItalic"] = {
29040    name: "LiberationSans-BoldItalic",
29041    baseWidths: LiberationSansBoldItalicWidths,
29042    baseMapping: LiberationSansBoldItalicMapping
29043  };
29044  t["Calibri-Regular"] = {
29045    name: "LiberationSans-Regular",
29046    factors: CalibriRegularFactors,
29047    baseWidths: LiberationSansRegularWidths,
29048    baseMapping: LiberationSansRegularMapping,
29049    metrics: CalibriRegularMetrics
29050  };
29051  t["Calibri-Bold"] = {
29052    name: "LiberationSans-Bold",
29053    factors: CalibriBoldFactors,
29054    baseWidths: LiberationSansBoldWidths,
29055    baseMapping: LiberationSansBoldMapping,
29056    metrics: CalibriBoldMetrics
29057  };
29058  t["Calibri-Italic"] = {
29059    name: "LiberationSans-Italic",
29060    factors: CalibriItalicFactors,
29061    baseWidths: LiberationSansItalicWidths,
29062    baseMapping: LiberationSansItalicMapping,
29063    metrics: CalibriItalicMetrics
29064  };
29065  t["Calibri-BoldItalic"] = {
29066    name: "LiberationSans-BoldItalic",
29067    factors: CalibriBoldItalicFactors,
29068    baseWidths: LiberationSansBoldItalicWidths,
29069    baseMapping: LiberationSansBoldItalicMapping,
29070    metrics: CalibriBoldItalicMetrics
29071  };
29072  t["Segoeui-Regular"] = {
29073    name: "LiberationSans-Regular",
29074    factors: SegoeuiRegularFactors,
29075    baseWidths: LiberationSansRegularWidths,
29076    baseMapping: LiberationSansRegularMapping,
29077    metrics: SegoeuiRegularMetrics
29078  };
29079  t["Segoeui-Bold"] = {
29080    name: "LiberationSans-Bold",
29081    factors: SegoeuiBoldFactors,
29082    baseWidths: LiberationSansBoldWidths,
29083    baseMapping: LiberationSansBoldMapping,
29084    metrics: SegoeuiBoldMetrics
29085  };
29086  t["Segoeui-Italic"] = {
29087    name: "LiberationSans-Italic",
29088    factors: SegoeuiItalicFactors,
29089    baseWidths: LiberationSansItalicWidths,
29090    baseMapping: LiberationSansItalicMapping,
29091    metrics: SegoeuiItalicMetrics
29092  };
29093  t["Segoeui-BoldItalic"] = {
29094    name: "LiberationSans-BoldItalic",
29095    factors: SegoeuiBoldItalicFactors,
29096    baseWidths: LiberationSansBoldItalicWidths,
29097    baseMapping: LiberationSansBoldItalicMapping,
29098    metrics: SegoeuiBoldItalicMetrics
29099  };
29100  t["Helvetica-Regular"] = t.Helvetica = {
29101    name: "LiberationSans-Regular",
29102    factors: HelveticaRegularFactors,
29103    baseWidths: LiberationSansRegularWidths,
29104    baseMapping: LiberationSansRegularMapping,
29105    metrics: HelveticaRegularMetrics
29106  };
29107  t["Helvetica-Bold"] = {
29108    name: "LiberationSans-Bold",
29109    factors: HelveticaBoldFactors,
29110    baseWidths: LiberationSansBoldWidths,
29111    baseMapping: LiberationSansBoldMapping,
29112    metrics: HelveticaBoldMetrics
29113  };
29114  t["Helvetica-Italic"] = {
29115    name: "LiberationSans-Italic",
29116    factors: HelveticaItalicFactors,
29117    baseWidths: LiberationSansItalicWidths,
29118    baseMapping: LiberationSansItalicMapping,
29119    metrics: HelveticaItalicMetrics
29120  };
29121  t["Helvetica-BoldItalic"] = {
29122    name: "LiberationSans-BoldItalic",
29123    factors: HelveticaBoldItalicFactors,
29124    baseWidths: LiberationSansBoldItalicWidths,
29125    baseMapping: LiberationSansBoldItalicMapping,
29126    metrics: HelveticaBoldItalicMetrics
29127  };
29128});
29129function getXfaFontName(name) {
29130  const fontName = normalizeFontName(name);
29131  const fontMap = getXFAFontMap();
29132  return fontMap[fontName];
29133}
29134function getXfaFontWidths(name) {
29135  const info = getXfaFontName(name);
29136  if (!info) {
29137    return null;
29138  }
29139  const {
29140    baseWidths,
29141    baseMapping,
29142    factors
29143  } = info;
29144  const rescaledBaseWidths = !factors ? baseWidths : baseWidths.map((w, i) => w * factors[i]);
29145  let currentCode = -2;
29146  let currentArray;
29147  const newWidths = [];
29148  for (const [unicode, glyphIndex] of baseMapping.map((charUnicode, index) => [charUnicode, index]).sort(([unicode1], [unicode2]) => unicode1 - unicode2)) {
29149    if (unicode === -1) {
29150      continue;
29151    }
29152    if (unicode === currentCode + 1) {
29153      currentArray.push(rescaledBaseWidths[glyphIndex]);
29154      currentCode += 1;
29155    } else {
29156      currentCode = unicode;
29157      currentArray = [rescaledBaseWidths[glyphIndex]];
29158      newWidths.push(unicode, currentArray);
29159    }
29160  }
29161  return newWidths;
29162}
29163function getXfaFontDict(name) {
29164  const widths = getXfaFontWidths(name);
29165  const dict = new Dict(null);
29166  dict.set("BaseFont", Name.get(name));
29167  dict.set("Type", Name.get("Font"));
29168  dict.set("Subtype", Name.get("CIDFontType2"));
29169  dict.set("Encoding", Name.get("Identity-H"));
29170  dict.set("CIDToGIDMap", Name.get("Identity"));
29171  dict.set("W", widths);
29172  dict.set("FirstChar", widths[0]);
29173  dict.set("LastChar", widths.at(-2) + widths.at(-1).length - 1);
29174  const descriptor = new Dict(null);
29175  dict.set("FontDescriptor", descriptor);
29176  const systemInfo = new Dict(null);
29177  systemInfo.set("Ordering", "Identity");
29178  systemInfo.set("Registry", "Adobe");
29179  systemInfo.set("Supplement", 0);
29180  dict.set("CIDSystemInfo", systemInfo);
29181  return dict;
29182}
29183
29184;// ./src/core/postscript/lexer.js
29185const TOKEN = {
29186  number: 0,
29187  lbrace: 1,
29188  rbrace: 2,
29189  true: 3,
29190  false: 4,
29191  add: 5,
29192  sub: 6,
29193  mul: 7,
29194  div: 8,
29195  idiv: 9,
29196  mod: 10,
29197  exp: 11,
29198  eq: 12,
29199  ne: 13,
29200  gt: 14,
29201  ge: 15,
29202  lt: 16,
29203  le: 17,
29204  and: 18,
29205  or: 19,
29206  xor: 20,
29207  bitshift: 21,
29208  abs: 22,
29209  neg: 23,
29210  ceiling: 24,
29211  floor: 25,
29212  round: 26,
29213  truncate: 27,
29214  not: 28,
29215  sqrt: 29,
29216  sin: 30,
29217  cos: 31,
29218  ln: 32,
29219  log: 33,
29220  atan: 34,
29221  cvi: 35,
29222  cvr: 36,
29223  dup: 37,
29224  exch: 38,
29225  pop: 39,
29226  copy: 40,
29227  index: 41,
29228  roll: 42,
29229  if: 43,
29230  ifelse: 44,
29231  eof: 45,
29232  min: 46,
29233  max: 47
29234};
29235class Token {
29236  constructor(id, value = null) {
29237    this.id = id;
29238    this.value = value;
29239  }
29240}
29241class lexer_Lexer {
29242  static #singletons = null;
29243  static #operatorSingletons = null;
29244  static #initSingletons() {
29245    const singletons = Object.create(null);
29246    const operatorSingletons = Object.create(null);
29247    for (const [name, id] of Object.entries(TOKEN)) {
29248      if (name === "number") {
29249        continue;
29250      }
29251      const isOperator = id >= TOKEN.true && id <= TOKEN.ifelse;
29252      const token = new Token(id, isOperator ? name : null);
29253      singletons[name] = token;
29254      if (isOperator) {
29255        operatorSingletons[name] = token;
29256      }
29257    }
29258    this.#singletons = singletons;
29259    this.#operatorSingletons = operatorSingletons;
29260  }
29261  constructor(data) {
29262    if (!lexer_Lexer.#singletons) {
29263      lexer_Lexer.#initSingletons();
29264    }
29265    this.data = data;
29266    this.pos = 0;
29267    this.len = data.length;
29268    this._numberPattern = /[+-]?(?:\d+
29268\.?\d*
vendor: 45,982 bytes, lines 29268-30966
29268|\.\d+)(?:e[+-]?\d+)?/iy;
29269    this._identifierPattern = /[a-z]+/y;
29270  }
29271  _skipComment() {
29272    const lf = this.data.indexOf("\n", this.pos);
29273    const cr = this.data.indexOf("\r", this.pos);
29274    const eol = Math.min(lf < 0 ? this.len : lf, cr < 0 ? this.len : cr);
29275    this.pos = Math.min(eol + 1, this.len);
29276  }
29277  _getNumber() {
29278    this._numberPattern.lastIndex = this.pos;
29279    const match = this._numberPattern.exec(this.data);
29280    if (!match) {
29281      return new Token(TOKEN.number, 0);
29282    }
29283    const number = parseFloat(match[0]);
29284    if (!Number.isFinite(number)) {
29285      return new Token(TOKEN.number, 0);
29286    }
29287    this.pos = this._numberPattern.lastIndex;
29288    return new Token(TOKEN.number, number);
29289  }
29290  _getOperator() {
29291    this._identifierPattern.lastIndex = this.pos;
29292    const match = this._identifierPattern.exec(this.data);
29293    if (!match) {
29294      return new Token(TOKEN.number, 0);
29295    }
29296    this.pos = this._identifierPattern.lastIndex;
29297    const op = match[0];
29298    const token = lexer_Lexer.#operatorSingletons[op];
29299    if (!token) {
29300      return new Token(TOKEN.number, 0);
29301    }
29302    return token;
29303  }
29304  next() {
29305    while (this.pos < this.len) {
29306      const ch = this.data.charCodeAt(this.pos++);
29307      switch (ch) {
29308        case 0x00:
29309        case 0x09:
29310        case 0x0a:
29311        case 0x0c:
29312        case 0x0d:
29313        case 0x20:
29314          break;
29315        case 0x25:
29316          this._skipComment();
29317          break;
29318        case 0x7b:
29319          return lexer_Lexer.#singletons.lbrace;
29320        case 0x7d:
29321          return lexer_Lexer.#singletons.rbrace;
29322        case 0x2b:
29323        case 0x2d:
29324          this.pos--;
29325          return this._getNumber();
29326        case 0x2e:
29327          this.pos--;
29328          return this._getNumber();
29329        default:
29330          if (ch >= 0x30 && ch <= 0x39) {
29331            this.pos--;
29332            return this._getNumber();
29333          }
29334          if (ch >= 0x61 && ch <= 0x7a) {
29335            this.pos--;
29336            return this._getOperator();
29337          }
29338          return new Token(TOKEN.number, 0);
29339      }
29340    }
29341    return lexer_Lexer.#singletons.eof;
29342  }
29343}
29344
29345;// ./src/core/postscript/ast.js
29346
29347
29348const PS_VALUE_TYPE = {
29349  numeric: 0,
29350  boolean: 1,
29351  unknown: 2
29352};
29353const PS_NODE = {
29354  program: 0,
29355  block: 1,
29356  number: 2,
29357  operator: 3,
29358  if: 4,
29359  ifelse: 5,
29360  arg: 6,
29361  const: 7,
29362  unary: 8,
29363  binary: 9,
29364  ternary: 10
29365};
29366class PsNode {
29367  constructor(type) {
29368    this.type = type;
29369  }
29370}
29371class PsProgram extends PsNode {
29372  constructor(body) {
29373    super(PS_NODE.program);
29374    this.body = body;
29375  }
29376}
29377class PsBlock extends PsNode {
29378  constructor(instructions) {
29379    super(PS_NODE.block);
29380    this.instructions = instructions;
29381  }
29382}
29383class PsNumber extends PsNode {
29384  constructor(value) {
29385    super(PS_NODE.number);
29386    this.value = value;
29387  }
29388}
29389class PsOperator extends PsNode {
29390  constructor(op) {
29391    super(PS_NODE.operator);
29392    this.op = op;
29393  }
29394}
29395class PsIf extends PsNode {
29396  constructor(then) {
29397    super(PS_NODE.if);
29398    this.then = then;
29399  }
29400}
29401class PsIfElse extends PsNode {
29402  constructor(then, otherwise) {
29403    super(PS_NODE.ifelse);
29404    this.then = then;
29405    this.otherwise = otherwise;
29406  }
29407}
29408class PsArgNode extends PsNode {
29409  constructor(index) {
29410    super(PS_NODE.arg);
29411    this.index = index;
29412    this.valueType = PS_VALUE_TYPE.numeric;
29413  }
29414}
29415class PsConstNode extends PsNode {
29416  constructor(value) {
29417    super(PS_NODE.const);
29418    this.value = value;
29419    this.valueType = typeof value === "boolean" ? PS_VALUE_TYPE.boolean : PS_VALUE_TYPE.numeric;
29420  }
29421}
29422class PsUnaryNode extends PsNode {
29423  constructor(op, operand, valueType = PS_VALUE_TYPE.unknown) {
29424    super(PS_NODE.unary);
29425    this.op = op;
29426    this.operand = operand;
29427    this.valueType = valueType;
29428  }
29429}
29430class PsBinaryNode extends PsNode {
29431  constructor(op, first, second, valueType = PS_VALUE_TYPE.unknown) {
29432    super(PS_NODE.binary);
29433    this.op = op;
29434    this.first = first;
29435    this.second = second;
29436    this.valueType = valueType;
29437  }
29438}
29439class PsTernaryNode extends PsNode {
29440  constructor(cond, then, otherwise, valueType = PS_VALUE_TYPE.unknown) {
29441    super(PS_NODE.ternary);
29442    this.cond = cond;
29443    this.then = then;
29444    this.otherwise = otherwise;
29445    this.valueType = valueType;
29446  }
29447}
29448class ast_Parser {
29449  constructor(lexer) {
29450    this.lexer = lexer;
29451    this._token = null;
29452  }
29453  static _isRegularOperator(id) {
29454    return id >= TOKEN.true && id < TOKEN.if;
29455  }
29456  _advance() {
29457    this._token = this.lexer.next();
29458  }
29459  _expect(id) {
29460    if (this._token.id !== id) {
29461      throw new FormatError(`PostScript function: expected token id ${id}, got ${this._token.id}.`);
29462    }
29463    const tok = this._token;
29464    this._advance();
29465    return tok;
29466  }
29467  parse() {
29468    this._advance();
29469    this._expect(TOKEN.lbrace);
29470    const block = this._parseBlock();
29471    this._expect(TOKEN.rbrace);
29472    if (this._token.id !== TOKEN.eof) {
29473      warn("PostScript function: unexpected content after closing brace.");
29474    }
29475    return new PsProgram(block);
29476  }
29477  _parseBlock() {
29478    const instructions = [];
29479    while (true) {
29480      const tok = this._token;
29481      switch (tok.id) {
29482        case TOKEN.number:
29483          instructions.push(new PsNumber(tok.value));
29484          this._advance();
29485          break;
29486        case TOKEN.lbrace:
29487          {
29488            this._advance();
29489            const thenBlock = this._parseBlock();
29490            this._expect(TOKEN.rbrace);
29491            if (this._token.id === TOKEN.if) {
29492              this._advance();
29493              instructions.push(new PsIf(thenBlock));
29494            } else if (this._token.id === TOKEN.lbrace) {
29495              this._advance();
29496              const elseBlock = this._parseBlock();
29497              this._expect(TOKEN.rbrace);
29498              this._expect(TOKEN.ifelse);
29499              instructions.push(new PsIfElse(thenBlock, elseBlock));
29500            } else {
29501              throw new FormatError("PostScript function: a procedure block must be followed by 'if' or '{…} ifelse'.");
29502            }
29503            break;
29504          }
29505        case TOKEN.rbrace:
29506        case TOKEN.eof:
29507          return new PsBlock(instructions);
29508        case TOKEN.if:
29509        case TOKEN.ifelse:
29510          throw new FormatError(`PostScript function: unexpected '${tok.value}' operator.`);
29511        default:
29512          if (ast_Parser._isRegularOperator(tok.id)) {
29513            instructions.push(new PsOperator(tok.id));
29514            this._advance();
29515            break;
29516          }
29517          throw new FormatError(`PostScript function: unexpected token id ${tok.id}.`);
29518      }
29519    }
29520  }
29521}
29522function parsePostScriptFunction(source) {
29523  return new ast_Parser(new lexer_Lexer(source)).parse();
29524}
29525function _nodesEqual(a, b) {
29526  if (a === b) {
29527    return true;
29528  }
29529  if (a.type !== b.type) {
29530    return false;
29531  }
29532  switch (a.type) {
29533    case PS_NODE.arg:
29534      return a.index === b.index;
29535    case PS_NODE.const:
29536      return a.value === b.value;
29537    case PS_NODE.unary:
29538      return a.op === b.op && _nodesEqual(a.operand, b.operand);
29539    case PS_NODE.binary:
29540      return a.op === b.op && _nodesEqual(a.first, b.first) && _nodesEqual(a.second, b.second);
29541    case PS_NODE.ternary:
29542      return _nodesEqual(a.cond, b.cond) && _nodesEqual(a.then, b.then) && _nodesEqual(a.otherwise, b.otherwise);
29543    default:
29544      return false;
29545  }
29546}
29547function _evalBinaryConst(op, a, b) {
29548  switch (op) {
29549    case TOKEN.add:
29550      return a + b;
29551    case TOKEN.sub:
29552      return a - b;
29553    case TOKEN.mul:
29554      return a * b;
29555    case TOKEN.div:
29556      return b !== 0 ? a / b : 0;
29557    case TOKEN.idiv:
29558      return b !== 0 ? Math.trunc(a / b) : 0;
29559    case TOKEN.mod:
29560      return b !== 0 ? a - Math.trunc(a / b) * b : 0;
29561    case TOKEN.exp:
29562      {
29563        const r = a ** b;
29564        return Number.isFinite(r) ? r : undefined;
29565      }
29566    case TOKEN.atan:
29567      {
29568        let deg = Math.atan2(a, b) * (180 / Math.PI);
29569        if (deg < 0) {
29570          deg += 360;
29571        }
29572        return deg;
29573      }
29574    case TOKEN.eq:
29575      return a === b;
29576    case TOKEN.ne:
29577      return a !== b;
29578    case TOKEN.gt:
29579      return a > b;
29580    case TOKEN.ge:
29581      return a >= b;
29582    case TOKEN.lt:
29583      return a < b;
29584    case TOKEN.le:
29585      return a <= b;
29586    case TOKEN.and:
29587      return typeof a === "boolean" ? a && b : a & b | 0;
29588    case TOKEN.or:
29589      return typeof a === "boolean" ? a || b : a | b | 0;
29590    case TOKEN.xor:
29591      return typeof a === "boolean" ? a !== b : a ^ b | 0;
29592    case TOKEN.bitshift:
29593      return b >= 0 ? a << b | 0 : a >> -b | 0;
29594    case TOKEN.min:
29595      return Math.min(a, b);
29596    case TOKEN.max:
29597      return Math.max(a, b);
29598    default:
29599      return undefined;
29600  }
29601}
29602function _evalUnaryConst(op, v) {
29603  switch (op) {
29604    case TOKEN.abs:
29605      return Math.abs(v);
29606    case TOKEN.neg:
29607      return -v;
29608    case TOKEN.ceiling:
29609      return Math.ceil(v);
29610    case TOKEN.floor:
29611      return Math.floor(v);
29612    case TOKEN.round:
29613      return Math.round(v);
29614    case TOKEN.truncate:
29615      return Math.trunc(v);
29616    case TOKEN.sqrt:
29617      {
29618        const r = Math.sqrt(v);
29619        return Number.isFinite(r) ? r : undefined;
29620      }
29621    case TOKEN.sin:
29622      return Math.sin(v % 360 * Math.PI / 180);
29623    case TOKEN.cos:
29624      return Math.cos(v % 360 * Math.PI / 180);
29625    case TOKEN.ln:
29626      {
29627        const r = Math.log(v);
29628        return Number.isFinite(r) ? r : undefined;
29629      }
29630    case TOKEN.log:
29631      {
29632        const r = Math.log10(v);
29633        return Number.isFinite(r) ? r : undefined;
29634      }
29635    case TOKEN.cvi:
29636      return Math.trunc(v);
29637    case TOKEN.cvr:
29638      return v;
29639    case TOKEN.not:
29640      return typeof v === "boolean" ? !v : ~v;
29641    default:
29642      return undefined;
29643  }
29644}
29645const MAX_STACK_SIZE = 100;
29646function _unaryValueType(op, operandType) {
29647  return op === TOKEN.not ? operandType : PS_VALUE_TYPE.numeric;
29648}
29649function _binaryValueType(op, firstType, secondType) {
29650  switch (op) {
29651    case TOKEN.eq:
29652    case TOKEN.ne:
29653    case TOKEN.gt:
29654    case TOKEN.ge:
29655    case TOKEN.lt:
29656    case TOKEN.le:
29657      return PS_VALUE_TYPE.boolean;
29658    case TOKEN.and:
29659    case TOKEN.or:
29660    case TOKEN.xor:
29661      return firstType === secondType && firstType !== PS_VALUE_TYPE.unknown ? firstType : PS_VALUE_TYPE.unknown;
29662    default:
29663      return PS_VALUE_TYPE.numeric;
29664  }
29665}
29666class PSStackToTree {
29667  static #binaryOps = null;
29668  static #unaryOps = null;
29669  static #idempotentUnary = null;
29670  static #negatedComparison = null;
29671  static #init() {
29672    this.#binaryOps = new Set([TOKEN.add, TOKEN.sub, TOKEN.mul, TOKEN.div, TOKEN.idiv, TOKEN.mod, TOKEN.exp, TOKEN.atan, TOKEN.eq, TOKEN.ne, TOKEN.gt, TOKEN.ge, TOKEN.lt, TOKEN.le, TOKEN.and, TOKEN.or, TOKEN.xor, TOKEN.bitshift]);
29673    this.#unaryOps = new Set([TOKEN.abs, TOKEN.neg, TOKEN.ceiling, TOKEN.floor, TOKEN.round, TOKEN.truncate, TOKEN.sqrt, TOKEN.sin, TOKEN.cos, TOKEN.ln, TOKEN.log, TOKEN.cvi, TOKEN.cvr, TOKEN.not]);
29674    this.#idempotentUnary = new Set([TOKEN.abs, TOKEN.ceiling, TOKEN.cvi, TOKEN.cvr, TOKEN.floor, TOKEN.round, TOKEN.truncate]);
29675    this.#negatedComparison = new Map([[TOKEN.eq, TOKEN.ne], [TOKEN.ne, TOKEN.eq], [TOKEN.lt, TOKEN.ge], [TOKEN.le, TOKEN.gt], [TOKEN.gt, TOKEN.le], [TOKEN.ge, TOKEN.lt]]);
29676  }
29677  evaluate(program, numInputs) {
29678    if (!PSStackToTree.#binaryOps) {
29679      PSStackToTree.#init();
29680    }
29681    this._failed = false;
29682    if (numInputs > MAX_STACK_SIZE) {
29683      return null;
29684    }
29685    const stack = [];
29686    for (let i = 0; i < numInputs; i++) {
29687      stack.push(new PsArgNode(i));
29688    }
29689    this._evalBlock(program.body, stack);
29690    if (this._failed) {
29691      return null;
29692    }
29693    PSStackToTree.#markShared(stack);
29694    return stack;
29695  }
29696  static #markShared(outputs) {
29697    const refCount = new Map();
29698    const visit = node => {
29699      if (!node || node.type === PS_NODE.arg || node.type === PS_NODE.const) {
29700        return;
29701      }
29702      const prev = refCount.get(node) ?? 0;
29703      refCount.set(node, prev + 1);
29704      if (prev > 0) {
29705        return;
29706      }
29707      switch (node.type) {
29708        case PS_NODE.unary:
29709          visit(node.operand);
29710          break;
29711        case PS_NODE.binary:
29712          visit(node.first);
29713          visit(node.second);
29714          break;
29715        case PS_NODE.ternary:
29716          visit(node.cond);
29717          visit(node.then);
29718          visit(node.otherwise);
29719          break;
29720      }
29721    };
29722    for (const output of outputs) {
29723      visit(output);
29724    }
29725    for (const [node, count] of refCount) {
29726      if (count > 1) {
29727        node.shared = true;
29728        node.sharedCount = count;
29729      }
29730    }
29731  }
29732  _evalBlock(block, stack) {
29733    this._evalBlockFrom(block.instructions, 0, stack);
29734  }
29735  _evalBlockFrom(instructions, startIdx, stack) {
29736    for (let idx = startIdx; idx < instructions.length; idx++) {
29737      if (this._failed) {
29738        break;
29739      }
29740      const instr = instructions[idx];
29741      switch (instr.type) {
29742        case PS_NODE.number:
29743          stack.push(new PsConstNode(instr.value));
29744          if (stack.length > MAX_STACK_SIZE) {
29745            this._failed = true;
29746          }
29747          break;
29748        case PS_NODE.operator:
29749          this._evalOp(instr.op, stack);
29750          break;
29751        case PS_NODE.if:
29752          {
29753            if (stack.length < 1) {
29754              this._failed = true;
29755              break;
29756            }
29757            const cond = stack.pop();
29758            const saved = stack.slice();
29759            this._evalBlock(instr.then, stack);
29760            if (this._failed) {
29761              break;
29762            }
29763            if (stack.length === saved.length) {
29764              for (let i = 0; i < stack.length; i++) {
29765                if (stack[i] !== saved[i]) {
29766                  stack[i] = this._makeTernary(cond, stack[i], saved[i]);
29767                }
29768              }
29769            } else if (stack.length > saved.length) {
29770              if (cond.type === PS_NODE.const) {
29771                if (!cond.value) {
29772                  stack.length = 0;
29773                  stack.push(...saved);
29774                }
29775                break;
29776              }
29777              const trueStack = stack.slice();
29778              this._evalBlockFrom(instructions, idx + 1, trueStack);
29779              if (this._failed) {
29780                break;
29781              }
29782              const falseStack = saved;
29783              this._evalBlockFrom(instructions, idx + 1, falseStack);
29784              if (this._failed) {
29785                break;
29786              }
29787              if (trueStack.length !== falseStack.length) {
29788                const zero = new PsConstNode(0);
29789                while (trueStack.length < falseStack.length) {
29790                  trueStack.push(zero);
29791                }
29792                while (falseStack.length < trueStack.length) {
29793                  falseStack.push(zero);
29794                }
29795              }
29796              stack.length = 0;
29797              for (let i = 0; i < trueStack.length; i++) {
29798                stack.push(this._makeTernary(cond, trueStack[i], falseStack[i]));
29799              }
29800              return;
29801            } else {
29802              this._failed = true;
29803            }
29804            break;
29805          }
29806        case PS_NODE.ifelse:
29807          {
29808            if (stack.length < 1) {
29809              this._failed = true;
29810              break;
29811            }
29812            const cond = stack.pop();
29813            const snapshot = stack.slice();
29814            const thenStack = snapshot.slice();
29815            this._evalBlock(instr.then, thenStack);
29816            if (this._failed) {
29817              break;
29818            }
29819            const elseStack = snapshot.slice();
29820            this._evalBlock(instr.otherwise, elseStack);
29821            if (this._failed) {
29822              break;
29823            }
29824            if (thenStack.length !== elseStack.length) {
29825              const zero = new PsConstNode(0);
29826              while (thenStack.length < elseStack.length) {
29827                thenStack.push(zero);
29828              }
29829              while (elseStack.length < thenStack.length) {
29830                elseStack.push(zero);
29831              }
29832            }
29833            stack.length = 0;
29834            for (let i = 0; i < thenStack.length; i++) {
29835              stack.push(this._makeTernary(cond, thenStack[i], elseStack[i]));
29836            }
29837            break;
29838          }
29839      }
29840    }
29841  }
29842  _evalOp(op, stack) {
29843    if (PSStackToTree.#binaryOps.has(op)) {
29844      if (stack.length < 2) {
29845        this._failed = true;
29846        return;
29847      }
29848      const first = stack.pop();
29849      const second = stack.pop();
29850      stack.push(this._makeBinary(op, first, second));
29851      return;
29852    }
29853    if (PSStackToTree.#unaryOps.has(op)) {
29854      if (stack.length < 1) {
29855        this._failed = true;
29856        return;
29857      }
29858      stack.push(this._makeUnary(op, stack.pop()));
29859      return;
29860    }
29861    switch (op) {
29862      case TOKEN.true:
29863        stack.push(new PsConstNode(true));
29864        if (stack.length > MAX_STACK_SIZE) {
29865          this._failed = true;
29866        }
29867        break;
29868      case TOKEN.false:
29869        stack.push(new PsConstNode(false));
29870        if (stack.length > MAX_STACK_SIZE) {
29871          this._failed = true;
29872        }
29873        break;
29874      case TOKEN.dup:
29875        if (stack.length < 1) {
29876          this._failed = true;
29877          break;
29878        }
29879        stack.push(stack.at(-1));
29880        if (stack.length > MAX_STACK_SIZE) {
29881          this._failed = true;
29882        }
29883        break;
29884      case TOKEN.exch:
29885        {
29886          if (stack.length < 2) {
29887            this._failed = true;
29888            break;
29889          }
29890          const a = stack.pop();
29891          const b = stack.pop();
29892          stack.push(a, b);
29893          break;
29894        }
29895      case TOKEN.pop:
29896        if (stack.length < 1) {
29897          this._failed = true;
29898          break;
29899        }
29900        stack.pop();
29901        break;
29902      case TOKEN.copy:
29903        {
29904          if (stack.length < 1) {
29905            this._failed = true;
29906            break;
29907          }
29908          const nNode = stack.pop();
29909          if (nNode.type === PS_NODE.const) {
29910            const n = nNode.value | 0;
29911            if (n === 0) {} else if (n < 0 || n > stack.length) {
29912              this._failed = true;
29913            } else {
29914              stack.push(...stack.slice(-n));
29915              if (stack.length > MAX_STACK_SIZE) {
29916                this._failed = true;
29917              }
29918            }
29919          } else {
29920            this._failed = true;
29921          }
29922          break;
29923        }
29924      case TOKEN.index:
29925        {
29926          if (stack.length < 1) {
29927            this._failed = true;
29928            break;
29929          }
29930          const nNode = stack.pop();
29931          if (nNode.type === PS_NODE.const) {
29932            const n = nNode.value | 0;
29933            if (n < 0 || n >= stack.length) {
29934              this._failed = true;
29935            } else {
29936              stack.push(stack.at(-n - 1));
29937            }
29938          } else {
29939            this._failed = true;
29940          }
29941          break;
29942        }
29943      case TOKEN.roll:
29944        {
29945          if (stack.length < 2) {
29946            this._failed = true;
29947            break;
29948          }
29949          const jNode = stack.pop();
29950          const nNode = stack.pop();
29951          if (nNode.type === PS_NODE.const && jNode.type === PS_NODE.const) {
29952            const n = nNode.value | 0;
29953            if (n === 0) {} else if (n < 0 || n > stack.length) {
29954              this._failed = true;
29955            } else {
29956              const j = ((jNode.value | 0) % n + n) % n;
29957              if (j > 0) {
29958                const slice = stack.splice(-n, n);
29959                stack.push(...slice.slice(n - j), ...slice.slice(0, n - j));
29960              }
29961            }
29962          } else {
29963            this._failed = true;
29964          }
29965          break;
29966        }
29967      default:
29968        this._failed = true;
29969        break;
29970    }
29971  }
29972  _makeBinary(op, first, second) {
29973    if (first.type === PS_NODE.const && second.type === PS_NODE.const) {
29974      const v = _evalBinaryConst(op, second.value, first.value);
29975      if (v !== undefined) {
29976        return new PsConstNode(v);
29977      }
29978    }
29979    if (_nodesEqual(first, second)) {
29980      switch (op) {
29981        case TOKEN.sub:
29982          return new PsConstNode(0);
29983        case TOKEN.xor:
29984          return new PsConstNode(first.valueType === PS_VALUE_TYPE.boolean ? false : 0);
29985        case TOKEN.and:
29986        case TOKEN.or:
29987          return first;
29988        case TOKEN.min:
29989        case TOKEN.max:
29990          return first;
29991        case TOKEN.eq:
29992        case TOKEN.ge:
29993        case TOKEN.le:
29994          return new PsConstNode(true);
29995        case TOKEN.ne:
29996        case TOKEN.gt:
29997        case TOKEN.lt:
29998          return new PsConstNode(false);
29999      }
30000    }
30001    if (first.type === PS_NODE.const) {
30002      const b = first.value;
30003      switch (op) {
30004        case TOKEN.add:
30005          if (b === 0) {
30006            return second;
30007          }
30008          break;
30009        case TOKEN.sub:
30010          if (b === 0) {
30011            return second;
30012          }
30013          break;
30014        case TOKEN.mul:
30015          if (b === 1) {
30016            return second;
30017          }
30018          if (b === 0) {
30019            return first;
30020          }
30021          if (b === -1) {
30022            return this._makeUnary(TOKEN.neg, second);
30023          }
30024          break;
30025        case TOKEN.div:
30026          if (b !== 0) {
30027            return this._makeBinary(TOKEN.mul, new PsConstNode(1 / b), second);
30028          }
30029          break;
30030        case TOKEN.idiv:
30031          if (b === 1) {
30032            return second;
30033          }
30034          break;
30035        case TOKEN.exp:
30036          if (b === 1) {
30037            return second;
30038          }
30039          if (b === -1) {
30040            return this._makeBinary(TOKEN.div, second, new PsConstNode(1));
30041          }
30042          if (b === 0.5) {
30043            return this._makeUnary(TOKEN.sqrt, second);
30044          }
30045          if (b === 0.25) {
30046            const sqrtOnce = this._makeUnary(TOKEN.sqrt, second);
30047            return this._makeUnary(TOKEN.sqrt, sqrtOnce);
30048          }
30049          if (b === 2) {
30050            return this._makeBinary(TOKEN.mul, second, second);
30051          }
30052          if (b === 3) {
30053            return this._makeBinary(TOKEN.mul, this._makeBinary(TOKEN.mul, second, second), second);
30054          }
30055          if (b === 4) {
30056            const square = this._makeBinary(TOKEN.mul, second, second);
30057            return this._makeBinary(TOKEN.mul, square, square);
30058          }
30059          if (b === 0) {
30060            return new PsConstNode(1);
30061          }
30062          break;
30063        case TOKEN.and:
30064          if (b === true) {
30065            return second;
30066          }
30067          if (b === false) {
30068            return first;
30069          }
30070          break;
30071        case TOKEN.or:
30072          if (b === false) {
30073            return second;
30074          }
30075          if (b === true) {
30076            return first;
30077          }
30078          break;
30079        case TOKEN.min:
30080          if (second.type === PS_NODE.binary && second.op === TOKEN.max && second.first.type === PS_NODE.const && second.first.value >= b) {
30081            return first;
30082          }
30083          break;
30084        case TOKEN.max:
30085          if (second.type === PS_NODE.binary && second.op === TOKEN.min && second.first.type === PS_NODE.const && second.first.value <= b) {
30086            return first;
30087          }
30088          break;
30089      }
30090    }
30091    if (second.type === PS_NODE.const) {
30092      const a = second.value;
30093      switch (op) {
30094        case TOKEN.add:
30095          if (a === 0) {
30096            return first;
30097          }
30098          break;
30099        case TOKEN.sub:
30100          if (a === 0) {
30101            return this._makeUnary(TOKEN.neg, first);
30102          }
30103          break;
30104        case TOKEN.mul:
30105          if (a === 1) {
30106            return first;
30107          }
30108          if (a === 0) {
30109            return second;
30110          }
30111          if (a === -1) {
30112            return this._makeUnary(TOKEN.neg, first);
30113          }
30114          break;
30115        case TOKEN.and:
30116          if (a === true) {
30117            return first;
30118          }
30119          if (a === false) {
30120            return second;
30121          }
30122          break;
30123        case TOKEN.or:
30124          if (a === false) {
30125            return first;
30126          }
30127          if (a === true) {
30128            return second;
30129          }
30130          break;
30131      }
30132    }
30133    return new PsBinaryNode(op, first, second, _binaryValueType(op, first.valueType, second.valueType));
30134  }
30135  _makeUnary(op, operand) {
30136    if (operand.type === PS_NODE.const) {
30137      const v = _evalUnaryConst(op, operand.value);
30138      if (v !== undefined) {
30139        return new PsConstNode(v);
30140      }
30141    }
30142    if (op === TOKEN.not && operand.type === PS_NODE.binary) {
30143      const negated = PSStackToTree.#negatedComparison.get(operand.op);
30144      if (negated !== undefined) {
30145        return new PsBinaryNode(negated, operand.first, operand.second, PS_VALUE_TYPE.boolean);
30146      }
30147    }
30148    if (op === TOKEN.neg && operand.type === PS_NODE.binary && operand.op === TOKEN.sub) {
30149      return this._makeBinary(TOKEN.sub, operand.second, operand.first);
30150    }
30151    if (operand.type === PS_NODE.unary) {
30152      if (op === TOKEN.neg && operand.op === TOKEN.neg || op === TOKEN.not && operand.op === TOKEN.not) {
30153        return operand.operand;
30154      }
30155      if (op === TOKEN.abs && operand.op === TOKEN.neg) {
30156        return this._makeUnary(TOKEN.abs, operand.operand);
30157      }
30158      if (PSStackToTree.#idempotentUnary.has(op) && op === operand.op) {
30159        return operand;
30160      }
30161    }
30162    return new PsUnaryNode(op, operand, _unaryValueType(op, operand.valueType));
30163  }
30164  _makeTernary(cond, then, otherwise) {
30165    if (cond.type === PS_NODE.const) {
30166      return cond.value ? then : otherwise;
30167    }
30168    if (_nodesEqual(then, otherwise)) {
30169      return then;
30170    }
30171    if (then.type === PS_NODE.const && otherwise.type === PS_NODE.const) {
30172      if (then.value === true && otherwise.value === false) {
30173        return cond;
30174      }
30175      if (then.value === false && otherwise.value === true) {
30176        return this._makeUnary(TOKEN.not, cond);
30177      }
30178    }
30179    if (cond.type === PS_NODE.binary) {
30180      const {
30181        op: cop,
30182        first: cf,
30183        second: cs
30184      } = cond;
30185      if (cop === TOKEN.gt || cop === TOKEN.ge) {
30186        if (_nodesEqual(then, cf) && _nodesEqual(otherwise, cs)) {
30187          return this._makeBinary(TOKEN.min, cf, cs);
30188        }
30189        if (_nodesEqual(then, cs) && _nodesEqual(otherwise, cf)) {
30190          return this._makeBinary(TOKEN.max, cf, cs);
30191        }
30192      } else if (cop === TOKEN.lt || cop === TOKEN.le) {
30193        if (_nodesEqual(then, cf) && _nodesEqual(otherwise, cs)) {
30194          return this._makeBinary(TOKEN.max, cf, cs);
30195        }
30196        if (_nodesEqual(then, cs) && _nodesEqual(otherwise, cf)) {
30197          return this._makeBinary(TOKEN.min, cf, cs);
30198        }
30199      }
30200    }
30201    return new PsTernaryNode(cond, then, otherwise, then.valueType === otherwise.valueType ? then.valueType : PS_VALUE_TYPE.unknown);
30202  }
30203}
30204
30205;// ./src/core/postscript/js_evaluator.js
30206
30207
30208
30209const OP = {
30210  ARG: 0,
30211  CONST: 1,
30212  STORE: 2,
30213  IF: 3,
30214  JUMP: 4,
30215  ABS: 5,
30216  NEG: 6,
30217  CEIL: 7,
30218  FLOOR: 8,
30219  ROUND: 9,
30220  TRUNC: 10,
30221  NOT_B: 11,
30222  NOT_N: 12,
30223  SQRT: 13,
30224  SIN: 14,
30225  COS: 15,
30226  LN: 16,
30227  LOG10: 17,
30228  CVI: 18,
30229  SHIFT: 19,
30230  ADD: 20,
30231  SUB: 21,
30232  MUL: 22,
30233  DIV: 23,
30234  IDIV: 24,
30235  MOD: 25,
30236  POW: 26,
30237  EQ: 27,
30238  NE: 28,
30239  GT: 29,
30240  GE: 30,
30241  LT: 31,
30242  LE: 32,
30243  AND: 33,
30244  OR: 34,
30245  XOR: 35,
30246  ATAN: 36,
30247  MIN: 37,
30248  MAX: 38,
30249  TEE_TMP: 39,
30250  LOAD_TMP: 40
30251};
30252const _DEG_TO_RAD = Math.PI / 180;
30253const _RAD_TO_DEG = 180 / Math.PI;
30254class PsJsCompiler {
30255  static #stack = new Float64Array(64);
30256  static #tmp = new Float64Array(64);
30257  constructor(domain, range) {
30258    this.nIn = domain.length >> 1;
30259    this.nOut = range.length >> 1;
30260    this.range = range;
30261    this.ir = [];
30262    this._tmpMap = new Map();
30263    this._nextTmp = 0;
30264  }
30265  _compileNode(node) {
30266    if (node.shared) {
30267      const cached = this._tmpMap.get(node);
30268      if (cached !== undefined) {
30269        this.ir.push(OP.LOAD_TMP, cached);
30270        return true;
30271      }
30272      if (!this._compileNodeImpl(node)) {
30273        return false;
30274      }
30275      const slot = this._nextTmp++;
30276      this._tmpMap.set(node, slot);
30277      this.ir.push(OP.TEE_TMP, slot);
30278      return true;
30279    }
30280    return this._compileNodeImpl(node);
30281  }
30282  _compileNodeImpl(node) {
30283    switch (node.type) {
30284      case PS_NODE.arg:
30285        this.ir.push(OP.ARG, node.index);
30286        return true;
30287      case PS_NODE.const:
30288        {
30289          const v = node.value;
30290          this.ir.push(OP.CONST, typeof v === "boolean" ? Number(v) : v);
30291          return true;
30292        }
30293      case PS_NODE.unary:
30294        return this._compileUnary(node);
30295      case PS_NODE.binary:
30296        return this._compileBinary(node);
30297      case PS_NODE.ternary:
30298        return this._compileTernary(node);
30299      default:
30300        return false;
30301    }
30302  }
30303  _compileUnary(node) {
30304    const {
30305      op,
30306      operand,
30307      valueType
30308    } = node;
30309    if (op === TOKEN.cvr) {
30310      return this._compileNode(operand);
30311    }
30312    if (!this._compileNode(operand)) {
30313      return false;
30314    }
30315    switch (op) {
30316      case TOKEN.abs:
30317        this.ir.push(OP.ABS);
30318        break;
30319      case TOKEN.neg:
30320        this.ir.push(OP.NEG);
30321        break;
30322      case TOKEN.ceiling:
30323        this.ir.push(OP.CEIL);
30324        break;
30325      case TOKEN.floor:
30326        this.ir.push(OP.FLOOR);
30327        break;
30328      case TOKEN.round:
30329        this.ir.push(OP.ROUND);
30330        break;
30331      case TOKEN.truncate:
30332        this.ir.push(OP.TRUNC);
30333        break;
30334      case TOKEN.sqrt:
30335        this.ir.push(OP.SQRT);
30336        break;
30337      case TOKEN.sin:
30338        this.ir.push(OP.SIN);
30339        break;
30340      case TOKEN.cos:
30341        this.ir.push(OP.COS);
30342        break;
30343      case TOKEN.ln:
30344        this.ir.push(OP.LN);
30345        break;
30346      case TOKEN.log:
30347        this.ir.push(OP.LOG10);
30348        break;
30349      case TOKEN.cvi:
30350        this.ir.push(OP.CVI);
30351        break;
30352      case TOKEN.not:
30353        if (valueType === PS_VALUE_TYPE.boolean) {
30354          this.ir.push(OP.NOT_B);
30355        } else if (valueType === PS_VALUE_TYPE.numeric) {
30356          this.ir.push(OP.NOT_N);
30357        } else {
30358          return false;
30359        }
30360        break;
30361      default:
30362        return false;
30363    }
30364    return true;
30365  }
30366  _compileBinary(node) {
30367    const {
30368      op,
30369      first,
30370      second
30371    } = node;
30372    if (op === TOKEN.bitshift) {
30373      if (first.type !== PS_NODE.const || !Number.isInteger(first.value)) {
30374        return false;
30375      }
30376      if (!this._compileNode(second)) {
30377        return false;
30378      }
30379      this.ir.push(OP.SHIFT, first.value);
30380      return true;
30381    }
30382    if (!this._compileNode(second)) {
30383      return false;
30384    }
30385    if (!this._compileNode(first)) {
30386      return false;
30387    }
30388    switch (op) {
30389      case TOKEN.add:
30390        this.ir.push(OP.ADD);
30391        break;
30392      case TOKEN.sub:
30393        this.ir.push(OP.SUB);
30394        break;
30395      case TOKEN.mul:
30396        this.ir.push(OP.MUL);
30397        break;
30398      case TOKEN.div:
30399        this.ir.push(OP.DIV);
30400        break;
30401      case TOKEN.idiv:
30402        this.ir.push(OP.IDIV);
30403        break;
30404      case TOKEN.mod:
30405        this.ir.push(OP.MOD);
30406        break;
30407      case TOKEN.exp:
30408        this.ir.push(OP.POW);
30409        break;
30410      case TOKEN.eq:
30411        this.ir.push(OP.EQ);
30412        break;
30413      case TOKEN.ne:
30414        this.ir.push(OP.NE);
30415        break;
30416      case TOKEN.gt:
30417        this.ir.push(OP.GT);
30418        break;
30419      case TOKEN.ge:
30420        this.ir.push(OP.GE);
30421        break;
30422      case TOKEN.lt:
30423        this.ir.push(OP.LT);
30424        break;
30425      case TOKEN.le:
30426        this.ir.push(OP.LE);
30427        break;
30428      case TOKEN.and:
30429        this.ir.push(OP.AND);
30430        break;
30431      case TOKEN.or:
30432        this.ir.push(OP.OR);
30433        break;
30434      case TOKEN.xor:
30435        this.ir.push(OP.XOR);
30436        break;
30437      case TOKEN.atan:
30438        this.ir.push(OP.ATAN);
30439        break;
30440      case TOKEN.min:
30441        this.ir.push(OP.MIN);
30442        break;
30443      case TOKEN.max:
30444        this.ir.push(OP.MAX);
30445        break;
30446      default:
30447        return false;
30448    }
30449    return true;
30450  }
30451  _compileTernary(node) {
30452    if (!this._compileNode(node.cond)) {
30453      return false;
30454    }
30455    this.ir.push(OP.IF, 0);
30456    const ifPatch = this.ir.length - 1;
30457    if (!this._compileNode(node.then)) {
30458      return false;
30459    }
30460    this.ir.push(OP.JUMP, 0);
30461    const jumpPatch = this.ir.length - 1;
30462    this.ir[ifPatch] = this.ir.length;
30463    if (!this._compileNode(node.otherwise)) {
30464      return false;
30465    }
30466    this.ir[jumpPatch] = this.ir.length;
30467    return true;
30468  }
30469  compile(program) {
30470    const outputs = new PSStackToTree().evaluate(program, this.nIn);
30471    if (!outputs || outputs.length < this.nOut) {
30472      return null;
30473    }
30474    for (let i = 0; i < this.nOut; i++) {
30475      if (!this._compileNode(outputs[i])) {
30476        return null;
30477      }
30478      const min = this.range[i * 2];
30479      const max = this.range[i * 2 + 1];
30480      this.ir.push(OP.STORE, i, min, max);
30481    }
30482    return new Float64Array(this.ir);
30483  }
30484  static execute(ir, src, srcOffset, dest, destOffset) {
30485    let ip = 0,
30486      sp = 0;
30487    const n = ir.length;
30488    const stack = this.#stack;
30489    const tmp = this.#tmp;
30490    while (ip < n) {
30491      switch (ir[ip++] | 0) {
30492        case OP.ARG:
30493          stack[sp++] = src[srcOffset + (ir[ip++] | 0)];
30494          break;
30495        case OP.CONST:
30496          stack[sp++] = ir[ip++];
30497          break;
30498        case OP.STORE:
30499          {
30500            const slot = ir[ip++] | 0;
30501            const min = ir[ip++];
30502            const max = ir[ip++];
30503            dest[destOffset + slot] = MathClamp(stack[--sp], min, max);
30504            break;
30505          }
30506        case OP.IF:
30507          {
30508            const tgt = ir[ip++];
30509            if (stack[--sp] === 0) {
30510              ip = tgt;
30511            }
30512            break;
30513          }
30514        case OP.JUMP:
30515          ip = ir[ip];
30516          break;
30517        case OP.ABS:
30518          stack[sp - 1] = Math.abs(stack[sp - 1]);
30519          break;
30520        case OP.NEG:
30521          stack[sp - 1] = -stack[sp - 1];
30522          break;
30523        case OP.CEIL:
30524          stack[sp - 1] = Math.ceil(stack[sp - 1]);
30525          break;
30526        case OP.FLOOR:
30527          stack[sp - 1] = Math.floor(stack[sp - 1]);
30528          break;
30529        case OP.ROUND:
30530          stack[sp - 1] = Math.floor(stack[sp - 1] + 0.5);
30531          break;
30532        case OP.TRUNC:
30533          stack[sp - 1] = Math.trunc(stack[sp - 1]);
30534          break;
30535        case OP.NOT_B:
30536          stack[sp - 1] = stack[sp - 1] !== 0 ? 0 : 1;
30537          break;
30538        case OP.NOT_N:
30539          stack[sp - 1] = ~(stack[sp - 1] | 0);
30540          break;
30541        case OP.SQRT:
30542          stack[sp - 1] = Math.sqrt(stack[sp - 1]);
30543          break;
30544        case OP.SIN:
30545          stack[sp - 1] = Math.sin(stack[sp - 1] % 360 * _DEG_TO_RAD);
30546          break;
30547        case OP.COS:
30548          stack[sp - 1] = Math.cos(stack[sp - 1] % 360 * _DEG_TO_RAD);
30549          break;
30550        case OP.LN:
30551          stack[sp - 1] = Math.log(stack[sp - 1]);
30552          break;
30553        case OP.LOG10:
30554          stack[sp - 1] = Math.log10(stack[sp - 1]);
30555          break;
30556        case OP.CVI:
30557          stack[sp - 1] = Math.trunc(stack[sp - 1]) | 0;
30558          break;
30559        case OP.SHIFT:
30560          {
30561            const amt = ir[ip++];
30562            const v = stack[sp - 1] | 0;
30563            if (amt > 0) {
30564              stack[sp - 1] = v << amt;
30565            } else if (amt < 0) {
30566              stack[sp - 1] = v >> -amt;
30567            } else {
30568              stack[sp - 1] = v;
30569            }
30570            break;
30571          }
30572        case OP.ADD:
30573          {
30574            const b = stack[--sp];
30575            stack[sp - 1] += b;
30576            break;
30577          }
30578        case OP.SUB:
30579          {
30580            const b = stack[--sp];
30581            stack[sp - 1] -= b;
30582            break;
30583          }
30584        case OP.MUL:
30585          {
30586            const b = stack[--sp];
30587            stack[sp - 1] *= b;
30588            break;
30589          }
30590        case OP.DIV:
30591          {
30592            const b = stack[--sp];
30593            stack[sp - 1] = b !== 0 ? stack[sp - 1] / b : 0;
30594            break;
30595          }
30596        case OP.IDIV:
30597          {
30598            const b = stack[--sp];
30599            stack[sp - 1] = b !== 0 ? Math.trunc(stack[sp - 1] / b) : 0;
30600            break;
30601          }
30602        case OP.MOD:
30603          {
30604            const b = stack[--sp];
30605            stack[sp - 1] = b !== 0 ? stack[sp - 1] % b : 0;
30606            break;
30607          }
30608        case OP.POW:
30609          {
30610            const b = stack[--sp];
30611            stack[sp - 1] **= b;
30612            break;
30613          }
30614        case OP.EQ:
30615          {
30616            const b = stack[--sp];
30617            stack[sp - 1] = stack[sp - 1] === b ? 1 : 0;
30618            break;
30619          }
30620        case OP.NE:
30621          {
30622            const b = stack[--sp];
30623            stack[sp - 1] = stack[sp - 1] !== b ? 1 : 0;
30624            break;
30625          }
30626        case OP.GT:
30627          {
30628            const b = stack[--sp];
30629            stack[sp - 1] = stack[sp - 1] > b ? 1 : 0;
30630            break;
30631          }
30632        case OP.GE:
30633          {
30634            const b = stack[--sp];
30635            stack[sp - 1] = stack[sp - 1] >= b ? 1 : 0;
30636            break;
30637          }
30638        case OP.LT:
30639          {
30640            const b = stack[--sp];
30641            stack[sp - 1] = stack[sp - 1] < b ? 1 : 0;
30642            break;
30643          }
30644        case OP.LE:
30645          {
30646            const b = stack[--sp];
30647            stack[sp - 1] = stack[sp - 1] <= b ? 1 : 0;
30648            break;
30649          }
30650        case OP.AND:
30651          {
30652            const b = stack[--sp] | 0;
30653            stack[sp - 1] = (stack[sp - 1] | 0) & b;
30654            break;
30655          }
30656        case OP.OR:
30657          {
30658            const b = stack[--sp] | 0;
30659            stack[sp - 1] = stack[sp - 1] | 0 | b;
30660            break;
30661          }
30662        case OP.XOR:
30663          {
30664            const b = stack[--sp] | 0;
30665            stack[sp - 1] = (stack[sp - 1] | 0) ^ b;
30666            break;
30667          }
30668        case OP.ATAN:
30669          {
30670            const b = stack[--sp];
30671            const deg = Math.atan2(stack[sp - 1], b) * _RAD_TO_DEG;
30672            stack[sp - 1] = deg < 0 ? deg + 360 : deg;
30673            break;
30674          }
30675        case OP.MIN:
30676          {
30677            const b = stack[--sp];
30678            stack[sp - 1] = Math.min(stack[sp - 1], b);
30679            break;
30680          }
30681        case OP.MAX:
30682          {
30683            const b = stack[--sp];
30684            stack[sp - 1] = Math.max(stack[sp - 1], b);
30685            break;
30686          }
30687        case OP.TEE_TMP:
30688          tmp[ir[ip++] | 0] = stack[sp - 1];
30689          break;
30690        case OP.LOAD_TMP:
30691          stack[sp++] = tmp[ir[ip++] | 0];
30692          break;
30693      }
30694    }
30695  }
30696}
30697class PSStackBasedInterpreter {
30698  static #stack = new Float64Array(100);
30699  static #sp = 0;
30700  static #push(v) {
30701    if (this.#sp < this.#stack.length) {
30702      this.#stack[this.#sp++] = v;
30703    }
30704  }
30705  static #execOp(op) {
30706    const stack = this.#stack;
30707    switch (op) {
30708      case TOKEN.true:
30709        this.#push(1);
30710        break;
30711      case TOKEN.false:
30712        this.#push(0);
30713        break;
30714      case TOKEN.abs:
30715        stack[this.#sp - 1] = Math.abs(stack[this.#sp - 1]);
30716        break;
30717      case TOKEN.neg:
30718        stack[this.#sp - 1] = -stack[this.#sp - 1];
30719        break;
30720      case TOKEN.ceiling:
30721        stack[this.#sp - 1] = Math.ceil(stack[this.#sp - 1]);
30722        break;
30723      case TOKEN.floor:
30724        stack[this.#sp - 1] = Math.floor(stack[this.#sp - 1]);
30725        break;
30726      case TOKEN.round:
30727        stack[this.#sp - 1] = Math.floor(stack[this.#sp - 1] + 0.5);
30728        break;
30729      case TOKEN.truncate:
30730        stack[this.#sp - 1] = Math.trunc(stack[this.#sp - 1]);
30731        break;
30732      case TOKEN.sqrt:
30733        stack[this.#sp - 1] = Math.sqrt(stack[this.#sp - 1]);
30734        break;
30735      case TOKEN.sin:
30736        stack[this.#sp - 1] = Math.sin(stack[this.#sp - 1] % 360 * _DEG_TO_RAD);
30737        break;
30738      case TOKEN.cos:
30739        stack[this.#sp - 1] = Math.cos(stack[this.#sp - 1] % 360 * _DEG_TO_RAD);
30740        break;
30741      case TOKEN.ln:
30742        stack[this.#sp - 1] = Math.log(stack[this.#sp - 1]);
30743        break;
30744      case TOKEN.log:
30745        stack[this.#sp - 1] = Math.log10(stack[this.#sp - 1]);
30746        break;
30747      case TOKEN.cvi:
30748        stack[this.#sp - 1] = Math.trunc(stack[this.#sp - 1]) | 0;
30749        break;
30750      case TOKEN.cvr:
30751        break;
30752      case TOKEN.not:
30753        {
30754          const v = stack[this.#sp - 1];
30755          stack[this.#sp - 1] = v === 0 || v === 1 ? 1 - v : ~(v | 0);
30756          break;
30757        }
30758      case TOKEN.add:
30759        {
30760          const b = stack[--this.#sp];
30761          stack[this.#sp - 1] += b;
30762          break;
30763        }
30764      case TOKEN.sub:
30765        {
30766          const b = stack[--this.#sp];
30767          stack[this.#sp - 1] -= b;
30768          break;
30769        }
30770      case TOKEN.mul:
30771        {
30772          const b = stack[--this.#sp];
30773          stack[this.#sp - 1] *= b;
30774          break;
30775        }
30776      case TOKEN.div:
30777        {
30778          const b = stack[--this.#sp];
30779          stack[this.#sp - 1] = b !== 0 ? stack[this.#sp - 1] / b : 0;
30780          break;
30781        }
30782      case TOKEN.idiv:
30783        {
30784          const b = stack[--this.#sp];
30785          stack[this.#sp - 1] = b !== 0 ? Math.trunc(stack[this.#sp - 1] / b) : 0;
30786          break;
30787        }
30788      case TOKEN.mod:
30789        {
30790          const b = stack[--this.#sp];
30791          stack[this.#sp - 1] = b !== 0 ? stack[this.#sp - 1] % b : 0;
30792          break;
30793        }
30794      case TOKEN.exp:
30795        {
30796          const b = stack[--this.#sp];
30797          stack[this.#sp - 1] **= b;
30798          break;
30799        }
30800      case TOKEN.atan:
30801        {
30802          const dx = stack[--this.#sp];
30803          const deg = Math.atan2(stack[this.#sp - 1], dx) * _RAD_TO_DEG;
30804          stack[this.#sp - 1] = deg < 0 ? deg + 360 : deg;
30805          break;
30806        }
30807      case TOKEN.eq:
30808        {
30809          const b = stack[--this.#sp];
30810          stack[this.#sp - 1] = stack[this.#sp - 1] === b ? 1 : 0;
30811          break;
30812        }
30813      case TOKEN.ne:
30814        {
30815          const b = stack[--this.#sp];
30816          stack[this.#sp - 1] = stack[this.#sp - 1] !== b ? 1 : 0;
30817          break;
30818        }
30819      case TOKEN.gt:
30820        {
30821          const b = stack[--this.#sp];
30822          stack[this.#sp - 1] = stack[this.#sp - 1] > b ? 1 : 0;
30823          break;
30824        }
30825      case TOKEN.ge:
30826        {
30827          const b = stack[--this.#sp];
30828          stack[this.#sp - 1] = stack[this.#sp - 1] >= b ? 1 : 0;
30829          break;
30830        }
30831      case TOKEN.lt:
30832        {
30833          const b = stack[--this.#sp];
30834          stack[this.#sp - 1] = stack[this.#sp - 1] < b ? 1 : 0;
30835          break;
30836        }
30837      case TOKEN.le:
30838        {
30839          const b = stack[--this.#sp];
30840          stack[this.#sp - 1] = stack[this.#sp - 1] <= b ? 1 : 0;
30841          break;
30842        }
30843      case TOKEN.and:
30844        {
30845          const b = stack[--this.#sp] | 0;
30846          stack[this.#sp - 1] = (stack[this.#sp - 1] | 0) & b;
30847          break;
30848        }
30849      case TOKEN.or:
30850        {
30851          const b = stack[--this.#sp] | 0;
30852          stack[this.#sp - 1] = stack[this.#sp - 1] | 0 | b;
30853          break;
30854        }
30855      case TOKEN.xor:
30856        {
30857          const b = stack[--this.#sp] | 0;
30858          stack[this.#sp - 1] = (stack[this.#sp - 1] | 0) ^ b;
30859          break;
30860        }
30861      case TOKEN.bitshift:
30862        {
30863          const amt = stack[--this.#sp] | 0;
30864          const v = stack[this.#sp - 1] | 0;
30865          stack[this.#sp - 1] = amt > 0 ? v << amt : v >> -amt;
30866          break;
30867        }
30868      case TOKEN.min:
30869        {
30870          const b = stack[--this.#sp];
30871          stack[this.#sp - 1] = Math.min(stack[this.#sp - 1], b);
30872          break;
30873        }
30874      case TOKEN.max:
30875        {
30876          const b = stack[--this.#sp];
30877          stack[this.#sp - 1] = Math.max(stack[this.#sp - 1], b);
30878          break;
30879        }
30880      case TOKEN.dup:
30881        this.#push(stack[this.#sp - 1]);
30882        break;
30883      case TOKEN.exch:
30884        {
30885          const a = stack[--this.#sp];
30886          const b = stack[--this.#sp];
30887          this.#push(a);
30888          this.#push(b);
30889          break;
30890        }
30891      case TOKEN.pop:
30892        this.#sp--;
30893        break;
30894      case TOKEN.copy:
30895        {
30896          const n = Math.trunc(stack[--this.#sp]);
30897          const base = this.#sp - n;
30898          for (let k = 0; k < n; k++) {
30899            this.#push(stack[base + k]);
30900          }
30901          break;
30902        }
30903      case TOKEN.index:
30904        {
30905          const i = Math.trunc(stack[--this.#sp]);
30906          this.#push(stack[this.#sp - 1 - i]);
30907          break;
30908        }
30909      case TOKEN.roll:
30910        {
30911          const j = Math.trunc(stack[--this.#sp]);
30912          const n = Math.trunc(stack[--this.#sp]);
30913          if (n > 1 && j !== 0) {
30914            const mod = (j % n + n) % n;
30915            if (mod !== 0) {
30916              const base = this.#sp - n;
30917              const sub = stack.slice(base, this.#sp);
30918              for (let k = 0; k < n; k++) {
30919                stack[base + k] = sub[(k - mod + n) % n];
30920              }
30921            }
30922          }
30923          break;
30924        }
30925    }
30926  }
30927  static #execBlock(instructions) {
30928    for (const instr of instructions) {
30929      switch (instr.type) {
30930        case PS_NODE.number:
30931          this.#push(instr.value);
30932          break;
30933        case PS_NODE.operator:
30934          this.#execOp(instr.op);
30935          break;
30936        case PS_NODE.if:
30937          if (this.#stack[--this.#sp] !== 0) {
30938            this.#execBlock(instr.then.instructions);
30939          }
30940          break;
30941        case PS_NODE.ifelse:
30942          if (this.#stack[--this.#sp] !== 0) {
30943            this.#execBlock(instr.then.instructions);
30944          } else {
30945            this.#execBlock(instr.otherwise.instructions);
30946          }
30947          break;
30948      }
30949    }
30950  }
30951  static build(program, domain, range) {
30952    const nIn = domain.length >> 1;
30953    const nOut = range.length >> 1;
30954    const {
30955      instructions
30956    } = program.body;
30957    return (src, srcOffset, dest, destOffset) => {
30958      this.#sp = 0;
30959      for (let i = 0; i < nIn; i++) {
30960        this.#push(src[srcOffset + i]);
30961      }
30962      this.#execBlock(instructions);
30963      const base = this.#sp - nOut;
30964      for (let i = 0; i < nOut; i++) {
30965        const v = base + i >= 0 ? this.#stack[base + i] : 0;
30966        dest[destOffset + i] = MathClamp(
30966range[i * 2 + 1], range[i * 2], v);
30967      }
30968    };
30969  }
30970}
30971function buildPostScriptJsFunction(source, domain, range, forceInterpreter = false) {
30972  const program = parsePostScriptFunction(source);
30973  const ir = !forceInterpreter && new PsJsCompiler(domain, range).compile(program);
30974  if (ir) {
30975    return (src, srcOffset, dest, destOffset) => {
30976      PsJsCompiler.execute(ir, src, srcOffset, dest, destOffset);
30977    };
30978  }
30979  return PSStackBasedInterpreter.build(program, domain, range);
30980}
30981
30982;// ./src/core/postscript/wasm_compiler.js
30983
30984
30985const wasm_compiler_OP = {
30986  if: 0x04,
30987  else: 0x05,
30988  end: 0x0b,
30989  select: 0x1b,
30990  call: 0x10,
30991  local_get: 0x20,
30992  local_set: 0x21,
30993  local_tee: 0x22,
30994  i32_const: 0x41,
30995  i32_eqz: 0x45,
30996  i32_and: 0x71,
30997  i32_or: 0x72,
30998  i32_xor: 0x73,
30999  i32_shl: 0x74,
31000  i32_shr_s: 0x75,
vendor: 4,156 bytes, lines 31001-31131
31001  i32_trunc_f64_s: 0xaa,
31002  f64_const: 0x44,
31003  f64_eq: 0x61,
31004  f64_ne: 0x62,
31005  f64_lt: 0x63,
31006  f64_gt: 0x64,
31007  f64_le: 0x65,
31008  f64_ge: 0x66,
31009  f64_abs: 0x99,
31010  f64_neg: 0x9a,
31011  f64_ceil: 0x9b,
31012  f64_floor: 0x9c,
31013  f64_trunc: 0x9d,
31014  f64_nearest: 0x9e,
31015  f64_sqrt: 0x9f,
31016  f64_add: 0xa0,
31017  f64_sub: 0xa1,
31018  f64_mul: 0xa2,
31019  f64_div: 0xa3,
31020  f64_min: 0xa4,
31021  f64_max: 0xa5,
31022  f64_convert_i32_s: 0xb7,
31023  f64_store: 0x39
31024};
31025const FUNC_TYPE = 0x60;
31026const F64 = 0x7c;
31027const SECTION = {
31028  type: 0x01,
31029  import: 0x02,
31030  function: 0x03,
31031  memory: 0x05,
31032  export: 0x07,
31033  code: 0x0a
31034};
31035const EXTERN_FUNC = 0x00;
31036const EXTERN_MEM = 0x02;
31037function unsignedLEB128(n) {
31038  const out = [];
31039  do {
31040    let byte = n & 0x7f;
31041    n >>>= 7;
31042    if (n !== 0) {
31043      byte |= 0x80;
31044    }
31045    out.push(byte);
31046  } while (n !== 0);
31047  return out;
31048}
31049function encodeASCIIString(s) {
31050  return [...unsignedLEB128(s.length), ...Array.from(s, c => c.charCodeAt(0))];
31051}
31052function section(id, data) {
31053  return [id, ...unsignedLEB128(data.length), ...data];
31054}
31055function vec(items) {
31056  const out = unsignedLEB128(items.length);
31057  for (const item of items) {
31058    if (typeof item === "number") {
31059      out.push(item);
31060      continue;
31061    }
31062    for (const byte of item) {
31063      out.push(byte);
31064    }
31065  }
31066  return out;
31067}
31068const MATH_IMPORTS = [["sin", "Math", "sin", [F64], [F64]], ["cos", "Math", "cos", [F64], [F64]], ["atan2", "Math", "atan2", [F64, F64], [F64]], ["log", "Math", "log", [F64], [F64]], ["log10", "Math", "log10", [F64], [F64]], ["pow", "Math", "pow", [F64, F64], [F64]]];
31069const _mathImportObject = {
31070  Math: Object.fromEntries(MATH_IMPORTS.map(([name]) => [name, Math[name]]))
31071};
31072class PsWasmCompiler {
31073  static #initialized = false;
31074  static #comparisonToOp = null;
31075  static #importIdx = null;
31076  static #degToRad = 0;
31077  static #radToDeg = 0;
31078  static #importTypeEntries = null;
31079  static #importSection = null;
31080  static #functionSection = null;
31081  static #memorySection = null;
31082  static #exportSection = null;
31083  static #wasmMagicVersion = null;
31084  static #f64View = null;
31085  static #f64Arr = null;
31086  static #init() {
31087    this.#comparisonToOp = new Map([[TOKEN.eq, wasm_compiler_OP.f64_eq], [TOKEN.ne, wasm_compiler_OP.f64_ne], [TOKEN.lt, wasm_compiler_OP.f64_lt], [TOKEN.le, wasm_compiler_OP.f64_le], [TOKEN.gt, wasm_compiler_OP.f64_gt], [TOKEN.ge, wasm_compiler_OP.f64_ge]]);
31088    this.#importIdx = Object.create(null);
31089    for (let i = 0; i < MATH_IMPORTS.length; i++) {
31090      this.#importIdx[MATH_IMPORTS[i][0]] = i;
31091    }
31092    this.#degToRad = Math.PI / 180;
31093    this.#radToDeg = 180 / Math.PI;
31094    this.#importTypeEntries = MATH_IMPORTS.map(([,,, params, results]) => [FUNC_TYPE, ...vec(params), ...vec(results)]);
31095    this.#importSection = new Uint8Array(section(SECTION.import, vec(MATH_IMPORTS.map(([, mod, field], i) => [...encodeASCIIString(mod), ...encodeASCIIString(field), EXTERN_FUNC, ...unsignedLEB128(i + 1)]))));
31096    this.#functionSection = new Uint8Array(section(SECTION.function, vec([[0]])));
31097    this.#memorySection = new Uint8Array(section(SECTION.memory, vec([[0x00, 0x01]])));
31098    this.#exportSection = new Uint8Array(section(SECTION.export, vec([[...encodeASCIIString("fn"), EXTERN_FUNC, ...unsignedLEB128(MATH_IMPORTS.length)], [...encodeASCIIString("mem"), EXTERN_MEM, 0x00]])));
31099    this.#wasmMagicVersion = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]);
31100    const f64Buf = new ArrayBuffer(8);
31101    this.#f64View = new DataView(f64Buf);
31102    this.#f64Arr = new Uint8Array(f64Buf);
31103    this.#initialized = true;
31104  }
31105  constructor(domain, range) {
31106    if (!PsWasmCompiler.#initialized) {
31107      PsWasmCompiler.#init();
31108    }
31109    this._nIn = domain.length >> 1;
31110    this._nOut = range.length >> 1;
31111    this._range = range;
31112    this._code = [];
31113    this._nextLocal = this._nIn;
31114    this._freeLocals = [];
31115    this._sharedLocals = new Map();
31116  }
31117  _allocLocal() {
31118    return this._freeLocals.pop() ?? this._nextLocal++;
31119  }
31120  _releaseLocal(idx) {
31121    this._freeLocals.push(idx);
31122  }
31123  _emitULEB128(n) {
31124    do {
31125      let b = n & 0x7f;
31126      n >>>= 7;
31127      if (n !== 0) {
31128        b |= 0x80;
31129      }
31130      this._code.push(b);
31131    } while (n !== 0);
vendor: 6,123 bytes, lines 31131-31341
31131
31132  }
31133  _emitF64Const(value) {
31134    this._code.push(wasm_compiler_OP.f64_const);
31135    PsWasmCompiler.#f64View.setFloat64(0, value, true);
31136    for (let i = 0; i < 8; i++) {
31137      this._code.push(PsWasmCompiler.#f64Arr[i]);
31138    }
31139  }
31140  _emitLocalGet(idx) {
31141    this._code.push(wasm_compiler_OP.local_get);
31142    this._emitULEB128(idx);
31143  }
31144  _emitLocalSet(idx) {
31145    this._code.push(wasm_compiler_OP.local_set);
31146    this._emitULEB128(idx);
31147  }
31148  _emitLocalTee(idx) {
31149    this._code.push(wasm_compiler_OP.local_tee);
31150    this._emitULEB128(idx);
31151  }
31152  _compileNode(node) {
31153    if (node.shared) {
31154      const entry = this._sharedLocals.get(node);
31155      if (entry !== undefined) {
31156        this._emitLocalGet(entry.local);
31157        if (--entry.remaining === 0) {
31158          this._releaseLocal(entry.local);
31159        }
31160        return true;
31161      }
31162      if (!this._compileNodeImpl(node)) {
31163        return false;
31164      }
31165      const local = this._allocLocal();
31166      this._sharedLocals.set(node, {
31167        local,
31168        remaining: node.sharedCount - 1
31169      });
31170      this._emitLocalTee(local);
31171      return true;
31172    }
31173    return this._compileNodeImpl(node);
31174  }
31175  _compileNodeImpl(node) {
31176    switch (node.type) {
31177      case PS_NODE.arg:
31178        this._emitLocalGet(node.index);
31179        return true;
31180      case PS_NODE.const:
31181        {
31182          let v = node.value;
31183          if (typeof v === "boolean") {
31184            v = v ? 1 : 0;
31185          }
31186          this._emitF64Const(v);
31187          return true;
31188        }
31189      case PS_NODE.unary:
31190        return this._compileUnaryNode(node);
31191      case PS_NODE.binary:
31192        return this._compileBinaryNode(node);
31193      case PS_NODE.ternary:
31194        return this._compileTernaryNode(node);
31195      default:
31196        return false;
31197    }
31198  }
31199  _compileSinCosNode(node) {
31200    const local = this._allocLocal();
31201    try {
31202      if (!this._compileNode(node.operand)) {
31203        return false;
31204      }
31205      const code = this._code;
31206      this._emitLocalSet(local);
31207      this._emitLocalGet(local);
31208      this._emitLocalGet(local);
31209      this._emitF64Const(360);
31210      code.push(wasm_compiler_OP.f64_div, wasm_compiler_OP.f64_trunc);
31211      this._emitF64Const(360);
31212      code.push(wasm_compiler_OP.f64_mul, wasm_compiler_OP.f64_sub);
31213      this._emitF64Const(PsWasmCompiler.#degToRad);
31214      code.push(wasm_compiler_OP.f64_mul, wasm_compiler_OP.call);
31215      this._emitULEB128(PsWasmCompiler.#importIdx[node.op === TOKEN.sin ? "sin" : "cos"]);
31216      return true;
31217    } finally {
31218      this._releaseLocal(local);
31219    }
31220  }
31221  _compileUnaryNode(node) {
31222    const code = this._code;
31223    if (node.op === TOKEN.sin || node.op === TOKEN.cos) {
31224      return this._compileSinCosNode(node);
31225    }
31226    if (node.op === TOKEN.not) {
31227      if (node.valueType === PS_VALUE_TYPE.boolean) {
31228        if (!this._compileNodeAsBoolI32(node.operand)) {
31229          return false;
31230        }
31231        code.push(wasm_compiler_OP.i32_eqz, wasm_compiler_OP.f64_convert_i32_s);
31232        return true;
31233      }
31234      if (node.valueType === PS_VALUE_TYPE.numeric) {
31235        if (!this._compileNode(node.operand)) {
31236          return false;
31237        }
31238        code.push(wasm_compiler_OP.i32_trunc_f64_s, wasm_compiler_OP.i32_const, 0x7f, wasm_compiler_OP.i32_xor, wasm_compiler_OP.f64_convert_i32_s);
31239        return true;
31240      }
31241      return false;
31242    }
31243    if (!this._compileNode(node.operand)) {
31244      return false;
31245    }
31246    switch (node.op) {
31247      case TOKEN.abs:
31248        code.push(wasm_compiler_OP.f64_abs);
31249        break;
31250      case TOKEN.neg:
31251        code.push(wasm_compiler_OP.f64_neg);
31252        break;
31253      case TOKEN.sqrt:
31254        code.push(wasm_compiler_OP.f64_sqrt);
31255        break;
31256      case TOKEN.floor:
31257        code.push(wasm_compiler_OP.f64_floor);
31258        break;
31259      case TOKEN.ceiling:
31260        code.push(wasm_compiler_OP.f64_ceil);
31261        break;
31262      case TOKEN.round:
31263        this._emitF64Const(0.5);
31264        code.push(wasm_compiler_OP.f64_add, wasm_compiler_OP.f64_floor);
31265        break;
31266      case TOKEN.truncate:
31267        code.push(wasm_compiler_OP.f64_trunc);
31268        break;
31269      case TOKEN.cvi:
31270        code.push(wasm_compiler_OP.i32_trunc_f64_s, wasm_compiler_OP.f64_convert_i32_s);
31271        break;
31272      case TOKEN.cvr:
31273        break;
31274      case TOKEN.ln:
31275        code.push(wasm_compiler_OP.call);
31276        this._emitULEB128(PsWasmCompiler.#importIdx.log);
31277        break;
31278      case TOKEN.log:
31279        code.push(wasm_compiler_OP.call);
31280        this._emitULEB128(PsWasmCompiler.#importIdx.log10);
31281        break;
31282      default:
31283        return false;
31284    }
31285    return true;
31286  }
31287  _compileSafeDivNode(first, second) {
31288    const tmp = this._allocLocal();
31289    try {
31290      if (!this._compileNode(second)) {
31291        return false;
31292      }
31293      if (!this._compileNode(first)) {
31294        return false;
31295      }
31296      const code = this._code;
31297      this._emitLocalTee(tmp);
31298      code.push(wasm_compiler_OP.f64_div);
31299      this._emitF64Const(0);
31300      this._emitLocalGet(tmp);
31301      this._emitF64Const(0);
31302      code.push(wasm_compiler_OP.f64_ne, wasm_compiler_OP.select);
31303      return true;
31304    } finally {
31305      this._releaseLocal(tmp);
31306    }
31307  }
31308  _compileSafeIdivNode(first, second) {
31309    const tmp = this._allocLocal();
31310    try {
31311      if (!this._compileNode(second)) {
31312        return false;
31313      }
31314      if (!this._compileNode(first)) {
31315        return false;
31316      }
31317      const code = this._code;
31318      this._emitLocalTee(tmp);
31319      code.push(wasm_compiler_OP.f64_div, wasm_compiler_OP.f64_trunc);
31320      this._emitF64Const(0);
31321      this._emitLocalGet(tmp);
31322      this._emitF64Const(0);
31323      code.push(wasm_compiler_OP.f64_ne, wasm_compiler_OP.select);
31324      return true;
31325    } finally {
31326      this._releaseLocal(tmp);
31327    }
31328  }
31329  _compileBitshiftNode(first, second) {
31330    if (first.type !== PS_NODE.const || !Number.isInteger(first.value)) {
31331      return false;
31332    }
31333    if (!this._compileNode(second)) {
31334      return false;
31335    }
31336    const code = this._code;
31337    code.push(wasm_compiler_OP.i32_trunc_f64_s);
31338    const shift = first.value;
31339    if (shift > 0) {
31340      code.push(wasm_compiler_OP.i32_const);
31341      this._emit
31341ULEB128(shift);
31342      code.push(wasm_compiler_OP.i32_shl);
31343    } else if (shift < 0) {
31344      code.push(wasm_compiler_OP.i32_const);
31345      this._emitU
vendor: 8,478 bytes, lines 31345-31626
31345LEB128(-shift);
31346      code.push(wasm_compiler_OP.i32_shr_s);
31347    }
31348    code.push(wasm_compiler_OP.f64_convert_i32_s);
31349    return true;
31350  }
31351  _compileModNode(first, second) {
31352    if (first.type === PS_NODE.const && first.value === 0) {
31353      if (!this._compileNode(second)) {
31354        return false;
31355      }
31356      this._code.push(wasm_compiler_OP.drop);
31357      this._emitF64Const(0);
31358      return true;
31359    }
31360    const localA = this._allocLocal();
31361    try {
31362      if (!this._compileNode(second)) {
31363        return false;
31364      }
31365      this._emitLocalTee(localA);
31366      const code = this._code;
31367      if (first.type === PS_NODE.const) {
31368        this._emitLocalGet(localA);
31369        this._emitF64Const(first.value);
31370        code.push(wasm_compiler_OP.f64_div, wasm_compiler_OP.f64_trunc);
31371        this._emitF64Const(first.value);
31372        code.push(wasm_compiler_OP.f64_mul, wasm_compiler_OP.f64_sub);
31373      } else {
31374        const localB = this._allocLocal();
31375        try {
31376          if (!this._compileNode(first)) {
31377            return false;
31378          }
31379          this._emitLocalSet(localB);
31380          this._emitLocalGet(localA);
31381          this._emitLocalGet(localB);
31382          code.push(wasm_compiler_OP.f64_div, wasm_compiler_OP.f64_trunc);
31383          this._emitLocalGet(localB);
31384          code.push(wasm_compiler_OP.f64_mul, wasm_compiler_OP.f64_sub);
31385          this._emitF64Const(0);
31386          this._emitLocalGet(localB);
31387          this._emitF64Const(0);
31388          code.push(wasm_compiler_OP.f64_ne, wasm_compiler_OP.select);
31389        } finally {
31390          this._releaseLocal(localB);
31391        }
31392      }
31393      return true;
31394    } finally {
31395      this._releaseLocal(localA);
31396    }
31397  }
31398  _compileAtanNode(first, second) {
31399    const localR = this._allocLocal();
31400    try {
31401      if (!this._compileNode(second)) {
31402        return false;
31403      }
31404      if (!this._compileNode(first)) {
31405        return false;
31406      }
31407      const code = this._code;
31408      code.push(wasm_compiler_OP.call);
31409      this._emitULEB128(PsWasmCompiler.#importIdx.atan2);
31410      this._emitF64Const(PsWasmCompiler.#radToDeg);
31411      code.push(wasm_compiler_OP.f64_mul);
31412      this._emitLocalTee(localR);
31413      this._emitF64Const(0);
31414      code.push(wasm_compiler_OP.f64_lt, wasm_compiler_OP.if, F64);
31415      this._emitLocalGet(localR);
31416      this._emitF64Const(360);
31417      code.push(wasm_compiler_OP.f64_add, wasm_compiler_OP.else);
31418      this._emitLocalGet(localR);
31419      code.push(wasm_compiler_OP.end);
31420      return true;
31421    } finally {
31422      this._releaseLocal(localR);
31423    }
31424  }
31425  _compileBitwiseNode(op, first, second) {
31426    if (!this._compileBitwiseOperandI32(second)) {
31427      return false;
31428    }
31429    if (!this._compileBitwiseOperandI32(first)) {
31430      return false;
31431    }
31432    const code = this._code;
31433    switch (op) {
31434      case TOKEN.and:
31435        code.push(wasm_compiler_OP.i32_and);
31436        break;
31437      case TOKEN.or:
31438        code.push(wasm_compiler_OP.i32_or);
31439        break;
31440      case TOKEN.xor:
31441        code.push(wasm_compiler_OP.i32_xor);
31442        break;
31443      default:
31444        return false;
31445    }
31446    code.push(wasm_compiler_OP.f64_convert_i32_s);
31447    return true;
31448  }
31449  _compileBitwiseOperandI32(node) {
31450    if (node.valueType === PS_VALUE_TYPE.boolean) {
31451      return this._compileNodeAsBoolI32(node);
31452    }
31453    if (!this._compileNode(node)) {
31454      return false;
31455    }
31456    this._code.push(wasm_compiler_OP.i32_trunc_f64_s);
31457    return true;
31458  }
31459  _compileStandardBinaryNode(op, first, second) {
31460    if (first === second && first.type !== PS_NODE.arg && first.type !== PS_NODE.const && !first.shared) {
31461      const tmp = this._allocLocal();
31462      try {
31463        if (!this._compileNode(first)) {
31464          return false;
31465        }
31466        this._emitLocalTee(tmp);
31467        this._emitLocalGet(tmp);
31468      } finally {
31469        this._releaseLocal(tmp);
31470      }
31471    } else {
31472      if (!this._compileNode(second)) {
31473        return false;
31474      }
31475      if (!this._compileNode(first)) {
31476        return false;
31477      }
31478    }
31479    const code = this._code;
31480    switch (op) {
31481      case TOKEN.add:
31482        code.push(wasm_compiler_OP.f64_add);
31483        break;
31484      case TOKEN.sub:
31485        code.push(wasm_compiler_OP.f64_sub);
31486        break;
31487      case TOKEN.mul:
31488        code.push(wasm_compiler_OP.f64_mul);
31489        break;
31490      case TOKEN.exp:
31491        code.push(wasm_compiler_OP.call);
31492        this._emitULEB128(PsWasmCompiler.#importIdx.pow);
31493        break;
31494      case TOKEN.eq:
31495        code.push(wasm_compiler_OP.f64_eq, wasm_compiler_OP.f64_convert_i32_s);
31496        break;
31497      case TOKEN.ne:
31498        code.push(wasm_compiler_OP.f64_ne, wasm_compiler_OP.f64_convert_i32_s);
31499        break;
31500      case TOKEN.lt:
31501        code.push(wasm_compiler_OP.f64_lt, wasm_compiler_OP.f64_convert_i32_s);
31502        break;
31503      case TOKEN.le:
31504        code.push(wasm_compiler_OP.f64_le, wasm_compiler_OP.f64_convert_i32_s);
31505        break;
31506      case TOKEN.gt:
31507        code.push(wasm_compiler_OP.f64_gt, wasm_compiler_OP.f64_convert_i32_s);
31508        break;
31509      case TOKEN.ge:
31510        code.push(wasm_compiler_OP.f64_ge, wasm_compiler_OP.f64_convert_i32_s);
31511        break;
31512      case TOKEN.min:
31513        code.push(wasm_compiler_OP.f64_min);
31514        break;
31515      case TOKEN.max:
31516        code.push(wasm_compiler_OP.f64_max);
31517        break;
31518      default:
31519        return false;
31520    }
31521    return true;
31522  }
31523  _compileBinaryNode(node) {
31524    const {
31525      op,
31526      first,
31527      second
31528    } = node;
31529    if (op === TOKEN.bitshift) {
31530      return this._compileBitshiftNode(first, second);
31531    }
31532    if (op === TOKEN.div) {
31533      return this._compileSafeDivNode(first, second);
31534    }
31535    if (op === TOKEN.idiv) {
31536      return this._compileSafeIdivNode(first, second);
31537    }
31538    if (op === TOKEN.mod) {
31539      return this._compileModNode(first, second);
31540    }
31541    if (op === TOKEN.atan) {
31542      return this._compileAtanNode(first, second);
31543    }
31544    if (op === TOKEN.and || op === TOKEN.or || op === TOKEN.xor) {
31545      return this._compileBitwiseNode(op, first, second);
31546    }
31547    return this._compileStandardBinaryNode(op, first, second);
31548  }
31549  _compileNodeAsBoolI32(node) {
31550    if (node.type === PS_NODE.binary) {
31551      const wasmOp = PsWasmCompiler.#comparisonToOp.get(node.op);
31552      if (wasmOp !== undefined) {
31553        if (!this._compileNode(node.second)) {
31554          return false;
31555        }
31556        if (!this._compileNode(node.first)) {
31557          return false;
31558        }
31559        this._code.push(wasmOp);
31560        return true;
31561      }
31562      if (node.valueType === PS_VALUE_TYPE.boolean && (node.op === TOKEN.and || node.op === TOKEN.or || node.op === TOKEN.xor)) {
31563        if (!this._compileNodeAsBoolI32(node.second)) {
31564          return false;
31565        }
31566        if (!this._compileNodeAsBoolI32(node.first)) {
31567          return false;
31568        }
31569        switch (node.op) {
31570          case TOKEN.and:
31571            this._code.push(wasm_compiler_OP.i32_and);
31572            break;
31573          case TOKEN.or:
31574            this._code.push(wasm_compiler_OP.i32_or);
31575            break;
31576          case TOKEN.xor:
31577            this._code.push(wasm_compiler_OP.i32_xor);
31578            break;
31579        }
31580        return true;
31581      }
31582    }
31583    if (node.type === PS_NODE.unary && node.op === TOKEN.not && node.valueType === PS_VALUE_TYPE.boolean) {
31584      if (!this._compileNodeAsBoolI32(node.operand)) {
31585        return false;
31586      }
31587      this._code.push(wasm_compiler_OP.i32_eqz);
31588      return true;
31589    }
31590    if (!this._compileNode(node)) {
31591      return false;
31592    }
31593    if (node.valueType === PS_VALUE_TYPE.boolean) {
31594      this._code.push(wasm_compiler_OP.i32_trunc_f64_s);
31595    } else {
31596      this._emitF64Const(0);
31597      this._code.push(wasm_compiler_OP.f64_ne);
31598    }
31599    return true;
31600  }
31601  _compileTernaryNode(node) {
31602    if (!this._compileNodeAsBoolI32(node.cond)) {
31603      return false;
31604    }
31605    this._code.push(wasm_compiler_OP.if, F64);
31606    if (!this._compileNode(node.then)) {
31607      return false;
31608    }
31609    this._code.push(wasm_compiler_OP.else);
31610    if (!this._compileNode(node.otherwise)) {
31611      return false;
31612    }
31613    this._code.push(wasm_compiler_OP.end);
31614    return true;
31615  }
31616  compile(program) {
31617    const outputs = new PSStackToTree().evaluate(program, this._nIn);
31618    if (!outputs || outputs.length < this._nOut) {
31619      return null;
31620    }
31621    const code = this._code;
31622    for (let i = 0; i < this._nOut; i++) {
31623      const min = this._range[i * 2];
31624      const max = this._range[i * 2 + 1];
31625      code.push(wasm_compiler_OP.i32_const);
31626      this._emit
vendor: 8,718 bytes, lines 31626-31933
31626ULEB128(i * 8);
31627      if (!this._compileNode(outputs[i])) {
31628        return null;
31629      }
31630      this._emitF64Const(max);
31631      code.push(wasm_compiler_OP.f64_min);
31632      this._emitF64Const(min);
31633      code.push(wasm_compiler_OP.f64_max, wasm_compiler_OP.f64_store, 0x03, 0x00);
31634    }
31635    code.push(wasm_compiler_OP.end);
31636    const nIn = this._nIn;
31637    const nLocals = this._nextLocal - nIn;
31638    const paramTypes = Array(nIn).fill(F64);
31639    const resultTypes = [];
31640    const funcType = [FUNC_TYPE, ...vec(paramTypes), ...vec(resultTypes)];
31641    const typeSectionBytes = new Uint8Array(section(SECTION.type, vec([funcType, ...PsWasmCompiler.#importTypeEntries])));
31642    const localDecls = nLocals > 0 ? vec([[...unsignedLEB128(nLocals), F64]]) : vec([]);
31643    const funcBodyLen = localDecls.length + code.length;
31644    const codeSectionBytes = new Uint8Array(section(SECTION.code, vec([[...unsignedLEB128(funcBodyLen), ...localDecls, ...code]])));
31645    const magicVersion = PsWasmCompiler.#wasmMagicVersion;
31646    const importSection = PsWasmCompiler.#importSection;
31647    const functionSection = PsWasmCompiler.#functionSection;
31648    const memorySection = PsWasmCompiler.#memorySection;
31649    const exportSection = PsWasmCompiler.#exportSection;
31650    const totalLen = magicVersion.length + typeSectionBytes.length + importSection.length + functionSection.length + memorySection.length + exportSection.length + codeSectionBytes.length;
31651    const result = new Uint8Array(totalLen);
31652    let off = 0;
31653    result.set(magicVersion, off);
31654    off += magicVersion.length;
31655    result.set(typeSectionBytes, off);
31656    off += typeSectionBytes.length;
31657    result.set(importSection, off);
31658    off += importSection.length;
31659    result.set(functionSection, off);
31660    off += functionSection.length;
31661    result.set(memorySection, off);
31662    off += memorySection.length;
31663    result.set(exportSection, off);
31664    off += exportSection.length;
31665    result.set(codeSectionBytes, off);
31666    return result;
31667  }
31668}
31669function compilePostScriptToWasm(source, domain, range) {
31670  return new PsWasmCompiler(domain, range).compile(parsePostScriptFunction(source));
31671}
31672function _makeWrapper(exports, nIn, nOut) {
31673  const {
31674    fn,
31675    mem
31676  } = exports;
31677  const outView = new Float64Array(mem.buffer, 0, nOut);
31678  let writeOut;
31679  switch (nOut) {
31680    case 1:
31681      writeOut = (dest, destOffset) => {
31682        dest[destOffset] = outView[0];
31683      };
31684      break;
31685    case 2:
31686      writeOut = (dest, destOffset) => {
31687        dest[destOffset] = outView[0];
31688        dest[destOffset + 1] = outView[1];
31689      };
31690      break;
31691    case 3:
31692      writeOut = (dest, destOffset) => {
31693        dest[destOffset] = outView[0];
31694        dest[destOffset + 1] = outView[1];
31695        dest[destOffset + 2] = outView[2];
31696      };
31697      break;
31698    case 4:
31699      writeOut = (dest, destOffset) => {
31700        dest[destOffset] = outView[0];
31701        dest[destOffset + 1] = outView[1];
31702        dest[destOffset + 2] = outView[2];
31703        dest[destOffset + 3] = outView[3];
31704      };
31705      break;
31706    default:
31707      writeOut = (dest, destOffset) => {
31708        for (let i = 0; i < nOut; i++) {
31709          dest[destOffset + i] = outView[i];
31710        }
31711      };
31712  }
31713  switch (nIn) {
31714    case 1:
31715      return (src, srcOffset, dest, destOffset) => {
31716        fn(src[srcOffset]);
31717        writeOut(dest, destOffset);
31718      };
31719    case 2:
31720      return (src, srcOffset, dest, destOffset) => {
31721        fn(src[srcOffset], src[srcOffset + 1]);
31722        writeOut(dest, destOffset);
31723      };
31724    case 3:
31725      return (src, srcOffset, dest, destOffset) => {
31726        fn(src[srcOffset], src[srcOffset + 1], src[srcOffset + 2]);
31727        writeOut(dest, destOffset);
31728      };
31729    case 4:
31730      return (src, srcOffset, dest, destOffset) => {
31731        fn(src[srcOffset], src[srcOffset + 1], src[srcOffset + 2], src[srcOffset + 3]);
31732        writeOut(dest, destOffset);
31733      };
31734    default:
31735      {
31736        const inBuf = new Float64Array(nIn);
31737        return (src, srcOffset, dest, destOffset) => {
31738          for (let i = 0; i < nIn; i++) {
31739            inBuf[i] = src[srcOffset + i];
31740          }
31741          fn(...inBuf);
31742          writeOut(dest, destOffset);
31743        };
31744      }
31745  }
31746}
31747function buildPostScriptWasmFunction(source, domain, range) {
31748  const bytes = compilePostScriptToWasm(source, domain, range);
31749  if (!bytes) {
31750    return null;
31751  }
31752  try {
31753    const instance = new WebAssembly.Instance(new WebAssembly.Module(bytes), _mathImportObject);
31754    return _makeWrapper(instance.exports, domain.length >> 1, range.length >> 1);
31755  } catch {
31756    return null;
31757  }
31758}
31759
31760;// ./src/core/image_utils.js
31761
31762
31763class BaseLocalCache {
31764  constructor(options) {
31765    this._onlyRefs = options?.onlyRefs === true;
31766    if (!this._onlyRefs) {
31767      this._nameRefMap = new Map();
31768      this._imageMap = new Map();
31769    }
31770    this._imageCache = new RefSetCache();
31771  }
31772  getByName(name) {
31773    if (this._onlyRefs) {
31774      unreachable("Should not call `getByName` method.");
31775    }
31776    const ref = this._nameRefMap.get(name);
31777    if (ref) {
31778      return this.getByRef(ref);
31779    }
31780    return this._imageMap.get(name) || null;
31781  }
31782  getByRef(ref) {
31783    return this._imageCache.get(ref) || null;
31784  }
31785  set(name, ref, data) {
31786    unreachable("Abstract method `set` called.");
31787  }
31788}
31789class LocalImageCache extends BaseLocalCache {
31790  set(name, ref = null, data) {
31791    if (typeof name !== "string") {
31792      throw new Error('LocalImageCache.set - expected "name" argument.');
31793    }
31794    if (ref) {
31795      if (this._imageCache.has(ref)) {
31796        return;
31797      }
31798      this._nameRefMap.set(name, ref);
31799      this._imageCache.put(ref, data);
31800      return;
31801    }
31802    if (this._imageMap.has(name)) {
31803      return;
31804    }
31805    this._imageMap.set(name, data);
31806  }
31807}
31808class LocalColorSpaceCache extends BaseLocalCache {
31809  set(name = null, ref = null, data) {
31810    if (typeof name !== "string" && !ref) {
31811      throw new Error('LocalColorSpaceCache.set - expected "name" and/or "ref" argument.');
31812    }
31813    if (ref) {
31814      if (this._imageCache.has(ref)) {
31815        return;
31816      }
31817      if (name !== null) {
31818        this._nameRefMap.set(name, ref);
31819      }
31820      this._imageCache.put(ref, data);
31821      return;
31822    }
31823    if (this._imageMap.has(name)) {
31824      return;
31825    }
31826    this._imageMap.set(name, data);
31827  }
31828}
31829class LocalFunctionCache extends BaseLocalCache {
31830  constructor(options) {
31831    super({
31832      onlyRefs: true
31833    });
31834  }
31835  set(name = null, ref, data) {
31836    if (!ref) {
31837      throw new Error('LocalFunctionCache.set - expected "ref" argument.');
31838    }
31839    if (this._imageCache.has(ref)) {
31840      return;
31841    }
31842    this._imageCache.put(ref, data);
31843  }
31844}
31845class LocalGStateCache extends BaseLocalCache {
31846  set(name, ref = null, data) {
31847    if (typeof name !== "string") {
31848      throw new Error('LocalGStateCache.set - expected "name" argument.');
31849    }
31850    if (ref) {
31851      if (this._imageCache.has(ref)) {
31852        return;
31853      }
31854      this._nameRefMap.set(name, ref);
31855      this._imageCache.put(ref, data);
31856      return;
31857    }
31858    if (this._imageMap.has(name)) {
31859      return;
31860    }
31861    this._imageMap.set(name, data);
31862  }
31863}
31864class LocalTilingPatternCache extends BaseLocalCache {
31865  constructor(options) {
31866    super({
31867      onlyRefs: true
31868    });
31869  }
31870  set(name = null, ref, data) {
31871    if (!ref) {
31872      throw new Error('LocalTilingPatternCache.set - expected "ref" argument.');
31873    }
31874    if (this._imageCache.has(ref)) {
31875      return;
31876    }
31877    this._imageCache.put(ref, data);
31878  }
31879}
31880class RegionalImageCache extends BaseLocalCache {
31881  constructor(options) {
31882    super({
31883      onlyRefs: true
31884    });
31885  }
31886  set(name = null, ref, data) {
31887    if (!ref) {
31888      throw new Error('RegionalImageCache.set - expected "ref" argument.');
31889    }
31890    if (this._imageCache.has(ref)) {
31891      return;
31892    }
31893    this._imageCache.put(ref, data);
31894  }
31895}
31896class GlobalColorSpaceCache extends BaseLocalCache {
31897  constructor(options) {
31898    super({
31899      onlyRefs: true
31900    });
31901  }
31902  set(name = null, ref, data) {
31903    if (!ref) {
31904      throw new Error('GlobalColorSpaceCache.set - expected "ref" argument.');
31905    }
31906    if (this._imageCache.has(ref)) {
31907      return;
31908    }
31909    this._imageCache.put(ref, data);
31910  }
31911  clear() {
31912    this._imageCache.clear();
31913  }
31914}
31915class GlobalImageCache {
31916  static NUM_PAGES_THRESHOLD = 2;
31917  static MIN_IMAGES_TO_CACHE = 10;
31918  static MAX_BYTE_SIZE = 5e7;
31919  #decodeFailedSet = new RefSet();
31920  constructor() {
31921    this._refCache = new RefSetCache();
31922    this._imageCache = new RefSetCache();
31923  }
31924  get #byteSize() {
31925    let byteSize = 0;
31926    for (const imageData of this._imageCache) {
31927      byteSize += imageData.byteSize;
31928    }
31929    return byteSize;
31930  }
31931  get #cacheLimitReached() {
31932    if (this._imageCache.size < GlobalImageCache.MIN_IMAGES_TO_CACHE) {
31933      return false;
31934    }
31935    if (this.#byteSize < GlobalImageCache.MAX_BYTE_SIZE) {
31936      return false;
31937    }
31938    return true;
31939  }
31940  shouldCache(ref, pageIndex) {
31941    let pageIndexSet = this._refCache.get(ref);
31942    if (!pageIndexSet) {
31943      pageIndexSet = new Set();
31944      this._refCache.put(ref, pageIndexSet);
31945    }
vendor: 37,800 bytes, lines 31945-33146
31945
31946    pageIndexSet.add(pageIndex);
31947    if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
31948      return false;
31949    }
31950    if (!this._imageCache.has(ref) && this.#cacheLimitReached) {
31951      return false;
31952    }
31953    return true;
31954  }
31955  addDecodeFailed(ref) {
31956    this.#decodeFailedSet.put(ref);
31957  }
31958  hasDecodeFailed(ref) {
31959    return this.#decodeFailedSet.has(ref);
31960  }
31961  addByteSize(ref, byteSize) {
31962    const imageData = this._imageCache.get(ref);
31963    if (!imageData) {
31964      return;
31965    }
31966    if (imageData.byteSize) {
31967      return;
31968    }
31969    imageData.byteSize = byteSize;
31970  }
31971  getData(ref, pageIndex) {
31972    const pageIndexSet = this._refCache.get(ref);
31973    if (!pageIndexSet) {
31974      return null;
31975    }
31976    if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
31977      return null;
31978    }
31979    const imageData = this._imageCache.get(ref);
31980    if (!imageData) {
31981      return null;
31982    }
31983    pageIndexSet.add(pageIndex);
31984    return imageData;
31985  }
31986  setData(ref, data) {
31987    if (!this._refCache.has(ref)) {
31988      throw new Error('GlobalImageCache.setData - expected "shouldCache" to have been called.');
31989    }
31990    if (this._imageCache.has(ref)) {
31991      return;
31992    }
31993    if (this.#cacheLimitReached) {
31994      warn("GlobalImageCache.setData - cache limit reached.");
31995      return;
31996    }
31997    this._imageCache.put(ref, data);
31998  }
31999  clear(onlyData = false) {
32000    if (!onlyData) {
32001      this.#decodeFailedSet.clear();
32002      this._refCache.clear();
32003    }
32004    this._imageCache.clear();
32005  }
32006}
32007
32008;// ./src/core/function.js
32009
32010
32011
32012
32013
32014
32015
32016
32017const FunctionType = {
32018  SAMPLED: 0,
32019  EXPONENTIAL_INTERPOLATION: 2,
32020  STITCHING: 3,
32021  POSTSCRIPT_CALCULATOR: 4
32022};
32023class PDFFunctionFactory {
32024  static #useWasm = true;
32025  static setOptions({
32026    useWasm
32027  }) {
32028    this.#useWasm = useWasm;
32029  }
32030  constructor({
32031    xref
32032  }) {
32033    this.xref = xref;
32034  }
32035  get useWasm() {
32036    return PDFFunctionFactory.#useWasm;
32037  }
32038  create(fn, parseArray = false) {
32039    let fnRef, parsedFn;
32040    if (fn instanceof Ref) {
32041      fnRef = fn;
32042    } else if (fn instanceof Dict) {
32043      fnRef = fn.objId;
32044    } else if (fn instanceof BaseStream) {
32045      fnRef = fn.dict?.objId;
32046    }
32047    if (fnRef) {
32048      const cachedFn = this._localFunctionCache.getByRef(fnRef);
32049      if (cachedFn) {
32050        return cachedFn;
32051      }
32052    }
32053    const fnObj = this.xref.fetchIfRef(fn);
32054    if (Array.isArray(fnObj)) {
32055      if (!parseArray) {
32056        throw new Error('PDFFunctionFactory.create - expected "parseArray" argument.');
32057      }
32058      parsedFn = PDFFunction.parseArray(this, fnObj);
32059    } else {
32060      parsedFn = PDFFunction.parse(this, fnObj);
32061    }
32062    if (fnRef) {
32063      this._localFunctionCache.set(null, fnRef, parsedFn);
32064    }
32065    return parsedFn;
32066  }
32067  get _localFunctionCache() {
32068    return shadow(this, "_localFunctionCache", new LocalFunctionCache());
32069  }
32070}
32071function toNumberArray(arr) {
32072  if (!Array.isArray(arr)) {
32073    return null;
32074  }
32075  if (!isNumberArray(arr, null)) {
32076    return arr.map(x => +x);
32077  }
32078  return arr;
32079}
32080class PDFFunction {
32081  static getSampleArray(size, outputSize, bps, stream) {
32082    let length = outputSize;
32083    for (const s of size) {
32084      length *= s;
32085    }
32086    const array = new Array(length);
32087    let codeSize = 0;
32088    let codeBuf = 0;
32089    const sampleMul = 1.0 / (2.0 ** bps - 1);
32090    const strBytes = stream.getBytes((length * bps + 7) / 8);
32091    let strIdx = 0;
32092    for (let i = 0; i < length; i++) {
32093      while (codeSize < bps) {
32094        codeBuf <<= 8;
32095        codeBuf |= strBytes[strIdx++];
32096        codeSize += 8;
32097      }
32098      codeSize -= bps;
32099      array[i] = (codeBuf >> codeSize) * sampleMul;
32100      codeBuf &= (1 << codeSize) - 1;
32101    }
32102    return array;
32103  }
32104  static parse(factory, fn) {
32105    const dict = fn.dict || fn;
32106    const typeNum = dict.get("FunctionType");
32107    switch (typeNum) {
32108      case FunctionType.SAMPLED:
32109        return this.constructSampled(factory, fn, dict);
32110      case FunctionType.EXPONENTIAL_INTERPOLATION:
32111        return this.constructInterpolated(factory, dict);
32112      case FunctionType.STITCHING:
32113        return this.constructStiched(factory, dict);
32114      case FunctionType.POSTSCRIPT_CALCULATOR:
32115        return this.constructPostScript(factory, fn, dict);
32116    }
32117    throw new FormatError(`Unknown function type: ${typeNum}`);
32118  }
32119  static parseArray(factory, fnObj) {
32120    const {
32121      xref
32122    } = factory;
32123    const fnArray = [];
32124    for (const fn of fnObj) {
32125      fnArray.push(this.parse(factory, xref.fetchIfRef(fn)));
32126    }
32127    return function (src, srcOffset, dest, destOffset) {
32128      for (let i = 0, ii = fnArray.length; i < ii; i++) {
32129        fnArray[i](src, srcOffset, dest, destOffset + i);
32130      }
32131    };
32132  }
32133  static constructSampled(factory, fn, dict) {
32134    function interpolate(x, xmin, xmax, ymin, ymax) {
32135      return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
32136    }
32137    const domain = toNumberArray(dict.getArray("Domain"));
32138    const range = toNumberArray(dict.getArray("Range"));
32139    if (!domain || !range) {
32140      throw new FormatError("No domain or range");
32141    }
32142    const inputSize = domain.length / 2;
32143    const outputSize = range.length / 2;
32144    const size = toNumberArray(dict.getArray("Size"));
32145    const bps = dict.get("BitsPerSample");
32146    const order = dict.get("Order") || 1;
32147    if (order !== 1) {
32148      info("No support for cubic spline interpolation: " + order);
32149    }
32150    let encode = toNumberArray(dict.getArray("Encode"));
32151    if (!encode) {
32152      encode = [];
32153      for (let i = 0; i < inputSize; ++i) {
32154        encode.push(0, size[i] - 1);
32155      }
32156    }
32157    const decode = toNumberArray(dict.getArray("Decode")) || range;
32158    const samples = this.getSampleArray(size, outputSize, bps, fn);
32159    return function constructSampledFn(src, srcOffset, dest, destOffset) {
32160      const cubeVertices = 1 << inputSize;
32161      const cubeN = new Float64Array(cubeVertices).fill(1);
32162      const cubeVertex = new Uint32Array(cubeVertices);
32163      let i, j;
32164      let k = outputSize,
32165        pos = 1;
32166      for (i = 0; i < inputSize; ++i) {
32167        const domain_2i = domain[2 * i];
32168        const domain_2i_1 = domain[2 * i + 1];
32169        const xi = MathClamp(src[srcOffset + i], domain_2i, domain_2i_1);
32170        let e = interpolate(xi, domain_2i, domain_2i_1, encode[2 * i], encode[2 * i + 1]);
32171        const size_i = size[i];
32172        e = MathClamp(e, 0, size_i - 1);
32173        const e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
32174        const n0 = e0 + 1 - e;
32175        const n1 = e - e0;
32176        const offset0 = e0 * k;
32177        const offset1 = offset0 + k;
32178        for (j = 0; j < cubeVertices; j++) {
32179          if (j & pos) {
32180            cubeN[j] *= n1;
32181            cubeVertex[j] += offset1;
32182          } else {
32183            cubeN[j] *= n0;
32184            cubeVertex[j] += offset0;
32185          }
32186        }
32187        k *= size_i;
32188        pos <<= 1;
32189      }
32190      for (j = 0; j < outputSize; ++j) {
32191        let rj = 0;
32192        for (i = 0; i < cubeVertices; i++) {
32193          rj += samples[cubeVertex[i] + j] * cubeN[i];
32194        }
32195        rj = interpolate(rj, 0, 1, decode[2 * j], decode[2 * j + 1]);
32196        dest[destOffset + j] = MathClamp(rj, range[2 * j], range[2 * j + 1]);
32197      }
32198    };
32199  }
32200  static constructInterpolated(factory, dict) {
32201    const c0 = toNumberArray(dict.getArray("C0")) || [0];
32202    const c1 = toNumberArray(dict.getArray("C1")) || [1];
32203    const n = dict.get("N");
32204    const diff = [];
32205    for (let i = 0, ii = c0.length; i < ii; ++i) {
32206      diff.push(c1[i] - c0[i]);
32207    }
32208    const length = diff.length;
32209    return function constructInterpolatedFn(src, srcOffset, dest, destOffset) {
32210      const x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
32211      for (let j = 0; j < length; ++j) {
32212        dest[destOffset + j] = c0[j] + x * diff[j];
32213      }
32214    };
32215  }
32216  static constructStiched(factory, dict) {
32217    const domain = toNumberArray(dict.getArray("Domain"));
32218    if (!domain) {
32219      throw new FormatError("No domain");
32220    }
32221    const inputSize = domain.length / 2;
32222    if (inputSize !== 1) {
32223      throw new FormatError("Bad domain for stiched function");
32224    }
32225    const {
32226      xref
32227    } = factory;
32228    const fns = [];
32229    for (const fn of dict.get("Functions")) {
32230      fns.push(this.parse(factory, xref.fetchIfRef(fn)));
32231    }
32232    const bounds = toNumberArray(dict.getArray("Bounds"));
32233    const encode = toNumberArray(dict.getArray("Encode"));
32234    const tmpBuf = new Float32Array(1);
32235    return function constructStichedFn(src, srcOffset, dest, destOffset) {
32236      const v = MathClamp(src[srcOffset], domain[0], domain[1]);
32237      const length = bounds.length;
32238      let i;
32239      for (i = 0; i < length; ++i) {
32240        if (v < bounds[i]) {
32241          break;
32242        }
32243      }
32244      const dmin = i > 0 ? bounds[i - 1] : domain[0];
32245      const dmax = i < length ? bounds[i] : domain[1];
32246      const rmin = encode[2 * i];
32247      const rmax = encode[2 * i + 1];
32248      tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
32249      fns[i](tmpBuf, 0, dest, destOffset);
32250    };
32251  }
32252  static constructPostScript(factory, fn, dict) {
32253    const domain = toNumberArray(dict.getArray("Domain"));
32254    const range = toNumberArray(dict.getArray("Range"));
32255    if (!domain) {
32256      throw new FormatError("No domain.");
32257    }
32258    if (!range) {
32259      throw new FormatError("No range.");
32260    }
32261    const psCode = fn.getString();
32262    try {
32263      if (factory.useWasm) {
32264        const wasmFn = buildPostScriptWasmFunction(psCode, domain, range);
32265        if (wasmFn) {
32266          return wasmFn;
32267        }
32268      }
32269    } catch {}
32270    warn("Failed to compile PostScript function to wasm, falling back to JS");
32271    return buildPostScriptJsFunction(psCode, domain, range);
32272  }
32273}
32274function isPDFFunction(v) {
32275  let fnDict;
32276  if (v instanceof Dict) {
32277    fnDict = v;
32278  } else if (v instanceof BaseStream) {
32279    fnDict = v.dict;
32280  } else {
32281    return false;
32282  }
32283  return fnDict.has("FunctionType");
32284}
32285
32286;// ./src/core/evaluator_utils.js
32287
32288
32289function textSinkWrapper(sink) {
32290  const TEXT_CONTENT_CHUNK_SIZE = 100;
32291  const resolved = sink ? null : Promise.resolve();
32292  return {
32293    enqueueInvoked: false,
32294    enqueue(chunk, size) {
32295      this.enqueueInvoked = true;
32296      sink?.enqueue(chunk, size);
32297    },
32298    get desiredSize() {
32299      return sink?.desiredSize ?? TEXT_CONTENT_CHUNK_SIZE;
32300    },
32301    get ready() {
32302      return sink?.ready ?? resolved;
32303    }
32304  };
32305}
32306function _parseVisibilityExpression(xref, array, nestingCounter, currentResult) {
32307  const MAX_NESTING = 10;
32308  if (++nestingCounter > MAX_NESTING) {
32309    warn("Visibility expression is too deeply nested");
32310    return;
32311  }
32312  const length = array.length;
32313  const operator = xref.fetchIfRef(array[0]);
32314  if (length < 2 || !(operator instanceof Name)) {
32315    warn("Invalid visibility expression");
32316    return;
32317  }
32318  switch (operator.name) {
32319    case "And":
32320    case "Or":
32321    case "Not":
32322      currentResult.push(operator.name);
32323      break;
32324    default:
32325      warn(`Invalid operator ${operator.name} in visibility expression`);
32326      return;
32327  }
32328  for (let i = 1; i < length; i++) {
32329    const raw = array[i];
32330    const object = xref.fetchIfRef(raw);
32331    if (Array.isArray(object)) {
32332      const nestedResult = [];
32333      currentResult.push(nestedResult);
32334      _parseVisibilityExpression(xref, object, nestingCounter, nestedResult);
32335    } else if (raw instanceof Ref) {
32336      currentResult.push(raw.toString());
32337    }
32338  }
32339}
32340function parseMarkedContentProps(xref, contentProperties, resources) {
32341  let optionalContent;
32342  if (contentProperties instanceof Name) {
32343    const properties = resources.get("Properties");
32344    optionalContent = properties.get(contentProperties.name);
32345  } else if (contentProperties instanceof Dict) {
32346    optionalContent = contentProperties;
32347  } else {
32348    throw new FormatError("Optional content properties malformed.");
32349  }
32350  const optionalContentType = optionalContent.get("Type")?.name;
32351  if (optionalContentType === "OCG") {
32352    return {
32353      type: optionalContentType,
32354      id: optionalContent.objId
32355    };
32356  } else if (optionalContentType === "OCMD") {
32357    const expression = optionalContent.get("VE");
32358    if (Array.isArray(expression)) {
32359      const result = [];
32360      _parseVisibilityExpression(xref, expression, 0, result);
32361      if (result.length > 0) {
32362        return {
32363          type: "OCMD",
32364          expression: result
32365        };
32366      }
32367    }
32368    const optionalContentGroups = optionalContent.get("OCGs");
32369    if (Array.isArray(optionalContentGroups) || optionalContentGroups instanceof Dict) {
32370      const groupIds = [];
32371      if (Array.isArray(optionalContentGroups)) {
32372        for (const ocg of optionalContentGroups) {
32373          groupIds.push(ocg.toString());
32374        }
32375      } else {
32376        groupIds.push(optionalContentGroups.objId);
32377      }
32378      const p = optionalContent.get("P");
32379      return {
32380        type: optionalContentType,
32381        ids: groupIds,
32382        policy: p instanceof Name ? p.name : null,
32383        expression: null
32384      };
32385    } else if (optionalContentGroups instanceof Ref) {
32386      return {
32387        type: optionalContentType,
32388        id: optionalContentGroups.toString()
32389      };
32390    }
32391  }
32392  return null;
32393}
32394
32395;// ./src/core/bidi.js
32396
32397const baseTypes = ["BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "S", "B", "S", "WS", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "B", "B", "B", "S", "WS", "ON", "ON", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "ON", "ES", "CS", "ES", "CS", "CS", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "CS", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "ON", "ON", "ON", "BN", "BN", "BN", "BN", "BN", "BN", "B", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "BN", "CS", "ON", "ET", "ET", "ET", "ET", "ON", "ON", "ON", "ON", "L", "ON", "ON", "BN", "ON", "ON", "ET", "ET", "EN", "EN", "ON", "L", "ON", "ON", "ON", "EN", "L", "ON", "ON", "ON", "ON", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "ON", "L", "L", "L", "L", "L", "L", "L", "L"];
32398const arabicTypes = ["AN", "AN", "AN", "AN", "AN", "AN", "ON", "ON", "AL", "ET", "ET", "AL", "CS", "AL", "ON", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "AN", "ET", "AN", "AN", "AL", "AL", "AL", "NSM", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "AL", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AN", "ON", "NSM", "NSM", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "NSM", "NSM", "ON", "NSM", "NSM", "NSM", "NSM", "AL", "AL", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "EN", "AL", "AL", "AL", "AL", "AL", "AL"];
32399function isOdd(i) {
32400  return (i & 1) !== 0;
32401}
32402function isEven(i) {
32403  return (i & 1) === 0;
32404}
32405function findUnequal(arr, start, value) {
32406  let j, jj;
32407  for (j = start, jj = arr.length; j < jj; ++j) {
32408    if (arr[j] !== value) {
32409      return j;
32410    }
32411  }
32412  return j;
32413}
32414function reverseValues(arr, start, end) {
32415  for (let i = start, j = end - 1; i < j; ++i, --j) {
32416    const temp = arr[i];
32417    arr[i] = arr[j];
32418    arr[j] = temp;
32419  }
32420}
32421function createBidiText(str, isLTR, vertical = false) {
32422  let dir = "ltr";
32423  if (vertical) {
32424    dir = "ttb";
32425  } else if (!isLTR) {
32426    dir = "rtl";
32427  }
32428  return {
32429    str,
32430    dir
32431  };
32432}
32433const chars = [];
32434const types = [];
32435function bidi(str, startLevel = -1, vertical = false) {
32436  let isLTR = true;
32437  const strLength = str.length;
32438  if (strLength === 0 || vertical) {
32439    return createBidiText(str, isLTR, vertical);
32440  }
32441  chars.length = strLength;
32442  types.length = strLength;
32443  let numBidi = 0;
32444  let i, ii;
32445  for (i = 0; i < strLength; ++i) {
32446    chars[i] = str.charAt(i);
32447    const charCode = str.charCodeAt(i);
32448    let charType = "L";
32449    if (charCode <= 0x00ff) {
32450      charType = baseTypes[charCode];
32451    } else if (0x0590 <= charCode && charCode <= 0x05f4) {
32452      charType = "R";
32453    } else if (0x0600 <= charCode && charCode <= 0x06ff) {
32454      charType = arabicTypes[charCode & 0xff];
32455      if (!charType) {
32456        warn("Bidi: invalid Unicode character " + charCode.toString(16));
32457      }
32458    } else if (0x0700 <= charCode && charCode <= 0x08ac || 0xfb50 <= charCode && charCode <= 0xfdff || 0xfe70 <= charCode && charCode <= 0xfeff) {
32459      charType = "AL";
32460    }
32461    if (charType === "R" || charType === "AL" || charType === "AN") {
32462      numBidi++;
32463    }
32464    types[i] = charType;
32465  }
32466  if (numBidi === 0) {
32467    isLTR = true;
32468    return createBidiText(str, isLTR);
32469  }
32470  if (startLevel === -1) {
32471    if (numBidi / strLength < 0.3 && strLength > 4) {
32472      isLTR = true;
32473      startLevel = 0;
32474    } else {
32475      isLTR = false;
32476      startLevel = 1;
32477    }
32478  }
32479  const levels = [];
32480  for (i = 0; i < strLength; ++i) {
32481    levels[i] = startLevel;
32482  }
32483  const e = isOdd(startLevel) ? "R" : "L";
32484  const sor = e;
32485  const eor = sor;
32486  let lastType = sor;
32487  for (i = 0; i < strLength; ++i) {
32488    if (types[i] === "NSM") {
32489      types[i] = lastType;
32490    } else {
32491      lastType = types[i];
32492    }
32493  }
32494  lastType = sor;
32495  let t;
32496  for (i = 0; i < strLength; ++i) {
32497    t = types[i];
32498    if (t === "EN") {
32499      types[i] = lastType === "AL" ? "AN" : "EN";
32500    } else if (t === "R" || t === "L" || t === "AL") {
32501      lastType = t;
32502    }
32503  }
32504  for (i = 0; i < strLength; ++i) {
32505    t = types[i];
32506    if (t === "AL") {
32507      types[i] = "R";
32508    }
32509  }
32510  for (i = 1; i < strLength - 1; ++i) {
32511    if (types[i] === "ES" && types[i - 1] === "EN" && types[i + 1] === "EN") {
32512      types[i] = "EN";
32513    }
32514    if (types[i] === "CS" && (types[i - 1] === "EN" || types[i - 1] === "AN") && types[i + 1] === types[i - 1]) {
32515      types[i] = types[i - 1];
32516    }
32517  }
32518  for (i = 0; i < strLength; ++i) {
32519    if (types[i] === "EN") {
32520      for (let j = i - 1; j >= 0; --j) {
32521        if (types[j] !== "ET") {
32522          break;
32523        }
32524        types[j] = "EN";
32525      }
32526      for (let j = i + 1; j < strLength; ++j) {
32527        if (types[j] !== "ET") {
32528          break;
32529        }
32530        types[j] = "EN";
32531      }
32532    }
32533  }
32534  for (i = 0; i < strLength; ++i) {
32535    t = types[i];
32536    if (t === "WS" || t === "ES" || t === "ET" || t === "CS") {
32537      types[i] = "ON";
32538    }
32539  }
32540  lastType = sor;
32541  for (i = 0; i < strLength; ++i) {
32542    t = types[i];
32543    if (t === "EN") {
32544      types[i] = lastType === "L" ? "L" : "EN";
32545    } else if (t === "R" || t === "L") {
32546      lastType = t;
32547    }
32548  }
32549  for (i = 0; i < strLength; ++i) {
32550    if (types[i] === "ON") {
32551      const end = findUnequal(types, i + 1, "ON");
32552      let before = sor;
32553      for (let j = i - 1; j >= 0; j--) {
32554        const tt = types[j];
32555        if (tt === "L") {
32556          before = "L";
32557          break;
32558        }
32559        if (tt === "R" || tt === "EN" || tt === "AN") {
32560          before = "R";
32561          break;
32562        }
32563      }
32564      let after = eor;
32565      for (let j = end; j < strLength; j++) {
32566        const tt = types[j];
32567        if (tt === "L") {
32568          after = "L";
32569          break;
32570        }
32571        if (tt === "R" || tt === "EN" || tt === "AN") {
32572          after = "R";
32573          break;
32574        }
32575      }
32576      if (before === after) {
32577        types.fill(before, i, end);
32578      }
32579      i = end - 1;
32580    }
32581  }
32582  for (i = 0; i < strLength; ++i) {
32583    if (types[i] === "ON") {
32584      types[i] = e;
32585    }
32586  }
32587  for (i = 0; i < strLength; ++i) {
32588    t = types[i];
32589    if (isEven(levels[i])) {
32590      if (t === "R") {
32591        levels[i] += 1;
32592      } else if (t === "AN" || t === "EN") {
32593        levels[i] += 2;
32594      }
32595    } else if (t === "L" || t === "AN" || t === "EN") {
32596      levels[i] += 1;
32597    }
32598  }
32599  let highestLevel = -1;
32600  let lowestOddLevel = 99;
32601  let level;
32602  for (i = 0, ii = levels.length; i < ii; ++i) {
32603    level = levels[i];
32604    if (highestLevel < level) {
32605      highestLevel = level;
32606    }
32607    if (lowestOddLevel > level && isOdd(level)) {
32608      lowestOddLevel = level;
32609    }
32610  }
32611  for (level = highestLevel; level >= lowestOddLevel; --level) {
32612    let start = -1;
32613    for (i = 0, ii = levels.length; i < ii; ++i) {
32614      if (levels[i] < level) {
32615        if (start >= 0) {
32616          reverseValues(chars, start, i);
32617          start = -1;
32618        }
32619      } else if (start < 0) {
32620        start = i;
32621      }
32622    }
32623    if (start >= 0) {
32624      reverseValues(chars, start, levels.length);
32625    }
32626  }
32627  for (i = 0, ii = chars.length; i < ii; ++i) {
32628    const ch = chars[i];
32629    if (ch === "<" || ch === ">") {
32630      chars[i] = "";
32631    }
32632  }
32633  return createBidiText(chars.join(""), isLTR);
32634}
32635
32636;// ./src/core/font_substitutions.js
32637
32638
32639
32640const NORMAL = {
32641  style: "normal",
32642  weight: "normal"
32643};
32644const MEDIUM = {
32645  style: "normal",
32646  weight: "500"
32647};
32648const BOLD = {
32649  style: "normal",
32650  weight: "bold"
32651};
32652const ITALIC = {
32653  style: "italic",
32654  weight: "normal"
32655};
32656const BOLDITALIC = {
32657  style: "italic",
32658  weight: "bold"
32659};
32660const substitutionMap = new Map([["Times-Roman", {
32661  local: ["Times New Roman", "Times-Roman", "Times", "Liberation Serif", "Nimbus Roman", "Nimbus Roman L", "Tinos", "Thorndale", "TeX Gyre Termes", "FreeSerif", "Linux Libertine O", "Libertinus Serif", "PT Astra Serif", "DejaVu Serif", "Bitstream Vera Serif", "Ubuntu"],
32662  style: NORMAL,
32663  ultimate: "serif"
32664}], ["Times-Bold", {
32665  alias: "Times-Roman",
32666  style: BOLD,
32667  ultimate: "serif"
32668}], ["Times-Italic", {
32669  alias: "Times-Roman",
32670  style: ITALIC,
32671  ultimate: "serif"
32672}], ["Times-BoldItalic", {
32673  alias: "Times-Roman",
32674  style: BOLDITALIC,
32675  ultimate: "serif"
32676}], ["Helvetica", {
32677  local: ["Helvetica", "Helvetica Neue", "Arial", "Arial Nova", "Liberation Sans", "Arimo", "Nimbus Sans", "Nimbus Sans L", "A030", "TeX Gyre Heros", "FreeSans", "DejaVu Sans", "Albany", "Bitstream Vera Sans", "Arial Unicode MS", "Microsoft Sans Serif", "Apple Symbols", "Cantarell"],
32678  path: "LiberationSans-Regular.ttf",
32679  style: NORMAL,
32680  ultimate: "sans-serif"
32681}], ["Helvetica-Bold", {
32682  alias: "Helvetica",
32683  path: "LiberationSans-Bold.ttf",
32684  style: BOLD,
32685  ultimate: "sans-serif"
32686}], ["Helvetica-Oblique", {
32687  alias: "Helvetica",
32688  path: "LiberationSans-Italic.ttf",
32689  style: ITALIC,
32690  ultimate: "sans-serif"
32691}], ["Helvetica-BoldOblique", {
32692  alias: "Helvetica",
32693  path: "LiberationSans-BoldItalic.ttf",
32694  style: BOLDITALIC,
32695  ultimate: "sans-serif"
32696}], ["Courier", {
32697  local: ["Courier", "Courier New", "Liberation Mono", "Nimbus Mono", "Nimbus Mono L", "Cousine", "Cumberland", "TeX Gyre Cursor", "FreeMono", "Linux Libertine Mono O", "Libertinus Mono"],
32698  style: NORMAL,
32699  ultimate: "monospace"
32700}], ["Courier-Bold", {
32701  alias: "Courier",
32702  style: BOLD,
32703  ultimate: "monospace"
32704}], ["Courier-Oblique", {
32705  alias: "Courier",
32706  style: ITALIC,
32707  ultimate: "monospace"
32708}], ["Courier-BoldOblique", {
32709  alias: "Courier",
32710  style: BOLDITALIC,
32711  ultimate: "monospace"
32712}], ["ArialBlack", {
32713  local: ["Arial Black"],
32714  style: {
32715    style: "normal",
32716    weight: "900"
32717  },
32718  fallback: "Helvetica-Bold"
32719}], ["ArialBlack-Bold", {
32720  alias: "ArialBlack"
32721}], ["ArialBlack-Italic", {
32722  alias: "ArialBlack",
32723  style: {
32724    style: "italic",
32725    weight: "900"
32726  },
32727  fallback: "Helvetica-BoldOblique"
32728}], ["ArialBlack-BoldItalic", {
32729  alias: "ArialBlack-Italic"
32730}], ["ArialNarrow", {
32731  local: ["Arial Narrow", "Liberation Sans Narrow", "Helvetica Condensed", "Nimbus Sans Narrow", "TeX Gyre Heros Cn"],
32732  style: NORMAL,
32733  fallback: "Helvetica"
32734}], ["ArialNarrow-Bold", {
32735  alias: "ArialNarrow",
32736  style: BOLD,
32737  fallback: "Helvetica-Bold"
32738}], ["ArialNarrow-Italic", {
32739  alias: "ArialNarrow",
32740  style: ITALIC,
32741  fallback: "Helvetica-Oblique"
32742}], ["ArialNarrow-BoldItalic", {
32743  alias: "ArialNarrow",
32744  style: BOLDITALIC,
32745  fallback: "Helvetica-BoldOblique"
32746}], ["Calibri", {
32747  local: ["Calibri", "Carlito"],
32748  style: NORMAL,
32749  fallback: "Helvetica"
32750}], ["Calibri-Bold", {
32751  alias: "Calibri",
32752  style: BOLD,
32753  fallback: "Helvetica-Bold"
32754}], ["Calibri-Italic", {
32755  alias: "Calibri",
32756  style: ITALIC,
32757  fallback: "Helvetica-Oblique"
32758}], ["Calibri-BoldItalic", {
32759  alias: "Calibri",
32760  style: BOLDITALIC,
32761  fallback: "Helvetica-BoldOblique"
32762}], ["Wingdings", {
32763  local: ["Wingdings", "URW Dingbats"],
32764  style: NORMAL
32765}], ["Wingdings-Regular", {
32766  alias: "Wingdings"
32767}], ["Wingdings-Bold", {
32768  alias: "Wingdings"
32769}], ["\xCB\xCE\xCC\xE5", {
32770  local: ["SimSun", "SimSun Regular", "NSimSun"],
32771  style: NORMAL,
32772  ultimate: "serif"
32773}], ["\xBA\xDA\xCC\xE5", {
32774  local: ["SimHei", "SimHei Regular"],
32775  style: NORMAL,
32776  ultimate: "sans-serif"
32777}], ["\xBF\xAC\xCC\xE5", {
32778  local: ["KaiTi", "SimKai", "SimKai Regular"],
32779  style: NORMAL,
32780  ultimate: "sans-serif"
32781}], ["\xB7\xC2\xCB\xCE", {
32782  local: ["FangSong", "SimFang", "SimFang Regular"],
32783  style: NORMAL,
32784  ultimate: "serif"
32785}], ["\xBF\xAC\xCC\xE5_GB2312", {
32786  alias: "\xBF\xAC\xCC\xE5"
32787}], ["\xB7\xC2\xCB\xCE_GB2312", {
32788  alias: "\xB7\xC2\xCB\xCE"
32789}], ["\xC1\xA5\xCA\xE9", {
32790  local: ["SimLi", "SimLi Regular"],
32791  style: NORMAL,
32792  ultimate: "serif"
32793}], ["\xD0\xC2\xCB\xCE", {
32794  alias: "\xCB\xCE\xCC\xE5"
32795}], ["HeiseiMin-W3", {
32796  local: ["Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", "YuMincho", "Source Han Serif JP", "Noto Serif JP", "Noto Serif CJK JP", "IPAexMincho", "IPAMincho", "Takao Mincho", "MS Mincho", "MS PMincho"],
32797  style: NORMAL,
32798  ultimate: "serif"
32799}], ["HeiseiKakuGo-W5", {
32800  local: ["Hiragino Kaku Gothic ProN", "Hiragino Kaku Gothic Pro", "Hiragino Sans", "Yu Gothic", "YuGothic", "Source Han Sans JP", "Noto Sans JP", "Noto Sans CJK JP", "IPAexGothic", "IPAGothic", "Takao Gothic", "Meiryo", "MS Gothic", "MS PGothic"],
32801  style: MEDIUM,
32802  ultimate: "sans-serif"
32803}], ["HeiseiMin-W3-Acro", {
32804  alias: "HeiseiMin-W3"
32805}], ["HeiseiKakuGo-W5-Acro", {
32806  alias: "HeiseiKakuGo-W5"
32807}], ["KozMinPro-Regular", {
32808  alias: "HeiseiMin-W3"
32809}], ["KozMinProVI-Regular", {
32810  alias: "HeiseiMin-W3"
32811}], ["KozMinPr6N-Regular", {
32812  alias: "HeiseiMin-W3"
32813}], ["KozGoPro-Regular", {
32814  alias: "HeiseiKakuGo-W5"
32815}], ["KozGoProVI-Regular", {
32816  alias: "HeiseiKakuGo-W5"
32817}], ["KozGoPr6N-Regular", {
32818  alias: "HeiseiKakuGo-W5"
32819}], ["STSong-Light", {
32820  local: ["STSong", "Songti SC", "Source Han Serif SC", "Source Han Serif CN", "Noto Serif SC", "Noto Serif CJK SC", "AR PL UMing CN", "SimSun", "NSimSun"],
32821  style: NORMAL,
32822  ultimate: "serif"
32823}], ["STHeiti-Regular", {
32824  local: ["STHeiti", "Heiti SC", "PingFang SC", "Source Han Sans SC", "Source Han Sans CN", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", "SimHei", "WenQuanYi Zen Hei"],
32825  style: NORMAL,
32826  ultimate: "sans-serif"
32827}], ["STSongStd-Light", {
32828  alias: "STSong-Light"
32829}], ["AdobeSongStd-Light", {
32830  alias: "STSong-Light"
32831}], ["AdobeHeitiStd-Regular", {
32832  alias: "STHeiti-Regular"
32833}], ["AdobeKaitiStd-Regular", {
32834  alias: "\xBF\xAC\xCC\xE5"
32835}], ["AdobeFangsongStd-Regular", {
32836  alias: "\xB7\xC2\xCB\xCE"
32837}], ["MSung-Light", {
32838  local: ["Songti TC", "LiSong Pro", "Source Han Serif TC", "Source Han Serif TW", "Noto Serif TC", "Noto Serif CJK TC", "AR PL UMing TW", "PMingLiU", "MingLiU", "MingLiU_HKSCS"],
32839  style: NORMAL,
32840  ultimate: "serif"
32841}], ["MHei-Medium", {
32842  local: ["Heiti TC", "STHeiti", "Source Han Sans TC", "Source Han Sans TW", "Noto Sans TC", "Noto Sans CJK TC", "PingFang TC", "Microsoft JhengHei"],
32843  style: MEDIUM,
32844  ultimate: "sans-serif"
32845}], ["MSungStd-Light", {
32846  alias: "MSung-Light"
32847}], ["AdobeMingStd-Light", {
32848  alias: "MSung-Light"
32849}], ["HYSMyeongJo-Medium", {
32850  local: ["AppleMyungjo", "Source Han Serif KR", "Noto Serif KR", "Noto Serif CJK KR", "Nanum Myeongjo", "Batang"],
32851  style: MEDIUM,
32852  ultimate: "serif"
32853}], ["HYGoThic-Medium", {
32854  local: ["Apple SD Gothic Neo", "AppleGothic", "Source Han Sans KR", "Noto Sans KR", "Noto Sans CJK KR", "Nanum Gothic", "Malgun Gothic", "Dotum", "Gulim"],
32855  style: MEDIUM,
32856  ultimate: "sans-serif"
32857}], ["HYSMyeongJoStd-Medium", {
32858  alias: "HYSMyeongJo-Medium"
32859}], ["AdobeMyungjoStd-Medium", {
32860  alias: "HYSMyeongJo-Medium"
32861}], ["HYGoThic-Bold", {
32862  alias: "HYGoThic-Medium",
32863  style: BOLD
32864}], ["AdobeGothicStd-Bold", {
32865  alias: "HYGoThic-Medium",
32866  style: BOLD
32867}]]);
32868const fontAliases = new Map([["Arial-Black", "ArialBlack"]]);
32869function getStyleToAppend(style) {
32870  switch (style) {
32871    case BOLD:
32872      return "Bold";
32873    case ITALIC:
32874      return "Italic";
32875    case BOLDITALIC:
32876      return "Bold Italic";
32877    default:
32878      if (style?.weight === "bold") {
32879        return "Bold";
32880      }
32881      if (style?.style === "italic") {
32882        return "Italic";
32883      }
32884  }
32885  return "";
32886}
32887function getFamilyName(str) {
32888  const keywords = new Set(["thin", "extralight", "ultralight", "demilight", "semilight", "light", "book", "regular", "normal", "medium", "demibold", "semibold", "bold", "extrabold", "ultrabold", "black", "heavy", "extrablack", "ultrablack", "roman", "italic", "oblique", "ultracondensed", "extracondensed", "condensed", "semicondensed", "normal", "semiexpanded", "expanded", "extraexpanded", "ultraexpanded", "bolditalic"]);
32889  return str.split(/[- ,+]+/g).filter(tok => !keywords.has(tok.toLowerCase())).join(" ");
32890}
32891function generateFont({
32892  alias,
32893  local,
32894  path,
32895  fallback,
32896  style,
32897  ultimate
32898}, src, localFontPath, useFallback = true, usePath = true, append = "") {
32899  const result = {
32900    style: null,
32901    ultimate: null
32902  };
32903  if (local) {
32904    const extra = append ? ` ${append}` : "";
32905    for (const name of local) {
32906      src.push(`local(${name}${extra})`);
32907    }
32908  }
32909  if (alias) {
32910    const substitution = substitutionMap.get(alias);
32911    const aliasAppend = append || getStyleToAppend(style);
32912    Object.assign(result, generateFont(substitution, src, localFontPath, useFallback && !fallback, usePath && !path, aliasAppend));
32913  }
32914  if (style) {
32915    result.style = style;
32916  }
32917  if (ultimate) {
32918    result.ultimate = ultimate;
32919  }
32920  if (useFallback && fallback) {
32921    const fallbackInfo = substitutionMap.get(fallback);
32922    const {
32923      ultimate: fallbackUltimate
32924    } = generateFont(fallbackInfo, src, localFontPath, useFallback, usePath && !path, append);
32925    result.ultimate ||= fallbackUltimate;
32926  }
32927  if (usePath && path && localFontPath) {
32928    src.push(`url(${localFontPath}${path})`);
32929  }
32930  return result;
32931}
32932function getFontSubstitution(systemFontCache, idFactory, localFontPath, baseFontName, standardFontName, type) {
32933  if (baseFontName.startsWith("InvalidPDFjsFont_")) {
32934    return null;
32935  }
32936  if ((type === "TrueType" || type === "Type1") && /^[A-Z]{6}\+/.test(baseFontName)) {
32937    baseFontName = baseFontName.slice(7);
32938  }
32939  baseFontName = normalizeFontName(baseFontName);
32940  const key = baseFontName;
32941  let substitutionInfo = systemFontCache.get(key);
32942  if (substitutionInfo) {
32943    return substitutionInfo;
32944  }
32945  let substitution = substitutionMap.get(baseFontName);
32946  if (!substitution) {
32947    for (const [alias, subst] of fontAliases) {
32948      if (baseFontName.startsWith(alias)) {
32949        baseFontName = `${subst}${baseFontName.substring(alias.length)}`;
32950        substitution = substitutionMap.get(baseFontName);
32951        break;
32952      }
32953    }
32954  }
32955  let mustAddBaseFont = false;
32956  if (!substitution) {
32957    substitution = substitutionMap.get(standardFontName);
32958    mustAddBaseFont = true;
32959  }
32960  const loadedName = `${idFactory.getDocId()}_s${idFactory.createFontId()}`;
32961  if (!substitution) {
32962    if (!validateFontName(baseFontName)) {
32963      warn(`Cannot substitute the font because of its name: ${baseFontName}`);
32964      systemFontCache.set(key, null);
32965      return null;
32966    }
32967    const bold = /bold/i.test(baseFontName);
32968    const italic = /oblique|italic/i.test(baseFontName);
32969    const style = bold && italic && BOLDITALIC || bold && BOLD || italic && ITALIC || NORMAL;
32970    substitutionInfo = {
32971      css: `"${getFamilyName(baseFontName)}",${loadedName}`,
32972      guessFallback: true,
32973      loadedName,
32974      baseFontName,
32975      src: `local(${baseFontName})`,
32976      style
32977    };
32978    systemFontCache.set(key, substitutionInfo);
32979    return substitutionInfo;
32980  }
32981  const src = [];
32982  if (mustAddBaseFont && validateFontName(baseFontName)) {
32983    src.push(`local(${baseFontName})`);
32984  }
32985  const {
32986    style,
32987    ultimate
32988  } = generateFont(substitution, src, localFontPath);
32989  const guessFallback = ultimate === null;
32990  const fallback = guessFallback ? "" : `,${ultimate}`;
32991  substitutionInfo = {
32992    css: `"${getFamilyName(baseFontName)}",${loadedName}${fallback}`,
32993    guessFallback,
32994    loadedName,
32995    baseFontName,
32996    src: src.join(","),
32997    style
32998  };
32999  systemFontCache.set(key, substitutionInfo);
33000  return substitutionInfo;
33001}
33002
33003;// ./src/shared/murmurhash3.js
33004const SEED = 0xc3d2e1f0;
33005const MASK_HIGH = 0xffff0000;
33006const MASK_LOW = 0xffff;
33007class MurmurHash3_64 {
33008  constructor(seed) {
33009    this.h1 = seed ? seed & 0xffffffff : SEED;
33010    this.h2 = seed ? seed & 0xffffffff : SEED;
33011  }
33012  update(input) {
33013    let data, length;
33014    if (typeof input === "string") {
33015      data = new Uint8Array(input.length * 2);
33016      length = 0;
33017      for (let i = 0, ii = input.length; i < ii; i++) {
33018        const code = input.charCodeAt(i);
33019        if (code <= 0xff) {
33020          data[length++] = code;
33021        } else {
33022          data[length++] = code >>> 8;
33023          data[length++] = code & 0xff;
33024        }
33025      }
33026    } else if (ArrayBuffer.isView(input)) {
33027      data = input.slice();
33028      length = data.byteLength;
33029    } else {
33030      throw new Error("Invalid data format, must be a string or TypedArray.");
33031    }
33032    const blockCounts = length >> 2;
33033    const tailLength = length - blockCounts * 4;
33034    const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
33035    let k1 = 0,
33036      k2 = 0;
33037    let h1 = this.h1,
33038      h2 = this.h2;
33039    const C1 = 0xcc9e2d51,
33040      C2 = 0x1b873593;
33041    const C1_LOW = C1 & MASK_LOW,
33042      C2_LOW = C2 & MASK_LOW;
33043    for (let i = 0; i < blockCounts; i++) {
33044      if (i & 1) {
33045        k1 = dataUint32[i];
33046        k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
33047        k1 = k1 << 15 | k1 >>> 17;
33048        k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
33049        h1 ^= k1;
33050        h1 = h1 << 13 | h1 >>> 19;
33051        h1 = h1 * 5 + 0xe6546b64;
33052      } else {
33053        k2 = dataUint32[i];
33054        k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
33055        k2 = k2 << 15 | k2 >>> 17;
33056        k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
33057        h2 ^= k2;
33058        h2 = h2 << 13 | h2 >>> 19;
33059        h2 = h2 * 5 + 0xe6546b64;
33060      }
33061    }
33062    k1 = 0;
33063    switch (tailLength) {
33064      case 3:
33065        k1 ^= data[blockCounts * 4 + 2] << 16;
33066      case 2:
33067        k1 ^= data[blockCounts * 4 + 1] << 8;
33068      case 1:
33069        k1 ^= data[blockCounts * 4];
33070        k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
33071        k1 = k1 << 15 | k1 >>> 17;
33072        k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
33073        if (blockCounts & 1) {
33074          h1 ^= k1;
33075        } else {
33076          h2 ^= k1;
33077        }
33078    }
33079    this.h1 = h1;
33080    this.h2 = h2;
33081  }
33082  hexdigest() {
33083    let h1 = this.h1,
33084      h2 = this.h2;
33085    h1 ^= h2 >>> 1;
33086    h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
33087    h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
33088    h1 ^= h2 >>> 1;
33089    h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
33090    h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
33091    h1 ^= h2 >>> 1;
33092    return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
33093  }
33094}
33095
33096;// ./src/core/image.js
33097
33098
33099
33100
33101
33102
33103
33104
33105
33106
33107
33108class PDFImage {
33109  constructor({
33110    xref,
33111    res,
33112    image,
33113    isInline = false,
33114    smask = null,
33115    mask = null,
33116    isMask = false,
33117    pdfFunctionFactory,
33118    globalColorSpaceCache,
33119    localColorSpaceCache
33120  }) {
33121    this.image = image;
33122    const dict = image.dict;
33123    const filter = dict.get("F", "Filter");
33124    let filterName;
33125    if (filter instanceof Name) {
33126      filterName = filter.name;
33127    } else if (Array.isArray(filter)) {
33128      const filterZero = xref.fetchIfRef(filter[0]);
33129      if (filterZero instanceof Name) {
33130        filterName = filterZero.name;
33131      }
33132    }
33133    switch (filterName) {
33134      case "JPXDecode":
33135        ({
33136          width: image.width,
33137          height: image.height,
33138          componentsCount: image.numComps,
33139          bitsPerComponent: image.bitsPerComponent
33140        } = JpxImage.parseImageProperties(image.stream));
33141        image.stream.reset();
33142        const reducePower = ImageResizer.getReducePowerForJPX(image.width, image.height, image.numComps);
33143        this.jpxDecoderOptions = {
33144          numComponents: 0,
33145          isIndexedColormap: false,
33146          smaskInData: dict.
vendor: 2,121 bytes, lines 33146-33201
33146has("SMaskInData"),
33147          reducePower
33148        };
33149        if (reducePower) {
33150          const factor = 2 ** reducePower;
33151          image.width = Math.ceil(image.width / factor);
33152          image.height = Math.ceil(image.height / factor);
33153        }
33154        break;
33155      case "JBIG2Decode":
33156        image.bitsPerComponent = 1;
33157        image.numComps = 1;
33158        break;
33159    }
33160    let width = dict.get("W", "Width");
33161    let height = dict.get("H", "Height");
33162    if (Number.isInteger(image.width) && image.width > 0 && Number.isInteger(image.height) && image.height > 0 && (image.width !== width || image.height !== height)) {
33163      warn("PDFImage - using the Width/Height of the image data, " + "rather than the image dictionary.");
33164      width = image.width;
33165      height = image.height;
33166    } else {
33167      const validWidth = typeof width === "number" && width > 0,
33168        validHeight = typeof height === "number" && height > 0;
33169      if (!validWidth || !validHeight) {
33170        if (!image.fallbackDims) {
33171          throw new FormatError(`Invalid image width: ${width} or height: ${height}`);
33172        }
33173        warn("PDFImage - using the Width/Height of the parent image, for SMask/Mask data.");
33174        if (!validWidth) {
33175          width = image.fallbackDims.width;
33176        }
33177        if (!validHeight) {
33178          height = image.fallbackDims.height;
33179        }
33180      }
33181    }
33182    this.width = width;
33183    this.height = height;
33184    this.interpolate = dict.get("I", "Interpolate");
33185    this.imageMask = dict.get("IM", "ImageMask") || false;
33186    this.matte = dict.get("Matte") || false;
33187    let bitsPerComponent = image.bitsPerComponent;
33188    if (!bitsPerComponent) {
33189      bitsPerComponent = dict.get("BPC", "BitsPerComponent");
33190      if (!bitsPerComponent) {
33191        if (this.imageMask) {
33192          bitsPerComponent = 1;
33193        } else {
33194          throw new FormatError(`Bits per component missing in image: ${this.imageMask}`);
33195        }
33196      }
33197    }
33198    this.bpc = bitsPerComponent;
33199    if (!this.imageMask) {
33200      let colorSpace = dict.getRaw("CS") || dict.getRaw("ColorSpace");
33201      const hasColorSpace = !!colorSpace;
vendor: 8,738 bytes, lines 33201-33507
33201
33202      if (!hasColorSpace) {
33203        if (this.jpxDecoderOptions) {
33204          colorSpace = Name.get("DeviceRGBA");
33205        } else {
33206          switch (image.numComps) {
33207            case 1:
33208              colorSpace = Name.get("DeviceGray");
33209              break;
33210            case 3:
33211              colorSpace = Name.get("DeviceRGB");
33212              break;
33213            case 4:
33214              colorSpace = Name.get("DeviceCMYK");
33215              break;
33216            default:
33217              throw new Error(`Images with ${image.numComps} color components not supported.`);
33218          }
33219        }
33220      } else if (this.jpxDecoderOptions?.smaskInData) {
33221        colorSpace = Name.get("DeviceRGBA");
33222      }
33223      this.colorSpace = ColorSpaceUtils.parse({
33224        cs: colorSpace,
33225        xref,
33226        resources: isInline ? res : null,
33227        pdfFunctionFactory,
33228        globalColorSpaceCache,
33229        localColorSpaceCache
33230      });
33231      this.numComps = this.colorSpace.numComps;
33232      if (this.jpxDecoderOptions) {
33233        this.jpxDecoderOptions.numComponents = hasColorSpace ? this.numComps : 0;
33234        this.jpxDecoderOptions.isIndexedColormap = this.colorSpace.name === "Indexed";
33235      }
33236    } else {
33237      this.numComps = 1;
33238    }
33239    this.decode = dict.getArray("D", "Decode");
33240    this.needsDecode = false;
33241    if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode, bitsPerComponent) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
33242      this.needsDecode = true;
33243      const max = (1 << bitsPerComponent) - 1;
33244      this.decodeCoefficients = [];
33245      this.decodeAddends = [];
33246      const isIndexed = this.colorSpace?.name === "Indexed";
33247      for (let i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
33248        const dmin = this.decode[i];
33249        const dmax = this.decode[i + 1];
33250        this.decodeCoefficients[j] = isIndexed ? (dmax - dmin) / max : dmax - dmin;
33251        this.decodeAddends[j] = isIndexed ? dmin : max * dmin;
33252      }
33253    }
33254    if (smask) {
33255      smask.fallbackDims ??= {
33256        width,
33257        height
33258      };
33259      this.smask = new PDFImage({
33260        xref,
33261        res,
33262        image: smask,
33263        isInline,
33264        pdfFunctionFactory,
33265        globalColorSpaceCache,
33266        localColorSpaceCache
33267      });
33268    } else if (mask) {
33269      if (mask instanceof BaseStream) {
33270        const maskDict = mask.dict,
33271          imageMask = maskDict.get("IM", "ImageMask");
33272        if (!imageMask) {
33273          warn("Ignoring /Mask in image without /ImageMask.");
33274        } else {
33275          mask.fallbackDims ??= {
33276            width,
33277            height
33278          };
33279          this.mask = new PDFImage({
33280            xref,
33281            res,
33282            image: mask,
33283            isInline,
33284            isMask: true,
33285            pdfFunctionFactory,
33286            globalColorSpaceCache,
33287            localColorSpaceCache
33288          });
33289        }
33290      } else {
33291        this.mask = mask;
33292      }
33293    }
33294  }
33295  static async buildImage({
33296    xref,
33297    res,
33298    image,
33299    isInline = false,
33300    pdfFunctionFactory,
33301    globalColorSpaceCache,
33302    localColorSpaceCache
33303  }) {
33304    const imageData = image;
33305    let smaskData = null;
33306    let maskData = null;
33307    const smask = image.dict.get("SMask");
33308    const mask = image.dict.get("Mask");
33309    if (smask) {
33310      if (smask instanceof BaseStream) {
33311        smaskData = smask;
33312      } else {
33313        warn("Unsupported /SMask format.");
33314      }
33315    } else if (mask) {
33316      if (mask instanceof BaseStream || Array.isArray(mask)) {
33317        maskData = mask;
33318      } else {
33319        warn("Unsupported /Mask format.");
33320      }
33321    }
33322    return new PDFImage({
33323      xref,
33324      res,
33325      image: imageData,
33326      isInline,
33327      smask: smaskData,
33328      mask: maskData,
33329      pdfFunctionFactory,
33330      globalColorSpaceCache,
33331      localColorSpaceCache
33332    });
33333  }
33334  static async createMask({
33335    image,
33336    isOffscreenCanvasSupported = false
33337  }) {
33338    const {
33339      dict
33340    } = image;
33341    const width = dict.get("W", "Width");
33342    const height = dict.get("H", "Height");
33343    const interpolate = dict.get("I", "Interpolate");
33344    const decode = dict.getArray("D", "Decode");
33345    const inverseDecode = decode?.[0] > 0;
33346    const computedLength = (width + 7 >> 3) * height;
33347    const imgArray = await image.getImageData(computedLength);
33348    const isSingleOpaquePixel = width === 1 && height === 1 && inverseDecode === (imgArray.length === 0 || !!(imgArray[0] & 128));
33349    if (isSingleOpaquePixel) {
33350      return {
33351        isSingleOpaquePixel
33352      };
33353    }
33354    if (isOffscreenCanvasSupported) {
33355      if (ImageResizer.needsToBeResized(width, height)) {
33356        const data = new Uint8ClampedArray(width * height * 4);
33357        convertBlackAndWhiteToRGBA({
33358          src: imgArray,
33359          dest: data,
33360          width,
33361          height,
33362          nonBlackColor: 0,
33363          inverseDecode
33364        });
33365        return ImageResizer.createImage({
33366          kind: ImageKind.RGBA_32BPP,
33367          data,
33368          width,
33369          height,
33370          interpolate
33371        });
33372      }
33373      const canvas = new OffscreenCanvas(width, height);
33374      const ctx = canvas.getContext("2d");
33375      const imgData = ctx.createImageData(width, height);
33376      convertBlackAndWhiteToRGBA({
33377        src: imgArray,
33378        dest: imgData.data,
33379        width,
33380        height,
33381        nonBlackColor: 0,
33382        inverseDecode
33383      });
33384      ctx.putImageData(imgData, 0, 0);
33385      const bitmap = canvas.transferToImageBitmap();
33386      return {
33387        data: null,
33388        width,
33389        height,
33390        interpolate,
33391        bitmap
33392      };
33393    }
33394    const actualLength = imgArray.byteLength;
33395    const haveFullData = computedLength === actualLength;
33396    let data;
33397    if (image instanceof DecodeStream && (!inverseDecode || haveFullData)) {
33398      data = imgArray;
33399    } else if (!inverseDecode) {
33400      data = new Uint8Array(imgArray);
33401    } else {
33402      data = new Uint8Array(computedLength);
33403      data.set(imgArray);
33404      data.fill(0xff, actualLength);
33405    }
33406    if (inverseDecode) {
33407      for (let i = 0; i < actualLength; i++) {
33408        data[i] ^= 0xff;
33409      }
33410    }
33411    return {
33412      data,
33413      width,
33414      height,
33415      interpolate
33416    };
33417  }
33418  get drawWidth() {
33419    return Math.max(this.width, this.smask?.width || 0, this.mask?.width || 0);
33420  }
33421  get drawHeight() {
33422    return Math.max(this.height, this.smask?.height || 0, this.mask?.height || 0);
33423  }
33424  decodeBuffer(buffer) {
33425    const bpc = this.bpc;
33426    const numComps = this.numComps;
33427    const decodeAddends = this.decodeAddends;
33428    const decodeCoefficients = this.decodeCoefficients;
33429    const max = (1 << bpc) - 1;
33430    let i, ii;
33431    if (bpc === 1) {
33432      for (i = 0, ii = buffer.length; i < ii; i++) {
33433        buffer[i] = +!buffer[i];
33434      }
33435      return;
33436    }
33437    let index = 0;
33438    for (i = 0, ii = this.width * this.height; i < ii; i++) {
33439      for (let j = 0; j < numComps; j++) {
33440        buffer[index] = MathClamp(decodeAddends[j] + buffer[index] * decodeCoefficients[j], 0, max);
33441        index++;
33442      }
33443    }
33444  }
33445  getComponents(buffer) {
33446    const bpc = this.bpc;
33447    if (bpc === 8) {
33448      return buffer;
33449    }
33450    const width = this.width;
33451    const height = this.height;
33452    const numComps = this.numComps;
33453    const length = width * height * numComps;
33454    let bufferPos = 0;
33455    let output;
33456    if (bpc <= 8) {
33457      output = new Uint8Array(length);
33458    } else if (bpc <= 16) {
33459      output = new Uint16Array(length);
33460    } else {
33461      output = new Uint32Array(length);
33462    }
33463    const rowComps = width * numComps;
33464    const max = (1 << bpc) - 1;
33465    let i = 0,
33466      ii,
33467      buf;
33468    if (bpc === 1) {
33469      let mask, loop1End, loop2End;
33470      for (let j = 0; j < height; j++) {
33471        loop1End = i + (rowComps & ~7);
33472        loop2End = i + rowComps;
33473        while (i < loop1End) {
33474          buf = buffer[bufferPos++];
33475          output[i] = buf >> 7 & 1;
33476          output[i + 1] = buf >> 6 & 1;
33477          output[i + 2] = buf >> 5 & 1;
33478          output[i + 3] = buf >> 4 & 1;
33479          output[i + 4] = buf >> 3 & 1;
33480          output[i + 5] = buf >> 2 & 1;
33481          output[i + 6] = buf >> 1 & 1;
33482          output[i + 7] = buf & 1;
33483          i += 8;
33484        }
33485        if (i < loop2End) {
33486          buf = buffer[bufferPos++];
33487          mask = 128;
33488          while (i < loop2End) {
33489            output[i++] = +!!(buf & mask);
33490            mask >>= 1;
33491          }
33492        }
33493      }
33494    } else {
33495      let bits = 0;
33496      buf = 0;
33497      for (i = 0, ii = length; i < ii; ++i) {
33498        if (i % rowComps === 0) {
33499          buf = 0;
33500          bits = 0;
33501        }
33502        while (bits < bpc) {
33503          buf = buf << 8 | buffer[bufferPos++];
33504          bits += 8;
33505        }
33506        const remainingBits = bits - bpc;
33507        
33507let value = buf >> remainingBits;
33508        if (value < 0) {
33509          value = 0;
33510        } else if (value > max) {
33511          value = max;
33512        }
33513        output[i] = value;
33514        buf &= (1 << remainingBits) - 1;
33515        bits = remainingBits;
33516      }
33517    }
33518    return output;
33519  }
33520  async fillOpacity(rgbaBuf, width, height, actualHeight, image) {
33521    let apply;
33522    if (this.smask) {
33523      apply = (buffer, options) => this.smask.fillGrayBuffer(buffer, {
33524        ...options,
33525        destWidth: width,
33526        destHeight: height
33527      });
33528    } else if (this.mask) {
33529      if (this.mask instanceof PDFImage) {
33530        apply = (buffer, options) => this.mask.fillGrayBuffer(buffer, {
33531          ...options,
33532          invertOutput: true,
33533          destWidth: width,
33534          destHeight: height
33535        });
33536      } else if (Array.isArray(this.mask)) {
33537        apply = (buffer, {
33538          maxRows,
33539          offset,
33540          stride
33541        }) => {
33542          for (let i = 0, ii = width * maxRows; i < ii; ++i) {
33543            let opacity = 0;
33544            const imageOffset = i * this.numComps;
33545            for (let j = 0; j < this.numComps; ++j) {
33546              const color = image[imageOffset + j];
33547              const maskOffset = j * 2;
33548              if (color < this.mask[maskOffset] || color > this.mask[maskOffset + 1]) {
33549                opacity = 255;
33550                break;
33551              }
33552            }
33553            buffer[i * stride + offset] = opacity;
33554          }
33555        };
33556      } else {
33557        throw new FormatError("Unknown mask format.");
33558      }
33559    } else {
33560      apply = (buffer, {
33561        maxRows,
33562        offset,
33563        stride
33564      }) => {
33565        for (let i = 0, ii = width * maxRows; i < ii; ++i) {
33566          buffer[i * stride + offset] = 255;
33567        }
33568      };
33569    }
33570    await apply(rgbaBuf, {
33571      maxRows: actualHeight,
33572      offset: 3,
vendor: 5,378 bytes, lines 33573-33723
33573      stride: 4
33574    });
33575  }
33576  undoPreblend(buffer, width, height) {
33577    const matte = this.smask?.matte;
33578    if (!matte) {
33579      return;
33580    }
33581    const matteRgb = this.colorSpace.getRgb(matte, 0);
33582    const matteR = matteRgb[0];
33583    const matteG = matteRgb[1];
33584    const matteB = matteRgb[2];
33585    const length = width * height * 4;
33586    for (let i = 0; i < length; i += 4) {
33587      const alpha = buffer[i + 3];
33588      if (alpha === 0) {
33589        buffer[i] = 255;
33590        buffer[i + 1] = 255;
33591        buffer[i + 2] = 255;
33592        continue;
33593      }
33594      const k = 255 / alpha;
33595      buffer[i] = (buffer[i] - matteR) * k + matteR;
33596      buffer[i + 1] = (buffer[i + 1] - matteG) * k + matteG;
33597      buffer[i + 2] = (buffer[i + 2] - matteB) * k + matteB;
33598    }
33599  }
33600  async createImageData(forceRGBA = false, isOffscreenCanvasSupported = false) {
33601    const drawWidth = this.drawWidth;
33602    const drawHeight = this.drawHeight;
33603    const imgData = {
33604      width: drawWidth,
33605      height: drawHeight,
33606      interpolate: this.interpolate,
33607      kind: 0,
33608      data: null
33609    };
33610    const numComps = this.numComps;
33611    const originalWidth = this.width;
33612    const originalHeight = this.height;
33613    const bpc = this.bpc;
33614    const rowBytes = originalWidth * numComps * bpc + 7 >> 3;
33615    const mustBeResized = isOffscreenCanvasSupported && ImageResizer.needsToBeResized(drawWidth, drawHeight);
33616    if (!this.smask && !this.mask && this.colorSpace.name === "DeviceRGBA") {
33617      imgData.kind = ImageKind.RGBA_32BPP;
33618      const imgArray = imgData.data = await this.getImageBytes(originalHeight * originalWidth * 4, {
33619        internal: isOffscreenCanvasSupported && mustBeResized
33620      });
33621      if (isOffscreenCanvasSupported) {
33622        if (!mustBeResized) {
33623          return this.createBitmap(ImageKind.RGBA_32BPP, drawWidth, drawHeight, imgArray);
33624        }
33625        return ImageResizer.createImage(imgData, false);
33626      }
33627      return imgData;
33628    }
33629    if (!forceRGBA) {
33630      let kind;
33631      if (this.colorSpace.name === "DeviceGray" && bpc === 1) {
33632        kind = ImageKind.GRAYSCALE_1BPP;
33633      } else if (this.colorSpace.name === "DeviceRGB" && bpc === 8 && !this.needsDecode) {
33634        kind = ImageKind.RGB_24BPP;
33635      }
33636      if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
33637        const image = await this.#getImage(originalWidth, originalHeight);
33638        if (image) {
33639          return image;
33640        }
33641        const data = await this.getImageBytes(originalHeight * rowBytes, {
33642          internal: isOffscreenCanvasSupported && mustBeResized
33643        });
33644        if (isOffscreenCanvasSupported) {
33645          if (mustBeResized) {
33646            return ImageResizer.createImage({
33647              data,
33648              kind,
33649              width: drawWidth,
33650              height: drawHeight,
33651              interpolate: this.interpolate
33652            }, this.needsDecode);
33653          }
33654          return this.createBitmap(kind, originalWidth, originalHeight, data);
33655        }
33656        imgData.kind = kind;
33657        imgData.data = data;
33658        if (this.needsDecode) {
33659          assert(kind === ImageKind.GRAYSCALE_1BPP, "PDFImage.createImageData: The image must be grayscale.");
33660          const buffer = imgData.data;
33661          for (let i = 0, ii = buffer.length; i < ii; i++) {
33662            buffer[i] ^= 0xff;
33663          }
33664        }
33665        return imgData;
33666      }
33667      if (this.image instanceof JpegStream && !this.smask && !this.mask && !this.needsDecode) {
33668        let imageLength = originalHeight * rowBytes;
33669        if (isOffscreenCanvasSupported && !mustBeResized) {
33670          let isHandled = false;
33671          switch (this.colorSpace.name) {
33672            case "DeviceGray":
33673              imageLength *= 4;
33674              isHandled = true;
33675              break;
33676            case "DeviceRGB":
33677              imageLength = imageLength / 3 * 4;
33678              isHandled = true;
33679              break;
33680            case "DeviceCMYK":
33681              isHandled = true;
33682              break;
33683          }
33684          if (isHandled) {
33685            const image = await this.#getImage(drawWidth, drawHeight);
33686            if (image) {
33687              return image;
33688            }
33689            const rgba = await this.getImageBytes(imageLength, {
33690              drawWidth,
33691              drawHeight,
33692              forceRGBA: true,
33693              internal: true
33694            });
33695            return this.createBitmap(ImageKind.RGBA_32BPP, drawWidth, drawHeight, rgba);
33696          }
33697        } else {
33698          switch (this.colorSpace.name) {
33699            case "DeviceGray":
33700              imageLength *= 3;
33701            case "DeviceRGB":
33702            case "DeviceCMYK":
33703              imgData.kind = ImageKind.RGB_24BPP;
33704              imgData.data = await this.getImageBytes(imageLength, {
33705                drawWidth,
33706                drawHeight,
33707                forceRGB: true,
33708                internal: mustBeResized
33709              });
33710              if (mustBeResized) {
33711                return ImageResizer.createImage(imgData);
33712              }
33713              return imgData;
33714          }
33715        }
33716      }
33717    }
33718    const imgArray = await this.getImageBytes(originalHeight * rowBytes, {
33719      internal: true
33720    });
33721    const actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
33722    const comps = this.getComponents(imgArray);
33723    let alpha01, maybeUndoPreblend;
vendor: 8,477 bytes, lines 33724-34039
33724    let canvas, ctx, canvasImgData, data;
33725    if (isOffscreenCanvasSupported && !mustBeResized) {
33726      canvas = new OffscreenCanvas(drawWidth, drawHeight);
33727      ctx = canvas.getContext("2d");
33728      canvasImgData = ctx.createImageData(drawWidth, drawHeight);
33729      data = canvasImgData.data;
33730    }
33731    imgData.kind = ImageKind.RGBA_32BPP;
33732    if (!forceRGBA && !this.smask && !this.mask) {
33733      if (!isOffscreenCanvasSupported || mustBeResized) {
33734        imgData.kind = ImageKind.RGB_24BPP;
33735        data = new Uint8ClampedArray(drawWidth * drawHeight * 3);
33736        alpha01 = 0;
33737      } else {
33738        const arr = new Uint32Array(data.buffer);
33739        arr.fill(FeatureTest.isLittleEndian ? 0xff000000 : 0x000000ff);
33740        alpha01 = 1;
33741      }
33742      maybeUndoPreblend = false;
33743    } else {
33744      if (!isOffscreenCanvasSupported || mustBeResized) {
33745        data = new Uint8ClampedArray(drawWidth * drawHeight * 4);
33746      }
33747      alpha01 = 1;
33748      maybeUndoPreblend = true;
33749      await this.fillOpacity(data, drawWidth, drawHeight, actualHeight, comps);
33750    }
33751    if (this.needsDecode) {
33752      this.decodeBuffer(comps);
33753    }
33754    this.colorSpace.fillRgb(data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
33755    if (maybeUndoPreblend) {
33756      this.undoPreblend(data, drawWidth, actualHeight);
33757    }
33758    if (isOffscreenCanvasSupported && !mustBeResized) {
33759      ctx.putImageData(canvasImgData, 0, 0);
33760      const bitmap = canvas.transferToImageBitmap();
33761      return {
33762        data: null,
33763        width: drawWidth,
33764        height: drawHeight,
33765        bitmap,
33766        interpolate: this.interpolate
33767      };
33768    }
33769    imgData.data = data;
33770    if (mustBeResized) {
33771      return ImageResizer.createImage(imgData);
33772    }
33773    return imgData;
33774  }
33775  async fillGrayBuffer(buffer, {
33776    destWidth,
33777    destHeight,
33778    invertOutput,
33779    maxRows,
33780    offset = 0,
33781    stride = 1
33782  } = {}) {
33783    const numComps = this.numComps;
33784    if (numComps !== 1) {
33785      throw new FormatError(`Reading gray scale from a color image: ${numComps}`);
33786    }
33787    const srcWidth = this.width;
33788    const srcHeight = this.height;
33789    const bpc = this.bpc;
33790    const rowBytes = srcWidth * numComps * bpc + 7 >> 3;
33791    const imgArray = await this.getImageBytes(srcHeight * rowBytes, {
33792      internal: true
33793    });
33794    const comps = this.getComponents(imgArray);
33795    const resolvedDestWidth = destWidth ?? srcWidth;
33796    const resolvedDestHeight = destHeight ?? srcHeight;
33797    const needsResampling = resolvedDestWidth !== srcWidth || resolvedDestHeight !== srcHeight;
33798    const rows = maxRows === undefined ? resolvedDestHeight : Math.min(resolvedDestHeight, maxRows);
33799    let outputWidth = srcWidth;
33800    let yRatio = 0;
33801    let xScaled = null;
33802    if (needsResampling) {
33803      outputWidth = resolvedDestWidth;
33804      yRatio = srcHeight / resolvedDestHeight;
33805      const xRatio = srcWidth / resolvedDestWidth;
33806      xScaled = new Uint32Array(resolvedDestWidth);
33807      for (let i = 0; i < resolvedDestWidth; i++) {
33808        xScaled[i] = Math.floor(i * xRatio);
33809      }
33810    }
33811    const mask = invertOutput ? 0xff : 0;
33812    if (bpc === 1) {
33813      if (xScaled) {
33814        const xMap = xScaled;
33815        let destIndex = offset;
33816        if (this.needsDecode) {
33817          for (let row = 0; row < rows; row++) {
33818            const py = Math.floor(row * yRatio) * srcWidth;
33819            for (let col = 0; col < outputWidth; col++) {
33820              buffer[destIndex] = comps[py + xMap[col]] - 1 & 255 ^ mask;
33821              destIndex += stride;
33822            }
33823          }
33824        } else {
33825          for (let row = 0; row < rows; row++) {
33826            const py = Math.floor(row * yRatio) * srcWidth;
33827            for (let col = 0; col < outputWidth; col++) {
33828              buffer[destIndex] = -comps[py + xMap[col]] & 255 ^ mask;
33829              destIndex += stride;
33830            }
33831          }
33832        }
33833      } else {
33834        const length = outputWidth * rows;
33835        if (this.needsDecode) {
33836          for (let i = 0; i < length; ++i) {
33837            buffer[i * stride + offset] = comps[i] - 1 & 255 ^ mask;
33838          }
33839        } else {
33840          for (let i = 0; i < length; ++i) {
33841            buffer[i * stride + offset] = -comps[i] & 255 ^ mask;
33842          }
33843        }
33844      }
33845      return;
33846    }
33847    if (this.needsDecode) {
33848      this.decodeBuffer(comps);
33849    }
33850    const scale = 255 / ((1 << bpc) - 1);
33851    if (xScaled) {
33852      const xMap = xScaled;
33853      let destIndex = offset;
33854      for (let row = 0; row < rows; row++) {
33855        const py = Math.floor(row * yRatio) * srcWidth;
33856        for (let col = 0; col < outputWidth; col++) {
33857          buffer[destIndex] = scale * comps[py + xMap[col]] ^ mask;
33858          destIndex += stride;
33859        }
33860      }
33861    } else {
33862      const length = outputWidth * rows;
33863      for (let i = 0; i < length; ++i) {
33864        buffer[i * stride + offset] = scale * comps[i] ^ mask;
33865      }
33866    }
33867  }
33868  createBitmap(kind, width, height, src) {
33869    const canvas = new OffscreenCanvas(width, height);
33870    const ctx = canvas.getContext("2d");
33871    let imgData;
33872    if (kind === ImageKind.RGBA_32BPP) {
33873      imgData = new ImageData(src, width, height);
33874    } else {
33875      imgData = ctx.createImageData(width, height);
33876      convertToRGBA({
33877        kind,
33878        src,
33879        dest: new Uint32Array(imgData.data.buffer),
33880        width,
33881        height,
33882        inverseDecode: this.needsDecode
33883      });
33884    }
33885    ctx.putImageData(imgData, 0, 0);
33886    const bitmap = canvas.transferToImageBitmap();
33887    return {
33888      data: null,
33889      width,
33890      height,
33891      bitmap,
33892      interpolate: this.interpolate
33893    };
33894  }
33895  async #getImage(width, height) {
33896    const bitmap = await this.image.getTransferableImage();
33897    if (!bitmap) {
33898      return null;
33899    }
33900    return {
33901      data: null,
33902      width,
33903      height,
33904      bitmap,
33905      interpolate: this.interpolate
33906    };
33907  }
33908  async getImageBytes(length, {
33909    drawWidth,
33910    drawHeight,
33911    forceRGBA = false,
33912    forceRGB = false,
33913    internal = false
33914  }) {
33915    this.image.reset();
33916    this.image.drawWidth = drawWidth || this.width;
33917    this.image.drawHeight = drawHeight || this.height;
33918    this.image.forceRGBA = !!forceRGBA;
33919    this.image.forceRGB = !!forceRGB;
33920    const imageBytes = await this.image.getImageData(length, this.jpxDecoderOptions);
33921    if (internal || this.image instanceof DecodeStream) {
33922      return imageBytes;
33923    }
33924    assert(imageBytes instanceof Uint8Array, 'PDFImage.getImageBytes: Unsupported "imageBytes" type.');
33925    return new Uint8Array(imageBytes);
33926  }
33927}
33928
33929;// ./src/core/evaluator.js
33930
33931
33932
33933
33934
33935
33936
33937
33938
33939
33940
33941
33942
33943
33944
33945
33946
33947
33948
33949
33950
33951
33952
33953
33954
33955
33956
33957
33958
33959const DefaultPartialEvaluatorOptions = Object.freeze({
33960  maxImageSize: -1,
33961  disableFontFace: false,
33962  ignoreErrors: false,
33963  isOffscreenCanvasSupported: false,
33964  isImageDecoderSupported: false,
33965  canvasMaxAreaInBytes: -1,
33966  fontExtraProperties: false,
33967  useSystemFonts: true,
33968  useWasm: true,
33969  useWorkerFetch: true,
33970  cMapUrl: null,
33971  cMapPacked: true,
33972  iccUrl: null,
33973  standardFontDataUrl: null,
33974  wasmUrl: null,
33975  hasGPU: false
33976});
33977const PatternType = {
33978  TILING: 1,
33979  SHADING: 2
33980};
33981const TEXT_CHUNK_BATCH_SIZE = 10;
33982const deferred = Promise.resolve();
33983function normalizeBlendMode(value, parsingArray = false) {
33984  if (Array.isArray(value)) {
33985    for (const val of value) {
33986      const maybeBM = normalizeBlendMode(val, true);
33987      if (maybeBM) {
33988        return maybeBM;
33989      }
33990    }
33991    warn(`Unsupported blend mode Array: ${value}`);
33992    return "source-over";
33993  }
33994  if (!(value instanceof Name)) {
33995    if (parsingArray) {
33996      return null;
33997    }
33998    return "source-over";
33999  }
34000  switch (value.name) {
34001    case "Normal":
34002    case "Compatible":
34003      return "source-over";
34004    case "Multiply":
34005      return "multiply";
34006    case "Screen":
34007      return "screen";
34008    case "Overlay":
34009      return "overlay";
34010    case "Darken":
34011      return "darken";
34012    case "Lighten":
34013      return "lighten";
34014    case "ColorDodge":
34015      return "color-dodge";
34016    case "ColorBurn":
34017      return "color-burn";
34018    case "HardLight":
34019      return "hard-light";
34020    case "SoftLight":
34021      return "soft-light";
34022    case "Difference":
34023      return "difference";
34024    case "Exclusion":
34025      return "exclusion";
34026    case "Hue":
34027      return "hue";
34028    case "Saturation":
34029      return "saturation";
34030    case "Color":
34031      return "color";
34032    case "Luminosity":
34033      return "luminosity";
34034  }
34035  if (parsingArray) {
34036    return null;
34037  }
34038  warn(`Unsupported blend mode: ${value.name}`);
34039  return
vendor: 16,037 bytes, lines 34039-34547
34039 "source-over";
34040}
34041function addCachedImageOps(opList, {
34042  objId,
34043  fn,
34044  args,
34045  optionalContent,
34046  hasMask
34047}) {
34048  if (objId) {
34049    opList.addDependency(objId);
34050  }
34051  opList.addImageOps(fn, args, optionalContent, hasMask);
34052  if (fn === OPS.paintImageMaskXObject && args[0]?.count > 0) {
34053    args[0].count++;
34054  }
34055}
34056class TimeSlotManager {
34057  static TIME_SLOT_DURATION_MS = 20;
34058  static CHECK_TIME_EVERY = 100;
34059  constructor() {
34060    this.reset();
34061  }
34062  check() {
34063    if (++this.checked < TimeSlotManager.CHECK_TIME_EVERY) {
34064      return false;
34065    }
34066    this.checked = 0;
34067    return this.endTime <= Date.now();
34068  }
34069  reset() {
34070    this.endTime = Date.now() + TimeSlotManager.TIME_SLOT_DURATION_MS;
34071    this.checked = 0;
34072  }
34073}
34074class PartialEvaluator {
34075  constructor({
34076    xref,
34077    handler,
34078    pageIndex,
34079    idFactory,
34080    fontCache,
34081    builtInCMapCache,
34082    standardFontDataCache,
34083    globalColorSpaceCache,
34084    globalImageCache,
34085    systemFontCache,
34086    options = null
34087  }) {
34088    this.xref = xref;
34089    this.handler = handler;
34090    this.pageIndex = pageIndex;
34091    this.idFactory = idFactory;
34092    this.fontCache = fontCache;
34093    this.builtInCMapCache = builtInCMapCache;
34094    this.standardFontDataCache = standardFontDataCache;
34095    this.globalColorSpaceCache = globalColorSpaceCache;
34096    this.globalImageCache = globalImageCache;
34097    this.systemFontCache = systemFontCache;
34098    this.options = options || DefaultPartialEvaluatorOptions;
34099    this.type3FontRefs = null;
34100    this._regionalImageCache = new RegionalImageCache();
34101    this._fetchBuiltInCMapBound = this.fetchBuiltInCMap.bind(this);
34102  }
34103  get _pdfFunctionFactory() {
34104    return shadow(this, "_pdfFunctionFactory", new PDFFunctionFactory({
34105      xref: this.xref
34106    }));
34107  }
34108  get parsingType3Font() {
34109    return !!this.type3FontRefs;
34110  }
34111  clone(newOptions = null) {
34112    const newEvaluator = Object.create(this);
34113    newEvaluator.options = Object.assign(Object.create(null), this.options, newOptions);
34114    return newEvaluator;
34115  }
34116  hasBlendModes(resources, nonBlendModesSet) {
34117    if (!(resources instanceof Dict)) {
34118      return false;
34119    }
34120    if (resources.objId && nonBlendModesSet.has(resources.objId)) {
34121      return false;
34122    }
34123    const processed = new RefSet(nonBlendModesSet);
34124    if (resources.objId) {
34125      processed.put(resources.objId);
34126    }
34127    const nodes = [resources],
34128      xref = this.xref;
34129    while (nodes.length) {
34130      const node = nodes.shift();
34131      const graphicStates = node.get("ExtGState");
34132      if (graphicStates instanceof Dict) {
34133        for (let graphicState of graphicStates.getRawValues()) {
34134          if (graphicState instanceof Ref) {
34135            if (processed.has(graphicState)) {
34136              continue;
34137            }
34138            try {
34139              graphicState = xref.fetch(graphicState);
34140            } catch (ex) {
34141              processed.put(graphicState);
34142              info(`hasBlendModes - ignoring ExtGState: "${ex}".`);
34143              continue;
34144            }
34145          }
34146          if (!(graphicState instanceof Dict)) {
34147            continue;
34148          }
34149          if (graphicState.objId) {
34150            processed.put(graphicState.objId);
34151          }
34152          const bm = graphicState.get("BM");
34153          if (bm instanceof Name) {
34154            if (bm.name !== "Normal") {
34155              return true;
34156            }
34157            continue;
34158          }
34159          if (bm !== undefined && Array.isArray(bm)) {
34160            for (const element of bm) {
34161              if (element instanceof Name && element.name !== "Normal") {
34162                return true;
34163              }
34164            }
34165          }
34166        }
34167      }
34168      const xObjects = node.get("XObject");
34169      if (!(xObjects instanceof Dict)) {
34170        continue;
34171      }
34172      for (let xObject of xObjects.getRawValues()) {
34173        if (xObject instanceof Ref) {
34174          if (processed.has(xObject)) {
34175            continue;
34176          }
34177          try {
34178            xObject = xref.fetch(xObject);
34179          } catch (ex) {
34180            processed.put(xObject);
34181            info(`hasBlendModes - ignoring XObject: "${ex}".`);
34182            continue;
34183          }
34184        }
34185        if (!(xObject instanceof BaseStream)) {
34186          continue;
34187        }
34188        if (xObject.dict.objId) {
34189          processed.put(xObject.dict.objId);
34190        }
34191        const xResources = xObject.dict.get("Resources");
34192        if (!(xResources instanceof Dict)) {
34193          continue;
34194        }
34195        if (xResources.objId && processed.has(xResources.objId)) {
34196          continue;
34197        }
34198        nodes.push(xResources);
34199        if (xResources.objId) {
34200          processed.put(xResources.objId);
34201        }
34202      }
34203    }
34204    for (const ref of processed) {
34205      nonBlendModesSet.put(ref);
34206    }
34207    return false;
34208  }
34209  async fetchBuiltInCMap(name) {
34210    const cachedData = this.builtInCMapCache.get(name);
34211    if (cachedData) {
34212      return cachedData;
34213    }
34214    let data;
34215    if (this.options.useWorkerFetch) {
34216      data = {
34217        cMapData: await fetchBinaryData(`${this.options.cMapUrl}${name}.bcmap`),
34218        isCompressed: true
34219      };
34220    } else {
34221      data = {
34222        cMapData: await this.handler.sendWithPromise("FetchBinaryData", {
34223          kind: "cMapUrl",
34224          filename: `${name}${this.options.cMapPacked ? ".bcmap" : ""}`
34225        }),
34226        isCompressed: this.options.cMapPacked
34227      };
34228    }
34229    this.builtInCMapCache.set(name, data);
34230    return data;
34231  }
34232  async fetchStandardFontData(name) {
34233    const cachedData = this.standardFontDataCache.get(name);
34234    if (cachedData) {
34235      return new Stream(cachedData);
34236    }
34237    if (this.options.useSystemFonts && name !== "Symbol" && name !== "ZapfDingbats") {
34238      return null;
34239    }
34240    const standardFontNameToFileName = getFontNameToFileMap(),
34241      filename = standardFontNameToFileName[name];
34242    let data;
34243    try {
34244      if (this.options.useWorkerFetch) {
34245        data = await fetchBinaryData(`${this.options.standardFontDataUrl}${filename}`);
34246      } else {
34247        data = await this.handler.sendWithPromise("FetchBinaryData", {
34248          kind: "standardFontDataUrl",
34249          filename
34250        });
34251      }
34252    } catch (ex) {
34253      warn(ex);
34254      return null;
34255    }
34256    this.standardFontDataCache.set(name, data);
34257    return new Stream(data);
34258  }
34259  async buildFormXObject(resources, xobj, smask, operatorList, task, initialState, localColorSpaceCache, seenRefs) {
34260    const {
34261      dict
34262    } = xobj;
34263    const matrix = lookupMatrix(dict.getArray("Matrix"), null);
34264    const bbox = lookupNormalRect(dict.getArray("BBox"), null);
34265    let f32bbox = bbox && new Float32Array(bbox);
34266    if (f32bbox?.some(x => !isFinite(x))) {
34267      f32bbox = null;
34268    }
34269    let optionalContent, groupOptions;
34270    if (dict.has("OC")) {
34271      optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources);
34272    }
34273    if (optionalContent !== undefined) {
34274      operatorList.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]);
34275    }
34276    const group = dict.get("Group");
34277    let newOpList;
34278    const f32matrix = matrix && new Float32Array(matrix);
34279    const args = [f32matrix, !group && f32bbox || null];
34280    const localResources = dict.get("Resources");
34281    if (group) {
34282      groupOptions = {
34283        matrix,
34284        bbox: f32bbox,
34285        smask,
34286        isolated: false,
34287        knockout: false,
34288        needsIsolation: false,
34289        hasSoftMask: false,
34290        isGray: false
34291      };
34292      const groupSubtype = group.get("S");
34293      let colorSpace = null;
34294      if (isName(groupSubtype, "Transparency")) {
34295        groupOptions.isolated = group.get("I") || false;
34296        groupOptions.knockout = group.get("K") || false;
34297        if (group.has("CS")) {
34298          const cs = this._getColorSpace(group.getRaw("CS"), resources, localColorSpaceCache);
34299          colorSpace = cs instanceof ColorSpace ? cs : await this._handleColorSpace(cs);
34300        }
34301      }
34302      groupOptions.isGray = colorSpace?.numComps === 1;
34303      if (smask?.backdrop) {
34304        colorSpace ||= ColorSpaceUtils.rgb;
34305        smask.backdrop = colorSpace.getRgbHex(smask.backdrop, 0);
34306      } else if (smask?.subtype === "Luminosity") {
34307        smask.backdrop = "#000000";
34308      }
34309      newOpList = new CheckedOperatorList();
34310    } else {
34311      newOpList = operatorList;
34312      operatorList.addOp(OPS.paintFormXObjectBegin, args);
34313    }
34314    await this.getOperatorList({
34315      stream: xobj,
34316      task,
34317      resources: localResources instanceof Dict ? localResources : resources,
34318      operatorList: newOpList,
34319      initialState,
34320      prevRefs: seenRefs
34321    });
34322    if (group) {
34323      groupOptions.needsIsolation = newOpList.needsIsolation || !!smask;
34324      groupOptions.hasSoftMask = newOpList.hasSoftMask || !!smask;
34325      operatorList.addOp(OPS.beginGroup, [groupOptions]);
34326      operatorList.addOp(OPS.paintFormXObjectBegin, args);
34327      operatorList.addOpList(newOpList);
34328      operatorList.addOp(OPS.paintFormXObjectEnd, []);
34329      operatorList.addOp(OPS.endGroup, [groupOptions]);
34330    } else {
34331      operatorList.addOp(OPS.paintFormXObjectEnd, []);
34332    }
34333    if (optionalContent !== undefined) {
34334      operatorList.addOp(OPS.endMarkedContent, []);
34335    }
34336  }
34337  _sendImgData(objId, imgData, cacheGlobally = false) {
34338    const transfers = imgData ? [imgData.bitmap || imgData.data.buffer] : null;
34339    if (this.parsingType3Font || cacheGlobally) {
34340      return this.handler.send("commonobj", [objId, "Image", imgData], transfers);
34341    }
34342    return this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], transfers);
34343  }
34344  async buildPaintImageXObject({
34345    resources,
34346    image,
34347    isInline = false,
34348    operatorList,
34349    cacheKey,
34350    localImageCache,
34351    localColorSpaceCache
34352  }) {
34353    const {
34354      maxImageSize,
34355      ignoreErrors,
34356      isOffscreenCanvasSupported
34357    } = this.options;
34358    const {
34359      dict
34360    } = image;
34361    const imageRef = dict.objId;
34362    const w = dict.get("W", "Width");
34363    const h = dict.get("H", "Height");
34364    if (!(w && typeof w === "number") || !(h && typeof h === "number")) {
34365      warn("Image dimensions are missing, or not numbers.");
34366      return;
34367    }
34368    if (maxImageSize !== -1 && w * h > maxImageSize) {
34369      const msg = "Image exceeded maximum allowed size and was removed.";
34370      if (!ignoreErrors) {
34371        throw new Error(msg);
34372      }
34373      warn(msg);
34374      return;
34375    }
34376    let optionalContent;
34377    if (dict.has("OC")) {
34378      optionalContent = await this.parseMarkedContentProps(dict.get("OC"), resources);
34379    }
34380    const imageMask = dict.get("IM", "ImageMask") || false;
34381    let imgData, fn, args;
34382    if (imageMask) {
34383      imgData = await PDFImage.createMask({
34384        image,
34385        isOffscreenCanvasSupported: isOffscreenCanvasSupported && !this.parsingType3Font
34386      });
34387      if (imgData.isSingleOpaquePixel) {
34388        fn = OPS.paintSolidColorImageMask;
34389        args = [];
34390        operatorList.addImageOps(fn, args, optionalContent);
34391        if (cacheKey) {
34392          const cacheData = {
34393            fn,
34394            args,
34395            optionalContent
34396          };
34397          localImageCache.set(cacheKey, imageRef, cacheData);
34398          if (imageRef) {
34399            this._regionalImageCache.set(null, imageRef, cacheData);
34400          }
34401        }
34402        return;
34403      }
34404      if (this.parsingType3Font) {
34405        args = compileType3Glyph(imgData);
34406        if (args) {
34407          operatorList.addImageOps(OPS.constructPath, args, optionalContent);
34408          return;
34409        }
34410        warn("Cannot compile Type3 glyph.");
34411        operatorList.addImageOps(OPS.paintImageMaskXObject, [imgData], optionalContent);
34412        return;
34413      }
34414      const objId = `mask_${this.idFactory.createObjId()}`;
34415      operatorList.addDependency(objId);
34416      imgData.dataLen = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length;
34417      this._sendImgData(objId, imgData);
34418      fn = OPS.paintImageMaskXObject;
34419      args = [{
34420        data: objId,
34421        width: imgData.width,
34422        height: imgData.height,
34423        interpolate: imgData.interpolate,
34424        count: 1
34425      }];
34426      operatorList.addImageOps(fn, args, optionalContent);
34427      if (cacheKey) {
34428        const cacheData = {
34429          objId,
34430          fn,
34431          args,
34432          optionalContent
34433        };
34434        localImageCache.set(cacheKey, imageRef, cacheData);
34435        if (imageRef) {
34436          this._regionalImageCache.set(null, imageRef, cacheData);
34437        }
34438      }
34439      return;
34440    }
34441    const SMALL_IMAGE_DIMENSIONS = 200;
34442    const hasMask = dict.has("SMask") || dict.has("Mask");
34443    if (isInline && w + h < SMALL_IMAGE_DIMENSIONS && !hasMask) {
34444      try {
34445        const imageObj = new PDFImage({
34446          xref: this.xref,
34447          res: resources,
34448          image,
34449          isInline,
34450          pdfFunctionFactory: this._pdfFunctionFactory,
34451          globalColorSpaceCache: this.globalColorSpaceCache,
34452          localColorSpaceCache
34453        });
34454        imgData = await imageObj.createImageData(true, false);
34455        operatorList.addImageOps(OPS.paintInlineImageXObject, [imgData], optionalContent);
34456      } catch (reason) {
34457        const msg = `Unable to decode inline image: "${reason}".`;
34458        if (!ignoreErrors) {
34459          throw new Error(msg);
34460        }
34461        warn(msg);
34462      }
34463      return;
34464    }
34465    let objId = `img_${this.idFactory.createObjId()}`,
34466      cacheGlobally = false,
34467      globalCacheData = null;
34468    if (this.parsingType3Font) {
34469      objId = `${this.idFactory.getDocId()}_type3_${objId}`;
34470    } else if (cacheKey && imageRef) {
34471      cacheGlobally = this.globalImageCache.shouldCache(imageRef, this.pageIndex);
34472      if (cacheGlobally) {
34473        assert(!isInline, "Cannot cache an inline image globally.");
34474        objId = `${this.idFactory.getDocId()}_${objId}`;
34475      }
34476    }
34477    operatorList.addDependency(objId);
34478    fn = OPS.paintImageXObject;
34479    args = [objId, w, h];
34480    operatorList.addImageOps(fn, args, optionalContent, hasMask);
34481    if (cacheGlobally) {
34482      globalCacheData = {
34483        objId,
34484        fn,
34485        args,
34486        optionalContent,
34487        hasMask,
34488        byteSize: 0
34489      };
34490      if (this.globalImageCache.hasDecodeFailed(imageRef)) {
34491        this.globalImageCache.setData(imageRef, globalCacheData);
34492        this._sendImgData(objId, null, cacheGlobally);
34493        return;
34494      }
34495      if (w * h > 250000 || hasMask) {
34496        const localLength = await this.handler.sendWithPromise("commonobj", [objId, "CopyLocalImage", {
34497          imageRef
34498        }]);
34499        if (localLength) {
34500          this.globalImageCache.setData(imageRef, globalCacheData);
34501          this.globalImageCache.addByteSize(imageRef, localLength);
34502          return;
34503        }
34504      }
34505    }
34506    PDFImage.buildImage({
34507      xref: this.xref,
34508      res: resources,
34509      image,
34510      isInline,
34511      pdfFunctionFactory: this._pdfFunctionFactory,
34512      globalColorSpaceCache: this.globalColorSpaceCache,
34513      localColorSpaceCache
34514    }).then(async imageObj => {
34515      imgData = await imageObj.createImageData(false, isOffscreenCanvasSupported);
34516      imgData.dataLen = imgData.bitmap ? imgData.width * imgData.height * 4 : imgData.data.length;
34517      imgData.ref = imageRef;
34518      if (cacheGlobally) {
34519        this.globalImageCache.addByteSize(imageRef, imgData.dataLen);
34520      }
34521      return this._sendImgData(objId, imgData, cacheGlobally);
34522    }).catch(reason => {
34523      warn(`Unable to decode image "${objId}": "${reason}".`);
34524      if (imageRef) {
34525        this.globalImageCache.addDecodeFailed(imageRef);
34526      }
34527      return this._sendImgData(objId, null, cacheGlobally);
34528    });
34529    if (cacheKey) {
34530      const cacheData = {
34531        objId,
34532        fn,
34533        args,
34534        optionalContent,
34535        hasMask
34536      };
34537      localImageCache.set(cacheKey, imageRef, cacheData);
34538      if (imageRef) {
34539        this._regionalImageCache.set(null, imageRef, cacheData);
34540        if (cacheGlobally) {
34541          assert(globalCacheData, "The global cache-data must be available.");
34542          this.globalImageCache.setData(imageRef, globalCacheData);
34543        }
34544      }
34545    }
34546  }
34547  
34547handleSMask(smask, resources, operatorList, task, stateManager, localColorSpaceCache, seenRefs) {
34548    const smaskContent = smask.get("G");
34549    const smaskOptions = {
34550      subtype: smask.get("S").name,
34551      backdrop: smask.get("BC")
34552    };
34553    const transferObj = smask.get("TR");
34554    if (isPDFFunction(transferObj)) {
34555      const transferFn = this._pdfFunctionFactory.create(transferObj);
34556      const transferMap = new Uint8Array(256);
34557      const tmp = new Float32Array(1);
34558      for (let i = 0; i < 256; i++) {
34559        tmp[0] = i / 255;
34560        transferFn(tmp, 0, tmp, 0);
34561        transferMap[i] = tmp[0] * 255 | 0;
34562      }
34563      smaskOptions.transferMap = transferMap;
34564    }
34565    return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone({
34566      newPath: true
34567    }), localColorSpaceCache, seenRefs);
34568  }
34569  handleTransferFunction(tr) {
34570    let transferArray;
34571    if (Array.isArray(tr)) {
34572      transferArray = tr;
34573      if (tr.length > 1 && tr.every(map => map === tr[0])) {
34574        transferArray = [tr[0]];
34575      }
34576    } else if (isPDFFunction(tr)) {
34577      transferArray = [tr];
34578    } else {
34579      return null;
34580    }
34581    const transferMaps = [];
34582    let numFns = 0,
34583      numEffectfulFns = 0;
34584    for (const entry of transferArray) {
34585      const transferObj = this.xref.fetchIfRef(entry);
34586      numFns++;
34587      if (isName(transferObj, "Identity")) {
34588        transferMaps.push(null);
34589        continue;
34590      } else if (!isPDFFunction(transferObj)) {
34591        return null;
34592      }
34593      const transferFn = this._pdfFunctionFactory.create(transferObj);
34594      const transferMap = new Uint8Array(256),
34595        tmp = new Float32Array(1);
34596      for (let j = 0; j < 256; j++) {
34597        tmp[0] = j / 255;
34598        transferFn(tmp, 0, tmp, 0);
34599        transferMap[j] = tmp[0] * 255 | 0;
34600      }
34601      transferMaps.push(transferMap);
34602      numEffectfulFns++;
34603    }
34604    if (!(numFns === 1 || numFns === 4)) {
34605      return null;
34606    }
34607    if (numEffectfulFns === 0) {
34608      return null;
34609    }
34610    return transferMaps;
34611  }
34612  handleTilingType(fn, color, resources, pattern, patternDict, operatorList, task, localTilingPatternCache, seenRefs) {
34613    const tilingOpList = new CheckedOperatorList();
34614    const patternResources = Dict.merge({
34615      xref: this.xref,
34616      dictArray: [patternDict.get("Resources"), resources]
34617    });
34618    return this.getOperatorList({
34619      stream: pattern,
34620      task,
vendor: 4,151 bytes, lines 34621-34746
34621      resources: patternResources,
34622      operatorList: tilingOpList,
34623      prevRefs: seenRefs
34624    }).then(function () {
34625      const operatorListIR = tilingOpList.getIR();
34626      const {
34627        needsIsolation
34628      } = tilingOpList;
34629      const tilingPatternIR = getTilingPatternIR(operatorListIR, patternDict, color, needsIsolation);
34630      operatorList.addDependencies(tilingOpList.dependencies);
34631      operatorList.addOp(fn, tilingPatternIR);
34632      if (patternDict.objId) {
34633        localTilingPatternCache.set(null, patternDict.objId, {
34634          operatorListIR,
34635          needsIsolation,
34636          dict: patternDict
34637        });
34638      }
34639    }).catch(reason => {
34640      if (reason instanceof AbortException) {
34641        return;
34642      }
34643      if (this.options.ignoreErrors) {
34644        warn(`handleTilingType - ignoring pattern: "${reason}".`);
34645        return;
34646      }
34647      throw reason;
34648    });
34649  }
34650  async handleSetFont(resources, fontArgs, fontRef, operatorList, task, state, fallbackFontDict = null, cssFontInfo = null, seenRefs = null) {
34651    const fontName = fontArgs?.[0] instanceof Name ? fontArgs[0].name : null;
34652    const translated = await this.loadFont(fontName, fontRef, resources, task, fallbackFontDict, cssFontInfo, seenRefs);
34653    if (translated.font.isType3Font) {
34654      operatorList.addDependencies(translated.type3Dependencies);
34655    }
34656    state.font = translated.font;
34657    translated.send(this.handler);
34658    return translated.loadedName;
34659  }
34660  handleText(chars, state) {
34661    const font = state.font;
34662    const glyphs = font.charsToGlyphs(chars);
34663    if (font.data) {
34664      const isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
34665      if (isAddToPathSet || state.fillColorSpace.name === "Pattern" || state.strokeColorSpace.name === "Pattern" || font.disableFontFace) {
34666        PartialEvaluator.buildFontPaths(font, glyphs, this.handler, this.options);
34667      }
34668    }
34669    return glyphs;
34670  }
34671  ensureStateFont(state) {
34672    if (state.font) {
34673      return;
34674    }
34675    const reason = new FormatError("Missing setFont (Tf) operator before text rendering operator.");
34676    if (this.options.ignoreErrors) {
34677      warn(`ensureStateFont: "${reason}".`);
34678      return;
34679    }
34680    throw reason;
34681  }
34682  async setGState({
34683    resources,
34684    gState,
34685    operatorList,
34686    cacheKey,
34687    task,
34688    stateManager,
34689    localGStateCache,
34690    localColorSpaceCache,
34691    seenRefs
34692  }) {
34693    const gStateRef = gState.objId;
34694    let isSimpleGState = true;
34695    const gStateObj = [];
34696    let promise = Promise.resolve();
34697    for (const [key, value] of gState) {
34698      switch (key) {
34699        case "Type":
34700          break;
34701        case "LW":
34702          if (typeof value !== "number") {
34703            warn(`Invalid LW (line width): ${value}`);
34704            break;
34705          }
34706          gStateObj.push([key, Math.abs(value)]);
34707          break;
34708        case "LC":
34709        case "LJ":
34710        case "ML":
34711        case "D":
34712        case "RI":
34713        case "FL":
34714        case "CA":
34715        case "ca":
34716          gStateObj.push([key, value]);
34717          break;
34718        case "Font":
34719          isSimpleGState = false;
34720          promise = promise.then(() => this.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state, null, null, seenRefs).then(function (loadedName) {
34721            operatorList.addDependency(loadedName);
34722            gStateObj.push([key, [loadedName, value[1]]]);
34723          }));
34724          break;
34725        case "BM":
34726          gStateObj.push([key, normalizeBlendMode(value)]);
34727          break;
34728        case "SMask":
34729          if (isName(value, "None")) {
34730            gStateObj.push([key, false]);
34731            break;
34732          }
34733          if (value instanceof Dict) {
34734            isSimpleGState = false;
34735            promise = promise.then(() => this.handleSMask(value, resources, operatorList, task, stateManager, localColorSpaceCache, seenRefs));
34736            gStateObj.push([key, true]);
34737          } else {
34738            warn("Unsupported SMask type");
34739          }
34740          break;
34741        case "TR":
34742        case "TR2":
34743          {
34744            if (key === "TR" && gState.has("TR2")) {
34745              break;
34746            }
vendor: 12,233 bytes, lines 34746-35110
34746
34747            const transferMaps = this.handleTransferFunction(value);
34748            gStateObj.push(["TR", transferMaps]);
34749            break;
34750          }
34751        case "OP":
34752        case "op":
34753        case "OPM":
34754        case "BG":
34755        case "BG2":
34756        case "UCR":
34757        case "UCR2":
34758        case "HT":
34759        case "SM":
34760        case "SA":
34761        case "AIS":
34762        case "TK":
34763          info("graphic state operator " + key);
34764          break;
34765        default:
34766          info("Unknown graphic state operator " + key);
34767          break;
34768      }
34769    }
34770    await promise;
34771    if (gStateObj.length > 0) {
34772      operatorList.addOp(OPS.setGState, [gStateObj]);
34773    }
34774    if (isSimpleGState) {
34775      localGStateCache.set(cacheKey, gStateRef, gStateObj);
34776    }
34777  }
34778  loadFont(fontName, font, resources, task, fallbackFontDict = null, cssFontInfo = null, seenRefs = null) {
34779    const errorFont = async () => new TranslatedFont({
34780      loadedName: "g_font_error",
34781      font: new ErrorFont(`Font "${fontName}" is not available.`),
34782      dict: font
34783    });
34784    let fontRef;
34785    if (font) {
34786      if (font instanceof Ref) {
34787        fontRef = font;
34788      }
34789    } else {
34790      const fontRes = resources.get("Font");
34791      if (fontRes) {
34792        fontRef = fontRes.getRaw(fontName);
34793      }
34794    }
34795    if (fontRef) {
34796      if (this.type3FontRefs?.has(fontRef)) {
34797        return errorFont();
34798      }
34799      if (this.fontCache.has(fontRef)) {
34800        return this.fontCache.get(fontRef);
34801      }
34802      try {
34803        font = this.xref.fetchIfRef(fontRef);
34804      } catch (ex) {
34805        warn(`loadFont - lookup failed: "${ex}".`);
34806      }
34807    }
34808    if (!(font instanceof Dict)) {
34809      if (!this.options.ignoreErrors && !this.parsingType3Font) {
34810        warn(`Font "${fontName}" is not available.`);
34811        return errorFont();
34812      }
34813      warn(`Font "${fontName}" is not available -- attempting to fallback to a default font.`);
34814      font = fallbackFontDict || PartialEvaluator.fallbackFontDict;
34815    }
34816    if (font.cacheKey && this.fontCache.has(font.cacheKey)) {
34817      return this.fontCache.get(font.cacheKey);
34818    }
34819    const {
34820      promise,
34821      resolve
34822    } = Promise.withResolvers();
34823    let preEvaluatedFont;
34824    try {
34825      preEvaluatedFont = this.preEvaluateFont(font);
34826      preEvaluatedFont.cssFontInfo = cssFontInfo;
34827    } catch (reason) {
34828      warn(`loadFont - preEvaluateFont failed: "${reason}".`);
34829      return errorFont();
34830    }
34831    const {
34832      descriptor,
34833      hash
34834    } = preEvaluatedFont;
34835    const fontRefIsRef = fontRef instanceof Ref;
34836    let fontID;
34837    if (hash && descriptor instanceof Dict) {
34838      const fontAliases = descriptor.fontAliases ||= Object.create(null);
34839      if (fontAliases[hash]) {
34840        const aliasFontRef = fontAliases[hash].aliasRef;
34841        if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
34842          this.fontCache.putAlias(fontRef, aliasFontRef);
34843          return this.fontCache.get(fontRef);
34844        }
34845      } else {
34846        fontAliases[hash] = {
34847          fontID: this.idFactory.createFontId()
34848        };
34849      }
34850      if (fontRefIsRef) {
34851        fontAliases[hash].aliasRef = fontRef;
34852      }
34853      fontID = fontAliases[hash].fontID;
34854    } else {
34855      fontID = this.idFactory.createFontId();
34856    }
34857    assert(fontID?.startsWith("f"), 'The "fontID" must be (correctly) defined.');
34858    if (fontRefIsRef) {
34859      this.fontCache.put(fontRef, promise);
34860    } else {
34861      font.cacheKey = `cacheKey_${fontID}`;
34862      this.fontCache.put(font.cacheKey, promise);
34863    }
34864    font.loadedName = `${this.idFactory.getDocId()}_${fontID}`;
34865    this.translateFont(preEvaluatedFont).then(async translatedFont => {
34866      const translated = new TranslatedFont({
34867        loadedName: font.loadedName,
34868        font: translatedFont,
34869        dict: font
34870      });
34871      if (translatedFont.isType3Font) {
34872        try {
34873          await translated.loadType3Data(this, resources, task, seenRefs);
34874        } catch (reason) {
34875          throw new Error(`Type3 font load error: ${reason}`);
34876        }
34877      }
34878      resolve(translated);
34879    }).catch(reason => {
34880      warn(`loadFont - translateFont failed: "${reason}".`);
34881      resolve(new TranslatedFont({
34882        loadedName: font.loadedName,
34883        font: new ErrorFont(reason?.message),
34884        dict: font
34885      }));
34886    });
34887    return promise;
34888  }
34889  buildPath(fn, args, state) {
34890    const {
34891      pathMinMax: minMax,
34892      pathBuffer
34893    } = state;
34894    switch (fn | 0) {
34895      case OPS.rectangle:
34896        {
34897          const x = state.currentPointX = args[0];
34898          const y = state.currentPointY = args[1];
34899          const width = args[2];
34900          const height = args[3];
34901          const xw = x + width;
34902          const yh = y + height;
34903          if (width === 0 || height === 0) {
34904            pathBuffer.push(DrawOPS.moveTo, x, y, DrawOPS.lineTo, xw, yh, DrawOPS.closePath);
34905          } else {
34906            pathBuffer.push(DrawOPS.moveTo, x, y, DrawOPS.lineTo, xw, y, DrawOPS.lineTo, xw, yh, DrawOPS.lineTo, x, yh, DrawOPS.closePath);
34907          }
34908          Util.rectBoundingBox(x, y, xw, yh, minMax);
34909          break;
34910        }
34911      case OPS.moveTo:
34912        {
34913          const x = state.currentPointX = args[0];
34914          const y = state.currentPointY = args[1];
34915          pathBuffer.push(DrawOPS.moveTo, x, y);
34916          Util.pointBoundingBox(x, y, minMax);
34917          break;
34918        }
34919      case OPS.lineTo:
34920        {
34921          const x = state.currentPointX = args[0];
34922          const y = state.currentPointY = args[1];
34923          pathBuffer.push(DrawOPS.lineTo, x, y);
34924          Util.pointBoundingBox(x, y, minMax);
34925          break;
34926        }
34927      case OPS.curveTo:
34928        {
34929          const startX = state.currentPointX;
34930          const startY = state.currentPointY;
34931          const [x1, y1, x2, y2, x, y] = args;
34932          state.currentPointX = x;
34933          state.currentPointY = y;
34934          pathBuffer.push(DrawOPS.curveTo, x1, y1, x2, y2, x, y);
34935          Util.bezierBoundingBox(startX, startY, x1, y1, x2, y2, x, y, minMax);
34936          break;
34937        }
34938      case OPS.curveTo2:
34939        {
34940          const startX = state.currentPointX;
34941          const startY = state.currentPointY;
34942          const [x1, y1, x, y] = args;
34943          state.currentPointX = x;
34944          state.currentPointY = y;
34945          pathBuffer.push(DrawOPS.curveTo, startX, startY, x1, y1, x, y);
34946          Util.bezierBoundingBox(startX, startY, startX, startY, x1, y1, x, y, minMax);
34947          break;
34948        }
34949      case OPS.curveTo3:
34950        {
34951          const startX = state.currentPointX;
34952          const startY = state.currentPointY;
34953          const [x1, y1, x, y] = args;
34954          state.currentPointX = x;
34955          state.currentPointY = y;
34956          pathBuffer.push(DrawOPS.curveTo, x1, y1, x, y, x, y);
34957          Util.bezierBoundingBox(startX, startY, x1, y1, x, y, x, y, minMax);
34958          break;
34959        }
34960      case OPS.closePath:
34961        pathBuffer.push(DrawOPS.closePath);
34962        break;
34963    }
34964  }
34965  _getColorSpace(cs, resources, localColorSpaceCache) {
34966    return ColorSpaceUtils.parse({
34967      cs,
34968      xref: this.xref,
34969      resources,
34970      pdfFunctionFactory: this._pdfFunctionFactory,
34971      globalColorSpaceCache: this.globalColorSpaceCache,
34972      localColorSpaceCache,
34973      asyncIfNotCached: true
34974    });
34975  }
34976  async _handleColorSpace(csPromise) {
34977    try {
34978      return await csPromise;
34979    } catch (ex) {
34980      if (ex instanceof AbortException) {
34981        return null;
34982      }
34983      if (this.options.ignoreErrors) {
34984        warn(`_handleColorSpace - ignoring ColorSpace: "${ex}".`);
34985        return null;
34986      }
34987      throw ex;
34988    }
34989  }
34990  parseShading({
34991    shading,
34992    resources,
34993    localColorSpaceCache,
34994    localShadingPatternCache
34995  }) {
34996    let id = localShadingPatternCache.get(shading);
34997    if (id) {
34998      return id;
34999    }
35000    let patternIR;
35001    try {
35002      const shadingFill = Pattern.parseShading(shading, this.xref, resources, this._pdfFunctionFactory, this.globalColorSpaceCache, localColorSpaceCache);
35003      patternIR = shadingFill.getIR();
35004    } catch (reason) {
35005      if (reason instanceof AbortException) {
35006        return null;
35007      }
35008      if (this.options.ignoreErrors) {
35009        warn(`parseShading - ignoring shading: "${reason}".`);
35010        localShadingPatternCache.set(shading, null);
35011        return null;
35012      }
35013      throw reason;
35014    }
35015    id = `pattern_${this.idFactory.createObjId()}`;
35016    if (this.parsingType3Font) {
35017      id = `${this.idFactory.getDocId()}_type3_${id}`;
35018    }
35019    localShadingPatternCache.set(shading, id);
35020    if (this.parsingType3Font) {
35021      const buffer = compilePatternInfo(patternIR);
35022      this.handler.send("commonobj", [id, "Pattern", buffer], [buffer]);
35023    } else {
35024      this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]);
35025    }
35026    return id;
35027  }
35028  handleColorN(operatorList, fn, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache, seenRefs) {
35029    const patternName = args.pop();
35030    if (patternName instanceof Name) {
35031      const rawPattern = patterns.getRaw(patternName.name);
35032      const localTilingPattern = rawPattern instanceof Ref && localTilingPatternCache.getByRef(rawPattern);
35033      if (localTilingPattern) {
35034        try {
35035          const color = cs.base ? cs.base.getRgbHex(args, 0) : null;
35036          const tilingPatternIR = getTilingPatternIR(localTilingPattern.operatorListIR, localTilingPattern.dict, color, localTilingPattern.needsIsolation);
35037          operatorList.addOp(fn, tilingPatternIR);
35038          return undefined;
35039        } catch {}
35040      }
35041      const pattern = this.xref.fetchIfRef(rawPattern);
35042      if (pattern) {
35043        const dict = pattern instanceof BaseStream ? pattern.dict : pattern;
35044        const typeNum = dict.get("PatternType");
35045        if (typeNum === PatternType.TILING) {
35046          const color = cs.base ? cs.base.getRgbHex(args, 0) : null;
35047          return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task, localTilingPatternCache, seenRefs);
35048        } else if (typeNum === PatternType.SHADING) {
35049          const shading = dict.get("Shading");
35050          const objId = this.parseShading({
35051            shading,
35052            resources,
35053            localColorSpaceCache,
35054            localShadingPatternCache
35055          });
35056          if (objId) {
35057            const matrix = lookupMatrix(dict.getArray("Matrix"), null);
35058            operatorList.addOp(fn, ["Shading", objId, matrix]);
35059          }
35060          return undefined;
35061        }
35062        throw new FormatError(`Unknown PatternType: ${typeNum}`);
35063      }
35064    }
35065    throw new FormatError(`Unknown PatternName: ${patternName}`);
35066  }
35067  async parseMarkedContentProps(contentProperties, resources) {
35068    return parseMarkedContentProps(this.xref, contentProperties, resources);
35069  }
35070  async getOperatorList({
35071    stream,
35072    task,
35073    resources,
35074    operatorList,
35075    initialState = null,
35076    fallbackFontDict = null,
35077    prevRefs = null
35078  }) {
35079    if (stream.isAsync) {
35080      const bytes = await stream.asyncGetBytes();
35081      if (bytes) {
35082        stream = new Stream(bytes, 0, bytes.length, stream.dict);
35083      }
35084    }
35085    const objId = stream.dict?.objId;
35086    const seenRefs = new RefSet(prevRefs);
35087    if (objId) {
35088      if (prevRefs?.has(objId)) {
35089        throw new Error(`getOperatorList - ignoring circular reference: ${objId}`);
35090      }
35091      seenRefs.put(objId);
35092    }
35093    resources ||= Dict.empty;
35094    initialState ||= new EvalState();
35095    if (!operatorList) {
35096      throw new Error('getOperatorList: missing "operatorList" parameter');
35097    }
35098    const self = this;
35099    const xref = this.xref;
35100    const localImageCache = new LocalImageCache();
35101    const localColorSpaceCache = new LocalColorSpaceCache();
35102    const localGStateCache = new LocalGStateCache();
35103    const localTilingPatternCache = new LocalTilingPatternCache();
35104    const localShadingPatternCache = new Map();
35105    const xobjs = resources.get("XObject") || Dict.empty;
35106    const patterns = resources.get("Pattern") || Dict.empty;
35107    const stateManager = new StateManager(initialState);
35108    const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
35109    const timeSlotManager = new TimeSlotManager();
35110    
vendor: 12,612 bytes, lines 35110-35428
35110function closePendingRestoreOPS(argument) {
35111      for (let i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
35112        operatorList.addOp(OPS.restore, []);
35113      }
35114    }
35115    return new Promise(function promiseBody(resolve, reject) {
35116      const next = function (promise) {
35117        Promise.all([promise, operatorList.ready]).then(function () {
35118          try {
35119            promiseBody(resolve, reject);
35120          } catch (ex) {
35121            reject(ex);
35122          }
35123        }, reject);
35124      };
35125      task.ensureNotTerminated();
35126      timeSlotManager.reset();
35127      const operation = {};
35128      let stop, i, ii, cs, name, isValidName;
35129      while (!(stop = timeSlotManager.check())) {
35130        operation.args = null;
35131        if (!preprocessor.read(operation)) {
35132          break;
35133        }
35134        let args = operation.args;
35135        let fn = operation.fn;
35136        switch (fn | 0) {
35137          case OPS.paintXObject:
35138            isValidName = args[0] instanceof Name;
35139            name = args[0].name;
35140            if (isValidName) {
35141              const localImage = localImageCache.getByName(name);
35142              if (localImage) {
35143                addCachedImageOps(operatorList, localImage);
35144                args = null;
35145                continue;
35146              }
35147            }
35148            next(new Promise(function (resolveXObject, rejectXObject) {
35149              if (!isValidName) {
35150                throw new FormatError("XObject must be referred to by name.");
35151              }
35152              let xobj = xobjs.getRaw(name);
35153              if (xobj instanceof Ref) {
35154                const cachedImage = localImageCache.getByRef(xobj) || self._regionalImageCache.getByRef(xobj) || self.globalImageCache.getData(xobj, self.pageIndex);
35155                if (cachedImage) {
35156                  addCachedImageOps(operatorList, cachedImage);
35157                  resolveXObject();
35158                  return;
35159                }
35160                xobj = xref.fetch(xobj);
35161              }
35162              if (!(xobj instanceof BaseStream)) {
35163                throw new FormatError("XObject should be a stream");
35164              }
35165              const type = xobj.dict.get("Subtype");
35166              if (!(type instanceof Name)) {
35167                throw new FormatError("XObject should have a Name subtype");
35168              }
35169              if (type.name === "Form") {
35170                stateManager.save();
35171                self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone({
35172                  newPath: true
35173                }), localColorSpaceCache, seenRefs).then(function () {
35174                  stateManager.restore();
35175                  resolveXObject();
35176                }, rejectXObject);
35177                return;
35178              } else if (type.name === "Image") {
35179                self.buildPaintImageXObject({
35180                  resources,
35181                  image: xobj,
35182                  operatorList,
35183                  cacheKey: name,
35184                  localImageCache,
35185                  localColorSpaceCache
35186                }).then(resolveXObject, rejectXObject);
35187                return;
35188              } else if (type.name === "PS") {
35189                info("Ignored XObject subtype PS");
35190              } else {
35191                throw new FormatError(`Unhandled XObject subtype ${type.name}`);
35192              }
35193              resolveXObject();
35194            }).catch(function (reason) {
35195              if (reason instanceof AbortException) {
35196                return;
35197              }
35198              if (self.options.ignoreErrors) {
35199                warn(`getOperatorList - ignoring XObject: "${reason}".`);
35200                return;
35201              }
35202              throw reason;
35203            }));
35204            return;
35205          case OPS.setFont:
35206            const fontSize = args[1];
35207            next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state, fallbackFontDict, null, seenRefs).then(function (loadedName) {
35208              operatorList.addDependency(loadedName);
35209              operatorList.addOp(OPS.setFont, [loadedName, fontSize]);
35210            }));
35211            return;
35212          case OPS.endInlineImage:
35213            const cacheKey = args[0].cacheKey;
35214            if (cacheKey) {
35215              const localImage = localImageCache.getByName(cacheKey);
35216              if (localImage) {
35217                addCachedImageOps(operatorList, localImage);
35218                args = null;
35219                continue;
35220              }
35221            }
35222            next(self.buildPaintImageXObject({
35223              resources,
35224              image: args[0],
35225              isInline: true,
35226              operatorList,
35227              cacheKey,
35228              localImageCache,
35229              localColorSpaceCache
35230            }));
35231            return;
35232          case OPS.showText:
35233            if (!stateManager.state.font) {
35234              self.ensureStateFont(stateManager.state);
35235              continue;
35236            }
35237            args[0] = self.handleText(args[0], stateManager.state);
35238            break;
35239          case OPS.showSpacedText:
35240            if (!stateManager.state.font) {
35241              self.ensureStateFont(stateManager.state);
35242              continue;
35243            }
35244            const combinedGlyphs = [],
35245              state = stateManager.state;
35246            for (const arrItem of args[0]) {
35247              if (typeof arrItem === "string") {
35248                combinedGlyphs.push(...self.handleText(arrItem, state));
35249              } else if (typeof arrItem === "number") {
35250                combinedGlyphs.push(arrItem);
35251              }
35252            }
35253            args[0] = combinedGlyphs;
35254            fn = OPS.showText;
35255            break;
35256          case OPS.nextLineShowText:
35257            if (!stateManager.state.font) {
35258              self.ensureStateFont(stateManager.state);
35259              continue;
35260            }
35261            operatorList.addOp(OPS.nextLine);
35262            args[0] = self.handleText(args[0], stateManager.state);
35263            fn = OPS.showText;
35264            break;
35265          case OPS.nextLineSetSpacingShowText:
35266            if (!stateManager.state.font) {
35267              self.ensureStateFont(stateManager.state);
35268              continue;
35269            }
35270            operatorList.addOp(OPS.nextLine);
35271            operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
35272            operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
35273            args[0] = self.handleText(args[0], stateManager.state);
35274            fn = OPS.showText;
35275            break;
35276          case OPS.setTextRenderingMode:
35277            stateManager.state.textRenderingMode = args[0];
35278            break;
35279          case OPS.setFillColorSpace:
35280            {
35281              const fillCS = self._getColorSpace(args[0], resources, localColorSpaceCache);
35282              if (fillCS instanceof ColorSpace) {
35283                stateManager.state.fillColorSpace = fillCS;
35284                continue;
35285              }
35286              next(self._handleColorSpace(fillCS).then(colorSpace => {
35287                stateManager.state.fillColorSpace = colorSpace || ColorSpaceUtils.gray;
35288              }));
35289              return;
35290            }
35291          case OPS.setStrokeColorSpace:
35292            {
35293              const strokeCS = self._getColorSpace(args[0], resources, localColorSpaceCache);
35294              if (strokeCS instanceof ColorSpace) {
35295                stateManager.state.strokeColorSpace = strokeCS;
35296                continue;
35297              }
35298              next(self._handleColorSpace(strokeCS).then(colorSpace => {
35299                stateManager.state.strokeColorSpace = colorSpace || ColorSpaceUtils.gray;
35300              }));
35301              return;
35302            }
35303          case OPS.setFillColor:
35304            cs = stateManager.state.fillColorSpace;
35305            args = [cs.getRgbHex(args, 0)];
35306            fn = OPS.setFillRGBColor;
35307            break;
35308          case OPS.setStrokeColor:
35309            cs = stateManager.state.strokeColorSpace;
35310            args = [cs.getRgbHex(args, 0)];
35311            fn = OPS.setStrokeRGBColor;
35312            break;
35313          case OPS.setFillGray:
35314            stateManager.state.fillColorSpace = ColorSpaceUtils.gray;
35315            args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
35316            fn = OPS.setFillRGBColor;
35317            break;
35318          case OPS.setStrokeGray:
35319            stateManager.state.strokeColorSpace = ColorSpaceUtils.gray;
35320            args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
35321            fn = OPS.setStrokeRGBColor;
35322            break;
35323          case OPS.setFillCMYKColor:
35324            stateManager.state.fillColorSpace = ColorSpaceUtils.cmyk;
35325            args = [ColorSpaceUtils.cmyk.getRgbHex(args, 0)];
35326            fn = OPS.setFillRGBColor;
35327            break;
35328          case OPS.setStrokeCMYKColor:
35329            stateManager.state.strokeColorSpace = ColorSpaceUtils.cmyk;
35330            args = [ColorSpaceUtils.cmyk.getRgbHex(args, 0)];
35331            fn = OPS.setStrokeRGBColor;
35332            break;
35333          case OPS.setFillRGBColor:
35334            stateManager.state.fillColorSpace = ColorSpaceUtils.rgb;
35335            args = [ColorSpaceUtils.rgb.getRgbHex(args, 0)];
35336            break;
35337          case OPS.setStrokeRGBColor:
35338            stateManager.state.strokeColorSpace = ColorSpaceUtils.rgb;
35339            args = [ColorSpaceUtils.rgb.getRgbHex(args, 0)];
35340            break;
35341          case OPS.setFillColorN:
35342            cs = stateManager.state.patternFillColorSpace;
35343            if (!cs) {
35344              if (isNumberArray(args, null)) {
35345                args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
35346                fn = OPS.setFillRGBColor;
35347                break;
35348              }
35349              args = [];
35350              fn = OPS.setFillTransparent;
35351              break;
35352            }
35353            if (cs.name === "Pattern") {
35354              next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache, seenRefs));
35355              return;
35356            }
35357            args = [cs.getRgbHex(args, 0)];
35358            fn = OPS.setFillRGBColor;
35359            break;
35360          case OPS.setStrokeColorN:
35361            cs = stateManager.state.patternStrokeColorSpace;
35362            if (!cs) {
35363              if (isNumberArray(args, null)) {
35364                args = [ColorSpaceUtils.gray.getRgbHex(args, 0)];
35365                fn = OPS.setStrokeRGBColor;
35366                break;
35367              }
35368              args = [];
35369              fn = OPS.setStrokeTransparent;
35370              break;
35371            }
35372            if (cs.name === "Pattern") {
35373              next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, localColorSpaceCache, localTilingPatternCache, localShadingPatternCache, seenRefs));
35374              return;
35375            }
35376            args = [cs.getRgbHex(args, 0)];
35377            fn = OPS.setStrokeRGBColor;
35378            break;
35379          case OPS.shadingFill:
35380            let shading;
35381            try {
35382              const shadingRes = resources.get("Shading");
35383              if (!shadingRes) {
35384                throw new FormatError("No shading resource found");
35385              }
35386              shading = shadingRes.get(args[0].name);
35387              if (!shading) {
35388                throw new FormatError("No shading object found");
35389              }
35390            } catch (reason) {
35391              if (reason instanceof AbortException) {
35392                continue;
35393              }
35394              if (self.options.ignoreErrors) {
35395                warn(`getOperatorList - ignoring Shading: "${reason}".`);
35396                continue;
35397              }
35398              throw reason;
35399            }
35400            const patternId = self.parseShading({
35401              shading,
35402              resources,
35403              localColorSpaceCache,
35404              localShadingPatternCache
35405            });
35406            if (!patternId) {
35407              continue;
35408            }
35409            args = [patternId];
35410            fn = OPS.shadingFill;
35411            break;
35412          case OPS.setGState:
35413            isValidName = args[0] instanceof Name;
35414            name = args[0].name;
35415            if (isValidName) {
35416              const localGStateObj = localGStateCache.getByName(name);
35417              if (localGStateObj) {
35418                if (localGStateObj.length > 0) {
35419                  operatorList.addOp(OPS.setGState, [localGStateObj]);
35420                }
35421                args = null;
35422                continue;
35423              }
35424            }
35425            next(new Promise(function (resolveGState, rejectGState) {
35426              if (!isValidName) {
35427                throw new FormatError("GState must be referred to by name.");
35428              }
vendor: 4,557 bytes, lines 35429-35552
35429              const extGState = resources.get("ExtGState");
35430              if (!(extGState instanceof Dict)) {
35431                throw new FormatError("ExtGState should be a dictionary.");
35432              }
35433              const gState = extGState.get(name);
35434              if (!(gState instanceof Dict)) {
35435                throw new FormatError("GState should be a dictionary.");
35436              }
35437              self.setGState({
35438                resources,
35439                gState,
35440                operatorList,
35441                cacheKey: name,
35442                task,
35443                stateManager,
35444                localGStateCache,
35445                localColorSpaceCache,
35446                seenRefs
35447              }).then(resolveGState, rejectGState);
35448            }).catch(function (reason) {
35449              if (reason instanceof AbortException) {
35450                return;
35451              }
35452              if (self.options.ignoreErrors) {
35453                warn(`getOperatorList - ignoring ExtGState: "${reason}".`);
35454                return;
35455              }
35456              throw reason;
35457            }));
35458            return;
35459          case OPS.setLineWidth:
35460            {
35461              const [thickness] = args;
35462              if (typeof thickness !== "number") {
35463                warn(`Invalid setLineWidth: ${thickness}`);
35464                continue;
35465              }
35466              args[0] = Math.abs(thickness);
35467              break;
35468            }
35469          case OPS.setDash:
35470            {
35471              const dashPhase = args[1];
35472              if (typeof dashPhase !== "number") {
35473                warn(`Invalid setDash: ${dashPhase}`);
35474                continue;
35475              }
35476              const dashArray = args[0];
35477              if (!Array.isArray(dashArray)) {
35478                warn(`Invalid setDash: ${dashArray}`);
35479                continue;
35480              }
35481              if (dashArray.some(x => typeof x !== "number")) {
35482                args[0] = dashArray.filter(x => typeof x === "number");
35483              }
35484              break;
35485            }
35486          case OPS.moveTo:
35487          case OPS.lineTo:
35488          case OPS.curveTo:
35489          case OPS.curveTo2:
35490          case OPS.curveTo3:
35491          case OPS.closePath:
35492          case OPS.rectangle:
35493            self.buildPath(fn, args, stateManager.state);
35494            continue;
35495          case OPS.stroke:
35496          case OPS.closeStroke:
35497          case OPS.fill:
35498          case OPS.eoFill:
35499          case OPS.fillStroke:
35500          case OPS.eoFillStroke:
35501          case OPS.closeFillStroke:
35502          case OPS.closeEOFillStroke:
35503          case OPS.endPath:
35504            {
35505              const {
35506                state: {
35507                  pathBuffer,
35508                  pathMinMax
35509                }
35510              } = stateManager;
35511              if (fn === OPS.closeStroke || fn === OPS.closeFillStroke || fn === OPS.closeEOFillStroke) {
35512                pathBuffer.push(DrawOPS.closePath);
35513              }
35514              if (pathBuffer.length === 0) {
35515                operatorList.addOp(OPS.constructPath, [fn, [null], null]);
35516              } else {
35517                operatorList.addOp(OPS.constructPath, [fn, [new Float32Array(pathBuffer)], pathMinMax.slice()]);
35518                pathBuffer.length = 0;
35519                pathMinMax.set(BBOX_INIT, 0);
35520              }
35521              continue;
35522            }
35523          case OPS.setTextMatrix:
35524            operatorList.addOp(fn, [new Float32Array(args)]);
35525            continue;
35526          case OPS.markPoint:
35527          case OPS.markPointProps:
35528          case OPS.beginCompat:
35529          case OPS.endCompat:
35530            continue;
35531          case OPS.beginMarkedContentProps:
35532            if (!(args[0] instanceof Name)) {
35533              warn(`Expected name for beginMarkedContentProps arg0=${args[0]}`);
35534              operatorList.addOp(OPS.beginMarkedContentProps, ["OC", null]);
35535              continue;
35536            }
35537            if (args[0].name === "OC") {
35538              next(self.parseMarkedContentProps(args[1], resources).then(data => {
35539                operatorList.addOp(OPS.beginMarkedContentProps, ["OC", data]);
35540              }).catch(reason => {
35541                if (reason instanceof AbortException) {
35542                  return;
35543                }
35544                if (self.options.ignoreErrors) {
35545                  warn(`getOperatorList - ignoring beginMarkedContentProps: "${reason}".`);
35546                  operatorList.addOp(OPS.beginMarkedContentProps, ["OC", null]);
35547                  return;
35548                }
35549                throw reason;
35550              }));
35551              return;
35552            }
35553            args = [args[0].name, args[1] instanceof Dict ? args[1].get("MCID") : null];
35554            break;
35555          case OPS.beginMarkedContent:
35556          case OPS.endMarkedContent:
35557          default:
35558            if (args !== null) {
35559              for (i = 0, ii = args.length; i < ii; i++) {
35560                if (args[i] instanceof Dict) {
35561                  break;
35562                }
35563              }
35564              if (i < ii) {
35565                warn("getOperatorList - ignoring operator: " + fn);
35566                continue;
35567              }
35568            }
35569        }
35570        operatorList.addOp(fn, args);
35571      }
35572      if (stop) {
35573        next(deferred);
35574        return;
35575      }
35576      closePendingRestoreOPS();
35577      resolve();
35578    }).catch(reason => {
35579      if (reason instanceof AbortException) {
35580        return;
35581      }
35582      if (this.options.ignoreErrors) {
35583        warn(`getOperatorList - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
35584        closePendingRestoreOPS();
35585        return;
35586      }
35587      throw reason;
35588    });
35589  }
35590  async getTextContent({
35591    stream,
35592    task,
35593    resources,
35594    stateManager = null,
35595    includeMarkedContent = false,
35596    sink,
35597    seenStyles = new Set(),
35598    viewBox,
35599    lang = null,
35600    markedContentData = null,
35601    disableNormalization = false,
35602    keepWhiteSpace = false,
35603    prevRefs = null,
35604    intersector = null
35605  }) {
35606    if (stream.isAsync) {
35607      const bytes = await stream.asyncGetBytes();
35608      if (bytes) {
35609        stream = new Stream(bytes, 0, bytes.length, stream.dict);
35610      }
35611    }
35612    sink ??= textSinkWrapper(null);
35613    const objId = stream.dict?.objId;
35614    const seenRefs = new RefSet(prevRefs);
35615    if (objId) {
35616      if (prevRefs?.has(objId)) {
35617        throw new Error(`getTextContent - ignoring circular reference: ${objId}`);
35618      }
35619      seenRefs.put(objId);
35620    }
35621    resources ||= Dict.empty;
35622    stateManager ||= new StateManager(new TextState());
35623    if (includeMarkedContent) {
35624      markedContentData ||= {
35625        level: 0
35626      };
35627    }
vendor: 17,338 bytes, lines 35627-36093
35627
35628    const textContent = {
35629      items: [],
35630      styles: Object.create(null),
35631      lang
35632    };
35633    const textContentItem = {
35634      initialized: false,
35635      str: [],
35636      totalWidth: 0,
35637      totalHeight: 0,
35638      width: 0,
35639      height: 0,
35640      vertical: false,
35641      prevTransform: null,
35642      prevTextRise: 0,
35643      textAdvanceScale: 0,
35644      spaceInFlowMin: 0,
35645      spaceInFlowMax: 0,
35646      trackingSpaceMin: Infinity,
35647      negativeSpaceMax: -Infinity,
35648      notASpace: -Infinity,
35649      transform: null,
35650      fontName: null,
35651      hasEOL: false
35652    };
35653    const twoLastChars = [" ", " "];
35654    let twoLastCharsPos = 0;
35655    function saveLastChar(char) {
35656      const nextPos = (twoLastCharsPos + 1) % 2;
35657      const ret = twoLastChars[twoLastCharsPos] !== " " && twoLastChars[nextPos] === " ";
35658      twoLastChars[twoLastCharsPos] = char;
35659      twoLastCharsPos = nextPos;
35660      return !keepWhiteSpace && ret;
35661    }
35662    function shouldAddWhitepsace() {
35663      return !keepWhiteSpace && twoLastChars[twoLastCharsPos] !== " " && twoLastChars[(twoLastCharsPos + 1) % 2] === " ";
35664    }
35665    function resetLastChars() {
35666      twoLastChars[0] = twoLastChars[1] = " ";
35667      twoLastCharsPos = 0;
35668    }
35669    const TRACKING_SPACE_FACTOR = 0.102;
35670    const NOT_A_SPACE_FACTOR = 0.03;
35671    const NEGATIVE_SPACE_FACTOR = -0.2;
35672    const SPACE_IN_FLOW_MIN_FACTOR = 0.102;
35673    const SPACE_IN_FLOW_MAX_FACTOR = 0.6;
35674    const VERTICAL_SHIFT_RATIO = 0.25;
35675    const self = this;
35676    const xref = this.xref;
35677    const showSpacedTextBuffer = [];
35678    let xobjs = null;
35679    const emptyXObjectCache = new LocalImageCache();
35680    const emptyGStateCache = new LocalGStateCache();
35681    const preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
35682    let textState, currentTextState;
35683    function pushWhitespace({
35684      width = 0,
35685      height = 0,
35686      transform = textContentItem.prevTransform,
35687      fontName = textContentItem.fontName
35688    }) {
35689      intersector?.addExtraChar(" ");
35690      textContent.items.push({
35691        str: " ",
35692        dir: "ltr",
35693        width,
35694        height,
35695        transform,
35696        fontName,
35697        hasEOL: false
35698      });
35699    }
35700    function getCurrentTextTransform() {
35701      const font = textState.font;
35702      const tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
35703      if (font.isType3Font && (textState.fontSize <= 1 || font.isCharBBox) && !isArrayEqual(textState.fontMatrix, FONT_IDENTITY_MATRIX)) {
35704        const glyphHeight = font.bbox[3] - font.bbox[1];
35705        if (glyphHeight > 0) {
35706          tsm[3] *= glyphHeight * textState.fontMatrix[3];
35707        }
35708      }
35709      return Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
35710    }
35711    function ensureTextContentItem() {
35712      if (textContentItem.initialized) {
35713        return textContentItem;
35714      }
35715      const {
35716        font,
35717        loadedName
35718      } = textState;
35719      if (!seenStyles.has(loadedName)) {
35720        seenStyles.add(loadedName);
35721        textContent.styles[loadedName] = {
35722          fontFamily: font.fallbackName,
35723          ascent: font.ascent,
35724          descent: font.descent,
35725          vertical: font.vertical
35726        };
35727        if (self.options.fontExtraProperties && font.systemFontInfo) {
35728          const style = textContent.styles[loadedName];
35729          style.fontSubstitution = font.systemFontInfo.css;
35730          style.fontSubstitutionLoadedName = font.systemFontInfo.loadedName;
35731        }
35732      }
35733      textContentItem.fontName = loadedName;
35734      const trm = textContentItem.transform = getCurrentTextTransform();
35735      if (!font.vertical) {
35736        textContentItem.width = textContentItem.totalWidth = 0;
35737        textContentItem.height = textContentItem.totalHeight = Math.hypot(trm[2], trm[3]);
35738        textContentItem.vertical = false;
35739      } else {
35740        textContentItem.width = textContentItem.totalWidth = Math.hypot(trm[0], trm[1]);
35741        textContentItem.height = textContentItem.totalHeight = 0;
35742        textContentItem.vertical = true;
35743      }
35744      const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]);
35745      const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]);
35746      textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
35747      const {
35748        fontSize
35749      } = textState;
35750      textContentItem.trackingSpaceMin = fontSize * TRACKING_SPACE_FACTOR;
35751      textContentItem.notASpace = fontSize * NOT_A_SPACE_FACTOR;
35752      textContentItem.negativeSpaceMax = fontSize * NEGATIVE_SPACE_FACTOR;
35753      textContentItem.spaceInFlowMin = fontSize * SPACE_IN_FLOW_MIN_FACTOR;
35754      textContentItem.spaceInFlowMax = fontSize * SPACE_IN_FLOW_MAX_FACTOR;
35755      textContentItem.hasEOL = false;
35756      textContentItem.initialized = true;
35757      return textContentItem;
35758    }
35759    function updateAdvanceScale() {
35760      if (!textContentItem.initialized) {
35761        return;
35762      }
35763      const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]);
35764      const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]);
35765      const scaleFactor = scaleCtmX * scaleLineX;
35766      if (scaleFactor === textContentItem.textAdvanceScale) {
35767        return;
35768      }
35769      if (!textContentItem.vertical) {
35770        textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale;
35771        textContentItem.width = 0;
35772      } else {
35773        textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale;
35774        textContentItem.height = 0;
35775      }
35776      textContentItem.textAdvanceScale = scaleFactor;
35777    }
35778    function runBidiTransform(textChunk) {
35779      let text = textChunk.str.join("");
35780      if (!disableNormalization) {
35781        text = normalizeUnicode(text);
35782      }
35783      const bidiResult = bidi(text, -1, textChunk.vertical);
35784      return {
35785        str: bidiResult.str,
35786        dir: bidiResult.dir,
35787        width: Math.abs(textChunk.totalWidth),
35788        height: Math.abs(textChunk.totalHeight),
35789        transform: textChunk.transform,
35790        fontName: textChunk.fontName,
35791        hasEOL: textChunk.hasEOL
35792      };
35793    }
35794    async function handleSetFont(fontName, fontRef) {
35795      const translated = await self.loadFont(fontName, fontRef, resources, task, null, null, seenRefs);
35796      textState.loadedName = translated.loadedName;
35797      textState.font = translated.font;
35798      textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
35799    }
35800    function applyInverseRotation(x, y, matrix) {
35801      const scale = Math.hypot(matrix[0], matrix[1]);
35802      return [(matrix[0] * x + matrix[1] * y) / scale, (matrix[2] * x + matrix[3] * y) / scale];
35803    }
35804    function compareWithLastPosition(glyphWidth) {
35805      const currentTransform = getCurrentTextTransform();
35806      let posX = currentTransform[4];
35807      let posY = currentTransform[5];
35808      if (textState.font?.vertical) {
35809        if (posX < viewBox[0] || posX > viewBox[2] || posY + glyphWidth < viewBox[1] || posY > viewBox[3]) {
35810          return false;
35811        }
35812      } else if (posX + glyphWidth < viewBox[0] || posX > viewBox[2] || posY < viewBox[1] || posY > viewBox[3]) {
35813        return false;
35814      }
35815      if (!textState.font || !textContentItem.prevTransform) {
35816        return true;
35817      }
35818      let lastPosX = textContentItem.prevTransform[4];
35819      let lastPosY = textContentItem.prevTransform[5];
35820      if (lastPosX === posX && lastPosY === posY) {
35821        return true;
35822      }
35823      let rotate = -1;
35824      if (currentTransform[0] && currentTransform[1] === 0 && currentTransform[2] === 0) {
35825        rotate = currentTransform[0] > 0 ? 0 : 180;
35826      } else if (currentTransform[1] && currentTransform[0] === 0 && currentTransform[3] === 0) {
35827        rotate = currentTransform[1] > 0 ? 90 : 270;
35828      }
35829      switch (rotate) {
35830        case 0:
35831          break;
35832        case 90:
35833          [posX, posY] = [posY, posX];
35834          [lastPosX, lastPosY] = [lastPosY, lastPosX];
35835          break;
35836        case 180:
35837          [posX, posY, lastPosX, lastPosY] = [-posX, -posY, -lastPosX, -lastPosY];
35838          break;
35839        case 270:
35840          [posX, posY] = [-posY, -posX];
35841          [lastPosX, lastPosY] = [-lastPosY, -lastPosX];
35842          break;
35843        default:
35844          [posX, posY] = applyInverseRotation(posX, posY, currentTransform);
35845          [lastPosX, lastPosY] = applyInverseRotation(lastPosX, lastPosY, textContentItem.prevTransform);
35846      }
35847      if (textState.font.vertical) {
35848        const advanceY = (lastPosY - posY) / textContentItem.textAdvanceScale;
35849        const advanceX = posX - lastPosX;
35850        const textOrientation = Math.sign(textContentItem.height || textContentItem.totalHeight);
35851        if (advanceY < textOrientation * textContentItem.negativeSpaceMax) {
35852          if (Math.abs(advanceX) > 0.5 * textContentItem.width) {
35853            appendEOL();
35854            return true;
35855          }
35856          resetLastChars();
35857          flushTextContentItem();
35858          return true;
35859        }
35860        if (Math.abs(advanceX) > textContentItem.width) {
35861          appendEOL();
35862          return true;
35863        }
35864        if (advanceY <= textOrientation * textContentItem.notASpace) {
35865          resetLastChars();
35866        }
35867        if (advanceY <= textOrientation * textContentItem.trackingSpaceMin) {
35868          if (shouldAddWhitepsace()) {
35869            resetLastChars();
35870            flushTextContentItem();
35871            pushWhitespace({
35872              height: Math.abs(advanceY)
35873            });
35874          } else {
35875            textContentItem.height += advanceY;
35876          }
35877        } else if (!addFakeSpaces(advanceY, textContentItem.prevTransform, textOrientation)) {
35878          if (textContentItem.str.length === 0) {
35879            resetLastChars();
35880            pushWhitespace({
35881              height: Math.abs(advanceY)
35882            });
35883          } else {
35884            textContentItem.height += advanceY;
35885          }
35886        }
35887        if (Math.abs(advanceX) > textContentItem.width * VERTICAL_SHIFT_RATIO) {
35888          flushTextContentItem();
35889        }
35890        return true;
35891      }
35892      const advanceX = (posX - lastPosX) / textContentItem.textAdvanceScale;
35893      const advanceY = posY - lastPosY;
35894      const textOrientation = Math.sign(textContentItem.width || textContentItem.totalWidth);
35895      if (advanceX < textOrientation * textContentItem.negativeSpaceMax) {
35896        if (Math.abs(advanceY) > 0.5 * textContentItem.height) {
35897          appendEOL();
35898          return true;
35899        }
35900        resetLastChars();
35901        flushTextContentItem();
35902        return true;
35903      }
35904      const textRiseDelta = textState.textRise - textContentItem.prevTextRise;
35905      const advanceYCorrected = textRiseDelta === 0 ? advanceY : advanceY - currentTransform[3] / textState.fontSize * textRiseDelta;
35906      if (Math.abs(advanceYCorrected) > textContentItem.height) {
35907        appendEOL();
35908        return true;
35909      }
35910      if (advanceX <= textOrientation * textContentItem.notASpace) {
35911        resetLastChars();
35912      }
35913      if (advanceX <= textOrientation * textContentItem.trackingSpaceMin) {
35914        if (shouldAddWhitepsace()) {
35915          resetLastChars();
35916          flushTextContentItem();
35917          pushWhitespace({
35918            width: Math.abs(advanceX)
35919          });
35920        } else {
35921          textContentItem.width += advanceX;
35922        }
35923      } else if (!addFakeSpaces(advanceX, textContentItem.prevTransform, textOrientation)) {
35924        if (textContentItem.str.length === 0) {
35925          resetLastChars();
35926          pushWhitespace({
35927            width: Math.abs(advanceX)
35928          });
35929        } else {
35930          textContentItem.width += advanceX;
35931        }
35932      }
35933      if (Math.abs(advanceY) > textContentItem.height * VERTICAL_SHIFT_RATIO) {
35934        flushTextContentItem();
35935      }
35936      return true;
35937    }
35938    function buildTextContentItem({
35939      chars,
35940      extraSpacing
35941    }) {
35942      if (currentTextState !== textState && (currentTextState.fontSize !== textState.fontSize || currentTextState.fontName !== textState.fontName && (currentTextState.font.name !== textState.font.name || currentTextState.font.vertical !== textState.font.vertical))) {
35943        flushTextContentItem();
35944        currentTextState = textState.clone();
35945      }
35946      const font = textState.font;
35947      const baseCharSpacing = font.vertical ? -textState.charSpacing : textState.charSpacing;
35948      if (!chars) {
35949        const charSpacing = baseCharSpacing + extraSpacing;
35950        if (charSpacing) {
35951          if (!font.vertical) {
35952            textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
35953          } else {
35954            textState.translateTextMatrix(0, -charSpacing);
35955          }
35956        }
35957        if (keepWhiteSpace) {
35958          compareWithLastPosition(0);
35959        }
35960        return;
35961      }
35962      const glyphs = font.charsToGlyphs(chars);
35963      const scale = textState.fontMatrix[0] * textState.fontSize;
35964      for (let i = 0, ii = glyphs.length; i < ii; i++) {
35965        const glyph = glyphs[i];
35966        const {
35967          category,
35968          originalCharCode
35969        } = glyph;
35970        if (category.isInvisibleFormatMark) {
35971          continue;
35972        }
35973        let charSpacing = baseCharSpacing + (i + 1 === ii ? extraSpacing : 0);
35974        let glyphWidth = glyph.width;
35975        if (font.vertical) {
35976          glyphWidth = glyph.vmetric ? glyph.vmetric[0] : -glyphWidth;
35977        }
35978        let scaledDim = glyphWidth * scale;
35979        if (originalCharCode === 0x20) {
35980          charSpacing += textState.wordSpacing;
35981        }
35982        if (!keepWhiteSpace && category.isWhitespace) {
35983          if (!font.vertical) {
35984            charSpacing += scaledDim;
35985            textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
35986          } else {
35987            charSpacing += -scaledDim;
35988            textState.translateTextMatrix(0, -charSpacing);
35989          }
35990          saveLastChar(" ");
35991          continue;
35992        }
35993        if (!category.isZeroWidthDiacritic && !compareWithLastPosition(scaledDim)) {
35994          if (!font.vertical) {
35995            textState.translateTextMatrix(scaledDim * textState.textHScale, 0);
35996          } else {
35997            textState.translateTextMatrix(0, scaledDim);
35998          }
35999          continue;
36000        }
36001        const textChunk = ensureTextContentItem();
36002        if (category.isZeroWidthDiacritic) {
36003          scaledDim = 0;
36004        }
36005        if (!font.vertical) {
36006          scaledDim *= textState.textHScale;
36007          intersector?.addGlyph(getCurrentTextTransform(), scaledDim, 0, glyph.unicode);
36008          textState.translateTextMatrix(scaledDim, 0);
36009          textChunk.width += scaledDim;
36010        } else {
36011          intersector?.addGlyph(getCurrentTextTransform(), 0, scaledDim, glyph.unicode);
36012          textState.translateTextMatrix(0, scaledDim);
36013          scaledDim = Math.abs(scaledDim);
36014          textChunk.height += scaledDim;
36015        }
36016        if (scaledDim) {
36017          textChunk.prevTransform = getCurrentTextTransform();
36018          textChunk.prevTextRise = textState.textRise;
36019        }
36020        const glyphUnicode = glyph.unicode;
36021        if (saveLastChar(glyphUnicode)) {
36022          textChunk.str.push(" ");
36023          intersector?.addExtraChar(" ");
36024        }
36025        if (!intersector) {
36026          textChunk.str.push(glyphUnicode);
36027        }
36028        if (charSpacing) {
36029          if (!font.vertical) {
36030            textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
36031          } else {
36032            textState.translateTextMatrix(0, -charSpacing);
36033          }
36034        }
36035      }
36036    }
36037    function appendEOL() {
36038      intersector?.addExtraChar("\n");
36039      resetLastChars();
36040      if (textContentItem.initialized) {
36041        textContentItem.hasEOL = true;
36042        flushTextContentItem();
36043      } else {
36044        textContent.items.push({
36045          str: "",
36046          dir: "ltr",
36047          width: 0,
36048          height: 0,
36049          transform: getCurrentTextTransform(),
36050          fontName: textState.loadedName,
36051          hasEOL: true
36052        });
36053      }
36054    }
36055    function addFakeSpaces(width, transf, textOrientation) {
36056      if (textOrientation * textContentItem.spaceInFlowMin <= width && width <= textOrientation * textContentItem.spaceInFlowMax) {
36057        if (textContentItem.initialized) {
36058          resetLastChars();
36059          textContentItem.str.push(" ");
36060          intersector?.addExtraChar(" ");
36061        }
36062        return false;
36063      }
36064      const fontName = textContentItem.fontName;
36065      let height = 0;
36066      if (textContentItem.vertical) {
36067        height = width;
36068        width = 0;
36069      }
36070      flushTextContentItem();
36071      resetLastChars();
36072      pushWhitespace({
36073        width: Math.abs(width),
36074        height: Math.abs(height),
36075        transform: transf || getCurrentTextTransform(),
36076        fontName
36077      });
36078      return true;
36079    }
36080    function flushTextContentItem() {
36081      if (!textContentItem.initialized || !textContentItem.str) {
36082        return;
36083      }
36084      if (!textContentItem.vertical) {
36085        textContentItem.totalWidth += textContentItem.width * textContentItem.textAdvanceScale;
36086      } else {
36087        textContentItem.totalHeight += textContentItem.height * textContentItem.textAdvanceScale;
36088      }
36089      textContent.items.push(runBidiTransform(textContentItem));
36090      textContentItem.initialized = false;
36091      textContentItem.str.length = 0;
36092    }
36093    function 
vendor: 2,037 bytes, lines 36093-36155
36093enqueueChunk(batch = false) {
36094      const length = textContent.items.length;
36095      if (length === 0) {
36096        return;
36097      }
36098      if (batch && length < TEXT_CHUNK_BATCH_SIZE) {
36099        return;
36100      }
36101      sink.enqueue(textContent, length);
36102      textContent.items = [];
36103      textContent.styles = Object.create(null);
36104    }
36105    const timeSlotManager = new TimeSlotManager();
36106    return new Promise(function promiseBody(resolve, reject) {
36107      const next = function (promise) {
36108        enqueueChunk(true);
36109        Promise.all([promise, sink.ready]).then(function () {
36110          try {
36111            promiseBody(resolve, reject);
36112          } catch (ex) {
36113            reject(ex);
36114          }
36115        }, reject);
36116      };
36117      task.ensureNotTerminated();
36118      timeSlotManager.reset();
36119      const operation = {};
36120      let stop,
36121        name,
36122        isValidName,
36123        args = [];
36124      while (!(stop = timeSlotManager.check())) {
36125        args.length = 0;
36126        operation.args = args;
36127        if (!preprocessor.read(operation)) {
36128          break;
36129        }
36130        textState = stateManager.state;
36131        currentTextState ||= textState.clone();
36132        const fn = operation.fn;
36133        args = operation.args;
36134        switch (fn | 0) {
36135          case OPS.setFont:
36136            const fontNameArg = args[0].name,
36137              fontSizeArg = args[1];
36138            if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
36139              break;
36140            }
36141            textState.fontName = fontNameArg;
36142            textState.fontSize = fontSizeArg;
36143            next(handleSetFont(fontNameArg, null));
36144            return;
36145          case OPS.setTextRise:
36146            textState.textRise = args[0];
36147            break;
36148          case OPS.setHScale:
36149            textState.textHScale = args[0] / 100;
36150            break;
36151          case OPS.setLeading:
36152            textState.leading = args[0];
36153            break;
36154          case OPS.moveText:
36155            textState.translateTextLineMatrix(args[0], args[1]);
vendor: 5,642 bytes, lines 36156-36300
36156            textState.textMatrix = textState.textLineMatrix.slice();
36157            break;
36158          case OPS.setLeadingMoveText:
36159            textState.leading = -args[1];
36160            textState.translateTextLineMatrix(args[0], args[1]);
36161            textState.textMatrix = textState.textLineMatrix.slice();
36162            break;
36163          case OPS.nextLine:
36164            textState.carriageReturn();
36165            break;
36166          case OPS.setTextMatrix:
36167            textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
36168            textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
36169            updateAdvanceScale();
36170            break;
36171          case OPS.setCharSpacing:
36172            textState.charSpacing = args[0];
36173            break;
36174          case OPS.setWordSpacing:
36175            textState.wordSpacing = args[0];
36176            break;
36177          case OPS.beginText:
36178            textState.textMatrix = IDENTITY_MATRIX.slice();
36179            textState.textLineMatrix = IDENTITY_MATRIX.slice();
36180            break;
36181          case OPS.showSpacedText:
36182            if (!stateManager.state.font) {
36183              self.ensureStateFont(stateManager.state);
36184              continue;
36185            }
36186            const spaceFactor = (textState.font.vertical ? 1 : -1) * textState.fontSize / 1000;
36187            const elements = args[0];
36188            for (let i = 0, ii = elements.length; i < ii; i++) {
36189              const item = elements[i];
36190              if (typeof item === "string") {
36191                showSpacedTextBuffer.push(item);
36192              } else if (typeof item === "number" && item !== 0) {
36193                const str = showSpacedTextBuffer.join("");
36194                showSpacedTextBuffer.length = 0;
36195                buildTextContentItem({
36196                  chars: str,
36197                  extraSpacing: item * spaceFactor
36198                });
36199              }
36200            }
36201            if (showSpacedTextBuffer.length > 0) {
36202              const str = showSpacedTextBuffer.join("");
36203              showSpacedTextBuffer.length = 0;
36204              buildTextContentItem({
36205                chars: str,
36206                extraSpacing: 0
36207              });
36208            }
36209            break;
36210          case OPS.showText:
36211            if (!stateManager.state.font) {
36212              self.ensureStateFont(stateManager.state);
36213              continue;
36214            }
36215            buildTextContentItem({
36216              chars: args[0],
36217              extraSpacing: 0
36218            });
36219            break;
36220          case OPS.nextLineShowText:
36221            if (!stateManager.state.font) {
36222              self.ensureStateFont(stateManager.state);
36223              continue;
36224            }
36225            textState.carriageReturn();
36226            buildTextContentItem({
36227              chars: args[0],
36228              extraSpacing: 0
36229            });
36230            break;
36231          case OPS.nextLineSetSpacingShowText:
36232            if (!stateManager.state.font) {
36233              self.ensureStateFont(stateManager.state);
36234              continue;
36235            }
36236            textState.wordSpacing = args[0];
36237            textState.charSpacing = args[1];
36238            textState.carriageReturn();
36239            buildTextContentItem({
36240              chars: args[2],
36241              extraSpacing: 0
36242            });
36243            break;
36244          case OPS.paintXObject:
36245            flushTextContentItem();
36246            xobjs ??= resources.get("XObject") || Dict.empty;
36247            isValidName = args[0] instanceof Name;
36248            name = args[0].name;
36249            if (isValidName && emptyXObjectCache.getByName(name)) {
36250              break;
36251            }
36252            next(new Promise(function (resolveXObject, rejectXObject) {
36253              if (!isValidName) {
36254                throw new FormatError("XObject must be referred to by name.");
36255              }
36256              let xobj = xobjs.getRaw(name);
36257              if (xobj instanceof Ref) {
36258                if (emptyXObjectCache.getByRef(xobj)) {
36259                  resolveXObject();
36260                  return;
36261                }
36262                const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
36263                if (globalImage) {
36264                  resolveXObject();
36265                  return;
36266                }
36267                xobj = xref.fetch(xobj);
36268              }
36269              if (!(xobj instanceof BaseStream)) {
36270                throw new FormatError("XObject should be a stream");
36271              }
36272              const {
36273                dict
36274              } = xobj;
36275              const type = dict.get("Subtype");
36276              if (!(type instanceof Name)) {
36277                throw new FormatError("XObject should have a Name subtype");
36278              }
36279              if (type.name !== "Form") {
36280                emptyXObjectCache.set(name, dict.objId, true);
36281                resolveXObject();
36282                return;
36283              }
36284              const currentState = stateManager.state.clone();
36285              const xObjStateManager = new StateManager(currentState);
36286              const matrix = lookupMatrix(dict.getArray("Matrix"), null);
36287              if (matrix) {
36288                xObjStateManager.transform(matrix);
36289              }
36290              const localResources = dict.get("Resources");
36291              enqueueChunk();
36292              const sinkWrapper = textSinkWrapper(sink);
36293              self.getTextContent({
36294                stream: xobj,
36295                task,
36296                resources: localResources instanceof Dict ? localResources : resources,
36297                stateManager: xObjStateManager,
36298                includeMarkedContent,
36299                sink: sinkWrapper,
36300                seenStyles,
vendor: 4,183 bytes, lines 36301-36416
36301                viewBox,
36302                lang,
36303                markedContentData,
36304                disableNormalization,
36305                keepWhiteSpace,
36306                prevRefs: seenRefs
36307              }).then(function () {
36308                if (!sinkWrapper.enqueueInvoked) {
36309                  emptyXObjectCache.set(name, dict.objId, true);
36310                }
36311                resolveXObject();
36312              }, rejectXObject);
36313            }).catch(function (reason) {
36314              if (reason instanceof AbortException) {
36315                return;
36316              }
36317              if (self.options.ignoreErrors) {
36318                warn(`getTextContent - ignoring XObject: "${reason}".`);
36319                return;
36320              }
36321              throw reason;
36322            }));
36323            return;
36324          case OPS.setGState:
36325            isValidName = args[0] instanceof Name;
36326            name = args[0].name;
36327            if (isValidName && emptyGStateCache.getByName(name)) {
36328              break;
36329            }
36330            next(new Promise(function (resolveGState, rejectGState) {
36331              if (!isValidName) {
36332                throw new FormatError("GState must be referred to by name.");
36333              }
36334              const extGState = resources.get("ExtGState");
36335              if (!(extGState instanceof Dict)) {
36336                throw new FormatError("ExtGState should be a dictionary.");
36337              }
36338              const gState = extGState.get(name);
36339              if (!(gState instanceof Dict)) {
36340                throw new FormatError("GState should be a dictionary.");
36341              }
36342              const gStateFont = gState.get("Font");
36343              if (!gStateFont) {
36344                emptyGStateCache.set(name, gState.objId, true);
36345                resolveGState();
36346                return;
36347              }
36348              flushTextContentItem();
36349              textState.fontName = null;
36350              textState.fontSize = gStateFont[1];
36351              handleSetFont(null, gStateFont[0]).then(resolveGState, rejectGState);
36352            }).catch(function (reason) {
36353              if (reason instanceof AbortException) {
36354                return;
36355              }
36356              if (self.options.ignoreErrors) {
36357                warn(`getTextContent - ignoring ExtGState: "${reason}".`);
36358                return;
36359              }
36360              throw reason;
36361            }));
36362            return;
36363          case OPS.beginMarkedContent:
36364            flushTextContentItem();
36365            if (includeMarkedContent) {
36366              markedContentData.level++;
36367              textContent.items.push({
36368                type: "beginMarkedContent",
36369                tag: args[0] instanceof Name ? args[0].name : null
36370              });
36371            }
36372            break;
36373          case OPS.beginMarkedContentProps:
36374            flushTextContentItem();
36375            if (includeMarkedContent) {
36376              markedContentData.level++;
36377              const mcid = args[1] instanceof Dict ? args[1].get("MCID") : null;
36378              textContent.items.push({
36379                type: "beginMarkedContentProps",
36380                id: Number.isInteger(mcid) ? `${self.idFactory.getPageObjId()}_mc${mcid}` : null,
36381                tag: args[0] instanceof Name ? args[0].name : null
36382              });
36383            }
36384            break;
36385          case OPS.endMarkedContent:
36386            flushTextContentItem();
36387            if (includeMarkedContent) {
36388              if (markedContentData.level === 0) {
36389                break;
36390              }
36391              markedContentData.level--;
36392              textContent.items.push({
36393                type: "endMarkedContent"
36394              });
36395            }
36396            break;
36397        }
36398        if (textContent.items.length >= sink.desiredSize) {
36399          stop = true;
36400          break;
36401        }
36402      }
36403      if (stop) {
36404        next(deferred);
36405        return;
36406      }
36407      flushTextContentItem();
36408      enqueueChunk();
36409      resolve();
36410    }).catch(reason => {
36411      if (reason instanceof AbortException) {
36412        return;
36413      }
36414      if (this.options.ignoreErrors) {
36415        warn(`getTextContent - ignoring errors during "${task.name}" ` + `task: "${reason}".`);
36416        flushTextContentItem
vendor: 30,887 bytes, lines 36416-37280
36416();
36417        enqueueChunk();
36418        return;
36419      }
36420      throw reason;
36421    });
36422  }
36423  async extractDataStructures(dict, properties) {
36424    const xref = this.xref;
36425    let cidToGidBytes;
36426    const toUnicodePromise = this.readToUnicode(properties.toUnicode);
36427    if (properties.composite) {
36428      const cidSystemInfo = dict.get("CIDSystemInfo");
36429      if (cidSystemInfo instanceof Dict && !properties.cidSystemInfo) {
36430        properties.cidSystemInfo = {
36431          registry: stringToPDFString(cidSystemInfo.get("Registry")),
36432          ordering: stringToPDFString(cidSystemInfo.get("Ordering")),
36433          supplement: cidSystemInfo.get("Supplement")
36434        };
36435      }
36436      try {
36437        const cidToGidMap = dict.get("CIDToGIDMap");
36438        if (cidToGidMap instanceof BaseStream) {
36439          cidToGidBytes = cidToGidMap.getBytes();
36440        }
36441      } catch (ex) {
36442        if (!this.options.ignoreErrors) {
36443          throw ex;
36444        }
36445        warn(`extractDataStructures - ignoring CIDToGIDMap data: "${ex}".`);
36446      }
36447    }
36448    const differences = [];
36449    let baseEncodingName = null;
36450    let encoding;
36451    if (dict.has("Encoding")) {
36452      encoding = dict.get("Encoding");
36453      if (encoding instanceof Dict) {
36454        baseEncodingName = encoding.get("BaseEncoding");
36455        baseEncodingName = baseEncodingName instanceof Name ? baseEncodingName.name : null;
36456        if (encoding.has("Differences")) {
36457          const diffEncoding = encoding.get("Differences");
36458          let index = 0;
36459          for (const entry of diffEncoding) {
36460            const data = xref.fetchIfRef(entry);
36461            if (typeof data === "number") {
36462              index = data;
36463            } else if (data instanceof Name) {
36464              differences[index++] = data.name;
36465            } else {
36466              throw new FormatError(`Invalid entry in 'Differences' array: ${data}`);
36467            }
36468          }
36469        }
36470      } else if (encoding instanceof Name) {
36471        baseEncodingName = encoding.name;
36472      } else {
36473        const msg = "Encoding is not a Name nor a Dict";
36474        if (!this.options.ignoreErrors) {
36475          throw new FormatError(msg);
36476        }
36477        warn(msg);
36478      }
36479      if (baseEncodingName !== "MacRomanEncoding" && baseEncodingName !== "MacExpertEncoding" && baseEncodingName !== "WinAnsiEncoding") {
36480        baseEncodingName = null;
36481      }
36482    }
36483    const nonEmbeddedFont = !properties.file || properties.isInternalFont,
36484      isSymbolsFontName = getSymbolsFonts()[properties.name];
36485    if (baseEncodingName && nonEmbeddedFont && isSymbolsFontName) {
36486      baseEncodingName = null;
36487    }
36488    if (baseEncodingName === "WinAnsiEncoding" && nonEmbeddedFont && properties.name?.charCodeAt(0) >= 0xb7) {
36489      const fontName = properties.name;
36490      const chineseFontNames = ["\xCB\xCE\xCC\xE5", "\xBA\xDA\xCC\xE5", "\xBF\xAC\xCC\xE5", "\xB7\xC2\xCB\xCE", "\xBF\xAC\xCC\xE5_GB2312", "\xB7\xC2\xCB\xCE_GB2312", "\xC1\xA5\xCA\xE9", "\xD0\xC2\xCB\xCE", "\xB7\xC2\xCB\xCE\xCC\xE5", "\xD0\xA1\xB1\xEA\xCB\xCE"];
36491      if (chineseFontNames.includes(fontName)) {
36492        baseEncodingName = null;
36493        properties.defaultEncoding = "Adobe-GB1-UCS2";
36494        properties.composite = true;
36495        properties.cidEncoding = Name.get("GBK-EUC-H");
36496        const cMap = await CMapFactory.create({
36497          encoding: properties.cidEncoding,
36498          fetchBuiltInCMap: this._fetchBuiltInCMapBound,
36499          useCMap: null
36500        });
36501        properties.cMap = cMap;
36502        properties.vertical = properties.cMap.vertical;
36503        properties.cidSystemInfo = {
36504          registry: "Adobe",
36505          ordering: "GB1",
36506          supplement: 0
36507        };
36508      }
36509    }
36510    if (baseEncodingName) {
36511      properties.defaultEncoding = getEncoding(baseEncodingName);
36512    } else {
36513      let isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
36514      const isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
36515      if (properties.type === "TrueType" && isSymbolicFont && isNonsymbolicFont && differences.length !== 0) {
36516        properties.flags &= ~FontFlags.Symbolic;
36517        isSymbolicFont = false;
36518      }
36519      encoding = StandardEncoding;
36520      if (properties.type === "TrueType" && !isNonsymbolicFont) {
36521        encoding = WinAnsiEncoding;
36522      }
36523      if (isSymbolicFont || isSymbolsFontName) {
36524        encoding = MacRomanEncoding;
36525        if (nonEmbeddedFont) {
36526          if (/Symbol/i.test(properties.name)) {
36527            encoding = SymbolSetEncoding;
36528          } else if (/Dingbats/i.test(properties.name)) {
36529            encoding = ZapfDingbatsEncoding;
36530          } else if (/Wingdings/i.test(properties.name)) {
36531            encoding = WinAnsiEncoding;
36532          }
36533        }
36534      }
36535      properties.defaultEncoding = encoding;
36536    }
36537    properties.differences = differences;
36538    properties.baseEncodingName = baseEncodingName;
36539    properties.hasEncoding = !!baseEncodingName || differences.length > 0;
36540    properties.dict = dict;
36541    properties.toUnicode = await toUnicodePromise;
36542    const builtToUnicode = await this.buildToUnicode(properties);
36543    properties.toUnicode = builtToUnicode;
36544    if (cidToGidBytes) {
36545      properties.cidToGidMap = this.readCidToGidMap(cidToGidBytes, builtToUnicode);
36546    }
36547    return properties;
36548  }
36549  _simpleFontToUnicode(properties, forceGlyphs = false) {
36550    assert(!properties.composite, "Must be a simple font.");
36551    const toUnicode = [];
36552    const encoding = properties.defaultEncoding.slice();
36553    const baseEncodingName = properties.baseEncodingName;
36554    const differences = properties.differences;
36555    for (const charcode in differences) {
36556      const glyphName = differences[charcode];
36557      if (glyphName === ".notdef") {
36558        continue;
36559      }
36560      encoding[charcode] = glyphName;
36561    }
36562    const glyphsUnicodeMap = getGlyphsUnicode();
36563    for (const charcode in encoding) {
36564      let glyphName = encoding[charcode];
36565      if (glyphName === "") {
36566        continue;
36567      }
36568      let unicode = glyphsUnicodeMap[glyphName];
36569      if (unicode !== undefined) {
36570        toUnicode[charcode] = String.fromCharCode(unicode);
36571        continue;
36572      }
36573      let code = 0;
36574      switch (glyphName[0]) {
36575        case "G":
36576          if (glyphName.length === 3) {
36577            code = parseInt(glyphName.substring(1), 16);
36578          }
36579          break;
36580        case "g":
36581          if (glyphName.length === 5) {
36582            code = parseInt(glyphName.substring(1), 16);
36583          }
36584          break;
36585        case "C":
36586        case "c":
36587          if (glyphName.length >= 3 && glyphName.length <= 4) {
36588            const codeStr = glyphName.substring(1);
36589            if (forceGlyphs) {
36590              code = parseInt(codeStr, 16);
36591              break;
36592            }
36593            code = +codeStr;
36594            if (Number.isNaN(code) && Number.isInteger(parseInt(codeStr, 16))) {
36595              return this._simpleFontToUnicode(properties, true);
36596            }
36597          }
36598          break;
36599        case "u":
36600          unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
36601          if (unicode !== -1) {
36602            code = unicode;
36603          }
36604          break;
36605        default:
36606          switch (glyphName) {
36607            case "f_h":
36608            case "f_t":
36609            case "T_h":
36610              toUnicode[charcode] = glyphName.replaceAll("_", "");
36611              continue;
36612          }
36613          break;
36614      }
36615      if (code > 0 && code <= 0x10ffff && Number.isInteger(code)) {
36616        if (baseEncodingName && code === +charcode) {
36617          const baseEncoding = getEncoding(baseEncodingName);
36618          if (baseEncoding && (glyphName = baseEncoding[charcode])) {
36619            toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
36620            continue;
36621          }
36622        }
36623        toUnicode[charcode] = String.fromCodePoint(code);
36624      }
36625    }
36626    return toUnicode;
36627  }
36628  async buildToUnicode(properties) {
36629    properties.hasIncludedToUnicodeMap = properties.toUnicode?.length > 0;
36630    if (properties.hasIncludedToUnicodeMap) {
36631      if (!properties.composite && properties.hasEncoding) {
36632        properties.fallbackToUnicode = this._simpleFontToUnicode(properties);
36633      }
36634      return properties.toUnicode;
36635    }
36636    if (!properties.composite) {
36637      return new ToUnicodeMap(this._simpleFontToUnicode(properties));
36638    }
36639    if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo?.registry === "Adobe" && (properties.cidSystemInfo.ordering === "GB1" || properties.cidSystemInfo.ordering === "CNS1" || properties.cidSystemInfo.ordering === "Japan1" || properties.cidSystemInfo.ordering === "Korea1"))) {
36640      const {
36641        registry,
36642        ordering
36643      } = properties.cidSystemInfo;
36644      const ucs2CMapName = Name.get(`${registry}-${ordering}-UCS2`);
36645      const ucs2CMap = await CMapFactory.create({
36646        encoding: ucs2CMapName,
36647        fetchBuiltInCMap: this._fetchBuiltInCMapBound,
36648        useCMap: null
36649      });
36650      const toUnicode = [],
36651        buf = [];
36652      properties.cMap.forEach(function (charcode, cid) {
36653        if (cid > 0xffff) {
36654          throw new FormatError("Max size of CID is 65,535");
36655        }
36656        const ucs2 = ucs2CMap.lookup(cid);
36657        if (ucs2) {
36658          buf.length = 0;
36659          for (let i = 0, ii = ucs2.length; i < ii; i += 2) {
36660            buf.push((ucs2.charCodeAt(i) << 8) + ucs2.charCodeAt(i + 1));
36661          }
36662          toUnicode[charcode] = String.fromCharCode(...buf);
36663        }
36664      });
36665      return new ToUnicodeMap(toUnicode);
36666    }
36667    return new IdentityToUnicodeMap(properties.firstChar, properties.lastChar);
36668  }
36669  async readToUnicode(cmapObj) {
36670    if (!cmapObj) {
36671      return null;
36672    }
36673    if (cmapObj instanceof Name) {
36674      const cmap = await CMapFactory.create({
36675        encoding: cmapObj,
36676        fetchBuiltInCMap: this._fetchBuiltInCMapBound,
36677        useCMap: null
36678      });
36679      if (cmap instanceof IdentityCMap) {
36680        return new IdentityToUnicodeMap(0, 0xffff);
36681      }
36682      return new ToUnicodeMap(cmap.getMap());
36683    }
36684    if (cmapObj instanceof BaseStream) {
36685      try {
36686        const cmap = await CMapFactory.create({
36687          encoding: cmapObj,
36688          fetchBuiltInCMap: this._fetchBuiltInCMapBound,
36689          useCMap: null
36690        });
36691        if (cmap instanceof IdentityCMap) {
36692          return new IdentityToUnicodeMap(0, 0xffff);
36693        }
36694        const map = new Array(cmap.length);
36695        cmap.forEach(function (charCode, token) {
36696          if (typeof token === "number") {
36697            map[charCode] = String.fromCodePoint(token);
36698            return;
36699          }
36700          if (token.length % 2 !== 0) {
36701            token = "\u0000" + token;
36702          }
36703          const str = [];
36704          for (let k = 0; k < token.length; k += 2) {
36705            const w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
36706            if ((w1 & 0xf800) !== 0xd800) {
36707              str.push(w1);
36708              continue;
36709            }
36710            k += 2;
36711            const w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
36712            str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
36713          }
36714          map[charCode] = String.fromCodePoint(...str);
36715        });
36716        return new ToUnicodeMap(map);
36717      } catch (reason) {
36718        if (reason instanceof AbortException) {
36719          return null;
36720        }
36721        if (this.options.ignoreErrors) {
36722          warn(`readToUnicode - ignoring ToUnicode data: "${reason}".`);
36723          return null;
36724        }
36725        throw reason;
36726      }
36727    }
36728    return null;
36729  }
36730  readCidToGidMap(glyphsData, toUnicode) {
36731    const result = [];
36732    for (let j = 0, jj = glyphsData.length; j < jj; j++) {
36733      const glyphID = glyphsData[j++] << 8 | glyphsData[j];
36734      const code = j >> 1;
36735      if (glyphID === 0 && !toUnicode.has(code)) {
36736        continue;
36737      }
36738      result[code] = glyphID;
36739    }
36740    return result;
36741  }
36742  extractWidths(dict, descriptor, properties) {
36743    const xref = this.xref;
36744    let glyphsWidths = [];
36745    let defaultWidth = 0;
36746    const glyphsVMetrics = [];
36747    let defaultVMetrics;
36748    if (properties.composite) {
36749      const dw = dict.get("DW");
36750      defaultWidth = typeof dw === "number" ? Math.ceil(dw) : 1000;
36751      const widths = dict.get("W");
36752      if (Array.isArray(widths)) {
36753        for (let i = 0, ii = widths.length; i < ii; i++) {
36754          let start = xref.fetchIfRef(widths[i++]);
36755          if (!Number.isInteger(start)) {
36756            break;
36757          }
36758          const code = xref.fetchIfRef(widths[i]);
36759          if (Array.isArray(code)) {
36760            for (const c of code) {
36761              const width = xref.fetchIfRef(c);
36762              if (typeof width === "number") {
36763                glyphsWidths[start] = width;
36764              }
36765              start++;
36766            }
36767          } else if (Number.isInteger(code)) {
36768            const width = xref.fetchIfRef(widths[++i]);
36769            if (typeof width !== "number") {
36770              continue;
36771            }
36772            for (let j = start; j <= code; j++) {
36773              glyphsWidths[j] = width;
36774            }
36775          } else {
36776            break;
36777          }
36778        }
36779      }
36780      if (properties.vertical) {
36781        const dw2 = dict.getArray("DW2");
36782        let vmetrics = isNumberArray(dw2, 2) ? dw2 : [880, -1000];
36783        defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
36784        vmetrics = dict.get("W2");
36785        if (Array.isArray(vmetrics)) {
36786          for (let i = 0, ii = vmetrics.length; i < ii; i++) {
36787            let start = xref.fetchIfRef(vmetrics[i++]);
36788            if (!Number.isInteger(start)) {
36789              break;
36790            }
36791            const code = xref.fetchIfRef(vmetrics[i]);
36792            if (Array.isArray(code)) {
36793              for (let j = 0, jj = code.length; j < jj; j++) {
36794                const vmetric = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
36795                if (isNumberArray(vmetric, null)) {
36796                  glyphsVMetrics[start] = vmetric;
36797                }
36798                start++;
36799              }
36800            } else if (Number.isInteger(code)) {
36801              const vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
36802              if (!isNumberArray(vmetric, null)) {
36803                continue;
36804              }
36805              for (let j = start; j <= code; j++) {
36806                glyphsVMetrics[j] = vmetric;
36807              }
36808            } else {
36809              break;
36810            }
36811          }
36812        }
36813      }
36814    } else {
36815      const widths = dict.get("Widths");
36816      if (Array.isArray(widths)) {
36817        let j = properties.firstChar;
36818        for (const w of widths) {
36819          const width = xref.fetchIfRef(w);
36820          if (typeof width === "number") {
36821            glyphsWidths[j] = width;
36822          }
36823          j++;
36824        }
36825        const missingWidth = descriptor.get("MissingWidth");
36826        defaultWidth = typeof missingWidth === "number" ? missingWidth : 0;
36827      } else {
36828        const baseFontName = dict.get("BaseFont");
36829        if (baseFontName instanceof Name) {
36830          const metrics = this.getBaseFontMetrics(baseFontName.name);
36831          glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
36832          defaultWidth = metrics.defaultWidth;
36833        }
36834      }
36835    }
36836    let isMonospace = true;
36837    let firstWidth = defaultWidth;
36838    for (const glyph in glyphsWidths) {
36839      const glyphWidth = glyphsWidths[glyph];
36840      if (!glyphWidth) {
36841        continue;
36842      }
36843      if (!firstWidth) {
36844        firstWidth = glyphWidth;
36845        continue;
36846      }
36847      if (firstWidth !== glyphWidth) {
36848        isMonospace = false;
36849        break;
36850      }
36851    }
36852    if (isMonospace) {
36853      properties.flags |= FontFlags.FixedPitch;
36854    } else {
36855      properties.flags &= ~FontFlags.FixedPitch;
36856    }
36857    properties.defaultWidth = defaultWidth;
36858    properties.widths = glyphsWidths;
36859    properties.defaultVMetrics = defaultVMetrics;
36860    properties.vmetrics = glyphsVMetrics;
36861  }
36862  isSerifFont(baseFontName) {
36863    const fontNameWoStyle = baseFontName.split("-", 1)[0];
36864    return fontNameWoStyle in getSerifFonts() || /serif/i.test(fontNameWoStyle);
36865  }
36866  getBaseFontMetrics(name) {
36867    let defaultWidth = 0;
36868    let widths = Object.create(null);
36869    let monospace = false;
36870    let fontName = normalizeFontName(name);
36871    const stdFontMap = getStdFontMap();
36872    fontName = stdFontMap[fontName] || fontName;
36873    const Metrics = getMetrics();
36874    const glyphWidths = Metrics[fontName] ?? Metrics[this.isSerifFont(name) ? "Times-Roman" : "Helvetica"];
36875    if (typeof glyphWidths === "number") {
36876      defaultWidth = glyphWidths;
36877      monospace = true;
36878    } else {
36879      widths = glyphWidths();
36880    }
36881    return {
36882      defaultWidth,
36883      monospace,
36884      widths
36885    };
36886  }
36887  buildCharCodeToWidth(widthsByGlyphName, properties) {
36888    const widths = Object.create(null);
36889    const differences = properties.differences;
36890    const encoding = properties.defaultEncoding;
36891    for (let charCode = 0; charCode < 256; charCode++) {
36892      if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
36893        widths[charCode] = widthsByGlyphName[differences[charCode]];
36894        continue;
36895      }
36896      if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
36897        widths[charCode] = widthsByGlyphName[encoding[charCode]];
36898        continue;
36899      }
36900    }
36901    return widths;
36902  }
36903  preEvaluateFont(dict) {
36904    const baseDict = dict;
36905    let type = dict.get("Subtype");
36906    if (!(type instanceof Name)) {
36907      throw new FormatError("invalid font Subtype");
36908    }
36909    let composite = false;
36910    let hash;
36911    if (type.name === "Type0") {
36912      const df = dict.get("DescendantFonts");
36913      if (!df) {
36914        throw new FormatError("Descendant fonts are not specified");
36915      }
36916      dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
36917      if (!(dict instanceof Dict)) {
36918        throw new FormatError("Descendant font is not a dictionary.");
36919      }
36920      type = dict.get("Subtype");
36921      if (!(type instanceof Name)) {
36922        throw new FormatError("invalid font Subtype");
36923      }
36924      composite = true;
36925    }
36926    let firstChar = dict.get("FirstChar");
36927    if (!Number.isInteger(firstChar)) {
36928      firstChar = 0;
36929    }
36930    let lastChar = dict.get("LastChar");
36931    if (!Number.isInteger(lastChar)) {
36932      lastChar = composite ? 0xffff : 0xff;
36933    }
36934    const descriptor = dict.get("FontDescriptor");
36935    const toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
36936    if (descriptor) {
36937      hash = new MurmurHash3_64();
36938      const encoding = baseDict.getRaw("Encoding");
36939      if (encoding instanceof Name) {
36940        hash.update(encoding.name);
36941      } else if (encoding instanceof Ref) {
36942        hash.update(encoding.toString());
36943      } else if (encoding instanceof Dict) {
36944        for (const entry of encoding.getRawValues()) {
36945          if (entry instanceof Name) {
36946            hash.update(entry.name);
36947          } else if (entry instanceof Ref) {
36948            hash.update(entry.toString());
36949          } else if (Array.isArray(entry)) {
36950            const diffLength = entry.length,
36951              diffBuf = new Array(diffLength);
36952            for (let j = 0; j < diffLength; j++) {
36953              const diffEntry = entry[j];
36954              if (diffEntry instanceof Name) {
36955                diffBuf[j] = diffEntry.name;
36956              } else if (typeof diffEntry === "number" || diffEntry instanceof Ref) {
36957                diffBuf[j] = diffEntry.toString();
36958              }
36959            }
36960            hash.update(diffBuf.join());
36961          }
36962        }
36963      }
36964      hash.update(`${firstChar}-${lastChar}`);
36965      if (toUnicode instanceof BaseStream) {
36966        const stream = toUnicode.stream || toUnicode;
36967        const uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
36968        hash.update(uint8array);
36969      } else if (toUnicode instanceof Name) {
36970        hash.update(toUnicode.name);
36971      }
36972      const widths = dict.get("Widths") || baseDict.get("Widths");
36973      if (Array.isArray(widths)) {
36974        const widthsBuf = [];
36975        for (const entry of widths) {
36976          if (typeof entry === "number" || entry instanceof Ref) {
36977            widthsBuf.push(entry.toString());
36978          }
36979        }
36980        hash.update(widthsBuf.join());
36981      }
36982      if (composite) {
36983        hash.update("compositeFont");
36984        const compositeWidths = dict.get("W") || baseDict.get("W");
36985        if (Array.isArray(compositeWidths)) {
36986          const widthsBuf = [];
36987          for (const entry of compositeWidths) {
36988            if (typeof entry === "number" || entry instanceof Ref) {
36989              widthsBuf.push(entry.toString());
36990            } else if (Array.isArray(entry)) {
36991              const subWidthsBuf = [];
36992              for (const element of entry) {
36993                if (typeof element === "number" || element instanceof Ref) {
36994                  subWidthsBuf.push(element.toString());
36995                }
36996              }
36997              widthsBuf.push(`[${subWidthsBuf.join()}]`);
36998            }
36999          }
37000          hash.update(widthsBuf.join());
37001        }
37002        const cidToGidMap = dict.getRaw("CIDToGIDMap") || baseDict.getRaw("CIDToGIDMap");
37003        if (cidToGidMap instanceof Name) {
37004          hash.update(cidToGidMap.name);
37005        } else if (cidToGidMap instanceof Ref) {
37006          hash.update(cidToGidMap.toString());
37007        } else if (cidToGidMap instanceof BaseStream) {
37008          hash.update(cidToGidMap.peekBytes());
37009        }
37010      }
37011      if (type.name === "Type3") {
37012        const charProcs = baseDict.get("CharProcs");
37013        if (charProcs instanceof Dict) {
37014          for (const [key, entry] of charProcs.getRawEntries()) {
37015            hash.update(entry instanceof Ref ? `${key}\0${entry}` : key);
37016          }
37017        }
37018      }
37019    }
37020    return {
37021      descriptor,
37022      dict,
37023      baseDict,
37024      composite,
37025      type: type.name,
37026      firstChar,
37027      lastChar,
37028      toUnicode,
37029      hash: hash ? hash.hexdigest() : ""
37030    };
37031  }
37032  async translateFont({
37033    descriptor,
37034    dict,
37035    baseDict,
37036    composite,
37037    type,
37038    firstChar,
37039    lastChar,
37040    toUnicode,
37041    cssFontInfo
37042  }) {
37043    const isType3Font = type === "Type3";
37044    if (!descriptor) {
37045      if (isType3Font) {
37046        descriptor = Dict.empty;
37047      } else if (composite) {
37048        descriptor = Dict.empty;
37049      } else {
37050        let baseFontName = dict.get("BaseFont");
37051        if (!(baseFontName instanceof Name)) {
37052          throw new FormatError("Base font is not specified");
37053        }
37054        baseFontName = normalizeFontName(baseFontName.name);
37055        const metrics = this.getBaseFontMetrics(baseFontName);
37056        const fontNameWoStyle = baseFontName.split("-", 1)[0];
37057        const flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
37058        const properties = {
37059          type,
37060          name: baseFontName,
37061          loadedName: baseDict.loadedName,
37062          systemFontInfo: null,
37063          widths: metrics.widths,
37064          defaultWidth: metrics.defaultWidth,
37065          isSimulatedFlags: true,
37066          flags,
37067          firstChar,
37068          lastChar,
37069          toUnicode,
37070          xHeight: 0,
37071          capHeight: 0,
37072          italicAngle: 0,
37073          isType3Font
37074        };
37075        const widths = dict.get("Widths");
37076        const standardFontName = getStandardFontName(baseFontName);
37077        let file = null;
37078        if (standardFontName) {
37079          file = await this.fetchStandardFontData(standardFontName);
37080          properties.isInternalFont = !!file;
37081        }
37082        if (!properties.isInternalFont && this.options.useSystemFonts) {
37083          properties.systemFontInfo = getFontSubstitution(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, baseFontName, standardFontName, type);
37084        }
37085        const newProperties = await this.extractDataStructures(dict, properties);
37086        if (Array.isArray(widths)) {
37087          const glyphWidths = [];
37088          let j = firstChar;
37089          for (const w of widths) {
37090            const width = this.xref.fetchIfRef(w);
37091            if (typeof width === "number") {
37092              glyphWidths[j] = width;
37093            }
37094            j++;
37095          }
37096          newProperties.widths = glyphWidths;
37097        } else {
37098          newProperties.widths = this.buildCharCodeToWidth(metrics.widths, newProperties);
37099        }
37100        return new Font(baseFontName, file, newProperties, this.options);
37101      }
37102    }
37103    let fontName = descriptor.get("FontName");
37104    let baseFont = dict.get("BaseFont");
37105    if (typeof fontName === "string") {
37106      fontName = Name.get(fontName);
37107    }
37108    if (typeof baseFont === "string") {
37109      baseFont = Name.get(baseFont);
37110    }
37111    const fontNameStr = fontName?.name;
37112    const baseFontStr = baseFont?.name;
37113    if (isType3Font) {
37114      if (!fontNameStr) {
37115        fontName = Name.get(type);
37116      }
37117    } else if (fontNameStr !== baseFontStr) {
37118      info(`The FontDescriptor's FontName is "${fontNameStr}" but ` + `should be the same as the Font's BaseFont "${baseFontStr}".`);
37119      if (fontNameStr && baseFontStr && (baseFontStr.startsWith(fontNameStr) || !isKnownFontName(fontNameStr) && isKnownFontName(baseFontStr))) {
37120        fontName = null;
37121      }
37122      fontName ||= baseFont;
37123    }
37124    if (!(fontName instanceof Name)) {
37125      throw new FormatError("invalid font name");
37126    }
37127    let fontFile, fontFileN, subtype, length1, length2, length3;
37128    try {
37129      for (const n of ["FontFile", "FontFile2", "FontFile3"]) {
37130        fontFile = descriptor.get(n);
37131        if (fontFile) {
37132          fontFileN = n;
37133          break;
37134        }
37135      }
37136      if (fontFile) {
37137        if (!(fontFile instanceof BaseStream)) {
37138          throw new FormatError("FontFile should be a stream");
37139        } else {
37140          if (fontFile.isAsync) {
37141            const bytes = await fontFile.asyncGetBytes();
37142            if (bytes) {
37143              fontFile = new Stream(bytes, 0, bytes.length, fontFile.dict);
37144            }
37145          }
37146          if (fontFile.isEmpty) {
37147            throw new FormatError("FontFile is empty");
37148          }
37149        }
37150      }
37151    } catch (ex) {
37152      if (!this.options.ignoreErrors) {
37153        throw ex;
37154      }
37155      warn(`translateFont - fetching "${fontName.name}" font file: "${ex}".`);
37156      fontFile = null;
37157    }
37158    let isInternalFont = false;
37159    let glyphScaleFactors = null;
37160    let systemFontInfo = null;
37161    if (fontFile) {
37162      if (fontFile.dict) {
37163        const subtypeEntry = fontFile.dict.get("Subtype");
37164        if (subtypeEntry instanceof Name) {
37165          subtype = subtypeEntry.name;
37166        }
37167        length1 = fontFile.dict.get("Length1");
37168        length2 = fontFile.dict.get("Length2");
37169        length3 = fontFile.dict.get("Length3");
37170      }
37171    } else if (cssFontInfo) {
37172      const standardFontName = getXfaFontName(fontName.name);
37173      if (standardFontName) {
37174        cssFontInfo.fontFamily = `${cssFontInfo.fontFamily}-PdfJS-XFA`;
37175        cssFontInfo.metrics = standardFontName.metrics || null;
37176        glyphScaleFactors = standardFontName.factors || null;
37177        fontFile = await this.fetchStandardFontData(standardFontName.name);
37178        isInternalFont = !!fontFile;
37179        baseDict = dict = getXfaFontDict(fontName.name);
37180        composite = true;
37181      }
37182    } else if (!isType3Font) {
37183      const standardFontName = getStandardFontName(fontName.name);
37184      if (standardFontName) {
37185        fontFile = await this.fetchStandardFontData(standardFontName);
37186        isInternalFont = !!fontFile;
37187      }
37188      if (!isInternalFont && this.options.useSystemFonts) {
37189        systemFontInfo = getFontSubstitution(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, fontName.name, standardFontName, type);
37190      }
37191    }
37192    const fontMatrix = lookupMatrix(dict.getArray("FontMatrix"), FONT_IDENTITY_MATRIX);
37193    const bbox = lookupNormalRect(descriptor.getArray("FontBBox") || dict.getArray("FontBBox"), isType3Font ? [0, 0, 0, 0] : undefined);
37194    let ascent = descriptor.get("Ascent");
37195    if (typeof ascent !== "number") {
37196      ascent = undefined;
37197    }
37198    let descent = descriptor.get("Descent");
37199    if (typeof descent !== "number") {
37200      descent = undefined;
37201    }
37202    let xHeight = descriptor.get("XHeight");
37203    if (typeof xHeight !== "number") {
37204      xHeight = 0;
37205    }
37206    let capHeight = descriptor.get("CapHeight");
37207    if (typeof capHeight !== "number") {
37208      capHeight = 0;
37209    }
37210    let flags = descriptor.get("Flags");
37211    if (!Number.isInteger(flags)) {
37212      flags = 0;
37213    }
37214    let italicAngle = descriptor.get("ItalicAngle");
37215    if (typeof italicAngle !== "number") {
37216      italicAngle = 0;
37217    }
37218    const properties = {
37219      type,
37220      name: fontName.name,
37221      subtype,
37222      file: fontFile,
37223      fontFileN,
37224      length1,
37225      length2,
37226      length3,
37227      isInternalFont,
37228      loadedName: baseDict.loadedName,
37229      composite,
37230      fixedPitch: false,
37231      fontMatrix,
37232      firstChar,
37233      lastChar,
37234      toUnicode,
37235      bbox,
37236      ascent,
37237      descent,
37238      xHeight,
37239      capHeight,
37240      flags,
37241      italicAngle,
37242      isType3Font,
37243      cssFontInfo,
37244      scaleFactors: glyphScaleFactors,
37245      systemFontInfo
37246    };
37247    if (composite) {
37248      const cidEncoding = baseDict.get("Encoding");
37249      if (cidEncoding instanceof Name) {
37250        properties.cidEncoding = cidEncoding.name;
37251      }
37252      const cMap = await CMapFactory.create({
37253        encoding: cidEncoding,
37254        fetchBuiltInCMap: this._fetchBuiltInCMapBound,
37255        useCMap: null
37256      });
37257      properties.cMap = cMap;
37258      properties.vertical = properties.cMap.vertical;
37259    }
37260    const newProperties = await this.extractDataStructures(dict, properties);
37261    this.extractWidths(dict, descriptor, newProperties);
37262    const font = new Font(fontName.name, fontFile, newProperties, this.options);
37263    if (font.missingFile && !font.systemFontInfo && !isType3Font && this.options.useSystemFonts) {
37264      const standardFontName = getStandardFontName(fontName.name);
37265      const substitution = getFontSubstitution(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, fontName.name, standardFontName, type);
37266      if (substitution) {
37267        if (substitution.guessFallback) {
37268          substitution.guessFallback = false;
37269          substitution.css += `,${font.fallbackName}`;
37270        }
37271        font.systemFontInfo = substitution;
37272      }
37273    }
37274    return font;
37275  }
37276  static buildFontPaths(font, glyphs, handler, evaluatorOptions) {
37277    function buildPath(fontChar) {
37278      const glyphName = `${font.loadedName}_path_${fontChar}`;
37279      try {
37280        
37280if (font.renderer.hasBuiltPath(fontChar)) {
37281          return;
37282        }
37283        const buffer = compileFontPathInfo(font.renderer.getPathJs(fontChar));
37284        handler.send("commonobj", [glyphName, "FontPath", buffer], [buffer]);
37285      } catch (reason) {
37286        if (evaluatorOptions.ignoreErrors) {
37287          warn(`buildFontPaths - ignoring ${glyphName} glyph: "${reason}".`);
37288          return;
37289        }
37290        throw reason;
37291      }
37292    }
37293    for (const glyph of glyphs) {
37294      buildPath(glyph.fontChar);
37295      const accent = glyph.accent;
37296      if (accent?.fontChar) {
37297        buildPath(accent.fontChar);
37298      }
37299    }
37300  }
37301  static get fallbackFontDict() {
37302    const dict = new Dict();
37303    dict.set("BaseFont", Name.get("Helvetica"));
37304    dict.set("Type", Name.get("FallbackType"));
37305    dict.set("Subtype", Name.get("FallbackType"));
37306    dict.set("Encoding", Name.get("WinAnsiEncoding"));
37307    return shadow(this, "fallbackFontDict", dict);
37308  }
37309}
37310class TranslatedFont {
37311  #sent = false;
37312  #type3Loaded = null;
37313  constructor({
37314    loadedName,
37315    font,
37316    dict
37317  }) {
37318    this.loadedName = loadedName;
37319    this.font = font;
37320    this.dict = dict;
37321    this.type3Dependencies = font.isType3Font ? new Set() : null;
37322  }
37323  send(handler) {
37324    if (this.#sent) {
37325      return;
37326    }
37327    this.#sent = true;
37328    const fontData = this.font.exportData(),
37329      transfers = fontData.buffer ? [fontData.buffer] : null;
37330    handler.send("commonobj", [this.loadedName, "Font", fontData], transfers);
37331  }
37332  fallback(handler, evaluatorOptions) {
37333    if (!this.font.data) {
37334      return;
37335    }
37336    this.font.disableFontFace = true;
37337    PartialEvaluator.buildFontPaths(this.font, this.font.glyphCacheValues, handler, evaluatorOptions);
37338  }
37339  loadType3Data(evaluator, resources, task, seenRefs = null) {
37340    if (this.#type3Loaded) {
37341      return this.#type3Loaded;
37342    }
37343    const {
37344      font,
37345      type3Dependencies
37346    } = this;
37347    assert(font.isType3Font, "Must be a Type3 font.");
37348    const type3Evaluator = evaluator.clone({
37349      ignoreErrors: false
37350    });
37351    const type3FontRefs = new RefSet(evaluator.type3FontRefs);
37352    if (this.dict.objId && !type3FontRefs.has(this.dict.objId)) {
37353      type3FontRefs.put(this.dict.objId);
37354    }
37355    type3Evaluator.type3FontRefs = type3FontRefs;
37356    let loadCharProcsPromise = Promise.resolve();
37357    const charProcs = this.dict.get("CharProcs");
37358    const fontResources = this.dict.get("Resources") || resources;
37359    const charProcOperatorList = Object.create(null);
37360    const [x0, y0, x1, y1] = font.bbox,
37361      width = x1 - x0,
37362      height = y1 - y0;
37363    const fontBBoxSize = Math.hypot(width, height);
37364    for (const key of charProcs.getKeys()) {
37365      loadCharProcsPromise = loadCharProcsPromise.then(() => {
37366        const glyphStream = charProcs.get(key);
37367        const operatorList = new OperatorList();
37368        return type3Evaluator.getOperatorList({
37369          stream: glyphStream,
37370          task,
37371          resources: fontResources,
37372          operatorList,
37373          prevRefs: seenRefs
37374        }).then(() => {
37375          switch (operatorList.fnArray[0]) {
37376            case OPS.setCharWidthAndBounds:
37377              this.#removeType3ColorOperators(operatorList, fontBBoxSize);
37378              break;
37379            case OPS.setCharWidth:
37380              if (!fontBBoxSize) {
37381                this.#guessType3FontBBox(operatorList);
37382              }
37383              break;
37384          }
37385          charProcOperatorList[key] = operatorList.getIR();
37386          for (const dependency of operatorList.dependencies) {
37387            type3Dependencies.add(dependency);
37388          }
37389        }).catch(function (reason) {
37390          warn(`Type3 font resource "${key}" is not available.`);
37391          const dummyOperatorList = new OperatorList();
37392          charProcOperatorList[key] = dummyOperatorList.getIR();
37393        });
37394      });
37395    }
37396    this.#type3Loaded = loadCharProcsPromise.then(() => {
37397      font.charProcOperatorList = charProcOperatorList;
37398      if (this._bbox) {
37399        font.isCharBBox = true;
37400        font.bbox = this._bbox;
37401      }
37402    }
vendor: 18,351 bytes, lines 37402-38178
37402);
37403    return this.#type3Loaded;
37404  }
37405  #removeType3ColorOperators(operatorList, fontBBoxSize = NaN) {
37406    const charBBox = Util.normalizeRect(operatorList.argsArray[0].slice(2)),
37407      width = charBBox[2] - charBBox[0],
37408      height = charBBox[3] - charBBox[1];
37409    const charBBoxSize = Math.hypot(width, height);
37410    if (width === 0 || height === 0) {
37411      operatorList.fnArray.splice(0, 1);
37412      operatorList.argsArray.splice(0, 1);
37413    } else if (fontBBoxSize === 0 || Math.round(charBBoxSize / fontBBoxSize) >= 10) {
37414      this._bbox ??= BBOX_INIT.slice();
37415      Util.rectBoundingBox(...charBBox, this._bbox);
37416    }
37417    let i = 0,
37418      ii = operatorList.length;
37419    while (i < ii) {
37420      switch (operatorList.fnArray[i]) {
37421        case OPS.setCharWidthAndBounds:
37422          break;
37423        case OPS.setStrokeColorSpace:
37424        case OPS.setFillColorSpace:
37425        case OPS.setStrokeColor:
37426        case OPS.setStrokeColorN:
37427        case OPS.setFillColor:
37428        case OPS.setFillColorN:
37429        case OPS.setStrokeGray:
37430        case OPS.setFillGray:
37431        case OPS.setStrokeRGBColor:
37432        case OPS.setFillRGBColor:
37433        case OPS.setStrokeCMYKColor:
37434        case OPS.setFillCMYKColor:
37435        case OPS.shadingFill:
37436        case OPS.setRenderingIntent:
37437          operatorList.fnArray.splice(i, 1);
37438          operatorList.argsArray.splice(i, 1);
37439          ii--;
37440          continue;
37441        case OPS.setGState:
37442          const [gStateObj] = operatorList.argsArray[i];
37443          let j = 0,
37444            jj = gStateObj.length;
37445          while (j < jj) {
37446            const [gStateKey] = gStateObj[j];
37447            switch (gStateKey) {
37448              case "TR":
37449              case "TR2":
37450              case "HT":
37451              case "BG":
37452              case "BG2":
37453              case "UCR":
37454              case "UCR2":
37455                gStateObj.splice(j, 1);
37456                jj--;
37457                continue;
37458            }
37459            j++;
37460          }
37461          break;
37462      }
37463      i++;
37464    }
37465  }
37466  #guessType3FontBBox(operatorList) {
37467    let i = 1;
37468    const ii = operatorList.length;
37469    while (i < ii) {
37470      switch (operatorList.fnArray[i]) {
37471        case OPS.constructPath:
37472          const minMax = operatorList.argsArray[i][2];
37473          this._bbox ??= BBOX_INIT.slice();
37474          Util.rectBoundingBox(...minMax, this._bbox);
37475          break;
37476      }
37477      i++;
37478    }
37479  }
37480}
37481class StateManager {
37482  constructor(initialState = new EvalState()) {
37483    this.state = initialState;
37484    this.stateStack = [];
37485  }
37486  save() {
37487    const old = this.state;
37488    this.stateStack.push(this.state);
37489    this.state = old.clone();
37490  }
37491  restore() {
37492    const prev = this.stateStack.pop();
37493    if (prev) {
37494      this.state = prev;
37495    }
37496  }
37497  transform(args) {
37498    this.state.ctm = Util.transform(this.state.ctm, args);
37499  }
37500}
37501class TextState {
37502  ctm = new Float32Array(IDENTITY_MATRIX);
37503  fontName = null;
37504  fontSize = 0;
37505  loadedName = null;
37506  font = null;
37507  fontMatrix = FONT_IDENTITY_MATRIX;
37508  textMatrix = IDENTITY_MATRIX.slice();
37509  textLineMatrix = IDENTITY_MATRIX.slice();
37510  charSpacing = 0;
37511  wordSpacing = 0;
37512  leading = 0;
37513  textHScale = 1;
37514  textRise = 0;
37515  setTextMatrix(a, b, c, d, e, f) {
37516    const m = this.textMatrix;
37517    m[0] = a;
37518    m[1] = b;
37519    m[2] = c;
37520    m[3] = d;
37521    m[4] = e;
37522    m[5] = f;
37523  }
37524  setTextLineMatrix(a, b, c, d, e, f) {
37525    const m = this.textLineMatrix;
37526    m[0] = a;
37527    m[1] = b;
37528    m[2] = c;
37529    m[3] = d;
37530    m[4] = e;
37531    m[5] = f;
37532  }
37533  translateTextMatrix(x, y) {
37534    const m = this.textMatrix;
37535    m[4] = m[0] * x + m[2] * y + m[4];
37536    m[5] = m[1] * x + m[3] * y + m[5];
37537  }
37538  translateTextLineMatrix(x, y) {
37539    const m = this.textLineMatrix;
37540    m[4] = m[0] * x + m[2] * y + m[4];
37541    m[5] = m[1] * x + m[3] * y + m[5];
37542  }
37543  carriageReturn() {
37544    this.translateTextLineMatrix(0, -this.leading);
37545    this.textMatrix = this.textLineMatrix.slice();
37546  }
37547  clone() {
37548    const clone = Object.assign(Object.create(this), this);
37549    clone.textMatrix = this.textMatrix.slice();
37550    clone.textLineMatrix = this.textLineMatrix.slice();
37551    clone.fontMatrix = this.fontMatrix.slice();
37552    return clone;
37553  }
37554}
37555class EvalState {
37556  ctm = new Float32Array(IDENTITY_MATRIX);
37557  font = null;
37558  textRenderingMode = TextRenderingMode.FILL;
37559  _fillColorSpace = ColorSpaceUtils.gray;
37560  _strokeColorSpace = ColorSpaceUtils.gray;
37561  patternFillColorSpace = null;
37562  patternStrokeColorSpace = null;
37563  currentPointX = 0;
37564  currentPointY = 0;
37565  pathMinMax = F32_BBOX_INIT.slice();
37566  pathBuffer = [];
37567  get fillColorSpace() {
37568    return this._fillColorSpace;
37569  }
37570  set fillColorSpace(colorSpace) {
37571    this._fillColorSpace = this.patternFillColorSpace = colorSpace;
37572  }
37573  get strokeColorSpace() {
37574    return this._strokeColorSpace;
37575  }
37576  set strokeColorSpace(colorSpace) {
37577    this._strokeColorSpace = this.patternStrokeColorSpace = colorSpace;
37578  }
37579  clone({
37580    newPath = false
37581  } = {}) {
37582    const clone = Object.create(this);
37583    if (newPath) {
37584      clone.pathBuffer = [];
37585      clone.pathMinMax = F32_BBOX_INIT.slice();
37586    }
37587    return clone;
37588  }
37589}
37590class EvaluatorPreprocessor {
37591  static get opMap() {
37592    return shadow(this, "opMap", Object.assign(Object.create(null), {
37593      w: {
37594        id: OPS.setLineWidth,
37595        numArgs: 1,
37596        variableArgs: false
37597      },
37598      J: {
37599        id: OPS.setLineCap,
37600        numArgs: 1,
37601        variableArgs: false
37602      },
37603      j: {
37604        id: OPS.setLineJoin,
37605        numArgs: 1,
37606        variableArgs: false
37607      },
37608      M: {
37609        id: OPS.setMiterLimit,
37610        numArgs: 1,
37611        variableArgs: false
37612      },
37613      d: {
37614        id: OPS.setDash,
37615        numArgs: 2,
37616        variableArgs: false
37617      },
37618      ri: {
37619        id: OPS.setRenderingIntent,
37620        numArgs: 1,
37621        variableArgs: false
37622      },
37623      i: {
37624        id: OPS.setFlatness,
37625        numArgs: 1,
37626        variableArgs: false
37627      },
37628      gs: {
37629        id: OPS.setGState,
37630        numArgs: 1,
37631        variableArgs: false
37632      },
37633      q: {
37634        id: OPS.save,
37635        numArgs: 0,
37636        variableArgs: false
37637      },
37638      Q: {
37639        id: OPS.restore,
37640        numArgs: 0,
37641        variableArgs: false
37642      },
37643      cm: {
37644        id: OPS.transform,
37645        numArgs: 6,
37646        variableArgs: false
37647      },
37648      m: {
37649        id: OPS.moveTo,
37650        numArgs: 2,
37651        variableArgs: false
37652      },
37653      l: {
37654        id: OPS.lineTo,
37655        numArgs: 2,
37656        variableArgs: false
37657      },
37658      c: {
37659        id: OPS.curveTo,
37660        numArgs: 6,
37661        variableArgs: false
37662      },
37663      v: {
37664        id: OPS.curveTo2,
37665        numArgs: 4,
37666        variableArgs: false
37667      },
37668      y: {
37669        id: OPS.curveTo3,
37670        numArgs: 4,
37671        variableArgs: false
37672      },
37673      h: {
37674        id: OPS.closePath,
37675        numArgs: 0,
37676        variableArgs: false
37677      },
37678      re: {
37679        id: OPS.rectangle,
37680        numArgs: 4,
37681        variableArgs: false
37682      },
37683      S: {
37684        id: OPS.stroke,
37685        numArgs: 0,
37686        variableArgs: false
37687      },
37688      s: {
37689        id: OPS.closeStroke,
37690        numArgs: 0,
37691        variableArgs: false
37692      },
37693      f: {
37694        id: OPS.fill,
37695        numArgs: 0,
37696        variableArgs: false
37697      },
37698      F: {
37699        id: OPS.fill,
37700        numArgs: 0,
37701        variableArgs: false
37702      },
37703      "f*": {
37704        id: OPS.eoFill,
37705        numArgs: 0,
37706        variableArgs: false
37707      },
37708      B: {
37709        id: OPS.fillStroke,
37710        numArgs: 0,
37711        variableArgs: false
37712      },
37713      "B*": {
37714        id: OPS.eoFillStroke,
37715        numArgs: 0,
37716        variableArgs: false
37717      },
37718      b: {
37719        id: OPS.closeFillStroke,
37720        numArgs: 0,
37721        variableArgs: false
37722      },
37723      "b*": {
37724        id: OPS.closeEOFillStroke,
37725        numArgs: 0,
37726        variableArgs: false
37727      },
37728      n: {
37729        id: OPS.endPath,
37730        numArgs: 0,
37731        variableArgs: false
37732      },
37733      W: {
37734        id: OPS.clip,
37735        numArgs: 0,
37736        variableArgs: false
37737      },
37738      "W*": {
37739        id: OPS.eoClip,
37740        numArgs: 0,
37741        variableArgs: false
37742      },
37743      BT: {
37744        id: OPS.beginText,
37745        numArgs: 0,
37746        variableArgs: false
37747      },
37748      ET: {
37749        id: OPS.endText,
37750        numArgs: 0,
37751        variableArgs: false
37752      },
37753      Tc: {
37754        id: OPS.setCharSpacing,
37755        numArgs: 1,
37756        variableArgs: false
37757      },
37758      Tw: {
37759        id: OPS.setWordSpacing,
37760        numArgs: 1,
37761        variableArgs: false
37762      },
37763      Tz: {
37764        id: OPS.setHScale,
37765        numArgs: 1,
37766        variableArgs: false
37767      },
37768      TL: {
37769        id: OPS.setLeading,
37770        numArgs: 1,
37771        variableArgs: false
37772      },
37773      Tf: {
37774        id: OPS.setFont,
37775        numArgs: 2,
37776        variableArgs: false
37777      },
37778      Tr: {
37779        id: OPS.setTextRenderingMode,
37780        numArgs: 1,
37781        variableArgs: false
37782      },
37783      Ts: {
37784        id: OPS.setTextRise,
37785        numArgs: 1,
37786        variableArgs: false
37787      },
37788      Td: {
37789        id: OPS.moveText,
37790        numArgs: 2,
37791        variableArgs: false
37792      },
37793      TD: {
37794        id: OPS.setLeadingMoveText,
37795        numArgs: 2,
37796        variableArgs: false
37797      },
37798      Tm: {
37799        id: OPS.setTextMatrix,
37800        numArgs: 6,
37801        variableArgs: false
37802      },
37803      "T*": {
37804        id: OPS.nextLine,
37805        numArgs: 0,
37806        variableArgs: false
37807      },
37808      Tj: {
37809        id: OPS.showText,
37810        numArgs: 1,
37811        variableArgs: false
37812      },
37813      TJ: {
37814        id: OPS.showSpacedText,
37815        numArgs: 1,
37816        variableArgs: false
37817      },
37818      "'": {
37819        id: OPS.nextLineShowText,
37820        numArgs: 1,
37821        variableArgs: false
37822      },
37823      '"': {
37824        id: OPS.nextLineSetSpacingShowText,
37825        numArgs: 3,
37826        variableArgs: false
37827      },
37828      d0: {
37829        id: OPS.setCharWidth,
37830        numArgs: 2,
37831        variableArgs: false
37832      },
37833      d1: {
37834        id: OPS.setCharWidthAndBounds,
37835        numArgs: 6,
37836        variableArgs: false
37837      },
37838      CS: {
37839        id: OPS.setStrokeColorSpace,
37840        numArgs: 1,
37841        variableArgs: false
37842      },
37843      cs: {
37844        id: OPS.setFillColorSpace,
37845        numArgs: 1,
37846        variableArgs: false
37847      },
37848      SC: {
37849        id: OPS.setStrokeColor,
37850        numArgs: 4,
37851        variableArgs: true
37852      },
37853      SCN: {
37854        id: OPS.setStrokeColorN,
37855        numArgs: 33,
37856        variableArgs: true
37857      },
37858      sc: {
37859        id: OPS.setFillColor,
37860        numArgs: 4,
37861        variableArgs: true
37862      },
37863      scn: {
37864        id: OPS.setFillColorN,
37865        numArgs: 33,
37866        variableArgs: true
37867      },
37868      G: {
37869        id: OPS.setStrokeGray,
37870        numArgs: 1,
37871        variableArgs: false
37872      },
37873      g: {
37874        id: OPS.setFillGray,
37875        numArgs: 1,
37876        variableArgs: false
37877      },
37878      RG: {
37879        id: OPS.setStrokeRGBColor,
37880        numArgs: 3,
37881        variableArgs: false
37882      },
37883      rg: {
37884        id: OPS.setFillRGBColor,
37885        numArgs: 3,
37886        variableArgs: false
37887      },
37888      K: {
37889        id: OPS.setStrokeCMYKColor,
37890        numArgs: 4,
37891        variableArgs: false
37892      },
37893      k: {
37894        id: OPS.setFillCMYKColor,
37895        numArgs: 4,
37896        variableArgs: false
37897      },
37898      sh: {
37899        id: OPS.shadingFill,
37900        numArgs: 1,
37901        variableArgs: false
37902      },
37903      BI: {
37904        id: OPS.beginInlineImage,
37905        numArgs: 0,
37906        variableArgs: false
37907      },
37908      ID: {
37909        id: OPS.beginImageData,
37910        numArgs: 0,
37911        variableArgs: false
37912      },
37913      EI: {
37914        id: OPS.endInlineImage,
37915        numArgs: 1,
37916        variableArgs: false
37917      },
37918      Do: {
37919        id: OPS.paintXObject,
37920        numArgs: 1,
37921        variableArgs: false
37922      },
37923      MP: {
37924        id: OPS.markPoint,
37925        numArgs: 1,
37926        variableArgs: false
37927      },
37928      DP: {
37929        id: OPS.markPointProps,
37930        numArgs: 2,
37931        variableArgs: false
37932      },
37933      BMC: {
37934        id: OPS.beginMarkedContent,
37935        numArgs: 1,
37936        variableArgs: false
37937      },
37938      BDC: {
37939        id: OPS.beginMarkedContentProps,
37940        numArgs: 2,
37941        variableArgs: false
37942      },
37943      EMC: {
37944        id: OPS.endMarkedContent,
37945        numArgs: 0,
37946        variableArgs: false
37947      },
37948      BX: {
37949        id: OPS.beginCompat,
37950        numArgs: 0,
37951        variableArgs: false
37952      },
37953      EX: {
37954        id: OPS.endCompat,
37955        numArgs: 0,
37956        variableArgs: false
37957      },
37958      BM: null,
37959      BD: null,
37960      true: null,
37961      fa: null,
37962      fal: null,
37963      fals: null,
37964      false: null,
37965      nu: null,
37966      nul: null,
37967      null: null
37968    }));
37969  }
37970  static MAX_INVALID_PATH_OPS = 10;
37971  constructor(stream, xref, stateManager = new StateManager()) {
37972    this.parser = new Parser({
37973      lexer: new Lexer(stream, EvaluatorPreprocessor.opMap),
37974      xref
37975    });
37976    this.stateManager = stateManager;
37977    this.nonProcessedArgs = [];
37978    this._isPathOp = false;
37979    this._numInvalidPathOPS = 0;
37980  }
37981  get savedStatesDepth() {
37982    return this.stateManager.stateStack.length;
37983  }
37984  read(operation) {
37985    let args = operation.args;
37986    while (true) {
37987      const obj = this.parser.getObj();
37988      if (obj instanceof Cmd) {
37989        const cmd = obj.cmd;
37990        const opSpec = EvaluatorPreprocessor.opMap[cmd];
37991        if (!opSpec) {
37992          warn(`Unknown command "${cmd}".`);
37993          continue;
37994        }
37995        const fn = opSpec.id;
37996        const numArgs = opSpec.numArgs;
37997        let argsLength = args !== null ? args.length : 0;
37998        if (!this._isPathOp) {
37999          this._numInvalidPathOPS = 0;
38000        }
38001        this._isPathOp = fn >= OPS.moveTo && fn <= OPS.endPath;
38002        if (!opSpec.variableArgs) {
38003          if (argsLength !== numArgs) {
38004            const nonProcessedArgs = this.nonProcessedArgs;
38005            while (argsLength > numArgs) {
38006              nonProcessedArgs.push(args.shift());
38007              argsLength--;
38008            }
38009            while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
38010              if (args === null) {
38011                args = [];
38012              }
38013              args.unshift(nonProcessedArgs.pop());
38014              argsLength++;
38015            }
38016          }
38017          if (argsLength < numArgs) {
38018            const partialMsg = `command ${cmd}: expected ${numArgs} args, ` + `but received ${argsLength} args.`;
38019            if (this._isPathOp && ++this._numInvalidPathOPS > EvaluatorPreprocessor.MAX_INVALID_PATH_OPS) {
38020              throw new FormatError(`Invalid ${partialMsg}`);
38021            }
38022            warn(`Skipping ${partialMsg}`);
38023            if (args !== null) {
38024              args.length = 0;
38025            }
38026            continue;
38027          }
38028        } else if (argsLength > numArgs) {
38029          info(`Command ${cmd}: expected [0, ${numArgs}] args, ` + `but received ${argsLength} args.`);
38030        }
38031        this.preprocessCommand(fn, args);
38032        operation.fn = fn;
38033        operation.args = args;
38034        return true;
38035      }
38036      if (obj === EOF) {
38037        return false;
38038      }
38039      if (obj !== null) {
38040        if (args === null) {
38041          args = [];
38042        }
38043        args.push(obj);
38044        if (args.length > 33) {
38045          throw new FormatError("Too many arguments");
38046        }
38047      }
38048    }
38049  }
38050  preprocessCommand(fn, args) {
38051    switch (fn | 0) {
38052      case OPS.save:
38053        this.stateManager.save();
38054        break;
38055      case OPS.restore:
38056        this.stateManager.restore();
38057        break;
38058      case OPS.transform:
38059        this.stateManager.transform(args);
38060        break;
38061    }
38062  }
38063}
38064
38065;// ./src/core/default_appearance.js
38066
38067
38068
38069
38070
38071
38072
38073
38074
38075class DefaultAppearanceEvaluator extends EvaluatorPreprocessor {
38076  constructor(str) {
38077    super(new StringStream(str));
38078  }
38079  parse() {
38080    const operation = {
38081      fn: 0,
38082      args: []
38083    };
38084    const result = {
38085      fontSize: 0,
38086      fontName: "",
38087      fontColor: new Uint8ClampedArray(3)
38088    };
38089    try {
38090      while (true) {
38091        operation.args.length = 0;
38092        if (!this.read(operation)) {
38093          break;
38094        }
38095        if (this.savedStatesDepth !== 0) {
38096          continue;
38097        }
38098        const {
38099          fn,
38100          args
38101        } = operation;
38102        switch (fn | 0) {
38103          case OPS.setFont:
38104            const [fontName, fontSize] = args;
38105            if (fontName instanceof Name) {
38106              result.fontName = fontName.name;
38107            }
38108            if (typeof fontSize === "number" && fontSize > 0) {
38109              result.fontSize = fontSize;
38110            }
38111            break;
38112          case OPS.setFillRGBColor:
38113            ColorSpaceUtils.rgb.getRgbItem(args, 0, result.fontColor, 0);
38114            break;
38115          case OPS.setFillGray:
38116            ColorSpaceUtils.gray.getRgbItem(args, 0, result.fontColor, 0);
38117            break;
38118          case OPS.setFillCMYKColor:
38119            ColorSpaceUtils.cmyk.getRgbItem(args, 0, result.fontColor, 0);
38120            break;
38121        }
38122      }
38123    } catch (reason) {
38124      warn(`parseDefaultAppearance - ignoring errors: "${reason}".`);
38125    }
38126    return result;
38127  }
38128}
38129function parseDefaultAppearance(str) {
38130  return new DefaultAppearanceEvaluator(str).parse();
38131}
38132class AppearanceStreamEvaluator extends EvaluatorPreprocessor {
38133  constructor(stream, xref, globalColorSpaceCache) {
38134    super(stream);
38135    this.stream = stream;
38136    this.xref = xref;
38137    this.globalColorSpaceCache = globalColorSpaceCache;
38138    this.resources = stream.dict?.get("Resources");
38139  }
38140  parse() {
38141    const operation = {
38142      fn: 0,
38143      args: []
38144    };
38145    let result = {
38146      scaleFactor: 1,
38147      fontSize: 0,
38148      fontName: "",
38149      fontColor: new Uint8ClampedArray(3),
38150      fillColorSpace: ColorSpaceUtils.gray
38151    };
38152    let breakLoop = false;
38153    const stack = [];
38154    try {
38155      while (true) {
38156        operation.args.length = 0;
38157        if (breakLoop || !this.read(operation)) {
38158          break;
38159        }
38160        const {
38161          fn,
38162          args
38163        } = operation;
38164        switch (fn | 0) {
38165          case OPS.save:
38166            stack.push({
38167              scaleFactor: result.scaleFactor,
38168              fontSize: result.fontSize,
38169              fontName: result.fontName,
38170              fontColor: result.fontColor.slice(),
38171              fillColorSpace: result.fillColorSpace
38172            });
38173            break;
38174          case OPS.restore:
38175            result = stack.pop() || result;
38176            break;
38177          case OPS.setTextMatrix:
38178            
vendor: 4,324 bytes, lines 38178-38293
38178result.scaleFactor *= Math.hypot(args[0], args[1]);
38179            break;
38180          case OPS.setFont:
38181            const [fontName, fontSize] = args;
38182            if (fontName instanceof Name) {
38183              result.fontName = fontName.name;
38184            }
38185            if (typeof fontSize === "number" && fontSize > 0) {
38186              result.fontSize = fontSize * result.scaleFactor;
38187            }
38188            break;
38189          case OPS.setFillColorSpace:
38190            result.fillColorSpace = ColorSpaceUtils.parse({
38191              cs: args[0],
38192              xref: this.xref,
38193              resources: this.resources,
38194              pdfFunctionFactory: this._pdfFunctionFactory,
38195              globalColorSpaceCache: this.globalColorSpaceCache,
38196              localColorSpaceCache: this._localColorSpaceCache
38197            });
38198            break;
38199          case OPS.setFillColor:
38200            const cs = result.fillColorSpace;
38201            cs.getRgbItem(args, 0, result.fontColor, 0);
38202            break;
38203          case OPS.setFillRGBColor:
38204            ColorSpaceUtils.rgb.getRgbItem(args, 0, result.fontColor, 0);
38205            break;
38206          case OPS.setFillGray:
38207            ColorSpaceUtils.gray.getRgbItem(args, 0, result.fontColor, 0);
38208            break;
38209          case OPS.setFillCMYKColor:
38210            ColorSpaceUtils.cmyk.getRgbItem(args, 0, result.fontColor, 0);
38211            break;
38212          case OPS.showText:
38213          case OPS.showSpacedText:
38214          case OPS.nextLineShowText:
38215          case OPS.nextLineSetSpacingShowText:
38216            breakLoop = true;
38217            break;
38218        }
38219      }
38220    } catch (reason) {
38221      warn(`parseAppearanceStream - ignoring errors: "${reason}".`);
38222    }
38223    this.stream.reset();
38224    delete result.scaleFactor;
38225    delete result.fillColorSpace;
38226    return result;
38227  }
38228  get _localColorSpaceCache() {
38229    return shadow(this, "_localColorSpaceCache", new LocalColorSpaceCache());
38230  }
38231  get _pdfFunctionFactory() {
38232    return shadow(this, "_pdfFunctionFactory", new PDFFunctionFactory({
38233      xref: this.xref
38234    }));
38235  }
38236}
38237function parseAppearanceStream(stream, xref, globalColorSpaceCache) {
38238  return new AppearanceStreamEvaluator(stream, xref, globalColorSpaceCache).parse();
38239}
38240function getPdfColor(color, isFill) {
38241  if (color[0] === color[1] && color[1] === color[2]) {
38242    const gray = color[0] / 255;
38243    return `${numberToString(gray)} ${isFill ? "g" : "G"}`;
38244  }
38245  return Array.from(color, c => numberToString(c / 255)).join(" ") + ` ${isFill ? "rg" : "RG"}`;
38246}
38247function createDefaultAppearance({
38248  fontSize,
38249  fontName,
38250  fontColor
38251}) {
38252  return `/${escapePDFName(fontName)} ${fontSize} Tf ${getPdfColor(fontColor, true)}`;
38253}
38254class FakeUnicodeFont {
38255  static #fontNameId = 1;
38256  constructor(xref, fontFamily) {
38257    this.xref = xref;
38258    this.widths = null;
38259    this.firstChar = Infinity;
38260    this.lastChar = -Infinity;
38261    this.fontFamily = fontFamily;
38262    const canvas = new OffscreenCanvas(1, 1);
38263    this.ctxMeasure = canvas.getContext("2d", {
38264      willReadFrequently: true
38265    });
38266    this.fontName = Name.get(`InvalidPDFjsFont_${fontFamily}_${FakeUnicodeFont.#fontNameId++}`);
38267  }
38268  get fontDescriptorRef() {
38269    if (!FakeUnicodeFont._fontDescriptorRef) {
38270      const fontDescriptor = new Dict(this.xref);
38271      fontDescriptor.setIfName("Type", "FontDescriptor");
38272      fontDescriptor.set("FontName", this.fontName);
38273      fontDescriptor.set("FontFamily", "MyriadPro Regular");
38274      fontDescriptor.set("FontBBox", [0, 0, 0, 0]);
38275      fontDescriptor.setIfName("FontStretch", "Normal");
38276      fontDescriptor.set("FontWeight", 400);
38277      fontDescriptor.set("ItalicAngle", 0);
38278      FakeUnicodeFont._fontDescriptorRef = this.xref.getNewPersistentRef(fontDescriptor);
38279    }
38280    return FakeUnicodeFont._fontDescriptorRef;
38281  }
38282  get descendantFontRef() {
38283    const descendantFont = new Dict(this.xref);
38284    descendantFont.set("BaseFont", this.fontName);
38285    descendantFont.setIfName("Type", "Font");
38286    descendantFont.setIfName("Subtype", "CIDFontType0");
38287    descendantFont.setIfName("CIDToGIDMap", "Identity");
38288    descendantFont.set("FirstChar", this.firstChar);
38289    descendantFont.set("LastChar", this.lastChar);
38290    descendantFont.set("FontDescriptor", this.fontDescriptorRef);
38291    descendantFont.set("DW", 1000);
38292    const widths = [];
38293    const chars = [...this.widths].sort();
vendor: 5,340 bytes, lines 38294-38440
38294    let currentChar = null;
38295    let currentWidths = null;
38296    for (const [char, width] of chars) {
38297      if (!currentChar) {
38298        currentChar = char;
38299        currentWidths = [width];
38300        continue;
38301      }
38302      if (char === currentChar + currentWidths.length) {
38303        currentWidths.push(width);
38304      } else {
38305        widths.push(currentChar, currentWidths);
38306        currentChar = char;
38307        currentWidths = [width];
38308      }
38309    }
38310    if (currentChar) {
38311      widths.push(currentChar, currentWidths);
38312    }
38313    descendantFont.set("W", widths);
38314    const cidSystemInfo = new Dict(this.xref);
38315    cidSystemInfo.set("Ordering", "Identity");
38316    cidSystemInfo.set("Registry", "Adobe");
38317    cidSystemInfo.set("Supplement", 0);
38318    descendantFont.set("CIDSystemInfo", cidSystemInfo);
38319    return this.xref.getNewPersistentRef(descendantFont);
38320  }
38321  get baseFontRef() {
38322    const baseFont = new Dict(this.xref);
38323    baseFont.set("BaseFont", this.fontName);
38324    baseFont.setIfName("Type", "Font");
38325    baseFont.setIfName("Subtype", "Type0");
38326    baseFont.setIfName("Encoding", "Identity-H");
38327    baseFont.set("DescendantFonts", [this.descendantFontRef]);
38328    baseFont.setIfName("ToUnicode", "Identity-H");
38329    return this.xref.getNewPersistentRef(baseFont);
38330  }
38331  get resources() {
38332    const resources = new Dict(this.xref);
38333    const font = new Dict(this.xref);
38334    font.set(this.fontName.name, this.baseFontRef);
38335    resources.set("Font", font);
38336    return resources;
38337  }
38338  _createContext() {
38339    this.widths = new Map();
38340    this.ctxMeasure.font = `1000px ${this.fontFamily}`;
38341    return this.ctxMeasure;
38342  }
38343  createFontResources(text) {
38344    const ctx = this._createContext();
38345    for (const line of text.split(/\r\n?|\n/)) {
38346      for (const char of line.split("")) {
38347        const code = char.charCodeAt(0);
38348        if (this.widths.has(code)) {
38349          continue;
38350        }
38351        const metrics = ctx.measureText(char);
38352        const width = Math.ceil(metrics.width);
38353        this.widths.set(code, width);
38354        this.firstChar = Math.min(code, this.firstChar);
38355        this.lastChar = Math.max(code, this.lastChar);
38356      }
38357    }
38358    return this.resources;
38359  }
38360  static getFirstPositionInfo(rect, rotation, fontSize) {
38361    const [x1, y1, x2, y2] = rect;
38362    let w = x2 - x1;
38363    let h = y2 - y1;
38364    if (rotation % 180 !== 0) {
38365      [w, h] = [h, w];
38366    }
38367    const lineHeight = LINE_FACTOR * fontSize;
38368    const lineDescent = LINE_DESCENT_FACTOR * fontSize;
38369    return {
38370      coords: [0, h + lineDescent - lineHeight],
38371      bbox: [0, 0, w, h],
38372      matrix: rotation !== 0 ? getRotationMatrix(rotation, h, lineHeight) : undefined
38373    };
38374  }
38375  createAppearance(text, rect, rotation, fontSize, bgColor, strokeAlpha) {
38376    const ctx = this._createContext();
38377    const lines = [];
38378    let maxWidth = -Infinity;
38379    for (const line of text.split(/\r\n?|\n/)) {
38380      lines.push(line);
38381      const lineWidth = ctx.measureText(line).width;
38382      maxWidth = Math.max(maxWidth, lineWidth);
38383      for (const code of codePointIter(line)) {
38384        const char = String.fromCodePoint(code);
38385        let width = this.widths.get(code);
38386        if (width === undefined) {
38387          const metrics = ctx.measureText(char);
38388          width = Math.ceil(metrics.width);
38389          this.widths.set(code, width);
38390          this.firstChar = Math.min(code, this.firstChar);
38391          this.lastChar = Math.max(code, this.lastChar);
38392        }
38393      }
38394    }
38395    maxWidth *= fontSize / 1000;
38396    const [x1, y1, x2, y2] = rect;
38397    let w = x2 - x1;
38398    let h = y2 - y1;
38399    if (rotation % 180 !== 0) {
38400      [w, h] = [h, w];
38401    }
38402    const hscale = maxWidth > w ? w / maxWidth : 1;
38403    let vscale = 1;
38404    const lineHeight = LINE_FACTOR * fontSize;
38405    const lineDescent = LINE_DESCENT_FACTOR * fontSize;
38406    const maxHeight = lineHeight * lines.length;
38407    if (maxHeight > h) {
38408      vscale = h / maxHeight;
38409    }
38410    const fscale = Math.min(hscale, vscale);
38411    const newFontSize = fontSize * fscale;
38412    const buffer = ["q", `0 0 ${numberToString(w)} ${numberToString(h)} re W n`, `BT`, `1 0 0 1 0 ${numberToString(h + lineDescent)} Tm 0 Tc ${getPdfColor(bgColor, true)}`, `/${this.fontName.name} ${numberToString(newFontSize)} Tf`];
38413    const {
38414      resources
38415    } = this;
38416    strokeAlpha = typeof strokeAlpha === "number" && strokeAlpha >= 0 && strokeAlpha <= 1 ? strokeAlpha : 1;
38417    if (strokeAlpha !== 1) {
38418      buffer.push("/R0 gs");
38419      const extGState = new Dict(this.xref);
38420      const r0 = new Dict(this.xref);
38421      r0.set("ca", strokeAlpha);
38422      r0.set("CA", strokeAlpha);
38423      r0.setIfName("Type", "ExtGState");
38424      extGState.set("R0", r0);
38425      resources.set("ExtGState", extGState);
38426    }
38427    const vShift = numberToString(lineHeight);
38428    for (const line of lines) {
38429      buffer.push(`0 -${vShift} Td <${stringToUTF16HexString(line)}> Tj`);
38430    }
38431    buffer.push("ET", "Q");
38432    const appearance = buffer.join("\n");
38433    const appearanceStreamDict = new Dict(this.xref);
38434    appearanceStreamDict.setIfName("Subtype", "Form");
38435    appearanceStreamDict.setIfName("Type", "XObject");
38436    appearanceStreamDict.set("BBox", [0, 0, w, h]);
38437    appearanceStreamDict.set("Length", appearance.length);
38438    appearanceStreamDict.set("Resources", resources);
38439    if (rotation) {
38440      const matrix = getRotationMatrix(rotation, w, h);
vendor: 7,774 bytes, lines 38441-38742
38441      appearanceStreamDict.set("Matrix", matrix);
38442    }
38443    return new StringStream(appearance, appearanceStreamDict);
38444  }
38445}
38446
38447;// ./src/shared/scripting_utils.js
38448/* unused harmony import specifier */ var scripting_utils_MathClamp;
38449
38450function makeColorComp(n) {
38451  return Math.floor(scripting_utils_MathClamp(n, 0, 1) * 255).toString(16).padStart(2, "0");
38452}
38453function scaleAndClamp(x) {
38454  return scripting_utils_MathClamp(x, 0, 1) * 255;
38455}
38456class ColorConverters {
38457  static CMYK_G([c, y, m, k]) {
38458    return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
38459  }
38460  static G_CMYK([g]) {
38461    return ["CMYK", 0, 0, 0, 1 - g];
38462  }
38463  static G_RGB([g]) {
38464    return ["RGB", g, g, g];
38465  }
38466  static G_rgb([g]) {
38467    g = scaleAndClamp(g);
38468    return [g, g, g];
38469  }
38470  static G_HTML([g]) {
38471    const G = makeColorComp(g);
38472    return `#${G}${G}${G}`;
38473  }
38474  static RGB_G([r, g, b]) {
38475    return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
38476  }
38477  static RGB_rgb(color) {
38478    return color.map(scaleAndClamp);
38479  }
38480  static RGB_HTML(color) {
38481    return `#${color.map(makeColorComp).join("")}`;
38482  }
38483  static T_HTML() {
38484    return "#00000000";
38485  }
38486  static T_rgb() {
38487    return [null];
38488  }
38489  static CMYK_RGB([c, y, m, k]) {
38490    return ["RGB", 1 - Math.min(1, c + k), 1 - Math.min(1, m + k), 1 - Math.min(1, y + k)];
38491  }
38492  static CMYK_rgb([c, y, m, k]) {
38493    return [scaleAndClamp(1 - Math.min(1, c + k)), scaleAndClamp(1 - Math.min(1, m + k)), scaleAndClamp(1 - Math.min(1, y + k))];
38494  }
38495  static CMYK_HTML(components) {
38496    const rgb = this.CMYK_RGB(components).slice(1);
38497    return this.RGB_HTML(rgb);
38498  }
38499  static RGB_CMYK([r, g, b]) {
38500    const c = 1 - r;
38501    const m = 1 - g;
38502    const y = 1 - b;
38503    const k = Math.min(c, m, y);
38504    return ["CMYK", c, m, y, k];
38505  }
38506}
38507const DateFormats = ["m/d", "m/d/yy", "mm/dd/yy", "mm/yy", "d-mmm", "d-mmm-yy", "dd-mmm-yy", "yy-mm-dd", "mmm-yy", "mmmm-yy", "mmm d, yyyy", "mmmm d, yyyy", "m/d/yy h:MM tt", "m/d/yy HH:MM"];
38508const TimeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];
38509
38510;// ./src/core/name_number_tree.js
38511
38512
38513class NameOrNumberTree {
38514  constructor(root, xref, type) {
38515    this.root = root;
38516    this.xref = xref;
38517    this._type = type;
38518  }
38519  getAll(isRaw = false) {
38520    const map = new Map();
38521    if (!this.root) {
38522      return map;
38523    }
38524    const xref = this.xref;
38525    const processed = new RefSet();
38526    if (this.root instanceof Ref) {
38527      processed.put(this.root);
38528    }
38529    const queue = [this.root];
38530    for (const node of queue) {
38531      const obj = xref.fetchIfRef(node);
38532      if (!(obj instanceof Dict)) {
38533        continue;
38534      }
38535      if (obj.has("Kids")) {
38536        const kids = obj.get("Kids");
38537        if (!Array.isArray(kids)) {
38538          continue;
38539        }
38540        for (const kid of kids) {
38541          if (kid instanceof Ref) {
38542            if (processed.has(kid)) {
38543              throw new FormatError(`Duplicate entry in "${this._type}" tree.`);
38544            }
38545            processed.put(kid);
38546          }
38547          queue.push(kid);
38548        }
38549        continue;
38550      }
38551      const entries = obj.get(this._type);
38552      if (!Array.isArray(entries)) {
38553        continue;
38554      }
38555      for (let i = 0, ii = entries.length; i < ii; i += 2) {
38556        map.set(isRaw ? entries[i] : xref.fetchIfRef(entries[i]), isRaw ? entries[i + 1] : xref.fetchIfRef(entries[i + 1]));
38557      }
38558    }
38559    return map;
38560  }
38561  getRaw(key) {
38562    if (!this.root) {
38563      return null;
38564    }
38565    const xref = this.xref;
38566    let kidsOrEntries = xref.fetchIfRef(this.root);
38567    let loopCount = 0;
38568    const MAX_LEVELS = 10;
38569    while (kidsOrEntries.has("Kids")) {
38570      if (++loopCount > MAX_LEVELS) {
38571        warn(`Search depth limit reached for "${this._type}" tree.`);
38572        return null;
38573      }
38574      const kids = kidsOrEntries.get("Kids");
38575      if (!Array.isArray(kids)) {
38576        return null;
38577      }
38578      let l = 0,
38579        r = kids.length - 1;
38580      while (l <= r) {
38581        const m = l + r >> 1;
38582        const kid = xref.fetchIfRef(kids[m]);
38583        const limits = kid.get("Limits");
38584        if (key < xref.fetchIfRef(limits[0])) {
38585          r = m - 1;
38586        } else if (key > xref.fetchIfRef(limits[1])) {
38587          l = m + 1;
38588        } else {
38589          kidsOrEntries = kid;
38590          break;
38591        }
38592      }
38593      if (l > r) {
38594        return null;
38595      }
38596    }
38597    const entries = kidsOrEntries.get(this._type);
38598    if (Array.isArray(entries)) {
38599      let l = 0,
38600        r = entries.length - 2;
38601      while (l <= r) {
38602        const tmp = l + r >> 1,
38603          m = tmp + (tmp & 1);
38604        const currentKey = xref.fetchIfRef(entries[m]);
38605        if (key < currentKey) {
38606          r = m - 2;
38607        } else if (key > currentKey) {
38608          l = m + 2;
38609        } else {
38610          return entries[m + 1];
38611        }
38612      }
38613    }
38614    return null;
38615  }
38616  get(key) {
38617    return this.xref.fetchIfRef(this.getRaw(key));
38618  }
38619}
38620class NameTree extends NameOrNumberTree {
38621  constructor(root, xref) {
38622    super(root, xref, "Names");
38623  }
38624}
38625class NumberTree extends NameOrNumberTree {
38626  constructor(root, xref) {
38627    super(root, xref, "Nums");
38628  }
38629}
38630
38631;// ./src/core/cleanup_helper.js
38632
38633
38634
38635
38636function clearGlobalCaches() {
38637  clearPatternCaches();
38638  clearPrimitiveCaches();
38639  clearUnicodeCaches();
38640  WasmImage.cleanup();
38641}
38642
38643;// ./src/core/file_spec.js
38644
38645
38646
38647
38648class FileSpec {
38649  constructor(root) {
38650    if (!(root instanceof Dict)) {
38651      return;
38652    }
38653    this.root = root;
38654    if (root.has("FS")) {
38655      this.fs = root.get("FS");
38656    }
38657    if (root.has("RF")) {
38658      warn("Related file specifications are not supported");
38659    }
38660  }
38661  get filename() {
38662    const item = FileSpec.pickPlatformItem(this.root);
38663    if (item && typeof item === "string") {
38664      return stringToPDFString(item, true).replaceAll("\\\\", "\\").replaceAll("\\/", "/").replaceAll("\\", "/");
38665    }
38666    return "";
38667  }
38668  get description() {
38669    const desc = this.root?.get("Desc");
38670    if (desc && typeof desc === "string") {
38671      return stringToPDFString(desc);
38672    }
38673    return "";
38674  }
38675  get serializable() {
38676    const {
38677      filename,
38678      description
38679    } = this;
38680    return {
38681      rawFilename: filename,
38682      filename: stripPath(filename) || "unnamed",
38683      description
38684    };
38685  }
38686  static pickPlatformItem(dict, raw = false) {
38687    if (dict instanceof Dict) {
38688      for (const key of ["UF", "F", "Unix", "Mac", "DOS"]) {
38689        if (dict.has(key)) {
38690          return raw ? dict.getRaw(key) : dict.get(key);
38691        }
38692      }
38693    }
38694    return null;
38695  }
38696  static hasEmbeddedFile(fileSpecDict) {
38697    return this.pickPlatformItem(fileSpecDict.get("EF")) instanceof BaseStream;
38698  }
38699  static readContent(dict) {
38700    if (!(dict instanceof Dict)) {
38701      return null;
38702    }
38703    const ef = this.pickPlatformItem(dict.get("EF"));
38704    if (!(ef instanceof BaseStream)) {
38705      warn("Embedded file specification points to non-existing/invalid content");
38706      return null;
38707    }
38708    return this.readStreamContent(ef);
38709  }
38710  static readStreamContent(stream) {
38711    const encrypt = stream.dict?.xref?.encrypt;
38712    if (encrypt?.encryptionKey === null) {
38713      throw new PasswordException("No password given", PasswordResponses.NEED_PASSWORD);
38714    }
38715    return stream.getBytes();
38716  }
38717}
38718
38719;// ./src/core/xml_parser.js
38720
38721
38722const XMLParserErrorCode = {
38723  NoError: 0,
38724  EndOfDocument: -1,
38725  UnterminatedCdat: -2,
38726  UnterminatedXmlDeclaration: -3,
38727  UnterminatedDoctypeDeclaration: -4,
38728  UnterminatedComment: -5,
38729  MalformedElement: -6,
38730  OutOfMemory: -7,
38731  UnterminatedAttributeValue: -8,
38732  UnterminatedElement: -9,
38733  ElementNeverBegun: -10
38734};
38735function isWhitespace(s, index) {
38736  const ch = s[index];
38737  return ch === " " || ch === "\n" || ch === "\r" || ch === "\t";
38738}
38739function isWhitespaceString(s) {
38740  for (let i = 0, ii = s.length; i < ii; i++) {
38741    if (!isWhitespace(s, i)) {
38742      return false;
38743    }
38744  }
38745  return true;
38746}
38747class XMLParserBase {
38748  static get _entityRegex() {
38749    return shadow(this, "_entityRegex", /&(?:#x([^;]+)|#([^;]+)|([^;]+));/g);
38750  }
38751  _resolveEntities(s) {
38752    return s.replaceAll(XMLParserBase._entityRegex, (_, hex, dec, entity) => {
38753      if (hex) {
38754        return String.fromCodePoint(parseInt(hex, 16));
38755      }
38756      if (dec) {
38757        return String.fromCodePoint(parseInt(dec
vendor: 10,729 bytes, lines 38757-39141
38757, 10));
38758      }
38759      switch (entity) {
38760        case "lt":
38761          return "<";
38762        case "gt":
38763          return ">";
38764        case "amp":
38765          return "&";
38766        case "quot":
38767          return '"';
38768        case "apos":
38769          return "'";
38770      }
38771      return this.onResolveEntity(entity);
38772    });
38773  }
38774  _parseContent(s, start) {
38775    const attributes = [];
38776    let pos = start;
38777    function skipWs() {
38778      while (pos < s.length && isWhitespace(s, pos)) {
38779        ++pos;
38780      }
38781    }
38782    while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "/") {
38783      ++pos;
38784    }
38785    const name = s.substring(start, pos);
38786    skipWs();
38787    while (pos < s.length && s[pos] !== ">" && s[pos] !== "/" && s[pos] !== "?") {
38788      skipWs();
38789      let attrName = "",
38790        attrValue = "";
38791      while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== "=") {
38792        attrName += s[pos];
38793        ++pos;
38794      }
38795      skipWs();
38796      if (s[pos] !== "=") {
38797        return null;
38798      }
38799      ++pos;
38800      skipWs();
38801      const attrEndChar = s[pos];
38802      if (attrEndChar !== '"' && attrEndChar !== "'") {
38803        return null;
38804      }
38805      const attrEndIndex = s.indexOf(attrEndChar, ++pos);
38806      if (attrEndIndex < 0) {
38807        return null;
38808      }
38809      attrValue = s.substring(pos, attrEndIndex);
38810      attributes.push({
38811        name: attrName,
38812        value: this._resolveEntities(attrValue)
38813      });
38814      pos = attrEndIndex + 1;
38815      skipWs();
38816    }
38817    return {
38818      name,
38819      attributes,
38820      parsed: pos - start
38821    };
38822  }
38823  _parseProcessingInstruction(s, start) {
38824    let pos = start;
38825    function skipWs() {
38826      while (pos < s.length && isWhitespace(s, pos)) {
38827        ++pos;
38828      }
38829    }
38830    while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && s[pos] !== "?" && s[pos] !== "/") {
38831      ++pos;
38832    }
38833    const name = s.substring(start, pos);
38834    skipWs();
38835    const attrStart = pos;
38836    while (pos < s.length && (s[pos] !== "?" || s[pos + 1] !== ">")) {
38837      ++pos;
38838    }
38839    const value = s.substring(attrStart, pos);
38840    return {
38841      name,
38842      value,
38843      parsed: pos - start
38844    };
38845  }
38846  parseXml(s) {
38847    let i = 0;
38848    while (i < s.length) {
38849      const ch = s[i];
38850      let j = i;
38851      if (ch === "<") {
38852        ++j;
38853        const ch2 = s[j];
38854        let q;
38855        switch (ch2) {
38856          case "/":
38857            ++j;
38858            q = s.indexOf(">", j);
38859            if (q < 0) {
38860              this.onError(XMLParserErrorCode.UnterminatedElement);
38861              return;
38862            }
38863            this.onEndElement(s.substring(j, q));
38864            j = q + 1;
38865            break;
38866          case "?":
38867            ++j;
38868            const pi = this._parseProcessingInstruction(s, j);
38869            if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== "?>") {
38870              this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration);
38871              return;
38872            }
38873            this.onPi(pi.name, pi.value);
38874            j += pi.parsed + 2;
38875            break;
38876          case "!":
38877            if (s.substring(j + 1, j + 3) === "--") {
38878              q = s.indexOf("-->", j + 3);
38879              if (q < 0) {
38880                this.onError(XMLParserErrorCode.UnterminatedComment);
38881                return;
38882              }
38883              this.onComment(s.substring(j + 3, q));
38884              j = q + 3;
38885            } else if (s.substring(j + 1, j + 8) === "[CDATA[") {
38886              q = s.indexOf("]]>", j + 8);
38887              if (q < 0) {
38888                this.onError(XMLParserErrorCode.UnterminatedCdat);
38889                return;
38890              }
38891              this.onCdata(s.substring(j + 8, q));
38892              j = q + 3;
38893            } else if (s.substring(j + 1, j + 8) === "DOCTYPE") {
38894              const q2 = s.indexOf("[", j + 8);
38895              let complexDoctype = false;
38896              q = s.indexOf(">", j + 8);
38897              if (q < 0) {
38898                this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
38899                return;
38900              }
38901              if (q2 > 0 && q > q2) {
38902                q = s.indexOf("]>", j + 8);
38903                if (q < 0) {
38904                  this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration);
38905                  return;
38906                }
38907                complexDoctype = true;
38908              }
38909              const doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0));
38910              this.onDoctype(doctypeContent);
38911              j = q + (complexDoctype ? 2 : 1);
38912            } else {
38913              this.onError(XMLParserErrorCode.MalformedElement);
38914              return;
38915            }
38916            break;
38917          default:
38918            const content = this._parseContent(s, j);
38919            if (content === null) {
38920              this.onError(XMLParserErrorCode.MalformedElement);
38921              return;
38922            }
38923            let isClosed = false;
38924            if (s.substring(j + content.parsed, j + content.parsed + 2) === "/>") {
38925              isClosed = true;
38926            } else if (s.substring(j + content.parsed, j + content.parsed + 1) !== ">") {
38927              this.onError(XMLParserErrorCode.UnterminatedElement);
38928              return;
38929            }
38930            this.onBeginElement(content.name, content.attributes, isClosed);
38931            j += content.parsed + (isClosed ? 2 : 1);
38932            break;
38933        }
38934      } else {
38935        while (j < s.length && s[j] !== "<") {
38936          j++;
38937        }
38938        const text = s.substring(i, j);
38939        this.onText(this._resolveEntities(text));
38940      }
38941      i = j;
38942    }
38943  }
38944  onResolveEntity(name) {
38945    return `&${name};`;
38946  }
38947  onPi(name, value) {}
38948  onComment(text) {}
38949  onCdata(text) {}
38950  onDoctype(doctypeContent) {}
38951  onText(text) {}
38952  onBeginElement(name, attributes, isEmpty) {}
38953  onEndElement(name) {}
38954  onError(code) {}
38955}
38956class SimpleDOMNode {
38957  constructor(nodeName, nodeValue) {
38958    this.nodeName = nodeName;
38959    this.nodeValue = nodeValue;
38960    Object.defineProperty(this, "parentNode", {
38961      value: null,
38962      writable: true
38963    });
38964  }
38965  get firstChild() {
38966    return this.childNodes?.[0];
38967  }
38968  get nextSibling() {
38969    const childNodes = this.parentNode.childNodes;
38970    if (!childNodes) {
38971      return undefined;
38972    }
38973    const index = childNodes.indexOf(this);
38974    if (index === -1) {
38975      return undefined;
38976    }
38977    return childNodes[index + 1];
38978  }
38979  get textContent() {
38980    if (!this.childNodes) {
38981      return this.nodeValue || "";
38982    }
38983    return this.childNodes.map(child => child.textContent).join("");
38984  }
38985  get children() {
38986    return this.childNodes || [];
38987  }
38988  hasChildNodes() {
38989    return this.childNodes?.length > 0;
38990  }
38991  searchNode(paths, pos) {
38992    if (pos >= paths.length) {
38993      return this;
38994    }
38995    const component = paths[pos];
38996    if (component.name.startsWith("#") && pos < paths.length - 1) {
38997      return this.searchNode(paths, pos + 1);
38998    }
38999    const stack = [];
39000    let node = this;
39001    while (true) {
39002      if (component.name === node.nodeName) {
39003        if (component.pos === 0) {
39004          const res = node.searchNode(paths, pos + 1);
39005          if (res !== null) {
39006            return res;
39007          }
39008        } else if (stack.length === 0) {
39009          return null;
39010        } else {
39011          const [parent] = stack.pop();
39012          let siblingPos = 0;
39013          for (const child of parent.childNodes) {
39014            if (component.name === child.nodeName) {
39015              if (siblingPos === component.pos) {
39016                return child.searchNode(paths, pos + 1);
39017              }
39018              siblingPos++;
39019            }
39020          }
39021          return node.searchNode(paths, pos + 1);
39022        }
39023      }
39024      if (node.childNodes?.length > 0) {
39025        stack.push([node, 0]);
39026        node = node.childNodes[0];
39027      } else if (stack.length === 0) {
39028        return null;
39029      } else {
39030        while (stack.length !== 0) {
39031          const [parent, currentPos] = stack.pop();
39032          const newPos = currentPos + 1;
39033          if (newPos < parent.childNodes.length) {
39034            stack.push([parent, newPos]);
39035            node = parent.childNodes[newPos];
39036            break;
39037          }
39038        }
39039        if (stack.length === 0) {
39040          return null;
39041        }
39042      }
39043    }
39044  }
39045  dump(buffer) {
39046    if (this.nodeName === "#text") {
39047      buffer.push(encodeToXmlString(this.nodeValue));
39048      return;
39049    }
39050    buffer.push(`<${this.nodeName}`);
39051    if (this.attributes) {
39052      for (const attribute of this.attributes) {
39053        buffer.push(` ${attribute.name}="${encodeToXmlString(attribute.value)}"`);
39054      }
39055    }
39056    if (this.hasChildNodes()) {
39057      buffer.push(">");
39058      for (const child of this.childNodes) {
39059        child.dump(buffer);
39060      }
39061      buffer.push(`</${this.nodeName}>`);
39062    } else if (this.nodeValue) {
39063      buffer.push(`>${encodeToXmlString(this.nodeValue)}</${this.nodeName}>`);
39064    } else {
39065      buffer.push("/>");
39066    }
39067  }
39068}
39069class SimpleXMLParser extends XMLParserBase {
39070  constructor({
39071    hasAttributes = false,
39072    lowerCaseName = false
39073  }) {
39074    super();
39075    this._currentFragment = null;
39076    this._stack = null;
39077    this._errorCode = XMLParserErrorCode.NoError;
39078    this._hasAttributes = hasAttributes;
39079    this._lowerCaseName = lowerCaseName;
39080  }
39081  parseFromString(data) {
39082    this._currentFragment = [];
39083    this._stack = [];
39084    this._errorCode = XMLParserErrorCode.NoError;
39085    this.parseXml(data);
39086    if (this._errorCode !== XMLParserErrorCode.NoError) {
39087      return undefined;
39088    }
39089    const [documentElement] = this._currentFragment;
39090    if (!documentElement) {
39091      return undefined;
39092    }
39093    return {
39094      documentElement
39095    };
39096  }
39097  onText(text) {
39098    if (isWhitespaceString(text)) {
39099      return;
39100    }
39101    const node = new SimpleDOMNode("#text", text);
39102    this._currentFragment.push(node);
39103  }
39104  onCdata(text) {
39105    const node = new SimpleDOMNode("#text", text);
39106    this._currentFragment.push(node);
39107  }
39108  onBeginElement(name, attributes, isEmpty) {
39109    if (this._lowerCaseName) {
39110      name = name.toLowerCase();
39111    }
39112    const node = new SimpleDOMNode(name);
39113    node.childNodes = [];
39114    if (this._hasAttributes) {
39115      node.attributes = attributes;
39116    }
39117    this._currentFragment.push(node);
39118    if (isEmpty) {
39119      return;
39120    }
39121    this._stack.push(this._currentFragment);
39122    this._currentFragment = node.childNodes;
39123  }
39124  onEndElement(name) {
39125    this._currentFragment = this._stack.pop() || [];
39126    const lastElement = this._currentFragment.at(-1);
39127    if (!lastElement) {
39128      return null;
39129    }
39130    for (const childNode of lastElement.childNodes) {
39131      childNode.parentNode = lastElement;
39132    }
39133    return lastElement;
39134  }
39135  onError(code) {
39136    this._errorCode = code;
39137  }
39138}
39139
39140;// ./src/core/metadata_parser.js
39141
vendor: 3,617 bytes, lines 39142-39272
39142class MetadataParser {
39143  constructor(data) {
39144    data = this._repair(data);
39145    const parser = new SimpleXMLParser({
39146      lowerCaseName: true
39147    });
39148    const xmlDocument = parser.parseFromString(data);
39149    this._metadataMap = new Map();
39150    this._data = data;
39151    if (xmlDocument) {
39152      this._parse(xmlDocument);
39153    }
39154  }
39155  _repair(data) {
39156    return data.replace(/^[^<]+/, "").replaceAll(/>\\376\\377([^<]+)/g, function (all, codes) {
39157      const bytes = codes.replaceAll(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
39158        return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
39159      }).replaceAll(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
39160        switch (name) {
39161          case "amp":
39162            return "&";
39163          case "apos":
39164            return "'";
39165          case "gt":
39166            return ">";
39167          case "lt":
39168            return "<";
39169          case "quot":
39170            return '"';
39171        }
39172        throw new Error(`_repair: ${name} isn't defined.`);
39173      });
39174      const charBuf = [">"];
39175      for (let i = 0, ii = bytes.length; i < ii; i += 2) {
39176        const code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
39177        if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) {
39178          charBuf.push(String.fromCharCode(code));
39179        } else {
39180          charBuf.push("&#x" + (0x10000 + code).toString(16).substring(1) + ";");
39181        }
39182      }
39183      return charBuf.join("");
39184    });
39185  }
39186  _getSequence(entry) {
39187    const name = entry.nodeName;
39188    if (name !== "rdf:bag" && name !== "rdf:seq" && name !== "rdf:alt") {
39189      return null;
39190    }
39191    return entry.childNodes.filter(node => node.nodeName === "rdf:li");
39192  }
39193  _parseArray(entry) {
39194    if (!entry.hasChildNodes()) {
39195      return;
39196    }
39197    const [seqNode] = entry.childNodes;
39198    const sequence = this._getSequence(seqNode) || [];
39199    this._metadataMap.set(entry.nodeName, sequence.map(node => node.textContent.trim()));
39200  }
39201  _parse(xmlDocument) {
39202    let rdf = xmlDocument.documentElement;
39203    if (rdf.nodeName !== "rdf:rdf") {
39204      rdf = rdf.firstChild;
39205      while (rdf && rdf.nodeName !== "rdf:rdf") {
39206        rdf = rdf.nextSibling;
39207      }
39208    }
39209    if (!rdf || rdf.nodeName !== "rdf:rdf" || !rdf.hasChildNodes()) {
39210      return;
39211    }
39212    for (const desc of rdf.childNodes) {
39213      if (desc.nodeName !== "rdf:description") {
39214        continue;
39215      }
39216      for (const entry of desc.childNodes) {
39217        const name = entry.nodeName;
39218        switch (name) {
39219          case "#text":
39220            continue;
39221          case "dc:creator":
39222          case "dc:subject":
39223            this._parseArray(entry);
39224            continue;
39225        }
39226        this._metadataMap.set(name, entry.textContent.trim());
39227      }
39228    }
39229  }
39230  get serializable() {
39231    return {
39232      parsedData: this._metadataMap,
39233      rawData: this._data
39234    };
39235  }
39236}
39237
39238;// ./src/core/struct_tree.js
39239
39240
39241
39242
39243
39244
39245
39246const MAX_DEPTH = 40;
39247const StructElementType = {
39248  PAGE_CONTENT: 1,
39249  STREAM_CONTENT: 2,
39250  OBJECT: 3,
39251  ANNOTATION: 4,
39252  ELEMENT: 5
39253};
39254class StructTreeRoot {
39255  kidRefToPosition = undefined;
39256  parentTree = null;
39257  roleMap = new Map();
39258  structParentIds = null;
39259  constructor(xref, rootDict, rootRef) {
39260    this.xref = xref;
39261    this.dict = rootDict;
39262    this.ref = rootRef instanceof Ref ? rootRef : null;
39263    const roleMap = rootDict.get("RoleMap");
39264    if (roleMap instanceof Dict) {
39265      for (const [key, value] of roleMap) {
39266        if (value instanceof Name) {
39267          this.roleMap.set(key, value.name);
39268        }
39269      }
39270    }
39271    const parentTree = rootDict.getRaw("ParentTree");
39272    if (parentTree) {
39273      this.parentTree = new NumberTree(parentTree, xref);
39274    }
39275  }
39276  getKidPosition(kidRef) {
39277    if (this.kidRefToPosition === undefined) {
39278      const obj = this.dict.get("K");
39279      if (Array.isArray(obj)) {
39280        const map = this.kidRefToPosition = new Map();
39281        for (let i = 0, ii = obj.length; i < ii; i++) {
39282          const ref = obj[i];
39283          if (ref) {
39284            map.set(ref.toString(), i);
39285          }
39286        }
39287      } else if (obj instanceof Dict) {
39288        this.kidRefToPosition = new Map([[obj.objId, 0]]);
39289      } else if (!obj) {
39290        this.kidRefToPosition = new Map();
39291      } else {
39292        this.kidRefToPosition = null;
39293      }
39294    }
39295    return this.kidRefToPosition ? this.kidRefToPosition.get(kidRef) ?? NaN : -1;
39296  }
39297  #addIdToPage(pageRef, id, type) {
39298    if (!(pageRef instanceof Ref) || id < 0) {
39299      return;
39300    }
39301    this.structParentIds ||= new RefSetCache();
39302    let ids = this.structParentIds.get(pageRef);
39303    if (!ids) {
39304      ids = [];
39305      this.structParentIds.put(pageRef, ids);
39306    }
39307    ids.push([id, type]);
39308  }
39309  addAnnotationIdToPage(pageRef, id) {
39310    this.#addIdToPage(pageRef, id, StructElementType.ANNOTATION);
39311  }
39312  static async canCreateStructureTree({
39313    catalogRef,
39314    pdfManager,
39315    newAnnotationsByPage
39316  }) {
39317    if (!(catalogRef instanceof Ref)) {
39318      warn("Cannot save the struct tree: no catalog reference.");
39319      return false;
39320    }
39321    let nextKey = 0;
39322    let hasNothingToUpdate = true;
39323    for (const [pageIndex, elements] of newAnnotationsByPage) {
39324      const {
39325        ref: pageRef
39326      } = await pdfManager.getPage(pageIndex);
39327      if (!(pageRef instanceof Ref)) {
39328        warn(`Cannot save the struct tree: page ${pageIndex} has no ref.`);
39329        hasNothingToUpdate = true;
39330        break;
39331      }
39332      for (const element of elements) {
39333        if (element.accessibilityData?.type) {
39334          element.parentTreeId = nextKey++;
39335          hasNothingToUpdate = false;
39336        }
39337      }
39338    }
39339    if (hasNothingToUpdate) {
39340      for (const elements of newAnnotationsByPage.values()) {
39341        for (const element of elements) {
39342          delete element.parentTreeId;
39343        }
39344      }
39345      return false;
39346    }
39347    return true;
39348  }
39349  static async createStructureTree({
39350    newAnnotationsByPage,
39351    xref,
39352    catalogRef,
39353    pdfManager,
39354    changes
39355  }) {
39356    const root = await pdfManager.ensureCatalog("cloneDict");
39357    const cache = new RefSetCache();
39358    cache.put(catalogRef, root);
39359    const structTreeRootRef = xref.getNewTemporaryRef();
39360    root.set("StructTreeRoot", structTreeRootRef);
39361    const structTreeRoot = new Dict(xref);
39362    structTreeRoot.set("Type", Name.get("StructTreeRoot"));
39363    const parentTreeRef = xref.getNewTemporaryRef();
39364    structTreeRoot.set("ParentTree", parentTreeRef);
39365    const kids = [];
39366    structTreeRoot.set("K", kids);
39367    cache.put(structTreeRootRef, structTreeRoot);
39368    const parentTree = new Dict(xref);
39369    const nums = [];
39370    parentTree.set("Nums", nums);
39371    const nextKey = await this.#writeKids({
39372      newAnnotationsByPage,
39373      structTreeRootRef,
39374      structTreeRoot: null,
39375      kids,
39376      nums,
39377      xref,
39378      pdfManager,
39379      changes,
39380      cache
39381    });
39382    structTreeRoot.set("ParentTreeNextKey", nextKey);
39383    cache.put(parentTreeRef, parentTree);
39384    for (const [ref, obj] of cache.items()) {
39385      changes.put(ref, {
39386        data: obj
39387      });
39388    }
39389  }
39390  async canUpdateStructTree({
39391    pdfManager,
39392    newAnnotationsByPage
39393  }) {
39394    if (!this.ref) {
39395      warn("Cannot update the struct tree: no root reference.");
39396      return false;
39397    }
39398    let nextKey = this.dict.get("ParentTreeNextKey");
39399    if (!Number.isInteger(nextKey) || nextKey < 0) {
39400      warn("Cannot update the struct tree: invalid next key.");
39401      return false;
39402    }
39403    const parentTree = this.dict.get("ParentTree");
39404    if (!(parentTree instanceof Dict)) {
39405      warn("Cannot update the struct tree: ParentTree isn't a dict.");
39406      return false;
39407    }
39408    const nums = parentTree.get("Nums");
39409    if (!Array.isArray(nums)) {
39410      warn("Cannot update the struct tree: nums isn't an array.");
39411      return false;
vendor: 15,426 bytes, lines 39412-39969
39412    }
39413    const numberTree = new NumberTree(parentTree, this.xref);
39414    for (const pageIndex of newAnnotationsByPage.keys()) {
39415      const {
39416        pageDict
39417      } = await pdfManager.getPage(pageIndex);
39418      if (!pageDict.has("StructParents")) {
39419        continue;
39420      }
39421      const id = pageDict.get("StructParents");
39422      if (!Number.isInteger(id) || !Array.isArray(numberTree.get(id))) {
39423        warn(`Cannot save the struct tree: page ${pageIndex} has a wrong id.`);
39424        return false;
39425      }
39426    }
39427    let hasNothingToUpdate = true;
39428    for (const [pageIndex, elements] of newAnnotationsByPage) {
39429      const {
39430        pageDict
39431      } = await pdfManager.getPage(pageIndex);
39432      StructTreeRoot.#collectParents({
39433        elements,
39434        xref: this.xref,
39435        pageDict,
39436        numberTree
39437      });
39438      for (const element of elements) {
39439        if (element.accessibilityData?.type) {
39440          if (!(element.accessibilityData.structParent >= 0)) {
39441            element.parentTreeId = nextKey++;
39442          }
39443          hasNothingToUpdate = false;
39444        }
39445      }
39446    }
39447    if (hasNothingToUpdate) {
39448      for (const elements of newAnnotationsByPage.values()) {
39449        for (const element of elements) {
39450          delete element.parentTreeId;
39451          delete element.structTreeParent;
39452        }
39453      }
39454      return false;
39455    }
39456    return true;
39457  }
39458  async updateStructureTree({
39459    newAnnotationsByPage,
39460    pdfManager,
39461    changes
39462  }) {
39463    const {
39464      ref: structTreeRootRef,
39465      xref
39466    } = this;
39467    const structTreeRoot = this.dict.clone();
39468    const cache = new RefSetCache();
39469    cache.put(structTreeRootRef, structTreeRoot);
39470    let parentTreeRef = structTreeRoot.getRaw("ParentTree");
39471    let parentTree;
39472    if (parentTreeRef instanceof Ref) {
39473      parentTree = xref.fetch(parentTreeRef);
39474    } else {
39475      parentTree = parentTreeRef;
39476      parentTreeRef = xref.getNewTemporaryRef();
39477      structTreeRoot.set("ParentTree", parentTreeRef);
39478    }
39479    parentTree = parentTree.clone();
39480    cache.put(parentTreeRef, parentTree);
39481    let nums = parentTree.getRaw("Nums");
39482    let numsRef = null;
39483    if (nums instanceof Ref) {
39484      numsRef = nums;
39485      nums = xref.fetch(numsRef);
39486    }
39487    nums = nums.slice();
39488    if (!numsRef) {
39489      parentTree.set("Nums", nums);
39490    }
39491    const newNextKey = await StructTreeRoot.#writeKids({
39492      newAnnotationsByPage,
39493      structTreeRootRef,
39494      structTreeRoot: this,
39495      kids: null,
39496      nums,
39497      xref,
39498      pdfManager,
39499      changes,
39500      cache
39501    });
39502    if (newNextKey === -1) {
39503      return;
39504    }
39505    structTreeRoot.set("ParentTreeNextKey", newNextKey);
39506    if (numsRef) {
39507      cache.put(numsRef, nums);
39508    }
39509    for (const [ref, obj] of cache.items()) {
39510      changes.put(ref, {
39511        data: obj
39512      });
39513    }
39514  }
39515  static async #writeKids({
39516    newAnnotationsByPage,
39517    structTreeRootRef,
39518    structTreeRoot,
39519    kids,
39520    nums,
39521    xref,
39522    pdfManager,
39523    changes,
39524    cache
39525  }) {
39526    const objr = Name.get("OBJR");
39527    let nextKey = -1;
39528    let structTreePageObjs;
39529    for (const [pageIndex, elements] of newAnnotationsByPage) {
39530      const page = await pdfManager.getPage(pageIndex);
39531      const {
39532        ref: pageRef
39533      } = page;
39534      const isPageRef = pageRef instanceof Ref;
39535      for (const {
39536        accessibilityData,
39537        ref,
39538        parentTreeId,
39539        structTreeParent
39540      } of elements) {
39541        if (!accessibilityData?.type) {
39542          continue;
39543        }
39544        const {
39545          structParent
39546        } = accessibilityData;
39547        if (structTreeRoot && Number.isInteger(structParent) && structParent >= 0) {
39548          let objs = (structTreePageObjs ||= new Map()).get(pageIndex);
39549          if (objs === undefined) {
39550            const structTreePage = new StructTreePage(structTreeRoot, page.pageDict);
39551            objs = structTreePage.collectObjects(pageRef);
39552            structTreePageObjs.set(pageIndex, objs);
39553          }
39554          const objRef = objs?.get(structParent);
39555          if (objRef) {
39556            const tagDict = xref.fetch(objRef).clone();
39557            StructTreeRoot.#writeProperties(tagDict, accessibilityData);
39558            changes.put(objRef, {
39559              data: tagDict
39560            });
39561            continue;
39562          }
39563        }
39564        nextKey = Math.max(nextKey, parentTreeId);
39565        const tagRef = xref.getNewTemporaryRef();
39566        const tagDict = new Dict(xref);
39567        StructTreeRoot.#writeProperties(tagDict, accessibilityData);
39568        await this.#updateParentTag({
39569          structTreeParent,
39570          tagDict,
39571          newTagRef: tagRef,
39572          structTreeRootRef,
39573          fallbackKids: kids,
39574          xref,
39575          cache
39576        });
39577        const objDict = new Dict(xref);
39578        tagDict.set("K", objDict);
39579        objDict.set("Type", objr);
39580        if (isPageRef) {
39581          objDict.set("Pg", pageRef);
39582        }
39583        objDict.set("Obj", ref);
39584        cache.put(tagRef, tagDict);
39585        nums.push(parentTreeId, tagRef);
39586      }
39587    }
39588    return nextKey + 1;
39589  }
39590  static #writeProperties(tagDict, {
39591    type,
39592    title,
39593    lang,
39594    alt,
39595    expanded,
39596    actualText
39597  }) {
39598    tagDict.set("S", Name.get(type));
39599    if (title) {
39600      tagDict.set("T", stringToAsciiOrUTF16BE(title));
39601    }
39602    if (lang) {
39603      tagDict.set("Lang", stringToAsciiOrUTF16BE(lang));
39604    }
39605    if (alt) {
39606      tagDict.set("Alt", stringToAsciiOrUTF16BE(alt));
39607    }
39608    if (expanded) {
39609      tagDict.set("E", stringToAsciiOrUTF16BE(expanded));
39610    }
39611    if (actualText) {
39612      tagDict.set("ActualText", stringToAsciiOrUTF16BE(actualText));
39613    }
39614  }
39615  static #collectParents({
39616    elements,
39617    xref,
39618    pageDict,
39619    numberTree
39620  }) {
39621    const idToElements = new Map();
39622    for (const element of elements) {
39623      if (element.structTreeParentId) {
39624        const id = parseInt(element.structTreeParentId.split("_mc")[1], 10);
39625        idToElements.getOrInsertComputed(id, makeArr).push(element);
39626      }
39627    }
39628    const id = pageDict.get("StructParents");
39629    if (!Number.isInteger(id)) {
39630      return;
39631    }
39632    const parentArray = numberTree.get(id);
39633    const updateElement = (kid, pageKid, kidRef) => {
39634      const elems = idToElements.get(kid);
39635      if (elems) {
39636        const parentRef = pageKid.getRaw("P");
39637        const parentDict = xref.fetchIfRef(parentRef);
39638        if (parentRef instanceof Ref && parentDict instanceof Dict) {
39639          const params = {
39640            ref: kidRef,
39641            dict: pageKid
39642          };
39643          for (const element of elems) {
39644            element.structTreeParent = params;
39645          }
39646        }
39647        return true;
39648      }
39649      return false;
39650    };
39651    for (const kidRef of parentArray) {
39652      if (!(kidRef instanceof Ref)) {
39653        continue;
39654      }
39655      const pageKid = xref.fetch(kidRef);
39656      const k = pageKid.get("K");
39657      if (Number.isInteger(k)) {
39658        updateElement(k, pageKid, kidRef);
39659        continue;
39660      }
39661      if (!Array.isArray(k)) {
39662        continue;
39663      }
39664      for (let kid of k) {
39665        kid = xref.fetchIfRef(kid);
39666        if (Number.isInteger(kid) && updateElement(kid, pageKid, kidRef)) {
39667          break;
39668        }
39669        if (!(kid instanceof Dict)) {
39670          continue;
39671        }
39672        if (!isName(kid.get("Type"), "MCR")) {
39673          break;
39674        }
39675        const mcid = kid.get("MCID");
39676        if (Number.isInteger(mcid) && updateElement(mcid, pageKid, kidRef)) {
39677          break;
39678        }
39679      }
39680    }
39681  }
39682  static async #updateParentTag({
39683    structTreeParent,
39684    tagDict,
39685    newTagRef,
39686    structTreeRootRef,
39687    fallbackKids,
39688    xref,
39689    cache
39690  }) {
39691    let ref = null;
39692    let parentRef;
39693    if (structTreeParent) {
39694      ({
39695        ref
39696      } = structTreeParent);
39697      parentRef = structTreeParent.dict.getRaw("P") || structTreeRootRef;
39698    } else {
39699      parentRef = structTreeRootRef;
39700    }
39701    tagDict.set("P", parentRef);
39702    const parentDict = xref.fetchIfRef(parentRef);
39703    if (!parentDict) {
39704      fallbackKids.push(newTagRef);
39705      return;
39706    }
39707    let cachedParentDict = cache.get(parentRef);
39708    if (!cachedParentDict) {
39709      cachedParentDict = parentDict.clone();
39710      cache.put(parentRef, cachedParentDict);
39711    }
39712    const parentKidsRaw = cachedParentDict.getRaw("K");
39713    let cachedParentKids = parentKidsRaw instanceof Ref ? cache.get(parentKidsRaw) : null;
39714    if (!cachedParentKids) {
39715      cachedParentKids = xref.fetchIfRef(parentKidsRaw);
39716      cachedParentKids = Array.isArray(cachedParentKids) ? cachedParentKids.slice() : [parentKidsRaw];
39717      const parentKidsRef = xref.getNewTemporaryRef();
39718      cachedParentDict.set("K", parentKidsRef);
39719      cache.put(parentKidsRef, cachedParentKids);
39720    }
39721    const index = cachedParentKids.indexOf(ref);
39722    cachedParentKids.splice(index >= 0 ? index + 1 : cachedParentKids.length, 0, newTagRef);
39723  }
39724}
39725class StructElementNode {
39726  constructor(tree, dict) {
39727    this.tree = tree;
39728    this.xref = tree.xref;
39729    this.dict = dict;
39730    this.kids = [];
39731    this.parseKids();
39732  }
39733  get role() {
39734    const nameObj = this.dict.get("S");
39735    const name = nameObj instanceof Name ? nameObj.name : "";
39736    const {
39737      root
39738    } = this.tree;
39739    return root.roleMap.get(name) ?? name;
39740  }
39741  get mathML() {
39742    let AFs = this.dict.get("AF") || [];
39743    if (!Array.isArray(AFs)) {
39744      AFs = [AFs];
39745    }
39746    for (let af of AFs) {
39747      af = this.xref.fetchIfRef(af);
39748      if (!isDict(af, "Filespec") || !isName(af.get("AFRelationship"), "Supplement")) {
39749        continue;
39750      }
39751      const fileStream = FileSpec.pickPlatformItem(af.get("EF"));
39752      if (!(fileStream instanceof BaseStream) || !isDict(fileStream.dict, "EmbeddedFile") || !isName(fileStream.dict.get("Subtype"), "application/mathml+xml")) {
39753        continue;
39754      }
39755      return stringToUTF8String(fileStream.getString());
39756    }
39757    const A = this.dict.get("A");
39758    if (A instanceof Dict) {
39759      const O = A.get("O");
39760      if (isName(O, "MSFT_Office")) {
39761        const mathml = A.get("MSFT_MathML");
39762        return mathml ? stringToPDFString(mathml) : null;
39763      }
39764    }
39765    return null;
39766  }
39767  parseKids() {
39768    let pageObjId = null;
39769    const objRef = this.dict.getRaw("Pg");
39770    if (objRef instanceof Ref) {
39771      pageObjId = objRef.toString();
39772    }
39773    const kids = this.dict.get("K");
39774    if (Array.isArray(kids)) {
39775      for (const kid of kids) {
39776        const element = this.parseKid(pageObjId, this.xref.fetchIfRef(kid));
39777        if (element) {
39778          this.kids.push(element);
39779        }
39780      }
39781    } else {
39782      const element = this.parseKid(pageObjId, kids);
39783      if (element) {
39784        this.kids.push(element);
39785      }
39786    }
39787  }
39788  parseKid(pageObjId, kid) {
39789    if (Number.isInteger(kid)) {
39790      if (this.tree.pageDict.objId !== pageObjId) {
39791        return null;
39792      }
39793      return new StructElement({
39794        type: StructElementType.PAGE_CONTENT,
39795        mcid: kid,
39796        pageObjId
39797      });
39798    }
39799    if (!(kid instanceof Dict)) {
39800      return null;
39801    }
39802    const pageRef = kid.getRaw("Pg");
39803    if (pageRef instanceof Ref) {
39804      pageObjId = pageRef.toString();
39805    }
39806    const type = kid.get("Type") instanceof Name ? kid.get("Type").name : null;
39807    if (type === "MCR") {
39808      if (this.tree.pageDict.objId !== pageObjId) {
39809        return null;
39810      }
39811      const kidRef = kid.getRaw("Stm");
39812      return new StructElement({
39813        type: StructElementType.STREAM_CONTENT,
39814        refObjId: kidRef instanceof Ref ? kidRef.toString() : null,
39815        pageObjId,
39816        mcid: kid.get("MCID")
39817      });
39818    }
39819    if (type === "OBJR") {
39820      if (this.tree.pageDict.objId !== pageObjId) {
39821        return null;
39822      }
39823      const kidRef = kid.getRaw("Obj");
39824      return new StructElement({
39825        type: StructElementType.OBJECT,
39826        refObjId: kidRef instanceof Ref ? kidRef.toString() : null,
39827        pageObjId
39828      });
39829    }
39830    return new StructElement({
39831      type: StructElementType.ELEMENT,
39832      dict: kid
39833    });
39834  }
39835}
39836class StructElement {
39837  constructor({
39838    type,
39839    dict = null,
39840    mcid = null,
39841    pageObjId = null,
39842    refObjId = null
39843  }) {
39844    this.type = type;
39845    this.dict = dict;
39846    this.mcid = mcid;
39847    this.pageObjId = pageObjId;
39848    this.refObjId = refObjId;
39849    this.parentNode = null;
39850  }
39851}
39852class StructTreePage {
39853  constructor(structTreeRoot, pageDict) {
39854    this.root = structTreeRoot;
39855    this.xref = structTreeRoot?.xref ?? null;
39856    this.rootDict = structTreeRoot?.dict ?? null;
39857    this.pageDict = pageDict;
39858    this.nodes = [];
39859  }
39860  collectObjects(pageRef) {
39861    if (!this.root || !this.rootDict || !(pageRef instanceof Ref)) {
39862      return null;
39863    }
39864    const parentTree = this.rootDict.get("ParentTree");
39865    if (!parentTree) {
39866      return null;
39867    }
39868    const ids = this.root.structParentIds?.get(pageRef);
39869    if (!ids) {
39870      return null;
39871    }
39872    const map = new Map();
39873    const numberTree = new NumberTree(parentTree, this.xref);
39874    for (const [elemId] of ids) {
39875      const obj = numberTree.getRaw(elemId);
39876      if (obj instanceof Ref) {
39877        map.set(elemId, obj);
39878      }
39879    }
39880    return map;
39881  }
39882  parse(pageRef) {
39883    if (!this.root || !this.rootDict || !(pageRef instanceof Ref)) {
39884      return;
39885    }
39886    const {
39887      parentTree
39888    } = this.root;
39889    if (!parentTree) {
39890      return;
39891    }
39892    const id = this.pageDict.get("StructParents");
39893    const ids = this.root.structParentIds?.get(pageRef);
39894    if (!Number.isInteger(id) && !ids) {
39895      return;
39896    }
39897    const map = new Map();
39898    if (Number.isInteger(id)) {
39899      const parentArray = parentTree.get(id);
39900      if (Array.isArray(parentArray)) {
39901        for (const ref of parentArray) {
39902          if (ref instanceof Ref) {
39903            this.addNode(this.xref.fetch(ref), map);
39904          }
39905        }
39906      }
39907    }
39908    if (!ids) {
39909      return;
39910    }
39911    for (const [elemId, type] of ids) {
39912      const obj = parentTree.get(elemId);
39913      if (obj) {
39914        const elem = this.addNode(this.xref.fetchIfRef(obj), map);
39915        if (elem?.kids?.length === 1 && elem.kids[0].type === StructElementType.OBJECT) {
39916          elem.kids[0].type = type;
39917        }
39918      }
39919    }
39920  }
39921  addNode(dict, map, level = 0) {
39922    if (level > MAX_DEPTH) {
39923      warn("StructTree MAX_DEPTH reached.");
39924      return null;
39925    }
39926    if (!(dict instanceof Dict)) {
39927      return null;
39928    }
39929    if (map.has(dict)) {
39930      return map.get(dict);
39931    }
39932    const element = new StructElementNode(this, dict);
39933    map.set(dict, element);
39934    switch (element.role) {
39935      case "L":
39936      case "LBody":
39937      case "LI":
39938      case "Table":
39939      case "THead":
39940      case "TBody":
39941      case "TFoot":
39942      case "TR":
39943        {
39944          for (const kid of element.kids) {
39945            if (kid.type === StructElementType.ELEMENT) {
39946              this.addNode(kid.dict, map, level - 1);
39947            }
39948          }
39949        }
39950    }
39951    const parent = dict.get("P");
39952    if (!(parent instanceof Dict) || isName(parent.get("Type"), "StructTreeRoot")) {
39953      if (!this.addTopLevelNode(dict, element)) {
39954        map.delete(dict);
39955      }
39956      return element;
39957    }
39958    const parentNode = this.addNode(parent, map, level + 1);
39959    if (!parentNode) {
39960      return element;
39961    }
39962    let save = false;
39963    for (const kid of parentNode.kids) {
39964      if (kid.type === StructElementType.ELEMENT && kid.dict === dict) {
39965        kid.parentNode = element;
39966        save = true;
39967      }
39968    }
39969    if (!save) {
39970      map.delete(dict);
39971    }
39972    return element;
39973  }
39974  addTopLevelNode(dict, element) {
39975    const index = this.root.getKidPosition(dict.objId);
39976    if (isNaN(index)) {
39977      return false;
39978    }
39979    if (index !== -1) {
39980      this.nodes[index] = element;
39981    }
39982    return true;
39983  }
39984  get serializable() {
39985    function nodeToSerializable(node, parent, level = 0) {
39986      if (level > MAX_DEPTH) {
39987        warn("StructTree too deep to be fully serialized.");
39988        return;
39989      }
39990      const obj = Object.create(null);
39991      obj.role = node.role;
39992      obj.children = [];
39993      parent.children.push(obj);
39994      let alt = node.dict.get("Alt");
39995      if (typeof alt !== "string") {
39996        alt = node.dict.get("ActualText");
39997      }
39998      if (typeof alt === "string") {
39999        obj.alt = stringToPDFString(alt);
40000      }
40001      if (obj.role === "Formula") {
40002        try {
40003          const {
40004            mathML
40005          } = node;
40006          if (mathML) {
40007            obj.mathML = mathML;
40008          }
40009        } catch (ex) {
40010          if (ex instanceof MissingDataException) {
40011            throw ex;
40012          }
40013          warn(`Ignoring mathML: "${ex}".`);
40014        }
40015      }
40016      const a = node.dict.get("A");
40017      if (a instanceof Dict) {
40018        const bbox = lookupNormalRect(a.getArray("BBox"), null);
40019        if (bbox) {
40020          obj.bbox = bbox;
40021        } else {
40022          const width = a.get("Width");
40023          const height = a.get("Height");
40024          if (typeof width === "number" && width > 0 && typeof height === "number" && height > 0) {
40025            obj.bbox = [0, 0, width, height];
40026          }
40027        }
40028      }
40029      const lang = node.dict.get("Lang");
40030      if (typeof lang === "string") {
40031        obj.lang = stringToPDFString(lang);
40032      }
40033      for (const kid of node.kids) {
40034        const kidElement = kid.type === StructElementType.ELEMENT ? kid.parentNode : null;
40035        if (kidElement) {
vendor: 10,862 bytes, lines 40036-40421
40036          nodeToSerializable(kidElement, obj, level + 1);
40037          continue;
40038        } else if (kid.type === StructElementType.PAGE_CONTENT || kid.type === StructElementType.STREAM_CONTENT) {
40039          obj.children.push({
40040            type: "content",
40041            id: `p${kid.pageObjId}_mc${kid.mcid}`
40042          });
40043        } else if (kid.type === StructElementType.OBJECT) {
40044          obj.children.push({
40045            type: "object",
40046            id: kid.refObjId
40047          });
40048        } else if (kid.type === StructElementType.ANNOTATION) {
40049          obj.children.push({
40050            type: "annotation",
40051            id: `${AnnotationPrefix}${kid.refObjId}`
40052          });
40053        }
40054      }
40055    }
40056    const root = Object.create(null);
40057    root.children = [];
40058    root.role = "Root";
40059    for (const child of this.nodes) {
40060      if (!child) {
40061        continue;
40062      }
40063      nodeToSerializable(child, root);
40064    }
40065    return root;
40066  }
40067}
40068
40069;// ./src/core/catalog.js
40070
40071
40072
40073
40074
40075
40076
40077
40078
40079
40080
40081
40082const isRef = v => v instanceof Ref;
40083const isValidExplicitDest = _isValidExplicitDest.bind(null, isRef, isName);
40084function fetchDest(dest) {
40085  if (dest instanceof Dict) {
40086    dest = dest.get("D");
40087  }
40088  return isValidExplicitDest(dest) ? dest : null;
40089}
40090function fetchRemoteDest(action) {
40091  let dest = action.get("D");
40092  if (dest) {
40093    if (dest instanceof Name) {
40094      dest = dest.name;
40095    }
40096    if (typeof dest === "string") {
40097      return stringToPDFString(dest, true);
40098    } else if (isValidExplicitDest(dest)) {
40099      return JSON.stringify(dest);
40100    }
40101  }
40102  return null;
40103}
40104class Catalog {
40105  #actualNumPages = null;
40106  #annotationAttachmentIdByRef = new RefSetCache();
40107  #annotationAttachmentRefById = new Map();
40108  #catDict = null;
40109  builtInCMapCache = new Map();
40110  fontCache = new RefSetCache();
40111  globalColorSpaceCache = new GlobalColorSpaceCache();
40112  globalImageCache = new GlobalImageCache();
40113  nonBlendModesSet = new RefSet();
40114  pageDictCache = new RefSetCache();
40115  pageIndexCache = new RefSetCache();
40116  pageKidsCountCache = new RefSetCache();
40117  standardFontDataCache = new Map();
40118  systemFontCache = new Map();
40119  constructor(pdfManager, xref) {
40120    this.pdfManager = pdfManager;
40121    this.xref = xref;
40122    this.#catDict = xref.getCatalogObj();
40123    if (!(this.#catDict instanceof Dict)) {
40124      throw new FormatError("Catalog object is not a dictionary.");
40125    }
40126    this.toplevelPagesDict;
40127  }
40128  cloneDict() {
40129    return this.#catDict.clone();
40130  }
40131  getAttachmentIdForAnnotation(ref) {
40132    let id = this.#annotationAttachmentIdByRef.get(ref);
40133    if (id) {
40134      return id;
40135    }
40136    const baseId = `attachmentRef:${ref.toString()}`;
40137    id = baseId;
40138    let i = 1;
40139    while (this.#annotationAttachmentRefById.has(id) || this.attachments?.has(id)) {
40140      id = `${baseId}-${i++}`;
40141    }
40142    this.#annotationAttachmentIdByRef.put(ref, id);
40143    this.#annotationAttachmentRefById.set(id, ref);
40144    return id;
40145  }
40146  get version() {
40147    const version = this.#catDict.get("Version");
40148    if (version instanceof Name) {
40149      if (PDF_VERSION_REGEXP.test(version.name)) {
40150        return shadow(this, "version", version.name);
40151      }
40152      warn(`Invalid PDF catalog version: ${version.name}`);
40153    }
40154    return shadow(this, "version", null);
40155  }
40156  get lang() {
40157    const lang = this.#catDict.get("Lang");
40158    return shadow(this, "lang", lang && typeof lang === "string" ? stringToPDFString(lang) : null);
40159  }
40160  get needsRendering() {
40161    const needsRendering = this.#catDict.get("NeedsRendering");
40162    return shadow(this, "needsRendering", typeof needsRendering === "boolean" ? needsRendering : false);
40163  }
40164  get collection() {
40165    let collection = null;
40166    try {
40167      const obj = this.#catDict.get("Collection");
40168      if (obj instanceof Dict && obj.size > 0) {
40169        collection = obj;
40170      }
40171    } catch (ex) {
40172      if (ex instanceof MissingDataException) {
40173        throw ex;
40174      }
40175      info("Cannot fetch Collection entry; assuming no collection is present.");
40176    }
40177    return shadow(this, "collection", collection);
40178  }
40179  get acroForm() {
40180    let acroForm = null;
40181    try {
40182      const obj = this.#catDict.get("AcroForm");
40183      if (obj instanceof Dict && obj.size > 0) {
40184        acroForm = obj;
40185      }
40186    } catch (ex) {
40187      if (ex instanceof MissingDataException) {
40188        throw ex;
40189      }
40190      info("Cannot fetch AcroForm entry; assuming no forms are present.");
40191    }
40192    return shadow(this, "acroForm", acroForm);
40193  }
40194  get acroFormRef() {
40195    const value = this.#catDict.getRaw("AcroForm");
40196    return shadow(this, "acroFormRef", value instanceof Ref ? value : null);
40197  }
40198  get metadata() {
40199    const streamRef = this.#catDict.getRaw("Metadata");
40200    if (!(streamRef instanceof Ref)) {
40201      return shadow(this, "metadata", null);
40202    }
40203    let metadata = null;
40204    try {
40205      const stream = this.xref.fetch(streamRef, !this.xref.encrypt?.encryptMetadata);
40206      if (stream instanceof BaseStream && isDict(stream.dict, "Metadata") && isName(stream.dict.get("Subtype"), "XML")) {
40207        const data = stringToUTF8String(stream.getString());
40208        if (data) {
40209          metadata = new MetadataParser(data).serializable;
40210        }
40211      }
40212    } catch (ex) {
40213      if (ex instanceof MissingDataException) {
40214        throw ex;
40215      }
40216      info(`Skipping invalid Metadata: "${ex}".`);
40217    }
40218    return shadow(this, "metadata", metadata);
40219  }
40220  get markInfo() {
40221    let markInfo = null;
40222    try {
40223      markInfo = this.#readMarkInfo();
40224    } catch (ex) {
40225      if (ex instanceof MissingDataException) {
40226        throw ex;
40227      }
40228      warn("Unable to read mark info.");
40229    }
40230    return shadow(this, "markInfo", markInfo);
40231  }
40232  #readMarkInfo() {
40233    const obj = this.#catDict.get("MarkInfo");
40234    if (!(obj instanceof Dict)) {
40235      return null;
40236    }
40237    const markInfo = {
40238      Marked: false,
40239      UserProperties: false,
40240      Suspects: false
40241    };
40242    for (const key in markInfo) {
40243      const value = obj.get(key);
40244      if (typeof value === "boolean") {
40245        markInfo[key] = value;
40246      }
40247    }
40248    return markInfo;
40249  }
40250  get hasStructTree() {
40251    return this.#catDict.has("StructTreeRoot");
40252  }
40253  get structTreeRoot() {
40254    let structTree = null;
40255    try {
40256      structTree = this.#readStructTreeRoot();
40257    } catch (ex) {
40258      if (ex instanceof MissingDataException) {
40259        throw ex;
40260      }
40261      warn("Unable read to structTreeRoot info.");
40262    }
40263    return shadow(this, "structTreeRoot", structTree);
40264  }
40265  #readStructTreeRoot() {
40266    const rawObj = this.#catDict.getRaw("StructTreeRoot"),
40267      obj = this.xref.fetchIfRef(rawObj);
40268    return obj instanceof Dict ? new StructTreeRoot(this.xref, obj, rawObj) : null;
40269  }
40270  get toplevelPagesDict() {
40271    const pagesObj = this.#catDict.get("Pages");
40272    if (!(pagesObj instanceof Dict)) {
40273      throw new FormatError("Invalid top-level pages dictionary.");
40274    }
40275    return shadow(this, "toplevelPagesDict", pagesObj);
40276  }
40277  get documentOutline() {
40278    let obj = null;
40279    try {
40280      obj = this.#readDocumentOutline();
40281    } catch (ex) {
40282      if (ex instanceof MissingDataException) {
40283        throw ex;
40284      }
40285      warn("Unable to read document outline.");
40286    }
40287    return shadow(this, "documentOutline", obj);
40288  }
40289  #readDocumentOutline(options = {}) {
40290    let obj = this.#catDict.get("Outlines");
40291    if (!(obj instanceof Dict)) {
40292      return null;
40293    }
40294    obj = obj.getRaw("First");
40295    if (!(obj instanceof Ref)) {
40296      return null;
40297    }
40298    const root = {
40299      items: []
40300    };
40301    const queue = [{
40302      obj,
40303      parent: root
40304    }];
40305    const processed = new RefSet();
40306    processed.put(obj);
40307    const xref = this.xref,
40308      blackColor = new Uint8ClampedArray(3);
40309    while (queue.length > 0) {
40310      const i = queue.shift();
40311      const outlineDict = xref.fetchIfRef(i.obj);
40312      if (outlineDict === null) {
40313        continue;
40314      }
40315      if (!outlineDict.has("Title")) {
40316        warn("Invalid outline item encountered.");
40317      }
40318      const data = {
40319        url: null,
40320        dest: null,
40321        action: null
40322      };
40323      Catalog.parseDestDictionary({
40324        destDict: outlineDict,
40325        resultObj: data,
40326        docBaseUrl: this.baseUrl,
40327        docAttachments: this.attachments
40328      });
40329      const title = outlineDict.get("Title");
40330      const flags = outlineDict.get("F") || 0;
40331      const color = outlineDict.getArray("C");
40332      const count = outlineDict.get("Count");
40333      let rgbColor = blackColor;
40334      if (isNumberArray(color, 3) && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
40335        rgbColor = ColorSpaceUtils.rgb.getRgb(color, 0);
40336      }
40337      const outlineItem = {
40338        action: data.action,
40339        attachmentId: data.attachmentId,
40340        attachment: data.attachment,
40341        dest: data.dest,
40342        url: data.url,
40343        unsafeUrl: data.unsafeUrl,
40344        newWindow: data.newWindow,
40345        setOCGState: data.setOCGState,
40346        title: typeof title === "string" ? stringToPDFString(title) : "",
40347        color: rgbColor,
40348        count: Number.isInteger(count) ? count : undefined,
40349        bold: !!(flags & 2),
40350        italic: !!(flags & 1),
40351        items: []
40352      };
40353      if (options.keepRawDict) {
40354        outlineItem.rawDict = outlineDict;
40355      }
40356      i.parent.items.push(outlineItem);
40357      obj = outlineDict.getRaw("First");
40358      if (obj instanceof Ref && !processed.has(obj)) {
40359        queue.push({
40360          obj,
40361          parent: outlineItem
40362        });
40363        processed.put(obj);
40364      }
40365      obj = outlineDict.getRaw("Next");
40366      if (obj instanceof Ref && !processed.has(obj)) {
40367        queue.push({
40368          obj,
40369          parent: i.parent
40370        });
40371        processed.put(obj);
40372      }
40373    }
40374    return root.items.length > 0 ? root.items : null;
40375  }
40376  get documentOutlineForEditor() {
40377    let obj = null;
40378    try {
40379      obj = this.#readDocumentOutline({
40380        keepRawDict: true
40381      });
40382    } catch (ex) {
40383      if (ex instanceof MissingDataException) {
40384        throw ex;
40385      }
40386      warn("Unable to read document outline.");
40387    }
40388    return shadow(this, "documentOutlineForEditor", obj);
40389  }
40390  get permissions() {
40391    let permissions = null;
40392    try {
40393      permissions = this.#readPermissions();
40394    } catch (ex) {
40395      if (ex instanceof MissingDataException) {
40396        throw ex;
40397      }
40398      warn("Unable to read permissions.");
40399    }
40400    return shadow(this, "permissions", permissions);
40401  }
40402  #readPermissions() {
40403    const encrypt = this.xref.trailer.get("Encrypt");
40404    if (!(encrypt instanceof Dict)) {
40405      return null;
40406    }
40407    let flags = encrypt.get("P");
40408    if (typeof flags !== "number") {
40409      return null;
40410    }
40411    flags += 2 ** 32;
40412    const permissions = [];
40413    for (const key in PermissionFlag) {
40414      const value = PermissionFlag[key];
40415      if (flags & value) {
40416        permissions.push(value);
40417      }
40418    }
40419    return permissions;
40420  }
40421  get optionalContentConfig() {
vendor: 15,679 bytes, lines 40422-40949
40422    let config = null;
40423    try {
40424      const properties = this.#catDict.get("OCProperties");
40425      if (!properties) {
40426        return shadow(this, "optionalContentConfig", null);
40427      }
40428      const defaultConfig = properties.get("D");
40429      if (!defaultConfig) {
40430        return shadow(this, "optionalContentConfig", null);
40431      }
40432      const groupsData = properties.get("OCGs");
40433      if (!Array.isArray(groupsData)) {
40434        return shadow(this, "optionalContentConfig", null);
40435      }
40436      const groupRefCache = new RefSetCache();
40437      for (const groupRef of groupsData) {
40438        if (!(groupRef instanceof Ref) || groupRefCache.has(groupRef)) {
40439          continue;
40440        }
40441        groupRefCache.put(groupRef, this.#readOptionalContentGroup(groupRef));
40442      }
40443      config = this.#readOptionalContentConfig(defaultConfig, groupRefCache);
40444    } catch (ex) {
40445      if (ex instanceof MissingDataException) {
40446        throw ex;
40447      }
40448      warn(`Unable to read optional content config: ${ex}`);
40449    }
40450    return shadow(this, "optionalContentConfig", config);
40451  }
40452  #readOptionalContentGroup(groupRef) {
40453    const group = this.xref.fetch(groupRef);
40454    const obj = {
40455      id: groupRef.toString(),
40456      name: null,
40457      intent: null,
40458      usage: {
40459        print: null,
40460        view: null
40461      },
40462      rbGroups: []
40463    };
40464    const name = group.get("Name");
40465    if (typeof name === "string") {
40466      obj.name = stringToPDFString(name);
40467    }
40468    let intent = group.getArray("Intent");
40469    if (!Array.isArray(intent)) {
40470      intent = [intent];
40471    }
40472    if (intent.every(i => i instanceof Name)) {
40473      obj.intent = intent.map(i => i.name);
40474    }
40475    const usage = group.get("Usage");
40476    if (!(usage instanceof Dict)) {
40477      return obj;
40478    }
40479    const usageObj = obj.usage;
40480    const print = usage.get("Print");
40481    if (print instanceof Dict) {
40482      const printState = print.get("PrintState");
40483      if (printState instanceof Name) {
40484        switch (printState.name) {
40485          case "ON":
40486          case "OFF":
40487            usageObj.print = {
40488              printState: printState.name
40489            };
40490        }
40491      }
40492    }
40493    const view = usage.get("View");
40494    if (view instanceof Dict) {
40495      const viewState = view.get("ViewState");
40496      if (viewState instanceof Name) {
40497        switch (viewState.name) {
40498          case "ON":
40499          case "OFF":
40500            usageObj.view = {
40501              viewState: viewState.name
40502            };
40503        }
40504      }
40505    }
40506    return obj;
40507  }
40508  #readOptionalContentConfig(config, groupRefCache) {
40509    function parseOnOff(refs) {
40510      const onParsed = [];
40511      if (Array.isArray(refs)) {
40512        for (const value of refs) {
40513          if (value instanceof Ref && groupRefCache.has(value)) {
40514            onParsed.push(value.toString());
40515          }
40516        }
40517      }
40518      return onParsed;
40519    }
40520    function parseOrder(refs, nestedLevels = 0) {
40521      if (!Array.isArray(refs)) {
40522        return null;
40523      }
40524      const order = [];
40525      for (const value of refs) {
40526        if (value instanceof Ref && groupRefCache.has(value)) {
40527          parsedOrderRefs.put(value);
40528          order.push(value.toString());
40529          continue;
40530        }
40531        const nestedOrder = parseNestedOrder(value, nestedLevels);
40532        if (nestedOrder) {
40533          order.push(nestedOrder);
40534        }
40535      }
40536      if (nestedLevels > 0) {
40537        return order;
40538      }
40539      const hiddenGroups = [];
40540      for (const [groupRef] of groupRefCache.items()) {
40541        if (parsedOrderRefs.has(groupRef)) {
40542          continue;
40543        }
40544        hiddenGroups.push(groupRef.toString());
40545      }
40546      if (hiddenGroups.length) {
40547        order.push({
40548          name: null,
40549          order: hiddenGroups
40550        });
40551      }
40552      return order;
40553    }
40554    function parseNestedOrder(ref, nestedLevels) {
40555      if (++nestedLevels > MAX_NESTED_LEVELS) {
40556        warn("parseNestedOrder - reached MAX_NESTED_LEVELS.");
40557        return null;
40558      }
40559      const value = xref.fetchIfRef(ref);
40560      if (!Array.isArray(value)) {
40561        return null;
40562      }
40563      const nestedName = xref.fetchIfRef(value[0]);
40564      if (typeof nestedName !== "string") {
40565        return null;
40566      }
40567      const nestedOrder = parseOrder(value.slice(1), nestedLevels);
40568      if (!nestedOrder?.length) {
40569        return null;
40570      }
40571      return {
40572        name: stringToPDFString(nestedName),
40573        order: nestedOrder
40574      };
40575    }
40576    function parseRBGroups(rbGroups) {
40577      if (!Array.isArray(rbGroups)) {
40578        return;
40579      }
40580      for (const value of rbGroups) {
40581        const rbGroup = xref.fetchIfRef(value);
40582        if (!Array.isArray(rbGroup) || !rbGroup.length) {
40583          continue;
40584        }
40585        const parsedRbGroup = new Set();
40586        for (const ref of rbGroup) {
40587          if (ref instanceof Ref && groupRefCache.has(ref) && !parsedRbGroup.has(ref.toString())) {
40588            parsedRbGroup.add(ref.toString());
40589            groupRefCache.get(ref).rbGroups.push(parsedRbGroup);
40590          }
40591        }
40592      }
40593    }
40594    const xref = this.xref,
40595      parsedOrderRefs = new RefSet(),
40596      MAX_NESTED_LEVELS = 10;
40597    parseRBGroups(config.get("RBGroups"));
40598    return {
40599      name: typeof config.get("Name") === "string" ? stringToPDFString(config.get("Name")) : null,
40600      creator: typeof config.get("Creator") === "string" ? stringToPDFString(config.get("Creator")) : null,
40601      baseState: config.get("BaseState") instanceof Name ? config.get("BaseState").name : null,
40602      on: parseOnOff(config.get("ON")),
40603      off: parseOnOff(config.get("OFF")),
40604      order: parseOrder(config.get("Order")),
40605      groups: [...groupRefCache]
40606    };
40607  }
40608  setActualNumPages(num = null) {
40609    this.#actualNumPages = num;
40610  }
40611  get hasActualNumPages() {
40612    return this.#actualNumPages !== null;
40613  }
40614  get _pagesCount() {
40615    const obj = this.toplevelPagesDict.get("Count");
40616    if (!Number.isInteger(obj)) {
40617      throw new FormatError("Page count in top-level pages dictionary is not an integer.");
40618    }
40619    return shadow(this, "_pagesCount", obj);
40620  }
40621  get numPages() {
40622    return this.#actualNumPages ?? this._pagesCount;
40623  }
40624  get destinations() {
40625    const rawDests = this.#readDests(),
40626      dests = Object.create(null);
40627    for (const obj of rawDests) {
40628      if (obj instanceof NameTree) {
40629        for (const [key, value] of obj.getAll()) {
40630          const dest = fetchDest(value);
40631          if (dest) {
40632            dests[stringToPDFString(key, true)] = dest;
40633          }
40634        }
40635      } else if (obj instanceof Dict) {
40636        for (const [key, value] of obj) {
40637          const dest = fetchDest(value);
40638          if (dest) {
40639            dests[stringToPDFString(key, true)] ||= dest;
40640          }
40641        }
40642      }
40643    }
40644    return shadow(this, "destinations", dests);
40645  }
40646  getDestination(id) {
40647    if (Object.hasOwn(this, "destinations")) {
40648      return this.destinations[id] ?? null;
40649    }
40650    const rawDests = this.#readDests();
40651    for (const obj of rawDests) {
40652      if (obj instanceof NameTree || obj instanceof Dict) {
40653        const dest = fetchDest(obj.get(id));
40654        if (dest) {
40655          return dest;
40656        }
40657      }
40658    }
40659    if (rawDests.length) {
40660      const dest = this.destinations[id];
40661      if (dest) {
40662        return dest;
40663      }
40664    }
40665    return null;
40666  }
40667  #readDests() {
40668    const obj = this.#catDict.get("Names");
40669    const rawDests = [];
40670    if (obj?.has("Dests")) {
40671      rawDests.push(new NameTree(obj.getRaw("Dests"), this.xref));
40672    }
40673    if (this.#catDict.has("Dests")) {
40674      rawDests.push(this.#catDict.get("Dests"));
40675    }
40676    return rawDests;
40677  }
40678  get rawPageLabels() {
40679    const obj = this.#catDict.getRaw("PageLabels");
40680    if (!obj) {
40681      return null;
40682    }
40683    const numberTree = new NumberTree(obj, this.xref);
40684    return numberTree.getAll();
40685  }
40686  get pageLabels() {
40687    let obj = null;
40688    try {
40689      obj = this.#readPageLabels();
40690    } catch (ex) {
40691      if (ex instanceof MissingDataException) {
40692        throw ex;
40693      }
40694      warn("Unable to read page labels.");
40695    }
40696    return shadow(this, "pageLabels", obj);
40697  }
40698  #readPageLabels() {
40699    const nums = this.rawPageLabels;
40700    if (!nums) {
40701      return null;
40702    }
40703    const pageLabels = new Array(this.numPages);
40704    let style = null,
40705      prefix = "";
40706    let currentLabel = "",
40707      currentIndex = 1;
40708    for (let i = 0, ii = this.numPages; i < ii; i++) {
40709      const labelDict = nums.get(i);
40710      if (labelDict !== undefined) {
40711        if (!(labelDict instanceof Dict)) {
40712          throw new FormatError("PageLabel is not a dictionary.");
40713        }
40714        if (labelDict.has("Type") && !isName(labelDict.get("Type"), "PageLabel")) {
40715          throw new FormatError("Invalid type in PageLabel dictionary.");
40716        }
40717        if (labelDict.has("S")) {
40718          const s = labelDict.get("S");
40719          if (!(s instanceof Name)) {
40720            throw new FormatError("Invalid style in PageLabel dictionary.");
40721          }
40722          style = s.name;
40723        } else {
40724          style = null;
40725        }
40726        if (labelDict.has("P")) {
40727          const p = labelDict.get("P");
40728          if (typeof p !== "string") {
40729            throw new FormatError("Invalid prefix in PageLabel dictionary.");
40730          }
40731          prefix = stringToPDFString(p);
40732        } else {
40733          prefix = "";
40734        }
40735        if (labelDict.has("St")) {
40736          const st = labelDict.get("St");
40737          if (!(Number.isInteger(st) && st >= 1)) {
40738            throw new FormatError("Invalid start in PageLabel dictionary.");
40739          }
40740          currentIndex = st;
40741        } else {
40742          currentIndex = 1;
40743        }
40744      }
40745      switch (style) {
40746        case "D":
40747          currentLabel = currentIndex;
40748          break;
40749        case "R":
40750        case "r":
40751          currentLabel = toRomanNumerals(currentIndex, style === "r");
40752          break;
40753        case "A":
40754        case "a":
40755          const LIMIT = 26;
40756          const A_UPPER_CASE = 0x41,
40757            A_LOWER_CASE = 0x61;
40758          const baseCharCode = style === "a" ? A_LOWER_CASE : A_UPPER_CASE;
40759          const letterIndex = currentIndex - 1;
40760          const character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
40761          currentLabel = character.repeat(Math.floor(letterIndex / LIMIT) + 1);
40762          break;
40763        default:
40764          if (style) {
40765            throw new FormatError(`Invalid style "${style}" in PageLabel dictionary.`);
40766          }
40767          currentLabel = "";
40768      }
40769      pageLabels[i] = prefix + currentLabel;
40770      currentIndex++;
40771    }
40772    return pageLabels;
40773  }
40774  get pageLayout() {
40775    const obj = this.#catDict.get("PageLayout");
40776    let pageLayout = "";
40777    if (obj instanceof Name) {
40778      switch (obj.name) {
40779        case "SinglePage":
40780        case "OneColumn":
40781        case "TwoColumnLeft":
40782        case "TwoColumnRight":
40783        case "TwoPageLeft":
40784        case "TwoPageRight":
40785          pageLayout = obj.name;
40786      }
40787    }
40788    return shadow(this, "pageLayout", pageLayout);
40789  }
40790  get pageMode() {
40791    const obj = this.#catDict.get("PageMode");
40792    let pageMode = "UseNone";
40793    if (obj instanceof Name) {
40794      switch (obj.name) {
40795        case "UseNone":
40796        case "UseOutlines":
40797        case "UseThumbs":
40798        case "FullScreen":
40799        case "UseOC":
40800        case "UseAttachments":
40801          pageMode = obj.name;
40802      }
40803    }
40804    return shadow(this, "pageMode", pageMode);
40805  }
40806  get viewerPreferences() {
40807    const obj = this.#catDict.get("ViewerPreferences");
40808    if (!(obj instanceof Dict)) {
40809      return shadow(this, "viewerPreferences", null);
40810    }
40811    let prefs = null;
40812    for (const [key, value] of obj) {
40813      let prefValue;
40814      switch (key) {
40815        case "HideToolbar":
40816        case "HideMenubar":
40817        case "HideWindowUI":
40818        case "FitWindow":
40819        case "CenterWindow":
40820        case "DisplayDocTitle":
40821        case "PickTrayByPDFSize":
40822          if (typeof value === "boolean") {
40823            prefValue = value;
40824          }
40825          break;
40826        case "NonFullScreenPageMode":
40827          if (value instanceof Name) {
40828            switch (value.name) {
40829              case "UseNone":
40830              case "UseOutlines":
40831              case "UseThumbs":
40832              case "UseOC":
40833                prefValue = value.name;
40834                break;
40835              default:
40836                prefValue = "UseNone";
40837            }
40838          }
40839          break;
40840        case "Direction":
40841          if (value instanceof Name) {
40842            switch (value.name) {
40843              case "L2R":
40844              case "R2L":
40845                prefValue = value.name;
40846                break;
40847              default:
40848                prefValue = "L2R";
40849            }
40850          }
40851          break;
40852        case "ViewArea":
40853        case "ViewClip":
40854        case "PrintArea":
40855        case "PrintClip":
40856          if (value instanceof Name) {
40857            switch (value.name) {
40858              case "MediaBox":
40859              case "CropBox":
40860              case "BleedBox":
40861              case "TrimBox":
40862              case "ArtBox":
40863                prefValue = value.name;
40864                break;
40865              default:
40866                prefValue = "CropBox";
40867            }
40868          }
40869          break;
40870        case "PrintScaling":
40871          if (value instanceof Name) {
40872            switch (value.name) {
40873              case "None":
40874              case "AppDefault":
40875                prefValue = value.name;
40876                break;
40877              default:
40878                prefValue = "AppDefault";
40879            }
40880          }
40881          break;
40882        case "Duplex":
40883          if (value instanceof Name) {
40884            switch (value.name) {
40885              case "Simplex":
40886              case "DuplexFlipShortEdge":
40887              case "DuplexFlipLongEdge":
40888                prefValue = value.name;
40889                break;
40890              default:
40891                prefValue = "None";
40892            }
40893          }
40894          break;
40895        case "PrintPageRange":
40896          if (Array.isArray(value) && value.length % 2 === 0) {
40897            const isValid = value.every((page, i, arr) => Number.isInteger(page) && page > 0 && (i === 0 || page >= arr[i - 1]) && page <= this.numPages);
40898            if (isValid) {
40899              prefValue = value;
40900            }
40901          }
40902          break;
40903        case "NumCopies":
40904          if (Number.isInteger(value) && value > 0) {
40905            prefValue = value;
40906          }
40907          break;
40908        default:
40909          warn(`Ignoring non-standard key in ViewerPreferences: ${key}.`);
40910          continue;
40911      }
40912      if (prefValue === undefined) {
40913        warn(`Bad value, for key "${key}", in ViewerPreferences: ${value}.`);
40914        continue;
40915      }
40916      prefs ??= Object.create(null);
40917      prefs[key] = prefValue;
40918    }
40919    return shadow(this, "viewerPreferences", prefs);
40920  }
40921  get openAction() {
40922    const obj = this.#catDict.get("OpenAction");
40923    const openAction = Object.create(null);
40924    if (obj instanceof Dict) {
40925      const destDict = new Dict(this.xref);
40926      destDict.set("A", obj);
40927      const resultObj = {
40928        url: null,
40929        dest: null,
40930        action: null
40931      };
40932      Catalog.parseDestDictionary({
40933        destDict,
40934        resultObj
40935      });
40936      if (Array.isArray(resultObj.dest)) {
40937        openAction.dest = resultObj.dest;
40938      } else if (resultObj.action) {
40939        openAction.action = resultObj.action;
40940      }
40941    } else if (isValidExplicitDest(obj)) {
40942      openAction.dest = obj;
40943    }
40944    return shadow(this, "openAction", objectSize(openAction) > 0 ? openAction : null);
40945  }
40946  get attachments() {
40947    const obj = this.#catDict.get("Names");
40948    let attachments = null;
40949    if (obj instanceof Dict && obj.has("EmbeddedFiles")) {
40950      const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
40951      for (const [key, value] of nameTree.getAll()) {
40952        (attachments ??= new Map()).set(stringToPDFString(key, true), new FileSpec(value).serializable);
40953      }
40954    }
40955    return shadow(this, "attachments", attachments);
40956  }
40957  #attachmentContentByName(id) {
40958    const obj = this.#catDict.get("Names");
40959    if (obj instanceof Dict && obj.has("EmbeddedFiles")) {
40960      const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
40961      for (const [key, value] of nameTree.getAll()) {
40962        if (stringToPDFString(key, true) === id) {
40963          return FileSpec.readContent(value);
40964        }
40965      }
40966    }
40967    return undefined;
40968  }
40969  attachmentContent(id) {
40970    const namedContent = this.#attachmentContentByName(id);
40971    if (namedContent !== undefined) {
40972      return namedContent;
40973    }
40974    const ref = this.#annotationAttachmentRefById.get(id);
40975    if (ref) {
40976      const target = this.xref.fetch(ref);
40977      if (target instanceof BaseStream) {
40978        return FileSpec.readStreamContent(target);
40979      }
40980      return target instanceof Dict ? FileSpec.readContent(target) : null;
40981    }
40982    return null;
40983  }
40984  get rawEmbeddedFiles() {
40985    const obj = this.#catDict.get("Names");
40986    if (!(obj instanceof Dict) || !obj.has("EmbeddedFiles")) {
40987      return null;
40988    }
40989    const nameTree = new NameTree(obj.getRaw("EmbeddedFiles"), this.xref);
40990    return nameTree.getAll(true);
40991  }
40992  get xfaImages() {
40993    const obj = this.#catDict.get("Names");
40994    let xfaImages = null;
40995    if (obj instanceof Dict && obj.has("XFAImages")) {
40996      const nameTree = new NameTree(obj.getRaw("XFAImages"), this.xref);
40997      for (const [key, value] of nameTree.getAll()) {
40998        if (value instanceof BaseStream) {
40999          xfaImages ??= new Map();
41000          xfaImages.set(stringToPDFString(key, true), value.getBytes());
41001        }
41002      }
41003    }
41004    return shadow(this, "xfaImages", xfaImages);
41005  }
41006  #collectJavaScript() {
41007    const obj = this.#catDict.get("Names");
41008    let javaScript = null;
41009    function appendIfJavaScriptDict(name, jsDict) {
41010      if (!(jsDict instanceof Dict)) {
41011        return;
41012      }
41013      if (!isName(jsDict.get("S"), "JavaScript")) {
41014        return;
41015      }
41016      let js = jsDict.get("JS");
41017      if (js instanceof BaseStream) {
41018        js = js.getString();
41019      } else if (typeof js !== "string") {
41020        return;
41021      }
41022      js = stringToPDFString(js, true).replaceAll("\x00", "");
41023      if (js) {
41024        (javaScript ||= new Map()).set(name, js);
41025      }
41026    }
41027    if (obj instanceof Dict && obj.has("JavaScript")) {
41028      const nameTree = new NameTree(obj.getRaw("JavaScript"), this.xref);
41029      for (const [key, value] of nameTree.getAll()) {
41030        appendIfJavaScriptDict(stringToPDFString(key, true), value);
41031      }
41032    }
41033    const openAction = this.#catDict.get("OpenAction");
41034    if (openAction) {
41035      appendIfJavaScriptDict("OpenAction", openAction);
41036    }
41037    return javaScript;
41038  }
41039  get jsActions() {
41040    const javaScript = this.#collectJavaScript();
41041    let actions = collectActions(this.xref, this.#catDict, DocumentActionEventType);
41042    if (javaScript) {
41043      actions ||= Object.create(null);
41044      for (const [key, val] of javaScript) {
41045        if (key in actions) {
41046          actions[key].push(val);
41047        } else {
41048          actions[key] = [val];
41049        }
vendor: 7,382 bytes, lines 41049-41285
41049
41050      }
41051    }
41052    return shadow(this, "jsActions", actions);
41053  }
41054  async cleanup(manuallyTriggered = false) {
41055    clearGlobalCaches();
41056    this.globalColorSpaceCache.clear();
41057    this.globalImageCache.clear(manuallyTriggered);
41058    this.pageKidsCountCache.clear();
41059    this.pageIndexCache.clear();
41060    this.pageDictCache.clear();
41061    this.nonBlendModesSet.clear();
41062    for (const {
41063      dict
41064    } of await Promise.all(this.fontCache)) {
41065      delete dict.cacheKey;
41066    }
41067    this.fontCache.clear();
41068    this.builtInCMapCache.clear();
41069    this.standardFontDataCache.clear();
41070    this.systemFontCache.clear();
41071  }
41072  async getPageDict(pageIndex) {
41073    const nodesToVisit = [this.toplevelPagesDict];
41074    const visitedNodes = new RefSet();
41075    const pagesRef = this.#catDict.getRaw("Pages");
41076    if (pagesRef instanceof Ref) {
41077      visitedNodes.put(pagesRef);
41078    }
41079    const xref = this.xref,
41080      pageKidsCountCache = this.pageKidsCountCache,
41081      pageIndexCache = this.pageIndexCache,
41082      pageDictCache = this.pageDictCache;
41083    let currentPageIndex = 0;
41084    while (nodesToVisit.length) {
41085      const currentNode = nodesToVisit.pop();
41086      if (currentNode instanceof Ref) {
41087        const count = pageKidsCountCache.get(currentNode);
41088        if (count >= 0 && currentPageIndex + count <= pageIndex) {
41089          currentPageIndex += count;
41090          continue;
41091        }
41092        if (visitedNodes.has(currentNode)) {
41093          throw new FormatError("Pages tree contains circular reference.");
41094        }
41095        visitedNodes.put(currentNode);
41096        const obj = await (pageDictCache.get(currentNode) || xref.fetchAsync(currentNode));
41097        if (obj instanceof Dict) {
41098          let type = obj.getRaw("Type");
41099          if (type instanceof Ref) {
41100            type = await xref.fetchAsync(type);
41101          }
41102          if (isName(type, "Page") || !obj.has("Kids")) {
41103            if (!pageKidsCountCache.has(currentNode)) {
41104              pageKidsCountCache.put(currentNode, 1);
41105            }
41106            if (!pageIndexCache.has(currentNode)) {
41107              pageIndexCache.put(currentNode, currentPageIndex);
41108            }
41109            if (currentPageIndex === pageIndex) {
41110              return [obj, currentNode];
41111            }
41112            currentPageIndex++;
41113            continue;
41114          }
41115        }
41116        nodesToVisit.push(obj);
41117        continue;
41118      }
41119      if (!(currentNode instanceof Dict)) {
41120        throw new FormatError("Page dictionary kid reference points to wrong type of object.");
41121      }
41122      const {
41123        objId
41124      } = currentNode;
41125      let count = currentNode.getRaw("Count");
41126      if (count instanceof Ref) {
41127        count = await xref.fetchAsync(count);
41128      }
41129      if (Number.isInteger(count) && count >= 0) {
41130        if (objId && !pageKidsCountCache.has(objId)) {
41131          pageKidsCountCache.put(objId, count);
41132        }
41133        if (currentPageIndex + count <= pageIndex) {
41134          currentPageIndex += count;
41135          continue;
41136        }
41137      }
41138      let kids = currentNode.getRaw("Kids");
41139      if (kids instanceof Ref) {
41140        kids = await xref.fetchAsync(kids);
41141      }
41142      if (!Array.isArray(kids)) {
41143        let type = currentNode.getRaw("Type");
41144        if (type instanceof Ref) {
41145          type = await xref.fetchAsync(type);
41146        }
41147        if (isName(type, "Page") || !currentNode.has("Kids")) {
41148          if (currentPageIndex === pageIndex) {
41149            return [currentNode, null];
41150          }
41151          currentPageIndex++;
41152          continue;
41153        }
41154        throw new FormatError("Page dictionary kids object is not an array.");
41155      }
41156      for (let last = kids.length - 1; last >= 0; last--) {
41157        const lastKid = kids[last];
41158        nodesToVisit.push(lastKid);
41159        if (currentNode === this.toplevelPagesDict && lastKid instanceof Ref && !pageDictCache.has(lastKid)) {
41160          pageDictCache.put(lastKid, xref.fetchAsync(lastKid));
41161        }
41162      }
41163    }
41164    throw new Error(`Page index ${pageIndex} not found.`);
41165  }
41166  async getAllPageDicts(recoveryMode = false) {
41167    const {
41168      ignoreErrors
41169    } = this.pdfManager.evaluatorOptions;
41170    const queue = [{
41171      currentNode: this.toplevelPagesDict,
41172      posInKids: 0
41173    }];
41174    const visitedNodes = new RefSet();
41175    const pagesRef = this.#catDict.getRaw("Pages");
41176    if (pagesRef instanceof Ref) {
41177      visitedNodes.put(pagesRef);
41178    }
41179    const map = new Map(),
41180      xref = this.xref,
41181      pageIndexCache = this.pageIndexCache;
41182    let pageIndex = 0;
41183    function addPageDict(pageDict, pageRef) {
41184      if (pageRef && !pageIndexCache.has(pageRef)) {
41185        pageIndexCache.put(pageRef, pageIndex);
41186      }
41187      map.set(pageIndex++, [pageDict, pageRef]);
41188    }
41189    function addPageError(error) {
41190      if (error instanceof XRefEntryException && !recoveryMode) {
41191        throw error;
41192      }
41193      if (recoveryMode && ignoreErrors && pageIndex === 0) {
41194        warn(`getAllPageDicts - Skipping invalid first page: "${error}".`);
41195        error = Dict.empty;
41196      }
41197      map.set(pageIndex++, [error, null]);
41198    }
41199    while (queue.length > 0) {
41200      const queueItem = queue.at(-1);
41201      const {
41202        currentNode,
41203        posInKids
41204      } = queueItem;
41205      let kids = currentNode.getRaw("Kids");
41206      if (kids instanceof Ref) {
41207        try {
41208          kids = await xref.fetchAsync(kids);
41209        } catch (ex) {
41210          addPageError(ex);
41211          break;
41212        }
41213      }
41214      if (!Array.isArray(kids)) {
41215        let type = currentNode.getRaw("Type");
41216        if (type instanceof Ref) {
41217          try {
41218            type = await xref.fetchAsync(type);
41219          } catch (ex) {
41220            addPageError(ex);
41221            break;
41222          }
41223        }
41224        if (isName(type, "Page") || !currentNode.has("Kids")) {
41225          addPageDict(currentNode, null);
41226          break;
41227        }
41228        addPageError(new FormatError("Page dictionary kids object is not an array."));
41229        break;
41230      }
41231      if (posInKids >= kids.length) {
41232        queue.pop();
41233        continue;
41234      }
41235      const kidObj = kids[posInKids];
41236      let obj;
41237      if (kidObj instanceof Ref) {
41238        if (visitedNodes.has(kidObj)) {
41239          addPageError(new FormatError("Pages tree contains circular reference."));
41240          break;
41241        }
41242        visitedNodes.put(kidObj);
41243        try {
41244          obj = await xref.fetchAsync(kidObj);
41245        } catch (ex) {
41246          addPageError(ex);
41247          break;
41248        }
41249      } else {
41250        obj = kidObj;
41251      }
41252      if (!(obj instanceof Dict)) {
41253        addPageError(new FormatError("Page dictionary kid reference points to wrong type of object."));
41254        break;
41255      }
41256      let type = obj.getRaw("Type");
41257      if (type instanceof Ref) {
41258        try {
41259          type = await xref.fetchAsync(type);
41260        } catch (ex) {
41261          addPageError(ex);
41262          break;
41263        }
41264      }
41265      if (isName(type, "Page") || !obj.has("Kids")) {
41266        addPageDict(obj, kidObj instanceof Ref ? kidObj : null);
41267      } else {
41268        queue.push({
41269          currentNode: obj,
41270          posInKids: 0
41271        });
41272      }
41273      queueItem.posInKids++;
41274    }
41275    return map;
41276  }
41277  async getPageIndex(pageRef) {
41278    const cachedPageIndex = this.pageIndexCache.get(pageRef);
41279    if (cachedPageIndex !== undefined) {
41280      return cachedPageIndex;
41281    }
41282    const xref = this.xref;
41283    let total = 0,
41284      ref = pageRef;
41285    
vendor: 15,119 bytes, lines 41285-41772
41285while (true) {
41286      const node = await xref.fetchAsync(ref);
41287      if (isRefsEqual(ref, pageRef) && !isDict(node, "Page") && !(node instanceof Dict && !node.has("Type") && node.has("Contents"))) {
41288        throw new FormatError("The reference does not point to a /Page dictionary.");
41289      }
41290      if (!node) {
41291        break;
41292      }
41293      if (!(node instanceof Dict)) {
41294        throw new FormatError("Node must be a dictionary.");
41295      }
41296      const parentRef = node.getRaw("Parent");
41297      const parent = await node.getAsync("Parent");
41298      if (!parent) {
41299        break;
41300      }
41301      if (!(parent instanceof Dict)) {
41302        throw new FormatError("Parent must be a dictionary.");
41303      }
41304      const kids = await parent.getAsync("Kids");
41305      if (!kids) {
41306        break;
41307      }
41308      if (!Array.isArray(kids)) {
41309        throw new FormatError("Kids must be an array.");
41310      }
41311      const kidPromises = [];
41312      let found = false;
41313      for (const kid of kids) {
41314        if (!(kid instanceof Ref)) {
41315          throw new FormatError("Kid must be a reference.");
41316        }
41317        if (isRefsEqual(kid, ref)) {
41318          found = true;
41319          break;
41320        }
41321        kidPromises.push(xref.fetchAsync(kid).then(obj => {
41322          if (!(obj instanceof Dict)) {
41323            throw new FormatError("Kid node must be a dictionary.");
41324          }
41325          if (obj.has("Count")) {
41326            const count = obj.get("Count");
41327            if (Number.isInteger(count) && count >= 0) {
41328              total += count;
41329              return;
41330            }
41331            throw new FormatError("Count must be a (positive) integer.");
41332          }
41333          total++;
41334        }));
41335      }
41336      if (!found) {
41337        throw new FormatError("Kid reference not found in parent's kids.");
41338      }
41339      await Promise.all(kidPromises);
41340      ref = parentRef;
41341    }
41342    this.pageIndexCache.put(pageRef, total);
41343    return total;
41344  }
41345  get baseUrl() {
41346    const uri = this.#catDict.get("URI");
41347    if (uri instanceof Dict) {
41348      const base = uri.get("Base");
41349      if (typeof base === "string") {
41350        const absoluteUrl = createValidAbsoluteUrl(base, null, {
41351          tryConvertEncoding: true
41352        });
41353        if (absoluteUrl) {
41354          return shadow(this, "baseUrl", absoluteUrl.href);
41355        }
41356      }
41357    }
41358    return shadow(this, "baseUrl", this.pdfManager.docBaseUrl);
41359  }
41360  static #getDestFromStructElement(xref, seRef) {
41361    const seDict = xref.fetchIfRef(seRef);
41362    if (!(seDict instanceof Dict)) {
41363      return null;
41364    }
41365    let pageRef = null;
41366    const directPg = seDict.getRaw("Pg");
41367    if (directPg instanceof Ref) {
41368      pageRef = directPg;
41369    }
41370    if (!pageRef) {
41371      const queue = [seDict];
41372      while (queue.length > 0 && !pageRef) {
41373        const node = queue.shift();
41374        const kids = node.get("K");
41375        let kidsArr;
41376        if (Array.isArray(kids)) {
41377          kidsArr = kids;
41378        } else if (kids) {
41379          kidsArr = [kids];
41380        } else {
41381          continue;
41382        }
41383        for (const kid of kidsArr) {
41384          const kidObj = xref.fetchIfRef(kid);
41385          if (!(kidObj instanceof Dict)) {
41386            continue;
41387          }
41388          const pg = kidObj.getRaw("Pg");
41389          if (pg instanceof Ref) {
41390            pageRef = pg;
41391            break;
41392          }
41393          queue.push(kidObj);
41394        }
41395      }
41396    }
41397    if (!pageRef) {
41398      const MAX_DEPTH = 40;
41399      let current = seDict;
41400      for (let depth = 0; depth < MAX_DEPTH; depth++) {
41401        const parentRaw = current.getRaw("P");
41402        if (!(parentRaw instanceof Ref)) {
41403          break;
41404        }
41405        const parentDict = xref.fetch(parentRaw);
41406        if (!(parentDict instanceof Dict)) {
41407          break;
41408        }
41409        if (isName(parentDict.get("Type"), "StructTreeRoot")) {
41410          break;
41411        }
41412        const pg = parentDict.getRaw("Pg");
41413        if (pg instanceof Ref) {
41414          pageRef = pg;
41415          break;
41416        }
41417        current = parentDict;
41418      }
41419    }
41420    if (!pageRef) {
41421      return null;
41422    }
41423    let x = null,
41424      y = null;
41425    const attrs = seDict.get("A");
41426    if (attrs instanceof Dict) {
41427      const bbox = lookupRect(attrs.getArray("BBox"), null);
41428      if (bbox) {
41429        x = bbox[0];
41430        y = bbox[3];
41431      }
41432    }
41433    return [pageRef, {
41434      name: "XYZ"
41435    }, x, y, null];
41436  }
41437  static parseDestDictionary({
41438    destDict,
41439    resultObj,
41440    docBaseUrl = null,
41441    docAttachments = null
41442  }) {
41443    if (!(destDict instanceof Dict)) {
41444      warn("parseDestDictionary: `destDict` must be a dictionary.");
41445      return;
41446    }
41447    let action = destDict.get("A"),
41448      url,
41449      dest;
41450    if (!(action instanceof Dict)) {
41451      if (destDict.has("Dest")) {
41452        action = destDict.get("Dest");
41453      } else {
41454        action = destDict.get("AA");
41455        if (action instanceof Dict) {
41456          if (action.has("D")) {
41457            action = action.get("D");
41458          } else if (action.has("U")) {
41459            action = action.get("U");
41460          }
41461        }
41462      }
41463    }
41464    if (action instanceof Dict) {
41465      const actionType = action.get("S");
41466      if (!(actionType instanceof Name)) {
41467        warn("parseDestDictionary: Invalid type in Action dictionary.");
41468        return;
41469      }
41470      const actionName = actionType.name;
41471      switch (actionName) {
41472        case "ResetForm":
41473          const flags = action.get("Flags");
41474          const include = ((typeof flags === "number" ? flags : 0) & 1) === 0;
41475          const fields = [];
41476          const refs = [];
41477          for (const obj of action.get("Fields") || []) {
41478            if (obj instanceof Ref) {
41479              refs.push(obj.toString());
41480            } else if (typeof obj === "string") {
41481              fields.push(stringToPDFString(obj));
41482            }
41483          }
41484          resultObj.resetForm = {
41485            fields,
41486            refs,
41487            include
41488          };
41489          break;
41490        case "URI":
41491          url = action.get("URI");
41492          if (url instanceof Name) {
41493            url = "/" + url.name;
41494          }
41495          break;
41496        case "GoTo":
41497          dest = action.get("D");
41498          break;
41499        case "Launch":
41500        case "GoToR":
41501          const urlDict = action.get("F");
41502          if (urlDict instanceof Dict) {
41503            url = new FileSpec(urlDict).filename;
41504          } else if (typeof urlDict === "string") {
41505            url = urlDict;
41506          } else {
41507            break;
41508          }
41509          const remoteDest = fetchRemoteDest(action);
41510          if (remoteDest) {
41511            url = url.split("#", 1)[0] + "#" + remoteDest;
41512          }
41513          const newWindow = action.get("NewWindow");
41514          if (typeof newWindow === "boolean") {
41515            resultObj.newWindow = newWindow;
41516          }
41517          break;
41518        case "GoToE":
41519          const target = action.get("T");
41520          let id = null;
41521          if (target instanceof Dict) {
41522            const relationship = target.get("R");
41523            const name = target.get("N");
41524            if (isName(relationship, "C") && typeof name === "string") {
41525              id = stringToPDFString(name, true);
41526            }
41527          }
41528          if (docAttachments && id) {
41529            resultObj.attachmentId = id;
41530            resultObj.attachment = docAttachments.get(id);
41531            const attachmentDest = fetchRemoteDest(action);
41532            if (attachmentDest) {
41533              resultObj.attachmentDest = attachmentDest;
41534            }
41535          } else {
41536            warn(`parseDestDictionary - unimplemented "GoToE" action.`);
41537          }
41538          break;
41539        case "Named":
41540          const namedAction = action.get("N");
41541          if (namedAction instanceof Name) {
41542            resultObj.action = namedAction.name;
41543          }
41544          break;
41545        case "SetOCGState":
41546          const state = action.get("State");
41547          const preserveRB = action.get("PreserveRB");
41548          if (!Array.isArray(state) || state.length === 0) {
41549            break;
41550          }
41551          const stateArr = [];
41552          for (const elem of state) {
41553            if (elem instanceof Name) {
41554              switch (elem.name) {
41555                case "ON":
41556                case "OFF":
41557                case "Toggle":
41558                  stateArr.push(elem.name);
41559                  break;
41560              }
41561            } else if (elem instanceof Ref) {
41562              stateArr.push(elem.toString());
41563            }
41564          }
41565          if (stateArr.length !== state.length) {
41566            break;
41567          }
41568          resultObj.setOCGState = {
41569            state: stateArr,
41570            preserveRB: typeof preserveRB === "boolean" ? preserveRB : true
41571          };
41572          break;
41573        case "JavaScript":
41574          const jsAction = action.get("JS");
41575          let js;
41576          if (jsAction instanceof BaseStream) {
41577            js = jsAction.getString();
41578          } else if (typeof jsAction === "string") {
41579            js = jsAction;
41580          }
41581          const jsURL = js && recoverJsURL(stringToPDFString(js, true));
41582          if (jsURL) {
41583            url = jsURL.url;
41584            resultObj.newWindow = jsURL.newWindow;
41585            break;
41586          }
41587        default:
41588          if (actionName === "JavaScript" || actionName === "SubmitForm") {
41589            break;
41590          }
41591          warn(`parseDestDictionary - unsupported action: "${actionName}".`);
41592          break;
41593      }
41594    } else if (destDict.has("Dest")) {
41595      dest = destDict.get("Dest");
41596    }
41597    if (typeof url === "string") {
41598      const absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl, {
41599        addDefaultProtocol: true,
41600        tryConvertEncoding: true
41601      });
41602      if (absoluteUrl) {
41603        resultObj.url = absoluteUrl.href;
41604      }
41605      resultObj.unsafeUrl = url;
41606    }
41607    if (dest) {
41608      if (dest instanceof Name) {
41609        dest = dest.name;
41610      }
41611      if (typeof dest === "string") {
41612        resultObj.dest = stringToPDFString(dest, true);
41613      } else if (isValidExplicitDest(dest)) {
41614        resultObj.dest = dest;
41615      }
41616    }
41617    if (!resultObj.dest && !resultObj.url && !resultObj.action && !resultObj.attachment && !resultObj.setOCGState && !resultObj.resetForm) {
41618      const seRef = destDict.getRaw("SE");
41619      if (seRef instanceof Ref) {
41620        try {
41621          const seDest = Catalog.#getDestFromStructElement(destDict.xref, seRef);
41622          if (seDest) {
41623            resultObj.dest = seDest;
41624          }
41625        } catch (ex) {
41626          if (ex instanceof MissingDataException) {
41627            throw ex;
41628          }
41629          info("SE parsing failed.");
41630        }
41631      }
41632    }
41633  }
41634}
41635
41636;// ./src/core/editor/pdf_images.js
41637
41638
41639
41640const FLATE_COLOR_COUNT_THRESHOLD = 16384;
41641function createImageDict(xref, width, height, colorSpace) {
41642  const image = new Dict(xref);
41643  image.set("Type", Name.get("XObject"));
41644  image.set("Subtype", Name.get("Image"));
41645  image.set("BitsPerComponent", 8);
41646  image.setIfName("ColorSpace", colorSpace);
41647  image.set("Width", width);
41648  image.set("Height", height);
41649  return image;
41650}
41651function createRawImage(buffer, dict) {
41652  return new Stream(buffer, 0, buffer.length, dict);
41653}
41654function paethPredictor(left, above, upperLeft) {
41655  const p = left + above - upperLeft;
41656  const pa = Math.abs(p - left);
41657  const pb = Math.abs(p - above);
41658  const pc = Math.abs(p - upperLeft);
41659  if (pa <= pb && pa <= pc) {
41660    return left;
41661  }
41662  return pb <= pc ? above : upperLeft;
41663}
41664function applyPNGOptimumFilter(data, width, height, bytesPerPixel) {
41665  const rowSize = width * bytesPerPixel;
41666  const out = new Uint8Array(height * (rowSize + 1));
41667  const candidates = [new Uint8Array(rowSize), new Uint8Array(rowSize), new Uint8Array(rowSize), new Uint8Array(rowSize), new Uint8Array(rowSize)];
41668  for (let y = 0; y < height; y++) {
41669    const rowOffset = y * rowSize;
41670    const prevRowOffset = rowOffset - rowSize;
41671    const scores = [0, 0, 0, 0, 0];
41672    for (let x = 0; x < rowSize; x++) {
41673      const offset = rowOffset + x;
41674      const cur = data[offset];
41675      const left = x >= bytesPerPixel ? data[offset - bytesPerPixel] : 0;
41676      const above = y > 0 ? data[prevRowOffset + x] : 0;
41677      const upperLeft = y > 0 && x >= bytesPerPixel ? data[prevRowOffset + x - bytesPerPixel] : 0;
41678      candidates[0][x] = cur;
41679      candidates[1][x] = cur - left & 0xff;
41680      candidates[2][x] = cur - above & 0xff;
41681      candidates[3][x] = cur - (left + above >> 1) & 0xff;
41682      candidates[4][x] = cur - paethPredictor(left, above, upperLeft) & 0xff;
41683      for (let f = 0; f < 5; f++) {
41684        const v = candidates[f][x];
41685        scores[f] += v < 128 ? v : 256 - v;
41686      }
41687    }
41688    let bestFilter = 0;
41689    for (let f = 1; f < 5; f++) {
41690      if (scores[f] < scores[bestFilter]) {
41691        bestFilter = f;
41692      }
41693    }
41694    const outOffset = y * (rowSize + 1);
41695    out[outOffset] = bestFilter;
41696    out.set(candidates[bestFilter], outOffset + 1);
41697  }
41698  return out;
41699}
41700async function deflate(bytes) {
41701  const cs = new CompressionStream("deflate");
41702  const writer = cs.writable.getWriter();
41703  const writePromise = (async () => {
41704    try {
41705      await writer.ready;
41706      await writer.write(bytes);
41707      await writer.ready;
41708      await writer.close();
41709    } catch (reason) {
41710      await writer.abort(reason).catch(() => {});
41711      throw reason;
41712    }
41713  })();
41714  const [compressed] = await Promise.all([new Response(cs.readable).bytes(), writePromise.then(() => null)]);
41715  return compressed;
41716}
41717async function createPNGLikeImage(buffer, width, height, dict) {
41718  const bytesPerPixel = buffer.length / (width * height);
41719  let compressed;
41720  if (typeof CompressionStream === "function") {
41721    try {
41722      const filtered = applyPNGOptimumFilter(buffer, width, height, bytesPerPixel);
41723      compressed = await deflate(filtered);
41724    } catch {}
41725  }
41726  if (!compressed) {
41727    return createRawImage(buffer, dict);
41728  }
41729  dict.setIfName("Filter", "FlateDecode");
41730  const decodeParms = new Dict(dict.xref);
41731  decodeParms.set("Predictor", 15);
41732  decodeParms.set("Columns", width);
41733  decodeParms.set("Colors", bytesPerPixel);
41734  decodeParms.set("BitsPerComponent", 8);
41735  dict.set("DecodeParms", decodeParms);
41736  return createRawImage(compressed, dict);
41737}
41738async function createImage(bitmap, xref, {
41739  closeBitmap = false
41740} = {}) {
41741  const {
41742    width,
41743    height
41744  } = bitmap;
41745  if (!Number.isInteger(width) || !Number.isInteger(height) || width <= 0 || height <= 0) {
41746    if (closeBitmap) {
41747      bitmap.close?.();
41748    }
41749    throw new Error(`createImage: invalid bitmap dimensions ${width}x${height}`);
41750  }
41751  const canvas = new OffscreenCanvas(width, height);
41752  const ctx = canvas.getContext("2d", {
41753    alpha: true,
41754    willReadFrequently: true
41755  });
41756  let data;
41757  try {
41758    ctx.drawImage(bitmap, 0, 0);
41759    data = ctx.getImageData(0, 0, width, height).data;
41760  } finally {
41761    if (closeBitmap) {
41762      bitmap.close?.();
41763    }
41764  }
41765  const buf32 = new Uint32Array(data.buffer, data.byteOffset, data.byteLength >> 2);
41766  const isLE = FeatureTest.isLittleEndian;
41767  const rgbMask = isLE ? 0x00ffffff : 0xffffff00;
41768  const colorCounter = new Set();
41769  let hasAlpha = false;
41770  let useFlate = true;
41771  for (let i = 0, ii = buf32.length; i < ii; i++) {
41772    const v = buf32[i];
vendor: 10,964 bytes, lines 41772-42212
41772
41773    if ((isLE ? v >>> 24 : v & 0xff) !== 0xff) {
41774      hasAlpha = true;
41775      break;
41776    }
41777    if (useFlate) {
41778      colorCounter.add((v & rgbMask) >>> 0);
41779      if (colorCounter.size > FLATE_COLOR_COUNT_THRESHOLD) {
41780        useFlate = false;
41781        colorCounter.clear();
41782      }
41783    }
41784  }
41785  if (hasAlpha) {
41786    useFlate = true;
41787  }
41788  const image = createImageDict(xref, width, height, "DeviceRGB");
41789  let imageStreamPromise;
41790  let imageRenderStream = null;
41791  if (useFlate) {
41792    const rgbBuffer = new Uint8Array(width * height * 3);
41793    for (let i = 0, j = 0, ii = data.length; i < ii; i += 4, j += 3) {
41794      rgbBuffer[j] = data[i];
41795      rgbBuffer[j + 1] = data[i + 1];
41796      rgbBuffer[j + 2] = data[i + 2];
41797    }
41798    imageStreamPromise = createPNGLikeImage(rgbBuffer, width, height, image);
41799    imageRenderStream = createRawImage(rgbBuffer, createImageDict(xref, width, height, "DeviceRGB"));
41800  } else {
41801    image.setIfName("Filter", "DCTDecode");
41802    imageStreamPromise = canvas.convertToBlob({
41803      type: "image/jpeg",
41804      quality: 1
41805    }).then(blob => blob.bytes()).then(bytes => createRawImage(bytes, image));
41806  }
41807  let smaskStreamPromise = Promise.resolve(null);
41808  let smaskRenderStream = null;
41809  if (hasAlpha) {
41810    const alphaBuffer = new Uint8Array(buf32.length);
41811    if (isLE) {
41812      for (let i = 0, ii = buf32.length; i < ii; i++) {
41813        alphaBuffer[i] = buf32[i] >>> 24;
41814      }
41815    } else {
41816      for (let i = 0, ii = buf32.length; i < ii; i++) {
41817        alphaBuffer[i] = buf32[i] & 0xff;
41818      }
41819    }
41820    const smask = createImageDict(xref, width, height, "DeviceGray");
41821    const smaskRenderDict = createImageDict(xref, width, height, "DeviceGray");
41822    smaskStreamPromise = createPNGLikeImage(alphaBuffer, width, height, smask);
41823    smaskRenderStream = createRawImage(alphaBuffer, smaskRenderDict);
41824  }
41825  const [imageStream, smaskStream] = await Promise.all([imageStreamPromise, smaskStreamPromise]);
41826  return {
41827    imageStream,
41828    imageRenderStream,
41829    smaskStream,
41830    smaskRenderStream,
41831    width,
41832    height
41833  };
41834}
41835
41836;// ./src/core/object_loader.js
41837
41838
41839
41840
41841function mayHaveChildren(value) {
41842  return value instanceof Ref || value instanceof Dict || value instanceof BaseStream || Array.isArray(value);
41843}
41844function addChildren(node, nodesToVisit) {
41845  if (node instanceof Dict) {
41846    node = node.getRawValues();
41847  } else if (node instanceof BaseStream) {
41848    node = node.dict.getRawValues();
41849  } else if (!Array.isArray(node)) {
41850    return;
41851  }
41852  for (const rawValue of node) {
41853    if (mayHaveChildren(rawValue)) {
41854      nodesToVisit.push(rawValue);
41855    }
41856  }
41857}
41858class ObjectLoader {
41859  refSet = new RefSet();
41860  constructor(dict, keys, xref) {
41861    this.dict = dict;
41862    this.keys = keys;
41863    this.xref = xref;
41864  }
41865  async load() {
41866    const {
41867      keys,
41868      dict
41869    } = this;
41870    const nodesToVisit = [];
41871    for (const key of keys) {
41872      const rawValue = dict.getRaw(key);
41873      if (rawValue !== undefined) {
41874        nodesToVisit.push(rawValue);
41875      }
41876    }
41877    await this.#walk(nodesToVisit);
41878    this.refSet = null;
41879  }
41880  async #walk(nodesToVisit) {
41881    const nodesToRevisit = [];
41882    const pendingRequests = [];
41883    while (nodesToVisit.length) {
41884      let currentNode = nodesToVisit.pop();
41885      if (currentNode instanceof Ref) {
41886        if (this.refSet.has(currentNode)) {
41887          continue;
41888        }
41889        try {
41890          this.refSet.put(currentNode);
41891          currentNode = this.xref.fetch(currentNode);
41892        } catch (ex) {
41893          if (!(ex instanceof MissingDataException)) {
41894            warn(`ObjectLoader.#walk - requesting all data: "${ex}".`);
41895            await this.xref.stream.manager.requestAllChunks();
41896            return;
41897          }
41898          nodesToRevisit.push(currentNode);
41899          pendingRequests.push({
41900            begin: ex.begin,
41901            end: ex.end
41902          });
41903        }
41904      }
41905      if (currentNode instanceof BaseStream) {
41906        const baseStreams = currentNode.getBaseStreams();
41907        if (baseStreams) {
41908          let foundMissingData = false;
41909          for (const stream of baseStreams) {
41910            if (stream.isDataLoaded) {
41911              continue;
41912            }
41913            foundMissingData = true;
41914            pendingRequests.push({
41915              begin: stream.start,
41916              end: stream.end
41917            });
41918          }
41919          if (foundMissingData) {
41920            nodesToRevisit.push(currentNode);
41921          }
41922        }
41923      }
41924      addChildren(currentNode, nodesToVisit);
41925    }
41926    if (pendingRequests.length) {
41927      await this.xref.stream.manager.requestRanges(pendingRequests);
41928      for (const node of nodesToRevisit) {
41929        if (node instanceof Ref) {
41930          this.refSet.remove(node);
41931        }
41932      }
41933      await this.#walk(nodesToRevisit);
41934    }
41935  }
41936  static async load(obj, keys, xref) {
41937    if (xref.stream.isDataLoaded) {
41938      return;
41939    }
41940    const objLoader = new ObjectLoader(obj, keys, xref);
41941    await objLoader.load();
41942  }
41943}
41944
41945;// ./src/core/xfa/symbol_utils.js
41946const $acceptWhitespace = Symbol();
41947const $addHTML = Symbol();
41948const $appendChild = Symbol();
41949const $childrenToHTML = Symbol();
41950const $clean = Symbol();
41951const $cleanPage = Symbol();
41952const $cleanup = Symbol();
41953const $clone = Symbol();
41954const $consumed = Symbol();
41955const $content = Symbol("content");
41956const $data = Symbol("data");
41957const $dump = Symbol();
41958const $extra = Symbol("extra");
41959const $finalize = Symbol();
41960const $flushHTML = Symbol();
41961const $getAttributeIt = Symbol();
41962const $getAttributes = Symbol();
41963const $getAvailableSpace = Symbol();
41964const $getChildrenByClass = Symbol();
41965const $getChildrenByName = Symbol();
41966const $getChildrenByNameIt = Symbol();
41967const $getDataValue = Symbol();
41968const $getExtra = Symbol();
41969const $getRealChildrenByNameIt = Symbol();
41970const $getChildren = Symbol();
41971const $getContainedChildren = Symbol();
41972const $getNextPage = Symbol();
41973const $getSubformParent = Symbol();
41974const $getParent = Symbol();
41975const $getTemplateRoot = Symbol();
41976const $globalData = Symbol();
41977const $hasSettableValue = Symbol();
41978const $ids = Symbol();
41979const $indexOf = Symbol();
41980const $insertAt = Symbol();
41981const $isCDATAXml = Symbol();
41982const $isBindable = Symbol();
41983const $isDataValue = Symbol();
41984const $isDescendent = Symbol();
41985const $isNsAgnostic = Symbol();
41986const $isSplittable = Symbol();
41987const $isThereMoreWidth = Symbol();
41988const $isTransparent = Symbol();
41989const $isUsable = Symbol();
41990const $lastAttribute = Symbol();
41991const $namespaceId = Symbol("namespaceId");
41992const $nodeName = Symbol("nodeName");
41993const $nsAttributes = Symbol();
41994const $onChild = Symbol();
41995const $onChildCheck = Symbol();
41996const $onText = Symbol();
41997const $pushGlyphs = Symbol();
41998const $popPara = Symbol();
41999const $pushPara = Symbol();
42000const $removeChild = Symbol();
42001const $root = Symbol("root");
42002const $resolvePrototypes = Symbol();
42003const $searchNode = Symbol();
42004const $setId = Symbol();
42005const $setSetAttributes = Symbol();
42006const $setValue = Symbol();
42007const $tabIndex = Symbol();
42008const $text = Symbol();
42009const $toPages = Symbol();
42010const $toHTML = Symbol();
42011const $toString = Symbol();
42012const $toStyle = Symbol();
42013const $uid = Symbol("uid");
42014
42015;// ./src/core/xfa/namespaces.js
42016const $buildXFAObject = Symbol();
42017const NamespaceIds = {
42018  config: {
42019    id: 0,
42020    check: ns => ns.startsWith("http://www.xfa.org/schema/xci/")
42021  },
42022  connectionSet: {
42023    id: 1,
42024    check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-connection-set/")
42025  },
42026  datasets: {
42027    id: 2,
42028    check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-data/")
42029  },
42030  form: {
42031    id: 3,
42032    check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-form/")
42033  },
42034  localeSet: {
42035    id: 4,
42036    check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-locale-set/")
42037  },
42038  pdf: {
42039    id: 5,
42040    check: ns => ns === "http://ns.adobe.com/xdp/pdf/"
42041  },
42042  signature: {
42043    id: 6,
42044    check: ns => ns === "http://www.w3.org/2000/09/xmldsig#"
42045  },
42046  sourceSet: {
42047    id: 7,
42048    check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-source-set/")
42049  },
42050  stylesheet: {
42051    id: 8,
42052    check: ns => ns === "http://www.w3.org/1999/XSL/Transform"
42053  },
42054  template: {
42055    id: 9,
42056    check: ns => ns.startsWith("http://www.xfa.org/schema/xfa-template/")
42057  },
42058  xdc: {
42059    id: 10,
42060    check: ns => ns.startsWith("http://www.xfa.org/schema/xdc/")
42061  },
42062  xdp: {
42063    id: 11,
42064    check: ns => ns === "http://ns.adobe.com/xdp/"
42065  },
42066  xfdf: {
42067    id: 12,
42068    check: ns => ns === "http://ns.adobe.com/xfdf/"
42069  },
42070  xhtml: {
42071    id: 13,
42072    check: ns => ns === "http://www.w3.org/1999/xhtml"
42073  },
42074  xmpmeta: {
42075    id: 14,
42076    check: ns => ns === "http://ns.adobe.com/xmpmeta/"
42077  }
42078};
42079
42080;// ./src/core/xfa/utils.js
42081
42082
42083const dimConverters = {
42084  pt: x => x,
42085  cm: x => x / 2.54 * 72,
42086  mm: x => x / (10 * 2.54) * 72,
42087  in: x => x * 72,
42088  px: x => x
42089};
42090const measurementPattern = /([+-]?\d+\.?\d*)(.*)/;
42091function stripQuotes(str) {
42092  if (str.startsWith("'") || str.startsWith('"')) {
42093    return str.slice(1, -1);
42094  }
42095  return str;
42096}
42097function getInteger({
42098  data,
42099  defaultValue,
42100  validate
42101}) {
42102  if (!data) {
42103    return defaultValue;
42104  }
42105  data = data.trim();
42106  const n = parseInt(data, 10);
42107  if (!isNaN(n) && validate(n)) {
42108    return n;
42109  }
42110  return defaultValue;
42111}
42112function getFloat({
42113  data,
42114  defaultValue,
42115  validate
42116}) {
42117  if (!data) {
42118    return defaultValue;
42119  }
42120  data = data.trim();
42121  const n = parseFloat(data);
42122  if (!isNaN(n) && validate(n)) {
42123    return n;
42124  }
42125  return defaultValue;
42126}
42127function getKeyword({
42128  data,
42129  defaultValue,
42130  validate
42131}) {
42132  if (!data) {
42133    return defaultValue;
42134  }
42135  data = data.trim();
42136  if (validate(data)) {
42137    return data;
42138  }
42139  return defaultValue;
42140}
42141function getStringOption(data, options) {
42142  return getKeyword({
42143    data,
42144    defaultValue: options[0],
42145    validate: k => options.includes(k)
42146  });
42147}
42148function getMeasurement(str, def = "0") {
42149  def ||= "0";
42150  if (!str) {
42151    return getMeasurement(def);
42152  }
42153  const match = str.trim().match(measurementPattern);
42154  if (!match) {
42155    return getMeasurement(def);
42156  }
42157  const [, valueStr, unit] = match;
42158  const value = parseFloat(valueStr);
42159  if (isNaN(value)) {
42160    return getMeasurement(def);
42161  }
42162  if (value === 0) {
42163    return 0;
42164  }
42165  const conv = dimConverters[unit];
42166  if (conv) {
42167    return conv(value);
42168  }
42169  return value;
42170}
42171function getRatio(data) {
42172  if (!data) {
42173    return {
42174      num: 1,
42175      den: 1
42176    };
42177  }
42178  const ratio = data.split(":", 2).map(x => parseFloat(x.trim())).filter(x => !isNaN(x));
42179  if (ratio.length === 1) {
42180    ratio.push(1);
42181  }
42182  if (ratio.length === 0) {
42183    return {
42184      num: 1,
42185      den: 1
42186    };
42187  }
42188  const [num, den] = ratio;
42189  return {
42190    num,
42191    den
42192  };
42193}
42194function getRelevant(data) {
42195  if (!data) {
42196    return [];
42197  }
42198  return data.trim().split(/\s+/).map(e => ({
42199    excluded: e[0] === "-",
42200    viewname: e.substring(1)
42201  }));
42202}
42203function getColor(data, def = [0, 0, 0]) {
42204  let [r, g, b] = def;
42205  if (!data) {
42206    return {
42207      r,
42208      g,
42209      b
42210    };
42211  }
42212  const color = data.split(",", 3).map(c => 
vendor: 4,838 bytes, lines 42212-42395
42212MathClamp(parseInt(c.trim(), 10), 0, 255)).map(c => isNaN(c) ? 0 : c);
42213  if (color.length < 3) {
42214    return {
42215      r,
42216      g,
42217      b
42218    };
42219  }
42220  [r, g, b] = color;
42221  return {
42222    r,
42223    g,
42224    b
42225  };
42226}
42227function getBBox(data) {
42228  const def = -1;
42229  if (!data) {
42230    return {
42231      x: def,
42232      y: def,
42233      width: def,
42234      height: def
42235    };
42236  }
42237  const bbox = data.split(",", 4).map(m => getMeasurement(m.trim(), "-1"));
42238  if (bbox.length < 4 || bbox[2] < 0 || bbox[3] < 0) {
42239    return {
42240      x: def,
42241      y: def,
42242      width: def,
42243      height: def
42244    };
42245  }
42246  const [x, y, width, height] = bbox;
42247  return {
42248    x,
42249    y,
42250    width,
42251    height
42252  };
42253}
42254class HTMLResult {
42255  static get FAILURE() {
42256    return shadow(this, "FAILURE", new HTMLResult(false, null, null, null));
42257  }
42258  static get EMPTY() {
42259    return shadow(this, "EMPTY", new HTMLResult(true, null, null, null));
42260  }
42261  constructor(success, html, bbox, breakNode) {
42262    this.success = success;
42263    this.html = html;
42264    this.bbox = bbox;
42265    this.breakNode = breakNode;
42266  }
42267  isBreak() {
42268    return !!this.breakNode;
42269  }
42270  static breakNode(node) {
42271    return new HTMLResult(false, null, null, node);
42272  }
42273  static success(html, bbox = null) {
42274    return new HTMLResult(true, html, bbox, null);
42275  }
42276}
42277
42278;// ./src/core/xfa/fonts.js
42279
42280
42281
42282class FontFinder {
42283  constructor(pdfFonts) {
42284    this.fonts = new Map();
42285    this.cache = new Map();
42286    this.warned = new Set();
42287    this.defaultFont = null;
42288    this.add(pdfFonts);
42289  }
42290  add(pdfFonts, reallyMissingFonts = null) {
42291    for (const pdfFont of pdfFonts) {
42292      this.addPdfFont(pdfFont);
42293    }
42294    for (const pdfFont of this.fonts.values()) {
42295      if (!pdfFont.regular) {
42296        pdfFont.regular = pdfFont.italic || pdfFont.bold || pdfFont.bolditalic;
42297      }
42298    }
42299    if (!reallyMissingFonts || reallyMissingFonts.size === 0) {
42300      return;
42301    }
42302    const myriad = this.fonts.get("PdfJS-Fallback-PdfJS-XFA");
42303    for (const missing of reallyMissingFonts) {
42304      this.fonts.set(missing, myriad);
42305    }
42306  }
42307  addPdfFont(pdfFont) {
42308    const cssFontInfo = pdfFont.cssFontInfo;
42309    const name = cssFontInfo.fontFamily;
42310    const font = this.fonts.getOrInsertComputed(name, makeObj);
42311    this.defaultFont ??= font;
42312    let property = "";
42313    const fontWeight = parseFloat(cssFontInfo.fontWeight);
42314    if (parseFloat(cssFontInfo.italicAngle) !== 0) {
42315      property = fontWeight >= 700 ? "bolditalic" : "italic";
42316    } else if (fontWeight >= 700) {
42317      property = "bold";
42318    }
42319    if (!property) {
42320      if (pdfFont.name.includes("Bold") || pdfFont.psName?.includes("Bold")) {
42321        property = "bold";
42322      }
42323      if (pdfFont.name.includes("Italic") || pdfFont.name.endsWith("It") || pdfFont.psName?.includes("Italic") || pdfFont.psName?.endsWith("It")) {
42324        property += "italic";
42325      }
42326    }
42327    if (!property) {
42328      property = "regular";
42329    }
42330    font[property] = pdfFont;
42331  }
42332  getDefault() {
42333    return this.defaultFont;
42334  }
42335  find(fontName, mustWarn = true) {
42336    let font = this.fonts.get(fontName) || this.cache.get(fontName);
42337    if (font) {
42338      return font;
42339    }
42340    const pattern = /[,\-_ ]|bolditalic|bold|italic|regular|it/gi;
42341    let name = fontName.replaceAll(pattern, "");
42342    font = this.fonts.get(name);
42343    if (font) {
42344      this.cache.set(fontName, font);
42345      return font;
42346    }
42347    name = name.toLowerCase();
42348    const maybe = [];
42349    for (const [family, pdfFont] of this.fonts) {
42350      if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
42351        maybe.push(pdfFont);
42352      }
42353    }
42354    if (maybe.length === 0) {
42355      for (const pdfFont of this.fonts.values()) {
42356        if (pdfFont.regular.name?.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
42357          maybe.push(pdfFont);
42358        }
42359      }
42360    }
42361    if (maybe.length === 0) {
42362      name = name.replaceAll(/psmt|mt/gi, "");
42363      for (const [family, pdfFont] of this.fonts) {
42364        if (family.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
42365          maybe.push(pdfFont);
42366        }
42367      }
42368    }
42369    if (maybe.length === 0) {
42370      for (const pdfFont of this.fonts.values()) {
42371        if (pdfFont.regular.name?.replaceAll(pattern, "").toLowerCase().startsWith(name)) {
42372          maybe.push(pdfFont);
42373        }
42374      }
42375    }
42376    if (maybe.length >= 1) {
42377      if (maybe.length !== 1 && mustWarn) {
42378        warn(`XFA - Too many choices to guess the correct font: ${fontName}`);
42379      }
42380      this.cache.set(fontName, maybe[0]);
42381      return maybe[0];
42382    }
42383    if (mustWarn && !this.warned.has(fontName)) {
42384      this.warned.add(fontName);
42385      warn(`XFA - Cannot find the font: ${fontName}`);
42386    }
42387    return null;
42388  }
42389}
42390function selectFont(xfaFont, typeface) {
42391  if (xfaFont.posture === "italic") {
42392    if (xfaFont.weight === "bold") {
42393      return typeface.bolditalic;
42394    }
42395    return
vendor: 17,669 bytes, lines 42395-43024
42395 typeface.italic;
42396  } else if (xfaFont.weight === "bold") {
42397    return typeface.bold;
42398  }
42399  return typeface.regular;
42400}
42401function fonts_getMetrics(xfaFont, real = false) {
42402  let pdfFont = null;
42403  if (xfaFont) {
42404    const name = stripQuotes(xfaFont.typeface);
42405    const typeface = xfaFont[$globalData].fontFinder.find(name);
42406    pdfFont = selectFont(xfaFont, typeface);
42407  }
42408  if (!pdfFont) {
42409    return {
42410      lineHeight: 12,
42411      lineGap: 2,
42412      lineNoGap: 10
42413    };
42414  }
42415  const size = xfaFont.size || 10;
42416  const lineHeight = pdfFont.lineHeight ? Math.max(real ? 0 : 1.2, pdfFont.lineHeight) : 1.2;
42417  const lineGap = pdfFont.lineGap === undefined ? 0.2 : pdfFont.lineGap;
42418  return {
42419    lineHeight: lineHeight * size,
42420    lineGap: lineGap * size,
42421    lineNoGap: Math.max(1, lineHeight - lineGap) * size
42422  };
42423}
42424
42425;// ./src/core/xfa/text.js
42426
42427const WIDTH_FACTOR = 1.02;
42428class FontInfo {
42429  constructor(xfaFont, margin, lineHeight, fontFinder) {
42430    this.lineHeight = lineHeight;
42431    this.paraMargin = margin || {
42432      top: 0,
42433      bottom: 0,
42434      left: 0,
42435      right: 0
42436    };
42437    if (!xfaFont) {
42438      [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
42439      return;
42440    }
42441    this.xfaFont = {
42442      typeface: xfaFont.typeface,
42443      posture: xfaFont.posture,
42444      weight: xfaFont.weight,
42445      size: xfaFont.size,
42446      letterSpacing: xfaFont.letterSpacing
42447    };
42448    const typeface = fontFinder.find(xfaFont.typeface);
42449    if (!typeface) {
42450      [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
42451      return;
42452    }
42453    this.pdfFont = selectFont(xfaFont, typeface);
42454    if (!this.pdfFont) {
42455      [this.pdfFont, this.xfaFont] = this.defaultFont(fontFinder);
42456    }
42457  }
42458  defaultFont(fontFinder) {
42459    const font = fontFinder.find("Helvetica", false) || fontFinder.find("Myriad Pro", false) || fontFinder.find("Arial", false) || fontFinder.getDefault();
42460    if (font?.regular) {
42461      const pdfFont = font.regular;
42462      const info = pdfFont.cssFontInfo;
42463      const xfaFont = {
42464        typeface: info.fontFamily,
42465        posture: "normal",
42466        weight: "normal",
42467        size: 10,
42468        letterSpacing: 0
42469      };
42470      return [pdfFont, xfaFont];
42471    }
42472    const xfaFont = {
42473      typeface: "Courier",
42474      posture: "normal",
42475      weight: "normal",
42476      size: 10,
42477      letterSpacing: 0
42478    };
42479    return [null, xfaFont];
42480  }
42481}
42482class FontSelector {
42483  constructor(defaultXfaFont, defaultParaMargin, defaultLineHeight, fontFinder) {
42484    this.fontFinder = fontFinder;
42485    this.stack = [new FontInfo(defaultXfaFont, defaultParaMargin, defaultLineHeight, fontFinder)];
42486  }
42487  pushData(xfaFont, margin, lineHeight) {
42488    const lastFont = this.stack.at(-1);
42489    for (const name of ["typeface", "posture", "weight", "size", "letterSpacing"]) {
42490      xfaFont[name] ||= lastFont.xfaFont[name];
42491    }
42492    for (const name of ["top", "bottom", "left", "right"]) {
42493      if (isNaN(margin[name])) {
42494        margin[name] = lastFont.paraMargin[name];
42495      }
42496    }
42497    const fontInfo = new FontInfo(xfaFont, margin, lineHeight || lastFont.lineHeight, this.fontFinder);
42498    fontInfo.pdfFont ||= lastFont.pdfFont;
42499    this.stack.push(fontInfo);
42500  }
42501  popFont() {
42502    this.stack.pop();
42503  }
42504  topFont() {
42505    return this.stack.at(-1);
42506  }
42507}
42508class TextMeasure {
42509  constructor(defaultXfaFont, defaultParaMargin, defaultLineHeight, fonts) {
42510    this.glyphs = [];
42511    this.fontSelector = new FontSelector(defaultXfaFont, defaultParaMargin, defaultLineHeight, fonts);
42512    this.extraHeight = 0;
42513  }
42514  pushData(xfaFont, margin, lineHeight) {
42515    this.fontSelector.pushData(xfaFont, margin, lineHeight);
42516  }
42517  popFont(xfaFont) {
42518    return this.fontSelector.popFont();
42519  }
42520  addPara() {
42521    const lastFont = this.fontSelector.topFont();
42522    this.extraHeight += lastFont.paraMargin.top + lastFont.paraMargin.bottom;
42523  }
42524  addString(str) {
42525    if (!str) {
42526      return;
42527    }
42528    const lastFont = this.fontSelector.topFont();
42529    const fontSize = lastFont.xfaFont.size;
42530    if (lastFont.pdfFont) {
42531      const letterSpacing = lastFont.xfaFont.letterSpacing;
42532      const pdfFont = lastFont.pdfFont;
42533      const fontLineHeight = pdfFont.lineHeight || 1.2;
42534      const lineHeight = lastFont.lineHeight || Math.max(1.2, fontLineHeight) * fontSize;
42535      const lineGap = pdfFont.lineGap === undefined ? 0.2 : pdfFont.lineGap;
42536      const noGap = fontLineHeight - lineGap;
42537      const firstLineHeight = Math.max(1, noGap) * fontSize;
42538      const scale = fontSize / 1000;
42539      const fallbackWidth = pdfFont.defaultWidth || pdfFont.charsToGlyphs(" ")[0].width;
42540      for (const line of str.split(/[\u2029\n]/)) {
42541        const encodedLine = pdfFont.encodeString(line).join("");
42542        const glyphs = pdfFont.charsToGlyphs(encodedLine);
42543        for (const glyph of glyphs) {
42544          const width = glyph.width || fallbackWidth;
42545          this.glyphs.push([width * scale + letterSpacing, lineHeight, firstLineHeight, glyph.unicode, false]);
42546        }
42547        this.glyphs.push([0, 0, 0, "\n", true]);
42548      }
42549      this.glyphs.pop();
42550      return;
42551    }
42552    for (const line of str.split(/[\u2029\n]/)) {
42553      for (const char of line.split("")) {
42554        this.glyphs.push([fontSize, 1.2 * fontSize, fontSize, char, false]);
42555      }
42556      this.glyphs.push([0, 0, 0, "\n", true]);
42557    }
42558    this.glyphs.pop();
42559  }
42560  compute(maxWidth) {
42561    let lastSpacePos = -1,
42562      lastSpaceWidth = 0,
42563      width = 0,
42564      height = 0,
42565      currentLineWidth = 0,
42566      currentLineHeight = 0;
42567    let isBroken = false;
42568    let isFirstLine = true;
42569    for (let i = 0, ii = this.glyphs.length; i < ii; i++) {
42570      const [glyphWidth, lineHeight, firstLineHeight, char, isEOL] = this.glyphs[i];
42571      const isSpace = char === " ";
42572      const glyphHeight = isFirstLine ? firstLineHeight : lineHeight;
42573      if (isEOL) {
42574        width = Math.max(width, currentLineWidth);
42575        currentLineWidth = 0;
42576        height += currentLineHeight;
42577        currentLineHeight = glyphHeight;
42578        lastSpacePos = -1;
42579        lastSpaceWidth = 0;
42580        isFirstLine = false;
42581        continue;
42582      }
42583      if (isSpace) {
42584        if (currentLineWidth + glyphWidth > maxWidth) {
42585          width = Math.max(width, currentLineWidth);
42586          currentLineWidth = 0;
42587          height += currentLineHeight;
42588          currentLineHeight = glyphHeight;
42589          lastSpacePos = -1;
42590          lastSpaceWidth = 0;
42591          isBroken = true;
42592          isFirstLine = false;
42593        } else {
42594          currentLineHeight = Math.max(glyphHeight, currentLineHeight);
42595          lastSpaceWidth = currentLineWidth;
42596          currentLineWidth += glyphWidth;
42597          lastSpacePos = i;
42598        }
42599        continue;
42600      }
42601      if (currentLineWidth + glyphWidth > maxWidth) {
42602        height += currentLineHeight;
42603        currentLineHeight = glyphHeight;
42604        if (lastSpacePos !== -1) {
42605          i = lastSpacePos;
42606          width = Math.max(width, lastSpaceWidth);
42607          currentLineWidth = 0;
42608          lastSpacePos = -1;
42609          lastSpaceWidth = 0;
42610        } else {
42611          width = Math.max(width, currentLineWidth);
42612          currentLineWidth = glyphWidth;
42613        }
42614        isBroken = true;
42615        isFirstLine = false;
42616        continue;
42617      }
42618      currentLineWidth += glyphWidth;
42619      currentLineHeight = Math.max(glyphHeight, currentLineHeight);
42620    }
42621    width = Math.max(width, currentLineWidth);
42622    height += currentLineHeight + this.extraHeight;
42623    return {
42624      width: WIDTH_FACTOR * width,
42625      height,
42626      isBroken
42627    };
42628  }
42629}
42630
42631;// ./src/core/xfa/som.js
42632
42633
42634const namePattern = /^[^.[]+/;
42635const indexPattern = /^[^\]]+/;
42636const operators = {
42637  dot: 0,
42638  dotDot: 1,
42639  dotHash: 2,
42640  dotBracket: 3,
42641  dotParen: 4
42642};
42643const shortcuts = new Map([["$data", (root, current) => root.datasets ? root.datasets.data : root], ["$record", (root, current) => (root.datasets ? root.datasets.data : root)[$getChildren]()[0]], ["$template", (root, current) => root.template], ["$connectionSet", (root, current) => root.connectionSet], ["$form", (root, current) => root.form], ["$layout", (root, current) => root.layout], ["$host", (root, current) => root.host], ["$dataWindow", (root, current) => root.dataWindow], ["$event", (root, current) => root.event], ["!", (root, current) => root.datasets], ["$xfa", (root, current) => root], ["xfa", (root, current) => root], ["$", (root, current) => current]]);
42644const somCache = new WeakMap();
42645function parseIndex(index) {
42646  index = index.trim();
42647  if (index === "*") {
42648    return Infinity;
42649  }
42650  return parseInt(index, 10) || 0;
42651}
42652function parseExpression(expr, dotDotAllowed, noExpr = true) {
42653  let match = expr.match(namePattern);
42654  if (!match) {
42655    return null;
42656  }
42657  let [name] = match;
42658  const parsed = [{
42659    name,
42660    cacheName: "." + name,
42661    index: 0,
42662    js: null,
42663    formCalc: null,
42664    operator: operators.dot
42665  }];
42666  let pos = name.length;
42667  while (pos < expr.length) {
42668    const spos = pos;
42669    const char = expr.charAt(pos++);
42670    if (char === "[") {
42671      match = expr.slice(pos).match(indexPattern);
42672      if (!match) {
42673        warn("XFA - Invalid index in SOM expression");
42674        return null;
42675      }
42676      parsed.at(-1).index = parseIndex(match[0]);
42677      pos += match[0].length + 1;
42678      continue;
42679    }
42680    let operator;
42681    switch (expr.charAt(pos)) {
42682      case ".":
42683        if (!dotDotAllowed) {
42684          return null;
42685        }
42686        pos++;
42687        operator = operators.dotDot;
42688        break;
42689      case "#":
42690        pos++;
42691        operator = operators.dotHash;
42692        break;
42693      case "[":
42694        if (noExpr) {
42695          warn("XFA - SOM expression contains a FormCalc subexpression which is not supported for now.");
42696          return null;
42697        }
42698        operator = operators.dotBracket;
42699        break;
42700      case "(":
42701        if (noExpr) {
42702          warn("XFA - SOM expression contains a JavaScript subexpression which is not supported for now.");
42703          return null;
42704        }
42705        operator = operators.dotParen;
42706        break;
42707      default:
42708        operator = operators.dot;
42709        break;
42710    }
42711    match = expr.slice(pos).match(namePattern);
42712    if (!match) {
42713      break;
42714    }
42715    [name] = match;
42716    pos += name.length;
42717    parsed.push({
42718      name,
42719      cacheName: expr.slice(spos, pos),
42720      operator,
42721      index: 0,
42722      js: null,
42723      formCalc: null
42724    });
42725  }
42726  return parsed;
42727}
42728function searchNode(root, container, expr, dotDotAllowed = true, useCache = true) {
42729  const parsed = parseExpression(expr, dotDotAllowed);
42730  if (!parsed) {
42731    return null;
42732  }
42733  const fn = shortcuts.get(parsed[0].name);
42734  let i = 0;
42735  let isQualified;
42736  if (fn) {
42737    isQualified = true;
42738    root = [fn(root, container)];
42739    i = 1;
42740  } else {
42741    isQualified = container === null;
42742    root = [container || root];
42743  }
42744  for (let ii = parsed.length; i < ii; i++) {
42745    const {
42746      name,
42747      cacheName,
42748      operator,
42749      index
42750    } = parsed[i];
42751    const nodes = [];
42752    for (const node of root) {
42753      if (!node.isXFAObject) {
42754        continue;
42755      }
42756      let children, cached;
42757      if (useCache) {
42758        cached = somCache.getOrInsertComputed(node, makeMap);
42759        children = cached.get(cacheName);
42760      }
42761      if (!children) {
42762        switch (operator) {
42763          case operators.dot:
42764            children = node[$getChildrenByName](name, false);
42765            break;
42766          case operators.dotDot:
42767            children = node[$getChildrenByName](name, true);
42768            break;
42769          case operators.dotHash:
42770            children = node[$getChildrenByClass](name);
42771            children = children.isXFAObjectArray ? children.children : [children];
42772            break;
42773          default:
42774            break;
42775        }
42776        if (useCache) {
42777          cached.set(cacheName, children);
42778        }
42779      }
42780      if (children.length > 0) {
42781        nodes.push(children);
42782      }
42783    }
42784    if (nodes.length === 0 && !isQualified && i === 0) {
42785      const parent = container[$getParent]();
42786      container = parent;
42787      if (!container) {
42788        return null;
42789      }
42790      i = -1;
42791      root = [container];
42792      continue;
42793    }
42794    root = isFinite(index) ? nodes.filter(node => index < node.length).map(node => node[index]) : nodes.flat();
42795  }
42796  if (root.length === 0) {
42797    return null;
42798  }
42799  return root;
42800}
42801function createDataNode(root, container, expr) {
42802  const parsed = parseExpression(expr);
42803  if (!parsed) {
42804    return null;
42805  }
42806  if (parsed.some(x => x.operator === operators.dotDot)) {
42807    return null;
42808  }
42809  const fn = shortcuts.get(parsed[0].name);
42810  let i = 0;
42811  if (fn) {
42812    root = fn(root, container);
42813    i = 1;
42814  } else {
42815    root = container || root;
42816  }
42817  for (let ii = parsed.length; i < ii; i++) {
42818    const {
42819      name,
42820      operator,
42821      index
42822    } = parsed[i];
42823    if (!isFinite(index)) {
42824      parsed[i].index = 0;
42825      return root.createNodes(parsed.slice(i));
42826    }
42827    let children;
42828    switch (operator) {
42829      case operators.dot:
42830        children = root[$getChildrenByName](name, false);
42831        break;
42832      case operators.dotDot:
42833        children = root[$getChildrenByName](name, true);
42834        break;
42835      case operators.dotHash:
42836        children = root[$getChildrenByClass](name);
42837        children = children.isXFAObjectArray ? children.children : [children];
42838        break;
42839      default:
42840        break;
42841    }
42842    if (children.length === 0) {
42843      return root.createNodes(parsed.slice(i));
42844    }
42845    if (index < children.length) {
42846      const child = children[index];
42847      if (!child.isXFAObject) {
42848        warn(`XFA - Cannot create a node.`);
42849        return null;
42850      }
42851      root = child;
42852    } else {
42853      parsed[i].index = index - children.length;
42854      return root.createNodes(parsed.slice(i));
42855    }
42856  }
42857  return null;
42858}
42859
42860;// ./src/core/xfa/xfa_object.js
42861
42862
42863
42864
42865
42866
42867const _applyPrototype = Symbol();
42868const _attributes = Symbol();
42869const _attributeNames = Symbol();
42870const _children = Symbol("_children");
42871const _cloneAttribute = Symbol();
42872const _dataValue = Symbol();
42873const _defaultValue = Symbol();
42874const _filteredChildrenGenerator = Symbol();
42875const _getPrototype = Symbol();
42876const _getUnsetAttributes = Symbol();
42877const _hasChildren = Symbol();
42878const _max = Symbol();
42879const _options = Symbol();
42880const _parent = Symbol("parent");
42881const _resolvePrototypesHelper = Symbol();
42882const _setAttributes = Symbol();
42883const _validator = Symbol();
42884let uid = 0;
42885const NS_DATASETS = NamespaceIds.datasets.id;
42886class XFAObject {
42887  constructor(nsId, name, hasChildren = false) {
42888    this[$namespaceId] = nsId;
42889    this[$nodeName] = name;
42890    this[_hasChildren] = hasChildren;
42891    this[_parent] = null;
42892    this[_children] = [];
42893    this[$uid] = `${name}${uid++}`;
42894    this[$globalData] = null;
42895  }
42896  get isXFAObject() {
42897    return true;
42898  }
42899  get isXFAObjectArray() {
42900    return false;
42901  }
42902  createNodes(path) {
42903    let root = this,
42904      node = null;
42905    for (const {
42906      name,
42907      index
42908    } of path) {
42909      for (let i = 0, ii = isFinite(index) ? index : 0; i <= ii; i++) {
42910        const nsId = root[$namespaceId] === NS_DATASETS ? -1 : root[$namespaceId];
42911        node = new XmlObject(nsId, name);
42912        root[$appendChild](node);
42913      }
42914      root = node;
42915    }
42916    return node;
42917  }
42918  [$onChild](child) {
42919    if (!this[_hasChildren] || !this[$onChildCheck](child)) {
42920      return false;
42921    }
42922    const name = child[$nodeName];
42923    const node = this[name];
42924    if (node instanceof XFAObjectArray) {
42925      if (node.push(child)) {
42926        this[$appendChild](child);
42927        return true;
42928      }
42929    } else {
42930      if (node !== null) {
42931        this[$removeChild](node);
42932      }
42933      this[name] = child;
42934      this[$appendChild](child);
42935      return true;
42936    }
42937    let id = "";
42938    if (this.id) {
42939      id = ` (id: ${this.id})`;
42940    } else if (this.name) {
42941      id = ` (name: ${this.name} ${this.h.value})`;
42942    }
42943    warn(`XFA - node "${this[$nodeName]}"${id} has already enough "${name}"!`);
42944    return false;
42945  }
42946  [$onChildCheck](child) {
42947    return Object.hasOwn(this, child[$nodeName]) && child[$namespaceId] === this[$namespaceId];
42948  }
42949  [$isNsAgnostic]() {
42950    return false;
42951  }
42952  [$acceptWhitespace]() {
42953    return false;
42954  }
42955  [$isCDATAXml]() {
42956    return false;
42957  }
42958  [$isBindable]() {
42959    return false;
42960  }
42961  [$popPara]() {
42962    if (this.para) {
42963      this[$getTemplateRoot]()[$extra].paraStack.pop();
42964    }
42965  }
42966  [$pushPara]() {
42967    this[$getTemplateRoot]()[$extra].paraStack.push(this.para);
42968  }
42969  [$setId](ids) {
42970    if (this.id && this[$namespaceId] === NamespaceIds.template.id) {
42971      ids.set(this.id, this);
42972    }
42973  }
42974  [$getTemplateRoot]() {
42975    return this[$globalData].template;
42976  }
42977  [$isSplittable]() {
42978    return false;
42979  }
42980  [$isThereMoreWidth]() {
42981    return false;
42982  }
42983  [$appendChild](child) {
42984    child[_parent] = this;
42985    this[_children].push(child);
42986    if (!child[$globalData] && this[$globalData]) {
42987      child[$globalData] = this[$globalData];
42988    }
42989  }
42990  [$removeChild](child) {
42991    const i = this[_children].indexOf(child);
42992    this[_children].splice(i, 1);
42993  }
42994  [$hasSettableValue]() {
42995    return Object.hasOwn(this, "value");
42996  }
42997  [$setValue](_) {}
42998  [$onText](_) {}
42999  [$finalize]() {}
43000  [$clean](builder) {
43001    delete this[_hasChildren];
43002    if (this[$cleanup]) {
43003      builder.clean(this[$cleanup]);
43004      delete this[$cleanup];
43005    }
43006  }
43007  [$indexOf](child) {
43008    return this[_children].indexOf(child);
43009  }
43010  [$insertAt](i, child) {
43011    child[_parent] = this;
43012    this[_children].splice(i, 0, child);
43013    if (!child[$globalData] && this[$globalData]) {
43014      child[$globalData] = this[$globalData];
43015    }
43016  }
43017  [$isTransparent]() {
43018    return !this.name;
43019  }
43020  [$lastAttribute]() {
43021    return "";
43022  }
43023  [$text]() {
43024    
vendor: 11,412 bytes, lines 43024-43433
43024if (this[_children].length === 0) {
43025      return this[$content];
43026    }
43027    return this[_children].map(c => c[$text]()).join("");
43028  }
43029  get [_attributeNames]() {
43030    const proto = Object.getPrototypeOf(this);
43031    if (!proto._attributes) {
43032      const attributes = proto._attributes = new Set();
43033      for (const name of Object.getOwnPropertyNames(this)) {
43034        if (this[name] === null || this[name] instanceof XFAObject || this[name] instanceof XFAObjectArray) {
43035          break;
43036        }
43037        attributes.add(name);
43038      }
43039    }
43040    return shadow(this, _attributeNames, proto._attributes);
43041  }
43042  [$isDescendent](parent) {
43043    let node = this;
43044    while (node) {
43045      if (node === parent) {
43046        return true;
43047      }
43048      node = node[$getParent]();
43049    }
43050    return false;
43051  }
43052  [$getParent]() {
43053    return this[_parent];
43054  }
43055  [$getSubformParent]() {
43056    return this[$getParent]();
43057  }
43058  [$getChildren](name = null) {
43059    if (!name) {
43060      return this[_children];
43061    }
43062    return this[name];
43063  }
43064  [$dump]() {
43065    const dumped = Object.create(null);
43066    if (this[$content]) {
43067      dumped.$content = this[$content];
43068    }
43069    for (const name of Object.getOwnPropertyNames(this)) {
43070      const value = this[name];
43071      if (value === null) {
43072        continue;
43073      }
43074      if (value instanceof XFAObject) {
43075        dumped[name] = value[$dump]();
43076      } else if (value instanceof XFAObjectArray) {
43077        if (!value.isEmpty()) {
43078          dumped[name] = value.dump();
43079        }
43080      } else {
43081        dumped[name] = value;
43082      }
43083    }
43084    return dumped;
43085  }
43086  [$toStyle]() {
43087    return null;
43088  }
43089  [$toHTML]() {
43090    return HTMLResult.EMPTY;
43091  }
43092  *[$getContainedChildren]() {
43093    for (const node of this[$getChildren]()) {
43094      yield node;
43095    }
43096  }
43097  *[_filteredChildrenGenerator](filter, include) {
43098    for (const node of this[$getContainedChildren]()) {
43099      if (!filter || include === filter.has(node[$nodeName])) {
43100        const availableSpace = this[$getAvailableSpace]();
43101        const res = node[$toHTML](availableSpace);
43102        if (!res.success) {
43103          this[$extra].failingNode = node;
43104        }
43105        yield res;
43106      }
43107    }
43108  }
43109  [$flushHTML]() {
43110    return null;
43111  }
43112  [$addHTML](html, bbox) {
43113    this[$extra].children.push(html);
43114  }
43115  [$getAvailableSpace]() {}
43116  [$childrenToHTML]({
43117    filter = null,
43118    include = true
43119  }) {
43120    if (!this[$extra].generator) {
43121      this[$extra].generator = this[_filteredChildrenGenerator](filter, include);
43122    } else {
43123      const availableSpace = this[$getAvailableSpace]();
43124      const res = this[$extra].failingNode[$toHTML](availableSpace);
43125      if (!res.success) {
43126        return res;
43127      }
43128      if (res.html) {
43129        this[$addHTML](res.html, res.bbox);
43130      }
43131      delete this[$extra].failingNode;
43132    }
43133    while (true) {
43134      const gen = this[$extra].generator.next();
43135      if (gen.done) {
43136        break;
43137      }
43138      const res = gen.value;
43139      if (!res.success) {
43140        return res;
43141      }
43142      if (res.html) {
43143        this[$addHTML](res.html, res.bbox);
43144      }
43145    }
43146    this[$extra].generator = null;
43147    return HTMLResult.EMPTY;
43148  }
43149  [$setSetAttributes](attributes) {
43150    this[_setAttributes] = new Set(Object.keys(attributes));
43151  }
43152  [_getUnsetAttributes](protoAttributes) {
43153    const allAttr = this[_attributeNames];
43154    const setAttr = this[_setAttributes];
43155    return [...protoAttributes].filter(x => allAttr.has(x) && !setAttr.has(x));
43156  }
43157  [$resolvePrototypes](ids, ancestors = new Set()) {
43158    for (const child of this[_children]) {
43159      child[_resolvePrototypesHelper](ids, ancestors);
43160    }
43161  }
43162  [_resolvePrototypesHelper](ids, ancestors) {
43163    const proto = this[_getPrototype](ids, ancestors);
43164    if (proto) {
43165      this[_applyPrototype](proto, ids, ancestors);
43166    } else {
43167      this[$resolvePrototypes](ids, ancestors);
43168    }
43169  }
43170  [_getPrototype](ids, ancestors) {
43171    const {
43172      use,
43173      usehref
43174    } = this;
43175    if (!use && !usehref) {
43176      return null;
43177    }
43178    let proto = null;
43179    let somExpression = null;
43180    let id = null;
43181    let ref = use;
43182    if (usehref) {
43183      ref = usehref;
43184      if (usehref.startsWith("#som(") && usehref.endsWith(")")) {
43185        somExpression = usehref.slice("#som(".length, -1);
43186      } else if (usehref.startsWith(".#som(") && usehref.endsWith(")")) {
43187        somExpression = usehref.slice(".#som(".length, -1);
43188      } else if (usehref.startsWith("#")) {
43189        id = usehref.slice(1);
43190      } else if (usehref.startsWith(".#")) {
43191        id = usehref.slice(2);
43192      }
43193    } else if (use.startsWith("#")) {
43194      id = use.slice(1);
43195    } else {
43196      somExpression = use;
43197    }
43198    this.use = this.usehref = "";
43199    if (id) {
43200      proto = ids.get(id);
43201    } else {
43202      proto = searchNode(ids.get($root), this, somExpression, true, false);
43203      if (proto) {
43204        proto = proto[0];
43205      }
43206    }
43207    if (!proto) {
43208      warn(`XFA - Invalid prototype reference: ${ref}.`);
43209      return null;
43210    }
43211    if (proto[$nodeName] !== this[$nodeName]) {
43212      warn(`XFA - Incompatible prototype: ${proto[$nodeName]} !== ${this[$nodeName]}.`);
43213      return null;
43214    }
43215    if (ancestors.has(proto)) {
43216      warn(`XFA - Cycle detected in prototypes use.`);
43217      return null;
43218    }
43219    ancestors.add(proto);
43220    const protoProto = proto[_getPrototype](ids, ancestors);
43221    if (protoProto) {
43222      proto[_applyPrototype](protoProto, ids, ancestors);
43223    }
43224    proto[$resolvePrototypes](ids, ancestors);
43225    ancestors.delete(proto);
43226    return proto;
43227  }
43228  [_applyPrototype](proto, ids, ancestors) {
43229    if (ancestors.has(proto)) {
43230      warn(`XFA - Cycle detected in prototypes use.`);
43231      return;
43232    }
43233    if (!this[$content] && proto[$content]) {
43234      this[$content] = proto[$content];
43235    }
43236    const newAncestors = new Set(ancestors);
43237    newAncestors.add(proto);
43238    for (const unsetAttrName of this[_getUnsetAttributes](proto[_setAttributes])) {
43239      this[unsetAttrName] = proto[unsetAttrName];
43240      if (this[_setAttributes]) {
43241        this[_setAttributes].add(unsetAttrName);
43242      }
43243    }
43244    for (const name of Object.getOwnPropertyNames(this)) {
43245      if (this[_attributeNames].has(name)) {
43246        continue;
43247      }
43248      const value = this[name];
43249      const protoValue = proto[name];
43250      if (value instanceof XFAObjectArray) {
43251        for (const child of value[_children]) {
43252          child[_resolvePrototypesHelper](ids, ancestors);
43253        }
43254        for (let i = value[_children].length, ii = protoValue[_children].length; i < ii; i++) {
43255          const child = proto[_children][i][$clone]();
43256          if (value.push(child)) {
43257            child[_parent] = this;
43258            this[_children].push(child);
43259            child[_resolvePrototypesHelper](ids, ancestors);
43260          } else {
43261            break;
43262          }
43263        }
43264        continue;
43265      }
43266      if (value !== null) {
43267        value[$resolvePrototypes](ids, ancestors);
43268        if (protoValue) {
43269          value[_applyPrototype](protoValue, ids, ancestors);
43270        }
43271        continue;
43272      }
43273      if (protoValue !== null) {
43274        const child = protoValue[$clone]();
43275        child[_parent] = this;
43276        this[name] = child;
43277        this[_children].push(child);
43278        child[_resolvePrototypesHelper](ids, ancestors);
43279      }
43280    }
43281  }
43282  static [_cloneAttribute](obj) {
43283    if (Array.isArray(obj)) {
43284      return obj.map(x => XFAObject[_cloneAttribute](x));
43285    }
43286    if (typeof obj === "object" && obj !== null) {
43287      return Object.assign({}, obj);
43288    }
43289    return obj;
43290  }
43291  [$clone]() {
43292    const clone = Object.create(Object.getPrototypeOf(this));
43293    for (const $symbol of Object.getOwnPropertySymbols(this)) {
43294      try {
43295        clone[$symbol] = this[$symbol];
43296      } catch {
43297        shadow(clone, $symbol, this[$symbol]);
43298      }
43299    }
43300    clone[$uid] = `${clone[$nodeName]}${uid++}`;
43301    clone[_children] = [];
43302    for (const name of Object.getOwnPropertyNames(this)) {
43303      if (this[_attributeNames].has(name)) {
43304        clone[name] = XFAObject[_cloneAttribute](this[name]);
43305        continue;
43306      }
43307      const value = this[name];
43308      clone[name] = value instanceof XFAObjectArray ? new XFAObjectArray(value[_max]) : null;
43309    }
43310    for (const child of this[_children]) {
43311      const name = child[$nodeName];
43312      const clonedChild = child[$clone]();
43313      clone[_children].push(clonedChild);
43314      clonedChild[_parent] = clone;
43315      if (clone[name] === null) {
43316        clone[name] = clonedChild;
43317      } else {
43318        clone[name][_children].push(clonedChild);
43319      }
43320    }
43321    return clone;
43322  }
43323  [$getChildren](name = null) {
43324    if (!name) {
43325      return this[_children];
43326    }
43327    return this[_children].filter(c => c[$nodeName] === name);
43328  }
43329  [$getChildrenByClass](name) {
43330    return this[name];
43331  }
43332  [$getChildrenByName](name, allTransparent, first = true) {
43333    return Array.from(this[$getChildrenByNameIt](name, allTransparent, first));
43334  }
43335  *[$getChildrenByNameIt](name, allTransparent, first = true) {
43336    if (name === "parent") {
43337      yield this[_parent];
43338      return;
43339    }
43340    for (const child of this[_children]) {
43341      if (child[$nodeName] === name) {
43342        yield child;
43343      }
43344      if (child.name === name) {
43345        yield child;
43346      }
43347      if (allTransparent || child[$isTransparent]()) {
43348        yield* child[$getChildrenByNameIt](name, allTransparent, false);
43349      }
43350    }
43351    if (first && this[_attributeNames].has(name)) {
43352      yield new XFAAttribute(this, name, this[name]);
43353    }
43354  }
43355}
43356class XFAObjectArray {
43357  constructor(max = Infinity) {
43358    this[_max] = max;
43359    this[_children] = [];
43360  }
43361  get isXFAObject() {
43362    return false;
43363  }
43364  get isXFAObjectArray() {
43365    return true;
43366  }
43367  push(child) {
43368    const len = this[_children].length;
43369    if (len <= this[_max]) {
43370      this[_children].push(child);
43371      return true;
43372    }
43373    warn(`XFA - node "${child[$nodeName]}" accepts no more than ${this[_max]} children`);
43374    return false;
43375  }
43376  isEmpty() {
43377    return this[_children].length === 0;
43378  }
43379  dump() {
43380    return this[_children].length === 1 ? this[_children][0][$dump]() : this[_children].map(x => x[$dump]());
43381  }
43382  [$clone]() {
43383    const clone = new XFAObjectArray(this[_max]);
43384    clone[_children] = this[_children].map(c => c[$clone]());
43385    return clone;
43386  }
43387  get children() {
43388    return this[_children];
43389  }
43390  clear() {
43391    this[_children].length = 0;
43392  }
43393}
43394class XFAAttribute {
43395  constructor(node, name, value) {
43396    this[_parent] = node;
43397    this[$nodeName] = name;
43398    this[$content] = value;
43399    this[$consumed] = false;
43400    this[$uid] = `attribute${uid++}`;
43401  }
43402  [$getParent]() {
43403    return this[_parent];
43404  }
43405  [$isDataValue]() {
43406    return true;
43407  }
43408  [$getDataValue]() {
43409    return this[$content].trim();
43410  }
43411  [$setValue](value) {
43412    value = value.value || "";
43413    this[$content] = value.toString();
43414  }
43415  [$text]() {
43416    return this[$content];
43417  }
43418  [$isDescendent](parent) {
43419    return this[_parent] === parent || this[_parent][$isDescendent](parent);
43420  }
43421}
43422class XmlObject extends XFAObject {
43423  constructor(nsId, name, attributes = {}) {
43424    super(nsId, name);
43425    this[$content] = "";
43426    this[_dataValue] = null;
43427    if (name !== "#text") {
43428      const map = new Map();
43429      this[_attributes] = map;
43430      for (const [attrName, value] of Object.entries(attributes)) {
43431        map.set(attrName, new XFAAttribute(this, attrName, value));
43432      }
43433      if (
vendor: 3,433 bytes, lines 43433-43554
43433Object.hasOwn(attributes, $nsAttributes)) {
43434        const dataNode = attributes[$nsAttributes].xfa.dataNode;
43435        if (dataNode !== undefined) {
43436          if (dataNode === "dataGroup") {
43437            this[_dataValue] = false;
43438          } else if (dataNode === "dataValue") {
43439            this[_dataValue] = true;
43440          }
43441        }
43442      }
43443    }
43444    this[$consumed] = false;
43445  }
43446  [$toString](buf) {
43447    const tagName = this[$nodeName];
43448    if (tagName === "#text") {
43449      buf.push(encodeToXmlString(this[$content]));
43450      return;
43451    }
43452    const utf8TagName = utf8StringToString(tagName);
43453    const prefix = this[$namespaceId] === NS_DATASETS ? "xfa:" : "";
43454    buf.push(`<${prefix}${utf8TagName}`);
43455    for (const [name, value] of this[_attributes]) {
43456      const utf8Name = utf8StringToString(name);
43457      buf.push(` ${utf8Name}="${encodeToXmlString(value[$content])}"`);
43458    }
43459    if (this[_dataValue] !== null) {
43460      if (this[_dataValue]) {
43461        buf.push(` xfa:dataNode="dataValue"`);
43462      } else {
43463        buf.push(` xfa:dataNode="dataGroup"`);
43464      }
43465    }
43466    if (!this[$content] && this[_children].length === 0) {
43467      buf.push("/>");
43468      return;
43469    }
43470    buf.push(">");
43471    if (this[$content]) {
43472      if (typeof this[$content] === "string") {
43473        buf.push(encodeToXmlString(this[$content]));
43474      } else {
43475        this[$content][$toString](buf);
43476      }
43477    } else {
43478      for (const child of this[_children]) {
43479        child[$toString](buf);
43480      }
43481    }
43482    buf.push(`</${prefix}${utf8TagName}>`);
43483  }
43484  [$onChild](child) {
43485    if (this[$content]) {
43486      const node = new XmlObject(this[$namespaceId], "#text");
43487      this[$appendChild](node);
43488      node[$content] = this[$content];
43489      this[$content] = "";
43490    }
43491    this[$appendChild](child);
43492    return true;
43493  }
43494  [$onText](str) {
43495    this[$content] += str;
43496  }
43497  [$finalize]() {
43498    if (this[$content] && this[_children].length > 0) {
43499      const node = new XmlObject(this[$namespaceId], "#text");
43500      this[$appendChild](node);
43501      node[$content] = this[$content];
43502      delete this[$content];
43503    }
43504  }
43505  [$toHTML]() {
43506    if (this[$nodeName] === "#text") {
43507      return HTMLResult.success({
43508        name: "#text",
43509        value: this[$content]
43510      });
43511    }
43512    return HTMLResult.EMPTY;
43513  }
43514  [$getChildren](name = null) {
43515    if (!name) {
43516      return this[_children];
43517    }
43518    return this[_children].filter(c => c[$nodeName] === name);
43519  }
43520  [$getAttributes]() {
43521    return this[_attributes];
43522  }
43523  [$getChildrenByClass](name) {
43524    const value = this[_attributes].get(name);
43525    if (value !== undefined) {
43526      return value;
43527    }
43528    return this[$getChildren](name);
43529  }
43530  *[$getChildrenByNameIt](name, allTransparent) {
43531    const value = this[_attributes].get(name);
43532    if (value) {
43533      yield value;
43534    }
43535    for (const child of this[_children]) {
43536      if (child[$nodeName] === name) {
43537        yield child;
43538      }
43539      if (allTransparent) {
43540        yield* child[$getChildrenByNameIt](name, allTransparent);
43541      }
43542    }
43543  }
43544  *[$getAttributeIt](name, skipConsumed) {
43545    const value = this[_attributes].get(name);
43546    if (value && (!skipConsumed || !value[$consumed])) {
43547      yield value;
43548    }
43549    for (const child of this[_children]) {
43550      yield* child[$getAttributeIt](name, skipConsumed);
43551    }
43552  }
43553  *[$getRealChildrenByNameIt](name, allTransparent, skipConsumed) {
43554    for (const child of this[_children]) {
vendor: 2,860 bytes, lines 43555-43667
43555      if (child[$nodeName] === name && (!skipConsumed || !child[$consumed])) {
43556        yield child;
43557      }
43558      if (allTransparent) {
43559        yield* child[$getRealChildrenByNameIt](name, allTransparent, skipConsumed);
43560      }
43561    }
43562  }
43563  [$isDataValue]() {
43564    if (this[_dataValue] === null) {
43565      return this[_children].length === 0 || this[_children][0][$namespaceId] === NamespaceIds.xhtml.id;
43566    }
43567    return this[_dataValue];
43568  }
43569  [$getDataValue]() {
43570    if (this[_dataValue] === null) {
43571      if (this[_children].length === 0) {
43572        return this[$content].trim();
43573      }
43574      if (this[_children][0][$namespaceId] === NamespaceIds.xhtml.id) {
43575        return this[_children][0][$text]().trim();
43576      }
43577      return null;
43578    }
43579    return this[$content].trim();
43580  }
43581  [$setValue](value) {
43582    value = value.value || "";
43583    this[$content] = value.toString();
43584  }
43585  [$dump](hasNS = false) {
43586    const dumped = Object.create(null);
43587    if (hasNS) {
43588      dumped.$ns = this[$namespaceId];
43589    }
43590    if (this[$content]) {
43591      dumped.$content = this[$content];
43592    }
43593    dumped.$name = this[$nodeName];
43594    dumped.children = [];
43595    for (const child of this[_children]) {
43596      dumped.children.push(child[$dump](hasNS));
43597    }
43598    dumped.attributes = Object.create(null);
43599    for (const [name, value] of this[_attributes]) {
43600      dumped.attributes[name] = value[$content];
43601    }
43602    return dumped;
43603  }
43604}
43605class ContentObject extends XFAObject {
43606  constructor(nsId, name) {
43607    super(nsId, name);
43608    this[$content] = "";
43609  }
43610  [$onText](text) {
43611    this[$content] += text;
43612  }
43613  [$finalize]() {}
43614}
43615class OptionObject extends ContentObject {
43616  constructor(nsId, name, options) {
43617    super(nsId, name);
43618    this[_options] = options;
43619  }
43620  [$finalize]() {
43621    this[$content] = getKeyword({
43622      data: this[$content],
43623      defaultValue: this[_options][0],
43624      validate: k => this[_options].includes(k)
43625    });
43626  }
43627  [$clean](builder) {
43628    super[$clean](builder);
43629    delete this[_options];
43630  }
43631}
43632class StringObject extends ContentObject {
43633  [$finalize]() {
43634    this[$content] = this[$content].trim();
43635  }
43636}
43637class IntegerObject extends ContentObject {
43638  constructor(nsId, name, defaultValue, validator) {
43639    super(nsId, name);
43640    this[_defaultValue] = defaultValue;
43641    this[_validator] = validator;
43642  }
43643  [$finalize]() {
43644    this[$content] = getInteger({
43645      data: this[$content],
43646      defaultValue: this[_defaultValue],
43647      validate: this[_validator]
43648    });
43649  }
43650  [$clean](builder) {
43651    super[$clean](builder);
43652    delete this[_defaultValue];
43653    delete this[_validator];
43654  }
43655}
43656class Option01 extends IntegerObject {
43657  constructor(nsId, name) {
43658    super(nsId, name, 0, n => n === 1);
43659  }
43660}
43661class Option10 extends IntegerObject {
43662  constructor(nsId, name) {
43663    super(nsId, name, 1, n => n === 0);
43664  }
43665}
43666
43667;// ./src/core/xfa/html_utils.js
vendor: 13,429 bytes, lines 43667-44141
43667
43668
43669
43670
43671
43672
43673
43674function measureToString(m) {
43675  if (typeof m === "string") {
43676    return "0px";
43677  }
43678  return Number.isInteger(m) ? `${m}px` : `${m.toFixed(2)}px`;
43679}
43680const converters = {
43681  anchorType(node, style) {
43682    const parent = node[$getSubformParent]();
43683    if (!parent || parent.layout && parent.layout !== "position") {
43684      return;
43685    }
43686    if (!("transform" in style)) {
43687      style.transform = "";
43688    }
43689    switch (node.anchorType) {
43690      case "bottomCenter":
43691        style.transform += "translate(-50%, -100%)";
43692        break;
43693      case "bottomLeft":
43694        style.transform += "translate(0,-100%)";
43695        break;
43696      case "bottomRight":
43697        style.transform += "translate(-100%,-100%)";
43698        break;
43699      case "middleCenter":
43700        style.transform += "translate(-50%,-50%)";
43701        break;
43702      case "middleLeft":
43703        style.transform += "translate(0,-50%)";
43704        break;
43705      case "middleRight":
43706        style.transform += "translate(-100%,-50%)";
43707        break;
43708      case "topCenter":
43709        style.transform += "translate(-50%,0)";
43710        break;
43711      case "topRight":
43712        style.transform += "translate(-100%,0)";
43713        break;
43714    }
43715  },
43716  dimensions(node, style) {
43717    const parent = node[$getSubformParent]();
43718    let width = node.w;
43719    const height = node.h;
43720    if (parent.layout?.includes("row")) {
43721      const extra = parent[$extra];
43722      const colSpan = node.colSpan;
43723      let w;
43724      if (colSpan === -1) {
43725        w = Math.sumPrecise(extra.columnWidths.slice(extra.currentColumn));
43726        extra.currentColumn = 0;
43727      } else {
43728        w = Math.sumPrecise(extra.columnWidths.slice(extra.currentColumn, extra.currentColumn + colSpan));
43729        extra.currentColumn = (extra.currentColumn + node.colSpan) % extra.columnWidths.length;
43730      }
43731      if (!isNaN(w)) {
43732        width = node.w = w;
43733      }
43734    }
43735    style.width = width !== "" ? measureToString(width) : "auto";
43736    style.height = height !== "" ? measureToString(height) : "auto";
43737  },
43738  position(node, style) {
43739    const parent = node[$getSubformParent]();
43740    if (parent?.layout && parent.layout !== "position") {
43741      return;
43742    }
43743    style.position = "absolute";
43744    style.left = measureToString(node.x);
43745    style.top = measureToString(node.y);
43746  },
43747  rotate(node, style) {
43748    if (node.rotate) {
43749      if (!("transform" in style)) {
43750        style.transform = "";
43751      }
43752      style.transform += `rotate(-${node.rotate}deg)`;
43753      style.transformOrigin = "top left";
43754    }
43755  },
43756  presence(node, style) {
43757    switch (node.presence) {
43758      case "invisible":
43759        style.visibility = "hidden";
43760        break;
43761      case "hidden":
43762      case "inactive":
43763        style.display = "none";
43764        break;
43765    }
43766  },
43767  hAlign(node, style) {
43768    if (node[$nodeName] === "para") {
43769      switch (node.hAlign) {
43770        case "justifyAll":
43771          style.textAlign = "justify-all";
43772          break;
43773        case "radix":
43774          style.textAlign = "left";
43775          break;
43776        default:
43777          style.textAlign = node.hAlign;
43778      }
43779    } else {
43780      switch (node.hAlign) {
43781        case "left":
43782          style.alignSelf = "start";
43783          break;
43784        case "center":
43785          style.alignSelf = "center";
43786          break;
43787        case "right":
43788          style.alignSelf = "end";
43789          break;
43790      }
43791    }
43792  },
43793  margin(node, style) {
43794    if (node.margin) {
43795      style.margin = node.margin[$toStyle]().margin;
43796    }
43797  }
43798};
43799function setMinMaxDimensions(node, style) {
43800  const parent = node[$getSubformParent]();
43801  if (parent.layout === "position") {
43802    if (node.minW > 0) {
43803      style.minWidth = measureToString(node.minW);
43804    }
43805    if (node.maxW > 0) {
43806      style.maxWidth = measureToString(node.maxW);
43807    }
43808    if (node.minH > 0) {
43809      style.minHeight = measureToString(node.minH);
43810    }
43811    if (node.maxH > 0) {
43812      style.maxHeight = measureToString(node.maxH);
43813    }
43814  }
43815}
43816function layoutText(text, xfaFont, margin, lineHeight, fontFinder, width) {
43817  const measure = new TextMeasure(xfaFont, margin, lineHeight, fontFinder);
43818  if (typeof text === "string") {
43819    measure.addString(text);
43820  } else {
43821    text[$pushGlyphs](measure);
43822  }
43823  return measure.compute(width);
43824}
43825function layoutNode(node, availableSpace) {
43826  let height = null;
43827  let width = null;
43828  let isBroken = false;
43829  if ((!node.w || !node.h) && node.value) {
43830    let marginH = 0;
43831    let marginV = 0;
43832    if (node.margin) {
43833      marginH = node.margin.leftInset + node.margin.rightInset;
43834      marginV = node.margin.topInset + node.margin.bottomInset;
43835    }
43836    let lineHeight = null;
43837    let margin = null;
43838    if (node.para) {
43839      margin = Object.create(null);
43840      lineHeight = node.para.lineHeight === "" ? null : node.para.lineHeight;
43841      margin.top = node.para.spaceAbove === "" ? 0 : node.para.spaceAbove;
43842      margin.bottom = node.para.spaceBelow === "" ? 0 : node.para.spaceBelow;
43843      margin.left = node.para.marginLeft === "" ? 0 : node.para.marginLeft;
43844      margin.right = node.para.marginRight === "" ? 0 : node.para.marginRight;
43845    }
43846    let font = node.font;
43847    if (!font) {
43848      const root = node[$getTemplateRoot]();
43849      let parent = node[$getParent]();
43850      while (parent && parent !== root) {
43851        if (parent.font) {
43852          font = parent.font;
43853          break;
43854        }
43855        parent = parent[$getParent]();
43856      }
43857    }
43858    const maxWidth = (node.w || availableSpace.width) - marginH;
43859    const fontFinder = node[$globalData].fontFinder;
43860    if (node.value.exData && node.value.exData[$content] && node.value.exData.contentType === "text/html") {
43861      const res = layoutText(node.value.exData[$content], font, margin, lineHeight, fontFinder, maxWidth);
43862      width = res.width;
43863      height = res.height;
43864      isBroken = res.isBroken;
43865    } else {
43866      const text = node.value[$text]();
43867      if (text) {
43868        const res = layoutText(text, font, margin, lineHeight, fontFinder, maxWidth);
43869        width = res.width;
43870        height = res.height;
43871        isBroken = res.isBroken;
43872      }
43873    }
43874    if (width !== null && !node.w) {
43875      width += marginH;
43876    }
43877    if (height !== null && !node.h) {
43878      height += marginV;
43879    }
43880  }
43881  return {
43882    w: width,
43883    h: height,
43884    isBroken
43885  };
43886}
43887function computeBbox(node, html, availableSpace) {
43888  let bbox;
43889  if (node.w !== "" && node.h !== "") {
43890    bbox = [node.x, node.y, node.w, node.h];
43891  } else {
43892    if (!availableSpace) {
43893      return null;
43894    }
43895    let width = node.w;
43896    if (width === "") {
43897      if (node.maxW === 0) {
43898        const parent = node[$getSubformParent]();
43899        width = parent.layout === "position" && parent.w !== "" ? 0 : node.minW;
43900      } else {
43901        width = Math.min(node.maxW, availableSpace.width);
43902      }
43903      html.attributes.style.width = measureToString(width);
43904    }
43905    let height = node.h;
43906    if (height === "") {
43907      if (node.maxH === 0) {
43908        const parent = node[$getSubformParent]();
43909        height = parent.layout === "position" && parent.h !== "" ? 0 : node.minH;
43910      } else {
43911        height = Math.min(node.maxH, availableSpace.height);
43912      }
43913      html.attributes.style.height = measureToString(height);
43914    }
43915    bbox = [node.x, node.y, width, height];
43916  }
43917  return bbox;
43918}
43919function fixDimensions(node) {
43920  const parent = node[$getSubformParent]();
43921  if (parent.layout?.includes("row")) {
43922    const extra = parent[$extra];
43923    const colSpan = node.colSpan;
43924    let width;
43925    if (colSpan === -1) {
43926      width = Math.sumPrecise(extra.columnWidths.slice(extra.currentColumn));
43927    } else {
43928      width = Math.sumPrecise(extra.columnWidths.slice(extra.currentColumn, extra.currentColumn + colSpan));
43929    }
43930    if (!isNaN(width)) {
43931      node.w = width;
43932    }
43933  }
43934  if (parent.layout && parent.layout !== "position") {
43935    node.x = node.y = 0;
43936  }
43937  if (node.layout === "table") {
43938    if (node.w === "" && Array.isArray(node.columnWidths)) {
43939      node.w = Math.sumPrecise(node.columnWidths);
43940    }
43941  }
43942}
43943function layoutClass(node) {
43944  switch (node.layout) {
43945    case "position":
43946      return "xfaPosition";
43947    case "lr-tb":
43948      return "xfaLrTb";
43949    case "rl-row":
43950      return "xfaRlRow";
43951    case "rl-tb":
43952      return "xfaRlTb";
43953    case "row":
43954      return "xfaRow";
43955    case "table":
43956      return "xfaTable";
43957    case "tb":
43958      return "xfaTb";
43959    default:
43960      return "xfaPosition";
43961  }
43962}
43963function toStyle(node, ...names) {
43964  const style = Object.create(null);
43965  for (const name of names) {
43966    const value = node[name];
43967    if (value === null) {
43968      continue;
43969    }
43970    if (Object.hasOwn(converters, name)) {
43971      converters[name](node, style);
43972      continue;
43973    }
43974    if (value instanceof XFAObject) {
43975      const newStyle = value[$toStyle]();
43976      if (newStyle) {
43977        Object.assign(style, newStyle);
43978      } else {
43979        warn(`(DEBUG) - XFA - style for ${name} not implemented yet`);
43980      }
43981    }
43982  }
43983  return style;
43984}
43985function createWrapper(node, html) {
43986  const {
43987    attributes
43988  } = html;
43989  const {
43990    style
43991  } = attributes;
43992  const wrapper = {
43993    name: "div",
43994    attributes: {
43995      class: ["xfaWrapper"],
43996      style: Object.create(null)
43997    },
43998    children: []
43999  };
44000  attributes.class.push("xfaWrapped");
44001  if (node.border) {
44002    const {
44003      widths,
44004      insets
44005    } = node.border[$extra];
44006    let width, height;
44007    let top = insets[0];
44008    let left = insets[3];
44009    const insetsH = insets[0] + insets[2];
44010    const insetsW = insets[1] + insets[3];
44011    switch (node.border.hand) {
44012      case "even":
44013        top -= widths[0] / 2;
44014        left -= widths[3] / 2;
44015        width = `calc(100% + ${(widths[1] + widths[3]) / 2 - insetsW}px)`;
44016        height = `calc(100% + ${(widths[0] + widths[2]) / 2 - insetsH}px)`;
44017        break;
44018      case "left":
44019        top -= widths[0];
44020        left -= widths[3];
44021        width = `calc(100% + ${widths[1] + widths[3] - insetsW}px)`;
44022        height = `calc(100% + ${widths[0] + widths[2] - insetsH}px)`;
44023        break;
44024      case "right":
44025        width = insetsW ? `calc(100% - ${insetsW}px)` : "100%";
44026        height = insetsH ? `calc(100% - ${insetsH}px)` : "100%";
44027        break;
44028    }
44029    const classNames = ["xfaBorder"];
44030    if (isPrintOnly(node.border)) {
44031      classNames.push("xfaPrintOnly");
44032    }
44033    const border = {
44034      name: "div",
44035      attributes: {
44036        class: classNames,
44037        style: {
44038          top: `${top}px`,
44039          left: `${left}px`,
44040          width,
44041          height
44042        }
44043      },
44044      children: []
44045    };
44046    for (const key of ["border", "borderWidth", "borderColor", "borderRadius", "borderStyle"]) {
44047      if (style[key] !== undefined) {
44048        border.attributes.style[key] = style[key];
44049        delete style[key];
44050      }
44051    }
44052    wrapper.children.push(border, html);
44053  } else {
44054    wrapper.children.push(html);
44055  }
44056  for (const key of ["background", "backgroundClip", "top", "left", "width", "height", "minWidth", "minHeight", "maxWidth", "maxHeight", "transform", "transformOrigin", "visibility"]) {
44057    if (style[key] !== undefined) {
44058      wrapper.attributes.style[key] = style[key];
44059      delete style[key];
44060    }
44061  }
44062  wrapper.attributes.style.position = style.position === "absolute" ? "absolute" : "relative";
44063  delete style.position;
44064  if (style.alignSelf) {
44065    wrapper.attributes.style.alignSelf = style.alignSelf;
44066    delete style.alignSelf;
44067  }
44068  return wrapper;
44069}
44070function fixTextIndent(styles) {
44071  const indent = getMeasurement(styles.textIndent, "0px");
44072  if (indent >= 0) {
44073    return;
44074  }
44075  const align = styles.textAlign === "right" ? "right" : "left";
44076  const name = "padding" + (align === "left" ? "Left" : "Right");
44077  const padding = getMeasurement(styles[name], "0px");
44078  styles[name] = `${padding - indent}px`;
44079}
44080function setAccess(node, classNames) {
44081  switch (node.access) {
44082    case "nonInteractive":
44083      classNames.push("xfaNonInteractive");
44084      break;
44085    case "readOnly":
44086      classNames.push("xfaReadOnly");
44087      break;
44088    case "protected":
44089      classNames.push("xfaDisabled");
44090      break;
44091  }
44092}
44093function isPrintOnly(node) {
44094  return node.relevant.length > 0 && !node.relevant[0].excluded && node.relevant[0].viewname === "print";
44095}
44096function getCurrentPara(node) {
44097  const stack = node[$getTemplateRoot]()[$extra].paraStack;
44098  return stack.length ? stack.at(-1) : null;
44099}
44100function setPara(node, nodeStyle, value) {
44101  if (value.attributes.class?.includes("xfaRich")) {
44102    if (nodeStyle) {
44103      if (node.h === "") {
44104        nodeStyle.height = "auto";
44105      }
44106      if (node.w === "") {
44107        nodeStyle.width = "auto";
44108      }
44109    }
44110    const para = getCurrentPara(node);
44111    if (para) {
44112      const valueStyle = value.attributes.style;
44113      valueStyle.display = "flex";
44114      valueStyle.flexDirection = "column";
44115      switch (para.vAlign) {
44116        case "top":
44117          valueStyle.justifyContent = "start";
44118          break;
44119        case "bottom":
44120          valueStyle.justifyContent = "end";
44121          break;
44122        case "middle":
44123          valueStyle.justifyContent = "center";
44124          break;
44125      }
44126      const paraStyle = para[$toStyle]();
44127      for (const [key, val] of Object.entries(paraStyle)) {
44128        if (!(key in valueStyle)) {
44129          valueStyle[key] = val;
44130        }
44131      }
44132    }
44133  }
44134}
44135function setFontFamily(xfaFont, node, fontFinder, style) {
44136  if (!fontFinder) {
44137    delete style.fontFamily;
44138    return;
44139  }
44140  const name = stripQuotes(xfaFont.typeface);
44141  style.fontFamily = 
44141`"${name}"`;
44142  const typeface = fontFinder.find(name);
44143  if (typeface) {
44144    const {
44145      fontFamily
44146    } = typeface.regular.cssFontInfo;
44147    if (fontFamily !== name) {
44148      style.fontFamily = `"${fontFamily}"`
vendor: 69,849 bytes, lines 44148-46378
44148;
44149    }
44150    const para = getCurrentPara(node);
44151    if (para && para.lineHeight !== "") {
44152      return;
44153    }
44154    if (style.lineHeight) {
44155      return;
44156    }
44157    const pdfFont = selectFont(xfaFont, typeface);
44158    if (pdfFont) {
44159      style.lineHeight = Math.max(1.2, pdfFont.lineHeight);
44160    }
44161  }
44162}
44163function fixURL(str) {
44164  const absoluteUrl = createValidAbsoluteUrl(str, null, {
44165    addDefaultProtocol: true,
44166    tryConvertEncoding: true
44167  });
44168  return absoluteUrl ? absoluteUrl.href : null;
44169}
44170
44171;// ./src/core/xfa/layout.js
44172
44173
44174
44175function createLine(node, children) {
44176  return {
44177    name: "div",
44178    attributes: {
44179      class: [node.layout === "lr-tb" ? "xfaLr" : "xfaRl"]
44180    },
44181    children
44182  };
44183}
44184function flushHTML(node) {
44185  if (!node[$extra]) {
44186    return null;
44187  }
44188  const attributes = node[$extra].attributes;
44189  const html = {
44190    name: "div",
44191    attributes,
44192    children: node[$extra].children
44193  };
44194  if (node[$extra].failingNode) {
44195    const htmlFromFailing = node[$extra].failingNode[$flushHTML]();
44196    if (htmlFromFailing) {
44197      if (node.layout.endsWith("-tb")) {
44198        html.children.push(createLine(node, [htmlFromFailing]));
44199      } else {
44200        html.children.push(htmlFromFailing);
44201      }
44202    }
44203  }
44204  if (html.children.length === 0) {
44205    return null;
44206  }
44207  return html;
44208}
44209function addHTML(node, html, bbox) {
44210  const extra = node[$extra];
44211  const availableSpace = extra.availableSpace;
44212  const [x, y, w, h] = bbox;
44213  switch (node.layout) {
44214    case "position":
44215      {
44216        extra.width = Math.max(extra.width, x + w);
44217        extra.height = Math.max(extra.height, y + h);
44218        extra.children.push(html);
44219        break;
44220      }
44221    case "lr-tb":
44222    case "rl-tb":
44223      if (!extra.line || extra.attempt === 1) {
44224        extra.line = createLine(node, []);
44225        extra.children.push(extra.line);
44226        extra.numberInLine = 0;
44227      }
44228      extra.numberInLine += 1;
44229      extra.line.children.push(html);
44230      if (extra.attempt === 0) {
44231        extra.currentWidth += w;
44232        extra.height = Math.max(extra.height, extra.prevHeight + h);
44233      } else {
44234        extra.currentWidth = w;
44235        extra.prevHeight = extra.height;
44236        extra.height += h;
44237        extra.attempt = 0;
44238      }
44239      extra.width = Math.max(extra.width, extra.currentWidth);
44240      break;
44241    case "rl-row":
44242    case "row":
44243      {
44244        extra.children.push(html);
44245        extra.width += w;
44246        extra.height = Math.max(extra.height, h);
44247        const height = measureToString(extra.height);
44248        for (const child of extra.children) {
44249          child.attributes.style.height = height;
44250        }
44251        break;
44252      }
44253    case "table":
44254      {
44255        extra.width = MathClamp(w, extra.width, availableSpace.width);
44256        extra.height += h;
44257        extra.children.push(html);
44258        break;
44259      }
44260    case "tb":
44261      {
44262        extra.width = MathClamp(w, extra.width, availableSpace.width);
44263        extra.height += h;
44264        extra.children.push(html);
44265        break;
44266      }
44267  }
44268}
44269function getAvailableSpace(node) {
44270  const availableSpace = node[$extra].availableSpace;
44271  const marginV = node.margin ? node.margin.topInset + node.margin.bottomInset : 0;
44272  const marginH = node.margin ? node.margin.leftInset + node.margin.rightInset : 0;
44273  switch (node.layout) {
44274    case "lr-tb":
44275    case "rl-tb":
44276      if (node[$extra].attempt === 0) {
44277        return {
44278          width: availableSpace.width - marginH - node[$extra].currentWidth,
44279          height: availableSpace.height - marginV - node[$extra].prevHeight
44280        };
44281      }
44282      return {
44283        width: availableSpace.width - marginH,
44284        height: availableSpace.height - marginV - node[$extra].height
44285      };
44286    case "rl-row":
44287    case "row":
44288      const width = Math.sumPrecise(node[$extra].columnWidths.slice(node[$extra].currentColumn));
44289      return {
44290        width,
44291        height: availableSpace.height - marginH
44292      };
44293    case "table":
44294    case "tb":
44295      return {
44296        width: availableSpace.width - marginH,
44297        height: availableSpace.height - marginV - node[$extra].height
44298      };
44299    case "position":
44300    default:
44301      return availableSpace;
44302  }
44303}
44304function getTransformedBBox(node) {
44305  let w = node.w === "" ? NaN : node.w;
44306  let h = node.h === "" ? NaN : node.h;
44307  let [centerX, centerY] = [0, 0];
44308  switch (node.anchorType || "") {
44309    case "bottomCenter":
44310      [centerX, centerY] = [w / 2, h];
44311      break;
44312    case "bottomLeft":
44313      [centerX, centerY] = [0, h];
44314      break;
44315    case "bottomRight":
44316      [centerX, centerY] = [w, h];
44317      break;
44318    case "middleCenter":
44319      [centerX, centerY] = [w / 2, h / 2];
44320      break;
44321    case "middleLeft":
44322      [centerX, centerY] = [0, h / 2];
44323      break;
44324    case "middleRight":
44325      [centerX, centerY] = [w, h / 2];
44326      break;
44327    case "topCenter":
44328      [centerX, centerY] = [w / 2, 0];
44329      break;
44330    case "topRight":
44331      [centerX, centerY] = [w, 0];
44332      break;
44333  }
44334  let x, y;
44335  switch (node.rotate || 0) {
44336    case 0:
44337      [x, y] = [-centerX, -centerY];
44338      break;
44339    case 90:
44340      [x, y] = [-centerY, centerX];
44341      [w, h] = [h, -w];
44342      break;
44343    case 180:
44344      [x, y] = [centerX, centerY];
44345      [w, h] = [-w, -h];
44346      break;
44347    case 270:
44348      [x, y] = [centerY, -centerX];
44349      [w, h] = [-h, w];
44350      break;
44351  }
44352  return [node.x + x + Math.min(0, w), node.y + y + Math.min(0, h), Math.abs(w), Math.abs(h)];
44353}
44354function checkDimensions(node, space) {
44355  if (node[$getTemplateRoot]()[$extra].firstUnsplittable === null) {
44356    return true;
44357  }
44358  if (node.w === 0 || node.h === 0) {
44359    return true;
44360  }
44361  const ERROR = 2;
44362  const parent = node[$getSubformParent]();
44363  const attempt = parent[$extra]?.attempt || 0;
44364  const [, y, w, h] = getTransformedBBox(node);
44365  switch (parent.layout) {
44366    case "lr-tb":
44367    case "rl-tb":
44368      if (attempt === 0) {
44369        if (!node[$getTemplateRoot]()[$extra].noLayoutFailure) {
44370          if (node.h !== "" && Math.round(h - space.height) > ERROR) {
44371            return false;
44372          }
44373          if (node.w !== "") {
44374            if (Math.round(w - space.width) <= ERROR) {
44375              return true;
44376            }
44377            if (parent[$extra].numberInLine === 0) {
44378              return space.height > ERROR;
44379            }
44380            return false;
44381          }
44382          return space.width > ERROR;
44383        }
44384        if (node.w !== "") {
44385          return Math.round(w - space.width) <= ERROR;
44386        }
44387        return space.width > ERROR;
44388      }
44389      if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
44390        return true;
44391      }
44392      if (node.h !== "" && Math.round(h - space.height) > ERROR) {
44393        return false;
44394      }
44395      if (node.w === "" || Math.round(w - space.width) <= ERROR) {
44396        return space.height > ERROR;
44397      }
44398      if (parent[$isThereMoreWidth]()) {
44399        return false;
44400      }
44401      return space.height > ERROR;
44402    case "table":
44403    case "tb":
44404      if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
44405        return true;
44406      }
44407      if (node.h !== "" && !node[$isSplittable]()) {
44408        return Math.round(h - space.height) <= ERROR;
44409      }
44410      if (node.w === "" || Math.round(w - space.width) <= ERROR) {
44411        return space.height > ERROR;
44412      }
44413      if (parent[$isThereMoreWidth]()) {
44414        return false;
44415      }
44416      return space.height > ERROR;
44417    case "position":
44418      if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
44419        return true;
44420      }
44421      if (node.h === "" || Math.round(h + y - space.height) <= ERROR) {
44422        return true;
44423      }
44424      const area = node[$getTemplateRoot]()[$extra].currentContentArea;
44425      return h + y > area.h;
44426    case "rl-row":
44427    case "row":
44428      if (node[$getTemplateRoot]()[$extra].noLayoutFailure) {
44429        return true;
44430      }
44431      if (node.h !== "") {
44432        return Math.round(h - space.height) <= ERROR;
44433      }
44434      return true;
44435    default:
44436      return true;
44437  }
44438}
44439
44440;// ./src/core/xfa/template.js
44441
44442
44443
44444
44445
44446
44447
44448
44449
44450
44451const TEMPLATE_NS_ID = NamespaceIds.template.id;
44452const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
44453const MAX_EMPTY_PAGES = 3;
44454const DEFAULT_TAB_INDEX = 5000;
44455const HEADING_PATTERN = /^H(\d+)$/;
44456const MIMES = new Set(["image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/png", "image/apng", "image/x-png", "image/bmp", "image/x-ms-bmp", "image/tiff", "image/tif", "application/octet-stream"]);
44457const IMAGES_HEADERS = [[[0x42, 0x4d], "image/bmp"], [[0xff, 0xd8, 0xff], "image/jpeg"], [[0x49, 0x49, 0x2a, 0x00], "image/tiff"], [[0x4d, 0x4d, 0x00, 0x2a], "image/tiff"], [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61], "image/gif"], [[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], "image/png"]];
44458function getBorderDims(node) {
44459  if (!node || !node.border) {
44460    return {
44461      w: 0,
44462      h: 0
44463    };
44464  }
44465  const borderExtra = node.border[$getExtra]();
44466  if (!borderExtra) {
44467    return {
44468      w: 0,
44469      h: 0
44470    };
44471  }
44472  return {
44473    w: borderExtra.widths[0] + borderExtra.widths[2] + borderExtra.insets[0] + borderExtra.insets[2],
44474    h: borderExtra.widths[1] + borderExtra.widths[3] + borderExtra.insets[1] + borderExtra.insets[3]
44475  };
44476}
44477function hasMargin(node) {
44478  return node.margin && (node.margin.topInset || node.margin.rightInset || node.margin.bottomInset || node.margin.leftInset);
44479}
44480function _setValue(templateNode, value) {
44481  if (!templateNode.value) {
44482    const nodeValue = new Value({});
44483    templateNode[$appendChild](nodeValue);
44484    templateNode.value = nodeValue;
44485  }
44486  templateNode.value[$setValue](value);
44487}
44488function* getContainedChildren(node) {
44489  for (const child of node[$getChildren]()) {
44490    if (child instanceof SubformSet) {
44491      yield* child[$getContainedChildren]();
44492      continue;
44493    }
44494    yield child;
44495  }
44496}
44497function isRequired(node) {
44498  return node.validate?.nullTest === "error";
44499}
44500function setTabIndex(node) {
44501  while (node) {
44502    if (!node.traversal) {
44503      node[$tabIndex] = node[$getParent]()[$tabIndex];
44504      return;
44505    }
44506    if (node[$tabIndex]) {
44507      return;
44508    }
44509    let next = null;
44510    for (const child of node.traversal[$getChildren]()) {
44511      if (child.operation === "next") {
44512        next = child;
44513        break;
44514      }
44515    }
44516    if (!next || !next.ref) {
44517      node[$tabIndex] = node[$getParent]()[$tabIndex];
44518      return;
44519    }
44520    const root = node[$getTemplateRoot]();
44521    node[$tabIndex] = ++root[$tabIndex];
44522    const ref = root[$searchNode](next.ref, node);
44523    if (!ref) {
44524      return;
44525    }
44526    node = ref[0];
44527  }
44528}
44529function applyAssist(obj, attributes) {
44530  const assist = obj.assist;
44531  if (assist) {
44532    const assistTitle = assist[$toHTML]();
44533    if (assistTitle) {
44534      attributes.title = assistTitle;
44535    }
44536    const role = assist.role;
44537    const match = role.match(HEADING_PATTERN);
44538    if (match) {
44539      const ariaRole = "heading";
44540      const ariaLevel = match[1];
44541      attributes.role = ariaRole;
44542      attributes["aria-level"] = ariaLevel;
44543    }
44544  }
44545  if (obj.layout === "table") {
44546    attributes.role = "table";
44547  } else if (obj.layout === "row") {
44548    attributes.role = "row";
44549  } else {
44550    const parent = obj[$getParent]();
44551    if (parent.layout === "row") {
44552      attributes.role = parent.assist?.role === "TH" ? "columnheader" : "cell";
44553    }
44554  }
44555}
44556function ariaLabel(obj) {
44557  if (!obj.assist) {
44558    return null;
44559  }
44560  const assist = obj.assist;
44561  if (assist.speak && assist.speak[$content] !== "") {
44562    return assist.speak[$content];
44563  }
44564  if (assist.toolTip) {
44565    return assist.toolTip[$content];
44566  }
44567  return null;
44568}
44569function valueToHtml(value) {
44570  return HTMLResult.success({
44571    name: "div",
44572    attributes: {
44573      class: ["xfaRich"],
44574      style: Object.create(null)
44575    },
44576    children: [{
44577      name: "span",
44578      attributes: {
44579        style: Object.create(null)
44580      },
44581      value
44582    }]
44583  });
44584}
44585function setFirstUnsplittable(node) {
44586  const root = node[$getTemplateRoot]();
44587  if (root[$extra].firstUnsplittable === null) {
44588    root[$extra].firstUnsplittable = node;
44589    root[$extra].noLayoutFailure = true;
44590  }
44591}
44592function unsetFirstUnsplittable(node) {
44593  const root = node[$getTemplateRoot]();
44594  if (root[$extra].firstUnsplittable === node) {
44595    root[$extra].noLayoutFailure = false;
44596  }
44597}
44598function handleBreak(node) {
44599  if (node[$extra]) {
44600    return false;
44601  }
44602  node[$extra] = Object.create(null);
44603  if (node.targetType === "auto") {
44604    return false;
44605  }
44606  const root = node[$getTemplateRoot]();
44607  let target = null;
44608  if (node.target) {
44609    target = root[$searchNode](node.target, node[$getParent]());
44610    if (!target) {
44611      return false;
44612    }
44613    target = target[0];
44614  }
44615  const {
44616    currentPageArea,
44617    currentContentArea
44618  } = root[$extra];
44619  if (node.targetType === "pageArea") {
44620    if (!(target instanceof PageArea)) {
44621      target = null;
44622    }
44623    if (node.startNew) {
44624      node[$extra].target = target || currentPageArea;
44625      return true;
44626    } else if (target && target !== currentPageArea) {
44627      node[$extra].target = target;
44628      return true;
44629    }
44630    return false;
44631  }
44632  if (!(target instanceof ContentArea)) {
44633    target = null;
44634  }
44635  const pageArea = target && target[$getParent]();
44636  let index;
44637  let nextPageArea = pageArea;
44638  if (node.startNew) {
44639    if (target) {
44640      const contentAreas = pageArea.contentArea.children;
44641      const indexForCurrent = contentAreas.indexOf(currentContentArea);
44642      const indexForTarget = contentAreas.indexOf(target);
44643      if (indexForCurrent !== -1 && indexForCurrent < indexForTarget) {
44644        nextPageArea = null;
44645      }
44646      index = indexForTarget - 1;
44647    } else {
44648      index = currentPageArea.contentArea.children.indexOf(currentContentArea);
44649    }
44650  } else if (target && target !== currentContentArea) {
44651    const contentAreas = pageArea.contentArea.children;
44652    index = contentAreas.indexOf(target) - 1;
44653    nextPageArea = pageArea === currentPageArea ? null : pageArea;
44654  } else {
44655    return false;
44656  }
44657  node[$extra].target = nextPageArea;
44658  node[$extra].index = index;
44659  return true;
44660}
44661function handleOverflow(node, extraNode, space) {
44662  const root = node[$getTemplateRoot]();
44663  const saved = root[$extra].noLayoutFailure;
44664  const savedMethod = extraNode[$getSubformParent];
44665  extraNode[$getSubformParent] = () => node;
44666  root[$extra].noLayoutFailure = true;
44667  const res = extraNode[$toHTML](space);
44668  node[$addHTML](res.html, res.bbox);
44669  root[$extra].noLayoutFailure = saved;
44670  extraNode[$getSubformParent] = savedMethod;
44671}
44672class AppearanceFilter extends StringObject {
44673  constructor(attributes) {
44674    super(TEMPLATE_NS_ID, "appearanceFilter");
44675    this.id = attributes.id || "";
44676    this.type = getStringOption(attributes.type, ["optional", "required"]);
44677    this.use = attributes.use || "";
44678    this.usehref = attributes.usehref || "";
44679  }
44680}
44681class Arc extends XFAObject {
44682  constructor(attributes) {
44683    super(TEMPLATE_NS_ID, "arc", true);
44684    this.circular = getInteger({
44685      data: attributes.circular,
44686      defaultValue: 0,
44687      validate: x => x === 1
44688    });
44689    this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
44690    this.id = attributes.id || "";
44691    this.startAngle = getFloat({
44692      data: attributes.startAngle,
44693      defaultValue: 0,
44694      validate: x => true
44695    });
44696    this.sweepAngle = getFloat({
44697      data: attributes.sweepAngle,
44698      defaultValue: 360,
44699      validate: x => true
44700    });
44701    this.use = attributes.use || "";
44702    this.usehref = attributes.usehref || "";
44703    this.edge = null;
44704    this.fill = null;
44705  }
44706  [$toHTML]() {
44707    const edge = this.edge || new Edge({});
44708    const edgeStyle = edge[$toStyle]();
44709    const style = Object.create(null);
44710    if (this.fill?.presence === "visible") {
44711      Object.assign(style, this.fill[$toStyle]());
44712    } else {
44713      style.fill = "transparent";
44714    }
44715    style.strokeWidth = measureToString(edge.presence === "visible" ? edge.thickness : 0);
44716    style.stroke = edgeStyle.color;
44717    let arc;
44718    const attributes = {
44719      xmlns: SVG_NS,
44720      style: {
44721        width: "100%",
44722        height: "100%",
44723        overflow: "visible"
44724      }
44725    };
44726    if (this.sweepAngle === 360) {
44727      arc = {
44728        name: "ellipse",
44729        attributes: {
44730          xmlns: SVG_NS,
44731          cx: "50%",
44732          cy: "50%",
44733          rx: "50%",
44734          ry: "50%",
44735          style
44736        }
44737      };
44738    } else {
44739      const startAngle = this.startAngle * Math.PI / 180;
44740      const sweepAngle = this.sweepAngle * Math.PI / 180;
44741      const largeArc = this.sweepAngle > 180 ? 1 : 0;
44742      const [x1, y1, x2, y2] = [50 * (1 + Math.cos(startAngle)), 50 * (1 - Math.sin(startAngle)), 50 * (1 + Math.cos(startAngle + sweepAngle)), 50 * (1 - Math.sin(startAngle + sweepAngle))];
44743      arc = {
44744        name: "path",
44745        attributes: {
44746          xmlns: SVG_NS,
44747          d: `M ${x1} ${y1} A 50 50 0 ${largeArc} 0 ${x2} ${y2}`,
44748          vectorEffect: "non-scaling-stroke",
44749          style
44750        }
44751      };
44752      Object.assign(attributes, {
44753        viewBox: "0 0 100 100",
44754        preserveAspectRatio: "none"
44755      });
44756    }
44757    const svg = {
44758      name: "svg",
44759      children: [arc],
44760      attributes
44761    };
44762    const parent = this[$getParent]()[$getParent]();
44763    if (hasMargin(parent)) {
44764      return HTMLResult.success({
44765        name: "div",
44766        attributes: {
44767          style: {
44768            display: "inline",
44769            width: "100%",
44770            height: "100%"
44771          }
44772        },
44773        children: [svg]
44774      });
44775    }
44776    svg.attributes.style.position = "absolute";
44777    return HTMLResult.success(svg);
44778  }
44779}
44780class Area extends XFAObject {
44781  constructor(attributes) {
44782    super(TEMPLATE_NS_ID, "area", true);
44783    this.colSpan = getInteger({
44784      data: attributes.colSpan,
44785      defaultValue: 1,
44786      validate: n => n >= 1 || n === -1
44787    });
44788    this.id = attributes.id || "";
44789    this.name = attributes.name || "";
44790    this.relevant = getRelevant(attributes.relevant);
44791    this.use = attributes.use || "";
44792    this.usehref = attributes.usehref || "";
44793    this.x = getMeasurement(attributes.x, "0pt");
44794    this.y = getMeasurement(attributes.y, "0pt");
44795    this.desc = null;
44796    this.extras = null;
44797    this.area = new XFAObjectArray();
44798    this.draw = new XFAObjectArray();
44799    this.exObject = new XFAObjectArray();
44800    this.exclGroup = new XFAObjectArray();
44801    this.field = new XFAObjectArray();
44802    this.subform = new XFAObjectArray();
44803    this.subformSet = new XFAObjectArray();
44804  }
44805  *[$getContainedChildren]() {
44806    yield* getContainedChildren(this);
44807  }
44808  [$isTransparent]() {
44809    return true;
44810  }
44811  [$isBindable]() {
44812    return true;
44813  }
44814  [$addHTML](html, bbox) {
44815    const [x, y, w, h] = bbox;
44816    this[$extra].width = Math.max(this[$extra].width, x + w);
44817    this[$extra].height = Math.max(this[$extra].height, y + h);
44818    this[$extra].children.push(html);
44819  }
44820  [$getAvailableSpace]() {
44821    return this[$extra].availableSpace;
44822  }
44823  [$toHTML](availableSpace) {
44824    const style = toStyle(this, "position");
44825    const attributes = {
44826      style,
44827      id: this[$uid],
44828      class: ["xfaArea"]
44829    };
44830    if (isPrintOnly(this)) {
44831      attributes.class.push("xfaPrintOnly");
44832    }
44833    if (this.name) {
44834      attributes.xfaName = this.name;
44835    }
44836    const children = [];
44837    this[$extra] = {
44838      children,
44839      width: 0,
44840      height: 0,
44841      availableSpace
44842    };
44843    const result = this[$childrenToHTML]({
44844      filter: new Set(["area", "draw", "field", "exclGroup", "subform", "subformSet"]),
44845      include: true
44846    });
44847    if (!result.success) {
44848      if (result.isBreak()) {
44849        return result;
44850      }
44851      delete this[$extra];
44852      return HTMLResult.FAILURE;
44853    }
44854    style.width = measureToString(this[$extra].width);
44855    style.height = measureToString(this[$extra].height);
44856    const html = {
44857      name: "div",
44858      attributes,
44859      children
44860    };
44861    const bbox = [this.x, this.y, this[$extra].width, this[$extra].height];
44862    delete this[$extra];
44863    return HTMLResult.success(html, bbox);
44864  }
44865}
44866class Assist extends XFAObject {
44867  constructor(attributes) {
44868    super(TEMPLATE_NS_ID, "assist", true);
44869    this.id = attributes.id || "";
44870    this.role = attributes.role || "";
44871    this.use = attributes.use || "";
44872    this.usehref = attributes.usehref || "";
44873    this.speak = null;
44874    this.toolTip = null;
44875  }
44876  [$toHTML]() {
44877    return this.toolTip?.[$content] || null;
44878  }
44879}
44880class Barcode extends XFAObject {
44881  constructor(attributes) {
44882    super(TEMPLATE_NS_ID, "barcode", true);
44883    this.charEncoding = getKeyword({
44884      data: attributes.charEncoding ? attributes.charEncoding.toLowerCase() : "",
44885      defaultValue: "",
44886      validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
44887    });
44888    this.checksum = getStringOption(attributes.checksum, ["none", "1mod10", "1mod10_1mod11", "2mod10", "auto"]);
44889    this.dataColumnCount = getInteger({
44890      data: attributes.dataColumnCount,
44891      defaultValue: -1,
44892      validate: x => x >= 0
44893    });
44894    this.dataLength = getInteger({
44895      data: attributes.dataLength,
44896      defaultValue: -1,
44897      validate: x => x >= 0
44898    });
44899    this.dataPrep = getStringOption(attributes.dataPrep, ["none", "flateCompress"]);
44900    this.dataRowCount = getInteger({
44901      data: attributes.dataRowCount,
44902      defaultValue: -1,
44903      validate: x => x >= 0
44904    });
44905    this.endChar = attributes.endChar || "";
44906    this.errorCorrectionLevel = getInteger({
44907      data: attributes.errorCorrectionLevel,
44908      defaultValue: -1,
44909      validate: x => x >= 0 && x <= 8
44910    });
44911    this.id = attributes.id || "";
44912    this.moduleHeight = getMeasurement(attributes.moduleHeight, "5mm");
44913    this.moduleWidth = getMeasurement(attributes.moduleWidth, "0.25mm");
44914    this.printCheckDigit = getInteger({
44915      data: attributes.printCheckDigit,
44916      defaultValue: 0,
44917      validate: x => x === 1
44918    });
44919    this.rowColumnRatio = getRatio(attributes.rowColumnRatio);
44920    this.startChar = attributes.startChar || "";
44921    this.textLocation = getStringOption(attributes.textLocation, ["below", "above", "aboveEmbedded", "belowEmbedded", "none"]);
44922    this.truncate = getInteger({
44923      data: attributes.truncate,
44924      defaultValue: 0,
44925      validate: x => x === 1
44926    });
44927    this.type = getStringOption(attributes.type ? attributes.type.toLowerCase() : "", ["aztec", "codabar", "code2of5industrial", "code2of5interleaved", "code2of5matrix", "code2of5standard", "code3of9", "code3of9extended", "code11", "code49", "code93", "code128", "code128a", "code128b", "code128c", "code128sscc", "datamatrix", "ean8", "ean8add2", "ean8add5", "ean13", "ean13add2", "ean13add5", "ean13pwcd", "fim", "logmars", "maxicode", "msi", "pdf417", "pdf417macro", "plessey", "postauscust2", "postauscust3", "postausreplypaid", "postausstandard", "postukrm4scc", "postusdpbc", "postusimb", "postusstandard", "postus5zip", "qrcode", "rfid", "rss14", "rss14expanded", "rss14limited", "rss14stacked", "rss14stackedomni", "rss14truncated", "telepen", "ucc128", "ucc128random", "ucc128sscc", "upca", "upcaadd2", "upcaadd5", "upcapwcd", "upce", "upceadd2", "upceadd5", "upcean2", "upcean5", "upsmaxicode"]);
44928    this.upsMode = getStringOption(attributes.upsMode, ["usCarrier", "internationalCarrier", "secureSymbol", "standardSymbol"]);
44929    this.use = attributes.use || "";
44930    this.usehref = attributes.usehref || "";
44931    this.wideNarrowRatio = getRatio(attributes.wideNarrowRatio);
44932    this.encrypt = null;
44933    this.extras = null;
44934  }
44935}
44936class Bind extends XFAObject {
44937  constructor(attributes) {
44938    super(TEMPLATE_NS_ID, "bind", true);
44939    this.match = getStringOption(attributes.match, ["once", "dataRef", "global", "none"]);
44940    this.ref = attributes.ref || "";
44941    this.picture = null;
44942  }
44943}
44944class BindItems extends XFAObject {
44945  constructor(attributes) {
44946    super(TEMPLATE_NS_ID, "bindItems");
44947    this.connection = attributes.connection || "";
44948    this.labelRef = attributes.labelRef || "";
44949    this.ref = attributes.ref || "";
44950    this.valueRef = attributes.valueRef || "";
44951  }
44952}
44953class Bookend extends XFAObject {
44954  constructor(attributes) {
44955    super(TEMPLATE_NS_ID, "bookend");
44956    this.id = attributes.id || "";
44957    this.leader = attributes.leader || "";
44958    this.trailer = attributes.trailer || "";
44959    this.use = attributes.use || "";
44960    this.usehref = attributes.usehref || "";
44961  }
44962}
44963class BooleanElement extends Option01 {
44964  constructor(attributes) {
44965    super(TEMPLATE_NS_ID, "boolean");
44966    this.id = attributes.id || "";
44967    this.name = attributes.name || "";
44968    this.use = attributes.use || "";
44969    this.usehref = attributes.usehref || "";
44970  }
44971  [$toHTML](availableSpace) {
44972    return valueToHtml(this[$content] === 1 ? "1" : "0");
44973  }
44974}
44975class Border extends XFAObject {
44976  constructor(attributes) {
44977    super(TEMPLATE_NS_ID, "border", true);
44978    this.break = getStringOption(attributes.break, ["close", "open"]);
44979    this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
44980    this.id = attributes.id || "";
44981    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
44982    this.relevant = getRelevant(attributes.relevant);
44983    this.use = attributes.use || "";
44984    this.usehref = attributes.usehref || "";
44985    this.corner = new XFAObjectArray(4);
44986    this.edge = new XFAObjectArray(4);
44987    this.extras = null;
44988    this.fill = null;
44989    this.margin = null;
44990  }
44991  [$getExtra]() {
44992    if (!this[$extra]) {
44993      const edges = this.edge.children.slice();
44994      if (edges.length < 4) {
44995        const defaultEdge = edges.at(-1) || new Edge({});
44996        for (let i = edges.length; i < 4; i++) {
44997          edges.push(defaultEdge);
44998        }
44999      }
45000      const widths = edges.map(edge => edge.thickness);
45001      const insets = [0, 0, 0, 0];
45002      if (this.margin) {
45003        insets[0] = this.margin.topInset;
45004        insets[1] = this.margin.rightInset;
45005        insets[2] = this.margin.bottomInset;
45006        insets[3] = this.margin.leftInset;
45007      }
45008      this[$extra] = {
45009        widths,
45010        insets,
45011        edges
45012      };
45013    }
45014    return this[$extra];
45015  }
45016  [$toStyle]() {
45017    const {
45018      edges
45019    } = this[$getExtra]();
45020    const edgeStyles = edges.map(node => {
45021      const style = node[$toStyle]();
45022      style.color ||= "#000000";
45023      return style;
45024    });
45025    const style = Object.create(null);
45026    if (this.margin) {
45027      Object.assign(style, this.margin[$toStyle]());
45028    }
45029    if (this.fill?.presence === "visible") {
45030      Object.assign(style, this.fill[$toStyle]());
45031    }
45032    if (this.corner.children.some(node => node.radius !== 0)) {
45033      const cornerStyles = this.corner.children.map(node => node[$toStyle]());
45034      if (cornerStyles.length === 2 || cornerStyles.length === 3) {
45035        const last = cornerStyles.at(-1);
45036        for (let i = cornerStyles.length; i < 4; i++) {
45037          cornerStyles.push(last);
45038        }
45039      }
45040      style.borderRadius = cornerStyles.map(s => s.radius).join(" ");
45041    }
45042    switch (this.presence) {
45043      case "invisible":
45044      case "hidden":
45045        style.borderStyle = "";
45046        break;
45047      case "inactive":
45048        style.borderStyle = "none";
45049        break;
45050      default:
45051        style.borderStyle = edgeStyles.map(s => s.style).join(" ");
45052        break;
45053    }
45054    style.borderWidth = edgeStyles.map(s => s.width).join(" ");
45055    style.borderColor = edgeStyles.map(s => s.color).join(" ");
45056    return style;
45057  }
45058}
45059class Break extends XFAObject {
45060  constructor(attributes) {
45061    super(TEMPLATE_NS_ID, "break", true);
45062    this.after = getStringOption(attributes.after, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
45063    this.afterTarget = attributes.afterTarget || "";
45064    this.before = getStringOption(attributes.before, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
45065    this.beforeTarget = attributes.beforeTarget || "";
45066    this.bookendLeader = attributes.bookendLeader || "";
45067    this.bookendTrailer = attributes.bookendTrailer || "";
45068    this.id = attributes.id || "";
45069    this.overflowLeader = attributes.overflowLeader || "";
45070    this.overflowTarget = attributes.overflowTarget || "";
45071    this.overflowTrailer = attributes.overflowTrailer || "";
45072    this.startNew = getInteger({
45073      data: attributes.startNew,
45074      defaultValue: 0,
45075      validate: x => x === 1
45076    });
45077    this.use = attributes.use || "";
45078    this.usehref = attributes.usehref || "";
45079    this.extras = null;
45080  }
45081}
45082class BreakAfter extends XFAObject {
45083  constructor(attributes) {
45084    super(TEMPLATE_NS_ID, "breakAfter", true);
45085    this.id = attributes.id || "";
45086    this.leader = attributes.leader || "";
45087    this.startNew = getInteger({
45088      data: attributes.startNew,
45089      defaultValue: 0,
45090      validate: x => x === 1
45091    });
45092    this.target = attributes.target || "";
45093    this.targetType = getStringOption(attributes.targetType, ["auto", "contentArea", "pageArea"]);
45094    this.trailer = attributes.trailer || "";
45095    this.use = attributes.use || "";
45096    this.usehref = attributes.usehref || "";
45097    this.script = null;
45098  }
45099}
45100class BreakBefore extends XFAObject {
45101  constructor(attributes) {
45102    super(TEMPLATE_NS_ID, "breakBefore", true);
45103    this.id = attributes.id || "";
45104    this.leader = attributes.leader || "";
45105    this.startNew = getInteger({
45106      data: attributes.startNew,
45107      defaultValue: 0,
45108      validate: x => x === 1
45109    });
45110    this.target = attributes.target || "";
45111    this.targetType = getStringOption(attributes.targetType, ["auto", "contentArea", "pageArea"]);
45112    this.trailer = attributes.trailer || "";
45113    this.use = attributes.use || "";
45114    this.usehref = attributes.usehref || "";
45115    this.script = null;
45116  }
45117  [$toHTML](availableSpace) {
45118    this[$extra] = {};
45119    return HTMLResult.FAILURE;
45120  }
45121}
45122class Button extends XFAObject {
45123  constructor(attributes) {
45124    super(TEMPLATE_NS_ID, "button", true);
45125    this.highlight = getStringOption(attributes.highlight, ["inverted", "none", "outline", "push"]);
45126    this.id = attributes.id || "";
45127    this.use = attributes.use || "";
45128    this.usehref = attributes.usehref || "";
45129    this.extras = null;
45130  }
45131  [$toHTML](availableSpace) {
45132    const parent = this[$getParent]();
45133    const grandpa = parent[$getParent]();
45134    const htmlButton = {
45135      name: "button",
45136      attributes: {
45137        id: this[$uid],
45138        class: ["xfaButton"],
45139        style: {}
45140      },
45141      children: []
45142    };
45143    for (const event of grandpa.event.children) {
45144      if (event.activity !== "click" || !event.script) {
45145        continue;
45146      }
45147      const jsURL = recoverJsURL(event.script[$content]);
45148      if (!jsURL) {
45149        continue;
45150      }
45151      const href = fixURL(jsURL.url);
45152      if (!href) {
45153        continue;
45154      }
45155      htmlButton.children.push({
45156        name: "a",
45157        attributes: {
45158          id: "link" + this[$uid],
45159          href,
45160          newWindow: jsURL.newWindow,
45161          class: ["xfaLink"],
45162          style: {}
45163        },
45164        children: []
45165      });
45166    }
45167    return HTMLResult.success(htmlButton);
45168  }
45169}
45170class Calculate extends XFAObject {
45171  constructor(attributes) {
45172    super(TEMPLATE_NS_ID, "calculate", true);
45173    this.id = attributes.id || "";
45174    this.override = getStringOption(attributes.override, ["disabled", "error", "ignore", "warning"]);
45175    this.use = attributes.use || "";
45176    this.usehref = attributes.usehref || "";
45177    this.extras = null;
45178    this.message = null;
45179    this.script = null;
45180  }
45181}
45182class Caption extends XFAObject {
45183  constructor(attributes) {
45184    super(TEMPLATE_NS_ID, "caption", true);
45185    this.id = attributes.id || "";
45186    this.placement = getStringOption(attributes.placement, ["left", "bottom", "inline", "right", "top"]);
45187    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
45188    this.reserve = Math.ceil(getMeasurement(attributes.reserve));
45189    this.use = attributes.use || "";
45190    this.usehref = attributes.usehref || "";
45191    this.extras = null;
45192    this.font = null;
45193    this.margin = null;
45194    this.para = null;
45195    this.value = null;
45196  }
45197  [$setValue](value) {
45198    _setValue(this, value);
45199  }
45200  [$getExtra](availableSpace) {
45201    if (!this[$extra]) {
45202      let {
45203        width,
45204        height
45205      } = availableSpace;
45206      switch (this.placement) {
45207        case "left":
45208        case "right":
45209        case "inline":
45210          width = this.reserve <= 0 ? width : this.reserve;
45211          break;
45212        case "top":
45213        case "bottom":
45214          height = this.reserve <= 0 ? height : this.reserve;
45215          break;
45216      }
45217      this[$extra] = layoutNode(this, {
45218        width,
45219        height
45220      });
45221    }
45222    return this[$extra];
45223  }
45224  [$toHTML](availableSpace) {
45225    if (!this.value) {
45226      return HTMLResult.EMPTY;
45227    }
45228    this[$pushPara]();
45229    const value = this.value[$toHTML](availableSpace).html;
45230    if (!value) {
45231      this[$popPara]();
45232      return HTMLResult.EMPTY;
45233    }
45234    const savedReserve = this.reserve;
45235    if (this.reserve <= 0) {
45236      const {
45237        w,
45238        h
45239      } = this[$getExtra](availableSpace);
45240      switch (this.placement) {
45241        case "left":
45242        case "right":
45243        case "inline":
45244          this.reserve = w;
45245          break;
45246        case "top":
45247        case "bottom":
45248          this.reserve = h;
45249          break;
45250      }
45251    }
45252    const children = [];
45253    if (typeof value === "string") {
45254      children.push({
45255        name: "#text",
45256        value
45257      });
45258    } else {
45259      children.push(value);
45260    }
45261    const style = toStyle(this, "font", "margin", "visibility");
45262    switch (this.placement) {
45263      case "left":
45264      case "right":
45265        if (this.reserve > 0) {
45266          style.width = measureToString(this.reserve);
45267        }
45268        break;
45269      case "top":
45270      case "bottom":
45271        if (this.reserve > 0) {
45272          style.height = measureToString(this.reserve);
45273        }
45274        break;
45275    }
45276    setPara(this, null, value);
45277    this[$popPara]();
45278    this.reserve = savedReserve;
45279    return HTMLResult.success({
45280      name: "div",
45281      attributes: {
45282        style,
45283        class: ["xfaCaption"]
45284      },
45285      children
45286    });
45287  }
45288}
45289class Certificate extends StringObject {
45290  constructor(attributes) {
45291    super(TEMPLATE_NS_ID, "certificate");
45292    this.id = attributes.id || "";
45293    this.name = attributes.name || "";
45294    this.use = attributes.use || "";
45295    this.usehref = attributes.usehref || "";
45296  }
45297}
45298class Certificates extends XFAObject {
45299  constructor(attributes) {
45300    super(TEMPLATE_NS_ID, "certificates", true);
45301    this.credentialServerPolicy = getStringOption(attributes.credentialServerPolicy, ["optional", "required"]);
45302    this.id = attributes.id || "";
45303    this.url = attributes.url || "";
45304    this.urlPolicy = attributes.urlPolicy || "";
45305    this.use = attributes.use || "";
45306    this.usehref = attributes.usehref || "";
45307    this.encryption = null;
45308    this.issuers = null;
45309    this.keyUsage = null;
45310    this.oids = null;
45311    this.signing = null;
45312    this.subjectDNs = null;
45313  }
45314}
45315class CheckButton extends XFAObject {
45316  constructor(attributes) {
45317    super(TEMPLATE_NS_ID, "checkButton", true);
45318    this.id = attributes.id || "";
45319    this.mark = getStringOption(attributes.mark, ["default", "check", "circle", "cross", "diamond", "square", "star"]);
45320    this.shape = getStringOption(attributes.shape, ["square", "round"]);
45321    this.size = getMeasurement(attributes.size, "10pt");
45322    this.use = attributes.use || "";
45323    this.usehref = attributes.usehref || "";
45324    this.border = null;
45325    this.extras = null;
45326    this.margin = null;
45327  }
45328  [$toHTML](availableSpace) {
45329    const style = toStyle(this, "margin");
45330    const size = measureToString(this.size);
45331    style.width = style.height = size;
45332    let type;
45333    let className;
45334    let groupId;
45335    const field = this[$getParent]()[$getParent]();
45336    const items = field.items.children.length && field.items.children[0][$toHTML]().html || [];
45337    const exportedValue = {
45338      on: (items[0] !== undefined ? items[0] : "on").toString(),
45339      off: (items[1] !== undefined ? items[1] : "off").toString()
45340    };
45341    const value = field.value?.[$text]() || "off";
45342    const checked = value === exportedValue.on || undefined;
45343    const container = field[$getSubformParent]();
45344    const fieldId = field[$uid];
45345    let dataId;
45346    if (container instanceof ExclGroup) {
45347      groupId = container[$uid];
45348      type = "radio";
45349      className = "xfaRadio";
45350      dataId = container[$data]?.[$uid] || container[$uid];
45351    } else {
45352      type = "checkbox";
45353      className = "xfaCheckbox";
45354      dataId = field[$data]?.[$uid] || field[$uid];
45355    }
45356    const input = {
45357      name: "input",
45358      attributes: {
45359        class: [className],
45360        style,
45361        fieldId,
45362        dataId,
45363        type,
45364        checked,
45365        xfaOn: exportedValue.on,
45366        xfaOff: exportedValue.off,
45367        "aria-label": ariaLabel(field),
45368        "aria-required": false
45369      }
45370    };
45371    if (groupId) {
45372      input.attributes.name = groupId;
45373    }
45374    if (isRequired(field)) {
45375      input.attributes["aria-required"] = true;
45376      input.attributes.required = true;
45377    }
45378    return HTMLResult.success({
45379      name: "label",
45380      attributes: {
45381        class: ["xfaLabel"]
45382      },
45383      children: [input]
45384    });
45385  }
45386}
45387class ChoiceList extends XFAObject {
45388  constructor(attributes) {
45389    super(TEMPLATE_NS_ID, "choiceList", true);
45390    this.commitOn = getStringOption(attributes.commitOn, ["select", "exit"]);
45391    this.id = attributes.id || "";
45392    this.open = getStringOption(attributes.open, ["userControl", "always", "multiSelect", "onEntry"]);
45393    this.textEntry = getInteger({
45394      data: attributes.textEntry,
45395      defaultValue: 0,
45396      validate: x => x === 1
45397    });
45398    this.use = attributes.use || "";
45399    this.usehref = attributes.usehref || "";
45400    this.border = null;
45401    this.extras = null;
45402    this.margin = null;
45403  }
45404  [$toHTML](availableSpace) {
45405    const style = toStyle(this, "border", "margin");
45406    const ui = this[$getParent]();
45407    const field = ui[$getParent]();
45408    const fontSize = field.font?.size || 10;
45409    const optionStyle = {
45410      fontSize: `calc(${fontSize}px * var(--total-scale-factor))`
45411    };
45412    const children = [];
45413    if (field.items.children.length > 0) {
45414      const items = field.items;
45415      let displayedIndex = 0;
45416      let saveIndex = 0;
45417      if (items.children.length === 2) {
45418        displayedIndex = items.children[0].save;
45419        saveIndex = 1 - displayedIndex;
45420      }
45421      const displayed = items.children[displayedIndex][$toHTML]().html;
45422      const values = items.children[saveIndex][$toHTML]().html;
45423      let selected = false;
45424      const value = field.value?.[$text]() || "";
45425      for (let i = 0, ii = displayed.length; i < ii; i++) {
45426        const option = {
45427          name: "option",
45428          attributes: {
45429            value: values[i] || displayed[i],
45430            style: optionStyle
45431          },
45432          value: displayed[i]
45433        };
45434        if (values[i] === value) {
45435          option.attributes.selected = selected = true;
45436        }
45437        children.push(option);
45438      }
45439      if (!selected) {
45440        children.splice(0, 0, {
45441          name: "option",
45442          attributes: {
45443            hidden: true,
45444            selected: true
45445          },
45446          value: " "
45447        });
45448      }
45449    }
45450    const selectAttributes = {
45451      class: ["xfaSelect"],
45452      fieldId: field[$uid],
45453      dataId: field[$data]?.[$uid] || field[$uid],
45454      style,
45455      "aria-label": ariaLabel(field),
45456      "aria-required": false
45457    };
45458    if (isRequired(field)) {
45459      selectAttributes["aria-required"] = true;
45460      selectAttributes.required = true;
45461    }
45462    if (this.open === "multiSelect") {
45463      selectAttributes.multiple = true;
45464    }
45465    return HTMLResult.success({
45466      name: "label",
45467      attributes: {
45468        class: ["xfaLabel"]
45469      },
45470      children: [{
45471        name: "select",
45472        children,
45473        attributes: selectAttributes
45474      }]
45475    });
45476  }
45477}
45478class Color extends XFAObject {
45479  constructor(attributes) {
45480    super(TEMPLATE_NS_ID, "color", true);
45481    this.cSpace = getStringOption(attributes.cSpace, ["SRGB"]);
45482    this.id = attributes.id || "";
45483    this.use = attributes.use || "";
45484    this.usehref = attributes.usehref || "";
45485    this.value = attributes.value ? getColor(attributes.value) : "";
45486    this.extras = null;
45487  }
45488  [$hasSettableValue]() {
45489    return false;
45490  }
45491  [$toStyle]() {
45492    return this.value ? Util.makeHexColor(this.value.r, this.value.g, this.value.b) : null;
45493  }
45494}
45495class Comb extends XFAObject {
45496  constructor(attributes) {
45497    super(TEMPLATE_NS_ID, "comb");
45498    this.id = attributes.id || "";
45499    this.numberOfCells = getInteger({
45500      data: attributes.numberOfCells,
45501      defaultValue: 0,
45502      validate: x => x >= 0
45503    });
45504    this.use = attributes.use || "";
45505    this.usehref = attributes.usehref || "";
45506  }
45507}
45508class Connect extends XFAObject {
45509  constructor(attributes) {
45510    super(TEMPLATE_NS_ID, "connect", true);
45511    this.connection = attributes.connection || "";
45512    this.id = attributes.id || "";
45513    this.ref = attributes.ref || "";
45514    this.usage = getStringOption(attributes.usage, ["exportAndImport", "exportOnly", "importOnly"]);
45515    this.use = attributes.use || "";
45516    this.usehref = attributes.usehref || "";
45517    this.picture = null;
45518  }
45519}
45520class ContentArea extends XFAObject {
45521  constructor(attributes) {
45522    super(TEMPLATE_NS_ID, "contentArea", true);
45523    this.h = getMeasurement(attributes.h);
45524    this.id = attributes.id || "";
45525    this.name = attributes.name || "";
45526    this.relevant = getRelevant(attributes.relevant);
45527    this.use = attributes.use || "";
45528    this.usehref = attributes.usehref || "";
45529    this.w = getMeasurement(attributes.w);
45530    this.x = getMeasurement(attributes.x, "0pt");
45531    this.y = getMeasurement(attributes.y, "0pt");
45532    this.desc = null;
45533    this.extras = null;
45534  }
45535  [$toHTML](availableSpace) {
45536    const left = measureToString(this.x);
45537    const top = measureToString(this.y);
45538    const style = {
45539      left,
45540      top,
45541      width: measureToString(this.w),
45542      height: measureToString(this.h)
45543    };
45544    const classNames = ["xfaContentarea"];
45545    if (isPrintOnly(this)) {
45546      classNames.push("xfaPrintOnly");
45547    }
45548    return HTMLResult.success({
45549      name: "div",
45550      children: [],
45551      attributes: {
45552        style,
45553        class: classNames,
45554        id: this[$uid]
45555      }
45556    });
45557  }
45558}
45559class Corner extends XFAObject {
45560  constructor(attributes) {
45561    super(TEMPLATE_NS_ID, "corner", true);
45562    this.id = attributes.id || "";
45563    this.inverted = getInteger({
45564      data: attributes.inverted,
45565      defaultValue: 0,
45566      validate: x => x === 1
45567    });
45568    this.join = getStringOption(attributes.join, ["square", "round"]);
45569    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
45570    this.radius = getMeasurement(attributes.radius);
45571    this.stroke = getStringOption(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
45572    this.thickness = getMeasurement(attributes.thickness, "0.5pt");
45573    this.use = attributes.use || "";
45574    this.usehref = attributes.usehref || "";
45575    this.color = null;
45576    this.extras = null;
45577  }
45578  [$toStyle]() {
45579    const style = toStyle(this, "visibility");
45580    style.radius = measureToString(this.join === "square" ? 0 : this.radius);
45581    return style;
45582  }
45583}
45584class DateElement extends ContentObject {
45585  constructor(attributes) {
45586    super(TEMPLATE_NS_ID, "date");
45587    this.id = attributes.id || "";
45588    this.name = attributes.name || "";
45589    this.use = attributes.use || "";
45590    this.usehref = attributes.usehref || "";
45591  }
45592  [$finalize]() {
45593    const date = this[$content].trim();
45594    this[$content] = date ? new Date(date) : null;
45595  }
45596  [$toHTML](availableSpace) {
45597    return valueToHtml(this[$content] ? this[$content].toString() : "");
45598  }
45599}
45600class DateTime extends ContentObject {
45601  constructor(attributes) {
45602    super(TEMPLATE_NS_ID, "dateTime");
45603    this.id = attributes.id || "";
45604    this.name = attributes.name || "";
45605    this.use = attributes.use || "";
45606    this.usehref = attributes.usehref || "";
45607  }
45608  [$finalize]() {
45609    const date = this[$content].trim();
45610    this[$content] = date ? new Date(date) : null;
45611  }
45612  [$toHTML](availableSpace) {
45613    return valueToHtml(this[$content] ? this[$content].toString() : "");
45614  }
45615}
45616class DateTimeEdit extends XFAObject {
45617  constructor(attributes) {
45618    super(TEMPLATE_NS_ID, "dateTimeEdit", true);
45619    this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, ["auto", "off", "on"]);
45620    this.id = attributes.id || "";
45621    this.picker = getStringOption(attributes.picker, ["host", "none"]);
45622    this.use = attributes.use || "";
45623    this.usehref = attributes.usehref || "";
45624    this.border = null;
45625    this.comb = null;
45626    this.extras = null;
45627    this.margin = null;
45628  }
45629  [$toHTML](availableSpace) {
45630    const style = toStyle(this, "border", "font", "margin");
45631    const field = this[$getParent]()[$getParent]();
45632    const html = {
45633      name: "input",
45634      attributes: {
45635        type: "text",
45636        fieldId: field[$uid],
45637        dataId: field[$data]?.[$uid] || field[$uid],
45638        class: ["xfaTextfield"],
45639        style,
45640        "aria-label": ariaLabel(field),
45641        "aria-required": false
45642      }
45643    };
45644    if (isRequired(field)) {
45645      html.attributes["aria-required"] = true;
45646      html.attributes.required = true;
45647    }
45648    return HTMLResult.success({
45649      name: "label",
45650      attributes: {
45651        class: ["xfaLabel"]
45652      },
45653      children: [html]
45654    });
45655  }
45656}
45657class Decimal extends ContentObject {
45658  constructor(attributes) {
45659    super(TEMPLATE_NS_ID, "decimal");
45660    this.fracDigits = getInteger({
45661      data: attributes.fracDigits,
45662      defaultValue: 2,
45663      validate: x => true
45664    });
45665    this.id = attributes.id || "";
45666    this.leadDigits = getInteger({
45667      data: attributes.leadDigits,
45668      defaultValue: -1,
45669      validate: x => true
45670    });
45671    this.name = attributes.name || "";
45672    this.use = attributes.use || "";
45673    this.usehref = attributes.usehref || "";
45674  }
45675  [$finalize]() {
45676    const number = parseFloat(this[$content].trim());
45677    this[$content] = isNaN(number) ? null : number;
45678  }
45679  [$toHTML](availableSpace) {
45680    return valueToHtml(this[$content] !== null ? this[$content].toString() : "");
45681  }
45682}
45683class DefaultUi extends XFAObject {
45684  constructor(attributes) {
45685    super(TEMPLATE_NS_ID, "defaultUi", true);
45686    this.id = attributes.id || "";
45687    this.use = attributes.use || "";
45688    this.usehref = attributes.usehref || "";
45689    this.extras = null;
45690  }
45691}
45692class Desc extends XFAObject {
45693  constructor(attributes) {
45694    super(TEMPLATE_NS_ID, "desc", true);
45695    this.id = attributes.id || "";
45696    this.use = attributes.use || "";
45697    this.usehref = attributes.usehref || "";
45698    this.boolean = new XFAObjectArray();
45699    this.date = new XFAObjectArray();
45700    this.dateTime = new XFAObjectArray();
45701    this.decimal = new XFAObjectArray();
45702    this.exData = new XFAObjectArray();
45703    this.float = new XFAObjectArray();
45704    this.image = new XFAObjectArray();
45705    this.integer = new XFAObjectArray();
45706    this.text = new XFAObjectArray();
45707    this.time = new XFAObjectArray();
45708  }
45709}
45710class DigestMethod extends OptionObject {
45711  constructor(attributes) {
45712    super(TEMPLATE_NS_ID, "digestMethod", ["", "SHA1", "SHA256", "SHA512", "RIPEMD160"]);
45713    this.id = attributes.id || "";
45714    this.use = attributes.use || "";
45715    this.usehref = attributes.usehref || "";
45716  }
45717}
45718class DigestMethods extends XFAObject {
45719  constructor(attributes) {
45720    super(TEMPLATE_NS_ID, "digestMethods", true);
45721    this.id = attributes.id || "";
45722    this.type = getStringOption(attributes.type, ["optional", "required"]);
45723    this.use = attributes.use || "";
45724    this.usehref = attributes.usehref || "";
45725    this.digestMethod = new XFAObjectArray();
45726  }
45727}
45728class Draw extends XFAObject {
45729  constructor(attributes) {
45730    super(TEMPLATE_NS_ID, "draw", true);
45731    this.anchorType = getStringOption(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
45732    this.colSpan = getInteger({
45733      data: attributes.colSpan,
45734      defaultValue: 1,
45735      validate: n => n >= 1 || n === -1
45736    });
45737    this.h = attributes.h ? getMeasurement(attributes.h) : "";
45738    this.hAlign = getStringOption(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
45739    this.id = attributes.id || "";
45740    this.locale = attributes.locale || "";
45741    this.maxH = getMeasurement(attributes.maxH, "0pt");
45742    this.maxW = getMeasurement(attributes.maxW, "0pt");
45743    this.minH = getMeasurement(attributes.minH, "0pt");
45744    this.minW = getMeasurement(attributes.minW, "0pt");
45745    this.name = attributes.name || "";
45746    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
45747    this.relevant = getRelevant(attributes.relevant);
45748    this.rotate = getInteger({
45749      data: attributes.rotate,
45750      defaultValue: 0,
45751      validate: x => x % 90 === 0
45752    });
45753    this.use = attributes.use || "";
45754    this.usehref = attributes.usehref || "";
45755    this.w = attributes.w ? getMeasurement(attributes.w) : "";
45756    this.x = getMeasurement(attributes.x, "0pt");
45757    this.y = getMeasurement(attributes.y, "0pt");
45758    this.assist = null;
45759    this.border = null;
45760    this.caption = null;
45761    this.desc = null;
45762    this.extras = null;
45763    this.font = null;
45764    this.keep = null;
45765    this.margin = null;
45766    this.para = null;
45767    this.traversal = null;
45768    this.ui = null;
45769    this.value = null;
45770    this.setProperty = new XFAObjectArray();
45771  }
45772  [$setValue](value) {
45773    _setValue(this, value);
45774  }
45775  [$toHTML](availableSpace) {
45776    setTabIndex(this);
45777    if (this.presence === "hidden" || this.presence === "inactive") {
45778      return HTMLResult.EMPTY;
45779    }
45780    fixDimensions(this);
45781    this[$pushPara]();
45782    const savedW = this.w;
45783    const savedH = this.h;
45784    const {
45785      w,
45786      h,
45787      isBroken
45788    } = layoutNode(this, availableSpace);
45789    if (w && this.w === "") {
45790      if (isBroken && this[$getSubformParent]()[$isThereMoreWidth]()) {
45791        this[$popPara]();
45792        return HTMLResult.FAILURE;
45793      }
45794      this.w = w;
45795    }
45796    if (h && this.h === "") {
45797      this.h = h;
45798    }
45799    setFirstUnsplittable(this);
45800    if (!checkDimensions(this, availableSpace)) {
45801      this.w = savedW;
45802      this.h = savedH;
45803      this[$popPara]();
45804      return HTMLResult.FAILURE;
45805    }
45806    unsetFirstUnsplittable(this);
45807    const style = toStyle(this, "font", "hAlign", "dimensions", "position", "presence", "rotate", "anchorType", "border", "margin");
45808    setMinMaxDimensions(this, style);
45809    if (style.margin) {
45810      style.padding = style.margin;
45811      delete style.margin;
45812    }
45813    const classNames = ["xfaDraw"];
45814    if (this.font) {
45815      classNames.push("xfaFont");
45816    }
45817    if (isPrintOnly(this)) {
45818      classNames.push("xfaPrintOnly");
45819    }
45820    const attributes = {
45821      style,
45822      id: this[$uid],
45823      class: classNames
45824    };
45825    if (this.name) {
45826      attributes.xfaName = this.name;
45827    }
45828    const html = {
45829      name: "div",
45830      attributes,
45831      children: []
45832    };
45833    applyAssist(this, attributes);
45834    const bbox = computeBbox(this, html, availableSpace);
45835    const value = this.value ? this.value[$toHTML](availableSpace).html : null;
45836    if (value === null) {
45837      this.w = savedW;
45838      this.h = savedH;
45839      this[$popPara]();
45840      return HTMLResult.success(createWrapper(this, html), bbox);
45841    }
45842    html.children.push(value);
45843    setPara(this, style, value);
45844    this.w = savedW;
45845    this.h = savedH;
45846    this[$popPara]();
45847    return HTMLResult.success(createWrapper(this, html), bbox);
45848  }
45849}
45850class Edge extends XFAObject {
45851  constructor(attributes) {
45852    super(TEMPLATE_NS_ID, "edge", true);
45853    this.cap = getStringOption(attributes.cap, ["square", "butt", "round"]);
45854    this.id = attributes.id || "";
45855    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
45856    this.stroke = getStringOption(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
45857    this.thickness = getMeasurement(attributes.thickness, "0.5pt");
45858    this.use = attributes.use || "";
45859    this.usehref = attributes.usehref || "";
45860    this.color = null;
45861    this.extras = null;
45862  }
45863  [$toStyle]() {
45864    const style = toStyle(this, "visibility");
45865    Object.assign(style, {
45866      linecap: this.cap,
45867      width: measureToString(this.thickness),
45868      color: this.color ? this.color[$toStyle]() : "#000000",
45869      style: ""
45870    });
45871    if (this.presence !== "visible") {
45872      style.style = "none";
45873    } else {
45874      switch (this.stroke) {
45875        case "solid":
45876          style.style = "solid";
45877          break;
45878        case "dashDot":
45879          style.style = "dashed";
45880          break;
45881        case "dashDotDot":
45882          style.style = "dashed";
45883          break;
45884        case "dashed":
45885          style.style = "dashed";
45886          break;
45887        case "dotted":
45888          style.style = "dotted";
45889          break;
45890        case "embossed":
45891          style.style = "ridge";
45892          break;
45893        case "etched":
45894          style.style = "groove";
45895          break;
45896        case "lowered":
45897          style.style = "inset";
45898          break;
45899        case "raised":
45900          style.style = "outset";
45901          break;
45902      }
45903    }
45904    return style;
45905  }
45906}
45907class Encoding extends OptionObject {
45908  constructor(attributes) {
45909    super(TEMPLATE_NS_ID, "encoding", ["adbe.x509.rsa_sha1", "adbe.pkcs7.detached", "adbe.pkcs7.sha1"]);
45910    this.id = attributes.id || "";
45911    this.use = attributes.use || "";
45912    this.usehref = attributes.usehref || "";
45913  }
45914}
45915class Encodings extends XFAObject {
45916  constructor(attributes) {
45917    super(TEMPLATE_NS_ID, "encodings", true);
45918    this.id = attributes.id || "";
45919    this.type = getStringOption(attributes.type, ["optional", "required"]);
45920    this.use = attributes.use || "";
45921    this.usehref = attributes.usehref || "";
45922    this.encoding = new XFAObjectArray();
45923  }
45924}
45925class Encrypt extends XFAObject {
45926  constructor(attributes) {
45927    super(TEMPLATE_NS_ID, "encrypt", true);
45928    this.id = attributes.id || "";
45929    this.use = attributes.use || "";
45930    this.usehref = attributes.usehref || "";
45931    this.certificate = null;
45932  }
45933}
45934class EncryptData extends XFAObject {
45935  constructor(attributes) {
45936    super(TEMPLATE_NS_ID, "encryptData", true);
45937    this.id = attributes.id || "";
45938    this.operation = getStringOption(attributes.operation, ["encrypt", "decrypt"]);
45939    this.target = attributes.target || "";
45940    this.use = attributes.use || "";
45941    this.usehref = attributes.usehref || "";
45942    this.filter = null;
45943    this.manifest = null;
45944  }
45945}
45946class Encryption extends XFAObject {
45947  constructor(attributes) {
45948    super(TEMPLATE_NS_ID, "encryption", true);
45949    this.id = attributes.id || "";
45950    this.type = getStringOption(attributes.type, ["optional", "required"]);
45951    this.use = attributes.use || "";
45952    this.usehref = attributes.usehref || "";
45953    this.certificate = new XFAObjectArray();
45954  }
45955}
45956class EncryptionMethod extends OptionObject {
45957  constructor(attributes) {
45958    super(TEMPLATE_NS_ID, "encryptionMethod", ["", "AES256-CBC", "TRIPLEDES-CBC", "AES128-CBC", "AES192-CBC"]);
45959    this.id = attributes.id || "";
45960    this.use = attributes.use || "";
45961    this.usehref = attributes.usehref || "";
45962  }
45963}
45964class EncryptionMethods extends XFAObject {
45965  constructor(attributes) {
45966    super(TEMPLATE_NS_ID, "encryptionMethods", true);
45967    this.id = attributes.id || "";
45968    this.type = getStringOption(attributes.type, ["optional", "required"]);
45969    this.use = attributes.use || "";
45970    this.usehref = attributes.usehref || "";
45971    this.encryptionMethod = new XFAObjectArray();
45972  }
45973}
45974class Event extends XFAObject {
45975  constructor(attributes) {
45976    super(TEMPLATE_NS_ID, "event", true);
45977    this.activity = getStringOption(attributes.activity, ["click", "change", "docClose", "docReady", "enter", "exit", "full", "indexChange", "initialize", "mouseDown", "mouseEnter", "mouseExit", "mouseUp", "postExecute", "postOpen", "postPrint", "postSave", "postSign", "postSubmit", "preExecute", "preOpen", "prePrint", "preSave", "preSign", "preSubmit", "ready", "validationState"]);
45978    this.id = attributes.id || "";
45979    this.listen = getStringOption(attributes.listen, ["refOnly", "refAndDescendents"]);
45980    this.name = attributes.name || "";
45981    this.ref = attributes.ref || "";
45982    this.use = attributes.use || "";
45983    this.usehref = attributes.usehref || "";
45984    this.extras = null;
45985    this.encryptData = null;
45986    this.execute = null;
45987    this.script = null;
45988    this.signData = null;
45989    this.submit = null;
45990  }
45991}
45992class ExData extends ContentObject {
45993  constructor(attributes) {
45994    super(TEMPLATE_NS_ID, "exData");
45995    this.contentType = attributes.contentType || "";
45996    this.href = attributes.href || "";
45997    this.id = attributes.id || "";
45998    this.maxLength = getInteger({
45999      data: attributes.maxLength,
46000      defaultValue: -1,
46001      validate: x => x >= -1
46002    });
46003    this.name = attributes.name || "";
46004    this.rid = attributes.rid || "";
46005    this.transferEncoding = getStringOption(attributes.transferEncoding, ["none", "base64", "package"]);
46006    this.use = attributes.use || "";
46007    this.usehref = attributes.usehref || "";
46008  }
46009  [$isCDATAXml]() {
46010    return this.contentType === "text/html";
46011  }
46012  [$onChild](child) {
46013    if (this.contentType === "text/html" && child[$namespaceId] === NamespaceIds.xhtml.id) {
46014      this[$content] = child;
46015      return true;
46016    }
46017    if (this.contentType === "text/xml") {
46018      this[$content] = child;
46019      return true;
46020    }
46021    return false;
46022  }
46023  [$toHTML](availableSpace) {
46024    if (this.contentType !== "text/html" || !this[$content]) {
46025      return HTMLResult.EMPTY;
46026    }
46027    return this[$content][$toHTML](availableSpace);
46028  }
46029}
46030class ExObject extends XFAObject {
46031  constructor(attributes) {
46032    super(TEMPLATE_NS_ID, "exObject", true);
46033    this.archive = attributes.archive || "";
46034    this.classId = attributes.classId || "";
46035    this.codeBase = attributes.codeBase || "";
46036    this.codeType = attributes.codeType || "";
46037    this.id = attributes.id || "";
46038    this.name = attributes.name || "";
46039    this.use = attributes.use || "";
46040    this.usehref = attributes.usehref || "";
46041    this.extras = null;
46042    this.boolean = new XFAObjectArray();
46043    this.date = new XFAObjectArray();
46044    this.dateTime = new XFAObjectArray();
46045    this.decimal = new XFAObjectArray();
46046    this.exData = new XFAObjectArray();
46047    this.exObject = new XFAObjectArray();
46048    this.float = new XFAObjectArray();
46049    this.image = new XFAObjectArray();
46050    this.integer = new XFAObjectArray();
46051    this.text = new XFAObjectArray();
46052    this.time = new XFAObjectArray();
46053  }
46054}
46055class ExclGroup extends XFAObject {
46056  constructor(attributes) {
46057    super(TEMPLATE_NS_ID, "exclGroup", true);
46058    this.access = getStringOption(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
46059    this.accessKey = attributes.accessKey || "";
46060    this.anchorType = getStringOption(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
46061    this.colSpan = getInteger({
46062      data: attributes.colSpan,
46063      defaultValue: 1,
46064      validate: n => n >= 1 || n === -1
46065    });
46066    this.h = attributes.h ? getMeasurement(attributes.h) : "";
46067    this.hAlign = getStringOption(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
46068    this.id = attributes.id || "";
46069    this.layout = getStringOption(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
46070    this.maxH = getMeasurement(attributes.maxH, "0pt");
46071    this.maxW = getMeasurement(attributes.maxW, "0pt");
46072    this.minH = getMeasurement(attributes.minH, "0pt");
46073    this.minW = getMeasurement(attributes.minW, "0pt");
46074    this.name = attributes.name || "";
46075    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
46076    this.relevant = getRelevant(attributes.relevant);
46077    this.use = attributes.use || "";
46078    this.usehref = attributes.usehref || "";
46079    this.w = attributes.w ? getMeasurement(attributes.w) : "";
46080    this.x = getMeasurement(attributes.x, "0pt");
46081    this.y = getMeasurement(attributes.y, "0pt");
46082    this.assist = null;
46083    this.bind = null;
46084    this.border = null;
46085    this.calculate = null;
46086    this.caption = null;
46087    this.desc = null;
46088    this.extras = null;
46089    this.margin = null;
46090    this.para = null;
46091    this.traversal = null;
46092    this.validate = null;
46093    this.connect = new XFAObjectArray();
46094    this.event = new XFAObjectArray();
46095    this.field = new XFAObjectArray();
46096    this.setProperty = new XFAObjectArray();
46097  }
46098  [$isBindable]() {
46099    return true;
46100  }
46101  [$hasSettableValue]() {
46102    return true;
46103  }
46104  [$setValue](value) {
46105    for (const field of this.field.children) {
46106      if (!field.value) {
46107        const nodeValue = new Value({});
46108        field[$appendChild](nodeValue);
46109        field.value = nodeValue;
46110      }
46111      field.value[$setValue](value);
46112    }
46113  }
46114  [$isThereMoreWidth]() {
46115    return this.layout.endsWith("-tb") && this[$extra].attempt === 0 && this[$extra].numberInLine > 0 || this[$getParent]()[$isThereMoreWidth]();
46116  }
46117  [$isSplittable]() {
46118    const parent = this[$getSubformParent]();
46119    if (!parent[$isSplittable]()) {
46120      return false;
46121    }
46122    if (this[$extra]._isSplittable !== undefined) {
46123      return this[$extra]._isSplittable;
46124    }
46125    if (this.layout === "position" || this.layout.includes("row")) {
46126      this[$extra]._isSplittable = false;
46127      return false;
46128    }
46129    if (parent.layout?.endsWith("-tb") && parent[$extra].numberInLine !== 0) {
46130      return false;
46131    }
46132    this[$extra]._isSplittable = true;
46133    return true;
46134  }
46135  [$flushHTML]() {
46136    return flushHTML(this);
46137  }
46138  [$addHTML](html, bbox) {
46139    addHTML(this, html, bbox);
46140  }
46141  [$getAvailableSpace]() {
46142    return getAvailableSpace(this);
46143  }
46144  [$toHTML](availableSpace) {
46145    setTabIndex(this);
46146    if (this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
46147      return HTMLResult.EMPTY;
46148    }
46149    fixDimensions(this);
46150    const children = [];
46151    const attributes = {
46152      id: this[$uid],
46153      class: []
46154    };
46155    setAccess(this, attributes.class);
46156    this[$extra] ||= Object.create(null);
46157    Object.assign(this[$extra], {
46158      children,
46159      attributes,
46160      attempt: 0,
46161      line: null,
46162      numberInLine: 0,
46163      availableSpace: {
46164        width: Math.min(this.w || Infinity, availableSpace.width),
46165        height: Math.min(this.h || Infinity, availableSpace.height)
46166      },
46167      width: 0,
46168      height: 0,
46169      prevHeight: 0,
46170      currentWidth: 0
46171    });
46172    const isSplittable = this[$isSplittable]();
46173    if (!isSplittable) {
46174      setFirstUnsplittable(this);
46175    }
46176    if (!checkDimensions(this, availableSpace)) {
46177      return HTMLResult.FAILURE;
46178    }
46179    const filter = new Set(["field"]);
46180    if (this.layout.includes("row")) {
46181      const columnWidths = this[$getSubformParent]().columnWidths;
46182      if (Array.isArray(columnWidths) && columnWidths.length > 0) {
46183        this[$extra].columnWidths = columnWidths;
46184        this[$extra].currentColumn = 0;
46185      }
46186    }
46187    const style = toStyle(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
46188    const classNames = ["xfaExclgroup"];
46189    const cl = layoutClass(this);
46190    if (cl) {
46191      classNames.push(cl);
46192    }
46193    if (isPrintOnly(this)) {
46194      classNames.push("xfaPrintOnly");
46195    }
46196    attributes.style = style;
46197    attributes.class = classNames;
46198    if (this.name) {
46199      attributes.xfaName = this.name;
46200    }
46201    this[$pushPara]();
46202    const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
46203    const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
46204    for (; this[$extra].attempt < maxRun; this[$extra].attempt++) {
46205      if (isLrTb && this[$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
46206        this[$extra].numberInLine = 0;
46207      }
46208      const result = this[$childrenToHTML]({
46209        filter,
46210        include: true
46211      });
46212      if (result.success) {
46213        break;
46214      }
46215      if (result.isBreak()) {
46216        this[$popPara]();
46217        return result;
46218      }
46219      if (isLrTb && this[$extra].attempt === 0 && this[$extra].numberInLine === 0 && !this[$getTemplateRoot]()[$extra].noLayoutFailure) {
46220        this[$extra].attempt = maxRun;
46221        break;
46222      }
46223    }
46224    this[$popPara]();
46225    if (!isSplittable) {
46226      unsetFirstUnsplittable(this);
46227    }
46228    if (this[$extra].attempt === maxRun) {
46229      if (!isSplittable) {
46230        delete this[$extra];
46231      }
46232      return HTMLResult.FAILURE;
46233    }
46234    let marginH = 0;
46235    let marginV = 0;
46236    if (this.margin) {
46237      marginH = this.margin.leftInset + this.margin.rightInset;
46238      marginV = this.margin.topInset + this.margin.bottomInset;
46239    }
46240    const width = Math.max(this[$extra].width + marginH, this.w || 0);
46241    const height = Math.max(this[$extra].height + marginV, this.h || 0);
46242    const bbox = [this.x, this.y, width, height];
46243    if (this.w === "") {
46244      style.width = measureToString(width);
46245    }
46246    if (this.h === "") {
46247      style.height = measureToString(height);
46248    }
46249    const html = {
46250      name: "div",
46251      attributes,
46252      children
46253    };
46254    applyAssist(this, attributes);
46255    delete this[$extra];
46256    return HTMLResult.success(createWrapper(this, html), bbox);
46257  }
46258}
46259class Execute extends XFAObject {
46260  constructor(attributes) {
46261    super(TEMPLATE_NS_ID, "execute");
46262    this.connection = attributes.connection || "";
46263    this.executeType = getStringOption(attributes.executeType, ["import", "remerge"]);
46264    this.id = attributes.id || "";
46265    this.runAt = getStringOption(attributes.runAt, ["client", "both", "server"]);
46266    this.use = attributes.use || "";
46267    this.usehref = attributes.usehref || "";
46268  }
46269}
46270class Extras extends XFAObject {
46271  constructor(attributes) {
46272    super(TEMPLATE_NS_ID, "extras", true);
46273    this.id = attributes.id || "";
46274    this.name = attributes.name || "";
46275    this.use = attributes.use || "";
46276    this.usehref = attributes.usehref || "";
46277    this.boolean = new XFAObjectArray();
46278    this.date = new XFAObjectArray();
46279    this.dateTime = new XFAObjectArray();
46280    this.decimal = new XFAObjectArray();
46281    this.exData = new XFAObjectArray();
46282    this.extras = new XFAObjectArray();
46283    this.float = new XFAObjectArray();
46284    this.image = new XFAObjectArray();
46285    this.integer = new XFAObjectArray();
46286    this.text = new XFAObjectArray();
46287    this.time = new XFAObjectArray();
46288  }
46289}
46290class Field extends XFAObject {
46291  constructor(attributes) {
46292    super(TEMPLATE_NS_ID, "field", true);
46293    this.access = getStringOption(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
46294    this.accessKey = attributes.accessKey || "";
46295    this.anchorType = getStringOption(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
46296    this.colSpan = getInteger({
46297      data: attributes.colSpan,
46298      defaultValue: 1,
46299      validate: n => n >= 1 || n === -1
46300    });
46301    this.h = attributes.h ? getMeasurement(attributes.h) : "";
46302    this.hAlign = getStringOption(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
46303    this.id = attributes.id || "";
46304    this.locale = attributes.locale || "";
46305    this.maxH = getMeasurement(attributes.maxH, "0pt");
46306    this.maxW = getMeasurement(attributes.maxW, "0pt");
46307    this.minH = getMeasurement(attributes.minH, "0pt");
46308    this.minW = getMeasurement(attributes.minW, "0pt");
46309    this.name = attributes.name || "";
46310    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
46311    this.relevant = getRelevant(attributes.relevant);
46312    this.rotate = getInteger({
46313      data: attributes.rotate,
46314      defaultValue: 0,
46315      validate: x => x % 90 === 0
46316    });
46317    this.use = attributes.use || "";
46318    this.usehref = attributes.usehref || "";
46319    this.w = attributes.w ? getMeasurement(attributes.w) : "";
46320    this.x = getMeasurement(attributes.x, "0pt");
46321    this.y = getMeasurement(attributes.y, "0pt");
46322    this.assist = null;
46323    this.bind = null;
46324    this.border = null;
46325    this.calculate = null;
46326    this.caption = null;
46327    this.desc = null;
46328    this.extras = null;
46329    this.font = null;
46330    this.format = null;
46331    this.items = new XFAObjectArray(2);
46332    this.keep = null;
46333    this.margin = null;
46334    this.para = null;
46335    this.traversal = null;
46336    this.ui = null;
46337    this.validate = null;
46338    this.value = null;
46339    this.bindItems = new XFAObjectArray();
46340    this.connect = new XFAObjectArray();
46341    this.event = new XFAObjectArray();
46342    this.setProperty = new XFAObjectArray();
46343  }
46344  [$isBindable]() {
46345    return true;
46346  }
46347  [$setValue](value) {
46348    _setValue(this, value);
46349  }
46350  [$toHTML](availableSpace) {
46351    setTabIndex(this);
46352    if (!this.ui) {
46353      this.ui = new Ui({});
46354      this.ui[$globalData] = this[$globalData];
46355      this[$appendChild](this.ui);
46356      let node;
46357      switch (this.items.children.length) {
46358        case 0:
46359          node = new TextEdit({});
46360          this.ui.textEdit = node;
46361          break;
46362        case 1:
46363          node = new CheckButton({});
46364          this.ui.checkButton = node;
46365          break;
46366        case 2:
46367          node = new ChoiceList({});
46368          this.ui.choiceList = node;
46369          break;
46370      }
46371      this.ui[$appendChild](node);
46372    }
46373    if (!this.ui || this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
46374      return HTMLResult.EMPTY;
46375    }
46376    if (this.caption) {
46377      delete this.caption[$extra];
46378    }
vendor: 6,271 bytes, lines 46379-46582
46379    this[$pushPara]();
46380    const caption = this.caption ? this.caption[$toHTML](availableSpace).html : null;
46381    const savedW = this.w;
46382    const savedH = this.h;
46383    let marginH = 0;
46384    let marginV = 0;
46385    if (this.margin) {
46386      marginH = this.margin.leftInset + this.margin.rightInset;
46387      marginV = this.margin.topInset + this.margin.bottomInset;
46388    }
46389    let borderDims = null;
46390    if (this.w === "" || this.h === "") {
46391      let width = null;
46392      let height = null;
46393      let uiW = 0;
46394      let uiH = 0;
46395      if (this.ui.checkButton) {
46396        uiW = uiH = this.ui.checkButton.size;
46397      } else {
46398        const {
46399          w,
46400          h
46401        } = layoutNode(this, availableSpace);
46402        if (w !== null) {
46403          uiW = w;
46404          uiH = h;
46405        } else {
46406          uiH = fonts_getMetrics(this.font, true).lineNoGap;
46407        }
46408      }
46409      borderDims = getBorderDims(this.ui[$getExtra]());
46410      uiW += borderDims.w;
46411      uiH += borderDims.h;
46412      if (this.caption) {
46413        const {
46414          w,
46415          h,
46416          isBroken
46417        } = this.caption[$getExtra](availableSpace);
46418        if (isBroken && this[$getSubformParent]()[$isThereMoreWidth]()) {
46419          this[$popPara]();
46420          return HTMLResult.FAILURE;
46421        }
46422        width = w;
46423        height = h;
46424        switch (this.caption.placement) {
46425          case "left":
46426          case "right":
46427          case "inline":
46428            width += uiW;
46429            break;
46430          case "top":
46431          case "bottom":
46432            height += uiH;
46433            break;
46434        }
46435      } else {
46436        width = uiW;
46437        height = uiH;
46438      }
46439      if (width && this.w === "") {
46440        width += marginH;
46441        this.w = Math.min(this.maxW <= 0 ? Infinity : this.maxW, this.minW + 1 < width ? width : this.minW);
46442      }
46443      if (height && this.h === "") {
46444        height += marginV;
46445        this.h = Math.min(this.maxH <= 0 ? Infinity : this.maxH, this.minH + 1 < height ? height : this.minH);
46446      }
46447    }
46448    this[$popPara]();
46449    fixDimensions(this);
46450    setFirstUnsplittable(this);
46451    if (!checkDimensions(this, availableSpace)) {
46452      this.w = savedW;
46453      this.h = savedH;
46454      this[$popPara]();
46455      return HTMLResult.FAILURE;
46456    }
46457    unsetFirstUnsplittable(this);
46458    const style = toStyle(this, "font", "dimensions", "position", "rotate", "anchorType", "presence", "margin", "hAlign");
46459    setMinMaxDimensions(this, style);
46460    const classNames = ["xfaField"];
46461    if (this.font) {
46462      classNames.push("xfaFont");
46463    }
46464    if (isPrintOnly(this)) {
46465      classNames.push("xfaPrintOnly");
46466    }
46467    const attributes = {
46468      style,
46469      id: this[$uid],
46470      class: classNames
46471    };
46472    if (style.margin) {
46473      style.padding = style.margin;
46474      delete style.margin;
46475    }
46476    setAccess(this, classNames);
46477    if (this.name) {
46478      attributes.xfaName = this.name;
46479    }
46480    const children = [];
46481    const html = {
46482      name: "div",
46483      attributes,
46484      children
46485    };
46486    applyAssist(this, attributes);
46487    const borderStyle = this.border ? this.border[$toStyle]() : null;
46488    const bbox = computeBbox(this, html, availableSpace);
46489    const ui = this.ui[$toHTML]().html;
46490    if (!ui) {
46491      Object.assign(style, borderStyle);
46492      return HTMLResult.success(createWrapper(this, html), bbox);
46493    }
46494    if (this[$tabIndex]) {
46495      if (ui.children?.[0]) {
46496        ui.children[0].attributes.tabindex = this[$tabIndex];
46497      } else {
46498        ui.attributes.tabindex = this[$tabIndex];
46499      }
46500    }
46501    ui.attributes.style ||= Object.create(null);
46502    let aElement = null;
46503    if (this.ui.button) {
46504      if (ui.children.length === 1) {
46505        [aElement] = ui.children.splice(0, 1);
46506      }
46507      Object.assign(ui.attributes.style, borderStyle);
46508    } else {
46509      Object.assign(style, borderStyle);
46510    }
46511    children.push(ui);
46512    if (this.value) {
46513      if (this.ui.imageEdit) {
46514        ui.children.push(this.value[$toHTML]().html);
46515      } else if (!this.ui.button) {
46516        let value = "";
46517        if (this.value.exData) {
46518          value = this.value.exData[$text]();
46519        } else if (this.value.text) {
46520          value = this.value.text[$getExtra]();
46521        } else {
46522          const htmlValue = this.value[$toHTML]().html;
46523          if (htmlValue !== null) {
46524            value = htmlValue.children[0].value;
46525          }
46526        }
46527        if (this.ui.textEdit && this.value.text?.maxChars) {
46528          ui.children[0].attributes.maxLength = this.value.text.maxChars;
46529        }
46530        if (value) {
46531          if (this.ui.numericEdit) {
46532            value = parseFloat(value);
46533            value = isNaN(value) ? "" : value.toString();
46534          }
46535          if (ui.children[0].name === "textarea") {
46536            ui.children[0].attributes.textContent = value;
46537          } else {
46538            ui.children[0].attributes.value = value;
46539          }
46540        }
46541      }
46542    }
46543    if (!this.ui.imageEdit && ui.children?.[0] && this.h) {
46544      borderDims = borderDims || getBorderDims(this.ui[$getExtra]());
46545      let captionHeight = 0;
46546      if (this.caption && ["top", "bottom"].includes(this.caption.placement)) {
46547        captionHeight = this.caption.reserve;
46548        if (captionHeight <= 0) {
46549          captionHeight = this.caption[$getExtra](availableSpace).h;
46550        }
46551        const inputHeight = this.h - captionHeight - marginV - borderDims.h;
46552        ui.children[0].attributes.style.height = measureToString(inputHeight);
46553      } else {
46554        ui.children[0].attributes.style.height = "100%";
46555      }
46556    }
46557    if (aElement) {
46558      ui.children.push(aElement);
46559    }
46560    if (!caption) {
46561      if (ui.attributes.class) {
46562        ui.attributes.class.push("xfaLeft");
46563      }
46564      this.w = savedW;
46565      this.h = savedH;
46566      return HTMLResult.success(createWrapper(this, html), bbox);
46567    }
46568    if (this.ui.button) {
46569      if (style.padding) {
46570        delete style.padding;
46571      }
46572      if (caption.name === "div") {
46573        caption.name = "span";
46574      }
46575      ui.children.push(caption);
46576      return HTMLResult.success(html, bbox);
46577    } else if (this.ui.checkButton) {
46578      caption.attributes.class[0] = "xfaCaptionForCheckButton";
46579    }
46580    ui.attributes.class ||= [];
46581    ui.children.splice(0, 0, caption);
46582    switch (this.caption.placement) {
vendor: 67,244 bytes, lines 46583-48592
46583      case "left":
46584        ui.attributes.class.push("xfaLeft");
46585        break;
46586      case "right":
46587        ui.attributes.class.push("xfaRight");
46588        break;
46589      case "top":
46590        ui.attributes.class.push("xfaTop");
46591        break;
46592      case "bottom":
46593        ui.attributes.class.push("xfaBottom");
46594        break;
46595      case "inline":
46596        ui.attributes.class.push("xfaLeft");
46597        break;
46598    }
46599    this.w = savedW;
46600    this.h = savedH;
46601    return HTMLResult.success(createWrapper(this, html), bbox);
46602  }
46603}
46604class Fill extends XFAObject {
46605  constructor(attributes) {
46606    super(TEMPLATE_NS_ID, "fill", true);
46607    this.id = attributes.id || "";
46608    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
46609    this.use = attributes.use || "";
46610    this.usehref = attributes.usehref || "";
46611    this.color = null;
46612    this.extras = null;
46613    this.linear = null;
46614    this.pattern = null;
46615    this.radial = null;
46616    this.solid = null;
46617    this.stipple = null;
46618  }
46619  [$toStyle]() {
46620    const parent = this[$getParent]();
46621    const grandpa = parent[$getParent]();
46622    const ggrandpa = grandpa[$getParent]();
46623    const style = Object.create(null);
46624    let propName = "color";
46625    let altPropName = propName;
46626    if (parent instanceof Border) {
46627      propName = "background-color";
46628      altPropName = "background";
46629      if (ggrandpa instanceof Ui) {
46630        style.backgroundColor = "white";
46631      }
46632    }
46633    if (parent instanceof Rectangle || parent instanceof Arc) {
46634      propName = altPropName = "fill";
46635      style.fill = "white";
46636    }
46637    for (const name of Object.getOwnPropertyNames(this)) {
46638      if (name === "extras" || name === "color") {
46639        continue;
46640      }
46641      const obj = this[name];
46642      if (!(obj instanceof XFAObject)) {
46643        continue;
46644      }
46645      const color = obj[$toStyle](this.color);
46646      if (color) {
46647        style[color.startsWith("#") ? propName : altPropName] = color;
46648      }
46649      return style;
46650    }
46651    if (this.color?.value) {
46652      const color = this.color[$toStyle]();
46653      style[color.startsWith("#") ? propName : altPropName] = color;
46654    }
46655    return style;
46656  }
46657}
46658class Filter extends XFAObject {
46659  constructor(attributes) {
46660    super(TEMPLATE_NS_ID, "filter", true);
46661    this.addRevocationInfo = getStringOption(attributes.addRevocationInfo, ["", "required", "optional", "none"]);
46662    this.id = attributes.id || "";
46663    this.name = attributes.name || "";
46664    this.use = attributes.use || "";
46665    this.usehref = attributes.usehref || "";
46666    this.version = getInteger({
46667      data: this.version,
46668      defaultValue: 5,
46669      validate: x => x >= 1 && x <= 5
46670    });
46671    this.appearanceFilter = null;
46672    this.certificates = null;
46673    this.digestMethods = null;
46674    this.encodings = null;
46675    this.encryptionMethods = null;
46676    this.handler = null;
46677    this.lockDocument = null;
46678    this.mdp = null;
46679    this.reasons = null;
46680    this.timeStamp = null;
46681  }
46682}
46683class Float extends ContentObject {
46684  constructor(attributes) {
46685    super(TEMPLATE_NS_ID, "float");
46686    this.id = attributes.id || "";
46687    this.name = attributes.name || "";
46688    this.use = attributes.use || "";
46689    this.usehref = attributes.usehref || "";
46690  }
46691  [$finalize]() {
46692    const number = parseFloat(this[$content].trim());
46693    this[$content] = isNaN(number) ? null : number;
46694  }
46695  [$toHTML](availableSpace) {
46696    return valueToHtml(this[$content] !== null ? this[$content].toString() : "");
46697  }
46698}
46699class template_Font extends XFAObject {
46700  constructor(attributes) {
46701    super(TEMPLATE_NS_ID, "font", true);
46702    this.baselineShift = getMeasurement(attributes.baselineShift);
46703    this.fontHorizontalScale = getFloat({
46704      data: attributes.fontHorizontalScale,
46705      defaultValue: 100,
46706      validate: x => x >= 0
46707    });
46708    this.fontVerticalScale = getFloat({
46709      data: attributes.fontVerticalScale,
46710      defaultValue: 100,
46711      validate: x => x >= 0
46712    });
46713    this.id = attributes.id || "";
46714    this.kerningMode = getStringOption(attributes.kerningMode, ["none", "pair"]);
46715    this.letterSpacing = getMeasurement(attributes.letterSpacing, "0");
46716    this.lineThrough = getInteger({
46717      data: attributes.lineThrough,
46718      defaultValue: 0,
46719      validate: x => x === 1 || x === 2
46720    });
46721    this.lineThroughPeriod = getStringOption(attributes.lineThroughPeriod, ["all", "word"]);
46722    this.overline = getInteger({
46723      data: attributes.overline,
46724      defaultValue: 0,
46725      validate: x => x === 1 || x === 2
46726    });
46727    this.overlinePeriod = getStringOption(attributes.overlinePeriod, ["all", "word"]);
46728    this.posture = getStringOption(attributes.posture, ["normal", "italic"]);
46729    this.size = getMeasurement(attributes.size, "10pt");
46730    this.typeface = attributes.typeface || "Courier";
46731    this.underline = getInteger({
46732      data: attributes.underline,
46733      defaultValue: 0,
46734      validate: x => x === 1 || x === 2
46735    });
46736    this.underlinePeriod = getStringOption(attributes.underlinePeriod, ["all", "word"]);
46737    this.use = attributes.use || "";
46738    this.usehref = attributes.usehref || "";
46739    this.weight = getStringOption(attributes.weight, ["normal", "bold"]);
46740    this.extras = null;
46741    this.fill = null;
46742  }
46743  [$clean](builder) {
46744    super[$clean](builder);
46745    this[$globalData].usedTypefaces.add(this.typeface);
46746  }
46747  [$toStyle]() {
46748    const style = toStyle(this, "fill");
46749    const color = style.color;
46750    if (color) {
46751      if (color === "#000000") {
46752        delete style.color;
46753      } else if (!color.startsWith("#")) {
46754        style.background = color;
46755        style.backgroundClip = "text";
46756        style.color = "transparent";
46757      }
46758    }
46759    if (this.baselineShift) {
46760      style.verticalAlign = measureToString(this.baselineShift);
46761    }
46762    style.fontKerning = this.kerningMode === "none" ? "none" : "normal";
46763    style.letterSpacing = measureToString(this.letterSpacing);
46764    if (this.lineThrough !== 0) {
46765      style.textDecoration = "line-through";
46766      if (this.lineThrough === 2) {
46767        style.textDecorationStyle = "double";
46768      }
46769    }
46770    if (this.overline !== 0) {
46771      style.textDecoration = "overline";
46772      if (this.overline === 2) {
46773        style.textDecorationStyle = "double";
46774      }
46775    }
46776    style.fontStyle = this.posture;
46777    style.fontSize = measureToString(0.99 * this.size);
46778    setFontFamily(this, this, this[$globalData].fontFinder, style);
46779    if (this.underline !== 0) {
46780      style.textDecoration = "underline";
46781      if (this.underline === 2) {
46782        style.textDecorationStyle = "double";
46783      }
46784    }
46785    style.fontWeight = this.weight;
46786    return style;
46787  }
46788}
46789class Format extends XFAObject {
46790  constructor(attributes) {
46791    super(TEMPLATE_NS_ID, "format", true);
46792    this.id = attributes.id || "";
46793    this.use = attributes.use || "";
46794    this.usehref = attributes.usehref || "";
46795    this.extras = null;
46796    this.picture = null;
46797  }
46798}
46799class Handler extends StringObject {
46800  constructor(attributes) {
46801    super(TEMPLATE_NS_ID, "handler");
46802    this.id = attributes.id || "";
46803    this.type = getStringOption(attributes.type, ["optional", "required"]);
46804    this.use = attributes.use || "";
46805    this.usehref = attributes.usehref || "";
46806  }
46807}
46808class Hyphenation extends XFAObject {
46809  constructor(attributes) {
46810    super(TEMPLATE_NS_ID, "hyphenation");
46811    this.excludeAllCaps = getInteger({
46812      data: attributes.excludeAllCaps,
46813      defaultValue: 0,
46814      validate: x => x === 1
46815    });
46816    this.excludeInitialCap = getInteger({
46817      data: attributes.excludeInitialCap,
46818      defaultValue: 0,
46819      validate: x => x === 1
46820    });
46821    this.hyphenate = getInteger({
46822      data: attributes.hyphenate,
46823      defaultValue: 0,
46824      validate: x => x === 1
46825    });
46826    this.id = attributes.id || "";
46827    this.pushCharacterCount = getInteger({
46828      data: attributes.pushCharacterCount,
46829      defaultValue: 3,
46830      validate: x => x >= 0
46831    });
46832    this.remainCharacterCount = getInteger({
46833      data: attributes.remainCharacterCount,
46834      defaultValue: 3,
46835      validate: x => x >= 0
46836    });
46837    this.use = attributes.use || "";
46838    this.usehref = attributes.usehref || "";
46839    this.wordCharacterCount = getInteger({
46840      data: attributes.wordCharacterCount,
46841      defaultValue: 7,
46842      validate: x => x >= 0
46843    });
46844  }
46845}
46846class Image extends StringObject {
46847  constructor(attributes) {
46848    super(TEMPLATE_NS_ID, "image");
46849    this.aspect = getStringOption(attributes.aspect, ["fit", "actual", "height", "none", "width"]);
46850    this.contentType = attributes.contentType || "";
46851    this.href = attributes.href || "";
46852    this.id = attributes.id || "";
46853    this.name = attributes.name || "";
46854    this.transferEncoding = getStringOption(attributes.transferEncoding, ["base64", "none", "package"]);
46855    this.use = attributes.use || "";
46856    this.usehref = attributes.usehref || "";
46857  }
46858  [$toHTML]() {
46859    if (this.contentType && !MIMES.has(this.contentType.toLowerCase())) {
46860      return HTMLResult.EMPTY;
46861    }
46862    let buffer = this[$globalData].images?.get(this.href);
46863    if (!buffer && (this.href || !this[$content])) {
46864      return HTMLResult.EMPTY;
46865    }
46866    if (!buffer && this.transferEncoding === "base64") {
46867      buffer = Uint8Array.fromBase64(this[$content]);
46868    }
46869    if (!buffer) {
46870      return HTMLResult.EMPTY;
46871    }
46872    if (!this.contentType) {
46873      for (const [header, type] of IMAGES_HEADERS) {
46874        if (buffer.length > header.length && header.every((x, i) => x === buffer[i])) {
46875          this.contentType = type;
46876          break;
46877        }
46878      }
46879      if (!this.contentType) {
46880        return HTMLResult.EMPTY;
46881      }
46882    }
46883    const blob = new Blob([buffer], {
46884      type: this.contentType
46885    });
46886    let style;
46887    switch (this.aspect) {
46888      case "fit":
46889      case "actual":
46890        break;
46891      case "height":
46892        style = {
46893          height: "100%",
46894          objectFit: "fill"
46895        };
46896        break;
46897      case "none":
46898        style = {
46899          width: "100%",
46900          height: "100%",
46901          objectFit: "fill"
46902        };
46903        break;
46904      case "width":
46905        style = {
46906          width: "100%",
46907          objectFit: "fill"
46908        };
46909        break;
46910    }
46911    const parent = this[$getParent]();
46912    return HTMLResult.success({
46913      name: "img",
46914      attributes: {
46915        class: ["xfaImage"],
46916        style,
46917        src: URL.createObjectURL(blob),
46918        alt: parent ? ariaLabel(parent[$getParent]()) : null
46919      }
46920    });
46921  }
46922}
46923class ImageEdit extends XFAObject {
46924  constructor(attributes) {
46925    super(TEMPLATE_NS_ID, "imageEdit", true);
46926    this.data = getStringOption(attributes.data, ["link", "embed"]);
46927    this.id = attributes.id || "";
46928    this.use = attributes.use || "";
46929    this.usehref = attributes.usehref || "";
46930    this.border = null;
46931    this.extras = null;
46932    this.margin = null;
46933  }
46934  [$toHTML](availableSpace) {
46935    if (this.data === "embed") {
46936      return HTMLResult.success({
46937        name: "div",
46938        children: [],
46939        attributes: {}
46940      });
46941    }
46942    return HTMLResult.EMPTY;
46943  }
46944}
46945class Integer extends ContentObject {
46946  constructor(attributes) {
46947    super(TEMPLATE_NS_ID, "integer");
46948    this.id = attributes.id || "";
46949    this.name = attributes.name || "";
46950    this.use = attributes.use || "";
46951    this.usehref = attributes.usehref || "";
46952  }
46953  [$finalize]() {
46954    const number = parseInt(this[$content].trim(), 10);
46955    this[$content] = isNaN(number) ? null : number;
46956  }
46957  [$toHTML](availableSpace) {
46958    return valueToHtml(this[$content] !== null ? this[$content].toString() : "");
46959  }
46960}
46961class Issuers extends XFAObject {
46962  constructor(attributes) {
46963    super(TEMPLATE_NS_ID, "issuers", true);
46964    this.id = attributes.id || "";
46965    this.type = getStringOption(attributes.type, ["optional", "required"]);
46966    this.use = attributes.use || "";
46967    this.usehref = attributes.usehref || "";
46968    this.certificate = new XFAObjectArray();
46969  }
46970}
46971class Items extends XFAObject {
46972  constructor(attributes) {
46973    super(TEMPLATE_NS_ID, "items", true);
46974    this.id = attributes.id || "";
46975    this.name = attributes.name || "";
46976    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
46977    this.ref = attributes.ref || "";
46978    this.save = getInteger({
46979      data: attributes.save,
46980      defaultValue: 0,
46981      validate: x => x === 1
46982    });
46983    this.use = attributes.use || "";
46984    this.usehref = attributes.usehref || "";
46985    this.boolean = new XFAObjectArray();
46986    this.date = new XFAObjectArray();
46987    this.dateTime = new XFAObjectArray();
46988    this.decimal = new XFAObjectArray();
46989    this.exData = new XFAObjectArray();
46990    this.float = new XFAObjectArray();
46991    this.image = new XFAObjectArray();
46992    this.integer = new XFAObjectArray();
46993    this.text = new XFAObjectArray();
46994    this.time = new XFAObjectArray();
46995  }
46996  [$toHTML]() {
46997    const output = [];
46998    for (const child of this[$getChildren]()) {
46999      output.push(child[$text]());
47000    }
47001    return HTMLResult.success(output);
47002  }
47003}
47004class Keep extends XFAObject {
47005  constructor(attributes) {
47006    super(TEMPLATE_NS_ID, "keep", true);
47007    this.id = attributes.id || "";
47008    const options = ["none", "contentArea", "pageArea"];
47009    this.intact = getStringOption(attributes.intact, options);
47010    this.next = getStringOption(attributes.next, options);
47011    this.previous = getStringOption(attributes.previous, options);
47012    this.use = attributes.use || "";
47013    this.usehref = attributes.usehref || "";
47014    this.extras = null;
47015  }
47016}
47017class KeyUsage extends XFAObject {
47018  constructor(attributes) {
47019    super(TEMPLATE_NS_ID, "keyUsage");
47020    const options = ["", "yes", "no"];
47021    this.crlSign = getStringOption(attributes.crlSign, options);
47022    this.dataEncipherment = getStringOption(attributes.dataEncipherment, options);
47023    this.decipherOnly = getStringOption(attributes.decipherOnly, options);
47024    this.digitalSignature = getStringOption(attributes.digitalSignature, options);
47025    this.encipherOnly = getStringOption(attributes.encipherOnly, options);
47026    this.id = attributes.id || "";
47027    this.keyAgreement = getStringOption(attributes.keyAgreement, options);
47028    this.keyCertSign = getStringOption(attributes.keyCertSign, options);
47029    this.keyEncipherment = getStringOption(attributes.keyEncipherment, options);
47030    this.nonRepudiation = getStringOption(attributes.nonRepudiation, options);
47031    this.type = getStringOption(attributes.type, ["optional", "required"]);
47032    this.use = attributes.use || "";
47033    this.usehref = attributes.usehref || "";
47034  }
47035}
47036class Line extends XFAObject {
47037  constructor(attributes) {
47038    super(TEMPLATE_NS_ID, "line", true);
47039    this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
47040    this.id = attributes.id || "";
47041    this.slope = getStringOption(attributes.slope, ["\\", "/"]);
47042    this.use = attributes.use || "";
47043    this.usehref = attributes.usehref || "";
47044    this.edge = null;
47045  }
47046  [$toHTML]() {
47047    const parent = this[$getParent]()[$getParent]();
47048    const edge = this.edge || new Edge({});
47049    const edgeStyle = edge[$toStyle]();
47050    const style = Object.create(null);
47051    const thickness = edge.presence === "visible" ? edge.thickness : 0;
47052    style.strokeWidth = measureToString(thickness);
47053    style.stroke = edgeStyle.color;
47054    let x1, y1, x2, y2;
47055    let width = "100%";
47056    let height = "100%";
47057    if (parent.w <= thickness) {
47058      [x1, y1, x2, y2] = ["50%", 0, "50%", "100%"];
47059      width = style.strokeWidth;
47060    } else if (parent.h <= thickness) {
47061      [x1, y1, x2, y2] = [0, "50%", "100%", "50%"];
47062      height = style.strokeWidth;
47063    } else if (this.slope === "\\") {
47064      [x1, y1, x2, y2] = [0, 0, "100%", "100%"];
47065    } else {
47066      [x1, y1, x2, y2] = [0, "100%", "100%", 0];
47067    }
47068    const line = {
47069      name: "line",
47070      attributes: {
47071        xmlns: SVG_NS,
47072        x1,
47073        y1,
47074        x2,
47075        y2,
47076        style
47077      }
47078    };
47079    const svg = {
47080      name: "svg",
47081      children: [line],
47082      attributes: {
47083        xmlns: SVG_NS,
47084        width,
47085        height,
47086        style: {
47087          overflow: "visible"
47088        }
47089      }
47090    };
47091    if (hasMargin(parent)) {
47092      return HTMLResult.success({
47093        name: "div",
47094        attributes: {
47095          style: {
47096            display: "inline",
47097            width: "100%",
47098            height: "100%"
47099          }
47100        },
47101        children: [svg]
47102      });
47103    }
47104    svg.attributes.style.position = "absolute";
47105    return HTMLResult.success(svg);
47106  }
47107}
47108class Linear extends XFAObject {
47109  constructor(attributes) {
47110    super(TEMPLATE_NS_ID, "linear", true);
47111    this.id = attributes.id || "";
47112    this.type = getStringOption(attributes.type, ["toRight", "toBottom", "toLeft", "toTop"]);
47113    this.use = attributes.use || "";
47114    this.usehref = attributes.usehref || "";
47115    this.color = null;
47116    this.extras = null;
47117  }
47118  [$toStyle](startColor) {
47119    startColor = startColor ? startColor[$toStyle]() : "#FFFFFF";
47120    const transf = this.type.replace(/([RBLT])/, " $1").toLowerCase();
47121    const endColor = this.color ? this.color[$toStyle]() : "#000000";
47122    return `linear-gradient(${transf}, ${startColor}, ${endColor})`;
47123  }
47124}
47125class LockDocument extends ContentObject {
47126  constructor(attributes) {
47127    super(TEMPLATE_NS_ID, "lockDocument");
47128    this.id = attributes.id || "";
47129    this.type = getStringOption(attributes.type, ["optional", "required"]);
47130    this.use = attributes.use || "";
47131    this.usehref = attributes.usehref || "";
47132  }
47133  [$finalize]() {
47134    this[$content] = getStringOption(this[$content], ["auto", "0", "1"]);
47135  }
47136}
47137class Manifest extends XFAObject {
47138  constructor(attributes) {
47139    super(TEMPLATE_NS_ID, "manifest", true);
47140    this.action = getStringOption(attributes.action, ["include", "all", "exclude"]);
47141    this.id = attributes.id || "";
47142    this.name = attributes.name || "";
47143    this.use = attributes.use || "";
47144    this.usehref = attributes.usehref || "";
47145    this.extras = null;
47146    this.ref = new XFAObjectArray();
47147  }
47148}
47149class Margin extends XFAObject {
47150  constructor(attributes) {
47151    super(TEMPLATE_NS_ID, "margin", true);
47152    this.bottomInset = getMeasurement(attributes.bottomInset, "0");
47153    this.id = attributes.id || "";
47154    this.leftInset = getMeasurement(attributes.leftInset, "0");
47155    this.rightInset = getMeasurement(attributes.rightInset, "0");
47156    this.topInset = getMeasurement(attributes.topInset, "0");
47157    this.use = attributes.use || "";
47158    this.usehref = attributes.usehref || "";
47159    this.extras = null;
47160  }
47161  [$toStyle]() {
47162    return {
47163      margin: measureToString(this.topInset) + " " + measureToString(this.rightInset) + " " + measureToString(this.bottomInset) + " " + measureToString(this.leftInset)
47164    };
47165  }
47166}
47167class Mdp extends XFAObject {
47168  constructor(attributes) {
47169    super(TEMPLATE_NS_ID, "mdp");
47170    this.id = attributes.id || "";
47171    this.permissions = getInteger({
47172      data: attributes.permissions,
47173      defaultValue: 2,
47174      validate: x => x === 1 || x === 3
47175    });
47176    this.signatureType = getStringOption(attributes.signatureType, ["filler", "author"]);
47177    this.use = attributes.use || "";
47178    this.usehref = attributes.usehref || "";
47179  }
47180}
47181class Medium extends XFAObject {
47182  constructor(attributes) {
47183    super(TEMPLATE_NS_ID, "medium");
47184    this.id = attributes.id || "";
47185    this.imagingBBox = getBBox(attributes.imagingBBox);
47186    this.long = getMeasurement(attributes.long);
47187    this.orientation = getStringOption(attributes.orientation, ["portrait", "landscape"]);
47188    this.short = getMeasurement(attributes.short);
47189    this.stock = attributes.stock || "";
47190    this.trayIn = getStringOption(attributes.trayIn, ["auto", "delegate", "pageFront"]);
47191    this.trayOut = getStringOption(attributes.trayOut, ["auto", "delegate"]);
47192    this.use = attributes.use || "";
47193    this.usehref = attributes.usehref || "";
47194  }
47195}
47196class Message extends XFAObject {
47197  constructor(attributes) {
47198    super(TEMPLATE_NS_ID, "message", true);
47199    this.id = attributes.id || "";
47200    this.use = attributes.use || "";
47201    this.usehref = attributes.usehref || "";
47202    this.text = new XFAObjectArray();
47203  }
47204}
47205class NumericEdit extends XFAObject {
47206  constructor(attributes) {
47207    super(TEMPLATE_NS_ID, "numericEdit", true);
47208    this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, ["auto", "off", "on"]);
47209    this.id = attributes.id || "";
47210    this.use = attributes.use || "";
47211    this.usehref = attributes.usehref || "";
47212    this.border = null;
47213    this.comb = null;
47214    this.extras = null;
47215    this.margin = null;
47216  }
47217  [$toHTML](availableSpace) {
47218    const style = toStyle(this, "border", "font", "margin");
47219    const field = this[$getParent]()[$getParent]();
47220    const html = {
47221      name: "input",
47222      attributes: {
47223        type: "text",
47224        fieldId: field[$uid],
47225        dataId: field[$data]?.[$uid] || field[$uid],
47226        class: ["xfaTextfield"],
47227        style,
47228        "aria-label": ariaLabel(field),
47229        "aria-required": false
47230      }
47231    };
47232    if (isRequired(field)) {
47233      html.attributes["aria-required"] = true;
47234      html.attributes.required = true;
47235    }
47236    return HTMLResult.success({
47237      name: "label",
47238      attributes: {
47239        class: ["xfaLabel"]
47240      },
47241      children: [html]
47242    });
47243  }
47244}
47245class Occur extends XFAObject {
47246  constructor(attributes) {
47247    super(TEMPLATE_NS_ID, "occur", true);
47248    this.id = attributes.id || "";
47249    this.initial = attributes.initial !== "" ? getInteger({
47250      data: attributes.initial,
47251      defaultValue: "",
47252      validate: x => true
47253    }) : "";
47254    this.max = attributes.max !== "" ? getInteger({
47255      data: attributes.max,
47256      defaultValue: -1,
47257      validate: x => true
47258    }) : "";
47259    this.min = attributes.min !== "" ? getInteger({
47260      data: attributes.min,
47261      defaultValue: 1,
47262      validate: x => true
47263    }) : "";
47264    this.use = attributes.use || "";
47265    this.usehref = attributes.usehref || "";
47266    this.extras = null;
47267  }
47268  [$clean]() {
47269    const parent = this[$getParent]();
47270    const originalMin = this.min;
47271    if (this.min === "") {
47272      this.min = parent instanceof PageArea || parent instanceof PageSet ? 0 : 1;
47273    }
47274    if (this.max === "") {
47275      if (originalMin === "") {
47276        this.max = parent instanceof PageArea || parent instanceof PageSet ? -1 : 1;
47277      } else {
47278        this.max = this.min;
47279      }
47280    }
47281    if (this.max !== -1 && this.max < this.min) {
47282      this.max = this.min;
47283    }
47284    if (this.initial === "") {
47285      this.initial = parent instanceof Template ? 1 : this.min;
47286    }
47287  }
47288}
47289class Oid extends StringObject {
47290  constructor(attributes) {
47291    super(TEMPLATE_NS_ID, "oid");
47292    this.id = attributes.id || "";
47293    this.name = attributes.name || "";
47294    this.use = attributes.use || "";
47295    this.usehref = attributes.usehref || "";
47296  }
47297}
47298class Oids extends XFAObject {
47299  constructor(attributes) {
47300    super(TEMPLATE_NS_ID, "oids", true);
47301    this.id = attributes.id || "";
47302    this.type = getStringOption(attributes.type, ["optional", "required"]);
47303    this.use = attributes.use || "";
47304    this.usehref = attributes.usehref || "";
47305    this.oid = new XFAObjectArray();
47306  }
47307}
47308class Overflow extends XFAObject {
47309  constructor(attributes) {
47310    super(TEMPLATE_NS_ID, "overflow");
47311    this.id = attributes.id || "";
47312    this.leader = attributes.leader || "";
47313    this.target = attributes.target || "";
47314    this.trailer = attributes.trailer || "";
47315    this.use = attributes.use || "";
47316    this.usehref = attributes.usehref || "";
47317  }
47318  [$getExtra]() {
47319    if (!this[$extra]) {
47320      const parent = this[$getParent]();
47321      const root = this[$getTemplateRoot]();
47322      const target = root[$searchNode](this.target, parent);
47323      const leader = root[$searchNode](this.leader, parent);
47324      const trailer = root[$searchNode](this.trailer, parent);
47325      this[$extra] = {
47326        target: target?.[0] || null,
47327        leader: leader?.[0] || null,
47328        trailer: trailer?.[0] || null,
47329        addLeader: false,
47330        addTrailer: false
47331      };
47332    }
47333    return this[$extra];
47334  }
47335}
47336class PageArea extends XFAObject {
47337  constructor(attributes) {
47338    super(TEMPLATE_NS_ID, "pageArea", true);
47339    this.blankOrNotBlank = getStringOption(attributes.blankOrNotBlank, ["any", "blank", "notBlank"]);
47340    this.id = attributes.id || "";
47341    this.initialNumber = getInteger({
47342      data: attributes.initialNumber,
47343      defaultValue: 1,
47344      validate: x => true
47345    });
47346    this.name = attributes.name || "";
47347    this.numbered = getInteger({
47348      data: attributes.numbered,
47349      defaultValue: 1,
47350      validate: x => true
47351    });
47352    this.oddOrEven = getStringOption(attributes.oddOrEven, ["any", "even", "odd"]);
47353    this.pagePosition = getStringOption(attributes.pagePosition, ["any", "first", "last", "only", "rest"]);
47354    this.relevant = getRelevant(attributes.relevant);
47355    this.use = attributes.use || "";
47356    this.usehref = attributes.usehref || "";
47357    this.desc = null;
47358    this.extras = null;
47359    this.medium = null;
47360    this.occur = null;
47361    this.area = new XFAObjectArray();
47362    this.contentArea = new XFAObjectArray();
47363    this.draw = new XFAObjectArray();
47364    this.exclGroup = new XFAObjectArray();
47365    this.field = new XFAObjectArray();
47366    this.subform = new XFAObjectArray();
47367  }
47368  [$isUsable]() {
47369    if (!this[$extra]) {
47370      this[$extra] = {
47371        numberOfUse: 0
47372      };
47373      return true;
47374    }
47375    return !this.occur || this.occur.max === -1 || this[$extra].numberOfUse < this.occur.max;
47376  }
47377  [$cleanPage]() {
47378    delete this[$extra];
47379  }
47380  [$getNextPage]() {
47381    this[$extra] ||= {
47382      numberOfUse: 0
47383    };
47384    const parent = this[$getParent]();
47385    if (parent.relation === "orderedOccurrence") {
47386      if (this[$isUsable]()) {
47387        this[$extra].numberOfUse += 1;
47388        return this;
47389      }
47390    }
47391    return parent[$getNextPage]();
47392  }
47393  [$getAvailableSpace]() {
47394    return this[$extra].space || {
47395      width: 0,
47396      height: 0
47397    };
47398  }
47399  [$toHTML]() {
47400    this[$extra] ||= {
47401      numberOfUse: 1
47402    };
47403    const children = [];
47404    this[$extra].children = children;
47405    const style = Object.create(null);
47406    if (this.medium && this.medium.short && this.medium.long) {
47407      style.width = measureToString(this.medium.short);
47408      style.height = measureToString(this.medium.long);
47409      this[$extra].space = {
47410        width: this.medium.short,
47411        height: this.medium.long
47412      };
47413      if (this.medium.orientation === "landscape") {
47414        const x = style.width;
47415        style.width = style.height;
47416        style.height = x;
47417        this[$extra].space = {
47418          width: this.medium.long,
47419          height: this.medium.short
47420        };
47421      }
47422    } else {
47423      warn("XFA - No medium specified in pageArea: please file a bug.");
47424    }
47425    this[$childrenToHTML]({
47426      filter: new Set(["area", "draw", "field", "subform"]),
47427      include: true
47428    });
47429    this[$childrenToHTML]({
47430      filter: new Set(["contentArea"]),
47431      include: true
47432    });
47433    return HTMLResult.success({
47434      name: "div",
47435      children,
47436      attributes: {
47437        class: ["xfaPage"],
47438        id: this[$uid],
47439        style,
47440        xfaName: this.name
47441      }
47442    });
47443  }
47444}
47445class PageSet extends XFAObject {
47446  constructor(attributes) {
47447    super(TEMPLATE_NS_ID, "pageSet", true);
47448    this.duplexImposition = getStringOption(attributes.duplexImposition, ["longEdge", "shortEdge"]);
47449    this.id = attributes.id || "";
47450    this.name = attributes.name || "";
47451    this.relation = getStringOption(attributes.relation, ["orderedOccurrence", "duplexPaginated", "simplexPaginated"]);
47452    this.relevant = getRelevant(attributes.relevant);
47453    this.use = attributes.use || "";
47454    this.usehref = attributes.usehref || "";
47455    this.extras = null;
47456    this.occur = null;
47457    this.pageArea = new XFAObjectArray();
47458    this.pageSet = new XFAObjectArray();
47459  }
47460  [$cleanPage]() {
47461    for (const page of this.pageArea.children) {
47462      page[$cleanPage]();
47463    }
47464    for (const page of this.pageSet.children) {
47465      page[$cleanPage]();
47466    }
47467  }
47468  [$isUsable]() {
47469    return !this.occur || this.occur.max === -1 || this[$extra].numberOfUse < this.occur.max;
47470  }
47471  [$getNextPage]() {
47472    this[$extra] ||= {
47473      numberOfUse: 1,
47474      pageIndex: -1,
47475      pageSetIndex: -1
47476    };
47477    if (this.relation === "orderedOccurrence") {
47478      if (this[$extra].pageIndex + 1 < this.pageArea.children.length) {
47479        this[$extra].pageIndex += 1;
47480        const pageArea = this.pageArea.children[this[$extra].pageIndex];
47481        return pageArea[$getNextPage]();
47482      }
47483      if (this[$extra].pageSetIndex + 1 < this.pageSet.children.length) {
47484        this[$extra].pageSetIndex += 1;
47485        return this.pageSet.children[this[$extra].pageSetIndex][$getNextPage]();
47486      }
47487      if (this[$isUsable]()) {
47488        this[$extra].numberOfUse += 1;
47489        this[$extra].pageIndex = -1;
47490        this[$extra].pageSetIndex = -1;
47491        return this[$getNextPage]();
47492      }
47493      const parent = this[$getParent]();
47494      if (parent instanceof PageSet) {
47495        return parent[$getNextPage]();
47496      }
47497      this[$cleanPage]();
47498      return this[$getNextPage]();
47499    }
47500    const pageNumber = this[$getTemplateRoot]()[$extra].pageNumber;
47501    const parity = pageNumber % 2 === 0 ? "even" : "odd";
47502    const position = pageNumber === 0 ? "first" : "rest";
47503    let page = this.pageArea.children.find(p => p.oddOrEven === parity && p.pagePosition === position);
47504    if (page) {
47505      return page;
47506    }
47507    page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === position);
47508    if (page) {
47509      return page;
47510    }
47511    page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === "any");
47512    if (page) {
47513      return page;
47514    }
47515    return this.pageArea.children[0];
47516  }
47517}
47518class Para extends XFAObject {
47519  constructor(attributes) {
47520    super(TEMPLATE_NS_ID, "para", true);
47521    this.hAlign = getStringOption(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
47522    this.id = attributes.id || "";
47523    this.lineHeight = attributes.lineHeight ? getMeasurement(attributes.lineHeight, "0pt") : "";
47524    this.marginLeft = attributes.marginLeft ? getMeasurement(attributes.marginLeft, "0pt") : "";
47525    this.marginRight = attributes.marginRight ? getMeasurement(attributes.marginRight, "0pt") : "";
47526    this.orphans = getInteger({
47527      data: attributes.orphans,
47528      defaultValue: 0,
47529      validate: x => x >= 0
47530    });
47531    this.preserve = attributes.preserve || "";
47532    this.radixOffset = attributes.radixOffset ? getMeasurement(attributes.radixOffset, "0pt") : "";
47533    this.spaceAbove = attributes.spaceAbove ? getMeasurement(attributes.spaceAbove, "0pt") : "";
47534    this.spaceBelow = attributes.spaceBelow ? getMeasurement(attributes.spaceBelow, "0pt") : "";
47535    this.tabDefault = attributes.tabDefault ? getMeasurement(this.tabDefault) : "";
47536    this.tabStops = (attributes.tabStops || "").trim().split(/\s+/).map((x, i) => i % 2 === 1 ? getMeasurement(x) : x);
47537    this.textIndent = attributes.textIndent ? getMeasurement(attributes.textIndent, "0pt") : "";
47538    this.use = attributes.use || "";
47539    this.usehref = attributes.usehref || "";
47540    this.vAlign = getStringOption(attributes.vAlign, ["top", "bottom", "middle"]);
47541    this.widows = getInteger({
47542      data: attributes.widows,
47543      defaultValue: 0,
47544      validate: x => x >= 0
47545    });
47546    this.hyphenation = null;
47547  }
47548  [$toStyle]() {
47549    const style = toStyle(this, "hAlign");
47550    if (this.marginLeft !== "") {
47551      style.paddingLeft = measureToString(this.marginLeft);
47552    }
47553    if (this.marginRight !== "") {
47554      style.paddingRight = measureToString(this.marginRight);
47555    }
47556    if (this.spaceAbove !== "") {
47557      style.paddingTop = measureToString(this.spaceAbove);
47558    }
47559    if (this.spaceBelow !== "") {
47560      style.paddingBottom = measureToString(this.spaceBelow);
47561    }
47562    if (this.textIndent !== "") {
47563      style.textIndent = measureToString(this.textIndent);
47564      fixTextIndent(style);
47565    }
47566    if (this.lineHeight > 0) {
47567      style.lineHeight = measureToString(this.lineHeight);
47568    }
47569    if (this.tabDefault !== "") {
47570      style.tabSize = measureToString(this.tabDefault);
47571    }
47572    if (this.tabStops.length > 0) {}
47573    if (this.hyphenatation) {
47574      Object.assign(style, this.hyphenatation[$toStyle]());
47575    }
47576    return style;
47577  }
47578}
47579class PasswordEdit extends XFAObject {
47580  constructor(attributes) {
47581    super(TEMPLATE_NS_ID, "passwordEdit", true);
47582    this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, ["auto", "off", "on"]);
47583    this.id = attributes.id || "";
47584    this.passwordChar = attributes.passwordChar || "*";
47585    this.use = attributes.use || "";
47586    this.usehref = attributes.usehref || "";
47587    this.border = null;
47588    this.extras = null;
47589    this.margin = null;
47590  }
47591}
47592class template_Pattern extends XFAObject {
47593  constructor(attributes) {
47594    super(TEMPLATE_NS_ID, "pattern", true);
47595    this.id = attributes.id || "";
47596    this.type = getStringOption(attributes.type, ["crossHatch", "crossDiagonal", "diagonalLeft", "diagonalRight", "horizontal", "vertical"]);
47597    this.use = attributes.use || "";
47598    this.usehref = attributes.usehref || "";
47599    this.color = null;
47600    this.extras = null;
47601  }
47602  [$toStyle](startColor) {
47603    startColor = startColor ? startColor[$toStyle]() : "#FFFFFF";
47604    const endColor = this.color ? this.color[$toStyle]() : "#000000";
47605    const width = 5;
47606    const cmd = "repeating-linear-gradient";
47607    const colors = `${startColor},${startColor} ${width}px,${endColor} ${width}px,${endColor} ${2 * width}px`;
47608    switch (this.type) {
47609      case "crossHatch":
47610        return `${cmd}(to top,${colors}) ${cmd}(to right,${colors})`;
47611      case "crossDiagonal":
47612        return `${cmd}(45deg,${colors}) ${cmd}(-45deg,${colors})`;
47613      case "diagonalLeft":
47614        return `${cmd}(45deg,${colors})`;
47615      case "diagonalRight":
47616        return `${cmd}(-45deg,${colors})`;
47617      case "horizontal":
47618        return `${cmd}(to top,${colors})`;
47619      case "vertical":
47620        return `${cmd}(to right,${colors})`;
47621    }
47622    return "";
47623  }
47624}
47625class Picture extends StringObject {
47626  constructor(attributes) {
47627    super(TEMPLATE_NS_ID, "picture");
47628    this.id = attributes.id || "";
47629    this.use = attributes.use || "";
47630    this.usehref = attributes.usehref || "";
47631  }
47632}
47633class Proto extends XFAObject {
47634  constructor(attributes) {
47635    super(TEMPLATE_NS_ID, "proto", true);
47636    this.appearanceFilter = new XFAObjectArray();
47637    this.arc = new XFAObjectArray();
47638    this.area = new XFAObjectArray();
47639    this.assist = new XFAObjectArray();
47640    this.barcode = new XFAObjectArray();
47641    this.bindItems = new XFAObjectArray();
47642    this.bookend = new XFAObjectArray();
47643    this.boolean = new XFAObjectArray();
47644    this.border = new XFAObjectArray();
47645    this.break = new XFAObjectArray();
47646    this.breakAfter = new XFAObjectArray();
47647    this.breakBefore = new XFAObjectArray();
47648    this.button = new XFAObjectArray();
47649    this.calculate = new XFAObjectArray();
47650    this.caption = new XFAObjectArray();
47651    this.certificate = new XFAObjectArray();
47652    this.certificates = new XFAObjectArray();
47653    this.checkButton = new XFAObjectArray();
47654    this.choiceList = new XFAObjectArray();
47655    this.color = new XFAObjectArray();
47656    this.comb = new XFAObjectArray();
47657    this.connect = new XFAObjectArray();
47658    this.contentArea = new XFAObjectArray();
47659    this.corner = new XFAObjectArray();
47660    this.date = new XFAObjectArray();
47661    this.dateTime = new XFAObjectArray();
47662    this.dateTimeEdit = new XFAObjectArray();
47663    this.decimal = new XFAObjectArray();
47664    this.defaultUi = new XFAObjectArray();
47665    this.desc = new XFAObjectArray();
47666    this.digestMethod = new XFAObjectArray();
47667    this.digestMethods = new XFAObjectArray();
47668    this.draw = new XFAObjectArray();
47669    this.edge = new XFAObjectArray();
47670    this.encoding = new XFAObjectArray();
47671    this.encodings = new XFAObjectArray();
47672    this.encrypt = new XFAObjectArray();
47673    this.encryptData = new XFAObjectArray();
47674    this.encryption = new XFAObjectArray();
47675    this.encryptionMethod = new XFAObjectArray();
47676    this.encryptionMethods = new XFAObjectArray();
47677    this.event = new XFAObjectArray();
47678    this.exData = new XFAObjectArray();
47679    this.exObject = new XFAObjectArray();
47680    this.exclGroup = new XFAObjectArray();
47681    this.execute = new XFAObjectArray();
47682    this.extras = new XFAObjectArray();
47683    this.field = new XFAObjectArray();
47684    this.fill = new XFAObjectArray();
47685    this.filter = new XFAObjectArray();
47686    this.float = new XFAObjectArray();
47687    this.font = new XFAObjectArray();
47688    this.format = new XFAObjectArray();
47689    this.handler = new XFAObjectArray();
47690    this.hyphenation = new XFAObjectArray();
47691    this.image = new XFAObjectArray();
47692    this.imageEdit = new XFAObjectArray();
47693    this.integer = new XFAObjectArray();
47694    this.issuers = new XFAObjectArray();
47695    this.items = new XFAObjectArray();
47696    this.keep = new XFAObjectArray();
47697    this.keyUsage = new XFAObjectArray();
47698    this.line = new XFAObjectArray();
47699    this.linear = new XFAObjectArray();
47700    this.lockDocument = new XFAObjectArray();
47701    this.manifest = new XFAObjectArray();
47702    this.margin = new XFAObjectArray();
47703    this.mdp = new XFAObjectArray();
47704    this.medium = new XFAObjectArray();
47705    this.message = new XFAObjectArray();
47706    this.numericEdit = new XFAObjectArray();
47707    this.occur = new XFAObjectArray();
47708    this.oid = new XFAObjectArray();
47709    this.oids = new XFAObjectArray();
47710    this.overflow = new XFAObjectArray();
47711    this.pageArea = new XFAObjectArray();
47712    this.pageSet = new XFAObjectArray();
47713    this.para = new XFAObjectArray();
47714    this.passwordEdit = new XFAObjectArray();
47715    this.pattern = new XFAObjectArray();
47716    this.picture = new XFAObjectArray();
47717    this.radial = new XFAObjectArray();
47718    this.reason = new XFAObjectArray();
47719    this.reasons = new XFAObjectArray();
47720    this.rectangle = new XFAObjectArray();
47721    this.ref = new XFAObjectArray();
47722    this.script = new XFAObjectArray();
47723    this.setProperty = new XFAObjectArray();
47724    this.signData = new XFAObjectArray();
47725    this.signature = new XFAObjectArray();
47726    this.signing = new XFAObjectArray();
47727    this.solid = new XFAObjectArray();
47728    this.speak = new XFAObjectArray();
47729    this.stipple = new XFAObjectArray();
47730    this.subform = new XFAObjectArray();
47731    this.subformSet = new XFAObjectArray();
47732    this.subjectDN = new XFAObjectArray();
47733    this.subjectDNs = new XFAObjectArray();
47734    this.submit = new XFAObjectArray();
47735    this.text = new XFAObjectArray();
47736    this.textEdit = new XFAObjectArray();
47737    this.time = new XFAObjectArray();
47738    this.timeStamp = new XFAObjectArray();
47739    this.toolTip = new XFAObjectArray();
47740    this.traversal = new XFAObjectArray();
47741    this.traverse = new XFAObjectArray();
47742    this.ui = new XFAObjectArray();
47743    this.validate = new XFAObjectArray();
47744    this.value = new XFAObjectArray();
47745    this.variables = new XFAObjectArray();
47746  }
47747}
47748class Radial extends XFAObject {
47749  constructor(attributes) {
47750    super(TEMPLATE_NS_ID, "radial", true);
47751    this.id = attributes.id || "";
47752    this.type = getStringOption(attributes.type, ["toEdge", "toCenter"]);
47753    this.use = attributes.use || "";
47754    this.usehref = attributes.usehref || "";
47755    this.color = null;
47756    this.extras = null;
47757  }
47758  [$toStyle](startColor) {
47759    startColor = startColor ? startColor[$toStyle]() : "#FFFFFF";
47760    const endColor = this.color ? this.color[$toStyle]() : "#000000";
47761    const colors = this.type === "toEdge" ? `${startColor},${endColor}` : `${endColor},${startColor}`;
47762    return `radial-gradient(circle at center, ${colors})`;
47763  }
47764}
47765class Reason extends StringObject {
47766  constructor(attributes) {
47767    super(TEMPLATE_NS_ID, "reason");
47768    this.id = attributes.id || "";
47769    this.name = attributes.name || "";
47770    this.use = attributes.use || "";
47771    this.usehref = attributes.usehref || "";
47772  }
47773}
47774class Reasons extends XFAObject {
47775  constructor(attributes) {
47776    super(TEMPLATE_NS_ID, "reasons", true);
47777    this.id = attributes.id || "";
47778    this.type = getStringOption(attributes.type, ["optional", "required"]);
47779    this.use = attributes.use || "";
47780    this.usehref = attributes.usehref || "";
47781    this.reason = new XFAObjectArray();
47782  }
47783}
47784class Rectangle extends XFAObject {
47785  constructor(attributes) {
47786    super(TEMPLATE_NS_ID, "rectangle", true);
47787    this.hand = getStringOption(attributes.hand, ["even", "left", "right"]);
47788    this.id = attributes.id || "";
47789    this.use = attributes.use || "";
47790    this.usehref = attributes.usehref || "";
47791    this.corner = new XFAObjectArray(4);
47792    this.edge = new XFAObjectArray(4);
47793    this.fill = null;
47794  }
47795  [$toHTML]() {
47796    const edge = this.edge.children.length ? this.edge.children[0] : new Edge({});
47797    const edgeStyle = edge[$toStyle]();
47798    const style = Object.create(null);
47799    if (this.fill?.presence === "visible") {
47800      Object.assign(style, this.fill[$toStyle]());
47801    } else {
47802      style.fill = "transparent";
47803    }
47804    style.strokeWidth = measureToString(edge.presence === "visible" ? edge.thickness : 0);
47805    style.stroke = edgeStyle.color;
47806    const corner = this.corner.children.length ? this.corner.children[0] : new Corner({});
47807    const cornerStyle = corner[$toStyle]();
47808    const rect = {
47809      name: "rect",
47810      attributes: {
47811        xmlns: SVG_NS,
47812        width: "100%",
47813        height: "100%",
47814        x: 0,
47815        y: 0,
47816        rx: cornerStyle.radius,
47817        ry: cornerStyle.radius,
47818        style
47819      }
47820    };
47821    const svg = {
47822      name: "svg",
47823      children: [rect],
47824      attributes: {
47825        xmlns: SVG_NS,
47826        style: {
47827          overflow: "visible"
47828        },
47829        width: "100%",
47830        height: "100%"
47831      }
47832    };
47833    const parent = this[$getParent]()[$getParent]();
47834    if (hasMargin(parent)) {
47835      return HTMLResult.success({
47836        name: "div",
47837        attributes: {
47838          style: {
47839            display: "inline",
47840            width: "100%",
47841            height: "100%"
47842          }
47843        },
47844        children: [svg]
47845      });
47846    }
47847    svg.attributes.style.position = "absolute";
47848    return HTMLResult.success(svg);
47849  }
47850}
47851class RefElement extends StringObject {
47852  constructor(attributes) {
47853    super(TEMPLATE_NS_ID, "ref");
47854    this.id = attributes.id || "";
47855    this.use = attributes.use || "";
47856    this.usehref = attributes.usehref || "";
47857  }
47858}
47859class Script extends StringObject {
47860  constructor(attributes) {
47861    super(TEMPLATE_NS_ID, "script");
47862    this.binding = attributes.binding || "";
47863    this.contentType = attributes.contentType || "";
47864    this.id = attributes.id || "";
47865    this.name = attributes.name || "";
47866    this.runAt = getStringOption(attributes.runAt, ["client", "both", "server"]);
47867    this.use = attributes.use || "";
47868    this.usehref = attributes.usehref || "";
47869  }
47870}
47871class SetProperty extends XFAObject {
47872  constructor(attributes) {
47873    super(TEMPLATE_NS_ID, "setProperty");
47874    this.connection = attributes.connection || "";
47875    this.ref = attributes.ref || "";
47876    this.target = attributes.target || "";
47877  }
47878}
47879class SignData extends XFAObject {
47880  constructor(attributes) {
47881    super(TEMPLATE_NS_ID, "signData", true);
47882    this.id = attributes.id || "";
47883    this.operation = getStringOption(attributes.operation, ["sign", "clear", "verify"]);
47884    this.ref = attributes.ref || "";
47885    this.target = attributes.target || "";
47886    this.use = attributes.use || "";
47887    this.usehref = attributes.usehref || "";
47888    this.filter = null;
47889    this.manifest = null;
47890  }
47891}
47892class Signature extends XFAObject {
47893  constructor(attributes) {
47894    super(TEMPLATE_NS_ID, "signature", true);
47895    this.id = attributes.id || "";
47896    this.type = getStringOption(attributes.type, ["PDF1.3", "PDF1.6"]);
47897    this.use = attributes.use || "";
47898    this.usehref = attributes.usehref || "";
47899    this.border = null;
47900    this.extras = null;
47901    this.filter = null;
47902    this.manifest = null;
47903    this.margin = null;
47904  }
47905}
47906class Signing extends XFAObject {
47907  constructor(attributes) {
47908    super(TEMPLATE_NS_ID, "signing", true);
47909    this.id = attributes.id || "";
47910    this.type = getStringOption(attributes.type, ["optional", "required"]);
47911    this.use = attributes.use || "";
47912    this.usehref = attributes.usehref || "";
47913    this.certificate = new XFAObjectArray();
47914  }
47915}
47916class Solid extends XFAObject {
47917  constructor(attributes) {
47918    super(TEMPLATE_NS_ID, "solid", true);
47919    this.id = attributes.id || "";
47920    this.use = attributes.use || "";
47921    this.usehref = attributes.usehref || "";
47922    this.extras = null;
47923  }
47924  [$toStyle](startColor) {
47925    return startColor ? startColor[$toStyle]() : "#FFFFFF";
47926  }
47927}
47928class Speak extends StringObject {
47929  constructor(attributes) {
47930    super(TEMPLATE_NS_ID, "speak");
47931    this.disable = getInteger({
47932      data: attributes.disable,
47933      defaultValue: 0,
47934      validate: x => x === 1
47935    });
47936    this.id = attributes.id || "";
47937    this.priority = getStringOption(attributes.priority, ["custom", "caption", "name", "toolTip"]);
47938    this.rid = attributes.rid || "";
47939    this.use = attributes.use || "";
47940    this.usehref = attributes.usehref || "";
47941  }
47942}
47943class Stipple extends XFAObject {
47944  constructor(attributes) {
47945    super(TEMPLATE_NS_ID, "stipple", true);
47946    this.id = attributes.id || "";
47947    this.rate = getInteger({
47948      data: attributes.rate,
47949      defaultValue: 50,
47950      validate: x => x >= 0 && x <= 100
47951    });
47952    this.use = attributes.use || "";
47953    this.usehref = attributes.usehref || "";
47954    this.color = null;
47955    this.extras = null;
47956  }
47957  [$toStyle](bgColor) {
47958    const alpha = this.rate / 100;
47959    return Util.makeHexColor(Math.round(bgColor.value.r * (1 - alpha) + this.value.r * alpha), Math.round(bgColor.value.g * (1 - alpha) + this.value.g * alpha), Math.round(bgColor.value.b * (1 - alpha) + this.value.b * alpha));
47960  }
47961}
47962class Subform extends XFAObject {
47963  constructor(attributes) {
47964    super(TEMPLATE_NS_ID, "subform", true);
47965    this.access = getStringOption(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
47966    this.allowMacro = getInteger({
47967      data: attributes.allowMacro,
47968      defaultValue: 0,
47969      validate: x => x === 1
47970    });
47971    this.anchorType = getStringOption(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
47972    this.colSpan = getInteger({
47973      data: attributes.colSpan,
47974      defaultValue: 1,
47975      validate: n => n >= 1 || n === -1
47976    });
47977    this.columnWidths = (attributes.columnWidths || "").trim().split(/\s+/).map(x => x === "-1" ? -1 : getMeasurement(x));
47978    this.h = attributes.h ? getMeasurement(attributes.h) : "";
47979    this.hAlign = getStringOption(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
47980    this.id = attributes.id || "";
47981    this.layout = getStringOption(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
47982    this.locale = attributes.locale || "";
47983    this.maxH = getMeasurement(attributes.maxH, "0pt");
47984    this.maxW = getMeasurement(attributes.maxW, "0pt");
47985    this.mergeMode = getStringOption(attributes.mergeMode, ["consumeData", "matchTemplate"]);
47986    this.minH = getMeasurement(attributes.minH, "0pt");
47987    this.minW = getMeasurement(attributes.minW, "0pt");
47988    this.name = attributes.name || "";
47989    this.presence = getStringOption(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
47990    this.relevant = getRelevant(attributes.relevant);
47991    this.restoreState = getStringOption(attributes.restoreState, ["manual", "auto"]);
47992    this.scope = getStringOption(attributes.scope, ["name", "none"]);
47993    this.use = attributes.use || "";
47994    this.usehref = attributes.usehref || "";
47995    this.w = attributes.w ? getMeasurement(attributes.w) : "";
47996    this.x = getMeasurement(attributes.x, "0pt");
47997    this.y = getMeasurement(attributes.y, "0pt");
47998    this.assist = null;
47999    this.bind = null;
48000    this.bookend = null;
48001    this.border = null;
48002    this.break = null;
48003    this.calculate = null;
48004    this.desc = null;
48005    this.extras = null;
48006    this.keep = null;
48007    this.margin = null;
48008    this.occur = null;
48009    this.overflow = null;
48010    this.pageSet = null;
48011    this.para = null;
48012    this.traversal = null;
48013    this.validate = null;
48014    this.variables = null;
48015    this.area = new XFAObjectArray();
48016    this.breakAfter = new XFAObjectArray();
48017    this.breakBefore = new XFAObjectArray();
48018    this.connect = new XFAObjectArray();
48019    this.draw = new XFAObjectArray();
48020    this.event = new XFAObjectArray();
48021    this.exObject = new XFAObjectArray();
48022    this.exclGroup = new XFAObjectArray();
48023    this.field = new XFAObjectArray();
48024    this.proto = new XFAObjectArray();
48025    this.setProperty = new XFAObjectArray();
48026    this.subform = new XFAObjectArray();
48027    this.subformSet = new XFAObjectArray();
48028  }
48029  [$getSubformParent]() {
48030    const parent = this[$getParent]();
48031    if (parent instanceof SubformSet) {
48032      return parent[$getSubformParent]();
48033    }
48034    return parent;
48035  }
48036  [$isBindable]() {
48037    return true;
48038  }
48039  [$isThereMoreWidth]() {
48040    return this.layout.endsWith("-tb") && this[$extra].attempt === 0 && this[$extra].numberInLine > 0 || this[$getParent]()[$isThereMoreWidth]();
48041  }
48042  *[$getContainedChildren]() {
48043    yield* getContainedChildren(this);
48044  }
48045  [$flushHTML]() {
48046    return flushHTML(this);
48047  }
48048  [$addHTML](html, bbox) {
48049    addHTML(this, html, bbox);
48050  }
48051  [$getAvailableSpace]() {
48052    return getAvailableSpace(this);
48053  }
48054  [$isSplittable]() {
48055    const parent = this[$getSubformParent]();
48056    if (!parent[$isSplittable]()) {
48057      return false;
48058    }
48059    if (this[$extra]._isSplittable !== undefined) {
48060      return this[$extra]._isSplittable;
48061    }
48062    if (this.layout === "position" || this.layout.includes("row")) {
48063      this[$extra]._isSplittable = false;
48064      return false;
48065    }
48066    if (this.keep && this.keep.intact !== "none") {
48067      this[$extra]._isSplittable = false;
48068      return false;
48069    }
48070    if (parent.layout?.endsWith("-tb") && parent[$extra].numberInLine !== 0) {
48071      return false;
48072    }
48073    this[$extra]._isSplittable = true;
48074    return true;
48075  }
48076  [$toHTML](availableSpace) {
48077    setTabIndex(this);
48078    if (this.break) {
48079      if (this.break.after !== "auto" || this.break.afterTarget !== "") {
48080        const node = new BreakAfter({
48081          targetType: this.break.after,
48082          target: this.break.afterTarget,
48083          startNew: this.break.startNew.toString()
48084        });
48085        node[$globalData] = this[$globalData];
48086        this[$appendChild](node);
48087        this.breakAfter.push(node);
48088      }
48089      if (this.break.before !== "auto" || this.break.beforeTarget !== "") {
48090        const node = new BreakBefore({
48091          targetType: this.break.before,
48092          target: this.break.beforeTarget,
48093          startNew: this.break.startNew.toString()
48094        });
48095        node[$globalData] = this[$globalData];
48096        this[$appendChild](node);
48097        this.breakBefore.push(node);
48098      }
48099      if (this.break.overflowTarget !== "") {
48100        const node = new Overflow({
48101          target: this.break.overflowTarget,
48102          leader: this.break.overflowLeader,
48103          trailer: this.break.overflowTrailer
48104        });
48105        node[$globalData] = this[$globalData];
48106        this[$appendChild](node);
48107        this.overflow.push(node);
48108      }
48109      this[$removeChild](this.break);
48110      this.break = null;
48111    }
48112    if (this.presence === "hidden" || this.presence === "inactive") {
48113      return HTMLResult.EMPTY;
48114    }
48115    if (this.breakBefore.children.length > 1 || this.breakAfter.children.length > 1) {
48116      warn("XFA - Several breakBefore or breakAfter in subforms: please file a bug.");
48117    }
48118    if (this.breakBefore.children.length >= 1) {
48119      const breakBefore = this.breakBefore.children[0];
48120      if (handleBreak(breakBefore)) {
48121        return HTMLResult.breakNode(breakBefore);
48122      }
48123    }
48124    if (this[$extra]?.afterBreakAfter) {
48125      return HTMLResult.EMPTY;
48126    }
48127    fixDimensions(this);
48128    const children = [];
48129    const attributes = {
48130      id: this[$uid],
48131      class: []
48132    };
48133    setAccess(this, attributes.class);
48134    this[$extra] ||= Object.create(null);
48135    Object.assign(this[$extra], {
48136      children,
48137      line: null,
48138      attributes,
48139      attempt: 0,
48140      numberInLine: 0,
48141      availableSpace: {
48142        width: Math.min(this.w || Infinity, availableSpace.width),
48143        height: Math.min(this.h || Infinity, availableSpace.height)
48144      },
48145      width: 0,
48146      height: 0,
48147      prevHeight: 0,
48148      currentWidth: 0
48149    });
48150    const root = this[$getTemplateRoot]();
48151    const savedNoLayoutFailure = root[$extra].noLayoutFailure;
48152    const isSplittable = this[$isSplittable]();
48153    if (!isSplittable) {
48154      setFirstUnsplittable(this);
48155    }
48156    if (!checkDimensions(this, availableSpace)) {
48157      return HTMLResult.FAILURE;
48158    }
48159    const filter = new Set(["area", "draw", "exclGroup", "field", "subform", "subformSet"]);
48160    if (this.layout.includes("row")) {
48161      const columnWidths = this[$getSubformParent]().columnWidths;
48162      if (Array.isArray(columnWidths) && columnWidths.length > 0) {
48163        this[$extra].columnWidths = columnWidths;
48164        this[$extra].currentColumn = 0;
48165      }
48166    }
48167    const style = toStyle(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
48168    const classNames = ["xfaSubform"];
48169    const cl = layoutClass(this);
48170    if (cl) {
48171      classNames.push(cl);
48172    }
48173    attributes.style = style;
48174    attributes.class = classNames;
48175    if (this.name) {
48176      attributes.xfaName = this.name;
48177    }
48178    if (this.overflow) {
48179      const overflowExtra = this.overflow[$getExtra]();
48180      if (overflowExtra.addLeader) {
48181        overflowExtra.addLeader = false;
48182        handleOverflow(this, overflowExtra.leader, availableSpace);
48183      }
48184    }
48185    this[$pushPara]();
48186    const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
48187    const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
48188    for (; this[$extra].attempt < maxRun; this[$extra].attempt++) {
48189      if (isLrTb && this[$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
48190        this[$extra].numberInLine = 0;
48191      }
48192      const result = this[$childrenToHTML]({
48193        filter,
48194        include: true
48195      });
48196      if (result.success) {
48197        break;
48198      }
48199      if (result.isBreak()) {
48200        this[$popPara]();
48201        return result;
48202      }
48203      if (isLrTb && this[$extra].attempt === 0 && this[$extra].numberInLine === 0 && !root[$extra].noLayoutFailure) {
48204        this[$extra].attempt = maxRun;
48205        break;
48206      }
48207    }
48208    this[$popPara]();
48209    if (!isSplittable) {
48210      unsetFirstUnsplittable(this);
48211    }
48212    root[$extra].noLayoutFailure = savedNoLayoutFailure;
48213    if (this[$extra].attempt === maxRun) {
48214      if (this.overflow) {
48215        this[$getTemplateRoot]()[$extra].overflowNode = this.overflow;
48216      }
48217      if (!isSplittable) {
48218        delete this[$extra];
48219      }
48220      return HTMLResult.FAILURE;
48221    }
48222    if (this.overflow) {
48223      const overflowExtra = this.overflow[$getExtra]();
48224      if (overflowExtra.addTrailer) {
48225        overflowExtra.addTrailer = false;
48226        handleOverflow(this, overflowExtra.trailer, availableSpace);
48227      }
48228    }
48229    let marginH = 0;
48230    let marginV = 0;
48231    if (this.margin) {
48232      marginH = this.margin.leftInset + this.margin.rightInset;
48233      marginV = this.margin.topInset + this.margin.bottomInset;
48234    }
48235    const width = Math.max(this[$extra].width + marginH, this.w || 0);
48236    const height = Math.max(this[$extra].height + marginV, this.h || 0);
48237    const bbox = [this.x, this.y, width, height];
48238    if (this.w === "") {
48239      style.width = measureToString(width);
48240    }
48241    if (this.h === "") {
48242      style.height = measureToString(height);
48243    }
48244    if ((style.width === "0px" || style.height === "0px") && children.length === 0) {
48245      return HTMLResult.EMPTY;
48246    }
48247    const html = {
48248      name: "div",
48249      attributes,
48250      children
48251    };
48252    applyAssist(this, attributes);
48253    const result = HTMLResult.success(createWrapper(this, html), bbox);
48254    if (this.breakAfter.children.length >= 1) {
48255      const breakAfter = this.breakAfter.children[0];
48256      if (handleBreak(breakAfter)) {
48257        this[$extra].afterBreakAfter = result;
48258        return HTMLResult.breakNode(breakAfter);
48259      }
48260    }
48261    delete this[$extra];
48262    return result;
48263  }
48264}
48265class SubformSet extends XFAObject {
48266  constructor(attributes) {
48267    super(TEMPLATE_NS_ID, "subformSet", true);
48268    this.id = attributes.id || "";
48269    this.name = attributes.name || "";
48270    this.relation = getStringOption(attributes.relation, ["ordered", "choice", "unordered"]);
48271    this.relevant = getRelevant(attributes.relevant);
48272    this.use = attributes.use || "";
48273    this.usehref = attributes.usehref || "";
48274    this.bookend = null;
48275    this.break = null;
48276    this.desc = null;
48277    this.extras = null;
48278    this.occur = null;
48279    this.overflow = null;
48280    this.breakAfter = new XFAObjectArray();
48281    this.breakBefore = new XFAObjectArray();
48282    this.subform = new XFAObjectArray();
48283    this.subformSet = new XFAObjectArray();
48284  }
48285  *[$getContainedChildren]() {
48286    yield* getContainedChildren(this);
48287  }
48288  [$getSubformParent]() {
48289    let parent = this[$getParent]();
48290    while (!(parent instanceof Subform)) {
48291      parent = parent[$getParent]();
48292    }
48293    return parent;
48294  }
48295  [$isBindable]() {
48296    return true;
48297  }
48298}
48299class SubjectDN extends ContentObject {
48300  constructor(attributes) {
48301    super(TEMPLATE_NS_ID, "subjectDN");
48302    this.delimiter = attributes.delimiter || ",";
48303    this.id = attributes.id || "";
48304    this.name = attributes.name || "";
48305    this.use = attributes.use || "";
48306    this.usehref = attributes.usehref || "";
48307  }
48308  [$finalize]() {
48309    this[$content] = new Map(this[$content].split(this.delimiter).map(kv => {
48310      kv = kv.split("=", 2);
48311      kv[0] = kv[0].trim();
48312      return kv;
48313    }));
48314  }
48315}
48316class SubjectDNs extends XFAObject {
48317  constructor(attributes) {
48318    super(TEMPLATE_NS_ID, "subjectDNs", true);
48319    this.id = attributes.id || "";
48320    this.type = getStringOption(attributes.type, ["optional", "required"]);
48321    this.use = attributes.use || "";
48322    this.usehref = attributes.usehref || "";
48323    this.subjectDN = new XFAObjectArray();
48324  }
48325}
48326class Submit extends XFAObject {
48327  constructor(attributes) {
48328    super(TEMPLATE_NS_ID, "submit", true);
48329    this.embedPDF = getInteger({
48330      data: attributes.embedPDF,
48331      defaultValue: 0,
48332      validate: x => x === 1
48333    });
48334    this.format = getStringOption(attributes.format, ["xdp", "formdata", "pdf", "urlencoded", "xfd", "xml"]);
48335    this.id = attributes.id || "";
48336    this.target = attributes.target || "";
48337    this.textEncoding = getKeyword({
48338      data: attributes.textEncoding ? attributes.textEncoding.toLowerCase() : "",
48339      defaultValue: "",
48340      validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
48341    });
48342    this.use = attributes.use || "";
48343    this.usehref = attributes.usehref || "";
48344    this.xdpContent = attributes.xdpContent || "";
48345    this.encrypt = null;
48346    this.encryptData = new XFAObjectArray();
48347    this.signData = new XFAObjectArray();
48348  }
48349}
48350class Template extends XFAObject {
48351  constructor(attributes) {
48352    super(TEMPLATE_NS_ID, "template", true);
48353    this.baseProfile = getStringOption(attributes.baseProfile, ["full", "interactiveForms"]);
48354    this.extras = null;
48355    this.subform = new XFAObjectArray();
48356  }
48357  [$finalize]() {
48358    if (this.subform.children.length === 0) {
48359      warn("XFA - No subforms in template node.");
48360    }
48361    if (this.subform.children.length >= 2) {
48362      warn("XFA - Several subforms in template node: please file a bug.");
48363    }
48364    this[$tabIndex] = DEFAULT_TAB_INDEX;
48365  }
48366  [$isSplittable]() {
48367    return true;
48368  }
48369  [$searchNode](expr, container) {
48370    if (expr.startsWith("#")) {
48371      return [this[$ids].get(expr.slice(1))];
48372    }
48373    return searchNode(this, container, expr, true, true);
48374  }
48375  *[$toPages]() {
48376    if (!this.subform.children.length) {
48377      return HTMLResult.success({
48378        name: "div",
48379        children: []
48380      });
48381    }
48382    this[$extra] = {
48383      overflowNode: null,
48384      firstUnsplittable: null,
48385      currentContentArea: null,
48386      currentPageArea: null,
48387      noLayoutFailure: false,
48388      pageNumber: 1,
48389      pagePosition: "first",
48390      oddOrEven: "odd",
48391      blankOrNotBlank: "nonBlank",
48392      paraStack: []
48393    };
48394    const root = this.subform.children[0];
48395    root.pageSet[$cleanPage]();
48396    const pageAreas = root.pageSet.pageArea.children;
48397    const mainHtml = {
48398      name: "div",
48399      children: []
48400    };
48401    let pageArea = null;
48402    let breakBefore = null;
48403    let breakBeforeTarget = null;
48404    if (root.breakBefore.children.length >= 1) {
48405      breakBefore = root.breakBefore.children[0];
48406      breakBeforeTarget = breakBefore.target;
48407    } else if (root.subform.children.length >= 1 && root.subform.children[0].breakBefore.children.length >= 1) {
48408      breakBefore = root.subform.children[0].breakBefore.children[0];
48409      breakBeforeTarget = breakBefore.target;
48410    } else if (root.break?.beforeTarget) {
48411      breakBefore = root.break;
48412      breakBeforeTarget = breakBefore.beforeTarget;
48413    } else if (root.subform.children.length >= 1 && root.subform.children[0].break?.beforeTarget) {
48414      breakBefore = root.subform.children[0].break;
48415      breakBeforeTarget = breakBefore.beforeTarget;
48416    }
48417    if (breakBefore) {
48418      const target = this[$searchNode](breakBeforeTarget, breakBefore[$getParent]());
48419      if (target instanceof PageArea) {
48420        pageArea = target;
48421        breakBefore[$extra] = {};
48422      }
48423    }
48424    pageArea ||= pageAreas[0];
48425    pageArea[$extra] = {
48426      numberOfUse: 1
48427    };
48428    const pageAreaParent = pageArea[$getParent]();
48429    pageAreaParent[$extra] = {
48430      numberOfUse: 1,
48431      pageIndex: pageAreaParent.pageArea.children.indexOf(pageArea),
48432      pageSetIndex: 0
48433    };
48434    let targetPageArea;
48435    let leader = null;
48436    let trailer = null;
48437    let hasSomething = true;
48438    let hasSomethingCounter = 0;
48439    let startIndex = 0;
48440    while (true) {
48441      if (!hasSomething) {
48442        mainHtml.children.pop();
48443        if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
48444          warn("XFA - Something goes wrong: please file a bug.");
48445          return mainHtml;
48446        }
48447      } else {
48448        hasSomethingCounter = 0;
48449      }
48450      targetPageArea = null;
48451      this[$extra].currentPageArea = pageArea;
48452      const page = pageArea[$toHTML]().html;
48453      mainHtml.children.push(page);
48454      if (leader) {
48455        this[$extra].noLayoutFailure = true;
48456        page.children.push(leader[$toHTML](pageArea[$extra].space).html);
48457        leader = null;
48458      }
48459      if (trailer) {
48460        this[$extra].noLayoutFailure = true;
48461        page.children.push(trailer[$toHTML](pageArea[$extra].space).html);
48462        trailer = null;
48463      }
48464      const contentAreas = pageArea.contentArea.children;
48465      const htmlContentAreas = page.children.filter(node => node.attributes.class.includes("xfaContentarea"));
48466      hasSomething = false;
48467      this[$extra].firstUnsplittable = null;
48468      this[$extra].noLayoutFailure = false;
48469      const flush = index => {
48470        const html = root[$flushHTML]();
48471        if (html) {
48472          hasSomething ||= html.children?.length > 0;
48473          htmlContentAreas[index].children.push(html);
48474        }
48475      };
48476      for (let i = startIndex, ii = contentAreas.length; i < ii; i++) {
48477        const contentArea = this[$extra].currentContentArea = contentAreas[i];
48478        const space = {
48479          width: contentArea.w,
48480          height: contentArea.h
48481        };
48482        startIndex = 0;
48483        if (leader) {
48484          htmlContentAreas[i].children.push(leader[$toHTML](space).html);
48485          leader = null;
48486        }
48487        if (trailer) {
48488          htmlContentAreas[i].children.push(trailer[$toHTML](space).html);
48489          trailer = null;
48490        }
48491        const html = root[$toHTML](space);
48492        if (html.success) {
48493          if (html.html) {
48494            hasSomething ||= html.html.children?.length > 0;
48495            htmlContentAreas[i].children.push(html.html);
48496          } else if (!hasSomething && mainHtml.children.length > 1) {
48497            mainHtml.children.pop();
48498          }
48499          return mainHtml;
48500        }
48501        if (html.isBreak()) {
48502          const node = html.breakNode;
48503          flush(i);
48504          if (node.targetType === "auto") {
48505            continue;
48506          }
48507          if (node.leader) {
48508            leader = this[$searchNode](node.leader, node[$getParent]());
48509            leader = leader ? leader[0] : null;
48510          }
48511          if (node.trailer) {
48512            trailer = this[$searchNode](node.trailer, node[$getParent]());
48513            trailer = trailer ? trailer[0] : null;
48514          }
48515          if (node.targetType === "pageArea") {
48516            targetPageArea = node[$extra].target;
48517            i = Infinity;
48518          } else if (!node[$extra].target) {
48519            i = node[$extra].index;
48520          } else {
48521            targetPageArea = node[$extra].target;
48522            startIndex = node[$extra].index + 1;
48523            i = Infinity;
48524          }
48525          continue;
48526        }
48527        if (this[$extra].overflowNode) {
48528          const node = this[$extra].overflowNode;
48529          this[$extra].overflowNode = null;
48530          const overflowExtra = node[$getExtra]();
48531          const target = overflowExtra.target;
48532          overflowExtra.addLeader = overflowExtra.leader !== null;
48533          overflowExtra.addTrailer = overflowExtra.trailer !== null;
48534          flush(i);
48535          const currentIndex = i;
48536          i = Infinity;
48537          if (target instanceof PageArea) {
48538            targetPageArea = target;
48539          } else if (target instanceof ContentArea) {
48540            const index = contentAreas.indexOf(target);
48541            if (index !== -1) {
48542              if (index > currentIndex) {
48543                i = index - 1;
48544              } else {
48545                startIndex = index;
48546              }
48547            } else {
48548              targetPageArea = target[$getParent]();
48549              startIndex = targetPageArea.contentArea.children.indexOf(target);
48550            }
48551          }
48552          continue;
48553        }
48554        flush(i);
48555      }
48556      this[$extra].pageNumber += 1;
48557      if (targetPageArea) {
48558        if (targetPageArea[$isUsable]()) {
48559          targetPageArea[$extra].numberOfUse += 1;
48560        } else {
48561          targetPageArea = null;
48562        }
48563      }
48564      pageArea = targetPageArea || pageArea[$getNextPage]();
48565      yield null;
48566    }
48567  }
48568}
48569class Text extends ContentObject {
48570  constructor(attributes) {
48571    super(TEMPLATE_NS_ID, "text");
48572    this.id = attributes.id || "";
48573    this.maxChars = getInteger({
48574      data: attributes.maxChars,
48575      defaultValue: 0,
48576      validate: x => x >= 0
48577    });
48578    this.name = attributes.name || "";
48579    this.rid = attributes.rid || "";
48580    this.use = attributes.use || "";
48581    this.usehref = attributes.usehref || "";
48582  }
48583  [$acceptWhitespace]() {
48584    return true;
48585  }
48586  [$onChild](child) {
48587    if (child[$namespaceId] === NamespaceIds.xhtml.id) {
48588      this[$content] = child;
48589      return true;
48590    }
48591    warn(`XFA - Invalid content in Text: ${child[$nodeName]}.`);
48592    return false;
vendor: 10,112 bytes, lines 48593-48944
48593  }
48594  [$onText](str) {
48595    if (this[$content] instanceof XFAObject) {
48596      return;
48597    }
48598    super[$onText](str);
48599  }
48600  [$finalize]() {
48601    if (typeof this[$content] === "string") {
48602      this[$content] = this[$content].replaceAll("\r\n", "\n");
48603    }
48604  }
48605  [$getExtra]() {
48606    if (typeof this[$content] === "string") {
48607      return this[$content].split(/[\u2029\u2028\n]/).filter(line => !!line).join("\n");
48608    }
48609    return this[$content][$text]();
48610  }
48611  [$toHTML](availableSpace) {
48612    if (typeof this[$content] === "string") {
48613      const html = valueToHtml(this[$content]).html;
48614      if (this[$content].includes("\u2029")) {
48615        html.name = "div";
48616        html.children = [];
48617        this[$content].split("\u2029").map(para => para.split(/[\u2028\n]/).flatMap(line => [{
48618          name: "span",
48619          value: line
48620        }, {
48621          name: "br"
48622        }])).forEach(lines => {
48623          html.children.push({
48624            name: "p",
48625            children: lines
48626          });
48627        });
48628      } else if (/[\u2028\n]/.test(this[$content])) {
48629        html.name = "div";
48630        html.children = [];
48631        this[$content].split(/[\u2028\n]/).forEach(line => {
48632          html.children.push({
48633            name: "span",
48634            value: line
48635          }, {
48636            name: "br"
48637          });
48638        });
48639      }
48640      return HTMLResult.success(html);
48641    }
48642    return this[$content][$toHTML](availableSpace);
48643  }
48644}
48645class TextEdit extends XFAObject {
48646  constructor(attributes) {
48647    super(TEMPLATE_NS_ID, "textEdit", true);
48648    this.allowRichText = getInteger({
48649      data: attributes.allowRichText,
48650      defaultValue: 0,
48651      validate: x => x === 1
48652    });
48653    this.hScrollPolicy = getStringOption(attributes.hScrollPolicy, ["auto", "off", "on"]);
48654    this.id = attributes.id || "";
48655    this.multiLine = getInteger({
48656      data: attributes.multiLine,
48657      defaultValue: "",
48658      validate: x => x === 0 || x === 1
48659    });
48660    this.use = attributes.use || "";
48661    this.usehref = attributes.usehref || "";
48662    this.vScrollPolicy = getStringOption(attributes.vScrollPolicy, ["auto", "off", "on"]);
48663    this.border = null;
48664    this.comb = null;
48665    this.extras = null;
48666    this.margin = null;
48667  }
48668  [$toHTML](availableSpace) {
48669    const style = toStyle(this, "border", "font", "margin");
48670    let html;
48671    const field = this[$getParent]()[$getParent]();
48672    if (this.multiLine === "") {
48673      this.multiLine = field instanceof Draw ? 1 : 0;
48674    }
48675    if (this.multiLine === 1) {
48676      html = {
48677        name: "textarea",
48678        attributes: {
48679          dataId: field[$data]?.[$uid] || field[$uid],
48680          fieldId: field[$uid],
48681          class: ["xfaTextfield"],
48682          style,
48683          "aria-label": ariaLabel(field),
48684          "aria-required": false
48685        }
48686      };
48687    } else {
48688      html = {
48689        name: "input",
48690        attributes: {
48691          type: "text",
48692          dataId: field[$data]?.[$uid] || field[$uid],
48693          fieldId: field[$uid],
48694          class: ["xfaTextfield"],
48695          style,
48696          "aria-label": ariaLabel(field),
48697          "aria-required": false
48698        }
48699      };
48700    }
48701    if (isRequired(field)) {
48702      html.attributes["aria-required"] = true;
48703      html.attributes.required = true;
48704    }
48705    return HTMLResult.success({
48706      name: "label",
48707      attributes: {
48708        class: ["xfaLabel"]
48709      },
48710      children: [html]
48711    });
48712  }
48713}
48714class Time extends StringObject {
48715  constructor(attributes) {
48716    super(TEMPLATE_NS_ID, "time");
48717    this.id = attributes.id || "";
48718    this.name = attributes.name || "";
48719    this.use = attributes.use || "";
48720    this.usehref = attributes.usehref || "";
48721  }
48722  [$finalize]() {
48723    const date = this[$content].trim();
48724    this[$content] = date ? new Date(date) : null;
48725  }
48726  [$toHTML](availableSpace) {
48727    return valueToHtml(this[$content] ? this[$content].toString() : "");
48728  }
48729}
48730class TimeStamp extends XFAObject {
48731  constructor(attributes) {
48732    super(TEMPLATE_NS_ID, "timeStamp");
48733    this.id = attributes.id || "";
48734    this.server = attributes.server || "";
48735    this.type = getStringOption(attributes.type, ["optional", "required"]);
48736    this.use = attributes.use || "";
48737    this.usehref = attributes.usehref || "";
48738  }
48739}
48740class ToolTip extends StringObject {
48741  constructor(attributes) {
48742    super(TEMPLATE_NS_ID, "toolTip");
48743    this.id = attributes.id || "";
48744    this.rid = attributes.rid || "";
48745    this.use = attributes.use || "";
48746    this.usehref = attributes.usehref || "";
48747  }
48748}
48749class Traversal extends XFAObject {
48750  constructor(attributes) {
48751    super(TEMPLATE_NS_ID, "traversal", true);
48752    this.id = attributes.id || "";
48753    this.use = attributes.use || "";
48754    this.usehref = attributes.usehref || "";
48755    this.extras = null;
48756    this.traverse = new XFAObjectArray();
48757  }
48758}
48759class Traverse extends XFAObject {
48760  constructor(attributes) {
48761    super(TEMPLATE_NS_ID, "traverse", true);
48762    this.id = attributes.id || "";
48763    this.operation = getStringOption(attributes.operation, ["next", "back", "down", "first", "left", "right", "up"]);
48764    this.ref = attributes.ref || "";
48765    this.use = attributes.use || "";
48766    this.usehref = attributes.usehref || "";
48767    this.extras = null;
48768    this.script = null;
48769  }
48770  get name() {
48771    return this.operation;
48772  }
48773  [$isTransparent]() {
48774    return false;
48775  }
48776}
48777class Ui extends XFAObject {
48778  constructor(attributes) {
48779    super(TEMPLATE_NS_ID, "ui", true);
48780    this.id = attributes.id || "";
48781    this.use = attributes.use || "";
48782    this.usehref = attributes.usehref || "";
48783    this.extras = null;
48784    this.picture = null;
48785    this.barcode = null;
48786    this.button = null;
48787    this.checkButton = null;
48788    this.choiceList = null;
48789    this.dateTimeEdit = null;
48790    this.defaultUi = null;
48791    this.imageEdit = null;
48792    this.numericEdit = null;
48793    this.passwordEdit = null;
48794    this.signature = null;
48795    this.textEdit = null;
48796  }
48797  [$getExtra]() {
48798    if (this[$extra] === undefined) {
48799      for (const name of Object.getOwnPropertyNames(this)) {
48800        if (name === "extras" || name === "picture") {
48801          continue;
48802        }
48803        const obj = this[name];
48804        if (!(obj instanceof XFAObject)) {
48805          continue;
48806        }
48807        this[$extra] = obj;
48808        return obj;
48809      }
48810      this[$extra] = null;
48811    }
48812    return this[$extra];
48813  }
48814  [$toHTML](availableSpace) {
48815    const obj = this[$getExtra]();
48816    if (obj) {
48817      return obj[$toHTML](availableSpace);
48818    }
48819    return HTMLResult.EMPTY;
48820  }
48821}
48822class Validate extends XFAObject {
48823  constructor(attributes) {
48824    super(TEMPLATE_NS_ID, "validate", true);
48825    this.formatTest = getStringOption(attributes.formatTest, ["warning", "disabled", "error"]);
48826    this.id = attributes.id || "";
48827    this.nullTest = getStringOption(attributes.nullTest, ["disabled", "error", "warning"]);
48828    this.scriptTest = getStringOption(attributes.scriptTest, ["error", "disabled", "warning"]);
48829    this.use = attributes.use || "";
48830    this.usehref = attributes.usehref || "";
48831    this.extras = null;
48832    this.message = null;
48833    this.picture = null;
48834    this.script = null;
48835  }
48836}
48837class Value extends XFAObject {
48838  constructor(attributes) {
48839    super(TEMPLATE_NS_ID, "value", true);
48840    this.id = attributes.id || "";
48841    this.override = getInteger({
48842      data: attributes.override,
48843      defaultValue: 0,
48844      validate: x => x === 1
48845    });
48846    this.relevant = getRelevant(attributes.relevant);
48847    this.use = attributes.use || "";
48848    this.usehref = attributes.usehref || "";
48849    this.arc = null;
48850    this.boolean = null;
48851    this.date = null;
48852    this.dateTime = null;
48853    this.decimal = null;
48854    this.exData = null;
48855    this.float = null;
48856    this.image = null;
48857    this.integer = null;
48858    this.line = null;
48859    this.rectangle = null;
48860    this.text = null;
48861    this.time = null;
48862  }
48863  [$setValue](value) {
48864    const parent = this[$getParent]();
48865    if (parent instanceof Field) {
48866      if (parent.ui?.imageEdit) {
48867        if (!this.image) {
48868          this.image = new Image({});
48869          this[$appendChild](this.image);
48870        }
48871        this.image[$content] = value[$content];
48872        return;
48873      }
48874    }
48875    const valueName = value[$nodeName];
48876    if (this[valueName] !== null) {
48877      this[valueName][$content] = value[$content];
48878      return;
48879    }
48880    for (const name of Object.getOwnPropertyNames(this)) {
48881      const obj = this[name];
48882      if (obj instanceof XFAObject) {
48883        this[name] = null;
48884        this[$removeChild](obj);
48885      }
48886    }
48887    this[value[$nodeName]] = value;
48888    this[$appendChild](value);
48889  }
48890  [$text]() {
48891    if (this.exData) {
48892      if (typeof this.exData[$content] === "string") {
48893        return this.exData[$content].trim();
48894      }
48895      return this.exData[$content][$text]().trim();
48896    }
48897    for (const name of Object.getOwnPropertyNames(this)) {
48898      if (name === "image") {
48899        continue;
48900      }
48901      const obj = this[name];
48902      if (obj instanceof XFAObject) {
48903        return (obj[$content] || "").toString().trim();
48904      }
48905    }
48906    return null;
48907  }
48908  [$toHTML](availableSpace) {
48909    for (const name of Object.getOwnPropertyNames(this)) {
48910      const obj = this[name];
48911      if (!(obj instanceof XFAObject)) {
48912        continue;
48913      }
48914      return obj[$toHTML](availableSpace);
48915    }
48916    return HTMLResult.EMPTY;
48917  }
48918}
48919class Variables extends XFAObject {
48920  constructor(attributes) {
48921    super(TEMPLATE_NS_ID, "variables", true);
48922    this.id = attributes.id || "";
48923    this.use = attributes.use || "";
48924    this.usehref = attributes.usehref || "";
48925    this.boolean = new XFAObjectArray();
48926    this.date = new XFAObjectArray();
48927    this.dateTime = new XFAObjectArray();
48928    this.decimal = new XFAObjectArray();
48929    this.exData = new XFAObjectArray();
48930    this.float = new XFAObjectArray();
48931    this.image = new XFAObjectArray();
48932    this.integer = new XFAObjectArray();
48933    this.manifest = new XFAObjectArray();
48934    this.script = new XFAObjectArray();
48935    this.text = new XFAObjectArray();
48936    this.time = new XFAObjectArray();
48937  }
48938  [$isTransparent]() {
48939    return true;
48940  }
48941}
48942class TemplateNamespace {
48943  static [$buildXFAObject](name, attributes) {
48944    if (
48944Object.hasOwn(TemplateNamespace, name)) {
48945      const node = TemplateNamespace[name](attributes);
48946      node[$setSetAttributes](attributes);
48947      return node;
48948    }
48949    return undefined;
48950  }
48951  static appearanceFilter(attrs) {
48952    return new AppearanceFilter(attrs);
48953  }
48954  static arc(attrs) {
48955    return new Arc(attrs);
48956  }
48957  static area(attrs) {
48958    return new Area(attrs);
48959  }
48960  static assist(attrs) {
48961    return new Assist(attrs);
48962  }
48963  static barcode(attrs) {
48964    return new Barcode(attrs);
48965  }
48966  static bind(attrs) {
48967    return new Bind(attrs);
48968  }
48969  static bindItems(attrs) {
48970    return new BindItems(attrs);
48971  }
48972  static bookend(attrs) {
48973    return new Bookend(attrs);
48974  }
48975  static boolean(attrs) {
48976    return new BooleanElement(attrs);
48977  }
48978  static border(attrs) {
48979    return new Border(attrs);
48980  }
48981  static break(attrs) {
48982    return new Break(attrs);
48983  }
48984  static breakAfter(attrs) {
48985    return new BreakAfter(attrs);
48986  }
48987  static breakBefore(attrs) {
48988    return new BreakBefore(attrs);
48989  }
48990  static button(attrs) {
48991    return new Button(attrs);
48992  }
48993  static calculate(attrs) {
48994    return new Calculate(attrs);
48995  }
48996  static caption(attrs) {
48997    return new Caption(attrs);
48998  }
48999  static certificate(attrs) {
49000    return new Certificate(attrs);
49001  }
49002  static certificates(attrs) {
49003    return new Certificates(attrs);
49004  }
49005  static checkButton(attrs) {
49006    return new CheckButton(attrs);
49007  }
49008  static choiceList(attrs) {
49009    return new ChoiceList(attrs);
49010  }
49011  static color(attrs) {
49012    return new Color(attrs);
49013  }
49014  static comb(attrs) {
49015    return new Comb(attrs);
49016  }
49017  static connect(attrs) {
49018    return new Connect(attrs);
49019  }
49020  static contentArea(attrs) {
49021    return new ContentArea(attrs);
49022  }
49023  static corner(attrs) {
49024    return new Corner(attrs);
49025  }
49026  static date(attrs) {
49027    return new DateElement(attrs);
49028  }
49029  static dateTime(attrs) {
49030    return new DateTime(attrs);
49031  }
49032  static dateTimeEdit(attrs) {
49033    return new DateTimeEdit(attrs);
49034  }
49035  static decimal(attrs) {
49036    return new Decimal(attrs);
49037  }
49038  static defaultUi(attrs) {
49039    return new DefaultUi(attrs);
49040  }
49041  static desc(attrs) {
49042    return new Desc(attrs);
49043  }
49044  static digestMethod(attrs) {
49045    return new DigestMethod(attrs);
49046  }
49047  static digestMethods(attrs) {
49048    return new DigestMethods(attrs);
49049  }
49050  static draw(attrs) {
49051    return new Draw(attrs);
49052  }
49053  static edge(attrs) {
49054    return new Edge(attrs);
49055  }
49056  static encoding(attrs) {
49057    return new Encoding(attrs);
49058  }
49059  static encodings(attrs) {
49060    return new Encodings(attrs);
49061  }
49062  static encrypt(attrs) {
49063    return new Encrypt(attrs);
49064  }
49065  static encryptData(attrs) {
49066    return new EncryptData(attrs);
49067  }
49068  static encryption(attrs) {
49069    return new Encryption(attrs);
49070  }
49071  static encryptionMethod(attrs) {
49072    return new EncryptionMethod(attrs);
49073  }
49074  static encryptionMethods(attrs) {
49075    return new EncryptionMethods(attrs);
49076  }
49077  static event(attrs) {
49078    return new Event(attrs);
49079  }
49080  static exData(attrs) {
49081    return new ExData(attrs);
49082  }
49083  static exObject(attrs) {
49084    return new ExObject(attrs);
49085  }
49086  static exclGroup(attrs) {
49087    return new ExclGroup(attrs);
49088  }
49089  static execute(attrs) {
49090    return new Execute(attrs);
49091  }
49092  static extras(attrs) {
49093    return new Extras(attrs);
49094  }
49095  static field(attrs) {
49096    return new Field(attrs);
49097  }
49098  static fill(attrs) {
49099    return new Fill(attrs);
49100  }
49101  static filter(attrs) {
49102    return new Filter(attrs);
49103  }
49104  static float(attrs) {
49105    return new Float(attrs);
49106  }
49107  static font(attrs) {
49108    return new template_Font(attrs);
49109  }
49110  static format(attrs) {
49111    return new Format(attrs);
49112  }
49113  static handler(attrs) {
49114    return new Handler(attrs);
49115  }
49116  static hyphenation(attrs) {
49117    return new Hyphenation(attrs);
49118  }
49119  static image(attrs) {
49120    return new Image(attrs);
49121  }
49122  static imageEdit(attrs) {
49123    return new ImageEdit(attrs);
49124  }
49125  static integer(attrs) {
49126    return new Integer(attrs);
49127  }
49128  static issuers(attrs) {
49129    return new Issuers(attrs);
49130  }
49131  static items(attrs) {
49132    return new Items(attrs);
49133  }
49134  static keep(attrs) {
49135    return new Keep(attrs);
49136  }
49137  static keyUsage(attrs) {
49138    return new KeyUsage(attrs);
49139  }
49140  static line(attrs) {
49141    return new Line(attrs);
49142  }
49143  static linear(attrs) {
49144    return new Linear(attrs);
49145  }
49146  static lockDocument(attrs) {
49147    return new LockDocument(attrs);
49148  }
49149  static manifest(attrs) {
49150    return new Manifest(attrs);
49151  }
49152  static margin(attrs) {
49153    return new Margin(attrs);
49154  }
49155  static mdp(attrs) {
49156    return new Mdp(attrs);
49157  }
49158  static medium(attrs) {
49159    return new Medium(attrs);
49160  }
49161  static message(attrs) {
vendor: 4,621 bytes, lines 49162-49360
49162    return new Message(attrs);
49163  }
49164  static numericEdit(attrs) {
49165    return new NumericEdit(attrs);
49166  }
49167  static occur(attrs) {
49168    return new Occur(attrs);
49169  }
49170  static oid(attrs) {
49171    return new Oid(attrs);
49172  }
49173  static oids(attrs) {
49174    return new Oids(attrs);
49175  }
49176  static overflow(attrs) {
49177    return new Overflow(attrs);
49178  }
49179  static pageArea(attrs) {
49180    return new PageArea(attrs);
49181  }
49182  static pageSet(attrs) {
49183    return new PageSet(attrs);
49184  }
49185  static para(attrs) {
49186    return new Para(attrs);
49187  }
49188  static passwordEdit(attrs) {
49189    return new PasswordEdit(attrs);
49190  }
49191  static pattern(attrs) {
49192    return new template_Pattern(attrs);
49193  }
49194  static picture(attrs) {
49195    return new Picture(attrs);
49196  }
49197  static proto(attrs) {
49198    return new Proto(attrs);
49199  }
49200  static radial(attrs) {
49201    return new Radial(attrs);
49202  }
49203  static reason(attrs) {
49204    return new Reason(attrs);
49205  }
49206  static reasons(attrs) {
49207    return new Reasons(attrs);
49208  }
49209  static rectangle(attrs) {
49210    return new Rectangle(attrs);
49211  }
49212  static ref(attrs) {
49213    return new RefElement(attrs);
49214  }
49215  static script(attrs) {
49216    return new Script(attrs);
49217  }
49218  static setProperty(attrs) {
49219    return new SetProperty(attrs);
49220  }
49221  static signData(attrs) {
49222    return new SignData(attrs);
49223  }
49224  static signature(attrs) {
49225    return new Signature(attrs);
49226  }
49227  static signing(attrs) {
49228    return new Signing(attrs);
49229  }
49230  static solid(attrs) {
49231    return new Solid(attrs);
49232  }
49233  static speak(attrs) {
49234    return new Speak(attrs);
49235  }
49236  static stipple(attrs) {
49237    return new Stipple(attrs);
49238  }
49239  static subform(attrs) {
49240    return new Subform(attrs);
49241  }
49242  static subformSet(attrs) {
49243    return new SubformSet(attrs);
49244  }
49245  static subjectDN(attrs) {
49246    return new SubjectDN(attrs);
49247  }
49248  static subjectDNs(attrs) {
49249    return new SubjectDNs(attrs);
49250  }
49251  static submit(attrs) {
49252    return new Submit(attrs);
49253  }
49254  static template(attrs) {
49255    return new Template(attrs);
49256  }
49257  static text(attrs) {
49258    return new Text(attrs);
49259  }
49260  static textEdit(attrs) {
49261    return new TextEdit(attrs);
49262  }
49263  static time(attrs) {
49264    return new Time(attrs);
49265  }
49266  static timeStamp(attrs) {
49267    return new TimeStamp(attrs);
49268  }
49269  static toolTip(attrs) {
49270    return new ToolTip(attrs);
49271  }
49272  static traversal(attrs) {
49273    return new Traversal(attrs);
49274  }
49275  static traverse(attrs) {
49276    return new Traverse(attrs);
49277  }
49278  static ui(attrs) {
49279    return new Ui(attrs);
49280  }
49281  static validate(attrs) {
49282    return new Validate(attrs);
49283  }
49284  static value(attrs) {
49285    return new Value(attrs);
49286  }
49287  static variables(attrs) {
49288    return new Variables(attrs);
49289  }
49290}
49291
49292;// ./src/core/xfa/bind.js
49293
49294
49295
49296
49297
49298
49299const bind_NS_DATASETS = NamespaceIds.datasets.id;
49300function createText(content) {
49301  const node = new Text({});
49302  node[$content] = content;
49303  return node;
49304}
49305class Binder {
49306  constructor(root) {
49307    this.root = root;
49308    this.datasets = root.datasets;
49309    this.data = root.datasets?.data || new XmlObject(NamespaceIds.datasets.id, "data");
49310    this.emptyMerge = this.data[$getChildren]().length === 0;
49311    this.root.form = this.form = root.template[$clone]();
49312  }
49313  _isConsumeData() {
49314    return !this.emptyMerge && this._mergeMode;
49315  }
49316  _isMatchTemplate() {
49317    return !this._isConsumeData();
49318  }
49319  bind() {
49320    this._bindElement(this.form, this.data);
49321    return this.form;
49322  }
49323  getData() {
49324    return this.data;
49325  }
49326  _bindValue(formNode, data, picture) {
49327    formNode[$data] = data;
49328    if (formNode[$hasSettableValue]()) {
49329      if (data[$isDataValue]()) {
49330        const value = data[$getDataValue]();
49331        formNode[$setValue](createText(value));
49332      } else if (formNode instanceof Field && formNode.ui?.choiceList?.open === "multiSelect") {
49333        const value = data[$getChildren]().map(child => child[$content].trim()).join("\n");
49334        formNode[$setValue](createText(value));
49335      } else if (this._isConsumeData()) {
49336        warn(`XFA - Nodes haven't the same type.`);
49337      }
49338    } else if (!data[$isDataValue]() || this._isMatchTemplate()) {
49339      this._bindElement(formNode, data);
49340    } else {
49341      warn(`XFA - Nodes haven't the same type.`);
49342    }
49343  }
49344  _findDataByNameToConsume(name, isValue, dataNode, global) {
49345    if (!name) {
49346      return null;
49347    }
49348    let generator, match;
49349    for (let i = 0; i < 3; i++) {
49350      generator = dataNode[$getRealChildrenByNameIt](name, false, true);
49351      while (true) {
49352        match = generator.next().value;
49353        if (!match) {
49354          break;
49355        }
49356        if (isValue === match[$isDataValue]()) {
49357          return match;
49358        }
49359      }
49360      if (dataNode[$namespaceId] === NamespaceIds.datasets.id
vendor: 20,716 bytes, lines 49360-50065
49360 && dataNode[$nodeName] === "data") {
49361        break;
49362      }
49363      dataNode = dataNode[$getParent]();
49364    }
49365    if (!global) {
49366      return null;
49367    }
49368    generator = this.data[$getRealChildrenByNameIt](name, true, false);
49369    match = generator.next().value;
49370    if (match) {
49371      return match;
49372    }
49373    generator = this.data[$getAttributeIt](name, true);
49374    match = generator.next().value;
49375    if (match?.[$isDataValue]()) {
49376      return match;
49377    }
49378    return null;
49379  }
49380  _setProperties(formNode, dataNode) {
49381    if (!Object.hasOwn(formNode, "setProperty")) {
49382      return;
49383    }
49384    for (const {
49385      ref,
49386      target,
49387      connection
49388    } of formNode.setProperty.children) {
49389      if (connection) {
49390        continue;
49391      }
49392      if (!ref) {
49393        continue;
49394      }
49395      const nodes = searchNode(this.root, dataNode, ref, false, false);
49396      if (!nodes) {
49397        warn(`XFA - Invalid reference: ${ref}.`);
49398        continue;
49399      }
49400      const [node] = nodes;
49401      if (!node[$isDescendent](this.data)) {
49402        warn(`XFA - Invalid node: must be a data node.`);
49403        continue;
49404      }
49405      const targetNodes = searchNode(this.root, formNode, target, false, false);
49406      if (!targetNodes) {
49407        warn(`XFA - Invalid target: ${target}.`);
49408        continue;
49409      }
49410      const [targetNode] = targetNodes;
49411      if (!targetNode[$isDescendent](formNode)) {
49412        warn(`XFA - Invalid target: must be a property or subproperty.`);
49413        continue;
49414      }
49415      const targetParent = targetNode[$getParent]();
49416      if (targetNode instanceof SetProperty || targetParent instanceof SetProperty) {
49417        warn(`XFA - Invalid target: cannot be a setProperty or one of its properties.`);
49418        continue;
49419      }
49420      if (targetNode instanceof BindItems || targetParent instanceof BindItems) {
49421        warn(`XFA - Invalid target: cannot be a bindItems or one of its properties.`);
49422        continue;
49423      }
49424      const content = node[$text]();
49425      const name = targetNode[$nodeName];
49426      if (targetNode instanceof XFAAttribute) {
49427        const attrs = Object.create(null);
49428        attrs[name] = content;
49429        const obj = Reflect.construct(Object.getPrototypeOf(targetParent).constructor, [attrs]);
49430        targetParent[name] = obj[name];
49431        continue;
49432      }
49433      if (!Object.hasOwn(targetNode, $content)) {
49434        warn(`XFA - Invalid node to use in setProperty`);
49435        continue;
49436      }
49437      targetNode[$data] = node;
49438      targetNode[$content] = content;
49439      targetNode[$finalize]();
49440    }
49441  }
49442  _bindItems(formNode, dataNode) {
49443    if (!Object.hasOwn(formNode, "items") || !Object.hasOwn(formNode, "bindItems") || formNode.bindItems.isEmpty()) {
49444      return;
49445    }
49446    for (const item of formNode.items.children) {
49447      formNode[$removeChild](item);
49448    }
49449    formNode.items.clear();
49450    const labels = new Items({});
49451    const values = new Items({});
49452    formNode[$appendChild](labels);
49453    formNode.items.push(labels);
49454    formNode[$appendChild](values);
49455    formNode.items.push(values);
49456    for (const {
49457      ref,
49458      labelRef,
49459      valueRef,
49460      connection
49461    } of formNode.bindItems.children) {
49462      if (connection) {
49463        continue;
49464      }
49465      if (!ref) {
49466        continue;
49467      }
49468      const nodes = searchNode(this.root, dataNode, ref, false, false);
49469      if (!nodes) {
49470        warn(`XFA - Invalid reference: ${ref}.`);
49471        continue;
49472      }
49473      for (const node of nodes) {
49474        if (!node[$isDescendent](this.datasets)) {
49475          warn(`XFA - Invalid ref (${ref}): must be a datasets child.`);
49476          continue;
49477        }
49478        const labelNodes = searchNode(this.root, node, labelRef, true, false);
49479        if (!labelNodes) {
49480          warn(`XFA - Invalid label: ${labelRef}.`);
49481          continue;
49482        }
49483        const [labelNode] = labelNodes;
49484        if (!labelNode[$isDescendent](this.datasets)) {
49485          warn(`XFA - Invalid label: must be a datasets child.`);
49486          continue;
49487        }
49488        const valueNodes = searchNode(this.root, node, valueRef, true, false);
49489        if (!valueNodes) {
49490          warn(`XFA - Invalid value: ${valueRef}.`);
49491          continue;
49492        }
49493        const [valueNode] = valueNodes;
49494        if (!valueNode[$isDescendent](this.datasets)) {
49495          warn(`XFA - Invalid value: must be a datasets child.`);
49496          continue;
49497        }
49498        const label = createText(labelNode[$text]());
49499        const value = createText(valueNode[$text]());
49500        labels[$appendChild](label);
49501        labels.text.push(label);
49502        values[$appendChild](value);
49503        values.text.push(value);
49504      }
49505    }
49506  }
49507  _bindOccurrences(formNode, matches, picture) {
49508    let baseClone;
49509    if (matches.length > 1) {
49510      baseClone = formNode[$clone]();
49511      baseClone[$removeChild](baseClone.occur);
49512      baseClone.occur = null;
49513    }
49514    this._bindValue(formNode, matches[0], picture);
49515    this._setProperties(formNode, matches[0]);
49516    this._bindItems(formNode, matches[0]);
49517    if (matches.length === 1) {
49518      return;
49519    }
49520    const parent = formNode[$getParent]();
49521    const name = formNode[$nodeName];
49522    const pos = parent[$indexOf](formNode);
49523    for (let i = 1, ii = matches.length; i < ii; i++) {
49524      const match = matches[i];
49525      const clone = baseClone[$clone]();
49526      parent[name].push(clone);
49527      parent[$insertAt](pos + i, clone);
49528      this._bindValue(clone, match, picture);
49529      this._setProperties(clone, match);
49530      this._bindItems(clone, match);
49531    }
49532  }
49533  _createOccurrences(formNode) {
49534    if (!this.emptyMerge) {
49535      return;
49536    }
49537    const {
49538      occur
49539    } = formNode;
49540    if (!occur || occur.initial <= 1) {
49541      return;
49542    }
49543    const parent = formNode[$getParent]();
49544    const name = formNode[$nodeName];
49545    if (!(parent[name] instanceof XFAObjectArray)) {
49546      return;
49547    }
49548    let currentNumber;
49549    if (formNode.name) {
49550      currentNumber = parent[name].children.filter(e => e.name === formNode.name).length;
49551    } else {
49552      currentNumber = parent[name].children.length;
49553    }
49554    const pos = parent[$indexOf](formNode) + 1;
49555    const ii = occur.initial - currentNumber;
49556    if (ii) {
49557      const nodeClone = formNode[$clone]();
49558      nodeClone[$removeChild](nodeClone.occur);
49559      nodeClone.occur = null;
49560      parent[name].push(nodeClone);
49561      parent[$insertAt](pos, nodeClone);
49562      for (let i = 1; i < ii; i++) {
49563        const clone = nodeClone[$clone]();
49564        parent[name].push(clone);
49565        parent[$insertAt](pos + i, clone);
49566      }
49567    }
49568  }
49569  _getOccurInfo(formNode) {
49570    const {
49571      name,
49572      occur
49573    } = formNode;
49574    if (!occur || !name) {
49575      return [1, 1];
49576    }
49577    const max = occur.max === -1 ? Infinity : occur.max;
49578    return [occur.min, max];
49579  }
49580  _setAndBind(formNode, dataNode) {
49581    this._setProperties(formNode, dataNode);
49582    this._bindItems(formNode, dataNode);
49583    this._bindElement(formNode, dataNode);
49584  }
49585  _bindElement(formNode, dataNode) {
49586    const uselessNodes = [];
49587    this._createOccurrences(formNode);
49588    for (const child of formNode[$getChildren]()) {
49589      if (child[$data]) {
49590        continue;
49591      }
49592      if (this._mergeMode === undefined && child[$nodeName] === "subform") {
49593        this._mergeMode = child.mergeMode === "consumeData";
49594        const dataChildren = dataNode[$getChildren]();
49595        if (dataChildren.length > 0) {
49596          this._bindOccurrences(child, [dataChildren[0]], null);
49597        } else if (this.emptyMerge) {
49598          const nsId = dataNode[$namespaceId] === bind_NS_DATASETS ? -1 : dataNode[$namespaceId];
49599          const dataChild = child[$data] = new XmlObject(nsId, child.name || "root");
49600          dataNode[$appendChild](dataChild);
49601          this._bindElement(child, dataChild);
49602        }
49603        continue;
49604      }
49605      if (!child[$isBindable]()) {
49606        continue;
49607      }
49608      let global = false;
49609      let picture = null;
49610      let ref = null;
49611      let match = null;
49612      if (child.bind) {
49613        switch (child.bind.match) {
49614          case "none":
49615            this._setAndBind(child, dataNode);
49616            continue;
49617          case "global":
49618            global = true;
49619            break;
49620          case "dataRef":
49621            if (!child.bind.ref) {
49622              warn(`XFA - ref is empty in node ${child[$nodeName]}.`);
49623              this._setAndBind(child, dataNode);
49624              continue;
49625            }
49626            ref = child.bind.ref;
49627            break;
49628          default:
49629            break;
49630        }
49631        if (child.bind.picture) {
49632          picture = child.bind.picture[$content];
49633        }
49634      }
49635      const [min, max] = this._getOccurInfo(child);
49636      if (ref) {
49637        match = searchNode(this.root, dataNode, ref, true, false);
49638        if (match === null) {
49639          match = createDataNode(this.data, dataNode, ref);
49640          if (!match) {
49641            continue;
49642          }
49643          if (this._isConsumeData()) {
49644            match[$consumed] = true;
49645          }
49646          this._setAndBind(child, match);
49647          continue;
49648        } else {
49649          if (this._isConsumeData()) {
49650            match = match.filter(node => !node[$consumed]);
49651          }
49652          if (match.length > max) {
49653            match = match.slice(0, max);
49654          } else if (match.length === 0) {
49655            match = null;
49656          }
49657          if (match && this._isConsumeData()) {
49658            match.forEach(node => {
49659              node[$consumed] = true;
49660            });
49661          }
49662        }
49663      } else {
49664        if (!child.name) {
49665          this._setAndBind(child, dataNode);
49666          continue;
49667        }
49668        if (this._isConsumeData()) {
49669          const matches = [];
49670          while (matches.length < max) {
49671            const found = this._findDataByNameToConsume(child.name, child[$hasSettableValue](), dataNode, global);
49672            if (!found) {
49673              break;
49674            }
49675            found[$consumed] = true;
49676            matches.push(found);
49677          }
49678          match = matches.length > 0 ? matches : null;
49679        } else {
49680          match = dataNode[$getRealChildrenByNameIt](child.name, false, this.emptyMerge).next().value;
49681          if (!match) {
49682            if (min === 0) {
49683              uselessNodes.push(child);
49684              continue;
49685            }
49686            const nsId = dataNode[$namespaceId] === bind_NS_DATASETS ? -1 : dataNode[$namespaceId];
49687            match = child[$data] = new XmlObject(nsId, child.name);
49688            if (this.emptyMerge) {
49689              match[$consumed] = true;
49690            }
49691            dataNode[$appendChild](match);
49692            this._setAndBind(child, match);
49693            continue;
49694          }
49695          if (this.emptyMerge) {
49696            match[$consumed] = true;
49697          }
49698          match = [match];
49699        }
49700      }
49701      if (match) {
49702        this._bindOccurrences(child, match, picture);
49703      } else if (min > 0) {
49704        this._setAndBind(child, dataNode);
49705      } else {
49706        uselessNodes.push(child);
49707      }
49708    }
49709    uselessNodes.forEach(node => node[$getParent]()[$removeChild](node));
49710  }
49711}
49712
49713;// ./src/core/xfa/data.js
49714
49715class DataHandler {
49716  constructor(root, data) {
49717    this.data = data;
49718    this.dataset = root.datasets || null;
49719  }
49720  serialize(storage) {
49721    const stack = [[-1, this.data[$getChildren]()]];
49722    while (stack.length > 0) {
49723      const last = stack.at(-1);
49724      const [i, children] = last;
49725      if (i + 1 === children.length) {
49726        stack.pop();
49727        continue;
49728      }
49729      const child = children[++last[0]];
49730      const storageEntry = storage.get(child[$uid]);
49731      if (storageEntry) {
49732        child[$setValue](storageEntry);
49733      } else {
49734        const attributes = child[$getAttributes]();
49735        for (const value of attributes.values()) {
49736          const entry = storage.get(value[$uid]);
49737          if (entry) {
49738            value[$setValue](entry);
49739            break;
49740          }
49741        }
49742      }
49743      const nodes = child[$getChildren]();
49744      if (nodes.length > 0) {
49745        stack.push([-1, nodes]);
49746      }
49747    }
49748    const buf = [`<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">`];
49749    if (this.dataset) {
49750      for (const child of this.dataset[$getChildren]()) {
49751        if (child[$nodeName] !== "data") {
49752          child[$toString](buf);
49753        }
49754      }
49755    }
49756    this.data[$toString](buf);
49757    buf.push("</xfa:datasets>");
49758    return buf.join("");
49759  }
49760}
49761
49762;// ./src/core/xfa/config.js
49763
49764
49765
49766
49767
49768const CONFIG_NS_ID = NamespaceIds.config.id;
49769class Acrobat extends XFAObject {
49770  constructor(attributes) {
49771    super(CONFIG_NS_ID, "acrobat", true);
49772    this.acrobat7 = null;
49773    this.autoSave = null;
49774    this.common = null;
49775    this.validate = null;
49776    this.validateApprovalSignatures = null;
49777    this.submitUrl = new XFAObjectArray();
49778  }
49779}
49780class Acrobat7 extends XFAObject {
49781  constructor(attributes) {
49782    super(CONFIG_NS_ID, "acrobat7", true);
49783    this.dynamicRender = null;
49784  }
49785}
49786class ADBE_JSConsole extends OptionObject {
49787  constructor(attributes) {
49788    super(CONFIG_NS_ID, "ADBE_JSConsole", ["delegate", "Enable", "Disable"]);
49789  }
49790}
49791class ADBE_JSDebugger extends OptionObject {
49792  constructor(attributes) {
49793    super(CONFIG_NS_ID, "ADBE_JSDebugger", ["delegate", "Enable", "Disable"]);
49794  }
49795}
49796class AddSilentPrint extends Option01 {
49797  constructor(attributes) {
49798    super(CONFIG_NS_ID, "addSilentPrint");
49799  }
49800}
49801class AddViewerPreferences extends Option01 {
49802  constructor(attributes) {
49803    super(CONFIG_NS_ID, "addViewerPreferences");
49804  }
49805}
49806class AdjustData extends Option10 {
49807  constructor(attributes) {
49808    super(CONFIG_NS_ID, "adjustData");
49809  }
49810}
49811class AdobeExtensionLevel extends IntegerObject {
49812  constructor(attributes) {
49813    super(CONFIG_NS_ID, "adobeExtensionLevel", 0, n => n >= 1 && n <= 8);
49814  }
49815}
49816class Agent extends XFAObject {
49817  constructor(attributes) {
49818    super(CONFIG_NS_ID, "agent", true);
49819    this.name = attributes.name ? attributes.name.trim() : "";
49820    this.common = new XFAObjectArray();
49821  }
49822}
49823class AlwaysEmbed extends ContentObject {
49824  constructor(attributes) {
49825    super(CONFIG_NS_ID, "alwaysEmbed");
49826  }
49827}
49828class Amd extends StringObject {
49829  constructor(attributes) {
49830    super(CONFIG_NS_ID, "amd");
49831  }
49832}
49833class config_Area extends XFAObject {
49834  constructor(attributes) {
49835    super(CONFIG_NS_ID, "area");
49836    this.level = getInteger({
49837      data: attributes.level,
49838      defaultValue: 0,
49839      validate: n => n >= 1 && n <= 3
49840    });
49841    this.name = getStringOption(attributes.name, ["", "barcode", "coreinit", "deviceDriver", "font", "general", "layout", "merge", "script", "signature", "sourceSet", "templateCache"]);
49842  }
49843}
49844class Attributes extends OptionObject {
49845  constructor(attributes) {
49846    super(CONFIG_NS_ID, "attributes", ["preserve", "delegate", "ignore"]);
49847  }
49848}
49849class AutoSave extends OptionObject {
49850  constructor(attributes) {
49851    super(CONFIG_NS_ID, "autoSave", ["disabled", "enabled"]);
49852  }
49853}
49854class Base extends StringObject {
49855  constructor(attributes) {
49856    super(CONFIG_NS_ID, "base");
49857  }
49858}
49859class BatchOutput extends XFAObject {
49860  constructor(attributes) {
49861    super(CONFIG_NS_ID, "batchOutput");
49862    this.format = getStringOption(attributes.format, ["none", "concat", "zip", "zipCompress"]);
49863  }
49864}
49865class BehaviorOverride extends ContentObject {
49866  constructor(attributes) {
49867    super(CONFIG_NS_ID, "behaviorOverride");
49868  }
49869  [$finalize]() {
49870    this[$content] = new Map(this[$content].trim().split(/\s+/).filter(x => x.includes(":")).map(x => x.split(":", 2)));
49871  }
49872}
49873class Cache extends XFAObject {
49874  constructor(attributes) {
49875    super(CONFIG_NS_ID, "cache", true);
49876    this.templateCache = null;
49877  }
49878}
49879class Change extends Option01 {
49880  constructor(attributes) {
49881    super(CONFIG_NS_ID, "change");
49882  }
49883}
49884class Common extends XFAObject {
49885  constructor(attributes) {
49886    super(CONFIG_NS_ID, "common", true);
49887    this.data = null;
49888    this.locale = null;
49889    this.localeSet = null;
49890    this.messaging = null;
49891    this.suppressBanner = null;
49892    this.template = null;
49893    this.validationMessaging = null;
49894    this.versionControl = null;
49895    this.log = new XFAObjectArray();
49896  }
49897}
49898class Compress extends XFAObject {
49899  constructor(attributes) {
49900    super(CONFIG_NS_ID, "compress");
49901    this.scope = getStringOption(attributes.scope, ["imageOnly", "document"]);
49902  }
49903}
49904class CompressLogicalStructure extends Option01 {
49905  constructor(attributes) {
49906    super(CONFIG_NS_ID, "compressLogicalStructure");
49907  }
49908}
49909class CompressObjectStream extends Option10 {
49910  constructor(attributes) {
49911    super(CONFIG_NS_ID, "compressObjectStream");
49912  }
49913}
49914class Compression extends XFAObject {
49915  constructor(attributes) {
49916    super(CONFIG_NS_ID, "compression", true);
49917    this.compressLogicalStructure = null;
49918    this.compressObjectStream = null;
49919    this.level = null;
49920    this.type = null;
49921  }
49922}
49923class Config extends XFAObject {
49924  constructor(attributes) {
49925    super(CONFIG_NS_ID, "config", true);
49926    this.acrobat = null;
49927    this.present = null;
49928    this.trace = null;
49929    this.agent = new XFAObjectArray();
49930  }
49931}
49932class Conformance extends OptionObject {
49933  constructor(attributes) {
49934    super(CONFIG_NS_ID, "conformance", ["A", "B"]);
49935  }
49936}
49937class ContentCopy extends Option01 {
49938  constructor(attributes) {
49939    super(CONFIG_NS_ID, "contentCopy");
49940  }
49941}
49942class Copies extends IntegerObject {
49943  constructor(attributes) {
49944    super(CONFIG_NS_ID, "copies", 1, n => n >= 1);
49945  }
49946}
49947class Creator extends StringObject {
49948  constructor(attributes) {
49949    super(CONFIG_NS_ID, "creator");
49950  }
49951}
49952class CurrentPage extends IntegerObject {
49953  constructor(attributes) {
49954    super(CONFIG_NS_ID, "currentPage", 0, n => n >= 0);
49955  }
49956}
49957class Data extends XFAObject {
49958  constructor(attributes) {
49959    super(CONFIG_NS_ID, "data", true);
49960    this.adjustData = null;
49961    this.attributes = null;
49962    this.incrementalLoad = null;
49963    this.outputXSL = null;
49964    this.range = null;
49965    this.record = null;
49966    this.startNode = null;
49967    this.uri = null;
49968    this.window = null;
49969    this.xsl = null;
49970    this.excludeNS = new XFAObjectArray();
49971    this.transform = new XFAObjectArray();
49972  }
49973}
49974class Debug extends XFAObject {
49975  constructor(attributes) {
49976    super(CONFIG_NS_ID, "debug", true);
49977    this.uri = null;
49978  }
49979}
49980class DefaultTypeface extends ContentObject {
49981  constructor(attributes) {
49982    super(CONFIG_NS_ID, "defaultTypeface");
49983    this.writingScript = getStringOption(attributes.writingScript, ["*", "Arabic", "Cyrillic", "EastEuropeanRoman", "Greek", "Hebrew", "Japanese", "Korean", "Roman", "SimplifiedChinese", "Thai", "TraditionalChinese", "Vietnamese"]);
49984  }
49985}
49986class Destination extends OptionObject {
49987  constructor(attributes) {
49988    super(CONFIG_NS_ID, "destination", ["pdf", "pcl", "ps", "webClient", "zpl"]);
49989  }
49990}
49991class DocumentAssembly extends Option01 {
49992  constructor(attributes) {
49993    super(CONFIG_NS_ID, "documentAssembly");
49994  }
49995}
49996class Driver extends XFAObject {
49997  constructor(attributes) {
49998    super(CONFIG_NS_ID, "driver", true);
49999    this.name = attributes.name ? attributes.name.trim() : "";
50000    this.fontInfo = null;
50001    this.xdc = null;
50002  }
50003}
50004class DuplexOption extends OptionObject {
50005  constructor(attributes) {
50006    super(CONFIG_NS_ID, "duplexOption", ["simplex", "duplexFlipLongEdge", "duplexFlipShortEdge"]);
50007  }
50008}
50009class DynamicRender extends OptionObject {
50010  constructor(attributes) {
50011    super(CONFIG_NS_ID, "dynamicRender", ["forbidden", "required"]);
50012  }
50013}
50014class Embed extends Option01 {
50015  constructor(attributes) {
50016    super(CONFIG_NS_ID, "embed");
50017  }
50018}
50019class config_Encrypt extends Option01 {
50020  constructor(attributes) {
50021    super(CONFIG_NS_ID, "encrypt");
50022  }
50023}
50024class config_Encryption extends XFAObject {
50025  constructor(attributes) {
50026    super(CONFIG_NS_ID, "encryption", true);
50027    this.encrypt = null;
50028    this.encryptionLevel = null;
50029    this.permissions = null;
50030  }
50031}
50032class EncryptionLevel extends OptionObject {
50033  constructor(attributes) {
50034    super(CONFIG_NS_ID, "encryptionLevel", ["40bit", "128bit"]);
50035  }
50036}
50037class Enforce extends StringObject {
50038  constructor(attributes) {
50039    super(CONFIG_NS_ID, "enforce");
50040  }
50041}
50042class Equate extends XFAObject {
50043  constructor(attributes) {
50044    super(CONFIG_NS_ID, "equate");
50045    this.force = getInteger({
50046      data: attributes.force,
50047      defaultValue: 1,
50048      validate: n => n === 0
50049    });
50050    this.from = attributes.from || "";
50051    this.to = attributes.to || "";
50052  }
50053}
50054class EquateRange extends XFAObject {
50055  constructor(attributes) {
50056    super(CONFIG_NS_ID, "equateRange");
50057    this.from = attributes.from || "";
50058    this.to = attributes.to || "";
50059    this._unicodeRange = attributes.unicodeRange || "";
50060  }
50061  get unicodeRange() {
50062    const ranges = [];
50063    const unicodeRegex = /U\+([0-9a-fA-F]+)/;
50064    const unicodeRange = this._unicodeRange;
50065    for (let range of unicodeRange.split(",").map(x => x.trim()).filter(
50065x => !!x
vendor: 47,585 bytes, lines 50065-51839
50065)) {
50066      range = range.split("-", 2).map(x => {
50067        const found = x.match(unicodeRegex);
50068        if (!found) {
50069          return 0;
50070        }
50071        return parseInt(found[1], 16);
50072      });
50073      if (range.length === 1) {
50074        range.push(range[0]);
50075      }
50076      ranges.push(range);
50077    }
50078    return shadow(this, "unicodeRange", ranges);
50079  }
50080}
50081class Exclude extends ContentObject {
50082  constructor(attributes) {
50083    super(CONFIG_NS_ID, "exclude");
50084  }
50085  [$finalize]() {
50086    this[$content] = this[$content].trim().split(/\s+/).filter(x => x && ["calculate", "close", "enter", "exit", "initialize", "ready", "validate"].includes(x));
50087  }
50088}
50089class ExcludeNS extends StringObject {
50090  constructor(attributes) {
50091    super(CONFIG_NS_ID, "excludeNS");
50092  }
50093}
50094class FlipLabel extends OptionObject {
50095  constructor(attributes) {
50096    super(CONFIG_NS_ID, "flipLabel", ["usePrinterSetting", "on", "off"]);
50097  }
50098}
50099class config_FontInfo extends XFAObject {
50100  constructor(attributes) {
50101    super(CONFIG_NS_ID, "fontInfo", true);
50102    this.embed = null;
50103    this.map = null;
50104    this.subsetBelow = null;
50105    this.alwaysEmbed = new XFAObjectArray();
50106    this.defaultTypeface = new XFAObjectArray();
50107    this.neverEmbed = new XFAObjectArray();
50108  }
50109}
50110class FormFieldFilling extends Option01 {
50111  constructor(attributes) {
50112    super(CONFIG_NS_ID, "formFieldFilling");
50113  }
50114}
50115class GroupParent extends StringObject {
50116  constructor(attributes) {
50117    super(CONFIG_NS_ID, "groupParent");
50118  }
50119}
50120class IfEmpty extends OptionObject {
50121  constructor(attributes) {
50122    super(CONFIG_NS_ID, "ifEmpty", ["dataValue", "dataGroup", "ignore", "remove"]);
50123  }
50124}
50125class IncludeXDPContent extends StringObject {
50126  constructor(attributes) {
50127    super(CONFIG_NS_ID, "includeXDPContent");
50128  }
50129}
50130class IncrementalLoad extends OptionObject {
50131  constructor(attributes) {
50132    super(CONFIG_NS_ID, "incrementalLoad", ["none", "forwardOnly"]);
50133  }
50134}
50135class IncrementalMerge extends Option01 {
50136  constructor(attributes) {
50137    super(CONFIG_NS_ID, "incrementalMerge");
50138  }
50139}
50140class Interactive extends Option01 {
50141  constructor(attributes) {
50142    super(CONFIG_NS_ID, "interactive");
50143  }
50144}
50145class Jog extends OptionObject {
50146  constructor(attributes) {
50147    super(CONFIG_NS_ID, "jog", ["usePrinterSetting", "none", "pageSet"]);
50148  }
50149}
50150class LabelPrinter extends XFAObject {
50151  constructor(attributes) {
50152    super(CONFIG_NS_ID, "labelPrinter", true);
50153    this.name = getStringOption(attributes.name, ["zpl", "dpl", "ipl", "tcpl"]);
50154    this.batchOutput = null;
50155    this.flipLabel = null;
50156    this.fontInfo = null;
50157    this.xdc = null;
50158  }
50159}
50160class Layout extends OptionObject {
50161  constructor(attributes) {
50162    super(CONFIG_NS_ID, "layout", ["paginate", "panel"]);
50163  }
50164}
50165class Level extends IntegerObject {
50166  constructor(attributes) {
50167    super(CONFIG_NS_ID, "level", 0, n => n > 0);
50168  }
50169}
50170class Linearized extends Option01 {
50171  constructor(attributes) {
50172    super(CONFIG_NS_ID, "linearized");
50173  }
50174}
50175class Locale extends StringObject {
50176  constructor(attributes) {
50177    super(CONFIG_NS_ID, "locale");
50178  }
50179}
50180class LocaleSet extends StringObject {
50181  constructor(attributes) {
50182    super(CONFIG_NS_ID, "localeSet");
50183  }
50184}
50185class Log extends XFAObject {
50186  constructor(attributes) {
50187    super(CONFIG_NS_ID, "log", true);
50188    this.mode = null;
50189    this.threshold = null;
50190    this.to = null;
50191    this.uri = null;
50192  }
50193}
50194class MapElement extends XFAObject {
50195  constructor(attributes) {
50196    super(CONFIG_NS_ID, "map", true);
50197    this.equate = new XFAObjectArray();
50198    this.equateRange = new XFAObjectArray();
50199  }
50200}
50201class MediumInfo extends XFAObject {
50202  constructor(attributes) {
50203    super(CONFIG_NS_ID, "mediumInfo", true);
50204    this.map = null;
50205  }
50206}
50207class config_Message extends XFAObject {
50208  constructor(attributes) {
50209    super(CONFIG_NS_ID, "message", true);
50210    this.msgId = null;
50211    this.severity = null;
50212  }
50213}
50214class Messaging extends XFAObject {
50215  constructor(attributes) {
50216    super(CONFIG_NS_ID, "messaging", true);
50217    this.message = new XFAObjectArray();
50218  }
50219}
50220class Mode extends OptionObject {
50221  constructor(attributes) {
50222    super(CONFIG_NS_ID, "mode", ["append", "overwrite"]);
50223  }
50224}
50225class ModifyAnnots extends Option01 {
50226  constructor(attributes) {
50227    super(CONFIG_NS_ID, "modifyAnnots");
50228  }
50229}
50230class MsgId extends IntegerObject {
50231  constructor(attributes) {
50232    super(CONFIG_NS_ID, "msgId", 1, n => n >= 1);
50233  }
50234}
50235class NameAttr extends StringObject {
50236  constructor(attributes) {
50237    super(CONFIG_NS_ID, "nameAttr");
50238  }
50239}
50240class NeverEmbed extends ContentObject {
50241  constructor(attributes) {
50242    super(CONFIG_NS_ID, "neverEmbed");
50243  }
50244}
50245class NumberOfCopies extends IntegerObject {
50246  constructor(attributes) {
50247    super(CONFIG_NS_ID, "numberOfCopies", null, n => n >= 2 && n <= 5);
50248  }
50249}
50250class OpenAction extends XFAObject {
50251  constructor(attributes) {
50252    super(CONFIG_NS_ID, "openAction", true);
50253    this.destination = null;
50254  }
50255}
50256class Output extends XFAObject {
50257  constructor(attributes) {
50258    super(CONFIG_NS_ID, "output", true);
50259    this.to = null;
50260    this.type = null;
50261    this.uri = null;
50262  }
50263}
50264class OutputBin extends StringObject {
50265  constructor(attributes) {
50266    super(CONFIG_NS_ID, "outputBin");
50267  }
50268}
50269class OutputXSL extends XFAObject {
50270  constructor(attributes) {
50271    super(CONFIG_NS_ID, "outputXSL", true);
50272    this.uri = null;
50273  }
50274}
50275class Overprint extends OptionObject {
50276  constructor(attributes) {
50277    super(CONFIG_NS_ID, "overprint", ["none", "both", "draw", "field"]);
50278  }
50279}
50280class Packets extends StringObject {
50281  constructor(attributes) {
50282    super(CONFIG_NS_ID, "packets");
50283  }
50284  [$finalize]() {
50285    if (this[$content] === "*") {
50286      return;
50287    }
50288    this[$content] = this[$content].trim().split(/\s+/).filter(x => ["config", "datasets", "template", "xfdf", "xslt"].includes(x));
50289  }
50290}
50291class PageOffset extends XFAObject {
50292  constructor(attributes) {
50293    super(CONFIG_NS_ID, "pageOffset");
50294    this.x = getInteger({
50295      data: attributes.x,
50296      defaultValue: "useXDCSetting",
50297      validate: n => true
50298    });
50299    this.y = getInteger({
50300      data: attributes.y,
50301      defaultValue: "useXDCSetting",
50302      validate: n => true
50303    });
50304  }
50305}
50306class PageRange extends StringObject {
50307  constructor(attributes) {
50308    super(CONFIG_NS_ID, "pageRange");
50309  }
50310  [$finalize]() {
50311    const numbers = this[$content].trim().split(/\s+/).map(x => parseInt(x, 10));
50312    const ranges = [];
50313    for (let i = 0, ii = numbers.length; i < ii; i += 2) {
50314      ranges.push(numbers.slice(i, i + 2));
50315    }
50316    this[$content] = ranges;
50317  }
50318}
50319class Pagination extends OptionObject {
50320  constructor(attributes) {
50321    super(CONFIG_NS_ID, "pagination", ["simplex", "duplexShortEdge", "duplexLongEdge"]);
50322  }
50323}
50324class PaginationOverride extends OptionObject {
50325  constructor(attributes) {
50326    super(CONFIG_NS_ID, "paginationOverride", ["none", "forceDuplex", "forceDuplexLongEdge", "forceDuplexShortEdge", "forceSimplex"]);
50327  }
50328}
50329class Part extends IntegerObject {
50330  constructor(attributes) {
50331    super(CONFIG_NS_ID, "part", 1, n => false);
50332  }
50333}
50334class Pcl extends XFAObject {
50335  constructor(attributes) {
50336    super(CONFIG_NS_ID, "pcl", true);
50337    this.name = attributes.name || "";
50338    this.batchOutput = null;
50339    this.fontInfo = null;
50340    this.jog = null;
50341    this.mediumInfo = null;
50342    this.outputBin = null;
50343    this.pageOffset = null;
50344    this.staple = null;
50345    this.xdc = null;
50346  }
50347}
50348class Pdf extends XFAObject {
50349  constructor(attributes) {
50350    super(CONFIG_NS_ID, "pdf", true);
50351    this.name = attributes.name || "";
50352    this.adobeExtensionLevel = null;
50353    this.batchOutput = null;
50354    this.compression = null;
50355    this.creator = null;
50356    this.encryption = null;
50357    this.fontInfo = null;
50358    this.interactive = null;
50359    this.linearized = null;
50360    this.openAction = null;
50361    this.pdfa = null;
50362    this.producer = null;
50363    this.renderPolicy = null;
50364    this.scriptModel = null;
50365    this.silentPrint = null;
50366    this.submitFormat = null;
50367    this.tagged = null;
50368    this.version = null;
50369    this.viewerPreferences = null;
50370    this.xdc = null;
50371  }
50372}
50373class Pdfa extends XFAObject {
50374  constructor(attributes) {
50375    super(CONFIG_NS_ID, "pdfa", true);
50376    this.amd = null;
50377    this.conformance = null;
50378    this.includeXDPContent = null;
50379    this.part = null;
50380  }
50381}
50382class Permissions extends XFAObject {
50383  constructor(attributes) {
50384    super(CONFIG_NS_ID, "permissions", true);
50385    this.accessibleContent = null;
50386    this.change = null;
50387    this.contentCopy = null;
50388    this.documentAssembly = null;
50389    this.formFieldFilling = null;
50390    this.modifyAnnots = null;
50391    this.plaintextMetadata = null;
50392    this.print = null;
50393    this.printHighQuality = null;
50394  }
50395}
50396class PickTrayByPDFSize extends Option01 {
50397  constructor(attributes) {
50398    super(CONFIG_NS_ID, "pickTrayByPDFSize");
50399  }
50400}
50401class config_Picture extends StringObject {
50402  constructor(attributes) {
50403    super(CONFIG_NS_ID, "picture");
50404  }
50405}
50406class PlaintextMetadata extends Option01 {
50407  constructor(attributes) {
50408    super(CONFIG_NS_ID, "plaintextMetadata");
50409  }
50410}
50411class Presence extends OptionObject {
50412  constructor(attributes) {
50413    super(CONFIG_NS_ID, "presence", ["preserve", "dissolve", "dissolveStructure", "ignore", "remove"]);
50414  }
50415}
50416class Present extends XFAObject {
50417  constructor(attributes) {
50418    super(CONFIG_NS_ID, "present", true);
50419    this.behaviorOverride = null;
50420    this.cache = null;
50421    this.common = null;
50422    this.copies = null;
50423    this.destination = null;
50424    this.incrementalMerge = null;
50425    this.layout = null;
50426    this.output = null;
50427    this.overprint = null;
50428    this.pagination = null;
50429    this.paginationOverride = null;
50430    this.script = null;
50431    this.validate = null;
50432    this.xdp = null;
50433    this.driver = new XFAObjectArray();
50434    this.labelPrinter = new XFAObjectArray();
50435    this.pcl = new XFAObjectArray();
50436    this.pdf = new XFAObjectArray();
50437    this.ps = new XFAObjectArray();
50438    this.submitUrl = new XFAObjectArray();
50439    this.webClient = new XFAObjectArray();
50440    this.zpl = new XFAObjectArray();
50441  }
50442}
50443class Print extends Option01 {
50444  constructor(attributes) {
50445    super(CONFIG_NS_ID, "print");
50446  }
50447}
50448class PrintHighQuality extends Option01 {
50449  constructor(attributes) {
50450    super(CONFIG_NS_ID, "printHighQuality");
50451  }
50452}
50453class PrintScaling extends OptionObject {
50454  constructor(attributes) {
50455    super(CONFIG_NS_ID, "printScaling", ["appdefault", "noScaling"]);
50456  }
50457}
50458class PrinterName extends StringObject {
50459  constructor(attributes) {
50460    super(CONFIG_NS_ID, "printerName");
50461  }
50462}
50463class Producer extends StringObject {
50464  constructor(attributes) {
50465    super(CONFIG_NS_ID, "producer");
50466  }
50467}
50468class Ps extends XFAObject {
50469  constructor(attributes) {
50470    super(CONFIG_NS_ID, "ps", true);
50471    this.name = attributes.name || "";
50472    this.batchOutput = null;
50473    this.fontInfo = null;
50474    this.jog = null;
50475    this.mediumInfo = null;
50476    this.outputBin = null;
50477    this.staple = null;
50478    this.xdc = null;
50479  }
50480}
50481class Range extends ContentObject {
50482  constructor(attributes) {
50483    super(CONFIG_NS_ID, "range");
50484  }
50485  [$finalize]() {
50486    this[$content] = this[$content].split(",", 2).map(range => range.split("-").map(x => parseInt(x.trim(), 10))).filter(range => range.every(x => !isNaN(x))).map(range => {
50487      if (range.length === 1) {
50488        range.push(range[0]);
50489      }
50490      return range;
50491    });
50492  }
50493}
50494class Record extends ContentObject {
50495  constructor(attributes) {
50496    super(CONFIG_NS_ID, "record");
50497  }
50498  [$finalize]() {
50499    this[$content] = this[$content].trim();
50500    const n = parseInt(this[$content], 10);
50501    if (!isNaN(n) && n >= 0) {
50502      this[$content] = n;
50503    }
50504  }
50505}
50506class Relevant extends ContentObject {
50507  constructor(attributes) {
50508    super(CONFIG_NS_ID, "relevant");
50509  }
50510  [$finalize]() {
50511    this[$content] = this[$content].trim().split(/\s+/);
50512  }
50513}
50514class Rename extends ContentObject {
50515  constructor(attributes) {
50516    super(CONFIG_NS_ID, "rename");
50517  }
50518  [$finalize]() {
50519    this[$content] = this[$content].trim();
50520    if (this[$content].toLowerCase().startsWith("xml") || /[\p{L}_][\p{L}\d._\p{M}-]*/u.test(this[$content])) {
50521      warn("XFA - Rename: invalid XFA name");
50522    }
50523  }
50524}
50525class RenderPolicy extends OptionObject {
50526  constructor(attributes) {
50527    super(CONFIG_NS_ID, "renderPolicy", ["server", "client"]);
50528  }
50529}
50530class RunScripts extends OptionObject {
50531  constructor(attributes) {
50532    super(CONFIG_NS_ID, "runScripts", ["both", "client", "none", "server"]);
50533  }
50534}
50535class config_Script extends XFAObject {
50536  constructor(attributes) {
50537    super(CONFIG_NS_ID, "script", true);
50538    this.currentPage = null;
50539    this.exclude = null;
50540    this.runScripts = null;
50541  }
50542}
50543class ScriptModel extends OptionObject {
50544  constructor(attributes) {
50545    super(CONFIG_NS_ID, "scriptModel", ["XFA", "none"]);
50546  }
50547}
50548class Severity extends OptionObject {
50549  constructor(attributes) {
50550    super(CONFIG_NS_ID, "severity", ["ignore", "error", "information", "trace", "warning"]);
50551  }
50552}
50553class SilentPrint extends XFAObject {
50554  constructor(attributes) {
50555    super(CONFIG_NS_ID, "silentPrint", true);
50556    this.addSilentPrint = null;
50557    this.printerName = null;
50558  }
50559}
50560class Staple extends XFAObject {
50561  constructor(attributes) {
50562    super(CONFIG_NS_ID, "staple");
50563    this.mode = getStringOption(attributes.mode, ["usePrinterSetting", "on", "off"]);
50564  }
50565}
50566class StartNode extends StringObject {
50567  constructor(attributes) {
50568    super(CONFIG_NS_ID, "startNode");
50569  }
50570}
50571class StartPage extends IntegerObject {
50572  constructor(attributes) {
50573    super(CONFIG_NS_ID, "startPage", 0, n => true);
50574  }
50575}
50576class SubmitFormat extends OptionObject {
50577  constructor(attributes) {
50578    super(CONFIG_NS_ID, "submitFormat", ["html", "delegate", "fdf", "xml", "pdf"]);
50579  }
50580}
50581class SubmitUrl extends StringObject {
50582  constructor(attributes) {
50583    super(CONFIG_NS_ID, "submitUrl");
50584  }
50585}
50586class SubsetBelow extends IntegerObject {
50587  constructor(attributes) {
50588    super(CONFIG_NS_ID, "subsetBelow", 100, n => n >= 0 && n <= 100);
50589  }
50590}
50591class SuppressBanner extends Option01 {
50592  constructor(attributes) {
50593    super(CONFIG_NS_ID, "suppressBanner");
50594  }
50595}
50596class Tagged extends Option01 {
50597  constructor(attributes) {
50598    super(CONFIG_NS_ID, "tagged");
50599  }
50600}
50601class config_Template extends XFAObject {
50602  constructor(attributes) {
50603    super(CONFIG_NS_ID, "template", true);
50604    this.base = null;
50605    this.relevant = null;
50606    this.startPage = null;
50607    this.uri = null;
50608    this.xsl = null;
50609  }
50610}
50611class Threshold extends OptionObject {
50612  constructor(attributes) {
50613    super(CONFIG_NS_ID, "threshold", ["trace", "error", "information", "warning"]);
50614  }
50615}
50616class To extends OptionObject {
50617  constructor(attributes) {
50618    super(CONFIG_NS_ID, "to", ["null", "memory", "stderr", "stdout", "system", "uri"]);
50619  }
50620}
50621class TemplateCache extends XFAObject {
50622  constructor(attributes) {
50623    super(CONFIG_NS_ID, "templateCache");
50624    this.maxEntries = getInteger({
50625      data: attributes.maxEntries,
50626      defaultValue: 5,
50627      validate: n => n >= 0
50628    });
50629  }
50630}
50631class Trace extends XFAObject {
50632  constructor(attributes) {
50633    super(CONFIG_NS_ID, "trace", true);
50634    this.area = new XFAObjectArray();
50635  }
50636}
50637class Transform extends XFAObject {
50638  constructor(attributes) {
50639    super(CONFIG_NS_ID, "transform", true);
50640    this.groupParent = null;
50641    this.ifEmpty = null;
50642    this.nameAttr = null;
50643    this.picture = null;
50644    this.presence = null;
50645    this.rename = null;
50646    this.whitespace = null;
50647  }
50648}
50649class Type extends OptionObject {
50650  constructor(attributes) {
50651    super(CONFIG_NS_ID, "type", ["none", "ascii85", "asciiHex", "ccittfax", "flate", "lzw", "runLength", "native", "xdp", "mergedXDP"]);
50652  }
50653}
50654class Uri extends StringObject {
50655  constructor(attributes) {
50656    super(CONFIG_NS_ID, "uri");
50657  }
50658}
50659class config_Validate extends OptionObject {
50660  constructor(attributes) {
50661    super(CONFIG_NS_ID, "validate", ["preSubmit", "prePrint", "preExecute", "preSave"]);
50662  }
50663}
50664class ValidateApprovalSignatures extends ContentObject {
50665  constructor(attributes) {
50666    super(CONFIG_NS_ID, "validateApprovalSignatures");
50667  }
50668  [$finalize]() {
50669    this[$content] = this[$content].trim().split(/\s+/).filter(x => ["docReady", "postSign"].includes(x));
50670  }
50671}
50672class ValidationMessaging extends OptionObject {
50673  constructor(attributes) {
50674    super(CONFIG_NS_ID, "validationMessaging", ["allMessagesIndividually", "allMessagesTogether", "firstMessageOnly", "noMessages"]);
50675  }
50676}
50677class Version extends OptionObject {
50678  constructor(attributes) {
50679    super(CONFIG_NS_ID, "version", ["1.7", "1.6", "1.5", "1.4", "1.3", "1.2"]);
50680  }
50681}
50682class VersionControl extends XFAObject {
50683  constructor(attributes) {
50684    super(CONFIG_NS_ID, "VersionControl");
50685    this.outputBelow = getStringOption(attributes.outputBelow, ["warn", "error", "update"]);
50686    this.sourceAbove = getStringOption(attributes.sourceAbove, ["warn", "error"]);
50687    this.sourceBelow = getStringOption(attributes.sourceBelow, ["update", "maintain"]);
50688  }
50689}
50690class ViewerPreferences extends XFAObject {
50691  constructor(attributes) {
50692    super(CONFIG_NS_ID, "viewerPreferences", true);
50693    this.ADBE_JSConsole = null;
50694    this.ADBE_JSDebugger = null;
50695    this.addViewerPreferences = null;
50696    this.duplexOption = null;
50697    this.enforce = null;
50698    this.numberOfCopies = null;
50699    this.pageRange = null;
50700    this.pickTrayByPDFSize = null;
50701    this.printScaling = null;
50702  }
50703}
50704class WebClient extends XFAObject {
50705  constructor(attributes) {
50706    super(CONFIG_NS_ID, "webClient", true);
50707    this.name = attributes.name ? attributes.name.trim() : "";
50708    this.fontInfo = null;
50709    this.xdc = null;
50710  }
50711}
50712class Whitespace extends OptionObject {
50713  constructor(attributes) {
50714    super(CONFIG_NS_ID, "whitespace", ["preserve", "ltrim", "normalize", "rtrim", "trim"]);
50715  }
50716}
50717class Window extends ContentObject {
50718  constructor(attributes) {
50719    super(CONFIG_NS_ID, "window");
50720  }
50721  [$finalize]() {
50722    const pair = this[$content].split(",", 2).map(x => parseInt(x.trim(), 10));
50723    if (pair.some(x => isNaN(x))) {
50724      this[$content] = [0, 0];
50725      return;
50726    }
50727    if (pair.length === 1) {
50728      pair.push(pair[0]);
50729    }
50730    this[$content] = pair;
50731  }
50732}
50733class Xdc extends XFAObject {
50734  constructor(attributes) {
50735    super(CONFIG_NS_ID, "xdc", true);
50736    this.uri = new XFAObjectArray();
50737    this.xsl = new XFAObjectArray();
50738  }
50739}
50740class Xdp extends XFAObject {
50741  constructor(attributes) {
50742    super(CONFIG_NS_ID, "xdp", true);
50743    this.packets = null;
50744  }
50745}
50746class Xsl extends XFAObject {
50747  constructor(attributes) {
50748    super(CONFIG_NS_ID, "xsl", true);
50749    this.debug = null;
50750    this.uri = null;
50751  }
50752}
50753class Zpl extends XFAObject {
50754  constructor(attributes) {
50755    super(CONFIG_NS_ID, "zpl", true);
50756    this.name = attributes.name ? attributes.name.trim() : "";
50757    this.batchOutput = null;
50758    this.flipLabel = null;
50759    this.fontInfo = null;
50760    this.xdc = null;
50761  }
50762}
50763class ConfigNamespace {
50764  static [$buildXFAObject](name, attributes) {
50765    if (Object.hasOwn(ConfigNamespace, name)) {
50766      return ConfigNamespace[name](attributes);
50767    }
50768    return undefined;
50769  }
50770  static acrobat(attrs) {
50771    return new Acrobat(attrs);
50772  }
50773  static acrobat7(attrs) {
50774    return new Acrobat7(attrs);
50775  }
50776  static ADBE_JSConsole(attrs) {
50777    return new ADBE_JSConsole(attrs);
50778  }
50779  static ADBE_JSDebugger(attrs) {
50780    return new ADBE_JSDebugger(attrs);
50781  }
50782  static addSilentPrint(attrs) {
50783    return new AddSilentPrint(attrs);
50784  }
50785  static addViewerPreferences(attrs) {
50786    return new AddViewerPreferences(attrs);
50787  }
50788  static adjustData(attrs) {
50789    return new AdjustData(attrs);
50790  }
50791  static adobeExtensionLevel(attrs) {
50792    return new AdobeExtensionLevel(attrs);
50793  }
50794  static agent(attrs) {
50795    return new Agent(attrs);
50796  }
50797  static alwaysEmbed(attrs) {
50798    return new AlwaysEmbed(attrs);
50799  }
50800  static amd(attrs) {
50801    return new Amd(attrs);
50802  }
50803  static area(attrs) {
50804    return new config_Area(attrs);
50805  }
50806  static attributes(attrs) {
50807    return new Attributes(attrs);
50808  }
50809  static autoSave(attrs) {
50810    return new AutoSave(attrs);
50811  }
50812  static base(attrs) {
50813    return new Base(attrs);
50814  }
50815  static batchOutput(attrs) {
50816    return new BatchOutput(attrs);
50817  }
50818  static behaviorOverride(attrs) {
50819    return new BehaviorOverride(attrs);
50820  }
50821  static cache(attrs) {
50822    return new Cache(attrs);
50823  }
50824  static change(attrs) {
50825    return new Change(attrs);
50826  }
50827  static common(attrs) {
50828    return new Common(attrs);
50829  }
50830  static compress(attrs) {
50831    return new Compress(attrs);
50832  }
50833  static compressLogicalStructure(attrs) {
50834    return new CompressLogicalStructure(attrs);
50835  }
50836  static compressObjectStream(attrs) {
50837    return new CompressObjectStream(attrs);
50838  }
50839  static compression(attrs) {
50840    return new Compression(attrs);
50841  }
50842  static config(attrs) {
50843    return new Config(attrs);
50844  }
50845  static conformance(attrs) {
50846    return new Conformance(attrs);
50847  }
50848  static contentCopy(attrs) {
50849    return new ContentCopy(attrs);
50850  }
50851  static copies(attrs) {
50852    return new Copies(attrs);
50853  }
50854  static creator(attrs) {
50855    return new Creator(attrs);
50856  }
50857  static currentPage(attrs) {
50858    return new CurrentPage(attrs);
50859  }
50860  static data(attrs) {
50861    return new Data(attrs);
50862  }
50863  static debug(attrs) {
50864    return new Debug(attrs);
50865  }
50866  static defaultTypeface(attrs) {
50867    return new DefaultTypeface(attrs);
50868  }
50869  static destination(attrs) {
50870    return new Destination(attrs);
50871  }
50872  static documentAssembly(attrs) {
50873    return new DocumentAssembly(attrs);
50874  }
50875  static driver(attrs) {
50876    return new Driver(attrs);
50877  }
50878  static duplexOption(attrs) {
50879    return new DuplexOption(attrs);
50880  }
50881  static dynamicRender(attrs) {
50882    return new DynamicRender(attrs);
50883  }
50884  static embed(attrs) {
50885    return new Embed(attrs);
50886  }
50887  static encrypt(attrs) {
50888    return new config_Encrypt(attrs);
50889  }
50890  static encryption(attrs) {
50891    return new config_Encryption(attrs);
50892  }
50893  static encryptionLevel(attrs) {
50894    return new EncryptionLevel(attrs);
50895  }
50896  static enforce(attrs) {
50897    return new Enforce(attrs);
50898  }
50899  static equate(attrs) {
50900    return new Equate(attrs);
50901  }
50902  static equateRange(attrs) {
50903    return new EquateRange(attrs);
50904  }
50905  static exclude(attrs) {
50906    return new Exclude(attrs);
50907  }
50908  static excludeNS(attrs) {
50909    return new ExcludeNS(attrs);
50910  }
50911  static flipLabel(attrs) {
50912    return new FlipLabel(attrs);
50913  }
50914  static fontInfo(attrs) {
50915    return new config_FontInfo(attrs);
50916  }
50917  static formFieldFilling(attrs) {
50918    return new FormFieldFilling(attrs);
50919  }
50920  static groupParent(attrs) {
50921    return new GroupParent(attrs);
50922  }
50923  static ifEmpty(attrs) {
50924    return new IfEmpty(attrs);
50925  }
50926  static includeXDPContent(attrs) {
50927    return new IncludeXDPContent(attrs);
50928  }
50929  static incrementalLoad(attrs) {
50930    return new IncrementalLoad(attrs);
50931  }
50932  static incrementalMerge(attrs) {
50933    return new IncrementalMerge(attrs);
50934  }
50935  static interactive(attrs) {
50936    return new Interactive(attrs);
50937  }
50938  static jog(attrs) {
50939    return new Jog(attrs);
50940  }
50941  static labelPrinter(attrs) {
50942    return new LabelPrinter(attrs);
50943  }
50944  static layout(attrs) {
50945    return new Layout(attrs);
50946  }
50947  static level(attrs) {
50948    return new Level(attrs);
50949  }
50950  static linearized(attrs) {
50951    return new Linearized(attrs);
50952  }
50953  static locale(attrs) {
50954    return new Locale(attrs);
50955  }
50956  static localeSet(attrs) {
50957    return new LocaleSet(attrs);
50958  }
50959  static log(attrs) {
50960    return new Log(attrs);
50961  }
50962  static map(attrs) {
50963    return new MapElement(attrs);
50964  }
50965  static mediumInfo(attrs) {
50966    return new MediumInfo(attrs);
50967  }
50968  static message(attrs) {
50969    return new config_Message(attrs);
50970  }
50971  static messaging(attrs) {
50972    return new Messaging(attrs);
50973  }
50974  static mode(attrs) {
50975    return new Mode(attrs);
50976  }
50977  static modifyAnnots(attrs) {
50978    return new ModifyAnnots(attrs);
50979  }
50980  static msgId(attrs) {
50981    return new MsgId(attrs);
50982  }
50983  static nameAttr(attrs) {
50984    return new NameAttr(attrs);
50985  }
50986  static neverEmbed(attrs) {
50987    return new NeverEmbed(attrs);
50988  }
50989  static numberOfCopies(attrs) {
50990    return new NumberOfCopies(attrs);
50991  }
50992  static openAction(attrs) {
50993    return new OpenAction(attrs);
50994  }
50995  static output(attrs) {
50996    return new Output(attrs);
50997  }
50998  static outputBin(attrs) {
50999    return new OutputBin(attrs);
51000  }
51001  static outputXSL(attrs) {
51002    return new OutputXSL(attrs);
51003  }
51004  static overprint(attrs) {
51005    return new Overprint(attrs);
51006  }
51007  static packets(attrs) {
51008    return new Packets(attrs);
51009  }
51010  static pageOffset(attrs) {
51011    return new PageOffset(attrs);
51012  }
51013  static pageRange(attrs) {
51014    return new PageRange(attrs);
51015  }
51016  static pagination(attrs) {
51017    return new Pagination(attrs);
51018  }
51019  static paginationOverride(attrs) {
51020    return new PaginationOverride(attrs);
51021  }
51022  static part(attrs) {
51023    return new Part(attrs);
51024  }
51025  static pcl(attrs) {
51026    return new Pcl(attrs);
51027  }
51028  static pdf(attrs) {
51029    return new Pdf(attrs);
51030  }
51031  static pdfa(attrs) {
51032    return new Pdfa(attrs);
51033  }
51034  static permissions(attrs) {
51035    return new Permissions(attrs);
51036  }
51037  static pickTrayByPDFSize(attrs) {
51038    return new PickTrayByPDFSize(attrs);
51039  }
51040  static picture(attrs) {
51041    return new config_Picture(attrs);
51042  }
51043  static plaintextMetadata(attrs) {
51044    return new PlaintextMetadata(attrs);
51045  }
51046  static presence(attrs) {
51047    return new Presence(attrs);
51048  }
51049  static present(attrs) {
51050    return new Present(attrs);
51051  }
51052  static print(attrs) {
51053    return new Print(attrs);
51054  }
51055  static printHighQuality(attrs) {
51056    return new PrintHighQuality(attrs);
51057  }
51058  static printScaling(attrs) {
51059    return new PrintScaling(attrs);
51060  }
51061  static printerName(attrs) {
51062    return new PrinterName(attrs);
51063  }
51064  static producer(attrs) {
51065    return new Producer(attrs);
51066  }
51067  static ps(attrs) {
51068    return new Ps(attrs);
51069  }
51070  static range(attrs) {
51071    return new Range(attrs);
51072  }
51073  static record(attrs) {
51074    return new Record(attrs);
51075  }
51076  static relevant(attrs) {
51077    return new Relevant(attrs);
51078  }
51079  static rename(attrs) {
51080    return new Rename(attrs);
51081  }
51082  static renderPolicy(attrs) {
51083    return new RenderPolicy(attrs);
51084  }
51085  static runScripts(attrs) {
51086    return new RunScripts(attrs);
51087  }
51088  static script(attrs) {
51089    return new config_Script(attrs);
51090  }
51091  static scriptModel(attrs) {
51092    return new ScriptModel(attrs);
51093  }
51094  static severity(attrs) {
51095    return new Severity(attrs);
51096  }
51097  static silentPrint(attrs) {
51098    return new SilentPrint(attrs);
51099  }
51100  static staple(attrs) {
51101    return new Staple(attrs);
51102  }
51103  static startNode(attrs) {
51104    return new StartNode(attrs);
51105  }
51106  static startPage(attrs) {
51107    return new StartPage(attrs);
51108  }
51109  static submitFormat(attrs) {
51110    return new SubmitFormat(attrs);
51111  }
51112  static submitUrl(attrs) {
51113    return new SubmitUrl(attrs);
51114  }
51115  static subsetBelow(attrs) {
51116    return new SubsetBelow(attrs);
51117  }
51118  static suppressBanner(attrs) {
51119    return new SuppressBanner(attrs);
51120  }
51121  static tagged(attrs) {
51122    return new Tagged(attrs);
51123  }
51124  static template(attrs) {
51125    return new config_Template(attrs);
51126  }
51127  static templateCache(attrs) {
51128    return new TemplateCache(attrs);
51129  }
51130  static threshold(attrs) {
51131    return new Threshold(attrs);
51132  }
51133  static to(attrs) {
51134    return new To(attrs);
51135  }
51136  static trace(attrs) {
51137    return new Trace(attrs);
51138  }
51139  static transform(attrs) {
51140    return new Transform(attrs);
51141  }
51142  static type(attrs) {
51143    return new Type(attrs);
51144  }
51145  static uri(attrs) {
51146    return new Uri(attrs);
51147  }
51148  static validate(attrs) {
51149    return new config_Validate(attrs);
51150  }
51151  static validateApprovalSignatures(attrs) {
51152    return new ValidateApprovalSignatures(attrs);
51153  }
51154  static validationMessaging(attrs) {
51155    return new ValidationMessaging(attrs);
51156  }
51157  static version(attrs) {
51158    return new Version(attrs);
51159  }
51160  static versionControl(attrs) {
51161    return new VersionControl(attrs);
51162  }
51163  static viewerPreferences(attrs) {
51164    return new ViewerPreferences(attrs);
51165  }
51166  static webClient(attrs) {
51167    return new WebClient(attrs);
51168  }
51169  static whitespace(attrs) {
51170    return new Whitespace(attrs);
51171  }
51172  static window(attrs) {
51173    return new Window(attrs);
51174  }
51175  static xdc(attrs) {
51176    return new Xdc(attrs);
51177  }
51178  static xdp(attrs) {
51179    return new Xdp(attrs);
51180  }
51181  static xsl(attrs) {
51182    return new Xsl(attrs);
51183  }
51184  static zpl(attrs) {
51185    return new Zpl(attrs);
51186  }
51187}
51188
51189;// ./src/core/xfa/connection_set.js
51190
51191
51192const CONNECTION_SET_NS_ID = NamespaceIds.connectionSet.id;
51193class ConnectionSet extends XFAObject {
51194  constructor(attributes) {
51195    super(CONNECTION_SET_NS_ID, "connectionSet", true);
51196    this.wsdlConnection = new XFAObjectArray();
51197    this.xmlConnection = new XFAObjectArray();
51198    this.xsdConnection = new XFAObjectArray();
51199  }
51200}
51201class EffectiveInputPolicy extends XFAObject {
51202  constructor(attributes) {
51203    super(CONNECTION_SET_NS_ID, "effectiveInputPolicy");
51204    this.id = attributes.id || "";
51205    this.name = attributes.name || "";
51206    this.use = attributes.use || "";
51207    this.usehref = attributes.usehref || "";
51208  }
51209}
51210class EffectiveOutputPolicy extends XFAObject {
51211  constructor(attributes) {
51212    super(CONNECTION_SET_NS_ID, "effectiveOutputPolicy");
51213    this.id = attributes.id || "";
51214    this.name = attributes.name || "";
51215    this.use = attributes.use || "";
51216    this.usehref = attributes.usehref || "";
51217  }
51218}
51219class Operation extends StringObject {
51220  constructor(attributes) {
51221    super(CONNECTION_SET_NS_ID, "operation");
51222    this.id = attributes.id || "";
51223    this.input = attributes.input || "";
51224    this.name = attributes.name || "";
51225    this.output = attributes.output || "";
51226    this.use = attributes.use || "";
51227    this.usehref = attributes.usehref || "";
51228  }
51229}
51230class RootElement extends StringObject {
51231  constructor(attributes) {
51232    super(CONNECTION_SET_NS_ID, "rootElement");
51233    this.id = attributes.id || "";
51234    this.name = attributes.name || "";
51235    this.use = attributes.use || "";
51236    this.usehref = attributes.usehref || "";
51237  }
51238}
51239class SoapAction extends StringObject {
51240  constructor(attributes) {
51241    super(CONNECTION_SET_NS_ID, "soapAction");
51242    this.id = attributes.id || "";
51243    this.name = attributes.name || "";
51244    this.use = attributes.use || "";
51245    this.usehref = attributes.usehref || "";
51246  }
51247}
51248class SoapAddress extends StringObject {
51249  constructor(attributes) {
51250    super(CONNECTION_SET_NS_ID, "soapAddress");
51251    this.id = attributes.id || "";
51252    this.name = attributes.name || "";
51253    this.use = attributes.use || "";
51254    this.usehref = attributes.usehref || "";
51255  }
51256}
51257class connection_set_Uri extends StringObject {
51258  constructor(attributes) {
51259    super(CONNECTION_SET_NS_ID, "uri");
51260    this.id = attributes.id || "";
51261    this.name = attributes.name || "";
51262    this.use = attributes.use || "";
51263    this.usehref = attributes.usehref || "";
51264  }
51265}
51266class WsdlAddress extends StringObject {
51267  constructor(attributes) {
51268    super(CONNECTION_SET_NS_ID, "wsdlAddress");
51269    this.id = attributes.id || "";
51270    this.name = attributes.name || "";
51271    this.use = attributes.use || "";
51272    this.usehref = attributes.usehref || "";
51273  }
51274}
51275class WsdlConnection extends XFAObject {
51276  constructor(attributes) {
51277    super(CONNECTION_SET_NS_ID, "wsdlConnection", true);
51278    this.dataDescription = attributes.dataDescription || "";
51279    this.name = attributes.name || "";
51280    this.effectiveInputPolicy = null;
51281    this.effectiveOutputPolicy = null;
51282    this.operation = null;
51283    this.soapAction = null;
51284    this.soapAddress = null;
51285    this.wsdlAddress = null;
51286  }
51287}
51288class XmlConnection extends XFAObject {
51289  constructor(attributes) {
51290    super(CONNECTION_SET_NS_ID, "xmlConnection", true);
51291    this.dataDescription = attributes.dataDescription || "";
51292    this.name = attributes.name || "";
51293    this.uri = null;
51294  }
51295}
51296class XsdConnection extends XFAObject {
51297  constructor(attributes) {
51298    super(CONNECTION_SET_NS_ID, "xsdConnection", true);
51299    this.dataDescription = attributes.dataDescription || "";
51300    this.name = attributes.name || "";
51301    this.rootElement = null;
51302    this.uri = null;
51303  }
51304}
51305class ConnectionSetNamespace {
51306  static [$buildXFAObject](name, attributes) {
51307    if (Object.hasOwn(ConnectionSetNamespace, name)) {
51308      return ConnectionSetNamespace[name](attributes);
51309    }
51310    return undefined;
51311  }
51312  static connectionSet(attrs) {
51313    return new ConnectionSet(attrs);
51314  }
51315  static effectiveInputPolicy(attrs) {
51316    return new EffectiveInputPolicy(attrs);
51317  }
51318  static effectiveOutputPolicy(attrs) {
51319    return new EffectiveOutputPolicy(attrs);
51320  }
51321  static operation(attrs) {
51322    return new Operation(attrs);
51323  }
51324  static rootElement(attrs) {
51325    return new RootElement(attrs);
51326  }
51327  static soapAction(attrs) {
51328    return new SoapAction(attrs);
51329  }
51330  static soapAddress(attrs) {
51331    return new SoapAddress(attrs);
51332  }
51333  static uri(attrs) {
51334    return new connection_set_Uri(attrs);
51335  }
51336  static wsdlAddress(attrs) {
51337    return new WsdlAddress(attrs);
51338  }
51339  static wsdlConnection(attrs) {
51340    return new WsdlConnection(attrs);
51341  }
51342  static xmlConnection(attrs) {
51343    return new XmlConnection(attrs);
51344  }
51345  static xsdConnection(attrs) {
51346    return new XsdConnection(attrs);
51347  }
51348}
51349
51350;// ./src/core/xfa/datasets.js
51351
51352
51353
51354const DATASETS_NS_ID = NamespaceIds.datasets.id;
51355class datasets_Data extends XmlObject {
51356  constructor(attributes) {
51357    super(DATASETS_NS_ID, "data", attributes);
51358  }
51359  [$isNsAgnostic]() {
51360    return true;
51361  }
51362}
51363class Datasets extends XFAObject {
51364  constructor(attributes) {
51365    super(DATASETS_NS_ID, "datasets", true);
51366    this.data = null;
51367    this.Signature = null;
51368  }
51369  [$onChild](child) {
51370    const name = child[$nodeName];
51371    if (name === "data" && child[$namespaceId] === DATASETS_NS_ID || name === "Signature" && child[$namespaceId] === NamespaceIds.signature.id) {
51372      this[name] = child;
51373    }
51374    this[$appendChild](child);
51375  }
51376}
51377class DatasetsNamespace {
51378  static [$buildXFAObject](name, attributes) {
51379    if (Object.hasOwn(DatasetsNamespace, name)) {
51380      return DatasetsNamespace[name](attributes);
51381    }
51382    return undefined;
51383  }
51384  static datasets(attributes) {
51385    return new Datasets(attributes);
51386  }
51387  static data(attributes) {
51388    return new datasets_Data(attributes);
51389  }
51390}
51391
51392;// ./src/core/xfa/locale_set.js
51393
51394
51395
51396const LOCALE_SET_NS_ID = NamespaceIds.localeSet.id;
51397class CalendarSymbols extends XFAObject {
51398  constructor(attributes) {
51399    super(LOCALE_SET_NS_ID, "calendarSymbols", true);
51400    this.name = "gregorian";
51401    this.dayNames = new XFAObjectArray(2);
51402    this.eraNames = null;
51403    this.meridiemNames = null;
51404    this.monthNames = new XFAObjectArray(2);
51405  }
51406}
51407class CurrencySymbol extends StringObject {
51408  constructor(attributes) {
51409    super(LOCALE_SET_NS_ID, "currencySymbol");
51410    this.name = getStringOption(attributes.name, ["symbol", "isoname", "decimal"]);
51411  }
51412}
51413class CurrencySymbols extends XFAObject {
51414  constructor(attributes) {
51415    super(LOCALE_SET_NS_ID, "currencySymbols", true);
51416    this.currencySymbol = new XFAObjectArray(3);
51417  }
51418}
51419class DatePattern extends StringObject {
51420  constructor(attributes) {
51421    super(LOCALE_SET_NS_ID, "datePattern");
51422    this.name = getStringOption(attributes.name, ["full", "long", "med", "short"]);
51423  }
51424}
51425class DatePatterns extends XFAObject {
51426  constructor(attributes) {
51427    super(LOCALE_SET_NS_ID, "datePatterns", true);
51428    this.datePattern = new XFAObjectArray(4);
51429  }
51430}
51431class DateTimeSymbols extends ContentObject {
51432  constructor(attributes) {
51433    super(LOCALE_SET_NS_ID, "dateTimeSymbols");
51434  }
51435}
51436class Day extends StringObject {
51437  constructor(attributes) {
51438    super(LOCALE_SET_NS_ID, "day");
51439  }
51440}
51441class DayNames extends XFAObject {
51442  constructor(attributes) {
51443    super(LOCALE_SET_NS_ID, "dayNames", true);
51444    this.abbr = getInteger({
51445      data: attributes.abbr,
51446      defaultValue: 0,
51447      validate: x => x === 1
51448    });
51449    this.day = new XFAObjectArray(7);
51450  }
51451}
51452class Era extends StringObject {
51453  constructor(attributes) {
51454    super(LOCALE_SET_NS_ID, "era");
51455  }
51456}
51457class EraNames extends XFAObject {
51458  constructor(attributes) {
51459    super(LOCALE_SET_NS_ID, "eraNames", true);
51460    this.era = new XFAObjectArray(2);
51461  }
51462}
51463class locale_set_Locale extends XFAObject {
51464  constructor(attributes) {
51465    super(LOCALE_SET_NS_ID, "locale", true);
51466    this.desc = attributes.desc || "";
51467    this.name = "isoname";
51468    this.calendarSymbols = null;
51469    this.currencySymbols = null;
51470    this.datePatterns = null;
51471    this.dateTimeSymbols = null;
51472    this.numberPatterns = null;
51473    this.numberSymbols = null;
51474    this.timePatterns = null;
51475    this.typeFaces = null;
51476  }
51477}
51478class locale_set_LocaleSet extends XFAObject {
51479  constructor(attributes) {
51480    super(LOCALE_SET_NS_ID, "localeSet", true);
51481    this.locale = new XFAObjectArray();
51482  }
51483}
51484class Meridiem extends StringObject {
51485  constructor(attributes) {
51486    super(LOCALE_SET_NS_ID, "meridiem");
51487  }
51488}
51489class MeridiemNames extends XFAObject {
51490  constructor(attributes) {
51491    super(LOCALE_SET_NS_ID, "meridiemNames", true);
51492    this.meridiem = new XFAObjectArray(2);
51493  }
51494}
51495class Month extends StringObject {
51496  constructor(attributes) {
51497    super(LOCALE_SET_NS_ID, "month");
51498  }
51499}
51500class MonthNames extends XFAObject {
51501  constructor(attributes) {
51502    super(LOCALE_SET_NS_ID, "monthNames", true);
51503    this.abbr = getInteger({
51504      data: attributes.abbr,
51505      defaultValue: 0,
51506      validate: x => x === 1
51507    });
51508    this.month = new XFAObjectArray(12);
51509  }
51510}
51511class NumberPattern extends StringObject {
51512  constructor(attributes) {
51513    super(LOCALE_SET_NS_ID, "numberPattern");
51514    this.name = getStringOption(attributes.name, ["full", "long", "med", "short"]);
51515  }
51516}
51517class NumberPatterns extends XFAObject {
51518  constructor(attributes) {
51519    super(LOCALE_SET_NS_ID, "numberPatterns", true);
51520    this.numberPattern = new XFAObjectArray(4);
51521  }
51522}
51523class NumberSymbol extends StringObject {
51524  constructor(attributes) {
51525    super(LOCALE_SET_NS_ID, "numberSymbol");
51526    this.name = getStringOption(attributes.name, ["decimal", "grouping", "percent", "minus", "zero"]);
51527  }
51528}
51529class NumberSymbols extends XFAObject {
51530  constructor(attributes) {
51531    super(LOCALE_SET_NS_ID, "numberSymbols", true);
51532    this.numberSymbol = new XFAObjectArray(5);
51533  }
51534}
51535class TimePattern extends StringObject {
51536  constructor(attributes) {
51537    super(LOCALE_SET_NS_ID, "timePattern");
51538    this.name = getStringOption(attributes.name, ["full", "long", "med", "short"]);
51539  }
51540}
51541class TimePatterns extends XFAObject {
51542  constructor(attributes) {
51543    super(LOCALE_SET_NS_ID, "timePatterns", true);
51544    this.timePattern = new XFAObjectArray(4);
51545  }
51546}
51547class TypeFace extends XFAObject {
51548  constructor(attributes) {
51549    super(LOCALE_SET_NS_ID, "typeFace", true);
51550    this.name = attributes.name | "";
51551  }
51552}
51553class TypeFaces extends XFAObject {
51554  constructor(attributes) {
51555    super(LOCALE_SET_NS_ID, "typeFaces", true);
51556    this.typeFace = new XFAObjectArray();
51557  }
51558}
51559class LocaleSetNamespace {
51560  static [$buildXFAObject](name, attributes) {
51561    if (Object.hasOwn(LocaleSetNamespace, name)) {
51562      return LocaleSetNamespace[name](attributes);
51563    }
51564    return undefined;
51565  }
51566  static calendarSymbols(attrs) {
51567    return new CalendarSymbols(attrs);
51568  }
51569  static currencySymbol(attrs) {
51570    return new CurrencySymbol(attrs);
51571  }
51572  static currencySymbols(attrs) {
51573    return new CurrencySymbols(attrs);
51574  }
51575  static datePattern(attrs) {
51576    return new DatePattern(attrs);
51577  }
51578  static datePatterns(attrs) {
51579    return new DatePatterns(attrs);
51580  }
51581  static dateTimeSymbols(attrs) {
51582    return new DateTimeSymbols(attrs);
51583  }
51584  static day(attrs) {
51585    return new Day(attrs);
51586  }
51587  static dayNames(attrs) {
51588    return new DayNames(attrs);
51589  }
51590  static era(attrs) {
51591    return new Era(attrs);
51592  }
51593  static eraNames(attrs) {
51594    return new EraNames(attrs);
51595  }
51596  static locale(attrs) {
51597    return new locale_set_Locale(attrs);
51598  }
51599  static localeSet(attrs) {
51600    return new locale_set_LocaleSet(attrs);
51601  }
51602  static meridiem(attrs) {
51603    return new Meridiem(attrs);
51604  }
51605  static meridiemNames(attrs) {
51606    return new MeridiemNames(attrs);
51607  }
51608  static month(attrs) {
51609    return new Month(attrs);
51610  }
51611  static monthNames(attrs) {
51612    return new MonthNames(attrs);
51613  }
51614  static numberPattern(attrs) {
51615    return new NumberPattern(attrs);
51616  }
51617  static numberPatterns(attrs) {
51618    return new NumberPatterns(attrs);
51619  }
51620  static numberSymbol(attrs) {
51621    return new NumberSymbol(attrs);
51622  }
51623  static numberSymbols(attrs) {
51624    return new NumberSymbols(attrs);
51625  }
51626  static timePattern(attrs) {
51627    return new TimePattern(attrs);
51628  }
51629  static timePatterns(attrs) {
51630    return new TimePatterns(attrs);
51631  }
51632  static typeFace(attrs) {
51633    return new TypeFace(attrs);
51634  }
51635  static typeFaces(attrs) {
51636    return new TypeFaces(attrs);
51637  }
51638}
51639
51640;// ./src/core/xfa/signature.js
51641
51642
51643const SIGNATURE_NS_ID = NamespaceIds.signature.id;
51644class signature_Signature extends XFAObject {
51645  constructor(attributes) {
51646    super(SIGNATURE_NS_ID, "signature", true);
51647  }
51648}
51649class SignatureNamespace {
51650  static [$buildXFAObject](name, attributes) {
51651    if (Object.hasOwn(SignatureNamespace, name)) {
51652      return SignatureNamespace[name](attributes);
51653    }
51654    return undefined;
51655  }
51656  static signature(attributes) {
51657    return new signature_Signature(attributes);
51658  }
51659}
51660
51661;// ./src/core/xfa/stylesheet.js
51662
51663
51664const STYLESHEET_NS_ID = NamespaceIds.stylesheet.id;
51665class Stylesheet extends XFAObject {
51666  constructor(attributes) {
51667    super(STYLESHEET_NS_ID, "stylesheet", true);
51668  }
51669}
51670class StylesheetNamespace {
51671  static [$buildXFAObject](name, attributes) {
51672    if (Object.hasOwn(StylesheetNamespace, name)) {
51673      return StylesheetNamespace[name](attributes);
51674    }
51675    return undefined;
51676  }
51677  static stylesheet(attributes) {
51678    return new Stylesheet(attributes);
51679  }
51680}
51681
51682;// ./src/core/xfa/xdp.js
51683
51684
51685
51686const XDP_NS_ID = NamespaceIds.xdp.id;
51687class xdp_Xdp extends XFAObject {
51688  constructor(attributes) {
51689    super(XDP_NS_ID, "xdp", true);
51690    this.uuid = attributes.uuid || "";
51691    this.timeStamp = attributes.timeStamp || "";
51692    this.config = null;
51693    this.connectionSet = null;
51694    this.datasets = null;
51695    this.localeSet = null;
51696    this.stylesheet = new XFAObjectArray();
51697    this.template = null;
51698  }
51699  [$onChildCheck](child) {
51700    const ns = NamespaceIds[child[$nodeName]];
51701    return ns && child[$namespaceId] === ns.id;
51702  }
51703}
51704class XdpNamespace {
51705  static [$buildXFAObject](name, attributes) {
51706    if (Object.hasOwn(XdpNamespace, name)) {
51707      return XdpNamespace[name](attributes);
51708    }
51709    return undefined;
51710  }
51711  static xdp(attributes) {
51712    return new xdp_Xdp(attributes);
51713  }
51714}
51715
51716;// ./src/core/xfa/xhtml.js
51717
51718
51719
51720
51721
51722const XHTML_NS_ID = NamespaceIds.xhtml.id;
51723const $richText = Symbol();
51724const VALID_STYLES = new Set(["color", "font", "font-family", "font-size", "font-stretch", "font-style", "font-weight", "margin", "margin-bottom", "margin-left", "margin-right", "margin-top", "letter-spacing", "line-height", "orphans", "page-break-after", "page-break-before", "page-break-inside", "tab-interval", "tab-stop", "text-align", "text-decoration", "text-indent", "vertical-align", "widows", "kerning-mode", "xfa-font-horizontal-scale", "xfa-font-vertical-scale", "xfa-spacerun", "xfa-tab-stops"]);
51725const StyleMapping = new Map([["page-break-after", "breakAfter"], ["page-break-before", "breakBefore"], ["page-break-inside", "breakInside"], ["kerning-mode", value => value === "none" ? "none" : "normal"], ["xfa-font-horizontal-scale", value => `scaleX(${Math.max(0, parseInt(value, 10) / 100).toFixed(2)})`], ["xfa-font-vertical-scale", value => `scaleY(${Math.max(0, parseInt(value, 10) / 100).toFixed(2)})`], ["xfa-spacerun", ""], ["xfa-tab-stops", ""], ["font-size", (value, original) => {
51726  value = original.fontSize = Math.abs(getMeasurement(value));
51727  return measureToString(0.99 * value);
51728}], ["letter-spacing", value => measureToString(getMeasurement(value))], ["line-height", value => measureToString(getMeasurement(value))], ["margin", value => measureToString(getMeasurement(value))], ["margin-bottom", value => measureToString(getMeasurement(value))], ["margin-left", value => measureToString(getMeasurement(value))], ["margin-right", value => measureToString(getMeasurement(value))], ["margin-top", value => measureToString(getMeasurement(value))], ["text-indent", value => measureToString(getMeasurement(value))], ["font-family", value => value], ["vertical-align", value => measureToString(getMeasurement(value))]]);
51729const spacesRegExp = /\s+/g;
51730const crlfRegExp = /[\r\n]+/g;
51731const crlfForRichTextRegExp = /\r\n?/g;
51732function mapStyle(styleStr, node, richText) {
51733  const style = Object.create(null);
51734  if (!styleStr) {
51735    return style;
51736  }
51737  const original = Object.create(null);
51738  for (const [key, value] of styleStr.split(";").map(s => s.split(":", 2))) {
51739    const mapping = StyleMapping.get(key);
51740    if (mapping === "") {
51741      continue;
51742    }
51743    let newValue = value;
51744    if (mapping) {
51745      newValue = typeof mapping === "string" ? mapping : mapping(value, original);
51746    }
51747    if (key.endsWith("scale")) {
51748      style.transform = style.transform ? `${style[key]} ${newValue}` : newValue;
51749    } else {
51750      style[key.replaceAll(/-([a-z])/gi, (_, x) => x.toUpperCase())] = newValue;
51751    }
51752  }
51753  if (style.fontFamily) {
51754    setFontFamily({
51755      typeface: style.fontFamily,
51756      weight: style.fontWeight || "normal",
51757      posture: style.fontStyle || "normal",
51758      size: original.fontSize || 0
51759    }, node, node[$globalData].fontFinder, style);
51760  }
51761  if (richText && style.verticalAlign && style.verticalAlign !== "0px" && style.fontSize) {
51762    const SUB_SUPER_SCRIPT_FACTOR = 0.583;
51763    const VERTICAL_FACTOR = 0.333;
51764    const fontSize = getMeasurement(style.fontSize);
51765    style.fontSize = measureToString(fontSize * SUB_SUPER_SCRIPT_FACTOR);
51766    style.verticalAlign = measureToString(Math.sign(getMeasurement(style.verticalAlign)) * fontSize * VERTICAL_FACTOR);
51767  }
51768  if (richText && style.fontSize) {
51769    style.fontSize = `calc(${style.fontSize} * var(--total-scale-factor))`;
51770  }
51771  fixTextIndent(style);
51772  return style;
51773}
51774function checkStyle(node) {
51775  if (!node.style) {
51776    return "";
51777  }
51778  return node.style.split(";").filter(s => !!s.trim()).map(s => s.split(":", 2).map(t => t.trim())).filter(([key, value]) => {
51779    if (key === "font-family") {
51780      node[$globalData].usedTypefaces.add(value);
51781    }
51782    return VALID_STYLES.has(key);
51783  }).map(kv => kv.join(":")).join(";");
51784}
51785const NoWhites = new Set(["body", "html"]);
51786class XhtmlObject extends XmlObject {
51787  constructor(attributes, name) {
51788    super(XHTML_NS_ID, name);
51789    this[$richText] = false;
51790    this.style = attributes.style || "";
51791  }
51792  [$clean](builder) {
51793    super[$clean](builder);
51794    this.style = checkStyle(this);
51795  }
51796  [$acceptWhitespace]() {
51797    return !NoWhites.has(this[$nodeName]);
51798  }
51799  [$onText](str, richText = false) {
51800    if (!richText) {
51801      str = str.replaceAll(crlfRegExp, "");
51802      if (!this.style.includes("xfa-spacerun:yes")) {
51803        str = str.replaceAll(spacesRegExp, " ");
51804      }
51805    } else {
51806      this[$richText] = true;
51807    }
51808    if (str) {
51809      this[$content] += str;
51810    }
51811  }
51812  [$pushGlyphs](measure, mustPop = true) {
51813    const xfaFont = Object.create(null);
51814    const margin = {
51815      top: NaN,
51816      bottom: NaN,
51817      left: NaN,
51818      right: NaN
51819    };
51820    let lineHeight = null;
51821    for (const [key, value] of this.style.split(";").map(s => s.split(":", 2))) {
51822      switch (key) {
51823        case "font-family":
51824          xfaFont.typeface = stripQuotes(value);
51825          break;
51826        case "font-size":
51827          xfaFont.size = getMeasurement(value);
51828          break;
51829        case "font-weight":
51830          xfaFont.weight = value;
51831          break;
51832        case "font-style":
51833          xfaFont.posture = value;
51834          break;
51835        case "letter-spacing":
51836          xfaFont.letterSpacing = getMeasurement(value);
51837          break;
51838        case "margin":
51839          const values = value.split(/ \t/).map(
51839x => getMeasurement(x)
vendor: 10,503 bytes, lines 51839-52299
51839);
51840          switch (values.length) {
51841            case 1:
51842              margin.top = margin.bottom = margin.left = margin.right = values[0];
51843              break;
51844            case 2:
51845              margin.top = margin.bottom = values[0];
51846              margin.left = margin.right = values[1];
51847              break;
51848            case 3:
51849              margin.top = values[0];
51850              margin.bottom = values[2];
51851              margin.left = margin.right = values[1];
51852              break;
51853            case 4:
51854              margin.top = values[0];
51855              margin.left = values[1];
51856              margin.bottom = values[2];
51857              margin.right = values[3];
51858              break;
51859          }
51860          break;
51861        case "margin-top":
51862          margin.top = getMeasurement(value);
51863          break;
51864        case "margin-bottom":
51865          margin.bottom = getMeasurement(value);
51866          break;
51867        case "margin-left":
51868          margin.left = getMeasurement(value);
51869          break;
51870        case "margin-right":
51871          margin.right = getMeasurement(value);
51872          break;
51873        case "line-height":
51874          lineHeight = getMeasurement(value);
51875          break;
51876      }
51877    }
51878    measure.pushData(xfaFont, margin, lineHeight);
51879    if (this[$content]) {
51880      measure.addString(this[$content]);
51881    } else {
51882      for (const child of this[$getChildren]()) {
51883        if (child[$nodeName] === "#text") {
51884          measure.addString(child[$content]);
51885          continue;
51886        }
51887        child[$pushGlyphs](measure);
51888      }
51889    }
51890    if (mustPop) {
51891      measure.popFont();
51892    }
51893  }
51894  [$toHTML](availableSpace) {
51895    const children = [];
51896    this[$extra] = {
51897      children
51898    };
51899    this[$childrenToHTML]({});
51900    if (children.length === 0 && !this[$content]) {
51901      return HTMLResult.EMPTY;
51902    }
51903    let value;
51904    if (this[$richText]) {
51905      value = this[$content] ? this[$content].replaceAll(crlfForRichTextRegExp, "\n") : undefined;
51906    } else {
51907      value = this[$content] || undefined;
51908    }
51909    return HTMLResult.success({
51910      name: this[$nodeName],
51911      attributes: {
51912        href: this.href,
51913        style: mapStyle(this.style, this, this[$richText])
51914      },
51915      children,
51916      value
51917    });
51918  }
51919}
51920class A extends XhtmlObject {
51921  constructor(attributes) {
51922    super(attributes, "a");
51923    this.href = fixURL(attributes.href) || "";
51924  }
51925}
51926class B extends XhtmlObject {
51927  constructor(attributes) {
51928    super(attributes, "b");
51929  }
51930  [$pushGlyphs](measure) {
51931    measure.pushFont({
51932      weight: "bold"
51933    });
51934    super[$pushGlyphs](measure);
51935    measure.popFont();
51936  }
51937}
51938class Body extends XhtmlObject {
51939  constructor(attributes) {
51940    super(attributes, "body");
51941  }
51942  [$toHTML](availableSpace) {
51943    const res = super[$toHTML](availableSpace);
51944    const {
51945      html
51946    } = res;
51947    if (!html) {
51948      return HTMLResult.EMPTY;
51949    }
51950    html.name = "div";
51951    html.attributes.class = ["xfaRich"];
51952    return res;
51953  }
51954}
51955class Br extends XhtmlObject {
51956  constructor(attributes) {
51957    super(attributes, "br");
51958  }
51959  [$text]() {
51960    return "\n";
51961  }
51962  [$pushGlyphs](measure) {
51963    measure.addString("\n");
51964  }
51965  [$toHTML](availableSpace) {
51966    return HTMLResult.success({
51967      name: "br"
51968    });
51969  }
51970}
51971class Html extends XhtmlObject {
51972  constructor(attributes) {
51973    super(attributes, "html");
51974  }
51975  [$toHTML](availableSpace) {
51976    const children = [];
51977    this[$extra] = {
51978      children
51979    };
51980    this[$childrenToHTML]({});
51981    if (children.length === 0) {
51982      return HTMLResult.success({
51983        name: "div",
51984        attributes: {
51985          class: ["xfaRich"],
51986          style: {}
51987        },
51988        value: this[$content] || ""
51989      });
51990    }
51991    if (children.length === 1) {
51992      const child = children[0];
51993      if (child.attributes?.class.includes("xfaRich")) {
51994        return HTMLResult.success(child);
51995      }
51996    }
51997    return HTMLResult.success({
51998      name: "div",
51999      attributes: {
52000        class: ["xfaRich"],
52001        style: {}
52002      },
52003      children
52004    });
52005  }
52006}
52007class I extends XhtmlObject {
52008  constructor(attributes) {
52009    super(attributes, "i");
52010  }
52011  [$pushGlyphs](measure) {
52012    measure.pushFont({
52013      posture: "italic"
52014    });
52015    super[$pushGlyphs](measure);
52016    measure.popFont();
52017  }
52018}
52019class Li extends XhtmlObject {
52020  constructor(attributes) {
52021    super(attributes, "li");
52022  }
52023}
52024class Ol extends XhtmlObject {
52025  constructor(attributes) {
52026    super(attributes, "ol");
52027  }
52028}
52029class P extends XhtmlObject {
52030  constructor(attributes) {
52031    super(attributes, "p");
52032  }
52033  [$pushGlyphs](measure) {
52034    super[$pushGlyphs](measure, false);
52035    measure.addString("\n");
52036    measure.addPara();
52037    measure.popFont();
52038  }
52039  [$text]() {
52040    const siblings = this[$getParent]()[$getChildren]();
52041    if (siblings.at(-1) === this) {
52042      return super[$text]();
52043    }
52044    return super[$text]() + "\n";
52045  }
52046}
52047class Span extends XhtmlObject {
52048  constructor(attributes) {
52049    super(attributes, "span");
52050  }
52051}
52052class Sub extends XhtmlObject {
52053  constructor(attributes) {
52054    super(attributes, "sub");
52055  }
52056}
52057class Sup extends XhtmlObject {
52058  constructor(attributes) {
52059    super(attributes, "sup");
52060  }
52061}
52062class Ul extends XhtmlObject {
52063  constructor(attributes) {
52064    super(attributes, "ul");
52065  }
52066}
52067class XhtmlNamespace {
52068  static [$buildXFAObject](name, attributes) {
52069    if (Object.hasOwn(XhtmlNamespace, name)) {
52070      return XhtmlNamespace[name](attributes);
52071    }
52072    return undefined;
52073  }
52074  static a(attributes) {
52075    return new A(attributes);
52076  }
52077  static b(attributes) {
52078    return new B(attributes);
52079  }
52080  static body(attributes) {
52081    return new Body(attributes);
52082  }
52083  static br(attributes) {
52084    return new Br(attributes);
52085  }
52086  static html(attributes) {
52087    return new Html(attributes);
52088  }
52089  static i(attributes) {
52090    return new I(attributes);
52091  }
52092  static li(attributes) {
52093    return new Li(attributes);
52094  }
52095  static ol(attributes) {
52096    return new Ol(attributes);
52097  }
52098  static p(attributes) {
52099    return new P(attributes);
52100  }
52101  static span(attributes) {
52102    return new Span(attributes);
52103  }
52104  static sub(attributes) {
52105    return new Sub(attributes);
52106  }
52107  static sup(attributes) {
52108    return new Sup(attributes);
52109  }
52110  static ul(attributes) {
52111    return new Ul(attributes);
52112  }
52113}
52114
52115;// ./src/core/xfa/setup.js
52116
52117
52118
52119
52120
52121
52122
52123
52124
52125const NamespaceSetUp = {
52126  config: ConfigNamespace,
52127  connection: ConnectionSetNamespace,
52128  datasets: DatasetsNamespace,
52129  localeSet: LocaleSetNamespace,
52130  signature: SignatureNamespace,
52131  stylesheet: StylesheetNamespace,
52132  template: TemplateNamespace,
52133  xdp: XdpNamespace,
52134  xhtml: XhtmlNamespace
52135};
52136
52137;// ./src/core/xfa/unknown.js
52138
52139
52140class UnknownNamespace {
52141  constructor(nsId) {
52142    this.namespaceId = nsId;
52143  }
52144  [$buildXFAObject](name, attributes) {
52145    return new XmlObject(this.namespaceId, name, attributes);
52146  }
52147}
52148
52149;// ./src/core/xfa/builder.js
52150
52151
52152
52153
52154
52155
52156
52157class Root extends XFAObject {
52158  constructor(ids) {
52159    super(-1, "root", Object.create(null));
52160    this.element = null;
52161    this[$ids] = ids;
52162  }
52163  [$onChild](child) {
52164    this.element = child;
52165    return true;
52166  }
52167  [$finalize]() {
52168    super[$finalize]();
52169    if (this.element.template instanceof Template) {
52170      this[$ids].set($root, this.element);
52171      this.element.template[$resolvePrototypes](this[$ids]);
52172      this.element.template[$ids] = this[$ids];
52173    }
52174  }
52175}
52176class Empty extends XFAObject {
52177  constructor() {
52178    super(-1, "", Object.create(null));
52179  }
52180  [$onChild](_) {
52181    return false;
52182  }
52183}
52184class Builder {
52185  constructor(rootNameSpace = null) {
52186    this._namespaceStack = [];
52187    this._nsAgnosticLevel = 0;
52188    this._namespacePrefixes = new Map();
52189    this._namespaces = new Map();
52190    this._nextNsId = Math.max(...Object.values(NamespaceIds).map(({
52191      id
52192    }) => id));
52193    this._currentNamespace = rootNameSpace || new UnknownNamespace(++this._nextNsId);
52194  }
52195  buildRoot(ids) {
52196    return new Root(ids);
52197  }
52198  build({
52199    nsPrefix,
52200    name,
52201    attributes,
52202    namespace,
52203    prefixes
52204  }) {
52205    const hasNamespaceDef = namespace !== null;
52206    if (hasNamespaceDef) {
52207      this._namespaceStack.push(this._currentNamespace);
52208      this._currentNamespace = this._searchNamespace(namespace);
52209    }
52210    if (prefixes) {
52211      this._addNamespacePrefix(prefixes);
52212    }
52213    if (Object.hasOwn(attributes, $nsAttributes)) {
52214      const dataTemplate = NamespaceSetUp.datasets;
52215      const nsAttrs = attributes[$nsAttributes];
52216      let xfaAttrs = null;
52217      for (const [ns, attrs] of Object.entries(nsAttrs)) {
52218        const nsToUse = this._getNamespaceToUse(ns);
52219        if (nsToUse === dataTemplate) {
52220          xfaAttrs = {
52221            xfa: attrs
52222          };
52223          break;
52224        }
52225      }
52226      if (xfaAttrs) {
52227        attributes[$nsAttributes] = xfaAttrs;
52228      } else {
52229        delete attributes[$nsAttributes];
52230      }
52231    }
52232    const namespaceToUse = this._getNamespaceToUse(nsPrefix);
52233    const node = namespaceToUse?.[$buildXFAObject](name, attributes) || new Empty();
52234    if (node[$isNsAgnostic]()) {
52235      this._nsAgnosticLevel++;
52236    }
52237    if (hasNamespaceDef || prefixes || node[$isNsAgnostic]()) {
52238      node[$cleanup] = {
52239        hasNamespace: hasNamespaceDef,
52240        prefixes,
52241        nsAgnostic: node[$isNsAgnostic]()
52242      };
52243    }
52244    return node;
52245  }
52246  isNsAgnostic() {
52247    return this._nsAgnosticLevel > 0;
52248  }
52249  _searchNamespace(nsName) {
52250    let ns = this._namespaces.get(nsName);
52251    if (ns) {
52252      return ns;
52253    }
52254    for (const [name, {
52255      check
52256    }] of Object.entries(NamespaceIds)) {
52257      if (check(nsName)) {
52258        ns = NamespaceSetUp[name];
52259        if (ns) {
52260          this._namespaces.set(nsName, ns);
52261          return ns;
52262        }
52263        break;
52264      }
52265    }
52266    ns = new UnknownNamespace(++this._nextNsId);
52267    this._namespaces.set(nsName, ns);
52268    return ns;
52269  }
52270  _addNamespacePrefix(prefixes) {
52271    for (const {
52272      prefix,
52273      value
52274    } of prefixes) {
52275      const namespace = this._searchNamespace(value);
52276      this._namespacePrefixes.getOrInsertComputed(prefix, makeArr).push(namespace);
52277    }
52278  }
52279  _getNamespaceToUse(prefix) {
52280    if (!prefix) {
52281      return this._currentNamespace;
52282    }
52283    const prefixStack = this._namespacePrefixes.get(prefix);
52284    if (prefixStack?.length > 0) {
52285      return prefixStack.at(-1);
52286    }
52287    warn(`Unknown namespace prefix: ${prefix}.`);
52288    return null;
52289  }
52290  clean(data) {
52291    const {
52292      hasNamespace,
52293      prefixes,
52294      nsAgnostic
52295    } = data;
52296    if (hasNamespace) {
52297      this._currentNamespace = this._namespaceStack.pop();
52298    }
52299    
vendor: 6,397 bytes, lines 52299-52546
52299if (prefixes) {
52300      prefixes.forEach(({
52301        prefix
52302      }) => {
52303        this._namespacePrefixes.get(prefix).pop();
52304      });
52305    }
52306    if (nsAgnostic) {
52307      this._nsAgnosticLevel--;
52308    }
52309  }
52310}
52311
52312;// ./src/core/xfa/parser.js
52313
52314
52315
52316
52317class XFAParser extends XMLParserBase {
52318  constructor(rootNameSpace = null, richText = false) {
52319    super();
52320    this._builder = new Builder(rootNameSpace);
52321    this._stack = [];
52322    this._globalData = {
52323      usedTypefaces: new Set()
52324    };
52325    this._ids = new Map();
52326    this._current = this._builder.buildRoot(this._ids);
52327    this._errorCode = XMLParserErrorCode.NoError;
52328    this._whiteRegex = /^\s+$/;
52329    this._nbsps = /\xa0+/g;
52330    this._richText = richText;
52331  }
52332  parse(data) {
52333    this.parseXml(data);
52334    if (this._errorCode !== XMLParserErrorCode.NoError) {
52335      return undefined;
52336    }
52337    this._current[$finalize]();
52338    return this._current.element;
52339  }
52340  onText(text) {
52341    text = text.replace(this._nbsps, match => match.slice(1) + " ");
52342    if (this._richText || this._current[$acceptWhitespace]()) {
52343      this._current[$onText](text, this._richText);
52344      return;
52345    }
52346    if (this._whiteRegex.test(text)) {
52347      return;
52348    }
52349    this._current[$onText](text.trim());
52350  }
52351  onCdata(text) {
52352    this._current[$onText](text);
52353  }
52354  _mkAttributes(attributes, tagName) {
52355    let namespace = null;
52356    let prefixes = null;
52357    const attributeObj = Object.create({});
52358    for (const {
52359      name,
52360      value
52361    } of attributes) {
52362      if (name === "xmlns") {
52363        if (!namespace) {
52364          namespace = value;
52365        } else {
52366          warn(`XFA - multiple namespace definition in <${tagName}>`);
52367        }
52368      } else if (name.startsWith("xmlns:")) {
52369        const prefix = name.substring("xmlns:".length);
52370        prefixes ??= [];
52371        prefixes.push({
52372          prefix,
52373          value
52374        });
52375      } else {
52376        const i = name.indexOf(":");
52377        if (i === -1) {
52378          attributeObj[name] = value;
52379        } else {
52380          const nsAttrs = attributeObj[$nsAttributes] ??= Object.create(null);
52381          const [ns, attrName] = [name.slice(0, i), name.slice(i + 1)];
52382          const attrs = nsAttrs[ns] ||= Object.create(null);
52383          attrs[attrName] = value;
52384        }
52385      }
52386    }
52387    return [namespace, prefixes, attributeObj];
52388  }
52389  _getNameAndPrefix(name, nsAgnostic) {
52390    const i = name.indexOf(":");
52391    if (i === -1) {
52392      return [name, null];
52393    }
52394    return [name.substring(i + 1), nsAgnostic ? "" : name.substring(0, i)];
52395  }
52396  onBeginElement(tagName, attributes, isEmpty) {
52397    const [namespace, prefixes, attributesObj] = this._mkAttributes(attributes, tagName);
52398    const [name, nsPrefix] = this._getNameAndPrefix(tagName, this._builder.isNsAgnostic());
52399    const node = this._builder.build({
52400      nsPrefix,
52401      name,
52402      attributes: attributesObj,
52403      namespace,
52404      prefixes
52405    });
52406    node[$globalData] = this._globalData;
52407    if (isEmpty) {
52408      node[$finalize]();
52409      if (this._current[$onChild](node)) {
52410        node[$setId](this._ids);
52411      }
52412      node[$clean](this._builder);
52413      return;
52414    }
52415    this._stack.push(this._current);
52416    this._current = node;
52417  }
52418  onEndElement(name) {
52419    const node = this._current;
52420    if (node[$isCDATAXml]() && typeof node[$content] === "string") {
52421      const parser = new XFAParser();
52422      parser._globalData = this._globalData;
52423      const root = parser.parse(node[$content]);
52424      node[$content] = null;
52425      node[$onChild](root);
52426    }
52427    node[$finalize]();
52428    this._current = this._stack.pop();
52429    if (this._current[$onChild](node)) {
52430      node[$setId](this._ids);
52431    }
52432    node[$clean](this._builder);
52433  }
52434  onError(code) {
52435    this._errorCode = code;
52436  }
52437}
52438
52439;// ./src/core/xfa/factory.js
52440
52441
52442
52443
52444
52445
52446
52447
52448class XFAFactory {
52449  constructor(data) {
52450    try {
52451      this.root = new XFAParser().parse(XFAFactory._createDocument(data));
52452      const binder = new Binder(this.root);
52453      this.form = binder.bind();
52454      this.dataHandler = new DataHandler(this.root, binder.getData());
52455      this.form[$globalData].template = this.form;
52456    } catch (e) {
52457      warn(`XFA - an error occurred during parsing and binding: ${e}`);
52458    }
52459  }
52460  isValid() {
52461    return !!(this.root && this.form);
52462  }
52463  _createPagesHelper() {
52464    const iterator = this.form[$toPages]();
52465    return new Promise((resolve, reject) => {
52466      const nextIteration = () => {
52467        try {
52468          const value = iterator.next();
52469          if (value.done) {
52470            resolve(value.value);
52471          } else {
52472            setTimeout(nextIteration, 0);
52473          }
52474        } catch (e) {
52475          reject(e);
52476        }
52477      };
52478      setTimeout(nextIteration, 0);
52479    });
52480  }
52481  async _createPages() {
52482    try {
52483      this.pages = await this._createPagesHelper();
52484      this.dims = this.pages.children.map(c => {
52485        const {
52486          width,
52487          height
52488        } = c.attributes.style;
52489        return [0, 0, parseInt(width, 10), parseInt(height, 10)];
52490      });
52491    } catch (e) {
52492      warn(`XFA - an error occurred during layout: ${e}`);
52493    }
52494  }
52495  getBoundingBox(pageIndex) {
52496    return this.dims[pageIndex];
52497  }
52498  async getNumPages() {
52499    if (!this.pages) {
52500      await this._createPages();
52501    }
52502    return this.dims.length;
52503  }
52504  setImages(images) {
52505    this.form[$globalData].images = images;
52506  }
52507  setFonts(fonts) {
52508    this.form[$globalData].fontFinder = new FontFinder(fonts);
52509    const missingFonts = [];
52510    for (let typeface of this.form[$globalData].usedTypefaces) {
52511      typeface = stripQuotes(typeface);
52512      const font = this.form[$globalData].fontFinder.find(typeface);
52513      if (!font) {
52514        missingFonts.push(typeface);
52515      }
52516    }
52517    if (missingFonts.length > 0) {
52518      return missingFonts;
52519    }
52520    return null;
52521  }
52522  appendFonts(fonts, reallyMissingFonts) {
52523    this.form[$globalData].fontFinder.add(fonts, reallyMissingFonts);
52524  }
52525  async getPages() {
52526    if (!this.pages) {
52527      await this._createPages();
52528    }
52529    const pages = this.pages;
52530    this.pages = null;
52531    return pages;
52532  }
52533  serializeData(storage) {
52534    return this.dataHandler.serialize(storage);
52535  }
52536  static _createDocument(data) {
52537    if (!data["/xdp:xdp"]) {
52538      return data["xdp:xdp"];
52539    }
52540    return Object.values(data).join("");
52541  }
52542  static getRichTextAsHtml(rc) {
52543    if (!rc || typeof rc !== "string") {
52544      return null;
52545    }
52546    try {
vendor: 29,975 bytes, lines 52547-53473
52547      let root = new XFAParser(XhtmlNamespace, true).parse(rc);
52548      if (!["body", "xhtml"].includes(root[$nodeName])) {
52549        const newRoot = XhtmlNamespace.body({});
52550        newRoot[$appendChild](root);
52551        root = newRoot;
52552      }
52553      const result = root[$toHTML]();
52554      if (!result.success) {
52555        return null;
52556      }
52557      const {
52558        html
52559      } = result;
52560      const {
52561        attributes
52562      } = html;
52563      if (attributes) {
52564        if (attributes.class) {
52565          attributes.class = attributes.class.filter(attr => !attr.startsWith("xfa"));
52566        }
52567        attributes.dir = "auto";
52568      }
52569      return {
52570        html,
52571        str: root[$text]()
52572      };
52573    } catch (e) {
52574      warn(`XFA - an error occurred during parsing of rich text: ${e}`);
52575    }
52576    return null;
52577  }
52578}
52579
52580;// ./src/core/annotation.js
52581
52582
52583
52584
52585
52586
52587
52588
52589
52590
52591
52592
52593
52594
52595
52596
52597
52598
52599class AnnotationFactory {
52600  static createGlobals(pdfManager) {
52601    return Promise.all([pdfManager.ensureCatalog("acroForm"), pdfManager.ensureDoc("xfaDatasets"), pdfManager.ensureCatalog("structTreeRoot"), pdfManager.ensureCatalog("baseUrl"), pdfManager.ensureCatalog("attachments"), pdfManager.ensureCatalog("globalColorSpaceCache")]).then(([acroForm, xfaDatasets, structTreeRoot, baseUrl, attachments, globalColorSpaceCache]) => ({
52602      pdfManager,
52603      catalog: pdfManager.pdfDocument.catalog,
52604      acroForm: acroForm instanceof Dict ? acroForm : Dict.empty,
52605      xfaDatasets,
52606      structTreeRoot,
52607      baseUrl,
52608      attachments,
52609      globalColorSpaceCache
52610    }), reason => {
52611      warn(`createGlobals: "${reason}".`);
52612      return null;
52613    });
52614  }
52615  static async create(xref, ref, annotationGlobals, idFactory, collectFields, orphanFields, collectByType, pageRef) {
52616    const pageIndex = collectFields ? await this._getPageIndex(xref, ref, annotationGlobals.pdfManager) : null;
52617    return annotationGlobals.pdfManager.ensure(this, "_create", [xref, ref, annotationGlobals, idFactory, collectFields, orphanFields, collectByType, pageIndex, pageRef]);
52618  }
52619  static _create(xref, ref, annotationGlobals, idFactory, collectFields = false, orphanFields = null, collectByType = null, pageIndex = null, pageRef = null) {
52620    const dict = xref.fetchIfRef(ref);
52621    if (!(dict instanceof Dict)) {
52622      return undefined;
52623    }
52624    let subtype = dict.get("Subtype");
52625    subtype = subtype instanceof Name ? subtype.name : null;
52626    if (collectByType && !collectByType.has(AnnotationType[subtype?.toUpperCase()])) {
52627      return null;
52628    }
52629    const {
52630      acroForm,
52631      pdfManager
52632    } = annotationGlobals;
52633    const id = ref instanceof Ref ? ref.toString() : `annot_${idFactory.createObjId()}`;
52634    const parameters = {
52635      xref,
52636      ref,
52637      dict,
52638      subtype,
52639      id,
52640      annotationGlobals,
52641      collectFields,
52642      orphanFields,
52643      needAppearances: !collectFields && acroForm.get("NeedAppearances") === true,
52644      pageIndex,
52645      evaluatorOptions: pdfManager.evaluatorOptions,
52646      pageRef
52647    };
52648    switch (subtype) {
52649      case "Link":
52650        return new LinkAnnotation(parameters);
52651      case "Text":
52652        return new TextAnnotation(parameters);
52653      case "Widget":
52654        let fieldType = getInheritableProperty({
52655          dict,
52656          key: "FT"
52657        });
52658        fieldType = fieldType instanceof Name ? fieldType.name : null;
52659        switch (fieldType) {
52660          case "Tx":
52661            return new TextWidgetAnnotation(parameters);
52662          case "Btn":
52663            return new ButtonWidgetAnnotation(parameters);
52664          case "Ch":
52665            return new ChoiceWidgetAnnotation(parameters);
52666          case "Sig":
52667            return new SignatureWidgetAnnotation(parameters);
52668        }
52669        warn(`Unimplemented widget field type "${fieldType}", ` + "falling back to base field type.");
52670        return new WidgetAnnotation(parameters);
52671      case "Popup":
52672        return new PopupAnnotation(parameters);
52673      case "FreeText":
52674        return new FreeTextAnnotation(parameters);
52675      case "Line":
52676        return new LineAnnotation(parameters);
52677      case "Square":
52678        return new SquareAnnotation(parameters);
52679      case "Circle":
52680        return new CircleAnnotation(parameters);
52681      case "PolyLine":
52682        return new PolylineAnnotation(parameters);
52683      case "Polygon":
52684        return new PolygonAnnotation(parameters);
52685      case "Caret":
52686        return new CaretAnnotation(parameters);
52687      case "Ink":
52688        return new InkAnnotation(parameters);
52689      case "Highlight":
52690        return new HighlightAnnotation(parameters);
52691      case "Underline":
52692        return new UnderlineAnnotation(parameters);
52693      case "Squiggly":
52694        return new SquigglyAnnotation(parameters);
52695      case "StrikeOut":
52696        return new StrikeOutAnnotation(parameters);
52697      case "Stamp":
52698        return new StampAnnotation(parameters);
52699      case "FileAttachment":
52700        return new FileAttachmentAnnotation(parameters);
52701      case "RichMedia":
52702        return new RichMediaAnnotation(parameters);
52703      case "Screen":
52704        return new ScreenAnnotation(parameters);
52705      default:
52706        if (!collectFields) {
52707          if (!subtype) {
52708            warn("Annotation is missing the required /Subtype.");
52709          } else {
52710            warn(`Unimplemented annotation type "${subtype}", ` + "falling back to base annotation.");
52711          }
52712        }
52713        return new Annotation(parameters);
52714    }
52715  }
52716  static async _getPageIndex(xref, ref, pdfManager) {
52717    try {
52718      const annotDict = await xref.fetchIfRefAsync(ref);
52719      if (!(annotDict instanceof Dict)) {
52720        return -1;
52721      }
52722      const pageRef = annotDict.getRaw("P");
52723      if (pageRef instanceof Ref) {
52724        try {
52725          const pageIndex = await pdfManager.ensureCatalog("getPageIndex", [pageRef]);
52726          return pageIndex;
52727        } catch (ex) {
52728          info(`_getPageIndex -- not a valid page reference: "${ex}".`);
52729        }
52730      }
52731      if (annotDict.has("Kids")) {
52732        return -1;
52733      }
52734      const numPages = await pdfManager.ensureDoc("numPages");
52735      for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
52736        const page = await pdfManager.getPage(pageIndex);
52737        const annotations = await pdfManager.ensure(page, "annotations");
52738        for (const annotRef of annotations) {
52739          if (annotRef instanceof Ref && isRefsEqual(annotRef, ref)) {
52740            return pageIndex;
52741          }
52742        }
52743      }
52744    } catch (ex) {
52745      warn(`_getPageIndex: "${ex}".`);
52746    }
52747    return -1;
52748  }
52749  static generateImages(annotations, xref, isOffscreenCanvasSupported) {
52750    if (!isOffscreenCanvasSupported) {
52751      warn("generateImages: OffscreenCanvas is not supported, cannot save or print some annotations with images.");
52752      return null;
52753    }
52754    let imagePromises;
52755    for (const {
52756      bitmapId,
52757      bitmap
52758    } of annotations) {
52759      if (!bitmap) {
52760        continue;
52761      }
52762      imagePromises ||= new Map();
52763      imagePromises.set(bitmapId, createImage(bitmap, xref));
52764    }
52765    return imagePromises;
52766  }
52767  static async saveNewAnnotations(evaluator, xref, task, annotations, imagePromises, changes) {
52768    let baseFontRef;
52769    const promises = [];
52770    const {
52771      isOffscreenCanvasSupported
52772    } = evaluator.options;
52773    for (const annotation of annotations) {
52774      if (annotation.deleted) {
52775        continue;
52776      }
52777      switch (annotation.annotationType) {
52778        case AnnotationEditorType.FREETEXT:
52779          if (!baseFontRef) {
52780            const baseFont = new Dict(xref);
52781            baseFont.setIfName("BaseFont", "Helvetica");
52782            baseFont.setIfName("Type", "Font");
52783            baseFont.setIfName("Subtype", "Type1");
52784            baseFont.setIfName("Encoding", "WinAnsiEncoding");
52785            baseFontRef = xref.getNewTemporaryRef();
52786            changes.put(baseFontRef, {
52787              data: baseFont
52788            });
52789          }
52790          promises.push(FreeTextAnnotation.createNewAnnotation(xref, annotation, changes, {
52791            evaluator,
52792            task,
52793            baseFontRef
52794          }));
52795          break;
52796        case AnnotationEditorType.HIGHLIGHT:
52797          if (annotation.quadPoints) {
52798            promises.push(HighlightAnnotation.createNewAnnotation(xref, annotation, changes));
52799          } else {
52800            promises.push(InkAnnotation.createNewAnnotation(xref, annotation, changes));
52801          }
52802          break;
52803        case AnnotationEditorType.INK:
52804          promises.push(InkAnnotation.createNewAnnotation(xref, annotation, changes));
52805          break;
52806        case AnnotationEditorType.STAMP:
52807          const image = isOffscreenCanvasSupported ? await imagePromises?.get(annotation.bitmapId) : null;
52808          if (image?.imageStream) {
52809            const {
52810              imageStream,
52811              smaskStream
52812            } = image;
52813            if (smaskStream) {
52814              const smaskRef = xref.getNewTemporaryRef();
52815              changes.put(smaskRef, {
52816                data: smaskStream
52817              });
52818              imageStream.dict.set("SMask", smaskRef);
52819            }
52820            const imageRef = image.imageRef = xref.getNewTemporaryRef();
52821            changes.put(imageRef, {
52822              data: imageStream
52823            });
52824            image.imageStream = null;
52825            image.imageRenderStream = null;
52826            image.smaskStream = null;
52827            image.smaskRenderStream = null;
52828          }
52829          promises.push(StampAnnotation.createNewAnnotation(xref, annotation, changes, {
52830            image
52831          }));
52832          break;
52833        case AnnotationEditorType.SIGNATURE:
52834          promises.push(StampAnnotation.createNewAnnotation(xref, annotation, changes, {}));
52835          break;
52836      }
52837    }
52838    return {
52839      annotations: (await Promise.all(promises)).flat()
52840    };
52841  }
52842  static async printNewAnnotations(annotationGlobals, evaluator, task, annotations, imagePromises) {
52843    if (!annotations) {
52844      return null;
52845    }
52846    const {
52847      options,
52848      xref
52849    } = evaluator;
52850    const promises = [];
52851    for (const annotation of annotations) {
52852      if (annotation.deleted) {
52853        continue;
52854      }
52855      switch (annotation.annotationType) {
52856        case AnnotationEditorType.FREETEXT:
52857          promises.push(FreeTextAnnotation.createNewPrintAnnotation(annotationGlobals, xref, annotation, {
52858            evaluator,
52859            task,
52860            evaluatorOptions: options
52861          }));
52862          break;
52863        case AnnotationEditorType.HIGHLIGHT:
52864          if (annotation.quadPoints) {
52865            promises.push(HighlightAnnotation.createNewPrintAnnotation(annotationGlobals, xref, annotation, {
52866              evaluatorOptions: options
52867            }));
52868          } else {
52869            promises.push(InkAnnotation.createNewPrintAnnotation(annotationGlobals, xref, annotation, {
52870              evaluatorOptions: options
52871            }));
52872          }
52873          break;
52874        case AnnotationEditorType.INK:
52875          promises.push(InkAnnotation.createNewPrintAnnotation(annotationGlobals, xref, annotation, {
52876            evaluatorOptions: options
52877          }));
52878          break;
52879        case AnnotationEditorType.STAMP:
52880          const image = options.isOffscreenCanvasSupported ? await imagePromises?.get(annotation.bitmapId) : null;
52881          if (image?.imageStream) {
52882            const {
52883              imageStream,
52884              imageRenderStream,
52885              smaskStream,
52886              smaskRenderStream
52887            } = image;
52888            const imageRef = imageRenderStream || new JpegStream(imageStream, imageStream.length);
52889            if (smaskStream || smaskRenderStream) {
52890              imageRef.dict.set("SMask", smaskRenderStream || smaskStream);
52891            }
52892            image.imageRef = imageRef;
52893            image.imageStream = null;
52894            image.imageRenderStream = null;
52895            image.smaskStream = null;
52896            image.smaskRenderStream = null;
52897          }
52898          promises.push(StampAnnotation.createNewPrintAnnotation(annotationGlobals, xref, annotation, {
52899            image,
52900            evaluatorOptions: options
52901          }));
52902          break;
52903        case AnnotationEditorType.SIGNATURE:
52904          promises.push(StampAnnotation.createNewPrintAnnotation(annotationGlobals, xref, annotation, {
52905            evaluatorOptions: options
52906          }));
52907          break;
52908      }
52909    }
52910    return Promise.all(promises);
52911  }
52912}
52913function getRgbColor(color, defaultColor = new Uint8ClampedArray(3)) {
52914  if (!Array.isArray(color)) {
52915    return defaultColor;
52916  }
52917  const rgbColor = defaultColor || new Uint8ClampedArray(3);
52918  switch (color.length) {
52919    case 0:
52920      return null;
52921    case 1:
52922      ColorSpaceUtils.gray.getRgbItem(color, 0, rgbColor, 0);
52923      return rgbColor;
52924    case 3:
52925      ColorSpaceUtils.rgb.getRgbItem(color, 0, rgbColor, 0);
52926      return rgbColor;
52927    case 4:
52928      ColorSpaceUtils.cmyk.getRgbItem(color, 0, rgbColor, 0);
52929      return rgbColor;
52930    default:
52931      return defaultColor;
52932  }
52933}
52934function getPdfColorArray(color, defaultValue = null) {
52935  return color && Array.from(color, c => c / 255) || defaultValue;
52936}
52937function getQuadPoints(dict, rect) {
52938  const quadPoints = dict.getArray("QuadPoints");
52939  if (!isNumberArray(quadPoints, null) || quadPoints.length === 0 || quadPoints.length % 8 > 0) {
52940    return null;
52941  }
52942  const newQuadPoints = new Float32Array(quadPoints.length);
52943  for (let i = 0, ii = quadPoints.length; i < ii; i += 8) {
52944    const [x1, y1, x2, y2, x3, y3, x4, y4] = quadPoints.slice(i, i + 8);
52945    const minX = Math.min(x1, x2, x3, x4);
52946    const maxX = Math.max(x1, x2, x3, x4);
52947    const minY = Math.min(y1, y2, y3, y4);
52948    const maxY = Math.max(y1, y2, y3, y4);
52949    if (rect !== null && (minX < rect[0] || maxX > rect[2] || minY < rect[1] || maxY > rect[3])) {
52950      return null;
52951    }
52952    newQuadPoints.set([minX, maxY, maxX, maxY, minX, minY, maxX, minY], i);
52953  }
52954  return newQuadPoints;
52955}
52956function getTransformMatrix(rect, bbox, matrix) {
52957  const minMax = F32_BBOX_INIT.slice();
52958  Util.axialAlignedBoundingBox(bbox, matrix, minMax);
52959  const [minX, minY, maxX, maxY] = minMax;
52960  if (minX === maxX || minY === maxY) {
52961    return [1, 0, 0, 1, rect[0], rect[1]];
52962  }
52963  const xRatio = (rect[2] - rect[0]) / (maxX - minX);
52964  const yRatio = (rect[3] - rect[1]) / (maxY - minY);
52965  return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
52966}
52967class Annotation {
52968  appearance = null;
52969  _oc = undefined;
52970  constructor(params) {
52971    const {
52972      annotationGlobals,
52973      dict,
52974      orphanFields,
52975      ref,
52976      subtype,
52977      xref
52978    } = params;
52979    const parentRef = orphanFields?.get(ref);
52980    if (parentRef) {
52981      dict.set("Parent", parentRef);
52982    }
52983    this.setTitle(dict.get("T"));
52984    this.setContents(dict.get("Contents"));
52985    this.setModificationDate(dict.get("M"));
52986    this.setFlags(dict.get("F"));
52987    this.setRectangle(dict.getArray("Rect"));
52988    this.setColor(dict.getArray("C"));
52989    this.setBorderStyle(dict);
52990    this.setAppearance(dict);
52991    this.#setOptionalContent(xref, dict);
52992    const MK = dict.get("MK");
52993    this.setBorderAndBackgroundColors(MK);
52994    this.setRotation(MK, dict);
52995    this.ref = params.ref instanceof Ref ? params.ref : null;
52996    this._streams = [];
52997    if (this.appearance) {
52998      this._streams.push(this.appearance);
52999    }
53000    const isLocked = !!(this.flags & AnnotationFlag.LOCKED);
53001    const isContentLocked = !!(this.flags & AnnotationFlag.LOCKEDCONTENTS);
53002    this.data = {
53003      annotationType: AnnotationType[subtype?.toUpperCase()],
53004      annotationFlags: this.flags,
53005      borderStyle: this.borderStyle,
53006      color: this.color,
53007      backgroundColor: this.backgroundColor,
53008      borderColor: this.borderColor,
53009      rotation: this.rotation,
53010      contentsObj: this._contents,
53011      hasAppearance: !!this.appearance,
53012      id: params.id,
53013      modificationDate: this.modificationDate,
53014      oc: this._oc,
53015      rect: this.rectangle,
53016      subtype,
53017      hasOwnCanvas: false,
53018      noRotate: !!(this.flags & AnnotationFlag.NOROTATE),
53019      noHTML: isLocked && isContentLocked,
53020      isEditable: false,
53021      structParent: -1
53022    };
53023    if (annotationGlobals.structTreeRoot) {
53024      let structParent = dict.get("StructParent");
53025      this.data.structParent = structParent = Number.isInteger(structParent) && structParent >= 0 ? structParent : -1;
53026      annotationGlobals.structTreeRoot.addAnnotationIdToPage(params.pageRef, structParent);
53027    }
53028    if (params.collectFields) {
53029      const kids = dict.get("Kids");
53030      if (Array.isArray(kids)) {
53031        const kidIds = [];
53032        for (const kid of kids) {
53033          if (kid instanceof Ref) {
53034            kidIds.push(kid.toString());
53035          }
53036        }
53037        if (kidIds.length !== 0) {
53038          this.data.kidIds = kidIds;
53039        }
53040      }
53041      this.data.actions = collectActions(xref, dict, AnnotationActionEventType);
53042      this.data.fieldName = this._constructFieldName(dict);
53043      this.data.pageIndex = params.pageIndex;
53044    }
53045    const it = dict.get("IT");
53046    if (it instanceof Name) {
53047      this.data.it = it.name;
53048    }
53049    this._isOffscreenCanvasSupported = params.evaluatorOptions.isOffscreenCanvasSupported;
53050    this._fallbackFontDict = null;
53051    this._needAppearances = false;
53052  }
53053  _getOperatorListNoAppearance() {
53054    return {
53055      opList: new OperatorList(),
53056      separateForm: false,
53057      separateCanvas: false
53058    };
53059  }
53060  _hasFlag(flags, flag) {
53061    return !!(flags & flag);
53062  }
53063  _buildFlags(noView, noPrint) {
53064    let {
53065      flags
53066    } = this;
53067    if (noView === undefined) {
53068      if (noPrint === undefined) {
53069        return undefined;
53070      }
53071      if (noPrint) {
53072        return flags & ~AnnotationFlag.PRINT;
53073      }
53074      return flags & ~AnnotationFlag.HIDDEN | AnnotationFlag.PRINT;
53075    }
53076    if (noView) {
53077      flags |= AnnotationFlag.PRINT;
53078      if (noPrint) {
53079        return flags & ~AnnotationFlag.NOVIEW | AnnotationFlag.HIDDEN;
53080      }
53081      return flags & ~AnnotationFlag.HIDDEN | AnnotationFlag.NOVIEW;
53082    }
53083    flags &= ~(AnnotationFlag.HIDDEN | AnnotationFlag.NOVIEW);
53084    if (noPrint) {
53085      return flags & ~AnnotationFlag.PRINT;
53086    }
53087    return flags | AnnotationFlag.PRINT;
53088  }
53089  _isViewable(flags) {
53090    return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
53091  }
53092  _isPrintable(flags) {
53093    return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE);
53094  }
53095  mustBeViewed(annotationStorage, _renderForms) {
53096    const noView = annotationStorage?.get(this.data.id)?.noView;
53097    if (noView !== undefined) {
53098      return !noView;
53099    }
53100    return this.viewable && !this._hasFlag(this.flags, AnnotationFlag.HIDDEN);
53101  }
53102  mustBePrinted(annotationStorage) {
53103    const noPrint = annotationStorage?.get(this.data.id)?.noPrint;
53104    if (noPrint !== undefined) {
53105      return !noPrint;
53106    }
53107    return this.printable;
53108  }
53109  mustBeViewedWhenEditing(isEditing, modifiedIds = null) {
53110    return isEditing ? !this.data.isEditable : !modifiedIds?.has(this.data.id);
53111  }
53112  get viewable() {
53113    if (this.data.quadPoints === null) {
53114      return false;
53115    }
53116    if (this.flags === 0) {
53117      return true;
53118    }
53119    return this._isViewable(this.flags);
53120  }
53121  get printable() {
53122    if (this.data.quadPoints === null) {
53123      return false;
53124    }
53125    if (this.flags === 0) {
53126      return false;
53127    }
53128    return this._isPrintable(this.flags);
53129  }
53130  _parseStringHelper(data) {
53131    const str = typeof data === "string" ? stringToPDFString(data) : "";
53132    const dir = str && bidi(str).dir === "rtl" ? "rtl" : "ltr";
53133    return {
53134      str,
53135      dir
53136    };
53137  }
53138  setDefaultAppearance(params) {
53139    const {
53140      dict,
53141      annotationGlobals
53142    } = params;
53143    const defaultAppearance = getInheritableProperty({
53144      dict,
53145      key: "DA"
53146    }) || annotationGlobals.acroForm.get("DA");
53147    this._defaultAppearance = typeof defaultAppearance === "string" ? defaultAppearance : "";
53148    this.data.defaultAppearanceData = parseDefaultAppearance(this._defaultAppearance);
53149  }
53150  setTitle(title) {
53151    this._title = this._parseStringHelper(title);
53152  }
53153  setContents(contents) {
53154    this._contents = this._parseStringHelper(contents);
53155  }
53156  setModificationDate(modificationDate) {
53157    this.modificationDate = typeof modificationDate === "string" ? modificationDate : null;
53158  }
53159  setFlags(flags) {
53160    this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
53161    if (this.flags & AnnotationFlag.INVISIBLE && this.constructor.name !== "Annotation") {
53162      this.flags ^= AnnotationFlag.INVISIBLE;
53163    }
53164  }
53165  hasFlag(flag) {
53166    return this._hasFlag(this.flags, flag);
53167  }
53168  setRectangle(rectangle) {
53169    this.rectangle = lookupNormalRect(rectangle, [0, 0, 0, 0]);
53170  }
53171  setColor(color) {
53172    this.color = getRgbColor(color);
53173  }
53174  setLineEndings(lineEndings) {
53175    this.lineEndings = ["None", "None"];
53176    if (Array.isArray(lineEndings) && lineEndings.length === 2) {
53177      for (let i = 0; i < 2; i++) {
53178        const obj = lineEndings[i];
53179        if (obj instanceof Name) {
53180          switch (obj.name) {
53181            case "None":
53182              continue;
53183            case "Square":
53184            case "Circle":
53185            case "Diamond":
53186            case "OpenArrow":
53187            case "ClosedArrow":
53188            case "Butt":
53189            case "ROpenArrow":
53190            case "RClosedArrow":
53191            case "Slash":
53192              this.lineEndings[i] = obj.name;
53193              continue;
53194          }
53195        }
53196        warn(`Ignoring invalid lineEnding: ${obj}`);
53197      }
53198    }
53199  }
53200  setRotation(mk, dict) {
53201    this.rotation = 0;
53202    let angle = mk instanceof Dict ? mk.get("R") || 0 : dict.get("Rotate") || 0;
53203    if (Number.isInteger(angle) && angle !== 0) {
53204      angle %= 360;
53205      if (angle < 0) {
53206        angle += 360;
53207      }
53208      if (angle % 90 === 0) {
53209        this.rotation = angle;
53210      }
53211    }
53212  }
53213  setBorderAndBackgroundColors(mk) {
53214    if (mk instanceof Dict) {
53215      this.borderColor = getRgbColor(mk.getArray("BC"), null);
53216      this.backgroundColor = getRgbColor(mk.getArray("BG"), null);
53217    } else {
53218      this.borderColor = this.backgroundColor = null;
53219    }
53220  }
53221  setBorderStyle(borderStyle) {
53222    this.borderStyle = new AnnotationBorderStyle();
53223    if (!(borderStyle instanceof Dict)) {
53224      return;
53225    }
53226    if (borderStyle.has("BS")) {
53227      const dict = borderStyle.get("BS");
53228      if (dict instanceof Dict) {
53229        const dictType = dict.get("Type");
53230        if (!dictType || isName(dictType, "Border")) {
53231          this.borderStyle.setWidth(dict.get("W"), this.rectangle);
53232          this.borderStyle.setStyle(dict.get("S"));
53233          this.borderStyle.setDashArray(dict.getArray("D"));
53234        }
53235      }
53236    } else if (borderStyle.has("Border")) {
53237      const array = borderStyle.getArray("Border");
53238      if (Array.isArray(array)) {
53239        if (array.length >= 3) {
53240          this.borderStyle.setHorizontalCornerRadius(array[0]);
53241          this.borderStyle.setVerticalCornerRadius(array[1]);
53242          this.borderStyle.setWidth(array[2], this.rectangle);
53243          if (array.length === 4) {
53244            this.borderStyle.setDashArray(array[3], true);
53245          }
53246        } else if (array.length === 0) {
53247          this.borderStyle.setWidth(0);
53248        }
53249      }
53250    } else {
53251      this.borderStyle.setWidth(0);
53252    }
53253  }
53254  setAppearance(dict) {
53255    const appearanceStates = dict.get("AP");
53256    if (!(appearanceStates instanceof Dict)) {
53257      return;
53258    }
53259    const normalAppearanceState = appearanceStates.get("N");
53260    if (normalAppearanceState instanceof BaseStream) {
53261      this.appearance = normalAppearanceState;
53262      return;
53263    }
53264    if (!(normalAppearanceState instanceof Dict)) {
53265      return;
53266    }
53267    const as = dict.get("AS");
53268    if (!(as instanceof Name)) {
53269      return;
53270    }
53271    const appearance = normalAppearanceState.get(as.name);
53272    if (appearance instanceof BaseStream) {
53273      this.appearance = appearance;
53274    }
53275  }
53276  #setOptionalContent(xref, dict) {
53277    if (dict.has("OC")) {
53278      try {
53279        this._oc = parseMarkedContentProps(xref, dict.get("OC"), null);
53280      } catch (ex) {
53281        if (ex instanceof MissingDataException) {
53282          throw ex;
53283        }
53284        warn(`#setOptionalContent: ${ex}`);
53285      }
53286    }
53287  }
53288  async loadResources(keys, appearance) {
53289    const resources = await appearance.dict.getAsync("Resources");
53290    if (resources) {
53291      await ObjectLoader.load(resources, keys, resources.xref);
53292    }
53293    return resources;
53294  }
53295  get _ownCanvasRequiresForms() {
53296    return false;
53297  }
53298  async getOperatorList(evaluator, task, intent, annotationStorage) {
53299    const {
53300      hasOwnCanvas,
53301      id,
53302      rect
53303    } = this.data;
53304    let appearance = this.appearance;
53305    const isUsingOwnCanvas = !!(hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY && (!this._ownCanvasRequiresForms || intent & RenderingIntentFlag.ANNOTATIONS_FORMS));
53306    if (isUsingOwnCanvas && (this.width === 0 || this.height === 0)) {
53307      this.data.hasOwnCanvas = false;
53308      return this._getOperatorListNoAppearance();
53309    }
53310    if (!appearance) {
53311      if (!isUsingOwnCanvas) {
53312        return this._getOperatorListNoAppearance();
53313      }
53314      appearance = new StringStream("", new Dict());
53315    }
53316    const appearanceDict = appearance.dict;
53317    const resources = await this.loadResources(RESOURCES_KEYS_OPERATOR_LIST, appearance);
53318    const bbox = lookupRect(appearanceDict.getArray("BBox"), [0, 0, this.width, this.height]);
53319    const matrix = lookupMatrix(appearanceDict.getArray("Matrix"), IDENTITY_MATRIX);
53320    const transform = getTransformMatrix(rect, bbox, matrix);
53321    const opList = new OperatorList();
53322    const optionalContent = this._oc;
53323    if (optionalContent !== undefined) {
53324      opList.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]);
53325    }
53326    opList.addOp(OPS.beginAnnotation, [id, rect, transform, matrix, isUsingOwnCanvas]);
53327    await evaluator.getOperatorList({
53328      stream: appearance,
53329      task,
53330      resources,
53331      operatorList: opList,
53332      fallbackFontDict: this._fallbackFontDict
53333    });
53334    opList.addOp(OPS.endAnnotation, []);
53335    if (optionalContent !== undefined) {
53336      opList.addOp(OPS.endMarkedContent, []);
53337    }
53338    this.reset();
53339    return {
53340      opList,
53341      separateForm: false,
53342      separateCanvas: isUsingOwnCanvas
53343    };
53344  }
53345  async save(evaluator, task, annotationStorage, changes) {
53346    return null;
53347  }
53348  get overlaysTextContent() {
53349    return false;
53350  }
53351  get hasTextContent() {
53352    return false;
53353  }
53354  async extractTextContent(evaluator, task, viewBox) {
53355    if (!this.appearance) {
53356      return;
53357    }
53358    const resources = await this.loadResources(RESOURCES_KEYS_TEXT_CONTENT, this.appearance);
53359    const text = [];
53360    const buffer = [];
53361    let firstPosition = null;
53362    const sink = {
53363      desiredSize: Math.Infinity,
53364      ready: true,
53365      enqueue(chunk, size) {
53366        for (const item of chunk.items) {
53367          if (item.str === undefined) {
53368            continue;
53369          }
53370          firstPosition ||= item.transform.slice(-2);
53371          buffer.push(item.str);
53372          if (item.hasEOL) {
53373            text.push(buffer.join("").trimEnd());
53374            buffer.length = 0;
53375          }
53376        }
53377      }
53378    };
53379    await evaluator.getTextContent({
53380      stream: this.appearance,
53381      task,
53382      resources,
53383      includeMarkedContent: true,
53384      keepWhiteSpace: true,
53385      sink,
53386      viewBox
53387    });
53388    this.reset();
53389    if (buffer.length) {
53390      text.push(buffer.join("").trimEnd());
53391    }
53392    if (text.length > 1 || text[0]) {
53393      const appearanceDict = this.appearance.dict;
53394      const bbox = lookupRect(appearanceDict.getArray("BBox"), null);
53395      const matrix = lookupMatrix(appearanceDict.getArray("Matrix"), null);
53396      this.data.textPosition = this._transformPoint(firstPosition, bbox, matrix);
53397      this.data.textContent = text;
53398    }
53399  }
53400  _transformPoint(coords, bbox, matrix) {
53401    const {
53402      rect
53403    } = this.data;
53404    bbox ||= [0, 0, 1, 1];
53405    matrix ||= [1, 0, 0, 1, 0, 0];
53406    const transform = getTransformMatrix(rect, bbox, matrix);
53407    transform[4] -= rect[0];
53408    transform[5] -= rect[1];
53409    const p = coords.slice();
53410    Util.applyTransform(p, transform);
53411    Util.applyTransform(p, matrix);
53412    return p;
53413  }
53414  getFieldObject() {
53415    if (this.data.kidIds) {
53416      return {
53417        id: this.data.id,
53418        actions: this.data.actions,
53419        name: this.data.fieldName,
53420        strokeColor: this.data.borderColor,
53421        fillColor: this.data.backgroundColor,
53422        type: "",
53423        kidIds: this.data.kidIds,
53424        page: this.data.pageIndex,
53425        rotation: this.rotation
53426      };
53427    }
53428    return null;
53429  }
53430  reset() {
53431    for (const stream of this._streams) {
53432      stream.reset();
53433    }
53434  }
53435  _constructFieldName(dict) {
53436    if (!dict.has("T") && !dict.has("Parent")) {
53437      warn("Unknown field name, falling back to empty field name.");
53438      return "";
53439    }
53440    if (!dict.has("Parent")) {
53441      return stringToPDFString(dict.get("T"));
53442    }
53443    const fieldName = [];
53444    if (dict.has("T")) {
53445      fieldName.unshift(stringToPDFString(dict.get("T")));
53446    }
53447    let loopDict = dict;
53448    const visited = new RefSet();
53449    if (dict.objId) {
53450      visited.put(dict.objId);
53451    }
53452    while (loopDict.has("Parent")) {
53453      loopDict = loopDict.get("Parent");
53454      if (!(loopDict instanceof Dict) || loopDict.objId && visited.has(loopDict.objId)) {
53455        break;
53456      }
53457      if (loopDict.objId) {
53458        visited.put(loopDict.objId);
53459      }
53460      if (loopDict.has("T")) {
53461        fieldName.unshift(stringToPDFString(loopDict.get("T")));
53462      }
53463    }
53464    return fieldName.join(".");
53465  }
53466  _getAttachmentId(fsDict, fsRef, annotationGlobals) {
53467    if (!(fsDict instanceof Dict)) {
53468      return undefined;
53469    }
53470    if (!(fsRef instanceof Ref)) {
53471      fsRef = FileSpec.pickPlatformItem(fsDict.get("EF"), true);
53472    }
53473    return fsRef instanceof Ref ? annotationGlobals.catalog.getAttachmentIdForAnnotation(fsRef
vendor: 22,939 bytes, lines 53473-54138
53473) : undefined;
53474  }
53475  get width() {
53476    return this.data.rect[2] - this.data.rect[0];
53477  }
53478  get height() {
53479    return this.data.rect[3] - this.data.rect[1];
53480  }
53481}
53482class AnnotationBorderStyle {
53483  width = 1;
53484  rawWidth = 1;
53485  style = AnnotationBorderStyleType.SOLID;
53486  dashArray = [3];
53487  horizontalCornerRadius = 0;
53488  verticalCornerRadius = 0;
53489  setWidth(width, rect = [0, 0, 0, 0]) {
53490    if (width instanceof Name) {
53491      this.width = 0;
53492      return;
53493    }
53494    if (typeof width === "number") {
53495      if (width > 0) {
53496        this.rawWidth = width;
53497        const maxWidth = (rect[2] - rect[0]) / 2;
53498        const maxHeight = (rect[3] - rect[1]) / 2;
53499        if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) {
53500          warn(`AnnotationBorderStyle.setWidth - ignoring width: ${width}`);
53501          width = 1;
53502        }
53503      }
53504      this.width = width;
53505    }
53506  }
53507  setStyle(style) {
53508    if (!(style instanceof Name)) {
53509      return;
53510    }
53511    switch (style.name) {
53512      case "S":
53513        this.style = AnnotationBorderStyleType.SOLID;
53514        break;
53515      case "D":
53516        this.style = AnnotationBorderStyleType.DASHED;
53517        break;
53518      case "B":
53519        this.style = AnnotationBorderStyleType.BEVELED;
53520        break;
53521      case "I":
53522        this.style = AnnotationBorderStyleType.INSET;
53523        break;
53524      case "U":
53525        this.style = AnnotationBorderStyleType.UNDERLINE;
53526        break;
53527      default:
53528        break;
53529    }
53530  }
53531  setDashArray(dashArray, forceStyle = false) {
53532    if (Array.isArray(dashArray)) {
53533      let isValid = true;
53534      let allZeros = true;
53535      for (const element of dashArray) {
53536        const validNumber = +element >= 0;
53537        if (!validNumber) {
53538          isValid = false;
53539          break;
53540        } else if (element > 0) {
53541          allZeros = false;
53542        }
53543      }
53544      if (dashArray.length === 0 || isValid && !allZeros) {
53545        this.dashArray = dashArray;
53546        if (forceStyle) {
53547          this.setStyle(Name.get("D"));
53548        }
53549      } else {
53550        this.width = 0;
53551      }
53552    } else if (dashArray) {
53553      this.width = 0;
53554    }
53555  }
53556  setHorizontalCornerRadius(radius) {
53557    if (Number.isInteger(radius)) {
53558      this.horizontalCornerRadius = radius;
53559    }
53560  }
53561  setVerticalCornerRadius(radius) {
53562    if (Number.isInteger(radius)) {
53563      this.verticalCornerRadius = radius;
53564    }
53565  }
53566}
53567class MarkupAnnotation extends Annotation {
53568  constructor(params) {
53569    super(params);
53570    const {
53571      dict
53572    } = params;
53573    if (dict.has("IRT")) {
53574      const rawIRT = dict.getRaw("IRT");
53575      this.data.inReplyTo = rawIRT instanceof Ref ? rawIRT.toString() : null;
53576      const rt = dict.get("RT");
53577      this.data.replyType = rt instanceof Name ? rt.name : AnnotationReplyType.REPLY;
53578    }
53579    let popupRef = null;
53580    if (this.data.replyType === AnnotationReplyType.GROUP) {
53581      const parent = dict.get("IRT");
53582      this.setTitle(parent.get("T"));
53583      this.data.titleObj = this._title;
53584      this.setContents(parent.get("Contents"));
53585      this.data.contentsObj = this._contents;
53586      if (!parent.has("CreationDate")) {
53587        this.data.creationDate = null;
53588      } else {
53589        this.setCreationDate(parent.get("CreationDate"));
53590        this.data.creationDate = this.creationDate;
53591      }
53592      if (!parent.has("M")) {
53593        this.data.modificationDate = null;
53594      } else {
53595        this.setModificationDate(parent.get("M"));
53596        this.data.modificationDate = this.modificationDate;
53597      }
53598      popupRef = parent.getRaw("Popup");
53599      if (!parent.has("C")) {
53600        this.data.color = null;
53601      } else {
53602        this.setColor(parent.getArray("C"));
53603        this.data.color = this.color;
53604      }
53605    } else {
53606      this.data.titleObj = this._title;
53607      this.setCreationDate(dict.get("CreationDate"));
53608      this.data.creationDate = this.creationDate;
53609      popupRef = dict.getRaw("Popup");
53610      if (!dict.has("C")) {
53611        this.data.color = null;
53612      }
53613    }
53614    this.data.popupRef = popupRef instanceof Ref ? popupRef.toString() : null;
53615    if (dict.has("RC")) {
53616      this.data.richText = XFAFactory.getRichTextAsHtml(dict.get("RC"));
53617    }
53618  }
53619  setCreationDate(creationDate) {
53620    this.creationDate = typeof creationDate === "string" ? creationDate : null;
53621  }
53622  _setDefaultAppearance({
53623    xref,
53624    extra,
53625    strokeColor,
53626    fillColor,
53627    blendMode,
53628    strokeAlpha,
53629    fillAlpha,
53630    pointsCallback
53631  }) {
53632    const bbox = this.data.rect = BBOX_INIT.slice();
53633    const buffer = ["q"];
53634    if (extra) {
53635      buffer.push(extra);
53636    }
53637    if (strokeColor) {
53638      buffer.push(`${strokeColor[0]} ${strokeColor[1]} ${strokeColor[2]} RG`);
53639    }
53640    if (fillColor) {
53641      buffer.push(`${fillColor[0]} ${fillColor[1]} ${fillColor[2]} rg`);
53642    }
53643    const pointsArray = this.data.quadPoints || Float32Array.from([this.rectangle[0], this.rectangle[3], this.rectangle[2], this.rectangle[3], this.rectangle[0], this.rectangle[1], this.rectangle[2], this.rectangle[1]]);
53644    for (let i = 0, ii = pointsArray.length; i < ii; i += 8) {
53645      const points = pointsCallback(buffer, pointsArray.subarray(i, i + 8));
53646      Util.rectBoundingBox(...points, bbox);
53647    }
53648    buffer.push("Q");
53649    const formDict = new Dict(xref);
53650    const appearanceStreamDict = new Dict(xref);
53651    appearanceStreamDict.setIfName("Subtype", "Form");
53652    const appearanceStream = new StringStream(buffer.join(" "), appearanceStreamDict);
53653    formDict.set("Fm0", appearanceStream);
53654    const gsDict = new Dict(xref);
53655    if (blendMode) {
53656      gsDict.setIfName("BM", blendMode);
53657    }
53658    gsDict.setIfNumber("CA", strokeAlpha);
53659    gsDict.setIfNumber("ca", fillAlpha);
53660    const stateDict = new Dict(xref);
53661    stateDict.set("GS0", gsDict);
53662    const resources = new Dict(xref);
53663    resources.set("ExtGState", stateDict);
53664    resources.set("XObject", formDict);
53665    const appearanceDict = new Dict(xref);
53666    appearanceDict.set("Resources", resources);
53667    appearanceDict.set("BBox", bbox);
53668    this.appearance = new StringStream("/GS0 gs /Fm0 Do", appearanceDict);
53669    this._streams.push(this.appearance, appearanceStream);
53670  }
53671  static async createNewAnnotation(xref, annotation, changes, params) {
53672    const annotationRef = annotation.ref ||= xref.getNewTemporaryRef();
53673    const ap = await this.createNewAppearanceStream(annotation, xref, params);
53674    let annotationDict;
53675    if (ap) {
53676      const apRef = xref.getNewTemporaryRef();
53677      annotationDict = this.createNewDict(annotation, xref, {
53678        apRef
53679      });
53680      changes.put(apRef, {
53681        data: ap
53682      });
53683    } else {
53684      annotationDict = this.createNewDict(annotation, xref, {});
53685    }
53686    if (Number.isInteger(annotation.parentTreeId)) {
53687      annotationDict.set("StructParent", annotation.parentTreeId);
53688    }
53689    changes.put(annotationRef, {
53690      data: annotationDict
53691    });
53692    const retRef = {
53693      ref: annotationRef
53694    };
53695    const {
53696      popup
53697    } = annotation;
53698    if (popup) {
53699      if (popup.deleted) {
53700        annotationDict.delete("Popup");
53701        annotationDict.delete("Contents");
53702        annotationDict.delete("RC");
53703        return retRef;
53704      }
53705      const popupRef = popup.ref ||= xref.getNewTemporaryRef();
53706      popup.parent = annotationRef;
53707      const popupDict = PopupAnnotation.createNewDict(popup, xref);
53708      changes.put(popupRef, {
53709        data: popupDict
53710      });
53711      annotationDict.setIfDefined("Contents", stringToAsciiOrUTF16BE(popup.contents));
53712      annotationDict.set("Popup", popupRef);
53713      return [retRef, {
53714        ref: popupRef
53715      }];
53716    }
53717    return retRef;
53718  }
53719  static async createNewPrintAnnotation(annotationGlobals, xref, annotation, params) {
53720    const ap = await this.createNewAppearanceStream(annotation, xref, params);
53721    const annotationDict = this.createNewDict(annotation, xref, ap ? {
53722      ap
53723    } : {});
53724    const newAnnotation = new this.prototype.constructor({
53725      dict: annotationDict,
53726      xref,
53727      annotationGlobals,
53728      evaluatorOptions: params.evaluatorOptions
53729    });
53730    if (annotation.ref) {
53731      newAnnotation.ref = newAnnotation.refToReplace = annotation.ref;
53732    }
53733    return newAnnotation;
53734  }
53735}
53736class WidgetAnnotation extends Annotation {
53737  constructor(params) {
53738    super(params);
53739    const {
53740      dict,
53741      xref,
53742      annotationGlobals
53743    } = params;
53744    const data = this.data;
53745    this._needAppearances = params.needAppearances;
53746    if (data.fieldName === undefined) {
53747      data.fieldName = this._constructFieldName(dict);
53748    }
53749    if (data.actions === undefined) {
53750      data.actions = collectActions(xref, dict, AnnotationActionEventType);
53751    }
53752    let fieldValue = getInheritableProperty({
53753      dict,
53754      key: "V",
53755      getArray: true
53756    });
53757    data.fieldValue = this._decodeFormValue(fieldValue);
53758    const defaultFieldValue = getInheritableProperty({
53759      dict,
53760      key: "DV",
53761      getArray: true
53762    });
53763    data.defaultFieldValue = this._decodeFormValue(defaultFieldValue);
53764    if (fieldValue === undefined && annotationGlobals.xfaDatasets) {
53765      const path = this._title.str;
53766      if (path) {
53767        this._hasValueFromXFA = true;
53768        data.fieldValue = fieldValue = annotationGlobals.xfaDatasets.getValue(path);
53769      }
53770    }
53771    if (fieldValue === undefined && data.defaultFieldValue !== null) {
53772      data.fieldValue = data.defaultFieldValue;
53773    }
53774    data.alternativeText = stringToPDFString(dict.get("TU") || "");
53775    this.setDefaultAppearance(params);
53776    data.hasAppearance ||= this._needAppearances && data.fieldValue !== undefined && data.fieldValue !== null;
53777    const fieldType = getInheritableProperty({
53778      dict,
53779      key: "FT"
53780    });
53781    data.fieldType = fieldType instanceof Name ? fieldType.name : null;
53782    const localResources = getInheritableProperty({
53783      dict,
53784      key: "DR"
53785    });
53786    const acroFormResources = annotationGlobals.acroForm.get("DR");
53787    const appearanceResources = this.appearance?.dict.get("Resources");
53788    this._fieldResources = {
53789      localResources,
53790      acroFormResources,
53791      appearanceResources,
53792      mergedResources: Dict.merge({
53793        xref,
53794        dictArray: [localResources, appearanceResources, acroFormResources],
53795        mergeSubDicts: true
53796      })
53797    };
53798    data.fieldFlags = getInheritableProperty({
53799      dict,
53800      key: "Ff"
53801    });
53802    if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
53803      data.fieldFlags = 0;
53804    }
53805    data.password = this.hasFieldFlag(AnnotationFieldFlag.PASSWORD);
53806    data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
53807    data.required = this.hasFieldFlag(AnnotationFieldFlag.REQUIRED);
53808    data.hidden = this._hasFlag(data.annotationFlags, AnnotationFlag.HIDDEN) || this._hasFlag(data.annotationFlags, AnnotationFlag.NOVIEW);
53809  }
53810  _decodeFormValue(formValue) {
53811    if (Array.isArray(formValue)) {
53812      const arr = formValue.map(item => this._decodeFormValue(item)).filter(item => item !== null);
53813      return arr.length > 0 ? arr : null;
53814    } else if (formValue instanceof Name) {
53815      return formValue.name;
53816    } else if (typeof formValue === "string") {
53817      return stringToPDFString(formValue);
53818    }
53819    return null;
53820  }
53821  hasFieldFlag(flag) {
53822    return !!(this.data.fieldFlags & flag);
53823  }
53824  _isViewable(flags) {
53825    return true;
53826  }
53827  mustBeViewed(annotationStorage, renderForms) {
53828    if (renderForms) {
53829      return this.viewable;
53830    }
53831    return super.mustBeViewed(annotationStorage, renderForms) && !this._hasFlag(this.flags, AnnotationFlag.NOVIEW);
53832  }
53833  getRotationMatrix(annotationStorage) {
53834    let rotation = annotationStorage?.get(this.data.id)?.rotation;
53835    if (rotation === undefined) {
53836      rotation = this.rotation;
53837    }
53838    return rotation === 0 ? IDENTITY_MATRIX : getRotationMatrix(rotation, this.width, this.height);
53839  }
53840  getBorderAndBackgroundAppearances(annotationStorage) {
53841    let rotation = annotationStorage?.get(this.data.id)?.rotation;
53842    if (rotation === undefined) {
53843      rotation = this.rotation;
53844    }
53845    if (!this.backgroundColor && !this.borderColor) {
53846      return "";
53847    }
53848    const rect = rotation === 0 || rotation === 180 ? `0 0 ${this.width} ${this.height} re` : `0 0 ${this.height} ${this.width} re`;
53849    let str = "";
53850    if (this.backgroundColor) {
53851      str = `${getPdfColor(this.backgroundColor, true)} ${rect} f `;
53852    }
53853    if (this.borderColor) {
53854      const borderWidth = this.borderStyle.width || 1;
53855      str += `${borderWidth} w ${getPdfColor(this.borderColor, false)} ${rect} S `;
53856    }
53857    return str;
53858  }
53859  async getOperatorList(evaluator, task, intent, annotationStorage) {
53860    if (intent & RenderingIntentFlag.ANNOTATIONS_FORMS && !(this instanceof SignatureWidgetAnnotation) && !this.data.noHTML && !this.data.hasOwnCanvas) {
53861      const list = this._getOperatorListNoAppearance();
53862      list.separateForm = true;
53863      return list;
53864    }
53865    if (!this._hasText) {
53866      return super.getOperatorList(evaluator, task, intent, annotationStorage);
53867    }
53868    const content = await this._getAppearance(evaluator, task, intent, annotationStorage);
53869    if (this.appearance && content === null) {
53870      return super.getOperatorList(evaluator, task, intent, annotationStorage);
53871    }
53872    const opList = new OperatorList();
53873    if (!this._defaultAppearance || content === null) {
53874      return {
53875        opList,
53876        separateForm: false,
53877        separateCanvas: false
53878      };
53879    }
53880    const isUsingOwnCanvas = !!(this.data.hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY);
53881    const matrix = [1, 0, 0, 1, 0, 0];
53882    const bbox = [0, 0, this.width, this.height];
53883    const transform = getTransformMatrix(this.data.rect, bbox, matrix);
53884    const optionalContent = this._oc;
53885    if (optionalContent !== undefined) {
53886      opList.addOp(OPS.beginMarkedContentProps, ["OC", optionalContent]);
53887    }
53888    opList.addOp(OPS.beginAnnotation, [this.data.id, this.data.rect, transform, this.getRotationMatrix(annotationStorage), isUsingOwnCanvas]);
53889    const stream = new StringStream(content);
53890    await evaluator.getOperatorList({
53891      stream,
53892      task,
53893      resources: this._fieldResources.mergedResources,
53894      operatorList: opList
53895    });
53896    opList.addOp(OPS.endAnnotation, []);
53897    if (optionalContent !== undefined) {
53898      opList.addOp(OPS.endMarkedContent, []);
53899    }
53900    return {
53901      opList,
53902      separateForm: false,
53903      separateCanvas: isUsingOwnCanvas
53904    };
53905  }
53906  _getMKDict(rotation) {
53907    const mk = new Dict(null);
53908    if (rotation) {
53909      mk.set("R", rotation);
53910    }
53911    mk.setIfArray("BC", getPdfColorArray(this.borderColor));
53912    mk.setIfArray("BG", getPdfColorArray(this.backgroundColor));
53913    return mk.size > 0 ? mk : null;
53914  }
53915  amendSavedDict(annotationStorage, dict) {}
53916  setValue(dict, value, xref, changes) {
53917    const {
53918      dict: parentDict,
53919      ref: parentRef
53920    } = getParentToUpdate(dict, this.ref, xref);
53921    if (!parentDict) {
53922      dict.set("V", value);
53923    } else if (!changes.has(parentRef)) {
53924      const newParentDict = parentDict.clone();
53925      newParentDict.set("V", value);
53926      changes.put(parentRef, {
53927        data: newParentDict
53928      });
53929      return newParentDict;
53930    }
53931    return null;
53932  }
53933  async save(evaluator, task, annotationStorage, changes) {
53934    const storageEntry = annotationStorage?.get(this.data.id);
53935    const flags = this._buildFlags(storageEntry?.noView, storageEntry?.noPrint);
53936    let value = storageEntry?.value,
53937      rotation = storageEntry?.rotation;
53938    if (value === this.data.fieldValue || value === undefined) {
53939      if (!this._hasValueFromXFA && rotation === undefined && flags === undefined) {
53940        return;
53941      }
53942      value ||= this.data.fieldValue;
53943    }
53944    if (rotation === undefined && !this._hasValueFromXFA && Array.isArray(value) && Array.isArray(this.data.fieldValue) && isArrayEqual(value, this.data.fieldValue) && flags === undefined) {
53945      return;
53946    }
53947    if (rotation === undefined) {
53948      rotation = this.rotation;
53949    }
53950    let appearance = null;
53951    if (!this._needAppearances) {
53952      appearance = await this._getAppearance(evaluator, task, RenderingIntentFlag.SAVE, annotationStorage);
53953      if (appearance === null && flags === undefined) {
53954        return;
53955      }
53956    } else {}
53957    let needAppearances = false;
53958    if (appearance?.needAppearances) {
53959      needAppearances = true;
53960      appearance = null;
53961    }
53962    const {
53963      xref
53964    } = evaluator;
53965    const originalDict = xref.fetchIfRef(this.ref);
53966    if (!(originalDict instanceof Dict)) {
53967      return;
53968    }
53969    const dict = new Dict(xref);
53970    for (const [key, rawVal] of originalDict.getRawEntries()) {
53971      if (key !== "AP") {
53972        dict.set(key, rawVal);
53973      }
53974    }
53975    if (flags !== undefined) {
53976      dict.set("F", flags);
53977      if (appearance === null && !needAppearances) {
53978        const ap = originalDict.getRaw("AP");
53979        if (ap) {
53980          dict.set("AP", ap);
53981        }
53982      }
53983    }
53984    const xfa = {
53985      path: this.data.fieldName,
53986      value
53987    };
53988    const newParentDict = this.setValue(dict, Array.isArray(value) ? value.map(stringToAsciiOrUTF16BE) : stringToAsciiOrUTF16BE(value), xref, changes);
53989    this.amendSavedDict(annotationStorage, newParentDict || dict);
53990    const maybeMK = this._getMKDict(rotation);
53991    if (maybeMK) {
53992      dict.set("MK", maybeMK);
53993    }
53994    changes.put(this.ref, {
53995      data: dict,
53996      xfa,
53997      needAppearances
53998    });
53999    if (appearance !== null) {
54000      const newRef = xref.getNewTemporaryRef();
54001      const AP = new Dict(xref);
54002      dict.set("AP", AP);
54003      AP.set("N", newRef);
54004      const resources = this._getSaveFieldResources(xref),
54005        appearanceDict = new Dict(xref);
54006      appearanceDict.setIfName("Subtype", "Form");
54007      appearanceDict.set("Resources", resources);
54008      const bbox = rotation % 180 === 0 ? [0, 0, this.width, this.height] : [0, 0, this.height, this.width];
54009      appearanceDict.set("BBox", bbox);
54010      const appearanceStream = new StringStream(appearance, appearanceDict);
54011      const rotationMatrix = this.getRotationMatrix(annotationStorage);
54012      if (rotationMatrix !== IDENTITY_MATRIX) {
54013        appearanceDict.set("Matrix", rotationMatrix);
54014      }
54015      changes.put(newRef, {
54016        data: appearanceStream,
54017        xfa: null,
54018        needAppearances: false
54019      });
54020    }
54021    dict.set("M", `D:${getModificationDate()}`);
54022  }
54023  async _getAppearance(evaluator, task, intent, annotationStorage) {
54024    if (this.data.password) {
54025      return null;
54026    }
54027    const storageEntry = annotationStorage?.get(this.data.id);
54028    let value, rotation;
54029    if (storageEntry) {
54030      value = storageEntry.formattedValue || storageEntry.value;
54031      rotation = storageEntry.rotation;
54032    }
54033    if (rotation === undefined && value === undefined && !this._needAppearances) {
54034      if (!this._hasValueFromXFA || this.appearance) {
54035        return null;
54036      }
54037    }
54038    const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
54039    if (value === undefined) {
54040      value = this.data.fieldValue;
54041      if (!value) {
54042        return `/Tx BMC q ${colors}Q EMC`;
54043      }
54044    }
54045    if (Array.isArray(value) && value.length === 1) {
54046      value = value[0];
54047    }
54048    assert(typeof value === "string", "Expected `value` to be a string.");
54049    value = value.trimEnd();
54050    if (this.data.combo) {
54051      const option = this.data.options.find(({
54052        exportValue
54053      }) => value === exportValue);
54054      value = option?.displayValue || value;
54055    }
54056    if (value === "") {
54057      return `/Tx BMC q ${colors}Q EMC`;
54058    }
54059    if (rotation === undefined) {
54060      rotation = this.rotation;
54061    }
54062    let lineCount = -1;
54063    let lines;
54064    if (this.data.multiLine) {
54065      lines = value.split(/\r\n?|\n/).map(line => line.normalize("NFC"));
54066      lineCount = lines.length;
54067    } else {
54068      lines = [value.replace(/\r\n?|\n/, "").normalize("NFC")];
54069    }
54070    const defaultPadding = 1;
54071    const defaultHPadding = 2;
54072    let {
54073      width: totalWidth,
54074      height: totalHeight
54075    } = this;
54076    if (rotation === 90 || rotation === 270) {
54077      [totalWidth, totalHeight] = [totalHeight, totalWidth];
54078    }
54079    if (!this._defaultAppearance) {
54080      this.data.defaultAppearanceData = parseDefaultAppearance(this._defaultAppearance = "/Helvetica 0 Tf 0 g");
54081    }
54082    let font = await WidgetAnnotation._getFontData(evaluator, task, this.data.defaultAppearanceData, this._fieldResources.mergedResources);
54083    let defaultAppearance, fontSize, lineHeight;
54084    const encodedLines = [];
54085    let encodingError = false;
54086    for (const line of lines) {
54087      const encodedString = font.encodeString(line);
54088      if (encodedString.length > 1) {
54089        encodingError = true;
54090      }
54091      encodedLines.push(encodedString.join(""));
54092    }
54093    if (encodingError && intent & RenderingIntentFlag.SAVE) {
54094      return {
54095        needAppearances: true
54096      };
54097    }
54098    if (encodingError && this._isOffscreenCanvasSupported) {
54099      const fontFamily = this.data.comb ? "monospace" : "sans-serif";
54100      const fakeUnicodeFont = new FakeUnicodeFont(evaluator.xref, fontFamily);
54101      const resources = fakeUnicodeFont.createFontResources(lines.join(""));
54102      const newFont = resources.getRaw("Font");
54103      if (this._fieldResources.mergedResources.has("Font")) {
54104        const oldFont = this._fieldResources.mergedResources.get("Font");
54105        for (const [key, rawVal] of newFont.getRawEntries()) {
54106          oldFont.set(key, rawVal);
54107        }
54108      } else {
54109        this._fieldResources.mergedResources.set("Font", newFont);
54110      }
54111      const fontName = fakeUnicodeFont.fontName.name;
54112      font = await WidgetAnnotation._getFontData(evaluator, task, {
54113        fontName,
54114        fontSize: 0
54115      }, resources);
54116      for (let i = 0, ii = encodedLines.length; i < ii; i++) {
54117        encodedLines[i] = stringToUTF16String(lines[i]);
54118      }
54119      const savedDefaultAppearance = Object.assign(Object.create(null), this.data.defaultAppearanceData);
54120      this.data.defaultAppearanceData.fontSize = 0;
54121      this.data.defaultAppearanceData.fontName = fontName;
54122      [defaultAppearance, fontSize, lineHeight] = this._computeFontSize(totalHeight - 2 * defaultPadding, totalWidth - 2 * defaultHPadding, value, font, lineCount);
54123      this.data.defaultAppearanceData = savedDefaultAppearance;
54124    } else {
54125      if (!this._isOffscreenCanvasSupported) {
54126        warn("_getAppearance: OffscreenCanvas is not supported, annotation may not render correctly.");
54127      }
54128      [defaultAppearance, fontSize, lineHeight] = this._computeFontSize(totalHeight - 2 * defaultPadding, totalWidth - 2 * defaultHPadding, value, font, lineCount);
54129    }
54130    let descent = font.descent;
54131    if (isNaN(descent)) {
54132      descent = BASELINE_FACTOR * lineHeight;
54133    } else {
54134      descent = Math.max(BASELINE_FACTOR * lineHeight, Math.abs(descent) * fontSize);
54135    }
54136    const defaultVPadding = Math.min(Math.floor((totalHeight - fontSize) / 2), defaultPadding);
54137    const alignment = this.data.textAlignment;
54138    
vendor: 8,693 bytes, lines 54138-54377
54138if (this.data.multiLine) {
54139      return this._getMultilineAppearance(defaultAppearance, encodedLines, font, fontSize, totalWidth, totalHeight, alignment, defaultHPadding, defaultVPadding, descent, lineHeight, annotationStorage);
54140    }
54141    if (this.data.comb) {
54142      return this._getCombAppearance(defaultAppearance, font, encodedLines[0], fontSize, totalWidth, totalHeight, alignment, bidi(lines[0]).dir === "rtl", annotationStorage);
54143    }
54144    const bottomPadding = defaultVPadding + descent;
54145    if (alignment === 0 || alignment > 2) {
54146      return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 ${numberToString(defaultHPadding)} ${numberToString(bottomPadding)} Tm (${escapeString(encodedLines[0])}) Tj` + " ET Q EMC";
54147    }
54148    const prevInfo = {
54149      shift: 0
54150    };
54151    const renderedText = this._renderText(encodedLines[0], font, fontSize, totalWidth, alignment, prevInfo, defaultHPadding, bottomPadding);
54152    return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 0 0 Tm ${renderedText}` + " ET Q EMC";
54153  }
54154  static async _getFontData(evaluator, task, appearanceData, resources) {
54155    const operatorList = new OperatorList();
54156    const initialState = {
54157      font: null,
54158      clone() {
54159        return this;
54160      }
54161    };
54162    const {
54163      fontName,
54164      fontSize
54165    } = appearanceData;
54166    await evaluator.handleSetFont(resources, [fontName && Name.get(fontName), fontSize], null, operatorList, task, initialState, null);
54167    return initialState.font;
54168  }
54169  _getTextWidth(text, font) {
54170    return Math.sumPrecise(font.charsToGlyphs(text).map(g => g.width)) / 1000;
54171  }
54172  _computeFontSize(height, width, text, font, lineCount) {
54173    let {
54174      fontSize
54175    } = this.data.defaultAppearanceData;
54176    let lineHeight = (fontSize || 12) * LINE_FACTOR,
54177      numberOfLines = Math.round(height / lineHeight);
54178    if (!fontSize) {
54179      const roundWithTwoDigits = x => Math.floor(x * 100) / 100;
54180      if (lineCount === -1) {
54181        const textWidth = this._getTextWidth(text, font);
54182        fontSize = roundWithTwoDigits(Math.min(height / LINE_FACTOR, width / textWidth));
54183        numberOfLines = 1;
54184      } else {
54185        const lines = text.split(/\r\n?|\n/);
54186        const cachedLines = [];
54187        for (const line of lines) {
54188          const encoded = font.encodeString(line).join("");
54189          const glyphs = font.charsToGlyphs(encoded);
54190          const positions = font.getCharPositions(encoded);
54191          cachedLines.push({
54192            line: encoded,
54193            glyphs,
54194            positions
54195          });
54196        }
54197        const isTooBig = fsize => {
54198          let totalHeight = 0;
54199          for (const cache of cachedLines) {
54200            const chunks = this._splitLine(null, font, fsize, width, cache);
54201            totalHeight += chunks.length * fsize;
54202            if (totalHeight > height) {
54203              return true;
54204            }
54205          }
54206          return false;
54207        };
54208        numberOfLines = Math.max(numberOfLines, lineCount);
54209        while (true) {
54210          lineHeight = height / numberOfLines;
54211          fontSize = roundWithTwoDigits(lineHeight / LINE_FACTOR);
54212          if (isTooBig(fontSize)) {
54213            numberOfLines++;
54214            continue;
54215          }
54216          break;
54217        }
54218      }
54219      const {
54220        fontName,
54221        fontColor
54222      } = this.data.defaultAppearanceData;
54223      this._defaultAppearance = createDefaultAppearance({
54224        fontSize,
54225        fontName,
54226        fontColor
54227      });
54228    }
54229    return [this._defaultAppearance, fontSize, height / numberOfLines];
54230  }
54231  _renderText(text, font, fontSize, totalWidth, alignment, prevInfo, hPadding, vPadding) {
54232    let shift;
54233    if (alignment === 1) {
54234      const width = this._getTextWidth(text, font) * fontSize;
54235      shift = (totalWidth - width) / 2;
54236    } else if (alignment === 2) {
54237      const width = this._getTextWidth(text, font) * fontSize;
54238      shift = totalWidth - width - hPadding;
54239    } else {
54240      shift = hPadding;
54241    }
54242    const shiftStr = numberToString(shift - prevInfo.shift);
54243    prevInfo.shift = shift;
54244    vPadding = numberToString(vPadding);
54245    return `${shiftStr} ${vPadding} Td (${escapeString(text)}) Tj`;
54246  }
54247  _getSaveFieldResources(xref) {
54248    const {
54249      localResources,
54250      appearanceResources,
54251      acroFormResources
54252    } = this._fieldResources;
54253    const fontName = this.data.defaultAppearanceData?.fontName;
54254    if (!fontName) {
54255      return localResources || Dict.empty;
54256    }
54257    for (const resources of [localResources, appearanceResources]) {
54258      if (resources instanceof Dict) {
54259        const localFont = resources.get("Font");
54260        if (localFont instanceof Dict && localFont.has(fontName)) {
54261          return resources;
54262        }
54263      }
54264    }
54265    if (acroFormResources instanceof Dict) {
54266      const acroFormFont = acroFormResources.get("Font");
54267      if (acroFormFont instanceof Dict && acroFormFont.has(fontName)) {
54268        const subFontDict = new Dict(xref);
54269        subFontDict.set(fontName, acroFormFont.getRaw(fontName));
54270        const subResourcesDict = new Dict(xref);
54271        subResourcesDict.set("Font", subFontDict);
54272        return Dict.merge({
54273          xref,
54274          dictArray: [subResourcesDict, localResources],
54275          mergeSubDicts: true
54276        });
54277      }
54278    }
54279    return localResources || Dict.empty;
54280  }
54281  getFieldObject() {
54282    return null;
54283  }
54284}
54285class TextWidgetAnnotation extends WidgetAnnotation {
54286  constructor(params) {
54287    super(params);
54288    const {
54289      dict
54290    } = params;
54291    if (dict.has("PMD")) {
54292      this.flags |= AnnotationFlag.HIDDEN;
54293      this.data.hidden = true;
54294      warn("Barcodes are not supported");
54295    }
54296    this.data.hasOwnCanvas = this.data.readOnly && !this.data.noHTML;
54297    this._hasText = true;
54298    if (typeof this.data.fieldValue !== "string") {
54299      this.data.fieldValue = "";
54300    }
54301    let alignment = getInheritableProperty({
54302      dict,
54303      key: "Q"
54304    });
54305    if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
54306      alignment = null;
54307    }
54308    this.data.textAlignment = alignment;
54309    let maximumLength = getInheritableProperty({
54310      dict,
54311      key: "MaxLen"
54312    });
54313    if (!Number.isInteger(maximumLength) || maximumLength < 0) {
54314      maximumLength = 0;
54315    }
54316    this.data.maxLen = maximumLength;
54317    this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
54318    this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.data.multiLine && !this.data.password && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== 0;
54319    this.data.doNotScroll = this.hasFieldFlag(AnnotationFieldFlag.DONOTSCROLL);
54320    const {
54321      data: {
54322        actions
54323      }
54324    } = this;
54325    if (!actions) {
54326      return;
54327    }
54328    const AFDateTime = /^AF(Date|Time)_(?:Keystroke|Format)(?:Ex)?\(['"]?([^'"]+)['"]?\);$/;
54329    let canUseHTMLDateTime = false;
54330    if (actions.Format?.length === 1 && actions.Keystroke?.length === 1 && AFDateTime.test(actions.Format[0]) && AFDateTime.test(actions.Keystroke[0]) || actions.Format?.length === 0 && actions.Keystroke?.length === 1 && AFDateTime.test(actions.Keystroke[0]) || actions.Keystroke?.length === 0 && actions.Format?.length === 1 && AFDateTime.test(actions.Format[0])) {
54331      canUseHTMLDateTime = true;
54332    }
54333    const actionsToVisit = [];
54334    if (actions.Format) {
54335      actionsToVisit.push(...actions.Format);
54336    }
54337    if (actions.Keystroke) {
54338      actionsToVisit.push(...actions.Keystroke);
54339    }
54340    if (canUseHTMLDateTime) {
54341      delete actions.Keystroke;
54342      actions.Format = actionsToVisit;
54343    }
54344    for (const formatAction of actionsToVisit) {
54345      const m = formatAction.match(AFDateTime);
54346      if (!m) {
54347        continue;
54348      }
54349      const isDate = m[1] === "Date";
54350      let format = m[2];
54351      const num = parseInt(format, 10);
54352      if (!isNaN(num) && Math.floor(Math.log10(num)) + 1 === m[2].length) {
54353        format = (isDate ? DateFormats : TimeFormats)[num] ?? format;
54354      }
54355      this.data.datetimeFormat = format;
54356      if (!canUseHTMLDateTime) {
54357        break;
54358      }
54359      if (isDate) {
54360        if (/HH|MM|ss|h/.test(format)) {
54361          this.data.datetimeType = "datetime-local";
54362          this.data.timeStep = /ss/.test(format) ? 1 : 60;
54363        } else {
54364          this.data.datetimeType = "date";
54365        }
54366        break;
54367      }
54368      this.data.datetimeType = "time";
54369      this.data.timeStep = /ss/.test(format) ? 1 : 60;
54370      break;
54371    }
54372  }
54373  get hasTextContent() {
54374    return !!this.appearance && !this._needAppearances;
54375  }
54376  _getCombAppearance(defaultAppearance, font, text, fontSize, width, height, alignment, isRTL, annotationStorage) {
54377    const combWidth = width / this.data.maxLen;
vendor: 8,647 bytes, lines 54378-54594
54378    const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
54379    const cells = font.getCharPositions(text).map(([start, end]) => {
54380      const glyph = text.substring(start, end);
54381      return {
54382        glyph,
54383        width: this._getTextWidth(glyph, font) * fontSize
54384      };
54385    });
54386    if (isRTL) {
54387      cells.reverse();
54388    }
54389    const textWidth = combWidth * cells.length;
54390    let hShift = 0;
54391    if (alignment === 1) {
54392      hShift += Math.floor((width - textWidth) / (2 * combWidth)) * combWidth;
54393    } else if (alignment === 2) {
54394      hShift += width - textWidth;
54395    }
54396    const buf = [];
54397    let previousWidth = 0;
54398    for (let i = 0, ii = cells.length; i < ii; i++) {
54399      const {
54400        glyph,
54401        width: glyphWidth
54402      } = cells[i];
54403      const shift = i === 0 ? (combWidth - glyphWidth) / 2 : combWidth + (previousWidth - glyphWidth) / 2;
54404      buf.push(`${numberToString(shift)} 0 Td (${escapeString(glyph)}) Tj`);
54405      previousWidth = glyphWidth;
54406    }
54407    const renderedComb = buf.join(" ");
54408    const vShift = (height - (font.capHeight || font.ascent || 1) * fontSize) / 2;
54409    return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 ${numberToString(hShift)} ${numberToString(vShift)} Tm ${renderedComb}` + " ET Q EMC";
54410  }
54411  _getMultilineAppearance(defaultAppearance, lines, font, fontSize, width, height, alignment, hPadding, vPadding, descent, lineHeight, annotationStorage) {
54412    const buf = [];
54413    const totalWidth = width - 2 * hPadding;
54414    const prevInfo = {
54415      shift: 0
54416    };
54417    for (let i = 0, ii = lines.length; i < ii; i++) {
54418      const line = lines[i];
54419      const chunks = this._splitLine(line, font, fontSize, totalWidth);
54420      for (let j = 0, jj = chunks.length; j < jj; j++) {
54421        const chunk = chunks[j];
54422        const vShift = i === 0 && j === 0 ? -vPadding - (lineHeight - descent) : -lineHeight;
54423        buf.push(this._renderText(chunk, font, fontSize, width, alignment, prevInfo, hPadding, vShift));
54424      }
54425    }
54426    const colors = this.getBorderAndBackgroundAppearances(annotationStorage);
54427    const renderedText = buf.join("\n");
54428    return `/Tx BMC q ${colors}BT ` + defaultAppearance + ` 1 0 0 1 0 ${numberToString(height)} Tm ${renderedText}` + " ET Q EMC";
54429  }
54430  _splitLine(line, font, fontSize, width, cache = {}) {
54431    line = cache.line || line;
54432    const glyphs = cache.glyphs || font.charsToGlyphs(line);
54433    if (glyphs.length <= 1) {
54434      return [line];
54435    }
54436    const positions = cache.positions || font.getCharPositions(line);
54437    const scale = fontSize / 1000;
54438    const chunks = [];
54439    let lastSpacePosInStringStart = -1,
54440      lastSpacePosInStringEnd = -1,
54441      lastSpacePos = -1,
54442      startChunk = 0,
54443      currentWidth = 0;
54444    for (let i = 0, ii = glyphs.length; i < ii; i++) {
54445      const [start, end] = positions[i];
54446      const glyph = glyphs[i];
54447      const glyphWidth = glyph.width * scale;
54448      if (glyph.unicode === " ") {
54449        if (currentWidth + glyphWidth > width) {
54450          chunks.push(line.substring(startChunk, start));
54451          startChunk = start;
54452          currentWidth = glyphWidth;
54453          lastSpacePosInStringStart = -1;
54454          lastSpacePos = -1;
54455        } else {
54456          currentWidth += glyphWidth;
54457          lastSpacePosInStringStart = start;
54458          lastSpacePosInStringEnd = end;
54459          lastSpacePos = i;
54460        }
54461      } else if (currentWidth + glyphWidth > width) {
54462        if (lastSpacePosInStringStart !== -1) {
54463          chunks.push(line.substring(startChunk, lastSpacePosInStringEnd));
54464          startChunk = lastSpacePosInStringEnd;
54465          i = lastSpacePos + 1;
54466          lastSpacePosInStringStart = -1;
54467          currentWidth = 0;
54468        } else {
54469          chunks.push(line.substring(startChunk, start));
54470          startChunk = start;
54471          currentWidth = glyphWidth;
54472        }
54473      } else {
54474        currentWidth += glyphWidth;
54475      }
54476    }
54477    if (startChunk < line.length) {
54478      chunks.push(line.substring(startChunk));
54479    }
54480    return chunks;
54481  }
54482  async extractTextContent(evaluator, task, viewBox) {
54483    await super.extractTextContent(evaluator, task, viewBox);
54484    const text = this.data.textContent;
54485    if (!text) {
54486      return;
54487    }
54488    const allText = text.join("\n");
54489    if (allText === this.data.fieldValue) {
54490      return;
54491    }
54492    const regex = allText.replaceAll(/([.*+?^${}()|[\]\\])|(\s+)/g, (_m, p1) => p1 ? `\\${p1}` : "\\s+");
54493    if (new RegExp(`^\\s*${regex}\\s*$`).test(this.data.fieldValue)) {
54494      this.data.textContent = this.data.fieldValue.split("\n");
54495    }
54496  }
54497  getFieldObject() {
54498    return {
54499      id: this.data.id,
54500      value: this.data.fieldValue,
54501      defaultValue: this.data.defaultFieldValue || "",
54502      multiline: this.data.multiLine,
54503      password: this.data.password,
54504      charLimit: this.data.maxLen,
54505      comb: this.data.comb,
54506      editable: !this.data.readOnly,
54507      hidden: this.data.hidden,
54508      name: this.data.fieldName,
54509      rect: this.data.rect,
54510      actions: this.data.actions,
54511      page: this.data.pageIndex,
54512      strokeColor: this.data.borderColor,
54513      fillColor: this.data.backgroundColor,
54514      rotation: this.rotation,
54515      datetimeFormat: this.data.datetimeFormat,
54516      hasDatetimeHTML: !!this.data.datetimeType,
54517      type: "text"
54518    };
54519  }
54520}
54521class ButtonWidgetAnnotation extends WidgetAnnotation {
54522  constructor(params) {
54523    super(params);
54524    this.checkedAppearance = null;
54525    this.uncheckedAppearance = null;
54526    const isRadio = this.hasFieldFlag(AnnotationFieldFlag.RADIO),
54527      isPushButton = this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
54528    this.data.checkBox = !isRadio && !isPushButton;
54529    this.data.radioButton = isRadio && !isPushButton;
54530    this.data.pushButton = isPushButton;
54531    this.data.isTooltipOnly = false;
54532    this.data.hasOwnCanvas = true;
54533    this.data.noHTML = false;
54534    if (this.data.checkBox) {
54535      this._processCheckBox(params);
54536    } else if (this.data.radioButton) {
54537      this._processRadioButton(params);
54538    } else if (this.data.pushButton) {
54539      this._processPushButton(params);
54540    } else {
54541      warn("Invalid field flags for button widget annotation");
54542    }
54543  }
54544  get _ownCanvasRequiresForms() {
54545    return this.data.checkBox || this.data.radioButton;
54546  }
54547  #getOperatorListForAppearance(evaluator, task, intent, annotationStorage, rotation, appearance) {
54548    if (!appearance) {
54549      return this._getOperatorListNoAppearance();
54550    }
54551    const savedAppearance = this.appearance;
54552    const savedMatrix = lookupMatrix(appearance.dict.getArray("Matrix"), IDENTITY_MATRIX);
54553    if (rotation) {
54554      appearance.dict.set("Matrix", this.getRotationMatrix(annotationStorage));
54555    }
54556    this.appearance = appearance;
54557    const operatorList = super.getOperatorList(evaluator, task, intent, annotationStorage);
54558    this.appearance = savedAppearance;
54559    appearance.dict.set("Matrix", savedMatrix);
54560    return operatorList;
54561  }
54562  async getOperatorList(evaluator, task, intent, annotationStorage) {
54563    if (this.data.pushButton) {
54564      return super.getOperatorList(evaluator, task, intent, false, annotationStorage);
54565    }
54566    if (intent & RenderingIntentFlag.DISPLAY && intent & RenderingIntentFlag.ANNOTATIONS_FORMS && (this.data.checkBox || this.data.radioButton)) {
54567      const setCanvasName = (operatorList, name) => {
54568        const index = operatorList.fnArray.indexOf(OPS.beginAnnotation);
54569        if (index !== -1) {
54570          operatorList.argsArray[index].push(name);
54571        }
54572      };
54573      const checked = await this.#getOperatorListForAppearance(evaluator, task, intent, annotationStorage, null, this.checkedAppearance);
54574      setCanvasName(checked.opList, "checked");
54575      const unchecked = await this.#getOperatorListForAppearance(evaluator, task, intent, annotationStorage, null, this.uncheckedAppearance);
54576      setCanvasName(unchecked.opList, "unchecked");
54577      checked.opList.addOpList(unchecked.opList);
54578      checked.separateForm ||= unchecked.separateForm;
54579      checked.separateCanvas ||= unchecked.separateCanvas;
54580      return checked;
54581    }
54582    let value = null;
54583    let rotation = null;
54584    if (annotationStorage) {
54585      const storageEntry = annotationStorage.get(this.data.id);
54586      value = storageEntry ? storageEntry.value : null;
54587      rotation = storageEntry ? storageEntry.rotation : null;
54588    }
54589    if (value === null && this.appearance) {
54590      return super.getOperatorList(evaluator, task, intent, annotationStorage);
54591    }
54592    if (value === null || value === undefined) {
54593      value = this.data.checkBox ? this.data.fieldValue === this.data.exportValue : this.data.fieldValue === this.data.buttonValue;
54594    }
vendor: 18,848 bytes, lines 54594-55146
54594
54595    return this.#getOperatorListForAppearance(evaluator, task, intent, annotationStorage, rotation, value ? this.checkedAppearance : this.uncheckedAppearance);
54596  }
54597  async save(evaluator, task, annotationStorage, changes) {
54598    if (this.data.checkBox) {
54599      this._saveCheckbox(evaluator, task, annotationStorage, changes);
54600      return;
54601    }
54602    if (this.data.radioButton) {
54603      this._saveRadioButton(evaluator, task, annotationStorage, changes);
54604    }
54605  }
54606  async _saveCheckbox(evaluator, task, annotationStorage, changes) {
54607    if (!annotationStorage) {
54608      return;
54609    }
54610    const storageEntry = annotationStorage.get(this.data.id);
54611    const flags = this._buildFlags(storageEntry?.noView, storageEntry?.noPrint);
54612    let rotation = storageEntry?.rotation,
54613      value = storageEntry?.value;
54614    if (rotation === undefined && flags === undefined) {
54615      if (value === undefined) {
54616        return;
54617      }
54618      const defaultValue = this.data.fieldValue === this.data.exportValue;
54619      if (defaultValue === value) {
54620        return;
54621      }
54622    }
54623    let dict = evaluator.xref.fetchIfRef(this.ref);
54624    if (!(dict instanceof Dict)) {
54625      return;
54626    }
54627    dict = dict.clone();
54628    if (rotation === undefined) {
54629      rotation = this.rotation;
54630    }
54631    if (value === undefined) {
54632      value = this.data.fieldValue === this.data.exportValue;
54633    }
54634    const xfa = {
54635      path: this.data.fieldName,
54636      value: value ? this.data.exportValue : ""
54637    };
54638    const name = Name.get(value ? this._onStateName : "Off");
54639    this.setValue(dict, name, evaluator.xref, changes);
54640    dict.set("AS", name);
54641    dict.set("M", `D:${getModificationDate()}`);
54642    if (flags !== undefined) {
54643      dict.set("F", flags);
54644    }
54645    const maybeMK = this._getMKDict(rotation);
54646    if (maybeMK) {
54647      dict.set("MK", maybeMK);
54648    }
54649    changes.put(this.ref, {
54650      data: dict,
54651      xfa,
54652      needAppearances: false
54653    });
54654  }
54655  async _saveRadioButton(evaluator, task, annotationStorage, changes) {
54656    if (!annotationStorage) {
54657      return;
54658    }
54659    const storageEntry = annotationStorage.get(this.data.id);
54660    const flags = this._buildFlags(storageEntry?.noView, storageEntry?.noPrint);
54661    let rotation = storageEntry?.rotation,
54662      value = storageEntry?.value;
54663    if (rotation === undefined && flags === undefined) {
54664      if (value === undefined) {
54665        return;
54666      }
54667      const defaultValue = this.data.fieldValue === this.data.buttonValue;
54668      if (defaultValue === value) {
54669        return;
54670      }
54671    }
54672    let dict = evaluator.xref.fetchIfRef(this.ref);
54673    if (!(dict instanceof Dict)) {
54674      return;
54675    }
54676    dict = dict.clone();
54677    if (value === undefined) {
54678      value = this.data.fieldValue === this.data.buttonValue;
54679    }
54680    if (rotation === undefined) {
54681      rotation = this.rotation;
54682    }
54683    const xfa = {
54684      path: this.data.fieldName,
54685      value: value ? this.data.buttonValue : ""
54686    };
54687    const name = Name.get(value ? this._onStateName : "Off");
54688    if (value) {
54689      this.setValue(dict, name, evaluator.xref, changes);
54690    }
54691    dict.set("AS", name);
54692    dict.set("M", `D:${getModificationDate()}`);
54693    if (flags !== undefined) {
54694      dict.set("F", flags);
54695    }
54696    const maybeMK = this._getMKDict(rotation);
54697    if (maybeMK) {
54698      dict.set("MK", maybeMK);
54699    }
54700    changes.put(this.ref, {
54701      data: dict,
54702      xfa,
54703      needAppearances: false
54704    });
54705  }
54706  _getDefaultCheckedAppearance(params, type) {
54707    const {
54708      width,
54709      height
54710    } = this;
54711    const bbox = [0, 0, width, height];
54712    const FONT_RATIO = 0.8;
54713    const fontSize = Math.min(width, height) * FONT_RATIO;
54714    let metrics, char;
54715    if (type === "check") {
54716      metrics = {
54717        width: 0.755 * fontSize,
54718        height: 0.705 * fontSize
54719      };
54720      char = "\x33";
54721    } else if (type === "disc") {
54722      metrics = {
54723        width: 0.791 * fontSize,
54724        height: 0.705 * fontSize
54725      };
54726      char = "\x6C";
54727    } else {
54728      unreachable(`_getDefaultCheckedAppearance - unsupported type: ${type}`);
54729    }
54730    const xShift = numberToString((width - metrics.width) / 2);
54731    const yShift = numberToString((height - metrics.height) / 2);
54732    const appearance = `q BT /PdfJsZaDb ${fontSize} Tf 0 g ${xShift} ${yShift} Td (${char}) Tj ET Q`;
54733    const appearanceStreamDict = new Dict(params.xref);
54734    appearanceStreamDict.set("FormType", 1);
54735    appearanceStreamDict.setIfName("Subtype", "Form");
54736    appearanceStreamDict.setIfName("Type", "XObject");
54737    appearanceStreamDict.set("BBox", bbox);
54738    appearanceStreamDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
54739    appearanceStreamDict.set("Length", appearance.length);
54740    const resources = new Dict(params.xref);
54741    const font = new Dict(params.xref);
54742    font.set("PdfJsZaDb", this.fallbackFontDict);
54743    resources.set("Font", font);
54744    appearanceStreamDict.set("Resources", resources);
54745    this.checkedAppearance = new StringStream(appearance, appearanceStreamDict);
54746    this._streams.push(this.checkedAppearance);
54747  }
54748  _getOnStateName(dict) {
54749    const appearanceStates = dict.get("AP");
54750    if (!(appearanceStates instanceof Dict)) {
54751      return null;
54752    }
54753    const normalAppearance = appearanceStates.get("N");
54754    if (!(normalAppearance instanceof Dict)) {
54755      return null;
54756    }
54757    for (const key of normalAppearance.getKeys()) {
54758      if (key !== "Off") {
54759        return key;
54760      }
54761    }
54762    return null;
54763  }
54764  _getExportValueForOptIndex(index, opt, xref) {
54765    if (Number.isInteger(index) && index >= 0 && index < opt.length) {
54766      const value = this._decodeFormValue(xref.fetchIfRef(opt[index]));
54767      if (typeof value === "string") {
54768        return value;
54769      }
54770    }
54771    return null;
54772  }
54773  _getOptInfo(dict, onState, opt, xref) {
54774    if (!Array.isArray(opt)) {
54775      return null;
54776    }
54777    const stateToIndex = new Map();
54778    let currentIndex = null;
54779    const fieldParent = dict.get("Parent");
54780    const kids = fieldParent instanceof Dict ? fieldParent.get("Kids") : null;
54781    if (Array.isArray(kids)) {
54782      for (let i = 0, ii = Math.min(kids.length, opt.length); i < ii; i++) {
54783        const kid = kids[i];
54784        if (kid instanceof Ref && isRefsEqual(kid, this.ref)) {
54785          currentIndex = i;
54786        }
54787        const kidDict = xref.fetchIfRef(kid);
54788        if (!(kidDict instanceof Dict)) {
54789          continue;
54790        }
54791        if (kidDict === dict) {
54792          currentIndex = i;
54793        }
54794        const kidOnState = this._getOnStateName(kidDict);
54795        if (typeof kidOnState === "string" && !stateToIndex.has(kidOnState)) {
54796          stateToIndex.set(kidOnState, i);
54797        }
54798      }
54799    } else if (opt.length === 1 && typeof onState === "string") {
54800      currentIndex = 0;
54801      stateToIndex.set(onState, 0);
54802    }
54803    return {
54804      currentIndex,
54805      opt,
54806      stateToIndex
54807    };
54808  }
54809  _getExportValue(state, optInfo, xref) {
54810    if (!optInfo || typeof state !== "string" || state === "Off") {
54811      return state;
54812    }
54813    if (state === this._onStateName) {
54814      const exportValue = this._getExportValueForOptIndex(optInfo.currentIndex, optInfo.opt, xref);
54815      if (exportValue !== null) {
54816        return exportValue;
54817      }
54818    }
54819    if (optInfo.stateToIndex.has(state)) {
54820      const exportValue = this._getExportValueForOptIndex(optInfo.stateToIndex.get(state), optInfo.opt, xref);
54821      if (exportValue !== null) {
54822        return exportValue;
54823      }
54824    }
54825    const index = parseInt(state, 10);
54826    if (Number.isInteger(index) && String(index) === state) {
54827      return this._getExportValueForOptIndex(index, optInfo.opt, xref) || state;
54828    }
54829    return state;
54830  }
54831  _processCheckBox(params) {
54832    const customAppearance = params.dict.get("AP");
54833    let normalAppearance = customAppearance instanceof Dict ? customAppearance.get("N") : null;
54834    if (!(normalAppearance instanceof Dict)) {
54835      normalAppearance = null;
54836    }
54837    const asValue = this._decodeFormValue(params.dict.get("AS"));
54838    if (typeof asValue === "string") {
54839      this.data.fieldValue = asValue;
54840    }
54841    const yes = this.data.fieldValue !== null && this.data.fieldValue !== "Off" ? this.data.fieldValue : "Yes";
54842    const exportValues = normalAppearance ? [...normalAppearance.getKeys()] : [];
54843    if (exportValues.length === 0) {
54844      exportValues.push("Off", yes);
54845    } else if (exportValues.length === 1) {
54846      if (exportValues[0] === "Off") {
54847        exportValues.push(yes);
54848      } else {
54849        exportValues.unshift("Off");
54850      }
54851    } else if (exportValues.includes(yes)) {
54852      exportValues.length = 0;
54853      exportValues.push("Off", yes);
54854    } else {
54855      const otherYes = exportValues.find(v => v !== "Off");
54856      exportValues.length = 0;
54857      exportValues.push("Off", otherYes);
54858    }
54859    const onState = exportValues[1];
54860    this._onStateName = onState;
54861    const opt = getInheritableProperty({
54862      dict: params.dict,
54863      key: "Opt"
54864    });
54865    const optInfo = this._getOptInfo(params.dict, onState, opt, params.xref);
54866    this.data.exportValue = this._getExportValue(onState, optInfo, params.xref);
54867    if (!exportValues.includes(this.data.fieldValue) && this.data.fieldValue !== this.data.exportValue) {
54868      this.data.fieldValue = "Off";
54869    }
54870    this.data.fieldValue = this._getExportValue(this.data.fieldValue, optInfo, params.xref);
54871    this.data.defaultFieldValue = this._getExportValue(this.data.defaultFieldValue, optInfo, params.xref);
54872    const checkedAppearance = normalAppearance?.get(onState);
54873    this.checkedAppearance = checkedAppearance instanceof BaseStream ? checkedAppearance : null;
54874    const uncheckedAppearance = normalAppearance?.get("Off");
54875    this.uncheckedAppearance = uncheckedAppearance instanceof BaseStream ? uncheckedAppearance : null;
54876    if (this.checkedAppearance) {
54877      this._streams.push(this.checkedAppearance);
54878    } else {
54879      this._getDefaultCheckedAppearance(params, "check");
54880    }
54881    if (this.uncheckedAppearance) {
54882      this._streams.push(this.uncheckedAppearance);
54883    }
54884    this._fallbackFontDict = this.fallbackFontDict;
54885    if (this.data.defaultFieldValue === null) {
54886      this.data.defaultFieldValue = "Off";
54887    }
54888  }
54889  _processRadioButton(params) {
54890    this.data.buttonValue = null;
54891    const fieldParent = params.dict.get("Parent");
54892    if (fieldParent instanceof Dict) {
54893      this.parent = params.dict.getRaw("Parent");
54894      const fieldParentValue = fieldParent.get("V");
54895      if (fieldParentValue instanceof Name) {
54896        this.data.fieldValue = this._decodeFormValue(fieldParentValue);
54897      }
54898    }
54899    const appearanceStates = params.dict.get("AP");
54900    if (!(appearanceStates instanceof Dict)) {
54901      return;
54902    }
54903    const normalAppearance = appearanceStates.get("N");
54904    if (!(normalAppearance instanceof Dict)) {
54905      return;
54906    }
54907    let onState = null;
54908    for (const key of normalAppearance.getKeys()) {
54909      if (key !== "Off") {
54910        onState = key;
54911        break;
54912      }
54913    }
54914    this._onStateName = onState;
54915    const opt = getInheritableProperty({
54916      dict: params.dict,
54917      key: "Opt"
54918    });
54919    const optInfo = this._getOptInfo(params.dict, onState, opt, params.xref);
54920    this.data.buttonValue = this._getExportValue(onState, optInfo, params.xref);
54921    this.data.fieldValue = this._getExportValue(this.data.fieldValue, optInfo, params.xref);
54922    this.data.defaultFieldValue = this._getExportValue(this.data.defaultFieldValue, optInfo, params.xref);
54923    const checkedAppearance = normalAppearance.get(onState);
54924    this.checkedAppearance = checkedAppearance instanceof BaseStream ? checkedAppearance : null;
54925    const uncheckedAppearance = normalAppearance.get("Off");
54926    this.uncheckedAppearance = uncheckedAppearance instanceof BaseStream ? uncheckedAppearance : null;
54927    if (this.checkedAppearance) {
54928      this._streams.push(this.checkedAppearance);
54929    } else {
54930      this._getDefaultCheckedAppearance(params, "disc");
54931    }
54932    if (this.uncheckedAppearance) {
54933      this._streams.push(this.uncheckedAppearance);
54934    }
54935    this._fallbackFontDict = this.fallbackFontDict;
54936    if (this.data.defaultFieldValue === null) {
54937      this.data.defaultFieldValue = "Off";
54938    }
54939  }
54940  _processPushButton(params) {
54941    const {
54942      dict,
54943      annotationGlobals
54944    } = params;
54945    if (!dict.has("A") && !dict.has("AA") && !this.data.alternativeText) {
54946      warn("Push buttons without action dictionaries are not supported");
54947      return;
54948    }
54949    this.data.isTooltipOnly = !dict.has("A") && !dict.has("AA");
54950    Catalog.parseDestDictionary({
54951      destDict: dict,
54952      resultObj: this.data,
54953      docBaseUrl: annotationGlobals.baseUrl,
54954      docAttachments: annotationGlobals.attachments
54955    });
54956  }
54957  getFieldObject() {
54958    let type = "button";
54959    let exportValues;
54960    if (this.data.checkBox) {
54961      type = "checkbox";
54962      exportValues = this.data.exportValue;
54963    } else if (this.data.radioButton) {
54964      type = "radiobutton";
54965      exportValues = this.data.buttonValue;
54966    }
54967    return {
54968      id: this.data.id,
54969      value: this.data.fieldValue || "Off",
54970      defaultValue: this.data.defaultFieldValue,
54971      exportValues,
54972      editable: !this.data.readOnly,
54973      name: this.data.fieldName,
54974      rect: this.data.rect,
54975      hidden: this.data.hidden,
54976      actions: this.data.actions,
54977      page: this.data.pageIndex,
54978      strokeColor: this.data.borderColor,
54979      fillColor: this.data.backgroundColor,
54980      rotation: this.rotation,
54981      type
54982    };
54983  }
54984  get fallbackFontDict() {
54985    const dict = new Dict();
54986    dict.setIfName("BaseFont", "ZapfDingbats");
54987    dict.setIfName("Type", "FallbackType");
54988    dict.setIfName("Subtype", "FallbackType");
54989    dict.setIfName("Encoding", "ZapfDingbatsEncoding");
54990    return shadow(this, "fallbackFontDict", dict);
54991  }
54992}
54993class ChoiceWidgetAnnotation extends WidgetAnnotation {
54994  constructor(params) {
54995    super(params);
54996    const {
54997      dict,
54998      xref
54999    } = params;
55000    this.indices = dict.getArray("I");
55001    this.hasIndices = Array.isArray(this.indices) && this.indices.length > 0;
55002    this.data.options = [];
55003    const options = getInheritableProperty({
55004      dict,
55005      key: "Opt"
55006    });
55007    if (Array.isArray(options)) {
55008      for (let i = 0, ii = options.length; i < ii; i++) {
55009        const option = xref.fetchIfRef(options[i]);
55010        const isOptionArray = Array.isArray(option);
55011        this.data.options[i] = {
55012          exportValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[0]) : option),
55013          displayValue: this._decodeFormValue(isOptionArray ? xref.fetchIfRef(option[1]) : option)
55014        };
55015      }
55016    }
55017    if (!this.hasIndices) {
55018      if (typeof this.data.fieldValue === "string") {
55019        this.data.fieldValue = [this.data.fieldValue];
55020      } else {
55021        this.data.fieldValue ||= [];
55022      }
55023    } else {
55024      this.data.fieldValue = [];
55025      const ii = this.data.options.length;
55026      for (const i of this.indices) {
55027        if (Number.isInteger(i) && i >= 0 && i < ii) {
55028          this.data.fieldValue.push(this.data.options[i].exportValue);
55029        }
55030      }
55031    }
55032    if (this.data.options.length === 0 && this.data.fieldValue.length > 0) {
55033      this.data.options = this.data.fieldValue.map(value => ({
55034        exportValue: value,
55035        displayValue: value
55036      }));
55037    }
55038    this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
55039    this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
55040    this._hasText = true;
55041  }
55042  getFieldObject() {
55043    const type = this.data.combo ? "combobox" : "listbox";
55044    const value = this.data.fieldValue.length > 0 ? this.data.fieldValue[0] : null;
55045    return {
55046      id: this.data.id,
55047      value,
55048      defaultValue: this.data.defaultFieldValue,
55049      editable: !this.data.readOnly,
55050      name: this.data.fieldName,
55051      rect: this.data.rect,
55052      numItems: this.data.fieldValue.length,
55053      multipleSelection: this.data.multiSelect,
55054      hidden: this.data.hidden,
55055      actions: this.data.actions,
55056      items: this.data.options,
55057      page: this.data.pageIndex,
55058      strokeColor: this.data.borderColor,
55059      fillColor: this.data.backgroundColor,
55060      rotation: this.rotation,
55061      type
55062    };
55063  }
55064  amendSavedDict(annotationStorage, dict) {
55065    if (!this.hasIndices) {
55066      return;
55067    }
55068    let values = annotationStorage?.get(this.data.id)?.value;
55069    if (!Array.isArray(values)) {
55070      values = [values];
55071    }
55072    const indices = [];
55073    const {
55074      options
55075    } = this.data;
55076    for (let i = 0, j = 0, ii = options.length; i < ii; i++) {
55077      if (options[i].exportValue === values[j]) {
55078        indices.push(i);
55079        j += 1;
55080      }
55081    }
55082    dict.set("I", indices);
55083  }
55084  async _getAppearance(evaluator, task, intent, annotationStorage) {
55085    if (this.data.combo) {
55086      return super._getAppearance(evaluator, task, intent, annotationStorage);
55087    }
55088    let exportedValue, rotation;
55089    const storageEntry = annotationStorage?.get(this.data.id);
55090    if (storageEntry) {
55091      rotation = storageEntry.rotation;
55092      exportedValue = storageEntry.value;
55093    }
55094    if (rotation === undefined && exportedValue === undefined && !this._needAppearances) {
55095      return null;
55096    }
55097    if (exportedValue === undefined) {
55098      exportedValue = this.data.fieldValue;
55099    } else if (!Array.isArray(exportedValue)) {
55100      exportedValue = [exportedValue];
55101    }
55102    const defaultPadding = 1;
55103    const defaultHPadding = 2;
55104    let {
55105      width: totalWidth,
55106      height: totalHeight
55107    } = this;
55108    if (rotation === 90 || rotation === 270) {
55109      [totalWidth, totalHeight] = [totalHeight, totalWidth];
55110    }
55111    const lineCount = this.data.options.length;
55112    const valueIndices = [];
55113    for (let i = 0; i < lineCount; i++) {
55114      const {
55115        exportValue
55116      } = this.data.options[i];
55117      if (exportedValue.includes(exportValue)) {
55118        valueIndices.push(i);
55119      }
55120    }
55121    if (!this._defaultAppearance) {
55122      this.data.defaultAppearanceData = parseDefaultAppearance(this._defaultAppearance = "/Helvetica 0 Tf 0 g");
55123    }
55124    const font = await WidgetAnnotation._getFontData(evaluator, task, this.data.defaultAppearanceData, this._fieldResources.mergedResources);
55125    let defaultAppearance;
55126    let {
55127      fontSize
55128    } = this.data.defaultAppearanceData;
55129    if (!fontSize) {
55130      const lineHeight = (totalHeight - defaultPadding) / lineCount;
55131      let lineWidth = -1;
55132      let value;
55133      for (const {
55134        displayValue
55135      } of this.data.options) {
55136        const width = this._getTextWidth(displayValue, font);
55137        if (width > lineWidth) {
55138          lineWidth = width;
55139          value = displayValue;
55140        }
55141      }
55142      [defaultAppearance, fontSize] = this._computeFontSize(lineHeight, totalWidth - 2 * defaultHPadding, value, font, -1);
55143    } else {
55144      defaultAppearance = this._defaultAppearance;
55145    }
55146    const lineHeight = fontSize * 
vendor: 2,117 bytes, lines 55146-55211
55146LINE_FACTOR;
55147    const vPadding = (lineHeight - fontSize) / 2;
55148    const numberOfVisibleLines = Math.floor(totalHeight / lineHeight);
55149    let firstIndex = 0;
55150    if (valueIndices.length > 0) {
55151      const minIndex = Math.min(...valueIndices);
55152      const maxIndex = Math.max(...valueIndices);
55153      firstIndex = Math.max(0, maxIndex - numberOfVisibleLines + 1);
55154      if (firstIndex > minIndex) {
55155        firstIndex = minIndex;
55156      }
55157    }
55158    const end = Math.min(firstIndex + numberOfVisibleLines + 1, lineCount);
55159    const buf = ["/Tx BMC q", `1 1 ${totalWidth} ${totalHeight} re W n`];
55160    if (valueIndices.length) {
55161      buf.push("0.600006 0.756866 0.854904 rg");
55162      for (const index of valueIndices) {
55163        if (firstIndex <= index && index < end) {
55164          buf.push(`1 ${totalHeight - (index - firstIndex + 1) * lineHeight} ${totalWidth} ${lineHeight} re f`);
55165        }
55166      }
55167    }
55168    buf.push("BT", defaultAppearance, `1 0 0 1 0 ${totalHeight} Tm`);
55169    const prevInfo = {
55170      shift: 0
55171    };
55172    for (let i = firstIndex; i < end; i++) {
55173      const {
55174        displayValue
55175      } = this.data.options[i];
55176      const vpadding = i === firstIndex ? vPadding : 0;
55177      buf.push(this._renderText(displayValue, font, fontSize, totalWidth, 0, prevInfo, defaultHPadding, -lineHeight + vpadding));
55178    }
55179    buf.push("ET Q EMC");
55180    return buf.join("\n");
55181  }
55182}
55183class SignatureWidgetAnnotation extends WidgetAnnotation {
55184  constructor(params) {
55185    super(params);
55186    this.data.fieldValue = null;
55187    this.data.hasOwnCanvas = this.data.noRotate;
55188    this.data.noHTML = !this.data.hasOwnCanvas;
55189  }
55190  getFieldObject() {
55191    return {
55192      id: this.data.id,
55193      value: null,
55194      page: this.data.pageIndex,
55195      type: "signature"
55196    };
55197  }
55198}
55199class TextAnnotation extends MarkupAnnotation {
55200  constructor(params) {
55201    const DEFAULT_ICON_SIZE = 22;
55202    super(params);
55203    this.data.noRotate = true;
55204    this.data.hasOwnCanvas = this.data.noRotate;
55205    this.data.noHTML = false;
55206    const {
55207      dict
55208    } = params;
55209    if (this.data.hasAppearance) {
55210      this.data.name = "NoIcon";
55211    } else {
vendor: 7,689 bytes, lines 55212-55458
55212      this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
55213      this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
55214      this.data.name = dict.has("Name") ? dict.get("Name").name : "Note";
55215    }
55216    if (dict.has("State")) {
55217      this.data.state = dict.get("State") || null;
55218      this.data.stateModel = dict.get("StateModel") || null;
55219    } else {
55220      this.data.state = null;
55221      this.data.stateModel = null;
55222    }
55223  }
55224}
55225class LinkAnnotation extends Annotation {
55226  constructor(params) {
55227    super(params);
55228    const {
55229      dict,
55230      annotationGlobals
55231    } = params;
55232    this.data.noHTML = false;
55233    const quadPoints = getQuadPoints(dict, this.rectangle);
55234    if (quadPoints) {
55235      this.data.quadPoints = quadPoints;
55236    }
55237    this.data.borderColor ||= this.data.color;
55238    Catalog.parseDestDictionary({
55239      destDict: dict,
55240      resultObj: this.data,
55241      docBaseUrl: annotationGlobals.baseUrl,
55242      docAttachments: annotationGlobals.attachments
55243    });
55244  }
55245  get overlaysTextContent() {
55246    return true;
55247  }
55248}
55249class PopupAnnotation extends Annotation {
55250  constructor(params) {
55251    super(params);
55252    const {
55253      dict
55254    } = params;
55255    this.data.noHTML = false;
55256    if (this.width === 0 || this.height === 0) {
55257      this.data.rect = null;
55258    }
55259    let parentItem = dict.get("Parent");
55260    if (!parentItem) {
55261      warn("Popup annotation has a missing or invalid parent annotation.");
55262      return;
55263    }
55264    this.data.parentRect = lookupNormalRect(parentItem.getArray("Rect"), null);
55265    this.data.creationDate = parentItem.get("CreationDate") || "";
55266    const rt = parentItem.get("RT");
55267    if (isName(rt, AnnotationReplyType.GROUP)) {
55268      parentItem = parentItem.get("IRT");
55269    }
55270    if (!parentItem.has("M")) {
55271      this.data.modificationDate = null;
55272    } else {
55273      this.setModificationDate(parentItem.get("M"));
55274      this.data.modificationDate = this.modificationDate;
55275    }
55276    if (!parentItem.has("C")) {
55277      this.data.color = null;
55278    } else {
55279      this.setColor(parentItem.getArray("C"));
55280      this.data.color = this.color;
55281    }
55282    if (!this.viewable) {
55283      const parentFlags = parentItem.get("F");
55284      if (this._isViewable(parentFlags)) {
55285        this.setFlags(parentFlags);
55286      }
55287    }
55288    this.setTitle(parentItem.get("T"));
55289    this.data.titleObj = this._title;
55290    this.setContents(parentItem.get("Contents"));
55291    this.data.contentsObj = this._contents;
55292    if (parentItem.has("RC")) {
55293      this.data.richText = XFAFactory.getRichTextAsHtml(parentItem.get("RC"));
55294    }
55295    this.data.open = !!dict.get("Open");
55296  }
55297  static createNewDict(annotation, xref, _params) {
55298    const {
55299      oldAnnotation,
55300      rect,
55301      parent
55302    } = annotation;
55303    const popup = oldAnnotation || new Dict(xref);
55304    popup.setIfNotExists("Type", Name.get("Annot"));
55305    popup.setIfNotExists("Subtype", Name.get("Popup"));
55306    popup.setIfNotExists("Open", false);
55307    popup.setIfArray("Rect", rect);
55308    popup.set("Parent", parent);
55309    return popup;
55310  }
55311  static async createNewAppearanceStream(annotation, xref, params) {
55312    return null;
55313  }
55314}
55315class FreeTextAnnotation extends MarkupAnnotation {
55316  constructor(params) {
55317    super(params);
55318    this.data.hasOwnCanvas = this.data.noRotate;
55319    this.data.isEditable = !this.data.noHTML;
55320    this.data.noHTML = false;
55321    const {
55322      annotationGlobals,
55323      xref
55324    } = params;
55325    this.setDefaultAppearance(params);
55326    this._hasAppearance = !!this.appearance;
55327    if (this._hasAppearance) {
55328      const {
55329        fontColor,
55330        fontSize
55331      } = parseAppearanceStream(this.appearance, xref, annotationGlobals.globalColorSpaceCache);
55332      this.data.defaultAppearanceData.fontColor = fontColor;
55333      this.data.defaultAppearanceData.fontSize = fontSize || 10;
55334    } else {
55335      this.data.defaultAppearanceData.fontSize ||= 10;
55336      const {
55337        fontColor,
55338        fontSize
55339      } = this.data.defaultAppearanceData;
55340      if (this._contents.str) {
55341        this.data.textContent = this._contents.str.split(/\r\n?|\n/).map(line => line.trimEnd());
55342        const {
55343          coords,
55344          bbox,
55345          matrix
55346        } = FakeUnicodeFont.getFirstPositionInfo(this.rectangle, this.rotation, fontSize);
55347        this.data.textPosition = this._transformPoint(coords, bbox, matrix);
55348      }
55349      if (this._isOffscreenCanvasSupported) {
55350        const strokeAlpha = params.dict.get("CA");
55351        const fakeUnicodeFont = new FakeUnicodeFont(xref, "sans-serif");
55352        this.appearance = fakeUnicodeFont.createAppearance(this._contents.str, this.rectangle, this.rotation, fontSize, fontColor, strokeAlpha);
55353        this._streams.push(this.appearance);
55354      } else {
55355        warn("FreeTextAnnotation: OffscreenCanvas is not supported, annotation may not render correctly.");
55356      }
55357    }
55358  }
55359  get hasTextContent() {
55360    return this._hasAppearance;
55361  }
55362  static createNewDict(annotation, xref, {
55363    apRef,
55364    ap
55365  }) {
55366    const {
55367      color,
55368      date,
55369      fontSize,
55370      oldAnnotation,
55371      rect,
55372      rotation,
55373      user,
55374      value
55375    } = annotation;
55376    const freetext = oldAnnotation || new Dict(xref);
55377    freetext.setIfNotExists("Type", Name.get("Annot"));
55378    freetext.setIfNotExists("Subtype", Name.get("FreeText"));
55379    freetext.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate(date)}`);
55380    if (oldAnnotation) {
55381      freetext.delete("RC");
55382    }
55383    freetext.setIfArray("Rect", rect);
55384    const da = `/Helv ${fontSize} Tf ${getPdfColor(color, true)}`;
55385    freetext.set("DA", da);
55386    freetext.setIfDefined("Contents", stringToAsciiOrUTF16BE(value));
55387    freetext.setIfNotExists("F", 4);
55388    freetext.setIfNotExists("Border", [0, 0, 0]);
55389    freetext.setIfNumber("Rotate", rotation);
55390    freetext.setIfDefined("T", stringToAsciiOrUTF16BE(user));
55391    if (apRef || ap) {
55392      const n = new Dict(xref);
55393      freetext.set("AP", n);
55394      n.set("N", apRef || ap);
55395    }
55396    return freetext;
55397  }
55398  static async createNewAppearanceStream(annotation, xref, params) {
55399    const {
55400      baseFontRef,
55401      evaluator,
55402      task
55403    } = params;
55404    const {
55405      color,
55406      fontSize,
55407      rect,
55408      rotation,
55409      value
55410    } = annotation;
55411    if (!color) {
55412      return null;
55413    }
55414    const resources = new Dict(xref);
55415    const font = new Dict(xref);
55416    if (baseFontRef) {
55417      font.set("Helv", baseFontRef);
55418    } else {
55419      const baseFont = new Dict(xref);
55420      baseFont.setIfName("BaseFont", "Helvetica");
55421      baseFont.setIfName("Type", "Font");
55422      baseFont.setIfName("Subtype", "Type1");
55423      baseFont.setIfName("Encoding", "WinAnsiEncoding");
55424      font.set("Helv", baseFont);
55425    }
55426    resources.set("Font", font);
55427    const helv = await WidgetAnnotation._getFontData(evaluator, task, {
55428      fontName: "Helv",
55429      fontSize
55430    }, resources);
55431    const [x1, y1, x2, y2] = rect;
55432    let w = x2 - x1;
55433    let h = y2 - y1;
55434    if (rotation % 180 !== 0) {
55435      [w, h] = [h, w];
55436    }
55437    const lines = value.split("\n");
55438    const scale = fontSize / 1000;
55439    let totalWidth = -Infinity;
55440    const encodedLines = [];
55441    for (let line of lines) {
55442      const encoded = helv.encodeString(line);
55443      if (encoded.length > 1) {
55444        return null;
55445      }
55446      line = encoded.join("");
55447      encodedLines.push(line);
55448      let lineWidth = 0;
55449      const glyphs = helv.charsToGlyphs(line);
55450      for (const glyph of glyphs) {
55451        lineWidth += glyph.width * scale;
55452      }
55453      totalWidth = Math.max(totalWidth, lineWidth);
55454    }
55455    const hscale = totalWidth > w ? w / totalWidth : 1;
55456    let vscale = 1;
55457    const lineHeight = LINE_FACTOR * fontSize;
55458    const lineAscent = (LINE_FACTOR - LINE_DESCENT_FACTOR
vendor: 7,571 bytes, lines 55458-55657
55458) * fontSize;
55459    const totalHeight = lineHeight * lines.length;
55460    if (totalHeight > h) {
55461      vscale = h / totalHeight;
55462    }
55463    const fscale = Math.min(hscale, vscale);
55464    const newFontSize = fontSize * fscale;
55465    let firstPoint, clipBox, matrix;
55466    switch (rotation) {
55467      case 0:
55468        matrix = [1, 0, 0, 1];
55469        clipBox = [rect[0], rect[1], w, h];
55470        firstPoint = [rect[0], rect[3] - lineAscent];
55471        break;
55472      case 90:
55473        matrix = [0, 1, -1, 0];
55474        clipBox = [rect[1], -rect[2], w, h];
55475        firstPoint = [rect[1], -rect[0] - lineAscent];
55476        break;
55477      case 180:
55478        matrix = [-1, 0, 0, -1];
55479        clipBox = [-rect[2], -rect[3], w, h];
55480        firstPoint = [-rect[2], -rect[1] - lineAscent];
55481        break;
55482      case 270:
55483        matrix = [0, -1, 1, 0];
55484        clipBox = [-rect[3], rect[0], w, h];
55485        firstPoint = [-rect[3], rect[2] - lineAscent];
55486        break;
55487    }
55488    const buffer = ["q", `${matrix.join(" ")} 0 0 cm`, `${clipBox.join(" ")} re W n`, `BT`, `${getPdfColor(color, true)}`, `0 Tc /Helv ${numberToString(newFontSize)} Tf`];
55489    buffer.push(`${firstPoint.join(" ")} Td (${escapeString(encodedLines[0])}) Tj`);
55490    const vShift = numberToString(lineHeight);
55491    for (let i = 1, ii = encodedLines.length; i < ii; i++) {
55492      const line = encodedLines[i];
55493      buffer.push(`0 -${vShift} Td (${escapeString(line)}) Tj`);
55494    }
55495    buffer.push("ET", "Q");
55496    const appearance = buffer.join("\n");
55497    const appearanceStreamDict = new Dict(xref);
55498    appearanceStreamDict.set("FormType", 1);
55499    appearanceStreamDict.setIfName("Subtype", "Form");
55500    appearanceStreamDict.setIfName("Type", "XObject");
55501    appearanceStreamDict.set("BBox", rect);
55502    appearanceStreamDict.set("Resources", resources);
55503    appearanceStreamDict.set("Matrix", [1, 0, 0, 1, -rect[0], -rect[1]]);
55504    return new StringStream(appearance, appearanceStreamDict);
55505  }
55506}
55507class LineAnnotation extends MarkupAnnotation {
55508  constructor(params) {
55509    super(params);
55510    const {
55511      dict,
55512      xref
55513    } = params;
55514    this.data.hasOwnCanvas = this.data.noRotate;
55515    this.data.noHTML = false;
55516    const lineCoordinates = lookupRect(dict.getArray("L"), [0, 0, 0, 0]);
55517    this.data.lineCoordinates = Util.normalizeRect(lineCoordinates);
55518    this.setLineEndings(dict.getArray("LE"));
55519    this.data.lineEndings = this.lineEndings;
55520    if (!this.appearance) {
55521      const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
55522      const strokeAlpha = dict.get("CA");
55523      const interiorColor = getRgbColor(dict.getArray("IC"), null);
55524      const fillColor = getPdfColorArray(interiorColor);
55525      const fillAlpha = fillColor ? strokeAlpha : null;
55526      const borderWidth = this.borderStyle.width || 1,
55527        borderAdjust = 2 * borderWidth;
55528      const bbox = [this.data.lineCoordinates[0] - borderAdjust, this.data.lineCoordinates[1] - borderAdjust, this.data.lineCoordinates[2] + borderAdjust, this.data.lineCoordinates[3] + borderAdjust];
55529      if (!Util.intersect(this.rectangle, bbox)) {
55530        this.rectangle = bbox;
55531      }
55532      this._setDefaultAppearance({
55533        xref,
55534        extra: `${borderWidth} w`,
55535        strokeColor,
55536        fillColor,
55537        strokeAlpha,
55538        fillAlpha,
55539        pointsCallback: (buffer, points) => {
55540          buffer.push(`${lineCoordinates[0]} ${lineCoordinates[1]} m`, `${lineCoordinates[2]} ${lineCoordinates[3]} l`, "S");
55541          return [points[0] - borderWidth, points[7] - borderWidth, points[2] + borderWidth, points[3] + borderWidth];
55542        }
55543      });
55544    }
55545  }
55546}
55547class SquareAnnotation extends MarkupAnnotation {
55548  constructor(params) {
55549    super(params);
55550    const {
55551      dict,
55552      xref
55553    } = params;
55554    this.data.hasOwnCanvas = this.data.noRotate;
55555    this.data.noHTML = false;
55556    if (!this.appearance) {
55557      const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
55558      const strokeAlpha = dict.get("CA");
55559      const interiorColor = getRgbColor(dict.getArray("IC"), null);
55560      const fillColor = getPdfColorArray(interiorColor);
55561      const fillAlpha = fillColor ? strokeAlpha : null;
55562      if (this.borderStyle.width === 0 && !fillColor) {
55563        return;
55564      }
55565      this._setDefaultAppearance({
55566        xref,
55567        extra: `${this.borderStyle.width} w`,
55568        strokeColor,
55569        fillColor,
55570        strokeAlpha,
55571        fillAlpha,
55572        pointsCallback: (buffer, points) => {
55573          const x = points[4] + this.borderStyle.width / 2;
55574          const y = points[5] + this.borderStyle.width / 2;
55575          const width = points[6] - points[4] - this.borderStyle.width;
55576          const height = points[3] - points[7] - this.borderStyle.width;
55577          buffer.push(`${x} ${y} ${width} ${height} re`);
55578          if (fillColor) {
55579            buffer.push("B");
55580          } else {
55581            buffer.push("S");
55582          }
55583          return [points[0], points[7], points[2], points[3]];
55584        }
55585      });
55586    }
55587  }
55588}
55589class CircleAnnotation extends MarkupAnnotation {
55590  constructor(params) {
55591    super(params);
55592    const {
55593      dict,
55594      xref
55595    } = params;
55596    if (!this.appearance) {
55597      const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
55598      const strokeAlpha = dict.get("CA");
55599      const interiorColor = getRgbColor(dict.getArray("IC"), null);
55600      const fillColor = getPdfColorArray(interiorColor);
55601      const fillAlpha = fillColor ? strokeAlpha : null;
55602      if (this.borderStyle.width === 0 && !fillColor) {
55603        return;
55604      }
55605      const controlPointsDistance = 4 / 3 * Math.tan(Math.PI / (2 * 4));
55606      this._setDefaultAppearance({
55607        xref,
55608        extra: `${this.borderStyle.width} w`,
55609        strokeColor,
55610        fillColor,
55611        strokeAlpha,
55612        fillAlpha,
55613        pointsCallback: (buffer, points) => {
55614          const x0 = points[0] + this.borderStyle.width / 2;
55615          const y0 = points[1] - this.borderStyle.width / 2;
55616          const x1 = points[6] - this.borderStyle.width / 2;
55617          const y1 = points[7] + this.borderStyle.width / 2;
55618          const xMid = x0 + (x1 - x0) / 2;
55619          const yMid = y0 + (y1 - y0) / 2;
55620          const xOffset = (x1 - x0) / 2 * controlPointsDistance;
55621          const yOffset = (y1 - y0) / 2 * controlPointsDistance;
55622          buffer.push(`${xMid} ${y1} m`, `${xMid + xOffset} ${y1} ${x1} ${yMid + yOffset} ${x1} ${yMid} c`, `${x1} ${yMid - yOffset} ${xMid + xOffset} ${y0} ${xMid} ${y0} c`, `${xMid - xOffset} ${y0} ${x0} ${yMid - yOffset} ${x0} ${yMid} c`, `${x0} ${yMid + yOffset} ${xMid - xOffset} ${y1} ${xMid} ${y1} c`, "h");
55623          if (fillColor) {
55624            buffer.push("B");
55625          } else {
55626            buffer.push("S");
55627          }
55628          return [points[0], points[7], points[2], points[3]];
55629        }
55630      });
55631    }
55632  }
55633}
55634class PolylineAnnotation extends MarkupAnnotation {
55635  constructor(params) {
55636    super(params);
55637    const {
55638      dict,
55639      xref
55640    } = params;
55641    this.data.hasOwnCanvas = this.data.noRotate;
55642    this.data.noHTML = false;
55643    this.data.vertices = null;
55644    if (!(this instanceof PolygonAnnotation)) {
55645      this.setLineEndings(dict.getArray("LE"));
55646      this.data.lineEndings = this.lineEndings;
55647    }
55648    const rawVertices = dict.getArray("Vertices");
55649    if (!isNumberArray(rawVertices, null)) {
55650      return;
55651    }
55652    const vertices = this.data.vertices = Float32Array.from(rawVertices);
55653    if (!this.appearance) {
55654      const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
55655      const strokeAlpha = dict.get("CA");
55656      let fillColor = getRgbColor(dict.getArray("IC"), null);
55657      
vendor: 7,502 bytes, lines 55657-55877
55657if (fillColor) {
55658        fillColor = getPdfColorArray(fillColor);
55659      }
55660      let operator;
55661      if (fillColor) {
55662        if (this.color) {
55663          operator = fillColor.every((c, i) => c === strokeColor[i]) ? "f" : "B";
55664        } else {
55665          operator = "f";
55666        }
55667      } else {
55668        operator = "S";
55669      }
55670      const borderWidth = this.borderStyle.width || 1,
55671        borderAdjust = 2 * borderWidth;
55672      const bbox = BBOX_INIT.slice();
55673      for (let i = 0, ii = vertices.length; i < ii; i += 2) {
55674        Util.rectBoundingBox(vertices[i] - borderAdjust, vertices[i + 1] - borderAdjust, vertices[i] + borderAdjust, vertices[i + 1] + borderAdjust, bbox);
55675      }
55676      if (!Util.intersect(this.rectangle, bbox)) {
55677        this.rectangle = bbox;
55678      }
55679      this._setDefaultAppearance({
55680        xref,
55681        extra: `${borderWidth} w`,
55682        strokeColor,
55683        strokeAlpha,
55684        fillColor,
55685        fillAlpha: fillColor ? strokeAlpha : null,
55686        pointsCallback: (buffer, points) => {
55687          for (let i = 0, ii = vertices.length; i < ii; i += 2) {
55688            buffer.push(`${vertices[i]} ${vertices[i + 1]} ${i === 0 ? "m" : "l"}`);
55689          }
55690          buffer.push(operator);
55691          return [points[0], points[7], points[2], points[3]];
55692        }
55693      });
55694    }
55695  }
55696}
55697class PolygonAnnotation extends PolylineAnnotation {}
55698class CaretAnnotation extends MarkupAnnotation {}
55699class InkAnnotation extends MarkupAnnotation {
55700  constructor(params) {
55701    super(params);
55702    this.data.hasOwnCanvas = this.data.noRotate;
55703    this.data.noHTML = false;
55704    const {
55705      dict,
55706      xref
55707    } = params;
55708    this.data.inkLists = [];
55709    this.data.isEditable = !this.data.noHTML;
55710    this.data.noHTML = false;
55711    this.data.opacity = dict.get("CA") || 1;
55712    const rawInkLists = dict.getArray("InkList");
55713    if (!Array.isArray(rawInkLists)) {
55714      return;
55715    }
55716    for (let i = 0, ii = rawInkLists.length; i < ii; ++i) {
55717      if (!Array.isArray(rawInkLists[i])) {
55718        continue;
55719      }
55720      const inkList = new Float32Array(rawInkLists[i].length);
55721      this.data.inkLists.push(inkList);
55722      for (let j = 0, jj = rawInkLists[i].length; j < jj; j += 2) {
55723        const x = xref.fetchIfRef(rawInkLists[i][j]),
55724          y = xref.fetchIfRef(rawInkLists[i][j + 1]);
55725        if (typeof x === "number" && typeof y === "number") {
55726          inkList[j] = x;
55727          inkList[j + 1] = y;
55728        }
55729      }
55730    }
55731    if (!this.appearance) {
55732      const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
55733      const strokeAlpha = dict.get("CA");
55734      const borderWidth = this.borderStyle.width || 1,
55735        borderAdjust = 2 * borderWidth;
55736      const bbox = BBOX_INIT.slice();
55737      for (const inkList of this.data.inkLists) {
55738        for (let i = 0, ii = inkList.length; i < ii; i += 2) {
55739          Util.rectBoundingBox(inkList[i] - borderAdjust, inkList[i + 1] - borderAdjust, inkList[i] + borderAdjust, inkList[i + 1] + borderAdjust, bbox);
55740        }
55741      }
55742      if (!Util.intersect(this.rectangle, bbox)) {
55743        this.rectangle = bbox;
55744      }
55745      this._setDefaultAppearance({
55746        xref,
55747        extra: `${borderWidth} w`,
55748        strokeColor,
55749        strokeAlpha,
55750        pointsCallback: (buffer, points) => {
55751          for (const inkList of this.data.inkLists) {
55752            for (let i = 0, ii = inkList.length; i < ii; i += 2) {
55753              buffer.push(`${inkList[i]} ${inkList[i + 1]} ${i === 0 ? "m" : "l"}`);
55754            }
55755            buffer.push("S");
55756          }
55757          return [points[0], points[7], points[2], points[3]];
55758        }
55759      });
55760    }
55761  }
55762  static createNewDict(annotation, xref, {
55763    apRef,
55764    ap
55765  }) {
55766    const {
55767      oldAnnotation,
55768      color,
55769      date,
55770      opacity,
55771      paths,
55772      outlines,
55773      rect,
55774      rotation,
55775      thickness,
55776      user
55777    } = annotation;
55778    const ink = oldAnnotation || new Dict(xref);
55779    ink.setIfNotExists("Type", Name.get("Annot"));
55780    ink.setIfNotExists("Subtype", Name.get("Ink"));
55781    ink.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate(date)}`);
55782    ink.setIfArray("Rect", rect);
55783    ink.setIfArray("InkList", outlines?.points || paths?.points);
55784    ink.setIfNotExists("F", 4);
55785    ink.setIfNumber("Rotate", rotation);
55786    ink.setIfDefined("T", stringToAsciiOrUTF16BE(user));
55787    if (outlines) {
55788      ink.setIfName("IT", "InkHighlight");
55789    }
55790    if (thickness > 0) {
55791      const bs = new Dict(xref);
55792      ink.set("BS", bs);
55793      bs.set("W", thickness);
55794    }
55795    ink.setIfArray("C", getPdfColorArray(color));
55796    ink.setIfNumber("CA", opacity);
55797    if (ap || apRef) {
55798      const n = new Dict(xref);
55799      ink.set("AP", n);
55800      n.set("N", apRef || ap);
55801    }
55802    return ink;
55803  }
55804  static async createNewAppearanceStream(annotation, xref, params) {
55805    if (annotation.outlines) {
55806      return this.createNewAppearanceStreamForHighlight(annotation, xref, params);
55807    }
55808    const {
55809      color,
55810      rect,
55811      paths,
55812      thickness,
55813      opacity
55814    } = annotation;
55815    if (!color) {
55816      return null;
55817    }
55818    const appearanceBuffer = [`${thickness} w 1 J 1 j`, `${getPdfColor(color, false)}`];
55819    if (opacity !== 1) {
55820      appearanceBuffer.push("/R0 gs");
55821    }
55822    for (const outline of paths.lines) {
55823      appearanceBuffer.push(`${numberToString(outline[4])} ${numberToString(outline[5])} m`);
55824      for (let i = 6, ii = outline.length; i < ii; i += 6) {
55825        if (isNaN(outline[i])) {
55826          appearanceBuffer.push(`${numberToString(outline[i + 4])} ${numberToString(outline[i + 5])} l`);
55827        } else {
55828          const [c1x, c1y, c2x, c2y, x, y] = outline.slice(i, i + 6);
55829          appearanceBuffer.push([c1x, c1y, c2x, c2y, x, y].map(numberToString).join(" ") + " c");
55830        }
55831      }
55832      if (outline.length === 6) {
55833        appearanceBuffer.push(`${numberToString(outline[4])} ${numberToString(outline[5])} l`);
55834      }
55835    }
55836    appearanceBuffer.push("S");
55837    const appearance = appearanceBuffer.join("\n");
55838    const appearanceStreamDict = new Dict(xref);
55839    appearanceStreamDict.set("FormType", 1);
55840    appearanceStreamDict.setIfName("Subtype", "Form");
55841    appearanceStreamDict.setIfName("Type", "XObject");
55842    appearanceStreamDict.set("BBox", rect);
55843    appearanceStreamDict.set("Length", appearance.length);
55844    if (opacity !== 1) {
55845      const resources = new Dict(xref);
55846      const extGState = new Dict(xref);
55847      const r0 = new Dict(xref);
55848      r0.set("CA", opacity);
55849      r0.setIfName("Type", "ExtGState");
55850      extGState.set("R0", r0);
55851      resources.set("ExtGState", extGState);
55852      appearanceStreamDict.set("Resources", resources);
55853    }
55854    return new StringStream(appearance, appearanceStreamDict);
55855  }
55856  static async createNewAppearanceStreamForHighlight(annotation, xref, params) {
55857    const {
55858      color,
55859      rect,
55860      outlines: {
55861        outline
55862      },
55863      opacity
55864    } = annotation;
55865    if (!color) {
55866      return null;
55867    }
55868    const appearanceBuffer = [`${getPdfColor(color, true)}`, "/R0 gs"];
55869    appearanceBuffer.push(`${numberToString(outline[4])} ${numberToString(outline[5])} m`);
55870    for (let i = 6, ii = outline.length; i < ii; i += 6) {
55871      if (isNaN(outline[i])) {
55872        appearanceBuffer.push(`${numberToString(outline[i + 4])} ${numberToString(outline[i + 5])} l`);
55873      } else {
55874        const [c1x, c1y, c2x, c2y, x, y] = outline.slice(i, i + 6);
55875        appearanceBuffer.push([c1x, c1y, c2x, c2y, x, y].map(numberToString).join(" ") + " c");
55876      }
55877    }
vendor: 9,245 bytes, lines 55877-56176
55877
55878    appearanceBuffer.push("h f");
55879    const appearance = appearanceBuffer.join("\n");
55880    const appearanceStreamDict = new Dict(xref);
55881    appearanceStreamDict.set("FormType", 1);
55882    appearanceStreamDict.setIfName("Subtype", "Form");
55883    appearanceStreamDict.setIfName("Type", "XObject");
55884    appearanceStreamDict.set("BBox", rect);
55885    appearanceStreamDict.set("Length", appearance.length);
55886    const resources = new Dict(xref);
55887    const extGState = new Dict(xref);
55888    resources.set("ExtGState", extGState);
55889    appearanceStreamDict.set("Resources", resources);
55890    const r0 = new Dict(xref);
55891    extGState.set("R0", r0);
55892    r0.setIfName("BM", "Multiply");
55893    if (opacity !== 1) {
55894      r0.set("ca", opacity);
55895      r0.setIfName("Type", "ExtGState");
55896    }
55897    return new StringStream(appearance, appearanceStreamDict);
55898  }
55899}
55900class HighlightAnnotation extends MarkupAnnotation {
55901  constructor(params) {
55902    super(params);
55903    const {
55904      dict,
55905      xref
55906    } = params;
55907    this.data.isEditable = !this.data.noHTML;
55908    this.data.noHTML = false;
55909    this.data.opacity = dict.get("CA") || 1;
55910    const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
55911    if (quadPoints) {
55912      if (!this.appearance) {
55913        const fillColor = getPdfColorArray(this.color, [1, 1, 0]);
55914        const fillAlpha = dict.get("CA");
55915        this._setDefaultAppearance({
55916          xref,
55917          fillColor,
55918          blendMode: "Multiply",
55919          fillAlpha,
55920          pointsCallback: (buffer, points) => {
55921            buffer.push(`${points[0]} ${points[1]} m`, `${points[2]} ${points[3]} l`, `${points[6]} ${points[7]} l`, `${points[4]} ${points[5]} l`, "f");
55922            return [points[0], points[7], points[2], points[3]];
55923          }
55924        });
55925      }
55926    } else {
55927      this.data.popupRef = null;
55928    }
55929  }
55930  get overlaysTextContent() {
55931    return true;
55932  }
55933  static createNewDict(annotation, xref, {
55934    apRef,
55935    ap
55936  }) {
55937    const {
55938      color,
55939      date,
55940      oldAnnotation,
55941      opacity,
55942      rect,
55943      rotation,
55944      user,
55945      quadPoints
55946    } = annotation;
55947    const highlight = oldAnnotation || new Dict(xref);
55948    highlight.setIfNotExists("Type", Name.get("Annot"));
55949    highlight.setIfNotExists("Subtype", Name.get("Highlight"));
55950    highlight.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate(date)}`);
55951    highlight.setIfArray("Rect", rect);
55952    highlight.setIfNotExists("F", 4);
55953    highlight.setIfNotExists("Border", [0, 0, 0]);
55954    highlight.setIfNumber("Rotate", rotation);
55955    highlight.setIfArray("QuadPoints", quadPoints);
55956    highlight.setIfArray("C", getPdfColorArray(color));
55957    highlight.setIfNumber("CA", opacity);
55958    highlight.setIfDefined("T", stringToAsciiOrUTF16BE(user));
55959    if (apRef || ap) {
55960      const n = new Dict(xref);
55961      highlight.set("AP", n);
55962      n.set("N", apRef || ap);
55963    }
55964    return highlight;
55965  }
55966  static async createNewAppearanceStream(annotation, xref, params) {
55967    const {
55968      color,
55969      rect,
55970      outlines,
55971      opacity
55972    } = annotation;
55973    if (!color) {
55974      return null;
55975    }
55976    const appearanceBuffer = [`${getPdfColor(color, true)}`, "/R0 gs"];
55977    const buffer = [];
55978    for (const outline of outlines) {
55979      buffer.length = 0;
55980      buffer.push(`${numberToString(outline[0])} ${numberToString(outline[1])} m`);
55981      for (let i = 2, ii = outline.length; i < ii; i += 2) {
55982        buffer.push(`${numberToString(outline[i])} ${numberToString(outline[i + 1])} l`);
55983      }
55984      buffer.push("h");
55985      appearanceBuffer.push(buffer.join("\n"));
55986    }
55987    appearanceBuffer.push("f*");
55988    const appearance = appearanceBuffer.join("\n");
55989    const appearanceStreamDict = new Dict(xref);
55990    appearanceStreamDict.set("FormType", 1);
55991    appearanceStreamDict.setIfName("Subtype", "Form");
55992    appearanceStreamDict.setIfName("Type", "XObject");
55993    appearanceStreamDict.set("BBox", rect);
55994    appearanceStreamDict.set("Length", appearance.length);
55995    const resources = new Dict(xref);
55996    const extGState = new Dict(xref);
55997    resources.set("ExtGState", extGState);
55998    appearanceStreamDict.set("Resources", resources);
55999    const r0 = new Dict(xref);
56000    extGState.set("R0", r0);
56001    r0.setIfName("BM", "Multiply");
56002    if (opacity !== 1) {
56003      r0.set("ca", opacity);
56004      r0.setIfName("Type", "ExtGState");
56005    }
56006    return new StringStream(appearance, appearanceStreamDict);
56007  }
56008}
56009class UnderlineAnnotation extends MarkupAnnotation {
56010  constructor(params) {
56011    super(params);
56012    const {
56013      dict,
56014      xref
56015    } = params;
56016    const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
56017    if (quadPoints) {
56018      if (!this.appearance) {
56019        const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
56020        const strokeAlpha = dict.get("CA");
56021        this._setDefaultAppearance({
56022          xref,
56023          extra: "[] 0 d 0.571 w",
56024          strokeColor,
56025          strokeAlpha,
56026          pointsCallback: (buffer, points) => {
56027            buffer.push(`${points[4]} ${points[5] + 1.3} m`, `${points[6]} ${points[7] + 1.3} l`, "S");
56028            return [points[0], points[7], points[2], points[3]];
56029          }
56030        });
56031      }
56032    } else {
56033      this.data.popupRef = null;
56034    }
56035  }
56036  get overlaysTextContent() {
56037    return true;
56038  }
56039}
56040class SquigglyAnnotation extends MarkupAnnotation {
56041  constructor(params) {
56042    super(params);
56043    const {
56044      dict,
56045      xref
56046    } = params;
56047    const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
56048    if (quadPoints) {
56049      if (!this.appearance) {
56050        const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
56051        const strokeAlpha = dict.get("CA");
56052        this._setDefaultAppearance({
56053          xref,
56054          extra: "[] 0 d 1 w",
56055          strokeColor,
56056          strokeAlpha,
56057          pointsCallback: (buffer, points) => {
56058            const dy = (points[1] - points[5]) / 6;
56059            let shift = dy;
56060            let x = points[4];
56061            const y = points[5];
56062            const xEnd = points[6];
56063            buffer.push(`${x} ${y + shift} m`);
56064            do {
56065              x += 2;
56066              shift = shift === 0 ? dy : 0;
56067              buffer.push(`${x} ${y + shift} l`);
56068            } while (x < xEnd);
56069            buffer.push("S");
56070            return [points[4], y - 2 * dy, xEnd, y + 2 * dy];
56071          }
56072        });
56073      }
56074    } else {
56075      this.data.popupRef = null;
56076    }
56077  }
56078  get overlaysTextContent() {
56079    return true;
56080  }
56081}
56082class StrikeOutAnnotation extends MarkupAnnotation {
56083  constructor(params) {
56084    super(params);
56085    const {
56086      dict,
56087      xref
56088    } = params;
56089    const quadPoints = this.data.quadPoints = getQuadPoints(dict, null);
56090    if (quadPoints) {
56091      if (!this.appearance) {
56092        const strokeColor = getPdfColorArray(this.color, [0, 0, 0]);
56093        const strokeAlpha = dict.get("CA");
56094        this._setDefaultAppearance({
56095          xref,
56096          extra: "[] 0 d 1 w",
56097          strokeColor,
56098          strokeAlpha,
56099          pointsCallback: (buffer, points) => {
56100            buffer.push(`${(points[0] + points[4]) / 2} ` + `${(points[1] + points[5]) / 2} m`, `${(points[2] + points[6]) / 2} ` + `${(points[3] + points[7]) / 2} l`, "S");
56101            return [points[0], points[7], points[2], points[3]];
56102          }
56103        });
56104      }
56105    } else {
56106      this.data.popupRef = null;
56107    }
56108  }
56109  get overlaysTextContent() {
56110    return true;
56111  }
56112}
56113class StampAnnotation extends MarkupAnnotation {
56114  #savedHasOwnCanvas = null;
56115  constructor(params) {
56116    super(params);
56117    this.data.hasOwnCanvas = this.data.noRotate;
56118    this.data.isEditable = !this.data.noHTML;
56119    this.data.noHTML = false;
56120  }
56121  mustBeViewedWhenEditing(isEditing, modifiedIds = null) {
56122    if (isEditing) {
56123      if (!this.data.isEditable) {
56124        return true;
56125      }
56126      this.#savedHasOwnCanvas ??= this.data.hasOwnCanvas;
56127      this.data.hasOwnCanvas = true;
56128      return true;
56129    }
56130    if (this.#savedHasOwnCanvas !== null) {
56131      this.data.hasOwnCanvas = this.#savedHasOwnCanvas;
56132      this.#savedHasOwnCanvas = null;
56133    }
56134    return !modifiedIds?.has(this.data.id);
56135  }
56136  static createNewDict(annotation, xref, {
56137    apRef,
56138    ap
56139  }) {
56140    const {
56141      date,
56142      oldAnnotation,
56143      rect,
56144      rotation,
56145      user
56146    } = annotation;
56147    const stamp = oldAnnotation || new Dict(xref);
56148    stamp.setIfNotExists("Type", Name.get("Annot"));
56149    stamp.setIfNotExists("Subtype", Name.get("Stamp"));
56150    stamp.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate(date)}`);
56151    stamp.setIfArray("Rect", rect);
56152    stamp.setIfNotExists("F", 4);
56153    stamp.setIfNotExists("Border", [0, 0, 0]);
56154    stamp.setIfNumber("Rotate", rotation);
56155    stamp.setIfDefined("T", stringToAsciiOrUTF16BE(user));
56156    if (apRef || ap) {
56157      const n = new Dict(xref);
56158      stamp.set("AP", n);
56159      n.set("N", apRef || ap);
56160    }
56161    return stamp;
56162  }
56163  static async #createNewAppearanceStreamForDrawing(annotation, xref) {
56164    const {
56165      areContours,
56166      color,
56167      rect,
56168      lines,
56169      thickness
56170    } = annotation;
56171    if (!color) {
56172      return null;
56173    }
56174    const appearanceBuffer = [`${thickness} w 1 J 1 j`, `${getPdfColor(color, areContours)}`];
56175    for (const line of lines) {
56176      
56176appearanceBuffer.push(`${numberToString(line[4])} ${numberToString(line[5])} m`);
56177      for (let i = 6, ii = line.length; i < ii; i += 6) {
56178        if (isNaN(line[i])) {
56179          appearanceBuffer.push(`${numberToString(line[i + 4])} ${numberToString(line[i + 5])} l`);
56180        } else {
56181          const [c1x, c1y, c2x, c2y, x, y] = line.slice(i, i + 6);
56182          appearanceBuffer.push([c1x, c1y, c2x, c2y, x, y].map(numberToString).join(" ") + " c");
56183        }
56184      }
56185      if (line.length === 6) {
56186        appearanceBuffer.push(`${numberToString(line[4])} ${numberToString(line[5])} l`);
56187      }
56188    }
56189    appearanceBuffer.push(areContours ? "F" : "S");
56190    const appearance = appearanceBuffer.join("\n");
56191    const appearanceStreamDict = new Dict(xref);
56192    appearanceStreamDict.set("FormType", 1);
56193    appearanceStreamDict.setIfName("Subtype", "Form");
56194    appearanceStreamDict.setIfName("Type", "XObject");
56195    appearanceStreamDict.set("BBox", rect);
56196    appearanceStreamDict.set("Length", appearance.length);
56197    return new StringStream(appearance, appearanceStreamDict);
56198  }
56199  static async createNewAppearanceStream(annotation, xref, params) {
56200    if (annotation.oldAnnotation) {
56201      return null;
56202    }
56203    if (annotation.isSignature) {
56204      return this.#createNewAppearanceStreamForDrawing(annotation, xref);
56205    }
56206    const {
56207      rotation
56208    } = annotation;
56209    const {
56210      imageRef,
56211      width,
56212      height
56213    } = params.image;
56214    const resources = new Dict(xref);
56215    const xobject = new Dict(xref);
56216    resources.set("XObject", xobject);
56217    xobject.set("Im0", imageRef);
56218    const appearance = `q ${width} 0 0 ${height} 0 0 cm /Im0 Do Q`;
56219    const appearanceStreamDict = new Dict(xref);
56220    appearanceStreamDict.set("FormType", 1);
56221    appearanceStreamDict.setIfName("Subtype", "Form");
56222    appearanceStreamDict.setIfName("Type", "XObject");
56223    appearanceStreamDict.set("BBox", [0, 0, width, height]);
56224    appearanceStreamDict.set("Resources", resources);
56225    if (rotation) {
56226      const matrix = getRotationMatrix(rotation, width, height);
56227      appearanceStreamDict.set("Matrix", matrix);
56228    }
56229    return new StringStream(appearance, appearanceStreamDict);
56230  }
56231}
56232class FileAttachmentAnnotation extends MarkupAnnotation {
56233  constructor(params) {
56234    super(params);
56235    const {
56236      annotationGlobals,
56237      dict
56238    } = params;
56239    const fsDict = dict.get("FS");
56240    this.data.hasOwnCanvas = this.data.noRotate;
56241    this.data.noHTML = false;
56242    this.data.fileId = this._getAttachmentId(fsDict, dict.getRaw("FS"), annotationGlobals);
56243    this.data.file = new FileSpec(fsDict).serializable;
56244    const name = dict.get("Name");
56245    this.data.name = name instanceof Name ? stringToPDFString(name.name) : "PushPin";
56246    const fillAlpha = dict.get("ca");
56247    this.data.fillAlpha = typeof fillAlpha === "number" && fillAlpha >= 0 && fillAlpha <= 1 ? fillAlpha : null;
56248  }
56249}
56250class MediaAnnotation extends Annotation {
56251  static #MEDIA_MIME_TYPE_RE = /^(?:video|audio)\//;
56252  constructor(params) {
56253    super(params);
56254    this.data.noHTML = true;
56255  }
56256  _setMediaData({
56257    assetRef,
56258    assetDict,
56259    filename,
56260    contentType
56261  }, annotationGlobals) {
56262    this.data.noHTML = false;
vendor: 6,280 bytes, lines 56263-56477
56263    this.data.richMedia = {
56264      fileId: this._getAttachmentId(assetDict, assetRef, annotationGlobals),
56265      filename,
56266      contentType
56267    };
56268  }
56269  static _getContentType(assetDict, filename, contentType = null) {
56270    if (typeof contentType === "string" && MediaAnnotation.#MEDIA_MIME_TYPE_RE.test(contentType)) {
56271      return contentType;
56272    }
56273    const stream = FileSpec.pickPlatformItem(assetDict.get("EF"));
56274    const subtype = stream instanceof BaseStream ? stream.dict?.get("Subtype") : null;
56275    if (subtype instanceof Name && MediaAnnotation.#MEDIA_MIME_TYPE_RE.test(subtype.name)) {
56276      return subtype.name;
56277    }
56278    const ext = filename.split(".").at(-1)?.toLowerCase();
56279    switch (ext) {
56280      case "mp4":
56281      case "m4v":
56282        return "video/mp4";
56283      case "webm":
56284        return "video/webm";
56285      case "ogv":
56286        return "video/ogg";
56287      case "mov":
56288        return "video/quicktime";
56289      case "mp3":
56290        return "audio/mpeg";
56291      case "m4a":
56292        return "audio/mp4";
56293      case "wav":
56294        return "audio/wav";
56295      case "oga":
56296      case "ogg":
56297        return "audio/ogg";
56298      default:
56299        return null;
56300    }
56301  }
56302}
56303class RichMediaAnnotation extends MediaAnnotation {
56304  constructor(params) {
56305    super(params);
56306    const {
56307      dict,
56308      xref,
56309      annotationGlobals
56310    } = params;
56311    const content = dict.get("RichMediaContent");
56312    if (!(content instanceof Dict)) {
56313      return;
56314    }
56315    const asset = RichMediaAnnotation.#findAsset(content, xref);
56316    if (!asset) {
56317      warn("RichMedia annotation has no playable asset.");
56318      return;
56319    }
56320    this._setMediaData(asset, annotationGlobals);
56321  }
56322  static #findAsset(content, xref) {
56323    const configurations = content.get("Configurations");
56324    if (!Array.isArray(configurations)) {
56325      return null;
56326    }
56327    for (const configRef of configurations) {
56328      const config = xref.fetchIfRef(configRef);
56329      if (!(config instanceof Dict)) {
56330        continue;
56331      }
56332      const instances = config.get("Instances");
56333      if (!Array.isArray(instances)) {
56334        continue;
56335      }
56336      for (const instanceRef of instances) {
56337        const instance = xref.fetchIfRef(instanceRef);
56338        if (!(instance instanceof Dict)) {
56339          continue;
56340        }
56341        if (isName(instance.get("Subtype"), "Flash")) {
56342          continue;
56343        }
56344        const rawAsset = instance.getRaw("Asset");
56345        const asset = xref.fetchIfRef(rawAsset);
56346        if (!(asset instanceof Dict)) {
56347          continue;
56348        }
56349        if (!FileSpec.hasEmbeddedFile(asset)) {
56350          continue;
56351        }
56352        const {
56353          filename
56354        } = new FileSpec(asset).serializable;
56355        const contentType = MediaAnnotation._getContentType(asset, filename);
56356        if (!contentType) {
56357          continue;
56358        }
56359        return {
56360          assetRef: rawAsset instanceof Ref ? rawAsset : null,
56361          assetDict: asset,
56362          filename,
56363          contentType
56364        };
56365      }
56366    }
56367    return null;
56368  }
56369}
56370class ScreenAnnotation extends MediaAnnotation {
56371  constructor(params) {
56372    super(params);
56373    const {
56374      dict,
56375      xref,
56376      annotationGlobals
56377    } = params;
56378    const asset = ScreenAnnotation.#findAsset(dict, xref);
56379    if (!asset) {
56380      return;
56381    }
56382    this._setMediaData(asset, annotationGlobals);
56383  }
56384  static #findAsset(dict, xref) {
56385    for (const action of this.#renditionActions(dict)) {
56386      const asset = this.#findRenditionAsset(action.get("R"), xref, new RefSet());
56387      if (asset) {
56388        return asset;
56389      }
56390    }
56391    return null;
56392  }
56393  static *#renditionActions(dict) {
56394    const action = dict.get("A");
56395    if (action instanceof Dict && isName(action.get("S"), "Rendition") && this.#isPlayAction(action)) {
56396      yield action;
56397    }
56398    const additionalActions = dict.get("AA");
56399    if (additionalActions instanceof Dict) {
56400      for (const [, aa] of additionalActions) {
56401        if (aa instanceof Dict && isName(aa.get("S"), "Rendition") && this.#isPlayAction(aa)) {
56402          yield aa;
56403        }
56404      }
56405    }
56406  }
56407  static #isPlayAction(action) {
56408    const operation = action.get("OP");
56409    return operation === undefined || operation === AnnotationRenditionOperation.PLAY_OR_RESUME || operation === AnnotationRenditionOperation.PLAY;
56410  }
56411  static #findRenditionAsset(rendition, xref, seen) {
56412    if (!(rendition instanceof Dict)) {
56413      return null;
56414    }
56415    const subtype = rendition.get("S");
56416    if (isName(subtype, "MR")) {
56417      return this.#findClipAsset(rendition.get("C"), xref);
56418    }
56419    if (isName(subtype, "SR")) {
56420      const renditions = rendition.get("R");
56421      if (Array.isArray(renditions)) {
56422        for (const ref of renditions) {
56423          if (ref instanceof Ref) {
56424            if (seen.has(ref)) {
56425              continue;
56426            }
56427            seen.put(ref);
56428          }
56429          const asset = this.#findRenditionAsset(xref.fetchIfRef(ref), xref, seen);
56430          if (asset) {
56431            return asset;
56432          }
56433        }
56434      }
56435    }
56436    return null;
56437  }
56438  static #findClipAsset(clip, xref) {
56439    if (!(clip instanceof Dict) || !isName(clip.get("S"), "MCD")) {
56440      return null;
56441    }
56442    const rawData = clip.getRaw("D");
56443    const data = xref.fetchIfRef(rawData);
56444    const contentTypeHint = clip.get("CT");
56445    let explicitType = typeof contentTypeHint === "string" ? contentTypeHint : null;
56446    let assetDict, filename;
56447    if (data instanceof BaseStream) {
56448      assetDict = data.dict;
56449      const name = clip.get("N");
56450      filename = typeof name === "string" ? stringToPDFString(name) : "";
56451      if (!explicitType) {
56452        const subtype = data.dict.get("Subtype");
56453        if (subtype instanceof Name) {
56454          explicitType = subtype.name;
56455        }
56456      }
56457    } else if (data instanceof Dict) {
56458      if (!FileSpec.hasEmbeddedFile(data)) {
56459        return null;
56460      }
56461      assetDict = data;
56462      ({
56463        filename
56464      } = new FileSpec(data).serializable);
56465    } else {
56466      return null;
56467    }
56468    const contentType = MediaAnnotation._getContentType(assetDict, filename, explicitType);
56469    if (!contentType) {
56470      return null;
56471    }
56472    return {
56473      assetRef: rawData instanceof Ref ? rawData : null,
56474      assetDict,
56475      filename,
56476      contentType
56477    }
vendor: 9,137 bytes, lines 56477-56785
56477;
56478  }
56479}
56480
56481;// ./src/core/calculate_md5.js
56482
56483const PARAMS = {
56484  get r() {
56485    return shadow(this, "r", new Uint8Array([7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]));
56486  },
56487  get k() {
56488    return shadow(this, "k", new Int32Array([-680876936, -389564586, 606105819, -1044525330, -176418897, 1200080426, -1473231341, -45705983, 1770035416, -1958414417, -42063, -1990404162, 1804603682, -40341101, -1502002290, 1236535329, -165796510, -1069501632, 643717713, -373897302, -701558691, 38016083, -660478335, -405537848, 568446438, -1019803690, -187363961, 1163531501, -1444681467, -51403784, 1735328473, -1926607734, -378558, -2022574463, 1839030562, -35309556, -1530992060, 1272893353, -155497632, -1094730640, 681279174, -358537222, -722521979, 76029189, -640364487, -421815835, 530742520, -995338651, -198630844, 1126891415, -1416354905, -57434055, 1700485571, -1894986606, -1051523, -2054922799, 1873313359, -30611744, -1560198380, 1309151649, -145523070, -1120210379, 718787259, -343485551]));
56489  }
56490};
56491function calculateMD5(data, offset, length) {
56492  let h0 = 1732584193,
56493    h1 = -271733879,
56494    h2 = -1732584194,
56495    h3 = 271733878;
56496  const paddedLength = length + 72 & ~63;
56497  const padded = new Uint8Array(paddedLength);
56498  let i, j;
56499  for (i = 0; i < length; ++i) {
56500    padded[i] = data[offset++];
56501  }
56502  padded[i++] = 0x80;
56503  const n = paddedLength - 8;
56504  if (i < n) {
56505    i = n;
56506  }
56507  padded[i++] = length << 3 & 0xff;
56508  padded[i++] = length >> 5 & 0xff;
56509  padded[i++] = length >> 13 & 0xff;
56510  padded[i++] = length >> 21 & 0xff;
56511  padded[i++] = length >>> 29 & 0xff;
56512  i += 3;
56513  const w = new Int32Array(16);
56514  const {
56515    k,
56516    r
56517  } = PARAMS;
56518  for (i = 0; i < paddedLength;) {
56519    for (j = 0; j < 16; ++j, i += 4) {
56520      w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
56521    }
56522    let a = h0,
56523      b = h1,
56524      c = h2,
56525      d = h3,
56526      f,
56527      g;
56528    for (j = 0; j < 64; ++j) {
56529      if (j < 16) {
56530        f = b & c | ~b & d;
56531        g = j;
56532      } else if (j < 32) {
56533        f = d & b | ~d & c;
56534        g = 5 * j + 1 & 15;
56535      } else if (j < 48) {
56536        f = b ^ c ^ d;
56537        g = 3 * j + 5 & 15;
56538      } else {
56539        f = c ^ (b | ~d);
56540        g = 7 * j & 15;
56541      }
56542      const tmp = d,
56543        rotateArg = a + f + k[j] + w[g] | 0,
56544        rotate = r[j];
56545      d = c;
56546      c = b;
56547      b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
56548      a = tmp;
56549    }
56550    h0 = h0 + a | 0;
56551    h1 = h1 + b | 0;
56552    h2 = h2 + c | 0;
56553    h3 = h3 + d | 0;
56554  }
56555  return new Uint8Array([h0 & 0xFF, h0 >> 8 & 0xFF, h0 >> 16 & 0xFF, h0 >>> 24 & 0xFF, h1 & 0xFF, h1 >> 8 & 0xFF, h1 >> 16 & 0xFF, h1 >>> 24 & 0xFF, h2 & 0xFF, h2 >> 8 & 0xFF, h2 >> 16 & 0xFF, h2 >>> 24 & 0xFF, h3 & 0xFF, h3 >> 8 & 0xFF, h3 >> 16 & 0xFF, h3 >>> 24 & 0xFF]);
56556}
56557
56558;// ./src/core/dataset_reader.js
56559
56560
56561
56562function decodeString(str) {
56563  try {
56564    return stringToUTF8String(str);
56565  } catch (ex) {
56566    warn(`UTF-8 decoding failed: "${ex}".`);
56567    return str;
56568  }
56569}
56570class DatasetXMLParser extends SimpleXMLParser {
56571  node = null;
56572  onEndElement(name) {
56573    const node = super.onEndElement(name);
56574    if (node && name === "xfa:datasets") {
56575      this.node = node;
56576      throw new Error("Aborting DatasetXMLParser.");
56577    }
56578  }
56579}
56580class DatasetReader {
56581  constructor(data) {
56582    if (data.datasets) {
56583      this.node = new SimpleXMLParser({
56584        hasAttributes: true
56585      }).parseFromString(data.datasets).documentElement;
56586    } else {
56587      const parser = new DatasetXMLParser({
56588        hasAttributes: true
56589      });
56590      try {
56591        parser.parseFromString(data["xdp:xdp"]);
56592      } catch {}
56593      this.node = parser.node;
56594    }
56595  }
56596  getValue(path) {
56597    if (!this.node || !path) {
56598      return "";
56599    }
56600    const node = this.node.searchNode(parseXFAPath(path), 0);
56601    if (!node) {
56602      return "";
56603    }
56604    const first = node.firstChild;
56605    if (first?.nodeName === "value") {
56606      return node.children.map(child => decodeString(child.textContent));
56607    }
56608    return decodeString(node.textContent);
56609  }
56610}
56611
56612;// ./src/core/intersector.js
56613class SingleIntersector {
56614  #annotation;
56615  minX = Infinity;
56616  minY = Infinity;
56617  maxX = -Infinity;
56618  maxY = -Infinity;
56619  #quadPoints = null;
56620  #text = [];
56621  #extraChars = [];
56622  #lastIntersectingQuadIndex = -1;
56623  #canTakeExtraChars = false;
56624  constructor(annotation) {
56625    this.#annotation = annotation;
56626    const quadPoints = annotation.data.quadPoints;
56627    if (!quadPoints) {
56628      [this.minX, this.minY, this.maxX, this.maxY] = annotation.data.rect;
56629      return;
56630    }
56631    for (let i = 0, ii = quadPoints.length; i < ii; i += 8) {
56632      this.minX = Math.min(this.minX, quadPoints[i]);
56633      this.maxX = Math.max(this.maxX, quadPoints[i + 2]);
56634      this.minY = Math.min(this.minY, quadPoints[i + 5]);
56635      this.maxY = Math.max(this.maxY, quadPoints[i + 1]);
56636    }
56637    if (quadPoints.length > 8) {
56638      this.#quadPoints = quadPoints;
56639    }
56640  }
56641  #intersects(x, y) {
56642    if (this.minX >= x || this.maxX <= x || this.minY >= y || this.maxY <= y) {
56643      return false;
56644    }
56645    const quadPoints = this.#quadPoints;
56646    if (!quadPoints) {
56647      return true;
56648    }
56649    if (this.#lastIntersectingQuadIndex >= 0) {
56650      const i = this.#lastIntersectingQuadIndex;
56651      if (!(quadPoints[i] >= x || quadPoints[i + 2] <= x || quadPoints[i + 5] >= y || quadPoints[i + 1] <= y)) {
56652        return true;
56653      }
56654      this.#lastIntersectingQuadIndex = -1;
56655    }
56656    for (let i = 0, ii = quadPoints.length; i < ii; i += 8) {
56657      if (!(quadPoints[i] >= x || quadPoints[i + 2] <= x || quadPoints[i + 5] >= y || quadPoints[i + 1] <= y)) {
56658        this.#lastIntersectingQuadIndex = i;
56659        return true;
56660      }
56661    }
56662    return false;
56663  }
56664  addGlyph(x, y, glyph) {
56665    if (!this.#intersects(x, y)) {
56666      this.disableExtraChars();
56667      return false;
56668    }
56669    if (this.#extraChars.length > 0) {
56670      this.#text.push(this.#extraChars.join(""));
56671      this.#extraChars.length = 0;
56672    }
56673    this.#text.push(glyph);
56674    this.#canTakeExtraChars = true;
56675    return true;
56676  }
56677  addExtraChar(char) {
56678    if (this.#canTakeExtraChars) {
56679      this.#extraChars.push(char);
56680    }
56681  }
56682  disableExtraChars() {
56683    if (!this.#canTakeExtraChars) {
56684      return;
56685    }
56686    this.#canTakeExtraChars = false;
56687    this.#extraChars.length = 0;
56688  }
56689  setText() {
56690    this.#annotation.data.overlaidText = this.#text.join("");
56691  }
56692}
56693const STEPS = 64;
56694class Intersector {
56695  #intersectors = [];
56696  #grid = [];
56697  #minX;
56698  #maxX;
56699  #minY;
56700  #maxY;
56701  #invXRatio;
56702  #invYRatio;
56703  constructor(annotations) {
56704    let minX = Infinity;
56705    let minY = Infinity;
56706    let maxX = -Infinity;
56707    let maxY = -Infinity;
56708    const intersectors = this.#intersectors;
56709    for (const annotation of annotations) {
56710      if (!annotation.data.quadPoints && !annotation.data.rect) {
56711        continue;
56712      }
56713      const intersector = new SingleIntersector(annotation);
56714      intersectors.push(intersector);
56715      minX = Math.min(minX, intersector.minX);
56716      minY = Math.min(minY, intersector.minY);
56717      maxX = Math.max(maxX, intersector.maxX);
56718      maxY = Math.max(maxY, intersector.maxY);
56719    }
56720    this.#minX = minX;
56721    this.#minY = minY;
56722    this.#maxX = maxX;
56723    this.#maxY = maxY;
56724    this.#invXRatio = (STEPS - 1) / (maxX - minX);
56725    this.#invYRatio = (STEPS - 1) / (maxY - minY);
56726    for (const intersector of intersectors) {
56727      const iMin = this.#getGridIndex(intersector.minX, intersector.minY);
56728      const iMax = this.#getGridIndex(intersector.maxX, intersector.maxY);
56729      const w = (iMax - iMin) % STEPS;
56730      const h = Math.floor((iMax - iMin) / STEPS);
56731      for (let i = iMin; i <= iMin + h * STEPS; i += STEPS) {
56732        for (let j = 0; j <= w; j++) {
56733          (this.#grid[i + j] ??= []).push(intersector);
56734        }
56735      }
56736    }
56737  }
56738  #getGridIndex(x, y) {
56739    const i = Math.floor((x - this.#minX) * this.#invXRatio);
56740    const j = Math.floor((y - this.#minY) * this.#invYRatio);
56741    return i + j * STEPS;
56742  }
56743  addGlyph(transform, width, height, glyph) {
56744    const x = transform[4] + width / 2;
56745    const y = transform[5] + height / 2;
56746    if (x < this.#minX || y < this.#minY || x > this.#maxX || y > this.#maxY) {
56747      return;
56748    }
56749    const intersectors = this.#grid[this.#getGridIndex(x, y)];
56750    if (!intersectors) {
56751      return;
56752    }
56753    for (const intersector of intersectors) {
56754      intersector.addGlyph(x, y, glyph);
56755    }
56756  }
56757  addExtraChar(char) {
56758    for (const intersector of this.#intersectors) {
56759      intersector.addExtraChar(char);
56760    }
56761  }
56762  setText() {
56763    for (const intersector of this.#intersectors) {
56764      intersector.setText();
56765    }
56766  }
56767}
56768
56769;// ./src/core/calculate_sha_other.js
56770
56771class Word64 {
56772  constructor(highInteger, lowInteger) {
56773    this.high = highInteger | 0;
56774    this.low = lowInteger | 0;
56775  }
56776  and(word) {
56777    this.high &= word.high;
56778    this.low &= word.low;
56779  }
56780  xor(word) {
56781    this.high ^= word.high;
56782    this.low ^= word.low;
56783  }
56784  shiftRight(places) {
56785    
56785if (places >= 32) {
56786      this.low = this.high >>> places - 32 | 0;
56787      this.high = 0;
56788    } else {
56789      this.low = this.low >>> places | this.high << 32 - places;
56790      this.high = this.high >>> places | 0;
56791    }
vendor: 12,903 bytes, lines 56791-57149
56791
56792  }
56793  rotateRight(places) {
56794    let low, high;
56795    if (places & 32) {
56796      high = this.low;
56797      low = this.high;
56798    } else {
56799      low = this.low;
56800      high = this.high;
56801    }
56802    places &= 31;
56803    this.low = low >>> places | high << 32 - places;
56804    this.high = high >>> places | low << 32 - places;
56805  }
56806  not() {
56807    this.high = ~this.high;
56808    this.low = ~this.low;
56809  }
56810  add(word) {
56811    const lowAdd = (this.low >>> 0) + (word.low >>> 0);
56812    let highAdd = (this.high >>> 0) + (word.high >>> 0);
56813    if (lowAdd > 0xffffffff) {
56814      highAdd += 1;
56815    }
56816    this.low = lowAdd | 0;
56817    this.high = highAdd | 0;
56818  }
56819  copyTo(bytes, offset) {
56820    bytes[offset] = this.high >>> 24 & 0xff;
56821    bytes[offset + 1] = this.high >> 16 & 0xff;
56822    bytes[offset + 2] = this.high >> 8 & 0xff;
56823    bytes[offset + 3] = this.high & 0xff;
56824    bytes[offset + 4] = this.low >>> 24 & 0xff;
56825    bytes[offset + 5] = this.low >> 16 & 0xff;
56826    bytes[offset + 6] = this.low >> 8 & 0xff;
56827    bytes[offset + 7] = this.low & 0xff;
56828  }
56829  assign(word) {
56830    this.high = word.high;
56831    this.low = word.low;
56832  }
56833}
56834const calculate_sha_other_PARAMS = {
56835  get k() {
56836    return shadow(this, "k", [new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd), new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc), new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019), new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118), new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe), new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2), new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1), new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694), new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3), new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65), new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483), new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5), new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210), new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4), new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725), new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70), new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926), new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df), new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8), new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b), new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001), new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30), new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910), new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8), new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53), new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8), new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb), new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3), new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60), new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec), new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9), new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b), new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207), new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178), new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6), new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b), new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493), new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c), new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a), new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)]);
56837  }
56838};
56839function ch(result, x, y, z, tmp) {
56840  result.assign(x);
56841  result.and(y);
56842  tmp.assign(x);
56843  tmp.not();
56844  tmp.and(z);
56845  result.xor(tmp);
56846}
56847function maj(result, x, y, z, tmp) {
56848  result.assign(x);
56849  result.and(y);
56850  tmp.assign(x);
56851  tmp.and(z);
56852  result.xor(tmp);
56853  tmp.assign(y);
56854  tmp.and(z);
56855  result.xor(tmp);
56856}
56857function sigma(result, x, tmp) {
56858  result.assign(x);
56859  result.rotateRight(28);
56860  tmp.assign(x);
56861  tmp.rotateRight(34);
56862  result.xor(tmp);
56863  tmp.assign(x);
56864  tmp.rotateRight(39);
56865  result.xor(tmp);
56866}
56867function sigmaPrime(result, x, tmp) {
56868  result.assign(x);
56869  result.rotateRight(14);
56870  tmp.assign(x);
56871  tmp.rotateRight(18);
56872  result.xor(tmp);
56873  tmp.assign(x);
56874  tmp.rotateRight(41);
56875  result.xor(tmp);
56876}
56877function littleSigma(result, x, tmp) {
56878  result.assign(x);
56879  result.rotateRight(1);
56880  tmp.assign(x);
56881  tmp.rotateRight(8);
56882  result.xor(tmp);
56883  tmp.assign(x);
56884  tmp.shiftRight(7);
56885  result.xor(tmp);
56886}
56887function littleSigmaPrime(result, x, tmp) {
56888  result.assign(x);
56889  result.rotateRight(19);
56890  tmp.assign(x);
56891  tmp.rotateRight(61);
56892  result.xor(tmp);
56893  tmp.assign(x);
56894  tmp.shiftRight(6);
56895  result.xor(tmp);
56896}
56897function calculateSHA512(data, offset, length, mode384 = false) {
56898  let h0, h1, h2, h3, h4, h5, h6, h7;
56899  if (!mode384) {
56900    h0 = new Word64(0x6a09e667, 0xf3bcc908);
56901    h1 = new Word64(0xbb67ae85, 0x84caa73b);
56902    h2 = new Word64(0x3c6ef372, 0xfe94f82b);
56903    h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
56904    h4 = new Word64(0x510e527f, 0xade682d1);
56905    h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
56906    h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
56907    h7 = new Word64(0x5be0cd19, 0x137e2179);
56908  } else {
56909    h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
56910    h1 = new Word64(0x629a292a, 0x367cd507);
56911    h2 = new Word64(0x9159015a, 0x3070dd17);
56912    h3 = new Word64(0x152fecd8, 0xf70e5939);
56913    h4 = new Word64(0x67332667, 0xffc00b31);
56914    h5 = new Word64(0x8eb44a87, 0x68581511);
56915    h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
56916    h7 = new Word64(0x47b5481d, 0xbefa4fa4);
56917  }
56918  const paddedLength = Math.ceil((length + 17) / 128) * 128;
56919  const padded = new Uint8Array(paddedLength);
56920  let i, j;
56921  for (i = 0; i < length; ++i) {
56922    padded[i] = data[offset++];
56923  }
56924  padded[i++] = 0x80;
56925  const n = paddedLength - 16;
56926  if (i < n) {
56927    i = n;
56928  }
56929  i += 11;
56930  padded[i++] = length >>> 29 & 0xff;
56931  padded[i++] = length >> 21 & 0xff;
56932  padded[i++] = length >> 13 & 0xff;
56933  padded[i++] = length >> 5 & 0xff;
56934  padded[i++] = length << 3 & 0xff;
56935  const w = new Array(80);
56936  for (i = 0; i < 80; i++) {
56937    w[i] = new Word64(0, 0);
56938  }
56939  const {
56940    k
56941  } = calculate_sha_other_PARAMS;
56942  let a = new Word64(0, 0),
56943    b = new Word64(0, 0),
56944    c = new Word64(0, 0);
56945  let d = new Word64(0, 0),
56946    e = new Word64(0, 0),
56947    f = new Word64(0, 0);
56948  let g = new Word64(0, 0),
56949    h = new Word64(0, 0);
56950  const t1 = new Word64(0, 0),
56951    t2 = new Word64(0, 0);
56952  const tmp1 = new Word64(0, 0),
56953    tmp2 = new Word64(0, 0);
56954  let tmp3;
56955  for (i = 0; i < paddedLength;) {
56956    for (j = 0; j < 16; ++j) {
56957      w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
56958      w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
56959      i += 8;
56960    }
56961    for (j = 16; j < 80; ++j) {
56962      tmp3 = w[j];
56963      littleSigmaPrime(tmp3, w[j - 2], tmp2);
56964      tmp3.add(w[j - 7]);
56965      littleSigma(tmp1, w[j - 15], tmp2);
56966      tmp3.add(tmp1);
56967      tmp3.add(w[j - 16]);
56968    }
56969    a.assign(h0);
56970    b.assign(h1);
56971    c.assign(h2);
56972    d.assign(h3);
56973    e.assign(h4);
56974    f.assign(h5);
56975    g.assign(h6);
56976    h.assign(h7);
56977    for (j = 0; j < 80; ++j) {
56978      t1.assign(h);
56979      sigmaPrime(tmp1, e, tmp2);
56980      t1.add(tmp1);
56981      ch(tmp1, e, f, g, tmp2);
56982      t1.add(tmp1);
56983      t1.add(k[j]);
56984      t1.add(w[j]);
56985      sigma(t2, a, tmp2);
56986      maj(tmp1, a, b, c, tmp2);
56987      t2.add(tmp1);
56988      tmp3 = h;
56989      h = g;
56990      g = f;
56991      f = e;
56992      d.add(t1);
56993      e = d;
56994      d = c;
56995      c = b;
56996      b = a;
56997      tmp3.assign(t1);
56998      tmp3.add(t2);
56999      a = tmp3;
57000    }
57001    h0.add(a);
57002    h1.add(b);
57003    h2.add(c);
57004    h3.add(d);
57005    h4.add(e);
57006    h5.add(f);
57007    h6.add(g);
57008    h7.add(h);
57009  }
57010  let result;
57011  if (!mode384) {
57012    result = new Uint8Array(64);
57013    h0.copyTo(result, 0);
57014    h1.copyTo(result, 8);
57015    h2.copyTo(result, 16);
57016    h3.copyTo(result, 24);
57017    h4.copyTo(result, 32);
57018    h5.copyTo(result, 40);
57019    h6.copyTo(result, 48);
57020    h7.copyTo(result, 56);
57021  } else {
57022    result = new Uint8Array(48);
57023    h0.copyTo(result, 0);
57024    h1.copyTo(result, 8);
57025    h2.copyTo(result, 16);
57026    h3.copyTo(result, 24);
57027    h4.copyTo(result, 32);
57028    h5.copyTo(result, 40);
57029  }
57030  return result;
57031}
57032function calculateSHA384(data, offset, length) {
57033  return calculateSHA512(data, offset, length, true);
57034}
57035
57036;// ./src/core/calculate_sha256.js
57037
57038const calculate_sha256_PARAMS = {
57039  get k() {
57040    return shadow(this, "k", [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2]);
57041  }
57042};
57043function rotr(x, n) {
57044  return x >>> n | x << 32 - n;
57045}
57046function calculate_sha256_ch(x, y, z) {
57047  return x & y ^ ~x & z;
57048}
57049function calculate_sha256_maj(x, y, z) {
57050  return x & y ^ x & z ^ y & z;
57051}
57052function calculate_sha256_sigma(x) {
57053  return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
57054}
57055function calculate_sha256_sigmaPrime(x) {
57056  return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
57057}
57058function calculate_sha256_littleSigma(x) {
57059  return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
57060}
57061function calculate_sha256_littleSigmaPrime(x) {
57062  return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
57063}
57064function calculateSHA256(data, offset, length) {
57065  let h0 = 0x6a09e667,
57066    h1 = 0xbb67ae85,
57067    h2 = 0x3c6ef372,
57068    h3 = 0xa54ff53a,
57069    h4 = 0x510e527f,
57070    h5 = 0x9b05688c,
57071    h6 = 0x1f83d9ab,
57072    h7 = 0x5be0cd19;
57073  const paddedLength = Math.ceil((length + 9) / 64) * 64;
57074  const padded = new Uint8Array(paddedLength);
57075  let i, j;
57076  for (i = 0; i < length; ++i) {
57077    padded[i] = data[offset++];
57078  }
57079  padded[i++] = 0x80;
57080  const n = paddedLength - 8;
57081  if (i < n) {
57082    i = n;
57083  }
57084  i += 3;
57085  padded[i++] = length >>> 29 & 0xff;
57086  padded[i++] = length >> 21 & 0xff;
57087  padded[i++] = length >> 13 & 0xff;
57088  padded[i++] = length >> 5 & 0xff;
57089  padded[i++] = length << 3 & 0xff;
57090  const w = new Uint32Array(64);
57091  const {
57092    k
57093  } = calculate_sha256_PARAMS;
57094  for (i = 0; i < paddedLength;) {
57095    for (j = 0; j < 16; ++j) {
57096      w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
57097      i += 4;
57098    }
57099    for (j = 16; j < 64; ++j) {
57100      w[j] = calculate_sha256_littleSigmaPrime(w[j - 2]) + w[j - 7] + calculate_sha256_littleSigma(w[j - 15]) + w[j - 16] | 0;
57101    }
57102    let a = h0,
57103      b = h1,
57104      c = h2,
57105      d = h3,
57106      e = h4,
57107      f = h5,
57108      g = h6,
57109      h = h7,
57110      t1,
57111      t2;
57112    for (j = 0; j < 64; ++j) {
57113      t1 = h + calculate_sha256_sigmaPrime(e) + calculate_sha256_ch(e, f, g) + k[j] + w[j];
57114      t2 = calculate_sha256_sigma(a) + calculate_sha256_maj(a, b, c);
57115      h = g;
57116      g = f;
57117      f = e;
57118      e = d + t1 | 0;
57119      d = c;
57120      c = b;
57121      b = a;
57122      a = t1 + t2 | 0;
57123    }
57124    h0 = h0 + a | 0;
57125    h1 = h1 + b | 0;
57126    h2 = h2 + c | 0;
57127    h3 = h3 + d | 0;
57128    h4 = h4 + e | 0;
57129    h5 = h5 + f | 0;
57130    h6 = h6 + g | 0;
57131    h7 = h7 + h | 0;
57132  }
57133  return new Uint8Array([h0 >> 24 & 0xFF, h0 >> 16 & 0xFF, h0 >> 8 & 0xFF, h0 & 0xFF, h1 >> 24 & 0xFF, h1 >> 16 & 0xFF, h1 >> 8 & 0xFF, h1 & 0xFF, h2 >> 24 & 0xFF, h2 >> 16 & 0xFF, h2 >> 8 & 0xFF, h2 & 0xFF, h3 >> 24 & 0xFF, h3 >> 16 & 0xFF, h3 >> 8 & 0xFF, h3 & 0xFF, h4 >> 24 & 0xFF, h4 >> 16 & 0xFF, h4 >> 8 & 0xFF, h4 & 0xFF, h5 >> 24 & 0xFF, h5 >> 16 & 0xFF, h5 >> 8 & 0xFF, h5 & 0xFF, h6 >> 24 & 0xFF, h6 >> 16 & 0xFF, h6 >> 8 & 0xFF, h6 & 0xFF, h7 >> 24 & 0xFF, h7 >> 16 & 0xFF, h7 >> 8 & 0xFF, h7 & 0xFF]);
57134}
57135
57136;// ./src/core/decrypt_stream.js
57137
57138const chunkSize = 512;
57139class DecryptStream extends DecodeStream {
57140  #nextChunk = null;
57141  constructor(str, maybeLength, decrypt) {
57142    super(maybeLength);
57143    this.stream = str;
57144    this.dict = str.dict;
57145    this.decrypt = decrypt;
57146  }
57147  readBlock() {
57148    let chunk = this.#nextChunk ?? this.stream.getBytes(chunkSize);
57149    if (!chunk
57149?.length) {
57150      this.eof = true;
57151      return;
57152    }
57153    this.#nextChunk = this.stream.getBytes(chunkSize);
57154    const hasMoreData = this.#nextChunk?.length > 0;
57155    const decrypt = this.decrypt;
57156    chunk = decrypt(chunk, !hasMoreData);
57157    const bufferLength = this.bufferLength,
57158      newLength = bufferLength + chunk.length,
57159      buffer = this.ensureBuffer(newLength);
57160    buffer.set(chunk, bufferLength);
57161    this.bufferLength = newLength;
57162  }
57163  getOriginalStream() {
57164    return this;
57165  }
57166}
57167
57168;// ./src/core/crypto.js
vendor: 5,193 bytes, lines 57168-57229
57168
57169
57170
57171
57172
57173
57174
57175class ARCFourCipher {
57176  a = 0;
57177  b = 0;
57178  constructor(key) {
57179    const s = new Uint8Array(256);
57180    const keyLength = key.length;
57181    for (let i = 0; i < 256; ++i) {
57182      s[i] = i;
57183    }
57184    for (let i = 0, j = 0; i < 256; ++i) {
57185      const tmp = s[i];
57186      j = j + tmp + key[i % keyLength] & 0xff;
57187      s[i] = s[j];
57188      s[j] = tmp;
57189    }
57190    this.s = s;
57191  }
57192  encryptBlock(data) {
57193    let a = this.a,
57194      b = this.b;
57195    const s = this.s;
57196    const n = data.length;
57197    const output = new Uint8Array(n);
57198    for (let i = 0; i < n; ++i) {
57199      a = a + 1 & 0xff;
57200      const tmp = s[a];
57201      b = b + tmp & 0xff;
57202      const tmp2 = s[b];
57203      s[a] = tmp2;
57204      s[b] = tmp;
57205      output[i] = data[i] ^ s[tmp + tmp2 & 0xff];
57206    }
57207    this.a = a;
57208    this.b = b;
57209    return output;
57210  }
57211  decryptBlock(data) {
57212    return this.encryptBlock(data);
57213  }
57214  encrypt(data) {
57215    return this.encryptBlock(data);
57216  }
57217}
57218class NullCipher {
57219  decryptBlock(data) {
57220    return data;
57221  }
57222  encrypt(data) {
57223    return data;
57224  }
57225}
57226class AESBaseCipher {
57227  _s = new Uint8Array([0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]);
57228  _inv_s = new Uint8Array([0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]);
57229  _mix = new Uint32Array([0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a
vendor: 4,150 bytes, lines 57229-57305
57229750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
57230  _mixCol = new Uint8Array(256).map((_, i) => i < 128 ? i << 1 : i << 1 ^ 0x1b);
57231  constructor() {
57232    this.buffer = new Uint8Array(16);
57233    this.bufferPosition = 0;
57234  }
57235  _expandKey(cipherKey) {
57236    unreachable("Cannot call `_expandKey` on the base class");
57237  }
57238  _decrypt(input, key) {
57239    let t, u, v;
57240    const state = new Uint8Array(16);
57241    state.set(input);
57242    for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
57243      state[j] ^= key[k];
57244    }
57245    for (let i = this._cyclesOfRepetition - 1; i >= 1; --i) {
57246      t = state[13];
57247      state[13] = state[9];
57248      state[9] = state[5];
57249      state[5] = state[1];
57250      state[1] = t;
57251      t = state[14];
57252      u = state[10];
57253      state[14] = state[6];
57254      state[10] = state[2];
57255      state[6] = t;
57256      state[2] = u;
57257      t = state[15];
57258      u = state[11];
57259      v = state[7];
57260      state[15] = state[3];
57261      state[11] = t;
57262      state[7] = u;
57263      state[3] = v;
57264      for (let j = 0; j < 16; ++j) {
57265        state[j] = this._inv_s[state[j]];
57266      }
57267      for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
57268        state[j] ^= key[k];
57269      }
57270      for (let j = 0; j < 16; j += 4) {
57271        const s0 = this._mix[state[j]];
57272        const s1 = this._mix[state[j + 1]];
57273        const s2 = this._mix[state[j + 2]];
57274        const s3 = this._mix[state[j + 3]];
57275        t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
57276        state[j] = t >>> 24 & 0xff;
57277        state[j + 1] = t >> 16 & 0xff;
57278        state[j + 2] = t >> 8 & 0xff;
57279        state[j + 3] = t & 0xff;
57280      }
57281    }
57282    t = state[13];
57283    state[13] = state[9];
57284    state[9] = state[5];
57285    state[5] = state[1];
57286    state[1] = t;
57287    t = state[14];
57288    u = state[10];
57289    state[14] = state[6];
57290    state[10] = state[2];
57291    state[6] = t;
57292    state[2] = u;
57293    t = state[15];
57294    u = state[11];
57295    v = state[7];
57296    state[15] = state[3];
57297    state[11] = t;
57298    state[7] = u;
57299    state[3] = v;
57300    for (let j = 0; j < 16; ++j) {
57301      state[j] = this._inv_s[state[j]];
57302      state[j] ^= key[j];
57303    }
57304    return state;
57305  }
vendor: 20,336 bytes, lines 57306-57884
57306  _encrypt(input, key) {
57307    const s = this._s;
57308    let t, u, v;
57309    const state = new Uint8Array(16);
57310    state.set(input);
57311    for (let j = 0; j < 16; ++j) {
57312      state[j] ^= key[j];
57313    }
57314    for (let i = 1; i < this._cyclesOfRepetition; i++) {
57315      for (let j = 0; j < 16; ++j) {
57316        state[j] = s[state[j]];
57317      }
57318      v = state[1];
57319      state[1] = state[5];
57320      state[5] = state[9];
57321      state[9] = state[13];
57322      state[13] = v;
57323      v = state[2];
57324      u = state[6];
57325      state[2] = state[10];
57326      state[6] = state[14];
57327      state[10] = v;
57328      state[14] = u;
57329      v = state[3];
57330      u = state[7];
57331      t = state[11];
57332      state[3] = state[15];
57333      state[7] = v;
57334      state[11] = u;
57335      state[15] = t;
57336      for (let j = 0; j < 16; j += 4) {
57337        const s0 = state[j];
57338        const s1 = state[j + 1];
57339        const s2 = state[j + 2];
57340        const s3 = state[j + 3];
57341        t = s0 ^ s1 ^ s2 ^ s3;
57342        state[j] ^= t ^ this._mixCol[s0 ^ s1];
57343        state[j + 1] ^= t ^ this._mixCol[s1 ^ s2];
57344        state[j + 2] ^= t ^ this._mixCol[s2 ^ s3];
57345        state[j + 3] ^= t ^ this._mixCol[s3 ^ s0];
57346      }
57347      for (let j = 0, k = i * 16; j < 16; ++j, ++k) {
57348        state[j] ^= key[k];
57349      }
57350    }
57351    for (let j = 0; j < 16; ++j) {
57352      state[j] = s[state[j]];
57353    }
57354    v = state[1];
57355    state[1] = state[5];
57356    state[5] = state[9];
57357    state[9] = state[13];
57358    state[13] = v;
57359    v = state[2];
57360    u = state[6];
57361    state[2] = state[10];
57362    state[6] = state[14];
57363    state[10] = v;
57364    state[14] = u;
57365    v = state[3];
57366    u = state[7];
57367    t = state[11];
57368    state[3] = state[15];
57369    state[7] = v;
57370    state[11] = u;
57371    state[15] = t;
57372    for (let j = 0, k = this._keySize; j < 16; ++j, ++k) {
57373      state[j] ^= key[k];
57374    }
57375    return state;
57376  }
57377  _decryptBlock2(data, finalize) {
57378    const sourceLength = data.length;
57379    let buffer = this.buffer,
57380      bufferLength = this.bufferPosition;
57381    const result = [];
57382    let iv = this.iv;
57383    for (let i = 0; i < sourceLength; ++i) {
57384      buffer[bufferLength] = data[i];
57385      ++bufferLength;
57386      if (bufferLength < 16) {
57387        continue;
57388      }
57389      const plain = this._decrypt(buffer, this._key);
57390      for (let j = 0; j < 16; ++j) {
57391        plain[j] ^= iv[j];
57392      }
57393      iv = buffer;
57394      result.push(plain);
57395      buffer = new Uint8Array(16);
57396      bufferLength = 0;
57397    }
57398    this.buffer = buffer;
57399    this.bufferLength = bufferLength;
57400    this.iv = iv;
57401    if (result.length === 0) {
57402      return new Uint8Array(0);
57403    }
57404    let outputLength = 16 * result.length;
57405    if (finalize) {
57406      const lastBlock = result.at(-1);
57407      let psLen = lastBlock[15];
57408      if (psLen <= 16) {
57409        for (let i = 15, ii = 16 - psLen; i >= ii; --i) {
57410          if (lastBlock[i] !== psLen) {
57411            psLen = 0;
57412            break;
57413          }
57414        }
57415        outputLength -= psLen;
57416        result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
57417      }
57418    }
57419    const output = new Uint8Array(outputLength);
57420    for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
57421      output.set(result[i], j);
57422    }
57423    return output;
57424  }
57425  decryptBlock(data, finalize, iv = null) {
57426    const sourceLength = data.length;
57427    const buffer = this.buffer;
57428    let bufferLength = this.bufferPosition;
57429    if (iv) {
57430      this.iv = iv;
57431    } else {
57432      for (let i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
57433        buffer[bufferLength] = data[i];
57434      }
57435      if (bufferLength < 16) {
57436        this.bufferLength = bufferLength;
57437        return new Uint8Array(0);
57438      }
57439      this.iv = buffer;
57440      data = data.subarray(16);
57441    }
57442    this.buffer = new Uint8Array(16);
57443    this.bufferLength = 0;
57444    this.decryptBlock = this._decryptBlock2;
57445    return this.decryptBlock(data, finalize);
57446  }
57447  encrypt(data, iv) {
57448    const sourceLength = data.length;
57449    let buffer = this.buffer,
57450      bufferLength = this.bufferPosition;
57451    const result = [];
57452    iv ||= new Uint8Array(16);
57453    for (let i = 0; i < sourceLength; ++i) {
57454      buffer[bufferLength] = data[i];
57455      ++bufferLength;
57456      if (bufferLength < 16) {
57457        continue;
57458      }
57459      for (let j = 0; j < 16; ++j) {
57460        buffer[j] ^= iv[j];
57461      }
57462      const cipher = this._encrypt(buffer, this._key);
57463      iv = cipher;
57464      result.push(cipher);
57465      buffer = new Uint8Array(16);
57466      bufferLength = 0;
57467    }
57468    this.buffer = buffer;
57469    this.bufferLength = bufferLength;
57470    this.iv = iv;
57471    if (result.length === 0) {
57472      return new Uint8Array(0);
57473    }
57474    const outputLength = 16 * result.length;
57475    const output = new Uint8Array(outputLength);
57476    for (let i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
57477      output.set(result[i], j);
57478    }
57479    return output;
57480  }
57481}
57482class AES128Cipher extends AESBaseCipher {
57483  _rcon = new Uint8Array([0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d]);
57484  constructor(key) {
57485    super();
57486    this._cyclesOfRepetition = 10;
57487    this._keySize = 160;
57488    this._key = this._expandKey(key);
57489  }
57490  _expandKey(cipherKey) {
57491    const b = 176;
57492    const s = this._s;
57493    const rcon = this._rcon;
57494    const result = new Uint8Array(b);
57495    result.set(cipherKey);
57496    for (let j = 16, i = 1; j < b; ++i) {
57497      let t1 = result[j - 3];
57498      let t2 = result[j - 2];
57499      let t3 = result[j - 1];
57500      let t4 = result[j - 4];
57501      t1 = s[t1];
57502      t2 = s[t2];
57503      t3 = s[t3];
57504      t4 = s[t4];
57505      t1 ^= rcon[i];
57506      for (let n = 0; n < 4; ++n) {
57507        result[j] = t1 ^= result[j - 16];
57508        j++;
57509        result[j] = t2 ^= result[j - 16];
57510        j++;
57511        result[j] = t3 ^= result[j - 16];
57512        j++;
57513        result[j] = t4 ^= result[j - 16];
57514        j++;
57515      }
57516    }
57517    return result;
57518  }
57519}
57520class AES256Cipher extends AESBaseCipher {
57521  constructor(key) {
57522    super();
57523    this._cyclesOfRepetition = 14;
57524    this._keySize = 224;
57525    this._key = this._expandKey(key);
57526  }
57527  _expandKey(cipherKey) {
57528    const b = 240;
57529    const s = this._s;
57530    const result = new Uint8Array(b);
57531    result.set(cipherKey);
57532    let r = 1;
57533    let t1, t2, t3, t4;
57534    for (let j = 32, i = 1; j < b; ++i) {
57535      if (j % 32 === 16) {
57536        t1 = s[t1];
57537        t2 = s[t2];
57538        t3 = s[t3];
57539        t4 = s[t4];
57540      } else if (j % 32 === 0) {
57541        t1 = result[j - 3];
57542        t2 = result[j - 2];
57543        t3 = result[j - 1];
57544        t4 = result[j - 4];
57545        t1 = s[t1];
57546        t2 = s[t2];
57547        t3 = s[t3];
57548        t4 = s[t4];
57549        t1 ^= r;
57550        if ((r <<= 1) >= 256) {
57551          r = (r ^ 0x1b) & 0xff;
57552        }
57553      }
57554      for (let n = 0; n < 4; ++n) {
57555        result[j] = t1 ^= result[j - 32];
57556        j++;
57557        result[j] = t2 ^= result[j - 32];
57558        j++;
57559        result[j] = t3 ^= result[j - 32];
57560        j++;
57561        result[j] = t4 ^= result[j - 32];
57562        j++;
57563      }
57564    }
57565    return result;
57566  }
57567}
57568class PDFBase {
57569  _hash(password, input, userBytes) {
57570    unreachable("Abstract method `_hash` called");
57571  }
57572  checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
57573    const hashData = new Uint8Array(password.length + 56);
57574    hashData.set(password, 0);
57575    hashData.set(ownerValidationSalt, password.length);
57576    hashData.set(userBytes, password.length + ownerValidationSalt.length);
57577    const result = this._hash(password, hashData, userBytes);
57578    return isArrayEqual(result, ownerPassword);
57579  }
57580  checkUserPassword(password, userValidationSalt, userPassword) {
57581    const hashData = new Uint8Array(password.length + 8);
57582    hashData.set(password, 0);
57583    hashData.set(userValidationSalt, password.length);
57584    const result = this._hash(password, hashData, []);
57585    return isArrayEqual(result, userPassword);
57586  }
57587  getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
57588    const hashData = new Uint8Array(password.length + 56);
57589    hashData.set(password, 0);
57590    hashData.set(ownerKeySalt, password.length);
57591    hashData.set(userBytes, password.length + ownerKeySalt.length);
57592    const key = this._hash(password, hashData, userBytes);
57593    const cipher = new AES256Cipher(key);
57594    return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
57595  }
57596  getUserKey(password, userKeySalt, userEncryption) {
57597    const hashData = new Uint8Array(password.length + 8);
57598    hashData.set(password, 0);
57599    hashData.set(userKeySalt, password.length);
57600    const key = this._hash(password, hashData, []);
57601    const cipher = new AES256Cipher(key);
57602    return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
57603  }
57604}
57605class PDF17 extends PDFBase {
57606  _hash(password, input, userBytes) {
57607    return calculateSHA256(input, 0, input.length);
57608  }
57609}
57610class PDF20 extends PDFBase {
57611  _hash(password, input, userBytes) {
57612    let k = calculateSHA256(input, 0, input.length).subarray(0, 32);
57613    let e = [0];
57614    let i = 0;
57615    while (i < 64 || e.at(-1) > i - 32) {
57616      const combinedLength = password.length + k.length + userBytes.length,
57617        combinedArray = new Uint8Array(combinedLength);
57618      let writeOffset = 0;
57619      combinedArray.set(password, writeOffset);
57620      writeOffset += password.length;
57621      combinedArray.set(k, writeOffset);
57622      writeOffset += k.length;
57623      combinedArray.set(userBytes, writeOffset);
57624      const k1 = new Uint8Array(combinedLength * 64);
57625      for (let j = 0, pos = 0; j < 64; j++, pos += combinedLength) {
57626        k1.set(combinedArray, pos);
57627      }
57628      const cipher = new AES128Cipher(k.subarray(0, 16));
57629      e = cipher.encrypt(k1, k.subarray(16, 32));
57630      const remainder = Math.sumPrecise(e.slice(0, 16)) % 3;
57631      if (remainder === 0) {
57632        k = calculateSHA256(e, 0, e.length);
57633      } else if (remainder === 1) {
57634        k = calculateSHA384(e, 0, e.length);
57635      } else if (remainder === 2) {
57636        k = calculateSHA512(e, 0, e.length);
57637      }
57638      i++;
57639    }
57640    return k.subarray(0, 32);
57641  }
57642}
57643class CipherTransform {
57644  #cipherCache = new Map();
57645  embeddedFilterName = null;
57646  constructor(resolveCipher, stringFilterName = null, streamFilterName = null) {
57647    this.resolveCipher = resolveCipher;
57648    this.streamFilterName = streamFilterName;
57649    this.stringFilterName = stringFilterName;
57650  }
57651  #getCipher(filterName = null) {
57652    const key = filterName instanceof Name ? filterName.name : "__default__";
57653    return this.#cipherCache.getOrInsertComputed(key, () => this.resolveCipher(filterName));
57654  }
57655  createStream(stream, length, cryptFilterName = null) {
57656    const defaultFilterName = this.embeddedFilterName && isDict(stream.dict, "EmbeddedFile") ? this.embeddedFilterName : this.streamFilterName;
57657    const Cipher = this.#getCipher(cryptFilterName || defaultFilterName);
57658    const cipher = new Cipher();
57659    return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
57660      return cipher.decryptBlock(data, finalize);
57661    });
57662  }
57663  decryptString(s) {
57664    const Cipher = this.#getCipher(this.stringFilterName);
57665    const cipher = new Cipher();
57666    let data = stringToBytes(s);
57667    data = cipher.decryptBlock(data, true);
57668    return bytesToString(data);
57669  }
57670  encryptString(s) {
57671    const Cipher = this.#getCipher(this.stringFilterName);
57672    const cipher = new Cipher();
57673    if (cipher instanceof AESBaseCipher) {
57674      const strLen = s.length;
57675      const pad = 16 - strLen % 16;
57676      s += String.fromCharCode(pad).repeat(pad);
57677      const iv = new Uint8Array(16);
57678      crypto.getRandomValues(iv);
57679      let data = stringToBytes(s);
57680      data = cipher.encrypt(data, iv);
57681      const buf = new Uint8Array(16 + data.length);
57682      buf.set(iv);
57683      buf.set(data, 16);
57684      return bytesToString(buf);
57685    }
57686    let data = stringToBytes(s);
57687    data = cipher.encrypt(data);
57688    return bytesToString(data);
57689  }
57690}
57691class CipherTransformFactory {
57692  #fileId;
57693  static get _defaultPasswordBytes() {
57694    return shadow(this, "_defaultPasswordBytes", new Uint8Array([0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a]));
57695  }
57696  #createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
57697    if (password) {
57698      const passwordLength = Math.min(127, password.length);
57699      password = password.subarray(0, passwordLength);
57700    } else {
57701      password = [];
57702    }
57703    const pdfAlgorithm = revision === 6 ? new PDF20() : new PDF17();
57704    if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
57705      return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
57706    } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
57707      return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
57708    }
57709    return null;
57710  }
57711  #prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
57712    const hashDataSize = 40 + ownerPassword.length + fileId.length;
57713    const hashData = new Uint8Array(hashDataSize);
57714    let i = 0,
57715      j,
57716      n;
57717    if (password) {
57718      n = Math.min(32, password.length);
57719      for (; i < n; ++i) {
57720        hashData[i] = password[i];
57721      }
57722    }
57723    j = 0;
57724    while (i < 32) {
57725      hashData[i++] = CipherTransformFactory._defaultPasswordBytes[j++];
57726    }
57727    hashData.set(ownerPassword, i);
57728    i += ownerPassword.length;
57729    hashData[i++] = flags & 0xff;
57730    hashData[i++] = flags >> 8 & 0xff;
57731    hashData[i++] = flags >> 16 & 0xff;
57732    hashData[i++] = flags >>> 24 & 0xff;
57733    hashData.set(fileId, i);
57734    i += fileId.length;
57735    if (revision >= 4 && !encryptMetadata) {
57736      hashData.fill(0xff, i, i + 4);
57737      i += 4;
57738    }
57739    let hash = calculateMD5(hashData, 0, i);
57740    const keyLengthInBytes = keyLength >> 3;
57741    if (revision >= 3) {
57742      for (j = 0; j < 50; ++j) {
57743        hash = calculateMD5(hash, 0, keyLengthInBytes);
57744      }
57745    }
57746    const encryptionKey = hash.subarray(0, keyLengthInBytes);
57747    let cipher, checkData;
57748    if (revision >= 3) {
57749      i = 0;
57750      hashData.set(CipherTransformFactory._defaultPasswordBytes, i);
57751      i += 32;
57752      hashData.set(fileId, i);
57753      i += fileId.length;
57754      cipher = new ARCFourCipher(encryptionKey);
57755      checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
57756      n = encryptionKey.length;
57757      const derivedKey = new Uint8Array(n);
57758      for (j = 1; j <= 19; ++j) {
57759        for (let k = 0; k < n; ++k) {
57760          derivedKey[k] = encryptionKey[k] ^ j;
57761        }
57762        cipher = new ARCFourCipher(derivedKey);
57763        checkData = cipher.encryptBlock(checkData);
57764      }
57765    } else {
57766      cipher = new ARCFourCipher(encryptionKey);
57767      checkData = cipher.encryptBlock(CipherTransformFactory._defaultPasswordBytes);
57768    }
57769    return checkData.every((data, k) => userPassword[k] === data) ? encryptionKey : null;
57770  }
57771  #decodeUserPassword(password, ownerPassword, revision, keyLength) {
57772    const hashData = new Uint8Array(32);
57773    let i = 0;
57774    const n = Math.min(32, password.length);
57775    for (; i < n; ++i) {
57776      hashData[i] = password[i];
57777    }
57778    let j = 0;
57779    while (i < 32) {
57780      hashData[i++] = CipherTransformFactory._defaultPasswordBytes[j++];
57781    }
57782    let hash = calculateMD5(hashData, 0, i);
57783    const keyLengthInBytes = keyLength >> 3;
57784    if (revision >= 3) {
57785      for (j = 0; j < 50; ++j) {
57786        hash = calculateMD5(hash, 0, hash.length);
57787      }
57788    }
57789    let cipher, userPassword;
57790    if (revision >= 3) {
57791      userPassword = ownerPassword;
57792      const derivedKey = new Uint8Array(keyLengthInBytes);
57793      for (j = 19; j >= 0; j--) {
57794        for (let k = 0; k < keyLengthInBytes; ++k) {
57795          derivedKey[k] = hash[k] ^ j;
57796        }
57797        cipher = new ARCFourCipher(derivedKey);
57798        userPassword = cipher.encryptBlock(userPassword);
57799      }
57800    } else {
57801      cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
57802      userPassword = cipher.encryptBlock(ownerPassword);
57803    }
57804    return userPassword;
57805  }
57806  #buildObjectKey(num, gen, encryptionKey, isAes = false) {
57807    const n = encryptionKey.length;
57808    const key = new Uint8Array(n + 9);
57809    key.set(encryptionKey);
57810    let i = n;
57811    key[i++] = num & 0xff;
57812    key[i++] = num >> 8 & 0xff;
57813    key[i++] = num >> 16 & 0xff;
57814    key[i++] = gen & 0xff;
57815    key[i++] = gen >> 8 & 0xff;
57816    if (isAes) {
57817      key[i++] = 0x73;
57818      key[i++] = 0x41;
57819      key[i++] = 0x6c;
57820      key[i++] = 0x54;
57821    }
57822    const hash = calculateMD5(key, 0, i);
57823    return hash.subarray(0, Math.min(n + 5, 16));
57824  }
57825  constructor(dict, fileId, password) {
57826    const filter = dict.get("Filter");
57827    if (!isName(filter, "Standard")) {
57828      throw new FormatError("unknown encryption method");
57829    }
57830    this.filterName = filter.name;
57831    this.dict = dict;
57832    this.#fileId = fileId;
57833    const algorithm = dict.get("V");
57834    if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
57835      throw new FormatError("unsupported encryption algorithm");
57836    }
57837    this.algorithm = algorithm;
57838    let keyLength = dict.get("Length");
57839    if (!keyLength) {
57840      if (algorithm <= 3) {
57841        keyLength = 40;
57842      } else {
57843        const cfDict = dict.get("CF");
57844        const streamCryptoName = dict.get("StmF");
57845        if (cfDict instanceof Dict && streamCryptoName instanceof Name) {
57846          cfDict.suppressEncryption = true;
57847          const handlerDict = cfDict.get(streamCryptoName.name);
57848          keyLength = handlerDict?.get("Length") || 128;
57849          if (keyLength < 40) {
57850            keyLength <<= 3;
57851          }
57852        }
57853      }
57854    }
57855    if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
57856      throw new FormatError("invalid key length");
57857    }
57858    let cf = null;
57859    let stmf = Name.get("Identity");
57860    let strf = Name.get("Identity");
57861    let eff = stmf;
57862    if (algorithm >= 4) {
57863      cf = dict.get("CF");
57864      if (cf instanceof Dict) {
57865        cf.suppressEncryption = true;
57866      }
57867      stmf = dict.get("StmF") || Name.get("Identity");
57868      strf = dict.get("StrF") || Name.get("Identity");
57869      eff = dict.get("EFF") || stmf;
57870    }
57871    this.cf = cf;
57872    this.stmf = stmf;
57873    this.strf = strf;
57874    this.eff = eff;
57875    const ownerBytes = stringToBytes(dict.get("O")),
57876      userBytes = stringToBytes(dict.get("U"));
57877    const ownerPassword = ownerBytes.subarray(0, 32);
57878    const userPassword = userBytes.subarray(0, 32);
57879    const flags = dict.get("P");
57880    const revision = dict.get("R");
57881    const encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get("EncryptMetadata") !== false;
57882    this.encryptMetadata = encryptMetadata;
57883    const fileIdBytes = stringToBytes(fileId);
57884    let passwordBytes
57884;
57885    if (password) {
57886      if (revision === 6) {
57887        try {
57888          password = utf8StringToString(password);
57889        } catch {
57890          warn("CipherTransformFactory: Unable to convert UTF8 encoded password.");
57891        }
57892      }
57893      passwordBytes = stringToBytes(password);
57894    }
57895    let encryptionKey;
57896    if (algorithm !== 5) {
57897      encryptionKey = this.#prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
57898    } else {
57899      const ownerValidationSalt = ownerBytes.subarray(32, 40);
57900      const ownerKeySalt = ownerBytes.subarray(40, 48);
57901      const uBytes = userBytes.subarray(0, 48);
57902      const userValidationSalt = userBytes.subarray(32, 40);
57903      const userKeySalt = userBytes.subarray(40, 48);
57904      const ownerEncryption = stringToBytes(dict.get("OE"));
57905      const userEncryption = stringToBytes(dict.get("UE"));
57906      const perms = stringToBytes(dict.get("Perms"));
57907      encryptionKey = this.#createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
57908    }
57909    if (!encryptionKey) {
57910      if (!password) {
57911        if (this.algorithm >= 4 && isName(this.stmf, "Identity") && isName(this.strf, "Identity")) {
57912          const effCF = this.cf?.get(this.eff.name);
57913          const authEvent = effCF?.get("AuthEvent");
57914          if (isName(authEvent, "EFOpen")) {
57915            this.encryptionKey = null;
57916            return;
57917          }
57918        }
57919        throw new PasswordException("No password given", PasswordResponses.NEED_PASSWORD);
57920      }
57921      const decodedPassword = this.#decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
57922      encryptionKey = this.#prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
57923    }
57924    if (!encryptionKey) {
57925      throw new PasswordException("Incorrect Password", PasswordResponses.INCORRECT_PASSWORD);
57926    }
57927    if (algorithm === 4 && encryptionKey.length < 16) {
57928      this.encryptionKey = new Uint8Array(16);
57929      this.encryptionKey.set(encryptionKey);
57930    } else {
57931      this.encryptionKey = encryptionKey;
57932    }
57933  }
57934  setPassword(password) {
57935    const transform = new CipherTransformFactory(this.dict, this.#fileId, password);
57936    this.encryptionKey = transform.encryptionKey;
57937  }
57938  createCipherTransform(num, gen) {
57939    if (this.algorithm === 4 || this.algorithm === 5) {
57940      const resolveCipher = filterName => {
57941        if (!(filterName instanceof Name)) {
57942          throw new FormatError("Invalid crypt filter name.");
57943        }
57944        const cryptFilter = this.cf.get(filterName.name);
57945        const cfm = cryptFilter?.get("CFM");
57946        if (!cfm || cfm.name === "None") {
57947          return NullCipher;
57948        }
57949        if (!this.encryptionKey) {
57950          throw new PasswordException("No password given", PasswordResponses.NEED_PASSWORD);
57951        }
57952        if (this.algorithm === 5) {
57953          return AES256Cipher.bind(null, this.encryptionKey);
57954        }
57955        if (cfm.name === "V2") {
57956          return ARCFourCipher.bind(null, this.#buildObjectKey(num, gen, this.encryptionKey, false));
57957        }
57958        if (cfm.name === "AESV2") {
57959          return AES128Cipher.bind(null, this.#buildObjectKey(num, gen, this.encryptionKey, true));
57960        }
57961        if (cfm.name === "AESV3") {
57962          return AES256Cipher.bind(null, this.encryptionKey);
57963        }
57964        throw new FormatError("Unknown crypto method");
57965      };
57966      const transform = new CipherTransform(resolveCipher, this.strf, this.stmf);
57967      transform.embeddedFilterName = this.eff;
57968      return transform;
57969    }
57970    const resolveCipher = () => ARCFourCipher.bind(null, this.#buildObjectKey(num, gen, this.encryptionKey, false));
57971    return new CipherTransform(resolveCipher);
57972  }
57973}
57974
57975;// ./src/core/xref.js
vendor: 15,400 bytes, lines 57975-58461
57975
57976
57977
57978
57979
57980
57981
57982class XRef {
57983  constructor(stream, pdfManager) {
57984    this.stream = stream;
57985    this.pdfManager = pdfManager;
57986    this.entries = [];
57987    this._xrefStms = new Set();
57988    this._cacheMap = new Map();
57989    this._pendingRefs = new RefSet();
57990    this._newPersistentRefNum = null;
57991    this._newTemporaryRefNum = null;
57992    this._persistentRefsCache = null;
57993  }
57994  getNewPersistentRef(obj) {
57995    if (this._newPersistentRefNum === null) {
57996      this._newPersistentRefNum = this.entries.length || 1;
57997    }
57998    const num = this._newPersistentRefNum++;
57999    this._cacheMap.set(num, obj);
58000    return Ref.get(num, 0);
58001  }
58002  getNewTemporaryRef() {
58003    if (this._newTemporaryRefNum === null) {
58004      this._newTemporaryRefNum = this.entries.length || 1;
58005      if (this._newPersistentRefNum) {
58006        this._persistentRefsCache = new Map();
58007        for (let i = this._newTemporaryRefNum; i < this._newPersistentRefNum; i++) {
58008          this._persistentRefsCache.set(i, this._cacheMap.get(i));
58009          this._cacheMap.delete(i);
58010        }
58011      }
58012    }
58013    return Ref.get(this._newTemporaryRefNum++, 0);
58014  }
58015  resetNewTemporaryRef() {
58016    this._newTemporaryRefNum = null;
58017    if (this._persistentRefsCache) {
58018      for (const [num, obj] of this._persistentRefsCache) {
58019        this._cacheMap.set(num, obj);
58020      }
58021    }
58022    this._persistentRefsCache = null;
58023  }
58024  setStartXRef(startXRef) {
58025    this.startXRefQueue = [startXRef];
58026  }
58027  parse(recoveryMode = false) {
58028    let trailerDict;
58029    if (!recoveryMode) {
58030      trailerDict = this.readXRef();
58031    } else {
58032      warn("Indexing all PDF objects");
58033      trailerDict = this.indexObjects();
58034    }
58035    trailerDict.assignXref(this);
58036    this.trailer = trailerDict;
58037    let encrypt;
58038    try {
58039      encrypt = trailerDict.get("Encrypt");
58040    } catch (ex) {
58041      if (ex instanceof MissingDataException) {
58042        throw ex;
58043      }
58044      warn(`XRef.parse - Invalid "Encrypt" reference: "${ex}".`);
58045    }
58046    if (encrypt instanceof Dict) {
58047      const ids = trailerDict.get("ID");
58048      const fileId = ids?.length ? ids[0] : "";
58049      encrypt.suppressEncryption = true;
58050      this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
58051    }
58052    let root;
58053    try {
58054      root = trailerDict.get("Root");
58055    } catch (ex) {
58056      if (ex instanceof MissingDataException) {
58057        throw ex;
58058      }
58059      warn(`XRef.parse - Invalid "Root" reference: "${ex}".`);
58060    }
58061    if (root instanceof Dict) {
58062      try {
58063        const pages = root.get("Pages");
58064        if (pages instanceof Dict) {
58065          this.root = root;
58066          return;
58067        }
58068      } catch (ex) {
58069        if (ex instanceof MissingDataException) {
58070          throw ex;
58071        }
58072        warn(`XRef.parse - Invalid "Pages" reference: "${ex}".`);
58073      }
58074    }
58075    if (!recoveryMode) {
58076      throw new XRefParseException();
58077    }
58078    throw new InvalidPDFException("Invalid Root reference.");
58079  }
58080  processXRefTable(parser) {
58081    if (!("tableState" in this)) {
58082      this.tableState = {
58083        entryNum: 0,
58084        streamPos: parser.lexer.stream.pos,
58085        parserBuf1: parser.buf1,
58086        parserBuf2: parser.buf2
58087      };
58088    }
58089    const obj = this.readXRefTable(parser);
58090    if (!isCmd(obj, "trailer")) {
58091      throw new FormatError("Invalid XRef table: could not find trailer dictionary");
58092    }
58093    let dict = parser.getObj();
58094    if (!(dict instanceof Dict) && dict.dict) {
58095      dict = dict.dict;
58096    }
58097    if (!(dict instanceof Dict)) {
58098      throw new FormatError("Invalid XRef table: could not parse trailer dictionary");
58099    }
58100    delete this.tableState;
58101    return dict;
58102  }
58103  readXRefTable(parser) {
58104    const stream = parser.lexer.stream;
58105    const tableState = this.tableState;
58106    stream.pos = tableState.streamPos;
58107    parser.buf1 = tableState.parserBuf1;
58108    parser.buf2 = tableState.parserBuf2;
58109    let obj;
58110    while (true) {
58111      if (!("firstEntryNum" in tableState) || !("entryCount" in tableState)) {
58112        if (isCmd(obj = parser.getObj(), "trailer")) {
58113          break;
58114        }
58115        tableState.firstEntryNum = obj;
58116        tableState.entryCount = parser.getObj();
58117      }
58118      let first = tableState.firstEntryNum;
58119      const count = tableState.entryCount;
58120      if (!Number.isInteger(first) || !Number.isInteger(count)) {
58121        throw new FormatError("Invalid XRef table: wrong types in subsection header");
58122      }
58123      for (let i = tableState.entryNum; i < count; i++) {
58124        tableState.streamPos = stream.pos;
58125        tableState.entryNum = i;
58126        tableState.parserBuf1 = parser.buf1;
58127        tableState.parserBuf2 = parser.buf2;
58128        const entry = {};
58129        entry.offset = parser.getObj();
58130        entry.gen = parser.getObj();
58131        const type = parser.getObj();
58132        if (type instanceof Cmd) {
58133          switch (type.cmd) {
58134            case "f":
58135              entry.free = true;
58136              break;
58137            case "n":
58138              entry.uncompressed = true;
58139              break;
58140          }
58141        }
58142        if (!Number.isInteger(entry.offset) || !Number.isInteger(entry.gen) || !(entry.free || entry.uncompressed)) {
58143          throw new FormatError(`Invalid entry in XRef subsection: ${first}, ${count}`);
58144        }
58145        if (i === 0 && entry.free && first === 1) {
58146          first = 0;
58147        }
58148        if (!this.entries[i + first]) {
58149          this.entries[i + first] = entry;
58150        }
58151      }
58152      tableState.entryNum = 0;
58153      tableState.streamPos = stream.pos;
58154      tableState.parserBuf1 = parser.buf1;
58155      tableState.parserBuf2 = parser.buf2;
58156      delete tableState.firstEntryNum;
58157      delete tableState.entryCount;
58158    }
58159    if (this.entries[0] && !this.entries[0].free) {
58160      throw new FormatError("Invalid XRef table: unexpected first object");
58161    }
58162    return obj;
58163  }
58164  processXRefStream(stream) {
58165    if (!("streamState" in this)) {
58166      const {
58167        dict,
58168        pos
58169      } = stream;
58170      const byteWidths = dict.get("W");
58171      const range = dict.get("Index") || [0, dict.get("Size")];
58172      this.streamState = {
58173        entryRanges: range,
58174        byteWidths,
58175        entryNum: 0,
58176        streamPos: pos
58177      };
58178    }
58179    this.readXRefStream(stream);
58180    delete this.streamState;
58181    return stream.dict;
58182  }
58183  readXRefStream(stream) {
58184    const streamState = this.streamState;
58185    stream.pos = streamState.streamPos;
58186    const [typeFieldWidth, offsetFieldWidth, generationFieldWidth] = streamState.byteWidths;
58187    const entryRanges = streamState.entryRanges;
58188    while (entryRanges.length > 0) {
58189      const [first, n] = entryRanges;
58190      if (!Number.isInteger(first) || !Number.isInteger(n)) {
58191        throw new FormatError(`Invalid XRef range fields: ${first}, ${n}`);
58192      }
58193      if (!Number.isInteger(typeFieldWidth) || !Number.isInteger(offsetFieldWidth) || !Number.isInteger(generationFieldWidth)) {
58194        throw new FormatError(`Invalid XRef entry fields length: ${first}, ${n}`);
58195      }
58196      for (let i = streamState.entryNum; i < n; ++i) {
58197        streamState.entryNum = i;
58198        streamState.streamPos = stream.pos;
58199        let type = 0,
58200          offset = 0,
58201          generation = 0;
58202        for (let j = 0; j < typeFieldWidth; ++j) {
58203          const typeByte = stream.getByte();
58204          if (typeByte === -1) {
58205            throw new FormatError("Invalid XRef byteWidths 'type'.");
58206          }
58207          type = type << 8 | typeByte;
58208        }
58209        if (typeFieldWidth === 0) {
58210          type = 1;
58211        }
58212        for (let j = 0; j < offsetFieldWidth; ++j) {
58213          const offsetByte = stream.getByte();
58214          if (offsetByte === -1) {
58215            throw new FormatError("Invalid XRef byteWidths 'offset'.");
58216          }
58217          offset = offset << 8 | offsetByte;
58218        }
58219        for (let j = 0; j < generationFieldWidth; ++j) {
58220          const generationByte = stream.getByte();
58221          if (generationByte === -1) {
58222            throw new FormatError("Invalid XRef byteWidths 'generation'.");
58223          }
58224          generation = generation << 8 | generationByte;
58225        }
58226        const entry = {};
58227        entry.offset = offset;
58228        entry.gen = generation;
58229        switch (type) {
58230          case 0:
58231            entry.free = true;
58232            break;
58233          case 1:
58234            entry.uncompressed = true;
58235            break;
58236          case 2:
58237            break;
58238          default:
58239            throw new FormatError(`Invalid XRef entry type: ${type}`);
58240        }
58241        if (!this.entries[first + i]) {
58242          this.entries[first + i] = entry;
58243        }
58244      }
58245      streamState.entryNum = 0;
58246      streamState.streamPos = stream.pos;
58247      entryRanges.splice(0, 2);
58248    }
58249  }
58250  indexObjects() {
58251    const TAB = 0x9,
58252      LF = 0xa,
58253      CR = 0xd,
58254      SPACE = 0x20;
58255    const PERCENT = 0x25,
58256      LT = 0x3c;
58257    function readToken(data, offset) {
58258      let token = "",
58259        ch = data[offset];
58260      while (ch !== LF && ch !== CR && ch !== LT) {
58261        if (++offset >= data.length) {
58262          break;
58263        }
58264        token += String.fromCharCode(ch);
58265        ch = data[offset];
58266      }
58267      return token;
58268    }
58269    function skipUntil(data, offset, what) {
58270      const length = what.length,
58271        dataLength = data.length;
58272      let skipped = 0;
58273      while (offset < dataLength) {
58274        let i = 0;
58275        while (i < length && data[offset + i] === what[i]) {
58276          ++i;
58277        }
58278        if (i >= length) {
58279          break;
58280        }
58281        offset++;
58282        skipped++;
58283      }
58284      return skipped;
58285    }
58286    const gEndobjRegExp = /\b(endobj|\d+\s+\d+\s+obj|xref|trailer\s*<<)\b/g;
58287    const gStartxrefRegExp = /\b(startxref|\d+\s+\d+\s+obj)\b/g;
58288    const objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
58289    const trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]);
58290    const startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114, 101, 102]);
58291    const xrefBytes = new Uint8Array([47, 88, 82, 101, 102]);
58292    this.entries.length = 0;
58293    this._cacheMap.clear();
58294    const stream = this.stream;
58295    stream.pos = 0;
58296    const buffer = stream.getBytes(),
58297      bufferStr = bytesToString(buffer),
58298      length = buffer.length;
58299    let position = stream.start;
58300    const trailers = [],
58301      xrefStms = [];
58302    while (position < length) {
58303      let ch = buffer[position];
58304      if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
58305        ++position;
58306        continue;
58307      }
58308      if (ch === PERCENT) {
58309        do {
58310          ++position;
58311          if (position >= length) {
58312            break;
58313          }
58314          ch = buffer[position];
58315        } while (ch !== LF && ch !== CR);
58316        continue;
58317      }
58318      const token = readToken(buffer, position);
58319      let m;
58320      if (token.startsWith("xref") && (token.length === 4 || /\s/.test(token[4]))) {
58321        position += skipUntil(buffer, position, trailerBytes);
58322        trailers.push(position);
58323        position += skipUntil(buffer, position, startxrefBytes);
58324      } else if (m = objRegExp.exec(token)) {
58325        const num = m[1] | 0,
58326          gen = m[2] | 0;
58327        const startPos = position + token.length;
58328        let contentLength,
58329          updateEntries = false;
58330        if (!this.entries[num]) {
58331          updateEntries = true;
58332        } else if (this.entries[num].gen === gen) {
58333          try {
58334            const parser = new Parser({
58335              lexer: new Lexer(stream.makeSubStream(startPos))
58336            });
58337            parser.getObj();
58338            updateEntries = true;
58339          } catch (ex) {
58340            if (ex instanceof ParserEOFException) {
58341              warn(`indexObjects -- checking object (${token}): "${ex}".`);
58342            } else {
58343              updateEntries = true;
58344            }
58345          }
58346        }
58347        if (updateEntries) {
58348          this.entries[num] = {
58349            offset: position - stream.start,
58350            gen,
58351            uncompressed: true
58352          };
58353        }
58354        gEndobjRegExp.lastIndex = startPos;
58355        const match = gEndobjRegExp.exec(bufferStr);
58356        if (match) {
58357          const endPos = gEndobjRegExp.lastIndex + 1;
58358          contentLength = endPos - position;
58359          if (match[1] !== "endobj") {
58360            warn(`indexObjects: Found "${match[1]}" inside of another "obj", ` + 'caused by missing "endobj" -- trying to recover.');
58361            contentLength -= match[1].length + 1;
58362          }
58363        } else {
58364          contentLength = length - position;
58365        }
58366        const content = buffer.subarray(position, position + contentLength);
58367        const xrefTagOffset = skipUntil(content, 0, xrefBytes);
58368        if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
58369          xrefStms.push(position - stream.start);
58370          this._xrefStms.add(position - stream.start);
58371        }
58372        position += contentLength;
58373      } else if (token.startsWith("trailer") && (token.length === 7 || /\s/.test(token[7]))) {
58374        trailers.push(position);
58375        const startPos = position + token.length;
58376        let contentLength;
58377        gStartxrefRegExp.lastIndex = startPos;
58378        const match = gStartxrefRegExp.exec(bufferStr);
58379        if (match) {
58380          const endPos = gStartxrefRegExp.lastIndex + 1;
58381          contentLength = endPos - position;
58382          if (match[1] !== "startxref") {
58383            warn(`indexObjects: Found "${match[1]}" after "trailer", ` + 'caused by missing "startxref" -- trying to recover.');
58384            contentLength -= match[1].length + 1;
58385          }
58386        } else {
58387          contentLength = length - position;
58388        }
58389        position += contentLength;
58390      } else {
58391        position += token.length + 1;
58392      }
58393    }
58394    for (const xrefStm of xrefStms) {
58395      this.startXRefQueue.push(xrefStm);
58396      this.readXRef(true);
58397    }
58398    const trailerDicts = [];
58399    let isEncrypted = false;
58400    for (const trailer of trailers) {
58401      stream.pos = trailer;
58402      const parser = new Parser({
58403        lexer: new Lexer(stream),
58404        xref: this,
58405        allowStreams: true,
58406        recoveryMode: true
58407      });
58408      const obj = parser.getObj();
58409      if (!isCmd(obj, "trailer")) {
58410        continue;
58411      }
58412      const dict = parser.getObj();
58413      if (!(dict instanceof Dict)) {
58414        continue;
58415      }
58416      trailerDicts.push(dict);
58417      if (dict.has("Encrypt")) {
58418        isEncrypted = true;
58419      }
58420    }
58421    let trailerDict, trailerError;
58422    for (const dict of [...trailerDicts, "genFallback", ...trailerDicts]) {
58423      if (dict === "genFallback") {
58424        if (!trailerError) {
58425          break;
58426        }
58427        this._generationFallback = true;
58428        continue;
58429      }
58430      let validPagesDict = false;
58431      try {
58432        const rootDict = dict.get("Root");
58433        if (!(rootDict instanceof Dict)) {
58434          continue;
58435        }
58436        const pagesDict = rootDict.get("Pages");
58437        if (!(pagesDict instanceof Dict)) {
58438          continue;
58439        }
58440        const pagesCount = pagesDict.get("Count");
58441        if (Number.isInteger(pagesCount)) {
58442          validPagesDict = true;
58443        }
58444      } catch (ex) {
58445        trailerError = ex;
58446        continue;
58447      }
58448      if (validPagesDict && (!isEncrypted || dict.has("Encrypt")) && dict.has("ID")) {
58449        return dict;
58450      }
58451      trailerDict = dict;
58452    }
58453    if (trailerDict) {
58454      return trailerDict;
58455    }
58456    if (this.topDict) {
58457      return this.topDict;
58458    }
58459    if (!trailerDicts.length) {
58460      for (const num in this.entries) {
58461        
58461const entry = this.entries[num];
58462        if (!entry) {
58463          continue;
58464        }
58465        const ref = Ref.get(parseInt(num, 10
vendor: 8,213 bytes, lines 58465-58744
58465), entry.gen);
58466        let obj;
58467        try {
58468          obj = this.fetch(ref);
58469        } catch {
58470          continue;
58471        }
58472        if (obj instanceof BaseStream) {
58473          obj = obj.dict;
58474        }
58475        if (obj instanceof Dict && obj.has("Root")) {
58476          return obj;
58477        }
58478      }
58479    }
58480    throw new InvalidPDFException("Invalid PDF structure.");
58481  }
58482  readXRef(recoveryMode = false) {
58483    const stream = this.stream;
58484    const startXRefParsedCache = new Set();
58485    while (this.startXRefQueue.length) {
58486      try {
58487        const startXRef = this.startXRefQueue[0];
58488        if (startXRefParsedCache.has(startXRef)) {
58489          warn("readXRef - skipping XRef table since it was already parsed.");
58490          this.startXRefQueue.shift();
58491          continue;
58492        }
58493        startXRefParsedCache.add(startXRef);
58494        stream.pos = startXRef + stream.start;
58495        const parser = new Parser({
58496          lexer: new Lexer(stream),
58497          xref: this,
58498          allowStreams: true
58499        });
58500        let obj = parser.getObj();
58501        let dict;
58502        if (isCmd(obj, "xref")) {
58503          dict = this.processXRefTable(parser);
58504          if (!this.topDict) {
58505            this.topDict = dict;
58506          }
58507          obj = dict.get("XRefStm");
58508          if (Number.isInteger(obj) && !this._xrefStms.has(obj)) {
58509            this._xrefStms.add(obj);
58510            this.startXRefQueue.push(obj);
58511          }
58512        } else if (Number.isInteger(obj)) {
58513          if (!Number.isInteger(parser.getObj()) || !isCmd(parser.getObj(), "obj") || !((obj = parser.getObj()) instanceof BaseStream)) {
58514            throw new FormatError("Invalid XRef stream");
58515          }
58516          dict = this.processXRefStream(obj);
58517          if (!this.topDict) {
58518            this.topDict = dict;
58519          }
58520          if (!dict) {
58521            throw new FormatError("Failed to read XRef stream");
58522          }
58523        } else {
58524          throw new FormatError("Invalid XRef stream header");
58525        }
58526        obj = dict.get("Prev");
58527        if (Number.isInteger(obj)) {
58528          this.startXRefQueue.push(obj);
58529        } else if (obj instanceof Ref) {
58530          this.startXRefQueue.push(obj.num);
58531        }
58532      } catch (e) {
58533        if (e instanceof MissingDataException) {
58534          throw e;
58535        }
58536        info("(while reading XRef): " + e);
58537      }
58538      this.startXRefQueue.shift();
58539    }
58540    if (this.topDict) {
58541      return this.topDict;
58542    }
58543    if (recoveryMode) {
58544      return undefined;
58545    }
58546    throw new XRefParseException();
58547  }
58548  getEntry(i) {
58549    const xrefEntry = this.entries[i];
58550    if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
58551      return xrefEntry;
58552    }
58553    return null;
58554  }
58555  fetchIfRef(obj, suppressEncryption = false) {
58556    if (obj instanceof Ref) {
58557      return this.fetch(obj, suppressEncryption);
58558    }
58559    return obj;
58560  }
58561  fetch(ref, suppressEncryption = false) {
58562    if (!(ref instanceof Ref)) {
58563      throw new Error("ref object is not a reference");
58564    }
58565    const num = ref.num;
58566    const cacheEntry = this._cacheMap.get(num);
58567    if (cacheEntry !== undefined) {
58568      if (cacheEntry instanceof Dict && !cacheEntry.objId) {
58569        cacheEntry.objId = ref.toString();
58570      }
58571      return cacheEntry;
58572    }
58573    let xrefEntry = this.getEntry(num);
58574    if (xrefEntry === null) {
58575      return xrefEntry;
58576    }
58577    if (this._pendingRefs.has(ref)) {
58578      this._pendingRefs.remove(ref);
58579      warn(`Ignoring circular reference: ${ref}.`);
58580      return CIRCULAR_REF;
58581    }
58582    this._pendingRefs.put(ref);
58583    try {
58584      xrefEntry = xrefEntry.uncompressed ? this.fetchUncompressed(ref, xrefEntry, suppressEncryption) : this.fetchCompressed(ref, xrefEntry, suppressEncryption);
58585      this._pendingRefs.remove(ref);
58586    } catch (ex) {
58587      this._pendingRefs.remove(ref);
58588      throw ex;
58589    }
58590    if (xrefEntry instanceof Dict) {
58591      xrefEntry.objId = ref.toString();
58592    } else if (xrefEntry instanceof BaseStream) {
58593      xrefEntry.dict.objId = ref.toString();
58594    }
58595    return xrefEntry;
58596  }
58597  fetchUncompressed(ref, xrefEntry, suppressEncryption = false) {
58598    const gen = ref.gen;
58599    let num = ref.num;
58600    if (xrefEntry.gen !== gen) {
58601      const msg = `Inconsistent generation in XRef: ${ref}`;
58602      if (this._generationFallback && xrefEntry.gen < gen) {
58603        warn(msg);
58604        return this.fetchUncompressed(Ref.get(num, xrefEntry.gen), xrefEntry, suppressEncryption);
58605      }
58606      throw new XRefEntryException(msg);
58607    }
58608    const stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
58609    const parser = new Parser({
58610      lexer: new Lexer(stream),
58611      xref: this,
58612      allowStreams: true
58613    });
58614    const obj1 = parser.getObj();
58615    const obj2 = parser.getObj();
58616    const obj3 = parser.getObj();
58617    if (obj1 !== num || obj2 !== gen || !(obj3 instanceof Cmd)) {
58618      throw new XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
58619    }
58620    if (obj3.cmd !== "obj") {
58621      if (obj3.cmd.startsWith("obj")) {
58622        num = parseInt(obj3.cmd.substring(3), 10);
58623        if (!Number.isNaN(num)) {
58624          return num;
58625        }
58626      }
58627      throw new XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
58628    }
58629    xrefEntry = this.encrypt && !suppressEncryption ? parser.getObj(this.encrypt.createCipherTransform(num, gen)) : parser.getObj();
58630    if (!(xrefEntry instanceof BaseStream)) {
58631      this._cacheMap.set(num, xrefEntry);
58632    }
58633    return xrefEntry;
58634  }
58635  fetchCompressed(ref, xrefEntry, suppressEncryption = false) {
58636    const tableOffset = xrefEntry.offset;
58637    const stream = this.fetch(Ref.get(tableOffset, 0));
58638    if (!(stream instanceof BaseStream)) {
58639      throw new FormatError("bad ObjStm stream");
58640    }
58641    const first = stream.dict.get("First");
58642    const n = stream.dict.get("N");
58643    if (!Number.isInteger(first) || !Number.isInteger(n)) {
58644      throw new FormatError("invalid first and n parameters for ObjStm stream");
58645    }
58646    let parser = new Parser({
58647      lexer: new Lexer(stream),
58648      xref: this,
58649      allowStreams: true
58650    });
58651    const nums = new Array(n);
58652    const offsets = new Array(n);
58653    for (let i = 0; i < n; ++i) {
58654      const num = parser.getObj();
58655      if (!Number.isInteger(num)) {
58656        throw new FormatError(`invalid object number in the ObjStm stream: ${num}`);
58657      }
58658      const offset = parser.getObj();
58659      if (!Number.isInteger(offset)) {
58660        throw new FormatError(`invalid object offset in the ObjStm stream: ${offset}`);
58661      }
58662      nums[i] = num;
58663      const entry = this.getEntry(num);
58664      if (entry?.offset === tableOffset && entry.gen !== i) {
58665        entry.gen = i;
58666      }
58667      offsets[i] = offset;
58668    }
58669    const start = (stream.start || 0) + first;
58670    const entries = new Array(n);
58671    for (let i = 0; i < n; ++i) {
58672      const length = i < n - 1 ? offsets[i + 1] - offsets[i] : undefined;
58673      if (length < 0) {
58674        throw new FormatError("Invalid offset in the ObjStm stream.");
58675      }
58676      parser = new Parser({
58677        lexer: new Lexer(stream.makeSubStream(start + offsets[i], length, stream.dict)),
58678        xref: this,
58679        allowStreams: true
58680      });
58681      const obj = parser.getObj();
58682      entries[i] = obj;
58683      if (obj instanceof BaseStream) {
58684        continue;
58685      }
58686      const num = nums[i],
58687        entry = this.entries[num];
58688      if (entry && entry.offset === tableOffset && entry.gen === i) {
58689        this._cacheMap.set(num, obj);
58690      }
58691    }
58692    xrefEntry = entries[xrefEntry.gen];
58693    if (xrefEntry === undefined) {
58694      throw new XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
58695    }
58696    return xrefEntry;
58697  }
58698  async fetchIfRefAsync(obj, suppressEncryption) {
58699    if (obj instanceof Ref) {
58700      return this.fetchAsync(obj, suppressEncryption);
58701    }
58702    return obj;
58703  }
58704  async fetchAsync(ref, suppressEncryption) {
58705    try {
58706      return this.fetch(ref, suppressEncryption);
58707    } catch (ex) {
58708      if (!(ex instanceof MissingDataException)) {
58709        throw ex;
58710      }
58711      await this.pdfManager.requestRange(ex.begin, ex.end);
58712      return this.fetchAsync(ref, suppressEncryption);
58713    }
58714  }
58715  getCatalogObj() {
58716    return this.root;
58717  }
58718}
58719
58720;// ./src/core/document.js
58721
58722
58723
58724
58725
58726
58727
58728
58729
58730
58731
58732
58733
58734
58735
58736
58737
58738
58739
58740
58741
58742
58743
58744
58745const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
58746class Page {
58747  #resourcesPromise = null;
58748  constructor({
58749    pdfManager,
58750    xref,
58751    pageIndex,
58752    pageDict,
58753    ref,
58754    globalIdFactory,
58755    fontCache,
58756    builtInCMapCache,
58757    standardFontDataCache,
58758    globalColorSpaceCache,
58759    globalImageCache,
58760    systemFontCache,
58761    nonBlendModesSet,
58762    xfaFactory
58763  }) {
58764    this.pdfManager = pdfManager;
58765    this.pageIndex = pageIndex;
58766    this.pageDict = pageDict;
58767    this.xref = xref;
58768    this.ref = ref;
58769    this.fontCache = fontCache;
58770    this.builtInCMapCache = builtInCMapCache;
58771    this.standardFontDataCache = standardFontDataCache;
58772    this.globalColorSpaceCache = globalColorSpaceCache;
58773    this.globalImageCache = globalImageCache;
58774    this.systemFontCache = systemFontCache;
58775    this.nonBlendModesSet = nonBlendModesSet;
58776    this.evaluatorOptions = pdfManager.evaluatorOptions;
58777    this.xfaFactory = xfaFactory;
58778    const idCounters = {
58779      obj: 0
58780    };
58781    this._localIdFactory = class extends globalIdFactory {
58782      static createObjId() {
58783        return `p${pageIndex}_${++idCounters.obj}`;
58784      }
58785      static getPageObjId() {
58786        return `p${ref.toString()}`;
58787      }
58788    };
58789  }
58790  #createPartialEvaluator(handler, pageIndex = this.pageIndex) {
58791    return new PartialEvaluator({
58792      xref: this.xref,
58793      handler,
58794      pageIndex,
58795      idFactory: this._localIdFactory,
58796      fontCache: this.fontCache,
58797      builtInCMapCache: this.builtInCMapCache,
58798      standardFontDataCache: this.standardFontDataCache,
58799      globalColorSpaceCache: this.globalColorSpaceCache,
58800      globalImageCache: this.globalImageCache,
58801      systemFontCache: this.systemFontCache,
58802      options: this.evaluatorOptions
58803    });
58804  }
58805  createAnnotationEvaluator(handler) {
58806    return this.#createPartialEvaluator(handler);
58807  }
58808  #getInheritableProperty(key, getArray = false) {
58809    const value = getInheritableProperty({
58810      dict: this.pageDict,
58811      key,
58812      getArray,
58813      stopWhenFound: false
58814    });
58815    if (!Array.isArray(value)) {
58816      return value;
58817    }
58818    if (value.length === 1 || !(value[0] instanceof Dict)) {
58819      return value[0];
58820    }
58821    return Dict.merge({
58822      xref: this.xref,
58823      dictArray: value
58824    });
58825  }
58826  get content() {
58827    return this.pageDict.getArray("Contents");
58828  }
58829  get resources() {
58830    const resources = this.#getInheritableProperty("Resources");
58831    return shadow(this, "resources", resources instanceof Dict ? resources : Dict.empty);
58832  }
58833  getBoundingBox(name) {
58834    if (this.xfaData) {
58835      return this.xfaData.bbox;
58836    }
58837    const box = lookupNormalRect(this.#getInheritableProperty(name, true), null);
58838    if (box) {
58839      if (box[2] - box[0] > 0 && box[3] - box[1] > 0) {
58840        return box;
58841      }
58842      warn(`Empty, or invalid, /${name} entry.`);
58843    }
58844    return null;
58845  }
58846  get mediaBox() {
58847    return shadow(this, "mediaBox", this.getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX);
58848  }
58849  get cropBox() {
58850    return shadow(this, "cropBox", this.getBoundingBox("CropBox") || this.mediaBox);
58851  }
58852  get userUnit() {
58853    const obj = this.pageDict.get("UserUnit");
vendor: 22,035 bytes, lines 58854-59491
58854    return shadow(this, "userUnit", typeof obj === "number" && obj > 0 ? obj : 1.0);
58855  }
58856  get view() {
58857    const {
58858      cropBox,
58859      mediaBox
58860    } = this;
58861    if (cropBox !== mediaBox && !isArrayEqual(cropBox, mediaBox)) {
58862      const box = Util.intersect(cropBox, mediaBox);
58863      if (box && box[2] - box[0] > 0 && box[3] - box[1] > 0) {
58864        return shadow(this, "view", box);
58865      }
58866      warn("Empty /CropBox and /MediaBox intersection.");
58867    }
58868    return shadow(this, "view", mediaBox);
58869  }
58870  get rotate() {
58871    let rotate = this.#getInheritableProperty("Rotate") || 0;
58872    if (rotate % 90 !== 0) {
58873      rotate = 0;
58874    } else if (rotate >= 360) {
58875      rotate %= 360;
58876    } else if (rotate < 0) {
58877      rotate = (rotate % 360 + 360) % 360;
58878    }
58879    return shadow(this, "rotate", rotate);
58880  }
58881  #onSubStreamError(reason, objId) {
58882    if (this.evaluatorOptions.ignoreErrors) {
58883      warn(`getContentStream - ignoring sub-stream (${objId}): "${reason}".`);
58884      return;
58885    }
58886    throw reason;
58887  }
58888  async getContentStream() {
58889    const content = await this.pdfManager.ensure(this, "content");
58890    if (content instanceof BaseStream && !content.isImageStream) {
58891      if (content.isAsync) {
58892        const bytes = await content.asyncGetBytes();
58893        if (bytes) {
58894          return new Stream(bytes, 0, bytes.length, content.dict);
58895        }
58896      }
58897      return content;
58898    }
58899    if (Array.isArray(content)) {
58900      const promises = [];
58901      for (let i = 0, ii = content.length; i < ii; i++) {
58902        const item = content[i];
58903        if (item instanceof BaseStream && item.isAsync) {
58904          promises.push(item.asyncGetBytes().then(bytes => {
58905            if (bytes) {
58906              content[i] = new Stream(bytes, 0, bytes.length, item.dict);
58907            }
58908          }));
58909        }
58910      }
58911      if (promises.length > 0) {
58912        await Promise.all(promises);
58913      }
58914      return new StreamsSequenceStream(content, this.#onSubStreamError.bind(this));
58915    }
58916    return new NullStream();
58917  }
58918  get xfaData() {
58919    return shadow(this, "xfaData", this.xfaFactory ? {
58920      bbox: this.xfaFactory.getBoundingBox(this.pageIndex)
58921    } : null);
58922  }
58923  async #replaceIdByRef(annotations, deletedAnnotations, existingAnnotations) {
58924    const promises = [];
58925    for (const annotation of annotations) {
58926      if (annotation.id) {
58927        const ref = Ref.fromString(annotation.id);
58928        if (!ref) {
58929          warn(`A non-linked annotation cannot be modified: ${annotation.id}`);
58930          continue;
58931        }
58932        if (annotation.deleted) {
58933          deletedAnnotations.put(ref, ref);
58934          if (annotation.popupRef) {
58935            const popupRef = Ref.fromString(annotation.popupRef);
58936            if (popupRef) {
58937              deletedAnnotations.put(popupRef, popupRef);
58938            }
58939          }
58940          continue;
58941        }
58942        if (annotation.popup?.deleted) {
58943          const popupRef = Ref.fromString(annotation.popupRef);
58944          if (popupRef) {
58945            deletedAnnotations.put(popupRef, popupRef);
58946          }
58947        }
58948        existingAnnotations?.put(ref);
58949        annotation.ref = ref;
58950        promises.push(this.xref.fetchAsync(ref).then(obj => {
58951          if (obj instanceof Dict) {
58952            annotation.oldAnnotation = obj.clone();
58953          }
58954        }, () => {
58955          warn(`Cannot fetch \`oldAnnotation\` for: ${ref}.`);
58956        }));
58957        delete annotation.id;
58958      }
58959    }
58960    await Promise.all(promises);
58961  }
58962  async saveNewAnnotations(handler, task, annotations, imagePromises, changes) {
58963    if (this.xfaFactory) {
58964      throw new Error("XFA: Cannot save new annotations.");
58965    }
58966    const partialEvaluator = this.#createPartialEvaluator(handler);
58967    const deletedAnnotations = new RefSetCache();
58968    const existingAnnotations = new RefSet();
58969    await this.#replaceIdByRef(annotations, deletedAnnotations, existingAnnotations);
58970    const pageDict = this.pageDict;
58971    const annotationsArray = this.annotations.filter(a => !(a instanceof Ref && deletedAnnotations.has(a)));
58972    const newData = await AnnotationFactory.saveNewAnnotations(partialEvaluator, this.xref, task, annotations, imagePromises, changes);
58973    for (const {
58974      ref
58975    } of newData.annotations) {
58976      if (ref instanceof Ref && !existingAnnotations.has(ref)) {
58977        annotationsArray.push(ref);
58978      }
58979    }
58980    const dict = pageDict.clone();
58981    dict.set("Annots", annotationsArray);
58982    changes.put(this.ref, {
58983      data: dict
58984    });
58985    for (const deletedRef of deletedAnnotations) {
58986      changes.put(deletedRef, {
58987        data: null
58988      });
58989    }
58990  }
58991  async save(handler, task, annotationStorage, changes) {
58992    const partialEvaluator = this.#createPartialEvaluator(handler);
58993    const annotations = await this._parsedAnnotations;
58994    const promises = [];
58995    for (const annotation of annotations) {
58996      promises.push(annotation.save(partialEvaluator, task, annotationStorage, changes).catch(function (reason) {
58997        warn("save - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
58998        return null;
58999      }));
59000    }
59001    return Promise.all(promises);
59002  }
59003  async loadResources(keys) {
59004    await (this.#resourcesPromise ??= this.pdfManager.ensure(this, "resources"));
59005    await ObjectLoader.load(this.resources, keys, this.xref);
59006  }
59007  async #getMergedResources(streamDict, keys) {
59008    const localResources = streamDict?.get("Resources");
59009    if (!(localResources instanceof Dict && localResources.size)) {
59010      return this.resources;
59011    }
59012    await ObjectLoader.load(localResources, keys, this.xref);
59013    return Dict.merge({
59014      xref: this.xref,
59015      dictArray: [localResources, this.resources],
59016      mergeSubDicts: true
59017    });
59018  }
59019  async getOperatorList({
59020    handler,
59021    sink,
59022    task,
59023    intent,
59024    cacheKey,
59025    pageIndex = this.pageIndex,
59026    annotationStorage = null,
59027    modifiedIds = null
59028  }) {
59029    const contentStreamPromise = this.getContentStream();
59030    const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
59031    const partialEvaluator = this.#createPartialEvaluator(handler, pageIndex);
59032    const newAnnotsByPage = !this.xfaFactory ? getNewAnnotationsMap(annotationStorage) : null;
59033    const newAnnots = newAnnotsByPage?.get(this.pageIndex);
59034    let newAnnotationsPromise = Promise.resolve(null);
59035    let deletedAnnotations = null;
59036    if (newAnnots) {
59037      const annotationGlobalsPromise = this.pdfManager.ensureDoc("annotationGlobals");
59038      let imagePromises;
59039      const missingBitmaps = new Set();
59040      for (const {
59041        bitmapId,
59042        bitmap
59043      } of newAnnots) {
59044        if (bitmapId && !bitmap && !missingBitmaps.has(bitmapId)) {
59045          missingBitmaps.add(bitmapId);
59046        }
59047      }
59048      const {
59049        isOffscreenCanvasSupported
59050      } = this.evaluatorOptions;
59051      if (missingBitmaps.size > 0) {
59052        const annotationWithBitmaps = newAnnots.slice();
59053        for (const [key, annotation] of annotationStorage) {
59054          if (!key.startsWith(AnnotationEditorPrefix)) {
59055            continue;
59056          }
59057          if (annotation.bitmap && missingBitmaps.has(annotation.bitmapId)) {
59058            annotationWithBitmaps.push(annotation);
59059          }
59060        }
59061        imagePromises = AnnotationFactory.generateImages(annotationWithBitmaps, this.xref, isOffscreenCanvasSupported);
59062      } else {
59063        imagePromises = AnnotationFactory.generateImages(newAnnots, this.xref, isOffscreenCanvasSupported);
59064      }
59065      deletedAnnotations = new RefSet();
59066      newAnnotationsPromise = Promise.all([annotationGlobalsPromise, this.#replaceIdByRef(newAnnots, deletedAnnotations, null)]).then(([annotationGlobals]) => {
59067        if (!annotationGlobals) {
59068          return null;
59069        }
59070        return AnnotationFactory.printNewAnnotations(annotationGlobals, partialEvaluator, task, newAnnots, imagePromises);
59071      });
59072    }
59073    const pageListPromise = Promise.all([contentStreamPromise, resourcesPromise]).then(async ([contentStream]) => {
59074      const resources = await this.#getMergedResources(contentStream.dict, RESOURCES_KEYS_OPERATOR_LIST);
59075      const opList = new OperatorList(intent, sink);
59076      handler.send("StartRenderPage", {
59077        transparency: partialEvaluator.hasBlendModes(resources, this.nonBlendModesSet),
59078        pageIndex,
59079        cacheKey
59080      });
59081      await partialEvaluator.getOperatorList({
59082        stream: contentStream,
59083        task,
59084        resources,
59085        operatorList: opList
59086      });
59087      return opList;
59088    });
59089    let [pageOpList, annotations, newAnnotations] = await Promise.all([pageListPromise, this._parsedAnnotations, newAnnotationsPromise]);
59090    if (newAnnotations) {
59091      annotations = annotations.filter(a => !(a.ref && deletedAnnotations.has(a.ref)));
59092      for (let i = 0, ii = newAnnotations.length; i < ii; i++) {
59093        const newAnnotation = newAnnotations[i];
59094        if (newAnnotation.refToReplace) {
59095          const j = annotations.findIndex(a => a.ref && isRefsEqual(a.ref, newAnnotation.refToReplace));
59096          if (j >= 0) {
59097            annotations.splice(j, 1, newAnnotation);
59098            newAnnotations.splice(i--, 1);
59099            ii--;
59100          }
59101        }
59102      }
59103      annotations = annotations.concat(newAnnotations);
59104    }
59105    if (annotations.length === 0 || intent & RenderingIntentFlag.ANNOTATIONS_DISABLE) {
59106      pageOpList.flush(true);
59107      return {
59108        length: pageOpList.totalLength
59109      };
59110    }
59111    const renderForms = !!(intent & RenderingIntentFlag.ANNOTATIONS_FORMS),
59112      isEditing = !!(intent & RenderingIntentFlag.IS_EDITING),
59113      intentAny = !!(intent & RenderingIntentFlag.ANY),
59114      intentDisplay = !!(intent & RenderingIntentFlag.DISPLAY),
59115      intentPrint = !!(intent & RenderingIntentFlag.PRINT);
59116    const opListPromises = [];
59117    for (const annotation of annotations) {
59118      if (intentAny || intentDisplay && annotation.mustBeViewed(annotationStorage, renderForms) && annotation.mustBeViewedWhenEditing(isEditing, modifiedIds) || intentPrint && annotation.mustBePrinted(annotationStorage)) {
59119        opListPromises.push(annotation.getOperatorList(partialEvaluator, task, intent, annotationStorage).catch(function (reason) {
59120          warn("getOperatorList - ignoring annotation data during " + `"${task.name}" task: "${reason}".`);
59121          return {
59122            opList: null,
59123            separateForm: false,
59124            separateCanvas: false
59125          };
59126        }));
59127      }
59128    }
59129    const opLists = await Promise.all(opListPromises);
59130    let form = false,
59131      canvas = false;
59132    for (const {
59133      opList,
59134      separateForm,
59135      separateCanvas
59136    } of opLists) {
59137      pageOpList.addOpList(opList);
59138      form ||= separateForm;
59139      canvas ||= separateCanvas;
59140    }
59141    pageOpList.flush(true, {
59142      form,
59143      canvas
59144    });
59145    return {
59146      length: pageOpList.totalLength
59147    };
59148  }
59149  async extractTextContent({
59150    handler,
59151    task,
59152    includeMarkedContent,
59153    disableNormalization,
59154    sink,
59155    intersector = null
59156  }) {
59157    const contentStreamPromise = this.getContentStream();
59158    const resourcesPromise = this.loadResources(RESOURCES_KEYS_TEXT_CONTENT);
59159    const langPromise = this.pdfManager.ensureCatalog("lang");
59160    const [contentStream,, lang] = await Promise.all([contentStreamPromise, resourcesPromise, langPromise]);
59161    const resources = await this.#getMergedResources(contentStream.dict, RESOURCES_KEYS_TEXT_CONTENT);
59162    const partialEvaluator = this.#createPartialEvaluator(handler);
59163    return partialEvaluator.getTextContent({
59164      stream: contentStream,
59165      task,
59166      resources,
59167      includeMarkedContent,
59168      disableNormalization,
59169      sink,
59170      viewBox: this.view,
59171      lang,
59172      intersector
59173    });
59174  }
59175  async getStructTree() {
59176    const structTreeRoot = await this.pdfManager.ensureCatalog("structTreeRoot");
59177    if (!structTreeRoot) {
59178      return null;
59179    }
59180    await this._parsedAnnotations;
59181    try {
59182      const structTree = await this.pdfManager.ensure(this, "_parseStructTree", [structTreeRoot]);
59183      return await this.pdfManager.ensure(structTree, "serializable");
59184    } catch (ex) {
59185      warn(`getStructTree: "${ex}".`);
59186      return null;
59187    }
59188  }
59189  _parseStructTree(structTreeRoot) {
59190    const tree = new StructTreePage(structTreeRoot, this.pageDict);
59191    tree.parse(this.ref);
59192    return tree;
59193  }
59194  async getAnnotationsData(handler, task, intent) {
59195    const annotations = await this._parsedAnnotations;
59196    if (annotations.length === 0) {
59197      return annotations;
59198    }
59199    const annotationsData = [],
59200      textContentPromises = [];
59201    let partialEvaluator;
59202    const intentAny = !!(intent & RenderingIntentFlag.ANY),
59203      intentDisplay = !!(intent & RenderingIntentFlag.DISPLAY),
59204      intentPrint = !!(intent & RenderingIntentFlag.PRINT);
59205    const highlightedAnnotations = [];
59206    for (const annotation of annotations) {
59207      const isVisible = intentAny || intentDisplay && annotation.viewable;
59208      if (isVisible || intentPrint && annotation.printable) {
59209        annotationsData.push(annotation.data);
59210      }
59211      if (annotation.hasTextContent && isVisible) {
59212        partialEvaluator ??= this.#createPartialEvaluator(handler);
59213        textContentPromises.push(annotation.extractTextContent(partialEvaluator, task, [-Infinity, -Infinity, Infinity, Infinity]).catch(function (reason) {
59214          warn(`getAnnotationsData - ignoring textContent during "${task.name}" task: "${reason}".`);
59215        }));
59216      } else if (annotation.overlaysTextContent && isVisible) {
59217        highlightedAnnotations.push(annotation);
59218      }
59219    }
59220    if (highlightedAnnotations.length > 0) {
59221      const intersector = new Intersector(highlightedAnnotations);
59222      textContentPromises.push(this.extractTextContent({
59223        handler,
59224        task,
59225        includeMarkedContent: false,
59226        disableNormalization: false,
59227        sink: null,
59228        intersector
59229      }).then(() => {
59230        intersector.setText();
59231      }));
59232    }
59233    await Promise.all(textContentPromises);
59234    return annotationsData;
59235  }
59236  get annotations() {
59237    const annots = this.#getInheritableProperty("Annots");
59238    return shadow(this, "annotations", Array.isArray(annots) ? annots : []);
59239  }
59240  get _parsedAnnotations() {
59241    const promise = this.pdfManager.ensure(this, "annotations").then(async annots => {
59242      if (annots.length === 0) {
59243        return annots;
59244      }
59245      const [annotationGlobals, fieldObjects] = await Promise.all([this.pdfManager.ensureDoc("annotationGlobals"), this.pdfManager.ensureDoc("fieldObjects")]);
59246      if (!annotationGlobals) {
59247        return [];
59248      }
59249      const orphanFields = fieldObjects?.orphanFields;
59250      const annotationPromises = [];
59251      for (const annotationRef of annots) {
59252        annotationPromises.push(AnnotationFactory.create(this.xref, annotationRef, annotationGlobals, this._localIdFactory, false, orphanFields, null, this.ref).catch(function (reason) {
59253          warn(`_parsedAnnotations: "${reason}".`);
59254          return null;
59255        }));
59256      }
59257      const sortedAnnotations = [];
59258      let popupAnnotations, widgetAnnotations;
59259      for (const annotation of await Promise.all(annotationPromises)) {
59260        if (!annotation) {
59261          continue;
59262        }
59263        if (annotation instanceof WidgetAnnotation) {
59264          (widgetAnnotations ||= []).push(annotation);
59265          continue;
59266        }
59267        if (annotation instanceof PopupAnnotation) {
59268          (popupAnnotations ||= []).push(annotation);
59269          continue;
59270        }
59271        sortedAnnotations.push(annotation);
59272      }
59273      if (widgetAnnotations) {
59274        sortedAnnotations.push(...widgetAnnotations);
59275      }
59276      if (popupAnnotations) {
59277        sortedAnnotations.push(...popupAnnotations);
59278      }
59279      return sortedAnnotations;
59280    });
59281    return shadow(this, "_parsedAnnotations", promise);
59282  }
59283  get jsActions() {
59284    const actions = collectActions(this.xref, this.pageDict, PageActionEventType);
59285    return shadow(this, "jsActions", actions);
59286  }
59287  async collectAnnotationsByType(handler, task, types, promises, annotationGlobals) {
59288    const {
59289      pageIndex
59290    } = this;
59291    if (Object.hasOwn(this, "_parsedAnnotations")) {
59292      const cachedAnnotations = await this._parsedAnnotations;
59293      for (const {
59294        data
59295      } of cachedAnnotations) {
59296        if (!types || types.has(data.annotationType)) {
59297          data.pageIndex = pageIndex;
59298          promises.push(Promise.resolve(data));
59299        }
59300      }
59301      return;
59302    }
59303    const annots = await this.pdfManager.ensure(this, "annotations");
59304    let partialEvaluator;
59305    for (const annotationRef of annots) {
59306      promises.push(AnnotationFactory.create(this.xref, annotationRef, annotationGlobals, this._localIdFactory, false, null, types, this.ref).then(async annotation => {
59307        if (!annotation) {
59308          return null;
59309        }
59310        annotation.data.pageIndex = pageIndex;
59311        if (annotation.hasTextContent && annotation.viewable) {
59312          partialEvaluator ??= this.#createPartialEvaluator(handler);
59313          await annotation.extractTextContent(partialEvaluator, task, [-Infinity, -Infinity, Infinity, Infinity]);
59314        }
59315        return annotation.data;
59316      }).catch(function (reason) {
59317        warn(`collectAnnotationsByType: "${reason}".`);
59318        return null;
59319      }));
59320    }
59321  }
59322}
59323const PDF_HEADER_SIGNATURE = new Uint8Array([0x25, 0x50, 0x44, 0x46, 0x2d]);
59324const STARTXREF_SIGNATURE = new Uint8Array([0x73, 0x74, 0x61, 0x72, 0x74, 0x78, 0x72, 0x65, 0x66]);
59325const ENDOBJ_SIGNATURE = new Uint8Array([0x65, 0x6e, 0x64, 0x6f, 0x62, 0x6a]);
59326function find(stream, signature, limit = 1024, backwards = false) {
59327  const signatureLength = signature.length;
59328  const scanBytes = stream.peekBytes(limit);
59329  const scanLength = scanBytes.length - signatureLength;
59330  if (scanLength <= 0) {
59331    return false;
59332  }
59333  if (backwards) {
59334    const signatureEnd = signatureLength - 1;
59335    let pos = scanBytes.length - 1;
59336    while (pos >= signatureEnd) {
59337      let j = 0;
59338      while (j < signatureLength && scanBytes[pos - j] === signature[signatureEnd - j]) {
59339        j++;
59340      }
59341      if (j >= signatureLength) {
59342        stream.pos += pos - signatureEnd;
59343        return true;
59344      }
59345      pos--;
59346    }
59347  } else {
59348    let pos = 0;
59349    while (pos <= scanLength) {
59350      let j = 0;
59351      while (j < signatureLength && scanBytes[pos + j] === signature[j]) {
59352        j++;
59353      }
59354      if (j >= signatureLength) {
59355        stream.pos += pos;
59356        return true;
59357      }
59358      pos++;
59359    }
59360  }
59361  return false;
59362}
59363class PDFDocument {
59364  #pagePromises = new Map();
59365  #version = null;
59366  constructor(pdfManager, stream) {
59367    if (stream.length <= 0) {
59368      throw new InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");
59369    }
59370    this.pdfManager = pdfManager;
59371    this.stream = stream;
59372    this.xref = new XRef(stream, pdfManager);
59373    const idCounters = {
59374      font: 0
59375    };
59376    this._globalIdFactory = class {
59377      static getDocId() {
59378        return `g_${pdfManager.docId}`;
59379      }
59380      static createFontId() {
59381        return `f${++idCounters.font}`;
59382      }
59383      static createObjId() {
59384        unreachable("Abstract method `createObjId` called.");
59385      }
59386      static getPageObjId() {
59387        unreachable("Abstract method `getPageObjId` called.");
59388      }
59389    };
59390  }
59391  parse(recoveryMode) {
59392    this.xref.parse(recoveryMode);
59393    this.catalog = new Catalog(this.pdfManager, this.xref);
59394  }
59395  get linearization() {
59396    let linearization = null;
59397    try {
59398      linearization = Linearization.create(this.stream);
59399    } catch (err) {
59400      if (err instanceof MissingDataException) {
59401        throw err;
59402      }
59403      info(err);
59404    }
59405    return shadow(this, "linearization", linearization);
59406  }
59407  get startXRef() {
59408    const stream = this.stream;
59409    let startXRef = 0;
59410    if (this.linearization) {
59411      stream.reset();
59412      if (find(stream, ENDOBJ_SIGNATURE)) {
59413        stream.skip(6);
59414        let ch = stream.peekByte();
59415        while (isWhiteSpace(ch)) {
59416          stream.pos++;
59417          ch = stream.peekByte();
59418        }
59419        startXRef = stream.pos - stream.start;
59420      }
59421    } else {
59422      const step = 1024;
59423      const startXRefLength = STARTXREF_SIGNATURE.length;
59424      let found = false,
59425        pos = stream.end;
59426      while (!found && pos > 0) {
59427        pos -= step - startXRefLength;
59428        if (pos < 0) {
59429          pos = 0;
59430        }
59431        stream.pos = pos;
59432        found = find(stream, STARTXREF_SIGNATURE, step, true);
59433      }
59434      if (found) {
59435        stream.skip(9);
59436        let ch;
59437        do {
59438          ch = stream.getByte();
59439        } while (isWhiteSpace(ch));
59440        let str = "";
59441        while (ch >= 0x20 && ch <= 0x39) {
59442          str += String.fromCharCode(ch);
59443          ch = stream.getByte();
59444        }
59445        startXRef = parseInt(str, 10);
59446        if (isNaN(startXRef)) {
59447          startXRef = 0;
59448        }
59449      }
59450    }
59451    return shadow(this, "startXRef", startXRef);
59452  }
59453  checkHeader() {
59454    const stream = this.stream;
59455    stream.reset();
59456    if (!find(stream, PDF_HEADER_SIGNATURE)) {
59457      return;
59458    }
59459    stream.moveStart();
59460    stream.skip(PDF_HEADER_SIGNATURE.length);
59461    let version = "",
59462      ch;
59463    while ((ch = stream.getByte()) > 0x20 && version.length < 7) {
59464      version += String.fromCharCode(ch);
59465    }
59466    if (PDF_VERSION_REGEXP.test(version)) {
59467      this.#version = version;
59468    } else {
59469      warn(`Invalid PDF header version: ${version}`);
59470    }
59471  }
59472  parseStartXRef() {
59473    this.xref.setStartXRef(this.startXRef);
59474  }
59475  get numPages() {
59476    let num = 0;
59477    if (this.catalog.hasActualNumPages) {
59478      num = this.catalog.numPages;
59479    } else if (this.xfaFactory) {
59480      num = this.xfaFactory.getNumPages();
59481    } else if (this.linearization) {
59482      num = this.linearization.numPages;
59483    } else {
59484      num = this.catalog.numPages;
59485    }
59486    return shadow(this, "numPages", num);
59487  }
59488  #hasOnlyDocumentSignatures(fields, recursionDepth = 0) {
59489    const RECURSION_LIMIT = 10;
59490    if (!Array.isArray(fields)) {
59491      return false;
vendor: 5,081 bytes, lines 59492-59665
59492    }
59493    return fields.every(field => {
59494      field = this.xref.fetchIfRef(field);
59495      if (!(field instanceof Dict)) {
59496        return false;
59497      }
59498      if (field.has("Kids")) {
59499        if (++recursionDepth > RECURSION_LIMIT) {
59500          warn("#hasOnlyDocumentSignatures: maximum recursion depth reached");
59501          return false;
59502        }
59503        return this.#hasOnlyDocumentSignatures(field.get("Kids"), recursionDepth);
59504      }
59505      const isSignature = isName(field.get("FT"), "Sig");
59506      const rectangle = field.get("Rect");
59507      const isInvisible = Array.isArray(rectangle) && rectangle.every(value => value === 0);
59508      return isSignature && isInvisible;
59509    });
59510  }
59511  get _xfaStreams() {
59512    const {
59513      acroForm
59514    } = this.catalog;
59515    if (!acroForm) {
59516      return null;
59517    }
59518    const xfa = acroForm.get("XFA");
59519    const entries = new Map(["xdp:xdp", "template", "datasets", "config", "connectionSet", "localeSet", "stylesheet", "/xdp:xdp"].map(e => [e, null]));
59520    if (xfa instanceof BaseStream && !xfa.isEmpty) {
59521      entries.set("xdp:xdp", xfa);
59522      return entries;
59523    }
59524    if (!Array.isArray(xfa) || xfa.length === 0) {
59525      return null;
59526    }
59527    for (let i = 0, ii = xfa.length; i < ii; i += 2) {
59528      let name;
59529      if (i === 0) {
59530        name = "xdp:xdp";
59531      } else if (i === ii - 2) {
59532        name = "/xdp:xdp";
59533      } else {
59534        name = xfa[i];
59535      }
59536      if (!entries.has(name)) {
59537        continue;
59538      }
59539      const data = this.xref.fetchIfRef(xfa[i + 1]);
59540      if (!(data instanceof BaseStream) || data.isEmpty) {
59541        continue;
59542      }
59543      entries.set(name, data);
59544    }
59545    return entries;
59546  }
59547  get xfaDatasets() {
59548    const streams = this._xfaStreams;
59549    if (!streams) {
59550      return shadow(this, "xfaDatasets", null);
59551    }
59552    for (const key of ["datasets", "xdp:xdp"]) {
59553      const stream = streams.get(key);
59554      if (!stream) {
59555        continue;
59556      }
59557      try {
59558        const str = stringToUTF8String(stream.getString());
59559        const data = {
59560          [key]: str
59561        };
59562        return shadow(this, "xfaDatasets", new DatasetReader(data));
59563      } catch {
59564        warn("XFA - Invalid utf-8 string.");
59565        break;
59566      }
59567    }
59568    return shadow(this, "xfaDatasets", null);
59569  }
59570  get xfaData() {
59571    const streams = this._xfaStreams;
59572    if (!streams) {
59573      return null;
59574    }
59575    const data = Object.create(null);
59576    for (const [key, stream] of streams) {
59577      if (!stream) {
59578        continue;
59579      }
59580      try {
59581        data[key] = stringToUTF8String(stream.getString());
59582      } catch {
59583        warn("XFA - Invalid utf-8 string.");
59584        return null;
59585      }
59586    }
59587    return data;
59588  }
59589  get xfaFactory() {
59590    let data;
59591    if (this.pdfManager.enableXfa && this.catalog.needsRendering && this.formInfo.hasXfa && !this.formInfo.hasAcroForm) {
59592      data = this.xfaData;
59593    }
59594    return shadow(this, "xfaFactory", data ? new XFAFactory(data) : null);
59595  }
59596  get isPureXfa() {
59597    return this.xfaFactory ? this.xfaFactory.isValid() : false;
59598  }
59599  get htmlForXfa() {
59600    return this.xfaFactory ? this.xfaFactory.getPages() : null;
59601  }
59602  async #loadXfaImages() {
59603    const xfaImages = await this.pdfManager.ensureCatalog("xfaImages");
59604    if (!xfaImages) {
59605      return;
59606    }
59607    this.xfaFactory.setImages(xfaImages);
59608  }
59609  async #loadXfaFonts(handler, task) {
59610    const acroForm = await this.pdfManager.ensureCatalog("acroForm");
59611    if (!acroForm) {
59612      return;
59613    }
59614    const resources = await acroForm.getAsync("DR");
59615    if (!(resources instanceof Dict)) {
59616      return;
59617    }
59618    await ObjectLoader.load(resources, ["Font"], this.xref);
59619    const fontRes = resources.get("Font");
59620    if (!(fontRes instanceof Dict)) {
59621      return;
59622    }
59623    const options = Object.assign(Object.create(null), this.pdfManager.evaluatorOptions, {
59624      useSystemFonts: false
59625    });
59626    const {
59627      builtInCMapCache,
59628      fontCache,
59629      standardFontDataCache
59630    } = this.catalog;
59631    const partialEvaluator = new PartialEvaluator({
59632      xref: this.xref,
59633      handler,
59634      pageIndex: -1,
59635      idFactory: this._globalIdFactory,
59636      fontCache,
59637      builtInCMapCache,
59638      standardFontDataCache,
59639      options
59640    });
59641    const operatorList = new OperatorList();
59642    const pdfFonts = [];
59643    const initialState = {
59644      get font() {
59645        return pdfFonts.at(-1);
59646      },
59647      set font(font) {
59648        pdfFonts.push(font);
59649      },
59650      clone() {
59651        return this;
59652      }
59653    };
59654    const parseFont = (fontName, fallbackFontDict, cssFontInfo) => partialEvaluator.handleSetFont(resources, [Name.get(fontName), 1], null, operatorList, task, initialState, fallbackFontDict, cssFontInfo).catch(reason => {
59655      warn(`loadXfaFonts: "${reason}".`);
59656      return null;
59657    });
59658    const promises = [];
59659    for (const [fontName, font] of fontRes) {
59660      const descriptor = font.get("FontDescriptor");
59661      if (!(descriptor instanceof Dict)) {
59662        continue;
59663      }
59664      let fontFamily = descriptor.get("FontFamily");
59665      fontFamily = fontFamily.replaceAll(/ +(\d)/g, "$1"
vendor: 4,890 bytes, lines 59665-59830
59665);
59666      const fontWeight = descriptor.get("FontWeight");
59667      const italicAngle = -descriptor.get("ItalicAngle");
59668      const cssFontInfo = {
59669        fontFamily,
59670        fontWeight,
59671        italicAngle
59672      };
59673      if (!validateCSSFont(cssFontInfo)) {
59674        continue;
59675      }
59676      promises.push(parseFont(fontName, null, cssFontInfo));
59677    }
59678    await Promise.all(promises);
59679    const missingFonts = this.xfaFactory.setFonts(pdfFonts);
59680    if (!missingFonts) {
59681      return;
59682    }
59683    options.ignoreErrors = true;
59684    promises.length = 0;
59685    pdfFonts.length = 0;
59686    const reallyMissingFonts = new Set();
59687    for (const missing of missingFonts) {
59688      if (!getXfaFontName(`${missing}-Regular`)) {
59689        reallyMissingFonts.add(missing);
59690      }
59691    }
59692    if (reallyMissingFonts.size) {
59693      missingFonts.push("PdfJS-Fallback");
59694    }
59695    for (const missing of missingFonts) {
59696      if (reallyMissingFonts.has(missing)) {
59697        continue;
59698      }
59699      for (const fontInfo of [{
59700        name: "Regular",
59701        fontWeight: 400,
59702        italicAngle: 0
59703      }, {
59704        name: "Bold",
59705        fontWeight: 700,
59706        italicAngle: 0
59707      }, {
59708        name: "Italic",
59709        fontWeight: 400,
59710        italicAngle: 12
59711      }, {
59712        name: "BoldItalic",
59713        fontWeight: 700,
59714        italicAngle: 12
59715      }]) {
59716        const name = `${missing}-${fontInfo.name}`;
59717        promises.push(parseFont(name, getXfaFontDict(name), {
59718          fontFamily: missing,
59719          fontWeight: fontInfo.fontWeight,
59720          italicAngle: fontInfo.italicAngle
59721        }));
59722      }
59723    }
59724    await Promise.all(promises);
59725    this.xfaFactory.appendFonts(pdfFonts, reallyMissingFonts);
59726  }
59727  loadXfaResources(handler, task) {
59728    return Promise.all([this.#loadXfaFonts(handler, task).catch(() => {}), this.#loadXfaImages()]);
59729  }
59730  serializeXfaData(annotationStorage) {
59731    return this.xfaFactory ? this.xfaFactory.serializeData(annotationStorage) : null;
59732  }
59733  get version() {
59734    return this.catalog.version || this.#version;
59735  }
59736  get formInfo() {
59737    const formInfo = {
59738      hasFields: false,
59739      hasAcroForm: false,
59740      hasXfa: false,
59741      hasSignatures: false
59742    };
59743    const {
59744      acroForm
59745    } = this.catalog;
59746    if (!acroForm) {
59747      return shadow(this, "formInfo", formInfo);
59748    }
59749    try {
59750      const fields = acroForm.get("Fields");
59751      const hasFields = Array.isArray(fields) && fields.length > 0;
59752      formInfo.hasFields = hasFields;
59753      const xfa = acroForm.get("XFA");
59754      formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || xfa instanceof BaseStream && !xfa.isEmpty;
59755      const sigFlags = acroForm.get("SigFlags");
59756      const hasSignatures = !!(sigFlags & 0x1);
59757      const hasOnlyDocumentSignatures = hasSignatures && this.#hasOnlyDocumentSignatures(fields);
59758      formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
59759      formInfo.hasSignatures = hasSignatures;
59760    } catch (ex) {
59761      if (ex instanceof MissingDataException) {
59762        throw ex;
59763      }
59764      warn(`Cannot fetch form information: "${ex}".`);
59765    }
59766    return shadow(this, "formInfo", formInfo);
59767  }
59768  get documentInfo() {
59769    const {
59770      catalog,
59771      formInfo,
59772      xref
59773    } = this;
59774    const docInfo = {
59775      PDFFormatVersion: this.version,
59776      Language: catalog.lang,
59777      EncryptFilterName: xref.encrypt?.filterName ?? null,
59778      IsLinearized: !!this.linearization,
59779      IsAcroFormPresent: formInfo.hasAcroForm,
59780      IsXFAPresent: formInfo.hasXfa,
59781      IsCollectionPresent: !!catalog.collection,
59782      IsSignaturesPresent: formInfo.hasSignatures
59783    };
59784    let infoDict;
59785    try {
59786      infoDict = xref.trailer.get("Info");
59787    } catch (err) {
59788      if (err instanceof MissingDataException) {
59789        throw err;
59790      }
59791      info("The document information dictionary is invalid.");
59792    }
59793    if (!(infoDict instanceof Dict)) {
59794      return shadow(this, "documentInfo", docInfo);
59795    }
59796    for (const [key, value] of infoDict) {
59797      switch (key) {
59798        case "Title":
59799        case "Author":
59800        case "Subject":
59801        case "Keywords":
59802        case "Creator":
59803        case "Producer":
59804        case "CreationDate":
59805        case "ModDate":
59806          if (typeof value === "string") {
59807            docInfo[key] = stringToPDFString(value);
59808            continue;
59809          }
59810          break;
59811        case "Trapped":
59812          if (value instanceof Name) {
59813            docInfo[key] = value;
59814            continue;
59815          }
59816          break;
59817        default:
59818          let customValue;
59819          switch (typeof value) {
59820            case "string":
59821              customValue = stringToPDFString(value);
59822              break;
59823            case "number":
59824            case "boolean":
59825              customValue = value;
59826              break;
59827            default:
59828              if (value instanceof Name) {
59829                customValue = value;
59830              
vendor: 9,198 bytes, lines 59830-60104
59830}
59831              break;
59832          }
59833          if (customValue === undefined) {
59834            warn(`Bad value, for custom key "${key}", in Info: ${value}.`);
59835            continue;
59836          }
59837          docInfo.Custom ??= Object.create(null);
59838          docInfo.Custom[key] = customValue;
59839          continue;
59840      }
59841      warn(`Bad value, for key "${key}", in Info: ${value}.`);
59842    }
59843    return shadow(this, "documentInfo", docInfo);
59844  }
59845  get fingerprints() {
59846    const FINGERPRINT_FIRST_BYTES = 1024;
59847    const EMPTY_FINGERPRINT = "\x00".repeat(16);
59848    function validate(data) {
59849      return typeof data === "string" && data.length === 16 && data !== EMPTY_FINGERPRINT;
59850    }
59851    const id = this.xref.trailer.get("ID");
59852    let hashOriginal, hashModified;
59853    if (Array.isArray(id) && validate(id[0])) {
59854      hashOriginal = stringToBytes(id[0]);
59855      if (id[1] !== id[0] && validate(id[1])) {
59856        hashModified = stringToBytes(id[1]);
59857      }
59858    } else {
59859      hashOriginal = calculateMD5(this.stream.getByteRange(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
59860    }
59861    return shadow(this, "fingerprints", [hashOriginal.toHex(), hashModified?.toHex() ?? null]);
59862  }
59863  async #getLinearizationPage(pageIndex) {
59864    const {
59865      catalog,
59866      linearization,
59867      xref
59868    } = this;
59869    const ref = Ref.get(linearization.objectNumberFirst, 0);
59870    try {
59871      const obj = await xref.fetchAsync(ref);
59872      if (obj instanceof Dict) {
59873        let type = obj.getRaw("Type");
59874        if (type instanceof Ref) {
59875          type = await xref.fetchAsync(type);
59876        }
59877        if (isName(type, "Page") || !obj.has("Type") && !obj.has("Kids") && obj.has("Contents")) {
59878          if (!catalog.pageKidsCountCache.has(ref)) {
59879            catalog.pageKidsCountCache.put(ref, 1);
59880          }
59881          if (!catalog.pageIndexCache.has(ref)) {
59882            catalog.pageIndexCache.put(ref, 0);
59883          }
59884          return [obj, ref];
59885        }
59886      }
59887      throw new FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.");
59888    } catch (reason) {
59889      warn(`_getLinearizationPage: "${reason.message}".`);
59890      return catalog.getPageDict(pageIndex);
59891    }
59892  }
59893  getPage(pageIndex) {
59894    const cachedPromise = this.#pagePromises.get(pageIndex);
59895    if (cachedPromise) {
59896      return cachedPromise;
59897    }
59898    const {
59899      catalog,
59900      linearization,
59901      xfaFactory
59902    } = this;
59903    let promise;
59904    if (xfaFactory) {
59905      promise = Promise.resolve([Dict.empty, null]);
59906    } else if (linearization?.pageFirst === pageIndex) {
59907      promise = this.#getLinearizationPage(pageIndex);
59908    } else {
59909      promise = catalog.getPageDict(pageIndex);
59910    }
59911    promise = promise.then(([pageDict, ref]) => new Page({
59912      pdfManager: this.pdfManager,
59913      xref: this.xref,
59914      pageIndex,
59915      pageDict,
59916      ref,
59917      globalIdFactory: this._globalIdFactory,
59918      fontCache: catalog.fontCache,
59919      builtInCMapCache: catalog.builtInCMapCache,
59920      standardFontDataCache: catalog.standardFontDataCache,
59921      globalColorSpaceCache: catalog.globalColorSpaceCache,
59922      globalImageCache: catalog.globalImageCache,
59923      systemFontCache: catalog.systemFontCache,
59924      nonBlendModesSet: catalog.nonBlendModesSet,
59925      xfaFactory
59926    }));
59927    this.#pagePromises.set(pageIndex, promise);
59928    return promise;
59929  }
59930  async checkFirstPage(recoveryMode = false) {
59931    if (recoveryMode) {
59932      return;
59933    }
59934    try {
59935      await this.getPage(0);
59936    } catch (reason) {
59937      if (reason instanceof XRefEntryException) {
59938        this.#pagePromises.delete(0);
59939        await this.cleanup();
59940        throw new XRefParseException();
59941      }
59942    }
59943  }
59944  async checkLastPage(recoveryMode = false) {
59945    const {
59946      catalog,
59947      pdfManager
59948    } = this;
59949    catalog.setActualNumPages();
59950    let numPages;
59951    try {
59952      await Promise.all([pdfManager.ensureDoc("xfaFactory"), pdfManager.ensureDoc("linearization"), pdfManager.ensureCatalog("numPages")]);
59953      if (this.xfaFactory) {
59954        return;
59955      } else if (this.linearization) {
59956        numPages = this.linearization.numPages;
59957      } else {
59958        numPages = catalog.numPages;
59959      }
59960      if (!Number.isInteger(numPages)) {
59961        throw new FormatError("Page count is not an integer.");
59962      } else if (numPages <= 1) {
59963        return;
59964      }
59965      await this.getPage(numPages - 1);
59966    } catch (reason) {
59967      this.#pagePromises.delete(numPages - 1);
59968      await this.cleanup();
59969      if (reason instanceof XRefEntryException && !recoveryMode) {
59970        throw new XRefParseException();
59971      }
59972      warn(`checkLastPage - invalid /Pages tree /Count: ${numPages}.`);
59973      let pagesTree;
59974      try {
59975        pagesTree = await catalog.getAllPageDicts(recoveryMode);
59976      } catch (reasonAll) {
59977        if (reasonAll instanceof XRefEntryException && !recoveryMode) {
59978          throw new XRefParseException();
59979        }
59980        catalog.setActualNumPages(1);
59981        return;
59982      }
59983      for (const [pageIndex, [pageDict, ref]] of pagesTree) {
59984        let promise;
59985        if (pageDict instanceof Error) {
59986          promise = Promise.reject(pageDict);
59987          promise.catch(() => {});
59988        } else {
59989          promise = Promise.resolve(new Page({
59990            pdfManager,
59991            xref: this.xref,
59992            pageIndex,
59993            pageDict,
59994            ref,
59995            globalIdFactory: this._globalIdFactory,
59996            fontCache: catalog.fontCache,
59997            builtInCMapCache: catalog.builtInCMapCache,
59998            standardFontDataCache: catalog.standardFontDataCache,
59999            globalColorSpaceCache: this.globalColorSpaceCache,
60000            globalImageCache: catalog.globalImageCache,
60001            systemFontCache: catalog.systemFontCache,
60002            nonBlendModesSet: catalog.nonBlendModesSet,
60003            xfaFactory: null
60004          }));
60005        }
60006        this.#pagePromises.set(pageIndex, promise);
60007      }
60008      catalog.setActualNumPages(pagesTree.size);
60009    }
60010  }
60011  async fontFallback(id, handler) {
60012    const {
60013      catalog,
60014      pdfManager
60015    } = this;
60016    for (const translatedFont of await Promise.all(catalog.fontCache)) {
60017      if (translatedFont.loadedName === id) {
60018        translatedFont.fallback(handler, pdfManager.evaluatorOptions);
60019        return;
60020      }
60021    }
60022  }
60023  async cleanup(manuallyTriggered = false) {
60024    return this.catalog ? this.catalog.cleanup(manuallyTriggered) : clearGlobalCaches();
60025  }
60026  async #collectFieldObjects(name, parentRef, fieldRef, promises, annotationGlobals, visitedRefs, orphanFields) {
60027    const {
60028      xref
60029    } = this;
60030    if (!(fieldRef instanceof Ref) || visitedRefs.has(fieldRef)) {
60031      return;
60032    }
60033    visitedRefs.put(fieldRef);
60034    const field = await xref.fetchAsync(fieldRef);
60035    if (!(field instanceof Dict)) {
60036      return;
60037    }
60038    let subtype = await field.getAsync("Subtype");
60039    subtype = subtype instanceof Name ? subtype.name : null;
60040    switch (subtype) {
60041      case "Link":
60042        return;
60043    }
60044    if (field.has("T")) {
60045      const partName = stringToPDFString(await field.getAsync("T"));
60046      name = name === "" ? partName : `${name}.${partName}`;
60047    } else {
60048      let obj = field;
60049      while (true) {
60050        obj = obj.getRaw("Parent") || parentRef;
60051        if (obj instanceof Ref) {
60052          if (visitedRefs.has(obj)) {
60053            break;
60054          }
60055          obj = await xref.fetchAsync(obj);
60056        }
60057        if (!(obj instanceof Dict)) {
60058          break;
60059        }
60060        if (obj.has("T")) {
60061          const partName = stringToPDFString(await obj.getAsync("T"));
60062          name = name === "" ? partName : `${name}.${partName}`;
60063          break;
60064        }
60065      }
60066    }
60067    if (parentRef && !field.has("Parent") && isName(field.get("Subtype"), "Widget")) {
60068      orphanFields.put(fieldRef, parentRef);
60069    }
60070    promises.getOrInsertComputed(name, makeArr).push(AnnotationFactory.create(xref, fieldRef, annotationGlobals, null, true, orphanFields, null, null).then(annotation => annotation?.getFieldObject()).catch(function (reason) {
60071      warn(`#collectFieldObjects: "${reason}".`);
60072      return null;
60073    }));
60074    if (!field.has("Kids")) {
60075      return;
60076    }
60077    const kids = await field.getAsync("Kids");
60078    if (Array.isArray(kids)) {
60079      for (const kid of kids) {
60080        await this.#collectFieldObjects(name, fieldRef, kid, promises, annotationGlobals, visitedRefs, orphanFields);
60081      }
60082    }
60083  }
60084  get fieldObjects() {
60085    const promise = this.pdfManager.ensureDoc("formInfo").then(async formInfo => {
60086      if (!formInfo.hasFields) {
60087        return null;
60088      }
60089      const annotationGlobals = await this.annotationGlobals;
60090      if (!annotationGlobals) {
60091        return null;
60092      }
60093      const {
60094        acroForm
60095      } = annotationGlobals;
60096      const visitedRefs = new RefSet();
60097      const allFields = Object.create(null);
60098      const fieldPromises = new Map();
60099      const orphanFields = new RefSetCache();
60100      for (const fieldRef of acroForm.get("Fields")) {
60101        await this.#collectFieldObjects("", null, fieldRef, fieldPromises, annotationGlobals, visitedRefs, orphanFields);
60102      }
60103      const allPromises = [];
60104      for (const [name, promises] of fieldPromises) {
60105        allPromises.push(Promise.all(promises).then(fields => {
60106          fields = fields.filter(field => !!field);
60107          if (fields.length > 0) {
60108            allFields[name] = fields;
60109          }
60110        }));
60111      }
60112      await Promise.all(allPromises);
60113      return {
60114        allFields: objectSize(allFields) > 0 ? allFields : null,
60115        orphanFields
60116      };
60117    });
60118    return shadow(this, "fieldObjects", promise);
60119  }
60120  get hasJSActions() {
60121    const promise = this.pdfManager.ensureDoc("_parseHasJSActions");
60122    return shadow(this, "hasJSActions", promise);
60123  }
60124  async _parseHasJSActions() {
60125    const [catalogJsActions, fieldObjects] = await Promise.all([this.pdfManager.ensureCatalog("jsActions"), this.pdfManager.ensureDoc("fieldObjects")]);
60126    if (catalogJsActions) {
60127      return true;
60128    }
60129    if (fieldObjects?.allFields) {
60130      return Object.values(fieldObjects.allFields).some(fieldObject => fieldObject.some(object => object.actions !== null));
60131    }
60132    return false;
60133  }
60134  get calculationOrderIds() {
60135    const calculationOrder = this.catalog.acroForm?.get("CO");
60136    if (!Array.isArray(calculationOrder) || calculationOrder.length === 0) {
60137      return shadow(this, "calculationOrderIds", null);
60138    }
60139    const ids = [];
60140    for (const id of calculationOrder) {
60141      if (id instanceof Ref) {
60142        ids.push(id.toString());
60143      }
60144    }
60145    return shadow(this, "calculationOrderIds", ids.length ? ids : null);
60146  }
60147  get annotationGlobals() {
60148    return shadow(this, "annotationGlobals", AnnotationFactory.createGlobals(this.pdfManager));
60149  }
60150  async toJSObject(value, firstCall = true) {
60151    throw new Error("Not implemented: toJSObject");
60152  }
60153}
60154
60155;// ./src/core/pdf_manager.js
60156
60157
60158
60159
60160
60161
60162
60163
60164
60165
60166
60167
60168function parseDocBaseUrl(url) {
60169  if (url) {
60170    const absoluteUrl = createValidAbsoluteUrl(url);
60171    if (absoluteUrl) {
60172      return absoluteUrl.href;
60173    }
60174    warn(`Invalid absolute docBaseUrl: "${url}".`);
60175  }
60176  return null;
60177}
60178class BasePdfManager {
60179  constructor({
60180    docBaseUrl,
60181    docId,
60182    enableXfa,
60183    evaluatorOptions,
60184    handler,
60185    password
60186  }) {
60187    this._docBaseUrl = parseDocBaseUrl(docBaseUrl);
60188    this._docId = docId;
60189    this._password = password;
60190    this.enableXfa = enableXfa;
60191    evaluatorOptions.isOffscreenCanvasSupported &&= FeatureTest.isOffscreenCanvasSupported;
60192    evaluatorOptions.isImageDecoderSupported &&= FeatureTest.isImageDecoderSupported;
60193    this.evaluatorOptions = Object.freeze(evaluatorOptions);
60194    ImageResizer.setOptions(evaluatorOptions);
60195    JpegStream.setOptions(evaluatorOptions);
60196    OperatorList.setOptions(evaluatorOptions);
60197    const options = {
60198      ...evaluatorOptions,
60199      handler
60200    };
60201    IccColorSpace.setOptions(options);
60202    CmykICCBasedCS.setOptions(options);
60203    PDFFunctionFactory.setOptions(options);
60204    Pattern.setOptions(options);
60205    WasmImage.setOptions(options);
60206  }
60207  get docId() {
60208    return this._docId;
60209  }
60210  get password() {
60211    return this._password;
60212  }
60213  get docBaseUrl() {
60214    return this._docBaseUrl;
60215  }
60216  ensureDoc(prop, args) {
60217    return this.ensure(this.pdfDocument, prop, args);
60218  }
60219  ensureXRef(prop, args) {
60220    return this.ensure(this.pdfDocument.xref, prop, args);
60221  }
60222  ensureCatalog(prop, args) {
60223    return this.ensure(this.pdfDocument.catalog, prop, args);
60224  }
60225  async initDocument(recoveryMode) {
60226    await this.ensureDoc("checkHeader");
60227    await this.ensureDoc("parseStartXRef");
60228    await this.ensureDoc("parse", [recoveryMode]);
60229    await this.ensureDoc("checkFirstPage", [recoveryMode]);
60230    await this.ensureDoc("checkLastPage", [recoveryMode]);
60231  }
60232  getPage(pageIndex) {
60233    return this.pdfDocument.getPage(pageIndex);
60234  }
60235  fontFallback(id, handler) {
60236    return this.pdfDocument.fontFallback(id, handler);
60237  }
60238  cleanup(manuallyTriggered = false) {
60239    return this.pdfDocument.cleanup(manuallyTriggered);
60240  }
60241  async ensure(obj, prop, args) {
60242    unreachable("Abstract method `ensure` called");
60243  }
60244  requestRange(begin, end) {
60245    unreachable("Abstract method `requestRange` called");
60246  }
60247  requestLoadedStream(noFetch = false) {
60248    unreachable("Abstract method `requestLoadedStream` called");
60249  }
60250  sendProgressiveData(chunk) {
60251    unreachable("Abstract method `sendProgressiveData` called");
60252  }
60253  updatePassword(password) {
60254    this._password = password;
60255    this.pdfDocument.xref.encrypt?.setPassword(password);
60256  }
60257  terminate(reason) {
60258    unreachable("Abstract method `terminate` called");
60259  }
60260}
60261class LocalPdfManager extends BasePdfManager {
60262  constructor(args) {
60263    super(args);
60264    const stream = new Stream(args.source);
60265    this.pdfDocument = new PDFDocument(this, stream);
60266    this._loadedStreamPromise = Promise.resolve(stream);
60267  }
60268  async ensure(obj, prop, args) {
60269    const value = obj[prop];
60270    if (typeof value === "function") {
vendor: 60,248 bytes, lines 60271-62217
60271      return value.apply(obj, args);
60272    }
60273    return value;
60274  }
60275  requestRange(begin, end) {
60276    return Promise.resolve();
60277  }
60278  requestLoadedStream(noFetch = false) {
60279    return this._loadedStreamPromise;
60280  }
60281  terminate(reason) {}
60282}
60283class NetworkPdfManager extends BasePdfManager {
60284  constructor(args) {
60285    super(args);
60286    this.streamManager = new ChunkedStreamManager(args.source, {
60287      msgHandler: args.handler,
60288      length: args.length,
60289      disableAutoFetch: args.disableAutoFetch,
60290      rangeChunkSize: args.rangeChunkSize
60291    });
60292    this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
60293  }
60294  async ensure(obj, prop, args) {
60295    try {
60296      const value = obj[prop];
60297      if (typeof value === "function") {
60298        return await value.apply(obj, args);
60299      }
60300      return value;
60301    } catch (ex) {
60302      if (!(ex instanceof MissingDataException)) {
60303        throw ex;
60304      }
60305      await this.requestRange(ex.begin, ex.end);
60306      return this.ensure(obj, prop, args);
60307    }
60308  }
60309  requestRange(begin, end) {
60310    return this.streamManager.requestRange(begin, end);
60311  }
60312  requestLoadedStream(noFetch = false) {
60313    return this.streamManager.requestAllChunks(noFetch);
60314  }
60315  sendProgressiveData(chunk) {
60316    this.streamManager.onReceiveData({
60317      chunk
60318    });
60319  }
60320  terminate(reason) {
60321    this.streamManager.abort(reason);
60322  }
60323}
60324
60325;// ./src/shared/message_handler.js
60326
60327const CallbackKind = {
60328  DATA: 1,
60329  ERROR: 2
60330};
60331const StreamKind = {
60332  CANCEL: 1,
60333  CANCEL_COMPLETE: 2,
60334  CLOSE: 3,
60335  ENQUEUE: 4,
60336  ERROR: 5,
60337  PULL: 6,
60338  PULL_COMPLETE: 7,
60339  START_COMPLETE: 8
60340};
60341function onFn() {}
60342function wrapReason(ex) {
60343  if (ex instanceof AbortException || ex instanceof InvalidPDFException || ex instanceof PasswordException || ex instanceof ResponseException || ex instanceof UnknownErrorException) {
60344    return ex;
60345  }
60346  if (!(ex instanceof Error || typeof ex === "object" && ex !== null)) {
60347    unreachable('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
60348  }
60349  switch (ex.name) {
60350    case "AbortException":
60351      return new AbortException(ex.message);
60352    case "InvalidPDFException":
60353      return new InvalidPDFException(ex.message);
60354    case "PasswordException":
60355      return new PasswordException(ex.message, ex.code);
60356    case "ResponseException":
60357      return new ResponseException(ex.message, ex.status, ex.missing);
60358    case "UnknownErrorException":
60359      return new UnknownErrorException(ex.message, ex.details);
60360  }
60361  return new UnknownErrorException(ex.message, ex.toString());
60362}
60363class MessageHandler {
60364  #messageAC = new AbortController();
60365  constructor(sourceName, targetName, comObj) {
60366    this.sourceName = sourceName;
60367    this.targetName = targetName;
60368    this.comObj = comObj;
60369    this.callbackId = 1;
60370    this.streamId = 1;
60371    this.streamSinks = Object.create(null);
60372    this.streamControllers = Object.create(null);
60373    this.callbackCapabilities = Object.create(null);
60374    this.actionHandler = Object.create(null);
60375    comObj.addEventListener("message", this.#onMessage.bind(this), {
60376      signal: this.#messageAC.signal
60377    });
60378  }
60379  #onMessage({
60380    data
60381  }) {
60382    if (data.targetName !== this.sourceName) {
60383      return;
60384    }
60385    if (data.stream) {
60386      this.#processStreamMessage(data);
60387      return;
60388    }
60389    if (data.callback) {
60390      const callbackId = data.callbackId;
60391      const capability = this.callbackCapabilities[callbackId];
60392      if (!capability) {
60393        throw new Error(`Cannot resolve callback ${callbackId}`);
60394      }
60395      delete this.callbackCapabilities[callbackId];
60396      if (data.callback === CallbackKind.DATA) {
60397        capability.resolve(data.data);
60398      } else if (data.callback === CallbackKind.ERROR) {
60399        capability.reject(wrapReason(data.reason));
60400      } else {
60401        throw new Error("Unexpected callback case");
60402      }
60403      return;
60404    }
60405    const action = this.actionHandler[data.action];
60406    if (!action) {
60407      throw new Error(`Unknown action from worker: ${data.action}`);
60408    }
60409    if (data.callbackId) {
60410      const sourceName = this.sourceName,
60411        targetName = data.sourceName,
60412        comObj = this.comObj;
60413      Promise.try(action, data.data).then(function (result) {
60414        comObj.postMessage({
60415          sourceName,
60416          targetName,
60417          callback: CallbackKind.DATA,
60418          callbackId: data.callbackId,
60419          data: result
60420        });
60421      }, function (reason) {
60422        comObj.postMessage({
60423          sourceName,
60424          targetName,
60425          callback: CallbackKind.ERROR,
60426          callbackId: data.callbackId,
60427          reason: wrapReason(reason)
60428        });
60429      });
60430      return;
60431    }
60432    if (data.streamId) {
60433      this.#createStreamSink(data);
60434      return;
60435    }
60436    action(data.data);
60437  }
60438  on(actionName, handler) {
60439    const ah = this.actionHandler;
60440    if (ah[actionName]) {
60441      throw new Error(`There is already an actionName called "${actionName}"`);
60442    }
60443    ah[actionName] = handler;
60444  }
60445  send(actionName, data, transfers) {
60446    this.comObj.postMessage({
60447      sourceName: this.sourceName,
60448      targetName: this.targetName,
60449      action: actionName,
60450      data
60451    }, transfers);
60452  }
60453  sendWithPromise(actionName, data, transfers) {
60454    const callbackId = this.callbackId++;
60455    const capability = Promise.withResolvers();
60456    this.callbackCapabilities[callbackId] = capability;
60457    try {
60458      this.comObj.postMessage({
60459        sourceName: this.sourceName,
60460        targetName: this.targetName,
60461        action: actionName,
60462        callbackId,
60463        data
60464      }, transfers);
60465    } catch (ex) {
60466      capability.reject(ex);
60467    }
60468    return capability.promise;
60469  }
60470  sendWithStream(actionName, data, queueingStrategy, transfers) {
60471    const streamId = this.streamId++,
60472      sourceName = this.sourceName,
60473      targetName = this.targetName,
60474      comObj = this.comObj;
60475    return new ReadableStream({
60476      start: controller => {
60477        const startCapability = Promise.withResolvers();
60478        this.streamControllers[streamId] = {
60479          controller,
60480          startCall: startCapability,
60481          pullCall: null,
60482          cancelCall: null,
60483          isClosed: false
60484        };
60485        comObj.postMessage({
60486          sourceName,
60487          targetName,
60488          action: actionName,
60489          streamId,
60490          data,
60491          desiredSize: controller.desiredSize
60492        }, transfers);
60493        return startCapability.promise;
60494      },
60495      pull: controller => {
60496        const pullCapability = Promise.withResolvers();
60497        this.streamControllers[streamId].pullCall = pullCapability;
60498        comObj.postMessage({
60499          sourceName,
60500          targetName,
60501          stream: StreamKind.PULL,
60502          streamId,
60503          desiredSize: controller.desiredSize
60504        });
60505        return pullCapability.promise;
60506      },
60507      cancel: reason => {
60508        assert(reason instanceof Error, "cancel must have a valid reason");
60509        const cancelCapability = Promise.withResolvers();
60510        this.streamControllers[streamId].cancelCall = cancelCapability;
60511        this.streamControllers[streamId].isClosed = true;
60512        comObj.postMessage({
60513          sourceName,
60514          targetName,
60515          stream: StreamKind.CANCEL,
60516          streamId,
60517          reason: wrapReason(reason)
60518        });
60519        return cancelCapability.promise;
60520      }
60521    }, queueingStrategy);
60522  }
60523  #createStreamSink(data) {
60524    const streamId = data.streamId,
60525      sourceName = this.sourceName,
60526      targetName = data.sourceName,
60527      comObj = this.comObj;
60528    const self = this,
60529      action = this.actionHandler[data.action];
60530    const streamSink = {
60531      enqueue(chunk, size = 1, transfers) {
60532        if (this.isCancelled) {
60533          return;
60534        }
60535        const lastDesiredSize = this.desiredSize;
60536        this.desiredSize -= size;
60537        if (lastDesiredSize > 0 && this.desiredSize <= 0) {
60538          this.sinkCapability = Promise.withResolvers();
60539          this.ready = this.sinkCapability.promise;
60540        }
60541        comObj.postMessage({
60542          sourceName,
60543          targetName,
60544          stream: StreamKind.ENQUEUE,
60545          streamId,
60546          chunk
60547        }, transfers);
60548      },
60549      close() {
60550        if (this.isCancelled) {
60551          return;
60552        }
60553        this.isCancelled = true;
60554        comObj.postMessage({
60555          sourceName,
60556          targetName,
60557          stream: StreamKind.CLOSE,
60558          streamId
60559        });
60560        delete self.streamSinks[streamId];
60561      },
60562      error(reason) {
60563        assert(reason instanceof Error, "error must have a valid reason");
60564        if (this.isCancelled) {
60565          return;
60566        }
60567        this.isCancelled = true;
60568        comObj.postMessage({
60569          sourceName,
60570          targetName,
60571          stream: StreamKind.ERROR,
60572          streamId,
60573          reason: wrapReason(reason)
60574        });
60575      },
60576      sinkCapability: Promise.withResolvers(),
60577      onPull: null,
60578      onCancel: null,
60579      isCancelled: false,
60580      desiredSize: data.desiredSize,
60581      ready: null
60582    };
60583    streamSink.sinkCapability.resolve();
60584    streamSink.ready = streamSink.sinkCapability.promise;
60585    this.streamSinks[streamId] = streamSink;
60586    Promise.try(action, data.data, streamSink).then(function () {
60587      comObj.postMessage({
60588        sourceName,
60589        targetName,
60590        stream: StreamKind.START_COMPLETE,
60591        streamId,
60592        success: true
60593      });
60594    }, function (reason) {
60595      comObj.postMessage({
60596        sourceName,
60597        targetName,
60598        stream: StreamKind.START_COMPLETE,
60599        streamId,
60600        reason: wrapReason(reason)
60601      });
60602    });
60603  }
60604  #processStreamMessage(data) {
60605    const streamId = data.streamId,
60606      sourceName = this.sourceName,
60607      targetName = data.sourceName,
60608      comObj = this.comObj;
60609    const streamController = this.streamControllers[streamId],
60610      streamSink = this.streamSinks[streamId];
60611    switch (data.stream) {
60612      case StreamKind.START_COMPLETE:
60613        if (data.success) {
60614          streamController.startCall.resolve();
60615        } else {
60616          streamController.startCall.reject(wrapReason(data.reason));
60617        }
60618        break;
60619      case StreamKind.PULL_COMPLETE:
60620        if (data.success) {
60621          streamController.pullCall.resolve();
60622        } else {
60623          streamController.pullCall.reject(wrapReason(data.reason));
60624        }
60625        break;
60626      case StreamKind.PULL:
60627        if (!streamSink) {
60628          comObj.postMessage({
60629            sourceName,
60630            targetName,
60631            stream: StreamKind.PULL_COMPLETE,
60632            streamId,
60633            success: true
60634          });
60635          break;
60636        }
60637        if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
60638          streamSink.sinkCapability.resolve();
60639        }
60640        streamSink.desiredSize = data.desiredSize;
60641        Promise.try(streamSink.onPull || onFn).then(function () {
60642          comObj.postMessage({
60643            sourceName,
60644            targetName,
60645            stream: StreamKind.PULL_COMPLETE,
60646            streamId,
60647            success: true
60648          });
60649        }, function (reason) {
60650          comObj.postMessage({
60651            sourceName,
60652            targetName,
60653            stream: StreamKind.PULL_COMPLETE,
60654            streamId,
60655            reason: wrapReason(reason)
60656          });
60657        });
60658        break;
60659      case StreamKind.ENQUEUE:
60660        assert(streamController, "enqueue should have stream controller");
60661        if (streamController.isClosed) {
60662          break;
60663        }
60664        streamController.controller.enqueue(data.chunk);
60665        break;
60666      case StreamKind.CLOSE:
60667        assert(streamController, "close should have stream controller");
60668        if (streamController.isClosed) {
60669          break;
60670        }
60671        streamController.isClosed = true;
60672        streamController.controller.close();
60673        this.#deleteStreamController(streamController, streamId);
60674        break;
60675      case StreamKind.ERROR:
60676        assert(streamController, "error should have stream controller");
60677        streamController.controller.error(wrapReason(data.reason));
60678        this.#deleteStreamController(streamController, streamId);
60679        break;
60680      case StreamKind.CANCEL_COMPLETE:
60681        if (data.success) {
60682          streamController.cancelCall.resolve();
60683        } else {
60684          streamController.cancelCall.reject(wrapReason(data.reason));
60685        }
60686        this.#deleteStreamController(streamController, streamId);
60687        break;
60688      case StreamKind.CANCEL:
60689        if (!streamSink) {
60690          break;
60691        }
60692        const dataReason = wrapReason(data.reason);
60693        Promise.try(streamSink.onCancel || onFn, dataReason).then(function () {
60694          comObj.postMessage({
60695            sourceName,
60696            targetName,
60697            stream: StreamKind.CANCEL_COMPLETE,
60698            streamId,
60699            success: true
60700          });
60701        }, function (reason) {
60702          comObj.postMessage({
60703            sourceName,
60704            targetName,
60705            stream: StreamKind.CANCEL_COMPLETE,
60706            streamId,
60707            reason: wrapReason(reason)
60708          });
60709        });
60710        streamSink.sinkCapability.reject(dataReason);
60711        streamSink.isCancelled = true;
60712        delete this.streamSinks[streamId];
60713        break;
60714      default:
60715        throw new Error("Unexpected stream case");
60716    }
60717  }
60718  async #deleteStreamController(streamController, streamId) {
60719    await Promise.allSettled([streamController.startCall?.promise, streamController.pullCall?.promise, streamController.cancelCall?.promise]);
60720    delete this.streamControllers[streamId];
60721  }
60722  destroy() {
60723    this.#messageAC?.abort();
60724    this.#messageAC = null;
60725  }
60726}
60727
60728;// ./src/core/writer.js
60729
60730
60731
60732
60733
60734
60735
60736async function writeObject(ref, obj, buffer, {
60737  encrypt = null,
60738  encryptRef = null
60739}) {
60740  const transform = encrypt && encryptRef !== ref ? encrypt.createCipherTransform(ref.num, ref.gen) : null;
60741  buffer.push(`${ref.num} ${ref.gen} obj\n`);
60742  await writeValue(obj, buffer, transform);
60743  buffer.push("\nendobj\n");
60744}
60745async function writeDict(dict, buffer, transform) {
60746  buffer.push("<<");
60747  for (const [key, rawObj] of dict.getRawEntries()) {
60748    buffer.push(` /${escapePDFName(key)} `);
60749    await writeValue(rawObj, buffer, transform);
60750  }
60751  buffer.push(">>");
60752}
60753async function writeStream(stream, buffer, transform) {
60754  stream = stream.getOriginalStream();
60755  stream.reset();
60756  let bytes = stream.getBytes();
60757  const {
60758    dict
60759  } = stream;
60760  const [filter, params] = await Promise.all([dict.getAsync("Filter"), dict.getAsync("DecodeParms")]);
60761  const filterZero = Array.isArray(filter) ? await dict.xref.fetchIfRefAsync(filter[0]) : filter;
60762  const isFilterZeroFlateDecode = isName(filterZero, "FlateDecode");
60763  const isFilterZeroImageDecode = isName(filterZero, "DCTDecode") || isName(filterZero, "JPXDecode") || isName(filterZero, "JBIG2Decode") || isName(filterZero, "CCITTFaxDecode") || isName(filterZero, "LZWDecode");
60764  const isFilterZeroCompressedObject = isFilterZeroFlateDecode || isFilterZeroImageDecode || isName(filterZero, "BrotliDecode");
60765  const MIN_LENGTH_FOR_COMPRESSING = 256;
60766  if (!isFilterZeroCompressedObject && bytes.length >= MIN_LENGTH_FOR_COMPRESSING) {
60767    try {
60768      const cs = new CompressionStream("deflate");
60769      const writer = cs.writable.getWriter();
60770      await writer.ready;
60771      writer.write(bytes).then(async () => {
60772        await writer.ready;
60773        await writer.close();
60774      }).catch(() => {});
60775      bytes = await new Response(cs.readable).bytes();
60776      let newFilter, newParams;
60777      if (!filter) {
60778        newFilter = Name.get("FlateDecode");
60779      } else if (!isFilterZeroFlateDecode) {
60780        newFilter = Array.isArray(filter) ? [Name.get("FlateDecode"), ...filter] : [Name.get("FlateDecode"), filter];
60781        if (params) {
60782          newParams = Array.isArray(params) ? [null, ...params] : [null, params];
60783        }
60784      }
60785      if (newFilter) {
60786        dict.set("Filter", newFilter);
60787      }
60788      if (newParams) {
60789        dict.set("DecodeParms", newParams);
60790      }
60791    } catch (ex) {
60792      info(`writeStream - cannot compress data: "${ex}".`);
60793    }
60794  }
60795  let string = bytesToString(bytes);
60796  if (transform) {
60797    string = transform.encryptString(string);
60798  }
60799  dict.set("Length", string.length);
60800  await writeDict(dict, buffer, transform);
60801  buffer.push(" stream\n", string, "\nendstream");
60802}
60803async function writeArray(array, buffer, transform) {
60804  buffer.push("[");
60805  for (let i = 0, ii = array.length; i < ii; i++) {
60806    await writeValue(array[i], buffer, transform);
60807    if (i < ii - 1) {
60808      buffer.push(" ");
60809    }
60810  }
60811  buffer.push("]");
60812}
60813async function writeValue(value, buffer, transform) {
60814  if (value instanceof Name) {
60815    buffer.push(`/${escapePDFName(value.name)}`);
60816  } else if (value instanceof Ref) {
60817    buffer.push(`${value.num} ${value.gen} R`);
60818  } else if (Array.isArray(value) || ArrayBuffer.isView(value)) {
60819    await writeArray(value, buffer, transform);
60820  } else if (typeof value === "string") {
60821    if (transform) {
60822      value = transform.encryptString(value);
60823    }
60824    buffer.push(`(${escapeString(value)})`);
60825  } else if (typeof value === "number") {
60826    buffer.push(value.toFixed(10).replace(/\.?0+$/, ""));
60827  } else if (typeof value === "boolean") {
60828    buffer.push(value.toString());
60829  } else if (value instanceof Dict) {
60830    await writeDict(value, buffer, transform);
60831  } else if (value instanceof BaseStream) {
60832    await writeStream(value, buffer, transform);
60833  } else if (value === null) {
60834    buffer.push("null");
60835  } else {
60836    warn(`Unhandled value in writer: ${typeof value}, please file a bug.`);
60837  }
60838}
60839function writeInt(number, size, offset, buffer) {
60840  for (let i = size + offset - 1; i > offset - 1; i--) {
60841    buffer[i] = number & 0xff;
60842    number >>= 8;
60843  }
60844  return offset + size;
60845}
60846function writeString(string, offset, buffer) {
60847  const ii = string.length;
60848  for (let i = 0; i < ii; i++) {
60849    buffer[offset + i] = string.charCodeAt(i) & 0xff;
60850  }
60851  return offset + ii;
60852}
60853function computeMD5(filesize, xrefInfo) {
60854  const time = Math.floor(Date.now() / 1000);
60855  const filename = xrefInfo.filename || "";
60856  const md5Buffer = [time.toString(), filename, filesize.toString(), ...xrefInfo.infoMap.values()];
60857  const md5BufferLen = Math.sumPrecise(md5Buffer.map(str => str.length));
60858  const array = new Uint8Array(md5BufferLen);
60859  let offset = 0;
60860  for (const str of md5Buffer) {
60861    offset = writeString(str, offset, array);
60862  }
60863  return bytesToString(calculateMD5(array, 0, array.length));
60864}
60865function writeXFADataForAcroform(str, changes) {
60866  const xml = new SimpleXMLParser({
60867    hasAttributes: true
60868  }).parseFromString(str);
60869  for (const {
60870    xfa
60871  } of changes) {
60872    if (!xfa) {
60873      continue;
60874    }
60875    const {
60876      path,
60877      value
60878    } = xfa;
60879    if (!path) {
60880      continue;
60881    }
60882    const nodePath = parseXFAPath(path);
60883    let node = xml.documentElement.searchNode(nodePath, 0);
60884    if (!node && nodePath.length > 1) {
60885      node = xml.documentElement.searchNode([nodePath.at(-1)], 0);
60886    }
60887    if (node) {
60888      node.childNodes = Array.isArray(value) ? value.map(val => new SimpleDOMNode("value", val)) : [new SimpleDOMNode("#text", value)];
60889    } else {
60890      warn(`Node not found for path: ${path}`);
60891    }
60892  }
60893  const buffer = [];
60894  xml.documentElement.dump(buffer);
60895  return buffer.join("");
60896}
60897async function updateAcroform({
60898  xref,
60899  acroForm,
60900  acroFormRef,
60901  hasXfa,
60902  hasXfaDatasetsEntry,
60903  xfaDatasetsRef,
60904  needAppearances,
60905  changes
60906}) {
60907  if (hasXfa && !hasXfaDatasetsEntry && !xfaDatasetsRef) {
60908    warn("XFA - Cannot save it");
60909  }
60910  if (!needAppearances && (!hasXfa || !xfaDatasetsRef || hasXfaDatasetsEntry)) {
60911    return;
60912  }
60913  const dict = acroForm.clone();
60914  if (hasXfa && !hasXfaDatasetsEntry) {
60915    const newXfa = acroForm.get("XFA").slice();
60916    newXfa.splice(2, 0, "datasets");
60917    newXfa.splice(3, 0, xfaDatasetsRef);
60918    dict.set("XFA", newXfa);
60919  }
60920  if (needAppearances) {
60921    dict.set("NeedAppearances", true);
60922  }
60923  changes.put(acroFormRef, {
60924    data: dict
60925  });
60926}
60927function updateXFA({
60928  xfaData,
60929  xfaDatasetsRef,
60930  changes,
60931  xref
60932}) {
60933  if (xfaData === null) {
60934    const datasets = xref.fetchIfRef(xfaDatasetsRef);
60935    xfaData = writeXFADataForAcroform(datasets.getString(), changes);
60936  }
60937  const xfaDataStream = new StringStream(xfaData, new Dict(xref));
60938  xfaDataStream.dict.setIfName("Type", "EmbeddedFile");
60939  changes.put(xfaDatasetsRef, {
60940    data: xfaDataStream
60941  });
60942}
60943async function getXRefTable(xrefInfo, baseOffset, newRefs, newXref, buffer) {
60944  buffer.push("xref\n");
60945  const indexes = getIndexes(newRefs);
60946  let indexesPosition = 0;
60947  for (const {
60948    ref,
60949    data
60950  } of newRefs) {
60951    if (ref.num === indexes[indexesPosition]) {
60952      buffer.push(`${indexes[indexesPosition]} ${indexes[indexesPosition + 1]}\n`);
60953      indexesPosition += 2;
60954    }
60955    if (data !== null) {
60956      buffer.push(`${baseOffset.toString().padStart(10, "0")} ${Math.min(ref.gen, 0xffff).toString().padStart(5, "0")} n\r\n`);
60957      baseOffset += data.length;
60958    } else {
60959      buffer.push(`0000000000 ${Math.min(ref.gen + 1, 0xffff).toString().padStart(5, "0")} f\r\n`);
60960    }
60961  }
60962  computeIDs(baseOffset, xrefInfo, newXref);
60963  buffer.push("trailer\n");
60964  await writeDict(newXref, buffer, null);
60965  buffer.push("\nstartxref\n", baseOffset.toString(), "\n%%EOF\n");
60966}
60967function getIndexes(newRefs) {
60968  const indexes = [];
60969  for (const {
60970    ref
60971  } of newRefs) {
60972    if (ref.num === indexes.at(-2) + indexes.at(-1)) {
60973      indexes[indexes.length - 1] += 1;
60974    } else {
60975      indexes.push(ref.num, 1);
60976    }
60977  }
60978  return indexes;
60979}
60980async function getXRefStreamTable(xrefInfo, baseOffset, newRefs, newXref, buffer) {
60981  const xrefTableData = [];
60982  let maxOffset = 0;
60983  let maxGen = 0;
60984  for (const {
60985    ref,
60986    data,
60987    objStreamRef,
60988    index
60989  } of newRefs) {
60990    let gen;
60991    maxOffset = Math.max(maxOffset, baseOffset);
60992    if (objStreamRef) {
60993      gen = index;
60994      xrefTableData.push([2, objStreamRef.num, gen]);
60995    } else if (data !== null) {
60996      gen = Math.min(ref.gen, 0xffff);
60997      xrefTableData.push([1, baseOffset, gen]);
60998      baseOffset += data.length;
60999    } else {
61000      gen = Math.min(ref.gen + 1, 0xffff);
61001      xrefTableData.push([0, 0, gen]);
61002    }
61003    maxGen = Math.max(maxGen, gen);
61004  }
61005  newXref.set("Index", getIndexes(newRefs));
61006  const offsetSize = getSizeInBytes(maxOffset);
61007  const maxGenSize = getSizeInBytes(maxGen);
61008  const sizes = [1, offsetSize, maxGenSize];
61009  newXref.set("W", sizes);
61010  computeIDs(baseOffset, xrefInfo, newXref);
61011  const structSize = Math.sumPrecise(sizes);
61012  const data = new Uint8Array(structSize * xrefTableData.length);
61013  const stream = new Stream(data);
61014  stream.dict = newXref;
61015  let offset = 0;
61016  for (const [type, objOffset, gen] of xrefTableData) {
61017    offset = writeInt(type, sizes[0], offset, data);
61018    offset = writeInt(objOffset, sizes[1], offset, data);
61019    offset = writeInt(gen, sizes[2], offset, data);
61020  }
61021  await writeObject(xrefInfo.newRef, stream, buffer, {});
61022  buffer.push("startxref\n", baseOffset.toString(), "\n%%EOF\n");
61023}
61024function computeIDs(baseOffset, xrefInfo, newXref) {
61025  if (Array.isArray(xrefInfo.fileIds) && xrefInfo.fileIds.length > 0) {
61026    const md5 = computeMD5(baseOffset, xrefInfo);
61027    newXref.set("ID", [xrefInfo.fileIds[0] || md5, md5]);
61028  }
61029}
61030function getTrailerDict(xrefInfo, changes, useXrefStream) {
61031  const newXref = new Dict(null);
61032  newXref.setIfDefined("Prev", xrefInfo?.startXRef);
61033  const refForXrefTable = xrefInfo.newRef;
61034  if (useXrefStream) {
61035    changes.put(refForXrefTable, {
61036      data: ""
61037    });
61038    newXref.set("Size", refForXrefTable.num + 1);
61039    newXref.setIfName("Type", "XRef");
61040  } else {
61041    newXref.set("Size", refForXrefTable.num);
61042  }
61043  newXref.setIfDefined("Root", xrefInfo?.rootRef);
61044  newXref.setIfDefined("Info", xrefInfo?.infoRef);
61045  newXref.setIfDefined("Encrypt", xrefInfo?.encryptRef);
61046  return newXref;
61047}
61048async function writeChanges(changes, xref, buffer = []) {
61049  const newRefs = [];
61050  for (const [ref, {
61051    data,
61052    objStreamRef,
61053    index
61054  }] of changes.items()) {
61055    if (objStreamRef) {
61056      newRefs.push({
61057        ref,
61058        data,
61059        objStreamRef,
61060        index
61061      });
61062      continue;
61063    }
61064    if (data === null || typeof data === "string") {
61065      newRefs.push({
61066        ref,
61067        data
61068      });
61069      continue;
61070    }
61071    await writeObject(ref, data, buffer, xref);
61072    newRefs.push({
61073      ref,
61074      data: buffer.join("")
61075    });
61076    buffer.length = 0;
61077  }
61078  return newRefs.sort((a, b) => a.ref.num - b.ref.num);
61079}
61080async function incrementalUpdate({
61081  originalData,
61082  xrefInfo,
61083  changes,
61084  xref = null,
61085  hasXfa = false,
61086  xfaDatasetsRef = null,
61087  hasXfaDatasetsEntry = false,
61088  needAppearances,
61089  acroFormRef = null,
61090  acroForm = null,
61091  xfaData = null,
61092  useXrefStream = false
61093}) {
61094  await updateAcroform({
61095    xref,
61096    acroForm,
61097    acroFormRef,
61098    hasXfa,
61099    hasXfaDatasetsEntry,
61100    xfaDatasetsRef,
61101    needAppearances,
61102    changes
61103  });
61104  if (hasXfa) {
61105    updateXFA({
61106      xfaData,
61107      xfaDatasetsRef,
61108      changes,
61109      xref
61110    });
61111  }
61112  const newXref = getTrailerDict(xrefInfo, changes, useXrefStream);
61113  const buffer = [];
61114  const newRefs = await writeChanges(changes, xref, buffer);
61115  let baseOffset = originalData.length;
61116  const lastByte = originalData.at(-1);
61117  if (lastByte !== 0x0a && lastByte !== 0x0d) {
61118    buffer.push("\n");
61119    baseOffset += 1;
61120  }
61121  for (const {
61122    data
61123  } of newRefs) {
61124    if (data !== null) {
61125      buffer.push(data);
61126    }
61127  }
61128  await (useXrefStream ? getXRefStreamTable(xrefInfo, baseOffset, newRefs, newXref, buffer) : getXRefTable(xrefInfo, baseOffset, newRefs, newXref, buffer));
61129  const totalLength = originalData.length + Math.sumPrecise(buffer.map(str => str.length));
61130  const array = new Uint8Array(totalLength);
61131  array.set(originalData);
61132  let offset = originalData.length;
61133  for (const str of buffer) {
61134    offset = writeString(str, offset, array);
61135  }
61136  return array;
61137}
61138
61139;// ./src/core/editor/pdf_editor.js
61140
61141
61142
61143
61144
61145
61146
61147
61148
61149
61150
61151
61152const MAX_LEAVES_PER_PAGES_NODE = 16;
61153const MAX_IN_NAME_TREE_NODE = 64;
61154class PageData {
61155  constructor(page, documentData) {
61156    this.page = page;
61157    this.documentData = documentData;
61158    this.annotations = null;
61159    this.pointingNamedDestinations = null;
61160    documentData.pagesMap.put(page.ref, this);
61161  }
61162}
61163class DocumentData {
61164  constructor(document) {
61165    this.document = document;
61166    this.destinations = null;
61167    this.pageLabels = null;
61168    this.pagesMap = new RefSetCache();
61169    this.oldRefMapping = new RefSetCache();
61170    this.dedupNamedDestinations = new Map();
61171    this.usedNamedDestinations = new Set();
61172    this.postponedRefCopies = new RefSetCache();
61173    this.resourceStreamPromises = new Map();
61174    this.usedStructParents = new Set();
61175    this.oldStructParentMapping = new Map();
61176    this.structTreeRoot = null;
61177    this.parentTree = null;
61178    this.idTree = null;
61179    this.roleMap = null;
61180    this.classMap = null;
61181    this.namespaces = null;
61182    this.structTreeAF = null;
61183    this.structTreePronunciationLexicon = [];
61184    this.acroForm = null;
61185    this.acroFormDefaultAppearance = "";
61186    this.acroFormDefaultResources = null;
61187    this.acroFormQ = 0;
61188    this.hasSignatureAnnotations = false;
61189    this.fieldToParent = new RefSetCache();
61190    this.outline = null;
61191    this.embeddedFiles = null;
61192  }
61193}
61194class XRefWrapper {
61195  constructor(entries, getNewRef) {
61196    this.entries = entries;
61197    this._getNewRef = getNewRef;
61198  }
61199  getNewTemporaryRef() {
61200    return this._getNewRef();
61201  }
61202  fetchIfRef(obj) {
61203    return obj instanceof Ref ? this.fetch(obj) : obj;
61204  }
61205  fetch(ref) {
61206    if (!(ref instanceof Ref)) {
61207      throw new Error("ref object is not a reference");
61208    }
61209    return this.entries[ref.num];
61210  }
61211  async fetchIfRefAsync(obj) {
61212    return obj instanceof Ref ? this.fetchAsync(obj) : obj;
61213  }
61214  async fetchAsync(ref) {
61215    return this.fetch(ref);
61216  }
61217}
61218class PDFEditor {
61219  isSingleFile = false;
61220  #newAnnotationsParams = null;
61221  #primaryDocument = null;
61222  #resourceStreamCache = new Map();
61223  currentDocument = null;
61224  oldPages = [];
61225  newPages = [];
61226  xref = [null];
61227  xrefWrapper = new XRefWrapper(this.xref, () => this.newRef);
61228  newRefCount = 1;
61229  namesDict = null;
61230  version = "1.7";
61231  pageLabels = null;
61232  namedDestinations = new Map();
61233  parentTree = new Map();
61234  structTreeKids = [];
61235  idTree = new Map();
61236  classMap = new Dict();
61237  roleMap = new Dict();
61238  namespaces = new Map();
61239  structTreeAF = [];
61240  structTreePronunciationLexicon = [];
61241  fields = [];
61242  acroFormDefaultAppearance = "";
61243  acroFormDefaultResources = null;
61244  acroFormNeedAppearances = false;
61245  acroFormSigFlags = 0;
61246  acroFormCalculationOrder = null;
61247  acroFormQ = 0;
61248  outlineItems = null;
61249  embeddedFiles = new Map();
61250  constructor({
61251    useObjectStreams = true,
61252    title = "",
61253    author = ""
61254  } = {}) {
61255    [this.rootRef, this.rootDict] = this.newDict;
61256    [this.infoRef, this.infoDict] = this.newDict;
61257    [this.pagesRef, this.pagesDict] = this.newDict;
61258    this.useObjectStreams = useObjectStreams;
61259    this.objStreamRefs = useObjectStreams ? new Set() : null;
61260    this.title = title;
61261    this.author = author;
61262  }
61263  get newRef() {
61264    return Ref.get(this.newRefCount++, 0);
61265  }
61266  get newDict() {
61267    const ref = this.newRef;
61268    const dict = this.xref[ref.num] = new Dict();
61269    return [ref, dict];
61270  }
61271  async #cloneObject(obj, xref) {
61272    const ref = this.newRef;
61273    this.xref[ref.num] = await this.#collectDependencies(obj, true, xref);
61274    return ref;
61275  }
61276  cloneDict(dict) {
61277    const newDict = dict.clone();
61278    newDict.xref = this.xrefWrapper;
61279    return newDict;
61280  }
61281  async #collectDependencies(obj, mustClone, xref, resourceStreamPath = new RefSet()) {
61282    if (obj instanceof Ref) {
61283      const {
61284        currentDocument: {
61285          oldRefMapping
61286        }
61287      } = this;
61288      const existingRef = oldRefMapping.get(obj);
61289      if (existingRef) {
61290        return existingRef;
61291      }
61292      const oldRef = obj;
61293      obj = await xref.fetchAsync(oldRef);
61294      if (typeof obj === "number") {
61295        return obj;
61296      }
61297      if (obj instanceof BaseStream && this.#isResourceStream(obj.dict)) {
61298        return this.#collectResourceStream(oldRef, obj, xref, resourceStreamPath);
61299      }
61300      const newRef = this.newRef;
61301      oldRefMapping.put(oldRef, newRef);
61302      this.xref[newRef.num] = await this.#collectDependencies(obj, true, xref, resourceStreamPath);
61303      return newRef;
61304    }
61305    const promises = [];
61306    const {
61307      currentDocument: {
61308        postponedRefCopies
61309      }
61310    } = this;
61311    if (Array.isArray(obj)) {
61312      if (mustClone) {
61313        obj = obj.slice();
61314      }
61315      for (let i = 0, ii = obj.length; i < ii; i++) {
61316        const postponedActions = obj[i] instanceof Ref && postponedRefCopies.get(obj[i]);
61317        if (postponedActions) {
61318          postponedActions.push(ref => obj[i] = ref);
61319          continue;
61320        }
61321        promises.push(this.#collectDependencies(obj[i], true, xref, resourceStreamPath).then(newObj => obj[i] = newObj));
61322      }
61323      await Promise.all(promises);
61324      return obj;
61325    }
61326    let dict;
61327    if (obj instanceof BaseStream) {
61328      ({
61329        dict
61330      } = obj = obj.getOriginalStream().clone());
61331      dict.xref = this.xrefWrapper;
61332    } else if (obj instanceof Dict) {
61333      if (mustClone) {
61334        obj = obj.clone();
61335        obj.xref = this.xrefWrapper;
61336      }
61337      dict = obj;
61338    }
61339    if (dict) {
61340      for (const [key, rawObj] of dict.getRawEntries()) {
61341        const postponedActions = rawObj instanceof Ref && postponedRefCopies.get(rawObj);
61342        if (postponedActions) {
61343          postponedActions.push(ref => dict.set(key, ref));
61344          continue;
61345        }
61346        promises.push(this.#collectDependencies(rawObj, true, xref, resourceStreamPath).then(newObj => dict.set(key, newObj)));
61347      }
61348      await Promise.all(promises);
61349    }
61350    return obj;
61351  }
61352  #isResourceStream(dict) {
61353    const subtype = dict.get("Subtype");
61354    return isName(subtype, "Image") || dict.has("Length1") || isName(subtype, "Type1C") || isName(subtype, "CIDFontType0C") || isName(subtype, "OpenType");
61355  }
61356  #rawStreamBytes(stream) {
61357    const original = stream.getOriginalStream();
61358    original.reset();
61359    return original.getBytes();
61360  }
61361  async #serializeDict(dict) {
61362    const buffer = [];
61363    await writeValue(dict, buffer, null);
61364    return buffer.join("");
61365  }
61366  #resourceStreamKey(dictStr, bytes) {
61367    const SAMPLE_SIZE = 256;
61368    const SAMPLE_COUNT = 4;
61369    const {
61370      length
61371    } = bytes;
61372    const hash = new MurmurHash3_64();
61373    hash.update(dictStr);
61374    hash.update(`#${length}`);
61375    if (length <= SAMPLE_SIZE * SAMPLE_COUNT) {
61376      hash.update(bytes);
61377    } else {
61378      const step = Math.floor((length - SAMPLE_SIZE) / (SAMPLE_COUNT - 1));
61379      for (let i = 0; i < SAMPLE_COUNT; i++) {
61380        const start = Math.min(i * step, length - SAMPLE_SIZE);
61381        hash.update(bytes.subarray(start, start + SAMPLE_SIZE));
61382      }
61383    }
61384    return hash.hexdigest();
61385  }
61386  async #collectResourceStream(oldRef, stream, xref, resourceStreamPath) {
61387    const {
61388      currentDocument: {
61389        oldRefMapping,
61390        resourceStreamPromises
61391      }
61392    } = this;
61393    if (resourceStreamPath.has(oldRef)) {
61394      let ref = oldRefMapping.get(oldRef);
61395      if (!ref) {
61396        ref = this.newRef;
61397        oldRefMapping.put(oldRef, ref);
61398      }
61399      return ref;
61400    }
61401    const key = oldRef.toString();
61402    const pending = resourceStreamPromises.get(key);
61403    if (pending) {
61404      return pending;
61405    }
61406    const childPath = new RefSet(resourceStreamPath);
61407    childPath.put(oldRef);
61408    const promise = Promise.resolve().then(async () => {
61409      const collected = await this.#collectDependencies(stream, true, xref, childPath);
61410      const cycleRef = oldRefMapping.get(oldRef);
61411      if (cycleRef) {
61412        this.xref[cycleRef.num] = collected;
61413        return cycleRef;
61414      }
61415      const ref = await this.#dedupResourceStream(collected);
61416      oldRefMapping.put(oldRef, ref);
61417      return ref;
61418    });
61419    resourceStreamPromises.set(key, promise);
61420    try {
61421      return await promise;
61422    } finally {
61423      if (resourceStreamPromises.get(key) === promise) {
61424        resourceStreamPromises.delete(key);
61425      }
61426    }
61427  }
61428  async #dedupResourceStream(stream) {
61429    const dictStr = await this.#serializeDict(stream.dict);
61430    const bytes = this.#rawStreamBytes(stream);
61431    const key = this.#resourceStreamKey(dictStr, bytes);
61432    const bucket = this.#resourceStreamCache.getOrInsertComputed(key, makeArr);
61433    for (const entry of bucket) {
61434      if (entry.dictStr === dictStr && isArrayEqual(this.#rawStreamBytes(entry.stream), bytes)) {
61435        return entry.ref;
61436      }
61437    }
61438    const ref = this.newRef;
61439    this.xref[ref.num] = stream;
61440    bucket.push({
61441      ref,
61442      dictStr,
61443      stream
61444    });
61445    return ref;
61446  }
61447  async #cloneStructTreeNode(parentStructRef, node, xref, removedStructElements, dedupIDs, dedupClasses, dedupRoles, visited = new RefSet()) {
61448    const {
61449      currentDocument: {
61450        pagesMap,
61451        oldRefMapping
61452      }
61453    } = this;
61454    const pg = node.getRaw("Pg");
61455    if (pg instanceof Ref && !pagesMap.has(pg)) {
61456      return null;
61457    }
61458    let kids;
61459    const k = kids = node.getRaw("K");
61460    if (k instanceof Ref) {
61461      if (visited.has(k)) {
61462        return null;
61463      }
61464      kids = await xref.fetchAsync(k);
61465      if (!Array.isArray(kids)) {
61466        kids = [k];
61467      }
61468    }
61469    kids = Array.isArray(kids) ? kids : [kids];
61470    const newKids = [];
61471    const structElemIndices = [];
61472    for (let kid of kids) {
61473      const kidRef = kid instanceof Ref ? kid : null;
61474      if (kidRef) {
61475        if (visited.has(kidRef)) {
61476          continue;
61477        }
61478        visited.put(kidRef);
61479        kid = await xref.fetchAsync(kidRef);
61480      }
61481      if (typeof kid === "number") {
61482        newKids.push(kid);
61483        continue;
61484      }
61485      if (!(kid instanceof Dict)) {
61486        continue;
61487      }
61488      const pgRef = kid.getRaw("Pg");
61489      if (pgRef instanceof Ref && !pagesMap.has(pgRef)) {
61490        continue;
61491      }
61492      const type = kid.get("Type");
61493      if (!type || isName(type, "StructElem")) {
61494        let setAsSpan = false;
61495        if (kidRef && removedStructElements.has(kidRef)) {
61496          if (!isName(kid.get("S"), "Link")) {
61497            continue;
61498          }
61499          setAsSpan = true;
61500        }
61501        const newKidRef = await this.#cloneStructTreeNode(kidRef, kid, xref, removedStructElements, dedupIDs, dedupClasses, dedupRoles, visited);
61502        if (newKidRef) {
61503          structElemIndices.push(newKids.length);
61504          newKids.push(newKidRef);
61505          if (kidRef) {
61506            oldRefMapping.put(kidRef, newKidRef);
61507          }
61508          if (setAsSpan) {
61509            this.xref[newKidRef.num].setIfName("S", "Span");
61510          }
61511        }
61512        continue;
61513      }
61514      if (isName(type, "OBJR")) {
61515        if (!kidRef) {
61516          continue;
61517        }
61518        const newKidRef = oldRefMapping.get(kidRef);
61519        if (!newKidRef) {
61520          continue;
61521        }
61522        const newKid = this.xref[newKidRef.num];
61523        const objRef = newKid.getRaw("Obj");
61524        if (objRef instanceof Ref) {
61525          const obj = this.xref[objRef.num];
61526          if (obj instanceof Dict && !obj.has("StructParent") && parentStructRef) {
61527            const structParent = this.parentTree.size;
61528            this.parentTree.set(structParent, [oldRefMapping, parentStructRef]);
61529            obj.set("StructParent", structParent);
61530          }
61531        }
61532        newKids.push(newKidRef);
61533        continue;
61534      }
61535      if (isName(type, "MCR")) {
61536        const newKid = await this.#collectDependencies(kidRef || kid, true, xref);
61537        newKids.push(newKid);
61538        continue;
61539      }
61540      if (kidRef) {
61541        const newKidRef = await this.#collectDependencies(kidRef, true, xref);
61542        newKids.push(newKidRef);
61543      }
61544    }
61545    if (kids.length !== 0 && newKids.length === 0) {
61546      return null;
61547    }
61548    const newNodeRef = this.newRef;
61549    const newNode = this.xref[newNodeRef.num] = this.cloneDict(node);
61550    newNode.delete("ID");
61551    newNode.delete("C");
61552    newNode.delete("K");
61553    newNode.delete("P");
61554    newNode.delete("S");
61555    await this.#collectDependencies(newNode, false, xref);
61556    const classNames = node.get("C");
61557    if (classNames instanceof Name) {
61558      const newClassName = dedupClasses.get(classNames.name);
61559      newNode.set("C", newClassName ? Name.get(newClassName) : classNames);
61560    } else if (Array.isArray(classNames)) {
61561      const newClassNames = [];
61562      for (const className of classNames) {
61563        if (className instanceof Name) {
61564          const newClassName = dedupClasses.get(className.name);
61565          newClassNames.push(newClassName ? Name.get(newClassName) : className);
61566        }
61567      }
61568      newNode.set("C", newClassNames);
61569    }
61570    const roleName = node.get("S");
61571    if (roleName instanceof Name) {
61572      const newRoleName = dedupRoles.get(roleName.name);
61573      newNode.set("S", newRoleName ? Name.get(newRoleName) : roleName);
61574    }
61575    const id = node.get("ID");
61576    if (typeof id === "string") {
61577      const stringId = stringToPDFString(id, false);
61578      const newId = dedupIDs.get(stringId);
61579      newNode.set("ID", newId ? stringToAsciiOrUTF16BE(newId) : id);
61580    }
61581    let attributes = newNode.get("A");
61582    if (attributes) {
61583      if (!Array.isArray(attributes)) {
61584        attributes = [attributes];
61585      }
61586      for (let attr of attributes) {
61587        attr = this.xrefWrapper.fetchIfRef(attr);
61588        if (isName(attr.get("O"), "Table") && attr.has("Headers")) {
61589          const headers = this.xrefWrapper.fetchIfRef(attr.getRaw("Headers"));
61590          if (Array.isArray(headers)) {
61591            for (let i = 0, ii = headers.length; i < ii; i++) {
61592              const newId = dedupIDs.get(stringToPDFString(headers[i], false));
61593              if (newId) {
61594                headers[i] = newId;
61595              }
61596            }
61597          }
61598        }
61599      }
61600    }
61601    for (const index of structElemIndices) {
61602      const structElemRef = newKids[index];
61603      const structElem = this.xref[structElemRef.num];
61604      structElem.set("P", newNodeRef);
61605    }
61606    if (newKids.length === 1) {
61607      newNode.set("K", newKids[0]);
61608    } else if (newKids.length > 1) {
61609      newNode.set("K", newKids);
61610    }
61611    return newNodeRef;
61612  }
61613  #getFilteredPageIndices({
61614    document,
61615    includePages,
61616    excludePages
61617  }) {
61618    if (!document) {
61619      return [];
61620    }
61621    const compile = list => {
61622      if (!list?.length) {
61623        return null;
61624      }
61625      const indices = new Set();
61626      const ranges = [];
61627      for (const item of list) {
61628        if (Array.isArray(item)) {
61629          ranges.push(item);
61630        } else {
61631          indices.add(item);
61632        }
61633      }
61634      return {
61635        indices,
61636        ranges
61637      };
61638    };
61639    const matches = (index, {
61640      indices,
61641      ranges
61642    }) => indices.has(index) || ranges.some(([start, end]) => index >= start && index <= end);
61643    const inc = compile(includePages);
61644    const exc = compile(excludePages);
61645    const result = [];
61646    for (let i = 0, ii = document.numPages; i < ii; i++) {
61647      if (exc && matches(i, exc)) {
61648        continue;
61649      }
61650      if (!inc || matches(i, inc)) {
61651        result.push(i);
61652      }
61653    }
61654    return result;
61655  }
61656  #resolveInsertAfterIndices(pageInfos) {
61657    const counts = new Array(pageInfos.length);
61658    const sequence = [];
61659    const insertAfterList = [];
61660    for (let i = 0; i < pageInfos.length; i++) {
61661      const info = pageInfos[i];
61662      let count;
61663      if (info.image) {
61664        count = counts[i] = 1;
61665      } else if (!info.document) {
61666        counts[i] = 0;
61667        continue;
61668      } else {
61669        count = counts[i] = this.#getFilteredPageIndices(info).length;
61670      }
61671      if (info.pageIndices) {
61672        continue;
61673      }
61674      if (info.insertAfter === undefined) {
61675        for (let j = 0; j < count; j++) {
61676          sequence.push(i);
61677        }
61678      } else {
61679        insertAfterList.push({
61680          i,
61681          insertAfter: info.insertAfter,
61682          count
61683        });
61684      }
61685    }
61686    if (insertAfterList.length === 0) {
61687      return pageInfos;
61688    }
61689    const hasContent = info => !!(info.document || info.image);
61690    for (let i = 0; i < pageInfos.length; i++) {
61691      const info = pageInfos[i];
61692      if (hasContent(info) && info.pageIndices && info.pageIndices.length < counts[i]) {
61693        throw new Error("extractPages: partial pageIndices cannot be combined with insertAfter entries.");
61694      }
61695    }
61696    insertAfterList.sort((a, b) => a.insertAfter - b.insertAfter || a.i - b.i);
61697    if (sequence.length === 0 && pageInfos.some(info => hasContent(info) && info.pageIndices)) {
61698      const updatedPageInfos = pageInfos.slice();
61699      let maxExistingPos = -1;
61700      for (const info of pageInfos) {
61701        if (!hasContent(info) || !info.pageIndices) {
61702          continue;
61703        }
61704        for (const idx of info.pageIndices) {
61705          if (idx > maxExistingPos) {
61706            maxExistingPos = idx;
61707          }
61708        }
61709      }
61710      let offset = 0;
61711      for (const {
61712        i,
61713        insertAfter,
61714        count
61715      } of insertAfterList) {
61716        const threshold = Math.min(Math.max(insertAfter, -1) + offset, maxExistingPos);
61717        for (let j = 0; j < updatedPageInfos.length; j++) {
61718          const existingInfo = updatedPageInfos[j];
61719          if (!hasContent(existingInfo) || !existingInfo.pageIndices || existingInfo.pageIndices.every(idx => idx <= threshold)) {
61720            continue;
61721          }
61722          updatedPageInfos[j] = {
61723            ...existingInfo,
61724            pageIndices: existingInfo.pageIndices.map(idx => idx > threshold ? idx + count : idx)
61725          };
61726        }
61727        const pageIndices = [];
61728        for (let k = 0; k < count; k++) {
61729          pageIndices.push(threshold + 1 + k);
61730        }
61731        const result = {
61732          ...updatedPageInfos[i],
61733          pageIndices
61734        };
61735        delete result.insertAfter;
61736        updatedPageInfos[i] = result;
61737        offset += count;
61738        maxExistingPos += count;
61739      }
61740      return updatedPageInfos;
61741    }
61742    let offset = 0;
61743    for (const {
61744      i,
61745      insertAfter,
61746      count
61747    } of insertAfterList) {
61748      const insertPos = Math.max(insertAfter, -1) + 1 + offset;
61749      sequence.splice(insertPos, 0, ...new Array(count).fill(i));
61750      offset += count;
61751    }
61752    const pageIndicesArr = new Array(pageInfos.length);
61753    for (let pos = 0; pos < sequence.length; pos++) {
61754      const infoIdx = sequence[pos];
61755      (pageIndicesArr[infoIdx] ||= []).push(pos);
61756    }
61757    return pageInfos.map((info, i) => {
61758      if (!hasContent(info) || info.pageIndices) {
61759        return info;
61760      }
61761      const result = {
61762        ...info,
61763        pageIndices: pageIndicesArr[i] || []
61764      };
61765      delete result.insertAfter;
61766      return result;
61767    });
61768  }
61769  async extractPages(pageInfos, annotationStorage, primaryDocument, handler, task) {
61770    this.#primaryDocument = primaryDocument;
61771    pageInfos = this.#resolveInsertAfterIndices(pageInfos);
61772    const promises = [];
61773    let newIndex = 0;
61774    const reservePageSlot = newPageIndex => {
61775      if (!Number.isInteger(newPageIndex) || newPageIndex < 0) {
61776        throw new Error("extractPages: invalid page index.");
61777      }
61778      if (this.oldPages[newPageIndex] !== undefined) {
61779        throw new Error("extractPages: overlapping pageIndices.");
61780      }
61781      this.oldPages[newPageIndex] = null;
61782    };
61783    const docPageInfos = pageInfos.filter(info => !!info.document);
61784    this.isSingleFile = docPageInfos.length === 1 || docPageInfos.length > 0 && docPageInfos.every(info => info.document === docPageInfos[0].document);
61785    const allDocumentData = [];
61786    if (annotationStorage) {
61787      this.#newAnnotationsParams = {
61788        handler,
61789        task,
61790        newAnnotationsByPage: getNewAnnotationsMap(annotationStorage),
61791        imagesPromises: AnnotationFactory.generateImages(annotationStorage.values(), this.xrefWrapper, true)
61792      };
61793    }
61794    const imageEntries = [];
61795    for (const pageInfo of pageInfos) {
61796      const {
61797        document,
61798        image,
61799        includePages,
61800        excludePages,
61801        pageIndices
61802      } = pageInfo;
61803      if (image) {
61804        if (pageIndices) {
61805          newIndex = -1;
61806          if (pageIndices.length > 1) {
61807            throw new Error("extractPages: too many pageIndices.");
61808          }
61809        }
61810        let newPageIndex;
61811        if (pageIndices?.length) {
61812          newPageIndex = pageIndices[0];
61813        } else if (newIndex !== -1) {
61814          newPageIndex = newIndex++;
61815        } else {
61816          for (newPageIndex = 0; this.oldPages[newPageIndex] !== undefined; newPageIndex++) {}
61817        }
61818        reservePageSlot(newPageIndex);
61819        imageEntries.push({
61820          image,
61821          slot: newPageIndex
61822        });
61823        continue;
61824      }
61825      if (!document) {
61826        continue;
61827      }
61828      if (pageIndices) {
61829        newIndex = -1;
61830      }
61831      const filteredPageIndices = this.#getFilteredPageIndices({
61832        document,
61833        includePages,
61834        excludePages
61835      });
61836      if (pageIndices && pageIndices.length > filteredPageIndices.length) {
61837        throw new Error("extractPages: too many pageIndices.");
61838      }
61839      const documentData = new DocumentData(document);
61840      allDocumentData.push(documentData);
61841      promises.push(this.#collectDocumentData(documentData));
61842      let pageIndex = 0;
61843      for (const i of filteredPageIndices) {
61844        let newPageIndex;
61845        if (pageIndices) {
61846          newPageIndex = pageIndices[pageIndex++];
61847        }
61848        if (newPageIndex === undefined) {
61849          if (newIndex !== -1) {
61850            newPageIndex = newIndex++;
61851          } else {
61852            for (newPageIndex = 0; this.oldPages[newPageIndex] !== undefined; newPageIndex++) {}
61853          }
61854        }
61855        reservePageSlot(newPageIndex);
61856        promises.push(document.getPage(i).then(page => {
61857          this.oldPages[newPageIndex] = new PageData(page, documentData);
61858        }));
61859      }
61860    }
61861    await Promise.all(promises);
61862    for (let i = 0, ii = this.oldPages.length; i < ii; i++) {
61863      if (this.oldPages[i] === undefined) {
61864        throw new Error("extractPages: sparse pageIndices.");
61865      }
61866    }
61867    promises.length = 0;
61868    this.#collectValidDestinations(allDocumentData);
61869    this.#collectOutlineDestinations(allDocumentData);
61870    this.#collectPageLabels();
61871    for (const page of this.oldPages) {
61872      if (page) {
61873        promises.push(this.#postCollectPageData(page));
61874      }
61875    }
61876    await Promise.all(promises);
61877    this.#findDuplicateNamedDestinations();
61878    this.#setPostponedRefCopies(allDocumentData);
61879    const imageSlots = new Map();
61880    for (const entry of imageEntries) {
61881      imageSlots.set(entry.slot, entry);
61882    }
61883    const modalPageSize = imageSlots.size > 0 ? this.#modalPageSize() : null;
61884    for (let i = 0, ii = this.oldPages.length; i < ii; i++) {
61885      const imageEntry = imageSlots.get(i);
61886      if (imageEntry) {
61887        this.newPages[i] = await this.#makeImagePage(imageEntry.image, modalPageSize);
61888      } else {
61889        this.newPages[i] = await this.#makePageCopy(i, null);
61890      }
61891    }
61892    this.#fixPostponedRefCopies(allDocumentData);
61893    await this.#mergeStructTrees(allDocumentData);
61894    await this.#mergeAcroForms(allDocumentData);
61895    this.#buildOutline(allDocumentData);
61896    await this.#collectEmbeddedFiles(allDocumentData);
61897    return this.writePDF();
61898  }
61899  async #collectDocumentData(documentData) {
61900    const {
61901      document: {
61902        pdfManager,
61903        xref
61904      }
61905    } = documentData;
61906    await Promise.all([pdfManager.ensureCatalog("destinations").then(destinations => documentData.destinations = destinations), pdfManager.ensureCatalog("rawPageLabels").then(pageLabels => documentData.pageLabels = pageLabels), pdfManager.ensureCatalog("structTreeRoot").then(structTreeRoot => documentData.structTreeRoot = structTreeRoot), pdfManager.ensureCatalog("acroForm").then(acroForm => documentData.acroForm = acroForm), pdfManager.ensureCatalog("documentOutlineForEditor").then(outline => documentData.outline = outline), pdfManager.ensureCatalog("rawEmbeddedFiles").then(ef => documentData.embeddedFiles = ef)]);
61907    const structTreeRoot = documentData.structTreeRoot;
61908    if (structTreeRoot) {
61909      const rootDict = structTreeRoot.dict;
61910      const parentTree = rootDict.get("ParentTree");
61911      if (parentTree) {
61912        const numberTree = new NumberTree(parentTree, xref);
61913        documentData.parentTree = numberTree.getAll(true);
61914      }
61915      const idTree = rootDict.get("IDTree");
61916      if (idTree) {
61917        const nameTree = new NameTree(idTree, xref);
61918        documentData.idTree = nameTree.getAll(true);
61919      }
61920      documentData.roleMap = rootDict.get("RoleMap") || null;
61921      documentData.classMap = rootDict.get("ClassMap") || null;
61922      let namespaces = rootDict.get("Namespaces") || null;
61923      if (namespaces && !Array.isArray(namespaces)) {
61924        namespaces = [namespaces];
61925      }
61926      documentData.namespaces = namespaces;
61927      documentData.structTreeAF = rootDict.get("AF") || null;
61928      documentData.structTreePronunciationLexicon = rootDict.get("PronunciationLexicon") || null;
61929    }
61930  }
61931  async #postCollectPageData(pageData) {
61932    const {
61933      page: {
61934        xref,
61935        annotations
61936      },
61937      documentData: {
61938        pagesMap,
61939        destinations,
61940        usedNamedDestinations,
61941        fieldToParent
61942      }
61943    } = pageData;
61944    if (!annotations) {
61945      return;
61946    }
61947    const promises = [];
61948    let newAnnotations = [];
61949    let newIndex = 0;
61950    let {
61951      hasSignatureAnnotations
61952    } = pageData.documentData;
61953    for (const annotationRef of annotations) {
61954      const newAnnotationIndex = newIndex++;
61955      promises.push(xref.fetchIfRefAsync(annotationRef).then(async annotationDict => {
61956        if (!isName(annotationDict.get("Subtype"), "Link")) {
61957          if (isName(annotationDict.get("Subtype"), "Widget")) {
61958            hasSignatureAnnotations ||= isName(annotationDict.get("FT"), "Sig");
61959            const parentRef = annotationDict.get("Parent") || null;
61960            annotationDict.delete("Parent");
61961            fieldToParent.put(annotationRef, parentRef);
61962          }
61963          newAnnotations[newAnnotationIndex] = annotationRef;
61964          return;
61965        }
61966        const action = annotationDict.get("A");
61967        const dest = action instanceof Dict ? action.get("D") : annotationDict.get("Dest");
61968        if (!dest || Array.isArray(dest) && (!(dest[0] instanceof Ref) || pagesMap.has(dest[0]))) {
61969          newAnnotations[newAnnotationIndex] = annotationRef;
61970        } else if (typeof dest === "string") {
61971          const destString = stringToPDFString(dest, true);
61972          if (destinations.has(destString)) {
61973            newAnnotations[newAnnotationIndex] = annotationRef;
61974            usedNamedDestinations.add(destString);
61975          }
61976        }
61977      }));
61978    }
61979    await Promise.all(promises);
61980    newAnnotations = newAnnotations.filter(annot => !!annot);
61981    pageData.annotations = newAnnotations.length > 0 ? newAnnotations : null;
61982    pageData.documentData.hasSignatureAnnotations ||= hasSignatureAnnotations;
61983  }
61984  #setPostponedRefCopies(allDocumentData) {
61985    for (const {
61986      postponedRefCopies,
61987      pagesMap
61988    } of allDocumentData) {
61989      for (const oldPageRef of pagesMap.keys()) {
61990        postponedRefCopies.put(oldPageRef, []);
61991      }
61992    }
61993  }
61994  #fixPostponedRefCopies(allDocumentData) {
61995    for (const {
61996      postponedRefCopies,
61997      oldRefMapping
61998    } of allDocumentData) {
61999      for (const [oldRef, actions] of postponedRefCopies.items()) {
62000        const newRef = oldRefMapping.get(oldRef);
62001        for (const action of actions) {
62002          action(newRef);
62003        }
62004      }
62005      postponedRefCopies.clear();
62006    }
62007  }
62008  #visitObject(obj, callback, visited = new RefSet()) {
62009    if (obj instanceof Ref) {
62010      if (!visited.has(obj)) {
62011        visited.put(obj);
62012        this.#visitObject(this.xref[obj.num], callback, visited);
62013      }
62014      return;
62015    }
62016    if (Array.isArray(obj)) {
62017      for (const item of obj) {
62018        this.#visitObject(item, callback, visited);
62019      }
62020      return;
62021    }
62022    let dict;
62023    if (obj instanceof BaseStream) {
62024      ({
62025        dict
62026      } = obj);
62027    } else if (obj instanceof Dict) {
62028      dict = obj;
62029    }
62030    if (dict) {
62031      callback(dict);
62032      for (const value of dict.getRawValues()) {
62033        this.#visitObject(value, callback, visited);
62034      }
62035    }
62036  }
62037  async #mergeStructTrees(allDocumentData) {
62038    let newStructParentId = 0;
62039    const {
62040      parentTree: newParentTree
62041    } = this;
62042    for (let i = 0, ii = this.newPages.length; i < ii; i++) {
62043      if (!this.oldPages[i]) {
62044        continue;
62045      }
62046      const {
62047        documentData: {
62048          parentTree,
62049          oldRefMapping,
62050          oldStructParentMapping,
62051          usedStructParents,
62052          document: {
62053            xref
62054          }
62055        }
62056      } = this.oldPages[i];
62057      if (!parentTree) {
62058        continue;
62059      }
62060      const pageRef = this.newPages[i];
62061      const pageDict = this.xref[pageRef.num];
62062      const visited = new RefSet();
62063      visited.put(pageRef);
62064      this.#visitObject(pageDict, dict => {
62065        const structParent = dict.get("StructParent") ?? dict.get("StructParents");
62066        if (typeof structParent !== "number") {
62067          return;
62068        }
62069        usedStructParents.add(structParent);
62070        let parent = parentTree.get(structParent);
62071        const parentRef = parent instanceof Ref ? parent : null;
62072        if (parentRef) {
62073          const array = xref.fetch(parentRef);
62074          if (Array.isArray(array)) {
62075            parent = array;
62076          }
62077        }
62078        if (Array.isArray(parent) && parent.every(ref => ref === null)) {
62079          parent = null;
62080        }
62081        if (!parent) {
62082          if (dict.has("StructParent")) {
62083            dict.delete("StructParent");
62084          } else {
62085            dict.delete("StructParents");
62086          }
62087          return;
62088        }
62089        let newStructParent = oldStructParentMapping.get(structParent);
62090        if (newStructParent === undefined) {
62091          newStructParent = newStructParentId++;
62092          oldStructParentMapping.set(structParent, newStructParent);
62093          newParentTree.set(newStructParent, [oldRefMapping, parent]);
62094        }
62095        if (dict.has("StructParent")) {
62096          dict.set("StructParent", newStructParent);
62097        } else {
62098          dict.set("StructParents", newStructParent);
62099        }
62100      }, visited);
62101    }
62102    const {
62103      structTreeKids,
62104      idTree: newIdTree,
62105      classMap: newClassMap,
62106      roleMap: newRoleMap,
62107      namespaces: newNamespaces,
62108      structTreeAF: newStructTreeAF,
62109      structTreePronunciationLexicon: newStructTreePronunciationLexicon
62110    } = this;
62111    for (const documentData of allDocumentData) {
62112      const {
62113        document: {
62114          xref
62115        },
62116        oldRefMapping,
62117        parentTree,
62118        usedStructParents,
62119        structTreeRoot,
62120        idTree,
62121        classMap,
62122        roleMap,
62123        namespaces,
62124        structTreeAF,
62125        structTreePronunciationLexicon
62126      } = documentData;
62127      if (!structTreeRoot) {
62128        continue;
62129      }
62130      this.currentDocument = documentData;
62131      const removedStructElements = new RefSet();
62132      for (const [key, value] of parentTree || []) {
62133        if (!usedStructParents.has(key) && value instanceof Ref) {
62134          removedStructElements.put(value);
62135        }
62136      }
62137      const dedupIDs = new Map();
62138      for (const [id, nodeRef] of idTree || []) {
62139        let _id = id;
62140        if (newIdTree.has(id)) {
62141          for (let i = 1;; i++) {
62142            const newId = `${id}_${i}`;
62143            if (!newIdTree.has(newId)) {
62144              dedupIDs.set(id, newId);
62145              _id = newId;
62146              break;
62147            }
62148          }
62149        }
62150        newIdTree.set(_id, nodeRef);
62151      }
62152      const dedupClasses = new Map();
62153      if (classMap?.size > 0) {
62154        for (let [className, classDict] of classMap) {
62155          classDict = await this.#collectDependencies(classDict, true, xref);
62156          if (newClassMap.has(className)) {
62157            for (let i = 1;; i++) {
62158              const newClassName = `${className}_${i}`;
62159              if (!newClassMap.has(newClassName)) {
62160                dedupClasses.set(className, newClassName);
62161                className = newClassName;
62162                break;
62163              }
62164            }
62165          }
62166          newClassMap.set(className, classDict);
62167        }
62168      }
62169      const dedupRoles = new Map();
62170      if (roleMap?.size > 0) {
62171        for (const [roleName, mappedName] of roleMap) {
62172          const newMappedName = newRoleMap.get(roleName);
62173          if (!newMappedName) {
62174            newRoleMap.set(roleName, mappedName);
62175            continue;
62176          }
62177          if (newMappedName === mappedName) {
62178            continue;
62179          }
62180          for (let i = 1;; i++) {
62181            const newRoleName = `${roleName}_${i}`;
62182            if (!newRoleMap.has(newRoleName)) {
62183              dedupRoles.set(roleName, newRoleName);
62184              newRoleMap.set(newRoleName, mappedName);
62185              break;
62186            }
62187          }
62188        }
62189      }
62190      if (namespaces?.length > 0) {
62191        for (const namespaceRef of namespaces) {
62192          const namespace = await xref.fetchIfRefAsync(namespaceRef);
62193          let ns = namespace.get("NS");
62194          if (!ns || newNamespaces.has(ns)) {
62195            continue;
62196          }
62197          ns = stringToPDFString(ns, false);
62198          const newNamespace = await this.#collectDependencies(namespace, true, xref);
62199          newNamespaces.set(ns, newNamespace);
62200        }
62201      }
62202      if (structTreeAF) {
62203        for (const afRef of structTreeAF) {
62204          newStructTreeAF.push(await this.#collectDependencies(afRef, true, xref));
62205        }
62206      }
62207      if (structTreePronunciationLexicon) {
62208        for (const lexiconRef of structTreePronunciationLexicon) {
62209          newStructTreePronunciationLexicon.push(await this.#collectDependencies(lexiconRef, true, xref));
62210        }
62211      }
62212      let kids = structTreeRoot.dict.get("K");
62213      if (!kids) {
62214        continue;
62215      }
62216      kids = Array.isArray(kids) ? kids : [kids];
62217      for (let kid of kids) {
62218        const kidRef = kid instanceof Ref ? kid : null;
62219        if (kidRef && removedStructElements.has(kidRef)) {
62220          continue;
62221        }
62222        kid = await xref.fetchIfRefAsync(kid);
62223        const newKidRef = await this.#cloneStructTreeNode(kidRef, kid, xref, removedStructElements, dedupIDs, dedupClasses, dedupRoles);
62224        if (newKidRef) {
62225          structTreeKids.push(newKidRef);
62226        }
62227      }
62228      for (const [id, nodeRef] of idTree || []) {
62229        const newNodeRef = nodeRef instanceof Ref && oldRefMapping.get(nodeRef);
62230        const newId = dedupIDs.get(id) || id;
62231        if (newNodeRef) {
62232          newIdTree.set(newId, newNodeRef);
62233        } else {
62234          newIdTree.delete(newId);
62235        }
62236      }
62237    }
62238    for (const [key, [oldRefMapping, parent]] of newParentTree) {
62239      if (!parent) {
62240        newParentTree.delete(key);
62241        continue;
62242      }
62243      if (!Array.isArray(parent)) {
62244        const newParent = oldRefMapping.get(parent);
62245        if (newParent === undefined) {
62246          newParentTree.delete(key);
62247        } else {
62248          newParentTree.set(key, newParent);
62249        }
62250        continue;
62251      }
62252      const newParents = parent.map(ref => ref instanceof Ref && oldRefMapping.get(ref) || null);
62253      if (newParents.length === 0 || newParents.every(ref => ref === null)) {
62254        newParentTree.delete(key);
62255        continue;
62256      }
62257      newParentTree.set(key, newParents);
62258    }
62259    this.currentDocument = null;
62260  }
62261  #collectValidDestinations(allDocumentData) {
62262    for (const documentData of allDocumentData) {
62263      if (!documentData.destinations) {
62264        continue;
62265      }
62266      const {
62267        destinations,
62268        pagesMap
62269      } = documentData;
62270      const newDestinations = documentData.destinations = new Map();
62271      for (const [key, dest] of Object.entries(destinations)
vendor: 12,568 bytes, lines 62271-62665
62271) {
62272        const pageRef = dest[0];
62273        const pageData = pageRef instanceof Ref && pagesMap.get(pageRef);
62274        if (!pageData) {
62275          continue;
62276        }
62277        (pageData.pointingNamedDestinations ||= new Set()).add(key);
62278        newDestinations.set(key, dest);
62279      }
62280    }
62281  }
62282  #findDuplicateNamedDestinations() {
62283    const {
62284      namedDestinations
62285    } = this;
62286    const getUniqueDestinationName = name => {
62287      if (!namedDestinations.has(name)) {
62288        return name;
62289      }
62290      for (let i = 1;; i++) {
62291        const dedupedName = `${name}_${i}`;
62292        if (!namedDestinations.has(dedupedName)) {
62293          return dedupedName;
62294        }
62295      }
62296    };
62297    for (let i = 0, ii = this.oldPages.length; i < ii; i++) {
62298      const page = this.oldPages[i];
62299      if (!page) {
62300        continue;
62301      }
62302      const {
62303        documentData: {
62304          destinations,
62305          dedupNamedDestinations,
62306          usedNamedDestinations
62307        }
62308      } = page;
62309      let {
62310        pointingNamedDestinations
62311      } = page;
62312      if (!pointingNamedDestinations) {
62313        continue;
62314      }
62315      page.pointingNamedDestinations = pointingNamedDestinations = pointingNamedDestinations.intersection(usedNamedDestinations);
62316      for (const pointingDest of pointingNamedDestinations) {
62317        if (!usedNamedDestinations.has(pointingDest)) {
62318          continue;
62319        }
62320        const dest = destinations.get(pointingDest).slice();
62321        if (!namedDestinations.has(pointingDest)) {
62322          namedDestinations.set(pointingDest, dest);
62323          continue;
62324        }
62325        const newName = getUniqueDestinationName(`${pointingDest}_p${i + 1}`);
62326        dedupNamedDestinations.set(pointingDest, newName);
62327        namedDestinations.set(newName, dest);
62328      }
62329    }
62330  }
62331  #fixNamedDestinations(annotations, dedupNamedDestinations) {
62332    if (dedupNamedDestinations.size === 0) {
62333      return;
62334    }
62335    const fixDestination = (dict, key, dest) => {
62336      if (typeof dest === "string") {
62337        dict.set(key, dedupNamedDestinations.get(stringToPDFString(dest, true)) || dest);
62338      }
62339    };
62340    for (const annotRef of annotations) {
62341      const annotDict = this.xref[annotRef.num];
62342      if (!isName(annotDict.get("Subtype"), "Link")) {
62343        continue;
62344      }
62345      const action = annotDict.get("A");
62346      if (action instanceof Dict && action.has("D")) {
62347        const dest = action.get("D");
62348        fixDestination(action, "D", dest);
62349        continue;
62350      }
62351      const dest = annotDict.get("Dest");
62352      fixDestination(annotDict, "Dest", dest);
62353    }
62354  }
62355  #collectOutlineDestinations(allDocumentData) {
62356    const collect = (items, destinations, usedNamedDestinations) => {
62357      for (const item of items) {
62358        if (typeof item.dest === "string" && destinations?.has(item.dest)) {
62359          usedNamedDestinations.add(item.dest);
62360        }
62361        if (item.items.length > 0) {
62362          collect(item.items, destinations, usedNamedDestinations);
62363        }
62364      }
62365    };
62366    for (const documentData of allDocumentData) {
62367      const {
62368        outline,
62369        destinations,
62370        usedNamedDestinations
62371      } = documentData;
62372      if (outline?.length) {
62373        collect(outline, destinations, usedNamedDestinations);
62374      }
62375    }
62376  }
62377  #isValidOutlineDest(item, documentData) {
62378    const {
62379      dest,
62380      action,
62381      url,
62382      unsafeUrl,
62383      attachment,
62384      setOCGState
62385    } = item;
62386    if (action || url || unsafeUrl || attachment || setOCGState) {
62387      return true;
62388    }
62389    if (!dest) {
62390      return false;
62391    }
62392    if (typeof dest === "string") {
62393      const name = documentData.dedupNamedDestinations.get(dest) || dest;
62394      return this.namedDestinations.has(name);
62395    }
62396    if (Array.isArray(dest) && dest[0] instanceof Ref) {
62397      return !!documentData.oldRefMapping.get(dest[0]);
62398    }
62399    return false;
62400  }
62401  #filterOutlineItems(items, documentData) {
62402    const result = [];
62403    for (const item of items) {
62404      const filteredChildren = this.#filterOutlineItems(item.items, documentData);
62405      const hasValidOwnDest = this.#isValidOutlineDest(item, documentData);
62406      if (hasValidOwnDest || filteredChildren.length > 0) {
62407        result.push({
62408          ...item,
62409          dest: hasValidOwnDest ? item.dest : null,
62410          rawDict: hasValidOwnDest ? item.rawDict : null,
62411          items: filteredChildren,
62412          _documentData: documentData
62413        });
62414      }
62415    }
62416    return result;
62417  }
62418  #buildOutline(allDocumentData) {
62419    const outlineItems = [];
62420    for (const documentData of allDocumentData) {
62421      const {
62422        outline
62423      } = documentData;
62424      if (!outline?.length) {
62425        continue;
62426      }
62427      outlineItems.push(...this.#filterOutlineItems(outline, documentData));
62428    }
62429    this.outlineItems = outlineItems.length > 0 ? outlineItems : null;
62430  }
62431  async #setOutlineItemDest(itemDict, item) {
62432    const {
62433      dest,
62434      rawDict
62435    } = item;
62436    const documentData = item._documentData;
62437    if (dest) {
62438      if (typeof dest === "string") {
62439        const name = documentData.dedupNamedDestinations.get(dest) || dest;
62440        itemDict.set("Dest", stringToAsciiOrUTF16BE(name));
62441      } else if (Array.isArray(dest)) {
62442        const newDest = dest.slice();
62443        if (newDest[0] instanceof Ref) {
62444          newDest[0] = documentData.oldRefMapping.get(newDest[0]) || newDest[0];
62445        }
62446        itemDict.set("Dest", newDest);
62447      }
62448      return;
62449    }
62450    const actionDict = rawDict?.get("A");
62451    if (actionDict instanceof Dict) {
62452      this.currentDocument = documentData;
62453      const actionRef = await this.#cloneObject(actionDict, documentData.document.xref);
62454      this.currentDocument = null;
62455      itemDict.set("A", actionRef);
62456    }
62457  }
62458  async #makeOutline() {
62459    const {
62460      outlineItems
62461    } = this;
62462    if (!outlineItems?.length) {
62463      return;
62464    }
62465    const [outlineRootRef, outlineRootDict] = this.newDict;
62466    outlineRootDict.setIfName("Type", "Outlines");
62467    const assignRefs = items => {
62468      for (const item of items) {
62469        [item._ref] = this.newDict;
62470        if (item.items.length > 0) {
62471          assignRefs(item.items);
62472        }
62473      }
62474    };
62475    assignRefs(outlineItems);
62476    const fillItems = async (items, parentRef) => {
62477      let totalCount = 0;
62478      for (let i = 0; i < items.length; i++) {
62479        const item = items[i];
62480        const dict = this.xref[item._ref.num];
62481        dict.set("Title", stringToAsciiOrUTF16BE(item.title));
62482        dict.set("Parent", parentRef);
62483        if (i > 0) {
62484          dict.set("Prev", items[i - 1]._ref);
62485        }
62486        if (i < items.length - 1) {
62487          dict.set("Next", items[i + 1]._ref);
62488        }
62489        if (item.items.length > 0) {
62490          dict.set("First", item.items[0]._ref);
62491          dict.set("Last", item.items.at(-1)._ref);
62492          const childCount = await fillItems(item.items, item._ref);
62493          if (item.count !== undefined) {
62494            dict.set("Count", item.count < 0 ? -childCount : childCount);
62495          }
62496          totalCount += item.count !== undefined && item.count < 0 ? 1 : childCount + 1;
62497        } else {
62498          totalCount += 1;
62499        }
62500        await this.#setOutlineItemDest(dict, item);
62501        const flags = (item.bold ? 2 : 0) | (item.italic ? 1 : 0);
62502        if (flags !== 0) {
62503          dict.set("F", flags);
62504        }
62505        if (item.color && (item.color[0] !== 0 || item.color[1] !== 0 || item.color[2] !== 0)) {
62506          dict.set("C", [item.color[0] / 255, item.color[1] / 255, item.color[2] / 255]);
62507        }
62508      }
62509      return totalCount;
62510    };
62511    const totalCount = await fillItems(outlineItems, outlineRootRef);
62512    outlineRootDict.set("First", outlineItems[0]._ref);
62513    outlineRootDict.set("Last", outlineItems.at(-1)._ref);
62514    outlineRootDict.set("Count", totalCount);
62515    this.rootDict.set("Outlines", outlineRootRef);
62516  }
62517  async #mergeAcroForms(allDocumentData) {
62518    this.#setAcroFormDefaultBasicValues(allDocumentData);
62519    this.#setAcroFormDefaultAppearance(allDocumentData);
62520    this.#setAcroFormQ(allDocumentData);
62521    await this.#setAcroFormDefaultResources(allDocumentData);
62522    const newFields = this.fields;
62523    for (const documentData of allDocumentData) {
62524      let fields = documentData.acroForm?.get("Fields") || null;
62525      if (!fields && documentData.fieldToParent.size > 0) {
62526        fields = this.#fixFields(documentData.fieldToParent, documentData.document.xref);
62527      }
62528      if (Array.isArray(fields) && fields.length > 0) {
62529        this.currentDocument = documentData;
62530        await this.#cloneFields(newFields, fields);
62531        this.currentDocument = null;
62532      }
62533    }
62534    this.#setAcroFormCalculationOrder(allDocumentData);
62535  }
62536  #setAcroFormQ(allDocumentData) {
62537    let firstQ = 0;
62538    let firstDocData = null;
62539    for (const documentData of allDocumentData) {
62540      const q = documentData.acroForm?.get("Q");
62541      if (typeof q !== "number" || q === 0) {
62542        continue;
62543      }
62544      if (firstDocData?.acroFormQ > 0) {
62545        documentData.acroFormQ = q;
62546        continue;
62547      }
62548      if (firstQ === 0) {
62549        firstQ = q;
62550        firstDocData = documentData;
62551        continue;
62552      }
62553      if (q === firstQ) {
62554        continue;
62555      }
62556      firstDocData.acroFormQ ||= firstQ;
62557      documentData.acroFormQ = q;
62558      firstQ = 0;
62559    }
62560    if (firstQ > 0) {
62561      this.acroFormQ = firstQ;
62562    }
62563  }
62564  #setAcroFormDefaultBasicValues(allDocumentData) {
62565    let sigFlags = 0;
62566    let needAppearances = false;
62567    for (const documentData of allDocumentData) {
62568      if (!documentData.acroForm) {
62569        continue;
62570      }
62571      const sf = documentData.acroForm.get("SigFlags");
62572      if (typeof sf === "number" && documentData.hasSignatureAnnotations) {
62573        sigFlags |= sf;
62574      }
62575      if (documentData.acroForm.get("NeedAppearances") === true) {
62576        needAppearances = true;
62577      }
62578    }
62579    this.acroFormSigFlags = sigFlags;
62580    this.acroFormNeedAppearances = needAppearances;
62581  }
62582  #setAcroFormCalculationOrder(allDocumentData) {
62583    const calculationOrder = [];
62584    for (const documentData of allDocumentData) {
62585      const co = documentData.acroForm?.get("CO") || null;
62586      if (!Array.isArray(co)) {
62587        continue;
62588      }
62589      const {
62590        oldRefMapping
62591      } = documentData;
62592      for (const coRef of co) {
62593        const newCoRef = coRef instanceof Ref && oldRefMapping.get(coRef);
62594        if (newCoRef) {
62595          calculationOrder.push(newCoRef);
62596        }
62597      }
62598    }
62599    this.acroFormCalculationOrder = calculationOrder.length > 0 ? calculationOrder : null;
62600  }
62601  #setAcroFormDefaultAppearance(allDocumentData) {
62602    let firstDA = null;
62603    let firstDocData = null;
62604    for (const documentData of allDocumentData) {
62605      const da = documentData.acroForm?.get("DA") || null;
62606      if (!da || typeof da !== "string") {
62607        continue;
62608      }
62609      if (firstDocData?.acroFormDefaultAppearance) {
62610        documentData.acroFormDefaultAppearance = da;
62611        continue;
62612      }
62613      if (!firstDA) {
62614        firstDA = da;
62615        firstDocData = documentData;
62616        continue;
62617      }
62618      if (da === firstDA) {
62619        continue;
62620      }
62621      firstDocData.acroFormDefaultAppearance ||= firstDA;
62622      documentData.acroFormDefaultAppearance = da;
62623      firstDA = null;
62624    }
62625    if (firstDA) {
62626      this.acroFormDefaultAppearance = firstDA;
62627    }
62628  }
62629  async #setAcroFormDefaultResources(allDocumentData) {
62630    let firstDR = null;
62631    let firstDRRef = null;
62632    let firstDocData = null;
62633    for (const documentData of allDocumentData) {
62634      const dr = documentData.acroForm?.get("DR") || null;
62635      if (!dr || !(dr instanceof Dict)) {
62636        continue;
62637      }
62638      if (firstDocData?.acroFormDefaultResources) {
62639        documentData.acroFormDefaultResources = dr;
62640        continue;
62641      }
62642      if (!firstDR) {
62643        firstDR = dr;
62644        firstDRRef = documentData.acroForm.getRaw("DR");
62645        firstDocData = documentData;
62646        continue;
62647      }
62648      if (deepCompare(firstDR, dr)) {
62649        continue;
62650      }
62651      firstDocData.acroFormDefaultResources ||= firstDR;
62652      documentData.acroFormDefaultResources = dr;
62653      firstDR = null;
62654      firstDRRef = null;
62655    }
62656    if (firstDR) {
62657      this.currentDocument = firstDocData;
62658      this.acroFormDefaultResources = await this.#collectDependencies(firstDRRef, true, firstDocData.document.xref);
62659      this.currentDocument = null;
62660    }
62661  }
62662  #fixFields(fieldToParent, xref) {
62663    const newFields = [];
62664    const processed = new RefSet();
62665    for (const [fieldRef, parentRef] of fieldToParent
vendor: 35,146 bytes, lines 62665-63851
62665) {
62666      if (!parentRef) {
62667        newFields.push(fieldRef);
62668        continue;
62669      }
62670      let parent = parentRef;
62671      let lastNonNullParent = parentRef;
62672      while (true) {
62673        parent = xref.fetchIfRef(parent)?.getRaw("Parent") || null;
62674        if (!parent) {
62675          break;
62676        }
62677        lastNonNullParent = parent;
62678      }
62679      if (lastNonNullParent instanceof Ref && !processed.has(lastNonNullParent)) {
62680        newFields.push(lastNonNullParent);
62681        processed.put(lastNonNullParent);
62682      }
62683    }
62684    return newFields;
62685  }
62686  async #cloneFields(newFields, fields) {
62687    const processed = new RefSet();
62688    const stack = [{
62689      kids: fields,
62690      newKids: newFields,
62691      pos: 0,
62692      oldParentRef: null,
62693      parentRef: null,
62694      parent: null
62695    }];
62696    const {
62697      document: {
62698        xref
62699      },
62700      oldRefMapping,
62701      fieldToParent,
62702      acroFormDefaultAppearance,
62703      acroFormDefaultResources,
62704      acroFormQ
62705    } = this.currentDocument;
62706    const daToFix = [];
62707    const drToFix = [];
62708    while (stack.length > 0) {
62709      const data = stack.at(-1);
62710      const {
62711        kids,
62712        newKids,
62713        parent,
62714        pos
62715      } = data;
62716      if (pos === kids.length) {
62717        stack.pop();
62718        if (newKids.length === 0 || !parent) {
62719          continue;
62720        }
62721        const parentDict = this.xref[data.parentRef.num] = this.cloneDict(parent);
62722        parentDict.delete("Parent");
62723        parentDict.delete("Kids");
62724        await this.#collectDependencies(parentDict, false, xref);
62725        parentDict.set("Kids", newKids);
62726        if (stack.length > 0) {
62727          const lastData = stack.at(-1);
62728          if (!lastData.parentRef && lastData.oldParentRef) {
62729            const parentRef = lastData.parentRef = this.newRef;
62730            parentDict.set("Parent", parentRef);
62731            oldRefMapping.put(lastData.oldParentRef, parentRef);
62732          }
62733          lastData.newKids.push(data.parentRef);
62734        }
62735        continue;
62736      }
62737      const oldKidRef = kids[data.pos++];
62738      if (!(oldKidRef instanceof Ref) || processed.has(oldKidRef)) {
62739        continue;
62740      }
62741      processed.put(oldKidRef);
62742      const kid = xref.fetchIfRef(oldKidRef);
62743      if (kid.has("Kids")) {
62744        const kidsArray = kid.get("Kids");
62745        if (!Array.isArray(kidsArray)) {
62746          continue;
62747        }
62748        stack.push({
62749          kids: kidsArray,
62750          newKids: [],
62751          pos: 0,
62752          oldParentRef: oldKidRef,
62753          parentRef: null,
62754          parent: kid
62755        });
62756        continue;
62757      }
62758      if (!fieldToParent.has(oldKidRef)) {
62759        continue;
62760      }
62761      const newRef = oldRefMapping.get(oldKidRef);
62762      if (!newRef) {
62763        continue;
62764      }
62765      newKids.push(newRef);
62766      if (!data.parentRef && data.oldParentRef) {
62767        data.parentRef = this.newRef;
62768        oldRefMapping.put(data.oldParentRef, data.parentRef);
62769      }
62770      const newKid = this.xref[newRef.num];
62771      if (data.parentRef) {
62772        newKid.set("Parent", data.parentRef);
62773      }
62774      if (acroFormDefaultAppearance && isName(newKid.get("FT"), "Tx") && !newKid.has("DA")) {
62775        daToFix.push(newKid);
62776      }
62777      if (acroFormDefaultResources && !newKid.has("Kids") && newKid.get("AP") instanceof Dict) {
62778        drToFix.push(newKid);
62779      }
62780      if (acroFormQ && !newKid.has("Q")) {
62781        newKid.set("Q", acroFormQ);
62782      }
62783    }
62784    for (const field of daToFix) {
62785      const da = getInheritableProperty({
62786        dict: field,
62787        key: "DA"
62788      });
62789      if (!da) {
62790        field.set("DA", acroFormDefaultAppearance);
62791      }
62792    }
62793    const resourcesValuesCache = new Map();
62794    for (const field of drToFix) {
62795      const ap = field.get("AP");
62796      for (const [, value] of ap) {
62797        if (!(value instanceof BaseStream)) {
62798          continue;
62799        }
62800        let resources = value.dict.getRaw("Resources");
62801        if (!resources) {
62802          const newResourcesRef = await resourcesValuesCache.getOrInsertComputed(acroFormDefaultResources, () => this.#cloneObject(acroFormDefaultResources, xref));
62803          value.dict.set("Resources", newResourcesRef);
62804          continue;
62805        }
62806        resources = xref.fetchIfRef(resources);
62807        for (const [resKey, resValue] of acroFormDefaultResources.getRawEntries()) {
62808          if (!resources.has(resKey)) {
62809            let newResValue = resValue;
62810            if (resValue instanceof Ref) {
62811              newResValue = await this.#collectDependencies(resValue, true, xref);
62812            } else if (resValue instanceof Dict || resValue instanceof BaseStream || Array.isArray(resValue)) {
62813              newResValue = await resourcesValuesCache.getOrInsertComputed(resValue, () => this.#cloneObject(resValue, xref));
62814            }
62815            resources.set(resKey, newResValue);
62816          }
62817        }
62818      }
62819    }
62820  }
62821  async #collectPageLabels() {
62822    if (!this.isSingleFile) {
62823      return;
62824    }
62825    const firstRealPage = this.oldPages.find(p => !!p);
62826    if (!firstRealPage) {
62827      return;
62828    }
62829    const {
62830      documentData: {
62831        document,
62832        pageLabels
62833      }
62834    } = firstRealPage;
62835    if (!pageLabels) {
62836      return;
62837    }
62838    const numPages = document.numPages;
62839    const labelsByPageIndex = new Map();
62840    const oldPageIndices = new Set(this.oldPages.filter(p => !!p).map(({
62841      page: {
62842        pageIndex
62843      }
62844    }) => pageIndex));
62845    let currentLabel = null;
62846    let stFirstIndex = -1;
62847    for (let i = 0; i < numPages; i++) {
62848      const newLabel = pageLabels.get(i);
62849      if (newLabel) {
62850        currentLabel = newLabel;
62851        stFirstIndex = currentLabel.has("St") ? i : -1;
62852      }
62853      if (!oldPageIndices.has(i)) {
62854        continue;
62855      }
62856      if (stFirstIndex !== -1) {
62857        const st = currentLabel.get("St");
62858        currentLabel = this.cloneDict(currentLabel);
62859        currentLabel.set("St", st + (i - stFirstIndex));
62860        stFirstIndex = -1;
62861      }
62862      labelsByPageIndex.set(i, currentLabel);
62863    }
62864    const defaultLabel = index => {
62865      const label = new Dict();
62866      label.setIfName("S", "D");
62867      label.set("St", index + 1);
62868      return label;
62869    };
62870    currentLabel = null;
62871    const newPageLabels = this.pageLabels = [];
62872    for (let i = 0, ii = this.oldPages.length; i < ii; i++) {
62873      const pageData = this.oldPages[i];
62874      const label = pageData ? labelsByPageIndex.get(pageData.page.pageIndex) || defaultLabel(i) : defaultLabel(i);
62875      if (label === currentLabel) {
62876        continue;
62877      }
62878      currentLabel = label;
62879      newPageLabels.push([i, currentLabel]);
62880    }
62881  }
62882  async #makePageCopy(pageIndex) {
62883    const {
62884      page,
62885      documentData,
62886      annotations,
62887      pointingNamedDestinations
62888    } = this.oldPages[pageIndex];
62889    this.currentDocument = documentData;
62890    const {
62891      dedupNamedDestinations,
62892      oldRefMapping
62893    } = documentData;
62894    const {
62895      xref,
62896      rotate,
62897      mediaBox,
62898      resources,
62899      ref: oldPageRef
62900    } = page;
62901    const pageRef = this.newRef;
62902    const pageDict = this.xref[pageRef.num] = this.cloneDict(page.pageDict);
62903    oldRefMapping.put(oldPageRef, pageRef);
62904    if (pointingNamedDestinations) {
62905      for (const pointingDest of pointingNamedDestinations) {
62906        const name = dedupNamedDestinations.get(pointingDest) || pointingDest;
62907        const dest = this.namedDestinations.get(name);
62908        dest[0] = pageRef;
62909      }
62910    }
62911    for (const key of ["Rotate", "MediaBox", "CropBox", "BleedBox", "TrimBox", "ArtBox", "Resources", "Annots", "Parent", "UserUnit"]) {
62912      pageDict.delete(key);
62913    }
62914    const lastRef = this.newRefCount;
62915    await this.#collectDependencies(pageDict, false, xref);
62916    pageDict.set("Rotate", rotate);
62917    pageDict.set("MediaBox", mediaBox);
62918    for (const boxName of ["CropBox", "BleedBox", "TrimBox", "ArtBox"]) {
62919      const box = page.getBoundingBox(boxName);
62920      if (box?.some((value, index) => value !== mediaBox[index])) {
62921        pageDict.set(boxName, box);
62922      }
62923    }
62924    const userUnit = page.userUnit;
62925    if (userUnit !== 1) {
62926      pageDict.set("UserUnit", userUnit);
62927    }
62928    pageDict.setIfDict("Resources", await this.#collectDependencies(resources, true, xref));
62929    let newAnnots = null;
62930    if (annotations) {
62931      const newAnnotations = await this.#collectDependencies(annotations, true, xref);
62932      this.#fixNamedDestinations(newAnnotations, dedupNamedDestinations);
62933      if (Array.isArray(newAnnotations) && newAnnotations.length > 0) {
62934        newAnnots = newAnnotations;
62935      }
62936    }
62937    const newAnnotations = documentData.document === this.#primaryDocument ? this.#newAnnotationsParams?.newAnnotationsByPage?.get(page.pageIndex) : null;
62938    if (newAnnotations) {
62939      const {
62940        handler,
62941        task,
62942        imagesPromises
62943      } = this.#newAnnotationsParams;
62944      const changes = new RefSetCache();
62945      const newData = await AnnotationFactory.saveNewAnnotations(page.createAnnotationEvaluator(handler), this.xrefWrapper, task, newAnnotations, imagesPromises, changes);
62946      for (const [ref, {
62947        data
62948      }] of changes.items()) {
62949        this.xref[ref.num] = data;
62950      }
62951      newAnnots ||= [];
62952      for (const {
62953        ref
62954      } of newData.annotations) {
62955        newAnnots.push(ref);
62956      }
62957    }
62958    pageDict.setIfArray("Annots", newAnnots);
62959    if (this.useObjectStreams) {
62960      const newLastRef = this.newRefCount;
62961      const pageObjectRefs = [];
62962      for (let i = lastRef; i < newLastRef; i++) {
62963        const obj = this.xref[i];
62964        if (obj instanceof BaseStream) {
62965          continue;
62966        }
62967        pageObjectRefs.push(Ref.get(i, 0));
62968      }
62969      for (let i = 0; i < pageObjectRefs.length; i += 0xffff) {
62970        const objStreamRef = this.newRef;
62971        this.objStreamRefs.add(objStreamRef.num);
62972        this.xref[objStreamRef.num] = pageObjectRefs.slice(i, i + 0xffff);
62973      }
62974    }
62975    this.currentDocument = null;
62976    return pageRef;
62977  }
62978  #modalPageSize() {
62979    const counts = new Map();
62980    for (const pageData of this.oldPages) {
62981      if (!pageData) {
62982        continue;
62983      }
62984      const {
62985        page
62986      } = pageData;
62987      const [x0, y0, x1, y1] = page.view;
62988      let width = x1 - x0;
62989      let height = y1 - y0;
62990      if (width <= 0 || height <= 0) {
62991        continue;
62992      }
62993      if (page.rotate % 180 !== 0) {
62994        [width, height] = [height, width];
62995      }
62996      const key = `${width}x${height}`;
62997      const entry = counts.get(key);
62998      if (entry) {
62999        entry.count++;
63000      } else {
63001        counts.set(key, {
63002          width,
63003          height,
63004          count: 1
63005        });
63006      }
63007    }
63008    if (counts.size === 0) {
63009      const [,, width, height] = LETTER_SIZE_MEDIABOX;
63010      return {
63011        width,
63012        height
63013      };
63014    }
63015    let best = null;
63016    for (const entry of counts.values()) {
63017      if (!best || entry.count > best.count || entry.count === best.count && entry.width * entry.height > best.width * best.height) {
63018        best = entry;
63019      }
63020    }
63021    return {
63022      width: best.width,
63023      height: best.height
63024    };
63025  }
63026  async #makeImagePage(bitmap, pageSize) {
63027    const {
63028      width: pageW,
63029      height: pageH
63030    } = pageSize;
63031    const DEFAULT_MARGIN_RATIO = 0.1;
63032    const margin = pageW * DEFAULT_MARGIN_RATIO;
63033    const availW = Math.max(1, pageW - 2 * margin);
63034    const availH = Math.max(1, pageH - 2 * margin);
63035    const lastRef = this.newRefCount;
63036    const {
63037      imageStream,
63038      smaskStream,
63039      width: imgW,
63040      height: imgH
63041    } = await createImage(bitmap, this.xrefWrapper, {
63042      closeBitmap: true
63043    });
63044    const scale = Math.min(availW / imgW, availH / imgH);
63045    const drawW = imgW * scale;
63046    const drawH = imgH * scale;
63047    const tx = (pageW - drawW) / 2;
63048    const ty = (pageH - drawH) / 2;
63049    if (smaskStream) {
63050      const smaskRef = this.newRef;
63051      this.xref[smaskRef.num] = smaskStream;
63052      imageStream.dict.set("SMask", smaskRef);
63053    }
63054    const imageRef = this.newRef;
63055    this.xref[imageRef.num] = imageStream;
63056    const xobjectDict = new Dict(this.xrefWrapper);
63057    xobjectDict.set("Im0", imageRef);
63058    const resourcesDict = new Dict(this.xrefWrapper);
63059    resourcesDict.set("XObject", xobjectDict);
63060    resourcesDict.set("ProcSet", [Name.get("PDF"), Name.get("ImageC")]);
63061    const content = `q ${numberToString(drawW)} 0 0 ${numberToString(drawH)} ` + `${numberToString(tx)} ${numberToString(ty)} cm /Im0 Do Q`;
63062    const contentsStream = new StringStream(content, new Dict(this.xrefWrapper));
63063    const contentsRef = this.newRef;
63064    this.xref[contentsRef.num] = contentsStream;
63065    const pageRef = this.newRef;
63066    const pageDict = this.xref[pageRef.num] = new Dict(this.xrefWrapper);
63067    pageDict.setIfName("Type", "Page");
63068    pageDict.set("MediaBox", [0, 0, pageW, pageH]);
63069    pageDict.set("Resources", resourcesDict);
63070    pageDict.set("Contents", contentsRef);
63071    if (this.useObjectStreams) {
63072      const newLastRef = this.newRefCount;
63073      const pageObjectRefs = [];
63074      for (let i = lastRef; i < newLastRef; i++) {
63075        const obj = this.xref[i];
63076        if (obj instanceof BaseStream) {
63077          continue;
63078        }
63079        pageObjectRefs.push(Ref.get(i, 0));
63080      }
63081      for (let i = 0; i < pageObjectRefs.length; i += 0xffff) {
63082        const objStreamRef = this.newRef;
63083        this.objStreamRefs.add(objStreamRef.num);
63084        this.xref[objStreamRef.num] = pageObjectRefs.slice(i, i + 0xffff);
63085      }
63086    }
63087    return pageRef;
63088  }
63089  #makePageTree() {
63090    const {
63091      newPages: pages,
63092      rootDict,
63093      pagesRef,
63094      pagesDict
63095    } = this;
63096    rootDict.set("Pages", pagesRef);
63097    pagesDict.setIfName("Type", "Pages");
63098    pagesDict.set("Count", pages.length);
63099    const maxLeaves = MAX_LEAVES_PER_PAGES_NODE <= 1 ? pages.length : MAX_LEAVES_PER_PAGES_NODE;
63100    const stack = [{
63101      dict: pagesDict,
63102      kids: pages,
63103      parentRef: pagesRef
63104    }];
63105    while (stack.length > 0) {
63106      const {
63107        dict,
63108        kids,
63109        parentRef
63110      } = stack.pop();
63111      if (kids.length <= maxLeaves) {
63112        dict.set("Kids", kids);
63113        for (const ref of kids) {
63114          this.xref[ref.num].set("Parent", parentRef);
63115        }
63116        continue;
63117      }
63118      const chunkSize = Math.max(maxLeaves, Math.ceil(kids.length / maxLeaves));
63119      const kidsChunks = [];
63120      for (let i = 0; i < kids.length; i += chunkSize) {
63121        kidsChunks.push(kids.slice(i, i + chunkSize));
63122      }
63123      const kidsRefs = [];
63124      dict.set("Kids", kidsRefs);
63125      for (const chunk of kidsChunks) {
63126        const [kidRef, kidDict] = this.newDict;
63127        kidsRefs.push(kidRef);
63128        kidDict.setIfName("Type", "Pages");
63129        kidDict.set("Parent", parentRef);
63130        kidDict.set("Count", chunk.length);
63131        stack.push({
63132          dict: kidDict,
63133          kids: chunk,
63134          parentRef: kidRef
63135        });
63136      }
63137    }
63138  }
63139  #makeNameNumTree(map, areNames) {
63140    const allEntries = map.sort(areNames ? ([keyA], [keyB]) => keyA.localeCompare(keyB) : ([keyA], [keyB]) => keyA - keyB);
63141    const maxLeaves = MAX_IN_NAME_TREE_NODE <= 1 ? allEntries.length : MAX_IN_NAME_TREE_NODE;
63142    const [treeRef, treeDict] = this.newDict;
63143    const stack = [{
63144      dict: treeDict,
63145      entries: allEntries,
63146      isRoot: true
63147    }];
63148    const valueType = areNames ? "Names" : "Nums";
63149    while (stack.length > 0) {
63150      const {
63151        dict,
63152        entries,
63153        isRoot
63154      } = stack.pop();
63155      if (entries.length <= maxLeaves) {
63156        if (!isRoot) {
63157          dict.set("Limits", [entries[0][0], entries.at(-1)[0]]);
63158        }
63159        dict.set(valueType, entries.flat());
63160        continue;
63161      }
63162      const entriesChunks = [];
63163      const chunkSize = Math.max(maxLeaves, Math.ceil(entries.length / maxLeaves));
63164      for (let i = 0; i < entries.length; i += chunkSize) {
63165        entriesChunks.push(entries.slice(i, i + chunkSize));
63166      }
63167      const entriesRefs = [];
63168      dict.set("Kids", entriesRefs);
63169      for (const chunk of entriesChunks) {
63170        const [entriesRef, entriesDict] = this.newDict;
63171        entriesRefs.push(entriesRef);
63172        entriesDict.set("Limits", [chunk[0][0], chunk.at(-1)[0]]);
63173        stack.push({
63174          dict: entriesDict,
63175          entries: chunk
63176        });
63177      }
63178    }
63179    return treeRef;
63180  }
63181  #makePageLabelsTree() {
63182    const {
63183      pageLabels
63184    } = this;
63185    if (!pageLabels?.length) {
63186      return;
63187    }
63188    const {
63189      rootDict
63190    } = this;
63191    const pageLabelsRef = this.#makeNameNumTree(this.pageLabels, false);
63192    rootDict.set("PageLabels", pageLabelsRef);
63193  }
63194  async #collectEmbeddedFiles(allDocumentData) {
63195    const {
63196      embeddedFiles
63197    } = this;
63198    for (const documentData of allDocumentData) {
63199      const {
63200        embeddedFiles: docEmbeddedFiles,
63201        document: {
63202          xref
63203        }
63204      } = documentData;
63205      if (!docEmbeddedFiles?.size) {
63206        continue;
63207      }
63208      this.currentDocument = documentData;
63209      for (const [key, valueRef] of docEmbeddedFiles) {
63210        let name = key;
63211        if (embeddedFiles.has(name)) {
63212          const displayName = stringToPDFString(key, true);
63213          for (let i = 1;; i++) {
63214            const deduped = `${displayName}_${i}`;
63215            if (!embeddedFiles.has(deduped)) {
63216              name = deduped;
63217              break;
63218            }
63219          }
63220        }
63221        embeddedFiles.set(name, await this.#collectDependencies(valueRef, true, xref));
63222      }
63223      this.currentDocument = null;
63224    }
63225  }
63226  #makeEmbeddedFilesTree() {
63227    const {
63228      embeddedFiles
63229    } = this;
63230    if (embeddedFiles.size === 0) {
63231      return;
63232    }
63233    if (!this.namesDict) {
63234      [this.namesRef, this.namesDict] = this.newDict;
63235      this.rootDict.set("Names", this.namesRef);
63236    }
63237    this.namesDict.set("EmbeddedFiles", this.#makeNameNumTree(Array.from(embeddedFiles.entries()), true));
63238  }
63239  #makeDestinationsTree() {
63240    const {
63241      namedDestinations
63242    } = this;
63243    if (namedDestinations.size === 0) {
63244      return;
63245    }
63246    if (!this.namesDict) {
63247      [this.namesRef, this.namesDict] = this.newDict;
63248      this.rootDict.set("Names", this.namesRef);
63249    }
63250    this.namesDict.set("Dests", this.#makeNameNumTree(Array.from(namedDestinations.entries()), true));
63251  }
63252  #makeStructTree() {
63253    const {
63254      structTreeKids
63255    } = this;
63256    if (!structTreeKids?.length) {
63257      return;
63258    }
63259    const {
63260      rootDict
63261    } = this;
63262    const structTreeRef = this.newRef;
63263    const structTree = this.xref[structTreeRef.num] = new Dict();
63264    structTree.setIfName("Type", "StructTreeRoot");
63265    structTree.setIfArray("K", structTreeKids);
63266    for (const kidRef of structTreeKids) {
63267      const kid = this.xref[kidRef.num];
63268      const type = kid.get("Type");
63269      if (!type || isName(type, "StructElem")) {
63270        kid.set("P", structTreeRef);
63271      }
63272    }
63273    if (this.parentTree.size > 0) {
63274      const parentTreeRef = this.#makeNameNumTree(Array.from(this.parentTree.entries()), false);
63275      const parentTree = this.xref[parentTreeRef.num];
63276      parentTree.setIfName("Type", "ParentTree");
63277      structTree.set("ParentTree", parentTreeRef);
63278      structTree.set("ParentTreeNextKey", this.parentTree.size);
63279    }
63280    if (this.idTree.size > 0) {
63281      const idTreeRef = this.#makeNameNumTree(Array.from(this.idTree.entries()), true);
63282      const idTree = this.xref[idTreeRef.num];
63283      idTree.setIfName("Type", "IDTree");
63284      structTree.set("IDTree", idTreeRef);
63285    }
63286    if (this.classMap.size > 0) {
63287      const classMapRef = this.newRef;
63288      this.xref[classMapRef.num] = this.classMap;
63289      structTree.set("ClassMap", classMapRef);
63290    }
63291    if (this.roleMap.size > 0) {
63292      const roleMapRef = this.newRef;
63293      this.xref[roleMapRef.num] = this.roleMap;
63294      structTree.set("RoleMap", roleMapRef);
63295    }
63296    if (this.namespaces.size > 0) {
63297      const namespacesRef = this.newRef;
63298      this.xref[namespacesRef.num] = Array.from(this.namespaces.values());
63299      structTree.set("Namespaces", namespacesRef);
63300    }
63301    if (this.structTreeAF.length > 0) {
63302      const structTreeAFRef = this.newRef;
63303      this.xref[structTreeAFRef.num] = this.structTreeAF;
63304      structTree.set("AF", structTreeAFRef);
63305    }
63306    if (this.structTreePronunciationLexicon.length > 0) {
63307      const structTreePronunciationLexiconRef = this.newRef;
63308      this.xref[structTreePronunciationLexiconRef.num] = this.structTreePronunciationLexicon;
63309      structTree.set("PronunciationLexicon", structTreePronunciationLexiconRef);
63310    }
63311    rootDict.set("StructTreeRoot", structTreeRef);
63312  }
63313  #makeAcroForm() {
63314    if (this.fields.length === 0) {
63315      return;
63316    }
63317    const {
63318      rootDict
63319    } = this;
63320    const acroFormRef = this.newRef;
63321    const acroForm = this.xref[acroFormRef.num] = new Dict();
63322    rootDict.set("AcroForm", acroFormRef);
63323    acroForm.set("Fields", this.fields);
63324    if (this.acroFormNeedAppearances) {
63325      acroForm.set("NeedAppearances", true);
63326    }
63327    if (this.acroFormSigFlags > 0) {
63328      acroForm.set("SigFlags", this.acroFormSigFlags);
63329    }
63330    acroForm.setIfArray("CO", this.acroFormCalculationOrder);
63331    acroForm.setIfDict("DR", this.acroFormDefaultResources);
63332    if (this.acroFormDefaultAppearance) {
63333      acroForm.set("DA", this.acroFormDefaultAppearance);
63334    }
63335    if (this.acroFormQ > 0) {
63336      acroForm.set("Q", this.acroFormQ);
63337    }
63338  }
63339  async #makeRoot() {
63340    const {
63341      rootDict
63342    } = this;
63343    rootDict.setIfName("Type", "Catalog");
63344    rootDict.setIfName("Version", this.version);
63345    this.#makeAcroForm();
63346    this.#makePageTree();
63347    this.#makePageLabelsTree();
63348    this.#makeEmbeddedFilesTree();
63349    this.#makeDestinationsTree();
63350    this.#makeStructTree();
63351    await this.#makeOutline();
63352  }
63353  #makeInfo() {
63354    const infoMap = new Map();
63355    if (this.isSingleFile) {
63356      const firstRealPage = this.oldPages.find(p => !!p);
63357      const {
63358        xref: {
63359          trailer
63360        }
63361      } = firstRealPage.documentData.document;
63362      const oldInfoDict = trailer.get("Info");
63363      for (const [key, value] of oldInfoDict || []) {
63364        if (typeof value === "string") {
63365          infoMap.set(key, stringToPDFString(value));
63366        }
63367      }
63368    }
63369    infoMap.delete("ModDate");
63370    infoMap.set("CreationDate", getModificationDate());
63371    infoMap.set("Creator", "PDF.js");
63372    infoMap.set("Producer", "Firefox");
63373    if (this.author) {
63374      infoMap.set("Author", this.author);
63375    }
63376    if (this.title) {
63377      infoMap.set("Title", this.title);
63378    }
63379    for (const [key, value] of infoMap) {
63380      this.infoDict.set(key, stringToAsciiOrUTF16BE(value));
63381    }
63382    return infoMap;
63383  }
63384  async #makeEncrypt() {
63385    if (!this.isSingleFile) {
63386      return [null, null, null];
63387    }
63388    const firstRealPage = this.oldPages.find(p => !!p);
63389    const {
63390      documentData
63391    } = firstRealPage;
63392    const {
63393      document: {
63394        xref: {
63395          trailer,
63396          encrypt
63397        }
63398      }
63399    } = documentData;
63400    if (!trailer.has("Encrypt")) {
63401      return [null, null, null];
63402    }
63403    const encryptDict = trailer.get("Encrypt");
63404    if (!(encryptDict instanceof Dict)) {
63405      return [null, null, null];
63406    }
63407    this.currentDocument = documentData;
63408    const result = [await this.#cloneObject(encryptDict, trailer.xref), encrypt, trailer.get("ID")];
63409    this.currentDocument = null;
63410    return result;
63411  }
63412  async #createChanges() {
63413    const changes = new RefSetCache();
63414    changes.put(Ref.get(0, 0xffff), {
63415      data: null
63416    });
63417    for (let i = 1, ii = this.xref.length; i < ii; i++) {
63418      if (this.objStreamRefs?.has(i)) {
63419        await this.#createObjectStream(Ref.get(i, 0), this.xref[i], changes);
63420      } else {
63421        changes.put(Ref.get(i, 0), {
63422          data: this.xref[i]
63423        });
63424      }
63425    }
63426    return [changes, this.newRef];
63427  }
63428  async #createObjectStream(objStreamRef, objRefs, changes) {
63429    const streamBuffer = [""];
63430    const objOffsets = [];
63431    let offset = 0;
63432    const buffer = [];
63433    for (let i = 0, ii = objRefs.length; i < ii; i++) {
63434      const objRef = objRefs[i];
63435      changes.put(objRef, {
63436        data: null,
63437        objStreamRef,
63438        index: i
63439      });
63440      objOffsets.push(`${objRef.num} ${offset}`);
63441      const data = this.xref[objRef.num];
63442      await writeValue(data, buffer, null);
63443      const obj = buffer.join("");
63444      buffer.length = 0;
63445      streamBuffer.push(obj);
63446      offset += obj.length + 1;
63447    }
63448    streamBuffer[0] = objOffsets.join("\n");
63449    const dict = new Dict();
63450    dict.setIfName("Type", "ObjStm");
63451    dict.set("N", objRefs.length);
63452    dict.set("First", streamBuffer[0].length + 1);
63453    const objStream = new StringStream(streamBuffer.join("\n"), dict);
63454    changes.put(objStreamRef, {
63455      data: objStream
63456    });
63457  }
63458  async writePDF() {
63459    await this.#makeRoot();
63460    const infoMap = this.#makeInfo();
63461    const [encryptRef, encrypt, fileIds] = await this.#makeEncrypt();
63462    const [changes, xrefTableRef] = await this.#createChanges();
63463    const header = stringToBytes(`%PDF-${this.version}\n%\xfa\xde\xfa\xce`);
63464    return incrementalUpdate({
63465      originalData: header,
63466      changes,
63467      xrefInfo: {
63468        startXRef: null,
63469        rootRef: this.rootRef,
63470        infoRef: this.infoRef,
63471        encryptRef,
63472        newRef: xrefTableRef,
63473        fileIds: fileIds || [null, null],
63474        infoMap
63475      },
63476      useXrefStream: this.useObjectStreams,
63477      xref: {
63478        encrypt,
63479        encryptRef
63480      }
63481    });
63482  }
63483}
63484
63485;// ./src/shared/base_pdf_stream.js
63486
63487class BasePDFStream {
63488  #PDFStreamReader = null;
63489  #PDFStreamRangeReader = null;
63490  _fullReader = null;
63491  _rangeReaders = new Set();
63492  _source = null;
63493  constructor(source, PDFStreamReader, PDFStreamRangeReader) {
63494    this._source = source;
63495    this.#PDFStreamReader = PDFStreamReader;
63496    this.#PDFStreamRangeReader = PDFStreamRangeReader;
63497  }
63498  get _progressiveDataLength() {
63499    return this._fullReader?._loaded ?? 0;
63500  }
63501  getFullReader() {
63502    assert(!this._fullReader, "BasePDFStream.getFullReader can only be called once.");
63503    return this._fullReader = new this.#PDFStreamReader(this);
63504  }
63505  getRangeReader(begin, end) {
63506    if (end <= this._progressiveDataLength) {
63507      return null;
63508    }
63509    const reader = new this.#PDFStreamRangeReader(this, begin, end);
63510    this._rangeReaders.add(reader);
63511    return reader;
63512  }
63513  cancelAllRequests(reason) {
63514    this._fullReader?.cancel(reason);
63515    for (const reader of new Set(this._rangeReaders)) {
63516      reader.cancel(reason);
63517    }
63518  }
63519}
63520class BasePDFStreamReader {
63521  onProgress = null;
63522  _contentLength = 0;
63523  _filename = null;
63524  _headersCapability = Promise.withResolvers();
63525  _isRangeSupported = false;
63526  _isStreamingSupported = false;
63527  _loaded = 0;
63528  _stream = null;
63529  constructor(stream) {
63530    this._stream = stream;
63531  }
63532  _callOnProgress() {
63533    this.onProgress?.({
63534      loaded: this._loaded,
63535      total: this._contentLength
63536    });
63537  }
63538  get headersReady() {
63539    return this._headersCapability.promise;
63540  }
63541  get filename() {
63542    return this._filename;
63543  }
63544  get contentLength() {
63545    return this._contentLength;
63546  }
63547  get isRangeSupported() {
63548    return this._isRangeSupported;
63549  }
63550  get isStreamingSupported() {
63551    return this._isStreamingSupported;
63552  }
63553  async read() {
63554    unreachable("Abstract method `read` called");
63555  }
63556  cancel(reason) {
63557    unreachable("Abstract method `cancel` called");
63558  }
63559}
63560class BasePDFStreamRangeReader {
63561  _stream = null;
63562  constructor(stream, begin, end) {
63563    this._stream = stream;
63564  }
63565  async read() {
63566    unreachable("Abstract method `read` called");
63567  }
63568  cancel(reason) {
63569    unreachable("Abstract method `cancel` called");
63570  }
63571}
63572
63573;// ./src/core/worker_stream.js
63574
63575class PDFWorkerStream extends BasePDFStream {
63576  constructor(source) {
63577    super(source, PDFWorkerStreamReader, PDFWorkerStreamRangeReader);
63578  }
63579}
63580class PDFWorkerStreamReader extends BasePDFStreamReader {
63581  _reader = null;
63582  constructor(stream) {
63583    super(stream);
63584    const {
63585      msgHandler
63586    } = stream._source;
63587    const readableStream = msgHandler.sendWithStream("GetReader");
63588    this._reader = readableStream.getReader();
63589    msgHandler.sendWithPromise("ReaderHeadersReady").then(data => {
63590      this._contentLength = data.contentLength;
63591      this._isStreamingSupported = data.isStreamingSupported;
63592      this._isRangeSupported = data.isRangeSupported;
63593      this._headersCapability.resolve();
63594    }, this._headersCapability.reject);
63595  }
63596  async read() {
63597    const {
63598      value,
63599      done
63600    } = await this._reader.read();
63601    if (done) {
63602      return {
63603        value: undefined,
63604        done: true
63605      };
63606    }
63607    return {
63608      value: value.buffer,
63609      done: false
63610    };
63611  }
63612  cancel(reason) {
63613    this._reader.cancel(reason);
63614  }
63615}
63616class PDFWorkerStreamRangeReader extends BasePDFStreamRangeReader {
63617  _reader = null;
63618  constructor(stream, begin, end) {
63619    super(stream, begin, end);
63620    const {
63621      msgHandler
63622    } = stream._source;
63623    const readableStream = msgHandler.sendWithStream("GetRangeReader", {
63624      begin,
63625      end
63626    });
63627    this._reader = readableStream.getReader();
63628  }
63629  async read() {
63630    const {
63631      value,
63632      done
63633    } = await this._reader.read();
63634    if (done) {
63635      return {
63636        value: undefined,
63637        done: true
63638      };
63639    }
63640    return {
63641      value: value.buffer,
63642      done: false
63643    };
63644  }
63645  cancel(reason) {
63646    this._reader.cancel(reason);
63647  }
63648}
63649
63650;// ./src/core/worker.js
63651
63652
63653
63654
63655
63656
63657
63658
63659
63660
63661
63662
63663class WorkerTask {
63664  constructor(name) {
63665    this.name = name;
63666    this.terminated = false;
63667    this._capability = Promise.withResolvers();
63668  }
63669  get finished() {
63670    return this._capability.promise;
63671  }
63672  finish() {
63673    this._capability.resolve();
63674  }
63675  terminate() {
63676    this.terminated = true;
63677  }
63678  ensureNotTerminated() {
63679    if (this.terminated) {
63680      throw new Error("Worker task was terminated");
63681    }
63682  }
63683}
63684class WorkerMessageHandler {
63685  static {
63686    if (typeof window === "undefined" && !isNodeJS && typeof self !== "undefined" && typeof self.postMessage === "function" && "onmessage" in self) {
63687      this.initializeFromPort(self);
63688    }
63689  }
63690  static setup(handler, port) {
63691    let testMessageProcessed = false;
63692    handler.on("test", data => {
63693      if (testMessageProcessed) {
63694        return;
63695      }
63696      testMessageProcessed = true;
63697      handler.send("test", data instanceof Uint8Array);
63698    });
63699    handler.on("configure", data => {
63700      setVerbosityLevel(data.verbosity);
63701    });
63702    handler.on("GetDocRequest", data => this.createDocumentHandler(data, port));
63703  }
63704  static createDocumentHandler(docParams, port) {
63705    let pdfManager;
63706    let terminated = false;
63707    let cancelXHRs = null;
63708    const WorkerTasks = new Set();
63709    const verbosity = getVerbosityLevel();
63710    const {
63711      docId,
63712      apiVersion
63713    } = docParams;
63714    const workerVersion = "6.1.200";
63715    if (apiVersion !== workerVersion) {
63716      throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
63717    }
63718    const buildMsg = (type, prop) => `The \`${type}.prototype\` contains unexpected enumerable property ` + `"${prop}", thus breaking e.g. \`for...in\` iteration of ${type}s.`;
63719    for (const prop in {}) {
63720      throw new Error(buildMsg("Object", prop));
63721    }
63722    for (const prop in []) {
63723      throw new Error(buildMsg("Array", prop));
63724    }
63725    const workerHandlerName = docId + "_worker";
63726    let handler = new MessageHandler(workerHandlerName, docId, port);
63727    function ensureNotTerminated() {
63728      if (terminated) {
63729        throw new Error("Worker was terminated");
63730      }
63731    }
63732    function startWorkerTask(task) {
63733      WorkerTasks.add(task);
63734    }
63735    function finishWorkerTask(task) {
63736      task.finish();
63737      WorkerTasks.delete(task);
63738    }
63739    async function loadDocument(recoveryMode) {
63740      await pdfManager.initDocument(recoveryMode);
63741      const isPureXfa = await pdfManager.ensureDoc("isPureXfa");
63742      if (isPureXfa) {
63743        const task = new WorkerTask("loadXfaResources");
63744        startWorkerTask(task);
63745        await pdfManager.ensureDoc("loadXfaResources", [handler, task]);
63746        finishWorkerTask(task);
63747      }
63748      const [numPages, fingerprints] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("fingerprints")]);
63749      const htmlForXfa = isPureXfa ? await pdfManager.ensureDoc("htmlForXfa") : null;
63750      return {
63751        numPages,
63752        fingerprints,
63753        htmlForXfa
63754      };
63755    }
63756    async function getPdfManager({
63757      data,
63758      password,
63759      disableAutoFetch,
63760      rangeChunkSize,
63761      docBaseUrl,
63762      enableXfa,
63763      evaluatorOptions
63764    }) {
63765      const pdfManagerArgs = {
63766        source: null,
63767        disableAutoFetch,
63768        docBaseUrl,
63769        docId,
63770        enableXfa,
63771        evaluatorOptions,
63772        handler,
63773        length: 0,
63774        password,
63775        rangeChunkSize
63776      };
63777      if (data) {
63778        pdfManagerArgs.source = data;
63779        return new LocalPdfManager(pdfManagerArgs);
63780      }
63781      const pdfStream = new PDFWorkerStream({
63782          msgHandler: handler
63783        }),
63784        fullReader = pdfStream.getFullReader();
63785      const {
63786        promise,
63787        resolve,
63788        reject
63789      } = Promise.withResolvers();
63790      let newPdfManager,
63791        cachedChunks = [];
63792      cancelXHRs = reason => pdfStream.cancelAllRequests(reason);
63793      fullReader.headersReady.then(() => {
63794        if (!fullReader.isRangeSupported) {
63795          return;
63796        }
63797        pdfManagerArgs.source = pdfStream;
63798        pdfManagerArgs.length = fullReader.contentLength;
63799        pdfManagerArgs.disableAutoFetch ||= fullReader.isStreamingSupported;
63800        newPdfManager = new NetworkPdfManager(pdfManagerArgs);
63801        for (const chunk of cachedChunks) {
63802          newPdfManager.sendProgressiveData(chunk);
63803        }
63804        cachedChunks = null;
63805        resolve(newPdfManager);
63806        cancelXHRs = null;
63807      }).catch(reason => {
63808        reject(reason);
63809        cancelXHRs = null;
63810      });
63811      async function readData() {
63812        let loaded = 0;
63813        while (true) {
63814          const {
63815            value,
63816            done
63817          } = await fullReader.read();
63818          ensureNotTerminated();
63819          if (done) {
63820            break;
63821          }
63822          loaded += value.byteLength;
63823          if (!fullReader.isStreamingSupported) {
63824            handler.send("DocProgress", {
63825              loaded,
63826              total: fullReader.contentLength
63827            });
63828          }
63829          if (newPdfManager) {
63830            newPdfManager.sendProgressiveData(value);
63831          } else {
63832            cachedChunks.push(value);
63833          }
63834        }
63835        if (!newPdfManager) {
63836          pdfManagerArgs.source = arrayBuffersToBytes(cachedChunks);
63837          cachedChunks = null;
63838          newPdfManager = new LocalPdfManager(pdfManagerArgs);
63839          resolve(newPdfManager);
63840        }
63841        cancelXHRs = null;
63842      }
63843      readData().catch(reason => {
63844        reject(reason);
63845        cancelXHRs = null;
63846      });
63847      return promise;
63848    }
63849    async function getPassword(ex) {
63850      const task = new WorkerTask(`PasswordException: response ${ex.code}`);
63851      startWorkerTask(task);
63852      try {
63853        const res = await handler.sendWithPromise("PasswordRequest", ex);
63854        return res.password;
63855      } finally {
63856        Promise.resolve().then(() => {
63857          finishWorkerTask(task);
63858        });
63859      }
63860    }
63861    function setupDoc(data) {
63862      function onSuccess(doc) {
63863        ensureNotTerminated();
63864        handler.send("GetDoc", {
63865          pdfInfo: doc
63866        });
63867      }
63868      function onFailure(ex) {
63869        if (terminated) {
63870          return;
63871        }
63872        if (ex instanceof PasswordException) {
63873          getPassword(ex).then(password => {
63874            pdfManager.updatePassword(password);
63875            pdfManagerReady();
63876          }).catch(() => {
63877            handler.send("DocException", ex);
63878          });
63879        } else {
63880          handler.send("DocException", wrapReason(ex));
63881        }
63882      }
63883      function pdfManagerReady() {
63884        ensureNotTerminated();
63885        loadDocument(false).then(onSuccess, function (reason) {
63886          ensureNotTerminated();
63887          if (!(reason instanceof XRefParseException)) {
63888            onFailure(reason);
63889            return;
63890          }
63891          pdfManager.requestLoadedStream().then(function () {
63892            ensureNotTerminated();
63893            loadDocument(true).then(onSuccess, onFailure);
63894          }, onFailure);
63895        });
63896      }
63897      ensureNotTerminated();
63898      getPdfManager(data).then(function (newPdfManager) {
63899        if (terminated) {
63900          newPdfManager.terminate(new AbortException("Worker was terminated."));
63901          throw new Error("Worker was terminated");
63902        }
63903        pdfManager = newPdfManager;
63904        pdfManager.requestLoadedStream(true).then(stream => {
63905          handler.send("DataLoaded", {
63906            length: stream.bytes.byteLength
63907          });
63908        }, () => {});
63909      }).then(pdfManagerReady, onFailure);
63910    }
63911    handler.on("GetPage", function (data) {
63912      return pdfManager.getPage(data.pageIndex).then(function (page) {
63913        return Promise.all([pdfManager.ensure(page, "rotate"), pdfManager.ensure(page, "ref"), pdfManager.ensure(page, "userUnit"), pdfManager.ensure(page, "view")]).then(function ([rotate, ref, userUnit, view]) {
63914          return {
63915            rotate,
63916            ref,
63917            refStr: ref?.toString() ?? null,
63918            userUnit,
63919            view
63920          };
63921        });
63922      });
63923    });
63924    handler.on("GetPageIndex", function (data) {
63925      const pageRef = Ref.get(data.num, data.gen);
63926      return pdfManager.ensureCatalog("getPageIndex", [pageRef]);
63927    });
63928    handler.on("GetDestinations", function (data) {
63929      return pdfManager.ensureCatalog("destinations");
63930    });
63931    handler.on("GetDestination", function (data) {
63932      return pdfManager.ensureCatalog("getDestination", [data.id]);
63933    });
63934    handler.on("GetPageLabels", function (data) {
63935      return pdfManager.ensureCatalog("pageLabels");
63936    });
63937    handler.on("GetPageLayout", function (data) {
63938      return pdfManager.ensureCatalog("pageLayout");
63939    });
63940    handler.on("GetPageMode", function (data) {
63941      return pdfManager.ensureCatalog("pageMode");
63942    });
63943    handler.on("GetViewerPreferences", function (data) {
63944      return pdfManager.ensureCatalog("viewerPreferences");
63945    });
63946    handler.on("GetOpenAction", function (data) {
63947      return pdfManager.ensureCatalog("openAction");
63948    });
63949    handler.on("GetAttachments", function (data) {
63950      return pdfManager.ensureCatalog("attachments");
63951    });
63952    handler.on("GetAttachmentContent", async function (id) {
63953      let passwordEx;
63954      while (true) {
63955        const password = passwordEx ? await getPassword(passwordEx) : null;
63956        try {
63957          if (password) {
63958            pdfManager.updatePassword(password);
63959          }
63960          return await pdfManager.ensureCatalog("attachmentContent", [id]);
63961        } catch (ex) {
63962          if (ex instanceof PasswordException) {
63963            passwordEx = ex;
63964            continue;
63965          }
63966          throw ex;
63967        }
63968      }
63969    });
63970    handler.on("GetDocJSActions", function (data) {
63971      return pdfManager.ensureCatalog("jsActions");
63972    });
63973    handler.on("GetPageJSActions", function ({
63974      pageIndex
63975    }) {
63976      return pdfManager.getPage(pageIndex).then(page => pdfManager.ensure(page, "jsActions"));
63977    });
63978    handler.on("GetAnnotationsByType", async function ({
63979      types,
63980      pageIndexesToSkip
63981    }) {
63982      const [numPages, annotationGlobals] = await Promise.all([pdfManager.ensureDoc("numPages"), pdfManager.ensureDoc("annotationGlobals")]);
63983      if (!annotationGlobals) {
63984        return null;
63985      }
63986      const pagePromises = [];
63987      const annotationPromises = [];
63988      let task = null;
63989      try {
63990        for (let i = 0, ii = numPages; i < ii; i++) {
63991          if (pageIndexesToSkip?.has(i)) {
63992            continue;
63993          }
63994          if (!task) {
63995            task = new WorkerTask("GetAnnotationsByType");
63996            startWorkerTask(task);
63997          }
63998          pagePromises.push(pdfManager.getPage(i).then(page => page.collectAnnotationsByType(handler, task, types, annotationPromises, annotationGlobals)));
63999        }
64000        await Promise.all(pagePromises);
64001        const annotations = await Promise.all(annotationPromises);
64002        return annotations.filter(a => !!a);
64003      } finally {
64004        if (task) {
64005          finishWorkerTask(task);
64006        }
64007      }
64008    });
64009    handler.on("GetOutline", function (data) {
64010      return pdfManager.ensureCatalog("documentOutline");
64011    });
64012    handler.on("GetOptionalContentConfig", function (data) {
64013      return pdfManager.ensureCatalog("optionalContentConfig");
64014    });
64015    handler.on("GetPermissions", function (data) {
64016      return pdfManager.ensureCatalog("permissions");
64017    });
64018    handler.on("GetMetadata", function (data) {
64019      return Promise.all([pdfManager.ensureDoc("documentInfo"), pdfManager.ensureCatalog("metadata"), pdfManager.ensureCatalog("hasStructTree")]);
64020    });
64021    handler.on("GetMarkInfo", function (data) {
64022      return pdfManager.ensureCatalog("markInfo");
64023    });
64024    handler.on("GetData", function (data) {
64025      return pdfManager.requestLoadedStream().then(stream => stream.bytes);
64026    });
64027    handler.on("GetAnnotations", function ({
64028      pageIndex,
64029      intent
64030    }) {
64031      return pdfManager.getPage(pageIndex).then(function (page) {
64032        const task = new WorkerTask(`GetAnnotations: page ${pageIndex}`);
64033        startWorkerTask(task);
64034        return page.getAnnotationsData(handler, task, intent).finally(() => {
64035          finishWorkerTask(task);
64036        });
64037      });
64038    });
64039    handler.on("GetFieldObjects", function (data) {
64040      return pdfManager.ensureDoc("fieldObjects").then(fieldObjects => fieldObjects?.allFields || null);
64041    });
64042    handler.on("HasJSActions", function (data) {
64043      return pdfManager.ensureDoc("hasJSActions");
64044    });
64045    handler.on("GetCalculationOrderIds", function (data) {
64046      return pdfManager.ensureDoc("calculationOrderIds");
64047    });
64048    handler.on("ExtractPages", async function ({
64049      pageInfos,
64050      annotationStorage
64051    }) {
64052      if (!pageInfos) {
64053        warn("extractPages: nothing to extract.");
64054        return null;
64055      }
64056      if (!Array.isArray(pageInfos)) {
64057        pageInfos = [pageInfos];
64058      }
64059      let newDocumentId = 0;
64060      for (const pageInfo of pageInfos) {
64061        if (pageInfo.image) {
64062          continue;
64063        }
64064        if (pageInfo.document === null) {
64065          pageInfo.document = pdfManager.pdfDocument;
64066        } else if (ArrayBuffer.isView(pageInfo.document)) {
64067          const manager = new LocalPdfManager({
64068            source: pageInfo.document,
64069            docId: `${docId}_extractPages_${newDocumentId++}`,
64070            handler,
64071            password: pageInfo.password ?? null,
64072            evaluatorOptions: Object.assign({}, pdfManager.evaluatorOptions)
64073          });
64074          let recoveryMode = false;
64075          let isValid = true;
64076          while (true) {
64077            try {
64078              await manager.requestLoadedStream();
64079              await manager.initDocument(recoveryMode);
64080              break;
64081            } catch (e) {
64082              if (e instanceof XRefParseException) {
64083                if (recoveryMode === false) {
64084                  recoveryMode = true;
64085                  continue;
64086                } else {
64087                  isValid = false;
64088                  warn("extractPages: XRefParseException.");
64089                }
64090              } else if (e instanceof PasswordException) {
64091                try {
64092                  const password = await getPassword(e);
64093                  manager.updatePassword(password);
64094                } catch {
64095                  isValid = false;
64096                  warn("extractPages: invalid password.");
64097                }
64098              } else {
64099                isValid = false;
vendor: 4,745 bytes, lines 64100-64222
64100                warn("extractPages: invalid document.");
64101              }
64102              if (!isValid) {
64103                break;
64104              }
64105            }
64106          }
64107          if (!isValid) {
64108            pageInfo.document = null;
64109          }
64110          const isPureXfa = await manager.ensureDoc("isPureXfa");
64111          if (isPureXfa) {
64112            pageInfo.document = null;
64113            warn("extractPages does not support pure XFA documents.");
64114          } else {
64115            pageInfo.document = manager.pdfDocument;
64116          }
64117        } else {
64118          warn("extractPages: invalid document.");
64119        }
64120      }
64121      let task;
64122      try {
64123        const pdfEditor = new PDFEditor();
64124        task = new WorkerTask(`ExtractPages: ${pageInfos.length} page(s)`);
64125        startWorkerTask(task);
64126        const buffer = await pdfEditor.extractPages(pageInfos, annotationStorage, pdfManager.pdfDocument, handler, task);
64127        return buffer;
64128      } catch (reason) {
64129        warn(`extractPages: "${reason}".`);
64130        return null;
64131      } finally {
64132        if (task) {
64133          finishWorkerTask(task);
64134        }
64135      }
64136    });
64137    handler.on("SaveDocument", async function ({
64138      isPureXfa,
64139      numPages,
64140      annotationStorage,
64141      filename
64142    }) {
64143      const globalPromises = [pdfManager.requestLoadedStream(), pdfManager.ensureCatalog("acroForm"), pdfManager.ensureCatalog("acroFormRef"), pdfManager.ensureDoc("startXRef"), pdfManager.ensureDoc("xref"), pdfManager.ensureCatalog("structTreeRoot")];
64144      const changes = new RefSetCache();
64145      const promises = [];
64146      const newAnnotationsByPage = !isPureXfa ? getNewAnnotationsMap(annotationStorage) : null;
64147      const [stream, acroForm, acroFormRef, startXRef, xref, _structTreeRoot] = await Promise.all(globalPromises);
64148      const catalogRef = xref.trailer.getRaw("Root") || null;
64149      let structTreeRoot;
64150      if (newAnnotationsByPage) {
64151        if (!_structTreeRoot) {
64152          if (await StructTreeRoot.canCreateStructureTree({
64153            catalogRef,
64154            pdfManager,
64155            newAnnotationsByPage
64156          })) {
64157            structTreeRoot = null;
64158          }
64159        } else if (await _structTreeRoot.canUpdateStructTree({
64160          pdfManager,
64161          newAnnotationsByPage
64162        })) {
64163          structTreeRoot = _structTreeRoot;
64164        }
64165        const imagePromises = AnnotationFactory.generateImages(annotationStorage.values(), xref, pdfManager.evaluatorOptions.isOffscreenCanvasSupported);
64166        const newAnnotationPromises = structTreeRoot === undefined ? promises : [];
64167        for (const [pageIndex, annotations] of newAnnotationsByPage) {
64168          newAnnotationPromises.push(pdfManager.getPage(pageIndex).then(page => {
64169            const task = new WorkerTask(`Save (editor): page ${pageIndex}`);
64170            startWorkerTask(task);
64171            return page.saveNewAnnotations(handler, task, annotations, imagePromises, changes).finally(() => {
64172              finishWorkerTask(task);
64173            });
64174          }));
64175        }
64176        if (structTreeRoot === null) {
64177          promises.push(Promise.all(newAnnotationPromises).then(async () => {
64178            await StructTreeRoot.createStructureTree({
64179              newAnnotationsByPage,
64180              xref,
64181              catalogRef,
64182              pdfManager,
64183              changes
64184            });
64185          }));
64186        } else if (structTreeRoot) {
64187          promises.push(Promise.all(newAnnotationPromises).then(async () => {
64188            await structTreeRoot.updateStructureTree({
64189              newAnnotationsByPage,
64190              pdfManager,
64191              changes
64192            });
64193          }));
64194        }
64195      }
64196      if (isPureXfa) {
64197        promises.push(pdfManager.ensureDoc("serializeXfaData", [annotationStorage]));
64198      } else {
64199        for (let pageIndex = 0; pageIndex < numPages; pageIndex++) {
64200          promises.push(pdfManager.getPage(pageIndex).then(function (page) {
64201            const task = new WorkerTask(`Save: page ${pageIndex}`);
64202            startWorkerTask(task);
64203            return page.save(handler, task, annotationStorage, changes).finally(() => {
64204              finishWorkerTask(task);
64205            });
64206          }));
64207        }
64208      }
64209      const refs = await Promise.all(promises);
64210      let xfaData = null;
64211      if (isPureXfa) {
64212        xfaData = refs[0];
64213        if (!xfaData) {
64214          return stream.bytes;
64215        }
64216      } else if (changes.size === 0) {
64217        return stream.bytes;
64218      }
64219      const needAppearances = acroFormRef && acroForm instanceof Dict && changes.values().some(ref => ref.needAppearances);
64220      const xfa = acroForm instanceof Dict && acroForm.get("XFA") || null;
64221      let xfaDatasetsRef = null;
64222      let hasXfaDatasetsEntry = false;
64223      if (Array.isArray(xfa)) {
64224        for (let i = 0, ii = xfa.length; i < ii; i += 2) {
64225          if (xfa[i] === "datasets") {
64226            xfaDatasetsRef = xfa[i + 1];
64227            hasXfaDatasetsEntry = true;
64228          }
64229        }
64230        if (xfaDatasetsRef === null) {
64231          xfaDatasetsRef = xref.getNewTemporaryRef();
64232        }
64233      } else if (xfa) {
64234        warn("Unsupported XFA type.");
64235      }
64236      let newXrefInfo = Object.create(null);
64237      if (xref.trailer) {
64238        const infoMap = new Map();
64239        const xrefInfo = xref.trailer.get("Info") || null;
64240        if (xrefInfo instanceof Dict) {
64241          for (const [key, value] of xrefInfo) {
64242            if (typeof value === "string") {
64243              infoMap.set(key, stringToPDFString(value));
64244            }
64245          }
64246        }
64247        newXrefInfo = {
64248          rootRef: catalogRef,
64249          encryptRef: xref.trailer.getRaw("Encrypt") || null,
64250          newRef: xref.getNewTemporaryRef(),
64251          infoRef: xref.trailer.getRaw("Info") || null,
64252          infoMap,
64253          fileIds: xref.trailer.get("ID") || null,
64254          startXRef,
64255          filename
64256        };
64257      }
64258      return incrementalUpdate({
64259        originalData: stream.bytes,
64260        xrefInfo: newXrefInfo,
64261        changes,
64262        xref,
64263        hasXfa: !!xfa,
64264        xfaDatasetsRef,
64265        hasXfaDatasetsEntry,
64266        needAppearances,
64267        acroFormRef,
64268        acroForm,
64269        xfaData,
64270        useXrefStream: isDict(xref.topDict, "XRef")
64271      }).finally(() => {
64272        xref.resetNewTemporaryRef();
64273      });
64274    });
64275    handler.on("GetOperatorList", function (data, sink) {
64276      const {
64277        pageId,
64278        pageIndex
64279      } = data;
64280      pdfManager.getPage(pageId).then(function (page) {
64281        const task = new WorkerTask(`GetOperatorList: page ${pageIndex}`);
64282        startWorkerTask(task);
64283        const start = verbosity >= VerbosityLevel.INFOS ? Date.now() : 0;
64284        page.getOperatorList({
64285          handler,
64286          sink,
64287          task,
64288          intent: data.intent,
64289          cacheKey: data.cacheKey,
64290          annotationStorage: data.annotationStorage,
64291          modifiedIds: data.modifiedIds,
64292          pageIndex
64293        }).then(operatorListInfo => {
64294          if (start) {
64295            info(`page=${pageIndex + 1} - getOperatorList: time=` + `${Date.now() - start}ms, len=${operatorListInfo.length}`);
64296          }
64297          sink.close();
64298        }, reason => {
64299          if (task.terminated) {
64300            return;
64301          }
64302          sink.error(reason);
64303        }).finally(() => {
64304          finishWorkerTask(task);
64305        });
64306      });
64307    });
64308    handler.on("GetTextContent", function (data, sink) {
64309      const {
64310        pageId,
64311        pageIndex,
64312        includeMarkedContent,
64313        disableNormalization
64314      } = data;
64315      pdfManager.getPage(pageId).then(function (page) {
64316        const task = new WorkerTask("GetTextContent: page " + pageIndex);
64317        startWorkerTask(task);
64318        const start = verbosity >= VerbosityLevel.INFOS ? Date.now() : 0;
64319        page.extractTextContent({
64320          handler,
64321          task,
64322          sink,
64323          includeMarkedContent,
64324          disableNormalization
64325        }).then(() => {
64326          if (start) {
64327            info(`page=${pageIndex + 1} - getTextContent: time=` + `${Date.now() - start}ms`);
64328          }
64329          sink.close();
64330        }, reason => {
64331          if (task.terminated) {
64332            return;
64333          }
64334          sink.error(reason);
64335        }).finally(() => {
64336          finishWorkerTask(task);
64337        });
64338      });
64339    });
64340    handler.on("GetStructTree", function (data) {
64341      return pdfManager.getPage(data.pageIndex).then(page => pdfManager.ensure(page, "getStructTree"));
64342    });
64343    handler.on("FontFallback", function (data) {
64344      return pdfManager.fontFallback(data.id, handler);
64345    });
64346    handler.on("Cleanup", function (data) {
64347      return pdfManager.cleanup(true);
64348    });
64349    handler.on("Terminate", async function (data) {
64350      terminated = true;
64351      const waitOn = [];
64352      if (pdfManager) {
64353        pdfManager.terminate(new AbortException("Worker was terminated."));
64354        const cleanupPromise = pdfManager.cleanup();
64355        waitOn.push(cleanupPromise);
64356        pdfManager = null;
64357      } else {
64358        clearGlobalCaches();
64359      }
64360      cancelXHRs?.(new AbortException("Worker was terminated."));
64361      for (const task of WorkerTasks) {
64362        waitOn.push(task.finished);
64363        task.terminate();
64364      }
64365      await Promise.all(waitOn);
64366      handler.destroy();
64367      handler = null;
64368    });
64369    handler.on("Ready", function (data
vendor: 442 bytes, lines 64369-64390
64369) {
64370      setupDoc(docParams);
64371      docParams = null;
64372    });
64373    return workerHandlerName;
64374  }
64375  static initializeFromPort(port) {
64376    const handler = new MessageHandler("worker", "main", port);
64377    this.setup(handler, port);
64378    handler.send("ready", null);
64379  }
64380}
64381
64382;// ./src/pdf.worker.js
64383
64384globalThis.pdfjsWorker = {
64385  WorkerMessageHandler: WorkerMessageHandler
64386};
64387
64388export { WorkerMessageHandler };
64389
64390//# sourceMappingURL=pdf.worker.mjs.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.