aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-07 16:25:53 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-07 16:26:04 +0100
commit9c2787182d7db731b18f26907efeaf6ca884803c (patch)
tree2b98499541df46b542592894e6059ddbe2c9dcf6
parent1c4b198c69fe82eb3ddfdf6b252255ad3d3ba492 (diff)
downloadwww-9c2787182d7db731b18f26907efeaf6ca884803c.tar.gz
www-9c2787182d7db731b18f26907efeaf6ca884803c.zip
updating investor page
-rw-r--r--dist/js/pdf-view.js100
-rw-r--r--dist/js/pdf.js11515
-rw-r--r--dist/js/pdf.min.js8
-rw-r--r--dist/js/pdf.worker.js43506
-rw-r--r--dist/js/pdf.worker.min.js28
-rw-r--r--index.html.j22
-rw-r--r--investors.html.j283
-rw-r--r--locale/de/LC_MESSAGES/messages.po244
-rw-r--r--locale/en/LC_MESSAGES/messages.po240
-rw-r--r--locale/es/LC_MESSAGES/messages.po244
-rw-r--r--locale/fr/LC_MESSAGES/messages.po244
-rw-r--r--locale/it/LC_MESSAGES/messages.po244
-rw-r--r--presentations/investors2017.pdfbin0 -> 4286360 bytes
13 files changed, 55867 insertions, 591 deletions
diff --git a/dist/js/pdf-view.js b/dist/js/pdf-view.js
new file mode 100644
index 00000000..74e668f3
--- /dev/null
+++ b/dist/js/pdf-view.js
@@ -0,0 +1,100 @@
1/** This code is under the Apache License Version 2.0, January 2004
2 * http://www.apache.org/licenses/, as it is heavily based on
3 * documentation of pdf.js (which is under Apache License v2.0)
4 */
5
6PDFJS.workerSrc = 'dist/js/pdf.worker.min.js';
7
8var url = 'presentations/investors2017.pdf';
9
10var pdfDoc = null,
11 pageNum = 1,
12 pageRendering = false,
13 pageNumPending = null,
14 scale = 1,
15 canvasLeft = document.getElementById('the-canvas-left'),
16 canvasRight = document.getElementById('the-canvas-right');
17
18/**
19 * Get page info from document, resize canvas accordingly, and render page.
20 * @param num Page number.
21 */
22function renderPage(canvas,num) {
23 pageRendering = true;
24 // Using promise to fetch the page
25 pdfDoc.getPage(num).then(function(page) {
26 var viewport = page.getViewport(scale);
27 canvas.height = viewport.height;
28 canvas.width = viewport.width;
29
30 // Render PDF page into canvas context
31 var renderContext = {
32 canvasContext: canvas.getContext('2d'),
33 viewport: viewport
34 };
35 var renderTask = page.render(renderContext);
36
37 // Wait for rendering to finish
38 renderTask.promise.then(function() {
39 pageRendering = false;
40 if (pageNumPending !== null) {
41 // New page rendering is pending
42 renderPage(pageNumPending);
43 pageNumPending = null;
44 }
45 });
46 });
47
48 // Update page counters
49 document.getElementById('page_num').textContent = pageNum;
50}
51
52/**
53 * If another page rendering in progress, waits until the rendering is
54 * finised. Otherwise, executes rendering immediately.
55 */
56function queueRenderPage(num) {
57 if (pageRendering) {
58 pageNumPending = num;
59 } else {
60 renderPage(canvasLeft,num);
61 renderPage(canvasRight,num+1);
62 }
63}
64
65/**
66 * Displays previous page.
67 */
68function onPrevPage() {
69 if (pageNum <= 1) {
70 return;
71 }
72 pageNum--;
73 queueRenderPage(pageNum);
74}
75document.getElementById('canvas-left').addEventListener('click', onPrevPage);
76
77/**
78 * Displays next page.
79 */
80function onNextPage() {
81 if (pageNum >= pdfDoc.numPages - 1) {
82 return;
83 }
84 pageNum++;
85 queueRenderPage(pageNum);
86}
87document.getElementById('canvas-right').addEventListener('click', onNextPage);
88
89document.getElementById('canvas-right').style.display = 'block';
90document.getElementById('canvas-left').style.display = 'block';
91
92/**
93 * Asynchronously downloads PDF.
94 */
95PDFJS.getDocument(url).then(function(pdfDoc_) {
96 pdfDoc = pdfDoc_;
97
98 // Initial/first page rendering
99 renderPage(pageNum);
100});
diff --git a/dist/js/pdf.js b/dist/js/pdf.js
new file mode 100644
index 00000000..2d3c3c83
--- /dev/null
+++ b/dist/js/pdf.js
@@ -0,0 +1,11515 @@
1/* Copyright 2012 Mozilla Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15/* jshint globalstrict: false */
16/* umdutils ignore */
17
18(function (root, factory) {
19 'use strict';
20 if (typeof define === 'function' && define.amd) {
21define('pdfjs-dist/build/pdf', ['exports'], factory);
22 } else if (typeof exports !== 'undefined') {
23 factory(exports);
24 } else {
25factory((root.pdfjsDistBuildPdf = {}));
26 }
27}(this, function (exports) {
28 // Use strict in our context only - users might not want it
29 'use strict';
30
31var pdfjsVersion = '1.6.210';
32var pdfjsBuild = '4ce2356';
33
34 var pdfjsFilePath =
35 typeof document !== 'undefined' && document.currentScript ?
36 document.currentScript.src : null;
37
38 var pdfjsLibs = {};
39
40 (function pdfjsWrapper() {
41
42
43
44(function (root, factory) {
45 {
46 factory((root.pdfjsSharedUtil = {}));
47 }
48}(this, function (exports) {
49
50var globalScope = (typeof window !== 'undefined') ? window :
51 (typeof global !== 'undefined') ? global :
52 (typeof self !== 'undefined') ? self : this;
53
54var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
55
56var TextRenderingMode = {
57 FILL: 0,
58 STROKE: 1,
59 FILL_STROKE: 2,
60 INVISIBLE: 3,
61 FILL_ADD_TO_PATH: 4,
62 STROKE_ADD_TO_PATH: 5,
63 FILL_STROKE_ADD_TO_PATH: 6,
64 ADD_TO_PATH: 7,
65 FILL_STROKE_MASK: 3,
66 ADD_TO_PATH_FLAG: 4
67};
68
69var ImageKind = {
70 GRAYSCALE_1BPP: 1,
71 RGB_24BPP: 2,
72 RGBA_32BPP: 3
73};
74
75var AnnotationType = {
76 TEXT: 1,
77 LINK: 2,
78 FREETEXT: 3,
79 LINE: 4,
80 SQUARE: 5,
81 CIRCLE: 6,
82 POLYGON: 7,
83 POLYLINE: 8,
84 HIGHLIGHT: 9,
85 UNDERLINE: 10,
86 SQUIGGLY: 11,
87 STRIKEOUT: 12,
88 STAMP: 13,
89 CARET: 14,
90 INK: 15,
91 POPUP: 16,
92 FILEATTACHMENT: 17,
93 SOUND: 18,
94 MOVIE: 19,
95 WIDGET: 20,
96 SCREEN: 21,
97 PRINTERMARK: 22,
98 TRAPNET: 23,
99 WATERMARK: 24,
100 THREED: 25,
101 REDACT: 26
102};
103
104var AnnotationFlag = {
105 INVISIBLE: 0x01,
106 HIDDEN: 0x02,
107 PRINT: 0x04,
108 NOZOOM: 0x08,
109 NOROTATE: 0x10,
110 NOVIEW: 0x20,
111 READONLY: 0x40,
112 LOCKED: 0x80,
113 TOGGLENOVIEW: 0x100,
114 LOCKEDCONTENTS: 0x200
115};
116
117var AnnotationFieldFlag = {
118 READONLY: 0x0000001,
119 REQUIRED: 0x0000002,
120 NOEXPORT: 0x0000004,
121 MULTILINE: 0x0001000,
122 PASSWORD: 0x0002000,
123 NOTOGGLETOOFF: 0x0004000,
124 RADIO: 0x0008000,
125 PUSHBUTTON: 0x0010000,
126 COMBO: 0x0020000,
127 EDIT: 0x0040000,
128 SORT: 0x0080000,
129 FILESELECT: 0x0100000,
130 MULTISELECT: 0x0200000,
131 DONOTSPELLCHECK: 0x0400000,
132 DONOTSCROLL: 0x0800000,
133 COMB: 0x1000000,
134 RICHTEXT: 0x2000000,
135 RADIOSINUNISON: 0x2000000,
136 COMMITONSELCHANGE: 0x4000000,
137};
138
139var AnnotationBorderStyleType = {
140 SOLID: 1,
141 DASHED: 2,
142 BEVELED: 3,
143 INSET: 4,
144 UNDERLINE: 5
145};
146
147var StreamType = {
148 UNKNOWN: 0,
149 FLATE: 1,
150 LZW: 2,
151 DCT: 3,
152 JPX: 4,
153 JBIG: 5,
154 A85: 6,
155 AHX: 7,
156 CCF: 8,
157 RL: 9
158};
159
160var FontType = {
161 UNKNOWN: 0,
162 TYPE1: 1,
163 TYPE1C: 2,
164 CIDFONTTYPE0: 3,
165 CIDFONTTYPE0C: 4,
166 TRUETYPE: 5,
167 CIDFONTTYPE2: 6,
168 TYPE3: 7,
169 OPENTYPE: 8,
170 TYPE0: 9,
171 MMTYPE1: 10
172};
173
174var VERBOSITY_LEVELS = {
175 errors: 0,
176 warnings: 1,
177 infos: 5
178};
179
180// All the possible operations for an operator list.
181var OPS = {
182 // Intentionally start from 1 so it is easy to spot bad operators that will be
183 // 0's.
184 dependency: 1,
185 setLineWidth: 2,
186 setLineCap: 3,
187 setLineJoin: 4,
188 setMiterLimit: 5,
189 setDash: 6,
190 setRenderingIntent: 7,
191 setFlatness: 8,
192 setGState: 9,
193 save: 10,
194 restore: 11,
195 transform: 12,
196 moveTo: 13,
197 lineTo: 14,
198 curveTo: 15,
199 curveTo2: 16,
200 curveTo3: 17,
201 closePath: 18,
202 rectangle: 19,
203 stroke: 20,
204 closeStroke: 21,
205 fill: 22,
206 eoFill: 23,
207 fillStroke: 24,
208 eoFillStroke: 25,
209 closeFillStroke: 26,
210 closeEOFillStroke: 27,
211 endPath: 28,
212 clip: 29,
213 eoClip: 30,
214 beginText: 31,
215 endText: 32,
216 setCharSpacing: 33,
217 setWordSpacing: 34,
218 setHScale: 35,
219 setLeading: 36,
220 setFont: 37,
221 setTextRenderingMode: 38,
222 setTextRise: 39,
223 moveText: 40,
224 setLeadingMoveText: 41,
225 setTextMatrix: 42,
226 nextLine: 43,
227 showText: 44,
228 showSpacedText: 45,
229 nextLineShowText: 46,
230 nextLineSetSpacingShowText: 47,
231 setCharWidth: 48,
232 setCharWidthAndBounds: 49,
233 setStrokeColorSpace: 50,
234 setFillColorSpace: 51,
235 setStrokeColor: 52,
236 setStrokeColorN: 53,
237 setFillColor: 54,
238 setFillColorN: 55,
239 setStrokeGray: 56,
240 setFillGray: 57,
241 setStrokeRGBColor: 58,
242 setFillRGBColor: 59,
243 setStrokeCMYKColor: 60,
244 setFillCMYKColor: 61,
245 shadingFill: 62,
246 beginInlineImage: 63,
247 beginImageData: 64,
248 endInlineImage: 65,
249 paintXObject: 66,
250 markPoint: 67,
251 markPointProps: 68,
252 beginMarkedContent: 69,
253 beginMarkedContentProps: 70,
254 endMarkedContent: 71,
255 beginCompat: 72,
256 endCompat: 73,
257 paintFormXObjectBegin: 74,
258 paintFormXObjectEnd: 75,
259 beginGroup: 76,
260 endGroup: 77,
261 beginAnnotations: 78,
262 endAnnotations: 79,
263 beginAnnotation: 80,
264 endAnnotation: 81,
265 paintJpegXObject: 82,
266 paintImageMaskXObject: 83,
267 paintImageMaskXObjectGroup: 84,
268 paintImageXObject: 85,
269 paintInlineImageXObject: 86,
270 paintInlineImageXObjectGroup: 87,
271 paintImageXObjectRepeat: 88,
272 paintImageMaskXObjectRepeat: 89,
273 paintSolidColorImageMask: 90,
274 constructPath: 91
275};
276
277var verbosity = VERBOSITY_LEVELS.warnings;
278
279function setVerbosityLevel(level) {
280 verbosity = level;
281}
282
283function getVerbosityLevel() {
284 return verbosity;
285}
286
287// A notice for devs. These are good for things that are helpful to devs, such
288// as warning that Workers were disabled, which is important to devs but not
289// end users.
290function info(msg) {
291 if (verbosity >= VERBOSITY_LEVELS.infos) {
292 console.log('Info: ' + msg);
293 }
294}
295
296// Non-fatal warnings.
297function warn(msg) {
298 if (verbosity >= VERBOSITY_LEVELS.warnings) {
299 console.log('Warning: ' + msg);
300 }
301}
302
303// Deprecated API function -- display regardless of the PDFJS.verbosity setting.
304function deprecated(details) {
305 console.log('Deprecated API usage: ' + details);
306}
307
308// Fatal errors that should trigger the fallback UI and halt execution by
309// throwing an exception.
310function error(msg) {
311 if (verbosity >= VERBOSITY_LEVELS.errors) {
312 console.log('Error: ' + msg);
313 console.log(backtrace());
314 }
315 throw new Error(msg);
316}
317
318function backtrace() {
319 try {
320 throw new Error();
321 } catch (e) {
322 return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
323 }
324}
325
326function assert(cond, msg) {
327 if (!cond) {
328 error(msg);
329 }
330}
331
332var UNSUPPORTED_FEATURES = {
333 unknown: 'unknown',
334 forms: 'forms',
335 javaScript: 'javaScript',
336 smask: 'smask',
337 shadingPattern: 'shadingPattern',
338 font: 'font'
339};
340
341// Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
342function isSameOrigin(baseUrl, otherUrl) {
343 try {
344 var base = new URL(baseUrl);
345 if (!base.origin || base.origin === 'null') {
346 return false; // non-HTTP url
347 }
348 } catch (e) {
349 return false;
350 }
351
352 var other = new URL(otherUrl, base);
353 return base.origin === other.origin;
354}
355
356// Validates if URL is safe and allowed, e.g. to avoid XSS.
357function isValidUrl(url, allowRelative) {
358 if (!url || typeof url !== 'string') {
359 return false;
360 }
361 // RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
362 // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
363 var protocol = /^[a-z][a-z0-9+\-.]*(?=:)/i.exec(url);
364 if (!protocol) {
365 return allowRelative;
366 }
367 protocol = protocol[0].toLowerCase();
368 switch (protocol) {
369 case 'http':
370 case 'https':
371 case 'ftp':
372 case 'mailto':
373 case 'tel':
374 return true;
375 default:
376 return false;
377 }
378}
379
380function shadow(obj, prop, value) {
381 Object.defineProperty(obj, prop, { value: value,
382 enumerable: true,
383 configurable: true,
384 writable: false });
385 return value;
386}
387
388function getLookupTableFactory(initializer) {
389 var lookup;
390 return function () {
391 if (initializer) {
392 lookup = Object.create(null);
393 initializer(lookup);
394 initializer = null;
395 }
396 return lookup;
397 };
398}
399
400var PasswordResponses = {
401 NEED_PASSWORD: 1,
402 INCORRECT_PASSWORD: 2
403};
404
405var PasswordException = (function PasswordExceptionClosure() {
406 function PasswordException(msg, code) {
407 this.name = 'PasswordException';
408 this.message = msg;
409 this.code = code;
410 }
411
412 PasswordException.prototype = new Error();
413 PasswordException.constructor = PasswordException;
414
415 return PasswordException;
416})();
417
418var UnknownErrorException = (function UnknownErrorExceptionClosure() {
419 function UnknownErrorException(msg, details) {
420 this.name = 'UnknownErrorException';
421 this.message = msg;
422 this.details = details;
423 }
424
425 UnknownErrorException.prototype = new Error();
426 UnknownErrorException.constructor = UnknownErrorException;
427
428 return UnknownErrorException;
429})();
430
431var InvalidPDFException = (function InvalidPDFExceptionClosure() {
432 function InvalidPDFException(msg) {
433 this.name = 'InvalidPDFException';
434 this.message = msg;
435 }
436
437 InvalidPDFException.prototype = new Error();
438 InvalidPDFException.constructor = InvalidPDFException;
439
440 return InvalidPDFException;
441})();
442
443var MissingPDFException = (function MissingPDFExceptionClosure() {
444 function MissingPDFException(msg) {
445 this.name = 'MissingPDFException';
446 this.message = msg;
447 }
448
449 MissingPDFException.prototype = new Error();
450 MissingPDFException.constructor = MissingPDFException;
451
452 return MissingPDFException;
453})();
454
455var UnexpectedResponseException =
456 (function UnexpectedResponseExceptionClosure() {
457 function UnexpectedResponseException(msg, status) {
458 this.name = 'UnexpectedResponseException';
459 this.message = msg;
460 this.status = status;
461 }
462
463 UnexpectedResponseException.prototype = new Error();
464 UnexpectedResponseException.constructor = UnexpectedResponseException;
465
466 return UnexpectedResponseException;
467})();
468
469var NotImplementedException = (function NotImplementedExceptionClosure() {
470 function NotImplementedException(msg) {
471 this.message = msg;
472 }
473
474 NotImplementedException.prototype = new Error();
475 NotImplementedException.prototype.name = 'NotImplementedException';
476 NotImplementedException.constructor = NotImplementedException;
477
478 return NotImplementedException;
479})();
480
481var MissingDataException = (function MissingDataExceptionClosure() {
482 function MissingDataException(begin, end) {
483 this.begin = begin;
484 this.end = end;
485 this.message = 'Missing data [' + begin + ', ' + end + ')';
486 }
487
488 MissingDataException.prototype = new Error();
489 MissingDataException.prototype.name = 'MissingDataException';
490 MissingDataException.constructor = MissingDataException;
491
492 return MissingDataException;
493})();
494
495var XRefParseException = (function XRefParseExceptionClosure() {
496 function XRefParseException(msg) {
497 this.message = msg;
498 }
499
500 XRefParseException.prototype = new Error();
501 XRefParseException.prototype.name = 'XRefParseException';
502 XRefParseException.constructor = XRefParseException;
503
504 return XRefParseException;
505})();
506
507var NullCharactersRegExp = /\x00/g;
508
509function removeNullCharacters(str) {
510 if (typeof str !== 'string') {
511 warn('The argument for removeNullCharacters must be a string.');
512 return str;
513 }
514 return str.replace(NullCharactersRegExp, '');
515}
516
517function bytesToString(bytes) {
518 assert(bytes !== null && typeof bytes === 'object' &&
519 bytes.length !== undefined, 'Invalid argument for bytesToString');
520 var length = bytes.length;
521 var MAX_ARGUMENT_COUNT = 8192;
522 if (length < MAX_ARGUMENT_COUNT) {
523 return String.fromCharCode.apply(null, bytes);
524 }
525 var strBuf = [];
526 for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
527 var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
528 var chunk = bytes.subarray(i, chunkEnd);
529 strBuf.push(String.fromCharCode.apply(null, chunk));
530 }
531 return strBuf.join('');
532}
533
534function stringToBytes(str) {
535 assert(typeof str === 'string', 'Invalid argument for stringToBytes');
536 var length = str.length;
537 var bytes = new Uint8Array(length);
538 for (var i = 0; i < length; ++i) {
539 bytes[i] = str.charCodeAt(i) & 0xFF;
540 }
541 return bytes;
542}
543
544/**
545 * Gets length of the array (Array, Uint8Array, or string) in bytes.
546 * @param {Array|Uint8Array|string} arr
547 * @returns {number}
548 */
549function arrayByteLength(arr) {
550 if (arr.length !== undefined) {
551 return arr.length;
552 }
553 assert(arr.byteLength !== undefined);
554 return arr.byteLength;
555}
556
557/**
558 * Combines array items (arrays) into single Uint8Array object.
559 * @param {Array} arr - the array of the arrays (Array, Uint8Array, or string).
560 * @returns {Uint8Array}
561 */
562function arraysToBytes(arr) {
563 // Shortcut: if first and only item is Uint8Array, return it.
564 if (arr.length === 1 && (arr[0] instanceof Uint8Array)) {
565 return arr[0];
566 }
567 var resultLength = 0;
568 var i, ii = arr.length;
569 var item, itemLength ;
570 for (i = 0; i < ii; i++) {
571 item = arr[i];
572 itemLength = arrayByteLength(item);
573 resultLength += itemLength;
574 }
575 var pos = 0;
576 var data = new Uint8Array(resultLength);
577 for (i = 0; i < ii; i++) {
578 item = arr[i];
579 if (!(item instanceof Uint8Array)) {
580 if (typeof item === 'string') {
581 item = stringToBytes(item);
582 } else {
583 item = new Uint8Array(item);
584 }
585 }
586 itemLength = item.byteLength;
587 data.set(item, pos);
588 pos += itemLength;
589 }
590 return data;
591}
592
593function string32(value) {
594 return String.fromCharCode((value >> 24) & 0xff, (value >> 16) & 0xff,
595 (value >> 8) & 0xff, value & 0xff);
596}
597
598function log2(x) {
599 var n = 1, i = 0;
600 while (x > n) {
601 n <<= 1;
602 i++;
603 }
604 return i;
605}
606
607function readInt8(data, start) {
608 return (data[start] << 24) >> 24;
609}
610
611function readUint16(data, offset) {
612 return (data[offset] << 8) | data[offset + 1];
613}
614
615function readUint32(data, offset) {
616 return ((data[offset] << 24) | (data[offset + 1] << 16) |
617 (data[offset + 2] << 8) | data[offset + 3]) >>> 0;
618}
619
620// Lazy test the endianness of the platform
621// NOTE: This will be 'true' for simulated TypedArrays
622function isLittleEndian() {
623 var buffer8 = new Uint8Array(2);
624 buffer8[0] = 1;
625 var buffer16 = new Uint16Array(buffer8.buffer);
626 return (buffer16[0] === 1);
627}
628
629// Checks if it's possible to eval JS expressions.
630function isEvalSupported() {
631 try {
632 /* jshint evil: true */
633 new Function('');
634 return true;
635 } catch (e) {
636 return false;
637 }
638}
639
640var Uint32ArrayView = (function Uint32ArrayViewClosure() {
641
642 function Uint32ArrayView(buffer, length) {
643 this.buffer = buffer;
644 this.byteLength = buffer.length;
645 this.length = length === undefined ? (this.byteLength >> 2) : length;
646 ensureUint32ArrayViewProps(this.length);
647 }
648 Uint32ArrayView.prototype = Object.create(null);
649
650 var uint32ArrayViewSetters = 0;
651 function createUint32ArrayProp(index) {
652 return {
653 get: function () {
654 var buffer = this.buffer, offset = index << 2;
655 return (buffer[offset] | (buffer[offset + 1] << 8) |
656 (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24)) >>> 0;
657 },
658 set: function (value) {
659 var buffer = this.buffer, offset = index << 2;
660 buffer[offset] = value & 255;
661 buffer[offset + 1] = (value >> 8) & 255;
662 buffer[offset + 2] = (value >> 16) & 255;
663 buffer[offset + 3] = (value >>> 24) & 255;
664 }
665 };
666 }
667
668 function ensureUint32ArrayViewProps(length) {
669 while (uint32ArrayViewSetters < length) {
670 Object.defineProperty(Uint32ArrayView.prototype,
671 uint32ArrayViewSetters,
672 createUint32ArrayProp(uint32ArrayViewSetters));
673 uint32ArrayViewSetters++;
674 }
675 }
676
677 return Uint32ArrayView;
678})();
679
680exports.Uint32ArrayView = Uint32ArrayView;
681
682var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
683
684var Util = (function UtilClosure() {
685 function Util() {}
686
687 var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
688
689 // makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
690 // creating many intermediate strings.
691 Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
692 rgbBuf[1] = r;
693 rgbBuf[3] = g;
694 rgbBuf[5] = b;
695 return rgbBuf.join('');
696 };
697
698 // Concatenates two transformation matrices together and returns the result.
699 Util.transform = function Util_transform(m1, m2) {
700 return [
701 m1[0] * m2[0] + m1[2] * m2[1],
702 m1[1] * m2[0] + m1[3] * m2[1],
703 m1[0] * m2[2] + m1[2] * m2[3],
704 m1[1] * m2[2] + m1[3] * m2[3],
705 m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
706 m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
707 ];
708 };
709
710 // For 2d affine transforms
711 Util.applyTransform = function Util_applyTransform(p, m) {
712 var xt = p[0] * m[0] + p[1] * m[2] + m[4];
713 var yt = p[0] * m[1] + p[1] * m[3] + m[5];
714 return [xt, yt];
715 };
716
717 Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
718 var d = m[0] * m[3] - m[1] * m[2];
719 var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
720 var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
721 return [xt, yt];
722 };
723
724 // Applies the transform to the rectangle and finds the minimum axially
725 // aligned bounding box.
726 Util.getAxialAlignedBoundingBox =
727 function Util_getAxialAlignedBoundingBox(r, m) {
728
729 var p1 = Util.applyTransform(r, m);
730 var p2 = Util.applyTransform(r.slice(2, 4), m);
731 var p3 = Util.applyTransform([r[0], r[3]], m);
732 var p4 = Util.applyTransform([r[2], r[1]], m);
733 return [
734 Math.min(p1[0], p2[0], p3[0], p4[0]),
735 Math.min(p1[1], p2[1], p3[1], p4[1]),
736 Math.max(p1[0], p2[0], p3[0], p4[0]),
737 Math.max(p1[1], p2[1], p3[1], p4[1])
738 ];
739 };
740
741 Util.inverseTransform = function Util_inverseTransform(m) {
742 var d = m[0] * m[3] - m[1] * m[2];
743 return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d,
744 (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
745 };
746
747 // Apply a generic 3d matrix M on a 3-vector v:
748 // | a b c | | X |
749 // | d e f | x | Y |
750 // | g h i | | Z |
751 // M is assumed to be serialized as [a,b,c,d,e,f,g,h,i],
752 // with v as [X,Y,Z]
753 Util.apply3dTransform = function Util_apply3dTransform(m, v) {
754 return [
755 m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
756 m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
757 m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
758 ];
759 };
760
761 // This calculation uses Singular Value Decomposition.
762 // The SVD can be represented with formula A = USV. We are interested in the
763 // matrix S here because it represents the scale values.
764 Util.singularValueDecompose2dScale =
765 function Util_singularValueDecompose2dScale(m) {
766
767 var transpose = [m[0], m[2], m[1], m[3]];
768
769 // Multiply matrix m with its transpose.
770 var a = m[0] * transpose[0] + m[1] * transpose[2];
771 var b = m[0] * transpose[1] + m[1] * transpose[3];
772 var c = m[2] * transpose[0] + m[3] * transpose[2];
773 var d = m[2] * transpose[1] + m[3] * transpose[3];
774
775 // Solve the second degree polynomial to get roots.
776 var first = (a + d) / 2;
777 var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
778 var sx = first + second || 1;
779 var sy = first - second || 1;
780
781 // Scale values are the square roots of the eigenvalues.
782 return [Math.sqrt(sx), Math.sqrt(sy)];
783 };
784
785 // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
786 // For coordinate systems whose origin lies in the bottom-left, this
787 // means normalization to (BL,TR) ordering. For systems with origin in the
788 // top-left, this means (TL,BR) ordering.
789 Util.normalizeRect = function Util_normalizeRect(rect) {
790 var r = rect.slice(0); // clone rect
791 if (rect[0] > rect[2]) {
792 r[0] = rect[2];
793 r[2] = rect[0];
794 }
795 if (rect[1] > rect[3]) {
796 r[1] = rect[3];
797 r[3] = rect[1];
798 }
799 return r;
800 };
801
802 // Returns a rectangle [x1, y1, x2, y2] corresponding to the
803 // intersection of rect1 and rect2. If no intersection, returns 'false'
804 // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
805 Util.intersect = function Util_intersect(rect1, rect2) {
806 function compare(a, b) {
807 return a - b;
808 }
809
810 // Order points along the axes
811 var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
812 orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
813 result = [];
814
815 rect1 = Util.normalizeRect(rect1);
816 rect2 = Util.normalizeRect(rect2);
817
818 // X: first and second points belong to different rectangles?
819 if ((orderedX[0] === rect1[0] && orderedX[1] === rect2[0]) ||
820 (orderedX[0] === rect2[0] && orderedX[1] === rect1[0])) {
821 // Intersection must be between second and third points
822 result[0] = orderedX[1];
823 result[2] = orderedX[2];
824 } else {
825 return false;
826 }
827
828 // Y: first and second points belong to different rectangles?
829 if ((orderedY[0] === rect1[1] && orderedY[1] === rect2[1]) ||
830 (orderedY[0] === rect2[1] && orderedY[1] === rect1[1])) {
831 // Intersection must be between second and third points
832 result[1] = orderedY[1];
833 result[3] = orderedY[2];
834 } else {
835 return false;
836 }
837
838 return result;
839 };
840
841 Util.sign = function Util_sign(num) {
842 return num < 0 ? -1 : 1;
843 };
844
845 var ROMAN_NUMBER_MAP = [
846 '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM',
847 '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC',
848 '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'
849 ];
850 /**
851 * Converts positive integers to (upper case) Roman numerals.
852 * @param {integer} number - The number that should be converted.
853 * @param {boolean} lowerCase - Indicates if the result should be converted
854 * to lower case letters. The default is false.
855 * @return {string} The resulting Roman number.
856 */
857 Util.toRoman = function Util_toRoman(number, lowerCase) {
858 assert(isInt(number) && number > 0,
859 'The number should be a positive integer.');
860 var pos, romanBuf = [];
861 // Thousands
862 while (number >= 1000) {
863 number -= 1000;
864 romanBuf.push('M');
865 }
866 // Hundreds
867 pos = (number / 100) | 0;
868 number %= 100;
869 romanBuf.push(ROMAN_NUMBER_MAP[pos]);
870 // Tens
871 pos = (number / 10) | 0;
872 number %= 10;
873 romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
874 // Ones
875 romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
876
877 var romanStr = romanBuf.join('');
878 return (lowerCase ? romanStr.toLowerCase() : romanStr);
879 };
880
881 Util.appendToArray = function Util_appendToArray(arr1, arr2) {
882 Array.prototype.push.apply(arr1, arr2);
883 };
884
885 Util.prependToArray = function Util_prependToArray(arr1, arr2) {
886 Array.prototype.unshift.apply(arr1, arr2);
887 };
888
889 Util.extendObj = function extendObj(obj1, obj2) {
890 for (var key in obj2) {
891 obj1[key] = obj2[key];
892 }
893 };
894
895 Util.getInheritableProperty = function Util_getInheritableProperty(dict,
896 name) {
897 while (dict && !dict.has(name)) {
898 dict = dict.get('Parent');
899 }
900 if (!dict) {
901 return null;
902 }
903 return dict.get(name);
904 };
905
906 Util.inherit = function Util_inherit(sub, base, prototype) {
907 sub.prototype = Object.create(base.prototype);
908 sub.prototype.constructor = sub;
909 for (var prop in prototype) {
910 sub.prototype[prop] = prototype[prop];
911 }
912 };
913
914 Util.loadScript = function Util_loadScript(src, callback) {
915 var script = document.createElement('script');
916 var loaded = false;
917 script.setAttribute('src', src);
918 if (callback) {
919 script.onload = function() {
920 if (!loaded) {
921 callback();
922 }
923 loaded = true;
924 };
925 }
926 document.getElementsByTagName('head')[0].appendChild(script);
927 };
928
929 return Util;
930})();
931
932/**
933 * PDF page viewport created based on scale, rotation and offset.
934 * @class
935 * @alias PageViewport
936 */
937var PageViewport = (function PageViewportClosure() {
938 /**
939 * @constructor
940 * @private
941 * @param viewBox {Array} xMin, yMin, xMax and yMax coordinates.
942 * @param scale {number} scale of the viewport.
943 * @param rotation {number} rotations of the viewport in degrees.
944 * @param offsetX {number} offset X
945 * @param offsetY {number} offset Y
946 * @param dontFlip {boolean} if true, axis Y will not be flipped.
947 */
948 function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
949 this.viewBox = viewBox;
950 this.scale = scale;
951 this.rotation = rotation;
952 this.offsetX = offsetX;
953 this.offsetY = offsetY;
954
955 // creating transform to convert pdf coordinate system to the normal
956 // canvas like coordinates taking in account scale and rotation
957 var centerX = (viewBox[2] + viewBox[0]) / 2;
958 var centerY = (viewBox[3] + viewBox[1]) / 2;
959 var rotateA, rotateB, rotateC, rotateD;
960 rotation = rotation % 360;
961 rotation = rotation < 0 ? rotation + 360 : rotation;
962 switch (rotation) {
963 case 180:
964 rotateA = -1; rotateB = 0; rotateC = 0; rotateD = 1;
965 break;
966 case 90:
967 rotateA = 0; rotateB = 1; rotateC = 1; rotateD = 0;
968 break;
969 case 270:
970 rotateA = 0; rotateB = -1; rotateC = -1; rotateD = 0;
971 break;
972 //case 0:
973 default:
974 rotateA = 1; rotateB = 0; rotateC = 0; rotateD = -1;
975 break;
976 }
977
978 if (dontFlip) {
979 rotateC = -rotateC; rotateD = -rotateD;
980 }
981
982 var offsetCanvasX, offsetCanvasY;
983 var width, height;
984 if (rotateA === 0) {
985 offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
986 offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
987 width = Math.abs(viewBox[3] - viewBox[1]) * scale;
988 height = Math.abs(viewBox[2] - viewBox[0]) * scale;
989 } else {
990 offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
991 offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
992 width = Math.abs(viewBox[2] - viewBox[0]) * scale;
993 height = Math.abs(viewBox[3] - viewBox[1]) * scale;
994 }
995 // creating transform for the following operations:
996 // translate(-centerX, -centerY), rotate and flip vertically,
997 // scale, and translate(offsetCanvasX, offsetCanvasY)
998 this.transform = [
999 rotateA * scale,
1000 rotateB * scale,
1001 rotateC * scale,
1002 rotateD * scale,
1003 offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
1004 offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
1005 ];
1006
1007 this.width = width;
1008 this.height = height;
1009 this.fontScale = scale;
1010 }
1011 PageViewport.prototype = /** @lends PageViewport.prototype */ {
1012 /**
1013 * Clones viewport with additional properties.
1014 * @param args {Object} (optional) If specified, may contain the 'scale' or
1015 * 'rotation' properties to override the corresponding properties in
1016 * the cloned viewport.
1017 * @returns {PageViewport} Cloned viewport.
1018 */
1019 clone: function PageViewPort_clone(args) {
1020 args = args || {};
1021 var scale = 'scale' in args ? args.scale : this.scale;
1022 var rotation = 'rotation' in args ? args.rotation : this.rotation;
1023 return new PageViewport(this.viewBox.slice(), scale, rotation,
1024 this.offsetX, this.offsetY, args.dontFlip);
1025 },
1026 /**
1027 * Converts PDF point to the viewport coordinates. For examples, useful for
1028 * converting PDF location into canvas pixel coordinates.
1029 * @param x {number} X coordinate.
1030 * @param y {number} Y coordinate.
1031 * @returns {Object} Object that contains 'x' and 'y' properties of the
1032 * point in the viewport coordinate space.
1033 * @see {@link convertToPdfPoint}
1034 * @see {@link convertToViewportRectangle}
1035 */
1036 convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
1037 return Util.applyTransform([x, y], this.transform);
1038 },
1039 /**
1040 * Converts PDF rectangle to the viewport coordinates.
1041 * @param rect {Array} xMin, yMin, xMax and yMax coordinates.
1042 * @returns {Array} Contains corresponding coordinates of the rectangle
1043 * in the viewport coordinate space.
1044 * @see {@link convertToViewportPoint}
1045 */
1046 convertToViewportRectangle:
1047 function PageViewport_convertToViewportRectangle(rect) {
1048 var tl = Util.applyTransform([rect[0], rect[1]], this.transform);
1049 var br = Util.applyTransform([rect[2], rect[3]], this.transform);
1050 return [tl[0], tl[1], br[0], br[1]];
1051 },
1052 /**
1053 * Converts viewport coordinates to the PDF location. For examples, useful
1054 * for converting canvas pixel location into PDF one.
1055 * @param x {number} X coordinate.
1056 * @param y {number} Y coordinate.
1057 * @returns {Object} Object that contains 'x' and 'y' properties of the
1058 * point in the PDF coordinate space.
1059 * @see {@link convertToViewportPoint}
1060 */
1061 convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
1062 return Util.applyInverseTransform([x, y], this.transform);
1063 }
1064 };
1065 return PageViewport;
1066})();
1067
1068var PDFStringTranslateTable = [
1069 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1070 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0,
1071 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,
1072 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,
1073 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,
1074 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014,
1075 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C,
1076 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160,
1077 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC
1078];
1079
1080function stringToPDFString(str) {
1081 var i, n = str.length, strBuf = [];
1082 if (str[0] === '\xFE' && str[1] === '\xFF') {
1083 // UTF16BE BOM
1084 for (i = 2; i < n; i += 2) {
1085 strBuf.push(String.fromCharCode(
1086 (str.charCodeAt(i) << 8) | str.charCodeAt(i + 1)));
1087 }
1088 } else {
1089 for (i = 0; i < n; ++i) {
1090 var code = PDFStringTranslateTable[str.charCodeAt(i)];
1091 strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
1092 }
1093 }
1094 return strBuf.join('');
1095}
1096
1097function stringToUTF8String(str) {
1098 return decodeURIComponent(escape(str));
1099}
1100
1101function utf8StringToString(str) {
1102 return unescape(encodeURIComponent(str));
1103}
1104
1105function isEmptyObj(obj) {
1106 for (var key in obj) {
1107 return false;
1108 }
1109 return true;
1110}
1111
1112function isBool(v) {
1113 return typeof v === 'boolean';
1114}
1115
1116function isInt(v) {
1117 return typeof v === 'number' && ((v | 0) === v);
1118}
1119
1120function isNum(v) {
1121 return typeof v === 'number';
1122}
1123
1124function isString(v) {
1125 return typeof v === 'string';
1126}
1127
1128function isArray(v) {
1129 return v instanceof Array;
1130}
1131
1132function isArrayBuffer(v) {
1133 return typeof v === 'object' && v !== null && v.byteLength !== undefined;
1134}
1135
1136// Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
1137function isSpace(ch) {
1138 return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A);
1139}
1140
1141/**
1142 * Promise Capability object.
1143 *
1144 * @typedef {Object} PromiseCapability
1145 * @property {Promise} promise - A promise object.
1146 * @property {function} resolve - Fulfills the promise.
1147 * @property {function} reject - Rejects the promise.
1148 */
1149
1150/**
1151 * Creates a promise capability object.
1152 * @alias createPromiseCapability
1153 *
1154 * @return {PromiseCapability} A capability object contains:
1155 * - a Promise, resolve and reject methods.
1156 */
1157function createPromiseCapability() {
1158 var capability = {};
1159 capability.promise = new Promise(function (resolve, reject) {
1160 capability.resolve = resolve;
1161 capability.reject = reject;
1162 });
1163 return capability;
1164}
1165
1166/**
1167 * Polyfill for Promises:
1168 * The following promise implementation tries to generally implement the
1169 * Promise/A+ spec. Some notable differences from other promise libraries are:
1170 * - There currently isn't a separate deferred and promise object.
1171 * - Unhandled rejections eventually show an error if they aren't handled.
1172 *
1173 * Based off of the work in:
1174 * https://bugzilla.mozilla.org/show_bug.cgi?id=810490
1175 */
1176(function PromiseClosure() {
1177 if (globalScope.Promise) {
1178 // Promises existing in the DOM/Worker, checking presence of all/resolve
1179 if (typeof globalScope.Promise.all !== 'function') {
1180 globalScope.Promise.all = function (iterable) {
1181 var count = 0, results = [], resolve, reject;
1182 var promise = new globalScope.Promise(function (resolve_, reject_) {
1183 resolve = resolve_;
1184 reject = reject_;
1185 });
1186 iterable.forEach(function (p, i) {
1187 count++;
1188 p.then(function (result) {
1189 results[i] = result;
1190 count--;
1191 if (count === 0) {
1192 resolve(results);
1193 }
1194 }, reject);
1195 });
1196 if (count === 0) {
1197 resolve(results);
1198 }
1199 return promise;
1200 };
1201 }
1202 if (typeof globalScope.Promise.resolve !== 'function') {
1203 globalScope.Promise.resolve = function (value) {
1204 return new globalScope.Promise(function (resolve) { resolve(value); });
1205 };
1206 }
1207 if (typeof globalScope.Promise.reject !== 'function') {
1208 globalScope.Promise.reject = function (reason) {
1209 return new globalScope.Promise(function (resolve, reject) {
1210 reject(reason);
1211 });
1212 };
1213 }
1214 if (typeof globalScope.Promise.prototype.catch !== 'function') {
1215 globalScope.Promise.prototype.catch = function (onReject) {
1216 return globalScope.Promise.prototype.then(undefined, onReject);
1217 };
1218 }
1219 return;
1220 }
1221 var STATUS_PENDING = 0;
1222 var STATUS_RESOLVED = 1;
1223 var STATUS_REJECTED = 2;
1224
1225 // In an attempt to avoid silent exceptions, unhandled rejections are
1226 // tracked and if they aren't handled in a certain amount of time an
1227 // error is logged.
1228 var REJECTION_TIMEOUT = 500;
1229
1230 var HandlerManager = {
1231 handlers: [],
1232 running: false,
1233 unhandledRejections: [],
1234 pendingRejectionCheck: false,
1235
1236 scheduleHandlers: function scheduleHandlers(promise) {
1237 if (promise._status === STATUS_PENDING) {
1238 return;
1239 }
1240
1241 this.handlers = this.handlers.concat(promise._handlers);
1242 promise._handlers = [];
1243
1244 if (this.running) {
1245 return;
1246 }
1247 this.running = true;
1248
1249 setTimeout(this.runHandlers.bind(this), 0);
1250 },
1251
1252 runHandlers: function runHandlers() {
1253 var RUN_TIMEOUT = 1; // ms
1254 var timeoutAt = Date.now() + RUN_TIMEOUT;
1255 while (this.handlers.length > 0) {
1256 var handler = this.handlers.shift();
1257
1258 var nextStatus = handler.thisPromise._status;
1259 var nextValue = handler.thisPromise._value;
1260
1261 try {
1262 if (nextStatus === STATUS_RESOLVED) {
1263 if (typeof handler.onResolve === 'function') {
1264 nextValue = handler.onResolve(nextValue);
1265 }
1266 } else if (typeof handler.onReject === 'function') {
1267 nextValue = handler.onReject(nextValue);
1268 nextStatus = STATUS_RESOLVED;
1269
1270 if (handler.thisPromise._unhandledRejection) {
1271 this.removeUnhandeledRejection(handler.thisPromise);
1272 }
1273 }
1274 } catch (ex) {
1275 nextStatus = STATUS_REJECTED;
1276 nextValue = ex;
1277 }
1278
1279 handler.nextPromise._updateStatus(nextStatus, nextValue);
1280 if (Date.now() >= timeoutAt) {
1281 break;
1282 }
1283 }
1284
1285 if (this.handlers.length > 0) {
1286 setTimeout(this.runHandlers.bind(this), 0);
1287 return;
1288 }
1289
1290 this.running = false;
1291 },
1292
1293 addUnhandledRejection: function addUnhandledRejection(promise) {
1294 this.unhandledRejections.push({
1295 promise: promise,
1296 time: Date.now()
1297 });
1298 this.scheduleRejectionCheck();
1299 },
1300
1301 removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
1302 promise._unhandledRejection = false;
1303 for (var i = 0; i < this.unhandledRejections.length; i++) {
1304 if (this.unhandledRejections[i].promise === promise) {
1305 this.unhandledRejections.splice(i);
1306 i--;
1307 }
1308 }
1309 },
1310
1311 scheduleRejectionCheck: function scheduleRejectionCheck() {
1312 if (this.pendingRejectionCheck) {
1313 return;
1314 }
1315 this.pendingRejectionCheck = true;
1316 setTimeout(function rejectionCheck() {
1317 this.pendingRejectionCheck = false;
1318 var now = Date.now();
1319 for (var i = 0; i < this.unhandledRejections.length; i++) {
1320 if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
1321 var unhandled = this.unhandledRejections[i].promise._value;
1322 var msg = 'Unhandled rejection: ' + unhandled;
1323 if (unhandled.stack) {
1324 msg += '\n' + unhandled.stack;
1325 }
1326 warn(msg);
1327 this.unhandledRejections.splice(i);
1328 i--;
1329 }
1330 }
1331 if (this.unhandledRejections.length) {
1332 this.scheduleRejectionCheck();
1333 }
1334 }.bind(this), REJECTION_TIMEOUT);
1335 }
1336 };
1337
1338 function Promise(resolver) {
1339 this._status = STATUS_PENDING;
1340 this._handlers = [];
1341 try {
1342 resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
1343 } catch (e) {
1344 this._reject(e);
1345 }
1346 }
1347 /**
1348 * Builds a promise that is resolved when all the passed in promises are
1349 * resolved.
1350 * @param {array} promises array of data and/or promises to wait for.
1351 * @return {Promise} New dependent promise.
1352 */
1353 Promise.all = function Promise_all(promises) {
1354 var resolveAll, rejectAll;
1355 var deferred = new Promise(function (resolve, reject) {
1356 resolveAll = resolve;
1357 rejectAll = reject;
1358 });
1359 var unresolved = promises.length;
1360 var results = [];
1361 if (unresolved === 0) {
1362 resolveAll(results);
1363 return deferred;
1364 }
1365 function reject(reason) {
1366 if (deferred._status === STATUS_REJECTED) {
1367 return;
1368 }
1369 results = [];
1370 rejectAll(reason);
1371 }
1372 for (var i = 0, ii = promises.length; i < ii; ++i) {
1373 var promise = promises[i];
1374 var resolve = (function(i) {
1375 return function(value) {
1376 if (deferred._status === STATUS_REJECTED) {
1377 return;
1378 }
1379 results[i] = value;
1380 unresolved--;
1381 if (unresolved === 0) {
1382 resolveAll(results);
1383 }
1384 };
1385 })(i);
1386 if (Promise.isPromise(promise)) {
1387 promise.then(resolve, reject);
1388 } else {
1389 resolve(promise);
1390 }
1391 }
1392 return deferred;
1393 };
1394
1395 /**
1396 * Checks if the value is likely a promise (has a 'then' function).
1397 * @return {boolean} true if value is thenable
1398 */
1399 Promise.isPromise = function Promise_isPromise(value) {
1400 return value && typeof value.then === 'function';
1401 };
1402
1403 /**
1404 * Creates resolved promise
1405 * @param value resolve value
1406 * @returns {Promise}
1407 */
1408 Promise.resolve = function Promise_resolve(value) {
1409 return new Promise(function (resolve) { resolve(value); });
1410 };
1411
1412 /**
1413 * Creates rejected promise
1414 * @param reason rejection value
1415 * @returns {Promise}
1416 */
1417 Promise.reject = function Promise_reject(reason) {
1418 return new Promise(function (resolve, reject) { reject(reason); });
1419 };
1420
1421 Promise.prototype = {
1422 _status: null,
1423 _value: null,
1424 _handlers: null,
1425 _unhandledRejection: null,
1426
1427 _updateStatus: function Promise__updateStatus(status, value) {
1428 if (this._status === STATUS_RESOLVED ||
1429 this._status === STATUS_REJECTED) {
1430 return;
1431 }
1432
1433 if (status === STATUS_RESOLVED &&
1434 Promise.isPromise(value)) {
1435 value.then(this._updateStatus.bind(this, STATUS_RESOLVED),
1436 this._updateStatus.bind(this, STATUS_REJECTED));
1437 return;
1438 }
1439
1440 this._status = status;
1441 this._value = value;
1442
1443 if (status === STATUS_REJECTED && this._handlers.length === 0) {
1444 this._unhandledRejection = true;
1445 HandlerManager.addUnhandledRejection(this);
1446 }
1447
1448 HandlerManager.scheduleHandlers(this);
1449 },
1450
1451 _resolve: function Promise_resolve(value) {
1452 this._updateStatus(STATUS_RESOLVED, value);
1453 },
1454
1455 _reject: function Promise_reject(reason) {
1456 this._updateStatus(STATUS_REJECTED, reason);
1457 },
1458
1459 then: function Promise_then(onResolve, onReject) {
1460 var nextPromise = new Promise(function (resolve, reject) {
1461 this.resolve = resolve;
1462 this.reject = reject;
1463 });
1464 this._handlers.push({
1465 thisPromise: this,
1466 onResolve: onResolve,
1467 onReject: onReject,
1468 nextPromise: nextPromise
1469 });
1470 HandlerManager.scheduleHandlers(this);
1471 return nextPromise;
1472 },
1473
1474 catch: function Promise_catch(onReject) {
1475 return this.then(undefined, onReject);
1476 }
1477 };
1478
1479 globalScope.Promise = Promise;
1480})();
1481
1482(function WeakMapClosure() {
1483 if (globalScope.WeakMap) {
1484 return;
1485 }
1486
1487 var id = 0;
1488 function WeakMap() {
1489 this.id = '$weakmap' + (id++);
1490 }
1491 WeakMap.prototype = {
1492 has: function(obj) {
1493 return !!Object.getOwnPropertyDescriptor(obj, this.id);
1494 },
1495 get: function(obj, defaultValue) {
1496 return this.has(obj) ? obj[this.id] : defaultValue;
1497 },
1498 set: function(obj, value) {
1499 Object.defineProperty(obj, this.id, {
1500 value: value,
1501 enumerable: false,
1502 configurable: true
1503 });
1504 },
1505 delete: function(obj) {
1506 delete obj[this.id];
1507 }
1508 };
1509
1510 globalScope.WeakMap = WeakMap;
1511})();
1512
1513var StatTimer = (function StatTimerClosure() {
1514 function rpad(str, pad, length) {
1515 while (str.length < length) {
1516 str += pad;
1517 }
1518 return str;
1519 }
1520 function StatTimer() {
1521 this.started = Object.create(null);
1522 this.times = [];
1523 this.enabled = true;
1524 }
1525 StatTimer.prototype = {
1526 time: function StatTimer_time(name) {
1527 if (!this.enabled) {
1528 return;
1529 }
1530 if (name in this.started) {
1531 warn('Timer is already running for ' + name);
1532 }
1533 this.started[name] = Date.now();
1534 },
1535 timeEnd: function StatTimer_timeEnd(name) {
1536 if (!this.enabled) {
1537 return;
1538 }
1539 if (!(name in this.started)) {
1540 warn('Timer has not been started for ' + name);
1541 }
1542 this.times.push({
1543 'name': name,
1544 'start': this.started[name],
1545 'end': Date.now()
1546 });
1547 // Remove timer from started so it can be called again.
1548 delete this.started[name];
1549 },
1550 toString: function StatTimer_toString() {
1551 var i, ii;
1552 var times = this.times;
1553 var out = '';
1554 // Find the longest name for padding purposes.
1555 var longest = 0;
1556 for (i = 0, ii = times.length; i < ii; ++i) {
1557 var name = times[i]['name'];
1558 if (name.length > longest) {
1559 longest = name.length;
1560 }
1561 }
1562 for (i = 0, ii = times.length; i < ii; ++i) {
1563 var span = times[i];
1564 var duration = span.end - span.start;
1565 out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
1566 }
1567 return out;
1568 }
1569 };
1570 return StatTimer;
1571})();
1572
1573var createBlob = function createBlob(data, contentType) {
1574 if (typeof Blob !== 'undefined') {
1575 return new Blob([data], { type: contentType });
1576 }
1577 warn('The "Blob" constructor is not supported.');
1578};
1579
1580var createObjectURL = (function createObjectURLClosure() {
1581 // Blob/createObjectURL is not available, falling back to data schema.
1582 var digits =
1583 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
1584
1585 return function createObjectURL(data, contentType, forceDataSchema) {
1586 if (!forceDataSchema &&
1587 typeof URL !== 'undefined' && URL.createObjectURL) {
1588 var blob = createBlob(data, contentType);
1589 return URL.createObjectURL(blob);
1590 }
1591
1592 var buffer = 'data:' + contentType + ';base64,';
1593 for (var i = 0, ii = data.length; i < ii; i += 3) {
1594 var b1 = data[i] & 0xFF;
1595 var b2 = data[i + 1] & 0xFF;
1596 var b3 = data[i + 2] & 0xFF;
1597 var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4);
1598 var d3 = i + 1 < ii ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64;
1599 var d4 = i + 2 < ii ? (b3 & 0x3F) : 64;
1600 buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
1601 }
1602 return buffer;
1603 };
1604})();
1605
1606function MessageHandler(sourceName, targetName, comObj) {
1607 this.sourceName = sourceName;
1608 this.targetName = targetName;
1609 this.comObj = comObj;
1610 this.callbackIndex = 1;
1611 this.postMessageTransfers = true;
1612 var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
1613 var ah = this.actionHandler = Object.create(null);
1614
1615 this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
1616 var data = event.data;
1617 if (data.targetName !== this.sourceName) {
1618 return;
1619 }
1620 if (data.isReply) {
1621 var callbackId = data.callbackId;
1622 if (data.callbackId in callbacksCapabilities) {
1623 var callback = callbacksCapabilities[callbackId];
1624 delete callbacksCapabilities[callbackId];
1625 if ('error' in data) {
1626 callback.reject(data.error);
1627 } else {
1628 callback.resolve(data.data);
1629 }
1630 } else {
1631 error('Cannot resolve callback ' + callbackId);
1632 }
1633 } else if (data.action in ah) {
1634 var action = ah[data.action];
1635 if (data.callbackId) {
1636 var sourceName = this.sourceName;
1637 var targetName = data.sourceName;
1638 Promise.resolve().then(function () {
1639 return action[0].call(action[1], data.data);
1640 }).then(function (result) {
1641 comObj.postMessage({
1642 sourceName: sourceName,
1643 targetName: targetName,
1644 isReply: true,
1645 callbackId: data.callbackId,
1646 data: result
1647 });
1648 }, function (reason) {
1649 if (reason instanceof Error) {
1650 // Serialize error to avoid "DataCloneError"
1651 reason = reason + '';
1652 }
1653 comObj.postMessage({
1654 sourceName: sourceName,
1655 targetName: targetName,
1656 isReply: true,
1657 callbackId: data.callbackId,
1658 error: reason
1659 });
1660 });
1661 } else {
1662 action[0].call(action[1], data.data);
1663 }
1664 } else {
1665 error('Unknown action from worker: ' + data.action);
1666 }
1667 }.bind(this);
1668 comObj.addEventListener('message', this._onComObjOnMessage);
1669}
1670
1671MessageHandler.prototype = {
1672 on: function messageHandlerOn(actionName, handler, scope) {
1673 var ah = this.actionHandler;
1674 if (ah[actionName]) {
1675 error('There is already an actionName called "' + actionName + '"');
1676 }
1677 ah[actionName] = [handler, scope];
1678 },
1679 /**
1680 * Sends a message to the comObj to invoke the action with the supplied data.
1681 * @param {String} actionName Action to call.
1682 * @param {JSON} data JSON data to send.
1683 * @param {Array} [transfers] Optional list of transfers/ArrayBuffers
1684 */
1685 send: function messageHandlerSend(actionName, data, transfers) {
1686 var message = {
1687 sourceName: this.sourceName,
1688 targetName: this.targetName,
1689 action: actionName,
1690 data: data
1691 };
1692 this.postMessage(message, transfers);
1693 },
1694 /**
1695 * Sends a message to the comObj to invoke the action with the supplied data.
1696 * Expects that other side will callback with the response.
1697 * @param {String} actionName Action to call.
1698 * @param {JSON} data JSON data to send.
1699 * @param {Array} [transfers] Optional list of transfers/ArrayBuffers.
1700 * @returns {Promise} Promise to be resolved with response data.
1701 */
1702 sendWithPromise:
1703 function messageHandlerSendWithPromise(actionName, data, transfers) {
1704 var callbackId = this.callbackIndex++;
1705 var message = {
1706 sourceName: this.sourceName,
1707 targetName: this.targetName,
1708 action: actionName,
1709 data: data,
1710 callbackId: callbackId
1711 };
1712 var capability = createPromiseCapability();
1713 this.callbacksCapabilities[callbackId] = capability;
1714 try {
1715 this.postMessage(message, transfers);
1716 } catch (e) {
1717 capability.reject(e);
1718 }
1719 return capability.promise;
1720 },
1721 /**
1722 * Sends raw message to the comObj.
1723 * @private
1724 * @param message {Object} Raw message.
1725 * @param transfers List of transfers/ArrayBuffers, or undefined.
1726 */
1727 postMessage: function (message, transfers) {
1728 if (transfers && this.postMessageTransfers) {
1729 this.comObj.postMessage(message, transfers);
1730 } else {
1731 this.comObj.postMessage(message);
1732 }
1733 },
1734
1735 destroy: function () {
1736 this.comObj.removeEventListener('message', this._onComObjOnMessage);
1737 }
1738};
1739
1740function loadJpegStream(id, imageUrl, objs) {
1741 var img = new Image();
1742 img.onload = (function loadJpegStream_onloadClosure() {
1743 objs.resolve(id, img);
1744 });
1745 img.onerror = (function loadJpegStream_onerrorClosure() {
1746 objs.resolve(id, null);
1747 warn('Error during JPEG image loading');
1748 });
1749 img.src = imageUrl;
1750}
1751
1752 // Polyfill from https://github.com/Polymer/URL
1753/* Any copyright is dedicated to the Public Domain.
1754 * http://creativecommons.org/publicdomain/zero/1.0/ */
1755(function checkURLConstructor(scope) {
1756 // feature detect for URL constructor
1757 var hasWorkingUrl = false;
1758 try {
1759 if (typeof URL === 'function' &&
1760 typeof URL.prototype === 'object' &&
1761 ('origin' in URL.prototype)) {
1762 var u = new URL('b', 'http://a');
1763 u.pathname = 'c%20d';
1764 hasWorkingUrl = u.href === 'http://a/c%20d';
1765 }
1766 } catch(e) { }
1767
1768 if (hasWorkingUrl) {
1769 return;
1770 }
1771
1772 var relative = Object.create(null);
1773 relative['ftp'] = 21;
1774 relative['file'] = 0;
1775 relative['gopher'] = 70;
1776 relative['http'] = 80;
1777 relative['https'] = 443;
1778 relative['ws'] = 80;
1779 relative['wss'] = 443;
1780
1781 var relativePathDotMapping = Object.create(null);
1782 relativePathDotMapping['%2e'] = '.';
1783 relativePathDotMapping['.%2e'] = '..';
1784 relativePathDotMapping['%2e.'] = '..';
1785 relativePathDotMapping['%2e%2e'] = '..';
1786
1787 function isRelativeScheme(scheme) {
1788 return relative[scheme] !== undefined;
1789 }
1790
1791 function invalid() {
1792 clear.call(this);
1793 this._isInvalid = true;
1794 }
1795
1796 function IDNAToASCII(h) {
1797 if ('' === h) {
1798 invalid.call(this);
1799 }
1800 // XXX
1801 return h.toLowerCase();
1802 }
1803
1804 function percentEscape(c) {
1805 var unicode = c.charCodeAt(0);
1806 if (unicode > 0x20 &&
1807 unicode < 0x7F &&
1808 // " # < > ? `
1809 [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1
1810 ) {
1811 return c;
1812 }
1813 return encodeURIComponent(c);
1814 }
1815
1816 function percentEscapeQuery(c) {
1817 // XXX This actually needs to encode c using encoding and then
1818 // convert the bytes one-by-one.
1819
1820 var unicode = c.charCodeAt(0);
1821 if (unicode > 0x20 &&
1822 unicode < 0x7F &&
1823 // " # < > ` (do not escape '?')
1824 [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1
1825 ) {
1826 return c;
1827 }
1828 return encodeURIComponent(c);
1829 }
1830
1831 var EOF, ALPHA = /[a-zA-Z]/,
1832 ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
1833
1834 function parse(input, stateOverride, base) {
1835 function err(message) {
1836 errors.push(message);
1837 }
1838
1839 var state = stateOverride || 'scheme start',
1840 cursor = 0,
1841 buffer = '',
1842 seenAt = false,
1843 seenBracket = false,
1844 errors = [];
1845
1846 loop: while ((input[cursor - 1] !== EOF || cursor === 0) &&
1847 !this._isInvalid) {
1848 var c = input[cursor];
1849 switch (state) {
1850 case 'scheme start':
1851 if (c && ALPHA.test(c)) {
1852 buffer += c.toLowerCase(); // ASCII-safe
1853 state = 'scheme';
1854 } else if (!stateOverride) {
1855 buffer = '';
1856 state = 'no scheme';
1857 continue;
1858 } else {
1859 err('Invalid scheme.');
1860 break loop;
1861 }
1862 break;
1863
1864 case 'scheme':
1865 if (c && ALPHANUMERIC.test(c)) {
1866 buffer += c.toLowerCase(); // ASCII-safe
1867 } else if (':' === c) {
1868 this._scheme = buffer;
1869 buffer = '';
1870 if (stateOverride) {
1871 break loop;
1872 }
1873 if (isRelativeScheme(this._scheme)) {
1874 this._isRelative = true;
1875 }
1876 if ('file' === this._scheme) {
1877 state = 'relative';
1878 } else if (this._isRelative && base &&
1879 base._scheme === this._scheme) {
1880 state = 'relative or authority';
1881 } else if (this._isRelative) {
1882 state = 'authority first slash';
1883 } else {
1884 state = 'scheme data';
1885 }
1886 } else if (!stateOverride) {
1887 buffer = '';
1888 cursor = 0;
1889 state = 'no scheme';
1890 continue;
1891 } else if (EOF === c) {
1892 break loop;
1893 } else {
1894 err('Code point not allowed in scheme: ' + c);
1895 break loop;
1896 }
1897 break;
1898
1899 case 'scheme data':
1900 if ('?' === c) {
1901 this._query = '?';
1902 state = 'query';
1903 } else if ('#' === c) {
1904 this._fragment = '#';
1905 state = 'fragment';
1906 } else {
1907 // XXX error handling
1908 if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
1909 this._schemeData += percentEscape(c);
1910 }
1911 }
1912 break;
1913
1914 case 'no scheme':
1915 if (!base || !(isRelativeScheme(base._scheme))) {
1916 err('Missing scheme.');
1917 invalid.call(this);
1918 } else {
1919 state = 'relative';
1920 continue;
1921 }
1922 break;
1923
1924 case 'relative or authority':
1925 if ('/' === c && '/' === input[cursor+1]) {
1926 state = 'authority ignore slashes';
1927 } else {
1928 err('Expected /, got: ' + c);
1929 state = 'relative';
1930 continue;
1931 }
1932 break;
1933
1934 case 'relative':
1935 this._isRelative = true;
1936 if ('file' !== this._scheme) {
1937 this._scheme = base._scheme;
1938 }
1939 if (EOF === c) {
1940 this._host = base._host;
1941 this._port = base._port;
1942 this._path = base._path.slice();
1943 this._query = base._query;
1944 this._username = base._username;
1945 this._password = base._password;
1946 break loop;
1947 } else if ('/' === c || '\\' === c) {
1948 if ('\\' === c) {
1949 err('\\ is an invalid code point.');
1950 }
1951 state = 'relative slash';
1952 } else if ('?' === c) {
1953 this._host = base._host;
1954 this._port = base._port;
1955 this._path = base._path.slice();
1956 this._query = '?';
1957 this._username = base._username;
1958 this._password = base._password;
1959 state = 'query';
1960 } else if ('#' === c) {
1961 this._host = base._host;
1962 this._port = base._port;
1963 this._path = base._path.slice();
1964 this._query = base._query;
1965 this._fragment = '#';
1966 this._username = base._username;
1967 this._password = base._password;
1968 state = 'fragment';
1969 } else {
1970 var nextC = input[cursor+1];
1971 var nextNextC = input[cursor+2];
1972 if ('file' !== this._scheme || !ALPHA.test(c) ||
1973 (nextC !== ':' && nextC !== '|') ||
1974 (EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC &&
1975 '?' !== nextNextC && '#' !== nextNextC)) {
1976 this._host = base._host;
1977 this._port = base._port;
1978 this._username = base._username;
1979 this._password = base._password;
1980 this._path = base._path.slice();
1981 this._path.pop();
1982 }
1983 state = 'relative path';
1984 continue;
1985 }
1986 break;
1987
1988 case 'relative slash':
1989 if ('/' === c || '\\' === c) {
1990 if ('\\' === c) {
1991 err('\\ is an invalid code point.');
1992 }
1993 if ('file' === this._scheme) {
1994 state = 'file host';
1995 } else {
1996 state = 'authority ignore slashes';
1997 }
1998 } else {
1999 if ('file' !== this._scheme) {
2000 this._host = base._host;
2001 this._port = base._port;
2002 this._username = base._username;
2003 this._password = base._password;
2004 }
2005 state = 'relative path';
2006 continue;
2007 }
2008 break;
2009
2010 case 'authority first slash':
2011 if ('/' === c) {
2012 state = 'authority second slash';
2013 } else {
2014 err('Expected \'/\', got: ' + c);
2015 state = 'authority ignore slashes';
2016 continue;
2017 }
2018 break;
2019
2020 case 'authority second slash':
2021 state = 'authority ignore slashes';
2022 if ('/' !== c) {
2023 err('Expected \'/\', got: ' + c);
2024 continue;
2025 }
2026 break;
2027
2028 case 'authority ignore slashes':
2029 if ('/' !== c && '\\' !== c) {
2030 state = 'authority';
2031 continue;
2032 } else {
2033 err('Expected authority, got: ' + c);
2034 }
2035 break;
2036
2037 case 'authority':
2038 if ('@' === c) {
2039 if (seenAt) {
2040 err('@ already seen.');
2041 buffer += '%40';
2042 }
2043 seenAt = true;
2044 for (var i = 0; i < buffer.length; i++) {
2045 var cp = buffer[i];
2046 if ('\t' === cp || '\n' === cp || '\r' === cp) {
2047 err('Invalid whitespace in authority.');
2048 continue;
2049 }
2050 // XXX check URL code points
2051 if (':' === cp && null === this._password) {
2052 this._password = '';
2053 continue;
2054 }
2055 var tempC = percentEscape(cp);
2056 if (null !== this._password) {
2057 this._password += tempC;
2058 } else {
2059 this._username += tempC;
2060 }
2061 }
2062 buffer = '';
2063 } else if (EOF === c || '/' === c || '\\' === c ||
2064 '?' === c || '#' === c) {
2065 cursor -= buffer.length;
2066 buffer = '';
2067 state = 'host';
2068 continue;
2069 } else {
2070 buffer += c;
2071 }
2072 break;
2073
2074 case 'file host':
2075 if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
2076 if (buffer.length === 2 && ALPHA.test(buffer[0]) &&
2077 (buffer[1] === ':' || buffer[1] === '|')) {
2078 state = 'relative path';
2079 } else if (buffer.length === 0) {
2080 state = 'relative path start';
2081 } else {
2082 this._host = IDNAToASCII.call(this, buffer);
2083 buffer = '';
2084 state = 'relative path start';
2085 }
2086 continue;
2087 } else if ('\t' === c || '\n' === c || '\r' === c) {
2088 err('Invalid whitespace in file host.');
2089 } else {
2090 buffer += c;
2091 }
2092 break;
2093
2094 case 'host':
2095 case 'hostname':
2096 if (':' === c && !seenBracket) {
2097 // XXX host parsing
2098 this._host = IDNAToASCII.call(this, buffer);
2099 buffer = '';
2100 state = 'port';
2101 if ('hostname' === stateOverride) {
2102 break loop;
2103 }
2104 } else if (EOF === c || '/' === c ||
2105 '\\' === c || '?' === c || '#' === c) {
2106 this._host = IDNAToASCII.call(this, buffer);
2107 buffer = '';
2108 state = 'relative path start';
2109 if (stateOverride) {
2110 break loop;
2111 }
2112 continue;
2113 } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
2114 if ('[' === c) {
2115 seenBracket = true;
2116 } else if (']' === c) {
2117 seenBracket = false;
2118 }
2119 buffer += c;
2120 } else {
2121 err('Invalid code point in host/hostname: ' + c);
2122 }
2123 break;
2124
2125 case 'port':
2126 if (/[0-9]/.test(c)) {
2127 buffer += c;
2128 } else if (EOF === c || '/' === c || '\\' === c ||
2129 '?' === c || '#' === c || stateOverride) {
2130 if ('' !== buffer) {
2131 var temp = parseInt(buffer, 10);
2132 if (temp !== relative[this._scheme]) {
2133 this._port = temp + '';
2134 }
2135 buffer = '';
2136 }
2137 if (stateOverride) {
2138 break loop;
2139 }
2140 state = 'relative path start';
2141 continue;
2142 } else if ('\t' === c || '\n' === c || '\r' === c) {
2143 err('Invalid code point in port: ' + c);
2144 } else {
2145 invalid.call(this);
2146 }
2147 break;
2148
2149 case 'relative path start':
2150 if ('\\' === c) {
2151 err('\'\\\' not allowed in path.');
2152 }
2153 state = 'relative path';
2154 if ('/' !== c && '\\' !== c) {
2155 continue;
2156 }
2157 break;
2158
2159 case 'relative path':
2160 if (EOF === c || '/' === c || '\\' === c ||
2161 (!stateOverride && ('?' === c || '#' === c))) {
2162 if ('\\' === c) {
2163 err('\\ not allowed in relative path.');
2164 }
2165 var tmp;
2166 if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
2167 buffer = tmp;
2168 }
2169 if ('..' === buffer) {
2170 this._path.pop();
2171 if ('/' !== c && '\\' !== c) {
2172 this._path.push('');
2173 }
2174 } else if ('.' === buffer && '/' !== c && '\\' !== c) {
2175 this._path.push('');
2176 } else if ('.' !== buffer) {
2177 if ('file' === this._scheme && this._path.length === 0 &&
2178 buffer.length === 2 && ALPHA.test(buffer[0]) &&
2179 buffer[1] === '|') {
2180 buffer = buffer[0] + ':';
2181 }
2182 this._path.push(buffer);
2183 }
2184 buffer = '';
2185 if ('?' === c) {
2186 this._query = '?';
2187 state = 'query';
2188 } else if ('#' === c) {
2189 this._fragment = '#';
2190 state = 'fragment';
2191 }
2192 } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
2193 buffer += percentEscape(c);
2194 }
2195 break;
2196
2197 case 'query':
2198 if (!stateOverride && '#' === c) {
2199 this._fragment = '#';
2200 state = 'fragment';
2201 } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
2202 this._query += percentEscapeQuery(c);
2203 }
2204 break;
2205
2206 case 'fragment':
2207 if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
2208 this._fragment += c;
2209 }
2210 break;
2211 }
2212
2213 cursor++;
2214 }
2215 }
2216
2217 function clear() {
2218 this._scheme = '';
2219 this._schemeData = '';
2220 this._username = '';
2221 this._password = null;
2222 this._host = '';
2223 this._port = '';
2224 this._path = [];
2225 this._query = '';
2226 this._fragment = '';
2227 this._isInvalid = false;
2228 this._isRelative = false;
2229 }
2230
2231 // Does not process domain names or IP addresses.
2232 // Does not handle encoding for the query parameter.
2233 function JURL(url, base /* , encoding */) {
2234 if (base !== undefined && !(base instanceof JURL)) {
2235 base = new JURL(String(base));
2236 }
2237
2238 this._url = url;
2239 clear.call(this);
2240
2241 var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
2242 // encoding = encoding || 'utf-8'
2243
2244 parse.call(this, input, null, base);
2245 }
2246
2247 JURL.prototype = {
2248 toString: function() {
2249 return this.href;
2250 },
2251 get href() {
2252 if (this._isInvalid) {
2253 return this._url;
2254 }
2255 var authority = '';
2256 if ('' !== this._username || null !== this._password) {
2257 authority = this._username +
2258 (null !== this._password ? ':' + this._password : '') + '@';
2259 }
2260
2261 return this.protocol +
2262 (this._isRelative ? '//' + authority + this.host : '') +
2263 this.pathname + this._query + this._fragment;
2264 },
2265 set href(href) {
2266 clear.call(this);
2267 parse.call(this, href);
2268 },
2269
2270 get protocol() {
2271 return this._scheme + ':';
2272 },
2273 set protocol(protocol) {
2274 if (this._isInvalid) {
2275 return;
2276 }
2277 parse.call(this, protocol + ':', 'scheme start');
2278 },
2279
2280 get host() {
2281 return this._isInvalid ? '' : this._port ?
2282 this._host + ':' + this._port : this._host;
2283 },
2284 set host(host) {
2285 if (this._isInvalid || !this._isRelative) {
2286 return;
2287 }
2288 parse.call(this, host, 'host');
2289 },
2290
2291 get hostname() {
2292 return this._host;
2293 },
2294 set hostname(hostname) {
2295 if (this._isInvalid || !this._isRelative) {
2296 return;
2297 }
2298 parse.call(this, hostname, 'hostname');
2299 },
2300
2301 get port() {
2302 return this._port;
2303 },
2304 set port(port) {
2305 if (this._isInvalid || !this._isRelative) {
2306 return;
2307 }
2308 parse.call(this, port, 'port');
2309 },
2310
2311 get pathname() {
2312 return this._isInvalid ? '' : this._isRelative ?
2313 '/' + this._path.join('/') : this._schemeData;
2314 },
2315 set pathname(pathname) {
2316 if (this._isInvalid || !this._isRelative) {
2317 return;
2318 }
2319 this._path = [];
2320 parse.call(this, pathname, 'relative path start');
2321 },
2322
2323 get search() {
2324 return this._isInvalid || !this._query || '?' === this._query ?
2325 '' : this._query;
2326 },
2327 set search(search) {
2328 if (this._isInvalid || !this._isRelative) {
2329 return;
2330 }
2331 this._query = '?';
2332 if ('?' === search[0]) {
2333 search = search.slice(1);
2334 }
2335 parse.call(this, search, 'query');
2336 },
2337
2338 get hash() {
2339 return this._isInvalid || !this._fragment || '#' === this._fragment ?
2340 '' : this._fragment;
2341 },
2342 set hash(hash) {
2343 if (this._isInvalid) {
2344 return;
2345 }
2346 this._fragment = '#';
2347 if ('#' === hash[0]) {
2348 hash = hash.slice(1);
2349 }
2350 parse.call(this, hash, 'fragment');
2351 },
2352
2353 get origin() {
2354 var host;
2355 if (this._isInvalid || !this._scheme) {
2356 return '';
2357 }
2358 // javascript: Gecko returns String(""), WebKit/Blink String("null")
2359 // Gecko throws error for "data://"
2360 // data: Gecko returns "", Blink returns "data://", WebKit returns "null"
2361 // Gecko returns String("") for file: mailto:
2362 // WebKit/Blink returns String("SCHEME://") for file: mailto:
2363 switch (this._scheme) {
2364 case 'data':
2365 case 'file':
2366 case 'javascript':
2367 case 'mailto':
2368 return 'null';
2369 }
2370 host = this.host;
2371 if (!host) {
2372 return '';
2373 }
2374 return this._scheme + '://' + host;
2375 }
2376 };
2377
2378 // Copy over the static methods
2379 var OriginalURL = scope.URL;
2380 if (OriginalURL) {
2381 JURL.createObjectURL = function(blob) {
2382 // IE extension allows a second optional options argument.
2383 // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx
2384 return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
2385 };
2386 JURL.revokeObjectURL = function(url) {
2387 OriginalURL.revokeObjectURL(url);
2388 };
2389 }
2390
2391 scope.URL = JURL;
2392})(globalScope);
2393
2394exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
2395exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
2396exports.OPS = OPS;
2397exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
2398exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
2399exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
2400exports.AnnotationFieldFlag = AnnotationFieldFlag;
2401exports.AnnotationFlag = AnnotationFlag;
2402exports.AnnotationType = AnnotationType;
2403exports.FontType = FontType;
2404exports.ImageKind = ImageKind;
2405exports.InvalidPDFException = InvalidPDFException;
2406exports.MessageHandler = MessageHandler;
2407exports.MissingDataException = MissingDataException;
2408exports.MissingPDFException = MissingPDFException;
2409exports.NotImplementedException = NotImplementedException;
2410exports.PageViewport = PageViewport;
2411exports.PasswordException = PasswordException;
2412exports.PasswordResponses = PasswordResponses;
2413exports.StatTimer = StatTimer;
2414exports.StreamType = StreamType;
2415exports.TextRenderingMode = TextRenderingMode;
2416exports.UnexpectedResponseException = UnexpectedResponseException;
2417exports.UnknownErrorException = UnknownErrorException;
2418exports.Util = Util;
2419exports.XRefParseException = XRefParseException;
2420exports.arrayByteLength = arrayByteLength;
2421exports.arraysToBytes = arraysToBytes;
2422exports.assert = assert;
2423exports.bytesToString = bytesToString;
2424exports.createBlob = createBlob;
2425exports.createPromiseCapability = createPromiseCapability;
2426exports.createObjectURL = createObjectURL;
2427exports.deprecated = deprecated;
2428exports.error = error;
2429exports.getLookupTableFactory = getLookupTableFactory;
2430exports.getVerbosityLevel = getVerbosityLevel;
2431exports.globalScope = globalScope;
2432exports.info = info;
2433exports.isArray = isArray;
2434exports.isArrayBuffer = isArrayBuffer;
2435exports.isBool = isBool;
2436exports.isEmptyObj = isEmptyObj;
2437exports.isInt = isInt;
2438exports.isNum = isNum;
2439exports.isString = isString;
2440exports.isSpace = isSpace;
2441exports.isSameOrigin = isSameOrigin;
2442exports.isValidUrl = isValidUrl;
2443exports.isLittleEndian = isLittleEndian;
2444exports.isEvalSupported = isEvalSupported;
2445exports.loadJpegStream = loadJpegStream;
2446exports.log2 = log2;
2447exports.readInt8 = readInt8;
2448exports.readUint16 = readUint16;
2449exports.readUint32 = readUint32;
2450exports.removeNullCharacters = removeNullCharacters;
2451exports.setVerbosityLevel = setVerbosityLevel;
2452exports.shadow = shadow;
2453exports.string32 = string32;
2454exports.stringToBytes = stringToBytes;
2455exports.stringToPDFString = stringToPDFString;
2456exports.stringToUTF8String = stringToUTF8String;
2457exports.utf8StringToString = utf8StringToString;
2458exports.warn = warn;
2459}));
2460
2461
2462(function (root, factory) {
2463 {
2464 factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedUtil);
2465 }
2466}(this, function (exports, sharedUtil) {
2467
2468var removeNullCharacters = sharedUtil.removeNullCharacters;
2469var warn = sharedUtil.warn;
2470
2471/**
2472 * Optimised CSS custom property getter/setter.
2473 * @class
2474 */
2475var CustomStyle = (function CustomStyleClosure() {
2476
2477 // As noted on: http://www.zachstronaut.com/posts/2009/02/17/
2478 // animate-css-transforms-firefox-webkit.html
2479 // in some versions of IE9 it is critical that ms appear in this list
2480 // before Moz
2481 var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
2482 var _cache = Object.create(null);
2483
2484 function CustomStyle() {}
2485
2486 CustomStyle.getProp = function get(propName, element) {
2487 // check cache only when no element is given
2488 if (arguments.length === 1 && typeof _cache[propName] === 'string') {
2489 return _cache[propName];
2490 }
2491
2492 element = element || document.documentElement;
2493 var style = element.style, prefixed, uPropName;
2494
2495 // test standard property first
2496 if (typeof style[propName] === 'string') {
2497 return (_cache[propName] = propName);
2498 }
2499
2500 // capitalize
2501 uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
2502
2503 // test vendor specific properties
2504 for (var i = 0, l = prefixes.length; i < l; i++) {
2505 prefixed = prefixes[i] + uPropName;
2506 if (typeof style[prefixed] === 'string') {
2507 return (_cache[propName] = prefixed);
2508 }
2509 }
2510
2511 //if all fails then set to undefined
2512 return (_cache[propName] = 'undefined');
2513 };
2514
2515 CustomStyle.setProp = function set(propName, element, str) {
2516 var prop = this.getProp(propName);
2517 if (prop !== 'undefined') {
2518 element.style[prop] = str;
2519 }
2520 };
2521
2522 return CustomStyle;
2523})();
2524
2525function hasCanvasTypedArrays() {
2526 var canvas = document.createElement('canvas');
2527 canvas.width = canvas.height = 1;
2528 var ctx = canvas.getContext('2d');
2529 var imageData = ctx.createImageData(1, 1);
2530 return (typeof imageData.data.buffer !== 'undefined');
2531}
2532
2533var LinkTarget = {
2534 NONE: 0, // Default value.
2535 SELF: 1,
2536 BLANK: 2,
2537 PARENT: 3,
2538 TOP: 4,
2539};
2540
2541var LinkTargetStringMap = [
2542 '',
2543 '_self',
2544 '_blank',
2545 '_parent',
2546 '_top'
2547];
2548
2549/**
2550 * @typedef ExternalLinkParameters
2551 * @typedef {Object} ExternalLinkParameters
2552 * @property {string} url - An absolute URL.
2553 * @property {LinkTarget} target - The link target.
2554 * @property {string} rel - The link relationship.
2555 */
2556
2557/**
2558 * Adds various attributes (href, title, target, rel) to hyperlinks.
2559 * @param {HTMLLinkElement} link - The link element.
2560 * @param {ExternalLinkParameters} params
2561 */
2562function addLinkAttributes(link, params) {
2563 var url = params && params.url;
2564 link.href = link.title = (url ? removeNullCharacters(url) : '');
2565
2566 if (url) {
2567 var target = params.target;
2568 if (typeof target === 'undefined') {
2569 target = getDefaultSetting('externalLinkTarget');
2570 }
2571 link.target = LinkTargetStringMap[target];
2572
2573 var rel = params.rel;
2574 if (typeof rel === 'undefined') {
2575 rel = getDefaultSetting('externalLinkRel');
2576 }
2577 link.rel = rel;
2578 }
2579}
2580
2581// Gets the file name from a given URL.
2582function getFilenameFromUrl(url) {
2583 var anchor = url.indexOf('#');
2584 var query = url.indexOf('?');
2585 var end = Math.min(
2586 anchor > 0 ? anchor : url.length,
2587 query > 0 ? query : url.length);
2588 return url.substring(url.lastIndexOf('/', end) + 1, end);
2589}
2590
2591function getDefaultSetting(id) {
2592 // The list of the settings and their default is maintained for backward
2593 // compatibility and shall not be extended or modified. See also global.js.
2594 var globalSettings = sharedUtil.globalScope.PDFJS;
2595 switch (id) {
2596 case 'pdfBug':
2597 return globalSettings ? globalSettings.pdfBug : false;
2598 case 'disableAutoFetch':
2599 return globalSettings ? globalSettings.disableAutoFetch : false;
2600 case 'disableStream':
2601 return globalSettings ? globalSettings.disableStream : false;
2602 case 'disableRange':
2603 return globalSettings ? globalSettings.disableRange : false;
2604 case 'disableFontFace':
2605 return globalSettings ? globalSettings.disableFontFace : false;
2606 case 'disableCreateObjectURL':
2607 return globalSettings ? globalSettings.disableCreateObjectURL : false;
2608 case 'disableWebGL':
2609 return globalSettings ? globalSettings.disableWebGL : true;
2610 case 'cMapUrl':
2611 return globalSettings ? globalSettings.cMapUrl : null;
2612 case 'cMapPacked':
2613 return globalSettings ? globalSettings.cMapPacked : false;
2614 case 'postMessageTransfers':
2615 return globalSettings ? globalSettings.postMessageTransfers : true;
2616 case 'workerSrc':
2617 return globalSettings ? globalSettings.workerSrc : null;
2618 case 'disableWorker':
2619 return globalSettings ? globalSettings.disableWorker : false;
2620 case 'maxImageSize':
2621 return globalSettings ? globalSettings.maxImageSize : -1;
2622 case 'imageResourcesPath':
2623 return globalSettings ? globalSettings.imageResourcesPath : '';
2624 case 'isEvalSupported':
2625 return globalSettings ? globalSettings.isEvalSupported : true;
2626 case 'externalLinkTarget':
2627 if (!globalSettings) {
2628 return LinkTarget.NONE;
2629 }
2630 switch (globalSettings.externalLinkTarget) {
2631 case LinkTarget.NONE:
2632 case LinkTarget.SELF:
2633 case LinkTarget.BLANK:
2634 case LinkTarget.PARENT:
2635 case LinkTarget.TOP:
2636 return globalSettings.externalLinkTarget;
2637 }
2638 warn('PDFJS.externalLinkTarget is invalid: ' +
2639 globalSettings.externalLinkTarget);
2640 // Reset the external link target, to suppress further warnings.
2641 globalSettings.externalLinkTarget = LinkTarget.NONE;
2642 return LinkTarget.NONE;
2643 case 'externalLinkRel':
2644 return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
2645 case 'enableStats':
2646 return !!(globalSettings && globalSettings.enableStats);
2647 default:
2648 throw new Error('Unknown default setting: ' + id);
2649 }
2650}
2651
2652function isExternalLinkTargetSet() {
2653 var externalLinkTarget = getDefaultSetting('externalLinkTarget');
2654 switch (externalLinkTarget) {
2655 case LinkTarget.NONE:
2656 return false;
2657 case LinkTarget.SELF:
2658 case LinkTarget.BLANK:
2659 case LinkTarget.PARENT:
2660 case LinkTarget.TOP:
2661 return true;
2662 }
2663}
2664
2665exports.CustomStyle = CustomStyle;
2666exports.addLinkAttributes = addLinkAttributes;
2667exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
2668exports.getFilenameFromUrl = getFilenameFromUrl;
2669exports.LinkTarget = LinkTarget;
2670exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
2671exports.getDefaultSetting = getDefaultSetting;
2672}));
2673
2674
2675(function (root, factory) {
2676 {
2677 factory((root.pdfjsDisplayFontLoader = {}), root.pdfjsSharedUtil);
2678 }
2679}(this, function (exports, sharedUtil) {
2680
2681var assert = sharedUtil.assert;
2682var bytesToString = sharedUtil.bytesToString;
2683var string32 = sharedUtil.string32;
2684var shadow = sharedUtil.shadow;
2685var warn = sharedUtil.warn;
2686
2687function FontLoader(docId) {
2688 this.docId = docId;
2689 this.styleElement = null;
2690 this.nativeFontFaces = [];
2691 this.loadTestFontId = 0;
2692 this.loadingContext = {
2693 requests: [],
2694 nextRequestId: 0
2695 };
2696}
2697FontLoader.prototype = {
2698 insertRule: function fontLoaderInsertRule(rule) {
2699 var styleElement = this.styleElement;
2700 if (!styleElement) {
2701 styleElement = this.styleElement = document.createElement('style');
2702 styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
2703 document.documentElement.getElementsByTagName('head')[0].appendChild(
2704 styleElement);
2705 }
2706
2707 var styleSheet = styleElement.sheet;
2708 styleSheet.insertRule(rule, styleSheet.cssRules.length);
2709 },
2710
2711 clear: function fontLoaderClear() {
2712 var styleElement = this.styleElement;
2713 if (styleElement) {
2714 styleElement.parentNode.removeChild(styleElement);
2715 styleElement = this.styleElement = null;
2716 }
2717 this.nativeFontFaces.forEach(function(nativeFontFace) {
2718 document.fonts.delete(nativeFontFace);
2719 });
2720 this.nativeFontFaces.length = 0;
2721 },
2722 get loadTestFont() {
2723 // This is a CFF font with 1 glyph for '.' that fills its entire width and
2724 // height.
2725 return shadow(this, 'loadTestFont', atob(
2726 'T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' +
2727 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' +
2728 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' +
2729 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' +
2730 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' +
2731 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' +
2732 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' +
2733 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' +
2734 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' +
2735 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' +
2736 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' +
2737 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' +
2738 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' +
2739 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
2740 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
2741 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +
2742 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' +
2743 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' +
2744 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' +
2745 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' +
2746 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' +
2747 'ABAAAAAAAAAAAD6AAAAAAAAA=='
2748 ));
2749 },
2750
2751 addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) {
2752 this.nativeFontFaces.push(nativeFontFace);
2753 document.fonts.add(nativeFontFace);
2754 },
2755
2756 bind: function fontLoaderBind(fonts, callback) {
2757 var rules = [];
2758 var fontsToLoad = [];
2759 var fontLoadPromises = [];
2760 var getNativeFontPromise = function(nativeFontFace) {
2761 // Return a promise that is always fulfilled, even when the font fails to
2762 // load.
2763 return nativeFontFace.loaded.catch(function(e) {
2764 warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
2765 });
2766 };
2767 for (var i = 0, ii = fonts.length; i < ii; i++) {
2768 var font = fonts[i];
2769
2770 // Add the font to the DOM only once or skip if the font
2771 // is already loaded.
2772 if (font.attached || font.loading === false) {
2773 continue;
2774 }
2775 font.attached = true;
2776
2777 if (FontLoader.isFontLoadingAPISupported) {
2778 var nativeFontFace = font.createNativeFontFace();
2779 if (nativeFontFace) {
2780 this.addNativeFontFace(nativeFontFace);
2781 fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
2782 }
2783 } else {
2784 var rule = font.createFontFaceRule();
2785 if (rule) {
2786 this.insertRule(rule);
2787 rules.push(rule);
2788 fontsToLoad.push(font);
2789 }
2790 }
2791 }
2792
2793 var request = this.queueLoadingCallback(callback);
2794 if (FontLoader.isFontLoadingAPISupported) {
2795 Promise.all(fontLoadPromises).then(function() {
2796 request.complete();
2797 });
2798 } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
2799 this.prepareFontLoadEvent(rules, fontsToLoad, request);
2800 } else {
2801 request.complete();
2802 }
2803 },
2804
2805 queueLoadingCallback: function FontLoader_queueLoadingCallback(callback) {
2806 function LoadLoader_completeRequest() {
2807 assert(!request.end, 'completeRequest() cannot be called twice');
2808 request.end = Date.now();
2809
2810 // sending all completed requests in order how they were queued
2811 while (context.requests.length > 0 && context.requests[0].end) {
2812 var otherRequest = context.requests.shift();
2813 setTimeout(otherRequest.callback, 0);
2814 }
2815 }
2816
2817 var context = this.loadingContext;
2818 var requestId = 'pdfjs-font-loading-' + (context.nextRequestId++);
2819 var request = {
2820 id: requestId,
2821 complete: LoadLoader_completeRequest,
2822 callback: callback,
2823 started: Date.now()
2824 };
2825 context.requests.push(request);
2826 return request;
2827 },
2828
2829 prepareFontLoadEvent: function fontLoaderPrepareFontLoadEvent(rules,
2830 fonts,
2831 request) {
2832 /** Hack begin */
2833 // There's currently no event when a font has finished downloading so the
2834 // following code is a dirty hack to 'guess' when a font is
2835 // ready. It's assumed fonts are loaded in order, so add a known test
2836 // font after the desired fonts and then test for the loading of that
2837 // test font.
2838
2839 function int32(data, offset) {
2840 return (data.charCodeAt(offset) << 24) |
2841 (data.charCodeAt(offset + 1) << 16) |
2842 (data.charCodeAt(offset + 2) << 8) |
2843 (data.charCodeAt(offset + 3) & 0xff);
2844 }
2845
2846 function spliceString(s, offset, remove, insert) {
2847 var chunk1 = s.substr(0, offset);
2848 var chunk2 = s.substr(offset + remove);
2849 return chunk1 + insert + chunk2;
2850 }
2851
2852 var i, ii;
2853
2854 var canvas = document.createElement('canvas');
2855 canvas.width = 1;
2856 canvas.height = 1;
2857 var ctx = canvas.getContext('2d');
2858
2859 var called = 0;
2860 function isFontReady(name, callback) {
2861 called++;
2862 // With setTimeout clamping this gives the font ~100ms to load.
2863 if(called > 30) {
2864 warn('Load test font never loaded.');
2865 callback();
2866 return;
2867 }
2868 ctx.font = '30px ' + name;
2869 ctx.fillText('.', 0, 20);
2870 var imageData = ctx.getImageData(0, 0, 1, 1);
2871 if (imageData.data[3] > 0) {
2872 callback();
2873 return;
2874 }
2875 setTimeout(isFontReady.bind(null, name, callback));
2876 }
2877
2878 var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
2879 // Chromium seems to cache fonts based on a hash of the actual font data,
2880 // so the font must be modified for each load test else it will appear to
2881 // be loaded already.
2882 // TODO: This could maybe be made faster by avoiding the btoa of the full
2883 // font by splitting it in chunks before hand and padding the font id.
2884 var data = this.loadTestFont;
2885 var COMMENT_OFFSET = 976; // has to be on 4 byte boundary (for checksum)
2886 data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length,
2887 loadTestFontId);
2888 // CFF checksum is important for IE, adjusting it
2889 var CFF_CHECKSUM_OFFSET = 16;
2890 var XXXX_VALUE = 0x58585858; // the "comment" filled with 'X'
2891 var checksum = int32(data, CFF_CHECKSUM_OFFSET);
2892 for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
2893 checksum = (checksum - XXXX_VALUE + int32(loadTestFontId, i)) | 0;
2894 }
2895 if (i < loadTestFontId.length) { // align to 4 bytes boundary
2896 checksum = (checksum - XXXX_VALUE +
2897 int32(loadTestFontId + 'XXX', i)) | 0;
2898 }
2899 data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
2900
2901 var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
2902 var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' +
2903 url + '}';
2904 this.insertRule(rule);
2905
2906 var names = [];
2907 for (i = 0, ii = fonts.length; i < ii; i++) {
2908 names.push(fonts[i].loadedName);
2909 }
2910 names.push(loadTestFontId);
2911
2912 var div = document.createElement('div');
2913 div.setAttribute('style',
2914 'visibility: hidden;' +
2915 'width: 10px; height: 10px;' +
2916 'position: absolute; top: 0px; left: 0px;');
2917 for (i = 0, ii = names.length; i < ii; ++i) {
2918 var span = document.createElement('span');
2919 span.textContent = 'Hi';
2920 span.style.fontFamily = names[i];
2921 div.appendChild(span);
2922 }
2923 document.body.appendChild(div);
2924
2925 isFontReady(loadTestFontId, function() {
2926 document.body.removeChild(div);
2927 request.complete();
2928 });
2929 /** Hack end */
2930 }
2931};
2932FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' &&
2933 !!document.fonts;
2934Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
2935 get: function () {
2936 if (typeof navigator === 'undefined') {
2937 // node.js - we can pretend sync font loading is supported.
2938 return shadow(FontLoader, 'isSyncFontLoadingSupported', true);
2939 }
2940
2941 var supported = false;
2942
2943 // User agent string sniffing is bad, but there is no reliable way to tell
2944 // if font is fully loaded and ready to be used with canvas.
2945 var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
2946 if (m && m[1] >= 14) {
2947 supported = true;
2948 }
2949 // TODO other browsers
2950 return shadow(FontLoader, 'isSyncFontLoadingSupported', supported);
2951 },
2952 enumerable: true,
2953 configurable: true
2954});
2955
2956var IsEvalSupportedCached = {
2957 get value() {
2958 return shadow(this, 'value', sharedUtil.isEvalSupported());
2959 }
2960};
2961
2962var FontFaceObject = (function FontFaceObjectClosure() {
2963 function FontFaceObject(translatedData, options) {
2964 this.compiledGlyphs = Object.create(null);
2965 // importing translated data
2966 for (var i in translatedData) {
2967 this[i] = translatedData[i];
2968 }
2969 this.options = options;
2970 }
2971 FontFaceObject.prototype = {
2972 createNativeFontFace: function FontFaceObject_createNativeFontFace() {
2973 if (!this.data) {
2974 return null;
2975 }
2976
2977 if (this.options.disableFontFace) {
2978 this.disableFontFace = true;
2979 return null;
2980 }
2981
2982 var nativeFontFace = new FontFace(this.loadedName, this.data, {});
2983
2984 if (this.options.fontRegistry) {
2985 this.options.fontRegistry.registerFont(this);
2986 }
2987 return nativeFontFace;
2988 },
2989
2990 createFontFaceRule: function FontFaceObject_createFontFaceRule() {
2991 if (!this.data) {
2992 return null;
2993 }
2994
2995 if (this.options.disableFontFace) {
2996 this.disableFontFace = true;
2997 return null;
2998 }
2999
3000 var data = bytesToString(new Uint8Array(this.data));
3001 var fontName = this.loadedName;
3002
3003 // Add the font-face rule to the document
3004 var url = ('url(data:' + this.mimetype + ';base64,' + btoa(data) + ');');
3005 var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
3006
3007 if (this.options.fontRegistry) {
3008 this.options.fontRegistry.registerFont(this, url);
3009 }
3010
3011 return rule;
3012 },
3013
3014 getPathGenerator:
3015 function FontFaceObject_getPathGenerator(objs, character) {
3016 if (!(character in this.compiledGlyphs)) {
3017 var cmds = objs.get(this.loadedName + '_path_' + character);
3018 var current, i, len;
3019
3020 // If we can, compile cmds into JS for MAXIMUM SPEED
3021 if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
3022 var args, js = '';
3023 for (i = 0, len = cmds.length; i < len; i++) {
3024 current = cmds[i];
3025
3026 if (current.args !== undefined) {
3027 args = current.args.join(',');
3028 } else {
3029 args = '';
3030 }
3031
3032 js += 'c.' + current.cmd + '(' + args + ');\n';
3033 }
3034 /* jshint -W054 */
3035 this.compiledGlyphs[character] = new Function('c', 'size', js);
3036 } else {
3037 // But fall back on using Function.prototype.apply() if we're
3038 // blocked from using eval() for whatever reason (like CSP policies)
3039 this.compiledGlyphs[character] = function(c, size) {
3040 for (i = 0, len = cmds.length; i < len; i++) {
3041 current = cmds[i];
3042
3043 if (current.cmd === 'scale') {
3044 current.args = [size, -size];
3045 }
3046
3047 c[current.cmd].apply(c, current.args);
3048 }
3049 };
3050 }
3051 }
3052 return this.compiledGlyphs[character];
3053 }
3054 };
3055 return FontFaceObject;
3056})();
3057
3058exports.FontFaceObject = FontFaceObject;
3059exports.FontLoader = FontLoader;
3060}));
3061
3062
3063(function (root, factory) {
3064 {
3065 factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil);
3066 }
3067}(this, function (exports, sharedUtil) {
3068
3069var error = sharedUtil.error;
3070
3071 function fixMetadata(meta) {
3072 return meta.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
3073 var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g,
3074 function(code, d1, d2, d3) {
3075 return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
3076 });
3077 var chars = '';
3078 for (var i = 0; i < bytes.length; i += 2) {
3079 var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
3080 chars += code >= 32 && code < 127 && code !== 60 && code !== 62 &&
3081 code !== 38 && false ? String.fromCharCode(code) :
3082 '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
3083 }
3084 return '>' + chars;
3085 });
3086 }
3087
3088 function Metadata(meta) {
3089 if (typeof meta === 'string') {
3090 // Ghostscript produces invalid metadata
3091 meta = fixMetadata(meta);
3092
3093 var parser = new DOMParser();
3094 meta = parser.parseFromString(meta, 'application/xml');
3095 } else if (!(meta instanceof Document)) {
3096 error('Metadata: Invalid metadata object');
3097 }
3098
3099 this.metaDocument = meta;
3100 this.metadata = Object.create(null);
3101 this.parse();
3102 }
3103
3104 Metadata.prototype = {
3105 parse: function Metadata_parse() {
3106 var doc = this.metaDocument;
3107 var rdf = doc.documentElement;
3108
3109 if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { // Wrapped in <xmpmeta>
3110 rdf = rdf.firstChild;
3111 while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
3112 rdf = rdf.nextSibling;
3113 }
3114 }
3115
3116 var nodeName = (rdf) ? rdf.nodeName.toLowerCase() : null;
3117 if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
3118 return;
3119 }
3120
3121 var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
3122 for (i = 0, length = children.length; i < length; i++) {
3123 desc = children[i];
3124 if (desc.nodeName.toLowerCase() !== 'rdf:description') {
3125 continue;
3126 }
3127
3128 for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
3129 if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
3130 entry = desc.childNodes[ii];
3131 name = entry.nodeName.toLowerCase();
3132 this.metadata[name] = entry.textContent.trim();
3133 }
3134 }
3135 }
3136 },
3137
3138 get: function Metadata_get(name) {
3139 return this.metadata[name] || null;
3140 },
3141
3142 has: function Metadata_has(name) {
3143 return typeof this.metadata[name] !== 'undefined';
3144 }
3145 };
3146
3147exports.Metadata = Metadata;
3148}));
3149
3150
3151(function (root, factory) {
3152 {
3153 factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil);
3154 }
3155}(this, function (exports, sharedUtil) {
3156var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
3157var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
3158var ImageKind = sharedUtil.ImageKind;
3159var OPS = sharedUtil.OPS;
3160var Util = sharedUtil.Util;
3161var isNum = sharedUtil.isNum;
3162var isArray = sharedUtil.isArray;
3163var warn = sharedUtil.warn;
3164var createObjectURL = sharedUtil.createObjectURL;
3165
3166var SVG_DEFAULTS = {
3167 fontStyle: 'normal',
3168 fontWeight: 'normal',
3169 fillColor: '#000000'
3170};
3171
3172var convertImgDataToPng = (function convertImgDataToPngClosure() {
3173 var PNG_HEADER =
3174 new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
3175
3176 var CHUNK_WRAPPER_SIZE = 12;
3177
3178 var crcTable = new Int32Array(256);
3179 for (var i = 0; i < 256; i++) {
3180 var c = i;
3181 for (var h = 0; h < 8; h++) {
3182 if (c & 1) {
3183 c = 0xedB88320 ^ ((c >> 1) & 0x7fffffff);
3184 } else {
3185 c = (c >> 1) & 0x7fffffff;
3186 }
3187 }
3188 crcTable[i] = c;
3189 }
3190
3191 function crc32(data, start, end) {
3192 var crc = -1;
3193 for (var i = start; i < end; i++) {
3194 var a = (crc ^ data[i]) & 0xff;
3195 var b = crcTable[a];
3196 crc = (crc >>> 8) ^ b;
3197 }
3198 return crc ^ -1;
3199 }
3200
3201 function writePngChunk(type, body, data, offset) {
3202 var p = offset;
3203 var len = body.length;
3204
3205 data[p] = len >> 24 & 0xff;
3206 data[p + 1] = len >> 16 & 0xff;
3207 data[p + 2] = len >> 8 & 0xff;
3208 data[p + 3] = len & 0xff;
3209 p += 4;
3210
3211 data[p] = type.charCodeAt(0) & 0xff;
3212 data[p + 1] = type.charCodeAt(1) & 0xff;
3213 data[p + 2] = type.charCodeAt(2) & 0xff;
3214 data[p + 3] = type.charCodeAt(3) & 0xff;
3215 p += 4;
3216
3217 data.set(body, p);
3218 p += body.length;
3219
3220 var crc = crc32(data, offset + 4, p);
3221
3222 data[p] = crc >> 24 & 0xff;
3223 data[p + 1] = crc >> 16 & 0xff;
3224 data[p + 2] = crc >> 8 & 0xff;
3225 data[p + 3] = crc & 0xff;
3226 }
3227
3228 function adler32(data, start, end) {
3229 var a = 1;
3230 var b = 0;
3231 for (var i = start; i < end; ++i) {
3232 a = (a + (data[i] & 0xff)) % 65521;
3233 b = (b + a) % 65521;
3234 }
3235 return (b << 16) | a;
3236 }
3237
3238 function encode(imgData, kind, forceDataSchema) {
3239 var width = imgData.width;
3240 var height = imgData.height;
3241 var bitDepth, colorType, lineSize;
3242 var bytes = imgData.data;
3243
3244 switch (kind) {
3245 case ImageKind.GRAYSCALE_1BPP:
3246 colorType = 0;
3247 bitDepth = 1;
3248 lineSize = (width + 7) >> 3;
3249 break;
3250 case ImageKind.RGB_24BPP:
3251 colorType = 2;
3252 bitDepth = 8;
3253 lineSize = width * 3;
3254 break;
3255 case ImageKind.RGBA_32BPP:
3256 colorType = 6;
3257 bitDepth = 8;
3258 lineSize = width * 4;
3259 break;
3260 default:
3261 throw new Error('invalid format');
3262 }
3263
3264 // prefix every row with predictor 0
3265 var literals = new Uint8Array((1 + lineSize) * height);
3266 var offsetLiterals = 0, offsetBytes = 0;
3267 var y, i;
3268 for (y = 0; y < height; ++y) {
3269 literals[offsetLiterals++] = 0; // no prediction
3270 literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize),
3271 offsetLiterals);
3272 offsetBytes += lineSize;
3273 offsetLiterals += lineSize;
3274 }
3275
3276 if (kind === ImageKind.GRAYSCALE_1BPP) {
3277 // inverting for B/W
3278 offsetLiterals = 0;
3279 for (y = 0; y < height; y++) {
3280 offsetLiterals++; // skipping predictor
3281 for (i = 0; i < lineSize; i++) {
3282 literals[offsetLiterals++] ^= 0xFF;
3283 }
3284 }
3285 }
3286
3287 var ihdr = new Uint8Array([
3288 width >> 24 & 0xff,
3289 width >> 16 & 0xff,
3290 width >> 8 & 0xff,
3291 width & 0xff,
3292 height >> 24 & 0xff,
3293 height >> 16 & 0xff,
3294 height >> 8 & 0xff,
3295 height & 0xff,
3296 bitDepth, // bit depth
3297 colorType, // color type
3298 0x00, // compression method
3299 0x00, // filter method
3300 0x00 // interlace method
3301 ]);
3302
3303 var len = literals.length;
3304 var maxBlockLength = 0xFFFF;
3305
3306 var deflateBlocks = Math.ceil(len / maxBlockLength);
3307 var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
3308 var pi = 0;
3309 idat[pi++] = 0x78; // compression method and flags
3310 idat[pi++] = 0x9c; // flags
3311
3312 var pos = 0;
3313 while (len > maxBlockLength) {
3314 // writing non-final DEFLATE blocks type 0 and length of 65535
3315 idat[pi++] = 0x00;
3316 idat[pi++] = 0xff;
3317 idat[pi++] = 0xff;
3318 idat[pi++] = 0x00;
3319 idat[pi++] = 0x00;
3320 idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
3321 pi += maxBlockLength;
3322 pos += maxBlockLength;
3323 len -= maxBlockLength;
3324 }
3325
3326 // writing non-final DEFLATE blocks type 0
3327 idat[pi++] = 0x01;
3328 idat[pi++] = len & 0xff;
3329 idat[pi++] = len >> 8 & 0xff;
3330 idat[pi++] = (~len & 0xffff) & 0xff;
3331 idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
3332 idat.set(literals.subarray(pos), pi);
3333 pi += literals.length - pos;
3334
3335 var adler = adler32(literals, 0, literals.length); // checksum
3336 idat[pi++] = adler >> 24 & 0xff;
3337 idat[pi++] = adler >> 16 & 0xff;
3338 idat[pi++] = adler >> 8 & 0xff;
3339 idat[pi++] = adler & 0xff;
3340
3341 // PNG will consists: header, IHDR+data, IDAT+data, and IEND.
3342 var pngLength = PNG_HEADER.length + (CHUNK_WRAPPER_SIZE * 3) +
3343 ihdr.length + idat.length;
3344 var data = new Uint8Array(pngLength);
3345 var offset = 0;
3346 data.set(PNG_HEADER, offset);
3347 offset += PNG_HEADER.length;
3348 writePngChunk('IHDR', ihdr, data, offset);
3349 offset += CHUNK_WRAPPER_SIZE + ihdr.length;
3350 writePngChunk('IDATA', idat, data, offset);
3351 offset += CHUNK_WRAPPER_SIZE + idat.length;
3352 writePngChunk('IEND', new Uint8Array(0), data, offset);
3353
3354 return createObjectURL(data, 'image/png', forceDataSchema);
3355 }
3356
3357 return function convertImgDataToPng(imgData, forceDataSchema) {
3358 var kind = (imgData.kind === undefined ?
3359 ImageKind.GRAYSCALE_1BPP : imgData.kind);
3360 return encode(imgData, kind, forceDataSchema);
3361 };
3362})();
3363
3364var SVGExtraState = (function SVGExtraStateClosure() {
3365 function SVGExtraState() {
3366 this.fontSizeScale = 1;
3367 this.fontWeight = SVG_DEFAULTS.fontWeight;
3368 this.fontSize = 0;
3369
3370 this.textMatrix = IDENTITY_MATRIX;
3371 this.fontMatrix = FONT_IDENTITY_MATRIX;
3372 this.leading = 0;
3373
3374 // Current point (in user coordinates)
3375 this.x = 0;
3376 this.y = 0;
3377
3378 // Start of text line (in text coordinates)
3379 this.lineX = 0;
3380 this.lineY = 0;
3381
3382 // Character and word spacing
3383 this.charSpacing = 0;
3384 this.wordSpacing = 0;
3385 this.textHScale = 1;
3386 this.textRise = 0;
3387
3388 // Default foreground and background colors
3389 this.fillColor = SVG_DEFAULTS.fillColor;
3390 this.strokeColor = '#000000';
3391
3392 this.fillAlpha = 1;
3393 this.strokeAlpha = 1;
3394 this.lineWidth = 1;
3395 this.lineJoin = '';
3396 this.lineCap = '';
3397 this.miterLimit = 0;
3398
3399 this.dashArray = [];
3400 this.dashPhase = 0;
3401
3402 this.dependencies = [];
3403
3404 // Clipping
3405 this.clipId = '';
3406 this.pendingClip = false;
3407
3408 this.maskId = '';
3409 }
3410
3411 SVGExtraState.prototype = {
3412 clone: function SVGExtraState_clone() {
3413 return Object.create(this);
3414 },
3415 setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
3416 this.x = x;
3417 this.y = y;
3418 }
3419 };
3420 return SVGExtraState;
3421})();
3422
3423var SVGGraphics = (function SVGGraphicsClosure() {
3424 function createScratchSVG(width, height) {
3425 var NS = 'http://www.w3.org/2000/svg';
3426 var svg = document.createElementNS(NS, 'svg:svg');
3427 svg.setAttributeNS(null, 'version', '1.1');
3428 svg.setAttributeNS(null, 'width', width + 'px');
3429 svg.setAttributeNS(null, 'height', height + 'px');
3430 svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height);
3431 return svg;
3432 }
3433
3434 function opListToTree(opList) {
3435 var opTree = [];
3436 var tmp = [];
3437 var opListLen = opList.length;
3438
3439 for (var x = 0; x < opListLen; x++) {
3440 if (opList[x].fn === 'save') {
3441 opTree.push({'fnId': 92, 'fn': 'group', 'items': []});
3442 tmp.push(opTree);
3443 opTree = opTree[opTree.length - 1].items;
3444 continue;
3445 }
3446
3447 if(opList[x].fn === 'restore') {
3448 opTree = tmp.pop();
3449 } else {
3450 opTree.push(opList[x]);
3451 }
3452 }
3453 return opTree;
3454 }
3455
3456 /**
3457 * Formats float number.
3458 * @param value {number} number to format.
3459 * @returns {string}
3460 */
3461 function pf(value) {
3462 if (value === (value | 0)) { // integer number
3463 return value.toString();
3464 }
3465 var s = value.toFixed(10);
3466 var i = s.length - 1;
3467 if (s[i] !== '0') {
3468 return s;
3469 }
3470 // removing trailing zeros
3471 do {
3472 i--;
3473 } while (s[i] === '0');
3474 return s.substr(0, s[i] === '.' ? i : i + 1);
3475 }
3476
3477 /**
3478 * Formats transform matrix. The standard rotation, scale and translate
3479 * matrices are replaced by their shorter forms, and for identity matrix
3480 * returns empty string to save the memory.
3481 * @param m {Array} matrix to format.
3482 * @returns {string}
3483 */
3484 function pm(m) {
3485 if (m[4] === 0 && m[5] === 0) {
3486 if (m[1] === 0 && m[2] === 0) {
3487 if (m[0] === 1 && m[3] === 1) {
3488 return '';
3489 }
3490 return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
3491 }
3492 if (m[0] === m[3] && m[1] === -m[2]) {
3493 var a = Math.acos(m[0]) * 180 / Math.PI;
3494 return 'rotate(' + pf(a) + ')';
3495 }
3496 } else {
3497 if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
3498 return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
3499 }
3500 }
3501 return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' +
3502 pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
3503 }
3504
3505 function SVGGraphics(commonObjs, objs, forceDataSchema) {
3506 this.current = new SVGExtraState();
3507 this.transformMatrix = IDENTITY_MATRIX; // Graphics state matrix
3508 this.transformStack = [];
3509 this.extraStack = [];
3510 this.commonObjs = commonObjs;
3511 this.objs = objs;
3512 this.pendingEOFill = false;
3513
3514 this.embedFonts = false;
3515 this.embeddedFonts = Object.create(null);
3516 this.cssStyle = null;
3517 this.forceDataSchema = !!forceDataSchema;
3518 }
3519
3520 var NS = 'http://www.w3.org/2000/svg';
3521 var XML_NS = 'http://www.w3.org/XML/1998/namespace';
3522 var XLINK_NS = 'http://www.w3.org/1999/xlink';
3523 var LINE_CAP_STYLES = ['butt', 'round', 'square'];
3524 var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
3525 var clipCount = 0;
3526 var maskCount = 0;
3527
3528 SVGGraphics.prototype = {
3529 save: function SVGGraphics_save() {
3530 this.transformStack.push(this.transformMatrix);
3531 var old = this.current;
3532 this.extraStack.push(old);
3533 this.current = old.clone();
3534 },
3535
3536 restore: function SVGGraphics_restore() {
3537 this.transformMatrix = this.transformStack.pop();
3538 this.current = this.extraStack.pop();
3539
3540 this.tgrp = document.createElementNS(NS, 'svg:g');
3541 this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
3542 this.pgrp.appendChild(this.tgrp);
3543 },
3544
3545 group: function SVGGraphics_group(items) {
3546 this.save();
3547 this.executeOpTree(items);
3548 this.restore();
3549 },
3550
3551 loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
3552 var fnArray = operatorList.fnArray;
3553 var fnArrayLen = fnArray.length;
3554 var argsArray = operatorList.argsArray;
3555
3556 var self = this;
3557 for (var i = 0; i < fnArrayLen; i++) {
3558 if (OPS.dependency === fnArray[i]) {
3559 var deps = argsArray[i];
3560 for (var n = 0, nn = deps.length; n < nn; n++) {
3561 var obj = deps[n];
3562 var common = obj.substring(0, 2) === 'g_';
3563 var promise;
3564 if (common) {
3565 promise = new Promise(function(resolve) {
3566 self.commonObjs.get(obj, resolve);
3567 });
3568 } else {
3569 promise = new Promise(function(resolve) {
3570 self.objs.get(obj, resolve);
3571 });
3572 }
3573 this.current.dependencies.push(promise);
3574 }
3575 }
3576 }
3577 return Promise.all(this.current.dependencies);
3578 },
3579
3580 transform: function SVGGraphics_transform(a, b, c, d, e, f) {
3581 var transformMatrix = [a, b, c, d, e, f];
3582 this.transformMatrix = Util.transform(this.transformMatrix,
3583 transformMatrix);
3584
3585 this.tgrp = document.createElementNS(NS, 'svg:g');
3586 this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
3587 },
3588
3589 getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
3590 this.svg = createScratchSVG(viewport.width, viewport.height);
3591 this.viewport = viewport;
3592
3593 return this.loadDependencies(operatorList).then(function () {
3594 this.transformMatrix = IDENTITY_MATRIX;
3595 this.pgrp = document.createElementNS(NS, 'svg:g'); // Parent group
3596 this.pgrp.setAttributeNS(null, 'transform', pm(viewport.transform));
3597 this.tgrp = document.createElementNS(NS, 'svg:g'); // Transform group
3598 this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
3599 this.defs = document.createElementNS(NS, 'svg:defs');
3600 this.pgrp.appendChild(this.defs);
3601 this.pgrp.appendChild(this.tgrp);
3602 this.svg.appendChild(this.pgrp);
3603 var opTree = this.convertOpList(operatorList);
3604 this.executeOpTree(opTree);
3605 return this.svg;
3606 }.bind(this));
3607 },
3608
3609 convertOpList: function SVGGraphics_convertOpList(operatorList) {
3610 var argsArray = operatorList.argsArray;
3611 var fnArray = operatorList.fnArray;
3612 var fnArrayLen = fnArray.length;
3613 var REVOPS = [];
3614 var opList = [];
3615
3616 for (var op in OPS) {
3617 REVOPS[OPS[op]] = op;
3618 }
3619
3620 for (var x = 0; x < fnArrayLen; x++) {
3621 var fnId = fnArray[x];
3622 opList.push({'fnId' : fnId, 'fn': REVOPS[fnId], 'args': argsArray[x]});
3623 }
3624 return opListToTree(opList);
3625 },
3626
3627 executeOpTree: function SVGGraphics_executeOpTree(opTree) {
3628 var opTreeLen = opTree.length;
3629 for(var x = 0; x < opTreeLen; x++) {
3630 var fn = opTree[x].fn;
3631 var fnId = opTree[x].fnId;
3632 var args = opTree[x].args;
3633
3634 switch (fnId | 0) {
3635 case OPS.beginText:
3636 this.beginText();
3637 break;
3638 case OPS.setLeading:
3639 this.setLeading(args);
3640 break;
3641 case OPS.setLeadingMoveText:
3642 this.setLeadingMoveText(args[0], args[1]);
3643 break;
3644 case OPS.setFont:
3645 this.setFont(args);
3646 break;
3647 case OPS.showText:
3648 this.showText(args[0]);
3649 break;
3650 case OPS.showSpacedText:
3651 this.showText(args[0]);
3652 break;
3653 case OPS.endText:
3654 this.endText();
3655 break;
3656 case OPS.moveText:
3657 this.moveText(args[0], args[1]);
3658 break;
3659 case OPS.setCharSpacing:
3660 this.setCharSpacing(args[0]);
3661 break;
3662 case OPS.setWordSpacing:
3663 this.setWordSpacing(args[0]);
3664 break;
3665 case OPS.setHScale:
3666 this.setHScale(args[0]);
3667 break;
3668 case OPS.setTextMatrix:
3669 this.setTextMatrix(args[0], args[1], args[2],
3670 args[3], args[4], args[5]);
3671 break;
3672 case OPS.setLineWidth:
3673 this.setLineWidth(args[0]);
3674 break;
3675 case OPS.setLineJoin:
3676 this.setLineJoin(args[0]);
3677 break;
3678 case OPS.setLineCap:
3679 this.setLineCap(args[0]);
3680 break;
3681 case OPS.setMiterLimit:
3682 this.setMiterLimit(args[0]);
3683 break;
3684 case OPS.setFillRGBColor:
3685 this.setFillRGBColor(args[0], args[1], args[2]);
3686 break;
3687 case OPS.setStrokeRGBColor:
3688 this.setStrokeRGBColor(args[0], args[1], args[2]);
3689 break;
3690 case OPS.setDash:
3691 this.setDash(args[0], args[1]);
3692 break;
3693 case OPS.setGState:
3694 this.setGState(args[0]);
3695 break;
3696 case OPS.fill:
3697 this.fill();
3698 break;
3699 case OPS.eoFill:
3700 this.eoFill();
3701 break;
3702 case OPS.stroke:
3703 this.stroke();
3704 break;
3705 case OPS.fillStroke:
3706 this.fillStroke();
3707 break;
3708 case OPS.eoFillStroke:
3709 this.eoFillStroke();
3710 break;
3711 case OPS.clip:
3712 this.clip('nonzero');
3713 break;
3714 case OPS.eoClip:
3715 this.clip('evenodd');
3716 break;
3717 case OPS.paintSolidColorImageMask:
3718 this.paintSolidColorImageMask();
3719 break;
3720 case OPS.paintJpegXObject:
3721 this.paintJpegXObject(args[0], args[1], args[2]);
3722 break;
3723 case OPS.paintImageXObject:
3724 this.paintImageXObject(args[0]);
3725 break;
3726 case OPS.paintInlineImageXObject:
3727 this.paintInlineImageXObject(args[0]);
3728 break;
3729 case OPS.paintImageMaskXObject:
3730 this.paintImageMaskXObject(args[0]);
3731 break;
3732 case OPS.paintFormXObjectBegin:
3733 this.paintFormXObjectBegin(args[0], args[1]);
3734 break;
3735 case OPS.paintFormXObjectEnd:
3736 this.paintFormXObjectEnd();
3737 break;
3738 case OPS.closePath:
3739 this.closePath();
3740 break;
3741 case OPS.closeStroke:
3742 this.closeStroke();
3743 break;
3744 case OPS.closeFillStroke:
3745 this.closeFillStroke();
3746 break;
3747 case OPS.nextLine:
3748 this.nextLine();
3749 break;
3750 case OPS.transform:
3751 this.transform(args[0], args[1], args[2], args[3],
3752 args[4], args[5]);
3753 break;
3754 case OPS.constructPath:
3755 this.constructPath(args[0], args[1]);
3756 break;
3757 case OPS.endPath:
3758 this.endPath();
3759 break;
3760 case 92:
3761 this.group(opTree[x].items);
3762 break;
3763 default:
3764 warn('Unimplemented method '+ fn);
3765 break;
3766 }
3767 }
3768 },
3769
3770 setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
3771 this.current.wordSpacing = wordSpacing;
3772 },
3773
3774 setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
3775 this.current.charSpacing = charSpacing;
3776 },
3777
3778 nextLine: function SVGGraphics_nextLine() {
3779 this.moveText(0, this.current.leading);
3780 },
3781
3782 setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
3783 var current = this.current;
3784 this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f];
3785
3786 this.current.x = this.current.lineX = 0;
3787 this.current.y = this.current.lineY = 0;
3788
3789 current.xcoords = [];
3790 current.tspan = document.createElementNS(NS, 'svg:tspan');
3791 current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
3792 current.tspan.setAttributeNS(null, 'font-size',
3793 pf(current.fontSize) + 'px');
3794 current.tspan.setAttributeNS(null, 'y', pf(-current.y));
3795
3796 current.txtElement = document.createElementNS(NS, 'svg:text');
3797 current.txtElement.appendChild(current.tspan);
3798 },
3799
3800 beginText: function SVGGraphics_beginText() {
3801 this.current.x = this.current.lineX = 0;
3802 this.current.y = this.current.lineY = 0;
3803 this.current.textMatrix = IDENTITY_MATRIX;
3804 this.current.lineMatrix = IDENTITY_MATRIX;
3805 this.current.tspan = document.createElementNS(NS, 'svg:tspan');
3806 this.current.txtElement = document.createElementNS(NS, 'svg:text');
3807 this.current.txtgrp = document.createElementNS(NS, 'svg:g');
3808 this.current.xcoords = [];
3809 },
3810
3811 moveText: function SVGGraphics_moveText(x, y) {
3812 var current = this.current;
3813 this.current.x = this.current.lineX += x;
3814 this.current.y = this.current.lineY += y;
3815
3816 current.xcoords = [];
3817 current.tspan = document.createElementNS(NS, 'svg:tspan');
3818 current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
3819 current.tspan.setAttributeNS(null, 'font-size',
3820 pf(current.fontSize) + 'px');
3821 current.tspan.setAttributeNS(null, 'y', pf(-current.y));
3822 },
3823
3824 showText: function SVGGraphics_showText(glyphs) {
3825 var current = this.current;
3826 var font = current.font;
3827 var fontSize = current.fontSize;
3828
3829 if (fontSize === 0) {
3830 return;
3831 }
3832
3833 var charSpacing = current.charSpacing;
3834 var wordSpacing = current.wordSpacing;
3835 var fontDirection = current.fontDirection;
3836 var textHScale = current.textHScale * fontDirection;
3837 var glyphsLength = glyphs.length;
3838 var vertical = font.vertical;
3839 var widthAdvanceScale = fontSize * current.fontMatrix[0];
3840
3841 var x = 0, i;
3842 for (i = 0; i < glyphsLength; ++i) {
3843 var glyph = glyphs[i];
3844 if (glyph === null) {
3845 // word break
3846 x += fontDirection * wordSpacing;
3847 continue;
3848 } else if (isNum(glyph)) {
3849 x += -glyph * fontSize * 0.001;
3850 continue;
3851 }
3852 current.xcoords.push(current.x + x * textHScale);
3853
3854 var width = glyph.width;
3855 var character = glyph.fontChar;
3856 var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
3857 x += charWidth;
3858
3859 current.tspan.textContent += character;
3860 }
3861 if (vertical) {
3862 current.y -= x * textHScale;
3863 } else {
3864 current.x += x * textHScale;
3865 }
3866
3867 current.tspan.setAttributeNS(null, 'x',
3868 current.xcoords.map(pf).join(' '));
3869 current.tspan.setAttributeNS(null, 'y', pf(-current.y));
3870 current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
3871 current.tspan.setAttributeNS(null, 'font-size',
3872 pf(current.fontSize) + 'px');
3873 if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
3874 current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
3875 }
3876 if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
3877 current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
3878 }
3879 if (current.fillColor !== SVG_DEFAULTS.fillColor) {
3880 current.tspan.setAttributeNS(null, 'fill', current.fillColor);
3881 }
3882
3883 current.txtElement.setAttributeNS(null, 'transform',
3884 pm(current.textMatrix) +
3885 ' scale(1, -1)' );
3886 current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
3887 current.txtElement.appendChild(current.tspan);
3888 current.txtgrp.appendChild(current.txtElement);
3889
3890 this.tgrp.appendChild(current.txtElement);
3891
3892 },
3893
3894 setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
3895 this.setLeading(-y);
3896 this.moveText(x, y);
3897 },
3898
3899 addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
3900 if (!this.cssStyle) {
3901 this.cssStyle = document.createElementNS(NS, 'svg:style');
3902 this.cssStyle.setAttributeNS(null, 'type', 'text/css');
3903 this.defs.appendChild(this.cssStyle);
3904 }
3905
3906 var url = createObjectURL(fontObj.data, fontObj.mimetype,
3907 this.forceDataSchema);
3908 this.cssStyle.textContent +=
3909 '@font-face { font-family: "' + fontObj.loadedName + '";' +
3910 ' src: url(' + url + '); }\n';
3911 },
3912
3913 setFont: function SVGGraphics_setFont(details) {
3914 var current = this.current;
3915 var fontObj = this.commonObjs.get(details[0]);
3916 var size = details[1];
3917 this.current.font = fontObj;
3918
3919 if (this.embedFonts && fontObj.data &&
3920 !this.embeddedFonts[fontObj.loadedName]) {
3921 this.addFontStyle(fontObj);
3922 this.embeddedFonts[fontObj.loadedName] = fontObj;
3923 }
3924
3925 current.fontMatrix = (fontObj.fontMatrix ?
3926 fontObj.fontMatrix : FONT_IDENTITY_MATRIX);
3927
3928 var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') :
3929 (fontObj.bold ? 'bold' : 'normal');
3930 var italic = fontObj.italic ? 'italic' : 'normal';
3931
3932 if (size < 0) {
3933 size = -size;
3934 current.fontDirection = -1;
3935 } else {
3936 current.fontDirection = 1;
3937 }
3938 current.fontSize = size;
3939 current.fontFamily = fontObj.loadedName;
3940 current.fontWeight = bold;
3941 current.fontStyle = italic;
3942
3943 current.tspan = document.createElementNS(NS, 'svg:tspan');
3944 current.tspan.setAttributeNS(null, 'y', pf(-current.y));
3945 current.xcoords = [];
3946 },
3947
3948 endText: function SVGGraphics_endText() {
3949 if (this.current.pendingClip) {
3950 this.cgrp.appendChild(this.tgrp);
3951 this.pgrp.appendChild(this.cgrp);
3952 } else {
3953 this.pgrp.appendChild(this.tgrp);
3954 }
3955 this.tgrp = document.createElementNS(NS, 'svg:g');
3956 this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
3957 },
3958
3959 // Path properties
3960 setLineWidth: function SVGGraphics_setLineWidth(width) {
3961 this.current.lineWidth = width;
3962 },
3963 setLineCap: function SVGGraphics_setLineCap(style) {
3964 this.current.lineCap = LINE_CAP_STYLES[style];
3965 },
3966 setLineJoin: function SVGGraphics_setLineJoin(style) {
3967 this.current.lineJoin = LINE_JOIN_STYLES[style];
3968 },
3969 setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
3970 this.current.miterLimit = limit;
3971 },
3972 setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
3973 var color = Util.makeCssRgb(r, g, b);
3974 this.current.strokeColor = color;
3975 },
3976 setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
3977 var color = Util.makeCssRgb(r, g, b);
3978 this.current.fillColor = color;
3979 this.current.tspan = document.createElementNS(NS, 'svg:tspan');
3980 this.current.xcoords = [];
3981 },
3982 setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
3983 this.current.dashArray = dashArray;
3984 this.current.dashPhase = dashPhase;
3985 },
3986
3987 constructPath: function SVGGraphics_constructPath(ops, args) {
3988 var current = this.current;
3989 var x = current.x, y = current.y;
3990 current.path = document.createElementNS(NS, 'svg:path');
3991 var d = [];
3992 var opLength = ops.length;
3993
3994 for (var i = 0, j = 0; i < opLength; i++) {
3995 switch (ops[i] | 0) {
3996 case OPS.rectangle:
3997 x = args[j++];
3998 y = args[j++];
3999 var width = args[j++];
4000 var height = args[j++];
4001 var xw = x + width;
4002 var yh = y + height;
4003 d.push('M', pf(x), pf(y), 'L', pf(xw) , pf(y), 'L', pf(xw), pf(yh),
4004 'L', pf(x), pf(yh), 'Z');
4005 break;
4006 case OPS.moveTo:
4007 x = args[j++];
4008 y = args[j++];
4009 d.push('M', pf(x), pf(y));
4010 break;
4011 case OPS.lineTo:
4012 x = args[j++];
4013 y = args[j++];
4014 d.push('L', pf(x) , pf(y));
4015 break;
4016 case OPS.curveTo:
4017 x = args[j + 4];
4018 y = args[j + 5];
4019 d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]),
4020 pf(args[j + 3]), pf(x), pf(y));
4021 j += 6;
4022 break;
4023 case OPS.curveTo2:
4024 x = args[j + 2];
4025 y = args[j + 3];
4026 d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]),
4027 pf(args[j + 2]), pf(args[j + 3]));
4028 j += 4;
4029 break;
4030 case OPS.curveTo3:
4031 x = args[j + 2];
4032 y = args[j + 3];
4033 d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y),
4034 pf(x), pf(y));
4035 j += 4;
4036 break;
4037 case OPS.closePath:
4038 d.push('Z');
4039 break;
4040 }
4041 }
4042 current.path.setAttributeNS(null, 'd', d.join(' '));
4043 current.path.setAttributeNS(null, 'stroke-miterlimit',
4044 pf(current.miterLimit));
4045 current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
4046 current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
4047 current.path.setAttributeNS(null, 'stroke-width',
4048 pf(current.lineWidth) + 'px');
4049 current.path.setAttributeNS(null, 'stroke-dasharray',
4050 current.dashArray.map(pf).join(' '));
4051 current.path.setAttributeNS(null, 'stroke-dashoffset',
4052 pf(current.dashPhase) + 'px');
4053 current.path.setAttributeNS(null, 'fill', 'none');
4054
4055 this.tgrp.appendChild(current.path);
4056 if (current.pendingClip) {
4057 this.cgrp.appendChild(this.tgrp);
4058 this.pgrp.appendChild(this.cgrp);
4059 } else {
4060 this.pgrp.appendChild(this.tgrp);
4061 }
4062 // Saving a reference in current.element so that it can be addressed
4063 // in 'fill' and 'stroke'
4064 current.element = current.path;
4065 current.setCurrentPoint(x, y);
4066 },
4067
4068 endPath: function SVGGraphics_endPath() {
4069 var current = this.current;
4070 if (current.pendingClip) {
4071 this.cgrp.appendChild(this.tgrp);
4072 this.pgrp.appendChild(this.cgrp);
4073 } else {
4074 this.pgrp.appendChild(this.tgrp);
4075 }
4076 this.tgrp = document.createElementNS(NS, 'svg:g');
4077 this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
4078 },
4079
4080 clip: function SVGGraphics_clip(type) {
4081 var current = this.current;
4082 // Add current path to clipping path
4083 current.clipId = 'clippath' + clipCount;
4084 clipCount++;
4085 this.clippath = document.createElementNS(NS, 'svg:clipPath');
4086 this.clippath.setAttributeNS(null, 'id', current.clipId);
4087 var clipElement = current.element.cloneNode();
4088 if (type === 'evenodd') {
4089 clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
4090 } else {
4091 clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
4092 }
4093 this.clippath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
4094 this.clippath.appendChild(clipElement);
4095 this.defs.appendChild(this.clippath);
4096
4097 // Create a new group with that attribute
4098 current.pendingClip = true;
4099 this.cgrp = document.createElementNS(NS, 'svg:g');
4100 this.cgrp.setAttributeNS(null, 'clip-path',
4101 'url(#' + current.clipId + ')');
4102 this.pgrp.appendChild(this.cgrp);
4103 },
4104
4105 closePath: function SVGGraphics_closePath() {
4106 var current = this.current;
4107 var d = current.path.getAttributeNS(null, 'd');
4108 d += 'Z';
4109 current.path.setAttributeNS(null, 'd', d);
4110 },
4111
4112 setLeading: function SVGGraphics_setLeading(leading) {
4113 this.current.leading = -leading;
4114 },
4115
4116 setTextRise: function SVGGraphics_setTextRise(textRise) {
4117 this.current.textRise = textRise;
4118 },
4119
4120 setHScale: function SVGGraphics_setHScale(scale) {
4121 this.current.textHScale = scale / 100;
4122 },
4123
4124 setGState: function SVGGraphics_setGState(states) {
4125 for (var i = 0, ii = states.length; i < ii; i++) {
4126 var state = states[i];
4127 var key = state[0];
4128 var value = state[1];
4129
4130 switch (key) {
4131 case 'LW':
4132 this.setLineWidth(value);
4133 break;
4134 case 'LC':
4135 this.setLineCap(value);
4136 break;
4137 case 'LJ':
4138 this.setLineJoin(value);
4139 break;
4140 case 'ML':
4141 this.setMiterLimit(value);
4142 break;
4143 case 'D':
4144 this.setDash(value[0], value[1]);
4145 break;
4146 case 'RI':
4147 break;
4148 case 'FL':
4149 break;
4150 case 'Font':
4151 this.setFont(value);
4152 break;
4153 case 'CA':
4154 break;
4155 case 'ca':
4156 break;
4157 case 'BM':
4158 break;
4159 case 'SMask':
4160 break;
4161 }
4162 }
4163 },
4164
4165 fill: function SVGGraphics_fill() {
4166 var current = this.current;
4167 current.element.setAttributeNS(null, 'fill', current.fillColor);
4168 },
4169
4170 stroke: function SVGGraphics_stroke() {
4171 var current = this.current;
4172 current.element.setAttributeNS(null, 'stroke', current.strokeColor);
4173 current.element.setAttributeNS(null, 'fill', 'none');
4174 },
4175
4176 eoFill: function SVGGraphics_eoFill() {
4177 var current = this.current;
4178 current.element.setAttributeNS(null, 'fill', current.fillColor);
4179 current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
4180 },
4181
4182 fillStroke: function SVGGraphics_fillStroke() {
4183 // Order is important since stroke wants fill to be none.
4184 // First stroke, then if fill needed, it will be overwritten.
4185 this.stroke();
4186 this.fill();
4187 },
4188
4189 eoFillStroke: function SVGGraphics_eoFillStroke() {
4190 this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
4191 this.fillStroke();
4192 },
4193
4194 closeStroke: function SVGGraphics_closeStroke() {
4195 this.closePath();
4196 this.stroke();
4197 },
4198
4199 closeFillStroke: function SVGGraphics_closeFillStroke() {
4200 this.closePath();
4201 this.fillStroke();
4202 },
4203
4204 paintSolidColorImageMask:
4205 function SVGGraphics_paintSolidColorImageMask() {
4206 var current = this.current;
4207 var rect = document.createElementNS(NS, 'svg:rect');
4208 rect.setAttributeNS(null, 'x', '0');
4209 rect.setAttributeNS(null, 'y', '0');
4210 rect.setAttributeNS(null, 'width', '1px');
4211 rect.setAttributeNS(null, 'height', '1px');
4212 rect.setAttributeNS(null, 'fill', current.fillColor);
4213 this.tgrp.appendChild(rect);
4214 },
4215
4216 paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
4217 var current = this.current;
4218 var imgObj = this.objs.get(objId);
4219 var imgEl = document.createElementNS(NS, 'svg:image');
4220 imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
4221 imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
4222 imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
4223 imgEl.setAttributeNS(null, 'x', '0');
4224 imgEl.setAttributeNS(null, 'y', pf(-h));
4225 imgEl.setAttributeNS(null, 'transform',
4226 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
4227
4228 this.tgrp.appendChild(imgEl);
4229 if (current.pendingClip) {
4230 this.cgrp.appendChild(this.tgrp);
4231 this.pgrp.appendChild(this.cgrp);
4232 } else {
4233 this.pgrp.appendChild(this.tgrp);
4234 }
4235 },
4236
4237 paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
4238 var imgData = this.objs.get(objId);
4239 if (!imgData) {
4240 warn('Dependent image isn\'t ready yet');
4241 return;
4242 }
4243 this.paintInlineImageXObject(imgData);
4244 },
4245
4246 paintInlineImageXObject:
4247 function SVGGraphics_paintInlineImageXObject(imgData, mask) {
4248 var current = this.current;
4249 var width = imgData.width;
4250 var height = imgData.height;
4251
4252 var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
4253 var cliprect = document.createElementNS(NS, 'svg:rect');
4254 cliprect.setAttributeNS(null, 'x', '0');
4255 cliprect.setAttributeNS(null, 'y', '0');
4256 cliprect.setAttributeNS(null, 'width', pf(width));
4257 cliprect.setAttributeNS(null, 'height', pf(height));
4258 current.element = cliprect;
4259 this.clip('nonzero');
4260 var imgEl = document.createElementNS(NS, 'svg:image');
4261 imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
4262 imgEl.setAttributeNS(null, 'x', '0');
4263 imgEl.setAttributeNS(null, 'y', pf(-height));
4264 imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
4265 imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
4266 imgEl.setAttributeNS(null, 'transform',
4267 'scale(' + pf(1 / width) + ' ' +
4268 pf(-1 / height) + ')');
4269 if (mask) {
4270 mask.appendChild(imgEl);
4271 } else {
4272 this.tgrp.appendChild(imgEl);
4273 }
4274 if (current.pendingClip) {
4275 this.cgrp.appendChild(this.tgrp);
4276 this.pgrp.appendChild(this.cgrp);
4277 } else {
4278 this.pgrp.appendChild(this.tgrp);
4279 }
4280 },
4281
4282 paintImageMaskXObject:
4283 function SVGGraphics_paintImageMaskXObject(imgData) {
4284 var current = this.current;
4285 var width = imgData.width;
4286 var height = imgData.height;
4287 var fillColor = current.fillColor;
4288
4289 current.maskId = 'mask' + maskCount++;
4290 var mask = document.createElementNS(NS, 'svg:mask');
4291 mask.setAttributeNS(null, 'id', current.maskId);
4292
4293 var rect = document.createElementNS(NS, 'svg:rect');
4294 rect.setAttributeNS(null, 'x', '0');
4295 rect.setAttributeNS(null, 'y', '0');
4296 rect.setAttributeNS(null, 'width', pf(width));
4297 rect.setAttributeNS(null, 'height', pf(height));
4298 rect.setAttributeNS(null, 'fill', fillColor);
4299 rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId +')');
4300 this.defs.appendChild(mask);
4301 this.tgrp.appendChild(rect);
4302
4303 this.paintInlineImageXObject(imgData, mask);
4304 },
4305
4306 paintFormXObjectBegin:
4307 function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
4308 this.save();
4309
4310 if (isArray(matrix) && matrix.length === 6) {
4311 this.transform(matrix[0], matrix[1], matrix[2],
4312 matrix[3], matrix[4], matrix[5]);
4313 }
4314
4315 if (isArray(bbox) && bbox.length === 4) {
4316 var width = bbox[2] - bbox[0];
4317 var height = bbox[3] - bbox[1];
4318
4319 var cliprect = document.createElementNS(NS, 'svg:rect');
4320 cliprect.setAttributeNS(null, 'x', bbox[0]);
4321 cliprect.setAttributeNS(null, 'y', bbox[1]);
4322 cliprect.setAttributeNS(null, 'width', pf(width));
4323 cliprect.setAttributeNS(null, 'height', pf(height));
4324 this.current.element = cliprect;
4325 this.clip('nonzero');
4326 this.endPath();
4327 }
4328 },
4329
4330 paintFormXObjectEnd:
4331 function SVGGraphics_paintFormXObjectEnd() {
4332 this.restore();
4333 }
4334 };
4335 return SVGGraphics;
4336})();
4337
4338exports.SVGGraphics = SVGGraphics;
4339}));
4340
4341
4342(function (root, factory) {
4343 {
4344 factory((root.pdfjsDisplayAnnotationLayer = {}), root.pdfjsSharedUtil,
4345 root.pdfjsDisplayDOMUtils);
4346 }
4347}(this, function (exports, sharedUtil, displayDOMUtils) {
4348
4349var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
4350var AnnotationType = sharedUtil.AnnotationType;
4351var Util = sharedUtil.Util;
4352var addLinkAttributes = displayDOMUtils.addLinkAttributes;
4353var LinkTarget = displayDOMUtils.LinkTarget;
4354var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
4355var warn = sharedUtil.warn;
4356var CustomStyle = displayDOMUtils.CustomStyle;
4357var getDefaultSetting = displayDOMUtils.getDefaultSetting;
4358
4359/**
4360 * @typedef {Object} AnnotationElementParameters
4361 * @property {Object} data
4362 * @property {HTMLDivElement} layer
4363 * @property {PDFPage} page
4364 * @property {PageViewport} viewport
4365 * @property {IPDFLinkService} linkService
4366 * @property {DownloadManager} downloadManager
4367 * @property {string} imageResourcesPath
4368 * @property {boolean} renderInteractiveForms
4369 */
4370
4371/**
4372 * @class
4373 * @alias AnnotationElementFactory
4374 */
4375function AnnotationElementFactory() {}
4376AnnotationElementFactory.prototype =
4377 /** @lends AnnotationElementFactory.prototype */ {
4378 /**
4379 * @param {AnnotationElementParameters} parameters
4380 * @returns {AnnotationElement}
4381 */
4382 create: function AnnotationElementFactory_create(parameters) {
4383 var subtype = parameters.data.annotationType;
4384
4385 switch (subtype) {
4386 case AnnotationType.LINK:
4387 return new LinkAnnotationElement(parameters);
4388
4389 case AnnotationType.TEXT:
4390 return new TextAnnotationElement(parameters);
4391
4392 case AnnotationType.WIDGET:
4393 var fieldType = parameters.data.fieldType;
4394
4395 switch (fieldType) {
4396 case 'Tx':
4397 return new TextWidgetAnnotationElement(parameters);
4398 }
4399 return new WidgetAnnotationElement(parameters);
4400
4401 case AnnotationType.POPUP:
4402 return new PopupAnnotationElement(parameters);
4403
4404 case AnnotationType.HIGHLIGHT:
4405 return new HighlightAnnotationElement(parameters);
4406
4407 case AnnotationType.UNDERLINE:
4408 return new UnderlineAnnotationElement(parameters);
4409
4410 case AnnotationType.SQUIGGLY:
4411 return new SquigglyAnnotationElement(parameters);
4412
4413 case AnnotationType.STRIKEOUT:
4414 return new StrikeOutAnnotationElement(parameters);
4415
4416 case AnnotationType.FILEATTACHMENT:
4417 return new FileAttachmentAnnotationElement(parameters);
4418
4419 default:
4420 return new AnnotationElement(parameters);
4421 }
4422 }
4423};
4424
4425/**
4426 * @class
4427 * @alias AnnotationElement
4428 */
4429var AnnotationElement = (function AnnotationElementClosure() {
4430 function AnnotationElement(parameters, isRenderable) {
4431 this.isRenderable = isRenderable || false;
4432 this.data = parameters.data;
4433 this.layer = parameters.layer;
4434 this.page = parameters.page;
4435 this.viewport = parameters.viewport;
4436 this.linkService = parameters.linkService;
4437 this.downloadManager = parameters.downloadManager;
4438 this.imageResourcesPath = parameters.imageResourcesPath;
4439 this.renderInteractiveForms = parameters.renderInteractiveForms;
4440
4441 if (isRenderable) {
4442 this.container = this._createContainer();
4443 }
4444 }
4445
4446 AnnotationElement.prototype = /** @lends AnnotationElement.prototype */ {
4447 /**
4448 * Create an empty container for the annotation's HTML element.
4449 *
4450 * @private
4451 * @memberof AnnotationElement
4452 * @returns {HTMLSectionElement}
4453 */
4454 _createContainer: function AnnotationElement_createContainer() {
4455 var data = this.data, page = this.page, viewport = this.viewport;
4456 var container = document.createElement('section');
4457 var width = data.rect[2] - data.rect[0];
4458 var height = data.rect[3] - data.rect[1];
4459
4460 container.setAttribute('data-annotation-id', data.id);
4461
4462 // Do *not* modify `data.rect`, since that will corrupt the annotation
4463 // position on subsequent calls to `_createContainer` (see issue 6804).
4464 var rect = Util.normalizeRect([
4465 data.rect[0],
4466 page.view[3] - data.rect[1] + page.view[1],
4467 data.rect[2],
4468 page.view[3] - data.rect[3] + page.view[1]
4469 ]);
4470
4471 CustomStyle.setProp('transform', container,
4472 'matrix(' + viewport.transform.join(',') + ')');
4473 CustomStyle.setProp('transformOrigin', container,
4474 -rect[0] + 'px ' + -rect[1] + 'px');
4475
4476 if (data.borderStyle.width > 0) {
4477 container.style.borderWidth = data.borderStyle.width + 'px';
4478 if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
4479 // Underline styles only have a bottom border, so we do not need
4480 // to adjust for all borders. This yields a similar result as
4481 // Adobe Acrobat/Reader.
4482 width = width - 2 * data.borderStyle.width;
4483 height = height - 2 * data.borderStyle.width;
4484 }
4485
4486 var horizontalRadius = data.borderStyle.horizontalCornerRadius;
4487 var verticalRadius = data.borderStyle.verticalCornerRadius;
4488 if (horizontalRadius > 0 || verticalRadius > 0) {
4489 var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
4490 CustomStyle.setProp('borderRadius', container, radius);
4491 }
4492
4493 switch (data.borderStyle.style) {
4494 case AnnotationBorderStyleType.SOLID:
4495 container.style.borderStyle = 'solid';
4496 break;
4497
4498 case AnnotationBorderStyleType.DASHED:
4499 container.style.borderStyle = 'dashed';
4500 break;
4501
4502 case AnnotationBorderStyleType.BEVELED:
4503 warn('Unimplemented border style: beveled');
4504 break;
4505
4506 case AnnotationBorderStyleType.INSET:
4507 warn('Unimplemented border style: inset');
4508 break;
4509
4510 case AnnotationBorderStyleType.UNDERLINE:
4511 container.style.borderBottomStyle = 'solid';
4512 break;
4513
4514 default:
4515 break;
4516 }
4517
4518 if (data.color) {
4519 container.style.borderColor =
4520 Util.makeCssRgb(data.color[0] | 0,
4521 data.color[1] | 0,
4522 data.color[2] | 0);
4523 } else {
4524 // Transparent (invisible) border, so do not draw it at all.
4525 container.style.borderWidth = 0;
4526 }
4527 }
4528
4529 container.style.left = rect[0] + 'px';
4530 container.style.top = rect[1] + 'px';
4531
4532 container.style.width = width + 'px';
4533 container.style.height = height + 'px';
4534
4535 return container;
4536 },
4537
4538 /**
4539 * Create a popup for the annotation's HTML element. This is used for
4540 * annotations that do not have a Popup entry in the dictionary, but
4541 * are of a type that works with popups (such as Highlight annotations).
4542 *
4543 * @private
4544 * @param {HTMLSectionElement} container
4545 * @param {HTMLDivElement|HTMLImageElement|null} trigger
4546 * @param {Object} data
4547 * @memberof AnnotationElement
4548 */
4549 _createPopup:
4550 function AnnotationElement_createPopup(container, trigger, data) {
4551 // If no trigger element is specified, create it.
4552 if (!trigger) {
4553 trigger = document.createElement('div');
4554 trigger.style.height = container.style.height;
4555 trigger.style.width = container.style.width;
4556 container.appendChild(trigger);
4557 }
4558
4559 var popupElement = new PopupElement({
4560 container: container,
4561 trigger: trigger,
4562 color: data.color,
4563 title: data.title,
4564 contents: data.contents,
4565 hideWrapper: true
4566 });
4567 var popup = popupElement.render();
4568
4569 // Position the popup next to the annotation's container.
4570 popup.style.left = container.style.width;
4571
4572 container.appendChild(popup);
4573 },
4574
4575 /**
4576 * Render the annotation's HTML element in the empty container.
4577 *
4578 * @public
4579 * @memberof AnnotationElement
4580 */
4581 render: function AnnotationElement_render() {
4582 throw new Error('Abstract method AnnotationElement.render called');
4583 }
4584 };
4585
4586 return AnnotationElement;
4587})();
4588
4589/**
4590 * @class
4591 * @alias LinkAnnotationElement
4592 */
4593var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
4594 function LinkAnnotationElement(parameters) {
4595 AnnotationElement.call(this, parameters, true);
4596 }
4597
4598 Util.inherit(LinkAnnotationElement, AnnotationElement, {
4599 /**
4600 * Render the link annotation's HTML element in the empty container.
4601 *
4602 * @public
4603 * @memberof LinkAnnotationElement
4604 * @returns {HTMLSectionElement}
4605 */
4606 render: function LinkAnnotationElement_render() {
4607 this.container.className = 'linkAnnotation';
4608
4609 var link = document.createElement('a');
4610 addLinkAttributes(link, {
4611 url: this.data.url,
4612 target: (this.data.newWindow ? LinkTarget.BLANK : undefined),
4613 });
4614
4615 if (!this.data.url) {
4616 if (this.data.action) {
4617 this._bindNamedAction(link, this.data.action);
4618 } else {
4619 this._bindLink(link, (this.data.dest || null));
4620 }
4621 }
4622
4623 this.container.appendChild(link);
4624 return this.container;
4625 },
4626
4627 /**
4628 * Bind internal links to the link element.
4629 *
4630 * @private
4631 * @param {Object} link
4632 * @param {Object} destination
4633 * @memberof LinkAnnotationElement
4634 */
4635 _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
4636 var self = this;
4637
4638 link.href = this.linkService.getDestinationHash(destination);
4639 link.onclick = function() {
4640 if (destination) {
4641 self.linkService.navigateTo(destination);
4642 }
4643 return false;
4644 };
4645 if (destination) {
4646 link.className = 'internalLink';
4647 }
4648 },
4649
4650 /**
4651 * Bind named actions to the link element.
4652 *
4653 * @private
4654 * @param {Object} link
4655 * @param {Object} action
4656 * @memberof LinkAnnotationElement
4657 */
4658 _bindNamedAction:
4659 function LinkAnnotationElement_bindNamedAction(link, action) {
4660 var self = this;
4661
4662 link.href = this.linkService.getAnchorUrl('');
4663 link.onclick = function() {
4664 self.linkService.executeNamedAction(action);
4665 return false;
4666 };
4667 link.className = 'internalLink';
4668 }
4669 });
4670
4671 return LinkAnnotationElement;
4672})();
4673
4674/**
4675 * @class
4676 * @alias TextAnnotationElement
4677 */
4678var TextAnnotationElement = (function TextAnnotationElementClosure() {
4679 function TextAnnotationElement(parameters) {
4680 var isRenderable = !!(parameters.data.hasPopup ||
4681 parameters.data.title || parameters.data.contents);
4682 AnnotationElement.call(this, parameters, isRenderable);
4683 }
4684
4685 Util.inherit(TextAnnotationElement, AnnotationElement, {
4686 /**
4687 * Render the text annotation's HTML element in the empty container.
4688 *
4689 * @public
4690 * @memberof TextAnnotationElement
4691 * @returns {HTMLSectionElement}
4692 */
4693 render: function TextAnnotationElement_render() {
4694 this.container.className = 'textAnnotation';
4695
4696 var image = document.createElement('img');
4697 image.style.height = this.container.style.height;
4698 image.style.width = this.container.style.width;
4699 image.src = this.imageResourcesPath + 'annotation-' +
4700 this.data.name.toLowerCase() + '.svg';
4701 image.alt = '[{{type}} Annotation]';
4702 image.dataset.l10nId = 'text_annotation_type';
4703 image.dataset.l10nArgs = JSON.stringify({type: this.data.name});
4704
4705 if (!this.data.hasPopup) {
4706 this._createPopup(this.container, image, this.data);
4707 }
4708
4709 this.container.appendChild(image);
4710 return this.container;
4711 }
4712 });
4713
4714 return TextAnnotationElement;
4715})();
4716
4717/**
4718 * @class
4719 * @alias WidgetAnnotationElement
4720 */
4721var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
4722 function WidgetAnnotationElement(parameters) {
4723 var isRenderable = parameters.renderInteractiveForms ||
4724 (!parameters.data.hasAppearance && !!parameters.data.fieldValue);
4725 AnnotationElement.call(this, parameters, isRenderable);
4726 }
4727
4728 Util.inherit(WidgetAnnotationElement, AnnotationElement, {
4729 /**
4730 * Render the widget annotation's HTML element in the empty container.
4731 *
4732 * @public
4733 * @memberof WidgetAnnotationElement
4734 * @returns {HTMLSectionElement}
4735 */
4736 render: function WidgetAnnotationElement_render() {
4737 // Show only the container for unsupported field types.
4738 return this.container;
4739 }
4740 });
4741
4742 return WidgetAnnotationElement;
4743})();
4744
4745/**
4746 * @class
4747 * @alias TextWidgetAnnotationElement
4748 */
4749var TextWidgetAnnotationElement = (
4750 function TextWidgetAnnotationElementClosure() {
4751 var TEXT_ALIGNMENT = ['left', 'center', 'right'];
4752
4753 function TextWidgetAnnotationElement(parameters) {
4754 WidgetAnnotationElement.call(this, parameters);
4755 }
4756
4757 Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
4758 /**
4759 * Render the text widget annotation's HTML element in the empty container.
4760 *
4761 * @public
4762 * @memberof TextWidgetAnnotationElement
4763 * @returns {HTMLSectionElement}
4764 */
4765 render: function TextWidgetAnnotationElement_render() {
4766 this.container.className = 'textWidgetAnnotation';
4767
4768 var element = null;
4769 if (this.renderInteractiveForms) {
4770 // NOTE: We cannot set the values using `element.value` below, since it
4771 // prevents the AnnotationLayer rasterizer in `test/driver.js`
4772 // from parsing the elements correctly for the reference tests.
4773 if (this.data.multiLine) {
4774 element = document.createElement('textarea');
4775 element.textContent = this.data.fieldValue;
4776 } else {
4777 element = document.createElement('input');
4778 element.type = 'text';
4779 element.setAttribute('value', this.data.fieldValue);
4780 }
4781
4782 element.disabled = this.data.readOnly;
4783
4784 if (this.data.maxLen !== null) {
4785 element.maxLength = this.data.maxLen;
4786 }
4787
4788 if (this.data.comb) {
4789 var fieldWidth = this.data.rect[2] - this.data.rect[0];
4790 var combWidth = fieldWidth / this.data.maxLen;
4791
4792 element.classList.add('comb');
4793 element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
4794 }
4795 } else {
4796 element = document.createElement('div');
4797 element.textContent = this.data.fieldValue;
4798 element.style.verticalAlign = 'middle';
4799 element.style.display = 'table-cell';
4800
4801 var font = null;
4802 if (this.data.fontRefName) {
4803 font = this.page.commonObjs.getData(this.data.fontRefName);
4804 }
4805 this._setTextStyle(element, font);
4806 }
4807
4808 if (this.data.textAlignment !== null) {
4809 element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
4810 }
4811
4812 this.container.appendChild(element);
4813 return this.container;
4814 },
4815
4816 /**
4817 * Apply text styles to the text in the element.
4818 *
4819 * @private
4820 * @param {HTMLDivElement} element
4821 * @param {Object} font
4822 * @memberof TextWidgetAnnotationElement
4823 */
4824 _setTextStyle:
4825 function TextWidgetAnnotationElement_setTextStyle(element, font) {
4826 // TODO: This duplicates some of the logic in CanvasGraphics.setFont().
4827 var style = element.style;
4828 style.fontSize = this.data.fontSize + 'px';
4829 style.direction = (this.data.fontDirection < 0 ? 'rtl': 'ltr');
4830
4831 if (!font) {
4832 return;
4833 }
4834
4835 style.fontWeight = (font.black ?
4836 (font.bold ? '900' : 'bold') :
4837 (font.bold ? 'bold' : 'normal'));
4838 style.fontStyle = (font.italic ? 'italic' : 'normal');
4839
4840 // Use a reasonable default font if the font doesn't specify a fallback.
4841 var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
4842 var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
4843 style.fontFamily = fontFamily + fallbackName;
4844 }
4845 });
4846
4847 return TextWidgetAnnotationElement;
4848})();
4849
4850/**
4851 * @class
4852 * @alias PopupAnnotationElement
4853 */
4854var PopupAnnotationElement = (function PopupAnnotationElementClosure() {
4855 function PopupAnnotationElement(parameters) {
4856 var isRenderable = !!(parameters.data.title || parameters.data.contents);
4857 AnnotationElement.call(this, parameters, isRenderable);
4858 }
4859
4860 Util.inherit(PopupAnnotationElement, AnnotationElement, {
4861 /**
4862 * Render the popup annotation's HTML element in the empty container.
4863 *
4864 * @public
4865 * @memberof PopupAnnotationElement
4866 * @returns {HTMLSectionElement}
4867 */
4868 render: function PopupAnnotationElement_render() {
4869 this.container.className = 'popupAnnotation';
4870
4871 var selector = '[data-annotation-id="' + this.data.parentId + '"]';
4872 var parentElement = this.layer.querySelector(selector);
4873 if (!parentElement) {
4874 return this.container;
4875 }
4876
4877 var popup = new PopupElement({
4878 container: this.container,
4879 trigger: parentElement,
4880 color: this.data.color,
4881 title: this.data.title,
4882 contents: this.data.contents
4883 });
4884
4885 // Position the popup next to the parent annotation's container.
4886 // PDF viewers ignore a popup annotation's rectangle.
4887 var parentLeft = parseFloat(parentElement.style.left);
4888 var parentWidth = parseFloat(parentElement.style.width);
4889 CustomStyle.setProp('transformOrigin', this.container,
4890 -(parentLeft + parentWidth) + 'px -' +
4891 parentElement.style.top);
4892 this.container.style.left = (parentLeft + parentWidth) + 'px';
4893
4894 this.container.appendChild(popup.render());
4895 return this.container;
4896 }
4897 });
4898
4899 return PopupAnnotationElement;
4900})();
4901
4902/**
4903 * @class
4904 * @alias PopupElement
4905 */
4906var PopupElement = (function PopupElementClosure() {
4907 var BACKGROUND_ENLIGHT = 0.7;
4908
4909 function PopupElement(parameters) {
4910 this.container = parameters.container;
4911 this.trigger = parameters.trigger;
4912 this.color = parameters.color;
4913 this.title = parameters.title;
4914 this.contents = parameters.contents;
4915 this.hideWrapper = parameters.hideWrapper || false;
4916
4917 this.pinned = false;
4918 }
4919
4920 PopupElement.prototype = /** @lends PopupElement.prototype */ {
4921 /**
4922 * Render the popup's HTML element.
4923 *
4924 * @public
4925 * @memberof PopupElement
4926 * @returns {HTMLSectionElement}
4927 */
4928 render: function PopupElement_render() {
4929 var wrapper = document.createElement('div');
4930 wrapper.className = 'popupWrapper';
4931
4932 // For Popup annotations we hide the entire section because it contains
4933 // only the popup. However, for Text annotations without a separate Popup
4934 // annotation, we cannot hide the entire container as the image would
4935 // disappear too. In that special case, hiding the wrapper suffices.
4936 this.hideElement = (this.hideWrapper ? wrapper : this.container);
4937 this.hideElement.setAttribute('hidden', true);
4938
4939 var popup = document.createElement('div');
4940 popup.className = 'popup';
4941
4942 var color = this.color;
4943 if (color) {
4944 // Enlighten the color.
4945 var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
4946 var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
4947 var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
4948 popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
4949 }
4950
4951 var contents = this._formatContents(this.contents);
4952 var title = document.createElement('h1');
4953 title.textContent = this.title;
4954
4955 // Attach the event listeners to the trigger element.
4956 this.trigger.addEventListener('click', this._toggle.bind(this));
4957 this.trigger.addEventListener('mouseover', this._show.bind(this, false));
4958 this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
4959 popup.addEventListener('click', this._hide.bind(this, true));
4960
4961 popup.appendChild(title);
4962 popup.appendChild(contents);
4963 wrapper.appendChild(popup);
4964 return wrapper;
4965 },
4966
4967 /**
4968 * Format the contents of the popup by adding newlines where necessary.
4969 *
4970 * @private
4971 * @param {string} contents
4972 * @memberof PopupElement
4973 * @returns {HTMLParagraphElement}
4974 */
4975 _formatContents: function PopupElement_formatContents(contents) {
4976 var p = document.createElement('p');
4977 var lines = contents.split(/(?:\r\n?|\n)/);
4978 for (var i = 0, ii = lines.length; i < ii; ++i) {
4979 var line = lines[i];
4980 p.appendChild(document.createTextNode(line));
4981 if (i < (ii - 1)) {
4982 p.appendChild(document.createElement('br'));
4983 }
4984 }
4985 return p;
4986 },
4987
4988 /**
4989 * Toggle the visibility of the popup.
4990 *
4991 * @private
4992 * @memberof PopupElement
4993 */
4994 _toggle: function PopupElement_toggle() {
4995 if (this.pinned) {
4996 this._hide(true);
4997 } else {
4998 this._show(true);
4999 }
5000 },
5001
5002 /**
5003 * Show the popup.
5004 *
5005 * @private
5006 * @param {boolean} pin
5007 * @memberof PopupElement
5008 */
5009 _show: function PopupElement_show(pin) {
5010 if (pin) {
5011 this.pinned = true;
5012 }
5013 if (this.hideElement.hasAttribute('hidden')) {
5014 this.hideElement.removeAttribute('hidden');
5015 this.container.style.zIndex += 1;
5016 }
5017 },
5018
5019 /**
5020 * Hide the popup.
5021 *
5022 * @private
5023 * @param {boolean} unpin
5024 * @memberof PopupElement
5025 */
5026 _hide: function PopupElement_hide(unpin) {
5027 if (unpin) {
5028 this.pinned = false;
5029 }
5030 if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
5031 this.hideElement.setAttribute('hidden', true);
5032 this.container.style.zIndex -= 1;
5033 }
5034 }
5035 };
5036
5037 return PopupElement;
5038})();
5039
5040/**
5041 * @class
5042 * @alias HighlightAnnotationElement
5043 */
5044var HighlightAnnotationElement = (
5045 function HighlightAnnotationElementClosure() {
5046 function HighlightAnnotationElement(parameters) {
5047 var isRenderable = !!(parameters.data.hasPopup ||
5048 parameters.data.title || parameters.data.contents);
5049 AnnotationElement.call(this, parameters, isRenderable);
5050 }
5051
5052 Util.inherit(HighlightAnnotationElement, AnnotationElement, {
5053 /**
5054 * Render the highlight annotation's HTML element in the empty container.
5055 *
5056 * @public
5057 * @memberof HighlightAnnotationElement
5058 * @returns {HTMLSectionElement}
5059 */
5060 render: function HighlightAnnotationElement_render() {
5061 this.container.className = 'highlightAnnotation';
5062
5063 if (!this.data.hasPopup) {
5064 this._createPopup(this.container, null, this.data);
5065 }
5066
5067 return this.container;
5068 }
5069 });
5070
5071 return HighlightAnnotationElement;
5072})();
5073
5074/**
5075 * @class
5076 * @alias UnderlineAnnotationElement
5077 */
5078var UnderlineAnnotationElement = (
5079 function UnderlineAnnotationElementClosure() {
5080 function UnderlineAnnotationElement(parameters) {
5081 var isRenderable = !!(parameters.data.hasPopup ||
5082 parameters.data.title || parameters.data.contents);
5083 AnnotationElement.call(this, parameters, isRenderable);
5084 }
5085
5086 Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
5087 /**
5088 * Render the underline annotation's HTML element in the empty container.
5089 *
5090 * @public
5091 * @memberof UnderlineAnnotationElement
5092 * @returns {HTMLSectionElement}
5093 */
5094 render: function UnderlineAnnotationElement_render() {
5095 this.container.className = 'underlineAnnotation';
5096
5097 if (!this.data.hasPopup) {
5098 this._createPopup(this.container, null, this.data);
5099 }
5100
5101 return this.container;
5102 }
5103 });
5104
5105 return UnderlineAnnotationElement;
5106})();
5107
5108/**
5109 * @class
5110 * @alias SquigglyAnnotationElement
5111 */
5112var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() {
5113 function SquigglyAnnotationElement(parameters) {
5114 var isRenderable = !!(parameters.data.hasPopup ||
5115 parameters.data.title || parameters.data.contents);
5116 AnnotationElement.call(this, parameters, isRenderable);
5117 }
5118
5119 Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
5120 /**
5121 * Render the squiggly annotation's HTML element in the empty container.
5122 *
5123 * @public
5124 * @memberof SquigglyAnnotationElement
5125 * @returns {HTMLSectionElement}
5126 */
5127 render: function SquigglyAnnotationElement_render() {
5128 this.container.className = 'squigglyAnnotation';
5129
5130 if (!this.data.hasPopup) {
5131 this._createPopup(this.container, null, this.data);
5132 }
5133
5134 return this.container;
5135 }
5136 });
5137
5138 return SquigglyAnnotationElement;
5139})();
5140
5141/**
5142 * @class
5143 * @alias StrikeOutAnnotationElement
5144 */
5145var StrikeOutAnnotationElement = (
5146 function StrikeOutAnnotationElementClosure() {
5147 function StrikeOutAnnotationElement(parameters) {
5148 var isRenderable = !!(parameters.data.hasPopup ||
5149 parameters.data.title || parameters.data.contents);
5150 AnnotationElement.call(this, parameters, isRenderable);
5151 }
5152
5153 Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
5154 /**
5155 * Render the strikeout annotation's HTML element in the empty container.
5156 *
5157 * @public
5158 * @memberof StrikeOutAnnotationElement
5159 * @returns {HTMLSectionElement}
5160 */
5161 render: function StrikeOutAnnotationElement_render() {
5162 this.container.className = 'strikeoutAnnotation';
5163
5164 if (!this.data.hasPopup) {
5165 this._createPopup(this.container, null, this.data);
5166 }
5167
5168 return this.container;
5169 }
5170 });
5171
5172 return StrikeOutAnnotationElement;
5173})();
5174
5175/**
5176 * @class
5177 * @alias FileAttachmentAnnotationElement
5178 */
5179var FileAttachmentAnnotationElement = (
5180 function FileAttachmentAnnotationElementClosure() {
5181 function FileAttachmentAnnotationElement(parameters) {
5182 AnnotationElement.call(this, parameters, true);
5183
5184 this.filename = getFilenameFromUrl(parameters.data.file.filename);
5185 this.content = parameters.data.file.content;
5186 }
5187
5188 Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
5189 /**
5190 * Render the file attachment annotation's HTML element in the empty
5191 * container.
5192 *
5193 * @public
5194 * @memberof FileAttachmentAnnotationElement
5195 * @returns {HTMLSectionElement}
5196 */
5197 render: function FileAttachmentAnnotationElement_render() {
5198 this.container.className = 'fileAttachmentAnnotation';
5199
5200 var trigger = document.createElement('div');
5201 trigger.style.height = this.container.style.height;
5202 trigger.style.width = this.container.style.width;
5203 trigger.addEventListener('dblclick', this._download.bind(this));
5204
5205 if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
5206 this._createPopup(this.container, trigger, this.data);
5207 }
5208
5209 this.container.appendChild(trigger);
5210 return this.container;
5211 },
5212
5213 /**
5214 * Download the file attachment associated with this annotation.
5215 *
5216 * @private
5217 * @memberof FileAttachmentAnnotationElement
5218 */
5219 _download: function FileAttachmentAnnotationElement_download() {
5220 if (!this.downloadManager) {
5221 warn('Download cannot be started due to unavailable download manager');
5222 return;
5223 }
5224 this.downloadManager.downloadData(this.content, this.filename, '');
5225 }
5226 });
5227
5228 return FileAttachmentAnnotationElement;
5229})();
5230
5231/**
5232 * @typedef {Object} AnnotationLayerParameters
5233 * @property {PageViewport} viewport
5234 * @property {HTMLDivElement} div
5235 * @property {Array} annotations
5236 * @property {PDFPage} page
5237 * @property {IPDFLinkService} linkService
5238 * @property {string} imageResourcesPath
5239 * @property {boolean} renderInteractiveForms
5240 */
5241
5242/**
5243 * @class
5244 * @alias AnnotationLayer
5245 */
5246var AnnotationLayer = (function AnnotationLayerClosure() {
5247 return {
5248 /**
5249 * Render a new annotation layer with all annotation elements.
5250 *
5251 * @public
5252 * @param {AnnotationLayerParameters} parameters
5253 * @memberof AnnotationLayer
5254 */
5255 render: function AnnotationLayer_render(parameters) {
5256 var annotationElementFactory = new AnnotationElementFactory();
5257
5258 for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
5259 var data = parameters.annotations[i];
5260 if (!data) {
5261 continue;
5262 }
5263
5264 var properties = {
5265 data: data,
5266 layer: parameters.div,
5267 page: parameters.page,
5268 viewport: parameters.viewport,
5269 linkService: parameters.linkService,
5270 downloadManager: parameters.downloadManager,
5271 imageResourcesPath: parameters.imageResourcesPath ||
5272 getDefaultSetting('imageResourcesPath'),
5273 renderInteractiveForms: parameters.renderInteractiveForms || false,
5274 };
5275 var element = annotationElementFactory.create(properties);
5276 if (element.isRenderable) {
5277 parameters.div.appendChild(element.render());
5278 }
5279 }
5280 },
5281
5282 /**
5283 * Update the annotation elements on existing annotation layer.
5284 *
5285 * @public
5286 * @param {AnnotationLayerParameters} parameters
5287 * @memberof AnnotationLayer
5288 */
5289 update: function AnnotationLayer_update(parameters) {
5290 for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
5291 var data = parameters.annotations[i];
5292 var element = parameters.div.querySelector(
5293 '[data-annotation-id="' + data.id + '"]');
5294 if (element) {
5295 CustomStyle.setProp('transform', element,
5296 'matrix(' + parameters.viewport.transform.join(',') + ')');
5297 }
5298 }
5299 parameters.div.removeAttribute('hidden');
5300 }
5301 };
5302})();
5303
5304exports.AnnotationLayer = AnnotationLayer;
5305}));
5306
5307
5308(function (root, factory) {
5309 {
5310 factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil,
5311 root.pdfjsDisplayDOMUtils);
5312 }
5313}(this, function (exports, sharedUtil, displayDOMUtils) {
5314
5315var Util = sharedUtil.Util;
5316var createPromiseCapability = sharedUtil.createPromiseCapability;
5317var CustomStyle = displayDOMUtils.CustomStyle;
5318var getDefaultSetting = displayDOMUtils.getDefaultSetting;
5319
5320/**
5321 * Text layer render parameters.
5322 *
5323 * @typedef {Object} TextLayerRenderParameters
5324 * @property {TextContent} textContent - Text content to render (the object is
5325 * returned by the page's getTextContent() method).
5326 * @property {HTMLElement} container - HTML element that will contain text runs.
5327 * @property {PageViewport} viewport - The target viewport to properly
5328 * layout the text runs.
5329 * @property {Array} textDivs - (optional) HTML elements that are correspond
5330 * the text items of the textContent input. This is output and shall be
5331 * initially be set to empty array.
5332 * @property {number} timeout - (optional) Delay in milliseconds before
5333 * rendering of the text runs occurs.
5334 * @property {boolean} enhanceTextSelection - (optional) Whether to turn on the
5335 * text selection enhancement.
5336 */
5337var renderTextLayer = (function renderTextLayerClosure() {
5338 var MAX_TEXT_DIVS_TO_RENDER = 100000;
5339
5340 var NonWhitespaceRegexp = /\S/;
5341
5342 function isAllWhitespace(str) {
5343 return !NonWhitespaceRegexp.test(str);
5344 }
5345
5346 // Text layers may contain many thousand div's, and using `styleBuf` avoids
5347 // creating many intermediate strings when building their 'style' properties.
5348 var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0,
5349 'px; font-family: ', '', ';'];
5350
5351 function appendText(task, geom, styles) {
5352 // Initialize all used properties to keep the caches monomorphic.
5353 var textDiv = document.createElement('div');
5354 var textDivProperties = {
5355 style: null,
5356 angle: 0,
5357 canvasWidth: 0,
5358 isWhitespace: false,
5359 originalTransform: null,
5360 paddingBottom: 0,
5361 paddingLeft: 0,
5362 paddingRight: 0,
5363 paddingTop: 0,
5364 scale: 1,
5365 };
5366
5367 task._textDivs.push(textDiv);
5368 if (isAllWhitespace(geom.str)) {
5369 textDivProperties.isWhitespace = true;
5370 task._textDivProperties.set(textDiv, textDivProperties);
5371 return;
5372 }
5373
5374 var tx = Util.transform(task._viewport.transform, geom.transform);
5375 var angle = Math.atan2(tx[1], tx[0]);
5376 var style = styles[geom.fontName];
5377 if (style.vertical) {
5378 angle += Math.PI / 2;
5379 }
5380 var fontHeight = Math.sqrt((tx[2] * tx[2]) + (tx[3] * tx[3]));
5381 var fontAscent = fontHeight;
5382 if (style.ascent) {
5383 fontAscent = style.ascent * fontAscent;
5384 } else if (style.descent) {
5385 fontAscent = (1 + style.descent) * fontAscent;
5386 }
5387
5388 var left;
5389 var top;
5390 if (angle === 0) {
5391 left = tx[4];
5392 top = tx[5] - fontAscent;
5393 } else {
5394 left = tx[4] + (fontAscent * Math.sin(angle));
5395 top = tx[5] - (fontAscent * Math.cos(angle));
5396 }
5397 styleBuf[1] = left;
5398 styleBuf[3] = top;
5399 styleBuf[5] = fontHeight;
5400 styleBuf[7] = style.fontFamily;
5401 textDivProperties.style = styleBuf.join('');
5402 textDiv.setAttribute('style', textDivProperties.style);
5403
5404 textDiv.textContent = geom.str;
5405 // |fontName| is only used by the Font Inspector. This test will succeed
5406 // when e.g. the Font Inspector is off but the Stepper is on, but it's
5407 // not worth the effort to do a more accurate test. We only use `dataset`
5408 // here to make the font name available for the debugger.
5409 if (getDefaultSetting('pdfBug')) {
5410 textDiv.dataset.fontName = geom.fontName;
5411 }
5412 if (angle !== 0) {
5413 textDivProperties.angle = angle * (180 / Math.PI);
5414 }
5415 // We don't bother scaling single-char text divs, because it has very
5416 // little effect on text highlighting. This makes scrolling on docs with
5417 // lots of such divs a lot faster.
5418 if (geom.str.length > 1) {
5419 if (style.vertical) {
5420 textDivProperties.canvasWidth = geom.height * task._viewport.scale;
5421 } else {
5422 textDivProperties.canvasWidth = geom.width * task._viewport.scale;
5423 }
5424 }
5425 task._textDivProperties.set(textDiv, textDivProperties);
5426
5427 if (task._enhanceTextSelection) {
5428 var angleCos = 1, angleSin = 0;
5429 if (angle !== 0) {
5430 angleCos = Math.cos(angle);
5431 angleSin = Math.sin(angle);
5432 }
5433 var divWidth = (style.vertical ? geom.height : geom.width) *
5434 task._viewport.scale;
5435 var divHeight = fontHeight;
5436
5437 var m, b;
5438 if (angle !== 0) {
5439 m = [angleCos, angleSin, -angleSin, angleCos, left, top];
5440 b = Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m);
5441 } else {
5442 b = [left, top, left + divWidth, top + divHeight];
5443 }
5444
5445 task._bounds.push({
5446 left: b[0],
5447 top: b[1],
5448 right: b[2],
5449 bottom: b[3],
5450 div: textDiv,
5451 size: [divWidth, divHeight],
5452 m: m
5453 });
5454 }
5455 }
5456
5457 function render(task) {
5458 if (task._canceled) {
5459 return;
5460 }
5461 var textLayerFrag = task._container;
5462 var textDivs = task._textDivs;
5463 var capability = task._capability;
5464 var textDivsLength = textDivs.length;
5465
5466 // No point in rendering many divs as it would make the browser
5467 // unusable even after the divs are rendered.
5468 if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
5469 task._renderingDone = true;
5470 capability.resolve();
5471 return;
5472 }
5473
5474 var canvas = document.createElement('canvas');
5475 canvas.mozOpaque = true;
5476 var ctx = canvas.getContext('2d', {alpha: false});
5477
5478 var lastFontSize;
5479 var lastFontFamily;
5480 for (var i = 0; i < textDivsLength; i++) {
5481 var textDiv = textDivs[i];
5482 var textDivProperties = task._textDivProperties.get(textDiv);
5483 if (textDivProperties.isWhitespace) {
5484 continue;
5485 }
5486
5487 var fontSize = textDiv.style.fontSize;
5488 var fontFamily = textDiv.style.fontFamily;
5489
5490 // Only build font string and set to context if different from last.
5491 if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
5492 ctx.font = fontSize + ' ' + fontFamily;
5493 lastFontSize = fontSize;
5494 lastFontFamily = fontFamily;
5495 }
5496
5497 var width = ctx.measureText(textDiv.textContent).width;
5498 textLayerFrag.appendChild(textDiv);
5499
5500 var transform = '';
5501 if (textDivProperties.canvasWidth !== 0 && width > 0) {
5502 textDivProperties.scale = textDivProperties.canvasWidth / width;
5503 transform = 'scaleX(' + textDivProperties.scale + ')';
5504 }
5505 if (textDivProperties.angle !== 0) {
5506 transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
5507 }
5508 if (transform !== '') {
5509 textDivProperties.originalTransform = transform;
5510 CustomStyle.setProp('transform', textDiv, transform);
5511 }
5512 task._textDivProperties.set(textDiv, textDivProperties);
5513 }
5514 task._renderingDone = true;
5515 capability.resolve();
5516 }
5517
5518 function expand(task) {
5519 var bounds = task._bounds;
5520 var viewport = task._viewport;
5521
5522 var expanded = expandBounds(viewport.width, viewport.height, bounds);
5523 for (var i = 0; i < expanded.length; i++) {
5524 var div = bounds[i].div;
5525 var divProperties = task._textDivProperties.get(div);
5526 if (divProperties.angle === 0) {
5527 divProperties.paddingLeft = bounds[i].left - expanded[i].left;
5528 divProperties.paddingTop = bounds[i].top - expanded[i].top;
5529 divProperties.paddingRight = expanded[i].right - bounds[i].right;
5530 divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
5531 task._textDivProperties.set(div, divProperties);
5532 continue;
5533 }
5534 // Box is rotated -- trying to find padding so rotated div will not
5535 // exceed its expanded bounds.
5536 var e = expanded[i], b = bounds[i];
5537 var m = b.m, c = m[0], s = m[1];
5538 // Finding intersections with expanded box.
5539 var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
5540 var ts = new Float64Array(64);
5541 points.forEach(function (p, i) {
5542 var t = Util.applyTransform(p, m);
5543 ts[i + 0] = c && (e.left - t[0]) / c;
5544 ts[i + 4] = s && (e.top - t[1]) / s;
5545 ts[i + 8] = c && (e.right - t[0]) / c;
5546 ts[i + 12] = s && (e.bottom - t[1]) / s;
5547
5548 ts[i + 16] = s && (e.left - t[0]) / -s;
5549 ts[i + 20] = c && (e.top - t[1]) / c;
5550 ts[i + 24] = s && (e.right - t[0]) / -s;
5551 ts[i + 28] = c && (e.bottom - t[1]) / c;
5552
5553 ts[i + 32] = c && (e.left - t[0]) / -c;
5554 ts[i + 36] = s && (e.top - t[1]) / -s;
5555 ts[i + 40] = c && (e.right - t[0]) / -c;
5556 ts[i + 44] = s && (e.bottom - t[1]) / -s;
5557
5558 ts[i + 48] = s && (e.left - t[0]) / s;
5559 ts[i + 52] = c && (e.top - t[1]) / -c;
5560 ts[i + 56] = s && (e.right - t[0]) / s;
5561 ts[i + 60] = c && (e.bottom - t[1]) / -c;
5562 });
5563 var findPositiveMin = function (ts, offset, count) {
5564 var result = 0;
5565 for (var i = 0; i < count; i++) {
5566 var t = ts[offset++];
5567 if (t > 0) {
5568 result = result ? Math.min(t, result) : t;
5569 }
5570 }
5571 return result;
5572 };
5573 // Not based on math, but to simplify calculations, using cos and sin
5574 // absolute values to not exceed the box (it can but insignificantly).
5575 var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
5576 divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
5577 divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
5578 divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
5579 divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
5580 task._textDivProperties.set(div, divProperties);
5581 }
5582 }
5583
5584 function expandBounds(width, height, boxes) {
5585 var bounds = boxes.map(function (box, i) {
5586 return {
5587 x1: box.left,
5588 y1: box.top,
5589 x2: box.right,
5590 y2: box.bottom,
5591 index: i,
5592 x1New: undefined,
5593 x2New: undefined
5594 };
5595 });
5596 expandBoundsLTR(width, bounds);
5597 var expanded = new Array(boxes.length);
5598 bounds.forEach(function (b) {
5599 var i = b.index;
5600 expanded[i] = {
5601 left: b.x1New,
5602 top: 0,
5603 right: b.x2New,
5604 bottom: 0
5605 };
5606 });
5607
5608 // Rotating on 90 degrees and extending extended boxes. Reusing the bounds
5609 // array and objects.
5610 boxes.map(function (box, i) {
5611 var e = expanded[i], b = bounds[i];
5612 b.x1 = box.top;
5613 b.y1 = width - e.right;
5614 b.x2 = box.bottom;
5615 b.y2 = width - e.left;
5616 b.index = i;
5617 b.x1New = undefined;
5618 b.x2New = undefined;
5619 });
5620 expandBoundsLTR(height, bounds);
5621
5622 bounds.forEach(function (b) {
5623 var i = b.index;
5624 expanded[i].top = b.x1New;
5625 expanded[i].bottom = b.x2New;
5626 });
5627 return expanded;
5628 }
5629
5630 function expandBoundsLTR(width, bounds) {
5631 // Sorting by x1 coordinate and walk by the bounds in the same order.
5632 bounds.sort(function (a, b) { return a.x1 - b.x1 || a.index - b.index; });
5633
5634 // First we see on the horizon is a fake boundary.
5635 var fakeBoundary = {
5636 x1: -Infinity,
5637 y1: -Infinity,
5638 x2: 0,
5639 y2: Infinity,
5640 index: -1,
5641 x1New: 0,
5642 x2New: 0
5643 };
5644 var horizon = [{
5645 start: -Infinity,
5646 end: Infinity,
5647 boundary: fakeBoundary
5648 }];
5649
5650 bounds.forEach(function (boundary) {
5651 // Searching for the affected part of horizon.
5652 // TODO red-black tree or simple binary search
5653 var i = 0;
5654 while (i < horizon.length && horizon[i].end <= boundary.y1) {
5655 i++;
5656 }
5657 var j = horizon.length - 1;
5658 while(j >= 0 && horizon[j].start >= boundary.y2) {
5659 j--;
5660 }
5661
5662 var horizonPart, affectedBoundary;
5663 var q, k, maxXNew = -Infinity;
5664 for (q = i; q <= j; q++) {
5665 horizonPart = horizon[q];
5666 affectedBoundary = horizonPart.boundary;
5667 var xNew;
5668 if (affectedBoundary.x2 > boundary.x1) {
5669 // In the middle of the previous element, new x shall be at the
5670 // boundary start. Extending if further if the affected bondary
5671 // placed on top of the current one.
5672 xNew = affectedBoundary.index > boundary.index ?
5673 affectedBoundary.x1New : boundary.x1;
5674 } else if (affectedBoundary.x2New === undefined) {
5675 // We have some space in between, new x in middle will be a fair
5676 // choice.
5677 xNew = (affectedBoundary.x2 + boundary.x1) / 2;
5678 } else {
5679 // Affected boundary has x2new set, using it as new x.
5680 xNew = affectedBoundary.x2New;
5681 }
5682 if (xNew > maxXNew) {
5683 maxXNew = xNew;
5684 }
5685 }
5686
5687 // Set new x1 for current boundary.
5688 boundary.x1New = maxXNew;
5689
5690 // Adjusts new x2 for the affected boundaries.
5691 for (q = i; q <= j; q++) {
5692 horizonPart = horizon[q];
5693 affectedBoundary = horizonPart.boundary;
5694 if (affectedBoundary.x2New === undefined) {
5695 // Was not set yet, choosing new x if possible.
5696 if (affectedBoundary.x2 > boundary.x1) {
5697 // Current and affected boundaries intersect. If affected boundary
5698 // is placed on top of the current, shrinking the affected.
5699 if (affectedBoundary.index > boundary.index) {
5700 affectedBoundary.x2New = affectedBoundary.x2;
5701 }
5702 } else {
5703 affectedBoundary.x2New = maxXNew;
5704 }
5705 } else if (affectedBoundary.x2New > maxXNew) {
5706 // Affected boundary is touching new x, pushing it back.
5707 affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
5708 }
5709 }
5710
5711 // Fixing the horizon.
5712 var changedHorizon = [], lastBoundary = null;
5713 for (q = i; q <= j; q++) {
5714 horizonPart = horizon[q];
5715 affectedBoundary = horizonPart.boundary;
5716 // Checking which boundary will be visible.
5717 var useBoundary = affectedBoundary.x2 > boundary.x2 ?
5718 affectedBoundary : boundary;
5719 if (lastBoundary === useBoundary) {
5720 // Merging with previous.
5721 changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
5722 } else {
5723 changedHorizon.push({
5724 start: horizonPart.start,
5725 end: horizonPart.end,
5726 boundary: useBoundary
5727 });
5728 lastBoundary = useBoundary;
5729 }
5730 }
5731 if (horizon[i].start < boundary.y1) {
5732 changedHorizon[0].start = boundary.y1;
5733 changedHorizon.unshift({
5734 start: horizon[i].start,
5735 end: boundary.y1,
5736 boundary: horizon[i].boundary
5737 });
5738 }
5739 if (boundary.y2 < horizon[j].end) {
5740 changedHorizon[changedHorizon.length - 1].end = boundary.y2;
5741 changedHorizon.push({
5742 start: boundary.y2,
5743 end: horizon[j].end,
5744 boundary: horizon[j].boundary
5745 });
5746 }
5747
5748 // Set x2 new of boundary that is no longer visible (see overlapping case
5749 // above).
5750 // TODO more efficient, e.g. via reference counting.
5751 for (q = i; q <= j; q++) {
5752 horizonPart = horizon[q];
5753 affectedBoundary = horizonPart.boundary;
5754 if (affectedBoundary.x2New !== undefined) {
5755 continue;
5756 }
5757 var used = false;
5758 for (k = i - 1; !used && k >= 0 &&
5759 horizon[k].start >= affectedBoundary.y1; k--) {
5760 used = horizon[k].boundary === affectedBoundary;
5761 }
5762 for (k = j + 1; !used && k < horizon.length &&
5763 horizon[k].end <= affectedBoundary.y2; k++) {
5764 used = horizon[k].boundary === affectedBoundary;
5765 }
5766 for (k = 0; !used && k < changedHorizon.length; k++) {
5767 used = changedHorizon[k].boundary === affectedBoundary;
5768 }
5769 if (!used) {
5770 affectedBoundary.x2New = maxXNew;
5771 }
5772 }
5773
5774 Array.prototype.splice.apply(horizon,
5775 [i, j - i + 1].concat(changedHorizon));
5776 });
5777
5778 // Set new x2 for all unset boundaries.
5779 horizon.forEach(function (horizonPart) {
5780 var affectedBoundary = horizonPart.boundary;
5781 if (affectedBoundary.x2New === undefined) {
5782 affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
5783 }
5784 });
5785 }
5786
5787 /**
5788 * Text layer rendering task.
5789 *
5790 * @param {TextContent} textContent
5791 * @param {HTMLElement} container
5792 * @param {PageViewport} viewport
5793 * @param {Array} textDivs
5794 * @param {boolean} enhanceTextSelection
5795 * @private
5796 */
5797 function TextLayerRenderTask(textContent, container, viewport, textDivs,
5798 enhanceTextSelection) {
5799 this._textContent = textContent;
5800 this._container = container;
5801 this._viewport = viewport;
5802 this._textDivs = textDivs || [];
5803 this._textDivProperties = new WeakMap();
5804 this._renderingDone = false;
5805 this._canceled = false;
5806 this._capability = createPromiseCapability();
5807 this._renderTimer = null;
5808 this._bounds = [];
5809 this._enhanceTextSelection = !!enhanceTextSelection;
5810 }
5811 TextLayerRenderTask.prototype = {
5812 get promise() {
5813 return this._capability.promise;
5814 },
5815
5816 cancel: function TextLayer_cancel() {
5817 this._canceled = true;
5818 if (this._renderTimer !== null) {
5819 clearTimeout(this._renderTimer);
5820 this._renderTimer = null;
5821 }
5822 this._capability.reject('canceled');
5823 },
5824
5825 _render: function TextLayer_render(timeout) {
5826 var textItems = this._textContent.items;
5827 var textStyles = this._textContent.styles;
5828 for (var i = 0, len = textItems.length; i < len; i++) {
5829 appendText(this, textItems[i], textStyles);
5830 }
5831
5832 if (!timeout) { // Render right away
5833 render(this);
5834 } else { // Schedule
5835 var self = this;
5836 this._renderTimer = setTimeout(function() {
5837 render(self);
5838 self._renderTimer = null;
5839 }, timeout);
5840 }
5841 },
5842
5843 expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
5844 if (!this._enhanceTextSelection || !this._renderingDone) {
5845 return;
5846 }
5847 if (this._bounds !== null) {
5848 expand(this);
5849 this._bounds = null;
5850 }
5851
5852 for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
5853 var div = this._textDivs[i];
5854 var divProperties = this._textDivProperties.get(div);
5855
5856 if (divProperties.isWhitespace) {
5857 continue;
5858 }
5859 if (expandDivs) {
5860 var transform = '', padding = '';
5861
5862 if (divProperties.scale !== 1) {
5863 transform = 'scaleX(' + divProperties.scale + ')';
5864 }
5865 if (divProperties.angle !== 0) {
5866 transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
5867 }
5868 if (divProperties.paddingLeft !== 0) {
5869 padding += ' padding-left: ' +
5870 (divProperties.paddingLeft / divProperties.scale) + 'px;';
5871 transform += ' translateX(' +
5872 (-divProperties.paddingLeft / divProperties.scale) + 'px)';
5873 }
5874 if (divProperties.paddingTop !== 0) {
5875 padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
5876 transform += ' translateY(' + (-divProperties.paddingTop) + 'px)';
5877 }
5878 if (divProperties.paddingRight !== 0) {
5879 padding += ' padding-right: ' +
5880 (divProperties.paddingRight / divProperties.scale) + 'px;';
5881 }
5882 if (divProperties.paddingBottom !== 0) {
5883 padding += ' padding-bottom: ' +
5884 divProperties.paddingBottom + 'px;';
5885 }
5886
5887 if (padding !== '') {
5888 div.setAttribute('style', divProperties.style + padding);
5889 }
5890 if (transform !== '') {
5891 CustomStyle.setProp('transform', div, transform);
5892 }
5893 } else {
5894 div.style.padding = 0;
5895 CustomStyle.setProp('transform', div,
5896 divProperties.originalTransform || '');
5897 }
5898 }
5899 },
5900 };
5901
5902 /**
5903 * Starts rendering of the text layer.
5904 *
5905 * @param {TextLayerRenderParameters} renderParameters
5906 * @returns {TextLayerRenderTask}
5907 */
5908 function renderTextLayer(renderParameters) {
5909 var task = new TextLayerRenderTask(renderParameters.textContent,
5910 renderParameters.container,
5911 renderParameters.viewport,
5912 renderParameters.textDivs,
5913 renderParameters.enhanceTextSelection);
5914 task._render(renderParameters.timeout);
5915 return task;
5916 }
5917
5918 return renderTextLayer;
5919})();
5920
5921exports.renderTextLayer = renderTextLayer;
5922}));
5923
5924
5925(function (root, factory) {
5926 {
5927 factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil,
5928 root.pdfjsDisplayDOMUtils);
5929 }
5930}(this, function (exports, sharedUtil, displayDOMUtils) {
5931
5932var shadow = sharedUtil.shadow;
5933var getDefaultSetting = displayDOMUtils.getDefaultSetting;
5934
5935var WebGLUtils = (function WebGLUtilsClosure() {
5936 function loadShader(gl, code, shaderType) {
5937 var shader = gl.createShader(shaderType);
5938 gl.shaderSource(shader, code);
5939 gl.compileShader(shader);
5940 var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
5941 if (!compiled) {
5942 var errorMsg = gl.getShaderInfoLog(shader);
5943 throw new Error('Error during shader compilation: ' + errorMsg);
5944 }
5945 return shader;
5946 }
5947 function createVertexShader(gl, code) {
5948 return loadShader(gl, code, gl.VERTEX_SHADER);
5949 }
5950 function createFragmentShader(gl, code) {
5951 return loadShader(gl, code, gl.FRAGMENT_SHADER);
5952 }
5953 function createProgram(gl, shaders) {
5954 var program = gl.createProgram();
5955 for (var i = 0, ii = shaders.length; i < ii; ++i) {
5956 gl.attachShader(program, shaders[i]);
5957 }
5958 gl.linkProgram(program);
5959 var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
5960 if (!linked) {
5961 var errorMsg = gl.getProgramInfoLog(program);
5962 throw new Error('Error during program linking: ' + errorMsg);
5963 }
5964 return program;
5965 }
5966 function createTexture(gl, image, textureId) {
5967 gl.activeTexture(textureId);
5968 var texture = gl.createTexture();
5969 gl.bindTexture(gl.TEXTURE_2D, texture);
5970
5971 // Set the parameters so we can render any size image.
5972 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
5973 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
5974 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
5975 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
5976
5977 // Upload the image into the texture.
5978 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
5979 return texture;
5980 }
5981
5982 var currentGL, currentCanvas;
5983 function generateGL() {
5984 if (currentGL) {
5985 return;
5986 }
5987 currentCanvas = document.createElement('canvas');
5988 currentGL = currentCanvas.getContext('webgl',
5989 { premultipliedalpha: false });
5990 }
5991
5992 var smaskVertexShaderCode = '\
5993 attribute vec2 a_position; \
5994 attribute vec2 a_texCoord; \
5995 \
5996 uniform vec2 u_resolution; \
5997 \
5998 varying vec2 v_texCoord; \
5999 \
6000 void main() { \
6001 vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
6002 gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
6003 \
6004 v_texCoord = a_texCoord; \
6005 } ';
6006
6007 var smaskFragmentShaderCode = '\
6008 precision mediump float; \
6009 \
6010 uniform vec4 u_backdrop; \
6011 uniform int u_subtype; \
6012 uniform sampler2D u_image; \
6013 uniform sampler2D u_mask; \
6014 \
6015 varying vec2 v_texCoord; \
6016 \
6017 void main() { \
6018 vec4 imageColor = texture2D(u_image, v_texCoord); \
6019 vec4 maskColor = texture2D(u_mask, v_texCoord); \
6020 if (u_backdrop.a > 0.0) { \
6021 maskColor.rgb = maskColor.rgb * maskColor.a + \
6022 u_backdrop.rgb * (1.0 - maskColor.a); \
6023 } \
6024 float lum; \
6025 if (u_subtype == 0) { \
6026 lum = maskColor.a; \
6027 } else { \
6028 lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
6029 maskColor.b * 0.11; \
6030 } \
6031 imageColor.a *= lum; \
6032 imageColor.rgb *= imageColor.a; \
6033 gl_FragColor = imageColor; \
6034 } ';
6035
6036 var smaskCache = null;
6037
6038 function initSmaskGL() {
6039 var canvas, gl;
6040
6041 generateGL();
6042 canvas = currentCanvas;
6043 currentCanvas = null;
6044 gl = currentGL;
6045 currentGL = null;
6046
6047 // setup a GLSL program
6048 var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
6049 var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
6050 var program = createProgram(gl, [vertexShader, fragmentShader]);
6051 gl.useProgram(program);
6052
6053 var cache = {};
6054 cache.gl = gl;
6055 cache.canvas = canvas;
6056 cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
6057 cache.positionLocation = gl.getAttribLocation(program, 'a_position');
6058 cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
6059 cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
6060
6061 var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
6062 var texLayerLocation = gl.getUniformLocation(program, 'u_image');
6063 var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
6064
6065 // provide texture coordinates for the rectangle.
6066 var texCoordBuffer = gl.createBuffer();
6067 gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
6068 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
6069 0.0, 0.0,
6070 1.0, 0.0,
6071 0.0, 1.0,
6072 0.0, 1.0,
6073 1.0, 0.0,
6074 1.0, 1.0]), gl.STATIC_DRAW);
6075 gl.enableVertexAttribArray(texCoordLocation);
6076 gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
6077
6078 gl.uniform1i(texLayerLocation, 0);
6079 gl.uniform1i(texMaskLocation, 1);
6080
6081 smaskCache = cache;
6082 }
6083
6084 function composeSMask(layer, mask, properties) {
6085 var width = layer.width, height = layer.height;
6086
6087 if (!smaskCache) {
6088 initSmaskGL();
6089 }
6090 var cache = smaskCache,canvas = cache.canvas, gl = cache.gl;
6091 canvas.width = width;
6092 canvas.height = height;
6093 gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
6094 gl.uniform2f(cache.resolutionLocation, width, height);
6095
6096 if (properties.backdrop) {
6097 gl.uniform4f(cache.resolutionLocation, properties.backdrop[0],
6098 properties.backdrop[1], properties.backdrop[2], 1);
6099 } else {
6100 gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
6101 }
6102 gl.uniform1i(cache.subtypeLocation,
6103 properties.subtype === 'Luminosity' ? 1 : 0);
6104
6105 // Create a textures
6106 var texture = createTexture(gl, layer, gl.TEXTURE0);
6107 var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
6108
6109
6110 // Create a buffer and put a single clipspace rectangle in
6111 // it (2 triangles)
6112 var buffer = gl.createBuffer();
6113 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
6114 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
6115 0, 0,
6116 width, 0,
6117 0, height,
6118 0, height,
6119 width, 0,
6120 width, height]), gl.STATIC_DRAW);
6121 gl.enableVertexAttribArray(cache.positionLocation);
6122 gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
6123
6124 // draw
6125 gl.clearColor(0, 0, 0, 0);
6126 gl.enable(gl.BLEND);
6127 gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
6128 gl.clear(gl.COLOR_BUFFER_BIT);
6129
6130 gl.drawArrays(gl.TRIANGLES, 0, 6);
6131
6132 gl.flush();
6133
6134 gl.deleteTexture(texture);
6135 gl.deleteTexture(maskTexture);
6136 gl.deleteBuffer(buffer);
6137
6138 return canvas;
6139 }
6140
6141 var figuresVertexShaderCode = '\
6142 attribute vec2 a_position; \
6143 attribute vec3 a_color; \
6144 \
6145 uniform vec2 u_resolution; \
6146 uniform vec2 u_scale; \
6147 uniform vec2 u_offset; \
6148 \
6149 varying vec4 v_color; \
6150 \
6151 void main() { \
6152 vec2 position = (a_position + u_offset) * u_scale; \
6153 vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
6154 gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
6155 \
6156 v_color = vec4(a_color / 255.0, 1.0); \
6157 } ';
6158
6159 var figuresFragmentShaderCode = '\
6160 precision mediump float; \
6161 \
6162 varying vec4 v_color; \
6163 \
6164 void main() { \
6165 gl_FragColor = v_color; \
6166 } ';
6167
6168 var figuresCache = null;
6169
6170 function initFiguresGL() {
6171 var canvas, gl;
6172
6173 generateGL();
6174 canvas = currentCanvas;
6175 currentCanvas = null;
6176 gl = currentGL;
6177 currentGL = null;
6178
6179 // setup a GLSL program
6180 var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
6181 var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
6182 var program = createProgram(gl, [vertexShader, fragmentShader]);
6183 gl.useProgram(program);
6184
6185 var cache = {};
6186 cache.gl = gl;
6187 cache.canvas = canvas;
6188 cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
6189 cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
6190 cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
6191 cache.positionLocation = gl.getAttribLocation(program, 'a_position');
6192 cache.colorLocation = gl.getAttribLocation(program, 'a_color');
6193
6194 figuresCache = cache;
6195 }
6196
6197 function drawFigures(width, height, backgroundColor, figures, context) {
6198 if (!figuresCache) {
6199 initFiguresGL();
6200 }
6201 var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
6202
6203 canvas.width = width;
6204 canvas.height = height;
6205 gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
6206 gl.uniform2f(cache.resolutionLocation, width, height);
6207
6208 // count triangle points
6209 var count = 0;
6210 var i, ii, rows;
6211 for (i = 0, ii = figures.length; i < ii; i++) {
6212 switch (figures[i].type) {
6213 case 'lattice':
6214 rows = (figures[i].coords.length / figures[i].verticesPerRow) | 0;
6215 count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
6216 break;
6217 case 'triangles':
6218 count += figures[i].coords.length;
6219 break;
6220 }
6221 }
6222 // transfer data
6223 var coords = new Float32Array(count * 2);
6224 var colors = new Uint8Array(count * 3);
6225 var coordsMap = context.coords, colorsMap = context.colors;
6226 var pIndex = 0, cIndex = 0;
6227 for (i = 0, ii = figures.length; i < ii; i++) {
6228 var figure = figures[i], ps = figure.coords, cs = figure.colors;
6229 switch (figure.type) {
6230 case 'lattice':
6231 var cols = figure.verticesPerRow;
6232 rows = (ps.length / cols) | 0;
6233 for (var row = 1; row < rows; row++) {
6234 var offset = row * cols + 1;
6235 for (var col = 1; col < cols; col++, offset++) {
6236 coords[pIndex] = coordsMap[ps[offset - cols - 1]];
6237 coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
6238 coords[pIndex + 2] = coordsMap[ps[offset - cols]];
6239 coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
6240 coords[pIndex + 4] = coordsMap[ps[offset - 1]];
6241 coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
6242 colors[cIndex] = colorsMap[cs[offset - cols - 1]];
6243 colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
6244 colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
6245 colors[cIndex + 3] = colorsMap[cs[offset - cols]];
6246 colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
6247 colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
6248 colors[cIndex + 6] = colorsMap[cs[offset - 1]];
6249 colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
6250 colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
6251
6252 coords[pIndex + 6] = coords[pIndex + 2];
6253 coords[pIndex + 7] = coords[pIndex + 3];
6254 coords[pIndex + 8] = coords[pIndex + 4];
6255 coords[pIndex + 9] = coords[pIndex + 5];
6256 coords[pIndex + 10] = coordsMap[ps[offset]];
6257 coords[pIndex + 11] = coordsMap[ps[offset] + 1];
6258 colors[cIndex + 9] = colors[cIndex + 3];
6259 colors[cIndex + 10] = colors[cIndex + 4];
6260 colors[cIndex + 11] = colors[cIndex + 5];
6261 colors[cIndex + 12] = colors[cIndex + 6];
6262 colors[cIndex + 13] = colors[cIndex + 7];
6263 colors[cIndex + 14] = colors[cIndex + 8];
6264 colors[cIndex + 15] = colorsMap[cs[offset]];
6265 colors[cIndex + 16] = colorsMap[cs[offset] + 1];
6266 colors[cIndex + 17] = colorsMap[cs[offset] + 2];
6267 pIndex += 12;
6268 cIndex += 18;
6269 }
6270 }
6271 break;
6272 case 'triangles':
6273 for (var j = 0, jj = ps.length; j < jj; j++) {
6274 coords[pIndex] = coordsMap[ps[j]];
6275 coords[pIndex + 1] = coordsMap[ps[j] + 1];
6276 colors[cIndex] = colorsMap[cs[j]];
6277 colors[cIndex + 1] = colorsMap[cs[j] + 1];
6278 colors[cIndex + 2] = colorsMap[cs[j] + 2];
6279 pIndex += 2;
6280 cIndex += 3;
6281 }
6282 break;
6283 }
6284 }
6285
6286 // draw
6287 if (backgroundColor) {
6288 gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255,
6289 backgroundColor[2] / 255, 1.0);
6290 } else {
6291 gl.clearColor(0, 0, 0, 0);
6292 }
6293 gl.clear(gl.COLOR_BUFFER_BIT);
6294
6295 var coordsBuffer = gl.createBuffer();
6296 gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
6297 gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
6298 gl.enableVertexAttribArray(cache.positionLocation);
6299 gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
6300
6301 var colorsBuffer = gl.createBuffer();
6302 gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
6303 gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
6304 gl.enableVertexAttribArray(cache.colorLocation);
6305 gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false,
6306 0, 0);
6307
6308 gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
6309 gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
6310
6311 gl.drawArrays(gl.TRIANGLES, 0, count);
6312
6313 gl.flush();
6314
6315 gl.deleteBuffer(coordsBuffer);
6316 gl.deleteBuffer(colorsBuffer);
6317
6318 return canvas;
6319 }
6320
6321 function cleanup() {
6322 if (smaskCache && smaskCache.canvas) {
6323 smaskCache.canvas.width = 0;
6324 smaskCache.canvas.height = 0;
6325 }
6326 if (figuresCache && figuresCache.canvas) {
6327 figuresCache.canvas.width = 0;
6328 figuresCache.canvas.height = 0;
6329 }
6330 smaskCache = null;
6331 figuresCache = null;
6332 }
6333
6334 return {
6335 get isEnabled() {
6336 if (getDefaultSetting('disableWebGL')) {
6337 return false;
6338 }
6339 var enabled = false;
6340 try {
6341 generateGL();
6342 enabled = !!currentGL;
6343 } catch (e) { }
6344 return shadow(this, 'isEnabled', enabled);
6345 },
6346 composeSMask: composeSMask,
6347 drawFigures: drawFigures,
6348 clear: cleanup
6349 };
6350})();
6351
6352exports.WebGLUtils = WebGLUtils;
6353}));
6354
6355
6356(function (root, factory) {
6357 {
6358 factory((root.pdfjsDisplayPatternHelper = {}), root.pdfjsSharedUtil,
6359 root.pdfjsDisplayWebGL);
6360 }
6361}(this, function (exports, sharedUtil, displayWebGL) {
6362
6363var Util = sharedUtil.Util;
6364var info = sharedUtil.info;
6365var isArray = sharedUtil.isArray;
6366var error = sharedUtil.error;
6367var WebGLUtils = displayWebGL.WebGLUtils;
6368
6369var ShadingIRs = {};
6370
6371ShadingIRs.RadialAxial = {
6372 fromIR: function RadialAxial_fromIR(raw) {
6373 var type = raw[1];
6374 var colorStops = raw[2];
6375 var p0 = raw[3];
6376 var p1 = raw[4];
6377 var r0 = raw[5];
6378 var r1 = raw[6];
6379 return {
6380 type: 'Pattern',
6381 getPattern: function RadialAxial_getPattern(ctx) {
6382 var grad;
6383 if (type === 'axial') {
6384 grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
6385 } else if (type === 'radial') {
6386 grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
6387 }
6388
6389 for (var i = 0, ii = colorStops.length; i < ii; ++i) {
6390 var c = colorStops[i];
6391 grad.addColorStop(c[0], c[1]);
6392 }
6393 return grad;
6394 }
6395 };
6396 }
6397};
6398
6399var createMeshCanvas = (function createMeshCanvasClosure() {
6400 function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
6401 // Very basic Gouraud-shaded triangle rasterization algorithm.
6402 var coords = context.coords, colors = context.colors;
6403 var bytes = data.data, rowSize = data.width * 4;
6404 var tmp;
6405 if (coords[p1 + 1] > coords[p2 + 1]) {
6406 tmp = p1; p1 = p2; p2 = tmp; tmp = c1; c1 = c2; c2 = tmp;
6407 }
6408 if (coords[p2 + 1] > coords[p3 + 1]) {
6409 tmp = p2; p2 = p3; p3 = tmp; tmp = c2; c2 = c3; c3 = tmp;
6410 }
6411 if (coords[p1 + 1] > coords[p2 + 1]) {
6412 tmp = p1; p1 = p2; p2 = tmp; tmp = c1; c1 = c2; c2 = tmp;
6413 }
6414 var x1 = (coords[p1] + context.offsetX) * context.scaleX;
6415 var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
6416 var x2 = (coords[p2] + context.offsetX) * context.scaleX;
6417 var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
6418 var x3 = (coords[p3] + context.offsetX) * context.scaleX;
6419 var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
6420 if (y1 >= y3) {
6421 return;
6422 }
6423 var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
6424 var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
6425 var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
6426
6427 var minY = Math.round(y1), maxY = Math.round(y3);
6428 var xa, car, cag, cab;
6429 var xb, cbr, cbg, cbb;
6430 var k;
6431 for (var y = minY; y <= maxY; y++) {
6432 if (y < y2) {
6433 k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
6434 xa = x1 - (x1 - x2) * k;
6435 car = c1r - (c1r - c2r) * k;
6436 cag = c1g - (c1g - c2g) * k;
6437 cab = c1b - (c1b - c2b) * k;
6438 } else {
6439 k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
6440 xa = x2 - (x2 - x3) * k;
6441 car = c2r - (c2r - c3r) * k;
6442 cag = c2g - (c2g - c3g) * k;
6443 cab = c2b - (c2b - c3b) * k;
6444 }
6445 k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
6446 xb = x1 - (x1 - x3) * k;
6447 cbr = c1r - (c1r - c3r) * k;
6448 cbg = c1g - (c1g - c3g) * k;
6449 cbb = c1b - (c1b - c3b) * k;
6450 var x1_ = Math.round(Math.min(xa, xb));
6451 var x2_ = Math.round(Math.max(xa, xb));
6452 var j = rowSize * y + x1_ * 4;
6453 for (var x = x1_; x <= x2_; x++) {
6454 k = (xa - x) / (xa - xb);
6455 k = k < 0 ? 0 : k > 1 ? 1 : k;
6456 bytes[j++] = (car - (car - cbr) * k) | 0;
6457 bytes[j++] = (cag - (cag - cbg) * k) | 0;
6458 bytes[j++] = (cab - (cab - cbb) * k) | 0;
6459 bytes[j++] = 255;
6460 }
6461 }
6462 }
6463
6464 function drawFigure(data, figure, context) {
6465 var ps = figure.coords;
6466 var cs = figure.colors;
6467 var i, ii;
6468 switch (figure.type) {
6469 case 'lattice':
6470 var verticesPerRow = figure.verticesPerRow;
6471 var rows = Math.floor(ps.length / verticesPerRow) - 1;
6472 var cols = verticesPerRow - 1;
6473 for (i = 0; i < rows; i++) {
6474 var q = i * verticesPerRow;
6475 for (var j = 0; j < cols; j++, q++) {
6476 drawTriangle(data, context,
6477 ps[q], ps[q + 1], ps[q + verticesPerRow],
6478 cs[q], cs[q + 1], cs[q + verticesPerRow]);
6479 drawTriangle(data, context,
6480 ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow],
6481 cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
6482 }
6483 }
6484 break;
6485 case 'triangles':
6486 for (i = 0, ii = ps.length; i < ii; i += 3) {
6487 drawTriangle(data, context,
6488 ps[i], ps[i + 1], ps[i + 2],
6489 cs[i], cs[i + 1], cs[i + 2]);
6490 }
6491 break;
6492 default:
6493 error('illigal figure');
6494 break;
6495 }
6496 }
6497
6498 function createMeshCanvas(bounds, combinesScale, coords, colors, figures,
6499 backgroundColor, cachedCanvases) {
6500 // we will increase scale on some weird factor to let antialiasing take
6501 // care of "rough" edges
6502 var EXPECTED_SCALE = 1.1;
6503 // MAX_PATTERN_SIZE is used to avoid OOM situation.
6504 var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough
6505 // We need to keep transparent border around our pattern for fill():
6506 // createPattern with 'no-repeat' will bleed edges across entire area.
6507 var BORDER_SIZE = 2;
6508
6509 var offsetX = Math.floor(bounds[0]);
6510 var offsetY = Math.floor(bounds[1]);
6511 var boundsWidth = Math.ceil(bounds[2]) - offsetX;
6512 var boundsHeight = Math.ceil(bounds[3]) - offsetY;
6513
6514 var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] *
6515 EXPECTED_SCALE)), MAX_PATTERN_SIZE);
6516 var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] *
6517 EXPECTED_SCALE)), MAX_PATTERN_SIZE);
6518 var scaleX = boundsWidth / width;
6519 var scaleY = boundsHeight / height;
6520
6521 var context = {
6522 coords: coords,
6523 colors: colors,
6524 offsetX: -offsetX,
6525 offsetY: -offsetY,
6526 scaleX: 1 / scaleX,
6527 scaleY: 1 / scaleY
6528 };
6529
6530 var paddedWidth = width + BORDER_SIZE * 2;
6531 var paddedHeight = height + BORDER_SIZE * 2;
6532
6533 var canvas, tmpCanvas, i, ii;
6534 if (WebGLUtils.isEnabled) {
6535 canvas = WebGLUtils.drawFigures(width, height, backgroundColor,
6536 figures, context);
6537
6538 // https://bugzilla.mozilla.org/show_bug.cgi?id=972126
6539 tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight,
6540 false);
6541 tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
6542 canvas = tmpCanvas.canvas;
6543 } else {
6544 tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight,
6545 false);
6546 var tmpCtx = tmpCanvas.context;
6547
6548 var data = tmpCtx.createImageData(width, height);
6549 if (backgroundColor) {
6550 var bytes = data.data;
6551 for (i = 0, ii = bytes.length; i < ii; i += 4) {
6552 bytes[i] = backgroundColor[0];
6553 bytes[i + 1] = backgroundColor[1];
6554 bytes[i + 2] = backgroundColor[2];
6555 bytes[i + 3] = 255;
6556 }
6557 }
6558 for (i = 0; i < figures.length; i++) {
6559 drawFigure(data, figures[i], context);
6560 }
6561 tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
6562 canvas = tmpCanvas.canvas;
6563 }
6564
6565 return {canvas: canvas,
6566 offsetX: offsetX - BORDER_SIZE * scaleX,
6567 offsetY: offsetY - BORDER_SIZE * scaleY,
6568 scaleX: scaleX, scaleY: scaleY};
6569 }
6570 return createMeshCanvas;
6571})();
6572
6573ShadingIRs.Mesh = {
6574 fromIR: function Mesh_fromIR(raw) {
6575 //var type = raw[1];
6576 var coords = raw[2];
6577 var colors = raw[3];
6578 var figures = raw[4];
6579 var bounds = raw[5];
6580 var matrix = raw[6];
6581 //var bbox = raw[7];
6582 var background = raw[8];
6583 return {
6584 type: 'Pattern',
6585 getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
6586 var scale;
6587 if (shadingFill) {
6588 scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
6589 } else {
6590 // Obtain scale from matrix and current transformation matrix.
6591 scale = Util.singularValueDecompose2dScale(owner.baseTransform);
6592 if (matrix) {
6593 var matrixScale = Util.singularValueDecompose2dScale(matrix);
6594 scale = [scale[0] * matrixScale[0],
6595 scale[1] * matrixScale[1]];
6596 }
6597 }
6598
6599
6600 // Rasterizing on the main thread since sending/queue large canvases
6601 // might cause OOM.
6602 var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords,
6603 colors, figures, shadingFill ? null : background,
6604 owner.cachedCanvases);
6605
6606 if (!shadingFill) {
6607 ctx.setTransform.apply(ctx, owner.baseTransform);
6608 if (matrix) {
6609 ctx.transform.apply(ctx, matrix);
6610 }
6611 }
6612
6613 ctx.translate(temporaryPatternCanvas.offsetX,
6614 temporaryPatternCanvas.offsetY);
6615 ctx.scale(temporaryPatternCanvas.scaleX,
6616 temporaryPatternCanvas.scaleY);
6617
6618 return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
6619 }
6620 };
6621 }
6622};
6623
6624ShadingIRs.Dummy = {
6625 fromIR: function Dummy_fromIR() {
6626 return {
6627 type: 'Pattern',
6628 getPattern: function Dummy_fromIR_getPattern() {
6629 return 'hotpink';
6630 }
6631 };
6632 }
6633};
6634
6635function getShadingPatternFromIR(raw) {
6636 var shadingIR = ShadingIRs[raw[0]];
6637 if (!shadingIR) {
6638 error('Unknown IR type: ' + raw[0]);
6639 }
6640 return shadingIR.fromIR(raw);
6641}
6642
6643var TilingPattern = (function TilingPatternClosure() {
6644 var PaintType = {
6645 COLORED: 1,
6646 UNCOLORED: 2
6647 };
6648
6649 var MAX_PATTERN_SIZE = 3000; // 10in @ 300dpi shall be enough
6650
6651 function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
6652 this.operatorList = IR[2];
6653 this.matrix = IR[3] || [1, 0, 0, 1, 0, 0];
6654 this.bbox = IR[4];
6655 this.xstep = IR[5];
6656 this.ystep = IR[6];
6657 this.paintType = IR[7];
6658 this.tilingType = IR[8];
6659 this.color = color;
6660 this.canvasGraphicsFactory = canvasGraphicsFactory;
6661 this.baseTransform = baseTransform;
6662 this.type = 'Pattern';
6663 this.ctx = ctx;
6664 }
6665
6666 TilingPattern.prototype = {
6667 createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
6668 var operatorList = this.operatorList;
6669 var bbox = this.bbox;
6670 var xstep = this.xstep;
6671 var ystep = this.ystep;
6672 var paintType = this.paintType;
6673 var tilingType = this.tilingType;
6674 var color = this.color;
6675 var canvasGraphicsFactory = this.canvasGraphicsFactory;
6676
6677 info('TilingType: ' + tilingType);
6678
6679 var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
6680
6681 var topLeft = [x0, y0];
6682 // we want the canvas to be as large as the step size
6683 var botRight = [x0 + xstep, y0 + ystep];
6684
6685 var width = botRight[0] - topLeft[0];
6686 var height = botRight[1] - topLeft[1];
6687
6688 // Obtain scale from matrix and current transformation matrix.
6689 var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
6690 var curMatrixScale = Util.singularValueDecompose2dScale(
6691 this.baseTransform);
6692 var combinedScale = [matrixScale[0] * curMatrixScale[0],
6693 matrixScale[1] * curMatrixScale[1]];
6694
6695 // MAX_PATTERN_SIZE is used to avoid OOM situation.
6696 // Use width and height values that are as close as possible to the end
6697 // result when the pattern is used. Too low value makes the pattern look
6698 // blurry. Too large value makes it look too crispy.
6699 width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])),
6700 MAX_PATTERN_SIZE);
6701
6702 height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])),
6703 MAX_PATTERN_SIZE);
6704
6705 var tmpCanvas = owner.cachedCanvases.getCanvas('pattern',
6706 width, height, true);
6707 var tmpCtx = tmpCanvas.context;
6708 var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
6709 graphics.groupLevel = owner.groupLevel;
6710
6711 this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
6712
6713 this.setScale(width, height, xstep, ystep);
6714 this.transformToScale(graphics);
6715
6716 // transform coordinates to pattern space
6717 var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]];
6718 graphics.transform.apply(graphics, tmpTranslate);
6719
6720 this.clipBbox(graphics, bbox, x0, y0, x1, y1);
6721
6722 graphics.executeOperatorList(operatorList);
6723 return tmpCanvas.canvas;
6724 },
6725
6726 setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
6727 this.scale = [width / xstep, height / ystep];
6728 },
6729
6730 transformToScale: function TilingPattern_transformToScale(graphics) {
6731 var scale = this.scale;
6732 var tmpScale = [scale[0], 0, 0, scale[1], 0, 0];
6733 graphics.transform.apply(graphics, tmpScale);
6734 },
6735
6736 scaleToContext: function TilingPattern_scaleToContext() {
6737 var scale = this.scale;
6738 this.ctx.scale(1 / scale[0], 1 / scale[1]);
6739 },
6740
6741 clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
6742 if (bbox && isArray(bbox) && bbox.length === 4) {
6743 var bboxWidth = x1 - x0;
6744 var bboxHeight = y1 - y0;
6745 graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
6746 graphics.clip();
6747 graphics.endPath();
6748 }
6749 },
6750
6751 setFillAndStrokeStyleToContext:
6752 function setFillAndStrokeStyleToContext(context, paintType, color) {
6753 switch (paintType) {
6754 case PaintType.COLORED:
6755 var ctx = this.ctx;
6756 context.fillStyle = ctx.fillStyle;
6757 context.strokeStyle = ctx.strokeStyle;
6758 break;
6759 case PaintType.UNCOLORED:
6760 var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
6761 context.fillStyle = cssColor;
6762 context.strokeStyle = cssColor;
6763 break;
6764 default:
6765 error('Unsupported paint type: ' + paintType);
6766 }
6767 },
6768
6769 getPattern: function TilingPattern_getPattern(ctx, owner) {
6770 var temporaryPatternCanvas = this.createPatternCanvas(owner);
6771
6772 ctx = this.ctx;
6773 ctx.setTransform.apply(ctx, this.baseTransform);
6774 ctx.transform.apply(ctx, this.matrix);
6775 this.scaleToContext();
6776
6777 return ctx.createPattern(temporaryPatternCanvas, 'repeat');
6778 }
6779 };
6780
6781 return TilingPattern;
6782})();
6783
6784exports.getShadingPatternFromIR = getShadingPatternFromIR;
6785exports.TilingPattern = TilingPattern;
6786}));
6787
6788
6789(function (root, factory) {
6790 {
6791 factory((root.pdfjsDisplayCanvas = {}), root.pdfjsSharedUtil,
6792 root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper,
6793 root.pdfjsDisplayWebGL);
6794 }
6795}(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper,
6796 displayWebGL) {
6797
6798var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
6799var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
6800var ImageKind = sharedUtil.ImageKind;
6801var OPS = sharedUtil.OPS;
6802var TextRenderingMode = sharedUtil.TextRenderingMode;
6803var Uint32ArrayView = sharedUtil.Uint32ArrayView;
6804var Util = sharedUtil.Util;
6805var assert = sharedUtil.assert;
6806var info = sharedUtil.info;
6807var isNum = sharedUtil.isNum;
6808var isArray = sharedUtil.isArray;
6809var isLittleEndian = sharedUtil.isLittleEndian;
6810var error = sharedUtil.error;
6811var shadow = sharedUtil.shadow;
6812var warn = sharedUtil.warn;
6813var TilingPattern = displayPatternHelper.TilingPattern;
6814var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
6815var WebGLUtils = displayWebGL.WebGLUtils;
6816var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
6817
6818// <canvas> contexts store most of the state we need natively.
6819// However, PDF needs a bit more state, which we store here.
6820
6821// Minimal font size that would be used during canvas fillText operations.
6822var MIN_FONT_SIZE = 16;
6823// Maximum font size that would be used during canvas fillText operations.
6824var MAX_FONT_SIZE = 100;
6825var MAX_GROUP_SIZE = 4096;
6826
6827// Heuristic value used when enforcing minimum line widths.
6828var MIN_WIDTH_FACTOR = 0.65;
6829
6830var COMPILE_TYPE3_GLYPHS = true;
6831var MAX_SIZE_TO_COMPILE = 1000;
6832
6833var FULL_CHUNK_HEIGHT = 16;
6834
6835var HasCanvasTypedArraysCached = {
6836 get value() {
6837 return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
6838 }
6839};
6840
6841var IsLittleEndianCached = {
6842 get value() {
6843 return shadow(IsLittleEndianCached, 'value', isLittleEndian());
6844 }
6845};
6846
6847function createScratchCanvas(width, height) {
6848 var canvas = document.createElement('canvas');
6849 canvas.width = width;
6850 canvas.height = height;
6851 return canvas;
6852}
6853
6854function addContextCurrentTransform(ctx) {
6855 // If the context doesn't expose a `mozCurrentTransform`, add a JS based one.
6856 if (!ctx.mozCurrentTransform) {
6857 ctx._originalSave = ctx.save;
6858 ctx._originalRestore = ctx.restore;
6859 ctx._originalRotate = ctx.rotate;
6860 ctx._originalScale = ctx.scale;
6861 ctx._originalTranslate = ctx.translate;
6862 ctx._originalTransform = ctx.transform;
6863 ctx._originalSetTransform = ctx.setTransform;
6864
6865 ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
6866 ctx._transformStack = [];
6867
6868 Object.defineProperty(ctx, 'mozCurrentTransform', {
6869 get: function getCurrentTransform() {
6870 return this._transformMatrix;
6871 }
6872 });
6873
6874 Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
6875 get: function getCurrentTransformInverse() {
6876 // Calculation done using WolframAlpha:
6877 // http://www.wolframalpha.com/input/?
6878 // i=Inverse+{{a%2C+c%2C+e}%2C+{b%2C+d%2C+f}%2C+{0%2C+0%2C+1}}
6879
6880 var m = this._transformMatrix;
6881 var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
6882
6883 var ad_bc = a * d - b * c;
6884 var bc_ad = b * c - a * d;
6885
6886 return [
6887 d / ad_bc,
6888 b / bc_ad,
6889 c / bc_ad,
6890 a / ad_bc,
6891 (d * e - c * f) / bc_ad,
6892 (b * e - a * f) / ad_bc
6893 ];
6894 }
6895 });
6896
6897 ctx.save = function ctxSave() {
6898 var old = this._transformMatrix;
6899 this._transformStack.push(old);
6900 this._transformMatrix = old.slice(0, 6);
6901
6902 this._originalSave();
6903 };
6904
6905 ctx.restore = function ctxRestore() {
6906 var prev = this._transformStack.pop();
6907 if (prev) {
6908 this._transformMatrix = prev;
6909 this._originalRestore();
6910 }
6911 };
6912
6913 ctx.translate = function ctxTranslate(x, y) {
6914 var m = this._transformMatrix;
6915 m[4] = m[0] * x + m[2] * y + m[4];
6916 m[5] = m[1] * x + m[3] * y + m[5];
6917
6918 this._originalTranslate(x, y);
6919 };
6920
6921 ctx.scale = function ctxScale(x, y) {
6922 var m = this._transformMatrix;
6923 m[0] = m[0] * x;
6924 m[1] = m[1] * x;
6925 m[2] = m[2] * y;
6926 m[3] = m[3] * y;
6927
6928 this._originalScale(x, y);
6929 };
6930
6931 ctx.transform = function ctxTransform(a, b, c, d, e, f) {
6932 var m = this._transformMatrix;
6933 this._transformMatrix = [
6934 m[0] * a + m[2] * b,
6935 m[1] * a + m[3] * b,
6936 m[0] * c + m[2] * d,
6937 m[1] * c + m[3] * d,
6938 m[0] * e + m[2] * f + m[4],
6939 m[1] * e + m[3] * f + m[5]
6940 ];
6941
6942 ctx._originalTransform(a, b, c, d, e, f);
6943 };
6944
6945 ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
6946 this._transformMatrix = [a, b, c, d, e, f];
6947
6948 ctx._originalSetTransform(a, b, c, d, e, f);
6949 };
6950
6951 ctx.rotate = function ctxRotate(angle) {
6952 var cosValue = Math.cos(angle);
6953 var sinValue = Math.sin(angle);
6954
6955 var m = this._transformMatrix;
6956 this._transformMatrix = [
6957 m[0] * cosValue + m[2] * sinValue,
6958 m[1] * cosValue + m[3] * sinValue,
6959 m[0] * (-sinValue) + m[2] * cosValue,
6960 m[1] * (-sinValue) + m[3] * cosValue,
6961 m[4],
6962 m[5]
6963 ];
6964
6965 this._originalRotate(angle);
6966 };
6967 }
6968}
6969
6970var CachedCanvases = (function CachedCanvasesClosure() {
6971 function CachedCanvases() {
6972 this.cache = Object.create(null);
6973 }
6974 CachedCanvases.prototype = {
6975 getCanvas: function CachedCanvases_getCanvas(id, width, height,
6976 trackTransform) {
6977 var canvasEntry;
6978 if (this.cache[id] !== undefined) {
6979 canvasEntry = this.cache[id];
6980 canvasEntry.canvas.width = width;
6981 canvasEntry.canvas.height = height;
6982 // reset canvas transform for emulated mozCurrentTransform, if needed
6983 canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
6984 } else {
6985 var canvas = createScratchCanvas(width, height);
6986 var ctx = canvas.getContext('2d');
6987 if (trackTransform) {
6988 addContextCurrentTransform(ctx);
6989 }
6990 this.cache[id] = canvasEntry = {canvas: canvas, context: ctx};
6991 }
6992 return canvasEntry;
6993 },
6994 clear: function () {
6995 for (var id in this.cache) {
6996 var canvasEntry = this.cache[id];
6997 // Zeroing the width and height causes Firefox to release graphics
6998 // resources immediately, which can greatly reduce memory consumption.
6999 canvasEntry.canvas.width = 0;
7000 canvasEntry.canvas.height = 0;
7001 delete this.cache[id];
7002 }
7003 }
7004 };
7005 return CachedCanvases;
7006})();
7007
7008function compileType3Glyph(imgData) {
7009 var POINT_TO_PROCESS_LIMIT = 1000;
7010
7011 var width = imgData.width, height = imgData.height;
7012 var i, j, j0, width1 = width + 1;
7013 var points = new Uint8Array(width1 * (height + 1));
7014 var POINT_TYPES =
7015 new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
7016
7017 // decodes bit-packed mask data
7018 var lineSize = (width + 7) & ~7, data0 = imgData.data;
7019 var data = new Uint8Array(lineSize * height), pos = 0, ii;
7020 for (i = 0, ii = data0.length; i < ii; i++) {
7021 var mask = 128, elem = data0[i];
7022 while (mask > 0) {
7023 data[pos++] = (elem & mask) ? 0 : 255;
7024 mask >>= 1;
7025 }
7026 }
7027
7028 // finding iteresting points: every point is located between mask pixels,
7029 // so there will be points of the (width + 1)x(height + 1) grid. Every point
7030 // will have flags assigned based on neighboring mask pixels:
7031 // 4 | 8
7032 // --P--
7033 // 2 | 1
7034 // We are interested only in points with the flags:
7035 // - outside corners: 1, 2, 4, 8;
7036 // - inside corners: 7, 11, 13, 14;
7037 // - and, intersections: 5, 10.
7038 var count = 0;
7039 pos = 0;
7040 if (data[pos] !== 0) {
7041 points[0] = 1;
7042 ++count;
7043 }
7044 for (j = 1; j < width; j++) {
7045 if (data[pos] !== data[pos + 1]) {
7046 points[j] = data[pos] ? 2 : 1;
7047 ++count;
7048 }
7049 pos++;
7050 }
7051 if (data[pos] !== 0) {
7052 points[j] = 2;
7053 ++count;
7054 }
7055 for (i = 1; i < height; i++) {
7056 pos = i * lineSize;
7057 j0 = i * width1;
7058 if (data[pos - lineSize] !== data[pos]) {
7059 points[j0] = data[pos] ? 1 : 8;
7060 ++count;
7061 }
7062 // 'sum' is the position of the current pixel configuration in the 'TYPES'
7063 // array (in order 8-1-2-4, so we can use '>>2' to shift the column).
7064 var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
7065 for (j = 1; j < width; j++) {
7066 sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) +
7067 (data[pos - lineSize + 1] ? 8 : 0);
7068 if (POINT_TYPES[sum]) {
7069 points[j0 + j] = POINT_TYPES[sum];
7070 ++count;
7071 }
7072 pos++;
7073 }
7074 if (data[pos - lineSize] !== data[pos]) {
7075 points[j0 + j] = data[pos] ? 2 : 4;
7076 ++count;
7077 }
7078
7079 if (count > POINT_TO_PROCESS_LIMIT) {
7080 return null;
7081 }
7082 }
7083
7084 pos = lineSize * (height - 1);
7085 j0 = i * width1;
7086 if (data[pos] !== 0) {
7087 points[j0] = 8;
7088 ++count;
7089 }
7090 for (j = 1; j < width; j++) {
7091 if (data[pos] !== data[pos + 1]) {
7092 points[j0 + j] = data[pos] ? 4 : 8;
7093 ++count;
7094 }
7095 pos++;
7096 }
7097 if (data[pos] !== 0) {
7098 points[j0 + j] = 4;
7099 ++count;
7100 }
7101 if (count > POINT_TO_PROCESS_LIMIT) {
7102 return null;
7103 }
7104
7105 // building outlines
7106 var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
7107 var outlines = [];
7108 for (i = 0; count && i <= height; i++) {
7109 var p = i * width1;
7110 var end = p + width;
7111 while (p < end && !points[p]) {
7112 p++;
7113 }
7114 if (p === end) {
7115 continue;
7116 }
7117 var coords = [p % width1, i];
7118
7119 var type = points[p], p0 = p, pp;
7120 do {
7121 var step = steps[type];
7122 do {
7123 p += step;
7124 } while (!points[p]);
7125
7126 pp = points[p];
7127 if (pp !== 5 && pp !== 10) {
7128 // set new direction
7129 type = pp;
7130 // delete mark
7131 points[p] = 0;
7132 } else { // type is 5 or 10, ie, a crossing
7133 // set new direction
7134 type = pp & ((0x33 * type) >> 4);
7135 // set new type for "future hit"
7136 points[p] &= (type >> 2 | type << 2);
7137 }
7138
7139 coords.push(p % width1);
7140 coords.push((p / width1) | 0);
7141 --count;
7142 } while (p0 !== p);
7143 outlines.push(coords);
7144 --i;
7145 }
7146
7147 var drawOutline = function(c) {
7148 c.save();
7149 // the path shall be painted in [0..1]x[0..1] space
7150 c.scale(1 / width, -1 / height);
7151 c.translate(0, -height);
7152 c.beginPath();
7153 for (var i = 0, ii = outlines.length; i < ii; i++) {
7154 var o = outlines[i];
7155 c.moveTo(o[0], o[1]);
7156 for (var j = 2, jj = o.length; j < jj; j += 2) {
7157 c.lineTo(o[j], o[j+1]);
7158 }
7159 }
7160 c.fill();
7161 c.beginPath();
7162 c.restore();
7163 };
7164
7165 return drawOutline;
7166}
7167
7168var CanvasExtraState = (function CanvasExtraStateClosure() {
7169 function CanvasExtraState(old) {
7170 // Are soft masks and alpha values shapes or opacities?
7171 this.alphaIsShape = false;
7172 this.fontSize = 0;
7173 this.fontSizeScale = 1;
7174 this.textMatrix = IDENTITY_MATRIX;
7175 this.textMatrixScale = 1;
7176 this.fontMatrix = FONT_IDENTITY_MATRIX;
7177 this.leading = 0;
7178 // Current point (in user coordinates)
7179 this.x = 0;
7180 this.y = 0;
7181 // Start of text line (in text coordinates)
7182 this.lineX = 0;
7183 this.lineY = 0;
7184 // Character and word spacing
7185 this.charSpacing = 0;
7186 this.wordSpacing = 0;
7187 this.textHScale = 1;
7188 this.textRenderingMode = TextRenderingMode.FILL;
7189 this.textRise = 0;
7190 // Default fore and background colors
7191 this.fillColor = '#000000';
7192 this.strokeColor = '#000000';
7193 this.patternFill = false;
7194 // Note: fill alpha applies to all non-stroking operations
7195 this.fillAlpha = 1;
7196 this.strokeAlpha = 1;
7197 this.lineWidth = 1;
7198 this.activeSMask = null;
7199 this.resumeSMaskCtx = null; // nonclonable field (see the save method below)
7200
7201 this.old = old;
7202 }
7203
7204 CanvasExtraState.prototype = {
7205 clone: function CanvasExtraState_clone() {
7206 return Object.create(this);
7207 },
7208 setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
7209 this.x = x;
7210 this.y = y;
7211 }
7212 };
7213 return CanvasExtraState;
7214})();
7215
7216var CanvasGraphics = (function CanvasGraphicsClosure() {
7217 // Defines the time the executeOperatorList is going to be executing
7218 // before it stops and shedules a continue of execution.
7219 var EXECUTION_TIME = 15;
7220 // Defines the number of steps before checking the execution time
7221 var EXECUTION_STEPS = 10;
7222
7223 function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
7224 this.ctx = canvasCtx;
7225 this.current = new CanvasExtraState();
7226 this.stateStack = [];
7227 this.pendingClip = null;
7228 this.pendingEOFill = false;
7229 this.res = null;
7230 this.xobjs = null;
7231 this.commonObjs = commonObjs;
7232 this.objs = objs;
7233 this.imageLayer = imageLayer;
7234 this.groupStack = [];
7235 this.processingType3 = null;
7236 // Patterns are painted relative to the initial page/form transform, see pdf
7237 // spec 8.7.2 NOTE 1.
7238 this.baseTransform = null;
7239 this.baseTransformStack = [];
7240 this.groupLevel = 0;
7241 this.smaskStack = [];
7242 this.smaskCounter = 0;
7243 this.tempSMask = null;
7244 this.cachedCanvases = new CachedCanvases();
7245 if (canvasCtx) {
7246 // NOTE: if mozCurrentTransform is polyfilled, then the current state of
7247 // the transformation must already be set in canvasCtx._transformMatrix.
7248 addContextCurrentTransform(canvasCtx);
7249 }
7250 this.cachedGetSinglePixelWidth = null;
7251 }
7252
7253 function putBinaryImageData(ctx, imgData) {
7254 if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
7255 ctx.putImageData(imgData, 0, 0);
7256 return;
7257 }
7258
7259 // Put the image data to the canvas in chunks, rather than putting the
7260 // whole image at once. This saves JS memory, because the ImageData object
7261 // is smaller. It also possibly saves C++ memory within the implementation
7262 // of putImageData(). (E.g. in Firefox we make two short-lived copies of
7263 // the data passed to putImageData()). |n| shouldn't be too small, however,
7264 // because too many putImageData() calls will slow things down.
7265 //
7266 // Note: as written, if the last chunk is partial, the putImageData() call
7267 // will (conceptually) put pixels past the bounds of the canvas. But
7268 // that's ok; any such pixels are ignored.
7269
7270 var height = imgData.height, width = imgData.width;
7271 var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
7272 var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
7273 var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
7274
7275 var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
7276 var srcPos = 0, destPos;
7277 var src = imgData.data;
7278 var dest = chunkImgData.data;
7279 var i, j, thisChunkHeight, elemsInThisChunk;
7280
7281 // There are multiple forms in which the pixel data can be passed, and
7282 // imgData.kind tells us which one this is.
7283 if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
7284 // Grayscale, 1 bit per pixel (i.e. black-and-white).
7285 var srcLength = src.byteLength;
7286 var dest32 = HasCanvasTypedArraysCached.value ?
7287 new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
7288 var dest32DataLength = dest32.length;
7289 var fullSrcDiff = (width + 7) >> 3;
7290 var white = 0xFFFFFFFF;
7291 var black = (IsLittleEndianCached.value ||
7292 !HasCanvasTypedArraysCached.value) ? 0xFF000000 : 0x000000FF;
7293 for (i = 0; i < totalChunks; i++) {
7294 thisChunkHeight =
7295 (i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
7296 destPos = 0;
7297 for (j = 0; j < thisChunkHeight; j++) {
7298 var srcDiff = srcLength - srcPos;
7299 var k = 0;
7300 var kEnd = (srcDiff > fullSrcDiff) ? width : srcDiff * 8 - 7;
7301 var kEndUnrolled = kEnd & ~7;
7302 var mask = 0;
7303 var srcByte = 0;
7304 for (; k < kEndUnrolled; k += 8) {
7305 srcByte = src[srcPos++];
7306 dest32[destPos++] = (srcByte & 128) ? white : black;
7307 dest32[destPos++] = (srcByte & 64) ? white : black;
7308 dest32[destPos++] = (srcByte & 32) ? white : black;
7309 dest32[destPos++] = (srcByte & 16) ? white : black;
7310 dest32[destPos++] = (srcByte & 8) ? white : black;
7311 dest32[destPos++] = (srcByte & 4) ? white : black;
7312 dest32[destPos++] = (srcByte & 2) ? white : black;
7313 dest32[destPos++] = (srcByte & 1) ? white : black;
7314 }
7315 for (; k < kEnd; k++) {
7316 if (mask === 0) {
7317 srcByte = src[srcPos++];
7318 mask = 128;
7319 }
7320
7321 dest32[destPos++] = (srcByte & mask) ? white : black;
7322 mask >>= 1;
7323 }
7324 }
7325 // We ran out of input. Make all remaining pixels transparent.
7326 while (destPos < dest32DataLength) {
7327 dest32[destPos++] = 0;
7328 }
7329
7330 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
7331 }
7332 } else if (imgData.kind === ImageKind.RGBA_32BPP) {
7333 // RGBA, 32-bits per pixel.
7334
7335 j = 0;
7336 elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
7337 for (i = 0; i < fullChunks; i++) {
7338 dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
7339 srcPos += elemsInThisChunk;
7340
7341 ctx.putImageData(chunkImgData, 0, j);
7342 j += FULL_CHUNK_HEIGHT;
7343 }
7344 if (i < totalChunks) {
7345 elemsInThisChunk = width * partialChunkHeight * 4;
7346 dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
7347 ctx.putImageData(chunkImgData, 0, j);
7348 }
7349
7350 } else if (imgData.kind === ImageKind.RGB_24BPP) {
7351 // RGB, 24-bits per pixel.
7352 thisChunkHeight = FULL_CHUNK_HEIGHT;
7353 elemsInThisChunk = width * thisChunkHeight;
7354 for (i = 0; i < totalChunks; i++) {
7355 if (i >= fullChunks) {
7356 thisChunkHeight = partialChunkHeight;
7357 elemsInThisChunk = width * thisChunkHeight;
7358 }
7359
7360 destPos = 0;
7361 for (j = elemsInThisChunk; j--;) {
7362 dest[destPos++] = src[srcPos++];
7363 dest[destPos++] = src[srcPos++];
7364 dest[destPos++] = src[srcPos++];
7365 dest[destPos++] = 255;
7366 }
7367 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
7368 }
7369 } else {
7370 error('bad image kind: ' + imgData.kind);
7371 }
7372 }
7373
7374 function putBinaryImageMask(ctx, imgData) {
7375 var height = imgData.height, width = imgData.width;
7376 var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
7377 var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
7378 var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
7379
7380 var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
7381 var srcPos = 0;
7382 var src = imgData.data;
7383 var dest = chunkImgData.data;
7384
7385 for (var i = 0; i < totalChunks; i++) {
7386 var thisChunkHeight =
7387 (i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
7388
7389 // Expand the mask so it can be used by the canvas. Any required
7390 // inversion has already been handled.
7391 var destPos = 3; // alpha component offset
7392 for (var j = 0; j < thisChunkHeight; j++) {
7393 var mask = 0;
7394 for (var k = 0; k < width; k++) {
7395 if (!mask) {
7396 var elem = src[srcPos++];
7397 mask = 128;
7398 }
7399 dest[destPos] = (elem & mask) ? 0 : 255;
7400 destPos += 4;
7401 mask >>= 1;
7402 }
7403 }
7404 ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
7405 }
7406 }
7407
7408 function copyCtxState(sourceCtx, destCtx) {
7409 var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha',
7410 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit',
7411 'globalCompositeOperation', 'font'];
7412 for (var i = 0, ii = properties.length; i < ii; i++) {
7413 var property = properties[i];
7414 if (sourceCtx[property] !== undefined) {
7415 destCtx[property] = sourceCtx[property];
7416 }
7417 }
7418 if (sourceCtx.setLineDash !== undefined) {
7419 destCtx.setLineDash(sourceCtx.getLineDash());
7420 destCtx.lineDashOffset = sourceCtx.lineDashOffset;
7421 }
7422 }
7423
7424 function composeSMaskBackdrop(bytes, r0, g0, b0) {
7425 var length = bytes.length;
7426 for (var i = 3; i < length; i += 4) {
7427 var alpha = bytes[i];
7428 if (alpha === 0) {
7429 bytes[i - 3] = r0;
7430 bytes[i - 2] = g0;
7431 bytes[i - 1] = b0;
7432 } else if (alpha < 255) {
7433 var alpha_ = 255 - alpha;
7434 bytes[i - 3] = (bytes[i - 3] * alpha + r0 * alpha_) >> 8;
7435 bytes[i - 2] = (bytes[i - 2] * alpha + g0 * alpha_) >> 8;
7436 bytes[i - 1] = (bytes[i - 1] * alpha + b0 * alpha_) >> 8;
7437 }
7438 }
7439 }
7440
7441 function composeSMaskAlpha(maskData, layerData, transferMap) {
7442 var length = maskData.length;
7443 var scale = 1 / 255;
7444 for (var i = 3; i < length; i += 4) {
7445 var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
7446 layerData[i] = (layerData[i] * alpha * scale) | 0;
7447 }
7448 }
7449
7450 function composeSMaskLuminosity(maskData, layerData, transferMap) {
7451 var length = maskData.length;
7452 for (var i = 3; i < length; i += 4) {
7453 var y = (maskData[i - 3] * 77) + // * 0.3 / 255 * 0x10000
7454 (maskData[i - 2] * 152) + // * 0.59 ....
7455 (maskData[i - 1] * 28); // * 0.11 ....
7456 layerData[i] = transferMap ?
7457 (layerData[i] * transferMap[y >> 8]) >> 8 :
7458 (layerData[i] * y) >> 16;
7459 }
7460 }
7461
7462 function genericComposeSMask(maskCtx, layerCtx, width, height,
7463 subtype, backdrop, transferMap) {
7464 var hasBackdrop = !!backdrop;
7465 var r0 = hasBackdrop ? backdrop[0] : 0;
7466 var g0 = hasBackdrop ? backdrop[1] : 0;
7467 var b0 = hasBackdrop ? backdrop[2] : 0;
7468
7469 var composeFn;
7470 if (subtype === 'Luminosity') {
7471 composeFn = composeSMaskLuminosity;
7472 } else {
7473 composeFn = composeSMaskAlpha;
7474 }
7475
7476 // processing image in chunks to save memory
7477 var PIXELS_TO_PROCESS = 1048576;
7478 var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
7479 for (var row = 0; row < height; row += chunkSize) {
7480 var chunkHeight = Math.min(chunkSize, height - row);
7481 var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
7482 var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
7483
7484 if (hasBackdrop) {
7485 composeSMaskBackdrop(maskData.data, r0, g0, b0);
7486 }
7487 composeFn(maskData.data, layerData.data, transferMap);
7488
7489 maskCtx.putImageData(layerData, 0, row);
7490 }
7491 }
7492
7493 function composeSMask(ctx, smask, layerCtx) {
7494 var mask = smask.canvas;
7495 var maskCtx = smask.context;
7496
7497 ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY,
7498 smask.offsetX, smask.offsetY);
7499
7500 var backdrop = smask.backdrop || null;
7501 if (!smask.transferMap && WebGLUtils.isEnabled) {
7502 var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask,
7503 {subtype: smask.subtype, backdrop: backdrop});
7504 ctx.setTransform(1, 0, 0, 1, 0, 0);
7505 ctx.drawImage(composed, smask.offsetX, smask.offsetY);
7506 return;
7507 }
7508 genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height,
7509 smask.subtype, backdrop, smask.transferMap);
7510 ctx.drawImage(mask, 0, 0);
7511 }
7512
7513 var LINE_CAP_STYLES = ['butt', 'round', 'square'];
7514 var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
7515 var NORMAL_CLIP = {};
7516 var EO_CLIP = {};
7517
7518 CanvasGraphics.prototype = {
7519
7520 beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport,
7521 transparency) {
7522 // For pdfs that use blend modes we have to clear the canvas else certain
7523 // blend modes can look wrong since we'd be blending with a white
7524 // backdrop. The problem with a transparent backdrop though is we then
7525 // don't get sub pixel anti aliasing on text, creating temporary
7526 // transparent canvas when we have blend modes.
7527 var width = this.ctx.canvas.width;
7528 var height = this.ctx.canvas.height;
7529
7530 this.ctx.save();
7531 this.ctx.fillStyle = 'rgb(255, 255, 255)';
7532 this.ctx.fillRect(0, 0, width, height);
7533 this.ctx.restore();
7534
7535 if (transparency) {
7536 var transparentCanvas = this.cachedCanvases.getCanvas(
7537 'transparent', width, height, true);
7538 this.compositeCtx = this.ctx;
7539 this.transparentCanvas = transparentCanvas.canvas;
7540 this.ctx = transparentCanvas.context;
7541 this.ctx.save();
7542 // The transform can be applied before rendering, transferring it to
7543 // the new canvas.
7544 this.ctx.transform.apply(this.ctx,
7545 this.compositeCtx.mozCurrentTransform);
7546 }
7547
7548 this.ctx.save();
7549 if (transform) {
7550 this.ctx.transform.apply(this.ctx, transform);
7551 }
7552 this.ctx.transform.apply(this.ctx, viewport.transform);
7553
7554 this.baseTransform = this.ctx.mozCurrentTransform.slice();
7555
7556 if (this.imageLayer) {
7557 this.imageLayer.beginLayout();
7558 }
7559 },
7560
7561 executeOperatorList: function CanvasGraphics_executeOperatorList(
7562 operatorList,
7563 executionStartIdx, continueCallback,
7564 stepper) {
7565 var argsArray = operatorList.argsArray;
7566 var fnArray = operatorList.fnArray;
7567 var i = executionStartIdx || 0;
7568 var argsArrayLen = argsArray.length;
7569
7570 // Sometimes the OperatorList to execute is empty.
7571 if (argsArrayLen === i) {
7572 return i;
7573 }
7574
7575 var chunkOperations = (argsArrayLen - i > EXECUTION_STEPS &&
7576 typeof continueCallback === 'function');
7577 var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
7578 var steps = 0;
7579
7580 var commonObjs = this.commonObjs;
7581 var objs = this.objs;
7582 var fnId;
7583
7584 while (true) {
7585 if (stepper !== undefined && i === stepper.nextBreakPoint) {
7586 stepper.breakIt(i, continueCallback);
7587 return i;
7588 }
7589
7590 fnId = fnArray[i];
7591
7592 if (fnId !== OPS.dependency) {
7593 this[fnId].apply(this, argsArray[i]);
7594 } else {
7595 var deps = argsArray[i];
7596 for (var n = 0, nn = deps.length; n < nn; n++) {
7597 var depObjId = deps[n];
7598 var common = depObjId[0] === 'g' && depObjId[1] === '_';
7599 var objsPool = common ? commonObjs : objs;
7600
7601 // If the promise isn't resolved yet, add the continueCallback
7602 // to the promise and bail out.
7603 if (!objsPool.isResolved(depObjId)) {
7604 objsPool.get(depObjId, continueCallback);
7605 return i;
7606 }
7607 }
7608 }
7609
7610 i++;
7611
7612 // If the entire operatorList was executed, stop as were done.
7613 if (i === argsArrayLen) {
7614 return i;
7615 }
7616
7617 // If the execution took longer then a certain amount of time and
7618 // `continueCallback` is specified, interrupt the execution.
7619 if (chunkOperations && ++steps > EXECUTION_STEPS) {
7620 if (Date.now() > endTime) {
7621 continueCallback();
7622 return i;
7623 }
7624 steps = 0;
7625 }
7626
7627 // If the operatorList isn't executed completely yet OR the execution
7628 // time was short enough, do another execution round.
7629 }
7630 },
7631
7632 endDrawing: function CanvasGraphics_endDrawing() {
7633 // Finishing all opened operations such as SMask group painting.
7634 if (this.current.activeSMask !== null) {
7635 this.endSMaskGroup();
7636 }
7637
7638 this.ctx.restore();
7639
7640 if (this.transparentCanvas) {
7641 this.ctx = this.compositeCtx;
7642 this.ctx.save();
7643 this.ctx.setTransform(1, 0, 0, 1, 0, 0); // Avoid apply transform twice
7644 this.ctx.drawImage(this.transparentCanvas, 0, 0);
7645 this.ctx.restore();
7646 this.transparentCanvas = null;
7647 }
7648
7649 this.cachedCanvases.clear();
7650 WebGLUtils.clear();
7651
7652 if (this.imageLayer) {
7653 this.imageLayer.endLayout();
7654 }
7655 },
7656
7657 // Graphics state
7658 setLineWidth: function CanvasGraphics_setLineWidth(width) {
7659 this.current.lineWidth = width;
7660 this.ctx.lineWidth = width;
7661 },
7662 setLineCap: function CanvasGraphics_setLineCap(style) {
7663 this.ctx.lineCap = LINE_CAP_STYLES[style];
7664 },
7665 setLineJoin: function CanvasGraphics_setLineJoin(style) {
7666 this.ctx.lineJoin = LINE_JOIN_STYLES[style];
7667 },
7668 setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
7669 this.ctx.miterLimit = limit;
7670 },
7671 setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
7672 var ctx = this.ctx;
7673 if (ctx.setLineDash !== undefined) {
7674 ctx.setLineDash(dashArray);
7675 ctx.lineDashOffset = dashPhase;
7676 }
7677 },
7678 setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
7679 // Maybe if we one day fully support color spaces this will be important
7680 // for now we can ignore.
7681 // TODO set rendering intent?
7682 },
7683 setFlatness: function CanvasGraphics_setFlatness(flatness) {
7684 // There's no way to control this with canvas, but we can safely ignore.
7685 // TODO set flatness?
7686 },
7687 setGState: function CanvasGraphics_setGState(states) {
7688 for (var i = 0, ii = states.length; i < ii; i++) {
7689 var state = states[i];
7690 var key = state[0];
7691 var value = state[1];
7692
7693 switch (key) {
7694 case 'LW':
7695 this.setLineWidth(value);
7696 break;
7697 case 'LC':
7698 this.setLineCap(value);
7699 break;
7700 case 'LJ':
7701 this.setLineJoin(value);
7702 break;
7703 case 'ML':
7704 this.setMiterLimit(value);
7705 break;
7706 case 'D':
7707 this.setDash(value[0], value[1]);
7708 break;
7709 case 'RI':
7710 this.setRenderingIntent(value);
7711 break;
7712 case 'FL':
7713 this.setFlatness(value);
7714 break;
7715 case 'Font':
7716 this.setFont(value[0], value[1]);
7717 break;
7718 case 'CA':
7719 this.current.strokeAlpha = state[1];
7720 break;
7721 case 'ca':
7722 this.current.fillAlpha = state[1];
7723 this.ctx.globalAlpha = state[1];
7724 break;
7725 case 'BM':
7726 if (value && value.name && (value.name !== 'Normal')) {
7727 var mode = value.name.replace(/([A-Z])/g,
7728 function(c) {
7729 return '-' + c.toLowerCase();
7730 }
7731 ).substring(1);
7732 this.ctx.globalCompositeOperation = mode;
7733 if (this.ctx.globalCompositeOperation !== mode) {
7734 warn('globalCompositeOperation "' + mode +
7735 '" is not supported');
7736 }
7737 } else {
7738 this.ctx.globalCompositeOperation = 'source-over';
7739 }
7740 break;
7741 case 'SMask':
7742 if (this.current.activeSMask) {
7743 // If SMask is currrenly used, it needs to be suspended or
7744 // finished. Suspend only makes sense when at least one save()
7745 // was performed and state needs to be reverted on restore().
7746 if (this.stateStack.length > 0 &&
7747 (this.stateStack[this.stateStack.length - 1].activeSMask ===
7748 this.current.activeSMask)) {
7749 this.suspendSMaskGroup();
7750 } else {
7751 this.endSMaskGroup();
7752 }
7753 }
7754 this.current.activeSMask = value ? this.tempSMask : null;
7755 if (this.current.activeSMask) {
7756 this.beginSMaskGroup();
7757 }
7758 this.tempSMask = null;
7759 break;
7760 }
7761 }
7762 },
7763 beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
7764
7765 var activeSMask = this.current.activeSMask;
7766 var drawnWidth = activeSMask.canvas.width;
7767 var drawnHeight = activeSMask.canvas.height;
7768 var cacheId = 'smaskGroupAt' + this.groupLevel;
7769 var scratchCanvas = this.cachedCanvases.getCanvas(
7770 cacheId, drawnWidth, drawnHeight, true);
7771
7772 var currentCtx = this.ctx;
7773 var currentTransform = currentCtx.mozCurrentTransform;
7774 this.ctx.save();
7775
7776 var groupCtx = scratchCanvas.context;
7777 groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
7778 groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
7779 groupCtx.transform.apply(groupCtx, currentTransform);
7780
7781 activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
7782
7783 copyCtxState(currentCtx, groupCtx);
7784 this.ctx = groupCtx;
7785 this.setGState([
7786 ['BM', 'Normal'],
7787 ['ca', 1],
7788 ['CA', 1]
7789 ]);
7790 this.groupStack.push(currentCtx);
7791 this.groupLevel++;
7792 },
7793 suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
7794 // Similar to endSMaskGroup, the intermediate canvas has to be composed
7795 // and future ctx state restored.
7796 var groupCtx = this.ctx;
7797 this.groupLevel--;
7798 this.ctx = this.groupStack.pop();
7799
7800 composeSMask(this.ctx, this.current.activeSMask, groupCtx);
7801 this.ctx.restore();
7802 this.ctx.save(); // save is needed since SMask will be resumed.
7803 copyCtxState(groupCtx, this.ctx);
7804
7805 // Saving state for resuming.
7806 this.current.resumeSMaskCtx = groupCtx;
7807 // Transform was changed in the SMask canvas, reflecting this change on
7808 // this.ctx.
7809 var deltaTransform = Util.transform(
7810 this.current.activeSMask.startTransformInverse,
7811 groupCtx.mozCurrentTransform);
7812 this.ctx.transform.apply(this.ctx, deltaTransform);
7813
7814 // SMask was composed, the results at the groupCtx can be cleared.
7815 groupCtx.save();
7816 groupCtx.setTransform(1, 0, 0, 1, 0, 0);
7817 groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
7818 groupCtx.restore();
7819 },
7820 resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
7821 // Resuming state saved by suspendSMaskGroup. We don't need to restore
7822 // any groupCtx state since restore() command (the only caller) will do
7823 // that for us. See also beginSMaskGroup.
7824 var groupCtx = this.current.resumeSMaskCtx;
7825 var currentCtx = this.ctx;
7826 this.ctx = groupCtx;
7827 this.groupStack.push(currentCtx);
7828 this.groupLevel++;
7829 },
7830 endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
7831 var groupCtx = this.ctx;
7832 this.groupLevel--;
7833 this.ctx = this.groupStack.pop();
7834
7835 composeSMask(this.ctx, this.current.activeSMask, groupCtx);
7836 this.ctx.restore();
7837 copyCtxState(groupCtx, this.ctx);
7838 // Transform was changed in the SMask canvas, reflecting this change on
7839 // this.ctx.
7840 var deltaTransform = Util.transform(
7841 this.current.activeSMask.startTransformInverse,
7842 groupCtx.mozCurrentTransform);
7843 this.ctx.transform.apply(this.ctx, deltaTransform);
7844 },
7845 save: function CanvasGraphics_save() {
7846 this.ctx.save();
7847 var old = this.current;
7848 this.stateStack.push(old);
7849 this.current = old.clone();
7850 this.current.resumeSMaskCtx = null;
7851 },
7852 restore: function CanvasGraphics_restore() {
7853 // SMask was suspended, we just need to resume it.
7854 if (this.current.resumeSMaskCtx) {
7855 this.resumeSMaskGroup();
7856 }
7857 // SMask has to be finished once there is no states that are using the
7858 // same SMask.
7859 if (this.current.activeSMask !== null && (this.stateStack.length === 0 ||
7860 this.stateStack[this.stateStack.length - 1].activeSMask !==
7861 this.current.activeSMask)) {
7862 this.endSMaskGroup();
7863 }
7864
7865 if (this.stateStack.length !== 0) {
7866 this.current = this.stateStack.pop();
7867 this.ctx.restore();
7868
7869 // Ensure that the clipping path is reset (fixes issue6413.pdf).
7870 this.pendingClip = null;
7871
7872 this.cachedGetSinglePixelWidth = null;
7873 }
7874 },
7875 transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
7876 this.ctx.transform(a, b, c, d, e, f);
7877
7878 this.cachedGetSinglePixelWidth = null;
7879 },
7880
7881 // Path
7882 constructPath: function CanvasGraphics_constructPath(ops, args) {
7883 var ctx = this.ctx;
7884 var current = this.current;
7885 var x = current.x, y = current.y;
7886 for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
7887 switch (ops[i] | 0) {
7888 case OPS.rectangle:
7889 x = args[j++];
7890 y = args[j++];
7891 var width = args[j++];
7892 var height = args[j++];
7893 if (width === 0) {
7894 width = this.getSinglePixelWidth();
7895 }
7896 if (height === 0) {
7897 height = this.getSinglePixelWidth();
7898 }
7899 var xw = x + width;
7900 var yh = y + height;
7901 this.ctx.moveTo(x, y);
7902 this.ctx.lineTo(xw, y);
7903 this.ctx.lineTo(xw, yh);
7904 this.ctx.lineTo(x, yh);
7905 this.ctx.lineTo(x, y);
7906 this.ctx.closePath();
7907 break;
7908 case OPS.moveTo:
7909 x = args[j++];
7910 y = args[j++];
7911 ctx.moveTo(x, y);
7912 break;
7913 case OPS.lineTo:
7914 x = args[j++];
7915 y = args[j++];
7916 ctx.lineTo(x, y);
7917 break;
7918 case OPS.curveTo:
7919 x = args[j + 4];
7920 y = args[j + 5];
7921 ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3],
7922 x, y);
7923 j += 6;
7924 break;
7925 case OPS.curveTo2:
7926 ctx.bezierCurveTo(x, y, args[j], args[j + 1],
7927 args[j + 2], args[j + 3]);
7928 x = args[j + 2];
7929 y = args[j + 3];
7930 j += 4;
7931 break;
7932 case OPS.curveTo3:
7933 x = args[j + 2];
7934 y = args[j + 3];
7935 ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
7936 j += 4;
7937 break;
7938 case OPS.closePath:
7939 ctx.closePath();
7940 break;
7941 }
7942 }
7943 current.setCurrentPoint(x, y);
7944 },
7945 closePath: function CanvasGraphics_closePath() {
7946 this.ctx.closePath();
7947 },
7948 stroke: function CanvasGraphics_stroke(consumePath) {
7949 consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
7950 var ctx = this.ctx;
7951 var strokeColor = this.current.strokeColor;
7952 // Prevent drawing too thin lines by enforcing a minimum line width.
7953 ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR,
7954 this.current.lineWidth);
7955 // For stroke we want to temporarily change the global alpha to the
7956 // stroking alpha.
7957 ctx.globalAlpha = this.current.strokeAlpha;
7958 if (strokeColor && strokeColor.hasOwnProperty('type') &&
7959 strokeColor.type === 'Pattern') {
7960 // for patterns, we transform to pattern space, calculate
7961 // the pattern, call stroke, and restore to user space
7962 ctx.save();
7963 ctx.strokeStyle = strokeColor.getPattern(ctx, this);
7964 ctx.stroke();
7965 ctx.restore();
7966 } else {
7967 ctx.stroke();
7968 }
7969 if (consumePath) {
7970 this.consumePath();
7971 }
7972 // Restore the global alpha to the fill alpha
7973 ctx.globalAlpha = this.current.fillAlpha;
7974 },
7975 closeStroke: function CanvasGraphics_closeStroke() {
7976 this.closePath();
7977 this.stroke();
7978 },
7979 fill: function CanvasGraphics_fill(consumePath) {
7980 consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
7981 var ctx = this.ctx;
7982 var fillColor = this.current.fillColor;
7983 var isPatternFill = this.current.patternFill;
7984 var needRestore = false;
7985
7986 if (isPatternFill) {
7987 ctx.save();
7988 if (this.baseTransform) {
7989 ctx.setTransform.apply(ctx, this.baseTransform);
7990 }
7991 ctx.fillStyle = fillColor.getPattern(ctx, this);
7992 needRestore = true;
7993 }
7994
7995 if (this.pendingEOFill) {
7996 if (ctx.mozFillRule !== undefined) {
7997 ctx.mozFillRule = 'evenodd';
7998 ctx.fill();
7999 ctx.mozFillRule = 'nonzero';
8000 } else {
8001 ctx.fill('evenodd');
8002 }
8003 this.pendingEOFill = false;
8004 } else {
8005 ctx.fill();
8006 }
8007
8008 if (needRestore) {
8009 ctx.restore();
8010 }
8011 if (consumePath) {
8012 this.consumePath();
8013 }
8014 },
8015 eoFill: function CanvasGraphics_eoFill() {
8016 this.pendingEOFill = true;
8017 this.fill();
8018 },
8019 fillStroke: function CanvasGraphics_fillStroke() {
8020 this.fill(false);
8021 this.stroke(false);
8022
8023 this.consumePath();
8024 },
8025 eoFillStroke: function CanvasGraphics_eoFillStroke() {
8026 this.pendingEOFill = true;
8027 this.fillStroke();
8028 },
8029 closeFillStroke: function CanvasGraphics_closeFillStroke() {
8030 this.closePath();
8031 this.fillStroke();
8032 },
8033 closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
8034 this.pendingEOFill = true;
8035 this.closePath();
8036 this.fillStroke();
8037 },
8038 endPath: function CanvasGraphics_endPath() {
8039 this.consumePath();
8040 },
8041
8042 // Clipping
8043 clip: function CanvasGraphics_clip() {
8044 this.pendingClip = NORMAL_CLIP;
8045 },
8046 eoClip: function CanvasGraphics_eoClip() {
8047 this.pendingClip = EO_CLIP;
8048 },
8049
8050 // Text
8051 beginText: function CanvasGraphics_beginText() {
8052 this.current.textMatrix = IDENTITY_MATRIX;
8053 this.current.textMatrixScale = 1;
8054 this.current.x = this.current.lineX = 0;
8055 this.current.y = this.current.lineY = 0;
8056 },
8057 endText: function CanvasGraphics_endText() {
8058 var paths = this.pendingTextPaths;
8059 var ctx = this.ctx;
8060 if (paths === undefined) {
8061 ctx.beginPath();
8062 return;
8063 }
8064
8065 ctx.save();
8066 ctx.beginPath();
8067 for (var i = 0; i < paths.length; i++) {
8068 var path = paths[i];
8069 ctx.setTransform.apply(ctx, path.transform);
8070 ctx.translate(path.x, path.y);
8071 path.addToPath(ctx, path.fontSize);
8072 }
8073 ctx.restore();
8074 ctx.clip();
8075 ctx.beginPath();
8076 delete this.pendingTextPaths;
8077 },
8078 setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
8079 this.current.charSpacing = spacing;
8080 },
8081 setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
8082 this.current.wordSpacing = spacing;
8083 },
8084 setHScale: function CanvasGraphics_setHScale(scale) {
8085 this.current.textHScale = scale / 100;
8086 },
8087 setLeading: function CanvasGraphics_setLeading(leading) {
8088 this.current.leading = -leading;
8089 },
8090 setFont: function CanvasGraphics_setFont(fontRefName, size) {
8091 var fontObj = this.commonObjs.get(fontRefName);
8092 var current = this.current;
8093
8094 if (!fontObj) {
8095 error('Can\'t find font for ' + fontRefName);
8096 }
8097
8098 current.fontMatrix = (fontObj.fontMatrix ?
8099 fontObj.fontMatrix : FONT_IDENTITY_MATRIX);
8100
8101 // A valid matrix needs all main diagonal elements to be non-zero
8102 // This also ensures we bypass FF bugzilla bug #719844.
8103 if (current.fontMatrix[0] === 0 ||
8104 current.fontMatrix[3] === 0) {
8105 warn('Invalid font matrix for font ' + fontRefName);
8106 }
8107
8108 // The spec for Tf (setFont) says that 'size' specifies the font 'scale',
8109 // and in some docs this can be negative (inverted x-y axes).
8110 if (size < 0) {
8111 size = -size;
8112 current.fontDirection = -1;
8113 } else {
8114 current.fontDirection = 1;
8115 }
8116
8117 this.current.font = fontObj;
8118 this.current.fontSize = size;
8119
8120 if (fontObj.isType3Font) {
8121 return; // we don't need ctx.font for Type3 fonts
8122 }
8123
8124 var name = fontObj.loadedName || 'sans-serif';
8125 var bold = fontObj.black ? (fontObj.bold ? '900' : 'bold') :
8126 (fontObj.bold ? 'bold' : 'normal');
8127
8128 var italic = fontObj.italic ? 'italic' : 'normal';
8129 var typeface = '"' + name + '", ' + fontObj.fallbackName;
8130
8131 // Some font backends cannot handle fonts below certain size.
8132 // Keeping the font at minimal size and using the fontSizeScale to change
8133 // the current transformation matrix before the fillText/strokeText.
8134 // See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
8135 var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE :
8136 size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
8137 this.current.fontSizeScale = size / browserFontSize;
8138
8139 var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
8140 this.ctx.font = rule;
8141 },
8142 setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
8143 this.current.textRenderingMode = mode;
8144 },
8145 setTextRise: function CanvasGraphics_setTextRise(rise) {
8146 this.current.textRise = rise;
8147 },
8148 moveText: function CanvasGraphics_moveText(x, y) {
8149 this.current.x = this.current.lineX += x;
8150 this.current.y = this.current.lineY += y;
8151 },
8152 setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
8153 this.setLeading(-y);
8154 this.moveText(x, y);
8155 },
8156 setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
8157 this.current.textMatrix = [a, b, c, d, e, f];
8158 this.current.textMatrixScale = Math.sqrt(a * a + b * b);
8159
8160 this.current.x = this.current.lineX = 0;
8161 this.current.y = this.current.lineY = 0;
8162 },
8163 nextLine: function CanvasGraphics_nextLine() {
8164 this.moveText(0, this.current.leading);
8165 },
8166
8167 paintChar: function CanvasGraphics_paintChar(character, x, y) {
8168 var ctx = this.ctx;
8169 var current = this.current;
8170 var font = current.font;
8171 var textRenderingMode = current.textRenderingMode;
8172 var fontSize = current.fontSize / current.fontSizeScale;
8173 var fillStrokeMode = textRenderingMode &
8174 TextRenderingMode.FILL_STROKE_MASK;
8175 var isAddToPathSet = !!(textRenderingMode &
8176 TextRenderingMode.ADD_TO_PATH_FLAG);
8177
8178 var addToPath;
8179 if (font.disableFontFace || isAddToPathSet) {
8180 addToPath = font.getPathGenerator(this.commonObjs, character);
8181 }
8182
8183 if (font.disableFontFace) {
8184 ctx.save();
8185 ctx.translate(x, y);
8186 ctx.beginPath();
8187 addToPath(ctx, fontSize);
8188 if (fillStrokeMode === TextRenderingMode.FILL ||
8189 fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8190 ctx.fill();
8191 }
8192 if (fillStrokeMode === TextRenderingMode.STROKE ||
8193 fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8194 ctx.stroke();
8195 }
8196 ctx.restore();
8197 } else {
8198 if (fillStrokeMode === TextRenderingMode.FILL ||
8199 fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8200 ctx.fillText(character, x, y);
8201 }
8202 if (fillStrokeMode === TextRenderingMode.STROKE ||
8203 fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8204 ctx.strokeText(character, x, y);
8205 }
8206 }
8207
8208 if (isAddToPathSet) {
8209 var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
8210 paths.push({
8211 transform: ctx.mozCurrentTransform,
8212 x: x,
8213 y: y,
8214 fontSize: fontSize,
8215 addToPath: addToPath
8216 });
8217 }
8218 },
8219
8220 get isFontSubpixelAAEnabled() {
8221 // Checks if anti-aliasing is enabled when scaled text is painted.
8222 // On Windows GDI scaled fonts looks bad.
8223 var ctx = document.createElement('canvas').getContext('2d');
8224 ctx.scale(1.5, 1);
8225 ctx.fillText('I', 0, 10);
8226 var data = ctx.getImageData(0, 0, 10, 10).data;
8227 var enabled = false;
8228 for (var i = 3; i < data.length; i += 4) {
8229 if (data[i] > 0 && data[i] < 255) {
8230 enabled = true;
8231 break;
8232 }
8233 }
8234 return shadow(this, 'isFontSubpixelAAEnabled', enabled);
8235 },
8236
8237 showText: function CanvasGraphics_showText(glyphs) {
8238 var current = this.current;
8239 var font = current.font;
8240 if (font.isType3Font) {
8241 return this.showType3Text(glyphs);
8242 }
8243
8244 var fontSize = current.fontSize;
8245 if (fontSize === 0) {
8246 return;
8247 }
8248
8249 var ctx = this.ctx;
8250 var fontSizeScale = current.fontSizeScale;
8251 var charSpacing = current.charSpacing;
8252 var wordSpacing = current.wordSpacing;
8253 var fontDirection = current.fontDirection;
8254 var textHScale = current.textHScale * fontDirection;
8255 var glyphsLength = glyphs.length;
8256 var vertical = font.vertical;
8257 var spacingDir = vertical ? 1 : -1;
8258 var defaultVMetrics = font.defaultVMetrics;
8259 var widthAdvanceScale = fontSize * current.fontMatrix[0];
8260
8261 var simpleFillText =
8262 current.textRenderingMode === TextRenderingMode.FILL &&
8263 !font.disableFontFace;
8264
8265 ctx.save();
8266 ctx.transform.apply(ctx, current.textMatrix);
8267 ctx.translate(current.x, current.y + current.textRise);
8268
8269 if (current.patternFill) {
8270 // TODO: Some shading patterns are not applied correctly to text,
8271 // e.g. issues 3988 and 5432, and ShowText-ShadingPattern.pdf.
8272 ctx.fillStyle = current.fillColor.getPattern(ctx, this);
8273 }
8274
8275 if (fontDirection > 0) {
8276 ctx.scale(textHScale, -1);
8277 } else {
8278 ctx.scale(textHScale, 1);
8279 }
8280
8281 var lineWidth = current.lineWidth;
8282 var scale = current.textMatrixScale;
8283 if (scale === 0 || lineWidth === 0) {
8284 var fillStrokeMode = current.textRenderingMode &
8285 TextRenderingMode.FILL_STROKE_MASK;
8286 if (fillStrokeMode === TextRenderingMode.STROKE ||
8287 fillStrokeMode === TextRenderingMode.FILL_STROKE) {
8288 this.cachedGetSinglePixelWidth = null;
8289 lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
8290 }
8291 } else {
8292 lineWidth /= scale;
8293 }
8294
8295 if (fontSizeScale !== 1.0) {
8296 ctx.scale(fontSizeScale, fontSizeScale);
8297 lineWidth /= fontSizeScale;
8298 }
8299
8300 ctx.lineWidth = lineWidth;
8301
8302 var x = 0, i;
8303 for (i = 0; i < glyphsLength; ++i) {
8304 var glyph = glyphs[i];
8305 if (isNum(glyph)) {
8306 x += spacingDir * glyph * fontSize / 1000;
8307 continue;
8308 }
8309
8310 var restoreNeeded = false;
8311 var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
8312 var character = glyph.fontChar;
8313 var accent = glyph.accent;
8314 var scaledX, scaledY, scaledAccentX, scaledAccentY;
8315 var width = glyph.width;
8316 if (vertical) {
8317 var vmetric, vx, vy;
8318 vmetric = glyph.vmetric || defaultVMetrics;
8319 vx = glyph.vmetric ? vmetric[1] : width * 0.5;
8320 vx = -vx * widthAdvanceScale;
8321 vy = vmetric[2] * widthAdvanceScale;
8322
8323 width = vmetric ? -vmetric[0] : width;
8324 scaledX = vx / fontSizeScale;
8325 scaledY = (x + vy) / fontSizeScale;
8326 } else {
8327 scaledX = x / fontSizeScale;
8328 scaledY = 0;
8329 }
8330
8331 if (font.remeasure && width > 0) {
8332 // Some standard fonts may not have the exact width: rescale per
8333 // character if measured width is greater than expected glyph width
8334 // and subpixel-aa is enabled, otherwise just center the glyph.
8335 var measuredWidth = ctx.measureText(character).width * 1000 /
8336 fontSize * fontSizeScale;
8337 if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
8338 var characterScaleX = width / measuredWidth;
8339 restoreNeeded = true;
8340 ctx.save();
8341 ctx.scale(characterScaleX, 1);
8342 scaledX /= characterScaleX;
8343 } else if (width !== measuredWidth) {
8344 scaledX += (width - measuredWidth) / 2000 *
8345 fontSize / fontSizeScale;
8346 }
8347 }
8348
8349 // Only attempt to draw the glyph if it is actually in the embedded font
8350 // file or if there isn't a font file so the fallback font is shown.
8351 if (glyph.isInFont || font.missingFile) {
8352 if (simpleFillText && !accent) {
8353 // common case
8354 ctx.fillText(character, scaledX, scaledY);
8355 } else {
8356 this.paintChar(character, scaledX, scaledY);
8357 if (accent) {
8358 scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
8359 scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
8360 this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
8361 }
8362 }
8363 }
8364
8365 var charWidth = width * widthAdvanceScale + spacing * fontDirection;
8366 x += charWidth;
8367
8368 if (restoreNeeded) {
8369 ctx.restore();
8370 }
8371 }
8372 if (vertical) {
8373 current.y -= x * textHScale;
8374 } else {
8375 current.x += x * textHScale;
8376 }
8377 ctx.restore();
8378 },
8379
8380 showType3Text: function CanvasGraphics_showType3Text(glyphs) {
8381 // Type3 fonts - each glyph is a "mini-PDF"
8382 var ctx = this.ctx;
8383 var current = this.current;
8384 var font = current.font;
8385 var fontSize = current.fontSize;
8386 var fontDirection = current.fontDirection;
8387 var spacingDir = font.vertical ? 1 : -1;
8388 var charSpacing = current.charSpacing;
8389 var wordSpacing = current.wordSpacing;
8390 var textHScale = current.textHScale * fontDirection;
8391 var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
8392 var glyphsLength = glyphs.length;
8393 var isTextInvisible =
8394 current.textRenderingMode === TextRenderingMode.INVISIBLE;
8395 var i, glyph, width, spacingLength;
8396
8397 if (isTextInvisible || fontSize === 0) {
8398 return;
8399 }
8400 this.cachedGetSinglePixelWidth = null;
8401
8402 ctx.save();
8403 ctx.transform.apply(ctx, current.textMatrix);
8404 ctx.translate(current.x, current.y);
8405
8406 ctx.scale(textHScale, fontDirection);
8407
8408 for (i = 0; i < glyphsLength; ++i) {
8409 glyph = glyphs[i];
8410 if (isNum(glyph)) {
8411 spacingLength = spacingDir * glyph * fontSize / 1000;
8412 this.ctx.translate(spacingLength, 0);
8413 current.x += spacingLength * textHScale;
8414 continue;
8415 }
8416
8417 var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
8418 var operatorList = font.charProcOperatorList[glyph.operatorListId];
8419 if (!operatorList) {
8420 warn('Type3 character \"' + glyph.operatorListId +
8421 '\" is not available');
8422 continue;
8423 }
8424 this.processingType3 = glyph;
8425 this.save();
8426 ctx.scale(fontSize, fontSize);
8427 ctx.transform.apply(ctx, fontMatrix);
8428 this.executeOperatorList(operatorList);
8429 this.restore();
8430
8431 var transformed = Util.applyTransform([glyph.width, 0], fontMatrix);
8432 width = transformed[0] * fontSize + spacing;
8433
8434 ctx.translate(width, 0);
8435 current.x += width * textHScale;
8436 }
8437 ctx.restore();
8438 this.processingType3 = null;
8439 },
8440
8441 // Type3 fonts
8442 setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
8443 // We can safely ignore this since the width should be the same
8444 // as the width in the Widths array.
8445 },
8446 setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth,
8447 yWidth,
8448 llx,
8449 lly,
8450 urx,
8451 ury) {
8452 // TODO According to the spec we're also suppose to ignore any operators
8453 // that set color or include images while processing this type3 font.
8454 this.ctx.rect(llx, lly, urx - llx, ury - lly);
8455 this.clip();
8456 this.endPath();
8457 },
8458
8459 // Color
8460 getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
8461 var pattern;
8462 if (IR[0] === 'TilingPattern') {
8463 var color = IR[1];
8464 var baseTransform = this.baseTransform ||
8465 this.ctx.mozCurrentTransform.slice();
8466 var self = this;
8467 var canvasGraphicsFactory = {
8468 createCanvasGraphics: function (ctx) {
8469 return new CanvasGraphics(ctx, self.commonObjs, self.objs);
8470 }
8471 };
8472 pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory,
8473 baseTransform);
8474 } else {
8475 pattern = getShadingPatternFromIR(IR);
8476 }
8477 return pattern;
8478 },
8479 setStrokeColorN: function CanvasGraphics_setStrokeColorN(/*...*/) {
8480 this.current.strokeColor = this.getColorN_Pattern(arguments);
8481 },
8482 setFillColorN: function CanvasGraphics_setFillColorN(/*...*/) {
8483 this.current.fillColor = this.getColorN_Pattern(arguments);
8484 this.current.patternFill = true;
8485 },
8486 setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
8487 var color = Util.makeCssRgb(r, g, b);
8488 this.ctx.strokeStyle = color;
8489 this.current.strokeColor = color;
8490 },
8491 setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
8492 var color = Util.makeCssRgb(r, g, b);
8493 this.ctx.fillStyle = color;
8494 this.current.fillColor = color;
8495 this.current.patternFill = false;
8496 },
8497
8498 shadingFill: function CanvasGraphics_shadingFill(patternIR) {
8499 var ctx = this.ctx;
8500
8501 this.save();
8502 var pattern = getShadingPatternFromIR(patternIR);
8503 ctx.fillStyle = pattern.getPattern(ctx, this, true);
8504
8505 var inv = ctx.mozCurrentTransformInverse;
8506 if (inv) {
8507 var canvas = ctx.canvas;
8508 var width = canvas.width;
8509 var height = canvas.height;
8510
8511 var bl = Util.applyTransform([0, 0], inv);
8512 var br = Util.applyTransform([0, height], inv);
8513 var ul = Util.applyTransform([width, 0], inv);
8514 var ur = Util.applyTransform([width, height], inv);
8515
8516 var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
8517 var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
8518 var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
8519 var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
8520
8521 this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
8522 } else {
8523 // HACK to draw the gradient onto an infinite rectangle.
8524 // PDF gradients are drawn across the entire image while
8525 // Canvas only allows gradients to be drawn in a rectangle
8526 // The following bug should allow us to remove this.
8527 // https://bugzilla.mozilla.org/show_bug.cgi?id=664884
8528
8529 this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
8530 }
8531
8532 this.restore();
8533 },
8534
8535 // Images
8536 beginInlineImage: function CanvasGraphics_beginInlineImage() {
8537 error('Should not call beginInlineImage');
8538 },
8539 beginImageData: function CanvasGraphics_beginImageData() {
8540 error('Should not call beginImageData');
8541 },
8542
8543 paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix,
8544 bbox) {
8545 this.save();
8546 this.baseTransformStack.push(this.baseTransform);
8547
8548 if (isArray(matrix) && 6 === matrix.length) {
8549 this.transform.apply(this, matrix);
8550 }
8551
8552 this.baseTransform = this.ctx.mozCurrentTransform;
8553
8554 if (isArray(bbox) && 4 === bbox.length) {
8555 var width = bbox[2] - bbox[0];
8556 var height = bbox[3] - bbox[1];
8557 this.ctx.rect(bbox[0], bbox[1], width, height);
8558 this.clip();
8559 this.endPath();
8560 }
8561 },
8562
8563 paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
8564 this.restore();
8565 this.baseTransform = this.baseTransformStack.pop();
8566 },
8567
8568 beginGroup: function CanvasGraphics_beginGroup(group) {
8569 this.save();
8570 var currentCtx = this.ctx;
8571 // TODO non-isolated groups - according to Rik at adobe non-isolated
8572 // group results aren't usually that different and they even have tools
8573 // that ignore this setting. Notes from Rik on implementing:
8574 // - When you encounter an transparency group, create a new canvas with
8575 // the dimensions of the bbox
8576 // - copy the content from the previous canvas to the new canvas
8577 // - draw as usual
8578 // - remove the backdrop alpha:
8579 // alphaNew = 1 - (1 - alpha)/(1 - alphaBackdrop) with 'alpha' the alpha
8580 // value of your transparency group and 'alphaBackdrop' the alpha of the
8581 // backdrop
8582 // - remove background color:
8583 // colorNew = color - alphaNew *colorBackdrop /(1 - alphaNew)
8584 if (!group.isolated) {
8585 info('TODO: Support non-isolated groups.');
8586 }
8587
8588 // TODO knockout - supposedly possible with the clever use of compositing
8589 // modes.
8590 if (group.knockout) {
8591 warn('Knockout groups not supported.');
8592 }
8593
8594 var currentTransform = currentCtx.mozCurrentTransform;
8595 if (group.matrix) {
8596 currentCtx.transform.apply(currentCtx, group.matrix);
8597 }
8598 assert(group.bbox, 'Bounding box is required.');
8599
8600 // Based on the current transform figure out how big the bounding box
8601 // will actually be.
8602 var bounds = Util.getAxialAlignedBoundingBox(
8603 group.bbox,
8604 currentCtx.mozCurrentTransform);
8605 // Clip the bounding box to the current canvas.
8606 var canvasBounds = [0,
8607 0,
8608 currentCtx.canvas.width,
8609 currentCtx.canvas.height];
8610 bounds = Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0];
8611 // Use ceil in case we're between sizes so we don't create canvas that is
8612 // too small and make the canvas at least 1x1 pixels.
8613 var offsetX = Math.floor(bounds[0]);
8614 var offsetY = Math.floor(bounds[1]);
8615 var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
8616 var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
8617 var scaleX = 1, scaleY = 1;
8618 if (drawnWidth > MAX_GROUP_SIZE) {
8619 scaleX = drawnWidth / MAX_GROUP_SIZE;
8620 drawnWidth = MAX_GROUP_SIZE;
8621 }
8622 if (drawnHeight > MAX_GROUP_SIZE) {
8623 scaleY = drawnHeight / MAX_GROUP_SIZE;
8624 drawnHeight = MAX_GROUP_SIZE;
8625 }
8626
8627 var cacheId = 'groupAt' + this.groupLevel;
8628 if (group.smask) {
8629 // Using two cache entries is case if masks are used one after another.
8630 cacheId += '_smask_' + ((this.smaskCounter++) % 2);
8631 }
8632 var scratchCanvas = this.cachedCanvases.getCanvas(
8633 cacheId, drawnWidth, drawnHeight, true);
8634 var groupCtx = scratchCanvas.context;
8635
8636 // Since we created a new canvas that is just the size of the bounding box
8637 // we have to translate the group ctx.
8638 groupCtx.scale(1 / scaleX, 1 / scaleY);
8639 groupCtx.translate(-offsetX, -offsetY);
8640 groupCtx.transform.apply(groupCtx, currentTransform);
8641
8642 if (group.smask) {
8643 // Saving state and cached mask to be used in setGState.
8644 this.smaskStack.push({
8645 canvas: scratchCanvas.canvas,
8646 context: groupCtx,
8647 offsetX: offsetX,
8648 offsetY: offsetY,
8649 scaleX: scaleX,
8650 scaleY: scaleY,
8651 subtype: group.smask.subtype,
8652 backdrop: group.smask.backdrop,
8653 transferMap: group.smask.transferMap || null,
8654 startTransformInverse: null, // used during suspend operation
8655 });
8656 } else {
8657 // Setup the current ctx so when the group is popped we draw it at the
8658 // right location.
8659 currentCtx.setTransform(1, 0, 0, 1, 0, 0);
8660 currentCtx.translate(offsetX, offsetY);
8661 currentCtx.scale(scaleX, scaleY);
8662 }
8663 // The transparency group inherits all off the current graphics state
8664 // except the blend mode, soft mask, and alpha constants.
8665 copyCtxState(currentCtx, groupCtx);
8666 this.ctx = groupCtx;
8667 this.setGState([
8668 ['BM', 'Normal'],
8669 ['ca', 1],
8670 ['CA', 1]
8671 ]);
8672 this.groupStack.push(currentCtx);
8673 this.groupLevel++;
8674
8675 // Reseting mask state, masks will be applied on restore of the group.
8676 this.current.activeSMask = null;
8677 },
8678
8679 endGroup: function CanvasGraphics_endGroup(group) {
8680 this.groupLevel--;
8681 var groupCtx = this.ctx;
8682 this.ctx = this.groupStack.pop();
8683 // Turn off image smoothing to avoid sub pixel interpolation which can
8684 // look kind of blurry for some pdfs.
8685 if (this.ctx.imageSmoothingEnabled !== undefined) {
8686 this.ctx.imageSmoothingEnabled = false;
8687 } else {
8688 this.ctx.mozImageSmoothingEnabled = false;
8689 }
8690 if (group.smask) {
8691 this.tempSMask = this.smaskStack.pop();
8692 } else {
8693 this.ctx.drawImage(groupCtx.canvas, 0, 0);
8694 }
8695 this.restore();
8696 },
8697
8698 beginAnnotations: function CanvasGraphics_beginAnnotations() {
8699 this.save();
8700 this.current = new CanvasExtraState();
8701
8702 if (this.baseTransform) {
8703 this.ctx.setTransform.apply(this.ctx, this.baseTransform);
8704 }
8705 },
8706
8707 endAnnotations: function CanvasGraphics_endAnnotations() {
8708 this.restore();
8709 },
8710
8711 beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform,
8712 matrix) {
8713 this.save();
8714
8715 if (isArray(rect) && 4 === rect.length) {
8716 var width = rect[2] - rect[0];
8717 var height = rect[3] - rect[1];
8718 this.ctx.rect(rect[0], rect[1], width, height);
8719 this.clip();
8720 this.endPath();
8721 }
8722
8723 this.transform.apply(this, transform);
8724 this.transform.apply(this, matrix);
8725 },
8726
8727 endAnnotation: function CanvasGraphics_endAnnotation() {
8728 this.restore();
8729 },
8730
8731 paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
8732 var domImage = this.objs.get(objId);
8733 if (!domImage) {
8734 warn('Dependent image isn\'t ready yet');
8735 return;
8736 }
8737
8738 this.save();
8739
8740 var ctx = this.ctx;
8741 // scale the image to the unit square
8742 ctx.scale(1 / w, -1 / h);
8743
8744 ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height,
8745 0, -h, w, h);
8746 if (this.imageLayer) {
8747 var currentTransform = ctx.mozCurrentTransformInverse;
8748 var position = this.getCanvasPosition(0, 0);
8749 this.imageLayer.appendImage({
8750 objId: objId,
8751 left: position[0],
8752 top: position[1],
8753 width: w / currentTransform[0],
8754 height: h / currentTransform[3]
8755 });
8756 }
8757 this.restore();
8758 },
8759
8760 paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
8761 var ctx = this.ctx;
8762 var width = img.width, height = img.height;
8763 var fillColor = this.current.fillColor;
8764 var isPatternFill = this.current.patternFill;
8765
8766 var glyph = this.processingType3;
8767
8768 if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
8769 if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
8770 glyph.compiled =
8771 compileType3Glyph({data: img.data, width: width, height: height});
8772 } else {
8773 glyph.compiled = null;
8774 }
8775 }
8776
8777 if (glyph && glyph.compiled) {
8778 glyph.compiled(ctx);
8779 return;
8780 }
8781
8782 var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas',
8783 width, height);
8784 var maskCtx = maskCanvas.context;
8785 maskCtx.save();
8786
8787 putBinaryImageMask(maskCtx, img);
8788
8789 maskCtx.globalCompositeOperation = 'source-in';
8790
8791 maskCtx.fillStyle = isPatternFill ?
8792 fillColor.getPattern(maskCtx, this) : fillColor;
8793 maskCtx.fillRect(0, 0, width, height);
8794
8795 maskCtx.restore();
8796
8797 this.paintInlineImageXObject(maskCanvas.canvas);
8798 },
8799
8800 paintImageMaskXObjectRepeat:
8801 function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX,
8802 scaleY, positions) {
8803 var width = imgData.width;
8804 var height = imgData.height;
8805 var fillColor = this.current.fillColor;
8806 var isPatternFill = this.current.patternFill;
8807
8808 var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas',
8809 width, height);
8810 var maskCtx = maskCanvas.context;
8811 maskCtx.save();
8812
8813 putBinaryImageMask(maskCtx, imgData);
8814
8815 maskCtx.globalCompositeOperation = 'source-in';
8816
8817 maskCtx.fillStyle = isPatternFill ?
8818 fillColor.getPattern(maskCtx, this) : fillColor;
8819 maskCtx.fillRect(0, 0, width, height);
8820
8821 maskCtx.restore();
8822
8823 var ctx = this.ctx;
8824 for (var i = 0, ii = positions.length; i < ii; i += 2) {
8825 ctx.save();
8826 ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
8827 ctx.scale(1, -1);
8828 ctx.drawImage(maskCanvas.canvas, 0, 0, width, height,
8829 0, -1, 1, 1);
8830 ctx.restore();
8831 }
8832 },
8833
8834 paintImageMaskXObjectGroup:
8835 function CanvasGraphics_paintImageMaskXObjectGroup(images) {
8836 var ctx = this.ctx;
8837
8838 var fillColor = this.current.fillColor;
8839 var isPatternFill = this.current.patternFill;
8840 for (var i = 0, ii = images.length; i < ii; i++) {
8841 var image = images[i];
8842 var width = image.width, height = image.height;
8843
8844 var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas',
8845 width, height);
8846 var maskCtx = maskCanvas.context;
8847 maskCtx.save();
8848
8849 putBinaryImageMask(maskCtx, image);
8850
8851 maskCtx.globalCompositeOperation = 'source-in';
8852
8853 maskCtx.fillStyle = isPatternFill ?
8854 fillColor.getPattern(maskCtx, this) : fillColor;
8855 maskCtx.fillRect(0, 0, width, height);
8856
8857 maskCtx.restore();
8858
8859 ctx.save();
8860 ctx.transform.apply(ctx, image.transform);
8861 ctx.scale(1, -1);
8862 ctx.drawImage(maskCanvas.canvas, 0, 0, width, height,
8863 0, -1, 1, 1);
8864 ctx.restore();
8865 }
8866 },
8867
8868 paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
8869 var imgData = this.objs.get(objId);
8870 if (!imgData) {
8871 warn('Dependent image isn\'t ready yet');
8872 return;
8873 }
8874
8875 this.paintInlineImageXObject(imgData);
8876 },
8877
8878 paintImageXObjectRepeat:
8879 function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY,
8880 positions) {
8881 var imgData = this.objs.get(objId);
8882 if (!imgData) {
8883 warn('Dependent image isn\'t ready yet');
8884 return;
8885 }
8886
8887 var width = imgData.width;
8888 var height = imgData.height;
8889 var map = [];
8890 for (var i = 0, ii = positions.length; i < ii; i += 2) {
8891 map.push({transform: [scaleX, 0, 0, scaleY, positions[i],
8892 positions[i + 1]], x: 0, y: 0, w: width, h: height});
8893 }
8894 this.paintInlineImageXObjectGroup(imgData, map);
8895 },
8896
8897 paintInlineImageXObject:
8898 function CanvasGraphics_paintInlineImageXObject(imgData) {
8899 var width = imgData.width;
8900 var height = imgData.height;
8901 var ctx = this.ctx;
8902
8903 this.save();
8904 // scale the image to the unit square
8905 ctx.scale(1 / width, -1 / height);
8906
8907 var currentTransform = ctx.mozCurrentTransformInverse;
8908 var a = currentTransform[0], b = currentTransform[1];
8909 var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
8910 var c = currentTransform[2], d = currentTransform[3];
8911 var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
8912
8913 var imgToPaint, tmpCanvas;
8914 // instanceof HTMLElement does not work in jsdom node.js module
8915 if (imgData instanceof HTMLElement || !imgData.data) {
8916 imgToPaint = imgData;
8917 } else {
8918 tmpCanvas = this.cachedCanvases.getCanvas('inlineImage',
8919 width, height);
8920 var tmpCtx = tmpCanvas.context;
8921 putBinaryImageData(tmpCtx, imgData);
8922 imgToPaint = tmpCanvas.canvas;
8923 }
8924
8925 var paintWidth = width, paintHeight = height;
8926 var tmpCanvasId = 'prescale1';
8927 // Vertial or horizontal scaling shall not be more than 2 to not loose the
8928 // pixels during drawImage operation, painting on the temporary canvas(es)
8929 // that are twice smaller in size
8930 while ((widthScale > 2 && paintWidth > 1) ||
8931 (heightScale > 2 && paintHeight > 1)) {
8932 var newWidth = paintWidth, newHeight = paintHeight;
8933 if (widthScale > 2 && paintWidth > 1) {
8934 newWidth = Math.ceil(paintWidth / 2);
8935 widthScale /= paintWidth / newWidth;
8936 }
8937 if (heightScale > 2 && paintHeight > 1) {
8938 newHeight = Math.ceil(paintHeight / 2);
8939 heightScale /= paintHeight / newHeight;
8940 }
8941 tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId,
8942 newWidth, newHeight);
8943 tmpCtx = tmpCanvas.context;
8944 tmpCtx.clearRect(0, 0, newWidth, newHeight);
8945 tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight,
8946 0, 0, newWidth, newHeight);
8947 imgToPaint = tmpCanvas.canvas;
8948 paintWidth = newWidth;
8949 paintHeight = newHeight;
8950 tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
8951 }
8952 ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight,
8953 0, -height, width, height);
8954
8955 if (this.imageLayer) {
8956 var position = this.getCanvasPosition(0, -height);
8957 this.imageLayer.appendImage({
8958 imgData: imgData,
8959 left: position[0],
8960 top: position[1],
8961 width: width / currentTransform[0],
8962 height: height / currentTransform[3]
8963 });
8964 }
8965 this.restore();
8966 },
8967
8968 paintInlineImageXObjectGroup:
8969 function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
8970 var ctx = this.ctx;
8971 var w = imgData.width;
8972 var h = imgData.height;
8973
8974 var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
8975 var tmpCtx = tmpCanvas.context;
8976 putBinaryImageData(tmpCtx, imgData);
8977
8978 for (var i = 0, ii = map.length; i < ii; i++) {
8979 var entry = map[i];
8980 ctx.save();
8981 ctx.transform.apply(ctx, entry.transform);
8982 ctx.scale(1, -1);
8983 ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h,
8984 0, -1, 1, 1);
8985 if (this.imageLayer) {
8986 var position = this.getCanvasPosition(entry.x, entry.y);
8987 this.imageLayer.appendImage({
8988 imgData: imgData,
8989 left: position[0],
8990 top: position[1],
8991 width: w,
8992 height: h
8993 });
8994 }
8995 ctx.restore();
8996 }
8997 },
8998
8999 paintSolidColorImageMask:
9000 function CanvasGraphics_paintSolidColorImageMask() {
9001 this.ctx.fillRect(0, 0, 1, 1);
9002 },
9003
9004 paintXObject: function CanvasGraphics_paintXObject() {
9005 warn('Unsupported \'paintXObject\' command.');
9006 },
9007
9008 // Marked content
9009
9010 markPoint: function CanvasGraphics_markPoint(tag) {
9011 // TODO Marked content.
9012 },
9013 markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
9014 // TODO Marked content.
9015 },
9016 beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
9017 // TODO Marked content.
9018 },
9019 beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(
9020 tag, properties) {
9021 // TODO Marked content.
9022 },
9023 endMarkedContent: function CanvasGraphics_endMarkedContent() {
9024 // TODO Marked content.
9025 },
9026
9027 // Compatibility
9028
9029 beginCompat: function CanvasGraphics_beginCompat() {
9030 // TODO ignore undefined operators (should we do that anyway?)
9031 },
9032 endCompat: function CanvasGraphics_endCompat() {
9033 // TODO stop ignoring undefined operators
9034 },
9035
9036 // Helper functions
9037
9038 consumePath: function CanvasGraphics_consumePath() {
9039 var ctx = this.ctx;
9040 if (this.pendingClip) {
9041 if (this.pendingClip === EO_CLIP) {
9042 if (ctx.mozFillRule !== undefined) {
9043 ctx.mozFillRule = 'evenodd';
9044 ctx.clip();
9045 ctx.mozFillRule = 'nonzero';
9046 } else {
9047 ctx.clip('evenodd');
9048 }
9049 } else {
9050 ctx.clip();
9051 }
9052 this.pendingClip = null;
9053 }
9054 ctx.beginPath();
9055 },
9056 getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
9057 if (this.cachedGetSinglePixelWidth === null) {
9058 // NOTE: The `save` and `restore` commands used below is a workaround
9059 // that is necessary in order to prevent `mozCurrentTransformInverse`
9060 // from intermittently returning incorrect values in Firefox, see:
9061 // https://github.com/mozilla/pdf.js/issues/7188.
9062 this.ctx.save();
9063 var inverse = this.ctx.mozCurrentTransformInverse;
9064 this.ctx.restore();
9065 // max of the current horizontal and vertical scale
9066 this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(
9067 (inverse[0] * inverse[0] + inverse[1] * inverse[1]),
9068 (inverse[2] * inverse[2] + inverse[3] * inverse[3])));
9069 }
9070 return this.cachedGetSinglePixelWidth;
9071 },
9072 getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
9073 var transform = this.ctx.mozCurrentTransform;
9074 return [
9075 transform[0] * x + transform[2] * y + transform[4],
9076 transform[1] * x + transform[3] * y + transform[5]
9077 ];
9078 }
9079 };
9080
9081 for (var op in OPS) {
9082 CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
9083 }
9084
9085 return CanvasGraphics;
9086})();
9087
9088exports.CanvasGraphics = CanvasGraphics;
9089exports.createScratchCanvas = createScratchCanvas;
9090}));
9091
9092
9093(function (root, factory) {
9094 {
9095 factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil,
9096 root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas,
9097 root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
9098 }
9099}(this, function (exports, sharedUtil, displayFontLoader, displayCanvas,
9100 displayMetadata, displayDOMUtils, amdRequire) {
9101
9102var InvalidPDFException = sharedUtil.InvalidPDFException;
9103var MessageHandler = sharedUtil.MessageHandler;
9104var MissingPDFException = sharedUtil.MissingPDFException;
9105var PageViewport = sharedUtil.PageViewport;
9106var PasswordResponses = sharedUtil.PasswordResponses;
9107var PasswordException = sharedUtil.PasswordException;
9108var StatTimer = sharedUtil.StatTimer;
9109var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
9110var UnknownErrorException = sharedUtil.UnknownErrorException;
9111var Util = sharedUtil.Util;
9112var createPromiseCapability = sharedUtil.createPromiseCapability;
9113var error = sharedUtil.error;
9114var deprecated = sharedUtil.deprecated;
9115var getVerbosityLevel = sharedUtil.getVerbosityLevel;
9116var info = sharedUtil.info;
9117var isInt = sharedUtil.isInt;
9118var isArray = sharedUtil.isArray;
9119var isArrayBuffer = sharedUtil.isArrayBuffer;
9120var isSameOrigin = sharedUtil.isSameOrigin;
9121var loadJpegStream = sharedUtil.loadJpegStream;
9122var stringToBytes = sharedUtil.stringToBytes;
9123var globalScope = sharedUtil.globalScope;
9124var warn = sharedUtil.warn;
9125var FontFaceObject = displayFontLoader.FontFaceObject;
9126var FontLoader = displayFontLoader.FontLoader;
9127var CanvasGraphics = displayCanvas.CanvasGraphics;
9128var createScratchCanvas = displayCanvas.createScratchCanvas;
9129var Metadata = displayMetadata.Metadata;
9130var getDefaultSetting = displayDOMUtils.getDefaultSetting;
9131
9132var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
9133
9134var isWorkerDisabled = false;
9135var workerSrc;
9136var isPostMessageTransfersDisabled = false;
9137
9138
9139var useRequireEnsure = false;
9140if (typeof window === 'undefined') {
9141 // node.js - disable worker and set require.ensure.
9142 isWorkerDisabled = true;
9143 if (typeof require.ensure === 'undefined') {
9144 require.ensure = require('node-ensure');
9145 }
9146 useRequireEnsure = true;
9147}
9148if (typeof __webpack_require__ !== 'undefined') {
9149 useRequireEnsure = true;
9150}
9151if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
9152 workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
9153}
9154var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
9155var fakeWorkerFilesLoader = useRequireEnsure ? (function (callback) {
9156 require.ensure([], function () {
9157 var worker = require('./pdf.worker.js');
9158 callback(worker.WorkerMessageHandler);
9159 });
9160}) : dynamicLoaderSupported ? (function (callback) {
9161 requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
9162 callback(worker.WorkerMessageHandler);
9163 });
9164}) : null;
9165
9166
9167/**
9168 * Document initialization / loading parameters object.
9169 *
9170 * @typedef {Object} DocumentInitParameters
9171 * @property {string} url - The URL of the PDF.
9172 * @property {TypedArray|Array|string} data - Binary PDF data. Use typed arrays
9173 * (Uint8Array) to improve the memory usage. If PDF data is BASE64-encoded,
9174 * use atob() to convert it to a binary string first.
9175 * @property {Object} httpHeaders - Basic authentication headers.
9176 * @property {boolean} withCredentials - Indicates whether or not cross-site
9177 * Access-Control requests should be made using credentials such as cookies
9178 * or authorization headers. The default is false.
9179 * @property {string} password - For decrypting password-protected PDFs.
9180 * @property {TypedArray} initialData - A typed array with the first portion or
9181 * all of the pdf data. Used by the extension since some data is already
9182 * loaded before the switch to range requests.
9183 * @property {number} length - The PDF file length. It's used for progress
9184 * reports and range requests operations.
9185 * @property {PDFDataRangeTransport} range
9186 * @property {number} rangeChunkSize - Optional parameter to specify
9187 * maximum number of bytes fetched per range request. The default value is
9188 * 2^16 = 65536.
9189 * @property {PDFWorker} worker - The worker that will be used for the loading
9190 * and parsing of the PDF data.
9191 */
9192
9193/**
9194 * @typedef {Object} PDFDocumentStats
9195 * @property {Array} streamTypes - Used stream types in the document (an item
9196 * is set to true if specific stream ID was used in the document).
9197 * @property {Array} fontTypes - Used font type in the document (an item is set
9198 * to true if specific font ID was used in the document).
9199 */
9200
9201/**
9202 * This is the main entry point for loading a PDF and interacting with it.
9203 * NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR)
9204 * is used, which means it must follow the same origin rules that any XHR does
9205 * e.g. No cross domain requests without CORS.
9206 *
9207 * @param {string|TypedArray|DocumentInitParameters|PDFDataRangeTransport} src
9208 * Can be a url to where a PDF is located, a typed array (Uint8Array)
9209 * already populated with data or parameter object.
9210 *
9211 * @param {PDFDataRangeTransport} pdfDataRangeTransport (deprecated) It is used
9212 * if you want to manually serve range requests for data in the PDF.
9213 *
9214 * @param {function} passwordCallback (deprecated) It is used to request a
9215 * password if wrong or no password was provided. The callback receives two
9216 * parameters: function that needs to be called with new password and reason
9217 * (see {PasswordResponses}).
9218 *
9219 * @param {function} progressCallback (deprecated) It is used to be able to
9220 * monitor the loading progress of the PDF file (necessary to implement e.g.
9221 * a loading bar). The callback receives an {Object} with the properties:
9222 * {number} loaded and {number} total.
9223 *
9224 * @return {PDFDocumentLoadingTask}
9225 */
9226function getDocument(src, pdfDataRangeTransport,
9227 passwordCallback, progressCallback) {
9228 var task = new PDFDocumentLoadingTask();
9229
9230 // Support of the obsolete arguments (for compatibility with API v1.0)
9231 if (arguments.length > 1) {
9232 deprecated('getDocument is called with pdfDataRangeTransport, ' +
9233 'passwordCallback or progressCallback argument');
9234 }
9235 if (pdfDataRangeTransport) {
9236 if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
9237 // Not a PDFDataRangeTransport instance, trying to add missing properties.
9238 pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
9239 pdfDataRangeTransport.length = src.length;
9240 pdfDataRangeTransport.initialData = src.initialData;
9241 if (!pdfDataRangeTransport.abort) {
9242 pdfDataRangeTransport.abort = function () {};
9243 }
9244 }
9245 src = Object.create(src);
9246 src.range = pdfDataRangeTransport;
9247 }
9248 task.onPassword = passwordCallback || null;
9249 task.onProgress = progressCallback || null;
9250
9251 var source;
9252 if (typeof src === 'string') {
9253 source = { url: src };
9254 } else if (isArrayBuffer(src)) {
9255 source = { data: src };
9256 } else if (src instanceof PDFDataRangeTransport) {
9257 source = { range: src };
9258 } else {
9259 if (typeof src !== 'object') {
9260 error('Invalid parameter in getDocument, need either Uint8Array, ' +
9261 'string or a parameter object');
9262 }
9263 if (!src.url && !src.data && !src.range) {
9264 error('Invalid parameter object: need either .data, .range or .url');
9265 }
9266
9267 source = src;
9268 }
9269
9270 var params = {};
9271 var rangeTransport = null;
9272 var worker = null;
9273 for (var key in source) {
9274 if (key === 'url' && typeof window !== 'undefined') {
9275 // The full path is required in the 'url' field.
9276 params[key] = new URL(source[key], window.location).href;
9277 continue;
9278 } else if (key === 'range') {
9279 rangeTransport = source[key];
9280 continue;
9281 } else if (key === 'worker') {
9282 worker = source[key];
9283 continue;
9284 } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
9285 // Converting string or array-like data to Uint8Array.
9286 var pdfBytes = source[key];
9287 if (typeof pdfBytes === 'string') {
9288 params[key] = stringToBytes(pdfBytes);
9289 } else if (typeof pdfBytes === 'object' && pdfBytes !== null &&
9290 !isNaN(pdfBytes.length)) {
9291 params[key] = new Uint8Array(pdfBytes);
9292 } else if (isArrayBuffer(pdfBytes)) {
9293 params[key] = new Uint8Array(pdfBytes);
9294 } else {
9295 error('Invalid PDF binary data: either typed array, string or ' +
9296 'array-like object is expected in the data property.');
9297 }
9298 continue;
9299 }
9300 params[key] = source[key];
9301 }
9302
9303 params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
9304
9305 if (!worker) {
9306 // Worker was not provided -- creating and owning our own.
9307 worker = new PDFWorker();
9308 task._worker = worker;
9309 }
9310 var docId = task.docId;
9311 worker.promise.then(function () {
9312 if (task.destroyed) {
9313 throw new Error('Loading aborted');
9314 }
9315 return _fetchDocument(worker, params, rangeTransport, docId).then(
9316 function (workerId) {
9317 if (task.destroyed) {
9318 throw new Error('Loading aborted');
9319 }
9320 var messageHandler = new MessageHandler(docId, workerId, worker.port);
9321 var transport = new WorkerTransport(messageHandler, task, rangeTransport);
9322 task._transport = transport;
9323 messageHandler.send('Ready', null);
9324 });
9325 }).catch(task._capability.reject);
9326
9327 return task;
9328}
9329
9330/**
9331 * Starts fetching of specified PDF document/data.
9332 * @param {PDFWorker} worker
9333 * @param {Object} source
9334 * @param {PDFDataRangeTransport} pdfDataRangeTransport
9335 * @param {string} docId Unique document id, used as MessageHandler id.
9336 * @returns {Promise} The promise, which is resolved when worker id of
9337 * MessageHandler is known.
9338 * @private
9339 */
9340function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
9341 if (worker.destroyed) {
9342 return Promise.reject(new Error('Worker was destroyed'));
9343 }
9344
9345 source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
9346 source.disableStream = getDefaultSetting('disableStream');
9347 source.chunkedViewerLoading = !!pdfDataRangeTransport;
9348 if (pdfDataRangeTransport) {
9349 source.length = pdfDataRangeTransport.length;
9350 source.initialData = pdfDataRangeTransport.initialData;
9351 }
9352 return worker.messageHandler.sendWithPromise('GetDocRequest', {
9353 docId: docId,
9354 source: source,
9355 disableRange: getDefaultSetting('disableRange'),
9356 maxImageSize: getDefaultSetting('maxImageSize'),
9357 cMapUrl: getDefaultSetting('cMapUrl'),
9358 cMapPacked: getDefaultSetting('cMapPacked'),
9359 disableFontFace: getDefaultSetting('disableFontFace'),
9360 disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
9361 postMessageTransfers: getDefaultSetting('postMessageTransfers') &&
9362 !isPostMessageTransfersDisabled,
9363 }).then(function (workerId) {
9364 if (worker.destroyed) {
9365 throw new Error('Worker was destroyed');
9366 }
9367 return workerId;
9368 });
9369}
9370
9371/**
9372 * PDF document loading operation.
9373 * @class
9374 * @alias PDFDocumentLoadingTask
9375 */
9376var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
9377 var nextDocumentId = 0;
9378
9379 /** @constructs PDFDocumentLoadingTask */
9380 function PDFDocumentLoadingTask() {
9381 this._capability = createPromiseCapability();
9382 this._transport = null;
9383 this._worker = null;
9384
9385 /**
9386 * Unique document loading task id -- used in MessageHandlers.
9387 * @type {string}
9388 */
9389 this.docId = 'd' + (nextDocumentId++);
9390
9391 /**
9392 * Shows if loading task is destroyed.
9393 * @type {boolean}
9394 */
9395 this.destroyed = false;
9396
9397 /**
9398 * Callback to request a password if wrong or no password was provided.
9399 * The callback receives two parameters: function that needs to be called
9400 * with new password and reason (see {PasswordResponses}).
9401 */
9402 this.onPassword = null;
9403
9404 /**
9405 * Callback to be able to monitor the loading progress of the PDF file
9406 * (necessary to implement e.g. a loading bar). The callback receives
9407 * an {Object} with the properties: {number} loaded and {number} total.
9408 */
9409 this.onProgress = null;
9410
9411 /**
9412 * Callback to when unsupported feature is used. The callback receives
9413 * an {UNSUPPORTED_FEATURES} argument.
9414 */
9415 this.onUnsupportedFeature = null;
9416 }
9417
9418 PDFDocumentLoadingTask.prototype =
9419 /** @lends PDFDocumentLoadingTask.prototype */ {
9420 /**
9421 * @return {Promise}
9422 */
9423 get promise() {
9424 return this._capability.promise;
9425 },
9426
9427 /**
9428 * Aborts all network requests and destroys worker.
9429 * @return {Promise} A promise that is resolved after destruction activity
9430 * is completed.
9431 */
9432 destroy: function () {
9433 this.destroyed = true;
9434
9435 var transportDestroyed = !this._transport ? Promise.resolve() :
9436 this._transport.destroy();
9437 return transportDestroyed.then(function () {
9438 this._transport = null;
9439 if (this._worker) {
9440 this._worker.destroy();
9441 this._worker = null;
9442 }
9443 }.bind(this));
9444 },
9445
9446 /**
9447 * Registers callbacks to indicate the document loading completion.
9448 *
9449 * @param {function} onFulfilled The callback for the loading completion.
9450 * @param {function} onRejected The callback for the loading failure.
9451 * @return {Promise} A promise that is resolved after the onFulfilled or
9452 * onRejected callback.
9453 */
9454 then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
9455 return this.promise.then.apply(this.promise, arguments);
9456 }
9457 };
9458
9459 return PDFDocumentLoadingTask;
9460})();
9461
9462/**
9463 * Abstract class to support range requests file loading.
9464 * @class
9465 * @alias PDFDataRangeTransport
9466 * @param {number} length
9467 * @param {Uint8Array} initialData
9468 */
9469var PDFDataRangeTransport = (function pdfDataRangeTransportClosure() {
9470 function PDFDataRangeTransport(length, initialData) {
9471 this.length = length;
9472 this.initialData = initialData;
9473
9474 this._rangeListeners = [];
9475 this._progressListeners = [];
9476 this._progressiveReadListeners = [];
9477 this._readyCapability = createPromiseCapability();
9478 }
9479 PDFDataRangeTransport.prototype =
9480 /** @lends PDFDataRangeTransport.prototype */ {
9481 addRangeListener:
9482 function PDFDataRangeTransport_addRangeListener(listener) {
9483 this._rangeListeners.push(listener);
9484 },
9485
9486 addProgressListener:
9487 function PDFDataRangeTransport_addProgressListener(listener) {
9488 this._progressListeners.push(listener);
9489 },
9490
9491 addProgressiveReadListener:
9492 function PDFDataRangeTransport_addProgressiveReadListener(listener) {
9493 this._progressiveReadListeners.push(listener);
9494 },
9495
9496 onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
9497 var listeners = this._rangeListeners;
9498 for (var i = 0, n = listeners.length; i < n; ++i) {
9499 listeners[i](begin, chunk);
9500 }
9501 },
9502
9503 onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
9504 this._readyCapability.promise.then(function () {
9505 var listeners = this._progressListeners;
9506 for (var i = 0, n = listeners.length; i < n; ++i) {
9507 listeners[i](loaded);
9508 }
9509 }.bind(this));
9510 },
9511
9512 onDataProgressiveRead:
9513 function PDFDataRangeTransport_onDataProgress(chunk) {
9514 this._readyCapability.promise.then(function () {
9515 var listeners = this._progressiveReadListeners;
9516 for (var i = 0, n = listeners.length; i < n; ++i) {
9517 listeners[i](chunk);
9518 }
9519 }.bind(this));
9520 },
9521
9522 transportReady: function PDFDataRangeTransport_transportReady() {
9523 this._readyCapability.resolve();
9524 },
9525
9526 requestDataRange:
9527 function PDFDataRangeTransport_requestDataRange(begin, end) {
9528 throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
9529 },
9530
9531 abort: function PDFDataRangeTransport_abort() {
9532 }
9533 };
9534 return PDFDataRangeTransport;
9535})();
9536
9537/**
9538 * Proxy to a PDFDocument in the worker thread. Also, contains commonly used
9539 * properties that can be read synchronously.
9540 * @class
9541 * @alias PDFDocumentProxy
9542 */
9543var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
9544 function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
9545 this.pdfInfo = pdfInfo;
9546 this.transport = transport;
9547 this.loadingTask = loadingTask;
9548 }
9549 PDFDocumentProxy.prototype = /** @lends PDFDocumentProxy.prototype */ {
9550 /**
9551 * @return {number} Total number of pages the PDF contains.
9552 */
9553 get numPages() {
9554 return this.pdfInfo.numPages;
9555 },
9556 /**
9557 * @return {string} A unique ID to identify a PDF. Not guaranteed to be
9558 * unique.
9559 */
9560 get fingerprint() {
9561 return this.pdfInfo.fingerprint;
9562 },
9563 /**
9564 * @param {number} pageNumber The page number to get. The first page is 1.
9565 * @return {Promise} A promise that is resolved with a {@link PDFPageProxy}
9566 * object.
9567 */
9568 getPage: function PDFDocumentProxy_getPage(pageNumber) {
9569 return this.transport.getPage(pageNumber);
9570 },
9571 /**
9572 * @param {{num: number, gen: number}} ref The page reference. Must have
9573 * the 'num' and 'gen' properties.
9574 * @return {Promise} A promise that is resolved with the page index that is
9575 * associated with the reference.
9576 */
9577 getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
9578 return this.transport.getPageIndex(ref);
9579 },
9580 /**
9581 * @return {Promise} A promise that is resolved with a lookup table for
9582 * mapping named destinations to reference numbers.
9583 *
9584 * This can be slow for large documents: use getDestination instead
9585 */
9586 getDestinations: function PDFDocumentProxy_getDestinations() {
9587 return this.transport.getDestinations();
9588 },
9589 /**
9590 * @param {string} id The named destination to get.
9591 * @return {Promise} A promise that is resolved with all information
9592 * of the given named destination.
9593 */
9594 getDestination: function PDFDocumentProxy_getDestination(id) {
9595 return this.transport.getDestination(id);
9596 },
9597 /**
9598 * @return {Promise} A promise that is resolved with:
9599 * an Array containing the pageLabels that correspond to the pageIndexes,
9600 * or `null` when no pageLabels are present in the PDF file.
9601 */
9602 getPageLabels: function PDFDocumentProxy_getPageLabels() {
9603 return this.transport.getPageLabels();
9604 },
9605 /**
9606 * @return {Promise} A promise that is resolved with a lookup table for
9607 * mapping named attachments to their content.
9608 */
9609 getAttachments: function PDFDocumentProxy_getAttachments() {
9610 return this.transport.getAttachments();
9611 },
9612 /**
9613 * @return {Promise} A promise that is resolved with an array of all the
9614 * JavaScript strings in the name tree.
9615 */
9616 getJavaScript: function PDFDocumentProxy_getJavaScript() {
9617 return this.transport.getJavaScript();
9618 },
9619 /**
9620 * @return {Promise} A promise that is resolved with an {Array} that is a
9621 * tree outline (if it has one) of the PDF. The tree is in the format of:
9622 * [
9623 * {
9624 * title: string,
9625 * bold: boolean,
9626 * italic: boolean,
9627 * color: rgb Uint8Array,
9628 * dest: dest obj,
9629 * url: string,
9630 * items: array of more items like this
9631 * },
9632 * ...
9633 * ].
9634 */
9635 getOutline: function PDFDocumentProxy_getOutline() {
9636 return this.transport.getOutline();
9637 },
9638 /**
9639 * @return {Promise} A promise that is resolved with an {Object} that has
9640 * info and metadata properties. Info is an {Object} filled with anything
9641 * available in the information dictionary and similarly metadata is a
9642 * {Metadata} object with information from the metadata section of the PDF.
9643 */
9644 getMetadata: function PDFDocumentProxy_getMetadata() {
9645 return this.transport.getMetadata();
9646 },
9647 /**
9648 * @return {Promise} A promise that is resolved with a TypedArray that has
9649 * the raw data from the PDF.
9650 */
9651 getData: function PDFDocumentProxy_getData() {
9652 return this.transport.getData();
9653 },
9654 /**
9655 * @return {Promise} A promise that is resolved when the document's data
9656 * is loaded. It is resolved with an {Object} that contains the length
9657 * property that indicates size of the PDF data in bytes.
9658 */
9659 getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
9660 return this.transport.downloadInfoCapability.promise;
9661 },
9662 /**
9663 * @return {Promise} A promise this is resolved with current stats about
9664 * document structures (see {@link PDFDocumentStats}).
9665 */
9666 getStats: function PDFDocumentProxy_getStats() {
9667 return this.transport.getStats();
9668 },
9669 /**
9670 * Cleans up resources allocated by the document, e.g. created @font-face.
9671 */
9672 cleanup: function PDFDocumentProxy_cleanup() {
9673 this.transport.startCleanup();
9674 },
9675 /**
9676 * Destroys current document instance and terminates worker.
9677 */
9678 destroy: function PDFDocumentProxy_destroy() {
9679 return this.loadingTask.destroy();
9680 }
9681 };
9682 return PDFDocumentProxy;
9683})();
9684
9685/**
9686 * Page getTextContent parameters.
9687 *
9688 * @typedef {Object} getTextContentParameters
9689 * @param {boolean} normalizeWhitespace - replaces all occurrences of
9690 * whitespace with standard spaces (0x20). The default value is `false`.
9691 * @param {boolean} disableCombineTextItems - do not attempt to combine
9692 * same line {@link TextItem}'s. The default value is `false`.
9693 */
9694
9695/**
9696 * Page text content.
9697 *
9698 * @typedef {Object} TextContent
9699 * @property {array} items - array of {@link TextItem}
9700 * @property {Object} styles - {@link TextStyles} objects, indexed by font
9701 * name.
9702 */
9703
9704/**
9705 * Page text content part.
9706 *
9707 * @typedef {Object} TextItem
9708 * @property {string} str - text content.
9709 * @property {string} dir - text direction: 'ttb', 'ltr' or 'rtl'.
9710 * @property {array} transform - transformation matrix.
9711 * @property {number} width - width in device space.
9712 * @property {number} height - height in device space.
9713 * @property {string} fontName - font name used by pdf.js for converted font.
9714 */
9715
9716/**
9717 * Text style.
9718 *
9719 * @typedef {Object} TextStyle
9720 * @property {number} ascent - font ascent.
9721 * @property {number} descent - font descent.
9722 * @property {boolean} vertical - text is in vertical mode.
9723 * @property {string} fontFamily - possible font family
9724 */
9725
9726/**
9727 * Page annotation parameters.
9728 *
9729 * @typedef {Object} GetAnnotationsParameters
9730 * @param {string} intent - Determines the annotations that will be fetched,
9731 * can be either 'display' (viewable annotations) or 'print'
9732 * (printable annotations).
9733 * If the parameter is omitted, all annotations are fetched.
9734 */
9735
9736/**
9737 * Page render parameters.
9738 *
9739 * @typedef {Object} RenderParameters
9740 * @property {Object} canvasContext - A 2D context of a DOM Canvas object.
9741 * @property {PageViewport} viewport - Rendering viewport obtained by
9742 * calling of PDFPage.getViewport method.
9743 * @property {string} intent - Rendering intent, can be 'display' or 'print'
9744 * (default value is 'display').
9745 * @property {boolean} renderInteractiveForms - (optional) Whether or not
9746 * interactive form elements are rendered in the display
9747 * layer. If so, we do not render them on canvas as well.
9748 * @property {Array} transform - (optional) Additional transform, applied
9749 * just before viewport transform.
9750 * @property {Object} imageLayer - (optional) An object that has beginLayout,
9751 * endLayout and appendImage functions.
9752 * @property {function} continueCallback - (deprecated) A function that will be
9753 * called each time the rendering is paused. To continue
9754 * rendering call the function that is the first argument
9755 * to the callback.
9756 */
9757
9758/**
9759 * PDF page operator list.
9760 *
9761 * @typedef {Object} PDFOperatorList
9762 * @property {Array} fnArray - Array containing the operator functions.
9763 * @property {Array} argsArray - Array containing the arguments of the
9764 * functions.
9765 */
9766
9767/**
9768 * Proxy to a PDFPage in the worker thread.
9769 * @class
9770 * @alias PDFPageProxy
9771 */
9772var PDFPageProxy = (function PDFPageProxyClosure() {
9773 function PDFPageProxy(pageIndex, pageInfo, transport) {
9774 this.pageIndex = pageIndex;
9775 this.pageInfo = pageInfo;
9776 this.transport = transport;
9777 this.stats = new StatTimer();
9778 this.stats.enabled = getDefaultSetting('enableStats');
9779 this.commonObjs = transport.commonObjs;
9780 this.objs = new PDFObjects();
9781 this.cleanupAfterRender = false;
9782 this.pendingCleanup = false;
9783 this.intentStates = Object.create(null);
9784 this.destroyed = false;
9785 }
9786 PDFPageProxy.prototype = /** @lends PDFPageProxy.prototype */ {
9787 /**
9788 * @return {number} Page number of the page. First page is 1.
9789 */
9790 get pageNumber() {
9791 return this.pageIndex + 1;
9792 },
9793 /**
9794 * @return {number} The number of degrees the page is rotated clockwise.
9795 */
9796 get rotate() {
9797 return this.pageInfo.rotate;
9798 },
9799 /**
9800 * @return {Object} The reference that points to this page. It has 'num' and
9801 * 'gen' properties.
9802 */
9803 get ref() {
9804 return this.pageInfo.ref;
9805 },
9806 /**
9807 * @return {Array} An array of the visible portion of the PDF page in the
9808 * user space units - [x1, y1, x2, y2].
9809 */
9810 get view() {
9811 return this.pageInfo.view;
9812 },
9813 /**
9814 * @param {number} scale The desired scale of the viewport.
9815 * @param {number} rotate Degrees to rotate the viewport. If omitted this
9816 * defaults to the page rotation.
9817 * @return {PageViewport} Contains 'width' and 'height' properties
9818 * along with transforms required for rendering.
9819 */
9820 getViewport: function PDFPageProxy_getViewport(scale, rotate) {
9821 if (arguments.length < 2) {
9822 rotate = this.rotate;
9823 }
9824 return new PageViewport(this.view, scale, rotate, 0, 0);
9825 },
9826 /**
9827 * @param {GetAnnotationsParameters} params - Annotation parameters.
9828 * @return {Promise} A promise that is resolved with an {Array} of the
9829 * annotation objects.
9830 */
9831 getAnnotations: function PDFPageProxy_getAnnotations(params) {
9832 var intent = (params && params.intent) || null;
9833
9834 if (!this.annotationsPromise || this.annotationsIntent !== intent) {
9835 this.annotationsPromise = this.transport.getAnnotations(this.pageIndex,
9836 intent);
9837 this.annotationsIntent = intent;
9838 }
9839 return this.annotationsPromise;
9840 },
9841 /**
9842 * Begins the process of rendering a page to the desired context.
9843 * @param {RenderParameters} params Page render parameters.
9844 * @return {RenderTask} An object that contains the promise, which
9845 * is resolved when the page finishes rendering.
9846 */
9847 render: function PDFPageProxy_render(params) {
9848 var stats = this.stats;
9849 stats.time('Overall');
9850
9851 // If there was a pending destroy cancel it so no cleanup happens during
9852 // this call to render.
9853 this.pendingCleanup = false;
9854
9855 var renderingIntent = (params.intent === 'print' ? 'print' : 'display');
9856 var renderInteractiveForms = (params.renderInteractiveForms === true ?
9857 true : /* Default */ false);
9858
9859 if (!this.intentStates[renderingIntent]) {
9860 this.intentStates[renderingIntent] = Object.create(null);
9861 }
9862 var intentState = this.intentStates[renderingIntent];
9863
9864 // If there's no displayReadyCapability yet, then the operatorList
9865 // was never requested before. Make the request and create the promise.
9866 if (!intentState.displayReadyCapability) {
9867 intentState.receivingOperatorList = true;
9868 intentState.displayReadyCapability = createPromiseCapability();
9869 intentState.operatorList = {
9870 fnArray: [],
9871 argsArray: [],
9872 lastChunk: false
9873 };
9874
9875 this.stats.time('Page Request');
9876 this.transport.messageHandler.send('RenderPageRequest', {
9877 pageIndex: this.pageNumber - 1,
9878 intent: renderingIntent,
9879 renderInteractiveForms: renderInteractiveForms,
9880 });
9881 }
9882
9883 var internalRenderTask = new InternalRenderTask(complete, params,
9884 this.objs,
9885 this.commonObjs,
9886 intentState.operatorList,
9887 this.pageNumber);
9888 internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
9889 if (!intentState.renderTasks) {
9890 intentState.renderTasks = [];
9891 }
9892 intentState.renderTasks.push(internalRenderTask);
9893 var renderTask = internalRenderTask.task;
9894
9895 // Obsolete parameter support
9896 if (params.continueCallback) {
9897 deprecated('render is used with continueCallback parameter');
9898 renderTask.onContinue = params.continueCallback;
9899 }
9900
9901 var self = this;
9902 intentState.displayReadyCapability.promise.then(
9903 function pageDisplayReadyPromise(transparency) {
9904 if (self.pendingCleanup) {
9905 complete();
9906 return;
9907 }
9908 stats.time('Rendering');
9909 internalRenderTask.initializeGraphics(transparency);
9910 internalRenderTask.operatorListChanged();
9911 },
9912 function pageDisplayReadPromiseError(reason) {
9913 complete(reason);
9914 }
9915 );
9916
9917 function complete(error) {
9918 var i = intentState.renderTasks.indexOf(internalRenderTask);
9919 if (i >= 0) {
9920 intentState.renderTasks.splice(i, 1);
9921 }
9922
9923 if (self.cleanupAfterRender) {
9924 self.pendingCleanup = true;
9925 }
9926 self._tryCleanup();
9927
9928 if (error) {
9929 internalRenderTask.capability.reject(error);
9930 } else {
9931 internalRenderTask.capability.resolve();
9932 }
9933 stats.timeEnd('Rendering');
9934 stats.timeEnd('Overall');
9935 }
9936
9937 return renderTask;
9938 },
9939
9940 /**
9941 * @return {Promise} A promise resolved with an {@link PDFOperatorList}
9942 * object that represents page's operator list.
9943 */
9944 getOperatorList: function PDFPageProxy_getOperatorList() {
9945 function operatorListChanged() {
9946 if (intentState.operatorList.lastChunk) {
9947 intentState.opListReadCapability.resolve(intentState.operatorList);
9948
9949 var i = intentState.renderTasks.indexOf(opListTask);
9950 if (i >= 0) {
9951 intentState.renderTasks.splice(i, 1);
9952 }
9953 }
9954 }
9955
9956 var renderingIntent = 'oplist';
9957 if (!this.intentStates[renderingIntent]) {
9958 this.intentStates[renderingIntent] = Object.create(null);
9959 }
9960 var intentState = this.intentStates[renderingIntent];
9961 var opListTask;
9962
9963 if (!intentState.opListReadCapability) {
9964 opListTask = {};
9965 opListTask.operatorListChanged = operatorListChanged;
9966 intentState.receivingOperatorList = true;
9967 intentState.opListReadCapability = createPromiseCapability();
9968 intentState.renderTasks = [];
9969 intentState.renderTasks.push(opListTask);
9970 intentState.operatorList = {
9971 fnArray: [],
9972 argsArray: [],
9973 lastChunk: false
9974 };
9975
9976 this.transport.messageHandler.send('RenderPageRequest', {
9977 pageIndex: this.pageIndex,
9978 intent: renderingIntent
9979 });
9980 }
9981 return intentState.opListReadCapability.promise;
9982 },
9983
9984 /**
9985 * @param {getTextContentParameters} params - getTextContent parameters.
9986 * @return {Promise} That is resolved a {@link TextContent}
9987 * object that represent the page text content.
9988 */
9989 getTextContent: function PDFPageProxy_getTextContent(params) {
9990 return this.transport.messageHandler.sendWithPromise('GetTextContent', {
9991 pageIndex: this.pageNumber - 1,
9992 normalizeWhitespace: (params && params.normalizeWhitespace === true ?
9993 true : /* Default */ false),
9994 combineTextItems: (params && params.disableCombineTextItems === true ?
9995 false : /* Default */ true),
9996 });
9997 },
9998
9999 /**
10000 * Destroys page object.
10001 */
10002 _destroy: function PDFPageProxy_destroy() {
10003 this.destroyed = true;
10004 this.transport.pageCache[this.pageIndex] = null;
10005
10006 var waitOn = [];
10007 Object.keys(this.intentStates).forEach(function(intent) {
10008 if (intent === 'oplist') {
10009 // Avoid errors below, since the renderTasks are just stubs.
10010 return;
10011 }
10012 var intentState = this.intentStates[intent];
10013 intentState.renderTasks.forEach(function(renderTask) {
10014 var renderCompleted = renderTask.capability.promise.
10015 catch(function () {}); // ignoring failures
10016 waitOn.push(renderCompleted);
10017 renderTask.cancel();
10018 });
10019 }, this);
10020 this.objs.clear();
10021 this.annotationsPromise = null;
10022 this.pendingCleanup = false;
10023 return Promise.all(waitOn);
10024 },
10025
10026 /**
10027 * Cleans up resources allocated by the page. (deprecated)
10028 */
10029 destroy: function() {
10030 deprecated('page destroy method, use cleanup() instead');
10031 this.cleanup();
10032 },
10033
10034 /**
10035 * Cleans up resources allocated by the page.
10036 */
10037 cleanup: function PDFPageProxy_cleanup() {
10038 this.pendingCleanup = true;
10039 this._tryCleanup();
10040 },
10041 /**
10042 * For internal use only. Attempts to clean up if rendering is in a state
10043 * where that's possible.
10044 * @ignore
10045 */
10046 _tryCleanup: function PDFPageProxy_tryCleanup() {
10047 if (!this.pendingCleanup ||
10048 Object.keys(this.intentStates).some(function(intent) {
10049 var intentState = this.intentStates[intent];
10050 return (intentState.renderTasks.length !== 0 ||
10051 intentState.receivingOperatorList);
10052 }, this)) {
10053 return;
10054 }
10055
10056 Object.keys(this.intentStates).forEach(function(intent) {
10057 delete this.intentStates[intent];
10058 }, this);
10059 this.objs.clear();
10060 this.annotationsPromise = null;
10061 this.pendingCleanup = false;
10062 },
10063 /**
10064 * For internal use only.
10065 * @ignore
10066 */
10067 _startRenderPage: function PDFPageProxy_startRenderPage(transparency,
10068 intent) {
10069 var intentState = this.intentStates[intent];
10070 // TODO Refactor RenderPageRequest to separate rendering
10071 // and operator list logic
10072 if (intentState.displayReadyCapability) {
10073 intentState.displayReadyCapability.resolve(transparency);
10074 }
10075 },
10076 /**
10077 * For internal use only.
10078 * @ignore
10079 */
10080 _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk,
10081 intent) {
10082 var intentState = this.intentStates[intent];
10083 var i, ii;
10084 // Add the new chunk to the current operator list.
10085 for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
10086 intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
10087 intentState.operatorList.argsArray.push(
10088 operatorListChunk.argsArray[i]);
10089 }
10090 intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
10091
10092 // Notify all the rendering tasks there are more operators to be consumed.
10093 for (i = 0; i < intentState.renderTasks.length; i++) {
10094 intentState.renderTasks[i].operatorListChanged();
10095 }
10096
10097 if (operatorListChunk.lastChunk) {
10098 intentState.receivingOperatorList = false;
10099 this._tryCleanup();
10100 }
10101 }
10102 };
10103 return PDFPageProxy;
10104})();
10105
10106/**
10107 * PDF.js web worker abstraction, it controls instantiation of PDF documents and
10108 * WorkerTransport for them. If creation of a web worker is not possible,
10109 * a "fake" worker will be used instead.
10110 * @class
10111 */
10112var PDFWorker = (function PDFWorkerClosure() {
10113 var nextFakeWorkerId = 0;
10114
10115 function getWorkerSrc() {
10116 if (typeof workerSrc !== 'undefined') {
10117 return workerSrc;
10118 }
10119 if (getDefaultSetting('workerSrc')) {
10120 return getDefaultSetting('workerSrc');
10121 }
10122 if (pdfjsFilePath) {
10123 return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
10124 }
10125 error('No PDFJS.workerSrc specified');
10126 }
10127
10128 var fakeWorkerFilesLoadedCapability;
10129
10130 // Loads worker code into main thread.
10131 function setupFakeWorkerGlobal() {
10132 var WorkerMessageHandler;
10133 if (!fakeWorkerFilesLoadedCapability) {
10134 fakeWorkerFilesLoadedCapability = createPromiseCapability();
10135 // In the developer build load worker_loader which in turn loads all the
10136 // other files and resolves the promise. In production only the
10137 // pdf.worker.js file is needed.
10138 var loader = fakeWorkerFilesLoader || function (callback) {
10139 Util.loadScript(getWorkerSrc(), function () {
10140 callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler);
10141 });
10142 };
10143 loader(fakeWorkerFilesLoadedCapability.resolve);
10144 }
10145 return fakeWorkerFilesLoadedCapability.promise;
10146 }
10147
10148 function FakeWorkerPort(defer) {
10149 this._listeners = [];
10150 this._defer = defer;
10151 this._deferred = Promise.resolve(undefined);
10152 }
10153 FakeWorkerPort.prototype = {
10154 postMessage: function (obj, transfers) {
10155 function cloneValue(value) {
10156 // Trying to perform a structured clone close to the spec, including
10157 // transfers.
10158 if (typeof value !== 'object' || value === null) {
10159 return value;
10160 }
10161 if (cloned.has(value)) { // already cloned the object
10162 return cloned.get(value);
10163 }
10164 var result;
10165 var buffer;
10166 if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
10167 // We found object with ArrayBuffer (typed array).
10168 var transferable = transfers && transfers.indexOf(buffer) >= 0;
10169 if (value === buffer) {
10170 // Special case when we are faking typed arrays in compatibility.js.
10171 result = value;
10172 } else if (transferable) {
10173 result = new value.constructor(buffer, value.byteOffset,
10174 value.byteLength);
10175 } else {
10176 result = new value.constructor(value);
10177 }
10178 cloned.set(value, result);
10179 return result;
10180 }
10181 result = isArray(value) ? [] : {};
10182 cloned.set(value, result); // adding to cache now for cyclic references
10183 // Cloning all value and object properties, however ignoring properties
10184 // defined via getter.
10185 for (var i in value) {
10186 var desc, p = value;
10187 while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
10188 p = Object.getPrototypeOf(p);
10189 }
10190 if (typeof desc.value === 'undefined' ||
10191 typeof desc.value === 'function') {
10192 continue;
10193 }
10194 result[i] = cloneValue(desc.value);
10195 }
10196 return result;
10197 }
10198
10199 if (!this._defer) {
10200 this._listeners.forEach(function (listener) {
10201 listener.call(this, {data: obj});
10202 }, this);
10203 return;
10204 }
10205
10206 var cloned = new WeakMap();
10207 var e = {data: cloneValue(obj)};
10208 this._deferred.then(function () {
10209 this._listeners.forEach(function (listener) {
10210 listener.call(this, e);
10211 }, this);
10212 }.bind(this));
10213 },
10214 addEventListener: function (name, listener) {
10215 this._listeners.push(listener);
10216 },
10217 removeEventListener: function (name, listener) {
10218 var i = this._listeners.indexOf(listener);
10219 this._listeners.splice(i, 1);
10220 },
10221 terminate: function () {
10222 this._listeners = [];
10223 }
10224 };
10225
10226 function createCDNWrapper(url) {
10227 // We will rely on blob URL's property to specify origin.
10228 // We want this function to fail in case if createObjectURL or Blob do not
10229 // exist or fail for some reason -- our Worker creation will fail anyway.
10230 var wrapper = 'importScripts(\'' + url + '\');';
10231 return URL.createObjectURL(new Blob([wrapper]));
10232 }
10233
10234 function PDFWorker(name) {
10235 this.name = name;
10236 this.destroyed = false;
10237
10238 this._readyCapability = createPromiseCapability();
10239 this._port = null;
10240 this._webWorker = null;
10241 this._messageHandler = null;
10242 this._initialize();
10243 }
10244
10245 PDFWorker.prototype = /** @lends PDFWorker.prototype */ {
10246 get promise() {
10247 return this._readyCapability.promise;
10248 },
10249
10250 get port() {
10251 return this._port;
10252 },
10253
10254 get messageHandler() {
10255 return this._messageHandler;
10256 },
10257
10258 _initialize: function PDFWorker_initialize() {
10259 // If worker support isn't disabled explicit and the browser has worker
10260 // support, create a new web worker and test if it/the browser fulfills
10261 // all requirements to run parts of pdf.js in a web worker.
10262 // Right now, the requirement is, that an Uint8Array is still an
10263 // Uint8Array as it arrives on the worker. (Chrome added this with v.15.)
10264 if (!isWorkerDisabled && !getDefaultSetting('disableWorker') &&
10265 typeof Worker !== 'undefined') {
10266 var workerSrc = getWorkerSrc();
10267
10268 try {
10269 // Wraps workerSrc path into blob URL, if the former does not belong
10270 // to the same origin.
10271 if (!isSameOrigin(window.location.href, workerSrc)) {
10272 workerSrc = createCDNWrapper(
10273 new URL(workerSrc, window.location).href);
10274 }
10275 // Some versions of FF can't create a worker on localhost, see:
10276 // https://bugzilla.mozilla.org/show_bug.cgi?id=683280
10277 var worker = new Worker(workerSrc);
10278 var messageHandler = new MessageHandler('main', 'worker', worker);
10279 var terminateEarly = function() {
10280 worker.removeEventListener('error', onWorkerError);
10281 messageHandler.destroy();
10282 worker.terminate();
10283 if (this.destroyed) {
10284 this._readyCapability.reject(new Error('Worker was destroyed'));
10285 } else {
10286 // Fall back to fake worker if the termination is caused by an
10287 // error (e.g. NetworkError / SecurityError).
10288 this._setupFakeWorker();
10289 }
10290 }.bind(this);
10291
10292 var onWorkerError = function(event) {
10293 if (!this._webWorker) {
10294 // Worker failed to initialize due to an error. Clean up and fall
10295 // back to the fake worker.
10296 terminateEarly();
10297 }
10298 }.bind(this);
10299 worker.addEventListener('error', onWorkerError);
10300
10301 messageHandler.on('test', function PDFWorker_test(data) {
10302 worker.removeEventListener('error', onWorkerError);
10303 if (this.destroyed) {
10304 terminateEarly();
10305 return; // worker was destroyed
10306 }
10307 var supportTypedArray = data && data.supportTypedArray;
10308 if (supportTypedArray) {
10309 this._messageHandler = messageHandler;
10310 this._port = worker;
10311 this._webWorker = worker;
10312 if (!data.supportTransfers) {
10313 isPostMessageTransfersDisabled = true;
10314 }
10315 this._readyCapability.resolve();
10316 // Send global setting, e.g. verbosity level.
10317 messageHandler.send('configure', {
10318 verbosity: getVerbosityLevel()
10319 });
10320 } else {
10321 this._setupFakeWorker();
10322 messageHandler.destroy();
10323 worker.terminate();
10324 }
10325 }.bind(this));
10326
10327 messageHandler.on('console_log', function (data) {
10328 console.log.apply(console, data);
10329 });
10330 messageHandler.on('console_error', function (data) {
10331 console.error.apply(console, data);
10332 });
10333
10334 messageHandler.on('ready', function (data) {
10335 worker.removeEventListener('error', onWorkerError);
10336 if (this.destroyed) {
10337 terminateEarly();
10338 return; // worker was destroyed
10339 }
10340 try {
10341 sendTest();
10342 } catch (e) {
10343 // We need fallback to a faked worker.
10344 this._setupFakeWorker();
10345 }
10346 }.bind(this));
10347
10348 var sendTest = function () {
10349 var postMessageTransfers =
10350 getDefaultSetting('postMessageTransfers') &&
10351 !isPostMessageTransfersDisabled;
10352 var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]);
10353 // Some versions of Opera throw a DATA_CLONE_ERR on serializing the
10354 // typed array. Also, checking if we can use transfers.
10355 try {
10356 messageHandler.send('test', testObj, [testObj.buffer]);
10357 } catch (ex) {
10358 info('Cannot use postMessage transfers');
10359 testObj[0] = 0;
10360 messageHandler.send('test', testObj);
10361 }
10362 };
10363
10364 // It might take time for worker to initialize (especially when AMD
10365 // loader is used). We will try to send test immediately, and then
10366 // when 'ready' message will arrive. The worker shall process only
10367 // first received 'test'.
10368 sendTest();
10369 return;
10370 } catch (e) {
10371 info('The worker has been disabled.');
10372 }
10373 }
10374 // Either workers are disabled, not supported or have thrown an exception.
10375 // Thus, we fallback to a faked worker.
10376 this._setupFakeWorker();
10377 },
10378
10379 _setupFakeWorker: function PDFWorker_setupFakeWorker() {
10380 if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
10381 warn('Setting up fake worker.');
10382 isWorkerDisabled = true;
10383 }
10384
10385 setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
10386 if (this.destroyed) {
10387 this._readyCapability.reject(new Error('Worker was destroyed'));
10388 return;
10389 }
10390
10391 // We cannot turn on proper fake port simulation (this includes
10392 // structured cloning) when typed arrays are not supported. Relying
10393 // on a chance that messages will be sent in proper order.
10394 var isTypedArraysPresent = Uint8Array !== Float32Array;
10395 var port = new FakeWorkerPort(isTypedArraysPresent);
10396 this._port = port;
10397
10398 // All fake workers use the same port, making id unique.
10399 var id = 'fake' + (nextFakeWorkerId++);
10400
10401 // If the main thread is our worker, setup the handling for the
10402 // messages -- the main thread sends to it self.
10403 var workerHandler = new MessageHandler(id + '_worker', id, port);
10404 WorkerMessageHandler.setup(workerHandler, port);
10405
10406 var messageHandler = new MessageHandler(id, id + '_worker', port);
10407 this._messageHandler = messageHandler;
10408 this._readyCapability.resolve();
10409 }.bind(this));
10410 },
10411
10412 /**
10413 * Destroys the worker instance.
10414 */
10415 destroy: function PDFWorker_destroy() {
10416 this.destroyed = true;
10417 if (this._webWorker) {
10418 // We need to terminate only web worker created resource.
10419 this._webWorker.terminate();
10420 this._webWorker = null;
10421 }
10422 this._port = null;
10423 if (this._messageHandler) {
10424 this._messageHandler.destroy();
10425 this._messageHandler = null;
10426 }
10427 }
10428 };
10429
10430 return PDFWorker;
10431})();
10432
10433/**
10434 * For internal use only.
10435 * @ignore
10436 */
10437var WorkerTransport = (function WorkerTransportClosure() {
10438 function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
10439 this.messageHandler = messageHandler;
10440 this.loadingTask = loadingTask;
10441 this.pdfDataRangeTransport = pdfDataRangeTransport;
10442 this.commonObjs = new PDFObjects();
10443 this.fontLoader = new FontLoader(loadingTask.docId);
10444
10445 this.destroyed = false;
10446 this.destroyCapability = null;
10447
10448 this.pageCache = [];
10449 this.pagePromises = [];
10450 this.downloadInfoCapability = createPromiseCapability();
10451
10452 this.setupMessageHandler();
10453 }
10454 WorkerTransport.prototype = {
10455 destroy: function WorkerTransport_destroy() {
10456 if (this.destroyCapability) {
10457 return this.destroyCapability.promise;
10458 }
10459
10460 this.destroyed = true;
10461 this.destroyCapability = createPromiseCapability();
10462
10463 var waitOn = [];
10464 // We need to wait for all renderings to be completed, e.g.
10465 // timeout/rAF can take a long time.
10466 this.pageCache.forEach(function (page) {
10467 if (page) {
10468 waitOn.push(page._destroy());
10469 }
10470 });
10471 this.pageCache = [];
10472 this.pagePromises = [];
10473 var self = this;
10474 // We also need to wait for the worker to finish its long running tasks.
10475 var terminated = this.messageHandler.sendWithPromise('Terminate', null);
10476 waitOn.push(terminated);
10477 Promise.all(waitOn).then(function () {
10478 self.fontLoader.clear();
10479 if (self.pdfDataRangeTransport) {
10480 self.pdfDataRangeTransport.abort();
10481 self.pdfDataRangeTransport = null;
10482 }
10483 if (self.messageHandler) {
10484 self.messageHandler.destroy();
10485 self.messageHandler = null;
10486 }
10487 self.destroyCapability.resolve();
10488 }, this.destroyCapability.reject);
10489 return this.destroyCapability.promise;
10490 },
10491
10492 setupMessageHandler:
10493 function WorkerTransport_setupMessageHandler() {
10494 var messageHandler = this.messageHandler;
10495
10496 function updatePassword(password) {
10497 messageHandler.send('UpdatePassword', password);
10498 }
10499
10500 var pdfDataRangeTransport = this.pdfDataRangeTransport;
10501 if (pdfDataRangeTransport) {
10502 pdfDataRangeTransport.addRangeListener(function(begin, chunk) {
10503 messageHandler.send('OnDataRange', {
10504 begin: begin,
10505 chunk: chunk
10506 });
10507 });
10508
10509 pdfDataRangeTransport.addProgressListener(function(loaded) {
10510 messageHandler.send('OnDataProgress', {
10511 loaded: loaded
10512 });
10513 });
10514
10515 pdfDataRangeTransport.addProgressiveReadListener(function(chunk) {
10516 messageHandler.send('OnDataRange', {
10517 chunk: chunk
10518 });
10519 });
10520
10521 messageHandler.on('RequestDataRange',
10522 function transportDataRange(data) {
10523 pdfDataRangeTransport.requestDataRange(data.begin, data.end);
10524 }, this);
10525 }
10526
10527 messageHandler.on('GetDoc', function transportDoc(data) {
10528 var pdfInfo = data.pdfInfo;
10529 this.numPages = data.pdfInfo.numPages;
10530 var loadingTask = this.loadingTask;
10531 var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
10532 this.pdfDocument = pdfDocument;
10533 loadingTask._capability.resolve(pdfDocument);
10534 }, this);
10535
10536 messageHandler.on('NeedPassword',
10537 function transportNeedPassword(exception) {
10538 var loadingTask = this.loadingTask;
10539 if (loadingTask.onPassword) {
10540 return loadingTask.onPassword(updatePassword,
10541 PasswordResponses.NEED_PASSWORD);
10542 }
10543 loadingTask._capability.reject(
10544 new PasswordException(exception.message, exception.code));
10545 }, this);
10546
10547 messageHandler.on('IncorrectPassword',
10548 function transportIncorrectPassword(exception) {
10549 var loadingTask = this.loadingTask;
10550 if (loadingTask.onPassword) {
10551 return loadingTask.onPassword(updatePassword,
10552 PasswordResponses.INCORRECT_PASSWORD);
10553 }
10554 loadingTask._capability.reject(
10555 new PasswordException(exception.message, exception.code));
10556 }, this);
10557
10558 messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
10559 this.loadingTask._capability.reject(
10560 new InvalidPDFException(exception.message));
10561 }, this);
10562
10563 messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
10564 this.loadingTask._capability.reject(
10565 new MissingPDFException(exception.message));
10566 }, this);
10567
10568 messageHandler.on('UnexpectedResponse',
10569 function transportUnexpectedResponse(exception) {
10570 this.loadingTask._capability.reject(
10571 new UnexpectedResponseException(exception.message, exception.status));
10572 }, this);
10573
10574 messageHandler.on('UnknownError',
10575 function transportUnknownError(exception) {
10576 this.loadingTask._capability.reject(
10577 new UnknownErrorException(exception.message, exception.details));
10578 }, this);
10579
10580 messageHandler.on('DataLoaded', function transportPage(data) {
10581 this.downloadInfoCapability.resolve(data);
10582 }, this);
10583
10584 messageHandler.on('PDFManagerReady', function transportPage(data) {
10585 if (this.pdfDataRangeTransport) {
10586 this.pdfDataRangeTransport.transportReady();
10587 }
10588 }, this);
10589
10590 messageHandler.on('StartRenderPage', function transportRender(data) {
10591 if (this.destroyed) {
10592 return; // Ignore any pending requests if the worker was terminated.
10593 }
10594 var page = this.pageCache[data.pageIndex];
10595
10596 page.stats.timeEnd('Page Request');
10597 page._startRenderPage(data.transparency, data.intent);
10598 }, this);
10599
10600 messageHandler.on('RenderPageChunk', function transportRender(data) {
10601 if (this.destroyed) {
10602 return; // Ignore any pending requests if the worker was terminated.
10603 }
10604 var page = this.pageCache[data.pageIndex];
10605
10606 page._renderPageChunk(data.operatorList, data.intent);
10607 }, this);
10608
10609 messageHandler.on('commonobj', function transportObj(data) {
10610 if (this.destroyed) {
10611 return; // Ignore any pending requests if the worker was terminated.
10612 }
10613
10614 var id = data[0];
10615 var type = data[1];
10616 if (this.commonObjs.hasData(id)) {
10617 return;
10618 }
10619
10620 switch (type) {
10621 case 'Font':
10622 var exportedData = data[2];
10623
10624 if ('error' in exportedData) {
10625 var exportedError = exportedData.error;
10626 warn('Error during font loading: ' + exportedError);
10627 this.commonObjs.resolve(id, exportedError);
10628 break;
10629 }
10630 var fontRegistry = null;
10631 if (getDefaultSetting('pdfBug') && globalScope.FontInspector &&
10632 globalScope['FontInspector'].enabled) {
10633 fontRegistry = {
10634 registerFont: function (font, url) {
10635 globalScope['FontInspector'].fontAdded(font, url);
10636 }
10637 };
10638 }
10639 var font = new FontFaceObject(exportedData, {
10640 isEvalSuported: getDefaultSetting('isEvalSupported'),
10641 disableFontFace: getDefaultSetting('disableFontFace'),
10642 fontRegistry: fontRegistry
10643 });
10644
10645 this.fontLoader.bind(
10646 [font],
10647 function fontReady(fontObjs) {
10648 this.commonObjs.resolve(id, font);
10649 }.bind(this)
10650 );
10651 break;
10652 case 'FontPath':
10653 this.commonObjs.resolve(id, data[2]);
10654 break;
10655 default:
10656 error('Got unknown common object type ' + type);
10657 }
10658 }, this);
10659
10660 messageHandler.on('obj', function transportObj(data) {
10661 if (this.destroyed) {
10662 return; // Ignore any pending requests if the worker was terminated.
10663 }
10664
10665 var id = data[0];
10666 var pageIndex = data[1];
10667 var type = data[2];
10668 var pageProxy = this.pageCache[pageIndex];
10669 var imageData;
10670 if (pageProxy.objs.hasData(id)) {
10671 return;
10672 }
10673
10674 switch (type) {
10675 case 'JpegStream':
10676 imageData = data[3];
10677 loadJpegStream(id, imageData, pageProxy.objs);
10678 break;
10679 case 'Image':
10680 imageData = data[3];
10681 pageProxy.objs.resolve(id, imageData);
10682
10683 // heuristics that will allow not to store large data
10684 var MAX_IMAGE_SIZE_TO_STORE = 8000000;
10685 if (imageData && 'data' in imageData &&
10686 imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
10687 pageProxy.cleanupAfterRender = true;
10688 }
10689 break;
10690 default:
10691 error('Got unknown object type ' + type);
10692 }
10693 }, this);
10694
10695 messageHandler.on('DocProgress', function transportDocProgress(data) {
10696 if (this.destroyed) {
10697 return; // Ignore any pending requests if the worker was terminated.
10698 }
10699
10700 var loadingTask = this.loadingTask;
10701 if (loadingTask.onProgress) {
10702 loadingTask.onProgress({
10703 loaded: data.loaded,
10704 total: data.total
10705 });
10706 }
10707 }, this);
10708
10709 messageHandler.on('PageError', function transportError(data) {
10710 if (this.destroyed) {
10711 return; // Ignore any pending requests if the worker was terminated.
10712 }
10713
10714 var page = this.pageCache[data.pageNum - 1];
10715 var intentState = page.intentStates[data.intent];
10716
10717 if (intentState.displayReadyCapability) {
10718 intentState.displayReadyCapability.reject(data.error);
10719 } else {
10720 error(data.error);
10721 }
10722
10723 if (intentState.operatorList) {
10724 // Mark operator list as complete.
10725 intentState.operatorList.lastChunk = true;
10726 for (var i = 0; i < intentState.renderTasks.length; i++) {
10727 intentState.renderTasks[i].operatorListChanged();
10728 }
10729 }
10730 }, this);
10731
10732 messageHandler.on('UnsupportedFeature',
10733 function transportUnsupportedFeature(data) {
10734 if (this.destroyed) {
10735 return; // Ignore any pending requests if the worker was terminated.
10736 }
10737 var featureId = data.featureId;
10738 var loadingTask = this.loadingTask;
10739 if (loadingTask.onUnsupportedFeature) {
10740 loadingTask.onUnsupportedFeature(featureId);
10741 }
10742 _UnsupportedManager.notify(featureId);
10743 }, this);
10744
10745 messageHandler.on('JpegDecode', function(data) {
10746 if (this.destroyed) {
10747 return Promise.reject(new Error('Worker was destroyed'));
10748 }
10749
10750 var imageUrl = data[0];
10751 var components = data[1];
10752 if (components !== 3 && components !== 1) {
10753 return Promise.reject(
10754 new Error('Only 3 components or 1 component can be returned'));
10755 }
10756
10757 return new Promise(function (resolve, reject) {
10758 var img = new Image();
10759 img.onload = function () {
10760 var width = img.width;
10761 var height = img.height;
10762 var size = width * height;
10763 var rgbaLength = size * 4;
10764 var buf = new Uint8Array(size * components);
10765 var tmpCanvas = createScratchCanvas(width, height);
10766 var tmpCtx = tmpCanvas.getContext('2d');
10767 tmpCtx.drawImage(img, 0, 0);
10768 var data = tmpCtx.getImageData(0, 0, width, height).data;
10769 var i, j;
10770
10771 if (components === 3) {
10772 for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
10773 buf[j] = data[i];
10774 buf[j + 1] = data[i + 1];
10775 buf[j + 2] = data[i + 2];
10776 }
10777 } else if (components === 1) {
10778 for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
10779 buf[j] = data[i];
10780 }
10781 }
10782 resolve({ data: buf, width: width, height: height});
10783 };
10784 img.onerror = function () {
10785 reject(new Error('JpegDecode failed to load image'));
10786 };
10787 img.src = imageUrl;
10788 });
10789 }, this);
10790 },
10791
10792 getData: function WorkerTransport_getData() {
10793 return this.messageHandler.sendWithPromise('GetData', null);
10794 },
10795
10796 getPage: function WorkerTransport_getPage(pageNumber, capability) {
10797 if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
10798 return Promise.reject(new Error('Invalid page request'));
10799 }
10800
10801 var pageIndex = pageNumber - 1;
10802 if (pageIndex in this.pagePromises) {
10803 return this.pagePromises[pageIndex];
10804 }
10805 var promise = this.messageHandler.sendWithPromise('GetPage', {
10806 pageIndex: pageIndex
10807 }).then(function (pageInfo) {
10808 if (this.destroyed) {
10809 throw new Error('Transport destroyed');
10810 }
10811 var page = new PDFPageProxy(pageIndex, pageInfo, this);
10812 this.pageCache[pageIndex] = page;
10813 return page;
10814 }.bind(this));
10815 this.pagePromises[pageIndex] = promise;
10816 return promise;
10817 },
10818
10819 getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
10820 return this.messageHandler.sendWithPromise('GetPageIndex', {
10821 ref: ref,
10822 }).catch(function (reason) {
10823 return Promise.reject(new Error(reason));
10824 });
10825 },
10826
10827 getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
10828 return this.messageHandler.sendWithPromise('GetAnnotations', {
10829 pageIndex: pageIndex,
10830 intent: intent,
10831 });
10832 },
10833
10834 getDestinations: function WorkerTransport_getDestinations() {
10835 return this.messageHandler.sendWithPromise('GetDestinations', null);
10836 },
10837
10838 getDestination: function WorkerTransport_getDestination(id) {
10839 return this.messageHandler.sendWithPromise('GetDestination', { id: id });
10840 },
10841
10842 getPageLabels: function WorkerTransport_getPageLabels() {
10843 return this.messageHandler.sendWithPromise('GetPageLabels', null);
10844 },
10845
10846 getAttachments: function WorkerTransport_getAttachments() {
10847 return this.messageHandler.sendWithPromise('GetAttachments', null);
10848 },
10849
10850 getJavaScript: function WorkerTransport_getJavaScript() {
10851 return this.messageHandler.sendWithPromise('GetJavaScript', null);
10852 },
10853
10854 getOutline: function WorkerTransport_getOutline() {
10855 return this.messageHandler.sendWithPromise('GetOutline', null);
10856 },
10857
10858 getMetadata: function WorkerTransport_getMetadata() {
10859 return this.messageHandler.sendWithPromise('GetMetadata', null).
10860 then(function transportMetadata(results) {
10861 return {
10862 info: results[0],
10863 metadata: (results[1] ? new Metadata(results[1]) : null)
10864 };
10865 });
10866 },
10867
10868 getStats: function WorkerTransport_getStats() {
10869 return this.messageHandler.sendWithPromise('GetStats', null);
10870 },
10871
10872 startCleanup: function WorkerTransport_startCleanup() {
10873 this.messageHandler.sendWithPromise('Cleanup', null).
10874 then(function endCleanup() {
10875 for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
10876 var page = this.pageCache[i];
10877 if (page) {
10878 page.cleanup();
10879 }
10880 }
10881 this.commonObjs.clear();
10882 this.fontLoader.clear();
10883 }.bind(this));
10884 }
10885 };
10886 return WorkerTransport;
10887
10888})();
10889
10890/**
10891 * A PDF document and page is built of many objects. E.g. there are objects
10892 * for fonts, images, rendering code and such. These objects might get processed
10893 * inside of a worker. The `PDFObjects` implements some basic functions to
10894 * manage these objects.
10895 * @ignore
10896 */
10897var PDFObjects = (function PDFObjectsClosure() {
10898 function PDFObjects() {
10899 this.objs = Object.create(null);
10900 }
10901
10902 PDFObjects.prototype = {
10903 /**
10904 * Internal function.
10905 * Ensures there is an object defined for `objId`.
10906 */
10907 ensureObj: function PDFObjects_ensureObj(objId) {
10908 if (this.objs[objId]) {
10909 return this.objs[objId];
10910 }
10911
10912 var obj = {
10913 capability: createPromiseCapability(),
10914 data: null,
10915 resolved: false
10916 };
10917 this.objs[objId] = obj;
10918
10919 return obj;
10920 },
10921
10922 /**
10923 * If called *without* callback, this returns the data of `objId` but the
10924 * object needs to be resolved. If it isn't, this function throws.
10925 *
10926 * If called *with* a callback, the callback is called with the data of the
10927 * object once the object is resolved. That means, if you call this
10928 * function and the object is already resolved, the callback gets called
10929 * right away.
10930 */
10931 get: function PDFObjects_get(objId, callback) {
10932 // If there is a callback, then the get can be async and the object is
10933 // not required to be resolved right now
10934 if (callback) {
10935 this.ensureObj(objId).capability.promise.then(callback);
10936 return null;
10937 }
10938
10939 // If there isn't a callback, the user expects to get the resolved data
10940 // directly.
10941 var obj = this.objs[objId];
10942
10943 // If there isn't an object yet or the object isn't resolved, then the
10944 // data isn't ready yet!
10945 if (!obj || !obj.resolved) {
10946 error('Requesting object that isn\'t resolved yet ' + objId);
10947 }
10948
10949 return obj.data;
10950 },
10951
10952 /**
10953 * Resolves the object `objId` with optional `data`.
10954 */
10955 resolve: function PDFObjects_resolve(objId, data) {
10956 var obj = this.ensureObj(objId);
10957
10958 obj.resolved = true;
10959 obj.data = data;
10960 obj.capability.resolve(data);
10961 },
10962
10963 isResolved: function PDFObjects_isResolved(objId) {
10964 var objs = this.objs;
10965
10966 if (!objs[objId]) {
10967 return false;
10968 } else {
10969 return objs[objId].resolved;
10970 }
10971 },
10972
10973 hasData: function PDFObjects_hasData(objId) {
10974 return this.isResolved(objId);
10975 },
10976
10977 /**
10978 * Returns the data of `objId` if object exists, null otherwise.
10979 */
10980 getData: function PDFObjects_getData(objId) {
10981 var objs = this.objs;
10982 if (!objs[objId] || !objs[objId].resolved) {
10983 return null;
10984 } else {
10985 return objs[objId].data;
10986 }
10987 },
10988
10989 clear: function PDFObjects_clear() {
10990 this.objs = Object.create(null);
10991 }
10992 };
10993 return PDFObjects;
10994})();
10995
10996/**
10997 * Allows controlling of the rendering tasks.
10998 * @class
10999 * @alias RenderTask
11000 */
11001var RenderTask = (function RenderTaskClosure() {
11002 function RenderTask(internalRenderTask) {
11003 this._internalRenderTask = internalRenderTask;
11004
11005 /**
11006 * Callback for incremental rendering -- a function that will be called
11007 * each time the rendering is paused. To continue rendering call the
11008 * function that is the first argument to the callback.
11009 * @type {function}
11010 */
11011 this.onContinue = null;
11012 }
11013
11014 RenderTask.prototype = /** @lends RenderTask.prototype */ {
11015 /**
11016 * Promise for rendering task completion.
11017 * @return {Promise}
11018 */
11019 get promise() {
11020 return this._internalRenderTask.capability.promise;
11021 },
11022
11023 /**
11024 * Cancels the rendering task. If the task is currently rendering it will
11025 * not be cancelled until graphics pauses with a timeout. The promise that
11026 * this object extends will resolved when cancelled.
11027 */
11028 cancel: function RenderTask_cancel() {
11029 this._internalRenderTask.cancel();
11030 },
11031
11032 /**
11033 * Registers callbacks to indicate the rendering task completion.
11034 *
11035 * @param {function} onFulfilled The callback for the rendering completion.
11036 * @param {function} onRejected The callback for the rendering failure.
11037 * @return {Promise} A promise that is resolved after the onFulfilled or
11038 * onRejected callback.
11039 */
11040 then: function RenderTask_then(onFulfilled, onRejected) {
11041 return this.promise.then.apply(this.promise, arguments);
11042 }
11043 };
11044
11045 return RenderTask;
11046})();
11047
11048/**
11049 * For internal use only.
11050 * @ignore
11051 */
11052var InternalRenderTask = (function InternalRenderTaskClosure() {
11053
11054 function InternalRenderTask(callback, params, objs, commonObjs, operatorList,
11055 pageNumber) {
11056 this.callback = callback;
11057 this.params = params;
11058 this.objs = objs;
11059 this.commonObjs = commonObjs;
11060 this.operatorListIdx = null;
11061 this.operatorList = operatorList;
11062 this.pageNumber = pageNumber;
11063 this.running = false;
11064 this.graphicsReadyCallback = null;
11065 this.graphicsReady = false;
11066 this.useRequestAnimationFrame = false;
11067 this.cancelled = false;
11068 this.capability = createPromiseCapability();
11069 this.task = new RenderTask(this);
11070 // caching this-bound methods
11071 this._continueBound = this._continue.bind(this);
11072 this._scheduleNextBound = this._scheduleNext.bind(this);
11073 this._nextBound = this._next.bind(this);
11074 }
11075
11076 InternalRenderTask.prototype = {
11077
11078 initializeGraphics:
11079 function InternalRenderTask_initializeGraphics(transparency) {
11080
11081 if (this.cancelled) {
11082 return;
11083 }
11084 if (getDefaultSetting('pdfBug') && globalScope.StepperManager &&
11085 globalScope.StepperManager.enabled) {
11086 this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
11087 this.stepper.init(this.operatorList);
11088 this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
11089 }
11090
11091 var params = this.params;
11092 this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs,
11093 this.objs, params.imageLayer);
11094
11095 this.gfx.beginDrawing(params.transform, params.viewport, transparency);
11096 this.operatorListIdx = 0;
11097 this.graphicsReady = true;
11098 if (this.graphicsReadyCallback) {
11099 this.graphicsReadyCallback();
11100 }
11101 },
11102
11103 cancel: function InternalRenderTask_cancel() {
11104 this.running = false;
11105 this.cancelled = true;
11106 this.callback('cancelled');
11107 },
11108
11109 operatorListChanged: function InternalRenderTask_operatorListChanged() {
11110 if (!this.graphicsReady) {
11111 if (!this.graphicsReadyCallback) {
11112 this.graphicsReadyCallback = this._continueBound;
11113 }
11114 return;
11115 }
11116
11117 if (this.stepper) {
11118 this.stepper.updateOperatorList(this.operatorList);
11119 }
11120
11121 if (this.running) {
11122 return;
11123 }
11124 this._continue();
11125 },
11126
11127 _continue: function InternalRenderTask__continue() {
11128 this.running = true;
11129 if (this.cancelled) {
11130 return;
11131 }
11132 if (this.task.onContinue) {
11133 this.task.onContinue.call(this.task, this._scheduleNextBound);
11134 } else {
11135 this._scheduleNext();
11136 }
11137 },
11138
11139 _scheduleNext: function InternalRenderTask__scheduleNext() {
11140 if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
11141 window.requestAnimationFrame(this._nextBound);
11142 } else {
11143 Promise.resolve(undefined).then(this._nextBound);
11144 }
11145 },
11146
11147 _next: function InternalRenderTask__next() {
11148 if (this.cancelled) {
11149 return;
11150 }
11151 this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList,
11152 this.operatorListIdx,
11153 this._continueBound,
11154 this.stepper);
11155 if (this.operatorListIdx === this.operatorList.argsArray.length) {
11156 this.running = false;
11157 if (this.operatorList.lastChunk) {
11158 this.gfx.endDrawing();
11159 this.callback();
11160 }
11161 }
11162 }
11163
11164 };
11165
11166 return InternalRenderTask;
11167})();
11168
11169/**
11170 * (Deprecated) Global observer of unsupported feature usages. Use
11171 * onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance.
11172 */
11173var _UnsupportedManager = (function UnsupportedManagerClosure() {
11174 var listeners = [];
11175 return {
11176 listen: function (cb) {
11177 deprecated('Global UnsupportedManager.listen is used: ' +
11178 ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
11179 listeners.push(cb);
11180 },
11181 notify: function (featureId) {
11182 for (var i = 0, ii = listeners.length; i < ii; i++) {
11183 listeners[i](featureId);
11184 }
11185 }
11186 };
11187})();
11188
11189if (typeof pdfjsVersion !== 'undefined') {
11190 exports.version = pdfjsVersion;
11191}
11192if (typeof pdfjsBuild !== 'undefined') {
11193 exports.build = pdfjsBuild;
11194}
11195
11196exports.getDocument = getDocument;
11197exports.PDFDataRangeTransport = PDFDataRangeTransport;
11198exports.PDFWorker = PDFWorker;
11199exports.PDFDocumentProxy = PDFDocumentProxy;
11200exports.PDFPageProxy = PDFPageProxy;
11201exports._UnsupportedManager = _UnsupportedManager;
11202}));
11203
11204
11205(function (root, factory) {
11206 {
11207 factory((root.pdfjsDisplayGlobal = {}), root.pdfjsSharedUtil,
11208 root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI,
11209 root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer,
11210 root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
11211 }
11212}(this, function (exports, sharedUtil, displayDOMUtils, displayAPI,
11213 displayAnnotationLayer, displayTextLayer, displayMetadata,
11214 displaySVG) {
11215
11216 var globalScope = sharedUtil.globalScope;
11217 var deprecated = sharedUtil.deprecated;
11218 var warn = sharedUtil.warn;
11219 var LinkTarget = displayDOMUtils.LinkTarget;
11220
11221 var isWorker = (typeof window === 'undefined');
11222
11223 // The global PDFJS object is now deprecated and will not be supported in
11224 // the future. The members below are maintained for backward compatibility
11225 // and shall not be extended or modified. If the global.js is included as
11226 // a module, we will create a global PDFJS object instance or use existing.
11227 if (!globalScope.PDFJS) {
11228 globalScope.PDFJS = {};
11229 }
11230 var PDFJS = globalScope.PDFJS;
11231
11232 if (typeof pdfjsVersion !== 'undefined') {
11233 PDFJS.version = pdfjsVersion;
11234 }
11235 if (typeof pdfjsBuild !== 'undefined') {
11236 PDFJS.build = pdfjsBuild;
11237 }
11238
11239 PDFJS.pdfBug = false;
11240
11241 if (PDFJS.verbosity !== undefined) {
11242 sharedUtil.setVerbosityLevel(PDFJS.verbosity);
11243 }
11244 delete PDFJS.verbosity;
11245 Object.defineProperty(PDFJS, 'verbosity', {
11246 get: function () { return sharedUtil.getVerbosityLevel(); },
11247 set: function (level) { sharedUtil.setVerbosityLevel(level); },
11248 enumerable: true,
11249 configurable: true
11250 });
11251
11252 PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
11253 PDFJS.OPS = sharedUtil.OPS;
11254 PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
11255 PDFJS.isValidUrl = sharedUtil.isValidUrl;
11256 PDFJS.shadow = sharedUtil.shadow;
11257 PDFJS.createBlob = sharedUtil.createBlob;
11258 PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
11259 return sharedUtil.createObjectURL(data, contentType,
11260 PDFJS.disableCreateObjectURL);
11261 };
11262 Object.defineProperty(PDFJS, 'isLittleEndian', {
11263 configurable: true,
11264 get: function PDFJS_isLittleEndian() {
11265 var value = sharedUtil.isLittleEndian();
11266 return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
11267 }
11268 });
11269 PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
11270 PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
11271 PDFJS.PasswordException = sharedUtil.PasswordException;
11272 PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
11273 PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
11274 PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
11275 PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
11276 PDFJS.Util = sharedUtil.Util;
11277 PDFJS.PageViewport = sharedUtil.PageViewport;
11278 PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
11279
11280 /**
11281 * The maximum allowed image size in total pixels e.g. width * height. Images
11282 * above this value will not be drawn. Use -1 for no limit.
11283 * @var {number}
11284 */
11285 PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ?
11286 -1 : PDFJS.maxImageSize);
11287
11288 /**
11289 * The url of where the predefined Adobe CMaps are located. Include trailing
11290 * slash.
11291 * @var {string}
11292 */
11293 PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl);
11294
11295 /**
11296 * Specifies if CMaps are binary packed.
11297 * @var {boolean}
11298 */
11299 PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
11300
11301 /**
11302 * By default fonts are converted to OpenType fonts and loaded via font face
11303 * rules. If disabled, the font will be rendered using a built in font
11304 * renderer that constructs the glyphs with primitive path commands.
11305 * @var {boolean}
11306 */
11307 PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
11308 false : PDFJS.disableFontFace);
11309
11310 /**
11311 * Path for image resources, mainly for annotation icons. Include trailing
11312 * slash.
11313 * @var {string}
11314 */
11315 PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ?
11316 '' : PDFJS.imageResourcesPath);
11317
11318 /**
11319 * Disable the web worker and run all code on the main thread. This will
11320 * happen automatically if the browser doesn't support workers or sending
11321 * typed arrays to workers.
11322 * @var {boolean}
11323 */
11324 PDFJS.disableWorker = (PDFJS.disableWorker === undefined ?
11325 false : PDFJS.disableWorker);
11326
11327 /**
11328 * Path and filename of the worker file. Required when the worker is enabled
11329 * in development mode. If unspecified in the production build, the worker
11330 * will be loaded based on the location of the pdf.js file. It is recommended
11331 * that the workerSrc is set in a custom application to prevent issues caused
11332 * by third-party frameworks and libraries.
11333 * @var {string}
11334 */
11335 PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
11336
11337 /**
11338 * Disable range request loading of PDF files. When enabled and if the server
11339 * supports partial content requests then the PDF will be fetched in chunks.
11340 * Enabled (false) by default.
11341 * @var {boolean}
11342 */
11343 PDFJS.disableRange = (PDFJS.disableRange === undefined ?
11344 false : PDFJS.disableRange);
11345
11346 /**
11347 * Disable streaming of PDF file data. By default PDF.js attempts to load PDF
11348 * in chunks. This default behavior can be disabled.
11349 * @var {boolean}
11350 */
11351 PDFJS.disableStream = (PDFJS.disableStream === undefined ?
11352 false : PDFJS.disableStream);
11353
11354 /**
11355 * Disable pre-fetching of PDF file data. When range requests are enabled
11356 * PDF.js will automatically keep fetching more data even if it isn't needed
11357 * to display the current page. This default behavior can be disabled.
11358 *
11359 * NOTE: It is also necessary to disable streaming, see above,
11360 * in order for disabling of pre-fetching to work correctly.
11361 * @var {boolean}
11362 */
11363 PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ?
11364 false : PDFJS.disableAutoFetch);
11365
11366 /**
11367 * Enables special hooks for debugging PDF.js.
11368 * @var {boolean}
11369 */
11370 PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug);
11371
11372 /**
11373 * Enables transfer usage in postMessage for ArrayBuffers.
11374 * @var {boolean}
11375 */
11376 PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ?
11377 true : PDFJS.postMessageTransfers);
11378
11379 /**
11380 * Disables URL.createObjectURL usage.
11381 * @var {boolean}
11382 */
11383 PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
11384 false : PDFJS.disableCreateObjectURL);
11385
11386 /**
11387 * Disables WebGL usage.
11388 * @var {boolean}
11389 */
11390 PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ?
11391 true : PDFJS.disableWebGL);
11392
11393 /**
11394 * Specifies the |target| attribute for external links.
11395 * The constants from PDFJS.LinkTarget should be used:
11396 * - NONE [default]
11397 * - SELF
11398 * - BLANK
11399 * - PARENT
11400 * - TOP
11401 * @var {number}
11402 */
11403 PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ?
11404 LinkTarget.NONE : PDFJS.externalLinkTarget);
11405
11406 /**
11407 * Specifies the |rel| attribute for external links. Defaults to stripping
11408 * the referrer.
11409 * @var {string}
11410 */
11411 PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ?
11412 'noreferrer' : PDFJS.externalLinkRel);
11413
11414 /**
11415 * Determines if we can eval strings as JS. Primarily used to improve
11416 * performance for font rendering.
11417 * @var {boolean}
11418 */
11419 PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
11420 true : PDFJS.isEvalSupported);
11421
11422 var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
11423 delete PDFJS.openExternalLinksInNewWindow;
11424 Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
11425 get: function () {
11426 return PDFJS.externalLinkTarget === LinkTarget.BLANK;
11427 },
11428 set: function (value) {
11429 if (value) {
11430 deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
11431 '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
11432 }
11433 if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
11434 warn('PDFJS.externalLinkTarget is already initialized');
11435 return;
11436 }
11437 PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
11438 },
11439 enumerable: true,
11440 configurable: true
11441 });
11442 if (savedOpenExternalLinksInNewWindow) {
11443 /**
11444 * (Deprecated) Opens external links in a new window if enabled.
11445 * The default behavior opens external links in the PDF.js window.
11446 *
11447 * NOTE: This property has been deprecated, please use
11448 * `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead.
11449 * @var {boolean}
11450 */
11451 PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
11452 }
11453
11454 PDFJS.getDocument = displayAPI.getDocument;
11455 PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
11456 PDFJS.PDFWorker = displayAPI.PDFWorker;
11457
11458 Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
11459 configurable: true,
11460 get: function PDFJS_hasCanvasTypedArrays() {
11461 var value = displayDOMUtils.hasCanvasTypedArrays();
11462 return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
11463 }
11464 });
11465 PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
11466 PDFJS.LinkTarget = LinkTarget;
11467 PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
11468 PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
11469 PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
11470
11471 PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
11472
11473 PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
11474
11475 PDFJS.Metadata = displayMetadata.Metadata;
11476
11477 PDFJS.SVGGraphics = displaySVG.SVGGraphics;
11478
11479 PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
11480
11481 exports.globalScope = globalScope;
11482 exports.isWorker = isWorker;
11483 exports.PDFJS = globalScope.PDFJS;
11484}));
11485 }).call(pdfjsLibs);
11486
11487 exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
11488 exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
11489 exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
11490 exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
11491 exports.PDFDataRangeTransport =
11492 pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
11493 exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
11494 exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
11495 exports.AnnotationLayer =
11496 pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
11497 exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
11498 exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
11499 exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
11500 exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
11501 exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
11502 exports.UnexpectedResponseException =
11503 pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
11504 exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
11505 exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
11506 exports.isValidUrl = pdfjsLibs.pdfjsSharedUtil.isValidUrl;
11507 exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
11508 exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
11509 exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
11510 exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
11511 exports.getFilenameFromUrl =
11512 pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
11513 exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
11514}));
11515
diff --git a/dist/js/pdf.min.js b/dist/js/pdf.min.js
new file mode 100644
index 00000000..38bd4aad
--- /dev/null
+++ b/dist/js/pdf.min.js
@@ -0,0 +1,8 @@
1(function(root,factory){"use strict";if(typeof define==="function"&&define.amd){define("pdfjs-dist/build/pdf",["exports"],factory)}else if(typeof exports!=="undefined"){factory(exports)}else{factory(root.pdfjsDistBuildPdf={})}})(this,function(exports){"use strict";var pdfjsVersion="1.6.210";var pdfjsBuild="4ce2356";var pdfjsFilePath=typeof document!=="undefined"&&document.currentScript?document.currentScript.src:null;var pdfjsLibs={};(function pdfjsWrapper(){(function(root,factory){{factory(root.pdfjsSharedUtil={})}})(this,function(exports){var globalScope=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:this;var FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];var TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};var ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};var AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};var AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};var AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};var AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var StreamType={UNKNOWN:0,FLATE:1,LZW:2,DCT:3,JPX:4,JBIG:5,A85:6,AHX:7,CCF:8,RL:9};var FontType={UNKNOWN:0,TYPE1:1,TYPE1C:2,CIDFONTTYPE0:3,CIDFONTTYPE0C:4,TRUETYPE:5,CIDFONTTYPE2:6,TYPE3:7,OPENTYPE:8,TYPE0:9,MMTYPE1:10};var VERBOSITY_LEVELS={errors:0,warnings:1,infos:5};var OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};var verbosity=VERBOSITY_LEVELS.warnings;function setVerbosityLevel(level){verbosity=level}function getVerbosityLevel(){return verbosity}function info(msg){if(verbosity>=VERBOSITY_LEVELS.infos){console.log("Info: "+msg)}}function warn(msg){if(verbosity>=VERBOSITY_LEVELS.warnings){console.log("Warning: "+msg)}}function deprecated(details){console.log("Deprecated API usage: "+details)}function error(msg){if(verbosity>=VERBOSITY_LEVELS.errors){console.log("Error: "+msg);console.log(backtrace())}throw new Error(msg)}function backtrace(){try{throw new Error}catch(e){return e.stack?e.stack.split("\n").slice(2).join("\n"):""}}function assert(cond,msg){if(!cond){error(msg)}}var UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",smask:"smask",shadingPattern:"shadingPattern",font:"font"};function isSameOrigin(baseUrl,otherUrl){try{var base=new URL(baseUrl);if(!base.origin||base.origin==="null"){return false}}catch(e){return false}var other=new URL(otherUrl,base);return base.origin===other.origin}function isValidUrl(url,allowRelative){if(!url||typeof url!=="string"){return false}var protocol=/^[a-z][a-z0-9+\-.]*(?=:)/i.exec(url);if(!protocol){return allowRelative}protocol=protocol[0].toLowerCase();switch(protocol){case"http":case"https":case"ftp":case"mailto":case"tel":return true;default:return false}}function shadow(obj,prop,value){Object.defineProperty(obj,prop,{value:value,enumerable:true,configurable:true,writable:false});return value}function getLookupTableFactory(initializer){var lookup;return function(){if(initializer){lookup=Object.create(null);initializer(lookup);initializer=null}return lookup}}var PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};var PasswordException=function PasswordExceptionClosure(){function PasswordException(msg,code){this.name="PasswordException";this.message=msg;this.code=code}PasswordException.prototype=new Error;PasswordException.constructor=PasswordException;return PasswordException}();var UnknownErrorException=function UnknownErrorExceptionClosure(){function UnknownErrorException(msg,details){this.name="UnknownErrorException";this.message=msg;this.details=details}UnknownErrorException.prototype=new Error;UnknownErrorException.constructor=UnknownErrorException;return UnknownErrorException}();var InvalidPDFException=function InvalidPDFExceptionClosure(){function InvalidPDFException(msg){this.name="InvalidPDFException";this.message=msg}InvalidPDFException.prototype=new Error;InvalidPDFException.constructor=InvalidPDFException;return InvalidPDFException}();var MissingPDFException=function MissingPDFExceptionClosure(){function MissingPDFException(msg){this.name="MissingPDFException";this.message=msg}MissingPDFException.prototype=new Error;MissingPDFException.constructor=MissingPDFException;return MissingPDFException}();var UnexpectedResponseException=function UnexpectedResponseExceptionClosure(){function UnexpectedResponseException(msg,status){this.name="UnexpectedResponseException";this.message=msg;this.status=status}UnexpectedResponseException.prototype=new Error;UnexpectedResponseException.constructor=UnexpectedResponseException;return UnexpectedResponseException}();var NotImplementedException=function NotImplementedExceptionClosure(){function NotImplementedException(msg){this.message=msg}NotImplementedException.prototype=new Error;NotImplementedException.prototype.name="NotImplementedException";NotImplementedException.constructor=NotImplementedException;return NotImplementedException}();var MissingDataException=function MissingDataExceptionClosure(){function MissingDataException(begin,end){this.begin=begin;this.end=end;this.message="Missing data ["+begin+", "+end+")"}MissingDataException.prototype=new Error;MissingDataException.prototype.name="MissingDataException";MissingDataException.constructor=MissingDataException;return MissingDataException}();var XRefParseException=function XRefParseExceptionClosure(){function XRefParseException(msg){this.message=msg}XRefParseException.prototype=new Error;XRefParseException.prototype.name="XRefParseException";XRefParseException.constructor=XRefParseException;return XRefParseException}();var NullCharactersRegExp=/\x00/g;function removeNullCharacters(str){if(typeof str!=="string"){warn("The argument for removeNullCharacters must be a string.");return str}return str.replace(NullCharactersRegExp,"")}function bytesToString(bytes){assert(bytes!==null&&typeof bytes==="object"&&bytes.length!==undefined,"Invalid argument for bytesToString");var length=bytes.length;var MAX_ARGUMENT_COUNT=8192;if(length<MAX_ARGUMENT_COUNT){return String.fromCharCode.apply(null,bytes)}var strBuf=[];for(var i=0;i<length;i+=MAX_ARGUMENT_COUNT){var chunkEnd=Math.min(i+MAX_ARGUMENT_COUNT,length);var chunk=bytes.subarray(i,chunkEnd);strBuf.push(String.fromCharCode.apply(null,chunk))}return strBuf.join("")}function stringToBytes(str){assert(typeof str==="string","Invalid argument for stringToBytes");var length=str.length;var bytes=new Uint8Array(length);for(var i=0;i<length;++i){bytes[i]=str.charCodeAt(i)&255}return bytes}function arrayByteLength(arr){if(arr.length!==undefined){return arr.length}assert(arr.byteLength!==undefined);return arr.byteLength}function arraysToBytes(arr){if(arr.length===1&&arr[0]instanceof Uint8Array){return arr[0]}var resultLength=0;var i,ii=arr.length;var item,itemLength;for(i=0;i<ii;i++){item=arr[i];itemLength=arrayByteLength(item);resultLength+=itemLength}var pos=0;var data=new Uint8Array(resultLength);for(i=0;i<ii;i++){item=arr[i];if(!(item instanceof Uint8Array)){if(typeof item==="string"){item=stringToBytes(item)}else{item=new Uint8Array(item)}}itemLength=item.byteLength;data.set(item,pos);pos+=itemLength}return data}function string32(value){return String.fromCharCode(value>>24&255,value>>16&255,value>>8&255,value&255)}function log2(x){var n=1,i=0;while(x>n){n<<=1;i++}return i}function readInt8(data,start){return data[start]<<24>>24}function readUint16(data,offset){return data[offset]<<8|data[offset+1]}function readUint32(data,offset){return(data[offset]<<24|data[offset+1]<<16|data[offset+2]<<8|data[offset+3])>>>0}function isLittleEndian(){var buffer8=new Uint8Array(2);buffer8[0]=1;var buffer16=new Uint16Array(buffer8.buffer);return buffer16[0]===1}function isEvalSupported(){try{new Function("");return true}catch(e){return false}}var Uint32ArrayView=function Uint32ArrayViewClosure(){function Uint32ArrayView(buffer,length){this.buffer=buffer;this.byteLength=buffer.length;this.length=length===undefined?this.byteLength>>2:length;ensureUint32ArrayViewProps(this.length)}Uint32ArrayView.prototype=Object.create(null);var uint32ArrayViewSetters=0;function createUint32ArrayProp(index){return{get:function(){var buffer=this.buffer,offset=index<<2;return(buffer[offset]|buffer[offset+1]<<8|buffer[offset+2]<<16|buffer[offset+3]<<24)>>>0},set:function(value){var buffer=this.buffer,offset=index<<2;buffer[offset]=value&255;buffer[offset+1]=value>>8&255;buffer[offset+2]=value>>16&255;buffer[offset+3]=value>>>24&255}}}function ensureUint32ArrayViewProps(length){while(uint32ArrayViewSetters<length){Object.defineProperty(Uint32ArrayView.prototype,uint32ArrayViewSetters,createUint32ArrayProp(uint32ArrayViewSetters));uint32ArrayViewSetters++}}return Uint32ArrayView}();exports.Uint32ArrayView=Uint32ArrayView;var IDENTITY_MATRIX=[1,0,0,1,0,0];var Util=function UtilClosure(){function Util(){}var rgbBuf=["rgb(",0,",",0,",",0,")"];Util.makeCssRgb=function Util_makeCssRgb(r,g,b){rgbBuf[1]=r;rgbBuf[3]=g;rgbBuf[5]=b;return rgbBuf.join("")};Util.transform=function Util_transform(m1,m2){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]]};Util.applyTransform=function Util_applyTransform(p,m){var xt=p[0]*m[0]+p[1]*m[2]+m[4];var yt=p[0]*m[1]+p[1]*m[3]+m[5];return[xt,yt]};Util.applyInverseTransform=function Util_applyInverseTransform(p,m){var d=m[0]*m[3]-m[1]*m[2];var xt=(p[0]*m[3]-p[1]*m[2]+m[2]*m[5]-m[4]*m[3])/d;var yt=(-p[0]*m[1]+p[1]*m[0]+m[4]*m[1]-m[5]*m[0])/d;return[xt,yt]};Util.getAxialAlignedBoundingBox=function Util_getAxialAlignedBoundingBox(r,m){var p1=Util.applyTransform(r,m);var p2=Util.applyTransform(r.slice(2,4),m);var p3=Util.applyTransform([r[0],r[3]],m);var p4=Util.applyTransform([r[2],r[1]],m);return[Math.min(p1[0],p2[0],p3[0],p4[0]),Math.min(p1[1],p2[1],p3[1],p4[1]),Math.max(p1[0],p2[0],p3[0],p4[0]),Math.max(p1[1],p2[1],p3[1],p4[1])]};Util.inverseTransform=function Util_inverseTransform(m){var d=m[0]*m[3]-m[1]*m[2];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]};Util.apply3dTransform=function Util_apply3dTransform(m,v){return[m[0]*v[0]+m[1]*v[1]+m[2]*v[2],m[3]*v[0]+m[4]*v[1]+m[5]*v[2],m[6]*v[0]+m[7]*v[1]+m[8]*v[2]]};Util.singularValueDecompose2dScale=function Util_singularValueDecompose2dScale(m){var transpose=[m[0],m[2],m[1],m[3]];var a=m[0]*transpose[0]+m[1]*transpose[2];var b=m[0]*transpose[1]+m[1]*transpose[3];var c=m[2]*transpose[0]+m[3]*transpose[2];var d=m[2]*transpose[1]+m[3]*transpose[3];var first=(a+d)/2;var second=Math.sqrt((a+d)*(a+d)-4*(a*d-c*b))/2;var sx=first+second||1;var sy=first-second||1;return[Math.sqrt(sx),Math.sqrt(sy)]};Util.normalizeRect=function Util_normalizeRect(rect){var r=rect.slice(0);if(rect[0]>rect[2]){r[0]=rect[2];r[2]=rect[0]}if(rect[1]>rect[3]){r[1]=rect[3];r[3]=rect[1]}return r};Util.intersect=function Util_intersect(rect1,rect2){function compare(a,b){return a-b}var orderedX=[rect1[0],rect1[2],rect2[0],rect2[2]].sort(compare),orderedY=[rect1[1],rect1[3],rect2[1],rect2[3]].sort(compare),result=[];rect1=Util.normalizeRect(rect1);rect2=Util.normalizeRect(rect2);if(orderedX[0]===rect1[0]&&orderedX[1]===rect2[0]||orderedX[0]===rect2[0]&&orderedX[1]===rect1[0]){result[0]=orderedX[1];result[2]=orderedX[2]}else{return false}if(orderedY[0]===rect1[1]&&orderedY[1]===rect2[1]||orderedY[0]===rect2[1]&&orderedY[1]===rect1[1]){result[1]=orderedY[1];result[3]=orderedY[2]}else{return false}return result};Util.sign=function Util_sign(num){return num<0?-1:1};var 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"];Util.toRoman=function Util_toRoman(number,lowerCase){assert(isInt(number)&&number>0,"The number should be a positive integer.");var pos,romanBuf=[];while(number>=1e3){number-=1e3;romanBuf.push("M")}pos=number/100|0;number%=100;romanBuf.push(ROMAN_NUMBER_MAP[pos]);pos=number/10|0;number%=10;romanBuf.push(ROMAN_NUMBER_MAP[10+pos]);romanBuf.push(ROMAN_NUMBER_MAP[20+number]);var romanStr=romanBuf.join("");return lowerCase?romanStr.toLowerCase():romanStr};Util.appendToArray=function Util_appendToArray(arr1,arr2){Array.prototype.push.apply(arr1,arr2)};Util.prependToArray=function Util_prependToArray(arr1,arr2){Array.prototype.unshift.apply(arr1,arr2)};Util.extendObj=function extendObj(obj1,obj2){for(var key in obj2){obj1[key]=obj2[key]}};Util.getInheritableProperty=function Util_getInheritableProperty(dict,name){while(dict&&!dict.has(name)){dict=dict.get("Parent")}if(!dict){return null}return dict.get(name)};Util.inherit=function Util_inherit(sub,base,prototype){sub.prototype=Object.create(base.prototype);sub.prototype.constructor=sub;for(var prop in prototype){sub.prototype[prop]=prototype[prop]}};Util.loadScript=function Util_loadScript(src,callback){var script=document.createElement("script");var loaded=false;script.setAttribute("src",src);if(callback){script.onload=function(){if(!loaded){callback()}loaded=true}}document.getElementsByTagName("head")[0].appendChild(script)};return Util}();var PageViewport=function PageViewportClosure(){function PageViewport(viewBox,scale,rotation,offsetX,offsetY,dontFlip){this.viewBox=viewBox;this.scale=scale;this.rotation=rotation;this.offsetX=offsetX;this.offsetY=offsetY;var centerX=(viewBox[2]+viewBox[0])/2;var centerY=(viewBox[3]+viewBox[1])/2;var rotateA,rotateB,rotateC,rotateD;rotation=rotation%360;rotation=rotation<0?rotation+360:rotation;switch(rotation){case 180:rotateA=-1;rotateB=0;rotateC=0;rotateD=1;break;case 90:rotateA=0;rotateB=1;rotateC=1;rotateD=0;break;case 270:rotateA=0;rotateB=-1;rotateC=-1;rotateD=0;break;default:rotateA=1;rotateB=0;rotateC=0;rotateD=-1;break}if(dontFlip){rotateC=-rotateC;rotateD=-rotateD}var offsetCanvasX,offsetCanvasY;var width,height;if(rotateA===0){offsetCanvasX=Math.abs(centerY-viewBox[1])*scale+offsetX;offsetCanvasY=Math.abs(centerX-viewBox[0])*scale+offsetY;width=Math.abs(viewBox[3]-viewBox[1])*scale;height=Math.abs(viewBox[2]-viewBox[0])*scale}else{offsetCanvasX=Math.abs(centerX-viewBox[0])*scale+offsetX;offsetCanvasY=Math.abs(centerY-viewBox[1])*scale+offsetY;width=Math.abs(viewBox[2]-viewBox[0])*scale;height=Math.abs(viewBox[3]-viewBox[1])*scale}this.transform=[rotateA*scale,rotateB*scale,rotateC*scale,rotateD*scale,offsetCanvasX-rotateA*scale*centerX-rotateC*scale*centerY,offsetCanvasY-rotateB*scale*centerX-rotateD*scale*centerY];this.width=width;this.height=height;this.fontScale=scale}PageViewport.prototype={clone:function PageViewPort_clone(args){args=args||{};var scale="scale"in args?args.scale:this.scale;var rotation="rotation"in args?args.rotation:this.rotation;return new PageViewport(this.viewBox.slice(),scale,rotation,this.offsetX,this.offsetY,args.dontFlip)},convertToViewportPoint:function PageViewport_convertToViewportPoint(x,y){return Util.applyTransform([x,y],this.transform)},convertToViewportRectangle:function PageViewport_convertToViewportRectangle(rect){var tl=Util.applyTransform([rect[0],rect[1]],this.transform);var br=Util.applyTransform([rect[2],rect[3]],this.transform);return[tl[0],tl[1],br[0],br[1]]},convertToPdfPoint:function PageViewport_convertToPdfPoint(x,y){return Util.applyInverseTransform([x,y],this.transform)}};return PageViewport}();var 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,728,711,710,729,733,731,730,732,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,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToPDFString(str){var i,n=str.length,strBuf=[];if(str[0]==="þ"&&str[1]==="ÿ"){for(i=2;i<n;i+=2){strBuf.push(String.fromCharCode(str.charCodeAt(i)<<8|str.charCodeAt(i+1)))}}else{for(i=0;i<n;++i){var code=PDFStringTranslateTable[str.charCodeAt(i)];strBuf.push(code?String.fromCharCode(code):str.charAt(i))}}return strBuf.join("")}function stringToUTF8String(str){return decodeURIComponent(escape(str))}function utf8StringToString(str){return unescape(encodeURIComponent(str))}function isEmptyObj(obj){for(var key in obj){return false}return true}function isBool(v){return typeof v==="boolean"}function isInt(v){return typeof v==="number"&&(v|0)===v}function isNum(v){return typeof v==="number"}function isString(v){return typeof v==="string"}function isArray(v){return v instanceof Array}function isArrayBuffer(v){return typeof v==="object"&&v!==null&&v.byteLength!==undefined}function isSpace(ch){return ch===32||ch===9||ch===13||ch===10}function createPromiseCapability(){var capability={};capability.promise=new Promise(function(resolve,reject){capability.resolve=resolve;capability.reject=reject});return capability}(function PromiseClosure(){if(globalScope.Promise){if(typeof globalScope.Promise.all!=="function"){globalScope.Promise.all=function(iterable){var count=0,results=[],resolve,reject;var promise=new globalScope.Promise(function(resolve_,reject_){resolve=resolve_;reject=reject_});iterable.forEach(function(p,i){count++;p.then(function(result){results[i]=result;count--;if(count===0){resolve(results)}},reject)});if(count===0){resolve(results)}return promise}}if(typeof globalScope.Promise.resolve!=="function"){globalScope.Promise.resolve=function(value){return new globalScope.Promise(function(resolve){resolve(value)})}}if(typeof globalScope.Promise.reject!=="function"){globalScope.Promise.reject=function(reason){return new globalScope.Promise(function(resolve,reject){reject(reason)})}}if(typeof globalScope.Promise.prototype.catch!=="function"){globalScope.Promise.prototype.catch=function(onReject){return globalScope.Promise.prototype.then(undefined,onReject)}}return}var STATUS_PENDING=0;var STATUS_RESOLVED=1;var STATUS_REJECTED=2;var REJECTION_TIMEOUT=500;var HandlerManager={handlers:[],running:false,unhandledRejections:[],pendingRejectionCheck:false,scheduleHandlers:function scheduleHandlers(promise){if(promise._status===STATUS_PENDING){return}this.handlers=this.handlers.concat(promise._handlers);promise._handlers=[];if(this.running){return}this.running=true;setTimeout(this.runHandlers.bind(this),0)},runHandlers:function runHandlers(){var RUN_TIMEOUT=1;var timeoutAt=Date.now()+RUN_TIMEOUT;while(this.handlers.length>0){var handler=this.handlers.shift();var nextStatus=handler.thisPromise._status;var nextValue=handler.thisPromise._value;try{if(nextStatus===STATUS_RESOLVED){if(typeof handler.onResolve==="function"){nextValue=handler.onResolve(nextValue)}}else if(typeof handler.onReject==="function"){nextValue=handler.onReject(nextValue);nextStatus=STATUS_RESOLVED;if(handler.thisPromise._unhandledRejection){this.removeUnhandeledRejection(handler.thisPromise)}}}catch(ex){nextStatus=STATUS_REJECTED;nextValue=ex}handler.nextPromise._updateStatus(nextStatus,nextValue);if(Date.now()>=timeoutAt){break}}if(this.handlers.length>0){setTimeout(this.runHandlers.bind(this),0);return}this.running=false},addUnhandledRejection:function addUnhandledRejection(promise){this.unhandledRejections.push({promise:promise,time:Date.now()});this.scheduleRejectionCheck()},removeUnhandeledRejection:function removeUnhandeledRejection(promise){promise._unhandledRejection=false;for(var i=0;i<this.unhandledRejections.length;i++){if(this.unhandledRejections[i].promise===promise){this.unhandledRejections.splice(i);i--}}},scheduleRejectionCheck:function scheduleRejectionCheck(){if(this.pendingRejectionCheck){return}this.pendingRejectionCheck=true;setTimeout(function rejectionCheck(){this.pendingRejectionCheck=false;var now=Date.now();for(var i=0;i<this.unhandledRejections.length;i++){if(now-this.unhandledRejections[i].time>REJECTION_TIMEOUT){var unhandled=this.unhandledRejections[i].promise._value;var msg="Unhandled rejection: "+unhandled;if(unhandled.stack){msg+="\n"+unhandled.stack}warn(msg);this.unhandledRejections.splice(i);i--}}if(this.unhandledRejections.length){this.scheduleRejectionCheck()}}.bind(this),REJECTION_TIMEOUT)}};function Promise(resolver){this._status=STATUS_PENDING;this._handlers=[];try{resolver.call(this,this._resolve.bind(this),this._reject.bind(this))}catch(e){this._reject(e)}}Promise.all=function Promise_all(promises){var resolveAll,rejectAll;var deferred=new Promise(function(resolve,reject){resolveAll=resolve;rejectAll=reject});var unresolved=promises.length;var results=[];if(unresolved===0){resolveAll(results);return deferred}function reject(reason){if(deferred._status===STATUS_REJECTED){return}results=[];rejectAll(reason)}for(var i=0,ii=promises.length;i<ii;++i){var promise=promises[i];var resolve=function(i){return function(value){if(deferred._status===STATUS_REJECTED){return}results[i]=value;unresolved--;if(unresolved===0){resolveAll(results)}}}(i);if(Promise.isPromise(promise)){promise.then(resolve,reject)}else{resolve(promise)}}return deferred};Promise.isPromise=function Promise_isPromise(value){return value&&typeof value.then==="function"};Promise.resolve=function Promise_resolve(value){return new Promise(function(resolve){resolve(value)})};Promise.reject=function Promise_reject(reason){return new Promise(function(resolve,reject){reject(reason)})};Promise.prototype={_status:null,_value:null,_handlers:null,_unhandledRejection:null,_updateStatus:function Promise__updateStatus(status,value){if(this._status===STATUS_RESOLVED||this._status===STATUS_REJECTED){return}if(status===STATUS_RESOLVED&&Promise.isPromise(value)){value.then(this._updateStatus.bind(this,STATUS_RESOLVED),this._updateStatus.bind(this,STATUS_REJECTED));return}this._status=status;this._value=value;if(status===STATUS_REJECTED&&this._handlers.length===0){this._unhandledRejection=true;HandlerManager.addUnhandledRejection(this)}HandlerManager.scheduleHandlers(this)},_resolve:function Promise_resolve(value){this._updateStatus(STATUS_RESOLVED,value)},_reject:function Promise_reject(reason){this._updateStatus(STATUS_REJECTED,reason)},then:function Promise_then(onResolve,onReject){var nextPromise=new Promise(function(resolve,reject){this.resolve=resolve;this.reject=reject});this._handlers.push({thisPromise:this,onResolve:onResolve,onReject:onReject,nextPromise:nextPromise});HandlerManager.scheduleHandlers(this);return nextPromise},"catch":function Promise_catch(onReject){return this.then(undefined,onReject)}};globalScope.Promise=Promise})();(function WeakMapClosure(){if(globalScope.WeakMap){return}var id=0;function WeakMap(){this.id="$weakmap"+id++}WeakMap.prototype={has:function(obj){return!!Object.getOwnPropertyDescriptor(obj,this.id)},get:function(obj,defaultValue){return this.has(obj)?obj[this.id]:defaultValue},set:function(obj,value){Object.defineProperty(obj,this.id,{value:value,enumerable:false,configurable:true})},"delete":function(obj){delete obj[this.id]}};globalScope.WeakMap=WeakMap})();var StatTimer=function StatTimerClosure(){function rpad(str,pad,length){while(str.length<length){str+=pad}return str}function StatTimer(){this.started=Object.create(null);this.times=[];this.enabled=true}StatTimer.prototype={time:function StatTimer_time(name){if(!this.enabled){return}if(name in this.started){warn("Timer is already running for "+name)}this.started[name]=Date.now()},timeEnd:function StatTimer_timeEnd(name){if(!this.enabled){return}if(!(name in this.started)){warn("Timer has not been started for "+name)}this.times.push({name:name,start:this.started[name],end:Date.now()});delete this.started[name]},toString:function StatTimer_toString(){var i,ii;var times=this.times;var out="";var longest=0;for(i=0,ii=times.length;i<ii;++i){var name=times[i]["name"];if(name.length>longest){longest=name.length}}for(i=0,ii=times.length;i<ii;++i){var span=times[i];var duration=span.end-span.start;out+=rpad(span["name"]," ",longest)+" "+duration+"ms\n"}return out}};return StatTimer}();var createBlob=function createBlob(data,contentType){if(typeof Blob!=="undefined"){return new Blob([data],{type:contentType})}warn('The "Blob" constructor is not supported.')};var createObjectURL=function createObjectURLClosure(){var digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(data,contentType,forceDataSchema){if(!forceDataSchema&&typeof URL!=="undefined"&&URL.createObjectURL){var blob=createBlob(data,contentType);return URL.createObjectURL(blob)}var buffer="data:"+contentType+";base64,";for(var i=0,ii=data.length;i<ii;i+=3){var b1=data[i]&255;var b2=data[i+1]&255;var b3=data[i+2]&255;var d1=b1>>2,d2=(b1&3)<<4|b2>>4;var d3=i+1<ii?(b2&15)<<2|b3>>6:64;var d4=i+2<ii?b3&63:64;buffer+=digits[d1]+digits[d2]+digits[d3]+digits[d4]}return buffer}}();function MessageHandler(sourceName,targetName,comObj){this.sourceName=sourceName;this.targetName=targetName;this.comObj=comObj;this.callbackIndex=1;this.postMessageTransfers=true;var callbacksCapabilities=this.callbacksCapabilities=Object.create(null);var ah=this.actionHandler=Object.create(null);this._onComObjOnMessage=function messageHandlerComObjOnMessage(event){var data=event.data;if(data.targetName!==this.sourceName){return}if(data.isReply){var callbackId=data.callbackId;if(data.callbackId in callbacksCapabilities){var callback=callbacksCapabilities[callbackId];delete callbacksCapabilities[callbackId];if("error"in data){callback.reject(data.error)}else{callback.resolve(data.data)}}else{error("Cannot resolve callback "+callbackId)}}else if(data.action in ah){var action=ah[data.action];if(data.callbackId){var sourceName=this.sourceName;var targetName=data.sourceName;Promise.resolve().then(function(){return action[0].call(action[1],data.data)}).then(function(result){comObj.postMessage({sourceName:sourceName,targetName:targetName,isReply:true,callbackId:data.callbackId,data:result})},function(reason){if(reason instanceof Error){reason=reason+""}comObj.postMessage({sourceName:sourceName,targetName:targetName,isReply:true,callbackId:data.callbackId,error:reason})})}else{action[0].call(action[1],data.data)}}else{error("Unknown action from worker: "+data.action)}}.bind(this);comObj.addEventListener("message",this._onComObjOnMessage)}MessageHandler.prototype={on:function messageHandlerOn(actionName,handler,scope){var ah=this.actionHandler;if(ah[actionName]){error('There is already an actionName called "'+actionName+'"')}ah[actionName]=[handler,scope]},send:function messageHandlerSend(actionName,data,transfers){var message={sourceName:this.sourceName,targetName:this.targetName,action:actionName,data:data};this.postMessage(message,transfers)},sendWithPromise:function messageHandlerSendWithPromise(actionName,data,transfers){var callbackId=this.callbackIndex++;var message={sourceName:this.sourceName,targetName:this.targetName,action:actionName,data:data,callbackId:callbackId};var capability=createPromiseCapability();this.callbacksCapabilities[callbackId]=capability;try{this.postMessage(message,transfers)}catch(e){capability.reject(e)}return capability.promise},postMessage:function(message,transfers){if(transfers&&this.postMessageTransfers){this.comObj.postMessage(message,transfers)}else{this.comObj.postMessage(message)}},destroy:function(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}};function loadJpegStream(id,imageUrl,objs){var img=new Image;img.onload=function loadJpegStream_onloadClosure(){objs.resolve(id,img)};img.onerror=function loadJpegStream_onerrorClosure(){objs.resolve(id,null);warn("Error during JPEG image loading")};img.src=imageUrl}(function checkURLConstructor(scope){var hasWorkingUrl=false;try{if(typeof URL==="function"&&typeof URL.prototype==="object"&&"origin"in URL.prototype){var u=new URL("b","http://a");u.pathname="c%20d";hasWorkingUrl=u.href==="http://a/c%20d"}}catch(e){}if(hasWorkingUrl){return}var relative=Object.create(null);relative["ftp"]=21;relative["file"]=0;relative["gopher"]=70;relative["http"]=80;relative["https"]=443;relative["ws"]=80;relative["wss"]=443;var relativePathDotMapping=Object.create(null);relativePathDotMapping["%2e"]=".";relativePathDotMapping[".%2e"]="..";relativePathDotMapping["%2e."]="..";relativePathDotMapping["%2e%2e"]="..";function isRelativeScheme(scheme){return relative[scheme]!==undefined}function invalid(){clear.call(this);this._isInvalid=true}function IDNAToASCII(h){if(""===h){invalid.call(this)}return h.toLowerCase()}function percentEscape(c){var unicode=c.charCodeAt(0);if(unicode>32&&unicode<127&&[34,35,60,62,63,96].indexOf(unicode)===-1){return c}return encodeURIComponent(c)}function percentEscapeQuery(c){var unicode=c.charCodeAt(0);if(unicode>32&&unicode<127&&[34,35,60,62,96].indexOf(unicode)===-1){return c}return encodeURIComponent(c)}var EOF,ALPHA=/[a-zA-Z]/,ALPHANUMERIC=/[a-zA-Z0-9\+\-\.]/;function parse(input,stateOverride,base){function err(message){errors.push(message)}var state=stateOverride||"scheme start",cursor=0,buffer="",seenAt=false,seenBracket=false,errors=[];loop:while((input[cursor-1]!==EOF||cursor===0)&&!this._isInvalid){var c=input[cursor];switch(state){case"scheme start":if(c&&ALPHA.test(c)){buffer+=c.toLowerCase();state="scheme"}else if(!stateOverride){buffer="";state="no scheme";continue}else{err("Invalid scheme.");break loop}break;case"scheme":if(c&&ALPHANUMERIC.test(c)){buffer+=c.toLowerCase()}else if(":"===c){this._scheme=buffer;buffer="";if(stateOverride){break loop}if(isRelativeScheme(this._scheme)){this._isRelative=true}if("file"===this._scheme){state="relative"}else if(this._isRelative&&base&&base._scheme===this._scheme){state="relative or authority"}else if(this._isRelative){state="authority first slash"}else{state="scheme data"}}else if(!stateOverride){buffer="";cursor=0;state="no scheme";continue}else if(EOF===c){break loop}else{err("Code point not allowed in scheme: "+c);
2break loop}break;case"scheme data":if("?"===c){this._query="?";state="query"}else if("#"===c){this._fragment="#";state="fragment"}else{if(EOF!==c&&" "!==c&&"\n"!==c&&"\r"!==c){this._schemeData+=percentEscape(c)}}break;case"no scheme":if(!base||!isRelativeScheme(base._scheme)){err("Missing scheme.");invalid.call(this)}else{state="relative";continue}break;case"relative or authority":if("/"===c&&"/"===input[cursor+1]){state="authority ignore slashes"}else{err("Expected /, got: "+c);state="relative";continue}break;case"relative":this._isRelative=true;if("file"!==this._scheme){this._scheme=base._scheme}if(EOF===c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query=base._query;this._username=base._username;this._password=base._password;break loop}else if("/"===c||"\\"===c){if("\\"===c){err("\\ is an invalid code point.")}state="relative slash"}else if("?"===c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query="?";this._username=base._username;this._password=base._password;state="query"}else if("#"===c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query=base._query;this._fragment="#";this._username=base._username;this._password=base._password;state="fragment"}else{var nextC=input[cursor+1];var nextNextC=input[cursor+2];if("file"!==this._scheme||!ALPHA.test(c)||nextC!==":"&&nextC!=="|"||EOF!==nextNextC&&"/"!==nextNextC&&"\\"!==nextNextC&&"?"!==nextNextC&&"#"!==nextNextC){this._host=base._host;this._port=base._port;this._username=base._username;this._password=base._password;this._path=base._path.slice();this._path.pop()}state="relative path";continue}break;case"relative slash":if("/"===c||"\\"===c){if("\\"===c){err("\\ is an invalid code point.")}if("file"===this._scheme){state="file host"}else{state="authority ignore slashes"}}else{if("file"!==this._scheme){this._host=base._host;this._port=base._port;this._username=base._username;this._password=base._password}state="relative path";continue}break;case"authority first slash":if("/"===c){state="authority second slash"}else{err("Expected '/', got: "+c);state="authority ignore slashes";continue}break;case"authority second slash":state="authority ignore slashes";if("/"!==c){err("Expected '/', got: "+c);continue}break;case"authority ignore slashes":if("/"!==c&&"\\"!==c){state="authority";continue}else{err("Expected authority, got: "+c)}break;case"authority":if("@"===c){if(seenAt){err("@ already seen.");buffer+="%40"}seenAt=true;for(var i=0;i<buffer.length;i++){var cp=buffer[i];if(" "===cp||"\n"===cp||"\r"===cp){err("Invalid whitespace in authority.");continue}if(":"===cp&&null===this._password){this._password="";continue}var tempC=percentEscape(cp);if(null!==this._password){this._password+=tempC}else{this._username+=tempC}}buffer=""}else if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c){cursor-=buffer.length;buffer="";state="host";continue}else{buffer+=c}break;case"file host":if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c){if(buffer.length===2&&ALPHA.test(buffer[0])&&(buffer[1]===":"||buffer[1]==="|")){state="relative path"}else if(buffer.length===0){state="relative path start"}else{this._host=IDNAToASCII.call(this,buffer);buffer="";state="relative path start"}continue}else if(" "===c||"\n"===c||"\r"===c){err("Invalid whitespace in file host.")}else{buffer+=c}break;case"host":case"hostname":if(":"===c&&!seenBracket){this._host=IDNAToASCII.call(this,buffer);buffer="";state="port";if("hostname"===stateOverride){break loop}}else if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c){this._host=IDNAToASCII.call(this,buffer);buffer="";state="relative path start";if(stateOverride){break loop}continue}else if(" "!==c&&"\n"!==c&&"\r"!==c){if("["===c){seenBracket=true}else if("]"===c){seenBracket=false}buffer+=c}else{err("Invalid code point in host/hostname: "+c)}break;case"port":if(/[0-9]/.test(c)){buffer+=c}else if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c||stateOverride){if(""!==buffer){var temp=parseInt(buffer,10);if(temp!==relative[this._scheme]){this._port=temp+""}buffer=""}if(stateOverride){break loop}state="relative path start";continue}else if(" "===c||"\n"===c||"\r"===c){err("Invalid code point in port: "+c)}else{invalid.call(this)}break;case"relative path start":if("\\"===c){err("'\\' not allowed in path.")}state="relative path";if("/"!==c&&"\\"!==c){continue}break;case"relative path":if(EOF===c||"/"===c||"\\"===c||!stateOverride&&("?"===c||"#"===c)){if("\\"===c){err("\\ not allowed in relative path.")}var tmp;if(tmp=relativePathDotMapping[buffer.toLowerCase()]){buffer=tmp}if(".."===buffer){this._path.pop();if("/"!==c&&"\\"!==c){this._path.push("")}}else if("."===buffer&&"/"!==c&&"\\"!==c){this._path.push("")}else if("."!==buffer){if("file"===this._scheme&&this._path.length===0&&buffer.length===2&&ALPHA.test(buffer[0])&&buffer[1]==="|"){buffer=buffer[0]+":"}this._path.push(buffer)}buffer="";if("?"===c){this._query="?";state="query"}else if("#"===c){this._fragment="#";state="fragment"}}else if(" "!==c&&"\n"!==c&&"\r"!==c){buffer+=percentEscape(c)}break;case"query":if(!stateOverride&&"#"===c){this._fragment="#";state="fragment"}else if(EOF!==c&&" "!==c&&"\n"!==c&&"\r"!==c){this._query+=percentEscapeQuery(c)}break;case"fragment":if(EOF!==c&&" "!==c&&"\n"!==c&&"\r"!==c){this._fragment+=c}break}cursor++}}function clear(){this._scheme="";this._schemeData="";this._username="";this._password=null;this._host="";this._port="";this._path=[];this._query="";this._fragment="";this._isInvalid=false;this._isRelative=false}function JURL(url,base){if(base!==undefined&&!(base instanceof JURL)){base=new JURL(String(base))}this._url=url;clear.call(this);var input=url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,"");parse.call(this,input,null,base)}JURL.prototype={toString:function(){return this.href},get href(){if(this._isInvalid){return this._url}var authority="";if(""!==this._username||null!==this._password){authority=this._username+(null!==this._password?":"+this._password:"")+"@"}return this.protocol+(this._isRelative?"//"+authority+this.host:"")+this.pathname+this._query+this._fragment},set href(href){clear.call(this);parse.call(this,href)},get protocol(){return this._scheme+":"},set protocol(protocol){if(this._isInvalid){return}parse.call(this,protocol+":","scheme start")},get host(){return this._isInvalid?"":this._port?this._host+":"+this._port:this._host},set host(host){if(this._isInvalid||!this._isRelative){return}parse.call(this,host,"host")},get hostname(){return this._host},set hostname(hostname){if(this._isInvalid||!this._isRelative){return}parse.call(this,hostname,"hostname")},get port(){return this._port},set port(port){if(this._isInvalid||!this._isRelative){return}parse.call(this,port,"port")},get pathname(){return this._isInvalid?"":this._isRelative?"/"+this._path.join("/"):this._schemeData},set pathname(pathname){if(this._isInvalid||!this._isRelative){return}this._path=[];parse.call(this,pathname,"relative path start")},get search(){return this._isInvalid||!this._query||"?"===this._query?"":this._query},set search(search){if(this._isInvalid||!this._isRelative){return}this._query="?";if("?"===search[0]){search=search.slice(1)}parse.call(this,search,"query")},get hash(){return this._isInvalid||!this._fragment||"#"===this._fragment?"":this._fragment},set hash(hash){if(this._isInvalid){return}this._fragment="#";if("#"===hash[0]){hash=hash.slice(1)}parse.call(this,hash,"fragment")},get origin(){var host;if(this._isInvalid||!this._scheme){return""}switch(this._scheme){case"data":case"file":case"javascript":case"mailto":return"null"}host=this.host;if(!host){return""}return this._scheme+"://"+host}};var OriginalURL=scope.URL;if(OriginalURL){JURL.createObjectURL=function(blob){return OriginalURL.createObjectURL.apply(OriginalURL,arguments)};JURL.revokeObjectURL=function(url){OriginalURL.revokeObjectURL(url)}}scope.URL=JURL})(globalScope);exports.FONT_IDENTITY_MATRIX=FONT_IDENTITY_MATRIX;exports.IDENTITY_MATRIX=IDENTITY_MATRIX;exports.OPS=OPS;exports.VERBOSITY_LEVELS=VERBOSITY_LEVELS;exports.UNSUPPORTED_FEATURES=UNSUPPORTED_FEATURES;exports.AnnotationBorderStyleType=AnnotationBorderStyleType;exports.AnnotationFieldFlag=AnnotationFieldFlag;exports.AnnotationFlag=AnnotationFlag;exports.AnnotationType=AnnotationType;exports.FontType=FontType;exports.ImageKind=ImageKind;exports.InvalidPDFException=InvalidPDFException;exports.MessageHandler=MessageHandler;exports.MissingDataException=MissingDataException;exports.MissingPDFException=MissingPDFException;exports.NotImplementedException=NotImplementedException;exports.PageViewport=PageViewport;exports.PasswordException=PasswordException;exports.PasswordResponses=PasswordResponses;exports.StatTimer=StatTimer;exports.StreamType=StreamType;exports.TextRenderingMode=TextRenderingMode;exports.UnexpectedResponseException=UnexpectedResponseException;exports.UnknownErrorException=UnknownErrorException;exports.Util=Util;exports.XRefParseException=XRefParseException;exports.arrayByteLength=arrayByteLength;exports.arraysToBytes=arraysToBytes;exports.assert=assert;exports.bytesToString=bytesToString;exports.createBlob=createBlob;exports.createPromiseCapability=createPromiseCapability;exports.createObjectURL=createObjectURL;exports.deprecated=deprecated;exports.error=error;exports.getLookupTableFactory=getLookupTableFactory;exports.getVerbosityLevel=getVerbosityLevel;exports.globalScope=globalScope;exports.info=info;exports.isArray=isArray;exports.isArrayBuffer=isArrayBuffer;exports.isBool=isBool;exports.isEmptyObj=isEmptyObj;exports.isInt=isInt;exports.isNum=isNum;exports.isString=isString;exports.isSpace=isSpace;exports.isSameOrigin=isSameOrigin;exports.isValidUrl=isValidUrl;exports.isLittleEndian=isLittleEndian;exports.isEvalSupported=isEvalSupported;exports.loadJpegStream=loadJpegStream;exports.log2=log2;exports.readInt8=readInt8;exports.readUint16=readUint16;exports.readUint32=readUint32;exports.removeNullCharacters=removeNullCharacters;exports.setVerbosityLevel=setVerbosityLevel;exports.shadow=shadow;exports.string32=string32;exports.stringToBytes=stringToBytes;exports.stringToPDFString=stringToPDFString;exports.stringToUTF8String=stringToUTF8String;exports.utf8StringToString=utf8StringToString;exports.warn=warn});(function(root,factory){{factory(root.pdfjsDisplayDOMUtils={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var removeNullCharacters=sharedUtil.removeNullCharacters;var warn=sharedUtil.warn;var CustomStyle=function CustomStyleClosure(){var prefixes=["ms","Moz","Webkit","O"];var _cache=Object.create(null);function CustomStyle(){}CustomStyle.getProp=function get(propName,element){if(arguments.length===1&&typeof _cache[propName]==="string"){return _cache[propName]}element=element||document.documentElement;var style=element.style,prefixed,uPropName;if(typeof style[propName]==="string"){return _cache[propName]=propName}uPropName=propName.charAt(0).toUpperCase()+propName.slice(1);for(var i=0,l=prefixes.length;i<l;i++){prefixed=prefixes[i]+uPropName;if(typeof style[prefixed]==="string"){return _cache[propName]=prefixed}}return _cache[propName]="undefined"};CustomStyle.setProp=function set(propName,element,str){var prop=this.getProp(propName);if(prop!=="undefined"){element.style[prop]=str}};return CustomStyle}();function hasCanvasTypedArrays(){var canvas=document.createElement("canvas");canvas.width=canvas.height=1;var ctx=canvas.getContext("2d");var imageData=ctx.createImageData(1,1);return typeof imageData.data.buffer!=="undefined"}var LinkTarget={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};var LinkTargetStringMap=["","_self","_blank","_parent","_top"];function addLinkAttributes(link,params){var url=params&&params.url;link.href=link.title=url?removeNullCharacters(url):"";if(url){var target=params.target;if(typeof target==="undefined"){target=getDefaultSetting("externalLinkTarget")}link.target=LinkTargetStringMap[target];var rel=params.rel;if(typeof rel==="undefined"){rel=getDefaultSetting("externalLinkRel")}link.rel=rel}}function getFilenameFromUrl(url){var anchor=url.indexOf("#");var query=url.indexOf("?");var end=Math.min(anchor>0?anchor:url.length,query>0?query:url.length);return url.substring(url.lastIndexOf("/",end)+1,end)}function getDefaultSetting(id){var globalSettings=sharedUtil.globalScope.PDFJS;switch(id){case"pdfBug":return globalSettings?globalSettings.pdfBug:false;case"disableAutoFetch":return globalSettings?globalSettings.disableAutoFetch:false;case"disableStream":return globalSettings?globalSettings.disableStream:false;case"disableRange":return globalSettings?globalSettings.disableRange:false;case"disableFontFace":return globalSettings?globalSettings.disableFontFace:false;case"disableCreateObjectURL":return globalSettings?globalSettings.disableCreateObjectURL:false;case"disableWebGL":return globalSettings?globalSettings.disableWebGL:true;case"cMapUrl":return globalSettings?globalSettings.cMapUrl:null;case"cMapPacked":return globalSettings?globalSettings.cMapPacked:false;case"postMessageTransfers":return globalSettings?globalSettings.postMessageTransfers:true;case"workerSrc":return globalSettings?globalSettings.workerSrc:null;case"disableWorker":return globalSettings?globalSettings.disableWorker:false;case"maxImageSize":return globalSettings?globalSettings.maxImageSize:-1;case"imageResourcesPath":return globalSettings?globalSettings.imageResourcesPath:"";case"isEvalSupported":return globalSettings?globalSettings.isEvalSupported:true;case"externalLinkTarget":if(!globalSettings){return LinkTarget.NONE}switch(globalSettings.externalLinkTarget){case LinkTarget.NONE:case LinkTarget.SELF:case LinkTarget.BLANK:case LinkTarget.PARENT:case LinkTarget.TOP:return globalSettings.externalLinkTarget}warn("PDFJS.externalLinkTarget is invalid: "+globalSettings.externalLinkTarget);globalSettings.externalLinkTarget=LinkTarget.NONE;return LinkTarget.NONE;case"externalLinkRel":return globalSettings?globalSettings.externalLinkRel:"noreferrer";case"enableStats":return!!(globalSettings&&globalSettings.enableStats);default:throw new Error("Unknown default setting: "+id)}}function isExternalLinkTargetSet(){var externalLinkTarget=getDefaultSetting("externalLinkTarget");switch(externalLinkTarget){case LinkTarget.NONE:return false;case LinkTarget.SELF:case LinkTarget.BLANK:case LinkTarget.PARENT:case LinkTarget.TOP:return true}}exports.CustomStyle=CustomStyle;exports.addLinkAttributes=addLinkAttributes;exports.isExternalLinkTargetSet=isExternalLinkTargetSet;exports.getFilenameFromUrl=getFilenameFromUrl;exports.LinkTarget=LinkTarget;exports.hasCanvasTypedArrays=hasCanvasTypedArrays;exports.getDefaultSetting=getDefaultSetting});(function(root,factory){{factory(root.pdfjsDisplayFontLoader={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var assert=sharedUtil.assert;var bytesToString=sharedUtil.bytesToString;var string32=sharedUtil.string32;var shadow=sharedUtil.shadow;var warn=sharedUtil.warn;function FontLoader(docId){this.docId=docId;this.styleElement=null;this.nativeFontFaces=[];this.loadTestFontId=0;this.loadingContext={requests:[],nextRequestId:0}}FontLoader.prototype={insertRule:function fontLoaderInsertRule(rule){var styleElement=this.styleElement;if(!styleElement){styleElement=this.styleElement=document.createElement("style");styleElement.id="PDFJS_FONT_STYLE_TAG_"+this.docId;document.documentElement.getElementsByTagName("head")[0].appendChild(styleElement)}var styleSheet=styleElement.sheet;styleSheet.insertRule(rule,styleSheet.cssRules.length)},clear:function fontLoaderClear(){var styleElement=this.styleElement;if(styleElement){styleElement.parentNode.removeChild(styleElement);styleElement=this.styleElement=null}this.nativeFontFaces.forEach(function(nativeFontFace){document.fonts.delete(nativeFontFace)});this.nativeFontFaces.length=0},get loadTestFont(){return shadow(this,"loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ"+"AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA"+"AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm"+"FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA"+"AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A"+"ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA"+"MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA"+"AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA"+"AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ"+"AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA"+"AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA"+"EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA"+"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"+"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA"+"AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc"+"A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF"+"hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA"+"AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg"+"ABAAAAAAAAAAAD6AAAAAAAAA=="))},addNativeFontFace:function fontLoader_addNativeFontFace(nativeFontFace){this.nativeFontFaces.push(nativeFontFace);document.fonts.add(nativeFontFace)},bind:function fontLoaderBind(fonts,callback){var rules=[];var fontsToLoad=[];var fontLoadPromises=[];var getNativeFontPromise=function(nativeFontFace){return nativeFontFace.loaded.catch(function(e){warn('Failed to load font "'+nativeFontFace.family+'": '+e)})};for(var i=0,ii=fonts.length;i<ii;i++){var font=fonts[i];if(font.attached||font.loading===false){continue}font.attached=true;if(FontLoader.isFontLoadingAPISupported){var nativeFontFace=font.createNativeFontFace();if(nativeFontFace){this.addNativeFontFace(nativeFontFace);fontLoadPromises.push(getNativeFontPromise(nativeFontFace))}}else{var rule=font.createFontFaceRule();if(rule){this.insertRule(rule);rules.push(rule);fontsToLoad.push(font)}}}var request=this.queueLoadingCallback(callback);if(FontLoader.isFontLoadingAPISupported){Promise.all(fontLoadPromises).then(function(){request.complete()})}else if(rules.length>0&&!FontLoader.isSyncFontLoadingSupported){this.prepareFontLoadEvent(rules,fontsToLoad,request)}else{request.complete()}},queueLoadingCallback:function FontLoader_queueLoadingCallback(callback){function LoadLoader_completeRequest(){assert(!request.end,"completeRequest() cannot be called twice");request.end=Date.now();while(context.requests.length>0&&context.requests[0].end){var otherRequest=context.requests.shift();setTimeout(otherRequest.callback,0)}}var context=this.loadingContext;var requestId="pdfjs-font-loading-"+context.nextRequestId++;var request={id:requestId,complete:LoadLoader_completeRequest,callback:callback,started:Date.now()};context.requests.push(request);return request},prepareFontLoadEvent:function fontLoaderPrepareFontLoadEvent(rules,fonts,request){function int32(data,offset){return data.charCodeAt(offset)<<24|data.charCodeAt(offset+1)<<16|data.charCodeAt(offset+2)<<8|data.charCodeAt(offset+3)&255}function spliceString(s,offset,remove,insert){var chunk1=s.substr(0,offset);var chunk2=s.substr(offset+remove);return chunk1+insert+chunk2}var i,ii;var canvas=document.createElement("canvas");canvas.width=1;canvas.height=1;var ctx=canvas.getContext("2d");var called=0;function isFontReady(name,callback){called++;if(called>30){warn("Load test font never loaded.");callback();return}ctx.font="30px "+name;ctx.fillText(".",0,20);var imageData=ctx.getImageData(0,0,1,1);if(imageData.data[3]>0){callback();return}setTimeout(isFontReady.bind(null,name,callback))}var loadTestFontId="lt"+Date.now()+this.loadTestFontId++;var data=this.loadTestFont;var COMMENT_OFFSET=976;data=spliceString(data,COMMENT_OFFSET,loadTestFontId.length,loadTestFontId);var CFF_CHECKSUM_OFFSET=16;var XXXX_VALUE=1482184792;var checksum=int32(data,CFF_CHECKSUM_OFFSET);for(i=0,ii=loadTestFontId.length-3;i<ii;i+=4){checksum=checksum-XXXX_VALUE+int32(loadTestFontId,i)|0}if(i<loadTestFontId.length){checksum=checksum-XXXX_VALUE+int32(loadTestFontId+"XXX",i)|0}data=spliceString(data,CFF_CHECKSUM_OFFSET,4,string32(checksum));var url="url(data:font/opentype;base64,"+btoa(data)+");";var rule='@font-face { font-family:"'+loadTestFontId+'";src:'+url+"}";this.insertRule(rule);var names=[];for(i=0,ii=fonts.length;i<ii;i++){names.push(fonts[i].loadedName)}names.push(loadTestFontId);var div=document.createElement("div");div.setAttribute("style","visibility: hidden;"+"width: 10px; height: 10px;"+"position: absolute; top: 0px; left: 0px;");for(i=0,ii=names.length;i<ii;++i){var span=document.createElement("span");span.textContent="Hi";span.style.fontFamily=names[i];div.appendChild(span)}document.body.appendChild(div);isFontReady(loadTestFontId,function(){document.body.removeChild(div);request.complete()})}};FontLoader.isFontLoadingAPISupported=typeof document!=="undefined"&&!!document.fonts;Object.defineProperty(FontLoader,"isSyncFontLoadingSupported",{get:function(){if(typeof navigator==="undefined"){return shadow(FontLoader,"isSyncFontLoadingSupported",true)}var supported=false;var m=/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);if(m&&m[1]>=14){supported=true}return shadow(FontLoader,"isSyncFontLoadingSupported",supported)},enumerable:true,configurable:true});var IsEvalSupportedCached={get value(){return shadow(this,"value",sharedUtil.isEvalSupported())}};var FontFaceObject=function FontFaceObjectClosure(){function FontFaceObject(translatedData,options){this.compiledGlyphs=Object.create(null);for(var i in translatedData){this[i]=translatedData[i]}this.options=options}FontFaceObject.prototype={createNativeFontFace:function FontFaceObject_createNativeFontFace(){if(!this.data){return null}if(this.options.disableFontFace){this.disableFontFace=true;return null}var nativeFontFace=new FontFace(this.loadedName,this.data,{});if(this.options.fontRegistry){this.options.fontRegistry.registerFont(this)}return nativeFontFace},createFontFaceRule:function FontFaceObject_createFontFaceRule(){if(!this.data){return null}if(this.options.disableFontFace){this.disableFontFace=true;return null}var data=bytesToString(new Uint8Array(this.data));var fontName=this.loadedName;var url="url(data:"+this.mimetype+";base64,"+btoa(data)+");";var rule='@font-face { font-family:"'+fontName+'";src:'+url+"}";if(this.options.fontRegistry){this.options.fontRegistry.registerFont(this,url)}return rule},getPathGenerator:function FontFaceObject_getPathGenerator(objs,character){if(!(character in this.compiledGlyphs)){var cmds=objs.get(this.loadedName+"_path_"+character);var current,i,len;if(this.options.isEvalSupported&&IsEvalSupportedCached.value){var args,js="";for(i=0,len=cmds.length;i<len;i++){current=cmds[i];if(current.args!==undefined){args=current.args.join(",")}else{args=""}js+="c."+current.cmd+"("+args+");\n"}this.compiledGlyphs[character]=new Function("c","size",js)}else{this.compiledGlyphs[character]=function(c,size){for(i=0,len=cmds.length;i<len;i++){current=cmds[i];if(current.cmd==="scale"){current.args=[size,-size]}c[current.cmd].apply(c,current.args)}}}}return this.compiledGlyphs[character]}};return FontFaceObject}();exports.FontFaceObject=FontFaceObject;exports.FontLoader=FontLoader});(function(root,factory){{factory(root.pdfjsDisplayMetadata={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var error=sharedUtil.error;function fixMetadata(meta){return meta.replace(/>\\376\\377([^<]+)/g,function(all,codes){var bytes=codes.replace(/\\([0-3])([0-7])([0-7])/g,function(code,d1,d2,d3){return String.fromCharCode(d1*64+d2*8+d3*1)});var chars="";for(var i=0;i<bytes.length;i+=2){var code=bytes.charCodeAt(i)*256+bytes.charCodeAt(i+1);chars+=code>=32&&code<127&&code!==60&&code!==62&&code!==38&&false?String.fromCharCode(code):"&#x"+(65536+code).toString(16).substring(1)+";"}return">"+chars})}function Metadata(meta){if(typeof meta==="string"){meta=fixMetadata(meta);var parser=new DOMParser;meta=parser.parseFromString(meta,"application/xml")}else if(!(meta instanceof Document)){error("Metadata: Invalid metadata object")}this.metaDocument=meta;this.metadata=Object.create(null);this.parse()}Metadata.prototype={parse:function Metadata_parse(){var doc=this.metaDocument;var rdf=doc.documentElement;if(rdf.nodeName.toLowerCase()!=="rdf:rdf"){rdf=rdf.firstChild;while(rdf&&rdf.nodeName.toLowerCase()!=="rdf:rdf"){rdf=rdf.nextSibling}}var nodeName=rdf?rdf.nodeName.toLowerCase():null;if(!rdf||nodeName!=="rdf:rdf"||!rdf.hasChildNodes()){return}var children=rdf.childNodes,desc,entry,name,i,ii,length,iLength;for(i=0,length=children.length;i<length;i++){desc=children[i];if(desc.nodeName.toLowerCase()!=="rdf:description"){continue}for(ii=0,iLength=desc.childNodes.length;ii<iLength;ii++){if(desc.childNodes[ii].nodeName.toLowerCase()!=="#text"){entry=desc.childNodes[ii];name=entry.nodeName.toLowerCase();this.metadata[name]=entry.textContent.trim()}}}},get:function Metadata_get(name){return this.metadata[name]||null},has:function Metadata_has(name){return typeof this.metadata[name]!=="undefined"}};exports.Metadata=Metadata});(function(root,factory){{factory(root.pdfjsDisplaySVG={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var FONT_IDENTITY_MATRIX=sharedUtil.FONT_IDENTITY_MATRIX;var IDENTITY_MATRIX=sharedUtil.IDENTITY_MATRIX;var ImageKind=sharedUtil.ImageKind;var OPS=sharedUtil.OPS;var Util=sharedUtil.Util;var isNum=sharedUtil.isNum;var isArray=sharedUtil.isArray;var warn=sharedUtil.warn;var createObjectURL=sharedUtil.createObjectURL;var SVG_DEFAULTS={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"};var convertImgDataToPng=function convertImgDataToPngClosure(){var PNG_HEADER=new Uint8Array([137,80,78,71,13,10,26,10]);var CHUNK_WRAPPER_SIZE=12;var crcTable=new Int32Array(256);for(var i=0;i<256;i++){var c=i;for(var h=0;h<8;h++){if(c&1){c=3988292384^c>>1&2147483647}else{c=c>>1&2147483647}}crcTable[i]=c}function crc32(data,start,end){var crc=-1;for(var i=start;i<end;i++){var a=(crc^data[i])&255;var b=crcTable[a];crc=crc>>>8^b}return crc^-1}function writePngChunk(type,body,data,offset){var p=offset;var len=body.length;data[p]=len>>24&255;data[p+1]=len>>16&255;data[p+2]=len>>8&255;data[p+3]=len&255;p+=4;data[p]=type.charCodeAt(0)&255;data[p+1]=type.charCodeAt(1)&255;data[p+2]=type.charCodeAt(2)&255;data[p+3]=type.charCodeAt(3)&255;p+=4;data.set(body,p);p+=body.length;var crc=crc32(data,offset+4,p);data[p]=crc>>24&255;data[p+1]=crc>>16&255;data[p+2]=crc>>8&255;data[p+3]=crc&255}function adler32(data,start,end){var a=1;var b=0;for(var i=start;i<end;++i){a=(a+(data[i]&255))%65521;b=(b+a)%65521}return b<<16|a}function encode(imgData,kind,forceDataSchema){var width=imgData.width;var height=imgData.height;var bitDepth,colorType,lineSize;var bytes=imgData.data;switch(kind){case ImageKind.GRAYSCALE_1BPP:colorType=0;bitDepth=1;lineSize=width+7>>3;break;case ImageKind.RGB_24BPP:colorType=2;bitDepth=8;lineSize=width*3;break;case ImageKind.RGBA_32BPP:colorType=6;bitDepth=8;lineSize=width*4;break;default:throw new Error("invalid format")}var literals=new Uint8Array((1+lineSize)*height);var offsetLiterals=0,offsetBytes=0;var y,i;for(y=0;y<height;++y){literals[offsetLiterals++]=0;literals.set(bytes.subarray(offsetBytes,offsetBytes+lineSize),offsetLiterals);offsetBytes+=lineSize;offsetLiterals+=lineSize}if(kind===ImageKind.GRAYSCALE_1BPP){offsetLiterals=0;for(y=0;y<height;y++){offsetLiterals++;for(i=0;i<lineSize;i++){literals[offsetLiterals++]^=255}}}var ihdr=new Uint8Array([width>>24&255,width>>16&255,width>>8&255,width&255,height>>24&255,height>>16&255,height>>8&255,height&255,bitDepth,colorType,0,0,0]);var len=literals.length;var maxBlockLength=65535;var deflateBlocks=Math.ceil(len/maxBlockLength);var idat=new Uint8Array(2+len+deflateBlocks*5+4);var pi=0;idat[pi++]=120;idat[pi++]=156;var pos=0;while(len>maxBlockLength){idat[pi++]=0;idat[pi++]=255;idat[pi++]=255;idat[pi++]=0;idat[pi++]=0;idat.set(literals.subarray(pos,pos+maxBlockLength),pi);pi+=maxBlockLength;pos+=maxBlockLength;len-=maxBlockLength}idat[pi++]=1;idat[pi++]=len&255;idat[pi++]=len>>8&255;idat[pi++]=~len&65535&255;idat[pi++]=(~len&65535)>>8&255;idat.set(literals.subarray(pos),pi);pi+=literals.length-pos;var adler=adler32(literals,0,literals.length);idat[pi++]=adler>>24&255;idat[pi++]=adler>>16&255;idat[pi++]=adler>>8&255;idat[pi++]=adler&255;var pngLength=PNG_HEADER.length+CHUNK_WRAPPER_SIZE*3+ihdr.length+idat.length;var data=new Uint8Array(pngLength);var offset=0;data.set(PNG_HEADER,offset);offset+=PNG_HEADER.length;writePngChunk("IHDR",ihdr,data,offset);offset+=CHUNK_WRAPPER_SIZE+ihdr.length;writePngChunk("IDATA",idat,data,offset);offset+=CHUNK_WRAPPER_SIZE+idat.length;writePngChunk("IEND",new Uint8Array(0),data,offset);return createObjectURL(data,"image/png",forceDataSchema)}return function convertImgDataToPng(imgData,forceDataSchema){var kind=imgData.kind===undefined?ImageKind.GRAYSCALE_1BPP:imgData.kind;return encode(imgData,kind,forceDataSchema)}}();var SVGExtraState=function SVGExtraStateClosure(){function SVGExtraState(){this.fontSizeScale=1;this.fontWeight=SVG_DEFAULTS.fontWeight;this.fontSize=0;this.textMatrix=IDENTITY_MATRIX;this.fontMatrix=FONT_IDENTITY_MATRIX;this.leading=0;this.x=0;this.y=0;this.lineX=0;this.lineY=0;this.charSpacing=0;this.wordSpacing=0;this.textHScale=1;this.textRise=0;this.fillColor=SVG_DEFAULTS.fillColor;this.strokeColor="#000000";this.fillAlpha=1;this.strokeAlpha=1;this.lineWidth=1;this.lineJoin="";this.lineCap="";this.miterLimit=0;this.dashArray=[];this.dashPhase=0;this.dependencies=[];this.clipId="";this.pendingClip=false;this.maskId=""}SVGExtraState.prototype={clone:function SVGExtraState_clone(){return Object.create(this)},setCurrentPoint:function SVGExtraState_setCurrentPoint(x,y){this.x=x;this.y=y}};return SVGExtraState}();var SVGGraphics=function SVGGraphicsClosure(){function createScratchSVG(width,height){var NS="http://www.w3.org/2000/svg";var svg=document.createElementNS(NS,"svg:svg");svg.setAttributeNS(null,"version","1.1");svg.setAttributeNS(null,"width",width+"px");svg.setAttributeNS(null,"height",height+"px");svg.setAttributeNS(null,"viewBox","0 0 "+width+" "+height);return svg}function opListToTree(opList){var opTree=[];var tmp=[];var opListLen=opList.length;for(var x=0;x<opListLen;x++){if(opList[x].fn==="save"){opTree.push({fnId:92,fn:"group",items:[]});tmp.push(opTree);opTree=opTree[opTree.length-1].items;continue}if(opList[x].fn==="restore"){opTree=tmp.pop()}else{opTree.push(opList[x])}}return opTree}function pf(value){if(value===(value|0)){return value.toString()}var s=value.toFixed(10);var i=s.length-1;if(s[i]!=="0"){return s}do{i--}while(s[i]==="0");return s.substr(0,s[i]==="."?i:i+1)}function pm(m){if(m[4]===0&&m[5]===0){if(m[1]===0&&m[2]===0){if(m[0]===1&&m[3]===1){return""}return"scale("+pf(m[0])+" "+pf(m[3])+")"}if(m[0]===m[3]&&m[1]===-m[2]){var a=Math.acos(m[0])*180/Math.PI;return"rotate("+pf(a)+")"}}else{if(m[0]===1&&m[1]===0&&m[2]===0&&m[3]===1){return"translate("+pf(m[4])+" "+pf(m[5])+")"}}return"matrix("+pf(m[0])+" "+pf(m[1])+" "+pf(m[2])+" "+pf(m[3])+" "+pf(m[4])+" "+pf(m[5])+")"}function SVGGraphics(commonObjs,objs,forceDataSchema){this.current=new SVGExtraState;this.transformMatrix=IDENTITY_MATRIX;this.transformStack=[];this.extraStack=[];this.commonObjs=commonObjs;this.objs=objs;this.pendingEOFill=false;this.embedFonts=false;this.embeddedFonts=Object.create(null);this.cssStyle=null;this.forceDataSchema=!!forceDataSchema}var NS="http://www.w3.org/2000/svg";var XML_NS="http://www.w3.org/XML/1998/namespace";var XLINK_NS="http://www.w3.org/1999/xlink";var LINE_CAP_STYLES=["butt","round","square"];var LINE_JOIN_STYLES=["miter","round","bevel"];
3var clipCount=0;var maskCount=0;SVGGraphics.prototype={save:function SVGGraphics_save(){this.transformStack.push(this.transformMatrix);var old=this.current;this.extraStack.push(old);this.current=old.clone()},restore:function SVGGraphics_restore(){this.transformMatrix=this.transformStack.pop();this.current=this.extraStack.pop();this.tgrp=document.createElementNS(NS,"svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix));this.pgrp.appendChild(this.tgrp)},group:function SVGGraphics_group(items){this.save();this.executeOpTree(items);this.restore()},loadDependencies:function SVGGraphics_loadDependencies(operatorList){var fnArray=operatorList.fnArray;var fnArrayLen=fnArray.length;var argsArray=operatorList.argsArray;var self=this;for(var i=0;i<fnArrayLen;i++){if(OPS.dependency===fnArray[i]){var deps=argsArray[i];for(var n=0,nn=deps.length;n<nn;n++){var obj=deps[n];var common=obj.substring(0,2)==="g_";var promise;if(common){promise=new Promise(function(resolve){self.commonObjs.get(obj,resolve)})}else{promise=new Promise(function(resolve){self.objs.get(obj,resolve)})}this.current.dependencies.push(promise)}}}return Promise.all(this.current.dependencies)},transform:function SVGGraphics_transform(a,b,c,d,e,f){var transformMatrix=[a,b,c,d,e,f];this.transformMatrix=Util.transform(this.transformMatrix,transformMatrix);this.tgrp=document.createElementNS(NS,"svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix))},getSVG:function SVGGraphics_getSVG(operatorList,viewport){this.svg=createScratchSVG(viewport.width,viewport.height);this.viewport=viewport;return this.loadDependencies(operatorList).then(function(){this.transformMatrix=IDENTITY_MATRIX;this.pgrp=document.createElementNS(NS,"svg:g");this.pgrp.setAttributeNS(null,"transform",pm(viewport.transform));this.tgrp=document.createElementNS(NS,"svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix));this.defs=document.createElementNS(NS,"svg:defs");this.pgrp.appendChild(this.defs);this.pgrp.appendChild(this.tgrp);this.svg.appendChild(this.pgrp);var opTree=this.convertOpList(operatorList);this.executeOpTree(opTree);return this.svg}.bind(this))},convertOpList:function SVGGraphics_convertOpList(operatorList){var argsArray=operatorList.argsArray;var fnArray=operatorList.fnArray;var fnArrayLen=fnArray.length;var REVOPS=[];var opList=[];for(var op in OPS){REVOPS[OPS[op]]=op}for(var x=0;x<fnArrayLen;x++){var fnId=fnArray[x];opList.push({fnId:fnId,fn:REVOPS[fnId],args:argsArray[x]})}return opListToTree(opList)},executeOpTree:function SVGGraphics_executeOpTree(opTree){var opTreeLen=opTree.length;for(var x=0;x<opTreeLen;x++){var fn=opTree[x].fn;var fnId=opTree[x].fnId;var args=opTree[x].args;switch(fnId|0){case OPS.beginText:this.beginText();break;case OPS.setLeading:this.setLeading(args);break;case OPS.setLeadingMoveText:this.setLeadingMoveText(args[0],args[1]);break;case OPS.setFont:this.setFont(args);break;case OPS.showText:this.showText(args[0]);break;case OPS.showSpacedText:this.showText(args[0]);break;case OPS.endText:this.endText();break;case OPS.moveText:this.moveText(args[0],args[1]);break;case OPS.setCharSpacing:this.setCharSpacing(args[0]);break;case OPS.setWordSpacing:this.setWordSpacing(args[0]);break;case OPS.setHScale:this.setHScale(args[0]);break;case OPS.setTextMatrix:this.setTextMatrix(args[0],args[1],args[2],args[3],args[4],args[5]);break;case OPS.setLineWidth:this.setLineWidth(args[0]);break;case OPS.setLineJoin:this.setLineJoin(args[0]);break;case OPS.setLineCap:this.setLineCap(args[0]);break;case OPS.setMiterLimit:this.setMiterLimit(args[0]);break;case OPS.setFillRGBColor:this.setFillRGBColor(args[0],args[1],args[2]);break;case OPS.setStrokeRGBColor:this.setStrokeRGBColor(args[0],args[1],args[2]);break;case OPS.setDash:this.setDash(args[0],args[1]);break;case OPS.setGState:this.setGState(args[0]);break;case OPS.fill:this.fill();break;case OPS.eoFill:this.eoFill();break;case OPS.stroke:this.stroke();break;case OPS.fillStroke:this.fillStroke();break;case OPS.eoFillStroke:this.eoFillStroke();break;case OPS.clip:this.clip("nonzero");break;case OPS.eoClip:this.clip("evenodd");break;case OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case OPS.paintJpegXObject:this.paintJpegXObject(args[0],args[1],args[2]);break;case OPS.paintImageXObject:this.paintImageXObject(args[0]);break;case OPS.paintInlineImageXObject:this.paintInlineImageXObject(args[0]);break;case OPS.paintImageMaskXObject:this.paintImageMaskXObject(args[0]);break;case OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(args[0],args[1]);break;case OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case OPS.closePath:this.closePath();break;case OPS.closeStroke:this.closeStroke();break;case OPS.closeFillStroke:this.closeFillStroke();break;case OPS.nextLine:this.nextLine();break;case OPS.transform:this.transform(args[0],args[1],args[2],args[3],args[4],args[5]);break;case OPS.constructPath:this.constructPath(args[0],args[1]);break;case OPS.endPath:this.endPath();break;case 92:this.group(opTree[x].items);break;default:warn("Unimplemented method "+fn);break}}},setWordSpacing:function SVGGraphics_setWordSpacing(wordSpacing){this.current.wordSpacing=wordSpacing},setCharSpacing:function SVGGraphics_setCharSpacing(charSpacing){this.current.charSpacing=charSpacing},nextLine:function SVGGraphics_nextLine(){this.moveText(0,this.current.leading)},setTextMatrix:function SVGGraphics_setTextMatrix(a,b,c,d,e,f){var current=this.current;this.current.textMatrix=this.current.lineMatrix=[a,b,c,d,e,f];this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0;current.xcoords=[];current.tspan=document.createElementNS(NS,"svg:tspan");current.tspan.setAttributeNS(null,"font-family",current.fontFamily);current.tspan.setAttributeNS(null,"font-size",pf(current.fontSize)+"px");current.tspan.setAttributeNS(null,"y",pf(-current.y));current.txtElement=document.createElementNS(NS,"svg:text");current.txtElement.appendChild(current.tspan)},beginText:function SVGGraphics_beginText(){this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0;this.current.textMatrix=IDENTITY_MATRIX;this.current.lineMatrix=IDENTITY_MATRIX;this.current.tspan=document.createElementNS(NS,"svg:tspan");this.current.txtElement=document.createElementNS(NS,"svg:text");this.current.txtgrp=document.createElementNS(NS,"svg:g");this.current.xcoords=[]},moveText:function SVGGraphics_moveText(x,y){var current=this.current;this.current.x=this.current.lineX+=x;this.current.y=this.current.lineY+=y;current.xcoords=[];current.tspan=document.createElementNS(NS,"svg:tspan");current.tspan.setAttributeNS(null,"font-family",current.fontFamily);current.tspan.setAttributeNS(null,"font-size",pf(current.fontSize)+"px");current.tspan.setAttributeNS(null,"y",pf(-current.y))},showText:function SVGGraphics_showText(glyphs){var current=this.current;var font=current.font;var fontSize=current.fontSize;if(fontSize===0){return}var charSpacing=current.charSpacing;var wordSpacing=current.wordSpacing;var fontDirection=current.fontDirection;var textHScale=current.textHScale*fontDirection;var glyphsLength=glyphs.length;var vertical=font.vertical;var widthAdvanceScale=fontSize*current.fontMatrix[0];var x=0,i;for(i=0;i<glyphsLength;++i){var glyph=glyphs[i];if(glyph===null){x+=fontDirection*wordSpacing;continue}else if(isNum(glyph)){x+=-glyph*fontSize*.001;continue}current.xcoords.push(current.x+x*textHScale);var width=glyph.width;var character=glyph.fontChar;var charWidth=width*widthAdvanceScale+charSpacing*fontDirection;x+=charWidth;current.tspan.textContent+=character}if(vertical){current.y-=x*textHScale}else{current.x+=x*textHScale}current.tspan.setAttributeNS(null,"x",current.xcoords.map(pf).join(" "));current.tspan.setAttributeNS(null,"y",pf(-current.y));current.tspan.setAttributeNS(null,"font-family",current.fontFamily);current.tspan.setAttributeNS(null,"font-size",pf(current.fontSize)+"px");if(current.fontStyle!==SVG_DEFAULTS.fontStyle){current.tspan.setAttributeNS(null,"font-style",current.fontStyle)}if(current.fontWeight!==SVG_DEFAULTS.fontWeight){current.tspan.setAttributeNS(null,"font-weight",current.fontWeight)}if(current.fillColor!==SVG_DEFAULTS.fillColor){current.tspan.setAttributeNS(null,"fill",current.fillColor)}current.txtElement.setAttributeNS(null,"transform",pm(current.textMatrix)+" scale(1, -1)");current.txtElement.setAttributeNS(XML_NS,"xml:space","preserve");current.txtElement.appendChild(current.tspan);current.txtgrp.appendChild(current.txtElement);this.tgrp.appendChild(current.txtElement)},setLeadingMoveText:function SVGGraphics_setLeadingMoveText(x,y){this.setLeading(-y);this.moveText(x,y)},addFontStyle:function SVGGraphics_addFontStyle(fontObj){if(!this.cssStyle){this.cssStyle=document.createElementNS(NS,"svg:style");this.cssStyle.setAttributeNS(null,"type","text/css");this.defs.appendChild(this.cssStyle)}var url=createObjectURL(fontObj.data,fontObj.mimetype,this.forceDataSchema);this.cssStyle.textContent+='@font-face { font-family: "'+fontObj.loadedName+'";'+" src: url("+url+"); }\n"},setFont:function SVGGraphics_setFont(details){var current=this.current;var fontObj=this.commonObjs.get(details[0]);var size=details[1];this.current.font=fontObj;if(this.embedFonts&&fontObj.data&&!this.embeddedFonts[fontObj.loadedName]){this.addFontStyle(fontObj);this.embeddedFonts[fontObj.loadedName]=fontObj}current.fontMatrix=fontObj.fontMatrix?fontObj.fontMatrix:FONT_IDENTITY_MATRIX;var bold=fontObj.black?fontObj.bold?"bolder":"bold":fontObj.bold?"bold":"normal";var italic=fontObj.italic?"italic":"normal";if(size<0){size=-size;current.fontDirection=-1}else{current.fontDirection=1}current.fontSize=size;current.fontFamily=fontObj.loadedName;current.fontWeight=bold;current.fontStyle=italic;current.tspan=document.createElementNS(NS,"svg:tspan");current.tspan.setAttributeNS(null,"y",pf(-current.y));current.xcoords=[]},endText:function SVGGraphics_endText(){if(this.current.pendingClip){this.cgrp.appendChild(this.tgrp);this.pgrp.appendChild(this.cgrp)}else{this.pgrp.appendChild(this.tgrp)}this.tgrp=document.createElementNS(NS,"svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix))},setLineWidth:function SVGGraphics_setLineWidth(width){this.current.lineWidth=width},setLineCap:function SVGGraphics_setLineCap(style){this.current.lineCap=LINE_CAP_STYLES[style]},setLineJoin:function SVGGraphics_setLineJoin(style){this.current.lineJoin=LINE_JOIN_STYLES[style]},setMiterLimit:function SVGGraphics_setMiterLimit(limit){this.current.miterLimit=limit},setStrokeRGBColor:function SVGGraphics_setStrokeRGBColor(r,g,b){var color=Util.makeCssRgb(r,g,b);this.current.strokeColor=color},setFillRGBColor:function SVGGraphics_setFillRGBColor(r,g,b){var color=Util.makeCssRgb(r,g,b);this.current.fillColor=color;this.current.tspan=document.createElementNS(NS,"svg:tspan");this.current.xcoords=[]},setDash:function SVGGraphics_setDash(dashArray,dashPhase){this.current.dashArray=dashArray;this.current.dashPhase=dashPhase},constructPath:function SVGGraphics_constructPath(ops,args){var current=this.current;var x=current.x,y=current.y;current.path=document.createElementNS(NS,"svg:path");var d=[];var opLength=ops.length;for(var i=0,j=0;i<opLength;i++){switch(ops[i]|0){case OPS.rectangle:x=args[j++];y=args[j++];var width=args[j++];var height=args[j++];var xw=x+width;var yh=y+height;d.push("M",pf(x),pf(y),"L",pf(xw),pf(y),"L",pf(xw),pf(yh),"L",pf(x),pf(yh),"Z");break;case OPS.moveTo:x=args[j++];y=args[j++];d.push("M",pf(x),pf(y));break;case OPS.lineTo:x=args[j++];y=args[j++];d.push("L",pf(x),pf(y));break;case OPS.curveTo:x=args[j+4];y=args[j+5];d.push("C",pf(args[j]),pf(args[j+1]),pf(args[j+2]),pf(args[j+3]),pf(x),pf(y));j+=6;break;case OPS.curveTo2:x=args[j+2];y=args[j+3];d.push("C",pf(x),pf(y),pf(args[j]),pf(args[j+1]),pf(args[j+2]),pf(args[j+3]));j+=4;break;case OPS.curveTo3:x=args[j+2];y=args[j+3];d.push("C",pf(args[j]),pf(args[j+1]),pf(x),pf(y),pf(x),pf(y));j+=4;break;case OPS.closePath:d.push("Z");break}}current.path.setAttributeNS(null,"d",d.join(" "));current.path.setAttributeNS(null,"stroke-miterlimit",pf(current.miterLimit));current.path.setAttributeNS(null,"stroke-linecap",current.lineCap);current.path.setAttributeNS(null,"stroke-linejoin",current.lineJoin);current.path.setAttributeNS(null,"stroke-width",pf(current.lineWidth)+"px");current.path.setAttributeNS(null,"stroke-dasharray",current.dashArray.map(pf).join(" "));current.path.setAttributeNS(null,"stroke-dashoffset",pf(current.dashPhase)+"px");current.path.setAttributeNS(null,"fill","none");this.tgrp.appendChild(current.path);if(current.pendingClip){this.cgrp.appendChild(this.tgrp);this.pgrp.appendChild(this.cgrp)}else{this.pgrp.appendChild(this.tgrp)}current.element=current.path;current.setCurrentPoint(x,y)},endPath:function SVGGraphics_endPath(){var current=this.current;if(current.pendingClip){this.cgrp.appendChild(this.tgrp);this.pgrp.appendChild(this.cgrp)}else{this.pgrp.appendChild(this.tgrp)}this.tgrp=document.createElementNS(NS,"svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix))},clip:function SVGGraphics_clip(type){var current=this.current;current.clipId="clippath"+clipCount;clipCount++;this.clippath=document.createElementNS(NS,"svg:clipPath");this.clippath.setAttributeNS(null,"id",current.clipId);var clipElement=current.element.cloneNode();if(type==="evenodd"){clipElement.setAttributeNS(null,"clip-rule","evenodd")}else{clipElement.setAttributeNS(null,"clip-rule","nonzero")}this.clippath.setAttributeNS(null,"transform",pm(this.transformMatrix));this.clippath.appendChild(clipElement);this.defs.appendChild(this.clippath);current.pendingClip=true;this.cgrp=document.createElementNS(NS,"svg:g");this.cgrp.setAttributeNS(null,"clip-path","url(#"+current.clipId+")");this.pgrp.appendChild(this.cgrp)},closePath:function SVGGraphics_closePath(){var current=this.current;var d=current.path.getAttributeNS(null,"d");d+="Z";current.path.setAttributeNS(null,"d",d)},setLeading:function SVGGraphics_setLeading(leading){this.current.leading=-leading},setTextRise:function SVGGraphics_setTextRise(textRise){this.current.textRise=textRise},setHScale:function SVGGraphics_setHScale(scale){this.current.textHScale=scale/100},setGState:function SVGGraphics_setGState(states){for(var i=0,ii=states.length;i<ii;i++){var state=states[i];var key=state[0];var value=state[1];switch(key){case"LW":this.setLineWidth(value);break;case"LC":this.setLineCap(value);break;case"LJ":this.setLineJoin(value);break;case"ML":this.setMiterLimit(value);break;case"D":this.setDash(value[0],value[1]);break;case"RI":break;case"FL":break;case"Font":this.setFont(value);break;case"CA":break;case"ca":break;case"BM":break;case"SMask":break}}},fill:function SVGGraphics_fill(){var current=this.current;current.element.setAttributeNS(null,"fill",current.fillColor)},stroke:function SVGGraphics_stroke(){var current=this.current;current.element.setAttributeNS(null,"stroke",current.strokeColor);current.element.setAttributeNS(null,"fill","none")},eoFill:function SVGGraphics_eoFill(){var current=this.current;current.element.setAttributeNS(null,"fill",current.fillColor);current.element.setAttributeNS(null,"fill-rule","evenodd")},fillStroke:function SVGGraphics_fillStroke(){this.stroke();this.fill()},eoFillStroke:function SVGGraphics_eoFillStroke(){this.current.element.setAttributeNS(null,"fill-rule","evenodd");this.fillStroke()},closeStroke:function SVGGraphics_closeStroke(){this.closePath();this.stroke()},closeFillStroke:function SVGGraphics_closeFillStroke(){this.closePath();this.fillStroke()},paintSolidColorImageMask:function SVGGraphics_paintSolidColorImageMask(){var current=this.current;var rect=document.createElementNS(NS,"svg:rect");rect.setAttributeNS(null,"x","0");rect.setAttributeNS(null,"y","0");rect.setAttributeNS(null,"width","1px");rect.setAttributeNS(null,"height","1px");rect.setAttributeNS(null,"fill",current.fillColor);this.tgrp.appendChild(rect)},paintJpegXObject:function SVGGraphics_paintJpegXObject(objId,w,h){var current=this.current;var imgObj=this.objs.get(objId);var imgEl=document.createElementNS(NS,"svg:image");imgEl.setAttributeNS(XLINK_NS,"xlink:href",imgObj.src);imgEl.setAttributeNS(null,"width",imgObj.width+"px");imgEl.setAttributeNS(null,"height",imgObj.height+"px");imgEl.setAttributeNS(null,"x","0");imgEl.setAttributeNS(null,"y",pf(-h));imgEl.setAttributeNS(null,"transform","scale("+pf(1/w)+" "+pf(-1/h)+")");this.tgrp.appendChild(imgEl);if(current.pendingClip){this.cgrp.appendChild(this.tgrp);this.pgrp.appendChild(this.cgrp)}else{this.pgrp.appendChild(this.tgrp)}},paintImageXObject:function SVGGraphics_paintImageXObject(objId){var imgData=this.objs.get(objId);if(!imgData){warn("Dependent image isn't ready yet");return}this.paintInlineImageXObject(imgData)},paintInlineImageXObject:function SVGGraphics_paintInlineImageXObject(imgData,mask){var current=this.current;var width=imgData.width;var height=imgData.height;var imgSrc=convertImgDataToPng(imgData,this.forceDataSchema);var cliprect=document.createElementNS(NS,"svg:rect");cliprect.setAttributeNS(null,"x","0");cliprect.setAttributeNS(null,"y","0");cliprect.setAttributeNS(null,"width",pf(width));cliprect.setAttributeNS(null,"height",pf(height));current.element=cliprect;this.clip("nonzero");var imgEl=document.createElementNS(NS,"svg:image");imgEl.setAttributeNS(XLINK_NS,"xlink:href",imgSrc);imgEl.setAttributeNS(null,"x","0");imgEl.setAttributeNS(null,"y",pf(-height));imgEl.setAttributeNS(null,"width",pf(width)+"px");imgEl.setAttributeNS(null,"height",pf(height)+"px");imgEl.setAttributeNS(null,"transform","scale("+pf(1/width)+" "+pf(-1/height)+")");if(mask){mask.appendChild(imgEl)}else{this.tgrp.appendChild(imgEl)}if(current.pendingClip){this.cgrp.appendChild(this.tgrp);this.pgrp.appendChild(this.cgrp)}else{this.pgrp.appendChild(this.tgrp)}},paintImageMaskXObject:function SVGGraphics_paintImageMaskXObject(imgData){var current=this.current;var width=imgData.width;var height=imgData.height;var fillColor=current.fillColor;current.maskId="mask"+maskCount++;var mask=document.createElementNS(NS,"svg:mask");mask.setAttributeNS(null,"id",current.maskId);var rect=document.createElementNS(NS,"svg:rect");rect.setAttributeNS(null,"x","0");rect.setAttributeNS(null,"y","0");rect.setAttributeNS(null,"width",pf(width));rect.setAttributeNS(null,"height",pf(height));rect.setAttributeNS(null,"fill",fillColor);rect.setAttributeNS(null,"mask","url(#"+current.maskId+")");this.defs.appendChild(mask);this.tgrp.appendChild(rect);this.paintInlineImageXObject(imgData,mask)},paintFormXObjectBegin:function SVGGraphics_paintFormXObjectBegin(matrix,bbox){this.save();if(isArray(matrix)&&matrix.length===6){this.transform(matrix[0],matrix[1],matrix[2],matrix[3],matrix[4],matrix[5])}if(isArray(bbox)&&bbox.length===4){var width=bbox[2]-bbox[0];var height=bbox[3]-bbox[1];var cliprect=document.createElementNS(NS,"svg:rect");cliprect.setAttributeNS(null,"x",bbox[0]);cliprect.setAttributeNS(null,"y",bbox[1]);cliprect.setAttributeNS(null,"width",pf(width));cliprect.setAttributeNS(null,"height",pf(height));this.current.element=cliprect;this.clip("nonzero");this.endPath()}},paintFormXObjectEnd:function SVGGraphics_paintFormXObjectEnd(){this.restore()}};return SVGGraphics}();exports.SVGGraphics=SVGGraphics});(function(root,factory){{factory(root.pdfjsDisplayAnnotationLayer={},root.pdfjsSharedUtil,root.pdfjsDisplayDOMUtils)}})(this,function(exports,sharedUtil,displayDOMUtils){var AnnotationBorderStyleType=sharedUtil.AnnotationBorderStyleType;var AnnotationType=sharedUtil.AnnotationType;var Util=sharedUtil.Util;var addLinkAttributes=displayDOMUtils.addLinkAttributes;var LinkTarget=displayDOMUtils.LinkTarget;var getFilenameFromUrl=displayDOMUtils.getFilenameFromUrl;var warn=sharedUtil.warn;var CustomStyle=displayDOMUtils.CustomStyle;var getDefaultSetting=displayDOMUtils.getDefaultSetting;function AnnotationElementFactory(){}AnnotationElementFactory.prototype={create:function AnnotationElementFactory_create(parameters){var subtype=parameters.data.annotationType;switch(subtype){case AnnotationType.LINK:return new LinkAnnotationElement(parameters);case AnnotationType.TEXT:return new TextAnnotationElement(parameters);case AnnotationType.WIDGET:var fieldType=parameters.data.fieldType;switch(fieldType){case"Tx":return new TextWidgetAnnotationElement(parameters)}return new WidgetAnnotationElement(parameters);case AnnotationType.POPUP:return new PopupAnnotationElement(parameters);case AnnotationType.HIGHLIGHT:return new HighlightAnnotationElement(parameters);case AnnotationType.UNDERLINE:return new UnderlineAnnotationElement(parameters);case AnnotationType.SQUIGGLY:return new SquigglyAnnotationElement(parameters);case AnnotationType.STRIKEOUT:return new StrikeOutAnnotationElement(parameters);case AnnotationType.FILEATTACHMENT:return new FileAttachmentAnnotationElement(parameters);default:return new AnnotationElement(parameters)}}};var AnnotationElement=function AnnotationElementClosure(){function AnnotationElement(parameters,isRenderable){this.isRenderable=isRenderable||false;this.data=parameters.data;this.layer=parameters.layer;this.page=parameters.page;this.viewport=parameters.viewport;this.linkService=parameters.linkService;this.downloadManager=parameters.downloadManager;this.imageResourcesPath=parameters.imageResourcesPath;this.renderInteractiveForms=parameters.renderInteractiveForms;if(isRenderable){this.container=this._createContainer()}}AnnotationElement.prototype={_createContainer:function AnnotationElement_createContainer(){var data=this.data,page=this.page,viewport=this.viewport;var container=document.createElement("section");var width=data.rect[2]-data.rect[0];var height=data.rect[3]-data.rect[1];container.setAttribute("data-annotation-id",data.id);var rect=Util.normalizeRect([data.rect[0],page.view[3]-data.rect[1]+page.view[1],data.rect[2],page.view[3]-data.rect[3]+page.view[1]]);CustomStyle.setProp("transform",container,"matrix("+viewport.transform.join(",")+")");CustomStyle.setProp("transformOrigin",container,-rect[0]+"px "+-rect[1]+"px");if(data.borderStyle.width>0){container.style.borderWidth=data.borderStyle.width+"px";if(data.borderStyle.style!==AnnotationBorderStyleType.UNDERLINE){width=width-2*data.borderStyle.width;height=height-2*data.borderStyle.width}var horizontalRadius=data.borderStyle.horizontalCornerRadius;var verticalRadius=data.borderStyle.verticalCornerRadius;if(horizontalRadius>0||verticalRadius>0){var radius=horizontalRadius+"px / "+verticalRadius+"px";CustomStyle.setProp("borderRadius",container,radius)}switch(data.borderStyle.style){case AnnotationBorderStyleType.SOLID:container.style.borderStyle="solid";break;case AnnotationBorderStyleType.DASHED:container.style.borderStyle="dashed";break;case AnnotationBorderStyleType.BEVELED:warn("Unimplemented border style: beveled");break;case AnnotationBorderStyleType.INSET:warn("Unimplemented border style: inset");break;case AnnotationBorderStyleType.UNDERLINE:container.style.borderBottomStyle="solid";break;default:break}if(data.color){container.style.borderColor=Util.makeCssRgb(data.color[0]|0,data.color[1]|0,data.color[2]|0)}else{container.style.borderWidth=0}}container.style.left=rect[0]+"px";container.style.top=rect[1]+"px";container.style.width=width+"px";container.style.height=height+"px";return container},_createPopup:function AnnotationElement_createPopup(container,trigger,data){if(!trigger){trigger=document.createElement("div");trigger.style.height=container.style.height;trigger.style.width=container.style.width;container.appendChild(trigger)}var popupElement=new PopupElement({container:container,trigger:trigger,color:data.color,title:data.title,contents:data.contents,hideWrapper:true});var popup=popupElement.render();popup.style.left=container.style.width;container.appendChild(popup)},render:function AnnotationElement_render(){throw new Error("Abstract method AnnotationElement.render called")}};return AnnotationElement}();var LinkAnnotationElement=function LinkAnnotationElementClosure(){function LinkAnnotationElement(parameters){AnnotationElement.call(this,parameters,true)}Util.inherit(LinkAnnotationElement,AnnotationElement,{render:function LinkAnnotationElement_render(){this.container.className="linkAnnotation";var link=document.createElement("a");addLinkAttributes(link,{url:this.data.url,target:this.data.newWindow?LinkTarget.BLANK:undefined});if(!this.data.url){if(this.data.action){this._bindNamedAction(link,this.data.action)}else{this._bindLink(link,this.data.dest||null)}}this.container.appendChild(link);return this.container},_bindLink:function LinkAnnotationElement_bindLink(link,destination){var self=this;link.href=this.linkService.getDestinationHash(destination);link.onclick=function(){if(destination){self.linkService.navigateTo(destination)}return false};if(destination){link.className="internalLink"}},_bindNamedAction:function LinkAnnotationElement_bindNamedAction(link,action){var self=this;link.href=this.linkService.getAnchorUrl("");link.onclick=function(){self.linkService.executeNamedAction(action);return false};link.className="internalLink"}});return LinkAnnotationElement}();var TextAnnotationElement=function TextAnnotationElementClosure(){function TextAnnotationElement(parameters){var isRenderable=!!(parameters.data.hasPopup||parameters.data.title||parameters.data.contents);AnnotationElement.call(this,parameters,isRenderable)}Util.inherit(TextAnnotationElement,AnnotationElement,{render:function TextAnnotationElement_render(){this.container.className="textAnnotation";var image=document.createElement("img");image.style.height=this.container.style.height;image.style.width=this.container.style.width;image.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg";image.alt="[{{type}} Annotation]";image.dataset.l10nId="text_annotation_type";image.dataset.l10nArgs=JSON.stringify({type:this.data.name});if(!this.data.hasPopup){this._createPopup(this.container,image,this.data)}this.container.appendChild(image);return this.container}});return TextAnnotationElement}();var WidgetAnnotationElement=function WidgetAnnotationElementClosure(){function WidgetAnnotationElement(parameters){var isRenderable=parameters.renderInteractiveForms||!parameters.data.hasAppearance&&!!parameters.data.fieldValue;AnnotationElement.call(this,parameters,isRenderable)}Util.inherit(WidgetAnnotationElement,AnnotationElement,{render:function WidgetAnnotationElement_render(){return this.container}});return WidgetAnnotationElement}();var TextWidgetAnnotationElement=function TextWidgetAnnotationElementClosure(){var TEXT_ALIGNMENT=["left","center","right"];function TextWidgetAnnotationElement(parameters){WidgetAnnotationElement.call(this,parameters)}Util.inherit(TextWidgetAnnotationElement,WidgetAnnotationElement,{render:function TextWidgetAnnotationElement_render(){this.container.className="textWidgetAnnotation";var element=null;if(this.renderInteractiveForms){if(this.data.multiLine){element=document.createElement("textarea");element.textContent=this.data.fieldValue}else{element=document.createElement("input");element.type="text";element.setAttribute("value",this.data.fieldValue)}element.disabled=this.data.readOnly;if(this.data.maxLen!==null){element.maxLength=this.data.maxLen}if(this.data.comb){var fieldWidth=this.data.rect[2]-this.data.rect[0];var combWidth=fieldWidth/this.data.maxLen;element.classList.add("comb");element.style.letterSpacing="calc("+combWidth+"px - 1ch)"}}else{element=document.createElement("div");element.textContent=this.data.fieldValue;element.style.verticalAlign="middle";element.style.display="table-cell";var font=null;if(this.data.fontRefName){font=this.page.commonObjs.getData(this.data.fontRefName)}this._setTextStyle(element,font)}if(this.data.textAlignment!==null){element.style.textAlign=TEXT_ALIGNMENT[this.data.textAlignment]}this.container.appendChild(element);return this.container},_setTextStyle:function TextWidgetAnnotationElement_setTextStyle(element,font){var style=element.style;style.fontSize=this.data.fontSize+"px";style.direction=this.data.fontDirection<0?"rtl":"ltr";if(!font){return}style.fontWeight=font.black?font.bold?"900":"bold":font.bold?"bold":"normal";style.fontStyle=font.italic?"italic":"normal";var fontFamily=font.loadedName?'"'+font.loadedName+'", ':"";var fallbackName=font.fallbackName||"Helvetica, sans-serif";style.fontFamily=fontFamily+fallbackName}});return TextWidgetAnnotationElement}();var PopupAnnotationElement=function PopupAnnotationElementClosure(){function PopupAnnotationElement(parameters){var isRenderable=!!(parameters.data.title||parameters.data.contents);AnnotationElement.call(this,parameters,isRenderable)}Util.inherit(PopupAnnotationElement,AnnotationElement,{render:function PopupAnnotationElement_render(){this.container.className="popupAnnotation";var selector='[data-annotation-id="'+this.data.parentId+'"]';var parentElement=this.layer.querySelector(selector);if(!parentElement){return this.container}var popup=new PopupElement({container:this.container,trigger:parentElement,color:this.data.color,title:this.data.title,contents:this.data.contents});var parentLeft=parseFloat(parentElement.style.left);var parentWidth=parseFloat(parentElement.style.width);CustomStyle.setProp("transformOrigin",this.container,-(parentLeft+parentWidth)+"px -"+parentElement.style.top);this.container.style.left=parentLeft+parentWidth+"px";this.container.appendChild(popup.render());return this.container}});return PopupAnnotationElement}();var PopupElement=function PopupElementClosure(){var BACKGROUND_ENLIGHT=.7;function PopupElement(parameters){this.container=parameters.container;this.trigger=parameters.trigger;this.color=parameters.color;this.title=parameters.title;this.contents=parameters.contents;this.hideWrapper=parameters.hideWrapper||false;this.pinned=false}PopupElement.prototype={render:function PopupElement_render(){var wrapper=document.createElement("div");wrapper.className="popupWrapper";this.hideElement=this.hideWrapper?wrapper:this.container;this.hideElement.setAttribute("hidden",true);var popup=document.createElement("div");popup.className="popup";var color=this.color;if(color){var r=BACKGROUND_ENLIGHT*(255-color[0])+color[0];var g=BACKGROUND_ENLIGHT*(255-color[1])+color[1];var b=BACKGROUND_ENLIGHT*(255-color[2])+color[2];popup.style.backgroundColor=Util.makeCssRgb(r|0,g|0,b|0)}var contents=this._formatContents(this.contents);var title=document.createElement("h1");title.textContent=this.title;this.trigger.addEventListener("click",this._toggle.bind(this));this.trigger.addEventListener("mouseover",this._show.bind(this,false));this.trigger.addEventListener("mouseout",this._hide.bind(this,false));popup.addEventListener("click",this._hide.bind(this,true));popup.appendChild(title);popup.appendChild(contents);wrapper.appendChild(popup);return wrapper},_formatContents:function PopupElement_formatContents(contents){var p=document.createElement("p");var lines=contents.split(/(?:\r\n?|\n)/);for(var i=0,ii=lines.length;i<ii;++i){var line=lines[i];p.appendChild(document.createTextNode(line));if(i<ii-1){p.appendChild(document.createElement("br"))}}return p},_toggle:function PopupElement_toggle(){if(this.pinned){this._hide(true)}else{this._show(true)}},_show:function PopupElement_show(pin){if(pin){this.pinned=true}if(this.hideElement.hasAttribute("hidden")){this.hideElement.removeAttribute("hidden");this.container.style.zIndex+=1}},_hide:function PopupElement_hide(unpin){if(unpin){this.pinned=false}if(!this.hideElement.hasAttribute("hidden")&&!this.pinned){this.hideElement.setAttribute("hidden",true);this.container.style.zIndex-=1}}};return PopupElement}();var HighlightAnnotationElement=function HighlightAnnotationElementClosure(){function HighlightAnnotationElement(parameters){var isRenderable=!!(parameters.data.hasPopup||parameters.data.title||parameters.data.contents);AnnotationElement.call(this,parameters,isRenderable)}Util.inherit(HighlightAnnotationElement,AnnotationElement,{render:function HighlightAnnotationElement_render(){this.container.className="highlightAnnotation";
4if(!this.data.hasPopup){this._createPopup(this.container,null,this.data)}return this.container}});return HighlightAnnotationElement}();var UnderlineAnnotationElement=function UnderlineAnnotationElementClosure(){function UnderlineAnnotationElement(parameters){var isRenderable=!!(parameters.data.hasPopup||parameters.data.title||parameters.data.contents);AnnotationElement.call(this,parameters,isRenderable)}Util.inherit(UnderlineAnnotationElement,AnnotationElement,{render:function UnderlineAnnotationElement_render(){this.container.className="underlineAnnotation";if(!this.data.hasPopup){this._createPopup(this.container,null,this.data)}return this.container}});return UnderlineAnnotationElement}();var SquigglyAnnotationElement=function SquigglyAnnotationElementClosure(){function SquigglyAnnotationElement(parameters){var isRenderable=!!(parameters.data.hasPopup||parameters.data.title||parameters.data.contents);AnnotationElement.call(this,parameters,isRenderable)}Util.inherit(SquigglyAnnotationElement,AnnotationElement,{render:function SquigglyAnnotationElement_render(){this.container.className="squigglyAnnotation";if(!this.data.hasPopup){this._createPopup(this.container,null,this.data)}return this.container}});return SquigglyAnnotationElement}();var StrikeOutAnnotationElement=function StrikeOutAnnotationElementClosure(){function StrikeOutAnnotationElement(parameters){var isRenderable=!!(parameters.data.hasPopup||parameters.data.title||parameters.data.contents);AnnotationElement.call(this,parameters,isRenderable)}Util.inherit(StrikeOutAnnotationElement,AnnotationElement,{render:function StrikeOutAnnotationElement_render(){this.container.className="strikeoutAnnotation";if(!this.data.hasPopup){this._createPopup(this.container,null,this.data)}return this.container}});return StrikeOutAnnotationElement}();var FileAttachmentAnnotationElement=function FileAttachmentAnnotationElementClosure(){function FileAttachmentAnnotationElement(parameters){AnnotationElement.call(this,parameters,true);this.filename=getFilenameFromUrl(parameters.data.file.filename);this.content=parameters.data.file.content}Util.inherit(FileAttachmentAnnotationElement,AnnotationElement,{render:function FileAttachmentAnnotationElement_render(){this.container.className="fileAttachmentAnnotation";var trigger=document.createElement("div");trigger.style.height=this.container.style.height;trigger.style.width=this.container.style.width;trigger.addEventListener("dblclick",this._download.bind(this));if(!this.data.hasPopup&&(this.data.title||this.data.contents)){this._createPopup(this.container,trigger,this.data)}this.container.appendChild(trigger);return this.container},_download:function FileAttachmentAnnotationElement_download(){if(!this.downloadManager){warn("Download cannot be started due to unavailable download manager");return}this.downloadManager.downloadData(this.content,this.filename,"")}});return FileAttachmentAnnotationElement}();var AnnotationLayer=function AnnotationLayerClosure(){return{render:function AnnotationLayer_render(parameters){var annotationElementFactory=new AnnotationElementFactory;for(var i=0,ii=parameters.annotations.length;i<ii;i++){var data=parameters.annotations[i];if(!data){continue}var properties={data:data,layer:parameters.div,page:parameters.page,viewport:parameters.viewport,linkService:parameters.linkService,downloadManager:parameters.downloadManager,imageResourcesPath:parameters.imageResourcesPath||getDefaultSetting("imageResourcesPath"),renderInteractiveForms:parameters.renderInteractiveForms||false};var element=annotationElementFactory.create(properties);if(element.isRenderable){parameters.div.appendChild(element.render())}}},update:function AnnotationLayer_update(parameters){for(var i=0,ii=parameters.annotations.length;i<ii;i++){var data=parameters.annotations[i];var element=parameters.div.querySelector('[data-annotation-id="'+data.id+'"]');if(element){CustomStyle.setProp("transform",element,"matrix("+parameters.viewport.transform.join(",")+")")}}parameters.div.removeAttribute("hidden")}}}();exports.AnnotationLayer=AnnotationLayer});(function(root,factory){{factory(root.pdfjsDisplayTextLayer={},root.pdfjsSharedUtil,root.pdfjsDisplayDOMUtils)}})(this,function(exports,sharedUtil,displayDOMUtils){var Util=sharedUtil.Util;var createPromiseCapability=sharedUtil.createPromiseCapability;var CustomStyle=displayDOMUtils.CustomStyle;var getDefaultSetting=displayDOMUtils.getDefaultSetting;var renderTextLayer=function renderTextLayerClosure(){var MAX_TEXT_DIVS_TO_RENDER=1e5;var NonWhitespaceRegexp=/\S/;function isAllWhitespace(str){return!NonWhitespaceRegexp.test(str)}var styleBuf=["left: ",0,"px; top: ",0,"px; font-size: ",0,"px; font-family: ","",";"];function appendText(task,geom,styles){var textDiv=document.createElement("div");var textDivProperties={style:null,angle:0,canvasWidth:0,isWhitespace:false,originalTransform:null,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,scale:1};task._textDivs.push(textDiv);if(isAllWhitespace(geom.str)){textDivProperties.isWhitespace=true;task._textDivProperties.set(textDiv,textDivProperties);return}var tx=Util.transform(task._viewport.transform,geom.transform);var angle=Math.atan2(tx[1],tx[0]);var style=styles[geom.fontName];if(style.vertical){angle+=Math.PI/2}var fontHeight=Math.sqrt(tx[2]*tx[2]+tx[3]*tx[3]);var fontAscent=fontHeight;if(style.ascent){fontAscent=style.ascent*fontAscent}else if(style.descent){fontAscent=(1+style.descent)*fontAscent}var left;var top;if(angle===0){left=tx[4];top=tx[5]-fontAscent}else{left=tx[4]+fontAscent*Math.sin(angle);top=tx[5]-fontAscent*Math.cos(angle)}styleBuf[1]=left;styleBuf[3]=top;styleBuf[5]=fontHeight;styleBuf[7]=style.fontFamily;textDivProperties.style=styleBuf.join("");textDiv.setAttribute("style",textDivProperties.style);textDiv.textContent=geom.str;if(getDefaultSetting("pdfBug")){textDiv.dataset.fontName=geom.fontName}if(angle!==0){textDivProperties.angle=angle*(180/Math.PI)}if(geom.str.length>1){if(style.vertical){textDivProperties.canvasWidth=geom.height*task._viewport.scale}else{textDivProperties.canvasWidth=geom.width*task._viewport.scale}}task._textDivProperties.set(textDiv,textDivProperties);if(task._enhanceTextSelection){var angleCos=1,angleSin=0;if(angle!==0){angleCos=Math.cos(angle);angleSin=Math.sin(angle)}var divWidth=(style.vertical?geom.height:geom.width)*task._viewport.scale;var divHeight=fontHeight;var m,b;if(angle!==0){m=[angleCos,angleSin,-angleSin,angleCos,left,top];b=Util.getAxialAlignedBoundingBox([0,0,divWidth,divHeight],m)}else{b=[left,top,left+divWidth,top+divHeight]}task._bounds.push({left:b[0],top:b[1],right:b[2],bottom:b[3],div:textDiv,size:[divWidth,divHeight],m:m})}}function render(task){if(task._canceled){return}var textLayerFrag=task._container;var textDivs=task._textDivs;var capability=task._capability;var textDivsLength=textDivs.length;if(textDivsLength>MAX_TEXT_DIVS_TO_RENDER){task._renderingDone=true;capability.resolve();return}var canvas=document.createElement("canvas");canvas.mozOpaque=true;var ctx=canvas.getContext("2d",{alpha:false});var lastFontSize;var lastFontFamily;for(var i=0;i<textDivsLength;i++){var textDiv=textDivs[i];var textDivProperties=task._textDivProperties.get(textDiv);if(textDivProperties.isWhitespace){continue}var fontSize=textDiv.style.fontSize;var fontFamily=textDiv.style.fontFamily;if(fontSize!==lastFontSize||fontFamily!==lastFontFamily){ctx.font=fontSize+" "+fontFamily;lastFontSize=fontSize;lastFontFamily=fontFamily}var width=ctx.measureText(textDiv.textContent).width;textLayerFrag.appendChild(textDiv);var transform="";if(textDivProperties.canvasWidth!==0&&width>0){textDivProperties.scale=textDivProperties.canvasWidth/width;transform="scaleX("+textDivProperties.scale+")"}if(textDivProperties.angle!==0){transform="rotate("+textDivProperties.angle+"deg) "+transform}if(transform!==""){textDivProperties.originalTransform=transform;CustomStyle.setProp("transform",textDiv,transform)}task._textDivProperties.set(textDiv,textDivProperties)}task._renderingDone=true;capability.resolve()}function expand(task){var bounds=task._bounds;var viewport=task._viewport;var expanded=expandBounds(viewport.width,viewport.height,bounds);for(var i=0;i<expanded.length;i++){var div=bounds[i].div;var divProperties=task._textDivProperties.get(div);if(divProperties.angle===0){divProperties.paddingLeft=bounds[i].left-expanded[i].left;divProperties.paddingTop=bounds[i].top-expanded[i].top;divProperties.paddingRight=expanded[i].right-bounds[i].right;divProperties.paddingBottom=expanded[i].bottom-bounds[i].bottom;task._textDivProperties.set(div,divProperties);continue}var e=expanded[i],b=bounds[i];var m=b.m,c=m[0],s=m[1];var points=[[0,0],[0,b.size[1]],[b.size[0],0],b.size];var ts=new Float64Array(64);points.forEach(function(p,i){var t=Util.applyTransform(p,m);ts[i+0]=c&&(e.left-t[0])/c;ts[i+4]=s&&(e.top-t[1])/s;ts[i+8]=c&&(e.right-t[0])/c;ts[i+12]=s&&(e.bottom-t[1])/s;ts[i+16]=s&&(e.left-t[0])/-s;ts[i+20]=c&&(e.top-t[1])/c;ts[i+24]=s&&(e.right-t[0])/-s;ts[i+28]=c&&(e.bottom-t[1])/c;ts[i+32]=c&&(e.left-t[0])/-c;ts[i+36]=s&&(e.top-t[1])/-s;ts[i+40]=c&&(e.right-t[0])/-c;ts[i+44]=s&&(e.bottom-t[1])/-s;ts[i+48]=s&&(e.left-t[0])/s;ts[i+52]=c&&(e.top-t[1])/-c;ts[i+56]=s&&(e.right-t[0])/s;ts[i+60]=c&&(e.bottom-t[1])/-c});var findPositiveMin=function(ts,offset,count){var result=0;for(var i=0;i<count;i++){var t=ts[offset++];if(t>0){result=result?Math.min(t,result):t}}return result};var boxScale=1+Math.min(Math.abs(c),Math.abs(s));divProperties.paddingLeft=findPositiveMin(ts,32,16)/boxScale;divProperties.paddingTop=findPositiveMin(ts,48,16)/boxScale;divProperties.paddingRight=findPositiveMin(ts,0,16)/boxScale;divProperties.paddingBottom=findPositiveMin(ts,16,16)/boxScale;task._textDivProperties.set(div,divProperties)}}function expandBounds(width,height,boxes){var bounds=boxes.map(function(box,i){return{x1:box.left,y1:box.top,x2:box.right,y2:box.bottom,index:i,x1New:undefined,x2New:undefined}});expandBoundsLTR(width,bounds);var expanded=new Array(boxes.length);bounds.forEach(function(b){var i=b.index;expanded[i]={left:b.x1New,top:0,right:b.x2New,bottom:0}});boxes.map(function(box,i){var e=expanded[i],b=bounds[i];b.x1=box.top;b.y1=width-e.right;b.x2=box.bottom;b.y2=width-e.left;b.index=i;b.x1New=undefined;b.x2New=undefined});expandBoundsLTR(height,bounds);bounds.forEach(function(b){var i=b.index;expanded[i].top=b.x1New;expanded[i].bottom=b.x2New});return expanded}function expandBoundsLTR(width,bounds){bounds.sort(function(a,b){return a.x1-b.x1||a.index-b.index});var fakeBoundary={x1:-Infinity,y1:-Infinity,x2:0,y2:Infinity,index:-1,x1New:0,x2New:0};var horizon=[{start:-Infinity,end:Infinity,boundary:fakeBoundary}];bounds.forEach(function(boundary){var i=0;while(i<horizon.length&&horizon[i].end<=boundary.y1){i++}var j=horizon.length-1;while(j>=0&&horizon[j].start>=boundary.y2){j--}var horizonPart,affectedBoundary;var q,k,maxXNew=-Infinity;for(q=i;q<=j;q++){horizonPart=horizon[q];affectedBoundary=horizonPart.boundary;var xNew;if(affectedBoundary.x2>boundary.x1){xNew=affectedBoundary.index>boundary.index?affectedBoundary.x1New:boundary.x1}else if(affectedBoundary.x2New===undefined){xNew=(affectedBoundary.x2+boundary.x1)/2}else{xNew=affectedBoundary.x2New}if(xNew>maxXNew){maxXNew=xNew}}boundary.x1New=maxXNew;for(q=i;q<=j;q++){horizonPart=horizon[q];affectedBoundary=horizonPart.boundary;if(affectedBoundary.x2New===undefined){if(affectedBoundary.x2>boundary.x1){if(affectedBoundary.index>boundary.index){affectedBoundary.x2New=affectedBoundary.x2}}else{affectedBoundary.x2New=maxXNew}}else if(affectedBoundary.x2New>maxXNew){affectedBoundary.x2New=Math.max(maxXNew,affectedBoundary.x2)}}var changedHorizon=[],lastBoundary=null;for(q=i;q<=j;q++){horizonPart=horizon[q];affectedBoundary=horizonPart.boundary;var useBoundary=affectedBoundary.x2>boundary.x2?affectedBoundary:boundary;if(lastBoundary===useBoundary){changedHorizon[changedHorizon.length-1].end=horizonPart.end}else{changedHorizon.push({start:horizonPart.start,end:horizonPart.end,boundary:useBoundary});lastBoundary=useBoundary}}if(horizon[i].start<boundary.y1){changedHorizon[0].start=boundary.y1;changedHorizon.unshift({start:horizon[i].start,end:boundary.y1,boundary:horizon[i].boundary})}if(boundary.y2<horizon[j].end){changedHorizon[changedHorizon.length-1].end=boundary.y2;changedHorizon.push({start:boundary.y2,end:horizon[j].end,boundary:horizon[j].boundary})}for(q=i;q<=j;q++){horizonPart=horizon[q];affectedBoundary=horizonPart.boundary;if(affectedBoundary.x2New!==undefined){continue}var used=false;for(k=i-1;!used&&k>=0&&horizon[k].start>=affectedBoundary.y1;k--){used=horizon[k].boundary===affectedBoundary}for(k=j+1;!used&&k<horizon.length&&horizon[k].end<=affectedBoundary.y2;k++){used=horizon[k].boundary===affectedBoundary}for(k=0;!used&&k<changedHorizon.length;k++){used=changedHorizon[k].boundary===affectedBoundary}if(!used){affectedBoundary.x2New=maxXNew}}Array.prototype.splice.apply(horizon,[i,j-i+1].concat(changedHorizon))});horizon.forEach(function(horizonPart){var affectedBoundary=horizonPart.boundary;if(affectedBoundary.x2New===undefined){affectedBoundary.x2New=Math.max(width,affectedBoundary.x2)}})}function TextLayerRenderTask(textContent,container,viewport,textDivs,enhanceTextSelection){this._textContent=textContent;this._container=container;this._viewport=viewport;this._textDivs=textDivs||[];this._textDivProperties=new WeakMap;this._renderingDone=false;this._canceled=false;this._capability=createPromiseCapability();this._renderTimer=null;this._bounds=[];this._enhanceTextSelection=!!enhanceTextSelection}TextLayerRenderTask.prototype={get promise(){return this._capability.promise},cancel:function TextLayer_cancel(){this._canceled=true;if(this._renderTimer!==null){clearTimeout(this._renderTimer);this._renderTimer=null}this._capability.reject("canceled")},_render:function TextLayer_render(timeout){var textItems=this._textContent.items;var textStyles=this._textContent.styles;for(var i=0,len=textItems.length;i<len;i++){appendText(this,textItems[i],textStyles)}if(!timeout){render(this)}else{var self=this;this._renderTimer=setTimeout(function(){render(self);self._renderTimer=null},timeout)}},expandTextDivs:function TextLayer_expandTextDivs(expandDivs){if(!this._enhanceTextSelection||!this._renderingDone){return}if(this._bounds!==null){expand(this);this._bounds=null}for(var i=0,ii=this._textDivs.length;i<ii;i++){var div=this._textDivs[i];var divProperties=this._textDivProperties.get(div);if(divProperties.isWhitespace){continue}if(expandDivs){var transform="",padding="";if(divProperties.scale!==1){transform="scaleX("+divProperties.scale+")"}if(divProperties.angle!==0){transform="rotate("+divProperties.angle+"deg) "+transform}if(divProperties.paddingLeft!==0){padding+=" padding-left: "+divProperties.paddingLeft/divProperties.scale+"px;";transform+=" translateX("+-divProperties.paddingLeft/divProperties.scale+"px)"}if(divProperties.paddingTop!==0){padding+=" padding-top: "+divProperties.paddingTop+"px;";transform+=" translateY("+-divProperties.paddingTop+"px)"}if(divProperties.paddingRight!==0){padding+=" padding-right: "+divProperties.paddingRight/divProperties.scale+"px;"}if(divProperties.paddingBottom!==0){padding+=" padding-bottom: "+divProperties.paddingBottom+"px;"}if(padding!==""){div.setAttribute("style",divProperties.style+padding)}if(transform!==""){CustomStyle.setProp("transform",div,transform)}}else{div.style.padding=0;CustomStyle.setProp("transform",div,divProperties.originalTransform||"")}}}};function renderTextLayer(renderParameters){var task=new TextLayerRenderTask(renderParameters.textContent,renderParameters.container,renderParameters.viewport,renderParameters.textDivs,renderParameters.enhanceTextSelection);task._render(renderParameters.timeout);return task}return renderTextLayer}();exports.renderTextLayer=renderTextLayer});(function(root,factory){{factory(root.pdfjsDisplayWebGL={},root.pdfjsSharedUtil,root.pdfjsDisplayDOMUtils)}})(this,function(exports,sharedUtil,displayDOMUtils){var shadow=sharedUtil.shadow;var getDefaultSetting=displayDOMUtils.getDefaultSetting;var WebGLUtils=function WebGLUtilsClosure(){function loadShader(gl,code,shaderType){var shader=gl.createShader(shaderType);gl.shaderSource(shader,code);gl.compileShader(shader);var compiled=gl.getShaderParameter(shader,gl.COMPILE_STATUS);if(!compiled){var errorMsg=gl.getShaderInfoLog(shader);throw new Error("Error during shader compilation: "+errorMsg)}return shader}function createVertexShader(gl,code){return loadShader(gl,code,gl.VERTEX_SHADER)}function createFragmentShader(gl,code){return loadShader(gl,code,gl.FRAGMENT_SHADER)}function createProgram(gl,shaders){var program=gl.createProgram();for(var i=0,ii=shaders.length;i<ii;++i){gl.attachShader(program,shaders[i])}gl.linkProgram(program);var linked=gl.getProgramParameter(program,gl.LINK_STATUS);if(!linked){var errorMsg=gl.getProgramInfoLog(program);throw new Error("Error during program linking: "+errorMsg)}return program}function createTexture(gl,image,textureId){gl.activeTexture(textureId);var texture=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,texture);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,image);return texture}var currentGL,currentCanvas;function generateGL(){if(currentGL){return}currentCanvas=document.createElement("canvas");currentGL=currentCanvas.getContext("webgl",{premultipliedalpha:false})}var smaskVertexShaderCode=" attribute vec2 a_position; attribute vec2 a_texCoord; uniform vec2 u_resolution; varying vec2 v_texCoord; void main() { vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); v_texCoord = a_texCoord; } ";var smaskFragmentShaderCode=" precision mediump float; uniform vec4 u_backdrop; uniform int u_subtype; uniform sampler2D u_image; uniform sampler2D u_mask; varying vec2 v_texCoord; void main() { vec4 imageColor = texture2D(u_image, v_texCoord); vec4 maskColor = texture2D(u_mask, v_texCoord); if (u_backdrop.a > 0.0) { maskColor.rgb = maskColor.rgb * maskColor.a + u_backdrop.rgb * (1.0 - maskColor.a); } float lum; if (u_subtype == 0) { lum = maskColor.a; } else { lum = maskColor.r * 0.3 + maskColor.g * 0.59 + maskColor.b * 0.11; } imageColor.a *= lum; imageColor.rgb *= imageColor.a; gl_FragColor = imageColor; } ";var smaskCache=null;function initSmaskGL(){var canvas,gl;generateGL();canvas=currentCanvas;currentCanvas=null;gl=currentGL;currentGL=null;var vertexShader=createVertexShader(gl,smaskVertexShaderCode);var fragmentShader=createFragmentShader(gl,smaskFragmentShaderCode);var program=createProgram(gl,[vertexShader,fragmentShader]);gl.useProgram(program);var cache={};cache.gl=gl;cache.canvas=canvas;cache.resolutionLocation=gl.getUniformLocation(program,"u_resolution");cache.positionLocation=gl.getAttribLocation(program,"a_position");cache.backdropLocation=gl.getUniformLocation(program,"u_backdrop");cache.subtypeLocation=gl.getUniformLocation(program,"u_subtype");var texCoordLocation=gl.getAttribLocation(program,"a_texCoord");var texLayerLocation=gl.getUniformLocation(program,"u_image");var texMaskLocation=gl.getUniformLocation(program,"u_mask");var texCoordBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,texCoordBuffer);gl.bufferData(gl.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),gl.STATIC_DRAW);gl.enableVertexAttribArray(texCoordLocation);gl.vertexAttribPointer(texCoordLocation,2,gl.FLOAT,false,0,0);gl.uniform1i(texLayerLocation,0);gl.uniform1i(texMaskLocation,1);smaskCache=cache}function composeSMask(layer,mask,properties){var width=layer.width,height=layer.height;if(!smaskCache){initSmaskGL()}var cache=smaskCache,canvas=cache.canvas,gl=cache.gl;canvas.width=width;canvas.height=height;gl.viewport(0,0,gl.drawingBufferWidth,gl.drawingBufferHeight);gl.uniform2f(cache.resolutionLocation,width,height);if(properties.backdrop){gl.uniform4f(cache.resolutionLocation,properties.backdrop[0],properties.backdrop[1],properties.backdrop[2],1)}else{gl.uniform4f(cache.resolutionLocation,0,0,0,0)}gl.uniform1i(cache.subtypeLocation,properties.subtype==="Luminosity"?1:0);var texture=createTexture(gl,layer,gl.TEXTURE0);var maskTexture=createTexture(gl,mask,gl.TEXTURE1);var buffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,buffer);gl.bufferData(gl.ARRAY_BUFFER,new Float32Array([0,0,width,0,0,height,0,height,width,0,width,height]),gl.STATIC_DRAW);gl.enableVertexAttribArray(cache.positionLocation);gl.vertexAttribPointer(cache.positionLocation,2,gl.FLOAT,false,0,0);gl.clearColor(0,0,0,0);gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE_MINUS_SRC_ALPHA);gl.clear(gl.COLOR_BUFFER_BIT);gl.drawArrays(gl.TRIANGLES,0,6);gl.flush();gl.deleteTexture(texture);gl.deleteTexture(maskTexture);gl.deleteBuffer(buffer);return canvas}var figuresVertexShaderCode=" attribute vec2 a_position; attribute vec3 a_color; uniform vec2 u_resolution; uniform vec2 u_scale; uniform vec2 u_offset; varying vec4 v_color; void main() { vec2 position = (a_position + u_offset) * u_scale; vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); v_color = vec4(a_color / 255.0, 1.0); } ";var figuresFragmentShaderCode=" precision mediump float; varying vec4 v_color; void main() { gl_FragColor = v_color; } ";var figuresCache=null;function initFiguresGL(){var canvas,gl;generateGL();canvas=currentCanvas;currentCanvas=null;gl=currentGL;currentGL=null;var vertexShader=createVertexShader(gl,figuresVertexShaderCode);var fragmentShader=createFragmentShader(gl,figuresFragmentShaderCode);var program=createProgram(gl,[vertexShader,fragmentShader]);gl.useProgram(program);var cache={};cache.gl=gl;cache.canvas=canvas;cache.resolutionLocation=gl.getUniformLocation(program,"u_resolution");cache.scaleLocation=gl.getUniformLocation(program,"u_scale");cache.offsetLocation=gl.getUniformLocation(program,"u_offset");cache.positionLocation=gl.getAttribLocation(program,"a_position");cache.colorLocation=gl.getAttribLocation(program,"a_color");figuresCache=cache}function drawFigures(width,height,backgroundColor,figures,context){if(!figuresCache){initFiguresGL()}var cache=figuresCache,canvas=cache.canvas,gl=cache.gl;canvas.width=width;canvas.height=height;gl.viewport(0,0,gl.drawingBufferWidth,gl.drawingBufferHeight);gl.uniform2f(cache.resolutionLocation,width,height);var count=0;var i,ii,rows;for(i=0,ii=figures.length;i<ii;i++){switch(figures[i].type){case"lattice":rows=figures[i].coords.length/figures[i].verticesPerRow|0;count+=(rows-1)*(figures[i].verticesPerRow-1)*6;break;case"triangles":count+=figures[i].coords.length;break}}var coords=new Float32Array(count*2);var colors=new Uint8Array(count*3);var coordsMap=context.coords,colorsMap=context.colors;var pIndex=0,cIndex=0;for(i=0,ii=figures.length;i<ii;i++){var figure=figures[i],ps=figure.coords,cs=figure.colors;switch(figure.type){case"lattice":var cols=figure.verticesPerRow;rows=ps.length/cols|0;for(var row=1;row<rows;row++){var offset=row*cols+1;for(var col=1;col<cols;col++,offset++){coords[pIndex]=coordsMap[ps[offset-cols-1]];coords[pIndex+1]=coordsMap[ps[offset-cols-1]+1];coords[pIndex+2]=coordsMap[ps[offset-cols]];coords[pIndex+3]=coordsMap[ps[offset-cols]+1];coords[pIndex+4]=coordsMap[ps[offset-1]];coords[pIndex+5]=coordsMap[ps[offset-1]+1];colors[cIndex]=colorsMap[cs[offset-cols-1]];colors[cIndex+1]=colorsMap[cs[offset-cols-1]+1];colors[cIndex+2]=colorsMap[cs[offset-cols-1]+2];colors[cIndex+3]=colorsMap[cs[offset-cols]];colors[cIndex+4]=colorsMap[cs[offset-cols]+1];colors[cIndex+5]=colorsMap[cs[offset-cols]+2];colors[cIndex+6]=colorsMap[cs[offset-1]];colors[cIndex+7]=colorsMap[cs[offset-1]+1];colors[cIndex+8]=colorsMap[cs[offset-1]+2];coords[pIndex+6]=coords[pIndex+2];coords[pIndex+7]=coords[pIndex+3];coords[pIndex+8]=coords[pIndex+4];coords[pIndex+9]=coords[pIndex+5];coords[pIndex+10]=coordsMap[ps[offset]];coords[pIndex+11]=coordsMap[ps[offset]+1];colors[cIndex+9]=colors[cIndex+3];colors[cIndex+10]=colors[cIndex+4];colors[cIndex+11]=colors[cIndex+5];colors[cIndex+12]=colors[cIndex+6];colors[cIndex+13]=colors[cIndex+7];colors[cIndex+14]=colors[cIndex+8];colors[cIndex+15]=colorsMap[cs[offset]];colors[cIndex+16]=colorsMap[cs[offset]+1];colors[cIndex+17]=colorsMap[cs[offset]+2];pIndex+=12;cIndex+=18}}break;case"triangles":for(var j=0,jj=ps.length;j<jj;j++){coords[pIndex]=coordsMap[ps[j]];coords[pIndex+1]=coordsMap[ps[j]+1];colors[cIndex]=colorsMap[cs[j]];colors[cIndex+1]=colorsMap[cs[j]+1];colors[cIndex+2]=colorsMap[cs[j]+2];pIndex+=2;cIndex+=3}break}}if(backgroundColor){gl.clearColor(backgroundColor[0]/255,backgroundColor[1]/255,backgroundColor[2]/255,1)}else{gl.clearColor(0,0,0,0)}gl.clear(gl.COLOR_BUFFER_BIT);var coordsBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,coordsBuffer);gl.bufferData(gl.ARRAY_BUFFER,coords,gl.STATIC_DRAW);gl.enableVertexAttribArray(cache.positionLocation);gl.vertexAttribPointer(cache.positionLocation,2,gl.FLOAT,false,0,0);var colorsBuffer=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,colorsBuffer);gl.bufferData(gl.ARRAY_BUFFER,colors,gl.STATIC_DRAW);gl.enableVertexAttribArray(cache.colorLocation);gl.vertexAttribPointer(cache.colorLocation,3,gl.UNSIGNED_BYTE,false,0,0);gl.uniform2f(cache.scaleLocation,context.scaleX,context.scaleY);gl.uniform2f(cache.offsetLocation,context.offsetX,context.offsetY);gl.drawArrays(gl.TRIANGLES,0,count);gl.flush();gl.deleteBuffer(coordsBuffer);gl.deleteBuffer(colorsBuffer);return canvas}function cleanup(){if(smaskCache&&smaskCache.canvas){smaskCache.canvas.width=0;smaskCache.canvas.height=0}if(figuresCache&&figuresCache.canvas){figuresCache.canvas.width=0;figuresCache.canvas.height=0}smaskCache=null;figuresCache=null}return{get isEnabled(){if(getDefaultSetting("disableWebGL")){return false}var enabled=false;try{generateGL();enabled=!!currentGL}catch(e){}return shadow(this,"isEnabled",enabled)},composeSMask:composeSMask,drawFigures:drawFigures,clear:cleanup}}();exports.WebGLUtils=WebGLUtils});(function(root,factory){{factory(root.pdfjsDisplayPatternHelper={},root.pdfjsSharedUtil,root.pdfjsDisplayWebGL)}})(this,function(exports,sharedUtil,displayWebGL){var Util=sharedUtil.Util;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var error=sharedUtil.error;var WebGLUtils=displayWebGL.WebGLUtils;var ShadingIRs={};ShadingIRs.RadialAxial={fromIR:function RadialAxial_fromIR(raw){var type=raw[1];var colorStops=raw[2];var p0=raw[3];var p1=raw[4];var r0=raw[5];var r1=raw[6];return{type:"Pattern",getPattern:function RadialAxial_getPattern(ctx){var grad;if(type==="axial"){grad=ctx.createLinearGradient(p0[0],p0[1],p1[0],p1[1])}else if(type==="radial"){grad=ctx.createRadialGradient(p0[0],p0[1],r0,p1[0],p1[1],r1)}for(var i=0,ii=colorStops.length;i<ii;++i){var c=colorStops[i];grad.addColorStop(c[0],c[1])}return grad}}}};var createMeshCanvas=function createMeshCanvasClosure(){function drawTriangle(data,context,p1,p2,p3,c1,c2,c3){var coords=context.coords,colors=context.colors;var bytes=data.data,rowSize=data.width*4;var tmp;if(coords[p1+1]>coords[p2+1]){tmp=p1;p1=p2;p2=tmp;tmp=c1;c1=c2;c2=tmp}if(coords[p2+1]>coords[p3+1]){tmp=p2;p2=p3;p3=tmp;tmp=c2;c2=c3;c3=tmp}if(coords[p1+1]>coords[p2+1]){tmp=p1;p1=p2;p2=tmp;tmp=c1;c1=c2;c2=tmp}var x1=(coords[p1]+context.offsetX)*context.scaleX;var y1=(coords[p1+1]+context.offsetY)*context.scaleY;var x2=(coords[p2]+context.offsetX)*context.scaleX;var y2=(coords[p2+1]+context.offsetY)*context.scaleY;var x3=(coords[p3]+context.offsetX)*context.scaleX;var y3=(coords[p3+1]+context.offsetY)*context.scaleY;if(y1>=y3){return}var c1r=colors[c1],c1g=colors[c1+1],c1b=colors[c1+2];var c2r=colors[c2],c2g=colors[c2+1],c2b=colors[c2+2];var c3r=colors[c3],c3g=colors[c3+1],c3b=colors[c3+2];var minY=Math.round(y1),maxY=Math.round(y3);var xa,car,cag,cab;var xb,cbr,cbg,cbb;var k;for(var y=minY;y<=maxY;y++){if(y<y2){k=y<y1?0:y1===y2?1:(y1-y)/(y1-y2);xa=x1-(x1-x2)*k;car=c1r-(c1r-c2r)*k;cag=c1g-(c1g-c2g)*k;cab=c1b-(c1b-c2b)*k}else{k=y>y3?1:y2===y3?0:(y2-y)/(y2-y3);xa=x2-(x2-x3)*k;car=c2r-(c2r-c3r)*k;cag=c2g-(c2g-c3g)*k;cab=c2b-(c2b-c3b)*k}k=y<y1?0:y>y3?1:(y1-y)/(y1-y3);xb=x1-(x1-x3)*k;cbr=c1r-(c1r-c3r)*k;cbg=c1g-(c1g-c3g)*k;cbb=c1b-(c1b-c3b)*k;var x1_=Math.round(Math.min(xa,xb));var x2_=Math.round(Math.max(xa,xb));var j=rowSize*y+x1_*4;for(var x=x1_;x<=x2_;x++){k=(xa-x)/(xa-xb);k=k<0?0:k>1?1:k;bytes[j++]=car-(car-cbr)*k|0;bytes[j++]=cag-(cag-cbg)*k|0;bytes[j++]=cab-(cab-cbb)*k|0;bytes[j++]=255}}}function drawFigure(data,figure,context){var ps=figure.coords;var cs=figure.colors;var i,ii;switch(figure.type){case"lattice":var verticesPerRow=figure.verticesPerRow;var rows=Math.floor(ps.length/verticesPerRow)-1;var cols=verticesPerRow-1;for(i=0;i<rows;i++){var q=i*verticesPerRow;for(var j=0;j<cols;j++,q++){drawTriangle(data,context,ps[q],ps[q+1],ps[q+verticesPerRow],cs[q],cs[q+1],cs[q+verticesPerRow]);drawTriangle(data,context,ps[q+verticesPerRow+1],ps[q+1],ps[q+verticesPerRow],cs[q+verticesPerRow+1],cs[q+1],cs[q+verticesPerRow])}}break;case"triangles":for(i=0,ii=ps.length;i<ii;i+=3){drawTriangle(data,context,ps[i],ps[i+1],ps[i+2],cs[i],cs[i+1],cs[i+2])
5}break;default:error("illigal figure");break}}function createMeshCanvas(bounds,combinesScale,coords,colors,figures,backgroundColor,cachedCanvases){var EXPECTED_SCALE=1.1;var MAX_PATTERN_SIZE=3e3;var BORDER_SIZE=2;var offsetX=Math.floor(bounds[0]);var offsetY=Math.floor(bounds[1]);var boundsWidth=Math.ceil(bounds[2])-offsetX;var boundsHeight=Math.ceil(bounds[3])-offsetY;var width=Math.min(Math.ceil(Math.abs(boundsWidth*combinesScale[0]*EXPECTED_SCALE)),MAX_PATTERN_SIZE);var height=Math.min(Math.ceil(Math.abs(boundsHeight*combinesScale[1]*EXPECTED_SCALE)),MAX_PATTERN_SIZE);var scaleX=boundsWidth/width;var scaleY=boundsHeight/height;var context={coords:coords,colors:colors,offsetX:-offsetX,offsetY:-offsetY,scaleX:1/scaleX,scaleY:1/scaleY};var paddedWidth=width+BORDER_SIZE*2;var paddedHeight=height+BORDER_SIZE*2;var canvas,tmpCanvas,i,ii;if(WebGLUtils.isEnabled){canvas=WebGLUtils.drawFigures(width,height,backgroundColor,figures,context);tmpCanvas=cachedCanvases.getCanvas("mesh",paddedWidth,paddedHeight,false);tmpCanvas.context.drawImage(canvas,BORDER_SIZE,BORDER_SIZE);canvas=tmpCanvas.canvas}else{tmpCanvas=cachedCanvases.getCanvas("mesh",paddedWidth,paddedHeight,false);var tmpCtx=tmpCanvas.context;var data=tmpCtx.createImageData(width,height);if(backgroundColor){var bytes=data.data;for(i=0,ii=bytes.length;i<ii;i+=4){bytes[i]=backgroundColor[0];bytes[i+1]=backgroundColor[1];bytes[i+2]=backgroundColor[2];bytes[i+3]=255}}for(i=0;i<figures.length;i++){drawFigure(data,figures[i],context)}tmpCtx.putImageData(data,BORDER_SIZE,BORDER_SIZE);canvas=tmpCanvas.canvas}return{canvas:canvas,offsetX:offsetX-BORDER_SIZE*scaleX,offsetY:offsetY-BORDER_SIZE*scaleY,scaleX:scaleX,scaleY:scaleY}}return createMeshCanvas}();ShadingIRs.Mesh={fromIR:function Mesh_fromIR(raw){var coords=raw[2];var colors=raw[3];var figures=raw[4];var bounds=raw[5];var matrix=raw[6];var background=raw[8];return{type:"Pattern",getPattern:function Mesh_getPattern(ctx,owner,shadingFill){var scale;if(shadingFill){scale=Util.singularValueDecompose2dScale(ctx.mozCurrentTransform)}else{scale=Util.singularValueDecompose2dScale(owner.baseTransform);if(matrix){var matrixScale=Util.singularValueDecompose2dScale(matrix);scale=[scale[0]*matrixScale[0],scale[1]*matrixScale[1]]}}var temporaryPatternCanvas=createMeshCanvas(bounds,scale,coords,colors,figures,shadingFill?null:background,owner.cachedCanvases);if(!shadingFill){ctx.setTransform.apply(ctx,owner.baseTransform);if(matrix){ctx.transform.apply(ctx,matrix)}}ctx.translate(temporaryPatternCanvas.offsetX,temporaryPatternCanvas.offsetY);ctx.scale(temporaryPatternCanvas.scaleX,temporaryPatternCanvas.scaleY);return ctx.createPattern(temporaryPatternCanvas.canvas,"no-repeat")}}}};ShadingIRs.Dummy={fromIR:function Dummy_fromIR(){return{type:"Pattern",getPattern:function Dummy_fromIR_getPattern(){return"hotpink"}}}};function getShadingPatternFromIR(raw){var shadingIR=ShadingIRs[raw[0]];if(!shadingIR){error("Unknown IR type: "+raw[0])}return shadingIR.fromIR(raw)}var TilingPattern=function TilingPatternClosure(){var PaintType={COLORED:1,UNCOLORED:2};var MAX_PATTERN_SIZE=3e3;function TilingPattern(IR,color,ctx,canvasGraphicsFactory,baseTransform){this.operatorList=IR[2];this.matrix=IR[3]||[1,0,0,1,0,0];this.bbox=IR[4];this.xstep=IR[5];this.ystep=IR[6];this.paintType=IR[7];this.tilingType=IR[8];this.color=color;this.canvasGraphicsFactory=canvasGraphicsFactory;this.baseTransform=baseTransform;this.type="Pattern";this.ctx=ctx}TilingPattern.prototype={createPatternCanvas:function TilinPattern_createPatternCanvas(owner){var operatorList=this.operatorList;var bbox=this.bbox;var xstep=this.xstep;var ystep=this.ystep;var paintType=this.paintType;var tilingType=this.tilingType;var color=this.color;var canvasGraphicsFactory=this.canvasGraphicsFactory;info("TilingType: "+tilingType);var x0=bbox[0],y0=bbox[1],x1=bbox[2],y1=bbox[3];var topLeft=[x0,y0];var botRight=[x0+xstep,y0+ystep];var width=botRight[0]-topLeft[0];var height=botRight[1]-topLeft[1];var matrixScale=Util.singularValueDecompose2dScale(this.matrix);var curMatrixScale=Util.singularValueDecompose2dScale(this.baseTransform);var combinedScale=[matrixScale[0]*curMatrixScale[0],matrixScale[1]*curMatrixScale[1]];width=Math.min(Math.ceil(Math.abs(width*combinedScale[0])),MAX_PATTERN_SIZE);height=Math.min(Math.ceil(Math.abs(height*combinedScale[1])),MAX_PATTERN_SIZE);var tmpCanvas=owner.cachedCanvases.getCanvas("pattern",width,height,true);var tmpCtx=tmpCanvas.context;var graphics=canvasGraphicsFactory.createCanvasGraphics(tmpCtx);graphics.groupLevel=owner.groupLevel;this.setFillAndStrokeStyleToContext(tmpCtx,paintType,color);this.setScale(width,height,xstep,ystep);this.transformToScale(graphics);var tmpTranslate=[1,0,0,1,-topLeft[0],-topLeft[1]];graphics.transform.apply(graphics,tmpTranslate);this.clipBbox(graphics,bbox,x0,y0,x1,y1);graphics.executeOperatorList(operatorList);return tmpCanvas.canvas},setScale:function TilingPattern_setScale(width,height,xstep,ystep){this.scale=[width/xstep,height/ystep]},transformToScale:function TilingPattern_transformToScale(graphics){var scale=this.scale;var tmpScale=[scale[0],0,0,scale[1],0,0];graphics.transform.apply(graphics,tmpScale)},scaleToContext:function TilingPattern_scaleToContext(){var scale=this.scale;this.ctx.scale(1/scale[0],1/scale[1])},clipBbox:function clipBbox(graphics,bbox,x0,y0,x1,y1){if(bbox&&isArray(bbox)&&bbox.length===4){var bboxWidth=x1-x0;var bboxHeight=y1-y0;graphics.ctx.rect(x0,y0,bboxWidth,bboxHeight);graphics.clip();graphics.endPath()}},setFillAndStrokeStyleToContext:function setFillAndStrokeStyleToContext(context,paintType,color){switch(paintType){case PaintType.COLORED:var ctx=this.ctx;context.fillStyle=ctx.fillStyle;context.strokeStyle=ctx.strokeStyle;break;case PaintType.UNCOLORED:var cssColor=Util.makeCssRgb(color[0],color[1],color[2]);context.fillStyle=cssColor;context.strokeStyle=cssColor;break;default:error("Unsupported paint type: "+paintType)}},getPattern:function TilingPattern_getPattern(ctx,owner){var temporaryPatternCanvas=this.createPatternCanvas(owner);ctx=this.ctx;ctx.setTransform.apply(ctx,this.baseTransform);ctx.transform.apply(ctx,this.matrix);this.scaleToContext();return ctx.createPattern(temporaryPatternCanvas,"repeat")}};return TilingPattern}();exports.getShadingPatternFromIR=getShadingPatternFromIR;exports.TilingPattern=TilingPattern});(function(root,factory){{factory(root.pdfjsDisplayCanvas={},root.pdfjsSharedUtil,root.pdfjsDisplayDOMUtils,root.pdfjsDisplayPatternHelper,root.pdfjsDisplayWebGL)}})(this,function(exports,sharedUtil,displayDOMUtils,displayPatternHelper,displayWebGL){var FONT_IDENTITY_MATRIX=sharedUtil.FONT_IDENTITY_MATRIX;var IDENTITY_MATRIX=sharedUtil.IDENTITY_MATRIX;var ImageKind=sharedUtil.ImageKind;var OPS=sharedUtil.OPS;var TextRenderingMode=sharedUtil.TextRenderingMode;var Uint32ArrayView=sharedUtil.Uint32ArrayView;var Util=sharedUtil.Util;var assert=sharedUtil.assert;var info=sharedUtil.info;var isNum=sharedUtil.isNum;var isArray=sharedUtil.isArray;var isLittleEndian=sharedUtil.isLittleEndian;var error=sharedUtil.error;var shadow=sharedUtil.shadow;var warn=sharedUtil.warn;var TilingPattern=displayPatternHelper.TilingPattern;var getShadingPatternFromIR=displayPatternHelper.getShadingPatternFromIR;var WebGLUtils=displayWebGL.WebGLUtils;var hasCanvasTypedArrays=displayDOMUtils.hasCanvasTypedArrays;var MIN_FONT_SIZE=16;var MAX_FONT_SIZE=100;var MAX_GROUP_SIZE=4096;var MIN_WIDTH_FACTOR=.65;var COMPILE_TYPE3_GLYPHS=true;var MAX_SIZE_TO_COMPILE=1e3;var FULL_CHUNK_HEIGHT=16;var HasCanvasTypedArraysCached={get value(){return shadow(HasCanvasTypedArraysCached,"value",hasCanvasTypedArrays())}};var IsLittleEndianCached={get value(){return shadow(IsLittleEndianCached,"value",isLittleEndian())}};function createScratchCanvas(width,height){var canvas=document.createElement("canvas");canvas.width=width;canvas.height=height;return canvas}function addContextCurrentTransform(ctx){if(!ctx.mozCurrentTransform){ctx._originalSave=ctx.save;ctx._originalRestore=ctx.restore;ctx._originalRotate=ctx.rotate;ctx._originalScale=ctx.scale;ctx._originalTranslate=ctx.translate;ctx._originalTransform=ctx.transform;ctx._originalSetTransform=ctx.setTransform;ctx._transformMatrix=ctx._transformMatrix||[1,0,0,1,0,0];ctx._transformStack=[];Object.defineProperty(ctx,"mozCurrentTransform",{get:function getCurrentTransform(){return this._transformMatrix}});Object.defineProperty(ctx,"mozCurrentTransformInverse",{get:function getCurrentTransformInverse(){var m=this._transformMatrix;var a=m[0],b=m[1],c=m[2],d=m[3],e=m[4],f=m[5];var ad_bc=a*d-b*c;var bc_ad=b*c-a*d;return[d/ad_bc,b/bc_ad,c/bc_ad,a/ad_bc,(d*e-c*f)/bc_ad,(b*e-a*f)/ad_bc]}});ctx.save=function ctxSave(){var old=this._transformMatrix;this._transformStack.push(old);this._transformMatrix=old.slice(0,6);this._originalSave()};ctx.restore=function ctxRestore(){var prev=this._transformStack.pop();if(prev){this._transformMatrix=prev;this._originalRestore()}};ctx.translate=function ctxTranslate(x,y){var m=this._transformMatrix;m[4]=m[0]*x+m[2]*y+m[4];m[5]=m[1]*x+m[3]*y+m[5];this._originalTranslate(x,y)};ctx.scale=function ctxScale(x,y){var m=this._transformMatrix;m[0]=m[0]*x;m[1]=m[1]*x;m[2]=m[2]*y;m[3]=m[3]*y;this._originalScale(x,y)};ctx.transform=function ctxTransform(a,b,c,d,e,f){var m=this._transformMatrix;this._transformMatrix=[m[0]*a+m[2]*b,m[1]*a+m[3]*b,m[0]*c+m[2]*d,m[1]*c+m[3]*d,m[0]*e+m[2]*f+m[4],m[1]*e+m[3]*f+m[5]];ctx._originalTransform(a,b,c,d,e,f)};ctx.setTransform=function ctxSetTransform(a,b,c,d,e,f){this._transformMatrix=[a,b,c,d,e,f];ctx._originalSetTransform(a,b,c,d,e,f)};ctx.rotate=function ctxRotate(angle){var cosValue=Math.cos(angle);var sinValue=Math.sin(angle);var m=this._transformMatrix;this._transformMatrix=[m[0]*cosValue+m[2]*sinValue,m[1]*cosValue+m[3]*sinValue,m[0]*-sinValue+m[2]*cosValue,m[1]*-sinValue+m[3]*cosValue,m[4],m[5]];this._originalRotate(angle)}}}var CachedCanvases=function CachedCanvasesClosure(){function CachedCanvases(){this.cache=Object.create(null)}CachedCanvases.prototype={getCanvas:function CachedCanvases_getCanvas(id,width,height,trackTransform){var canvasEntry;if(this.cache[id]!==undefined){canvasEntry=this.cache[id];canvasEntry.canvas.width=width;canvasEntry.canvas.height=height;canvasEntry.context.setTransform(1,0,0,1,0,0)}else{var canvas=createScratchCanvas(width,height);var ctx=canvas.getContext("2d");if(trackTransform){addContextCurrentTransform(ctx)}this.cache[id]=canvasEntry={canvas:canvas,context:ctx}}return canvasEntry},clear:function(){for(var id in this.cache){var canvasEntry=this.cache[id];canvasEntry.canvas.width=0;canvasEntry.canvas.height=0;delete this.cache[id]}}};return CachedCanvases}();function compileType3Glyph(imgData){var POINT_TO_PROCESS_LIMIT=1e3;var width=imgData.width,height=imgData.height;var i,j,j0,width1=width+1;var points=new Uint8Array(width1*(height+1));var POINT_TYPES=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]);var lineSize=width+7&~7,data0=imgData.data;var data=new Uint8Array(lineSize*height),pos=0,ii;for(i=0,ii=data0.length;i<ii;i++){var mask=128,elem=data0[i];while(mask>0){data[pos++]=elem&mask?0:255;mask>>=1}}var count=0;pos=0;if(data[pos]!==0){points[0]=1;++count}for(j=1;j<width;j++){if(data[pos]!==data[pos+1]){points[j]=data[pos]?2:1;++count}pos++}if(data[pos]!==0){points[j]=2;++count}for(i=1;i<height;i++){pos=i*lineSize;j0=i*width1;if(data[pos-lineSize]!==data[pos]){points[j0]=data[pos]?1:8;++count}var sum=(data[pos]?4:0)+(data[pos-lineSize]?8:0);for(j=1;j<width;j++){sum=(sum>>2)+(data[pos+1]?4:0)+(data[pos-lineSize+1]?8:0);if(POINT_TYPES[sum]){points[j0+j]=POINT_TYPES[sum];++count}pos++}if(data[pos-lineSize]!==data[pos]){points[j0+j]=data[pos]?2:4;++count}if(count>POINT_TO_PROCESS_LIMIT){return null}}pos=lineSize*(height-1);j0=i*width1;if(data[pos]!==0){points[j0]=8;++count}for(j=1;j<width;j++){if(data[pos]!==data[pos+1]){points[j0+j]=data[pos]?4:8;++count}pos++}if(data[pos]!==0){points[j0+j]=4;++count}if(count>POINT_TO_PROCESS_LIMIT){return null}var steps=new Int32Array([0,width1,-1,0,-width1,0,0,0,1]);var outlines=[];for(i=0;count&&i<=height;i++){var p=i*width1;var end=p+width;while(p<end&&!points[p]){p++}if(p===end){continue}var coords=[p%width1,i];var type=points[p],p0=p,pp;do{var step=steps[type];do{p+=step}while(!points[p]);pp=points[p];if(pp!==5&&pp!==10){type=pp;points[p]=0}else{type=pp&51*type>>4;points[p]&=type>>2|type<<2}coords.push(p%width1);coords.push(p/width1|0);--count}while(p0!==p);outlines.push(coords);--i}var drawOutline=function(c){c.save();c.scale(1/width,-1/height);c.translate(0,-height);c.beginPath();for(var i=0,ii=outlines.length;i<ii;i++){var o=outlines[i];c.moveTo(o[0],o[1]);for(var j=2,jj=o.length;j<jj;j+=2){c.lineTo(o[j],o[j+1])}}c.fill();c.beginPath();c.restore()};return drawOutline}var CanvasExtraState=function CanvasExtraStateClosure(){function CanvasExtraState(old){this.alphaIsShape=false;this.fontSize=0;this.fontSizeScale=1;this.textMatrix=IDENTITY_MATRIX;this.textMatrixScale=1;this.fontMatrix=FONT_IDENTITY_MATRIX;this.leading=0;this.x=0;this.y=0;this.lineX=0;this.lineY=0;this.charSpacing=0;this.wordSpacing=0;this.textHScale=1;this.textRenderingMode=TextRenderingMode.FILL;this.textRise=0;this.fillColor="#000000";this.strokeColor="#000000";this.patternFill=false;this.fillAlpha=1;this.strokeAlpha=1;this.lineWidth=1;this.activeSMask=null;this.resumeSMaskCtx=null;this.old=old}CanvasExtraState.prototype={clone:function CanvasExtraState_clone(){return Object.create(this)},setCurrentPoint:function CanvasExtraState_setCurrentPoint(x,y){this.x=x;this.y=y}};return CanvasExtraState}();var CanvasGraphics=function CanvasGraphicsClosure(){var EXECUTION_TIME=15;var EXECUTION_STEPS=10;function CanvasGraphics(canvasCtx,commonObjs,objs,imageLayer){this.ctx=canvasCtx;this.current=new CanvasExtraState;this.stateStack=[];this.pendingClip=null;this.pendingEOFill=false;this.res=null;this.xobjs=null;this.commonObjs=commonObjs;this.objs=objs;this.imageLayer=imageLayer;this.groupStack=[];this.processingType3=null;this.baseTransform=null;this.baseTransformStack=[];this.groupLevel=0;this.smaskStack=[];this.smaskCounter=0;this.tempSMask=null;this.cachedCanvases=new CachedCanvases;if(canvasCtx){addContextCurrentTransform(canvasCtx)}this.cachedGetSinglePixelWidth=null}function putBinaryImageData(ctx,imgData){if(typeof ImageData!=="undefined"&&imgData instanceof ImageData){ctx.putImageData(imgData,0,0);return}var height=imgData.height,width=imgData.width;var partialChunkHeight=height%FULL_CHUNK_HEIGHT;var fullChunks=(height-partialChunkHeight)/FULL_CHUNK_HEIGHT;var totalChunks=partialChunkHeight===0?fullChunks:fullChunks+1;var chunkImgData=ctx.createImageData(width,FULL_CHUNK_HEIGHT);var srcPos=0,destPos;var src=imgData.data;var dest=chunkImgData.data;var i,j,thisChunkHeight,elemsInThisChunk;if(imgData.kind===ImageKind.GRAYSCALE_1BPP){var srcLength=src.byteLength;var dest32=HasCanvasTypedArraysCached.value?new Uint32Array(dest.buffer):new Uint32ArrayView(dest);var dest32DataLength=dest32.length;var fullSrcDiff=width+7>>3;var white=4294967295;var black=IsLittleEndianCached.value||!HasCanvasTypedArraysCached.value?4278190080:255;for(i=0;i<totalChunks;i++){thisChunkHeight=i<fullChunks?FULL_CHUNK_HEIGHT:partialChunkHeight;destPos=0;for(j=0;j<thisChunkHeight;j++){var srcDiff=srcLength-srcPos;var k=0;var kEnd=srcDiff>fullSrcDiff?width:srcDiff*8-7;var kEndUnrolled=kEnd&~7;var mask=0;var srcByte=0;for(;k<kEndUnrolled;k+=8){srcByte=src[srcPos++];dest32[destPos++]=srcByte&128?white:black;dest32[destPos++]=srcByte&64?white:black;dest32[destPos++]=srcByte&32?white:black;dest32[destPos++]=srcByte&16?white:black;dest32[destPos++]=srcByte&8?white:black;dest32[destPos++]=srcByte&4?white:black;dest32[destPos++]=srcByte&2?white:black;dest32[destPos++]=srcByte&1?white:black}for(;k<kEnd;k++){if(mask===0){srcByte=src[srcPos++];mask=128}dest32[destPos++]=srcByte&mask?white:black;mask>>=1}}while(destPos<dest32DataLength){dest32[destPos++]=0}ctx.putImageData(chunkImgData,0,i*FULL_CHUNK_HEIGHT)}}else if(imgData.kind===ImageKind.RGBA_32BPP){j=0;elemsInThisChunk=width*FULL_CHUNK_HEIGHT*4;for(i=0;i<fullChunks;i++){dest.set(src.subarray(srcPos,srcPos+elemsInThisChunk));srcPos+=elemsInThisChunk;ctx.putImageData(chunkImgData,0,j);j+=FULL_CHUNK_HEIGHT}if(i<totalChunks){elemsInThisChunk=width*partialChunkHeight*4;dest.set(src.subarray(srcPos,srcPos+elemsInThisChunk));ctx.putImageData(chunkImgData,0,j)}}else if(imgData.kind===ImageKind.RGB_24BPP){thisChunkHeight=FULL_CHUNK_HEIGHT;elemsInThisChunk=width*thisChunkHeight;for(i=0;i<totalChunks;i++){if(i>=fullChunks){thisChunkHeight=partialChunkHeight;elemsInThisChunk=width*thisChunkHeight}destPos=0;for(j=elemsInThisChunk;j--;){dest[destPos++]=src[srcPos++];dest[destPos++]=src[srcPos++];dest[destPos++]=src[srcPos++];dest[destPos++]=255}ctx.putImageData(chunkImgData,0,i*FULL_CHUNK_HEIGHT)}}else{error("bad image kind: "+imgData.kind)}}function putBinaryImageMask(ctx,imgData){var height=imgData.height,width=imgData.width;var partialChunkHeight=height%FULL_CHUNK_HEIGHT;var fullChunks=(height-partialChunkHeight)/FULL_CHUNK_HEIGHT;var totalChunks=partialChunkHeight===0?fullChunks:fullChunks+1;var chunkImgData=ctx.createImageData(width,FULL_CHUNK_HEIGHT);var srcPos=0;var src=imgData.data;var dest=chunkImgData.data;for(var i=0;i<totalChunks;i++){var thisChunkHeight=i<fullChunks?FULL_CHUNK_HEIGHT:partialChunkHeight;var destPos=3;for(var j=0;j<thisChunkHeight;j++){var mask=0;for(var k=0;k<width;k++){if(!mask){var elem=src[srcPos++];mask=128}dest[destPos]=elem&mask?0:255;destPos+=4;mask>>=1}}ctx.putImageData(chunkImgData,0,i*FULL_CHUNK_HEIGHT)}}function copyCtxState(sourceCtx,destCtx){var properties=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"];for(var i=0,ii=properties.length;i<ii;i++){var property=properties[i];if(sourceCtx[property]!==undefined){destCtx[property]=sourceCtx[property]}}if(sourceCtx.setLineDash!==undefined){destCtx.setLineDash(sourceCtx.getLineDash());destCtx.lineDashOffset=sourceCtx.lineDashOffset}}function composeSMaskBackdrop(bytes,r0,g0,b0){var length=bytes.length;for(var i=3;i<length;i+=4){var alpha=bytes[i];if(alpha===0){bytes[i-3]=r0;bytes[i-2]=g0;bytes[i-1]=b0}else if(alpha<255){var alpha_=255-alpha;bytes[i-3]=bytes[i-3]*alpha+r0*alpha_>>8;bytes[i-2]=bytes[i-2]*alpha+g0*alpha_>>8;bytes[i-1]=bytes[i-1]*alpha+b0*alpha_>>8}}}function composeSMaskAlpha(maskData,layerData,transferMap){var length=maskData.length;var scale=1/255;for(var i=3;i<length;i+=4){var alpha=transferMap?transferMap[maskData[i]]:maskData[i];layerData[i]=layerData[i]*alpha*scale|0}}function composeSMaskLuminosity(maskData,layerData,transferMap){var length=maskData.length;for(var i=3;i<length;i+=4){var y=maskData[i-3]*77+maskData[i-2]*152+maskData[i-1]*28;layerData[i]=transferMap?layerData[i]*transferMap[y>>8]>>8:layerData[i]*y>>16}}function genericComposeSMask(maskCtx,layerCtx,width,height,subtype,backdrop,transferMap){var hasBackdrop=!!backdrop;var r0=hasBackdrop?backdrop[0]:0;var g0=hasBackdrop?backdrop[1]:0;var b0=hasBackdrop?backdrop[2]:0;var composeFn;if(subtype==="Luminosity"){composeFn=composeSMaskLuminosity}else{composeFn=composeSMaskAlpha}var PIXELS_TO_PROCESS=1048576;var chunkSize=Math.min(height,Math.ceil(PIXELS_TO_PROCESS/width));for(var row=0;row<height;row+=chunkSize){var chunkHeight=Math.min(chunkSize,height-row);var maskData=maskCtx.getImageData(0,row,width,chunkHeight);var layerData=layerCtx.getImageData(0,row,width,chunkHeight);if(hasBackdrop){composeSMaskBackdrop(maskData.data,r0,g0,b0)}composeFn(maskData.data,layerData.data,transferMap);maskCtx.putImageData(layerData,0,row)}}function composeSMask(ctx,smask,layerCtx){var mask=smask.canvas;var maskCtx=smask.context;ctx.setTransform(smask.scaleX,0,0,smask.scaleY,smask.offsetX,smask.offsetY);var backdrop=smask.backdrop||null;if(!smask.transferMap&&WebGLUtils.isEnabled){var composed=WebGLUtils.composeSMask(layerCtx.canvas,mask,{subtype:smask.subtype,backdrop:backdrop});ctx.setTransform(1,0,0,1,0,0);ctx.drawImage(composed,smask.offsetX,smask.offsetY);return}genericComposeSMask(maskCtx,layerCtx,mask.width,mask.height,smask.subtype,backdrop,smask.transferMap);ctx.drawImage(mask,0,0)}var LINE_CAP_STYLES=["butt","round","square"];var LINE_JOIN_STYLES=["miter","round","bevel"];var NORMAL_CLIP={};var EO_CLIP={};CanvasGraphics.prototype={beginDrawing:function CanvasGraphics_beginDrawing(transform,viewport,transparency){var width=this.ctx.canvas.width;var height=this.ctx.canvas.height;this.ctx.save();this.ctx.fillStyle="rgb(255, 255, 255)";this.ctx.fillRect(0,0,width,height);this.ctx.restore();if(transparency){var transparentCanvas=this.cachedCanvases.getCanvas("transparent",width,height,true);this.compositeCtx=this.ctx;this.transparentCanvas=transparentCanvas.canvas;this.ctx=transparentCanvas.context;this.ctx.save();this.ctx.transform.apply(this.ctx,this.compositeCtx.mozCurrentTransform)}this.ctx.save();if(transform){this.ctx.transform.apply(this.ctx,transform)}this.ctx.transform.apply(this.ctx,viewport.transform);this.baseTransform=this.ctx.mozCurrentTransform.slice();if(this.imageLayer){this.imageLayer.beginLayout()}},executeOperatorList:function CanvasGraphics_executeOperatorList(operatorList,executionStartIdx,continueCallback,stepper){var argsArray=operatorList.argsArray;var fnArray=operatorList.fnArray;var i=executionStartIdx||0;var argsArrayLen=argsArray.length;if(argsArrayLen===i){return i}var chunkOperations=argsArrayLen-i>EXECUTION_STEPS&&typeof continueCallback==="function";var endTime=chunkOperations?Date.now()+EXECUTION_TIME:0;var steps=0;var commonObjs=this.commonObjs;var objs=this.objs;var fnId;while(true){if(stepper!==undefined&&i===stepper.nextBreakPoint){stepper.breakIt(i,continueCallback);return i}fnId=fnArray[i];if(fnId!==OPS.dependency){this[fnId].apply(this,argsArray[i])}else{var deps=argsArray[i];for(var n=0,nn=deps.length;n<nn;n++){var depObjId=deps[n];var common=depObjId[0]==="g"&&depObjId[1]==="_";var objsPool=common?commonObjs:objs;if(!objsPool.isResolved(depObjId)){objsPool.get(depObjId,continueCallback);return i}}}i++;if(i===argsArrayLen){return i}if(chunkOperations&&++steps>EXECUTION_STEPS){if(Date.now()>endTime){continueCallback();return i}steps=0}}},endDrawing:function CanvasGraphics_endDrawing(){if(this.current.activeSMask!==null){this.endSMaskGroup()}this.ctx.restore();if(this.transparentCanvas){this.ctx=this.compositeCtx;this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.drawImage(this.transparentCanvas,0,0);this.ctx.restore();this.transparentCanvas=null}this.cachedCanvases.clear();WebGLUtils.clear();if(this.imageLayer){this.imageLayer.endLayout()}},setLineWidth:function CanvasGraphics_setLineWidth(width){this.current.lineWidth=width;this.ctx.lineWidth=width},setLineCap:function CanvasGraphics_setLineCap(style){this.ctx.lineCap=LINE_CAP_STYLES[style]},setLineJoin:function CanvasGraphics_setLineJoin(style){this.ctx.lineJoin=LINE_JOIN_STYLES[style]},setMiterLimit:function CanvasGraphics_setMiterLimit(limit){this.ctx.miterLimit=limit},setDash:function CanvasGraphics_setDash(dashArray,dashPhase){var ctx=this.ctx;if(ctx.setLineDash!==undefined){ctx.setLineDash(dashArray);ctx.lineDashOffset=dashPhase}},setRenderingIntent:function CanvasGraphics_setRenderingIntent(intent){},setFlatness:function CanvasGraphics_setFlatness(flatness){},setGState:function CanvasGraphics_setGState(states){for(var i=0,ii=states.length;i<ii;i++){var state=states[i];var key=state[0];var value=state[1];switch(key){case"LW":this.setLineWidth(value);break;case"LC":this.setLineCap(value);break;case"LJ":this.setLineJoin(value);break;case"ML":this.setMiterLimit(value);break;case"D":this.setDash(value[0],value[1]);break;case"RI":this.setRenderingIntent(value);break;case"FL":this.setFlatness(value);break;case"Font":this.setFont(value[0],value[1]);break;case"CA":this.current.strokeAlpha=state[1];break;case"ca":this.current.fillAlpha=state[1];this.ctx.globalAlpha=state[1];break;case"BM":if(value&&value.name&&value.name!=="Normal"){var mode=value.name.replace(/([A-Z])/g,function(c){return"-"+c.toLowerCase()}).substring(1);this.ctx.globalCompositeOperation=mode;if(this.ctx.globalCompositeOperation!==mode){warn('globalCompositeOperation "'+mode+'" is not supported')}}else{this.ctx.globalCompositeOperation="source-over"}break;case"SMask":if(this.current.activeSMask){if(this.stateStack.length>0&&this.stateStack[this.stateStack.length-1].activeSMask===this.current.activeSMask){this.suspendSMaskGroup()}else{this.endSMaskGroup()}}this.current.activeSMask=value?this.tempSMask:null;if(this.current.activeSMask){this.beginSMaskGroup()}this.tempSMask=null;break}}},beginSMaskGroup:function CanvasGraphics_beginSMaskGroup(){var activeSMask=this.current.activeSMask;var drawnWidth=activeSMask.canvas.width;var drawnHeight=activeSMask.canvas.height;var cacheId="smaskGroupAt"+this.groupLevel;var scratchCanvas=this.cachedCanvases.getCanvas(cacheId,drawnWidth,drawnHeight,true);var currentCtx=this.ctx;var currentTransform=currentCtx.mozCurrentTransform;this.ctx.save();var groupCtx=scratchCanvas.context;groupCtx.scale(1/activeSMask.scaleX,1/activeSMask.scaleY);groupCtx.translate(-activeSMask.offsetX,-activeSMask.offsetY);groupCtx.transform.apply(groupCtx,currentTransform);activeSMask.startTransformInverse=groupCtx.mozCurrentTransformInverse;copyCtxState(currentCtx,groupCtx);this.ctx=groupCtx;this.setGState([["BM","Normal"],["ca",1],["CA",1]]);this.groupStack.push(currentCtx);this.groupLevel++},suspendSMaskGroup:function CanvasGraphics_endSMaskGroup(){var groupCtx=this.ctx;this.groupLevel--;this.ctx=this.groupStack.pop();composeSMask(this.ctx,this.current.activeSMask,groupCtx);this.ctx.restore();this.ctx.save();copyCtxState(groupCtx,this.ctx);this.current.resumeSMaskCtx=groupCtx;var deltaTransform=Util.transform(this.current.activeSMask.startTransformInverse,groupCtx.mozCurrentTransform);this.ctx.transform.apply(this.ctx,deltaTransform);groupCtx.save();groupCtx.setTransform(1,0,0,1,0,0);groupCtx.clearRect(0,0,groupCtx.canvas.width,groupCtx.canvas.height);groupCtx.restore()},resumeSMaskGroup:function CanvasGraphics_endSMaskGroup(){var groupCtx=this.current.resumeSMaskCtx;var currentCtx=this.ctx;this.ctx=groupCtx;this.groupStack.push(currentCtx);this.groupLevel++},endSMaskGroup:function CanvasGraphics_endSMaskGroup(){var groupCtx=this.ctx;this.groupLevel--;this.ctx=this.groupStack.pop();composeSMask(this.ctx,this.current.activeSMask,groupCtx);this.ctx.restore();copyCtxState(groupCtx,this.ctx);var deltaTransform=Util.transform(this.current.activeSMask.startTransformInverse,groupCtx.mozCurrentTransform);this.ctx.transform.apply(this.ctx,deltaTransform)},save:function CanvasGraphics_save(){this.ctx.save();var old=this.current;this.stateStack.push(old);this.current=old.clone();this.current.resumeSMaskCtx=null},restore:function CanvasGraphics_restore(){if(this.current.resumeSMaskCtx){this.resumeSMaskGroup()}if(this.current.activeSMask!==null&&(this.stateStack.length===0||this.stateStack[this.stateStack.length-1].activeSMask!==this.current.activeSMask)){this.endSMaskGroup()}if(this.stateStack.length!==0){this.current=this.stateStack.pop();this.ctx.restore();this.pendingClip=null;this.cachedGetSinglePixelWidth=null}},transform:function CanvasGraphics_transform(a,b,c,d,e,f){this.ctx.transform(a,b,c,d,e,f);this.cachedGetSinglePixelWidth=null},constructPath:function CanvasGraphics_constructPath(ops,args){var ctx=this.ctx;var current=this.current;var x=current.x,y=current.y;for(var i=0,j=0,ii=ops.length;i<ii;i++){switch(ops[i]|0){case OPS.rectangle:x=args[j++];y=args[j++];var width=args[j++];var height=args[j++];if(width===0){width=this.getSinglePixelWidth()}if(height===0){height=this.getSinglePixelWidth()}var xw=x+width;var yh=y+height;this.ctx.moveTo(x,y);this.ctx.lineTo(xw,y);this.ctx.lineTo(xw,yh);this.ctx.lineTo(x,yh);this.ctx.lineTo(x,y);this.ctx.closePath();break;case OPS.moveTo:x=args[j++];y=args[j++];ctx.moveTo(x,y);break;case OPS.lineTo:x=args[j++];y=args[j++];ctx.lineTo(x,y);break;case OPS.curveTo:x=args[j+4];y=args[j+5];ctx.bezierCurveTo(args[j],args[j+1],args[j+2],args[j+3],x,y);j+=6;break;case OPS.curveTo2:ctx.bezierCurveTo(x,y,args[j],args[j+1],args[j+2],args[j+3]);x=args[j+2];y=args[j+3];j+=4;break;case OPS.curveTo3:x=args[j+2];y=args[j+3];ctx.bezierCurveTo(args[j],args[j+1],x,y,x,y);j+=4;break;case OPS.closePath:ctx.closePath();break}}current.setCurrentPoint(x,y)},closePath:function CanvasGraphics_closePath(){this.ctx.closePath()},stroke:function CanvasGraphics_stroke(consumePath){consumePath=typeof consumePath!=="undefined"?consumePath:true;var ctx=this.ctx;var strokeColor=this.current.strokeColor;ctx.lineWidth=Math.max(this.getSinglePixelWidth()*MIN_WIDTH_FACTOR,this.current.lineWidth);ctx.globalAlpha=this.current.strokeAlpha;if(strokeColor&&strokeColor.hasOwnProperty("type")&&strokeColor.type==="Pattern"){ctx.save();ctx.strokeStyle=strokeColor.getPattern(ctx,this);ctx.stroke();ctx.restore()}else{ctx.stroke()}if(consumePath){this.consumePath()}ctx.globalAlpha=this.current.fillAlpha},closeStroke:function CanvasGraphics_closeStroke(){this.closePath();this.stroke()},fill:function CanvasGraphics_fill(consumePath){consumePath=typeof consumePath!=="undefined"?consumePath:true;var ctx=this.ctx;var fillColor=this.current.fillColor;var isPatternFill=this.current.patternFill;var needRestore=false;if(isPatternFill){ctx.save();if(this.baseTransform){ctx.setTransform.apply(ctx,this.baseTransform)}ctx.fillStyle=fillColor.getPattern(ctx,this);needRestore=true}if(this.pendingEOFill){if(ctx.mozFillRule!==undefined){ctx.mozFillRule="evenodd";ctx.fill();ctx.mozFillRule="nonzero"}else{ctx.fill("evenodd")}this.pendingEOFill=false}else{ctx.fill()}if(needRestore){ctx.restore()}if(consumePath){this.consumePath()}},eoFill:function CanvasGraphics_eoFill(){this.pendingEOFill=true;this.fill()},fillStroke:function CanvasGraphics_fillStroke(){this.fill(false);this.stroke(false);this.consumePath()},eoFillStroke:function CanvasGraphics_eoFillStroke(){this.pendingEOFill=true;this.fillStroke()},closeFillStroke:function CanvasGraphics_closeFillStroke(){this.closePath();this.fillStroke()},closeEOFillStroke:function CanvasGraphics_closeEOFillStroke(){this.pendingEOFill=true;this.closePath();this.fillStroke()},endPath:function CanvasGraphics_endPath(){this.consumePath()},clip:function CanvasGraphics_clip(){this.pendingClip=NORMAL_CLIP},eoClip:function CanvasGraphics_eoClip(){this.pendingClip=EO_CLIP},beginText:function CanvasGraphics_beginText(){this.current.textMatrix=IDENTITY_MATRIX;this.current.textMatrixScale=1;this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0},endText:function CanvasGraphics_endText(){var paths=this.pendingTextPaths;var ctx=this.ctx;if(paths===undefined){ctx.beginPath();return}ctx.save();ctx.beginPath();for(var i=0;i<paths.length;i++){var path=paths[i];ctx.setTransform.apply(ctx,path.transform);ctx.translate(path.x,path.y);path.addToPath(ctx,path.fontSize)}ctx.restore();ctx.clip();ctx.beginPath();delete this.pendingTextPaths},setCharSpacing:function CanvasGraphics_setCharSpacing(spacing){this.current.charSpacing=spacing},setWordSpacing:function CanvasGraphics_setWordSpacing(spacing){this.current.wordSpacing=spacing},setHScale:function CanvasGraphics_setHScale(scale){this.current.textHScale=scale/100},setLeading:function CanvasGraphics_setLeading(leading){this.current.leading=-leading},setFont:function CanvasGraphics_setFont(fontRefName,size){var fontObj=this.commonObjs.get(fontRefName);var current=this.current;if(!fontObj){error("Can't find font for "+fontRefName)}current.fontMatrix=fontObj.fontMatrix?fontObj.fontMatrix:FONT_IDENTITY_MATRIX;if(current.fontMatrix[0]===0||current.fontMatrix[3]===0){warn("Invalid font matrix for font "+fontRefName)}if(size<0){size=-size;current.fontDirection=-1}else{current.fontDirection=1}this.current.font=fontObj;this.current.fontSize=size;if(fontObj.isType3Font){return}var name=fontObj.loadedName||"sans-serif";
6var bold=fontObj.black?fontObj.bold?"900":"bold":fontObj.bold?"bold":"normal";var italic=fontObj.italic?"italic":"normal";var typeface='"'+name+'", '+fontObj.fallbackName;var browserFontSize=size<MIN_FONT_SIZE?MIN_FONT_SIZE:size>MAX_FONT_SIZE?MAX_FONT_SIZE:size;this.current.fontSizeScale=size/browserFontSize;var rule=italic+" "+bold+" "+browserFontSize+"px "+typeface;this.ctx.font=rule},setTextRenderingMode:function CanvasGraphics_setTextRenderingMode(mode){this.current.textRenderingMode=mode},setTextRise:function CanvasGraphics_setTextRise(rise){this.current.textRise=rise},moveText:function CanvasGraphics_moveText(x,y){this.current.x=this.current.lineX+=x;this.current.y=this.current.lineY+=y},setLeadingMoveText:function CanvasGraphics_setLeadingMoveText(x,y){this.setLeading(-y);this.moveText(x,y)},setTextMatrix:function CanvasGraphics_setTextMatrix(a,b,c,d,e,f){this.current.textMatrix=[a,b,c,d,e,f];this.current.textMatrixScale=Math.sqrt(a*a+b*b);this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0},nextLine:function CanvasGraphics_nextLine(){this.moveText(0,this.current.leading)},paintChar:function CanvasGraphics_paintChar(character,x,y){var ctx=this.ctx;var current=this.current;var font=current.font;var textRenderingMode=current.textRenderingMode;var fontSize=current.fontSize/current.fontSizeScale;var fillStrokeMode=textRenderingMode&TextRenderingMode.FILL_STROKE_MASK;var isAddToPathSet=!!(textRenderingMode&TextRenderingMode.ADD_TO_PATH_FLAG);var addToPath;if(font.disableFontFace||isAddToPathSet){addToPath=font.getPathGenerator(this.commonObjs,character)}if(font.disableFontFace){ctx.save();ctx.translate(x,y);ctx.beginPath();addToPath(ctx,fontSize);if(fillStrokeMode===TextRenderingMode.FILL||fillStrokeMode===TextRenderingMode.FILL_STROKE){ctx.fill()}if(fillStrokeMode===TextRenderingMode.STROKE||fillStrokeMode===TextRenderingMode.FILL_STROKE){ctx.stroke()}ctx.restore()}else{if(fillStrokeMode===TextRenderingMode.FILL||fillStrokeMode===TextRenderingMode.FILL_STROKE){ctx.fillText(character,x,y)}if(fillStrokeMode===TextRenderingMode.STROKE||fillStrokeMode===TextRenderingMode.FILL_STROKE){ctx.strokeText(character,x,y)}}if(isAddToPathSet){var paths=this.pendingTextPaths||(this.pendingTextPaths=[]);paths.push({transform:ctx.mozCurrentTransform,x:x,y:y,fontSize:fontSize,addToPath:addToPath})}},get isFontSubpixelAAEnabled(){var ctx=document.createElement("canvas").getContext("2d");ctx.scale(1.5,1);ctx.fillText("I",0,10);var data=ctx.getImageData(0,0,10,10).data;var enabled=false;for(var i=3;i<data.length;i+=4){if(data[i]>0&&data[i]<255){enabled=true;break}}return shadow(this,"isFontSubpixelAAEnabled",enabled)},showText:function CanvasGraphics_showText(glyphs){var current=this.current;var font=current.font;if(font.isType3Font){return this.showType3Text(glyphs)}var fontSize=current.fontSize;if(fontSize===0){return}var ctx=this.ctx;var fontSizeScale=current.fontSizeScale;var charSpacing=current.charSpacing;var wordSpacing=current.wordSpacing;var fontDirection=current.fontDirection;var textHScale=current.textHScale*fontDirection;var glyphsLength=glyphs.length;var vertical=font.vertical;var spacingDir=vertical?1:-1;var defaultVMetrics=font.defaultVMetrics;var widthAdvanceScale=fontSize*current.fontMatrix[0];var simpleFillText=current.textRenderingMode===TextRenderingMode.FILL&&!font.disableFontFace;ctx.save();ctx.transform.apply(ctx,current.textMatrix);ctx.translate(current.x,current.y+current.textRise);if(current.patternFill){ctx.fillStyle=current.fillColor.getPattern(ctx,this)}if(fontDirection>0){ctx.scale(textHScale,-1)}else{ctx.scale(textHScale,1)}var lineWidth=current.lineWidth;var scale=current.textMatrixScale;if(scale===0||lineWidth===0){var fillStrokeMode=current.textRenderingMode&TextRenderingMode.FILL_STROKE_MASK;if(fillStrokeMode===TextRenderingMode.STROKE||fillStrokeMode===TextRenderingMode.FILL_STROKE){this.cachedGetSinglePixelWidth=null;lineWidth=this.getSinglePixelWidth()*MIN_WIDTH_FACTOR}}else{lineWidth/=scale}if(fontSizeScale!==1){ctx.scale(fontSizeScale,fontSizeScale);lineWidth/=fontSizeScale}ctx.lineWidth=lineWidth;var x=0,i;for(i=0;i<glyphsLength;++i){var glyph=glyphs[i];if(isNum(glyph)){x+=spacingDir*glyph*fontSize/1e3;continue}var restoreNeeded=false;var spacing=(glyph.isSpace?wordSpacing:0)+charSpacing;var character=glyph.fontChar;var accent=glyph.accent;var scaledX,scaledY,scaledAccentX,scaledAccentY;var width=glyph.width;if(vertical){var vmetric,vx,vy;vmetric=glyph.vmetric||defaultVMetrics;vx=glyph.vmetric?vmetric[1]:width*.5;vx=-vx*widthAdvanceScale;vy=vmetric[2]*widthAdvanceScale;width=vmetric?-vmetric[0]:width;scaledX=vx/fontSizeScale;scaledY=(x+vy)/fontSizeScale}else{scaledX=x/fontSizeScale;scaledY=0}if(font.remeasure&&width>0){var measuredWidth=ctx.measureText(character).width*1e3/fontSize*fontSizeScale;if(width<measuredWidth&&this.isFontSubpixelAAEnabled){var characterScaleX=width/measuredWidth;restoreNeeded=true;ctx.save();ctx.scale(characterScaleX,1);scaledX/=characterScaleX}else if(width!==measuredWidth){scaledX+=(width-measuredWidth)/2e3*fontSize/fontSizeScale}}if(glyph.isInFont||font.missingFile){if(simpleFillText&&!accent){ctx.fillText(character,scaledX,scaledY)}else{this.paintChar(character,scaledX,scaledY);if(accent){scaledAccentX=scaledX+accent.offset.x/fontSizeScale;scaledAccentY=scaledY-accent.offset.y/fontSizeScale;this.paintChar(accent.fontChar,scaledAccentX,scaledAccentY)}}}var charWidth=width*widthAdvanceScale+spacing*fontDirection;x+=charWidth;if(restoreNeeded){ctx.restore()}}if(vertical){current.y-=x*textHScale}else{current.x+=x*textHScale}ctx.restore()},showType3Text:function CanvasGraphics_showType3Text(glyphs){var ctx=this.ctx;var current=this.current;var font=current.font;var fontSize=current.fontSize;var fontDirection=current.fontDirection;var spacingDir=font.vertical?1:-1;var charSpacing=current.charSpacing;var wordSpacing=current.wordSpacing;var textHScale=current.textHScale*fontDirection;var fontMatrix=current.fontMatrix||FONT_IDENTITY_MATRIX;var glyphsLength=glyphs.length;var isTextInvisible=current.textRenderingMode===TextRenderingMode.INVISIBLE;var i,glyph,width,spacingLength;if(isTextInvisible||fontSize===0){return}this.cachedGetSinglePixelWidth=null;ctx.save();ctx.transform.apply(ctx,current.textMatrix);ctx.translate(current.x,current.y);ctx.scale(textHScale,fontDirection);for(i=0;i<glyphsLength;++i){glyph=glyphs[i];if(isNum(glyph)){spacingLength=spacingDir*glyph*fontSize/1e3;this.ctx.translate(spacingLength,0);current.x+=spacingLength*textHScale;continue}var spacing=(glyph.isSpace?wordSpacing:0)+charSpacing;var operatorList=font.charProcOperatorList[glyph.operatorListId];if(!operatorList){warn('Type3 character "'+glyph.operatorListId+'" is not available');continue}this.processingType3=glyph;this.save();ctx.scale(fontSize,fontSize);ctx.transform.apply(ctx,fontMatrix);this.executeOperatorList(operatorList);this.restore();var transformed=Util.applyTransform([glyph.width,0],fontMatrix);width=transformed[0]*fontSize+spacing;ctx.translate(width,0);current.x+=width*textHScale}ctx.restore();this.processingType3=null},setCharWidth:function CanvasGraphics_setCharWidth(xWidth,yWidth){},setCharWidthAndBounds:function CanvasGraphics_setCharWidthAndBounds(xWidth,yWidth,llx,lly,urx,ury){this.ctx.rect(llx,lly,urx-llx,ury-lly);this.clip();this.endPath()},getColorN_Pattern:function CanvasGraphics_getColorN_Pattern(IR){var pattern;if(IR[0]==="TilingPattern"){var color=IR[1];var baseTransform=this.baseTransform||this.ctx.mozCurrentTransform.slice();var self=this;var canvasGraphicsFactory={createCanvasGraphics:function(ctx){return new CanvasGraphics(ctx,self.commonObjs,self.objs)}};pattern=new TilingPattern(IR,color,this.ctx,canvasGraphicsFactory,baseTransform)}else{pattern=getShadingPatternFromIR(IR)}return pattern},setStrokeColorN:function CanvasGraphics_setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)},setFillColorN:function CanvasGraphics_setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments);this.current.patternFill=true},setStrokeRGBColor:function CanvasGraphics_setStrokeRGBColor(r,g,b){var color=Util.makeCssRgb(r,g,b);this.ctx.strokeStyle=color;this.current.strokeColor=color},setFillRGBColor:function CanvasGraphics_setFillRGBColor(r,g,b){var color=Util.makeCssRgb(r,g,b);this.ctx.fillStyle=color;this.current.fillColor=color;this.current.patternFill=false},shadingFill:function CanvasGraphics_shadingFill(patternIR){var ctx=this.ctx;this.save();var pattern=getShadingPatternFromIR(patternIR);ctx.fillStyle=pattern.getPattern(ctx,this,true);var inv=ctx.mozCurrentTransformInverse;if(inv){var canvas=ctx.canvas;var width=canvas.width;var height=canvas.height;var bl=Util.applyTransform([0,0],inv);var br=Util.applyTransform([0,height],inv);var ul=Util.applyTransform([width,0],inv);var ur=Util.applyTransform([width,height],inv);var x0=Math.min(bl[0],br[0],ul[0],ur[0]);var y0=Math.min(bl[1],br[1],ul[1],ur[1]);var x1=Math.max(bl[0],br[0],ul[0],ur[0]);var y1=Math.max(bl[1],br[1],ul[1],ur[1]);this.ctx.fillRect(x0,y0,x1-x0,y1-y0)}else{this.ctx.fillRect(-1e10,-1e10,2e10,2e10)}this.restore()},beginInlineImage:function CanvasGraphics_beginInlineImage(){error("Should not call beginInlineImage")},beginImageData:function CanvasGraphics_beginImageData(){error("Should not call beginImageData")},paintFormXObjectBegin:function CanvasGraphics_paintFormXObjectBegin(matrix,bbox){this.save();this.baseTransformStack.push(this.baseTransform);if(isArray(matrix)&&6===matrix.length){this.transform.apply(this,matrix)}this.baseTransform=this.ctx.mozCurrentTransform;if(isArray(bbox)&&4===bbox.length){var width=bbox[2]-bbox[0];var height=bbox[3]-bbox[1];this.ctx.rect(bbox[0],bbox[1],width,height);this.clip();this.endPath()}},paintFormXObjectEnd:function CanvasGraphics_paintFormXObjectEnd(){this.restore();this.baseTransform=this.baseTransformStack.pop()},beginGroup:function CanvasGraphics_beginGroup(group){this.save();var currentCtx=this.ctx;if(!group.isolated){info("TODO: Support non-isolated groups.")}if(group.knockout){warn("Knockout groups not supported.")}var currentTransform=currentCtx.mozCurrentTransform;if(group.matrix){currentCtx.transform.apply(currentCtx,group.matrix)}assert(group.bbox,"Bounding box is required.");var bounds=Util.getAxialAlignedBoundingBox(group.bbox,currentCtx.mozCurrentTransform);var canvasBounds=[0,0,currentCtx.canvas.width,currentCtx.canvas.height];bounds=Util.intersect(bounds,canvasBounds)||[0,0,0,0];var offsetX=Math.floor(bounds[0]);var offsetY=Math.floor(bounds[1]);var drawnWidth=Math.max(Math.ceil(bounds[2])-offsetX,1);var drawnHeight=Math.max(Math.ceil(bounds[3])-offsetY,1);var scaleX=1,scaleY=1;if(drawnWidth>MAX_GROUP_SIZE){scaleX=drawnWidth/MAX_GROUP_SIZE;drawnWidth=MAX_GROUP_SIZE}if(drawnHeight>MAX_GROUP_SIZE){scaleY=drawnHeight/MAX_GROUP_SIZE;drawnHeight=MAX_GROUP_SIZE}var cacheId="groupAt"+this.groupLevel;if(group.smask){cacheId+="_smask_"+this.smaskCounter++%2}var scratchCanvas=this.cachedCanvases.getCanvas(cacheId,drawnWidth,drawnHeight,true);var groupCtx=scratchCanvas.context;groupCtx.scale(1/scaleX,1/scaleY);groupCtx.translate(-offsetX,-offsetY);groupCtx.transform.apply(groupCtx,currentTransform);if(group.smask){this.smaskStack.push({canvas:scratchCanvas.canvas,context:groupCtx,offsetX:offsetX,offsetY:offsetY,scaleX:scaleX,scaleY:scaleY,subtype:group.smask.subtype,backdrop:group.smask.backdrop,transferMap:group.smask.transferMap||null,startTransformInverse:null})}else{currentCtx.setTransform(1,0,0,1,0,0);currentCtx.translate(offsetX,offsetY);currentCtx.scale(scaleX,scaleY)}copyCtxState(currentCtx,groupCtx);this.ctx=groupCtx;this.setGState([["BM","Normal"],["ca",1],["CA",1]]);this.groupStack.push(currentCtx);this.groupLevel++;this.current.activeSMask=null},endGroup:function CanvasGraphics_endGroup(group){this.groupLevel--;var groupCtx=this.ctx;this.ctx=this.groupStack.pop();if(this.ctx.imageSmoothingEnabled!==undefined){this.ctx.imageSmoothingEnabled=false}else{this.ctx.mozImageSmoothingEnabled=false}if(group.smask){this.tempSMask=this.smaskStack.pop()}else{this.ctx.drawImage(groupCtx.canvas,0,0)}this.restore()},beginAnnotations:function CanvasGraphics_beginAnnotations(){this.save();this.current=new CanvasExtraState;if(this.baseTransform){this.ctx.setTransform.apply(this.ctx,this.baseTransform)}},endAnnotations:function CanvasGraphics_endAnnotations(){this.restore()},beginAnnotation:function CanvasGraphics_beginAnnotation(rect,transform,matrix){this.save();if(isArray(rect)&&4===rect.length){var width=rect[2]-rect[0];var height=rect[3]-rect[1];this.ctx.rect(rect[0],rect[1],width,height);this.clip();this.endPath()}this.transform.apply(this,transform);this.transform.apply(this,matrix)},endAnnotation:function CanvasGraphics_endAnnotation(){this.restore()},paintJpegXObject:function CanvasGraphics_paintJpegXObject(objId,w,h){var domImage=this.objs.get(objId);if(!domImage){warn("Dependent image isn't ready yet");return}this.save();var ctx=this.ctx;ctx.scale(1/w,-1/h);ctx.drawImage(domImage,0,0,domImage.width,domImage.height,0,-h,w,h);if(this.imageLayer){var currentTransform=ctx.mozCurrentTransformInverse;var position=this.getCanvasPosition(0,0);this.imageLayer.appendImage({objId:objId,left:position[0],top:position[1],width:w/currentTransform[0],height:h/currentTransform[3]})}this.restore()},paintImageMaskXObject:function CanvasGraphics_paintImageMaskXObject(img){var ctx=this.ctx;var width=img.width,height=img.height;var fillColor=this.current.fillColor;var isPatternFill=this.current.patternFill;var glyph=this.processingType3;if(COMPILE_TYPE3_GLYPHS&&glyph&&glyph.compiled===undefined){if(width<=MAX_SIZE_TO_COMPILE&&height<=MAX_SIZE_TO_COMPILE){glyph.compiled=compileType3Glyph({data:img.data,width:width,height:height})}else{glyph.compiled=null}}if(glyph&&glyph.compiled){glyph.compiled(ctx);return}var maskCanvas=this.cachedCanvases.getCanvas("maskCanvas",width,height);var maskCtx=maskCanvas.context;maskCtx.save();putBinaryImageMask(maskCtx,img);maskCtx.globalCompositeOperation="source-in";maskCtx.fillStyle=isPatternFill?fillColor.getPattern(maskCtx,this):fillColor;maskCtx.fillRect(0,0,width,height);maskCtx.restore();this.paintInlineImageXObject(maskCanvas.canvas)},paintImageMaskXObjectRepeat:function CanvasGraphics_paintImageMaskXObjectRepeat(imgData,scaleX,scaleY,positions){var width=imgData.width;var height=imgData.height;var fillColor=this.current.fillColor;var isPatternFill=this.current.patternFill;var maskCanvas=this.cachedCanvases.getCanvas("maskCanvas",width,height);var maskCtx=maskCanvas.context;maskCtx.save();putBinaryImageMask(maskCtx,imgData);maskCtx.globalCompositeOperation="source-in";maskCtx.fillStyle=isPatternFill?fillColor.getPattern(maskCtx,this):fillColor;maskCtx.fillRect(0,0,width,height);maskCtx.restore();var ctx=this.ctx;for(var i=0,ii=positions.length;i<ii;i+=2){ctx.save();ctx.transform(scaleX,0,0,scaleY,positions[i],positions[i+1]);ctx.scale(1,-1);ctx.drawImage(maskCanvas.canvas,0,0,width,height,0,-1,1,1);ctx.restore()}},paintImageMaskXObjectGroup:function CanvasGraphics_paintImageMaskXObjectGroup(images){var ctx=this.ctx;var fillColor=this.current.fillColor;var isPatternFill=this.current.patternFill;for(var i=0,ii=images.length;i<ii;i++){var image=images[i];var width=image.width,height=image.height;var maskCanvas=this.cachedCanvases.getCanvas("maskCanvas",width,height);var maskCtx=maskCanvas.context;maskCtx.save();putBinaryImageMask(maskCtx,image);maskCtx.globalCompositeOperation="source-in";maskCtx.fillStyle=isPatternFill?fillColor.getPattern(maskCtx,this):fillColor;maskCtx.fillRect(0,0,width,height);maskCtx.restore();ctx.save();ctx.transform.apply(ctx,image.transform);ctx.scale(1,-1);ctx.drawImage(maskCanvas.canvas,0,0,width,height,0,-1,1,1);ctx.restore()}},paintImageXObject:function CanvasGraphics_paintImageXObject(objId){var imgData=this.objs.get(objId);if(!imgData){warn("Dependent image isn't ready yet");return}this.paintInlineImageXObject(imgData)},paintImageXObjectRepeat:function CanvasGraphics_paintImageXObjectRepeat(objId,scaleX,scaleY,positions){var imgData=this.objs.get(objId);if(!imgData){warn("Dependent image isn't ready yet");return}var width=imgData.width;var height=imgData.height;var map=[];for(var i=0,ii=positions.length;i<ii;i+=2){map.push({transform:[scaleX,0,0,scaleY,positions[i],positions[i+1]],x:0,y:0,w:width,h:height})}this.paintInlineImageXObjectGroup(imgData,map)},paintInlineImageXObject:function CanvasGraphics_paintInlineImageXObject(imgData){var width=imgData.width;var height=imgData.height;var ctx=this.ctx;this.save();ctx.scale(1/width,-1/height);var currentTransform=ctx.mozCurrentTransformInverse;var a=currentTransform[0],b=currentTransform[1];var widthScale=Math.max(Math.sqrt(a*a+b*b),1);var c=currentTransform[2],d=currentTransform[3];var heightScale=Math.max(Math.sqrt(c*c+d*d),1);var imgToPaint,tmpCanvas;if(imgData instanceof HTMLElement||!imgData.data){imgToPaint=imgData}else{tmpCanvas=this.cachedCanvases.getCanvas("inlineImage",width,height);var tmpCtx=tmpCanvas.context;putBinaryImageData(tmpCtx,imgData);imgToPaint=tmpCanvas.canvas}var paintWidth=width,paintHeight=height;var tmpCanvasId="prescale1";while(widthScale>2&&paintWidth>1||heightScale>2&&paintHeight>1){var newWidth=paintWidth,newHeight=paintHeight;if(widthScale>2&&paintWidth>1){newWidth=Math.ceil(paintWidth/2);widthScale/=paintWidth/newWidth}if(heightScale>2&&paintHeight>1){newHeight=Math.ceil(paintHeight/2);heightScale/=paintHeight/newHeight}tmpCanvas=this.cachedCanvases.getCanvas(tmpCanvasId,newWidth,newHeight);tmpCtx=tmpCanvas.context;tmpCtx.clearRect(0,0,newWidth,newHeight);tmpCtx.drawImage(imgToPaint,0,0,paintWidth,paintHeight,0,0,newWidth,newHeight);imgToPaint=tmpCanvas.canvas;paintWidth=newWidth;paintHeight=newHeight;tmpCanvasId=tmpCanvasId==="prescale1"?"prescale2":"prescale1"}ctx.drawImage(imgToPaint,0,0,paintWidth,paintHeight,0,-height,width,height);if(this.imageLayer){var position=this.getCanvasPosition(0,-height);this.imageLayer.appendImage({imgData:imgData,left:position[0],top:position[1],width:width/currentTransform[0],height:height/currentTransform[3]})}this.restore()},paintInlineImageXObjectGroup:function CanvasGraphics_paintInlineImageXObjectGroup(imgData,map){var ctx=this.ctx;var w=imgData.width;var h=imgData.height;var tmpCanvas=this.cachedCanvases.getCanvas("inlineImage",w,h);var tmpCtx=tmpCanvas.context;putBinaryImageData(tmpCtx,imgData);for(var i=0,ii=map.length;i<ii;i++){var entry=map[i];ctx.save();ctx.transform.apply(ctx,entry.transform);ctx.scale(1,-1);ctx.drawImage(tmpCanvas.canvas,entry.x,entry.y,entry.w,entry.h,0,-1,1,1);if(this.imageLayer){var position=this.getCanvasPosition(entry.x,entry.y);this.imageLayer.appendImage({imgData:imgData,left:position[0],top:position[1],width:w,height:h})}ctx.restore()}},paintSolidColorImageMask:function CanvasGraphics_paintSolidColorImageMask(){this.ctx.fillRect(0,0,1,1)},paintXObject:function CanvasGraphics_paintXObject(){warn("Unsupported 'paintXObject' command.")},markPoint:function CanvasGraphics_markPoint(tag){},markPointProps:function CanvasGraphics_markPointProps(tag,properties){},beginMarkedContent:function CanvasGraphics_beginMarkedContent(tag){},beginMarkedContentProps:function CanvasGraphics_beginMarkedContentProps(tag,properties){},endMarkedContent:function CanvasGraphics_endMarkedContent(){},beginCompat:function CanvasGraphics_beginCompat(){},endCompat:function CanvasGraphics_endCompat(){},consumePath:function CanvasGraphics_consumePath(){var ctx=this.ctx;if(this.pendingClip){if(this.pendingClip===EO_CLIP){if(ctx.mozFillRule!==undefined){ctx.mozFillRule="evenodd";ctx.clip();ctx.mozFillRule="nonzero"}else{ctx.clip("evenodd")}}else{ctx.clip()}this.pendingClip=null}ctx.beginPath()},getSinglePixelWidth:function CanvasGraphics_getSinglePixelWidth(scale){if(this.cachedGetSinglePixelWidth===null){this.ctx.save();var inverse=this.ctx.mozCurrentTransformInverse;this.ctx.restore();this.cachedGetSinglePixelWidth=Math.sqrt(Math.max(inverse[0]*inverse[0]+inverse[1]*inverse[1],inverse[2]*inverse[2]+inverse[3]*inverse[3]))}return this.cachedGetSinglePixelWidth},getCanvasPosition:function CanvasGraphics_getCanvasPosition(x,y){var transform=this.ctx.mozCurrentTransform;return[transform[0]*x+transform[2]*y+transform[4],transform[1]*x+transform[3]*y+transform[5]]}};for(var op in OPS){CanvasGraphics.prototype[OPS[op]]=CanvasGraphics.prototype[op]}return CanvasGraphics}();exports.CanvasGraphics=CanvasGraphics;exports.createScratchCanvas=createScratchCanvas});(function(root,factory){{factory(root.pdfjsDisplayAPI={},root.pdfjsSharedUtil,root.pdfjsDisplayFontLoader,root.pdfjsDisplayCanvas,root.pdfjsDisplayMetadata,root.pdfjsDisplayDOMUtils)}})(this,function(exports,sharedUtil,displayFontLoader,displayCanvas,displayMetadata,displayDOMUtils,amdRequire){var InvalidPDFException=sharedUtil.InvalidPDFException;var MessageHandler=sharedUtil.MessageHandler;var MissingPDFException=sharedUtil.MissingPDFException;var PageViewport=sharedUtil.PageViewport;var PasswordResponses=sharedUtil.PasswordResponses;var PasswordException=sharedUtil.PasswordException;var StatTimer=sharedUtil.StatTimer;var UnexpectedResponseException=sharedUtil.UnexpectedResponseException;var UnknownErrorException=sharedUtil.UnknownErrorException;var Util=sharedUtil.Util;var createPromiseCapability=sharedUtil.createPromiseCapability;var error=sharedUtil.error;var deprecated=sharedUtil.deprecated;var getVerbosityLevel=sharedUtil.getVerbosityLevel;var info=sharedUtil.info;var isInt=sharedUtil.isInt;var isArray=sharedUtil.isArray;var isArrayBuffer=sharedUtil.isArrayBuffer;var isSameOrigin=sharedUtil.isSameOrigin;var loadJpegStream=sharedUtil.loadJpegStream;var stringToBytes=sharedUtil.stringToBytes;var globalScope=sharedUtil.globalScope;var warn=sharedUtil.warn;var FontFaceObject=displayFontLoader.FontFaceObject;var FontLoader=displayFontLoader.FontLoader;var CanvasGraphics=displayCanvas.CanvasGraphics;var createScratchCanvas=displayCanvas.createScratchCanvas;var Metadata=displayMetadata.Metadata;var getDefaultSetting=displayDOMUtils.getDefaultSetting;var DEFAULT_RANGE_CHUNK_SIZE=65536;var isWorkerDisabled=false;var workerSrc;var isPostMessageTransfersDisabled=false;var useRequireEnsure=false;if(typeof window==="undefined"){isWorkerDisabled=true;if(typeof require.ensure==="undefined"){require.ensure=require("node-ensure")}useRequireEnsure=true}if(typeof __webpack_require__!=="undefined"){useRequireEnsure=true}if(typeof requirejs!=="undefined"&&requirejs.toUrl){workerSrc=requirejs.toUrl("pdfjs-dist/build/pdf.worker.js")}var dynamicLoaderSupported=typeof requirejs!=="undefined"&&requirejs.load;var fakeWorkerFilesLoader=useRequireEnsure?function(callback){require.ensure([],function(){var worker=require("./pdf.worker.js");callback(worker.WorkerMessageHandler)})}:dynamicLoaderSupported?function(callback){requirejs(["pdfjs-dist/build/pdf.worker"],function(worker){callback(worker.WorkerMessageHandler)})}:null;function getDocument(src,pdfDataRangeTransport,passwordCallback,progressCallback){var task=new PDFDocumentLoadingTask;if(arguments.length>1){deprecated("getDocument is called with pdfDataRangeTransport, "+"passwordCallback or progressCallback argument")}if(pdfDataRangeTransport){if(!(pdfDataRangeTransport instanceof PDFDataRangeTransport)){pdfDataRangeTransport=Object.create(pdfDataRangeTransport);pdfDataRangeTransport.length=src.length;pdfDataRangeTransport.initialData=src.initialData;if(!pdfDataRangeTransport.abort){pdfDataRangeTransport.abort=function(){}}}src=Object.create(src);src.range=pdfDataRangeTransport}task.onPassword=passwordCallback||null;task.onProgress=progressCallback||null;var source;if(typeof src==="string"){source={url:src}}else if(isArrayBuffer(src)){source={data:src}}else if(src instanceof PDFDataRangeTransport){source={range:src}}else{if(typeof src!=="object"){error("Invalid parameter in getDocument, need either Uint8Array, "+"string or a parameter object")}if(!src.url&&!src.data&&!src.range){error("Invalid parameter object: need either .data, .range or .url")}source=src}var params={};var rangeTransport=null;var worker=null;for(var key in source){if(key==="url"&&typeof window!=="undefined"){params[key]=new URL(source[key],window.location).href;continue}else if(key==="range"){rangeTransport=source[key];continue}else if(key==="worker"){worker=source[key];continue}else if(key==="data"&&!(source[key]instanceof Uint8Array)){var pdfBytes=source[key];if(typeof pdfBytes==="string"){params[key]=stringToBytes(pdfBytes)}else if(typeof pdfBytes==="object"&&pdfBytes!==null&&!isNaN(pdfBytes.length)){params[key]=new Uint8Array(pdfBytes)}else if(isArrayBuffer(pdfBytes)){params[key]=new Uint8Array(pdfBytes)}else{error("Invalid PDF binary data: either typed array, string or "+"array-like object is expected in the data property.")}continue}params[key]=source[key]}params.rangeChunkSize=params.rangeChunkSize||DEFAULT_RANGE_CHUNK_SIZE;if(!worker){worker=new PDFWorker;task._worker=worker}var docId=task.docId;worker.promise.then(function(){if(task.destroyed){throw new Error("Loading aborted")}return _fetchDocument(worker,params,rangeTransport,docId).then(function(workerId){if(task.destroyed){throw new Error("Loading aborted")}var messageHandler=new MessageHandler(docId,workerId,worker.port);var transport=new WorkerTransport(messageHandler,task,rangeTransport);task._transport=transport;messageHandler.send("Ready",null)})}).catch(task._capability.reject);return task}function _fetchDocument(worker,source,pdfDataRangeTransport,docId){if(worker.destroyed){return Promise.reject(new Error("Worker was destroyed"))}source.disableAutoFetch=getDefaultSetting("disableAutoFetch");source.disableStream=getDefaultSetting("disableStream");source.chunkedViewerLoading=!!pdfDataRangeTransport;if(pdfDataRangeTransport){source.length=pdfDataRangeTransport.length;source.initialData=pdfDataRangeTransport.initialData}return worker.messageHandler.sendWithPromise("GetDocRequest",{docId:docId,source:source,disableRange:getDefaultSetting("disableRange"),maxImageSize:getDefaultSetting("maxImageSize"),cMapUrl:getDefaultSetting("cMapUrl"),cMapPacked:getDefaultSetting("cMapPacked"),disableFontFace:getDefaultSetting("disableFontFace"),disableCreateObjectURL:getDefaultSetting("disableCreateObjectURL"),postMessageTransfers:getDefaultSetting("postMessageTransfers")&&!isPostMessageTransfersDisabled}).then(function(workerId){if(worker.destroyed){throw new Error("Worker was destroyed")}return workerId})}var PDFDocumentLoadingTask=function PDFDocumentLoadingTaskClosure(){var nextDocumentId=0;function PDFDocumentLoadingTask(){this._capability=createPromiseCapability();this._transport=null;this._worker=null;this.docId="d"+nextDocumentId++;this.destroyed=false;this.onPassword=null;this.onProgress=null;this.onUnsupportedFeature=null}PDFDocumentLoadingTask.prototype={get promise(){return this._capability.promise},destroy:function(){this.destroyed=true;var transportDestroyed=!this._transport?Promise.resolve():this._transport.destroy();return transportDestroyed.then(function(){this._transport=null;if(this._worker){this._worker.destroy();this._worker=null}}.bind(this))},then:function PDFDocumentLoadingTask_then(onFulfilled,onRejected){return this.promise.then.apply(this.promise,arguments)}};return PDFDocumentLoadingTask}();var PDFDataRangeTransport=function pdfDataRangeTransportClosure(){function PDFDataRangeTransport(length,initialData){this.length=length;this.initialData=initialData;this._rangeListeners=[];this._progressListeners=[];this._progressiveReadListeners=[];this._readyCapability=createPromiseCapability()}PDFDataRangeTransport.prototype={addRangeListener:function PDFDataRangeTransport_addRangeListener(listener){this._rangeListeners.push(listener)},addProgressListener:function PDFDataRangeTransport_addProgressListener(listener){this._progressListeners.push(listener)},addProgressiveReadListener:function PDFDataRangeTransport_addProgressiveReadListener(listener){this._progressiveReadListeners.push(listener)},onDataRange:function PDFDataRangeTransport_onDataRange(begin,chunk){var listeners=this._rangeListeners;for(var i=0,n=listeners.length;i<n;++i){listeners[i](begin,chunk)}},onDataProgress:function PDFDataRangeTransport_onDataProgress(loaded){this._readyCapability.promise.then(function(){var listeners=this._progressListeners;for(var i=0,n=listeners.length;i<n;++i){listeners[i](loaded)}}.bind(this))},onDataProgressiveRead:function PDFDataRangeTransport_onDataProgress(chunk){this._readyCapability.promise.then(function(){var listeners=this._progressiveReadListeners;for(var i=0,n=listeners.length;i<n;++i){listeners[i](chunk)}}.bind(this))},transportReady:function PDFDataRangeTransport_transportReady(){this._readyCapability.resolve()},requestDataRange:function PDFDataRangeTransport_requestDataRange(begin,end){throw new Error("Abstract method PDFDataRangeTransport.requestDataRange")},abort:function PDFDataRangeTransport_abort(){}};return PDFDataRangeTransport}();var PDFDocumentProxy=function PDFDocumentProxyClosure(){function PDFDocumentProxy(pdfInfo,transport,loadingTask){this.pdfInfo=pdfInfo;this.transport=transport;this.loadingTask=loadingTask}PDFDocumentProxy.prototype={get numPages(){return this.pdfInfo.numPages},get fingerprint(){return this.pdfInfo.fingerprint},getPage:function PDFDocumentProxy_getPage(pageNumber){return this.transport.getPage(pageNumber)},getPageIndex:function PDFDocumentProxy_getPageIndex(ref){return this.transport.getPageIndex(ref)},getDestinations:function PDFDocumentProxy_getDestinations(){return this.transport.getDestinations()},getDestination:function PDFDocumentProxy_getDestination(id){return this.transport.getDestination(id)},getPageLabels:function PDFDocumentProxy_getPageLabels(){return this.transport.getPageLabels()},getAttachments:function PDFDocumentProxy_getAttachments(){return this.transport.getAttachments()},getJavaScript:function PDFDocumentProxy_getJavaScript(){return this.transport.getJavaScript()},getOutline:function PDFDocumentProxy_getOutline(){return this.transport.getOutline()},getMetadata:function PDFDocumentProxy_getMetadata(){return this.transport.getMetadata()},getData:function PDFDocumentProxy_getData(){return this.transport.getData()},getDownloadInfo:function PDFDocumentProxy_getDownloadInfo(){return this.transport.downloadInfoCapability.promise},getStats:function PDFDocumentProxy_getStats(){return this.transport.getStats()},cleanup:function PDFDocumentProxy_cleanup(){this.transport.startCleanup()},destroy:function PDFDocumentProxy_destroy(){return this.loadingTask.destroy()}};return PDFDocumentProxy}();var PDFPageProxy=function PDFPageProxyClosure(){function PDFPageProxy(pageIndex,pageInfo,transport){this.pageIndex=pageIndex;this.pageInfo=pageInfo;this.transport=transport;this.stats=new StatTimer;this.stats.enabled=getDefaultSetting("enableStats");this.commonObjs=transport.commonObjs;this.objs=new PDFObjects;this.cleanupAfterRender=false;this.pendingCleanup=false;this.intentStates=Object.create(null);this.destroyed=false}PDFPageProxy.prototype={get pageNumber(){return this.pageIndex+1},get rotate(){return this.pageInfo.rotate},get ref(){return this.pageInfo.ref},get view(){return this.pageInfo.view},getViewport:function PDFPageProxy_getViewport(scale,rotate){if(arguments.length<2){rotate=this.rotate}return new PageViewport(this.view,scale,rotate,0,0)},getAnnotations:function PDFPageProxy_getAnnotations(params){var intent=params&&params.intent||null;if(!this.annotationsPromise||this.annotationsIntent!==intent){this.annotationsPromise=this.transport.getAnnotations(this.pageIndex,intent);this.annotationsIntent=intent}return this.annotationsPromise},render:function PDFPageProxy_render(params){var stats=this.stats;stats.time("Overall");this.pendingCleanup=false;var renderingIntent=params.intent==="print"?"print":"display";var renderInteractiveForms=params.renderInteractiveForms===true?true:false;if(!this.intentStates[renderingIntent]){this.intentStates[renderingIntent]=Object.create(null)
7}var intentState=this.intentStates[renderingIntent];if(!intentState.displayReadyCapability){intentState.receivingOperatorList=true;intentState.displayReadyCapability=createPromiseCapability();intentState.operatorList={fnArray:[],argsArray:[],lastChunk:false};this.stats.time("Page Request");this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageNumber-1,intent:renderingIntent,renderInteractiveForms:renderInteractiveForms})}var internalRenderTask=new InternalRenderTask(complete,params,this.objs,this.commonObjs,intentState.operatorList,this.pageNumber);internalRenderTask.useRequestAnimationFrame=renderingIntent!=="print";if(!intentState.renderTasks){intentState.renderTasks=[]}intentState.renderTasks.push(internalRenderTask);var renderTask=internalRenderTask.task;if(params.continueCallback){deprecated("render is used with continueCallback parameter");renderTask.onContinue=params.continueCallback}var self=this;intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency){if(self.pendingCleanup){complete();return}stats.time("Rendering");internalRenderTask.initializeGraphics(transparency);internalRenderTask.operatorListChanged()},function pageDisplayReadPromiseError(reason){complete(reason)});function complete(error){var i=intentState.renderTasks.indexOf(internalRenderTask);if(i>=0){intentState.renderTasks.splice(i,1)}if(self.cleanupAfterRender){self.pendingCleanup=true}self._tryCleanup();if(error){internalRenderTask.capability.reject(error)}else{internalRenderTask.capability.resolve()}stats.timeEnd("Rendering");stats.timeEnd("Overall")}return renderTask},getOperatorList:function PDFPageProxy_getOperatorList(){function operatorListChanged(){if(intentState.operatorList.lastChunk){intentState.opListReadCapability.resolve(intentState.operatorList);var i=intentState.renderTasks.indexOf(opListTask);if(i>=0){intentState.renderTasks.splice(i,1)}}}var renderingIntent="oplist";if(!this.intentStates[renderingIntent]){this.intentStates[renderingIntent]=Object.create(null)}var intentState=this.intentStates[renderingIntent];var opListTask;if(!intentState.opListReadCapability){opListTask={};opListTask.operatorListChanged=operatorListChanged;intentState.receivingOperatorList=true;intentState.opListReadCapability=createPromiseCapability();intentState.renderTasks=[];intentState.renderTasks.push(opListTask);intentState.operatorList={fnArray:[],argsArray:[],lastChunk:false};this.transport.messageHandler.send("RenderPageRequest",{pageIndex:this.pageIndex,intent:renderingIntent})}return intentState.opListReadCapability.promise},getTextContent:function PDFPageProxy_getTextContent(params){return this.transport.messageHandler.sendWithPromise("GetTextContent",{pageIndex:this.pageNumber-1,normalizeWhitespace:params&&params.normalizeWhitespace===true?true:false,combineTextItems:params&&params.disableCombineTextItems===true?false:true})},_destroy:function PDFPageProxy_destroy(){this.destroyed=true;this.transport.pageCache[this.pageIndex]=null;var waitOn=[];Object.keys(this.intentStates).forEach(function(intent){if(intent==="oplist"){return}var intentState=this.intentStates[intent];intentState.renderTasks.forEach(function(renderTask){var renderCompleted=renderTask.capability.promise.catch(function(){});waitOn.push(renderCompleted);renderTask.cancel()})},this);this.objs.clear();this.annotationsPromise=null;this.pendingCleanup=false;return Promise.all(waitOn)},destroy:function(){deprecated("page destroy method, use cleanup() instead");this.cleanup()},cleanup:function PDFPageProxy_cleanup(){this.pendingCleanup=true;this._tryCleanup()},_tryCleanup:function PDFPageProxy_tryCleanup(){if(!this.pendingCleanup||Object.keys(this.intentStates).some(function(intent){var intentState=this.intentStates[intent];return intentState.renderTasks.length!==0||intentState.receivingOperatorList},this)){return}Object.keys(this.intentStates).forEach(function(intent){delete this.intentStates[intent]},this);this.objs.clear();this.annotationsPromise=null;this.pendingCleanup=false},_startRenderPage:function PDFPageProxy_startRenderPage(transparency,intent){var intentState=this.intentStates[intent];if(intentState.displayReadyCapability){intentState.displayReadyCapability.resolve(transparency)}},_renderPageChunk:function PDFPageProxy_renderPageChunk(operatorListChunk,intent){var intentState=this.intentStates[intent];var i,ii;for(i=0,ii=operatorListChunk.length;i<ii;i++){intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i])}intentState.operatorList.lastChunk=operatorListChunk.lastChunk;for(i=0;i<intentState.renderTasks.length;i++){intentState.renderTasks[i].operatorListChanged()}if(operatorListChunk.lastChunk){intentState.receivingOperatorList=false;this._tryCleanup()}}};return PDFPageProxy}();var PDFWorker=function PDFWorkerClosure(){var nextFakeWorkerId=0;function getWorkerSrc(){if(typeof workerSrc!=="undefined"){return workerSrc}if(getDefaultSetting("workerSrc")){return getDefaultSetting("workerSrc")}if(pdfjsFilePath){return pdfjsFilePath.replace(/\.js$/i,".worker.js")}error("No PDFJS.workerSrc specified")}var fakeWorkerFilesLoadedCapability;function setupFakeWorkerGlobal(){var WorkerMessageHandler;if(!fakeWorkerFilesLoadedCapability){fakeWorkerFilesLoadedCapability=createPromiseCapability();var loader=fakeWorkerFilesLoader||function(callback){Util.loadScript(getWorkerSrc(),function(){callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler)})};loader(fakeWorkerFilesLoadedCapability.resolve)}return fakeWorkerFilesLoadedCapability.promise}function FakeWorkerPort(defer){this._listeners=[];this._defer=defer;this._deferred=Promise.resolve(undefined)}FakeWorkerPort.prototype={postMessage:function(obj,transfers){function cloneValue(value){if(typeof value!=="object"||value===null){return value}if(cloned.has(value)){return cloned.get(value)}var result;var buffer;if((buffer=value.buffer)&&isArrayBuffer(buffer)){var transferable=transfers&&transfers.indexOf(buffer)>=0;if(value===buffer){result=value}else if(transferable){result=new value.constructor(buffer,value.byteOffset,value.byteLength)}else{result=new value.constructor(value)}cloned.set(value,result);return result}result=isArray(value)?[]:{};cloned.set(value,result);for(var i in value){var desc,p=value;while(!(desc=Object.getOwnPropertyDescriptor(p,i))){p=Object.getPrototypeOf(p)}if(typeof desc.value==="undefined"||typeof desc.value==="function"){continue}result[i]=cloneValue(desc.value)}return result}if(!this._defer){this._listeners.forEach(function(listener){listener.call(this,{data:obj})},this);return}var cloned=new WeakMap;var e={data:cloneValue(obj)};this._deferred.then(function(){this._listeners.forEach(function(listener){listener.call(this,e)},this)}.bind(this))},addEventListener:function(name,listener){this._listeners.push(listener)},removeEventListener:function(name,listener){var i=this._listeners.indexOf(listener);this._listeners.splice(i,1)},terminate:function(){this._listeners=[]}};function createCDNWrapper(url){var wrapper="importScripts('"+url+"');";return URL.createObjectURL(new Blob([wrapper]))}function PDFWorker(name){this.name=name;this.destroyed=false;this._readyCapability=createPromiseCapability();this._port=null;this._webWorker=null;this._messageHandler=null;this._initialize()}PDFWorker.prototype={get promise(){return this._readyCapability.promise},get port(){return this._port},get messageHandler(){return this._messageHandler},_initialize:function PDFWorker_initialize(){if(!isWorkerDisabled&&!getDefaultSetting("disableWorker")&&typeof Worker!=="undefined"){var workerSrc=getWorkerSrc();try{if(!isSameOrigin(window.location.href,workerSrc)){workerSrc=createCDNWrapper(new URL(workerSrc,window.location).href)}var worker=new Worker(workerSrc);var messageHandler=new MessageHandler("main","worker",worker);var terminateEarly=function(){worker.removeEventListener("error",onWorkerError);messageHandler.destroy();worker.terminate();if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"))}else{this._setupFakeWorker()}}.bind(this);var onWorkerError=function(event){if(!this._webWorker){terminateEarly()}}.bind(this);worker.addEventListener("error",onWorkerError);messageHandler.on("test",function PDFWorker_test(data){worker.removeEventListener("error",onWorkerError);if(this.destroyed){terminateEarly();return}var supportTypedArray=data&&data.supportTypedArray;if(supportTypedArray){this._messageHandler=messageHandler;this._port=worker;this._webWorker=worker;if(!data.supportTransfers){isPostMessageTransfersDisabled=true}this._readyCapability.resolve();messageHandler.send("configure",{verbosity:getVerbosityLevel()})}else{this._setupFakeWorker();messageHandler.destroy();worker.terminate()}}.bind(this));messageHandler.on("console_log",function(data){console.log.apply(console,data)});messageHandler.on("console_error",function(data){console.error.apply(console,data)});messageHandler.on("ready",function(data){worker.removeEventListener("error",onWorkerError);if(this.destroyed){terminateEarly();return}try{sendTest()}catch(e){this._setupFakeWorker()}}.bind(this));var sendTest=function(){var postMessageTransfers=getDefaultSetting("postMessageTransfers")&&!isPostMessageTransfersDisabled;var testObj=new Uint8Array([postMessageTransfers?255:0]);try{messageHandler.send("test",testObj,[testObj.buffer])}catch(ex){info("Cannot use postMessage transfers");testObj[0]=0;messageHandler.send("test",testObj)}};sendTest();return}catch(e){info("The worker has been disabled.")}}this._setupFakeWorker()},_setupFakeWorker:function PDFWorker_setupFakeWorker(){if(!isWorkerDisabled&&!getDefaultSetting("disableWorker")){warn("Setting up fake worker.");isWorkerDisabled=true}setupFakeWorkerGlobal().then(function(WorkerMessageHandler){if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}var isTypedArraysPresent=Uint8Array!==Float32Array;var port=new FakeWorkerPort(isTypedArraysPresent);this._port=port;var id="fake"+nextFakeWorkerId++;var workerHandler=new MessageHandler(id+"_worker",id,port);WorkerMessageHandler.setup(workerHandler,port);var messageHandler=new MessageHandler(id,id+"_worker",port);this._messageHandler=messageHandler;this._readyCapability.resolve()}.bind(this))},destroy:function PDFWorker_destroy(){this.destroyed=true;if(this._webWorker){this._webWorker.terminate();this._webWorker=null}this._port=null;if(this._messageHandler){this._messageHandler.destroy();this._messageHandler=null}}};return PDFWorker}();var WorkerTransport=function WorkerTransportClosure(){function WorkerTransport(messageHandler,loadingTask,pdfDataRangeTransport){this.messageHandler=messageHandler;this.loadingTask=loadingTask;this.pdfDataRangeTransport=pdfDataRangeTransport;this.commonObjs=new PDFObjects;this.fontLoader=new FontLoader(loadingTask.docId);this.destroyed=false;this.destroyCapability=null;this.pageCache=[];this.pagePromises=[];this.downloadInfoCapability=createPromiseCapability();this.setupMessageHandler()}WorkerTransport.prototype={destroy:function WorkerTransport_destroy(){if(this.destroyCapability){return this.destroyCapability.promise}this.destroyed=true;this.destroyCapability=createPromiseCapability();var waitOn=[];this.pageCache.forEach(function(page){if(page){waitOn.push(page._destroy())}});this.pageCache=[];this.pagePromises=[];var self=this;var terminated=this.messageHandler.sendWithPromise("Terminate",null);waitOn.push(terminated);Promise.all(waitOn).then(function(){self.fontLoader.clear();if(self.pdfDataRangeTransport){self.pdfDataRangeTransport.abort();self.pdfDataRangeTransport=null}if(self.messageHandler){self.messageHandler.destroy();self.messageHandler=null}self.destroyCapability.resolve()},this.destroyCapability.reject);return this.destroyCapability.promise},setupMessageHandler:function WorkerTransport_setupMessageHandler(){var messageHandler=this.messageHandler;function updatePassword(password){messageHandler.send("UpdatePassword",password)}var pdfDataRangeTransport=this.pdfDataRangeTransport;if(pdfDataRangeTransport){pdfDataRangeTransport.addRangeListener(function(begin,chunk){messageHandler.send("OnDataRange",{begin:begin,chunk:chunk})});pdfDataRangeTransport.addProgressListener(function(loaded){messageHandler.send("OnDataProgress",{loaded:loaded})});pdfDataRangeTransport.addProgressiveReadListener(function(chunk){messageHandler.send("OnDataRange",{chunk:chunk})});messageHandler.on("RequestDataRange",function transportDataRange(data){pdfDataRangeTransport.requestDataRange(data.begin,data.end)},this)}messageHandler.on("GetDoc",function transportDoc(data){var pdfInfo=data.pdfInfo;this.numPages=data.pdfInfo.numPages;var loadingTask=this.loadingTask;var pdfDocument=new PDFDocumentProxy(pdfInfo,this,loadingTask);this.pdfDocument=pdfDocument;loadingTask._capability.resolve(pdfDocument)},this);messageHandler.on("NeedPassword",function transportNeedPassword(exception){var loadingTask=this.loadingTask;if(loadingTask.onPassword){return loadingTask.onPassword(updatePassword,PasswordResponses.NEED_PASSWORD)}loadingTask._capability.reject(new PasswordException(exception.message,exception.code))},this);messageHandler.on("IncorrectPassword",function transportIncorrectPassword(exception){var loadingTask=this.loadingTask;if(loadingTask.onPassword){return loadingTask.onPassword(updatePassword,PasswordResponses.INCORRECT_PASSWORD)}loadingTask._capability.reject(new PasswordException(exception.message,exception.code))},this);messageHandler.on("InvalidPDF",function transportInvalidPDF(exception){this.loadingTask._capability.reject(new InvalidPDFException(exception.message))},this);messageHandler.on("MissingPDF",function transportMissingPDF(exception){this.loadingTask._capability.reject(new MissingPDFException(exception.message))},this);messageHandler.on("UnexpectedResponse",function transportUnexpectedResponse(exception){this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message,exception.status))},this);messageHandler.on("UnknownError",function transportUnknownError(exception){this.loadingTask._capability.reject(new UnknownErrorException(exception.message,exception.details))},this);messageHandler.on("DataLoaded",function transportPage(data){this.downloadInfoCapability.resolve(data)},this);messageHandler.on("PDFManagerReady",function transportPage(data){if(this.pdfDataRangeTransport){this.pdfDataRangeTransport.transportReady()}},this);messageHandler.on("StartRenderPage",function transportRender(data){if(this.destroyed){return}var page=this.pageCache[data.pageIndex];page.stats.timeEnd("Page Request");page._startRenderPage(data.transparency,data.intent)},this);messageHandler.on("RenderPageChunk",function transportRender(data){if(this.destroyed){return}var page=this.pageCache[data.pageIndex];page._renderPageChunk(data.operatorList,data.intent)},this);messageHandler.on("commonobj",function transportObj(data){if(this.destroyed){return}var id=data[0];var type=data[1];if(this.commonObjs.hasData(id)){return}switch(type){case"Font":var exportedData=data[2];if("error"in exportedData){var exportedError=exportedData.error;warn("Error during font loading: "+exportedError);this.commonObjs.resolve(id,exportedError);break}var fontRegistry=null;if(getDefaultSetting("pdfBug")&&globalScope.FontInspector&&globalScope["FontInspector"].enabled){fontRegistry={registerFont:function(font,url){globalScope["FontInspector"].fontAdded(font,url)}}}var font=new FontFaceObject(exportedData,{isEvalSuported:getDefaultSetting("isEvalSupported"),disableFontFace:getDefaultSetting("disableFontFace"),fontRegistry:fontRegistry});this.fontLoader.bind([font],function fontReady(fontObjs){this.commonObjs.resolve(id,font)}.bind(this));break;case"FontPath":this.commonObjs.resolve(id,data[2]);break;default:error("Got unknown common object type "+type)}},this);messageHandler.on("obj",function transportObj(data){if(this.destroyed){return}var id=data[0];var pageIndex=data[1];var type=data[2];var pageProxy=this.pageCache[pageIndex];var imageData;if(pageProxy.objs.hasData(id)){return}switch(type){case"JpegStream":imageData=data[3];loadJpegStream(id,imageData,pageProxy.objs);break;case"Image":imageData=data[3];pageProxy.objs.resolve(id,imageData);var MAX_IMAGE_SIZE_TO_STORE=8e6;if(imageData&&"data"in imageData&&imageData.data.length>MAX_IMAGE_SIZE_TO_STORE){pageProxy.cleanupAfterRender=true}break;default:error("Got unknown object type "+type)}},this);messageHandler.on("DocProgress",function transportDocProgress(data){if(this.destroyed){return}var loadingTask=this.loadingTask;if(loadingTask.onProgress){loadingTask.onProgress({loaded:data.loaded,total:data.total})}},this);messageHandler.on("PageError",function transportError(data){if(this.destroyed){return}var page=this.pageCache[data.pageNum-1];var intentState=page.intentStates[data.intent];if(intentState.displayReadyCapability){intentState.displayReadyCapability.reject(data.error)}else{error(data.error)}if(intentState.operatorList){intentState.operatorList.lastChunk=true;for(var i=0;i<intentState.renderTasks.length;i++){intentState.renderTasks[i].operatorListChanged()}}},this);messageHandler.on("UnsupportedFeature",function transportUnsupportedFeature(data){if(this.destroyed){return}var featureId=data.featureId;var loadingTask=this.loadingTask;if(loadingTask.onUnsupportedFeature){loadingTask.onUnsupportedFeature(featureId)}_UnsupportedManager.notify(featureId)},this);messageHandler.on("JpegDecode",function(data){if(this.destroyed){return Promise.reject(new Error("Worker was destroyed"))}var imageUrl=data[0];var components=data[1];if(components!==3&&components!==1){return Promise.reject(new Error("Only 3 components or 1 component can be returned"))}return new Promise(function(resolve,reject){var img=new Image;img.onload=function(){var width=img.width;var height=img.height;var size=width*height;var rgbaLength=size*4;var buf=new Uint8Array(size*components);var tmpCanvas=createScratchCanvas(width,height);var tmpCtx=tmpCanvas.getContext("2d");tmpCtx.drawImage(img,0,0);var data=tmpCtx.getImageData(0,0,width,height).data;var i,j;if(components===3){for(i=0,j=0;i<rgbaLength;i+=4,j+=3){buf[j]=data[i];buf[j+1]=data[i+1];buf[j+2]=data[i+2]}}else if(components===1){for(i=0,j=0;i<rgbaLength;i+=4,j++){buf[j]=data[i]}}resolve({data:buf,width:width,height:height})};img.onerror=function(){reject(new Error("JpegDecode failed to load image"))};img.src=imageUrl})},this)},getData:function WorkerTransport_getData(){return this.messageHandler.sendWithPromise("GetData",null)},getPage:function WorkerTransport_getPage(pageNumber,capability){if(!isInt(pageNumber)||pageNumber<=0||pageNumber>this.numPages){return Promise.reject(new Error("Invalid page request"))}var pageIndex=pageNumber-1;if(pageIndex in this.pagePromises){return this.pagePromises[pageIndex]}var promise=this.messageHandler.sendWithPromise("GetPage",{pageIndex:pageIndex}).then(function(pageInfo){if(this.destroyed){throw new Error("Transport destroyed")}var page=new PDFPageProxy(pageIndex,pageInfo,this);this.pageCache[pageIndex]=page;return page}.bind(this));this.pagePromises[pageIndex]=promise;return promise},getPageIndex:function WorkerTransport_getPageIndexByRef(ref){return this.messageHandler.sendWithPromise("GetPageIndex",{ref:ref}).catch(function(reason){return Promise.reject(new Error(reason))})},getAnnotations:function WorkerTransport_getAnnotations(pageIndex,intent){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:pageIndex,intent:intent})},getDestinations:function WorkerTransport_getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)},getDestination:function WorkerTransport_getDestination(id){return this.messageHandler.sendWithPromise("GetDestination",{id:id})},getPageLabels:function WorkerTransport_getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)},getAttachments:function WorkerTransport_getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)},getJavaScript:function WorkerTransport_getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)},getOutline:function WorkerTransport_getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)},getMetadata:function WorkerTransport_getMetadata(){return this.messageHandler.sendWithPromise("GetMetadata",null).then(function transportMetadata(results){return{info:results[0],metadata:results[1]?new Metadata(results[1]):null}})},getStats:function WorkerTransport_getStats(){return this.messageHandler.sendWithPromise("GetStats",null)},startCleanup:function WorkerTransport_startCleanup(){this.messageHandler.sendWithPromise("Cleanup",null).then(function endCleanup(){for(var i=0,ii=this.pageCache.length;i<ii;i++){var page=this.pageCache[i];if(page){page.cleanup()}}this.commonObjs.clear();this.fontLoader.clear()}.bind(this))}};return WorkerTransport}();var PDFObjects=function PDFObjectsClosure(){function PDFObjects(){this.objs=Object.create(null)}PDFObjects.prototype={ensureObj:function PDFObjects_ensureObj(objId){if(this.objs[objId]){return this.objs[objId]}var obj={capability:createPromiseCapability(),data:null,resolved:false};this.objs[objId]=obj;return obj},get:function PDFObjects_get(objId,callback){if(callback){this.ensureObj(objId).capability.promise.then(callback);return null}var obj=this.objs[objId];if(!obj||!obj.resolved){error("Requesting object that isn't resolved yet "+objId)}return obj.data},resolve:function PDFObjects_resolve(objId,data){var obj=this.ensureObj(objId);obj.resolved=true;obj.data=data;obj.capability.resolve(data)},isResolved:function PDFObjects_isResolved(objId){var objs=this.objs;if(!objs[objId]){return false}else{return objs[objId].resolved}},hasData:function PDFObjects_hasData(objId){return this.isResolved(objId)},getData:function PDFObjects_getData(objId){var objs=this.objs;if(!objs[objId]||!objs[objId].resolved){return null}else{return objs[objId].data}},clear:function PDFObjects_clear(){this.objs=Object.create(null)}};return PDFObjects}();var RenderTask=function RenderTaskClosure(){function RenderTask(internalRenderTask){this._internalRenderTask=internalRenderTask;this.onContinue=null}RenderTask.prototype={get promise(){return this._internalRenderTask.capability.promise},cancel:function RenderTask_cancel(){this._internalRenderTask.cancel()},then:function RenderTask_then(onFulfilled,onRejected){return this.promise.then.apply(this.promise,arguments)}};return RenderTask}();var InternalRenderTask=function InternalRenderTaskClosure(){function InternalRenderTask(callback,params,objs,commonObjs,operatorList,pageNumber){this.callback=callback;this.params=params;this.objs=objs;this.commonObjs=commonObjs;this.operatorListIdx=null;this.operatorList=operatorList;this.pageNumber=pageNumber;this.running=false;this.graphicsReadyCallback=null;this.graphicsReady=false;this.useRequestAnimationFrame=false;this.cancelled=false;this.capability=createPromiseCapability();this.task=new RenderTask(this);this._continueBound=this._continue.bind(this);this._scheduleNextBound=this._scheduleNext.bind(this);this._nextBound=this._next.bind(this)}InternalRenderTask.prototype={initializeGraphics:function InternalRenderTask_initializeGraphics(transparency){if(this.cancelled){return}if(getDefaultSetting("pdfBug")&&globalScope.StepperManager&&globalScope.StepperManager.enabled){this.stepper=globalScope.StepperManager.create(this.pageNumber-1);this.stepper.init(this.operatorList);this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint()}var params=this.params;this.gfx=new CanvasGraphics(params.canvasContext,this.commonObjs,this.objs,params.imageLayer);this.gfx.beginDrawing(params.transform,params.viewport,transparency);this.operatorListIdx=0;this.graphicsReady=true;if(this.graphicsReadyCallback){this.graphicsReadyCallback()}},cancel:function InternalRenderTask_cancel(){this.running=false;this.cancelled=true;this.callback("cancelled")},operatorListChanged:function InternalRenderTask_operatorListChanged(){if(!this.graphicsReady){if(!this.graphicsReadyCallback){this.graphicsReadyCallback=this._continueBound}return}if(this.stepper){this.stepper.updateOperatorList(this.operatorList)}if(this.running){return}this._continue()},_continue:function InternalRenderTask__continue(){this.running=true;if(this.cancelled){return}if(this.task.onContinue){this.task.onContinue.call(this.task,this._scheduleNextBound)}else{this._scheduleNext()}},_scheduleNext:function InternalRenderTask__scheduleNext(){if(this.useRequestAnimationFrame&&typeof window!=="undefined"){window.requestAnimationFrame(this._nextBound)}else{Promise.resolve(undefined).then(this._nextBound)}},_next:function InternalRenderTask__next(){if(this.cancelled){return}this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper);if(this.operatorListIdx===this.operatorList.argsArray.length){this.running=false;if(this.operatorList.lastChunk){this.gfx.endDrawing();this.callback()}}}};return InternalRenderTask}();var _UnsupportedManager=function UnsupportedManagerClosure(){var listeners=[];return{listen:function(cb){deprecated("Global UnsupportedManager.listen is used: "+" use PDFDocumentLoadingTask.onUnsupportedFeature instead");listeners.push(cb)},notify:function(featureId){for(var i=0,ii=listeners.length;i<ii;i++){listeners[i](featureId)}}}}();if(typeof pdfjsVersion!=="undefined"){exports.version=pdfjsVersion}if(typeof pdfjsBuild!=="undefined"){exports.build=pdfjsBuild}exports.getDocument=getDocument;exports.PDFDataRangeTransport=PDFDataRangeTransport;exports.PDFWorker=PDFWorker;exports.PDFDocumentProxy=PDFDocumentProxy;exports.PDFPageProxy=PDFPageProxy;exports._UnsupportedManager=_UnsupportedManager});(function(root,factory){{factory(root.pdfjsDisplayGlobal={},root.pdfjsSharedUtil,root.pdfjsDisplayDOMUtils,root.pdfjsDisplayAPI,root.pdfjsDisplayAnnotationLayer,root.pdfjsDisplayTextLayer,root.pdfjsDisplayMetadata,root.pdfjsDisplaySVG)}})(this,function(exports,sharedUtil,displayDOMUtils,displayAPI,displayAnnotationLayer,displayTextLayer,displayMetadata,displaySVG){var globalScope=sharedUtil.globalScope;var deprecated=sharedUtil.deprecated;var warn=sharedUtil.warn;var LinkTarget=displayDOMUtils.LinkTarget;var isWorker=typeof window==="undefined";if(!globalScope.PDFJS){globalScope.PDFJS={}}var PDFJS=globalScope.PDFJS;if(typeof pdfjsVersion!=="undefined"){PDFJS.version=pdfjsVersion}if(typeof pdfjsBuild!=="undefined"){PDFJS.build=pdfjsBuild}PDFJS.pdfBug=false;if(PDFJS.verbosity!==undefined){sharedUtil.setVerbosityLevel(PDFJS.verbosity)}delete PDFJS.verbosity;Object.defineProperty(PDFJS,"verbosity",{get:function(){return sharedUtil.getVerbosityLevel()},set:function(level){sharedUtil.setVerbosityLevel(level)},enumerable:true,configurable:true});PDFJS.VERBOSITY_LEVELS=sharedUtil.VERBOSITY_LEVELS;PDFJS.OPS=sharedUtil.OPS;PDFJS.UNSUPPORTED_FEATURES=sharedUtil.UNSUPPORTED_FEATURES;PDFJS.isValidUrl=sharedUtil.isValidUrl;PDFJS.shadow=sharedUtil.shadow;PDFJS.createBlob=sharedUtil.createBlob;PDFJS.createObjectURL=function PDFJS_createObjectURL(data,contentType){return sharedUtil.createObjectURL(data,contentType,PDFJS.disableCreateObjectURL)};Object.defineProperty(PDFJS,"isLittleEndian",{configurable:true,get:function PDFJS_isLittleEndian(){var value=sharedUtil.isLittleEndian();return sharedUtil.shadow(PDFJS,"isLittleEndian",value)}});PDFJS.removeNullCharacters=sharedUtil.removeNullCharacters;PDFJS.PasswordResponses=sharedUtil.PasswordResponses;PDFJS.PasswordException=sharedUtil.PasswordException;PDFJS.UnknownErrorException=sharedUtil.UnknownErrorException;PDFJS.InvalidPDFException=sharedUtil.InvalidPDFException;PDFJS.MissingPDFException=sharedUtil.MissingPDFException;PDFJS.UnexpectedResponseException=sharedUtil.UnexpectedResponseException;PDFJS.Util=sharedUtil.Util;PDFJS.PageViewport=sharedUtil.PageViewport;PDFJS.createPromiseCapability=sharedUtil.createPromiseCapability;PDFJS.maxImageSize=PDFJS.maxImageSize===undefined?-1:PDFJS.maxImageSize;PDFJS.cMapUrl=PDFJS.cMapUrl===undefined?null:PDFJS.cMapUrl;PDFJS.cMapPacked=PDFJS.cMapPacked===undefined?false:PDFJS.cMapPacked;PDFJS.disableFontFace=PDFJS.disableFontFace===undefined?false:PDFJS.disableFontFace;PDFJS.imageResourcesPath=PDFJS.imageResourcesPath===undefined?"":PDFJS.imageResourcesPath;PDFJS.disableWorker=PDFJS.disableWorker===undefined?false:PDFJS.disableWorker;PDFJS.workerSrc=PDFJS.workerSrc===undefined?null:PDFJS.workerSrc;PDFJS.disableRange=PDFJS.disableRange===undefined?false:PDFJS.disableRange;PDFJS.disableStream=PDFJS.disableStream===undefined?false:PDFJS.disableStream;PDFJS.disableAutoFetch=PDFJS.disableAutoFetch===undefined?false:PDFJS.disableAutoFetch;PDFJS.pdfBug=PDFJS.pdfBug===undefined?false:PDFJS.pdfBug;PDFJS.postMessageTransfers=PDFJS.postMessageTransfers===undefined?true:PDFJS.postMessageTransfers;PDFJS.disableCreateObjectURL=PDFJS.disableCreateObjectURL===undefined?false:PDFJS.disableCreateObjectURL;PDFJS.disableWebGL=PDFJS.disableWebGL===undefined?true:PDFJS.disableWebGL;PDFJS.externalLinkTarget=PDFJS.externalLinkTarget===undefined?LinkTarget.NONE:PDFJS.externalLinkTarget;PDFJS.externalLinkRel=PDFJS.externalLinkRel===undefined?"noreferrer":PDFJS.externalLinkRel;PDFJS.isEvalSupported=PDFJS.isEvalSupported===undefined?true:PDFJS.isEvalSupported;var savedOpenExternalLinksInNewWindow=PDFJS.openExternalLinksInNewWindow;delete PDFJS.openExternalLinksInNewWindow;Object.defineProperty(PDFJS,"openExternalLinksInNewWindow",{get:function(){return PDFJS.externalLinkTarget===LinkTarget.BLANK},set:function(value){if(value){deprecated("PDFJS.openExternalLinksInNewWindow, please use "+'"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.')}if(PDFJS.externalLinkTarget!==LinkTarget.NONE){warn("PDFJS.externalLinkTarget is already initialized");return}PDFJS.externalLinkTarget=value?LinkTarget.BLANK:LinkTarget.NONE},enumerable:true,configurable:true});if(savedOpenExternalLinksInNewWindow){PDFJS.openExternalLinksInNewWindow=savedOpenExternalLinksInNewWindow}PDFJS.getDocument=displayAPI.getDocument;PDFJS.PDFDataRangeTransport=displayAPI.PDFDataRangeTransport;PDFJS.PDFWorker=displayAPI.PDFWorker;Object.defineProperty(PDFJS,"hasCanvasTypedArrays",{configurable:true,get:function PDFJS_hasCanvasTypedArrays(){var value=displayDOMUtils.hasCanvasTypedArrays();return sharedUtil.shadow(PDFJS,"hasCanvasTypedArrays",value)}});PDFJS.CustomStyle=displayDOMUtils.CustomStyle;PDFJS.LinkTarget=LinkTarget;PDFJS.addLinkAttributes=displayDOMUtils.addLinkAttributes;PDFJS.getFilenameFromUrl=displayDOMUtils.getFilenameFromUrl;PDFJS.isExternalLinkTargetSet=displayDOMUtils.isExternalLinkTargetSet;PDFJS.AnnotationLayer=displayAnnotationLayer.AnnotationLayer;PDFJS.renderTextLayer=displayTextLayer.renderTextLayer;PDFJS.Metadata=displayMetadata.Metadata;PDFJS.SVGGraphics=displaySVG.SVGGraphics;PDFJS.UnsupportedManager=displayAPI._UnsupportedManager;exports.globalScope=globalScope;exports.isWorker=isWorker;exports.PDFJS=globalScope.PDFJS})}).call(pdfjsLibs);exports.PDFJS=pdfjsLibs.pdfjsDisplayGlobal.PDFJS;exports.build=pdfjsLibs.pdfjsDisplayAPI.build;exports.version=pdfjsLibs.pdfjsDisplayAPI.version;exports.getDocument=pdfjsLibs.pdfjsDisplayAPI.getDocument;exports.PDFDataRangeTransport=pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;exports.PDFWorker=pdfjsLibs.pdfjsDisplayAPI.PDFWorker;exports.renderTextLayer=pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;exports.AnnotationLayer=pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;exports.CustomStyle=pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;exports.PasswordResponses=pdfjsLibs.pdfjsSharedUtil.PasswordResponses;exports.InvalidPDFException=pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;exports.MissingPDFException=pdfjsLibs.pdfjsSharedUtil.MissingPDFException;exports.SVGGraphics=pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;exports.UnexpectedResponseException=pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;exports.OPS=pdfjsLibs.pdfjsSharedUtil.OPS;
8exports.UNSUPPORTED_FEATURES=pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;exports.isValidUrl=pdfjsLibs.pdfjsSharedUtil.isValidUrl;exports.createObjectURL=pdfjsLibs.pdfjsSharedUtil.createObjectURL;exports.removeNullCharacters=pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;exports.shadow=pdfjsLibs.pdfjsSharedUtil.shadow;exports.createBlob=pdfjsLibs.pdfjsSharedUtil.createBlob;exports.getFilenameFromUrl=pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;exports.addLinkAttributes=pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes}); \ No newline at end of file
diff --git a/dist/js/pdf.worker.js b/dist/js/pdf.worker.js
new file mode 100644
index 00000000..11a6cf9e
--- /dev/null
+++ b/dist/js/pdf.worker.js
@@ -0,0 +1,43506 @@
1/* Copyright 2012 Mozilla Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15/* jshint globalstrict: false */
16/* umdutils ignore */
17
18(function (root, factory) {
19 'use strict';
20 if (typeof define === 'function' && define.amd) {
21define('pdfjs-dist/build/pdf.worker', ['exports'], factory);
22 } else if (typeof exports !== 'undefined') {
23 factory(exports);
24 } else {
25factory((root.pdfjsDistBuildPdfWorker = {}));
26 }
27}(this, function (exports) {
28 // Use strict in our context only - users might not want it
29 'use strict';
30
31var pdfjsVersion = '1.6.210';
32var pdfjsBuild = '4ce2356';
33
34 var pdfjsFilePath =
35 typeof document !== 'undefined' && document.currentScript ?
36 document.currentScript.src : null;
37
38 var pdfjsLibs = {};
39
40 (function pdfjsWrapper() {
41
42
43
44(function (root, factory) {
45 {
46 factory((root.pdfjsCoreArithmeticDecoder = {}));
47 }
48}(this, function (exports) {
49
50/* This class implements the QM Coder decoding as defined in
51 * JPEG 2000 Part I Final Committee Draft Version 1.0
52 * Annex C.3 Arithmetic decoding procedure
53 * available at http://www.jpeg.org/public/fcd15444-1.pdf
54 *
55 * The arithmetic decoder is used in conjunction with context models to decode
56 * JPEG2000 and JBIG2 streams.
57 */
58var ArithmeticDecoder = (function ArithmeticDecoderClosure() {
59 // Table C-2
60 var QeTable = [
61 {qe: 0x5601, nmps: 1, nlps: 1, switchFlag: 1},
62 {qe: 0x3401, nmps: 2, nlps: 6, switchFlag: 0},
63 {qe: 0x1801, nmps: 3, nlps: 9, switchFlag: 0},
64 {qe: 0x0AC1, nmps: 4, nlps: 12, switchFlag: 0},
65 {qe: 0x0521, nmps: 5, nlps: 29, switchFlag: 0},
66 {qe: 0x0221, nmps: 38, nlps: 33, switchFlag: 0},
67 {qe: 0x5601, nmps: 7, nlps: 6, switchFlag: 1},
68 {qe: 0x5401, nmps: 8, nlps: 14, switchFlag: 0},
69 {qe: 0x4801, nmps: 9, nlps: 14, switchFlag: 0},
70 {qe: 0x3801, nmps: 10, nlps: 14, switchFlag: 0},
71 {qe: 0x3001, nmps: 11, nlps: 17, switchFlag: 0},
72 {qe: 0x2401, nmps: 12, nlps: 18, switchFlag: 0},
73 {qe: 0x1C01, nmps: 13, nlps: 20, switchFlag: 0},
74 {qe: 0x1601, nmps: 29, nlps: 21, switchFlag: 0},
75 {qe: 0x5601, nmps: 15, nlps: 14, switchFlag: 1},
76 {qe: 0x5401, nmps: 16, nlps: 14, switchFlag: 0},
77 {qe: 0x5101, nmps: 17, nlps: 15, switchFlag: 0},
78 {qe: 0x4801, nmps: 18, nlps: 16, switchFlag: 0},
79 {qe: 0x3801, nmps: 19, nlps: 17, switchFlag: 0},
80 {qe: 0x3401, nmps: 20, nlps: 18, switchFlag: 0},
81 {qe: 0x3001, nmps: 21, nlps: 19, switchFlag: 0},
82 {qe: 0x2801, nmps: 22, nlps: 19, switchFlag: 0},
83 {qe: 0x2401, nmps: 23, nlps: 20, switchFlag: 0},
84 {qe: 0x2201, nmps: 24, nlps: 21, switchFlag: 0},
85 {qe: 0x1C01, nmps: 25, nlps: 22, switchFlag: 0},
86 {qe: 0x1801, nmps: 26, nlps: 23, switchFlag: 0},
87 {qe: 0x1601, nmps: 27, nlps: 24, switchFlag: 0},
88 {qe: 0x1401, nmps: 28, nlps: 25, switchFlag: 0},
89 {qe: 0x1201, nmps: 29, nlps: 26, switchFlag: 0},
90 {qe: 0x1101, nmps: 30, nlps: 27, switchFlag: 0},
91 {qe: 0x0AC1, nmps: 31, nlps: 28, switchFlag: 0},
92 {qe: 0x09C1, nmps: 32, nlps: 29, switchFlag: 0},
93 {qe: 0x08A1, nmps: 33, nlps: 30, switchFlag: 0},
94 {qe: 0x0521, nmps: 34, nlps: 31, switchFlag: 0},
95 {qe: 0x0441, nmps: 35, nlps: 32, switchFlag: 0},
96 {qe: 0x02A1, nmps: 36, nlps: 33, switchFlag: 0},
97 {qe: 0x0221, nmps: 37, nlps: 34, switchFlag: 0},
98 {qe: 0x0141, nmps: 38, nlps: 35, switchFlag: 0},
99 {qe: 0x0111, nmps: 39, nlps: 36, switchFlag: 0},
100 {qe: 0x0085, nmps: 40, nlps: 37, switchFlag: 0},
101 {qe: 0x0049, nmps: 41, nlps: 38, switchFlag: 0},
102 {qe: 0x0025, nmps: 42, nlps: 39, switchFlag: 0},
103 {qe: 0x0015, nmps: 43, nlps: 40, switchFlag: 0},
104 {qe: 0x0009, nmps: 44, nlps: 41, switchFlag: 0},
105 {qe: 0x0005, nmps: 45, nlps: 42, switchFlag: 0},
106 {qe: 0x0001, nmps: 45, nlps: 43, switchFlag: 0},
107 {qe: 0x5601, nmps: 46, nlps: 46, switchFlag: 0}
108 ];
109
110 // C.3.5 Initialisation of the decoder (INITDEC)
111 function ArithmeticDecoder(data, start, end) {
112 this.data = data;
113 this.bp = start;
114 this.dataEnd = end;
115
116 this.chigh = data[start];
117 this.clow = 0;
118
119 this.byteIn();
120
121 this.chigh = ((this.chigh << 7) & 0xFFFF) | ((this.clow >> 9) & 0x7F);
122 this.clow = (this.clow << 7) & 0xFFFF;
123 this.ct -= 7;
124 this.a = 0x8000;
125 }
126
127 ArithmeticDecoder.prototype = {
128 // C.3.4 Compressed data input (BYTEIN)
129 byteIn: function ArithmeticDecoder_byteIn() {
130 var data = this.data;
131 var bp = this.bp;
132 if (data[bp] === 0xFF) {
133 var b1 = data[bp + 1];
134 if (b1 > 0x8F) {
135 this.clow += 0xFF00;
136 this.ct = 8;
137 } else {
138 bp++;
139 this.clow += (data[bp] << 9);
140 this.ct = 7;
141 this.bp = bp;
142 }
143 } else {
144 bp++;
145 this.clow += bp < this.dataEnd ? (data[bp] << 8) : 0xFF00;
146 this.ct = 8;
147 this.bp = bp;
148 }
149 if (this.clow > 0xFFFF) {
150 this.chigh += (this.clow >> 16);
151 this.clow &= 0xFFFF;
152 }
153 },
154 // C.3.2 Decoding a decision (DECODE)
155 readBit: function ArithmeticDecoder_readBit(contexts, pos) {
156 // contexts are packed into 1 byte:
157 // highest 7 bits carry cx.index, lowest bit carries cx.mps
158 var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
159 var qeTableIcx = QeTable[cx_index];
160 var qeIcx = qeTableIcx.qe;
161 var d;
162 var a = this.a - qeIcx;
163
164 if (this.chigh < qeIcx) {
165 // exchangeLps
166 if (a < qeIcx) {
167 a = qeIcx;
168 d = cx_mps;
169 cx_index = qeTableIcx.nmps;
170 } else {
171 a = qeIcx;
172 d = 1 ^ cx_mps;
173 if (qeTableIcx.switchFlag === 1) {
174 cx_mps = d;
175 }
176 cx_index = qeTableIcx.nlps;
177 }
178 } else {
179 this.chigh -= qeIcx;
180 if ((a & 0x8000) !== 0) {
181 this.a = a;
182 return cx_mps;
183 }
184 // exchangeMps
185 if (a < qeIcx) {
186 d = 1 ^ cx_mps;
187 if (qeTableIcx.switchFlag === 1) {
188 cx_mps = d;
189 }
190 cx_index = qeTableIcx.nlps;
191 } else {
192 d = cx_mps;
193 cx_index = qeTableIcx.nmps;
194 }
195 }
196 // C.3.3 renormD;
197 do {
198 if (this.ct === 0) {
199 this.byteIn();
200 }
201
202 a <<= 1;
203 this.chigh = ((this.chigh << 1) & 0xFFFF) | ((this.clow >> 15) & 1);
204 this.clow = (this.clow << 1) & 0xFFFF;
205 this.ct--;
206 } while ((a & 0x8000) === 0);
207 this.a = a;
208
209 contexts[pos] = cx_index << 1 | cx_mps;
210 return d;
211 }
212 };
213
214 return ArithmeticDecoder;
215})();
216
217exports.ArithmeticDecoder = ArithmeticDecoder;
218}));
219
220
221(function (root, factory) {
222 {
223 factory((root.pdfjsCoreBidi = {}));
224 }
225}(this, function (exports) {
226
227 // Character types for symbols from 0000 to 00FF.
228 var baseTypes = [
229 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'S', 'B', 'S', 'WS',
230 'B', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN',
231 'BN', 'BN', 'B', 'B', 'B', 'S', 'WS', 'ON', 'ON', 'ET', 'ET', 'ET', 'ON',
232 'ON', 'ON', 'ON', 'ON', 'ON', 'CS', 'ON', 'CS', 'ON', 'EN', 'EN', 'EN',
233 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'ON', 'ON', 'ON', 'ON', 'ON',
234 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
235 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON',
236 'ON', 'ON', 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
237 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
238 'L', 'ON', 'ON', 'ON', 'ON', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'B', 'BN',
239 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN',
240 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN',
241 'BN', 'CS', 'ON', 'ET', 'ET', 'ET', 'ET', 'ON', 'ON', 'ON', 'ON', 'L', 'ON',
242 'ON', 'ON', 'ON', 'ON', 'ET', 'ET', 'EN', 'EN', 'ON', 'L', 'ON', 'ON', 'ON',
243 'EN', 'L', 'ON', 'ON', 'ON', 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
244 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
245 'L', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
246 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
247 'L', 'L', 'L', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L'
248 ];
249
250 // Character types for symbols from 0600 to 06FF
251 var arabicTypes = [
252 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
253 'CS', 'AL', 'ON', 'ON', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AL',
254 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
255 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
256 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
257 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
258 'AL', 'AL', 'AL', 'AL', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM',
259 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AL', 'AL', 'AL', 'AL',
260 'AL', 'AL', 'AL', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN',
261 'AN', 'ET', 'AN', 'AN', 'AL', 'AL', 'AL', 'NSM', 'AL', 'AL', 'AL', 'AL',
262 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
263 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
264 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
265 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
266 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
267 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
268 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
269 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
270 'AL', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM',
271 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'ON', 'NSM',
272 'NSM', 'NSM', 'NSM', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
273 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL'
274 ];
275
276 function isOdd(i) {
277 return (i & 1) !== 0;
278 }
279
280 function isEven(i) {
281 return (i & 1) === 0;
282 }
283
284 function findUnequal(arr, start, value) {
285 for (var j = start, jj = arr.length; j < jj; ++j) {
286 if (arr[j] !== value) {
287 return j;
288 }
289 }
290 return j;
291 }
292
293 function setValues(arr, start, end, value) {
294 for (var j = start; j < end; ++j) {
295 arr[j] = value;
296 }
297 }
298
299 function reverseValues(arr, start, end) {
300 for (var i = start, j = end - 1; i < j; ++i, --j) {
301 var temp = arr[i];
302 arr[i] = arr[j];
303 arr[j] = temp;
304 }
305 }
306
307 function createBidiText(str, isLTR, vertical) {
308 return {
309 str: str,
310 dir: (vertical ? 'ttb' : (isLTR ? 'ltr' : 'rtl'))
311 };
312 }
313
314 // These are used in bidi(), which is called frequently. We re-use them on
315 // each call to avoid unnecessary allocations.
316 var chars = [];
317 var types = [];
318
319 function bidi(str, startLevel, vertical) {
320 var isLTR = true;
321 var strLength = str.length;
322 if (strLength === 0 || vertical) {
323 return createBidiText(str, isLTR, vertical);
324 }
325
326 // Get types and fill arrays
327 chars.length = strLength;
328 types.length = strLength;
329 var numBidi = 0;
330
331 var i, ii;
332 for (i = 0; i < strLength; ++i) {
333 chars[i] = str.charAt(i);
334
335 var charCode = str.charCodeAt(i);
336 var charType = 'L';
337 if (charCode <= 0x00ff) {
338 charType = baseTypes[charCode];
339 } else if (0x0590 <= charCode && charCode <= 0x05f4) {
340 charType = 'R';
341 } else if (0x0600 <= charCode && charCode <= 0x06ff) {
342 charType = arabicTypes[charCode & 0xff];
343 } else if (0x0700 <= charCode && charCode <= 0x08AC) {
344 charType = 'AL';
345 }
346 if (charType === 'R' || charType === 'AL' || charType === 'AN') {
347 numBidi++;
348 }
349 types[i] = charType;
350 }
351
352 // Detect the bidi method
353 // - If there are no rtl characters then no bidi needed
354 // - If less than 30% chars are rtl then string is primarily ltr
355 // - If more than 30% chars are rtl then string is primarily rtl
356 if (numBidi === 0) {
357 isLTR = true;
358 return createBidiText(str, isLTR);
359 }
360
361 if (startLevel === -1) {
362 if ((strLength / numBidi) < 0.3) {
363 isLTR = true;
364 startLevel = 0;
365 } else {
366 isLTR = false;
367 startLevel = 1;
368 }
369 }
370
371 var levels = [];
372 for (i = 0; i < strLength; ++i) {
373 levels[i] = startLevel;
374 }
375
376 /*
377 X1-X10: skip most of this, since we are NOT doing the embeddings.
378 */
379 var e = (isOdd(startLevel) ? 'R' : 'L');
380 var sor = e;
381 var eor = sor;
382
383 /*
384 W1. Examine each non-spacing mark (NSM) in the level run, and change the
385 type of the NSM to the type of the previous character. If the NSM is at the
386 start of the level run, it will get the type of sor.
387 */
388 var lastType = sor;
389 for (i = 0; i < strLength; ++i) {
390 if (types[i] === 'NSM') {
391 types[i] = lastType;
392 } else {
393 lastType = types[i];
394 }
395 }
396
397 /*
398 W2. Search backwards from each instance of a European number until the
399 first strong type (R, L, AL, or sor) is found. If an AL is found, change
400 the type of the European number to Arabic number.
401 */
402 lastType = sor;
403 var t;
404 for (i = 0; i < strLength; ++i) {
405 t = types[i];
406 if (t === 'EN') {
407 types[i] = (lastType === 'AL') ? 'AN' : 'EN';
408 } else if (t === 'R' || t === 'L' || t === 'AL') {
409 lastType = t;
410 }
411 }
412
413 /*
414 W3. Change all ALs to R.
415 */
416 for (i = 0; i < strLength; ++i) {
417 t = types[i];
418 if (t === 'AL') {
419 types[i] = 'R';
420 }
421 }
422
423 /*
424 W4. A single European separator between two European numbers changes to a
425 European number. A single common separator between two numbers of the same
426 type changes to that type:
427 */
428 for (i = 1; i < strLength - 1; ++i) {
429 if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
430 types[i] = 'EN';
431 }
432 if (types[i] === 'CS' &&
433 (types[i - 1] === 'EN' || types[i - 1] === 'AN') &&
434 types[i + 1] === types[i - 1]) {
435 types[i] = types[i - 1];
436 }
437 }
438
439 /*
440 W5. A sequence of European terminators adjacent to European numbers changes
441 to all European numbers:
442 */
443 for (i = 0; i < strLength; ++i) {
444 if (types[i] === 'EN') {
445 // do before
446 var j;
447 for (j = i - 1; j >= 0; --j) {
448 if (types[j] !== 'ET') {
449 break;
450 }
451 types[j] = 'EN';
452 }
453 // do after
454 for (j = i + 1; j < strLength; ++j) {
455 if (types[j] !== 'ET') {
456 break;
457 }
458 types[j] = 'EN';
459 }
460 }
461 }
462
463 /*
464 W6. Otherwise, separators and terminators change to Other Neutral:
465 */
466 for (i = 0; i < strLength; ++i) {
467 t = types[i];
468 if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
469 types[i] = 'ON';
470 }
471 }
472
473 /*
474 W7. Search backwards from each instance of a European number until the
475 first strong type (R, L, or sor) is found. If an L is found, then change
476 the type of the European number to L.
477 */
478 lastType = sor;
479 for (i = 0; i < strLength; ++i) {
480 t = types[i];
481 if (t === 'EN') {
482 types[i] = ((lastType === 'L') ? 'L' : 'EN');
483 } else if (t === 'R' || t === 'L') {
484 lastType = t;
485 }
486 }
487
488 /*
489 N1. A sequence of neutrals takes the direction of the surrounding strong
490 text if the text on both sides has the same direction. European and Arabic
491 numbers are treated as though they were R. Start-of-level-run (sor) and
492 end-of-level-run (eor) are used at level run boundaries.
493 */
494 for (i = 0; i < strLength; ++i) {
495 if (types[i] === 'ON') {
496 var end = findUnequal(types, i + 1, 'ON');
497 var before = sor;
498 if (i > 0) {
499 before = types[i - 1];
500 }
501
502 var after = eor;
503 if (end + 1 < strLength) {
504 after = types[end + 1];
505 }
506 if (before !== 'L') {
507 before = 'R';
508 }
509 if (after !== 'L') {
510 after = 'R';
511 }
512 if (before === after) {
513 setValues(types, i, end, before);
514 }
515 i = end - 1; // reset to end (-1 so next iteration is ok)
516 }
517 }
518
519 /*
520 N2. Any remaining neutrals take the embedding direction.
521 */
522 for (i = 0; i < strLength; ++i) {
523 if (types[i] === 'ON') {
524 types[i] = e;
525 }
526 }
527
528 /*
529 I1. For all characters with an even (left-to-right) embedding direction,
530 those of type R go up one level and those of type AN or EN go up two
531 levels.
532 I2. For all characters with an odd (right-to-left) embedding direction,
533 those of type L, EN or AN go up one level.
534 */
535 for (i = 0; i < strLength; ++i) {
536 t = types[i];
537 if (isEven(levels[i])) {
538 if (t === 'R') {
539 levels[i] += 1;
540 } else if (t === 'AN' || t === 'EN') {
541 levels[i] += 2;
542 }
543 } else { // isOdd
544 if (t === 'L' || t === 'AN' || t === 'EN') {
545 levels[i] += 1;
546 }
547 }
548 }
549
550 /*
551 L1. On each line, reset the embedding level of the following characters to
552 the paragraph embedding level:
553
554 segment separators,
555 paragraph separators,
556 any sequence of whitespace characters preceding a segment separator or
557 paragraph separator, and any sequence of white space characters at the end
558 of the line.
559 */
560
561 // don't bother as text is only single line
562
563 /*
564 L2. From the highest level found in the text to the lowest odd level on
565 each line, reverse any contiguous sequence of characters that are at that
566 level or higher.
567 */
568
569 // find highest level & lowest odd level
570 var highestLevel = -1;
571 var lowestOddLevel = 99;
572 var level;
573 for (i = 0, ii = levels.length; i < ii; ++i) {
574 level = levels[i];
575 if (highestLevel < level) {
576 highestLevel = level;
577 }
578 if (lowestOddLevel > level && isOdd(level)) {
579 lowestOddLevel = level;
580 }
581 }
582
583 // now reverse between those limits
584 for (level = highestLevel; level >= lowestOddLevel; --level) {
585 // find segments to reverse
586 var start = -1;
587 for (i = 0, ii = levels.length; i < ii; ++i) {
588 if (levels[i] < level) {
589 if (start >= 0) {
590 reverseValues(chars, start, i);
591 start = -1;
592 }
593 } else if (start < 0) {
594 start = i;
595 }
596 }
597 if (start >= 0) {
598 reverseValues(chars, start, levels.length);
599 }
600 }
601
602 /*
603 L3. Combining marks applied to a right-to-left base character will at this
604 point precede their base character. If the rendering engine expects them to
605 follow the base characters in the final display process, then the ordering
606 of the marks and the base character must be reversed.
607 */
608
609 // don't bother for now
610
611 /*
612 L4. A character that possesses the mirrored property as specified by
613 Section 4.7, Mirrored, must be depicted by a mirrored glyph if the resolved
614 directionality of that character is R.
615 */
616
617 // don't mirror as characters are already mirrored in the pdf
618
619 // Finally, return string
620 for (i = 0, ii = chars.length; i < ii; ++i) {
621 var ch = chars[i];
622 if (ch === '<' || ch === '>') {
623 chars[i] = '';
624 }
625 }
626 return createBidiText(chars.join(''), isLTR);
627 }
628
629exports.bidi = bidi;
630}));
631
632
633(function (root, factory) {
634 {
635 factory((root.pdfjsCoreCharsets = {}));
636 }
637}(this, function (exports) {
638
639var ISOAdobeCharset = [
640 '.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar',
641 'percent', 'ampersand', 'quoteright', 'parenleft', 'parenright',
642 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash', 'zero',
643 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
644 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question',
645 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
646 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
647 'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore',
648 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
649 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
650 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent',
651 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency',
652 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft',
653 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl',
654 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase',
655 'quotedblbase', 'quotedblright', 'guillemotright', 'ellipsis',
656 'perthousand', 'questiondown', 'grave', 'acute', 'circumflex', 'tilde',
657 'macron', 'breve', 'dotaccent', 'dieresis', 'ring', 'cedilla',
658 'hungarumlaut', 'ogonek', 'caron', 'emdash', 'AE', 'ordfeminine',
659 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae', 'dotlessi', 'lslash',
660 'oslash', 'oe', 'germandbls', 'onesuperior', 'logicalnot', 'mu',
661 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn', 'onequarter',
662 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters', 'twosuperior',
663 'registered', 'minus', 'eth', 'multiply', 'threesuperior', 'copyright',
664 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring', 'Atilde',
665 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave', 'Iacute',
666 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute', 'Ocircumflex',
667 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute', 'Ucircumflex',
668 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron', 'aacute',
669 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde', 'ccedilla',
670 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute', 'icircumflex',
671 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex', 'odieresis',
672 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex', 'udieresis',
673 'ugrave', 'yacute', 'ydieresis', 'zcaron'
674];
675
676var ExpertCharset = [
677 '.notdef', 'space', 'exclamsmall', 'Hungarumlautsmall', 'dollaroldstyle',
678 'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior',
679 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'comma',
680 'hyphen', 'period', 'fraction', 'zerooldstyle', 'oneoldstyle',
681 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle',
682 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle',
683 'colon', 'semicolon', 'commasuperior', 'threequartersemdash',
684 'periodsuperior', 'questionsmall', 'asuperior', 'bsuperior',
685 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior',
686 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior',
687 'tsuperior', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior',
688 'parenrightinferior', 'Circumflexsmall', 'hyphensuperior', 'Gravesmall',
689 'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall',
690 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall',
691 'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall',
692 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary',
693 'onefitted', 'rupiah', 'Tildesmall', 'exclamdownsmall', 'centoldstyle',
694 'Lslashsmall', 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall',
695 'Brevesmall', 'Caronsmall', 'Dotaccentsmall', 'Macronsmall',
696 'figuredash', 'hypheninferior', 'Ogoneksmall', 'Ringsmall',
697 'Cedillasmall', 'onequarter', 'onehalf', 'threequarters',
698 'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths',
699 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'onesuperior',
700 'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior',
701 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior',
702 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior',
703 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior',
704 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior',
705 'periodinferior', 'commainferior', 'Agravesmall', 'Aacutesmall',
706 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall', 'Aringsmall',
707 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall',
708 'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall',
709 'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall',
710 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall',
711 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall',
712 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall',
713 'Ydieresissmall'
714];
715
716var ExpertSubsetCharset = [
717 '.notdef', 'space', 'dollaroldstyle', 'dollarsuperior',
718 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader',
719 'onedotenleader', 'comma', 'hyphen', 'period', 'fraction',
720 'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle',
721 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle',
722 'eightoldstyle', 'nineoldstyle', 'colon', 'semicolon', 'commasuperior',
723 'threequartersemdash', 'periodsuperior', 'asuperior', 'bsuperior',
724 'centsuperior', 'dsuperior', 'esuperior', 'isuperior', 'lsuperior',
725 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior',
726 'tsuperior', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior',
727 'parenrightinferior', 'hyphensuperior', 'colonmonetary', 'onefitted',
728 'rupiah', 'centoldstyle', 'figuredash', 'hypheninferior', 'onequarter',
729 'onehalf', 'threequarters', 'oneeighth', 'threeeighths', 'fiveeighths',
730 'seveneighths', 'onethird', 'twothirds', 'zerosuperior', 'onesuperior',
731 'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior',
732 'sixsuperior', 'sevensuperior', 'eightsuperior', 'ninesuperior',
733 'zeroinferior', 'oneinferior', 'twoinferior', 'threeinferior',
734 'fourinferior', 'fiveinferior', 'sixinferior', 'seveninferior',
735 'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior',
736 'periodinferior', 'commainferior'
737];
738
739exports.ISOAdobeCharset = ISOAdobeCharset;
740exports.ExpertCharset = ExpertCharset;
741exports.ExpertSubsetCharset = ExpertSubsetCharset;
742}));
743
744
745(function (root, factory) {
746 {
747 factory((root.pdfjsCoreEncodings = {}));
748 }
749}(this, function (exports) {
750
751 var ExpertEncoding = [
752 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
753 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
754 'space', 'exclamsmall', 'Hungarumlautsmall', '', 'dollaroldstyle',
755 'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior',
756 'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'comma',
757 'hyphen', 'period', 'fraction', 'zerooldstyle', 'oneoldstyle',
758 'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle',
759 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'colon',
760 'semicolon', 'commasuperior', 'threequartersemdash', 'periodsuperior',
761 'questionsmall', '', 'asuperior', 'bsuperior', 'centsuperior', 'dsuperior',
762 'esuperior', '', '', 'isuperior', '', '', 'lsuperior', 'msuperior',
763 'nsuperior', 'osuperior', '', '', 'rsuperior', 'ssuperior', 'tsuperior',
764 '', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', '',
765 'parenrightinferior', 'Circumflexsmall', 'hyphensuperior', 'Gravesmall',
766 'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall',
767 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall',
768 'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall',
769 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary',
770 'onefitted', 'rupiah', 'Tildesmall', '', '', '', '', '', '', '', '', '',
771 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
772 '', '', '', '', '', '', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall',
773 '', '', 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall',
774 'Caronsmall', '', 'Dotaccentsmall', '', '', 'Macronsmall', '', '',
775 'figuredash', 'hypheninferior', '', '', 'Ogoneksmall', 'Ringsmall',
776 'Cedillasmall', '', '', '', 'onequarter', 'onehalf', 'threequarters',
777 'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths',
778 'seveneighths', 'onethird', 'twothirds', '', '', 'zerosuperior',
779 'onesuperior', 'twosuperior', 'threesuperior', 'foursuperior',
780 'fivesuperior', 'sixsuperior', 'sevensuperior', 'eightsuperior',
781 'ninesuperior', 'zeroinferior', 'oneinferior', 'twoinferior',
782 'threeinferior', 'fourinferior', 'fiveinferior', 'sixinferior',
783 'seveninferior', 'eightinferior', 'nineinferior', 'centinferior',
784 'dollarinferior', 'periodinferior', 'commainferior', 'Agravesmall',
785 'Aacutesmall', 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall',
786 'Aringsmall', 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall',
787 'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall',
788 'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall',
789 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall',
790 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall',
791 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall',
792 'Ydieresissmall'];
793
794 var MacExpertEncoding = [
795 '', '', '', '', '', '', '', '', '', '', '', '', '', '',
796 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
797 'space', 'exclamsmall', 'Hungarumlautsmall', 'centoldstyle',
798 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', 'Acutesmall',
799 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader',
800 'onedotenleader', 'comma', 'hyphen', 'period', 'fraction', 'zerooldstyle',
801 'oneoldstyle', 'twooldstyle', 'threeoldstyle', 'fouroldstyle',
802 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle',
803 'nineoldstyle', 'colon', 'semicolon', '', 'threequartersemdash', '',
804 'questionsmall', '', '', '', '', 'Ethsmall', '', '', 'onequarter',
805 'onehalf', 'threequarters', 'oneeighth', 'threeeighths', 'fiveeighths',
806 'seveneighths', 'onethird', 'twothirds', '', '', '', '', '', '', 'ff',
807 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', '', 'parenrightinferior',
808 'Circumflexsmall', 'hypheninferior', 'Gravesmall', 'Asmall', 'Bsmall',
809 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall',
810 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall',
811 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall',
812 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah',
813 'Tildesmall', '', '', 'asuperior', 'centsuperior', '', '', '', '',
814 'Aacutesmall', 'Agravesmall', 'Acircumflexsmall', 'Adieresissmall',
815 'Atildesmall', 'Aringsmall', 'Ccedillasmall', 'Eacutesmall', 'Egravesmall',
816 'Ecircumflexsmall', 'Edieresissmall', 'Iacutesmall', 'Igravesmall',
817 'Icircumflexsmall', 'Idieresissmall', 'Ntildesmall', 'Oacutesmall',
818 'Ogravesmall', 'Ocircumflexsmall', 'Odieresissmall', 'Otildesmall',
819 'Uacutesmall', 'Ugravesmall', 'Ucircumflexsmall', 'Udieresissmall', '',
820 'eightsuperior', 'fourinferior', 'threeinferior', 'sixinferior',
821 'eightinferior', 'seveninferior', 'Scaronsmall', '', 'centinferior',
822 'twoinferior', '', 'Dieresissmall', '', 'Caronsmall', 'osuperior',
823 'fiveinferior', '', 'commainferior', 'periodinferior', 'Yacutesmall', '',
824 'dollarinferior', '', 'Thornsmall', '', 'nineinferior', 'zeroinferior',
825 'Zcaronsmall', 'AEsmall', 'Oslashsmall', 'questiondownsmall',
826 'oneinferior', 'Lslashsmall', '', '', '', '', '', '', 'Cedillasmall', '',
827 '', '', '', '', 'OEsmall', 'figuredash', 'hyphensuperior', '', '', '', '',
828 'exclamdownsmall', '', 'Ydieresissmall', '', 'onesuperior', 'twosuperior',
829 'threesuperior', 'foursuperior', 'fivesuperior', 'sixsuperior',
830 'sevensuperior', 'ninesuperior', 'zerosuperior', '', 'esuperior',
831 'rsuperior', 'tsuperior', '', '', 'isuperior', 'ssuperior', 'dsuperior',
832 '', '', '', '', '', 'lsuperior', 'Ogoneksmall', 'Brevesmall',
833 'Macronsmall', 'bsuperior', 'nsuperior', 'msuperior', 'commasuperior',
834 'periodsuperior', 'Dotaccentsmall', 'Ringsmall'];
835
836 var MacRomanEncoding = [
837 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
838 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
839 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
840 'ampersand', 'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus',
841 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three',
842 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon',
843 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
844 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
845 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
846 'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
847 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
848 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', '',
849 'Adieresis', 'Aring', 'Ccedilla', 'Eacute', 'Ntilde', 'Odieresis',
850 'Udieresis', 'aacute', 'agrave', 'acircumflex', 'adieresis', 'atilde',
851 'aring', 'ccedilla', 'eacute', 'egrave', 'ecircumflex', 'edieresis',
852 'iacute', 'igrave', 'icircumflex', 'idieresis', 'ntilde', 'oacute',
853 'ograve', 'ocircumflex', 'odieresis', 'otilde', 'uacute', 'ugrave',
854 'ucircumflex', 'udieresis', 'dagger', 'degree', 'cent', 'sterling',
855 'section', 'bullet', 'paragraph', 'germandbls', 'registered', 'copyright',
856 'trademark', 'acute', 'dieresis', 'notequal', 'AE', 'Oslash', 'infinity',
857 'plusminus', 'lessequal', 'greaterequal', 'yen', 'mu', 'partialdiff',
858 'summation', 'product', 'pi', 'integral', 'ordfeminine', 'ordmasculine',
859 'Omega', 'ae', 'oslash', 'questiondown', 'exclamdown', 'logicalnot',
860 'radical', 'florin', 'approxequal', 'Delta', 'guillemotleft',
861 'guillemotright', 'ellipsis', 'space', 'Agrave', 'Atilde', 'Otilde', 'OE',
862 'oe', 'endash', 'emdash', 'quotedblleft', 'quotedblright', 'quoteleft',
863 'quoteright', 'divide', 'lozenge', 'ydieresis', 'Ydieresis', 'fraction',
864 'currency', 'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'daggerdbl',
865 'periodcentered', 'quotesinglbase', 'quotedblbase', 'perthousand',
866 'Acircumflex', 'Ecircumflex', 'Aacute', 'Edieresis', 'Egrave', 'Iacute',
867 'Icircumflex', 'Idieresis', 'Igrave', 'Oacute', 'Ocircumflex', 'apple',
868 'Ograve', 'Uacute', 'Ucircumflex', 'Ugrave', 'dotlessi', 'circumflex',
869 'tilde', 'macron', 'breve', 'dotaccent', 'ring', 'cedilla', 'hungarumlaut',
870 'ogonek', 'caron'];
871
872 var StandardEncoding = [
873 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
874 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
875 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
876 'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus',
877 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three',
878 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon',
879 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
880 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
881 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
882 'asciicircum', 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f',
883 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
884 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde',
885 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
886 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'exclamdown',
887 'cent', 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency',
888 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft',
889 'guilsinglright', 'fi', 'fl', '', 'endash', 'dagger', 'daggerdbl',
890 'periodcentered', '', 'paragraph', 'bullet', 'quotesinglbase',
891 'quotedblbase', 'quotedblright', 'guillemotright', 'ellipsis',
892 'perthousand', '', 'questiondown', '', 'grave', 'acute', 'circumflex',
893 'tilde', 'macron', 'breve', 'dotaccent', 'dieresis', '', 'ring', 'cedilla',
894 '', 'hungarumlaut', 'ogonek', 'caron', 'emdash', '', '', '', '', '', '',
895 '', '', '', '', '', '', '', '', '', '', 'AE', '', 'ordfeminine', '', '',
896 '', '', 'Lslash', 'Oslash', 'OE', 'ordmasculine', '', '', '', '', '', 'ae',
897 '', '', '', 'dotlessi', '', '', 'lslash', 'oslash', 'oe', 'germandbls'];
898
899 var WinAnsiEncoding = [
900 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
901 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
902 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
903 'ampersand', 'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus',
904 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three',
905 'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon',
906 'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
907 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
908 'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
909 'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
910 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
911 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde',
912 'bullet', 'Euro', 'bullet', 'quotesinglbase', 'florin', 'quotedblbase',
913 'ellipsis', 'dagger', 'daggerdbl', 'circumflex', 'perthousand', 'Scaron',
914 'guilsinglleft', 'OE', 'bullet', 'Zcaron', 'bullet', 'bullet', 'quoteleft',
915 'quoteright', 'quotedblleft', 'quotedblright', 'bullet', 'endash',
916 'emdash', 'tilde', 'trademark', 'scaron', 'guilsinglright', 'oe', 'bullet',
917 'zcaron', 'Ydieresis', 'space', 'exclamdown', 'cent', 'sterling',
918 'currency', 'yen', 'brokenbar', 'section', 'dieresis', 'copyright',
919 'ordfeminine', 'guillemotleft', 'logicalnot', 'hyphen', 'registered',
920 'macron', 'degree', 'plusminus', 'twosuperior', 'threesuperior', 'acute',
921 'mu', 'paragraph', 'periodcentered', 'cedilla', 'onesuperior',
922 'ordmasculine', 'guillemotright', 'onequarter', 'onehalf', 'threequarters',
923 'questiondown', 'Agrave', 'Aacute', 'Acircumflex', 'Atilde', 'Adieresis',
924 'Aring', 'AE', 'Ccedilla', 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
925 'Igrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Eth', 'Ntilde', 'Ograve',
926 'Oacute', 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply', 'Oslash',
927 'Ugrave', 'Uacute', 'Ucircumflex', 'Udieresis', 'Yacute', 'Thorn',
928 'germandbls', 'agrave', 'aacute', 'acircumflex', 'atilde', 'adieresis',
929 'aring', 'ae', 'ccedilla', 'egrave', 'eacute', 'ecircumflex', 'edieresis',
930 'igrave', 'iacute', 'icircumflex', 'idieresis', 'eth', 'ntilde', 'ograve',
931 'oacute', 'ocircumflex', 'otilde', 'odieresis', 'divide', 'oslash',
932 'ugrave', 'uacute', 'ucircumflex', 'udieresis', 'yacute', 'thorn',
933 'ydieresis'];
934
935 var SymbolSetEncoding = [
936 '', '', '', '', '', '', '', '', '', '', '', '', '', '',
937 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
938 'space', 'exclam', 'universal', 'numbersign', 'existential', 'percent',
939 'ampersand', 'suchthat', 'parenleft', 'parenright', 'asteriskmath', 'plus',
940 'comma', 'minus', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four',
941 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less',
942 'equal', 'greater', 'question', 'congruent', 'Alpha', 'Beta', 'Chi',
943 'Delta', 'Epsilon', 'Phi', 'Gamma', 'Eta', 'Iota', 'theta1', 'Kappa',
944 'Lambda', 'Mu', 'Nu', 'Omicron', 'Pi', 'Theta', 'Rho', 'Sigma', 'Tau',
945 'Upsilon', 'sigma1', 'Omega', 'Xi', 'Psi', 'Zeta', 'bracketleft',
946 'therefore', 'bracketright', 'perpendicular', 'underscore', 'radicalex',
947 'alpha', 'beta', 'chi', 'delta', 'epsilon', 'phi', 'gamma', 'eta', 'iota',
948 'phi1', 'kappa', 'lambda', 'mu', 'nu', 'omicron', 'pi', 'theta', 'rho',
949 'sigma', 'tau', 'upsilon', 'omega1', 'omega', 'xi', 'psi', 'zeta',
950 'braceleft', 'bar', 'braceright', 'similar', '', '', '', '', '', '', '',
951 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
952 '', '', '', '', '', '', '', 'Euro', 'Upsilon1', 'minute', 'lessequal',
953 'fraction', 'infinity', 'florin', 'club', 'diamond', 'heart', 'spade',
954 'arrowboth', 'arrowleft', 'arrowup', 'arrowright', 'arrowdown', 'degree',
955 'plusminus', 'second', 'greaterequal', 'multiply', 'proportional',
956 'partialdiff', 'bullet', 'divide', 'notequal', 'equivalence',
957 'approxequal', 'ellipsis', 'arrowvertex', 'arrowhorizex', 'carriagereturn',
958 'aleph', 'Ifraktur', 'Rfraktur', 'weierstrass', 'circlemultiply',
959 'circleplus', 'emptyset', 'intersection', 'union', 'propersuperset',
960 'reflexsuperset', 'notsubset', 'propersubset', 'reflexsubset', 'element',
961 'notelement', 'angle', 'gradient', 'registerserif', 'copyrightserif',
962 'trademarkserif', 'product', 'radical', 'dotmath', 'logicalnot',
963 'logicaland', 'logicalor', 'arrowdblboth', 'arrowdblleft', 'arrowdblup',
964 'arrowdblright', 'arrowdbldown', 'lozenge', 'angleleft', 'registersans',
965 'copyrightsans', 'trademarksans', 'summation', 'parenlefttp',
966 'parenleftex', 'parenleftbt', 'bracketlefttp', 'bracketleftex',
967 'bracketleftbt', 'bracelefttp', 'braceleftmid', 'braceleftbt', 'braceex',
968 '', 'angleright', 'integral', 'integraltp', 'integralex', 'integralbt',
969 'parenrighttp', 'parenrightex', 'parenrightbt', 'bracketrighttp',
970 'bracketrightex', 'bracketrightbt', 'bracerighttp', 'bracerightmid',
971 'bracerightbt'];
972
973 var ZapfDingbatsEncoding = [
974 '', '', '', '', '', '', '', '', '', '', '', '', '', '',
975 '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
976 'space', 'a1', 'a2', 'a202', 'a3', 'a4', 'a5', 'a119', 'a118', 'a117',
977 'a11', 'a12', 'a13', 'a14', 'a15', 'a16', 'a105', 'a17', 'a18', 'a19',
978 'a20', 'a21', 'a22', 'a23', 'a24', 'a25', 'a26', 'a27', 'a28', 'a6', 'a7',
979 'a8', 'a9', 'a10', 'a29', 'a30', 'a31', 'a32', 'a33', 'a34', 'a35', 'a36',
980 'a37', 'a38', 'a39', 'a40', 'a41', 'a42', 'a43', 'a44', 'a45', 'a46',
981 'a47', 'a48', 'a49', 'a50', 'a51', 'a52', 'a53', 'a54', 'a55', 'a56',
982 'a57', 'a58', 'a59', 'a60', 'a61', 'a62', 'a63', 'a64', 'a65', 'a66',
983 'a67', 'a68', 'a69', 'a70', 'a71', 'a72', 'a73', 'a74', 'a203', 'a75',
984 'a204', 'a76', 'a77', 'a78', 'a79', 'a81', 'a82', 'a83', 'a84', 'a97',
985 'a98', 'a99', 'a100', '', 'a89', 'a90', 'a93', 'a94', 'a91', 'a92', 'a205',
986 'a85', 'a206', 'a86', 'a87', 'a88', 'a95', 'a96', '', '', '', '', '', '',
987 '', '', '', '', '', '', '', '', '', '', '', '', '', 'a101', 'a102', 'a103',
988 'a104', 'a106', 'a107', 'a108', 'a112', 'a111', 'a110', 'a109', 'a120',
989 'a121', 'a122', 'a123', 'a124', 'a125', 'a126', 'a127', 'a128', 'a129',
990 'a130', 'a131', 'a132', 'a133', 'a134', 'a135', 'a136', 'a137', 'a138',
991 'a139', 'a140', 'a141', 'a142', 'a143', 'a144', 'a145', 'a146', 'a147',
992 'a148', 'a149', 'a150', 'a151', 'a152', 'a153', 'a154', 'a155', 'a156',
993 'a157', 'a158', 'a159', 'a160', 'a161', 'a163', 'a164', 'a196', 'a165',
994 'a192', 'a166', 'a167', 'a168', 'a169', 'a170', 'a171', 'a172', 'a173',
995 'a162', 'a174', 'a175', 'a176', 'a177', 'a178', 'a179', 'a193', 'a180',
996 'a199', 'a181', 'a200', 'a182', '', 'a201', 'a183', 'a184', 'a197', 'a185',
997 'a194', 'a198', 'a186', 'a195', 'a187', 'a188', 'a189', 'a190', 'a191'];
998
999 function getEncoding(encodingName) {
1000 switch (encodingName) {
1001 case 'WinAnsiEncoding':
1002 return WinAnsiEncoding;
1003 case 'StandardEncoding':
1004 return StandardEncoding;
1005 case 'MacRomanEncoding':
1006 return MacRomanEncoding;
1007 case 'SymbolSetEncoding':
1008 return SymbolSetEncoding;
1009 case 'ZapfDingbatsEncoding':
1010 return ZapfDingbatsEncoding;
1011 case 'ExpertEncoding':
1012 return ExpertEncoding;
1013 case 'MacExpertEncoding':
1014 return MacExpertEncoding;
1015 default:
1016 return null;
1017 }
1018 }
1019
1020 exports.WinAnsiEncoding = WinAnsiEncoding;
1021 exports.StandardEncoding = StandardEncoding;
1022 exports.MacRomanEncoding = MacRomanEncoding;
1023 exports.SymbolSetEncoding = SymbolSetEncoding;
1024 exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
1025 exports.ExpertEncoding = ExpertEncoding;
1026 exports.getEncoding = getEncoding;
1027}));
1028
1029
1030(function (root, factory) {
1031 {
1032 factory((root.pdfjsSharedUtil = {}));
1033 }
1034}(this, function (exports) {
1035
1036var globalScope = (typeof window !== 'undefined') ? window :
1037 (typeof global !== 'undefined') ? global :
1038 (typeof self !== 'undefined') ? self : this;
1039
1040var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
1041
1042var TextRenderingMode = {
1043 FILL: 0,
1044 STROKE: 1,
1045 FILL_STROKE: 2,
1046 INVISIBLE: 3,
1047 FILL_ADD_TO_PATH: 4,
1048 STROKE_ADD_TO_PATH: 5,
1049 FILL_STROKE_ADD_TO_PATH: 6,
1050 ADD_TO_PATH: 7,
1051 FILL_STROKE_MASK: 3,
1052 ADD_TO_PATH_FLAG: 4
1053};
1054
1055var ImageKind = {
1056 GRAYSCALE_1BPP: 1,
1057 RGB_24BPP: 2,
1058 RGBA_32BPP: 3
1059};
1060
1061var AnnotationType = {
1062 TEXT: 1,
1063 LINK: 2,
1064 FREETEXT: 3,
1065 LINE: 4,
1066 SQUARE: 5,
1067 CIRCLE: 6,
1068 POLYGON: 7,
1069 POLYLINE: 8,
1070 HIGHLIGHT: 9,
1071 UNDERLINE: 10,
1072 SQUIGGLY: 11,
1073 STRIKEOUT: 12,
1074 STAMP: 13,
1075 CARET: 14,
1076 INK: 15,
1077 POPUP: 16,
1078 FILEATTACHMENT: 17,
1079 SOUND: 18,
1080 MOVIE: 19,
1081 WIDGET: 20,
1082 SCREEN: 21,
1083 PRINTERMARK: 22,
1084 TRAPNET: 23,
1085 WATERMARK: 24,
1086 THREED: 25,
1087 REDACT: 26
1088};
1089
1090var AnnotationFlag = {
1091 INVISIBLE: 0x01,
1092 HIDDEN: 0x02,
1093 PRINT: 0x04,
1094 NOZOOM: 0x08,
1095 NOROTATE: 0x10,
1096 NOVIEW: 0x20,
1097 READONLY: 0x40,
1098 LOCKED: 0x80,
1099 TOGGLENOVIEW: 0x100,
1100 LOCKEDCONTENTS: 0x200
1101};
1102
1103var AnnotationFieldFlag = {
1104 READONLY: 0x0000001,
1105 REQUIRED: 0x0000002,
1106 NOEXPORT: 0x0000004,
1107 MULTILINE: 0x0001000,
1108 PASSWORD: 0x0002000,
1109 NOTOGGLETOOFF: 0x0004000,
1110 RADIO: 0x0008000,
1111 PUSHBUTTON: 0x0010000,
1112 COMBO: 0x0020000,
1113 EDIT: 0x0040000,
1114 SORT: 0x0080000,
1115 FILESELECT: 0x0100000,
1116 MULTISELECT: 0x0200000,
1117 DONOTSPELLCHECK: 0x0400000,
1118 DONOTSCROLL: 0x0800000,
1119 COMB: 0x1000000,
1120 RICHTEXT: 0x2000000,
1121 RADIOSINUNISON: 0x2000000,
1122 COMMITONSELCHANGE: 0x4000000,
1123};
1124
1125var AnnotationBorderStyleType = {
1126 SOLID: 1,
1127 DASHED: 2,
1128 BEVELED: 3,
1129 INSET: 4,
1130 UNDERLINE: 5
1131};
1132
1133var StreamType = {
1134 UNKNOWN: 0,
1135 FLATE: 1,
1136 LZW: 2,
1137 DCT: 3,
1138 JPX: 4,
1139 JBIG: 5,
1140 A85: 6,
1141 AHX: 7,
1142 CCF: 8,
1143 RL: 9
1144};
1145
1146var FontType = {
1147 UNKNOWN: 0,
1148 TYPE1: 1,
1149 TYPE1C: 2,
1150 CIDFONTTYPE0: 3,
1151 CIDFONTTYPE0C: 4,
1152 TRUETYPE: 5,
1153 CIDFONTTYPE2: 6,
1154 TYPE3: 7,
1155 OPENTYPE: 8,
1156 TYPE0: 9,
1157 MMTYPE1: 10
1158};
1159
1160var VERBOSITY_LEVELS = {
1161 errors: 0,
1162 warnings: 1,
1163 infos: 5
1164};
1165
1166// All the possible operations for an operator list.
1167var OPS = {
1168 // Intentionally start from 1 so it is easy to spot bad operators that will be
1169 // 0's.
1170 dependency: 1,
1171 setLineWidth: 2,
1172 setLineCap: 3,
1173 setLineJoin: 4,
1174 setMiterLimit: 5,
1175 setDash: 6,
1176 setRenderingIntent: 7,
1177 setFlatness: 8,
1178 setGState: 9,
1179 save: 10,
1180 restore: 11,
1181 transform: 12,
1182 moveTo: 13,
1183 lineTo: 14,
1184 curveTo: 15,
1185 curveTo2: 16,
1186 curveTo3: 17,
1187 closePath: 18,
1188 rectangle: 19,
1189 stroke: 20,
1190 closeStroke: 21,
1191 fill: 22,
1192 eoFill: 23,
1193 fillStroke: 24,
1194 eoFillStroke: 25,
1195 closeFillStroke: 26,
1196 closeEOFillStroke: 27,
1197 endPath: 28,
1198 clip: 29,
1199 eoClip: 30,
1200 beginText: 31,
1201 endText: 32,
1202 setCharSpacing: 33,
1203 setWordSpacing: 34,
1204 setHScale: 35,
1205 setLeading: 36,
1206 setFont: 37,
1207 setTextRenderingMode: 38,
1208 setTextRise: 39,
1209 moveText: 40,
1210 setLeadingMoveText: 41,
1211 setTextMatrix: 42,
1212 nextLine: 43,
1213 showText: 44,
1214 showSpacedText: 45,
1215 nextLineShowText: 46,
1216 nextLineSetSpacingShowText: 47,
1217 setCharWidth: 48,
1218 setCharWidthAndBounds: 49,
1219 setStrokeColorSpace: 50,
1220 setFillColorSpace: 51,
1221 setStrokeColor: 52,
1222 setStrokeColorN: 53,
1223 setFillColor: 54,
1224 setFillColorN: 55,
1225 setStrokeGray: 56,
1226 setFillGray: 57,
1227 setStrokeRGBColor: 58,
1228 setFillRGBColor: 59,
1229 setStrokeCMYKColor: 60,
1230 setFillCMYKColor: 61,
1231 shadingFill: 62,
1232 beginInlineImage: 63,
1233 beginImageData: 64,
1234 endInlineImage: 65,
1235 paintXObject: 66,
1236 markPoint: 67,
1237 markPointProps: 68,
1238 beginMarkedContent: 69,
1239 beginMarkedContentProps: 70,
1240 endMarkedContent: 71,
1241 beginCompat: 72,
1242 endCompat: 73,
1243 paintFormXObjectBegin: 74,
1244 paintFormXObjectEnd: 75,
1245 beginGroup: 76,
1246 endGroup: 77,
1247 beginAnnotations: 78,
1248 endAnnotations: 79,
1249 beginAnnotation: 80,
1250 endAnnotation: 81,
1251 paintJpegXObject: 82,
1252 paintImageMaskXObject: 83,
1253 paintImageMaskXObjectGroup: 84,
1254 paintImageXObject: 85,
1255 paintInlineImageXObject: 86,
1256 paintInlineImageXObjectGroup: 87,
1257 paintImageXObjectRepeat: 88,
1258 paintImageMaskXObjectRepeat: 89,
1259 paintSolidColorImageMask: 90,
1260 constructPath: 91
1261};
1262
1263var verbosity = VERBOSITY_LEVELS.warnings;
1264
1265function setVerbosityLevel(level) {
1266 verbosity = level;
1267}
1268
1269function getVerbosityLevel() {
1270 return verbosity;
1271}
1272
1273// A notice for devs. These are good for things that are helpful to devs, such
1274// as warning that Workers were disabled, which is important to devs but not
1275// end users.
1276function info(msg) {
1277 if (verbosity >= VERBOSITY_LEVELS.infos) {
1278 console.log('Info: ' + msg);
1279 }
1280}
1281
1282// Non-fatal warnings.
1283function warn(msg) {
1284 if (verbosity >= VERBOSITY_LEVELS.warnings) {
1285 console.log('Warning: ' + msg);
1286 }
1287}
1288
1289// Deprecated API function -- display regardless of the PDFJS.verbosity setting.
1290function deprecated(details) {
1291 console.log('Deprecated API usage: ' + details);
1292}
1293
1294// Fatal errors that should trigger the fallback UI and halt execution by
1295// throwing an exception.
1296function error(msg) {
1297 if (verbosity >= VERBOSITY_LEVELS.errors) {
1298 console.log('Error: ' + msg);
1299 console.log(backtrace());
1300 }
1301 throw new Error(msg);
1302}
1303
1304function backtrace() {
1305 try {
1306 throw new Error();
1307 } catch (e) {
1308 return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
1309 }
1310}
1311
1312function assert(cond, msg) {
1313 if (!cond) {
1314 error(msg);
1315 }
1316}
1317
1318var UNSUPPORTED_FEATURES = {
1319 unknown: 'unknown',
1320 forms: 'forms',
1321 javaScript: 'javaScript',
1322 smask: 'smask',
1323 shadingPattern: 'shadingPattern',
1324 font: 'font'
1325};
1326
1327// Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
1328function isSameOrigin(baseUrl, otherUrl) {
1329 try {
1330 var base = new URL(baseUrl);
1331 if (!base.origin || base.origin === 'null') {
1332 return false; // non-HTTP url
1333 }
1334 } catch (e) {
1335 return false;
1336 }
1337
1338 var other = new URL(otherUrl, base);
1339 return base.origin === other.origin;
1340}
1341
1342// Validates if URL is safe and allowed, e.g. to avoid XSS.
1343function isValidUrl(url, allowRelative) {
1344 if (!url || typeof url !== 'string') {
1345 return false;
1346 }
1347 // RFC 3986 (http://tools.ietf.org/html/rfc3986#section-3.1)
1348 // scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
1349 var protocol = /^[a-z][a-z0-9+\-.]*(?=:)/i.exec(url);
1350 if (!protocol) {
1351 return allowRelative;
1352 }
1353 protocol = protocol[0].toLowerCase();
1354 switch (protocol) {
1355 case 'http':
1356 case 'https':
1357 case 'ftp':
1358 case 'mailto':
1359 case 'tel':
1360 return true;
1361 default:
1362 return false;
1363 }
1364}
1365
1366function shadow(obj, prop, value) {
1367 Object.defineProperty(obj, prop, { value: value,
1368 enumerable: true,
1369 configurable: true,
1370 writable: false });
1371 return value;
1372}
1373
1374function getLookupTableFactory(initializer) {
1375 var lookup;
1376 return function () {
1377 if (initializer) {
1378 lookup = Object.create(null);
1379 initializer(lookup);
1380 initializer = null;
1381 }
1382 return lookup;
1383 };
1384}
1385
1386var PasswordResponses = {
1387 NEED_PASSWORD: 1,
1388 INCORRECT_PASSWORD: 2
1389};
1390
1391var PasswordException = (function PasswordExceptionClosure() {
1392 function PasswordException(msg, code) {
1393 this.name = 'PasswordException';
1394 this.message = msg;
1395 this.code = code;
1396 }
1397
1398 PasswordException.prototype = new Error();
1399 PasswordException.constructor = PasswordException;
1400
1401 return PasswordException;
1402})();
1403
1404var UnknownErrorException = (function UnknownErrorExceptionClosure() {
1405 function UnknownErrorException(msg, details) {
1406 this.name = 'UnknownErrorException';
1407 this.message = msg;
1408 this.details = details;
1409 }
1410
1411 UnknownErrorException.prototype = new Error();
1412 UnknownErrorException.constructor = UnknownErrorException;
1413
1414 return UnknownErrorException;
1415})();
1416
1417var InvalidPDFException = (function InvalidPDFExceptionClosure() {
1418 function InvalidPDFException(msg) {
1419 this.name = 'InvalidPDFException';
1420 this.message = msg;
1421 }
1422
1423 InvalidPDFException.prototype = new Error();
1424 InvalidPDFException.constructor = InvalidPDFException;
1425
1426 return InvalidPDFException;
1427})();
1428
1429var MissingPDFException = (function MissingPDFExceptionClosure() {
1430 function MissingPDFException(msg) {
1431 this.name = 'MissingPDFException';
1432 this.message = msg;
1433 }
1434
1435 MissingPDFException.prototype = new Error();
1436 MissingPDFException.constructor = MissingPDFException;
1437
1438 return MissingPDFException;
1439})();
1440
1441var UnexpectedResponseException =
1442 (function UnexpectedResponseExceptionClosure() {
1443 function UnexpectedResponseException(msg, status) {
1444 this.name = 'UnexpectedResponseException';
1445 this.message = msg;
1446 this.status = status;
1447 }
1448
1449 UnexpectedResponseException.prototype = new Error();
1450 UnexpectedResponseException.constructor = UnexpectedResponseException;
1451
1452 return UnexpectedResponseException;
1453})();
1454
1455var NotImplementedException = (function NotImplementedExceptionClosure() {
1456 function NotImplementedException(msg) {
1457 this.message = msg;
1458 }
1459
1460 NotImplementedException.prototype = new Error();
1461 NotImplementedException.prototype.name = 'NotImplementedException';
1462 NotImplementedException.constructor = NotImplementedException;
1463
1464 return NotImplementedException;
1465})();
1466
1467var MissingDataException = (function MissingDataExceptionClosure() {
1468 function MissingDataException(begin, end) {
1469 this.begin = begin;
1470 this.end = end;
1471 this.message = 'Missing data [' + begin + ', ' + end + ')';
1472 }
1473
1474 MissingDataException.prototype = new Error();
1475 MissingDataException.prototype.name = 'MissingDataException';
1476 MissingDataException.constructor = MissingDataException;
1477
1478 return MissingDataException;
1479})();
1480
1481var XRefParseException = (function XRefParseExceptionClosure() {
1482 function XRefParseException(msg) {
1483 this.message = msg;
1484 }
1485
1486 XRefParseException.prototype = new Error();
1487 XRefParseException.prototype.name = 'XRefParseException';
1488 XRefParseException.constructor = XRefParseException;
1489
1490 return XRefParseException;
1491})();
1492
1493var NullCharactersRegExp = /\x00/g;
1494
1495function removeNullCharacters(str) {
1496 if (typeof str !== 'string') {
1497 warn('The argument for removeNullCharacters must be a string.');
1498 return str;
1499 }
1500 return str.replace(NullCharactersRegExp, '');
1501}
1502
1503function bytesToString(bytes) {
1504 assert(bytes !== null && typeof bytes === 'object' &&
1505 bytes.length !== undefined, 'Invalid argument for bytesToString');
1506 var length = bytes.length;
1507 var MAX_ARGUMENT_COUNT = 8192;
1508 if (length < MAX_ARGUMENT_COUNT) {
1509 return String.fromCharCode.apply(null, bytes);
1510 }
1511 var strBuf = [];
1512 for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
1513 var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
1514 var chunk = bytes.subarray(i, chunkEnd);
1515 strBuf.push(String.fromCharCode.apply(null, chunk));
1516 }
1517 return strBuf.join('');
1518}
1519
1520function stringToBytes(str) {
1521 assert(typeof str === 'string', 'Invalid argument for stringToBytes');
1522 var length = str.length;
1523 var bytes = new Uint8Array(length);
1524 for (var i = 0; i < length; ++i) {
1525 bytes[i] = str.charCodeAt(i) & 0xFF;
1526 }
1527 return bytes;
1528}
1529
1530/**
1531 * Gets length of the array (Array, Uint8Array, or string) in bytes.
1532 * @param {Array|Uint8Array|string} arr
1533 * @returns {number}
1534 */
1535function arrayByteLength(arr) {
1536 if (arr.length !== undefined) {
1537 return arr.length;
1538 }
1539 assert(arr.byteLength !== undefined);
1540 return arr.byteLength;
1541}
1542
1543/**
1544 * Combines array items (arrays) into single Uint8Array object.
1545 * @param {Array} arr - the array of the arrays (Array, Uint8Array, or string).
1546 * @returns {Uint8Array}
1547 */
1548function arraysToBytes(arr) {
1549 // Shortcut: if first and only item is Uint8Array, return it.
1550 if (arr.length === 1 && (arr[0] instanceof Uint8Array)) {
1551 return arr[0];
1552 }
1553 var resultLength = 0;
1554 var i, ii = arr.length;
1555 var item, itemLength ;
1556 for (i = 0; i < ii; i++) {
1557 item = arr[i];
1558 itemLength = arrayByteLength(item);
1559 resultLength += itemLength;
1560 }
1561 var pos = 0;
1562 var data = new Uint8Array(resultLength);
1563 for (i = 0; i < ii; i++) {
1564 item = arr[i];
1565 if (!(item instanceof Uint8Array)) {
1566 if (typeof item === 'string') {
1567 item = stringToBytes(item);
1568 } else {
1569 item = new Uint8Array(item);
1570 }
1571 }
1572 itemLength = item.byteLength;
1573 data.set(item, pos);
1574 pos += itemLength;
1575 }
1576 return data;
1577}
1578
1579function string32(value) {
1580 return String.fromCharCode((value >> 24) & 0xff, (value >> 16) & 0xff,
1581 (value >> 8) & 0xff, value & 0xff);
1582}
1583
1584function log2(x) {
1585 var n = 1, i = 0;
1586 while (x > n) {
1587 n <<= 1;
1588 i++;
1589 }
1590 return i;
1591}
1592
1593function readInt8(data, start) {
1594 return (data[start] << 24) >> 24;
1595}
1596
1597function readUint16(data, offset) {
1598 return (data[offset] << 8) | data[offset + 1];
1599}
1600
1601function readUint32(data, offset) {
1602 return ((data[offset] << 24) | (data[offset + 1] << 16) |
1603 (data[offset + 2] << 8) | data[offset + 3]) >>> 0;
1604}
1605
1606// Lazy test the endianness of the platform
1607// NOTE: This will be 'true' for simulated TypedArrays
1608function isLittleEndian() {
1609 var buffer8 = new Uint8Array(2);
1610 buffer8[0] = 1;
1611 var buffer16 = new Uint16Array(buffer8.buffer);
1612 return (buffer16[0] === 1);
1613}
1614
1615// Checks if it's possible to eval JS expressions.
1616function isEvalSupported() {
1617 try {
1618 /* jshint evil: true */
1619 new Function('');
1620 return true;
1621 } catch (e) {
1622 return false;
1623 }
1624}
1625
1626var Uint32ArrayView = (function Uint32ArrayViewClosure() {
1627
1628 function Uint32ArrayView(buffer, length) {
1629 this.buffer = buffer;
1630 this.byteLength = buffer.length;
1631 this.length = length === undefined ? (this.byteLength >> 2) : length;
1632 ensureUint32ArrayViewProps(this.length);
1633 }
1634 Uint32ArrayView.prototype = Object.create(null);
1635
1636 var uint32ArrayViewSetters = 0;
1637 function createUint32ArrayProp(index) {
1638 return {
1639 get: function () {
1640 var buffer = this.buffer, offset = index << 2;
1641 return (buffer[offset] | (buffer[offset + 1] << 8) |
1642 (buffer[offset + 2] << 16) | (buffer[offset + 3] << 24)) >>> 0;
1643 },
1644 set: function (value) {
1645 var buffer = this.buffer, offset = index << 2;
1646 buffer[offset] = value & 255;
1647 buffer[offset + 1] = (value >> 8) & 255;
1648 buffer[offset + 2] = (value >> 16) & 255;
1649 buffer[offset + 3] = (value >>> 24) & 255;
1650 }
1651 };
1652 }
1653
1654 function ensureUint32ArrayViewProps(length) {
1655 while (uint32ArrayViewSetters < length) {
1656 Object.defineProperty(Uint32ArrayView.prototype,
1657 uint32ArrayViewSetters,
1658 createUint32ArrayProp(uint32ArrayViewSetters));
1659 uint32ArrayViewSetters++;
1660 }
1661 }
1662
1663 return Uint32ArrayView;
1664})();
1665
1666exports.Uint32ArrayView = Uint32ArrayView;
1667
1668var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
1669
1670var Util = (function UtilClosure() {
1671 function Util() {}
1672
1673 var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
1674
1675 // makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
1676 // creating many intermediate strings.
1677 Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
1678 rgbBuf[1] = r;
1679 rgbBuf[3] = g;
1680 rgbBuf[5] = b;
1681 return rgbBuf.join('');
1682 };
1683
1684 // Concatenates two transformation matrices together and returns the result.
1685 Util.transform = function Util_transform(m1, m2) {
1686 return [
1687 m1[0] * m2[0] + m1[2] * m2[1],
1688 m1[1] * m2[0] + m1[3] * m2[1],
1689 m1[0] * m2[2] + m1[2] * m2[3],
1690 m1[1] * m2[2] + m1[3] * m2[3],
1691 m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
1692 m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
1693 ];
1694 };
1695
1696 // For 2d affine transforms
1697 Util.applyTransform = function Util_applyTransform(p, m) {
1698 var xt = p[0] * m[0] + p[1] * m[2] + m[4];
1699 var yt = p[0] * m[1] + p[1] * m[3] + m[5];
1700 return [xt, yt];
1701 };
1702
1703 Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
1704 var d = m[0] * m[3] - m[1] * m[2];
1705 var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
1706 var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
1707 return [xt, yt];
1708 };
1709
1710 // Applies the transform to the rectangle and finds the minimum axially
1711 // aligned bounding box.
1712 Util.getAxialAlignedBoundingBox =
1713 function Util_getAxialAlignedBoundingBox(r, m) {
1714
1715 var p1 = Util.applyTransform(r, m);
1716 var p2 = Util.applyTransform(r.slice(2, 4), m);
1717 var p3 = Util.applyTransform([r[0], r[3]], m);
1718 var p4 = Util.applyTransform([r[2], r[1]], m);
1719 return [
1720 Math.min(p1[0], p2[0], p3[0], p4[0]),
1721 Math.min(p1[1], p2[1], p3[1], p4[1]),
1722 Math.max(p1[0], p2[0], p3[0], p4[0]),
1723 Math.max(p1[1], p2[1], p3[1], p4[1])
1724 ];
1725 };
1726
1727 Util.inverseTransform = function Util_inverseTransform(m) {
1728 var d = m[0] * m[3] - m[1] * m[2];
1729 return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d,
1730 (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
1731 };
1732
1733 // Apply a generic 3d matrix M on a 3-vector v:
1734 // | a b c | | X |
1735 // | d e f | x | Y |
1736 // | g h i | | Z |
1737 // M is assumed to be serialized as [a,b,c,d,e,f,g,h,i],
1738 // with v as [X,Y,Z]
1739 Util.apply3dTransform = function Util_apply3dTransform(m, v) {
1740 return [
1741 m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
1742 m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
1743 m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
1744 ];
1745 };
1746
1747 // This calculation uses Singular Value Decomposition.
1748 // The SVD can be represented with formula A = USV. We are interested in the
1749 // matrix S here because it represents the scale values.
1750 Util.singularValueDecompose2dScale =
1751 function Util_singularValueDecompose2dScale(m) {
1752
1753 var transpose = [m[0], m[2], m[1], m[3]];
1754
1755 // Multiply matrix m with its transpose.
1756 var a = m[0] * transpose[0] + m[1] * transpose[2];
1757 var b = m[0] * transpose[1] + m[1] * transpose[3];
1758 var c = m[2] * transpose[0] + m[3] * transpose[2];
1759 var d = m[2] * transpose[1] + m[3] * transpose[3];
1760
1761 // Solve the second degree polynomial to get roots.
1762 var first = (a + d) / 2;
1763 var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
1764 var sx = first + second || 1;
1765 var sy = first - second || 1;
1766
1767 // Scale values are the square roots of the eigenvalues.
1768 return [Math.sqrt(sx), Math.sqrt(sy)];
1769 };
1770
1771 // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
1772 // For coordinate systems whose origin lies in the bottom-left, this
1773 // means normalization to (BL,TR) ordering. For systems with origin in the
1774 // top-left, this means (TL,BR) ordering.
1775 Util.normalizeRect = function Util_normalizeRect(rect) {
1776 var r = rect.slice(0); // clone rect
1777 if (rect[0] > rect[2]) {
1778 r[0] = rect[2];
1779 r[2] = rect[0];
1780 }
1781 if (rect[1] > rect[3]) {
1782 r[1] = rect[3];
1783 r[3] = rect[1];
1784 }
1785 return r;
1786 };
1787
1788 // Returns a rectangle [x1, y1, x2, y2] corresponding to the
1789 // intersection of rect1 and rect2. If no intersection, returns 'false'
1790 // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
1791 Util.intersect = function Util_intersect(rect1, rect2) {
1792 function compare(a, b) {
1793 return a - b;
1794 }
1795
1796 // Order points along the axes
1797 var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
1798 orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
1799 result = [];
1800
1801 rect1 = Util.normalizeRect(rect1);
1802 rect2 = Util.normalizeRect(rect2);
1803
1804 // X: first and second points belong to different rectangles?
1805 if ((orderedX[0] === rect1[0] && orderedX[1] === rect2[0]) ||
1806 (orderedX[0] === rect2[0] && orderedX[1] === rect1[0])) {
1807 // Intersection must be between second and third points
1808 result[0] = orderedX[1];
1809 result[2] = orderedX[2];
1810 } else {
1811 return false;
1812 }
1813
1814 // Y: first and second points belong to different rectangles?
1815 if ((orderedY[0] === rect1[1] && orderedY[1] === rect2[1]) ||
1816 (orderedY[0] === rect2[1] && orderedY[1] === rect1[1])) {
1817 // Intersection must be between second and third points
1818 result[1] = orderedY[1];
1819 result[3] = orderedY[2];
1820 } else {
1821 return false;
1822 }
1823
1824 return result;
1825 };
1826
1827 Util.sign = function Util_sign(num) {
1828 return num < 0 ? -1 : 1;
1829 };
1830
1831 var ROMAN_NUMBER_MAP = [
1832 '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM',
1833 '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC',
1834 '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'
1835 ];
1836 /**
1837 * Converts positive integers to (upper case) Roman numerals.
1838 * @param {integer} number - The number that should be converted.
1839 * @param {boolean} lowerCase - Indicates if the result should be converted
1840 * to lower case letters. The default is false.
1841 * @return {string} The resulting Roman number.
1842 */
1843 Util.toRoman = function Util_toRoman(number, lowerCase) {
1844 assert(isInt(number) && number > 0,
1845 'The number should be a positive integer.');
1846 var pos, romanBuf = [];
1847 // Thousands
1848 while (number >= 1000) {
1849 number -= 1000;
1850 romanBuf.push('M');
1851 }
1852 // Hundreds
1853 pos = (number / 100) | 0;
1854 number %= 100;
1855 romanBuf.push(ROMAN_NUMBER_MAP[pos]);
1856 // Tens
1857 pos = (number / 10) | 0;
1858 number %= 10;
1859 romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
1860 // Ones
1861 romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
1862
1863 var romanStr = romanBuf.join('');
1864 return (lowerCase ? romanStr.toLowerCase() : romanStr);
1865 };
1866
1867 Util.appendToArray = function Util_appendToArray(arr1, arr2) {
1868 Array.prototype.push.apply(arr1, arr2);
1869 };
1870
1871 Util.prependToArray = function Util_prependToArray(arr1, arr2) {
1872 Array.prototype.unshift.apply(arr1, arr2);
1873 };
1874
1875 Util.extendObj = function extendObj(obj1, obj2) {
1876 for (var key in obj2) {
1877 obj1[key] = obj2[key];
1878 }
1879 };
1880
1881 Util.getInheritableProperty = function Util_getInheritableProperty(dict,
1882 name) {
1883 while (dict && !dict.has(name)) {
1884 dict = dict.get('Parent');
1885 }
1886 if (!dict) {
1887 return null;
1888 }
1889 return dict.get(name);
1890 };
1891
1892 Util.inherit = function Util_inherit(sub, base, prototype) {
1893 sub.prototype = Object.create(base.prototype);
1894 sub.prototype.constructor = sub;
1895 for (var prop in prototype) {
1896 sub.prototype[prop] = prototype[prop];
1897 }
1898 };
1899
1900 Util.loadScript = function Util_loadScript(src, callback) {
1901 var script = document.createElement('script');
1902 var loaded = false;
1903 script.setAttribute('src', src);
1904 if (callback) {
1905 script.onload = function() {
1906 if (!loaded) {
1907 callback();
1908 }
1909 loaded = true;
1910 };
1911 }
1912 document.getElementsByTagName('head')[0].appendChild(script);
1913 };
1914
1915 return Util;
1916})();
1917
1918/**
1919 * PDF page viewport created based on scale, rotation and offset.
1920 * @class
1921 * @alias PageViewport
1922 */
1923var PageViewport = (function PageViewportClosure() {
1924 /**
1925 * @constructor
1926 * @private
1927 * @param viewBox {Array} xMin, yMin, xMax and yMax coordinates.
1928 * @param scale {number} scale of the viewport.
1929 * @param rotation {number} rotations of the viewport in degrees.
1930 * @param offsetX {number} offset X
1931 * @param offsetY {number} offset Y
1932 * @param dontFlip {boolean} if true, axis Y will not be flipped.
1933 */
1934 function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
1935 this.viewBox = viewBox;
1936 this.scale = scale;
1937 this.rotation = rotation;
1938 this.offsetX = offsetX;
1939 this.offsetY = offsetY;
1940
1941 // creating transform to convert pdf coordinate system to the normal
1942 // canvas like coordinates taking in account scale and rotation
1943 var centerX = (viewBox[2] + viewBox[0]) / 2;
1944 var centerY = (viewBox[3] + viewBox[1]) / 2;
1945 var rotateA, rotateB, rotateC, rotateD;
1946 rotation = rotation % 360;
1947 rotation = rotation < 0 ? rotation + 360 : rotation;
1948 switch (rotation) {
1949 case 180:
1950 rotateA = -1; rotateB = 0; rotateC = 0; rotateD = 1;
1951 break;
1952 case 90:
1953 rotateA = 0; rotateB = 1; rotateC = 1; rotateD = 0;
1954 break;
1955 case 270:
1956 rotateA = 0; rotateB = -1; rotateC = -1; rotateD = 0;
1957 break;
1958 //case 0:
1959 default:
1960 rotateA = 1; rotateB = 0; rotateC = 0; rotateD = -1;
1961 break;
1962 }
1963
1964 if (dontFlip) {
1965 rotateC = -rotateC; rotateD = -rotateD;
1966 }
1967
1968 var offsetCanvasX, offsetCanvasY;
1969 var width, height;
1970 if (rotateA === 0) {
1971 offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
1972 offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
1973 width = Math.abs(viewBox[3] - viewBox[1]) * scale;
1974 height = Math.abs(viewBox[2] - viewBox[0]) * scale;
1975 } else {
1976 offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
1977 offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
1978 width = Math.abs(viewBox[2] - viewBox[0]) * scale;
1979 height = Math.abs(viewBox[3] - viewBox[1]) * scale;
1980 }
1981 // creating transform for the following operations:
1982 // translate(-centerX, -centerY), rotate and flip vertically,
1983 // scale, and translate(offsetCanvasX, offsetCanvasY)
1984 this.transform = [
1985 rotateA * scale,
1986 rotateB * scale,
1987 rotateC * scale,
1988 rotateD * scale,
1989 offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
1990 offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
1991 ];
1992
1993 this.width = width;
1994 this.height = height;
1995 this.fontScale = scale;
1996 }
1997 PageViewport.prototype = /** @lends PageViewport.prototype */ {
1998 /**
1999 * Clones viewport with additional properties.
2000 * @param args {Object} (optional) If specified, may contain the 'scale' or
2001 * 'rotation' properties to override the corresponding properties in
2002 * the cloned viewport.
2003 * @returns {PageViewport} Cloned viewport.
2004 */
2005 clone: function PageViewPort_clone(args) {
2006 args = args || {};
2007 var scale = 'scale' in args ? args.scale : this.scale;
2008 var rotation = 'rotation' in args ? args.rotation : this.rotation;
2009 return new PageViewport(this.viewBox.slice(), scale, rotation,
2010 this.offsetX, this.offsetY, args.dontFlip);
2011 },
2012 /**
2013 * Converts PDF point to the viewport coordinates. For examples, useful for
2014 * converting PDF location into canvas pixel coordinates.
2015 * @param x {number} X coordinate.
2016 * @param y {number} Y coordinate.
2017 * @returns {Object} Object that contains 'x' and 'y' properties of the
2018 * point in the viewport coordinate space.
2019 * @see {@link convertToPdfPoint}
2020 * @see {@link convertToViewportRectangle}
2021 */
2022 convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
2023 return Util.applyTransform([x, y], this.transform);
2024 },
2025 /**
2026 * Converts PDF rectangle to the viewport coordinates.
2027 * @param rect {Array} xMin, yMin, xMax and yMax coordinates.
2028 * @returns {Array} Contains corresponding coordinates of the rectangle
2029 * in the viewport coordinate space.
2030 * @see {@link convertToViewportPoint}
2031 */
2032 convertToViewportRectangle:
2033 function PageViewport_convertToViewportRectangle(rect) {
2034 var tl = Util.applyTransform([rect[0], rect[1]], this.transform);
2035 var br = Util.applyTransform([rect[2], rect[3]], this.transform);
2036 return [tl[0], tl[1], br[0], br[1]];
2037 },
2038 /**
2039 * Converts viewport coordinates to the PDF location. For examples, useful
2040 * for converting canvas pixel location into PDF one.
2041 * @param x {number} X coordinate.
2042 * @param y {number} Y coordinate.
2043 * @returns {Object} Object that contains 'x' and 'y' properties of the
2044 * point in the PDF coordinate space.
2045 * @see {@link convertToViewportPoint}
2046 */
2047 convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
2048 return Util.applyInverseTransform([x, y], this.transform);
2049 }
2050 };
2051 return PageViewport;
2052})();
2053
2054var PDFStringTranslateTable = [
2055 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2056 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0,
2057 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,
2058 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,
2059 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,
2060 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014,
2061 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C,
2062 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160,
2063 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC
2064];
2065
2066function stringToPDFString(str) {
2067 var i, n = str.length, strBuf = [];
2068 if (str[0] === '\xFE' && str[1] === '\xFF') {
2069 // UTF16BE BOM
2070 for (i = 2; i < n; i += 2) {
2071 strBuf.push(String.fromCharCode(
2072 (str.charCodeAt(i) << 8) | str.charCodeAt(i + 1)));
2073 }
2074 } else {
2075 for (i = 0; i < n; ++i) {
2076 var code = PDFStringTranslateTable[str.charCodeAt(i)];
2077 strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
2078 }
2079 }
2080 return strBuf.join('');
2081}
2082
2083function stringToUTF8String(str) {
2084 return decodeURIComponent(escape(str));
2085}
2086
2087function utf8StringToString(str) {
2088 return unescape(encodeURIComponent(str));
2089}
2090
2091function isEmptyObj(obj) {
2092 for (var key in obj) {
2093 return false;
2094 }
2095 return true;
2096}
2097
2098function isBool(v) {
2099 return typeof v === 'boolean';
2100}
2101
2102function isInt(v) {
2103 return typeof v === 'number' && ((v | 0) === v);
2104}
2105
2106function isNum(v) {
2107 return typeof v === 'number';
2108}
2109
2110function isString(v) {
2111 return typeof v === 'string';
2112}
2113
2114function isArray(v) {
2115 return v instanceof Array;
2116}
2117
2118function isArrayBuffer(v) {
2119 return typeof v === 'object' && v !== null && v.byteLength !== undefined;
2120}
2121
2122// Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
2123function isSpace(ch) {
2124 return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A);
2125}
2126
2127/**
2128 * Promise Capability object.
2129 *
2130 * @typedef {Object} PromiseCapability
2131 * @property {Promise} promise - A promise object.
2132 * @property {function} resolve - Fulfills the promise.
2133 * @property {function} reject - Rejects the promise.
2134 */
2135
2136/**
2137 * Creates a promise capability object.
2138 * @alias createPromiseCapability
2139 *
2140 * @return {PromiseCapability} A capability object contains:
2141 * - a Promise, resolve and reject methods.
2142 */
2143function createPromiseCapability() {
2144 var capability = {};
2145 capability.promise = new Promise(function (resolve, reject) {
2146 capability.resolve = resolve;
2147 capability.reject = reject;
2148 });
2149 return capability;
2150}
2151
2152/**
2153 * Polyfill for Promises:
2154 * The following promise implementation tries to generally implement the
2155 * Promise/A+ spec. Some notable differences from other promise libraries are:
2156 * - There currently isn't a separate deferred and promise object.
2157 * - Unhandled rejections eventually show an error if they aren't handled.
2158 *
2159 * Based off of the work in:
2160 * https://bugzilla.mozilla.org/show_bug.cgi?id=810490
2161 */
2162(function PromiseClosure() {
2163 if (globalScope.Promise) {
2164 // Promises existing in the DOM/Worker, checking presence of all/resolve
2165 if (typeof globalScope.Promise.all !== 'function') {
2166 globalScope.Promise.all = function (iterable) {
2167 var count = 0, results = [], resolve, reject;
2168 var promise = new globalScope.Promise(function (resolve_, reject_) {
2169 resolve = resolve_;
2170 reject = reject_;
2171 });
2172 iterable.forEach(function (p, i) {
2173 count++;
2174 p.then(function (result) {
2175 results[i] = result;
2176 count--;
2177 if (count === 0) {
2178 resolve(results);
2179 }
2180 }, reject);
2181 });
2182 if (count === 0) {
2183 resolve(results);
2184 }
2185 return promise;
2186 };
2187 }
2188 if (typeof globalScope.Promise.resolve !== 'function') {
2189 globalScope.Promise.resolve = function (value) {
2190 return new globalScope.Promise(function (resolve) { resolve(value); });
2191 };
2192 }
2193 if (typeof globalScope.Promise.reject !== 'function') {
2194 globalScope.Promise.reject = function (reason) {
2195 return new globalScope.Promise(function (resolve, reject) {
2196 reject(reason);
2197 });
2198 };
2199 }
2200 if (typeof globalScope.Promise.prototype.catch !== 'function') {
2201 globalScope.Promise.prototype.catch = function (onReject) {
2202 return globalScope.Promise.prototype.then(undefined, onReject);
2203 };
2204 }
2205 return;
2206 }
2207 var STATUS_PENDING = 0;
2208 var STATUS_RESOLVED = 1;
2209 var STATUS_REJECTED = 2;
2210
2211 // In an attempt to avoid silent exceptions, unhandled rejections are
2212 // tracked and if they aren't handled in a certain amount of time an
2213 // error is logged.
2214 var REJECTION_TIMEOUT = 500;
2215
2216 var HandlerManager = {
2217 handlers: [],
2218 running: false,
2219 unhandledRejections: [],
2220 pendingRejectionCheck: false,
2221
2222 scheduleHandlers: function scheduleHandlers(promise) {
2223 if (promise._status === STATUS_PENDING) {
2224 return;
2225 }
2226
2227 this.handlers = this.handlers.concat(promise._handlers);
2228 promise._handlers = [];
2229
2230 if (this.running) {
2231 return;
2232 }
2233 this.running = true;
2234
2235 setTimeout(this.runHandlers.bind(this), 0);
2236 },
2237
2238 runHandlers: function runHandlers() {
2239 var RUN_TIMEOUT = 1; // ms
2240 var timeoutAt = Date.now() + RUN_TIMEOUT;
2241 while (this.handlers.length > 0) {
2242 var handler = this.handlers.shift();
2243
2244 var nextStatus = handler.thisPromise._status;
2245 var nextValue = handler.thisPromise._value;
2246
2247 try {
2248 if (nextStatus === STATUS_RESOLVED) {
2249 if (typeof handler.onResolve === 'function') {
2250 nextValue = handler.onResolve(nextValue);
2251 }
2252 } else if (typeof handler.onReject === 'function') {
2253 nextValue = handler.onReject(nextValue);
2254 nextStatus = STATUS_RESOLVED;
2255
2256 if (handler.thisPromise._unhandledRejection) {
2257 this.removeUnhandeledRejection(handler.thisPromise);
2258 }
2259 }
2260 } catch (ex) {
2261 nextStatus = STATUS_REJECTED;
2262 nextValue = ex;
2263 }
2264
2265 handler.nextPromise._updateStatus(nextStatus, nextValue);
2266 if (Date.now() >= timeoutAt) {
2267 break;
2268 }
2269 }
2270
2271 if (this.handlers.length > 0) {
2272 setTimeout(this.runHandlers.bind(this), 0);
2273 return;
2274 }
2275
2276 this.running = false;
2277 },
2278
2279 addUnhandledRejection: function addUnhandledRejection(promise) {
2280 this.unhandledRejections.push({
2281 promise: promise,
2282 time: Date.now()
2283 });
2284 this.scheduleRejectionCheck();
2285 },
2286
2287 removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
2288 promise._unhandledRejection = false;
2289 for (var i = 0; i < this.unhandledRejections.length; i++) {
2290 if (this.unhandledRejections[i].promise === promise) {
2291 this.unhandledRejections.splice(i);
2292 i--;
2293 }
2294 }
2295 },
2296
2297 scheduleRejectionCheck: function scheduleRejectionCheck() {
2298 if (this.pendingRejectionCheck) {
2299 return;
2300 }
2301 this.pendingRejectionCheck = true;
2302 setTimeout(function rejectionCheck() {
2303 this.pendingRejectionCheck = false;
2304 var now = Date.now();
2305 for (var i = 0; i < this.unhandledRejections.length; i++) {
2306 if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
2307 var unhandled = this.unhandledRejections[i].promise._value;
2308 var msg = 'Unhandled rejection: ' + unhandled;
2309 if (unhandled.stack) {
2310 msg += '\n' + unhandled.stack;
2311 }
2312 warn(msg);
2313 this.unhandledRejections.splice(i);
2314 i--;
2315 }
2316 }
2317 if (this.unhandledRejections.length) {
2318 this.scheduleRejectionCheck();
2319 }
2320 }.bind(this), REJECTION_TIMEOUT);
2321 }
2322 };
2323
2324 function Promise(resolver) {
2325 this._status = STATUS_PENDING;
2326 this._handlers = [];
2327 try {
2328 resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
2329 } catch (e) {
2330 this._reject(e);
2331 }
2332 }
2333 /**
2334 * Builds a promise that is resolved when all the passed in promises are
2335 * resolved.
2336 * @param {array} promises array of data and/or promises to wait for.
2337 * @return {Promise} New dependent promise.
2338 */
2339 Promise.all = function Promise_all(promises) {
2340 var resolveAll, rejectAll;
2341 var deferred = new Promise(function (resolve, reject) {
2342 resolveAll = resolve;
2343 rejectAll = reject;
2344 });
2345 var unresolved = promises.length;
2346 var results = [];
2347 if (unresolved === 0) {
2348 resolveAll(results);
2349 return deferred;
2350 }
2351 function reject(reason) {
2352 if (deferred._status === STATUS_REJECTED) {
2353 return;
2354 }
2355 results = [];
2356 rejectAll(reason);
2357 }
2358 for (var i = 0, ii = promises.length; i < ii; ++i) {
2359 var promise = promises[i];
2360 var resolve = (function(i) {
2361 return function(value) {
2362 if (deferred._status === STATUS_REJECTED) {
2363 return;
2364 }
2365 results[i] = value;
2366 unresolved--;
2367 if (unresolved === 0) {
2368 resolveAll(results);
2369 }
2370 };
2371 })(i);
2372 if (Promise.isPromise(promise)) {
2373 promise.then(resolve, reject);
2374 } else {
2375 resolve(promise);
2376 }
2377 }
2378 return deferred;
2379 };
2380
2381 /**
2382 * Checks if the value is likely a promise (has a 'then' function).
2383 * @return {boolean} true if value is thenable
2384 */
2385 Promise.isPromise = function Promise_isPromise(value) {
2386 return value && typeof value.then === 'function';
2387 };
2388
2389 /**
2390 * Creates resolved promise
2391 * @param value resolve value
2392 * @returns {Promise}
2393 */
2394 Promise.resolve = function Promise_resolve(value) {
2395 return new Promise(function (resolve) { resolve(value); });
2396 };
2397
2398 /**
2399 * Creates rejected promise
2400 * @param reason rejection value
2401 * @returns {Promise}
2402 */
2403 Promise.reject = function Promise_reject(reason) {
2404 return new Promise(function (resolve, reject) { reject(reason); });
2405 };
2406
2407 Promise.prototype = {
2408 _status: null,
2409 _value: null,
2410 _handlers: null,
2411 _unhandledRejection: null,
2412
2413 _updateStatus: function Promise__updateStatus(status, value) {
2414 if (this._status === STATUS_RESOLVED ||
2415 this._status === STATUS_REJECTED) {
2416 return;
2417 }
2418
2419 if (status === STATUS_RESOLVED &&
2420 Promise.isPromise(value)) {
2421 value.then(this._updateStatus.bind(this, STATUS_RESOLVED),
2422 this._updateStatus.bind(this, STATUS_REJECTED));
2423 return;
2424 }
2425
2426 this._status = status;
2427 this._value = value;
2428
2429 if (status === STATUS_REJECTED && this._handlers.length === 0) {
2430 this._unhandledRejection = true;
2431 HandlerManager.addUnhandledRejection(this);
2432 }
2433
2434 HandlerManager.scheduleHandlers(this);
2435 },
2436
2437 _resolve: function Promise_resolve(value) {
2438 this._updateStatus(STATUS_RESOLVED, value);
2439 },
2440
2441 _reject: function Promise_reject(reason) {
2442 this._updateStatus(STATUS_REJECTED, reason);
2443 },
2444
2445 then: function Promise_then(onResolve, onReject) {
2446 var nextPromise = new Promise(function (resolve, reject) {
2447 this.resolve = resolve;
2448 this.reject = reject;
2449 });
2450 this._handlers.push({
2451 thisPromise: this,
2452 onResolve: onResolve,
2453 onReject: onReject,
2454 nextPromise: nextPromise
2455 });
2456 HandlerManager.scheduleHandlers(this);
2457 return nextPromise;
2458 },
2459
2460 catch: function Promise_catch(onReject) {
2461 return this.then(undefined, onReject);
2462 }
2463 };
2464
2465 globalScope.Promise = Promise;
2466})();
2467
2468(function WeakMapClosure() {
2469 if (globalScope.WeakMap) {
2470 return;
2471 }
2472
2473 var id = 0;
2474 function WeakMap() {
2475 this.id = '$weakmap' + (id++);
2476 }
2477 WeakMap.prototype = {
2478 has: function(obj) {
2479 return !!Object.getOwnPropertyDescriptor(obj, this.id);
2480 },
2481 get: function(obj, defaultValue) {
2482 return this.has(obj) ? obj[this.id] : defaultValue;
2483 },
2484 set: function(obj, value) {
2485 Object.defineProperty(obj, this.id, {
2486 value: value,
2487 enumerable: false,
2488 configurable: true
2489 });
2490 },
2491 delete: function(obj) {
2492 delete obj[this.id];
2493 }
2494 };
2495
2496 globalScope.WeakMap = WeakMap;
2497})();
2498
2499var StatTimer = (function StatTimerClosure() {
2500 function rpad(str, pad, length) {
2501 while (str.length < length) {
2502 str += pad;
2503 }
2504 return str;
2505 }
2506 function StatTimer() {
2507 this.started = Object.create(null);
2508 this.times = [];
2509 this.enabled = true;
2510 }
2511 StatTimer.prototype = {
2512 time: function StatTimer_time(name) {
2513 if (!this.enabled) {
2514 return;
2515 }
2516 if (name in this.started) {
2517 warn('Timer is already running for ' + name);
2518 }
2519 this.started[name] = Date.now();
2520 },
2521 timeEnd: function StatTimer_timeEnd(name) {
2522 if (!this.enabled) {
2523 return;
2524 }
2525 if (!(name in this.started)) {
2526 warn('Timer has not been started for ' + name);
2527 }
2528 this.times.push({
2529 'name': name,
2530 'start': this.started[name],
2531 'end': Date.now()
2532 });
2533 // Remove timer from started so it can be called again.
2534 delete this.started[name];
2535 },
2536 toString: function StatTimer_toString() {
2537 var i, ii;
2538 var times = this.times;
2539 var out = '';
2540 // Find the longest name for padding purposes.
2541 var longest = 0;
2542 for (i = 0, ii = times.length; i < ii; ++i) {
2543 var name = times[i]['name'];
2544 if (name.length > longest) {
2545 longest = name.length;
2546 }
2547 }
2548 for (i = 0, ii = times.length; i < ii; ++i) {
2549 var span = times[i];
2550 var duration = span.end - span.start;
2551 out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
2552 }
2553 return out;
2554 }
2555 };
2556 return StatTimer;
2557})();
2558
2559var createBlob = function createBlob(data, contentType) {
2560 if (typeof Blob !== 'undefined') {
2561 return new Blob([data], { type: contentType });
2562 }
2563 warn('The "Blob" constructor is not supported.');
2564};
2565
2566var createObjectURL = (function createObjectURLClosure() {
2567 // Blob/createObjectURL is not available, falling back to data schema.
2568 var digits =
2569 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
2570
2571 return function createObjectURL(data, contentType, forceDataSchema) {
2572 if (!forceDataSchema &&
2573 typeof URL !== 'undefined' && URL.createObjectURL) {
2574 var blob = createBlob(data, contentType);
2575 return URL.createObjectURL(blob);
2576 }
2577
2578 var buffer = 'data:' + contentType + ';base64,';
2579 for (var i = 0, ii = data.length; i < ii; i += 3) {
2580 var b1 = data[i] & 0xFF;
2581 var b2 = data[i + 1] & 0xFF;
2582 var b3 = data[i + 2] & 0xFF;
2583 var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4);
2584 var d3 = i + 1 < ii ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64;
2585 var d4 = i + 2 < ii ? (b3 & 0x3F) : 64;
2586 buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
2587 }
2588 return buffer;
2589 };
2590})();
2591
2592function MessageHandler(sourceName, targetName, comObj) {
2593 this.sourceName = sourceName;
2594 this.targetName = targetName;
2595 this.comObj = comObj;
2596 this.callbackIndex = 1;
2597 this.postMessageTransfers = true;
2598 var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
2599 var ah = this.actionHandler = Object.create(null);
2600
2601 this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
2602 var data = event.data;
2603 if (data.targetName !== this.sourceName) {
2604 return;
2605 }
2606 if (data.isReply) {
2607 var callbackId = data.callbackId;
2608 if (data.callbackId in callbacksCapabilities) {
2609 var callback = callbacksCapabilities[callbackId];
2610 delete callbacksCapabilities[callbackId];
2611 if ('error' in data) {
2612 callback.reject(data.error);
2613 } else {
2614 callback.resolve(data.data);
2615 }
2616 } else {
2617 error('Cannot resolve callback ' + callbackId);
2618 }
2619 } else if (data.action in ah) {
2620 var action = ah[data.action];
2621 if (data.callbackId) {
2622 var sourceName = this.sourceName;
2623 var targetName = data.sourceName;
2624 Promise.resolve().then(function () {
2625 return action[0].call(action[1], data.data);
2626 }).then(function (result) {
2627 comObj.postMessage({
2628 sourceName: sourceName,
2629 targetName: targetName,
2630 isReply: true,
2631 callbackId: data.callbackId,
2632 data: result
2633 });
2634 }, function (reason) {
2635 if (reason instanceof Error) {
2636 // Serialize error to avoid "DataCloneError"
2637 reason = reason + '';
2638 }
2639 comObj.postMessage({
2640 sourceName: sourceName,
2641 targetName: targetName,
2642 isReply: true,
2643 callbackId: data.callbackId,
2644 error: reason
2645 });
2646 });
2647 } else {
2648 action[0].call(action[1], data.data);
2649 }
2650 } else {
2651 error('Unknown action from worker: ' + data.action);
2652 }
2653 }.bind(this);
2654 comObj.addEventListener('message', this._onComObjOnMessage);
2655}
2656
2657MessageHandler.prototype = {
2658 on: function messageHandlerOn(actionName, handler, scope) {
2659 var ah = this.actionHandler;
2660 if (ah[actionName]) {
2661 error('There is already an actionName called "' + actionName + '"');
2662 }
2663 ah[actionName] = [handler, scope];
2664 },
2665 /**
2666 * Sends a message to the comObj to invoke the action with the supplied data.
2667 * @param {String} actionName Action to call.
2668 * @param {JSON} data JSON data to send.
2669 * @param {Array} [transfers] Optional list of transfers/ArrayBuffers
2670 */
2671 send: function messageHandlerSend(actionName, data, transfers) {
2672 var message = {
2673 sourceName: this.sourceName,
2674 targetName: this.targetName,
2675 action: actionName,
2676 data: data
2677 };
2678 this.postMessage(message, transfers);
2679 },
2680 /**
2681 * Sends a message to the comObj to invoke the action with the supplied data.
2682 * Expects that other side will callback with the response.
2683 * @param {String} actionName Action to call.
2684 * @param {JSON} data JSON data to send.
2685 * @param {Array} [transfers] Optional list of transfers/ArrayBuffers.
2686 * @returns {Promise} Promise to be resolved with response data.
2687 */
2688 sendWithPromise:
2689 function messageHandlerSendWithPromise(actionName, data, transfers) {
2690 var callbackId = this.callbackIndex++;
2691 var message = {
2692 sourceName: this.sourceName,
2693 targetName: this.targetName,
2694 action: actionName,
2695 data: data,
2696 callbackId: callbackId
2697 };
2698 var capability = createPromiseCapability();
2699 this.callbacksCapabilities[callbackId] = capability;
2700 try {
2701 this.postMessage(message, transfers);
2702 } catch (e) {
2703 capability.reject(e);
2704 }
2705 return capability.promise;
2706 },
2707 /**
2708 * Sends raw message to the comObj.
2709 * @private
2710 * @param message {Object} Raw message.
2711 * @param transfers List of transfers/ArrayBuffers, or undefined.
2712 */
2713 postMessage: function (message, transfers) {
2714 if (transfers && this.postMessageTransfers) {
2715 this.comObj.postMessage(message, transfers);
2716 } else {
2717 this.comObj.postMessage(message);
2718 }
2719 },
2720
2721 destroy: function () {
2722 this.comObj.removeEventListener('message', this._onComObjOnMessage);
2723 }
2724};
2725
2726function loadJpegStream(id, imageUrl, objs) {
2727 var img = new Image();
2728 img.onload = (function loadJpegStream_onloadClosure() {
2729 objs.resolve(id, img);
2730 });
2731 img.onerror = (function loadJpegStream_onerrorClosure() {
2732 objs.resolve(id, null);
2733 warn('Error during JPEG image loading');
2734 });
2735 img.src = imageUrl;
2736}
2737
2738 // Polyfill from https://github.com/Polymer/URL
2739/* Any copyright is dedicated to the Public Domain.
2740 * http://creativecommons.org/publicdomain/zero/1.0/ */
2741(function checkURLConstructor(scope) {
2742 // feature detect for URL constructor
2743 var hasWorkingUrl = false;
2744 try {
2745 if (typeof URL === 'function' &&
2746 typeof URL.prototype === 'object' &&
2747 ('origin' in URL.prototype)) {
2748 var u = new URL('b', 'http://a');
2749 u.pathname = 'c%20d';
2750 hasWorkingUrl = u.href === 'http://a/c%20d';
2751 }
2752 } catch(e) { }
2753
2754 if (hasWorkingUrl) {
2755 return;
2756 }
2757
2758 var relative = Object.create(null);
2759 relative['ftp'] = 21;
2760 relative['file'] = 0;
2761 relative['gopher'] = 70;
2762 relative['http'] = 80;
2763 relative['https'] = 443;
2764 relative['ws'] = 80;
2765 relative['wss'] = 443;
2766
2767 var relativePathDotMapping = Object.create(null);
2768 relativePathDotMapping['%2e'] = '.';
2769 relativePathDotMapping['.%2e'] = '..';
2770 relativePathDotMapping['%2e.'] = '..';
2771 relativePathDotMapping['%2e%2e'] = '..';
2772
2773 function isRelativeScheme(scheme) {
2774 return relative[scheme] !== undefined;
2775 }
2776
2777 function invalid() {
2778 clear.call(this);
2779 this._isInvalid = true;
2780 }
2781
2782 function IDNAToASCII(h) {
2783 if ('' === h) {
2784 invalid.call(this);
2785 }
2786 // XXX
2787 return h.toLowerCase();
2788 }
2789
2790 function percentEscape(c) {
2791 var unicode = c.charCodeAt(0);
2792 if (unicode > 0x20 &&
2793 unicode < 0x7F &&
2794 // " # < > ? `
2795 [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1
2796 ) {
2797 return c;
2798 }
2799 return encodeURIComponent(c);
2800 }
2801
2802 function percentEscapeQuery(c) {
2803 // XXX This actually needs to encode c using encoding and then
2804 // convert the bytes one-by-one.
2805
2806 var unicode = c.charCodeAt(0);
2807 if (unicode > 0x20 &&
2808 unicode < 0x7F &&
2809 // " # < > ` (do not escape '?')
2810 [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1
2811 ) {
2812 return c;
2813 }
2814 return encodeURIComponent(c);
2815 }
2816
2817 var EOF, ALPHA = /[a-zA-Z]/,
2818 ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
2819
2820 function parse(input, stateOverride, base) {
2821 function err(message) {
2822 errors.push(message);
2823 }
2824
2825 var state = stateOverride || 'scheme start',
2826 cursor = 0,
2827 buffer = '',
2828 seenAt = false,
2829 seenBracket = false,
2830 errors = [];
2831
2832 loop: while ((input[cursor - 1] !== EOF || cursor === 0) &&
2833 !this._isInvalid) {
2834 var c = input[cursor];
2835 switch (state) {
2836 case 'scheme start':
2837 if (c && ALPHA.test(c)) {
2838 buffer += c.toLowerCase(); // ASCII-safe
2839 state = 'scheme';
2840 } else if (!stateOverride) {
2841 buffer = '';
2842 state = 'no scheme';
2843 continue;
2844 } else {
2845 err('Invalid scheme.');
2846 break loop;
2847 }
2848 break;
2849
2850 case 'scheme':
2851 if (c && ALPHANUMERIC.test(c)) {
2852 buffer += c.toLowerCase(); // ASCII-safe
2853 } else if (':' === c) {
2854 this._scheme = buffer;
2855 buffer = '';
2856 if (stateOverride) {
2857 break loop;
2858 }
2859 if (isRelativeScheme(this._scheme)) {
2860 this._isRelative = true;
2861 }
2862 if ('file' === this._scheme) {
2863 state = 'relative';
2864 } else if (this._isRelative && base &&
2865 base._scheme === this._scheme) {
2866 state = 'relative or authority';
2867 } else if (this._isRelative) {
2868 state = 'authority first slash';
2869 } else {
2870 state = 'scheme data';
2871 }
2872 } else if (!stateOverride) {
2873 buffer = '';
2874 cursor = 0;
2875 state = 'no scheme';
2876 continue;
2877 } else if (EOF === c) {
2878 break loop;
2879 } else {
2880 err('Code point not allowed in scheme: ' + c);
2881 break loop;
2882 }
2883 break;
2884
2885 case 'scheme data':
2886 if ('?' === c) {
2887 this._query = '?';
2888 state = 'query';
2889 } else if ('#' === c) {
2890 this._fragment = '#';
2891 state = 'fragment';
2892 } else {
2893 // XXX error handling
2894 if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
2895 this._schemeData += percentEscape(c);
2896 }
2897 }
2898 break;
2899
2900 case 'no scheme':
2901 if (!base || !(isRelativeScheme(base._scheme))) {
2902 err('Missing scheme.');
2903 invalid.call(this);
2904 } else {
2905 state = 'relative';
2906 continue;
2907 }
2908 break;
2909
2910 case 'relative or authority':
2911 if ('/' === c && '/' === input[cursor+1]) {
2912 state = 'authority ignore slashes';
2913 } else {
2914 err('Expected /, got: ' + c);
2915 state = 'relative';
2916 continue;
2917 }
2918 break;
2919
2920 case 'relative':
2921 this._isRelative = true;
2922 if ('file' !== this._scheme) {
2923 this._scheme = base._scheme;
2924 }
2925 if (EOF === c) {
2926 this._host = base._host;
2927 this._port = base._port;
2928 this._path = base._path.slice();
2929 this._query = base._query;
2930 this._username = base._username;
2931 this._password = base._password;
2932 break loop;
2933 } else if ('/' === c || '\\' === c) {
2934 if ('\\' === c) {
2935 err('\\ is an invalid code point.');
2936 }
2937 state = 'relative slash';
2938 } else if ('?' === c) {
2939 this._host = base._host;
2940 this._port = base._port;
2941 this._path = base._path.slice();
2942 this._query = '?';
2943 this._username = base._username;
2944 this._password = base._password;
2945 state = 'query';
2946 } else if ('#' === c) {
2947 this._host = base._host;
2948 this._port = base._port;
2949 this._path = base._path.slice();
2950 this._query = base._query;
2951 this._fragment = '#';
2952 this._username = base._username;
2953 this._password = base._password;
2954 state = 'fragment';
2955 } else {
2956 var nextC = input[cursor+1];
2957 var nextNextC = input[cursor+2];
2958 if ('file' !== this._scheme || !ALPHA.test(c) ||
2959 (nextC !== ':' && nextC !== '|') ||
2960 (EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC &&
2961 '?' !== nextNextC && '#' !== nextNextC)) {
2962 this._host = base._host;
2963 this._port = base._port;
2964 this._username = base._username;
2965 this._password = base._password;
2966 this._path = base._path.slice();
2967 this._path.pop();
2968 }
2969 state = 'relative path';
2970 continue;
2971 }
2972 break;
2973
2974 case 'relative slash':
2975 if ('/' === c || '\\' === c) {
2976 if ('\\' === c) {
2977 err('\\ is an invalid code point.');
2978 }
2979 if ('file' === this._scheme) {
2980 state = 'file host';
2981 } else {
2982 state = 'authority ignore slashes';
2983 }
2984 } else {
2985 if ('file' !== this._scheme) {
2986 this._host = base._host;
2987 this._port = base._port;
2988 this._username = base._username;
2989 this._password = base._password;
2990 }
2991 state = 'relative path';
2992 continue;
2993 }
2994 break;
2995
2996 case 'authority first slash':
2997 if ('/' === c) {
2998 state = 'authority second slash';
2999 } else {
3000 err('Expected \'/\', got: ' + c);
3001 state = 'authority ignore slashes';
3002 continue;
3003 }
3004 break;
3005
3006 case 'authority second slash':
3007 state = 'authority ignore slashes';
3008 if ('/' !== c) {
3009 err('Expected \'/\', got: ' + c);
3010 continue;
3011 }
3012 break;
3013
3014 case 'authority ignore slashes':
3015 if ('/' !== c && '\\' !== c) {
3016 state = 'authority';
3017 continue;
3018 } else {
3019 err('Expected authority, got: ' + c);
3020 }
3021 break;
3022
3023 case 'authority':
3024 if ('@' === c) {
3025 if (seenAt) {
3026 err('@ already seen.');
3027 buffer += '%40';
3028 }
3029 seenAt = true;
3030 for (var i = 0; i < buffer.length; i++) {
3031 var cp = buffer[i];
3032 if ('\t' === cp || '\n' === cp || '\r' === cp) {
3033 err('Invalid whitespace in authority.');
3034 continue;
3035 }
3036 // XXX check URL code points
3037 if (':' === cp && null === this._password) {
3038 this._password = '';
3039 continue;
3040 }
3041 var tempC = percentEscape(cp);
3042 if (null !== this._password) {
3043 this._password += tempC;
3044 } else {
3045 this._username += tempC;
3046 }
3047 }
3048 buffer = '';
3049 } else if (EOF === c || '/' === c || '\\' === c ||
3050 '?' === c || '#' === c) {
3051 cursor -= buffer.length;
3052 buffer = '';
3053 state = 'host';
3054 continue;
3055 } else {
3056 buffer += c;
3057 }
3058 break;
3059
3060 case 'file host':
3061 if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
3062 if (buffer.length === 2 && ALPHA.test(buffer[0]) &&
3063 (buffer[1] === ':' || buffer[1] === '|')) {
3064 state = 'relative path';
3065 } else if (buffer.length === 0) {
3066 state = 'relative path start';
3067 } else {
3068 this._host = IDNAToASCII.call(this, buffer);
3069 buffer = '';
3070 state = 'relative path start';
3071 }
3072 continue;
3073 } else if ('\t' === c || '\n' === c || '\r' === c) {
3074 err('Invalid whitespace in file host.');
3075 } else {
3076 buffer += c;
3077 }
3078 break;
3079
3080 case 'host':
3081 case 'hostname':
3082 if (':' === c && !seenBracket) {
3083 // XXX host parsing
3084 this._host = IDNAToASCII.call(this, buffer);
3085 buffer = '';
3086 state = 'port';
3087 if ('hostname' === stateOverride) {
3088 break loop;
3089 }
3090 } else if (EOF === c || '/' === c ||
3091 '\\' === c || '?' === c || '#' === c) {
3092 this._host = IDNAToASCII.call(this, buffer);
3093 buffer = '';
3094 state = 'relative path start';
3095 if (stateOverride) {
3096 break loop;
3097 }
3098 continue;
3099 } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
3100 if ('[' === c) {
3101 seenBracket = true;
3102 } else if (']' === c) {
3103 seenBracket = false;
3104 }
3105 buffer += c;
3106 } else {
3107 err('Invalid code point in host/hostname: ' + c);
3108 }
3109 break;
3110
3111 case 'port':
3112 if (/[0-9]/.test(c)) {
3113 buffer += c;
3114 } else if (EOF === c || '/' === c || '\\' === c ||
3115 '?' === c || '#' === c || stateOverride) {
3116 if ('' !== buffer) {
3117 var temp = parseInt(buffer, 10);
3118 if (temp !== relative[this._scheme]) {
3119 this._port = temp + '';
3120 }
3121 buffer = '';
3122 }
3123 if (stateOverride) {
3124 break loop;
3125 }
3126 state = 'relative path start';
3127 continue;
3128 } else if ('\t' === c || '\n' === c || '\r' === c) {
3129 err('Invalid code point in port: ' + c);
3130 } else {
3131 invalid.call(this);
3132 }
3133 break;
3134
3135 case 'relative path start':
3136 if ('\\' === c) {
3137 err('\'\\\' not allowed in path.');
3138 }
3139 state = 'relative path';
3140 if ('/' !== c && '\\' !== c) {
3141 continue;
3142 }
3143 break;
3144
3145 case 'relative path':
3146 if (EOF === c || '/' === c || '\\' === c ||
3147 (!stateOverride && ('?' === c || '#' === c))) {
3148 if ('\\' === c) {
3149 err('\\ not allowed in relative path.');
3150 }
3151 var tmp;
3152 if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
3153 buffer = tmp;
3154 }
3155 if ('..' === buffer) {
3156 this._path.pop();
3157 if ('/' !== c && '\\' !== c) {
3158 this._path.push('');
3159 }
3160 } else if ('.' === buffer && '/' !== c && '\\' !== c) {
3161 this._path.push('');
3162 } else if ('.' !== buffer) {
3163 if ('file' === this._scheme && this._path.length === 0 &&
3164 buffer.length === 2 && ALPHA.test(buffer[0]) &&
3165 buffer[1] === '|') {
3166 buffer = buffer[0] + ':';
3167 }
3168 this._path.push(buffer);
3169 }
3170 buffer = '';
3171 if ('?' === c) {
3172 this._query = '?';
3173 state = 'query';
3174 } else if ('#' === c) {
3175 this._fragment = '#';
3176 state = 'fragment';
3177 }
3178 } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
3179 buffer += percentEscape(c);
3180 }
3181 break;
3182
3183 case 'query':
3184 if (!stateOverride && '#' === c) {
3185 this._fragment = '#';
3186 state = 'fragment';
3187 } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
3188 this._query += percentEscapeQuery(c);
3189 }
3190 break;
3191
3192 case 'fragment':
3193 if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
3194 this._fragment += c;
3195 }
3196 break;
3197 }
3198
3199 cursor++;
3200 }
3201 }
3202
3203 function clear() {
3204 this._scheme = '';
3205 this._schemeData = '';
3206 this._username = '';
3207 this._password = null;
3208 this._host = '';
3209 this._port = '';
3210 this._path = [];
3211 this._query = '';
3212 this._fragment = '';
3213 this._isInvalid = false;
3214 this._isRelative = false;
3215 }
3216
3217 // Does not process domain names or IP addresses.
3218 // Does not handle encoding for the query parameter.
3219 function JURL(url, base /* , encoding */) {
3220 if (base !== undefined && !(base instanceof JURL)) {
3221 base = new JURL(String(base));
3222 }
3223
3224 this._url = url;
3225 clear.call(this);
3226
3227 var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
3228 // encoding = encoding || 'utf-8'
3229
3230 parse.call(this, input, null, base);
3231 }
3232
3233 JURL.prototype = {
3234 toString: function() {
3235 return this.href;
3236 },
3237 get href() {
3238 if (this._isInvalid) {
3239 return this._url;
3240 }
3241 var authority = '';
3242 if ('' !== this._username || null !== this._password) {
3243 authority = this._username +
3244 (null !== this._password ? ':' + this._password : '') + '@';
3245 }
3246
3247 return this.protocol +
3248 (this._isRelative ? '//' + authority + this.host : '') +
3249 this.pathname + this._query + this._fragment;
3250 },
3251 set href(href) {
3252 clear.call(this);
3253 parse.call(this, href);
3254 },
3255
3256 get protocol() {
3257 return this._scheme + ':';
3258 },
3259 set protocol(protocol) {
3260 if (this._isInvalid) {
3261 return;
3262 }
3263 parse.call(this, protocol + ':', 'scheme start');
3264 },
3265
3266 get host() {
3267 return this._isInvalid ? '' : this._port ?
3268 this._host + ':' + this._port : this._host;
3269 },
3270 set host(host) {
3271 if (this._isInvalid || !this._isRelative) {
3272 return;
3273 }
3274 parse.call(this, host, 'host');
3275 },
3276
3277 get hostname() {
3278 return this._host;
3279 },
3280 set hostname(hostname) {
3281 if (this._isInvalid || !this._isRelative) {
3282 return;
3283 }
3284 parse.call(this, hostname, 'hostname');
3285 },
3286
3287 get port() {
3288 return this._port;
3289 },
3290 set port(port) {
3291 if (this._isInvalid || !this._isRelative) {
3292 return;
3293 }
3294 parse.call(this, port, 'port');
3295 },
3296
3297 get pathname() {
3298 return this._isInvalid ? '' : this._isRelative ?
3299 '/' + this._path.join('/') : this._schemeData;
3300 },
3301 set pathname(pathname) {
3302 if (this._isInvalid || !this._isRelative) {
3303 return;
3304 }
3305 this._path = [];
3306 parse.call(this, pathname, 'relative path start');
3307 },
3308
3309 get search() {
3310 return this._isInvalid || !this._query || '?' === this._query ?
3311 '' : this._query;
3312 },
3313 set search(search) {
3314 if (this._isInvalid || !this._isRelative) {
3315 return;
3316 }
3317 this._query = '?';
3318 if ('?' === search[0]) {
3319 search = search.slice(1);
3320 }
3321 parse.call(this, search, 'query');
3322 },
3323
3324 get hash() {
3325 return this._isInvalid || !this._fragment || '#' === this._fragment ?
3326 '' : this._fragment;
3327 },
3328 set hash(hash) {
3329 if (this._isInvalid) {
3330 return;
3331 }
3332 this._fragment = '#';
3333 if ('#' === hash[0]) {
3334 hash = hash.slice(1);
3335 }
3336 parse.call(this, hash, 'fragment');
3337 },
3338
3339 get origin() {
3340 var host;
3341 if (this._isInvalid || !this._scheme) {
3342 return '';
3343 }
3344 // javascript: Gecko returns String(""), WebKit/Blink String("null")
3345 // Gecko throws error for "data://"
3346 // data: Gecko returns "", Blink returns "data://", WebKit returns "null"
3347 // Gecko returns String("") for file: mailto:
3348 // WebKit/Blink returns String("SCHEME://") for file: mailto:
3349 switch (this._scheme) {
3350 case 'data':
3351 case 'file':
3352 case 'javascript':
3353 case 'mailto':
3354 return 'null';
3355 }
3356 host = this.host;
3357 if (!host) {
3358 return '';
3359 }
3360 return this._scheme + '://' + host;
3361 }
3362 };
3363
3364 // Copy over the static methods
3365 var OriginalURL = scope.URL;
3366 if (OriginalURL) {
3367 JURL.createObjectURL = function(blob) {
3368 // IE extension allows a second optional options argument.
3369 // http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx
3370 return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
3371 };
3372 JURL.revokeObjectURL = function(url) {
3373 OriginalURL.revokeObjectURL(url);
3374 };
3375 }
3376
3377 scope.URL = JURL;
3378})(globalScope);
3379
3380exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
3381exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
3382exports.OPS = OPS;
3383exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
3384exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
3385exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
3386exports.AnnotationFieldFlag = AnnotationFieldFlag;
3387exports.AnnotationFlag = AnnotationFlag;
3388exports.AnnotationType = AnnotationType;
3389exports.FontType = FontType;
3390exports.ImageKind = ImageKind;
3391exports.InvalidPDFException = InvalidPDFException;
3392exports.MessageHandler = MessageHandler;
3393exports.MissingDataException = MissingDataException;
3394exports.MissingPDFException = MissingPDFException;
3395exports.NotImplementedException = NotImplementedException;
3396exports.PageViewport = PageViewport;
3397exports.PasswordException = PasswordException;
3398exports.PasswordResponses = PasswordResponses;
3399exports.StatTimer = StatTimer;
3400exports.StreamType = StreamType;
3401exports.TextRenderingMode = TextRenderingMode;
3402exports.UnexpectedResponseException = UnexpectedResponseException;
3403exports.UnknownErrorException = UnknownErrorException;
3404exports.Util = Util;
3405exports.XRefParseException = XRefParseException;
3406exports.arrayByteLength = arrayByteLength;
3407exports.arraysToBytes = arraysToBytes;
3408exports.assert = assert;
3409exports.bytesToString = bytesToString;
3410exports.createBlob = createBlob;
3411exports.createPromiseCapability = createPromiseCapability;
3412exports.createObjectURL = createObjectURL;
3413exports.deprecated = deprecated;
3414exports.error = error;
3415exports.getLookupTableFactory = getLookupTableFactory;
3416exports.getVerbosityLevel = getVerbosityLevel;
3417exports.globalScope = globalScope;
3418exports.info = info;
3419exports.isArray = isArray;
3420exports.isArrayBuffer = isArrayBuffer;
3421exports.isBool = isBool;
3422exports.isEmptyObj = isEmptyObj;
3423exports.isInt = isInt;
3424exports.isNum = isNum;
3425exports.isString = isString;
3426exports.isSpace = isSpace;
3427exports.isSameOrigin = isSameOrigin;
3428exports.isValidUrl = isValidUrl;
3429exports.isLittleEndian = isLittleEndian;
3430exports.isEvalSupported = isEvalSupported;
3431exports.loadJpegStream = loadJpegStream;
3432exports.log2 = log2;
3433exports.readInt8 = readInt8;
3434exports.readUint16 = readUint16;
3435exports.readUint32 = readUint32;
3436exports.removeNullCharacters = removeNullCharacters;
3437exports.setVerbosityLevel = setVerbosityLevel;
3438exports.shadow = shadow;
3439exports.string32 = string32;
3440exports.stringToBytes = stringToBytes;
3441exports.stringToPDFString = stringToPDFString;
3442exports.stringToUTF8String = stringToUTF8String;
3443exports.utf8StringToString = utf8StringToString;
3444exports.warn = warn;
3445}));
3446
3447
3448(function (root, factory) {
3449 {
3450 factory((root.pdfjsCoreCFFParser = {}), root.pdfjsSharedUtil,
3451 root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
3452 }
3453}(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
3454
3455var error = sharedUtil.error;
3456var info = sharedUtil.info;
3457var bytesToString = sharedUtil.bytesToString;
3458var warn = sharedUtil.warn;
3459var isArray = sharedUtil.isArray;
3460var Util = sharedUtil.Util;
3461var stringToBytes = sharedUtil.stringToBytes;
3462var assert = sharedUtil.assert;
3463var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
3464var ExpertCharset = coreCharsets.ExpertCharset;
3465var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
3466var StandardEncoding = coreEncodings.StandardEncoding;
3467var ExpertEncoding = coreEncodings.ExpertEncoding;
3468
3469// Maximum subroutine call depth of type 2 chartrings. Matches OTS.
3470var MAX_SUBR_NESTING = 10;
3471
3472/**
3473 * The CFF class takes a Type1 file and wrap it into a
3474 * 'Compact Font Format' which itself embed Type2 charstrings.
3475 */
3476var CFFStandardStrings = [
3477 '.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
3478 'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus',
3479 'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four',
3480 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less',
3481 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
3482 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
3483 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright', 'asciicircum',
3484 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
3485 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
3486 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', 'exclamdown', 'cent',
3487 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency',
3488 'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft',
3489 'guilsinglright', 'fi', 'fl', 'endash', 'dagger', 'daggerdbl',
3490 'periodcentered', 'paragraph', 'bullet', 'quotesinglbase', 'quotedblbase',
3491 'quotedblright', 'guillemotright', 'ellipsis', 'perthousand', 'questiondown',
3492 'grave', 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent',
3493 'dieresis', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron', 'emdash',
3494 'AE', 'ordfeminine', 'Lslash', 'Oslash', 'OE', 'ordmasculine', 'ae',
3495 'dotlessi', 'lslash', 'oslash', 'oe', 'germandbls', 'onesuperior',
3496 'logicalnot', 'mu', 'trademark', 'Eth', 'onehalf', 'plusminus', 'Thorn',
3497 'onequarter', 'divide', 'brokenbar', 'degree', 'thorn', 'threequarters',
3498 'twosuperior', 'registered', 'minus', 'eth', 'multiply', 'threesuperior',
3499 'copyright', 'Aacute', 'Acircumflex', 'Adieresis', 'Agrave', 'Aring',
3500 'Atilde', 'Ccedilla', 'Eacute', 'Ecircumflex', 'Edieresis', 'Egrave',
3501 'Iacute', 'Icircumflex', 'Idieresis', 'Igrave', 'Ntilde', 'Oacute',
3502 'Ocircumflex', 'Odieresis', 'Ograve', 'Otilde', 'Scaron', 'Uacute',
3503 'Ucircumflex', 'Udieresis', 'Ugrave', 'Yacute', 'Ydieresis', 'Zcaron',
3504 'aacute', 'acircumflex', 'adieresis', 'agrave', 'aring', 'atilde',
3505 'ccedilla', 'eacute', 'ecircumflex', 'edieresis', 'egrave', 'iacute',
3506 'icircumflex', 'idieresis', 'igrave', 'ntilde', 'oacute', 'ocircumflex',
3507 'odieresis', 'ograve', 'otilde', 'scaron', 'uacute', 'ucircumflex',
3508 'udieresis', 'ugrave', 'yacute', 'ydieresis', 'zcaron', 'exclamsmall',
3509 'Hungarumlautsmall', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall',
3510 'Acutesmall', 'parenleftsuperior', 'parenrightsuperior', 'twodotenleader',
3511 'onedotenleader', 'zerooldstyle', 'oneoldstyle', 'twooldstyle',
3512 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle',
3513 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'commasuperior',
3514 'threequartersemdash', 'periodsuperior', 'questionsmall', 'asuperior',
3515 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', 'isuperior',
3516 'lsuperior', 'msuperior', 'nsuperior', 'osuperior', 'rsuperior', 'ssuperior',
3517 'tsuperior', 'ff', 'ffi', 'ffl', 'parenleftinferior', 'parenrightinferior',
3518 'Circumflexsmall', 'hyphensuperior', 'Gravesmall', 'Asmall', 'Bsmall',
3519 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall',
3520 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall',
3521 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall',
3522 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah',
3523 'Tildesmall', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall',
3524 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall', 'Caronsmall',
3525 'Dotaccentsmall', 'Macronsmall', 'figuredash', 'hypheninferior',
3526 'Ogoneksmall', 'Ringsmall', 'Cedillasmall', 'questiondownsmall', 'oneeighth',
3527 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird', 'twothirds',
3528 'zerosuperior', 'foursuperior', 'fivesuperior', 'sixsuperior',
3529 'sevensuperior', 'eightsuperior', 'ninesuperior', 'zeroinferior',
3530 'oneinferior', 'twoinferior', 'threeinferior', 'fourinferior',
3531 'fiveinferior', 'sixinferior', 'seveninferior', 'eightinferior',
3532 'nineinferior', 'centinferior', 'dollarinferior', 'periodinferior',
3533 'commainferior', 'Agravesmall', 'Aacutesmall', 'Acircumflexsmall',
3534 'Atildesmall', 'Adieresissmall', 'Aringsmall', 'AEsmall', 'Ccedillasmall',
3535 'Egravesmall', 'Eacutesmall', 'Ecircumflexsmall', 'Edieresissmall',
3536 'Igravesmall', 'Iacutesmall', 'Icircumflexsmall', 'Idieresissmall',
3537 'Ethsmall', 'Ntildesmall', 'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall',
3538 'Otildesmall', 'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall',
3539 'Uacutesmall', 'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall',
3540 'Thornsmall', 'Ydieresissmall', '001.000', '001.001', '001.002', '001.003',
3541 'Black', 'Bold', 'Book', 'Light', 'Medium', 'Regular', 'Roman', 'Semibold'
3542];
3543
3544
3545var CFFParser = (function CFFParserClosure() {
3546 var CharstringValidationData = [
3547 null,
3548 { id: 'hstem', min: 2, stackClearing: true, stem: true },
3549 null,
3550 { id: 'vstem', min: 2, stackClearing: true, stem: true },
3551 { id: 'vmoveto', min: 1, stackClearing: true },
3552 { id: 'rlineto', min: 2, resetStack: true },
3553 { id: 'hlineto', min: 1, resetStack: true },
3554 { id: 'vlineto', min: 1, resetStack: true },
3555 { id: 'rrcurveto', min: 6, resetStack: true },
3556 null,
3557 { id: 'callsubr', min: 1, undefStack: true },
3558 { id: 'return', min: 0, undefStack: true },
3559 null, // 12
3560 null,
3561 { id: 'endchar', min: 0, stackClearing: true },
3562 null,
3563 null,
3564 null,
3565 { id: 'hstemhm', min: 2, stackClearing: true, stem: true },
3566 { id: 'hintmask', min: 0, stackClearing: true },
3567 { id: 'cntrmask', min: 0, stackClearing: true },
3568 { id: 'rmoveto', min: 2, stackClearing: true },
3569 { id: 'hmoveto', min: 1, stackClearing: true },
3570 { id: 'vstemhm', min: 2, stackClearing: true, stem: true },
3571 { id: 'rcurveline', min: 8, resetStack: true },
3572 { id: 'rlinecurve', min: 8, resetStack: true },
3573 { id: 'vvcurveto', min: 4, resetStack: true },
3574 { id: 'hhcurveto', min: 4, resetStack: true },
3575 null, // shortint
3576 { id: 'callgsubr', min: 1, undefStack: true },
3577 { id: 'vhcurveto', min: 4, resetStack: true },
3578 { id: 'hvcurveto', min: 4, resetStack: true }
3579 ];
3580 var CharstringValidationData12 = [
3581 null,
3582 null,
3583 null,
3584 { id: 'and', min: 2, stackDelta: -1 },
3585 { id: 'or', min: 2, stackDelta: -1 },
3586 { id: 'not', min: 1, stackDelta: 0 },
3587 null,
3588 null,
3589 null,
3590 { id: 'abs', min: 1, stackDelta: 0 },
3591 { id: 'add', min: 2, stackDelta: -1,
3592 stackFn: function stack_div(stack, index) {
3593 stack[index - 2] = stack[index - 2] + stack[index - 1];
3594 }
3595 },
3596 { id: 'sub', min: 2, stackDelta: -1,
3597 stackFn: function stack_div(stack, index) {
3598 stack[index - 2] = stack[index - 2] - stack[index - 1];
3599 }
3600 },
3601 { id: 'div', min: 2, stackDelta: -1,
3602 stackFn: function stack_div(stack, index) {
3603 stack[index - 2] = stack[index - 2] / stack[index - 1];
3604 }
3605 },
3606 null,
3607 { id: 'neg', min: 1, stackDelta: 0,
3608 stackFn: function stack_div(stack, index) {
3609 stack[index - 1] = -stack[index - 1];
3610 }
3611 },
3612 { id: 'eq', min: 2, stackDelta: -1 },
3613 null,
3614 null,
3615 { id: 'drop', min: 1, stackDelta: -1 },
3616 null,
3617 { id: 'put', min: 2, stackDelta: -2 },
3618 { id: 'get', min: 1, stackDelta: 0 },
3619 { id: 'ifelse', min: 4, stackDelta: -3 },
3620 { id: 'random', min: 0, stackDelta: 1 },
3621 { id: 'mul', min: 2, stackDelta: -1,
3622 stackFn: function stack_div(stack, index) {
3623 stack[index - 2] = stack[index - 2] * stack[index - 1];
3624 }
3625 },
3626 null,
3627 { id: 'sqrt', min: 1, stackDelta: 0 },
3628 { id: 'dup', min: 1, stackDelta: 1 },
3629 { id: 'exch', min: 2, stackDelta: 0 },
3630 { id: 'index', min: 2, stackDelta: 0 },
3631 { id: 'roll', min: 3, stackDelta: -2 },
3632 null,
3633 null,
3634 null,
3635 { id: 'hflex', min: 7, resetStack: true },
3636 { id: 'flex', min: 13, resetStack: true },
3637 { id: 'hflex1', min: 9, resetStack: true },
3638 { id: 'flex1', min: 11, resetStack: true }
3639 ];
3640
3641 function CFFParser(file, properties, seacAnalysisEnabled) {
3642 this.bytes = file.getBytes();
3643 this.properties = properties;
3644 this.seacAnalysisEnabled = !!seacAnalysisEnabled;
3645 }
3646 CFFParser.prototype = {
3647 parse: function CFFParser_parse() {
3648 var properties = this.properties;
3649 var cff = new CFF();
3650 this.cff = cff;
3651
3652 // The first five sections must be in order, all the others are reached
3653 // via offsets contained in one of the below.
3654 var header = this.parseHeader();
3655 var nameIndex = this.parseIndex(header.endPos);
3656 var topDictIndex = this.parseIndex(nameIndex.endPos);
3657 var stringIndex = this.parseIndex(topDictIndex.endPos);
3658 var globalSubrIndex = this.parseIndex(stringIndex.endPos);
3659
3660 var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
3661 var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
3662
3663 cff.header = header.obj;
3664 cff.names = this.parseNameIndex(nameIndex.obj);
3665 cff.strings = this.parseStringIndex(stringIndex.obj);
3666 cff.topDict = topDict;
3667 cff.globalSubrIndex = globalSubrIndex.obj;
3668
3669 this.parsePrivateDict(cff.topDict);
3670
3671 cff.isCIDFont = topDict.hasName('ROS');
3672
3673 var charStringOffset = topDict.getByName('CharStrings');
3674 var charStringIndex = this.parseIndex(charStringOffset).obj;
3675
3676 var fontMatrix = topDict.getByName('FontMatrix');
3677 if (fontMatrix) {
3678 properties.fontMatrix = fontMatrix;
3679 }
3680
3681 var fontBBox = topDict.getByName('FontBBox');
3682 if (fontBBox) {
3683 // adjusting ascent/descent
3684 properties.ascent = fontBBox[3];
3685 properties.descent = fontBBox[1];
3686 properties.ascentScaled = true;
3687 }
3688
3689 var charset, encoding;
3690 if (cff.isCIDFont) {
3691 var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
3692 for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
3693 var dictRaw = fdArrayIndex.get(i);
3694 var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw),
3695 cff.strings);
3696 this.parsePrivateDict(fontDict);
3697 cff.fdArray.push(fontDict);
3698 }
3699 // cid fonts don't have an encoding
3700 encoding = null;
3701 charset = this.parseCharsets(topDict.getByName('charset'),
3702 charStringIndex.count, cff.strings, true);
3703 cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'),
3704 charStringIndex.count);
3705 } else {
3706 charset = this.parseCharsets(topDict.getByName('charset'),
3707 charStringIndex.count, cff.strings, false);
3708 encoding = this.parseEncoding(topDict.getByName('Encoding'),
3709 properties,
3710 cff.strings, charset.charset);
3711 }
3712
3713 cff.charset = charset;
3714 cff.encoding = encoding;
3715
3716 var charStringsAndSeacs = this.parseCharStrings(
3717 charStringIndex,
3718 topDict.privateDict.subrsIndex,
3719 globalSubrIndex.obj,
3720 cff.fdSelect,
3721 cff.fdArray);
3722 cff.charStrings = charStringsAndSeacs.charStrings;
3723 cff.seacs = charStringsAndSeacs.seacs;
3724 cff.widths = charStringsAndSeacs.widths;
3725
3726 return cff;
3727 },
3728 parseHeader: function CFFParser_parseHeader() {
3729 var bytes = this.bytes;
3730 var bytesLength = bytes.length;
3731 var offset = 0;
3732
3733 // Prevent an infinite loop, by checking that the offset is within the
3734 // bounds of the bytes array. Necessary in empty, or invalid, font files.
3735 while (offset < bytesLength && bytes[offset] !== 1) {
3736 ++offset;
3737 }
3738 if (offset >= bytesLength) {
3739 error('Invalid CFF header');
3740 } else if (offset !== 0) {
3741 info('cff data is shifted');
3742 bytes = bytes.subarray(offset);
3743 this.bytes = bytes;
3744 }
3745 var major = bytes[0];
3746 var minor = bytes[1];
3747 var hdrSize = bytes[2];
3748 var offSize = bytes[3];
3749 var header = new CFFHeader(major, minor, hdrSize, offSize);
3750 return { obj: header, endPos: hdrSize };
3751 },
3752 parseDict: function CFFParser_parseDict(dict) {
3753 var pos = 0;
3754
3755 function parseOperand() {
3756 var value = dict[pos++];
3757 if (value === 30) {
3758 return parseFloatOperand();
3759 } else if (value === 28) {
3760 value = dict[pos++];
3761 value = ((value << 24) | (dict[pos++] << 16)) >> 16;
3762 return value;
3763 } else if (value === 29) {
3764 value = dict[pos++];
3765 value = (value << 8) | dict[pos++];
3766 value = (value << 8) | dict[pos++];
3767 value = (value << 8) | dict[pos++];
3768 return value;
3769 } else if (value >= 32 && value <= 246) {
3770 return value - 139;
3771 } else if (value >= 247 && value <= 250) {
3772 return ((value - 247) * 256) + dict[pos++] + 108;
3773 } else if (value >= 251 && value <= 254) {
3774 return -((value - 251) * 256) - dict[pos++] - 108;
3775 } else {
3776 error('255 is not a valid DICT command');
3777 }
3778 return -1;
3779 }
3780
3781 function parseFloatOperand() {
3782 var str = '';
3783 var eof = 15;
3784 var lookup = ['0', '1', '2', '3', '4', '5', '6', '7', '8',
3785 '9', '.', 'E', 'E-', null, '-'];
3786 var length = dict.length;
3787 while (pos < length) {
3788 var b = dict[pos++];
3789 var b1 = b >> 4;
3790 var b2 = b & 15;
3791
3792 if (b1 === eof) {
3793 break;
3794 }
3795 str += lookup[b1];
3796
3797 if (b2 === eof) {
3798 break;
3799 }
3800 str += lookup[b2];
3801 }
3802 return parseFloat(str);
3803 }
3804
3805 var operands = [];
3806 var entries = [];
3807
3808 pos = 0;
3809 var end = dict.length;
3810 while (pos < end) {
3811 var b = dict[pos];
3812 if (b <= 21) {
3813 if (b === 12) {
3814 b = (b << 8) | dict[++pos];
3815 }
3816 entries.push([b, operands]);
3817 operands = [];
3818 ++pos;
3819 } else {
3820 operands.push(parseOperand());
3821 }
3822 }
3823 return entries;
3824 },
3825 parseIndex: function CFFParser_parseIndex(pos) {
3826 var cffIndex = new CFFIndex();
3827 var bytes = this.bytes;
3828 var count = (bytes[pos++] << 8) | bytes[pos++];
3829 var offsets = [];
3830 var end = pos;
3831 var i, ii;
3832
3833 if (count !== 0) {
3834 var offsetSize = bytes[pos++];
3835 // add 1 for offset to determine size of last object
3836 var startPos = pos + ((count + 1) * offsetSize) - 1;
3837
3838 for (i = 0, ii = count + 1; i < ii; ++i) {
3839 var offset = 0;
3840 for (var j = 0; j < offsetSize; ++j) {
3841 offset <<= 8;
3842 offset += bytes[pos++];
3843 }
3844 offsets.push(startPos + offset);
3845 }
3846 end = offsets[count];
3847 }
3848 for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
3849 var offsetStart = offsets[i];
3850 var offsetEnd = offsets[i + 1];
3851 cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
3852 }
3853 return {obj: cffIndex, endPos: end};
3854 },
3855 parseNameIndex: function CFFParser_parseNameIndex(index) {
3856 var names = [];
3857 for (var i = 0, ii = index.count; i < ii; ++i) {
3858 var name = index.get(i);
3859 // OTS doesn't allow names to be over 127 characters.
3860 var length = Math.min(name.length, 127);
3861 var data = [];
3862 // OTS also only permits certain characters in the name.
3863 for (var j = 0; j < length; ++j) {
3864 var c = name[j];
3865 if (j === 0 && c === 0) {
3866 data[j] = c;
3867 continue;
3868 }
3869 if ((c < 33 || c > 126) || c === 91 /* [ */ || c === 93 /* ] */ ||
3870 c === 40 /* ( */ || c === 41 /* ) */ || c === 123 /* { */ ||
3871 c === 125 /* } */ || c === 60 /* < */ || c === 62 /* > */ ||
3872 c === 47 /* / */ || c === 37 /* % */ || c === 35 /* # */) {
3873 data[j] = 95;
3874 continue;
3875 }
3876 data[j] = c;
3877 }
3878 names.push(bytesToString(data));
3879 }
3880 return names;
3881 },
3882 parseStringIndex: function CFFParser_parseStringIndex(index) {
3883 var strings = new CFFStrings();
3884 for (var i = 0, ii = index.count; i < ii; ++i) {
3885 var data = index.get(i);
3886 strings.add(bytesToString(data));
3887 }
3888 return strings;
3889 },
3890 createDict: function CFFParser_createDict(Type, dict, strings) {
3891 var cffDict = new Type(strings);
3892 for (var i = 0, ii = dict.length; i < ii; ++i) {
3893 var pair = dict[i];
3894 var key = pair[0];
3895 var value = pair[1];
3896 cffDict.setByKey(key, value);
3897 }
3898 return cffDict;
3899 },
3900 parseCharString: function CFFParser_parseCharString(state, data,
3901 localSubrIndex,
3902 globalSubrIndex) {
3903 if (state.callDepth > MAX_SUBR_NESTING) {
3904 return false;
3905 }
3906 var stackSize = state.stackSize;
3907 var stack = state.stack;
3908
3909 var length = data.length;
3910
3911 for (var j = 0; j < length;) {
3912 var value = data[j++];
3913 var validationCommand = null;
3914 if (value === 12) {
3915 var q = data[j++];
3916 if (q === 0) {
3917 // The CFF specification state that the 'dotsection' command
3918 // (12, 0) is deprecated and treated as a no-op, but all Type2
3919 // charstrings processors should support them. Unfortunately
3920 // the font sanitizer don't. As a workaround the sequence (12, 0)
3921 // is replaced by a useless (0, hmoveto).
3922 data[j - 2] = 139;
3923 data[j - 1] = 22;
3924 stackSize = 0;
3925 } else {
3926 validationCommand = CharstringValidationData12[q];
3927 }
3928 } else if (value === 28) { // number (16 bit)
3929 stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16)) >> 16;
3930 j += 2;
3931 stackSize++;
3932 } else if (value === 14) {
3933 if (stackSize >= 4) {
3934 stackSize -= 4;
3935 if (this.seacAnalysisEnabled) {
3936 state.seac = stack.slice(stackSize, stackSize + 4);
3937 return false;
3938 }
3939 }
3940 validationCommand = CharstringValidationData[value];
3941 } else if (value >= 32 && value <= 246) { // number
3942 stack[stackSize] = value - 139;
3943 stackSize++;
3944 } else if (value >= 247 && value <= 254) { // number (+1 bytes)
3945 stack[stackSize] = (value < 251 ?
3946 ((value - 247) << 8) + data[j] + 108 :
3947 -((value - 251) << 8) - data[j] - 108);
3948 j++;
3949 stackSize++;
3950 } else if (value === 255) { // number (32 bit)
3951 stack[stackSize] = ((data[j] << 24) | (data[j + 1] << 16) |
3952 (data[j + 2] << 8) | data[j + 3]) / 65536;
3953 j += 4;
3954 stackSize++;
3955 } else if (value === 19 || value === 20) {
3956 state.hints += stackSize >> 1;
3957 // skipping right amount of hints flag data
3958 j += (state.hints + 7) >> 3;
3959 stackSize %= 2;
3960 validationCommand = CharstringValidationData[value];
3961 } else if (value === 10 || value === 29) {
3962 var subrsIndex;
3963 if (value === 10) {
3964 subrsIndex = localSubrIndex;
3965 } else {
3966 subrsIndex = globalSubrIndex;
3967 }
3968 if (!subrsIndex) {
3969 validationCommand = CharstringValidationData[value];
3970 warn('Missing subrsIndex for ' + validationCommand.id);
3971 return false;
3972 }
3973 var bias = 32768;
3974 if (subrsIndex.count < 1240) {
3975 bias = 107;
3976 } else if (subrsIndex.count < 33900) {
3977 bias = 1131;
3978 }
3979 var subrNumber = stack[--stackSize] + bias;
3980 if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
3981 validationCommand = CharstringValidationData[value];
3982 warn('Out of bounds subrIndex for ' + validationCommand.id);
3983 return false;
3984 }
3985 state.stackSize = stackSize;
3986 state.callDepth++;
3987 var valid = this.parseCharString(state, subrsIndex.get(subrNumber),
3988 localSubrIndex, globalSubrIndex);
3989 if (!valid) {
3990 return false;
3991 }
3992 state.callDepth--;
3993 stackSize = state.stackSize;
3994 continue;
3995 } else if (value === 11) {
3996 state.stackSize = stackSize;
3997 return true;
3998 } else {
3999 validationCommand = CharstringValidationData[value];
4000 }
4001 if (validationCommand) {
4002 if (validationCommand.stem) {
4003 state.hints += stackSize >> 1;
4004 }
4005 if ('min' in validationCommand) {
4006 if (!state.undefStack && stackSize < validationCommand.min) {
4007 warn('Not enough parameters for ' + validationCommand.id +
4008 '; actual: ' + stackSize +
4009 ', expected: ' + validationCommand.min);
4010 return false;
4011 }
4012 }
4013 if (state.firstStackClearing && validationCommand.stackClearing) {
4014 state.firstStackClearing = false;
4015 // the optional character width can be found before the first
4016 // stack-clearing command arguments
4017 stackSize -= validationCommand.min;
4018 if (stackSize >= 2 && validationCommand.stem) {
4019 // there are even amount of arguments for stem commands
4020 stackSize %= 2;
4021 } else if (stackSize > 1) {
4022 warn('Found too many parameters for stack-clearing command');
4023 }
4024 if (stackSize > 0 && stack[stackSize - 1] >= 0) {
4025 state.width = stack[stackSize - 1];
4026 }
4027 }
4028 if ('stackDelta' in validationCommand) {
4029 if ('stackFn' in validationCommand) {
4030 validationCommand.stackFn(stack, stackSize);
4031 }
4032 stackSize += validationCommand.stackDelta;
4033 } else if (validationCommand.stackClearing) {
4034 stackSize = 0;
4035 } else if (validationCommand.resetStack) {
4036 stackSize = 0;
4037 state.undefStack = false;
4038 } else if (validationCommand.undefStack) {
4039 stackSize = 0;
4040 state.undefStack = true;
4041 state.firstStackClearing = false;
4042 }
4043 }
4044 }
4045 state.stackSize = stackSize;
4046 return true;
4047 },
4048 parseCharStrings: function CFFParser_parseCharStrings(charStrings,
4049 localSubrIndex,
4050 globalSubrIndex,
4051 fdSelect,
4052 fdArray) {
4053 var seacs = [];
4054 var widths = [];
4055 var count = charStrings.count;
4056 for (var i = 0; i < count; i++) {
4057 var charstring = charStrings.get(i);
4058 var state = {
4059 callDepth: 0,
4060 stackSize: 0,
4061 stack: [],
4062 undefStack: true,
4063 hints: 0,
4064 firstStackClearing: true,
4065 seac: null,
4066 width: null
4067 };
4068 var valid = true;
4069 var localSubrToUse = null;
4070 if (fdSelect && fdArray.length) {
4071 var fdIndex = fdSelect.getFDIndex(i);
4072 if (fdIndex === -1) {
4073 warn('Glyph index is not in fd select.');
4074 valid = false;
4075 }
4076 if (fdIndex >= fdArray.length) {
4077 warn('Invalid fd index for glyph index.');
4078 valid = false;
4079 }
4080 if (valid) {
4081 localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
4082 }
4083 } else if (localSubrIndex) {
4084 localSubrToUse = localSubrIndex;
4085 }
4086 if (valid) {
4087 valid = this.parseCharString(state, charstring, localSubrToUse,
4088 globalSubrIndex);
4089 }
4090 if (state.width !== null) {
4091 widths[i] = state.width;
4092 }
4093 if (state.seac !== null) {
4094 seacs[i] = state.seac;
4095 }
4096 if (!valid) {
4097 // resetting invalid charstring to single 'endchar'
4098 charStrings.set(i, new Uint8Array([14]));
4099 }
4100 }
4101 return { charStrings: charStrings, seacs: seacs, widths: widths };
4102 },
4103 emptyPrivateDictionary:
4104 function CFFParser_emptyPrivateDictionary(parentDict) {
4105 var privateDict = this.createDict(CFFPrivateDict, [],
4106 parentDict.strings);
4107 parentDict.setByKey(18, [0, 0]);
4108 parentDict.privateDict = privateDict;
4109 },
4110 parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
4111 // no private dict, do nothing
4112 if (!parentDict.hasName('Private')) {
4113 this.emptyPrivateDictionary(parentDict);
4114 return;
4115 }
4116 var privateOffset = parentDict.getByName('Private');
4117 // make sure the params are formatted correctly
4118 if (!isArray(privateOffset) || privateOffset.length !== 2) {
4119 parentDict.removeByName('Private');
4120 return;
4121 }
4122 var size = privateOffset[0];
4123 var offset = privateOffset[1];
4124 // remove empty dicts or ones that refer to invalid location
4125 if (size === 0 || offset >= this.bytes.length) {
4126 this.emptyPrivateDictionary(parentDict);
4127 return;
4128 }
4129
4130 var privateDictEnd = offset + size;
4131 var dictData = this.bytes.subarray(offset, privateDictEnd);
4132 var dict = this.parseDict(dictData);
4133 var privateDict = this.createDict(CFFPrivateDict, dict,
4134 parentDict.strings);
4135 parentDict.privateDict = privateDict;
4136
4137 // Parse the Subrs index also since it's relative to the private dict.
4138 if (!privateDict.getByName('Subrs')) {
4139 return;
4140 }
4141 var subrsOffset = privateDict.getByName('Subrs');
4142 var relativeOffset = offset + subrsOffset;
4143 // Validate the offset.
4144 if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
4145 this.emptyPrivateDictionary(parentDict);
4146 return;
4147 }
4148 var subrsIndex = this.parseIndex(relativeOffset);
4149 privateDict.subrsIndex = subrsIndex.obj;
4150 },
4151 parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
4152 if (pos === 0) {
4153 return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE,
4154 ISOAdobeCharset);
4155 } else if (pos === 1) {
4156 return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT,
4157 ExpertCharset);
4158 } else if (pos === 2) {
4159 return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET,
4160 ExpertSubsetCharset);
4161 }
4162
4163 var bytes = this.bytes;
4164 var start = pos;
4165 var format = bytes[pos++];
4166 var charset = ['.notdef'];
4167 var id, count, i;
4168
4169 // subtract 1 for the .notdef glyph
4170 length -= 1;
4171
4172 switch (format) {
4173 case 0:
4174 for (i = 0; i < length; i++) {
4175 id = (bytes[pos++] << 8) | bytes[pos++];
4176 charset.push(cid ? id : strings.get(id));
4177 }
4178 break;
4179 case 1:
4180 while (charset.length <= length) {
4181 id = (bytes[pos++] << 8) | bytes[pos++];
4182 count = bytes[pos++];
4183 for (i = 0; i <= count; i++) {
4184 charset.push(cid ? id++ : strings.get(id++));
4185 }
4186 }
4187 break;
4188 case 2:
4189 while (charset.length <= length) {
4190 id = (bytes[pos++] << 8) | bytes[pos++];
4191 count = (bytes[pos++] << 8) | bytes[pos++];
4192 for (i = 0; i <= count; i++) {
4193 charset.push(cid ? id++ : strings.get(id++));
4194 }
4195 }
4196 break;
4197 default:
4198 error('Unknown charset format');
4199 }
4200 // Raw won't be needed if we actually compile the charset.
4201 var end = pos;
4202 var raw = bytes.subarray(start, end);
4203
4204 return new CFFCharset(false, format, charset, raw);
4205 },
4206 parseEncoding: function CFFParser_parseEncoding(pos,
4207 properties,
4208 strings,
4209 charset) {
4210 var encoding = Object.create(null);
4211 var bytes = this.bytes;
4212 var predefined = false;
4213 var hasSupplement = false;
4214 var format, i, ii;
4215 var raw = null;
4216
4217 function readSupplement() {
4218 var supplementsCount = bytes[pos++];
4219 for (i = 0; i < supplementsCount; i++) {
4220 var code = bytes[pos++];
4221 var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
4222 encoding[code] = charset.indexOf(strings.get(sid));
4223 }
4224 }
4225
4226 if (pos === 0 || pos === 1) {
4227 predefined = true;
4228 format = pos;
4229 var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
4230 for (i = 0, ii = charset.length; i < ii; i++) {
4231 var index = baseEncoding.indexOf(charset[i]);
4232 if (index !== -1) {
4233 encoding[index] = i;
4234 }
4235 }
4236 } else {
4237 var dataStart = pos;
4238 format = bytes[pos++];
4239 switch (format & 0x7f) {
4240 case 0:
4241 var glyphsCount = bytes[pos++];
4242 for (i = 1; i <= glyphsCount; i++) {
4243 encoding[bytes[pos++]] = i;
4244 }
4245 break;
4246
4247 case 1:
4248 var rangesCount = bytes[pos++];
4249 var gid = 1;
4250 for (i = 0; i < rangesCount; i++) {
4251 var start = bytes[pos++];
4252 var left = bytes[pos++];
4253 for (var j = start; j <= start + left; j++) {
4254 encoding[j] = gid++;
4255 }
4256 }
4257 break;
4258
4259 default:
4260 error('Unknown encoding format: ' + format + ' in CFF');
4261 break;
4262 }
4263 var dataEnd = pos;
4264 if (format & 0x80) {
4265 // The font sanitizer does not support CFF encoding with a
4266 // supplement, since the encoding is not really used to map
4267 // between gid to glyph, let's overwrite what is declared in
4268 // the top dictionary to let the sanitizer think the font use
4269 // StandardEncoding, that's a lie but that's ok.
4270 bytes[dataStart] &= 0x7f;
4271 readSupplement();
4272 hasSupplement = true;
4273 }
4274 raw = bytes.subarray(dataStart, dataEnd);
4275 }
4276 format = format & 0x7f;
4277 return new CFFEncoding(predefined, format, encoding, raw);
4278 },
4279 parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
4280 var start = pos;
4281 var bytes = this.bytes;
4282 var format = bytes[pos++];
4283 var fdSelect = [], rawBytes;
4284 var i, invalidFirstGID = false;
4285
4286 switch (format) {
4287 case 0:
4288 for (i = 0; i < length; ++i) {
4289 var id = bytes[pos++];
4290 fdSelect.push(id);
4291 }
4292 rawBytes = bytes.subarray(start, pos);
4293 break;
4294 case 3:
4295 var rangesCount = (bytes[pos++] << 8) | bytes[pos++];
4296 for (i = 0; i < rangesCount; ++i) {
4297 var first = (bytes[pos++] << 8) | bytes[pos++];
4298 if (i === 0 && first !== 0) {
4299 warn('parseFDSelect: The first range must have a first GID of 0' +
4300 ' -- trying to recover.');
4301 invalidFirstGID = true;
4302 first = 0;
4303 }
4304 var fdIndex = bytes[pos++];
4305 var next = (bytes[pos] << 8) | bytes[pos + 1];
4306 for (var j = first; j < next; ++j) {
4307 fdSelect.push(fdIndex);
4308 }
4309 }
4310 // Advance past the sentinel(next).
4311 pos += 2;
4312 rawBytes = bytes.subarray(start, pos);
4313
4314 if (invalidFirstGID) {
4315 rawBytes[3] = rawBytes[4] = 0; // Adjust the first range, first GID.
4316 }
4317 break;
4318 default:
4319 error('parseFDSelect: Unknown format "' + format + '".');
4320 break;
4321 }
4322 assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
4323
4324 return new CFFFDSelect(fdSelect, rawBytes);
4325 }
4326 };
4327 return CFFParser;
4328})();
4329
4330// Compact Font Format
4331var CFF = (function CFFClosure() {
4332 function CFF() {
4333 this.header = null;
4334 this.names = [];
4335 this.topDict = null;
4336 this.strings = new CFFStrings();
4337 this.globalSubrIndex = null;
4338
4339 // The following could really be per font, but since we only have one font
4340 // store them here.
4341 this.encoding = null;
4342 this.charset = null;
4343 this.charStrings = null;
4344 this.fdArray = [];
4345 this.fdSelect = null;
4346
4347 this.isCIDFont = false;
4348 }
4349 return CFF;
4350})();
4351
4352var CFFHeader = (function CFFHeaderClosure() {
4353 function CFFHeader(major, minor, hdrSize, offSize) {
4354 this.major = major;
4355 this.minor = minor;
4356 this.hdrSize = hdrSize;
4357 this.offSize = offSize;
4358 }
4359 return CFFHeader;
4360})();
4361
4362var CFFStrings = (function CFFStringsClosure() {
4363 function CFFStrings() {
4364 this.strings = [];
4365 }
4366 CFFStrings.prototype = {
4367 get: function CFFStrings_get(index) {
4368 if (index >= 0 && index <= 390) {
4369 return CFFStandardStrings[index];
4370 }
4371 if (index - 391 <= this.strings.length) {
4372 return this.strings[index - 391];
4373 }
4374 return CFFStandardStrings[0];
4375 },
4376 add: function CFFStrings_add(value) {
4377 this.strings.push(value);
4378 },
4379 get count() {
4380 return this.strings.length;
4381 }
4382 };
4383 return CFFStrings;
4384})();
4385
4386var CFFIndex = (function CFFIndexClosure() {
4387 function CFFIndex() {
4388 this.objects = [];
4389 this.length = 0;
4390 }
4391 CFFIndex.prototype = {
4392 add: function CFFIndex_add(data) {
4393 this.length += data.length;
4394 this.objects.push(data);
4395 },
4396 set: function CFFIndex_set(index, data) {
4397 this.length += data.length - this.objects[index].length;
4398 this.objects[index] = data;
4399 },
4400 get: function CFFIndex_get(index) {
4401 return this.objects[index];
4402 },
4403 get count() {
4404 return this.objects.length;
4405 }
4406 };
4407 return CFFIndex;
4408})();
4409
4410var CFFDict = (function CFFDictClosure() {
4411 function CFFDict(tables, strings) {
4412 this.keyToNameMap = tables.keyToNameMap;
4413 this.nameToKeyMap = tables.nameToKeyMap;
4414 this.defaults = tables.defaults;
4415 this.types = tables.types;
4416 this.opcodes = tables.opcodes;
4417 this.order = tables.order;
4418 this.strings = strings;
4419 this.values = Object.create(null);
4420 }
4421 CFFDict.prototype = {
4422 // value should always be an array
4423 setByKey: function CFFDict_setByKey(key, value) {
4424 if (!(key in this.keyToNameMap)) {
4425 return false;
4426 }
4427 // ignore empty values
4428 if (value.length === 0) {
4429 return true;
4430 }
4431 var type = this.types[key];
4432 // remove the array wrapping these types of values
4433 if (type === 'num' || type === 'sid' || type === 'offset') {
4434 value = value[0];
4435 // Ignore invalid values (fixes bug 1068432).
4436 if (isNaN(value)) {
4437 warn('Invalid CFFDict value: ' + value + ', for key: ' + key + '.');
4438 return true;
4439 }
4440 }
4441 this.values[key] = value;
4442 return true;
4443 },
4444 setByName: function CFFDict_setByName(name, value) {
4445 if (!(name in this.nameToKeyMap)) {
4446 error('Invalid dictionary name "' + name + '"');
4447 }
4448 this.values[this.nameToKeyMap[name]] = value;
4449 },
4450 hasName: function CFFDict_hasName(name) {
4451 return this.nameToKeyMap[name] in this.values;
4452 },
4453 getByName: function CFFDict_getByName(name) {
4454 if (!(name in this.nameToKeyMap)) {
4455 error('Invalid dictionary name "' + name + '"');
4456 }
4457 var key = this.nameToKeyMap[name];
4458 if (!(key in this.values)) {
4459 return this.defaults[key];
4460 }
4461 return this.values[key];
4462 },
4463 removeByName: function CFFDict_removeByName(name) {
4464 delete this.values[this.nameToKeyMap[name]];
4465 }
4466 };
4467 CFFDict.createTables = function CFFDict_createTables(layout) {
4468 var tables = {
4469 keyToNameMap: {},
4470 nameToKeyMap: {},
4471 defaults: {},
4472 types: {},
4473 opcodes: {},
4474 order: []
4475 };
4476 for (var i = 0, ii = layout.length; i < ii; ++i) {
4477 var entry = layout[i];
4478 var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
4479 tables.keyToNameMap[key] = entry[1];
4480 tables.nameToKeyMap[entry[1]] = key;
4481 tables.types[key] = entry[2];
4482 tables.defaults[key] = entry[3];
4483 tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
4484 tables.order.push(key);
4485 }
4486 return tables;
4487 };
4488 return CFFDict;
4489})();
4490
4491var CFFTopDict = (function CFFTopDictClosure() {
4492 var layout = [
4493 [[12, 30], 'ROS', ['sid', 'sid', 'num'], null],
4494 [[12, 20], 'SyntheticBase', 'num', null],
4495 [0, 'version', 'sid', null],
4496 [1, 'Notice', 'sid', null],
4497 [[12, 0], 'Copyright', 'sid', null],
4498 [2, 'FullName', 'sid', null],
4499 [3, 'FamilyName', 'sid', null],
4500 [4, 'Weight', 'sid', null],
4501 [[12, 1], 'isFixedPitch', 'num', 0],
4502 [[12, 2], 'ItalicAngle', 'num', 0],
4503 [[12, 3], 'UnderlinePosition', 'num', -100],
4504 [[12, 4], 'UnderlineThickness', 'num', 50],
4505 [[12, 5], 'PaintType', 'num', 0],
4506 [[12, 6], 'CharstringType', 'num', 2],
4507 [[12, 7], 'FontMatrix', ['num', 'num', 'num', 'num', 'num', 'num'],
4508 [0.001, 0, 0, 0.001, 0, 0]],
4509 [13, 'UniqueID', 'num', null],
4510 [5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]],
4511 [[12, 8], 'StrokeWidth', 'num', 0],
4512 [14, 'XUID', 'array', null],
4513 [15, 'charset', 'offset', 0],
4514 [16, 'Encoding', 'offset', 0],
4515 [17, 'CharStrings', 'offset', 0],
4516 [18, 'Private', ['offset', 'offset'], null],
4517 [[12, 21], 'PostScript', 'sid', null],
4518 [[12, 22], 'BaseFontName', 'sid', null],
4519 [[12, 23], 'BaseFontBlend', 'delta', null],
4520 [[12, 31], 'CIDFontVersion', 'num', 0],
4521 [[12, 32], 'CIDFontRevision', 'num', 0],
4522 [[12, 33], 'CIDFontType', 'num', 0],
4523 [[12, 34], 'CIDCount', 'num', 8720],
4524 [[12, 35], 'UIDBase', 'num', null],
4525 // XXX: CID Fonts on DirectWrite 6.1 only seem to work if FDSelect comes
4526 // before FDArray.
4527 [[12, 37], 'FDSelect', 'offset', null],
4528 [[12, 36], 'FDArray', 'offset', null],
4529 [[12, 38], 'FontName', 'sid', null]
4530 ];
4531 var tables = null;
4532 function CFFTopDict(strings) {
4533 if (tables === null) {
4534 tables = CFFDict.createTables(layout);
4535 }
4536 CFFDict.call(this, tables, strings);
4537 this.privateDict = null;
4538 }
4539 CFFTopDict.prototype = Object.create(CFFDict.prototype);
4540 return CFFTopDict;
4541})();
4542
4543var CFFPrivateDict = (function CFFPrivateDictClosure() {
4544 var layout = [
4545 [6, 'BlueValues', 'delta', null],
4546 [7, 'OtherBlues', 'delta', null],
4547 [8, 'FamilyBlues', 'delta', null],
4548 [9, 'FamilyOtherBlues', 'delta', null],
4549 [[12, 9], 'BlueScale', 'num', 0.039625],
4550 [[12, 10], 'BlueShift', 'num', 7],
4551 [[12, 11], 'BlueFuzz', 'num', 1],
4552 [10, 'StdHW', 'num', null],
4553 [11, 'StdVW', 'num', null],
4554 [[12, 12], 'StemSnapH', 'delta', null],
4555 [[12, 13], 'StemSnapV', 'delta', null],
4556 [[12, 14], 'ForceBold', 'num', 0],
4557 [[12, 17], 'LanguageGroup', 'num', 0],
4558 [[12, 18], 'ExpansionFactor', 'num', 0.06],
4559 [[12, 19], 'initialRandomSeed', 'num', 0],
4560 [20, 'defaultWidthX', 'num', 0],
4561 [21, 'nominalWidthX', 'num', 0],
4562 [19, 'Subrs', 'offset', null]
4563 ];
4564 var tables = null;
4565 function CFFPrivateDict(strings) {
4566 if (tables === null) {
4567 tables = CFFDict.createTables(layout);
4568 }
4569 CFFDict.call(this, tables, strings);
4570 this.subrsIndex = null;
4571 }
4572 CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
4573 return CFFPrivateDict;
4574})();
4575
4576var CFFCharsetPredefinedTypes = {
4577 ISO_ADOBE: 0,
4578 EXPERT: 1,
4579 EXPERT_SUBSET: 2
4580};
4581var CFFCharset = (function CFFCharsetClosure() {
4582 function CFFCharset(predefined, format, charset, raw) {
4583 this.predefined = predefined;
4584 this.format = format;
4585 this.charset = charset;
4586 this.raw = raw;
4587 }
4588 return CFFCharset;
4589})();
4590
4591var CFFEncoding = (function CFFEncodingClosure() {
4592 function CFFEncoding(predefined, format, encoding, raw) {
4593 this.predefined = predefined;
4594 this.format = format;
4595 this.encoding = encoding;
4596 this.raw = raw;
4597 }
4598 return CFFEncoding;
4599})();
4600
4601var CFFFDSelect = (function CFFFDSelectClosure() {
4602 function CFFFDSelect(fdSelect, raw) {
4603 this.fdSelect = fdSelect;
4604 this.raw = raw;
4605 }
4606 CFFFDSelect.prototype = {
4607 getFDIndex: function CFFFDSelect_get(glyphIndex) {
4608 if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
4609 return -1;
4610 }
4611 return this.fdSelect[glyphIndex];
4612 }
4613 };
4614 return CFFFDSelect;
4615})();
4616
4617// Helper class to keep track of where an offset is within the data and helps
4618// filling in that offset once it's known.
4619var CFFOffsetTracker = (function CFFOffsetTrackerClosure() {
4620 function CFFOffsetTracker() {
4621 this.offsets = Object.create(null);
4622 }
4623 CFFOffsetTracker.prototype = {
4624 isTracking: function CFFOffsetTracker_isTracking(key) {
4625 return key in this.offsets;
4626 },
4627 track: function CFFOffsetTracker_track(key, location) {
4628 if (key in this.offsets) {
4629 error('Already tracking location of ' + key);
4630 }
4631 this.offsets[key] = location;
4632 },
4633 offset: function CFFOffsetTracker_offset(value) {
4634 for (var key in this.offsets) {
4635 this.offsets[key] += value;
4636 }
4637 },
4638 setEntryLocation: function CFFOffsetTracker_setEntryLocation(key,
4639 values,
4640 output) {
4641 if (!(key in this.offsets)) {
4642 error('Not tracking location of ' + key);
4643 }
4644 var data = output.data;
4645 var dataOffset = this.offsets[key];
4646 var size = 5;
4647 for (var i = 0, ii = values.length; i < ii; ++i) {
4648 var offset0 = i * size + dataOffset;
4649 var offset1 = offset0 + 1;
4650 var offset2 = offset0 + 2;
4651 var offset3 = offset0 + 3;
4652 var offset4 = offset0 + 4;
4653 // It's easy to screw up offsets so perform this sanity check.
4654 if (data[offset0] !== 0x1d || data[offset1] !== 0 ||
4655 data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
4656 error('writing to an offset that is not empty');
4657 }
4658 var value = values[i];
4659 data[offset0] = 0x1d;
4660 data[offset1] = (value >> 24) & 0xFF;
4661 data[offset2] = (value >> 16) & 0xFF;
4662 data[offset3] = (value >> 8) & 0xFF;
4663 data[offset4] = value & 0xFF;
4664 }
4665 }
4666 };
4667 return CFFOffsetTracker;
4668})();
4669
4670// Takes a CFF and converts it to the binary representation.
4671var CFFCompiler = (function CFFCompilerClosure() {
4672 function CFFCompiler(cff) {
4673 this.cff = cff;
4674 }
4675 CFFCompiler.prototype = {
4676 compile: function CFFCompiler_compile() {
4677 var cff = this.cff;
4678 var output = {
4679 data: [],
4680 length: 0,
4681 add: function CFFCompiler_add(data) {
4682 this.data = this.data.concat(data);
4683 this.length = this.data.length;
4684 }
4685 };
4686
4687 // Compile the five entries that must be in order.
4688 var header = this.compileHeader(cff.header);
4689 output.add(header);
4690
4691 var nameIndex = this.compileNameIndex(cff.names);
4692 output.add(nameIndex);
4693
4694 if (cff.isCIDFont) {
4695 // The spec is unclear on how font matrices should relate to each other
4696 // when there is one in the main top dict and the sub top dicts.
4697 // Windows handles this differently than linux and osx so we have to
4698 // normalize to work on all.
4699 // Rules based off of some mailing list discussions:
4700 // - If main font has a matrix and subfont doesn't, use the main matrix.
4701 // - If no main font matrix and there is a subfont matrix, use the
4702 // subfont matrix.
4703 // - If both have matrices, concat together.
4704 // - If neither have matrices, use default.
4705 // To make this work on all platforms we move the top matrix into each
4706 // sub top dict and concat if necessary.
4707 if (cff.topDict.hasName('FontMatrix')) {
4708 var base = cff.topDict.getByName('FontMatrix');
4709 cff.topDict.removeByName('FontMatrix');
4710 for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
4711 var subDict = cff.fdArray[i];
4712 var matrix = base.slice(0);
4713 if (subDict.hasName('FontMatrix')) {
4714 matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
4715 }
4716 subDict.setByName('FontMatrix', matrix);
4717 }
4718 }
4719 }
4720
4721 var compiled = this.compileTopDicts([cff.topDict],
4722 output.length,
4723 cff.isCIDFont);
4724 output.add(compiled.output);
4725 var topDictTracker = compiled.trackers[0];
4726
4727 var stringIndex = this.compileStringIndex(cff.strings.strings);
4728 output.add(stringIndex);
4729
4730 var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
4731 output.add(globalSubrIndex);
4732
4733 // Now start on the other entries that have no specific order.
4734 if (cff.encoding && cff.topDict.hasName('Encoding')) {
4735 if (cff.encoding.predefined) {
4736 topDictTracker.setEntryLocation('Encoding', [cff.encoding.format],
4737 output);
4738 } else {
4739 var encoding = this.compileEncoding(cff.encoding);
4740 topDictTracker.setEntryLocation('Encoding', [output.length], output);
4741 output.add(encoding);
4742 }
4743 }
4744
4745 if (cff.charset && cff.topDict.hasName('charset')) {
4746 if (cff.charset.predefined) {
4747 topDictTracker.setEntryLocation('charset', [cff.charset.format],
4748 output);
4749 } else {
4750 var charset = this.compileCharset(cff.charset);
4751 topDictTracker.setEntryLocation('charset', [output.length], output);
4752 output.add(charset);
4753 }
4754 }
4755
4756 var charStrings = this.compileCharStrings(cff.charStrings);
4757 topDictTracker.setEntryLocation('CharStrings', [output.length], output);
4758 output.add(charStrings);
4759
4760 if (cff.isCIDFont) {
4761 // For some reason FDSelect must be in front of FDArray on windows. OSX
4762 // and linux don't seem to care.
4763 topDictTracker.setEntryLocation('FDSelect', [output.length], output);
4764 var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
4765 output.add(fdSelect);
4766 // It is unclear if the sub font dictionary can have CID related
4767 // dictionary keys, but the sanitizer doesn't like them so remove them.
4768 compiled = this.compileTopDicts(cff.fdArray, output.length, true);
4769 topDictTracker.setEntryLocation('FDArray', [output.length], output);
4770 output.add(compiled.output);
4771 var fontDictTrackers = compiled.trackers;
4772
4773 this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
4774 }
4775
4776 this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
4777
4778 // If the font data ends with INDEX whose object data is zero-length,
4779 // the sanitizer will bail out. Add a dummy byte to avoid that.
4780 output.add([0]);
4781
4782 return output.data;
4783 },
4784 encodeNumber: function CFFCompiler_encodeNumber(value) {
4785 if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) { // isInt
4786 return this.encodeInteger(value);
4787 } else {
4788 return this.encodeFloat(value);
4789 }
4790 },
4791 encodeFloat: function CFFCompiler_encodeFloat(num) {
4792 var value = num.toString();
4793
4794 // rounding inaccurate doubles
4795 var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
4796 if (m) {
4797 var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
4798 value = (Math.round(num * epsilon) / epsilon).toString();
4799 }
4800
4801 var nibbles = '';
4802 var i, ii;
4803 for (i = 0, ii = value.length; i < ii; ++i) {
4804 var a = value[i];
4805 if (a === 'e') {
4806 nibbles += value[++i] === '-' ? 'c' : 'b';
4807 } else if (a === '.') {
4808 nibbles += 'a';
4809 } else if (a === '-') {
4810 nibbles += 'e';
4811 } else {
4812 nibbles += a;
4813 }
4814 }
4815 nibbles += (nibbles.length & 1) ? 'f' : 'ff';
4816 var out = [30];
4817 for (i = 0, ii = nibbles.length; i < ii; i += 2) {
4818 out.push(parseInt(nibbles.substr(i, 2), 16));
4819 }
4820 return out;
4821 },
4822 encodeInteger: function CFFCompiler_encodeInteger(value) {
4823 var code;
4824 if (value >= -107 && value <= 107) {
4825 code = [value + 139];
4826 } else if (value >= 108 && value <= 1131) {
4827 value = value - 108;
4828 code = [(value >> 8) + 247, value & 0xFF];
4829 } else if (value >= -1131 && value <= -108) {
4830 value = -value - 108;
4831 code = [(value >> 8) + 251, value & 0xFF];
4832 } else if (value >= -32768 && value <= 32767) {
4833 code = [0x1c, (value >> 8) & 0xFF, value & 0xFF];
4834 } else {
4835 code = [0x1d,
4836 (value >> 24) & 0xFF,
4837 (value >> 16) & 0xFF,
4838 (value >> 8) & 0xFF,
4839 value & 0xFF];
4840 }
4841 return code;
4842 },
4843 compileHeader: function CFFCompiler_compileHeader(header) {
4844 return [
4845 header.major,
4846 header.minor,
4847 header.hdrSize,
4848 header.offSize
4849 ];
4850 },
4851 compileNameIndex: function CFFCompiler_compileNameIndex(names) {
4852 var nameIndex = new CFFIndex();
4853 for (var i = 0, ii = names.length; i < ii; ++i) {
4854 nameIndex.add(stringToBytes(names[i]));
4855 }
4856 return this.compileIndex(nameIndex);
4857 },
4858 compileTopDicts: function CFFCompiler_compileTopDicts(dicts,
4859 length,
4860 removeCidKeys) {
4861 var fontDictTrackers = [];
4862 var fdArrayIndex = new CFFIndex();
4863 for (var i = 0, ii = dicts.length; i < ii; ++i) {
4864 var fontDict = dicts[i];
4865 if (removeCidKeys) {
4866 fontDict.removeByName('CIDFontVersion');
4867 fontDict.removeByName('CIDFontRevision');
4868 fontDict.removeByName('CIDFontType');
4869 fontDict.removeByName('CIDCount');
4870 fontDict.removeByName('UIDBase');
4871 }
4872 var fontDictTracker = new CFFOffsetTracker();
4873 var fontDictData = this.compileDict(fontDict, fontDictTracker);
4874 fontDictTrackers.push(fontDictTracker);
4875 fdArrayIndex.add(fontDictData);
4876 fontDictTracker.offset(length);
4877 }
4878 fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
4879 return {
4880 trackers: fontDictTrackers,
4881 output: fdArrayIndex
4882 };
4883 },
4884 compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts,
4885 trackers,
4886 output) {
4887 for (var i = 0, ii = dicts.length; i < ii; ++i) {
4888 var fontDict = dicts[i];
4889 assert(fontDict.privateDict && fontDict.hasName('Private'),
4890 'There must be an private dictionary.');
4891 var privateDict = fontDict.privateDict;
4892 var privateDictTracker = new CFFOffsetTracker();
4893 var privateDictData = this.compileDict(privateDict, privateDictTracker);
4894
4895 var outputLength = output.length;
4896 privateDictTracker.offset(outputLength);
4897 if (!privateDictData.length) {
4898 // The private dictionary was empty, set the output length to zero to
4899 // ensure the offset length isn't out of bounds in the eyes of the
4900 // sanitizer.
4901 outputLength = 0;
4902 }
4903
4904 trackers[i].setEntryLocation('Private',
4905 [privateDictData.length, outputLength],
4906 output);
4907 output.add(privateDictData);
4908
4909 if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
4910 var subrs = this.compileIndex(privateDict.subrsIndex);
4911 privateDictTracker.setEntryLocation('Subrs', [privateDictData.length],
4912 output);
4913 output.add(subrs);
4914 }
4915 }
4916 },
4917 compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
4918 var out = [];
4919 // The dictionary keys must be in a certain order.
4920 var order = dict.order;
4921 for (var i = 0; i < order.length; ++i) {
4922 var key = order[i];
4923 if (!(key in dict.values)) {
4924 continue;
4925 }
4926 var values = dict.values[key];
4927 var types = dict.types[key];
4928 if (!isArray(types)) {
4929 types = [types];
4930 }
4931 if (!isArray(values)) {
4932 values = [values];
4933 }
4934
4935 // Remove any empty dict values.
4936 if (values.length === 0) {
4937 continue;
4938 }
4939
4940 for (var j = 0, jj = types.length; j < jj; ++j) {
4941 var type = types[j];
4942 var value = values[j];
4943 switch (type) {
4944 case 'num':
4945 case 'sid':
4946 out = out.concat(this.encodeNumber(value));
4947 break;
4948 case 'offset':
4949 // For offsets we just insert a 32bit integer so we don't have to
4950 // deal with figuring out the length of the offset when it gets
4951 // replaced later on by the compiler.
4952 var name = dict.keyToNameMap[key];
4953 // Some offsets have the offset and the length, so just record the
4954 // position of the first one.
4955 if (!offsetTracker.isTracking(name)) {
4956 offsetTracker.track(name, out.length);
4957 }
4958 out = out.concat([0x1d, 0, 0, 0, 0]);
4959 break;
4960 case 'array':
4961 case 'delta':
4962 out = out.concat(this.encodeNumber(value));
4963 for (var k = 1, kk = values.length; k < kk; ++k) {
4964 out = out.concat(this.encodeNumber(values[k]));
4965 }
4966 break;
4967 default:
4968 error('Unknown data type of ' + type);
4969 break;
4970 }
4971 }
4972 out = out.concat(dict.opcodes[key]);
4973 }
4974 return out;
4975 },
4976 compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
4977 var stringIndex = new CFFIndex();
4978 for (var i = 0, ii = strings.length; i < ii; ++i) {
4979 stringIndex.add(stringToBytes(strings[i]));
4980 }
4981 return this.compileIndex(stringIndex);
4982 },
4983 compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
4984 var globalSubrIndex = this.cff.globalSubrIndex;
4985 this.out.writeByteArray(this.compileIndex(globalSubrIndex));
4986 },
4987 compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
4988 return this.compileIndex(charStrings);
4989 },
4990 compileCharset: function CFFCompiler_compileCharset(charset) {
4991 return this.compileTypedArray(charset.raw);
4992 },
4993 compileEncoding: function CFFCompiler_compileEncoding(encoding) {
4994 return this.compileTypedArray(encoding.raw);
4995 },
4996 compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
4997 return this.compileTypedArray(fdSelect);
4998 },
4999 compileTypedArray: function CFFCompiler_compileTypedArray(data) {
5000 var out = [];
5001 for (var i = 0, ii = data.length; i < ii; ++i) {
5002 out[i] = data[i];
5003 }
5004 return out;
5005 },
5006 compileIndex: function CFFCompiler_compileIndex(index, trackers) {
5007 trackers = trackers || [];
5008 var objects = index.objects;
5009 // First 2 bytes contains the number of objects contained into this index
5010 var count = objects.length;
5011
5012 // If there is no object, just create an index. This technically
5013 // should just be [0, 0] but OTS has an issue with that.
5014 if (count === 0) {
5015 return [0, 0, 0];
5016 }
5017
5018 var data = [(count >> 8) & 0xFF, count & 0xff];
5019
5020 var lastOffset = 1, i;
5021 for (i = 0; i < count; ++i) {
5022 lastOffset += objects[i].length;
5023 }
5024
5025 var offsetSize;
5026 if (lastOffset < 0x100) {
5027 offsetSize = 1;
5028 } else if (lastOffset < 0x10000) {
5029 offsetSize = 2;
5030 } else if (lastOffset < 0x1000000) {
5031 offsetSize = 3;
5032 } else {
5033 offsetSize = 4;
5034 }
5035
5036 // Next byte contains the offset size use to reference object in the file
5037 data.push(offsetSize);
5038
5039 // Add another offset after this one because we need a new offset
5040 var relativeOffset = 1;
5041 for (i = 0; i < count + 1; i++) {
5042 if (offsetSize === 1) {
5043 data.push(relativeOffset & 0xFF);
5044 } else if (offsetSize === 2) {
5045 data.push((relativeOffset >> 8) & 0xFF,
5046 relativeOffset & 0xFF);
5047 } else if (offsetSize === 3) {
5048 data.push((relativeOffset >> 16) & 0xFF,
5049 (relativeOffset >> 8) & 0xFF,
5050 relativeOffset & 0xFF);
5051 } else {
5052 data.push((relativeOffset >>> 24) & 0xFF,
5053 (relativeOffset >> 16) & 0xFF,
5054 (relativeOffset >> 8) & 0xFF,
5055 relativeOffset & 0xFF);
5056 }
5057
5058 if (objects[i]) {
5059 relativeOffset += objects[i].length;
5060 }
5061 }
5062
5063 for (i = 0; i < count; i++) {
5064 // Notify the tracker where the object will be offset in the data.
5065 if (trackers[i]) {
5066 trackers[i].offset(data.length);
5067 }
5068 for (var j = 0, jj = objects[i].length; j < jj; j++) {
5069 data.push(objects[i][j]);
5070 }
5071 }
5072 return data;
5073 }
5074 };
5075 return CFFCompiler;
5076})();
5077
5078exports.CFFStandardStrings = CFFStandardStrings;
5079exports.CFFParser = CFFParser;
5080exports.CFF = CFF;
5081exports.CFFHeader = CFFHeader;
5082exports.CFFStrings = CFFStrings;
5083exports.CFFIndex = CFFIndex;
5084exports.CFFCharset = CFFCharset;
5085exports.CFFTopDict = CFFTopDict;
5086exports.CFFPrivateDict = CFFPrivateDict;
5087exports.CFFCompiler = CFFCompiler;
5088}));
5089
5090
5091(function (root, factory) {
5092 {
5093 factory((root.pdfjsCoreChunkedStream = {}), root.pdfjsSharedUtil);
5094 }
5095}(this, function (exports, sharedUtil) {
5096
5097var MissingDataException = sharedUtil.MissingDataException;
5098var arrayByteLength = sharedUtil.arrayByteLength;
5099var arraysToBytes = sharedUtil.arraysToBytes;
5100var assert = sharedUtil.assert;
5101var createPromiseCapability = sharedUtil.createPromiseCapability;
5102var isInt = sharedUtil.isInt;
5103var isEmptyObj = sharedUtil.isEmptyObj;
5104
5105var ChunkedStream = (function ChunkedStreamClosure() {
5106 function ChunkedStream(length, chunkSize, manager) {
5107 this.bytes = new Uint8Array(length);
5108 this.start = 0;
5109 this.pos = 0;
5110 this.end = length;
5111 this.chunkSize = chunkSize;
5112 this.loadedChunks = [];
5113 this.numChunksLoaded = 0;
5114 this.numChunks = Math.ceil(length / chunkSize);
5115 this.manager = manager;
5116 this.progressiveDataLength = 0;
5117 this.lastSuccessfulEnsureByteChunk = -1; // a single-entry cache
5118 }
5119
5120 // required methods for a stream. if a particular stream does not
5121 // implement these, an error should be thrown
5122 ChunkedStream.prototype = {
5123
5124 getMissingChunks: function ChunkedStream_getMissingChunks() {
5125 var chunks = [];
5126 for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
5127 if (!this.loadedChunks[chunk]) {
5128 chunks.push(chunk);
5129 }
5130 }
5131 return chunks;
5132 },
5133
5134 getBaseStreams: function ChunkedStream_getBaseStreams() {
5135 return [this];
5136 },
5137
5138 allChunksLoaded: function ChunkedStream_allChunksLoaded() {
5139 return this.numChunksLoaded === this.numChunks;
5140 },
5141
5142 onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
5143 var end = begin + chunk.byteLength;
5144
5145 assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
5146 // Using this.length is inaccurate here since this.start can be moved
5147 // See ChunkedStream.moveStart()
5148 var length = this.bytes.length;
5149 assert(end % this.chunkSize === 0 || end === length,
5150 'Bad end offset: ' + end);
5151
5152 this.bytes.set(new Uint8Array(chunk), begin);
5153 var chunkSize = this.chunkSize;
5154 var beginChunk = Math.floor(begin / chunkSize);
5155 var endChunk = Math.floor((end - 1) / chunkSize) + 1;
5156 var curChunk;
5157
5158 for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
5159 if (!this.loadedChunks[curChunk]) {
5160 this.loadedChunks[curChunk] = true;
5161 ++this.numChunksLoaded;
5162 }
5163 }
5164 },
5165
5166 onReceiveProgressiveData:
5167 function ChunkedStream_onReceiveProgressiveData(data) {
5168 var position = this.progressiveDataLength;
5169 var beginChunk = Math.floor(position / this.chunkSize);
5170
5171 this.bytes.set(new Uint8Array(data), position);
5172 position += data.byteLength;
5173 this.progressiveDataLength = position;
5174 var endChunk = position >= this.end ? this.numChunks :
5175 Math.floor(position / this.chunkSize);
5176 var curChunk;
5177 for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
5178 if (!this.loadedChunks[curChunk]) {
5179 this.loadedChunks[curChunk] = true;
5180 ++this.numChunksLoaded;
5181 }
5182 }
5183 },
5184
5185 ensureByte: function ChunkedStream_ensureByte(pos) {
5186 var chunk = Math.floor(pos / this.chunkSize);
5187 if (chunk === this.lastSuccessfulEnsureByteChunk) {
5188 return;
5189 }
5190
5191 if (!this.loadedChunks[chunk]) {
5192 throw new MissingDataException(pos, pos + 1);
5193 }
5194 this.lastSuccessfulEnsureByteChunk = chunk;
5195 },
5196
5197 ensureRange: function ChunkedStream_ensureRange(begin, end) {
5198 if (begin >= end) {
5199 return;
5200 }
5201
5202 if (end <= this.progressiveDataLength) {
5203 return;
5204 }
5205
5206 var chunkSize = this.chunkSize;
5207 var beginChunk = Math.floor(begin / chunkSize);
5208 var endChunk = Math.floor((end - 1) / chunkSize) + 1;
5209 for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
5210 if (!this.loadedChunks[chunk]) {
5211 throw new MissingDataException(begin, end);
5212 }
5213 }
5214 },
5215
5216 nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
5217 var chunk, numChunks = this.numChunks;
5218 for (var i = 0; i < numChunks; ++i) {
5219 chunk = (beginChunk + i) % numChunks; // Wrap around to beginning
5220 if (!this.loadedChunks[chunk]) {
5221 return chunk;
5222 }
5223 }
5224 return null;
5225 },
5226
5227 hasChunk: function ChunkedStream_hasChunk(chunk) {
5228 return !!this.loadedChunks[chunk];
5229 },
5230
5231 get length() {
5232 return this.end - this.start;
5233 },
5234
5235 get isEmpty() {
5236 return this.length === 0;
5237 },
5238
5239 getByte: function ChunkedStream_getByte() {
5240 var pos = this.pos;
5241 if (pos >= this.end) {
5242 return -1;
5243 }
5244 this.ensureByte(pos);
5245 return this.bytes[this.pos++];
5246 },
5247
5248 getUint16: function ChunkedStream_getUint16() {
5249 var b0 = this.getByte();
5250 var b1 = this.getByte();
5251 if (b0 === -1 || b1 === -1) {
5252 return -1;
5253 }
5254 return (b0 << 8) + b1;
5255 },
5256
5257 getInt32: function ChunkedStream_getInt32() {
5258 var b0 = this.getByte();
5259 var b1 = this.getByte();
5260 var b2 = this.getByte();
5261 var b3 = this.getByte();
5262 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
5263 },
5264
5265 // returns subarray of original buffer
5266 // should only be read
5267 getBytes: function ChunkedStream_getBytes(length) {
5268 var bytes = this.bytes;
5269 var pos = this.pos;
5270 var strEnd = this.end;
5271
5272 if (!length) {
5273 this.ensureRange(pos, strEnd);
5274 return bytes.subarray(pos, strEnd);
5275 }
5276
5277 var end = pos + length;
5278 if (end > strEnd) {
5279 end = strEnd;
5280 }
5281 this.ensureRange(pos, end);
5282
5283 this.pos = end;
5284 return bytes.subarray(pos, end);
5285 },
5286
5287 peekByte: function ChunkedStream_peekByte() {
5288 var peekedByte = this.getByte();
5289 this.pos--;
5290 return peekedByte;
5291 },
5292
5293 peekBytes: function ChunkedStream_peekBytes(length) {
5294 var bytes = this.getBytes(length);
5295 this.pos -= bytes.length;
5296 return bytes;
5297 },
5298
5299 getByteRange: function ChunkedStream_getBytes(begin, end) {
5300 this.ensureRange(begin, end);
5301 return this.bytes.subarray(begin, end);
5302 },
5303
5304 skip: function ChunkedStream_skip(n) {
5305 if (!n) {
5306 n = 1;
5307 }
5308 this.pos += n;
5309 },
5310
5311 reset: function ChunkedStream_reset() {
5312 this.pos = this.start;
5313 },
5314
5315 moveStart: function ChunkedStream_moveStart() {
5316 this.start = this.pos;
5317 },
5318
5319 makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
5320 this.ensureRange(start, start + length);
5321
5322 function ChunkedStreamSubstream() {}
5323 ChunkedStreamSubstream.prototype = Object.create(this);
5324 ChunkedStreamSubstream.prototype.getMissingChunks = function() {
5325 var chunkSize = this.chunkSize;
5326 var beginChunk = Math.floor(this.start / chunkSize);
5327 var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
5328 var missingChunks = [];
5329 for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
5330 if (!this.loadedChunks[chunk]) {
5331 missingChunks.push(chunk);
5332 }
5333 }
5334 return missingChunks;
5335 };
5336 var subStream = new ChunkedStreamSubstream();
5337 subStream.pos = subStream.start = start;
5338 subStream.end = start + length || this.end;
5339 subStream.dict = dict;
5340 return subStream;
5341 },
5342
5343 isStream: true
5344 };
5345
5346 return ChunkedStream;
5347})();
5348
5349var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
5350
5351 function ChunkedStreamManager(pdfNetworkStream, args) {
5352 var chunkSize = args.rangeChunkSize;
5353 var length = args.length;
5354 this.stream = new ChunkedStream(length, chunkSize, this);
5355 this.length = length;
5356 this.chunkSize = chunkSize;
5357 this.pdfNetworkStream = pdfNetworkStream;
5358 this.url = args.url;
5359 this.disableAutoFetch = args.disableAutoFetch;
5360 this.msgHandler = args.msgHandler;
5361
5362 this.currRequestId = 0;
5363
5364 this.chunksNeededByRequest = Object.create(null);
5365 this.requestsByChunk = Object.create(null);
5366 this.promisesByRequest = Object.create(null);
5367 this.progressiveDataLength = 0;
5368 this.aborted = false;
5369
5370 this._loadedStreamCapability = createPromiseCapability();
5371 }
5372
5373 ChunkedStreamManager.prototype = {
5374 onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
5375 return this._loadedStreamCapability.promise;
5376 },
5377
5378 sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
5379 var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
5380 if (!rangeReader.isStreamingSupported) {
5381 rangeReader.onProgress = this.onProgress.bind(this);
5382 }
5383 var chunks = [], loaded = 0;
5384 var manager = this;
5385 var promise = new Promise(function (resolve, reject) {
5386 var readChunk = function (chunk) {
5387 try {
5388 if (!chunk.done) {
5389 var data = chunk.value;
5390 chunks.push(data);
5391 loaded += arrayByteLength(data);
5392 if (rangeReader.isStreamingSupported) {
5393 manager.onProgress({loaded: loaded});
5394 }
5395 rangeReader.read().then(readChunk, reject);
5396 return;
5397 }
5398 var chunkData = arraysToBytes(chunks);
5399 chunks = null;
5400 resolve(chunkData);
5401 } catch (e) {
5402 reject(e);
5403 }
5404 };
5405 rangeReader.read().then(readChunk, reject);
5406 });
5407 promise.then(function (data) {
5408 if (this.aborted) {
5409 return; // ignoring any data after abort
5410 }
5411 this.onReceiveData({chunk: data, begin: begin});
5412 }.bind(this));
5413 // TODO check errors
5414 },
5415
5416 // Get all the chunks that are not yet loaded and groups them into
5417 // contiguous ranges to load in as few requests as possible
5418 requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
5419 var missingChunks = this.stream.getMissingChunks();
5420 this._requestChunks(missingChunks);
5421 return this._loadedStreamCapability.promise;
5422 },
5423
5424 _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
5425 var requestId = this.currRequestId++;
5426
5427 var i, ii;
5428 var chunksNeeded = Object.create(null);
5429 this.chunksNeededByRequest[requestId] = chunksNeeded;
5430 for (i = 0, ii = chunks.length; i < ii; i++) {
5431 if (!this.stream.hasChunk(chunks[i])) {
5432 chunksNeeded[chunks[i]] = true;
5433 }
5434 }
5435
5436 if (isEmptyObj(chunksNeeded)) {
5437 return Promise.resolve();
5438 }
5439
5440 var capability = createPromiseCapability();
5441 this.promisesByRequest[requestId] = capability;
5442
5443 var chunksToRequest = [];
5444 for (var chunk in chunksNeeded) {
5445 chunk = chunk | 0;
5446 if (!(chunk in this.requestsByChunk)) {
5447 this.requestsByChunk[chunk] = [];
5448 chunksToRequest.push(chunk);
5449 }
5450 this.requestsByChunk[chunk].push(requestId);
5451 }
5452
5453 if (!chunksToRequest.length) {
5454 return capability.promise;
5455 }
5456
5457 var groupedChunksToRequest = this.groupChunks(chunksToRequest);
5458
5459 for (i = 0; i < groupedChunksToRequest.length; ++i) {
5460 var groupedChunk = groupedChunksToRequest[i];
5461 var begin = groupedChunk.beginChunk * this.chunkSize;
5462 var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
5463 this.sendRequest(begin, end);
5464 }
5465
5466 return capability.promise;
5467 },
5468
5469 getStream: function ChunkedStreamManager_getStream() {
5470 return this.stream;
5471 },
5472
5473 // Loads any chunks in the requested range that are not yet loaded
5474 requestRange: function ChunkedStreamManager_requestRange(begin, end) {
5475
5476 end = Math.min(end, this.length);
5477
5478 var beginChunk = this.getBeginChunk(begin);
5479 var endChunk = this.getEndChunk(end);
5480
5481 var chunks = [];
5482 for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
5483 chunks.push(chunk);
5484 }
5485
5486 return this._requestChunks(chunks);
5487 },
5488
5489 requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
5490 ranges = ranges || [];
5491 var chunksToRequest = [];
5492
5493 for (var i = 0; i < ranges.length; i++) {
5494 var beginChunk = this.getBeginChunk(ranges[i].begin);
5495 var endChunk = this.getEndChunk(ranges[i].end);
5496 for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
5497 if (chunksToRequest.indexOf(chunk) < 0) {
5498 chunksToRequest.push(chunk);
5499 }
5500 }
5501 }
5502
5503 chunksToRequest.sort(function(a, b) { return a - b; });
5504 return this._requestChunks(chunksToRequest);
5505 },
5506
5507 // Groups a sorted array of chunks into as few contiguous larger
5508 // chunks as possible
5509 groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
5510 var groupedChunks = [];
5511 var beginChunk = -1;
5512 var prevChunk = -1;
5513 for (var i = 0; i < chunks.length; ++i) {
5514 var chunk = chunks[i];
5515
5516 if (beginChunk < 0) {
5517 beginChunk = chunk;
5518 }
5519
5520 if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
5521 groupedChunks.push({ beginChunk: beginChunk,
5522 endChunk: prevChunk + 1 });
5523 beginChunk = chunk;
5524 }
5525 if (i + 1 === chunks.length) {
5526 groupedChunks.push({ beginChunk: beginChunk,
5527 endChunk: chunk + 1 });
5528 }
5529
5530 prevChunk = chunk;
5531 }
5532 return groupedChunks;
5533 },
5534
5535 onProgress: function ChunkedStreamManager_onProgress(args) {
5536 var bytesLoaded = (this.stream.numChunksLoaded * this.chunkSize +
5537 args.loaded);
5538 this.msgHandler.send('DocProgress', {
5539 loaded: bytesLoaded,
5540 total: this.length
5541 });
5542 },
5543
5544 onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
5545 var chunk = args.chunk;
5546 var isProgressive = args.begin === undefined;
5547 var begin = isProgressive ? this.progressiveDataLength : args.begin;
5548 var end = begin + chunk.byteLength;
5549
5550 var beginChunk = Math.floor(begin / this.chunkSize);
5551 var endChunk = end < this.length ? Math.floor(end / this.chunkSize) :
5552 Math.ceil(end / this.chunkSize);
5553
5554 if (isProgressive) {
5555 this.stream.onReceiveProgressiveData(chunk);
5556 this.progressiveDataLength = end;
5557 } else {
5558 this.stream.onReceiveData(begin, chunk);
5559 }
5560
5561 if (this.stream.allChunksLoaded()) {
5562 this._loadedStreamCapability.resolve(this.stream);
5563 }
5564
5565 var loadedRequests = [];
5566 var i, requestId;
5567 for (chunk = beginChunk; chunk < endChunk; ++chunk) {
5568 // The server might return more chunks than requested
5569 var requestIds = this.requestsByChunk[chunk] || [];
5570 delete this.requestsByChunk[chunk];
5571
5572 for (i = 0; i < requestIds.length; ++i) {
5573 requestId = requestIds[i];
5574 var chunksNeeded = this.chunksNeededByRequest[requestId];
5575 if (chunk in chunksNeeded) {
5576 delete chunksNeeded[chunk];
5577 }
5578
5579 if (!isEmptyObj(chunksNeeded)) {
5580 continue;
5581 }
5582
5583 loadedRequests.push(requestId);
5584 }
5585 }
5586
5587 // If there are no pending requests, automatically fetch the next
5588 // unfetched chunk of the PDF
5589 if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
5590 var nextEmptyChunk;
5591 if (this.stream.numChunksLoaded === 1) {
5592 // This is a special optimization so that after fetching the first
5593 // chunk, rather than fetching the second chunk, we fetch the last
5594 // chunk.
5595 var lastChunk = this.stream.numChunks - 1;
5596 if (!this.stream.hasChunk(lastChunk)) {
5597 nextEmptyChunk = lastChunk;
5598 }
5599 } else {
5600 nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
5601 }
5602 if (isInt(nextEmptyChunk)) {
5603 this._requestChunks([nextEmptyChunk]);
5604 }
5605 }
5606
5607 for (i = 0; i < loadedRequests.length; ++i) {
5608 requestId = loadedRequests[i];
5609 var capability = this.promisesByRequest[requestId];
5610 delete this.promisesByRequest[requestId];
5611 capability.resolve();
5612 }
5613
5614 this.msgHandler.send('DocProgress', {
5615 loaded: this.stream.numChunksLoaded * this.chunkSize,
5616 total: this.length
5617 });
5618 },
5619
5620 onError: function ChunkedStreamManager_onError(err) {
5621 this._loadedStreamCapability.reject(err);
5622 },
5623
5624 getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
5625 var chunk = Math.floor(begin / this.chunkSize);
5626 return chunk;
5627 },
5628
5629 getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
5630 var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
5631 return chunk;
5632 },
5633
5634 abort: function ChunkedStreamManager_abort() {
5635 this.aborted = true;
5636 if (this.pdfNetworkStream) {
5637 this.pdfNetworkStream.cancelAllRequests('abort');
5638 }
5639 for(var requestId in this.promisesByRequest) {
5640 var capability = this.promisesByRequest[requestId];
5641 capability.reject(new Error('Request was aborted'));
5642 }
5643 }
5644 };
5645
5646 return ChunkedStreamManager;
5647})();
5648
5649exports.ChunkedStream = ChunkedStream;
5650exports.ChunkedStreamManager = ChunkedStreamManager;
5651}));
5652
5653
5654(function (root, factory) {
5655 {
5656 factory((root.pdfjsCoreGlyphList = {}), root.pdfjsSharedUtil);
5657 }
5658}(this, function (exports, sharedUtil) {
5659var getLookupTableFactory = sharedUtil.getLookupTableFactory;
5660
5661var getGlyphsUnicode = getLookupTableFactory(function (t) {
5662 t['A'] = 0x0041;
5663 t['AE'] = 0x00C6;
5664 t['AEacute'] = 0x01FC;
5665 t['AEmacron'] = 0x01E2;
5666 t['AEsmall'] = 0xF7E6;
5667 t['Aacute'] = 0x00C1;
5668 t['Aacutesmall'] = 0xF7E1;
5669 t['Abreve'] = 0x0102;
5670 t['Abreveacute'] = 0x1EAE;
5671 t['Abrevecyrillic'] = 0x04D0;
5672 t['Abrevedotbelow'] = 0x1EB6;
5673 t['Abrevegrave'] = 0x1EB0;
5674 t['Abrevehookabove'] = 0x1EB2;
5675 t['Abrevetilde'] = 0x1EB4;
5676 t['Acaron'] = 0x01CD;
5677 t['Acircle'] = 0x24B6;
5678 t['Acircumflex'] = 0x00C2;
5679 t['Acircumflexacute'] = 0x1EA4;
5680 t['Acircumflexdotbelow'] = 0x1EAC;
5681 t['Acircumflexgrave'] = 0x1EA6;
5682 t['Acircumflexhookabove'] = 0x1EA8;
5683 t['Acircumflexsmall'] = 0xF7E2;
5684 t['Acircumflextilde'] = 0x1EAA;
5685 t['Acute'] = 0xF6C9;
5686 t['Acutesmall'] = 0xF7B4;
5687 t['Acyrillic'] = 0x0410;
5688 t['Adblgrave'] = 0x0200;
5689 t['Adieresis'] = 0x00C4;
5690 t['Adieresiscyrillic'] = 0x04D2;
5691 t['Adieresismacron'] = 0x01DE;
5692 t['Adieresissmall'] = 0xF7E4;
5693 t['Adotbelow'] = 0x1EA0;
5694 t['Adotmacron'] = 0x01E0;
5695 t['Agrave'] = 0x00C0;
5696 t['Agravesmall'] = 0xF7E0;
5697 t['Ahookabove'] = 0x1EA2;
5698 t['Aiecyrillic'] = 0x04D4;
5699 t['Ainvertedbreve'] = 0x0202;
5700 t['Alpha'] = 0x0391;
5701 t['Alphatonos'] = 0x0386;
5702 t['Amacron'] = 0x0100;
5703 t['Amonospace'] = 0xFF21;
5704 t['Aogonek'] = 0x0104;
5705 t['Aring'] = 0x00C5;
5706 t['Aringacute'] = 0x01FA;
5707 t['Aringbelow'] = 0x1E00;
5708 t['Aringsmall'] = 0xF7E5;
5709 t['Asmall'] = 0xF761;
5710 t['Atilde'] = 0x00C3;
5711 t['Atildesmall'] = 0xF7E3;
5712 t['Aybarmenian'] = 0x0531;
5713 t['B'] = 0x0042;
5714 t['Bcircle'] = 0x24B7;
5715 t['Bdotaccent'] = 0x1E02;
5716 t['Bdotbelow'] = 0x1E04;
5717 t['Becyrillic'] = 0x0411;
5718 t['Benarmenian'] = 0x0532;
5719 t['Beta'] = 0x0392;
5720 t['Bhook'] = 0x0181;
5721 t['Blinebelow'] = 0x1E06;
5722 t['Bmonospace'] = 0xFF22;
5723 t['Brevesmall'] = 0xF6F4;
5724 t['Bsmall'] = 0xF762;
5725 t['Btopbar'] = 0x0182;
5726 t['C'] = 0x0043;
5727 t['Caarmenian'] = 0x053E;
5728 t['Cacute'] = 0x0106;
5729 t['Caron'] = 0xF6CA;
5730 t['Caronsmall'] = 0xF6F5;
5731 t['Ccaron'] = 0x010C;
5732 t['Ccedilla'] = 0x00C7;
5733 t['Ccedillaacute'] = 0x1E08;
5734 t['Ccedillasmall'] = 0xF7E7;
5735 t['Ccircle'] = 0x24B8;
5736 t['Ccircumflex'] = 0x0108;
5737 t['Cdot'] = 0x010A;
5738 t['Cdotaccent'] = 0x010A;
5739 t['Cedillasmall'] = 0xF7B8;
5740 t['Chaarmenian'] = 0x0549;
5741 t['Cheabkhasiancyrillic'] = 0x04BC;
5742 t['Checyrillic'] = 0x0427;
5743 t['Chedescenderabkhasiancyrillic'] = 0x04BE;
5744 t['Chedescendercyrillic'] = 0x04B6;
5745 t['Chedieresiscyrillic'] = 0x04F4;
5746 t['Cheharmenian'] = 0x0543;
5747 t['Chekhakassiancyrillic'] = 0x04CB;
5748 t['Cheverticalstrokecyrillic'] = 0x04B8;
5749 t['Chi'] = 0x03A7;
5750 t['Chook'] = 0x0187;
5751 t['Circumflexsmall'] = 0xF6F6;
5752 t['Cmonospace'] = 0xFF23;
5753 t['Coarmenian'] = 0x0551;
5754 t['Csmall'] = 0xF763;
5755 t['D'] = 0x0044;
5756 t['DZ'] = 0x01F1;
5757 t['DZcaron'] = 0x01C4;
5758 t['Daarmenian'] = 0x0534;
5759 t['Dafrican'] = 0x0189;
5760 t['Dcaron'] = 0x010E;
5761 t['Dcedilla'] = 0x1E10;
5762 t['Dcircle'] = 0x24B9;
5763 t['Dcircumflexbelow'] = 0x1E12;
5764 t['Dcroat'] = 0x0110;
5765 t['Ddotaccent'] = 0x1E0A;
5766 t['Ddotbelow'] = 0x1E0C;
5767 t['Decyrillic'] = 0x0414;
5768 t['Deicoptic'] = 0x03EE;
5769 t['Delta'] = 0x2206;
5770 t['Deltagreek'] = 0x0394;
5771 t['Dhook'] = 0x018A;
5772 t['Dieresis'] = 0xF6CB;
5773 t['DieresisAcute'] = 0xF6CC;
5774 t['DieresisGrave'] = 0xF6CD;
5775 t['Dieresissmall'] = 0xF7A8;
5776 t['Digammagreek'] = 0x03DC;
5777 t['Djecyrillic'] = 0x0402;
5778 t['Dlinebelow'] = 0x1E0E;
5779 t['Dmonospace'] = 0xFF24;
5780 t['Dotaccentsmall'] = 0xF6F7;
5781 t['Dslash'] = 0x0110;
5782 t['Dsmall'] = 0xF764;
5783 t['Dtopbar'] = 0x018B;
5784 t['Dz'] = 0x01F2;
5785 t['Dzcaron'] = 0x01C5;
5786 t['Dzeabkhasiancyrillic'] = 0x04E0;
5787 t['Dzecyrillic'] = 0x0405;
5788 t['Dzhecyrillic'] = 0x040F;
5789 t['E'] = 0x0045;
5790 t['Eacute'] = 0x00C9;
5791 t['Eacutesmall'] = 0xF7E9;
5792 t['Ebreve'] = 0x0114;
5793 t['Ecaron'] = 0x011A;
5794 t['Ecedillabreve'] = 0x1E1C;
5795 t['Echarmenian'] = 0x0535;
5796 t['Ecircle'] = 0x24BA;
5797 t['Ecircumflex'] = 0x00CA;
5798 t['Ecircumflexacute'] = 0x1EBE;
5799 t['Ecircumflexbelow'] = 0x1E18;
5800 t['Ecircumflexdotbelow'] = 0x1EC6;
5801 t['Ecircumflexgrave'] = 0x1EC0;
5802 t['Ecircumflexhookabove'] = 0x1EC2;
5803 t['Ecircumflexsmall'] = 0xF7EA;
5804 t['Ecircumflextilde'] = 0x1EC4;
5805 t['Ecyrillic'] = 0x0404;
5806 t['Edblgrave'] = 0x0204;
5807 t['Edieresis'] = 0x00CB;
5808 t['Edieresissmall'] = 0xF7EB;
5809 t['Edot'] = 0x0116;
5810 t['Edotaccent'] = 0x0116;
5811 t['Edotbelow'] = 0x1EB8;
5812 t['Efcyrillic'] = 0x0424;
5813 t['Egrave'] = 0x00C8;
5814 t['Egravesmall'] = 0xF7E8;
5815 t['Eharmenian'] = 0x0537;
5816 t['Ehookabove'] = 0x1EBA;
5817 t['Eightroman'] = 0x2167;
5818 t['Einvertedbreve'] = 0x0206;
5819 t['Eiotifiedcyrillic'] = 0x0464;
5820 t['Elcyrillic'] = 0x041B;
5821 t['Elevenroman'] = 0x216A;
5822 t['Emacron'] = 0x0112;
5823 t['Emacronacute'] = 0x1E16;
5824 t['Emacrongrave'] = 0x1E14;
5825 t['Emcyrillic'] = 0x041C;
5826 t['Emonospace'] = 0xFF25;
5827 t['Encyrillic'] = 0x041D;
5828 t['Endescendercyrillic'] = 0x04A2;
5829 t['Eng'] = 0x014A;
5830 t['Enghecyrillic'] = 0x04A4;
5831 t['Enhookcyrillic'] = 0x04C7;
5832 t['Eogonek'] = 0x0118;
5833 t['Eopen'] = 0x0190;
5834 t['Epsilon'] = 0x0395;
5835 t['Epsilontonos'] = 0x0388;
5836 t['Ercyrillic'] = 0x0420;
5837 t['Ereversed'] = 0x018E;
5838 t['Ereversedcyrillic'] = 0x042D;
5839 t['Escyrillic'] = 0x0421;
5840 t['Esdescendercyrillic'] = 0x04AA;
5841 t['Esh'] = 0x01A9;
5842 t['Esmall'] = 0xF765;
5843 t['Eta'] = 0x0397;
5844 t['Etarmenian'] = 0x0538;
5845 t['Etatonos'] = 0x0389;
5846 t['Eth'] = 0x00D0;
5847 t['Ethsmall'] = 0xF7F0;
5848 t['Etilde'] = 0x1EBC;
5849 t['Etildebelow'] = 0x1E1A;
5850 t['Euro'] = 0x20AC;
5851 t['Ezh'] = 0x01B7;
5852 t['Ezhcaron'] = 0x01EE;
5853 t['Ezhreversed'] = 0x01B8;
5854 t['F'] = 0x0046;
5855 t['Fcircle'] = 0x24BB;
5856 t['Fdotaccent'] = 0x1E1E;
5857 t['Feharmenian'] = 0x0556;
5858 t['Feicoptic'] = 0x03E4;
5859 t['Fhook'] = 0x0191;
5860 t['Fitacyrillic'] = 0x0472;
5861 t['Fiveroman'] = 0x2164;
5862 t['Fmonospace'] = 0xFF26;
5863 t['Fourroman'] = 0x2163;
5864 t['Fsmall'] = 0xF766;
5865 t['G'] = 0x0047;
5866 t['GBsquare'] = 0x3387;
5867 t['Gacute'] = 0x01F4;
5868 t['Gamma'] = 0x0393;
5869 t['Gammaafrican'] = 0x0194;
5870 t['Gangiacoptic'] = 0x03EA;
5871 t['Gbreve'] = 0x011E;
5872 t['Gcaron'] = 0x01E6;
5873 t['Gcedilla'] = 0x0122;
5874 t['Gcircle'] = 0x24BC;
5875 t['Gcircumflex'] = 0x011C;
5876 t['Gcommaaccent'] = 0x0122;
5877 t['Gdot'] = 0x0120;
5878 t['Gdotaccent'] = 0x0120;
5879 t['Gecyrillic'] = 0x0413;
5880 t['Ghadarmenian'] = 0x0542;
5881 t['Ghemiddlehookcyrillic'] = 0x0494;
5882 t['Ghestrokecyrillic'] = 0x0492;
5883 t['Gheupturncyrillic'] = 0x0490;
5884 t['Ghook'] = 0x0193;
5885 t['Gimarmenian'] = 0x0533;
5886 t['Gjecyrillic'] = 0x0403;
5887 t['Gmacron'] = 0x1E20;
5888 t['Gmonospace'] = 0xFF27;
5889 t['Grave'] = 0xF6CE;
5890 t['Gravesmall'] = 0xF760;
5891 t['Gsmall'] = 0xF767;
5892 t['Gsmallhook'] = 0x029B;
5893 t['Gstroke'] = 0x01E4;
5894 t['H'] = 0x0048;
5895 t['H18533'] = 0x25CF;
5896 t['H18543'] = 0x25AA;
5897 t['H18551'] = 0x25AB;
5898 t['H22073'] = 0x25A1;
5899 t['HPsquare'] = 0x33CB;
5900 t['Haabkhasiancyrillic'] = 0x04A8;
5901 t['Hadescendercyrillic'] = 0x04B2;
5902 t['Hardsigncyrillic'] = 0x042A;
5903 t['Hbar'] = 0x0126;
5904 t['Hbrevebelow'] = 0x1E2A;
5905 t['Hcedilla'] = 0x1E28;
5906 t['Hcircle'] = 0x24BD;
5907 t['Hcircumflex'] = 0x0124;
5908 t['Hdieresis'] = 0x1E26;
5909 t['Hdotaccent'] = 0x1E22;
5910 t['Hdotbelow'] = 0x1E24;
5911 t['Hmonospace'] = 0xFF28;
5912 t['Hoarmenian'] = 0x0540;
5913 t['Horicoptic'] = 0x03E8;
5914 t['Hsmall'] = 0xF768;
5915 t['Hungarumlaut'] = 0xF6CF;
5916 t['Hungarumlautsmall'] = 0xF6F8;
5917 t['Hzsquare'] = 0x3390;
5918 t['I'] = 0x0049;
5919 t['IAcyrillic'] = 0x042F;
5920 t['IJ'] = 0x0132;
5921 t['IUcyrillic'] = 0x042E;
5922 t['Iacute'] = 0x00CD;
5923 t['Iacutesmall'] = 0xF7ED;
5924 t['Ibreve'] = 0x012C;
5925 t['Icaron'] = 0x01CF;
5926 t['Icircle'] = 0x24BE;
5927 t['Icircumflex'] = 0x00CE;
5928 t['Icircumflexsmall'] = 0xF7EE;
5929 t['Icyrillic'] = 0x0406;
5930 t['Idblgrave'] = 0x0208;
5931 t['Idieresis'] = 0x00CF;
5932 t['Idieresisacute'] = 0x1E2E;
5933 t['Idieresiscyrillic'] = 0x04E4;
5934 t['Idieresissmall'] = 0xF7EF;
5935 t['Idot'] = 0x0130;
5936 t['Idotaccent'] = 0x0130;
5937 t['Idotbelow'] = 0x1ECA;
5938 t['Iebrevecyrillic'] = 0x04D6;
5939 t['Iecyrillic'] = 0x0415;
5940 t['Ifraktur'] = 0x2111;
5941 t['Igrave'] = 0x00CC;
5942 t['Igravesmall'] = 0xF7EC;
5943 t['Ihookabove'] = 0x1EC8;
5944 t['Iicyrillic'] = 0x0418;
5945 t['Iinvertedbreve'] = 0x020A;
5946 t['Iishortcyrillic'] = 0x0419;
5947 t['Imacron'] = 0x012A;
5948 t['Imacroncyrillic'] = 0x04E2;
5949 t['Imonospace'] = 0xFF29;
5950 t['Iniarmenian'] = 0x053B;
5951 t['Iocyrillic'] = 0x0401;
5952 t['Iogonek'] = 0x012E;
5953 t['Iota'] = 0x0399;
5954 t['Iotaafrican'] = 0x0196;
5955 t['Iotadieresis'] = 0x03AA;
5956 t['Iotatonos'] = 0x038A;
5957 t['Ismall'] = 0xF769;
5958 t['Istroke'] = 0x0197;
5959 t['Itilde'] = 0x0128;
5960 t['Itildebelow'] = 0x1E2C;
5961 t['Izhitsacyrillic'] = 0x0474;
5962 t['Izhitsadblgravecyrillic'] = 0x0476;
5963 t['J'] = 0x004A;
5964 t['Jaarmenian'] = 0x0541;
5965 t['Jcircle'] = 0x24BF;
5966 t['Jcircumflex'] = 0x0134;
5967 t['Jecyrillic'] = 0x0408;
5968 t['Jheharmenian'] = 0x054B;
5969 t['Jmonospace'] = 0xFF2A;
5970 t['Jsmall'] = 0xF76A;
5971 t['K'] = 0x004B;
5972 t['KBsquare'] = 0x3385;
5973 t['KKsquare'] = 0x33CD;
5974 t['Kabashkircyrillic'] = 0x04A0;
5975 t['Kacute'] = 0x1E30;
5976 t['Kacyrillic'] = 0x041A;
5977 t['Kadescendercyrillic'] = 0x049A;
5978 t['Kahookcyrillic'] = 0x04C3;
5979 t['Kappa'] = 0x039A;
5980 t['Kastrokecyrillic'] = 0x049E;
5981 t['Kaverticalstrokecyrillic'] = 0x049C;
5982 t['Kcaron'] = 0x01E8;
5983 t['Kcedilla'] = 0x0136;
5984 t['Kcircle'] = 0x24C0;
5985 t['Kcommaaccent'] = 0x0136;
5986 t['Kdotbelow'] = 0x1E32;
5987 t['Keharmenian'] = 0x0554;
5988 t['Kenarmenian'] = 0x053F;
5989 t['Khacyrillic'] = 0x0425;
5990 t['Kheicoptic'] = 0x03E6;
5991 t['Khook'] = 0x0198;
5992 t['Kjecyrillic'] = 0x040C;
5993 t['Klinebelow'] = 0x1E34;
5994 t['Kmonospace'] = 0xFF2B;
5995 t['Koppacyrillic'] = 0x0480;
5996 t['Koppagreek'] = 0x03DE;
5997 t['Ksicyrillic'] = 0x046E;
5998 t['Ksmall'] = 0xF76B;
5999 t['L'] = 0x004C;
6000 t['LJ'] = 0x01C7;
6001 t['LL'] = 0xF6BF;
6002 t['Lacute'] = 0x0139;
6003 t['Lambda'] = 0x039B;
6004 t['Lcaron'] = 0x013D;
6005 t['Lcedilla'] = 0x013B;
6006 t['Lcircle'] = 0x24C1;
6007 t['Lcircumflexbelow'] = 0x1E3C;
6008 t['Lcommaaccent'] = 0x013B;
6009 t['Ldot'] = 0x013F;
6010 t['Ldotaccent'] = 0x013F;
6011 t['Ldotbelow'] = 0x1E36;
6012 t['Ldotbelowmacron'] = 0x1E38;
6013 t['Liwnarmenian'] = 0x053C;
6014 t['Lj'] = 0x01C8;
6015 t['Ljecyrillic'] = 0x0409;
6016 t['Llinebelow'] = 0x1E3A;
6017 t['Lmonospace'] = 0xFF2C;
6018 t['Lslash'] = 0x0141;
6019 t['Lslashsmall'] = 0xF6F9;
6020 t['Lsmall'] = 0xF76C;
6021 t['M'] = 0x004D;
6022 t['MBsquare'] = 0x3386;
6023 t['Macron'] = 0xF6D0;
6024 t['Macronsmall'] = 0xF7AF;
6025 t['Macute'] = 0x1E3E;
6026 t['Mcircle'] = 0x24C2;
6027 t['Mdotaccent'] = 0x1E40;
6028 t['Mdotbelow'] = 0x1E42;
6029 t['Menarmenian'] = 0x0544;
6030 t['Mmonospace'] = 0xFF2D;
6031 t['Msmall'] = 0xF76D;
6032 t['Mturned'] = 0x019C;
6033 t['Mu'] = 0x039C;
6034 t['N'] = 0x004E;
6035 t['NJ'] = 0x01CA;
6036 t['Nacute'] = 0x0143;
6037 t['Ncaron'] = 0x0147;
6038 t['Ncedilla'] = 0x0145;
6039 t['Ncircle'] = 0x24C3;
6040 t['Ncircumflexbelow'] = 0x1E4A;
6041 t['Ncommaaccent'] = 0x0145;
6042 t['Ndotaccent'] = 0x1E44;
6043 t['Ndotbelow'] = 0x1E46;
6044 t['Nhookleft'] = 0x019D;
6045 t['Nineroman'] = 0x2168;
6046 t['Nj'] = 0x01CB;
6047 t['Njecyrillic'] = 0x040A;
6048 t['Nlinebelow'] = 0x1E48;
6049 t['Nmonospace'] = 0xFF2E;
6050 t['Nowarmenian'] = 0x0546;
6051 t['Nsmall'] = 0xF76E;
6052 t['Ntilde'] = 0x00D1;
6053 t['Ntildesmall'] = 0xF7F1;
6054 t['Nu'] = 0x039D;
6055 t['O'] = 0x004F;
6056 t['OE'] = 0x0152;
6057 t['OEsmall'] = 0xF6FA;
6058 t['Oacute'] = 0x00D3;
6059 t['Oacutesmall'] = 0xF7F3;
6060 t['Obarredcyrillic'] = 0x04E8;
6061 t['Obarreddieresiscyrillic'] = 0x04EA;
6062 t['Obreve'] = 0x014E;
6063 t['Ocaron'] = 0x01D1;
6064 t['Ocenteredtilde'] = 0x019F;
6065 t['Ocircle'] = 0x24C4;
6066 t['Ocircumflex'] = 0x00D4;
6067 t['Ocircumflexacute'] = 0x1ED0;
6068 t['Ocircumflexdotbelow'] = 0x1ED8;
6069 t['Ocircumflexgrave'] = 0x1ED2;
6070 t['Ocircumflexhookabove'] = 0x1ED4;
6071 t['Ocircumflexsmall'] = 0xF7F4;
6072 t['Ocircumflextilde'] = 0x1ED6;
6073 t['Ocyrillic'] = 0x041E;
6074 t['Odblacute'] = 0x0150;
6075 t['Odblgrave'] = 0x020C;
6076 t['Odieresis'] = 0x00D6;
6077 t['Odieresiscyrillic'] = 0x04E6;
6078 t['Odieresissmall'] = 0xF7F6;
6079 t['Odotbelow'] = 0x1ECC;
6080 t['Ogoneksmall'] = 0xF6FB;
6081 t['Ograve'] = 0x00D2;
6082 t['Ogravesmall'] = 0xF7F2;
6083 t['Oharmenian'] = 0x0555;
6084 t['Ohm'] = 0x2126;
6085 t['Ohookabove'] = 0x1ECE;
6086 t['Ohorn'] = 0x01A0;
6087 t['Ohornacute'] = 0x1EDA;
6088 t['Ohorndotbelow'] = 0x1EE2;
6089 t['Ohorngrave'] = 0x1EDC;
6090 t['Ohornhookabove'] = 0x1EDE;
6091 t['Ohorntilde'] = 0x1EE0;
6092 t['Ohungarumlaut'] = 0x0150;
6093 t['Oi'] = 0x01A2;
6094 t['Oinvertedbreve'] = 0x020E;
6095 t['Omacron'] = 0x014C;
6096 t['Omacronacute'] = 0x1E52;
6097 t['Omacrongrave'] = 0x1E50;
6098 t['Omega'] = 0x2126;
6099 t['Omegacyrillic'] = 0x0460;
6100 t['Omegagreek'] = 0x03A9;
6101 t['Omegaroundcyrillic'] = 0x047A;
6102 t['Omegatitlocyrillic'] = 0x047C;
6103 t['Omegatonos'] = 0x038F;
6104 t['Omicron'] = 0x039F;
6105 t['Omicrontonos'] = 0x038C;
6106 t['Omonospace'] = 0xFF2F;
6107 t['Oneroman'] = 0x2160;
6108 t['Oogonek'] = 0x01EA;
6109 t['Oogonekmacron'] = 0x01EC;
6110 t['Oopen'] = 0x0186;
6111 t['Oslash'] = 0x00D8;
6112 t['Oslashacute'] = 0x01FE;
6113 t['Oslashsmall'] = 0xF7F8;
6114 t['Osmall'] = 0xF76F;
6115 t['Ostrokeacute'] = 0x01FE;
6116 t['Otcyrillic'] = 0x047E;
6117 t['Otilde'] = 0x00D5;
6118 t['Otildeacute'] = 0x1E4C;
6119 t['Otildedieresis'] = 0x1E4E;
6120 t['Otildesmall'] = 0xF7F5;
6121 t['P'] = 0x0050;
6122 t['Pacute'] = 0x1E54;
6123 t['Pcircle'] = 0x24C5;
6124 t['Pdotaccent'] = 0x1E56;
6125 t['Pecyrillic'] = 0x041F;
6126 t['Peharmenian'] = 0x054A;
6127 t['Pemiddlehookcyrillic'] = 0x04A6;
6128 t['Phi'] = 0x03A6;
6129 t['Phook'] = 0x01A4;
6130 t['Pi'] = 0x03A0;
6131 t['Piwrarmenian'] = 0x0553;
6132 t['Pmonospace'] = 0xFF30;
6133 t['Psi'] = 0x03A8;
6134 t['Psicyrillic'] = 0x0470;
6135 t['Psmall'] = 0xF770;
6136 t['Q'] = 0x0051;
6137 t['Qcircle'] = 0x24C6;
6138 t['Qmonospace'] = 0xFF31;
6139 t['Qsmall'] = 0xF771;
6140 t['R'] = 0x0052;
6141 t['Raarmenian'] = 0x054C;
6142 t['Racute'] = 0x0154;
6143 t['Rcaron'] = 0x0158;
6144 t['Rcedilla'] = 0x0156;
6145 t['Rcircle'] = 0x24C7;
6146 t['Rcommaaccent'] = 0x0156;
6147 t['Rdblgrave'] = 0x0210;
6148 t['Rdotaccent'] = 0x1E58;
6149 t['Rdotbelow'] = 0x1E5A;
6150 t['Rdotbelowmacron'] = 0x1E5C;
6151 t['Reharmenian'] = 0x0550;
6152 t['Rfraktur'] = 0x211C;
6153 t['Rho'] = 0x03A1;
6154 t['Ringsmall'] = 0xF6FC;
6155 t['Rinvertedbreve'] = 0x0212;
6156 t['Rlinebelow'] = 0x1E5E;
6157 t['Rmonospace'] = 0xFF32;
6158 t['Rsmall'] = 0xF772;
6159 t['Rsmallinverted'] = 0x0281;
6160 t['Rsmallinvertedsuperior'] = 0x02B6;
6161 t['S'] = 0x0053;
6162 t['SF010000'] = 0x250C;
6163 t['SF020000'] = 0x2514;
6164 t['SF030000'] = 0x2510;
6165 t['SF040000'] = 0x2518;
6166 t['SF050000'] = 0x253C;
6167 t['SF060000'] = 0x252C;
6168 t['SF070000'] = 0x2534;
6169 t['SF080000'] = 0x251C;
6170 t['SF090000'] = 0x2524;
6171 t['SF100000'] = 0x2500;
6172 t['SF110000'] = 0x2502;
6173 t['SF190000'] = 0x2561;
6174 t['SF200000'] = 0x2562;
6175 t['SF210000'] = 0x2556;
6176 t['SF220000'] = 0x2555;
6177 t['SF230000'] = 0x2563;
6178 t['SF240000'] = 0x2551;
6179 t['SF250000'] = 0x2557;
6180 t['SF260000'] = 0x255D;
6181 t['SF270000'] = 0x255C;
6182 t['SF280000'] = 0x255B;
6183 t['SF360000'] = 0x255E;
6184 t['SF370000'] = 0x255F;
6185 t['SF380000'] = 0x255A;
6186 t['SF390000'] = 0x2554;
6187 t['SF400000'] = 0x2569;
6188 t['SF410000'] = 0x2566;
6189 t['SF420000'] = 0x2560;
6190 t['SF430000'] = 0x2550;
6191 t['SF440000'] = 0x256C;
6192 t['SF450000'] = 0x2567;
6193 t['SF460000'] = 0x2568;
6194 t['SF470000'] = 0x2564;
6195 t['SF480000'] = 0x2565;
6196 t['SF490000'] = 0x2559;
6197 t['SF500000'] = 0x2558;
6198 t['SF510000'] = 0x2552;
6199 t['SF520000'] = 0x2553;
6200 t['SF530000'] = 0x256B;
6201 t['SF540000'] = 0x256A;
6202 t['Sacute'] = 0x015A;
6203 t['Sacutedotaccent'] = 0x1E64;
6204 t['Sampigreek'] = 0x03E0;
6205 t['Scaron'] = 0x0160;
6206 t['Scarondotaccent'] = 0x1E66;
6207 t['Scaronsmall'] = 0xF6FD;
6208 t['Scedilla'] = 0x015E;
6209 t['Schwa'] = 0x018F;
6210 t['Schwacyrillic'] = 0x04D8;
6211 t['Schwadieresiscyrillic'] = 0x04DA;
6212 t['Scircle'] = 0x24C8;
6213 t['Scircumflex'] = 0x015C;
6214 t['Scommaaccent'] = 0x0218;
6215 t['Sdotaccent'] = 0x1E60;
6216 t['Sdotbelow'] = 0x1E62;
6217 t['Sdotbelowdotaccent'] = 0x1E68;
6218 t['Seharmenian'] = 0x054D;
6219 t['Sevenroman'] = 0x2166;
6220 t['Shaarmenian'] = 0x0547;
6221 t['Shacyrillic'] = 0x0428;
6222 t['Shchacyrillic'] = 0x0429;
6223 t['Sheicoptic'] = 0x03E2;
6224 t['Shhacyrillic'] = 0x04BA;
6225 t['Shimacoptic'] = 0x03EC;
6226 t['Sigma'] = 0x03A3;
6227 t['Sixroman'] = 0x2165;
6228 t['Smonospace'] = 0xFF33;
6229 t['Softsigncyrillic'] = 0x042C;
6230 t['Ssmall'] = 0xF773;
6231 t['Stigmagreek'] = 0x03DA;
6232 t['T'] = 0x0054;
6233 t['Tau'] = 0x03A4;
6234 t['Tbar'] = 0x0166;
6235 t['Tcaron'] = 0x0164;
6236 t['Tcedilla'] = 0x0162;
6237 t['Tcircle'] = 0x24C9;
6238 t['Tcircumflexbelow'] = 0x1E70;
6239 t['Tcommaaccent'] = 0x0162;
6240 t['Tdotaccent'] = 0x1E6A;
6241 t['Tdotbelow'] = 0x1E6C;
6242 t['Tecyrillic'] = 0x0422;
6243 t['Tedescendercyrillic'] = 0x04AC;
6244 t['Tenroman'] = 0x2169;
6245 t['Tetsecyrillic'] = 0x04B4;
6246 t['Theta'] = 0x0398;
6247 t['Thook'] = 0x01AC;
6248 t['Thorn'] = 0x00DE;
6249 t['Thornsmall'] = 0xF7FE;
6250 t['Threeroman'] = 0x2162;
6251 t['Tildesmall'] = 0xF6FE;
6252 t['Tiwnarmenian'] = 0x054F;
6253 t['Tlinebelow'] = 0x1E6E;
6254 t['Tmonospace'] = 0xFF34;
6255 t['Toarmenian'] = 0x0539;
6256 t['Tonefive'] = 0x01BC;
6257 t['Tonesix'] = 0x0184;
6258 t['Tonetwo'] = 0x01A7;
6259 t['Tretroflexhook'] = 0x01AE;
6260 t['Tsecyrillic'] = 0x0426;
6261 t['Tshecyrillic'] = 0x040B;
6262 t['Tsmall'] = 0xF774;
6263 t['Twelveroman'] = 0x216B;
6264 t['Tworoman'] = 0x2161;
6265 t['U'] = 0x0055;
6266 t['Uacute'] = 0x00DA;
6267 t['Uacutesmall'] = 0xF7FA;
6268 t['Ubreve'] = 0x016C;
6269 t['Ucaron'] = 0x01D3;
6270 t['Ucircle'] = 0x24CA;
6271 t['Ucircumflex'] = 0x00DB;
6272 t['Ucircumflexbelow'] = 0x1E76;
6273 t['Ucircumflexsmall'] = 0xF7FB;
6274 t['Ucyrillic'] = 0x0423;
6275 t['Udblacute'] = 0x0170;
6276 t['Udblgrave'] = 0x0214;
6277 t['Udieresis'] = 0x00DC;
6278 t['Udieresisacute'] = 0x01D7;
6279 t['Udieresisbelow'] = 0x1E72;
6280 t['Udieresiscaron'] = 0x01D9;
6281 t['Udieresiscyrillic'] = 0x04F0;
6282 t['Udieresisgrave'] = 0x01DB;
6283 t['Udieresismacron'] = 0x01D5;
6284 t['Udieresissmall'] = 0xF7FC;
6285 t['Udotbelow'] = 0x1EE4;
6286 t['Ugrave'] = 0x00D9;
6287 t['Ugravesmall'] = 0xF7F9;
6288 t['Uhookabove'] = 0x1EE6;
6289 t['Uhorn'] = 0x01AF;
6290 t['Uhornacute'] = 0x1EE8;
6291 t['Uhorndotbelow'] = 0x1EF0;
6292 t['Uhorngrave'] = 0x1EEA;
6293 t['Uhornhookabove'] = 0x1EEC;
6294 t['Uhorntilde'] = 0x1EEE;
6295 t['Uhungarumlaut'] = 0x0170;
6296 t['Uhungarumlautcyrillic'] = 0x04F2;
6297 t['Uinvertedbreve'] = 0x0216;
6298 t['Ukcyrillic'] = 0x0478;
6299 t['Umacron'] = 0x016A;
6300 t['Umacroncyrillic'] = 0x04EE;
6301 t['Umacrondieresis'] = 0x1E7A;
6302 t['Umonospace'] = 0xFF35;
6303 t['Uogonek'] = 0x0172;
6304 t['Upsilon'] = 0x03A5;
6305 t['Upsilon1'] = 0x03D2;
6306 t['Upsilonacutehooksymbolgreek'] = 0x03D3;
6307 t['Upsilonafrican'] = 0x01B1;
6308 t['Upsilondieresis'] = 0x03AB;
6309 t['Upsilondieresishooksymbolgreek'] = 0x03D4;
6310 t['Upsilonhooksymbol'] = 0x03D2;
6311 t['Upsilontonos'] = 0x038E;
6312 t['Uring'] = 0x016E;
6313 t['Ushortcyrillic'] = 0x040E;
6314 t['Usmall'] = 0xF775;
6315 t['Ustraightcyrillic'] = 0x04AE;
6316 t['Ustraightstrokecyrillic'] = 0x04B0;
6317 t['Utilde'] = 0x0168;
6318 t['Utildeacute'] = 0x1E78;
6319 t['Utildebelow'] = 0x1E74;
6320 t['V'] = 0x0056;
6321 t['Vcircle'] = 0x24CB;
6322 t['Vdotbelow'] = 0x1E7E;
6323 t['Vecyrillic'] = 0x0412;
6324 t['Vewarmenian'] = 0x054E;
6325 t['Vhook'] = 0x01B2;
6326 t['Vmonospace'] = 0xFF36;
6327 t['Voarmenian'] = 0x0548;
6328 t['Vsmall'] = 0xF776;
6329 t['Vtilde'] = 0x1E7C;
6330 t['W'] = 0x0057;
6331 t['Wacute'] = 0x1E82;
6332 t['Wcircle'] = 0x24CC;
6333 t['Wcircumflex'] = 0x0174;
6334 t['Wdieresis'] = 0x1E84;
6335 t['Wdotaccent'] = 0x1E86;
6336 t['Wdotbelow'] = 0x1E88;
6337 t['Wgrave'] = 0x1E80;
6338 t['Wmonospace'] = 0xFF37;
6339 t['Wsmall'] = 0xF777;
6340 t['X'] = 0x0058;
6341 t['Xcircle'] = 0x24CD;
6342 t['Xdieresis'] = 0x1E8C;
6343 t['Xdotaccent'] = 0x1E8A;
6344 t['Xeharmenian'] = 0x053D;
6345 t['Xi'] = 0x039E;
6346 t['Xmonospace'] = 0xFF38;
6347 t['Xsmall'] = 0xF778;
6348 t['Y'] = 0x0059;
6349 t['Yacute'] = 0x00DD;
6350 t['Yacutesmall'] = 0xF7FD;
6351 t['Yatcyrillic'] = 0x0462;
6352 t['Ycircle'] = 0x24CE;
6353 t['Ycircumflex'] = 0x0176;
6354 t['Ydieresis'] = 0x0178;
6355 t['Ydieresissmall'] = 0xF7FF;
6356 t['Ydotaccent'] = 0x1E8E;
6357 t['Ydotbelow'] = 0x1EF4;
6358 t['Yericyrillic'] = 0x042B;
6359 t['Yerudieresiscyrillic'] = 0x04F8;
6360 t['Ygrave'] = 0x1EF2;
6361 t['Yhook'] = 0x01B3;
6362 t['Yhookabove'] = 0x1EF6;
6363 t['Yiarmenian'] = 0x0545;
6364 t['Yicyrillic'] = 0x0407;
6365 t['Yiwnarmenian'] = 0x0552;
6366 t['Ymonospace'] = 0xFF39;
6367 t['Ysmall'] = 0xF779;
6368 t['Ytilde'] = 0x1EF8;
6369 t['Yusbigcyrillic'] = 0x046A;
6370 t['Yusbigiotifiedcyrillic'] = 0x046C;
6371 t['Yuslittlecyrillic'] = 0x0466;
6372 t['Yuslittleiotifiedcyrillic'] = 0x0468;
6373 t['Z'] = 0x005A;
6374 t['Zaarmenian'] = 0x0536;
6375 t['Zacute'] = 0x0179;
6376 t['Zcaron'] = 0x017D;
6377 t['Zcaronsmall'] = 0xF6FF;
6378 t['Zcircle'] = 0x24CF;
6379 t['Zcircumflex'] = 0x1E90;
6380 t['Zdot'] = 0x017B;
6381 t['Zdotaccent'] = 0x017B;
6382 t['Zdotbelow'] = 0x1E92;
6383 t['Zecyrillic'] = 0x0417;
6384 t['Zedescendercyrillic'] = 0x0498;
6385 t['Zedieresiscyrillic'] = 0x04DE;
6386 t['Zeta'] = 0x0396;
6387 t['Zhearmenian'] = 0x053A;
6388 t['Zhebrevecyrillic'] = 0x04C1;
6389 t['Zhecyrillic'] = 0x0416;
6390 t['Zhedescendercyrillic'] = 0x0496;
6391 t['Zhedieresiscyrillic'] = 0x04DC;
6392 t['Zlinebelow'] = 0x1E94;
6393 t['Zmonospace'] = 0xFF3A;
6394 t['Zsmall'] = 0xF77A;
6395 t['Zstroke'] = 0x01B5;
6396 t['a'] = 0x0061;
6397 t['aabengali'] = 0x0986;
6398 t['aacute'] = 0x00E1;
6399 t['aadeva'] = 0x0906;
6400 t['aagujarati'] = 0x0A86;
6401 t['aagurmukhi'] = 0x0A06;
6402 t['aamatragurmukhi'] = 0x0A3E;
6403 t['aarusquare'] = 0x3303;
6404 t['aavowelsignbengali'] = 0x09BE;
6405 t['aavowelsigndeva'] = 0x093E;
6406 t['aavowelsigngujarati'] = 0x0ABE;
6407 t['abbreviationmarkarmenian'] = 0x055F;
6408 t['abbreviationsigndeva'] = 0x0970;
6409 t['abengali'] = 0x0985;
6410 t['abopomofo'] = 0x311A;
6411 t['abreve'] = 0x0103;
6412 t['abreveacute'] = 0x1EAF;
6413 t['abrevecyrillic'] = 0x04D1;
6414 t['abrevedotbelow'] = 0x1EB7;
6415 t['abrevegrave'] = 0x1EB1;
6416 t['abrevehookabove'] = 0x1EB3;
6417 t['abrevetilde'] = 0x1EB5;
6418 t['acaron'] = 0x01CE;
6419 t['acircle'] = 0x24D0;
6420 t['acircumflex'] = 0x00E2;
6421 t['acircumflexacute'] = 0x1EA5;
6422 t['acircumflexdotbelow'] = 0x1EAD;
6423 t['acircumflexgrave'] = 0x1EA7;
6424 t['acircumflexhookabove'] = 0x1EA9;
6425 t['acircumflextilde'] = 0x1EAB;
6426 t['acute'] = 0x00B4;
6427 t['acutebelowcmb'] = 0x0317;
6428 t['acutecmb'] = 0x0301;
6429 t['acutecomb'] = 0x0301;
6430 t['acutedeva'] = 0x0954;
6431 t['acutelowmod'] = 0x02CF;
6432 t['acutetonecmb'] = 0x0341;
6433 t['acyrillic'] = 0x0430;
6434 t['adblgrave'] = 0x0201;
6435 t['addakgurmukhi'] = 0x0A71;
6436 t['adeva'] = 0x0905;
6437 t['adieresis'] = 0x00E4;
6438 t['adieresiscyrillic'] = 0x04D3;
6439 t['adieresismacron'] = 0x01DF;
6440 t['adotbelow'] = 0x1EA1;
6441 t['adotmacron'] = 0x01E1;
6442 t['ae'] = 0x00E6;
6443 t['aeacute'] = 0x01FD;
6444 t['aekorean'] = 0x3150;
6445 t['aemacron'] = 0x01E3;
6446 t['afii00208'] = 0x2015;
6447 t['afii08941'] = 0x20A4;
6448 t['afii10017'] = 0x0410;
6449 t['afii10018'] = 0x0411;
6450 t['afii10019'] = 0x0412;
6451 t['afii10020'] = 0x0413;
6452 t['afii10021'] = 0x0414;
6453 t['afii10022'] = 0x0415;
6454 t['afii10023'] = 0x0401;
6455 t['afii10024'] = 0x0416;
6456 t['afii10025'] = 0x0417;
6457 t['afii10026'] = 0x0418;
6458 t['afii10027'] = 0x0419;
6459 t['afii10028'] = 0x041A;
6460 t['afii10029'] = 0x041B;
6461 t['afii10030'] = 0x041C;
6462 t['afii10031'] = 0x041D;
6463 t['afii10032'] = 0x041E;
6464 t['afii10033'] = 0x041F;
6465 t['afii10034'] = 0x0420;
6466 t['afii10035'] = 0x0421;
6467 t['afii10036'] = 0x0422;
6468 t['afii10037'] = 0x0423;
6469 t['afii10038'] = 0x0424;
6470 t['afii10039'] = 0x0425;
6471 t['afii10040'] = 0x0426;
6472 t['afii10041'] = 0x0427;
6473 t['afii10042'] = 0x0428;
6474 t['afii10043'] = 0x0429;
6475 t['afii10044'] = 0x042A;
6476 t['afii10045'] = 0x042B;
6477 t['afii10046'] = 0x042C;
6478 t['afii10047'] = 0x042D;
6479 t['afii10048'] = 0x042E;
6480 t['afii10049'] = 0x042F;
6481 t['afii10050'] = 0x0490;
6482 t['afii10051'] = 0x0402;
6483 t['afii10052'] = 0x0403;
6484 t['afii10053'] = 0x0404;
6485 t['afii10054'] = 0x0405;
6486 t['afii10055'] = 0x0406;
6487 t['afii10056'] = 0x0407;
6488 t['afii10057'] = 0x0408;
6489 t['afii10058'] = 0x0409;
6490 t['afii10059'] = 0x040A;
6491 t['afii10060'] = 0x040B;
6492 t['afii10061'] = 0x040C;
6493 t['afii10062'] = 0x040E;
6494 t['afii10063'] = 0xF6C4;
6495 t['afii10064'] = 0xF6C5;
6496 t['afii10065'] = 0x0430;
6497 t['afii10066'] = 0x0431;
6498 t['afii10067'] = 0x0432;
6499 t['afii10068'] = 0x0433;
6500 t['afii10069'] = 0x0434;
6501 t['afii10070'] = 0x0435;
6502 t['afii10071'] = 0x0451;
6503 t['afii10072'] = 0x0436;
6504 t['afii10073'] = 0x0437;
6505 t['afii10074'] = 0x0438;
6506 t['afii10075'] = 0x0439;
6507 t['afii10076'] = 0x043A;
6508 t['afii10077'] = 0x043B;
6509 t['afii10078'] = 0x043C;
6510 t['afii10079'] = 0x043D;
6511 t['afii10080'] = 0x043E;
6512 t['afii10081'] = 0x043F;
6513 t['afii10082'] = 0x0440;
6514 t['afii10083'] = 0x0441;
6515 t['afii10084'] = 0x0442;
6516 t['afii10085'] = 0x0443;
6517 t['afii10086'] = 0x0444;
6518 t['afii10087'] = 0x0445;
6519 t['afii10088'] = 0x0446;
6520 t['afii10089'] = 0x0447;
6521 t['afii10090'] = 0x0448;
6522 t['afii10091'] = 0x0449;
6523 t['afii10092'] = 0x044A;
6524 t['afii10093'] = 0x044B;
6525 t['afii10094'] = 0x044C;
6526 t['afii10095'] = 0x044D;
6527 t['afii10096'] = 0x044E;
6528 t['afii10097'] = 0x044F;
6529 t['afii10098'] = 0x0491;
6530 t['afii10099'] = 0x0452;
6531 t['afii10100'] = 0x0453;
6532 t['afii10101'] = 0x0454;
6533 t['afii10102'] = 0x0455;
6534 t['afii10103'] = 0x0456;
6535 t['afii10104'] = 0x0457;
6536 t['afii10105'] = 0x0458;
6537 t['afii10106'] = 0x0459;
6538 t['afii10107'] = 0x045A;
6539 t['afii10108'] = 0x045B;
6540 t['afii10109'] = 0x045C;
6541 t['afii10110'] = 0x045E;
6542 t['afii10145'] = 0x040F;
6543 t['afii10146'] = 0x0462;
6544 t['afii10147'] = 0x0472;
6545 t['afii10148'] = 0x0474;
6546 t['afii10192'] = 0xF6C6;
6547 t['afii10193'] = 0x045F;
6548 t['afii10194'] = 0x0463;
6549 t['afii10195'] = 0x0473;
6550 t['afii10196'] = 0x0475;
6551 t['afii10831'] = 0xF6C7;
6552 t['afii10832'] = 0xF6C8;
6553 t['afii10846'] = 0x04D9;
6554 t['afii299'] = 0x200E;
6555 t['afii300'] = 0x200F;
6556 t['afii301'] = 0x200D;
6557 t['afii57381'] = 0x066A;
6558 t['afii57388'] = 0x060C;
6559 t['afii57392'] = 0x0660;
6560 t['afii57393'] = 0x0661;
6561 t['afii57394'] = 0x0662;
6562 t['afii57395'] = 0x0663;
6563 t['afii57396'] = 0x0664;
6564 t['afii57397'] = 0x0665;
6565 t['afii57398'] = 0x0666;
6566 t['afii57399'] = 0x0667;
6567 t['afii57400'] = 0x0668;
6568 t['afii57401'] = 0x0669;
6569 t['afii57403'] = 0x061B;
6570 t['afii57407'] = 0x061F;
6571 t['afii57409'] = 0x0621;
6572 t['afii57410'] = 0x0622;
6573 t['afii57411'] = 0x0623;
6574 t['afii57412'] = 0x0624;
6575 t['afii57413'] = 0x0625;
6576 t['afii57414'] = 0x0626;
6577 t['afii57415'] = 0x0627;
6578 t['afii57416'] = 0x0628;
6579 t['afii57417'] = 0x0629;
6580 t['afii57418'] = 0x062A;
6581 t['afii57419'] = 0x062B;
6582 t['afii57420'] = 0x062C;
6583 t['afii57421'] = 0x062D;
6584 t['afii57422'] = 0x062E;
6585 t['afii57423'] = 0x062F;
6586 t['afii57424'] = 0x0630;
6587 t['afii57425'] = 0x0631;
6588 t['afii57426'] = 0x0632;
6589 t['afii57427'] = 0x0633;
6590 t['afii57428'] = 0x0634;
6591 t['afii57429'] = 0x0635;
6592 t['afii57430'] = 0x0636;
6593 t['afii57431'] = 0x0637;
6594 t['afii57432'] = 0x0638;
6595 t['afii57433'] = 0x0639;
6596 t['afii57434'] = 0x063A;
6597 t['afii57440'] = 0x0640;
6598 t['afii57441'] = 0x0641;
6599 t['afii57442'] = 0x0642;
6600 t['afii57443'] = 0x0643;
6601 t['afii57444'] = 0x0644;
6602 t['afii57445'] = 0x0645;
6603 t['afii57446'] = 0x0646;
6604 t['afii57448'] = 0x0648;
6605 t['afii57449'] = 0x0649;
6606 t['afii57450'] = 0x064A;
6607 t['afii57451'] = 0x064B;
6608 t['afii57452'] = 0x064C;
6609 t['afii57453'] = 0x064D;
6610 t['afii57454'] = 0x064E;
6611 t['afii57455'] = 0x064F;
6612 t['afii57456'] = 0x0650;
6613 t['afii57457'] = 0x0651;
6614 t['afii57458'] = 0x0652;
6615 t['afii57470'] = 0x0647;
6616 t['afii57505'] = 0x06A4;
6617 t['afii57506'] = 0x067E;
6618 t['afii57507'] = 0x0686;
6619 t['afii57508'] = 0x0698;
6620 t['afii57509'] = 0x06AF;
6621 t['afii57511'] = 0x0679;
6622 t['afii57512'] = 0x0688;
6623 t['afii57513'] = 0x0691;
6624 t['afii57514'] = 0x06BA;
6625 t['afii57519'] = 0x06D2;
6626 t['afii57534'] = 0x06D5;
6627 t['afii57636'] = 0x20AA;
6628 t['afii57645'] = 0x05BE;
6629 t['afii57658'] = 0x05C3;
6630 t['afii57664'] = 0x05D0;
6631 t['afii57665'] = 0x05D1;
6632 t['afii57666'] = 0x05D2;
6633 t['afii57667'] = 0x05D3;
6634 t['afii57668'] = 0x05D4;
6635 t['afii57669'] = 0x05D5;
6636 t['afii57670'] = 0x05D6;
6637 t['afii57671'] = 0x05D7;
6638 t['afii57672'] = 0x05D8;
6639 t['afii57673'] = 0x05D9;
6640 t['afii57674'] = 0x05DA;
6641 t['afii57675'] = 0x05DB;
6642 t['afii57676'] = 0x05DC;
6643 t['afii57677'] = 0x05DD;
6644 t['afii57678'] = 0x05DE;
6645 t['afii57679'] = 0x05DF;
6646 t['afii57680'] = 0x05E0;
6647 t['afii57681'] = 0x05E1;
6648 t['afii57682'] = 0x05E2;
6649 t['afii57683'] = 0x05E3;
6650 t['afii57684'] = 0x05E4;
6651 t['afii57685'] = 0x05E5;
6652 t['afii57686'] = 0x05E6;
6653 t['afii57687'] = 0x05E7;
6654 t['afii57688'] = 0x05E8;
6655 t['afii57689'] = 0x05E9;
6656 t['afii57690'] = 0x05EA;
6657 t['afii57694'] = 0xFB2A;
6658 t['afii57695'] = 0xFB2B;
6659 t['afii57700'] = 0xFB4B;
6660 t['afii57705'] = 0xFB1F;
6661 t['afii57716'] = 0x05F0;
6662 t['afii57717'] = 0x05F1;
6663 t['afii57718'] = 0x05F2;
6664 t['afii57723'] = 0xFB35;
6665 t['afii57793'] = 0x05B4;
6666 t['afii57794'] = 0x05B5;
6667 t['afii57795'] = 0x05B6;
6668 t['afii57796'] = 0x05BB;
6669 t['afii57797'] = 0x05B8;
6670 t['afii57798'] = 0x05B7;
6671 t['afii57799'] = 0x05B0;
6672 t['afii57800'] = 0x05B2;
6673 t['afii57801'] = 0x05B1;
6674 t['afii57802'] = 0x05B3;
6675 t['afii57803'] = 0x05C2;
6676 t['afii57804'] = 0x05C1;
6677 t['afii57806'] = 0x05B9;
6678 t['afii57807'] = 0x05BC;
6679 t['afii57839'] = 0x05BD;
6680 t['afii57841'] = 0x05BF;
6681 t['afii57842'] = 0x05C0;
6682 t['afii57929'] = 0x02BC;
6683 t['afii61248'] = 0x2105;
6684 t['afii61289'] = 0x2113;
6685 t['afii61352'] = 0x2116;
6686 t['afii61573'] = 0x202C;
6687 t['afii61574'] = 0x202D;
6688 t['afii61575'] = 0x202E;
6689 t['afii61664'] = 0x200C;
6690 t['afii63167'] = 0x066D;
6691 t['afii64937'] = 0x02BD;
6692 t['agrave'] = 0x00E0;
6693 t['agujarati'] = 0x0A85;
6694 t['agurmukhi'] = 0x0A05;
6695 t['ahiragana'] = 0x3042;
6696 t['ahookabove'] = 0x1EA3;
6697 t['aibengali'] = 0x0990;
6698 t['aibopomofo'] = 0x311E;
6699 t['aideva'] = 0x0910;
6700 t['aiecyrillic'] = 0x04D5;
6701 t['aigujarati'] = 0x0A90;
6702 t['aigurmukhi'] = 0x0A10;
6703 t['aimatragurmukhi'] = 0x0A48;
6704 t['ainarabic'] = 0x0639;
6705 t['ainfinalarabic'] = 0xFECA;
6706 t['aininitialarabic'] = 0xFECB;
6707 t['ainmedialarabic'] = 0xFECC;
6708 t['ainvertedbreve'] = 0x0203;
6709 t['aivowelsignbengali'] = 0x09C8;
6710 t['aivowelsigndeva'] = 0x0948;
6711 t['aivowelsigngujarati'] = 0x0AC8;
6712 t['akatakana'] = 0x30A2;
6713 t['akatakanahalfwidth'] = 0xFF71;
6714 t['akorean'] = 0x314F;
6715 t['alef'] = 0x05D0;
6716 t['alefarabic'] = 0x0627;
6717 t['alefdageshhebrew'] = 0xFB30;
6718 t['aleffinalarabic'] = 0xFE8E;
6719 t['alefhamzaabovearabic'] = 0x0623;
6720 t['alefhamzaabovefinalarabic'] = 0xFE84;
6721 t['alefhamzabelowarabic'] = 0x0625;
6722 t['alefhamzabelowfinalarabic'] = 0xFE88;
6723 t['alefhebrew'] = 0x05D0;
6724 t['aleflamedhebrew'] = 0xFB4F;
6725 t['alefmaddaabovearabic'] = 0x0622;
6726 t['alefmaddaabovefinalarabic'] = 0xFE82;
6727 t['alefmaksuraarabic'] = 0x0649;
6728 t['alefmaksurafinalarabic'] = 0xFEF0;
6729 t['alefmaksurainitialarabic'] = 0xFEF3;
6730 t['alefmaksuramedialarabic'] = 0xFEF4;
6731 t['alefpatahhebrew'] = 0xFB2E;
6732 t['alefqamatshebrew'] = 0xFB2F;
6733 t['aleph'] = 0x2135;
6734 t['allequal'] = 0x224C;
6735 t['alpha'] = 0x03B1;
6736 t['alphatonos'] = 0x03AC;
6737 t['amacron'] = 0x0101;
6738 t['amonospace'] = 0xFF41;
6739 t['ampersand'] = 0x0026;
6740 t['ampersandmonospace'] = 0xFF06;
6741 t['ampersandsmall'] = 0xF726;
6742 t['amsquare'] = 0x33C2;
6743 t['anbopomofo'] = 0x3122;
6744 t['angbopomofo'] = 0x3124;
6745 t['angbracketleft'] = 0x3008; // Glyph is missing from Adobe's original list.
6746 t['angbracketright'] = 0x3009; // Glyph is missing from Adobe's original list.
6747 t['angkhankhuthai'] = 0x0E5A;
6748 t['angle'] = 0x2220;
6749 t['anglebracketleft'] = 0x3008;
6750 t['anglebracketleftvertical'] = 0xFE3F;
6751 t['anglebracketright'] = 0x3009;
6752 t['anglebracketrightvertical'] = 0xFE40;
6753 t['angleleft'] = 0x2329;
6754 t['angleright'] = 0x232A;
6755 t['angstrom'] = 0x212B;
6756 t['anoteleia'] = 0x0387;
6757 t['anudattadeva'] = 0x0952;
6758 t['anusvarabengali'] = 0x0982;
6759 t['anusvaradeva'] = 0x0902;
6760 t['anusvaragujarati'] = 0x0A82;
6761 t['aogonek'] = 0x0105;
6762 t['apaatosquare'] = 0x3300;
6763 t['aparen'] = 0x249C;
6764 t['apostrophearmenian'] = 0x055A;
6765 t['apostrophemod'] = 0x02BC;
6766 t['apple'] = 0xF8FF;
6767 t['approaches'] = 0x2250;
6768 t['approxequal'] = 0x2248;
6769 t['approxequalorimage'] = 0x2252;
6770 t['approximatelyequal'] = 0x2245;
6771 t['araeaekorean'] = 0x318E;
6772 t['araeakorean'] = 0x318D;
6773 t['arc'] = 0x2312;
6774 t['arighthalfring'] = 0x1E9A;
6775 t['aring'] = 0x00E5;
6776 t['aringacute'] = 0x01FB;
6777 t['aringbelow'] = 0x1E01;
6778 t['arrowboth'] = 0x2194;
6779 t['arrowdashdown'] = 0x21E3;
6780 t['arrowdashleft'] = 0x21E0;
6781 t['arrowdashright'] = 0x21E2;
6782 t['arrowdashup'] = 0x21E1;
6783 t['arrowdblboth'] = 0x21D4;
6784 t['arrowdbldown'] = 0x21D3;
6785 t['arrowdblleft'] = 0x21D0;
6786 t['arrowdblright'] = 0x21D2;
6787 t['arrowdblup'] = 0x21D1;
6788 t['arrowdown'] = 0x2193;
6789 t['arrowdownleft'] = 0x2199;
6790 t['arrowdownright'] = 0x2198;
6791 t['arrowdownwhite'] = 0x21E9;
6792 t['arrowheaddownmod'] = 0x02C5;
6793 t['arrowheadleftmod'] = 0x02C2;
6794 t['arrowheadrightmod'] = 0x02C3;
6795 t['arrowheadupmod'] = 0x02C4;
6796 t['arrowhorizex'] = 0xF8E7;
6797 t['arrowleft'] = 0x2190;
6798 t['arrowleftdbl'] = 0x21D0;
6799 t['arrowleftdblstroke'] = 0x21CD;
6800 t['arrowleftoverright'] = 0x21C6;
6801 t['arrowleftwhite'] = 0x21E6;
6802 t['arrowright'] = 0x2192;
6803 t['arrowrightdblstroke'] = 0x21CF;
6804 t['arrowrightheavy'] = 0x279E;
6805 t['arrowrightoverleft'] = 0x21C4;
6806 t['arrowrightwhite'] = 0x21E8;
6807 t['arrowtableft'] = 0x21E4;
6808 t['arrowtabright'] = 0x21E5;
6809 t['arrowup'] = 0x2191;
6810 t['arrowupdn'] = 0x2195;
6811 t['arrowupdnbse'] = 0x21A8;
6812 t['arrowupdownbase'] = 0x21A8;
6813 t['arrowupleft'] = 0x2196;
6814 t['arrowupleftofdown'] = 0x21C5;
6815 t['arrowupright'] = 0x2197;
6816 t['arrowupwhite'] = 0x21E7;
6817 t['arrowvertex'] = 0xF8E6;
6818 t['asciicircum'] = 0x005E;
6819 t['asciicircummonospace'] = 0xFF3E;
6820 t['asciitilde'] = 0x007E;
6821 t['asciitildemonospace'] = 0xFF5E;
6822 t['ascript'] = 0x0251;
6823 t['ascriptturned'] = 0x0252;
6824 t['asmallhiragana'] = 0x3041;
6825 t['asmallkatakana'] = 0x30A1;
6826 t['asmallkatakanahalfwidth'] = 0xFF67;
6827 t['asterisk'] = 0x002A;
6828 t['asteriskaltonearabic'] = 0x066D;
6829 t['asteriskarabic'] = 0x066D;
6830 t['asteriskmath'] = 0x2217;
6831 t['asteriskmonospace'] = 0xFF0A;
6832 t['asterisksmall'] = 0xFE61;
6833 t['asterism'] = 0x2042;
6834 t['asuperior'] = 0xF6E9;
6835 t['asymptoticallyequal'] = 0x2243;
6836 t['at'] = 0x0040;
6837 t['atilde'] = 0x00E3;
6838 t['atmonospace'] = 0xFF20;
6839 t['atsmall'] = 0xFE6B;
6840 t['aturned'] = 0x0250;
6841 t['aubengali'] = 0x0994;
6842 t['aubopomofo'] = 0x3120;
6843 t['audeva'] = 0x0914;
6844 t['augujarati'] = 0x0A94;
6845 t['augurmukhi'] = 0x0A14;
6846 t['aulengthmarkbengali'] = 0x09D7;
6847 t['aumatragurmukhi'] = 0x0A4C;
6848 t['auvowelsignbengali'] = 0x09CC;
6849 t['auvowelsigndeva'] = 0x094C;
6850 t['auvowelsigngujarati'] = 0x0ACC;
6851 t['avagrahadeva'] = 0x093D;
6852 t['aybarmenian'] = 0x0561;
6853 t['ayin'] = 0x05E2;
6854 t['ayinaltonehebrew'] = 0xFB20;
6855 t['ayinhebrew'] = 0x05E2;
6856 t['b'] = 0x0062;
6857 t['babengali'] = 0x09AC;
6858 t['backslash'] = 0x005C;
6859 t['backslashmonospace'] = 0xFF3C;
6860 t['badeva'] = 0x092C;
6861 t['bagujarati'] = 0x0AAC;
6862 t['bagurmukhi'] = 0x0A2C;
6863 t['bahiragana'] = 0x3070;
6864 t['bahtthai'] = 0x0E3F;
6865 t['bakatakana'] = 0x30D0;
6866 t['bar'] = 0x007C;
6867 t['barmonospace'] = 0xFF5C;
6868 t['bbopomofo'] = 0x3105;
6869 t['bcircle'] = 0x24D1;
6870 t['bdotaccent'] = 0x1E03;
6871 t['bdotbelow'] = 0x1E05;
6872 t['beamedsixteenthnotes'] = 0x266C;
6873 t['because'] = 0x2235;
6874 t['becyrillic'] = 0x0431;
6875 t['beharabic'] = 0x0628;
6876 t['behfinalarabic'] = 0xFE90;
6877 t['behinitialarabic'] = 0xFE91;
6878 t['behiragana'] = 0x3079;
6879 t['behmedialarabic'] = 0xFE92;
6880 t['behmeeminitialarabic'] = 0xFC9F;
6881 t['behmeemisolatedarabic'] = 0xFC08;
6882 t['behnoonfinalarabic'] = 0xFC6D;
6883 t['bekatakana'] = 0x30D9;
6884 t['benarmenian'] = 0x0562;
6885 t['bet'] = 0x05D1;
6886 t['beta'] = 0x03B2;
6887 t['betasymbolgreek'] = 0x03D0;
6888 t['betdagesh'] = 0xFB31;
6889 t['betdageshhebrew'] = 0xFB31;
6890 t['bethebrew'] = 0x05D1;
6891 t['betrafehebrew'] = 0xFB4C;
6892 t['bhabengali'] = 0x09AD;
6893 t['bhadeva'] = 0x092D;
6894 t['bhagujarati'] = 0x0AAD;
6895 t['bhagurmukhi'] = 0x0A2D;
6896 t['bhook'] = 0x0253;
6897 t['bihiragana'] = 0x3073;
6898 t['bikatakana'] = 0x30D3;
6899 t['bilabialclick'] = 0x0298;
6900 t['bindigurmukhi'] = 0x0A02;
6901 t['birusquare'] = 0x3331;
6902 t['blackcircle'] = 0x25CF;
6903 t['blackdiamond'] = 0x25C6;
6904 t['blackdownpointingtriangle'] = 0x25BC;
6905 t['blackleftpointingpointer'] = 0x25C4;
6906 t['blackleftpointingtriangle'] = 0x25C0;
6907 t['blacklenticularbracketleft'] = 0x3010;
6908 t['blacklenticularbracketleftvertical'] = 0xFE3B;
6909 t['blacklenticularbracketright'] = 0x3011;
6910 t['blacklenticularbracketrightvertical'] = 0xFE3C;
6911 t['blacklowerlefttriangle'] = 0x25E3;
6912 t['blacklowerrighttriangle'] = 0x25E2;
6913 t['blackrectangle'] = 0x25AC;
6914 t['blackrightpointingpointer'] = 0x25BA;
6915 t['blackrightpointingtriangle'] = 0x25B6;
6916 t['blacksmallsquare'] = 0x25AA;
6917 t['blacksmilingface'] = 0x263B;
6918 t['blacksquare'] = 0x25A0;
6919 t['blackstar'] = 0x2605;
6920 t['blackupperlefttriangle'] = 0x25E4;
6921 t['blackupperrighttriangle'] = 0x25E5;
6922 t['blackuppointingsmalltriangle'] = 0x25B4;
6923 t['blackuppointingtriangle'] = 0x25B2;
6924 t['blank'] = 0x2423;
6925 t['blinebelow'] = 0x1E07;
6926 t['block'] = 0x2588;
6927 t['bmonospace'] = 0xFF42;
6928 t['bobaimaithai'] = 0x0E1A;
6929 t['bohiragana'] = 0x307C;
6930 t['bokatakana'] = 0x30DC;
6931 t['bparen'] = 0x249D;
6932 t['bqsquare'] = 0x33C3;
6933 t['braceex'] = 0xF8F4;
6934 t['braceleft'] = 0x007B;
6935 t['braceleftbt'] = 0xF8F3;
6936 t['braceleftmid'] = 0xF8F2;
6937 t['braceleftmonospace'] = 0xFF5B;
6938 t['braceleftsmall'] = 0xFE5B;
6939 t['bracelefttp'] = 0xF8F1;
6940 t['braceleftvertical'] = 0xFE37;
6941 t['braceright'] = 0x007D;
6942 t['bracerightbt'] = 0xF8FE;
6943 t['bracerightmid'] = 0xF8FD;
6944 t['bracerightmonospace'] = 0xFF5D;
6945 t['bracerightsmall'] = 0xFE5C;
6946 t['bracerighttp'] = 0xF8FC;
6947 t['bracerightvertical'] = 0xFE38;
6948 t['bracketleft'] = 0x005B;
6949 t['bracketleftbt'] = 0xF8F0;
6950 t['bracketleftex'] = 0xF8EF;
6951 t['bracketleftmonospace'] = 0xFF3B;
6952 t['bracketlefttp'] = 0xF8EE;
6953 t['bracketright'] = 0x005D;
6954 t['bracketrightbt'] = 0xF8FB;
6955 t['bracketrightex'] = 0xF8FA;
6956 t['bracketrightmonospace'] = 0xFF3D;
6957 t['bracketrighttp'] = 0xF8F9;
6958 t['breve'] = 0x02D8;
6959 t['brevebelowcmb'] = 0x032E;
6960 t['brevecmb'] = 0x0306;
6961 t['breveinvertedbelowcmb'] = 0x032F;
6962 t['breveinvertedcmb'] = 0x0311;
6963 t['breveinverteddoublecmb'] = 0x0361;
6964 t['bridgebelowcmb'] = 0x032A;
6965 t['bridgeinvertedbelowcmb'] = 0x033A;
6966 t['brokenbar'] = 0x00A6;
6967 t['bstroke'] = 0x0180;
6968 t['bsuperior'] = 0xF6EA;
6969 t['btopbar'] = 0x0183;
6970 t['buhiragana'] = 0x3076;
6971 t['bukatakana'] = 0x30D6;
6972 t['bullet'] = 0x2022;
6973 t['bulletinverse'] = 0x25D8;
6974 t['bulletoperator'] = 0x2219;
6975 t['bullseye'] = 0x25CE;
6976 t['c'] = 0x0063;
6977 t['caarmenian'] = 0x056E;
6978 t['cabengali'] = 0x099A;
6979 t['cacute'] = 0x0107;
6980 t['cadeva'] = 0x091A;
6981 t['cagujarati'] = 0x0A9A;
6982 t['cagurmukhi'] = 0x0A1A;
6983 t['calsquare'] = 0x3388;
6984 t['candrabindubengali'] = 0x0981;
6985 t['candrabinducmb'] = 0x0310;
6986 t['candrabindudeva'] = 0x0901;
6987 t['candrabindugujarati'] = 0x0A81;
6988 t['capslock'] = 0x21EA;
6989 t['careof'] = 0x2105;
6990 t['caron'] = 0x02C7;
6991 t['caronbelowcmb'] = 0x032C;
6992 t['caroncmb'] = 0x030C;
6993 t['carriagereturn'] = 0x21B5;
6994 t['cbopomofo'] = 0x3118;
6995 t['ccaron'] = 0x010D;
6996 t['ccedilla'] = 0x00E7;
6997 t['ccedillaacute'] = 0x1E09;
6998 t['ccircle'] = 0x24D2;
6999 t['ccircumflex'] = 0x0109;
7000 t['ccurl'] = 0x0255;
7001 t['cdot'] = 0x010B;
7002 t['cdotaccent'] = 0x010B;
7003 t['cdsquare'] = 0x33C5;
7004 t['cedilla'] = 0x00B8;
7005 t['cedillacmb'] = 0x0327;
7006 t['cent'] = 0x00A2;
7007 t['centigrade'] = 0x2103;
7008 t['centinferior'] = 0xF6DF;
7009 t['centmonospace'] = 0xFFE0;
7010 t['centoldstyle'] = 0xF7A2;
7011 t['centsuperior'] = 0xF6E0;
7012 t['chaarmenian'] = 0x0579;
7013 t['chabengali'] = 0x099B;
7014 t['chadeva'] = 0x091B;
7015 t['chagujarati'] = 0x0A9B;
7016 t['chagurmukhi'] = 0x0A1B;
7017 t['chbopomofo'] = 0x3114;
7018 t['cheabkhasiancyrillic'] = 0x04BD;
7019 t['checkmark'] = 0x2713;
7020 t['checyrillic'] = 0x0447;
7021 t['chedescenderabkhasiancyrillic'] = 0x04BF;
7022 t['chedescendercyrillic'] = 0x04B7;
7023 t['chedieresiscyrillic'] = 0x04F5;
7024 t['cheharmenian'] = 0x0573;
7025 t['chekhakassiancyrillic'] = 0x04CC;
7026 t['cheverticalstrokecyrillic'] = 0x04B9;
7027 t['chi'] = 0x03C7;
7028 t['chieuchacirclekorean'] = 0x3277;
7029 t['chieuchaparenkorean'] = 0x3217;
7030 t['chieuchcirclekorean'] = 0x3269;
7031 t['chieuchkorean'] = 0x314A;
7032 t['chieuchparenkorean'] = 0x3209;
7033 t['chochangthai'] = 0x0E0A;
7034 t['chochanthai'] = 0x0E08;
7035 t['chochingthai'] = 0x0E09;
7036 t['chochoethai'] = 0x0E0C;
7037 t['chook'] = 0x0188;
7038 t['cieucacirclekorean'] = 0x3276;
7039 t['cieucaparenkorean'] = 0x3216;
7040 t['cieuccirclekorean'] = 0x3268;
7041 t['cieuckorean'] = 0x3148;
7042 t['cieucparenkorean'] = 0x3208;
7043 t['cieucuparenkorean'] = 0x321C;
7044 t['circle'] = 0x25CB;
7045 t['circlecopyrt'] = 0x00A9; // Glyph is missing from Adobe's original list.
7046 t['circlemultiply'] = 0x2297;
7047 t['circleot'] = 0x2299;
7048 t['circleplus'] = 0x2295;
7049 t['circlepostalmark'] = 0x3036;
7050 t['circlewithlefthalfblack'] = 0x25D0;
7051 t['circlewithrighthalfblack'] = 0x25D1;
7052 t['circumflex'] = 0x02C6;
7053 t['circumflexbelowcmb'] = 0x032D;
7054 t['circumflexcmb'] = 0x0302;
7055 t['clear'] = 0x2327;
7056 t['clickalveolar'] = 0x01C2;
7057 t['clickdental'] = 0x01C0;
7058 t['clicklateral'] = 0x01C1;
7059 t['clickretroflex'] = 0x01C3;
7060 t['club'] = 0x2663;
7061 t['clubsuitblack'] = 0x2663;
7062 t['clubsuitwhite'] = 0x2667;
7063 t['cmcubedsquare'] = 0x33A4;
7064 t['cmonospace'] = 0xFF43;
7065 t['cmsquaredsquare'] = 0x33A0;
7066 t['coarmenian'] = 0x0581;
7067 t['colon'] = 0x003A;
7068 t['colonmonetary'] = 0x20A1;
7069 t['colonmonospace'] = 0xFF1A;
7070 t['colonsign'] = 0x20A1;
7071 t['colonsmall'] = 0xFE55;
7072 t['colontriangularhalfmod'] = 0x02D1;
7073 t['colontriangularmod'] = 0x02D0;
7074 t['comma'] = 0x002C;
7075 t['commaabovecmb'] = 0x0313;
7076 t['commaaboverightcmb'] = 0x0315;
7077 t['commaaccent'] = 0xF6C3;
7078 t['commaarabic'] = 0x060C;
7079 t['commaarmenian'] = 0x055D;
7080 t['commainferior'] = 0xF6E1;
7081 t['commamonospace'] = 0xFF0C;
7082 t['commareversedabovecmb'] = 0x0314;
7083 t['commareversedmod'] = 0x02BD;
7084 t['commasmall'] = 0xFE50;
7085 t['commasuperior'] = 0xF6E2;
7086 t['commaturnedabovecmb'] = 0x0312;
7087 t['commaturnedmod'] = 0x02BB;
7088 t['compass'] = 0x263C;
7089 t['congruent'] = 0x2245;
7090 t['contourintegral'] = 0x222E;
7091 t['control'] = 0x2303;
7092 t['controlACK'] = 0x0006;
7093 t['controlBEL'] = 0x0007;
7094 t['controlBS'] = 0x0008;
7095 t['controlCAN'] = 0x0018;
7096 t['controlCR'] = 0x000D;
7097 t['controlDC1'] = 0x0011;
7098 t['controlDC2'] = 0x0012;
7099 t['controlDC3'] = 0x0013;
7100 t['controlDC4'] = 0x0014;
7101 t['controlDEL'] = 0x007F;
7102 t['controlDLE'] = 0x0010;
7103 t['controlEM'] = 0x0019;
7104 t['controlENQ'] = 0x0005;
7105 t['controlEOT'] = 0x0004;
7106 t['controlESC'] = 0x001B;
7107 t['controlETB'] = 0x0017;
7108 t['controlETX'] = 0x0003;
7109 t['controlFF'] = 0x000C;
7110 t['controlFS'] = 0x001C;
7111 t['controlGS'] = 0x001D;
7112 t['controlHT'] = 0x0009;
7113 t['controlLF'] = 0x000A;
7114 t['controlNAK'] = 0x0015;
7115 t['controlRS'] = 0x001E;
7116 t['controlSI'] = 0x000F;
7117 t['controlSO'] = 0x000E;
7118 t['controlSOT'] = 0x0002;
7119 t['controlSTX'] = 0x0001;
7120 t['controlSUB'] = 0x001A;
7121 t['controlSYN'] = 0x0016;
7122 t['controlUS'] = 0x001F;
7123 t['controlVT'] = 0x000B;
7124 t['copyright'] = 0x00A9;
7125 t['copyrightsans'] = 0xF8E9;
7126 t['copyrightserif'] = 0xF6D9;
7127 t['cornerbracketleft'] = 0x300C;
7128 t['cornerbracketlefthalfwidth'] = 0xFF62;
7129 t['cornerbracketleftvertical'] = 0xFE41;
7130 t['cornerbracketright'] = 0x300D;
7131 t['cornerbracketrighthalfwidth'] = 0xFF63;
7132 t['cornerbracketrightvertical'] = 0xFE42;
7133 t['corporationsquare'] = 0x337F;
7134 t['cosquare'] = 0x33C7;
7135 t['coverkgsquare'] = 0x33C6;
7136 t['cparen'] = 0x249E;
7137 t['cruzeiro'] = 0x20A2;
7138 t['cstretched'] = 0x0297;
7139 t['curlyand'] = 0x22CF;
7140 t['curlyor'] = 0x22CE;
7141 t['currency'] = 0x00A4;
7142 t['cyrBreve'] = 0xF6D1;
7143 t['cyrFlex'] = 0xF6D2;
7144 t['cyrbreve'] = 0xF6D4;
7145 t['cyrflex'] = 0xF6D5;
7146 t['d'] = 0x0064;
7147 t['daarmenian'] = 0x0564;
7148 t['dabengali'] = 0x09A6;
7149 t['dadarabic'] = 0x0636;
7150 t['dadeva'] = 0x0926;
7151 t['dadfinalarabic'] = 0xFEBE;
7152 t['dadinitialarabic'] = 0xFEBF;
7153 t['dadmedialarabic'] = 0xFEC0;
7154 t['dagesh'] = 0x05BC;
7155 t['dageshhebrew'] = 0x05BC;
7156 t['dagger'] = 0x2020;
7157 t['daggerdbl'] = 0x2021;
7158 t['dagujarati'] = 0x0AA6;
7159 t['dagurmukhi'] = 0x0A26;
7160 t['dahiragana'] = 0x3060;
7161 t['dakatakana'] = 0x30C0;
7162 t['dalarabic'] = 0x062F;
7163 t['dalet'] = 0x05D3;
7164 t['daletdagesh'] = 0xFB33;
7165 t['daletdageshhebrew'] = 0xFB33;
7166 t['dalethebrew'] = 0x05D3;
7167 t['dalfinalarabic'] = 0xFEAA;
7168 t['dammaarabic'] = 0x064F;
7169 t['dammalowarabic'] = 0x064F;
7170 t['dammatanaltonearabic'] = 0x064C;
7171 t['dammatanarabic'] = 0x064C;
7172 t['danda'] = 0x0964;
7173 t['dargahebrew'] = 0x05A7;
7174 t['dargalefthebrew'] = 0x05A7;
7175 t['dasiapneumatacyrilliccmb'] = 0x0485;
7176 t['dblGrave'] = 0xF6D3;
7177 t['dblanglebracketleft'] = 0x300A;
7178 t['dblanglebracketleftvertical'] = 0xFE3D;
7179 t['dblanglebracketright'] = 0x300B;
7180 t['dblanglebracketrightvertical'] = 0xFE3E;
7181 t['dblarchinvertedbelowcmb'] = 0x032B;
7182 t['dblarrowleft'] = 0x21D4;
7183 t['dblarrowright'] = 0x21D2;
7184 t['dbldanda'] = 0x0965;
7185 t['dblgrave'] = 0xF6D6;
7186 t['dblgravecmb'] = 0x030F;
7187 t['dblintegral'] = 0x222C;
7188 t['dbllowline'] = 0x2017;
7189 t['dbllowlinecmb'] = 0x0333;
7190 t['dbloverlinecmb'] = 0x033F;
7191 t['dblprimemod'] = 0x02BA;
7192 t['dblverticalbar'] = 0x2016;
7193 t['dblverticallineabovecmb'] = 0x030E;
7194 t['dbopomofo'] = 0x3109;
7195 t['dbsquare'] = 0x33C8;
7196 t['dcaron'] = 0x010F;
7197 t['dcedilla'] = 0x1E11;
7198 t['dcircle'] = 0x24D3;
7199 t['dcircumflexbelow'] = 0x1E13;
7200 t['dcroat'] = 0x0111;
7201 t['ddabengali'] = 0x09A1;
7202 t['ddadeva'] = 0x0921;
7203 t['ddagujarati'] = 0x0AA1;
7204 t['ddagurmukhi'] = 0x0A21;
7205 t['ddalarabic'] = 0x0688;
7206 t['ddalfinalarabic'] = 0xFB89;
7207 t['dddhadeva'] = 0x095C;
7208 t['ddhabengali'] = 0x09A2;
7209 t['ddhadeva'] = 0x0922;
7210 t['ddhagujarati'] = 0x0AA2;
7211 t['ddhagurmukhi'] = 0x0A22;
7212 t['ddotaccent'] = 0x1E0B;
7213 t['ddotbelow'] = 0x1E0D;
7214 t['decimalseparatorarabic'] = 0x066B;
7215 t['decimalseparatorpersian'] = 0x066B;
7216 t['decyrillic'] = 0x0434;
7217 t['degree'] = 0x00B0;
7218 t['dehihebrew'] = 0x05AD;
7219 t['dehiragana'] = 0x3067;
7220 t['deicoptic'] = 0x03EF;
7221 t['dekatakana'] = 0x30C7;
7222 t['deleteleft'] = 0x232B;
7223 t['deleteright'] = 0x2326;
7224 t['delta'] = 0x03B4;
7225 t['deltaturned'] = 0x018D;
7226 t['denominatorminusonenumeratorbengali'] = 0x09F8;
7227 t['dezh'] = 0x02A4;
7228 t['dhabengali'] = 0x09A7;
7229 t['dhadeva'] = 0x0927;
7230 t['dhagujarati'] = 0x0AA7;
7231 t['dhagurmukhi'] = 0x0A27;
7232 t['dhook'] = 0x0257;
7233 t['dialytikatonos'] = 0x0385;
7234 t['dialytikatonoscmb'] = 0x0344;
7235 t['diamond'] = 0x2666;
7236 t['diamondsuitwhite'] = 0x2662;
7237 t['dieresis'] = 0x00A8;
7238 t['dieresisacute'] = 0xF6D7;
7239 t['dieresisbelowcmb'] = 0x0324;
7240 t['dieresiscmb'] = 0x0308;
7241 t['dieresisgrave'] = 0xF6D8;
7242 t['dieresistonos'] = 0x0385;
7243 t['dihiragana'] = 0x3062;
7244 t['dikatakana'] = 0x30C2;
7245 t['dittomark'] = 0x3003;
7246 t['divide'] = 0x00F7;
7247 t['divides'] = 0x2223;
7248 t['divisionslash'] = 0x2215;
7249 t['djecyrillic'] = 0x0452;
7250 t['dkshade'] = 0x2593;
7251 t['dlinebelow'] = 0x1E0F;
7252 t['dlsquare'] = 0x3397;
7253 t['dmacron'] = 0x0111;
7254 t['dmonospace'] = 0xFF44;
7255 t['dnblock'] = 0x2584;
7256 t['dochadathai'] = 0x0E0E;
7257 t['dodekthai'] = 0x0E14;
7258 t['dohiragana'] = 0x3069;
7259 t['dokatakana'] = 0x30C9;
7260 t['dollar'] = 0x0024;
7261 t['dollarinferior'] = 0xF6E3;
7262 t['dollarmonospace'] = 0xFF04;
7263 t['dollaroldstyle'] = 0xF724;
7264 t['dollarsmall'] = 0xFE69;
7265 t['dollarsuperior'] = 0xF6E4;
7266 t['dong'] = 0x20AB;
7267 t['dorusquare'] = 0x3326;
7268 t['dotaccent'] = 0x02D9;
7269 t['dotaccentcmb'] = 0x0307;
7270 t['dotbelowcmb'] = 0x0323;
7271 t['dotbelowcomb'] = 0x0323;
7272 t['dotkatakana'] = 0x30FB;
7273 t['dotlessi'] = 0x0131;
7274 t['dotlessj'] = 0xF6BE;
7275 t['dotlessjstrokehook'] = 0x0284;
7276 t['dotmath'] = 0x22C5;
7277 t['dottedcircle'] = 0x25CC;
7278 t['doubleyodpatah'] = 0xFB1F;
7279 t['doubleyodpatahhebrew'] = 0xFB1F;
7280 t['downtackbelowcmb'] = 0x031E;
7281 t['downtackmod'] = 0x02D5;
7282 t['dparen'] = 0x249F;
7283 t['dsuperior'] = 0xF6EB;
7284 t['dtail'] = 0x0256;
7285 t['dtopbar'] = 0x018C;
7286 t['duhiragana'] = 0x3065;
7287 t['dukatakana'] = 0x30C5;
7288 t['dz'] = 0x01F3;
7289 t['dzaltone'] = 0x02A3;
7290 t['dzcaron'] = 0x01C6;
7291 t['dzcurl'] = 0x02A5;
7292 t['dzeabkhasiancyrillic'] = 0x04E1;
7293 t['dzecyrillic'] = 0x0455;
7294 t['dzhecyrillic'] = 0x045F;
7295 t['e'] = 0x0065;
7296 t['eacute'] = 0x00E9;
7297 t['earth'] = 0x2641;
7298 t['ebengali'] = 0x098F;
7299 t['ebopomofo'] = 0x311C;
7300 t['ebreve'] = 0x0115;
7301 t['ecandradeva'] = 0x090D;
7302 t['ecandragujarati'] = 0x0A8D;
7303 t['ecandravowelsigndeva'] = 0x0945;
7304 t['ecandravowelsigngujarati'] = 0x0AC5;
7305 t['ecaron'] = 0x011B;
7306 t['ecedillabreve'] = 0x1E1D;
7307 t['echarmenian'] = 0x0565;
7308 t['echyiwnarmenian'] = 0x0587;
7309 t['ecircle'] = 0x24D4;
7310 t['ecircumflex'] = 0x00EA;
7311 t['ecircumflexacute'] = 0x1EBF;
7312 t['ecircumflexbelow'] = 0x1E19;
7313 t['ecircumflexdotbelow'] = 0x1EC7;
7314 t['ecircumflexgrave'] = 0x1EC1;
7315 t['ecircumflexhookabove'] = 0x1EC3;
7316 t['ecircumflextilde'] = 0x1EC5;
7317 t['ecyrillic'] = 0x0454;
7318 t['edblgrave'] = 0x0205;
7319 t['edeva'] = 0x090F;
7320 t['edieresis'] = 0x00EB;
7321 t['edot'] = 0x0117;
7322 t['edotaccent'] = 0x0117;
7323 t['edotbelow'] = 0x1EB9;
7324 t['eegurmukhi'] = 0x0A0F;
7325 t['eematragurmukhi'] = 0x0A47;
7326 t['efcyrillic'] = 0x0444;
7327 t['egrave'] = 0x00E8;
7328 t['egujarati'] = 0x0A8F;
7329 t['eharmenian'] = 0x0567;
7330 t['ehbopomofo'] = 0x311D;
7331 t['ehiragana'] = 0x3048;
7332 t['ehookabove'] = 0x1EBB;
7333 t['eibopomofo'] = 0x311F;
7334 t['eight'] = 0x0038;
7335 t['eightarabic'] = 0x0668;
7336 t['eightbengali'] = 0x09EE;
7337 t['eightcircle'] = 0x2467;
7338 t['eightcircleinversesansserif'] = 0x2791;
7339 t['eightdeva'] = 0x096E;
7340 t['eighteencircle'] = 0x2471;
7341 t['eighteenparen'] = 0x2485;
7342 t['eighteenperiod'] = 0x2499;
7343 t['eightgujarati'] = 0x0AEE;
7344 t['eightgurmukhi'] = 0x0A6E;
7345 t['eighthackarabic'] = 0x0668;
7346 t['eighthangzhou'] = 0x3028;
7347 t['eighthnotebeamed'] = 0x266B;
7348 t['eightideographicparen'] = 0x3227;
7349 t['eightinferior'] = 0x2088;
7350 t['eightmonospace'] = 0xFF18;
7351 t['eightoldstyle'] = 0xF738;
7352 t['eightparen'] = 0x247B;
7353 t['eightperiod'] = 0x248F;
7354 t['eightpersian'] = 0x06F8;
7355 t['eightroman'] = 0x2177;
7356 t['eightsuperior'] = 0x2078;
7357 t['eightthai'] = 0x0E58;
7358 t['einvertedbreve'] = 0x0207;
7359 t['eiotifiedcyrillic'] = 0x0465;
7360 t['ekatakana'] = 0x30A8;
7361 t['ekatakanahalfwidth'] = 0xFF74;
7362 t['ekonkargurmukhi'] = 0x0A74;
7363 t['ekorean'] = 0x3154;
7364 t['elcyrillic'] = 0x043B;
7365 t['element'] = 0x2208;
7366 t['elevencircle'] = 0x246A;
7367 t['elevenparen'] = 0x247E;
7368 t['elevenperiod'] = 0x2492;
7369 t['elevenroman'] = 0x217A;
7370 t['ellipsis'] = 0x2026;
7371 t['ellipsisvertical'] = 0x22EE;
7372 t['emacron'] = 0x0113;
7373 t['emacronacute'] = 0x1E17;
7374 t['emacrongrave'] = 0x1E15;
7375 t['emcyrillic'] = 0x043C;
7376 t['emdash'] = 0x2014;
7377 t['emdashvertical'] = 0xFE31;
7378 t['emonospace'] = 0xFF45;
7379 t['emphasismarkarmenian'] = 0x055B;
7380 t['emptyset'] = 0x2205;
7381 t['enbopomofo'] = 0x3123;
7382 t['encyrillic'] = 0x043D;
7383 t['endash'] = 0x2013;
7384 t['endashvertical'] = 0xFE32;
7385 t['endescendercyrillic'] = 0x04A3;
7386 t['eng'] = 0x014B;
7387 t['engbopomofo'] = 0x3125;
7388 t['enghecyrillic'] = 0x04A5;
7389 t['enhookcyrillic'] = 0x04C8;
7390 t['enspace'] = 0x2002;
7391 t['eogonek'] = 0x0119;
7392 t['eokorean'] = 0x3153;
7393 t['eopen'] = 0x025B;
7394 t['eopenclosed'] = 0x029A;
7395 t['eopenreversed'] = 0x025C;
7396 t['eopenreversedclosed'] = 0x025E;
7397 t['eopenreversedhook'] = 0x025D;
7398 t['eparen'] = 0x24A0;
7399 t['epsilon'] = 0x03B5;
7400 t['epsilontonos'] = 0x03AD;
7401 t['equal'] = 0x003D;
7402 t['equalmonospace'] = 0xFF1D;
7403 t['equalsmall'] = 0xFE66;
7404 t['equalsuperior'] = 0x207C;
7405 t['equivalence'] = 0x2261;
7406 t['erbopomofo'] = 0x3126;
7407 t['ercyrillic'] = 0x0440;
7408 t['ereversed'] = 0x0258;
7409 t['ereversedcyrillic'] = 0x044D;
7410 t['escyrillic'] = 0x0441;
7411 t['esdescendercyrillic'] = 0x04AB;
7412 t['esh'] = 0x0283;
7413 t['eshcurl'] = 0x0286;
7414 t['eshortdeva'] = 0x090E;
7415 t['eshortvowelsigndeva'] = 0x0946;
7416 t['eshreversedloop'] = 0x01AA;
7417 t['eshsquatreversed'] = 0x0285;
7418 t['esmallhiragana'] = 0x3047;
7419 t['esmallkatakana'] = 0x30A7;
7420 t['esmallkatakanahalfwidth'] = 0xFF6A;
7421 t['estimated'] = 0x212E;
7422 t['esuperior'] = 0xF6EC;
7423 t['eta'] = 0x03B7;
7424 t['etarmenian'] = 0x0568;
7425 t['etatonos'] = 0x03AE;
7426 t['eth'] = 0x00F0;
7427 t['etilde'] = 0x1EBD;
7428 t['etildebelow'] = 0x1E1B;
7429 t['etnahtafoukhhebrew'] = 0x0591;
7430 t['etnahtafoukhlefthebrew'] = 0x0591;
7431 t['etnahtahebrew'] = 0x0591;
7432 t['etnahtalefthebrew'] = 0x0591;
7433 t['eturned'] = 0x01DD;
7434 t['eukorean'] = 0x3161;
7435 t['euro'] = 0x20AC;
7436 t['evowelsignbengali'] = 0x09C7;
7437 t['evowelsigndeva'] = 0x0947;
7438 t['evowelsigngujarati'] = 0x0AC7;
7439 t['exclam'] = 0x0021;
7440 t['exclamarmenian'] = 0x055C;
7441 t['exclamdbl'] = 0x203C;
7442 t['exclamdown'] = 0x00A1;
7443 t['exclamdownsmall'] = 0xF7A1;
7444 t['exclammonospace'] = 0xFF01;
7445 t['exclamsmall'] = 0xF721;
7446 t['existential'] = 0x2203;
7447 t['ezh'] = 0x0292;
7448 t['ezhcaron'] = 0x01EF;
7449 t['ezhcurl'] = 0x0293;
7450 t['ezhreversed'] = 0x01B9;
7451 t['ezhtail'] = 0x01BA;
7452 t['f'] = 0x0066;
7453 t['fadeva'] = 0x095E;
7454 t['fagurmukhi'] = 0x0A5E;
7455 t['fahrenheit'] = 0x2109;
7456 t['fathaarabic'] = 0x064E;
7457 t['fathalowarabic'] = 0x064E;
7458 t['fathatanarabic'] = 0x064B;
7459 t['fbopomofo'] = 0x3108;
7460 t['fcircle'] = 0x24D5;
7461 t['fdotaccent'] = 0x1E1F;
7462 t['feharabic'] = 0x0641;
7463 t['feharmenian'] = 0x0586;
7464 t['fehfinalarabic'] = 0xFED2;
7465 t['fehinitialarabic'] = 0xFED3;
7466 t['fehmedialarabic'] = 0xFED4;
7467 t['feicoptic'] = 0x03E5;
7468 t['female'] = 0x2640;
7469 t['ff'] = 0xFB00;
7470 t['ffi'] = 0xFB03;
7471 t['ffl'] = 0xFB04;
7472 t['fi'] = 0xFB01;
7473 t['fifteencircle'] = 0x246E;
7474 t['fifteenparen'] = 0x2482;
7475 t['fifteenperiod'] = 0x2496;
7476 t['figuredash'] = 0x2012;
7477 t['filledbox'] = 0x25A0;
7478 t['filledrect'] = 0x25AC;
7479 t['finalkaf'] = 0x05DA;
7480 t['finalkafdagesh'] = 0xFB3A;
7481 t['finalkafdageshhebrew'] = 0xFB3A;
7482 t['finalkafhebrew'] = 0x05DA;
7483 t['finalmem'] = 0x05DD;
7484 t['finalmemhebrew'] = 0x05DD;
7485 t['finalnun'] = 0x05DF;
7486 t['finalnunhebrew'] = 0x05DF;
7487 t['finalpe'] = 0x05E3;
7488 t['finalpehebrew'] = 0x05E3;
7489 t['finaltsadi'] = 0x05E5;
7490 t['finaltsadihebrew'] = 0x05E5;
7491 t['firsttonechinese'] = 0x02C9;
7492 t['fisheye'] = 0x25C9;
7493 t['fitacyrillic'] = 0x0473;
7494 t['five'] = 0x0035;
7495 t['fivearabic'] = 0x0665;
7496 t['fivebengali'] = 0x09EB;
7497 t['fivecircle'] = 0x2464;
7498 t['fivecircleinversesansserif'] = 0x278E;
7499 t['fivedeva'] = 0x096B;
7500 t['fiveeighths'] = 0x215D;
7501 t['fivegujarati'] = 0x0AEB;
7502 t['fivegurmukhi'] = 0x0A6B;
7503 t['fivehackarabic'] = 0x0665;
7504 t['fivehangzhou'] = 0x3025;
7505 t['fiveideographicparen'] = 0x3224;
7506 t['fiveinferior'] = 0x2085;
7507 t['fivemonospace'] = 0xFF15;
7508 t['fiveoldstyle'] = 0xF735;
7509 t['fiveparen'] = 0x2478;
7510 t['fiveperiod'] = 0x248C;
7511 t['fivepersian'] = 0x06F5;
7512 t['fiveroman'] = 0x2174;
7513 t['fivesuperior'] = 0x2075;
7514 t['fivethai'] = 0x0E55;
7515 t['fl'] = 0xFB02;
7516 t['florin'] = 0x0192;
7517 t['fmonospace'] = 0xFF46;
7518 t['fmsquare'] = 0x3399;
7519 t['fofanthai'] = 0x0E1F;
7520 t['fofathai'] = 0x0E1D;
7521 t['fongmanthai'] = 0x0E4F;
7522 t['forall'] = 0x2200;
7523 t['four'] = 0x0034;
7524 t['fourarabic'] = 0x0664;
7525 t['fourbengali'] = 0x09EA;
7526 t['fourcircle'] = 0x2463;
7527 t['fourcircleinversesansserif'] = 0x278D;
7528 t['fourdeva'] = 0x096A;
7529 t['fourgujarati'] = 0x0AEA;
7530 t['fourgurmukhi'] = 0x0A6A;
7531 t['fourhackarabic'] = 0x0664;
7532 t['fourhangzhou'] = 0x3024;
7533 t['fourideographicparen'] = 0x3223;
7534 t['fourinferior'] = 0x2084;
7535 t['fourmonospace'] = 0xFF14;
7536 t['fournumeratorbengali'] = 0x09F7;
7537 t['fouroldstyle'] = 0xF734;
7538 t['fourparen'] = 0x2477;
7539 t['fourperiod'] = 0x248B;
7540 t['fourpersian'] = 0x06F4;
7541 t['fourroman'] = 0x2173;
7542 t['foursuperior'] = 0x2074;
7543 t['fourteencircle'] = 0x246D;
7544 t['fourteenparen'] = 0x2481;
7545 t['fourteenperiod'] = 0x2495;
7546 t['fourthai'] = 0x0E54;
7547 t['fourthtonechinese'] = 0x02CB;
7548 t['fparen'] = 0x24A1;
7549 t['fraction'] = 0x2044;
7550 t['franc'] = 0x20A3;
7551 t['g'] = 0x0067;
7552 t['gabengali'] = 0x0997;
7553 t['gacute'] = 0x01F5;
7554 t['gadeva'] = 0x0917;
7555 t['gafarabic'] = 0x06AF;
7556 t['gaffinalarabic'] = 0xFB93;
7557 t['gafinitialarabic'] = 0xFB94;
7558 t['gafmedialarabic'] = 0xFB95;
7559 t['gagujarati'] = 0x0A97;
7560 t['gagurmukhi'] = 0x0A17;
7561 t['gahiragana'] = 0x304C;
7562 t['gakatakana'] = 0x30AC;
7563 t['gamma'] = 0x03B3;
7564 t['gammalatinsmall'] = 0x0263;
7565 t['gammasuperior'] = 0x02E0;
7566 t['gangiacoptic'] = 0x03EB;
7567 t['gbopomofo'] = 0x310D;
7568 t['gbreve'] = 0x011F;
7569 t['gcaron'] = 0x01E7;
7570 t['gcedilla'] = 0x0123;
7571 t['gcircle'] = 0x24D6;
7572 t['gcircumflex'] = 0x011D;
7573 t['gcommaaccent'] = 0x0123;
7574 t['gdot'] = 0x0121;
7575 t['gdotaccent'] = 0x0121;
7576 t['gecyrillic'] = 0x0433;
7577 t['gehiragana'] = 0x3052;
7578 t['gekatakana'] = 0x30B2;
7579 t['geometricallyequal'] = 0x2251;
7580 t['gereshaccenthebrew'] = 0x059C;
7581 t['gereshhebrew'] = 0x05F3;
7582 t['gereshmuqdamhebrew'] = 0x059D;
7583 t['germandbls'] = 0x00DF;
7584 t['gershayimaccenthebrew'] = 0x059E;
7585 t['gershayimhebrew'] = 0x05F4;
7586 t['getamark'] = 0x3013;
7587 t['ghabengali'] = 0x0998;
7588 t['ghadarmenian'] = 0x0572;
7589 t['ghadeva'] = 0x0918;
7590 t['ghagujarati'] = 0x0A98;
7591 t['ghagurmukhi'] = 0x0A18;
7592 t['ghainarabic'] = 0x063A;
7593 t['ghainfinalarabic'] = 0xFECE;
7594 t['ghaininitialarabic'] = 0xFECF;
7595 t['ghainmedialarabic'] = 0xFED0;
7596 t['ghemiddlehookcyrillic'] = 0x0495;
7597 t['ghestrokecyrillic'] = 0x0493;
7598 t['gheupturncyrillic'] = 0x0491;
7599 t['ghhadeva'] = 0x095A;
7600 t['ghhagurmukhi'] = 0x0A5A;
7601 t['ghook'] = 0x0260;
7602 t['ghzsquare'] = 0x3393;
7603 t['gihiragana'] = 0x304E;
7604 t['gikatakana'] = 0x30AE;
7605 t['gimarmenian'] = 0x0563;
7606 t['gimel'] = 0x05D2;
7607 t['gimeldagesh'] = 0xFB32;
7608 t['gimeldageshhebrew'] = 0xFB32;
7609 t['gimelhebrew'] = 0x05D2;
7610 t['gjecyrillic'] = 0x0453;
7611 t['glottalinvertedstroke'] = 0x01BE;
7612 t['glottalstop'] = 0x0294;
7613 t['glottalstopinverted'] = 0x0296;
7614 t['glottalstopmod'] = 0x02C0;
7615 t['glottalstopreversed'] = 0x0295;
7616 t['glottalstopreversedmod'] = 0x02C1;
7617 t['glottalstopreversedsuperior'] = 0x02E4;
7618 t['glottalstopstroke'] = 0x02A1;
7619 t['glottalstopstrokereversed'] = 0x02A2;
7620 t['gmacron'] = 0x1E21;
7621 t['gmonospace'] = 0xFF47;
7622 t['gohiragana'] = 0x3054;
7623 t['gokatakana'] = 0x30B4;
7624 t['gparen'] = 0x24A2;
7625 t['gpasquare'] = 0x33AC;
7626 t['gradient'] = 0x2207;
7627 t['grave'] = 0x0060;
7628 t['gravebelowcmb'] = 0x0316;
7629 t['gravecmb'] = 0x0300;
7630 t['gravecomb'] = 0x0300;
7631 t['gravedeva'] = 0x0953;
7632 t['gravelowmod'] = 0x02CE;
7633 t['gravemonospace'] = 0xFF40;
7634 t['gravetonecmb'] = 0x0340;
7635 t['greater'] = 0x003E;
7636 t['greaterequal'] = 0x2265;
7637 t['greaterequalorless'] = 0x22DB;
7638 t['greatermonospace'] = 0xFF1E;
7639 t['greaterorequivalent'] = 0x2273;
7640 t['greaterorless'] = 0x2277;
7641 t['greateroverequal'] = 0x2267;
7642 t['greatersmall'] = 0xFE65;
7643 t['gscript'] = 0x0261;
7644 t['gstroke'] = 0x01E5;
7645 t['guhiragana'] = 0x3050;
7646 t['guillemotleft'] = 0x00AB;
7647 t['guillemotright'] = 0x00BB;
7648 t['guilsinglleft'] = 0x2039;
7649 t['guilsinglright'] = 0x203A;
7650 t['gukatakana'] = 0x30B0;
7651 t['guramusquare'] = 0x3318;
7652 t['gysquare'] = 0x33C9;
7653 t['h'] = 0x0068;
7654 t['haabkhasiancyrillic'] = 0x04A9;
7655 t['haaltonearabic'] = 0x06C1;
7656 t['habengali'] = 0x09B9;
7657 t['hadescendercyrillic'] = 0x04B3;
7658 t['hadeva'] = 0x0939;
7659 t['hagujarati'] = 0x0AB9;
7660 t['hagurmukhi'] = 0x0A39;
7661 t['haharabic'] = 0x062D;
7662 t['hahfinalarabic'] = 0xFEA2;
7663 t['hahinitialarabic'] = 0xFEA3;
7664 t['hahiragana'] = 0x306F;
7665 t['hahmedialarabic'] = 0xFEA4;
7666 t['haitusquare'] = 0x332A;
7667 t['hakatakana'] = 0x30CF;
7668 t['hakatakanahalfwidth'] = 0xFF8A;
7669 t['halantgurmukhi'] = 0x0A4D;
7670 t['hamzaarabic'] = 0x0621;
7671 t['hamzalowarabic'] = 0x0621;
7672 t['hangulfiller'] = 0x3164;
7673 t['hardsigncyrillic'] = 0x044A;
7674 t['harpoonleftbarbup'] = 0x21BC;
7675 t['harpoonrightbarbup'] = 0x21C0;
7676 t['hasquare'] = 0x33CA;
7677 t['hatafpatah'] = 0x05B2;
7678 t['hatafpatah16'] = 0x05B2;
7679 t['hatafpatah23'] = 0x05B2;
7680 t['hatafpatah2f'] = 0x05B2;
7681 t['hatafpatahhebrew'] = 0x05B2;
7682 t['hatafpatahnarrowhebrew'] = 0x05B2;
7683 t['hatafpatahquarterhebrew'] = 0x05B2;
7684 t['hatafpatahwidehebrew'] = 0x05B2;
7685 t['hatafqamats'] = 0x05B3;
7686 t['hatafqamats1b'] = 0x05B3;
7687 t['hatafqamats28'] = 0x05B3;
7688 t['hatafqamats34'] = 0x05B3;
7689 t['hatafqamatshebrew'] = 0x05B3;
7690 t['hatafqamatsnarrowhebrew'] = 0x05B3;
7691 t['hatafqamatsquarterhebrew'] = 0x05B3;
7692 t['hatafqamatswidehebrew'] = 0x05B3;
7693 t['hatafsegol'] = 0x05B1;
7694 t['hatafsegol17'] = 0x05B1;
7695 t['hatafsegol24'] = 0x05B1;
7696 t['hatafsegol30'] = 0x05B1;
7697 t['hatafsegolhebrew'] = 0x05B1;
7698 t['hatafsegolnarrowhebrew'] = 0x05B1;
7699 t['hatafsegolquarterhebrew'] = 0x05B1;
7700 t['hatafsegolwidehebrew'] = 0x05B1;
7701 t['hbar'] = 0x0127;
7702 t['hbopomofo'] = 0x310F;
7703 t['hbrevebelow'] = 0x1E2B;
7704 t['hcedilla'] = 0x1E29;
7705 t['hcircle'] = 0x24D7;
7706 t['hcircumflex'] = 0x0125;
7707 t['hdieresis'] = 0x1E27;
7708 t['hdotaccent'] = 0x1E23;
7709 t['hdotbelow'] = 0x1E25;
7710 t['he'] = 0x05D4;
7711 t['heart'] = 0x2665;
7712 t['heartsuitblack'] = 0x2665;
7713 t['heartsuitwhite'] = 0x2661;
7714 t['hedagesh'] = 0xFB34;
7715 t['hedageshhebrew'] = 0xFB34;
7716 t['hehaltonearabic'] = 0x06C1;
7717 t['heharabic'] = 0x0647;
7718 t['hehebrew'] = 0x05D4;
7719 t['hehfinalaltonearabic'] = 0xFBA7;
7720 t['hehfinalalttwoarabic'] = 0xFEEA;
7721 t['hehfinalarabic'] = 0xFEEA;
7722 t['hehhamzaabovefinalarabic'] = 0xFBA5;
7723 t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
7724 t['hehinitialaltonearabic'] = 0xFBA8;
7725 t['hehinitialarabic'] = 0xFEEB;
7726 t['hehiragana'] = 0x3078;
7727 t['hehmedialaltonearabic'] = 0xFBA9;
7728 t['hehmedialarabic'] = 0xFEEC;
7729 t['heiseierasquare'] = 0x337B;
7730 t['hekatakana'] = 0x30D8;
7731 t['hekatakanahalfwidth'] = 0xFF8D;
7732 t['hekutaarusquare'] = 0x3336;
7733 t['henghook'] = 0x0267;
7734 t['herutusquare'] = 0x3339;
7735 t['het'] = 0x05D7;
7736 t['hethebrew'] = 0x05D7;
7737 t['hhook'] = 0x0266;
7738 t['hhooksuperior'] = 0x02B1;
7739 t['hieuhacirclekorean'] = 0x327B;
7740 t['hieuhaparenkorean'] = 0x321B;
7741 t['hieuhcirclekorean'] = 0x326D;
7742 t['hieuhkorean'] = 0x314E;
7743 t['hieuhparenkorean'] = 0x320D;
7744 t['hihiragana'] = 0x3072;
7745 t['hikatakana'] = 0x30D2;
7746 t['hikatakanahalfwidth'] = 0xFF8B;
7747 t['hiriq'] = 0x05B4;
7748 t['hiriq14'] = 0x05B4;
7749 t['hiriq21'] = 0x05B4;
7750 t['hiriq2d'] = 0x05B4;
7751 t['hiriqhebrew'] = 0x05B4;
7752 t['hiriqnarrowhebrew'] = 0x05B4;
7753 t['hiriqquarterhebrew'] = 0x05B4;
7754 t['hiriqwidehebrew'] = 0x05B4;
7755 t['hlinebelow'] = 0x1E96;
7756 t['hmonospace'] = 0xFF48;
7757 t['hoarmenian'] = 0x0570;
7758 t['hohipthai'] = 0x0E2B;
7759 t['hohiragana'] = 0x307B;
7760 t['hokatakana'] = 0x30DB;
7761 t['hokatakanahalfwidth'] = 0xFF8E;
7762 t['holam'] = 0x05B9;
7763 t['holam19'] = 0x05B9;
7764 t['holam26'] = 0x05B9;
7765 t['holam32'] = 0x05B9;
7766 t['holamhebrew'] = 0x05B9;
7767 t['holamnarrowhebrew'] = 0x05B9;
7768 t['holamquarterhebrew'] = 0x05B9;
7769 t['holamwidehebrew'] = 0x05B9;
7770 t['honokhukthai'] = 0x0E2E;
7771 t['hookabovecomb'] = 0x0309;
7772 t['hookcmb'] = 0x0309;
7773 t['hookpalatalizedbelowcmb'] = 0x0321;
7774 t['hookretroflexbelowcmb'] = 0x0322;
7775 t['hoonsquare'] = 0x3342;
7776 t['horicoptic'] = 0x03E9;
7777 t['horizontalbar'] = 0x2015;
7778 t['horncmb'] = 0x031B;
7779 t['hotsprings'] = 0x2668;
7780 t['house'] = 0x2302;
7781 t['hparen'] = 0x24A3;
7782 t['hsuperior'] = 0x02B0;
7783 t['hturned'] = 0x0265;
7784 t['huhiragana'] = 0x3075;
7785 t['huiitosquare'] = 0x3333;
7786 t['hukatakana'] = 0x30D5;
7787 t['hukatakanahalfwidth'] = 0xFF8C;
7788 t['hungarumlaut'] = 0x02DD;
7789 t['hungarumlautcmb'] = 0x030B;
7790 t['hv'] = 0x0195;
7791 t['hyphen'] = 0x002D;
7792 t['hypheninferior'] = 0xF6E5;
7793 t['hyphenmonospace'] = 0xFF0D;
7794 t['hyphensmall'] = 0xFE63;
7795 t['hyphensuperior'] = 0xF6E6;
7796 t['hyphentwo'] = 0x2010;
7797 t['i'] = 0x0069;
7798 t['iacute'] = 0x00ED;
7799 t['iacyrillic'] = 0x044F;
7800 t['ibengali'] = 0x0987;
7801 t['ibopomofo'] = 0x3127;
7802 t['ibreve'] = 0x012D;
7803 t['icaron'] = 0x01D0;
7804 t['icircle'] = 0x24D8;
7805 t['icircumflex'] = 0x00EE;
7806 t['icyrillic'] = 0x0456;
7807 t['idblgrave'] = 0x0209;
7808 t['ideographearthcircle'] = 0x328F;
7809 t['ideographfirecircle'] = 0x328B;
7810 t['ideographicallianceparen'] = 0x323F;
7811 t['ideographiccallparen'] = 0x323A;
7812 t['ideographiccentrecircle'] = 0x32A5;
7813 t['ideographicclose'] = 0x3006;
7814 t['ideographiccomma'] = 0x3001;
7815 t['ideographiccommaleft'] = 0xFF64;
7816 t['ideographiccongratulationparen'] = 0x3237;
7817 t['ideographiccorrectcircle'] = 0x32A3;
7818 t['ideographicearthparen'] = 0x322F;
7819 t['ideographicenterpriseparen'] = 0x323D;
7820 t['ideographicexcellentcircle'] = 0x329D;
7821 t['ideographicfestivalparen'] = 0x3240;
7822 t['ideographicfinancialcircle'] = 0x3296;
7823 t['ideographicfinancialparen'] = 0x3236;
7824 t['ideographicfireparen'] = 0x322B;
7825 t['ideographichaveparen'] = 0x3232;
7826 t['ideographichighcircle'] = 0x32A4;
7827 t['ideographiciterationmark'] = 0x3005;
7828 t['ideographiclaborcircle'] = 0x3298;
7829 t['ideographiclaborparen'] = 0x3238;
7830 t['ideographicleftcircle'] = 0x32A7;
7831 t['ideographiclowcircle'] = 0x32A6;
7832 t['ideographicmedicinecircle'] = 0x32A9;
7833 t['ideographicmetalparen'] = 0x322E;
7834 t['ideographicmoonparen'] = 0x322A;
7835 t['ideographicnameparen'] = 0x3234;
7836 t['ideographicperiod'] = 0x3002;
7837 t['ideographicprintcircle'] = 0x329E;
7838 t['ideographicreachparen'] = 0x3243;
7839 t['ideographicrepresentparen'] = 0x3239;
7840 t['ideographicresourceparen'] = 0x323E;
7841 t['ideographicrightcircle'] = 0x32A8;
7842 t['ideographicsecretcircle'] = 0x3299;
7843 t['ideographicselfparen'] = 0x3242;
7844 t['ideographicsocietyparen'] = 0x3233;
7845 t['ideographicspace'] = 0x3000;
7846 t['ideographicspecialparen'] = 0x3235;
7847 t['ideographicstockparen'] = 0x3231;
7848 t['ideographicstudyparen'] = 0x323B;
7849 t['ideographicsunparen'] = 0x3230;
7850 t['ideographicsuperviseparen'] = 0x323C;
7851 t['ideographicwaterparen'] = 0x322C;
7852 t['ideographicwoodparen'] = 0x322D;
7853 t['ideographiczero'] = 0x3007;
7854 t['ideographmetalcircle'] = 0x328E;
7855 t['ideographmooncircle'] = 0x328A;
7856 t['ideographnamecircle'] = 0x3294;
7857 t['ideographsuncircle'] = 0x3290;
7858 t['ideographwatercircle'] = 0x328C;
7859 t['ideographwoodcircle'] = 0x328D;
7860 t['ideva'] = 0x0907;
7861 t['idieresis'] = 0x00EF;
7862 t['idieresisacute'] = 0x1E2F;
7863 t['idieresiscyrillic'] = 0x04E5;
7864 t['idotbelow'] = 0x1ECB;
7865 t['iebrevecyrillic'] = 0x04D7;
7866 t['iecyrillic'] = 0x0435;
7867 t['ieungacirclekorean'] = 0x3275;
7868 t['ieungaparenkorean'] = 0x3215;
7869 t['ieungcirclekorean'] = 0x3267;
7870 t['ieungkorean'] = 0x3147;
7871 t['ieungparenkorean'] = 0x3207;
7872 t['igrave'] = 0x00EC;
7873 t['igujarati'] = 0x0A87;
7874 t['igurmukhi'] = 0x0A07;
7875 t['ihiragana'] = 0x3044;
7876 t['ihookabove'] = 0x1EC9;
7877 t['iibengali'] = 0x0988;
7878 t['iicyrillic'] = 0x0438;
7879 t['iideva'] = 0x0908;
7880 t['iigujarati'] = 0x0A88;
7881 t['iigurmukhi'] = 0x0A08;
7882 t['iimatragurmukhi'] = 0x0A40;
7883 t['iinvertedbreve'] = 0x020B;
7884 t['iishortcyrillic'] = 0x0439;
7885 t['iivowelsignbengali'] = 0x09C0;
7886 t['iivowelsigndeva'] = 0x0940;
7887 t['iivowelsigngujarati'] = 0x0AC0;
7888 t['ij'] = 0x0133;
7889 t['ikatakana'] = 0x30A4;
7890 t['ikatakanahalfwidth'] = 0xFF72;
7891 t['ikorean'] = 0x3163;
7892 t['ilde'] = 0x02DC;
7893 t['iluyhebrew'] = 0x05AC;
7894 t['imacron'] = 0x012B;
7895 t['imacroncyrillic'] = 0x04E3;
7896 t['imageorapproximatelyequal'] = 0x2253;
7897 t['imatragurmukhi'] = 0x0A3F;
7898 t['imonospace'] = 0xFF49;
7899 t['increment'] = 0x2206;
7900 t['infinity'] = 0x221E;
7901 t['iniarmenian'] = 0x056B;
7902 t['integral'] = 0x222B;
7903 t['integralbottom'] = 0x2321;
7904 t['integralbt'] = 0x2321;
7905 t['integralex'] = 0xF8F5;
7906 t['integraltop'] = 0x2320;
7907 t['integraltp'] = 0x2320;
7908 t['intersection'] = 0x2229;
7909 t['intisquare'] = 0x3305;
7910 t['invbullet'] = 0x25D8;
7911 t['invcircle'] = 0x25D9;
7912 t['invsmileface'] = 0x263B;
7913 t['iocyrillic'] = 0x0451;
7914 t['iogonek'] = 0x012F;
7915 t['iota'] = 0x03B9;
7916 t['iotadieresis'] = 0x03CA;
7917 t['iotadieresistonos'] = 0x0390;
7918 t['iotalatin'] = 0x0269;
7919 t['iotatonos'] = 0x03AF;
7920 t['iparen'] = 0x24A4;
7921 t['irigurmukhi'] = 0x0A72;
7922 t['ismallhiragana'] = 0x3043;
7923 t['ismallkatakana'] = 0x30A3;
7924 t['ismallkatakanahalfwidth'] = 0xFF68;
7925 t['issharbengali'] = 0x09FA;
7926 t['istroke'] = 0x0268;
7927 t['isuperior'] = 0xF6ED;
7928 t['iterationhiragana'] = 0x309D;
7929 t['iterationkatakana'] = 0x30FD;
7930 t['itilde'] = 0x0129;
7931 t['itildebelow'] = 0x1E2D;
7932 t['iubopomofo'] = 0x3129;
7933 t['iucyrillic'] = 0x044E;
7934 t['ivowelsignbengali'] = 0x09BF;
7935 t['ivowelsigndeva'] = 0x093F;
7936 t['ivowelsigngujarati'] = 0x0ABF;
7937 t['izhitsacyrillic'] = 0x0475;
7938 t['izhitsadblgravecyrillic'] = 0x0477;
7939 t['j'] = 0x006A;
7940 t['jaarmenian'] = 0x0571;
7941 t['jabengali'] = 0x099C;
7942 t['jadeva'] = 0x091C;
7943 t['jagujarati'] = 0x0A9C;
7944 t['jagurmukhi'] = 0x0A1C;
7945 t['jbopomofo'] = 0x3110;
7946 t['jcaron'] = 0x01F0;
7947 t['jcircle'] = 0x24D9;
7948 t['jcircumflex'] = 0x0135;
7949 t['jcrossedtail'] = 0x029D;
7950 t['jdotlessstroke'] = 0x025F;
7951 t['jecyrillic'] = 0x0458;
7952 t['jeemarabic'] = 0x062C;
7953 t['jeemfinalarabic'] = 0xFE9E;
7954 t['jeeminitialarabic'] = 0xFE9F;
7955 t['jeemmedialarabic'] = 0xFEA0;
7956 t['jeharabic'] = 0x0698;
7957 t['jehfinalarabic'] = 0xFB8B;
7958 t['jhabengali'] = 0x099D;
7959 t['jhadeva'] = 0x091D;
7960 t['jhagujarati'] = 0x0A9D;
7961 t['jhagurmukhi'] = 0x0A1D;
7962 t['jheharmenian'] = 0x057B;
7963 t['jis'] = 0x3004;
7964 t['jmonospace'] = 0xFF4A;
7965 t['jparen'] = 0x24A5;
7966 t['jsuperior'] = 0x02B2;
7967 t['k'] = 0x006B;
7968 t['kabashkircyrillic'] = 0x04A1;
7969 t['kabengali'] = 0x0995;
7970 t['kacute'] = 0x1E31;
7971 t['kacyrillic'] = 0x043A;
7972 t['kadescendercyrillic'] = 0x049B;
7973 t['kadeva'] = 0x0915;
7974 t['kaf'] = 0x05DB;
7975 t['kafarabic'] = 0x0643;
7976 t['kafdagesh'] = 0xFB3B;
7977 t['kafdageshhebrew'] = 0xFB3B;
7978 t['kaffinalarabic'] = 0xFEDA;
7979 t['kafhebrew'] = 0x05DB;
7980 t['kafinitialarabic'] = 0xFEDB;
7981 t['kafmedialarabic'] = 0xFEDC;
7982 t['kafrafehebrew'] = 0xFB4D;
7983 t['kagujarati'] = 0x0A95;
7984 t['kagurmukhi'] = 0x0A15;
7985 t['kahiragana'] = 0x304B;
7986 t['kahookcyrillic'] = 0x04C4;
7987 t['kakatakana'] = 0x30AB;
7988 t['kakatakanahalfwidth'] = 0xFF76;
7989 t['kappa'] = 0x03BA;
7990 t['kappasymbolgreek'] = 0x03F0;
7991 t['kapyeounmieumkorean'] = 0x3171;
7992 t['kapyeounphieuphkorean'] = 0x3184;
7993 t['kapyeounpieupkorean'] = 0x3178;
7994 t['kapyeounssangpieupkorean'] = 0x3179;
7995 t['karoriisquare'] = 0x330D;
7996 t['kashidaautoarabic'] = 0x0640;
7997 t['kashidaautonosidebearingarabic'] = 0x0640;
7998 t['kasmallkatakana'] = 0x30F5;
7999 t['kasquare'] = 0x3384;
8000 t['kasraarabic'] = 0x0650;
8001 t['kasratanarabic'] = 0x064D;
8002 t['kastrokecyrillic'] = 0x049F;
8003 t['katahiraprolongmarkhalfwidth'] = 0xFF70;
8004 t['kaverticalstrokecyrillic'] = 0x049D;
8005 t['kbopomofo'] = 0x310E;
8006 t['kcalsquare'] = 0x3389;
8007 t['kcaron'] = 0x01E9;
8008 t['kcedilla'] = 0x0137;
8009 t['kcircle'] = 0x24DA;
8010 t['kcommaaccent'] = 0x0137;
8011 t['kdotbelow'] = 0x1E33;
8012 t['keharmenian'] = 0x0584;
8013 t['kehiragana'] = 0x3051;
8014 t['kekatakana'] = 0x30B1;
8015 t['kekatakanahalfwidth'] = 0xFF79;
8016 t['kenarmenian'] = 0x056F;
8017 t['kesmallkatakana'] = 0x30F6;
8018 t['kgreenlandic'] = 0x0138;
8019 t['khabengali'] = 0x0996;
8020 t['khacyrillic'] = 0x0445;
8021 t['khadeva'] = 0x0916;
8022 t['khagujarati'] = 0x0A96;
8023 t['khagurmukhi'] = 0x0A16;
8024 t['khaharabic'] = 0x062E;
8025 t['khahfinalarabic'] = 0xFEA6;
8026 t['khahinitialarabic'] = 0xFEA7;
8027 t['khahmedialarabic'] = 0xFEA8;
8028 t['kheicoptic'] = 0x03E7;
8029 t['khhadeva'] = 0x0959;
8030 t['khhagurmukhi'] = 0x0A59;
8031 t['khieukhacirclekorean'] = 0x3278;
8032 t['khieukhaparenkorean'] = 0x3218;
8033 t['khieukhcirclekorean'] = 0x326A;
8034 t['khieukhkorean'] = 0x314B;
8035 t['khieukhparenkorean'] = 0x320A;
8036 t['khokhaithai'] = 0x0E02;
8037 t['khokhonthai'] = 0x0E05;
8038 t['khokhuatthai'] = 0x0E03;
8039 t['khokhwaithai'] = 0x0E04;
8040 t['khomutthai'] = 0x0E5B;
8041 t['khook'] = 0x0199;
8042 t['khorakhangthai'] = 0x0E06;
8043 t['khzsquare'] = 0x3391;
8044 t['kihiragana'] = 0x304D;
8045 t['kikatakana'] = 0x30AD;
8046 t['kikatakanahalfwidth'] = 0xFF77;
8047 t['kiroguramusquare'] = 0x3315;
8048 t['kiromeetorusquare'] = 0x3316;
8049 t['kirosquare'] = 0x3314;
8050 t['kiyeokacirclekorean'] = 0x326E;
8051 t['kiyeokaparenkorean'] = 0x320E;
8052 t['kiyeokcirclekorean'] = 0x3260;
8053 t['kiyeokkorean'] = 0x3131;
8054 t['kiyeokparenkorean'] = 0x3200;
8055 t['kiyeoksioskorean'] = 0x3133;
8056 t['kjecyrillic'] = 0x045C;
8057 t['klinebelow'] = 0x1E35;
8058 t['klsquare'] = 0x3398;
8059 t['kmcubedsquare'] = 0x33A6;
8060 t['kmonospace'] = 0xFF4B;
8061 t['kmsquaredsquare'] = 0x33A2;
8062 t['kohiragana'] = 0x3053;
8063 t['kohmsquare'] = 0x33C0;
8064 t['kokaithai'] = 0x0E01;
8065 t['kokatakana'] = 0x30B3;
8066 t['kokatakanahalfwidth'] = 0xFF7A;
8067 t['kooposquare'] = 0x331E;
8068 t['koppacyrillic'] = 0x0481;
8069 t['koreanstandardsymbol'] = 0x327F;
8070 t['koroniscmb'] = 0x0343;
8071 t['kparen'] = 0x24A6;
8072 t['kpasquare'] = 0x33AA;
8073 t['ksicyrillic'] = 0x046F;
8074 t['ktsquare'] = 0x33CF;
8075 t['kturned'] = 0x029E;
8076 t['kuhiragana'] = 0x304F;
8077 t['kukatakana'] = 0x30AF;
8078 t['kukatakanahalfwidth'] = 0xFF78;
8079 t['kvsquare'] = 0x33B8;
8080 t['kwsquare'] = 0x33BE;
8081 t['l'] = 0x006C;
8082 t['labengali'] = 0x09B2;
8083 t['lacute'] = 0x013A;
8084 t['ladeva'] = 0x0932;
8085 t['lagujarati'] = 0x0AB2;
8086 t['lagurmukhi'] = 0x0A32;
8087 t['lakkhangyaothai'] = 0x0E45;
8088 t['lamaleffinalarabic'] = 0xFEFC;
8089 t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
8090 t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
8091 t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
8092 t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
8093 t['lamalefisolatedarabic'] = 0xFEFB;
8094 t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
8095 t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
8096 t['lamarabic'] = 0x0644;
8097 t['lambda'] = 0x03BB;
8098 t['lambdastroke'] = 0x019B;
8099 t['lamed'] = 0x05DC;
8100 t['lameddagesh'] = 0xFB3C;
8101 t['lameddageshhebrew'] = 0xFB3C;
8102 t['lamedhebrew'] = 0x05DC;
8103 t['lamfinalarabic'] = 0xFEDE;
8104 t['lamhahinitialarabic'] = 0xFCCA;
8105 t['laminitialarabic'] = 0xFEDF;
8106 t['lamjeeminitialarabic'] = 0xFCC9;
8107 t['lamkhahinitialarabic'] = 0xFCCB;
8108 t['lamlamhehisolatedarabic'] = 0xFDF2;
8109 t['lammedialarabic'] = 0xFEE0;
8110 t['lammeemhahinitialarabic'] = 0xFD88;
8111 t['lammeeminitialarabic'] = 0xFCCC;
8112 t['largecircle'] = 0x25EF;
8113 t['lbar'] = 0x019A;
8114 t['lbelt'] = 0x026C;
8115 t['lbopomofo'] = 0x310C;
8116 t['lcaron'] = 0x013E;
8117 t['lcedilla'] = 0x013C;
8118 t['lcircle'] = 0x24DB;
8119 t['lcircumflexbelow'] = 0x1E3D;
8120 t['lcommaaccent'] = 0x013C;
8121 t['ldot'] = 0x0140;
8122 t['ldotaccent'] = 0x0140;
8123 t['ldotbelow'] = 0x1E37;
8124 t['ldotbelowmacron'] = 0x1E39;
8125 t['leftangleabovecmb'] = 0x031A;
8126 t['lefttackbelowcmb'] = 0x0318;
8127 t['less'] = 0x003C;
8128 t['lessequal'] = 0x2264;
8129 t['lessequalorgreater'] = 0x22DA;
8130 t['lessmonospace'] = 0xFF1C;
8131 t['lessorequivalent'] = 0x2272;
8132 t['lessorgreater'] = 0x2276;
8133 t['lessoverequal'] = 0x2266;
8134 t['lesssmall'] = 0xFE64;
8135 t['lezh'] = 0x026E;
8136 t['lfblock'] = 0x258C;
8137 t['lhookretroflex'] = 0x026D;
8138 t['lira'] = 0x20A4;
8139 t['liwnarmenian'] = 0x056C;
8140 t['lj'] = 0x01C9;
8141 t['ljecyrillic'] = 0x0459;
8142 t['ll'] = 0xF6C0;
8143 t['lladeva'] = 0x0933;
8144 t['llagujarati'] = 0x0AB3;
8145 t['llinebelow'] = 0x1E3B;
8146 t['llladeva'] = 0x0934;
8147 t['llvocalicbengali'] = 0x09E1;
8148 t['llvocalicdeva'] = 0x0961;
8149 t['llvocalicvowelsignbengali'] = 0x09E3;
8150 t['llvocalicvowelsigndeva'] = 0x0963;
8151 t['lmiddletilde'] = 0x026B;
8152 t['lmonospace'] = 0xFF4C;
8153 t['lmsquare'] = 0x33D0;
8154 t['lochulathai'] = 0x0E2C;
8155 t['logicaland'] = 0x2227;
8156 t['logicalnot'] = 0x00AC;
8157 t['logicalnotreversed'] = 0x2310;
8158 t['logicalor'] = 0x2228;
8159 t['lolingthai'] = 0x0E25;
8160 t['longs'] = 0x017F;
8161 t['lowlinecenterline'] = 0xFE4E;
8162 t['lowlinecmb'] = 0x0332;
8163 t['lowlinedashed'] = 0xFE4D;
8164 t['lozenge'] = 0x25CA;
8165 t['lparen'] = 0x24A7;
8166 t['lslash'] = 0x0142;
8167 t['lsquare'] = 0x2113;
8168 t['lsuperior'] = 0xF6EE;
8169 t['ltshade'] = 0x2591;
8170 t['luthai'] = 0x0E26;
8171 t['lvocalicbengali'] = 0x098C;
8172 t['lvocalicdeva'] = 0x090C;
8173 t['lvocalicvowelsignbengali'] = 0x09E2;
8174 t['lvocalicvowelsigndeva'] = 0x0962;
8175 t['lxsquare'] = 0x33D3;
8176 t['m'] = 0x006D;
8177 t['mabengali'] = 0x09AE;
8178 t['macron'] = 0x00AF;
8179 t['macronbelowcmb'] = 0x0331;
8180 t['macroncmb'] = 0x0304;
8181 t['macronlowmod'] = 0x02CD;
8182 t['macronmonospace'] = 0xFFE3;
8183 t['macute'] = 0x1E3F;
8184 t['madeva'] = 0x092E;
8185 t['magujarati'] = 0x0AAE;
8186 t['magurmukhi'] = 0x0A2E;
8187 t['mahapakhhebrew'] = 0x05A4;
8188 t['mahapakhlefthebrew'] = 0x05A4;
8189 t['mahiragana'] = 0x307E;
8190 t['maichattawalowleftthai'] = 0xF895;
8191 t['maichattawalowrightthai'] = 0xF894;
8192 t['maichattawathai'] = 0x0E4B;
8193 t['maichattawaupperleftthai'] = 0xF893;
8194 t['maieklowleftthai'] = 0xF88C;
8195 t['maieklowrightthai'] = 0xF88B;
8196 t['maiekthai'] = 0x0E48;
8197 t['maiekupperleftthai'] = 0xF88A;
8198 t['maihanakatleftthai'] = 0xF884;
8199 t['maihanakatthai'] = 0x0E31;
8200 t['maitaikhuleftthai'] = 0xF889;
8201 t['maitaikhuthai'] = 0x0E47;
8202 t['maitholowleftthai'] = 0xF88F;
8203 t['maitholowrightthai'] = 0xF88E;
8204 t['maithothai'] = 0x0E49;
8205 t['maithoupperleftthai'] = 0xF88D;
8206 t['maitrilowleftthai'] = 0xF892;
8207 t['maitrilowrightthai'] = 0xF891;
8208 t['maitrithai'] = 0x0E4A;
8209 t['maitriupperleftthai'] = 0xF890;
8210 t['maiyamokthai'] = 0x0E46;
8211 t['makatakana'] = 0x30DE;
8212 t['makatakanahalfwidth'] = 0xFF8F;
8213 t['male'] = 0x2642;
8214 t['mansyonsquare'] = 0x3347;
8215 t['maqafhebrew'] = 0x05BE;
8216 t['mars'] = 0x2642;
8217 t['masoracirclehebrew'] = 0x05AF;
8218 t['masquare'] = 0x3383;
8219 t['mbopomofo'] = 0x3107;
8220 t['mbsquare'] = 0x33D4;
8221 t['mcircle'] = 0x24DC;
8222 t['mcubedsquare'] = 0x33A5;
8223 t['mdotaccent'] = 0x1E41;
8224 t['mdotbelow'] = 0x1E43;
8225 t['meemarabic'] = 0x0645;
8226 t['meemfinalarabic'] = 0xFEE2;
8227 t['meeminitialarabic'] = 0xFEE3;
8228 t['meemmedialarabic'] = 0xFEE4;
8229 t['meemmeeminitialarabic'] = 0xFCD1;
8230 t['meemmeemisolatedarabic'] = 0xFC48;
8231 t['meetorusquare'] = 0x334D;
8232 t['mehiragana'] = 0x3081;
8233 t['meizierasquare'] = 0x337E;
8234 t['mekatakana'] = 0x30E1;
8235 t['mekatakanahalfwidth'] = 0xFF92;
8236 t['mem'] = 0x05DE;
8237 t['memdagesh'] = 0xFB3E;
8238 t['memdageshhebrew'] = 0xFB3E;
8239 t['memhebrew'] = 0x05DE;
8240 t['menarmenian'] = 0x0574;
8241 t['merkhahebrew'] = 0x05A5;
8242 t['merkhakefulahebrew'] = 0x05A6;
8243 t['merkhakefulalefthebrew'] = 0x05A6;
8244 t['merkhalefthebrew'] = 0x05A5;
8245 t['mhook'] = 0x0271;
8246 t['mhzsquare'] = 0x3392;
8247 t['middledotkatakanahalfwidth'] = 0xFF65;
8248 t['middot'] = 0x00B7;
8249 t['mieumacirclekorean'] = 0x3272;
8250 t['mieumaparenkorean'] = 0x3212;
8251 t['mieumcirclekorean'] = 0x3264;
8252 t['mieumkorean'] = 0x3141;
8253 t['mieumpansioskorean'] = 0x3170;
8254 t['mieumparenkorean'] = 0x3204;
8255 t['mieumpieupkorean'] = 0x316E;
8256 t['mieumsioskorean'] = 0x316F;
8257 t['mihiragana'] = 0x307F;
8258 t['mikatakana'] = 0x30DF;
8259 t['mikatakanahalfwidth'] = 0xFF90;
8260 t['minus'] = 0x2212;
8261 t['minusbelowcmb'] = 0x0320;
8262 t['minuscircle'] = 0x2296;
8263 t['minusmod'] = 0x02D7;
8264 t['minusplus'] = 0x2213;
8265 t['minute'] = 0x2032;
8266 t['miribaarusquare'] = 0x334A;
8267 t['mirisquare'] = 0x3349;
8268 t['mlonglegturned'] = 0x0270;
8269 t['mlsquare'] = 0x3396;
8270 t['mmcubedsquare'] = 0x33A3;
8271 t['mmonospace'] = 0xFF4D;
8272 t['mmsquaredsquare'] = 0x339F;
8273 t['mohiragana'] = 0x3082;
8274 t['mohmsquare'] = 0x33C1;
8275 t['mokatakana'] = 0x30E2;
8276 t['mokatakanahalfwidth'] = 0xFF93;
8277 t['molsquare'] = 0x33D6;
8278 t['momathai'] = 0x0E21;
8279 t['moverssquare'] = 0x33A7;
8280 t['moverssquaredsquare'] = 0x33A8;
8281 t['mparen'] = 0x24A8;
8282 t['mpasquare'] = 0x33AB;
8283 t['mssquare'] = 0x33B3;
8284 t['msuperior'] = 0xF6EF;
8285 t['mturned'] = 0x026F;
8286 t['mu'] = 0x00B5;
8287 t['mu1'] = 0x00B5;
8288 t['muasquare'] = 0x3382;
8289 t['muchgreater'] = 0x226B;
8290 t['muchless'] = 0x226A;
8291 t['mufsquare'] = 0x338C;
8292 t['mugreek'] = 0x03BC;
8293 t['mugsquare'] = 0x338D;
8294 t['muhiragana'] = 0x3080;
8295 t['mukatakana'] = 0x30E0;
8296 t['mukatakanahalfwidth'] = 0xFF91;
8297 t['mulsquare'] = 0x3395;
8298 t['multiply'] = 0x00D7;
8299 t['mumsquare'] = 0x339B;
8300 t['munahhebrew'] = 0x05A3;
8301 t['munahlefthebrew'] = 0x05A3;
8302 t['musicalnote'] = 0x266A;
8303 t['musicalnotedbl'] = 0x266B;
8304 t['musicflatsign'] = 0x266D;
8305 t['musicsharpsign'] = 0x266F;
8306 t['mussquare'] = 0x33B2;
8307 t['muvsquare'] = 0x33B6;
8308 t['muwsquare'] = 0x33BC;
8309 t['mvmegasquare'] = 0x33B9;
8310 t['mvsquare'] = 0x33B7;
8311 t['mwmegasquare'] = 0x33BF;
8312 t['mwsquare'] = 0x33BD;
8313 t['n'] = 0x006E;
8314 t['nabengali'] = 0x09A8;
8315 t['nabla'] = 0x2207;
8316 t['nacute'] = 0x0144;
8317 t['nadeva'] = 0x0928;
8318 t['nagujarati'] = 0x0AA8;
8319 t['nagurmukhi'] = 0x0A28;
8320 t['nahiragana'] = 0x306A;
8321 t['nakatakana'] = 0x30CA;
8322 t['nakatakanahalfwidth'] = 0xFF85;
8323 t['napostrophe'] = 0x0149;
8324 t['nasquare'] = 0x3381;
8325 t['nbopomofo'] = 0x310B;
8326 t['nbspace'] = 0x00A0;
8327 t['ncaron'] = 0x0148;
8328 t['ncedilla'] = 0x0146;
8329 t['ncircle'] = 0x24DD;
8330 t['ncircumflexbelow'] = 0x1E4B;
8331 t['ncommaaccent'] = 0x0146;
8332 t['ndotaccent'] = 0x1E45;
8333 t['ndotbelow'] = 0x1E47;
8334 t['nehiragana'] = 0x306D;
8335 t['nekatakana'] = 0x30CD;
8336 t['nekatakanahalfwidth'] = 0xFF88;
8337 t['newsheqelsign'] = 0x20AA;
8338 t['nfsquare'] = 0x338B;
8339 t['ngabengali'] = 0x0999;
8340 t['ngadeva'] = 0x0919;
8341 t['ngagujarati'] = 0x0A99;
8342 t['ngagurmukhi'] = 0x0A19;
8343 t['ngonguthai'] = 0x0E07;
8344 t['nhiragana'] = 0x3093;
8345 t['nhookleft'] = 0x0272;
8346 t['nhookretroflex'] = 0x0273;
8347 t['nieunacirclekorean'] = 0x326F;
8348 t['nieunaparenkorean'] = 0x320F;
8349 t['nieuncieuckorean'] = 0x3135;
8350 t['nieuncirclekorean'] = 0x3261;
8351 t['nieunhieuhkorean'] = 0x3136;
8352 t['nieunkorean'] = 0x3134;
8353 t['nieunpansioskorean'] = 0x3168;
8354 t['nieunparenkorean'] = 0x3201;
8355 t['nieunsioskorean'] = 0x3167;
8356 t['nieuntikeutkorean'] = 0x3166;
8357 t['nihiragana'] = 0x306B;
8358 t['nikatakana'] = 0x30CB;
8359 t['nikatakanahalfwidth'] = 0xFF86;
8360 t['nikhahitleftthai'] = 0xF899;
8361 t['nikhahitthai'] = 0x0E4D;
8362 t['nine'] = 0x0039;
8363 t['ninearabic'] = 0x0669;
8364 t['ninebengali'] = 0x09EF;
8365 t['ninecircle'] = 0x2468;
8366 t['ninecircleinversesansserif'] = 0x2792;
8367 t['ninedeva'] = 0x096F;
8368 t['ninegujarati'] = 0x0AEF;
8369 t['ninegurmukhi'] = 0x0A6F;
8370 t['ninehackarabic'] = 0x0669;
8371 t['ninehangzhou'] = 0x3029;
8372 t['nineideographicparen'] = 0x3228;
8373 t['nineinferior'] = 0x2089;
8374 t['ninemonospace'] = 0xFF19;
8375 t['nineoldstyle'] = 0xF739;
8376 t['nineparen'] = 0x247C;
8377 t['nineperiod'] = 0x2490;
8378 t['ninepersian'] = 0x06F9;
8379 t['nineroman'] = 0x2178;
8380 t['ninesuperior'] = 0x2079;
8381 t['nineteencircle'] = 0x2472;
8382 t['nineteenparen'] = 0x2486;
8383 t['nineteenperiod'] = 0x249A;
8384 t['ninethai'] = 0x0E59;
8385 t['nj'] = 0x01CC;
8386 t['njecyrillic'] = 0x045A;
8387 t['nkatakana'] = 0x30F3;
8388 t['nkatakanahalfwidth'] = 0xFF9D;
8389 t['nlegrightlong'] = 0x019E;
8390 t['nlinebelow'] = 0x1E49;
8391 t['nmonospace'] = 0xFF4E;
8392 t['nmsquare'] = 0x339A;
8393 t['nnabengali'] = 0x09A3;
8394 t['nnadeva'] = 0x0923;
8395 t['nnagujarati'] = 0x0AA3;
8396 t['nnagurmukhi'] = 0x0A23;
8397 t['nnnadeva'] = 0x0929;
8398 t['nohiragana'] = 0x306E;
8399 t['nokatakana'] = 0x30CE;
8400 t['nokatakanahalfwidth'] = 0xFF89;
8401 t['nonbreakingspace'] = 0x00A0;
8402 t['nonenthai'] = 0x0E13;
8403 t['nonuthai'] = 0x0E19;
8404 t['noonarabic'] = 0x0646;
8405 t['noonfinalarabic'] = 0xFEE6;
8406 t['noonghunnaarabic'] = 0x06BA;
8407 t['noonghunnafinalarabic'] = 0xFB9F;
8408 t['nooninitialarabic'] = 0xFEE7;
8409 t['noonjeeminitialarabic'] = 0xFCD2;
8410 t['noonjeemisolatedarabic'] = 0xFC4B;
8411 t['noonmedialarabic'] = 0xFEE8;
8412 t['noonmeeminitialarabic'] = 0xFCD5;
8413 t['noonmeemisolatedarabic'] = 0xFC4E;
8414 t['noonnoonfinalarabic'] = 0xFC8D;
8415 t['notcontains'] = 0x220C;
8416 t['notelement'] = 0x2209;
8417 t['notelementof'] = 0x2209;
8418 t['notequal'] = 0x2260;
8419 t['notgreater'] = 0x226F;
8420 t['notgreaternorequal'] = 0x2271;
8421 t['notgreaternorless'] = 0x2279;
8422 t['notidentical'] = 0x2262;
8423 t['notless'] = 0x226E;
8424 t['notlessnorequal'] = 0x2270;
8425 t['notparallel'] = 0x2226;
8426 t['notprecedes'] = 0x2280;
8427 t['notsubset'] = 0x2284;
8428 t['notsucceeds'] = 0x2281;
8429 t['notsuperset'] = 0x2285;
8430 t['nowarmenian'] = 0x0576;
8431 t['nparen'] = 0x24A9;
8432 t['nssquare'] = 0x33B1;
8433 t['nsuperior'] = 0x207F;
8434 t['ntilde'] = 0x00F1;
8435 t['nu'] = 0x03BD;
8436 t['nuhiragana'] = 0x306C;
8437 t['nukatakana'] = 0x30CC;
8438 t['nukatakanahalfwidth'] = 0xFF87;
8439 t['nuktabengali'] = 0x09BC;
8440 t['nuktadeva'] = 0x093C;
8441 t['nuktagujarati'] = 0x0ABC;
8442 t['nuktagurmukhi'] = 0x0A3C;
8443 t['numbersign'] = 0x0023;
8444 t['numbersignmonospace'] = 0xFF03;
8445 t['numbersignsmall'] = 0xFE5F;
8446 t['numeralsigngreek'] = 0x0374;
8447 t['numeralsignlowergreek'] = 0x0375;
8448 t['numero'] = 0x2116;
8449 t['nun'] = 0x05E0;
8450 t['nundagesh'] = 0xFB40;
8451 t['nundageshhebrew'] = 0xFB40;
8452 t['nunhebrew'] = 0x05E0;
8453 t['nvsquare'] = 0x33B5;
8454 t['nwsquare'] = 0x33BB;
8455 t['nyabengali'] = 0x099E;
8456 t['nyadeva'] = 0x091E;
8457 t['nyagujarati'] = 0x0A9E;
8458 t['nyagurmukhi'] = 0x0A1E;
8459 t['o'] = 0x006F;
8460 t['oacute'] = 0x00F3;
8461 t['oangthai'] = 0x0E2D;
8462 t['obarred'] = 0x0275;
8463 t['obarredcyrillic'] = 0x04E9;
8464 t['obarreddieresiscyrillic'] = 0x04EB;
8465 t['obengali'] = 0x0993;
8466 t['obopomofo'] = 0x311B;
8467 t['obreve'] = 0x014F;
8468 t['ocandradeva'] = 0x0911;
8469 t['ocandragujarati'] = 0x0A91;
8470 t['ocandravowelsigndeva'] = 0x0949;
8471 t['ocandravowelsigngujarati'] = 0x0AC9;
8472 t['ocaron'] = 0x01D2;
8473 t['ocircle'] = 0x24DE;
8474 t['ocircumflex'] = 0x00F4;
8475 t['ocircumflexacute'] = 0x1ED1;
8476 t['ocircumflexdotbelow'] = 0x1ED9;
8477 t['ocircumflexgrave'] = 0x1ED3;
8478 t['ocircumflexhookabove'] = 0x1ED5;
8479 t['ocircumflextilde'] = 0x1ED7;
8480 t['ocyrillic'] = 0x043E;
8481 t['odblacute'] = 0x0151;
8482 t['odblgrave'] = 0x020D;
8483 t['odeva'] = 0x0913;
8484 t['odieresis'] = 0x00F6;
8485 t['odieresiscyrillic'] = 0x04E7;
8486 t['odotbelow'] = 0x1ECD;
8487 t['oe'] = 0x0153;
8488 t['oekorean'] = 0x315A;
8489 t['ogonek'] = 0x02DB;
8490 t['ogonekcmb'] = 0x0328;
8491 t['ograve'] = 0x00F2;
8492 t['ogujarati'] = 0x0A93;
8493 t['oharmenian'] = 0x0585;
8494 t['ohiragana'] = 0x304A;
8495 t['ohookabove'] = 0x1ECF;
8496 t['ohorn'] = 0x01A1;
8497 t['ohornacute'] = 0x1EDB;
8498 t['ohorndotbelow'] = 0x1EE3;
8499 t['ohorngrave'] = 0x1EDD;
8500 t['ohornhookabove'] = 0x1EDF;
8501 t['ohorntilde'] = 0x1EE1;
8502 t['ohungarumlaut'] = 0x0151;
8503 t['oi'] = 0x01A3;
8504 t['oinvertedbreve'] = 0x020F;
8505 t['okatakana'] = 0x30AA;
8506 t['okatakanahalfwidth'] = 0xFF75;
8507 t['okorean'] = 0x3157;
8508 t['olehebrew'] = 0x05AB;
8509 t['omacron'] = 0x014D;
8510 t['omacronacute'] = 0x1E53;
8511 t['omacrongrave'] = 0x1E51;
8512 t['omdeva'] = 0x0950;
8513 t['omega'] = 0x03C9;
8514 t['omega1'] = 0x03D6;
8515 t['omegacyrillic'] = 0x0461;
8516 t['omegalatinclosed'] = 0x0277;
8517 t['omegaroundcyrillic'] = 0x047B;
8518 t['omegatitlocyrillic'] = 0x047D;
8519 t['omegatonos'] = 0x03CE;
8520 t['omgujarati'] = 0x0AD0;
8521 t['omicron'] = 0x03BF;
8522 t['omicrontonos'] = 0x03CC;
8523 t['omonospace'] = 0xFF4F;
8524 t['one'] = 0x0031;
8525 t['onearabic'] = 0x0661;
8526 t['onebengali'] = 0x09E7;
8527 t['onecircle'] = 0x2460;
8528 t['onecircleinversesansserif'] = 0x278A;
8529 t['onedeva'] = 0x0967;
8530 t['onedotenleader'] = 0x2024;
8531 t['oneeighth'] = 0x215B;
8532 t['onefitted'] = 0xF6DC;
8533 t['onegujarati'] = 0x0AE7;
8534 t['onegurmukhi'] = 0x0A67;
8535 t['onehackarabic'] = 0x0661;
8536 t['onehalf'] = 0x00BD;
8537 t['onehangzhou'] = 0x3021;
8538 t['oneideographicparen'] = 0x3220;
8539 t['oneinferior'] = 0x2081;
8540 t['onemonospace'] = 0xFF11;
8541 t['onenumeratorbengali'] = 0x09F4;
8542 t['oneoldstyle'] = 0xF731;
8543 t['oneparen'] = 0x2474;
8544 t['oneperiod'] = 0x2488;
8545 t['onepersian'] = 0x06F1;
8546 t['onequarter'] = 0x00BC;
8547 t['oneroman'] = 0x2170;
8548 t['onesuperior'] = 0x00B9;
8549 t['onethai'] = 0x0E51;
8550 t['onethird'] = 0x2153;
8551 t['oogonek'] = 0x01EB;
8552 t['oogonekmacron'] = 0x01ED;
8553 t['oogurmukhi'] = 0x0A13;
8554 t['oomatragurmukhi'] = 0x0A4B;
8555 t['oopen'] = 0x0254;
8556 t['oparen'] = 0x24AA;
8557 t['openbullet'] = 0x25E6;
8558 t['option'] = 0x2325;
8559 t['ordfeminine'] = 0x00AA;
8560 t['ordmasculine'] = 0x00BA;
8561 t['orthogonal'] = 0x221F;
8562 t['oshortdeva'] = 0x0912;
8563 t['oshortvowelsigndeva'] = 0x094A;
8564 t['oslash'] = 0x00F8;
8565 t['oslashacute'] = 0x01FF;
8566 t['osmallhiragana'] = 0x3049;
8567 t['osmallkatakana'] = 0x30A9;
8568 t['osmallkatakanahalfwidth'] = 0xFF6B;
8569 t['ostrokeacute'] = 0x01FF;
8570 t['osuperior'] = 0xF6F0;
8571 t['otcyrillic'] = 0x047F;
8572 t['otilde'] = 0x00F5;
8573 t['otildeacute'] = 0x1E4D;
8574 t['otildedieresis'] = 0x1E4F;
8575 t['oubopomofo'] = 0x3121;
8576 t['overline'] = 0x203E;
8577 t['overlinecenterline'] = 0xFE4A;
8578 t['overlinecmb'] = 0x0305;
8579 t['overlinedashed'] = 0xFE49;
8580 t['overlinedblwavy'] = 0xFE4C;
8581 t['overlinewavy'] = 0xFE4B;
8582 t['overscore'] = 0x00AF;
8583 t['ovowelsignbengali'] = 0x09CB;
8584 t['ovowelsigndeva'] = 0x094B;
8585 t['ovowelsigngujarati'] = 0x0ACB;
8586 t['p'] = 0x0070;
8587 t['paampssquare'] = 0x3380;
8588 t['paasentosquare'] = 0x332B;
8589 t['pabengali'] = 0x09AA;
8590 t['pacute'] = 0x1E55;
8591 t['padeva'] = 0x092A;
8592 t['pagedown'] = 0x21DF;
8593 t['pageup'] = 0x21DE;
8594 t['pagujarati'] = 0x0AAA;
8595 t['pagurmukhi'] = 0x0A2A;
8596 t['pahiragana'] = 0x3071;
8597 t['paiyannoithai'] = 0x0E2F;
8598 t['pakatakana'] = 0x30D1;
8599 t['palatalizationcyrilliccmb'] = 0x0484;
8600 t['palochkacyrillic'] = 0x04C0;
8601 t['pansioskorean'] = 0x317F;
8602 t['paragraph'] = 0x00B6;
8603 t['parallel'] = 0x2225;
8604 t['parenleft'] = 0x0028;
8605 t['parenleftaltonearabic'] = 0xFD3E;
8606 t['parenleftbt'] = 0xF8ED;
8607 t['parenleftex'] = 0xF8EC;
8608 t['parenleftinferior'] = 0x208D;
8609 t['parenleftmonospace'] = 0xFF08;
8610 t['parenleftsmall'] = 0xFE59;
8611 t['parenleftsuperior'] = 0x207D;
8612 t['parenlefttp'] = 0xF8EB;
8613 t['parenleftvertical'] = 0xFE35;
8614 t['parenright'] = 0x0029;
8615 t['parenrightaltonearabic'] = 0xFD3F;
8616 t['parenrightbt'] = 0xF8F8;
8617 t['parenrightex'] = 0xF8F7;
8618 t['parenrightinferior'] = 0x208E;
8619 t['parenrightmonospace'] = 0xFF09;
8620 t['parenrightsmall'] = 0xFE5A;
8621 t['parenrightsuperior'] = 0x207E;
8622 t['parenrighttp'] = 0xF8F6;
8623 t['parenrightvertical'] = 0xFE36;
8624 t['partialdiff'] = 0x2202;
8625 t['paseqhebrew'] = 0x05C0;
8626 t['pashtahebrew'] = 0x0599;
8627 t['pasquare'] = 0x33A9;
8628 t['patah'] = 0x05B7;
8629 t['patah11'] = 0x05B7;
8630 t['patah1d'] = 0x05B7;
8631 t['patah2a'] = 0x05B7;
8632 t['patahhebrew'] = 0x05B7;
8633 t['patahnarrowhebrew'] = 0x05B7;
8634 t['patahquarterhebrew'] = 0x05B7;
8635 t['patahwidehebrew'] = 0x05B7;
8636 t['pazerhebrew'] = 0x05A1;
8637 t['pbopomofo'] = 0x3106;
8638 t['pcircle'] = 0x24DF;
8639 t['pdotaccent'] = 0x1E57;
8640 t['pe'] = 0x05E4;
8641 t['pecyrillic'] = 0x043F;
8642 t['pedagesh'] = 0xFB44;
8643 t['pedageshhebrew'] = 0xFB44;
8644 t['peezisquare'] = 0x333B;
8645 t['pefinaldageshhebrew'] = 0xFB43;
8646 t['peharabic'] = 0x067E;
8647 t['peharmenian'] = 0x057A;
8648 t['pehebrew'] = 0x05E4;
8649 t['pehfinalarabic'] = 0xFB57;
8650 t['pehinitialarabic'] = 0xFB58;
8651 t['pehiragana'] = 0x307A;
8652 t['pehmedialarabic'] = 0xFB59;
8653 t['pekatakana'] = 0x30DA;
8654 t['pemiddlehookcyrillic'] = 0x04A7;
8655 t['perafehebrew'] = 0xFB4E;
8656 t['percent'] = 0x0025;
8657 t['percentarabic'] = 0x066A;
8658 t['percentmonospace'] = 0xFF05;
8659 t['percentsmall'] = 0xFE6A;
8660 t['period'] = 0x002E;
8661 t['periodarmenian'] = 0x0589;
8662 t['periodcentered'] = 0x00B7;
8663 t['periodhalfwidth'] = 0xFF61;
8664 t['periodinferior'] = 0xF6E7;
8665 t['periodmonospace'] = 0xFF0E;
8666 t['periodsmall'] = 0xFE52;
8667 t['periodsuperior'] = 0xF6E8;
8668 t['perispomenigreekcmb'] = 0x0342;
8669 t['perpendicular'] = 0x22A5;
8670 t['perthousand'] = 0x2030;
8671 t['peseta'] = 0x20A7;
8672 t['pfsquare'] = 0x338A;
8673 t['phabengali'] = 0x09AB;
8674 t['phadeva'] = 0x092B;
8675 t['phagujarati'] = 0x0AAB;
8676 t['phagurmukhi'] = 0x0A2B;
8677 t['phi'] = 0x03C6;
8678 t['phi1'] = 0x03D5;
8679 t['phieuphacirclekorean'] = 0x327A;
8680 t['phieuphaparenkorean'] = 0x321A;
8681 t['phieuphcirclekorean'] = 0x326C;
8682 t['phieuphkorean'] = 0x314D;
8683 t['phieuphparenkorean'] = 0x320C;
8684 t['philatin'] = 0x0278;
8685 t['phinthuthai'] = 0x0E3A;
8686 t['phisymbolgreek'] = 0x03D5;
8687 t['phook'] = 0x01A5;
8688 t['phophanthai'] = 0x0E1E;
8689 t['phophungthai'] = 0x0E1C;
8690 t['phosamphaothai'] = 0x0E20;
8691 t['pi'] = 0x03C0;
8692 t['pieupacirclekorean'] = 0x3273;
8693 t['pieupaparenkorean'] = 0x3213;
8694 t['pieupcieuckorean'] = 0x3176;
8695 t['pieupcirclekorean'] = 0x3265;
8696 t['pieupkiyeokkorean'] = 0x3172;
8697 t['pieupkorean'] = 0x3142;
8698 t['pieupparenkorean'] = 0x3205;
8699 t['pieupsioskiyeokkorean'] = 0x3174;
8700 t['pieupsioskorean'] = 0x3144;
8701 t['pieupsiostikeutkorean'] = 0x3175;
8702 t['pieupthieuthkorean'] = 0x3177;
8703 t['pieuptikeutkorean'] = 0x3173;
8704 t['pihiragana'] = 0x3074;
8705 t['pikatakana'] = 0x30D4;
8706 t['pisymbolgreek'] = 0x03D6;
8707 t['piwrarmenian'] = 0x0583;
8708 t['plus'] = 0x002B;
8709 t['plusbelowcmb'] = 0x031F;
8710 t['pluscircle'] = 0x2295;
8711 t['plusminus'] = 0x00B1;
8712 t['plusmod'] = 0x02D6;
8713 t['plusmonospace'] = 0xFF0B;
8714 t['plussmall'] = 0xFE62;
8715 t['plussuperior'] = 0x207A;
8716 t['pmonospace'] = 0xFF50;
8717 t['pmsquare'] = 0x33D8;
8718 t['pohiragana'] = 0x307D;
8719 t['pointingindexdownwhite'] = 0x261F;
8720 t['pointingindexleftwhite'] = 0x261C;
8721 t['pointingindexrightwhite'] = 0x261E;
8722 t['pointingindexupwhite'] = 0x261D;
8723 t['pokatakana'] = 0x30DD;
8724 t['poplathai'] = 0x0E1B;
8725 t['postalmark'] = 0x3012;
8726 t['postalmarkface'] = 0x3020;
8727 t['pparen'] = 0x24AB;
8728 t['precedes'] = 0x227A;
8729 t['prescription'] = 0x211E;
8730 t['primemod'] = 0x02B9;
8731 t['primereversed'] = 0x2035;
8732 t['product'] = 0x220F;
8733 t['projective'] = 0x2305;
8734 t['prolongedkana'] = 0x30FC;
8735 t['propellor'] = 0x2318;
8736 t['propersubset'] = 0x2282;
8737 t['propersuperset'] = 0x2283;
8738 t['proportion'] = 0x2237;
8739 t['proportional'] = 0x221D;
8740 t['psi'] = 0x03C8;
8741 t['psicyrillic'] = 0x0471;
8742 t['psilipneumatacyrilliccmb'] = 0x0486;
8743 t['pssquare'] = 0x33B0;
8744 t['puhiragana'] = 0x3077;
8745 t['pukatakana'] = 0x30D7;
8746 t['pvsquare'] = 0x33B4;
8747 t['pwsquare'] = 0x33BA;
8748 t['q'] = 0x0071;
8749 t['qadeva'] = 0x0958;
8750 t['qadmahebrew'] = 0x05A8;
8751 t['qafarabic'] = 0x0642;
8752 t['qaffinalarabic'] = 0xFED6;
8753 t['qafinitialarabic'] = 0xFED7;
8754 t['qafmedialarabic'] = 0xFED8;
8755 t['qamats'] = 0x05B8;
8756 t['qamats10'] = 0x05B8;
8757 t['qamats1a'] = 0x05B8;
8758 t['qamats1c'] = 0x05B8;
8759 t['qamats27'] = 0x05B8;
8760 t['qamats29'] = 0x05B8;
8761 t['qamats33'] = 0x05B8;
8762 t['qamatsde'] = 0x05B8;
8763 t['qamatshebrew'] = 0x05B8;
8764 t['qamatsnarrowhebrew'] = 0x05B8;
8765 t['qamatsqatanhebrew'] = 0x05B8;
8766 t['qamatsqatannarrowhebrew'] = 0x05B8;
8767 t['qamatsqatanquarterhebrew'] = 0x05B8;
8768 t['qamatsqatanwidehebrew'] = 0x05B8;
8769 t['qamatsquarterhebrew'] = 0x05B8;
8770 t['qamatswidehebrew'] = 0x05B8;
8771 t['qarneyparahebrew'] = 0x059F;
8772 t['qbopomofo'] = 0x3111;
8773 t['qcircle'] = 0x24E0;
8774 t['qhook'] = 0x02A0;
8775 t['qmonospace'] = 0xFF51;
8776 t['qof'] = 0x05E7;
8777 t['qofdagesh'] = 0xFB47;
8778 t['qofdageshhebrew'] = 0xFB47;
8779 t['qofhebrew'] = 0x05E7;
8780 t['qparen'] = 0x24AC;
8781 t['quarternote'] = 0x2669;
8782 t['qubuts'] = 0x05BB;
8783 t['qubuts18'] = 0x05BB;
8784 t['qubuts25'] = 0x05BB;
8785 t['qubuts31'] = 0x05BB;
8786 t['qubutshebrew'] = 0x05BB;
8787 t['qubutsnarrowhebrew'] = 0x05BB;
8788 t['qubutsquarterhebrew'] = 0x05BB;
8789 t['qubutswidehebrew'] = 0x05BB;
8790 t['question'] = 0x003F;
8791 t['questionarabic'] = 0x061F;
8792 t['questionarmenian'] = 0x055E;
8793 t['questiondown'] = 0x00BF;
8794 t['questiondownsmall'] = 0xF7BF;
8795 t['questiongreek'] = 0x037E;
8796 t['questionmonospace'] = 0xFF1F;
8797 t['questionsmall'] = 0xF73F;
8798 t['quotedbl'] = 0x0022;
8799 t['quotedblbase'] = 0x201E;
8800 t['quotedblleft'] = 0x201C;
8801 t['quotedblmonospace'] = 0xFF02;
8802 t['quotedblprime'] = 0x301E;
8803 t['quotedblprimereversed'] = 0x301D;
8804 t['quotedblright'] = 0x201D;
8805 t['quoteleft'] = 0x2018;
8806 t['quoteleftreversed'] = 0x201B;
8807 t['quotereversed'] = 0x201B;
8808 t['quoteright'] = 0x2019;
8809 t['quoterightn'] = 0x0149;
8810 t['quotesinglbase'] = 0x201A;
8811 t['quotesingle'] = 0x0027;
8812 t['quotesinglemonospace'] = 0xFF07;
8813 t['r'] = 0x0072;
8814 t['raarmenian'] = 0x057C;
8815 t['rabengali'] = 0x09B0;
8816 t['racute'] = 0x0155;
8817 t['radeva'] = 0x0930;
8818 t['radical'] = 0x221A;
8819 t['radicalex'] = 0xF8E5;
8820 t['radoverssquare'] = 0x33AE;
8821 t['radoverssquaredsquare'] = 0x33AF;
8822 t['radsquare'] = 0x33AD;
8823 t['rafe'] = 0x05BF;
8824 t['rafehebrew'] = 0x05BF;
8825 t['ragujarati'] = 0x0AB0;
8826 t['ragurmukhi'] = 0x0A30;
8827 t['rahiragana'] = 0x3089;
8828 t['rakatakana'] = 0x30E9;
8829 t['rakatakanahalfwidth'] = 0xFF97;
8830 t['ralowerdiagonalbengali'] = 0x09F1;
8831 t['ramiddlediagonalbengali'] = 0x09F0;
8832 t['ramshorn'] = 0x0264;
8833 t['ratio'] = 0x2236;
8834 t['rbopomofo'] = 0x3116;
8835 t['rcaron'] = 0x0159;
8836 t['rcedilla'] = 0x0157;
8837 t['rcircle'] = 0x24E1;
8838 t['rcommaaccent'] = 0x0157;
8839 t['rdblgrave'] = 0x0211;
8840 t['rdotaccent'] = 0x1E59;
8841 t['rdotbelow'] = 0x1E5B;
8842 t['rdotbelowmacron'] = 0x1E5D;
8843 t['referencemark'] = 0x203B;
8844 t['reflexsubset'] = 0x2286;
8845 t['reflexsuperset'] = 0x2287;
8846 t['registered'] = 0x00AE;
8847 t['registersans'] = 0xF8E8;
8848 t['registerserif'] = 0xF6DA;
8849 t['reharabic'] = 0x0631;
8850 t['reharmenian'] = 0x0580;
8851 t['rehfinalarabic'] = 0xFEAE;
8852 t['rehiragana'] = 0x308C;
8853 t['rekatakana'] = 0x30EC;
8854 t['rekatakanahalfwidth'] = 0xFF9A;
8855 t['resh'] = 0x05E8;
8856 t['reshdageshhebrew'] = 0xFB48;
8857 t['reshhebrew'] = 0x05E8;
8858 t['reversedtilde'] = 0x223D;
8859 t['reviahebrew'] = 0x0597;
8860 t['reviamugrashhebrew'] = 0x0597;
8861 t['revlogicalnot'] = 0x2310;
8862 t['rfishhook'] = 0x027E;
8863 t['rfishhookreversed'] = 0x027F;
8864 t['rhabengali'] = 0x09DD;
8865 t['rhadeva'] = 0x095D;
8866 t['rho'] = 0x03C1;
8867 t['rhook'] = 0x027D;
8868 t['rhookturned'] = 0x027B;
8869 t['rhookturnedsuperior'] = 0x02B5;
8870 t['rhosymbolgreek'] = 0x03F1;
8871 t['rhotichookmod'] = 0x02DE;
8872 t['rieulacirclekorean'] = 0x3271;
8873 t['rieulaparenkorean'] = 0x3211;
8874 t['rieulcirclekorean'] = 0x3263;
8875 t['rieulhieuhkorean'] = 0x3140;
8876 t['rieulkiyeokkorean'] = 0x313A;
8877 t['rieulkiyeoksioskorean'] = 0x3169;
8878 t['rieulkorean'] = 0x3139;
8879 t['rieulmieumkorean'] = 0x313B;
8880 t['rieulpansioskorean'] = 0x316C;
8881 t['rieulparenkorean'] = 0x3203;
8882 t['rieulphieuphkorean'] = 0x313F;
8883 t['rieulpieupkorean'] = 0x313C;
8884 t['rieulpieupsioskorean'] = 0x316B;
8885 t['rieulsioskorean'] = 0x313D;
8886 t['rieulthieuthkorean'] = 0x313E;
8887 t['rieultikeutkorean'] = 0x316A;
8888 t['rieulyeorinhieuhkorean'] = 0x316D;
8889 t['rightangle'] = 0x221F;
8890 t['righttackbelowcmb'] = 0x0319;
8891 t['righttriangle'] = 0x22BF;
8892 t['rihiragana'] = 0x308A;
8893 t['rikatakana'] = 0x30EA;
8894 t['rikatakanahalfwidth'] = 0xFF98;
8895 t['ring'] = 0x02DA;
8896 t['ringbelowcmb'] = 0x0325;
8897 t['ringcmb'] = 0x030A;
8898 t['ringhalfleft'] = 0x02BF;
8899 t['ringhalfleftarmenian'] = 0x0559;
8900 t['ringhalfleftbelowcmb'] = 0x031C;
8901 t['ringhalfleftcentered'] = 0x02D3;
8902 t['ringhalfright'] = 0x02BE;
8903 t['ringhalfrightbelowcmb'] = 0x0339;
8904 t['ringhalfrightcentered'] = 0x02D2;
8905 t['rinvertedbreve'] = 0x0213;
8906 t['rittorusquare'] = 0x3351;
8907 t['rlinebelow'] = 0x1E5F;
8908 t['rlongleg'] = 0x027C;
8909 t['rlonglegturned'] = 0x027A;
8910 t['rmonospace'] = 0xFF52;
8911 t['rohiragana'] = 0x308D;
8912 t['rokatakana'] = 0x30ED;
8913 t['rokatakanahalfwidth'] = 0xFF9B;
8914 t['roruathai'] = 0x0E23;
8915 t['rparen'] = 0x24AD;
8916 t['rrabengali'] = 0x09DC;
8917 t['rradeva'] = 0x0931;
8918 t['rragurmukhi'] = 0x0A5C;
8919 t['rreharabic'] = 0x0691;
8920 t['rrehfinalarabic'] = 0xFB8D;
8921 t['rrvocalicbengali'] = 0x09E0;
8922 t['rrvocalicdeva'] = 0x0960;
8923 t['rrvocalicgujarati'] = 0x0AE0;
8924 t['rrvocalicvowelsignbengali'] = 0x09C4;
8925 t['rrvocalicvowelsigndeva'] = 0x0944;
8926 t['rrvocalicvowelsigngujarati'] = 0x0AC4;
8927 t['rsuperior'] = 0xF6F1;
8928 t['rtblock'] = 0x2590;
8929 t['rturned'] = 0x0279;
8930 t['rturnedsuperior'] = 0x02B4;
8931 t['ruhiragana'] = 0x308B;
8932 t['rukatakana'] = 0x30EB;
8933 t['rukatakanahalfwidth'] = 0xFF99;
8934 t['rupeemarkbengali'] = 0x09F2;
8935 t['rupeesignbengali'] = 0x09F3;
8936 t['rupiah'] = 0xF6DD;
8937 t['ruthai'] = 0x0E24;
8938 t['rvocalicbengali'] = 0x098B;
8939 t['rvocalicdeva'] = 0x090B;
8940 t['rvocalicgujarati'] = 0x0A8B;
8941 t['rvocalicvowelsignbengali'] = 0x09C3;
8942 t['rvocalicvowelsigndeva'] = 0x0943;
8943 t['rvocalicvowelsigngujarati'] = 0x0AC3;
8944 t['s'] = 0x0073;
8945 t['sabengali'] = 0x09B8;
8946 t['sacute'] = 0x015B;
8947 t['sacutedotaccent'] = 0x1E65;
8948 t['sadarabic'] = 0x0635;
8949 t['sadeva'] = 0x0938;
8950 t['sadfinalarabic'] = 0xFEBA;
8951 t['sadinitialarabic'] = 0xFEBB;
8952 t['sadmedialarabic'] = 0xFEBC;
8953 t['sagujarati'] = 0x0AB8;
8954 t['sagurmukhi'] = 0x0A38;
8955 t['sahiragana'] = 0x3055;
8956 t['sakatakana'] = 0x30B5;
8957 t['sakatakanahalfwidth'] = 0xFF7B;
8958 t['sallallahoualayhewasallamarabic'] = 0xFDFA;
8959 t['samekh'] = 0x05E1;
8960 t['samekhdagesh'] = 0xFB41;
8961 t['samekhdageshhebrew'] = 0xFB41;
8962 t['samekhhebrew'] = 0x05E1;
8963 t['saraaathai'] = 0x0E32;
8964 t['saraaethai'] = 0x0E41;
8965 t['saraaimaimalaithai'] = 0x0E44;
8966 t['saraaimaimuanthai'] = 0x0E43;
8967 t['saraamthai'] = 0x0E33;
8968 t['saraathai'] = 0x0E30;
8969 t['saraethai'] = 0x0E40;
8970 t['saraiileftthai'] = 0xF886;
8971 t['saraiithai'] = 0x0E35;
8972 t['saraileftthai'] = 0xF885;
8973 t['saraithai'] = 0x0E34;
8974 t['saraothai'] = 0x0E42;
8975 t['saraueeleftthai'] = 0xF888;
8976 t['saraueethai'] = 0x0E37;
8977 t['saraueleftthai'] = 0xF887;
8978 t['sarauethai'] = 0x0E36;
8979 t['sarauthai'] = 0x0E38;
8980 t['sarauuthai'] = 0x0E39;
8981 t['sbopomofo'] = 0x3119;
8982 t['scaron'] = 0x0161;
8983 t['scarondotaccent'] = 0x1E67;
8984 t['scedilla'] = 0x015F;
8985 t['schwa'] = 0x0259;
8986 t['schwacyrillic'] = 0x04D9;
8987 t['schwadieresiscyrillic'] = 0x04DB;
8988 t['schwahook'] = 0x025A;
8989 t['scircle'] = 0x24E2;
8990 t['scircumflex'] = 0x015D;
8991 t['scommaaccent'] = 0x0219;
8992 t['sdotaccent'] = 0x1E61;
8993 t['sdotbelow'] = 0x1E63;
8994 t['sdotbelowdotaccent'] = 0x1E69;
8995 t['seagullbelowcmb'] = 0x033C;
8996 t['second'] = 0x2033;
8997 t['secondtonechinese'] = 0x02CA;
8998 t['section'] = 0x00A7;
8999 t['seenarabic'] = 0x0633;
9000 t['seenfinalarabic'] = 0xFEB2;
9001 t['seeninitialarabic'] = 0xFEB3;
9002 t['seenmedialarabic'] = 0xFEB4;
9003 t['segol'] = 0x05B6;
9004 t['segol13'] = 0x05B6;
9005 t['segol1f'] = 0x05B6;
9006 t['segol2c'] = 0x05B6;
9007 t['segolhebrew'] = 0x05B6;
9008 t['segolnarrowhebrew'] = 0x05B6;
9009 t['segolquarterhebrew'] = 0x05B6;
9010 t['segoltahebrew'] = 0x0592;
9011 t['segolwidehebrew'] = 0x05B6;
9012 t['seharmenian'] = 0x057D;
9013 t['sehiragana'] = 0x305B;
9014 t['sekatakana'] = 0x30BB;
9015 t['sekatakanahalfwidth'] = 0xFF7E;
9016 t['semicolon'] = 0x003B;
9017 t['semicolonarabic'] = 0x061B;
9018 t['semicolonmonospace'] = 0xFF1B;
9019 t['semicolonsmall'] = 0xFE54;
9020 t['semivoicedmarkkana'] = 0x309C;
9021 t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
9022 t['sentisquare'] = 0x3322;
9023 t['sentosquare'] = 0x3323;
9024 t['seven'] = 0x0037;
9025 t['sevenarabic'] = 0x0667;
9026 t['sevenbengali'] = 0x09ED;
9027 t['sevencircle'] = 0x2466;
9028 t['sevencircleinversesansserif'] = 0x2790;
9029 t['sevendeva'] = 0x096D;
9030 t['seveneighths'] = 0x215E;
9031 t['sevengujarati'] = 0x0AED;
9032 t['sevengurmukhi'] = 0x0A6D;
9033 t['sevenhackarabic'] = 0x0667;
9034 t['sevenhangzhou'] = 0x3027;
9035 t['sevenideographicparen'] = 0x3226;
9036 t['seveninferior'] = 0x2087;
9037 t['sevenmonospace'] = 0xFF17;
9038 t['sevenoldstyle'] = 0xF737;
9039 t['sevenparen'] = 0x247A;
9040 t['sevenperiod'] = 0x248E;
9041 t['sevenpersian'] = 0x06F7;
9042 t['sevenroman'] = 0x2176;
9043 t['sevensuperior'] = 0x2077;
9044 t['seventeencircle'] = 0x2470;
9045 t['seventeenparen'] = 0x2484;
9046 t['seventeenperiod'] = 0x2498;
9047 t['seventhai'] = 0x0E57;
9048 t['sfthyphen'] = 0x00AD;
9049 t['shaarmenian'] = 0x0577;
9050 t['shabengali'] = 0x09B6;
9051 t['shacyrillic'] = 0x0448;
9052 t['shaddaarabic'] = 0x0651;
9053 t['shaddadammaarabic'] = 0xFC61;
9054 t['shaddadammatanarabic'] = 0xFC5E;
9055 t['shaddafathaarabic'] = 0xFC60;
9056 t['shaddakasraarabic'] = 0xFC62;
9057 t['shaddakasratanarabic'] = 0xFC5F;
9058 t['shade'] = 0x2592;
9059 t['shadedark'] = 0x2593;
9060 t['shadelight'] = 0x2591;
9061 t['shademedium'] = 0x2592;
9062 t['shadeva'] = 0x0936;
9063 t['shagujarati'] = 0x0AB6;
9064 t['shagurmukhi'] = 0x0A36;
9065 t['shalshelethebrew'] = 0x0593;
9066 t['shbopomofo'] = 0x3115;
9067 t['shchacyrillic'] = 0x0449;
9068 t['sheenarabic'] = 0x0634;
9069 t['sheenfinalarabic'] = 0xFEB6;
9070 t['sheeninitialarabic'] = 0xFEB7;
9071 t['sheenmedialarabic'] = 0xFEB8;
9072 t['sheicoptic'] = 0x03E3;
9073 t['sheqel'] = 0x20AA;
9074 t['sheqelhebrew'] = 0x20AA;
9075 t['sheva'] = 0x05B0;
9076 t['sheva115'] = 0x05B0;
9077 t['sheva15'] = 0x05B0;
9078 t['sheva22'] = 0x05B0;
9079 t['sheva2e'] = 0x05B0;
9080 t['shevahebrew'] = 0x05B0;
9081 t['shevanarrowhebrew'] = 0x05B0;
9082 t['shevaquarterhebrew'] = 0x05B0;
9083 t['shevawidehebrew'] = 0x05B0;
9084 t['shhacyrillic'] = 0x04BB;
9085 t['shimacoptic'] = 0x03ED;
9086 t['shin'] = 0x05E9;
9087 t['shindagesh'] = 0xFB49;
9088 t['shindageshhebrew'] = 0xFB49;
9089 t['shindageshshindot'] = 0xFB2C;
9090 t['shindageshshindothebrew'] = 0xFB2C;
9091 t['shindageshsindot'] = 0xFB2D;
9092 t['shindageshsindothebrew'] = 0xFB2D;
9093 t['shindothebrew'] = 0x05C1;
9094 t['shinhebrew'] = 0x05E9;
9095 t['shinshindot'] = 0xFB2A;
9096 t['shinshindothebrew'] = 0xFB2A;
9097 t['shinsindot'] = 0xFB2B;
9098 t['shinsindothebrew'] = 0xFB2B;
9099 t['shook'] = 0x0282;
9100 t['sigma'] = 0x03C3;
9101 t['sigma1'] = 0x03C2;
9102 t['sigmafinal'] = 0x03C2;
9103 t['sigmalunatesymbolgreek'] = 0x03F2;
9104 t['sihiragana'] = 0x3057;
9105 t['sikatakana'] = 0x30B7;
9106 t['sikatakanahalfwidth'] = 0xFF7C;
9107 t['siluqhebrew'] = 0x05BD;
9108 t['siluqlefthebrew'] = 0x05BD;
9109 t['similar'] = 0x223C;
9110 t['sindothebrew'] = 0x05C2;
9111 t['siosacirclekorean'] = 0x3274;
9112 t['siosaparenkorean'] = 0x3214;
9113 t['sioscieuckorean'] = 0x317E;
9114 t['sioscirclekorean'] = 0x3266;
9115 t['sioskiyeokkorean'] = 0x317A;
9116 t['sioskorean'] = 0x3145;
9117 t['siosnieunkorean'] = 0x317B;
9118 t['siosparenkorean'] = 0x3206;
9119 t['siospieupkorean'] = 0x317D;
9120 t['siostikeutkorean'] = 0x317C;
9121 t['six'] = 0x0036;
9122 t['sixarabic'] = 0x0666;
9123 t['sixbengali'] = 0x09EC;
9124 t['sixcircle'] = 0x2465;
9125 t['sixcircleinversesansserif'] = 0x278F;
9126 t['sixdeva'] = 0x096C;
9127 t['sixgujarati'] = 0x0AEC;
9128 t['sixgurmukhi'] = 0x0A6C;
9129 t['sixhackarabic'] = 0x0666;
9130 t['sixhangzhou'] = 0x3026;
9131 t['sixideographicparen'] = 0x3225;
9132 t['sixinferior'] = 0x2086;
9133 t['sixmonospace'] = 0xFF16;
9134 t['sixoldstyle'] = 0xF736;
9135 t['sixparen'] = 0x2479;
9136 t['sixperiod'] = 0x248D;
9137 t['sixpersian'] = 0x06F6;
9138 t['sixroman'] = 0x2175;
9139 t['sixsuperior'] = 0x2076;
9140 t['sixteencircle'] = 0x246F;
9141 t['sixteencurrencydenominatorbengali'] = 0x09F9;
9142 t['sixteenparen'] = 0x2483;
9143 t['sixteenperiod'] = 0x2497;
9144 t['sixthai'] = 0x0E56;
9145 t['slash'] = 0x002F;
9146 t['slashmonospace'] = 0xFF0F;
9147 t['slong'] = 0x017F;
9148 t['slongdotaccent'] = 0x1E9B;
9149 t['smileface'] = 0x263A;
9150 t['smonospace'] = 0xFF53;
9151 t['sofpasuqhebrew'] = 0x05C3;
9152 t['softhyphen'] = 0x00AD;
9153 t['softsigncyrillic'] = 0x044C;
9154 t['sohiragana'] = 0x305D;
9155 t['sokatakana'] = 0x30BD;
9156 t['sokatakanahalfwidth'] = 0xFF7F;
9157 t['soliduslongoverlaycmb'] = 0x0338;
9158 t['solidusshortoverlaycmb'] = 0x0337;
9159 t['sorusithai'] = 0x0E29;
9160 t['sosalathai'] = 0x0E28;
9161 t['sosothai'] = 0x0E0B;
9162 t['sosuathai'] = 0x0E2A;
9163 t['space'] = 0x0020;
9164 t['spacehackarabic'] = 0x0020;
9165 t['spade'] = 0x2660;
9166 t['spadesuitblack'] = 0x2660;
9167 t['spadesuitwhite'] = 0x2664;
9168 t['sparen'] = 0x24AE;
9169 t['squarebelowcmb'] = 0x033B;
9170 t['squarecc'] = 0x33C4;
9171 t['squarecm'] = 0x339D;
9172 t['squarediagonalcrosshatchfill'] = 0x25A9;
9173 t['squarehorizontalfill'] = 0x25A4;
9174 t['squarekg'] = 0x338F;
9175 t['squarekm'] = 0x339E;
9176 t['squarekmcapital'] = 0x33CE;
9177 t['squareln'] = 0x33D1;
9178 t['squarelog'] = 0x33D2;
9179 t['squaremg'] = 0x338E;
9180 t['squaremil'] = 0x33D5;
9181 t['squaremm'] = 0x339C;
9182 t['squaremsquared'] = 0x33A1;
9183 t['squareorthogonalcrosshatchfill'] = 0x25A6;
9184 t['squareupperlefttolowerrightfill'] = 0x25A7;
9185 t['squareupperrighttolowerleftfill'] = 0x25A8;
9186 t['squareverticalfill'] = 0x25A5;
9187 t['squarewhitewithsmallblack'] = 0x25A3;
9188 t['srsquare'] = 0x33DB;
9189 t['ssabengali'] = 0x09B7;
9190 t['ssadeva'] = 0x0937;
9191 t['ssagujarati'] = 0x0AB7;
9192 t['ssangcieuckorean'] = 0x3149;
9193 t['ssanghieuhkorean'] = 0x3185;
9194 t['ssangieungkorean'] = 0x3180;
9195 t['ssangkiyeokkorean'] = 0x3132;
9196 t['ssangnieunkorean'] = 0x3165;
9197 t['ssangpieupkorean'] = 0x3143;
9198 t['ssangsioskorean'] = 0x3146;
9199 t['ssangtikeutkorean'] = 0x3138;
9200 t['ssuperior'] = 0xF6F2;
9201 t['sterling'] = 0x00A3;
9202 t['sterlingmonospace'] = 0xFFE1;
9203 t['strokelongoverlaycmb'] = 0x0336;
9204 t['strokeshortoverlaycmb'] = 0x0335;
9205 t['subset'] = 0x2282;
9206 t['subsetnotequal'] = 0x228A;
9207 t['subsetorequal'] = 0x2286;
9208 t['succeeds'] = 0x227B;
9209 t['suchthat'] = 0x220B;
9210 t['suhiragana'] = 0x3059;
9211 t['sukatakana'] = 0x30B9;
9212 t['sukatakanahalfwidth'] = 0xFF7D;
9213 t['sukunarabic'] = 0x0652;
9214 t['summation'] = 0x2211;
9215 t['sun'] = 0x263C;
9216 t['superset'] = 0x2283;
9217 t['supersetnotequal'] = 0x228B;
9218 t['supersetorequal'] = 0x2287;
9219 t['svsquare'] = 0x33DC;
9220 t['syouwaerasquare'] = 0x337C;
9221 t['t'] = 0x0074;
9222 t['tabengali'] = 0x09A4;
9223 t['tackdown'] = 0x22A4;
9224 t['tackleft'] = 0x22A3;
9225 t['tadeva'] = 0x0924;
9226 t['tagujarati'] = 0x0AA4;
9227 t['tagurmukhi'] = 0x0A24;
9228 t['taharabic'] = 0x0637;
9229 t['tahfinalarabic'] = 0xFEC2;
9230 t['tahinitialarabic'] = 0xFEC3;
9231 t['tahiragana'] = 0x305F;
9232 t['tahmedialarabic'] = 0xFEC4;
9233 t['taisyouerasquare'] = 0x337D;
9234 t['takatakana'] = 0x30BF;
9235 t['takatakanahalfwidth'] = 0xFF80;
9236 t['tatweelarabic'] = 0x0640;
9237 t['tau'] = 0x03C4;
9238 t['tav'] = 0x05EA;
9239 t['tavdages'] = 0xFB4A;
9240 t['tavdagesh'] = 0xFB4A;
9241 t['tavdageshhebrew'] = 0xFB4A;
9242 t['tavhebrew'] = 0x05EA;
9243 t['tbar'] = 0x0167;
9244 t['tbopomofo'] = 0x310A;
9245 t['tcaron'] = 0x0165;
9246 t['tccurl'] = 0x02A8;
9247 t['tcedilla'] = 0x0163;
9248 t['tcheharabic'] = 0x0686;
9249 t['tchehfinalarabic'] = 0xFB7B;
9250 t['tchehinitialarabic'] = 0xFB7C;
9251 t['tchehmedialarabic'] = 0xFB7D;
9252 t['tcircle'] = 0x24E3;
9253 t['tcircumflexbelow'] = 0x1E71;
9254 t['tcommaaccent'] = 0x0163;
9255 t['tdieresis'] = 0x1E97;
9256 t['tdotaccent'] = 0x1E6B;
9257 t['tdotbelow'] = 0x1E6D;
9258 t['tecyrillic'] = 0x0442;
9259 t['tedescendercyrillic'] = 0x04AD;
9260 t['teharabic'] = 0x062A;
9261 t['tehfinalarabic'] = 0xFE96;
9262 t['tehhahinitialarabic'] = 0xFCA2;
9263 t['tehhahisolatedarabic'] = 0xFC0C;
9264 t['tehinitialarabic'] = 0xFE97;
9265 t['tehiragana'] = 0x3066;
9266 t['tehjeeminitialarabic'] = 0xFCA1;
9267 t['tehjeemisolatedarabic'] = 0xFC0B;
9268 t['tehmarbutaarabic'] = 0x0629;
9269 t['tehmarbutafinalarabic'] = 0xFE94;
9270 t['tehmedialarabic'] = 0xFE98;
9271 t['tehmeeminitialarabic'] = 0xFCA4;
9272 t['tehmeemisolatedarabic'] = 0xFC0E;
9273 t['tehnoonfinalarabic'] = 0xFC73;
9274 t['tekatakana'] = 0x30C6;
9275 t['tekatakanahalfwidth'] = 0xFF83;
9276 t['telephone'] = 0x2121;
9277 t['telephoneblack'] = 0x260E;
9278 t['telishagedolahebrew'] = 0x05A0;
9279 t['telishaqetanahebrew'] = 0x05A9;
9280 t['tencircle'] = 0x2469;
9281 t['tenideographicparen'] = 0x3229;
9282 t['tenparen'] = 0x247D;
9283 t['tenperiod'] = 0x2491;
9284 t['tenroman'] = 0x2179;
9285 t['tesh'] = 0x02A7;
9286 t['tet'] = 0x05D8;
9287 t['tetdagesh'] = 0xFB38;
9288 t['tetdageshhebrew'] = 0xFB38;
9289 t['tethebrew'] = 0x05D8;
9290 t['tetsecyrillic'] = 0x04B5;
9291 t['tevirhebrew'] = 0x059B;
9292 t['tevirlefthebrew'] = 0x059B;
9293 t['thabengali'] = 0x09A5;
9294 t['thadeva'] = 0x0925;
9295 t['thagujarati'] = 0x0AA5;
9296 t['thagurmukhi'] = 0x0A25;
9297 t['thalarabic'] = 0x0630;
9298 t['thalfinalarabic'] = 0xFEAC;
9299 t['thanthakhatlowleftthai'] = 0xF898;
9300 t['thanthakhatlowrightthai'] = 0xF897;
9301 t['thanthakhatthai'] = 0x0E4C;
9302 t['thanthakhatupperleftthai'] = 0xF896;
9303 t['theharabic'] = 0x062B;
9304 t['thehfinalarabic'] = 0xFE9A;
9305 t['thehinitialarabic'] = 0xFE9B;
9306 t['thehmedialarabic'] = 0xFE9C;
9307 t['thereexists'] = 0x2203;
9308 t['therefore'] = 0x2234;
9309 t['theta'] = 0x03B8;
9310 t['theta1'] = 0x03D1;
9311 t['thetasymbolgreek'] = 0x03D1;
9312 t['thieuthacirclekorean'] = 0x3279;
9313 t['thieuthaparenkorean'] = 0x3219;
9314 t['thieuthcirclekorean'] = 0x326B;
9315 t['thieuthkorean'] = 0x314C;
9316 t['thieuthparenkorean'] = 0x320B;
9317 t['thirteencircle'] = 0x246C;
9318 t['thirteenparen'] = 0x2480;
9319 t['thirteenperiod'] = 0x2494;
9320 t['thonangmonthothai'] = 0x0E11;
9321 t['thook'] = 0x01AD;
9322 t['thophuthaothai'] = 0x0E12;
9323 t['thorn'] = 0x00FE;
9324 t['thothahanthai'] = 0x0E17;
9325 t['thothanthai'] = 0x0E10;
9326 t['thothongthai'] = 0x0E18;
9327 t['thothungthai'] = 0x0E16;
9328 t['thousandcyrillic'] = 0x0482;
9329 t['thousandsseparatorarabic'] = 0x066C;
9330 t['thousandsseparatorpersian'] = 0x066C;
9331 t['three'] = 0x0033;
9332 t['threearabic'] = 0x0663;
9333 t['threebengali'] = 0x09E9;
9334 t['threecircle'] = 0x2462;
9335 t['threecircleinversesansserif'] = 0x278C;
9336 t['threedeva'] = 0x0969;
9337 t['threeeighths'] = 0x215C;
9338 t['threegujarati'] = 0x0AE9;
9339 t['threegurmukhi'] = 0x0A69;
9340 t['threehackarabic'] = 0x0663;
9341 t['threehangzhou'] = 0x3023;
9342 t['threeideographicparen'] = 0x3222;
9343 t['threeinferior'] = 0x2083;
9344 t['threemonospace'] = 0xFF13;
9345 t['threenumeratorbengali'] = 0x09F6;
9346 t['threeoldstyle'] = 0xF733;
9347 t['threeparen'] = 0x2476;
9348 t['threeperiod'] = 0x248A;
9349 t['threepersian'] = 0x06F3;
9350 t['threequarters'] = 0x00BE;
9351 t['threequartersemdash'] = 0xF6DE;
9352 t['threeroman'] = 0x2172;
9353 t['threesuperior'] = 0x00B3;
9354 t['threethai'] = 0x0E53;
9355 t['thzsquare'] = 0x3394;
9356 t['tihiragana'] = 0x3061;
9357 t['tikatakana'] = 0x30C1;
9358 t['tikatakanahalfwidth'] = 0xFF81;
9359 t['tikeutacirclekorean'] = 0x3270;
9360 t['tikeutaparenkorean'] = 0x3210;
9361 t['tikeutcirclekorean'] = 0x3262;
9362 t['tikeutkorean'] = 0x3137;
9363 t['tikeutparenkorean'] = 0x3202;
9364 t['tilde'] = 0x02DC;
9365 t['tildebelowcmb'] = 0x0330;
9366 t['tildecmb'] = 0x0303;
9367 t['tildecomb'] = 0x0303;
9368 t['tildedoublecmb'] = 0x0360;
9369 t['tildeoperator'] = 0x223C;
9370 t['tildeoverlaycmb'] = 0x0334;
9371 t['tildeverticalcmb'] = 0x033E;
9372 t['timescircle'] = 0x2297;
9373 t['tipehahebrew'] = 0x0596;
9374 t['tipehalefthebrew'] = 0x0596;
9375 t['tippigurmukhi'] = 0x0A70;
9376 t['titlocyrilliccmb'] = 0x0483;
9377 t['tiwnarmenian'] = 0x057F;
9378 t['tlinebelow'] = 0x1E6F;
9379 t['tmonospace'] = 0xFF54;
9380 t['toarmenian'] = 0x0569;
9381 t['tohiragana'] = 0x3068;
9382 t['tokatakana'] = 0x30C8;
9383 t['tokatakanahalfwidth'] = 0xFF84;
9384 t['tonebarextrahighmod'] = 0x02E5;
9385 t['tonebarextralowmod'] = 0x02E9;
9386 t['tonebarhighmod'] = 0x02E6;
9387 t['tonebarlowmod'] = 0x02E8;
9388 t['tonebarmidmod'] = 0x02E7;
9389 t['tonefive'] = 0x01BD;
9390 t['tonesix'] = 0x0185;
9391 t['tonetwo'] = 0x01A8;
9392 t['tonos'] = 0x0384;
9393 t['tonsquare'] = 0x3327;
9394 t['topatakthai'] = 0x0E0F;
9395 t['tortoiseshellbracketleft'] = 0x3014;
9396 t['tortoiseshellbracketleftsmall'] = 0xFE5D;
9397 t['tortoiseshellbracketleftvertical'] = 0xFE39;
9398 t['tortoiseshellbracketright'] = 0x3015;
9399 t['tortoiseshellbracketrightsmall'] = 0xFE5E;
9400 t['tortoiseshellbracketrightvertical'] = 0xFE3A;
9401 t['totaothai'] = 0x0E15;
9402 t['tpalatalhook'] = 0x01AB;
9403 t['tparen'] = 0x24AF;
9404 t['trademark'] = 0x2122;
9405 t['trademarksans'] = 0xF8EA;
9406 t['trademarkserif'] = 0xF6DB;
9407 t['tretroflexhook'] = 0x0288;
9408 t['triagdn'] = 0x25BC;
9409 t['triaglf'] = 0x25C4;
9410 t['triagrt'] = 0x25BA;
9411 t['triagup'] = 0x25B2;
9412 t['ts'] = 0x02A6;
9413 t['tsadi'] = 0x05E6;
9414 t['tsadidagesh'] = 0xFB46;
9415 t['tsadidageshhebrew'] = 0xFB46;
9416 t['tsadihebrew'] = 0x05E6;
9417 t['tsecyrillic'] = 0x0446;
9418 t['tsere'] = 0x05B5;
9419 t['tsere12'] = 0x05B5;
9420 t['tsere1e'] = 0x05B5;
9421 t['tsere2b'] = 0x05B5;
9422 t['tserehebrew'] = 0x05B5;
9423 t['tserenarrowhebrew'] = 0x05B5;
9424 t['tserequarterhebrew'] = 0x05B5;
9425 t['tserewidehebrew'] = 0x05B5;
9426 t['tshecyrillic'] = 0x045B;
9427 t['tsuperior'] = 0xF6F3;
9428 t['ttabengali'] = 0x099F;
9429 t['ttadeva'] = 0x091F;
9430 t['ttagujarati'] = 0x0A9F;
9431 t['ttagurmukhi'] = 0x0A1F;
9432 t['tteharabic'] = 0x0679;
9433 t['ttehfinalarabic'] = 0xFB67;
9434 t['ttehinitialarabic'] = 0xFB68;
9435 t['ttehmedialarabic'] = 0xFB69;
9436 t['tthabengali'] = 0x09A0;
9437 t['tthadeva'] = 0x0920;
9438 t['tthagujarati'] = 0x0AA0;
9439 t['tthagurmukhi'] = 0x0A20;
9440 t['tturned'] = 0x0287;
9441 t['tuhiragana'] = 0x3064;
9442 t['tukatakana'] = 0x30C4;
9443 t['tukatakanahalfwidth'] = 0xFF82;
9444 t['tusmallhiragana'] = 0x3063;
9445 t['tusmallkatakana'] = 0x30C3;
9446 t['tusmallkatakanahalfwidth'] = 0xFF6F;
9447 t['twelvecircle'] = 0x246B;
9448 t['twelveparen'] = 0x247F;
9449 t['twelveperiod'] = 0x2493;
9450 t['twelveroman'] = 0x217B;
9451 t['twentycircle'] = 0x2473;
9452 t['twentyhangzhou'] = 0x5344;
9453 t['twentyparen'] = 0x2487;
9454 t['twentyperiod'] = 0x249B;
9455 t['two'] = 0x0032;
9456 t['twoarabic'] = 0x0662;
9457 t['twobengali'] = 0x09E8;
9458 t['twocircle'] = 0x2461;
9459 t['twocircleinversesansserif'] = 0x278B;
9460 t['twodeva'] = 0x0968;
9461 t['twodotenleader'] = 0x2025;
9462 t['twodotleader'] = 0x2025;
9463 t['twodotleadervertical'] = 0xFE30;
9464 t['twogujarati'] = 0x0AE8;
9465 t['twogurmukhi'] = 0x0A68;
9466 t['twohackarabic'] = 0x0662;
9467 t['twohangzhou'] = 0x3022;
9468 t['twoideographicparen'] = 0x3221;
9469 t['twoinferior'] = 0x2082;
9470 t['twomonospace'] = 0xFF12;
9471 t['twonumeratorbengali'] = 0x09F5;
9472 t['twooldstyle'] = 0xF732;
9473 t['twoparen'] = 0x2475;
9474 t['twoperiod'] = 0x2489;
9475 t['twopersian'] = 0x06F2;
9476 t['tworoman'] = 0x2171;
9477 t['twostroke'] = 0x01BB;
9478 t['twosuperior'] = 0x00B2;
9479 t['twothai'] = 0x0E52;
9480 t['twothirds'] = 0x2154;
9481 t['u'] = 0x0075;
9482 t['uacute'] = 0x00FA;
9483 t['ubar'] = 0x0289;
9484 t['ubengali'] = 0x0989;
9485 t['ubopomofo'] = 0x3128;
9486 t['ubreve'] = 0x016D;
9487 t['ucaron'] = 0x01D4;
9488 t['ucircle'] = 0x24E4;
9489 t['ucircumflex'] = 0x00FB;
9490 t['ucircumflexbelow'] = 0x1E77;
9491 t['ucyrillic'] = 0x0443;
9492 t['udattadeva'] = 0x0951;
9493 t['udblacute'] = 0x0171;
9494 t['udblgrave'] = 0x0215;
9495 t['udeva'] = 0x0909;
9496 t['udieresis'] = 0x00FC;
9497 t['udieresisacute'] = 0x01D8;
9498 t['udieresisbelow'] = 0x1E73;
9499 t['udieresiscaron'] = 0x01DA;
9500 t['udieresiscyrillic'] = 0x04F1;
9501 t['udieresisgrave'] = 0x01DC;
9502 t['udieresismacron'] = 0x01D6;
9503 t['udotbelow'] = 0x1EE5;
9504 t['ugrave'] = 0x00F9;
9505 t['ugujarati'] = 0x0A89;
9506 t['ugurmukhi'] = 0x0A09;
9507 t['uhiragana'] = 0x3046;
9508 t['uhookabove'] = 0x1EE7;
9509 t['uhorn'] = 0x01B0;
9510 t['uhornacute'] = 0x1EE9;
9511 t['uhorndotbelow'] = 0x1EF1;
9512 t['uhorngrave'] = 0x1EEB;
9513 t['uhornhookabove'] = 0x1EED;
9514 t['uhorntilde'] = 0x1EEF;
9515 t['uhungarumlaut'] = 0x0171;
9516 t['uhungarumlautcyrillic'] = 0x04F3;
9517 t['uinvertedbreve'] = 0x0217;
9518 t['ukatakana'] = 0x30A6;
9519 t['ukatakanahalfwidth'] = 0xFF73;
9520 t['ukcyrillic'] = 0x0479;
9521 t['ukorean'] = 0x315C;
9522 t['umacron'] = 0x016B;
9523 t['umacroncyrillic'] = 0x04EF;
9524 t['umacrondieresis'] = 0x1E7B;
9525 t['umatragurmukhi'] = 0x0A41;
9526 t['umonospace'] = 0xFF55;
9527 t['underscore'] = 0x005F;
9528 t['underscoredbl'] = 0x2017;
9529 t['underscoremonospace'] = 0xFF3F;
9530 t['underscorevertical'] = 0xFE33;
9531 t['underscorewavy'] = 0xFE4F;
9532 t['union'] = 0x222A;
9533 t['universal'] = 0x2200;
9534 t['uogonek'] = 0x0173;
9535 t['uparen'] = 0x24B0;
9536 t['upblock'] = 0x2580;
9537 t['upperdothebrew'] = 0x05C4;
9538 t['upsilon'] = 0x03C5;
9539 t['upsilondieresis'] = 0x03CB;
9540 t['upsilondieresistonos'] = 0x03B0;
9541 t['upsilonlatin'] = 0x028A;
9542 t['upsilontonos'] = 0x03CD;
9543 t['uptackbelowcmb'] = 0x031D;
9544 t['uptackmod'] = 0x02D4;
9545 t['uragurmukhi'] = 0x0A73;
9546 t['uring'] = 0x016F;
9547 t['ushortcyrillic'] = 0x045E;
9548 t['usmallhiragana'] = 0x3045;
9549 t['usmallkatakana'] = 0x30A5;
9550 t['usmallkatakanahalfwidth'] = 0xFF69;
9551 t['ustraightcyrillic'] = 0x04AF;
9552 t['ustraightstrokecyrillic'] = 0x04B1;
9553 t['utilde'] = 0x0169;
9554 t['utildeacute'] = 0x1E79;
9555 t['utildebelow'] = 0x1E75;
9556 t['uubengali'] = 0x098A;
9557 t['uudeva'] = 0x090A;
9558 t['uugujarati'] = 0x0A8A;
9559 t['uugurmukhi'] = 0x0A0A;
9560 t['uumatragurmukhi'] = 0x0A42;
9561 t['uuvowelsignbengali'] = 0x09C2;
9562 t['uuvowelsigndeva'] = 0x0942;
9563 t['uuvowelsigngujarati'] = 0x0AC2;
9564 t['uvowelsignbengali'] = 0x09C1;
9565 t['uvowelsigndeva'] = 0x0941;
9566 t['uvowelsigngujarati'] = 0x0AC1;
9567 t['v'] = 0x0076;
9568 t['vadeva'] = 0x0935;
9569 t['vagujarati'] = 0x0AB5;
9570 t['vagurmukhi'] = 0x0A35;
9571 t['vakatakana'] = 0x30F7;
9572 t['vav'] = 0x05D5;
9573 t['vavdagesh'] = 0xFB35;
9574 t['vavdagesh65'] = 0xFB35;
9575 t['vavdageshhebrew'] = 0xFB35;
9576 t['vavhebrew'] = 0x05D5;
9577 t['vavholam'] = 0xFB4B;
9578 t['vavholamhebrew'] = 0xFB4B;
9579 t['vavvavhebrew'] = 0x05F0;
9580 t['vavyodhebrew'] = 0x05F1;
9581 t['vcircle'] = 0x24E5;
9582 t['vdotbelow'] = 0x1E7F;
9583 t['vecyrillic'] = 0x0432;
9584 t['veharabic'] = 0x06A4;
9585 t['vehfinalarabic'] = 0xFB6B;
9586 t['vehinitialarabic'] = 0xFB6C;
9587 t['vehmedialarabic'] = 0xFB6D;
9588 t['vekatakana'] = 0x30F9;
9589 t['venus'] = 0x2640;
9590 t['verticalbar'] = 0x007C;
9591 t['verticallineabovecmb'] = 0x030D;
9592 t['verticallinebelowcmb'] = 0x0329;
9593 t['verticallinelowmod'] = 0x02CC;
9594 t['verticallinemod'] = 0x02C8;
9595 t['vewarmenian'] = 0x057E;
9596 t['vhook'] = 0x028B;
9597 t['vikatakana'] = 0x30F8;
9598 t['viramabengali'] = 0x09CD;
9599 t['viramadeva'] = 0x094D;
9600 t['viramagujarati'] = 0x0ACD;
9601 t['visargabengali'] = 0x0983;
9602 t['visargadeva'] = 0x0903;
9603 t['visargagujarati'] = 0x0A83;
9604 t['vmonospace'] = 0xFF56;
9605 t['voarmenian'] = 0x0578;
9606 t['voicediterationhiragana'] = 0x309E;
9607 t['voicediterationkatakana'] = 0x30FE;
9608 t['voicedmarkkana'] = 0x309B;
9609 t['voicedmarkkanahalfwidth'] = 0xFF9E;
9610 t['vokatakana'] = 0x30FA;
9611 t['vparen'] = 0x24B1;
9612 t['vtilde'] = 0x1E7D;
9613 t['vturned'] = 0x028C;
9614 t['vuhiragana'] = 0x3094;
9615 t['vukatakana'] = 0x30F4;
9616 t['w'] = 0x0077;
9617 t['wacute'] = 0x1E83;
9618 t['waekorean'] = 0x3159;
9619 t['wahiragana'] = 0x308F;
9620 t['wakatakana'] = 0x30EF;
9621 t['wakatakanahalfwidth'] = 0xFF9C;
9622 t['wakorean'] = 0x3158;
9623 t['wasmallhiragana'] = 0x308E;
9624 t['wasmallkatakana'] = 0x30EE;
9625 t['wattosquare'] = 0x3357;
9626 t['wavedash'] = 0x301C;
9627 t['wavyunderscorevertical'] = 0xFE34;
9628 t['wawarabic'] = 0x0648;
9629 t['wawfinalarabic'] = 0xFEEE;
9630 t['wawhamzaabovearabic'] = 0x0624;
9631 t['wawhamzaabovefinalarabic'] = 0xFE86;
9632 t['wbsquare'] = 0x33DD;
9633 t['wcircle'] = 0x24E6;
9634 t['wcircumflex'] = 0x0175;
9635 t['wdieresis'] = 0x1E85;
9636 t['wdotaccent'] = 0x1E87;
9637 t['wdotbelow'] = 0x1E89;
9638 t['wehiragana'] = 0x3091;
9639 t['weierstrass'] = 0x2118;
9640 t['wekatakana'] = 0x30F1;
9641 t['wekorean'] = 0x315E;
9642 t['weokorean'] = 0x315D;
9643 t['wgrave'] = 0x1E81;
9644 t['whitebullet'] = 0x25E6;
9645 t['whitecircle'] = 0x25CB;
9646 t['whitecircleinverse'] = 0x25D9;
9647 t['whitecornerbracketleft'] = 0x300E;
9648 t['whitecornerbracketleftvertical'] = 0xFE43;
9649 t['whitecornerbracketright'] = 0x300F;
9650 t['whitecornerbracketrightvertical'] = 0xFE44;
9651 t['whitediamond'] = 0x25C7;
9652 t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
9653 t['whitedownpointingsmalltriangle'] = 0x25BF;
9654 t['whitedownpointingtriangle'] = 0x25BD;
9655 t['whiteleftpointingsmalltriangle'] = 0x25C3;
9656 t['whiteleftpointingtriangle'] = 0x25C1;
9657 t['whitelenticularbracketleft'] = 0x3016;
9658 t['whitelenticularbracketright'] = 0x3017;
9659 t['whiterightpointingsmalltriangle'] = 0x25B9;
9660 t['whiterightpointingtriangle'] = 0x25B7;
9661 t['whitesmallsquare'] = 0x25AB;
9662 t['whitesmilingface'] = 0x263A;
9663 t['whitesquare'] = 0x25A1;
9664 t['whitestar'] = 0x2606;
9665 t['whitetelephone'] = 0x260F;
9666 t['whitetortoiseshellbracketleft'] = 0x3018;
9667 t['whitetortoiseshellbracketright'] = 0x3019;
9668 t['whiteuppointingsmalltriangle'] = 0x25B5;
9669 t['whiteuppointingtriangle'] = 0x25B3;
9670 t['wihiragana'] = 0x3090;
9671 t['wikatakana'] = 0x30F0;
9672 t['wikorean'] = 0x315F;
9673 t['wmonospace'] = 0xFF57;
9674 t['wohiragana'] = 0x3092;
9675 t['wokatakana'] = 0x30F2;
9676 t['wokatakanahalfwidth'] = 0xFF66;
9677 t['won'] = 0x20A9;
9678 t['wonmonospace'] = 0xFFE6;
9679 t['wowaenthai'] = 0x0E27;
9680 t['wparen'] = 0x24B2;
9681 t['wring'] = 0x1E98;
9682 t['wsuperior'] = 0x02B7;
9683 t['wturned'] = 0x028D;
9684 t['wynn'] = 0x01BF;
9685 t['x'] = 0x0078;
9686 t['xabovecmb'] = 0x033D;
9687 t['xbopomofo'] = 0x3112;
9688 t['xcircle'] = 0x24E7;
9689 t['xdieresis'] = 0x1E8D;
9690 t['xdotaccent'] = 0x1E8B;
9691 t['xeharmenian'] = 0x056D;
9692 t['xi'] = 0x03BE;
9693 t['xmonospace'] = 0xFF58;
9694 t['xparen'] = 0x24B3;
9695 t['xsuperior'] = 0x02E3;
9696 t['y'] = 0x0079;
9697 t['yaadosquare'] = 0x334E;
9698 t['yabengali'] = 0x09AF;
9699 t['yacute'] = 0x00FD;
9700 t['yadeva'] = 0x092F;
9701 t['yaekorean'] = 0x3152;
9702 t['yagujarati'] = 0x0AAF;
9703 t['yagurmukhi'] = 0x0A2F;
9704 t['yahiragana'] = 0x3084;
9705 t['yakatakana'] = 0x30E4;
9706 t['yakatakanahalfwidth'] = 0xFF94;
9707 t['yakorean'] = 0x3151;
9708 t['yamakkanthai'] = 0x0E4E;
9709 t['yasmallhiragana'] = 0x3083;
9710 t['yasmallkatakana'] = 0x30E3;
9711 t['yasmallkatakanahalfwidth'] = 0xFF6C;
9712 t['yatcyrillic'] = 0x0463;
9713 t['ycircle'] = 0x24E8;
9714 t['ycircumflex'] = 0x0177;
9715 t['ydieresis'] = 0x00FF;
9716 t['ydotaccent'] = 0x1E8F;
9717 t['ydotbelow'] = 0x1EF5;
9718 t['yeharabic'] = 0x064A;
9719 t['yehbarreearabic'] = 0x06D2;
9720 t['yehbarreefinalarabic'] = 0xFBAF;
9721 t['yehfinalarabic'] = 0xFEF2;
9722 t['yehhamzaabovearabic'] = 0x0626;
9723 t['yehhamzaabovefinalarabic'] = 0xFE8A;
9724 t['yehhamzaaboveinitialarabic'] = 0xFE8B;
9725 t['yehhamzaabovemedialarabic'] = 0xFE8C;
9726 t['yehinitialarabic'] = 0xFEF3;
9727 t['yehmedialarabic'] = 0xFEF4;
9728 t['yehmeeminitialarabic'] = 0xFCDD;
9729 t['yehmeemisolatedarabic'] = 0xFC58;
9730 t['yehnoonfinalarabic'] = 0xFC94;
9731 t['yehthreedotsbelowarabic'] = 0x06D1;
9732 t['yekorean'] = 0x3156;
9733 t['yen'] = 0x00A5;
9734 t['yenmonospace'] = 0xFFE5;
9735 t['yeokorean'] = 0x3155;
9736 t['yeorinhieuhkorean'] = 0x3186;
9737 t['yerahbenyomohebrew'] = 0x05AA;
9738 t['yerahbenyomolefthebrew'] = 0x05AA;
9739 t['yericyrillic'] = 0x044B;
9740 t['yerudieresiscyrillic'] = 0x04F9;
9741 t['yesieungkorean'] = 0x3181;
9742 t['yesieungpansioskorean'] = 0x3183;
9743 t['yesieungsioskorean'] = 0x3182;
9744 t['yetivhebrew'] = 0x059A;
9745 t['ygrave'] = 0x1EF3;
9746 t['yhook'] = 0x01B4;
9747 t['yhookabove'] = 0x1EF7;
9748 t['yiarmenian'] = 0x0575;
9749 t['yicyrillic'] = 0x0457;
9750 t['yikorean'] = 0x3162;
9751 t['yinyang'] = 0x262F;
9752 t['yiwnarmenian'] = 0x0582;
9753 t['ymonospace'] = 0xFF59;
9754 t['yod'] = 0x05D9;
9755 t['yoddagesh'] = 0xFB39;
9756 t['yoddageshhebrew'] = 0xFB39;
9757 t['yodhebrew'] = 0x05D9;
9758 t['yodyodhebrew'] = 0x05F2;
9759 t['yodyodpatahhebrew'] = 0xFB1F;
9760 t['yohiragana'] = 0x3088;
9761 t['yoikorean'] = 0x3189;
9762 t['yokatakana'] = 0x30E8;
9763 t['yokatakanahalfwidth'] = 0xFF96;
9764 t['yokorean'] = 0x315B;
9765 t['yosmallhiragana'] = 0x3087;
9766 t['yosmallkatakana'] = 0x30E7;
9767 t['yosmallkatakanahalfwidth'] = 0xFF6E;
9768 t['yotgreek'] = 0x03F3;
9769 t['yoyaekorean'] = 0x3188;
9770 t['yoyakorean'] = 0x3187;
9771 t['yoyakthai'] = 0x0E22;
9772 t['yoyingthai'] = 0x0E0D;
9773 t['yparen'] = 0x24B4;
9774 t['ypogegrammeni'] = 0x037A;
9775 t['ypogegrammenigreekcmb'] = 0x0345;
9776 t['yr'] = 0x01A6;
9777 t['yring'] = 0x1E99;
9778 t['ysuperior'] = 0x02B8;
9779 t['ytilde'] = 0x1EF9;
9780 t['yturned'] = 0x028E;
9781 t['yuhiragana'] = 0x3086;
9782 t['yuikorean'] = 0x318C;
9783 t['yukatakana'] = 0x30E6;
9784 t['yukatakanahalfwidth'] = 0xFF95;
9785 t['yukorean'] = 0x3160;
9786 t['yusbigcyrillic'] = 0x046B;
9787 t['yusbigiotifiedcyrillic'] = 0x046D;
9788 t['yuslittlecyrillic'] = 0x0467;
9789 t['yuslittleiotifiedcyrillic'] = 0x0469;
9790 t['yusmallhiragana'] = 0x3085;
9791 t['yusmallkatakana'] = 0x30E5;
9792 t['yusmallkatakanahalfwidth'] = 0xFF6D;
9793 t['yuyekorean'] = 0x318B;
9794 t['yuyeokorean'] = 0x318A;
9795 t['yyabengali'] = 0x09DF;
9796 t['yyadeva'] = 0x095F;
9797 t['z'] = 0x007A;
9798 t['zaarmenian'] = 0x0566;
9799 t['zacute'] = 0x017A;
9800 t['zadeva'] = 0x095B;
9801 t['zagurmukhi'] = 0x0A5B;
9802 t['zaharabic'] = 0x0638;
9803 t['zahfinalarabic'] = 0xFEC6;
9804 t['zahinitialarabic'] = 0xFEC7;
9805 t['zahiragana'] = 0x3056;
9806 t['zahmedialarabic'] = 0xFEC8;
9807 t['zainarabic'] = 0x0632;
9808 t['zainfinalarabic'] = 0xFEB0;
9809 t['zakatakana'] = 0x30B6;
9810 t['zaqefgadolhebrew'] = 0x0595;
9811 t['zaqefqatanhebrew'] = 0x0594;
9812 t['zarqahebrew'] = 0x0598;
9813 t['zayin'] = 0x05D6;
9814 t['zayindagesh'] = 0xFB36;
9815 t['zayindageshhebrew'] = 0xFB36;
9816 t['zayinhebrew'] = 0x05D6;
9817 t['zbopomofo'] = 0x3117;
9818 t['zcaron'] = 0x017E;
9819 t['zcircle'] = 0x24E9;
9820 t['zcircumflex'] = 0x1E91;
9821 t['zcurl'] = 0x0291;
9822 t['zdot'] = 0x017C;
9823 t['zdotaccent'] = 0x017C;
9824 t['zdotbelow'] = 0x1E93;
9825 t['zecyrillic'] = 0x0437;
9826 t['zedescendercyrillic'] = 0x0499;
9827 t['zedieresiscyrillic'] = 0x04DF;
9828 t['zehiragana'] = 0x305C;
9829 t['zekatakana'] = 0x30BC;
9830 t['zero'] = 0x0030;
9831 t['zeroarabic'] = 0x0660;
9832 t['zerobengali'] = 0x09E6;
9833 t['zerodeva'] = 0x0966;
9834 t['zerogujarati'] = 0x0AE6;
9835 t['zerogurmukhi'] = 0x0A66;
9836 t['zerohackarabic'] = 0x0660;
9837 t['zeroinferior'] = 0x2080;
9838 t['zeromonospace'] = 0xFF10;
9839 t['zerooldstyle'] = 0xF730;
9840 t['zeropersian'] = 0x06F0;
9841 t['zerosuperior'] = 0x2070;
9842 t['zerothai'] = 0x0E50;
9843 t['zerowidthjoiner'] = 0xFEFF;
9844 t['zerowidthnonjoiner'] = 0x200C;
9845 t['zerowidthspace'] = 0x200B;
9846 t['zeta'] = 0x03B6;
9847 t['zhbopomofo'] = 0x3113;
9848 t['zhearmenian'] = 0x056A;
9849 t['zhebrevecyrillic'] = 0x04C2;
9850 t['zhecyrillic'] = 0x0436;
9851 t['zhedescendercyrillic'] = 0x0497;
9852 t['zhedieresiscyrillic'] = 0x04DD;
9853 t['zihiragana'] = 0x3058;
9854 t['zikatakana'] = 0x30B8;
9855 t['zinorhebrew'] = 0x05AE;
9856 t['zlinebelow'] = 0x1E95;
9857 t['zmonospace'] = 0xFF5A;
9858 t['zohiragana'] = 0x305E;
9859 t['zokatakana'] = 0x30BE;
9860 t['zparen'] = 0x24B5;
9861 t['zretroflexhook'] = 0x0290;
9862 t['zstroke'] = 0x01B6;
9863 t['zuhiragana'] = 0x305A;
9864 t['zukatakana'] = 0x30BA;
9865 t['.notdef'] = 0x0000;
9866});
9867
9868var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
9869 t['space'] = 0x0020;
9870 t['a1'] = 0x2701;
9871 t['a2'] = 0x2702;
9872 t['a202'] = 0x2703;
9873 t['a3'] = 0x2704;
9874 t['a4'] = 0x260E;
9875 t['a5'] = 0x2706;
9876 t['a119'] = 0x2707;
9877 t['a118'] = 0x2708;
9878 t['a117'] = 0x2709;
9879 t['a11'] = 0x261B;
9880 t['a12'] = 0x261E;
9881 t['a13'] = 0x270C;
9882 t['a14'] = 0x270D;
9883 t['a15'] = 0x270E;
9884 t['a16'] = 0x270F;
9885 t['a105'] = 0x2710;
9886 t['a17'] = 0x2711;
9887 t['a18'] = 0x2712;
9888 t['a19'] = 0x2713;
9889 t['a20'] = 0x2714;
9890 t['a21'] = 0x2715;
9891 t['a22'] = 0x2716;
9892 t['a23'] = 0x2717;
9893 t['a24'] = 0x2718;
9894 t['a25'] = 0x2719;
9895 t['a26'] = 0x271A;
9896 t['a27'] = 0x271B;
9897 t['a28'] = 0x271C;
9898 t['a6'] = 0x271D;
9899 t['a7'] = 0x271E;
9900 t['a8'] = 0x271F;
9901 t['a9'] = 0x2720;
9902 t['a10'] = 0x2721;
9903 t['a29'] = 0x2722;
9904 t['a30'] = 0x2723;
9905 t['a31'] = 0x2724;
9906 t['a32'] = 0x2725;
9907 t['a33'] = 0x2726;
9908 t['a34'] = 0x2727;
9909 t['a35'] = 0x2605;
9910 t['a36'] = 0x2729;
9911 t['a37'] = 0x272A;
9912 t['a38'] = 0x272B;
9913 t['a39'] = 0x272C;
9914 t['a40'] = 0x272D;
9915 t['a41'] = 0x272E;
9916 t['a42'] = 0x272F;
9917 t['a43'] = 0x2730;
9918 t['a44'] = 0x2731;
9919 t['a45'] = 0x2732;
9920 t['a46'] = 0x2733;
9921 t['a47'] = 0x2734;
9922 t['a48'] = 0x2735;
9923 t['a49'] = 0x2736;
9924 t['a50'] = 0x2737;
9925 t['a51'] = 0x2738;
9926 t['a52'] = 0x2739;
9927 t['a53'] = 0x273A;
9928 t['a54'] = 0x273B;
9929 t['a55'] = 0x273C;
9930 t['a56'] = 0x273D;
9931 t['a57'] = 0x273E;
9932 t['a58'] = 0x273F;
9933 t['a59'] = 0x2740;
9934 t['a60'] = 0x2741;
9935 t['a61'] = 0x2742;
9936 t['a62'] = 0x2743;
9937 t['a63'] = 0x2744;
9938 t['a64'] = 0x2745;
9939 t['a65'] = 0x2746;
9940 t['a66'] = 0x2747;
9941 t['a67'] = 0x2748;
9942 t['a68'] = 0x2749;
9943 t['a69'] = 0x274A;
9944 t['a70'] = 0x274B;
9945 t['a71'] = 0x25CF;
9946 t['a72'] = 0x274D;
9947 t['a73'] = 0x25A0;
9948 t['a74'] = 0x274F;
9949 t['a203'] = 0x2750;
9950 t['a75'] = 0x2751;
9951 t['a204'] = 0x2752;
9952 t['a76'] = 0x25B2;
9953 t['a77'] = 0x25BC;
9954 t['a78'] = 0x25C6;
9955 t['a79'] = 0x2756;
9956 t['a81'] = 0x25D7;
9957 t['a82'] = 0x2758;
9958 t['a83'] = 0x2759;
9959 t['a84'] = 0x275A;
9960 t['a97'] = 0x275B;
9961 t['a98'] = 0x275C;
9962 t['a99'] = 0x275D;
9963 t['a100'] = 0x275E;
9964 t['a101'] = 0x2761;
9965 t['a102'] = 0x2762;
9966 t['a103'] = 0x2763;
9967 t['a104'] = 0x2764;
9968 t['a106'] = 0x2765;
9969 t['a107'] = 0x2766;
9970 t['a108'] = 0x2767;
9971 t['a112'] = 0x2663;
9972 t['a111'] = 0x2666;
9973 t['a110'] = 0x2665;
9974 t['a109'] = 0x2660;
9975 t['a120'] = 0x2460;
9976 t['a121'] = 0x2461;
9977 t['a122'] = 0x2462;
9978 t['a123'] = 0x2463;
9979 t['a124'] = 0x2464;
9980 t['a125'] = 0x2465;
9981 t['a126'] = 0x2466;
9982 t['a127'] = 0x2467;
9983 t['a128'] = 0x2468;
9984 t['a129'] = 0x2469;
9985 t['a130'] = 0x2776;
9986 t['a131'] = 0x2777;
9987 t['a132'] = 0x2778;
9988 t['a133'] = 0x2779;
9989 t['a134'] = 0x277A;
9990 t['a135'] = 0x277B;
9991 t['a136'] = 0x277C;
9992 t['a137'] = 0x277D;
9993 t['a138'] = 0x277E;
9994 t['a139'] = 0x277F;
9995 t['a140'] = 0x2780;
9996 t['a141'] = 0x2781;
9997 t['a142'] = 0x2782;
9998 t['a143'] = 0x2783;
9999 t['a144'] = 0x2784;
10000 t['a145'] = 0x2785;
10001 t['a146'] = 0x2786;
10002 t['a147'] = 0x2787;
10003 t['a148'] = 0x2788;
10004 t['a149'] = 0x2789;
10005 t['a150'] = 0x278A;
10006 t['a151'] = 0x278B;
10007 t['a152'] = 0x278C;
10008 t['a153'] = 0x278D;
10009 t['a154'] = 0x278E;
10010 t['a155'] = 0x278F;
10011 t['a156'] = 0x2790;
10012 t['a157'] = 0x2791;
10013 t['a158'] = 0x2792;
10014 t['a159'] = 0x2793;
10015 t['a160'] = 0x2794;
10016 t['a161'] = 0x2192;
10017 t['a163'] = 0x2194;
10018 t['a164'] = 0x2195;
10019 t['a196'] = 0x2798;
10020 t['a165'] = 0x2799;
10021 t['a192'] = 0x279A;
10022 t['a166'] = 0x279B;
10023 t['a167'] = 0x279C;
10024 t['a168'] = 0x279D;
10025 t['a169'] = 0x279E;
10026 t['a170'] = 0x279F;
10027 t['a171'] = 0x27A0;
10028 t['a172'] = 0x27A1;
10029 t['a173'] = 0x27A2;
10030 t['a162'] = 0x27A3;
10031 t['a174'] = 0x27A4;
10032 t['a175'] = 0x27A5;
10033 t['a176'] = 0x27A6;
10034 t['a177'] = 0x27A7;
10035 t['a178'] = 0x27A8;
10036 t['a179'] = 0x27A9;
10037 t['a193'] = 0x27AA;
10038 t['a180'] = 0x27AB;
10039 t['a199'] = 0x27AC;
10040 t['a181'] = 0x27AD;
10041 t['a200'] = 0x27AE;
10042 t['a182'] = 0x27AF;
10043 t['a201'] = 0x27B1;
10044 t['a183'] = 0x27B2;
10045 t['a184'] = 0x27B3;
10046 t['a197'] = 0x27B4;
10047 t['a185'] = 0x27B5;
10048 t['a194'] = 0x27B6;
10049 t['a198'] = 0x27B7;
10050 t['a186'] = 0x27B8;
10051 t['a195'] = 0x27B9;
10052 t['a187'] = 0x27BA;
10053 t['a188'] = 0x27BB;
10054 t['a189'] = 0x27BC;
10055 t['a190'] = 0x27BD;
10056 t['a191'] = 0x27BE;
10057 t['a89'] = 0x2768; // 0xF8D7
10058 t['a90'] = 0x2769; // 0xF8D8
10059 t['a93'] = 0x276A; // 0xF8D9
10060 t['a94'] = 0x276B; // 0xF8DA
10061 t['a91'] = 0x276C; // 0xF8DB
10062 t['a92'] = 0x276D; // 0xF8DC
10063 t['a205'] = 0x276E; // 0xF8DD
10064 t['a85'] = 0x276F; // 0xF8DE
10065 t['a206'] = 0x2770; // 0xF8DF
10066 t['a86'] = 0x2771; // 0xF8E0
10067 t['a87'] = 0x2772; // 0xF8E1
10068 t['a88'] = 0x2773; // 0xF8E2
10069 t['a95'] = 0x2774; // 0xF8E3
10070 t['a96'] = 0x2775; // 0xF8E4
10071 t['.notdef'] = 0x0000;
10072});
10073
10074exports.getGlyphsUnicode = getGlyphsUnicode;
10075exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
10076}));
10077
10078
10079(function (root, factory) {
10080 {
10081 factory((root.pdfjsCoreJbig2 = {}), root.pdfjsSharedUtil,
10082 root.pdfjsCoreArithmeticDecoder);
10083 }
10084}(this, function (exports, sharedUtil, coreArithmeticDecoder) {
10085
10086var error = sharedUtil.error;
10087var log2 = sharedUtil.log2;
10088var readInt8 = sharedUtil.readInt8;
10089var readUint16 = sharedUtil.readUint16;
10090var readUint32 = sharedUtil.readUint32;
10091var shadow = sharedUtil.shadow;
10092var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
10093
10094var Jbig2Image = (function Jbig2ImageClosure() {
10095 // Utility data structures
10096 function ContextCache() {}
10097
10098 ContextCache.prototype = {
10099 getContexts: function(id) {
10100 if (id in this) {
10101 return this[id];
10102 }
10103 return (this[id] = new Int8Array(1 << 16));
10104 }
10105 };
10106
10107 function DecodingContext(data, start, end) {
10108 this.data = data;
10109 this.start = start;
10110 this.end = end;
10111 }
10112
10113 DecodingContext.prototype = {
10114 get decoder() {
10115 var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
10116 return shadow(this, 'decoder', decoder);
10117 },
10118 get contextCache() {
10119 var cache = new ContextCache();
10120 return shadow(this, 'contextCache', cache);
10121 }
10122 };
10123
10124 // Annex A. Arithmetic Integer Decoding Procedure
10125 // A.2 Procedure for decoding values
10126 function decodeInteger(contextCache, procedure, decoder) {
10127 var contexts = contextCache.getContexts(procedure);
10128 var prev = 1;
10129
10130 function readBits(length) {
10131 var v = 0;
10132 for (var i = 0; i < length; i++) {
10133 var bit = decoder.readBit(contexts, prev);
10134 prev = (prev < 256 ? (prev << 1) | bit :
10135 (((prev << 1) | bit) & 511) | 256);
10136 v = (v << 1) | bit;
10137 }
10138 return v >>> 0;
10139 }
10140
10141 var sign = readBits(1);
10142 var value = readBits(1) ?
10143 (readBits(1) ?
10144 (readBits(1) ?
10145 (readBits(1) ?
10146 (readBits(1) ?
10147 (readBits(32) + 4436) :
10148 readBits(12) + 340) :
10149 readBits(8) + 84) :
10150 readBits(6) + 20) :
10151 readBits(4) + 4) :
10152 readBits(2);
10153 return (sign === 0 ? value : (value > 0 ? -value : null));
10154 }
10155
10156 // A.3 The IAID decoding procedure
10157 function decodeIAID(contextCache, decoder, codeLength) {
10158 var contexts = contextCache.getContexts('IAID');
10159
10160 var prev = 1;
10161 for (var i = 0; i < codeLength; i++) {
10162 var bit = decoder.readBit(contexts, prev);
10163 prev = (prev << 1) | bit;
10164 }
10165 if (codeLength < 31) {
10166 return prev & ((1 << codeLength) - 1);
10167 }
10168 return prev & 0x7FFFFFFF;
10169 }
10170
10171 // 7.3 Segment types
10172 var SegmentTypes = [
10173 'SymbolDictionary', null, null, null, 'IntermediateTextRegion', null,
10174 'ImmediateTextRegion', 'ImmediateLosslessTextRegion', null, null, null,
10175 null, null, null, null, null, 'patternDictionary', null, null, null,
10176 'IntermediateHalftoneRegion', null, 'ImmediateHalftoneRegion',
10177 'ImmediateLosslessHalftoneRegion', null, null, null, null, null, null, null,
10178 null, null, null, null, null, 'IntermediateGenericRegion', null,
10179 'ImmediateGenericRegion', 'ImmediateLosslessGenericRegion',
10180 'IntermediateGenericRefinementRegion', null,
10181 'ImmediateGenericRefinementRegion',
10182 'ImmediateLosslessGenericRefinementRegion', null, null, null, null,
10183 'PageInformation', 'EndOfPage', 'EndOfStripe', 'EndOfFile', 'Profiles',
10184 'Tables', null, null, null, null, null, null, null, null,
10185 'Extension'
10186 ];
10187
10188 var CodingTemplates = [
10189 [{x: -1, y: -2}, {x: 0, y: -2}, {x: 1, y: -2}, {x: -2, y: -1},
10190 {x: -1, y: -1}, {x: 0, y: -1}, {x: 1, y: -1}, {x: 2, y: -1},
10191 {x: -4, y: 0}, {x: -3, y: 0}, {x: -2, y: 0}, {x: -1, y: 0}],
10192 [{x: -1, y: -2}, {x: 0, y: -2}, {x: 1, y: -2}, {x: 2, y: -2},
10193 {x: -2, y: -1}, {x: -1, y: -1}, {x: 0, y: -1}, {x: 1, y: -1},
10194 {x: 2, y: -1}, {x: -3, y: 0}, {x: -2, y: 0}, {x: -1, y: 0}],
10195 [{x: -1, y: -2}, {x: 0, y: -2}, {x: 1, y: -2}, {x: -2, y: -1},
10196 {x: -1, y: -1}, {x: 0, y: -1}, {x: 1, y: -1}, {x: -2, y: 0},
10197 {x: -1, y: 0}],
10198 [{x: -3, y: -1}, {x: -2, y: -1}, {x: -1, y: -1}, {x: 0, y: -1},
10199 {x: 1, y: -1}, {x: -4, y: 0}, {x: -3, y: 0}, {x: -2, y: 0}, {x: -1, y: 0}]
10200 ];
10201
10202 var RefinementTemplates = [
10203 {
10204 coding: [{x: 0, y: -1}, {x: 1, y: -1}, {x: -1, y: 0}],
10205 reference: [{x: 0, y: -1}, {x: 1, y: -1}, {x: -1, y: 0}, {x: 0, y: 0},
10206 {x: 1, y: 0}, {x: -1, y: 1}, {x: 0, y: 1}, {x: 1, y: 1}]
10207 },
10208 {
10209 coding: [{x: -1, y: -1}, {x: 0, y: -1}, {x: 1, y: -1}, {x: -1, y: 0}],
10210 reference: [{x: 0, y: -1}, {x: -1, y: 0}, {x: 0, y: 0}, {x: 1, y: 0},
10211 {x: 0, y: 1}, {x: 1, y: 1}]
10212 }
10213 ];
10214
10215 // See 6.2.5.7 Decoding the bitmap.
10216 var ReusedContexts = [
10217 0x9B25, // 10011 0110010 0101
10218 0x0795, // 0011 110010 101
10219 0x00E5, // 001 11001 01
10220 0x0195 // 011001 0101
10221 ];
10222
10223 var RefinementReusedContexts = [
10224 0x0020, // '000' + '0' (coding) + '00010000' + '0' (reference)
10225 0x0008 // '0000' + '001000'
10226 ];
10227
10228 function decodeBitmapTemplate0(width, height, decodingContext) {
10229 var decoder = decodingContext.decoder;
10230 var contexts = decodingContext.contextCache.getContexts('GB');
10231 var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
10232
10233 // ...ooooo....
10234 // ..ooooooo... Context template for current pixel (X)
10235 // .ooooX...... (concatenate values of 'o'-pixels to get contextLabel)
10236 var OLD_PIXEL_MASK = 0x7BF7; // 01111 0111111 0111
10237
10238 for (i = 0; i < height; i++) {
10239 row = bitmap[i] = new Uint8Array(width);
10240 row1 = (i < 1) ? row : bitmap[i - 1];
10241 row2 = (i < 2) ? row : bitmap[i - 2];
10242
10243 // At the beginning of each row:
10244 // Fill contextLabel with pixels that are above/right of (X)
10245 contextLabel = (row2[0] << 13) | (row2[1] << 12) | (row2[2] << 11) |
10246 (row1[0] << 7) | (row1[1] << 6) | (row1[2] << 5) |
10247 (row1[3] << 4);
10248
10249 for (j = 0; j < width; j++) {
10250 row[j] = pixel = decoder.readBit(contexts, contextLabel);
10251
10252 // At each pixel: Clear contextLabel pixels that are shifted
10253 // out of the context, then add new ones.
10254 contextLabel = ((contextLabel & OLD_PIXEL_MASK) << 1) |
10255 (j + 3 < width ? row2[j + 3] << 11 : 0) |
10256 (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
10257 }
10258 }
10259
10260 return bitmap;
10261 }
10262
10263 // 6.2 Generic Region Decoding Procedure
10264 function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at,
10265 decodingContext) {
10266 if (mmr) {
10267 error('JBIG2 error: MMR encoding is not supported');
10268 }
10269
10270 // Use optimized version for the most common case
10271 if (templateIndex === 0 && !skip && !prediction && at.length === 4 &&
10272 at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 &&
10273 at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
10274 return decodeBitmapTemplate0(width, height, decodingContext);
10275 }
10276
10277 var useskip = !!skip;
10278 var template = CodingTemplates[templateIndex].concat(at);
10279
10280 // Sorting is non-standard, and it is not required. But sorting increases
10281 // the number of template bits that can be reused from the previous
10282 // contextLabel in the main loop.
10283 template.sort(function (a, b) {
10284 return (a.y - b.y) || (a.x - b.x);
10285 });
10286
10287 var templateLength = template.length;
10288 var templateX = new Int8Array(templateLength);
10289 var templateY = new Int8Array(templateLength);
10290 var changingTemplateEntries = [];
10291 var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
10292 var c, k;
10293
10294 for (k = 0; k < templateLength; k++) {
10295 templateX[k] = template[k].x;
10296 templateY[k] = template[k].y;
10297 minX = Math.min(minX, template[k].x);
10298 maxX = Math.max(maxX, template[k].x);
10299 minY = Math.min(minY, template[k].y);
10300 // Check if the template pixel appears in two consecutive context labels,
10301 // so it can be reused. Otherwise, we add it to the list of changing
10302 // template entries.
10303 if (k < templateLength - 1 &&
10304 template[k].y === template[k + 1].y &&
10305 template[k].x === template[k + 1].x - 1) {
10306 reuseMask |= 1 << (templateLength - 1 - k);
10307 } else {
10308 changingTemplateEntries.push(k);
10309 }
10310 }
10311 var changingEntriesLength = changingTemplateEntries.length;
10312
10313 var changingTemplateX = new Int8Array(changingEntriesLength);
10314 var changingTemplateY = new Int8Array(changingEntriesLength);
10315 var changingTemplateBit = new Uint16Array(changingEntriesLength);
10316 for (c = 0; c < changingEntriesLength; c++) {
10317 k = changingTemplateEntries[c];
10318 changingTemplateX[c] = template[k].x;
10319 changingTemplateY[c] = template[k].y;
10320 changingTemplateBit[c] = 1 << (templateLength - 1 - k);
10321 }
10322
10323 // Get the safe bounding box edges from the width, height, minX, maxX, minY
10324 var sbb_left = -minX;
10325 var sbb_top = -minY;
10326 var sbb_right = width - maxX;
10327
10328 var pseudoPixelContext = ReusedContexts[templateIndex];
10329 var row = new Uint8Array(width);
10330 var bitmap = [];
10331
10332 var decoder = decodingContext.decoder;
10333 var contexts = decodingContext.contextCache.getContexts('GB');
10334
10335 var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
10336 for (var i = 0; i < height; i++) {
10337 if (prediction) {
10338 var sltp = decoder.readBit(contexts, pseudoPixelContext);
10339 ltp ^= sltp;
10340 if (ltp) {
10341 bitmap.push(row); // duplicate previous row
10342 continue;
10343 }
10344 }
10345 row = new Uint8Array(row);
10346 bitmap.push(row);
10347 for (j = 0; j < width; j++) {
10348 if (useskip && skip[i][j]) {
10349 row[j] = 0;
10350 continue;
10351 }
10352 // Are we in the middle of a scanline, so we can reuse contextLabel
10353 // bits?
10354 if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
10355 // If yes, we can just shift the bits that are reusable and only
10356 // fetch the remaining ones.
10357 contextLabel = (contextLabel << 1) & reuseMask;
10358 for (k = 0; k < changingEntriesLength; k++) {
10359 i0 = i + changingTemplateY[k];
10360 j0 = j + changingTemplateX[k];
10361 bit = bitmap[i0][j0];
10362 if (bit) {
10363 bit = changingTemplateBit[k];
10364 contextLabel |= bit;
10365 }
10366 }
10367 } else {
10368 // compute the contextLabel from scratch
10369 contextLabel = 0;
10370 shift = templateLength - 1;
10371 for (k = 0; k < templateLength; k++, shift--) {
10372 j0 = j + templateX[k];
10373 if (j0 >= 0 && j0 < width) {
10374 i0 = i + templateY[k];
10375 if (i0 >= 0) {
10376 bit = bitmap[i0][j0];
10377 if (bit) {
10378 contextLabel |= bit << shift;
10379 }
10380 }
10381 }
10382 }
10383 }
10384 var pixel = decoder.readBit(contexts, contextLabel);
10385 row[j] = pixel;
10386 }
10387 }
10388 return bitmap;
10389 }
10390
10391 // 6.3.2 Generic Refinement Region Decoding Procedure
10392 function decodeRefinement(width, height, templateIndex, referenceBitmap,
10393 offsetX, offsetY, prediction, at,
10394 decodingContext) {
10395 var codingTemplate = RefinementTemplates[templateIndex].coding;
10396 if (templateIndex === 0) {
10397 codingTemplate = codingTemplate.concat([at[0]]);
10398 }
10399 var codingTemplateLength = codingTemplate.length;
10400 var codingTemplateX = new Int32Array(codingTemplateLength);
10401 var codingTemplateY = new Int32Array(codingTemplateLength);
10402 var k;
10403 for (k = 0; k < codingTemplateLength; k++) {
10404 codingTemplateX[k] = codingTemplate[k].x;
10405 codingTemplateY[k] = codingTemplate[k].y;
10406 }
10407
10408 var referenceTemplate = RefinementTemplates[templateIndex].reference;
10409 if (templateIndex === 0) {
10410 referenceTemplate = referenceTemplate.concat([at[1]]);
10411 }
10412 var referenceTemplateLength = referenceTemplate.length;
10413 var referenceTemplateX = new Int32Array(referenceTemplateLength);
10414 var referenceTemplateY = new Int32Array(referenceTemplateLength);
10415 for (k = 0; k < referenceTemplateLength; k++) {
10416 referenceTemplateX[k] = referenceTemplate[k].x;
10417 referenceTemplateY[k] = referenceTemplate[k].y;
10418 }
10419 var referenceWidth = referenceBitmap[0].length;
10420 var referenceHeight = referenceBitmap.length;
10421
10422 var pseudoPixelContext = RefinementReusedContexts[templateIndex];
10423 var bitmap = [];
10424
10425 var decoder = decodingContext.decoder;
10426 var contexts = decodingContext.contextCache.getContexts('GR');
10427
10428 var ltp = 0;
10429 for (var i = 0; i < height; i++) {
10430 if (prediction) {
10431 var sltp = decoder.readBit(contexts, pseudoPixelContext);
10432 ltp ^= sltp;
10433 if (ltp) {
10434 error('JBIG2 error: prediction is not supported');
10435 }
10436 }
10437 var row = new Uint8Array(width);
10438 bitmap.push(row);
10439 for (var j = 0; j < width; j++) {
10440 var i0, j0;
10441 var contextLabel = 0;
10442 for (k = 0; k < codingTemplateLength; k++) {
10443 i0 = i + codingTemplateY[k];
10444 j0 = j + codingTemplateX[k];
10445 if (i0 < 0 || j0 < 0 || j0 >= width) {
10446 contextLabel <<= 1; // out of bound pixel
10447 } else {
10448 contextLabel = (contextLabel << 1) | bitmap[i0][j0];
10449 }
10450 }
10451 for (k = 0; k < referenceTemplateLength; k++) {
10452 i0 = i + referenceTemplateY[k] + offsetY;
10453 j0 = j + referenceTemplateX[k] + offsetX;
10454 if (i0 < 0 || i0 >= referenceHeight || j0 < 0 ||
10455 j0 >= referenceWidth) {
10456 contextLabel <<= 1; // out of bound pixel
10457 } else {
10458 contextLabel = (contextLabel << 1) | referenceBitmap[i0][j0];
10459 }
10460 }
10461 var pixel = decoder.readBit(contexts, contextLabel);
10462 row[j] = pixel;
10463 }
10464 }
10465
10466 return bitmap;
10467 }
10468
10469 // 6.5.5 Decoding the symbol dictionary
10470 function decodeSymbolDictionary(huffman, refinement, symbols,
10471 numberOfNewSymbols, numberOfExportedSymbols,
10472 huffmanTables, templateIndex, at,
10473 refinementTemplateIndex, refinementAt,
10474 decodingContext) {
10475 if (huffman) {
10476 error('JBIG2 error: huffman is not supported');
10477 }
10478
10479 var newSymbols = [];
10480 var currentHeight = 0;
10481 var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
10482
10483 var decoder = decodingContext.decoder;
10484 var contextCache = decodingContext.contextCache;
10485
10486 while (newSymbols.length < numberOfNewSymbols) {
10487 var deltaHeight = decodeInteger(contextCache, 'IADH', decoder); // 6.5.6
10488 currentHeight += deltaHeight;
10489 var currentWidth = 0;
10490 var totalWidth = 0;
10491 while (true) {
10492 var deltaWidth = decodeInteger(contextCache, 'IADW', decoder); // 6.5.7
10493 if (deltaWidth === null) {
10494 break; // OOB
10495 }
10496 currentWidth += deltaWidth;
10497 totalWidth += currentWidth;
10498 var bitmap;
10499 if (refinement) {
10500 // 6.5.8.2 Refinement/aggregate-coded symbol bitmap
10501 var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
10502 if (numberOfInstances > 1) {
10503 bitmap = decodeTextRegion(huffman, refinement,
10504 currentWidth, currentHeight, 0,
10505 numberOfInstances, 1, //strip size
10506 symbols.concat(newSymbols),
10507 symbolCodeLength,
10508 0, //transposed
10509 0, //ds offset
10510 1, //top left 7.4.3.1.1
10511 0, //OR operator
10512 huffmanTables,
10513 refinementTemplateIndex, refinementAt,
10514 decodingContext);
10515 } else {
10516 var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
10517 var rdx = decodeInteger(contextCache, 'IARDX', decoder); // 6.4.11.3
10518 var rdy = decodeInteger(contextCache, 'IARDY', decoder); // 6.4.11.4
10519 var symbol = (symbolId < symbols.length ? symbols[symbolId] :
10520 newSymbols[symbolId - symbols.length]);
10521 bitmap = decodeRefinement(currentWidth, currentHeight,
10522 refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt,
10523 decodingContext);
10524 }
10525 } else {
10526 // 6.5.8.1 Direct-coded symbol bitmap
10527 bitmap = decodeBitmap(false, currentWidth, currentHeight,
10528 templateIndex, false, null, at, decodingContext);
10529 }
10530 newSymbols.push(bitmap);
10531 }
10532 }
10533 // 6.5.10 Exported symbols
10534 var exportedSymbols = [];
10535 var flags = [], currentFlag = false;
10536 var totalSymbolsLength = symbols.length + numberOfNewSymbols;
10537 while (flags.length < totalSymbolsLength) {
10538 var runLength = decodeInteger(contextCache, 'IAEX', decoder);
10539 while (runLength--) {
10540 flags.push(currentFlag);
10541 }
10542 currentFlag = !currentFlag;
10543 }
10544 for (var i = 0, ii = symbols.length; i < ii; i++) {
10545 if (flags[i]) {
10546 exportedSymbols.push(symbols[i]);
10547 }
10548 }
10549 for (var j = 0; j < numberOfNewSymbols; i++, j++) {
10550 if (flags[i]) {
10551 exportedSymbols.push(newSymbols[j]);
10552 }
10553 }
10554 return exportedSymbols;
10555 }
10556
10557 function decodeTextRegion(huffman, refinement, width, height,
10558 defaultPixelValue, numberOfSymbolInstances,
10559 stripSize, inputSymbols, symbolCodeLength,
10560 transposed, dsOffset, referenceCorner,
10561 combinationOperator, huffmanTables,
10562 refinementTemplateIndex, refinementAt,
10563 decodingContext) {
10564 if (huffman) {
10565 error('JBIG2 error: huffman is not supported');
10566 }
10567
10568 // Prepare bitmap
10569 var bitmap = [];
10570 var i, row;
10571 for (i = 0; i < height; i++) {
10572 row = new Uint8Array(width);
10573 if (defaultPixelValue) {
10574 for (var j = 0; j < width; j++) {
10575 row[j] = defaultPixelValue;
10576 }
10577 }
10578 bitmap.push(row);
10579 }
10580
10581 var decoder = decodingContext.decoder;
10582 var contextCache = decodingContext.contextCache;
10583 var stripT = -decodeInteger(contextCache, 'IADT', decoder); // 6.4.6
10584 var firstS = 0;
10585 i = 0;
10586 while (i < numberOfSymbolInstances) {
10587 var deltaT = decodeInteger(contextCache, 'IADT', decoder); // 6.4.6
10588 stripT += deltaT;
10589
10590 var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder); // 6.4.7
10591 firstS += deltaFirstS;
10592 var currentS = firstS;
10593 do {
10594 var currentT = (stripSize === 1 ? 0 :
10595 decodeInteger(contextCache, 'IAIT', decoder)); // 6.4.9
10596 var t = stripSize * stripT + currentT;
10597 var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
10598 var applyRefinement = (refinement &&
10599 decodeInteger(contextCache, 'IARI', decoder));
10600 var symbolBitmap = inputSymbols[symbolId];
10601 var symbolWidth = symbolBitmap[0].length;
10602 var symbolHeight = symbolBitmap.length;
10603 if (applyRefinement) {
10604 var rdw = decodeInteger(contextCache, 'IARDW', decoder); // 6.4.11.1
10605 var rdh = decodeInteger(contextCache, 'IARDH', decoder); // 6.4.11.2
10606 var rdx = decodeInteger(contextCache, 'IARDX', decoder); // 6.4.11.3
10607 var rdy = decodeInteger(contextCache, 'IARDY', decoder); // 6.4.11.4
10608 symbolWidth += rdw;
10609 symbolHeight += rdh;
10610 symbolBitmap = decodeRefinement(symbolWidth, symbolHeight,
10611 refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx,
10612 (rdh >> 1) + rdy, false, refinementAt,
10613 decodingContext);
10614 }
10615 var offsetT = t - ((referenceCorner & 1) ? 0 : symbolHeight);
10616 var offsetS = currentS - ((referenceCorner & 2) ? symbolWidth : 0);
10617 var s2, t2, symbolRow;
10618 if (transposed) {
10619 // Place Symbol Bitmap from T1,S1
10620 for (s2 = 0; s2 < symbolHeight; s2++) {
10621 row = bitmap[offsetS + s2];
10622 if (!row) {
10623 continue;
10624 }
10625 symbolRow = symbolBitmap[s2];
10626 // To ignore Parts of Symbol bitmap which goes
10627 // outside bitmap region
10628 var maxWidth = Math.min(width - offsetT, symbolWidth);
10629 switch (combinationOperator) {
10630 case 0: // OR
10631 for (t2 = 0; t2 < maxWidth; t2++) {
10632 row[offsetT + t2] |= symbolRow[t2];
10633 }
10634 break;
10635 case 2: // XOR
10636 for (t2 = 0; t2 < maxWidth; t2++) {
10637 row[offsetT + t2] ^= symbolRow[t2];
10638 }
10639 break;
10640 default:
10641 error('JBIG2 error: operator ' + combinationOperator +
10642 ' is not supported');
10643 }
10644 }
10645 currentS += symbolHeight - 1;
10646 } else {
10647 for (t2 = 0; t2 < symbolHeight; t2++) {
10648 row = bitmap[offsetT + t2];
10649 if (!row) {
10650 continue;
10651 }
10652 symbolRow = symbolBitmap[t2];
10653 switch (combinationOperator) {
10654 case 0: // OR
10655 for (s2 = 0; s2 < symbolWidth; s2++) {
10656 row[offsetS + s2] |= symbolRow[s2];
10657 }
10658 break;
10659 case 2: // XOR
10660 for (s2 = 0; s2 < symbolWidth; s2++) {
10661 row[offsetS + s2] ^= symbolRow[s2];
10662 }
10663 break;
10664 default:
10665 error('JBIG2 error: operator ' + combinationOperator +
10666 ' is not supported');
10667 }
10668 }
10669 currentS += symbolWidth - 1;
10670 }
10671 i++;
10672 var deltaS = decodeInteger(contextCache, 'IADS', decoder); // 6.4.8
10673 if (deltaS === null) {
10674 break; // OOB
10675 }
10676 currentS += deltaS + dsOffset;
10677 } while (true);
10678 }
10679 return bitmap;
10680 }
10681
10682 function readSegmentHeader(data, start) {
10683 var segmentHeader = {};
10684 segmentHeader.number = readUint32(data, start);
10685 var flags = data[start + 4];
10686 var segmentType = flags & 0x3F;
10687 if (!SegmentTypes[segmentType]) {
10688 error('JBIG2 error: invalid segment type: ' + segmentType);
10689 }
10690 segmentHeader.type = segmentType;
10691 segmentHeader.typeName = SegmentTypes[segmentType];
10692 segmentHeader.deferredNonRetain = !!(flags & 0x80);
10693
10694 var pageAssociationFieldSize = !!(flags & 0x40);
10695 var referredFlags = data[start + 5];
10696 var referredToCount = (referredFlags >> 5) & 7;
10697 var retainBits = [referredFlags & 31];
10698 var position = start + 6;
10699 if (referredFlags === 7) {
10700 referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
10701 position += 3;
10702 var bytes = (referredToCount + 7) >> 3;
10703 retainBits[0] = data[position++];
10704 while (--bytes > 0) {
10705 retainBits.push(data[position++]);
10706 }
10707 } else if (referredFlags === 5 || referredFlags === 6) {
10708 error('JBIG2 error: invalid referred-to flags');
10709 }
10710
10711 segmentHeader.retainBits = retainBits;
10712 var referredToSegmentNumberSize = (segmentHeader.number <= 256 ? 1 :
10713 (segmentHeader.number <= 65536 ? 2 : 4));
10714 var referredTo = [];
10715 var i, ii;
10716 for (i = 0; i < referredToCount; i++) {
10717 var number = (referredToSegmentNumberSize === 1 ? data[position] :
10718 (referredToSegmentNumberSize === 2 ? readUint16(data, position) :
10719 readUint32(data, position)));
10720 referredTo.push(number);
10721 position += referredToSegmentNumberSize;
10722 }
10723 segmentHeader.referredTo = referredTo;
10724 if (!pageAssociationFieldSize) {
10725 segmentHeader.pageAssociation = data[position++];
10726 } else {
10727 segmentHeader.pageAssociation = readUint32(data, position);
10728 position += 4;
10729 }
10730 segmentHeader.length = readUint32(data, position);
10731 position += 4;
10732
10733 if (segmentHeader.length === 0xFFFFFFFF) {
10734 // 7.2.7 Segment data length, unknown segment length
10735 if (segmentType === 38) { // ImmediateGenericRegion
10736 var genericRegionInfo = readRegionSegmentInformation(data, position);
10737 var genericRegionSegmentFlags = data[position +
10738 RegionSegmentInformationFieldLength];
10739 var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
10740 // searching for the segment end
10741 var searchPatternLength = 6;
10742 var searchPattern = new Uint8Array(searchPatternLength);
10743 if (!genericRegionMmr) {
10744 searchPattern[0] = 0xFF;
10745 searchPattern[1] = 0xAC;
10746 }
10747 searchPattern[2] = (genericRegionInfo.height >>> 24) & 0xFF;
10748 searchPattern[3] = (genericRegionInfo.height >> 16) & 0xFF;
10749 searchPattern[4] = (genericRegionInfo.height >> 8) & 0xFF;
10750 searchPattern[5] = genericRegionInfo.height & 0xFF;
10751 for (i = position, ii = data.length; i < ii; i++) {
10752 var j = 0;
10753 while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
10754 j++;
10755 }
10756 if (j === searchPatternLength) {
10757 segmentHeader.length = i + searchPatternLength;
10758 break;
10759 }
10760 }
10761 if (segmentHeader.length === 0xFFFFFFFF) {
10762 error('JBIG2 error: segment end was not found');
10763 }
10764 } else {
10765 error('JBIG2 error: invalid unknown segment length');
10766 }
10767 }
10768 segmentHeader.headerEnd = position;
10769 return segmentHeader;
10770 }
10771
10772 function readSegments(header, data, start, end) {
10773 var segments = [];
10774 var position = start;
10775 while (position < end) {
10776 var segmentHeader = readSegmentHeader(data, position);
10777 position = segmentHeader.headerEnd;
10778 var segment = {
10779 header: segmentHeader,
10780 data: data
10781 };
10782 if (!header.randomAccess) {
10783 segment.start = position;
10784 position += segmentHeader.length;
10785 segment.end = position;
10786 }
10787 segments.push(segment);
10788 if (segmentHeader.type === 51) {
10789 break; // end of file is found
10790 }
10791 }
10792 if (header.randomAccess) {
10793 for (var i = 0, ii = segments.length; i < ii; i++) {
10794 segments[i].start = position;
10795 position += segments[i].header.length;
10796 segments[i].end = position;
10797 }
10798 }
10799 return segments;
10800 }
10801
10802 // 7.4.1 Region segment information field
10803 function readRegionSegmentInformation(data, start) {
10804 return {
10805 width: readUint32(data, start),
10806 height: readUint32(data, start + 4),
10807 x: readUint32(data, start + 8),
10808 y: readUint32(data, start + 12),
10809 combinationOperator: data[start + 16] & 7
10810 };
10811 }
10812 var RegionSegmentInformationFieldLength = 17;
10813
10814 function processSegment(segment, visitor) {
10815 var header = segment.header;
10816
10817 var data = segment.data, position = segment.start, end = segment.end;
10818 var args, at, i, atLength;
10819 switch (header.type) {
10820 case 0: // SymbolDictionary
10821 // 7.4.2 Symbol dictionary segment syntax
10822 var dictionary = {};
10823 var dictionaryFlags = readUint16(data, position); // 7.4.2.1.1
10824 dictionary.huffman = !!(dictionaryFlags & 1);
10825 dictionary.refinement = !!(dictionaryFlags & 2);
10826 dictionary.huffmanDHSelector = (dictionaryFlags >> 2) & 3;
10827 dictionary.huffmanDWSelector = (dictionaryFlags >> 4) & 3;
10828 dictionary.bitmapSizeSelector = (dictionaryFlags >> 6) & 1;
10829 dictionary.aggregationInstancesSelector = (dictionaryFlags >> 7) & 1;
10830 dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
10831 dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
10832 dictionary.template = (dictionaryFlags >> 10) & 3;
10833 dictionary.refinementTemplate = (dictionaryFlags >> 12) & 1;
10834 position += 2;
10835 if (!dictionary.huffman) {
10836 atLength = dictionary.template === 0 ? 4 : 1;
10837 at = [];
10838 for (i = 0; i < atLength; i++) {
10839 at.push({
10840 x: readInt8(data, position),
10841 y: readInt8(data, position + 1)
10842 });
10843 position += 2;
10844 }
10845 dictionary.at = at;
10846 }
10847 if (dictionary.refinement && !dictionary.refinementTemplate) {
10848 at = [];
10849 for (i = 0; i < 2; i++) {
10850 at.push({
10851 x: readInt8(data, position),
10852 y: readInt8(data, position + 1)
10853 });
10854 position += 2;
10855 }
10856 dictionary.refinementAt = at;
10857 }
10858 dictionary.numberOfExportedSymbols = readUint32(data, position);
10859 position += 4;
10860 dictionary.numberOfNewSymbols = readUint32(data, position);
10861 position += 4;
10862 args = [dictionary, header.number, header.referredTo,
10863 data, position, end];
10864 break;
10865 case 6: // ImmediateTextRegion
10866 case 7: // ImmediateLosslessTextRegion
10867 var textRegion = {};
10868 textRegion.info = readRegionSegmentInformation(data, position);
10869 position += RegionSegmentInformationFieldLength;
10870 var textRegionSegmentFlags = readUint16(data, position);
10871 position += 2;
10872 textRegion.huffman = !!(textRegionSegmentFlags & 1);
10873 textRegion.refinement = !!(textRegionSegmentFlags & 2);
10874 textRegion.stripSize = 1 << ((textRegionSegmentFlags >> 2) & 3);
10875 textRegion.referenceCorner = (textRegionSegmentFlags >> 4) & 3;
10876 textRegion.transposed = !!(textRegionSegmentFlags & 64);
10877 textRegion.combinationOperator = (textRegionSegmentFlags >> 7) & 3;
10878 textRegion.defaultPixelValue = (textRegionSegmentFlags >> 9) & 1;
10879 textRegion.dsOffset = (textRegionSegmentFlags << 17) >> 27;
10880 textRegion.refinementTemplate = (textRegionSegmentFlags >> 15) & 1;
10881 if (textRegion.huffman) {
10882 var textRegionHuffmanFlags = readUint16(data, position);
10883 position += 2;
10884 textRegion.huffmanFS = (textRegionHuffmanFlags) & 3;
10885 textRegion.huffmanDS = (textRegionHuffmanFlags >> 2) & 3;
10886 textRegion.huffmanDT = (textRegionHuffmanFlags >> 4) & 3;
10887 textRegion.huffmanRefinementDW = (textRegionHuffmanFlags >> 6) & 3;
10888 textRegion.huffmanRefinementDH = (textRegionHuffmanFlags >> 8) & 3;
10889 textRegion.huffmanRefinementDX = (textRegionHuffmanFlags >> 10) & 3;
10890 textRegion.huffmanRefinementDY = (textRegionHuffmanFlags >> 12) & 3;
10891 textRegion.huffmanRefinementSizeSelector =
10892 !!(textRegionHuffmanFlags & 14);
10893 }
10894 if (textRegion.refinement && !textRegion.refinementTemplate) {
10895 at = [];
10896 for (i = 0; i < 2; i++) {
10897 at.push({
10898 x: readInt8(data, position),
10899 y: readInt8(data, position + 1)
10900 });
10901 position += 2;
10902 }
10903 textRegion.refinementAt = at;
10904 }
10905 textRegion.numberOfSymbolInstances = readUint32(data, position);
10906 position += 4;
10907 // TODO 7.4.3.1.7 Symbol ID Huffman table decoding
10908 if (textRegion.huffman) {
10909 error('JBIG2 error: huffman is not supported');
10910 }
10911 args = [textRegion, header.referredTo, data, position, end];
10912 break;
10913 case 38: // ImmediateGenericRegion
10914 case 39: // ImmediateLosslessGenericRegion
10915 var genericRegion = {};
10916 genericRegion.info = readRegionSegmentInformation(data, position);
10917 position += RegionSegmentInformationFieldLength;
10918 var genericRegionSegmentFlags = data[position++];
10919 genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
10920 genericRegion.template = (genericRegionSegmentFlags >> 1) & 3;
10921 genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
10922 if (!genericRegion.mmr) {
10923 atLength = genericRegion.template === 0 ? 4 : 1;
10924 at = [];
10925 for (i = 0; i < atLength; i++) {
10926 at.push({
10927 x: readInt8(data, position),
10928 y: readInt8(data, position + 1)
10929 });
10930 position += 2;
10931 }
10932 genericRegion.at = at;
10933 }
10934 args = [genericRegion, data, position, end];
10935 break;
10936 case 48: // PageInformation
10937 var pageInfo = {
10938 width: readUint32(data, position),
10939 height: readUint32(data, position + 4),
10940 resolutionX: readUint32(data, position + 8),
10941 resolutionY: readUint32(data, position + 12)
10942 };
10943 if (pageInfo.height === 0xFFFFFFFF) {
10944 delete pageInfo.height;
10945 }
10946 var pageSegmentFlags = data[position + 16];
10947 var pageStripingInformation = readUint16(data, position + 17);
10948 pageInfo.lossless = !!(pageSegmentFlags & 1);
10949 pageInfo.refinement = !!(pageSegmentFlags & 2);
10950 pageInfo.defaultPixelValue = (pageSegmentFlags >> 2) & 1;
10951 pageInfo.combinationOperator = (pageSegmentFlags >> 3) & 3;
10952 pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
10953 pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
10954 args = [pageInfo];
10955 break;
10956 case 49: // EndOfPage
10957 break;
10958 case 50: // EndOfStripe
10959 break;
10960 case 51: // EndOfFile
10961 break;
10962 case 62: // 7.4.15 defines 2 extension types which
10963 // are comments and can be ignored.
10964 break;
10965 default:
10966 error('JBIG2 error: segment type ' + header.typeName + '(' +
10967 header.type + ') is not implemented');
10968 }
10969 var callbackName = 'on' + header.typeName;
10970 if (callbackName in visitor) {
10971 visitor[callbackName].apply(visitor, args);
10972 }
10973 }
10974
10975 function processSegments(segments, visitor) {
10976 for (var i = 0, ii = segments.length; i < ii; i++) {
10977 processSegment(segments[i], visitor);
10978 }
10979 }
10980
10981 function parseJbig2(data, start, end) {
10982 var position = start;
10983 if (data[position] !== 0x97 || data[position + 1] !== 0x4A ||
10984 data[position + 2] !== 0x42 || data[position + 3] !== 0x32 ||
10985 data[position + 4] !== 0x0D || data[position + 5] !== 0x0A ||
10986 data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
10987 error('JBIG2 error: invalid header');
10988 }
10989 var header = {};
10990 position += 8;
10991 var flags = data[position++];
10992 header.randomAccess = !(flags & 1);
10993 if (!(flags & 2)) {
10994 header.numberOfPages = readUint32(data, position);
10995 position += 4;
10996 }
10997 var segments = readSegments(header, data, position, end);
10998 error('Not implemented');
10999 // processSegments(segments, new SimpleSegmentVisitor());
11000 }
11001
11002 function parseJbig2Chunks(chunks) {
11003 var visitor = new SimpleSegmentVisitor();
11004 for (var i = 0, ii = chunks.length; i < ii; i++) {
11005 var chunk = chunks[i];
11006 var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
11007 processSegments(segments, visitor);
11008 }
11009 return visitor.buffer;
11010 }
11011
11012 function SimpleSegmentVisitor() {}
11013
11014 SimpleSegmentVisitor.prototype = {
11015 onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
11016 this.currentPageInfo = info;
11017 var rowSize = (info.width + 7) >> 3;
11018 var buffer = new Uint8Array(rowSize * info.height);
11019 // The contents of ArrayBuffers are initialized to 0.
11020 // Fill the buffer with 0xFF only if info.defaultPixelValue is set
11021 if (info.defaultPixelValue) {
11022 for (var i = 0, ii = buffer.length; i < ii; i++) {
11023 buffer[i] = 0xFF;
11024 }
11025 }
11026 this.buffer = buffer;
11027 },
11028 drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
11029 var pageInfo = this.currentPageInfo;
11030 var width = regionInfo.width, height = regionInfo.height;
11031 var rowSize = (pageInfo.width + 7) >> 3;
11032 var combinationOperator = pageInfo.combinationOperatorOverride ?
11033 regionInfo.combinationOperator : pageInfo.combinationOperator;
11034 var buffer = this.buffer;
11035 var mask0 = 128 >> (regionInfo.x & 7);
11036 var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
11037 var i, j, mask, offset;
11038 switch (combinationOperator) {
11039 case 0: // OR
11040 for (i = 0; i < height; i++) {
11041 mask = mask0;
11042 offset = offset0;
11043 for (j = 0; j < width; j++) {
11044 if (bitmap[i][j]) {
11045 buffer[offset] |= mask;
11046 }
11047 mask >>= 1;
11048 if (!mask) {
11049 mask = 128;
11050 offset++;
11051 }
11052 }
11053 offset0 += rowSize;
11054 }
11055 break;
11056 case 2: // XOR
11057 for (i = 0; i < height; i++) {
11058 mask = mask0;
11059 offset = offset0;
11060 for (j = 0; j < width; j++) {
11061 if (bitmap[i][j]) {
11062 buffer[offset] ^= mask;
11063 }
11064 mask >>= 1;
11065 if (!mask) {
11066 mask = 128;
11067 offset++;
11068 }
11069 }
11070 offset0 += rowSize;
11071 }
11072 break;
11073 default:
11074 error('JBIG2 error: operator ' + combinationOperator +
11075 ' is not supported');
11076 }
11077 },
11078 onImmediateGenericRegion:
11079 function SimpleSegmentVisitor_onImmediateGenericRegion(region, data,
11080 start, end) {
11081 var regionInfo = region.info;
11082 var decodingContext = new DecodingContext(data, start, end);
11083 var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height,
11084 region.template, region.prediction, null,
11085 region.at, decodingContext);
11086 this.drawBitmap(regionInfo, bitmap);
11087 },
11088 onImmediateLosslessGenericRegion:
11089 function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
11090 this.onImmediateGenericRegion.apply(this, arguments);
11091 },
11092 onSymbolDictionary:
11093 function SimpleSegmentVisitor_onSymbolDictionary(dictionary,
11094 currentSegment,
11095 referredSegments,
11096 data, start, end) {
11097 var huffmanTables;
11098 if (dictionary.huffman) {
11099 error('JBIG2 error: huffman is not supported');
11100 }
11101
11102 // Combines exported symbols from all referred segments
11103 var symbols = this.symbols;
11104 if (!symbols) {
11105 this.symbols = symbols = {};
11106 }
11107
11108 var inputSymbols = [];
11109 for (var i = 0, ii = referredSegments.length; i < ii; i++) {
11110 inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
11111 }
11112
11113 var decodingContext = new DecodingContext(data, start, end);
11114 symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman,
11115 dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols,
11116 dictionary.numberOfExportedSymbols, huffmanTables,
11117 dictionary.template, dictionary.at,
11118 dictionary.refinementTemplate, dictionary.refinementAt,
11119 decodingContext);
11120 },
11121 onImmediateTextRegion:
11122 function SimpleSegmentVisitor_onImmediateTextRegion(region,
11123 referredSegments,
11124 data, start, end) {
11125 var regionInfo = region.info;
11126 var huffmanTables;
11127
11128 // Combines exported symbols from all referred segments
11129 var symbols = this.symbols;
11130 var inputSymbols = [];
11131 for (var i = 0, ii = referredSegments.length; i < ii; i++) {
11132 inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
11133 }
11134 var symbolCodeLength = log2(inputSymbols.length);
11135
11136 var decodingContext = new DecodingContext(data, start, end);
11137 var bitmap = decodeTextRegion(region.huffman, region.refinement,
11138 regionInfo.width, regionInfo.height, region.defaultPixelValue,
11139 region.numberOfSymbolInstances, region.stripSize, inputSymbols,
11140 symbolCodeLength, region.transposed, region.dsOffset,
11141 region.referenceCorner, region.combinationOperator, huffmanTables,
11142 region.refinementTemplate, region.refinementAt, decodingContext);
11143 this.drawBitmap(regionInfo, bitmap);
11144 },
11145 onImmediateLosslessTextRegion:
11146 function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
11147 this.onImmediateTextRegion.apply(this, arguments);
11148 }
11149 };
11150
11151 function Jbig2Image() {}
11152
11153 Jbig2Image.prototype = {
11154 parseChunks: function Jbig2Image_parseChunks(chunks) {
11155 return parseJbig2Chunks(chunks);
11156 }
11157 };
11158
11159 return Jbig2Image;
11160})();
11161
11162exports.Jbig2Image = Jbig2Image;
11163}));
11164
11165
11166(function (root, factory) {
11167 {
11168 factory((root.pdfjsCoreJpg = {}), root.pdfjsSharedUtil);
11169 }
11170}(this, function (exports, sharedUtil) {
11171
11172var error = sharedUtil.error;
11173
11174/**
11175 * This code was forked from https://github.com/notmasteryet/jpgjs.
11176 * The original version was created by GitHub user notmasteryet.
11177 *
11178 * - The JPEG specification can be found in the ITU CCITT Recommendation T.81
11179 * (www.w3.org/Graphics/JPEG/itu-t81.pdf)
11180 * - The JFIF specification can be found in the JPEG File Interchange Format
11181 * (www.w3.org/Graphics/JPEG/jfif3.pdf)
11182 * - The Adobe Application-Specific JPEG markers in the
11183 * Supporting the DCT Filters in PostScript Level 2, Technical Note #5116
11184 * (partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf)
11185 */
11186
11187var JpegImage = (function JpegImageClosure() {
11188 var dctZigZag = new Uint8Array([
11189 0,
11190 1, 8,
11191 16, 9, 2,
11192 3, 10, 17, 24,
11193 32, 25, 18, 11, 4,
11194 5, 12, 19, 26, 33, 40,
11195 48, 41, 34, 27, 20, 13, 6,
11196 7, 14, 21, 28, 35, 42, 49, 56,
11197 57, 50, 43, 36, 29, 22, 15,
11198 23, 30, 37, 44, 51, 58,
11199 59, 52, 45, 38, 31,
11200 39, 46, 53, 60,
11201 61, 54, 47,
11202 55, 62,
11203 63
11204 ]);
11205
11206 var dctCos1 = 4017; // cos(pi/16)
11207 var dctSin1 = 799; // sin(pi/16)
11208 var dctCos3 = 3406; // cos(3*pi/16)
11209 var dctSin3 = 2276; // sin(3*pi/16)
11210 var dctCos6 = 1567; // cos(6*pi/16)
11211 var dctSin6 = 3784; // sin(6*pi/16)
11212 var dctSqrt2 = 5793; // sqrt(2)
11213 var dctSqrt1d2 = 2896; // sqrt(2) / 2
11214
11215 function JpegImage() {
11216 this.decodeTransform = null;
11217 this.colorTransform = -1;
11218 }
11219
11220 function buildHuffmanTable(codeLengths, values) {
11221 var k = 0, code = [], i, j, length = 16;
11222 while (length > 0 && !codeLengths[length - 1]) {
11223 length--;
11224 }
11225 code.push({children: [], index: 0});
11226 var p = code[0], q;
11227 for (i = 0; i < length; i++) {
11228 for (j = 0; j < codeLengths[i]; j++) {
11229 p = code.pop();
11230 p.children[p.index] = values[k];
11231 while (p.index > 0) {
11232 p = code.pop();
11233 }
11234 p.index++;
11235 code.push(p);
11236 while (code.length <= i) {
11237 code.push(q = {children: [], index: 0});
11238 p.children[p.index] = q.children;
11239 p = q;
11240 }
11241 k++;
11242 }
11243 if (i + 1 < length) {
11244 // p here points to last code
11245 code.push(q = {children: [], index: 0});
11246 p.children[p.index] = q.children;
11247 p = q;
11248 }
11249 }
11250 return code[0].children;
11251 }
11252
11253 function getBlockBufferOffset(component, row, col) {
11254 return 64 * ((component.blocksPerLine + 1) * row + col);
11255 }
11256
11257 function decodeScan(data, offset, frame, components, resetInterval,
11258 spectralStart, spectralEnd, successivePrev, successive) {
11259 var mcusPerLine = frame.mcusPerLine;
11260 var progressive = frame.progressive;
11261
11262 var startOffset = offset, bitsData = 0, bitsCount = 0;
11263
11264 function readBit() {
11265 if (bitsCount > 0) {
11266 bitsCount--;
11267 return (bitsData >> bitsCount) & 1;
11268 }
11269 bitsData = data[offset++];
11270 if (bitsData === 0xFF) {
11271 var nextByte = data[offset++];
11272 if (nextByte) {
11273 error('JPEG error: unexpected marker ' +
11274 ((bitsData << 8) | nextByte).toString(16));
11275 }
11276 // unstuff 0
11277 }
11278 bitsCount = 7;
11279 return bitsData >>> 7;
11280 }
11281
11282 function decodeHuffman(tree) {
11283 var node = tree;
11284 while (true) {
11285 node = node[readBit()];
11286 if (typeof node === 'number') {
11287 return node;
11288 }
11289 if (typeof node !== 'object') {
11290 error('JPEG error: invalid huffman sequence');
11291 }
11292 }
11293 }
11294
11295 function receive(length) {
11296 var n = 0;
11297 while (length > 0) {
11298 n = (n << 1) | readBit();
11299 length--;
11300 }
11301 return n;
11302 }
11303
11304 function receiveAndExtend(length) {
11305 if (length === 1) {
11306 return readBit() === 1 ? 1 : -1;
11307 }
11308 var n = receive(length);
11309 if (n >= 1 << (length - 1)) {
11310 return n;
11311 }
11312 return n + (-1 << length) + 1;
11313 }
11314
11315 function decodeBaseline(component, offset) {
11316 var t = decodeHuffman(component.huffmanTableDC);
11317 var diff = t === 0 ? 0 : receiveAndExtend(t);
11318 component.blockData[offset] = (component.pred += diff);
11319 var k = 1;
11320 while (k < 64) {
11321 var rs = decodeHuffman(component.huffmanTableAC);
11322 var s = rs & 15, r = rs >> 4;
11323 if (s === 0) {
11324 if (r < 15) {
11325 break;
11326 }
11327 k += 16;
11328 continue;
11329 }
11330 k += r;
11331 var z = dctZigZag[k];
11332 component.blockData[offset + z] = receiveAndExtend(s);
11333 k++;
11334 }
11335 }
11336
11337 function decodeDCFirst(component, offset) {
11338 var t = decodeHuffman(component.huffmanTableDC);
11339 var diff = t === 0 ? 0 : (receiveAndExtend(t) << successive);
11340 component.blockData[offset] = (component.pred += diff);
11341 }
11342
11343 function decodeDCSuccessive(component, offset) {
11344 component.blockData[offset] |= readBit() << successive;
11345 }
11346
11347 var eobrun = 0;
11348 function decodeACFirst(component, offset) {
11349 if (eobrun > 0) {
11350 eobrun--;
11351 return;
11352 }
11353 var k = spectralStart, e = spectralEnd;
11354 while (k <= e) {
11355 var rs = decodeHuffman(component.huffmanTableAC);
11356 var s = rs & 15, r = rs >> 4;
11357 if (s === 0) {
11358 if (r < 15) {
11359 eobrun = receive(r) + (1 << r) - 1;
11360 break;
11361 }
11362 k += 16;
11363 continue;
11364 }
11365 k += r;
11366 var z = dctZigZag[k];
11367 component.blockData[offset + z] =
11368 receiveAndExtend(s) * (1 << successive);
11369 k++;
11370 }
11371 }
11372
11373 var successiveACState = 0, successiveACNextValue;
11374 function decodeACSuccessive(component, offset) {
11375 var k = spectralStart;
11376 var e = spectralEnd;
11377 var r = 0;
11378 var s;
11379 var rs;
11380 while (k <= e) {
11381 var z = dctZigZag[k];
11382 switch (successiveACState) {
11383 case 0: // initial state
11384 rs = decodeHuffman(component.huffmanTableAC);
11385 s = rs & 15;
11386 r = rs >> 4;
11387 if (s === 0) {
11388 if (r < 15) {
11389 eobrun = receive(r) + (1 << r);
11390 successiveACState = 4;
11391 } else {
11392 r = 16;
11393 successiveACState = 1;
11394 }
11395 } else {
11396 if (s !== 1) {
11397 error('JPEG error: invalid ACn encoding');
11398 }
11399 successiveACNextValue = receiveAndExtend(s);
11400 successiveACState = r ? 2 : 3;
11401 }
11402 continue;
11403 case 1: // skipping r zero items
11404 case 2:
11405 if (component.blockData[offset + z]) {
11406 component.blockData[offset + z] += (readBit() << successive);
11407 } else {
11408 r--;
11409 if (r === 0) {
11410 successiveACState = successiveACState === 2 ? 3 : 0;
11411 }
11412 }
11413 break;
11414 case 3: // set value for a zero item
11415 if (component.blockData[offset + z]) {
11416 component.blockData[offset + z] += (readBit() << successive);
11417 } else {
11418 component.blockData[offset + z] =
11419 successiveACNextValue << successive;
11420 successiveACState = 0;
11421 }
11422 break;
11423 case 4: // eob
11424 if (component.blockData[offset + z]) {
11425 component.blockData[offset + z] += (readBit() << successive);
11426 }
11427 break;
11428 }
11429 k++;
11430 }
11431 if (successiveACState === 4) {
11432 eobrun--;
11433 if (eobrun === 0) {
11434 successiveACState = 0;
11435 }
11436 }
11437 }
11438
11439 function decodeMcu(component, decode, mcu, row, col) {
11440 var mcuRow = (mcu / mcusPerLine) | 0;
11441 var mcuCol = mcu % mcusPerLine;
11442 var blockRow = mcuRow * component.v + row;
11443 var blockCol = mcuCol * component.h + col;
11444 var offset = getBlockBufferOffset(component, blockRow, blockCol);
11445 decode(component, offset);
11446 }
11447
11448 function decodeBlock(component, decode, mcu) {
11449 var blockRow = (mcu / component.blocksPerLine) | 0;
11450 var blockCol = mcu % component.blocksPerLine;
11451 var offset = getBlockBufferOffset(component, blockRow, blockCol);
11452 decode(component, offset);
11453 }
11454
11455 var componentsLength = components.length;
11456 var component, i, j, k, n;
11457 var decodeFn;
11458 if (progressive) {
11459 if (spectralStart === 0) {
11460 decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
11461 } else {
11462 decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
11463 }
11464 } else {
11465 decodeFn = decodeBaseline;
11466 }
11467
11468 var mcu = 0, marker;
11469 var mcuExpected;
11470 if (componentsLength === 1) {
11471 mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
11472 } else {
11473 mcuExpected = mcusPerLine * frame.mcusPerColumn;
11474 }
11475 if (!resetInterval) {
11476 resetInterval = mcuExpected;
11477 }
11478
11479 var h, v;
11480 while (mcu < mcuExpected) {
11481 // reset interval stuff
11482 for (i = 0; i < componentsLength; i++) {
11483 components[i].pred = 0;
11484 }
11485 eobrun = 0;
11486
11487 if (componentsLength === 1) {
11488 component = components[0];
11489 for (n = 0; n < resetInterval; n++) {
11490 decodeBlock(component, decodeFn, mcu);
11491 mcu++;
11492 }
11493 } else {
11494 for (n = 0; n < resetInterval; n++) {
11495 for (i = 0; i < componentsLength; i++) {
11496 component = components[i];
11497 h = component.h;
11498 v = component.v;
11499 for (j = 0; j < v; j++) {
11500 for (k = 0; k < h; k++) {
11501 decodeMcu(component, decodeFn, mcu, j, k);
11502 }
11503 }
11504 }
11505 mcu++;
11506 }
11507 }
11508
11509 // find marker
11510 bitsCount = 0;
11511 marker = (data[offset] << 8) | data[offset + 1];
11512 // Some bad images seem to pad Scan blocks with zero bytes, skip past
11513 // those to attempt to find a valid marker (fixes issue4090.pdf).
11514 while (data[offset] === 0x00 && offset < data.length - 1) {
11515 offset++;
11516 marker = (data[offset] << 8) | data[offset + 1];
11517 }
11518 if (marker <= 0xFF00) {
11519 error('JPEG error: marker was not found');
11520 }
11521
11522 if (marker >= 0xFFD0 && marker <= 0xFFD7) { // RSTx
11523 offset += 2;
11524 } else {
11525 break;
11526 }
11527 }
11528
11529 return offset - startOffset;
11530 }
11531
11532 // A port of poppler's IDCT method which in turn is taken from:
11533 // Christoph Loeffler, Adriaan Ligtenberg, George S. Moschytz,
11534 // 'Practical Fast 1-D DCT Algorithms with 11 Multiplications',
11535 // IEEE Intl. Conf. on Acoustics, Speech & Signal Processing, 1989,
11536 // 988-991.
11537 function quantizeAndInverse(component, blockBufferOffset, p) {
11538 var qt = component.quantizationTable, blockData = component.blockData;
11539 var v0, v1, v2, v3, v4, v5, v6, v7;
11540 var p0, p1, p2, p3, p4, p5, p6, p7;
11541 var t;
11542
11543 if (!qt) {
11544 error('JPEG error: missing required Quantization Table.');
11545 }
11546
11547 // inverse DCT on rows
11548 for (var row = 0; row < 64; row += 8) {
11549 // gather block data
11550 p0 = blockData[blockBufferOffset + row];
11551 p1 = blockData[blockBufferOffset + row + 1];
11552 p2 = blockData[blockBufferOffset + row + 2];
11553 p3 = blockData[blockBufferOffset + row + 3];
11554 p4 = blockData[blockBufferOffset + row + 4];
11555 p5 = blockData[blockBufferOffset + row + 5];
11556 p6 = blockData[blockBufferOffset + row + 6];
11557 p7 = blockData[blockBufferOffset + row + 7];
11558
11559 // dequant p0
11560 p0 *= qt[row];
11561
11562 // check for all-zero AC coefficients
11563 if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
11564 t = (dctSqrt2 * p0 + 512) >> 10;
11565 p[row] = t;
11566 p[row + 1] = t;
11567 p[row + 2] = t;
11568 p[row + 3] = t;
11569 p[row + 4] = t;
11570 p[row + 5] = t;
11571 p[row + 6] = t;
11572 p[row + 7] = t;
11573 continue;
11574 }
11575 // dequant p1 ... p7
11576 p1 *= qt[row + 1];
11577 p2 *= qt[row + 2];
11578 p3 *= qt[row + 3];
11579 p4 *= qt[row + 4];
11580 p5 *= qt[row + 5];
11581 p6 *= qt[row + 6];
11582 p7 *= qt[row + 7];
11583
11584 // stage 4
11585 v0 = (dctSqrt2 * p0 + 128) >> 8;
11586 v1 = (dctSqrt2 * p4 + 128) >> 8;
11587 v2 = p2;
11588 v3 = p6;
11589 v4 = (dctSqrt1d2 * (p1 - p7) + 128) >> 8;
11590 v7 = (dctSqrt1d2 * (p1 + p7) + 128) >> 8;
11591 v5 = p3 << 4;
11592 v6 = p5 << 4;
11593
11594 // stage 3
11595 v0 = (v0 + v1 + 1) >> 1;
11596 v1 = v0 - v1;
11597 t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8;
11598 v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8;
11599 v3 = t;
11600 v4 = (v4 + v6 + 1) >> 1;
11601 v6 = v4 - v6;
11602 v7 = (v7 + v5 + 1) >> 1;
11603 v5 = v7 - v5;
11604
11605 // stage 2
11606 v0 = (v0 + v3 + 1) >> 1;
11607 v3 = v0 - v3;
11608 v1 = (v1 + v2 + 1) >> 1;
11609 v2 = v1 - v2;
11610 t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;
11611 v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;
11612 v7 = t;
11613 t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;
11614 v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;
11615 v6 = t;
11616
11617 // stage 1
11618 p[row] = v0 + v7;
11619 p[row + 7] = v0 - v7;
11620 p[row + 1] = v1 + v6;
11621 p[row + 6] = v1 - v6;
11622 p[row + 2] = v2 + v5;
11623 p[row + 5] = v2 - v5;
11624 p[row + 3] = v3 + v4;
11625 p[row + 4] = v3 - v4;
11626 }
11627
11628 // inverse DCT on columns
11629 for (var col = 0; col < 8; ++col) {
11630 p0 = p[col];
11631 p1 = p[col + 8];
11632 p2 = p[col + 16];
11633 p3 = p[col + 24];
11634 p4 = p[col + 32];
11635 p5 = p[col + 40];
11636 p6 = p[col + 48];
11637 p7 = p[col + 56];
11638
11639 // check for all-zero AC coefficients
11640 if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
11641 t = (dctSqrt2 * p0 + 8192) >> 14;
11642 // convert to 8 bit
11643 t = (t < -2040) ? 0 : (t >= 2024) ? 255 : (t + 2056) >> 4;
11644 blockData[blockBufferOffset + col] = t;
11645 blockData[blockBufferOffset + col + 8] = t;
11646 blockData[blockBufferOffset + col + 16] = t;
11647 blockData[blockBufferOffset + col + 24] = t;
11648 blockData[blockBufferOffset + col + 32] = t;
11649 blockData[blockBufferOffset + col + 40] = t;
11650 blockData[blockBufferOffset + col + 48] = t;
11651 blockData[blockBufferOffset + col + 56] = t;
11652 continue;
11653 }
11654
11655 // stage 4
11656 v0 = (dctSqrt2 * p0 + 2048) >> 12;
11657 v1 = (dctSqrt2 * p4 + 2048) >> 12;
11658 v2 = p2;
11659 v3 = p6;
11660 v4 = (dctSqrt1d2 * (p1 - p7) + 2048) >> 12;
11661 v7 = (dctSqrt1d2 * (p1 + p7) + 2048) >> 12;
11662 v5 = p3;
11663 v6 = p5;
11664
11665 // stage 3
11666 // Shift v0 by 128.5 << 5 here, so we don't need to shift p0...p7 when
11667 // converting to UInt8 range later.
11668 v0 = ((v0 + v1 + 1) >> 1) + 4112;
11669 v1 = v0 - v1;
11670 t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12;
11671 v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12;
11672 v3 = t;
11673 v4 = (v4 + v6 + 1) >> 1;
11674 v6 = v4 - v6;
11675 v7 = (v7 + v5 + 1) >> 1;
11676 v5 = v7 - v5;
11677
11678 // stage 2
11679 v0 = (v0 + v3 + 1) >> 1;
11680 v3 = v0 - v3;
11681 v1 = (v1 + v2 + 1) >> 1;
11682 v2 = v1 - v2;
11683 t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12;
11684 v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12;
11685 v7 = t;
11686 t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12;
11687 v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12;
11688 v6 = t;
11689
11690 // stage 1
11691 p0 = v0 + v7;
11692 p7 = v0 - v7;
11693 p1 = v1 + v6;
11694 p6 = v1 - v6;
11695 p2 = v2 + v5;
11696 p5 = v2 - v5;
11697 p3 = v3 + v4;
11698 p4 = v3 - v4;
11699
11700 // convert to 8-bit integers
11701 p0 = (p0 < 16) ? 0 : (p0 >= 4080) ? 255 : p0 >> 4;
11702 p1 = (p1 < 16) ? 0 : (p1 >= 4080) ? 255 : p1 >> 4;
11703 p2 = (p2 < 16) ? 0 : (p2 >= 4080) ? 255 : p2 >> 4;
11704 p3 = (p3 < 16) ? 0 : (p3 >= 4080) ? 255 : p3 >> 4;
11705 p4 = (p4 < 16) ? 0 : (p4 >= 4080) ? 255 : p4 >> 4;
11706 p5 = (p5 < 16) ? 0 : (p5 >= 4080) ? 255 : p5 >> 4;
11707 p6 = (p6 < 16) ? 0 : (p6 >= 4080) ? 255 : p6 >> 4;
11708 p7 = (p7 < 16) ? 0 : (p7 >= 4080) ? 255 : p7 >> 4;
11709
11710 // store block data
11711 blockData[blockBufferOffset + col] = p0;
11712 blockData[blockBufferOffset + col + 8] = p1;
11713 blockData[blockBufferOffset + col + 16] = p2;
11714 blockData[blockBufferOffset + col + 24] = p3;
11715 blockData[blockBufferOffset + col + 32] = p4;
11716 blockData[blockBufferOffset + col + 40] = p5;
11717 blockData[blockBufferOffset + col + 48] = p6;
11718 blockData[blockBufferOffset + col + 56] = p7;
11719 }
11720 }
11721
11722 function buildComponentData(frame, component) {
11723 var blocksPerLine = component.blocksPerLine;
11724 var blocksPerColumn = component.blocksPerColumn;
11725 var computationBuffer = new Int16Array(64);
11726
11727 for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
11728 for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
11729 var offset = getBlockBufferOffset(component, blockRow, blockCol);
11730 quantizeAndInverse(component, offset, computationBuffer);
11731 }
11732 }
11733 return component.blockData;
11734 }
11735
11736 function clamp0to255(a) {
11737 return a <= 0 ? 0 : a >= 255 ? 255 : a;
11738 }
11739
11740 JpegImage.prototype = {
11741 parse: function parse(data) {
11742
11743 function readUint16() {
11744 var value = (data[offset] << 8) | data[offset + 1];
11745 offset += 2;
11746 return value;
11747 }
11748
11749 function readDataBlock() {
11750 var length = readUint16();
11751 var array = data.subarray(offset, offset + length - 2);
11752 offset += array.length;
11753 return array;
11754 }
11755
11756 function prepareComponents(frame) {
11757 var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
11758 var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
11759 for (var i = 0; i < frame.components.length; i++) {
11760 component = frame.components[i];
11761 var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) *
11762 component.h / frame.maxH);
11763 var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) *
11764 component.v / frame.maxV);
11765 var blocksPerLineForMcu = mcusPerLine * component.h;
11766 var blocksPerColumnForMcu = mcusPerColumn * component.v;
11767
11768 var blocksBufferSize = 64 * blocksPerColumnForMcu *
11769 (blocksPerLineForMcu + 1);
11770 component.blockData = new Int16Array(blocksBufferSize);
11771 component.blocksPerLine = blocksPerLine;
11772 component.blocksPerColumn = blocksPerColumn;
11773 }
11774 frame.mcusPerLine = mcusPerLine;
11775 frame.mcusPerColumn = mcusPerColumn;
11776 }
11777
11778 var offset = 0;
11779 var jfif = null;
11780 var adobe = null;
11781 var frame, resetInterval;
11782 var quantizationTables = [];
11783 var huffmanTablesAC = [], huffmanTablesDC = [];
11784 var fileMarker = readUint16();
11785 if (fileMarker !== 0xFFD8) { // SOI (Start of Image)
11786 error('JPEG error: SOI not found');
11787 }
11788
11789 fileMarker = readUint16();
11790 while (fileMarker !== 0xFFD9) { // EOI (End of image)
11791 var i, j, l;
11792 switch(fileMarker) {
11793 case 0xFFE0: // APP0 (Application Specific)
11794 case 0xFFE1: // APP1
11795 case 0xFFE2: // APP2
11796 case 0xFFE3: // APP3
11797 case 0xFFE4: // APP4
11798 case 0xFFE5: // APP5
11799 case 0xFFE6: // APP6
11800 case 0xFFE7: // APP7
11801 case 0xFFE8: // APP8
11802 case 0xFFE9: // APP9
11803 case 0xFFEA: // APP10
11804 case 0xFFEB: // APP11
11805 case 0xFFEC: // APP12
11806 case 0xFFED: // APP13
11807 case 0xFFEE: // APP14
11808 case 0xFFEF: // APP15
11809 case 0xFFFE: // COM (Comment)
11810 var appData = readDataBlock();
11811
11812 if (fileMarker === 0xFFE0) {
11813 if (appData[0] === 0x4A && appData[1] === 0x46 &&
11814 appData[2] === 0x49 && appData[3] === 0x46 &&
11815 appData[4] === 0) { // 'JFIF\x00'
11816 jfif = {
11817 version: { major: appData[5], minor: appData[6] },
11818 densityUnits: appData[7],
11819 xDensity: (appData[8] << 8) | appData[9],
11820 yDensity: (appData[10] << 8) | appData[11],
11821 thumbWidth: appData[12],
11822 thumbHeight: appData[13],
11823 thumbData: appData.subarray(14, 14 +
11824 3 * appData[12] * appData[13])
11825 };
11826 }
11827 }
11828 // TODO APP1 - Exif
11829 if (fileMarker === 0xFFEE) {
11830 if (appData[0] === 0x41 && appData[1] === 0x64 &&
11831 appData[2] === 0x6F && appData[3] === 0x62 &&
11832 appData[4] === 0x65) { // 'Adobe'
11833 adobe = {
11834 version: (appData[5] << 8) | appData[6],
11835 flags0: (appData[7] << 8) | appData[8],
11836 flags1: (appData[9] << 8) | appData[10],
11837 transformCode: appData[11]
11838 };
11839 }
11840 }
11841 break;
11842
11843 case 0xFFDB: // DQT (Define Quantization Tables)
11844 var quantizationTablesLength = readUint16();
11845 var quantizationTablesEnd = quantizationTablesLength + offset - 2;
11846 var z;
11847 while (offset < quantizationTablesEnd) {
11848 var quantizationTableSpec = data[offset++];
11849 var tableData = new Uint16Array(64);
11850 if ((quantizationTableSpec >> 4) === 0) { // 8 bit values
11851 for (j = 0; j < 64; j++) {
11852 z = dctZigZag[j];
11853 tableData[z] = data[offset++];
11854 }
11855 } else if ((quantizationTableSpec >> 4) === 1) { //16 bit
11856 for (j = 0; j < 64; j++) {
11857 z = dctZigZag[j];
11858 tableData[z] = readUint16();
11859 }
11860 } else {
11861 error('JPEG error: DQT - invalid table spec');
11862 }
11863 quantizationTables[quantizationTableSpec & 15] = tableData;
11864 }
11865 break;
11866
11867 case 0xFFC0: // SOF0 (Start of Frame, Baseline DCT)
11868 case 0xFFC1: // SOF1 (Start of Frame, Extended DCT)
11869 case 0xFFC2: // SOF2 (Start of Frame, Progressive DCT)
11870 if (frame) {
11871 error('JPEG error: Only single frame JPEGs supported');
11872 }
11873 readUint16(); // skip data length
11874 frame = {};
11875 frame.extended = (fileMarker === 0xFFC1);
11876 frame.progressive = (fileMarker === 0xFFC2);
11877 frame.precision = data[offset++];
11878 frame.scanLines = readUint16();
11879 frame.samplesPerLine = readUint16();
11880 frame.components = [];
11881 frame.componentIds = {};
11882 var componentsCount = data[offset++], componentId;
11883 var maxH = 0, maxV = 0;
11884 for (i = 0; i < componentsCount; i++) {
11885 componentId = data[offset];
11886 var h = data[offset + 1] >> 4;
11887 var v = data[offset + 1] & 15;
11888 if (maxH < h) {
11889 maxH = h;
11890 }
11891 if (maxV < v) {
11892 maxV = v;
11893 }
11894 var qId = data[offset + 2];
11895 l = frame.components.push({
11896 h: h,
11897 v: v,
11898 quantizationId: qId,
11899 quantizationTable: null, // See comment below.
11900 });
11901 frame.componentIds[componentId] = l - 1;
11902 offset += 3;
11903 }
11904 frame.maxH = maxH;
11905 frame.maxV = maxV;
11906 prepareComponents(frame);
11907 break;
11908
11909 case 0xFFC4: // DHT (Define Huffman Tables)
11910 var huffmanLength = readUint16();
11911 for (i = 2; i < huffmanLength;) {
11912 var huffmanTableSpec = data[offset++];
11913 var codeLengths = new Uint8Array(16);
11914 var codeLengthSum = 0;
11915 for (j = 0; j < 16; j++, offset++) {
11916 codeLengthSum += (codeLengths[j] = data[offset]);
11917 }
11918 var huffmanValues = new Uint8Array(codeLengthSum);
11919 for (j = 0; j < codeLengthSum; j++, offset++) {
11920 huffmanValues[j] = data[offset];
11921 }
11922 i += 17 + codeLengthSum;
11923
11924 ((huffmanTableSpec >> 4) === 0 ?
11925 huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] =
11926 buildHuffmanTable(codeLengths, huffmanValues);
11927 }
11928 break;
11929
11930 case 0xFFDD: // DRI (Define Restart Interval)
11931 readUint16(); // skip data length
11932 resetInterval = readUint16();
11933 break;
11934
11935 case 0xFFDA: // SOS (Start of Scan)
11936 var scanLength = readUint16();
11937 var selectorsCount = data[offset++];
11938 var components = [], component;
11939 for (i = 0; i < selectorsCount; i++) {
11940 var componentIndex = frame.componentIds[data[offset++]];
11941 component = frame.components[componentIndex];
11942 var tableSpec = data[offset++];
11943 component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
11944 component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
11945 components.push(component);
11946 }
11947 var spectralStart = data[offset++];
11948 var spectralEnd = data[offset++];
11949 var successiveApproximation = data[offset++];
11950 var processed = decodeScan(data, offset,
11951 frame, components, resetInterval,
11952 spectralStart, spectralEnd,
11953 successiveApproximation >> 4, successiveApproximation & 15);
11954 offset += processed;
11955 break;
11956
11957 case 0xFFFF: // Fill bytes
11958 if (data[offset] !== 0xFF) { // Avoid skipping a valid marker.
11959 offset--;
11960 }
11961 break;
11962
11963 default:
11964 if (data[offset - 3] === 0xFF &&
11965 data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
11966 // could be incorrect encoding -- last 0xFF byte of the previous
11967 // block was eaten by the encoder
11968 offset -= 3;
11969 break;
11970 }
11971 error('JPEG error: unknown marker ' + fileMarker.toString(16));
11972 }
11973 fileMarker = readUint16();
11974 }
11975
11976 this.width = frame.samplesPerLine;
11977 this.height = frame.scanLines;
11978 this.jfif = jfif;
11979 this.adobe = adobe;
11980 this.components = [];
11981 for (i = 0; i < frame.components.length; i++) {
11982 component = frame.components[i];
11983
11984 // Prevent errors when DQT markers are placed after SOF{n} markers,
11985 // by assigning the `quantizationTable` entry after the entire image
11986 // has been parsed (fixes issue7406.pdf).
11987 var quantizationTable = quantizationTables[component.quantizationId];
11988 if (quantizationTable) {
11989 component.quantizationTable = quantizationTable;
11990 }
11991
11992 this.components.push({
11993 output: buildComponentData(frame, component),
11994 scaleX: component.h / frame.maxH,
11995 scaleY: component.v / frame.maxV,
11996 blocksPerLine: component.blocksPerLine,
11997 blocksPerColumn: component.blocksPerColumn
11998 });
11999 }
12000 this.numComponents = this.components.length;
12001 },
12002
12003 _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
12004 var scaleX = this.width / width, scaleY = this.height / height;
12005
12006 var component, componentScaleX, componentScaleY, blocksPerScanline;
12007 var x, y, i, j, k;
12008 var index;
12009 var offset = 0;
12010 var output;
12011 var numComponents = this.components.length;
12012 var dataLength = width * height * numComponents;
12013 var data = new Uint8Array(dataLength);
12014 var xScaleBlockOffset = new Uint32Array(width);
12015 var mask3LSB = 0xfffffff8; // used to clear the 3 LSBs
12016
12017 for (i = 0; i < numComponents; i++) {
12018 component = this.components[i];
12019 componentScaleX = component.scaleX * scaleX;
12020 componentScaleY = component.scaleY * scaleY;
12021 offset = i;
12022 output = component.output;
12023 blocksPerScanline = (component.blocksPerLine + 1) << 3;
12024 // precalculate the xScaleBlockOffset
12025 for (x = 0; x < width; x++) {
12026 j = 0 | (x * componentScaleX);
12027 xScaleBlockOffset[x] = ((j & mask3LSB) << 3) | (j & 7);
12028 }
12029 // linearize the blocks of the component
12030 for (y = 0; y < height; y++) {
12031 j = 0 | (y * componentScaleY);
12032 index = blocksPerScanline * (j & mask3LSB) | ((j & 7) << 3);
12033 for (x = 0; x < width; x++) {
12034 data[offset] = output[index + xScaleBlockOffset[x]];
12035 offset += numComponents;
12036 }
12037 }
12038 }
12039
12040 // decodeTransform contains pairs of multiplier (-256..256) and additive
12041 var transform = this.decodeTransform;
12042 if (transform) {
12043 for (i = 0; i < dataLength;) {
12044 for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
12045 data[i] = ((data[i] * transform[k]) >> 8) + transform[k + 1];
12046 }
12047 }
12048 }
12049 return data;
12050 },
12051
12052 _isColorConversionNeeded: function isColorConversionNeeded() {
12053 if (this.adobe && this.adobe.transformCode) {
12054 // The adobe transform marker overrides any previous setting
12055 return true;
12056 } else if (this.numComponents === 3) {
12057 if (!this.adobe && this.colorTransform === 0) {
12058 // If the Adobe transform marker is not present and the image
12059 // dictionary has a 'ColorTransform' entry, explicitly set to `0`,
12060 // then the colours should *not* be transformed.
12061 return false;
12062 }
12063 return true;
12064 } else { // `this.numComponents !== 3`
12065 if (!this.adobe && this.colorTransform === 1) {
12066 // If the Adobe transform marker is not present and the image
12067 // dictionary has a 'ColorTransform' entry, explicitly set to `1`,
12068 // then the colours should be transformed.
12069 return true;
12070 }
12071 return false;
12072 }
12073 },
12074
12075 _convertYccToRgb: function convertYccToRgb(data) {
12076 var Y, Cb, Cr;
12077 for (var i = 0, length = data.length; i < length; i += 3) {
12078 Y = data[i ];
12079 Cb = data[i + 1];
12080 Cr = data[i + 2];
12081 data[i ] = clamp0to255(Y - 179.456 + 1.402 * Cr);
12082 data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
12083 data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
12084 }
12085 return data;
12086 },
12087
12088 _convertYcckToRgb: function convertYcckToRgb(data) {
12089 var Y, Cb, Cr, k;
12090 var offset = 0;
12091 for (var i = 0, length = data.length; i < length; i += 4) {
12092 Y = data[i];
12093 Cb = data[i + 1];
12094 Cr = data[i + 2];
12095 k = data[i + 3];
12096
12097 var r = -122.67195406894 +
12098 Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr -
12099 5.4080610064599e-5 * Y + 0.00048449797120281 * k -
12100 0.154362151871126) +
12101 Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y -
12102 0.00477271405408747 * k + 1.53380253221734) +
12103 Y * (0.000961250184130688 * Y - 0.00266257332283933 * k +
12104 0.48357088451265) +
12105 k * (-0.000336197177618394 * k + 0.484791561490776);
12106
12107 var g = 107.268039397724 +
12108 Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr +
12109 0.000659397001245577 * Y + 0.000426105652938837 * k -
12110 0.176491792462875) +
12111 Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y +
12112 0.000770482631801132 * k - 0.151051492775562) +
12113 Y * (0.00126935368114843 * Y - 0.00265090189010898 * k +
12114 0.25802910206845) +
12115 k * (-0.000318913117588328 * k - 0.213742400323665);
12116
12117 var b = -20.810012546947 +
12118 Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr +
12119 0.0020741088115012 * Y - 0.00288260236853442 * k +
12120 0.814272968359295) +
12121 Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y +
12122 0.000560833691242812 * k - 0.195152027534049) +
12123 Y * (0.00174418132927582 * Y - 0.00255243321439347 * k +
12124 0.116935020465145) +
12125 k * (-0.000343531996510555 * k + 0.24165260232407);
12126
12127 data[offset++] = clamp0to255(r);
12128 data[offset++] = clamp0to255(g);
12129 data[offset++] = clamp0to255(b);
12130 }
12131 return data;
12132 },
12133
12134 _convertYcckToCmyk: function convertYcckToCmyk(data) {
12135 var Y, Cb, Cr;
12136 for (var i = 0, length = data.length; i < length; i += 4) {
12137 Y = data[i];
12138 Cb = data[i + 1];
12139 Cr = data[i + 2];
12140 data[i ] = clamp0to255(434.456 - Y - 1.402 * Cr);
12141 data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
12142 data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
12143 // K in data[i + 3] is unchanged
12144 }
12145 return data;
12146 },
12147
12148 _convertCmykToRgb: function convertCmykToRgb(data) {
12149 var c, m, y, k;
12150 var offset = 0;
12151 var min = -255 * 255 * 255;
12152 var scale = 1 / 255 / 255;
12153 for (var i = 0, length = data.length; i < length; i += 4) {
12154 c = data[i];
12155 m = data[i + 1];
12156 y = data[i + 2];
12157 k = data[i + 3];
12158
12159 var r =
12160 c * (-4.387332384609988 * c + 54.48615194189176 * m +
12161 18.82290502165302 * y + 212.25662451639585 * k -
12162 72734.4411664936) +
12163 m * (1.7149763477362134 * m - 5.6096736904047315 * y -
12164 17.873870861415444 * k - 1401.7366389350734) +
12165 y * (-2.5217340131683033 * y - 21.248923337353073 * k +
12166 4465.541406466231) -
12167 k * (21.86122147463605 * k + 48317.86113160301);
12168 var g =
12169 c * (8.841041422036149 * c + 60.118027045597366 * m +
12170 6.871425592049007 * y + 31.159100130055922 * k -
12171 20220.756542821975) +
12172 m * (-15.310361306967817 * m + 17.575251261109482 * y +
12173 131.35250912493976 * k - 48691.05921601825) +
12174 y * (4.444339102852739 * y + 9.8632861493405 * k -
12175 6341.191035517494) -
12176 k * (20.737325471181034 * k + 47890.15695978492);
12177 var b =
12178 c * (0.8842522430003296 * c + 8.078677503112928 * m +
12179 30.89978309703729 * y - 0.23883238689178934 * k -
12180 3616.812083916688) +
12181 m * (10.49593273432072 * m + 63.02378494754052 * y +
12182 50.606957656360734 * k - 28620.90484698408) +
12183 y * (0.03296041114873217 * y + 115.60384449646641 * k -
12184 49363.43385999684) -
12185 k * (22.33816807309886 * k + 45932.16563550634);
12186
12187 data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
12188 data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
12189 data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
12190 }
12191 return data;
12192 },
12193
12194 getData: function getData(width, height, forceRGBoutput) {
12195 if (this.numComponents > 4) {
12196 error('JPEG error: Unsupported color mode');
12197 }
12198 // type of data: Uint8Array(width * height * numComponents)
12199 var data = this._getLinearizedBlockData(width, height);
12200
12201 if (this.numComponents === 1 && forceRGBoutput) {
12202 var dataLength = data.length;
12203 var rgbData = new Uint8Array(dataLength * 3);
12204 var offset = 0;
12205 for (var i = 0; i < dataLength; i++) {
12206 var grayColor = data[i];
12207 rgbData[offset++] = grayColor;
12208 rgbData[offset++] = grayColor;
12209 rgbData[offset++] = grayColor;
12210 }
12211 return rgbData;
12212 } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
12213 return this._convertYccToRgb(data);
12214 } else if (this.numComponents === 4) {
12215 if (this._isColorConversionNeeded()) {
12216 if (forceRGBoutput) {
12217 return this._convertYcckToRgb(data);
12218 } else {
12219 return this._convertYcckToCmyk(data);
12220 }
12221 } else if (forceRGBoutput) {
12222 return this._convertCmykToRgb(data);
12223 }
12224 }
12225 return data;
12226 }
12227 };
12228
12229 return JpegImage;
12230})();
12231
12232exports.JpegImage = JpegImage;
12233}));
12234
12235
12236(function (root, factory) {
12237 {
12238 factory((root.pdfjsCoreJpx = {}), root.pdfjsSharedUtil,
12239 root.pdfjsCoreArithmeticDecoder);
12240 }
12241}(this, function (exports, sharedUtil, coreArithmeticDecoder) {
12242
12243var info = sharedUtil.info;
12244var warn = sharedUtil.warn;
12245var error = sharedUtil.error;
12246var log2 = sharedUtil.log2;
12247var readUint16 = sharedUtil.readUint16;
12248var readUint32 = sharedUtil.readUint32;
12249var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
12250
12251var JpxImage = (function JpxImageClosure() {
12252 // Table E.1
12253 var SubbandsGainLog2 = {
12254 'LL': 0,
12255 'LH': 1,
12256 'HL': 1,
12257 'HH': 2
12258 };
12259 function JpxImage() {
12260 this.failOnCorruptedImage = false;
12261 }
12262 JpxImage.prototype = {
12263 parse: function JpxImage_parse(data) {
12264
12265 var head = readUint16(data, 0);
12266 // No box header, immediate start of codestream (SOC)
12267 if (head === 0xFF4F) {
12268 this.parseCodestream(data, 0, data.length);
12269 return;
12270 }
12271
12272 var position = 0, length = data.length;
12273 while (position < length) {
12274 var headerSize = 8;
12275 var lbox = readUint32(data, position);
12276 var tbox = readUint32(data, position + 4);
12277 position += headerSize;
12278 if (lbox === 1) {
12279 // XLBox: read UInt64 according to spec.
12280 // JavaScript's int precision of 53 bit should be sufficient here.
12281 lbox = readUint32(data, position) * 4294967296 +
12282 readUint32(data, position + 4);
12283 position += 8;
12284 headerSize += 8;
12285 }
12286 if (lbox === 0) {
12287 lbox = length - position + headerSize;
12288 }
12289 if (lbox < headerSize) {
12290 error('JPX Error: Invalid box field size');
12291 }
12292 var dataLength = lbox - headerSize;
12293 var jumpDataLength = true;
12294 switch (tbox) {
12295 case 0x6A703268: // 'jp2h'
12296 jumpDataLength = false; // parsing child boxes
12297 break;
12298 case 0x636F6C72: // 'colr'
12299 // Colorspaces are not used, the CS from the PDF is used.
12300 var method = data[position];
12301 if (method === 1) {
12302 // enumerated colorspace
12303 var colorspace = readUint32(data, position + 3);
12304 switch (colorspace) {
12305 case 16: // this indicates a sRGB colorspace
12306 case 17: // this indicates a grayscale colorspace
12307 case 18: // this indicates a YUV colorspace
12308 break;
12309 default:
12310 warn('Unknown colorspace ' + colorspace);
12311 break;
12312 }
12313 } else if (method === 2) {
12314 info('ICC profile not supported');
12315 }
12316 break;
12317 case 0x6A703263: // 'jp2c'
12318 this.parseCodestream(data, position, position + dataLength);
12319 break;
12320 case 0x6A502020: // 'jP\024\024'
12321 if (0x0d0a870a !== readUint32(data, position)) {
12322 warn('Invalid JP2 signature');
12323 }
12324 break;
12325 // The following header types are valid but currently not used:
12326 case 0x6A501A1A: // 'jP\032\032'
12327 case 0x66747970: // 'ftyp'
12328 case 0x72726571: // 'rreq'
12329 case 0x72657320: // 'res '
12330 case 0x69686472: // 'ihdr'
12331 break;
12332 default:
12333 var headerType = String.fromCharCode((tbox >> 24) & 0xFF,
12334 (tbox >> 16) & 0xFF,
12335 (tbox >> 8) & 0xFF,
12336 tbox & 0xFF);
12337 warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
12338 break;
12339 }
12340 if (jumpDataLength) {
12341 position += dataLength;
12342 }
12343 }
12344 },
12345 parseImageProperties: function JpxImage_parseImageProperties(stream) {
12346 var newByte = stream.getByte();
12347 while (newByte >= 0) {
12348 var oldByte = newByte;
12349 newByte = stream.getByte();
12350 var code = (oldByte << 8) | newByte;
12351 // Image and tile size (SIZ)
12352 if (code === 0xFF51) {
12353 stream.skip(4);
12354 var Xsiz = stream.getInt32() >>> 0; // Byte 4
12355 var Ysiz = stream.getInt32() >>> 0; // Byte 8
12356 var XOsiz = stream.getInt32() >>> 0; // Byte 12
12357 var YOsiz = stream.getInt32() >>> 0; // Byte 16
12358 stream.skip(16);
12359 var Csiz = stream.getUint16(); // Byte 36
12360 this.width = Xsiz - XOsiz;
12361 this.height = Ysiz - YOsiz;
12362 this.componentsCount = Csiz;
12363 // Results are always returned as Uint8Arrays
12364 this.bitsPerComponent = 8;
12365 return;
12366 }
12367 }
12368 error('JPX Error: No size marker found in JPX stream');
12369 },
12370 parseCodestream: function JpxImage_parseCodestream(data, start, end) {
12371 var context = {};
12372 var doNotRecover = false;
12373 try {
12374 var position = start;
12375 while (position + 1 < end) {
12376 var code = readUint16(data, position);
12377 position += 2;
12378
12379 var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
12380 switch (code) {
12381 case 0xFF4F: // Start of codestream (SOC)
12382 context.mainHeader = true;
12383 break;
12384 case 0xFFD9: // End of codestream (EOC)
12385 break;
12386 case 0xFF51: // Image and tile size (SIZ)
12387 length = readUint16(data, position);
12388 var siz = {};
12389 siz.Xsiz = readUint32(data, position + 4);
12390 siz.Ysiz = readUint32(data, position + 8);
12391 siz.XOsiz = readUint32(data, position + 12);
12392 siz.YOsiz = readUint32(data, position + 16);
12393 siz.XTsiz = readUint32(data, position + 20);
12394 siz.YTsiz = readUint32(data, position + 24);
12395 siz.XTOsiz = readUint32(data, position + 28);
12396 siz.YTOsiz = readUint32(data, position + 32);
12397 var componentsCount = readUint16(data, position + 36);
12398 siz.Csiz = componentsCount;
12399 var components = [];
12400 j = position + 38;
12401 for (var i = 0; i < componentsCount; i++) {
12402 var component = {
12403 precision: (data[j] & 0x7F) + 1,
12404 isSigned: !!(data[j] & 0x80),
12405 XRsiz: data[j + 1],
12406 YRsiz: data[j + 1]
12407 };
12408 calculateComponentDimensions(component, siz);
12409 components.push(component);
12410 }
12411 context.SIZ = siz;
12412 context.components = components;
12413 calculateTileGrids(context, components);
12414 context.QCC = [];
12415 context.COC = [];
12416 break;
12417 case 0xFF5C: // Quantization default (QCD)
12418 length = readUint16(data, position);
12419 var qcd = {};
12420 j = position + 2;
12421 sqcd = data[j++];
12422 switch (sqcd & 0x1F) {
12423 case 0:
12424 spqcdSize = 8;
12425 scalarExpounded = true;
12426 break;
12427 case 1:
12428 spqcdSize = 16;
12429 scalarExpounded = false;
12430 break;
12431 case 2:
12432 spqcdSize = 16;
12433 scalarExpounded = true;
12434 break;
12435 default:
12436 throw new Error('Invalid SQcd value ' + sqcd);
12437 }
12438 qcd.noQuantization = (spqcdSize === 8);
12439 qcd.scalarExpounded = scalarExpounded;
12440 qcd.guardBits = sqcd >> 5;
12441 spqcds = [];
12442 while (j < length + position) {
12443 var spqcd = {};
12444 if (spqcdSize === 8) {
12445 spqcd.epsilon = data[j++] >> 3;
12446 spqcd.mu = 0;
12447 } else {
12448 spqcd.epsilon = data[j] >> 3;
12449 spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
12450 j += 2;
12451 }
12452 spqcds.push(spqcd);
12453 }
12454 qcd.SPqcds = spqcds;
12455 if (context.mainHeader) {
12456 context.QCD = qcd;
12457 } else {
12458 context.currentTile.QCD = qcd;
12459 context.currentTile.QCC = [];
12460 }
12461 break;
12462 case 0xFF5D: // Quantization component (QCC)
12463 length = readUint16(data, position);
12464 var qcc = {};
12465 j = position + 2;
12466 var cqcc;
12467 if (context.SIZ.Csiz < 257) {
12468 cqcc = data[j++];
12469 } else {
12470 cqcc = readUint16(data, j);
12471 j += 2;
12472 }
12473 sqcd = data[j++];
12474 switch (sqcd & 0x1F) {
12475 case 0:
12476 spqcdSize = 8;
12477 scalarExpounded = true;
12478 break;
12479 case 1:
12480 spqcdSize = 16;
12481 scalarExpounded = false;
12482 break;
12483 case 2:
12484 spqcdSize = 16;
12485 scalarExpounded = true;
12486 break;
12487 default:
12488 throw new Error('Invalid SQcd value ' + sqcd);
12489 }
12490 qcc.noQuantization = (spqcdSize === 8);
12491 qcc.scalarExpounded = scalarExpounded;
12492 qcc.guardBits = sqcd >> 5;
12493 spqcds = [];
12494 while (j < (length + position)) {
12495 spqcd = {};
12496 if (spqcdSize === 8) {
12497 spqcd.epsilon = data[j++] >> 3;
12498 spqcd.mu = 0;
12499 } else {
12500 spqcd.epsilon = data[j] >> 3;
12501 spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
12502 j += 2;
12503 }
12504 spqcds.push(spqcd);
12505 }
12506 qcc.SPqcds = spqcds;
12507 if (context.mainHeader) {
12508 context.QCC[cqcc] = qcc;
12509 } else {
12510 context.currentTile.QCC[cqcc] = qcc;
12511 }
12512 break;
12513 case 0xFF52: // Coding style default (COD)
12514 length = readUint16(data, position);
12515 var cod = {};
12516 j = position + 2;
12517 var scod = data[j++];
12518 cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
12519 cod.sopMarkerUsed = !!(scod & 2);
12520 cod.ephMarkerUsed = !!(scod & 4);
12521 cod.progressionOrder = data[j++];
12522 cod.layersCount = readUint16(data, j);
12523 j += 2;
12524 cod.multipleComponentTransform = data[j++];
12525
12526 cod.decompositionLevelsCount = data[j++];
12527 cod.xcb = (data[j++] & 0xF) + 2;
12528 cod.ycb = (data[j++] & 0xF) + 2;
12529 var blockStyle = data[j++];
12530 cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
12531 cod.resetContextProbabilities = !!(blockStyle & 2);
12532 cod.terminationOnEachCodingPass = !!(blockStyle & 4);
12533 cod.verticalyStripe = !!(blockStyle & 8);
12534 cod.predictableTermination = !!(blockStyle & 16);
12535 cod.segmentationSymbolUsed = !!(blockStyle & 32);
12536 cod.reversibleTransformation = data[j++];
12537 if (cod.entropyCoderWithCustomPrecincts) {
12538 var precinctsSizes = [];
12539 while (j < length + position) {
12540 var precinctsSize = data[j++];
12541 precinctsSizes.push({
12542 PPx: precinctsSize & 0xF,
12543 PPy: precinctsSize >> 4
12544 });
12545 }
12546 cod.precinctsSizes = precinctsSizes;
12547 }
12548 var unsupported = [];
12549 if (cod.selectiveArithmeticCodingBypass) {
12550 unsupported.push('selectiveArithmeticCodingBypass');
12551 }
12552 if (cod.resetContextProbabilities) {
12553 unsupported.push('resetContextProbabilities');
12554 }
12555 if (cod.terminationOnEachCodingPass) {
12556 unsupported.push('terminationOnEachCodingPass');
12557 }
12558 if (cod.verticalyStripe) {
12559 unsupported.push('verticalyStripe');
12560 }
12561 if (cod.predictableTermination) {
12562 unsupported.push('predictableTermination');
12563 }
12564 if (unsupported.length > 0) {
12565 doNotRecover = true;
12566 throw new Error('Unsupported COD options (' +
12567 unsupported.join(', ') + ')');
12568 }
12569 if (context.mainHeader) {
12570 context.COD = cod;
12571 } else {
12572 context.currentTile.COD = cod;
12573 context.currentTile.COC = [];
12574 }
12575 break;
12576 case 0xFF90: // Start of tile-part (SOT)
12577 length = readUint16(data, position);
12578 tile = {};
12579 tile.index = readUint16(data, position + 2);
12580 tile.length = readUint32(data, position + 4);
12581 tile.dataEnd = tile.length + position - 2;
12582 tile.partIndex = data[position + 8];
12583 tile.partsCount = data[position + 9];
12584
12585 context.mainHeader = false;
12586 if (tile.partIndex === 0) {
12587 // reset component specific settings
12588 tile.COD = context.COD;
12589 tile.COC = context.COC.slice(0); // clone of the global COC
12590 tile.QCD = context.QCD;
12591 tile.QCC = context.QCC.slice(0); // clone of the global COC
12592 }
12593 context.currentTile = tile;
12594 break;
12595 case 0xFF93: // Start of data (SOD)
12596 tile = context.currentTile;
12597 if (tile.partIndex === 0) {
12598 initializeTile(context, tile.index);
12599 buildPackets(context);
12600 }
12601
12602 // moving to the end of the data
12603 length = tile.dataEnd - position;
12604 parseTilePackets(context, data, position, length);
12605 break;
12606 case 0xFF55: // Tile-part lengths, main header (TLM)
12607 case 0xFF57: // Packet length, main header (PLM)
12608 case 0xFF58: // Packet length, tile-part header (PLT)
12609 case 0xFF64: // Comment (COM)
12610 length = readUint16(data, position);
12611 // skipping content
12612 break;
12613 case 0xFF53: // Coding style component (COC)
12614 throw new Error('Codestream code 0xFF53 (COC) is ' +
12615 'not implemented');
12616 default:
12617 throw new Error('Unknown codestream code: ' + code.toString(16));
12618 }
12619 position += length;
12620 }
12621 } catch (e) {
12622 if (doNotRecover || this.failOnCorruptedImage) {
12623 error('JPX Error: ' + e.message);
12624 } else {
12625 warn('JPX: Trying to recover from: ' + e.message);
12626 }
12627 }
12628 this.tiles = transformComponents(context);
12629 this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
12630 this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
12631 this.componentsCount = context.SIZ.Csiz;
12632 }
12633 };
12634 function calculateComponentDimensions(component, siz) {
12635 // Section B.2 Component mapping
12636 component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
12637 component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
12638 component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
12639 component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
12640 component.width = component.x1 - component.x0;
12641 component.height = component.y1 - component.y0;
12642 }
12643 function calculateTileGrids(context, components) {
12644 var siz = context.SIZ;
12645 // Section B.3 Division into tile and tile-components
12646 var tile, tiles = [];
12647 var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
12648 var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
12649 for (var q = 0; q < numYtiles; q++) {
12650 for (var p = 0; p < numXtiles; p++) {
12651 tile = {};
12652 tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
12653 tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
12654 tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
12655 tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
12656 tile.width = tile.tx1 - tile.tx0;
12657 tile.height = tile.ty1 - tile.ty0;
12658 tile.components = [];
12659 tiles.push(tile);
12660 }
12661 }
12662 context.tiles = tiles;
12663
12664 var componentsCount = siz.Csiz;
12665 for (var i = 0, ii = componentsCount; i < ii; i++) {
12666 var component = components[i];
12667 for (var j = 0, jj = tiles.length; j < jj; j++) {
12668 var tileComponent = {};
12669 tile = tiles[j];
12670 tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
12671 tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
12672 tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
12673 tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
12674 tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
12675 tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
12676 tile.components[i] = tileComponent;
12677 }
12678 }
12679 }
12680 function getBlocksDimensions(context, component, r) {
12681 var codOrCoc = component.codingStyleParameters;
12682 var result = {};
12683 if (!codOrCoc.entropyCoderWithCustomPrecincts) {
12684 result.PPx = 15;
12685 result.PPy = 15;
12686 } else {
12687 result.PPx = codOrCoc.precinctsSizes[r].PPx;
12688 result.PPy = codOrCoc.precinctsSizes[r].PPy;
12689 }
12690 // calculate codeblock size as described in section B.7
12691 result.xcb_ = (r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) :
12692 Math.min(codOrCoc.xcb, result.PPx));
12693 result.ycb_ = (r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) :
12694 Math.min(codOrCoc.ycb, result.PPy));
12695 return result;
12696 }
12697 function buildPrecincts(context, resolution, dimensions) {
12698 // Section B.6 Division resolution to precincts
12699 var precinctWidth = 1 << dimensions.PPx;
12700 var precinctHeight = 1 << dimensions.PPy;
12701 // Jasper introduces codeblock groups for mapping each subband codeblocks
12702 // to precincts. Precinct partition divides a resolution according to width
12703 // and height parameters. The subband that belongs to the resolution level
12704 // has a different size than the level, unless it is the zero resolution.
12705
12706 // From Jasper documentation: jpeg2000.pdf, section K: Tier-2 coding:
12707 // The precinct partitioning for a particular subband is derived from a
12708 // partitioning of its parent LL band (i.e., the LL band at the next higher
12709 // resolution level)... The LL band associated with each resolution level is
12710 // divided into precincts... Each of the resulting precinct regions is then
12711 // mapped into its child subbands (if any) at the next lower resolution
12712 // level. This is accomplished by using the coordinate transformation
12713 // (u, v) = (ceil(x/2), ceil(y/2)) where (x, y) and (u, v) are the
12714 // coordinates of a point in the LL band and child subband, respectively.
12715 var isZeroRes = resolution.resLevel === 0;
12716 var precinctWidthInSubband = 1 << (dimensions.PPx + (isZeroRes ? 0 : -1));
12717 var precinctHeightInSubband = 1 << (dimensions.PPy + (isZeroRes ? 0 : -1));
12718 var numprecinctswide = (resolution.trx1 > resolution.trx0 ?
12719 Math.ceil(resolution.trx1 / precinctWidth) -
12720 Math.floor(resolution.trx0 / precinctWidth) : 0);
12721 var numprecinctshigh = (resolution.try1 > resolution.try0 ?
12722 Math.ceil(resolution.try1 / precinctHeight) -
12723 Math.floor(resolution.try0 / precinctHeight) : 0);
12724 var numprecincts = numprecinctswide * numprecinctshigh;
12725
12726 resolution.precinctParameters = {
12727 precinctWidth: precinctWidth,
12728 precinctHeight: precinctHeight,
12729 numprecinctswide: numprecinctswide,
12730 numprecinctshigh: numprecinctshigh,
12731 numprecincts: numprecincts,
12732 precinctWidthInSubband: precinctWidthInSubband,
12733 precinctHeightInSubband: precinctHeightInSubband
12734 };
12735 }
12736 function buildCodeblocks(context, subband, dimensions) {
12737 // Section B.7 Division sub-band into code-blocks
12738 var xcb_ = dimensions.xcb_;
12739 var ycb_ = dimensions.ycb_;
12740 var codeblockWidth = 1 << xcb_;
12741 var codeblockHeight = 1 << ycb_;
12742 var cbx0 = subband.tbx0 >> xcb_;
12743 var cby0 = subband.tby0 >> ycb_;
12744 var cbx1 = (subband.tbx1 + codeblockWidth - 1) >> xcb_;
12745 var cby1 = (subband.tby1 + codeblockHeight - 1) >> ycb_;
12746 var precinctParameters = subband.resolution.precinctParameters;
12747 var codeblocks = [];
12748 var precincts = [];
12749 var i, j, codeblock, precinctNumber;
12750 for (j = cby0; j < cby1; j++) {
12751 for (i = cbx0; i < cbx1; i++) {
12752 codeblock = {
12753 cbx: i,
12754 cby: j,
12755 tbx0: codeblockWidth * i,
12756 tby0: codeblockHeight * j,
12757 tbx1: codeblockWidth * (i + 1),
12758 tby1: codeblockHeight * (j + 1)
12759 };
12760
12761 codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
12762 codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
12763 codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
12764 codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
12765
12766 // Calculate precinct number for this codeblock, codeblock position
12767 // should be relative to its subband, use actual dimension and position
12768 // See comment about codeblock group width and height
12769 var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) /
12770 precinctParameters.precinctWidthInSubband);
12771 var pj = Math.floor((codeblock.tby0_ - subband.tby0) /
12772 precinctParameters.precinctHeightInSubband);
12773 precinctNumber = pi + (pj * precinctParameters.numprecinctswide);
12774
12775 codeblock.precinctNumber = precinctNumber;
12776 codeblock.subbandType = subband.type;
12777 codeblock.Lblock = 3;
12778
12779 if (codeblock.tbx1_ <= codeblock.tbx0_ ||
12780 codeblock.tby1_ <= codeblock.tby0_) {
12781 continue;
12782 }
12783 codeblocks.push(codeblock);
12784 // building precinct for the sub-band
12785 var precinct = precincts[precinctNumber];
12786 if (precinct !== undefined) {
12787 if (i < precinct.cbxMin) {
12788 precinct.cbxMin = i;
12789 } else if (i > precinct.cbxMax) {
12790 precinct.cbxMax = i;
12791 }
12792 if (j < precinct.cbyMin) {
12793 precinct.cbxMin = j;
12794 } else if (j > precinct.cbyMax) {
12795 precinct.cbyMax = j;
12796 }
12797 } else {
12798 precincts[precinctNumber] = precinct = {
12799 cbxMin: i,
12800 cbyMin: j,
12801 cbxMax: i,
12802 cbyMax: j
12803 };
12804 }
12805 codeblock.precinct = precinct;
12806 }
12807 }
12808 subband.codeblockParameters = {
12809 codeblockWidth: xcb_,
12810 codeblockHeight: ycb_,
12811 numcodeblockwide: cbx1 - cbx0 + 1,
12812 numcodeblockhigh: cby1 - cby0 + 1
12813 };
12814 subband.codeblocks = codeblocks;
12815 subband.precincts = precincts;
12816 }
12817 function createPacket(resolution, precinctNumber, layerNumber) {
12818 var precinctCodeblocks = [];
12819 // Section B.10.8 Order of info in packet
12820 var subbands = resolution.subbands;
12821 // sub-bands already ordered in 'LL', 'HL', 'LH', and 'HH' sequence
12822 for (var i = 0, ii = subbands.length; i < ii; i++) {
12823 var subband = subbands[i];
12824 var codeblocks = subband.codeblocks;
12825 for (var j = 0, jj = codeblocks.length; j < jj; j++) {
12826 var codeblock = codeblocks[j];
12827 if (codeblock.precinctNumber !== precinctNumber) {
12828 continue;
12829 }
12830 precinctCodeblocks.push(codeblock);
12831 }
12832 }
12833 return {
12834 layerNumber: layerNumber,
12835 codeblocks: precinctCodeblocks
12836 };
12837 }
12838 function LayerResolutionComponentPositionIterator(context) {
12839 var siz = context.SIZ;
12840 var tileIndex = context.currentTile.index;
12841 var tile = context.tiles[tileIndex];
12842 var layersCount = tile.codingStyleDefaultParameters.layersCount;
12843 var componentsCount = siz.Csiz;
12844 var maxDecompositionLevelsCount = 0;
12845 for (var q = 0; q < componentsCount; q++) {
12846 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount,
12847 tile.components[q].codingStyleParameters.decompositionLevelsCount);
12848 }
12849
12850 var l = 0, r = 0, i = 0, k = 0;
12851
12852 this.nextPacket = function JpxImage_nextPacket() {
12853 // Section B.12.1.1 Layer-resolution-component-position
12854 for (; l < layersCount; l++) {
12855 for (; r <= maxDecompositionLevelsCount; r++) {
12856 for (; i < componentsCount; i++) {
12857 var component = tile.components[i];
12858 if (r > component.codingStyleParameters.decompositionLevelsCount) {
12859 continue;
12860 }
12861
12862 var resolution = component.resolutions[r];
12863 var numprecincts = resolution.precinctParameters.numprecincts;
12864 for (; k < numprecincts;) {
12865 var packet = createPacket(resolution, k, l);
12866 k++;
12867 return packet;
12868 }
12869 k = 0;
12870 }
12871 i = 0;
12872 }
12873 r = 0;
12874 }
12875 error('JPX Error: Out of packets');
12876 };
12877 }
12878 function ResolutionLayerComponentPositionIterator(context) {
12879 var siz = context.SIZ;
12880 var tileIndex = context.currentTile.index;
12881 var tile = context.tiles[tileIndex];
12882 var layersCount = tile.codingStyleDefaultParameters.layersCount;
12883 var componentsCount = siz.Csiz;
12884 var maxDecompositionLevelsCount = 0;
12885 for (var q = 0; q < componentsCount; q++) {
12886 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount,
12887 tile.components[q].codingStyleParameters.decompositionLevelsCount);
12888 }
12889
12890 var r = 0, l = 0, i = 0, k = 0;
12891
12892 this.nextPacket = function JpxImage_nextPacket() {
12893 // Section B.12.1.2 Resolution-layer-component-position
12894 for (; r <= maxDecompositionLevelsCount; r++) {
12895 for (; l < layersCount; l++) {
12896 for (; i < componentsCount; i++) {
12897 var component = tile.components[i];
12898 if (r > component.codingStyleParameters.decompositionLevelsCount) {
12899 continue;
12900 }
12901
12902 var resolution = component.resolutions[r];
12903 var numprecincts = resolution.precinctParameters.numprecincts;
12904 for (; k < numprecincts;) {
12905 var packet = createPacket(resolution, k, l);
12906 k++;
12907 return packet;
12908 }
12909 k = 0;
12910 }
12911 i = 0;
12912 }
12913 l = 0;
12914 }
12915 error('JPX Error: Out of packets');
12916 };
12917 }
12918 function ResolutionPositionComponentLayerIterator(context) {
12919 var siz = context.SIZ;
12920 var tileIndex = context.currentTile.index;
12921 var tile = context.tiles[tileIndex];
12922 var layersCount = tile.codingStyleDefaultParameters.layersCount;
12923 var componentsCount = siz.Csiz;
12924 var l, r, c, p;
12925 var maxDecompositionLevelsCount = 0;
12926 for (c = 0; c < componentsCount; c++) {
12927 var component = tile.components[c];
12928 maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount,
12929 component.codingStyleParameters.decompositionLevelsCount);
12930 }
12931 var maxNumPrecinctsInLevel = new Int32Array(
12932 maxDecompositionLevelsCount + 1);
12933 for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
12934 var maxNumPrecincts = 0;
12935 for (c = 0; c < componentsCount; ++c) {
12936 var resolutions = tile.components[c].resolutions;
12937 if (r < resolutions.length) {
12938 maxNumPrecincts = Math.max(maxNumPrecincts,
12939 resolutions[r].precinctParameters.numprecincts);
12940 }
12941 }
12942 maxNumPrecinctsInLevel[r] = maxNumPrecincts;
12943 }
12944 l = 0;
12945 r = 0;
12946 c = 0;
12947 p = 0;
12948
12949 this.nextPacket = function JpxImage_nextPacket() {
12950 // Section B.12.1.3 Resolution-position-component-layer
12951 for (; r <= maxDecompositionLevelsCount; r++) {
12952 for (; p < maxNumPrecinctsInLevel[r]; p++) {
12953 for (; c < componentsCount; c++) {
12954 var component = tile.components[c];
12955 if (r > component.codingStyleParameters.decompositionLevelsCount) {
12956 continue;
12957 }
12958 var resolution = component.resolutions[r];
12959 var numprecincts = resolution.precinctParameters.numprecincts;
12960 if (p >= numprecincts) {
12961 continue;
12962 }
12963 for (; l < layersCount;) {
12964 var packet = createPacket(resolution, p, l);
12965 l++;
12966 return packet;
12967 }
12968 l = 0;
12969 }
12970 c = 0;
12971 }
12972 p = 0;
12973 }
12974 error('JPX Error: Out of packets');
12975 };
12976 }
12977 function PositionComponentResolutionLayerIterator(context) {
12978 var siz = context.SIZ;
12979 var tileIndex = context.currentTile.index;
12980 var tile = context.tiles[tileIndex];
12981 var layersCount = tile.codingStyleDefaultParameters.layersCount;
12982 var componentsCount = siz.Csiz;
12983 var precinctsSizes = getPrecinctSizesInImageScale(tile);
12984 var precinctsIterationSizes = precinctsSizes;
12985 var l = 0, r = 0, c = 0, px = 0, py = 0;
12986
12987 this.nextPacket = function JpxImage_nextPacket() {
12988 // Section B.12.1.4 Position-component-resolution-layer
12989 for (; py < precinctsIterationSizes.maxNumHigh; py++) {
12990 for (; px < precinctsIterationSizes.maxNumWide; px++) {
12991 for (; c < componentsCount; c++) {
12992 var component = tile.components[c];
12993 var decompositionLevelsCount =
12994 component.codingStyleParameters.decompositionLevelsCount;
12995 for (; r <= decompositionLevelsCount; r++) {
12996 var resolution = component.resolutions[r];
12997 var sizeInImageScale =
12998 precinctsSizes.components[c].resolutions[r];
12999 var k = getPrecinctIndexIfExist(
13000 px,
13001 py,
13002 sizeInImageScale,
13003 precinctsIterationSizes,
13004 resolution);
13005 if (k === null) {
13006 continue;
13007 }
13008 for (; l < layersCount;) {
13009 var packet = createPacket(resolution, k, l);
13010 l++;
13011 return packet;
13012 }
13013 l = 0;
13014 }
13015 r = 0;
13016 }
13017 c = 0;
13018 }
13019 px = 0;
13020 }
13021 error('JPX Error: Out of packets');
13022 };
13023 }
13024 function ComponentPositionResolutionLayerIterator(context) {
13025 var siz = context.SIZ;
13026 var tileIndex = context.currentTile.index;
13027 var tile = context.tiles[tileIndex];
13028 var layersCount = tile.codingStyleDefaultParameters.layersCount;
13029 var componentsCount = siz.Csiz;
13030 var precinctsSizes = getPrecinctSizesInImageScale(tile);
13031 var l = 0, r = 0, c = 0, px = 0, py = 0;
13032
13033 this.nextPacket = function JpxImage_nextPacket() {
13034 // Section B.12.1.5 Component-position-resolution-layer
13035 for (; c < componentsCount; ++c) {
13036 var component = tile.components[c];
13037 var precinctsIterationSizes = precinctsSizes.components[c];
13038 var decompositionLevelsCount =
13039 component.codingStyleParameters.decompositionLevelsCount;
13040 for (; py < precinctsIterationSizes.maxNumHigh; py++) {
13041 for (; px < precinctsIterationSizes.maxNumWide; px++) {
13042 for (; r <= decompositionLevelsCount; r++) {
13043 var resolution = component.resolutions[r];
13044 var sizeInImageScale = precinctsIterationSizes.resolutions[r];
13045 var k = getPrecinctIndexIfExist(
13046 px,
13047 py,
13048 sizeInImageScale,
13049 precinctsIterationSizes,
13050 resolution);
13051 if (k === null) {
13052 continue;
13053 }
13054 for (; l < layersCount;) {
13055 var packet = createPacket(resolution, k, l);
13056 l++;
13057 return packet;
13058 }
13059 l = 0;
13060 }
13061 r = 0;
13062 }
13063 px = 0;
13064 }
13065 py = 0;
13066 }
13067 error('JPX Error: Out of packets');
13068 };
13069 }
13070 function getPrecinctIndexIfExist(
13071 pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
13072 var posX = pxIndex * precinctIterationSizes.minWidth;
13073 var posY = pyIndex * precinctIterationSizes.minHeight;
13074 if (posX % sizeInImageScale.width !== 0 ||
13075 posY % sizeInImageScale.height !== 0) {
13076 return null;
13077 }
13078 var startPrecinctRowIndex =
13079 (posY / sizeInImageScale.width) *
13080 resolution.precinctParameters.numprecinctswide;
13081 return (posX / sizeInImageScale.height) + startPrecinctRowIndex;
13082 }
13083 function getPrecinctSizesInImageScale(tile) {
13084 var componentsCount = tile.components.length;
13085 var minWidth = Number.MAX_VALUE;
13086 var minHeight = Number.MAX_VALUE;
13087 var maxNumWide = 0;
13088 var maxNumHigh = 0;
13089 var sizePerComponent = new Array(componentsCount);
13090 for (var c = 0; c < componentsCount; c++) {
13091 var component = tile.components[c];
13092 var decompositionLevelsCount =
13093 component.codingStyleParameters.decompositionLevelsCount;
13094 var sizePerResolution = new Array(decompositionLevelsCount + 1);
13095 var minWidthCurrentComponent = Number.MAX_VALUE;
13096 var minHeightCurrentComponent = Number.MAX_VALUE;
13097 var maxNumWideCurrentComponent = 0;
13098 var maxNumHighCurrentComponent = 0;
13099 var scale = 1;
13100 for (var r = decompositionLevelsCount; r >= 0; --r) {
13101 var resolution = component.resolutions[r];
13102 var widthCurrentResolution =
13103 scale * resolution.precinctParameters.precinctWidth;
13104 var heightCurrentResolution =
13105 scale * resolution.precinctParameters.precinctHeight;
13106 minWidthCurrentComponent = Math.min(
13107 minWidthCurrentComponent,
13108 widthCurrentResolution);
13109 minHeightCurrentComponent = Math.min(
13110 minHeightCurrentComponent,
13111 heightCurrentResolution);
13112 maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent,
13113 resolution.precinctParameters.numprecinctswide);
13114 maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent,
13115 resolution.precinctParameters.numprecinctshigh);
13116 sizePerResolution[r] = {
13117 width: widthCurrentResolution,
13118 height: heightCurrentResolution
13119 };
13120 scale <<= 1;
13121 }
13122 minWidth = Math.min(minWidth, minWidthCurrentComponent);
13123 minHeight = Math.min(minHeight, minHeightCurrentComponent);
13124 maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
13125 maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
13126 sizePerComponent[c] = {
13127 resolutions: sizePerResolution,
13128 minWidth: minWidthCurrentComponent,
13129 minHeight: minHeightCurrentComponent,
13130 maxNumWide: maxNumWideCurrentComponent,
13131 maxNumHigh: maxNumHighCurrentComponent
13132 };
13133 }
13134 return {
13135 components: sizePerComponent,
13136 minWidth: minWidth,
13137 minHeight: minHeight,
13138 maxNumWide: maxNumWide,
13139 maxNumHigh: maxNumHigh
13140 };
13141 }
13142 function buildPackets(context) {
13143 var siz = context.SIZ;
13144 var tileIndex = context.currentTile.index;
13145 var tile = context.tiles[tileIndex];
13146 var componentsCount = siz.Csiz;
13147 // Creating resolutions and sub-bands for each component
13148 for (var c = 0; c < componentsCount; c++) {
13149 var component = tile.components[c];
13150 var decompositionLevelsCount =
13151 component.codingStyleParameters.decompositionLevelsCount;
13152 // Section B.5 Resolution levels and sub-bands
13153 var resolutions = [];
13154 var subbands = [];
13155 for (var r = 0; r <= decompositionLevelsCount; r++) {
13156 var blocksDimensions = getBlocksDimensions(context, component, r);
13157 var resolution = {};
13158 var scale = 1 << (decompositionLevelsCount - r);
13159 resolution.trx0 = Math.ceil(component.tcx0 / scale);
13160 resolution.try0 = Math.ceil(component.tcy0 / scale);
13161 resolution.trx1 = Math.ceil(component.tcx1 / scale);
13162 resolution.try1 = Math.ceil(component.tcy1 / scale);
13163 resolution.resLevel = r;
13164 buildPrecincts(context, resolution, blocksDimensions);
13165 resolutions.push(resolution);
13166
13167 var subband;
13168 if (r === 0) {
13169 // one sub-band (LL) with last decomposition
13170 subband = {};
13171 subband.type = 'LL';
13172 subband.tbx0 = Math.ceil(component.tcx0 / scale);
13173 subband.tby0 = Math.ceil(component.tcy0 / scale);
13174 subband.tbx1 = Math.ceil(component.tcx1 / scale);
13175 subband.tby1 = Math.ceil(component.tcy1 / scale);
13176 subband.resolution = resolution;
13177 buildCodeblocks(context, subband, blocksDimensions);
13178 subbands.push(subband);
13179 resolution.subbands = [subband];
13180 } else {
13181 var bscale = 1 << (decompositionLevelsCount - r + 1);
13182 var resolutionSubbands = [];
13183 // three sub-bands (HL, LH and HH) with rest of decompositions
13184 subband = {};
13185 subband.type = 'HL';
13186 subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
13187 subband.tby0 = Math.ceil(component.tcy0 / bscale);
13188 subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
13189 subband.tby1 = Math.ceil(component.tcy1 / bscale);
13190 subband.resolution = resolution;
13191 buildCodeblocks(context, subband, blocksDimensions);
13192 subbands.push(subband);
13193 resolutionSubbands.push(subband);
13194
13195 subband = {};
13196 subband.type = 'LH';
13197 subband.tbx0 = Math.ceil(component.tcx0 / bscale);
13198 subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
13199 subband.tbx1 = Math.ceil(component.tcx1 / bscale);
13200 subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
13201 subband.resolution = resolution;
13202 buildCodeblocks(context, subband, blocksDimensions);
13203 subbands.push(subband);
13204 resolutionSubbands.push(subband);
13205
13206 subband = {};
13207 subband.type = 'HH';
13208 subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
13209 subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
13210 subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
13211 subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
13212 subband.resolution = resolution;
13213 buildCodeblocks(context, subband, blocksDimensions);
13214 subbands.push(subband);
13215 resolutionSubbands.push(subband);
13216
13217 resolution.subbands = resolutionSubbands;
13218 }
13219 }
13220 component.resolutions = resolutions;
13221 component.subbands = subbands;
13222 }
13223 // Generate the packets sequence
13224 var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
13225 switch (progressionOrder) {
13226 case 0:
13227 tile.packetsIterator =
13228 new LayerResolutionComponentPositionIterator(context);
13229 break;
13230 case 1:
13231 tile.packetsIterator =
13232 new ResolutionLayerComponentPositionIterator(context);
13233 break;
13234 case 2:
13235 tile.packetsIterator =
13236 new ResolutionPositionComponentLayerIterator(context);
13237 break;
13238 case 3:
13239 tile.packetsIterator =
13240 new PositionComponentResolutionLayerIterator(context);
13241 break;
13242 case 4:
13243 tile.packetsIterator =
13244 new ComponentPositionResolutionLayerIterator(context);
13245 break;
13246 default:
13247 error('JPX Error: Unsupported progression order ' + progressionOrder);
13248 }
13249 }
13250 function parseTilePackets(context, data, offset, dataLength) {
13251 var position = 0;
13252 var buffer, bufferSize = 0, skipNextBit = false;
13253 function readBits(count) {
13254 while (bufferSize < count) {
13255 var b = data[offset + position];
13256 position++;
13257 if (skipNextBit) {
13258 buffer = (buffer << 7) | b;
13259 bufferSize += 7;
13260 skipNextBit = false;
13261 } else {
13262 buffer = (buffer << 8) | b;
13263 bufferSize += 8;
13264 }
13265 if (b === 0xFF) {
13266 skipNextBit = true;
13267 }
13268 }
13269 bufferSize -= count;
13270 return (buffer >>> bufferSize) & ((1 << count) - 1);
13271 }
13272 function skipMarkerIfEqual(value) {
13273 if (data[offset + position - 1] === 0xFF &&
13274 data[offset + position] === value) {
13275 skipBytes(1);
13276 return true;
13277 } else if (data[offset + position] === 0xFF &&
13278 data[offset + position + 1] === value) {
13279 skipBytes(2);
13280 return true;
13281 }
13282 return false;
13283 }
13284 function skipBytes(count) {
13285 position += count;
13286 }
13287 function alignToByte() {
13288 bufferSize = 0;
13289 if (skipNextBit) {
13290 position++;
13291 skipNextBit = false;
13292 }
13293 }
13294 function readCodingpasses() {
13295 if (readBits(1) === 0) {
13296 return 1;
13297 }
13298 if (readBits(1) === 0) {
13299 return 2;
13300 }
13301 var value = readBits(2);
13302 if (value < 3) {
13303 return value + 3;
13304 }
13305 value = readBits(5);
13306 if (value < 31) {
13307 return value + 6;
13308 }
13309 value = readBits(7);
13310 return value + 37;
13311 }
13312 var tileIndex = context.currentTile.index;
13313 var tile = context.tiles[tileIndex];
13314 var sopMarkerUsed = context.COD.sopMarkerUsed;
13315 var ephMarkerUsed = context.COD.ephMarkerUsed;
13316 var packetsIterator = tile.packetsIterator;
13317 while (position < dataLength) {
13318 alignToByte();
13319 if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
13320 // Skip also marker segment length and packet sequence ID
13321 skipBytes(4);
13322 }
13323 var packet = packetsIterator.nextPacket();
13324 if (!readBits(1)) {
13325 continue;
13326 }
13327 var layerNumber = packet.layerNumber;
13328 var queue = [], codeblock;
13329 for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
13330 codeblock = packet.codeblocks[i];
13331 var precinct = codeblock.precinct;
13332 var codeblockColumn = codeblock.cbx - precinct.cbxMin;
13333 var codeblockRow = codeblock.cby - precinct.cbyMin;
13334 var codeblockIncluded = false;
13335 var firstTimeInclusion = false;
13336 var valueReady;
13337 if (codeblock['included'] !== undefined) {
13338 codeblockIncluded = !!readBits(1);
13339 } else {
13340 // reading inclusion tree
13341 precinct = codeblock.precinct;
13342 var inclusionTree, zeroBitPlanesTree;
13343 if (precinct['inclusionTree'] !== undefined) {
13344 inclusionTree = precinct.inclusionTree;
13345 } else {
13346 // building inclusion and zero bit-planes trees
13347 var width = precinct.cbxMax - precinct.cbxMin + 1;
13348 var height = precinct.cbyMax - precinct.cbyMin + 1;
13349 inclusionTree = new InclusionTree(width, height, layerNumber);
13350 zeroBitPlanesTree = new TagTree(width, height);
13351 precinct.inclusionTree = inclusionTree;
13352 precinct.zeroBitPlanesTree = zeroBitPlanesTree;
13353 }
13354
13355 if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
13356 while (true) {
13357 if (readBits(1)) {
13358 valueReady = !inclusionTree.nextLevel();
13359 if (valueReady) {
13360 codeblock.included = true;
13361 codeblockIncluded = firstTimeInclusion = true;
13362 break;
13363 }
13364 } else {
13365 inclusionTree.incrementValue(layerNumber);
13366 break;
13367 }
13368 }
13369 }
13370 }
13371 if (!codeblockIncluded) {
13372 continue;
13373 }
13374 if (firstTimeInclusion) {
13375 zeroBitPlanesTree = precinct.zeroBitPlanesTree;
13376 zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
13377 while (true) {
13378 if (readBits(1)) {
13379 valueReady = !zeroBitPlanesTree.nextLevel();
13380 if (valueReady) {
13381 break;
13382 }
13383 } else {
13384 zeroBitPlanesTree.incrementValue();
13385 }
13386 }
13387 codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
13388 }
13389 var codingpasses = readCodingpasses();
13390 while (readBits(1)) {
13391 codeblock.Lblock++;
13392 }
13393 var codingpassesLog2 = log2(codingpasses);
13394 // rounding down log2
13395 var bits = ((codingpasses < (1 << codingpassesLog2)) ?
13396 codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
13397 var codedDataLength = readBits(bits);
13398 queue.push({
13399 codeblock: codeblock,
13400 codingpasses: codingpasses,
13401 dataLength: codedDataLength
13402 });
13403 }
13404 alignToByte();
13405 if (ephMarkerUsed) {
13406 skipMarkerIfEqual(0x92);
13407 }
13408 while (queue.length > 0) {
13409 var packetItem = queue.shift();
13410 codeblock = packetItem.codeblock;
13411 if (codeblock['data'] === undefined) {
13412 codeblock.data = [];
13413 }
13414 codeblock.data.push({
13415 data: data,
13416 start: offset + position,
13417 end: offset + position + packetItem.dataLength,
13418 codingpasses: packetItem.codingpasses
13419 });
13420 position += packetItem.dataLength;
13421 }
13422 }
13423 return position;
13424 }
13425 function copyCoefficients(coefficients, levelWidth, levelHeight, subband,
13426 delta, mb, reversible, segmentationSymbolUsed) {
13427 var x0 = subband.tbx0;
13428 var y0 = subband.tby0;
13429 var width = subband.tbx1 - subband.tbx0;
13430 var codeblocks = subband.codeblocks;
13431 var right = subband.type.charAt(0) === 'H' ? 1 : 0;
13432 var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
13433
13434 for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
13435 var codeblock = codeblocks[i];
13436 var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
13437 var blockHeight = codeblock.tby1_ - codeblock.tby0_;
13438 if (blockWidth === 0 || blockHeight === 0) {
13439 continue;
13440 }
13441 if (codeblock['data'] === undefined) {
13442 continue;
13443 }
13444
13445 var bitModel, currentCodingpassType;
13446 bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType,
13447 codeblock.zeroBitPlanes, mb);
13448 currentCodingpassType = 2; // first bit plane starts from cleanup
13449
13450 // collect data
13451 var data = codeblock.data, totalLength = 0, codingpasses = 0;
13452 var j, jj, dataItem;
13453 for (j = 0, jj = data.length; j < jj; j++) {
13454 dataItem = data[j];
13455 totalLength += dataItem.end - dataItem.start;
13456 codingpasses += dataItem.codingpasses;
13457 }
13458 var encodedData = new Uint8Array(totalLength);
13459 var position = 0;
13460 for (j = 0, jj = data.length; j < jj; j++) {
13461 dataItem = data[j];
13462 var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
13463 encodedData.set(chunk, position);
13464 position += chunk.length;
13465 }
13466 // decoding the item
13467 var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
13468 bitModel.setDecoder(decoder);
13469
13470 for (j = 0; j < codingpasses; j++) {
13471 switch (currentCodingpassType) {
13472 case 0:
13473 bitModel.runSignificancePropagationPass();
13474 break;
13475 case 1:
13476 bitModel.runMagnitudeRefinementPass();
13477 break;
13478 case 2:
13479 bitModel.runCleanupPass();
13480 if (segmentationSymbolUsed) {
13481 bitModel.checkSegmentationSymbol();
13482 }
13483 break;
13484 }
13485 currentCodingpassType = (currentCodingpassType + 1) % 3;
13486 }
13487
13488 var offset = (codeblock.tbx0_ - x0) + (codeblock.tby0_ - y0) * width;
13489 var sign = bitModel.coefficentsSign;
13490 var magnitude = bitModel.coefficentsMagnitude;
13491 var bitsDecoded = bitModel.bitsDecoded;
13492 var magnitudeCorrection = reversible ? 0 : 0.5;
13493 var k, n, nb;
13494 position = 0;
13495 // Do the interleaving of Section F.3.3 here, so we do not need
13496 // to copy later. LL level is not interleaved, just copied.
13497 var interleave = (subband.type !== 'LL');
13498 for (j = 0; j < blockHeight; j++) {
13499 var row = (offset / width) | 0; // row in the non-interleaved subband
13500 var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
13501 for (k = 0; k < blockWidth; k++) {
13502 n = magnitude[position];
13503 if (n !== 0) {
13504 n = (n + magnitudeCorrection) * delta;
13505 if (sign[position] !== 0) {
13506 n = -n;
13507 }
13508 nb = bitsDecoded[position];
13509 var pos = interleave ? (levelOffset + (offset << 1)) : offset;
13510 if (reversible && (nb >= mb)) {
13511 coefficients[pos] = n;
13512 } else {
13513 coefficients[pos] = n * (1 << (mb - nb));
13514 }
13515 }
13516 offset++;
13517 position++;
13518 }
13519 offset += width - blockWidth;
13520 }
13521 }
13522 }
13523 function transformTile(context, tile, c) {
13524 var component = tile.components[c];
13525 var codingStyleParameters = component.codingStyleParameters;
13526 var quantizationParameters = component.quantizationParameters;
13527 var decompositionLevelsCount =
13528 codingStyleParameters.decompositionLevelsCount;
13529 var spqcds = quantizationParameters.SPqcds;
13530 var scalarExpounded = quantizationParameters.scalarExpounded;
13531 var guardBits = quantizationParameters.guardBits;
13532 var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
13533 var precision = context.components[c].precision;
13534
13535 var reversible = codingStyleParameters.reversibleTransformation;
13536 var transform = (reversible ? new ReversibleTransform() :
13537 new IrreversibleTransform());
13538
13539 var subbandCoefficients = [];
13540 var b = 0;
13541 for (var i = 0; i <= decompositionLevelsCount; i++) {
13542 var resolution = component.resolutions[i];
13543
13544 var width = resolution.trx1 - resolution.trx0;
13545 var height = resolution.try1 - resolution.try0;
13546 // Allocate space for the whole sublevel.
13547 var coefficients = new Float32Array(width * height);
13548
13549 for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
13550 var mu, epsilon;
13551 if (!scalarExpounded) {
13552 // formula E-5
13553 mu = spqcds[0].mu;
13554 epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
13555 } else {
13556 mu = spqcds[b].mu;
13557 epsilon = spqcds[b].epsilon;
13558 b++;
13559 }
13560
13561 var subband = resolution.subbands[j];
13562 var gainLog2 = SubbandsGainLog2[subband.type];
13563
13564 // calculate quantization coefficient (Section E.1.1.1)
13565 var delta = (reversible ? 1 :
13566 Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048));
13567 var mb = (guardBits + epsilon - 1);
13568
13569 // In the first resolution level, copyCoefficients will fill the
13570 // whole array with coefficients. In the succeeding passes,
13571 // copyCoefficients will consecutively fill in the values that belong
13572 // to the interleaved positions of the HL, LH, and HH coefficients.
13573 // The LL coefficients will then be interleaved in Transform.iterate().
13574 copyCoefficients(coefficients, width, height, subband, delta, mb,
13575 reversible, segmentationSymbolUsed);
13576 }
13577 subbandCoefficients.push({
13578 width: width,
13579 height: height,
13580 items: coefficients
13581 });
13582 }
13583
13584 var result = transform.calculate(subbandCoefficients,
13585 component.tcx0, component.tcy0);
13586 return {
13587 left: component.tcx0,
13588 top: component.tcy0,
13589 width: result.width,
13590 height: result.height,
13591 items: result.items
13592 };
13593 }
13594 function transformComponents(context) {
13595 var siz = context.SIZ;
13596 var components = context.components;
13597 var componentsCount = siz.Csiz;
13598 var resultImages = [];
13599 for (var i = 0, ii = context.tiles.length; i < ii; i++) {
13600 var tile = context.tiles[i];
13601 var transformedTiles = [];
13602 var c;
13603 for (c = 0; c < componentsCount; c++) {
13604 transformedTiles[c] = transformTile(context, tile, c);
13605 }
13606 var tile0 = transformedTiles[0];
13607 var out = new Uint8Array(tile0.items.length * componentsCount);
13608 var result = {
13609 left: tile0.left,
13610 top: tile0.top,
13611 width: tile0.width,
13612 height: tile0.height,
13613 items: out
13614 };
13615
13616 // Section G.2.2 Inverse multi component transform
13617 var shift, offset, max, min, maxK;
13618 var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
13619 if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
13620 var fourComponents = componentsCount === 4;
13621 var y0items = transformedTiles[0].items;
13622 var y1items = transformedTiles[1].items;
13623 var y2items = transformedTiles[2].items;
13624 var y3items = fourComponents ? transformedTiles[3].items : null;
13625
13626 // HACK: The multiple component transform formulas below assume that
13627 // all components have the same precision. With this in mind, we
13628 // compute shift and offset only once.
13629 shift = components[0].precision - 8;
13630 offset = (128 << shift) + 0.5;
13631 max = 255 * (1 << shift);
13632 maxK = max * 0.5;
13633 min = -maxK;
13634
13635 var component0 = tile.components[0];
13636 var alpha01 = componentsCount - 3;
13637 jj = y0items.length;
13638 if (!component0.codingStyleParameters.reversibleTransformation) {
13639 // inverse irreversible multiple component transform
13640 for (j = 0; j < jj; j++, pos += alpha01) {
13641 y0 = y0items[j] + offset;
13642 y1 = y1items[j];
13643 y2 = y2items[j];
13644 r = y0 + 1.402 * y2;
13645 g = y0 - 0.34413 * y1 - 0.71414 * y2;
13646 b = y0 + 1.772 * y1;
13647 out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
13648 out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
13649 out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
13650 }
13651 } else {
13652 // inverse reversible multiple component transform
13653 for (j = 0; j < jj; j++, pos += alpha01) {
13654 y0 = y0items[j] + offset;
13655 y1 = y1items[j];
13656 y2 = y2items[j];
13657 g = y0 - ((y2 + y1) >> 2);
13658 r = g + y2;
13659 b = g + y1;
13660 out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
13661 out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
13662 out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
13663 }
13664 }
13665 if (fourComponents) {
13666 for (j = 0, pos = 3; j < jj; j++, pos += 4) {
13667 k = y3items[j];
13668 out[pos] = k <= min ? 0 : k >= maxK ? 255 : (k + offset) >> shift;
13669 }
13670 }
13671 } else { // no multi-component transform
13672 for (c = 0; c < componentsCount; c++) {
13673 var items = transformedTiles[c].items;
13674 shift = components[c].precision - 8;
13675 offset = (128 << shift) + 0.5;
13676 max = (127.5 * (1 << shift));
13677 min = -max;
13678 for (pos = c, j = 0, jj = items.length; j < jj; j++) {
13679 val = items[j];
13680 out[pos] = val <= min ? 0 :
13681 val >= max ? 255 : (val + offset) >> shift;
13682 pos += componentsCount;
13683 }
13684 }
13685 }
13686 resultImages.push(result);
13687 }
13688 return resultImages;
13689 }
13690 function initializeTile(context, tileIndex) {
13691 var siz = context.SIZ;
13692 var componentsCount = siz.Csiz;
13693 var tile = context.tiles[tileIndex];
13694 for (var c = 0; c < componentsCount; c++) {
13695 var component = tile.components[c];
13696 var qcdOrQcc = (context.currentTile.QCC[c] !== undefined ?
13697 context.currentTile.QCC[c] : context.currentTile.QCD);
13698 component.quantizationParameters = qcdOrQcc;
13699 var codOrCoc = (context.currentTile.COC[c] !== undefined ?
13700 context.currentTile.COC[c] : context.currentTile.COD);
13701 component.codingStyleParameters = codOrCoc;
13702 }
13703 tile.codingStyleDefaultParameters = context.currentTile.COD;
13704 }
13705
13706 // Section B.10.2 Tag trees
13707 var TagTree = (function TagTreeClosure() {
13708 function TagTree(width, height) {
13709 var levelsLength = log2(Math.max(width, height)) + 1;
13710 this.levels = [];
13711 for (var i = 0; i < levelsLength; i++) {
13712 var level = {
13713 width: width,
13714 height: height,
13715 items: []
13716 };
13717 this.levels.push(level);
13718 width = Math.ceil(width / 2);
13719 height = Math.ceil(height / 2);
13720 }
13721 }
13722 TagTree.prototype = {
13723 reset: function TagTree_reset(i, j) {
13724 var currentLevel = 0, value = 0, level;
13725 while (currentLevel < this.levels.length) {
13726 level = this.levels[currentLevel];
13727 var index = i + j * level.width;
13728 if (level.items[index] !== undefined) {
13729 value = level.items[index];
13730 break;
13731 }
13732 level.index = index;
13733 i >>= 1;
13734 j >>= 1;
13735 currentLevel++;
13736 }
13737 currentLevel--;
13738 level = this.levels[currentLevel];
13739 level.items[level.index] = value;
13740 this.currentLevel = currentLevel;
13741 delete this.value;
13742 },
13743 incrementValue: function TagTree_incrementValue() {
13744 var level = this.levels[this.currentLevel];
13745 level.items[level.index]++;
13746 },
13747 nextLevel: function TagTree_nextLevel() {
13748 var currentLevel = this.currentLevel;
13749 var level = this.levels[currentLevel];
13750 var value = level.items[level.index];
13751 currentLevel--;
13752 if (currentLevel < 0) {
13753 this.value = value;
13754 return false;
13755 }
13756
13757 this.currentLevel = currentLevel;
13758 level = this.levels[currentLevel];
13759 level.items[level.index] = value;
13760 return true;
13761 }
13762 };
13763 return TagTree;
13764 })();
13765
13766 var InclusionTree = (function InclusionTreeClosure() {
13767 function InclusionTree(width, height, defaultValue) {
13768 var levelsLength = log2(Math.max(width, height)) + 1;
13769 this.levels = [];
13770 for (var i = 0; i < levelsLength; i++) {
13771 var items = new Uint8Array(width * height);
13772 for (var j = 0, jj = items.length; j < jj; j++) {
13773 items[j] = defaultValue;
13774 }
13775
13776 var level = {
13777 width: width,
13778 height: height,
13779 items: items
13780 };
13781 this.levels.push(level);
13782
13783 width = Math.ceil(width / 2);
13784 height = Math.ceil(height / 2);
13785 }
13786 }
13787 InclusionTree.prototype = {
13788 reset: function InclusionTree_reset(i, j, stopValue) {
13789 var currentLevel = 0;
13790 while (currentLevel < this.levels.length) {
13791 var level = this.levels[currentLevel];
13792 var index = i + j * level.width;
13793 level.index = index;
13794 var value = level.items[index];
13795
13796 if (value === 0xFF) {
13797 break;
13798 }
13799
13800 if (value > stopValue) {
13801 this.currentLevel = currentLevel;
13802 // already know about this one, propagating the value to top levels
13803 this.propagateValues();
13804 return false;
13805 }
13806
13807 i >>= 1;
13808 j >>= 1;
13809 currentLevel++;
13810 }
13811 this.currentLevel = currentLevel - 1;
13812 return true;
13813 },
13814 incrementValue: function InclusionTree_incrementValue(stopValue) {
13815 var level = this.levels[this.currentLevel];
13816 level.items[level.index] = stopValue + 1;
13817 this.propagateValues();
13818 },
13819 propagateValues: function InclusionTree_propagateValues() {
13820 var levelIndex = this.currentLevel;
13821 var level = this.levels[levelIndex];
13822 var currentValue = level.items[level.index];
13823 while (--levelIndex >= 0) {
13824 level = this.levels[levelIndex];
13825 level.items[level.index] = currentValue;
13826 }
13827 },
13828 nextLevel: function InclusionTree_nextLevel() {
13829 var currentLevel = this.currentLevel;
13830 var level = this.levels[currentLevel];
13831 var value = level.items[level.index];
13832 level.items[level.index] = 0xFF;
13833 currentLevel--;
13834 if (currentLevel < 0) {
13835 return false;
13836 }
13837
13838 this.currentLevel = currentLevel;
13839 level = this.levels[currentLevel];
13840 level.items[level.index] = value;
13841 return true;
13842 }
13843 };
13844 return InclusionTree;
13845 })();
13846
13847 // Section D. Coefficient bit modeling
13848 var BitModel = (function BitModelClosure() {
13849 var UNIFORM_CONTEXT = 17;
13850 var RUNLENGTH_CONTEXT = 18;
13851 // Table D-1
13852 // The index is binary presentation: 0dddvvhh, ddd - sum of Di (0..4),
13853 // vv - sum of Vi (0..2), and hh - sum of Hi (0..2)
13854 var LLAndLHContextsLabel = new Uint8Array([
13855 0, 5, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 1, 6, 8, 0, 3, 7, 8, 0, 4,
13856 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6,
13857 8, 0, 3, 7, 8, 0, 4, 7, 8, 0, 0, 0, 0, 0, 2, 6, 8, 0, 3, 7, 8, 0, 4, 7, 8
13858 ]);
13859 var HLContextLabel = new Uint8Array([
13860 0, 3, 4, 0, 5, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 1, 3, 4, 0, 6, 7, 7, 0, 8,
13861 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3,
13862 4, 0, 6, 7, 7, 0, 8, 8, 8, 0, 0, 0, 0, 0, 2, 3, 4, 0, 6, 7, 7, 0, 8, 8, 8
13863 ]);
13864 var HHContextLabel = new Uint8Array([
13865 0, 1, 2, 0, 1, 2, 2, 0, 2, 2, 2, 0, 0, 0, 0, 0, 3, 4, 5, 0, 4, 5, 5, 0, 5,
13866 5, 5, 0, 0, 0, 0, 0, 6, 7, 7, 0, 7, 7, 7, 0, 7, 7, 7, 0, 0, 0, 0, 0, 8, 8,
13867 8, 0, 8, 8, 8, 0, 8, 8, 8, 0, 0, 0, 0, 0, 8, 8, 8, 0, 8, 8, 8, 0, 8, 8, 8
13868 ]);
13869
13870 function BitModel(width, height, subband, zeroBitPlanes, mb) {
13871 this.width = width;
13872 this.height = height;
13873
13874 this.contextLabelTable = (subband === 'HH' ? HHContextLabel :
13875 (subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel));
13876
13877 var coefficientCount = width * height;
13878
13879 // coefficients outside the encoding region treated as insignificant
13880 // add border state cells for significanceState
13881 this.neighborsSignificance = new Uint8Array(coefficientCount);
13882 this.coefficentsSign = new Uint8Array(coefficientCount);
13883 this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) :
13884 mb > 6 ? new Uint16Array(coefficientCount) :
13885 new Uint8Array(coefficientCount);
13886 this.processingFlags = new Uint8Array(coefficientCount);
13887
13888 var bitsDecoded = new Uint8Array(coefficientCount);
13889 if (zeroBitPlanes !== 0) {
13890 for (var i = 0; i < coefficientCount; i++) {
13891 bitsDecoded[i] = zeroBitPlanes;
13892 }
13893 }
13894 this.bitsDecoded = bitsDecoded;
13895
13896 this.reset();
13897 }
13898
13899 BitModel.prototype = {
13900 setDecoder: function BitModel_setDecoder(decoder) {
13901 this.decoder = decoder;
13902 },
13903 reset: function BitModel_reset() {
13904 // We have 17 contexts that are accessed via context labels,
13905 // plus the uniform and runlength context.
13906 this.contexts = new Int8Array(19);
13907
13908 // Contexts are packed into 1 byte:
13909 // highest 7 bits carry the index, lowest bit carries mps
13910 this.contexts[0] = (4 << 1) | 0;
13911 this.contexts[UNIFORM_CONTEXT] = (46 << 1) | 0;
13912 this.contexts[RUNLENGTH_CONTEXT] = (3 << 1) | 0;
13913 },
13914 setNeighborsSignificance:
13915 function BitModel_setNeighborsSignificance(row, column, index) {
13916 var neighborsSignificance = this.neighborsSignificance;
13917 var width = this.width, height = this.height;
13918 var left = (column > 0);
13919 var right = (column + 1 < width);
13920 var i;
13921
13922 if (row > 0) {
13923 i = index - width;
13924 if (left) {
13925 neighborsSignificance[i - 1] += 0x10;
13926 }
13927 if (right) {
13928 neighborsSignificance[i + 1] += 0x10;
13929 }
13930 neighborsSignificance[i] += 0x04;
13931 }
13932
13933 if (row + 1 < height) {
13934 i = index + width;
13935 if (left) {
13936 neighborsSignificance[i - 1] += 0x10;
13937 }
13938 if (right) {
13939 neighborsSignificance[i + 1] += 0x10;
13940 }
13941 neighborsSignificance[i] += 0x04;
13942 }
13943
13944 if (left) {
13945 neighborsSignificance[index - 1] += 0x01;
13946 }
13947 if (right) {
13948 neighborsSignificance[index + 1] += 0x01;
13949 }
13950 neighborsSignificance[index] |= 0x80;
13951 },
13952 runSignificancePropagationPass:
13953 function BitModel_runSignificancePropagationPass() {
13954 var decoder = this.decoder;
13955 var width = this.width, height = this.height;
13956 var coefficentsMagnitude = this.coefficentsMagnitude;
13957 var coefficentsSign = this.coefficentsSign;
13958 var neighborsSignificance = this.neighborsSignificance;
13959 var processingFlags = this.processingFlags;
13960 var contexts = this.contexts;
13961 var labels = this.contextLabelTable;
13962 var bitsDecoded = this.bitsDecoded;
13963 var processedInverseMask = ~1;
13964 var processedMask = 1;
13965 var firstMagnitudeBitMask = 2;
13966
13967 for (var i0 = 0; i0 < height; i0 += 4) {
13968 for (var j = 0; j < width; j++) {
13969 var index = i0 * width + j;
13970 for (var i1 = 0; i1 < 4; i1++, index += width) {
13971 var i = i0 + i1;
13972 if (i >= height) {
13973 break;
13974 }
13975 // clear processed flag first
13976 processingFlags[index] &= processedInverseMask;
13977
13978 if (coefficentsMagnitude[index] ||
13979 !neighborsSignificance[index]) {
13980 continue;
13981 }
13982
13983 var contextLabel = labels[neighborsSignificance[index]];
13984 var decision = decoder.readBit(contexts, contextLabel);
13985 if (decision) {
13986 var sign = this.decodeSignBit(i, j, index);
13987 coefficentsSign[index] = sign;
13988 coefficentsMagnitude[index] = 1;
13989 this.setNeighborsSignificance(i, j, index);
13990 processingFlags[index] |= firstMagnitudeBitMask;
13991 }
13992 bitsDecoded[index]++;
13993 processingFlags[index] |= processedMask;
13994 }
13995 }
13996 }
13997 },
13998 decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
13999 var width = this.width, height = this.height;
14000 var coefficentsMagnitude = this.coefficentsMagnitude;
14001 var coefficentsSign = this.coefficentsSign;
14002 var contribution, sign0, sign1, significance1;
14003 var contextLabel, decoded;
14004
14005 // calculate horizontal contribution
14006 significance1 = (column > 0 && coefficentsMagnitude[index - 1] !== 0);
14007 if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
14008 sign1 = coefficentsSign[index + 1];
14009 if (significance1) {
14010 sign0 = coefficentsSign[index - 1];
14011 contribution = 1 - sign1 - sign0;
14012 } else {
14013 contribution = 1 - sign1 - sign1;
14014 }
14015 } else if (significance1) {
14016 sign0 = coefficentsSign[index - 1];
14017 contribution = 1 - sign0 - sign0;
14018 } else {
14019 contribution = 0;
14020 }
14021 var horizontalContribution = 3 * contribution;
14022
14023 // calculate vertical contribution and combine with the horizontal
14024 significance1 = (row > 0 && coefficentsMagnitude[index - width] !== 0);
14025 if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
14026 sign1 = coefficentsSign[index + width];
14027 if (significance1) {
14028 sign0 = coefficentsSign[index - width];
14029 contribution = 1 - sign1 - sign0 + horizontalContribution;
14030 } else {
14031 contribution = 1 - sign1 - sign1 + horizontalContribution;
14032 }
14033 } else if (significance1) {
14034 sign0 = coefficentsSign[index - width];
14035 contribution = 1 - sign0 - sign0 + horizontalContribution;
14036 } else {
14037 contribution = horizontalContribution;
14038 }
14039
14040 if (contribution >= 0) {
14041 contextLabel = 9 + contribution;
14042 decoded = this.decoder.readBit(this.contexts, contextLabel);
14043 } else {
14044 contextLabel = 9 - contribution;
14045 decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
14046 }
14047 return decoded;
14048 },
14049 runMagnitudeRefinementPass:
14050 function BitModel_runMagnitudeRefinementPass() {
14051 var decoder = this.decoder;
14052 var width = this.width, height = this.height;
14053 var coefficentsMagnitude = this.coefficentsMagnitude;
14054 var neighborsSignificance = this.neighborsSignificance;
14055 var contexts = this.contexts;
14056 var bitsDecoded = this.bitsDecoded;
14057 var processingFlags = this.processingFlags;
14058 var processedMask = 1;
14059 var firstMagnitudeBitMask = 2;
14060 var length = width * height;
14061 var width4 = width * 4;
14062
14063 for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
14064 indexNext = Math.min(length, index0 + width4);
14065 for (var j = 0; j < width; j++) {
14066 for (var index = index0 + j; index < indexNext; index += width) {
14067
14068 // significant but not those that have just become
14069 if (!coefficentsMagnitude[index] ||
14070 (processingFlags[index] & processedMask) !== 0) {
14071 continue;
14072 }
14073
14074 var contextLabel = 16;
14075 if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
14076 processingFlags[index] ^= firstMagnitudeBitMask;
14077 // first refinement
14078 var significance = neighborsSignificance[index] & 127;
14079 contextLabel = significance === 0 ? 15 : 14;
14080 }
14081
14082 var bit = decoder.readBit(contexts, contextLabel);
14083 coefficentsMagnitude[index] =
14084 (coefficentsMagnitude[index] << 1) | bit;
14085 bitsDecoded[index]++;
14086 processingFlags[index] |= processedMask;
14087 }
14088 }
14089 }
14090 },
14091 runCleanupPass: function BitModel_runCleanupPass() {
14092 var decoder = this.decoder;
14093 var width = this.width, height = this.height;
14094 var neighborsSignificance = this.neighborsSignificance;
14095 var coefficentsMagnitude = this.coefficentsMagnitude;
14096 var coefficentsSign = this.coefficentsSign;
14097 var contexts = this.contexts;
14098 var labels = this.contextLabelTable;
14099 var bitsDecoded = this.bitsDecoded;
14100 var processingFlags = this.processingFlags;
14101 var processedMask = 1;
14102 var firstMagnitudeBitMask = 2;
14103 var oneRowDown = width;
14104 var twoRowsDown = width * 2;
14105 var threeRowsDown = width * 3;
14106 var iNext;
14107 for (var i0 = 0; i0 < height; i0 = iNext) {
14108 iNext = Math.min(i0 + 4, height);
14109 var indexBase = i0 * width;
14110 var checkAllEmpty = i0 + 3 < height;
14111 for (var j = 0; j < width; j++) {
14112 var index0 = indexBase + j;
14113 // using the property: labels[neighborsSignificance[index]] === 0
14114 // when neighborsSignificance[index] === 0
14115 var allEmpty = (checkAllEmpty &&
14116 processingFlags[index0] === 0 &&
14117 processingFlags[index0 + oneRowDown] === 0 &&
14118 processingFlags[index0 + twoRowsDown] === 0 &&
14119 processingFlags[index0 + threeRowsDown] === 0 &&
14120 neighborsSignificance[index0] === 0 &&
14121 neighborsSignificance[index0 + oneRowDown] === 0 &&
14122 neighborsSignificance[index0 + twoRowsDown] === 0 &&
14123 neighborsSignificance[index0 + threeRowsDown] === 0);
14124 var i1 = 0, index = index0;
14125 var i = i0, sign;
14126 if (allEmpty) {
14127 var hasSignificantCoefficent =
14128 decoder.readBit(contexts, RUNLENGTH_CONTEXT);
14129 if (!hasSignificantCoefficent) {
14130 bitsDecoded[index0]++;
14131 bitsDecoded[index0 + oneRowDown]++;
14132 bitsDecoded[index0 + twoRowsDown]++;
14133 bitsDecoded[index0 + threeRowsDown]++;
14134 continue; // next column
14135 }
14136 i1 = (decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) |
14137 decoder.readBit(contexts, UNIFORM_CONTEXT);
14138 if (i1 !== 0) {
14139 i = i0 + i1;
14140 index += i1 * width;
14141 }
14142
14143 sign = this.decodeSignBit(i, j, index);
14144 coefficentsSign[index] = sign;
14145 coefficentsMagnitude[index] = 1;
14146 this.setNeighborsSignificance(i, j, index);
14147 processingFlags[index] |= firstMagnitudeBitMask;
14148
14149 index = index0;
14150 for (var i2 = i0; i2 <= i; i2++, index += width) {
14151 bitsDecoded[index]++;
14152 }
14153
14154 i1++;
14155 }
14156 for (i = i0 + i1; i < iNext; i++, index += width) {
14157 if (coefficentsMagnitude[index] ||
14158 (processingFlags[index] & processedMask) !== 0) {
14159 continue;
14160 }
14161
14162 var contextLabel = labels[neighborsSignificance[index]];
14163 var decision = decoder.readBit(contexts, contextLabel);
14164 if (decision === 1) {
14165 sign = this.decodeSignBit(i, j, index);
14166 coefficentsSign[index] = sign;
14167 coefficentsMagnitude[index] = 1;
14168 this.setNeighborsSignificance(i, j, index);
14169 processingFlags[index] |= firstMagnitudeBitMask;
14170 }
14171 bitsDecoded[index]++;
14172 }
14173 }
14174 }
14175 },
14176 checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
14177 var decoder = this.decoder;
14178 var contexts = this.contexts;
14179 var symbol = (decoder.readBit(contexts, UNIFORM_CONTEXT) << 3) |
14180 (decoder.readBit(contexts, UNIFORM_CONTEXT) << 2) |
14181 (decoder.readBit(contexts, UNIFORM_CONTEXT) << 1) |
14182 decoder.readBit(contexts, UNIFORM_CONTEXT);
14183 if (symbol !== 0xA) {
14184 error('JPX Error: Invalid segmentation symbol');
14185 }
14186 }
14187 };
14188
14189 return BitModel;
14190 })();
14191
14192 // Section F, Discrete wavelet transformation
14193 var Transform = (function TransformClosure() {
14194 function Transform() {}
14195
14196 Transform.prototype.calculate =
14197 function transformCalculate(subbands, u0, v0) {
14198 var ll = subbands[0];
14199 for (var i = 1, ii = subbands.length; i < ii; i++) {
14200 ll = this.iterate(ll, subbands[i], u0, v0);
14201 }
14202 return ll;
14203 };
14204 Transform.prototype.extend = function extend(buffer, offset, size) {
14205 // Section F.3.7 extending... using max extension of 4
14206 var i1 = offset - 1, j1 = offset + 1;
14207 var i2 = offset + size - 2, j2 = offset + size;
14208 buffer[i1--] = buffer[j1++];
14209 buffer[j2++] = buffer[i2--];
14210 buffer[i1--] = buffer[j1++];
14211 buffer[j2++] = buffer[i2--];
14212 buffer[i1--] = buffer[j1++];
14213 buffer[j2++] = buffer[i2--];
14214 buffer[i1] = buffer[j1];
14215 buffer[j2] = buffer[i2];
14216 };
14217 Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh,
14218 u0, v0) {
14219 var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
14220 var width = hl_lh_hh.width;
14221 var height = hl_lh_hh.height;
14222 var items = hl_lh_hh.items;
14223 var i, j, k, l, u, v;
14224
14225 // Interleave LL according to Section F.3.3
14226 for (k = 0, i = 0; i < llHeight; i++) {
14227 l = i * 2 * width;
14228 for (j = 0; j < llWidth; j++, k++, l += 2) {
14229 items[l] = llItems[k];
14230 }
14231 }
14232 // The LL band is not needed anymore.
14233 llItems = ll.items = null;
14234
14235 var bufferPadding = 4;
14236 var rowBuffer = new Float32Array(width + 2 * bufferPadding);
14237
14238 // Section F.3.4 HOR_SR
14239 if (width === 1) {
14240 // if width = 1, when u0 even keep items as is, when odd divide by 2
14241 if ((u0 & 1) !== 0) {
14242 for (v = 0, k = 0; v < height; v++, k += width) {
14243 items[k] *= 0.5;
14244 }
14245 }
14246 } else {
14247 for (v = 0, k = 0; v < height; v++, k += width) {
14248 rowBuffer.set(items.subarray(k, k + width), bufferPadding);
14249
14250 this.extend(rowBuffer, bufferPadding, width);
14251 this.filter(rowBuffer, bufferPadding, width);
14252
14253 items.set(
14254 rowBuffer.subarray(bufferPadding, bufferPadding + width),
14255 k);
14256 }
14257 }
14258
14259 // Accesses to the items array can take long, because it may not fit into
14260 // CPU cache and has to be fetched from main memory. Since subsequent
14261 // accesses to the items array are not local when reading columns, we
14262 // have a cache miss every time. To reduce cache misses, get up to
14263 // 'numBuffers' items at a time and store them into the individual
14264 // buffers. The colBuffers should be small enough to fit into CPU cache.
14265 var numBuffers = 16;
14266 var colBuffers = [];
14267 for (i = 0; i < numBuffers; i++) {
14268 colBuffers.push(new Float32Array(height + 2 * bufferPadding));
14269 }
14270 var b, currentBuffer = 0;
14271 ll = bufferPadding + height;
14272
14273 // Section F.3.5 VER_SR
14274 if (height === 1) {
14275 // if height = 1, when v0 even keep items as is, when odd divide by 2
14276 if ((v0 & 1) !== 0) {
14277 for (u = 0; u < width; u++) {
14278 items[u] *= 0.5;
14279 }
14280 }
14281 } else {
14282 for (u = 0; u < width; u++) {
14283 // if we ran out of buffers, copy several image columns at once
14284 if (currentBuffer === 0) {
14285 numBuffers = Math.min(width - u, numBuffers);
14286 for (k = u, l = bufferPadding; l < ll; k += width, l++) {
14287 for (b = 0; b < numBuffers; b++) {
14288 colBuffers[b][l] = items[k + b];
14289 }
14290 }
14291 currentBuffer = numBuffers;
14292 }
14293
14294 currentBuffer--;
14295 var buffer = colBuffers[currentBuffer];
14296 this.extend(buffer, bufferPadding, height);
14297 this.filter(buffer, bufferPadding, height);
14298
14299 // If this is last buffer in this group of buffers, flush all buffers.
14300 if (currentBuffer === 0) {
14301 k = u - numBuffers + 1;
14302 for (l = bufferPadding; l < ll; k += width, l++) {
14303 for (b = 0; b < numBuffers; b++) {
14304 items[k + b] = colBuffers[b][l];
14305 }
14306 }
14307 }
14308 }
14309 }
14310
14311 return {
14312 width: width,
14313 height: height,
14314 items: items
14315 };
14316 };
14317 return Transform;
14318 })();
14319
14320 // Section 3.8.2 Irreversible 9-7 filter
14321 var IrreversibleTransform = (function IrreversibleTransformClosure() {
14322 function IrreversibleTransform() {
14323 Transform.call(this);
14324 }
14325
14326 IrreversibleTransform.prototype = Object.create(Transform.prototype);
14327 IrreversibleTransform.prototype.filter =
14328 function irreversibleTransformFilter(x, offset, length) {
14329 var len = length >> 1;
14330 offset = offset | 0;
14331 var j, n, current, next;
14332
14333 var alpha = -1.586134342059924;
14334 var beta = -0.052980118572961;
14335 var gamma = 0.882911075530934;
14336 var delta = 0.443506852043971;
14337 var K = 1.230174104914001;
14338 var K_ = 1 / K;
14339
14340 // step 1 is combined with step 3
14341
14342 // step 2
14343 j = offset - 3;
14344 for (n = len + 4; n--; j += 2) {
14345 x[j] *= K_;
14346 }
14347
14348 // step 1 & 3
14349 j = offset - 2;
14350 current = delta * x[j -1];
14351 for (n = len + 3; n--; j += 2) {
14352 next = delta * x[j + 1];
14353 x[j] = K * x[j] - current - next;
14354 if (n--) {
14355 j += 2;
14356 current = delta * x[j + 1];
14357 x[j] = K * x[j] - current - next;
14358 } else {
14359 break;
14360 }
14361 }
14362
14363 // step 4
14364 j = offset - 1;
14365 current = gamma * x[j - 1];
14366 for (n = len + 2; n--; j += 2) {
14367 next = gamma * x[j + 1];
14368 x[j] -= current + next;
14369 if (n--) {
14370 j += 2;
14371 current = gamma * x[j + 1];
14372 x[j] -= current + next;
14373 } else {
14374 break;
14375 }
14376 }
14377
14378 // step 5
14379 j = offset;
14380 current = beta * x[j - 1];
14381 for (n = len + 1; n--; j += 2) {
14382 next = beta * x[j + 1];
14383 x[j] -= current + next;
14384 if (n--) {
14385 j += 2;
14386 current = beta * x[j + 1];
14387 x[j] -= current + next;
14388 } else {
14389 break;
14390 }
14391 }
14392
14393 // step 6
14394 if (len !== 0) {
14395 j = offset + 1;
14396 current = alpha * x[j - 1];
14397 for (n = len; n--; j += 2) {
14398 next = alpha * x[j + 1];
14399 x[j] -= current + next;
14400 if (n--) {
14401 j += 2;
14402 current = alpha * x[j + 1];
14403 x[j] -= current + next;
14404 } else {
14405 break;
14406 }
14407 }
14408 }
14409 };
14410
14411 return IrreversibleTransform;
14412 })();
14413
14414 // Section 3.8.1 Reversible 5-3 filter
14415 var ReversibleTransform = (function ReversibleTransformClosure() {
14416 function ReversibleTransform() {
14417 Transform.call(this);
14418 }
14419
14420 ReversibleTransform.prototype = Object.create(Transform.prototype);
14421 ReversibleTransform.prototype.filter =
14422 function reversibleTransformFilter(x, offset, length) {
14423 var len = length >> 1;
14424 offset = offset | 0;
14425 var j, n;
14426
14427 for (j = offset, n = len + 1; n--; j += 2) {
14428 x[j] -= (x[j - 1] + x[j + 1] + 2) >> 2;
14429 }
14430
14431 for (j = offset + 1, n = len; n--; j += 2) {
14432 x[j] += (x[j - 1] + x[j + 1]) >> 1;
14433 }
14434 };
14435
14436 return ReversibleTransform;
14437 })();
14438
14439 return JpxImage;
14440})();
14441
14442exports.JpxImage = JpxImage;
14443}));
14444
14445
14446(function (root, factory) {
14447 {
14448 factory((root.pdfjsCoreMetrics = {}), root.pdfjsSharedUtil);
14449 }
14450}(this, function (exports, sharedUtil) {
14451var getLookupTableFactory = sharedUtil.getLookupTableFactory;
14452
14453// The Metrics object contains glyph widths (in glyph space units).
14454// As per PDF spec, for most fonts (Type 3 being an exception) a glyph
14455// space unit corresponds to 1/1000th of text space unit.
14456var getMetrics = getLookupTableFactory(function (t) {
14457 t['Courier'] = 600;
14458 t['Courier-Bold'] = 600;
14459 t['Courier-BoldOblique'] = 600;
14460 t['Courier-Oblique'] = 600;
14461 t['Helvetica'] = getLookupTableFactory(function (t) {
14462 t['space'] = 278;
14463 t['exclam'] = 278;
14464 t['quotedbl'] = 355;
14465 t['numbersign'] = 556;
14466 t['dollar'] = 556;
14467 t['percent'] = 889;
14468 t['ampersand'] = 667;
14469 t['quoteright'] = 222;
14470 t['parenleft'] = 333;
14471 t['parenright'] = 333;
14472 t['asterisk'] = 389;
14473 t['plus'] = 584;
14474 t['comma'] = 278;
14475 t['hyphen'] = 333;
14476 t['period'] = 278;
14477 t['slash'] = 278;
14478 t['zero'] = 556;
14479 t['one'] = 556;
14480 t['two'] = 556;
14481 t['three'] = 556;
14482 t['four'] = 556;
14483 t['five'] = 556;
14484 t['six'] = 556;
14485 t['seven'] = 556;
14486 t['eight'] = 556;
14487 t['nine'] = 556;
14488 t['colon'] = 278;
14489 t['semicolon'] = 278;
14490 t['less'] = 584;
14491 t['equal'] = 584;
14492 t['greater'] = 584;
14493 t['question'] = 556;
14494 t['at'] = 1015;
14495 t['A'] = 667;
14496 t['B'] = 667;
14497 t['C'] = 722;
14498 t['D'] = 722;
14499 t['E'] = 667;
14500 t['F'] = 611;
14501 t['G'] = 778;
14502 t['H'] = 722;
14503 t['I'] = 278;
14504 t['J'] = 500;
14505 t['K'] = 667;
14506 t['L'] = 556;
14507 t['M'] = 833;
14508 t['N'] = 722;
14509 t['O'] = 778;
14510 t['P'] = 667;
14511 t['Q'] = 778;
14512 t['R'] = 722;
14513 t['S'] = 667;
14514 t['T'] = 611;
14515 t['U'] = 722;
14516 t['V'] = 667;
14517 t['W'] = 944;
14518 t['X'] = 667;
14519 t['Y'] = 667;
14520 t['Z'] = 611;
14521 t['bracketleft'] = 278;
14522 t['backslash'] = 278;
14523 t['bracketright'] = 278;
14524 t['asciicircum'] = 469;
14525 t['underscore'] = 556;
14526 t['quoteleft'] = 222;
14527 t['a'] = 556;
14528 t['b'] = 556;
14529 t['c'] = 500;
14530 t['d'] = 556;
14531 t['e'] = 556;
14532 t['f'] = 278;
14533 t['g'] = 556;
14534 t['h'] = 556;
14535 t['i'] = 222;
14536 t['j'] = 222;
14537 t['k'] = 500;
14538 t['l'] = 222;
14539 t['m'] = 833;
14540 t['n'] = 556;
14541 t['o'] = 556;
14542 t['p'] = 556;
14543 t['q'] = 556;
14544 t['r'] = 333;
14545 t['s'] = 500;
14546 t['t'] = 278;
14547 t['u'] = 556;
14548 t['v'] = 500;
14549 t['w'] = 722;
14550 t['x'] = 500;
14551 t['y'] = 500;
14552 t['z'] = 500;
14553 t['braceleft'] = 334;
14554 t['bar'] = 260;
14555 t['braceright'] = 334;
14556 t['asciitilde'] = 584;
14557 t['exclamdown'] = 333;
14558 t['cent'] = 556;
14559 t['sterling'] = 556;
14560 t['fraction'] = 167;
14561 t['yen'] = 556;
14562 t['florin'] = 556;
14563 t['section'] = 556;
14564 t['currency'] = 556;
14565 t['quotesingle'] = 191;
14566 t['quotedblleft'] = 333;
14567 t['guillemotleft'] = 556;
14568 t['guilsinglleft'] = 333;
14569 t['guilsinglright'] = 333;
14570 t['fi'] = 500;
14571 t['fl'] = 500;
14572 t['endash'] = 556;
14573 t['dagger'] = 556;
14574 t['daggerdbl'] = 556;
14575 t['periodcentered'] = 278;
14576 t['paragraph'] = 537;
14577 t['bullet'] = 350;
14578 t['quotesinglbase'] = 222;
14579 t['quotedblbase'] = 333;
14580 t['quotedblright'] = 333;
14581 t['guillemotright'] = 556;
14582 t['ellipsis'] = 1000;
14583 t['perthousand'] = 1000;
14584 t['questiondown'] = 611;
14585 t['grave'] = 333;
14586 t['acute'] = 333;
14587 t['circumflex'] = 333;
14588 t['tilde'] = 333;
14589 t['macron'] = 333;
14590 t['breve'] = 333;
14591 t['dotaccent'] = 333;
14592 t['dieresis'] = 333;
14593 t['ring'] = 333;
14594 t['cedilla'] = 333;
14595 t['hungarumlaut'] = 333;
14596 t['ogonek'] = 333;
14597 t['caron'] = 333;
14598 t['emdash'] = 1000;
14599 t['AE'] = 1000;
14600 t['ordfeminine'] = 370;
14601 t['Lslash'] = 556;
14602 t['Oslash'] = 778;
14603 t['OE'] = 1000;
14604 t['ordmasculine'] = 365;
14605 t['ae'] = 889;
14606 t['dotlessi'] = 278;
14607 t['lslash'] = 222;
14608 t['oslash'] = 611;
14609 t['oe'] = 944;
14610 t['germandbls'] = 611;
14611 t['Idieresis'] = 278;
14612 t['eacute'] = 556;
14613 t['abreve'] = 556;
14614 t['uhungarumlaut'] = 556;
14615 t['ecaron'] = 556;
14616 t['Ydieresis'] = 667;
14617 t['divide'] = 584;
14618 t['Yacute'] = 667;
14619 t['Acircumflex'] = 667;
14620 t['aacute'] = 556;
14621 t['Ucircumflex'] = 722;
14622 t['yacute'] = 500;
14623 t['scommaaccent'] = 500;
14624 t['ecircumflex'] = 556;
14625 t['Uring'] = 722;
14626 t['Udieresis'] = 722;
14627 t['aogonek'] = 556;
14628 t['Uacute'] = 722;
14629 t['uogonek'] = 556;
14630 t['Edieresis'] = 667;
14631 t['Dcroat'] = 722;
14632 t['commaaccent'] = 250;
14633 t['copyright'] = 737;
14634 t['Emacron'] = 667;
14635 t['ccaron'] = 500;
14636 t['aring'] = 556;
14637 t['Ncommaaccent'] = 722;
14638 t['lacute'] = 222;
14639 t['agrave'] = 556;
14640 t['Tcommaaccent'] = 611;
14641 t['Cacute'] = 722;
14642 t['atilde'] = 556;
14643 t['Edotaccent'] = 667;
14644 t['scaron'] = 500;
14645 t['scedilla'] = 500;
14646 t['iacute'] = 278;
14647 t['lozenge'] = 471;
14648 t['Rcaron'] = 722;
14649 t['Gcommaaccent'] = 778;
14650 t['ucircumflex'] = 556;
14651 t['acircumflex'] = 556;
14652 t['Amacron'] = 667;
14653 t['rcaron'] = 333;
14654 t['ccedilla'] = 500;
14655 t['Zdotaccent'] = 611;
14656 t['Thorn'] = 667;
14657 t['Omacron'] = 778;
14658 t['Racute'] = 722;
14659 t['Sacute'] = 667;
14660 t['dcaron'] = 643;
14661 t['Umacron'] = 722;
14662 t['uring'] = 556;
14663 t['threesuperior'] = 333;
14664 t['Ograve'] = 778;
14665 t['Agrave'] = 667;
14666 t['Abreve'] = 667;
14667 t['multiply'] = 584;
14668 t['uacute'] = 556;
14669 t['Tcaron'] = 611;
14670 t['partialdiff'] = 476;
14671 t['ydieresis'] = 500;
14672 t['Nacute'] = 722;
14673 t['icircumflex'] = 278;
14674 t['Ecircumflex'] = 667;
14675 t['adieresis'] = 556;
14676 t['edieresis'] = 556;
14677 t['cacute'] = 500;
14678 t['nacute'] = 556;
14679 t['umacron'] = 556;
14680 t['Ncaron'] = 722;
14681 t['Iacute'] = 278;
14682 t['plusminus'] = 584;
14683 t['brokenbar'] = 260;
14684 t['registered'] = 737;
14685 t['Gbreve'] = 778;
14686 t['Idotaccent'] = 278;
14687 t['summation'] = 600;
14688 t['Egrave'] = 667;
14689 t['racute'] = 333;
14690 t['omacron'] = 556;
14691 t['Zacute'] = 611;
14692 t['Zcaron'] = 611;
14693 t['greaterequal'] = 549;
14694 t['Eth'] = 722;
14695 t['Ccedilla'] = 722;
14696 t['lcommaaccent'] = 222;
14697 t['tcaron'] = 317;
14698 t['eogonek'] = 556;
14699 t['Uogonek'] = 722;
14700 t['Aacute'] = 667;
14701 t['Adieresis'] = 667;
14702 t['egrave'] = 556;
14703 t['zacute'] = 500;
14704 t['iogonek'] = 222;
14705 t['Oacute'] = 778;
14706 t['oacute'] = 556;
14707 t['amacron'] = 556;
14708 t['sacute'] = 500;
14709 t['idieresis'] = 278;
14710 t['Ocircumflex'] = 778;
14711 t['Ugrave'] = 722;
14712 t['Delta'] = 612;
14713 t['thorn'] = 556;
14714 t['twosuperior'] = 333;
14715 t['Odieresis'] = 778;
14716 t['mu'] = 556;
14717 t['igrave'] = 278;
14718 t['ohungarumlaut'] = 556;
14719 t['Eogonek'] = 667;
14720 t['dcroat'] = 556;
14721 t['threequarters'] = 834;
14722 t['Scedilla'] = 667;
14723 t['lcaron'] = 299;
14724 t['Kcommaaccent'] = 667;
14725 t['Lacute'] = 556;
14726 t['trademark'] = 1000;
14727 t['edotaccent'] = 556;
14728 t['Igrave'] = 278;
14729 t['Imacron'] = 278;
14730 t['Lcaron'] = 556;
14731 t['onehalf'] = 834;
14732 t['lessequal'] = 549;
14733 t['ocircumflex'] = 556;
14734 t['ntilde'] = 556;
14735 t['Uhungarumlaut'] = 722;
14736 t['Eacute'] = 667;
14737 t['emacron'] = 556;
14738 t['gbreve'] = 556;
14739 t['onequarter'] = 834;
14740 t['Scaron'] = 667;
14741 t['Scommaaccent'] = 667;
14742 t['Ohungarumlaut'] = 778;
14743 t['degree'] = 400;
14744 t['ograve'] = 556;
14745 t['Ccaron'] = 722;
14746 t['ugrave'] = 556;
14747 t['radical'] = 453;
14748 t['Dcaron'] = 722;
14749 t['rcommaaccent'] = 333;
14750 t['Ntilde'] = 722;
14751 t['otilde'] = 556;
14752 t['Rcommaaccent'] = 722;
14753 t['Lcommaaccent'] = 556;
14754 t['Atilde'] = 667;
14755 t['Aogonek'] = 667;
14756 t['Aring'] = 667;
14757 t['Otilde'] = 778;
14758 t['zdotaccent'] = 500;
14759 t['Ecaron'] = 667;
14760 t['Iogonek'] = 278;
14761 t['kcommaaccent'] = 500;
14762 t['minus'] = 584;
14763 t['Icircumflex'] = 278;
14764 t['ncaron'] = 556;
14765 t['tcommaaccent'] = 278;
14766 t['logicalnot'] = 584;
14767 t['odieresis'] = 556;
14768 t['udieresis'] = 556;
14769 t['notequal'] = 549;
14770 t['gcommaaccent'] = 556;
14771 t['eth'] = 556;
14772 t['zcaron'] = 500;
14773 t['ncommaaccent'] = 556;
14774 t['onesuperior'] = 333;
14775 t['imacron'] = 278;
14776 t['Euro'] = 556;
14777 });
14778 t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
14779 t['space'] = 278;
14780 t['exclam'] = 333;
14781 t['quotedbl'] = 474;
14782 t['numbersign'] = 556;
14783 t['dollar'] = 556;
14784 t['percent'] = 889;
14785 t['ampersand'] = 722;
14786 t['quoteright'] = 278;
14787 t['parenleft'] = 333;
14788 t['parenright'] = 333;
14789 t['asterisk'] = 389;
14790 t['plus'] = 584;
14791 t['comma'] = 278;
14792 t['hyphen'] = 333;
14793 t['period'] = 278;
14794 t['slash'] = 278;
14795 t['zero'] = 556;
14796 t['one'] = 556;
14797 t['two'] = 556;
14798 t['three'] = 556;
14799 t['four'] = 556;
14800 t['five'] = 556;
14801 t['six'] = 556;
14802 t['seven'] = 556;
14803 t['eight'] = 556;
14804 t['nine'] = 556;
14805 t['colon'] = 333;
14806 t['semicolon'] = 333;
14807 t['less'] = 584;
14808 t['equal'] = 584;
14809 t['greater'] = 584;
14810 t['question'] = 611;
14811 t['at'] = 975;
14812 t['A'] = 722;
14813 t['B'] = 722;
14814 t['C'] = 722;
14815 t['D'] = 722;
14816 t['E'] = 667;
14817 t['F'] = 611;
14818 t['G'] = 778;
14819 t['H'] = 722;
14820 t['I'] = 278;
14821 t['J'] = 556;
14822 t['K'] = 722;
14823 t['L'] = 611;
14824 t['M'] = 833;
14825 t['N'] = 722;
14826 t['O'] = 778;
14827 t['P'] = 667;
14828 t['Q'] = 778;
14829 t['R'] = 722;
14830 t['S'] = 667;
14831 t['T'] = 611;
14832 t['U'] = 722;
14833 t['V'] = 667;
14834 t['W'] = 944;
14835 t['X'] = 667;
14836 t['Y'] = 667;
14837 t['Z'] = 611;
14838 t['bracketleft'] = 333;
14839 t['backslash'] = 278;
14840 t['bracketright'] = 333;
14841 t['asciicircum'] = 584;
14842 t['underscore'] = 556;
14843 t['quoteleft'] = 278;
14844 t['a'] = 556;
14845 t['b'] = 611;
14846 t['c'] = 556;
14847 t['d'] = 611;
14848 t['e'] = 556;
14849 t['f'] = 333;
14850 t['g'] = 611;
14851 t['h'] = 611;
14852 t['i'] = 278;
14853 t['j'] = 278;
14854 t['k'] = 556;
14855 t['l'] = 278;
14856 t['m'] = 889;
14857 t['n'] = 611;
14858 t['o'] = 611;
14859 t['p'] = 611;
14860 t['q'] = 611;
14861 t['r'] = 389;
14862 t['s'] = 556;
14863 t['t'] = 333;
14864 t['u'] = 611;
14865 t['v'] = 556;
14866 t['w'] = 778;
14867 t['x'] = 556;
14868 t['y'] = 556;
14869 t['z'] = 500;
14870 t['braceleft'] = 389;
14871 t['bar'] = 280;
14872 t['braceright'] = 389;
14873 t['asciitilde'] = 584;
14874 t['exclamdown'] = 333;
14875 t['cent'] = 556;
14876 t['sterling'] = 556;
14877 t['fraction'] = 167;
14878 t['yen'] = 556;
14879 t['florin'] = 556;
14880 t['section'] = 556;
14881 t['currency'] = 556;
14882 t['quotesingle'] = 238;
14883 t['quotedblleft'] = 500;
14884 t['guillemotleft'] = 556;
14885 t['guilsinglleft'] = 333;
14886 t['guilsinglright'] = 333;
14887 t['fi'] = 611;
14888 t['fl'] = 611;
14889 t['endash'] = 556;
14890 t['dagger'] = 556;
14891 t['daggerdbl'] = 556;
14892 t['periodcentered'] = 278;
14893 t['paragraph'] = 556;
14894 t['bullet'] = 350;
14895 t['quotesinglbase'] = 278;
14896 t['quotedblbase'] = 500;
14897 t['quotedblright'] = 500;
14898 t['guillemotright'] = 556;
14899 t['ellipsis'] = 1000;
14900 t['perthousand'] = 1000;
14901 t['questiondown'] = 611;
14902 t['grave'] = 333;
14903 t['acute'] = 333;
14904 t['circumflex'] = 333;
14905 t['tilde'] = 333;
14906 t['macron'] = 333;
14907 t['breve'] = 333;
14908 t['dotaccent'] = 333;
14909 t['dieresis'] = 333;
14910 t['ring'] = 333;
14911 t['cedilla'] = 333;
14912 t['hungarumlaut'] = 333;
14913 t['ogonek'] = 333;
14914 t['caron'] = 333;
14915 t['emdash'] = 1000;
14916 t['AE'] = 1000;
14917 t['ordfeminine'] = 370;
14918 t['Lslash'] = 611;
14919 t['Oslash'] = 778;
14920 t['OE'] = 1000;
14921 t['ordmasculine'] = 365;
14922 t['ae'] = 889;
14923 t['dotlessi'] = 278;
14924 t['lslash'] = 278;
14925 t['oslash'] = 611;
14926 t['oe'] = 944;
14927 t['germandbls'] = 611;
14928 t['Idieresis'] = 278;
14929 t['eacute'] = 556;
14930 t['abreve'] = 556;
14931 t['uhungarumlaut'] = 611;
14932 t['ecaron'] = 556;
14933 t['Ydieresis'] = 667;
14934 t['divide'] = 584;
14935 t['Yacute'] = 667;
14936 t['Acircumflex'] = 722;
14937 t['aacute'] = 556;
14938 t['Ucircumflex'] = 722;
14939 t['yacute'] = 556;
14940 t['scommaaccent'] = 556;
14941 t['ecircumflex'] = 556;
14942 t['Uring'] = 722;
14943 t['Udieresis'] = 722;
14944 t['aogonek'] = 556;
14945 t['Uacute'] = 722;
14946 t['uogonek'] = 611;
14947 t['Edieresis'] = 667;
14948 t['Dcroat'] = 722;
14949 t['commaaccent'] = 250;
14950 t['copyright'] = 737;
14951 t['Emacron'] = 667;
14952 t['ccaron'] = 556;
14953 t['aring'] = 556;
14954 t['Ncommaaccent'] = 722;
14955 t['lacute'] = 278;
14956 t['agrave'] = 556;
14957 t['Tcommaaccent'] = 611;
14958 t['Cacute'] = 722;
14959 t['atilde'] = 556;
14960 t['Edotaccent'] = 667;
14961 t['scaron'] = 556;
14962 t['scedilla'] = 556;
14963 t['iacute'] = 278;
14964 t['lozenge'] = 494;
14965 t['Rcaron'] = 722;
14966 t['Gcommaaccent'] = 778;
14967 t['ucircumflex'] = 611;
14968 t['acircumflex'] = 556;
14969 t['Amacron'] = 722;
14970 t['rcaron'] = 389;
14971 t['ccedilla'] = 556;
14972 t['Zdotaccent'] = 611;
14973 t['Thorn'] = 667;
14974 t['Omacron'] = 778;
14975 t['Racute'] = 722;
14976 t['Sacute'] = 667;
14977 t['dcaron'] = 743;
14978 t['Umacron'] = 722;
14979 t['uring'] = 611;
14980 t['threesuperior'] = 333;
14981 t['Ograve'] = 778;
14982 t['Agrave'] = 722;
14983 t['Abreve'] = 722;
14984 t['multiply'] = 584;
14985 t['uacute'] = 611;
14986 t['Tcaron'] = 611;
14987 t['partialdiff'] = 494;
14988 t['ydieresis'] = 556;
14989 t['Nacute'] = 722;
14990 t['icircumflex'] = 278;
14991 t['Ecircumflex'] = 667;
14992 t['adieresis'] = 556;
14993 t['edieresis'] = 556;
14994 t['cacute'] = 556;
14995 t['nacute'] = 611;
14996 t['umacron'] = 611;
14997 t['Ncaron'] = 722;
14998 t['Iacute'] = 278;
14999 t['plusminus'] = 584;
15000 t['brokenbar'] = 280;
15001 t['registered'] = 737;
15002 t['Gbreve'] = 778;
15003 t['Idotaccent'] = 278;
15004 t['summation'] = 600;
15005 t['Egrave'] = 667;
15006 t['racute'] = 389;
15007 t['omacron'] = 611;
15008 t['Zacute'] = 611;
15009 t['Zcaron'] = 611;
15010 t['greaterequal'] = 549;
15011 t['Eth'] = 722;
15012 t['Ccedilla'] = 722;
15013 t['lcommaaccent'] = 278;
15014 t['tcaron'] = 389;
15015 t['eogonek'] = 556;
15016 t['Uogonek'] = 722;
15017 t['Aacute'] = 722;
15018 t['Adieresis'] = 722;
15019 t['egrave'] = 556;
15020 t['zacute'] = 500;
15021 t['iogonek'] = 278;
15022 t['Oacute'] = 778;
15023 t['oacute'] = 611;
15024 t['amacron'] = 556;
15025 t['sacute'] = 556;
15026 t['idieresis'] = 278;
15027 t['Ocircumflex'] = 778;
15028 t['Ugrave'] = 722;
15029 t['Delta'] = 612;
15030 t['thorn'] = 611;
15031 t['twosuperior'] = 333;
15032 t['Odieresis'] = 778;
15033 t['mu'] = 611;
15034 t['igrave'] = 278;
15035 t['ohungarumlaut'] = 611;
15036 t['Eogonek'] = 667;
15037 t['dcroat'] = 611;
15038 t['threequarters'] = 834;
15039 t['Scedilla'] = 667;
15040 t['lcaron'] = 400;
15041 t['Kcommaaccent'] = 722;
15042 t['Lacute'] = 611;
15043 t['trademark'] = 1000;
15044 t['edotaccent'] = 556;
15045 t['Igrave'] = 278;
15046 t['Imacron'] = 278;
15047 t['Lcaron'] = 611;
15048 t['onehalf'] = 834;
15049 t['lessequal'] = 549;
15050 t['ocircumflex'] = 611;
15051 t['ntilde'] = 611;
15052 t['Uhungarumlaut'] = 722;
15053 t['Eacute'] = 667;
15054 t['emacron'] = 556;
15055 t['gbreve'] = 611;
15056 t['onequarter'] = 834;
15057 t['Scaron'] = 667;
15058 t['Scommaaccent'] = 667;
15059 t['Ohungarumlaut'] = 778;
15060 t['degree'] = 400;
15061 t['ograve'] = 611;
15062 t['Ccaron'] = 722;
15063 t['ugrave'] = 611;
15064 t['radical'] = 549;
15065 t['Dcaron'] = 722;
15066 t['rcommaaccent'] = 389;
15067 t['Ntilde'] = 722;
15068 t['otilde'] = 611;
15069 t['Rcommaaccent'] = 722;
15070 t['Lcommaaccent'] = 611;
15071 t['Atilde'] = 722;
15072 t['Aogonek'] = 722;
15073 t['Aring'] = 722;
15074 t['Otilde'] = 778;
15075 t['zdotaccent'] = 500;
15076 t['Ecaron'] = 667;
15077 t['Iogonek'] = 278;
15078 t['kcommaaccent'] = 556;
15079 t['minus'] = 584;
15080 t['Icircumflex'] = 278;
15081 t['ncaron'] = 611;
15082 t['tcommaaccent'] = 333;
15083 t['logicalnot'] = 584;
15084 t['odieresis'] = 611;
15085 t['udieresis'] = 611;
15086 t['notequal'] = 549;
15087 t['gcommaaccent'] = 611;
15088 t['eth'] = 611;
15089 t['zcaron'] = 500;
15090 t['ncommaaccent'] = 611;
15091 t['onesuperior'] = 333;
15092 t['imacron'] = 278;
15093 t['Euro'] = 556;
15094 });
15095 t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
15096 t['space'] = 278;
15097 t['exclam'] = 333;
15098 t['quotedbl'] = 474;
15099 t['numbersign'] = 556;
15100 t['dollar'] = 556;
15101 t['percent'] = 889;
15102 t['ampersand'] = 722;
15103 t['quoteright'] = 278;
15104 t['parenleft'] = 333;
15105 t['parenright'] = 333;
15106 t['asterisk'] = 389;
15107 t['plus'] = 584;
15108 t['comma'] = 278;
15109 t['hyphen'] = 333;
15110 t['period'] = 278;
15111 t['slash'] = 278;
15112 t['zero'] = 556;
15113 t['one'] = 556;
15114 t['two'] = 556;
15115 t['three'] = 556;
15116 t['four'] = 556;
15117 t['five'] = 556;
15118 t['six'] = 556;
15119 t['seven'] = 556;
15120 t['eight'] = 556;
15121 t['nine'] = 556;
15122 t['colon'] = 333;
15123 t['semicolon'] = 333;
15124 t['less'] = 584;
15125 t['equal'] = 584;
15126 t['greater'] = 584;
15127 t['question'] = 611;
15128 t['at'] = 975;
15129 t['A'] = 722;
15130 t['B'] = 722;
15131 t['C'] = 722;
15132 t['D'] = 722;
15133 t['E'] = 667;
15134 t['F'] = 611;
15135 t['G'] = 778;
15136 t['H'] = 722;
15137 t['I'] = 278;
15138 t['J'] = 556;
15139 t['K'] = 722;
15140 t['L'] = 611;
15141 t['M'] = 833;
15142 t['N'] = 722;
15143 t['O'] = 778;
15144 t['P'] = 667;
15145 t['Q'] = 778;
15146 t['R'] = 722;
15147 t['S'] = 667;
15148 t['T'] = 611;
15149 t['U'] = 722;
15150 t['V'] = 667;
15151 t['W'] = 944;
15152 t['X'] = 667;
15153 t['Y'] = 667;
15154 t['Z'] = 611;
15155 t['bracketleft'] = 333;
15156 t['backslash'] = 278;
15157 t['bracketright'] = 333;
15158 t['asciicircum'] = 584;
15159 t['underscore'] = 556;
15160 t['quoteleft'] = 278;
15161 t['a'] = 556;
15162 t['b'] = 611;
15163 t['c'] = 556;
15164 t['d'] = 611;
15165 t['e'] = 556;
15166 t['f'] = 333;
15167 t['g'] = 611;
15168 t['h'] = 611;
15169 t['i'] = 278;
15170 t['j'] = 278;
15171 t['k'] = 556;
15172 t['l'] = 278;
15173 t['m'] = 889;
15174 t['n'] = 611;
15175 t['o'] = 611;
15176 t['p'] = 611;
15177 t['q'] = 611;
15178 t['r'] = 389;
15179 t['s'] = 556;
15180 t['t'] = 333;
15181 t['u'] = 611;
15182 t['v'] = 556;
15183 t['w'] = 778;
15184 t['x'] = 556;
15185 t['y'] = 556;
15186 t['z'] = 500;
15187 t['braceleft'] = 389;
15188 t['bar'] = 280;
15189 t['braceright'] = 389;
15190 t['asciitilde'] = 584;
15191 t['exclamdown'] = 333;
15192 t['cent'] = 556;
15193 t['sterling'] = 556;
15194 t['fraction'] = 167;
15195 t['yen'] = 556;
15196 t['florin'] = 556;
15197 t['section'] = 556;
15198 t['currency'] = 556;
15199 t['quotesingle'] = 238;
15200 t['quotedblleft'] = 500;
15201 t['guillemotleft'] = 556;
15202 t['guilsinglleft'] = 333;
15203 t['guilsinglright'] = 333;
15204 t['fi'] = 611;
15205 t['fl'] = 611;
15206 t['endash'] = 556;
15207 t['dagger'] = 556;
15208 t['daggerdbl'] = 556;
15209 t['periodcentered'] = 278;
15210 t['paragraph'] = 556;
15211 t['bullet'] = 350;
15212 t['quotesinglbase'] = 278;
15213 t['quotedblbase'] = 500;
15214 t['quotedblright'] = 500;
15215 t['guillemotright'] = 556;
15216 t['ellipsis'] = 1000;
15217 t['perthousand'] = 1000;
15218 t['questiondown'] = 611;
15219 t['grave'] = 333;
15220 t['acute'] = 333;
15221 t['circumflex'] = 333;
15222 t['tilde'] = 333;
15223 t['macron'] = 333;
15224 t['breve'] = 333;
15225 t['dotaccent'] = 333;
15226 t['dieresis'] = 333;
15227 t['ring'] = 333;
15228 t['cedilla'] = 333;
15229 t['hungarumlaut'] = 333;
15230 t['ogonek'] = 333;
15231 t['caron'] = 333;
15232 t['emdash'] = 1000;
15233 t['AE'] = 1000;
15234 t['ordfeminine'] = 370;
15235 t['Lslash'] = 611;
15236 t['Oslash'] = 778;
15237 t['OE'] = 1000;
15238 t['ordmasculine'] = 365;
15239 t['ae'] = 889;
15240 t['dotlessi'] = 278;
15241 t['lslash'] = 278;
15242 t['oslash'] = 611;
15243 t['oe'] = 944;
15244 t['germandbls'] = 611;
15245 t['Idieresis'] = 278;
15246 t['eacute'] = 556;
15247 t['abreve'] = 556;
15248 t['uhungarumlaut'] = 611;
15249 t['ecaron'] = 556;
15250 t['Ydieresis'] = 667;
15251 t['divide'] = 584;
15252 t['Yacute'] = 667;
15253 t['Acircumflex'] = 722;
15254 t['aacute'] = 556;
15255 t['Ucircumflex'] = 722;
15256 t['yacute'] = 556;
15257 t['scommaaccent'] = 556;
15258 t['ecircumflex'] = 556;
15259 t['Uring'] = 722;
15260 t['Udieresis'] = 722;
15261 t['aogonek'] = 556;
15262 t['Uacute'] = 722;
15263 t['uogonek'] = 611;
15264 t['Edieresis'] = 667;
15265 t['Dcroat'] = 722;
15266 t['commaaccent'] = 250;
15267 t['copyright'] = 737;
15268 t['Emacron'] = 667;
15269 t['ccaron'] = 556;
15270 t['aring'] = 556;
15271 t['Ncommaaccent'] = 722;
15272 t['lacute'] = 278;
15273 t['agrave'] = 556;
15274 t['Tcommaaccent'] = 611;
15275 t['Cacute'] = 722;
15276 t['atilde'] = 556;
15277 t['Edotaccent'] = 667;
15278 t['scaron'] = 556;
15279 t['scedilla'] = 556;
15280 t['iacute'] = 278;
15281 t['lozenge'] = 494;
15282 t['Rcaron'] = 722;
15283 t['Gcommaaccent'] = 778;
15284 t['ucircumflex'] = 611;
15285 t['acircumflex'] = 556;
15286 t['Amacron'] = 722;
15287 t['rcaron'] = 389;
15288 t['ccedilla'] = 556;
15289 t['Zdotaccent'] = 611;
15290 t['Thorn'] = 667;
15291 t['Omacron'] = 778;
15292 t['Racute'] = 722;
15293 t['Sacute'] = 667;
15294 t['dcaron'] = 743;
15295 t['Umacron'] = 722;
15296 t['uring'] = 611;
15297 t['threesuperior'] = 333;
15298 t['Ograve'] = 778;
15299 t['Agrave'] = 722;
15300 t['Abreve'] = 722;
15301 t['multiply'] = 584;
15302 t['uacute'] = 611;
15303 t['Tcaron'] = 611;
15304 t['partialdiff'] = 494;
15305 t['ydieresis'] = 556;
15306 t['Nacute'] = 722;
15307 t['icircumflex'] = 278;
15308 t['Ecircumflex'] = 667;
15309 t['adieresis'] = 556;
15310 t['edieresis'] = 556;
15311 t['cacute'] = 556;
15312 t['nacute'] = 611;
15313 t['umacron'] = 611;
15314 t['Ncaron'] = 722;
15315 t['Iacute'] = 278;
15316 t['plusminus'] = 584;
15317 t['brokenbar'] = 280;
15318 t['registered'] = 737;
15319 t['Gbreve'] = 778;
15320 t['Idotaccent'] = 278;
15321 t['summation'] = 600;
15322 t['Egrave'] = 667;
15323 t['racute'] = 389;
15324 t['omacron'] = 611;
15325 t['Zacute'] = 611;
15326 t['Zcaron'] = 611;
15327 t['greaterequal'] = 549;
15328 t['Eth'] = 722;
15329 t['Ccedilla'] = 722;
15330 t['lcommaaccent'] = 278;
15331 t['tcaron'] = 389;
15332 t['eogonek'] = 556;
15333 t['Uogonek'] = 722;
15334 t['Aacute'] = 722;
15335 t['Adieresis'] = 722;
15336 t['egrave'] = 556;
15337 t['zacute'] = 500;
15338 t['iogonek'] = 278;
15339 t['Oacute'] = 778;
15340 t['oacute'] = 611;
15341 t['amacron'] = 556;
15342 t['sacute'] = 556;
15343 t['idieresis'] = 278;
15344 t['Ocircumflex'] = 778;
15345 t['Ugrave'] = 722;
15346 t['Delta'] = 612;
15347 t['thorn'] = 611;
15348 t['twosuperior'] = 333;
15349 t['Odieresis'] = 778;
15350 t['mu'] = 611;
15351 t['igrave'] = 278;
15352 t['ohungarumlaut'] = 611;
15353 t['Eogonek'] = 667;
15354 t['dcroat'] = 611;
15355 t['threequarters'] = 834;
15356 t['Scedilla'] = 667;
15357 t['lcaron'] = 400;
15358 t['Kcommaaccent'] = 722;
15359 t['Lacute'] = 611;
15360 t['trademark'] = 1000;
15361 t['edotaccent'] = 556;
15362 t['Igrave'] = 278;
15363 t['Imacron'] = 278;
15364 t['Lcaron'] = 611;
15365 t['onehalf'] = 834;
15366 t['lessequal'] = 549;
15367 t['ocircumflex'] = 611;
15368 t['ntilde'] = 611;
15369 t['Uhungarumlaut'] = 722;
15370 t['Eacute'] = 667;
15371 t['emacron'] = 556;
15372 t['gbreve'] = 611;
15373 t['onequarter'] = 834;
15374 t['Scaron'] = 667;
15375 t['Scommaaccent'] = 667;
15376 t['Ohungarumlaut'] = 778;
15377 t['degree'] = 400;
15378 t['ograve'] = 611;
15379 t['Ccaron'] = 722;
15380 t['ugrave'] = 611;
15381 t['radical'] = 549;
15382 t['Dcaron'] = 722;
15383 t['rcommaaccent'] = 389;
15384 t['Ntilde'] = 722;
15385 t['otilde'] = 611;
15386 t['Rcommaaccent'] = 722;
15387 t['Lcommaaccent'] = 611;
15388 t['Atilde'] = 722;
15389 t['Aogonek'] = 722;
15390 t['Aring'] = 722;
15391 t['Otilde'] = 778;
15392 t['zdotaccent'] = 500;
15393 t['Ecaron'] = 667;
15394 t['Iogonek'] = 278;
15395 t['kcommaaccent'] = 556;
15396 t['minus'] = 584;
15397 t['Icircumflex'] = 278;
15398 t['ncaron'] = 611;
15399 t['tcommaaccent'] = 333;
15400 t['logicalnot'] = 584;
15401 t['odieresis'] = 611;
15402 t['udieresis'] = 611;
15403 t['notequal'] = 549;
15404 t['gcommaaccent'] = 611;
15405 t['eth'] = 611;
15406 t['zcaron'] = 500;
15407 t['ncommaaccent'] = 611;
15408 t['onesuperior'] = 333;
15409 t['imacron'] = 278;
15410 t['Euro'] = 556;
15411 });
15412 t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
15413 t['space'] = 278;
15414 t['exclam'] = 278;
15415 t['quotedbl'] = 355;
15416 t['numbersign'] = 556;
15417 t['dollar'] = 556;
15418 t['percent'] = 889;
15419 t['ampersand'] = 667;
15420 t['quoteright'] = 222;
15421 t['parenleft'] = 333;
15422 t['parenright'] = 333;
15423 t['asterisk'] = 389;
15424 t['plus'] = 584;
15425 t['comma'] = 278;
15426 t['hyphen'] = 333;
15427 t['period'] = 278;
15428 t['slash'] = 278;
15429 t['zero'] = 556;
15430 t['one'] = 556;
15431 t['two'] = 556;
15432 t['three'] = 556;
15433 t['four'] = 556;
15434 t['five'] = 556;
15435 t['six'] = 556;
15436 t['seven'] = 556;
15437 t['eight'] = 556;
15438 t['nine'] = 556;
15439 t['colon'] = 278;
15440 t['semicolon'] = 278;
15441 t['less'] = 584;
15442 t['equal'] = 584;
15443 t['greater'] = 584;
15444 t['question'] = 556;
15445 t['at'] = 1015;
15446 t['A'] = 667;
15447 t['B'] = 667;
15448 t['C'] = 722;
15449 t['D'] = 722;
15450 t['E'] = 667;
15451 t['F'] = 611;
15452 t['G'] = 778;
15453 t['H'] = 722;
15454 t['I'] = 278;
15455 t['J'] = 500;
15456 t['K'] = 667;
15457 t['L'] = 556;
15458 t['M'] = 833;
15459 t['N'] = 722;
15460 t['O'] = 778;
15461 t['P'] = 667;
15462 t['Q'] = 778;
15463 t['R'] = 722;
15464 t['S'] = 667;
15465 t['T'] = 611;
15466 t['U'] = 722;
15467 t['V'] = 667;
15468 t['W'] = 944;
15469 t['X'] = 667;
15470 t['Y'] = 667;
15471 t['Z'] = 611;
15472 t['bracketleft'] = 278;
15473 t['backslash'] = 278;
15474 t['bracketright'] = 278;
15475 t['asciicircum'] = 469;
15476 t['underscore'] = 556;
15477 t['quoteleft'] = 222;
15478 t['a'] = 556;
15479 t['b'] = 556;
15480 t['c'] = 500;
15481 t['d'] = 556;
15482 t['e'] = 556;
15483 t['f'] = 278;
15484 t['g'] = 556;
15485 t['h'] = 556;
15486 t['i'] = 222;
15487 t['j'] = 222;
15488 t['k'] = 500;
15489 t['l'] = 222;
15490 t['m'] = 833;
15491 t['n'] = 556;
15492 t['o'] = 556;
15493 t['p'] = 556;
15494 t['q'] = 556;
15495 t['r'] = 333;
15496 t['s'] = 500;
15497 t['t'] = 278;
15498 t['u'] = 556;
15499 t['v'] = 500;
15500 t['w'] = 722;
15501 t['x'] = 500;
15502 t['y'] = 500;
15503 t['z'] = 500;
15504 t['braceleft'] = 334;
15505 t['bar'] = 260;
15506 t['braceright'] = 334;
15507 t['asciitilde'] = 584;
15508 t['exclamdown'] = 333;
15509 t['cent'] = 556;
15510 t['sterling'] = 556;
15511 t['fraction'] = 167;
15512 t['yen'] = 556;
15513 t['florin'] = 556;
15514 t['section'] = 556;
15515 t['currency'] = 556;
15516 t['quotesingle'] = 191;
15517 t['quotedblleft'] = 333;
15518 t['guillemotleft'] = 556;
15519 t['guilsinglleft'] = 333;
15520 t['guilsinglright'] = 333;
15521 t['fi'] = 500;
15522 t['fl'] = 500;
15523 t['endash'] = 556;
15524 t['dagger'] = 556;
15525 t['daggerdbl'] = 556;
15526 t['periodcentered'] = 278;
15527 t['paragraph'] = 537;
15528 t['bullet'] = 350;
15529 t['quotesinglbase'] = 222;
15530 t['quotedblbase'] = 333;
15531 t['quotedblright'] = 333;
15532 t['guillemotright'] = 556;
15533 t['ellipsis'] = 1000;
15534 t['perthousand'] = 1000;
15535 t['questiondown'] = 611;
15536 t['grave'] = 333;
15537 t['acute'] = 333;
15538 t['circumflex'] = 333;
15539 t['tilde'] = 333;
15540 t['macron'] = 333;
15541 t['breve'] = 333;
15542 t['dotaccent'] = 333;
15543 t['dieresis'] = 333;
15544 t['ring'] = 333;
15545 t['cedilla'] = 333;
15546 t['hungarumlaut'] = 333;
15547 t['ogonek'] = 333;
15548 t['caron'] = 333;
15549 t['emdash'] = 1000;
15550 t['AE'] = 1000;
15551 t['ordfeminine'] = 370;
15552 t['Lslash'] = 556;
15553 t['Oslash'] = 778;
15554 t['OE'] = 1000;
15555 t['ordmasculine'] = 365;
15556 t['ae'] = 889;
15557 t['dotlessi'] = 278;
15558 t['lslash'] = 222;
15559 t['oslash'] = 611;
15560 t['oe'] = 944;
15561 t['germandbls'] = 611;
15562 t['Idieresis'] = 278;
15563 t['eacute'] = 556;
15564 t['abreve'] = 556;
15565 t['uhungarumlaut'] = 556;
15566 t['ecaron'] = 556;
15567 t['Ydieresis'] = 667;
15568 t['divide'] = 584;
15569 t['Yacute'] = 667;
15570 t['Acircumflex'] = 667;
15571 t['aacute'] = 556;
15572 t['Ucircumflex'] = 722;
15573 t['yacute'] = 500;
15574 t['scommaaccent'] = 500;
15575 t['ecircumflex'] = 556;
15576 t['Uring'] = 722;
15577 t['Udieresis'] = 722;
15578 t['aogonek'] = 556;
15579 t['Uacute'] = 722;
15580 t['uogonek'] = 556;
15581 t['Edieresis'] = 667;
15582 t['Dcroat'] = 722;
15583 t['commaaccent'] = 250;
15584 t['copyright'] = 737;
15585 t['Emacron'] = 667;
15586 t['ccaron'] = 500;
15587 t['aring'] = 556;
15588 t['Ncommaaccent'] = 722;
15589 t['lacute'] = 222;
15590 t['agrave'] = 556;
15591 t['Tcommaaccent'] = 611;
15592 t['Cacute'] = 722;
15593 t['atilde'] = 556;
15594 t['Edotaccent'] = 667;
15595 t['scaron'] = 500;
15596 t['scedilla'] = 500;
15597 t['iacute'] = 278;
15598 t['lozenge'] = 471;
15599 t['Rcaron'] = 722;
15600 t['Gcommaaccent'] = 778;
15601 t['ucircumflex'] = 556;
15602 t['acircumflex'] = 556;
15603 t['Amacron'] = 667;
15604 t['rcaron'] = 333;
15605 t['ccedilla'] = 500;
15606 t['Zdotaccent'] = 611;
15607 t['Thorn'] = 667;
15608 t['Omacron'] = 778;
15609 t['Racute'] = 722;
15610 t['Sacute'] = 667;
15611 t['dcaron'] = 643;
15612 t['Umacron'] = 722;
15613 t['uring'] = 556;
15614 t['threesuperior'] = 333;
15615 t['Ograve'] = 778;
15616 t['Agrave'] = 667;
15617 t['Abreve'] = 667;
15618 t['multiply'] = 584;
15619 t['uacute'] = 556;
15620 t['Tcaron'] = 611;
15621 t['partialdiff'] = 476;
15622 t['ydieresis'] = 500;
15623 t['Nacute'] = 722;
15624 t['icircumflex'] = 278;
15625 t['Ecircumflex'] = 667;
15626 t['adieresis'] = 556;
15627 t['edieresis'] = 556;
15628 t['cacute'] = 500;
15629 t['nacute'] = 556;
15630 t['umacron'] = 556;
15631 t['Ncaron'] = 722;
15632 t['Iacute'] = 278;
15633 t['plusminus'] = 584;
15634 t['brokenbar'] = 260;
15635 t['registered'] = 737;
15636 t['Gbreve'] = 778;
15637 t['Idotaccent'] = 278;
15638 t['summation'] = 600;
15639 t['Egrave'] = 667;
15640 t['racute'] = 333;
15641 t['omacron'] = 556;
15642 t['Zacute'] = 611;
15643 t['Zcaron'] = 611;
15644 t['greaterequal'] = 549;
15645 t['Eth'] = 722;
15646 t['Ccedilla'] = 722;
15647 t['lcommaaccent'] = 222;
15648 t['tcaron'] = 317;
15649 t['eogonek'] = 556;
15650 t['Uogonek'] = 722;
15651 t['Aacute'] = 667;
15652 t['Adieresis'] = 667;
15653 t['egrave'] = 556;
15654 t['zacute'] = 500;
15655 t['iogonek'] = 222;
15656 t['Oacute'] = 778;
15657 t['oacute'] = 556;
15658 t['amacron'] = 556;
15659 t['sacute'] = 500;
15660 t['idieresis'] = 278;
15661 t['Ocircumflex'] = 778;
15662 t['Ugrave'] = 722;
15663 t['Delta'] = 612;
15664 t['thorn'] = 556;
15665 t['twosuperior'] = 333;
15666 t['Odieresis'] = 778;
15667 t['mu'] = 556;
15668 t['igrave'] = 278;
15669 t['ohungarumlaut'] = 556;
15670 t['Eogonek'] = 667;
15671 t['dcroat'] = 556;
15672 t['threequarters'] = 834;
15673 t['Scedilla'] = 667;
15674 t['lcaron'] = 299;
15675 t['Kcommaaccent'] = 667;
15676 t['Lacute'] = 556;
15677 t['trademark'] = 1000;
15678 t['edotaccent'] = 556;
15679 t['Igrave'] = 278;
15680 t['Imacron'] = 278;
15681 t['Lcaron'] = 556;
15682 t['onehalf'] = 834;
15683 t['lessequal'] = 549;
15684 t['ocircumflex'] = 556;
15685 t['ntilde'] = 556;
15686 t['Uhungarumlaut'] = 722;
15687 t['Eacute'] = 667;
15688 t['emacron'] = 556;
15689 t['gbreve'] = 556;
15690 t['onequarter'] = 834;
15691 t['Scaron'] = 667;
15692 t['Scommaaccent'] = 667;
15693 t['Ohungarumlaut'] = 778;
15694 t['degree'] = 400;
15695 t['ograve'] = 556;
15696 t['Ccaron'] = 722;
15697 t['ugrave'] = 556;
15698 t['radical'] = 453;
15699 t['Dcaron'] = 722;
15700 t['rcommaaccent'] = 333;
15701 t['Ntilde'] = 722;
15702 t['otilde'] = 556;
15703 t['Rcommaaccent'] = 722;
15704 t['Lcommaaccent'] = 556;
15705 t['Atilde'] = 667;
15706 t['Aogonek'] = 667;
15707 t['Aring'] = 667;
15708 t['Otilde'] = 778;
15709 t['zdotaccent'] = 500;
15710 t['Ecaron'] = 667;
15711 t['Iogonek'] = 278;
15712 t['kcommaaccent'] = 500;
15713 t['minus'] = 584;
15714 t['Icircumflex'] = 278;
15715 t['ncaron'] = 556;
15716 t['tcommaaccent'] = 278;
15717 t['logicalnot'] = 584;
15718 t['odieresis'] = 556;
15719 t['udieresis'] = 556;
15720 t['notequal'] = 549;
15721 t['gcommaaccent'] = 556;
15722 t['eth'] = 556;
15723 t['zcaron'] = 500;
15724 t['ncommaaccent'] = 556;
15725 t['onesuperior'] = 333;
15726 t['imacron'] = 278;
15727 t['Euro'] = 556;
15728 });
15729 t['Symbol'] = getLookupTableFactory(function (t) {
15730 t['space'] = 250;
15731 t['exclam'] = 333;
15732 t['universal'] = 713;
15733 t['numbersign'] = 500;
15734 t['existential'] = 549;
15735 t['percent'] = 833;
15736 t['ampersand'] = 778;
15737 t['suchthat'] = 439;
15738 t['parenleft'] = 333;
15739 t['parenright'] = 333;
15740 t['asteriskmath'] = 500;
15741 t['plus'] = 549;
15742 t['comma'] = 250;
15743 t['minus'] = 549;
15744 t['period'] = 250;
15745 t['slash'] = 278;
15746 t['zero'] = 500;
15747 t['one'] = 500;
15748 t['two'] = 500;
15749 t['three'] = 500;
15750 t['four'] = 500;
15751 t['five'] = 500;
15752 t['six'] = 500;
15753 t['seven'] = 500;
15754 t['eight'] = 500;
15755 t['nine'] = 500;
15756 t['colon'] = 278;
15757 t['semicolon'] = 278;
15758 t['less'] = 549;
15759 t['equal'] = 549;
15760 t['greater'] = 549;
15761 t['question'] = 444;
15762 t['congruent'] = 549;
15763 t['Alpha'] = 722;
15764 t['Beta'] = 667;
15765 t['Chi'] = 722;
15766 t['Delta'] = 612;
15767 t['Epsilon'] = 611;
15768 t['Phi'] = 763;
15769 t['Gamma'] = 603;
15770 t['Eta'] = 722;
15771 t['Iota'] = 333;
15772 t['theta1'] = 631;
15773 t['Kappa'] = 722;
15774 t['Lambda'] = 686;
15775 t['Mu'] = 889;
15776 t['Nu'] = 722;
15777 t['Omicron'] = 722;
15778 t['Pi'] = 768;
15779 t['Theta'] = 741;
15780 t['Rho'] = 556;
15781 t['Sigma'] = 592;
15782 t['Tau'] = 611;
15783 t['Upsilon'] = 690;
15784 t['sigma1'] = 439;
15785 t['Omega'] = 768;
15786 t['Xi'] = 645;
15787 t['Psi'] = 795;
15788 t['Zeta'] = 611;
15789 t['bracketleft'] = 333;
15790 t['therefore'] = 863;
15791 t['bracketright'] = 333;
15792 t['perpendicular'] = 658;
15793 t['underscore'] = 500;
15794 t['radicalex'] = 500;
15795 t['alpha'] = 631;
15796 t['beta'] = 549;
15797 t['chi'] = 549;
15798 t['delta'] = 494;
15799 t['epsilon'] = 439;
15800 t['phi'] = 521;
15801 t['gamma'] = 411;
15802 t['eta'] = 603;
15803 t['iota'] = 329;
15804 t['phi1'] = 603;
15805 t['kappa'] = 549;
15806 t['lambda'] = 549;
15807 t['mu'] = 576;
15808 t['nu'] = 521;
15809 t['omicron'] = 549;
15810 t['pi'] = 549;
15811 t['theta'] = 521;
15812 t['rho'] = 549;
15813 t['sigma'] = 603;
15814 t['tau'] = 439;
15815 t['upsilon'] = 576;
15816 t['omega1'] = 713;
15817 t['omega'] = 686;
15818 t['xi'] = 493;
15819 t['psi'] = 686;
15820 t['zeta'] = 494;
15821 t['braceleft'] = 480;
15822 t['bar'] = 200;
15823 t['braceright'] = 480;
15824 t['similar'] = 549;
15825 t['Euro'] = 750;
15826 t['Upsilon1'] = 620;
15827 t['minute'] = 247;
15828 t['lessequal'] = 549;
15829 t['fraction'] = 167;
15830 t['infinity'] = 713;
15831 t['florin'] = 500;
15832 t['club'] = 753;
15833 t['diamond'] = 753;
15834 t['heart'] = 753;
15835 t['spade'] = 753;
15836 t['arrowboth'] = 1042;
15837 t['arrowleft'] = 987;
15838 t['arrowup'] = 603;
15839 t['arrowright'] = 987;
15840 t['arrowdown'] = 603;
15841 t['degree'] = 400;
15842 t['plusminus'] = 549;
15843 t['second'] = 411;
15844 t['greaterequal'] = 549;
15845 t['multiply'] = 549;
15846 t['proportional'] = 713;
15847 t['partialdiff'] = 494;
15848 t['bullet'] = 460;
15849 t['divide'] = 549;
15850 t['notequal'] = 549;
15851 t['equivalence'] = 549;
15852 t['approxequal'] = 549;
15853 t['ellipsis'] = 1000;
15854 t['arrowvertex'] = 603;
15855 t['arrowhorizex'] = 1000;
15856 t['carriagereturn'] = 658;
15857 t['aleph'] = 823;
15858 t['Ifraktur'] = 686;
15859 t['Rfraktur'] = 795;
15860 t['weierstrass'] = 987;
15861 t['circlemultiply'] = 768;
15862 t['circleplus'] = 768;
15863 t['emptyset'] = 823;
15864 t['intersection'] = 768;
15865 t['union'] = 768;
15866 t['propersuperset'] = 713;
15867 t['reflexsuperset'] = 713;
15868 t['notsubset'] = 713;
15869 t['propersubset'] = 713;
15870 t['reflexsubset'] = 713;
15871 t['element'] = 713;
15872 t['notelement'] = 713;
15873 t['angle'] = 768;
15874 t['gradient'] = 713;
15875 t['registerserif'] = 790;
15876 t['copyrightserif'] = 790;
15877 t['trademarkserif'] = 890;
15878 t['product'] = 823;
15879 t['radical'] = 549;
15880 t['dotmath'] = 250;
15881 t['logicalnot'] = 713;
15882 t['logicaland'] = 603;
15883 t['logicalor'] = 603;
15884 t['arrowdblboth'] = 1042;
15885 t['arrowdblleft'] = 987;
15886 t['arrowdblup'] = 603;
15887 t['arrowdblright'] = 987;
15888 t['arrowdbldown'] = 603;
15889 t['lozenge'] = 494;
15890 t['angleleft'] = 329;
15891 t['registersans'] = 790;
15892 t['copyrightsans'] = 790;
15893 t['trademarksans'] = 786;
15894 t['summation'] = 713;
15895 t['parenlefttp'] = 384;
15896 t['parenleftex'] = 384;
15897 t['parenleftbt'] = 384;
15898 t['bracketlefttp'] = 384;
15899 t['bracketleftex'] = 384;
15900 t['bracketleftbt'] = 384;
15901 t['bracelefttp'] = 494;
15902 t['braceleftmid'] = 494;
15903 t['braceleftbt'] = 494;
15904 t['braceex'] = 494;
15905 t['angleright'] = 329;
15906 t['integral'] = 274;
15907 t['integraltp'] = 686;
15908 t['integralex'] = 686;
15909 t['integralbt'] = 686;
15910 t['parenrighttp'] = 384;
15911 t['parenrightex'] = 384;
15912 t['parenrightbt'] = 384;
15913 t['bracketrighttp'] = 384;
15914 t['bracketrightex'] = 384;
15915 t['bracketrightbt'] = 384;
15916 t['bracerighttp'] = 494;
15917 t['bracerightmid'] = 494;
15918 t['bracerightbt'] = 494;
15919 t['apple'] = 790;
15920 });
15921 t['Times-Roman'] = getLookupTableFactory(function (t) {
15922 t['space'] = 250;
15923 t['exclam'] = 333;
15924 t['quotedbl'] = 408;
15925 t['numbersign'] = 500;
15926 t['dollar'] = 500;
15927 t['percent'] = 833;
15928 t['ampersand'] = 778;
15929 t['quoteright'] = 333;
15930 t['parenleft'] = 333;
15931 t['parenright'] = 333;
15932 t['asterisk'] = 500;
15933 t['plus'] = 564;
15934 t['comma'] = 250;
15935 t['hyphen'] = 333;
15936 t['period'] = 250;
15937 t['slash'] = 278;
15938 t['zero'] = 500;
15939 t['one'] = 500;
15940 t['two'] = 500;
15941 t['three'] = 500;
15942 t['four'] = 500;
15943 t['five'] = 500;
15944 t['six'] = 500;
15945 t['seven'] = 500;
15946 t['eight'] = 500;
15947 t['nine'] = 500;
15948 t['colon'] = 278;
15949 t['semicolon'] = 278;
15950 t['less'] = 564;
15951 t['equal'] = 564;
15952 t['greater'] = 564;
15953 t['question'] = 444;
15954 t['at'] = 921;
15955 t['A'] = 722;
15956 t['B'] = 667;
15957 t['C'] = 667;
15958 t['D'] = 722;
15959 t['E'] = 611;
15960 t['F'] = 556;
15961 t['G'] = 722;
15962 t['H'] = 722;
15963 t['I'] = 333;
15964 t['J'] = 389;
15965 t['K'] = 722;
15966 t['L'] = 611;
15967 t['M'] = 889;
15968 t['N'] = 722;
15969 t['O'] = 722;
15970 t['P'] = 556;
15971 t['Q'] = 722;
15972 t['R'] = 667;
15973 t['S'] = 556;
15974 t['T'] = 611;
15975 t['U'] = 722;
15976 t['V'] = 722;
15977 t['W'] = 944;
15978 t['X'] = 722;
15979 t['Y'] = 722;
15980 t['Z'] = 611;
15981 t['bracketleft'] = 333;
15982 t['backslash'] = 278;
15983 t['bracketright'] = 333;
15984 t['asciicircum'] = 469;
15985 t['underscore'] = 500;
15986 t['quoteleft'] = 333;
15987 t['a'] = 444;
15988 t['b'] = 500;
15989 t['c'] = 444;
15990 t['d'] = 500;
15991 t['e'] = 444;
15992 t['f'] = 333;
15993 t['g'] = 500;
15994 t['h'] = 500;
15995 t['i'] = 278;
15996 t['j'] = 278;
15997 t['k'] = 500;
15998 t['l'] = 278;
15999 t['m'] = 778;
16000 t['n'] = 500;
16001 t['o'] = 500;
16002 t['p'] = 500;
16003 t['q'] = 500;
16004 t['r'] = 333;
16005 t['s'] = 389;
16006 t['t'] = 278;
16007 t['u'] = 500;
16008 t['v'] = 500;
16009 t['w'] = 722;
16010 t['x'] = 500;
16011 t['y'] = 500;
16012 t['z'] = 444;
16013 t['braceleft'] = 480;
16014 t['bar'] = 200;
16015 t['braceright'] = 480;
16016 t['asciitilde'] = 541;
16017 t['exclamdown'] = 333;
16018 t['cent'] = 500;
16019 t['sterling'] = 500;
16020 t['fraction'] = 167;
16021 t['yen'] = 500;
16022 t['florin'] = 500;
16023 t['section'] = 500;
16024 t['currency'] = 500;
16025 t['quotesingle'] = 180;
16026 t['quotedblleft'] = 444;
16027 t['guillemotleft'] = 500;
16028 t['guilsinglleft'] = 333;
16029 t['guilsinglright'] = 333;
16030 t['fi'] = 556;
16031 t['fl'] = 556;
16032 t['endash'] = 500;
16033 t['dagger'] = 500;
16034 t['daggerdbl'] = 500;
16035 t['periodcentered'] = 250;
16036 t['paragraph'] = 453;
16037 t['bullet'] = 350;
16038 t['quotesinglbase'] = 333;
16039 t['quotedblbase'] = 444;
16040 t['quotedblright'] = 444;
16041 t['guillemotright'] = 500;
16042 t['ellipsis'] = 1000;
16043 t['perthousand'] = 1000;
16044 t['questiondown'] = 444;
16045 t['grave'] = 333;
16046 t['acute'] = 333;
16047 t['circumflex'] = 333;
16048 t['tilde'] = 333;
16049 t['macron'] = 333;
16050 t['breve'] = 333;
16051 t['dotaccent'] = 333;
16052 t['dieresis'] = 333;
16053 t['ring'] = 333;
16054 t['cedilla'] = 333;
16055 t['hungarumlaut'] = 333;
16056 t['ogonek'] = 333;
16057 t['caron'] = 333;
16058 t['emdash'] = 1000;
16059 t['AE'] = 889;
16060 t['ordfeminine'] = 276;
16061 t['Lslash'] = 611;
16062 t['Oslash'] = 722;
16063 t['OE'] = 889;
16064 t['ordmasculine'] = 310;
16065 t['ae'] = 667;
16066 t['dotlessi'] = 278;
16067 t['lslash'] = 278;
16068 t['oslash'] = 500;
16069 t['oe'] = 722;
16070 t['germandbls'] = 500;
16071 t['Idieresis'] = 333;
16072 t['eacute'] = 444;
16073 t['abreve'] = 444;
16074 t['uhungarumlaut'] = 500;
16075 t['ecaron'] = 444;
16076 t['Ydieresis'] = 722;
16077 t['divide'] = 564;
16078 t['Yacute'] = 722;
16079 t['Acircumflex'] = 722;
16080 t['aacute'] = 444;
16081 t['Ucircumflex'] = 722;
16082 t['yacute'] = 500;
16083 t['scommaaccent'] = 389;
16084 t['ecircumflex'] = 444;
16085 t['Uring'] = 722;
16086 t['Udieresis'] = 722;
16087 t['aogonek'] = 444;
16088 t['Uacute'] = 722;
16089 t['uogonek'] = 500;
16090 t['Edieresis'] = 611;
16091 t['Dcroat'] = 722;
16092 t['commaaccent'] = 250;
16093 t['copyright'] = 760;
16094 t['Emacron'] = 611;
16095 t['ccaron'] = 444;
16096 t['aring'] = 444;
16097 t['Ncommaaccent'] = 722;
16098 t['lacute'] = 278;
16099 t['agrave'] = 444;
16100 t['Tcommaaccent'] = 611;
16101 t['Cacute'] = 667;
16102 t['atilde'] = 444;
16103 t['Edotaccent'] = 611;
16104 t['scaron'] = 389;
16105 t['scedilla'] = 389;
16106 t['iacute'] = 278;
16107 t['lozenge'] = 471;
16108 t['Rcaron'] = 667;
16109 t['Gcommaaccent'] = 722;
16110 t['ucircumflex'] = 500;
16111 t['acircumflex'] = 444;
16112 t['Amacron'] = 722;
16113 t['rcaron'] = 333;
16114 t['ccedilla'] = 444;
16115 t['Zdotaccent'] = 611;
16116 t['Thorn'] = 556;
16117 t['Omacron'] = 722;
16118 t['Racute'] = 667;
16119 t['Sacute'] = 556;
16120 t['dcaron'] = 588;
16121 t['Umacron'] = 722;
16122 t['uring'] = 500;
16123 t['threesuperior'] = 300;
16124 t['Ograve'] = 722;
16125 t['Agrave'] = 722;
16126 t['Abreve'] = 722;
16127 t['multiply'] = 564;
16128 t['uacute'] = 500;
16129 t['Tcaron'] = 611;
16130 t['partialdiff'] = 476;
16131 t['ydieresis'] = 500;
16132 t['Nacute'] = 722;
16133 t['icircumflex'] = 278;
16134 t['Ecircumflex'] = 611;
16135 t['adieresis'] = 444;
16136 t['edieresis'] = 444;
16137 t['cacute'] = 444;
16138 t['nacute'] = 500;
16139 t['umacron'] = 500;
16140 t['Ncaron'] = 722;
16141 t['Iacute'] = 333;
16142 t['plusminus'] = 564;
16143 t['brokenbar'] = 200;
16144 t['registered'] = 760;
16145 t['Gbreve'] = 722;
16146 t['Idotaccent'] = 333;
16147 t['summation'] = 600;
16148 t['Egrave'] = 611;
16149 t['racute'] = 333;
16150 t['omacron'] = 500;
16151 t['Zacute'] = 611;
16152 t['Zcaron'] = 611;
16153 t['greaterequal'] = 549;
16154 t['Eth'] = 722;
16155 t['Ccedilla'] = 667;
16156 t['lcommaaccent'] = 278;
16157 t['tcaron'] = 326;
16158 t['eogonek'] = 444;
16159 t['Uogonek'] = 722;
16160 t['Aacute'] = 722;
16161 t['Adieresis'] = 722;
16162 t['egrave'] = 444;
16163 t['zacute'] = 444;
16164 t['iogonek'] = 278;
16165 t['Oacute'] = 722;
16166 t['oacute'] = 500;
16167 t['amacron'] = 444;
16168 t['sacute'] = 389;
16169 t['idieresis'] = 278;
16170 t['Ocircumflex'] = 722;
16171 t['Ugrave'] = 722;
16172 t['Delta'] = 612;
16173 t['thorn'] = 500;
16174 t['twosuperior'] = 300;
16175 t['Odieresis'] = 722;
16176 t['mu'] = 500;
16177 t['igrave'] = 278;
16178 t['ohungarumlaut'] = 500;
16179 t['Eogonek'] = 611;
16180 t['dcroat'] = 500;
16181 t['threequarters'] = 750;
16182 t['Scedilla'] = 556;
16183 t['lcaron'] = 344;
16184 t['Kcommaaccent'] = 722;
16185 t['Lacute'] = 611;
16186 t['trademark'] = 980;
16187 t['edotaccent'] = 444;
16188 t['Igrave'] = 333;
16189 t['Imacron'] = 333;
16190 t['Lcaron'] = 611;
16191 t['onehalf'] = 750;
16192 t['lessequal'] = 549;
16193 t['ocircumflex'] = 500;
16194 t['ntilde'] = 500;
16195 t['Uhungarumlaut'] = 722;
16196 t['Eacute'] = 611;
16197 t['emacron'] = 444;
16198 t['gbreve'] = 500;
16199 t['onequarter'] = 750;
16200 t['Scaron'] = 556;
16201 t['Scommaaccent'] = 556;
16202 t['Ohungarumlaut'] = 722;
16203 t['degree'] = 400;
16204 t['ograve'] = 500;
16205 t['Ccaron'] = 667;
16206 t['ugrave'] = 500;
16207 t['radical'] = 453;
16208 t['Dcaron'] = 722;
16209 t['rcommaaccent'] = 333;
16210 t['Ntilde'] = 722;
16211 t['otilde'] = 500;
16212 t['Rcommaaccent'] = 667;
16213 t['Lcommaaccent'] = 611;
16214 t['Atilde'] = 722;
16215 t['Aogonek'] = 722;
16216 t['Aring'] = 722;
16217 t['Otilde'] = 722;
16218 t['zdotaccent'] = 444;
16219 t['Ecaron'] = 611;
16220 t['Iogonek'] = 333;
16221 t['kcommaaccent'] = 500;
16222 t['minus'] = 564;
16223 t['Icircumflex'] = 333;
16224 t['ncaron'] = 500;
16225 t['tcommaaccent'] = 278;
16226 t['logicalnot'] = 564;
16227 t['odieresis'] = 500;
16228 t['udieresis'] = 500;
16229 t['notequal'] = 549;
16230 t['gcommaaccent'] = 500;
16231 t['eth'] = 500;
16232 t['zcaron'] = 444;
16233 t['ncommaaccent'] = 500;
16234 t['onesuperior'] = 300;
16235 t['imacron'] = 278;
16236 t['Euro'] = 500;
16237 });
16238 t['Times-Bold'] = getLookupTableFactory(function (t) {
16239 t['space'] = 250;
16240 t['exclam'] = 333;
16241 t['quotedbl'] = 555;
16242 t['numbersign'] = 500;
16243 t['dollar'] = 500;
16244 t['percent'] = 1000;
16245 t['ampersand'] = 833;
16246 t['quoteright'] = 333;
16247 t['parenleft'] = 333;
16248 t['parenright'] = 333;
16249 t['asterisk'] = 500;
16250 t['plus'] = 570;
16251 t['comma'] = 250;
16252 t['hyphen'] = 333;
16253 t['period'] = 250;
16254 t['slash'] = 278;
16255 t['zero'] = 500;
16256 t['one'] = 500;
16257 t['two'] = 500;
16258 t['three'] = 500;
16259 t['four'] = 500;
16260 t['five'] = 500;
16261 t['six'] = 500;
16262 t['seven'] = 500;
16263 t['eight'] = 500;
16264 t['nine'] = 500;
16265 t['colon'] = 333;
16266 t['semicolon'] = 333;
16267 t['less'] = 570;
16268 t['equal'] = 570;
16269 t['greater'] = 570;
16270 t['question'] = 500;
16271 t['at'] = 930;
16272 t['A'] = 722;
16273 t['B'] = 667;
16274 t['C'] = 722;
16275 t['D'] = 722;
16276 t['E'] = 667;
16277 t['F'] = 611;
16278 t['G'] = 778;
16279 t['H'] = 778;
16280 t['I'] = 389;
16281 t['J'] = 500;
16282 t['K'] = 778;
16283 t['L'] = 667;
16284 t['M'] = 944;
16285 t['N'] = 722;
16286 t['O'] = 778;
16287 t['P'] = 611;
16288 t['Q'] = 778;
16289 t['R'] = 722;
16290 t['S'] = 556;
16291 t['T'] = 667;
16292 t['U'] = 722;
16293 t['V'] = 722;
16294 t['W'] = 1000;
16295 t['X'] = 722;
16296 t['Y'] = 722;
16297 t['Z'] = 667;
16298 t['bracketleft'] = 333;
16299 t['backslash'] = 278;
16300 t['bracketright'] = 333;
16301 t['asciicircum'] = 581;
16302 t['underscore'] = 500;
16303 t['quoteleft'] = 333;
16304 t['a'] = 500;
16305 t['b'] = 556;
16306 t['c'] = 444;
16307 t['d'] = 556;
16308 t['e'] = 444;
16309 t['f'] = 333;
16310 t['g'] = 500;
16311 t['h'] = 556;
16312 t['i'] = 278;
16313 t['j'] = 333;
16314 t['k'] = 556;
16315 t['l'] = 278;
16316 t['m'] = 833;
16317 t['n'] = 556;
16318 t['o'] = 500;
16319 t['p'] = 556;
16320 t['q'] = 556;
16321 t['r'] = 444;
16322 t['s'] = 389;
16323 t['t'] = 333;
16324 t['u'] = 556;
16325 t['v'] = 500;
16326 t['w'] = 722;
16327 t['x'] = 500;
16328 t['y'] = 500;
16329 t['z'] = 444;
16330 t['braceleft'] = 394;
16331 t['bar'] = 220;
16332 t['braceright'] = 394;
16333 t['asciitilde'] = 520;
16334 t['exclamdown'] = 333;
16335 t['cent'] = 500;
16336 t['sterling'] = 500;
16337 t['fraction'] = 167;
16338 t['yen'] = 500;
16339 t['florin'] = 500;
16340 t['section'] = 500;
16341 t['currency'] = 500;
16342 t['quotesingle'] = 278;
16343 t['quotedblleft'] = 500;
16344 t['guillemotleft'] = 500;
16345 t['guilsinglleft'] = 333;
16346 t['guilsinglright'] = 333;
16347 t['fi'] = 556;
16348 t['fl'] = 556;
16349 t['endash'] = 500;
16350 t['dagger'] = 500;
16351 t['daggerdbl'] = 500;
16352 t['periodcentered'] = 250;
16353 t['paragraph'] = 540;
16354 t['bullet'] = 350;
16355 t['quotesinglbase'] = 333;
16356 t['quotedblbase'] = 500;
16357 t['quotedblright'] = 500;
16358 t['guillemotright'] = 500;
16359 t['ellipsis'] = 1000;
16360 t['perthousand'] = 1000;
16361 t['questiondown'] = 500;
16362 t['grave'] = 333;
16363 t['acute'] = 333;
16364 t['circumflex'] = 333;
16365 t['tilde'] = 333;
16366 t['macron'] = 333;
16367 t['breve'] = 333;
16368 t['dotaccent'] = 333;
16369 t['dieresis'] = 333;
16370 t['ring'] = 333;
16371 t['cedilla'] = 333;
16372 t['hungarumlaut'] = 333;
16373 t['ogonek'] = 333;
16374 t['caron'] = 333;
16375 t['emdash'] = 1000;
16376 t['AE'] = 1000;
16377 t['ordfeminine'] = 300;
16378 t['Lslash'] = 667;
16379 t['Oslash'] = 778;
16380 t['OE'] = 1000;
16381 t['ordmasculine'] = 330;
16382 t['ae'] = 722;
16383 t['dotlessi'] = 278;
16384 t['lslash'] = 278;
16385 t['oslash'] = 500;
16386 t['oe'] = 722;
16387 t['germandbls'] = 556;
16388 t['Idieresis'] = 389;
16389 t['eacute'] = 444;
16390 t['abreve'] = 500;
16391 t['uhungarumlaut'] = 556;
16392 t['ecaron'] = 444;
16393 t['Ydieresis'] = 722;
16394 t['divide'] = 570;
16395 t['Yacute'] = 722;
16396 t['Acircumflex'] = 722;
16397 t['aacute'] = 500;
16398 t['Ucircumflex'] = 722;
16399 t['yacute'] = 500;
16400 t['scommaaccent'] = 389;
16401 t['ecircumflex'] = 444;
16402 t['Uring'] = 722;
16403 t['Udieresis'] = 722;
16404 t['aogonek'] = 500;
16405 t['Uacute'] = 722;
16406 t['uogonek'] = 556;
16407 t['Edieresis'] = 667;
16408 t['Dcroat'] = 722;
16409 t['commaaccent'] = 250;
16410 t['copyright'] = 747;
16411 t['Emacron'] = 667;
16412 t['ccaron'] = 444;
16413 t['aring'] = 500;
16414 t['Ncommaaccent'] = 722;
16415 t['lacute'] = 278;
16416 t['agrave'] = 500;
16417 t['Tcommaaccent'] = 667;
16418 t['Cacute'] = 722;
16419 t['atilde'] = 500;
16420 t['Edotaccent'] = 667;
16421 t['scaron'] = 389;
16422 t['scedilla'] = 389;
16423 t['iacute'] = 278;
16424 t['lozenge'] = 494;
16425 t['Rcaron'] = 722;
16426 t['Gcommaaccent'] = 778;
16427 t['ucircumflex'] = 556;
16428 t['acircumflex'] = 500;
16429 t['Amacron'] = 722;
16430 t['rcaron'] = 444;
16431 t['ccedilla'] = 444;
16432 t['Zdotaccent'] = 667;
16433 t['Thorn'] = 611;
16434 t['Omacron'] = 778;
16435 t['Racute'] = 722;
16436 t['Sacute'] = 556;
16437 t['dcaron'] = 672;
16438 t['Umacron'] = 722;
16439 t['uring'] = 556;
16440 t['threesuperior'] = 300;
16441 t['Ograve'] = 778;
16442 t['Agrave'] = 722;
16443 t['Abreve'] = 722;
16444 t['multiply'] = 570;
16445 t['uacute'] = 556;
16446 t['Tcaron'] = 667;
16447 t['partialdiff'] = 494;
16448 t['ydieresis'] = 500;
16449 t['Nacute'] = 722;
16450 t['icircumflex'] = 278;
16451 t['Ecircumflex'] = 667;
16452 t['adieresis'] = 500;
16453 t['edieresis'] = 444;
16454 t['cacute'] = 444;
16455 t['nacute'] = 556;
16456 t['umacron'] = 556;
16457 t['Ncaron'] = 722;
16458 t['Iacute'] = 389;
16459 t['plusminus'] = 570;
16460 t['brokenbar'] = 220;
16461 t['registered'] = 747;
16462 t['Gbreve'] = 778;
16463 t['Idotaccent'] = 389;
16464 t['summation'] = 600;
16465 t['Egrave'] = 667;
16466 t['racute'] = 444;
16467 t['omacron'] = 500;
16468 t['Zacute'] = 667;
16469 t['Zcaron'] = 667;
16470 t['greaterequal'] = 549;
16471 t['Eth'] = 722;
16472 t['Ccedilla'] = 722;
16473 t['lcommaaccent'] = 278;
16474 t['tcaron'] = 416;
16475 t['eogonek'] = 444;
16476 t['Uogonek'] = 722;
16477 t['Aacute'] = 722;
16478 t['Adieresis'] = 722;
16479 t['egrave'] = 444;
16480 t['zacute'] = 444;
16481 t['iogonek'] = 278;
16482 t['Oacute'] = 778;
16483 t['oacute'] = 500;
16484 t['amacron'] = 500;
16485 t['sacute'] = 389;
16486 t['idieresis'] = 278;
16487 t['Ocircumflex'] = 778;
16488 t['Ugrave'] = 722;
16489 t['Delta'] = 612;
16490 t['thorn'] = 556;
16491 t['twosuperior'] = 300;
16492 t['Odieresis'] = 778;
16493 t['mu'] = 556;
16494 t['igrave'] = 278;
16495 t['ohungarumlaut'] = 500;
16496 t['Eogonek'] = 667;
16497 t['dcroat'] = 556;
16498 t['threequarters'] = 750;
16499 t['Scedilla'] = 556;
16500 t['lcaron'] = 394;
16501 t['Kcommaaccent'] = 778;
16502 t['Lacute'] = 667;
16503 t['trademark'] = 1000;
16504 t['edotaccent'] = 444;
16505 t['Igrave'] = 389;
16506 t['Imacron'] = 389;
16507 t['Lcaron'] = 667;
16508 t['onehalf'] = 750;
16509 t['lessequal'] = 549;
16510 t['ocircumflex'] = 500;
16511 t['ntilde'] = 556;
16512 t['Uhungarumlaut'] = 722;
16513 t['Eacute'] = 667;
16514 t['emacron'] = 444;
16515 t['gbreve'] = 500;
16516 t['onequarter'] = 750;
16517 t['Scaron'] = 556;
16518 t['Scommaaccent'] = 556;
16519 t['Ohungarumlaut'] = 778;
16520 t['degree'] = 400;
16521 t['ograve'] = 500;
16522 t['Ccaron'] = 722;
16523 t['ugrave'] = 556;
16524 t['radical'] = 549;
16525 t['Dcaron'] = 722;
16526 t['rcommaaccent'] = 444;
16527 t['Ntilde'] = 722;
16528 t['otilde'] = 500;
16529 t['Rcommaaccent'] = 722;
16530 t['Lcommaaccent'] = 667;
16531 t['Atilde'] = 722;
16532 t['Aogonek'] = 722;
16533 t['Aring'] = 722;
16534 t['Otilde'] = 778;
16535 t['zdotaccent'] = 444;
16536 t['Ecaron'] = 667;
16537 t['Iogonek'] = 389;
16538 t['kcommaaccent'] = 556;
16539 t['minus'] = 570;
16540 t['Icircumflex'] = 389;
16541 t['ncaron'] = 556;
16542 t['tcommaaccent'] = 333;
16543 t['logicalnot'] = 570;
16544 t['odieresis'] = 500;
16545 t['udieresis'] = 556;
16546 t['notequal'] = 549;
16547 t['gcommaaccent'] = 500;
16548 t['eth'] = 500;
16549 t['zcaron'] = 444;
16550 t['ncommaaccent'] = 556;
16551 t['onesuperior'] = 300;
16552 t['imacron'] = 278;
16553 t['Euro'] = 500;
16554 });
16555 t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
16556 t['space'] = 250;
16557 t['exclam'] = 389;
16558 t['quotedbl'] = 555;
16559 t['numbersign'] = 500;
16560 t['dollar'] = 500;
16561 t['percent'] = 833;
16562 t['ampersand'] = 778;
16563 t['quoteright'] = 333;
16564 t['parenleft'] = 333;
16565 t['parenright'] = 333;
16566 t['asterisk'] = 500;
16567 t['plus'] = 570;
16568 t['comma'] = 250;
16569 t['hyphen'] = 333;
16570 t['period'] = 250;
16571 t['slash'] = 278;
16572 t['zero'] = 500;
16573 t['one'] = 500;
16574 t['two'] = 500;
16575 t['three'] = 500;
16576 t['four'] = 500;
16577 t['five'] = 500;
16578 t['six'] = 500;
16579 t['seven'] = 500;
16580 t['eight'] = 500;
16581 t['nine'] = 500;
16582 t['colon'] = 333;
16583 t['semicolon'] = 333;
16584 t['less'] = 570;
16585 t['equal'] = 570;
16586 t['greater'] = 570;
16587 t['question'] = 500;
16588 t['at'] = 832;
16589 t['A'] = 667;
16590 t['B'] = 667;
16591 t['C'] = 667;
16592 t['D'] = 722;
16593 t['E'] = 667;
16594 t['F'] = 667;
16595 t['G'] = 722;
16596 t['H'] = 778;
16597 t['I'] = 389;
16598 t['J'] = 500;
16599 t['K'] = 667;
16600 t['L'] = 611;
16601 t['M'] = 889;
16602 t['N'] = 722;
16603 t['O'] = 722;
16604 t['P'] = 611;
16605 t['Q'] = 722;
16606 t['R'] = 667;
16607 t['S'] = 556;
16608 t['T'] = 611;
16609 t['U'] = 722;
16610 t['V'] = 667;
16611 t['W'] = 889;
16612 t['X'] = 667;
16613 t['Y'] = 611;
16614 t['Z'] = 611;
16615 t['bracketleft'] = 333;
16616 t['backslash'] = 278;
16617 t['bracketright'] = 333;
16618 t['asciicircum'] = 570;
16619 t['underscore'] = 500;
16620 t['quoteleft'] = 333;
16621 t['a'] = 500;
16622 t['b'] = 500;
16623 t['c'] = 444;
16624 t['d'] = 500;
16625 t['e'] = 444;
16626 t['f'] = 333;
16627 t['g'] = 500;
16628 t['h'] = 556;
16629 t['i'] = 278;
16630 t['j'] = 278;
16631 t['k'] = 500;
16632 t['l'] = 278;
16633 t['m'] = 778;
16634 t['n'] = 556;
16635 t['o'] = 500;
16636 t['p'] = 500;
16637 t['q'] = 500;
16638 t['r'] = 389;
16639 t['s'] = 389;
16640 t['t'] = 278;
16641 t['u'] = 556;
16642 t['v'] = 444;
16643 t['w'] = 667;
16644 t['x'] = 500;
16645 t['y'] = 444;
16646 t['z'] = 389;
16647 t['braceleft'] = 348;
16648 t['bar'] = 220;
16649 t['braceright'] = 348;
16650 t['asciitilde'] = 570;
16651 t['exclamdown'] = 389;
16652 t['cent'] = 500;
16653 t['sterling'] = 500;
16654 t['fraction'] = 167;
16655 t['yen'] = 500;
16656 t['florin'] = 500;
16657 t['section'] = 500;
16658 t['currency'] = 500;
16659 t['quotesingle'] = 278;
16660 t['quotedblleft'] = 500;
16661 t['guillemotleft'] = 500;
16662 t['guilsinglleft'] = 333;
16663 t['guilsinglright'] = 333;
16664 t['fi'] = 556;
16665 t['fl'] = 556;
16666 t['endash'] = 500;
16667 t['dagger'] = 500;
16668 t['daggerdbl'] = 500;
16669 t['periodcentered'] = 250;
16670 t['paragraph'] = 500;
16671 t['bullet'] = 350;
16672 t['quotesinglbase'] = 333;
16673 t['quotedblbase'] = 500;
16674 t['quotedblright'] = 500;
16675 t['guillemotright'] = 500;
16676 t['ellipsis'] = 1000;
16677 t['perthousand'] = 1000;
16678 t['questiondown'] = 500;
16679 t['grave'] = 333;
16680 t['acute'] = 333;
16681 t['circumflex'] = 333;
16682 t['tilde'] = 333;
16683 t['macron'] = 333;
16684 t['breve'] = 333;
16685 t['dotaccent'] = 333;
16686 t['dieresis'] = 333;
16687 t['ring'] = 333;
16688 t['cedilla'] = 333;
16689 t['hungarumlaut'] = 333;
16690 t['ogonek'] = 333;
16691 t['caron'] = 333;
16692 t['emdash'] = 1000;
16693 t['AE'] = 944;
16694 t['ordfeminine'] = 266;
16695 t['Lslash'] = 611;
16696 t['Oslash'] = 722;
16697 t['OE'] = 944;
16698 t['ordmasculine'] = 300;
16699 t['ae'] = 722;
16700 t['dotlessi'] = 278;
16701 t['lslash'] = 278;
16702 t['oslash'] = 500;
16703 t['oe'] = 722;
16704 t['germandbls'] = 500;
16705 t['Idieresis'] = 389;
16706 t['eacute'] = 444;
16707 t['abreve'] = 500;
16708 t['uhungarumlaut'] = 556;
16709 t['ecaron'] = 444;
16710 t['Ydieresis'] = 611;
16711 t['divide'] = 570;
16712 t['Yacute'] = 611;
16713 t['Acircumflex'] = 667;
16714 t['aacute'] = 500;
16715 t['Ucircumflex'] = 722;
16716 t['yacute'] = 444;
16717 t['scommaaccent'] = 389;
16718 t['ecircumflex'] = 444;
16719 t['Uring'] = 722;
16720 t['Udieresis'] = 722;
16721 t['aogonek'] = 500;
16722 t['Uacute'] = 722;
16723 t['uogonek'] = 556;
16724 t['Edieresis'] = 667;
16725 t['Dcroat'] = 722;
16726 t['commaaccent'] = 250;
16727 t['copyright'] = 747;
16728 t['Emacron'] = 667;
16729 t['ccaron'] = 444;
16730 t['aring'] = 500;
16731 t['Ncommaaccent'] = 722;
16732 t['lacute'] = 278;
16733 t['agrave'] = 500;
16734 t['Tcommaaccent'] = 611;
16735 t['Cacute'] = 667;
16736 t['atilde'] = 500;
16737 t['Edotaccent'] = 667;
16738 t['scaron'] = 389;
16739 t['scedilla'] = 389;
16740 t['iacute'] = 278;
16741 t['lozenge'] = 494;
16742 t['Rcaron'] = 667;
16743 t['Gcommaaccent'] = 722;
16744 t['ucircumflex'] = 556;
16745 t['acircumflex'] = 500;
16746 t['Amacron'] = 667;
16747 t['rcaron'] = 389;
16748 t['ccedilla'] = 444;
16749 t['Zdotaccent'] = 611;
16750 t['Thorn'] = 611;
16751 t['Omacron'] = 722;
16752 t['Racute'] = 667;
16753 t['Sacute'] = 556;
16754 t['dcaron'] = 608;
16755 t['Umacron'] = 722;
16756 t['uring'] = 556;
16757 t['threesuperior'] = 300;
16758 t['Ograve'] = 722;
16759 t['Agrave'] = 667;
16760 t['Abreve'] = 667;
16761 t['multiply'] = 570;
16762 t['uacute'] = 556;
16763 t['Tcaron'] = 611;
16764 t['partialdiff'] = 494;
16765 t['ydieresis'] = 444;
16766 t['Nacute'] = 722;
16767 t['icircumflex'] = 278;
16768 t['Ecircumflex'] = 667;
16769 t['adieresis'] = 500;
16770 t['edieresis'] = 444;
16771 t['cacute'] = 444;
16772 t['nacute'] = 556;
16773 t['umacron'] = 556;
16774 t['Ncaron'] = 722;
16775 t['Iacute'] = 389;
16776 t['plusminus'] = 570;
16777 t['brokenbar'] = 220;
16778 t['registered'] = 747;
16779 t['Gbreve'] = 722;
16780 t['Idotaccent'] = 389;
16781 t['summation'] = 600;
16782 t['Egrave'] = 667;
16783 t['racute'] = 389;
16784 t['omacron'] = 500;
16785 t['Zacute'] = 611;
16786 t['Zcaron'] = 611;
16787 t['greaterequal'] = 549;
16788 t['Eth'] = 722;
16789 t['Ccedilla'] = 667;
16790 t['lcommaaccent'] = 278;
16791 t['tcaron'] = 366;
16792 t['eogonek'] = 444;
16793 t['Uogonek'] = 722;
16794 t['Aacute'] = 667;
16795 t['Adieresis'] = 667;
16796 t['egrave'] = 444;
16797 t['zacute'] = 389;
16798 t['iogonek'] = 278;
16799 t['Oacute'] = 722;
16800 t['oacute'] = 500;
16801 t['amacron'] = 500;
16802 t['sacute'] = 389;
16803 t['idieresis'] = 278;
16804 t['Ocircumflex'] = 722;
16805 t['Ugrave'] = 722;
16806 t['Delta'] = 612;
16807 t['thorn'] = 500;
16808 t['twosuperior'] = 300;
16809 t['Odieresis'] = 722;
16810 t['mu'] = 576;
16811 t['igrave'] = 278;
16812 t['ohungarumlaut'] = 500;
16813 t['Eogonek'] = 667;
16814 t['dcroat'] = 500;
16815 t['threequarters'] = 750;
16816 t['Scedilla'] = 556;
16817 t['lcaron'] = 382;
16818 t['Kcommaaccent'] = 667;
16819 t['Lacute'] = 611;
16820 t['trademark'] = 1000;
16821 t['edotaccent'] = 444;
16822 t['Igrave'] = 389;
16823 t['Imacron'] = 389;
16824 t['Lcaron'] = 611;
16825 t['onehalf'] = 750;
16826 t['lessequal'] = 549;
16827 t['ocircumflex'] = 500;
16828 t['ntilde'] = 556;
16829 t['Uhungarumlaut'] = 722;
16830 t['Eacute'] = 667;
16831 t['emacron'] = 444;
16832 t['gbreve'] = 500;
16833 t['onequarter'] = 750;
16834 t['Scaron'] = 556;
16835 t['Scommaaccent'] = 556;
16836 t['Ohungarumlaut'] = 722;
16837 t['degree'] = 400;
16838 t['ograve'] = 500;
16839 t['Ccaron'] = 667;
16840 t['ugrave'] = 556;
16841 t['radical'] = 549;
16842 t['Dcaron'] = 722;
16843 t['rcommaaccent'] = 389;
16844 t['Ntilde'] = 722;
16845 t['otilde'] = 500;
16846 t['Rcommaaccent'] = 667;
16847 t['Lcommaaccent'] = 611;
16848 t['Atilde'] = 667;
16849 t['Aogonek'] = 667;
16850 t['Aring'] = 667;
16851 t['Otilde'] = 722;
16852 t['zdotaccent'] = 389;
16853 t['Ecaron'] = 667;
16854 t['Iogonek'] = 389;
16855 t['kcommaaccent'] = 500;
16856 t['minus'] = 606;
16857 t['Icircumflex'] = 389;
16858 t['ncaron'] = 556;
16859 t['tcommaaccent'] = 278;
16860 t['logicalnot'] = 606;
16861 t['odieresis'] = 500;
16862 t['udieresis'] = 556;
16863 t['notequal'] = 549;
16864 t['gcommaaccent'] = 500;
16865 t['eth'] = 500;
16866 t['zcaron'] = 389;
16867 t['ncommaaccent'] = 556;
16868 t['onesuperior'] = 300;
16869 t['imacron'] = 278;
16870 t['Euro'] = 500;
16871 });
16872 t['Times-Italic'] = getLookupTableFactory(function (t) {
16873 t['space'] = 250;
16874 t['exclam'] = 333;
16875 t['quotedbl'] = 420;
16876 t['numbersign'] = 500;
16877 t['dollar'] = 500;
16878 t['percent'] = 833;
16879 t['ampersand'] = 778;
16880 t['quoteright'] = 333;
16881 t['parenleft'] = 333;
16882 t['parenright'] = 333;
16883 t['asterisk'] = 500;
16884 t['plus'] = 675;
16885 t['comma'] = 250;
16886 t['hyphen'] = 333;
16887 t['period'] = 250;
16888 t['slash'] = 278;
16889 t['zero'] = 500;
16890 t['one'] = 500;
16891 t['two'] = 500;
16892 t['three'] = 500;
16893 t['four'] = 500;
16894 t['five'] = 500;
16895 t['six'] = 500;
16896 t['seven'] = 500;
16897 t['eight'] = 500;
16898 t['nine'] = 500;
16899 t['colon'] = 333;
16900 t['semicolon'] = 333;
16901 t['less'] = 675;
16902 t['equal'] = 675;
16903 t['greater'] = 675;
16904 t['question'] = 500;
16905 t['at'] = 920;
16906 t['A'] = 611;
16907 t['B'] = 611;
16908 t['C'] = 667;
16909 t['D'] = 722;
16910 t['E'] = 611;
16911 t['F'] = 611;
16912 t['G'] = 722;
16913 t['H'] = 722;
16914 t['I'] = 333;
16915 t['J'] = 444;
16916 t['K'] = 667;
16917 t['L'] = 556;
16918 t['M'] = 833;
16919 t['N'] = 667;
16920 t['O'] = 722;
16921 t['P'] = 611;
16922 t['Q'] = 722;
16923 t['R'] = 611;
16924 t['S'] = 500;
16925 t['T'] = 556;
16926 t['U'] = 722;
16927 t['V'] = 611;
16928 t['W'] = 833;
16929 t['X'] = 611;
16930 t['Y'] = 556;
16931 t['Z'] = 556;
16932 t['bracketleft'] = 389;
16933 t['backslash'] = 278;
16934 t['bracketright'] = 389;
16935 t['asciicircum'] = 422;
16936 t['underscore'] = 500;
16937 t['quoteleft'] = 333;
16938 t['a'] = 500;
16939 t['b'] = 500;
16940 t['c'] = 444;
16941 t['d'] = 500;
16942 t['e'] = 444;
16943 t['f'] = 278;
16944 t['g'] = 500;
16945 t['h'] = 500;
16946 t['i'] = 278;
16947 t['j'] = 278;
16948 t['k'] = 444;
16949 t['l'] = 278;
16950 t['m'] = 722;
16951 t['n'] = 500;
16952 t['o'] = 500;
16953 t['p'] = 500;
16954 t['q'] = 500;
16955 t['r'] = 389;
16956 t['s'] = 389;
16957 t['t'] = 278;
16958 t['u'] = 500;
16959 t['v'] = 444;
16960 t['w'] = 667;
16961 t['x'] = 444;
16962 t['y'] = 444;
16963 t['z'] = 389;
16964 t['braceleft'] = 400;
16965 t['bar'] = 275;
16966 t['braceright'] = 400;
16967 t['asciitilde'] = 541;
16968 t['exclamdown'] = 389;
16969 t['cent'] = 500;
16970 t['sterling'] = 500;
16971 t['fraction'] = 167;
16972 t['yen'] = 500;
16973 t['florin'] = 500;
16974 t['section'] = 500;
16975 t['currency'] = 500;
16976 t['quotesingle'] = 214;
16977 t['quotedblleft'] = 556;
16978 t['guillemotleft'] = 500;
16979 t['guilsinglleft'] = 333;
16980 t['guilsinglright'] = 333;
16981 t['fi'] = 500;
16982 t['fl'] = 500;
16983 t['endash'] = 500;
16984 t['dagger'] = 500;
16985 t['daggerdbl'] = 500;
16986 t['periodcentered'] = 250;
16987 t['paragraph'] = 523;
16988 t['bullet'] = 350;
16989 t['quotesinglbase'] = 333;
16990 t['quotedblbase'] = 556;
16991 t['quotedblright'] = 556;
16992 t['guillemotright'] = 500;
16993 t['ellipsis'] = 889;
16994 t['perthousand'] = 1000;
16995 t['questiondown'] = 500;
16996 t['grave'] = 333;
16997 t['acute'] = 333;
16998 t['circumflex'] = 333;
16999 t['tilde'] = 333;
17000 t['macron'] = 333;
17001 t['breve'] = 333;
17002 t['dotaccent'] = 333;
17003 t['dieresis'] = 333;
17004 t['ring'] = 333;
17005 t['cedilla'] = 333;
17006 t['hungarumlaut'] = 333;
17007 t['ogonek'] = 333;
17008 t['caron'] = 333;
17009 t['emdash'] = 889;
17010 t['AE'] = 889;
17011 t['ordfeminine'] = 276;
17012 t['Lslash'] = 556;
17013 t['Oslash'] = 722;
17014 t['OE'] = 944;
17015 t['ordmasculine'] = 310;
17016 t['ae'] = 667;
17017 t['dotlessi'] = 278;
17018 t['lslash'] = 278;
17019 t['oslash'] = 500;
17020 t['oe'] = 667;
17021 t['germandbls'] = 500;
17022 t['Idieresis'] = 333;
17023 t['eacute'] = 444;
17024 t['abreve'] = 500;
17025 t['uhungarumlaut'] = 500;
17026 t['ecaron'] = 444;
17027 t['Ydieresis'] = 556;
17028 t['divide'] = 675;
17029 t['Yacute'] = 556;
17030 t['Acircumflex'] = 611;
17031 t['aacute'] = 500;
17032 t['Ucircumflex'] = 722;
17033 t['yacute'] = 444;
17034 t['scommaaccent'] = 389;
17035 t['ecircumflex'] = 444;
17036 t['Uring'] = 722;
17037 t['Udieresis'] = 722;
17038 t['aogonek'] = 500;
17039 t['Uacute'] = 722;
17040 t['uogonek'] = 500;
17041 t['Edieresis'] = 611;
17042 t['Dcroat'] = 722;
17043 t['commaaccent'] = 250;
17044 t['copyright'] = 760;
17045 t['Emacron'] = 611;
17046 t['ccaron'] = 444;
17047 t['aring'] = 500;
17048 t['Ncommaaccent'] = 667;
17049 t['lacute'] = 278;
17050 t['agrave'] = 500;
17051 t['Tcommaaccent'] = 556;
17052 t['Cacute'] = 667;
17053 t['atilde'] = 500;
17054 t['Edotaccent'] = 611;
17055 t['scaron'] = 389;
17056 t['scedilla'] = 389;
17057 t['iacute'] = 278;
17058 t['lozenge'] = 471;
17059 t['Rcaron'] = 611;
17060 t['Gcommaaccent'] = 722;
17061 t['ucircumflex'] = 500;
17062 t['acircumflex'] = 500;
17063 t['Amacron'] = 611;
17064 t['rcaron'] = 389;
17065 t['ccedilla'] = 444;
17066 t['Zdotaccent'] = 556;
17067 t['Thorn'] = 611;
17068 t['Omacron'] = 722;
17069 t['Racute'] = 611;
17070 t['Sacute'] = 500;
17071 t['dcaron'] = 544;
17072 t['Umacron'] = 722;
17073 t['uring'] = 500;
17074 t['threesuperior'] = 300;
17075 t['Ograve'] = 722;
17076 t['Agrave'] = 611;
17077 t['Abreve'] = 611;
17078 t['multiply'] = 675;
17079 t['uacute'] = 500;
17080 t['Tcaron'] = 556;
17081 t['partialdiff'] = 476;
17082 t['ydieresis'] = 444;
17083 t['Nacute'] = 667;
17084 t['icircumflex'] = 278;
17085 t['Ecircumflex'] = 611;
17086 t['adieresis'] = 500;
17087 t['edieresis'] = 444;
17088 t['cacute'] = 444;
17089 t['nacute'] = 500;
17090 t['umacron'] = 500;
17091 t['Ncaron'] = 667;
17092 t['Iacute'] = 333;
17093 t['plusminus'] = 675;
17094 t['brokenbar'] = 275;
17095 t['registered'] = 760;
17096 t['Gbreve'] = 722;
17097 t['Idotaccent'] = 333;
17098 t['summation'] = 600;
17099 t['Egrave'] = 611;
17100 t['racute'] = 389;
17101 t['omacron'] = 500;
17102 t['Zacute'] = 556;
17103 t['Zcaron'] = 556;
17104 t['greaterequal'] = 549;
17105 t['Eth'] = 722;
17106 t['Ccedilla'] = 667;
17107 t['lcommaaccent'] = 278;
17108 t['tcaron'] = 300;
17109 t['eogonek'] = 444;
17110 t['Uogonek'] = 722;
17111 t['Aacute'] = 611;
17112 t['Adieresis'] = 611;
17113 t['egrave'] = 444;
17114 t['zacute'] = 389;
17115 t['iogonek'] = 278;
17116 t['Oacute'] = 722;
17117 t['oacute'] = 500;
17118 t['amacron'] = 500;
17119 t['sacute'] = 389;
17120 t['idieresis'] = 278;
17121 t['Ocircumflex'] = 722;
17122 t['Ugrave'] = 722;
17123 t['Delta'] = 612;
17124 t['thorn'] = 500;
17125 t['twosuperior'] = 300;
17126 t['Odieresis'] = 722;
17127 t['mu'] = 500;
17128 t['igrave'] = 278;
17129 t['ohungarumlaut'] = 500;
17130 t['Eogonek'] = 611;
17131 t['dcroat'] = 500;
17132 t['threequarters'] = 750;
17133 t['Scedilla'] = 500;
17134 t['lcaron'] = 300;
17135 t['Kcommaaccent'] = 667;
17136 t['Lacute'] = 556;
17137 t['trademark'] = 980;
17138 t['edotaccent'] = 444;
17139 t['Igrave'] = 333;
17140 t['Imacron'] = 333;
17141 t['Lcaron'] = 611;
17142 t['onehalf'] = 750;
17143 t['lessequal'] = 549;
17144 t['ocircumflex'] = 500;
17145 t['ntilde'] = 500;
17146 t['Uhungarumlaut'] = 722;
17147 t['Eacute'] = 611;
17148 t['emacron'] = 444;
17149 t['gbreve'] = 500;
17150 t['onequarter'] = 750;
17151 t['Scaron'] = 500;
17152 t['Scommaaccent'] = 500;
17153 t['Ohungarumlaut'] = 722;
17154 t['degree'] = 400;
17155 t['ograve'] = 500;
17156 t['Ccaron'] = 667;
17157 t['ugrave'] = 500;
17158 t['radical'] = 453;
17159 t['Dcaron'] = 722;
17160 t['rcommaaccent'] = 389;
17161 t['Ntilde'] = 667;
17162 t['otilde'] = 500;
17163 t['Rcommaaccent'] = 611;
17164 t['Lcommaaccent'] = 556;
17165 t['Atilde'] = 611;
17166 t['Aogonek'] = 611;
17167 t['Aring'] = 611;
17168 t['Otilde'] = 722;
17169 t['zdotaccent'] = 389;
17170 t['Ecaron'] = 611;
17171 t['Iogonek'] = 333;
17172 t['kcommaaccent'] = 444;
17173 t['minus'] = 675;
17174 t['Icircumflex'] = 333;
17175 t['ncaron'] = 500;
17176 t['tcommaaccent'] = 278;
17177 t['logicalnot'] = 675;
17178 t['odieresis'] = 500;
17179 t['udieresis'] = 500;
17180 t['notequal'] = 549;
17181 t['gcommaaccent'] = 500;
17182 t['eth'] = 500;
17183 t['zcaron'] = 389;
17184 t['ncommaaccent'] = 500;
17185 t['onesuperior'] = 300;
17186 t['imacron'] = 278;
17187 t['Euro'] = 500;
17188 });
17189 t['ZapfDingbats'] = getLookupTableFactory(function (t) {
17190 t['space'] = 278;
17191 t['a1'] = 974;
17192 t['a2'] = 961;
17193 t['a202'] = 974;
17194 t['a3'] = 980;
17195 t['a4'] = 719;
17196 t['a5'] = 789;
17197 t['a119'] = 790;
17198 t['a118'] = 791;
17199 t['a117'] = 690;
17200 t['a11'] = 960;
17201 t['a12'] = 939;
17202 t['a13'] = 549;
17203 t['a14'] = 855;
17204 t['a15'] = 911;
17205 t['a16'] = 933;
17206 t['a105'] = 911;
17207 t['a17'] = 945;
17208 t['a18'] = 974;
17209 t['a19'] = 755;
17210 t['a20'] = 846;
17211 t['a21'] = 762;
17212 t['a22'] = 761;
17213 t['a23'] = 571;
17214 t['a24'] = 677;
17215 t['a25'] = 763;
17216 t['a26'] = 760;
17217 t['a27'] = 759;
17218 t['a28'] = 754;
17219 t['a6'] = 494;
17220 t['a7'] = 552;
17221 t['a8'] = 537;
17222 t['a9'] = 577;
17223 t['a10'] = 692;
17224 t['a29'] = 786;
17225 t['a30'] = 788;
17226 t['a31'] = 788;
17227 t['a32'] = 790;
17228 t['a33'] = 793;
17229 t['a34'] = 794;
17230 t['a35'] = 816;
17231 t['a36'] = 823;
17232 t['a37'] = 789;
17233 t['a38'] = 841;
17234 t['a39'] = 823;
17235 t['a40'] = 833;
17236 t['a41'] = 816;
17237 t['a42'] = 831;
17238 t['a43'] = 923;
17239 t['a44'] = 744;
17240 t['a45'] = 723;
17241 t['a46'] = 749;
17242 t['a47'] = 790;
17243 t['a48'] = 792;
17244 t['a49'] = 695;
17245 t['a50'] = 776;
17246 t['a51'] = 768;
17247 t['a52'] = 792;
17248 t['a53'] = 759;
17249 t['a54'] = 707;
17250 t['a55'] = 708;
17251 t['a56'] = 682;
17252 t['a57'] = 701;
17253 t['a58'] = 826;
17254 t['a59'] = 815;
17255 t['a60'] = 789;
17256 t['a61'] = 789;
17257 t['a62'] = 707;
17258 t['a63'] = 687;
17259 t['a64'] = 696;
17260 t['a65'] = 689;
17261 t['a66'] = 786;
17262 t['a67'] = 787;
17263 t['a68'] = 713;
17264 t['a69'] = 791;
17265 t['a70'] = 785;
17266 t['a71'] = 791;
17267 t['a72'] = 873;
17268 t['a73'] = 761;
17269 t['a74'] = 762;
17270 t['a203'] = 762;
17271 t['a75'] = 759;
17272 t['a204'] = 759;
17273 t['a76'] = 892;
17274 t['a77'] = 892;
17275 t['a78'] = 788;
17276 t['a79'] = 784;
17277 t['a81'] = 438;
17278 t['a82'] = 138;
17279 t['a83'] = 277;
17280 t['a84'] = 415;
17281 t['a97'] = 392;
17282 t['a98'] = 392;
17283 t['a99'] = 668;
17284 t['a100'] = 668;
17285 t['a89'] = 390;
17286 t['a90'] = 390;
17287 t['a93'] = 317;
17288 t['a94'] = 317;
17289 t['a91'] = 276;
17290 t['a92'] = 276;
17291 t['a205'] = 509;
17292 t['a85'] = 509;
17293 t['a206'] = 410;
17294 t['a86'] = 410;
17295 t['a87'] = 234;
17296 t['a88'] = 234;
17297 t['a95'] = 334;
17298 t['a96'] = 334;
17299 t['a101'] = 732;
17300 t['a102'] = 544;
17301 t['a103'] = 544;
17302 t['a104'] = 910;
17303 t['a106'] = 667;
17304 t['a107'] = 760;
17305 t['a108'] = 760;
17306 t['a112'] = 776;
17307 t['a111'] = 595;
17308 t['a110'] = 694;
17309 t['a109'] = 626;
17310 t['a120'] = 788;
17311 t['a121'] = 788;
17312 t['a122'] = 788;
17313 t['a123'] = 788;
17314 t['a124'] = 788;
17315 t['a125'] = 788;
17316 t['a126'] = 788;
17317 t['a127'] = 788;
17318 t['a128'] = 788;
17319 t['a129'] = 788;
17320 t['a130'] = 788;
17321 t['a131'] = 788;
17322 t['a132'] = 788;
17323 t['a133'] = 788;
17324 t['a134'] = 788;
17325 t['a135'] = 788;
17326 t['a136'] = 788;
17327 t['a137'] = 788;
17328 t['a138'] = 788;
17329 t['a139'] = 788;
17330 t['a140'] = 788;
17331 t['a141'] = 788;
17332 t['a142'] = 788;
17333 t['a143'] = 788;
17334 t['a144'] = 788;
17335 t['a145'] = 788;
17336 t['a146'] = 788;
17337 t['a147'] = 788;
17338 t['a148'] = 788;
17339 t['a149'] = 788;
17340 t['a150'] = 788;
17341 t['a151'] = 788;
17342 t['a152'] = 788;
17343 t['a153'] = 788;
17344 t['a154'] = 788;
17345 t['a155'] = 788;
17346 t['a156'] = 788;
17347 t['a157'] = 788;
17348 t['a158'] = 788;
17349 t['a159'] = 788;
17350 t['a160'] = 894;
17351 t['a161'] = 838;
17352 t['a163'] = 1016;
17353 t['a164'] = 458;
17354 t['a196'] = 748;
17355 t['a165'] = 924;
17356 t['a192'] = 748;
17357 t['a166'] = 918;
17358 t['a167'] = 927;
17359 t['a168'] = 928;
17360 t['a169'] = 928;
17361 t['a170'] = 834;
17362 t['a171'] = 873;
17363 t['a172'] = 828;
17364 t['a173'] = 924;
17365 t['a162'] = 924;
17366 t['a174'] = 917;
17367 t['a175'] = 930;
17368 t['a176'] = 931;
17369 t['a177'] = 463;
17370 t['a178'] = 883;
17371 t['a179'] = 836;
17372 t['a193'] = 836;
17373 t['a180'] = 867;
17374 t['a199'] = 867;
17375 t['a181'] = 696;
17376 t['a200'] = 696;
17377 t['a182'] = 874;
17378 t['a201'] = 874;
17379 t['a183'] = 760;
17380 t['a184'] = 946;
17381 t['a197'] = 771;
17382 t['a185'] = 865;
17383 t['a194'] = 771;
17384 t['a198'] = 888;
17385 t['a186'] = 967;
17386 t['a195'] = 888;
17387 t['a187'] = 831;
17388 t['a188'] = 873;
17389 t['a189'] = 927;
17390 t['a190'] = 970;
17391 t['a191'] = 918;
17392 });
17393});
17394
17395exports.getMetrics = getMetrics;
17396}));
17397
17398
17399
17400(function (root, factory) {
17401 {
17402 factory((root.pdfjsCoreMurmurHash3 = {}), root.pdfjsSharedUtil);
17403 }
17404}(this, function (exports, sharedUtil) {
17405
17406var Uint32ArrayView = sharedUtil.Uint32ArrayView;
17407
17408var MurmurHash3_64 = (function MurmurHash3_64Closure (seed) {
17409 // Workaround for missing math precision in JS.
17410 var MASK_HIGH = 0xffff0000;
17411 var MASK_LOW = 0xffff;
17412
17413 function MurmurHash3_64 (seed) {
17414 var SEED = 0xc3d2e1f0;
17415 this.h1 = seed ? seed & 0xffffffff : SEED;
17416 this.h2 = seed ? seed & 0xffffffff : SEED;
17417 }
17418
17419 var alwaysUseUint32ArrayView = false;
17420 // old webkits have issues with non-aligned arrays
17421 try {
17422 new Uint32Array(new Uint8Array(5).buffer, 0, 1);
17423 } catch (e) {
17424 alwaysUseUint32ArrayView = true;
17425 }
17426
17427 MurmurHash3_64.prototype = {
17428 update: function MurmurHash3_64_update(input) {
17429 var useUint32ArrayView = alwaysUseUint32ArrayView;
17430 var i;
17431 if (typeof input === 'string') {
17432 var data = new Uint8Array(input.length * 2);
17433 var length = 0;
17434 for (i = 0; i < input.length; i++) {
17435 var code = input.charCodeAt(i);
17436 if (code <= 0xff) {
17437 data[length++] = code;
17438 }
17439 else {
17440 data[length++] = code >>> 8;
17441 data[length++] = code & 0xff;
17442 }
17443 }
17444 } else if (input instanceof Uint8Array) {
17445 data = input;
17446 length = data.length;
17447 } else if (typeof input === 'object' && ('length' in input)) {
17448 // processing regular arrays as well, e.g. for IE9
17449 data = input;
17450 length = data.length;
17451 useUint32ArrayView = true;
17452 } else {
17453 throw new Error('Wrong data format in MurmurHash3_64_update. ' +
17454 'Input must be a string or array.');
17455 }
17456
17457 var blockCounts = length >> 2;
17458 var tailLength = length - blockCounts * 4;
17459 // we don't care about endianness here
17460 var dataUint32 = useUint32ArrayView ?
17461 new Uint32ArrayView(data, blockCounts) :
17462 new Uint32Array(data.buffer, 0, blockCounts);
17463 var k1 = 0;
17464 var k2 = 0;
17465 var h1 = this.h1;
17466 var h2 = this.h2;
17467 var C1 = 0xcc9e2d51;
17468 var C2 = 0x1b873593;
17469 var C1_LOW = C1 & MASK_LOW;
17470 var C2_LOW = C2 & MASK_LOW;
17471
17472 for (i = 0; i < blockCounts; i++) {
17473 if (i & 1) {
17474 k1 = dataUint32[i];
17475 k1 = (k1 * C1 & MASK_HIGH) | (k1 * C1_LOW & MASK_LOW);
17476 k1 = k1 << 15 | k1 >>> 17;
17477 k1 = (k1 * C2 & MASK_HIGH) | (k1 * C2_LOW & MASK_LOW);
17478 h1 ^= k1;
17479 h1 = h1 << 13 | h1 >>> 19;
17480 h1 = h1 * 5 + 0xe6546b64;
17481 } else {
17482 k2 = dataUint32[i];
17483 k2 = (k2 * C1 & MASK_HIGH) | (k2 * C1_LOW & MASK_LOW);
17484 k2 = k2 << 15 | k2 >>> 17;
17485 k2 = (k2 * C2 & MASK_HIGH) | (k2 * C2_LOW & MASK_LOW);
17486 h2 ^= k2;
17487 h2 = h2 << 13 | h2 >>> 19;
17488 h2 = h2 * 5 + 0xe6546b64;
17489 }
17490 }
17491
17492 k1 = 0;
17493
17494 switch (tailLength) {
17495 case 3:
17496 k1 ^= data[blockCounts * 4 + 2] << 16;
17497 /* falls through */
17498 case 2:
17499 k1 ^= data[blockCounts * 4 + 1] << 8;
17500 /* falls through */
17501 case 1:
17502 k1 ^= data[blockCounts * 4];
17503 /* falls through */
17504 k1 = (k1 * C1 & MASK_HIGH) | (k1 * C1_LOW & MASK_LOW);
17505 k1 = k1 << 15 | k1 >>> 17;
17506 k1 = (k1 * C2 & MASK_HIGH) | (k1 * C2_LOW & MASK_LOW);
17507 if (blockCounts & 1) {
17508 h1 ^= k1;
17509 } else {
17510 h2 ^= k1;
17511 }
17512 }
17513
17514 this.h1 = h1;
17515 this.h2 = h2;
17516 return this;
17517 },
17518
17519 hexdigest: function MurmurHash3_64_hexdigest () {
17520 var h1 = this.h1;
17521 var h2 = this.h2;
17522
17523 h1 ^= h2 >>> 1;
17524 h1 = (h1 * 0xed558ccd & MASK_HIGH) | (h1 * 0x8ccd & MASK_LOW);
17525 h2 = (h2 * 0xff51afd7 & MASK_HIGH) |
17526 (((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16);
17527 h1 ^= h2 >>> 1;
17528 h1 = (h1 * 0x1a85ec53 & MASK_HIGH) | (h1 * 0xec53 & MASK_LOW);
17529 h2 = (h2 * 0xc4ceb9fe & MASK_HIGH) |
17530 (((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16);
17531 h1 ^= h2 >>> 1;
17532
17533 for (var i = 0, arr = [h1, h2], str = ''; i < arr.length; i++) {
17534 var hex = (arr[i] >>> 0).toString(16);
17535 while (hex.length < 8) {
17536 hex = '0' + hex;
17537 }
17538 str += hex;
17539 }
17540
17541 return str;
17542 }
17543 };
17544
17545 return MurmurHash3_64;
17546})();
17547
17548exports.MurmurHash3_64 = MurmurHash3_64;
17549}));
17550
17551
17552(function (root, factory) {
17553 {
17554 factory((root.pdfjsCorePrimitives = {}), root.pdfjsSharedUtil);
17555 }
17556}(this, function (exports, sharedUtil) {
17557
17558var isArray = sharedUtil.isArray;
17559
17560var Name = (function NameClosure() {
17561 function Name(name) {
17562 this.name = name;
17563 }
17564
17565 Name.prototype = {};
17566
17567 var nameCache = Object.create(null);
17568
17569 Name.get = function Name_get(name) {
17570 var nameValue = nameCache[name];
17571 return (nameValue ? nameValue : (nameCache[name] = new Name(name)));
17572 };
17573
17574 return Name;
17575})();
17576
17577var Cmd = (function CmdClosure() {
17578 function Cmd(cmd) {
17579 this.cmd = cmd;
17580 }
17581
17582 Cmd.prototype = {};
17583
17584 var cmdCache = Object.create(null);
17585
17586 Cmd.get = function Cmd_get(cmd) {
17587 var cmdValue = cmdCache[cmd];
17588 return (cmdValue ? cmdValue : (cmdCache[cmd] = new Cmd(cmd)));
17589 };
17590
17591 return Cmd;
17592})();
17593
17594var Dict = (function DictClosure() {
17595 var nonSerializable = function nonSerializableClosure() {
17596 return nonSerializable; // creating closure on some variable
17597 };
17598
17599 // xref is optional
17600 function Dict(xref) {
17601 // Map should only be used internally, use functions below to access.
17602 this.map = Object.create(null);
17603 this.xref = xref;
17604 this.objId = null;
17605 this.__nonSerializable__ = nonSerializable; // disable cloning of the Dict
17606 }
17607
17608 Dict.prototype = {
17609 assignXref: function Dict_assignXref(newXref) {
17610 this.xref = newXref;
17611 },
17612
17613 // automatically dereferences Ref objects
17614 get: function Dict_get(key1, key2, key3) {
17615 var value;
17616 var xref = this.xref;
17617 if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
17618 typeof key2 === 'undefined') {
17619 return xref ? xref.fetchIfRef(value) : value;
17620 }
17621 if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
17622 typeof key3 === 'undefined') {
17623 return xref ? xref.fetchIfRef(value) : value;
17624 }
17625 value = this.map[key3] || null;
17626 return xref ? xref.fetchIfRef(value) : value;
17627 },
17628
17629 // Same as get(), but returns a promise and uses fetchIfRefAsync().
17630 getAsync: function Dict_getAsync(key1, key2, key3) {
17631 var value;
17632 var xref = this.xref;
17633 if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map ||
17634 typeof key2 === 'undefined') {
17635 if (xref) {
17636 return xref.fetchIfRefAsync(value);
17637 }
17638 return Promise.resolve(value);
17639 }
17640 if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map ||
17641 typeof key3 === 'undefined') {
17642 if (xref) {
17643 return xref.fetchIfRefAsync(value);
17644 }
17645 return Promise.resolve(value);
17646 }
17647 value = this.map[key3] || null;
17648 if (xref) {
17649 return xref.fetchIfRefAsync(value);
17650 }
17651 return Promise.resolve(value);
17652 },
17653
17654 // Same as get(), but dereferences all elements if the result is an Array.
17655 getArray: function Dict_getArray(key1, key2, key3) {
17656 var value = this.get(key1, key2, key3);
17657 var xref = this.xref;
17658 if (!isArray(value) || !xref) {
17659 return value;
17660 }
17661 value = value.slice(); // Ensure that we don't modify the Dict data.
17662 for (var i = 0, ii = value.length; i < ii; i++) {
17663 if (!isRef(value[i])) {
17664 continue;
17665 }
17666 value[i] = xref.fetch(value[i]);
17667 }
17668 return value;
17669 },
17670
17671 // no dereferencing
17672 getRaw: function Dict_getRaw(key) {
17673 return this.map[key];
17674 },
17675
17676 getKeys: function Dict_getKeys() {
17677 return Object.keys(this.map);
17678 },
17679
17680 set: function Dict_set(key, value) {
17681 this.map[key] = value;
17682 },
17683
17684 has: function Dict_has(key) {
17685 return key in this.map;
17686 },
17687
17688 forEach: function Dict_forEach(callback) {
17689 for (var key in this.map) {
17690 callback(key, this.get(key));
17691 }
17692 }
17693 };
17694
17695 Dict.empty = new Dict(null);
17696
17697 Dict.merge = function Dict_merge(xref, dictArray) {
17698 var mergedDict = new Dict(xref);
17699
17700 for (var i = 0, ii = dictArray.length; i < ii; i++) {
17701 var dict = dictArray[i];
17702 if (!isDict(dict)) {
17703 continue;
17704 }
17705 for (var keyName in dict.map) {
17706 if (mergedDict.map[keyName]) {
17707 continue;
17708 }
17709 mergedDict.map[keyName] = dict.map[keyName];
17710 }
17711 }
17712 return mergedDict;
17713 };
17714
17715 return Dict;
17716})();
17717
17718var Ref = (function RefClosure() {
17719 function Ref(num, gen) {
17720 this.num = num;
17721 this.gen = gen;
17722 }
17723
17724 Ref.prototype = {
17725 toString: function Ref_toString() {
17726 // This function is hot, so we make the string as compact as possible.
17727 // |this.gen| is almost always zero, so we treat that case specially.
17728 var str = this.num + 'R';
17729 if (this.gen !== 0) {
17730 str += this.gen;
17731 }
17732 return str;
17733 }
17734 };
17735
17736 return Ref;
17737})();
17738
17739// The reference is identified by number and generation.
17740// This structure stores only one instance of the reference.
17741var RefSet = (function RefSetClosure() {
17742 function RefSet() {
17743 this.dict = Object.create(null);
17744 }
17745
17746 RefSet.prototype = {
17747 has: function RefSet_has(ref) {
17748 return ref.toString() in this.dict;
17749 },
17750
17751 put: function RefSet_put(ref) {
17752 this.dict[ref.toString()] = true;
17753 },
17754
17755 remove: function RefSet_remove(ref) {
17756 delete this.dict[ref.toString()];
17757 }
17758 };
17759
17760 return RefSet;
17761})();
17762
17763var RefSetCache = (function RefSetCacheClosure() {
17764 function RefSetCache() {
17765 this.dict = Object.create(null);
17766 }
17767
17768 RefSetCache.prototype = {
17769 get: function RefSetCache_get(ref) {
17770 return this.dict[ref.toString()];
17771 },
17772
17773 has: function RefSetCache_has(ref) {
17774 return ref.toString() in this.dict;
17775 },
17776
17777 put: function RefSetCache_put(ref, obj) {
17778 this.dict[ref.toString()] = obj;
17779 },
17780
17781 putAlias: function RefSetCache_putAlias(ref, aliasRef) {
17782 this.dict[ref.toString()] = this.get(aliasRef);
17783 },
17784
17785 forEach: function RefSetCache_forEach(fn, thisArg) {
17786 for (var i in this.dict) {
17787 fn.call(thisArg, this.dict[i]);
17788 }
17789 },
17790
17791 clear: function RefSetCache_clear() {
17792 this.dict = Object.create(null);
17793 }
17794 };
17795
17796 return RefSetCache;
17797})();
17798
17799function isName(v, name) {
17800 return v instanceof Name && (name === undefined || v.name === name);
17801}
17802
17803function isCmd(v, cmd) {
17804 return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
17805}
17806
17807function isDict(v, type) {
17808 return v instanceof Dict &&
17809 (type === undefined || isName(v.get('Type'), type));
17810}
17811
17812function isRef(v) {
17813 return v instanceof Ref;
17814}
17815
17816function isRefsEqual(v1, v2) {
17817 return v1.num === v2.num && v1.gen === v2.gen;
17818}
17819
17820function isStream(v) {
17821 return typeof v === 'object' && v !== null && v.getBytes !== undefined;
17822}
17823
17824exports.Cmd = Cmd;
17825exports.Dict = Dict;
17826exports.Name = Name;
17827exports.Ref = Ref;
17828exports.RefSet = RefSet;
17829exports.RefSetCache = RefSetCache;
17830exports.isCmd = isCmd;
17831exports.isDict = isDict;
17832exports.isName = isName;
17833exports.isRef = isRef;
17834exports.isRefsEqual = isRefsEqual;
17835exports.isStream = isStream;
17836}));
17837
17838
17839(function (root, factory) {
17840 {
17841 factory((root.pdfjsCoreStandardFonts = {}), root.pdfjsSharedUtil);
17842 }
17843}(this, function (exports, sharedUtil) {
17844 var getLookupTableFactory = sharedUtil.getLookupTableFactory;
17845
17846 /**
17847 * Hold a map of decoded fonts and of the standard fourteen Type1
17848 * fonts and their acronyms.
17849 */
17850 var getStdFontMap = getLookupTableFactory(function (t) {
17851 t['ArialNarrow'] = 'Helvetica';
17852 t['ArialNarrow-Bold'] = 'Helvetica-Bold';
17853 t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
17854 t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
17855 t['ArialBlack'] = 'Helvetica';
17856 t['ArialBlack-Bold'] = 'Helvetica-Bold';
17857 t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
17858 t['ArialBlack-Italic'] = 'Helvetica-Oblique';
17859 t['Arial'] = 'Helvetica';
17860 t['Arial-Bold'] = 'Helvetica-Bold';
17861 t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
17862 t['Arial-Italic'] = 'Helvetica-Oblique';
17863 t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
17864 t['Arial-BoldMT'] = 'Helvetica-Bold';
17865 t['Arial-ItalicMT'] = 'Helvetica-Oblique';
17866 t['ArialMT'] = 'Helvetica';
17867 t['Courier-Bold'] = 'Courier-Bold';
17868 t['Courier-BoldItalic'] = 'Courier-BoldOblique';
17869 t['Courier-Italic'] = 'Courier-Oblique';
17870 t['CourierNew'] = 'Courier';
17871 t['CourierNew-Bold'] = 'Courier-Bold';
17872 t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
17873 t['CourierNew-Italic'] = 'Courier-Oblique';
17874 t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
17875 t['CourierNewPS-BoldMT'] = 'Courier-Bold';
17876 t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
17877 t['CourierNewPSMT'] = 'Courier';
17878 t['Helvetica'] = 'Helvetica';
17879 t['Helvetica-Bold'] = 'Helvetica-Bold';
17880 t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
17881 t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
17882 t['Helvetica-Italic'] = 'Helvetica-Oblique';
17883 t['Helvetica-Oblique'] = 'Helvetica-Oblique';
17884 t['Symbol-Bold'] = 'Symbol';
17885 t['Symbol-BoldItalic'] = 'Symbol';
17886 t['Symbol-Italic'] = 'Symbol';
17887 t['TimesNewRoman'] = 'Times-Roman';
17888 t['TimesNewRoman-Bold'] = 'Times-Bold';
17889 t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
17890 t['TimesNewRoman-Italic'] = 'Times-Italic';
17891 t['TimesNewRomanPS'] = 'Times-Roman';
17892 t['TimesNewRomanPS-Bold'] = 'Times-Bold';
17893 t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
17894 t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
17895 t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
17896 t['TimesNewRomanPS-Italic'] = 'Times-Italic';
17897 t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
17898 t['TimesNewRomanPSMT'] = 'Times-Roman';
17899 t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
17900 t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
17901 t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
17902 });
17903
17904 /**
17905 * Holds the map of the non-standard fonts that might be included as
17906 * a standard fonts without glyph data.
17907 */
17908 var getNonStdFontMap = getLookupTableFactory(function (t) {
17909 t['CenturyGothic'] = 'Helvetica';
17910 t['CenturyGothic-Bold'] = 'Helvetica-Bold';
17911 t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
17912 t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
17913 t['ComicSansMS'] = 'Comic Sans MS';
17914 t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
17915 t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
17916 t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
17917 t['LucidaConsole'] = 'Courier';
17918 t['LucidaConsole-Bold'] = 'Courier-Bold';
17919 t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
17920 t['LucidaConsole-Italic'] = 'Courier-Oblique';
17921 t['MS-Gothic'] = 'MS Gothic';
17922 t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
17923 t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
17924 t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
17925 t['MS-Mincho'] = 'MS Mincho';
17926 t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
17927 t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
17928 t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
17929 t['MS-PGothic'] = 'MS PGothic';
17930 t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
17931 t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
17932 t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
17933 t['MS-PMincho'] = 'MS PMincho';
17934 t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
17935 t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
17936 t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
17937 t['Wingdings'] = 'ZapfDingbats';
17938 });
17939
17940 var getSerifFonts = getLookupTableFactory(function (t) {
17941 t['Adobe Jenson'] = true;
17942 t['Adobe Text'] = true;
17943 t['Albertus'] = true;
17944 t['Aldus'] = true;
17945 t['Alexandria'] = true;
17946 t['Algerian'] = true;
17947 t['American Typewriter'] = true;
17948 t['Antiqua'] = true;
17949 t['Apex'] = true;
17950 t['Arno'] = true;
17951 t['Aster'] = true;
17952 t['Aurora'] = true;
17953 t['Baskerville'] = true;
17954 t['Bell'] = true;
17955 t['Bembo'] = true;
17956 t['Bembo Schoolbook'] = true;
17957 t['Benguiat'] = true;
17958 t['Berkeley Old Style'] = true;
17959 t['Bernhard Modern'] = true;
17960 t['Berthold City'] = true;
17961 t['Bodoni'] = true;
17962 t['Bauer Bodoni'] = true;
17963 t['Book Antiqua'] = true;
17964 t['Bookman'] = true;
17965 t['Bordeaux Roman'] = true;
17966 t['Californian FB'] = true;
17967 t['Calisto'] = true;
17968 t['Calvert'] = true;
17969 t['Capitals'] = true;
17970 t['Cambria'] = true;
17971 t['Cartier'] = true;
17972 t['Caslon'] = true;
17973 t['Catull'] = true;
17974 t['Centaur'] = true;
17975 t['Century Old Style'] = true;
17976 t['Century Schoolbook'] = true;
17977 t['Chaparral'] = true;
17978 t['Charis SIL'] = true;
17979 t['Cheltenham'] = true;
17980 t['Cholla Slab'] = true;
17981 t['Clarendon'] = true;
17982 t['Clearface'] = true;
17983 t['Cochin'] = true;
17984 t['Colonna'] = true;
17985 t['Computer Modern'] = true;
17986 t['Concrete Roman'] = true;
17987 t['Constantia'] = true;
17988 t['Cooper Black'] = true;
17989 t['Corona'] = true;
17990 t['Ecotype'] = true;
17991 t['Egyptienne'] = true;
17992 t['Elephant'] = true;
17993 t['Excelsior'] = true;
17994 t['Fairfield'] = true;
17995 t['FF Scala'] = true;
17996 t['Folkard'] = true;
17997 t['Footlight'] = true;
17998 t['FreeSerif'] = true;
17999 t['Friz Quadrata'] = true;
18000 t['Garamond'] = true;
18001 t['Gentium'] = true;
18002 t['Georgia'] = true;
18003 t['Gloucester'] = true;
18004 t['Goudy Old Style'] = true;
18005 t['Goudy Schoolbook'] = true;
18006 t['Goudy Pro Font'] = true;
18007 t['Granjon'] = true;
18008 t['Guardian Egyptian'] = true;
18009 t['Heather'] = true;
18010 t['Hercules'] = true;
18011 t['High Tower Text'] = true;
18012 t['Hiroshige'] = true;
18013 t['Hoefler Text'] = true;
18014 t['Humana Serif'] = true;
18015 t['Imprint'] = true;
18016 t['Ionic No. 5'] = true;
18017 t['Janson'] = true;
18018 t['Joanna'] = true;
18019 t['Korinna'] = true;
18020 t['Lexicon'] = true;
18021 t['Liberation Serif'] = true;
18022 t['Linux Libertine'] = true;
18023 t['Literaturnaya'] = true;
18024 t['Lucida'] = true;
18025 t['Lucida Bright'] = true;
18026 t['Melior'] = true;
18027 t['Memphis'] = true;
18028 t['Miller'] = true;
18029 t['Minion'] = true;
18030 t['Modern'] = true;
18031 t['Mona Lisa'] = true;
18032 t['Mrs Eaves'] = true;
18033 t['MS Serif'] = true;
18034 t['Museo Slab'] = true;
18035 t['New York'] = true;
18036 t['Nimbus Roman'] = true;
18037 t['NPS Rawlinson Roadway'] = true;
18038 t['Palatino'] = true;
18039 t['Perpetua'] = true;
18040 t['Plantin'] = true;
18041 t['Plantin Schoolbook'] = true;
18042 t['Playbill'] = true;
18043 t['Poor Richard'] = true;
18044 t['Rawlinson Roadway'] = true;
18045 t['Renault'] = true;
18046 t['Requiem'] = true;
18047 t['Rockwell'] = true;
18048 t['Roman'] = true;
18049 t['Rotis Serif'] = true;
18050 t['Sabon'] = true;
18051 t['Scala'] = true;
18052 t['Seagull'] = true;
18053 t['Sistina'] = true;
18054 t['Souvenir'] = true;
18055 t['STIX'] = true;
18056 t['Stone Informal'] = true;
18057 t['Stone Serif'] = true;
18058 t['Sylfaen'] = true;
18059 t['Times'] = true;
18060 t['Trajan'] = true;
18061 t['Trinité'] = true;
18062 t['Trump Mediaeval'] = true;
18063 t['Utopia'] = true;
18064 t['Vale Type'] = true;
18065 t['Bitstream Vera'] = true;
18066 t['Vera Serif'] = true;
18067 t['Versailles'] = true;
18068 t['Wanted'] = true;
18069 t['Weiss'] = true;
18070 t['Wide Latin'] = true;
18071 t['Windsor'] = true;
18072 t['XITS'] = true;
18073 });
18074
18075 var getSymbolsFonts = getLookupTableFactory(function (t) {
18076 t['Dingbats'] = true;
18077 t['Symbol'] = true;
18078 t['ZapfDingbats'] = true;
18079 });
18080
18081 // Glyph map for well-known standard fonts. Sometimes Ghostscript uses CID
18082 // fonts, but does not embed the CID to GID mapping. The mapping is incomplete
18083 // for all glyphs, but common for some set of the standard fonts.
18084 var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
18085 t[2] = 10; t[3] = 32; t[4] = 33; t[5] = 34; t[6] = 35; t[7] = 36; t[8] = 37;
18086 t[9] = 38; t[10] = 39; t[11] = 40; t[12] = 41; t[13] = 42; t[14] = 43;
18087 t[15] = 44; t[16] = 45; t[17] = 46; t[18] = 47; t[19] = 48; t[20] = 49;
18088 t[21] = 50; t[22] = 51; t[23] = 52; t[24] = 53; t[25] = 54; t[26] = 55;
18089 t[27] = 56; t[28] = 57; t[29] = 58; t[30] = 894; t[31] = 60; t[32] = 61;
18090 t[33] = 62; t[34] = 63; t[35] = 64; t[36] = 65; t[37] = 66; t[38] = 67;
18091 t[39] = 68; t[40] = 69; t[41] = 70; t[42] = 71; t[43] = 72; t[44] = 73;
18092 t[45] = 74; t[46] = 75; t[47] = 76; t[48] = 77; t[49] = 78; t[50] = 79;
18093 t[51] = 80; t[52] = 81; t[53] = 82; t[54] = 83; t[55] = 84; t[56] = 85;
18094 t[57] = 86; t[58] = 87; t[59] = 88; t[60] = 89; t[61] = 90; t[62] = 91;
18095 t[63] = 92; t[64] = 93; t[65] = 94; t[66] = 95; t[67] = 96; t[68] = 97;
18096 t[69] = 98; t[70] = 99; t[71] = 100; t[72] = 101; t[73] = 102; t[74] = 103;
18097 t[75] = 104; t[76] = 105; t[77] = 106; t[78] = 107; t[79] = 108;
18098 t[80] = 109; t[81] = 110; t[82] = 111; t[83] = 112; t[84] = 113;
18099 t[85] = 114; t[86] = 115; t[87] = 116; t[88] = 117; t[89] = 118;
18100 t[90] = 119; t[91] = 120; t[92] = 121; t[93] = 122; t[94] = 123;
18101 t[95] = 124; t[96] = 125; t[97] = 126; t[98] = 196; t[99] = 197;
18102 t[100] = 199; t[101] = 201; t[102] = 209; t[103] = 214; t[104] = 220;
18103 t[105] = 225; t[106] = 224; t[107] = 226; t[108] = 228; t[109] = 227;
18104 t[110] = 229; t[111] = 231; t[112] = 233; t[113] = 232; t[114] = 234;
18105 t[115] = 235; t[116] = 237; t[117] = 236; t[118] = 238; t[119] = 239;
18106 t[120] = 241; t[121] = 243; t[122] = 242; t[123] = 244; t[124] = 246;
18107 t[125] = 245; t[126] = 250; t[127] = 249; t[128] = 251; t[129] = 252;
18108 t[130] = 8224; t[131] = 176; t[132] = 162; t[133] = 163; t[134] = 167;
18109 t[135] = 8226; t[136] = 182; t[137] = 223; t[138] = 174; t[139] = 169;
18110 t[140] = 8482; t[141] = 180; t[142] = 168; t[143] = 8800; t[144] = 198;
18111 t[145] = 216; t[146] = 8734; t[147] = 177; t[148] = 8804; t[149] = 8805;
18112 t[150] = 165; t[151] = 181; t[152] = 8706; t[153] = 8721; t[154] = 8719;
18113 t[156] = 8747; t[157] = 170; t[158] = 186; t[159] = 8486; t[160] = 230;
18114 t[161] = 248; t[162] = 191; t[163] = 161; t[164] = 172; t[165] = 8730;
18115 t[166] = 402; t[167] = 8776; t[168] = 8710; t[169] = 171; t[170] = 187;
18116 t[171] = 8230; t[210] = 218; t[223] = 711; t[224] = 321; t[225] = 322;
18117 t[227] = 353; t[229] = 382; t[234] = 253; t[252] = 263; t[253] = 268;
18118 t[254] = 269; t[258] = 258; t[260] = 260; t[261] = 261; t[265] = 280;
18119 t[266] = 281; t[268] = 283; t[269] = 313; t[275] = 323; t[276] = 324;
18120 t[278] = 328; t[284] = 345; t[285] = 346; t[286] = 347; t[292] = 367;
18121 t[295] = 377; t[296] = 378; t[298] = 380; t[305] = 963; t[306] = 964;
18122 t[307] = 966; t[308] = 8215; t[309] = 8252; t[310] = 8319; t[311] = 8359;
18123 t[312] = 8592; t[313] = 8593; t[337] = 9552; t[493] = 1039;
18124 t[494] = 1040; t[705] = 1524; t[706] = 8362; t[710] = 64288; t[711] = 64298;
18125 t[759] = 1617; t[761] = 1776; t[763] = 1778; t[775] = 1652; t[777] = 1764;
18126 t[778] = 1780; t[779] = 1781; t[780] = 1782; t[782] = 771; t[783] = 64726;
18127 t[786] = 8363; t[788] = 8532; t[790] = 768; t[791] = 769; t[792] = 768;
18128 t[795] = 803; t[797] = 64336; t[798] = 64337; t[799] = 64342;
18129 t[800] = 64343; t[801] = 64344; t[802] = 64345; t[803] = 64362;
18130 t[804] = 64363; t[805] = 64364; t[2424] = 7821; t[2425] = 7822;
18131 t[2426] = 7823; t[2427] = 7824; t[2428] = 7825; t[2429] = 7826;
18132 t[2430] = 7827; t[2433] = 7682; t[2678] = 8045; t[2679] = 8046;
18133 t[2830] = 1552; t[2838] = 686; t[2840] = 751; t[2842] = 753; t[2843] = 754;
18134 t[2844] = 755; t[2846] = 757; t[2856] = 767; t[2857] = 848; t[2858] = 849;
18135 t[2862] = 853; t[2863] = 854; t[2864] = 855; t[2865] = 861; t[2866] = 862;
18136 t[2906] = 7460; t[2908] = 7462; t[2909] = 7463; t[2910] = 7464;
18137 t[2912] = 7466; t[2913] = 7467; t[2914] = 7468; t[2916] = 7470;
18138 t[2917] = 7471; t[2918] = 7472; t[2920] = 7474; t[2921] = 7475;
18139 t[2922] = 7476; t[2924] = 7478; t[2925] = 7479; t[2926] = 7480;
18140 t[2928] = 7482; t[2929] = 7483; t[2930] = 7484; t[2932] = 7486;
18141 t[2933] = 7487; t[2934] = 7488; t[2936] = 7490; t[2937] = 7491;
18142 t[2938] = 7492; t[2940] = 7494; t[2941] = 7495; t[2942] = 7496;
18143 t[2944] = 7498; t[2946] = 7500; t[2948] = 7502; t[2950] = 7504;
18144 t[2951] = 7505; t[2952] = 7506; t[2954] = 7508; t[2955] = 7509;
18145 t[2956] = 7510; t[2958] = 7512; t[2959] = 7513; t[2960] = 7514;
18146 t[2962] = 7516; t[2963] = 7517; t[2964] = 7518; t[2966] = 7520;
18147 t[2967] = 7521; t[2968] = 7522; t[2970] = 7524; t[2971] = 7525;
18148 t[2972] = 7526; t[2974] = 7528; t[2975] = 7529; t[2976] = 7530;
18149 t[2978] = 1537; t[2979] = 1538; t[2980] = 1539; t[2982] = 1549;
18150 t[2983] = 1551; t[2984] = 1552; t[2986] = 1554; t[2987] = 1555;
18151 t[2988] = 1556; t[2990] = 1623; t[2991] = 1624; t[2995] = 1775;
18152 t[2999] = 1791; t[3002] = 64290; t[3003] = 64291; t[3004] = 64292;
18153 t[3006] = 64294; t[3007] = 64295; t[3008] = 64296; t[3011] = 1900;
18154 t[3014] = 8223; t[3015] = 8244; t[3017] = 7532; t[3018] = 7533;
18155 t[3019] = 7534; t[3075] = 7590; t[3076] = 7591; t[3079] = 7594;
18156 t[3080] = 7595; t[3083] = 7598; t[3084] = 7599; t[3087] = 7602;
18157 t[3088] = 7603; t[3091] = 7606; t[3092] = 7607; t[3095] = 7610;
18158 t[3096] = 7611; t[3099] = 7614; t[3100] = 7615; t[3103] = 7618;
18159 t[3104] = 7619; t[3107] = 8337; t[3108] = 8338; t[3116] = 1884;
18160 t[3119] = 1885; t[3120] = 1885; t[3123] = 1886; t[3124] = 1886;
18161 t[3127] = 1887; t[3128] = 1887; t[3131] = 1888; t[3132] = 1888;
18162 t[3135] = 1889; t[3136] = 1889; t[3139] = 1890; t[3140] = 1890;
18163 t[3143] = 1891; t[3144] = 1891; t[3147] = 1892; t[3148] = 1892;
18164 t[3153] = 580; t[3154] = 581; t[3157] = 584; t[3158] = 585; t[3161] = 588;
18165 t[3162] = 589; t[3165] = 891; t[3166] = 892; t[3169] = 1274; t[3170] = 1275;
18166 t[3173] = 1278; t[3174] = 1279; t[3181] = 7622; t[3182] = 7623;
18167 t[3282] = 11799; t[3316] = 578; t[3379] = 42785; t[3393] = 1159;
18168 t[3416] = 8377;
18169 });
18170
18171 // The glyph map for ArialBlack differs slightly from the glyph map used for
18172 // other well-known standard fonts. Hence we use this (incomplete) CID to GID
18173 // mapping to adjust the glyph map for non-embedded ArialBlack fonts.
18174 var getSupplementalGlyphMapForArialBlack =
18175 getLookupTableFactory(function (t) {
18176 t[227] = 322; t[264] = 261; t[291] = 346;
18177 });
18178
18179 exports.getStdFontMap = getStdFontMap;
18180 exports.getNonStdFontMap = getNonStdFontMap;
18181 exports.getSerifFonts = getSerifFonts;
18182 exports.getSymbolsFonts = getSymbolsFonts;
18183 exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
18184 exports.getSupplementalGlyphMapForArialBlack =
18185 getSupplementalGlyphMapForArialBlack;
18186}));
18187
18188
18189(function (root, factory) {
18190 {
18191 factory((root.pdfjsCoreUnicode = {}), root.pdfjsSharedUtil);
18192 }
18193}(this, function (exports, sharedUtil) {
18194 var getLookupTableFactory = sharedUtil.getLookupTableFactory;
18195
18196 // Some characters, e.g. copyrightserif, are mapped to the private use area
18197 // and might not be displayed using standard fonts. Mapping/hacking well-known
18198 // chars to the similar equivalents in the normal characters range.
18199 var getSpecialPUASymbols = getLookupTableFactory(function (t) {
18200 t[63721] = 0x00A9; // copyrightsans (0xF8E9) => copyright
18201 t[63193] = 0x00A9; // copyrightserif (0xF6D9) => copyright
18202 t[63720] = 0x00AE; // registersans (0xF8E8) => registered
18203 t[63194] = 0x00AE; // registerserif (0xF6DA) => registered
18204 t[63722] = 0x2122; // trademarksans (0xF8EA) => trademark
18205 t[63195] = 0x2122; // trademarkserif (0xF6DB) => trademark
18206 t[63729] = 0x23A7; // bracelefttp (0xF8F1)
18207 t[63730] = 0x23A8; // braceleftmid (0xF8F2)
18208 t[63731] = 0x23A9; // braceleftbt (0xF8F3)
18209 t[63740] = 0x23AB; // bracerighttp (0xF8FC)
18210 t[63741] = 0x23AC; // bracerightmid (0xF8FD)
18211 t[63742] = 0x23AD; // bracerightbt (0xF8FE)
18212 t[63726] = 0x23A1; // bracketlefttp (0xF8EE)
18213 t[63727] = 0x23A2; // bracketleftex (0xF8EF)
18214 t[63728] = 0x23A3; // bracketleftbt (0xF8F0)
18215 t[63737] = 0x23A4; // bracketrighttp (0xF8F9)
18216 t[63738] = 0x23A5; // bracketrightex (0xF8FA)
18217 t[63739] = 0x23A6; // bracketrightbt (0xF8FB)
18218 t[63723] = 0x239B; // parenlefttp (0xF8EB)
18219 t[63724] = 0x239C; // parenleftex (0xF8EC)
18220 t[63725] = 0x239D; // parenleftbt (0xF8ED)
18221 t[63734] = 0x239E; // parenrighttp (0xF8F6)
18222 t[63735] = 0x239F; // parenrightex (0xF8F7)
18223 t[63736] = 0x23A0; // parenrightbt (0xF8F8)
18224 });
18225
18226 function mapSpecialUnicodeValues(code) {
18227 if (code >= 0xFFF0 && code <= 0xFFFF) { // Specials unicode block.
18228 return 0;
18229 } else if (code >= 0xF600 && code <= 0xF8FF) {
18230 return (getSpecialPUASymbols()[code] || code);
18231 }
18232 return code;
18233 }
18234
18235 function getUnicodeForGlyph(name, glyphsUnicodeMap) {
18236 var unicode = glyphsUnicodeMap[name];
18237 if (unicode !== undefined) {
18238 return unicode;
18239 }
18240 if (!name) {
18241 return -1;
18242 }
18243 // Try to recover valid Unicode values from 'uniXXXX'/'uXXXX{XX}' glyphs.
18244 if (name[0] === 'u') {
18245 var nameLen = name.length, hexStr;
18246
18247 if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') { // 'uniXXXX'
18248 hexStr = name.substr(3);
18249 } else if (nameLen >= 5 && nameLen <= 7) { // 'uXXXX{XX}'
18250 hexStr = name.substr(1);
18251 } else {
18252 return -1;
18253 }
18254 // Check for upper-case hexadecimal characters, to avoid false positives.
18255 if (hexStr === hexStr.toUpperCase()) {
18256 unicode = parseInt(hexStr, 16);
18257 if (unicode >= 0) {
18258 return unicode;
18259 }
18260 }
18261 }
18262 return -1;
18263 }
18264
18265 var UnicodeRanges = [
18266 { 'begin': 0x0000, 'end': 0x007F }, // Basic Latin
18267 { 'begin': 0x0080, 'end': 0x00FF }, // Latin-1 Supplement
18268 { 'begin': 0x0100, 'end': 0x017F }, // Latin Extended-A
18269 { 'begin': 0x0180, 'end': 0x024F }, // Latin Extended-B
18270 { 'begin': 0x0250, 'end': 0x02AF }, // IPA Extensions
18271 { 'begin': 0x02B0, 'end': 0x02FF }, // Spacing Modifier Letters
18272 { 'begin': 0x0300, 'end': 0x036F }, // Combining Diacritical Marks
18273 { 'begin': 0x0370, 'end': 0x03FF }, // Greek and Coptic
18274 { 'begin': 0x2C80, 'end': 0x2CFF }, // Coptic
18275 { 'begin': 0x0400, 'end': 0x04FF }, // Cyrillic
18276 { 'begin': 0x0530, 'end': 0x058F }, // Armenian
18277 { 'begin': 0x0590, 'end': 0x05FF }, // Hebrew
18278 { 'begin': 0xA500, 'end': 0xA63F }, // Vai
18279 { 'begin': 0x0600, 'end': 0x06FF }, // Arabic
18280 { 'begin': 0x07C0, 'end': 0x07FF }, // NKo
18281 { 'begin': 0x0900, 'end': 0x097F }, // Devanagari
18282 { 'begin': 0x0980, 'end': 0x09FF }, // Bengali
18283 { 'begin': 0x0A00, 'end': 0x0A7F }, // Gurmukhi
18284 { 'begin': 0x0A80, 'end': 0x0AFF }, // Gujarati
18285 { 'begin': 0x0B00, 'end': 0x0B7F }, // Oriya
18286 { 'begin': 0x0B80, 'end': 0x0BFF }, // Tamil
18287 { 'begin': 0x0C00, 'end': 0x0C7F }, // Telugu
18288 { 'begin': 0x0C80, 'end': 0x0CFF }, // Kannada
18289 { 'begin': 0x0D00, 'end': 0x0D7F }, // Malayalam
18290 { 'begin': 0x0E00, 'end': 0x0E7F }, // Thai
18291 { 'begin': 0x0E80, 'end': 0x0EFF }, // Lao
18292 { 'begin': 0x10A0, 'end': 0x10FF }, // Georgian
18293 { 'begin': 0x1B00, 'end': 0x1B7F }, // Balinese
18294 { 'begin': 0x1100, 'end': 0x11FF }, // Hangul Jamo
18295 { 'begin': 0x1E00, 'end': 0x1EFF }, // Latin Extended Additional
18296 { 'begin': 0x1F00, 'end': 0x1FFF }, // Greek Extended
18297 { 'begin': 0x2000, 'end': 0x206F }, // General Punctuation
18298 { 'begin': 0x2070, 'end': 0x209F }, // Superscripts And Subscripts
18299 { 'begin': 0x20A0, 'end': 0x20CF }, // Currency Symbol
18300 { 'begin': 0x20D0, 'end': 0x20FF }, // Combining Diacritical Marks
18301 { 'begin': 0x2100, 'end': 0x214F }, // Letterlike Symbols
18302 { 'begin': 0x2150, 'end': 0x218F }, // Number Forms
18303 { 'begin': 0x2190, 'end': 0x21FF }, // Arrows
18304 { 'begin': 0x2200, 'end': 0x22FF }, // Mathematical Operators
18305 { 'begin': 0x2300, 'end': 0x23FF }, // Miscellaneous Technical
18306 { 'begin': 0x2400, 'end': 0x243F }, // Control Pictures
18307 { 'begin': 0x2440, 'end': 0x245F }, // Optical Character Recognition
18308 { 'begin': 0x2460, 'end': 0x24FF }, // Enclosed Alphanumerics
18309 { 'begin': 0x2500, 'end': 0x257F }, // Box Drawing
18310 { 'begin': 0x2580, 'end': 0x259F }, // Block Elements
18311 { 'begin': 0x25A0, 'end': 0x25FF }, // Geometric Shapes
18312 { 'begin': 0x2600, 'end': 0x26FF }, // Miscellaneous Symbols
18313 { 'begin': 0x2700, 'end': 0x27BF }, // Dingbats
18314 { 'begin': 0x3000, 'end': 0x303F }, // CJK Symbols And Punctuation
18315 { 'begin': 0x3040, 'end': 0x309F }, // Hiragana
18316 { 'begin': 0x30A0, 'end': 0x30FF }, // Katakana
18317 { 'begin': 0x3100, 'end': 0x312F }, // Bopomofo
18318 { 'begin': 0x3130, 'end': 0x318F }, // Hangul Compatibility Jamo
18319 { 'begin': 0xA840, 'end': 0xA87F }, // Phags-pa
18320 { 'begin': 0x3200, 'end': 0x32FF }, // Enclosed CJK Letters And Months
18321 { 'begin': 0x3300, 'end': 0x33FF }, // CJK Compatibility
18322 { 'begin': 0xAC00, 'end': 0xD7AF }, // Hangul Syllables
18323 { 'begin': 0xD800, 'end': 0xDFFF }, // Non-Plane 0 *
18324 { 'begin': 0x10900, 'end': 0x1091F }, // Phoenicia
18325 { 'begin': 0x4E00, 'end': 0x9FFF }, // CJK Unified Ideographs
18326 { 'begin': 0xE000, 'end': 0xF8FF }, // Private Use Area (plane 0)
18327 { 'begin': 0x31C0, 'end': 0x31EF }, // CJK Strokes
18328 { 'begin': 0xFB00, 'end': 0xFB4F }, // Alphabetic Presentation Forms
18329 { 'begin': 0xFB50, 'end': 0xFDFF }, // Arabic Presentation Forms-A
18330 { 'begin': 0xFE20, 'end': 0xFE2F }, // Combining Half Marks
18331 { 'begin': 0xFE10, 'end': 0xFE1F }, // Vertical Forms
18332 { 'begin': 0xFE50, 'end': 0xFE6F }, // Small Form Variants
18333 { 'begin': 0xFE70, 'end': 0xFEFF }, // Arabic Presentation Forms-B
18334 { 'begin': 0xFF00, 'end': 0xFFEF }, // Halfwidth And Fullwidth Forms
18335 { 'begin': 0xFFF0, 'end': 0xFFFF }, // Specials
18336 { 'begin': 0x0F00, 'end': 0x0FFF }, // Tibetan
18337 { 'begin': 0x0700, 'end': 0x074F }, // Syriac
18338 { 'begin': 0x0780, 'end': 0x07BF }, // Thaana
18339 { 'begin': 0x0D80, 'end': 0x0DFF }, // Sinhala
18340 { 'begin': 0x1000, 'end': 0x109F }, // Myanmar
18341 { 'begin': 0x1200, 'end': 0x137F }, // Ethiopic
18342 { 'begin': 0x13A0, 'end': 0x13FF }, // Cherokee
18343 { 'begin': 0x1400, 'end': 0x167F }, // Unified Canadian Aboriginal Syllabics
18344 { 'begin': 0x1680, 'end': 0x169F }, // Ogham
18345 { 'begin': 0x16A0, 'end': 0x16FF }, // Runic
18346 { 'begin': 0x1780, 'end': 0x17FF }, // Khmer
18347 { 'begin': 0x1800, 'end': 0x18AF }, // Mongolian
18348 { 'begin': 0x2800, 'end': 0x28FF }, // Braille Patterns
18349 { 'begin': 0xA000, 'end': 0xA48F }, // Yi Syllables
18350 { 'begin': 0x1700, 'end': 0x171F }, // Tagalog
18351 { 'begin': 0x10300, 'end': 0x1032F }, // Old Italic
18352 { 'begin': 0x10330, 'end': 0x1034F }, // Gothic
18353 { 'begin': 0x10400, 'end': 0x1044F }, // Deseret
18354 { 'begin': 0x1D000, 'end': 0x1D0FF }, // Byzantine Musical Symbols
18355 { 'begin': 0x1D400, 'end': 0x1D7FF }, // Mathematical Alphanumeric Symbols
18356 { 'begin': 0xFF000, 'end': 0xFFFFD }, // Private Use (plane 15)
18357 { 'begin': 0xFE00, 'end': 0xFE0F }, // Variation Selectors
18358 { 'begin': 0xE0000, 'end': 0xE007F }, // Tags
18359 { 'begin': 0x1900, 'end': 0x194F }, // Limbu
18360 { 'begin': 0x1950, 'end': 0x197F }, // Tai Le
18361 { 'begin': 0x1980, 'end': 0x19DF }, // New Tai Lue
18362 { 'begin': 0x1A00, 'end': 0x1A1F }, // Buginese
18363 { 'begin': 0x2C00, 'end': 0x2C5F }, // Glagolitic
18364 { 'begin': 0x2D30, 'end': 0x2D7F }, // Tifinagh
18365 { 'begin': 0x4DC0, 'end': 0x4DFF }, // Yijing Hexagram Symbols
18366 { 'begin': 0xA800, 'end': 0xA82F }, // Syloti Nagri
18367 { 'begin': 0x10000, 'end': 0x1007F }, // Linear B Syllabary
18368 { 'begin': 0x10140, 'end': 0x1018F }, // Ancient Greek Numbers
18369 { 'begin': 0x10380, 'end': 0x1039F }, // Ugaritic
18370 { 'begin': 0x103A0, 'end': 0x103DF }, // Old Persian
18371 { 'begin': 0x10450, 'end': 0x1047F }, // Shavian
18372 { 'begin': 0x10480, 'end': 0x104AF }, // Osmanya
18373 { 'begin': 0x10800, 'end': 0x1083F }, // Cypriot Syllabary
18374 { 'begin': 0x10A00, 'end': 0x10A5F }, // Kharoshthi
18375 { 'begin': 0x1D300, 'end': 0x1D35F }, // Tai Xuan Jing Symbols
18376 { 'begin': 0x12000, 'end': 0x123FF }, // Cuneiform
18377 { 'begin': 0x1D360, 'end': 0x1D37F }, // Counting Rod Numerals
18378 { 'begin': 0x1B80, 'end': 0x1BBF }, // Sundanese
18379 { 'begin': 0x1C00, 'end': 0x1C4F }, // Lepcha
18380 { 'begin': 0x1C50, 'end': 0x1C7F }, // Ol Chiki
18381 { 'begin': 0xA880, 'end': 0xA8DF }, // Saurashtra
18382 { 'begin': 0xA900, 'end': 0xA92F }, // Kayah Li
18383 { 'begin': 0xA930, 'end': 0xA95F }, // Rejang
18384 { 'begin': 0xAA00, 'end': 0xAA5F }, // Cham
18385 { 'begin': 0x10190, 'end': 0x101CF }, // Ancient Symbols
18386 { 'begin': 0x101D0, 'end': 0x101FF }, // Phaistos Disc
18387 { 'begin': 0x102A0, 'end': 0x102DF }, // Carian
18388 { 'begin': 0x1F030, 'end': 0x1F09F } // Domino Tiles
18389 ];
18390
18391 function getUnicodeRangeFor(value) {
18392 for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
18393 var range = UnicodeRanges[i];
18394 if (value >= range.begin && value < range.end) {
18395 return i;
18396 }
18397 }
18398 return -1;
18399 }
18400
18401 function isRTLRangeFor(value) {
18402 var range = UnicodeRanges[13];
18403 if (value >= range.begin && value < range.end) {
18404 return true;
18405 }
18406 range = UnicodeRanges[11];
18407 if (value >= range.begin && value < range.end) {
18408 return true;
18409 }
18410 return false;
18411 }
18412
18413 // The normalization table is obtained by filtering the Unicode characters
18414 // database with <compat> entries.
18415 var getNormalizedUnicodes = getLookupTableFactory(function (t) {
18416 t['\u00A8'] = '\u0020\u0308';
18417 t['\u00AF'] = '\u0020\u0304';
18418 t['\u00B4'] = '\u0020\u0301';
18419 t['\u00B5'] = '\u03BC';
18420 t['\u00B8'] = '\u0020\u0327';
18421 t['\u0132'] = '\u0049\u004A';
18422 t['\u0133'] = '\u0069\u006A';
18423 t['\u013F'] = '\u004C\u00B7';
18424 t['\u0140'] = '\u006C\u00B7';
18425 t['\u0149'] = '\u02BC\u006E';
18426 t['\u017F'] = '\u0073';
18427 t['\u01C4'] = '\u0044\u017D';
18428 t['\u01C5'] = '\u0044\u017E';
18429 t['\u01C6'] = '\u0064\u017E';
18430 t['\u01C7'] = '\u004C\u004A';
18431 t['\u01C8'] = '\u004C\u006A';
18432 t['\u01C9'] = '\u006C\u006A';
18433 t['\u01CA'] = '\u004E\u004A';
18434 t['\u01CB'] = '\u004E\u006A';
18435 t['\u01CC'] = '\u006E\u006A';
18436 t['\u01F1'] = '\u0044\u005A';
18437 t['\u01F2'] = '\u0044\u007A';
18438 t['\u01F3'] = '\u0064\u007A';
18439 t['\u02D8'] = '\u0020\u0306';
18440 t['\u02D9'] = '\u0020\u0307';
18441 t['\u02DA'] = '\u0020\u030A';
18442 t['\u02DB'] = '\u0020\u0328';
18443 t['\u02DC'] = '\u0020\u0303';
18444 t['\u02DD'] = '\u0020\u030B';
18445 t['\u037A'] = '\u0020\u0345';
18446 t['\u0384'] = '\u0020\u0301';
18447 t['\u03D0'] = '\u03B2';
18448 t['\u03D1'] = '\u03B8';
18449 t['\u03D2'] = '\u03A5';
18450 t['\u03D5'] = '\u03C6';
18451 t['\u03D6'] = '\u03C0';
18452 t['\u03F0'] = '\u03BA';
18453 t['\u03F1'] = '\u03C1';
18454 t['\u03F2'] = '\u03C2';
18455 t['\u03F4'] = '\u0398';
18456 t['\u03F5'] = '\u03B5';
18457 t['\u03F9'] = '\u03A3';
18458 t['\u0587'] = '\u0565\u0582';
18459 t['\u0675'] = '\u0627\u0674';
18460 t['\u0676'] = '\u0648\u0674';
18461 t['\u0677'] = '\u06C7\u0674';
18462 t['\u0678'] = '\u064A\u0674';
18463 t['\u0E33'] = '\u0E4D\u0E32';
18464 t['\u0EB3'] = '\u0ECD\u0EB2';
18465 t['\u0EDC'] = '\u0EAB\u0E99';
18466 t['\u0EDD'] = '\u0EAB\u0EA1';
18467 t['\u0F77'] = '\u0FB2\u0F81';
18468 t['\u0F79'] = '\u0FB3\u0F81';
18469 t['\u1E9A'] = '\u0061\u02BE';
18470 t['\u1FBD'] = '\u0020\u0313';
18471 t['\u1FBF'] = '\u0020\u0313';
18472 t['\u1FC0'] = '\u0020\u0342';
18473 t['\u1FFE'] = '\u0020\u0314';
18474 t['\u2002'] = '\u0020';
18475 t['\u2003'] = '\u0020';
18476 t['\u2004'] = '\u0020';
18477 t['\u2005'] = '\u0020';
18478 t['\u2006'] = '\u0020';
18479 t['\u2008'] = '\u0020';
18480 t['\u2009'] = '\u0020';
18481 t['\u200A'] = '\u0020';
18482 t['\u2017'] = '\u0020\u0333';
18483 t['\u2024'] = '\u002E';
18484 t['\u2025'] = '\u002E\u002E';
18485 t['\u2026'] = '\u002E\u002E\u002E';
18486 t['\u2033'] = '\u2032\u2032';
18487 t['\u2034'] = '\u2032\u2032\u2032';
18488 t['\u2036'] = '\u2035\u2035';
18489 t['\u2037'] = '\u2035\u2035\u2035';
18490 t['\u203C'] = '\u0021\u0021';
18491 t['\u203E'] = '\u0020\u0305';
18492 t['\u2047'] = '\u003F\u003F';
18493 t['\u2048'] = '\u003F\u0021';
18494 t['\u2049'] = '\u0021\u003F';
18495 t['\u2057'] = '\u2032\u2032\u2032\u2032';
18496 t['\u205F'] = '\u0020';
18497 t['\u20A8'] = '\u0052\u0073';
18498 t['\u2100'] = '\u0061\u002F\u0063';
18499 t['\u2101'] = '\u0061\u002F\u0073';
18500 t['\u2103'] = '\u00B0\u0043';
18501 t['\u2105'] = '\u0063\u002F\u006F';
18502 t['\u2106'] = '\u0063\u002F\u0075';
18503 t['\u2107'] = '\u0190';
18504 t['\u2109'] = '\u00B0\u0046';
18505 t['\u2116'] = '\u004E\u006F';
18506 t['\u2121'] = '\u0054\u0045\u004C';
18507 t['\u2135'] = '\u05D0';
18508 t['\u2136'] = '\u05D1';
18509 t['\u2137'] = '\u05D2';
18510 t['\u2138'] = '\u05D3';
18511 t['\u213B'] = '\u0046\u0041\u0058';
18512 t['\u2160'] = '\u0049';
18513 t['\u2161'] = '\u0049\u0049';
18514 t['\u2162'] = '\u0049\u0049\u0049';
18515 t['\u2163'] = '\u0049\u0056';
18516 t['\u2164'] = '\u0056';
18517 t['\u2165'] = '\u0056\u0049';
18518 t['\u2166'] = '\u0056\u0049\u0049';
18519 t['\u2167'] = '\u0056\u0049\u0049\u0049';
18520 t['\u2168'] = '\u0049\u0058';
18521 t['\u2169'] = '\u0058';
18522 t['\u216A'] = '\u0058\u0049';
18523 t['\u216B'] = '\u0058\u0049\u0049';
18524 t['\u216C'] = '\u004C';
18525 t['\u216D'] = '\u0043';
18526 t['\u216E'] = '\u0044';
18527 t['\u216F'] = '\u004D';
18528 t['\u2170'] = '\u0069';
18529 t['\u2171'] = '\u0069\u0069';
18530 t['\u2172'] = '\u0069\u0069\u0069';
18531 t['\u2173'] = '\u0069\u0076';
18532 t['\u2174'] = '\u0076';
18533 t['\u2175'] = '\u0076\u0069';
18534 t['\u2176'] = '\u0076\u0069\u0069';
18535 t['\u2177'] = '\u0076\u0069\u0069\u0069';
18536 t['\u2178'] = '\u0069\u0078';
18537 t['\u2179'] = '\u0078';
18538 t['\u217A'] = '\u0078\u0069';
18539 t['\u217B'] = '\u0078\u0069\u0069';
18540 t['\u217C'] = '\u006C';
18541 t['\u217D'] = '\u0063';
18542 t['\u217E'] = '\u0064';
18543 t['\u217F'] = '\u006D';
18544 t['\u222C'] = '\u222B\u222B';
18545 t['\u222D'] = '\u222B\u222B\u222B';
18546 t['\u222F'] = '\u222E\u222E';
18547 t['\u2230'] = '\u222E\u222E\u222E';
18548 t['\u2474'] = '\u0028\u0031\u0029';
18549 t['\u2475'] = '\u0028\u0032\u0029';
18550 t['\u2476'] = '\u0028\u0033\u0029';
18551 t['\u2477'] = '\u0028\u0034\u0029';
18552 t['\u2478'] = '\u0028\u0035\u0029';
18553 t['\u2479'] = '\u0028\u0036\u0029';
18554 t['\u247A'] = '\u0028\u0037\u0029';
18555 t['\u247B'] = '\u0028\u0038\u0029';
18556 t['\u247C'] = '\u0028\u0039\u0029';
18557 t['\u247D'] = '\u0028\u0031\u0030\u0029';
18558 t['\u247E'] = '\u0028\u0031\u0031\u0029';
18559 t['\u247F'] = '\u0028\u0031\u0032\u0029';
18560 t['\u2480'] = '\u0028\u0031\u0033\u0029';
18561 t['\u2481'] = '\u0028\u0031\u0034\u0029';
18562 t['\u2482'] = '\u0028\u0031\u0035\u0029';
18563 t['\u2483'] = '\u0028\u0031\u0036\u0029';
18564 t['\u2484'] = '\u0028\u0031\u0037\u0029';
18565 t['\u2485'] = '\u0028\u0031\u0038\u0029';
18566 t['\u2486'] = '\u0028\u0031\u0039\u0029';
18567 t['\u2487'] = '\u0028\u0032\u0030\u0029';
18568 t['\u2488'] = '\u0031\u002E';
18569 t['\u2489'] = '\u0032\u002E';
18570 t['\u248A'] = '\u0033\u002E';
18571 t['\u248B'] = '\u0034\u002E';
18572 t['\u248C'] = '\u0035\u002E';
18573 t['\u248D'] = '\u0036\u002E';
18574 t['\u248E'] = '\u0037\u002E';
18575 t['\u248F'] = '\u0038\u002E';
18576 t['\u2490'] = '\u0039\u002E';
18577 t['\u2491'] = '\u0031\u0030\u002E';
18578 t['\u2492'] = '\u0031\u0031\u002E';
18579 t['\u2493'] = '\u0031\u0032\u002E';
18580 t['\u2494'] = '\u0031\u0033\u002E';
18581 t['\u2495'] = '\u0031\u0034\u002E';
18582 t['\u2496'] = '\u0031\u0035\u002E';
18583 t['\u2497'] = '\u0031\u0036\u002E';
18584 t['\u2498'] = '\u0031\u0037\u002E';
18585 t['\u2499'] = '\u0031\u0038\u002E';
18586 t['\u249A'] = '\u0031\u0039\u002E';
18587 t['\u249B'] = '\u0032\u0030\u002E';
18588 t['\u249C'] = '\u0028\u0061\u0029';
18589 t['\u249D'] = '\u0028\u0062\u0029';
18590 t['\u249E'] = '\u0028\u0063\u0029';
18591 t['\u249F'] = '\u0028\u0064\u0029';
18592 t['\u24A0'] = '\u0028\u0065\u0029';
18593 t['\u24A1'] = '\u0028\u0066\u0029';
18594 t['\u24A2'] = '\u0028\u0067\u0029';
18595 t['\u24A3'] = '\u0028\u0068\u0029';
18596 t['\u24A4'] = '\u0028\u0069\u0029';
18597 t['\u24A5'] = '\u0028\u006A\u0029';
18598 t['\u24A6'] = '\u0028\u006B\u0029';
18599 t['\u24A7'] = '\u0028\u006C\u0029';
18600 t['\u24A8'] = '\u0028\u006D\u0029';
18601 t['\u24A9'] = '\u0028\u006E\u0029';
18602 t['\u24AA'] = '\u0028\u006F\u0029';
18603 t['\u24AB'] = '\u0028\u0070\u0029';
18604 t['\u24AC'] = '\u0028\u0071\u0029';
18605 t['\u24AD'] = '\u0028\u0072\u0029';
18606 t['\u24AE'] = '\u0028\u0073\u0029';
18607 t['\u24AF'] = '\u0028\u0074\u0029';
18608 t['\u24B0'] = '\u0028\u0075\u0029';
18609 t['\u24B1'] = '\u0028\u0076\u0029';
18610 t['\u24B2'] = '\u0028\u0077\u0029';
18611 t['\u24B3'] = '\u0028\u0078\u0029';
18612 t['\u24B4'] = '\u0028\u0079\u0029';
18613 t['\u24B5'] = '\u0028\u007A\u0029';
18614 t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
18615 t['\u2A74'] = '\u003A\u003A\u003D';
18616 t['\u2A75'] = '\u003D\u003D';
18617 t['\u2A76'] = '\u003D\u003D\u003D';
18618 t['\u2E9F'] = '\u6BCD';
18619 t['\u2EF3'] = '\u9F9F';
18620 t['\u2F00'] = '\u4E00';
18621 t['\u2F01'] = '\u4E28';
18622 t['\u2F02'] = '\u4E36';
18623 t['\u2F03'] = '\u4E3F';
18624 t['\u2F04'] = '\u4E59';
18625 t['\u2F05'] = '\u4E85';
18626 t['\u2F06'] = '\u4E8C';
18627 t['\u2F07'] = '\u4EA0';
18628 t['\u2F08'] = '\u4EBA';
18629 t['\u2F09'] = '\u513F';
18630 t['\u2F0A'] = '\u5165';
18631 t['\u2F0B'] = '\u516B';
18632 t['\u2F0C'] = '\u5182';
18633 t['\u2F0D'] = '\u5196';
18634 t['\u2F0E'] = '\u51AB';
18635 t['\u2F0F'] = '\u51E0';
18636 t['\u2F10'] = '\u51F5';
18637 t['\u2F11'] = '\u5200';
18638 t['\u2F12'] = '\u529B';
18639 t['\u2F13'] = '\u52F9';
18640 t['\u2F14'] = '\u5315';
18641 t['\u2F15'] = '\u531A';
18642 t['\u2F16'] = '\u5338';
18643 t['\u2F17'] = '\u5341';
18644 t['\u2F18'] = '\u535C';
18645 t['\u2F19'] = '\u5369';
18646 t['\u2F1A'] = '\u5382';
18647 t['\u2F1B'] = '\u53B6';
18648 t['\u2F1C'] = '\u53C8';
18649 t['\u2F1D'] = '\u53E3';
18650 t['\u2F1E'] = '\u56D7';
18651 t['\u2F1F'] = '\u571F';
18652 t['\u2F20'] = '\u58EB';
18653 t['\u2F21'] = '\u5902';
18654 t['\u2F22'] = '\u590A';
18655 t['\u2F23'] = '\u5915';
18656 t['\u2F24'] = '\u5927';
18657 t['\u2F25'] = '\u5973';
18658 t['\u2F26'] = '\u5B50';
18659 t['\u2F27'] = '\u5B80';
18660 t['\u2F28'] = '\u5BF8';
18661 t['\u2F29'] = '\u5C0F';
18662 t['\u2F2A'] = '\u5C22';
18663 t['\u2F2B'] = '\u5C38';
18664 t['\u2F2C'] = '\u5C6E';
18665 t['\u2F2D'] = '\u5C71';
18666 t['\u2F2E'] = '\u5DDB';
18667 t['\u2F2F'] = '\u5DE5';
18668 t['\u2F30'] = '\u5DF1';
18669 t['\u2F31'] = '\u5DFE';
18670 t['\u2F32'] = '\u5E72';
18671 t['\u2F33'] = '\u5E7A';
18672 t['\u2F34'] = '\u5E7F';
18673 t['\u2F35'] = '\u5EF4';
18674 t['\u2F36'] = '\u5EFE';
18675 t['\u2F37'] = '\u5F0B';
18676 t['\u2F38'] = '\u5F13';
18677 t['\u2F39'] = '\u5F50';
18678 t['\u2F3A'] = '\u5F61';
18679 t['\u2F3B'] = '\u5F73';
18680 t['\u2F3C'] = '\u5FC3';
18681 t['\u2F3D'] = '\u6208';
18682 t['\u2F3E'] = '\u6236';
18683 t['\u2F3F'] = '\u624B';
18684 t['\u2F40'] = '\u652F';
18685 t['\u2F41'] = '\u6534';
18686 t['\u2F42'] = '\u6587';
18687 t['\u2F43'] = '\u6597';
18688 t['\u2F44'] = '\u65A4';
18689 t['\u2F45'] = '\u65B9';
18690 t['\u2F46'] = '\u65E0';
18691 t['\u2F47'] = '\u65E5';
18692 t['\u2F48'] = '\u66F0';
18693 t['\u2F49'] = '\u6708';
18694 t['\u2F4A'] = '\u6728';
18695 t['\u2F4B'] = '\u6B20';
18696 t['\u2F4C'] = '\u6B62';
18697 t['\u2F4D'] = '\u6B79';
18698 t['\u2F4E'] = '\u6BB3';
18699 t['\u2F4F'] = '\u6BCB';
18700 t['\u2F50'] = '\u6BD4';
18701 t['\u2F51'] = '\u6BDB';
18702 t['\u2F52'] = '\u6C0F';
18703 t['\u2F53'] = '\u6C14';
18704 t['\u2F54'] = '\u6C34';
18705 t['\u2F55'] = '\u706B';
18706 t['\u2F56'] = '\u722A';
18707 t['\u2F57'] = '\u7236';
18708 t['\u2F58'] = '\u723B';
18709 t['\u2F59'] = '\u723F';
18710 t['\u2F5A'] = '\u7247';
18711 t['\u2F5B'] = '\u7259';
18712 t['\u2F5C'] = '\u725B';
18713 t['\u2F5D'] = '\u72AC';
18714 t['\u2F5E'] = '\u7384';
18715 t['\u2F5F'] = '\u7389';
18716 t['\u2F60'] = '\u74DC';
18717 t['\u2F61'] = '\u74E6';
18718 t['\u2F62'] = '\u7518';
18719 t['\u2F63'] = '\u751F';
18720 t['\u2F64'] = '\u7528';
18721 t['\u2F65'] = '\u7530';
18722 t['\u2F66'] = '\u758B';
18723 t['\u2F67'] = '\u7592';
18724 t['\u2F68'] = '\u7676';
18725 t['\u2F69'] = '\u767D';
18726 t['\u2F6A'] = '\u76AE';
18727 t['\u2F6B'] = '\u76BF';
18728 t['\u2F6C'] = '\u76EE';
18729 t['\u2F6D'] = '\u77DB';
18730 t['\u2F6E'] = '\u77E2';
18731 t['\u2F6F'] = '\u77F3';
18732 t['\u2F70'] = '\u793A';
18733 t['\u2F71'] = '\u79B8';
18734 t['\u2F72'] = '\u79BE';
18735 t['\u2F73'] = '\u7A74';
18736 t['\u2F74'] = '\u7ACB';
18737 t['\u2F75'] = '\u7AF9';
18738 t['\u2F76'] = '\u7C73';
18739 t['\u2F77'] = '\u7CF8';
18740 t['\u2F78'] = '\u7F36';
18741 t['\u2F79'] = '\u7F51';
18742 t['\u2F7A'] = '\u7F8A';
18743 t['\u2F7B'] = '\u7FBD';
18744 t['\u2F7C'] = '\u8001';
18745 t['\u2F7D'] = '\u800C';
18746 t['\u2F7E'] = '\u8012';
18747 t['\u2F7F'] = '\u8033';
18748 t['\u2F80'] = '\u807F';
18749 t['\u2F81'] = '\u8089';
18750 t['\u2F82'] = '\u81E3';
18751 t['\u2F83'] = '\u81EA';
18752 t['\u2F84'] = '\u81F3';
18753 t['\u2F85'] = '\u81FC';
18754 t['\u2F86'] = '\u820C';
18755 t['\u2F87'] = '\u821B';
18756 t['\u2F88'] = '\u821F';
18757 t['\u2F89'] = '\u826E';
18758 t['\u2F8A'] = '\u8272';
18759 t['\u2F8B'] = '\u8278';
18760 t['\u2F8C'] = '\u864D';
18761 t['\u2F8D'] = '\u866B';
18762 t['\u2F8E'] = '\u8840';
18763 t['\u2F8F'] = '\u884C';
18764 t['\u2F90'] = '\u8863';
18765 t['\u2F91'] = '\u897E';
18766 t['\u2F92'] = '\u898B';
18767 t['\u2F93'] = '\u89D2';
18768 t['\u2F94'] = '\u8A00';
18769 t['\u2F95'] = '\u8C37';
18770 t['\u2F96'] = '\u8C46';
18771 t['\u2F97'] = '\u8C55';
18772 t['\u2F98'] = '\u8C78';
18773 t['\u2F99'] = '\u8C9D';
18774 t['\u2F9A'] = '\u8D64';
18775 t['\u2F9B'] = '\u8D70';
18776 t['\u2F9C'] = '\u8DB3';
18777 t['\u2F9D'] = '\u8EAB';
18778 t['\u2F9E'] = '\u8ECA';
18779 t['\u2F9F'] = '\u8F9B';
18780 t['\u2FA0'] = '\u8FB0';
18781 t['\u2FA1'] = '\u8FB5';
18782 t['\u2FA2'] = '\u9091';
18783 t['\u2FA3'] = '\u9149';
18784 t['\u2FA4'] = '\u91C6';
18785 t['\u2FA5'] = '\u91CC';
18786 t['\u2FA6'] = '\u91D1';
18787 t['\u2FA7'] = '\u9577';
18788 t['\u2FA8'] = '\u9580';
18789 t['\u2FA9'] = '\u961C';
18790 t['\u2FAA'] = '\u96B6';
18791 t['\u2FAB'] = '\u96B9';
18792 t['\u2FAC'] = '\u96E8';
18793 t['\u2FAD'] = '\u9751';
18794 t['\u2FAE'] = '\u975E';
18795 t['\u2FAF'] = '\u9762';
18796 t['\u2FB0'] = '\u9769';
18797 t['\u2FB1'] = '\u97CB';
18798 t['\u2FB2'] = '\u97ED';
18799 t['\u2FB3'] = '\u97F3';
18800 t['\u2FB4'] = '\u9801';
18801 t['\u2FB5'] = '\u98A8';
18802 t['\u2FB6'] = '\u98DB';
18803 t['\u2FB7'] = '\u98DF';
18804 t['\u2FB8'] = '\u9996';
18805 t['\u2FB9'] = '\u9999';
18806 t['\u2FBA'] = '\u99AC';
18807 t['\u2FBB'] = '\u9AA8';
18808 t['\u2FBC'] = '\u9AD8';
18809 t['\u2FBD'] = '\u9ADF';
18810 t['\u2FBE'] = '\u9B25';
18811 t['\u2FBF'] = '\u9B2F';
18812 t['\u2FC0'] = '\u9B32';
18813 t['\u2FC1'] = '\u9B3C';
18814 t['\u2FC2'] = '\u9B5A';
18815 t['\u2FC3'] = '\u9CE5';
18816 t['\u2FC4'] = '\u9E75';
18817 t['\u2FC5'] = '\u9E7F';
18818 t['\u2FC6'] = '\u9EA5';
18819 t['\u2FC7'] = '\u9EBB';
18820 t['\u2FC8'] = '\u9EC3';
18821 t['\u2FC9'] = '\u9ECD';
18822 t['\u2FCA'] = '\u9ED1';
18823 t['\u2FCB'] = '\u9EF9';
18824 t['\u2FCC'] = '\u9EFD';
18825 t['\u2FCD'] = '\u9F0E';
18826 t['\u2FCE'] = '\u9F13';
18827 t['\u2FCF'] = '\u9F20';
18828 t['\u2FD0'] = '\u9F3B';
18829 t['\u2FD1'] = '\u9F4A';
18830 t['\u2FD2'] = '\u9F52';
18831 t['\u2FD3'] = '\u9F8D';
18832 t['\u2FD4'] = '\u9F9C';
18833 t['\u2FD5'] = '\u9FA0';
18834 t['\u3036'] = '\u3012';
18835 t['\u3038'] = '\u5341';
18836 t['\u3039'] = '\u5344';
18837 t['\u303A'] = '\u5345';
18838 t['\u309B'] = '\u0020\u3099';
18839 t['\u309C'] = '\u0020\u309A';
18840 t['\u3131'] = '\u1100';
18841 t['\u3132'] = '\u1101';
18842 t['\u3133'] = '\u11AA';
18843 t['\u3134'] = '\u1102';
18844 t['\u3135'] = '\u11AC';
18845 t['\u3136'] = '\u11AD';
18846 t['\u3137'] = '\u1103';
18847 t['\u3138'] = '\u1104';
18848 t['\u3139'] = '\u1105';
18849 t['\u313A'] = '\u11B0';
18850 t['\u313B'] = '\u11B1';
18851 t['\u313C'] = '\u11B2';
18852 t['\u313D'] = '\u11B3';
18853 t['\u313E'] = '\u11B4';
18854 t['\u313F'] = '\u11B5';
18855 t['\u3140'] = '\u111A';
18856 t['\u3141'] = '\u1106';
18857 t['\u3142'] = '\u1107';
18858 t['\u3143'] = '\u1108';
18859 t['\u3144'] = '\u1121';
18860 t['\u3145'] = '\u1109';
18861 t['\u3146'] = '\u110A';
18862 t['\u3147'] = '\u110B';
18863 t['\u3148'] = '\u110C';
18864 t['\u3149'] = '\u110D';
18865 t['\u314A'] = '\u110E';
18866 t['\u314B'] = '\u110F';
18867 t['\u314C'] = '\u1110';
18868 t['\u314D'] = '\u1111';
18869 t['\u314E'] = '\u1112';
18870 t['\u314F'] = '\u1161';
18871 t['\u3150'] = '\u1162';
18872 t['\u3151'] = '\u1163';
18873 t['\u3152'] = '\u1164';
18874 t['\u3153'] = '\u1165';
18875 t['\u3154'] = '\u1166';
18876 t['\u3155'] = '\u1167';
18877 t['\u3156'] = '\u1168';
18878 t['\u3157'] = '\u1169';
18879 t['\u3158'] = '\u116A';
18880 t['\u3159'] = '\u116B';
18881 t['\u315A'] = '\u116C';
18882 t['\u315B'] = '\u116D';
18883 t['\u315C'] = '\u116E';
18884 t['\u315D'] = '\u116F';
18885 t['\u315E'] = '\u1170';
18886 t['\u315F'] = '\u1171';
18887 t['\u3160'] = '\u1172';
18888 t['\u3161'] = '\u1173';
18889 t['\u3162'] = '\u1174';
18890 t['\u3163'] = '\u1175';
18891 t['\u3164'] = '\u1160';
18892 t['\u3165'] = '\u1114';
18893 t['\u3166'] = '\u1115';
18894 t['\u3167'] = '\u11C7';
18895 t['\u3168'] = '\u11C8';
18896 t['\u3169'] = '\u11CC';
18897 t['\u316A'] = '\u11CE';
18898 t['\u316B'] = '\u11D3';
18899 t['\u316C'] = '\u11D7';
18900 t['\u316D'] = '\u11D9';
18901 t['\u316E'] = '\u111C';
18902 t['\u316F'] = '\u11DD';
18903 t['\u3170'] = '\u11DF';
18904 t['\u3171'] = '\u111D';
18905 t['\u3172'] = '\u111E';
18906 t['\u3173'] = '\u1120';
18907 t['\u3174'] = '\u1122';
18908 t['\u3175'] = '\u1123';
18909 t['\u3176'] = '\u1127';
18910 t['\u3177'] = '\u1129';
18911 t['\u3178'] = '\u112B';
18912 t['\u3179'] = '\u112C';
18913 t['\u317A'] = '\u112D';
18914 t['\u317B'] = '\u112E';
18915 t['\u317C'] = '\u112F';
18916 t['\u317D'] = '\u1132';
18917 t['\u317E'] = '\u1136';
18918 t['\u317F'] = '\u1140';
18919 t['\u3180'] = '\u1147';
18920 t['\u3181'] = '\u114C';
18921 t['\u3182'] = '\u11F1';
18922 t['\u3183'] = '\u11F2';
18923 t['\u3184'] = '\u1157';
18924 t['\u3185'] = '\u1158';
18925 t['\u3186'] = '\u1159';
18926 t['\u3187'] = '\u1184';
18927 t['\u3188'] = '\u1185';
18928 t['\u3189'] = '\u1188';
18929 t['\u318A'] = '\u1191';
18930 t['\u318B'] = '\u1192';
18931 t['\u318C'] = '\u1194';
18932 t['\u318D'] = '\u119E';
18933 t['\u318E'] = '\u11A1';
18934 t['\u3200'] = '\u0028\u1100\u0029';
18935 t['\u3201'] = '\u0028\u1102\u0029';
18936 t['\u3202'] = '\u0028\u1103\u0029';
18937 t['\u3203'] = '\u0028\u1105\u0029';
18938 t['\u3204'] = '\u0028\u1106\u0029';
18939 t['\u3205'] = '\u0028\u1107\u0029';
18940 t['\u3206'] = '\u0028\u1109\u0029';
18941 t['\u3207'] = '\u0028\u110B\u0029';
18942 t['\u3208'] = '\u0028\u110C\u0029';
18943 t['\u3209'] = '\u0028\u110E\u0029';
18944 t['\u320A'] = '\u0028\u110F\u0029';
18945 t['\u320B'] = '\u0028\u1110\u0029';
18946 t['\u320C'] = '\u0028\u1111\u0029';
18947 t['\u320D'] = '\u0028\u1112\u0029';
18948 t['\u320E'] = '\u0028\u1100\u1161\u0029';
18949 t['\u320F'] = '\u0028\u1102\u1161\u0029';
18950 t['\u3210'] = '\u0028\u1103\u1161\u0029';
18951 t['\u3211'] = '\u0028\u1105\u1161\u0029';
18952 t['\u3212'] = '\u0028\u1106\u1161\u0029';
18953 t['\u3213'] = '\u0028\u1107\u1161\u0029';
18954 t['\u3214'] = '\u0028\u1109\u1161\u0029';
18955 t['\u3215'] = '\u0028\u110B\u1161\u0029';
18956 t['\u3216'] = '\u0028\u110C\u1161\u0029';
18957 t['\u3217'] = '\u0028\u110E\u1161\u0029';
18958 t['\u3218'] = '\u0028\u110F\u1161\u0029';
18959 t['\u3219'] = '\u0028\u1110\u1161\u0029';
18960 t['\u321A'] = '\u0028\u1111\u1161\u0029';
18961 t['\u321B'] = '\u0028\u1112\u1161\u0029';
18962 t['\u321C'] = '\u0028\u110C\u116E\u0029';
18963 t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
18964 t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
18965 t['\u3220'] = '\u0028\u4E00\u0029';
18966 t['\u3221'] = '\u0028\u4E8C\u0029';
18967 t['\u3222'] = '\u0028\u4E09\u0029';
18968 t['\u3223'] = '\u0028\u56DB\u0029';
18969 t['\u3224'] = '\u0028\u4E94\u0029';
18970 t['\u3225'] = '\u0028\u516D\u0029';
18971 t['\u3226'] = '\u0028\u4E03\u0029';
18972 t['\u3227'] = '\u0028\u516B\u0029';
18973 t['\u3228'] = '\u0028\u4E5D\u0029';
18974 t['\u3229'] = '\u0028\u5341\u0029';
18975 t['\u322A'] = '\u0028\u6708\u0029';
18976 t['\u322B'] = '\u0028\u706B\u0029';
18977 t['\u322C'] = '\u0028\u6C34\u0029';
18978 t['\u322D'] = '\u0028\u6728\u0029';
18979 t['\u322E'] = '\u0028\u91D1\u0029';
18980 t['\u322F'] = '\u0028\u571F\u0029';
18981 t['\u3230'] = '\u0028\u65E5\u0029';
18982 t['\u3231'] = '\u0028\u682A\u0029';
18983 t['\u3232'] = '\u0028\u6709\u0029';
18984 t['\u3233'] = '\u0028\u793E\u0029';
18985 t['\u3234'] = '\u0028\u540D\u0029';
18986 t['\u3235'] = '\u0028\u7279\u0029';
18987 t['\u3236'] = '\u0028\u8CA1\u0029';
18988 t['\u3237'] = '\u0028\u795D\u0029';
18989 t['\u3238'] = '\u0028\u52B4\u0029';
18990 t['\u3239'] = '\u0028\u4EE3\u0029';
18991 t['\u323A'] = '\u0028\u547C\u0029';
18992 t['\u323B'] = '\u0028\u5B66\u0029';
18993 t['\u323C'] = '\u0028\u76E3\u0029';
18994 t['\u323D'] = '\u0028\u4F01\u0029';
18995 t['\u323E'] = '\u0028\u8CC7\u0029';
18996 t['\u323F'] = '\u0028\u5354\u0029';
18997 t['\u3240'] = '\u0028\u796D\u0029';
18998 t['\u3241'] = '\u0028\u4F11\u0029';
18999 t['\u3242'] = '\u0028\u81EA\u0029';
19000 t['\u3243'] = '\u0028\u81F3\u0029';
19001 t['\u32C0'] = '\u0031\u6708';
19002 t['\u32C1'] = '\u0032\u6708';
19003 t['\u32C2'] = '\u0033\u6708';
19004 t['\u32C3'] = '\u0034\u6708';
19005 t['\u32C4'] = '\u0035\u6708';
19006 t['\u32C5'] = '\u0036\u6708';
19007 t['\u32C6'] = '\u0037\u6708';
19008 t['\u32C7'] = '\u0038\u6708';
19009 t['\u32C8'] = '\u0039\u6708';
19010 t['\u32C9'] = '\u0031\u0030\u6708';
19011 t['\u32CA'] = '\u0031\u0031\u6708';
19012 t['\u32CB'] = '\u0031\u0032\u6708';
19013 t['\u3358'] = '\u0030\u70B9';
19014 t['\u3359'] = '\u0031\u70B9';
19015 t['\u335A'] = '\u0032\u70B9';
19016 t['\u335B'] = '\u0033\u70B9';
19017 t['\u335C'] = '\u0034\u70B9';
19018 t['\u335D'] = '\u0035\u70B9';
19019 t['\u335E'] = '\u0036\u70B9';
19020 t['\u335F'] = '\u0037\u70B9';
19021 t['\u3360'] = '\u0038\u70B9';
19022 t['\u3361'] = '\u0039\u70B9';
19023 t['\u3362'] = '\u0031\u0030\u70B9';
19024 t['\u3363'] = '\u0031\u0031\u70B9';
19025 t['\u3364'] = '\u0031\u0032\u70B9';
19026 t['\u3365'] = '\u0031\u0033\u70B9';
19027 t['\u3366'] = '\u0031\u0034\u70B9';
19028 t['\u3367'] = '\u0031\u0035\u70B9';
19029 t['\u3368'] = '\u0031\u0036\u70B9';
19030 t['\u3369'] = '\u0031\u0037\u70B9';
19031 t['\u336A'] = '\u0031\u0038\u70B9';
19032 t['\u336B'] = '\u0031\u0039\u70B9';
19033 t['\u336C'] = '\u0032\u0030\u70B9';
19034 t['\u336D'] = '\u0032\u0031\u70B9';
19035 t['\u336E'] = '\u0032\u0032\u70B9';
19036 t['\u336F'] = '\u0032\u0033\u70B9';
19037 t['\u3370'] = '\u0032\u0034\u70B9';
19038 t['\u33E0'] = '\u0031\u65E5';
19039 t['\u33E1'] = '\u0032\u65E5';
19040 t['\u33E2'] = '\u0033\u65E5';
19041 t['\u33E3'] = '\u0034\u65E5';
19042 t['\u33E4'] = '\u0035\u65E5';
19043 t['\u33E5'] = '\u0036\u65E5';
19044 t['\u33E6'] = '\u0037\u65E5';
19045 t['\u33E7'] = '\u0038\u65E5';
19046 t['\u33E8'] = '\u0039\u65E5';
19047 t['\u33E9'] = '\u0031\u0030\u65E5';
19048 t['\u33EA'] = '\u0031\u0031\u65E5';
19049 t['\u33EB'] = '\u0031\u0032\u65E5';
19050 t['\u33EC'] = '\u0031\u0033\u65E5';
19051 t['\u33ED'] = '\u0031\u0034\u65E5';
19052 t['\u33EE'] = '\u0031\u0035\u65E5';
19053 t['\u33EF'] = '\u0031\u0036\u65E5';
19054 t['\u33F0'] = '\u0031\u0037\u65E5';
19055 t['\u33F1'] = '\u0031\u0038\u65E5';
19056 t['\u33F2'] = '\u0031\u0039\u65E5';
19057 t['\u33F3'] = '\u0032\u0030\u65E5';
19058 t['\u33F4'] = '\u0032\u0031\u65E5';
19059 t['\u33F5'] = '\u0032\u0032\u65E5';
19060 t['\u33F6'] = '\u0032\u0033\u65E5';
19061 t['\u33F7'] = '\u0032\u0034\u65E5';
19062 t['\u33F8'] = '\u0032\u0035\u65E5';
19063 t['\u33F9'] = '\u0032\u0036\u65E5';
19064 t['\u33FA'] = '\u0032\u0037\u65E5';
19065 t['\u33FB'] = '\u0032\u0038\u65E5';
19066 t['\u33FC'] = '\u0032\u0039\u65E5';
19067 t['\u33FD'] = '\u0033\u0030\u65E5';
19068 t['\u33FE'] = '\u0033\u0031\u65E5';
19069 t['\uFB00'] = '\u0066\u0066';
19070 t['\uFB01'] = '\u0066\u0069';
19071 t['\uFB02'] = '\u0066\u006C';
19072 t['\uFB03'] = '\u0066\u0066\u0069';
19073 t['\uFB04'] = '\u0066\u0066\u006C';
19074 t['\uFB05'] = '\u017F\u0074';
19075 t['\uFB06'] = '\u0073\u0074';
19076 t['\uFB13'] = '\u0574\u0576';
19077 t['\uFB14'] = '\u0574\u0565';
19078 t['\uFB15'] = '\u0574\u056B';
19079 t['\uFB16'] = '\u057E\u0576';
19080 t['\uFB17'] = '\u0574\u056D';
19081 t['\uFB4F'] = '\u05D0\u05DC';
19082 t['\uFB50'] = '\u0671';
19083 t['\uFB51'] = '\u0671';
19084 t['\uFB52'] = '\u067B';
19085 t['\uFB53'] = '\u067B';
19086 t['\uFB54'] = '\u067B';
19087 t['\uFB55'] = '\u067B';
19088 t['\uFB56'] = '\u067E';
19089 t['\uFB57'] = '\u067E';
19090 t['\uFB58'] = '\u067E';
19091 t['\uFB59'] = '\u067E';
19092 t['\uFB5A'] = '\u0680';
19093 t['\uFB5B'] = '\u0680';
19094 t['\uFB5C'] = '\u0680';
19095 t['\uFB5D'] = '\u0680';
19096 t['\uFB5E'] = '\u067A';
19097 t['\uFB5F'] = '\u067A';
19098 t['\uFB60'] = '\u067A';
19099 t['\uFB61'] = '\u067A';
19100 t['\uFB62'] = '\u067F';
19101 t['\uFB63'] = '\u067F';
19102 t['\uFB64'] = '\u067F';
19103 t['\uFB65'] = '\u067F';
19104 t['\uFB66'] = '\u0679';
19105 t['\uFB67'] = '\u0679';
19106 t['\uFB68'] = '\u0679';
19107 t['\uFB69'] = '\u0679';
19108 t['\uFB6A'] = '\u06A4';
19109 t['\uFB6B'] = '\u06A4';
19110 t['\uFB6C'] = '\u06A4';
19111 t['\uFB6D'] = '\u06A4';
19112 t['\uFB6E'] = '\u06A6';
19113 t['\uFB6F'] = '\u06A6';
19114 t['\uFB70'] = '\u06A6';
19115 t['\uFB71'] = '\u06A6';
19116 t['\uFB72'] = '\u0684';
19117 t['\uFB73'] = '\u0684';
19118 t['\uFB74'] = '\u0684';
19119 t['\uFB75'] = '\u0684';
19120 t['\uFB76'] = '\u0683';
19121 t['\uFB77'] = '\u0683';
19122 t['\uFB78'] = '\u0683';
19123 t['\uFB79'] = '\u0683';
19124 t['\uFB7A'] = '\u0686';
19125 t['\uFB7B'] = '\u0686';
19126 t['\uFB7C'] = '\u0686';
19127 t['\uFB7D'] = '\u0686';
19128 t['\uFB7E'] = '\u0687';
19129 t['\uFB7F'] = '\u0687';
19130 t['\uFB80'] = '\u0687';
19131 t['\uFB81'] = '\u0687';
19132 t['\uFB82'] = '\u068D';
19133 t['\uFB83'] = '\u068D';
19134 t['\uFB84'] = '\u068C';
19135 t['\uFB85'] = '\u068C';
19136 t['\uFB86'] = '\u068E';
19137 t['\uFB87'] = '\u068E';
19138 t['\uFB88'] = '\u0688';
19139 t['\uFB89'] = '\u0688';
19140 t['\uFB8A'] = '\u0698';
19141 t['\uFB8B'] = '\u0698';
19142 t['\uFB8C'] = '\u0691';
19143 t['\uFB8D'] = '\u0691';
19144 t['\uFB8E'] = '\u06A9';
19145 t['\uFB8F'] = '\u06A9';
19146 t['\uFB90'] = '\u06A9';
19147 t['\uFB91'] = '\u06A9';
19148 t['\uFB92'] = '\u06AF';
19149 t['\uFB93'] = '\u06AF';
19150 t['\uFB94'] = '\u06AF';
19151 t['\uFB95'] = '\u06AF';
19152 t['\uFB96'] = '\u06B3';
19153 t['\uFB97'] = '\u06B3';
19154 t['\uFB98'] = '\u06B3';
19155 t['\uFB99'] = '\u06B3';
19156 t['\uFB9A'] = '\u06B1';
19157 t['\uFB9B'] = '\u06B1';
19158 t['\uFB9C'] = '\u06B1';
19159 t['\uFB9D'] = '\u06B1';
19160 t['\uFB9E'] = '\u06BA';
19161 t['\uFB9F'] = '\u06BA';
19162 t['\uFBA0'] = '\u06BB';
19163 t['\uFBA1'] = '\u06BB';
19164 t['\uFBA2'] = '\u06BB';
19165 t['\uFBA3'] = '\u06BB';
19166 t['\uFBA4'] = '\u06C0';
19167 t['\uFBA5'] = '\u06C0';
19168 t['\uFBA6'] = '\u06C1';
19169 t['\uFBA7'] = '\u06C1';
19170 t['\uFBA8'] = '\u06C1';
19171 t['\uFBA9'] = '\u06C1';
19172 t['\uFBAA'] = '\u06BE';
19173 t['\uFBAB'] = '\u06BE';
19174 t['\uFBAC'] = '\u06BE';
19175 t['\uFBAD'] = '\u06BE';
19176 t['\uFBAE'] = '\u06D2';
19177 t['\uFBAF'] = '\u06D2';
19178 t['\uFBB0'] = '\u06D3';
19179 t['\uFBB1'] = '\u06D3';
19180 t['\uFBD3'] = '\u06AD';
19181 t['\uFBD4'] = '\u06AD';
19182 t['\uFBD5'] = '\u06AD';
19183 t['\uFBD6'] = '\u06AD';
19184 t['\uFBD7'] = '\u06C7';
19185 t['\uFBD8'] = '\u06C7';
19186 t['\uFBD9'] = '\u06C6';
19187 t['\uFBDA'] = '\u06C6';
19188 t['\uFBDB'] = '\u06C8';
19189 t['\uFBDC'] = '\u06C8';
19190 t['\uFBDD'] = '\u0677';
19191 t['\uFBDE'] = '\u06CB';
19192 t['\uFBDF'] = '\u06CB';
19193 t['\uFBE0'] = '\u06C5';
19194 t['\uFBE1'] = '\u06C5';
19195 t['\uFBE2'] = '\u06C9';
19196 t['\uFBE3'] = '\u06C9';
19197 t['\uFBE4'] = '\u06D0';
19198 t['\uFBE5'] = '\u06D0';
19199 t['\uFBE6'] = '\u06D0';
19200 t['\uFBE7'] = '\u06D0';
19201 t['\uFBE8'] = '\u0649';
19202 t['\uFBE9'] = '\u0649';
19203 t['\uFBEA'] = '\u0626\u0627';
19204 t['\uFBEB'] = '\u0626\u0627';
19205 t['\uFBEC'] = '\u0626\u06D5';
19206 t['\uFBED'] = '\u0626\u06D5';
19207 t['\uFBEE'] = '\u0626\u0648';
19208 t['\uFBEF'] = '\u0626\u0648';
19209 t['\uFBF0'] = '\u0626\u06C7';
19210 t['\uFBF1'] = '\u0626\u06C7';
19211 t['\uFBF2'] = '\u0626\u06C6';
19212 t['\uFBF3'] = '\u0626\u06C6';
19213 t['\uFBF4'] = '\u0626\u06C8';
19214 t['\uFBF5'] = '\u0626\u06C8';
19215 t['\uFBF6'] = '\u0626\u06D0';
19216 t['\uFBF7'] = '\u0626\u06D0';
19217 t['\uFBF8'] = '\u0626\u06D0';
19218 t['\uFBF9'] = '\u0626\u0649';
19219 t['\uFBFA'] = '\u0626\u0649';
19220 t['\uFBFB'] = '\u0626\u0649';
19221 t['\uFBFC'] = '\u06CC';
19222 t['\uFBFD'] = '\u06CC';
19223 t['\uFBFE'] = '\u06CC';
19224 t['\uFBFF'] = '\u06CC';
19225 t['\uFC00'] = '\u0626\u062C';
19226 t['\uFC01'] = '\u0626\u062D';
19227 t['\uFC02'] = '\u0626\u0645';
19228 t['\uFC03'] = '\u0626\u0649';
19229 t['\uFC04'] = '\u0626\u064A';
19230 t['\uFC05'] = '\u0628\u062C';
19231 t['\uFC06'] = '\u0628\u062D';
19232 t['\uFC07'] = '\u0628\u062E';
19233 t['\uFC08'] = '\u0628\u0645';
19234 t['\uFC09'] = '\u0628\u0649';
19235 t['\uFC0A'] = '\u0628\u064A';
19236 t['\uFC0B'] = '\u062A\u062C';
19237 t['\uFC0C'] = '\u062A\u062D';
19238 t['\uFC0D'] = '\u062A\u062E';
19239 t['\uFC0E'] = '\u062A\u0645';
19240 t['\uFC0F'] = '\u062A\u0649';
19241 t['\uFC10'] = '\u062A\u064A';
19242 t['\uFC11'] = '\u062B\u062C';
19243 t['\uFC12'] = '\u062B\u0645';
19244 t['\uFC13'] = '\u062B\u0649';
19245 t['\uFC14'] = '\u062B\u064A';
19246 t['\uFC15'] = '\u062C\u062D';
19247 t['\uFC16'] = '\u062C\u0645';
19248 t['\uFC17'] = '\u062D\u062C';
19249 t['\uFC18'] = '\u062D\u0645';
19250 t['\uFC19'] = '\u062E\u062C';
19251 t['\uFC1A'] = '\u062E\u062D';
19252 t['\uFC1B'] = '\u062E\u0645';
19253 t['\uFC1C'] = '\u0633\u062C';
19254 t['\uFC1D'] = '\u0633\u062D';
19255 t['\uFC1E'] = '\u0633\u062E';
19256 t['\uFC1F'] = '\u0633\u0645';
19257 t['\uFC20'] = '\u0635\u062D';
19258 t['\uFC21'] = '\u0635\u0645';
19259 t['\uFC22'] = '\u0636\u062C';
19260 t['\uFC23'] = '\u0636\u062D';
19261 t['\uFC24'] = '\u0636\u062E';
19262 t['\uFC25'] = '\u0636\u0645';
19263 t['\uFC26'] = '\u0637\u062D';
19264 t['\uFC27'] = '\u0637\u0645';
19265 t['\uFC28'] = '\u0638\u0645';
19266 t['\uFC29'] = '\u0639\u062C';
19267 t['\uFC2A'] = '\u0639\u0645';
19268 t['\uFC2B'] = '\u063A\u062C';
19269 t['\uFC2C'] = '\u063A\u0645';
19270 t['\uFC2D'] = '\u0641\u062C';
19271 t['\uFC2E'] = '\u0641\u062D';
19272 t['\uFC2F'] = '\u0641\u062E';
19273 t['\uFC30'] = '\u0641\u0645';
19274 t['\uFC31'] = '\u0641\u0649';
19275 t['\uFC32'] = '\u0641\u064A';
19276 t['\uFC33'] = '\u0642\u062D';
19277 t['\uFC34'] = '\u0642\u0645';
19278 t['\uFC35'] = '\u0642\u0649';
19279 t['\uFC36'] = '\u0642\u064A';
19280 t['\uFC37'] = '\u0643\u0627';
19281 t['\uFC38'] = '\u0643\u062C';
19282 t['\uFC39'] = '\u0643\u062D';
19283 t['\uFC3A'] = '\u0643\u062E';
19284 t['\uFC3B'] = '\u0643\u0644';
19285 t['\uFC3C'] = '\u0643\u0645';
19286 t['\uFC3D'] = '\u0643\u0649';
19287 t['\uFC3E'] = '\u0643\u064A';
19288 t['\uFC3F'] = '\u0644\u062C';
19289 t['\uFC40'] = '\u0644\u062D';
19290 t['\uFC41'] = '\u0644\u062E';
19291 t['\uFC42'] = '\u0644\u0645';
19292 t['\uFC43'] = '\u0644\u0649';
19293 t['\uFC44'] = '\u0644\u064A';
19294 t['\uFC45'] = '\u0645\u062C';
19295 t['\uFC46'] = '\u0645\u062D';
19296 t['\uFC47'] = '\u0645\u062E';
19297 t['\uFC48'] = '\u0645\u0645';
19298 t['\uFC49'] = '\u0645\u0649';
19299 t['\uFC4A'] = '\u0645\u064A';
19300 t['\uFC4B'] = '\u0646\u062C';
19301 t['\uFC4C'] = '\u0646\u062D';
19302 t['\uFC4D'] = '\u0646\u062E';
19303 t['\uFC4E'] = '\u0646\u0645';
19304 t['\uFC4F'] = '\u0646\u0649';
19305 t['\uFC50'] = '\u0646\u064A';
19306 t['\uFC51'] = '\u0647\u062C';
19307 t['\uFC52'] = '\u0647\u0645';
19308 t['\uFC53'] = '\u0647\u0649';
19309 t['\uFC54'] = '\u0647\u064A';
19310 t['\uFC55'] = '\u064A\u062C';
19311 t['\uFC56'] = '\u064A\u062D';
19312 t['\uFC57'] = '\u064A\u062E';
19313 t['\uFC58'] = '\u064A\u0645';
19314 t['\uFC59'] = '\u064A\u0649';
19315 t['\uFC5A'] = '\u064A\u064A';
19316 t['\uFC5B'] = '\u0630\u0670';
19317 t['\uFC5C'] = '\u0631\u0670';
19318 t['\uFC5D'] = '\u0649\u0670';
19319 t['\uFC5E'] = '\u0020\u064C\u0651';
19320 t['\uFC5F'] = '\u0020\u064D\u0651';
19321 t['\uFC60'] = '\u0020\u064E\u0651';
19322 t['\uFC61'] = '\u0020\u064F\u0651';
19323 t['\uFC62'] = '\u0020\u0650\u0651';
19324 t['\uFC63'] = '\u0020\u0651\u0670';
19325 t['\uFC64'] = '\u0626\u0631';
19326 t['\uFC65'] = '\u0626\u0632';
19327 t['\uFC66'] = '\u0626\u0645';
19328 t['\uFC67'] = '\u0626\u0646';
19329 t['\uFC68'] = '\u0626\u0649';
19330 t['\uFC69'] = '\u0626\u064A';
19331 t['\uFC6A'] = '\u0628\u0631';
19332 t['\uFC6B'] = '\u0628\u0632';
19333 t['\uFC6C'] = '\u0628\u0645';
19334 t['\uFC6D'] = '\u0628\u0646';
19335 t['\uFC6E'] = '\u0628\u0649';
19336 t['\uFC6F'] = '\u0628\u064A';
19337 t['\uFC70'] = '\u062A\u0631';
19338 t['\uFC71'] = '\u062A\u0632';
19339 t['\uFC72'] = '\u062A\u0645';
19340 t['\uFC73'] = '\u062A\u0646';
19341 t['\uFC74'] = '\u062A\u0649';
19342 t['\uFC75'] = '\u062A\u064A';
19343 t['\uFC76'] = '\u062B\u0631';
19344 t['\uFC77'] = '\u062B\u0632';
19345 t['\uFC78'] = '\u062B\u0645';
19346 t['\uFC79'] = '\u062B\u0646';
19347 t['\uFC7A'] = '\u062B\u0649';
19348 t['\uFC7B'] = '\u062B\u064A';
19349 t['\uFC7C'] = '\u0641\u0649';
19350 t['\uFC7D'] = '\u0641\u064A';
19351 t['\uFC7E'] = '\u0642\u0649';
19352 t['\uFC7F'] = '\u0642\u064A';
19353 t['\uFC80'] = '\u0643\u0627';
19354 t['\uFC81'] = '\u0643\u0644';
19355 t['\uFC82'] = '\u0643\u0645';
19356 t['\uFC83'] = '\u0643\u0649';
19357 t['\uFC84'] = '\u0643\u064A';
19358 t['\uFC85'] = '\u0644\u0645';
19359 t['\uFC86'] = '\u0644\u0649';
19360 t['\uFC87'] = '\u0644\u064A';
19361 t['\uFC88'] = '\u0645\u0627';
19362 t['\uFC89'] = '\u0645\u0645';
19363 t['\uFC8A'] = '\u0646\u0631';
19364 t['\uFC8B'] = '\u0646\u0632';
19365 t['\uFC8C'] = '\u0646\u0645';
19366 t['\uFC8D'] = '\u0646\u0646';
19367 t['\uFC8E'] = '\u0646\u0649';
19368 t['\uFC8F'] = '\u0646\u064A';
19369 t['\uFC90'] = '\u0649\u0670';
19370 t['\uFC91'] = '\u064A\u0631';
19371 t['\uFC92'] = '\u064A\u0632';
19372 t['\uFC93'] = '\u064A\u0645';
19373 t['\uFC94'] = '\u064A\u0646';
19374 t['\uFC95'] = '\u064A\u0649';
19375 t['\uFC96'] = '\u064A\u064A';
19376 t['\uFC97'] = '\u0626\u062C';
19377 t['\uFC98'] = '\u0626\u062D';
19378 t['\uFC99'] = '\u0626\u062E';
19379 t['\uFC9A'] = '\u0626\u0645';
19380 t['\uFC9B'] = '\u0626\u0647';
19381 t['\uFC9C'] = '\u0628\u062C';
19382 t['\uFC9D'] = '\u0628\u062D';
19383 t['\uFC9E'] = '\u0628\u062E';
19384 t['\uFC9F'] = '\u0628\u0645';
19385 t['\uFCA0'] = '\u0628\u0647';
19386 t['\uFCA1'] = '\u062A\u062C';
19387 t['\uFCA2'] = '\u062A\u062D';
19388 t['\uFCA3'] = '\u062A\u062E';
19389 t['\uFCA4'] = '\u062A\u0645';
19390 t['\uFCA5'] = '\u062A\u0647';
19391 t['\uFCA6'] = '\u062B\u0645';
19392 t['\uFCA7'] = '\u062C\u062D';
19393 t['\uFCA8'] = '\u062C\u0645';
19394 t['\uFCA9'] = '\u062D\u062C';
19395 t['\uFCAA'] = '\u062D\u0645';
19396 t['\uFCAB'] = '\u062E\u062C';
19397 t['\uFCAC'] = '\u062E\u0645';
19398 t['\uFCAD'] = '\u0633\u062C';
19399 t['\uFCAE'] = '\u0633\u062D';
19400 t['\uFCAF'] = '\u0633\u062E';
19401 t['\uFCB0'] = '\u0633\u0645';
19402 t['\uFCB1'] = '\u0635\u062D';
19403 t['\uFCB2'] = '\u0635\u062E';
19404 t['\uFCB3'] = '\u0635\u0645';
19405 t['\uFCB4'] = '\u0636\u062C';
19406 t['\uFCB5'] = '\u0636\u062D';
19407 t['\uFCB6'] = '\u0636\u062E';
19408 t['\uFCB7'] = '\u0636\u0645';
19409 t['\uFCB8'] = '\u0637\u062D';
19410 t['\uFCB9'] = '\u0638\u0645';
19411 t['\uFCBA'] = '\u0639\u062C';
19412 t['\uFCBB'] = '\u0639\u0645';
19413 t['\uFCBC'] = '\u063A\u062C';
19414 t['\uFCBD'] = '\u063A\u0645';
19415 t['\uFCBE'] = '\u0641\u062C';
19416 t['\uFCBF'] = '\u0641\u062D';
19417 t['\uFCC0'] = '\u0641\u062E';
19418 t['\uFCC1'] = '\u0641\u0645';
19419 t['\uFCC2'] = '\u0642\u062D';
19420 t['\uFCC3'] = '\u0642\u0645';
19421 t['\uFCC4'] = '\u0643\u062C';
19422 t['\uFCC5'] = '\u0643\u062D';
19423 t['\uFCC6'] = '\u0643\u062E';
19424 t['\uFCC7'] = '\u0643\u0644';
19425 t['\uFCC8'] = '\u0643\u0645';
19426 t['\uFCC9'] = '\u0644\u062C';
19427 t['\uFCCA'] = '\u0644\u062D';
19428 t['\uFCCB'] = '\u0644\u062E';
19429 t['\uFCCC'] = '\u0644\u0645';
19430 t['\uFCCD'] = '\u0644\u0647';
19431 t['\uFCCE'] = '\u0645\u062C';
19432 t['\uFCCF'] = '\u0645\u062D';
19433 t['\uFCD0'] = '\u0645\u062E';
19434 t['\uFCD1'] = '\u0645\u0645';
19435 t['\uFCD2'] = '\u0646\u062C';
19436 t['\uFCD3'] = '\u0646\u062D';
19437 t['\uFCD4'] = '\u0646\u062E';
19438 t['\uFCD5'] = '\u0646\u0645';
19439 t['\uFCD6'] = '\u0646\u0647';
19440 t['\uFCD7'] = '\u0647\u062C';
19441 t['\uFCD8'] = '\u0647\u0645';
19442 t['\uFCD9'] = '\u0647\u0670';
19443 t['\uFCDA'] = '\u064A\u062C';
19444 t['\uFCDB'] = '\u064A\u062D';
19445 t['\uFCDC'] = '\u064A\u062E';
19446 t['\uFCDD'] = '\u064A\u0645';
19447 t['\uFCDE'] = '\u064A\u0647';
19448 t['\uFCDF'] = '\u0626\u0645';
19449 t['\uFCE0'] = '\u0626\u0647';
19450 t['\uFCE1'] = '\u0628\u0645';
19451 t['\uFCE2'] = '\u0628\u0647';
19452 t['\uFCE3'] = '\u062A\u0645';
19453 t['\uFCE4'] = '\u062A\u0647';
19454 t['\uFCE5'] = '\u062B\u0645';
19455 t['\uFCE6'] = '\u062B\u0647';
19456 t['\uFCE7'] = '\u0633\u0645';
19457 t['\uFCE8'] = '\u0633\u0647';
19458 t['\uFCE9'] = '\u0634\u0645';
19459 t['\uFCEA'] = '\u0634\u0647';
19460 t['\uFCEB'] = '\u0643\u0644';
19461 t['\uFCEC'] = '\u0643\u0645';
19462 t['\uFCED'] = '\u0644\u0645';
19463 t['\uFCEE'] = '\u0646\u0645';
19464 t['\uFCEF'] = '\u0646\u0647';
19465 t['\uFCF0'] = '\u064A\u0645';
19466 t['\uFCF1'] = '\u064A\u0647';
19467 t['\uFCF2'] = '\u0640\u064E\u0651';
19468 t['\uFCF3'] = '\u0640\u064F\u0651';
19469 t['\uFCF4'] = '\u0640\u0650\u0651';
19470 t['\uFCF5'] = '\u0637\u0649';
19471 t['\uFCF6'] = '\u0637\u064A';
19472 t['\uFCF7'] = '\u0639\u0649';
19473 t['\uFCF8'] = '\u0639\u064A';
19474 t['\uFCF9'] = '\u063A\u0649';
19475 t['\uFCFA'] = '\u063A\u064A';
19476 t['\uFCFB'] = '\u0633\u0649';
19477 t['\uFCFC'] = '\u0633\u064A';
19478 t['\uFCFD'] = '\u0634\u0649';
19479 t['\uFCFE'] = '\u0634\u064A';
19480 t['\uFCFF'] = '\u062D\u0649';
19481 t['\uFD00'] = '\u062D\u064A';
19482 t['\uFD01'] = '\u062C\u0649';
19483 t['\uFD02'] = '\u062C\u064A';
19484 t['\uFD03'] = '\u062E\u0649';
19485 t['\uFD04'] = '\u062E\u064A';
19486 t['\uFD05'] = '\u0635\u0649';
19487 t['\uFD06'] = '\u0635\u064A';
19488 t['\uFD07'] = '\u0636\u0649';
19489 t['\uFD08'] = '\u0636\u064A';
19490 t['\uFD09'] = '\u0634\u062C';
19491 t['\uFD0A'] = '\u0634\u062D';
19492 t['\uFD0B'] = '\u0634\u062E';
19493 t['\uFD0C'] = '\u0634\u0645';
19494 t['\uFD0D'] = '\u0634\u0631';
19495 t['\uFD0E'] = '\u0633\u0631';
19496 t['\uFD0F'] = '\u0635\u0631';
19497 t['\uFD10'] = '\u0636\u0631';
19498 t['\uFD11'] = '\u0637\u0649';
19499 t['\uFD12'] = '\u0637\u064A';
19500 t['\uFD13'] = '\u0639\u0649';
19501 t['\uFD14'] = '\u0639\u064A';
19502 t['\uFD15'] = '\u063A\u0649';
19503 t['\uFD16'] = '\u063A\u064A';
19504 t['\uFD17'] = '\u0633\u0649';
19505 t['\uFD18'] = '\u0633\u064A';
19506 t['\uFD19'] = '\u0634\u0649';
19507 t['\uFD1A'] = '\u0634\u064A';
19508 t['\uFD1B'] = '\u062D\u0649';
19509 t['\uFD1C'] = '\u062D\u064A';
19510 t['\uFD1D'] = '\u062C\u0649';
19511 t['\uFD1E'] = '\u062C\u064A';
19512 t['\uFD1F'] = '\u062E\u0649';
19513 t['\uFD20'] = '\u062E\u064A';
19514 t['\uFD21'] = '\u0635\u0649';
19515 t['\uFD22'] = '\u0635\u064A';
19516 t['\uFD23'] = '\u0636\u0649';
19517 t['\uFD24'] = '\u0636\u064A';
19518 t['\uFD25'] = '\u0634\u062C';
19519 t['\uFD26'] = '\u0634\u062D';
19520 t['\uFD27'] = '\u0634\u062E';
19521 t['\uFD28'] = '\u0634\u0645';
19522 t['\uFD29'] = '\u0634\u0631';
19523 t['\uFD2A'] = '\u0633\u0631';
19524 t['\uFD2B'] = '\u0635\u0631';
19525 t['\uFD2C'] = '\u0636\u0631';
19526 t['\uFD2D'] = '\u0634\u062C';
19527 t['\uFD2E'] = '\u0634\u062D';
19528 t['\uFD2F'] = '\u0634\u062E';
19529 t['\uFD30'] = '\u0634\u0645';
19530 t['\uFD31'] = '\u0633\u0647';
19531 t['\uFD32'] = '\u0634\u0647';
19532 t['\uFD33'] = '\u0637\u0645';
19533 t['\uFD34'] = '\u0633\u062C';
19534 t['\uFD35'] = '\u0633\u062D';
19535 t['\uFD36'] = '\u0633\u062E';
19536 t['\uFD37'] = '\u0634\u062C';
19537 t['\uFD38'] = '\u0634\u062D';
19538 t['\uFD39'] = '\u0634\u062E';
19539 t['\uFD3A'] = '\u0637\u0645';
19540 t['\uFD3B'] = '\u0638\u0645';
19541 t['\uFD3C'] = '\u0627\u064B';
19542 t['\uFD3D'] = '\u0627\u064B';
19543 t['\uFD50'] = '\u062A\u062C\u0645';
19544 t['\uFD51'] = '\u062A\u062D\u062C';
19545 t['\uFD52'] = '\u062A\u062D\u062C';
19546 t['\uFD53'] = '\u062A\u062D\u0645';
19547 t['\uFD54'] = '\u062A\u062E\u0645';
19548 t['\uFD55'] = '\u062A\u0645\u062C';
19549 t['\uFD56'] = '\u062A\u0645\u062D';
19550 t['\uFD57'] = '\u062A\u0645\u062E';
19551 t['\uFD58'] = '\u062C\u0645\u062D';
19552 t['\uFD59'] = '\u062C\u0645\u062D';
19553 t['\uFD5A'] = '\u062D\u0645\u064A';
19554 t['\uFD5B'] = '\u062D\u0645\u0649';
19555 t['\uFD5C'] = '\u0633\u062D\u062C';
19556 t['\uFD5D'] = '\u0633\u062C\u062D';
19557 t['\uFD5E'] = '\u0633\u062C\u0649';
19558 t['\uFD5F'] = '\u0633\u0645\u062D';
19559 t['\uFD60'] = '\u0633\u0645\u062D';
19560 t['\uFD61'] = '\u0633\u0645\u062C';
19561 t['\uFD62'] = '\u0633\u0645\u0645';
19562 t['\uFD63'] = '\u0633\u0645\u0645';
19563 t['\uFD64'] = '\u0635\u062D\u062D';
19564 t['\uFD65'] = '\u0635\u062D\u062D';
19565 t['\uFD66'] = '\u0635\u0645\u0645';
19566 t['\uFD67'] = '\u0634\u062D\u0645';
19567 t['\uFD68'] = '\u0634\u062D\u0645';
19568 t['\uFD69'] = '\u0634\u062C\u064A';
19569 t['\uFD6A'] = '\u0634\u0645\u062E';
19570 t['\uFD6B'] = '\u0634\u0645\u062E';
19571 t['\uFD6C'] = '\u0634\u0645\u0645';
19572 t['\uFD6D'] = '\u0634\u0645\u0645';
19573 t['\uFD6E'] = '\u0636\u062D\u0649';
19574 t['\uFD6F'] = '\u0636\u062E\u0645';
19575 t['\uFD70'] = '\u0636\u062E\u0645';
19576 t['\uFD71'] = '\u0637\u0645\u062D';
19577 t['\uFD72'] = '\u0637\u0645\u062D';
19578 t['\uFD73'] = '\u0637\u0645\u0645';
19579 t['\uFD74'] = '\u0637\u0645\u064A';
19580 t['\uFD75'] = '\u0639\u062C\u0645';
19581 t['\uFD76'] = '\u0639\u0645\u0645';
19582 t['\uFD77'] = '\u0639\u0645\u0645';
19583 t['\uFD78'] = '\u0639\u0645\u0649';
19584 t['\uFD79'] = '\u063A\u0645\u0645';
19585 t['\uFD7A'] = '\u063A\u0645\u064A';
19586 t['\uFD7B'] = '\u063A\u0645\u0649';
19587 t['\uFD7C'] = '\u0641\u062E\u0645';
19588 t['\uFD7D'] = '\u0641\u062E\u0645';
19589 t['\uFD7E'] = '\u0642\u0645\u062D';
19590 t['\uFD7F'] = '\u0642\u0645\u0645';
19591 t['\uFD80'] = '\u0644\u062D\u0645';
19592 t['\uFD81'] = '\u0644\u062D\u064A';
19593 t['\uFD82'] = '\u0644\u062D\u0649';
19594 t['\uFD83'] = '\u0644\u062C\u062C';
19595 t['\uFD84'] = '\u0644\u062C\u062C';
19596 t['\uFD85'] = '\u0644\u062E\u0645';
19597 t['\uFD86'] = '\u0644\u062E\u0645';
19598 t['\uFD87'] = '\u0644\u0645\u062D';
19599 t['\uFD88'] = '\u0644\u0645\u062D';
19600 t['\uFD89'] = '\u0645\u062D\u062C';
19601 t['\uFD8A'] = '\u0645\u062D\u0645';
19602 t['\uFD8B'] = '\u0645\u062D\u064A';
19603 t['\uFD8C'] = '\u0645\u062C\u062D';
19604 t['\uFD8D'] = '\u0645\u062C\u0645';
19605 t['\uFD8E'] = '\u0645\u062E\u062C';
19606 t['\uFD8F'] = '\u0645\u062E\u0645';
19607 t['\uFD92'] = '\u0645\u062C\u062E';
19608 t['\uFD93'] = '\u0647\u0645\u062C';
19609 t['\uFD94'] = '\u0647\u0645\u0645';
19610 t['\uFD95'] = '\u0646\u062D\u0645';
19611 t['\uFD96'] = '\u0646\u062D\u0649';
19612 t['\uFD97'] = '\u0646\u062C\u0645';
19613 t['\uFD98'] = '\u0646\u062C\u0645';
19614 t['\uFD99'] = '\u0646\u062C\u0649';
19615 t['\uFD9A'] = '\u0646\u0645\u064A';
19616 t['\uFD9B'] = '\u0646\u0645\u0649';
19617 t['\uFD9C'] = '\u064A\u0645\u0645';
19618 t['\uFD9D'] = '\u064A\u0645\u0645';
19619 t['\uFD9E'] = '\u0628\u062E\u064A';
19620 t['\uFD9F'] = '\u062A\u062C\u064A';
19621 t['\uFDA0'] = '\u062A\u062C\u0649';
19622 t['\uFDA1'] = '\u062A\u062E\u064A';
19623 t['\uFDA2'] = '\u062A\u062E\u0649';
19624 t['\uFDA3'] = '\u062A\u0645\u064A';
19625 t['\uFDA4'] = '\u062A\u0645\u0649';
19626 t['\uFDA5'] = '\u062C\u0645\u064A';
19627 t['\uFDA6'] = '\u062C\u062D\u0649';
19628 t['\uFDA7'] = '\u062C\u0645\u0649';
19629 t['\uFDA8'] = '\u0633\u062E\u0649';
19630 t['\uFDA9'] = '\u0635\u062D\u064A';
19631 t['\uFDAA'] = '\u0634\u062D\u064A';
19632 t['\uFDAB'] = '\u0636\u062D\u064A';
19633 t['\uFDAC'] = '\u0644\u062C\u064A';
19634 t['\uFDAD'] = '\u0644\u0645\u064A';
19635 t['\uFDAE'] = '\u064A\u062D\u064A';
19636 t['\uFDAF'] = '\u064A\u062C\u064A';
19637 t['\uFDB0'] = '\u064A\u0645\u064A';
19638 t['\uFDB1'] = '\u0645\u0645\u064A';
19639 t['\uFDB2'] = '\u0642\u0645\u064A';
19640 t['\uFDB3'] = '\u0646\u062D\u064A';
19641 t['\uFDB4'] = '\u0642\u0645\u062D';
19642 t['\uFDB5'] = '\u0644\u062D\u0645';
19643 t['\uFDB6'] = '\u0639\u0645\u064A';
19644 t['\uFDB7'] = '\u0643\u0645\u064A';
19645 t['\uFDB8'] = '\u0646\u062C\u062D';
19646 t['\uFDB9'] = '\u0645\u062E\u064A';
19647 t['\uFDBA'] = '\u0644\u062C\u0645';
19648 t['\uFDBB'] = '\u0643\u0645\u0645';
19649 t['\uFDBC'] = '\u0644\u062C\u0645';
19650 t['\uFDBD'] = '\u0646\u062C\u062D';
19651 t['\uFDBE'] = '\u062C\u062D\u064A';
19652 t['\uFDBF'] = '\u062D\u062C\u064A';
19653 t['\uFDC0'] = '\u0645\u062C\u064A';
19654 t['\uFDC1'] = '\u0641\u0645\u064A';
19655 t['\uFDC2'] = '\u0628\u062D\u064A';
19656 t['\uFDC3'] = '\u0643\u0645\u0645';
19657 t['\uFDC4'] = '\u0639\u062C\u0645';
19658 t['\uFDC5'] = '\u0635\u0645\u0645';
19659 t['\uFDC6'] = '\u0633\u062E\u064A';
19660 t['\uFDC7'] = '\u0646\u062C\u064A';
19661 t['\uFE49'] = '\u203E';
19662 t['\uFE4A'] = '\u203E';
19663 t['\uFE4B'] = '\u203E';
19664 t['\uFE4C'] = '\u203E';
19665 t['\uFE4D'] = '\u005F';
19666 t['\uFE4E'] = '\u005F';
19667 t['\uFE4F'] = '\u005F';
19668 t['\uFE80'] = '\u0621';
19669 t['\uFE81'] = '\u0622';
19670 t['\uFE82'] = '\u0622';
19671 t['\uFE83'] = '\u0623';
19672 t['\uFE84'] = '\u0623';
19673 t['\uFE85'] = '\u0624';
19674 t['\uFE86'] = '\u0624';
19675 t['\uFE87'] = '\u0625';
19676 t['\uFE88'] = '\u0625';
19677 t['\uFE89'] = '\u0626';
19678 t['\uFE8A'] = '\u0626';
19679 t['\uFE8B'] = '\u0626';
19680 t['\uFE8C'] = '\u0626';
19681 t['\uFE8D'] = '\u0627';
19682 t['\uFE8E'] = '\u0627';
19683 t['\uFE8F'] = '\u0628';
19684 t['\uFE90'] = '\u0628';
19685 t['\uFE91'] = '\u0628';
19686 t['\uFE92'] = '\u0628';
19687 t['\uFE93'] = '\u0629';
19688 t['\uFE94'] = '\u0629';
19689 t['\uFE95'] = '\u062A';
19690 t['\uFE96'] = '\u062A';
19691 t['\uFE97'] = '\u062A';
19692 t['\uFE98'] = '\u062A';
19693 t['\uFE99'] = '\u062B';
19694 t['\uFE9A'] = '\u062B';
19695 t['\uFE9B'] = '\u062B';
19696 t['\uFE9C'] = '\u062B';
19697 t['\uFE9D'] = '\u062C';
19698 t['\uFE9E'] = '\u062C';
19699 t['\uFE9F'] = '\u062C';
19700 t['\uFEA0'] = '\u062C';
19701 t['\uFEA1'] = '\u062D';
19702 t['\uFEA2'] = '\u062D';
19703 t['\uFEA3'] = '\u062D';
19704 t['\uFEA4'] = '\u062D';
19705 t['\uFEA5'] = '\u062E';
19706 t['\uFEA6'] = '\u062E';
19707 t['\uFEA7'] = '\u062E';
19708 t['\uFEA8'] = '\u062E';
19709 t['\uFEA9'] = '\u062F';
19710 t['\uFEAA'] = '\u062F';
19711 t['\uFEAB'] = '\u0630';
19712 t['\uFEAC'] = '\u0630';
19713 t['\uFEAD'] = '\u0631';
19714 t['\uFEAE'] = '\u0631';
19715 t['\uFEAF'] = '\u0632';
19716 t['\uFEB0'] = '\u0632';
19717 t['\uFEB1'] = '\u0633';
19718 t['\uFEB2'] = '\u0633';
19719 t['\uFEB3'] = '\u0633';
19720 t['\uFEB4'] = '\u0633';
19721 t['\uFEB5'] = '\u0634';
19722 t['\uFEB6'] = '\u0634';
19723 t['\uFEB7'] = '\u0634';
19724 t['\uFEB8'] = '\u0634';
19725 t['\uFEB9'] = '\u0635';
19726 t['\uFEBA'] = '\u0635';
19727 t['\uFEBB'] = '\u0635';
19728 t['\uFEBC'] = '\u0635';
19729 t['\uFEBD'] = '\u0636';
19730 t['\uFEBE'] = '\u0636';
19731 t['\uFEBF'] = '\u0636';
19732 t['\uFEC0'] = '\u0636';
19733 t['\uFEC1'] = '\u0637';
19734 t['\uFEC2'] = '\u0637';
19735 t['\uFEC3'] = '\u0637';
19736 t['\uFEC4'] = '\u0637';
19737 t['\uFEC5'] = '\u0638';
19738 t['\uFEC6'] = '\u0638';
19739 t['\uFEC7'] = '\u0638';
19740 t['\uFEC8'] = '\u0638';
19741 t['\uFEC9'] = '\u0639';
19742 t['\uFECA'] = '\u0639';
19743 t['\uFECB'] = '\u0639';
19744 t['\uFECC'] = '\u0639';
19745 t['\uFECD'] = '\u063A';
19746 t['\uFECE'] = '\u063A';
19747 t['\uFECF'] = '\u063A';
19748 t['\uFED0'] = '\u063A';
19749 t['\uFED1'] = '\u0641';
19750 t['\uFED2'] = '\u0641';
19751 t['\uFED3'] = '\u0641';
19752 t['\uFED4'] = '\u0641';
19753 t['\uFED5'] = '\u0642';
19754 t['\uFED6'] = '\u0642';
19755 t['\uFED7'] = '\u0642';
19756 t['\uFED8'] = '\u0642';
19757 t['\uFED9'] = '\u0643';
19758 t['\uFEDA'] = '\u0643';
19759 t['\uFEDB'] = '\u0643';
19760 t['\uFEDC'] = '\u0643';
19761 t['\uFEDD'] = '\u0644';
19762 t['\uFEDE'] = '\u0644';
19763 t['\uFEDF'] = '\u0644';
19764 t['\uFEE0'] = '\u0644';
19765 t['\uFEE1'] = '\u0645';
19766 t['\uFEE2'] = '\u0645';
19767 t['\uFEE3'] = '\u0645';
19768 t['\uFEE4'] = '\u0645';
19769 t['\uFEE5'] = '\u0646';
19770 t['\uFEE6'] = '\u0646';
19771 t['\uFEE7'] = '\u0646';
19772 t['\uFEE8'] = '\u0646';
19773 t['\uFEE9'] = '\u0647';
19774 t['\uFEEA'] = '\u0647';
19775 t['\uFEEB'] = '\u0647';
19776 t['\uFEEC'] = '\u0647';
19777 t['\uFEED'] = '\u0648';
19778 t['\uFEEE'] = '\u0648';
19779 t['\uFEEF'] = '\u0649';
19780 t['\uFEF0'] = '\u0649';
19781 t['\uFEF1'] = '\u064A';
19782 t['\uFEF2'] = '\u064A';
19783 t['\uFEF3'] = '\u064A';
19784 t['\uFEF4'] = '\u064A';
19785 t['\uFEF5'] = '\u0644\u0622';
19786 t['\uFEF6'] = '\u0644\u0622';
19787 t['\uFEF7'] = '\u0644\u0623';
19788 t['\uFEF8'] = '\u0644\u0623';
19789 t['\uFEF9'] = '\u0644\u0625';
19790 t['\uFEFA'] = '\u0644\u0625';
19791 t['\uFEFB'] = '\u0644\u0627';
19792 t['\uFEFC'] = '\u0644\u0627';
19793 });
19794
19795 function reverseIfRtl(chars) {
19796 var charsLength = chars.length;
19797 //reverse an arabic ligature
19798 if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
19799 return chars;
19800 }
19801 var s = '';
19802 for (var ii = charsLength - 1; ii >= 0; ii--) {
19803 s += chars[ii];
19804 }
19805 return s;
19806 }
19807
19808 exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
19809 exports.reverseIfRtl = reverseIfRtl;
19810 exports.getUnicodeRangeFor = getUnicodeRangeFor;
19811 exports.getNormalizedUnicodes = getNormalizedUnicodes;
19812 exports.getUnicodeForGlyph = getUnicodeForGlyph;
19813}));
19814
19815
19816(function (root, factory) {
19817 {
19818 factory((root.pdfjsCoreStream = {}), root.pdfjsSharedUtil,
19819 root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg,
19820 root.pdfjsCoreJpx);
19821 }
19822}(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg,
19823 coreJpx) {
19824
19825var Util = sharedUtil.Util;
19826var error = sharedUtil.error;
19827var info = sharedUtil.info;
19828var isInt = sharedUtil.isInt;
19829var isArray = sharedUtil.isArray;
19830var createObjectURL = sharedUtil.createObjectURL;
19831var shadow = sharedUtil.shadow;
19832var warn = sharedUtil.warn;
19833var isSpace = sharedUtil.isSpace;
19834var Dict = corePrimitives.Dict;
19835var isDict = corePrimitives.isDict;
19836var Jbig2Image = coreJbig2.Jbig2Image;
19837var JpegImage = coreJpg.JpegImage;
19838var JpxImage = coreJpx.JpxImage;
19839
19840var Stream = (function StreamClosure() {
19841 function Stream(arrayBuffer, start, length, dict) {
19842 this.bytes = (arrayBuffer instanceof Uint8Array ?
19843 arrayBuffer : new Uint8Array(arrayBuffer));
19844 this.start = start || 0;
19845 this.pos = this.start;
19846 this.end = (start + length) || this.bytes.length;
19847 this.dict = dict;
19848 }
19849
19850 // required methods for a stream. if a particular stream does not
19851 // implement these, an error should be thrown
19852 Stream.prototype = {
19853 get length() {
19854 return this.end - this.start;
19855 },
19856 get isEmpty() {
19857 return this.length === 0;
19858 },
19859 getByte: function Stream_getByte() {
19860 if (this.pos >= this.end) {
19861 return -1;
19862 }
19863 return this.bytes[this.pos++];
19864 },
19865 getUint16: function Stream_getUint16() {
19866 var b0 = this.getByte();
19867 var b1 = this.getByte();
19868 if (b0 === -1 || b1 === -1) {
19869 return -1;
19870 }
19871 return (b0 << 8) + b1;
19872 },
19873 getInt32: function Stream_getInt32() {
19874 var b0 = this.getByte();
19875 var b1 = this.getByte();
19876 var b2 = this.getByte();
19877 var b3 = this.getByte();
19878 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
19879 },
19880 // returns subarray of original buffer
19881 // should only be read
19882 getBytes: function Stream_getBytes(length) {
19883 var bytes = this.bytes;
19884 var pos = this.pos;
19885 var strEnd = this.end;
19886
19887 if (!length) {
19888 return bytes.subarray(pos, strEnd);
19889 }
19890 var end = pos + length;
19891 if (end > strEnd) {
19892 end = strEnd;
19893 }
19894 this.pos = end;
19895 return bytes.subarray(pos, end);
19896 },
19897 peekByte: function Stream_peekByte() {
19898 var peekedByte = this.getByte();
19899 this.pos--;
19900 return peekedByte;
19901 },
19902 peekBytes: function Stream_peekBytes(length) {
19903 var bytes = this.getBytes(length);
19904 this.pos -= bytes.length;
19905 return bytes;
19906 },
19907 skip: function Stream_skip(n) {
19908 if (!n) {
19909 n = 1;
19910 }
19911 this.pos += n;
19912 },
19913 reset: function Stream_reset() {
19914 this.pos = this.start;
19915 },
19916 moveStart: function Stream_moveStart() {
19917 this.start = this.pos;
19918 },
19919 makeSubStream: function Stream_makeSubStream(start, length, dict) {
19920 return new Stream(this.bytes.buffer, start, length, dict);
19921 },
19922 isStream: true
19923 };
19924
19925 return Stream;
19926})();
19927
19928var StringStream = (function StringStreamClosure() {
19929 function StringStream(str) {
19930 var length = str.length;
19931 var bytes = new Uint8Array(length);
19932 for (var n = 0; n < length; ++n) {
19933 bytes[n] = str.charCodeAt(n);
19934 }
19935 Stream.call(this, bytes);
19936 }
19937
19938 StringStream.prototype = Stream.prototype;
19939
19940 return StringStream;
19941})();
19942
19943// super class for the decoding streams
19944var DecodeStream = (function DecodeStreamClosure() {
19945 // Lots of DecodeStreams are created whose buffers are never used. For these
19946 // we share a single empty buffer. This is (a) space-efficient and (b) avoids
19947 // having special cases that would be required if we used |null| for an empty
19948 // buffer.
19949 var emptyBuffer = new Uint8Array(0);
19950
19951 function DecodeStream(maybeMinBufferLength) {
19952 this.pos = 0;
19953 this.bufferLength = 0;
19954 this.eof = false;
19955 this.buffer = emptyBuffer;
19956 this.minBufferLength = 512;
19957 if (maybeMinBufferLength) {
19958 // Compute the first power of two that is as big as maybeMinBufferLength.
19959 while (this.minBufferLength < maybeMinBufferLength) {
19960 this.minBufferLength *= 2;
19961 }
19962 }
19963 }
19964
19965 DecodeStream.prototype = {
19966 get isEmpty() {
19967 while (!this.eof && this.bufferLength === 0) {
19968 this.readBlock();
19969 }
19970 return this.bufferLength === 0;
19971 },
19972 ensureBuffer: function DecodeStream_ensureBuffer(requested) {
19973 var buffer = this.buffer;
19974 if (requested <= buffer.byteLength) {
19975 return buffer;
19976 }
19977 var size = this.minBufferLength;
19978 while (size < requested) {
19979 size *= 2;
19980 }
19981 var buffer2 = new Uint8Array(size);
19982 buffer2.set(buffer);
19983 return (this.buffer = buffer2);
19984 },
19985 getByte: function DecodeStream_getByte() {
19986 var pos = this.pos;
19987 while (this.bufferLength <= pos) {
19988 if (this.eof) {
19989 return -1;
19990 }
19991 this.readBlock();
19992 }
19993 return this.buffer[this.pos++];
19994 },
19995 getUint16: function DecodeStream_getUint16() {
19996 var b0 = this.getByte();
19997 var b1 = this.getByte();
19998 if (b0 === -1 || b1 === -1) {
19999 return -1;
20000 }
20001 return (b0 << 8) + b1;
20002 },
20003 getInt32: function DecodeStream_getInt32() {
20004 var b0 = this.getByte();
20005 var b1 = this.getByte();
20006 var b2 = this.getByte();
20007 var b3 = this.getByte();
20008 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
20009 },
20010 getBytes: function DecodeStream_getBytes(length) {
20011 var end, pos = this.pos;
20012
20013 if (length) {
20014 this.ensureBuffer(pos + length);
20015 end = pos + length;
20016
20017 while (!this.eof && this.bufferLength < end) {
20018 this.readBlock();
20019 }
20020 var bufEnd = this.bufferLength;
20021 if (end > bufEnd) {
20022 end = bufEnd;
20023 }
20024 } else {
20025 while (!this.eof) {
20026 this.readBlock();
20027 }
20028 end = this.bufferLength;
20029 }
20030
20031 this.pos = end;
20032 return this.buffer.subarray(pos, end);
20033 },
20034 peekByte: function DecodeStream_peekByte() {
20035 var peekedByte = this.getByte();
20036 this.pos--;
20037 return peekedByte;
20038 },
20039 peekBytes: function DecodeStream_peekBytes(length) {
20040 var bytes = this.getBytes(length);
20041 this.pos -= bytes.length;
20042 return bytes;
20043 },
20044 makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
20045 var end = start + length;
20046 while (this.bufferLength <= end && !this.eof) {
20047 this.readBlock();
20048 }
20049 return new Stream(this.buffer, start, length, dict);
20050 },
20051 skip: function DecodeStream_skip(n) {
20052 if (!n) {
20053 n = 1;
20054 }
20055 this.pos += n;
20056 },
20057 reset: function DecodeStream_reset() {
20058 this.pos = 0;
20059 },
20060 getBaseStreams: function DecodeStream_getBaseStreams() {
20061 if (this.str && this.str.getBaseStreams) {
20062 return this.str.getBaseStreams();
20063 }
20064 return [];
20065 }
20066 };
20067
20068 return DecodeStream;
20069})();
20070
20071var StreamsSequenceStream = (function StreamsSequenceStreamClosure() {
20072 function StreamsSequenceStream(streams) {
20073 this.streams = streams;
20074 DecodeStream.call(this, /* maybeLength = */ null);
20075 }
20076
20077 StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
20078
20079 StreamsSequenceStream.prototype.readBlock =
20080 function streamSequenceStreamReadBlock() {
20081
20082 var streams = this.streams;
20083 if (streams.length === 0) {
20084 this.eof = true;
20085 return;
20086 }
20087 var stream = streams.shift();
20088 var chunk = stream.getBytes();
20089 var bufferLength = this.bufferLength;
20090 var newLength = bufferLength + chunk.length;
20091 var buffer = this.ensureBuffer(newLength);
20092 buffer.set(chunk, bufferLength);
20093 this.bufferLength = newLength;
20094 };
20095
20096 StreamsSequenceStream.prototype.getBaseStreams =
20097 function StreamsSequenceStream_getBaseStreams() {
20098
20099 var baseStreams = [];
20100 for (var i = 0, ii = this.streams.length; i < ii; i++) {
20101 var stream = this.streams[i];
20102 if (stream.getBaseStreams) {
20103 Util.appendToArray(baseStreams, stream.getBaseStreams());
20104 }
20105 }
20106 return baseStreams;
20107 };
20108
20109 return StreamsSequenceStream;
20110})();
20111
20112var FlateStream = (function FlateStreamClosure() {
20113 var codeLenCodeMap = new Int32Array([
20114 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
20115 ]);
20116
20117 var lengthDecode = new Int32Array([
20118 0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a,
20119 0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f,
20120 0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073,
20121 0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102
20122 ]);
20123
20124 var distDecode = new Int32Array([
20125 0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d,
20126 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1,
20127 0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01,
20128 0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001
20129 ]);
20130
20131 var fixedLitCodeTab = [new Int32Array([
20132 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0,
20133 0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0,
20134 0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0,
20135 0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0,
20136 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8,
20137 0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8,
20138 0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8,
20139 0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8,
20140 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4,
20141 0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4,
20142 0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4,
20143 0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4,
20144 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc,
20145 0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec,
20146 0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc,
20147 0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc,
20148 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2,
20149 0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2,
20150 0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2,
20151 0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2,
20152 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca,
20153 0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea,
20154 0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da,
20155 0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa,
20156 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6,
20157 0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6,
20158 0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6,
20159 0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6,
20160 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce,
20161 0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee,
20162 0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de,
20163 0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe,
20164 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1,
20165 0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1,
20166 0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1,
20167 0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1,
20168 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9,
20169 0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9,
20170 0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9,
20171 0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9,
20172 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5,
20173 0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5,
20174 0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5,
20175 0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5,
20176 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd,
20177 0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed,
20178 0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd,
20179 0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd,
20180 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3,
20181 0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3,
20182 0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3,
20183 0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3,
20184 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb,
20185 0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb,
20186 0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db,
20187 0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb,
20188 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7,
20189 0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7,
20190 0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7,
20191 0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7,
20192 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf,
20193 0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef,
20194 0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df,
20195 0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff
20196 ]), 9];
20197
20198 var fixedDistCodeTab = [new Int32Array([
20199 0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c,
20200 0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000,
20201 0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d,
20202 0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000
20203 ]), 5];
20204
20205 function FlateStream(str, maybeLength) {
20206 this.str = str;
20207 this.dict = str.dict;
20208
20209 var cmf = str.getByte();
20210 var flg = str.getByte();
20211 if (cmf === -1 || flg === -1) {
20212 error('Invalid header in flate stream: ' + cmf + ', ' + flg);
20213 }
20214 if ((cmf & 0x0f) !== 0x08) {
20215 error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
20216 }
20217 if ((((cmf << 8) + flg) % 31) !== 0) {
20218 error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
20219 }
20220 if (flg & 0x20) {
20221 error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
20222 }
20223
20224 this.codeSize = 0;
20225 this.codeBuf = 0;
20226
20227 DecodeStream.call(this, maybeLength);
20228 }
20229
20230 FlateStream.prototype = Object.create(DecodeStream.prototype);
20231
20232 FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
20233 var str = this.str;
20234 var codeSize = this.codeSize;
20235 var codeBuf = this.codeBuf;
20236
20237 var b;
20238 while (codeSize < bits) {
20239 if ((b = str.getByte()) === -1) {
20240 error('Bad encoding in flate stream');
20241 }
20242 codeBuf |= b << codeSize;
20243 codeSize += 8;
20244 }
20245 b = codeBuf & ((1 << bits) - 1);
20246 this.codeBuf = codeBuf >> bits;
20247 this.codeSize = codeSize -= bits;
20248
20249 return b;
20250 };
20251
20252 FlateStream.prototype.getCode = function FlateStream_getCode(table) {
20253 var str = this.str;
20254 var codes = table[0];
20255 var maxLen = table[1];
20256 var codeSize = this.codeSize;
20257 var codeBuf = this.codeBuf;
20258
20259 var b;
20260 while (codeSize < maxLen) {
20261 if ((b = str.getByte()) === -1) {
20262 // premature end of stream. code might however still be valid.
20263 // codeSize < codeLen check below guards against incomplete codeVal.
20264 break;
20265 }
20266 codeBuf |= (b << codeSize);
20267 codeSize += 8;
20268 }
20269 var code = codes[codeBuf & ((1 << maxLen) - 1)];
20270 var codeLen = code >> 16;
20271 var codeVal = code & 0xffff;
20272 if (codeLen < 1 || codeSize < codeLen) {
20273 error('Bad encoding in flate stream');
20274 }
20275 this.codeBuf = (codeBuf >> codeLen);
20276 this.codeSize = (codeSize - codeLen);
20277 return codeVal;
20278 };
20279
20280 FlateStream.prototype.generateHuffmanTable =
20281 function flateStreamGenerateHuffmanTable(lengths) {
20282 var n = lengths.length;
20283
20284 // find max code length
20285 var maxLen = 0;
20286 var i;
20287 for (i = 0; i < n; ++i) {
20288 if (lengths[i] > maxLen) {
20289 maxLen = lengths[i];
20290 }
20291 }
20292
20293 // build the table
20294 var size = 1 << maxLen;
20295 var codes = new Int32Array(size);
20296 for (var len = 1, code = 0, skip = 2;
20297 len <= maxLen;
20298 ++len, code <<= 1, skip <<= 1) {
20299 for (var val = 0; val < n; ++val) {
20300 if (lengths[val] === len) {
20301 // bit-reverse the code
20302 var code2 = 0;
20303 var t = code;
20304 for (i = 0; i < len; ++i) {
20305 code2 = (code2 << 1) | (t & 1);
20306 t >>= 1;
20307 }
20308
20309 // fill the table entries
20310 for (i = code2; i < size; i += skip) {
20311 codes[i] = (len << 16) | val;
20312 }
20313 ++code;
20314 }
20315 }
20316 }
20317
20318 return [codes, maxLen];
20319 };
20320
20321 FlateStream.prototype.readBlock = function FlateStream_readBlock() {
20322 var buffer, len;
20323 var str = this.str;
20324 // read block header
20325 var hdr = this.getBits(3);
20326 if (hdr & 1) {
20327 this.eof = true;
20328 }
20329 hdr >>= 1;
20330
20331 if (hdr === 0) { // uncompressed block
20332 var b;
20333
20334 if ((b = str.getByte()) === -1) {
20335 error('Bad block header in flate stream');
20336 }
20337 var blockLen = b;
20338 if ((b = str.getByte()) === -1) {
20339 error('Bad block header in flate stream');
20340 }
20341 blockLen |= (b << 8);
20342 if ((b = str.getByte()) === -1) {
20343 error('Bad block header in flate stream');
20344 }
20345 var check = b;
20346 if ((b = str.getByte()) === -1) {
20347 error('Bad block header in flate stream');
20348 }
20349 check |= (b << 8);
20350 if (check !== (~blockLen & 0xffff) &&
20351 (blockLen !== 0 || check !== 0)) {
20352 // Ignoring error for bad "empty" block (see issue 1277)
20353 error('Bad uncompressed block length in flate stream');
20354 }
20355
20356 this.codeBuf = 0;
20357 this.codeSize = 0;
20358
20359 var bufferLength = this.bufferLength;
20360 buffer = this.ensureBuffer(bufferLength + blockLen);
20361 var end = bufferLength + blockLen;
20362 this.bufferLength = end;
20363 if (blockLen === 0) {
20364 if (str.peekByte() === -1) {
20365 this.eof = true;
20366 }
20367 } else {
20368 for (var n = bufferLength; n < end; ++n) {
20369 if ((b = str.getByte()) === -1) {
20370 this.eof = true;
20371 break;
20372 }
20373 buffer[n] = b;
20374 }
20375 }
20376 return;
20377 }
20378
20379 var litCodeTable;
20380 var distCodeTable;
20381 if (hdr === 1) { // compressed block, fixed codes
20382 litCodeTable = fixedLitCodeTab;
20383 distCodeTable = fixedDistCodeTab;
20384 } else if (hdr === 2) { // compressed block, dynamic codes
20385 var numLitCodes = this.getBits(5) + 257;
20386 var numDistCodes = this.getBits(5) + 1;
20387 var numCodeLenCodes = this.getBits(4) + 4;
20388
20389 // build the code lengths code table
20390 var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
20391
20392 var i;
20393 for (i = 0; i < numCodeLenCodes; ++i) {
20394 codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
20395 }
20396 var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
20397
20398 // build the literal and distance code tables
20399 len = 0;
20400 i = 0;
20401 var codes = numLitCodes + numDistCodes;
20402 var codeLengths = new Uint8Array(codes);
20403 var bitsLength, bitsOffset, what;
20404 while (i < codes) {
20405 var code = this.getCode(codeLenCodeTab);
20406 if (code === 16) {
20407 bitsLength = 2; bitsOffset = 3; what = len;
20408 } else if (code === 17) {
20409 bitsLength = 3; bitsOffset = 3; what = (len = 0);
20410 } else if (code === 18) {
20411 bitsLength = 7; bitsOffset = 11; what = (len = 0);
20412 } else {
20413 codeLengths[i++] = len = code;
20414 continue;
20415 }
20416
20417 var repeatLength = this.getBits(bitsLength) + bitsOffset;
20418 while (repeatLength-- > 0) {
20419 codeLengths[i++] = what;
20420 }
20421 }
20422
20423 litCodeTable =
20424 this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
20425 distCodeTable =
20426 this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
20427 } else {
20428 error('Unknown block type in flate stream');
20429 }
20430
20431 buffer = this.buffer;
20432 var limit = buffer ? buffer.length : 0;
20433 var pos = this.bufferLength;
20434 while (true) {
20435 var code1 = this.getCode(litCodeTable);
20436 if (code1 < 256) {
20437 if (pos + 1 >= limit) {
20438 buffer = this.ensureBuffer(pos + 1);
20439 limit = buffer.length;
20440 }
20441 buffer[pos++] = code1;
20442 continue;
20443 }
20444 if (code1 === 256) {
20445 this.bufferLength = pos;
20446 return;
20447 }
20448 code1 -= 257;
20449 code1 = lengthDecode[code1];
20450 var code2 = code1 >> 16;
20451 if (code2 > 0) {
20452 code2 = this.getBits(code2);
20453 }
20454 len = (code1 & 0xffff) + code2;
20455 code1 = this.getCode(distCodeTable);
20456 code1 = distDecode[code1];
20457 code2 = code1 >> 16;
20458 if (code2 > 0) {
20459 code2 = this.getBits(code2);
20460 }
20461 var dist = (code1 & 0xffff) + code2;
20462 if (pos + len >= limit) {
20463 buffer = this.ensureBuffer(pos + len);
20464 limit = buffer.length;
20465 }
20466 for (var k = 0; k < len; ++k, ++pos) {
20467 buffer[pos] = buffer[pos - dist];
20468 }
20469 }
20470 };
20471
20472 return FlateStream;
20473})();
20474
20475var PredictorStream = (function PredictorStreamClosure() {
20476 function PredictorStream(str, maybeLength, params) {
20477 if (!isDict(params)) {
20478 return str; // no prediction
20479 }
20480 var predictor = this.predictor = params.get('Predictor') || 1;
20481
20482 if (predictor <= 1) {
20483 return str; // no prediction
20484 }
20485 if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
20486 error('Unsupported predictor: ' + predictor);
20487 }
20488
20489 if (predictor === 2) {
20490 this.readBlock = this.readBlockTiff;
20491 } else {
20492 this.readBlock = this.readBlockPng;
20493 }
20494
20495 this.str = str;
20496 this.dict = str.dict;
20497
20498 var colors = this.colors = params.get('Colors') || 1;
20499 var bits = this.bits = params.get('BitsPerComponent') || 8;
20500 var columns = this.columns = params.get('Columns') || 1;
20501
20502 this.pixBytes = (colors * bits + 7) >> 3;
20503 this.rowBytes = (columns * colors * bits + 7) >> 3;
20504
20505 DecodeStream.call(this, maybeLength);
20506 return this;
20507 }
20508
20509 PredictorStream.prototype = Object.create(DecodeStream.prototype);
20510
20511 PredictorStream.prototype.readBlockTiff =
20512 function predictorStreamReadBlockTiff() {
20513 var rowBytes = this.rowBytes;
20514
20515 var bufferLength = this.bufferLength;
20516 var buffer = this.ensureBuffer(bufferLength + rowBytes);
20517
20518 var bits = this.bits;
20519 var colors = this.colors;
20520
20521 var rawBytes = this.str.getBytes(rowBytes);
20522 this.eof = !rawBytes.length;
20523 if (this.eof) {
20524 return;
20525 }
20526
20527 var inbuf = 0, outbuf = 0;
20528 var inbits = 0, outbits = 0;
20529 var pos = bufferLength;
20530 var i;
20531
20532 if (bits === 1) {
20533 for (i = 0; i < rowBytes; ++i) {
20534 var c = rawBytes[i];
20535 inbuf = (inbuf << 8) | c;
20536 // bitwise addition is exclusive or
20537 // first shift inbuf and then add
20538 buffer[pos++] = (c ^ (inbuf >> colors)) & 0xFF;
20539 // truncate inbuf (assumes colors < 16)
20540 inbuf &= 0xFFFF;
20541 }
20542 } else if (bits === 8) {
20543 for (i = 0; i < colors; ++i) {
20544 buffer[pos++] = rawBytes[i];
20545 }
20546 for (; i < rowBytes; ++i) {
20547 buffer[pos] = buffer[pos - colors] + rawBytes[i];
20548 pos++;
20549 }
20550 } else {
20551 var compArray = new Uint8Array(colors + 1);
20552 var bitMask = (1 << bits) - 1;
20553 var j = 0, k = bufferLength;
20554 var columns = this.columns;
20555 for (i = 0; i < columns; ++i) {
20556 for (var kk = 0; kk < colors; ++kk) {
20557 if (inbits < bits) {
20558 inbuf = (inbuf << 8) | (rawBytes[j++] & 0xFF);
20559 inbits += 8;
20560 }
20561 compArray[kk] = (compArray[kk] +
20562 (inbuf >> (inbits - bits))) & bitMask;
20563 inbits -= bits;
20564 outbuf = (outbuf << bits) | compArray[kk];
20565 outbits += bits;
20566 if (outbits >= 8) {
20567 buffer[k++] = (outbuf >> (outbits - 8)) & 0xFF;
20568 outbits -= 8;
20569 }
20570 }
20571 }
20572 if (outbits > 0) {
20573 buffer[k++] = (outbuf << (8 - outbits)) +
20574 (inbuf & ((1 << (8 - outbits)) - 1));
20575 }
20576 }
20577 this.bufferLength += rowBytes;
20578 };
20579
20580 PredictorStream.prototype.readBlockPng =
20581 function predictorStreamReadBlockPng() {
20582
20583 var rowBytes = this.rowBytes;
20584 var pixBytes = this.pixBytes;
20585
20586 var predictor = this.str.getByte();
20587 var rawBytes = this.str.getBytes(rowBytes);
20588 this.eof = !rawBytes.length;
20589 if (this.eof) {
20590 return;
20591 }
20592
20593 var bufferLength = this.bufferLength;
20594 var buffer = this.ensureBuffer(bufferLength + rowBytes);
20595
20596 var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
20597 if (prevRow.length === 0) {
20598 prevRow = new Uint8Array(rowBytes);
20599 }
20600
20601 var i, j = bufferLength, up, c;
20602 switch (predictor) {
20603 case 0:
20604 for (i = 0; i < rowBytes; ++i) {
20605 buffer[j++] = rawBytes[i];
20606 }
20607 break;
20608 case 1:
20609 for (i = 0; i < pixBytes; ++i) {
20610 buffer[j++] = rawBytes[i];
20611 }
20612 for (; i < rowBytes; ++i) {
20613 buffer[j] = (buffer[j - pixBytes] + rawBytes[i]) & 0xFF;
20614 j++;
20615 }
20616 break;
20617 case 2:
20618 for (i = 0; i < rowBytes; ++i) {
20619 buffer[j++] = (prevRow[i] + rawBytes[i]) & 0xFF;
20620 }
20621 break;
20622 case 3:
20623 for (i = 0; i < pixBytes; ++i) {
20624 buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
20625 }
20626 for (; i < rowBytes; ++i) {
20627 buffer[j] = (((prevRow[i] + buffer[j - pixBytes]) >> 1) +
20628 rawBytes[i]) & 0xFF;
20629 j++;
20630 }
20631 break;
20632 case 4:
20633 // we need to save the up left pixels values. the simplest way
20634 // is to create a new buffer
20635 for (i = 0; i < pixBytes; ++i) {
20636 up = prevRow[i];
20637 c = rawBytes[i];
20638 buffer[j++] = up + c;
20639 }
20640 for (; i < rowBytes; ++i) {
20641 up = prevRow[i];
20642 var upLeft = prevRow[i - pixBytes];
20643 var left = buffer[j - pixBytes];
20644 var p = left + up - upLeft;
20645
20646 var pa = p - left;
20647 if (pa < 0) {
20648 pa = -pa;
20649 }
20650 var pb = p - up;
20651 if (pb < 0) {
20652 pb = -pb;
20653 }
20654 var pc = p - upLeft;
20655 if (pc < 0) {
20656 pc = -pc;
20657 }
20658
20659 c = rawBytes[i];
20660 if (pa <= pb && pa <= pc) {
20661 buffer[j++] = left + c;
20662 } else if (pb <= pc) {
20663 buffer[j++] = up + c;
20664 } else {
20665 buffer[j++] = upLeft + c;
20666 }
20667 }
20668 break;
20669 default:
20670 error('Unsupported predictor: ' + predictor);
20671 }
20672 this.bufferLength += rowBytes;
20673 };
20674
20675 return PredictorStream;
20676})();
20677
20678/**
20679 * Depending on the type of JPEG a JpegStream is handled in different ways. For
20680 * JPEG's that are supported natively such as DeviceGray and DeviceRGB the image
20681 * data is stored and then loaded by the browser. For unsupported JPEG's we use
20682 * a library to decode these images and the stream behaves like all the other
20683 * DecodeStreams.
20684 */
20685var JpegStream = (function JpegStreamClosure() {
20686 function JpegStream(stream, maybeLength, dict) {
20687 // Some images may contain 'junk' before the SOI (start-of-image) marker.
20688 // Note: this seems to mainly affect inline images.
20689 var ch;
20690 while ((ch = stream.getByte()) !== -1) {
20691 if (ch === 0xFF) { // Find the first byte of the SOI marker (0xFFD8).
20692 stream.skip(-1); // Reset the stream position to the SOI.
20693 break;
20694 }
20695 }
20696 this.stream = stream;
20697 this.maybeLength = maybeLength;
20698 this.dict = dict;
20699
20700 DecodeStream.call(this, maybeLength);
20701 }
20702
20703 JpegStream.prototype = Object.create(DecodeStream.prototype);
20704
20705 Object.defineProperty(JpegStream.prototype, 'bytes', {
20706 get: function JpegStream_bytes() {
20707 // If this.maybeLength is null, we'll get the entire stream.
20708 return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
20709 },
20710 configurable: true
20711 });
20712
20713 JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
20714 if (this.bufferLength) {
20715 return;
20716 }
20717 var jpegImage = new JpegImage();
20718
20719 // Checking if values need to be transformed before conversion.
20720 var decodeArr = this.dict.getArray('Decode', 'D');
20721 if (this.forceRGB && isArray(decodeArr)) {
20722 var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
20723 var decodeArrLength = decodeArr.length;
20724 var transform = new Int32Array(decodeArrLength);
20725 var transformNeeded = false;
20726 var maxValue = (1 << bitsPerComponent) - 1;
20727 for (var i = 0; i < decodeArrLength; i += 2) {
20728 transform[i] = ((decodeArr[i + 1] - decodeArr[i]) * 256) | 0;
20729 transform[i + 1] = (decodeArr[i] * maxValue) | 0;
20730 if (transform[i] !== 256 || transform[i + 1] !== 0) {
20731 transformNeeded = true;
20732 }
20733 }
20734 if (transformNeeded) {
20735 jpegImage.decodeTransform = transform;
20736 }
20737 }
20738 // Fetching the 'ColorTransform' entry, if it exists.
20739 var decodeParams = this.dict.get('DecodeParms', 'DP');
20740 if (isDict(decodeParams)) {
20741 var colorTransform = decodeParams.get('ColorTransform');
20742 if (isInt(colorTransform)) {
20743 jpegImage.colorTransform = colorTransform;
20744 }
20745 }
20746
20747 jpegImage.parse(this.bytes);
20748 var data = jpegImage.getData(this.drawWidth, this.drawHeight,
20749 this.forceRGB);
20750 this.buffer = data;
20751 this.bufferLength = data.length;
20752 this.eof = true;
20753 };
20754
20755 JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
20756 this.ensureBuffer();
20757 return this.buffer;
20758 };
20759
20760 JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
20761 return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
20762 };
20763
20764 return JpegStream;
20765})();
20766
20767/**
20768 * For JPEG 2000's we use a library to decode these images and
20769 * the stream behaves like all the other DecodeStreams.
20770 */
20771var JpxStream = (function JpxStreamClosure() {
20772 function JpxStream(stream, maybeLength, dict) {
20773 this.stream = stream;
20774 this.maybeLength = maybeLength;
20775 this.dict = dict;
20776
20777 DecodeStream.call(this, maybeLength);
20778 }
20779
20780 JpxStream.prototype = Object.create(DecodeStream.prototype);
20781
20782 Object.defineProperty(JpxStream.prototype, 'bytes', {
20783 get: function JpxStream_bytes() {
20784 // If this.maybeLength is null, we'll get the entire stream.
20785 return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
20786 },
20787 configurable: true
20788 });
20789
20790 JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
20791 if (this.bufferLength) {
20792 return;
20793 }
20794
20795 var jpxImage = new JpxImage();
20796 jpxImage.parse(this.bytes);
20797
20798 var width = jpxImage.width;
20799 var height = jpxImage.height;
20800 var componentsCount = jpxImage.componentsCount;
20801 var tileCount = jpxImage.tiles.length;
20802 if (tileCount === 1) {
20803 this.buffer = jpxImage.tiles[0].items;
20804 } else {
20805 var data = new Uint8Array(width * height * componentsCount);
20806
20807 for (var k = 0; k < tileCount; k++) {
20808 var tileComponents = jpxImage.tiles[k];
20809 var tileWidth = tileComponents.width;
20810 var tileHeight = tileComponents.height;
20811 var tileLeft = tileComponents.left;
20812 var tileTop = tileComponents.top;
20813
20814 var src = tileComponents.items;
20815 var srcPosition = 0;
20816 var dataPosition = (width * tileTop + tileLeft) * componentsCount;
20817 var imgRowSize = width * componentsCount;
20818 var tileRowSize = tileWidth * componentsCount;
20819
20820 for (var j = 0; j < tileHeight; j++) {
20821 var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
20822 data.set(rowBytes, dataPosition);
20823 srcPosition += tileRowSize;
20824 dataPosition += imgRowSize;
20825 }
20826 }
20827 this.buffer = data;
20828 }
20829 this.bufferLength = this.buffer.length;
20830 this.eof = true;
20831 };
20832
20833 return JpxStream;
20834})();
20835
20836/**
20837 * For JBIG2's we use a library to decode these images and
20838 * the stream behaves like all the other DecodeStreams.
20839 */
20840var Jbig2Stream = (function Jbig2StreamClosure() {
20841 function Jbig2Stream(stream, maybeLength, dict) {
20842 this.stream = stream;
20843 this.maybeLength = maybeLength;
20844 this.dict = dict;
20845
20846 DecodeStream.call(this, maybeLength);
20847 }
20848
20849 Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
20850
20851 Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
20852 get: function Jbig2Stream_bytes() {
20853 // If this.maybeLength is null, we'll get the entire stream.
20854 return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
20855 },
20856 configurable: true
20857 });
20858
20859 Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
20860 if (this.bufferLength) {
20861 return;
20862 }
20863
20864 var jbig2Image = new Jbig2Image();
20865
20866 var chunks = [];
20867 var decodeParams = this.dict.getArray('DecodeParms', 'DP');
20868
20869 // According to the PDF specification, DecodeParms can be either
20870 // a dictionary, or an array whose elements are dictionaries.
20871 if (isArray(decodeParams)) {
20872 if (decodeParams.length > 1) {
20873 warn('JBIG2 - \'DecodeParms\' array with multiple elements ' +
20874 'not supported.');
20875 }
20876 decodeParams = decodeParams[0];
20877 }
20878 if (decodeParams && decodeParams.has('JBIG2Globals')) {
20879 var globalsStream = decodeParams.get('JBIG2Globals');
20880 var globals = globalsStream.getBytes();
20881 chunks.push({data: globals, start: 0, end: globals.length});
20882 }
20883 chunks.push({data: this.bytes, start: 0, end: this.bytes.length});
20884 var data = jbig2Image.parseChunks(chunks);
20885 var dataLength = data.length;
20886
20887 // JBIG2 had black as 1 and white as 0, inverting the colors
20888 for (var i = 0; i < dataLength; i++) {
20889 data[i] ^= 0xFF;
20890 }
20891
20892 this.buffer = data;
20893 this.bufferLength = dataLength;
20894 this.eof = true;
20895 };
20896
20897 return Jbig2Stream;
20898})();
20899
20900var DecryptStream = (function DecryptStreamClosure() {
20901 function DecryptStream(str, maybeLength, decrypt) {
20902 this.str = str;
20903 this.dict = str.dict;
20904 this.decrypt = decrypt;
20905 this.nextChunk = null;
20906 this.initialized = false;
20907
20908 DecodeStream.call(this, maybeLength);
20909 }
20910
20911 var chunkSize = 512;
20912
20913 DecryptStream.prototype = Object.create(DecodeStream.prototype);
20914
20915 DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
20916 var chunk;
20917 if (this.initialized) {
20918 chunk = this.nextChunk;
20919 } else {
20920 chunk = this.str.getBytes(chunkSize);
20921 this.initialized = true;
20922 }
20923 if (!chunk || chunk.length === 0) {
20924 this.eof = true;
20925 return;
20926 }
20927 this.nextChunk = this.str.getBytes(chunkSize);
20928 var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
20929
20930 var decrypt = this.decrypt;
20931 chunk = decrypt(chunk, !hasMoreData);
20932
20933 var bufferLength = this.bufferLength;
20934 var i, n = chunk.length;
20935 var buffer = this.ensureBuffer(bufferLength + n);
20936 for (i = 0; i < n; i++) {
20937 buffer[bufferLength++] = chunk[i];
20938 }
20939 this.bufferLength = bufferLength;
20940 };
20941
20942 return DecryptStream;
20943})();
20944
20945var Ascii85Stream = (function Ascii85StreamClosure() {
20946 function Ascii85Stream(str, maybeLength) {
20947 this.str = str;
20948 this.dict = str.dict;
20949 this.input = new Uint8Array(5);
20950
20951 // Most streams increase in size when decoded, but Ascii85 streams
20952 // typically shrink by ~20%.
20953 if (maybeLength) {
20954 maybeLength = 0.8 * maybeLength;
20955 }
20956 DecodeStream.call(this, maybeLength);
20957 }
20958
20959 Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
20960
20961 Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
20962 var TILDA_CHAR = 0x7E; // '~'
20963 var Z_LOWER_CHAR = 0x7A; // 'z'
20964 var EOF = -1;
20965
20966 var str = this.str;
20967
20968 var c = str.getByte();
20969 while (isSpace(c)) {
20970 c = str.getByte();
20971 }
20972
20973 if (c === EOF || c === TILDA_CHAR) {
20974 this.eof = true;
20975 return;
20976 }
20977
20978 var bufferLength = this.bufferLength, buffer;
20979 var i;
20980
20981 // special code for z
20982 if (c === Z_LOWER_CHAR) {
20983 buffer = this.ensureBuffer(bufferLength + 4);
20984 for (i = 0; i < 4; ++i) {
20985 buffer[bufferLength + i] = 0;
20986 }
20987 this.bufferLength += 4;
20988 } else {
20989 var input = this.input;
20990 input[0] = c;
20991 for (i = 1; i < 5; ++i) {
20992 c = str.getByte();
20993 while (isSpace(c)) {
20994 c = str.getByte();
20995 }
20996
20997 input[i] = c;
20998
20999 if (c === EOF || c === TILDA_CHAR) {
21000 break;
21001 }
21002 }
21003 buffer = this.ensureBuffer(bufferLength + i - 1);
21004 this.bufferLength += i - 1;
21005
21006 // partial ending;
21007 if (i < 5) {
21008 for (; i < 5; ++i) {
21009 input[i] = 0x21 + 84;
21010 }
21011 this.eof = true;
21012 }
21013 var t = 0;
21014 for (i = 0; i < 5; ++i) {
21015 t = t * 85 + (input[i] - 0x21);
21016 }
21017
21018 for (i = 3; i >= 0; --i) {
21019 buffer[bufferLength + i] = t & 0xFF;
21020 t >>= 8;
21021 }
21022 }
21023 };
21024
21025 return Ascii85Stream;
21026})();
21027
21028var AsciiHexStream = (function AsciiHexStreamClosure() {
21029 function AsciiHexStream(str, maybeLength) {
21030 this.str = str;
21031 this.dict = str.dict;
21032
21033 this.firstDigit = -1;
21034
21035 // Most streams increase in size when decoded, but AsciiHex streams shrink
21036 // by 50%.
21037 if (maybeLength) {
21038 maybeLength = 0.5 * maybeLength;
21039 }
21040 DecodeStream.call(this, maybeLength);
21041 }
21042
21043 AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
21044
21045 AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
21046 var UPSTREAM_BLOCK_SIZE = 8000;
21047 var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
21048 if (!bytes.length) {
21049 this.eof = true;
21050 return;
21051 }
21052
21053 var maxDecodeLength = (bytes.length + 1) >> 1;
21054 var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
21055 var bufferLength = this.bufferLength;
21056
21057 var firstDigit = this.firstDigit;
21058 for (var i = 0, ii = bytes.length; i < ii; i++) {
21059 var ch = bytes[i], digit;
21060 if (ch >= 0x30 && ch <= 0x39) { // '0'-'9'
21061 digit = ch & 0x0F;
21062 } else if ((ch >= 0x41 && ch <= 0x46) || (ch >= 0x61 && ch <= 0x66)) {
21063 // 'A'-'Z', 'a'-'z'
21064 digit = (ch & 0x0F) + 9;
21065 } else if (ch === 0x3E) { // '>'
21066 this.eof = true;
21067 break;
21068 } else { // probably whitespace
21069 continue; // ignoring
21070 }
21071 if (firstDigit < 0) {
21072 firstDigit = digit;
21073 } else {
21074 buffer[bufferLength++] = (firstDigit << 4) | digit;
21075 firstDigit = -1;
21076 }
21077 }
21078 if (firstDigit >= 0 && this.eof) {
21079 // incomplete byte
21080 buffer[bufferLength++] = (firstDigit << 4);
21081 firstDigit = -1;
21082 }
21083 this.firstDigit = firstDigit;
21084 this.bufferLength = bufferLength;
21085 };
21086
21087 return AsciiHexStream;
21088})();
21089
21090var RunLengthStream = (function RunLengthStreamClosure() {
21091 function RunLengthStream(str, maybeLength) {
21092 this.str = str;
21093 this.dict = str.dict;
21094
21095 DecodeStream.call(this, maybeLength);
21096 }
21097
21098 RunLengthStream.prototype = Object.create(DecodeStream.prototype);
21099
21100 RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
21101 // The repeatHeader has following format. The first byte defines type of run
21102 // and amount of bytes to repeat/copy: n = 0 through 127 - copy next n bytes
21103 // (in addition to the second byte from the header), n = 129 through 255 -
21104 // duplicate the second byte from the header (257 - n) times, n = 128 - end.
21105 var repeatHeader = this.str.getBytes(2);
21106 if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
21107 this.eof = true;
21108 return;
21109 }
21110
21111 var buffer;
21112 var bufferLength = this.bufferLength;
21113 var n = repeatHeader[0];
21114 if (n < 128) {
21115 // copy n bytes
21116 buffer = this.ensureBuffer(bufferLength + n + 1);
21117 buffer[bufferLength++] = repeatHeader[1];
21118 if (n > 0) {
21119 var source = this.str.getBytes(n);
21120 buffer.set(source, bufferLength);
21121 bufferLength += n;
21122 }
21123 } else {
21124 n = 257 - n;
21125 var b = repeatHeader[1];
21126 buffer = this.ensureBuffer(bufferLength + n + 1);
21127 for (var i = 0; i < n; i++) {
21128 buffer[bufferLength++] = b;
21129 }
21130 }
21131 this.bufferLength = bufferLength;
21132 };
21133
21134 return RunLengthStream;
21135})();
21136
21137var CCITTFaxStream = (function CCITTFaxStreamClosure() {
21138
21139 var ccittEOL = -2;
21140 var ccittEOF = -1;
21141 var twoDimPass = 0;
21142 var twoDimHoriz = 1;
21143 var twoDimVert0 = 2;
21144 var twoDimVertR1 = 3;
21145 var twoDimVertL1 = 4;
21146 var twoDimVertR2 = 5;
21147 var twoDimVertL2 = 6;
21148 var twoDimVertR3 = 7;
21149 var twoDimVertL3 = 8;
21150
21151 var twoDimTable = [
21152 [-1, -1], [-1, -1], // 000000x
21153 [7, twoDimVertL3], // 0000010
21154 [7, twoDimVertR3], // 0000011
21155 [6, twoDimVertL2], [6, twoDimVertL2], // 000010x
21156 [6, twoDimVertR2], [6, twoDimVertR2], // 000011x
21157 [4, twoDimPass], [4, twoDimPass], // 0001xxx
21158 [4, twoDimPass], [4, twoDimPass],
21159 [4, twoDimPass], [4, twoDimPass],
21160 [4, twoDimPass], [4, twoDimPass],
21161 [3, twoDimHoriz], [3, twoDimHoriz], // 001xxxx
21162 [3, twoDimHoriz], [3, twoDimHoriz],
21163 [3, twoDimHoriz], [3, twoDimHoriz],
21164 [3, twoDimHoriz], [3, twoDimHoriz],
21165 [3, twoDimHoriz], [3, twoDimHoriz],
21166 [3, twoDimHoriz], [3, twoDimHoriz],
21167 [3, twoDimHoriz], [3, twoDimHoriz],
21168 [3, twoDimHoriz], [3, twoDimHoriz],
21169 [3, twoDimVertL1], [3, twoDimVertL1], // 010xxxx
21170 [3, twoDimVertL1], [3, twoDimVertL1],
21171 [3, twoDimVertL1], [3, twoDimVertL1],
21172 [3, twoDimVertL1], [3, twoDimVertL1],
21173 [3, twoDimVertL1], [3, twoDimVertL1],
21174 [3, twoDimVertL1], [3, twoDimVertL1],
21175 [3, twoDimVertL1], [3, twoDimVertL1],
21176 [3, twoDimVertL1], [3, twoDimVertL1],
21177 [3, twoDimVertR1], [3, twoDimVertR1], // 011xxxx
21178 [3, twoDimVertR1], [3, twoDimVertR1],
21179 [3, twoDimVertR1], [3, twoDimVertR1],
21180 [3, twoDimVertR1], [3, twoDimVertR1],
21181 [3, twoDimVertR1], [3, twoDimVertR1],
21182 [3, twoDimVertR1], [3, twoDimVertR1],
21183 [3, twoDimVertR1], [3, twoDimVertR1],
21184 [3, twoDimVertR1], [3, twoDimVertR1],
21185 [1, twoDimVert0], [1, twoDimVert0], // 1xxxxxx
21186 [1, twoDimVert0], [1, twoDimVert0],
21187 [1, twoDimVert0], [1, twoDimVert0],
21188 [1, twoDimVert0], [1, twoDimVert0],
21189 [1, twoDimVert0], [1, twoDimVert0],
21190 [1, twoDimVert0], [1, twoDimVert0],
21191 [1, twoDimVert0], [1, twoDimVert0],
21192 [1, twoDimVert0], [1, twoDimVert0],
21193 [1, twoDimVert0], [1, twoDimVert0],
21194 [1, twoDimVert0], [1, twoDimVert0],
21195 [1, twoDimVert0], [1, twoDimVert0],
21196 [1, twoDimVert0], [1, twoDimVert0],
21197 [1, twoDimVert0], [1, twoDimVert0],
21198 [1, twoDimVert0], [1, twoDimVert0],
21199 [1, twoDimVert0], [1, twoDimVert0],
21200 [1, twoDimVert0], [1, twoDimVert0],
21201 [1, twoDimVert0], [1, twoDimVert0],
21202 [1, twoDimVert0], [1, twoDimVert0],
21203 [1, twoDimVert0], [1, twoDimVert0],
21204 [1, twoDimVert0], [1, twoDimVert0],
21205 [1, twoDimVert0], [1, twoDimVert0],
21206 [1, twoDimVert0], [1, twoDimVert0],
21207 [1, twoDimVert0], [1, twoDimVert0],
21208 [1, twoDimVert0], [1, twoDimVert0],
21209 [1, twoDimVert0], [1, twoDimVert0],
21210 [1, twoDimVert0], [1, twoDimVert0],
21211 [1, twoDimVert0], [1, twoDimVert0],
21212 [1, twoDimVert0], [1, twoDimVert0],
21213 [1, twoDimVert0], [1, twoDimVert0],
21214 [1, twoDimVert0], [1, twoDimVert0],
21215 [1, twoDimVert0], [1, twoDimVert0],
21216 [1, twoDimVert0], [1, twoDimVert0]
21217 ];
21218
21219 var whiteTable1 = [
21220 [-1, -1], // 00000
21221 [12, ccittEOL], // 00001
21222 [-1, -1], [-1, -1], // 0001x
21223 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 001xx
21224 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 010xx
21225 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 011xx
21226 [11, 1792], [11, 1792], // 1000x
21227 [12, 1984], // 10010
21228 [12, 2048], // 10011
21229 [12, 2112], // 10100
21230 [12, 2176], // 10101
21231 [12, 2240], // 10110
21232 [12, 2304], // 10111
21233 [11, 1856], [11, 1856], // 1100x
21234 [11, 1920], [11, 1920], // 1101x
21235 [12, 2368], // 11100
21236 [12, 2432], // 11101
21237 [12, 2496], // 11110
21238 [12, 2560] // 11111
21239 ];
21240
21241 var whiteTable2 = [
21242 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 0000000xx
21243 [8, 29], [8, 29], // 00000010x
21244 [8, 30], [8, 30], // 00000011x
21245 [8, 45], [8, 45], // 00000100x
21246 [8, 46], [8, 46], // 00000101x
21247 [7, 22], [7, 22], [7, 22], [7, 22], // 0000011xx
21248 [7, 23], [7, 23], [7, 23], [7, 23], // 0000100xx
21249 [8, 47], [8, 47], // 00001010x
21250 [8, 48], [8, 48], // 00001011x
21251 [6, 13], [6, 13], [6, 13], [6, 13], // 000011xxx
21252 [6, 13], [6, 13], [6, 13], [6, 13],
21253 [7, 20], [7, 20], [7, 20], [7, 20], // 0001000xx
21254 [8, 33], [8, 33], // 00010010x
21255 [8, 34], [8, 34], // 00010011x
21256 [8, 35], [8, 35], // 00010100x
21257 [8, 36], [8, 36], // 00010101x
21258 [8, 37], [8, 37], // 00010110x
21259 [8, 38], [8, 38], // 00010111x
21260 [7, 19], [7, 19], [7, 19], [7, 19], // 0001100xx
21261 [8, 31], [8, 31], // 00011010x
21262 [8, 32], [8, 32], // 00011011x
21263 [6, 1], [6, 1], [6, 1], [6, 1], // 000111xxx
21264 [6, 1], [6, 1], [6, 1], [6, 1],
21265 [6, 12], [6, 12], [6, 12], [6, 12], // 001000xxx
21266 [6, 12], [6, 12], [6, 12], [6, 12],
21267 [8, 53], [8, 53], // 00100100x
21268 [8, 54], [8, 54], // 00100101x
21269 [7, 26], [7, 26], [7, 26], [7, 26], // 0010011xx
21270 [8, 39], [8, 39], // 00101000x
21271 [8, 40], [8, 40], // 00101001x
21272 [8, 41], [8, 41], // 00101010x
21273 [8, 42], [8, 42], // 00101011x
21274 [8, 43], [8, 43], // 00101100x
21275 [8, 44], [8, 44], // 00101101x
21276 [7, 21], [7, 21], [7, 21], [7, 21], // 0010111xx
21277 [7, 28], [7, 28], [7, 28], [7, 28], // 0011000xx
21278 [8, 61], [8, 61], // 00110010x
21279 [8, 62], [8, 62], // 00110011x
21280 [8, 63], [8, 63], // 00110100x
21281 [8, 0], [8, 0], // 00110101x
21282 [8, 320], [8, 320], // 00110110x
21283 [8, 384], [8, 384], // 00110111x
21284 [5, 10], [5, 10], [5, 10], [5, 10], // 00111xxxx
21285 [5, 10], [5, 10], [5, 10], [5, 10],
21286 [5, 10], [5, 10], [5, 10], [5, 10],
21287 [5, 10], [5, 10], [5, 10], [5, 10],
21288 [5, 11], [5, 11], [5, 11], [5, 11], // 01000xxxx
21289 [5, 11], [5, 11], [5, 11], [5, 11],
21290 [5, 11], [5, 11], [5, 11], [5, 11],
21291 [5, 11], [5, 11], [5, 11], [5, 11],
21292 [7, 27], [7, 27], [7, 27], [7, 27], // 0100100xx
21293 [8, 59], [8, 59], // 01001010x
21294 [8, 60], [8, 60], // 01001011x
21295 [9, 1472], // 010011000
21296 [9, 1536], // 010011001
21297 [9, 1600], // 010011010
21298 [9, 1728], // 010011011
21299 [7, 18], [7, 18], [7, 18], [7, 18], // 0100111xx
21300 [7, 24], [7, 24], [7, 24], [7, 24], // 0101000xx
21301 [8, 49], [8, 49], // 01010010x
21302 [8, 50], [8, 50], // 01010011x
21303 [8, 51], [8, 51], // 01010100x
21304 [8, 52], [8, 52], // 01010101x
21305 [7, 25], [7, 25], [7, 25], [7, 25], // 0101011xx
21306 [8, 55], [8, 55], // 01011000x
21307 [8, 56], [8, 56], // 01011001x
21308 [8, 57], [8, 57], // 01011010x
21309 [8, 58], [8, 58], // 01011011x
21310 [6, 192], [6, 192], [6, 192], [6, 192], // 010111xxx
21311 [6, 192], [6, 192], [6, 192], [6, 192],
21312 [6, 1664], [6, 1664], [6, 1664], [6, 1664], // 011000xxx
21313 [6, 1664], [6, 1664], [6, 1664], [6, 1664],
21314 [8, 448], [8, 448], // 01100100x
21315 [8, 512], [8, 512], // 01100101x
21316 [9, 704], // 011001100
21317 [9, 768], // 011001101
21318 [8, 640], [8, 640], // 01100111x
21319 [8, 576], [8, 576], // 01101000x
21320 [9, 832], // 011010010
21321 [9, 896], // 011010011
21322 [9, 960], // 011010100
21323 [9, 1024], // 011010101
21324 [9, 1088], // 011010110
21325 [9, 1152], // 011010111
21326 [9, 1216], // 011011000
21327 [9, 1280], // 011011001
21328 [9, 1344], // 011011010
21329 [9, 1408], // 011011011
21330 [7, 256], [7, 256], [7, 256], [7, 256], // 0110111xx
21331 [4, 2], [4, 2], [4, 2], [4, 2], // 0111xxxxx
21332 [4, 2], [4, 2], [4, 2], [4, 2],
21333 [4, 2], [4, 2], [4, 2], [4, 2],
21334 [4, 2], [4, 2], [4, 2], [4, 2],
21335 [4, 2], [4, 2], [4, 2], [4, 2],
21336 [4, 2], [4, 2], [4, 2], [4, 2],
21337 [4, 2], [4, 2], [4, 2], [4, 2],
21338 [4, 2], [4, 2], [4, 2], [4, 2],
21339 [4, 3], [4, 3], [4, 3], [4, 3], // 1000xxxxx
21340 [4, 3], [4, 3], [4, 3], [4, 3],
21341 [4, 3], [4, 3], [4, 3], [4, 3],
21342 [4, 3], [4, 3], [4, 3], [4, 3],
21343 [4, 3], [4, 3], [4, 3], [4, 3],
21344 [4, 3], [4, 3], [4, 3], [4, 3],
21345 [4, 3], [4, 3], [4, 3], [4, 3],
21346 [4, 3], [4, 3], [4, 3], [4, 3],
21347 [5, 128], [5, 128], [5, 128], [5, 128], // 10010xxxx
21348 [5, 128], [5, 128], [5, 128], [5, 128],
21349 [5, 128], [5, 128], [5, 128], [5, 128],
21350 [5, 128], [5, 128], [5, 128], [5, 128],
21351 [5, 8], [5, 8], [5, 8], [5, 8], // 10011xxxx
21352 [5, 8], [5, 8], [5, 8], [5, 8],
21353 [5, 8], [5, 8], [5, 8], [5, 8],
21354 [5, 8], [5, 8], [5, 8], [5, 8],
21355 [5, 9], [5, 9], [5, 9], [5, 9], // 10100xxxx
21356 [5, 9], [5, 9], [5, 9], [5, 9],
21357 [5, 9], [5, 9], [5, 9], [5, 9],
21358 [5, 9], [5, 9], [5, 9], [5, 9],
21359 [6, 16], [6, 16], [6, 16], [6, 16], // 101010xxx
21360 [6, 16], [6, 16], [6, 16], [6, 16],
21361 [6, 17], [6, 17], [6, 17], [6, 17], // 101011xxx
21362 [6, 17], [6, 17], [6, 17], [6, 17],
21363 [4, 4], [4, 4], [4, 4], [4, 4], // 1011xxxxx
21364 [4, 4], [4, 4], [4, 4], [4, 4],
21365 [4, 4], [4, 4], [4, 4], [4, 4],
21366 [4, 4], [4, 4], [4, 4], [4, 4],
21367 [4, 4], [4, 4], [4, 4], [4, 4],
21368 [4, 4], [4, 4], [4, 4], [4, 4],
21369 [4, 4], [4, 4], [4, 4], [4, 4],
21370 [4, 4], [4, 4], [4, 4], [4, 4],
21371 [4, 5], [4, 5], [4, 5], [4, 5], // 1100xxxxx
21372 [4, 5], [4, 5], [4, 5], [4, 5],
21373 [4, 5], [4, 5], [4, 5], [4, 5],
21374 [4, 5], [4, 5], [4, 5], [4, 5],
21375 [4, 5], [4, 5], [4, 5], [4, 5],
21376 [4, 5], [4, 5], [4, 5], [4, 5],
21377 [4, 5], [4, 5], [4, 5], [4, 5],
21378 [4, 5], [4, 5], [4, 5], [4, 5],
21379 [6, 14], [6, 14], [6, 14], [6, 14], // 110100xxx
21380 [6, 14], [6, 14], [6, 14], [6, 14],
21381 [6, 15], [6, 15], [6, 15], [6, 15], // 110101xxx
21382 [6, 15], [6, 15], [6, 15], [6, 15],
21383 [5, 64], [5, 64], [5, 64], [5, 64], // 11011xxxx
21384 [5, 64], [5, 64], [5, 64], [5, 64],
21385 [5, 64], [5, 64], [5, 64], [5, 64],
21386 [5, 64], [5, 64], [5, 64], [5, 64],
21387 [4, 6], [4, 6], [4, 6], [4, 6], // 1110xxxxx
21388 [4, 6], [4, 6], [4, 6], [4, 6],
21389 [4, 6], [4, 6], [4, 6], [4, 6],
21390 [4, 6], [4, 6], [4, 6], [4, 6],
21391 [4, 6], [4, 6], [4, 6], [4, 6],
21392 [4, 6], [4, 6], [4, 6], [4, 6],
21393 [4, 6], [4, 6], [4, 6], [4, 6],
21394 [4, 6], [4, 6], [4, 6], [4, 6],
21395 [4, 7], [4, 7], [4, 7], [4, 7], // 1111xxxxx
21396 [4, 7], [4, 7], [4, 7], [4, 7],
21397 [4, 7], [4, 7], [4, 7], [4, 7],
21398 [4, 7], [4, 7], [4, 7], [4, 7],
21399 [4, 7], [4, 7], [4, 7], [4, 7],
21400 [4, 7], [4, 7], [4, 7], [4, 7],
21401 [4, 7], [4, 7], [4, 7], [4, 7],
21402 [4, 7], [4, 7], [4, 7], [4, 7]
21403 ];
21404
21405 var blackTable1 = [
21406 [-1, -1], [-1, -1], // 000000000000x
21407 [12, ccittEOL], [12, ccittEOL], // 000000000001x
21408 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 00000000001xx
21409 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 00000000010xx
21410 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 00000000011xx
21411 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 00000000100xx
21412 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 00000000101xx
21413 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 00000000110xx
21414 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 00000000111xx
21415 [11, 1792], [11, 1792], [11, 1792], [11, 1792], // 00000001000xx
21416 [12, 1984], [12, 1984], // 000000010010x
21417 [12, 2048], [12, 2048], // 000000010011x
21418 [12, 2112], [12, 2112], // 000000010100x
21419 [12, 2176], [12, 2176], // 000000010101x
21420 [12, 2240], [12, 2240], // 000000010110x
21421 [12, 2304], [12, 2304], // 000000010111x
21422 [11, 1856], [11, 1856], [11, 1856], [11, 1856], // 00000001100xx
21423 [11, 1920], [11, 1920], [11, 1920], [11, 1920], // 00000001101xx
21424 [12, 2368], [12, 2368], // 000000011100x
21425 [12, 2432], [12, 2432], // 000000011101x
21426 [12, 2496], [12, 2496], // 000000011110x
21427 [12, 2560], [12, 2560], // 000000011111x
21428 [10, 18], [10, 18], [10, 18], [10, 18], // 0000001000xxx
21429 [10, 18], [10, 18], [10, 18], [10, 18],
21430 [12, 52], [12, 52], // 000000100100x
21431 [13, 640], // 0000001001010
21432 [13, 704], // 0000001001011
21433 [13, 768], // 0000001001100
21434 [13, 832], // 0000001001101
21435 [12, 55], [12, 55], // 000000100111x
21436 [12, 56], [12, 56], // 000000101000x
21437 [13, 1280], // 0000001010010
21438 [13, 1344], // 0000001010011
21439 [13, 1408], // 0000001010100
21440 [13, 1472], // 0000001010101
21441 [12, 59], [12, 59], // 000000101011x
21442 [12, 60], [12, 60], // 000000101100x
21443 [13, 1536], // 0000001011010
21444 [13, 1600], // 0000001011011
21445 [11, 24], [11, 24], [11, 24], [11, 24], // 00000010111xx
21446 [11, 25], [11, 25], [11, 25], [11, 25], // 00000011000xx
21447 [13, 1664], // 0000001100100
21448 [13, 1728], // 0000001100101
21449 [12, 320], [12, 320], // 000000110011x
21450 [12, 384], [12, 384], // 000000110100x
21451 [12, 448], [12, 448], // 000000110101x
21452 [13, 512], // 0000001101100
21453 [13, 576], // 0000001101101
21454 [12, 53], [12, 53], // 000000110111x
21455 [12, 54], [12, 54], // 000000111000x
21456 [13, 896], // 0000001110010
21457 [13, 960], // 0000001110011
21458 [13, 1024], // 0000001110100
21459 [13, 1088], // 0000001110101
21460 [13, 1152], // 0000001110110
21461 [13, 1216], // 0000001110111
21462 [10, 64], [10, 64], [10, 64], [10, 64], // 0000001111xxx
21463 [10, 64], [10, 64], [10, 64], [10, 64]
21464 ];
21465
21466 var blackTable2 = [
21467 [8, 13], [8, 13], [8, 13], [8, 13], // 00000100xxxx
21468 [8, 13], [8, 13], [8, 13], [8, 13],
21469 [8, 13], [8, 13], [8, 13], [8, 13],
21470 [8, 13], [8, 13], [8, 13], [8, 13],
21471 [11, 23], [11, 23], // 00000101000x
21472 [12, 50], // 000001010010
21473 [12, 51], // 000001010011
21474 [12, 44], // 000001010100
21475 [12, 45], // 000001010101
21476 [12, 46], // 000001010110
21477 [12, 47], // 000001010111
21478 [12, 57], // 000001011000
21479 [12, 58], // 000001011001
21480 [12, 61], // 000001011010
21481 [12, 256], // 000001011011
21482 [10, 16], [10, 16], [10, 16], [10, 16], // 0000010111xx
21483 [10, 17], [10, 17], [10, 17], [10, 17], // 0000011000xx
21484 [12, 48], // 000001100100
21485 [12, 49], // 000001100101
21486 [12, 62], // 000001100110
21487 [12, 63], // 000001100111
21488 [12, 30], // 000001101000
21489 [12, 31], // 000001101001
21490 [12, 32], // 000001101010
21491 [12, 33], // 000001101011
21492 [12, 40], // 000001101100
21493 [12, 41], // 000001101101
21494 [11, 22], [11, 22], // 00000110111x
21495 [8, 14], [8, 14], [8, 14], [8, 14], // 00000111xxxx
21496 [8, 14], [8, 14], [8, 14], [8, 14],
21497 [8, 14], [8, 14], [8, 14], [8, 14],
21498 [8, 14], [8, 14], [8, 14], [8, 14],
21499 [7, 10], [7, 10], [7, 10], [7, 10], // 0000100xxxxx
21500 [7, 10], [7, 10], [7, 10], [7, 10],
21501 [7, 10], [7, 10], [7, 10], [7, 10],
21502 [7, 10], [7, 10], [7, 10], [7, 10],
21503 [7, 10], [7, 10], [7, 10], [7, 10],
21504 [7, 10], [7, 10], [7, 10], [7, 10],
21505 [7, 10], [7, 10], [7, 10], [7, 10],
21506 [7, 10], [7, 10], [7, 10], [7, 10],
21507 [7, 11], [7, 11], [7, 11], [7, 11], // 0000101xxxxx
21508 [7, 11], [7, 11], [7, 11], [7, 11],
21509 [7, 11], [7, 11], [7, 11], [7, 11],
21510 [7, 11], [7, 11], [7, 11], [7, 11],
21511 [7, 11], [7, 11], [7, 11], [7, 11],
21512 [7, 11], [7, 11], [7, 11], [7, 11],
21513 [7, 11], [7, 11], [7, 11], [7, 11],
21514 [7, 11], [7, 11], [7, 11], [7, 11],
21515 [9, 15], [9, 15], [9, 15], [9, 15], // 000011000xxx
21516 [9, 15], [9, 15], [9, 15], [9, 15],
21517 [12, 128], // 000011001000
21518 [12, 192], // 000011001001
21519 [12, 26], // 000011001010
21520 [12, 27], // 000011001011
21521 [12, 28], // 000011001100
21522 [12, 29], // 000011001101
21523 [11, 19], [11, 19], // 00001100111x
21524 [11, 20], [11, 20], // 00001101000x
21525 [12, 34], // 000011010010
21526 [12, 35], // 000011010011
21527 [12, 36], // 000011010100
21528 [12, 37], // 000011010101
21529 [12, 38], // 000011010110
21530 [12, 39], // 000011010111
21531 [11, 21], [11, 21], // 00001101100x
21532 [12, 42], // 000011011010
21533 [12, 43], // 000011011011
21534 [10, 0], [10, 0], [10, 0], [10, 0], // 0000110111xx
21535 [7, 12], [7, 12], [7, 12], [7, 12], // 0000111xxxxx
21536 [7, 12], [7, 12], [7, 12], [7, 12],
21537 [7, 12], [7, 12], [7, 12], [7, 12],
21538 [7, 12], [7, 12], [7, 12], [7, 12],
21539 [7, 12], [7, 12], [7, 12], [7, 12],
21540 [7, 12], [7, 12], [7, 12], [7, 12],
21541 [7, 12], [7, 12], [7, 12], [7, 12],
21542 [7, 12], [7, 12], [7, 12], [7, 12]
21543 ];
21544
21545 var blackTable3 = [
21546 [-1, -1], [-1, -1], [-1, -1], [-1, -1], // 0000xx
21547 [6, 9], // 000100
21548 [6, 8], // 000101
21549 [5, 7], [5, 7], // 00011x
21550 [4, 6], [4, 6], [4, 6], [4, 6], // 0010xx
21551 [4, 5], [4, 5], [4, 5], [4, 5], // 0011xx
21552 [3, 1], [3, 1], [3, 1], [3, 1], // 010xxx
21553 [3, 1], [3, 1], [3, 1], [3, 1],
21554 [3, 4], [3, 4], [3, 4], [3, 4], // 011xxx
21555 [3, 4], [3, 4], [3, 4], [3, 4],
21556 [2, 3], [2, 3], [2, 3], [2, 3], // 10xxxx
21557 [2, 3], [2, 3], [2, 3], [2, 3],
21558 [2, 3], [2, 3], [2, 3], [2, 3],
21559 [2, 3], [2, 3], [2, 3], [2, 3],
21560 [2, 2], [2, 2], [2, 2], [2, 2], // 11xxxx
21561 [2, 2], [2, 2], [2, 2], [2, 2],
21562 [2, 2], [2, 2], [2, 2], [2, 2],
21563 [2, 2], [2, 2], [2, 2], [2, 2]
21564 ];
21565
21566 function CCITTFaxStream(str, maybeLength, params) {
21567 this.str = str;
21568 this.dict = str.dict;
21569
21570 params = params || Dict.empty;
21571
21572 this.encoding = params.get('K') || 0;
21573 this.eoline = params.get('EndOfLine') || false;
21574 this.byteAlign = params.get('EncodedByteAlign') || false;
21575 this.columns = params.get('Columns') || 1728;
21576 this.rows = params.get('Rows') || 0;
21577 var eoblock = params.get('EndOfBlock');
21578 if (eoblock === null || eoblock === undefined) {
21579 eoblock = true;
21580 }
21581 this.eoblock = eoblock;
21582 this.black = params.get('BlackIs1') || false;
21583
21584 this.codingLine = new Uint32Array(this.columns + 1);
21585 this.refLine = new Uint32Array(this.columns + 2);
21586
21587 this.codingLine[0] = this.columns;
21588 this.codingPos = 0;
21589
21590 this.row = 0;
21591 this.nextLine2D = this.encoding < 0;
21592 this.inputBits = 0;
21593 this.inputBuf = 0;
21594 this.outputBits = 0;
21595
21596 var code1;
21597 while ((code1 = this.lookBits(12)) === 0) {
21598 this.eatBits(1);
21599 }
21600 if (code1 === 1) {
21601 this.eatBits(12);
21602 }
21603 if (this.encoding > 0) {
21604 this.nextLine2D = !this.lookBits(1);
21605 this.eatBits(1);
21606 }
21607
21608 DecodeStream.call(this, maybeLength);
21609 }
21610
21611 CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
21612
21613 CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
21614 while (!this.eof) {
21615 var c = this.lookChar();
21616 this.ensureBuffer(this.bufferLength + 1);
21617 this.buffer[this.bufferLength++] = c;
21618 }
21619 };
21620
21621 CCITTFaxStream.prototype.addPixels =
21622 function ccittFaxStreamAddPixels(a1, blackPixels) {
21623 var codingLine = this.codingLine;
21624 var codingPos = this.codingPos;
21625
21626 if (a1 > codingLine[codingPos]) {
21627 if (a1 > this.columns) {
21628 info('row is wrong length');
21629 this.err = true;
21630 a1 = this.columns;
21631 }
21632 if ((codingPos & 1) ^ blackPixels) {
21633 ++codingPos;
21634 }
21635
21636 codingLine[codingPos] = a1;
21637 }
21638 this.codingPos = codingPos;
21639 };
21640
21641 CCITTFaxStream.prototype.addPixelsNeg =
21642 function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
21643 var codingLine = this.codingLine;
21644 var codingPos = this.codingPos;
21645
21646 if (a1 > codingLine[codingPos]) {
21647 if (a1 > this.columns) {
21648 info('row is wrong length');
21649 this.err = true;
21650 a1 = this.columns;
21651 }
21652 if ((codingPos & 1) ^ blackPixels) {
21653 ++codingPos;
21654 }
21655
21656 codingLine[codingPos] = a1;
21657 } else if (a1 < codingLine[codingPos]) {
21658 if (a1 < 0) {
21659 info('invalid code');
21660 this.err = true;
21661 a1 = 0;
21662 }
21663 while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
21664 --codingPos;
21665 }
21666 codingLine[codingPos] = a1;
21667 }
21668
21669 this.codingPos = codingPos;
21670 };
21671
21672 CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
21673 var refLine = this.refLine;
21674 var codingLine = this.codingLine;
21675 var columns = this.columns;
21676
21677 var refPos, blackPixels, bits, i;
21678
21679 if (this.outputBits === 0) {
21680 if (this.eof) {
21681 return null;
21682 }
21683 this.err = false;
21684
21685 var code1, code2, code3;
21686 if (this.nextLine2D) {
21687 for (i = 0; codingLine[i] < columns; ++i) {
21688 refLine[i] = codingLine[i];
21689 }
21690 refLine[i++] = columns;
21691 refLine[i] = columns;
21692 codingLine[0] = 0;
21693 this.codingPos = 0;
21694 refPos = 0;
21695 blackPixels = 0;
21696
21697 while (codingLine[this.codingPos] < columns) {
21698 code1 = this.getTwoDimCode();
21699 switch (code1) {
21700 case twoDimPass:
21701 this.addPixels(refLine[refPos + 1], blackPixels);
21702 if (refLine[refPos + 1] < columns) {
21703 refPos += 2;
21704 }
21705 break;
21706 case twoDimHoriz:
21707 code1 = code2 = 0;
21708 if (blackPixels) {
21709 do {
21710 code1 += (code3 = this.getBlackCode());
21711 } while (code3 >= 64);
21712 do {
21713 code2 += (code3 = this.getWhiteCode());
21714 } while (code3 >= 64);
21715 } else {
21716 do {
21717 code1 += (code3 = this.getWhiteCode());
21718 } while (code3 >= 64);
21719 do {
21720 code2 += (code3 = this.getBlackCode());
21721 } while (code3 >= 64);
21722 }
21723 this.addPixels(codingLine[this.codingPos] +
21724 code1, blackPixels);
21725 if (codingLine[this.codingPos] < columns) {
21726 this.addPixels(codingLine[this.codingPos] + code2,
21727 blackPixels ^ 1);
21728 }
21729 while (refLine[refPos] <= codingLine[this.codingPos] &&
21730 refLine[refPos] < columns) {
21731 refPos += 2;
21732 }
21733 break;
21734 case twoDimVertR3:
21735 this.addPixels(refLine[refPos] + 3, blackPixels);
21736 blackPixels ^= 1;
21737 if (codingLine[this.codingPos] < columns) {
21738 ++refPos;
21739 while (refLine[refPos] <= codingLine[this.codingPos] &&
21740 refLine[refPos] < columns) {
21741 refPos += 2;
21742 }
21743 }
21744 break;
21745 case twoDimVertR2:
21746 this.addPixels(refLine[refPos] + 2, blackPixels);
21747 blackPixels ^= 1;
21748 if (codingLine[this.codingPos] < columns) {
21749 ++refPos;
21750 while (refLine[refPos] <= codingLine[this.codingPos] &&
21751 refLine[refPos] < columns) {
21752 refPos += 2;
21753 }
21754 }
21755 break;
21756 case twoDimVertR1:
21757 this.addPixels(refLine[refPos] + 1, blackPixels);
21758 blackPixels ^= 1;
21759 if (codingLine[this.codingPos] < columns) {
21760 ++refPos;
21761 while (refLine[refPos] <= codingLine[this.codingPos] &&
21762 refLine[refPos] < columns) {
21763 refPos += 2;
21764 }
21765 }
21766 break;
21767 case twoDimVert0:
21768 this.addPixels(refLine[refPos], blackPixels);
21769 blackPixels ^= 1;
21770 if (codingLine[this.codingPos] < columns) {
21771 ++refPos;
21772 while (refLine[refPos] <= codingLine[this.codingPos] &&
21773 refLine[refPos] < columns) {
21774 refPos += 2;
21775 }
21776 }
21777 break;
21778 case twoDimVertL3:
21779 this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
21780 blackPixels ^= 1;
21781 if (codingLine[this.codingPos] < columns) {
21782 if (refPos > 0) {
21783 --refPos;
21784 } else {
21785 ++refPos;
21786 }
21787 while (refLine[refPos] <= codingLine[this.codingPos] &&
21788 refLine[refPos] < columns) {
21789 refPos += 2;
21790 }
21791 }
21792 break;
21793 case twoDimVertL2:
21794 this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
21795 blackPixels ^= 1;
21796 if (codingLine[this.codingPos] < columns) {
21797 if (refPos > 0) {
21798 --refPos;
21799 } else {
21800 ++refPos;
21801 }
21802 while (refLine[refPos] <= codingLine[this.codingPos] &&
21803 refLine[refPos] < columns) {
21804 refPos += 2;
21805 }
21806 }
21807 break;
21808 case twoDimVertL1:
21809 this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
21810 blackPixels ^= 1;
21811 if (codingLine[this.codingPos] < columns) {
21812 if (refPos > 0) {
21813 --refPos;
21814 } else {
21815 ++refPos;
21816 }
21817 while (refLine[refPos] <= codingLine[this.codingPos] &&
21818 refLine[refPos] < columns) {
21819 refPos += 2;
21820 }
21821 }
21822 break;
21823 case ccittEOF:
21824 this.addPixels(columns, 0);
21825 this.eof = true;
21826 break;
21827 default:
21828 info('bad 2d code');
21829 this.addPixels(columns, 0);
21830 this.err = true;
21831 }
21832 }
21833 } else {
21834 codingLine[0] = 0;
21835 this.codingPos = 0;
21836 blackPixels = 0;
21837 while (codingLine[this.codingPos] < columns) {
21838 code1 = 0;
21839 if (blackPixels) {
21840 do {
21841 code1 += (code3 = this.getBlackCode());
21842 } while (code3 >= 64);
21843 } else {
21844 do {
21845 code1 += (code3 = this.getWhiteCode());
21846 } while (code3 >= 64);
21847 }
21848 this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
21849 blackPixels ^= 1;
21850 }
21851 }
21852
21853 var gotEOL = false;
21854
21855 if (this.byteAlign) {
21856 this.inputBits &= ~7;
21857 }
21858
21859 if (!this.eoblock && this.row === this.rows - 1) {
21860 this.eof = true;
21861 } else {
21862 code1 = this.lookBits(12);
21863 if (this.eoline) {
21864 while (code1 !== ccittEOF && code1 !== 1) {
21865 this.eatBits(1);
21866 code1 = this.lookBits(12);
21867 }
21868 } else {
21869 while (code1 === 0) {
21870 this.eatBits(1);
21871 code1 = this.lookBits(12);
21872 }
21873 }
21874 if (code1 === 1) {
21875 this.eatBits(12);
21876 gotEOL = true;
21877 } else if (code1 === ccittEOF) {
21878 this.eof = true;
21879 }
21880 }
21881
21882 if (!this.eof && this.encoding > 0) {
21883 this.nextLine2D = !this.lookBits(1);
21884 this.eatBits(1);
21885 }
21886
21887 if (this.eoblock && gotEOL && this.byteAlign) {
21888 code1 = this.lookBits(12);
21889 if (code1 === 1) {
21890 this.eatBits(12);
21891 if (this.encoding > 0) {
21892 this.lookBits(1);
21893 this.eatBits(1);
21894 }
21895 if (this.encoding >= 0) {
21896 for (i = 0; i < 4; ++i) {
21897 code1 = this.lookBits(12);
21898 if (code1 !== 1) {
21899 info('bad rtc code: ' + code1);
21900 }
21901 this.eatBits(12);
21902 if (this.encoding > 0) {
21903 this.lookBits(1);
21904 this.eatBits(1);
21905 }
21906 }
21907 }
21908 this.eof = true;
21909 }
21910 } else if (this.err && this.eoline) {
21911 while (true) {
21912 code1 = this.lookBits(13);
21913 if (code1 === ccittEOF) {
21914 this.eof = true;
21915 return null;
21916 }
21917 if ((code1 >> 1) === 1) {
21918 break;
21919 }
21920 this.eatBits(1);
21921 }
21922 this.eatBits(12);
21923 if (this.encoding > 0) {
21924 this.eatBits(1);
21925 this.nextLine2D = !(code1 & 1);
21926 }
21927 }
21928
21929 if (codingLine[0] > 0) {
21930 this.outputBits = codingLine[this.codingPos = 0];
21931 } else {
21932 this.outputBits = codingLine[this.codingPos = 1];
21933 }
21934 this.row++;
21935 }
21936
21937 var c;
21938 if (this.outputBits >= 8) {
21939 c = (this.codingPos & 1) ? 0 : 0xFF;
21940 this.outputBits -= 8;
21941 if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
21942 this.codingPos++;
21943 this.outputBits = (codingLine[this.codingPos] -
21944 codingLine[this.codingPos - 1]);
21945 }
21946 } else {
21947 bits = 8;
21948 c = 0;
21949 do {
21950 if (this.outputBits > bits) {
21951 c <<= bits;
21952 if (!(this.codingPos & 1)) {
21953 c |= 0xFF >> (8 - bits);
21954 }
21955 this.outputBits -= bits;
21956 bits = 0;
21957 } else {
21958 c <<= this.outputBits;
21959 if (!(this.codingPos & 1)) {
21960 c |= 0xFF >> (8 - this.outputBits);
21961 }
21962 bits -= this.outputBits;
21963 this.outputBits = 0;
21964 if (codingLine[this.codingPos] < columns) {
21965 this.codingPos++;
21966 this.outputBits = (codingLine[this.codingPos] -
21967 codingLine[this.codingPos - 1]);
21968 } else if (bits > 0) {
21969 c <<= bits;
21970 bits = 0;
21971 }
21972 }
21973 } while (bits);
21974 }
21975 if (this.black) {
21976 c ^= 0xFF;
21977 }
21978 return c;
21979 };
21980
21981 // This functions returns the code found from the table.
21982 // The start and end parameters set the boundaries for searching the table.
21983 // The limit parameter is optional. Function returns an array with three
21984 // values. The first array element indicates whether a valid code is being
21985 // returned. The second array element is the actual code. The third array
21986 // element indicates whether EOF was reached.
21987 CCITTFaxStream.prototype.findTableCode =
21988 function ccittFaxStreamFindTableCode(start, end, table, limit) {
21989
21990 var limitValue = limit || 0;
21991 for (var i = start; i <= end; ++i) {
21992 var code = this.lookBits(i);
21993 if (code === ccittEOF) {
21994 return [true, 1, false];
21995 }
21996 if (i < end) {
21997 code <<= end - i;
21998 }
21999 if (!limitValue || code >= limitValue) {
22000 var p = table[code - limitValue];
22001 if (p[0] === i) {
22002 this.eatBits(i);
22003 return [true, p[1], true];
22004 }
22005 }
22006 }
22007 return [false, 0, false];
22008 };
22009
22010 CCITTFaxStream.prototype.getTwoDimCode =
22011 function ccittFaxStreamGetTwoDimCode() {
22012
22013 var code = 0;
22014 var p;
22015 if (this.eoblock) {
22016 code = this.lookBits(7);
22017 p = twoDimTable[code];
22018 if (p && p[0] > 0) {
22019 this.eatBits(p[0]);
22020 return p[1];
22021 }
22022 } else {
22023 var result = this.findTableCode(1, 7, twoDimTable);
22024 if (result[0] && result[2]) {
22025 return result[1];
22026 }
22027 }
22028 info('Bad two dim code');
22029 return ccittEOF;
22030 };
22031
22032 CCITTFaxStream.prototype.getWhiteCode =
22033 function ccittFaxStreamGetWhiteCode() {
22034
22035 var code = 0;
22036 var p;
22037 if (this.eoblock) {
22038 code = this.lookBits(12);
22039 if (code === ccittEOF) {
22040 return 1;
22041 }
22042
22043 if ((code >> 5) === 0) {
22044 p = whiteTable1[code];
22045 } else {
22046 p = whiteTable2[code >> 3];
22047 }
22048
22049 if (p[0] > 0) {
22050 this.eatBits(p[0]);
22051 return p[1];
22052 }
22053 } else {
22054 var result = this.findTableCode(1, 9, whiteTable2);
22055 if (result[0]) {
22056 return result[1];
22057 }
22058
22059 result = this.findTableCode(11, 12, whiteTable1);
22060 if (result[0]) {
22061 return result[1];
22062 }
22063 }
22064 info('bad white code');
22065 this.eatBits(1);
22066 return 1;
22067 };
22068
22069 CCITTFaxStream.prototype.getBlackCode =
22070 function ccittFaxStreamGetBlackCode() {
22071
22072 var code, p;
22073 if (this.eoblock) {
22074 code = this.lookBits(13);
22075 if (code === ccittEOF) {
22076 return 1;
22077 }
22078 if ((code >> 7) === 0) {
22079 p = blackTable1[code];
22080 } else if ((code >> 9) === 0 && (code >> 7) !== 0) {
22081 p = blackTable2[(code >> 1) - 64];
22082 } else {
22083 p = blackTable3[code >> 7];
22084 }
22085
22086 if (p[0] > 0) {
22087 this.eatBits(p[0]);
22088 return p[1];
22089 }
22090 } else {
22091 var result = this.findTableCode(2, 6, blackTable3);
22092 if (result[0]) {
22093 return result[1];
22094 }
22095
22096 result = this.findTableCode(7, 12, blackTable2, 64);
22097 if (result[0]) {
22098 return result[1];
22099 }
22100
22101 result = this.findTableCode(10, 13, blackTable1);
22102 if (result[0]) {
22103 return result[1];
22104 }
22105 }
22106 info('bad black code');
22107 this.eatBits(1);
22108 return 1;
22109 };
22110
22111 CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
22112 var c;
22113 while (this.inputBits < n) {
22114 if ((c = this.str.getByte()) === -1) {
22115 if (this.inputBits === 0) {
22116 return ccittEOF;
22117 }
22118 return ((this.inputBuf << (n - this.inputBits)) &
22119 (0xFFFF >> (16 - n)));
22120 }
22121 this.inputBuf = (this.inputBuf << 8) | c;
22122 this.inputBits += 8;
22123 }
22124 return (this.inputBuf >> (this.inputBits - n)) & (0xFFFF >> (16 - n));
22125 };
22126
22127 CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
22128 if ((this.inputBits -= n) < 0) {
22129 this.inputBits = 0;
22130 }
22131 };
22132
22133 return CCITTFaxStream;
22134})();
22135
22136var LZWStream = (function LZWStreamClosure() {
22137 function LZWStream(str, maybeLength, earlyChange) {
22138 this.str = str;
22139 this.dict = str.dict;
22140 this.cachedData = 0;
22141 this.bitsCached = 0;
22142
22143 var maxLzwDictionarySize = 4096;
22144 var lzwState = {
22145 earlyChange: earlyChange,
22146 codeLength: 9,
22147 nextCode: 258,
22148 dictionaryValues: new Uint8Array(maxLzwDictionarySize),
22149 dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
22150 dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
22151 currentSequence: new Uint8Array(maxLzwDictionarySize),
22152 currentSequenceLength: 0
22153 };
22154 for (var i = 0; i < 256; ++i) {
22155 lzwState.dictionaryValues[i] = i;
22156 lzwState.dictionaryLengths[i] = 1;
22157 }
22158 this.lzwState = lzwState;
22159
22160 DecodeStream.call(this, maybeLength);
22161 }
22162
22163 LZWStream.prototype = Object.create(DecodeStream.prototype);
22164
22165 LZWStream.prototype.readBits = function LZWStream_readBits(n) {
22166 var bitsCached = this.bitsCached;
22167 var cachedData = this.cachedData;
22168 while (bitsCached < n) {
22169 var c = this.str.getByte();
22170 if (c === -1) {
22171 this.eof = true;
22172 return null;
22173 }
22174 cachedData = (cachedData << 8) | c;
22175 bitsCached += 8;
22176 }
22177 this.bitsCached = (bitsCached -= n);
22178 this.cachedData = cachedData;
22179 this.lastCode = null;
22180 return (cachedData >>> bitsCached) & ((1 << n) - 1);
22181 };
22182
22183 LZWStream.prototype.readBlock = function LZWStream_readBlock() {
22184 var blockSize = 512;
22185 var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
22186 var i, j, q;
22187
22188 var lzwState = this.lzwState;
22189 if (!lzwState) {
22190 return; // eof was found
22191 }
22192
22193 var earlyChange = lzwState.earlyChange;
22194 var nextCode = lzwState.nextCode;
22195 var dictionaryValues = lzwState.dictionaryValues;
22196 var dictionaryLengths = lzwState.dictionaryLengths;
22197 var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
22198 var codeLength = lzwState.codeLength;
22199 var prevCode = lzwState.prevCode;
22200 var currentSequence = lzwState.currentSequence;
22201 var currentSequenceLength = lzwState.currentSequenceLength;
22202
22203 var decodedLength = 0;
22204 var currentBufferLength = this.bufferLength;
22205 var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
22206
22207 for (i = 0; i < blockSize; i++) {
22208 var code = this.readBits(codeLength);
22209 var hasPrev = currentSequenceLength > 0;
22210 if (code < 256) {
22211 currentSequence[0] = code;
22212 currentSequenceLength = 1;
22213 } else if (code >= 258) {
22214 if (code < nextCode) {
22215 currentSequenceLength = dictionaryLengths[code];
22216 for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
22217 currentSequence[j] = dictionaryValues[q];
22218 q = dictionaryPrevCodes[q];
22219 }
22220 } else {
22221 currentSequence[currentSequenceLength++] = currentSequence[0];
22222 }
22223 } else if (code === 256) {
22224 codeLength = 9;
22225 nextCode = 258;
22226 currentSequenceLength = 0;
22227 continue;
22228 } else {
22229 this.eof = true;
22230 delete this.lzwState;
22231 break;
22232 }
22233
22234 if (hasPrev) {
22235 dictionaryPrevCodes[nextCode] = prevCode;
22236 dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
22237 dictionaryValues[nextCode] = currentSequence[0];
22238 nextCode++;
22239 codeLength = (nextCode + earlyChange) & (nextCode + earlyChange - 1) ?
22240 codeLength : Math.min(Math.log(nextCode + earlyChange) /
22241 0.6931471805599453 + 1, 12) | 0;
22242 }
22243 prevCode = code;
22244
22245 decodedLength += currentSequenceLength;
22246 if (estimatedDecodedSize < decodedLength) {
22247 do {
22248 estimatedDecodedSize += decodedSizeDelta;
22249 } while (estimatedDecodedSize < decodedLength);
22250 buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
22251 }
22252 for (j = 0; j < currentSequenceLength; j++) {
22253 buffer[currentBufferLength++] = currentSequence[j];
22254 }
22255 }
22256 lzwState.nextCode = nextCode;
22257 lzwState.codeLength = codeLength;
22258 lzwState.prevCode = prevCode;
22259 lzwState.currentSequenceLength = currentSequenceLength;
22260
22261 this.bufferLength = currentBufferLength;
22262 };
22263
22264 return LZWStream;
22265})();
22266
22267var NullStream = (function NullStreamClosure() {
22268 function NullStream() {
22269 Stream.call(this, new Uint8Array(0));
22270 }
22271
22272 NullStream.prototype = Stream.prototype;
22273
22274 return NullStream;
22275})();
22276
22277exports.Ascii85Stream = Ascii85Stream;
22278exports.AsciiHexStream = AsciiHexStream;
22279exports.CCITTFaxStream = CCITTFaxStream;
22280exports.DecryptStream = DecryptStream;
22281exports.DecodeStream = DecodeStream;
22282exports.FlateStream = FlateStream;
22283exports.Jbig2Stream = Jbig2Stream;
22284exports.JpegStream = JpegStream;
22285exports.JpxStream = JpxStream;
22286exports.NullStream = NullStream;
22287exports.PredictorStream = PredictorStream;
22288exports.RunLengthStream = RunLengthStream;
22289exports.Stream = Stream;
22290exports.StreamsSequenceStream = StreamsSequenceStream;
22291exports.StringStream = StringStream;
22292exports.LZWStream = LZWStream;
22293}));
22294
22295
22296(function (root, factory) {
22297 {
22298 factory((root.pdfjsCoreCrypto = {}), root.pdfjsSharedUtil,
22299 root.pdfjsCorePrimitives, root.pdfjsCoreStream);
22300 }
22301}(this, function (exports, sharedUtil, corePrimitives, coreStream) {
22302
22303var PasswordException = sharedUtil.PasswordException;
22304var PasswordResponses = sharedUtil.PasswordResponses;
22305var bytesToString = sharedUtil.bytesToString;
22306var error = sharedUtil.error;
22307var isInt = sharedUtil.isInt;
22308var stringToBytes = sharedUtil.stringToBytes;
22309var utf8StringToString = sharedUtil.utf8StringToString;
22310var warn = sharedUtil.warn;
22311var Name = corePrimitives.Name;
22312var isName = corePrimitives.isName;
22313var isDict = corePrimitives.isDict;
22314var DecryptStream = coreStream.DecryptStream;
22315
22316var ARCFourCipher = (function ARCFourCipherClosure() {
22317 function ARCFourCipher(key) {
22318 this.a = 0;
22319 this.b = 0;
22320 var s = new Uint8Array(256);
22321 var i, j = 0, tmp, keyLength = key.length;
22322 for (i = 0; i < 256; ++i) {
22323 s[i] = i;
22324 }
22325 for (i = 0; i < 256; ++i) {
22326 tmp = s[i];
22327 j = (j + tmp + key[i % keyLength]) & 0xFF;
22328 s[i] = s[j];
22329 s[j] = tmp;
22330 }
22331 this.s = s;
22332 }
22333
22334 ARCFourCipher.prototype = {
22335 encryptBlock: function ARCFourCipher_encryptBlock(data) {
22336 var i, n = data.length, tmp, tmp2;
22337 var a = this.a, b = this.b, s = this.s;
22338 var output = new Uint8Array(n);
22339 for (i = 0; i < n; ++i) {
22340 a = (a + 1) & 0xFF;
22341 tmp = s[a];
22342 b = (b + tmp) & 0xFF;
22343 tmp2 = s[b];
22344 s[a] = tmp2;
22345 s[b] = tmp;
22346 output[i] = data[i] ^ s[(tmp + tmp2) & 0xFF];
22347 }
22348 this.a = a;
22349 this.b = b;
22350 return output;
22351 }
22352 };
22353 ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
22354
22355 return ARCFourCipher;
22356})();
22357
22358var calculateMD5 = (function calculateMD5Closure() {
22359 var r = new Uint8Array([
22360 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
22361 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
22362 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
22363 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21]);
22364
22365 var k = new Int32Array([
22366 -680876936, -389564586, 606105819, -1044525330, -176418897, 1200080426,
22367 -1473231341, -45705983, 1770035416, -1958414417, -42063, -1990404162,
22368 1804603682, -40341101, -1502002290, 1236535329, -165796510, -1069501632,
22369 643717713, -373897302, -701558691, 38016083, -660478335, -405537848,
22370 568446438, -1019803690, -187363961, 1163531501, -1444681467, -51403784,
22371 1735328473, -1926607734, -378558, -2022574463, 1839030562, -35309556,
22372 -1530992060, 1272893353, -155497632, -1094730640, 681279174, -358537222,
22373 -722521979, 76029189, -640364487, -421815835, 530742520, -995338651,
22374 -198630844, 1126891415, -1416354905, -57434055, 1700485571, -1894986606,
22375 -1051523, -2054922799, 1873313359, -30611744, -1560198380, 1309151649,
22376 -145523070, -1120210379, 718787259, -343485551]);
22377
22378 function hash(data, offset, length) {
22379 var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
22380 // pre-processing
22381 var paddedLength = (length + 72) & ~63; // data + 9 extra bytes
22382 var padded = new Uint8Array(paddedLength);
22383 var i, j, n;
22384 for (i = 0; i < length; ++i) {
22385 padded[i] = data[offset++];
22386 }
22387 padded[i++] = 0x80;
22388 n = paddedLength - 8;
22389 while (i < n) {
22390 padded[i++] = 0;
22391 }
22392 padded[i++] = (length << 3) & 0xFF;
22393 padded[i++] = (length >> 5) & 0xFF;
22394 padded[i++] = (length >> 13) & 0xFF;
22395 padded[i++] = (length >> 21) & 0xFF;
22396 padded[i++] = (length >>> 29) & 0xFF;
22397 padded[i++] = 0;
22398 padded[i++] = 0;
22399 padded[i++] = 0;
22400 var w = new Int32Array(16);
22401 for (i = 0; i < paddedLength;) {
22402 for (j = 0; j < 16; ++j, i += 4) {
22403 w[j] = (padded[i] | (padded[i + 1] << 8) |
22404 (padded[i + 2] << 16) | (padded[i + 3] << 24));
22405 }
22406 var a = h0, b = h1, c = h2, d = h3, f, g;
22407 for (j = 0; j < 64; ++j) {
22408 if (j < 16) {
22409 f = (b & c) | ((~b) & d);
22410 g = j;
22411 } else if (j < 32) {
22412 f = (d & b) | ((~d) & c);
22413 g = (5 * j + 1) & 15;
22414 } else if (j < 48) {
22415 f = b ^ c ^ d;
22416 g = (3 * j + 5) & 15;
22417 } else {
22418 f = c ^ (b | (~d));
22419 g = (7 * j) & 15;
22420 }
22421 var tmp = d, rotateArg = (a + f + k[j] + w[g]) | 0, rotate = r[j];
22422 d = c;
22423 c = b;
22424 b = (b + ((rotateArg << rotate) | (rotateArg >>> (32 - rotate)))) | 0;
22425 a = tmp;
22426 }
22427 h0 = (h0 + a) | 0;
22428 h1 = (h1 + b) | 0;
22429 h2 = (h2 + c) | 0;
22430 h3 = (h3 + d) | 0;
22431 }
22432 return new Uint8Array([
22433 h0 & 0xFF, (h0 >> 8) & 0xFF, (h0 >> 16) & 0xFF, (h0 >>> 24) & 0xFF,
22434 h1 & 0xFF, (h1 >> 8) & 0xFF, (h1 >> 16) & 0xFF, (h1 >>> 24) & 0xFF,
22435 h2 & 0xFF, (h2 >> 8) & 0xFF, (h2 >> 16) & 0xFF, (h2 >>> 24) & 0xFF,
22436 h3 & 0xFF, (h3 >> 8) & 0xFF, (h3 >> 16) & 0xFF, (h3 >>> 24) & 0xFF
22437 ]);
22438 }
22439
22440 return hash;
22441})();
22442var Word64 = (function Word64Closure() {
22443 function Word64(highInteger, lowInteger) {
22444 this.high = highInteger | 0;
22445 this.low = lowInteger | 0;
22446 }
22447 Word64.prototype = {
22448 and: function Word64_and(word) {
22449 this.high &= word.high;
22450 this.low &= word.low;
22451 },
22452 xor: function Word64_xor(word) {
22453 this.high ^= word.high;
22454 this.low ^= word.low;
22455 },
22456
22457 or: function Word64_or(word) {
22458 this.high |= word.high;
22459 this.low |= word.low;
22460 },
22461
22462 shiftRight: function Word64_shiftRight(places) {
22463 if (places >= 32) {
22464 this.low = (this.high >>> (places - 32)) | 0;
22465 this.high = 0;
22466 } else {
22467 this.low = (this.low >>> places) | (this.high << (32 - places));
22468 this.high = (this.high >>> places) | 0;
22469 }
22470 },
22471
22472 shiftLeft: function Word64_shiftLeft(places) {
22473 if (places >= 32) {
22474 this.high = this.low << (places - 32);
22475 this.low = 0;
22476 } else {
22477 this.high = (this.high << places) | (this.low >>> (32 - places));
22478 this.low = this.low << places;
22479 }
22480 },
22481
22482 rotateRight: function Word64_rotateRight(places) {
22483 var low, high;
22484 if (places & 32) {
22485 high = this.low;
22486 low = this.high;
22487 } else {
22488 low = this.low;
22489 high = this.high;
22490 }
22491 places &= 31;
22492 this.low = (low >>> places) | (high << (32 - places));
22493 this.high = (high >>> places) | (low << (32 - places));
22494 },
22495
22496 not: function Word64_not() {
22497 this.high = ~this.high;
22498 this.low = ~this.low;
22499 },
22500
22501 add: function Word64_add(word) {
22502 var lowAdd = (this.low >>> 0) + (word.low >>> 0);
22503 var highAdd = (this.high >>> 0) + (word.high >>> 0);
22504 if (lowAdd > 0xFFFFFFFF) {
22505 highAdd += 1;
22506 }
22507 this.low = lowAdd | 0;
22508 this.high = highAdd | 0;
22509 },
22510
22511 copyTo: function Word64_copyTo(bytes, offset) {
22512 bytes[offset] = (this.high >>> 24) & 0xFF;
22513 bytes[offset + 1] = (this.high >> 16) & 0xFF;
22514 bytes[offset + 2] = (this.high >> 8) & 0xFF;
22515 bytes[offset + 3] = this.high & 0xFF;
22516 bytes[offset + 4] = (this.low >>> 24) & 0xFF;
22517 bytes[offset + 5] = (this.low >> 16) & 0xFF;
22518 bytes[offset + 6] = (this.low >> 8) & 0xFF;
22519 bytes[offset + 7] = this.low & 0xFF;
22520 },
22521
22522 assign: function Word64_assign(word) {
22523 this.high = word.high;
22524 this.low = word.low;
22525 }
22526 };
22527 return Word64;
22528})();
22529
22530var calculateSHA256 = (function calculateSHA256Closure() {
22531 function rotr(x, n) {
22532 return (x >>> n) | (x << 32 - n);
22533 }
22534
22535 function ch(x, y, z) {
22536 return (x & y) ^ (~x & z);
22537 }
22538
22539 function maj(x, y, z) {
22540 return (x & y) ^ (x & z) ^ (y & z);
22541 }
22542
22543 function sigma(x) {
22544 return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
22545 }
22546
22547 function sigmaPrime(x) {
22548 return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
22549 }
22550
22551 function littleSigma(x) {
22552 return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
22553 }
22554
22555 function littleSigmaPrime(x) {
22556 return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
22557 }
22558
22559 var k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
22560 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
22561 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
22562 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
22563 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
22564 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
22565 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
22566 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
22567 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
22568 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
22569 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
22570 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
22571 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
22572 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
22573 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
22574 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
22575
22576 function hash(data, offset, length) {
22577 // initial hash values
22578 var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372,
22579 h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c,
22580 h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
22581 // pre-processing
22582 var paddedLength = Math.ceil((length + 9) / 64) * 64;
22583 var padded = new Uint8Array(paddedLength);
22584 var i, j, n;
22585 for (i = 0; i < length; ++i) {
22586 padded[i] = data[offset++];
22587 }
22588 padded[i++] = 0x80;
22589 n = paddedLength - 8;
22590 while (i < n) {
22591 padded[i++] = 0;
22592 }
22593 padded[i++] = 0;
22594 padded[i++] = 0;
22595 padded[i++] = 0;
22596 padded[i++] = (length >>> 29) & 0xFF;
22597 padded[i++] = (length >> 21) & 0xFF;
22598 padded[i++] = (length >> 13) & 0xFF;
22599 padded[i++] = (length >> 5) & 0xFF;
22600 padded[i++] = (length << 3) & 0xFF;
22601 var w = new Uint32Array(64);
22602 // for each 512 bit block
22603 for (i = 0; i < paddedLength;) {
22604 for (j = 0; j < 16; ++j) {
22605 w[j] = (padded[i] << 24 | (padded[i + 1] << 16) |
22606 (padded[i + 2] << 8) | (padded[i + 3]));
22607 i += 4;
22608 }
22609
22610 for (j = 16; j < 64; ++j) {
22611 w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] +
22612 littleSigma(w[j - 15]) + w[j - 16] | 0;
22613 }
22614 var a = h0, b = h1, c = h2, d = h3, e = h4,
22615 f = h5, g = h6, h = h7, t1, t2;
22616 for (j = 0; j < 64; ++j) {
22617 t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
22618 t2 = sigma(a) + maj(a, b, c);
22619 h = g;
22620 g = f;
22621 f = e;
22622 e = (d + t1) | 0;
22623 d = c;
22624 c = b;
22625 b = a;
22626 a = (t1 + t2) | 0;
22627 }
22628 h0 = (h0 + a) | 0;
22629 h1 = (h1 + b) | 0;
22630 h2 = (h2 + c) | 0;
22631 h3 = (h3 + d) | 0;
22632 h4 = (h4 + e) | 0;
22633 h5 = (h5 + f) | 0;
22634 h6 = (h6 + g) | 0;
22635 h7 = (h7 + h) | 0;
22636 }
22637 return new Uint8Array([
22638 (h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, (h0) & 0xFF,
22639 (h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, (h1) & 0xFF,
22640 (h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, (h2) & 0xFF,
22641 (h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, (h3) & 0xFF,
22642 (h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, (h4) & 0xFF,
22643 (h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, (h5) & 0xFF,
22644 (h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, (h6) & 0xFF,
22645 (h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, (h7) & 0xFF
22646 ]);
22647 }
22648
22649 return hash;
22650})();
22651
22652var calculateSHA512 = (function calculateSHA512Closure() {
22653 function ch(result, x, y, z, tmp) {
22654 result.assign(x);
22655 result.and(y);
22656 tmp.assign(x);
22657 tmp.not();
22658 tmp.and(z);
22659 result.xor(tmp);
22660 }
22661
22662 function maj(result, x, y, z, tmp) {
22663 result.assign(x);
22664 result.and(y);
22665 tmp.assign(x);
22666 tmp.and(z);
22667 result.xor(tmp);
22668 tmp.assign(y);
22669 tmp.and(z);
22670 result.xor(tmp);
22671 }
22672
22673 function sigma(result, x, tmp) {
22674 result.assign(x);
22675 result.rotateRight(28);
22676 tmp.assign(x);
22677 tmp.rotateRight(34);
22678 result.xor(tmp);
22679 tmp.assign(x);
22680 tmp.rotateRight(39);
22681 result.xor(tmp);
22682 }
22683
22684 function sigmaPrime(result, x, tmp) {
22685 result.assign(x);
22686 result.rotateRight(14);
22687 tmp.assign(x);
22688 tmp.rotateRight(18);
22689 result.xor(tmp);
22690 tmp.assign(x);
22691 tmp.rotateRight(41);
22692 result.xor(tmp);
22693 }
22694
22695 function littleSigma(result, x, tmp) {
22696 result.assign(x);
22697 result.rotateRight(1);
22698 tmp.assign(x);
22699 tmp.rotateRight(8);
22700 result.xor(tmp);
22701 tmp.assign(x);
22702 tmp.shiftRight(7);
22703 result.xor(tmp);
22704 }
22705
22706 function littleSigmaPrime(result, x, tmp) {
22707 result.assign(x);
22708 result.rotateRight(19);
22709 tmp.assign(x);
22710 tmp.rotateRight(61);
22711 result.xor(tmp);
22712 tmp.assign(x);
22713 tmp.shiftRight(6);
22714 result.xor(tmp);
22715 }
22716
22717 var k = [
22718 new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd),
22719 new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc),
22720 new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019),
22721 new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118),
22722 new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe),
22723 new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2),
22724 new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1),
22725 new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694),
22726 new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3),
22727 new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65),
22728 new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483),
22729 new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5),
22730 new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210),
22731 new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4),
22732 new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725),
22733 new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70),
22734 new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926),
22735 new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df),
22736 new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8),
22737 new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b),
22738 new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001),
22739 new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30),
22740 new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910),
22741 new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8),
22742 new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53),
22743 new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8),
22744 new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb),
22745 new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3),
22746 new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60),
22747 new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec),
22748 new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9),
22749 new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b),
22750 new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207),
22751 new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178),
22752 new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6),
22753 new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b),
22754 new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493),
22755 new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c),
22756 new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a),
22757 new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)];
22758
22759 function hash(data, offset, length, mode384) {
22760 mode384 = !!mode384;
22761 // initial hash values
22762 var h0, h1, h2, h3, h4, h5, h6, h7;
22763 if (!mode384) {
22764 h0 = new Word64(0x6a09e667, 0xf3bcc908);
22765 h1 = new Word64(0xbb67ae85, 0x84caa73b);
22766 h2 = new Word64(0x3c6ef372, 0xfe94f82b);
22767 h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
22768 h4 = new Word64(0x510e527f, 0xade682d1);
22769 h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
22770 h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
22771 h7 = new Word64(0x5be0cd19, 0x137e2179);
22772 }
22773 else {
22774 // SHA384 is exactly the same
22775 // except with different starting values and a trimmed result
22776 h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
22777 h1 = new Word64(0x629a292a, 0x367cd507);
22778 h2 = new Word64(0x9159015a, 0x3070dd17);
22779 h3 = new Word64(0x152fecd8, 0xf70e5939);
22780 h4 = new Word64(0x67332667, 0xffc00b31);
22781 h5 = new Word64(0x8eb44a87, 0x68581511);
22782 h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
22783 h7 = new Word64(0x47b5481d, 0xbefa4fa4);
22784 }
22785
22786 // pre-processing
22787 var paddedLength = Math.ceil((length + 17) / 128) * 128;
22788 var padded = new Uint8Array(paddedLength);
22789 var i, j, n;
22790 for (i = 0; i < length; ++i) {
22791 padded[i] = data[offset++];
22792 }
22793 padded[i++] = 0x80;
22794 n = paddedLength - 16;
22795 while (i < n) {
22796 padded[i++] = 0;
22797 }
22798 padded[i++] = 0;
22799 padded[i++] = 0;
22800 padded[i++] = 0;
22801 padded[i++] = 0;
22802 padded[i++] = 0;
22803 padded[i++] = 0;
22804 padded[i++] = 0;
22805 padded[i++] = 0;
22806 padded[i++] = 0;
22807 padded[i++] = 0;
22808 padded[i++] = 0;
22809 padded[i++] = (length >>> 29) & 0xFF;
22810 padded[i++] = (length >> 21) & 0xFF;
22811 padded[i++] = (length >> 13) & 0xFF;
22812 padded[i++] = (length >> 5) & 0xFF;
22813 padded[i++] = (length << 3) & 0xFF;
22814
22815 var w = new Array(80);
22816 for (i = 0; i < 80; i++) {
22817 w[i] = new Word64(0, 0);
22818 }
22819 var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
22820 var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
22821 var g = new Word64(0, 0), h = new Word64(0, 0);
22822 var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
22823 var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
22824
22825 // for each 1024 bit block
22826 for (i = 0; i < paddedLength;) {
22827 for (j = 0; j < 16; ++j) {
22828 w[j].high = (padded[i] << 24) | (padded[i + 1] << 16) |
22829 (padded[i + 2] << 8) | (padded[i + 3]);
22830 w[j].low = (padded[i + 4]) << 24 | (padded[i + 5]) << 16 |
22831 (padded[i + 6]) << 8 | (padded[i + 7]);
22832 i += 8;
22833 }
22834 for (j = 16; j < 80; ++j) {
22835 tmp3 = w[j];
22836 littleSigmaPrime(tmp3, w[j - 2], tmp2);
22837 tmp3.add(w[j - 7]);
22838 littleSigma(tmp1, w[j - 15], tmp2);
22839 tmp3.add(tmp1);
22840 tmp3.add(w[j - 16]);
22841 }
22842
22843 a.assign(h0); b.assign(h1); c.assign(h2); d.assign(h3);
22844 e.assign(h4); f.assign(h5); g.assign(h6); h.assign(h7);
22845 for (j = 0; j < 80; ++j) {
22846 t1.assign(h);
22847 sigmaPrime(tmp1, e, tmp2);
22848 t1.add(tmp1);
22849 ch(tmp1, e, f, g, tmp2);
22850 t1.add(tmp1);
22851 t1.add(k[j]);
22852 t1.add(w[j]);
22853
22854 sigma(t2, a, tmp2);
22855 maj(tmp1, a, b, c, tmp2);
22856 t2.add(tmp1);
22857
22858 tmp3 = h;
22859 h = g;
22860 g = f;
22861 f = e;
22862 d.add(t1);
22863 e = d;
22864 d = c;
22865 c = b;
22866 b = a;
22867 tmp3.assign(t1);
22868 tmp3.add(t2);
22869 a = tmp3;
22870 }
22871 h0.add(a);
22872 h1.add(b);
22873 h2.add(c);
22874 h3.add(d);
22875 h4.add(e);
22876 h5.add(f);
22877 h6.add(g);
22878 h7.add(h);
22879 }
22880
22881 var result;
22882 if (!mode384) {
22883 result = new Uint8Array(64);
22884 h0.copyTo(result,0);
22885 h1.copyTo(result,8);
22886 h2.copyTo(result,16);
22887 h3.copyTo(result,24);
22888 h4.copyTo(result,32);
22889 h5.copyTo(result,40);
22890 h6.copyTo(result,48);
22891 h7.copyTo(result,56);
22892 }
22893 else {
22894 result = new Uint8Array(48);
22895 h0.copyTo(result,0);
22896 h1.copyTo(result,8);
22897 h2.copyTo(result,16);
22898 h3.copyTo(result,24);
22899 h4.copyTo(result,32);
22900 h5.copyTo(result,40);
22901 }
22902 return result;
22903 }
22904
22905 return hash;
22906})();
22907var calculateSHA384 = (function calculateSHA384Closure() {
22908 function hash(data, offset, length) {
22909 return calculateSHA512(data, offset, length, true);
22910 }
22911
22912 return hash;
22913})();
22914var NullCipher = (function NullCipherClosure() {
22915 function NullCipher() {
22916 }
22917
22918 NullCipher.prototype = {
22919 decryptBlock: function NullCipher_decryptBlock(data) {
22920 return data;
22921 }
22922 };
22923
22924 return NullCipher;
22925})();
22926
22927var AES128Cipher = (function AES128CipherClosure() {
22928 var rcon = new Uint8Array([
22929 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
22930 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
22931 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
22932 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
22933 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
22934 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6,
22935 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72,
22936 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc,
22937 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10,
22938 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e,
22939 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5,
22940 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94,
22941 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02,
22942 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d,
22943 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d,
22944 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f,
22945 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb,
22946 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
22947 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
22948 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
22949 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
22950 0x74, 0xe8, 0xcb, 0x8d]);
22951
22952 var s = new Uint8Array([
22953 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b,
22954 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
22955 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26,
22956 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
22957 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2,
22958 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
22959 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed,
22960 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
22961 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f,
22962 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
22963 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec,
22964 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
22965 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14,
22966 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
22967 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d,
22968 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
22969 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f,
22970 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
22971 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11,
22972 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
22973 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f,
22974 0xb0, 0x54, 0xbb, 0x16]);
22975
22976 var inv_s = new Uint8Array([
22977 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e,
22978 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
22979 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32,
22980 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
22981 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49,
22982 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
22983 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50,
22984 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
22985 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05,
22986 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
22987 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41,
22988 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
22989 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8,
22990 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
22991 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b,
22992 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
22993 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59,
22994 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
22995 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d,
22996 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
22997 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63,
22998 0x55, 0x21, 0x0c, 0x7d]);
22999 var mixCol = new Uint8Array(256);
23000 for (var i = 0; i < 256; i++) {
23001 if (i < 128) {
23002 mixCol[i] = i << 1;
23003 } else {
23004 mixCol[i] = (i << 1) ^ 0x1b;
23005 }
23006 }
23007 var mix = new Uint32Array([
23008 0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927,
23009 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45,
23010 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb,
23011 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381,
23012 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf,
23013 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66,
23014 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28,
23015 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012,
23016 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec,
23017 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e,
23018 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd,
23019 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7,
23020 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89,
23021 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b,
23022 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815,
23023 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f,
23024 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa,
23025 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8,
23026 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36,
23027 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c,
23028 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742,
23029 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea,
23030 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4,
23031 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e,
23032 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360,
23033 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502,
23034 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87,
23035 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd,
23036 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3,
23037 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621,
23038 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f,
23039 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55,
23040 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26,
23041 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844,
23042 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba,
23043 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480,
23044 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce,
23045 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67,
23046 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929,
23047 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713,
23048 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed,
23049 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f,
23050 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
23051
23052 function expandKey128(cipherKey) {
23053 var b = 176, result = new Uint8Array(b);
23054 result.set(cipherKey);
23055 for (var j = 16, i = 1; j < b; ++i) {
23056 // RotWord
23057 var t1 = result[j - 3], t2 = result[j - 2],
23058 t3 = result[j - 1], t4 = result[j - 4];
23059 // SubWord
23060 t1 = s[t1];
23061 t2 = s[t2];
23062 t3 = s[t3];
23063 t4 = s[t4];
23064 // Rcon
23065 t1 = t1 ^ rcon[i];
23066 for (var n = 0; n < 4; ++n) {
23067 result[j] = (t1 ^= result[j - 16]);
23068 j++;
23069 result[j] = (t2 ^= result[j - 16]);
23070 j++;
23071 result[j] = (t3 ^= result[j - 16]);
23072 j++;
23073 result[j] = (t4 ^= result[j - 16]);
23074 j++;
23075 }
23076 }
23077 return result;
23078 }
23079
23080 function decrypt128(input, key) {
23081 var state = new Uint8Array(16);
23082 state.set(input);
23083 var i, j, k;
23084 var t, u, v;
23085 // AddRoundKey
23086 for (j = 0, k = 160; j < 16; ++j, ++k) {
23087 state[j] ^= key[k];
23088 }
23089 for (i = 9; i >= 1; --i) {
23090 // InvShiftRows
23091 t = state[13];
23092 state[13] = state[9];
23093 state[9] = state[5];
23094 state[5] = state[1];
23095 state[1] = t;
23096 t = state[14];
23097 u = state[10];
23098 state[14] = state[6];
23099 state[10] = state[2];
23100 state[6] = t;
23101 state[2] = u;
23102 t = state[15];
23103 u = state[11];
23104 v = state[7];
23105 state[15] = state[3];
23106 state[11] = t;
23107 state[7] = u;
23108 state[3] = v;
23109 // InvSubBytes
23110 for (j = 0; j < 16; ++j) {
23111 state[j] = inv_s[state[j]];
23112 }
23113 // AddRoundKey
23114 for (j = 0, k = i * 16; j < 16; ++j, ++k) {
23115 state[j] ^= key[k];
23116 }
23117 // InvMixColumns
23118 for (j = 0; j < 16; j += 4) {
23119 var s0 = mix[state[j]], s1 = mix[state[j + 1]],
23120 s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
23121 t = (s0 ^ (s1 >>> 8) ^ (s1 << 24) ^ (s2 >>> 16) ^ (s2 << 16) ^
23122 (s3 >>> 24) ^ (s3 << 8));
23123 state[j] = (t >>> 24) & 0xFF;
23124 state[j + 1] = (t >> 16) & 0xFF;
23125 state[j + 2] = (t >> 8) & 0xFF;
23126 state[j + 3] = t & 0xFF;
23127 }
23128 }
23129 // InvShiftRows
23130 t = state[13];
23131 state[13] = state[9];
23132 state[9] = state[5];
23133 state[5] = state[1];
23134 state[1] = t;
23135 t = state[14];
23136 u = state[10];
23137 state[14] = state[6];
23138 state[10] = state[2];
23139 state[6] = t;
23140 state[2] = u;
23141 t = state[15];
23142 u = state[11];
23143 v = state[7];
23144 state[15] = state[3];
23145 state[11] = t;
23146 state[7] = u;
23147 state[3] = v;
23148 for (j = 0; j < 16; ++j) {
23149 // InvSubBytes
23150 state[j] = inv_s[state[j]];
23151 // AddRoundKey
23152 state[j] ^= key[j];
23153 }
23154 return state;
23155 }
23156
23157 function encrypt128(input, key) {
23158 var t, u, v, k;
23159 var state = new Uint8Array(16);
23160 state.set(input);
23161 for (j = 0; j < 16; ++j) {
23162 // AddRoundKey
23163 state[j] ^= key[j];
23164 }
23165
23166 for (i = 1; i < 10; i++) {
23167 //SubBytes
23168 for (j = 0; j < 16; ++j) {
23169 state[j] = s[state[j]];
23170 }
23171 //ShiftRows
23172 v = state[1];
23173 state[1] = state[5];
23174 state[5] = state[9];
23175 state[9] = state[13];
23176 state[13] = v;
23177 v = state[2];
23178 u = state[6];
23179 state[2] = state[10];
23180 state[6] = state[14];
23181 state[10] = v;
23182 state[14] = u;
23183 v = state[3];
23184 u = state[7];
23185 t = state[11];
23186 state[3] = state[15];
23187 state[7] = v;
23188 state[11] = u;
23189 state[15] = t;
23190 //MixColumns
23191 for (var j = 0; j < 16; j += 4) {
23192 var s0 = state[j + 0], s1 = state[j + 1];
23193 var s2 = state[j + 2], s3 = state[j + 3];
23194 t = s0 ^ s1 ^ s2 ^ s3;
23195 state[j + 0] ^= t ^ mixCol[s0 ^ s1];
23196 state[j + 1] ^= t ^ mixCol[s1 ^ s2];
23197 state[j + 2] ^= t ^ mixCol[s2 ^ s3];
23198 state[j + 3] ^= t ^ mixCol[s3 ^ s0];
23199 }
23200 //AddRoundKey
23201 for (j = 0, k = i * 16; j < 16; ++j, ++k) {
23202 state[j] ^= key[k];
23203 }
23204 }
23205
23206 //SubBytes
23207 for (j = 0; j < 16; ++j) {
23208 state[j] = s[state[j]];
23209 }
23210 //ShiftRows
23211 v = state[1];
23212 state[1] = state[5];
23213 state[5] = state[9];
23214 state[9] = state[13];
23215 state[13] = v;
23216 v = state[2];
23217 u = state[6];
23218 state[2] = state[10];
23219 state[6] = state[14];
23220 state[10] = v;
23221 state[14] = u;
23222 v = state[3];
23223 u = state[7];
23224 t = state[11];
23225 state[3] = state[15];
23226 state[7] = v;
23227 state[11] = u;
23228 state[15] = t;
23229 //AddRoundKey
23230 for (j = 0, k = 160; j < 16; ++j, ++k) {
23231 state[j] ^= key[k];
23232 }
23233 return state;
23234 }
23235
23236 function AES128Cipher(key) {
23237 this.key = expandKey128(key);
23238 this.buffer = new Uint8Array(16);
23239 this.bufferPosition = 0;
23240 }
23241
23242 function decryptBlock2(data, finalize) {
23243 var i, j, ii, sourceLength = data.length,
23244 buffer = this.buffer, bufferLength = this.bufferPosition,
23245 result = [], iv = this.iv;
23246 for (i = 0; i < sourceLength; ++i) {
23247 buffer[bufferLength] = data[i];
23248 ++bufferLength;
23249 if (bufferLength < 16) {
23250 continue;
23251 }
23252 // buffer is full, decrypting
23253 var plain = decrypt128(buffer, this.key);
23254 // xor-ing the IV vector to get plain text
23255 for (j = 0; j < 16; ++j) {
23256 plain[j] ^= iv[j];
23257 }
23258 iv = buffer;
23259 result.push(plain);
23260 buffer = new Uint8Array(16);
23261 bufferLength = 0;
23262 }
23263 // saving incomplete buffer
23264 this.buffer = buffer;
23265 this.bufferLength = bufferLength;
23266 this.iv = iv;
23267 if (result.length === 0) {
23268 return new Uint8Array([]);
23269 }
23270 // combining plain text blocks into one
23271 var outputLength = 16 * result.length;
23272 if (finalize) {
23273 // undo a padding that is described in RFC 2898
23274 var lastBlock = result[result.length - 1];
23275 var psLen = lastBlock[15];
23276 if (psLen <= 16) {
23277 for (i = 15, ii = 16 - psLen; i >= ii; --i) {
23278 if (lastBlock[i] !== psLen) {
23279 // Invalid padding, assume that the block has no padding.
23280 psLen = 0;
23281 break;
23282 }
23283 }
23284 outputLength -= psLen;
23285 result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
23286 }
23287 }
23288 var output = new Uint8Array(outputLength);
23289 for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
23290 output.set(result[i], j);
23291 }
23292 return output;
23293 }
23294
23295 AES128Cipher.prototype = {
23296 decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
23297 var i, sourceLength = data.length;
23298 var buffer = this.buffer, bufferLength = this.bufferPosition;
23299 // waiting for IV values -- they are at the start of the stream
23300 for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
23301 buffer[bufferLength] = data[i];
23302 }
23303 if (bufferLength < 16) {
23304 // need more data
23305 this.bufferLength = bufferLength;
23306 return new Uint8Array([]);
23307 }
23308 this.iv = buffer;
23309 this.buffer = new Uint8Array(16);
23310 this.bufferLength = 0;
23311 // starting decryption
23312 this.decryptBlock = decryptBlock2;
23313 return this.decryptBlock(data.subarray(16), finalize);
23314 },
23315 encrypt: function AES128Cipher_encrypt(data, iv) {
23316 var i, j, ii, sourceLength = data.length,
23317 buffer = this.buffer, bufferLength = this.bufferPosition,
23318 result = [];
23319 if (!iv) {
23320 iv = new Uint8Array(16);
23321 }
23322 for (i = 0; i < sourceLength; ++i) {
23323 buffer[bufferLength] = data[i];
23324 ++bufferLength;
23325 if (bufferLength < 16) {
23326 continue;
23327 }
23328 for (j = 0; j < 16; ++j) {
23329 buffer[j] ^= iv[j];
23330 }
23331
23332 // buffer is full, encrypting
23333 var cipher = encrypt128(buffer, this.key);
23334 iv = cipher;
23335 result.push(cipher);
23336 buffer = new Uint8Array(16);
23337 bufferLength = 0;
23338 }
23339 // saving incomplete buffer
23340 this.buffer = buffer;
23341 this.bufferLength = bufferLength;
23342 this.iv = iv;
23343 if (result.length === 0) {
23344 return new Uint8Array([]);
23345 }
23346 // combining plain text blocks into one
23347 var outputLength = 16 * result.length;
23348 var output = new Uint8Array(outputLength);
23349 for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
23350 output.set(result[i], j);
23351 }
23352 return output;
23353 }
23354 };
23355
23356 return AES128Cipher;
23357})();
23358
23359var AES256Cipher = (function AES256CipherClosure() {
23360 var rcon = new Uint8Array([
23361 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
23362 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
23363 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
23364 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
23365 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
23366 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6,
23367 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72,
23368 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc,
23369 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10,
23370 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e,
23371 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5,
23372 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94,
23373 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02,
23374 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d,
23375 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d,
23376 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f,
23377 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb,
23378 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c,
23379 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a,
23380 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd,
23381 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a,
23382 0x74, 0xe8, 0xcb, 0x8d]);
23383
23384 var s = new Uint8Array([
23385 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b,
23386 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0,
23387 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26,
23388 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
23389 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2,
23390 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0,
23391 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed,
23392 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
23393 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f,
23394 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5,
23395 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec,
23396 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
23397 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14,
23398 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c,
23399 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d,
23400 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
23401 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f,
23402 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e,
23403 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11,
23404 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
23405 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f,
23406 0xb0, 0x54, 0xbb, 0x16]);
23407
23408 var inv_s = new Uint8Array([
23409 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e,
23410 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87,
23411 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32,
23412 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
23413 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49,
23414 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16,
23415 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50,
23416 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
23417 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05,
23418 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02,
23419 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41,
23420 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
23421 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8,
23422 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89,
23423 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b,
23424 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
23425 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59,
23426 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d,
23427 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d,
23428 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
23429 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63,
23430 0x55, 0x21, 0x0c, 0x7d]);
23431
23432 var mixCol = new Uint8Array(256);
23433 for (var i = 0; i < 256; i++) {
23434 if (i < 128) {
23435 mixCol[i] = i << 1;
23436 } else {
23437 mixCol[i] = (i << 1) ^ 0x1b;
23438 }
23439 }
23440 var mix = new Uint32Array([
23441 0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927,
23442 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45,
23443 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb,
23444 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381,
23445 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf,
23446 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66,
23447 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28,
23448 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012,
23449 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec,
23450 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e,
23451 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd,
23452 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7,
23453 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89,
23454 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b,
23455 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815,
23456 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f,
23457 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa,
23458 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8,
23459 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36,
23460 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c,
23461 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742,
23462 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea,
23463 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4,
23464 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e,
23465 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360,
23466 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502,
23467 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87,
23468 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd,
23469 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3,
23470 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621,
23471 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f,
23472 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55,
23473 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26,
23474 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844,
23475 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba,
23476 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480,
23477 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce,
23478 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67,
23479 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929,
23480 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713,
23481 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed,
23482 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f,
23483 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
23484
23485 function expandKey256(cipherKey) {
23486 var b = 240, result = new Uint8Array(b);
23487 var r = 1;
23488
23489 result.set(cipherKey);
23490 for (var j = 32, i = 1; j < b; ++i) {
23491 if (j % 32 === 16) {
23492 t1 = s[t1];
23493 t2 = s[t2];
23494 t3 = s[t3];
23495 t4 = s[t4];
23496 } else if (j % 32 === 0) {
23497 // RotWord
23498 var t1 = result[j - 3], t2 = result[j - 2],
23499 t3 = result[j - 1], t4 = result[j - 4];
23500 // SubWord
23501 t1 = s[t1];
23502 t2 = s[t2];
23503 t3 = s[t3];
23504 t4 = s[t4];
23505 // Rcon
23506 t1 = t1 ^ r;
23507 if ((r <<= 1) >= 256) {
23508 r = (r ^ 0x1b) & 0xFF;
23509 }
23510 }
23511
23512 for (var n = 0; n < 4; ++n) {
23513 result[j] = (t1 ^= result[j - 32]);
23514 j++;
23515 result[j] = (t2 ^= result[j - 32]);
23516 j++;
23517 result[j] = (t3 ^= result[j - 32]);
23518 j++;
23519 result[j] = (t4 ^= result[j - 32]);
23520 j++;
23521 }
23522 }
23523 return result;
23524 }
23525
23526 function decrypt256(input, key) {
23527 var state = new Uint8Array(16);
23528 state.set(input);
23529 var i, j, k;
23530 var t, u, v;
23531 // AddRoundKey
23532 for (j = 0, k = 224; j < 16; ++j, ++k) {
23533 state[j] ^= key[k];
23534 }
23535 for (i = 13; i >= 1; --i) {
23536 // InvShiftRows
23537 t = state[13];
23538 state[13] = state[9];
23539 state[9] = state[5];
23540 state[5] = state[1];
23541 state[1] = t;
23542 t = state[14];
23543 u = state[10];
23544 state[14] = state[6];
23545 state[10] = state[2];
23546 state[6] = t;
23547 state[2] = u;
23548 t = state[15];
23549 u = state[11];
23550 v = state[7];
23551 state[15] = state[3];
23552 state[11] = t;
23553 state[7] = u;
23554 state[3] = v;
23555 // InvSubBytes
23556 for (j = 0; j < 16; ++j) {
23557 state[j] = inv_s[state[j]];
23558 }
23559 // AddRoundKey
23560 for (j = 0, k = i * 16; j < 16; ++j, ++k) {
23561 state[j] ^= key[k];
23562 }
23563 // InvMixColumns
23564 for (j = 0; j < 16; j += 4) {
23565 var s0 = mix[state[j]], s1 = mix[state[j + 1]],
23566 s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
23567 t = (s0 ^ (s1 >>> 8) ^ (s1 << 24) ^ (s2 >>> 16) ^ (s2 << 16) ^
23568 (s3 >>> 24) ^ (s3 << 8));
23569 state[j] = (t >>> 24) & 0xFF;
23570 state[j + 1] = (t >> 16) & 0xFF;
23571 state[j + 2] = (t >> 8) & 0xFF;
23572 state[j + 3] = t & 0xFF;
23573 }
23574 }
23575 // InvShiftRows
23576 t = state[13];
23577 state[13] = state[9];
23578 state[9] = state[5];
23579 state[5] = state[1];
23580 state[1] = t;
23581 t = state[14];
23582 u = state[10];
23583 state[14] = state[6];
23584 state[10] = state[2];
23585 state[6] = t;
23586 state[2] = u;
23587 t = state[15];
23588 u = state[11];
23589 v = state[7];
23590 state[15] = state[3];
23591 state[11] = t;
23592 state[7] = u;
23593 state[3] = v;
23594 for (j = 0; j < 16; ++j) {
23595 // InvSubBytes
23596 state[j] = inv_s[state[j]];
23597 // AddRoundKey
23598 state[j] ^= key[j];
23599 }
23600 return state;
23601 }
23602
23603 function encrypt256(input, key) {
23604 var t, u, v, k;
23605 var state = new Uint8Array(16);
23606 state.set(input);
23607 for (j = 0; j < 16; ++j) {
23608 // AddRoundKey
23609 state[j] ^= key[j];
23610 }
23611
23612 for (i = 1; i < 14; i++) {
23613 //SubBytes
23614 for (j = 0; j < 16; ++j) {
23615 state[j] = s[state[j]];
23616 }
23617 //ShiftRows
23618 v = state[1];
23619 state[1] = state[5];
23620 state[5] = state[9];
23621 state[9] = state[13];
23622 state[13] = v;
23623 v = state[2];
23624 u = state[6];
23625 state[2] = state[10];
23626 state[6] = state[14];
23627 state[10] = v;
23628 state[14] = u;
23629 v = state[3];
23630 u = state[7];
23631 t = state[11];
23632 state[3] = state[15];
23633 state[7] = v;
23634 state[11] = u;
23635 state[15] = t;
23636 //MixColumns
23637 for (var j = 0; j < 16; j += 4) {
23638 var s0 = state[j + 0], s1 = state[j + 1];
23639 var s2 = state[j + 2], s3 = state[j + 3];
23640 t = s0 ^ s1 ^ s2 ^ s3;
23641 state[j + 0] ^= t ^ mixCol[s0 ^ s1];
23642 state[j + 1] ^= t ^ mixCol[s1 ^ s2];
23643 state[j + 2] ^= t ^ mixCol[s2 ^ s3];
23644 state[j + 3] ^= t ^ mixCol[s3 ^ s0];
23645 }
23646 //AddRoundKey
23647 for (j = 0, k = i * 16; j < 16; ++j, ++k) {
23648 state[j] ^= key[k];
23649 }
23650 }
23651
23652 //SubBytes
23653 for (j = 0; j < 16; ++j) {
23654 state[j] = s[state[j]];
23655 }
23656 //ShiftRows
23657 v = state[1];
23658 state[1] = state[5];
23659 state[5] = state[9];
23660 state[9] = state[13];
23661 state[13] = v;
23662 v = state[2];
23663 u = state[6];
23664 state[2] = state[10];
23665 state[6] = state[14];
23666 state[10] = v;
23667 state[14] = u;
23668 v = state[3];
23669 u = state[7];
23670 t = state[11];
23671 state[3] = state[15];
23672 state[7] = v;
23673 state[11] = u;
23674 state[15] = t;
23675 //AddRoundKey
23676 for (j = 0, k = 224; j < 16; ++j, ++k) {
23677 state[j] ^= key[k];
23678 }
23679
23680 return state;
23681
23682 }
23683
23684 function AES256Cipher(key) {
23685 this.key = expandKey256(key);
23686 this.buffer = new Uint8Array(16);
23687 this.bufferPosition = 0;
23688 }
23689
23690 function decryptBlock2(data, finalize) {
23691 var i, j, ii, sourceLength = data.length,
23692 buffer = this.buffer, bufferLength = this.bufferPosition,
23693 result = [], iv = this.iv;
23694
23695 for (i = 0; i < sourceLength; ++i) {
23696 buffer[bufferLength] = data[i];
23697 ++bufferLength;
23698 if (bufferLength < 16) {
23699 continue;
23700 }
23701 // buffer is full, decrypting
23702 var plain = decrypt256(buffer, this.key);
23703 // xor-ing the IV vector to get plain text
23704 for (j = 0; j < 16; ++j) {
23705 plain[j] ^= iv[j];
23706 }
23707 iv = buffer;
23708 result.push(plain);
23709 buffer = new Uint8Array(16);
23710 bufferLength = 0;
23711 }
23712 // saving incomplete buffer
23713 this.buffer = buffer;
23714 this.bufferLength = bufferLength;
23715 this.iv = iv;
23716 if (result.length === 0) {
23717 return new Uint8Array([]);
23718 }
23719 // combining plain text blocks into one
23720 var outputLength = 16 * result.length;
23721 if (finalize) {
23722 // undo a padding that is described in RFC 2898
23723 var lastBlock = result[result.length - 1];
23724 var psLen = lastBlock[15];
23725 if (psLen <= 16) {
23726 for (i = 15, ii = 16 - psLen; i >= ii; --i) {
23727 if (lastBlock[i] !== psLen) {
23728 // Invalid padding, assume that the block has no padding.
23729 psLen = 0;
23730 break;
23731 }
23732 }
23733 outputLength -= psLen;
23734 result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
23735 }
23736 }
23737 var output = new Uint8Array(outputLength);
23738 for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
23739 output.set(result[i], j);
23740 }
23741 return output;
23742
23743 }
23744
23745 AES256Cipher.prototype = {
23746 decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
23747 var i, sourceLength = data.length;
23748 var buffer = this.buffer, bufferLength = this.bufferPosition;
23749 // if not supplied an IV wait for IV values
23750 // they are at the start of the stream
23751 if (iv) {
23752 this.iv = iv;
23753 } else {
23754 for (i = 0; bufferLength < 16 &&
23755 i < sourceLength; ++i, ++bufferLength) {
23756 buffer[bufferLength] = data[i];
23757 }
23758 if (bufferLength < 16) {
23759 //need more data
23760 this.bufferLength = bufferLength;
23761 return new Uint8Array([]);
23762 }
23763 this.iv = buffer;
23764 data = data.subarray(16);
23765 }
23766 this.buffer = new Uint8Array(16);
23767 this.bufferLength = 0;
23768 // starting decryption
23769 this.decryptBlock = decryptBlock2;
23770 return this.decryptBlock(data, finalize);
23771 },
23772 encrypt: function AES256Cipher_encrypt(data, iv) {
23773 var i, j, ii, sourceLength = data.length,
23774 buffer = this.buffer, bufferLength = this.bufferPosition,
23775 result = [];
23776 if (!iv) {
23777 iv = new Uint8Array(16);
23778 }
23779 for (i = 0; i < sourceLength; ++i) {
23780 buffer[bufferLength] = data[i];
23781 ++bufferLength;
23782 if (bufferLength < 16) {
23783 continue;
23784 }
23785 for (j = 0; j < 16; ++j) {
23786 buffer[j] ^= iv[j];
23787 }
23788
23789 // buffer is full, encrypting
23790 var cipher = encrypt256(buffer, this.key);
23791 this.iv = cipher;
23792 result.push(cipher);
23793 buffer = new Uint8Array(16);
23794 bufferLength = 0;
23795 }
23796 // saving incomplete buffer
23797 this.buffer = buffer;
23798 this.bufferLength = bufferLength;
23799 this.iv = iv;
23800 if (result.length === 0) {
23801 return new Uint8Array([]);
23802 }
23803 // combining plain text blocks into one
23804 var outputLength = 16 * result.length;
23805 var output = new Uint8Array(outputLength);
23806 for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
23807 output.set(result[i], j);
23808 }
23809 return output;
23810 }
23811 };
23812
23813 return AES256Cipher;
23814})();
23815
23816var PDF17 = (function PDF17Closure() {
23817
23818 function compareByteArrays(array1, array2) {
23819 if (array1.length !== array2.length) {
23820 return false;
23821 }
23822 for (var i = 0; i < array1.length; i++) {
23823 if (array1[i] !== array2[i]) {
23824 return false;
23825 }
23826 }
23827 return true;
23828 }
23829
23830 function PDF17() {
23831 }
23832
23833 PDF17.prototype = {
23834 checkOwnerPassword: function PDF17_checkOwnerPassword(password,
23835 ownerValidationSalt,
23836 userBytes,
23837 ownerPassword) {
23838 var hashData = new Uint8Array(password.length + 56);
23839 hashData.set(password, 0);
23840 hashData.set(ownerValidationSalt, password.length);
23841 hashData.set(userBytes, password.length + ownerValidationSalt.length);
23842 var result = calculateSHA256(hashData, 0, hashData.length);
23843 return compareByteArrays(result, ownerPassword);
23844 },
23845 checkUserPassword: function PDF17_checkUserPassword(password,
23846 userValidationSalt,
23847 userPassword) {
23848 var hashData = new Uint8Array(password.length + 8);
23849 hashData.set(password, 0);
23850 hashData.set(userValidationSalt, password.length);
23851 var result = calculateSHA256(hashData, 0, hashData.length);
23852 return compareByteArrays(result, userPassword);
23853 },
23854 getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes,
23855 ownerEncryption) {
23856 var hashData = new Uint8Array(password.length + 56);
23857 hashData.set(password, 0);
23858 hashData.set(ownerKeySalt, password.length);
23859 hashData.set(userBytes, password.length + ownerKeySalt.length);
23860 var key = calculateSHA256(hashData, 0, hashData.length);
23861 var cipher = new AES256Cipher(key);
23862 return cipher.decryptBlock(ownerEncryption,
23863 false,
23864 new Uint8Array(16));
23865
23866 },
23867 getUserKey: function PDF17_getUserKey(password, userKeySalt,
23868 userEncryption) {
23869 var hashData = new Uint8Array(password.length + 8);
23870 hashData.set(password, 0);
23871 hashData.set(userKeySalt, password.length);
23872 //key is the decryption key for the UE string
23873 var key = calculateSHA256(hashData, 0, hashData.length);
23874 var cipher = new AES256Cipher(key);
23875 return cipher.decryptBlock(userEncryption,
23876 false,
23877 new Uint8Array(16));
23878 }
23879 };
23880 return PDF17;
23881})();
23882
23883var PDF20 = (function PDF20Closure() {
23884
23885 function concatArrays(array1, array2) {
23886 var t = new Uint8Array(array1.length + array2.length);
23887 t.set(array1, 0);
23888 t.set(array2, array1.length);
23889 return t;
23890 }
23891
23892 function calculatePDF20Hash(password, input, userBytes) {
23893 //This refers to Algorithm 2.B as defined in ISO 32000-2
23894 var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
23895 var e = [0];
23896 var i = 0;
23897 while (i < 64 || e[e.length - 1] > i - 32) {
23898 var arrayLength = password.length + k.length + userBytes.length;
23899
23900 var k1 = new Uint8Array(arrayLength * 64);
23901 var array = concatArrays(password, k);
23902 array = concatArrays(array, userBytes);
23903 for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
23904 k1.set(array, pos);
23905 }
23906 //AES128 CBC NO PADDING with
23907 //first 16 bytes of k as the key and the second 16 as the iv.
23908 var cipher = new AES128Cipher(k.subarray(0, 16));
23909 e = cipher.encrypt(k1, k.subarray(16, 32));
23910 //Now we have to take the first 16 bytes of an unsigned
23911 //big endian integer... and compute the remainder
23912 //modulo 3.... That is a fairly large number and
23913 //JavaScript isn't going to handle that well...
23914 //So we're using a trick that allows us to perform
23915 //modulo math byte by byte
23916 var remainder = 0;
23917 for (var z = 0; z < 16; z++) {
23918 remainder *= (256 % 3);
23919 remainder %= 3;
23920 remainder += ((e[z] >>> 0) % 3);
23921 remainder %= 3;
23922 }
23923 if (remainder === 0) {
23924 k = calculateSHA256(e, 0, e.length);
23925 }
23926 else if (remainder === 1) {
23927 k = calculateSHA384(e, 0, e.length);
23928 }
23929 else if (remainder === 2) {
23930 k = calculateSHA512(e, 0, e.length);
23931 }
23932 i++;
23933 }
23934 return k.subarray(0, 32);
23935 }
23936
23937 function PDF20() {
23938 }
23939
23940 function compareByteArrays(array1, array2) {
23941 if (array1.length !== array2.length) {
23942 return false;
23943 }
23944 for (var i = 0; i < array1.length; i++) {
23945 if (array1[i] !== array2[i]) {
23946 return false;
23947 }
23948 }
23949 return true;
23950 }
23951
23952 PDF20.prototype = {
23953 hash: function PDF20_hash(password, concatBytes, userBytes) {
23954 return calculatePDF20Hash(password, concatBytes, userBytes);
23955 },
23956 checkOwnerPassword: function PDF20_checkOwnerPassword(password,
23957 ownerValidationSalt,
23958 userBytes,
23959 ownerPassword) {
23960 var hashData = new Uint8Array(password.length + 56);
23961 hashData.set(password, 0);
23962 hashData.set(ownerValidationSalt, password.length);
23963 hashData.set(userBytes, password.length + ownerValidationSalt.length);
23964 var result = calculatePDF20Hash(password, hashData, userBytes);
23965 return compareByteArrays(result, ownerPassword);
23966 },
23967 checkUserPassword: function PDF20_checkUserPassword(password,
23968 userValidationSalt,
23969 userPassword) {
23970 var hashData = new Uint8Array(password.length + 8);
23971 hashData.set(password, 0);
23972 hashData.set(userValidationSalt, password.length);
23973 var result = calculatePDF20Hash(password, hashData, []);
23974 return compareByteArrays(result, userPassword);
23975 },
23976 getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes,
23977 ownerEncryption) {
23978 var hashData = new Uint8Array(password.length + 56);
23979 hashData.set(password, 0);
23980 hashData.set(ownerKeySalt, password.length);
23981 hashData.set(userBytes, password.length + ownerKeySalt.length);
23982 var key = calculatePDF20Hash(password, hashData, userBytes);
23983 var cipher = new AES256Cipher(key);
23984 return cipher.decryptBlock(ownerEncryption,
23985 false,
23986 new Uint8Array(16));
23987
23988 },
23989 getUserKey: function PDF20_getUserKey(password, userKeySalt,
23990 userEncryption) {
23991 var hashData = new Uint8Array(password.length + 8);
23992 hashData.set(password, 0);
23993 hashData.set(userKeySalt, password.length);
23994 //key is the decryption key for the UE string
23995 var key = calculatePDF20Hash(password, hashData, []);
23996 var cipher = new AES256Cipher(key);
23997 return cipher.decryptBlock(userEncryption,
23998 false,
23999 new Uint8Array(16));
24000 }
24001 };
24002 return PDF20;
24003})();
24004
24005var CipherTransform = (function CipherTransformClosure() {
24006 function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
24007 this.stringCipherConstructor = stringCipherConstructor;
24008 this.streamCipherConstructor = streamCipherConstructor;
24009 }
24010
24011 CipherTransform.prototype = {
24012 createStream: function CipherTransform_createStream(stream, length) {
24013 var cipher = new this.streamCipherConstructor();
24014 return new DecryptStream(stream, length,
24015 function cipherTransformDecryptStream(data, finalize) {
24016 return cipher.decryptBlock(data, finalize);
24017 }
24018 );
24019 },
24020 decryptString: function CipherTransform_decryptString(s) {
24021 var cipher = new this.stringCipherConstructor();
24022 var data = stringToBytes(s);
24023 data = cipher.decryptBlock(data, true);
24024 return bytesToString(data);
24025 }
24026 };
24027 return CipherTransform;
24028})();
24029
24030var CipherTransformFactory = (function CipherTransformFactoryClosure() {
24031 var defaultPasswordBytes = new Uint8Array([
24032 0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41,
24033 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08,
24034 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80,
24035 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A]);
24036
24037 function createEncryptionKey20(revision, password, ownerPassword,
24038 ownerValidationSalt, ownerKeySalt, uBytes,
24039 userPassword, userValidationSalt, userKeySalt,
24040 ownerEncryption, userEncryption, perms) {
24041 if (password) {
24042 var passwordLength = Math.min(127, password.length);
24043 password = password.subarray(0, passwordLength);
24044 } else {
24045 password = [];
24046 }
24047 var pdfAlgorithm;
24048 if (revision === 6) {
24049 pdfAlgorithm = new PDF20();
24050 } else {
24051 pdfAlgorithm = new PDF17();
24052 }
24053
24054 if (pdfAlgorithm.checkUserPassword(password, userValidationSalt,
24055 userPassword)) {
24056 return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
24057 } else if (password.length && pdfAlgorithm.checkOwnerPassword(password,
24058 ownerValidationSalt,
24059 uBytes,
24060 ownerPassword)) {
24061 return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes,
24062 ownerEncryption);
24063 }
24064
24065 return null;
24066 }
24067
24068 function prepareKeyData(fileId, password, ownerPassword, userPassword,
24069 flags, revision, keyLength, encryptMetadata) {
24070 var hashDataSize = 40 + ownerPassword.length + fileId.length;
24071 var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
24072 if (password) {
24073 n = Math.min(32, password.length);
24074 for (; i < n; ++i) {
24075 hashData[i] = password[i];
24076 }
24077 }
24078 j = 0;
24079 while (i < 32) {
24080 hashData[i++] = defaultPasswordBytes[j++];
24081 }
24082 // as now the padded password in the hashData[0..i]
24083 for (j = 0, n = ownerPassword.length; j < n; ++j) {
24084 hashData[i++] = ownerPassword[j];
24085 }
24086 hashData[i++] = flags & 0xFF;
24087 hashData[i++] = (flags >> 8) & 0xFF;
24088 hashData[i++] = (flags >> 16) & 0xFF;
24089 hashData[i++] = (flags >>> 24) & 0xFF;
24090 for (j = 0, n = fileId.length; j < n; ++j) {
24091 hashData[i++] = fileId[j];
24092 }
24093 if (revision >= 4 && !encryptMetadata) {
24094 hashData[i++] = 0xFF;
24095 hashData[i++] = 0xFF;
24096 hashData[i++] = 0xFF;
24097 hashData[i++] = 0xFF;
24098 }
24099 var hash = calculateMD5(hashData, 0, i);
24100 var keyLengthInBytes = keyLength >> 3;
24101 if (revision >= 3) {
24102 for (j = 0; j < 50; ++j) {
24103 hash = calculateMD5(hash, 0, keyLengthInBytes);
24104 }
24105 }
24106 var encryptionKey = hash.subarray(0, keyLengthInBytes);
24107 var cipher, checkData;
24108
24109 if (revision >= 3) {
24110 for (i = 0; i < 32; ++i) {
24111 hashData[i] = defaultPasswordBytes[i];
24112 }
24113 for (j = 0, n = fileId.length; j < n; ++j) {
24114 hashData[i++] = fileId[j];
24115 }
24116 cipher = new ARCFourCipher(encryptionKey);
24117 checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
24118 n = encryptionKey.length;
24119 var derivedKey = new Uint8Array(n), k;
24120 for (j = 1; j <= 19; ++j) {
24121 for (k = 0; k < n; ++k) {
24122 derivedKey[k] = encryptionKey[k] ^ j;
24123 }
24124 cipher = new ARCFourCipher(derivedKey);
24125 checkData = cipher.encryptBlock(checkData);
24126 }
24127 for (j = 0, n = checkData.length; j < n; ++j) {
24128 if (userPassword[j] !== checkData[j]) {
24129 return null;
24130 }
24131 }
24132 } else {
24133 cipher = new ARCFourCipher(encryptionKey);
24134 checkData = cipher.encryptBlock(defaultPasswordBytes);
24135 for (j = 0, n = checkData.length; j < n; ++j) {
24136 if (userPassword[j] !== checkData[j]) {
24137 return null;
24138 }
24139 }
24140 }
24141 return encryptionKey;
24142 }
24143
24144 function decodeUserPassword(password, ownerPassword, revision, keyLength) {
24145 var hashData = new Uint8Array(32), i = 0, j, n;
24146 n = Math.min(32, password.length);
24147 for (; i < n; ++i) {
24148 hashData[i] = password[i];
24149 }
24150 j = 0;
24151 while (i < 32) {
24152 hashData[i++] = defaultPasswordBytes[j++];
24153 }
24154 var hash = calculateMD5(hashData, 0, i);
24155 var keyLengthInBytes = keyLength >> 3;
24156 if (revision >= 3) {
24157 for (j = 0; j < 50; ++j) {
24158 hash = calculateMD5(hash, 0, hash.length);
24159 }
24160 }
24161
24162 var cipher, userPassword;
24163 if (revision >= 3) {
24164 userPassword = ownerPassword;
24165 var derivedKey = new Uint8Array(keyLengthInBytes), k;
24166 for (j = 19; j >= 0; j--) {
24167 for (k = 0; k < keyLengthInBytes; ++k) {
24168 derivedKey[k] = hash[k] ^ j;
24169 }
24170 cipher = new ARCFourCipher(derivedKey);
24171 userPassword = cipher.encryptBlock(userPassword);
24172 }
24173 } else {
24174 cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
24175 userPassword = cipher.encryptBlock(ownerPassword);
24176 }
24177 return userPassword;
24178 }
24179
24180 var identityName = Name.get('Identity');
24181
24182 function CipherTransformFactory(dict, fileId, password) {
24183 var filter = dict.get('Filter');
24184 if (!isName(filter, 'Standard')) {
24185 error('unknown encryption method');
24186 }
24187 this.dict = dict;
24188 var algorithm = dict.get('V');
24189 if (!isInt(algorithm) ||
24190 (algorithm !== 1 && algorithm !== 2 && algorithm !== 4 &&
24191 algorithm !== 5)) {
24192 error('unsupported encryption algorithm');
24193 }
24194 this.algorithm = algorithm;
24195 var keyLength = dict.get('Length');
24196 if (!keyLength) {
24197 // Spec asks to rely on encryption dictionary's Length entry, however
24198 // some PDFs don't have it. Trying to recover.
24199 if (algorithm <= 3) {
24200 // For 1 and 2 it's fixed to 40-bit, for 3 40-bit is a minimal value.
24201 keyLength = 40;
24202 } else {
24203 // Trying to find default handler -- it usually has Length.
24204 var cfDict = dict.get('CF');
24205 var streamCryptoName = dict.get('StmF');
24206 if (isDict(cfDict) && isName(streamCryptoName)) {
24207 var handlerDict = cfDict.get(streamCryptoName.name);
24208 keyLength = (handlerDict && handlerDict.get('Length')) || 128;
24209 if (keyLength < 40) {
24210 // Sometimes it's incorrect value of bits, generators specify bytes.
24211 keyLength <<= 3;
24212 }
24213 }
24214 }
24215 }
24216 if (!isInt(keyLength) ||
24217 keyLength < 40 || (keyLength % 8) !== 0) {
24218 error('invalid key length');
24219 }
24220
24221 // prepare keys
24222 var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
24223 var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
24224 var flags = dict.get('P');
24225 var revision = dict.get('R');
24226 // meaningful when V is 4 or 5
24227 var encryptMetadata = ((algorithm === 4 || algorithm === 5) &&
24228 dict.get('EncryptMetadata') !== false);
24229 this.encryptMetadata = encryptMetadata;
24230
24231 var fileIdBytes = stringToBytes(fileId);
24232 var passwordBytes;
24233 if (password) {
24234 if (revision === 6) {
24235 try {
24236 password = utf8StringToString(password);
24237 } catch (ex) {
24238 warn('CipherTransformFactory: ' +
24239 'Unable to convert UTF8 encoded password.');
24240 }
24241 }
24242 passwordBytes = stringToBytes(password);
24243 }
24244
24245 var encryptionKey;
24246 if (algorithm !== 5) {
24247 encryptionKey = prepareKeyData(fileIdBytes, passwordBytes,
24248 ownerPassword, userPassword, flags,
24249 revision, keyLength, encryptMetadata);
24250 }
24251 else {
24252 var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
24253 var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
24254 var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
24255 var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
24256 var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
24257 var ownerEncryption = stringToBytes(dict.get('OE'));
24258 var userEncryption = stringToBytes(dict.get('UE'));
24259 var perms = stringToBytes(dict.get('Perms'));
24260 encryptionKey =
24261 createEncryptionKey20(revision, passwordBytes,
24262 ownerPassword, ownerValidationSalt,
24263 ownerKeySalt, uBytes,
24264 userPassword, userValidationSalt,
24265 userKeySalt, ownerEncryption,
24266 userEncryption, perms);
24267 }
24268 if (!encryptionKey && !password) {
24269 throw new PasswordException('No password given',
24270 PasswordResponses.NEED_PASSWORD);
24271 } else if (!encryptionKey && password) {
24272 // Attempting use the password as an owner password
24273 var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword,
24274 revision, keyLength);
24275 encryptionKey = prepareKeyData(fileIdBytes, decodedPassword,
24276 ownerPassword, userPassword, flags,
24277 revision, keyLength, encryptMetadata);
24278 }
24279
24280 if (!encryptionKey) {
24281 throw new PasswordException('Incorrect Password',
24282 PasswordResponses.INCORRECT_PASSWORD);
24283 }
24284
24285 this.encryptionKey = encryptionKey;
24286
24287 if (algorithm >= 4) {
24288 this.cf = dict.get('CF');
24289 this.stmf = dict.get('StmF') || identityName;
24290 this.strf = dict.get('StrF') || identityName;
24291 this.eff = dict.get('EFF') || this.stmf;
24292 }
24293 }
24294
24295 function buildObjectKey(num, gen, encryptionKey, isAes) {
24296 var key = new Uint8Array(encryptionKey.length + 9), i, n;
24297 for (i = 0, n = encryptionKey.length; i < n; ++i) {
24298 key[i] = encryptionKey[i];
24299 }
24300 key[i++] = num & 0xFF;
24301 key[i++] = (num >> 8) & 0xFF;
24302 key[i++] = (num >> 16) & 0xFF;
24303 key[i++] = gen & 0xFF;
24304 key[i++] = (gen >> 8) & 0xFF;
24305 if (isAes) {
24306 key[i++] = 0x73;
24307 key[i++] = 0x41;
24308 key[i++] = 0x6C;
24309 key[i++] = 0x54;
24310 }
24311 var hash = calculateMD5(key, 0, i);
24312 return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
24313 }
24314
24315 function buildCipherConstructor(cf, name, num, gen, key) {
24316 var cryptFilter = cf.get(name.name);
24317 var cfm;
24318 if (cryptFilter !== null && cryptFilter !== undefined) {
24319 cfm = cryptFilter.get('CFM');
24320 }
24321 if (!cfm || cfm.name === 'None') {
24322 return function cipherTransformFactoryBuildCipherConstructorNone() {
24323 return new NullCipher();
24324 };
24325 }
24326 if ('V2' === cfm.name) {
24327 return function cipherTransformFactoryBuildCipherConstructorV2() {
24328 return new ARCFourCipher(buildObjectKey(num, gen, key, false));
24329 };
24330 }
24331 if ('AESV2' === cfm.name) {
24332 return function cipherTransformFactoryBuildCipherConstructorAESV2() {
24333 return new AES128Cipher(buildObjectKey(num, gen, key, true));
24334 };
24335 }
24336 if ('AESV3' === cfm.name) {
24337 return function cipherTransformFactoryBuildCipherConstructorAESV3() {
24338 return new AES256Cipher(key);
24339 };
24340 }
24341 error('Unknown crypto method');
24342 }
24343
24344 CipherTransformFactory.prototype = {
24345 createCipherTransform:
24346 function CipherTransformFactory_createCipherTransform(num, gen) {
24347 if (this.algorithm === 4 || this.algorithm === 5) {
24348 return new CipherTransform(
24349 buildCipherConstructor(this.cf, this.stmf,
24350 num, gen, this.encryptionKey),
24351 buildCipherConstructor(this.cf, this.strf,
24352 num, gen, this.encryptionKey));
24353 }
24354 // algorithms 1 and 2
24355 var key = buildObjectKey(num, gen, this.encryptionKey, false);
24356 var cipherConstructor = function buildCipherCipherConstructor() {
24357 return new ARCFourCipher(key);
24358 };
24359 return new CipherTransform(cipherConstructor, cipherConstructor);
24360 }
24361 };
24362
24363 return CipherTransformFactory;
24364})();
24365
24366exports.AES128Cipher = AES128Cipher;
24367exports.AES256Cipher = AES256Cipher;
24368exports.ARCFourCipher = ARCFourCipher;
24369exports.CipherTransformFactory = CipherTransformFactory;
24370exports.PDF17 = PDF17;
24371exports.PDF20 = PDF20;
24372exports.calculateMD5 = calculateMD5;
24373exports.calculateSHA256 = calculateSHA256;
24374exports.calculateSHA384 = calculateSHA384;
24375exports.calculateSHA512 = calculateSHA512;
24376}));
24377
24378(function (root, factory) {
24379 {
24380 factory((root.pdfjsCoreFontRenderer = {}), root.pdfjsSharedUtil,
24381 root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings,
24382 root.pdfjsCoreCFFParser);
24383 }
24384}(this, function (exports, sharedUtil, coreStream, coreGlyphList,
24385 coreEncodings, coreCFFParser) {
24386
24387var Util = sharedUtil.Util;
24388var bytesToString = sharedUtil.bytesToString;
24389var error = sharedUtil.error;
24390var Stream = coreStream.Stream;
24391var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
24392var StandardEncoding = coreEncodings.StandardEncoding;
24393var CFFParser = coreCFFParser.CFFParser;
24394
24395var FontRendererFactory = (function FontRendererFactoryClosure() {
24396 function getLong(data, offset) {
24397 return (data[offset] << 24) | (data[offset + 1] << 16) |
24398 (data[offset + 2] << 8) | data[offset + 3];
24399 }
24400
24401 function getUshort(data, offset) {
24402 return (data[offset] << 8) | data[offset + 1];
24403 }
24404
24405 function parseCmap(data, start, end) {
24406 var offset = (getUshort(data, start + 2) === 1 ?
24407 getLong(data, start + 8) : getLong(data, start + 16));
24408 var format = getUshort(data, start + offset);
24409 var length, ranges, p, i;
24410 if (format === 4) {
24411 length = getUshort(data, start + offset + 2);
24412 var segCount = getUshort(data, start + offset + 6) >> 1;
24413 p = start + offset + 14;
24414 ranges = [];
24415 for (i = 0; i < segCount; i++, p += 2) {
24416 ranges[i] = {end: getUshort(data, p)};
24417 }
24418 p += 2;
24419 for (i = 0; i < segCount; i++, p += 2) {
24420 ranges[i].start = getUshort(data, p);
24421 }
24422 for (i = 0; i < segCount; i++, p += 2) {
24423 ranges[i].idDelta = getUshort(data, p);
24424 }
24425 for (i = 0; i < segCount; i++, p += 2) {
24426 var idOffset = getUshort(data, p);
24427 if (idOffset === 0) {
24428 continue;
24429 }
24430 ranges[i].ids = [];
24431 for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
24432 ranges[i].ids[j] = getUshort(data, p + idOffset);
24433 idOffset += 2;
24434 }
24435 }
24436 return ranges;
24437 } else if (format === 12) {
24438 length = getLong(data, start + offset + 4);
24439 var groups = getLong(data, start + offset + 12);
24440 p = start + offset + 16;
24441 ranges = [];
24442 for (i = 0; i < groups; i++) {
24443 ranges.push({
24444 start: getLong(data, p),
24445 end: getLong(data, p + 4),
24446 idDelta: getLong(data, p + 8) - getLong(data, p)
24447 });
24448 p += 12;
24449 }
24450 return ranges;
24451 }
24452 error('not supported cmap: ' + format);
24453 }
24454
24455 function parseCff(data, start, end, seacAnalysisEnabled) {
24456 var properties = {};
24457 var parser = new CFFParser(new Stream(data, start, end - start),
24458 properties, seacAnalysisEnabled);
24459 var cff = parser.parse();
24460 return {
24461 glyphs: cff.charStrings.objects,
24462 subrs: (cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex &&
24463 cff.topDict.privateDict.subrsIndex.objects),
24464 gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
24465 };
24466 }
24467
24468 function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
24469 var itemSize, itemDecode;
24470 if (isGlyphLocationsLong) {
24471 itemSize = 4;
24472 itemDecode = function fontItemDecodeLong(data, offset) {
24473 return (data[offset] << 24) | (data[offset + 1] << 16) |
24474 (data[offset + 2] << 8) | data[offset + 3];
24475 };
24476 } else {
24477 itemSize = 2;
24478 itemDecode = function fontItemDecode(data, offset) {
24479 return (data[offset] << 9) | (data[offset + 1] << 1);
24480 };
24481 }
24482 var glyphs = [];
24483 var startOffset = itemDecode(loca, 0);
24484 for (var j = itemSize; j < loca.length; j += itemSize) {
24485 var endOffset = itemDecode(loca, j);
24486 glyphs.push(glyf.subarray(startOffset, endOffset));
24487 startOffset = endOffset;
24488 }
24489 return glyphs;
24490 }
24491
24492 function lookupCmap(ranges, unicode) {
24493 var code = unicode.charCodeAt(0), gid = 0;
24494 var l = 0, r = ranges.length - 1;
24495 while (l < r) {
24496 var c = (l + r + 1) >> 1;
24497 if (code < ranges[c].start) {
24498 r = c - 1;
24499 } else {
24500 l = c;
24501 }
24502 }
24503 if (ranges[l].start <= code && code <= ranges[l].end) {
24504 gid = (ranges[l].idDelta + (ranges[l].ids ?
24505 ranges[l].ids[code - ranges[l].start] : code)) & 0xFFFF;
24506 }
24507 return {
24508 charCode: code,
24509 glyphId: gid,
24510 };
24511 }
24512
24513 function compileGlyf(code, cmds, font) {
24514 function moveTo(x, y) {
24515 cmds.push({cmd: 'moveTo', args: [x, y]});
24516 }
24517 function lineTo(x, y) {
24518 cmds.push({cmd: 'lineTo', args: [x, y]});
24519 }
24520 function quadraticCurveTo(xa, ya, x, y) {
24521 cmds.push({cmd: 'quadraticCurveTo', args: [xa, ya, x, y]});
24522 }
24523
24524 var i = 0;
24525 var numberOfContours = ((code[i] << 24) | (code[i + 1] << 16)) >> 16;
24526 var flags;
24527 var x = 0, y = 0;
24528 i += 10;
24529 if (numberOfContours < 0) {
24530 // composite glyph
24531 do {
24532 flags = (code[i] << 8) | code[i + 1];
24533 var glyphIndex = (code[i + 2] << 8) | code[i + 3];
24534 i += 4;
24535 var arg1, arg2;
24536 if ((flags & 0x01)) {
24537 arg1 = ((code[i] << 24) | (code[i + 1] << 16)) >> 16;
24538 arg2 = ((code[i + 2] << 24) | (code[i + 3] << 16)) >> 16;
24539 i += 4;
24540 } else {
24541 arg1 = code[i++]; arg2 = code[i++];
24542 }
24543 if ((flags & 0x02)) {
24544 x = arg1;
24545 y = arg2;
24546 } else {
24547 x = 0; y = 0; // TODO "they are points" ?
24548 }
24549 var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
24550 if ((flags & 0x08)) {
24551 scaleX =
24552 scaleY = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
24553 i += 2;
24554 } else if ((flags & 0x40)) {
24555 scaleX = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
24556 scaleY = ((code[i + 2] << 24) | (code[i + 3] << 16)) / 1073741824;
24557 i += 4;
24558 } else if ((flags & 0x80)) {
24559 scaleX = ((code[i] << 24) | (code[i + 1] << 16)) / 1073741824;
24560 scale01 = ((code[i + 2] << 24) | (code[i + 3] << 16)) / 1073741824;
24561 scale10 = ((code[i + 4] << 24) | (code[i + 5] << 16)) / 1073741824;
24562 scaleY = ((code[i + 6] << 24) | (code[i + 7] << 16)) / 1073741824;
24563 i += 8;
24564 }
24565 var subglyph = font.glyphs[glyphIndex];
24566 if (subglyph) {
24567 cmds.push({cmd: 'save'});
24568 cmds.push({cmd: 'transform',
24569 args: [scaleX, scale01, scale10, scaleY, x, y]});
24570 compileGlyf(subglyph, cmds, font);
24571 cmds.push({cmd: 'restore'});
24572 }
24573 } while ((flags & 0x20));
24574 } else {
24575 // simple glyph
24576 var endPtsOfContours = [];
24577 var j, jj;
24578 for (j = 0; j < numberOfContours; j++) {
24579 endPtsOfContours.push((code[i] << 8) | code[i + 1]);
24580 i += 2;
24581 }
24582 var instructionLength = (code[i] << 8) | code[i + 1];
24583 i += 2 + instructionLength; // skipping the instructions
24584 var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
24585 var points = [];
24586 while (points.length < numberOfPoints) {
24587 flags = code[i++];
24588 var repeat = 1;
24589 if ((flags & 0x08)) {
24590 repeat += code[i++];
24591 }
24592 while (repeat-- > 0) {
24593 points.push({flags: flags});
24594 }
24595 }
24596 for (j = 0; j < numberOfPoints; j++) {
24597 switch (points[j].flags & 0x12) {
24598 case 0x00:
24599 x += ((code[i] << 24) | (code[i + 1] << 16)) >> 16;
24600 i += 2;
24601 break;
24602 case 0x02:
24603 x -= code[i++];
24604 break;
24605 case 0x12:
24606 x += code[i++];
24607 break;
24608 }
24609 points[j].x = x;
24610 }
24611 for (j = 0; j < numberOfPoints; j++) {
24612 switch (points[j].flags & 0x24) {
24613 case 0x00:
24614 y += ((code[i] << 24) | (code[i + 1] << 16)) >> 16;
24615 i += 2;
24616 break;
24617 case 0x04:
24618 y -= code[i++];
24619 break;
24620 case 0x24:
24621 y += code[i++];
24622 break;
24623 }
24624 points[j].y = y;
24625 }
24626
24627 var startPoint = 0;
24628 for (i = 0; i < numberOfContours; i++) {
24629 var endPoint = endPtsOfContours[i];
24630 // contours might have implicit points, which is located in the middle
24631 // between two neighboring off-curve points
24632 var contour = points.slice(startPoint, endPoint + 1);
24633 if ((contour[0].flags & 1)) {
24634 contour.push(contour[0]); // using start point at the contour end
24635 } else if ((contour[contour.length - 1].flags & 1)) {
24636 // first is off-curve point, trying to use one from the end
24637 contour.unshift(contour[contour.length - 1]);
24638 } else {
24639 // start and end are off-curve points, creating implicit one
24640 var p = {
24641 flags: 1,
24642 x: (contour[0].x + contour[contour.length - 1].x) / 2,
24643 y: (contour[0].y + contour[contour.length - 1].y) / 2
24644 };
24645 contour.unshift(p);
24646 contour.push(p);
24647 }
24648 moveTo(contour[0].x, contour[0].y);
24649 for (j = 1, jj = contour.length; j < jj; j++) {
24650 if ((contour[j].flags & 1)) {
24651 lineTo(contour[j].x, contour[j].y);
24652 } else if ((contour[j + 1].flags & 1)){
24653 quadraticCurveTo(contour[j].x, contour[j].y,
24654 contour[j + 1].x, contour[j + 1].y);
24655 j++;
24656 } else {
24657 quadraticCurveTo(contour[j].x, contour[j].y,
24658 (contour[j].x + contour[j + 1].x) / 2,
24659 (contour[j].y + contour[j + 1].y) / 2);
24660 }
24661 }
24662 startPoint = endPoint + 1;
24663 }
24664 }
24665 }
24666
24667 function compileCharString(code, cmds, font) {
24668 var stack = [];
24669 var x = 0, y = 0;
24670 var stems = 0;
24671
24672 function moveTo(x, y) {
24673 cmds.push({cmd: 'moveTo', args: [x, y]});
24674 }
24675 function lineTo(x, y) {
24676 cmds.push({cmd: 'lineTo', args: [x, y]});
24677 }
24678 function bezierCurveTo(x1, y1, x2, y2, x, y) {
24679 cmds.push({cmd: 'bezierCurveTo', args: [x1, y1, x2, y2, x, y]});
24680 }
24681
24682 function parse(code) {
24683 var i = 0;
24684 while (i < code.length) {
24685 var stackClean = false;
24686 var v = code[i++];
24687 var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
24688 switch (v) {
24689 case 1: // hstem
24690 stems += stack.length >> 1;
24691 stackClean = true;
24692 break;
24693 case 3: // vstem
24694 stems += stack.length >> 1;
24695 stackClean = true;
24696 break;
24697 case 4: // vmoveto
24698 y += stack.pop();
24699 moveTo(x, y);
24700 stackClean = true;
24701 break;
24702 case 5: // rlineto
24703 while (stack.length > 0) {
24704 x += stack.shift();
24705 y += stack.shift();
24706 lineTo(x, y);
24707 }
24708 break;
24709 case 6: // hlineto
24710 while (stack.length > 0) {
24711 x += stack.shift();
24712 lineTo(x, y);
24713 if (stack.length === 0) {
24714 break;
24715 }
24716 y += stack.shift();
24717 lineTo(x, y);
24718 }
24719 break;
24720 case 7: // vlineto
24721 while (stack.length > 0) {
24722 y += stack.shift();
24723 lineTo(x, y);
24724 if (stack.length === 0) {
24725 break;
24726 }
24727 x += stack.shift();
24728 lineTo(x, y);
24729 }
24730 break;
24731 case 8: // rrcurveto
24732 while (stack.length > 0) {
24733 xa = x + stack.shift(); ya = y + stack.shift();
24734 xb = xa + stack.shift(); yb = ya + stack.shift();
24735 x = xb + stack.shift(); y = yb + stack.shift();
24736 bezierCurveTo(xa, ya, xb, yb, x, y);
24737 }
24738 break;
24739 case 10: // callsubr
24740 n = stack.pop() + font.subrsBias;
24741 subrCode = font.subrs[n];
24742 if (subrCode) {
24743 parse(subrCode);
24744 }
24745 break;
24746 case 11: // return
24747 return;
24748 case 12:
24749 v = code[i++];
24750 switch (v) {
24751 case 34: // flex
24752 xa = x + stack.shift();
24753 xb = xa + stack.shift(); y1 = y + stack.shift();
24754 x = xb + stack.shift();
24755 bezierCurveTo(xa, y, xb, y1, x, y1);
24756 xa = x + stack.shift();
24757 xb = xa + stack.shift();
24758 x = xb + stack.shift();
24759 bezierCurveTo(xa, y1, xb, y, x, y);
24760 break;
24761 case 35: // flex
24762 xa = x + stack.shift(); ya = y + stack.shift();
24763 xb = xa + stack.shift(); yb = ya + stack.shift();
24764 x = xb + stack.shift(); y = yb + stack.shift();
24765 bezierCurveTo(xa, ya, xb, yb, x, y);
24766 xa = x + stack.shift(); ya = y + stack.shift();
24767 xb = xa + stack.shift(); yb = ya + stack.shift();
24768 x = xb + stack.shift(); y = yb + stack.shift();
24769 bezierCurveTo(xa, ya, xb, yb, x, y);
24770 stack.pop(); // fd
24771 break;
24772 case 36: // hflex1
24773 xa = x + stack.shift(); y1 = y + stack.shift();
24774 xb = xa + stack.shift(); y2 = y1 + stack.shift();
24775 x = xb + stack.shift();
24776 bezierCurveTo(xa, y1, xb, y2, x, y2);
24777 xa = x + stack.shift();
24778 xb = xa + stack.shift(); y3 = y2 + stack.shift();
24779 x = xb + stack.shift();
24780 bezierCurveTo(xa, y2, xb, y3, x, y);
24781 break;
24782 case 37: // flex1
24783 var x0 = x, y0 = y;
24784 xa = x + stack.shift(); ya = y + stack.shift();
24785 xb = xa + stack.shift(); yb = ya + stack.shift();
24786 x = xb + stack.shift(); y = yb + stack.shift();
24787 bezierCurveTo(xa, ya, xb, yb, x, y);
24788 xa = x + stack.shift(); ya = y + stack.shift();
24789 xb = xa + stack.shift(); yb = ya + stack.shift();
24790 x = xb; y = yb;
24791 if (Math.abs(x - x0) > Math.abs(y - y0)) {
24792 x += stack.shift();
24793 } else {
24794 y += stack.shift();
24795 }
24796 bezierCurveTo(xa, ya, xb, yb, x, y);
24797 break;
24798 default:
24799 error('unknown operator: 12 ' + v);
24800 }
24801 break;
24802 case 14: // endchar
24803 if (stack.length >= 4) {
24804 var achar = stack.pop();
24805 var bchar = stack.pop();
24806 y = stack.pop();
24807 x = stack.pop();
24808 cmds.push({cmd: 'save'});
24809 cmds.push({cmd: 'translate', args: [x, y]});
24810 var cmap = lookupCmap(font.cmap, String.fromCharCode(
24811 font.glyphNameMap[StandardEncoding[achar]]));
24812 compileCharString(font.glyphs[cmap.glyphId], cmds, font);
24813 cmds.push({cmd: 'restore'});
24814
24815 cmap = lookupCmap(font.cmap, String.fromCharCode(
24816 font.glyphNameMap[StandardEncoding[bchar]]));
24817 compileCharString(font.glyphs[cmap.glyphId], cmds, font);
24818 }
24819 return;
24820 case 18: // hstemhm
24821 stems += stack.length >> 1;
24822 stackClean = true;
24823 break;
24824 case 19: // hintmask
24825 stems += stack.length >> 1;
24826 i += (stems + 7) >> 3;
24827 stackClean = true;
24828 break;
24829 case 20: // cntrmask
24830 stems += stack.length >> 1;
24831 i += (stems + 7) >> 3;
24832 stackClean = true;
24833 break;
24834 case 21: // rmoveto
24835 y += stack.pop();
24836 x += stack.pop();
24837 moveTo(x, y);
24838 stackClean = true;
24839 break;
24840 case 22: // hmoveto
24841 x += stack.pop();
24842 moveTo(x, y);
24843 stackClean = true;
24844 break;
24845 case 23: // vstemhm
24846 stems += stack.length >> 1;
24847 stackClean = true;
24848 break;
24849 case 24: // rcurveline
24850 while (stack.length > 2) {
24851 xa = x + stack.shift(); ya = y + stack.shift();
24852 xb = xa + stack.shift(); yb = ya + stack.shift();
24853 x = xb + stack.shift(); y = yb + stack.shift();
24854 bezierCurveTo(xa, ya, xb, yb, x, y);
24855 }
24856 x += stack.shift();
24857 y += stack.shift();
24858 lineTo(x, y);
24859 break;
24860 case 25: // rlinecurve
24861 while (stack.length > 6) {
24862 x += stack.shift();
24863 y += stack.shift();
24864 lineTo(x, y);
24865 }
24866 xa = x + stack.shift(); ya = y + stack.shift();
24867 xb = xa + stack.shift(); yb = ya + stack.shift();
24868 x = xb + stack.shift(); y = yb + stack.shift();
24869 bezierCurveTo(xa, ya, xb, yb, x, y);
24870 break;
24871 case 26: // vvcurveto
24872 if (stack.length % 2) {
24873 x += stack.shift();
24874 }
24875 while (stack.length > 0) {
24876 xa = x; ya = y + stack.shift();
24877 xb = xa + stack.shift(); yb = ya + stack.shift();
24878 x = xb; y = yb + stack.shift();
24879 bezierCurveTo(xa, ya, xb, yb, x, y);
24880 }
24881 break;
24882 case 27: // hhcurveto
24883 if (stack.length % 2) {
24884 y += stack.shift();
24885 }
24886 while (stack.length > 0) {
24887 xa = x + stack.shift(); ya = y;
24888 xb = xa + stack.shift(); yb = ya + stack.shift();
24889 x = xb + stack.shift(); y = yb;
24890 bezierCurveTo(xa, ya, xb, yb, x, y);
24891 }
24892 break;
24893 case 28:
24894 stack.push(((code[i] << 24) | (code[i + 1] << 16)) >> 16);
24895 i += 2;
24896 break;
24897 case 29: // callgsubr
24898 n = stack.pop() + font.gsubrsBias;
24899 subrCode = font.gsubrs[n];
24900 if (subrCode) {
24901 parse(subrCode);
24902 }
24903 break;
24904 case 30: // vhcurveto
24905 while (stack.length > 0) {
24906 xa = x; ya = y + stack.shift();
24907 xb = xa + stack.shift(); yb = ya + stack.shift();
24908 x = xb + stack.shift();
24909 y = yb + (stack.length === 1 ? stack.shift() : 0);
24910 bezierCurveTo(xa, ya, xb, yb, x, y);
24911 if (stack.length === 0) {
24912 break;
24913 }
24914
24915 xa = x + stack.shift(); ya = y;
24916 xb = xa + stack.shift(); yb = ya + stack.shift();
24917 y = yb + stack.shift();
24918 x = xb + (stack.length === 1 ? stack.shift() : 0);
24919 bezierCurveTo(xa, ya, xb, yb, x, y);
24920 }
24921 break;
24922 case 31: // hvcurveto
24923 while (stack.length > 0) {
24924 xa = x + stack.shift(); ya = y;
24925 xb = xa + stack.shift(); yb = ya + stack.shift();
24926 y = yb + stack.shift();
24927 x = xb + (stack.length === 1 ? stack.shift() : 0);
24928 bezierCurveTo(xa, ya, xb, yb, x, y);
24929 if (stack.length === 0) {
24930 break;
24931 }
24932
24933 xa = x; ya = y + stack.shift();
24934 xb = xa + stack.shift(); yb = ya + stack.shift();
24935 x = xb + stack.shift();
24936 y = yb + (stack.length === 1 ? stack.shift() : 0);
24937 bezierCurveTo(xa, ya, xb, yb, x, y);
24938 }
24939 break;
24940 default:
24941 if (v < 32) {
24942 error('unknown operator: ' + v);
24943 }
24944 if (v < 247) {
24945 stack.push(v - 139);
24946 } else if (v < 251) {
24947 stack.push((v - 247) * 256 + code[i++] + 108);
24948 } else if (v < 255) {
24949 stack.push(-(v - 251) * 256 - code[i++] - 108);
24950 } else {
24951 stack.push(((code[i] << 24) | (code[i + 1] << 16) |
24952 (code[i + 2] << 8) | code[i + 3]) / 65536);
24953 i += 4;
24954 }
24955 break;
24956 }
24957 if (stackClean) {
24958 stack.length = 0;
24959 }
24960 }
24961 }
24962 parse(code);
24963 }
24964
24965 var noop = '';
24966
24967 function CompiledFont(fontMatrix) {
24968 this.compiledGlyphs = Object.create(null);
24969 this.compiledCharCodeToGlyphId = Object.create(null);
24970 this.fontMatrix = fontMatrix;
24971 }
24972 CompiledFont.prototype = {
24973 getPathJs: function (unicode) {
24974 var cmap = lookupCmap(this.cmap, unicode);
24975 var fn = this.compiledGlyphs[cmap.glyphId];
24976 if (!fn) {
24977 fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
24978 this.compiledGlyphs[cmap.glyphId] = fn;
24979 }
24980 if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
24981 this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
24982 }
24983 return fn;
24984 },
24985
24986 compileGlyph: function (code) {
24987 if (!code || code.length === 0 || code[0] === 14) {
24988 return noop;
24989 }
24990
24991 var cmds = [];
24992 cmds.push({cmd: 'save'});
24993 cmds.push({cmd: 'transform', args: this.fontMatrix.slice()});
24994 cmds.push({cmd: 'scale', args: ['size', '-size']});
24995
24996 this.compileGlyphImpl(code, cmds);
24997
24998 cmds.push({cmd: 'restore'});
24999
25000 return cmds;
25001 },
25002
25003 compileGlyphImpl: function () {
25004 error('Children classes should implement this.');
25005 },
25006
25007 hasBuiltPath: function (unicode) {
25008 var cmap = lookupCmap(this.cmap, unicode);
25009 return (this.compiledGlyphs[cmap.glyphId] !== undefined &&
25010 this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined);
25011 }
25012 };
25013
25014 function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
25015 fontMatrix = fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0];
25016 CompiledFont.call(this, fontMatrix);
25017
25018 this.glyphs = glyphs;
25019 this.cmap = cmap;
25020 }
25021
25022 Util.inherit(TrueTypeCompiled, CompiledFont, {
25023 compileGlyphImpl: function (code, cmds) {
25024 compileGlyf(code, cmds, this);
25025 }
25026 });
25027
25028 function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
25029 fontMatrix = fontMatrix || [0.001, 0, 0, 0.001, 0, 0];
25030 CompiledFont.call(this, fontMatrix);
25031
25032 this.glyphs = cffInfo.glyphs;
25033 this.gsubrs = cffInfo.gsubrs || [];
25034 this.subrs = cffInfo.subrs || [];
25035 this.cmap = cmap;
25036 this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
25037
25038 this.gsubrsBias = (this.gsubrs.length < 1240 ?
25039 107 : (this.gsubrs.length < 33900 ? 1131 : 32768));
25040 this.subrsBias = (this.subrs.length < 1240 ?
25041 107 : (this.subrs.length < 33900 ? 1131 : 32768));
25042 }
25043
25044 Util.inherit(Type2Compiled, CompiledFont, {
25045 compileGlyphImpl: function (code, cmds) {
25046 compileCharString(code, cmds, this);
25047 }
25048 });
25049
25050
25051 return {
25052 create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
25053 var data = new Uint8Array(font.data);
25054 var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
25055 var numTables = getUshort(data, 4);
25056 for (var i = 0, p = 12; i < numTables; i++, p += 16) {
25057 var tag = bytesToString(data.subarray(p, p + 4));
25058 var offset = getLong(data, p + 8);
25059 var length = getLong(data, p + 12);
25060 switch (tag) {
25061 case 'cmap':
25062 cmap = parseCmap(data, offset, offset + length);
25063 break;
25064 case 'glyf':
25065 glyf = data.subarray(offset, offset + length);
25066 break;
25067 case 'loca':
25068 loca = data.subarray(offset, offset + length);
25069 break;
25070 case 'head':
25071 unitsPerEm = getUshort(data, offset + 18);
25072 indexToLocFormat = getUshort(data, offset + 50);
25073 break;
25074 case 'CFF ':
25075 cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
25076 break;
25077 }
25078 }
25079
25080 if (glyf) {
25081 var fontMatrix = (!unitsPerEm ? font.fontMatrix :
25082 [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0]);
25083 return new TrueTypeCompiled(
25084 parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
25085 } else {
25086 return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
25087 }
25088 }
25089 };
25090})();
25091
25092exports.FontRendererFactory = FontRendererFactory;
25093}));
25094
25095
25096(function (root, factory) {
25097 {
25098 factory((root.pdfjsCoreParser = {}), root.pdfjsSharedUtil,
25099 root.pdfjsCorePrimitives, root.pdfjsCoreStream);
25100 }
25101}(this, function (exports, sharedUtil, corePrimitives, coreStream) {
25102
25103var MissingDataException = sharedUtil.MissingDataException;
25104var StreamType = sharedUtil.StreamType;
25105var assert = sharedUtil.assert;
25106var error = sharedUtil.error;
25107var info = sharedUtil.info;
25108var isArray = sharedUtil.isArray;
25109var isInt = sharedUtil.isInt;
25110var isNum = sharedUtil.isNum;
25111var isString = sharedUtil.isString;
25112var warn = sharedUtil.warn;
25113var Cmd = corePrimitives.Cmd;
25114var Dict = corePrimitives.Dict;
25115var Name = corePrimitives.Name;
25116var Ref = corePrimitives.Ref;
25117var isCmd = corePrimitives.isCmd;
25118var isDict = corePrimitives.isDict;
25119var isName = corePrimitives.isName;
25120var Ascii85Stream = coreStream.Ascii85Stream;
25121var AsciiHexStream = coreStream.AsciiHexStream;
25122var CCITTFaxStream = coreStream.CCITTFaxStream;
25123var FlateStream = coreStream.FlateStream;
25124var Jbig2Stream = coreStream.Jbig2Stream;
25125var JpegStream = coreStream.JpegStream;
25126var JpxStream = coreStream.JpxStream;
25127var LZWStream = coreStream.LZWStream;
25128var NullStream = coreStream.NullStream;
25129var PredictorStream = coreStream.PredictorStream;
25130var RunLengthStream = coreStream.RunLengthStream;
25131
25132var EOF = {};
25133
25134function isEOF(v) {
25135 return (v === EOF);
25136}
25137
25138var MAX_LENGTH_TO_CACHE = 1000;
25139
25140var Parser = (function ParserClosure() {
25141 function Parser(lexer, allowStreams, xref, recoveryMode) {
25142 this.lexer = lexer;
25143 this.allowStreams = allowStreams;
25144 this.xref = xref;
25145 this.recoveryMode = recoveryMode || false;
25146 this.imageCache = Object.create(null);
25147 this.refill();
25148 }
25149
25150 Parser.prototype = {
25151 refill: function Parser_refill() {
25152 this.buf1 = this.lexer.getObj();
25153 this.buf2 = this.lexer.getObj();
25154 },
25155 shift: function Parser_shift() {
25156 if (isCmd(this.buf2, 'ID')) {
25157 this.buf1 = this.buf2;
25158 this.buf2 = null;
25159 } else {
25160 this.buf1 = this.buf2;
25161 this.buf2 = this.lexer.getObj();
25162 }
25163 },
25164 tryShift: function Parser_tryShift() {
25165 try {
25166 this.shift();
25167 return true;
25168 } catch (e) {
25169 if (e instanceof MissingDataException) {
25170 throw e;
25171 }
25172 // Upon failure, the caller should reset this.lexer.pos to a known good
25173 // state and call this.shift() twice to reset the buffers.
25174 return false;
25175 }
25176 },
25177 getObj: function Parser_getObj(cipherTransform) {
25178 var buf1 = this.buf1;
25179 this.shift();
25180
25181 if (buf1 instanceof Cmd) {
25182 switch (buf1.cmd) {
25183 case 'BI': // inline image
25184 return this.makeInlineImage(cipherTransform);
25185 case '[': // array
25186 var array = [];
25187 while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
25188 array.push(this.getObj(cipherTransform));
25189 }
25190 if (isEOF(this.buf1)) {
25191 if (!this.recoveryMode) {
25192 error('End of file inside array');
25193 }
25194 return array;
25195 }
25196 this.shift();
25197 return array;
25198 case '<<': // dictionary or stream
25199 var dict = new Dict(this.xref);
25200 while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
25201 if (!isName(this.buf1)) {
25202 info('Malformed dictionary: key must be a name object');
25203 this.shift();
25204 continue;
25205 }
25206
25207 var key = this.buf1.name;
25208 this.shift();
25209 if (isEOF(this.buf1)) {
25210 break;
25211 }
25212 dict.set(key, this.getObj(cipherTransform));
25213 }
25214 if (isEOF(this.buf1)) {
25215 if (!this.recoveryMode) {
25216 error('End of file inside dictionary');
25217 }
25218 return dict;
25219 }
25220
25221 // Stream objects are not allowed inside content streams or
25222 // object streams.
25223 if (isCmd(this.buf2, 'stream')) {
25224 return (this.allowStreams ?
25225 this.makeStream(dict, cipherTransform) : dict);
25226 }
25227 this.shift();
25228 return dict;
25229 default: // simple object
25230 return buf1;
25231 }
25232 }
25233
25234 if (isInt(buf1)) { // indirect reference or integer
25235 var num = buf1;
25236 if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
25237 var ref = new Ref(num, this.buf1);
25238 this.shift();
25239 this.shift();
25240 return ref;
25241 }
25242 return num;
25243 }
25244
25245 if (isString(buf1)) { // string
25246 var str = buf1;
25247 if (cipherTransform) {
25248 str = cipherTransform.decryptString(str);
25249 }
25250 return str;
25251 }
25252
25253 // simple object
25254 return buf1;
25255 },
25256 /**
25257 * Find the end of the stream by searching for the /EI\s/.
25258 * @returns {number} The inline stream length.
25259 */
25260 findDefaultInlineStreamEnd:
25261 function Parser_findDefaultInlineStreamEnd(stream) {
25262 var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
25263 var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
25264 while ((ch = stream.getByte()) !== -1) {
25265 if (state === 0) {
25266 state = (ch === E) ? 1 : 0;
25267 } else if (state === 1) {
25268 state = (ch === I) ? 2 : 0;
25269 } else {
25270 assert(state === 2);
25271 if (ch === SPACE || ch === LF || ch === CR) {
25272 // Let's check the next five bytes are ASCII... just be sure.
25273 n = 5;
25274 followingBytes = stream.peekBytes(n);
25275 for (i = 0; i < n; i++) {
25276 ch = followingBytes[i];
25277 if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
25278 // Not a LF, CR, SPACE or any visible ASCII character, i.e.
25279 // it's binary stuff. Resetting the state.
25280 state = 0;
25281 break;
25282 }
25283 }
25284 if (state === 2) {
25285 break; // Finished!
25286 }
25287 } else {
25288 state = 0;
25289 }
25290 }
25291 }
25292 return ((stream.pos - 4) - startPos);
25293 },
25294 /**
25295 * Find the EOI (end-of-image) marker 0xFFD9 of the stream.
25296 * @returns {number} The inline stream length.
25297 */
25298 findDCTDecodeInlineStreamEnd:
25299 function Parser_findDCTDecodeInlineStreamEnd(stream) {
25300 var startPos = stream.pos, foundEOI = false, b, markerLength, length;
25301 while ((b = stream.getByte()) !== -1) {
25302 if (b !== 0xFF) { // Not a valid marker.
25303 continue;
25304 }
25305 switch (stream.getByte()) {
25306 case 0x00: // Byte stuffing.
25307 // 0xFF00 appears to be a very common byte sequence in JPEG images.
25308 break;
25309
25310 case 0xFF: // Fill byte.
25311 // Avoid skipping a valid marker, resetting the stream position.
25312 stream.skip(-1);
25313 break;
25314
25315 case 0xD9: // EOI
25316 foundEOI = true;
25317 break;
25318
25319 case 0xC0: // SOF0
25320 case 0xC1: // SOF1
25321 case 0xC2: // SOF2
25322 case 0xC3: // SOF3
25323
25324 case 0xC5: // SOF5
25325 case 0xC6: // SOF6
25326 case 0xC7: // SOF7
25327
25328 case 0xC9: // SOF9
25329 case 0xCA: // SOF10
25330 case 0xCB: // SOF11
25331
25332 case 0xCD: // SOF13
25333 case 0xCE: // SOF14
25334 case 0xCF: // SOF15
25335
25336 case 0xC4: // DHT
25337 case 0xCC: // DAC
25338
25339 case 0xDA: // SOS
25340 case 0xDB: // DQT
25341 case 0xDC: // DNL
25342 case 0xDD: // DRI
25343 case 0xDE: // DHP
25344 case 0xDF: // EXP
25345
25346 case 0xE0: // APP0
25347 case 0xE1: // APP1
25348 case 0xE2: // APP2
25349 case 0xE3: // APP3
25350 case 0xE4: // APP4
25351 case 0xE5: // APP5
25352 case 0xE6: // APP6
25353 case 0xE7: // APP7
25354 case 0xE8: // APP8
25355 case 0xE9: // APP9
25356 case 0xEA: // APP10
25357 case 0xEB: // APP11
25358 case 0xEC: // APP12
25359 case 0xED: // APP13
25360 case 0xEE: // APP14
25361 case 0xEF: // APP15
25362
25363 case 0xFE: // COM
25364 // The marker should be followed by the length of the segment.
25365 markerLength = stream.getUint16();
25366 if (markerLength > 2) {
25367 // |markerLength| contains the byte length of the marker segment,
25368 // including its own length (2 bytes) and excluding the marker.
25369 stream.skip(markerLength - 2); // Jump to the next marker.
25370 } else {
25371 // The marker length is invalid, resetting the stream position.
25372 stream.skip(-2);
25373 }
25374 break;
25375 }
25376 if (foundEOI) {
25377 break;
25378 }
25379 }
25380 length = stream.pos - startPos;
25381 if (b === -1) {
25382 warn('Inline DCTDecode image stream: ' +
25383 'EOI marker not found, searching for /EI/ instead.');
25384 stream.skip(-length); // Reset the stream position.
25385 return this.findDefaultInlineStreamEnd(stream);
25386 }
25387 this.inlineStreamSkipEI(stream);
25388 return length;
25389 },
25390 /**
25391 * Find the EOD (end-of-data) marker '~>' (i.e. TILDE + GT) of the stream.
25392 * @returns {number} The inline stream length.
25393 */
25394 findASCII85DecodeInlineStreamEnd:
25395 function Parser_findASCII85DecodeInlineStreamEnd(stream) {
25396 var TILDE = 0x7E, GT = 0x3E;
25397 var startPos = stream.pos, ch, length;
25398 while ((ch = stream.getByte()) !== -1) {
25399 if (ch === TILDE && stream.peekByte() === GT) {
25400 stream.skip();
25401 break;
25402 }
25403 }
25404 length = stream.pos - startPos;
25405 if (ch === -1) {
25406 warn('Inline ASCII85Decode image stream: ' +
25407 'EOD marker not found, searching for /EI/ instead.');
25408 stream.skip(-length); // Reset the stream position.
25409 return this.findDefaultInlineStreamEnd(stream);
25410 }
25411 this.inlineStreamSkipEI(stream);
25412 return length;
25413 },
25414 /**
25415 * Find the EOD (end-of-data) marker '>' (i.e. GT) of the stream.
25416 * @returns {number} The inline stream length.
25417 */
25418 findASCIIHexDecodeInlineStreamEnd:
25419 function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
25420 var GT = 0x3E;
25421 var startPos = stream.pos, ch, length;
25422 while ((ch = stream.getByte()) !== -1) {
25423 if (ch === GT) {
25424 break;
25425 }
25426 }
25427 length = stream.pos - startPos;
25428 if (ch === -1) {
25429 warn('Inline ASCIIHexDecode image stream: ' +
25430 'EOD marker not found, searching for /EI/ instead.');
25431 stream.skip(-length); // Reset the stream position.
25432 return this.findDefaultInlineStreamEnd(stream);
25433 }
25434 this.inlineStreamSkipEI(stream);
25435 return length;
25436 },
25437 /**
25438 * Skip over the /EI/ for streams where we search for an EOD marker.
25439 */
25440 inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
25441 var E = 0x45, I = 0x49;
25442 var state = 0, ch;
25443 while ((ch = stream.getByte()) !== -1) {
25444 if (state === 0) {
25445 state = (ch === E) ? 1 : 0;
25446 } else if (state === 1) {
25447 state = (ch === I) ? 2 : 0;
25448 } else if (state === 2) {
25449 break;
25450 }
25451 }
25452 },
25453 makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
25454 var lexer = this.lexer;
25455 var stream = lexer.stream;
25456
25457 // Parse dictionary.
25458 var dict = new Dict(this.xref);
25459 while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
25460 if (!isName(this.buf1)) {
25461 error('Dictionary key must be a name object');
25462 }
25463 var key = this.buf1.name;
25464 this.shift();
25465 if (isEOF(this.buf1)) {
25466 break;
25467 }
25468 dict.set(key, this.getObj(cipherTransform));
25469 }
25470
25471 // Extract the name of the first (i.e. the current) image filter.
25472 var filter = dict.get('Filter', 'F'), filterName;
25473 if (isName(filter)) {
25474 filterName = filter.name;
25475 } else if (isArray(filter) && isName(filter[0])) {
25476 filterName = filter[0].name;
25477 }
25478
25479 // Parse image stream.
25480 var startPos = stream.pos, length, i, ii;
25481 if (filterName === 'DCTDecode' || filterName === 'DCT') {
25482 length = this.findDCTDecodeInlineStreamEnd(stream);
25483 } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
25484 length = this.findASCII85DecodeInlineStreamEnd(stream);
25485 } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
25486 length = this.findASCIIHexDecodeInlineStreamEnd(stream);
25487 } else {
25488 length = this.findDefaultInlineStreamEnd(stream);
25489 }
25490 var imageStream = stream.makeSubStream(startPos, length, dict);
25491
25492 // Cache all images below the MAX_LENGTH_TO_CACHE threshold by their
25493 // adler32 checksum.
25494 var adler32;
25495 if (length < MAX_LENGTH_TO_CACHE) {
25496 var imageBytes = imageStream.getBytes();
25497 imageStream.reset();
25498
25499 var a = 1;
25500 var b = 0;
25501 for (i = 0, ii = imageBytes.length; i < ii; ++i) {
25502 // No modulo required in the loop if imageBytes.length < 5552.
25503 a += imageBytes[i] & 0xff;
25504 b += a;
25505 }
25506 adler32 = ((b % 65521) << 16) | (a % 65521);
25507
25508 if (this.imageCache.adler32 === adler32) {
25509 this.buf2 = Cmd.get('EI');
25510 this.shift();
25511
25512 this.imageCache[adler32].reset();
25513 return this.imageCache[adler32];
25514 }
25515 }
25516
25517 if (cipherTransform) {
25518 imageStream = cipherTransform.createStream(imageStream, length);
25519 }
25520
25521 imageStream = this.filter(imageStream, dict, length);
25522 imageStream.dict = dict;
25523 if (adler32 !== undefined) {
25524 imageStream.cacheKey = 'inline_' + length + '_' + adler32;
25525 this.imageCache[adler32] = imageStream;
25526 }
25527
25528 this.buf2 = Cmd.get('EI');
25529 this.shift();
25530
25531 return imageStream;
25532 },
25533 makeStream: function Parser_makeStream(dict, cipherTransform) {
25534 var lexer = this.lexer;
25535 var stream = lexer.stream;
25536
25537 // get stream start position
25538 lexer.skipToNextLine();
25539 var pos = stream.pos - 1;
25540
25541 // get length
25542 var length = dict.get('Length');
25543 if (!isInt(length)) {
25544 info('Bad ' + length + ' attribute in stream');
25545 length = 0;
25546 }
25547
25548 // skip over the stream data
25549 stream.pos = pos + length;
25550 lexer.nextChar();
25551
25552 // Shift '>>' and check whether the new object marks the end of the stream
25553 if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
25554 this.shift(); // 'stream'
25555 } else {
25556 // bad stream length, scanning for endstream
25557 stream.pos = pos;
25558 var SCAN_BLOCK_SIZE = 2048;
25559 var ENDSTREAM_SIGNATURE_LENGTH = 9;
25560 var ENDSTREAM_SIGNATURE = [0x65, 0x6E, 0x64, 0x73, 0x74, 0x72, 0x65,
25561 0x61, 0x6D];
25562 var skipped = 0, found = false, i, j;
25563 while (stream.pos < stream.end) {
25564 var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
25565 var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
25566 if (scanLength <= 0) {
25567 break;
25568 }
25569 found = false;
25570 i = 0;
25571 while (i < scanLength) {
25572 j = 0;
25573 while (j < ENDSTREAM_SIGNATURE_LENGTH &&
25574 scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
25575 j++;
25576 }
25577 if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
25578 found = true;
25579 break;
25580 }
25581 i++;
25582 }
25583 if (found) {
25584 skipped += i;
25585 stream.pos += i;
25586 break;
25587 }
25588 skipped += scanLength;
25589 stream.pos += scanLength;
25590 }
25591 if (!found) {
25592 error('Missing endstream');
25593 }
25594 length = skipped;
25595
25596 lexer.nextChar();
25597 this.shift();
25598 this.shift();
25599 }
25600 this.shift(); // 'endstream'
25601
25602 stream = stream.makeSubStream(pos, length, dict);
25603 if (cipherTransform) {
25604 stream = cipherTransform.createStream(stream, length);
25605 }
25606 stream = this.filter(stream, dict, length);
25607 stream.dict = dict;
25608 return stream;
25609 },
25610 filter: function Parser_filter(stream, dict, length) {
25611 var filter = dict.get('Filter', 'F');
25612 var params = dict.get('DecodeParms', 'DP');
25613 if (isName(filter)) {
25614 return this.makeFilter(stream, filter.name, length, params);
25615 }
25616
25617 var maybeLength = length;
25618 if (isArray(filter)) {
25619 var filterArray = filter;
25620 var paramsArray = params;
25621 for (var i = 0, ii = filterArray.length; i < ii; ++i) {
25622 filter = filterArray[i];
25623 if (!isName(filter)) {
25624 error('Bad filter name: ' + filter);
25625 }
25626
25627 params = null;
25628 if (isArray(paramsArray) && (i in paramsArray)) {
25629 params = paramsArray[i];
25630 }
25631 stream = this.makeFilter(stream, filter.name, maybeLength, params);
25632 // after the first stream the length variable is invalid
25633 maybeLength = null;
25634 }
25635 }
25636 return stream;
25637 },
25638 makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
25639 if (stream.dict.get('Length') === 0 && !maybeLength) {
25640 warn('Empty "' + name + '" stream.');
25641 return new NullStream(stream);
25642 }
25643 try {
25644 if (params && this.xref) {
25645 params = this.xref.fetchIfRef(params);
25646 }
25647 var xrefStreamStats = this.xref.stats.streamTypes;
25648 if (name === 'FlateDecode' || name === 'Fl') {
25649 xrefStreamStats[StreamType.FLATE] = true;
25650 if (params) {
25651 return new PredictorStream(new FlateStream(stream, maybeLength),
25652 maybeLength, params);
25653 }
25654 return new FlateStream(stream, maybeLength);
25655 }
25656 if (name === 'LZWDecode' || name === 'LZW') {
25657 xrefStreamStats[StreamType.LZW] = true;
25658 var earlyChange = 1;
25659 if (params) {
25660 if (params.has('EarlyChange')) {
25661 earlyChange = params.get('EarlyChange');
25662 }
25663 return new PredictorStream(
25664 new LZWStream(stream, maybeLength, earlyChange),
25665 maybeLength, params);
25666 }
25667 return new LZWStream(stream, maybeLength, earlyChange);
25668 }
25669 if (name === 'DCTDecode' || name === 'DCT') {
25670 xrefStreamStats[StreamType.DCT] = true;
25671 return new JpegStream(stream, maybeLength, stream.dict);
25672 }
25673 if (name === 'JPXDecode' || name === 'JPX') {
25674 xrefStreamStats[StreamType.JPX] = true;
25675 return new JpxStream(stream, maybeLength, stream.dict);
25676 }
25677 if (name === 'ASCII85Decode' || name === 'A85') {
25678 xrefStreamStats[StreamType.A85] = true;
25679 return new Ascii85Stream(stream, maybeLength);
25680 }
25681 if (name === 'ASCIIHexDecode' || name === 'AHx') {
25682 xrefStreamStats[StreamType.AHX] = true;
25683 return new AsciiHexStream(stream, maybeLength);
25684 }
25685 if (name === 'CCITTFaxDecode' || name === 'CCF') {
25686 xrefStreamStats[StreamType.CCF] = true;
25687 return new CCITTFaxStream(stream, maybeLength, params);
25688 }
25689 if (name === 'RunLengthDecode' || name === 'RL') {
25690 xrefStreamStats[StreamType.RL] = true;
25691 return new RunLengthStream(stream, maybeLength);
25692 }
25693 if (name === 'JBIG2Decode') {
25694 xrefStreamStats[StreamType.JBIG] = true;
25695 return new Jbig2Stream(stream, maybeLength, stream.dict);
25696 }
25697 warn('filter "' + name + '" not supported yet');
25698 return stream;
25699 } catch (ex) {
25700 if (ex instanceof MissingDataException) {
25701 throw ex;
25702 }
25703 warn('Invalid stream: \"' + ex + '\"');
25704 return new NullStream(stream);
25705 }
25706 }
25707 };
25708
25709 return Parser;
25710})();
25711
25712var Lexer = (function LexerClosure() {
25713 function Lexer(stream, knownCommands) {
25714 this.stream = stream;
25715 this.nextChar();
25716
25717 // While lexing, we build up many strings one char at a time. Using += for
25718 // this can result in lots of garbage strings. It's better to build an
25719 // array of single-char strings and then join() them together at the end.
25720 // And reusing a single array (i.e. |this.strBuf|) over and over for this
25721 // purpose uses less memory than using a new array for each string.
25722 this.strBuf = [];
25723
25724 // The PDFs might have "glued" commands with other commands, operands or
25725 // literals, e.g. "q1". The knownCommands is a dictionary of the valid
25726 // commands and their prefixes. The prefixes are built the following way:
25727 // if there a command that is a prefix of the other valid command or
25728 // literal (e.g. 'f' and 'false') the following prefixes must be included,
25729 // 'fa', 'fal', 'fals'. The prefixes are not needed, if the command has no
25730 // other commands or literals as a prefix. The knowCommands is optional.
25731 this.knownCommands = knownCommands;
25732 }
25733
25734 // A '1' in this array means the character is white space. A '1' or
25735 // '2' means the character ends a name or command.
25736 var specialChars = [
25737 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, // 0x
25738 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
25739 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, // 2x
25740 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, // 3x
25741 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 4x
25742 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, // 5x
25743 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 6x
25744 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, // 7x
25745 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
25746 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
25747 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ax
25748 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // bx
25749 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // cx
25750 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // dx
25751 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ex
25752 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // fx
25753 ];
25754
25755 function toHexDigit(ch) {
25756 if (ch >= 0x30 && ch <= 0x39) { // '0'-'9'
25757 return ch & 0x0F;
25758 }
25759 if ((ch >= 0x41 && ch <= 0x46) || (ch >= 0x61 && ch <= 0x66)) {
25760 // 'A'-'F', 'a'-'f'
25761 return (ch & 0x0F) + 9;
25762 }
25763 return -1;
25764 }
25765
25766 Lexer.prototype = {
25767 nextChar: function Lexer_nextChar() {
25768 return (this.currentChar = this.stream.getByte());
25769 },
25770 peekChar: function Lexer_peekChar() {
25771 return this.stream.peekByte();
25772 },
25773 getNumber: function Lexer_getNumber() {
25774 var ch = this.currentChar;
25775 var eNotation = false;
25776 var divideBy = 0; // different from 0 if it's a floating point value
25777 var sign = 1;
25778
25779 if (ch === 0x2D) { // '-'
25780 sign = -1;
25781 ch = this.nextChar();
25782
25783 if (ch === 0x2D) { // '-'
25784 // Ignore double negative (this is consistent with Adobe Reader).
25785 ch = this.nextChar();
25786 }
25787 } else if (ch === 0x2B) { // '+'
25788 ch = this.nextChar();
25789 }
25790 if (ch === 0x2E) { // '.'
25791 divideBy = 10;
25792 ch = this.nextChar();
25793 }
25794 if (ch < 0x30 || ch > 0x39) { // '0' - '9'
25795 error('Invalid number: ' + String.fromCharCode(ch));
25796 return 0;
25797 }
25798
25799 var baseValue = ch - 0x30; // '0'
25800 var powerValue = 0;
25801 var powerValueSign = 1;
25802
25803 while ((ch = this.nextChar()) >= 0) {
25804 if (0x30 <= ch && ch <= 0x39) { // '0' - '9'
25805 var currentDigit = ch - 0x30; // '0'
25806 if (eNotation) { // We are after an 'e' or 'E'
25807 powerValue = powerValue * 10 + currentDigit;
25808 } else {
25809 if (divideBy !== 0) { // We are after a point
25810 divideBy *= 10;
25811 }
25812 baseValue = baseValue * 10 + currentDigit;
25813 }
25814 } else if (ch === 0x2E) { // '.'
25815 if (divideBy === 0) {
25816 divideBy = 1;
25817 } else {
25818 // A number can have only one '.'
25819 break;
25820 }
25821 } else if (ch === 0x2D) { // '-'
25822 // ignore minus signs in the middle of numbers to match
25823 // Adobe's behavior
25824 warn('Badly formatted number');
25825 } else if (ch === 0x45 || ch === 0x65) { // 'E', 'e'
25826 // 'E' can be either a scientific notation or the beginning of a new
25827 // operator
25828 ch = this.peekChar();
25829 if (ch === 0x2B || ch === 0x2D) { // '+', '-'
25830 powerValueSign = (ch === 0x2D) ? -1 : 1;
25831 this.nextChar(); // Consume the sign character
25832 } else if (ch < 0x30 || ch > 0x39) { // '0' - '9'
25833 // The 'E' must be the beginning of a new operator
25834 break;
25835 }
25836 eNotation = true;
25837 } else {
25838 // the last character doesn't belong to us
25839 break;
25840 }
25841 }
25842
25843 if (divideBy !== 0) {
25844 baseValue /= divideBy;
25845 }
25846 if (eNotation) {
25847 baseValue *= Math.pow(10, powerValueSign * powerValue);
25848 }
25849 return sign * baseValue;
25850 },
25851 getString: function Lexer_getString() {
25852 var numParen = 1;
25853 var done = false;
25854 var strBuf = this.strBuf;
25855 strBuf.length = 0;
25856
25857 var ch = this.nextChar();
25858 while (true) {
25859 var charBuffered = false;
25860 switch (ch | 0) {
25861 case -1:
25862 warn('Unterminated string');
25863 done = true;
25864 break;
25865 case 0x28: // '('
25866 ++numParen;
25867 strBuf.push('(');
25868 break;
25869 case 0x29: // ')'
25870 if (--numParen === 0) {
25871 this.nextChar(); // consume strings ')'
25872 done = true;
25873 } else {
25874 strBuf.push(')');
25875 }
25876 break;
25877 case 0x5C: // '\\'
25878 ch = this.nextChar();
25879 switch (ch) {
25880 case -1:
25881 warn('Unterminated string');
25882 done = true;
25883 break;
25884 case 0x6E: // 'n'
25885 strBuf.push('\n');
25886 break;
25887 case 0x72: // 'r'
25888 strBuf.push('\r');
25889 break;
25890 case 0x74: // 't'
25891 strBuf.push('\t');
25892 break;
25893 case 0x62: // 'b'
25894 strBuf.push('\b');
25895 break;
25896 case 0x66: // 'f'
25897 strBuf.push('\f');
25898 break;
25899 case 0x5C: // '\'
25900 case 0x28: // '('
25901 case 0x29: // ')'
25902 strBuf.push(String.fromCharCode(ch));
25903 break;
25904 case 0x30: case 0x31: case 0x32: case 0x33: // '0'-'3'
25905 case 0x34: case 0x35: case 0x36: case 0x37: // '4'-'7'
25906 var x = ch & 0x0F;
25907 ch = this.nextChar();
25908 charBuffered = true;
25909 if (ch >= 0x30 && ch <= 0x37) { // '0'-'7'
25910 x = (x << 3) + (ch & 0x0F);
25911 ch = this.nextChar();
25912 if (ch >= 0x30 && ch <= 0x37) { // '0'-'7'
25913 charBuffered = false;
25914 x = (x << 3) + (ch & 0x0F);
25915 }
25916 }
25917 strBuf.push(String.fromCharCode(x));
25918 break;
25919 case 0x0D: // CR
25920 if (this.peekChar() === 0x0A) { // LF
25921 this.nextChar();
25922 }
25923 break;
25924 case 0x0A: // LF
25925 break;
25926 default:
25927 strBuf.push(String.fromCharCode(ch));
25928 break;
25929 }
25930 break;
25931 default:
25932 strBuf.push(String.fromCharCode(ch));
25933 break;
25934 }
25935 if (done) {
25936 break;
25937 }
25938 if (!charBuffered) {
25939 ch = this.nextChar();
25940 }
25941 }
25942 return strBuf.join('');
25943 },
25944 getName: function Lexer_getName() {
25945 var ch, previousCh;
25946 var strBuf = this.strBuf;
25947 strBuf.length = 0;
25948 while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
25949 if (ch === 0x23) { // '#'
25950 ch = this.nextChar();
25951 if (specialChars[ch]) {
25952 warn('Lexer_getName: ' +
25953 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
25954 strBuf.push('#');
25955 break;
25956 }
25957 var x = toHexDigit(ch);
25958 if (x !== -1) {
25959 previousCh = ch;
25960 ch = this.nextChar();
25961 var x2 = toHexDigit(ch);
25962 if (x2 === -1) {
25963 warn('Lexer_getName: Illegal digit (' +
25964 String.fromCharCode(ch) +') in hexadecimal number.');
25965 strBuf.push('#', String.fromCharCode(previousCh));
25966 if (specialChars[ch]) {
25967 break;
25968 }
25969 strBuf.push(String.fromCharCode(ch));
25970 continue;
25971 }
25972 strBuf.push(String.fromCharCode((x << 4) | x2));
25973 } else {
25974 strBuf.push('#', String.fromCharCode(ch));
25975 }
25976 } else {
25977 strBuf.push(String.fromCharCode(ch));
25978 }
25979 }
25980 if (strBuf.length > 127) {
25981 warn('name token is longer than allowed by the spec: ' + strBuf.length);
25982 }
25983 return Name.get(strBuf.join(''));
25984 },
25985 getHexString: function Lexer_getHexString() {
25986 var strBuf = this.strBuf;
25987 strBuf.length = 0;
25988 var ch = this.currentChar;
25989 var isFirstHex = true;
25990 var firstDigit;
25991 var secondDigit;
25992 while (true) {
25993 if (ch < 0) {
25994 warn('Unterminated hex string');
25995 break;
25996 } else if (ch === 0x3E) { // '>'
25997 this.nextChar();
25998 break;
25999 } else if (specialChars[ch] === 1) {
26000 ch = this.nextChar();
26001 continue;
26002 } else {
26003 if (isFirstHex) {
26004 firstDigit = toHexDigit(ch);
26005 if (firstDigit === -1) {
26006 warn('Ignoring invalid character "' + ch + '" in hex string');
26007 ch = this.nextChar();
26008 continue;
26009 }
26010 } else {
26011 secondDigit = toHexDigit(ch);
26012 if (secondDigit === -1) {
26013 warn('Ignoring invalid character "' + ch + '" in hex string');
26014 ch = this.nextChar();
26015 continue;
26016 }
26017 strBuf.push(String.fromCharCode((firstDigit << 4) | secondDigit));
26018 }
26019 isFirstHex = !isFirstHex;
26020 ch = this.nextChar();
26021 }
26022 }
26023 return strBuf.join('');
26024 },
26025 getObj: function Lexer_getObj() {
26026 // skip whitespace and comments
26027 var comment = false;
26028 var ch = this.currentChar;
26029 while (true) {
26030 if (ch < 0) {
26031 return EOF;
26032 }
26033 if (comment) {
26034 if (ch === 0x0A || ch === 0x0D) { // LF, CR
26035 comment = false;
26036 }
26037 } else if (ch === 0x25) { // '%'
26038 comment = true;
26039 } else if (specialChars[ch] !== 1) {
26040 break;
26041 }
26042 ch = this.nextChar();
26043 }
26044
26045 // start reading token
26046 switch (ch | 0) {
26047 case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // '0'-'4'
26048 case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: // '5'-'9'
26049 case 0x2B: case 0x2D: case 0x2E: // '+', '-', '.'
26050 return this.getNumber();
26051 case 0x28: // '('
26052 return this.getString();
26053 case 0x2F: // '/'
26054 return this.getName();
26055 // array punctuation
26056 case 0x5B: // '['
26057 this.nextChar();
26058 return Cmd.get('[');
26059 case 0x5D: // ']'
26060 this.nextChar();
26061 return Cmd.get(']');
26062 // hex string or dict punctuation
26063 case 0x3C: // '<'
26064 ch = this.nextChar();
26065 if (ch === 0x3C) {
26066 // dict punctuation
26067 this.nextChar();
26068 return Cmd.get('<<');
26069 }
26070 return this.getHexString();
26071 // dict punctuation
26072 case 0x3E: // '>'
26073 ch = this.nextChar();
26074 if (ch === 0x3E) {
26075 this.nextChar();
26076 return Cmd.get('>>');
26077 }
26078 return Cmd.get('>');
26079 case 0x7B: // '{'
26080 this.nextChar();
26081 return Cmd.get('{');
26082 case 0x7D: // '}'
26083 this.nextChar();
26084 return Cmd.get('}');
26085 case 0x29: // ')'
26086 error('Illegal character: ' + ch);
26087 break;
26088 }
26089
26090 // command
26091 var str = String.fromCharCode(ch);
26092 var knownCommands = this.knownCommands;
26093 var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
26094 while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
26095 // stop if known command is found and next character does not make
26096 // the str a command
26097 var possibleCommand = str + String.fromCharCode(ch);
26098 if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
26099 break;
26100 }
26101 if (str.length === 128) {
26102 error('Command token too long: ' + str.length);
26103 }
26104 str = possibleCommand;
26105 knownCommandFound = knownCommands && knownCommands[str] !== undefined;
26106 }
26107 if (str === 'true') {
26108 return true;
26109 }
26110 if (str === 'false') {
26111 return false;
26112 }
26113 if (str === 'null') {
26114 return null;
26115 }
26116 return Cmd.get(str);
26117 },
26118 skipToNextLine: function Lexer_skipToNextLine() {
26119 var ch = this.currentChar;
26120 while (ch >= 0) {
26121 if (ch === 0x0D) { // CR
26122 ch = this.nextChar();
26123 if (ch === 0x0A) { // LF
26124 this.nextChar();
26125 }
26126 break;
26127 } else if (ch === 0x0A) { // LF
26128 this.nextChar();
26129 break;
26130 }
26131 ch = this.nextChar();
26132 }
26133 }
26134 };
26135
26136 return Lexer;
26137})();
26138
26139var Linearization = {
26140 create: function LinearizationCreate(stream) {
26141 function getInt(name, allowZeroValue) {
26142 var obj = linDict.get(name);
26143 if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
26144 return obj;
26145 }
26146 throw new Error('The "' + name + '" parameter in the linearization ' +
26147 'dictionary is invalid.');
26148 }
26149 function getHints() {
26150 var hints = linDict.get('H'), hintsLength, item;
26151 if (isArray(hints) &&
26152 ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
26153 for (var index = 0; index < hintsLength; index++) {
26154 if (!(isInt(item = hints[index]) && item > 0)) {
26155 throw new Error('Hint (' + index +
26156 ') in the linearization dictionary is invalid.');
26157 }
26158 }
26159 return hints;
26160 }
26161 throw new Error('Hint array in the linearization dictionary is invalid.');
26162 }
26163 var parser = new Parser(new Lexer(stream), false, null);
26164 var obj1 = parser.getObj();
26165 var obj2 = parser.getObj();
26166 var obj3 = parser.getObj();
26167 var linDict = parser.getObj();
26168 var obj, length;
26169 if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) &&
26170 isNum(obj = linDict.get('Linearized')) && obj > 0)) {
26171 return null; // No valid linearization dictionary found.
26172 } else if ((length = getInt('L')) !== stream.length) {
26173 throw new Error('The "L" parameter in the linearization dictionary ' +
26174 'does not equal the stream length.');
26175 }
26176 return {
26177 length: length,
26178 hints: getHints(),
26179 objectNumberFirst: getInt('O'),
26180 endFirst: getInt('E'),
26181 numPages: getInt('N'),
26182 mainXRefEntriesOffset: getInt('T'),
26183 pageFirst: (linDict.has('P') ? getInt('P', true) : 0)
26184 };
26185 }
26186};
26187
26188exports.EOF = EOF;
26189exports.Lexer = Lexer;
26190exports.Linearization = Linearization;
26191exports.Parser = Parser;
26192exports.isEOF = isEOF;
26193}));
26194
26195
26196(function (root, factory) {
26197 {
26198 factory((root.pdfjsCoreType1Parser = {}), root.pdfjsSharedUtil,
26199 root.pdfjsCoreStream, root.pdfjsCoreEncodings);
26200 }
26201}(this, function (exports, sharedUtil, coreStream, coreEncodings) {
26202
26203var warn = sharedUtil.warn;
26204var isSpace = sharedUtil.isSpace;
26205var Stream = coreStream.Stream;
26206var getEncoding = coreEncodings.getEncoding;
26207
26208// Hinting is currently disabled due to unknown problems on windows
26209// in tracemonkey and various other pdfs with type1 fonts.
26210var HINTING_ENABLED = false;
26211
26212/*
26213 * CharStrings are encoded following the the CharString Encoding sequence
26214 * describe in Chapter 6 of the "Adobe Type1 Font Format" specification.
26215 * The value in a byte indicates a command, a number, or subsequent bytes
26216 * that are to be interpreted in a special way.
26217 *
26218 * CharString Number Encoding:
26219 * A CharString byte containing the values from 32 through 255 inclusive
26220 * indicate an integer. These values are decoded in four ranges.
26221 *
26222 * 1. A CharString byte containing a value, v, between 32 and 246 inclusive,
26223 * indicate the integer v - 139. Thus, the integer values from -107 through
26224 * 107 inclusive may be encoded in single byte.
26225 *
26226 * 2. A CharString byte containing a value, v, between 247 and 250 inclusive,
26227 * indicates an integer involving the next byte, w, according to the formula:
26228 * [(v - 247) x 256] + w + 108
26229 *
26230 * 3. A CharString byte containing a value, v, between 251 and 254 inclusive,
26231 * indicates an integer involving the next byte, w, according to the formula:
26232 * -[(v - 251) * 256] - w - 108
26233 *
26234 * 4. A CharString containing the value 255 indicates that the next 4 bytes
26235 * are a two complement signed integer. The first of these bytes contains the
26236 * highest order bits, the second byte contains the next higher order bits
26237 * and the fourth byte contain the lowest order bits.
26238 *
26239 *
26240 * CharString Command Encoding:
26241 * CharStrings commands are encoded in 1 or 2 bytes.
26242 *
26243 * Single byte commands are encoded in 1 byte that contains a value between
26244 * 0 and 31 inclusive.
26245 * If a command byte contains the value 12, then the value in the next byte
26246 * indicates a command. This "escape" mechanism allows many extra commands
26247 * to be encoded and this encoding technique helps to minimize the length of
26248 * the charStrings.
26249 */
26250var Type1CharString = (function Type1CharStringClosure() {
26251 var COMMAND_MAP = {
26252 'hstem': [1],
26253 'vstem': [3],
26254 'vmoveto': [4],
26255 'rlineto': [5],
26256 'hlineto': [6],
26257 'vlineto': [7],
26258 'rrcurveto': [8],
26259 'callsubr': [10],
26260 'flex': [12, 35],
26261 'drop' : [12, 18],
26262 'endchar': [14],
26263 'rmoveto': [21],
26264 'hmoveto': [22],
26265 'vhcurveto': [30],
26266 'hvcurveto': [31]
26267 };
26268
26269 function Type1CharString() {
26270 this.width = 0;
26271 this.lsb = 0;
26272 this.flexing = false;
26273 this.output = [];
26274 this.stack = [];
26275 }
26276
26277 Type1CharString.prototype = {
26278 convert: function Type1CharString_convert(encoded, subrs,
26279 seacAnalysisEnabled) {
26280 var count = encoded.length;
26281 var error = false;
26282 var wx, sbx, subrNumber;
26283 for (var i = 0; i < count; i++) {
26284 var value = encoded[i];
26285 if (value < 32) {
26286 if (value === 12) {
26287 value = (value << 8) + encoded[++i];
26288 }
26289 switch (value) {
26290 case 1: // hstem
26291 if (!HINTING_ENABLED) {
26292 this.stack = [];
26293 break;
26294 }
26295 error = this.executeCommand(2, COMMAND_MAP.hstem);
26296 break;
26297 case 3: // vstem
26298 if (!HINTING_ENABLED) {
26299 this.stack = [];
26300 break;
26301 }
26302 error = this.executeCommand(2, COMMAND_MAP.vstem);
26303 break;
26304 case 4: // vmoveto
26305 if (this.flexing) {
26306 if (this.stack.length < 1) {
26307 error = true;
26308 break;
26309 }
26310 // Add the dx for flex and but also swap the values so they are
26311 // the right order.
26312 var dy = this.stack.pop();
26313 this.stack.push(0, dy);
26314 break;
26315 }
26316 error = this.executeCommand(1, COMMAND_MAP.vmoveto);
26317 break;
26318 case 5: // rlineto
26319 error = this.executeCommand(2, COMMAND_MAP.rlineto);
26320 break;
26321 case 6: // hlineto
26322 error = this.executeCommand(1, COMMAND_MAP.hlineto);
26323 break;
26324 case 7: // vlineto
26325 error = this.executeCommand(1, COMMAND_MAP.vlineto);
26326 break;
26327 case 8: // rrcurveto
26328 error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
26329 break;
26330 case 9: // closepath
26331 // closepath is a Type1 command that does not take argument and is
26332 // useless in Type2 and it can simply be ignored.
26333 this.stack = [];
26334 break;
26335 case 10: // callsubr
26336 if (this.stack.length < 1) {
26337 error = true;
26338 break;
26339 }
26340 subrNumber = this.stack.pop();
26341 error = this.convert(subrs[subrNumber], subrs,
26342 seacAnalysisEnabled);
26343 break;
26344 case 11: // return
26345 return error;
26346 case 13: // hsbw
26347 if (this.stack.length < 2) {
26348 error = true;
26349 break;
26350 }
26351 // To convert to type2 we have to move the width value to the
26352 // first part of the charstring and then use hmoveto with lsb.
26353 wx = this.stack.pop();
26354 sbx = this.stack.pop();
26355 this.lsb = sbx;
26356 this.width = wx;
26357 this.stack.push(wx, sbx);
26358 error = this.executeCommand(2, COMMAND_MAP.hmoveto);
26359 break;
26360 case 14: // endchar
26361 this.output.push(COMMAND_MAP.endchar[0]);
26362 break;
26363 case 21: // rmoveto
26364 if (this.flexing) {
26365 break;
26366 }
26367 error = this.executeCommand(2, COMMAND_MAP.rmoveto);
26368 break;
26369 case 22: // hmoveto
26370 if (this.flexing) {
26371 // Add the dy for flex.
26372 this.stack.push(0);
26373 break;
26374 }
26375 error = this.executeCommand(1, COMMAND_MAP.hmoveto);
26376 break;
26377 case 30: // vhcurveto
26378 error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
26379 break;
26380 case 31: // hvcurveto
26381 error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
26382 break;
26383 case (12 << 8) + 0: // dotsection
26384 // dotsection is a Type1 command to specify some hinting feature
26385 // for dots that do not take a parameter and it can safely be
26386 // ignored for Type2.
26387 this.stack = [];
26388 break;
26389 case (12 << 8) + 1: // vstem3
26390 if (!HINTING_ENABLED) {
26391 this.stack = [];
26392 break;
26393 }
26394 // [vh]stem3 are Type1 only and Type2 supports [vh]stem with
26395 // multiple parameters, so instead of returning [vh]stem3 take a
26396 // shortcut and return [vhstem] instead.
26397 error = this.executeCommand(2, COMMAND_MAP.vstem);
26398 break;
26399 case (12 << 8) + 2: // hstem3
26400 if (!HINTING_ENABLED) {
26401 this.stack = [];
26402 break;
26403 }
26404 // See vstem3.
26405 error = this.executeCommand(2, COMMAND_MAP.hstem);
26406 break;
26407 case (12 << 8) + 6: // seac
26408 // seac is like type 2's special endchar but it doesn't use the
26409 // first argument asb, so remove it.
26410 if (seacAnalysisEnabled) {
26411 this.seac = this.stack.splice(-4, 4);
26412 error = this.executeCommand(0, COMMAND_MAP.endchar);
26413 } else {
26414 error = this.executeCommand(4, COMMAND_MAP.endchar);
26415 }
26416 break;
26417 case (12 << 8) + 7: // sbw
26418 if (this.stack.length < 4) {
26419 error = true;
26420 break;
26421 }
26422 // To convert to type2 we have to move the width value to the
26423 // first part of the charstring and then use rmoveto with
26424 // (dx, dy). The height argument will not be used for vmtx and
26425 // vhea tables reconstruction -- ignoring it.
26426 var wy = this.stack.pop();
26427 wx = this.stack.pop();
26428 var sby = this.stack.pop();
26429 sbx = this.stack.pop();
26430 this.lsb = sbx;
26431 this.width = wx;
26432 this.stack.push(wx, sbx, sby);
26433 error = this.executeCommand(3, COMMAND_MAP.rmoveto);
26434 break;
26435 case (12 << 8) + 12: // div
26436 if (this.stack.length < 2) {
26437 error = true;
26438 break;
26439 }
26440 var num2 = this.stack.pop();
26441 var num1 = this.stack.pop();
26442 this.stack.push(num1 / num2);
26443 break;
26444 case (12 << 8) + 16: // callothersubr
26445 if (this.stack.length < 2) {
26446 error = true;
26447 break;
26448 }
26449 subrNumber = this.stack.pop();
26450 var numArgs = this.stack.pop();
26451 if (subrNumber === 0 && numArgs === 3) {
26452 var flexArgs = this.stack.splice(this.stack.length - 17, 17);
26453 this.stack.push(
26454 flexArgs[2] + flexArgs[0], // bcp1x + rpx
26455 flexArgs[3] + flexArgs[1], // bcp1y + rpy
26456 flexArgs[4], // bcp2x
26457 flexArgs[5], // bcp2y
26458 flexArgs[6], // p2x
26459 flexArgs[7], // p2y
26460 flexArgs[8], // bcp3x
26461 flexArgs[9], // bcp3y
26462 flexArgs[10], // bcp4x
26463 flexArgs[11], // bcp4y
26464 flexArgs[12], // p3x
26465 flexArgs[13], // p3y
26466 flexArgs[14] // flexDepth
26467 // 15 = finalx unused by flex
26468 // 16 = finaly unused by flex
26469 );
26470 error = this.executeCommand(13, COMMAND_MAP.flex, true);
26471 this.flexing = false;
26472 this.stack.push(flexArgs[15], flexArgs[16]);
26473 } else if (subrNumber === 1 && numArgs === 0) {
26474 this.flexing = true;
26475 }
26476 break;
26477 case (12 << 8) + 17: // pop
26478 // Ignore this since it is only used with othersubr.
26479 break;
26480 case (12 << 8) + 33: // setcurrentpoint
26481 // Ignore for now.
26482 this.stack = [];
26483 break;
26484 default:
26485 warn('Unknown type 1 charstring command of "' + value + '"');
26486 break;
26487 }
26488 if (error) {
26489 break;
26490 }
26491 continue;
26492 } else if (value <= 246) {
26493 value = value - 139;
26494 } else if (value <= 250) {
26495 value = ((value - 247) * 256) + encoded[++i] + 108;
26496 } else if (value <= 254) {
26497 value = -((value - 251) * 256) - encoded[++i] - 108;
26498 } else {
26499 value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 |
26500 (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
26501 }
26502 this.stack.push(value);
26503 }
26504 return error;
26505 },
26506
26507 executeCommand: function(howManyArgs, command, keepStack) {
26508 var stackLength = this.stack.length;
26509 if (howManyArgs > stackLength) {
26510 return true;
26511 }
26512 var start = stackLength - howManyArgs;
26513 for (var i = start; i < stackLength; i++) {
26514 var value = this.stack[i];
26515 if (value === (value | 0)) { // int
26516 this.output.push(28, (value >> 8) & 0xff, value & 0xff);
26517 } else { // fixed point
26518 value = (65536 * value) | 0;
26519 this.output.push(255,
26520 (value >> 24) & 0xFF,
26521 (value >> 16) & 0xFF,
26522 (value >> 8) & 0xFF,
26523 value & 0xFF);
26524 }
26525 }
26526 this.output.push.apply(this.output, command);
26527 if (keepStack) {
26528 this.stack.splice(start, howManyArgs);
26529 } else {
26530 this.stack.length = 0;
26531 }
26532 return false;
26533 }
26534 };
26535
26536 return Type1CharString;
26537})();
26538
26539/*
26540 * Type1Parser encapsulate the needed code for parsing a Type1 font
26541 * program. Some of its logic depends on the Type2 charstrings
26542 * structure.
26543 * Note: this doesn't really parse the font since that would require evaluation
26544 * of PostScript, but it is possible in most cases to extract what we need
26545 * without a full parse.
26546 */
26547var Type1Parser = (function Type1ParserClosure() {
26548 /*
26549 * Decrypt a Sequence of Ciphertext Bytes to Produce the Original Sequence
26550 * of Plaintext Bytes. The function took a key as a parameter which can be
26551 * for decrypting the eexec block of for decoding charStrings.
26552 */
26553 var EEXEC_ENCRYPT_KEY = 55665;
26554 var CHAR_STRS_ENCRYPT_KEY = 4330;
26555
26556 function isHexDigit(code) {
26557 return code >= 48 && code <= 57 || // '0'-'9'
26558 code >= 65 && code <= 70 || // 'A'-'F'
26559 code >= 97 && code <= 102; // 'a'-'f'
26560 }
26561
26562 function decrypt(data, key, discardNumber) {
26563 if (discardNumber >= data.length) {
26564 return new Uint8Array(0);
26565 }
26566 var r = key | 0, c1 = 52845, c2 = 22719, i, j;
26567 for (i = 0; i < discardNumber; i++) {
26568 r = ((data[i] + r) * c1 + c2) & ((1 << 16) - 1);
26569 }
26570 var count = data.length - discardNumber;
26571 var decrypted = new Uint8Array(count);
26572 for (i = discardNumber, j = 0; j < count; i++, j++) {
26573 var value = data[i];
26574 decrypted[j] = value ^ (r >> 8);
26575 r = ((value + r) * c1 + c2) & ((1 << 16) - 1);
26576 }
26577 return decrypted;
26578 }
26579
26580 function decryptAscii(data, key, discardNumber) {
26581 var r = key | 0, c1 = 52845, c2 = 22719;
26582 var count = data.length, maybeLength = count >>> 1;
26583 var decrypted = new Uint8Array(maybeLength);
26584 var i, j;
26585 for (i = 0, j = 0; i < count; i++) {
26586 var digit1 = data[i];
26587 if (!isHexDigit(digit1)) {
26588 continue;
26589 }
26590 i++;
26591 var digit2;
26592 while (i < count && !isHexDigit(digit2 = data[i])) {
26593 i++;
26594 }
26595 if (i < count) {
26596 var value = parseInt(String.fromCharCode(digit1, digit2), 16);
26597 decrypted[j++] = value ^ (r >> 8);
26598 r = ((value + r) * c1 + c2) & ((1 << 16) - 1);
26599 }
26600 }
26601 return Array.prototype.slice.call(decrypted, discardNumber, j);
26602 }
26603
26604 function isSpecial(c) {
26605 return c === 0x2F || // '/'
26606 c === 0x5B || c === 0x5D || // '[', ']'
26607 c === 0x7B || c === 0x7D || // '{', '}'
26608 c === 0x28 || c === 0x29; // '(', ')'
26609 }
26610
26611 function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
26612 if (encrypted) {
26613 var data = stream.getBytes();
26614 var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) &&
26615 isHexDigit(data[2]) && isHexDigit(data[3]));
26616 stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) :
26617 decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
26618 }
26619 this.seacAnalysisEnabled = !!seacAnalysisEnabled;
26620
26621 this.stream = stream;
26622 this.nextChar();
26623 }
26624
26625 Type1Parser.prototype = {
26626 readNumberArray: function Type1Parser_readNumberArray() {
26627 this.getToken(); // read '[' or '{' (arrays can start with either)
26628 var array = [];
26629 while (true) {
26630 var token = this.getToken();
26631 if (token === null || token === ']' || token === '}') {
26632 break;
26633 }
26634 array.push(parseFloat(token || 0));
26635 }
26636 return array;
26637 },
26638
26639 readNumber: function Type1Parser_readNumber() {
26640 var token = this.getToken();
26641 return parseFloat(token || 0);
26642 },
26643
26644 readInt: function Type1Parser_readInt() {
26645 // Use '| 0' to prevent setting a double into length such as the double
26646 // does not flow into the loop variable.
26647 var token = this.getToken();
26648 return parseInt(token || 0, 10) | 0;
26649 },
26650
26651 readBoolean: function Type1Parser_readBoolean() {
26652 var token = this.getToken();
26653
26654 // Use 1 and 0 since that's what type2 charstrings use.
26655 return token === 'true' ? 1 : 0;
26656 },
26657
26658 nextChar : function Type1_nextChar() {
26659 return (this.currentChar = this.stream.getByte());
26660 },
26661
26662 getToken: function Type1Parser_getToken() {
26663 // Eat whitespace and comments.
26664 var comment = false;
26665 var ch = this.currentChar;
26666 while (true) {
26667 if (ch === -1) {
26668 return null;
26669 }
26670
26671 if (comment) {
26672 if (ch === 0x0A || ch === 0x0D) {
26673 comment = false;
26674 }
26675 } else if (ch === 0x25) { // '%'
26676 comment = true;
26677 } else if (!isSpace(ch)) {
26678 break;
26679 }
26680 ch = this.nextChar();
26681 }
26682 if (isSpecial(ch)) {
26683 this.nextChar();
26684 return String.fromCharCode(ch);
26685 }
26686 var token = '';
26687 do {
26688 token += String.fromCharCode(ch);
26689 ch = this.nextChar();
26690 } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
26691 return token;
26692 },
26693
26694 /*
26695 * Returns an object containing a Subrs array and a CharStrings
26696 * array extracted from and eexec encrypted block of data
26697 */
26698 extractFontProgram: function Type1Parser_extractFontProgram() {
26699 var stream = this.stream;
26700
26701 var subrs = [], charstrings = [];
26702 var privateData = Object.create(null);
26703 privateData['lenIV'] = 4;
26704 var program = {
26705 subrs: [],
26706 charstrings: [],
26707 properties: {
26708 'privateData': privateData
26709 }
26710 };
26711 var token, length, data, lenIV, encoded;
26712 while ((token = this.getToken()) !== null) {
26713 if (token !== '/') {
26714 continue;
26715 }
26716 token = this.getToken();
26717 switch (token) {
26718 case 'CharStrings':
26719 // The number immediately following CharStrings must be greater or
26720 // equal to the number of CharStrings.
26721 this.getToken();
26722 this.getToken(); // read in 'dict'
26723 this.getToken(); // read in 'dup'
26724 this.getToken(); // read in 'begin'
26725 while(true) {
26726 token = this.getToken();
26727 if (token === null || token === 'end') {
26728 break;
26729 }
26730
26731 if (token !== '/') {
26732 continue;
26733 }
26734 var glyph = this.getToken();
26735 length = this.readInt();
26736 this.getToken(); // read in 'RD' or '-|'
26737 data = stream.makeSubStream(stream.pos, length);
26738 lenIV = program.properties.privateData['lenIV'];
26739 encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
26740 // Skip past the required space and binary data.
26741 stream.skip(length);
26742 this.nextChar();
26743 token = this.getToken(); // read in 'ND' or '|-'
26744 if (token === 'noaccess') {
26745 this.getToken(); // read in 'def'
26746 }
26747 charstrings.push({
26748 glyph: glyph,
26749 encoded: encoded
26750 });
26751 }
26752 break;
26753 case 'Subrs':
26754 var num = this.readInt();
26755 this.getToken(); // read in 'array'
26756 while ((token = this.getToken()) === 'dup') {
26757 var index = this.readInt();
26758 length = this.readInt();
26759 this.getToken(); // read in 'RD' or '-|'
26760 data = stream.makeSubStream(stream.pos, length);
26761 lenIV = program.properties.privateData['lenIV'];
26762 encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
26763 // Skip past the required space and binary data.
26764 stream.skip(length);
26765 this.nextChar();
26766 token = this.getToken(); // read in 'NP' or '|'
26767 if (token === 'noaccess') {
26768 this.getToken(); // read in 'put'
26769 }
26770 subrs[index] = encoded;
26771 }
26772 break;
26773 case 'BlueValues':
26774 case 'OtherBlues':
26775 case 'FamilyBlues':
26776 case 'FamilyOtherBlues':
26777 var blueArray = this.readNumberArray();
26778 // *Blue* values may contain invalid data: disables reading of
26779 // those values when hinting is disabled.
26780 if (blueArray.length > 0 && (blueArray.length % 2) === 0 &&
26781 HINTING_ENABLED) {
26782 program.properties.privateData[token] = blueArray;
26783 }
26784 break;
26785 case 'StemSnapH':
26786 case 'StemSnapV':
26787 program.properties.privateData[token] = this.readNumberArray();
26788 break;
26789 case 'StdHW':
26790 case 'StdVW':
26791 program.properties.privateData[token] =
26792 this.readNumberArray()[0];
26793 break;
26794 case 'BlueShift':
26795 case 'lenIV':
26796 case 'BlueFuzz':
26797 case 'BlueScale':
26798 case 'LanguageGroup':
26799 case 'ExpansionFactor':
26800 program.properties.privateData[token] = this.readNumber();
26801 break;
26802 case 'ForceBold':
26803 program.properties.privateData[token] = this.readBoolean();
26804 break;
26805 }
26806 }
26807
26808 for (var i = 0; i < charstrings.length; i++) {
26809 glyph = charstrings[i].glyph;
26810 encoded = charstrings[i].encoded;
26811 var charString = new Type1CharString();
26812 var error = charString.convert(encoded, subrs,
26813 this.seacAnalysisEnabled);
26814 var output = charString.output;
26815 if (error) {
26816 // It seems when FreeType encounters an error while evaluating a glyph
26817 // that it completely ignores the glyph so we'll mimic that behaviour
26818 // here and put an endchar to make the validator happy.
26819 output = [14];
26820 }
26821 program.charstrings.push({
26822 glyphName: glyph,
26823 charstring: output,
26824 width: charString.width,
26825 lsb: charString.lsb,
26826 seac: charString.seac
26827 });
26828 }
26829
26830 return program;
26831 },
26832
26833 extractFontHeader: function Type1Parser_extractFontHeader(properties) {
26834 var token;
26835 while ((token = this.getToken()) !== null) {
26836 if (token !== '/') {
26837 continue;
26838 }
26839 token = this.getToken();
26840 switch (token) {
26841 case 'FontMatrix':
26842 var matrix = this.readNumberArray();
26843 properties.fontMatrix = matrix;
26844 break;
26845 case 'Encoding':
26846 var encodingArg = this.getToken();
26847 var encoding;
26848 if (!/^\d+$/.test(encodingArg)) {
26849 // encoding name is specified
26850 encoding = getEncoding(encodingArg);
26851 } else {
26852 encoding = [];
26853 var size = parseInt(encodingArg, 10) | 0;
26854 this.getToken(); // read in 'array'
26855
26856 for (var j = 0; j < size; j++) {
26857 token = this.getToken();
26858 // skipping till first dup or def (e.g. ignoring for statement)
26859 while (token !== 'dup' && token !== 'def') {
26860 token = this.getToken();
26861 if (token === null) {
26862 return; // invalid header
26863 }
26864 }
26865 if (token === 'def') {
26866 break; // read all array data
26867 }
26868 var index = this.readInt();
26869 this.getToken(); // read in '/'
26870 var glyph = this.getToken();
26871 encoding[index] = glyph;
26872 this.getToken(); // read the in 'put'
26873 }
26874 }
26875 properties.builtInEncoding = encoding;
26876 break;
26877 case 'FontBBox':
26878 var fontBBox = this.readNumberArray();
26879 // adjusting ascent/descent
26880 properties.ascent = fontBBox[3];
26881 properties.descent = fontBBox[1];
26882 properties.ascentScaled = true;
26883 break;
26884 }
26885 }
26886 }
26887 };
26888
26889 return Type1Parser;
26890})();
26891
26892exports.Type1Parser = Type1Parser;
26893}));
26894
26895
26896(function (root, factory) {
26897 {
26898 factory((root.pdfjsCoreCMap = {}), root.pdfjsSharedUtil,
26899 root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
26900 }
26901}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
26902
26903var Util = sharedUtil.Util;
26904var assert = sharedUtil.assert;
26905var warn = sharedUtil.warn;
26906var error = sharedUtil.error;
26907var isInt = sharedUtil.isInt;
26908var isString = sharedUtil.isString;
26909var MissingDataException = sharedUtil.MissingDataException;
26910var isName = corePrimitives.isName;
26911var isCmd = corePrimitives.isCmd;
26912var isStream = corePrimitives.isStream;
26913var StringStream = coreStream.StringStream;
26914var Lexer = coreParser.Lexer;
26915var isEOF = coreParser.isEOF;
26916
26917var BUILT_IN_CMAPS = [
26918// << Start unicode maps.
26919'Adobe-GB1-UCS2',
26920'Adobe-CNS1-UCS2',
26921'Adobe-Japan1-UCS2',
26922'Adobe-Korea1-UCS2',
26923// >> End unicode maps.
26924'78-EUC-H',
26925'78-EUC-V',
26926'78-H',
26927'78-RKSJ-H',
26928'78-RKSJ-V',
26929'78-V',
26930'78ms-RKSJ-H',
26931'78ms-RKSJ-V',
26932'83pv-RKSJ-H',
26933'90ms-RKSJ-H',
26934'90ms-RKSJ-V',
26935'90msp-RKSJ-H',
26936'90msp-RKSJ-V',
26937'90pv-RKSJ-H',
26938'90pv-RKSJ-V',
26939'Add-H',
26940'Add-RKSJ-H',
26941'Add-RKSJ-V',
26942'Add-V',
26943'Adobe-CNS1-0',
26944'Adobe-CNS1-1',
26945'Adobe-CNS1-2',
26946'Adobe-CNS1-3',
26947'Adobe-CNS1-4',
26948'Adobe-CNS1-5',
26949'Adobe-CNS1-6',
26950'Adobe-GB1-0',
26951'Adobe-GB1-1',
26952'Adobe-GB1-2',
26953'Adobe-GB1-3',
26954'Adobe-GB1-4',
26955'Adobe-GB1-5',
26956'Adobe-Japan1-0',
26957'Adobe-Japan1-1',
26958'Adobe-Japan1-2',
26959'Adobe-Japan1-3',
26960'Adobe-Japan1-4',
26961'Adobe-Japan1-5',
26962'Adobe-Japan1-6',
26963'Adobe-Korea1-0',
26964'Adobe-Korea1-1',
26965'Adobe-Korea1-2',
26966'B5-H',
26967'B5-V',
26968'B5pc-H',
26969'B5pc-V',
26970'CNS-EUC-H',
26971'CNS-EUC-V',
26972'CNS1-H',
26973'CNS1-V',
26974'CNS2-H',
26975'CNS2-V',
26976'ETHK-B5-H',
26977'ETHK-B5-V',
26978'ETen-B5-H',
26979'ETen-B5-V',
26980'ETenms-B5-H',
26981'ETenms-B5-V',
26982'EUC-H',
26983'EUC-V',
26984'Ext-H',
26985'Ext-RKSJ-H',
26986'Ext-RKSJ-V',
26987'Ext-V',
26988'GB-EUC-H',
26989'GB-EUC-V',
26990'GB-H',
26991'GB-V',
26992'GBK-EUC-H',
26993'GBK-EUC-V',
26994'GBK2K-H',
26995'GBK2K-V',
26996'GBKp-EUC-H',
26997'GBKp-EUC-V',
26998'GBT-EUC-H',
26999'GBT-EUC-V',
27000'GBT-H',
27001'GBT-V',
27002'GBTpc-EUC-H',
27003'GBTpc-EUC-V',
27004'GBpc-EUC-H',
27005'GBpc-EUC-V',
27006'H',
27007'HKdla-B5-H',
27008'HKdla-B5-V',
27009'HKdlb-B5-H',
27010'HKdlb-B5-V',
27011'HKgccs-B5-H',
27012'HKgccs-B5-V',
27013'HKm314-B5-H',
27014'HKm314-B5-V',
27015'HKm471-B5-H',
27016'HKm471-B5-V',
27017'HKscs-B5-H',
27018'HKscs-B5-V',
27019'Hankaku',
27020'Hiragana',
27021'KSC-EUC-H',
27022'KSC-EUC-V',
27023'KSC-H',
27024'KSC-Johab-H',
27025'KSC-Johab-V',
27026'KSC-V',
27027'KSCms-UHC-H',
27028'KSCms-UHC-HW-H',
27029'KSCms-UHC-HW-V',
27030'KSCms-UHC-V',
27031'KSCpc-EUC-H',
27032'KSCpc-EUC-V',
27033'Katakana',
27034'NWP-H',
27035'NWP-V',
27036'RKSJ-H',
27037'RKSJ-V',
27038'Roman',
27039'UniCNS-UCS2-H',
27040'UniCNS-UCS2-V',
27041'UniCNS-UTF16-H',
27042'UniCNS-UTF16-V',
27043'UniCNS-UTF32-H',
27044'UniCNS-UTF32-V',
27045'UniCNS-UTF8-H',
27046'UniCNS-UTF8-V',
27047'UniGB-UCS2-H',
27048'UniGB-UCS2-V',
27049'UniGB-UTF16-H',
27050'UniGB-UTF16-V',
27051'UniGB-UTF32-H',
27052'UniGB-UTF32-V',
27053'UniGB-UTF8-H',
27054'UniGB-UTF8-V',
27055'UniJIS-UCS2-H',
27056'UniJIS-UCS2-HW-H',
27057'UniJIS-UCS2-HW-V',
27058'UniJIS-UCS2-V',
27059'UniJIS-UTF16-H',
27060'UniJIS-UTF16-V',
27061'UniJIS-UTF32-H',
27062'UniJIS-UTF32-V',
27063'UniJIS-UTF8-H',
27064'UniJIS-UTF8-V',
27065'UniJIS2004-UTF16-H',
27066'UniJIS2004-UTF16-V',
27067'UniJIS2004-UTF32-H',
27068'UniJIS2004-UTF32-V',
27069'UniJIS2004-UTF8-H',
27070'UniJIS2004-UTF8-V',
27071'UniJISPro-UCS2-HW-V',
27072'UniJISPro-UCS2-V',
27073'UniJISPro-UTF8-V',
27074'UniJISX0213-UTF32-H',
27075'UniJISX0213-UTF32-V',
27076'UniJISX02132004-UTF32-H',
27077'UniJISX02132004-UTF32-V',
27078'UniKS-UCS2-H',
27079'UniKS-UCS2-V',
27080'UniKS-UTF16-H',
27081'UniKS-UTF16-V',
27082'UniKS-UTF32-H',
27083'UniKS-UTF32-V',
27084'UniKS-UTF8-H',
27085'UniKS-UTF8-V',
27086'V',
27087'WP-Symbol'];
27088
27089// CMap, not to be confused with TrueType's cmap.
27090var CMap = (function CMapClosure() {
27091 function CMap(builtInCMap) {
27092 // Codespace ranges are stored as follows:
27093 // [[1BytePairs], [2BytePairs], [3BytePairs], [4BytePairs]]
27094 // where nBytePairs are ranges e.g. [low1, high1, low2, high2, ...]
27095 this.codespaceRanges = [[], [], [], []];
27096 this.numCodespaceRanges = 0;
27097 // Map entries have one of two forms.
27098 // - cid chars are 16-bit unsigned integers, stored as integers.
27099 // - bf chars are variable-length byte sequences, stored as strings, with
27100 // one byte per character.
27101 this._map = [];
27102 this.name = '';
27103 this.vertical = false;
27104 this.useCMap = null;
27105 this.builtInCMap = builtInCMap;
27106 }
27107 CMap.prototype = {
27108 addCodespaceRange: function(n, low, high) {
27109 this.codespaceRanges[n - 1].push(low, high);
27110 this.numCodespaceRanges++;
27111 },
27112
27113 mapCidRange: function(low, high, dstLow) {
27114 while (low <= high) {
27115 this._map[low++] = dstLow++;
27116 }
27117 },
27118
27119 mapBfRange: function(low, high, dstLow) {
27120 var lastByte = dstLow.length - 1;
27121 while (low <= high) {
27122 this._map[low++] = dstLow;
27123 // Only the last byte has to be incremented.
27124 dstLow = dstLow.substr(0, lastByte) +
27125 String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
27126 }
27127 },
27128
27129 mapBfRangeToArray: function(low, high, array) {
27130 var i = 0, ii = array.length;
27131 while (low <= high && i < ii) {
27132 this._map[low] = array[i++];
27133 ++low;
27134 }
27135 },
27136
27137 // This is used for both bf and cid chars.
27138 mapOne: function(src, dst) {
27139 this._map[src] = dst;
27140 },
27141
27142 lookup: function(code) {
27143 return this._map[code];
27144 },
27145
27146 contains: function(code) {
27147 return this._map[code] !== undefined;
27148 },
27149
27150 forEach: function(callback) {
27151 // Most maps have fewer than 65536 entries, and for those we use normal
27152 // array iteration. But really sparse tables are possible -- e.g. with
27153 // indices in the *billions*. For such tables we use for..in, which isn't
27154 // ideal because it stringifies the indices for all present elements, but
27155 // it does avoid iterating over every undefined entry.
27156 var map = this._map;
27157 var length = map.length;
27158 var i;
27159 if (length <= 0x10000) {
27160 for (i = 0; i < length; i++) {
27161 if (map[i] !== undefined) {
27162 callback(i, map[i]);
27163 }
27164 }
27165 } else {
27166 for (i in this._map) {
27167 callback(i, map[i]);
27168 }
27169 }
27170 },
27171
27172 charCodeOf: function(value) {
27173 return this._map.indexOf(value);
27174 },
27175
27176 getMap: function() {
27177 return this._map;
27178 },
27179
27180 readCharCode: function(str, offset, out) {
27181 var c = 0;
27182 var codespaceRanges = this.codespaceRanges;
27183 var codespaceRangesLen = this.codespaceRanges.length;
27184 // 9.7.6.2 CMap Mapping
27185 // The code length is at most 4.
27186 for (var n = 0; n < codespaceRangesLen; n++) {
27187 c = ((c << 8) | str.charCodeAt(offset + n)) >>> 0;
27188 // Check each codespace range to see if it falls within.
27189 var codespaceRange = codespaceRanges[n];
27190 for (var k = 0, kk = codespaceRange.length; k < kk;) {
27191 var low = codespaceRange[k++];
27192 var high = codespaceRange[k++];
27193 if (c >= low && c <= high) {
27194 out.charcode = c;
27195 out.length = n + 1;
27196 return;
27197 }
27198 }
27199 }
27200 out.charcode = 0;
27201 out.length = 1;
27202 },
27203
27204 get length() {
27205 return this._map.length;
27206 },
27207
27208 get isIdentityCMap() {
27209 if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
27210 return false;
27211 }
27212 if (this._map.length !== 0x10000) {
27213 return false;
27214 }
27215 for (var i = 0; i < 0x10000; i++) {
27216 if (this._map[i] !== i) {
27217 return false;
27218 }
27219 }
27220 return true;
27221 }
27222 };
27223 return CMap;
27224})();
27225
27226// A special case of CMap, where the _map array implicitly has a length of
27227// 65536 and each element is equal to its index.
27228var IdentityCMap = (function IdentityCMapClosure() {
27229 function IdentityCMap(vertical, n) {
27230 CMap.call(this);
27231 this.vertical = vertical;
27232 this.addCodespaceRange(n, 0, 0xffff);
27233 }
27234 Util.inherit(IdentityCMap, CMap, {});
27235
27236 IdentityCMap.prototype = {
27237 addCodespaceRange: CMap.prototype.addCodespaceRange,
27238
27239 mapCidRange: function(low, high, dstLow) {
27240 error('should not call mapCidRange');
27241 },
27242
27243 mapBfRange: function(low, high, dstLow) {
27244 error('should not call mapBfRange');
27245 },
27246
27247 mapBfRangeToArray: function(low, high, array) {
27248 error('should not call mapBfRangeToArray');
27249 },
27250
27251 mapOne: function(src, dst) {
27252 error('should not call mapCidOne');
27253 },
27254
27255 lookup: function(code) {
27256 return (isInt(code) && code <= 0xffff) ? code : undefined;
27257 },
27258
27259 contains: function(code) {
27260 return isInt(code) && code <= 0xffff;
27261 },
27262
27263 forEach: function(callback) {
27264 for (var i = 0; i <= 0xffff; i++) {
27265 callback(i, i);
27266 }
27267 },
27268
27269 charCodeOf: function(value) {
27270 return (isInt(value) && value <= 0xffff) ? value : -1;
27271 },
27272
27273 getMap: function() {
27274 // Sometimes identity maps must be instantiated, but it's rare.
27275 var map = new Array(0x10000);
27276 for (var i = 0; i <= 0xffff; i++) {
27277 map[i] = i;
27278 }
27279 return map;
27280 },
27281
27282 readCharCode: CMap.prototype.readCharCode,
27283
27284 get length() {
27285 return 0x10000;
27286 },
27287
27288 get isIdentityCMap() {
27289 error('should not access .isIdentityCMap');
27290 }
27291 };
27292
27293 return IdentityCMap;
27294})();
27295
27296var BinaryCMapReader = (function BinaryCMapReaderClosure() {
27297 function fetchBinaryData(url) {
27298 return new Promise(function (resolve, reject) {
27299 var request = new XMLHttpRequest();
27300 request.open('GET', url, true);
27301 request.responseType = 'arraybuffer';
27302 request.onreadystatechange = function () {
27303 if (request.readyState === XMLHttpRequest.DONE) {
27304 if (!request.response || request.status !== 200 &&
27305 request.status !== 0) {
27306 reject(new Error('Unable to get binary cMap at: ' + url));
27307 } else {
27308 resolve(new Uint8Array(request.response));
27309 }
27310 }
27311 };
27312 request.send(null);
27313 });
27314 }
27315
27316 function hexToInt(a, size) {
27317 var n = 0;
27318 for (var i = 0; i <= size; i++) {
27319 n = (n << 8) | a[i];
27320 }
27321 return n >>> 0;
27322 }
27323
27324 function hexToStr(a, size) {
27325 // This code is hot. Special-case some common values to avoid creating an
27326 // object with subarray().
27327 if (size === 1) {
27328 return String.fromCharCode(a[0], a[1]);
27329 }
27330 if (size === 3) {
27331 return String.fromCharCode(a[0], a[1], a[2], a[3]);
27332 }
27333 return String.fromCharCode.apply(null, a.subarray(0, size + 1));
27334 }
27335
27336 function addHex(a, b, size) {
27337 var c = 0;
27338 for (var i = size; i >= 0; i--) {
27339 c += a[i] + b[i];
27340 a[i] = c & 255;
27341 c >>= 8;
27342 }
27343 }
27344
27345 function incHex(a, size) {
27346 var c = 1;
27347 for (var i = size; i >= 0 && c > 0; i--) {
27348 c += a[i];
27349 a[i] = c & 255;
27350 c >>= 8;
27351 }
27352 }
27353
27354 var MAX_NUM_SIZE = 16;
27355 var MAX_ENCODED_NUM_SIZE = 19; // ceil(MAX_NUM_SIZE * 7 / 8)
27356
27357 function BinaryCMapStream(data) {
27358 this.buffer = data;
27359 this.pos = 0;
27360 this.end = data.length;
27361 this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
27362 }
27363
27364 BinaryCMapStream.prototype = {
27365 readByte: function () {
27366 if (this.pos >= this.end) {
27367 return -1;
27368 }
27369 return this.buffer[this.pos++];
27370 },
27371 readNumber: function () {
27372 var n = 0;
27373 var last;
27374 do {
27375 var b = this.readByte();
27376 if (b < 0) {
27377 error('unexpected EOF in bcmap');
27378 }
27379 last = !(b & 0x80);
27380 n = (n << 7) | (b & 0x7F);
27381 } while (!last);
27382 return n;
27383 },
27384 readSigned: function () {
27385 var n = this.readNumber();
27386 return (n & 1) ? ~(n >>> 1) : n >>> 1;
27387 },
27388 readHex: function (num, size) {
27389 num.set(this.buffer.subarray(this.pos,
27390 this.pos + size + 1));
27391 this.pos += size + 1;
27392 },
27393 readHexNumber: function (num, size) {
27394 var last;
27395 var stack = this.tmpBuf, sp = 0;
27396 do {
27397 var b = this.readByte();
27398 if (b < 0) {
27399 error('unexpected EOF in bcmap');
27400 }
27401 last = !(b & 0x80);
27402 stack[sp++] = b & 0x7F;
27403 } while (!last);
27404 var i = size, buffer = 0, bufferSize = 0;
27405 while (i >= 0) {
27406 while (bufferSize < 8 && stack.length > 0) {
27407 buffer = (stack[--sp] << bufferSize) | buffer;
27408 bufferSize += 7;
27409 }
27410 num[i] = buffer & 255;
27411 i--;
27412 buffer >>= 8;
27413 bufferSize -= 8;
27414 }
27415 },
27416 readHexSigned: function (num, size) {
27417 this.readHexNumber(num, size);
27418 var sign = num[size] & 1 ? 255 : 0;
27419 var c = 0;
27420 for (var i = 0; i <= size; i++) {
27421 c = ((c & 1) << 8) | num[i];
27422 num[i] = (c >> 1) ^ sign;
27423 }
27424 },
27425 readString: function () {
27426 var len = this.readNumber();
27427 var s = '';
27428 for (var i = 0; i < len; i++) {
27429 s += String.fromCharCode(this.readNumber());
27430 }
27431 return s;
27432 }
27433 };
27434
27435 function processBinaryCMap(url, cMap, extend) {
27436 return fetchBinaryData(url).then(function (data) {
27437 var stream = new BinaryCMapStream(data);
27438 var header = stream.readByte();
27439 cMap.vertical = !!(header & 1);
27440
27441 var useCMap = null;
27442 var start = new Uint8Array(MAX_NUM_SIZE);
27443 var end = new Uint8Array(MAX_NUM_SIZE);
27444 var char = new Uint8Array(MAX_NUM_SIZE);
27445 var charCode = new Uint8Array(MAX_NUM_SIZE);
27446 var tmp = new Uint8Array(MAX_NUM_SIZE);
27447 var code;
27448
27449 var b;
27450 while ((b = stream.readByte()) >= 0) {
27451 var type = b >> 5;
27452 if (type === 7) { // metadata, e.g. comment or usecmap
27453 switch (b & 0x1F) {
27454 case 0:
27455 stream.readString(); // skipping comment
27456 break;
27457 case 1:
27458 useCMap = stream.readString();
27459 break;
27460 }
27461 continue;
27462 }
27463 var sequence = !!(b & 0x10);
27464 var dataSize = b & 15;
27465
27466 assert(dataSize + 1 <= MAX_NUM_SIZE);
27467
27468 var ucs2DataSize = 1;
27469 var subitemsCount = stream.readNumber();
27470 var i;
27471 switch (type) {
27472 case 0: // codespacerange
27473 stream.readHex(start, dataSize);
27474 stream.readHexNumber(end, dataSize);
27475 addHex(end, start, dataSize);
27476 cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize),
27477 hexToInt(end, dataSize));
27478 for (i = 1; i < subitemsCount; i++) {
27479 incHex(end, dataSize);
27480 stream.readHexNumber(start, dataSize);
27481 addHex(start, end, dataSize);
27482 stream.readHexNumber(end, dataSize);
27483 addHex(end, start, dataSize);
27484 cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize),
27485 hexToInt(end, dataSize));
27486 }
27487 break;
27488 case 1: // notdefrange
27489 stream.readHex(start, dataSize);
27490 stream.readHexNumber(end, dataSize);
27491 addHex(end, start, dataSize);
27492 code = stream.readNumber();
27493 // undefined range, skipping
27494 for (i = 1; i < subitemsCount; i++) {
27495 incHex(end, dataSize);
27496 stream.readHexNumber(start, dataSize);
27497 addHex(start, end, dataSize);
27498 stream.readHexNumber(end, dataSize);
27499 addHex(end, start, dataSize);
27500 code = stream.readNumber();
27501 // nop
27502 }
27503 break;
27504 case 2: // cidchar
27505 stream.readHex(char, dataSize);
27506 code = stream.readNumber();
27507 cMap.mapOne(hexToInt(char, dataSize), code);
27508 for (i = 1; i < subitemsCount; i++) {
27509 incHex(char, dataSize);
27510 if (!sequence) {
27511 stream.readHexNumber(tmp, dataSize);
27512 addHex(char, tmp, dataSize);
27513 }
27514 code = stream.readSigned() + (code + 1);
27515 cMap.mapOne(hexToInt(char, dataSize), code);
27516 }
27517 break;
27518 case 3: // cidrange
27519 stream.readHex(start, dataSize);
27520 stream.readHexNumber(end, dataSize);
27521 addHex(end, start, dataSize);
27522 code = stream.readNumber();
27523 cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize),
27524 code);
27525 for (i = 1; i < subitemsCount; i++) {
27526 incHex(end, dataSize);
27527 if (!sequence) {
27528 stream.readHexNumber(start, dataSize);
27529 addHex(start, end, dataSize);
27530 } else {
27531 start.set(end);
27532 }
27533 stream.readHexNumber(end, dataSize);
27534 addHex(end, start, dataSize);
27535 code = stream.readNumber();
27536 cMap.mapCidRange(hexToInt(start, dataSize),
27537 hexToInt(end, dataSize), code);
27538 }
27539 break;
27540 case 4: // bfchar
27541 stream.readHex(char, ucs2DataSize);
27542 stream.readHex(charCode, dataSize);
27543 cMap.mapOne(hexToInt(char, ucs2DataSize),
27544 hexToStr(charCode, dataSize));
27545 for (i = 1; i < subitemsCount; i++) {
27546 incHex(char, ucs2DataSize);
27547 if (!sequence) {
27548 stream.readHexNumber(tmp, ucs2DataSize);
27549 addHex(char, tmp, ucs2DataSize);
27550 }
27551 incHex(charCode, dataSize);
27552 stream.readHexSigned(tmp, dataSize);
27553 addHex(charCode, tmp, dataSize);
27554 cMap.mapOne(hexToInt(char, ucs2DataSize),
27555 hexToStr(charCode, dataSize));
27556 }
27557 break;
27558 case 5: // bfrange
27559 stream.readHex(start, ucs2DataSize);
27560 stream.readHexNumber(end, ucs2DataSize);
27561 addHex(end, start, ucs2DataSize);
27562 stream.readHex(charCode, dataSize);
27563 cMap.mapBfRange(hexToInt(start, ucs2DataSize),
27564 hexToInt(end, ucs2DataSize),
27565 hexToStr(charCode, dataSize));
27566 for (i = 1; i < subitemsCount; i++) {
27567 incHex(end, ucs2DataSize);
27568 if (!sequence) {
27569 stream.readHexNumber(start, ucs2DataSize);
27570 addHex(start, end, ucs2DataSize);
27571 } else {
27572 start.set(end);
27573 }
27574 stream.readHexNumber(end, ucs2DataSize);
27575 addHex(end, start, ucs2DataSize);
27576 stream.readHex(charCode, dataSize);
27577 cMap.mapBfRange(hexToInt(start, ucs2DataSize),
27578 hexToInt(end, ucs2DataSize),
27579 hexToStr(charCode, dataSize));
27580 }
27581 break;
27582 default:
27583 error('Unknown type: ' + type);
27584 break;
27585 }
27586 }
27587
27588 if (useCMap) {
27589 return extend(useCMap);
27590 }
27591 return cMap;
27592 });
27593 }
27594
27595 function BinaryCMapReader() {}
27596
27597 BinaryCMapReader.prototype = {
27598 read: processBinaryCMap
27599 };
27600
27601 return BinaryCMapReader;
27602})();
27603
27604var CMapFactory = (function CMapFactoryClosure() {
27605 function strToInt(str) {
27606 var a = 0;
27607 for (var i = 0; i < str.length; i++) {
27608 a = (a << 8) | str.charCodeAt(i);
27609 }
27610 return a >>> 0;
27611 }
27612
27613 function expectString(obj) {
27614 if (!isString(obj)) {
27615 error('Malformed CMap: expected string.');
27616 }
27617 }
27618
27619 function expectInt(obj) {
27620 if (!isInt(obj)) {
27621 error('Malformed CMap: expected int.');
27622 }
27623 }
27624
27625 function parseBfChar(cMap, lexer) {
27626 while (true) {
27627 var obj = lexer.getObj();
27628 if (isEOF(obj)) {
27629 break;
27630 }
27631 if (isCmd(obj, 'endbfchar')) {
27632 return;
27633 }
27634 expectString(obj);
27635 var src = strToInt(obj);
27636 obj = lexer.getObj();
27637 // TODO are /dstName used?
27638 expectString(obj);
27639 var dst = obj;
27640 cMap.mapOne(src, dst);
27641 }
27642 }
27643
27644 function parseBfRange(cMap, lexer) {
27645 while (true) {
27646 var obj = lexer.getObj();
27647 if (isEOF(obj)) {
27648 break;
27649 }
27650 if (isCmd(obj, 'endbfrange')) {
27651 return;
27652 }
27653 expectString(obj);
27654 var low = strToInt(obj);
27655 obj = lexer.getObj();
27656 expectString(obj);
27657 var high = strToInt(obj);
27658 obj = lexer.getObj();
27659 if (isInt(obj) || isString(obj)) {
27660 var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
27661 cMap.mapBfRange(low, high, dstLow);
27662 } else if (isCmd(obj, '[')) {
27663 obj = lexer.getObj();
27664 var array = [];
27665 while (!isCmd(obj, ']') && !isEOF(obj)) {
27666 array.push(obj);
27667 obj = lexer.getObj();
27668 }
27669 cMap.mapBfRangeToArray(low, high, array);
27670 } else {
27671 break;
27672 }
27673 }
27674 error('Invalid bf range.');
27675 }
27676
27677 function parseCidChar(cMap, lexer) {
27678 while (true) {
27679 var obj = lexer.getObj();
27680 if (isEOF(obj)) {
27681 break;
27682 }
27683 if (isCmd(obj, 'endcidchar')) {
27684 return;
27685 }
27686 expectString(obj);
27687 var src = strToInt(obj);
27688 obj = lexer.getObj();
27689 expectInt(obj);
27690 var dst = obj;
27691 cMap.mapOne(src, dst);
27692 }
27693 }
27694
27695 function parseCidRange(cMap, lexer) {
27696 while (true) {
27697 var obj = lexer.getObj();
27698 if (isEOF(obj)) {
27699 break;
27700 }
27701 if (isCmd(obj, 'endcidrange')) {
27702 return;
27703 }
27704 expectString(obj);
27705 var low = strToInt(obj);
27706 obj = lexer.getObj();
27707 expectString(obj);
27708 var high = strToInt(obj);
27709 obj = lexer.getObj();
27710 expectInt(obj);
27711 var dstLow = obj;
27712 cMap.mapCidRange(low, high, dstLow);
27713 }
27714 }
27715
27716 function parseCodespaceRange(cMap, lexer) {
27717 while (true) {
27718 var obj = lexer.getObj();
27719 if (isEOF(obj)) {
27720 break;
27721 }
27722 if (isCmd(obj, 'endcodespacerange')) {
27723 return;
27724 }
27725 if (!isString(obj)) {
27726 break;
27727 }
27728 var low = strToInt(obj);
27729 obj = lexer.getObj();
27730 if (!isString(obj)) {
27731 break;
27732 }
27733 var high = strToInt(obj);
27734 cMap.addCodespaceRange(obj.length, low, high);
27735 }
27736 error('Invalid codespace range.');
27737 }
27738
27739 function parseWMode(cMap, lexer) {
27740 var obj = lexer.getObj();
27741 if (isInt(obj)) {
27742 cMap.vertical = !!obj;
27743 }
27744 }
27745
27746 function parseCMapName(cMap, lexer) {
27747 var obj = lexer.getObj();
27748 if (isName(obj) && isString(obj.name)) {
27749 cMap.name = obj.name;
27750 }
27751 }
27752
27753 function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
27754 var previous;
27755 var embededUseCMap;
27756 objLoop: while (true) {
27757 try {
27758 var obj = lexer.getObj();
27759 if (isEOF(obj)) {
27760 break;
27761 } else if (isName(obj)) {
27762 if (obj.name === 'WMode') {
27763 parseWMode(cMap, lexer);
27764 } else if (obj.name === 'CMapName') {
27765 parseCMapName(cMap, lexer);
27766 }
27767 previous = obj;
27768 } else if (isCmd(obj)) {
27769 switch (obj.cmd) {
27770 case 'endcmap':
27771 break objLoop;
27772 case 'usecmap':
27773 if (isName(previous)) {
27774 embededUseCMap = previous.name;
27775 }
27776 break;
27777 case 'begincodespacerange':
27778 parseCodespaceRange(cMap, lexer);
27779 break;
27780 case 'beginbfchar':
27781 parseBfChar(cMap, lexer);
27782 break;
27783 case 'begincidchar':
27784 parseCidChar(cMap, lexer);
27785 break;
27786 case 'beginbfrange':
27787 parseBfRange(cMap, lexer);
27788 break;
27789 case 'begincidrange':
27790 parseCidRange(cMap, lexer);
27791 break;
27792 }
27793 }
27794 } catch (ex) {
27795 if (ex instanceof MissingDataException) {
27796 throw ex;
27797 }
27798 warn('Invalid cMap data: ' + ex);
27799 continue;
27800 }
27801 }
27802
27803 if (!useCMap && embededUseCMap) {
27804 // Load the usecmap definition from the file only if there wasn't one
27805 // specified.
27806 useCMap = embededUseCMap;
27807 }
27808 if (useCMap) {
27809 return extendCMap(cMap, builtInCMapParams, useCMap);
27810 }
27811 return Promise.resolve(cMap);
27812 }
27813
27814 function extendCMap(cMap, builtInCMapParams, useCMap) {
27815 return createBuiltInCMap(useCMap, builtInCMapParams).then(
27816 function(newCMap) {
27817 cMap.useCMap = newCMap;
27818 // If there aren't any code space ranges defined clone all the parent ones
27819 // into this cMap.
27820 if (cMap.numCodespaceRanges === 0) {
27821 var useCodespaceRanges = cMap.useCMap.codespaceRanges;
27822 for (var i = 0; i < useCodespaceRanges.length; i++) {
27823 cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
27824 }
27825 cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
27826 }
27827 // Merge the map into the current one, making sure not to override
27828 // any previously defined entries.
27829 cMap.useCMap.forEach(function(key, value) {
27830 if (!cMap.contains(key)) {
27831 cMap.mapOne(key, cMap.useCMap.lookup(key));
27832 }
27833 });
27834
27835 return cMap;
27836 });
27837 }
27838
27839 function parseBinaryCMap(name, builtInCMapParams) {
27840 var url = builtInCMapParams.url + name + '.bcmap';
27841 var cMap = new CMap(true);
27842 return new BinaryCMapReader().read(url, cMap, function (useCMap) {
27843 return extendCMap(cMap, builtInCMapParams, useCMap);
27844 });
27845 }
27846
27847 function createBuiltInCMap(name, builtInCMapParams) {
27848 if (name === 'Identity-H') {
27849 return Promise.resolve(new IdentityCMap(false, 2));
27850 } else if (name === 'Identity-V') {
27851 return Promise.resolve(new IdentityCMap(true, 2));
27852 }
27853 if (BUILT_IN_CMAPS.indexOf(name) === -1) {
27854 return Promise.reject(new Error('Unknown cMap name: ' + name));
27855 }
27856 assert(builtInCMapParams, 'built-in cMap parameters are not provided');
27857
27858 if (builtInCMapParams.packed) {
27859 return parseBinaryCMap(name, builtInCMapParams);
27860 }
27861
27862 return new Promise(function (resolve, reject) {
27863 var url = builtInCMapParams.url + name;
27864 var request = new XMLHttpRequest();
27865 request.onreadystatechange = function () {
27866 if (request.readyState === XMLHttpRequest.DONE) {
27867 if (request.status === 200 || request.status === 0) {
27868 var cMap = new CMap(true);
27869 var lexer = new Lexer(new StringStream(request.responseText));
27870 parseCMap(cMap, lexer, builtInCMapParams, null).then(
27871 function (parsedCMap) {
27872 resolve(parsedCMap);
27873 });
27874 } else {
27875 reject(new Error('Unable to get cMap at: ' + url));
27876 }
27877 }
27878 };
27879 request.open('GET', url, true);
27880 request.send(null);
27881 });
27882 }
27883
27884 return {
27885 create: function (encoding, builtInCMapParams, useCMap) {
27886 if (isName(encoding)) {
27887 return createBuiltInCMap(encoding.name, builtInCMapParams);
27888 } else if (isStream(encoding)) {
27889 var cMap = new CMap();
27890 var lexer = new Lexer(encoding);
27891 return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(
27892 function (parsedCMap) {
27893 if (parsedCMap.isIdentityCMap) {
27894 return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
27895 }
27896 return parsedCMap;
27897 });
27898 }
27899 return Promise.reject(new Error('Encoding required.'));
27900 }
27901 };
27902})();
27903
27904exports.CMap = CMap;
27905exports.CMapFactory = CMapFactory;
27906exports.IdentityCMap = IdentityCMap;
27907}));
27908
27909
27910(function (root, factory) {
27911 {
27912 factory((root.pdfjsCoreFonts = {}), root.pdfjsSharedUtil,
27913 root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList,
27914 root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings,
27915 root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode,
27916 root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
27917 }
27918}(this, function (exports, sharedUtil, corePrimitives, coreStream,
27919 coreGlyphList, coreFontRenderer, coreEncodings,
27920 coreStandardFonts, coreUnicode, coreType1Parser,
27921 coreCFFParser) {
27922
27923var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
27924var FontType = sharedUtil.FontType;
27925var assert = sharedUtil.assert;
27926var bytesToString = sharedUtil.bytesToString;
27927var error = sharedUtil.error;
27928var info = sharedUtil.info;
27929var isArray = sharedUtil.isArray;
27930var isInt = sharedUtil.isInt;
27931var isNum = sharedUtil.isNum;
27932var readUint32 = sharedUtil.readUint32;
27933var shadow = sharedUtil.shadow;
27934var string32 = sharedUtil.string32;
27935var warn = sharedUtil.warn;
27936var MissingDataException = sharedUtil.MissingDataException;
27937var isSpace = sharedUtil.isSpace;
27938var Stream = coreStream.Stream;
27939var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
27940var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
27941var FontRendererFactory = coreFontRenderer.FontRendererFactory;
27942var StandardEncoding = coreEncodings.StandardEncoding;
27943var MacRomanEncoding = coreEncodings.MacRomanEncoding;
27944var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
27945var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
27946var getEncoding = coreEncodings.getEncoding;
27947var getStdFontMap = coreStandardFonts.getStdFontMap;
27948var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
27949var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
27950var getSupplementalGlyphMapForArialBlack =
27951 coreStandardFonts.getSupplementalGlyphMapForArialBlack;
27952var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
27953var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
27954var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
27955var Type1Parser = coreType1Parser.Type1Parser;
27956var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
27957var CFFParser = coreCFFParser.CFFParser;
27958var CFFCompiler = coreCFFParser.CFFCompiler;
27959var CFF = coreCFFParser.CFF;
27960var CFFHeader = coreCFFParser.CFFHeader;
27961var CFFTopDict = coreCFFParser.CFFTopDict;
27962var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
27963var CFFStrings = coreCFFParser.CFFStrings;
27964var CFFIndex = coreCFFParser.CFFIndex;
27965var CFFCharset = coreCFFParser.CFFCharset;
27966
27967// Unicode Private Use Area
27968var PRIVATE_USE_OFFSET_START = 0xE000;
27969var PRIVATE_USE_OFFSET_END = 0xF8FF;
27970var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
27971
27972// PDF Glyph Space Units are one Thousandth of a TextSpace Unit
27973// except for Type 3 fonts
27974var PDF_GLYPH_SPACE_UNITS = 1000;
27975
27976// Accented charactars are not displayed properly on Windows, using this flag
27977// to control analysis of seac charstrings.
27978var SEAC_ANALYSIS_ENABLED = false;
27979
27980var FontFlags = {
27981 FixedPitch: 1,
27982 Serif: 2,
27983 Symbolic: 4,
27984 Script: 8,
27985 Nonsymbolic: 32,
27986 Italic: 64,
27987 AllCap: 65536,
27988 SmallCap: 131072,
27989 ForceBold: 262144
27990};
27991
27992var MacStandardGlyphOrdering = [
27993 '.notdef', '.null', 'nonmarkingreturn', 'space', 'exclam', 'quotedbl',
27994 'numbersign', 'dollar', 'percent', 'ampersand', 'quotesingle', 'parenleft',
27995 'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash',
27996 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
27997 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question', 'at',
27998 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
27999 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'bracketleft',
28000 'backslash', 'bracketright', 'asciicircum', 'underscore', 'grave', 'a', 'b',
28001 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
28002 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright',
28003 'asciitilde', 'Adieresis', 'Aring', 'Ccedilla', 'Eacute', 'Ntilde',
28004 'Odieresis', 'Udieresis', 'aacute', 'agrave', 'acircumflex', 'adieresis',
28005 'atilde', 'aring', 'ccedilla', 'eacute', 'egrave', 'ecircumflex', 'edieresis',
28006 'iacute', 'igrave', 'icircumflex', 'idieresis', 'ntilde', 'oacute', 'ograve',
28007 'ocircumflex', 'odieresis', 'otilde', 'uacute', 'ugrave', 'ucircumflex',
28008 'udieresis', 'dagger', 'degree', 'cent', 'sterling', 'section', 'bullet',
28009 'paragraph', 'germandbls', 'registered', 'copyright', 'trademark', 'acute',
28010 'dieresis', 'notequal', 'AE', 'Oslash', 'infinity', 'plusminus', 'lessequal',
28011 'greaterequal', 'yen', 'mu', 'partialdiff', 'summation', 'product', 'pi',
28012 'integral', 'ordfeminine', 'ordmasculine', 'Omega', 'ae', 'oslash',
28013 'questiondown', 'exclamdown', 'logicalnot', 'radical', 'florin',
28014 'approxequal', 'Delta', 'guillemotleft', 'guillemotright', 'ellipsis',
28015 'nonbreakingspace', 'Agrave', 'Atilde', 'Otilde', 'OE', 'oe', 'endash',
28016 'emdash', 'quotedblleft', 'quotedblright', 'quoteleft', 'quoteright',
28017 'divide', 'lozenge', 'ydieresis', 'Ydieresis', 'fraction', 'currency',
28018 'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'daggerdbl', 'periodcentered',
28019 'quotesinglbase', 'quotedblbase', 'perthousand', 'Acircumflex',
28020 'Ecircumflex', 'Aacute', 'Edieresis', 'Egrave', 'Iacute', 'Icircumflex',
28021 'Idieresis', 'Igrave', 'Oacute', 'Ocircumflex', 'apple', 'Ograve', 'Uacute',
28022 'Ucircumflex', 'Ugrave', 'dotlessi', 'circumflex', 'tilde', 'macron',
28023 'breve', 'dotaccent', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron',
28024 'Lslash', 'lslash', 'Scaron', 'scaron', 'Zcaron', 'zcaron', 'brokenbar',
28025 'Eth', 'eth', 'Yacute', 'yacute', 'Thorn', 'thorn', 'minus', 'multiply',
28026 'onesuperior', 'twosuperior', 'threesuperior', 'onehalf', 'onequarter',
28027 'threequarters', 'franc', 'Gbreve', 'gbreve', 'Idotaccent', 'Scedilla',
28028 'scedilla', 'Cacute', 'cacute', 'Ccaron', 'ccaron', 'dcroat'];
28029
28030function adjustWidths(properties) {
28031 if (!properties.fontMatrix) {
28032 return;
28033 }
28034 if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
28035 return;
28036 }
28037 // adjusting width to fontMatrix scale
28038 var scale = 0.001 / properties.fontMatrix[0];
28039 var glyphsWidths = properties.widths;
28040 for (var glyph in glyphsWidths) {
28041 glyphsWidths[glyph] *= scale;
28042 }
28043 properties.defaultWidth *= scale;
28044}
28045
28046function adjustToUnicode(properties, builtInEncoding) {
28047 if (properties.hasIncludedToUnicodeMap) {
28048 return; // The font dictionary has a `ToUnicode` entry.
28049 }
28050 if (properties.hasEncoding) {
28051 return; // The font dictionary has an `Encoding` entry.
28052 }
28053 if (builtInEncoding === properties.defaultEncoding) {
28054 return; // No point in trying to adjust `toUnicode` if the encodings match.
28055 }
28056 if (properties.toUnicode instanceof IdentityToUnicodeMap) {
28057 return;
28058 }
28059 var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
28060 for (var charCode in builtInEncoding) {
28061 var glyphName = builtInEncoding[charCode];
28062 var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
28063 if (unicode !== -1) {
28064 toUnicode[charCode] = String.fromCharCode(unicode);
28065 }
28066 }
28067 properties.toUnicode.amend(toUnicode);
28068}
28069
28070function getFontType(type, subtype) {
28071 switch (type) {
28072 case 'Type1':
28073 return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
28074 case 'CIDFontType0':
28075 return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C :
28076 FontType.CIDFONTTYPE0;
28077 case 'OpenType':
28078 return FontType.OPENTYPE;
28079 case 'TrueType':
28080 return FontType.TRUETYPE;
28081 case 'CIDFontType2':
28082 return FontType.CIDFONTTYPE2;
28083 case 'MMType1':
28084 return FontType.MMTYPE1;
28085 case 'Type0':
28086 return FontType.TYPE0;
28087 default:
28088 return FontType.UNKNOWN;
28089 }
28090}
28091
28092// Some bad PDF generators, e.g. Scribus PDF, include glyph names
28093// in a 'uniXXXX' format -- attempting to recover proper ones.
28094function recoverGlyphName(name, glyphsUnicodeMap) {
28095 if (glyphsUnicodeMap[name] !== undefined) {
28096 return name;
28097 }
28098 // The glyph name is non-standard, trying to recover.
28099 var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
28100 if (unicode !== -1) {
28101 for (var key in glyphsUnicodeMap) {
28102 if (glyphsUnicodeMap[key] === unicode) {
28103 return key;
28104 }
28105 }
28106 }
28107 info('Unable to recover a standard glyph name for: ' + name);
28108 return name;
28109}
28110
28111var Glyph = (function GlyphClosure() {
28112 function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId,
28113 isSpace, isInFont) {
28114 this.fontChar = fontChar;
28115 this.unicode = unicode;
28116 this.accent = accent;
28117 this.width = width;
28118 this.vmetric = vmetric;
28119 this.operatorListId = operatorListId;
28120 this.isSpace = isSpace;
28121 this.isInFont = isInFont;
28122 }
28123
28124 Glyph.prototype.matchesForCache = function(fontChar, unicode, accent, width,
28125 vmetric, operatorListId, isSpace,
28126 isInFont) {
28127 return this.fontChar === fontChar &&
28128 this.unicode === unicode &&
28129 this.accent === accent &&
28130 this.width === width &&
28131 this.vmetric === vmetric &&
28132 this.operatorListId === operatorListId &&
28133 this.isSpace === isSpace &&
28134 this.isInFont === isInFont;
28135 };
28136
28137 return Glyph;
28138})();
28139
28140var ToUnicodeMap = (function ToUnicodeMapClosure() {
28141 function ToUnicodeMap(cmap) {
28142 // The elements of this._map can be integers or strings, depending on how
28143 // |cmap| was created.
28144 this._map = cmap;
28145 }
28146
28147 ToUnicodeMap.prototype = {
28148 get length() {
28149 return this._map.length;
28150 },
28151
28152 forEach: function(callback) {
28153 for (var charCode in this._map) {
28154 callback(charCode, this._map[charCode].charCodeAt(0));
28155 }
28156 },
28157
28158 has: function(i) {
28159 return this._map[i] !== undefined;
28160 },
28161
28162 get: function(i) {
28163 return this._map[i];
28164 },
28165
28166 charCodeOf: function(v) {
28167 return this._map.indexOf(v);
28168 },
28169
28170 amend: function (map) {
28171 for (var charCode in map) {
28172 this._map[charCode] = map[charCode];
28173 }
28174 },
28175 };
28176
28177 return ToUnicodeMap;
28178})();
28179
28180var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
28181 function IdentityToUnicodeMap(firstChar, lastChar) {
28182 this.firstChar = firstChar;
28183 this.lastChar = lastChar;
28184 }
28185
28186 IdentityToUnicodeMap.prototype = {
28187 get length() {
28188 return (this.lastChar + 1) - this.firstChar;
28189 },
28190
28191 forEach: function (callback) {
28192 for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
28193 callback(i, i);
28194 }
28195 },
28196
28197 has: function (i) {
28198 return this.firstChar <= i && i <= this.lastChar;
28199 },
28200
28201 get: function (i) {
28202 if (this.firstChar <= i && i <= this.lastChar) {
28203 return String.fromCharCode(i);
28204 }
28205 return undefined;
28206 },
28207
28208 charCodeOf: function (v) {
28209 return (isInt(v) && v >= this.firstChar && v <= this.lastChar) ? v : -1;
28210 },
28211
28212 amend: function (map) {
28213 error('Should not call amend()');
28214 },
28215 };
28216
28217 return IdentityToUnicodeMap;
28218})();
28219
28220var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() {
28221 function writeInt16(dest, offset, num) {
28222 dest[offset] = (num >> 8) & 0xFF;
28223 dest[offset + 1] = num & 0xFF;
28224 }
28225
28226 function writeInt32(dest, offset, num) {
28227 dest[offset] = (num >> 24) & 0xFF;
28228 dest[offset + 1] = (num >> 16) & 0xFF;
28229 dest[offset + 2] = (num >> 8) & 0xFF;
28230 dest[offset + 3] = num & 0xFF;
28231 }
28232
28233 function writeData(dest, offset, data) {
28234 var i, ii;
28235 if (data instanceof Uint8Array) {
28236 dest.set(data, offset);
28237 } else if (typeof data === 'string') {
28238 for (i = 0, ii = data.length; i < ii; i++) {
28239 dest[offset++] = data.charCodeAt(i) & 0xFF;
28240 }
28241 } else {
28242 // treating everything else as array
28243 for (i = 0, ii = data.length; i < ii; i++) {
28244 dest[offset++] = data[i] & 0xFF;
28245 }
28246 }
28247 }
28248
28249 function OpenTypeFileBuilder(sfnt) {
28250 this.sfnt = sfnt;
28251 this.tables = Object.create(null);
28252 }
28253
28254 OpenTypeFileBuilder.getSearchParams =
28255 function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
28256 var maxPower2 = 1, log2 = 0;
28257 while ((maxPower2 ^ entriesCount) > maxPower2) {
28258 maxPower2 <<= 1;
28259 log2++;
28260 }
28261 var searchRange = maxPower2 * entrySize;
28262 return {
28263 range: searchRange,
28264 entry: log2,
28265 rangeShift: entrySize * entriesCount - searchRange
28266 };
28267 };
28268
28269 var OTF_HEADER_SIZE = 12;
28270 var OTF_TABLE_ENTRY_SIZE = 16;
28271
28272 OpenTypeFileBuilder.prototype = {
28273 toArray: function OpenTypeFileBuilder_toArray() {
28274 var sfnt = this.sfnt;
28275
28276 // Tables needs to be written by ascendant alphabetic order
28277 var tables = this.tables;
28278 var tablesNames = Object.keys(tables);
28279 tablesNames.sort();
28280 var numTables = tablesNames.length;
28281
28282 var i, j, jj, table, tableName;
28283 // layout the tables data
28284 var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
28285 var tableOffsets = [offset];
28286 for (i = 0; i < numTables; i++) {
28287 table = tables[tablesNames[i]];
28288 var paddedLength = ((table.length + 3) & ~3) >>> 0;
28289 offset += paddedLength;
28290 tableOffsets.push(offset);
28291 }
28292
28293 var file = new Uint8Array(offset);
28294 // write the table data first (mostly for checksum)
28295 for (i = 0; i < numTables; i++) {
28296 table = tables[tablesNames[i]];
28297 writeData(file, tableOffsets[i], table);
28298 }
28299
28300 // sfnt version (4 bytes)
28301 if (sfnt === 'true') {
28302 // Windows hates the Mac TrueType sfnt version number
28303 sfnt = string32(0x00010000);
28304 }
28305 file[0] = sfnt.charCodeAt(0) & 0xFF;
28306 file[1] = sfnt.charCodeAt(1) & 0xFF;
28307 file[2] = sfnt.charCodeAt(2) & 0xFF;
28308 file[3] = sfnt.charCodeAt(3) & 0xFF;
28309
28310 // numTables (2 bytes)
28311 writeInt16(file, 4, numTables);
28312
28313 var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
28314
28315 // searchRange (2 bytes)
28316 writeInt16(file, 6, searchParams.range);
28317 // entrySelector (2 bytes)
28318 writeInt16(file, 8, searchParams.entry);
28319 // rangeShift (2 bytes)
28320 writeInt16(file, 10, searchParams.rangeShift);
28321
28322 offset = OTF_HEADER_SIZE;
28323 // writing table entries
28324 for (i = 0; i < numTables; i++) {
28325 tableName = tablesNames[i];
28326 file[offset] = tableName.charCodeAt(0) & 0xFF;
28327 file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
28328 file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
28329 file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
28330
28331 // checksum
28332 var checksum = 0;
28333 for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
28334 var quad = readUint32(file, j);
28335 checksum = (checksum + quad) >>> 0;
28336 }
28337 writeInt32(file, offset + 4, checksum);
28338
28339 // offset
28340 writeInt32(file, offset + 8, tableOffsets[i]);
28341 // length
28342 writeInt32(file, offset + 12, tables[tableName].length);
28343
28344 offset += OTF_TABLE_ENTRY_SIZE;
28345 }
28346 return file;
28347 },
28348
28349 addTable: function OpenTypeFileBuilder_addTable(tag, data) {
28350 if (tag in this.tables) {
28351 throw new Error('Table ' + tag + ' already exists');
28352 }
28353 this.tables[tag] = data;
28354 }
28355 };
28356
28357 return OpenTypeFileBuilder;
28358})();
28359
28360// Problematic Unicode characters in the fonts that needs to be moved to avoid
28361// issues when they are painted on the canvas, e.g. complex-script shaping or
28362// control/whitespace characters. The ranges are listed in pairs: the first item
28363// is a code of the first problematic code, the second one is the next
28364// non-problematic code. The ranges must be in sorted order.
28365var ProblematicCharRanges = new Int32Array([
28366 // Control characters.
28367 0x0000, 0x0020,
28368 0x007F, 0x00A1,
28369 0x00AD, 0x00AE,
28370 // Chars that is used in complex-script shaping.
28371 0x0600, 0x0780,
28372 0x08A0, 0x10A0,
28373 0x1780, 0x1800,
28374 0x1C00, 0x1C50,
28375 // General punctuation chars.
28376 0x2000, 0x2010,
28377 0x2011, 0x2012,
28378 0x2028, 0x2030,
28379 0x205F, 0x2070,
28380 0x25CC, 0x25CD,
28381 0x3000, 0x3001,
28382 // Chars that is used in complex-script shaping.
28383 0xAA60, 0xAA80,
28384 // Specials Unicode block.
28385 0xFFF0, 0x10000
28386]);
28387
28388
28389/**
28390 * 'Font' is the class the outside world should use, it encapsulate all the font
28391 * decoding logics whatever type it is (assuming the font type is supported).
28392 *
28393 * For example to read a Type1 font and to attach it to the document:
28394 * var type1Font = new Font("MyFontName", binaryFile, propertiesObject);
28395 * type1Font.bind();
28396 */
28397var Font = (function FontClosure() {
28398 function Font(name, file, properties) {
28399 var charCode, glyphName, unicode;
28400
28401 this.name = name;
28402 this.loadedName = properties.loadedName;
28403 this.isType3Font = properties.isType3Font;
28404 this.sizes = [];
28405 this.missingFile = false;
28406
28407 this.glyphCache = Object.create(null);
28408
28409 var names = name.split('+');
28410 names = names.length > 1 ? names[1] : names[0];
28411 names = names.split(/[-,_]/g)[0];
28412 this.isSerifFont = !!(properties.flags & FontFlags.Serif);
28413 this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
28414 this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
28415
28416 var type = properties.type;
28417 var subtype = properties.subtype;
28418 this.type = type;
28419
28420 this.fallbackName = (this.isMonospace ? 'monospace' :
28421 (this.isSerifFont ? 'serif' : 'sans-serif'));
28422
28423 this.differences = properties.differences;
28424 this.widths = properties.widths;
28425 this.defaultWidth = properties.defaultWidth;
28426 this.composite = properties.composite;
28427 this.wideChars = properties.wideChars;
28428 this.cMap = properties.cMap;
28429 this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
28430 this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
28431 this.fontMatrix = properties.fontMatrix;
28432 this.bbox = properties.bbox;
28433
28434 this.toUnicode = properties.toUnicode;
28435
28436 this.toFontChar = [];
28437
28438 if (properties.type === 'Type3') {
28439 for (charCode = 0; charCode < 256; charCode++) {
28440 this.toFontChar[charCode] = (this.differences[charCode] ||
28441 properties.defaultEncoding[charCode]);
28442 }
28443 this.fontType = FontType.TYPE3;
28444 return;
28445 }
28446
28447 this.cidEncoding = properties.cidEncoding;
28448 this.vertical = properties.vertical;
28449 if (this.vertical) {
28450 this.vmetrics = properties.vmetrics;
28451 this.defaultVMetrics = properties.defaultVMetrics;
28452 }
28453 var glyphsUnicodeMap;
28454 if (!file || file.isEmpty) {
28455 if (file) {
28456 // Some bad PDF generators will include empty font files,
28457 // attempting to recover by assuming that no file exists.
28458 warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
28459 }
28460
28461 this.missingFile = true;
28462 // The file data is not specified. Trying to fix the font name
28463 // to be used with the canvas.font.
28464 var fontName = name.replace(/[,_]/g, '-');
28465 var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
28466 var isStandardFont = !!stdFontMap[fontName] ||
28467 !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
28468 fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
28469
28470 this.bold = (fontName.search(/bold/gi) !== -1);
28471 this.italic = ((fontName.search(/oblique/gi) !== -1) ||
28472 (fontName.search(/italic/gi) !== -1));
28473
28474 // Use 'name' instead of 'fontName' here because the original
28475 // name ArialBlack for example will be replaced by Helvetica.
28476 this.black = (name.search(/Black/g) !== -1);
28477
28478 // if at least one width is present, remeasure all chars when exists
28479 this.remeasure = Object.keys(this.widths).length > 0;
28480 if (isStandardFont && type === 'CIDFontType2' &&
28481 properties.cidEncoding.indexOf('Identity-') === 0) {
28482 var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
28483 // Standard fonts might be embedded as CID font without glyph mapping.
28484 // Building one based on GlyphMapForStandardFonts.
28485 var map = [];
28486 for (charCode in GlyphMapForStandardFonts) {
28487 map[+charCode] = GlyphMapForStandardFonts[charCode];
28488 }
28489 if (/ArialBlack/i.test(name)) {
28490 var SupplementalGlyphMapForArialBlack =
28491 getSupplementalGlyphMapForArialBlack();
28492 for (charCode in SupplementalGlyphMapForArialBlack) {
28493 map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
28494 }
28495 }
28496 var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
28497 if (!isIdentityUnicode) {
28498 this.toUnicode.forEach(function(charCode, unicodeCharCode) {
28499 map[+charCode] = unicodeCharCode;
28500 });
28501 }
28502 this.toFontChar = map;
28503 this.toUnicode = new ToUnicodeMap(map);
28504 } else if (/Symbol/i.test(fontName)) {
28505 this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(),
28506 properties.differences);
28507 } else if (/Dingbats/i.test(fontName)) {
28508 if (/Wingdings/i.test(name)) {
28509 warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
28510 }
28511 this.toFontChar = buildToFontChar(ZapfDingbatsEncoding,
28512 getDingbatsGlyphsUnicode(),
28513 properties.differences);
28514 } else if (isStandardFont) {
28515 this.toFontChar = buildToFontChar(properties.defaultEncoding,
28516 getGlyphsUnicode(),
28517 properties.differences);
28518 } else {
28519 glyphsUnicodeMap = getGlyphsUnicode();
28520 this.toUnicode.forEach(function(charCode, unicodeCharCode) {
28521 if (!this.composite) {
28522 glyphName = (properties.differences[charCode] ||
28523 properties.defaultEncoding[charCode]);
28524 unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
28525 if (unicode !== -1) {
28526 unicodeCharCode = unicode;
28527 }
28528 }
28529 this.toFontChar[charCode] = unicodeCharCode;
28530 }.bind(this));
28531 }
28532 this.loadedName = fontName.split('-')[0];
28533 this.loading = false;
28534 this.fontType = getFontType(type, subtype);
28535 return;
28536 }
28537
28538 // Some fonts might use wrong font types for Type1C or CIDFontType0C
28539 if (subtype === 'Type1C') {
28540 if (type !== 'Type1' && type !== 'MMType1') {
28541 // Some TrueType fonts by mistake claim Type1C
28542 if (isTrueTypeFile(file)) {
28543 subtype = 'TrueType';
28544 } else {
28545 type = 'Type1';
28546 }
28547 } else if (isOpenTypeFile(file)) {
28548 // Sometimes the type/subtype can be a complete lie (see issue7598.pdf).
28549 type = subtype = 'OpenType';
28550 }
28551 }
28552 if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
28553 type = 'CIDFontType0';
28554 }
28555 if (subtype === 'OpenType') {
28556 type = 'OpenType';
28557 }
28558 // Some CIDFontType0C fonts by mistake claim CIDFontType0.
28559 if (type === 'CIDFontType0') {
28560 if (isType1File(file)) {
28561 subtype = 'CIDFontType0';
28562 } else if (isOpenTypeFile(file)) {
28563 // Sometimes the type/subtype can be a complete lie (see issue6782.pdf).
28564 type = subtype = 'OpenType';
28565 } else {
28566 subtype = 'CIDFontType0C';
28567 }
28568 }
28569
28570 var data;
28571 switch (type) {
28572 case 'MMType1':
28573 info('MMType1 font (' + name + '), falling back to Type1.');
28574 /* falls through */
28575 case 'Type1':
28576 case 'CIDFontType0':
28577 this.mimetype = 'font/opentype';
28578
28579 var cff = (subtype === 'Type1C' || subtype === 'CIDFontType0C') ?
28580 new CFFFont(file, properties) : new Type1Font(name, file, properties);
28581
28582 adjustWidths(properties);
28583
28584 // Wrap the CFF data inside an OTF font file
28585 data = this.convert(name, cff, properties);
28586 break;
28587
28588 case 'OpenType':
28589 case 'TrueType':
28590 case 'CIDFontType2':
28591 this.mimetype = 'font/opentype';
28592
28593 // Repair the TrueType file. It is can be damaged in the point of
28594 // view of the sanitizer
28595 data = this.checkAndRepair(name, file, properties);
28596 if (this.isOpenType) {
28597 adjustWidths(properties);
28598
28599 type = 'OpenType';
28600 }
28601 break;
28602
28603 default:
28604 error('Font ' + type + ' is not supported');
28605 break;
28606 }
28607
28608 this.data = data;
28609 this.fontType = getFontType(type, subtype);
28610
28611 // Transfer some properties again that could change during font conversion
28612 this.fontMatrix = properties.fontMatrix;
28613 this.widths = properties.widths;
28614 this.defaultWidth = properties.defaultWidth;
28615 this.toUnicode = properties.toUnicode;
28616 this.encoding = properties.baseEncoding;
28617 this.seacMap = properties.seacMap;
28618
28619 this.loading = true;
28620 }
28621
28622 Font.getFontID = (function () {
28623 var ID = 1;
28624 return function Font_getFontID() {
28625 return String(ID++);
28626 };
28627 })();
28628
28629 function int16(b0, b1) {
28630 return (b0 << 8) + b1;
28631 }
28632
28633 function signedInt16(b0, b1) {
28634 var value = (b0 << 8) + b1;
28635 return value & (1 << 15) ? value - 0x10000 : value;
28636 }
28637
28638 function int32(b0, b1, b2, b3) {
28639 return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
28640 }
28641
28642 function string16(value) {
28643 return String.fromCharCode((value >> 8) & 0xff, value & 0xff);
28644 }
28645
28646 function safeString16(value) {
28647 // clamp value to the 16-bit int range
28648 value = (value > 0x7FFF ? 0x7FFF : (value < -0x8000 ? -0x8000 : value));
28649 return String.fromCharCode((value >> 8) & 0xff, value & 0xff);
28650 }
28651
28652 function isTrueTypeFile(file) {
28653 var header = file.peekBytes(4);
28654 return readUint32(header, 0) === 0x00010000;
28655 }
28656
28657 function isOpenTypeFile(file) {
28658 var header = file.peekBytes(4);
28659 return bytesToString(header) === 'OTTO';
28660 }
28661
28662 function isType1File(file) {
28663 var header = file.peekBytes(2);
28664 // All Type1 font programs must begin with the comment '%!' (0x25 + 0x21).
28665 if (header[0] === 0x25 && header[1] === 0x21) {
28666 return true;
28667 }
28668 // ... obviously some fonts violate that part of the specification,
28669 // please refer to the comment in |Type1Font| below.
28670 if (header[0] === 0x80 && header[1] === 0x01) { // pfb file header.
28671 return true;
28672 }
28673 return false;
28674 }
28675
28676 function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
28677 var toFontChar = [], unicode;
28678 for (var i = 0, ii = encoding.length; i < ii; i++) {
28679 unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
28680 if (unicode !== -1) {
28681 toFontChar[i] = unicode;
28682 }
28683 }
28684 for (var charCode in differences) {
28685 unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
28686 if (unicode !== -1) {
28687 toFontChar[+charCode] = unicode;
28688 }
28689 }
28690 return toFontChar;
28691 }
28692
28693 /**
28694 * Helper function for |adjustMapping|.
28695 * @return {boolean}
28696 */
28697 function isProblematicUnicodeLocation(code) {
28698 // Using binary search to find a range start.
28699 var i = 0, j = ProblematicCharRanges.length - 1;
28700 while (i < j) {
28701 var c = (i + j + 1) >> 1;
28702 if (code < ProblematicCharRanges[c]) {
28703 j = c - 1;
28704 } else {
28705 i = c;
28706 }
28707 }
28708 // Even index means code in problematic range.
28709 return !(i & 1);
28710 }
28711
28712 /**
28713 * Rebuilds the char code to glyph ID map by trying to replace the char codes
28714 * with their unicode value. It also moves char codes that are in known
28715 * problematic locations.
28716 * @return {Object} Two properties:
28717 * 'toFontChar' - maps original char codes(the value that will be read
28718 * from commands such as show text) to the char codes that will be used in the
28719 * font that we build
28720 * 'charCodeToGlyphId' - maps the new font char codes to glyph ids
28721 */
28722 function adjustMapping(charCodeToGlyphId, properties) {
28723 var toUnicode = properties.toUnicode;
28724 var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
28725 var isIdentityUnicode =
28726 properties.toUnicode instanceof IdentityToUnicodeMap;
28727 var newMap = Object.create(null);
28728 var toFontChar = [];
28729 var usedFontCharCodes = [];
28730 var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
28731 for (var originalCharCode in charCodeToGlyphId) {
28732 originalCharCode |= 0;
28733 var glyphId = charCodeToGlyphId[originalCharCode];
28734 var fontCharCode = originalCharCode;
28735 // First try to map the value to a unicode position if a non identity map
28736 // was created.
28737 if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
28738 var unicode = toUnicode.get(fontCharCode);
28739 // TODO: Try to map ligatures to the correct spot.
28740 if (unicode.length === 1) {
28741 fontCharCode = unicode.charCodeAt(0);
28742 }
28743 }
28744 // Try to move control characters, special characters and already mapped
28745 // characters to the private use area since they will not be drawn by
28746 // canvas if left in their current position. Also, move characters if the
28747 // font was symbolic and there is only an identity unicode map since the
28748 // characters probably aren't in the correct position (fixes an issue
28749 // with firefox and thuluthfont).
28750 if ((usedFontCharCodes[fontCharCode] !== undefined ||
28751 isProblematicUnicodeLocation(fontCharCode) ||
28752 (isSymbolic && isIdentityUnicode)) &&
28753 nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) { // Room left.
28754 // Loop to try and find a free spot in the private use area.
28755 do {
28756 fontCharCode = nextAvailableFontCharCode++;
28757
28758 if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
28759 fontCharCode = 0xF020;
28760 nextAvailableFontCharCode = fontCharCode + 1;
28761 }
28762
28763 } while (usedFontCharCodes[fontCharCode] !== undefined &&
28764 nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
28765 }
28766
28767 newMap[fontCharCode] = glyphId;
28768 toFontChar[originalCharCode] = fontCharCode;
28769 usedFontCharCodes[fontCharCode] = true;
28770 }
28771 return {
28772 toFontChar: toFontChar,
28773 charCodeToGlyphId: newMap,
28774 nextAvailableFontCharCode: nextAvailableFontCharCode
28775 };
28776 }
28777
28778 function getRanges(glyphs, numGlyphs) {
28779 // Array.sort() sorts by characters, not numerically, so convert to an
28780 // array of characters.
28781 var codes = [];
28782 for (var charCode in glyphs) {
28783 // Remove an invalid glyph ID mappings to make OTS happy.
28784 if (glyphs[charCode] >= numGlyphs) {
28785 continue;
28786 }
28787 codes.push({ fontCharCode: charCode | 0, glyphId: glyphs[charCode] });
28788 }
28789 codes.sort(function fontGetRangesSort(a, b) {
28790 return a.fontCharCode - b.fontCharCode;
28791 });
28792
28793 // Split the sorted codes into ranges.
28794 var ranges = [];
28795 var length = codes.length;
28796 for (var n = 0; n < length; ) {
28797 var start = codes[n].fontCharCode;
28798 var codeIndices = [codes[n].glyphId];
28799 ++n;
28800 var end = start;
28801 while (n < length && end + 1 === codes[n].fontCharCode) {
28802 codeIndices.push(codes[n].glyphId);
28803 ++end;
28804 ++n;
28805 if (end === 0xFFFF) {
28806 break;
28807 }
28808 }
28809 ranges.push([start, end, codeIndices]);
28810 }
28811
28812 return ranges;
28813 }
28814
28815 function createCmapTable(glyphs, numGlyphs) {
28816 var ranges = getRanges(glyphs, numGlyphs);
28817 var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
28818 var cmap = '\x00\x00' + // version
28819 string16(numTables) + // numTables
28820 '\x00\x03' + // platformID
28821 '\x00\x01' + // encodingID
28822 string32(4 + numTables * 8); // start of the table record
28823
28824 var i, ii, j, jj;
28825 for (i = ranges.length - 1; i >= 0; --i) {
28826 if (ranges[i][0] <= 0xFFFF) { break; }
28827 }
28828 var bmpLength = i + 1;
28829
28830 if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
28831 ranges[i][1] = 0xFFFE;
28832 }
28833 var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
28834 var segCount = bmpLength + trailingRangesCount;
28835 var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
28836
28837 // Fill up the 4 parallel arrays describing the segments.
28838 var startCount = '';
28839 var endCount = '';
28840 var idDeltas = '';
28841 var idRangeOffsets = '';
28842 var glyphsIds = '';
28843 var bias = 0;
28844
28845 var range, start, end, codes;
28846 for (i = 0, ii = bmpLength; i < ii; i++) {
28847 range = ranges[i];
28848 start = range[0];
28849 end = range[1];
28850 startCount += string16(start);
28851 endCount += string16(end);
28852 codes = range[2];
28853 var contiguous = true;
28854 for (j = 1, jj = codes.length; j < jj; ++j) {
28855 if (codes[j] !== codes[j - 1] + 1) {
28856 contiguous = false;
28857 break;
28858 }
28859 }
28860 if (!contiguous) {
28861 var offset = (segCount - i) * 2 + bias * 2;
28862 bias += (end - start + 1);
28863
28864 idDeltas += string16(0);
28865 idRangeOffsets += string16(offset);
28866
28867 for (j = 0, jj = codes.length; j < jj; ++j) {
28868 glyphsIds += string16(codes[j]);
28869 }
28870 } else {
28871 var startCode = codes[0];
28872
28873 idDeltas += string16((startCode - start) & 0xFFFF);
28874 idRangeOffsets += string16(0);
28875 }
28876 }
28877
28878 if (trailingRangesCount > 0) {
28879 endCount += '\xFF\xFF';
28880 startCount += '\xFF\xFF';
28881 idDeltas += '\x00\x01';
28882 idRangeOffsets += '\x00\x00';
28883 }
28884
28885 var format314 = '\x00\x00' + // language
28886 string16(2 * segCount) +
28887 string16(searchParams.range) +
28888 string16(searchParams.entry) +
28889 string16(searchParams.rangeShift) +
28890 endCount + '\x00\x00' + startCount +
28891 idDeltas + idRangeOffsets + glyphsIds;
28892
28893 var format31012 = '';
28894 var header31012 = '';
28895 if (numTables > 1) {
28896 cmap += '\x00\x03' + // platformID
28897 '\x00\x0A' + // encodingID
28898 string32(4 + numTables * 8 +
28899 4 + format314.length); // start of the table record
28900 format31012 = '';
28901 for (i = 0, ii = ranges.length; i < ii; i++) {
28902 range = ranges[i];
28903 start = range[0];
28904 codes = range[2];
28905 var code = codes[0];
28906 for (j = 1, jj = codes.length; j < jj; ++j) {
28907 if (codes[j] !== codes[j - 1] + 1) {
28908 end = range[0] + j - 1;
28909 format31012 += string32(start) + // startCharCode
28910 string32(end) + // endCharCode
28911 string32(code); // startGlyphID
28912 start = end + 1;
28913 code = codes[j];
28914 }
28915 }
28916 format31012 += string32(start) + // startCharCode
28917 string32(range[1]) + // endCharCode
28918 string32(code); // startGlyphID
28919 }
28920 header31012 = '\x00\x0C' + // format
28921 '\x00\x00' + // reserved
28922 string32(format31012.length + 16) + // length
28923 '\x00\x00\x00\x00' + // language
28924 string32(format31012.length / 12); // nGroups
28925 }
28926
28927 return cmap + '\x00\x04' + // format
28928 string16(format314.length + 4) + // length
28929 format314 + header31012 + format31012;
28930 }
28931
28932 function validateOS2Table(os2) {
28933 var stream = new Stream(os2.data);
28934 var version = stream.getUint16();
28935 // TODO verify all OS/2 tables fields, but currently we validate only those
28936 // that give us issues
28937 stream.getBytes(60); // skipping type, misc sizes, panose, unicode ranges
28938 var selection = stream.getUint16();
28939 if (version < 4 && (selection & 0x0300)) {
28940 return false;
28941 }
28942 var firstChar = stream.getUint16();
28943 var lastChar = stream.getUint16();
28944 if (firstChar > lastChar) {
28945 return false;
28946 }
28947 stream.getBytes(6); // skipping sTypoAscender/Descender/LineGap
28948 var usWinAscent = stream.getUint16();
28949 if (usWinAscent === 0) { // makes font unreadable by windows
28950 return false;
28951 }
28952
28953 // OS/2 appears to be valid, resetting some fields
28954 os2.data[8] = os2.data[9] = 0; // IE rejects fonts if fsType != 0
28955 return true;
28956 }
28957
28958 function createOS2Table(properties, charstrings, override) {
28959 override = override || {
28960 unitsPerEm: 0,
28961 yMax: 0,
28962 yMin: 0,
28963 ascent: 0,
28964 descent: 0
28965 };
28966
28967 var ulUnicodeRange1 = 0;
28968 var ulUnicodeRange2 = 0;
28969 var ulUnicodeRange3 = 0;
28970 var ulUnicodeRange4 = 0;
28971
28972 var firstCharIndex = null;
28973 var lastCharIndex = 0;
28974
28975 if (charstrings) {
28976 for (var code in charstrings) {
28977 code |= 0;
28978 if (firstCharIndex > code || !firstCharIndex) {
28979 firstCharIndex = code;
28980 }
28981 if (lastCharIndex < code) {
28982 lastCharIndex = code;
28983 }
28984
28985 var position = getUnicodeRangeFor(code);
28986 if (position < 32) {
28987 ulUnicodeRange1 |= 1 << position;
28988 } else if (position < 64) {
28989 ulUnicodeRange2 |= 1 << position - 32;
28990 } else if (position < 96) {
28991 ulUnicodeRange3 |= 1 << position - 64;
28992 } else if (position < 123) {
28993 ulUnicodeRange4 |= 1 << position - 96;
28994 } else {
28995 error('Unicode ranges Bits > 123 are reserved for internal usage');
28996 }
28997 }
28998 } else {
28999 // TODO
29000 firstCharIndex = 0;
29001 lastCharIndex = 255;
29002 }
29003
29004 var bbox = properties.bbox || [0, 0, 0, 0];
29005 var unitsPerEm = (override.unitsPerEm ||
29006 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0]);
29007
29008 // if the font units differ to the PDF glyph space units
29009 // then scale up the values
29010 var scale = (properties.ascentScaled ? 1.0 :
29011 unitsPerEm / PDF_GLYPH_SPACE_UNITS);
29012
29013 var typoAscent = (override.ascent ||
29014 Math.round(scale * (properties.ascent || bbox[3])));
29015 var typoDescent = (override.descent ||
29016 Math.round(scale * (properties.descent || bbox[1])));
29017 if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
29018 typoDescent = -typoDescent; // fixing incorrect descent
29019 }
29020 var winAscent = override.yMax || typoAscent;
29021 var winDescent = -override.yMin || -typoDescent;
29022
29023 return '\x00\x03' + // version
29024 '\x02\x24' + // xAvgCharWidth
29025 '\x01\xF4' + // usWeightClass
29026 '\x00\x05' + // usWidthClass
29027 '\x00\x00' + // fstype (0 to let the font loads via font-face on IE)
29028 '\x02\x8A' + // ySubscriptXSize
29029 '\x02\xBB' + // ySubscriptYSize
29030 '\x00\x00' + // ySubscriptXOffset
29031 '\x00\x8C' + // ySubscriptYOffset
29032 '\x02\x8A' + // ySuperScriptXSize
29033 '\x02\xBB' + // ySuperScriptYSize
29034 '\x00\x00' + // ySuperScriptXOffset
29035 '\x01\xDF' + // ySuperScriptYOffset
29036 '\x00\x31' + // yStrikeOutSize
29037 '\x01\x02' + // yStrikeOutPosition
29038 '\x00\x00' + // sFamilyClass
29039 '\x00\x00\x06' +
29040 String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) +
29041 '\x00\x00\x00\x00\x00\x00' + // Panose
29042 string32(ulUnicodeRange1) + // ulUnicodeRange1 (Bits 0-31)
29043 string32(ulUnicodeRange2) + // ulUnicodeRange2 (Bits 32-63)
29044 string32(ulUnicodeRange3) + // ulUnicodeRange3 (Bits 64-95)
29045 string32(ulUnicodeRange4) + // ulUnicodeRange4 (Bits 96-127)
29046 '\x2A\x32\x31\x2A' + // achVendID
29047 string16(properties.italicAngle ? 1 : 0) + // fsSelection
29048 string16(firstCharIndex ||
29049 properties.firstChar) + // usFirstCharIndex
29050 string16(lastCharIndex || properties.lastChar) + // usLastCharIndex
29051 string16(typoAscent) + // sTypoAscender
29052 string16(typoDescent) + // sTypoDescender
29053 '\x00\x64' + // sTypoLineGap (7%-10% of the unitsPerEM value)
29054 string16(winAscent) + // usWinAscent
29055 string16(winDescent) + // usWinDescent
29056 '\x00\x00\x00\x00' + // ulCodePageRange1 (Bits 0-31)
29057 '\x00\x00\x00\x00' + // ulCodePageRange2 (Bits 32-63)
29058 string16(properties.xHeight) + // sxHeight
29059 string16(properties.capHeight) + // sCapHeight
29060 string16(0) + // usDefaultChar
29061 string16(firstCharIndex || properties.firstChar) + // usBreakChar
29062 '\x00\x03'; // usMaxContext
29063 }
29064
29065 function createPostTable(properties) {
29066 var angle = Math.floor(properties.italicAngle * (Math.pow(2, 16)));
29067 return ('\x00\x03\x00\x00' + // Version number
29068 string32(angle) + // italicAngle
29069 '\x00\x00' + // underlinePosition
29070 '\x00\x00' + // underlineThickness
29071 string32(properties.fixedPitch) + // isFixedPitch
29072 '\x00\x00\x00\x00' + // minMemType42
29073 '\x00\x00\x00\x00' + // maxMemType42
29074 '\x00\x00\x00\x00' + // minMemType1
29075 '\x00\x00\x00\x00'); // maxMemType1
29076 }
29077
29078 function createNameTable(name, proto) {
29079 if (!proto) {
29080 proto = [[], []]; // no strings and unicode strings
29081 }
29082
29083 var strings = [
29084 proto[0][0] || 'Original licence', // 0.Copyright
29085 proto[0][1] || name, // 1.Font family
29086 proto[0][2] || 'Unknown', // 2.Font subfamily (font weight)
29087 proto[0][3] || 'uniqueID', // 3.Unique ID
29088 proto[0][4] || name, // 4.Full font name
29089 proto[0][5] || 'Version 0.11', // 5.Version
29090 proto[0][6] || '', // 6.Postscript name
29091 proto[0][7] || 'Unknown', // 7.Trademark
29092 proto[0][8] || 'Unknown', // 8.Manufacturer
29093 proto[0][9] || 'Unknown' // 9.Designer
29094 ];
29095
29096 // Mac want 1-byte per character strings while Windows want
29097 // 2-bytes per character, so duplicate the names table
29098 var stringsUnicode = [];
29099 var i, ii, j, jj, str;
29100 for (i = 0, ii = strings.length; i < ii; i++) {
29101 str = proto[1][i] || strings[i];
29102
29103 var strBufUnicode = [];
29104 for (j = 0, jj = str.length; j < jj; j++) {
29105 strBufUnicode.push(string16(str.charCodeAt(j)));
29106 }
29107 stringsUnicode.push(strBufUnicode.join(''));
29108 }
29109
29110 var names = [strings, stringsUnicode];
29111 var platforms = ['\x00\x01', '\x00\x03'];
29112 var encodings = ['\x00\x00', '\x00\x01'];
29113 var languages = ['\x00\x00', '\x04\x09'];
29114
29115 var namesRecordCount = strings.length * platforms.length;
29116 var nameTable =
29117 '\x00\x00' + // format
29118 string16(namesRecordCount) + // Number of names Record
29119 string16(namesRecordCount * 12 + 6); // Storage
29120
29121 // Build the name records field
29122 var strOffset = 0;
29123 for (i = 0, ii = platforms.length; i < ii; i++) {
29124 var strs = names[i];
29125 for (j = 0, jj = strs.length; j < jj; j++) {
29126 str = strs[j];
29127 var nameRecord =
29128 platforms[i] + // platform ID
29129 encodings[i] + // encoding ID
29130 languages[i] + // language ID
29131 string16(j) + // name ID
29132 string16(str.length) +
29133 string16(strOffset);
29134 nameTable += nameRecord;
29135 strOffset += str.length;
29136 }
29137 }
29138
29139 nameTable += strings.join('') + stringsUnicode.join('');
29140 return nameTable;
29141 }
29142
29143 Font.prototype = {
29144 name: null,
29145 font: null,
29146 mimetype: null,
29147 encoding: null,
29148 get renderer() {
29149 var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
29150 return shadow(this, 'renderer', renderer);
29151 },
29152
29153 exportData: function Font_exportData() {
29154 // TODO remove enumerating of the properties, e.g. hardcode exact names.
29155 var data = {};
29156 for (var i in this) {
29157 if (this.hasOwnProperty(i)) {
29158 data[i] = this[i];
29159 }
29160 }
29161 return data;
29162 },
29163
29164 checkAndRepair: function Font_checkAndRepair(name, font, properties) {
29165 function readTableEntry(file) {
29166 var tag = bytesToString(file.getBytes(4));
29167
29168 var checksum = file.getInt32() >>> 0;
29169 var offset = file.getInt32() >>> 0;
29170 var length = file.getInt32() >>> 0;
29171
29172 // Read the table associated data
29173 var previousPosition = file.pos;
29174 file.pos = file.start ? file.start : 0;
29175 file.skip(offset);
29176 var data = file.getBytes(length);
29177 file.pos = previousPosition;
29178
29179 if (tag === 'head') {
29180 // clearing checksum adjustment
29181 data[8] = data[9] = data[10] = data[11] = 0;
29182 data[17] |= 0x20; //Set font optimized for cleartype flag
29183 }
29184
29185 return {
29186 tag: tag,
29187 checksum: checksum,
29188 length: length,
29189 offset: offset,
29190 data: data
29191 };
29192 }
29193
29194 function readOpenTypeHeader(ttf) {
29195 return {
29196 version: bytesToString(ttf.getBytes(4)),
29197 numTables: ttf.getUint16(),
29198 searchRange: ttf.getUint16(),
29199 entrySelector: ttf.getUint16(),
29200 rangeShift: ttf.getUint16()
29201 };
29202 }
29203
29204 /**
29205 * Read the appropriate subtable from the cmap according to 9.6.6.4 from
29206 * PDF spec
29207 */
29208 function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
29209 if (!cmap) {
29210 warn('No cmap table available.');
29211 return {
29212 platformId: -1,
29213 encodingId: -1,
29214 mappings: [],
29215 hasShortCmap: false
29216 };
29217 }
29218 var segment;
29219 var start = (font.start ? font.start : 0) + cmap.offset;
29220 font.pos = start;
29221
29222 var version = font.getUint16();
29223 var numTables = font.getUint16();
29224
29225 var potentialTable;
29226 var canBreak = false;
29227 // There's an order of preference in terms of which cmap subtable to
29228 // use:
29229 // - non-symbolic fonts the preference is a 3,1 table then a 1,0 table
29230 // - symbolic fonts the preference is a 3,0 table then a 1,0 table
29231 // The following takes advantage of the fact that the tables are sorted
29232 // to work.
29233 for (var i = 0; i < numTables; i++) {
29234 var platformId = font.getUint16();
29235 var encodingId = font.getUint16();
29236 var offset = font.getInt32() >>> 0;
29237 var useTable = false;
29238
29239 if (platformId === 0 && encodingId === 0) {
29240 useTable = true;
29241 // Continue the loop since there still may be a higher priority
29242 // table.
29243 } else if (platformId === 1 && encodingId === 0) {
29244 useTable = true;
29245 // Continue the loop since there still may be a higher priority
29246 // table.
29247 } else if (platformId === 3 && encodingId === 1 &&
29248 ((!isSymbolicFont && hasEncoding) || !potentialTable)) {
29249 useTable = true;
29250 if (!isSymbolicFont) {
29251 canBreak = true;
29252 }
29253 } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
29254 useTable = true;
29255 canBreak = true;
29256 }
29257
29258 if (useTable) {
29259 potentialTable = {
29260 platformId: platformId,
29261 encodingId: encodingId,
29262 offset: offset
29263 };
29264 }
29265 if (canBreak) {
29266 break;
29267 }
29268 }
29269
29270 if (potentialTable) {
29271 font.pos = start + potentialTable.offset;
29272 }
29273 if (!potentialTable || font.peekByte() === -1) {
29274 warn('Could not find a preferred cmap table.');
29275 return {
29276 platformId: -1,
29277 encodingId: -1,
29278 mappings: [],
29279 hasShortCmap: false
29280 };
29281 }
29282
29283 var format = font.getUint16();
29284 var length = font.getUint16();
29285 var language = font.getUint16();
29286
29287 var hasShortCmap = false;
29288 var mappings = [];
29289 var j, glyphId;
29290
29291 // TODO(mack): refactor this cmap subtable reading logic out
29292 if (format === 0) {
29293 for (j = 0; j < 256; j++) {
29294 var index = font.getByte();
29295 if (!index) {
29296 continue;
29297 }
29298 mappings.push({
29299 charCode: j,
29300 glyphId: index
29301 });
29302 }
29303 hasShortCmap = true;
29304 } else if (format === 4) {
29305 // re-creating the table in format 4 since the encoding
29306 // might be changed
29307 var segCount = (font.getUint16() >> 1);
29308 font.getBytes(6); // skipping range fields
29309 var segIndex, segments = [];
29310 for (segIndex = 0; segIndex < segCount; segIndex++) {
29311 segments.push({ end: font.getUint16() });
29312 }
29313 font.getUint16();
29314 for (segIndex = 0; segIndex < segCount; segIndex++) {
29315 segments[segIndex].start = font.getUint16();
29316 }
29317
29318 for (segIndex = 0; segIndex < segCount; segIndex++) {
29319 segments[segIndex].delta = font.getUint16();
29320 }
29321
29322 var offsetsCount = 0;
29323 for (segIndex = 0; segIndex < segCount; segIndex++) {
29324 segment = segments[segIndex];
29325 var rangeOffset = font.getUint16();
29326 if (!rangeOffset) {
29327 segment.offsetIndex = -1;
29328 continue;
29329 }
29330
29331 var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
29332 segment.offsetIndex = offsetIndex;
29333 offsetsCount = Math.max(offsetsCount, offsetIndex +
29334 segment.end - segment.start + 1);
29335 }
29336
29337 var offsets = [];
29338 for (j = 0; j < offsetsCount; j++) {
29339 offsets.push(font.getUint16());
29340 }
29341
29342 for (segIndex = 0; segIndex < segCount; segIndex++) {
29343 segment = segments[segIndex];
29344 start = segment.start;
29345 var end = segment.end;
29346 var delta = segment.delta;
29347 offsetIndex = segment.offsetIndex;
29348
29349 for (j = start; j <= end; j++) {
29350 if (j === 0xFFFF) {
29351 continue;
29352 }
29353
29354 glyphId = (offsetIndex < 0 ?
29355 j : offsets[offsetIndex + j - start]);
29356 glyphId = (glyphId + delta) & 0xFFFF;
29357 if (glyphId === 0) {
29358 continue;
29359 }
29360 mappings.push({
29361 charCode: j,
29362 glyphId: glyphId
29363 });
29364 }
29365 }
29366 } else if (format === 6) {
29367 // Format 6 is a 2-bytes dense mapping, which means the font data
29368 // lives glue together even if they are pretty far in the unicode
29369 // table. (This looks weird, so I can have missed something), this
29370 // works on Linux but seems to fails on Mac so let's rewrite the
29371 // cmap table to a 3-1-4 style
29372 var firstCode = font.getUint16();
29373 var entryCount = font.getUint16();
29374
29375 for (j = 0; j < entryCount; j++) {
29376 glyphId = font.getUint16();
29377 var charCode = firstCode + j;
29378
29379 mappings.push({
29380 charCode: charCode,
29381 glyphId: glyphId
29382 });
29383 }
29384 } else {
29385 warn('cmap table has unsupported format: ' + format);
29386 return {
29387 platformId: -1,
29388 encodingId: -1,
29389 mappings: [],
29390 hasShortCmap: false
29391 };
29392 }
29393
29394 // removing duplicate entries
29395 mappings.sort(function (a, b) {
29396 return a.charCode - b.charCode;
29397 });
29398 for (i = 1; i < mappings.length; i++) {
29399 if (mappings[i - 1].charCode === mappings[i].charCode) {
29400 mappings.splice(i, 1);
29401 i--;
29402 }
29403 }
29404
29405 return {
29406 platformId: potentialTable.platformId,
29407 encodingId: potentialTable.encodingId,
29408 mappings: mappings,
29409 hasShortCmap: hasShortCmap
29410 };
29411 }
29412
29413 function sanitizeMetrics(font, header, metrics, numGlyphs) {
29414 if (!header) {
29415 if (metrics) {
29416 metrics.data = null;
29417 }
29418 return;
29419 }
29420
29421 font.pos = (font.start ? font.start : 0) + header.offset;
29422 font.pos += header.length - 2;
29423 var numOfMetrics = font.getUint16();
29424
29425 if (numOfMetrics > numGlyphs) {
29426 info('The numOfMetrics (' + numOfMetrics + ') should not be ' +
29427 'greater than the numGlyphs (' + numGlyphs + ')');
29428 // Reduce numOfMetrics if it is greater than numGlyphs
29429 numOfMetrics = numGlyphs;
29430 header.data[34] = (numOfMetrics & 0xff00) >> 8;
29431 header.data[35] = numOfMetrics & 0x00ff;
29432 }
29433
29434 var numOfSidebearings = numGlyphs - numOfMetrics;
29435 var numMissing = numOfSidebearings -
29436 ((metrics.length - numOfMetrics * 4) >> 1);
29437
29438 if (numMissing > 0) {
29439 // For each missing glyph, we set both the width and lsb to 0 (zero).
29440 // Since we need to add two properties for each glyph, this explains
29441 // the use of |numMissing * 2| when initializing the typed array.
29442 var entries = new Uint8Array(metrics.length + numMissing * 2);
29443 entries.set(metrics.data);
29444 metrics.data = entries;
29445 }
29446 }
29447
29448 function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart,
29449 hintsValid) {
29450 if (sourceEnd - sourceStart <= 12) {
29451 // glyph with data less than 12 is invalid one
29452 return 0;
29453 }
29454 var glyf = source.subarray(sourceStart, sourceEnd);
29455 var contoursCount = (glyf[0] << 8) | glyf[1];
29456 if (contoursCount & 0x8000) {
29457 // complex glyph, writing as is
29458 dest.set(glyf, destStart);
29459 return glyf.length;
29460 }
29461
29462 var i, j = 10, flagsCount = 0;
29463 for (i = 0; i < contoursCount; i++) {
29464 var endPoint = (glyf[j] << 8) | glyf[j + 1];
29465 flagsCount = endPoint + 1;
29466 j += 2;
29467 }
29468 // skipping instructions
29469 var instructionsStart = j;
29470 var instructionsLength = (glyf[j] << 8) | glyf[j + 1];
29471 j += 2 + instructionsLength;
29472 var instructionsEnd = j;
29473 // validating flags
29474 var coordinatesLength = 0;
29475 for (i = 0; i < flagsCount; i++) {
29476 var flag = glyf[j++];
29477 if (flag & 0xC0) {
29478 // reserved flags must be zero, cleaning up
29479 glyf[j - 1] = flag & 0x3F;
29480 }
29481 var xyLength = ((flag & 2) ? 1 : (flag & 16) ? 0 : 2) +
29482 ((flag & 4) ? 1 : (flag & 32) ? 0 : 2);
29483 coordinatesLength += xyLength;
29484 if (flag & 8) {
29485 var repeat = glyf[j++];
29486 i += repeat;
29487 coordinatesLength += repeat * xyLength;
29488 }
29489 }
29490 // glyph without coordinates will be rejected
29491 if (coordinatesLength === 0) {
29492 return 0;
29493 }
29494 var glyphDataLength = j + coordinatesLength;
29495 if (glyphDataLength > glyf.length) {
29496 // not enough data for coordinates
29497 return 0;
29498 }
29499 if (!hintsValid && instructionsLength > 0) {
29500 dest.set(glyf.subarray(0, instructionsStart), destStart);
29501 dest.set([0, 0], destStart + instructionsStart);
29502 dest.set(glyf.subarray(instructionsEnd, glyphDataLength),
29503 destStart + instructionsStart + 2);
29504 glyphDataLength -= instructionsLength;
29505 if (glyf.length - glyphDataLength > 3) {
29506 glyphDataLength = (glyphDataLength + 3) & ~3;
29507 }
29508 return glyphDataLength;
29509 }
29510 if (glyf.length - glyphDataLength > 3) {
29511 // truncating and aligning to 4 bytes the long glyph data
29512 glyphDataLength = (glyphDataLength + 3) & ~3;
29513 dest.set(glyf.subarray(0, glyphDataLength), destStart);
29514 return glyphDataLength;
29515 }
29516 // glyph data is fine
29517 dest.set(glyf, destStart);
29518 return glyf.length;
29519 }
29520
29521 function sanitizeHead(head, numGlyphs, locaLength) {
29522 var data = head.data;
29523
29524 // Validate version:
29525 // Should always be 0x00010000
29526 var version = int32(data[0], data[1], data[2], data[3]);
29527 if (version >> 16 !== 1) {
29528 info('Attempting to fix invalid version in head table: ' + version);
29529 data[0] = 0;
29530 data[1] = 1;
29531 data[2] = 0;
29532 data[3] = 0;
29533 }
29534
29535 var indexToLocFormat = int16(data[50], data[51]);
29536 if (indexToLocFormat < 0 || indexToLocFormat > 1) {
29537 info('Attempting to fix invalid indexToLocFormat in head table: ' +
29538 indexToLocFormat);
29539
29540 // The value of indexToLocFormat should be 0 if the loca table
29541 // consists of short offsets, and should be 1 if the loca table
29542 // consists of long offsets.
29543 //
29544 // The number of entries in the loca table should be numGlyphs + 1.
29545 //
29546 // Using this information, we can work backwards to deduce if the
29547 // size of each offset in the loca table, and thus figure out the
29548 // appropriate value for indexToLocFormat.
29549
29550 var numGlyphsPlusOne = numGlyphs + 1;
29551 if (locaLength === numGlyphsPlusOne << 1) {
29552 // 0x0000 indicates the loca table consists of short offsets
29553 data[50] = 0;
29554 data[51] = 0;
29555 } else if (locaLength === numGlyphsPlusOne << 2) {
29556 // 0x0001 indicates the loca table consists of long offsets
29557 data[50] = 0;
29558 data[51] = 1;
29559 } else {
29560 warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
29561 }
29562 }
29563 }
29564
29565 function sanitizeGlyphLocations(loca, glyf, numGlyphs,
29566 isGlyphLocationsLong, hintsValid,
29567 dupFirstEntry) {
29568 var itemSize, itemDecode, itemEncode;
29569 if (isGlyphLocationsLong) {
29570 itemSize = 4;
29571 itemDecode = function fontItemDecodeLong(data, offset) {
29572 return (data[offset] << 24) | (data[offset + 1] << 16) |
29573 (data[offset + 2] << 8) | data[offset + 3];
29574 };
29575 itemEncode = function fontItemEncodeLong(data, offset, value) {
29576 data[offset] = (value >>> 24) & 0xFF;
29577 data[offset + 1] = (value >> 16) & 0xFF;
29578 data[offset + 2] = (value >> 8) & 0xFF;
29579 data[offset + 3] = value & 0xFF;
29580 };
29581 } else {
29582 itemSize = 2;
29583 itemDecode = function fontItemDecode(data, offset) {
29584 return (data[offset] << 9) | (data[offset + 1] << 1);
29585 };
29586 itemEncode = function fontItemEncode(data, offset, value) {
29587 data[offset] = (value >> 9) & 0xFF;
29588 data[offset + 1] = (value >> 1) & 0xFF;
29589 };
29590 }
29591 var locaData = loca.data;
29592 var locaDataSize = itemSize * (1 + numGlyphs);
29593 // is loca.data too short or long?
29594 if (locaData.length !== locaDataSize) {
29595 locaData = new Uint8Array(locaDataSize);
29596 locaData.set(loca.data.subarray(0, locaDataSize));
29597 loca.data = locaData;
29598 }
29599 // removing the invalid glyphs
29600 var oldGlyfData = glyf.data;
29601 var oldGlyfDataLength = oldGlyfData.length;
29602 var newGlyfData = new Uint8Array(oldGlyfDataLength);
29603 var startOffset = itemDecode(locaData, 0);
29604 var writeOffset = 0;
29605 var missingGlyphData = Object.create(null);
29606 itemEncode(locaData, 0, writeOffset);
29607 var i, j;
29608 for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
29609 var endOffset = itemDecode(locaData, j);
29610 if (endOffset > oldGlyfDataLength &&
29611 ((oldGlyfDataLength + 3) & ~3) === endOffset) {
29612 // Aspose breaks fonts by aligning the glyphs to the qword, but not
29613 // the glyf table size, which makes last glyph out of range.
29614 endOffset = oldGlyfDataLength;
29615 }
29616 if (endOffset > oldGlyfDataLength) {
29617 // glyph end offset points outside glyf data, rejecting the glyph
29618 itemEncode(locaData, j, writeOffset);
29619 startOffset = endOffset;
29620 continue;
29621 }
29622
29623 if (startOffset === endOffset) {
29624 missingGlyphData[i] = true;
29625 }
29626
29627 var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset,
29628 newGlyfData, writeOffset, hintsValid);
29629 writeOffset += newLength;
29630 itemEncode(locaData, j, writeOffset);
29631 startOffset = endOffset;
29632 }
29633
29634 if (writeOffset === 0) {
29635 // glyf table cannot be empty -- redoing the glyf and loca tables
29636 // to have single glyph with one point
29637 var simpleGlyph = new Uint8Array(
29638 [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
29639 for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
29640 itemEncode(locaData, j, simpleGlyph.length);
29641 }
29642 glyf.data = simpleGlyph;
29643 return missingGlyphData;
29644 }
29645
29646 if (dupFirstEntry) {
29647 var firstEntryLength = itemDecode(locaData, itemSize);
29648 if (newGlyfData.length > firstEntryLength + writeOffset) {
29649 glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
29650 } else {
29651 glyf.data = new Uint8Array(firstEntryLength + writeOffset);
29652 glyf.data.set(newGlyfData.subarray(0, writeOffset));
29653 }
29654 glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
29655 itemEncode(loca.data, locaData.length - itemSize,
29656 writeOffset + firstEntryLength);
29657 } else {
29658 glyf.data = newGlyfData.subarray(0, writeOffset);
29659 }
29660 return missingGlyphData;
29661 }
29662
29663 function readPostScriptTable(post, properties, maxpNumGlyphs) {
29664 var start = (font.start ? font.start : 0) + post.offset;
29665 font.pos = start;
29666
29667 var length = post.length, end = start + length;
29668 var version = font.getInt32();
29669 // skip rest to the tables
29670 font.getBytes(28);
29671
29672 var glyphNames;
29673 var valid = true;
29674 var i;
29675
29676 switch (version) {
29677 case 0x00010000:
29678 glyphNames = MacStandardGlyphOrdering;
29679 break;
29680 case 0x00020000:
29681 var numGlyphs = font.getUint16();
29682 if (numGlyphs !== maxpNumGlyphs) {
29683 valid = false;
29684 break;
29685 }
29686 var glyphNameIndexes = [];
29687 for (i = 0; i < numGlyphs; ++i) {
29688 var index = font.getUint16();
29689 if (index >= 32768) {
29690 valid = false;
29691 break;
29692 }
29693 glyphNameIndexes.push(index);
29694 }
29695 if (!valid) {
29696 break;
29697 }
29698 var customNames = [];
29699 var strBuf = [];
29700 while (font.pos < end) {
29701 var stringLength = font.getByte();
29702 strBuf.length = stringLength;
29703 for (i = 0; i < stringLength; ++i) {
29704 strBuf[i] = String.fromCharCode(font.getByte());
29705 }
29706 customNames.push(strBuf.join(''));
29707 }
29708 glyphNames = [];
29709 for (i = 0; i < numGlyphs; ++i) {
29710 var j = glyphNameIndexes[i];
29711 if (j < 258) {
29712 glyphNames.push(MacStandardGlyphOrdering[j]);
29713 continue;
29714 }
29715 glyphNames.push(customNames[j - 258]);
29716 }
29717 break;
29718 case 0x00030000:
29719 break;
29720 default:
29721 warn('Unknown/unsupported post table version ' + version);
29722 valid = false;
29723 if (properties.defaultEncoding) {
29724 glyphNames = properties.defaultEncoding;
29725 }
29726 break;
29727 }
29728 properties.glyphNames = glyphNames;
29729 return valid;
29730 }
29731
29732 function readNameTable(nameTable) {
29733 var start = (font.start ? font.start : 0) + nameTable.offset;
29734 font.pos = start;
29735
29736 var names = [[], []];
29737 var length = nameTable.length, end = start + length;
29738 var format = font.getUint16();
29739 var FORMAT_0_HEADER_LENGTH = 6;
29740 if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
29741 // unsupported name table format or table "too" small
29742 return names;
29743 }
29744 var numRecords = font.getUint16();
29745 var stringsStart = font.getUint16();
29746 var records = [];
29747 var NAME_RECORD_LENGTH = 12;
29748 var i, ii;
29749
29750 for (i = 0; i < numRecords &&
29751 font.pos + NAME_RECORD_LENGTH <= end; i++) {
29752 var r = {
29753 platform: font.getUint16(),
29754 encoding: font.getUint16(),
29755 language: font.getUint16(),
29756 name: font.getUint16(),
29757 length: font.getUint16(),
29758 offset: font.getUint16()
29759 };
29760 // using only Macintosh and Windows platform/encoding names
29761 if ((r.platform === 1 && r.encoding === 0 && r.language === 0) ||
29762 (r.platform === 3 && r.encoding === 1 && r.language === 0x409)) {
29763 records.push(r);
29764 }
29765 }
29766 for (i = 0, ii = records.length; i < ii; i++) {
29767 var record = records[i];
29768 if (record.length <= 0) {
29769 continue; // Nothing to process, ignoring.
29770 }
29771 var pos = start + stringsStart + record.offset;
29772 if (pos + record.length > end) {
29773 continue; // outside of name table, ignoring
29774 }
29775 font.pos = pos;
29776 var nameIndex = record.name;
29777 if (record.encoding) {
29778 // unicode
29779 var str = '';
29780 for (var j = 0, jj = record.length; j < jj; j += 2) {
29781 str += String.fromCharCode(font.getUint16());
29782 }
29783 names[1][nameIndex] = str;
29784 } else {
29785 names[0][nameIndex] = bytesToString(font.getBytes(record.length));
29786 }
29787 }
29788 return names;
29789 }
29790
29791 var TTOpsStackDeltas = [
29792 0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5,
29793 -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1,
29794 1, -1, -999, 0, 1, 0, -1, -2, 0, -1, -2, -1, -1, 0, -1, -1,
29795 0, 0, -999, -999, -1, -1, -1, -1, -2, -999, -2, -2, -999, 0, -2, -2,
29796 0, 0, -2, 0, -2, 0, 0, 0, -2, -1, -1, 1, 1, 0, 0, -1,
29797 -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -999, -1, -1,
29798 -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
29799 -2, -999, -999, -999, -999, -999, -1, -1, -2, -2, 0, 0, 0, 0, -1, -1,
29800 -999, -2, -2, 0, 0, -1, -2, -2, 0, 0, 0, -1, -1, -1, -2];
29801 // 0xC0-DF == -1 and 0xE0-FF == -2
29802
29803 function sanitizeTTProgram(table, ttContext) {
29804 var data = table.data;
29805 var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
29806 var stack = [];
29807 var callstack = [];
29808 var functionsCalled = [];
29809 var tooComplexToFollowFunctions =
29810 ttContext.tooComplexToFollowFunctions;
29811 var inFDEF = false, ifLevel = 0, inELSE = 0;
29812 for (var ii = data.length; i < ii;) {
29813 var op = data[i++];
29814 // The TrueType instruction set docs can be found at
29815 // https://developer.apple.com/fonts/TTRefMan/RM05/Chap5.html
29816 if (op === 0x40) { // NPUSHB - pushes n bytes
29817 n = data[i++];
29818 if (inFDEF || inELSE) {
29819 i += n;
29820 } else {
29821 for (j = 0; j < n; j++) {
29822 stack.push(data[i++]);
29823 }
29824 }
29825 } else if (op === 0x41) { // NPUSHW - pushes n words
29826 n = data[i++];
29827 if (inFDEF || inELSE) {
29828 i += n * 2;
29829 } else {
29830 for (j = 0; j < n; j++) {
29831 b = data[i++];
29832 stack.push((b << 8) | data[i++]);
29833 }
29834 }
29835 } else if ((op & 0xF8) === 0xB0) { // PUSHB - pushes bytes
29836 n = op - 0xB0 + 1;
29837 if (inFDEF || inELSE) {
29838 i += n;
29839 } else {
29840 for (j = 0; j < n; j++) {
29841 stack.push(data[i++]);
29842 }
29843 }
29844 } else if ((op & 0xF8) === 0xB8) { // PUSHW - pushes words
29845 n = op - 0xB8 + 1;
29846 if (inFDEF || inELSE) {
29847 i += n * 2;
29848 } else {
29849 for (j = 0; j < n; j++) {
29850 b = data[i++];
29851 stack.push((b << 8) | data[i++]);
29852 }
29853 }
29854 } else if (op === 0x2B && !tooComplexToFollowFunctions) { // CALL
29855 if (!inFDEF && !inELSE) {
29856 // collecting inforamtion about which functions are used
29857 funcId = stack[stack.length - 1];
29858 ttContext.functionsUsed[funcId] = true;
29859 if (funcId in ttContext.functionsStackDeltas) {
29860 stack.length += ttContext.functionsStackDeltas[funcId];
29861 } else if (funcId in ttContext.functionsDefined &&
29862 functionsCalled.indexOf(funcId) < 0) {
29863 callstack.push({data: data, i: i, stackTop: stack.length - 1});
29864 functionsCalled.push(funcId);
29865 pc = ttContext.functionsDefined[funcId];
29866 if (!pc) {
29867 warn('TT: CALL non-existent function');
29868 ttContext.hintsValid = false;
29869 return;
29870 }
29871 data = pc.data;
29872 i = pc.i;
29873 }
29874 }
29875 } else if (op === 0x2C && !tooComplexToFollowFunctions) { // FDEF
29876 if (inFDEF || inELSE) {
29877 warn('TT: nested FDEFs not allowed');
29878 tooComplexToFollowFunctions = true;
29879 }
29880 inFDEF = true;
29881 // collecting inforamtion about which functions are defined
29882 lastDeff = i;
29883 funcId = stack.pop();
29884 ttContext.functionsDefined[funcId] = {data: data, i: i};
29885 } else if (op === 0x2D) { // ENDF - end of function
29886 if (inFDEF) {
29887 inFDEF = false;
29888 lastEndf = i;
29889 } else {
29890 pc = callstack.pop();
29891 if (!pc) {
29892 warn('TT: ENDF bad stack');
29893 ttContext.hintsValid = false;
29894 return;
29895 }
29896 funcId = functionsCalled.pop();
29897 data = pc.data;
29898 i = pc.i;
29899 ttContext.functionsStackDeltas[funcId] =
29900 stack.length - pc.stackTop;
29901 }
29902 } else if (op === 0x89) { // IDEF - instruction definition
29903 if (inFDEF || inELSE) {
29904 warn('TT: nested IDEFs not allowed');
29905 tooComplexToFollowFunctions = true;
29906 }
29907 inFDEF = true;
29908 // recording it as a function to track ENDF
29909 lastDeff = i;
29910 } else if (op === 0x58) { // IF
29911 ++ifLevel;
29912 } else if (op === 0x1B) { // ELSE
29913 inELSE = ifLevel;
29914 } else if (op === 0x59) { // EIF
29915 if (inELSE === ifLevel) {
29916 inELSE = 0;
29917 }
29918 --ifLevel;
29919 } else if (op === 0x1C) { // JMPR
29920 if (!inFDEF && !inELSE) {
29921 var offset = stack[stack.length - 1];
29922 // only jumping forward to prevent infinite loop
29923 if (offset > 0) {
29924 i += offset - 1;
29925 }
29926 }
29927 }
29928 // Adjusting stack not extactly, but just enough to get function id
29929 if (!inFDEF && !inELSE) {
29930 var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] :
29931 op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
29932 if (op >= 0x71 && op <= 0x75) {
29933 n = stack.pop();
29934 if (n === n) {
29935 stackDelta = -n * 2;
29936 }
29937 }
29938 while (stackDelta < 0 && stack.length > 0) {
29939 stack.pop();
29940 stackDelta++;
29941 }
29942 while (stackDelta > 0) {
29943 stack.push(NaN); // pushing any number into stack
29944 stackDelta--;
29945 }
29946 }
29947 }
29948 ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
29949 var content = [data];
29950 if (i > data.length) {
29951 content.push(new Uint8Array(i - data.length));
29952 }
29953 if (lastDeff > lastEndf) {
29954 warn('TT: complementing a missing function tail');
29955 // new function definition started, but not finished
29956 // complete function by [CLEAR, ENDF]
29957 content.push(new Uint8Array([0x22, 0x2D]));
29958 }
29959 foldTTTable(table, content);
29960 }
29961
29962 function checkInvalidFunctions(ttContext, maxFunctionDefs) {
29963 if (ttContext.tooComplexToFollowFunctions) {
29964 return;
29965 }
29966 if (ttContext.functionsDefined.length > maxFunctionDefs) {
29967 warn('TT: more functions defined than expected');
29968 ttContext.hintsValid = false;
29969 return;
29970 }
29971 for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
29972 if (j > maxFunctionDefs) {
29973 warn('TT: invalid function id: ' + j);
29974 ttContext.hintsValid = false;
29975 return;
29976 }
29977 if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
29978 warn('TT: undefined function: ' + j);
29979 ttContext.hintsValid = false;
29980 return;
29981 }
29982 }
29983 }
29984
29985 function foldTTTable(table, content) {
29986 if (content.length > 1) {
29987 // concatenating the content items
29988 var newLength = 0;
29989 var j, jj;
29990 for (j = 0, jj = content.length; j < jj; j++) {
29991 newLength += content[j].length;
29992 }
29993 newLength = (newLength + 3) & ~3;
29994 var result = new Uint8Array(newLength);
29995 var pos = 0;
29996 for (j = 0, jj = content.length; j < jj; j++) {
29997 result.set(content[j], pos);
29998 pos += content[j].length;
29999 }
30000 table.data = result;
30001 table.length = newLength;
30002 }
30003 }
30004
30005 function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
30006 var ttContext = {
30007 functionsDefined: [],
30008 functionsUsed: [],
30009 functionsStackDeltas: [],
30010 tooComplexToFollowFunctions: false,
30011 hintsValid: true
30012 };
30013 if (fpgm) {
30014 sanitizeTTProgram(fpgm, ttContext);
30015 }
30016 if (prep) {
30017 sanitizeTTProgram(prep, ttContext);
30018 }
30019 if (fpgm) {
30020 checkInvalidFunctions(ttContext, maxFunctionDefs);
30021 }
30022 if (cvt && (cvt.length & 1)) {
30023 var cvtData = new Uint8Array(cvt.length + 1);
30024 cvtData.set(cvt.data);
30025 cvt.data = cvtData;
30026 }
30027 return ttContext.hintsValid;
30028 }
30029
30030 // The following steps modify the original font data, making copy
30031 font = new Stream(new Uint8Array(font.getBytes()));
30032
30033 var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp',
30034 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
30035
30036 var header = readOpenTypeHeader(font);
30037 var numTables = header.numTables;
30038 var cff, cffFile;
30039
30040 var tables = Object.create(null);
30041 tables['OS/2'] = null;
30042 tables['cmap'] = null;
30043 tables['head'] = null;
30044 tables['hhea'] = null;
30045 tables['hmtx'] = null;
30046 tables['maxp'] = null;
30047 tables['name'] = null;
30048 tables['post'] = null;
30049
30050 var table;
30051 for (var i = 0; i < numTables; i++) {
30052 table = readTableEntry(font);
30053 if (VALID_TABLES.indexOf(table.tag) < 0) {
30054 continue; // skipping table if it's not a required or optional table
30055 }
30056 if (table.length === 0) {
30057 continue; // skipping empty tables
30058 }
30059 tables[table.tag] = table;
30060 }
30061
30062 var isTrueType = !tables['CFF '];
30063 if (!isTrueType) {
30064 // OpenType font
30065 if ((header.version === 'OTTO' && properties.type !== 'CIDFontType2') ||
30066 !tables['head'] || !tables['hhea'] || !tables['maxp'] ||
30067 !tables['post']) {
30068 // no major tables: throwing everything at CFFFont
30069 cffFile = new Stream(tables['CFF '].data);
30070 cff = new CFFFont(cffFile, properties);
30071
30072 adjustWidths(properties);
30073
30074 return this.convert(name, cff, properties);
30075 }
30076
30077 delete tables['glyf'];
30078 delete tables['loca'];
30079 delete tables['fpgm'];
30080 delete tables['prep'];
30081 delete tables['cvt '];
30082 this.isOpenType = true;
30083 } else {
30084 if (!tables['loca']) {
30085 error('Required "loca" table is not found');
30086 }
30087 if (!tables['glyf']) {
30088 warn('Required "glyf" table is not found -- trying to recover.');
30089 // Note: We use `sanitizeGlyphLocations` to add dummy glyf data below.
30090 tables['glyf'] = {
30091 tag: 'glyf',
30092 data: new Uint8Array(0),
30093 };
30094 }
30095 this.isOpenType = false;
30096 }
30097
30098 if (!tables['maxp']) {
30099 error('Required "maxp" table is not found');
30100 }
30101
30102 font.pos = (font.start || 0) + tables['maxp'].offset;
30103 var version = font.getInt32();
30104 var numGlyphs = font.getUint16();
30105 var maxFunctionDefs = 0;
30106 if (version >= 0x00010000 && tables['maxp'].length >= 22) {
30107 // maxZones can be invalid
30108 font.pos += 8;
30109 var maxZones = font.getUint16();
30110 if (maxZones > 2) { // reset to 2 if font has invalid maxZones
30111 tables['maxp'].data[14] = 0;
30112 tables['maxp'].data[15] = 2;
30113 }
30114 font.pos += 4;
30115 maxFunctionDefs = font.getUint16();
30116 }
30117
30118 var dupFirstEntry = false;
30119 if (properties.type === 'CIDFontType2' && properties.toUnicode &&
30120 properties.toUnicode.get(0) > '\u0000') {
30121 // oracle's defect (see 3427), duplicating first entry
30122 dupFirstEntry = true;
30123 numGlyphs++;
30124 tables['maxp'].data[4] = numGlyphs >> 8;
30125 tables['maxp'].data[5] = numGlyphs & 255;
30126 }
30127
30128 var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'],
30129 tables['cvt '], maxFunctionDefs);
30130 if (!hintsValid) {
30131 delete tables['fpgm'];
30132 delete tables['prep'];
30133 delete tables['cvt '];
30134 }
30135
30136 // Ensure the hmtx table contains the advance width and
30137 // sidebearings information for numGlyphs in the maxp table
30138 sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
30139
30140 if (!tables['head']) {
30141 error('Required "head" table is not found');
30142 }
30143
30144 sanitizeHead(tables['head'], numGlyphs,
30145 isTrueType ? tables['loca'].length : 0);
30146
30147 var missingGlyphs = Object.create(null);
30148 if (isTrueType) {
30149 var isGlyphLocationsLong = int16(tables['head'].data[50],
30150 tables['head'].data[51]);
30151 missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'],
30152 numGlyphs, isGlyphLocationsLong,
30153 hintsValid, dupFirstEntry);
30154 }
30155
30156 if (!tables['hhea']) {
30157 error('Required "hhea" table is not found');
30158 }
30159
30160 // Sanitizer reduces the glyph advanceWidth to the maxAdvanceWidth
30161 // Sometimes it's 0. That needs to be fixed
30162 if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
30163 tables['hhea'].data[10] = 0xFF;
30164 tables['hhea'].data[11] = 0xFF;
30165 }
30166
30167 // Extract some more font properties from the OpenType head and
30168 // hhea tables; yMin and descent value are always negative.
30169 var metricsOverride = {
30170 unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
30171 yMax: int16(tables['head'].data[42], tables['head'].data[43]),
30172 yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
30173 ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
30174 descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
30175 };
30176
30177 // PDF FontDescriptor metrics lie -- using data from actual font.
30178 this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
30179 this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
30180
30181 // The 'post' table has glyphs names.
30182 if (tables['post']) {
30183 var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
30184 if (!valid) {
30185 tables['post'] = null;
30186 }
30187 }
30188
30189 var charCodeToGlyphId = [], charCode;
30190 var toUnicode = properties.toUnicode, widths = properties.widths;
30191 var skipToUnicode = (toUnicode instanceof IdentityToUnicodeMap ||
30192 toUnicode.length === 0x10000);
30193
30194 // Helper function to try to skip mapping of empty glyphs.
30195 // Note: In some cases, just relying on the glyph data doesn't work,
30196 // hence we also use a few heuristics to fix various PDF files.
30197 function hasGlyph(glyphId, charCode, widthCode) {
30198 if (!missingGlyphs[glyphId]) {
30199 return true;
30200 }
30201 if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
30202 return true;
30203 }
30204 if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
30205 return true;
30206 }
30207 return false;
30208 }
30209
30210 if (properties.type === 'CIDFontType2') {
30211 var cidToGidMap = properties.cidToGidMap || [];
30212 var isCidToGidMapEmpty = cidToGidMap.length === 0;
30213
30214 properties.cMap.forEach(function(charCode, cid) {
30215 assert(cid <= 0xffff, 'Max size of CID is 65,535');
30216 var glyphId = -1;
30217 if (isCidToGidMapEmpty) {
30218 glyphId = cid;
30219 } else if (cidToGidMap[cid] !== undefined) {
30220 glyphId = cidToGidMap[cid];
30221 }
30222
30223 if (glyphId >= 0 && glyphId < numGlyphs &&
30224 hasGlyph(glyphId, charCode, cid)) {
30225 charCodeToGlyphId[charCode] = glyphId;
30226 }
30227 });
30228 if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
30229 // We don't duplicate the first entry in the `charCodeToGlyphId` map
30230 // if the font has a `CIDToGIDMap` which has already mapped the first
30231 // entry to a non-zero `glyphId` (fixes issue7544.pdf).
30232 charCodeToGlyphId[0] = numGlyphs - 1;
30233 }
30234 } else {
30235 // Most of the following logic in this code branch is based on the
30236 // 9.6.6.4 of the PDF spec.
30237 var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont,
30238 properties.hasEncoding);
30239 var cmapPlatformId = cmapTable.platformId;
30240 var cmapEncodingId = cmapTable.encodingId;
30241 var cmapMappings = cmapTable.mappings;
30242 var cmapMappingsLength = cmapMappings.length;
30243
30244 // The spec seems to imply that if the font is symbolic the encoding
30245 // should be ignored, this doesn't appear to work for 'preistabelle.pdf'
30246 // where the the font is symbolic and it has an encoding.
30247 if (properties.hasEncoding &&
30248 (cmapPlatformId === 3 && cmapEncodingId === 1 ||
30249 cmapPlatformId === 1 && cmapEncodingId === 0) ||
30250 (cmapPlatformId === -1 && cmapEncodingId === -1 && // Temporary hack
30251 !!getEncoding(properties.baseEncodingName))) { // Temporary hack
30252 // When no preferred cmap table was found and |baseEncodingName| is
30253 // one of the predefined encodings, we seem to obtain a better
30254 // |charCodeToGlyphId| map from the code below (fixes bug 1057544).
30255 // TODO: Note that this is a hack which should be removed as soon as
30256 // we have proper support for more exotic cmap tables.
30257
30258 var baseEncoding = [];
30259 if (properties.baseEncodingName === 'MacRomanEncoding' ||
30260 properties.baseEncodingName === 'WinAnsiEncoding') {
30261 baseEncoding = getEncoding(properties.baseEncodingName);
30262 }
30263 var glyphsUnicodeMap = getGlyphsUnicode();
30264 for (charCode = 0; charCode < 256; charCode++) {
30265 var glyphName, standardGlyphName;
30266 if (this.differences && charCode in this.differences) {
30267 glyphName = this.differences[charCode];
30268 } else if (charCode in baseEncoding &&
30269 baseEncoding[charCode] !== '') {
30270 glyphName = baseEncoding[charCode];
30271 } else {
30272 glyphName = StandardEncoding[charCode];
30273 }
30274 if (!glyphName) {
30275 continue;
30276 }
30277 // Ensure that non-standard glyph names are resolved to valid ones.
30278 standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
30279
30280 var unicodeOrCharCode, isUnicode = false;
30281 if (cmapPlatformId === 3 && cmapEncodingId === 1) {
30282 unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
30283 isUnicode = true;
30284 } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
30285 // TODO: the encoding needs to be updated with mac os table.
30286 unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
30287 }
30288
30289 var found = false;
30290 for (i = 0; i < cmapMappingsLength; ++i) {
30291 if (cmapMappings[i].charCode !== unicodeOrCharCode) {
30292 continue;
30293 }
30294 var code = isUnicode ? charCode : unicodeOrCharCode;
30295 if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
30296 charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
30297 found = true;
30298 break;
30299 }
30300 }
30301 if (!found && properties.glyphNames) {
30302 // Try to map using the post table.
30303 var glyphId = properties.glyphNames.indexOf(glyphName);
30304 // The post table ought to use the same kind of glyph names as the
30305 // `differences` array, but check the standard ones as a fallback.
30306 if (glyphId === -1 && standardGlyphName !== glyphName) {
30307 glyphId = properties.glyphNames.indexOf(standardGlyphName);
30308 }
30309 if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
30310 charCodeToGlyphId[charCode] = glyphId;
30311 found = true;
30312 }
30313 }
30314 if (!found) {
30315 charCodeToGlyphId[charCode] = 0; // notdef
30316 }
30317 }
30318 } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
30319 // Default Unicode semantics, use the charcodes as is.
30320 for (i = 0; i < cmapMappingsLength; ++i) {
30321 charCodeToGlyphId[cmapMappings[i].charCode] =
30322 cmapMappings[i].glyphId;
30323 }
30324 } else {
30325 // For (3, 0) cmap tables:
30326 // The charcode key being stored in charCodeToGlyphId is the lower
30327 // byte of the two-byte charcodes of the cmap table since according to
30328 // the spec: 'each byte from the string shall be prepended with the
30329 // high byte of the range [of charcodes in the cmap table], to form
30330 // a two-byte character, which shall be used to select the
30331 // associated glyph description from the subtable'.
30332 //
30333 // For (1, 0) cmap tables:
30334 // 'single bytes from the string shall be used to look up the
30335 // associated glyph descriptions from the subtable'. This means
30336 // charcodes in the cmap will be single bytes, so no-op since
30337 // glyph.charCode & 0xFF === glyph.charCode
30338 for (i = 0; i < cmapMappingsLength; ++i) {
30339 charCode = cmapMappings[i].charCode & 0xFF;
30340 charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
30341 }
30342 }
30343 }
30344
30345 if (charCodeToGlyphId.length === 0) {
30346 // defines at least one glyph
30347 charCodeToGlyphId[0] = 0;
30348 }
30349
30350 // Converting glyphs and ids into font's cmap table
30351 var newMapping = adjustMapping(charCodeToGlyphId, properties);
30352 this.toFontChar = newMapping.toFontChar;
30353 tables['cmap'] = {
30354 tag: 'cmap',
30355 data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
30356 };
30357
30358 if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
30359 tables['OS/2'] = {
30360 tag: 'OS/2',
30361 data: createOS2Table(properties, newMapping.charCodeToGlyphId,
30362 metricsOverride)
30363 };
30364 }
30365
30366 // Rewrite the 'post' table if needed
30367 if (!tables['post']) {
30368 tables['post'] = {
30369 tag: 'post',
30370 data: createPostTable(properties)
30371 };
30372 }
30373
30374 if (!isTrueType) {
30375 try {
30376 // Trying to repair CFF file
30377 cffFile = new Stream(tables['CFF '].data);
30378 var parser = new CFFParser(cffFile, properties,
30379 SEAC_ANALYSIS_ENABLED);
30380 cff = parser.parse();
30381 var compiler = new CFFCompiler(cff);
30382 tables['CFF '].data = compiler.compile();
30383 } catch (e) {
30384 warn('Failed to compile font ' + properties.loadedName);
30385 }
30386 }
30387
30388 // Re-creating 'name' table
30389 if (!tables['name']) {
30390 tables['name'] = {
30391 tag: 'name',
30392 data: createNameTable(this.name)
30393 };
30394 } else {
30395 // ... using existing 'name' table as prototype
30396 var namePrototype = readNameTable(tables['name']);
30397 tables['name'].data = createNameTable(name, namePrototype);
30398 }
30399
30400 var builder = new OpenTypeFileBuilder(header.version);
30401 for (var tableTag in tables) {
30402 builder.addTable(tableTag, tables[tableTag].data);
30403 }
30404 return builder.toArray();
30405 },
30406
30407 convert: function Font_convert(fontName, font, properties) {
30408 // TODO: Check the charstring widths to determine this.
30409 properties.fixedPitch = false;
30410
30411 if (properties.builtInEncoding) {
30412 // For Type1 fonts that do not include either `ToUnicode` or `Encoding`
30413 // data, attempt to use the `builtInEncoding` to improve text selection.
30414 adjustToUnicode(properties, properties.builtInEncoding);
30415 }
30416
30417 var mapping = font.getGlyphMapping(properties);
30418 var newMapping = adjustMapping(mapping, properties);
30419 this.toFontChar = newMapping.toFontChar;
30420 var numGlyphs = font.numGlyphs;
30421
30422 function getCharCodes(charCodeToGlyphId, glyphId) {
30423 var charCodes = null;
30424 for (var charCode in charCodeToGlyphId) {
30425 if (glyphId === charCodeToGlyphId[charCode]) {
30426 if (!charCodes) {
30427 charCodes = [];
30428 }
30429 charCodes.push(charCode | 0);
30430 }
30431 }
30432 return charCodes;
30433 }
30434
30435 function createCharCode(charCodeToGlyphId, glyphId) {
30436 for (var charCode in charCodeToGlyphId) {
30437 if (glyphId === charCodeToGlyphId[charCode]) {
30438 return charCode | 0;
30439 }
30440 }
30441 newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] =
30442 glyphId;
30443 return newMapping.nextAvailableFontCharCode++;
30444 }
30445
30446 var seacs = font.seacs;
30447 if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
30448 var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
30449 var charset = font.getCharset();
30450 var seacMap = Object.create(null);
30451 for (var glyphId in seacs) {
30452 glyphId |= 0;
30453 var seac = seacs[glyphId];
30454 var baseGlyphName = StandardEncoding[seac[2]];
30455 var accentGlyphName = StandardEncoding[seac[3]];
30456 var baseGlyphId = charset.indexOf(baseGlyphName);
30457 var accentGlyphId = charset.indexOf(accentGlyphName);
30458 if (baseGlyphId < 0 || accentGlyphId < 0) {
30459 continue;
30460 }
30461 var accentOffset = {
30462 x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
30463 y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
30464 };
30465
30466 var charCodes = getCharCodes(mapping, glyphId);
30467 if (!charCodes) {
30468 // There's no point in mapping it if the char code was never mapped
30469 // to begin with.
30470 continue;
30471 }
30472 for (var i = 0, ii = charCodes.length; i < ii; i++) {
30473 var charCode = charCodes[i];
30474 // Find a fontCharCode that maps to the base and accent glyphs.
30475 // If one doesn't exists, create it.
30476 var charCodeToGlyphId = newMapping.charCodeToGlyphId;
30477 var baseFontCharCode = createCharCode(charCodeToGlyphId,
30478 baseGlyphId);
30479 var accentFontCharCode = createCharCode(charCodeToGlyphId,
30480 accentGlyphId);
30481 seacMap[charCode] = {
30482 baseFontCharCode: baseFontCharCode,
30483 accentFontCharCode: accentFontCharCode,
30484 accentOffset: accentOffset
30485 };
30486 }
30487 }
30488 properties.seacMap = seacMap;
30489 }
30490
30491 var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
30492
30493 var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
30494 // PostScript Font Program
30495 builder.addTable('CFF ', font.data);
30496 // OS/2 and Windows Specific metrics
30497 builder.addTable('OS/2', createOS2Table(properties,
30498 newMapping.charCodeToGlyphId));
30499 // Character to glyphs mapping
30500 builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId,
30501 numGlyphs));
30502 // Font header
30503 builder.addTable('head',
30504 '\x00\x01\x00\x00' + // Version number
30505 '\x00\x00\x10\x00' + // fontRevision
30506 '\x00\x00\x00\x00' + // checksumAdjustement
30507 '\x5F\x0F\x3C\xF5' + // magicNumber
30508 '\x00\x00' + // Flags
30509 safeString16(unitsPerEm) + // unitsPerEM
30510 '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + // creation date
30511 '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + // modifification date
30512 '\x00\x00' + // xMin
30513 safeString16(properties.descent) + // yMin
30514 '\x0F\xFF' + // xMax
30515 safeString16(properties.ascent) + // yMax
30516 string16(properties.italicAngle ? 2 : 0) + // macStyle
30517 '\x00\x11' + // lowestRecPPEM
30518 '\x00\x00' + // fontDirectionHint
30519 '\x00\x00' + // indexToLocFormat
30520 '\x00\x00'); // glyphDataFormat
30521
30522 // Horizontal header
30523 builder.addTable('hhea',
30524 '\x00\x01\x00\x00' + // Version number
30525 safeString16(properties.ascent) + // Typographic Ascent
30526 safeString16(properties.descent) + // Typographic Descent
30527 '\x00\x00' + // Line Gap
30528 '\xFF\xFF' + // advanceWidthMax
30529 '\x00\x00' + // minLeftSidebearing
30530 '\x00\x00' + // minRightSidebearing
30531 '\x00\x00' + // xMaxExtent
30532 safeString16(properties.capHeight) + // caretSlopeRise
30533 safeString16(Math.tan(properties.italicAngle) *
30534 properties.xHeight) + // caretSlopeRun
30535 '\x00\x00' + // caretOffset
30536 '\x00\x00' + // -reserved-
30537 '\x00\x00' + // -reserved-
30538 '\x00\x00' + // -reserved-
30539 '\x00\x00' + // -reserved-
30540 '\x00\x00' + // metricDataFormat
30541 string16(numGlyphs)); // Number of HMetrics
30542
30543 // Horizontal metrics
30544 builder.addTable('hmtx', (function fontFieldsHmtx() {
30545 var charstrings = font.charstrings;
30546 var cffWidths = font.cff ? font.cff.widths : null;
30547 var hmtx = '\x00\x00\x00\x00'; // Fake .notdef
30548 for (var i = 1, ii = numGlyphs; i < ii; i++) {
30549 var width = 0;
30550 if (charstrings) {
30551 var charstring = charstrings[i - 1];
30552 width = 'width' in charstring ? charstring.width : 0;
30553 } else if (cffWidths) {
30554 width = Math.ceil(cffWidths[i] || 0);
30555 }
30556 hmtx += string16(width) + string16(0);
30557 }
30558 return hmtx;
30559 })());
30560
30561 // Maximum profile
30562 builder.addTable('maxp',
30563 '\x00\x00\x50\x00' + // Version number
30564 string16(numGlyphs)); // Num of glyphs
30565
30566 // Naming tables
30567 builder.addTable('name', createNameTable(fontName));
30568
30569 // PostScript information
30570 builder.addTable('post', createPostTable(properties));
30571
30572 return builder.toArray();
30573 },
30574
30575 get spaceWidth() {
30576 if ('_shadowWidth' in this) {
30577 return this._shadowWidth;
30578 }
30579
30580 // trying to estimate space character width
30581 var possibleSpaceReplacements = ['space', 'minus', 'one', 'i', 'I'];
30582 var width;
30583 for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
30584 var glyphName = possibleSpaceReplacements[i];
30585 // if possible, getting width by glyph name
30586 if (glyphName in this.widths) {
30587 width = this.widths[glyphName];
30588 break;
30589 }
30590 var glyphsUnicodeMap = getGlyphsUnicode();
30591 var glyphUnicode = glyphsUnicodeMap[glyphName];
30592 // finding the charcode via unicodeToCID map
30593 var charcode = 0;
30594 if (this.composite) {
30595 if (this.cMap.contains(glyphUnicode)) {
30596 charcode = this.cMap.lookup(glyphUnicode);
30597 }
30598 }
30599 // ... via toUnicode map
30600 if (!charcode && this.toUnicode) {
30601 charcode = this.toUnicode.charCodeOf(glyphUnicode);
30602 }
30603 // setting it to unicode if negative or undefined
30604 if (charcode <= 0) {
30605 charcode = glyphUnicode;
30606 }
30607 // trying to get width via charcode
30608 width = this.widths[charcode];
30609 if (width) {
30610 break; // the non-zero width found
30611 }
30612 }
30613 width = width || this.defaultWidth;
30614 // Do not shadow the property here. See discussion:
30615 // https://github.com/mozilla/pdf.js/pull/2127#discussion_r1662280
30616 this._shadowWidth = width;
30617 return width;
30618 },
30619
30620 charToGlyph: function Font_charToGlyph(charcode, isSpace) {
30621 var fontCharCode, width, operatorListId;
30622
30623 var widthCode = charcode;
30624 if (this.cMap && this.cMap.contains(charcode)) {
30625 widthCode = this.cMap.lookup(charcode);
30626 }
30627 width = this.widths[widthCode];
30628 width = isNum(width) ? width : this.defaultWidth;
30629 var vmetric = this.vmetrics && this.vmetrics[widthCode];
30630
30631 var unicode = this.toUnicode.get(charcode) || charcode;
30632 if (typeof unicode === 'number') {
30633 unicode = String.fromCharCode(unicode);
30634 }
30635
30636 var isInFont = charcode in this.toFontChar;
30637 // First try the toFontChar map, if it's not there then try falling
30638 // back to the char code.
30639 fontCharCode = this.toFontChar[charcode] || charcode;
30640 if (this.missingFile) {
30641 fontCharCode = mapSpecialUnicodeValues(fontCharCode);
30642 }
30643
30644 if (this.isType3Font) {
30645 // Font char code in this case is actually a glyph name.
30646 operatorListId = fontCharCode;
30647 }
30648
30649 var accent = null;
30650 if (this.seacMap && this.seacMap[charcode]) {
30651 isInFont = true;
30652 var seac = this.seacMap[charcode];
30653 fontCharCode = seac.baseFontCharCode;
30654 accent = {
30655 fontChar: String.fromCharCode(seac.accentFontCharCode),
30656 offset: seac.accentOffset
30657 };
30658 }
30659
30660 var fontChar = String.fromCharCode(fontCharCode);
30661
30662 var glyph = this.glyphCache[charcode];
30663 if (!glyph ||
30664 !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric,
30665 operatorListId, isSpace, isInFont)) {
30666 glyph = new Glyph(fontChar, unicode, accent, width, vmetric,
30667 operatorListId, isSpace, isInFont);
30668 this.glyphCache[charcode] = glyph;
30669 }
30670 return glyph;
30671 },
30672
30673 charsToGlyphs: function Font_charsToGlyphs(chars) {
30674 var charsCache = this.charsCache;
30675 var glyphs, glyph, charcode;
30676
30677 // if we translated this string before, just grab it from the cache
30678 if (charsCache) {
30679 glyphs = charsCache[chars];
30680 if (glyphs) {
30681 return glyphs;
30682 }
30683 }
30684
30685 // lazily create the translation cache
30686 if (!charsCache) {
30687 charsCache = this.charsCache = Object.create(null);
30688 }
30689
30690 glyphs = [];
30691 var charsCacheKey = chars;
30692 var i = 0, ii;
30693
30694 if (this.cMap) {
30695 // composite fonts have multi-byte strings convert the string from
30696 // single-byte to multi-byte
30697 var c = Object.create(null);
30698 while (i < chars.length) {
30699 this.cMap.readCharCode(chars, i, c);
30700 charcode = c.charcode;
30701 var length = c.length;
30702 i += length;
30703 // Space is char with code 0x20 and length 1 in multiple-byte codes.
30704 var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
30705 glyph = this.charToGlyph(charcode, isSpace);
30706 glyphs.push(glyph);
30707 }
30708 } else {
30709 for (i = 0, ii = chars.length; i < ii; ++i) {
30710 charcode = chars.charCodeAt(i);
30711 glyph = this.charToGlyph(charcode, charcode === 0x20);
30712 glyphs.push(glyph);
30713 }
30714 }
30715
30716 // Enter the translated string into the cache
30717 return (charsCache[charsCacheKey] = glyphs);
30718 }
30719 };
30720
30721 return Font;
30722})();
30723
30724var ErrorFont = (function ErrorFontClosure() {
30725 function ErrorFont(error) {
30726 this.error = error;
30727 this.loadedName = 'g_font_error';
30728 this.loading = false;
30729 }
30730
30731 ErrorFont.prototype = {
30732 charsToGlyphs: function ErrorFont_charsToGlyphs() {
30733 return [];
30734 },
30735 exportData: function ErrorFont_exportData() {
30736 return {error: this.error};
30737 }
30738 };
30739
30740 return ErrorFont;
30741})();
30742
30743/**
30744 * Shared logic for building a char code to glyph id mapping for Type1 and
30745 * simple CFF fonts. See section 9.6.6.2 of the spec.
30746 * @param {Object} properties Font properties object.
30747 * @param {Object} builtInEncoding The encoding contained within the actual font
30748 * data.
30749 * @param {Array} glyphNames Array of glyph names where the index is the
30750 * glyph ID.
30751 * @returns {Object} A char code to glyph ID map.
30752 */
30753function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
30754 var charCodeToGlyphId = Object.create(null);
30755 var glyphId, charCode, baseEncoding;
30756
30757 if (properties.baseEncodingName) {
30758 // If a valid base encoding name was used, the mapping is initialized with
30759 // that.
30760 baseEncoding = getEncoding(properties.baseEncodingName);
30761 for (charCode = 0; charCode < baseEncoding.length; charCode++) {
30762 glyphId = glyphNames.indexOf(baseEncoding[charCode]);
30763 if (glyphId >= 0) {
30764 charCodeToGlyphId[charCode] = glyphId;
30765 } else {
30766 charCodeToGlyphId[charCode] = 0; // notdef
30767 }
30768 }
30769 } else if (!!(properties.flags & FontFlags.Symbolic)) {
30770 // For a symbolic font the encoding should be the fonts built-in
30771 // encoding.
30772 for (charCode in builtInEncoding) {
30773 charCodeToGlyphId[charCode] = builtInEncoding[charCode];
30774 }
30775 } else {
30776 // For non-symbolic fonts that don't have a base encoding the standard
30777 // encoding should be used.
30778 baseEncoding = StandardEncoding;
30779 for (charCode = 0; charCode < baseEncoding.length; charCode++) {
30780 glyphId = glyphNames.indexOf(baseEncoding[charCode]);
30781 if (glyphId >= 0) {
30782 charCodeToGlyphId[charCode] = glyphId;
30783 } else {
30784 charCodeToGlyphId[charCode] = 0; // notdef
30785 }
30786 }
30787 }
30788
30789 // Lastly, merge in the differences.
30790 var differences = properties.differences, glyphsUnicodeMap;
30791 if (differences) {
30792 for (charCode in differences) {
30793 var glyphName = differences[charCode];
30794 glyphId = glyphNames.indexOf(glyphName);
30795
30796 if (glyphId === -1) {
30797 if (!glyphsUnicodeMap) {
30798 glyphsUnicodeMap = getGlyphsUnicode();
30799 }
30800 var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
30801 if (standardGlyphName !== glyphName) {
30802 glyphId = glyphNames.indexOf(standardGlyphName);
30803 }
30804 }
30805 if (glyphId >= 0) {
30806 charCodeToGlyphId[charCode] = glyphId;
30807 } else {
30808 charCodeToGlyphId[charCode] = 0; // notdef
30809 }
30810 }
30811 }
30812 return charCodeToGlyphId;
30813}
30814
30815// Type1Font is also a CIDFontType0.
30816var Type1Font = (function Type1FontClosure() {
30817 function findBlock(streamBytes, signature, startIndex) {
30818 var streamBytesLength = streamBytes.length;
30819 var signatureLength = signature.length;
30820 var scanLength = streamBytesLength - signatureLength;
30821
30822 var i = startIndex, j, found = false;
30823 while (i < scanLength) {
30824 j = 0;
30825 while (j < signatureLength && streamBytes[i + j] === signature[j]) {
30826 j++;
30827 }
30828 if (j >= signatureLength) { // `signature` found, skip over whitespace.
30829 i += j;
30830 while (i < streamBytesLength && isSpace(streamBytes[i])) {
30831 i++;
30832 }
30833 found = true;
30834 break;
30835 }
30836 i++;
30837 }
30838 return {
30839 found: found,
30840 length: i,
30841 };
30842 }
30843
30844 function getHeaderBlock(stream, suggestedLength) {
30845 var EEXEC_SIGNATURE = [0x65, 0x65, 0x78, 0x65, 0x63];
30846
30847 var streamStartPos = stream.pos; // Save the initial stream position.
30848 var headerBytes, headerBytesLength, block;
30849 try {
30850 headerBytes = stream.getBytes(suggestedLength);
30851 headerBytesLength = headerBytes.length;
30852 } catch (ex) {
30853 if (ex instanceof MissingDataException) {
30854 throw ex;
30855 }
30856 // Ignore errors if the `suggestedLength` is huge enough that a Uint8Array
30857 // cannot hold the result of `getBytes`, and fallback to simply checking
30858 // the entire stream (fixes issue3928.pdf).
30859 }
30860
30861 if (headerBytesLength === suggestedLength) {
30862 // Most of the time `suggestedLength` is correct, so to speed things up we
30863 // initially only check the last few bytes to see if the header was found.
30864 // Otherwise we (potentially) check the entire stream to prevent errors in
30865 // `Type1Parser` (fixes issue5686.pdf).
30866 block = findBlock(headerBytes, EEXEC_SIGNATURE,
30867 suggestedLength - 2 * EEXEC_SIGNATURE.length);
30868
30869 if (block.found && block.length === suggestedLength) {
30870 return {
30871 stream: new Stream(headerBytes),
30872 length: suggestedLength,
30873 };
30874 }
30875 }
30876 warn('Invalid "Length1" property in Type1 font -- trying to recover.');
30877 stream.pos = streamStartPos; // Reset the stream position.
30878
30879 var SCAN_BLOCK_LENGTH = 2048;
30880 var actualLength;
30881 while (true) {
30882 var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
30883 block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
30884
30885 if (block.length === 0) {
30886 break;
30887 }
30888 stream.pos += block.length; // Update the stream position.
30889
30890 if (block.found) {
30891 actualLength = stream.pos - streamStartPos;
30892 break;
30893 }
30894 }
30895 stream.pos = streamStartPos; // Reset the stream position.
30896
30897 if (actualLength) {
30898 return {
30899 stream: new Stream(stream.getBytes(actualLength)),
30900 length: actualLength,
30901 };
30902 }
30903 warn('Unable to recover "Length1" property in Type1 font -- using as is.');
30904 return {
30905 stream: new Stream(stream.getBytes(suggestedLength)),
30906 length: suggestedLength,
30907 };
30908 }
30909
30910 function getEexecBlock(stream, suggestedLength) {
30911 // We should ideally parse the eexec block to ensure that `suggestedLength`
30912 // is correct, so we don't truncate the block data if it's too small.
30913 // However, this would also require checking if the fixed-content portion
30914 // exists (using the 'Length3' property), and ensuring that it's valid.
30915 //
30916 // Given that `suggestedLength` almost always is correct, all the validation
30917 // would require a great deal of unnecessary parsing for most fonts.
30918 // To save time, we always fetch the entire stream instead, which also avoid
30919 // issues if `suggestedLength` is huge (see comment in `getHeaderBlock`).
30920 //
30921 // NOTE: This means that the function can include the fixed-content portion
30922 // in the returned eexec block. In practice this does *not* seem to matter,
30923 // since `Type1Parser_extractFontProgram` will skip over any non-commands.
30924 var eexecBytes = stream.getBytes();
30925 return {
30926 stream: new Stream(eexecBytes),
30927 length: eexecBytes.length,
30928 };
30929 }
30930
30931 function Type1Font(name, file, properties) {
30932 // Some bad generators embed pfb file as is, we have to strip 6-byte header.
30933 // Also, length1 and length2 might be off by 6 bytes as well.
30934 // http://www.math.ubc.ca/~cass/piscript/type1.pdf
30935 var PFB_HEADER_SIZE = 6;
30936 var headerBlockLength = properties.length1;
30937 var eexecBlockLength = properties.length2;
30938 var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
30939 var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
30940 if (pfbHeaderPresent) {
30941 file.skip(PFB_HEADER_SIZE);
30942 headerBlockLength = (pfbHeader[5] << 24) | (pfbHeader[4] << 16) |
30943 (pfbHeader[3] << 8) | pfbHeader[2];
30944 }
30945
30946 // Get the data block containing glyphs and subrs information
30947 var headerBlock = getHeaderBlock(file, headerBlockLength);
30948 headerBlockLength = headerBlock.length;
30949 var headerBlockParser = new Type1Parser(headerBlock.stream, false,
30950 SEAC_ANALYSIS_ENABLED);
30951 headerBlockParser.extractFontHeader(properties);
30952
30953 if (pfbHeaderPresent) {
30954 pfbHeader = file.getBytes(PFB_HEADER_SIZE);
30955 eexecBlockLength = (pfbHeader[5] << 24) | (pfbHeader[4] << 16) |
30956 (pfbHeader[3] << 8) | pfbHeader[2];
30957 }
30958
30959 // Decrypt the data blocks and retrieve it's content
30960 var eexecBlock = getEexecBlock(file, eexecBlockLength);
30961 eexecBlockLength = eexecBlock.length;
30962 var eexecBlockParser = new Type1Parser(eexecBlock.stream, true,
30963 SEAC_ANALYSIS_ENABLED);
30964 var data = eexecBlockParser.extractFontProgram();
30965 for (var info in data.properties) {
30966 properties[info] = data.properties[info];
30967 }
30968
30969 var charstrings = data.charstrings;
30970 var type2Charstrings = this.getType2Charstrings(charstrings);
30971 var subrs = this.getType2Subrs(data.subrs);
30972
30973 this.charstrings = charstrings;
30974 this.data = this.wrap(name, type2Charstrings, this.charstrings,
30975 subrs, properties);
30976 this.seacs = this.getSeacs(data.charstrings);
30977 }
30978
30979 Type1Font.prototype = {
30980 get numGlyphs() {
30981 return this.charstrings.length + 1;
30982 },
30983
30984 getCharset: function Type1Font_getCharset() {
30985 var charset = ['.notdef'];
30986 var charstrings = this.charstrings;
30987 for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
30988 charset.push(charstrings[glyphId].glyphName);
30989 }
30990 return charset;
30991 },
30992
30993 getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
30994 var charstrings = this.charstrings;
30995 var glyphNames = ['.notdef'], glyphId;
30996 for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
30997 glyphNames.push(charstrings[glyphId].glyphName);
30998 }
30999 var encoding = properties.builtInEncoding;
31000 if (encoding) {
31001 var builtInEncoding = Object.create(null);
31002 for (var charCode in encoding) {
31003 glyphId = glyphNames.indexOf(encoding[charCode]);
31004 if (glyphId >= 0) {
31005 builtInEncoding[charCode] = glyphId;
31006 }
31007 }
31008 }
31009
31010 return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
31011 },
31012
31013 getSeacs: function Type1Font_getSeacs(charstrings) {
31014 var i, ii;
31015 var seacMap = [];
31016 for (i = 0, ii = charstrings.length; i < ii; i++) {
31017 var charstring = charstrings[i];
31018 if (charstring.seac) {
31019 // Offset by 1 for .notdef
31020 seacMap[i + 1] = charstring.seac;
31021 }
31022 }
31023 return seacMap;
31024 },
31025
31026 getType2Charstrings: function Type1Font_getType2Charstrings(
31027 type1Charstrings) {
31028 var type2Charstrings = [];
31029 for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
31030 type2Charstrings.push(type1Charstrings[i].charstring);
31031 }
31032 return type2Charstrings;
31033 },
31034
31035 getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
31036 var bias = 0;
31037 var count = type1Subrs.length;
31038 if (count < 1133) {
31039 bias = 107;
31040 } else if (count < 33769) {
31041 bias = 1131;
31042 } else {
31043 bias = 32768;
31044 }
31045
31046 // Add a bunch of empty subrs to deal with the Type2 bias
31047 var type2Subrs = [];
31048 var i;
31049 for (i = 0; i < bias; i++) {
31050 type2Subrs.push([0x0B]);
31051 }
31052
31053 for (i = 0; i < count; i++) {
31054 type2Subrs.push(type1Subrs[i]);
31055 }
31056
31057 return type2Subrs;
31058 },
31059
31060 wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs,
31061 properties) {
31062 var cff = new CFF();
31063 cff.header = new CFFHeader(1, 0, 4, 4);
31064
31065 cff.names = [name];
31066
31067 var topDict = new CFFTopDict();
31068 // CFF strings IDs 0...390 are predefined names, so refering
31069 // to entries in our own String INDEX starts at SID 391.
31070 topDict.setByName('version', 391);
31071 topDict.setByName('Notice', 392);
31072 topDict.setByName('FullName', 393);
31073 topDict.setByName('FamilyName', 394);
31074 topDict.setByName('Weight', 395);
31075 topDict.setByName('Encoding', null); // placeholder
31076 topDict.setByName('FontMatrix', properties.fontMatrix);
31077 topDict.setByName('FontBBox', properties.bbox);
31078 topDict.setByName('charset', null); // placeholder
31079 topDict.setByName('CharStrings', null); // placeholder
31080 topDict.setByName('Private', null); // placeholder
31081 cff.topDict = topDict;
31082
31083 var strings = new CFFStrings();
31084 strings.add('Version 0.11'); // Version
31085 strings.add('See original notice'); // Notice
31086 strings.add(name); // FullName
31087 strings.add(name); // FamilyName
31088 strings.add('Medium'); // Weight
31089 cff.strings = strings;
31090
31091 cff.globalSubrIndex = new CFFIndex();
31092
31093 var count = glyphs.length;
31094 var charsetArray = [0];
31095 var i, ii;
31096 for (i = 0; i < count; i++) {
31097 var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
31098 // TODO: Insert the string and correctly map it. Previously it was
31099 // thought mapping names that aren't in the standard strings to .notdef
31100 // was fine, however in issue818 when mapping them all to .notdef the
31101 // adieresis glyph no longer worked.
31102 if (index === -1) {
31103 index = 0;
31104 }
31105 charsetArray.push((index >> 8) & 0xff, index & 0xff);
31106 }
31107 cff.charset = new CFFCharset(false, 0, [], charsetArray);
31108
31109 var charStringsIndex = new CFFIndex();
31110 charStringsIndex.add([0x8B, 0x0E]); // .notdef
31111 for (i = 0; i < count; i++) {
31112 var glyph = glyphs[i];
31113 // If the CharString outline is empty, replace it with .notdef to
31114 // prevent OTS from rejecting the font (fixes bug1252420.pdf).
31115 if (glyph.length === 0) {
31116 charStringsIndex.add([0x8B, 0x0E]); // .notdef
31117 continue;
31118 }
31119 charStringsIndex.add(glyph);
31120 }
31121 cff.charStrings = charStringsIndex;
31122
31123 var privateDict = new CFFPrivateDict();
31124 privateDict.setByName('Subrs', null); // placeholder
31125 var fields = [
31126 'BlueValues',
31127 'OtherBlues',
31128 'FamilyBlues',
31129 'FamilyOtherBlues',
31130 'StemSnapH',
31131 'StemSnapV',
31132 'BlueShift',
31133 'BlueFuzz',
31134 'BlueScale',
31135 'LanguageGroup',
31136 'ExpansionFactor',
31137 'ForceBold',
31138 'StdHW',
31139 'StdVW'
31140 ];
31141 for (i = 0, ii = fields.length; i < ii; i++) {
31142 var field = fields[i];
31143 if (!(field in properties.privateData)) {
31144 continue;
31145 }
31146 var value = properties.privateData[field];
31147 if (isArray(value)) {
31148 // All of the private dictionary array data in CFF must be stored as
31149 // "delta-encoded" numbers.
31150 for (var j = value.length - 1; j > 0; j--) {
31151 value[j] -= value[j - 1]; // ... difference from previous value
31152 }
31153 }
31154 privateDict.setByName(field, value);
31155 }
31156 cff.topDict.privateDict = privateDict;
31157
31158 var subrIndex = new CFFIndex();
31159 for (i = 0, ii = subrs.length; i < ii; i++) {
31160 subrIndex.add(subrs[i]);
31161 }
31162 privateDict.subrsIndex = subrIndex;
31163
31164 var compiler = new CFFCompiler(cff);
31165 return compiler.compile();
31166 }
31167 };
31168
31169 return Type1Font;
31170})();
31171
31172var CFFFont = (function CFFFontClosure() {
31173 function CFFFont(file, properties) {
31174 this.properties = properties;
31175
31176 var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
31177 this.cff = parser.parse();
31178 var compiler = new CFFCompiler(this.cff);
31179 this.seacs = this.cff.seacs;
31180 try {
31181 this.data = compiler.compile();
31182 } catch (e) {
31183 warn('Failed to compile font ' + properties.loadedName);
31184 // There may have just been an issue with the compiler, set the data
31185 // anyway and hope the font loaded.
31186 this.data = file;
31187 }
31188 }
31189
31190 CFFFont.prototype = {
31191 get numGlyphs() {
31192 return this.cff.charStrings.count;
31193 },
31194 getCharset: function CFFFont_getCharset() {
31195 return this.cff.charset.charset;
31196 },
31197 getGlyphMapping: function CFFFont_getGlyphMapping() {
31198 var cff = this.cff;
31199 var properties = this.properties;
31200 var charsets = cff.charset.charset;
31201 var charCodeToGlyphId;
31202 var glyphId;
31203
31204 if (properties.composite) {
31205 charCodeToGlyphId = Object.create(null);
31206 if (cff.isCIDFont) {
31207 // If the font is actually a CID font then we should use the charset
31208 // to map CIDs to GIDs.
31209 for (glyphId = 0; glyphId < charsets.length; glyphId++) {
31210 var cid = charsets[glyphId];
31211 var charCode = properties.cMap.charCodeOf(cid);
31212 charCodeToGlyphId[charCode] = glyphId;
31213 }
31214 } else {
31215 // If it is NOT actually a CID font then CIDs should be mapped
31216 // directly to GIDs.
31217 for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
31218 charCodeToGlyphId[glyphId] = glyphId;
31219 }
31220 }
31221 return charCodeToGlyphId;
31222 }
31223
31224 var encoding = cff.encoding ? cff.encoding.encoding : null;
31225 charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
31226 return charCodeToGlyphId;
31227 }
31228 };
31229
31230 return CFFFont;
31231})();
31232
31233// Workaround for seac on Windows.
31234(function checkSeacSupport() {
31235 if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
31236 SEAC_ANALYSIS_ENABLED = true;
31237 }
31238})();
31239
31240// Workaround for Private Use Area characters in Chrome on Windows
31241// http://code.google.com/p/chromium/issues/detail?id=122465
31242// https://github.com/mozilla/pdf.js/issues/1689
31243(function checkChromeWindows() {
31244 if (typeof navigator !== 'undefined' &&
31245 /Windows.*Chrome/.test(navigator.userAgent)) {
31246 SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
31247 }
31248})();
31249
31250exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
31251exports.ErrorFont = ErrorFont;
31252exports.Font = Font;
31253exports.FontFlags = FontFlags;
31254exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
31255exports.ToUnicodeMap = ToUnicodeMap;
31256exports.getFontType = getFontType;
31257}));
31258
31259
31260(function (root, factory) {
31261 {
31262 factory((root.pdfjsCorePsParser = {}), root.pdfjsSharedUtil,
31263 root.pdfjsCoreParser);
31264 }
31265}(this, function (exports, sharedUtil, coreParser) {
31266
31267var error = sharedUtil.error;
31268var isSpace = sharedUtil.isSpace;
31269var EOF = coreParser.EOF;
31270
31271var PostScriptParser = (function PostScriptParserClosure() {
31272 function PostScriptParser(lexer) {
31273 this.lexer = lexer;
31274 this.operators = [];
31275 this.token = null;
31276 this.prev = null;
31277 }
31278 PostScriptParser.prototype = {
31279 nextToken: function PostScriptParser_nextToken() {
31280 this.prev = this.token;
31281 this.token = this.lexer.getToken();
31282 },
31283 accept: function PostScriptParser_accept(type) {
31284 if (this.token.type === type) {
31285 this.nextToken();
31286 return true;
31287 }
31288 return false;
31289 },
31290 expect: function PostScriptParser_expect(type) {
31291 if (this.accept(type)) {
31292 return true;
31293 }
31294 error('Unexpected symbol: found ' + this.token.type + ' expected ' +
31295 type + '.');
31296 },
31297 parse: function PostScriptParser_parse() {
31298 this.nextToken();
31299 this.expect(PostScriptTokenTypes.LBRACE);
31300 this.parseBlock();
31301 this.expect(PostScriptTokenTypes.RBRACE);
31302 return this.operators;
31303 },
31304 parseBlock: function PostScriptParser_parseBlock() {
31305 while (true) {
31306 if (this.accept(PostScriptTokenTypes.NUMBER)) {
31307 this.operators.push(this.prev.value);
31308 } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
31309 this.operators.push(this.prev.value);
31310 } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
31311 this.parseCondition();
31312 } else {
31313 return;
31314 }
31315 }
31316 },
31317 parseCondition: function PostScriptParser_parseCondition() {
31318 // Add two place holders that will be updated later
31319 var conditionLocation = this.operators.length;
31320 this.operators.push(null, null);
31321
31322 this.parseBlock();
31323 this.expect(PostScriptTokenTypes.RBRACE);
31324 if (this.accept(PostScriptTokenTypes.IF)) {
31325 // The true block is right after the 'if' so it just falls through on
31326 // true else it jumps and skips the true block.
31327 this.operators[conditionLocation] = this.operators.length;
31328 this.operators[conditionLocation + 1] = 'jz';
31329 } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
31330 var jumpLocation = this.operators.length;
31331 this.operators.push(null, null);
31332 var endOfTrue = this.operators.length;
31333 this.parseBlock();
31334 this.expect(PostScriptTokenTypes.RBRACE);
31335 this.expect(PostScriptTokenTypes.IFELSE);
31336 // The jump is added at the end of the true block to skip the false
31337 // block.
31338 this.operators[jumpLocation] = this.operators.length;
31339 this.operators[jumpLocation + 1] = 'j';
31340
31341 this.operators[conditionLocation] = endOfTrue;
31342 this.operators[conditionLocation + 1] = 'jz';
31343 } else {
31344 error('PS Function: error parsing conditional.');
31345 }
31346 }
31347 };
31348 return PostScriptParser;
31349})();
31350
31351var PostScriptTokenTypes = {
31352 LBRACE: 0,
31353 RBRACE: 1,
31354 NUMBER: 2,
31355 OPERATOR: 3,
31356 IF: 4,
31357 IFELSE: 5
31358};
31359
31360var PostScriptToken = (function PostScriptTokenClosure() {
31361 function PostScriptToken(type, value) {
31362 this.type = type;
31363 this.value = value;
31364 }
31365
31366 var opCache = Object.create(null);
31367
31368 PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
31369 var opValue = opCache[op];
31370 if (opValue) {
31371 return opValue;
31372 }
31373 return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
31374 };
31375
31376 PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE,
31377 '{');
31378 PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE,
31379 '}');
31380 PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
31381 PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE,
31382 'IFELSE');
31383 return PostScriptToken;
31384})();
31385
31386var PostScriptLexer = (function PostScriptLexerClosure() {
31387 function PostScriptLexer(stream) {
31388 this.stream = stream;
31389 this.nextChar();
31390
31391 this.strBuf = [];
31392 }
31393 PostScriptLexer.prototype = {
31394 nextChar: function PostScriptLexer_nextChar() {
31395 return (this.currentChar = this.stream.getByte());
31396 },
31397 getToken: function PostScriptLexer_getToken() {
31398 var comment = false;
31399 var ch = this.currentChar;
31400
31401 // skip comments
31402 while (true) {
31403 if (ch < 0) {
31404 return EOF;
31405 }
31406
31407 if (comment) {
31408 if (ch === 0x0A || ch === 0x0D) {
31409 comment = false;
31410 }
31411 } else if (ch === 0x25) { // '%'
31412 comment = true;
31413 } else if (!isSpace(ch)) {
31414 break;
31415 }
31416 ch = this.nextChar();
31417 }
31418 switch (ch | 0) {
31419 case 0x30: case 0x31: case 0x32: case 0x33: case 0x34: // '0'-'4'
31420 case 0x35: case 0x36: case 0x37: case 0x38: case 0x39: // '5'-'9'
31421 case 0x2B: case 0x2D: case 0x2E: // '+', '-', '.'
31422 return new PostScriptToken(PostScriptTokenTypes.NUMBER,
31423 this.getNumber());
31424 case 0x7B: // '{'
31425 this.nextChar();
31426 return PostScriptToken.LBRACE;
31427 case 0x7D: // '}'
31428 this.nextChar();
31429 return PostScriptToken.RBRACE;
31430 }
31431 // operator
31432 var strBuf = this.strBuf;
31433 strBuf.length = 0;
31434 strBuf[0] = String.fromCharCode(ch);
31435
31436 while ((ch = this.nextChar()) >= 0 && // and 'A'-'Z', 'a'-'z'
31437 ((ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A))) {
31438 strBuf.push(String.fromCharCode(ch));
31439 }
31440 var str = strBuf.join('');
31441 switch (str.toLowerCase()) {
31442 case 'if':
31443 return PostScriptToken.IF;
31444 case 'ifelse':
31445 return PostScriptToken.IFELSE;
31446 default:
31447 return PostScriptToken.getOperator(str);
31448 }
31449 },
31450 getNumber: function PostScriptLexer_getNumber() {
31451 var ch = this.currentChar;
31452 var strBuf = this.strBuf;
31453 strBuf.length = 0;
31454 strBuf[0] = String.fromCharCode(ch);
31455
31456 while ((ch = this.nextChar()) >= 0) {
31457 if ((ch >= 0x30 && ch <= 0x39) || // '0'-'9'
31458 ch === 0x2D || ch === 0x2E) { // '-', '.'
31459 strBuf.push(String.fromCharCode(ch));
31460 } else {
31461 break;
31462 }
31463 }
31464 var value = parseFloat(strBuf.join(''));
31465 if (isNaN(value)) {
31466 error('Invalid floating point number: ' + value);
31467 }
31468 return value;
31469 }
31470 };
31471 return PostScriptLexer;
31472})();
31473
31474exports.PostScriptLexer = PostScriptLexer;
31475exports.PostScriptParser = PostScriptParser;
31476}));
31477
31478
31479(function (root, factory) {
31480 {
31481 factory((root.pdfjsCoreFunction = {}), root.pdfjsSharedUtil,
31482 root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
31483 }
31484}(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
31485
31486var error = sharedUtil.error;
31487var info = sharedUtil.info;
31488var isArray = sharedUtil.isArray;
31489var isBool = sharedUtil.isBool;
31490var isDict = corePrimitives.isDict;
31491var isStream = corePrimitives.isStream;
31492var PostScriptLexer = corePsParser.PostScriptLexer;
31493var PostScriptParser = corePsParser.PostScriptParser;
31494
31495var PDFFunction = (function PDFFunctionClosure() {
31496 var CONSTRUCT_SAMPLED = 0;
31497 var CONSTRUCT_INTERPOLATED = 2;
31498 var CONSTRUCT_STICHED = 3;
31499 var CONSTRUCT_POSTSCRIPT = 4;
31500
31501 return {
31502 getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps,
31503 str) {
31504 var i, ii;
31505 var length = 1;
31506 for (i = 0, ii = size.length; i < ii; i++) {
31507 length *= size[i];
31508 }
31509 length *= outputSize;
31510
31511 var array = new Array(length);
31512 var codeSize = 0;
31513 var codeBuf = 0;
31514 // 32 is a valid bps so shifting won't work
31515 var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
31516
31517 var strBytes = str.getBytes((length * bps + 7) / 8);
31518 var strIdx = 0;
31519 for (i = 0; i < length; i++) {
31520 while (codeSize < bps) {
31521 codeBuf <<= 8;
31522 codeBuf |= strBytes[strIdx++];
31523 codeSize += 8;
31524 }
31525 codeSize -= bps;
31526 array[i] = (codeBuf >> codeSize) * sampleMul;
31527 codeBuf &= (1 << codeSize) - 1;
31528 }
31529 return array;
31530 },
31531
31532 getIR: function PDFFunction_getIR(xref, fn) {
31533 var dict = fn.dict;
31534 if (!dict) {
31535 dict = fn;
31536 }
31537
31538 var types = [this.constructSampled,
31539 null,
31540 this.constructInterpolated,
31541 this.constructStiched,
31542 this.constructPostScript];
31543
31544 var typeNum = dict.get('FunctionType');
31545 var typeFn = types[typeNum];
31546 if (!typeFn) {
31547 error('Unknown type of function');
31548 }
31549
31550 return typeFn.call(this, fn, dict, xref);
31551 },
31552
31553 fromIR: function PDFFunction_fromIR(IR) {
31554 var type = IR[0];
31555 switch (type) {
31556 case CONSTRUCT_SAMPLED:
31557 return this.constructSampledFromIR(IR);
31558 case CONSTRUCT_INTERPOLATED:
31559 return this.constructInterpolatedFromIR(IR);
31560 case CONSTRUCT_STICHED:
31561 return this.constructStichedFromIR(IR);
31562 //case CONSTRUCT_POSTSCRIPT:
31563 default:
31564 return this.constructPostScriptFromIR(IR);
31565 }
31566 },
31567
31568 parse: function PDFFunction_parse(xref, fn) {
31569 var IR = this.getIR(xref, fn);
31570 return this.fromIR(IR);
31571 },
31572
31573 parseArray: function PDFFunction_parseArray(xref, fnObj) {
31574 if (!isArray(fnObj)) {
31575 // not an array -- parsing as regular function
31576 return this.parse(xref, fnObj);
31577 }
31578
31579 var fnArray = [];
31580 for (var j = 0, jj = fnObj.length; j < jj; j++) {
31581 var obj = xref.fetchIfRef(fnObj[j]);
31582 fnArray.push(PDFFunction.parse(xref, obj));
31583 }
31584 return function (src, srcOffset, dest, destOffset) {
31585 for (var i = 0, ii = fnArray.length; i < ii; i++) {
31586 fnArray[i](src, srcOffset, dest, destOffset + i);
31587 }
31588 };
31589 },
31590
31591 constructSampled: function PDFFunction_constructSampled(str, dict) {
31592 function toMultiArray(arr) {
31593 var inputLength = arr.length;
31594 var out = [];
31595 var index = 0;
31596 for (var i = 0; i < inputLength; i += 2) {
31597 out[index] = [arr[i], arr[i + 1]];
31598 ++index;
31599 }
31600 return out;
31601 }
31602 var domain = dict.getArray('Domain');
31603 var range = dict.getArray('Range');
31604
31605 if (!domain || !range) {
31606 error('No domain or range');
31607 }
31608
31609 var inputSize = domain.length / 2;
31610 var outputSize = range.length / 2;
31611
31612 domain = toMultiArray(domain);
31613 range = toMultiArray(range);
31614
31615 var size = dict.get('Size');
31616 var bps = dict.get('BitsPerSample');
31617 var order = dict.get('Order') || 1;
31618 if (order !== 1) {
31619 // No description how cubic spline interpolation works in PDF32000:2008
31620 // As in poppler, ignoring order, linear interpolation may work as good
31621 info('No support for cubic spline interpolation: ' + order);
31622 }
31623
31624 var encode = dict.getArray('Encode');
31625 if (!encode) {
31626 encode = [];
31627 for (var i = 0; i < inputSize; ++i) {
31628 encode.push(0);
31629 encode.push(size[i] - 1);
31630 }
31631 }
31632 encode = toMultiArray(encode);
31633
31634 var decode = dict.getArray('Decode');
31635 if (!decode) {
31636 decode = range;
31637 } else {
31638 decode = toMultiArray(decode);
31639 }
31640
31641 var samples = this.getSampleArray(size, outputSize, bps, str);
31642
31643 return [
31644 CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size,
31645 outputSize, Math.pow(2, bps) - 1, range
31646 ];
31647 },
31648
31649 constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
31650 // See chapter 3, page 109 of the PDF reference
31651 function interpolate(x, xmin, xmax, ymin, ymax) {
31652 return ymin + ((x - xmin) * ((ymax - ymin) / (xmax - xmin)));
31653 }
31654
31655 return function constructSampledFromIRResult(src, srcOffset,
31656 dest, destOffset) {
31657 // See chapter 3, page 110 of the PDF reference.
31658 var m = IR[1];
31659 var domain = IR[2];
31660 var encode = IR[3];
31661 var decode = IR[4];
31662 var samples = IR[5];
31663 var size = IR[6];
31664 var n = IR[7];
31665 //var mask = IR[8];
31666 var range = IR[9];
31667
31668 // Building the cube vertices: its part and sample index
31669 // http://rjwagner49.com/Mathematics/Interpolation.pdf
31670 var cubeVertices = 1 << m;
31671 var cubeN = new Float64Array(cubeVertices);
31672 var cubeVertex = new Uint32Array(cubeVertices);
31673 var i, j;
31674 for (j = 0; j < cubeVertices; j++) {
31675 cubeN[j] = 1;
31676 }
31677
31678 var k = n, pos = 1;
31679 // Map x_i to y_j for 0 <= i < m using the sampled function.
31680 for (i = 0; i < m; ++i) {
31681 // x_i' = min(max(x_i, Domain_2i), Domain_2i+1)
31682 var domain_2i = domain[i][0];
31683 var domain_2i_1 = domain[i][1];
31684 var xi = Math.min(Math.max(src[srcOffset +i], domain_2i),
31685 domain_2i_1);
31686
31687 // e_i = Interpolate(x_i', Domain_2i, Domain_2i+1,
31688 // Encode_2i, Encode_2i+1)
31689 var e = interpolate(xi, domain_2i, domain_2i_1,
31690 encode[i][0], encode[i][1]);
31691
31692 // e_i' = min(max(e_i, 0), Size_i - 1)
31693 var size_i = size[i];
31694 e = Math.min(Math.max(e, 0), size_i - 1);
31695
31696 // Adjusting the cube: N and vertex sample index
31697 var e0 = e < size_i - 1 ? Math.floor(e) : e - 1; // e1 = e0 + 1;
31698 var n0 = e0 + 1 - e; // (e1 - e) / (e1 - e0);
31699 var n1 = e - e0; // (e - e0) / (e1 - e0);
31700 var offset0 = e0 * k;
31701 var offset1 = offset0 + k; // e1 * k
31702 for (j = 0; j < cubeVertices; j++) {
31703 if (j & pos) {
31704 cubeN[j] *= n1;
31705 cubeVertex[j] += offset1;
31706 } else {
31707 cubeN[j] *= n0;
31708 cubeVertex[j] += offset0;
31709 }
31710 }
31711
31712 k *= size_i;
31713 pos <<= 1;
31714 }
31715
31716 for (j = 0; j < n; ++j) {
31717 // Sum all cube vertices' samples portions
31718 var rj = 0;
31719 for (i = 0; i < cubeVertices; i++) {
31720 rj += samples[cubeVertex[i] + j] * cubeN[i];
31721 }
31722
31723 // r_j' = Interpolate(r_j, 0, 2^BitsPerSample - 1,
31724 // Decode_2j, Decode_2j+1)
31725 rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
31726
31727 // y_j = min(max(r_j, range_2j), range_2j+1)
31728 dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]),
31729 range[j][1]);
31730 }
31731 };
31732 },
31733
31734 constructInterpolated: function PDFFunction_constructInterpolated(str,
31735 dict) {
31736 var c0 = dict.getArray('C0') || [0];
31737 var c1 = dict.getArray('C1') || [1];
31738 var n = dict.get('N');
31739
31740 if (!isArray(c0) || !isArray(c1)) {
31741 error('Illegal dictionary for interpolated function');
31742 }
31743
31744 var length = c0.length;
31745 var diff = [];
31746 for (var i = 0; i < length; ++i) {
31747 diff.push(c1[i] - c0[i]);
31748 }
31749
31750 return [CONSTRUCT_INTERPOLATED, c0, diff, n];
31751 },
31752
31753 constructInterpolatedFromIR:
31754 function PDFFunction_constructInterpolatedFromIR(IR) {
31755 var c0 = IR[1];
31756 var diff = IR[2];
31757 var n = IR[3];
31758
31759 var length = diff.length;
31760
31761 return function constructInterpolatedFromIRResult(src, srcOffset,
31762 dest, destOffset) {
31763 var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
31764
31765 for (var j = 0; j < length; ++j) {
31766 dest[destOffset + j] = c0[j] + (x * diff[j]);
31767 }
31768 };
31769 },
31770
31771 constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
31772 var domain = dict.getArray('Domain');
31773
31774 if (!domain) {
31775 error('No domain');
31776 }
31777
31778 var inputSize = domain.length / 2;
31779 if (inputSize !== 1) {
31780 error('Bad domain for stiched function');
31781 }
31782
31783 var fnRefs = dict.get('Functions');
31784 var fns = [];
31785 for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
31786 fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
31787 }
31788
31789 var bounds = dict.getArray('Bounds');
31790 var encode = dict.getArray('Encode');
31791
31792 return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
31793 },
31794
31795 constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
31796 var domain = IR[1];
31797 var bounds = IR[2];
31798 var encode = IR[3];
31799 var fnsIR = IR[4];
31800 var fns = [];
31801 var tmpBuf = new Float32Array(1);
31802
31803 for (var i = 0, ii = fnsIR.length; i < ii; i++) {
31804 fns.push(PDFFunction.fromIR(fnsIR[i]));
31805 }
31806
31807 return function constructStichedFromIRResult(src, srcOffset,
31808 dest, destOffset) {
31809 var clip = function constructStichedFromIRClip(v, min, max) {
31810 if (v > max) {
31811 v = max;
31812 } else if (v < min) {
31813 v = min;
31814 }
31815 return v;
31816 };
31817
31818 // clip to domain
31819 var v = clip(src[srcOffset], domain[0], domain[1]);
31820 // calculate which bound the value is in
31821 for (var i = 0, ii = bounds.length; i < ii; ++i) {
31822 if (v < bounds[i]) {
31823 break;
31824 }
31825 }
31826
31827 // encode value into domain of function
31828 var dmin = domain[0];
31829 if (i > 0) {
31830 dmin = bounds[i - 1];
31831 }
31832 var dmax = domain[1];
31833 if (i < bounds.length) {
31834 dmax = bounds[i];
31835 }
31836
31837 var rmin = encode[2 * i];
31838 var rmax = encode[2 * i + 1];
31839
31840 // Prevent the value from becoming NaN as a result
31841 // of division by zero (fixes issue6113.pdf).
31842 tmpBuf[0] = dmin === dmax ? rmin :
31843 rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
31844
31845 // call the appropriate function
31846 fns[i](tmpBuf, 0, dest, destOffset);
31847 };
31848 },
31849
31850 constructPostScript: function PDFFunction_constructPostScript(fn, dict,
31851 xref) {
31852 var domain = dict.getArray('Domain');
31853 var range = dict.getArray('Range');
31854
31855 if (!domain) {
31856 error('No domain.');
31857 }
31858
31859 if (!range) {
31860 error('No range.');
31861 }
31862
31863 var lexer = new PostScriptLexer(fn);
31864 var parser = new PostScriptParser(lexer);
31865 var code = parser.parse();
31866
31867 return [CONSTRUCT_POSTSCRIPT, domain, range, code];
31868 },
31869
31870 constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(
31871 IR) {
31872 var domain = IR[1];
31873 var range = IR[2];
31874 var code = IR[3];
31875
31876 var compiled = (new PostScriptCompiler()).compile(code, domain, range);
31877 if (compiled) {
31878 // Compiled function consists of simple expressions such as addition,
31879 // subtraction, Math.max, and also contains 'var' and 'return'
31880 // statements. See the generation in the PostScriptCompiler below.
31881 /*jshint -W054 */
31882 return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
31883 }
31884
31885 info('Unable to compile PS function');
31886
31887 var numOutputs = range.length >> 1;
31888 var numInputs = domain.length >> 1;
31889 var evaluator = new PostScriptEvaluator(code);
31890 // Cache the values for a big speed up, the cache size is limited though
31891 // since the number of possible values can be huge from a PS function.
31892 var cache = Object.create(null);
31893 // The MAX_CACHE_SIZE is set to ~4x the maximum number of distinct values
31894 // seen in our tests.
31895 var MAX_CACHE_SIZE = 2048 * 4;
31896 var cache_available = MAX_CACHE_SIZE;
31897 var tmpBuf = new Float32Array(numInputs);
31898
31899 return function constructPostScriptFromIRResult(src, srcOffset,
31900 dest, destOffset) {
31901 var i, value;
31902 var key = '';
31903 var input = tmpBuf;
31904 for (i = 0; i < numInputs; i++) {
31905 value = src[srcOffset + i];
31906 input[i] = value;
31907 key += value + '_';
31908 }
31909
31910 var cachedValue = cache[key];
31911 if (cachedValue !== undefined) {
31912 dest.set(cachedValue, destOffset);
31913 return;
31914 }
31915
31916 var output = new Float32Array(numOutputs);
31917 var stack = evaluator.execute(input);
31918 var stackIndex = stack.length - numOutputs;
31919 for (i = 0; i < numOutputs; i++) {
31920 value = stack[stackIndex + i];
31921 var bound = range[i * 2];
31922 if (value < bound) {
31923 value = bound;
31924 } else {
31925 bound = range[i * 2 +1];
31926 if (value > bound) {
31927 value = bound;
31928 }
31929 }
31930 output[i] = value;
31931 }
31932 if (cache_available > 0) {
31933 cache_available--;
31934 cache[key] = output;
31935 }
31936 dest.set(output, destOffset);
31937 };
31938 }
31939 };
31940})();
31941
31942function isPDFFunction(v) {
31943 var fnDict;
31944 if (typeof v !== 'object') {
31945 return false;
31946 } else if (isDict(v)) {
31947 fnDict = v;
31948 } else if (isStream(v)) {
31949 fnDict = v.dict;
31950 } else {
31951 return false;
31952 }
31953 return fnDict.has('FunctionType');
31954}
31955
31956var PostScriptStack = (function PostScriptStackClosure() {
31957 var MAX_STACK_SIZE = 100;
31958 function PostScriptStack(initialStack) {
31959 this.stack = !initialStack ? [] :
31960 Array.prototype.slice.call(initialStack, 0);
31961 }
31962
31963 PostScriptStack.prototype = {
31964 push: function PostScriptStack_push(value) {
31965 if (this.stack.length >= MAX_STACK_SIZE) {
31966 error('PostScript function stack overflow.');
31967 }
31968 this.stack.push(value);
31969 },
31970 pop: function PostScriptStack_pop() {
31971 if (this.stack.length <= 0) {
31972 error('PostScript function stack underflow.');
31973 }
31974 return this.stack.pop();
31975 },
31976 copy: function PostScriptStack_copy(n) {
31977 if (this.stack.length + n >= MAX_STACK_SIZE) {
31978 error('PostScript function stack overflow.');
31979 }
31980 var stack = this.stack;
31981 for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
31982 stack.push(stack[i]);
31983 }
31984 },
31985 index: function PostScriptStack_index(n) {
31986 this.push(this.stack[this.stack.length - n - 1]);
31987 },
31988 // rotate the last n stack elements p times
31989 roll: function PostScriptStack_roll(n, p) {
31990 var stack = this.stack;
31991 var l = stack.length - n;
31992 var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
31993 for (i = l, j = r; i < j; i++, j--) {
31994 t = stack[i]; stack[i] = stack[j]; stack[j] = t;
31995 }
31996 for (i = l, j = c - 1; i < j; i++, j--) {
31997 t = stack[i]; stack[i] = stack[j]; stack[j] = t;
31998 }
31999 for (i = c, j = r; i < j; i++, j--) {
32000 t = stack[i]; stack[i] = stack[j]; stack[j] = t;
32001 }
32002 }
32003 };
32004 return PostScriptStack;
32005})();
32006var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
32007 function PostScriptEvaluator(operators) {
32008 this.operators = operators;
32009 }
32010 PostScriptEvaluator.prototype = {
32011 execute: function PostScriptEvaluator_execute(initialStack) {
32012 var stack = new PostScriptStack(initialStack);
32013 var counter = 0;
32014 var operators = this.operators;
32015 var length = operators.length;
32016 var operator, a, b;
32017 while (counter < length) {
32018 operator = operators[counter++];
32019 if (typeof operator === 'number') {
32020 // Operator is really an operand and should be pushed to the stack.
32021 stack.push(operator);
32022 continue;
32023 }
32024 switch (operator) {
32025 // non standard ps operators
32026 case 'jz': // jump if false
32027 b = stack.pop();
32028 a = stack.pop();
32029 if (!a) {
32030 counter = b;
32031 }
32032 break;
32033 case 'j': // jump
32034 a = stack.pop();
32035 counter = a;
32036 break;
32037
32038 // all ps operators in alphabetical order (excluding if/ifelse)
32039 case 'abs':
32040 a = stack.pop();
32041 stack.push(Math.abs(a));
32042 break;
32043 case 'add':
32044 b = stack.pop();
32045 a = stack.pop();
32046 stack.push(a + b);
32047 break;
32048 case 'and':
32049 b = stack.pop();
32050 a = stack.pop();
32051 if (isBool(a) && isBool(b)) {
32052 stack.push(a && b);
32053 } else {
32054 stack.push(a & b);
32055 }
32056 break;
32057 case 'atan':
32058 a = stack.pop();
32059 stack.push(Math.atan(a));
32060 break;
32061 case 'bitshift':
32062 b = stack.pop();
32063 a = stack.pop();
32064 if (a > 0) {
32065 stack.push(a << b);
32066 } else {
32067 stack.push(a >> b);
32068 }
32069 break;
32070 case 'ceiling':
32071 a = stack.pop();
32072 stack.push(Math.ceil(a));
32073 break;
32074 case 'copy':
32075 a = stack.pop();
32076 stack.copy(a);
32077 break;
32078 case 'cos':
32079 a = stack.pop();
32080 stack.push(Math.cos(a));
32081 break;
32082 case 'cvi':
32083 a = stack.pop() | 0;
32084 stack.push(a);
32085 break;
32086 case 'cvr':
32087 // noop
32088 break;
32089 case 'div':
32090 b = stack.pop();
32091 a = stack.pop();
32092 stack.push(a / b);
32093 break;
32094 case 'dup':
32095 stack.copy(1);
32096 break;
32097 case 'eq':
32098 b = stack.pop();
32099 a = stack.pop();
32100 stack.push(a === b);
32101 break;
32102 case 'exch':
32103 stack.roll(2, 1);
32104 break;
32105 case 'exp':
32106 b = stack.pop();
32107 a = stack.pop();
32108 stack.push(Math.pow(a, b));
32109 break;
32110 case 'false':
32111 stack.push(false);
32112 break;
32113 case 'floor':
32114 a = stack.pop();
32115 stack.push(Math.floor(a));
32116 break;
32117 case 'ge':
32118 b = stack.pop();
32119 a = stack.pop();
32120 stack.push(a >= b);
32121 break;
32122 case 'gt':
32123 b = stack.pop();
32124 a = stack.pop();
32125 stack.push(a > b);
32126 break;
32127 case 'idiv':
32128 b = stack.pop();
32129 a = stack.pop();
32130 stack.push((a / b) | 0);
32131 break;
32132 case 'index':
32133 a = stack.pop();
32134 stack.index(a);
32135 break;
32136 case 'le':
32137 b = stack.pop();
32138 a = stack.pop();
32139 stack.push(a <= b);
32140 break;
32141 case 'ln':
32142 a = stack.pop();
32143 stack.push(Math.log(a));
32144 break;
32145 case 'log':
32146 a = stack.pop();
32147 stack.push(Math.log(a) / Math.LN10);
32148 break;
32149 case 'lt':
32150 b = stack.pop();
32151 a = stack.pop();
32152 stack.push(a < b);
32153 break;
32154 case 'mod':
32155 b = stack.pop();
32156 a = stack.pop();
32157 stack.push(a % b);
32158 break;
32159 case 'mul':
32160 b = stack.pop();
32161 a = stack.pop();
32162 stack.push(a * b);
32163 break;
32164 case 'ne':
32165 b = stack.pop();
32166 a = stack.pop();
32167 stack.push(a !== b);
32168 break;
32169 case 'neg':
32170 a = stack.pop();
32171 stack.push(-a);
32172 break;
32173 case 'not':
32174 a = stack.pop();
32175 if (isBool(a)) {
32176 stack.push(!a);
32177 } else {
32178 stack.push(~a);
32179 }
32180 break;
32181 case 'or':
32182 b = stack.pop();
32183 a = stack.pop();
32184 if (isBool(a) && isBool(b)) {
32185 stack.push(a || b);
32186 } else {
32187 stack.push(a | b);
32188 }
32189 break;
32190 case 'pop':
32191 stack.pop();
32192 break;
32193 case 'roll':
32194 b = stack.pop();
32195 a = stack.pop();
32196 stack.roll(a, b);
32197 break;
32198 case 'round':
32199 a = stack.pop();
32200 stack.push(Math.round(a));
32201 break;
32202 case 'sin':
32203 a = stack.pop();
32204 stack.push(Math.sin(a));
32205 break;
32206 case 'sqrt':
32207 a = stack.pop();
32208 stack.push(Math.sqrt(a));
32209 break;
32210 case 'sub':
32211 b = stack.pop();
32212 a = stack.pop();
32213 stack.push(a - b);
32214 break;
32215 case 'true':
32216 stack.push(true);
32217 break;
32218 case 'truncate':
32219 a = stack.pop();
32220 a = a < 0 ? Math.ceil(a) : Math.floor(a);
32221 stack.push(a);
32222 break;
32223 case 'xor':
32224 b = stack.pop();
32225 a = stack.pop();
32226 if (isBool(a) && isBool(b)) {
32227 stack.push(a !== b);
32228 } else {
32229 stack.push(a ^ b);
32230 }
32231 break;
32232 default:
32233 error('Unknown operator ' + operator);
32234 break;
32235 }
32236 }
32237 return stack.stack;
32238 }
32239 };
32240 return PostScriptEvaluator;
32241})();
32242
32243// Most of the PDFs functions consist of simple operations such as:
32244// roll, exch, sub, cvr, pop, index, dup, mul, if, gt, add.
32245//
32246// We can compile most of such programs, and at the same moment, we can
32247// optimize some expressions using basic math properties. Keeping track of
32248// min/max values will allow us to avoid extra Math.min/Math.max calls.
32249var PostScriptCompiler = (function PostScriptCompilerClosure() {
32250 function AstNode(type) {
32251 this.type = type;
32252 }
32253 AstNode.prototype.visit = function (visitor) {
32254 throw new Error('abstract method');
32255 };
32256
32257 function AstArgument(index, min, max) {
32258 AstNode.call(this, 'args');
32259 this.index = index;
32260 this.min = min;
32261 this.max = max;
32262 }
32263 AstArgument.prototype = Object.create(AstNode.prototype);
32264 AstArgument.prototype.visit = function (visitor) {
32265 visitor.visitArgument(this);
32266 };
32267
32268 function AstLiteral(number) {
32269 AstNode.call(this, 'literal');
32270 this.number = number;
32271 this.min = number;
32272 this.max = number;
32273 }
32274 AstLiteral.prototype = Object.create(AstNode.prototype);
32275 AstLiteral.prototype.visit = function (visitor) {
32276 visitor.visitLiteral(this);
32277 };
32278
32279 function AstBinaryOperation(op, arg1, arg2, min, max) {
32280 AstNode.call(this, 'binary');
32281 this.op = op;
32282 this.arg1 = arg1;
32283 this.arg2 = arg2;
32284 this.min = min;
32285 this.max = max;
32286 }
32287 AstBinaryOperation.prototype = Object.create(AstNode.prototype);
32288 AstBinaryOperation.prototype.visit = function (visitor) {
32289 visitor.visitBinaryOperation(this);
32290 };
32291
32292 function AstMin(arg, max) {
32293 AstNode.call(this, 'max');
32294 this.arg = arg;
32295 this.min = arg.min;
32296 this.max = max;
32297 }
32298 AstMin.prototype = Object.create(AstNode.prototype);
32299 AstMin.prototype.visit = function (visitor) {
32300 visitor.visitMin(this);
32301 };
32302
32303 function AstVariable(index, min, max) {
32304 AstNode.call(this, 'var');
32305 this.index = index;
32306 this.min = min;
32307 this.max = max;
32308 }
32309 AstVariable.prototype = Object.create(AstNode.prototype);
32310 AstVariable.prototype.visit = function (visitor) {
32311 visitor.visitVariable(this);
32312 };
32313
32314 function AstVariableDefinition(variable, arg) {
32315 AstNode.call(this, 'definition');
32316 this.variable = variable;
32317 this.arg = arg;
32318 }
32319 AstVariableDefinition.prototype = Object.create(AstNode.prototype);
32320 AstVariableDefinition.prototype.visit = function (visitor) {
32321 visitor.visitVariableDefinition(this);
32322 };
32323
32324 function ExpressionBuilderVisitor() {
32325 this.parts = [];
32326 }
32327 ExpressionBuilderVisitor.prototype = {
32328 visitArgument: function (arg) {
32329 this.parts.push('Math.max(', arg.min, ', Math.min(',
32330 arg.max, ', src[srcOffset + ', arg.index, ']))');
32331 },
32332 visitVariable: function (variable) {
32333 this.parts.push('v', variable.index);
32334 },
32335 visitLiteral: function (literal) {
32336 this.parts.push(literal.number);
32337 },
32338 visitBinaryOperation: function (operation) {
32339 this.parts.push('(');
32340 operation.arg1.visit(this);
32341 this.parts.push(' ', operation.op, ' ');
32342 operation.arg2.visit(this);
32343 this.parts.push(')');
32344 },
32345 visitVariableDefinition: function (definition) {
32346 this.parts.push('var ');
32347 definition.variable.visit(this);
32348 this.parts.push(' = ');
32349 definition.arg.visit(this);
32350 this.parts.push(';');
32351 },
32352 visitMin: function (max) {
32353 this.parts.push('Math.min(');
32354 max.arg.visit(this);
32355 this.parts.push(', ', max.max, ')');
32356 },
32357 toString: function () {
32358 return this.parts.join('');
32359 }
32360 };
32361
32362 function buildAddOperation(num1, num2) {
32363 if (num2.type === 'literal' && num2.number === 0) {
32364 // optimization: second operand is 0
32365 return num1;
32366 }
32367 if (num1.type === 'literal' && num1.number === 0) {
32368 // optimization: first operand is 0
32369 return num2;
32370 }
32371 if (num2.type === 'literal' && num1.type === 'literal') {
32372 // optimization: operands operand are literals
32373 return new AstLiteral(num1.number + num2.number);
32374 }
32375 return new AstBinaryOperation('+', num1, num2,
32376 num1.min + num2.min, num1.max + num2.max);
32377 }
32378
32379 function buildMulOperation(num1, num2) {
32380 if (num2.type === 'literal') {
32381 // optimization: second operands is a literal...
32382 if (num2.number === 0) {
32383 return new AstLiteral(0); // and it's 0
32384 } else if (num2.number === 1) {
32385 return num1; // and it's 1
32386 } else if (num1.type === 'literal') {
32387 // ... and first operands is a literal too
32388 return new AstLiteral(num1.number * num2.number);
32389 }
32390 }
32391 if (num1.type === 'literal') {
32392 // optimization: first operands is a literal...
32393 if (num1.number === 0) {
32394 return new AstLiteral(0); // and it's 0
32395 } else if (num1.number === 1) {
32396 return num2; // and it's 1
32397 }
32398 }
32399 var min = Math.min(num1.min * num2.min, num1.min * num2.max,
32400 num1.max * num2.min, num1.max * num2.max);
32401 var max = Math.max(num1.min * num2.min, num1.min * num2.max,
32402 num1.max * num2.min, num1.max * num2.max);
32403 return new AstBinaryOperation('*', num1, num2, min, max);
32404 }
32405
32406 function buildSubOperation(num1, num2) {
32407 if (num2.type === 'literal') {
32408 // optimization: second operands is a literal...
32409 if (num2.number === 0) {
32410 return num1; // ... and it's 0
32411 } else if (num1.type === 'literal') {
32412 // ... and first operands is a literal too
32413 return new AstLiteral(num1.number - num2.number);
32414 }
32415 }
32416 if (num2.type === 'binary' && num2.op === '-' &&
32417 num1.type === 'literal' && num1.number === 1 &&
32418 num2.arg1.type === 'literal' && num2.arg1.number === 1) {
32419 // optimization for case: 1 - (1 - x)
32420 return num2.arg2;
32421 }
32422 return new AstBinaryOperation('-', num1, num2,
32423 num1.min - num2.max, num1.max - num2.min);
32424 }
32425
32426 function buildMinOperation(num1, max) {
32427 if (num1.min >= max) {
32428 // optimization: num1 min value is not less than required max
32429 return new AstLiteral(max); // just returning max
32430 } else if (num1.max <= max) {
32431 // optimization: num1 max value is not greater than required max
32432 return num1; // just returning an argument
32433 }
32434 return new AstMin(num1, max);
32435 }
32436
32437 function PostScriptCompiler() {}
32438 PostScriptCompiler.prototype = {
32439 compile: function PostScriptCompiler_compile(code, domain, range) {
32440 var stack = [];
32441 var i, ii;
32442 var instructions = [];
32443 var inputSize = domain.length >> 1, outputSize = range.length >> 1;
32444 var lastRegister = 0;
32445 var n, j;
32446 var num1, num2, ast1, ast2, tmpVar, item;
32447 for (i = 0; i < inputSize; i++) {
32448 stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
32449 }
32450
32451 for (i = 0, ii = code.length; i < ii; i++) {
32452 item = code[i];
32453 if (typeof item === 'number') {
32454 stack.push(new AstLiteral(item));
32455 continue;
32456 }
32457
32458 switch (item) {
32459 case 'add':
32460 if (stack.length < 2) {
32461 return null;
32462 }
32463 num2 = stack.pop();
32464 num1 = stack.pop();
32465 stack.push(buildAddOperation(num1, num2));
32466 break;
32467 case 'cvr':
32468 if (stack.length < 1) {
32469 return null;
32470 }
32471 break;
32472 case 'mul':
32473 if (stack.length < 2) {
32474 return null;
32475 }
32476 num2 = stack.pop();
32477 num1 = stack.pop();
32478 stack.push(buildMulOperation(num1, num2));
32479 break;
32480 case 'sub':
32481 if (stack.length < 2) {
32482 return null;
32483 }
32484 num2 = stack.pop();
32485 num1 = stack.pop();
32486 stack.push(buildSubOperation(num1, num2));
32487 break;
32488 case 'exch':
32489 if (stack.length < 2) {
32490 return null;
32491 }
32492 ast1 = stack.pop(); ast2 = stack.pop();
32493 stack.push(ast1, ast2);
32494 break;
32495 case 'pop':
32496 if (stack.length < 1) {
32497 return null;
32498 }
32499 stack.pop();
32500 break;
32501 case 'index':
32502 if (stack.length < 1) {
32503 return null;
32504 }
32505 num1 = stack.pop();
32506 if (num1.type !== 'literal') {
32507 return null;
32508 }
32509 n = num1.number;
32510 if (n < 0 || (n|0) !== n || stack.length < n) {
32511 return null;
32512 }
32513 ast1 = stack[stack.length - n - 1];
32514 if (ast1.type === 'literal' || ast1.type === 'var') {
32515 stack.push(ast1);
32516 break;
32517 }
32518 tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
32519 stack[stack.length - n - 1] = tmpVar;
32520 stack.push(tmpVar);
32521 instructions.push(new AstVariableDefinition(tmpVar, ast1));
32522 break;
32523 case 'dup':
32524 if (stack.length < 1) {
32525 return null;
32526 }
32527 if (typeof code[i + 1] === 'number' && code[i + 2] === 'gt' &&
32528 code[i + 3] === i + 7 && code[i + 4] === 'jz' &&
32529 code[i + 5] === 'pop' && code[i + 6] === code[i + 1]) {
32530 // special case of the commands sequence for the min operation
32531 num1 = stack.pop();
32532 stack.push(buildMinOperation(num1, code[i + 1]));
32533 i += 6;
32534 break;
32535 }
32536 ast1 = stack[stack.length - 1];
32537 if (ast1.type === 'literal' || ast1.type === 'var') {
32538 // we don't have to save into intermediate variable a literal or
32539 // variable.
32540 stack.push(ast1);
32541 break;
32542 }
32543 tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
32544 stack[stack.length - 1] = tmpVar;
32545 stack.push(tmpVar);
32546 instructions.push(new AstVariableDefinition(tmpVar, ast1));
32547 break;
32548 case 'roll':
32549 if (stack.length < 2) {
32550 return null;
32551 }
32552 num2 = stack.pop();
32553 num1 = stack.pop();
32554 if (num2.type !== 'literal' || num1.type !== 'literal') {
32555 // both roll operands must be numbers
32556 return null;
32557 }
32558 j = num2.number;
32559 n = num1.number;
32560 if (n <= 0 || (n|0) !== n || (j|0) !== j || stack.length < n) {
32561 // ... and integers
32562 return null;
32563 }
32564 j = ((j % n) + n) % n;
32565 if (j === 0) {
32566 break; // just skipping -- there are nothing to rotate
32567 }
32568 Array.prototype.push.apply(stack,
32569 stack.splice(stack.length - n, n - j));
32570 break;
32571 default:
32572 return null; // unsupported operator
32573 }
32574 }
32575
32576 if (stack.length !== outputSize) {
32577 return null;
32578 }
32579
32580 var result = [];
32581 instructions.forEach(function (instruction) {
32582 var statementBuilder = new ExpressionBuilderVisitor();
32583 instruction.visit(statementBuilder);
32584 result.push(statementBuilder.toString());
32585 });
32586 stack.forEach(function (expr, i) {
32587 var statementBuilder = new ExpressionBuilderVisitor();
32588 expr.visit(statementBuilder);
32589 var min = range[i * 2], max = range[i * 2 + 1];
32590 var out = [statementBuilder.toString()];
32591 if (min > expr.min) {
32592 out.unshift('Math.max(', min, ', ');
32593 out.push(')');
32594 }
32595 if (max < expr.max) {
32596 out.unshift('Math.min(', max, ', ');
32597 out.push(')');
32598 }
32599 out.unshift('dest[destOffset + ', i, '] = ');
32600 out.push(';');
32601 result.push(out.join(''));
32602 });
32603 return result.join('\n');
32604 }
32605 };
32606
32607 return PostScriptCompiler;
32608})();
32609
32610exports.isPDFFunction = isPDFFunction;
32611exports.PDFFunction = PDFFunction;
32612exports.PostScriptEvaluator = PostScriptEvaluator;
32613exports.PostScriptCompiler = PostScriptCompiler;
32614}));
32615
32616
32617(function (root, factory) {
32618 {
32619 factory((root.pdfjsCoreColorSpace = {}), root.pdfjsSharedUtil,
32620 root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
32621 }
32622}(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
32623
32624var error = sharedUtil.error;
32625var info = sharedUtil.info;
32626var isArray = sharedUtil.isArray;
32627var isString = sharedUtil.isString;
32628var shadow = sharedUtil.shadow;
32629var warn = sharedUtil.warn;
32630var isDict = corePrimitives.isDict;
32631var isName = corePrimitives.isName;
32632var isStream = corePrimitives.isStream;
32633var PDFFunction = coreFunction.PDFFunction;
32634
32635var ColorSpace = (function ColorSpaceClosure() {
32636 /**
32637 * Resizes an RGB image with 3 components.
32638 * @param {TypedArray} src - The source buffer.
32639 * @param {Number} bpc - Number of bits per component.
32640 * @param {Number} w1 - Original width.
32641 * @param {Number} h1 - Original height.
32642 * @param {Number} w2 - New width.
32643 * @param {Number} h2 - New height.
32644 * @param {Number} alpha01 - Size reserved for the alpha channel.
32645 * @param {TypedArray} dest - The destination buffer.
32646 */
32647 function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
32648 var COMPONENTS = 3;
32649 alpha01 = alpha01 !== 1 ? 0 : alpha01;
32650 var xRatio = w1 / w2;
32651 var yRatio = h1 / h2;
32652 var i, j, py, newIndex = 0, oldIndex;
32653 var xScaled = new Uint16Array(w2);
32654 var w1Scanline = w1 * COMPONENTS;
32655
32656 for (i = 0; i < w2; i++) {
32657 xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
32658 }
32659 for (i = 0; i < h2; i++) {
32660 py = Math.floor(i * yRatio) * w1Scanline;
32661 for (j = 0; j < w2; j++) {
32662 oldIndex = py + xScaled[j];
32663 dest[newIndex++] = src[oldIndex++];
32664 dest[newIndex++] = src[oldIndex++];
32665 dest[newIndex++] = src[oldIndex++];
32666 newIndex += alpha01;
32667 }
32668 }
32669 }
32670
32671 // Constructor should define this.numComps, this.defaultColor, this.name
32672 function ColorSpace() {
32673 error('should not call ColorSpace constructor');
32674 }
32675
32676 ColorSpace.prototype = {
32677 /**
32678 * Converts the color value to the RGB color. The color components are
32679 * located in the src array starting from the srcOffset. Returns the array
32680 * of the rgb components, each value ranging from [0,255].
32681 */
32682 getRgb: function ColorSpace_getRgb(src, srcOffset) {
32683 var rgb = new Uint8Array(3);
32684 this.getRgbItem(src, srcOffset, rgb, 0);
32685 return rgb;
32686 },
32687 /**
32688 * Converts the color value to the RGB color, similar to the getRgb method.
32689 * The result placed into the dest array starting from the destOffset.
32690 */
32691 getRgbItem: function ColorSpace_getRgbItem(src, srcOffset,
32692 dest, destOffset) {
32693 error('Should not call ColorSpace.getRgbItem');
32694 },
32695 /**
32696 * Converts the specified number of the color values to the RGB colors.
32697 * The colors are located in the src array starting from the srcOffset.
32698 * The result is placed into the dest array starting from the destOffset.
32699 * The src array items shall be in [0,2^bits) range, the dest array items
32700 * will be in [0,255] range. alpha01 indicates how many alpha components
32701 * there are in the dest array; it will be either 0 (RGB array) or 1 (RGBA
32702 * array).
32703 */
32704 getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count,
32705 dest, destOffset, bits,
32706 alpha01) {
32707 error('Should not call ColorSpace.getRgbBuffer');
32708 },
32709 /**
32710 * Determines the number of bytes required to store the result of the
32711 * conversion done by the getRgbBuffer method. As in getRgbBuffer,
32712 * |alpha01| is either 0 (RGB output) or 1 (RGBA output).
32713 */
32714 getOutputLength: function ColorSpace_getOutputLength(inputLength,
32715 alpha01) {
32716 error('Should not call ColorSpace.getOutputLength');
32717 },
32718 /**
32719 * Returns true if source data will be equal the result/output data.
32720 */
32721 isPassthrough: function ColorSpace_isPassthrough(bits) {
32722 return false;
32723 },
32724 /**
32725 * Fills in the RGB colors in the destination buffer. alpha01 indicates
32726 * how many alpha components there are in the dest array; it will be either
32727 * 0 (RGB array) or 1 (RGBA array).
32728 */
32729 fillRgb: function ColorSpace_fillRgb(dest, originalWidth,
32730 originalHeight, width, height,
32731 actualHeight, bpc, comps, alpha01) {
32732 var count = originalWidth * originalHeight;
32733 var rgbBuf = null;
32734 var numComponentColors = 1 << bpc;
32735 var needsResizing = originalHeight !== height || originalWidth !== width;
32736 var i, ii;
32737
32738 if (this.isPassthrough(bpc)) {
32739 rgbBuf = comps;
32740 } else if (this.numComps === 1 && count > numComponentColors &&
32741 this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
32742 // Optimization: create a color map when there is just one component and
32743 // we are converting more colors than the size of the color map. We
32744 // don't build the map if the colorspace is gray or rgb since those
32745 // methods are faster than building a map. This mainly offers big speed
32746 // ups for indexed and alternate colorspaces.
32747 //
32748 // TODO it may be worth while to cache the color map. While running
32749 // testing I never hit a cache so I will leave that out for now (perhaps
32750 // we are reparsing colorspaces too much?).
32751 var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) :
32752 new Uint16Array(numComponentColors);
32753 var key;
32754 for (i = 0; i < numComponentColors; i++) {
32755 allColors[i] = i;
32756 }
32757 var colorMap = new Uint8Array(numComponentColors * 3);
32758 this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc,
32759 /* alpha01 = */ 0);
32760
32761 var destPos, rgbPos;
32762 if (!needsResizing) {
32763 // Fill in the RGB values directly into |dest|.
32764 destPos = 0;
32765 for (i = 0; i < count; ++i) {
32766 key = comps[i] * 3;
32767 dest[destPos++] = colorMap[key];
32768 dest[destPos++] = colorMap[key + 1];
32769 dest[destPos++] = colorMap[key + 2];
32770 destPos += alpha01;
32771 }
32772 } else {
32773 rgbBuf = new Uint8Array(count * 3);
32774 rgbPos = 0;
32775 for (i = 0; i < count; ++i) {
32776 key = comps[i] * 3;
32777 rgbBuf[rgbPos++] = colorMap[key];
32778 rgbBuf[rgbPos++] = colorMap[key + 1];
32779 rgbBuf[rgbPos++] = colorMap[key + 2];
32780 }
32781 }
32782 } else {
32783 if (!needsResizing) {
32784 // Fill in the RGB values directly into |dest|.
32785 this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc,
32786 alpha01);
32787 } else {
32788 rgbBuf = new Uint8Array(count * 3);
32789 this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc,
32790 /* alpha01 = */ 0);
32791 }
32792 }
32793
32794 if (rgbBuf) {
32795 if (needsResizing) {
32796 resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight,
32797 width, height, alpha01, dest);
32798 } else {
32799 rgbPos = 0;
32800 destPos = 0;
32801 for (i = 0, ii = width * actualHeight; i < ii; i++) {
32802 dest[destPos++] = rgbBuf[rgbPos++];
32803 dest[destPos++] = rgbBuf[rgbPos++];
32804 dest[destPos++] = rgbBuf[rgbPos++];
32805 destPos += alpha01;
32806 }
32807 }
32808 }
32809 },
32810 /**
32811 * True if the colorspace has components in the default range of [0, 1].
32812 * This should be true for all colorspaces except for lab color spaces
32813 * which are [0,100], [-128, 127], [-128, 127].
32814 */
32815 usesZeroToOneRange: true
32816 };
32817
32818 ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
32819 var IR = ColorSpace.parseToIR(cs, xref, res);
32820 if (IR instanceof AlternateCS) {
32821 return IR;
32822 }
32823 return ColorSpace.fromIR(IR);
32824 };
32825
32826 ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
32827 var name = isArray(IR) ? IR[0] : IR;
32828 var whitePoint, blackPoint, gamma;
32829
32830 switch (name) {
32831 case 'DeviceGrayCS':
32832 return this.singletons.gray;
32833 case 'DeviceRgbCS':
32834 return this.singletons.rgb;
32835 case 'DeviceCmykCS':
32836 return this.singletons.cmyk;
32837 case 'CalGrayCS':
32838 whitePoint = IR[1];
32839 blackPoint = IR[2];
32840 gamma = IR[3];
32841 return new CalGrayCS(whitePoint, blackPoint, gamma);
32842 case 'CalRGBCS':
32843 whitePoint = IR[1];
32844 blackPoint = IR[2];
32845 gamma = IR[3];
32846 var matrix = IR[4];
32847 return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
32848 case 'PatternCS':
32849 var basePatternCS = IR[1];
32850 if (basePatternCS) {
32851 basePatternCS = ColorSpace.fromIR(basePatternCS);
32852 }
32853 return new PatternCS(basePatternCS);
32854 case 'IndexedCS':
32855 var baseIndexedCS = IR[1];
32856 var hiVal = IR[2];
32857 var lookup = IR[3];
32858 return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
32859 case 'AlternateCS':
32860 var numComps = IR[1];
32861 var alt = IR[2];
32862 var tintFnIR = IR[3];
32863
32864 return new AlternateCS(numComps, ColorSpace.fromIR(alt),
32865 PDFFunction.fromIR(tintFnIR));
32866 case 'LabCS':
32867 whitePoint = IR[1];
32868 blackPoint = IR[2];
32869 var range = IR[3];
32870 return new LabCS(whitePoint, blackPoint, range);
32871 default:
32872 error('Unknown name ' + name);
32873 }
32874 return null;
32875 };
32876
32877 ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
32878 if (isName(cs)) {
32879 var colorSpaces = res.get('ColorSpace');
32880 if (isDict(colorSpaces)) {
32881 var refcs = colorSpaces.get(cs.name);
32882 if (refcs) {
32883 cs = refcs;
32884 }
32885 }
32886 }
32887
32888 cs = xref.fetchIfRef(cs);
32889 var mode;
32890
32891 if (isName(cs)) {
32892 mode = cs.name;
32893 this.mode = mode;
32894
32895 switch (mode) {
32896 case 'DeviceGray':
32897 case 'G':
32898 return 'DeviceGrayCS';
32899 case 'DeviceRGB':
32900 case 'RGB':
32901 return 'DeviceRgbCS';
32902 case 'DeviceCMYK':
32903 case 'CMYK':
32904 return 'DeviceCmykCS';
32905 case 'Pattern':
32906 return ['PatternCS', null];
32907 default:
32908 error('unrecognized colorspace ' + mode);
32909 }
32910 } else if (isArray(cs)) {
32911 mode = xref.fetchIfRef(cs[0]).name;
32912 this.mode = mode;
32913 var numComps, params, alt, whitePoint, blackPoint, gamma;
32914
32915 switch (mode) {
32916 case 'DeviceGray':
32917 case 'G':
32918 return 'DeviceGrayCS';
32919 case 'DeviceRGB':
32920 case 'RGB':
32921 return 'DeviceRgbCS';
32922 case 'DeviceCMYK':
32923 case 'CMYK':
32924 return 'DeviceCmykCS';
32925 case 'CalGray':
32926 params = xref.fetchIfRef(cs[1]);
32927 whitePoint = params.getArray('WhitePoint');
32928 blackPoint = params.getArray('BlackPoint');
32929 gamma = params.get('Gamma');
32930 return ['CalGrayCS', whitePoint, blackPoint, gamma];
32931 case 'CalRGB':
32932 params = xref.fetchIfRef(cs[1]);
32933 whitePoint = params.getArray('WhitePoint');
32934 blackPoint = params.getArray('BlackPoint');
32935 gamma = params.getArray('Gamma');
32936 var matrix = params.getArray('Matrix');
32937 return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];
32938 case 'ICCBased':
32939 var stream = xref.fetchIfRef(cs[1]);
32940 var dict = stream.dict;
32941 numComps = dict.get('N');
32942 alt = dict.get('Alternate');
32943 if (alt) {
32944 var altIR = ColorSpace.parseToIR(alt, xref, res);
32945 // Parse the /Alternate CS to ensure that the number of components
32946 // are correct, and also (indirectly) that it is not a PatternCS.
32947 var altCS = ColorSpace.fromIR(altIR);
32948 if (altCS.numComps === numComps) {
32949 return altIR;
32950 }
32951 warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
32952 }
32953 if (numComps === 1) {
32954 return 'DeviceGrayCS';
32955 } else if (numComps === 3) {
32956 return 'DeviceRgbCS';
32957 } else if (numComps === 4) {
32958 return 'DeviceCmykCS';
32959 }
32960 break;
32961 case 'Pattern':
32962 var basePatternCS = cs[1] || null;
32963 if (basePatternCS) {
32964 basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
32965 }
32966 return ['PatternCS', basePatternCS];
32967 case 'Indexed':
32968 case 'I':
32969 var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
32970 var hiVal = xref.fetchIfRef(cs[2]) + 1;
32971 var lookup = xref.fetchIfRef(cs[3]);
32972 if (isStream(lookup)) {
32973 lookup = lookup.getBytes();
32974 }
32975 return ['IndexedCS', baseIndexedCS, hiVal, lookup];
32976 case 'Separation':
32977 case 'DeviceN':
32978 var name = xref.fetchIfRef(cs[1]);
32979 numComps = 1;
32980 if (isName(name)) {
32981 numComps = 1;
32982 } else if (isArray(name)) {
32983 numComps = name.length;
32984 }
32985 alt = ColorSpace.parseToIR(cs[2], xref, res);
32986 var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
32987 return ['AlternateCS', numComps, alt, tintFnIR];
32988 case 'Lab':
32989 params = xref.fetchIfRef(cs[1]);
32990 whitePoint = params.getArray('WhitePoint');
32991 blackPoint = params.getArray('BlackPoint');
32992 var range = params.getArray('Range');
32993 return ['LabCS', whitePoint, blackPoint, range];
32994 default:
32995 error('unimplemented color space object "' + mode + '"');
32996 }
32997 } else {
32998 error('unrecognized color space object: "' + cs + '"');
32999 }
33000 return null;
33001 };
33002 /**
33003 * Checks if a decode map matches the default decode map for a color space.
33004 * This handles the general decode maps where there are two values per
33005 * component. e.g. [0, 1, 0, 1, 0, 1] for a RGB color.
33006 * This does not handle Lab, Indexed, or Pattern decode maps since they are
33007 * slightly different.
33008 * @param {Array} decode Decode map (usually from an image).
33009 * @param {Number} n Number of components the color space has.
33010 */
33011 ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
33012 if (!isArray(decode)) {
33013 return true;
33014 }
33015
33016 if (n * 2 !== decode.length) {
33017 warn('The decode map is not the correct length');
33018 return true;
33019 }
33020 for (var i = 0, ii = decode.length; i < ii; i += 2) {
33021 if (decode[i] !== 0 || decode[i + 1] !== 1) {
33022 return false;
33023 }
33024 }
33025 return true;
33026 };
33027
33028 ColorSpace.singletons = {
33029 get gray() {
33030 return shadow(this, 'gray', new DeviceGrayCS());
33031 },
33032 get rgb() {
33033 return shadow(this, 'rgb', new DeviceRgbCS());
33034 },
33035 get cmyk() {
33036 return shadow(this, 'cmyk', new DeviceCmykCS());
33037 }
33038 };
33039
33040 return ColorSpace;
33041})();
33042
33043/**
33044 * Alternate color space handles both Separation and DeviceN color spaces. A
33045 * Separation color space is actually just a DeviceN with one color component.
33046 * Both color spaces use a tinting function to convert colors to a base color
33047 * space.
33048 */
33049var AlternateCS = (function AlternateCSClosure() {
33050 function AlternateCS(numComps, base, tintFn) {
33051 this.name = 'Alternate';
33052 this.numComps = numComps;
33053 this.defaultColor = new Float32Array(numComps);
33054 for (var i = 0; i < numComps; ++i) {
33055 this.defaultColor[i] = 1;
33056 }
33057 this.base = base;
33058 this.tintFn = tintFn;
33059 this.tmpBuf = new Float32Array(base.numComps);
33060 }
33061
33062 AlternateCS.prototype = {
33063 getRgb: ColorSpace.prototype.getRgb,
33064 getRgbItem: function AlternateCS_getRgbItem(src, srcOffset,
33065 dest, destOffset) {
33066 var tmpBuf = this.tmpBuf;
33067 this.tintFn(src, srcOffset, tmpBuf, 0);
33068 this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
33069 },
33070 getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count,
33071 dest, destOffset, bits,
33072 alpha01) {
33073 var tintFn = this.tintFn;
33074 var base = this.base;
33075 var scale = 1 / ((1 << bits) - 1);
33076 var baseNumComps = base.numComps;
33077 var usesZeroToOneRange = base.usesZeroToOneRange;
33078 var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) &&
33079 alpha01 === 0;
33080 var pos = isPassthrough ? destOffset : 0;
33081 var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
33082 var numComps = this.numComps;
33083
33084 var scaled = new Float32Array(numComps);
33085 var tinted = new Float32Array(baseNumComps);
33086 var i, j;
33087 if (usesZeroToOneRange) {
33088 for (i = 0; i < count; i++) {
33089 for (j = 0; j < numComps; j++) {
33090 scaled[j] = src[srcOffset++] * scale;
33091 }
33092 tintFn(scaled, 0, tinted, 0);
33093 for (j = 0; j < baseNumComps; j++) {
33094 baseBuf[pos++] = tinted[j] * 255;
33095 }
33096 }
33097 } else {
33098 for (i = 0; i < count; i++) {
33099 for (j = 0; j < numComps; j++) {
33100 scaled[j] = src[srcOffset++] * scale;
33101 }
33102 tintFn(scaled, 0, tinted, 0);
33103 base.getRgbItem(tinted, 0, baseBuf, pos);
33104 pos += baseNumComps;
33105 }
33106 }
33107 if (!isPassthrough) {
33108 base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
33109 }
33110 },
33111 getOutputLength: function AlternateCS_getOutputLength(inputLength,
33112 alpha01) {
33113 return this.base.getOutputLength(inputLength *
33114 this.base.numComps / this.numComps,
33115 alpha01);
33116 },
33117 isPassthrough: ColorSpace.prototype.isPassthrough,
33118 fillRgb: ColorSpace.prototype.fillRgb,
33119 isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
33120 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
33121 },
33122 usesZeroToOneRange: true
33123 };
33124
33125 return AlternateCS;
33126})();
33127
33128var PatternCS = (function PatternCSClosure() {
33129 function PatternCS(baseCS) {
33130 this.name = 'Pattern';
33131 this.base = baseCS;
33132 }
33133 PatternCS.prototype = {};
33134
33135 return PatternCS;
33136})();
33137
33138var IndexedCS = (function IndexedCSClosure() {
33139 function IndexedCS(base, highVal, lookup) {
33140 this.name = 'Indexed';
33141 this.numComps = 1;
33142 this.defaultColor = new Uint8Array([0]);
33143 this.base = base;
33144 this.highVal = highVal;
33145
33146 var baseNumComps = base.numComps;
33147 var length = baseNumComps * highVal;
33148 var lookupArray;
33149
33150 if (isStream(lookup)) {
33151 lookupArray = new Uint8Array(length);
33152 var bytes = lookup.getBytes(length);
33153 lookupArray.set(bytes);
33154 } else if (isString(lookup)) {
33155 lookupArray = new Uint8Array(length);
33156 for (var i = 0; i < length; ++i) {
33157 lookupArray[i] = lookup.charCodeAt(i);
33158 }
33159 } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
33160 lookupArray = lookup;
33161 } else {
33162 error('Unrecognized lookup table: ' + lookup);
33163 }
33164 this.lookup = lookupArray;
33165 }
33166
33167 IndexedCS.prototype = {
33168 getRgb: ColorSpace.prototype.getRgb,
33169 getRgbItem: function IndexedCS_getRgbItem(src, srcOffset,
33170 dest, destOffset) {
33171 var numComps = this.base.numComps;
33172 var start = src[srcOffset] * numComps;
33173 this.base.getRgbItem(this.lookup, start, dest, destOffset);
33174 },
33175 getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count,
33176 dest, destOffset, bits,
33177 alpha01) {
33178 var base = this.base;
33179 var numComps = base.numComps;
33180 var outputDelta = base.getOutputLength(numComps, alpha01);
33181 var lookup = this.lookup;
33182
33183 for (var i = 0; i < count; ++i) {
33184 var lookupPos = src[srcOffset++] * numComps;
33185 base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
33186 destOffset += outputDelta;
33187 }
33188 },
33189 getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
33190 return this.base.getOutputLength(inputLength * this.base.numComps,
33191 alpha01);
33192 },
33193 isPassthrough: ColorSpace.prototype.isPassthrough,
33194 fillRgb: ColorSpace.prototype.fillRgb,
33195 isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
33196 // indexed color maps shouldn't be changed
33197 return true;
33198 },
33199 usesZeroToOneRange: true
33200 };
33201 return IndexedCS;
33202})();
33203
33204var DeviceGrayCS = (function DeviceGrayCSClosure() {
33205 function DeviceGrayCS() {
33206 this.name = 'DeviceGray';
33207 this.numComps = 1;
33208 this.defaultColor = new Float32Array([0]);
33209 }
33210
33211 DeviceGrayCS.prototype = {
33212 getRgb: ColorSpace.prototype.getRgb,
33213 getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset,
33214 dest, destOffset) {
33215 var c = (src[srcOffset] * 255) | 0;
33216 c = c < 0 ? 0 : c > 255 ? 255 : c;
33217 dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
33218 },
33219 getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count,
33220 dest, destOffset, bits,
33221 alpha01) {
33222 var scale = 255 / ((1 << bits) - 1);
33223 var j = srcOffset, q = destOffset;
33224 for (var i = 0; i < count; ++i) {
33225 var c = (scale * src[j++]) | 0;
33226 dest[q++] = c;
33227 dest[q++] = c;
33228 dest[q++] = c;
33229 q += alpha01;
33230 }
33231 },
33232 getOutputLength: function DeviceGrayCS_getOutputLength(inputLength,
33233 alpha01) {
33234 return inputLength * (3 + alpha01);
33235 },
33236 isPassthrough: ColorSpace.prototype.isPassthrough,
33237 fillRgb: ColorSpace.prototype.fillRgb,
33238 isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
33239 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
33240 },
33241 usesZeroToOneRange: true
33242 };
33243 return DeviceGrayCS;
33244})();
33245
33246var DeviceRgbCS = (function DeviceRgbCSClosure() {
33247 function DeviceRgbCS() {
33248 this.name = 'DeviceRGB';
33249 this.numComps = 3;
33250 this.defaultColor = new Float32Array([0, 0, 0]);
33251 }
33252 DeviceRgbCS.prototype = {
33253 getRgb: ColorSpace.prototype.getRgb,
33254 getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset,
33255 dest, destOffset) {
33256 var r = (src[srcOffset] * 255) | 0;
33257 var g = (src[srcOffset + 1] * 255) | 0;
33258 var b = (src[srcOffset + 2] * 255) | 0;
33259 dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
33260 dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
33261 dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
33262 },
33263 getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count,
33264 dest, destOffset, bits,
33265 alpha01) {
33266 if (bits === 8 && alpha01 === 0) {
33267 dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
33268 return;
33269 }
33270 var scale = 255 / ((1 << bits) - 1);
33271 var j = srcOffset, q = destOffset;
33272 for (var i = 0; i < count; ++i) {
33273 dest[q++] = (scale * src[j++]) | 0;
33274 dest[q++] = (scale * src[j++]) | 0;
33275 dest[q++] = (scale * src[j++]) | 0;
33276 q += alpha01;
33277 }
33278 },
33279 getOutputLength: function DeviceRgbCS_getOutputLength(inputLength,
33280 alpha01) {
33281 return (inputLength * (3 + alpha01) / 3) | 0;
33282 },
33283 isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
33284 return bits === 8;
33285 },
33286 fillRgb: ColorSpace.prototype.fillRgb,
33287 isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
33288 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
33289 },
33290 usesZeroToOneRange: true
33291 };
33292 return DeviceRgbCS;
33293})();
33294
33295var DeviceCmykCS = (function DeviceCmykCSClosure() {
33296 // The coefficients below was found using numerical analysis: the method of
33297 // steepest descent for the sum((f_i - color_value_i)^2) for r/g/b colors,
33298 // where color_value is the tabular value from the table of sampled RGB colors
33299 // from CMYK US Web Coated (SWOP) colorspace, and f_i is the corresponding
33300 // CMYK color conversion using the estimation below:
33301 // f(A, B,.. N) = Acc+Bcm+Ccy+Dck+c+Fmm+Gmy+Hmk+Im+Jyy+Kyk+Ly+Mkk+Nk+255
33302 function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
33303 var c = src[srcOffset + 0] * srcScale;
33304 var m = src[srcOffset + 1] * srcScale;
33305 var y = src[srcOffset + 2] * srcScale;
33306 var k = src[srcOffset + 3] * srcScale;
33307
33308 var r =
33309 (c * (-4.387332384609988 * c + 54.48615194189176 * m +
33310 18.82290502165302 * y + 212.25662451639585 * k +
33311 -285.2331026137004) +
33312 m * (1.7149763477362134 * m - 5.6096736904047315 * y +
33313 -17.873870861415444 * k - 5.497006427196366) +
33314 y * (-2.5217340131683033 * y - 21.248923337353073 * k +
33315 17.5119270841813) +
33316 k * (-21.86122147463605 * k - 189.48180835922747) + 255) | 0;
33317 var g =
33318 (c * (8.841041422036149 * c + 60.118027045597366 * m +
33319 6.871425592049007 * y + 31.159100130055922 * k +
33320 -79.2970844816548) +
33321 m * (-15.310361306967817 * m + 17.575251261109482 * y +
33322 131.35250912493976 * k - 190.9453302588951) +
33323 y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) +
33324 k * (-20.737325471181034 * k - 187.80453709719578) + 255) | 0;
33325 var b =
33326 (c * (0.8842522430003296 * c + 8.078677503112928 * m +
33327 30.89978309703729 * y - 0.23883238689178934 * k +
33328 -14.183576799673286) +
33329 m * (10.49593273432072 * m + 63.02378494754052 * y +
33330 50.606957656360734 * k - 112.23884253719248) +
33331 y * (0.03296041114873217 * y + 115.60384449646641 * k +
33332 -193.58209356861505) +
33333 k * (-22.33816807309886 * k - 180.12613974708367) + 255) | 0;
33334
33335 dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
33336 dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
33337 dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
33338 }
33339
33340 function DeviceCmykCS() {
33341 this.name = 'DeviceCMYK';
33342 this.numComps = 4;
33343 this.defaultColor = new Float32Array([0, 0, 0, 1]);
33344 }
33345 DeviceCmykCS.prototype = {
33346 getRgb: ColorSpace.prototype.getRgb,
33347 getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset,
33348 dest, destOffset) {
33349 convertToRgb(src, srcOffset, 1, dest, destOffset);
33350 },
33351 getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count,
33352 dest, destOffset, bits,
33353 alpha01) {
33354 var scale = 1 / ((1 << bits) - 1);
33355 for (var i = 0; i < count; i++) {
33356 convertToRgb(src, srcOffset, scale, dest, destOffset);
33357 srcOffset += 4;
33358 destOffset += 3 + alpha01;
33359 }
33360 },
33361 getOutputLength: function DeviceCmykCS_getOutputLength(inputLength,
33362 alpha01) {
33363 return (inputLength / 4 * (3 + alpha01)) | 0;
33364 },
33365 isPassthrough: ColorSpace.prototype.isPassthrough,
33366 fillRgb: ColorSpace.prototype.fillRgb,
33367 isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
33368 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
33369 },
33370 usesZeroToOneRange: true
33371 };
33372
33373 return DeviceCmykCS;
33374})();
33375
33376//
33377// CalGrayCS: Based on "PDF Reference, Sixth Ed", p.245
33378//
33379var CalGrayCS = (function CalGrayCSClosure() {
33380 function CalGrayCS(whitePoint, blackPoint, gamma) {
33381 this.name = 'CalGray';
33382 this.numComps = 1;
33383 this.defaultColor = new Float32Array([0]);
33384
33385 if (!whitePoint) {
33386 error('WhitePoint missing - required for color space CalGray');
33387 }
33388 blackPoint = blackPoint || [0, 0, 0];
33389 gamma = gamma || 1;
33390
33391 // Translate arguments to spec variables.
33392 this.XW = whitePoint[0];
33393 this.YW = whitePoint[1];
33394 this.ZW = whitePoint[2];
33395
33396 this.XB = blackPoint[0];
33397 this.YB = blackPoint[1];
33398 this.ZB = blackPoint[2];
33399
33400 this.G = gamma;
33401
33402 // Validate variables as per spec.
33403 if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
33404 error('Invalid WhitePoint components for ' + this.name +
33405 ', no fallback available');
33406 }
33407
33408 if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
33409 info('Invalid BlackPoint for ' + this.name + ', falling back to default');
33410 this.XB = this.YB = this.ZB = 0;
33411 }
33412
33413 if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
33414 warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB +
33415 ', ZB: ' + this.ZB + ', only default values are supported.');
33416 }
33417
33418 if (this.G < 1) {
33419 info('Invalid Gamma: ' + this.G + ' for ' + this.name +
33420 ', falling back to default');
33421 this.G = 1;
33422 }
33423 }
33424
33425 function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
33426 // A represents a gray component of a calibrated gray space.
33427 // A <---> AG in the spec
33428 var A = src[srcOffset] * scale;
33429 var AG = Math.pow(A, cs.G);
33430
33431 // Computes L as per spec. ( = cs.YW * AG )
33432 // Except if other than default BlackPoint values are used.
33433 var L = cs.YW * AG;
33434 // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
33435 // Convert values to rgb range [0, 255].
33436 var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
33437 dest[destOffset] = val;
33438 dest[destOffset + 1] = val;
33439 dest[destOffset + 2] = val;
33440 }
33441
33442 CalGrayCS.prototype = {
33443 getRgb: ColorSpace.prototype.getRgb,
33444 getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset,
33445 dest, destOffset) {
33446 convertToRgb(this, src, srcOffset, dest, destOffset, 1);
33447 },
33448 getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count,
33449 dest, destOffset, bits,
33450 alpha01) {
33451 var scale = 1 / ((1 << bits) - 1);
33452
33453 for (var i = 0; i < count; ++i) {
33454 convertToRgb(this, src, srcOffset, dest, destOffset, scale);
33455 srcOffset += 1;
33456 destOffset += 3 + alpha01;
33457 }
33458 },
33459 getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
33460 return inputLength * (3 + alpha01);
33461 },
33462 isPassthrough: ColorSpace.prototype.isPassthrough,
33463 fillRgb: ColorSpace.prototype.fillRgb,
33464 isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
33465 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
33466 },
33467 usesZeroToOneRange: true
33468 };
33469 return CalGrayCS;
33470})();
33471
33472//
33473// CalRGBCS: Based on "PDF Reference, Sixth Ed", p.247
33474//
33475var CalRGBCS = (function CalRGBCSClosure() {
33476
33477 // See http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html for these
33478 // matrices.
33479 var BRADFORD_SCALE_MATRIX = new Float32Array([
33480 0.8951, 0.2664, -0.1614,
33481 -0.7502, 1.7135, 0.0367,
33482 0.0389, -0.0685, 1.0296]);
33483
33484 var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
33485 0.9869929, -0.1470543, 0.1599627,
33486 0.4323053, 0.5183603, 0.0492912,
33487 -0.0085287, 0.0400428, 0.9684867]);
33488
33489 // See http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html.
33490 var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
33491 3.2404542, -1.5371385, -0.4985314,
33492 -0.9692660, 1.8760108, 0.0415560,
33493 0.0556434, -0.2040259, 1.0572252]);
33494
33495 var FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
33496
33497 var tempNormalizeMatrix = new Float32Array(3);
33498 var tempConvertMatrix1 = new Float32Array(3);
33499 var tempConvertMatrix2 = new Float32Array(3);
33500
33501 var DECODE_L_CONSTANT = Math.pow(((8 + 16) / 116), 3) / 8.0;
33502
33503 function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
33504 this.name = 'CalRGB';
33505 this.numComps = 3;
33506 this.defaultColor = new Float32Array(3);
33507
33508 if (!whitePoint) {
33509 error('WhitePoint missing - required for color space CalRGB');
33510 }
33511 blackPoint = blackPoint || new Float32Array(3);
33512 gamma = gamma || new Float32Array([1, 1, 1]);
33513 matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
33514
33515 // Translate arguments to spec variables.
33516 var XW = whitePoint[0];
33517 var YW = whitePoint[1];
33518 var ZW = whitePoint[2];
33519 this.whitePoint = whitePoint;
33520
33521 var XB = blackPoint[0];
33522 var YB = blackPoint[1];
33523 var ZB = blackPoint[2];
33524 this.blackPoint = blackPoint;
33525
33526 this.GR = gamma[0];
33527 this.GG = gamma[1];
33528 this.GB = gamma[2];
33529
33530 this.MXA = matrix[0];
33531 this.MYA = matrix[1];
33532 this.MZA = matrix[2];
33533 this.MXB = matrix[3];
33534 this.MYB = matrix[4];
33535 this.MZB = matrix[5];
33536 this.MXC = matrix[6];
33537 this.MYC = matrix[7];
33538 this.MZC = matrix[8];
33539
33540 // Validate variables as per spec.
33541 if (XW < 0 || ZW < 0 || YW !== 1) {
33542 error('Invalid WhitePoint components for ' + this.name +
33543 ', no fallback available');
33544 }
33545
33546 if (XB < 0 || YB < 0 || ZB < 0) {
33547 info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB +
33548 ', ' + ZB + '], falling back to default');
33549 this.blackPoint = new Float32Array(3);
33550 }
33551
33552 if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
33553 info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB +
33554 '] for ' + this.name + ', falling back to default');
33555 this.GR = this.GG = this.GB = 1;
33556 }
33557
33558 if (this.MXA < 0 || this.MYA < 0 || this.MZA < 0 ||
33559 this.MXB < 0 || this.MYB < 0 || this.MZB < 0 ||
33560 this.MXC < 0 || this.MYC < 0 || this.MZC < 0) {
33561 info('Invalid Matrix for ' + this.name + ' [' +
33562 this.MXA + ', ' + this.MYA + ', ' + this.MZA +
33563 this.MXB + ', ' + this.MYB + ', ' + this.MZB +
33564 this.MXC + ', ' + this.MYC + ', ' + this.MZC +
33565 '], falling back to default');
33566 this.MXA = this.MYB = this.MZC = 1;
33567 this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
33568 }
33569 }
33570
33571 function matrixProduct(a, b, result) {
33572 result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
33573 result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
33574 result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
33575 }
33576
33577 function convertToFlat(sourceWhitePoint, LMS, result) {
33578 result[0] = LMS[0] * 1 / sourceWhitePoint[0];
33579 result[1] = LMS[1] * 1 / sourceWhitePoint[1];
33580 result[2] = LMS[2] * 1 / sourceWhitePoint[2];
33581 }
33582
33583 function convertToD65(sourceWhitePoint, LMS, result) {
33584 var D65X = 0.95047;
33585 var D65Y = 1;
33586 var D65Z = 1.08883;
33587
33588 result[0] = LMS[0] * D65X / sourceWhitePoint[0];
33589 result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
33590 result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
33591 }
33592
33593 function sRGBTransferFunction(color) {
33594 // See http://en.wikipedia.org/wiki/SRGB.
33595 if (color <= 0.0031308){
33596 return adjustToRange(0, 1, 12.92 * color);
33597 }
33598
33599 return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
33600 }
33601
33602 function adjustToRange(min, max, value) {
33603 return Math.max(min, Math.min(max, value));
33604 }
33605
33606 function decodeL(L) {
33607 if (L < 0) {
33608 return -decodeL(-L);
33609 }
33610
33611 if (L > 8.0) {
33612 return Math.pow(((L + 16) / 116), 3);
33613 }
33614
33615 return L * DECODE_L_CONSTANT;
33616 }
33617
33618 function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
33619
33620 // In case the blackPoint is already the default blackPoint then there is
33621 // no need to do compensation.
33622 if (sourceBlackPoint[0] === 0 &&
33623 sourceBlackPoint[1] === 0 &&
33624 sourceBlackPoint[2] === 0) {
33625 result[0] = XYZ_Flat[0];
33626 result[1] = XYZ_Flat[1];
33627 result[2] = XYZ_Flat[2];
33628 return;
33629 }
33630
33631 // For the blackPoint calculation details, please see
33632 // http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/sdk/
33633 // AdobeBPC.pdf.
33634 // The destination blackPoint is the default blackPoint [0, 0, 0].
33635 var zeroDecodeL = decodeL(0);
33636
33637 var X_DST = zeroDecodeL;
33638 var X_SRC = decodeL(sourceBlackPoint[0]);
33639
33640 var Y_DST = zeroDecodeL;
33641 var Y_SRC = decodeL(sourceBlackPoint[1]);
33642
33643 var Z_DST = zeroDecodeL;
33644 var Z_SRC = decodeL(sourceBlackPoint[2]);
33645
33646 var X_Scale = (1 - X_DST) / (1 - X_SRC);
33647 var X_Offset = 1 - X_Scale;
33648
33649 var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
33650 var Y_Offset = 1 - Y_Scale;
33651
33652 var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
33653 var Z_Offset = 1 - Z_Scale;
33654
33655 result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
33656 result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
33657 result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
33658 }
33659
33660 function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
33661
33662 // In case the whitePoint is already flat then there is no need to do
33663 // normalization.
33664 if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
33665 result[0] = XYZ_In[0];
33666 result[1] = XYZ_In[1];
33667 result[2] = XYZ_In[2];
33668 return;
33669 }
33670
33671 var LMS = result;
33672 matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
33673
33674 var LMS_Flat = tempNormalizeMatrix;
33675 convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
33676
33677 matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
33678 }
33679
33680 function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
33681
33682 var LMS = result;
33683 matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
33684
33685 var LMS_D65 = tempNormalizeMatrix;
33686 convertToD65(sourceWhitePoint, LMS, LMS_D65);
33687
33688 matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
33689 }
33690
33691 function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
33692 // A, B and C represent a red, green and blue components of a calibrated
33693 // rgb space.
33694 var A = adjustToRange(0, 1, src[srcOffset] * scale);
33695 var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
33696 var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
33697
33698 // A <---> AGR in the spec
33699 // B <---> BGG in the spec
33700 // C <---> CGB in the spec
33701 var AGR = Math.pow(A, cs.GR);
33702 var BGG = Math.pow(B, cs.GG);
33703 var CGB = Math.pow(C, cs.GB);
33704
33705 // Computes intermediate variables L, M, N as per spec.
33706 // To decode X, Y, Z values map L, M, N directly to them.
33707 var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
33708 var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
33709 var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
33710
33711 // The following calculations are based on this document:
33712 // http://www.adobe.com/content/dam/Adobe/en/devnet/photoshop/sdk/
33713 // AdobeBPC.pdf.
33714 var XYZ = tempConvertMatrix1;
33715 XYZ[0] = X;
33716 XYZ[1] = Y;
33717 XYZ[2] = Z;
33718 var XYZ_Flat = tempConvertMatrix2;
33719
33720 normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
33721
33722 var XYZ_Black = tempConvertMatrix1;
33723 compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
33724
33725 var XYZ_D65 = tempConvertMatrix2;
33726 normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
33727
33728 var SRGB = tempConvertMatrix1;
33729 matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
33730
33731 var sR = sRGBTransferFunction(SRGB[0]);
33732 var sG = sRGBTransferFunction(SRGB[1]);
33733 var sB = sRGBTransferFunction(SRGB[2]);
33734
33735 // Convert the values to rgb range [0, 255].
33736 dest[destOffset] = Math.round(sR * 255);
33737 dest[destOffset + 1] = Math.round(sG * 255);
33738 dest[destOffset + 2] = Math.round(sB * 255);
33739 }
33740
33741 CalRGBCS.prototype = {
33742 getRgb: function CalRGBCS_getRgb(src, srcOffset) {
33743 var rgb = new Uint8Array(3);
33744 this.getRgbItem(src, srcOffset, rgb, 0);
33745 return rgb;
33746 },
33747 getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset,
33748 dest, destOffset) {
33749 convertToRgb(this, src, srcOffset, dest, destOffset, 1);
33750 },
33751 getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count,
33752 dest, destOffset, bits,
33753 alpha01) {
33754 var scale = 1 / ((1 << bits) - 1);
33755
33756 for (var i = 0; i < count; ++i) {
33757 convertToRgb(this, src, srcOffset, dest, destOffset, scale);
33758 srcOffset += 3;
33759 destOffset += 3 + alpha01;
33760 }
33761 },
33762 getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
33763 return (inputLength * (3 + alpha01) / 3) | 0;
33764 },
33765 isPassthrough: ColorSpace.prototype.isPassthrough,
33766 fillRgb: ColorSpace.prototype.fillRgb,
33767 isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
33768 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
33769 },
33770 usesZeroToOneRange: true
33771 };
33772 return CalRGBCS;
33773})();
33774
33775//
33776// LabCS: Based on "PDF Reference, Sixth Ed", p.250
33777//
33778var LabCS = (function LabCSClosure() {
33779 function LabCS(whitePoint, blackPoint, range) {
33780 this.name = 'Lab';
33781 this.numComps = 3;
33782 this.defaultColor = new Float32Array([0, 0, 0]);
33783
33784 if (!whitePoint) {
33785 error('WhitePoint missing - required for color space Lab');
33786 }
33787 blackPoint = blackPoint || [0, 0, 0];
33788 range = range || [-100, 100, -100, 100];
33789
33790 // Translate args to spec variables
33791 this.XW = whitePoint[0];
33792 this.YW = whitePoint[1];
33793 this.ZW = whitePoint[2];
33794 this.amin = range[0];
33795 this.amax = range[1];
33796 this.bmin = range[2];
33797 this.bmax = range[3];
33798
33799 // These are here just for completeness - the spec doesn't offer any
33800 // formulas that use BlackPoint in Lab
33801 this.XB = blackPoint[0];
33802 this.YB = blackPoint[1];
33803 this.ZB = blackPoint[2];
33804
33805 // Validate vars as per spec
33806 if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
33807 error('Invalid WhitePoint components, no fallback available');
33808 }
33809
33810 if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
33811 info('Invalid BlackPoint, falling back to default');
33812 this.XB = this.YB = this.ZB = 0;
33813 }
33814
33815 if (this.amin > this.amax || this.bmin > this.bmax) {
33816 info('Invalid Range, falling back to defaults');
33817 this.amin = -100;
33818 this.amax = 100;
33819 this.bmin = -100;
33820 this.bmax = 100;
33821 }
33822 }
33823
33824 // Function g(x) from spec
33825 function fn_g(x) {
33826 if (x >= 6 / 29) {
33827 return x * x * x;
33828 } else {
33829 return (108 / 841) * (x - 4 / 29);
33830 }
33831 }
33832
33833 function decode(value, high1, low2, high2) {
33834 return low2 + (value) * (high2 - low2) / (high1);
33835 }
33836
33837 // If decoding is needed maxVal should be 2^bits per component - 1.
33838 function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
33839 // XXX: Lab input is in the range of [0, 100], [amin, amax], [bmin, bmax]
33840 // not the usual [0, 1]. If a command like setFillColor is used the src
33841 // values will already be within the correct range. However, if we are
33842 // converting an image we have to map the values to the correct range given
33843 // above.
33844 // Ls,as,bs <---> L*,a*,b* in the spec
33845 var Ls = src[srcOffset];
33846 var as = src[srcOffset + 1];
33847 var bs = src[srcOffset + 2];
33848 if (maxVal !== false) {
33849 Ls = decode(Ls, maxVal, 0, 100);
33850 as = decode(as, maxVal, cs.amin, cs.amax);
33851 bs = decode(bs, maxVal, cs.bmin, cs.bmax);
33852 }
33853
33854 // Adjust limits of 'as' and 'bs'
33855 as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
33856 bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
33857
33858 // Computes intermediate variables X,Y,Z as per spec
33859 var M = (Ls + 16) / 116;
33860 var L = M + (as / 500);
33861 var N = M - (bs / 200);
33862
33863 var X = cs.XW * fn_g(L);
33864 var Y = cs.YW * fn_g(M);
33865 var Z = cs.ZW * fn_g(N);
33866
33867 var r, g, b;
33868 // Using different conversions for D50 and D65 white points,
33869 // per http://www.color.org/srgb.pdf
33870 if (cs.ZW < 1) {
33871 // Assuming D50 (X=0.9642, Y=1.00, Z=0.8249)
33872 r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
33873 g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
33874 b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
33875 } else {
33876 // Assuming D65 (X=0.9505, Y=1.00, Z=1.0888)
33877 r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
33878 g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
33879 b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
33880 }
33881 // clamp color values to [0,1] range then convert to [0,255] range.
33882 dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
33883 dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
33884 dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
33885 }
33886
33887 LabCS.prototype = {
33888 getRgb: ColorSpace.prototype.getRgb,
33889 getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
33890 convertToRgb(this, src, srcOffset, false, dest, destOffset);
33891 },
33892 getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count,
33893 dest, destOffset, bits,
33894 alpha01) {
33895 var maxVal = (1 << bits) - 1;
33896 for (var i = 0; i < count; i++) {
33897 convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
33898 srcOffset += 3;
33899 destOffset += 3 + alpha01;
33900 }
33901 },
33902 getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
33903 return (inputLength * (3 + alpha01) / 3) | 0;
33904 },
33905 isPassthrough: ColorSpace.prototype.isPassthrough,
33906 fillRgb: ColorSpace.prototype.fillRgb,
33907 isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
33908 // XXX: Decoding is handled with the lab conversion because of the strange
33909 // ranges that are used.
33910 return true;
33911 },
33912 usesZeroToOneRange: false
33913 };
33914 return LabCS;
33915})();
33916
33917exports.ColorSpace = ColorSpace;
33918}));
33919
33920
33921(function (root, factory) {
33922 {
33923 factory((root.pdfjsCoreImage = {}), root.pdfjsSharedUtil,
33924 root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream,
33925 root.pdfjsCoreJpx);
33926 }
33927}(this, function (exports, sharedUtil, corePrimitives, coreColorSpace,
33928 coreStream, coreJpx) {
33929
33930var ImageKind = sharedUtil.ImageKind;
33931var assert = sharedUtil.assert;
33932var error = sharedUtil.error;
33933var info = sharedUtil.info;
33934var isArray = sharedUtil.isArray;
33935var warn = sharedUtil.warn;
33936var Name = corePrimitives.Name;
33937var isStream = corePrimitives.isStream;
33938var ColorSpace = coreColorSpace.ColorSpace;
33939var DecodeStream = coreStream.DecodeStream;
33940var JpegStream = coreStream.JpegStream;
33941var JpxImage = coreJpx.JpxImage;
33942
33943var PDFImage = (function PDFImageClosure() {
33944 /**
33945 * Decodes the image using native decoder if possible. Resolves the promise
33946 * when the image data is ready.
33947 */
33948 function handleImageData(image, nativeDecoder) {
33949 if (nativeDecoder && nativeDecoder.canDecode(image)) {
33950 return nativeDecoder.decode(image);
33951 } else {
33952 return Promise.resolve(image);
33953 }
33954 }
33955
33956 /**
33957 * Decode and clamp a value. The formula is different from the spec because we
33958 * don't decode to float range [0,1], we decode it in the [0,max] range.
33959 */
33960 function decodeAndClamp(value, addend, coefficient, max) {
33961 value = addend + value * coefficient;
33962 // Clamp the value to the range
33963 return (value < 0 ? 0 : (value > max ? max : value));
33964 }
33965
33966 /**
33967 * Resizes an image mask with 1 component.
33968 * @param {TypedArray} src - The source buffer.
33969 * @param {Number} bpc - Number of bits per component.
33970 * @param {Number} w1 - Original width.
33971 * @param {Number} h1 - Original height.
33972 * @param {Number} w2 - New width.
33973 * @param {Number} h2 - New height.
33974 * @returns {TypedArray} The resized image mask buffer.
33975 */
33976 function resizeImageMask(src, bpc, w1, h1, w2, h2) {
33977 var length = w2 * h2;
33978 var dest = (bpc <= 8 ? new Uint8Array(length) :
33979 (bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length)));
33980 var xRatio = w1 / w2;
33981 var yRatio = h1 / h2;
33982 var i, j, py, newIndex = 0, oldIndex;
33983 var xScaled = new Uint16Array(w2);
33984 var w1Scanline = w1;
33985
33986 for (i = 0; i < w2; i++) {
33987 xScaled[i] = Math.floor(i * xRatio);
33988 }
33989 for (i = 0; i < h2; i++) {
33990 py = Math.floor(i * yRatio) * w1Scanline;
33991 for (j = 0; j < w2; j++) {
33992 oldIndex = py + xScaled[j];
33993 dest[newIndex++] = src[oldIndex];
33994 }
33995 }
33996 return dest;
33997 }
33998
33999 function PDFImage(xref, res, image, inline, smask, mask, isMask) {
34000 this.image = image;
34001 var dict = image.dict;
34002 if (dict.has('Filter')) {
34003 var filter = dict.get('Filter').name;
34004 if (filter === 'JPXDecode') {
34005 var jpxImage = new JpxImage();
34006 jpxImage.parseImageProperties(image.stream);
34007 image.stream.reset();
34008 image.bitsPerComponent = jpxImage.bitsPerComponent;
34009 image.numComps = jpxImage.componentsCount;
34010 } else if (filter === 'JBIG2Decode') {
34011 image.bitsPerComponent = 1;
34012 image.numComps = 1;
34013 }
34014 }
34015 // TODO cache rendered images?
34016
34017 this.width = dict.get('Width', 'W');
34018 this.height = dict.get('Height', 'H');
34019
34020 if (this.width < 1 || this.height < 1) {
34021 error('Invalid image width: ' + this.width + ' or height: ' +
34022 this.height);
34023 }
34024
34025 this.interpolate = dict.get('Interpolate', 'I') || false;
34026 this.imageMask = dict.get('ImageMask', 'IM') || false;
34027 this.matte = dict.get('Matte') || false;
34028
34029 var bitsPerComponent = image.bitsPerComponent;
34030 if (!bitsPerComponent) {
34031 bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
34032 if (!bitsPerComponent) {
34033 if (this.imageMask) {
34034 bitsPerComponent = 1;
34035 } else {
34036 error('Bits per component missing in image: ' + this.imageMask);
34037 }
34038 }
34039 }
34040 this.bpc = bitsPerComponent;
34041
34042 if (!this.imageMask) {
34043 var colorSpace = dict.get('ColorSpace', 'CS');
34044 if (!colorSpace) {
34045 info('JPX images (which do not require color spaces)');
34046 switch (image.numComps) {
34047 case 1:
34048 colorSpace = Name.get('DeviceGray');
34049 break;
34050 case 3:
34051 colorSpace = Name.get('DeviceRGB');
34052 break;
34053 case 4:
34054 colorSpace = Name.get('DeviceCMYK');
34055 break;
34056 default:
34057 error('JPX images with ' + this.numComps +
34058 ' color components not supported.');
34059 }
34060 }
34061 this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
34062 this.numComps = this.colorSpace.numComps;
34063 }
34064
34065 this.decode = dict.getArray('Decode', 'D');
34066 this.needsDecode = false;
34067 if (this.decode &&
34068 ((this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode)) ||
34069 (isMask && !ColorSpace.isDefaultDecode(this.decode, 1)))) {
34070 this.needsDecode = true;
34071 // Do some preprocessing to avoid more math.
34072 var max = (1 << bitsPerComponent) - 1;
34073 this.decodeCoefficients = [];
34074 this.decodeAddends = [];
34075 for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
34076 var dmin = this.decode[i];
34077 var dmax = this.decode[i + 1];
34078 this.decodeCoefficients[j] = dmax - dmin;
34079 this.decodeAddends[j] = max * dmin;
34080 }
34081 }
34082
34083 if (smask) {
34084 this.smask = new PDFImage(xref, res, smask, false);
34085 } else if (mask) {
34086 if (isStream(mask)) {
34087 var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
34088 if (!imageMask) {
34089 warn('Ignoring /Mask in image without /ImageMask.');
34090 } else {
34091 this.mask = new PDFImage(xref, res, mask, false, null, null, true);
34092 }
34093 } else {
34094 // Color key mask (just an array).
34095 this.mask = mask;
34096 }
34097 }
34098 }
34099 /**
34100 * Handles processing of image data and returns the Promise that is resolved
34101 * with a PDFImage when the image is ready to be used.
34102 */
34103 PDFImage.buildImage = function PDFImage_buildImage(handler, xref,
34104 res, image, inline,
34105 nativeDecoder) {
34106 var imagePromise = handleImageData(image, nativeDecoder);
34107 var smaskPromise;
34108 var maskPromise;
34109
34110 var smask = image.dict.get('SMask');
34111 var mask = image.dict.get('Mask');
34112
34113 if (smask) {
34114 smaskPromise = handleImageData(smask, nativeDecoder);
34115 maskPromise = Promise.resolve(null);
34116 } else {
34117 smaskPromise = Promise.resolve(null);
34118 if (mask) {
34119 if (isStream(mask)) {
34120 maskPromise = handleImageData(mask, nativeDecoder);
34121 } else if (isArray(mask)) {
34122 maskPromise = Promise.resolve(mask);
34123 } else {
34124 warn('Unsupported mask format.');
34125 maskPromise = Promise.resolve(null);
34126 }
34127 } else {
34128 maskPromise = Promise.resolve(null);
34129 }
34130 }
34131 return Promise.all([imagePromise, smaskPromise, maskPromise]).then(
34132 function(results) {
34133 var imageData = results[0];
34134 var smaskData = results[1];
34135 var maskData = results[2];
34136 return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
34137 });
34138 };
34139
34140 PDFImage.createMask =
34141 function PDFImage_createMask(imgArray, width, height,
34142 imageIsFromDecodeStream, inverseDecode) {
34143
34144 // |imgArray| might not contain full data for every pixel of the mask, so
34145 // we need to distinguish between |computedLength| and |actualLength|.
34146 // In particular, if inverseDecode is true, then the array we return must
34147 // have a length of |computedLength|.
34148
34149 var computedLength = ((width + 7) >> 3) * height;
34150 var actualLength = imgArray.byteLength;
34151 var haveFullData = computedLength === actualLength;
34152 var data, i;
34153
34154 if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
34155 // imgArray came from a DecodeStream and its data is in an appropriate
34156 // form, so we can just transfer it.
34157 data = imgArray;
34158 } else if (!inverseDecode) {
34159 data = new Uint8Array(actualLength);
34160 data.set(imgArray);
34161 } else {
34162 data = new Uint8Array(computedLength);
34163 data.set(imgArray);
34164 for (i = actualLength; i < computedLength; i++) {
34165 data[i] = 0xff;
34166 }
34167 }
34168
34169 // If necessary, invert the original mask data (but not any extra we might
34170 // have added above). It's safe to modify the array -- whether it's the
34171 // original or a copy, we're about to transfer it anyway, so nothing else
34172 // in this thread can be relying on its contents.
34173 if (inverseDecode) {
34174 for (i = 0; i < actualLength; i++) {
34175 data[i] = ~data[i];
34176 }
34177 }
34178
34179 return {data: data, width: width, height: height};
34180 };
34181
34182 PDFImage.prototype = {
34183 get drawWidth() {
34184 return Math.max(this.width,
34185 this.smask && this.smask.width || 0,
34186 this.mask && this.mask.width || 0);
34187 },
34188
34189 get drawHeight() {
34190 return Math.max(this.height,
34191 this.smask && this.smask.height || 0,
34192 this.mask && this.mask.height || 0);
34193 },
34194
34195 decodeBuffer: function PDFImage_decodeBuffer(buffer) {
34196 var bpc = this.bpc;
34197 var numComps = this.numComps;
34198
34199 var decodeAddends = this.decodeAddends;
34200 var decodeCoefficients = this.decodeCoefficients;
34201 var max = (1 << bpc) - 1;
34202 var i, ii;
34203
34204 if (bpc === 1) {
34205 // If the buffer needed decode that means it just needs to be inverted.
34206 for (i = 0, ii = buffer.length; i < ii; i++) {
34207 buffer[i] = +!(buffer[i]);
34208 }
34209 return;
34210 }
34211 var index = 0;
34212 for (i = 0, ii = this.width * this.height; i < ii; i++) {
34213 for (var j = 0; j < numComps; j++) {
34214 buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j],
34215 decodeCoefficients[j], max);
34216 index++;
34217 }
34218 }
34219 },
34220
34221 getComponents: function PDFImage_getComponents(buffer) {
34222 var bpc = this.bpc;
34223
34224 // This image doesn't require any extra work.
34225 if (bpc === 8) {
34226 return buffer;
34227 }
34228
34229 var width = this.width;
34230 var height = this.height;
34231 var numComps = this.numComps;
34232
34233 var length = width * height * numComps;
34234 var bufferPos = 0;
34235 var output = (bpc <= 8 ? new Uint8Array(length) :
34236 (bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length)));
34237 var rowComps = width * numComps;
34238
34239 var max = (1 << bpc) - 1;
34240 var i = 0, ii, buf;
34241
34242 if (bpc === 1) {
34243 // Optimization for reading 1 bpc images.
34244 var mask, loop1End, loop2End;
34245 for (var j = 0; j < height; j++) {
34246 loop1End = i + (rowComps & ~7);
34247 loop2End = i + rowComps;
34248
34249 // unroll loop for all full bytes
34250 while (i < loop1End) {
34251 buf = buffer[bufferPos++];
34252 output[i] = (buf >> 7) & 1;
34253 output[i + 1] = (buf >> 6) & 1;
34254 output[i + 2] = (buf >> 5) & 1;
34255 output[i + 3] = (buf >> 4) & 1;
34256 output[i + 4] = (buf >> 3) & 1;
34257 output[i + 5] = (buf >> 2) & 1;
34258 output[i + 6] = (buf >> 1) & 1;
34259 output[i + 7] = buf & 1;
34260 i += 8;
34261 }
34262
34263 // handle remaining bits
34264 if (i < loop2End) {
34265 buf = buffer[bufferPos++];
34266 mask = 128;
34267 while (i < loop2End) {
34268 output[i++] = +!!(buf & mask);
34269 mask >>= 1;
34270 }
34271 }
34272 }
34273 } else {
34274 // The general case that handles all other bpc values.
34275 var bits = 0;
34276 buf = 0;
34277 for (i = 0, ii = length; i < ii; ++i) {
34278 if (i % rowComps === 0) {
34279 buf = 0;
34280 bits = 0;
34281 }
34282
34283 while (bits < bpc) {
34284 buf = (buf << 8) | buffer[bufferPos++];
34285 bits += 8;
34286 }
34287
34288 var remainingBits = bits - bpc;
34289 var value = buf >> remainingBits;
34290 output[i] = (value < 0 ? 0 : (value > max ? max : value));
34291 buf = buf & ((1 << remainingBits) - 1);
34292 bits = remainingBits;
34293 }
34294 }
34295 return output;
34296 },
34297
34298 fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height,
34299 actualHeight, image) {
34300 var smask = this.smask;
34301 var mask = this.mask;
34302 var alphaBuf, sw, sh, i, ii, j;
34303
34304 if (smask) {
34305 sw = smask.width;
34306 sh = smask.height;
34307 alphaBuf = new Uint8Array(sw * sh);
34308 smask.fillGrayBuffer(alphaBuf);
34309 if (sw !== width || sh !== height) {
34310 alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh,
34311 width, height);
34312 }
34313 } else if (mask) {
34314 if (mask instanceof PDFImage) {
34315 sw = mask.width;
34316 sh = mask.height;
34317 alphaBuf = new Uint8Array(sw * sh);
34318 mask.numComps = 1;
34319 mask.fillGrayBuffer(alphaBuf);
34320
34321 // Need to invert values in rgbaBuf
34322 for (i = 0, ii = sw * sh; i < ii; ++i) {
34323 alphaBuf[i] = 255 - alphaBuf[i];
34324 }
34325
34326 if (sw !== width || sh !== height) {
34327 alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh,
34328 width, height);
34329 }
34330 } else if (isArray(mask)) {
34331 // Color key mask: if any of the components are outside the range
34332 // then they should be painted.
34333 alphaBuf = new Uint8Array(width * height);
34334 var numComps = this.numComps;
34335 for (i = 0, ii = width * height; i < ii; ++i) {
34336 var opacity = 0;
34337 var imageOffset = i * numComps;
34338 for (j = 0; j < numComps; ++j) {
34339 var color = image[imageOffset + j];
34340 var maskOffset = j * 2;
34341 if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
34342 opacity = 255;
34343 break;
34344 }
34345 }
34346 alphaBuf[i] = opacity;
34347 }
34348 } else {
34349 error('Unknown mask format.');
34350 }
34351 }
34352
34353 if (alphaBuf) {
34354 for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
34355 rgbaBuf[j] = alphaBuf[i];
34356 }
34357 } else {
34358 // No mask.
34359 for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
34360 rgbaBuf[j] = 255;
34361 }
34362 }
34363 },
34364
34365 undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
34366 var matte = this.smask && this.smask.matte;
34367 if (!matte) {
34368 return;
34369 }
34370 var matteRgb = this.colorSpace.getRgb(matte, 0);
34371 var matteR = matteRgb[0];
34372 var matteG = matteRgb[1];
34373 var matteB = matteRgb[2];
34374 var length = width * height * 4;
34375 var r, g, b;
34376 for (var i = 0; i < length; i += 4) {
34377 var alpha = buffer[i + 3];
34378 if (alpha === 0) {
34379 // according formula we have to get Infinity in all components
34380 // making it white (typical paper color) should be okay
34381 buffer[i] = 255;
34382 buffer[i + 1] = 255;
34383 buffer[i + 2] = 255;
34384 continue;
34385 }
34386 var k = 255 / alpha;
34387 r = (buffer[i] - matteR) * k + matteR;
34388 g = (buffer[i + 1] - matteG) * k + matteG;
34389 b = (buffer[i + 2] - matteB) * k + matteB;
34390 buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
34391 buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
34392 buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
34393 }
34394 },
34395
34396 createImageData: function PDFImage_createImageData(forceRGBA) {
34397 var drawWidth = this.drawWidth;
34398 var drawHeight = this.drawHeight;
34399 var imgData = { // other fields are filled in below
34400 width: drawWidth,
34401 height: drawHeight
34402 };
34403
34404 var numComps = this.numComps;
34405 var originalWidth = this.width;
34406 var originalHeight = this.height;
34407 var bpc = this.bpc;
34408
34409 // Rows start at byte boundary.
34410 var rowBytes = (originalWidth * numComps * bpc + 7) >> 3;
34411 var imgArray;
34412
34413 if (!forceRGBA) {
34414 // If it is a 1-bit-per-pixel grayscale (i.e. black-and-white) image
34415 // without any complications, we pass a same-sized copy to the main
34416 // thread rather than expanding by 32x to RGBA form. This saves *lots*
34417 // of memory for many scanned documents. It's also much faster.
34418 //
34419 // Similarly, if it is a 24-bit-per pixel RGB image without any
34420 // complications, we avoid expanding by 1.333x to RGBA form.
34421 var kind;
34422 if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
34423 kind = ImageKind.GRAYSCALE_1BPP;
34424 } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 &&
34425 !this.needsDecode) {
34426 kind = ImageKind.RGB_24BPP;
34427 }
34428 if (kind && !this.smask && !this.mask &&
34429 drawWidth === originalWidth && drawHeight === originalHeight) {
34430 imgData.kind = kind;
34431
34432 imgArray = this.getImageBytes(originalHeight * rowBytes);
34433 // If imgArray came from a DecodeStream, we're safe to transfer it
34434 // (and thus detach its underlying buffer) because it will constitute
34435 // the entire DecodeStream's data. But if it came from a Stream, we
34436 // need to copy it because it'll only be a portion of the Stream's
34437 // data, and the rest will be read later on.
34438 if (this.image instanceof DecodeStream) {
34439 imgData.data = imgArray;
34440 } else {
34441 var newArray = new Uint8Array(imgArray.length);
34442 newArray.set(imgArray);
34443 imgData.data = newArray;
34444 }
34445 if (this.needsDecode) {
34446 // Invert the buffer (which must be grayscale if we reached here).
34447 assert(kind === ImageKind.GRAYSCALE_1BPP);
34448 var buffer = imgData.data;
34449 for (var i = 0, ii = buffer.length; i < ii; i++) {
34450 buffer[i] ^= 0xff;
34451 }
34452 }
34453 return imgData;
34454 }
34455 if (this.image instanceof JpegStream && !this.smask && !this.mask &&
34456 (this.colorSpace.name === 'DeviceGray' ||
34457 this.colorSpace.name === 'DeviceRGB' ||
34458 this.colorSpace.name === 'DeviceCMYK')) {
34459 imgData.kind = ImageKind.RGB_24BPP;
34460 imgData.data = this.getImageBytes(originalHeight * rowBytes,
34461 drawWidth, drawHeight, true);
34462 return imgData;
34463 }
34464 }
34465
34466 imgArray = this.getImageBytes(originalHeight * rowBytes);
34467 // imgArray can be incomplete (e.g. after CCITT fax encoding).
34468 var actualHeight = 0 | (imgArray.length / rowBytes *
34469 drawHeight / originalHeight);
34470
34471 var comps = this.getComponents(imgArray);
34472
34473 // If opacity data is present, use RGBA_32BPP form. Otherwise, use the
34474 // more compact RGB_24BPP form if allowable.
34475 var alpha01, maybeUndoPreblend;
34476 if (!forceRGBA && !this.smask && !this.mask) {
34477 imgData.kind = ImageKind.RGB_24BPP;
34478 imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
34479 alpha01 = 0;
34480 maybeUndoPreblend = false;
34481 } else {
34482 imgData.kind = ImageKind.RGBA_32BPP;
34483 imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
34484 alpha01 = 1;
34485 maybeUndoPreblend = true;
34486
34487 // Color key masking (opacity) must be performed before decoding.
34488 this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight,
34489 comps);
34490 }
34491
34492 if (this.needsDecode) {
34493 this.decodeBuffer(comps);
34494 }
34495 this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight,
34496 drawWidth, drawHeight, actualHeight, bpc, comps,
34497 alpha01);
34498 if (maybeUndoPreblend) {
34499 this.undoPreblend(imgData.data, drawWidth, actualHeight);
34500 }
34501
34502 return imgData;
34503 },
34504
34505 fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
34506 var numComps = this.numComps;
34507 if (numComps !== 1) {
34508 error('Reading gray scale from a color image: ' + numComps);
34509 }
34510
34511 var width = this.width;
34512 var height = this.height;
34513 var bpc = this.bpc;
34514
34515 // rows start at byte boundary
34516 var rowBytes = (width * numComps * bpc + 7) >> 3;
34517 var imgArray = this.getImageBytes(height * rowBytes);
34518
34519 var comps = this.getComponents(imgArray);
34520 var i, length;
34521
34522 if (bpc === 1) {
34523 // inline decoding (= inversion) for 1 bpc images
34524 length = width * height;
34525 if (this.needsDecode) {
34526 // invert and scale to {0, 255}
34527 for (i = 0; i < length; ++i) {
34528 buffer[i] = (comps[i] - 1) & 255;
34529 }
34530 } else {
34531 // scale to {0, 255}
34532 for (i = 0; i < length; ++i) {
34533 buffer[i] = (-comps[i]) & 255;
34534 }
34535 }
34536 return;
34537 }
34538
34539 if (this.needsDecode) {
34540 this.decodeBuffer(comps);
34541 }
34542 length = width * height;
34543 // we aren't using a colorspace so we need to scale the value
34544 var scale = 255 / ((1 << bpc) - 1);
34545 for (i = 0; i < length; ++i) {
34546 buffer[i] = (scale * comps[i]) | 0;
34547 }
34548 },
34549
34550 getImageBytes: function PDFImage_getImageBytes(length,
34551 drawWidth, drawHeight,
34552 forceRGB) {
34553 this.image.reset();
34554 this.image.drawWidth = drawWidth || this.width;
34555 this.image.drawHeight = drawHeight || this.height;
34556 this.image.forceRGB = !!forceRGB;
34557 return this.image.getBytes(length);
34558 }
34559 };
34560 return PDFImage;
34561})();
34562
34563exports.PDFImage = PDFImage;
34564}));
34565
34566
34567(function (root, factory) {
34568 {
34569 factory((root.pdfjsCoreObj = {}), root.pdfjsSharedUtil,
34570 root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser,
34571 root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
34572 }
34573}(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser,
34574 coreChunkedStream, coreColorSpace) {
34575
34576var InvalidPDFException = sharedUtil.InvalidPDFException;
34577var MissingDataException = sharedUtil.MissingDataException;
34578var XRefParseException = sharedUtil.XRefParseException;
34579var assert = sharedUtil.assert;
34580var bytesToString = sharedUtil.bytesToString;
34581var createPromiseCapability = sharedUtil.createPromiseCapability;
34582var error = sharedUtil.error;
34583var info = sharedUtil.info;
34584var isArray = sharedUtil.isArray;
34585var isInt = sharedUtil.isInt;
34586var isString = sharedUtil.isString;
34587var shadow = sharedUtil.shadow;
34588var stringToPDFString = sharedUtil.stringToPDFString;
34589var stringToUTF8String = sharedUtil.stringToUTF8String;
34590var warn = sharedUtil.warn;
34591var isValidUrl = sharedUtil.isValidUrl;
34592var Util = sharedUtil.Util;
34593var Ref = corePrimitives.Ref;
34594var RefSet = corePrimitives.RefSet;
34595var RefSetCache = corePrimitives.RefSetCache;
34596var isName = corePrimitives.isName;
34597var isCmd = corePrimitives.isCmd;
34598var isDict = corePrimitives.isDict;
34599var isRef = corePrimitives.isRef;
34600var isRefsEqual = corePrimitives.isRefsEqual;
34601var isStream = corePrimitives.isStream;
34602var CipherTransformFactory = coreCrypto.CipherTransformFactory;
34603var Lexer = coreParser.Lexer;
34604var Parser = coreParser.Parser;
34605var ChunkedStream = coreChunkedStream.ChunkedStream;
34606var ColorSpace = coreColorSpace.ColorSpace;
34607
34608var Catalog = (function CatalogClosure() {
34609 function Catalog(pdfManager, xref, pageFactory) {
34610 this.pdfManager = pdfManager;
34611 this.xref = xref;
34612 this.catDict = xref.getCatalogObj();
34613 this.fontCache = new RefSetCache();
34614 assert(isDict(this.catDict),
34615 'catalog object is not a dictionary');
34616
34617 // TODO refactor to move getPage() to the PDFDocument.
34618 this.pageFactory = pageFactory;
34619 this.pagePromises = [];
34620 }
34621
34622 Catalog.prototype = {
34623 get metadata() {
34624 var streamRef = this.catDict.getRaw('Metadata');
34625 if (!isRef(streamRef)) {
34626 return shadow(this, 'metadata', null);
34627 }
34628
34629 var encryptMetadata = (!this.xref.encrypt ? false :
34630 this.xref.encrypt.encryptMetadata);
34631
34632 var stream = this.xref.fetch(streamRef, !encryptMetadata);
34633 var metadata;
34634 if (stream && isDict(stream.dict)) {
34635 var type = stream.dict.get('Type');
34636 var subtype = stream.dict.get('Subtype');
34637
34638 if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
34639 // XXX: This should examine the charset the XML document defines,
34640 // however since there are currently no real means to decode
34641 // arbitrary charsets, let's just hope that the author of the PDF
34642 // was reasonable enough to stick with the XML default charset,
34643 // which is UTF-8.
34644 try {
34645 metadata = stringToUTF8String(bytesToString(stream.getBytes()));
34646 } catch (e) {
34647 info('Skipping invalid metadata.');
34648 }
34649 }
34650 }
34651
34652 return shadow(this, 'metadata', metadata);
34653 },
34654 get toplevelPagesDict() {
34655 var pagesObj = this.catDict.get('Pages');
34656 assert(isDict(pagesObj), 'invalid top-level pages dictionary');
34657 // shadow the prototype getter
34658 return shadow(this, 'toplevelPagesDict', pagesObj);
34659 },
34660 get documentOutline() {
34661 var obj = null;
34662 try {
34663 obj = this.readDocumentOutline();
34664 } catch (ex) {
34665 if (ex instanceof MissingDataException) {
34666 throw ex;
34667 }
34668 warn('Unable to read document outline');
34669 }
34670 return shadow(this, 'documentOutline', obj);
34671 },
34672 readDocumentOutline: function Catalog_readDocumentOutline() {
34673 var obj = this.catDict.get('Outlines');
34674 if (!isDict(obj)) {
34675 return null;
34676 }
34677 obj = obj.getRaw('First');
34678 if (!isRef(obj)) {
34679 return null;
34680 }
34681 var root = { items: [] };
34682 var queue = [{obj: obj, parent: root}];
34683 // To avoid recursion, keep track of the already processed items.
34684 var processed = new RefSet();
34685 processed.put(obj);
34686 var xref = this.xref, blackColor = new Uint8Array(3);
34687
34688 while (queue.length > 0) {
34689 var i = queue.shift();
34690 var outlineDict = xref.fetchIfRef(i.obj);
34691 if (outlineDict === null) {
34692 continue;
34693 }
34694 assert(outlineDict.has('Title'), 'Invalid outline item');
34695
34696 var actionDict = outlineDict.get('A'), dest = null, url = null;
34697 if (actionDict) {
34698 var destEntry = actionDict.get('D');
34699 if (destEntry) {
34700 dest = destEntry;
34701 } else {
34702 var uriEntry = actionDict.get('URI');
34703 if (isString(uriEntry) && isValidUrl(uriEntry, false)) {
34704 url = uriEntry;
34705 }
34706 }
34707 } else if (outlineDict.has('Dest')) {
34708 dest = outlineDict.getRaw('Dest');
34709 if (isName(dest)) {
34710 dest = dest.name;
34711 }
34712 }
34713 var title = outlineDict.get('Title');
34714 var flags = outlineDict.get('F') || 0;
34715
34716 var color = outlineDict.getArray('C'), rgbColor = blackColor;
34717 // We only need to parse the color when it's valid, and non-default.
34718 if (isArray(color) && color.length === 3 &&
34719 (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
34720 rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
34721 }
34722 var outlineItem = {
34723 dest: dest,
34724 url: url,
34725 title: stringToPDFString(title),
34726 color: rgbColor,
34727 count: outlineDict.get('Count'),
34728 bold: !!(flags & 2),
34729 italic: !!(flags & 1),
34730 items: []
34731 };
34732 i.parent.items.push(outlineItem);
34733 obj = outlineDict.getRaw('First');
34734 if (isRef(obj) && !processed.has(obj)) {
34735 queue.push({obj: obj, parent: outlineItem});
34736 processed.put(obj);
34737 }
34738 obj = outlineDict.getRaw('Next');
34739 if (isRef(obj) && !processed.has(obj)) {
34740 queue.push({obj: obj, parent: i.parent});
34741 processed.put(obj);
34742 }
34743 }
34744 return (root.items.length > 0 ? root.items : null);
34745 },
34746 get numPages() {
34747 var obj = this.toplevelPagesDict.get('Count');
34748 assert(
34749 isInt(obj),
34750 'page count in top level pages object is not an integer'
34751 );
34752 // shadow the prototype getter
34753 return shadow(this, 'num', obj);
34754 },
34755 get destinations() {
34756 function fetchDestination(dest) {
34757 return isDict(dest) ? dest.get('D') : dest;
34758 }
34759
34760 var xref = this.xref;
34761 var dests = {}, nameTreeRef, nameDictionaryRef;
34762 var obj = this.catDict.get('Names');
34763 if (obj && obj.has('Dests')) {
34764 nameTreeRef = obj.getRaw('Dests');
34765 } else if (this.catDict.has('Dests')) {
34766 nameDictionaryRef = this.catDict.get('Dests');
34767 }
34768
34769 if (nameDictionaryRef) {
34770 // reading simple destination dictionary
34771 obj = nameDictionaryRef;
34772 obj.forEach(function catalogForEach(key, value) {
34773 if (!value) {
34774 return;
34775 }
34776 dests[key] = fetchDestination(value);
34777 });
34778 }
34779 if (nameTreeRef) {
34780 var nameTree = new NameTree(nameTreeRef, xref);
34781 var names = nameTree.getAll();
34782 for (var name in names) {
34783 dests[name] = fetchDestination(names[name]);
34784 }
34785 }
34786 return shadow(this, 'destinations', dests);
34787 },
34788 getDestination: function Catalog_getDestination(destinationId) {
34789 function fetchDestination(dest) {
34790 return isDict(dest) ? dest.get('D') : dest;
34791 }
34792
34793 var xref = this.xref;
34794 var dest = null, nameTreeRef, nameDictionaryRef;
34795 var obj = this.catDict.get('Names');
34796 if (obj && obj.has('Dests')) {
34797 nameTreeRef = obj.getRaw('Dests');
34798 } else if (this.catDict.has('Dests')) {
34799 nameDictionaryRef = this.catDict.get('Dests');
34800 }
34801
34802 if (nameDictionaryRef) { // Simple destination dictionary.
34803 var value = nameDictionaryRef.get(destinationId);
34804 if (value) {
34805 dest = fetchDestination(value);
34806 }
34807 }
34808 if (nameTreeRef) {
34809 var nameTree = new NameTree(nameTreeRef, xref);
34810 dest = fetchDestination(nameTree.get(destinationId));
34811 }
34812 return dest;
34813 },
34814
34815 get pageLabels() {
34816 var obj = null;
34817 try {
34818 obj = this.readPageLabels();
34819 } catch (ex) {
34820 if (ex instanceof MissingDataException) {
34821 throw ex;
34822 }
34823 warn('Unable to read page labels.');
34824 }
34825 return shadow(this, 'pageLabels', obj);
34826 },
34827 readPageLabels: function Catalog_readPageLabels() {
34828 var obj = this.catDict.getRaw('PageLabels');
34829 if (!obj) {
34830 return null;
34831 }
34832 var pageLabels = new Array(this.numPages);
34833 var style = null;
34834 var prefix = '';
34835 var start = 1;
34836
34837 var numberTree = new NumberTree(obj, this.xref);
34838 var nums = numberTree.getAll();
34839 var currentLabel = '', currentIndex = 1;
34840
34841 for (var i = 0, ii = this.numPages; i < ii; i++) {
34842 if (i in nums) {
34843 var labelDict = nums[i];
34844 assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
34845
34846 var type = labelDict.get('Type');
34847 assert(!type || isName(type, 'PageLabel'),
34848 'Invalid type in PageLabel dictionary.');
34849
34850 var s = labelDict.get('S');
34851 assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
34852 style = (s ? s.name : null);
34853
34854 prefix = labelDict.get('P') || '';
34855 assert(isString(prefix), 'Invalid prefix in PageLabel dictionary.');
34856
34857 start = labelDict.get('St') || 1;
34858 assert(isInt(start), 'Invalid start in PageLabel dictionary.');
34859 currentIndex = start;
34860 }
34861
34862 switch (style) {
34863 case 'D':
34864 currentLabel = currentIndex;
34865 break;
34866 case 'R':
34867 case 'r':
34868 currentLabel = Util.toRoman(currentIndex, style === 'r');
34869 break;
34870 case 'A':
34871 case 'a':
34872 var LIMIT = 26; // Use only the characters A--Z, or a--z.
34873 var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
34874
34875 var baseCharCode = (style === 'a' ? A_LOWER_CASE : A_UPPER_CASE);
34876 var letterIndex = currentIndex - 1;
34877 var character = String.fromCharCode(baseCharCode +
34878 (letterIndex % LIMIT));
34879 var charBuf = [];
34880 for (var j = 0, jj = (letterIndex / LIMIT) | 0; j <= jj; j++) {
34881 charBuf.push(character);
34882 }
34883 currentLabel = charBuf.join('');
34884 break;
34885 default:
34886 assert(!style,
34887 'Invalid style "' + style + '" in PageLabel dictionary.');
34888 }
34889 pageLabels[i] = prefix + currentLabel;
34890
34891 currentLabel = '';
34892 currentIndex++;
34893 }
34894 return pageLabels;
34895 },
34896
34897 get attachments() {
34898 var xref = this.xref;
34899 var attachments = null, nameTreeRef;
34900 var obj = this.catDict.get('Names');
34901 if (obj) {
34902 nameTreeRef = obj.getRaw('EmbeddedFiles');
34903 }
34904
34905 if (nameTreeRef) {
34906 var nameTree = new NameTree(nameTreeRef, xref);
34907 var names = nameTree.getAll();
34908 for (var name in names) {
34909 var fs = new FileSpec(names[name], xref);
34910 if (!attachments) {
34911 attachments = Object.create(null);
34912 }
34913 attachments[stringToPDFString(name)] = fs.serializable;
34914 }
34915 }
34916 return shadow(this, 'attachments', attachments);
34917 },
34918 get javaScript() {
34919 var xref = this.xref;
34920 var obj = this.catDict.get('Names');
34921
34922 var javaScript = [];
34923 function appendIfJavaScriptDict(jsDict) {
34924 var type = jsDict.get('S');
34925 if (!isName(type, 'JavaScript')) {
34926 return;
34927 }
34928 var js = jsDict.get('JS');
34929 if (isStream(js)) {
34930 js = bytesToString(js.getBytes());
34931 } else if (!isString(js)) {
34932 return;
34933 }
34934 javaScript.push(stringToPDFString(js));
34935 }
34936 if (obj && obj.has('JavaScript')) {
34937 var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
34938 var names = nameTree.getAll();
34939 for (var name in names) {
34940 // We don't really use the JavaScript right now. This code is
34941 // defensive so we don't cause errors on document load.
34942 var jsDict = names[name];
34943 if (isDict(jsDict)) {
34944 appendIfJavaScriptDict(jsDict);
34945 }
34946 }
34947 }
34948
34949 // Append OpenAction actions to javaScript array
34950 var openactionDict = this.catDict.get('OpenAction');
34951 if (isDict(openactionDict, 'Action')) {
34952 var actionType = openactionDict.get('S');
34953 if (isName(actionType, 'Named')) {
34954 // The named Print action is not a part of the PDF 1.7 specification,
34955 // but is supported by many PDF readers/writers (including Adobe's).
34956 var action = openactionDict.get('N');
34957 if (isName(action, 'Print')) {
34958 javaScript.push('print({});');
34959 }
34960 } else {
34961 appendIfJavaScriptDict(openactionDict);
34962 }
34963 }
34964
34965 return shadow(this, 'javaScript', javaScript);
34966 },
34967
34968 cleanup: function Catalog_cleanup() {
34969 var promises = [];
34970 this.fontCache.forEach(function (promise) {
34971 promises.push(promise);
34972 });
34973 return Promise.all(promises).then(function (translatedFonts) {
34974 for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
34975 var font = translatedFonts[i].dict;
34976 delete font.translated;
34977 }
34978 this.fontCache.clear();
34979 }.bind(this));
34980 },
34981
34982 getPage: function Catalog_getPage(pageIndex) {
34983 if (!(pageIndex in this.pagePromises)) {
34984 this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(
34985 function (a) {
34986 var dict = a[0];
34987 var ref = a[1];
34988 return this.pageFactory.createPage(pageIndex, dict, ref,
34989 this.fontCache);
34990 }.bind(this)
34991 );
34992 }
34993 return this.pagePromises[pageIndex];
34994 },
34995
34996 getPageDict: function Catalog_getPageDict(pageIndex) {
34997 var capability = createPromiseCapability();
34998 var nodesToVisit = [this.catDict.getRaw('Pages')];
34999 var currentPageIndex = 0;
35000 var xref = this.xref;
35001 var checkAllKids = false;
35002
35003 function next() {
35004 while (nodesToVisit.length) {
35005 var currentNode = nodesToVisit.pop();
35006
35007 if (isRef(currentNode)) {
35008 xref.fetchAsync(currentNode).then(function (obj) {
35009 if (isDict(obj, 'Page') || (isDict(obj) && !obj.has('Kids'))) {
35010 if (pageIndex === currentPageIndex) {
35011 capability.resolve([obj, currentNode]);
35012 } else {
35013 currentPageIndex++;
35014 next();
35015 }
35016 return;
35017 }
35018 nodesToVisit.push(obj);
35019 next();
35020 }, capability.reject);
35021 return;
35022 }
35023
35024 // Must be a child page dictionary.
35025 assert(
35026 isDict(currentNode),
35027 'page dictionary kid reference points to wrong type of object'
35028 );
35029 var count = currentNode.get('Count');
35030 // If the current node doesn't have any children, avoid getting stuck
35031 // in an empty node further down in the tree (see issue5644.pdf).
35032 if (count === 0) {
35033 checkAllKids = true;
35034 }
35035 // Skip nodes where the page can't be.
35036 if (currentPageIndex + count <= pageIndex) {
35037 currentPageIndex += count;
35038 continue;
35039 }
35040
35041 var kids = currentNode.get('Kids');
35042 assert(isArray(kids), 'page dictionary kids object is not an array');
35043 if (!checkAllKids && count === kids.length) {
35044 // Nodes that don't have the page have been skipped and this is the
35045 // bottom of the tree which means the page requested must be a
35046 // descendant of this pages node. Ideally we would just resolve the
35047 // promise with the page ref here, but there is the case where more
35048 // pages nodes could link to single a page (see issue 3666 pdf). To
35049 // handle this push it back on the queue so if it is a pages node it
35050 // will be descended into.
35051 nodesToVisit = [kids[pageIndex - currentPageIndex]];
35052 currentPageIndex = pageIndex;
35053 continue;
35054 } else {
35055 for (var last = kids.length - 1; last >= 0; last--) {
35056 nodesToVisit.push(kids[last]);
35057 }
35058 }
35059 }
35060 capability.reject('Page index ' + pageIndex + ' not found.');
35061 }
35062 next();
35063 return capability.promise;
35064 },
35065
35066 getPageIndex: function Catalog_getPageIndex(pageRef) {
35067 // The page tree nodes have the count of all the leaves below them. To get
35068 // how many pages are before we just have to walk up the tree and keep
35069 // adding the count of siblings to the left of the node.
35070 var xref = this.xref;
35071 function pagesBeforeRef(kidRef) {
35072 var total = 0;
35073 var parentRef;
35074 return xref.fetchAsync(kidRef).then(function (node) {
35075 if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') &&
35076 !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
35077 throw new Error('The reference does not point to a /Page Dict.');
35078 }
35079 if (!node) {
35080 return null;
35081 }
35082 assert(isDict(node), 'node must be a Dict.');
35083 parentRef = node.getRaw('Parent');
35084 return node.getAsync('Parent');
35085 }).then(function (parent) {
35086 if (!parent) {
35087 return null;
35088 }
35089 assert(isDict(parent), 'parent must be a Dict.');
35090 return parent.getAsync('Kids');
35091 }).then(function (kids) {
35092 if (!kids) {
35093 return null;
35094 }
35095 var kidPromises = [];
35096 var found = false;
35097 for (var i = 0; i < kids.length; i++) {
35098 var kid = kids[i];
35099 assert(isRef(kid), 'kid must be a Ref.');
35100 if (kid.num === kidRef.num) {
35101 found = true;
35102 break;
35103 }
35104 kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
35105 if (kid.has('Count')) {
35106 var count = kid.get('Count');
35107 total += count;
35108 } else { // page leaf node
35109 total++;
35110 }
35111 }));
35112 }
35113 if (!found) {
35114 error('kid ref not found in parents kids');
35115 }
35116 return Promise.all(kidPromises).then(function () {
35117 return [total, parentRef];
35118 });
35119 });
35120 }
35121
35122 var total = 0;
35123 function next(ref) {
35124 return pagesBeforeRef(ref).then(function (args) {
35125 if (!args) {
35126 return total;
35127 }
35128 var count = args[0];
35129 var parentRef = args[1];
35130 total += count;
35131 return next(parentRef);
35132 });
35133 }
35134
35135 return next(pageRef);
35136 }
35137 };
35138
35139 return Catalog;
35140})();
35141
35142var XRef = (function XRefClosure() {
35143 function XRef(stream, password) {
35144 this.stream = stream;
35145 this.entries = [];
35146 this.xrefstms = Object.create(null);
35147 // prepare the XRef cache
35148 this.cache = [];
35149 this.password = password;
35150 this.stats = {
35151 streamTypes: [],
35152 fontTypes: []
35153 };
35154 }
35155
35156 XRef.prototype = {
35157 setStartXRef: function XRef_setStartXRef(startXRef) {
35158 // Store the starting positions of xref tables as we process them
35159 // so we can recover from missing data errors
35160 this.startXRefQueue = [startXRef];
35161 },
35162
35163 parse: function XRef_parse(recoveryMode) {
35164 var trailerDict;
35165 if (!recoveryMode) {
35166 trailerDict = this.readXRef();
35167 } else {
35168 warn('Indexing all PDF objects');
35169 trailerDict = this.indexObjects();
35170 }
35171 trailerDict.assignXref(this);
35172 this.trailer = trailerDict;
35173 var encrypt = trailerDict.get('Encrypt');
35174 if (encrypt) {
35175 var ids = trailerDict.get('ID');
35176 var fileId = (ids && ids.length) ? ids[0] : '';
35177 this.encrypt = new CipherTransformFactory(encrypt, fileId,
35178 this.password);
35179 }
35180
35181 // get the root dictionary (catalog) object
35182 if (!(this.root = trailerDict.get('Root'))) {
35183 error('Invalid root reference');
35184 }
35185 },
35186
35187 processXRefTable: function XRef_processXRefTable(parser) {
35188 if (!('tableState' in this)) {
35189 // Stores state of the table as we process it so we can resume
35190 // from middle of table in case of missing data error
35191 this.tableState = {
35192 entryNum: 0,
35193 streamPos: parser.lexer.stream.pos,
35194 parserBuf1: parser.buf1,
35195 parserBuf2: parser.buf2
35196 };
35197 }
35198
35199 var obj = this.readXRefTable(parser);
35200
35201 // Sanity check
35202 if (!isCmd(obj, 'trailer')) {
35203 error('Invalid XRef table: could not find trailer dictionary');
35204 }
35205 // Read trailer dictionary, e.g.
35206 // trailer
35207 // << /Size 22
35208 // /Root 20R
35209 // /Info 10R
35210 // /ID [ <81b14aafa313db63dbd6f981e49f94f4> ]
35211 // >>
35212 // The parser goes through the entire stream << ... >> and provides
35213 // a getter interface for the key-value table
35214 var dict = parser.getObj();
35215
35216 // The pdflib PDF generator can generate a nested trailer dictionary
35217 if (!isDict(dict) && dict.dict) {
35218 dict = dict.dict;
35219 }
35220 if (!isDict(dict)) {
35221 error('Invalid XRef table: could not parse trailer dictionary');
35222 }
35223 delete this.tableState;
35224
35225 return dict;
35226 },
35227
35228 readXRefTable: function XRef_readXRefTable(parser) {
35229 // Example of cross-reference table:
35230 // xref
35231 // 0 1 <-- subsection header (first obj #, obj count)
35232 // 0000000000 65535 f <-- actual object (offset, generation #, f/n)
35233 // 23 2 <-- subsection header ... and so on ...
35234 // 0000025518 00002 n
35235 // 0000025635 00000 n
35236 // trailer
35237 // ...
35238
35239 var stream = parser.lexer.stream;
35240 var tableState = this.tableState;
35241 stream.pos = tableState.streamPos;
35242 parser.buf1 = tableState.parserBuf1;
35243 parser.buf2 = tableState.parserBuf2;
35244
35245 // Outer loop is over subsection headers
35246 var obj;
35247
35248 while (true) {
35249 if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
35250 if (isCmd(obj = parser.getObj(), 'trailer')) {
35251 break;
35252 }
35253 tableState.firstEntryNum = obj;
35254 tableState.entryCount = parser.getObj();
35255 }
35256
35257 var first = tableState.firstEntryNum;
35258 var count = tableState.entryCount;
35259 if (!isInt(first) || !isInt(count)) {
35260 error('Invalid XRef table: wrong types in subsection header');
35261 }
35262 // Inner loop is over objects themselves
35263 for (var i = tableState.entryNum; i < count; i++) {
35264 tableState.streamPos = stream.pos;
35265 tableState.entryNum = i;
35266 tableState.parserBuf1 = parser.buf1;
35267 tableState.parserBuf2 = parser.buf2;
35268
35269 var entry = {};
35270 entry.offset = parser.getObj();
35271 entry.gen = parser.getObj();
35272 var type = parser.getObj();
35273
35274 if (isCmd(type, 'f')) {
35275 entry.free = true;
35276 } else if (isCmd(type, 'n')) {
35277 entry.uncompressed = true;
35278 }
35279
35280 // Validate entry obj
35281 if (!isInt(entry.offset) || !isInt(entry.gen) ||
35282 !(entry.free || entry.uncompressed)) {
35283 error('Invalid entry in XRef subsection: ' + first + ', ' + count);
35284 }
35285
35286 // The first xref table entry, i.e. obj 0, should be free. Attempting
35287 // to adjust an incorrect first obj # (fixes issue 3248 and 7229).
35288 if (i === 0 && entry.free && first === 1) {
35289 first = 0;
35290 }
35291
35292 if (!this.entries[i + first]) {
35293 this.entries[i + first] = entry;
35294 }
35295 }
35296
35297 tableState.entryNum = 0;
35298 tableState.streamPos = stream.pos;
35299 tableState.parserBuf1 = parser.buf1;
35300 tableState.parserBuf2 = parser.buf2;
35301 delete tableState.firstEntryNum;
35302 delete tableState.entryCount;
35303 }
35304
35305 // Sanity check: as per spec, first object must be free
35306 if (this.entries[0] && !this.entries[0].free) {
35307 error('Invalid XRef table: unexpected first object');
35308 }
35309 return obj;
35310 },
35311
35312 processXRefStream: function XRef_processXRefStream(stream) {
35313 if (!('streamState' in this)) {
35314 // Stores state of the stream as we process it so we can resume
35315 // from middle of stream in case of missing data error
35316 var streamParameters = stream.dict;
35317 var byteWidths = streamParameters.get('W');
35318 var range = streamParameters.get('Index');
35319 if (!range) {
35320 range = [0, streamParameters.get('Size')];
35321 }
35322
35323 this.streamState = {
35324 entryRanges: range,
35325 byteWidths: byteWidths,
35326 entryNum: 0,
35327 streamPos: stream.pos
35328 };
35329 }
35330 this.readXRefStream(stream);
35331 delete this.streamState;
35332
35333 return stream.dict;
35334 },
35335
35336 readXRefStream: function XRef_readXRefStream(stream) {
35337 var i, j;
35338 var streamState = this.streamState;
35339 stream.pos = streamState.streamPos;
35340
35341 var byteWidths = streamState.byteWidths;
35342 var typeFieldWidth = byteWidths[0];
35343 var offsetFieldWidth = byteWidths[1];
35344 var generationFieldWidth = byteWidths[2];
35345
35346 var entryRanges = streamState.entryRanges;
35347 while (entryRanges.length > 0) {
35348 var first = entryRanges[0];
35349 var n = entryRanges[1];
35350
35351 if (!isInt(first) || !isInt(n)) {
35352 error('Invalid XRef range fields: ' + first + ', ' + n);
35353 }
35354 if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) ||
35355 !isInt(generationFieldWidth)) {
35356 error('Invalid XRef entry fields length: ' + first + ', ' + n);
35357 }
35358 for (i = streamState.entryNum; i < n; ++i) {
35359 streamState.entryNum = i;
35360 streamState.streamPos = stream.pos;
35361
35362 var type = 0, offset = 0, generation = 0;
35363 for (j = 0; j < typeFieldWidth; ++j) {
35364 type = (type << 8) | stream.getByte();
35365 }
35366 // if type field is absent, its default value is 1
35367 if (typeFieldWidth === 0) {
35368 type = 1;
35369 }
35370 for (j = 0; j < offsetFieldWidth; ++j) {
35371 offset = (offset << 8) | stream.getByte();
35372 }
35373 for (j = 0; j < generationFieldWidth; ++j) {
35374 generation = (generation << 8) | stream.getByte();
35375 }
35376 var entry = {};
35377 entry.offset = offset;
35378 entry.gen = generation;
35379 switch (type) {
35380 case 0:
35381 entry.free = true;
35382 break;
35383 case 1:
35384 entry.uncompressed = true;
35385 break;
35386 case 2:
35387 break;
35388 default:
35389 error('Invalid XRef entry type: ' + type);
35390 }
35391 if (!this.entries[first + i]) {
35392 this.entries[first + i] = entry;
35393 }
35394 }
35395
35396 streamState.entryNum = 0;
35397 streamState.streamPos = stream.pos;
35398 entryRanges.splice(0, 2);
35399 }
35400 },
35401
35402 indexObjects: function XRef_indexObjects() {
35403 // Simple scan through the PDF content to find objects,
35404 // trailers and XRef streams.
35405 var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
35406 var PERCENT = 0x25, LT = 0x3C;
35407
35408 function readToken(data, offset) {
35409 var token = '', ch = data[offset];
35410 while (ch !== LF && ch !== CR && ch !== LT) {
35411 if (++offset >= data.length) {
35412 break;
35413 }
35414 token += String.fromCharCode(ch);
35415 ch = data[offset];
35416 }
35417 return token;
35418 }
35419 function skipUntil(data, offset, what) {
35420 var length = what.length, dataLength = data.length;
35421 var skipped = 0;
35422 // finding byte sequence
35423 while (offset < dataLength) {
35424 var i = 0;
35425 while (i < length && data[offset + i] === what[i]) {
35426 ++i;
35427 }
35428 if (i >= length) {
35429 break; // sequence found
35430 }
35431 offset++;
35432 skipped++;
35433 }
35434 return skipped;
35435 }
35436 var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
35437 var trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]);
35438 var startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114,
35439 101, 102]);
35440 var endobjBytes = new Uint8Array([101, 110, 100, 111, 98, 106]);
35441 var xrefBytes = new Uint8Array([47, 88, 82, 101, 102]);
35442
35443 // Clear out any existing entries, since they may be bogus.
35444 this.entries.length = 0;
35445
35446 var stream = this.stream;
35447 stream.pos = 0;
35448 var buffer = stream.getBytes();
35449 var position = stream.start, length = buffer.length;
35450 var trailers = [], xrefStms = [];
35451 while (position < length) {
35452 var ch = buffer[position];
35453 if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
35454 ++position;
35455 continue;
35456 }
35457 if (ch === PERCENT) { // %-comment
35458 do {
35459 ++position;
35460 if (position >= length) {
35461 break;
35462 }
35463 ch = buffer[position];
35464 } while (ch !== LF && ch !== CR);
35465 continue;
35466 }
35467 var token = readToken(buffer, position);
35468 var m;
35469 if (token.indexOf('xref') === 0 &&
35470 (token.length === 4 || /\s/.test(token[4]))) {
35471 position += skipUntil(buffer, position, trailerBytes);
35472 trailers.push(position);
35473 position += skipUntil(buffer, position, startxrefBytes);
35474 } else if ((m = objRegExp.exec(token))) {
35475 if (typeof this.entries[m[1]] === 'undefined') {
35476 this.entries[m[1]] = {
35477 offset: position - stream.start,
35478 gen: m[2] | 0,
35479 uncompressed: true
35480 };
35481 }
35482 var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
35483 var content = buffer.subarray(position, position + contentLength);
35484
35485 // checking XRef stream suspect
35486 // (it shall have '/XRef' and next char is not a letter)
35487 var xrefTagOffset = skipUntil(content, 0, xrefBytes);
35488 if (xrefTagOffset < contentLength &&
35489 content[xrefTagOffset + 5] < 64) {
35490 xrefStms.push(position - stream.start);
35491 this.xrefstms[position - stream.start] = 1; // Avoid recursion
35492 }
35493
35494 position += contentLength;
35495 } else if (token.indexOf('trailer') === 0 &&
35496 (token.length === 7 || /\s/.test(token[7]))) {
35497 trailers.push(position);
35498 position += skipUntil(buffer, position, startxrefBytes);
35499 } else {
35500 position += token.length + 1;
35501 }
35502 }
35503 // reading XRef streams
35504 var i, ii;
35505 for (i = 0, ii = xrefStms.length; i < ii; ++i) {
35506 this.startXRefQueue.push(xrefStms[i]);
35507 this.readXRef(/* recoveryMode */ true);
35508 }
35509 // finding main trailer
35510 var dict;
35511 for (i = 0, ii = trailers.length; i < ii; ++i) {
35512 stream.pos = trailers[i];
35513 var parser = new Parser(new Lexer(stream), /* allowStreams = */ true,
35514 /* xref = */ this, /* recoveryMode = */ true);
35515 var obj = parser.getObj();
35516 if (!isCmd(obj, 'trailer')) {
35517 continue;
35518 }
35519 // read the trailer dictionary
35520 dict = parser.getObj();
35521 if (!isDict(dict)) {
35522 continue;
35523 }
35524 // taking the first one with 'ID'
35525 if (dict.has('ID')) {
35526 return dict;
35527 }
35528 }
35529 // no tailer with 'ID', taking last one (if exists)
35530 if (dict) {
35531 return dict;
35532 }
35533 // nothing helps
35534 // calling error() would reject worker with an UnknownErrorException.
35535 throw new InvalidPDFException('Invalid PDF structure');
35536 },
35537
35538 readXRef: function XRef_readXRef(recoveryMode) {
35539 var stream = this.stream;
35540
35541 try {
35542 while (this.startXRefQueue.length) {
35543 var startXRef = this.startXRefQueue[0];
35544
35545 stream.pos = startXRef + stream.start;
35546
35547 var parser = new Parser(new Lexer(stream), true, this);
35548 var obj = parser.getObj();
35549 var dict;
35550
35551 // Get dictionary
35552 if (isCmd(obj, 'xref')) {
35553 // Parse end-of-file XRef
35554 dict = this.processXRefTable(parser);
35555 if (!this.topDict) {
35556 this.topDict = dict;
35557 }
35558
35559 // Recursively get other XRefs 'XRefStm', if any
35560 obj = dict.get('XRefStm');
35561 if (isInt(obj)) {
35562 var pos = obj;
35563 // ignore previously loaded xref streams
35564 // (possible infinite recursion)
35565 if (!(pos in this.xrefstms)) {
35566 this.xrefstms[pos] = 1;
35567 this.startXRefQueue.push(pos);
35568 }
35569 }
35570 } else if (isInt(obj)) {
35571 // Parse in-stream XRef
35572 if (!isInt(parser.getObj()) ||
35573 !isCmd(parser.getObj(), 'obj') ||
35574 !isStream(obj = parser.getObj())) {
35575 error('Invalid XRef stream');
35576 }
35577 dict = this.processXRefStream(obj);
35578 if (!this.topDict) {
35579 this.topDict = dict;
35580 }
35581 if (!dict) {
35582 error('Failed to read XRef stream');
35583 }
35584 } else {
35585 error('Invalid XRef stream header');
35586 }
35587
35588 // Recursively get previous dictionary, if any
35589 obj = dict.get('Prev');
35590 if (isInt(obj)) {
35591 this.startXRefQueue.push(obj);
35592 } else if (isRef(obj)) {
35593 // The spec says Prev must not be a reference, i.e. "/Prev NNN"
35594 // This is a fallback for non-compliant PDFs, i.e. "/Prev NNN 0 R"
35595 this.startXRefQueue.push(obj.num);
35596 }
35597
35598 this.startXRefQueue.shift();
35599 }
35600
35601 return this.topDict;
35602 } catch (e) {
35603 if (e instanceof MissingDataException) {
35604 throw e;
35605 }
35606 info('(while reading XRef): ' + e);
35607 }
35608
35609 if (recoveryMode) {
35610 return;
35611 }
35612 throw new XRefParseException();
35613 },
35614
35615 getEntry: function XRef_getEntry(i) {
35616 var xrefEntry = this.entries[i];
35617 if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
35618 return xrefEntry;
35619 }
35620 return null;
35621 },
35622
35623 fetchIfRef: function XRef_fetchIfRef(obj) {
35624 if (!isRef(obj)) {
35625 return obj;
35626 }
35627 return this.fetch(obj);
35628 },
35629
35630 fetch: function XRef_fetch(ref, suppressEncryption) {
35631 assert(isRef(ref), 'ref object is not a reference');
35632 var num = ref.num;
35633 if (num in this.cache) {
35634 var cacheEntry = this.cache[num];
35635 return cacheEntry;
35636 }
35637
35638 var xrefEntry = this.getEntry(num);
35639
35640 // the referenced entry can be free
35641 if (xrefEntry === null) {
35642 return (this.cache[num] = null);
35643 }
35644
35645 if (xrefEntry.uncompressed) {
35646 xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
35647 } else {
35648 xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
35649 }
35650 if (isDict(xrefEntry)){
35651 xrefEntry.objId = ref.toString();
35652 } else if (isStream(xrefEntry)) {
35653 xrefEntry.dict.objId = ref.toString();
35654 }
35655 return xrefEntry;
35656 },
35657
35658 fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry,
35659 suppressEncryption) {
35660 var gen = ref.gen;
35661 var num = ref.num;
35662 if (xrefEntry.gen !== gen) {
35663 error('inconsistent generation in XRef');
35664 }
35665 var stream = this.stream.makeSubStream(xrefEntry.offset +
35666 this.stream.start);
35667 var parser = new Parser(new Lexer(stream), true, this);
35668 var obj1 = parser.getObj();
35669 var obj2 = parser.getObj();
35670 var obj3 = parser.getObj();
35671 if (!isInt(obj1) || parseInt(obj1, 10) !== num ||
35672 !isInt(obj2) || parseInt(obj2, 10) !== gen ||
35673 !isCmd(obj3)) {
35674 error('bad XRef entry');
35675 }
35676 if (!isCmd(obj3, 'obj')) {
35677 // some bad PDFs use "obj1234" and really mean 1234
35678 if (obj3.cmd.indexOf('obj') === 0) {
35679 num = parseInt(obj3.cmd.substring(3), 10);
35680 if (!isNaN(num)) {
35681 return num;
35682 }
35683 }
35684 error('bad XRef entry');
35685 }
35686 if (this.encrypt && !suppressEncryption) {
35687 xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
35688 } else {
35689 xrefEntry = parser.getObj();
35690 }
35691 if (!isStream(xrefEntry)) {
35692 this.cache[num] = xrefEntry;
35693 }
35694 return xrefEntry;
35695 },
35696
35697 fetchCompressed: function XRef_fetchCompressed(xrefEntry,
35698 suppressEncryption) {
35699 var tableOffset = xrefEntry.offset;
35700 var stream = this.fetch(new Ref(tableOffset, 0));
35701 if (!isStream(stream)) {
35702 error('bad ObjStm stream');
35703 }
35704 var first = stream.dict.get('First');
35705 var n = stream.dict.get('N');
35706 if (!isInt(first) || !isInt(n)) {
35707 error('invalid first and n parameters for ObjStm stream');
35708 }
35709 var parser = new Parser(new Lexer(stream), false, this);
35710 parser.allowStreams = true;
35711 var i, entries = [], num, nums = [];
35712 // read the object numbers to populate cache
35713 for (i = 0; i < n; ++i) {
35714 num = parser.getObj();
35715 if (!isInt(num)) {
35716 error('invalid object number in the ObjStm stream: ' + num);
35717 }
35718 nums.push(num);
35719 var offset = parser.getObj();
35720 if (!isInt(offset)) {
35721 error('invalid object offset in the ObjStm stream: ' + offset);
35722 }
35723 }
35724 // read stream objects for cache
35725 for (i = 0; i < n; ++i) {
35726 entries.push(parser.getObj());
35727 // The ObjStm should not contain 'endobj'. If it's present, skip over it
35728 // to support corrupt PDFs (fixes issue 5241, bug 898610, bug 1037816).
35729 if (isCmd(parser.buf1, 'endobj')) {
35730 parser.shift();
35731 }
35732 num = nums[i];
35733 var entry = this.entries[num];
35734 if (entry && entry.offset === tableOffset && entry.gen === i) {
35735 this.cache[num] = entries[i];
35736 }
35737 }
35738 xrefEntry = entries[xrefEntry.gen];
35739 if (xrefEntry === undefined) {
35740 error('bad XRef entry for compressed object');
35741 }
35742 return xrefEntry;
35743 },
35744
35745 fetchIfRefAsync: function XRef_fetchIfRefAsync(obj) {
35746 if (!isRef(obj)) {
35747 return Promise.resolve(obj);
35748 }
35749 return this.fetchAsync(obj);
35750 },
35751
35752 fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
35753 var streamManager = this.stream.manager;
35754 var xref = this;
35755 return new Promise(function tryFetch(resolve, reject) {
35756 try {
35757 resolve(xref.fetch(ref, suppressEncryption));
35758 } catch (e) {
35759 if (e instanceof MissingDataException) {
35760 streamManager.requestRange(e.begin, e.end).then(function () {
35761 tryFetch(resolve, reject);
35762 }, reject);
35763 return;
35764 }
35765 reject(e);
35766 }
35767 });
35768 },
35769
35770 getCatalogObj: function XRef_getCatalogObj() {
35771 return this.root;
35772 }
35773 };
35774
35775 return XRef;
35776})();
35777
35778/**
35779 * A NameTree/NumberTree is like a Dict but has some advantageous properties,
35780 * see the specification (7.9.6 and 7.9.7) for additional details.
35781 * TODO: implement all the Dict functions and make this more efficient.
35782 */
35783var NameOrNumberTree = (function NameOrNumberTreeClosure() {
35784 function NameOrNumberTree(root, xref) {
35785 throw new Error('Cannot initialize NameOrNumberTree.');
35786 }
35787
35788 NameOrNumberTree.prototype = {
35789 getAll: function NameOrNumberTree_getAll() {
35790 var dict = Object.create(null);
35791 if (!this.root) {
35792 return dict;
35793 }
35794 var xref = this.xref;
35795 // Reading Name/Number tree.
35796 var processed = new RefSet();
35797 processed.put(this.root);
35798 var queue = [this.root];
35799 while (queue.length > 0) {
35800 var i, n;
35801 var obj = xref.fetchIfRef(queue.shift());
35802 if (!isDict(obj)) {
35803 continue;
35804 }
35805 if (obj.has('Kids')) {
35806 var kids = obj.get('Kids');
35807 for (i = 0, n = kids.length; i < n; i++) {
35808 var kid = kids[i];
35809 assert(!processed.has(kid),
35810 'Duplicate entry in "' + this._type + '" tree.');
35811 queue.push(kid);
35812 processed.put(kid);
35813 }
35814 continue;
35815 }
35816 var entries = obj.get(this._type);
35817 if (isArray(entries)) {
35818 for (i = 0, n = entries.length; i < n; i += 2) {
35819 dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
35820 }
35821 }
35822 }
35823 return dict;
35824 },
35825
35826 get: function NameOrNumberTree_get(key) {
35827 if (!this.root) {
35828 return null;
35829 }
35830
35831 var xref = this.xref;
35832 var kidsOrEntries = xref.fetchIfRef(this.root);
35833 var loopCount = 0;
35834 var MAX_LEVELS = 10;
35835 var l, r, m;
35836
35837 // Perform a binary search to quickly find the entry that
35838 // contains the key we are looking for.
35839 while (kidsOrEntries.has('Kids')) {
35840 if (++loopCount > MAX_LEVELS) {
35841 warn('Search depth limit reached for "' + this._type + '" tree.');
35842 return null;
35843 }
35844
35845 var kids = kidsOrEntries.get('Kids');
35846 if (!isArray(kids)) {
35847 return null;
35848 }
35849
35850 l = 0;
35851 r = kids.length - 1;
35852 while (l <= r) {
35853 m = (l + r) >> 1;
35854 var kid = xref.fetchIfRef(kids[m]);
35855 var limits = kid.get('Limits');
35856
35857 if (key < xref.fetchIfRef(limits[0])) {
35858 r = m - 1;
35859 } else if (key > xref.fetchIfRef(limits[1])) {
35860 l = m + 1;
35861 } else {
35862 kidsOrEntries = xref.fetchIfRef(kids[m]);
35863 break;
35864 }
35865 }
35866 if (l > r) {
35867 return null;
35868 }
35869 }
35870
35871 // If we get here, then we have found the right entry. Now go through the
35872 // entries in the dictionary until we find the key we're looking for.
35873 var entries = kidsOrEntries.get(this._type);
35874 if (isArray(entries)) {
35875 // Perform a binary search to reduce the lookup time.
35876 l = 0;
35877 r = entries.length - 2;
35878 while (l <= r) {
35879 // Check only even indices (0, 2, 4, ...) because the
35880 // odd indices contain the actual data.
35881 m = (l + r) & ~1;
35882 var currentKey = xref.fetchIfRef(entries[m]);
35883 if (key < currentKey) {
35884 r = m - 2;
35885 } else if (key > currentKey) {
35886 l = m + 2;
35887 } else {
35888 return xref.fetchIfRef(entries[m + 1]);
35889 }
35890 }
35891 }
35892 return null;
35893 }
35894 };
35895 return NameOrNumberTree;
35896})();
35897
35898var NameTree = (function NameTreeClosure() {
35899 function NameTree(root, xref) {
35900 this.root = root;
35901 this.xref = xref;
35902 this._type = 'Names';
35903 }
35904
35905 Util.inherit(NameTree, NameOrNumberTree, {});
35906
35907 return NameTree;
35908})();
35909
35910var NumberTree = (function NumberTreeClosure() {
35911 function NumberTree(root, xref) {
35912 this.root = root;
35913 this.xref = xref;
35914 this._type = 'Nums';
35915 }
35916
35917 Util.inherit(NumberTree, NameOrNumberTree, {});
35918
35919 return NumberTree;
35920})();
35921
35922/**
35923 * "A PDF file can refer to the contents of another file by using a File
35924 * Specification (PDF 1.1)", see the spec (7.11) for more details.
35925 * NOTE: Only embedded files are supported (as part of the attachments support)
35926 * TODO: support the 'URL' file system (with caching if !/V), portable
35927 * collections attributes and related files (/RF)
35928 */
35929var FileSpec = (function FileSpecClosure() {
35930 function FileSpec(root, xref) {
35931 if (!root || !isDict(root)) {
35932 return;
35933 }
35934 this.xref = xref;
35935 this.root = root;
35936 if (root.has('FS')) {
35937 this.fs = root.get('FS');
35938 }
35939 this.description = root.has('Desc') ?
35940 stringToPDFString(root.get('Desc')) :
35941 '';
35942 if (root.has('RF')) {
35943 warn('Related file specifications are not supported');
35944 }
35945 this.contentAvailable = true;
35946 if (!root.has('EF')) {
35947 this.contentAvailable = false;
35948 warn('Non-embedded file specifications are not supported');
35949 }
35950 }
35951
35952 function pickPlatformItem(dict) {
35953 // Look for the filename in this order:
35954 // UF, F, Unix, Mac, DOS
35955 if (dict.has('UF')) {
35956 return dict.get('UF');
35957 } else if (dict.has('F')) {
35958 return dict.get('F');
35959 } else if (dict.has('Unix')) {
35960 return dict.get('Unix');
35961 } else if (dict.has('Mac')) {
35962 return dict.get('Mac');
35963 } else if (dict.has('DOS')) {
35964 return dict.get('DOS');
35965 } else {
35966 return null;
35967 }
35968 }
35969
35970 FileSpec.prototype = {
35971 get filename() {
35972 if (!this._filename && this.root) {
35973 var filename = pickPlatformItem(this.root) || 'unnamed';
35974 this._filename = stringToPDFString(filename).
35975 replace(/\\\\/g, '\\').
35976 replace(/\\\//g, '/').
35977 replace(/\\/g, '/');
35978 }
35979 return this._filename;
35980 },
35981 get content() {
35982 if (!this.contentAvailable) {
35983 return null;
35984 }
35985 if (!this.contentRef && this.root) {
35986 this.contentRef = pickPlatformItem(this.root.get('EF'));
35987 }
35988 var content = null;
35989 if (this.contentRef) {
35990 var xref = this.xref;
35991 var fileObj = xref.fetchIfRef(this.contentRef);
35992 if (fileObj && isStream(fileObj)) {
35993 content = fileObj.getBytes();
35994 } else {
35995 warn('Embedded file specification points to non-existing/invalid ' +
35996 'content');
35997 }
35998 } else {
35999 warn('Embedded file specification does not have a content');
36000 }
36001 return content;
36002 },
36003 get serializable() {
36004 return {
36005 filename: this.filename,
36006 content: this.content
36007 };
36008 }
36009 };
36010 return FileSpec;
36011})();
36012
36013/**
36014 * A helper for loading missing data in object graphs. It traverses the graph
36015 * depth first and queues up any objects that have missing data. Once it has
36016 * has traversed as many objects that are available it attempts to bundle the
36017 * missing data requests and then resume from the nodes that weren't ready.
36018 *
36019 * NOTE: It provides protection from circular references by keeping track of
36020 * of loaded references. However, you must be careful not to load any graphs
36021 * that have references to the catalog or other pages since that will cause the
36022 * entire PDF document object graph to be traversed.
36023 */
36024var ObjectLoader = (function() {
36025 function mayHaveChildren(value) {
36026 return isRef(value) || isDict(value) || isArray(value) || isStream(value);
36027 }
36028
36029 function addChildren(node, nodesToVisit) {
36030 var value;
36031 if (isDict(node) || isStream(node)) {
36032 var map;
36033 if (isDict(node)) {
36034 map = node.map;
36035 } else {
36036 map = node.dict.map;
36037 }
36038 for (var key in map) {
36039 value = map[key];
36040 if (mayHaveChildren(value)) {
36041 nodesToVisit.push(value);
36042 }
36043 }
36044 } else if (isArray(node)) {
36045 for (var i = 0, ii = node.length; i < ii; i++) {
36046 value = node[i];
36047 if (mayHaveChildren(value)) {
36048 nodesToVisit.push(value);
36049 }
36050 }
36051 }
36052 }
36053
36054 function ObjectLoader(obj, keys, xref) {
36055 this.obj = obj;
36056 this.keys = keys;
36057 this.xref = xref;
36058 this.refSet = null;
36059 this.capability = null;
36060 }
36061
36062 ObjectLoader.prototype = {
36063 load: function ObjectLoader_load() {
36064 var keys = this.keys;
36065 this.capability = createPromiseCapability();
36066 // Don't walk the graph if all the data is already loaded.
36067 if (!(this.xref.stream instanceof ChunkedStream) ||
36068 this.xref.stream.getMissingChunks().length === 0) {
36069 this.capability.resolve();
36070 return this.capability.promise;
36071 }
36072
36073 this.refSet = new RefSet();
36074 // Setup the initial nodes to visit.
36075 var nodesToVisit = [];
36076 for (var i = 0; i < keys.length; i++) {
36077 nodesToVisit.push(this.obj[keys[i]]);
36078 }
36079
36080 this._walk(nodesToVisit);
36081 return this.capability.promise;
36082 },
36083
36084 _walk: function ObjectLoader_walk(nodesToVisit) {
36085 var nodesToRevisit = [];
36086 var pendingRequests = [];
36087 // DFS walk of the object graph.
36088 while (nodesToVisit.length) {
36089 var currentNode = nodesToVisit.pop();
36090
36091 // Only references or chunked streams can cause missing data exceptions.
36092 if (isRef(currentNode)) {
36093 // Skip nodes that have already been visited.
36094 if (this.refSet.has(currentNode)) {
36095 continue;
36096 }
36097 try {
36098 var ref = currentNode;
36099 this.refSet.put(ref);
36100 currentNode = this.xref.fetch(currentNode);
36101 } catch (e) {
36102 if (!(e instanceof MissingDataException)) {
36103 throw e;
36104 }
36105 nodesToRevisit.push(currentNode);
36106 pendingRequests.push({ begin: e.begin, end: e.end });
36107 }
36108 }
36109 if (currentNode && currentNode.getBaseStreams) {
36110 var baseStreams = currentNode.getBaseStreams();
36111 var foundMissingData = false;
36112 for (var i = 0; i < baseStreams.length; i++) {
36113 var stream = baseStreams[i];
36114 if (stream.getMissingChunks && stream.getMissingChunks().length) {
36115 foundMissingData = true;
36116 pendingRequests.push({
36117 begin: stream.start,
36118 end: stream.end
36119 });
36120 }
36121 }
36122 if (foundMissingData) {
36123 nodesToRevisit.push(currentNode);
36124 }
36125 }
36126
36127 addChildren(currentNode, nodesToVisit);
36128 }
36129
36130 if (pendingRequests.length) {
36131 this.xref.stream.manager.requestRanges(pendingRequests).then(
36132 function pendingRequestCallback() {
36133 nodesToVisit = nodesToRevisit;
36134 for (var i = 0; i < nodesToRevisit.length; i++) {
36135 var node = nodesToRevisit[i];
36136 // Remove any reference nodes from the currrent refset so they
36137 // aren't skipped when we revist them.
36138 if (isRef(node)) {
36139 this.refSet.remove(node);
36140 }
36141 }
36142 this._walk(nodesToVisit);
36143 }.bind(this), this.capability.reject);
36144 return;
36145 }
36146 // Everything is loaded.
36147 this.refSet = null;
36148 this.capability.resolve();
36149 }
36150 };
36151
36152 return ObjectLoader;
36153})();
36154
36155exports.Catalog = Catalog;
36156exports.ObjectLoader = ObjectLoader;
36157exports.XRef = XRef;
36158exports.FileSpec = FileSpec;
36159}));
36160
36161
36162(function (root, factory) {
36163 {
36164 factory((root.pdfjsCorePattern = {}), root.pdfjsSharedUtil,
36165 root.pdfjsCorePrimitives, root.pdfjsCoreFunction,
36166 root.pdfjsCoreColorSpace);
36167 }
36168}(this, function (exports, sharedUtil, corePrimitives, coreFunction,
36169 coreColorSpace) {
36170
36171var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
36172var MissingDataException = sharedUtil.MissingDataException;
36173var Util = sharedUtil.Util;
36174var assert = sharedUtil.assert;
36175var error = sharedUtil.error;
36176var info = sharedUtil.info;
36177var warn = sharedUtil.warn;
36178var isStream = corePrimitives.isStream;
36179var PDFFunction = coreFunction.PDFFunction;
36180var ColorSpace = coreColorSpace.ColorSpace;
36181
36182var ShadingType = {
36183 FUNCTION_BASED: 1,
36184 AXIAL: 2,
36185 RADIAL: 3,
36186 FREE_FORM_MESH: 4,
36187 LATTICE_FORM_MESH: 5,
36188 COONS_PATCH_MESH: 6,
36189 TENSOR_PATCH_MESH: 7
36190};
36191
36192var Pattern = (function PatternClosure() {
36193 // Constructor should define this.getPattern
36194 function Pattern() {
36195 error('should not call Pattern constructor');
36196 }
36197
36198 Pattern.prototype = {
36199 // Input: current Canvas context
36200 // Output: the appropriate fillStyle or strokeStyle
36201 getPattern: function Pattern_getPattern(ctx) {
36202 error('Should not call Pattern.getStyle: ' + ctx);
36203 }
36204 };
36205
36206 Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref,
36207 res, handler) {
36208
36209 var dict = isStream(shading) ? shading.dict : shading;
36210 var type = dict.get('ShadingType');
36211
36212 try {
36213 switch (type) {
36214 case ShadingType.AXIAL:
36215 case ShadingType.RADIAL:
36216 // Both radial and axial shadings are handled by RadialAxial shading.
36217 return new Shadings.RadialAxial(dict, matrix, xref, res);
36218 case ShadingType.FREE_FORM_MESH:
36219 case ShadingType.LATTICE_FORM_MESH:
36220 case ShadingType.COONS_PATCH_MESH:
36221 case ShadingType.TENSOR_PATCH_MESH:
36222 return new Shadings.Mesh(shading, matrix, xref, res);
36223 default:
36224 throw new Error('Unsupported ShadingType: ' + type);
36225 }
36226 } catch (ex) {
36227 if (ex instanceof MissingDataException) {
36228 throw ex;
36229 }
36230 handler.send('UnsupportedFeature',
36231 {featureId: UNSUPPORTED_FEATURES.shadingPattern});
36232 warn(ex);
36233 return new Shadings.Dummy();
36234 }
36235 };
36236 return Pattern;
36237})();
36238
36239var Shadings = {};
36240
36241// A small number to offset the first/last color stops so we can insert ones to
36242// support extend. Number.MIN_VALUE is too small and breaks the extend.
36243Shadings.SMALL_NUMBER = 1e-6;
36244
36245// Radial and axial shading have very similar implementations
36246// If needed, the implementations can be broken into two classes
36247Shadings.RadialAxial = (function RadialAxialClosure() {
36248 function RadialAxial(dict, matrix, xref, res) {
36249 this.matrix = matrix;
36250 this.coordsArr = dict.getArray('Coords');
36251 this.shadingType = dict.get('ShadingType');
36252 this.type = 'Pattern';
36253 var cs = dict.get('ColorSpace', 'CS');
36254 cs = ColorSpace.parse(cs, xref, res);
36255 this.cs = cs;
36256
36257 var t0 = 0.0, t1 = 1.0;
36258 if (dict.has('Domain')) {
36259 var domainArr = dict.getArray('Domain');
36260 t0 = domainArr[0];
36261 t1 = domainArr[1];
36262 }
36263
36264 var extendStart = false, extendEnd = false;
36265 if (dict.has('Extend')) {
36266 var extendArr = dict.getArray('Extend');
36267 extendStart = extendArr[0];
36268 extendEnd = extendArr[1];
36269 }
36270
36271 if (this.shadingType === ShadingType.RADIAL &&
36272 (!extendStart || !extendEnd)) {
36273 // Radial gradient only currently works if either circle is fully within
36274 // the other circle.
36275 var x1 = this.coordsArr[0];
36276 var y1 = this.coordsArr[1];
36277 var r1 = this.coordsArr[2];
36278 var x2 = this.coordsArr[3];
36279 var y2 = this.coordsArr[4];
36280 var r2 = this.coordsArr[5];
36281 var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
36282 if (r1 <= r2 + distance &&
36283 r2 <= r1 + distance) {
36284 warn('Unsupported radial gradient.');
36285 }
36286 }
36287
36288 this.extendStart = extendStart;
36289 this.extendEnd = extendEnd;
36290
36291 var fnObj = dict.get('Function');
36292 var fn = PDFFunction.parseArray(xref, fnObj);
36293
36294 // 10 samples seems good enough for now, but probably won't work
36295 // if there are sharp color changes. Ideally, we would implement
36296 // the spec faithfully and add lossless optimizations.
36297 var diff = t1 - t0;
36298 var step = diff / 10;
36299
36300 var colorStops = this.colorStops = [];
36301
36302 // Protect against bad domains so we don't end up in an infinte loop below.
36303 if (t0 >= t1 || step <= 0) {
36304 // Acrobat doesn't seem to handle these cases so we'll ignore for
36305 // now.
36306 info('Bad shading domain.');
36307 return;
36308 }
36309
36310 var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
36311 var rgbColor;
36312 for (var i = t0; i <= t1; i += step) {
36313 ratio[0] = i;
36314 fn(ratio, 0, color, 0);
36315 rgbColor = cs.getRgb(color, 0);
36316 var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
36317 colorStops.push([(i - t0) / diff, cssColor]);
36318 }
36319
36320 var background = 'transparent';
36321 if (dict.has('Background')) {
36322 rgbColor = cs.getRgb(dict.get('Background'), 0);
36323 background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
36324 }
36325
36326 if (!extendStart) {
36327 // Insert a color stop at the front and offset the first real color stop
36328 // so it doesn't conflict with the one we insert.
36329 colorStops.unshift([0, background]);
36330 colorStops[1][0] += Shadings.SMALL_NUMBER;
36331 }
36332 if (!extendEnd) {
36333 // Same idea as above in extendStart but for the end.
36334 colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
36335 colorStops.push([1, background]);
36336 }
36337
36338 this.colorStops = colorStops;
36339 }
36340
36341 RadialAxial.prototype = {
36342 getIR: function RadialAxial_getIR() {
36343 var coordsArr = this.coordsArr;
36344 var shadingType = this.shadingType;
36345 var type, p0, p1, r0, r1;
36346 if (shadingType === ShadingType.AXIAL) {
36347 p0 = [coordsArr[0], coordsArr[1]];
36348 p1 = [coordsArr[2], coordsArr[3]];
36349 r0 = null;
36350 r1 = null;
36351 type = 'axial';
36352 } else if (shadingType === ShadingType.RADIAL) {
36353 p0 = [coordsArr[0], coordsArr[1]];
36354 p1 = [coordsArr[3], coordsArr[4]];
36355 r0 = coordsArr[2];
36356 r1 = coordsArr[5];
36357 type = 'radial';
36358 } else {
36359 error('getPattern type unknown: ' + shadingType);
36360 }
36361
36362 var matrix = this.matrix;
36363 if (matrix) {
36364 p0 = Util.applyTransform(p0, matrix);
36365 p1 = Util.applyTransform(p1, matrix);
36366 if (shadingType === ShadingType.RADIAL) {
36367 var scale = Util.singularValueDecompose2dScale(matrix);
36368 r0 *= scale[0];
36369 r1 *= scale[1];
36370 }
36371 }
36372
36373 return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1];
36374 }
36375 };
36376
36377 return RadialAxial;
36378})();
36379
36380// All mesh shading. For now, they will be presented as set of the triangles
36381// to be drawn on the canvas and rgb color for each vertex.
36382Shadings.Mesh = (function MeshClosure() {
36383 function MeshStreamReader(stream, context) {
36384 this.stream = stream;
36385 this.context = context;
36386 this.buffer = 0;
36387 this.bufferLength = 0;
36388
36389 var numComps = context.numComps;
36390 this.tmpCompsBuf = new Float32Array(numComps);
36391 var csNumComps = context.colorSpace.numComps;
36392 this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) :
36393 this.tmpCompsBuf;
36394 }
36395 MeshStreamReader.prototype = {
36396 get hasData() {
36397 if (this.stream.end) {
36398 return this.stream.pos < this.stream.end;
36399 }
36400 if (this.bufferLength > 0) {
36401 return true;
36402 }
36403 var nextByte = this.stream.getByte();
36404 if (nextByte < 0) {
36405 return false;
36406 }
36407 this.buffer = nextByte;
36408 this.bufferLength = 8;
36409 return true;
36410 },
36411 readBits: function MeshStreamReader_readBits(n) {
36412 var buffer = this.buffer;
36413 var bufferLength = this.bufferLength;
36414 if (n === 32) {
36415 if (bufferLength === 0) {
36416 return ((this.stream.getByte() << 24) |
36417 (this.stream.getByte() << 16) | (this.stream.getByte() << 8) |
36418 this.stream.getByte()) >>> 0;
36419 }
36420 buffer = (buffer << 24) | (this.stream.getByte() << 16) |
36421 (this.stream.getByte() << 8) | this.stream.getByte();
36422 var nextByte = this.stream.getByte();
36423 this.buffer = nextByte & ((1 << bufferLength) - 1);
36424 return ((buffer << (8 - bufferLength)) |
36425 ((nextByte & 0xFF) >> bufferLength)) >>> 0;
36426 }
36427 if (n === 8 && bufferLength === 0) {
36428 return this.stream.getByte();
36429 }
36430 while (bufferLength < n) {
36431 buffer = (buffer << 8) | this.stream.getByte();
36432 bufferLength += 8;
36433 }
36434 bufferLength -= n;
36435 this.bufferLength = bufferLength;
36436 this.buffer = buffer & ((1 << bufferLength) - 1);
36437 return buffer >> bufferLength;
36438 },
36439 align: function MeshStreamReader_align() {
36440 this.buffer = 0;
36441 this.bufferLength = 0;
36442 },
36443 readFlag: function MeshStreamReader_readFlag() {
36444 return this.readBits(this.context.bitsPerFlag);
36445 },
36446 readCoordinate: function MeshStreamReader_readCoordinate() {
36447 var bitsPerCoordinate = this.context.bitsPerCoordinate;
36448 var xi = this.readBits(bitsPerCoordinate);
36449 var yi = this.readBits(bitsPerCoordinate);
36450 var decode = this.context.decode;
36451 var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) :
36452 2.3283064365386963e-10; // 2 ^ -32
36453 return [
36454 xi * scale * (decode[1] - decode[0]) + decode[0],
36455 yi * scale * (decode[3] - decode[2]) + decode[2]
36456 ];
36457 },
36458 readComponents: function MeshStreamReader_readComponents() {
36459 var numComps = this.context.numComps;
36460 var bitsPerComponent = this.context.bitsPerComponent;
36461 var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) :
36462 2.3283064365386963e-10; // 2 ^ -32
36463 var decode = this.context.decode;
36464 var components = this.tmpCompsBuf;
36465 for (var i = 0, j = 4; i < numComps; i++, j += 2) {
36466 var ci = this.readBits(bitsPerComponent);
36467 components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
36468 }
36469 var color = this.tmpCsCompsBuf;
36470 if (this.context.colorFn) {
36471 this.context.colorFn(components, 0, color, 0);
36472 }
36473 return this.context.colorSpace.getRgb(color, 0);
36474 }
36475 };
36476
36477 function decodeType4Shading(mesh, reader) {
36478 var coords = mesh.coords;
36479 var colors = mesh.colors;
36480 var operators = [];
36481 var ps = []; // not maintaining cs since that will match ps
36482 var verticesLeft = 0; // assuming we have all data to start a new triangle
36483 while (reader.hasData) {
36484 var f = reader.readFlag();
36485 var coord = reader.readCoordinate();
36486 var color = reader.readComponents();
36487 if (verticesLeft === 0) { // ignoring flags if we started a triangle
36488 assert(0 <= f && f <= 2, 'Unknown type4 flag');
36489 switch (f) {
36490 case 0:
36491 verticesLeft = 3;
36492 break;
36493 case 1:
36494 ps.push(ps[ps.length - 2], ps[ps.length - 1]);
36495 verticesLeft = 1;
36496 break;
36497 case 2:
36498 ps.push(ps[ps.length - 3], ps[ps.length - 1]);
36499 verticesLeft = 1;
36500 break;
36501 }
36502 operators.push(f);
36503 }
36504 ps.push(coords.length);
36505 coords.push(coord);
36506 colors.push(color);
36507 verticesLeft--;
36508
36509 reader.align();
36510 }
36511 mesh.figures.push({
36512 type: 'triangles',
36513 coords: new Int32Array(ps),
36514 colors: new Int32Array(ps),
36515 });
36516 }
36517
36518 function decodeType5Shading(mesh, reader, verticesPerRow) {
36519 var coords = mesh.coords;
36520 var colors = mesh.colors;
36521 var ps = []; // not maintaining cs since that will match ps
36522 while (reader.hasData) {
36523 var coord = reader.readCoordinate();
36524 var color = reader.readComponents();
36525 ps.push(coords.length);
36526 coords.push(coord);
36527 colors.push(color);
36528 }
36529 mesh.figures.push({
36530 type: 'lattice',
36531 coords: new Int32Array(ps),
36532 colors: new Int32Array(ps),
36533 verticesPerRow: verticesPerRow
36534 });
36535 }
36536
36537 var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
36538 var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
36539
36540 var TRIANGLE_DENSITY = 20; // count of triangles per entire mesh bounds
36541
36542 var getB = (function getBClosure() {
36543 function buildB(count) {
36544 var lut = [];
36545 for (var i = 0; i <= count; i++) {
36546 var t = i / count, t_ = 1 - t;
36547 lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_,
36548 3 * t * t * t_, t * t * t]));
36549 }
36550 return lut;
36551 }
36552 var cache = [];
36553 return function getB(count) {
36554 if (!cache[count]) {
36555 cache[count] = buildB(count);
36556 }
36557 return cache[count];
36558 };
36559 })();
36560
36561 function buildFigureFromPatch(mesh, index) {
36562 var figure = mesh.figures[index];
36563 assert(figure.type === 'patch', 'Unexpected patch mesh figure');
36564
36565 var coords = mesh.coords, colors = mesh.colors;
36566 var pi = figure.coords;
36567 var ci = figure.colors;
36568
36569 var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0],
36570 coords[pi[12]][0], coords[pi[15]][0]);
36571 var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1],
36572 coords[pi[12]][1], coords[pi[15]][1]);
36573 var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0],
36574 coords[pi[12]][0], coords[pi[15]][0]);
36575 var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1],
36576 coords[pi[12]][1], coords[pi[15]][1]);
36577 var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY /
36578 (mesh.bounds[2] - mesh.bounds[0]));
36579 splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
36580 Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
36581 var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY /
36582 (mesh.bounds[3] - mesh.bounds[1]));
36583 splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT,
36584 Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
36585
36586 var verticesPerRow = splitXBy + 1;
36587 var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
36588 var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
36589 var k = 0;
36590 var cl = new Uint8Array(3), cr = new Uint8Array(3);
36591 var c0 = colors[ci[0]], c1 = colors[ci[1]],
36592 c2 = colors[ci[2]], c3 = colors[ci[3]];
36593 var bRow = getB(splitYBy), bCol = getB(splitXBy);
36594 for (var row = 0; row <= splitYBy; row++) {
36595 cl[0] = ((c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy) | 0;
36596 cl[1] = ((c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy) | 0;
36597 cl[2] = ((c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy) | 0;
36598
36599 cr[0] = ((c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy) | 0;
36600 cr[1] = ((c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy) | 0;
36601 cr[2] = ((c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy) | 0;
36602
36603 for (var col = 0; col <= splitXBy; col++, k++) {
36604 if ((row === 0 || row === splitYBy) &&
36605 (col === 0 || col === splitXBy)) {
36606 continue;
36607 }
36608 var x = 0, y = 0;
36609 var q = 0;
36610 for (var i = 0; i <= 3; i++) {
36611 for (var j = 0; j <= 3; j++, q++) {
36612 var m = bRow[row][i] * bCol[col][j];
36613 x += coords[pi[q]][0] * m;
36614 y += coords[pi[q]][1] * m;
36615 }
36616 }
36617 figureCoords[k] = coords.length;
36618 coords.push([x, y]);
36619 figureColors[k] = colors.length;
36620 var newColor = new Uint8Array(3);
36621 newColor[0] = ((cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy) | 0;
36622 newColor[1] = ((cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy) | 0;
36623 newColor[2] = ((cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy) | 0;
36624 colors.push(newColor);
36625 }
36626 }
36627 figureCoords[0] = pi[0];
36628 figureColors[0] = ci[0];
36629 figureCoords[splitXBy] = pi[3];
36630 figureColors[splitXBy] = ci[1];
36631 figureCoords[verticesPerRow * splitYBy] = pi[12];
36632 figureColors[verticesPerRow * splitYBy] = ci[2];
36633 figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
36634 figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
36635
36636 mesh.figures[index] = {
36637 type: 'lattice',
36638 coords: figureCoords,
36639 colors: figureColors,
36640 verticesPerRow: verticesPerRow
36641 };
36642 }
36643
36644 function decodeType6Shading(mesh, reader) {
36645 // A special case of Type 7. The p11, p12, p21, p22 automatically filled
36646 var coords = mesh.coords;
36647 var colors = mesh.colors;
36648 var ps = new Int32Array(16); // p00, p10, ..., p30, p01, ..., p33
36649 var cs = new Int32Array(4); // c00, c30, c03, c33
36650 while (reader.hasData) {
36651 var f = reader.readFlag();
36652 assert(0 <= f && f <= 3, 'Unknown type6 flag');
36653 var i, ii;
36654 var pi = coords.length;
36655 for (i = 0, ii = (f !== 0 ? 8 : 12); i < ii; i++) {
36656 coords.push(reader.readCoordinate());
36657 }
36658 var ci = colors.length;
36659 for (i = 0, ii = (f !== 0 ? 2 : 4); i < ii; i++) {
36660 colors.push(reader.readComponents());
36661 }
36662 var tmp1, tmp2, tmp3, tmp4;
36663 switch (f) {
36664 case 0:
36665 ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6;
36666 ps[ 8] = pi + 2; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 7;
36667 ps[ 4] = pi + 1; /* calculated below */ ps[ 7] = pi + 8;
36668 ps[ 0] = pi; ps[ 1] = pi + 11; ps[ 2] = pi + 10; ps[ 3] = pi + 9;
36669 cs[2] = ci + 1; cs[3] = ci + 2;
36670 cs[0] = ci; cs[1] = ci + 3;
36671 break;
36672 case 1:
36673 tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];
36674 ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
36675 ps[ 8] = tmp3; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
36676 ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;
36677 ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
36678 tmp1 = cs[2]; tmp2 = cs[3];
36679 cs[2] = tmp2; cs[3] = ci;
36680 cs[0] = tmp1; cs[1] = ci + 1;
36681 break;
36682 case 2:
36683 tmp1 = ps[15];
36684 tmp2 = ps[11];
36685 ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
36686 ps[ 8] = ps[7]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
36687 ps[ 4] = tmp2; /* calculated below */ ps[ 7] = pi + 4;
36688 ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
36689 tmp1 = cs[3];
36690 cs[2] = cs[1]; cs[3] = ci;
36691 cs[0] = tmp1; cs[1] = ci + 1;
36692 break;
36693 case 3:
36694 ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
36695 ps[ 8] = ps[1]; /* values for 5, 6, 9, 10 are */ ps[11] = pi + 3;
36696 ps[ 4] = ps[2]; /* calculated below */ ps[ 7] = pi + 4;
36697 ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
36698 cs[2] = cs[0]; cs[3] = ci;
36699 cs[0] = cs[1]; cs[1] = ci + 1;
36700 break;
36701 }
36702 // set p11, p12, p21, p22
36703 ps[5] = coords.length;
36704 coords.push([
36705 (-4 * coords[ps[0]][0] - coords[ps[15]][0] +
36706 6 * (coords[ps[4]][0] + coords[ps[1]][0]) -
36707 2 * (coords[ps[12]][0] + coords[ps[3]][0]) +
36708 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9,
36709 (-4 * coords[ps[0]][1] - coords[ps[15]][1] +
36710 6 * (coords[ps[4]][1] + coords[ps[1]][1]) -
36711 2 * (coords[ps[12]][1] + coords[ps[3]][1]) +
36712 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9
36713 ]);
36714 ps[6] = coords.length;
36715 coords.push([
36716 (-4 * coords[ps[3]][0] - coords[ps[12]][0] +
36717 6 * (coords[ps[2]][0] + coords[ps[7]][0]) -
36718 2 * (coords[ps[0]][0] + coords[ps[15]][0]) +
36719 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9,
36720 (-4 * coords[ps[3]][1] - coords[ps[12]][1] +
36721 6 * (coords[ps[2]][1] + coords[ps[7]][1]) -
36722 2 * (coords[ps[0]][1] + coords[ps[15]][1]) +
36723 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9
36724 ]);
36725 ps[9] = coords.length;
36726 coords.push([
36727 (-4 * coords[ps[12]][0] - coords[ps[3]][0] +
36728 6 * (coords[ps[8]][0] + coords[ps[13]][0]) -
36729 2 * (coords[ps[0]][0] + coords[ps[15]][0]) +
36730 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9,
36731 (-4 * coords[ps[12]][1] - coords[ps[3]][1] +
36732 6 * (coords[ps[8]][1] + coords[ps[13]][1]) -
36733 2 * (coords[ps[0]][1] + coords[ps[15]][1]) +
36734 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9
36735 ]);
36736 ps[10] = coords.length;
36737 coords.push([
36738 (-4 * coords[ps[15]][0] - coords[ps[0]][0] +
36739 6 * (coords[ps[11]][0] + coords[ps[14]][0]) -
36740 2 * (coords[ps[12]][0] + coords[ps[3]][0]) +
36741 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9,
36742 (-4 * coords[ps[15]][1] - coords[ps[0]][1] +
36743 6 * (coords[ps[11]][1] + coords[ps[14]][1]) -
36744 2 * (coords[ps[12]][1] + coords[ps[3]][1]) +
36745 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9
36746 ]);
36747 mesh.figures.push({
36748 type: 'patch',
36749 coords: new Int32Array(ps), // making copies of ps and cs
36750 colors: new Int32Array(cs)
36751 });
36752 }
36753 }
36754
36755 function decodeType7Shading(mesh, reader) {
36756 var coords = mesh.coords;
36757 var colors = mesh.colors;
36758 var ps = new Int32Array(16); // p00, p10, ..., p30, p01, ..., p33
36759 var cs = new Int32Array(4); // c00, c30, c03, c33
36760 while (reader.hasData) {
36761 var f = reader.readFlag();
36762 assert(0 <= f && f <= 3, 'Unknown type7 flag');
36763 var i, ii;
36764 var pi = coords.length;
36765 for (i = 0, ii = (f !== 0 ? 12 : 16); i < ii; i++) {
36766 coords.push(reader.readCoordinate());
36767 }
36768 var ci = colors.length;
36769 for (i = 0, ii = (f !== 0 ? 2 : 4); i < ii; i++) {
36770 colors.push(reader.readComponents());
36771 }
36772 var tmp1, tmp2, tmp3, tmp4;
36773 switch (f) {
36774 case 0:
36775 ps[12] = pi + 3; ps[13] = pi + 4; ps[14] = pi + 5; ps[15] = pi + 6;
36776 ps[ 8] = pi + 2; ps[ 9] = pi + 13; ps[10] = pi + 14; ps[11] = pi + 7;
36777 ps[ 4] = pi + 1; ps[ 5] = pi + 12; ps[ 6] = pi + 15; ps[ 7] = pi + 8;
36778 ps[ 0] = pi; ps[ 1] = pi + 11; ps[ 2] = pi + 10; ps[ 3] = pi + 9;
36779 cs[2] = ci + 1; cs[3] = ci + 2;
36780 cs[0] = ci; cs[1] = ci + 3;
36781 break;
36782 case 1:
36783 tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];
36784 ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
36785 ps[ 8] = tmp3; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
36786 ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
36787 ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
36788 tmp1 = cs[2]; tmp2 = cs[3];
36789 cs[2] = tmp2; cs[3] = ci;
36790 cs[0] = tmp1; cs[1] = ci + 1;
36791 break;
36792 case 2:
36793 tmp1 = ps[15];
36794 tmp2 = ps[11];
36795 ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
36796 ps[ 8] = ps[7]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
36797 ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
36798 ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
36799 tmp1 = cs[3];
36800 cs[2] = cs[1]; cs[3] = ci;
36801 cs[0] = tmp1; cs[1] = ci + 1;
36802 break;
36803 case 3:
36804 ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
36805 ps[ 8] = ps[1]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
36806 ps[ 4] = ps[2]; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
36807 ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
36808 cs[2] = cs[0]; cs[3] = ci;
36809 cs[0] = cs[1]; cs[1] = ci + 1;
36810 break;
36811 }
36812 mesh.figures.push({
36813 type: 'patch',
36814 coords: new Int32Array(ps), // making copies of ps and cs
36815 colors: new Int32Array(cs)
36816 });
36817 }
36818 }
36819
36820 function updateBounds(mesh) {
36821 var minX = mesh.coords[0][0], minY = mesh.coords[0][1],
36822 maxX = minX, maxY = minY;
36823 for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
36824 var x = mesh.coords[i][0], y = mesh.coords[i][1];
36825 minX = minX > x ? x : minX;
36826 minY = minY > y ? y : minY;
36827 maxX = maxX < x ? x : maxX;
36828 maxY = maxY < y ? y : maxY;
36829 }
36830 mesh.bounds = [minX, minY, maxX, maxY];
36831 }
36832
36833 function packData(mesh) {
36834 var i, ii, j, jj;
36835
36836 var coords = mesh.coords;
36837 var coordsPacked = new Float32Array(coords.length * 2);
36838 for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
36839 var xy = coords[i];
36840 coordsPacked[j++] = xy[0];
36841 coordsPacked[j++] = xy[1];
36842 }
36843 mesh.coords = coordsPacked;
36844
36845 var colors = mesh.colors;
36846 var colorsPacked = new Uint8Array(colors.length * 3);
36847 for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
36848 var c = colors[i];
36849 colorsPacked[j++] = c[0];
36850 colorsPacked[j++] = c[1];
36851 colorsPacked[j++] = c[2];
36852 }
36853 mesh.colors = colorsPacked;
36854
36855 var figures = mesh.figures;
36856 for (i = 0, ii = figures.length; i < ii; i++) {
36857 var figure = figures[i], ps = figure.coords, cs = figure.colors;
36858 for (j = 0, jj = ps.length; j < jj; j++) {
36859 ps[j] *= 2;
36860 cs[j] *= 3;
36861 }
36862 }
36863 }
36864
36865 function Mesh(stream, matrix, xref, res) {
36866 assert(isStream(stream), 'Mesh data is not a stream');
36867 var dict = stream.dict;
36868 this.matrix = matrix;
36869 this.shadingType = dict.get('ShadingType');
36870 this.type = 'Pattern';
36871 this.bbox = dict.getArray('BBox');
36872 var cs = dict.get('ColorSpace', 'CS');
36873 cs = ColorSpace.parse(cs, xref, res);
36874 this.cs = cs;
36875 this.background = dict.has('Background') ?
36876 cs.getRgb(dict.get('Background'), 0) : null;
36877
36878 var fnObj = dict.get('Function');
36879 var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
36880
36881 this.coords = [];
36882 this.colors = [];
36883 this.figures = [];
36884
36885 var decodeContext = {
36886 bitsPerCoordinate: dict.get('BitsPerCoordinate'),
36887 bitsPerComponent: dict.get('BitsPerComponent'),
36888 bitsPerFlag: dict.get('BitsPerFlag'),
36889 decode: dict.getArray('Decode'),
36890 colorFn: fn,
36891 colorSpace: cs,
36892 numComps: fn ? 1 : cs.numComps
36893 };
36894 var reader = new MeshStreamReader(stream, decodeContext);
36895
36896 var patchMesh = false;
36897 switch (this.shadingType) {
36898 case ShadingType.FREE_FORM_MESH:
36899 decodeType4Shading(this, reader);
36900 break;
36901 case ShadingType.LATTICE_FORM_MESH:
36902 var verticesPerRow = dict.get('VerticesPerRow') | 0;
36903 assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
36904 decodeType5Shading(this, reader, verticesPerRow);
36905 break;
36906 case ShadingType.COONS_PATCH_MESH:
36907 decodeType6Shading(this, reader);
36908 patchMesh = true;
36909 break;
36910 case ShadingType.TENSOR_PATCH_MESH:
36911 decodeType7Shading(this, reader);
36912 patchMesh = true;
36913 break;
36914 default:
36915 error('Unsupported mesh type.');
36916 break;
36917 }
36918
36919 if (patchMesh) {
36920 // dirty bounds calculation for determining, how dense shall be triangles
36921 updateBounds(this);
36922 for (var i = 0, ii = this.figures.length; i < ii; i++) {
36923 buildFigureFromPatch(this, i);
36924 }
36925 }
36926 // calculate bounds
36927 updateBounds(this);
36928
36929 packData(this);
36930 }
36931
36932 Mesh.prototype = {
36933 getIR: function Mesh_getIR() {
36934 return ['Mesh', this.shadingType, this.coords, this.colors, this.figures,
36935 this.bounds, this.matrix, this.bbox, this.background];
36936 }
36937 };
36938
36939 return Mesh;
36940})();
36941
36942Shadings.Dummy = (function DummyClosure() {
36943 function Dummy() {
36944 this.type = 'Pattern';
36945 }
36946
36947 Dummy.prototype = {
36948 getIR: function Dummy_getIR() {
36949 return ['Dummy'];
36950 }
36951 };
36952 return Dummy;
36953})();
36954
36955function getTilingPatternIR(operatorList, dict, args) {
36956 var matrix = dict.getArray('Matrix');
36957 var bbox = dict.getArray('BBox');
36958 var xstep = dict.get('XStep');
36959 var ystep = dict.get('YStep');
36960 var paintType = dict.get('PaintType');
36961 var tilingType = dict.get('TilingType');
36962
36963 return [
36964 'TilingPattern', args, operatorList, matrix, bbox, xstep, ystep,
36965 paintType, tilingType
36966 ];
36967}
36968
36969exports.Pattern = Pattern;
36970exports.getTilingPatternIR = getTilingPatternIR;
36971}));
36972
36973
36974(function (root, factory) {
36975 {
36976 factory((root.pdfjsCoreEvaluator = {}), root.pdfjsSharedUtil,
36977 root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser,
36978 root.pdfjsCoreImage, root.pdfjsCoreColorSpace, root.pdfjsCoreMurmurHash3,
36979 root.pdfjsCoreFonts, root.pdfjsCoreFunction, root.pdfjsCorePattern,
36980 root.pdfjsCoreCMap, root.pdfjsCoreMetrics, root.pdfjsCoreBidi,
36981 root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts,
36982 root.pdfjsCoreUnicode, root.pdfjsCoreGlyphList);
36983 }
36984}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser,
36985 coreImage, coreColorSpace, coreMurmurHash3, coreFonts,
36986 coreFunction, corePattern, coreCMap, coreMetrics, coreBidi,
36987 coreEncodings, coreStandardFonts, coreUnicode,
36988 coreGlyphList) {
36989
36990var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
36991var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
36992var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
36993var ImageKind = sharedUtil.ImageKind;
36994var OPS = sharedUtil.OPS;
36995var TextRenderingMode = sharedUtil.TextRenderingMode;
36996var Util = sharedUtil.Util;
36997var assert = sharedUtil.assert;
36998var createPromiseCapability = sharedUtil.createPromiseCapability;
36999var error = sharedUtil.error;
37000var info = sharedUtil.info;
37001var isArray = sharedUtil.isArray;
37002var isNum = sharedUtil.isNum;
37003var isString = sharedUtil.isString;
37004var getLookupTableFactory = sharedUtil.getLookupTableFactory;
37005var warn = sharedUtil.warn;
37006var Dict = corePrimitives.Dict;
37007var Name = corePrimitives.Name;
37008var isCmd = corePrimitives.isCmd;
37009var isDict = corePrimitives.isDict;
37010var isName = corePrimitives.isName;
37011var isRef = corePrimitives.isRef;
37012var isStream = corePrimitives.isStream;
37013var DecodeStream = coreStream.DecodeStream;
37014var JpegStream = coreStream.JpegStream;
37015var Stream = coreStream.Stream;
37016var Lexer = coreParser.Lexer;
37017var Parser = coreParser.Parser;
37018var isEOF = coreParser.isEOF;
37019var PDFImage = coreImage.PDFImage;
37020var ColorSpace = coreColorSpace.ColorSpace;
37021var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
37022var ErrorFont = coreFonts.ErrorFont;
37023var FontFlags = coreFonts.FontFlags;
37024var Font = coreFonts.Font;
37025var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
37026var ToUnicodeMap = coreFonts.ToUnicodeMap;
37027var getFontType = coreFonts.getFontType;
37028var isPDFFunction = coreFunction.isPDFFunction;
37029var PDFFunction = coreFunction.PDFFunction;
37030var Pattern = corePattern.Pattern;
37031var getTilingPatternIR = corePattern.getTilingPatternIR;
37032var CMapFactory = coreCMap.CMapFactory;
37033var IdentityCMap = coreCMap.IdentityCMap;
37034var getMetrics = coreMetrics.getMetrics;
37035var bidi = coreBidi.bidi;
37036var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
37037var StandardEncoding = coreEncodings.StandardEncoding;
37038var MacRomanEncoding = coreEncodings.MacRomanEncoding;
37039var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
37040var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
37041var getEncoding = coreEncodings.getEncoding;
37042var getStdFontMap = coreStandardFonts.getStdFontMap;
37043var getSerifFonts = coreStandardFonts.getSerifFonts;
37044var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
37045var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
37046var reverseIfRtl = coreUnicode.reverseIfRtl;
37047var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
37048var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
37049
37050var PartialEvaluator = (function PartialEvaluatorClosure() {
37051 var DefaultPartialEvaluatorOptions = {
37052 forceDataSchema: false,
37053 maxImageSize: -1,
37054 disableFontFace: false,
37055 cMapOptions: { url: null, packed: false }
37056 };
37057
37058 function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
37059 this.xref = xref;
37060 this.resources = resources;
37061 this.handler = handler;
37062 this.forceDataSchema = forceDataSchema;
37063 }
37064 NativeImageDecoder.prototype = {
37065 canDecode: function (image) {
37066 return image instanceof JpegStream &&
37067 NativeImageDecoder.isDecodable(image, this.xref, this.resources);
37068 },
37069 decode: function (image) {
37070 // For natively supported JPEGs send them to the main thread for decoding.
37071 var dict = image.dict;
37072 var colorSpace = dict.get('ColorSpace', 'CS');
37073 colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
37074 var numComps = colorSpace.numComps;
37075 var decodePromise = this.handler.sendWithPromise('JpegDecode',
37076 [image.getIR(this.forceDataSchema), numComps]);
37077 return decodePromise.then(function (message) {
37078 var data = message.data;
37079 return new Stream(data, 0, data.length, image.dict);
37080 });
37081 }
37082 };
37083 /**
37084 * Checks if the image can be decoded and displayed by the browser without any
37085 * further processing such as color space conversions.
37086 */
37087 NativeImageDecoder.isSupported =
37088 function NativeImageDecoder_isSupported(image, xref, res) {
37089 var dict = image.dict;
37090 if (dict.has('DecodeParms') || dict.has('DP')) {
37091 return false;
37092 }
37093 var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
37094 return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') &&
37095 cs.isDefaultDecode(dict.getArray('Decode', 'D'));
37096 };
37097 /**
37098 * Checks if the image can be decoded by the browser.
37099 */
37100 NativeImageDecoder.isDecodable =
37101 function NativeImageDecoder_isDecodable(image, xref, res) {
37102 var dict = image.dict;
37103 if (dict.has('DecodeParms') || dict.has('DP')) {
37104 return false;
37105 }
37106 var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
37107 return (cs.numComps === 1 || cs.numComps === 3) &&
37108 cs.isDefaultDecode(dict.getArray('Decode', 'D'));
37109 };
37110
37111 function PartialEvaluator(pdfManager, xref, handler, pageIndex,
37112 uniquePrefix, idCounters, fontCache, options) {
37113 this.pdfManager = pdfManager;
37114 this.xref = xref;
37115 this.handler = handler;
37116 this.pageIndex = pageIndex;
37117 this.uniquePrefix = uniquePrefix;
37118 this.idCounters = idCounters;
37119 this.fontCache = fontCache;
37120 this.options = options || DefaultPartialEvaluatorOptions;
37121 }
37122
37123 // Trying to minimize Date.now() usage and check every 100 time
37124 var TIME_SLOT_DURATION_MS = 20;
37125 var CHECK_TIME_EVERY = 100;
37126 function TimeSlotManager() {
37127 this.reset();
37128 }
37129 TimeSlotManager.prototype = {
37130 check: function TimeSlotManager_check() {
37131 if (++this.checked < CHECK_TIME_EVERY) {
37132 return false;
37133 }
37134 this.checked = 0;
37135 return this.endTime <= Date.now();
37136 },
37137 reset: function TimeSlotManager_reset() {
37138 this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
37139 this.checked = 0;
37140 }
37141 };
37142
37143 var deferred = Promise.resolve();
37144
37145 var TILING_PATTERN = 1, SHADING_PATTERN = 2;
37146
37147 PartialEvaluator.prototype = {
37148 hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
37149 if (!isDict(resources)) {
37150 return false;
37151 }
37152
37153 var processed = Object.create(null);
37154 if (resources.objId) {
37155 processed[resources.objId] = true;
37156 }
37157
37158 var nodes = [resources], xref = this.xref;
37159 while (nodes.length) {
37160 var key, i, ii;
37161 var node = nodes.shift();
37162 // First check the current resources for blend modes.
37163 var graphicStates = node.get('ExtGState');
37164 if (isDict(graphicStates)) {
37165 var graphicStatesKeys = graphicStates.getKeys();
37166 for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
37167 key = graphicStatesKeys[i];
37168
37169 var graphicState = graphicStates.get(key);
37170 var bm = graphicState.get('BM');
37171 if (isName(bm) && bm.name !== 'Normal') {
37172 return true;
37173 }
37174 }
37175 }
37176 // Descend into the XObjects to look for more resources and blend modes.
37177 var xObjects = node.get('XObject');
37178 if (!isDict(xObjects)) {
37179 continue;
37180 }
37181 var xObjectsKeys = xObjects.getKeys();
37182 for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
37183 key = xObjectsKeys[i];
37184
37185 var xObject = xObjects.getRaw(key);
37186 if (isRef(xObject)) {
37187 if (processed[xObject.toString()]) {
37188 // The XObject has already been processed, and by avoiding a
37189 // redundant `xref.fetch` we can *significantly* reduce the load
37190 // time for badly generated PDF files (fixes issue6961.pdf).
37191 continue;
37192 }
37193 xObject = xref.fetch(xObject);
37194 }
37195 if (!isStream(xObject)) {
37196 continue;
37197 }
37198 if (xObject.dict.objId) {
37199 if (processed[xObject.dict.objId]) {
37200 // stream has objId and is processed already
37201 continue;
37202 }
37203 processed[xObject.dict.objId] = true;
37204 }
37205 var xResources = xObject.dict.get('Resources');
37206 // Checking objId to detect an infinite loop.
37207 if (isDict(xResources) &&
37208 (!xResources.objId || !processed[xResources.objId])) {
37209 nodes.push(xResources);
37210 if (xResources.objId) {
37211 processed[xResources.objId] = true;
37212 }
37213 }
37214 }
37215 }
37216 return false;
37217 },
37218
37219 buildFormXObject: function PartialEvaluator_buildFormXObject(resources,
37220 xobj, smask,
37221 operatorList,
37222 task,
37223 initialState) {
37224 var matrix = xobj.dict.getArray('Matrix');
37225 var bbox = xobj.dict.getArray('BBox');
37226 var group = xobj.dict.get('Group');
37227 if (group) {
37228 var groupOptions = {
37229 matrix: matrix,
37230 bbox: bbox,
37231 smask: smask,
37232 isolated: false,
37233 knockout: false
37234 };
37235
37236 var groupSubtype = group.get('S');
37237 var colorSpace;
37238 if (isName(groupSubtype, 'Transparency')) {
37239 groupOptions.isolated = (group.get('I') || false);
37240 groupOptions.knockout = (group.get('K') || false);
37241 colorSpace = (group.has('CS') ?
37242 ColorSpace.parse(group.get('CS'), this.xref, resources) : null);
37243 }
37244
37245 if (smask && smask.backdrop) {
37246 colorSpace = colorSpace || ColorSpace.singletons.rgb;
37247 smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
37248 }
37249
37250 operatorList.addOp(OPS.beginGroup, [groupOptions]);
37251 }
37252
37253 operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]);
37254
37255 return this.getOperatorList(xobj, task,
37256 (xobj.dict.get('Resources') || resources), operatorList, initialState).
37257 then(function () {
37258 operatorList.addOp(OPS.paintFormXObjectEnd, []);
37259
37260 if (group) {
37261 operatorList.addOp(OPS.endGroup, [groupOptions]);
37262 }
37263 });
37264 },
37265
37266 buildPaintImageXObject:
37267 function PartialEvaluator_buildPaintImageXObject(resources, image,
37268 inline, operatorList,
37269 cacheKey, imageCache) {
37270 var self = this;
37271 var dict = image.dict;
37272 var w = dict.get('Width', 'W');
37273 var h = dict.get('Height', 'H');
37274
37275 if (!(w && isNum(w)) || !(h && isNum(h))) {
37276 warn('Image dimensions are missing, or not numbers.');
37277 return;
37278 }
37279 var maxImageSize = this.options.maxImageSize;
37280 if (maxImageSize !== -1 && w * h > maxImageSize) {
37281 warn('Image exceeded maximum allowed size and was removed.');
37282 return;
37283 }
37284
37285 var imageMask = (dict.get('ImageMask', 'IM') || false);
37286 var imgData, args;
37287 if (imageMask) {
37288 // This depends on a tmpCanvas being filled with the
37289 // current fillStyle, such that processing the pixel
37290 // data can't be done here. Instead of creating a
37291 // complete PDFImage, only read the information needed
37292 // for later.
37293
37294 var width = dict.get('Width', 'W');
37295 var height = dict.get('Height', 'H');
37296 var bitStrideLength = (width + 7) >> 3;
37297 var imgArray = image.getBytes(bitStrideLength * height);
37298 var decode = dict.getArray('Decode', 'D');
37299 var inverseDecode = (!!decode && decode[0] > 0);
37300
37301 imgData = PDFImage.createMask(imgArray, width, height,
37302 image instanceof DecodeStream,
37303 inverseDecode);
37304 imgData.cached = true;
37305 args = [imgData];
37306 operatorList.addOp(OPS.paintImageMaskXObject, args);
37307 if (cacheKey) {
37308 imageCache[cacheKey] = {
37309 fn: OPS.paintImageMaskXObject,
37310 args: args
37311 };
37312 }
37313 return;
37314 }
37315
37316 var softMask = (dict.get('SMask', 'SM') || false);
37317 var mask = (dict.get('Mask') || false);
37318
37319 var SMALL_IMAGE_DIMENSIONS = 200;
37320 // Inlining small images into the queue as RGB data
37321 if (inline && !softMask && !mask && !(image instanceof JpegStream) &&
37322 (w + h) < SMALL_IMAGE_DIMENSIONS) {
37323 var imageObj = new PDFImage(this.xref, resources, image,
37324 inline, null, null);
37325 // We force the use of RGBA_32BPP images here, because we can't handle
37326 // any other kind.
37327 imgData = imageObj.createImageData(/* forceRGBA = */ true);
37328 operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
37329 return;
37330 }
37331
37332 // If there is no imageMask, create the PDFImage and a lot
37333 // of image processing can be done here.
37334 var uniquePrefix = (this.uniquePrefix || '');
37335 var objId = 'img_' + uniquePrefix + (++this.idCounters.obj);
37336 operatorList.addDependency(objId);
37337 args = [objId, w, h];
37338
37339 if (!softMask && !mask && image instanceof JpegStream &&
37340 NativeImageDecoder.isSupported(image, this.xref, resources)) {
37341 // These JPEGs don't need any more processing so we can just send it.
37342 operatorList.addOp(OPS.paintJpegXObject, args);
37343 this.handler.send('obj',
37344 [objId, this.pageIndex, 'JpegStream',
37345 image.getIR(this.options.forceDataSchema)]);
37346 return;
37347 }
37348
37349 // Creates native image decoder only if a JPEG image or mask is present.
37350 var nativeImageDecoder = null;
37351 if (image instanceof JpegStream || mask instanceof JpegStream ||
37352 softMask instanceof JpegStream) {
37353 nativeImageDecoder = new NativeImageDecoder(self.xref, resources,
37354 self.handler, self.options.forceDataSchema);
37355 }
37356
37357 PDFImage.buildImage(self.handler, self.xref, resources, image, inline,
37358 nativeImageDecoder).
37359 then(function(imageObj) {
37360 var imgData = imageObj.createImageData(/* forceRGBA = */ false);
37361 self.handler.send('obj', [objId, self.pageIndex, 'Image', imgData],
37362 [imgData.data.buffer]);
37363 }).then(undefined, function (reason) {
37364 warn('Unable to decode image: ' + reason);
37365 self.handler.send('obj', [objId, self.pageIndex, 'Image', null]);
37366 });
37367
37368 operatorList.addOp(OPS.paintImageXObject, args);
37369 if (cacheKey) {
37370 imageCache[cacheKey] = {
37371 fn: OPS.paintImageXObject,
37372 args: args
37373 };
37374 }
37375 },
37376
37377 handleSMask: function PartialEvaluator_handleSmask(smask, resources,
37378 operatorList, task,
37379 stateManager) {
37380 var smaskContent = smask.get('G');
37381 var smaskOptions = {
37382 subtype: smask.get('S').name,
37383 backdrop: smask.get('BC')
37384 };
37385
37386 // The SMask might have a alpha/luminosity value transfer function --
37387 // we will build a map of integer values in range 0..255 to be fast.
37388 var transferObj = smask.get('TR');
37389 if (isPDFFunction(transferObj)) {
37390 var transferFn = PDFFunction.parse(this.xref, transferObj);
37391 var transferMap = new Uint8Array(256);
37392 var tmp = new Float32Array(1);
37393 for (var i = 0; i < 256; i++) {
37394 tmp[0] = i / 255;
37395 transferFn(tmp, 0, tmp, 0);
37396 transferMap[i] = (tmp[0] * 255) | 0;
37397 }
37398 smaskOptions.transferMap = transferMap;
37399 }
37400
37401 return this.buildFormXObject(resources, smaskContent, smaskOptions,
37402 operatorList, task, stateManager.state.clone());
37403 },
37404
37405 handleTilingType:
37406 function PartialEvaluator_handleTilingType(fn, args, resources,
37407 pattern, patternDict,
37408 operatorList, task) {
37409 // Create an IR of the pattern code.
37410 var tilingOpList = new OperatorList();
37411 // Merge the available resources, to prevent issues when the patternDict
37412 // is missing some /Resources entries (fixes issue6541.pdf).
37413 var resourcesArray = [patternDict.get('Resources'), resources];
37414 var patternResources = Dict.merge(this.xref, resourcesArray);
37415
37416 return this.getOperatorList(pattern, task, patternResources,
37417 tilingOpList).then(function () {
37418 // Add the dependencies to the parent operator list so they are
37419 // resolved before sub operator list is executed synchronously.
37420 operatorList.addDependencies(tilingOpList.dependencies);
37421 operatorList.addOp(fn, getTilingPatternIR({
37422 fnArray: tilingOpList.fnArray,
37423 argsArray: tilingOpList.argsArray
37424 }, patternDict, args));
37425 });
37426 },
37427
37428 handleSetFont:
37429 function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef,
37430 operatorList, task, state) {
37431 // TODO(mack): Not needed?
37432 var fontName;
37433 if (fontArgs) {
37434 fontArgs = fontArgs.slice();
37435 fontName = fontArgs[0].name;
37436 }
37437
37438 var self = this;
37439 return this.loadFont(fontName, fontRef, this.xref, resources).then(
37440 function (translated) {
37441 if (!translated.font.isType3Font) {
37442 return translated;
37443 }
37444 return translated.loadType3Data(self, resources, operatorList, task).
37445 then(function () {
37446 return translated;
37447 }, function (reason) {
37448 // Error in the font data -- sending unsupported feature notification.
37449 self.handler.send('UnsupportedFeature',
37450 {featureId: UNSUPPORTED_FEATURES.font});
37451 return new TranslatedFont('g_font_error',
37452 new ErrorFont('Type3 font load error: ' + reason), translated.font);
37453 });
37454 }).then(function (translated) {
37455 state.font = translated.font;
37456 translated.send(self.handler);
37457 return translated.loadedName;
37458 });
37459 },
37460
37461 handleText: function PartialEvaluator_handleText(chars, state) {
37462 var font = state.font;
37463 var glyphs = font.charsToGlyphs(chars);
37464 var isAddToPathSet = !!(state.textRenderingMode &
37465 TextRenderingMode.ADD_TO_PATH_FLAG);
37466 if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
37467 var buildPath = function (fontChar) {
37468 if (!font.renderer.hasBuiltPath(fontChar)) {
37469 var path = font.renderer.getPathJs(fontChar);
37470 this.handler.send('commonobj', [
37471 font.loadedName + '_path_' + fontChar,
37472 'FontPath',
37473 path
37474 ]);
37475 }
37476 }.bind(this);
37477
37478 for (var i = 0, ii = glyphs.length; i < ii; i++) {
37479 var glyph = glyphs[i];
37480 buildPath(glyph.fontChar);
37481
37482 // If the glyph has an accent we need to build a path for its
37483 // fontChar too, otherwise CanvasGraphics_paintChar will fail.
37484 var accent = glyph.accent;
37485 if (accent && accent.fontChar) {
37486 buildPath(accent.fontChar);
37487 }
37488 }
37489 }
37490
37491 return glyphs;
37492 },
37493
37494 setGState: function PartialEvaluator_setGState(resources, gState,
37495 operatorList, task,
37496 xref, stateManager) {
37497 // This array holds the converted/processed state data.
37498 var gStateObj = [];
37499 var gStateKeys = gState.getKeys();
37500 var self = this;
37501 var promise = Promise.resolve();
37502 for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
37503 var key = gStateKeys[i];
37504 var value = gState.get(key);
37505 switch (key) {
37506 case 'Type':
37507 break;
37508 case 'LW':
37509 case 'LC':
37510 case 'LJ':
37511 case 'ML':
37512 case 'D':
37513 case 'RI':
37514 case 'FL':
37515 case 'CA':
37516 case 'ca':
37517 gStateObj.push([key, value]);
37518 break;
37519 case 'Font':
37520 promise = promise.then(function () {
37521 return self.handleSetFont(resources, null, value[0], operatorList,
37522 task, stateManager.state).
37523 then(function (loadedName) {
37524 operatorList.addDependency(loadedName);
37525 gStateObj.push([key, [loadedName, value[1]]]);
37526 });
37527 });
37528 break;
37529 case 'BM':
37530 gStateObj.push([key, value]);
37531 break;
37532 case 'SMask':
37533 if (isName(value, 'None')) {
37534 gStateObj.push([key, false]);
37535 break;
37536 }
37537 if (isDict(value)) {
37538 promise = promise.then(function (dict) {
37539 return self.handleSMask(dict, resources, operatorList,
37540 task, stateManager);
37541 }.bind(this, value));
37542 gStateObj.push([key, true]);
37543 } else {
37544 warn('Unsupported SMask type');
37545 }
37546
37547 break;
37548 // Only generate info log messages for the following since
37549 // they are unlikely to have a big impact on the rendering.
37550 case 'OP':
37551 case 'op':
37552 case 'OPM':
37553 case 'BG':
37554 case 'BG2':
37555 case 'UCR':
37556 case 'UCR2':
37557 case 'TR':
37558 case 'TR2':
37559 case 'HT':
37560 case 'SM':
37561 case 'SA':
37562 case 'AIS':
37563 case 'TK':
37564 // TODO implement these operators.
37565 info('graphic state operator ' + key);
37566 break;
37567 default:
37568 info('Unknown graphic state operator ' + key);
37569 break;
37570 }
37571 }
37572 return promise.then(function () {
37573 if (gStateObj.length > 0) {
37574 operatorList.addOp(OPS.setGState, [gStateObj]);
37575 }
37576 });
37577 },
37578
37579 loadFont: function PartialEvaluator_loadFont(fontName, font, xref,
37580 resources) {
37581
37582 function errorFont() {
37583 return Promise.resolve(new TranslatedFont('g_font_error',
37584 new ErrorFont('Font ' + fontName + ' is not available'), font));
37585 }
37586 var fontRef;
37587 if (font) { // Loading by ref.
37588 assert(isRef(font));
37589 fontRef = font;
37590 } else { // Loading by name.
37591 var fontRes = resources.get('Font');
37592 if (fontRes) {
37593 fontRef = fontRes.getRaw(fontName);
37594 } else {
37595 warn('fontRes not available');
37596 return errorFont();
37597 }
37598 }
37599 if (!fontRef) {
37600 warn('fontRef not available');
37601 return errorFont();
37602 }
37603
37604 if (this.fontCache.has(fontRef)) {
37605 return this.fontCache.get(fontRef);
37606 }
37607
37608 font = xref.fetchIfRef(fontRef);
37609 if (!isDict(font)) {
37610 return errorFont();
37611 }
37612
37613 // We are holding `font.translated` references just for `fontRef`s that
37614 // are not actually `Ref`s, but rather `Dict`s. See explanation below.
37615 if (font.translated) {
37616 return font.translated;
37617 }
37618
37619 var fontCapability = createPromiseCapability();
37620
37621 var preEvaluatedFont = this.preEvaluateFont(font, xref);
37622 var descriptor = preEvaluatedFont.descriptor;
37623
37624 var fontRefIsRef = isRef(fontRef), fontID;
37625 if (fontRefIsRef) {
37626 fontID = fontRef.toString();
37627 }
37628
37629 if (isDict(descriptor)) {
37630 if (!descriptor.fontAliases) {
37631 descriptor.fontAliases = Object.create(null);
37632 }
37633
37634 var fontAliases = descriptor.fontAliases;
37635 var hash = preEvaluatedFont.hash;
37636 if (fontAliases[hash]) {
37637 var aliasFontRef = fontAliases[hash].aliasRef;
37638 if (fontRefIsRef && aliasFontRef &&
37639 this.fontCache.has(aliasFontRef)) {
37640 this.fontCache.putAlias(fontRef, aliasFontRef);
37641 return this.fontCache.get(fontRef);
37642 }
37643 } else {
37644 fontAliases[hash] = {
37645 fontID: Font.getFontID()
37646 };
37647 }
37648
37649 if (fontRefIsRef) {
37650 fontAliases[hash].aliasRef = fontRef;
37651 }
37652 fontID = fontAliases[hash].fontID;
37653 }
37654
37655 // Workaround for bad PDF generators that reference fonts incorrectly,
37656 // where `fontRef` is a `Dict` rather than a `Ref` (fixes bug946506.pdf).
37657 // In this case we should not put the font into `this.fontCache` (which is
37658 // a `RefSetCache`), since it's not meaningful to use a `Dict` as a key.
37659 //
37660 // However, if we don't cache the font it's not possible to remove it
37661 // when `cleanup` is triggered from the API, which causes issues on
37662 // subsequent rendering operations (see issue7403.pdf).
37663 // A simple workaround would be to just not hold `font.translated`
37664 // references in this case, but this would force us to unnecessarily load
37665 // the same fonts over and over.
37666 //
37667 // Instead, we cheat a bit by attempting to use a modified `fontID` as a
37668 // key in `this.fontCache`, to allow the font to be cached.
37669 // NOTE: This works because `RefSetCache` calls `toString()` on provided
37670 // keys. Also, since `fontRef` is used when getting cached fonts,
37671 // we'll not accidentally match fonts cached with the `fontID`.
37672 if (fontRefIsRef) {
37673 this.fontCache.put(fontRef, fontCapability.promise);
37674 } else {
37675 if (!fontID) {
37676 fontID = (this.uniquePrefix || 'F_') + (++this.idCounters.obj);
37677 }
37678 this.fontCache.put('id_' + fontID, fontCapability.promise);
37679 }
37680 assert(fontID, 'The "fontID" must be defined.');
37681
37682 // Keep track of each font we translated so the caller can
37683 // load them asynchronously before calling display on a page.
37684 font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
37685
37686 font.translated = fontCapability.promise;
37687
37688 // TODO move promises into translate font
37689 var translatedPromise;
37690 try {
37691 translatedPromise = this.translateFont(preEvaluatedFont, xref);
37692 } catch (e) {
37693 translatedPromise = Promise.reject(e);
37694 }
37695
37696 var self = this;
37697 translatedPromise.then(function (translatedFont) {
37698 if (translatedFont.fontType !== undefined) {
37699 var xrefFontStats = xref.stats.fontTypes;
37700 xrefFontStats[translatedFont.fontType] = true;
37701 }
37702
37703 fontCapability.resolve(new TranslatedFont(font.loadedName,
37704 translatedFont, font));
37705 }, function (reason) {
37706 // TODO fontCapability.reject?
37707 // Error in the font data -- sending unsupported feature notification.
37708 self.handler.send('UnsupportedFeature',
37709 {featureId: UNSUPPORTED_FEATURES.font});
37710
37711 try {
37712 // error, but it's still nice to have font type reported
37713 var descriptor = preEvaluatedFont.descriptor;
37714 var fontFile3 = descriptor && descriptor.get('FontFile3');
37715 var subtype = fontFile3 && fontFile3.get('Subtype');
37716 var fontType = getFontType(preEvaluatedFont.type,
37717 subtype && subtype.name);
37718 var xrefFontStats = xref.stats.fontTypes;
37719 xrefFontStats[fontType] = true;
37720 } catch (ex) { }
37721
37722 fontCapability.resolve(new TranslatedFont(font.loadedName,
37723 new ErrorFont(reason instanceof Error ? reason.message : reason),
37724 font));
37725 });
37726 return fontCapability.promise;
37727 },
37728
37729 buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
37730 var lastIndex = operatorList.length - 1;
37731 if (!args) {
37732 args = [];
37733 }
37734 if (lastIndex < 0 ||
37735 operatorList.fnArray[lastIndex] !== OPS.constructPath) {
37736 operatorList.addOp(OPS.constructPath, [[fn], args]);
37737 } else {
37738 var opArgs = operatorList.argsArray[lastIndex];
37739 opArgs[0].push(fn);
37740 Array.prototype.push.apply(opArgs[1], args);
37741 }
37742 },
37743
37744 handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args,
37745 cs, patterns, resources, task, xref) {
37746 // compile tiling patterns
37747 var patternName = args[args.length - 1];
37748 // SCN/scn applies patterns along with normal colors
37749 var pattern;
37750 if (isName(patternName) &&
37751 (pattern = patterns.get(patternName.name))) {
37752 var dict = (isStream(pattern) ? pattern.dict : pattern);
37753 var typeNum = dict.get('PatternType');
37754
37755 if (typeNum === TILING_PATTERN) {
37756 var color = cs.base ? cs.base.getRgb(args, 0) : null;
37757 return this.handleTilingType(fn, color, resources, pattern,
37758 dict, operatorList, task);
37759 } else if (typeNum === SHADING_PATTERN) {
37760 var shading = dict.get('Shading');
37761 var matrix = dict.getArray('Matrix');
37762 pattern = Pattern.parseShading(shading, matrix, xref, resources,
37763 this.handler);
37764 operatorList.addOp(fn, pattern.getIR());
37765 return Promise.resolve();
37766 } else {
37767 return Promise.reject('Unknown PatternType: ' + typeNum);
37768 }
37769 }
37770 // TODO shall we fail here?
37771 operatorList.addOp(fn, args);
37772 return Promise.resolve();
37773 },
37774
37775 getOperatorList: function PartialEvaluator_getOperatorList(stream,
37776 task,
37777 resources,
37778 operatorList,
37779 initialState) {
37780
37781 var self = this;
37782 var xref = this.xref;
37783 var imageCache = Object.create(null);
37784
37785 assert(operatorList);
37786
37787 resources = (resources || Dict.empty);
37788 var xobjs = (resources.get('XObject') || Dict.empty);
37789 var patterns = (resources.get('Pattern') || Dict.empty);
37790 var stateManager = new StateManager(initialState || new EvalState());
37791 var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
37792 var timeSlotManager = new TimeSlotManager();
37793
37794 return new Promise(function promiseBody(resolve, reject) {
37795 var next = function (promise) {
37796 promise.then(function () {
37797 try {
37798 promiseBody(resolve, reject);
37799 } catch (ex) {
37800 reject(ex);
37801 }
37802 }, reject);
37803 };
37804 task.ensureNotTerminated();
37805 timeSlotManager.reset();
37806 var stop, operation = {}, i, ii, cs;
37807 while (!(stop = timeSlotManager.check())) {
37808 // The arguments parsed by read() are used beyond this loop, so we
37809 // cannot reuse the same array on each iteration. Therefore we pass
37810 // in |null| as the initial value (see the comment on
37811 // EvaluatorPreprocessor_read() for why).
37812 operation.args = null;
37813 if (!(preprocessor.read(operation))) {
37814 break;
37815 }
37816 var args = operation.args;
37817 var fn = operation.fn;
37818
37819 switch (fn | 0) {
37820 case OPS.paintXObject:
37821 if (args[0].code) {
37822 break;
37823 }
37824 // eagerly compile XForm objects
37825 var name = args[0].name;
37826 if (!name) {
37827 warn('XObject must be referred to by name.');
37828 continue;
37829 }
37830 if (imageCache[name] !== undefined) {
37831 operatorList.addOp(imageCache[name].fn, imageCache[name].args);
37832 args = null;
37833 continue;
37834 }
37835
37836 var xobj = xobjs.get(name);
37837 if (xobj) {
37838 assert(isStream(xobj), 'XObject should be a stream');
37839
37840 var type = xobj.dict.get('Subtype');
37841 assert(isName(type), 'XObject should have a Name subtype');
37842
37843 if (type.name === 'Form') {
37844 stateManager.save();
37845 next(self.buildFormXObject(resources, xobj, null,
37846 operatorList, task,
37847 stateManager.state.clone()).
37848 then(function () {
37849 stateManager.restore();
37850 }));
37851 return;
37852 } else if (type.name === 'Image') {
37853 self.buildPaintImageXObject(resources, xobj, false,
37854 operatorList, name, imageCache);
37855 args = null;
37856 continue;
37857 } else if (type.name === 'PS') {
37858 // PostScript XObjects are unused when viewing documents.
37859 // See section 4.7.1 of Adobe's PDF reference.
37860 info('Ignored XObject subtype PS');
37861 continue;
37862 } else {
37863 error('Unhandled XObject subtype ' + type.name);
37864 }
37865 }
37866 break;
37867 case OPS.setFont:
37868 var fontSize = args[1];
37869 // eagerly collect all fonts
37870 next(self.handleSetFont(resources, args, null, operatorList,
37871 task, stateManager.state).
37872 then(function (loadedName) {
37873 operatorList.addDependency(loadedName);
37874 operatorList.addOp(OPS.setFont, [loadedName, fontSize]);
37875 }));
37876 return;
37877 case OPS.endInlineImage:
37878 var cacheKey = args[0].cacheKey;
37879 if (cacheKey) {
37880 var cacheEntry = imageCache[cacheKey];
37881 if (cacheEntry !== undefined) {
37882 operatorList.addOp(cacheEntry.fn, cacheEntry.args);
37883 args = null;
37884 continue;
37885 }
37886 }
37887 self.buildPaintImageXObject(resources, args[0], true,
37888 operatorList, cacheKey, imageCache);
37889 args = null;
37890 continue;
37891 case OPS.showText:
37892 args[0] = self.handleText(args[0], stateManager.state);
37893 break;
37894 case OPS.showSpacedText:
37895 var arr = args[0];
37896 var combinedGlyphs = [];
37897 var arrLength = arr.length;
37898 var state = stateManager.state;
37899 for (i = 0; i < arrLength; ++i) {
37900 var arrItem = arr[i];
37901 if (isString(arrItem)) {
37902 Array.prototype.push.apply(combinedGlyphs,
37903 self.handleText(arrItem, state));
37904 } else if (isNum(arrItem)) {
37905 combinedGlyphs.push(arrItem);
37906 }
37907 }
37908 args[0] = combinedGlyphs;
37909 fn = OPS.showText;
37910 break;
37911 case OPS.nextLineShowText:
37912 operatorList.addOp(OPS.nextLine);
37913 args[0] = self.handleText(args[0], stateManager.state);
37914 fn = OPS.showText;
37915 break;
37916 case OPS.nextLineSetSpacingShowText:
37917 operatorList.addOp(OPS.nextLine);
37918 operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
37919 operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
37920 args[0] = self.handleText(args[0], stateManager.state);
37921 fn = OPS.showText;
37922 break;
37923 case OPS.setTextRenderingMode:
37924 stateManager.state.textRenderingMode = args[0];
37925 break;
37926
37927 case OPS.setFillColorSpace:
37928 stateManager.state.fillColorSpace =
37929 ColorSpace.parse(args[0], xref, resources);
37930 continue;
37931 case OPS.setStrokeColorSpace:
37932 stateManager.state.strokeColorSpace =
37933 ColorSpace.parse(args[0], xref, resources);
37934 continue;
37935 case OPS.setFillColor:
37936 cs = stateManager.state.fillColorSpace;
37937 args = cs.getRgb(args, 0);
37938 fn = OPS.setFillRGBColor;
37939 break;
37940 case OPS.setStrokeColor:
37941 cs = stateManager.state.strokeColorSpace;
37942 args = cs.getRgb(args, 0);
37943 fn = OPS.setStrokeRGBColor;
37944 break;
37945 case OPS.setFillGray:
37946 stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
37947 args = ColorSpace.singletons.gray.getRgb(args, 0);
37948 fn = OPS.setFillRGBColor;
37949 break;
37950 case OPS.setStrokeGray:
37951 stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
37952 args = ColorSpace.singletons.gray.getRgb(args, 0);
37953 fn = OPS.setStrokeRGBColor;
37954 break;
37955 case OPS.setFillCMYKColor:
37956 stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
37957 args = ColorSpace.singletons.cmyk.getRgb(args, 0);
37958 fn = OPS.setFillRGBColor;
37959 break;
37960 case OPS.setStrokeCMYKColor:
37961 stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
37962 args = ColorSpace.singletons.cmyk.getRgb(args, 0);
37963 fn = OPS.setStrokeRGBColor;
37964 break;
37965 case OPS.setFillRGBColor:
37966 stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
37967 args = ColorSpace.singletons.rgb.getRgb(args, 0);
37968 break;
37969 case OPS.setStrokeRGBColor:
37970 stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
37971 args = ColorSpace.singletons.rgb.getRgb(args, 0);
37972 break;
37973 case OPS.setFillColorN:
37974 cs = stateManager.state.fillColorSpace;
37975 if (cs.name === 'Pattern') {
37976 next(self.handleColorN(operatorList, OPS.setFillColorN, args,
37977 cs, patterns, resources, task, xref));
37978 return;
37979 }
37980 args = cs.getRgb(args, 0);
37981 fn = OPS.setFillRGBColor;
37982 break;
37983 case OPS.setStrokeColorN:
37984 cs = stateManager.state.strokeColorSpace;
37985 if (cs.name === 'Pattern') {
37986 next(self.handleColorN(operatorList, OPS.setStrokeColorN, args,
37987 cs, patterns, resources, task, xref));
37988 return;
37989 }
37990 args = cs.getRgb(args, 0);
37991 fn = OPS.setStrokeRGBColor;
37992 break;
37993
37994 case OPS.shadingFill:
37995 var shadingRes = resources.get('Shading');
37996 if (!shadingRes) {
37997 error('No shading resource found');
37998 }
37999
38000 var shading = shadingRes.get(args[0].name);
38001 if (!shading) {
38002 error('No shading object found');
38003 }
38004
38005 var shadingFill = Pattern.parseShading(shading, null, xref,
38006 resources, self.handler);
38007 var patternIR = shadingFill.getIR();
38008 args = [patternIR];
38009 fn = OPS.shadingFill;
38010 break;
38011 case OPS.setGState:
38012 var dictName = args[0];
38013 var extGState = resources.get('ExtGState');
38014
38015 if (!isDict(extGState) || !extGState.has(dictName.name)) {
38016 break;
38017 }
38018
38019 var gState = extGState.get(dictName.name);
38020 next(self.setGState(resources, gState, operatorList, task, xref,
38021 stateManager));
38022 return;
38023 case OPS.moveTo:
38024 case OPS.lineTo:
38025 case OPS.curveTo:
38026 case OPS.curveTo2:
38027 case OPS.curveTo3:
38028 case OPS.closePath:
38029 self.buildPath(operatorList, fn, args);
38030 continue;
38031 case OPS.rectangle:
38032 self.buildPath(operatorList, fn, args);
38033 continue;
38034 case OPS.markPoint:
38035 case OPS.markPointProps:
38036 case OPS.beginMarkedContent:
38037 case OPS.beginMarkedContentProps:
38038 case OPS.endMarkedContent:
38039 case OPS.beginCompat:
38040 case OPS.endCompat:
38041 // Ignore operators where the corresponding handlers are known to
38042 // be no-op in CanvasGraphics (display/canvas.js). This prevents
38043 // serialization errors and is also a bit more efficient.
38044 // We could also try to serialize all objects in a general way,
38045 // e.g. as done in https://github.com/mozilla/pdf.js/pull/6266,
38046 // but doing so is meaningless without knowing the semantics.
38047 continue;
38048 default:
38049 // Note: Ignore the operator if it has `Dict` arguments, since
38050 // those are non-serializable, otherwise postMessage will throw
38051 // "An object could not be cloned.".
38052 if (args !== null) {
38053 for (i = 0, ii = args.length; i < ii; i++) {
38054 if (args[i] instanceof Dict) {
38055 break;
38056 }
38057 }
38058 if (i < ii) {
38059 warn('getOperatorList - ignoring operator: ' + fn);
38060 continue;
38061 }
38062 }
38063 }
38064 operatorList.addOp(fn, args);
38065 }
38066 if (stop) {
38067 next(deferred);
38068 return;
38069 }
38070 // Some PDFs don't close all restores inside object/form.
38071 // Closing those for them.
38072 for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
38073 operatorList.addOp(OPS.restore, []);
38074 }
38075 resolve();
38076 });
38077 },
38078
38079 getTextContent:
38080 function PartialEvaluator_getTextContent(stream, task, resources,
38081 stateManager,
38082 normalizeWhitespace,
38083 combineTextItems) {
38084
38085 stateManager = (stateManager || new StateManager(new TextState()));
38086
38087 var WhitespaceRegexp = /\s/g;
38088
38089 var textContent = {
38090 items: [],
38091 styles: Object.create(null)
38092 };
38093 var textContentItem = {
38094 initialized: false,
38095 str: [],
38096 width: 0,
38097 height: 0,
38098 vertical: false,
38099 lastAdvanceWidth: 0,
38100 lastAdvanceHeight: 0,
38101 textAdvanceScale: 0,
38102 spaceWidth: 0,
38103 fakeSpaceMin: Infinity,
38104 fakeMultiSpaceMin: Infinity,
38105 fakeMultiSpaceMax: -0,
38106 textRunBreakAllowed: false,
38107 transform: null,
38108 fontName: null
38109 };
38110 var SPACE_FACTOR = 0.3;
38111 var MULTI_SPACE_FACTOR = 1.5;
38112 var MULTI_SPACE_FACTOR_MAX = 4;
38113
38114 var self = this;
38115 var xref = this.xref;
38116
38117 resources = (xref.fetchIfRef(resources) || Dict.empty);
38118
38119 // The xobj is parsed iff it's needed, e.g. if there is a `DO` cmd.
38120 var xobjs = null;
38121 var xobjsCache = Object.create(null);
38122
38123 var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
38124
38125 var textState;
38126
38127 function ensureTextContentItem() {
38128 if (textContentItem.initialized) {
38129 return textContentItem;
38130 }
38131 var font = textState.font;
38132 if (!(font.loadedName in textContent.styles)) {
38133 textContent.styles[font.loadedName] = {
38134 fontFamily: font.fallbackName,
38135 ascent: font.ascent,
38136 descent: font.descent,
38137 vertical: font.vertical
38138 };
38139 }
38140 textContentItem.fontName = font.loadedName;
38141
38142 // 9.4.4 Text Space Details
38143 var tsm = [textState.fontSize * textState.textHScale, 0,
38144 0, textState.fontSize,
38145 0, textState.textRise];
38146
38147 if (font.isType3Font &&
38148 textState.fontMatrix !== FONT_IDENTITY_MATRIX &&
38149 textState.fontSize === 1) {
38150 var glyphHeight = font.bbox[3] - font.bbox[1];
38151 if (glyphHeight > 0) {
38152 glyphHeight = glyphHeight * textState.fontMatrix[3];
38153 tsm[3] *= glyphHeight;
38154 }
38155 }
38156
38157 var trm = Util.transform(textState.ctm,
38158 Util.transform(textState.textMatrix, tsm));
38159 textContentItem.transform = trm;
38160 if (!font.vertical) {
38161 textContentItem.width = 0;
38162 textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
38163 textContentItem.vertical = false;
38164 } else {
38165 textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
38166 textContentItem.height = 0;
38167 textContentItem.vertical = true;
38168 }
38169
38170 var a = textState.textLineMatrix[0];
38171 var b = textState.textLineMatrix[1];
38172 var scaleLineX = Math.sqrt(a * a + b * b);
38173 a = textState.ctm[0];
38174 b = textState.ctm[1];
38175 var scaleCtmX = Math.sqrt(a * a + b * b);
38176 textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
38177 textContentItem.lastAdvanceWidth = 0;
38178 textContentItem.lastAdvanceHeight = 0;
38179
38180 var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
38181 if (spaceWidth) {
38182 textContentItem.spaceWidth = spaceWidth;
38183 textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
38184 textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
38185 textContentItem.fakeMultiSpaceMax =
38186 spaceWidth * MULTI_SPACE_FACTOR_MAX;
38187 // It's okay for monospace fonts to fake as much space as needed.
38188 textContentItem.textRunBreakAllowed = !font.isMonospace;
38189 } else {
38190 textContentItem.spaceWidth = 0;
38191 textContentItem.fakeSpaceMin = Infinity;
38192 textContentItem.fakeMultiSpaceMin = Infinity;
38193 textContentItem.fakeMultiSpaceMax = 0;
38194 textContentItem.textRunBreakAllowed = false;
38195 }
38196
38197
38198 textContentItem.initialized = true;
38199 return textContentItem;
38200 }
38201
38202 function replaceWhitespace(str) {
38203 // Replaces all whitespaces with standard spaces (0x20), to avoid
38204 // alignment issues between the textLayer and the canvas if the text
38205 // contains e.g. tabs (fixes issue6612.pdf).
38206 var i = 0, ii = str.length, code;
38207 while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
38208 i++;
38209 }
38210 return (i < ii ? str.replace(WhitespaceRegexp, ' ') : str);
38211 }
38212
38213 function runBidiTransform(textChunk) {
38214 var str = textChunk.str.join('');
38215 var bidiResult = bidi(str, -1, textChunk.vertical);
38216 return {
38217 str: (normalizeWhitespace ? replaceWhitespace(bidiResult.str) :
38218 bidiResult.str),
38219 dir: bidiResult.dir,
38220 width: textChunk.width,
38221 height: textChunk.height,
38222 transform: textChunk.transform,
38223 fontName: textChunk.fontName
38224 };
38225 }
38226
38227 function handleSetFont(fontName, fontRef) {
38228 return self.loadFont(fontName, fontRef, xref, resources).
38229 then(function (translated) {
38230 textState.font = translated.font;
38231 textState.fontMatrix = translated.font.fontMatrix ||
38232 FONT_IDENTITY_MATRIX;
38233 });
38234 }
38235
38236 function buildTextContentItem(chars) {
38237 var font = textState.font;
38238 var textChunk = ensureTextContentItem();
38239 var width = 0;
38240 var height = 0;
38241 var glyphs = font.charsToGlyphs(chars);
38242 var defaultVMetrics = font.defaultVMetrics;
38243 for (var i = 0; i < glyphs.length; i++) {
38244 var glyph = glyphs[i];
38245 var vMetricX = null;
38246 var vMetricY = null;
38247 var glyphWidth = null;
38248 if (font.vertical) {
38249 if (glyph.vmetric) {
38250 glyphWidth = glyph.vmetric[0];
38251 vMetricX = glyph.vmetric[1];
38252 vMetricY = glyph.vmetric[2];
38253 } else {
38254 glyphWidth = glyph.width;
38255 vMetricX = glyph.width * 0.5;
38256 vMetricY = defaultVMetrics[2];
38257 }
38258 } else {
38259 glyphWidth = glyph.width;
38260 }
38261
38262 var glyphUnicode = glyph.unicode;
38263 var NormalizedUnicodes = getNormalizedUnicodes();
38264 if (NormalizedUnicodes[glyphUnicode] !== undefined) {
38265 glyphUnicode = NormalizedUnicodes[glyphUnicode];
38266 }
38267 glyphUnicode = reverseIfRtl(glyphUnicode);
38268
38269 // The following will calculate the x and y of the individual glyphs.
38270 // if (font.vertical) {
38271 // tsm[4] -= vMetricX * Math.abs(textState.fontSize) *
38272 // textState.fontMatrix[0];
38273 // tsm[5] -= vMetricY * textState.fontSize *
38274 // textState.fontMatrix[0];
38275 // }
38276 // var trm = Util.transform(textState.textMatrix, tsm);
38277 // var pt = Util.applyTransform([trm[4], trm[5]], textState.ctm);
38278 // var x = pt[0];
38279 // var y = pt[1];
38280
38281 var charSpacing = textState.charSpacing;
38282 if (glyph.isSpace) {
38283 var wordSpacing = textState.wordSpacing;
38284 charSpacing += wordSpacing;
38285 if (wordSpacing > 0) {
38286 addFakeSpaces(wordSpacing, textChunk.str);
38287 }
38288 }
38289
38290 var tx = 0;
38291 var ty = 0;
38292 if (!font.vertical) {
38293 var w0 = glyphWidth * textState.fontMatrix[0];
38294 tx = (w0 * textState.fontSize + charSpacing) *
38295 textState.textHScale;
38296 width += tx;
38297 } else {
38298 var w1 = glyphWidth * textState.fontMatrix[0];
38299 ty = w1 * textState.fontSize + charSpacing;
38300 height += ty;
38301 }
38302 textState.translateTextMatrix(tx, ty);
38303
38304 textChunk.str.push(glyphUnicode);
38305 }
38306
38307 if (!font.vertical) {
38308 textChunk.lastAdvanceWidth = width;
38309 textChunk.width += width * textChunk.textAdvanceScale;
38310 } else {
38311 textChunk.lastAdvanceHeight = height;
38312 textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
38313 }
38314
38315 return textChunk;
38316 }
38317
38318 function addFakeSpaces(width, strBuf) {
38319 if (width < textContentItem.fakeSpaceMin) {
38320 return;
38321 }
38322 if (width < textContentItem.fakeMultiSpaceMin) {
38323 strBuf.push(' ');
38324 return;
38325 }
38326 var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
38327 while (fakeSpaces-- > 0) {
38328 strBuf.push(' ');
38329 }
38330 }
38331
38332 function flushTextContentItem() {
38333 if (!textContentItem.initialized) {
38334 return;
38335 }
38336 textContent.items.push(runBidiTransform(textContentItem));
38337
38338 textContentItem.initialized = false;
38339 textContentItem.str.length = 0;
38340 }
38341
38342 var timeSlotManager = new TimeSlotManager();
38343
38344 return new Promise(function promiseBody(resolve, reject) {
38345 var next = function (promise) {
38346 promise.then(function () {
38347 try {
38348 promiseBody(resolve, reject);
38349 } catch (ex) {
38350 reject(ex);
38351 }
38352 }, reject);
38353 };
38354 task.ensureNotTerminated();
38355 timeSlotManager.reset();
38356 var stop, operation = {}, args = [];
38357 while (!(stop = timeSlotManager.check())) {
38358 // The arguments parsed by read() are not used beyond this loop, so
38359 // we can reuse the same array on every iteration, thus avoiding
38360 // unnecessary allocations.
38361 args.length = 0;
38362 operation.args = args;
38363 if (!(preprocessor.read(operation))) {
38364 break;
38365 }
38366 textState = stateManager.state;
38367 var fn = operation.fn;
38368 args = operation.args;
38369 var advance, diff;
38370
38371 switch (fn | 0) {
38372 case OPS.setFont:
38373 // Optimization to ignore multiple identical Tf commands.
38374 var fontNameArg = args[0].name, fontSizeArg = args[1];
38375 if (textState.font && fontNameArg === textState.fontName &&
38376 fontSizeArg === textState.fontSize) {
38377 break;
38378 }
38379
38380 flushTextContentItem();
38381 textState.fontName = fontNameArg;
38382 textState.fontSize = fontSizeArg;
38383 next(handleSetFont(fontNameArg, null));
38384 return;
38385 case OPS.setTextRise:
38386 flushTextContentItem();
38387 textState.textRise = args[0];
38388 break;
38389 case OPS.setHScale:
38390 flushTextContentItem();
38391 textState.textHScale = args[0] / 100;
38392 break;
38393 case OPS.setLeading:
38394 flushTextContentItem();
38395 textState.leading = args[0];
38396 break;
38397 case OPS.moveText:
38398 // Optimization to treat same line movement as advance
38399 var isSameTextLine = !textState.font ? false :
38400 ((textState.font.vertical ? args[0] : args[1]) === 0);
38401 advance = args[0] - args[1];
38402 if (combineTextItems &&
38403 isSameTextLine && textContentItem.initialized &&
38404 advance > 0 &&
38405 advance <= textContentItem.fakeMultiSpaceMax) {
38406 textState.translateTextLineMatrix(args[0], args[1]);
38407 textContentItem.width +=
38408 (args[0] - textContentItem.lastAdvanceWidth);
38409 textContentItem.height +=
38410 (args[1] - textContentItem.lastAdvanceHeight);
38411 diff = (args[0] - textContentItem.lastAdvanceWidth) -
38412 (args[1] - textContentItem.lastAdvanceHeight);
38413 addFakeSpaces(diff, textContentItem.str);
38414 break;
38415 }
38416
38417 flushTextContentItem();
38418 textState.translateTextLineMatrix(args[0], args[1]);
38419 textState.textMatrix = textState.textLineMatrix.slice();
38420 break;
38421 case OPS.setLeadingMoveText:
38422 flushTextContentItem();
38423 textState.leading = -args[1];
38424 textState.translateTextLineMatrix(args[0], args[1]);
38425 textState.textMatrix = textState.textLineMatrix.slice();
38426 break;
38427 case OPS.nextLine:
38428 flushTextContentItem();
38429 textState.carriageReturn();
38430 break;
38431 case OPS.setTextMatrix:
38432 // Optimization to treat same line movement as advance.
38433 advance = textState.calcTextLineMatrixAdvance(
38434 args[0], args[1], args[2], args[3], args[4], args[5]);
38435 if (combineTextItems &&
38436 advance !== null && textContentItem.initialized &&
38437 advance.value > 0 &&
38438 advance.value <= textContentItem.fakeMultiSpaceMax) {
38439 textState.translateTextLineMatrix(advance.width,
38440 advance.height);
38441 textContentItem.width +=
38442 (advance.width - textContentItem.lastAdvanceWidth);
38443 textContentItem.height +=
38444 (advance.height - textContentItem.lastAdvanceHeight);
38445 diff = (advance.width - textContentItem.lastAdvanceWidth) -
38446 (advance.height - textContentItem.lastAdvanceHeight);
38447 addFakeSpaces(diff, textContentItem.str);
38448 break;
38449 }
38450
38451 flushTextContentItem();
38452 textState.setTextMatrix(args[0], args[1], args[2], args[3],
38453 args[4], args[5]);
38454 textState.setTextLineMatrix(args[0], args[1], args[2], args[3],
38455 args[4], args[5]);
38456 break;
38457 case OPS.setCharSpacing:
38458 textState.charSpacing = args[0];
38459 break;
38460 case OPS.setWordSpacing:
38461 textState.wordSpacing = args[0];
38462 break;
38463 case OPS.beginText:
38464 flushTextContentItem();
38465 textState.textMatrix = IDENTITY_MATRIX.slice();
38466 textState.textLineMatrix = IDENTITY_MATRIX.slice();
38467 break;
38468 case OPS.showSpacedText:
38469 var items = args[0];
38470 var offset;
38471 for (var j = 0, jj = items.length; j < jj; j++) {
38472 if (typeof items[j] === 'string') {
38473 buildTextContentItem(items[j]);
38474 } else {
38475 ensureTextContentItem();
38476
38477 // PDF Specification 5.3.2 states:
38478 // The number is expressed in thousandths of a unit of text
38479 // space.
38480 // This amount is subtracted from the current horizontal or
38481 // vertical coordinate, depending on the writing mode.
38482 // In the default coordinate system, a positive adjustment
38483 // has the effect of moving the next glyph painted either to
38484 // the left or down by the given amount.
38485 advance = items[j] * textState.fontSize / 1000;
38486 var breakTextRun = false;
38487 if (textState.font.vertical) {
38488 offset = advance *
38489 (textState.textHScale * textState.textMatrix[2] +
38490 textState.textMatrix[3]);
38491 textState.translateTextMatrix(0, advance);
38492 breakTextRun = textContentItem.textRunBreakAllowed &&
38493 advance > textContentItem.fakeMultiSpaceMax;
38494 if (!breakTextRun) {
38495 // Value needs to be added to height to paint down.
38496 textContentItem.height += offset;
38497 }
38498 } else {
38499 advance = -advance;
38500 offset = advance * (
38501 textState.textHScale * textState.textMatrix[0] +
38502 textState.textMatrix[1]);
38503 textState.translateTextMatrix(advance, 0);
38504 breakTextRun = textContentItem.textRunBreakAllowed &&
38505 advance > textContentItem.fakeMultiSpaceMax;
38506 if (!breakTextRun) {
38507 // Value needs to be subtracted from width to paint left.
38508 textContentItem.width += offset;
38509 }
38510 }
38511 if (breakTextRun) {
38512 flushTextContentItem();
38513 } else if (advance > 0) {
38514 addFakeSpaces(advance, textContentItem.str);
38515 }
38516 }
38517 }
38518 break;
38519 case OPS.showText:
38520 buildTextContentItem(args[0]);
38521 break;
38522 case OPS.nextLineShowText:
38523 flushTextContentItem();
38524 textState.carriageReturn();
38525 buildTextContentItem(args[0]);
38526 break;
38527 case OPS.nextLineSetSpacingShowText:
38528 flushTextContentItem();
38529 textState.wordSpacing = args[0];
38530 textState.charSpacing = args[1];
38531 textState.carriageReturn();
38532 buildTextContentItem(args[2]);
38533 break;
38534 case OPS.paintXObject:
38535 flushTextContentItem();
38536 if (args[0].code) {
38537 break;
38538 }
38539
38540 if (!xobjs) {
38541 xobjs = (resources.get('XObject') || Dict.empty);
38542 }
38543
38544 var name = args[0].name;
38545 if (xobjsCache.key === name) {
38546 if (xobjsCache.texts) {
38547 Util.appendToArray(textContent.items, xobjsCache.texts.items);
38548 Util.extendObj(textContent.styles, xobjsCache.texts.styles);
38549 }
38550 break;
38551 }
38552
38553 var xobj = xobjs.get(name);
38554 if (!xobj) {
38555 break;
38556 }
38557 assert(isStream(xobj), 'XObject should be a stream');
38558
38559 var type = xobj.dict.get('Subtype');
38560 assert(isName(type), 'XObject should have a Name subtype');
38561
38562 if ('Form' !== type.name) {
38563 xobjsCache.key = name;
38564 xobjsCache.texts = null;
38565 break;
38566 }
38567
38568 stateManager.save();
38569 var matrix = xobj.dict.getArray('Matrix');
38570 if (isArray(matrix) && matrix.length === 6) {
38571 stateManager.transform(matrix);
38572 }
38573
38574 next(self.getTextContent(xobj, task,
38575 xobj.dict.get('Resources') || resources, stateManager,
38576 normalizeWhitespace, combineTextItems).then(
38577 function (formTextContent) {
38578 Util.appendToArray(textContent.items, formTextContent.items);
38579 Util.extendObj(textContent.styles, formTextContent.styles);
38580 stateManager.restore();
38581
38582 xobjsCache.key = name;
38583 xobjsCache.texts = formTextContent;
38584 }));
38585 return;
38586 case OPS.setGState:
38587 flushTextContentItem();
38588 var dictName = args[0];
38589 var extGState = resources.get('ExtGState');
38590
38591 if (!isDict(extGState) || !isName(dictName)) {
38592 break;
38593 }
38594 var gState = extGState.get(dictName.name);
38595 if (!isDict(gState)) {
38596 break;
38597 }
38598 var gStateFont = gState.get('Font');
38599 if (gStateFont) {
38600 textState.fontName = null;
38601 textState.fontSize = gStateFont[1];
38602 next(handleSetFont(null, gStateFont[0]));
38603 return;
38604 }
38605 break;
38606 } // switch
38607 } // while
38608 if (stop) {
38609 next(deferred);
38610 return;
38611 }
38612 flushTextContentItem();
38613 resolve(textContent);
38614 });
38615 },
38616
38617 extractDataStructures:
38618 function PartialEvaluator_extractDataStructures(dict, baseDict,
38619 xref, properties) {
38620 // 9.10.2
38621 var toUnicode = (dict.get('ToUnicode') || baseDict.get('ToUnicode'));
38622 var toUnicodePromise = toUnicode ?
38623 this.readToUnicode(toUnicode) : Promise.resolve(undefined);
38624
38625 if (properties.composite) {
38626 // CIDSystemInfo helps to match CID to glyphs
38627 var cidSystemInfo = dict.get('CIDSystemInfo');
38628 if (isDict(cidSystemInfo)) {
38629 properties.cidSystemInfo = {
38630 registry: cidSystemInfo.get('Registry'),
38631 ordering: cidSystemInfo.get('Ordering'),
38632 supplement: cidSystemInfo.get('Supplement')
38633 };
38634 }
38635
38636 var cidToGidMap = dict.get('CIDToGIDMap');
38637 if (isStream(cidToGidMap)) {
38638 properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
38639 }
38640 }
38641
38642 // Based on 9.6.6 of the spec the encoding can come from multiple places
38643 // and depends on the font type. The base encoding and differences are
38644 // read here, but the encoding that is actually used is chosen during
38645 // glyph mapping in the font.
38646 // TODO: Loading the built in encoding in the font would allow the
38647 // differences to be merged in here not require us to hold on to it.
38648 var differences = [];
38649 var baseEncodingName = null;
38650 var encoding;
38651 if (dict.has('Encoding')) {
38652 encoding = dict.get('Encoding');
38653 if (isDict(encoding)) {
38654 baseEncodingName = encoding.get('BaseEncoding');
38655 baseEncodingName = (isName(baseEncodingName) ?
38656 baseEncodingName.name : null);
38657 // Load the differences between the base and original
38658 if (encoding.has('Differences')) {
38659 var diffEncoding = encoding.get('Differences');
38660 var index = 0;
38661 for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
38662 var data = xref.fetchIfRef(diffEncoding[j]);
38663 if (isNum(data)) {
38664 index = data;
38665 } else if (isName(data)) {
38666 differences[index++] = data.name;
38667 } else {
38668 error('Invalid entry in \'Differences\' array: ' + data);
38669 }
38670 }
38671 }
38672 } else if (isName(encoding)) {
38673 baseEncodingName = encoding.name;
38674 } else {
38675 error('Encoding is not a Name nor a Dict');
38676 }
38677 // According to table 114 if the encoding is a named encoding it must be
38678 // one of these predefined encodings.
38679 if ((baseEncodingName !== 'MacRomanEncoding' &&
38680 baseEncodingName !== 'MacExpertEncoding' &&
38681 baseEncodingName !== 'WinAnsiEncoding')) {
38682 baseEncodingName = null;
38683 }
38684 }
38685
38686 if (baseEncodingName) {
38687 properties.defaultEncoding = getEncoding(baseEncodingName).slice();
38688 } else {
38689 encoding = (properties.type === 'TrueType' ?
38690 WinAnsiEncoding : StandardEncoding);
38691 // The Symbolic attribute can be misused for regular fonts
38692 // Heuristic: we have to check if the font is a standard one also
38693 if (!!(properties.flags & FontFlags.Symbolic)) {
38694 encoding = MacRomanEncoding;
38695 if (!properties.file) {
38696 if (/Symbol/i.test(properties.name)) {
38697 encoding = SymbolSetEncoding;
38698 } else if (/Dingbats/i.test(properties.name)) {
38699 encoding = ZapfDingbatsEncoding;
38700 }
38701 }
38702 }
38703 properties.defaultEncoding = encoding;
38704 }
38705
38706 properties.differences = differences;
38707 properties.baseEncodingName = baseEncodingName;
38708 properties.hasEncoding = !!baseEncodingName || differences.length > 0;
38709 properties.dict = dict;
38710 return toUnicodePromise.then(function(toUnicode) {
38711 properties.toUnicode = toUnicode;
38712 return this.buildToUnicode(properties);
38713 }.bind(this)).then(function (toUnicode) {
38714 properties.toUnicode = toUnicode;
38715 return properties;
38716 });
38717 },
38718
38719 /**
38720 * Builds a char code to unicode map based on section 9.10 of the spec.
38721 * @param {Object} properties Font properties object.
38722 * @return {Promise} A Promise that is resolved with a
38723 * {ToUnicodeMap|IdentityToUnicodeMap} object.
38724 */
38725 buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
38726 properties.hasIncludedToUnicodeMap =
38727 !!properties.toUnicode && properties.toUnicode.length > 0;
38728 // Section 9.10.2 Mapping Character Codes to Unicode Values
38729 if (properties.hasIncludedToUnicodeMap) {
38730 return Promise.resolve(properties.toUnicode);
38731 }
38732 // According to the spec if the font is a simple font we should only map
38733 // to unicode if the base encoding is MacRoman, MacExpert, or WinAnsi or
38734 // the differences array only contains adobe standard or symbol set names,
38735 // in pratice it seems better to always try to create a toUnicode
38736 // map based of the default encoding.
38737 var toUnicode, charcode, glyphName;
38738 if (!properties.composite /* is simple font */) {
38739 toUnicode = [];
38740 var encoding = properties.defaultEncoding.slice();
38741 var baseEncodingName = properties.baseEncodingName;
38742 // Merge in the differences array.
38743 var differences = properties.differences;
38744 for (charcode in differences) {
38745 glyphName = differences[charcode];
38746 if (glyphName === '.notdef') {
38747 // Skip .notdef to prevent rendering errors, e.g. boxes appearing
38748 // where there should be spaces (fixes issue5256.pdf).
38749 continue;
38750 }
38751 encoding[charcode] = glyphName;
38752 }
38753 var glyphsUnicodeMap = getGlyphsUnicode();
38754 for (charcode in encoding) {
38755 // a) Map the character code to a character name.
38756 glyphName = encoding[charcode];
38757 // b) Look up the character name in the Adobe Glyph List (see the
38758 // Bibliography) to obtain the corresponding Unicode value.
38759 if (glyphName === '') {
38760 continue;
38761 } else if (glyphsUnicodeMap[glyphName] === undefined) {
38762 // (undocumented) c) Few heuristics to recognize unknown glyphs
38763 // NOTE: Adobe Reader does not do this step, but OSX Preview does
38764 var code = 0;
38765 switch (glyphName[0]) {
38766 case 'G': // Gxx glyph
38767 if (glyphName.length === 3) {
38768 code = parseInt(glyphName.substr(1), 16);
38769 }
38770 break;
38771 case 'g': // g00xx glyph
38772 if (glyphName.length === 5) {
38773 code = parseInt(glyphName.substr(1), 16);
38774 }
38775 break;
38776 case 'C': // Cddd glyph
38777 case 'c': // cddd glyph
38778 if (glyphName.length >= 3) {
38779 code = +glyphName.substr(1);
38780 }
38781 break;
38782 default:
38783 // 'uniXXXX'/'uXXXX{XX}' glyphs
38784 var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
38785 if (unicode !== -1) {
38786 code = unicode;
38787 }
38788 }
38789 if (code) {
38790 // If |baseEncodingName| is one the predefined encodings,
38791 // and |code| equals |charcode|, using the glyph defined in the
38792 // baseEncoding seems to yield a better |toUnicode| mapping
38793 // (fixes issue 5070).
38794 if (baseEncodingName && code === +charcode) {
38795 var baseEncoding = getEncoding(baseEncodingName);
38796 if (baseEncoding && (glyphName = baseEncoding[charcode])) {
38797 toUnicode[charcode] =
38798 String.fromCharCode(glyphsUnicodeMap[glyphName]);
38799 continue;
38800 }
38801 }
38802 toUnicode[charcode] = String.fromCharCode(code);
38803 }
38804 continue;
38805 }
38806 toUnicode[charcode] =
38807 String.fromCharCode(glyphsUnicodeMap[glyphName]);
38808 }
38809 return Promise.resolve(new ToUnicodeMap(toUnicode));
38810 }
38811 // If the font is a composite font that uses one of the predefined CMaps
38812 // listed in Table 118 (except Identity–H and Identity–V) or whose
38813 // descendant CIDFont uses the Adobe-GB1, Adobe-CNS1, Adobe-Japan1, or
38814 // Adobe-Korea1 character collection:
38815 if (properties.composite && (
38816 (properties.cMap.builtInCMap &&
38817 !(properties.cMap instanceof IdentityCMap)) ||
38818 (properties.cidSystemInfo.registry === 'Adobe' &&
38819 (properties.cidSystemInfo.ordering === 'GB1' ||
38820 properties.cidSystemInfo.ordering === 'CNS1' ||
38821 properties.cidSystemInfo.ordering === 'Japan1' ||
38822 properties.cidSystemInfo.ordering === 'Korea1')))) {
38823 // Then:
38824 // a) Map the character code to a character identifier (CID) according
38825 // to the font’s CMap.
38826 // b) Obtain the registry and ordering of the character collection used
38827 // by the font’s CMap (for example, Adobe and Japan1) from its
38828 // CIDSystemInfo dictionary.
38829 var registry = properties.cidSystemInfo.registry;
38830 var ordering = properties.cidSystemInfo.ordering;
38831 // c) Construct a second CMap name by concatenating the registry and
38832 // ordering obtained in step (b) in the format registry–ordering–UCS2
38833 // (for example, Adobe–Japan1–UCS2).
38834 var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
38835 // d) Obtain the CMap with the name constructed in step (c) (available
38836 // from the ASN Web site; see the Bibliography).
38837 return CMapFactory.create(ucs2CMapName, this.options.cMapOptions,
38838 null).then(
38839 function (ucs2CMap) {
38840 var cMap = properties.cMap;
38841 toUnicode = [];
38842 cMap.forEach(function(charcode, cid) {
38843 assert(cid <= 0xffff, 'Max size of CID is 65,535');
38844 // e) Map the CID obtained in step (a) according to the CMap
38845 // obtained in step (d), producing a Unicode value.
38846 var ucs2 = ucs2CMap.lookup(cid);
38847 if (ucs2) {
38848 toUnicode[charcode] =
38849 String.fromCharCode((ucs2.charCodeAt(0) << 8) +
38850 ucs2.charCodeAt(1));
38851 }
38852 });
38853 return new ToUnicodeMap(toUnicode);
38854 });
38855 }
38856
38857 // The viewer's choice, just use an identity map.
38858 return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar,
38859 properties.lastChar));
38860 },
38861
38862 readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
38863 var cmapObj = toUnicode;
38864 if (isName(cmapObj)) {
38865 return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(
38866 function (cmap) {
38867 if (cmap instanceof IdentityCMap) {
38868 return new IdentityToUnicodeMap(0, 0xFFFF);
38869 }
38870 return new ToUnicodeMap(cmap.getMap());
38871 });
38872 } else if (isStream(cmapObj)) {
38873 return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(
38874 function (cmap) {
38875 if (cmap instanceof IdentityCMap) {
38876 return new IdentityToUnicodeMap(0, 0xFFFF);
38877 }
38878 var map = new Array(cmap.length);
38879 // Convert UTF-16BE
38880 // NOTE: cmap can be a sparse array, so use forEach instead of for(;;)
38881 // to iterate over all keys.
38882 cmap.forEach(function(charCode, token) {
38883 var str = [];
38884 for (var k = 0; k < token.length; k += 2) {
38885 var w1 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1);
38886 if ((w1 & 0xF800) !== 0xD800) { // w1 < 0xD800 || w1 > 0xDFFF
38887 str.push(w1);
38888 continue;
38889 }
38890 k += 2;
38891 var w2 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1);
38892 str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
38893 }
38894 map[charCode] = String.fromCharCode.apply(String, str);
38895 });
38896 return new ToUnicodeMap(map);
38897 });
38898 }
38899 return Promise.resolve(null);
38900 },
38901
38902 readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
38903 // Extract the encoding from the CIDToGIDMap
38904 var glyphsData = cidToGidStream.getBytes();
38905
38906 // Set encoding 0 to later verify the font has an encoding
38907 var result = [];
38908 for (var j = 0, jj = glyphsData.length; j < jj; j++) {
38909 var glyphID = (glyphsData[j++] << 8) | glyphsData[j];
38910 if (glyphID === 0) {
38911 continue;
38912 }
38913 var code = j >> 1;
38914 result[code] = glyphID;
38915 }
38916 return result;
38917 },
38918
38919 extractWidths: function PartialEvaluator_extractWidths(dict, xref,
38920 descriptor,
38921 properties) {
38922 var glyphsWidths = [];
38923 var defaultWidth = 0;
38924 var glyphsVMetrics = [];
38925 var defaultVMetrics;
38926 var i, ii, j, jj, start, code, widths;
38927 if (properties.composite) {
38928 defaultWidth = dict.get('DW') || 1000;
38929
38930 widths = dict.get('W');
38931 if (widths) {
38932 for (i = 0, ii = widths.length; i < ii; i++) {
38933 start = widths[i++];
38934 code = xref.fetchIfRef(widths[i]);
38935 if (isArray(code)) {
38936 for (j = 0, jj = code.length; j < jj; j++) {
38937 glyphsWidths[start++] = code[j];
38938 }
38939 } else {
38940 var width = widths[++i];
38941 for (j = start; j <= code; j++) {
38942 glyphsWidths[j] = width;
38943 }
38944 }
38945 }
38946 }
38947
38948 if (properties.vertical) {
38949 var vmetrics = (dict.get('DW2') || [880, -1000]);
38950 defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
38951 vmetrics = dict.get('W2');
38952 if (vmetrics) {
38953 for (i = 0, ii = vmetrics.length; i < ii; i++) {
38954 start = vmetrics[i++];
38955 code = xref.fetchIfRef(vmetrics[i]);
38956 if (isArray(code)) {
38957 for (j = 0, jj = code.length; j < jj; j++) {
38958 glyphsVMetrics[start++] = [code[j++], code[j++], code[j]];
38959 }
38960 } else {
38961 var vmetric = [vmetrics[++i], vmetrics[++i], vmetrics[++i]];
38962 for (j = start; j <= code; j++) {
38963 glyphsVMetrics[j] = vmetric;
38964 }
38965 }
38966 }
38967 }
38968 }
38969 } else {
38970 var firstChar = properties.firstChar;
38971 widths = dict.get('Widths');
38972 if (widths) {
38973 j = firstChar;
38974 for (i = 0, ii = widths.length; i < ii; i++) {
38975 glyphsWidths[j++] = widths[i];
38976 }
38977 defaultWidth = (parseFloat(descriptor.get('MissingWidth')) || 0);
38978 } else {
38979 // Trying get the BaseFont metrics (see comment above).
38980 var baseFontName = dict.get('BaseFont');
38981 if (isName(baseFontName)) {
38982 var metrics = this.getBaseFontMetrics(baseFontName.name);
38983
38984 glyphsWidths = this.buildCharCodeToWidth(metrics.widths,
38985 properties);
38986 defaultWidth = metrics.defaultWidth;
38987 }
38988 }
38989 }
38990
38991 // Heuristic: detection of monospace font by checking all non-zero widths
38992 var isMonospace = true;
38993 var firstWidth = defaultWidth;
38994 for (var glyph in glyphsWidths) {
38995 var glyphWidth = glyphsWidths[glyph];
38996 if (!glyphWidth) {
38997 continue;
38998 }
38999 if (!firstWidth) {
39000 firstWidth = glyphWidth;
39001 continue;
39002 }
39003 if (firstWidth !== glyphWidth) {
39004 isMonospace = false;
39005 break;
39006 }
39007 }
39008 if (isMonospace) {
39009 properties.flags |= FontFlags.FixedPitch;
39010 }
39011
39012 properties.defaultWidth = defaultWidth;
39013 properties.widths = glyphsWidths;
39014 properties.defaultVMetrics = defaultVMetrics;
39015 properties.vmetrics = glyphsVMetrics;
39016 },
39017
39018 isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
39019 // Simulating descriptor flags attribute
39020 var fontNameWoStyle = baseFontName.split('-')[0];
39021 return (fontNameWoStyle in getSerifFonts()) ||
39022 (fontNameWoStyle.search(/serif/gi) !== -1);
39023 },
39024
39025 getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
39026 var defaultWidth = 0;
39027 var widths = [];
39028 var monospace = false;
39029 var stdFontMap = getStdFontMap();
39030 var lookupName = (stdFontMap[name] || name);
39031 var Metrics = getMetrics();
39032
39033 if (!(lookupName in Metrics)) {
39034 // Use default fonts for looking up font metrics if the passed
39035 // font is not a base font
39036 if (this.isSerifFont(name)) {
39037 lookupName = 'Times-Roman';
39038 } else {
39039 lookupName = 'Helvetica';
39040 }
39041 }
39042 var glyphWidths = Metrics[lookupName];
39043
39044 if (isNum(glyphWidths)) {
39045 defaultWidth = glyphWidths;
39046 monospace = true;
39047 } else {
39048 widths = glyphWidths(); // expand lazy widths array
39049 }
39050
39051 return {
39052 defaultWidth: defaultWidth,
39053 monospace: monospace,
39054 widths: widths
39055 };
39056 },
39057
39058 buildCharCodeToWidth:
39059 function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName,
39060 properties) {
39061 var widths = Object.create(null);
39062 var differences = properties.differences;
39063 var encoding = properties.defaultEncoding;
39064 for (var charCode = 0; charCode < 256; charCode++) {
39065 if (charCode in differences &&
39066 widthsByGlyphName[differences[charCode]]) {
39067 widths[charCode] = widthsByGlyphName[differences[charCode]];
39068 continue;
39069 }
39070 if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
39071 widths[charCode] = widthsByGlyphName[encoding[charCode]];
39072 continue;
39073 }
39074 }
39075 return widths;
39076 },
39077
39078 preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
39079 var baseDict = dict;
39080 var type = dict.get('Subtype');
39081 assert(isName(type), 'invalid font Subtype');
39082
39083 var composite = false;
39084 var uint8array;
39085 if (type.name === 'Type0') {
39086 // If font is a composite
39087 // - get the descendant font
39088 // - set the type according to the descendant font
39089 // - get the FontDescriptor from the descendant font
39090 var df = dict.get('DescendantFonts');
39091 if (!df) {
39092 error('Descendant fonts are not specified');
39093 }
39094 dict = (isArray(df) ? xref.fetchIfRef(df[0]) : df);
39095
39096 type = dict.get('Subtype');
39097 assert(isName(type), 'invalid font Subtype');
39098 composite = true;
39099 }
39100
39101 var descriptor = dict.get('FontDescriptor');
39102 if (descriptor) {
39103 var hash = new MurmurHash3_64();
39104 var encoding = baseDict.getRaw('Encoding');
39105 if (isName(encoding)) {
39106 hash.update(encoding.name);
39107 } else if (isRef(encoding)) {
39108 hash.update(encoding.toString());
39109 } else if (isDict(encoding)) {
39110 var keys = encoding.getKeys();
39111 for (var i = 0, ii = keys.length; i < ii; i++) {
39112 var entry = encoding.getRaw(keys[i]);
39113 if (isName(entry)) {
39114 hash.update(entry.name);
39115 } else if (isRef(entry)) {
39116 hash.update(entry.toString());
39117 } else if (isArray(entry)) { // 'Differences' entry.
39118 // Ideally we should check the contents of the array, but to avoid
39119 // parsing it here and then again in |extractDataStructures|,
39120 // we only use the array length for now (fixes bug1157493.pdf).
39121 hash.update(entry.length.toString());
39122 }
39123 }
39124 }
39125
39126 var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
39127 if (isStream(toUnicode)) {
39128 var stream = toUnicode.str || toUnicode;
39129 uint8array = stream.buffer ?
39130 new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) :
39131 new Uint8Array(stream.bytes.buffer,
39132 stream.start, stream.end - stream.start);
39133 hash.update(uint8array);
39134
39135 } else if (isName(toUnicode)) {
39136 hash.update(toUnicode.name);
39137 }
39138
39139 var widths = dict.get('Widths') || baseDict.get('Widths');
39140 if (widths) {
39141 uint8array = new Uint8Array(new Uint32Array(widths).buffer);
39142 hash.update(uint8array);
39143 }
39144 }
39145
39146 return {
39147 descriptor: descriptor,
39148 dict: dict,
39149 baseDict: baseDict,
39150 composite: composite,
39151 type: type.name,
39152 hash: hash ? hash.hexdigest() : ''
39153 };
39154 },
39155
39156 translateFont: function PartialEvaluator_translateFont(preEvaluatedFont,
39157 xref) {
39158 var baseDict = preEvaluatedFont.baseDict;
39159 var dict = preEvaluatedFont.dict;
39160 var composite = preEvaluatedFont.composite;
39161 var descriptor = preEvaluatedFont.descriptor;
39162 var type = preEvaluatedFont.type;
39163 var maxCharIndex = (composite ? 0xFFFF : 0xFF);
39164 var cMapOptions = this.options.cMapOptions;
39165 var properties;
39166
39167 if (!descriptor) {
39168 if (type === 'Type3') {
39169 // FontDescriptor is only required for Type3 fonts when the document
39170 // is a tagged pdf. Create a barbebones one to get by.
39171 descriptor = new Dict(null);
39172 descriptor.set('FontName', Name.get(type));
39173 descriptor.set('FontBBox', dict.getArray('FontBBox'));
39174 } else {
39175 // Before PDF 1.5 if the font was one of the base 14 fonts, having a
39176 // FontDescriptor was not required.
39177 // This case is here for compatibility.
39178 var baseFontName = dict.get('BaseFont');
39179 if (!isName(baseFontName)) {
39180 error('Base font is not specified');
39181 }
39182
39183 // Using base font name as a font name.
39184 baseFontName = baseFontName.name.replace(/[,_]/g, '-');
39185 var metrics = this.getBaseFontMetrics(baseFontName);
39186
39187 // Simulating descriptor flags attribute
39188 var fontNameWoStyle = baseFontName.split('-')[0];
39189 var flags =
39190 (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) |
39191 (metrics.monospace ? FontFlags.FixedPitch : 0) |
39192 (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic :
39193 FontFlags.Nonsymbolic);
39194
39195 properties = {
39196 type: type,
39197 name: baseFontName,
39198 widths: metrics.widths,
39199 defaultWidth: metrics.defaultWidth,
39200 flags: flags,
39201 firstChar: 0,
39202 lastChar: maxCharIndex
39203 };
39204 return this.extractDataStructures(dict, dict, xref, properties).then(
39205 function (properties) {
39206 properties.widths = this.buildCharCodeToWidth(metrics.widths,
39207 properties);
39208 return new Font(baseFontName, null, properties);
39209 }.bind(this));
39210 }
39211 }
39212
39213 // According to the spec if 'FontDescriptor' is declared, 'FirstChar',
39214 // 'LastChar' and 'Widths' should exist too, but some PDF encoders seem
39215 // to ignore this rule when a variant of a standard font is used.
39216 // TODO Fill the width array depending on which of the base font this is
39217 // a variant.
39218 var firstChar = (dict.get('FirstChar') || 0);
39219 var lastChar = (dict.get('LastChar') || maxCharIndex);
39220
39221 var fontName = descriptor.get('FontName');
39222 var baseFont = dict.get('BaseFont');
39223 // Some bad PDFs have a string as the font name.
39224 if (isString(fontName)) {
39225 fontName = Name.get(fontName);
39226 }
39227 if (isString(baseFont)) {
39228 baseFont = Name.get(baseFont);
39229 }
39230
39231 if (type !== 'Type3') {
39232 var fontNameStr = fontName && fontName.name;
39233 var baseFontStr = baseFont && baseFont.name;
39234 if (fontNameStr !== baseFontStr) {
39235 info('The FontDescriptor\'s FontName is "' + fontNameStr +
39236 '" but should be the same as the Font\'s BaseFont "' +
39237 baseFontStr + '"');
39238 // Workaround for cases where e.g. fontNameStr = 'Arial' and
39239 // baseFontStr = 'Arial,Bold' (needed when no font file is embedded).
39240 if (fontNameStr && baseFontStr &&
39241 baseFontStr.indexOf(fontNameStr) === 0) {
39242 fontName = baseFont;
39243 }
39244 }
39245 }
39246 fontName = (fontName || baseFont);
39247
39248 assert(isName(fontName), 'invalid font name');
39249
39250 var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
39251 if (fontFile) {
39252 if (fontFile.dict) {
39253 var subtype = fontFile.dict.get('Subtype');
39254 if (subtype) {
39255 subtype = subtype.name;
39256 }
39257 var length1 = fontFile.dict.get('Length1');
39258 var length2 = fontFile.dict.get('Length2');
39259 var length3 = fontFile.dict.get('Length3');
39260 }
39261 }
39262
39263 properties = {
39264 type: type,
39265 name: fontName.name,
39266 subtype: subtype,
39267 file: fontFile,
39268 length1: length1,
39269 length2: length2,
39270 length3: length3,
39271 loadedName: baseDict.loadedName,
39272 composite: composite,
39273 wideChars: composite,
39274 fixedPitch: false,
39275 fontMatrix: (dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX),
39276 firstChar: firstChar || 0,
39277 lastChar: (lastChar || maxCharIndex),
39278 bbox: descriptor.getArray('FontBBox'),
39279 ascent: descriptor.get('Ascent'),
39280 descent: descriptor.get('Descent'),
39281 xHeight: descriptor.get('XHeight'),
39282 capHeight: descriptor.get('CapHeight'),
39283 flags: descriptor.get('Flags'),
39284 italicAngle: descriptor.get('ItalicAngle'),
39285 coded: false
39286 };
39287
39288 var cMapPromise;
39289 if (composite) {
39290 var cidEncoding = baseDict.get('Encoding');
39291 if (isName(cidEncoding)) {
39292 properties.cidEncoding = cidEncoding.name;
39293 }
39294 cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(
39295 function (cMap) {
39296 properties.cMap = cMap;
39297 properties.vertical = properties.cMap.vertical;
39298 });
39299 } else {
39300 cMapPromise = Promise.resolve(undefined);
39301 }
39302
39303 return cMapPromise.then(function () {
39304 return this.extractDataStructures(dict, baseDict, xref, properties);
39305 }.bind(this)).then(function (properties) {
39306 this.extractWidths(dict, xref, descriptor, properties);
39307
39308 if (type === 'Type3') {
39309 properties.isType3Font = true;
39310 }
39311
39312 return new Font(fontName.name, fontFile, properties);
39313 }.bind(this));
39314 }
39315 };
39316
39317 return PartialEvaluator;
39318})();
39319
39320var TranslatedFont = (function TranslatedFontClosure() {
39321 function TranslatedFont(loadedName, font, dict) {
39322 this.loadedName = loadedName;
39323 this.font = font;
39324 this.dict = dict;
39325 this.type3Loaded = null;
39326 this.sent = false;
39327 }
39328 TranslatedFont.prototype = {
39329 send: function (handler) {
39330 if (this.sent) {
39331 return;
39332 }
39333 var fontData = this.font.exportData();
39334 handler.send('commonobj', [
39335 this.loadedName,
39336 'Font',
39337 fontData
39338 ]);
39339 this.sent = true;
39340 },
39341 loadType3Data: function (evaluator, resources, parentOperatorList, task) {
39342 assert(this.font.isType3Font);
39343
39344 if (this.type3Loaded) {
39345 return this.type3Loaded;
39346 }
39347
39348 var translatedFont = this.font;
39349 var loadCharProcsPromise = Promise.resolve();
39350 var charProcs = this.dict.get('CharProcs');
39351 var fontResources = this.dict.get('Resources') || resources;
39352 var charProcKeys = charProcs.getKeys();
39353 var charProcOperatorList = Object.create(null);
39354 for (var i = 0, n = charProcKeys.length; i < n; ++i) {
39355 loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
39356 var glyphStream = charProcs.get(key);
39357 var operatorList = new OperatorList();
39358 return evaluator.getOperatorList(glyphStream, task, fontResources,
39359 operatorList).then(function () {
39360 charProcOperatorList[key] = operatorList.getIR();
39361
39362 // Add the dependencies to the parent operator list so they are
39363 // resolved before sub operator list is executed synchronously.
39364 parentOperatorList.addDependencies(operatorList.dependencies);
39365 }, function (reason) {
39366 warn('Type3 font resource \"' + key + '\" is not available');
39367 var operatorList = new OperatorList();
39368 charProcOperatorList[key] = operatorList.getIR();
39369 });
39370 }.bind(this, charProcKeys[i]));
39371 }
39372 this.type3Loaded = loadCharProcsPromise.then(function () {
39373 translatedFont.charProcOperatorList = charProcOperatorList;
39374 });
39375 return this.type3Loaded;
39376 }
39377 };
39378 return TranslatedFont;
39379})();
39380
39381var OperatorList = (function OperatorListClosure() {
39382 var CHUNK_SIZE = 1000;
39383 var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5; // close to chunk size
39384
39385 function getTransfers(queue) {
39386 var transfers = [];
39387 var fnArray = queue.fnArray, argsArray = queue.argsArray;
39388 for (var i = 0, ii = queue.length; i < ii; i++) {
39389 switch (fnArray[i]) {
39390 case OPS.paintInlineImageXObject:
39391 case OPS.paintInlineImageXObjectGroup:
39392 case OPS.paintImageMaskXObject:
39393 var arg = argsArray[i][0]; // first param in imgData
39394 if (!arg.cached) {
39395 transfers.push(arg.data.buffer);
39396 }
39397 break;
39398 }
39399 }
39400 return transfers;
39401 }
39402
39403 function OperatorList(intent, messageHandler, pageIndex) {
39404 this.messageHandler = messageHandler;
39405 this.fnArray = [];
39406 this.argsArray = [];
39407 this.dependencies = Object.create(null);
39408 this._totalLength = 0;
39409 this.pageIndex = pageIndex;
39410 this.intent = intent;
39411 }
39412
39413 OperatorList.prototype = {
39414 get length() {
39415 return this.argsArray.length;
39416 },
39417
39418 /**
39419 * @returns {number} The total length of the entire operator list,
39420 * since `this.length === 0` after flushing.
39421 */
39422 get totalLength() {
39423 return (this._totalLength + this.length);
39424 },
39425
39426 addOp: function(fn, args) {
39427 this.fnArray.push(fn);
39428 this.argsArray.push(args);
39429 if (this.messageHandler) {
39430 if (this.fnArray.length >= CHUNK_SIZE) {
39431 this.flush();
39432 } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT &&
39433 (fn === OPS.restore || fn === OPS.endText)) {
39434 // heuristic to flush on boundary of restore or endText
39435 this.flush();
39436 }
39437 }
39438 },
39439
39440 addDependency: function(dependency) {
39441 if (dependency in this.dependencies) {
39442 return;
39443 }
39444 this.dependencies[dependency] = true;
39445 this.addOp(OPS.dependency, [dependency]);
39446 },
39447
39448 addDependencies: function(dependencies) {
39449 for (var key in dependencies) {
39450 this.addDependency(key);
39451 }
39452 },
39453
39454 addOpList: function(opList) {
39455 Util.extendObj(this.dependencies, opList.dependencies);
39456 for (var i = 0, ii = opList.length; i < ii; i++) {
39457 this.addOp(opList.fnArray[i], opList.argsArray[i]);
39458 }
39459 },
39460
39461 getIR: function() {
39462 return {
39463 fnArray: this.fnArray,
39464 argsArray: this.argsArray,
39465 length: this.length
39466 };
39467 },
39468
39469 flush: function(lastChunk) {
39470 if (this.intent !== 'oplist') {
39471 new QueueOptimizer().optimize(this);
39472 }
39473 var transfers = getTransfers(this);
39474 var length = this.length;
39475 this._totalLength += length;
39476
39477 this.messageHandler.send('RenderPageChunk', {
39478 operatorList: {
39479 fnArray: this.fnArray,
39480 argsArray: this.argsArray,
39481 lastChunk: lastChunk,
39482 length: length
39483 },
39484 pageIndex: this.pageIndex,
39485 intent: this.intent
39486 }, transfers);
39487 this.dependencies = Object.create(null);
39488 this.fnArray.length = 0;
39489 this.argsArray.length = 0;
39490 }
39491 };
39492
39493 return OperatorList;
39494})();
39495
39496var StateManager = (function StateManagerClosure() {
39497 function StateManager(initialState) {
39498 this.state = initialState;
39499 this.stateStack = [];
39500 }
39501 StateManager.prototype = {
39502 save: function () {
39503 var old = this.state;
39504 this.stateStack.push(this.state);
39505 this.state = old.clone();
39506 },
39507 restore: function () {
39508 var prev = this.stateStack.pop();
39509 if (prev) {
39510 this.state = prev;
39511 }
39512 },
39513 transform: function (args) {
39514 this.state.ctm = Util.transform(this.state.ctm, args);
39515 }
39516 };
39517 return StateManager;
39518})();
39519
39520var TextState = (function TextStateClosure() {
39521 function TextState() {
39522 this.ctm = new Float32Array(IDENTITY_MATRIX);
39523 this.fontName = null;
39524 this.fontSize = 0;
39525 this.font = null;
39526 this.fontMatrix = FONT_IDENTITY_MATRIX;
39527 this.textMatrix = IDENTITY_MATRIX.slice();
39528 this.textLineMatrix = IDENTITY_MATRIX.slice();
39529 this.charSpacing = 0;
39530 this.wordSpacing = 0;
39531 this.leading = 0;
39532 this.textHScale = 1;
39533 this.textRise = 0;
39534 }
39535
39536 TextState.prototype = {
39537 setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
39538 var m = this.textMatrix;
39539 m[0] = a; m[1] = b; m[2] = c; m[3] = d; m[4] = e; m[5] = f;
39540 },
39541 setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
39542 var m = this.textLineMatrix;
39543 m[0] = a; m[1] = b; m[2] = c; m[3] = d; m[4] = e; m[5] = f;
39544 },
39545 translateTextMatrix: function TextState_translateTextMatrix(x, y) {
39546 var m = this.textMatrix;
39547 m[4] = m[0] * x + m[2] * y + m[4];
39548 m[5] = m[1] * x + m[3] * y + m[5];
39549 },
39550 translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
39551 var m = this.textLineMatrix;
39552 m[4] = m[0] * x + m[2] * y + m[4];
39553 m[5] = m[1] * x + m[3] * y + m[5];
39554 },
39555 calcTextLineMatrixAdvance:
39556 function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
39557 var font = this.font;
39558 if (!font) {
39559 return null;
39560 }
39561 var m = this.textLineMatrix;
39562 if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
39563 return null;
39564 }
39565 var txDiff = e - m[4], tyDiff = f - m[5];
39566 if ((font.vertical && txDiff !== 0) || (!font.vertical && tyDiff !== 0)) {
39567 return null;
39568 }
39569 var tx, ty, denominator = a * d - b * c;
39570 if (font.vertical) {
39571 tx = -tyDiff * c / denominator;
39572 ty = tyDiff * a / denominator;
39573 } else {
39574 tx = txDiff * d / denominator;
39575 ty = -txDiff * b / denominator;
39576 }
39577 return { width: tx, height: ty, value: (font.vertical ? ty : tx), };
39578 },
39579 calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
39580 // 9.4.4 Text Space Details
39581 var tsm = [this.fontSize * this.textHScale, 0,
39582 0, this.fontSize,
39583 0, this.textRise];
39584 return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
39585 },
39586 carriageReturn: function TextState_carriageReturn() {
39587 this.translateTextLineMatrix(0, -this.leading);
39588 this.textMatrix = this.textLineMatrix.slice();
39589 },
39590 clone: function TextState_clone() {
39591 var clone = Object.create(this);
39592 clone.textMatrix = this.textMatrix.slice();
39593 clone.textLineMatrix = this.textLineMatrix.slice();
39594 clone.fontMatrix = this.fontMatrix.slice();
39595 return clone;
39596 }
39597 };
39598 return TextState;
39599})();
39600
39601var EvalState = (function EvalStateClosure() {
39602 function EvalState() {
39603 this.ctm = new Float32Array(IDENTITY_MATRIX);
39604 this.font = null;
39605 this.textRenderingMode = TextRenderingMode.FILL;
39606 this.fillColorSpace = ColorSpace.singletons.gray;
39607 this.strokeColorSpace = ColorSpace.singletons.gray;
39608 }
39609 EvalState.prototype = {
39610 clone: function CanvasExtraState_clone() {
39611 return Object.create(this);
39612 },
39613 };
39614 return EvalState;
39615})();
39616
39617var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
39618 // Specifies properties for each command
39619 //
39620 // If variableArgs === true: [0, `numArgs`] expected
39621 // If variableArgs === false: exactly `numArgs` expected
39622 var getOPMap = getLookupTableFactory(function (t) {
39623 // Graphic state
39624 t['w'] = { id: OPS.setLineWidth, numArgs: 1, variableArgs: false };
39625 t['J'] = { id: OPS.setLineCap, numArgs: 1, variableArgs: false };
39626 t['j'] = { id: OPS.setLineJoin, numArgs: 1, variableArgs: false };
39627 t['M'] = { id: OPS.setMiterLimit, numArgs: 1, variableArgs: false };
39628 t['d'] = { id: OPS.setDash, numArgs: 2, variableArgs: false };
39629 t['ri'] = { id: OPS.setRenderingIntent, numArgs: 1, variableArgs: false };
39630 t['i'] = { id: OPS.setFlatness, numArgs: 1, variableArgs: false };
39631 t['gs'] = { id: OPS.setGState, numArgs: 1, variableArgs: false };
39632 t['q'] = { id: OPS.save, numArgs: 0, variableArgs: false };
39633 t['Q'] = { id: OPS.restore, numArgs: 0, variableArgs: false };
39634 t['cm'] = { id: OPS.transform, numArgs: 6, variableArgs: false };
39635
39636 // Path
39637 t['m'] = { id: OPS.moveTo, numArgs: 2, variableArgs: false };
39638 t['l'] = { id: OPS.lineTo, numArgs: 2, variableArgs: false };
39639 t['c'] = { id: OPS.curveTo, numArgs: 6, variableArgs: false };
39640 t['v'] = { id: OPS.curveTo2, numArgs: 4, variableArgs: false };
39641 t['y'] = { id: OPS.curveTo3, numArgs: 4, variableArgs: false };
39642 t['h'] = { id: OPS.closePath, numArgs: 0, variableArgs: false };
39643 t['re'] = { id: OPS.rectangle, numArgs: 4, variableArgs: false };
39644 t['S'] = { id: OPS.stroke, numArgs: 0, variableArgs: false };
39645 t['s'] = { id: OPS.closeStroke, numArgs: 0, variableArgs: false };
39646 t['f'] = { id: OPS.fill, numArgs: 0, variableArgs: false };
39647 t['F'] = { id: OPS.fill, numArgs: 0, variableArgs: false };
39648 t['f*'] = { id: OPS.eoFill, numArgs: 0, variableArgs: false };
39649 t['B'] = { id: OPS.fillStroke, numArgs: 0, variableArgs: false };
39650 t['B*'] = { id: OPS.eoFillStroke, numArgs: 0, variableArgs: false };
39651 t['b'] = { id: OPS.closeFillStroke, numArgs: 0, variableArgs: false };
39652 t['b*'] = { id: OPS.closeEOFillStroke, numArgs: 0, variableArgs: false };
39653 t['n'] = { id: OPS.endPath, numArgs: 0, variableArgs: false };
39654
39655 // Clipping
39656 t['W'] = { id: OPS.clip, numArgs: 0, variableArgs: false };
39657 t['W*'] = { id: OPS.eoClip, numArgs: 0, variableArgs: false };
39658
39659 // Text
39660 t['BT'] = { id: OPS.beginText, numArgs: 0, variableArgs: false };
39661 t['ET'] = { id: OPS.endText, numArgs: 0, variableArgs: false };
39662 t['Tc'] = { id: OPS.setCharSpacing, numArgs: 1, variableArgs: false };
39663 t['Tw'] = { id: OPS.setWordSpacing, numArgs: 1, variableArgs: false };
39664 t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false };
39665 t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false };
39666 t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false };
39667 t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false };
39668 t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false };
39669 t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false };
39670 t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false };
39671 t['Tm'] = { id: OPS.setTextMatrix, numArgs: 6, variableArgs: false };
39672 t['T*'] = { id: OPS.nextLine, numArgs: 0, variableArgs: false };
39673 t['Tj'] = { id: OPS.showText, numArgs: 1, variableArgs: false };
39674 t['TJ'] = { id: OPS.showSpacedText, numArgs: 1, variableArgs: false };
39675 t['\''] = { id: OPS.nextLineShowText, numArgs: 1, variableArgs: false };
39676 t['"'] = { id: OPS.nextLineSetSpacingShowText, numArgs: 3,
39677 variableArgs: false };
39678
39679 // Type3 fonts
39680 t['d0'] = { id: OPS.setCharWidth, numArgs: 2, variableArgs: false };
39681 t['d1'] = { id: OPS.setCharWidthAndBounds, numArgs: 6,
39682 variableArgs: false };
39683
39684 // Color
39685 t['CS'] = { id: OPS.setStrokeColorSpace, numArgs: 1, variableArgs: false };
39686 t['cs'] = { id: OPS.setFillColorSpace, numArgs: 1, variableArgs: false };
39687 t['SC'] = { id: OPS.setStrokeColor, numArgs: 4, variableArgs: true };
39688 t['SCN'] = { id: OPS.setStrokeColorN, numArgs: 33, variableArgs: true };
39689 t['sc'] = { id: OPS.setFillColor, numArgs: 4, variableArgs: true };
39690 t['scn'] = { id: OPS.setFillColorN, numArgs: 33, variableArgs: true };
39691 t['G'] = { id: OPS.setStrokeGray, numArgs: 1, variableArgs: false };
39692 t['g'] = { id: OPS.setFillGray, numArgs: 1, variableArgs: false };
39693 t['RG'] = { id: OPS.setStrokeRGBColor, numArgs: 3, variableArgs: false };
39694 t['rg'] = { id: OPS.setFillRGBColor, numArgs: 3, variableArgs: false };
39695 t['K'] = { id: OPS.setStrokeCMYKColor, numArgs: 4, variableArgs: false };
39696 t['k'] = { id: OPS.setFillCMYKColor, numArgs: 4, variableArgs: false };
39697
39698 // Shading
39699 t['sh'] = { id: OPS.shadingFill, numArgs: 1, variableArgs: false };
39700
39701 // Images
39702 t['BI'] = { id: OPS.beginInlineImage, numArgs: 0, variableArgs: false };
39703 t['ID'] = { id: OPS.beginImageData, numArgs: 0, variableArgs: false };
39704 t['EI'] = { id: OPS.endInlineImage, numArgs: 1, variableArgs: false };
39705
39706 // XObjects
39707 t['Do'] = { id: OPS.paintXObject, numArgs: 1, variableArgs: false };
39708 t['MP'] = { id: OPS.markPoint, numArgs: 1, variableArgs: false };
39709 t['DP'] = { id: OPS.markPointProps, numArgs: 2, variableArgs: false };
39710 t['BMC'] = { id: OPS.beginMarkedContent, numArgs: 1, variableArgs: false };
39711 t['BDC'] = { id: OPS.beginMarkedContentProps, numArgs: 2,
39712 variableArgs: false };
39713 t['EMC'] = { id: OPS.endMarkedContent, numArgs: 0, variableArgs: false };
39714
39715 // Compatibility
39716 t['BX'] = { id: OPS.beginCompat, numArgs: 0, variableArgs: false };
39717 t['EX'] = { id: OPS.endCompat, numArgs: 0, variableArgs: false };
39718
39719 // (reserved partial commands for the lexer)
39720 t['BM'] = null;
39721 t['BD'] = null;
39722 t['true'] = null;
39723 t['fa'] = null;
39724 t['fal'] = null;
39725 t['fals'] = null;
39726 t['false'] = null;
39727 t['nu'] = null;
39728 t['nul'] = null;
39729 t['null'] = null;
39730 });
39731
39732 function EvaluatorPreprocessor(stream, xref, stateManager) {
39733 this.opMap = getOPMap();
39734 // TODO(mduan): pass array of knownCommands rather than this.opMap
39735 // dictionary
39736 this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
39737 this.stateManager = stateManager;
39738 this.nonProcessedArgs = [];
39739 }
39740
39741 EvaluatorPreprocessor.prototype = {
39742 get savedStatesDepth() {
39743 return this.stateManager.stateStack.length;
39744 },
39745
39746 // |operation| is an object with two fields:
39747 //
39748 // - |fn| is an out param.
39749 //
39750 // - |args| is an inout param. On entry, it should have one of two values.
39751 //
39752 // - An empty array. This indicates that the caller is providing the
39753 // array in which the args will be stored in. The caller should use
39754 // this value if it can reuse a single array for each call to read().
39755 //
39756 // - |null|. This indicates that the caller needs this function to create
39757 // the array in which any args are stored in. If there are zero args,
39758 // this function will leave |operation.args| as |null| (thus avoiding
39759 // allocations that would occur if we used an empty array to represent
39760 // zero arguments). Otherwise, it will replace |null| with a new array
39761 // containing the arguments. The caller should use this value if it
39762 // cannot reuse an array for each call to read().
39763 //
39764 // These two modes are present because this function is very hot and so
39765 // avoiding allocations where possible is worthwhile.
39766 //
39767 read: function EvaluatorPreprocessor_read(operation) {
39768 var args = operation.args;
39769 while (true) {
39770 var obj = this.parser.getObj();
39771 if (isCmd(obj)) {
39772 var cmd = obj.cmd;
39773 // Check that the command is valid
39774 var opSpec = this.opMap[cmd];
39775 if (!opSpec) {
39776 warn('Unknown command "' + cmd + '"');
39777 continue;
39778 }
39779
39780 var fn = opSpec.id;
39781 var numArgs = opSpec.numArgs;
39782 var argsLength = args !== null ? args.length : 0;
39783
39784 if (!opSpec.variableArgs) {
39785 // Postscript commands can be nested, e.g. /F2 /GS2 gs 5.711 Tf
39786 if (argsLength !== numArgs) {
39787 var nonProcessedArgs = this.nonProcessedArgs;
39788 while (argsLength > numArgs) {
39789 nonProcessedArgs.push(args.shift());
39790 argsLength--;
39791 }
39792 while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
39793 if (!args) {
39794 args = [];
39795 }
39796 args.unshift(nonProcessedArgs.pop());
39797 argsLength++;
39798 }
39799 }
39800
39801 if (argsLength < numArgs) {
39802 // If we receive too few args, it's not possible to possible
39803 // to execute the command, so skip the command
39804 info('Command ' + fn + ': because expected ' +
39805 numArgs + ' args, but received ' + argsLength +
39806 ' args; skipping');
39807 args = null;
39808 continue;
39809 }
39810 } else if (argsLength > numArgs) {
39811 info('Command ' + fn + ': expected [0,' + numArgs +
39812 '] args, but received ' + argsLength + ' args');
39813 }
39814
39815 // TODO figure out how to type-check vararg functions
39816 this.preprocessCommand(fn, args);
39817
39818 operation.fn = fn;
39819 operation.args = args;
39820 return true;
39821 } else {
39822 if (isEOF(obj)) {
39823 return false; // no more commands
39824 }
39825 // argument
39826 if (obj !== null) {
39827 if (!args) {
39828 args = [];
39829 }
39830 args.push(obj);
39831 assert(args.length <= 33, 'Too many arguments');
39832 }
39833 }
39834 }
39835 },
39836
39837 preprocessCommand:
39838 function EvaluatorPreprocessor_preprocessCommand(fn, args) {
39839 switch (fn | 0) {
39840 case OPS.save:
39841 this.stateManager.save();
39842 break;
39843 case OPS.restore:
39844 this.stateManager.restore();
39845 break;
39846 case OPS.transform:
39847 this.stateManager.transform(args);
39848 break;
39849 }
39850 }
39851 };
39852 return EvaluatorPreprocessor;
39853})();
39854
39855var QueueOptimizer = (function QueueOptimizerClosure() {
39856 function addState(parentState, pattern, fn) {
39857 var state = parentState;
39858 for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
39859 var item = pattern[i];
39860 state = (state[item] || (state[item] = []));
39861 }
39862 state[pattern[pattern.length - 1]] = fn;
39863 }
39864
39865 function handlePaintSolidColorImageMask(iFirstSave, count, fnArray,
39866 argsArray) {
39867 // Handles special case of mainly LaTeX documents which use image masks to
39868 // draw lines with the current fill style.
39869 // 'count' groups of (save, transform, paintImageMaskXObject, restore)+
39870 // have been found at iFirstSave.
39871 var iFirstPIMXO = iFirstSave + 2;
39872 for (var i = 0; i < count; i++) {
39873 var arg = argsArray[iFirstPIMXO + 4 * i];
39874 var imageMask = arg.length === 1 && arg[0];
39875 if (imageMask && imageMask.width === 1 && imageMask.height === 1 &&
39876 (!imageMask.data.length ||
39877 (imageMask.data.length === 1 && imageMask.data[0] === 0))) {
39878 fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
39879 continue;
39880 }
39881 break;
39882 }
39883 return count - i;
39884 }
39885
39886 var InitialState = [];
39887
39888 // This replaces (save, transform, paintInlineImageXObject, restore)+
39889 // sequences with one |paintInlineImageXObjectGroup| operation.
39890 addState(InitialState,
39891 [OPS.save, OPS.transform, OPS.paintInlineImageXObject, OPS.restore],
39892 function foundInlineImageGroup(context) {
39893 var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
39894 var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
39895 var MAX_WIDTH = 1000;
39896 var IMAGE_PADDING = 1;
39897
39898 var fnArray = context.fnArray, argsArray = context.argsArray;
39899 var curr = context.iCurr;
39900 var iFirstSave = curr - 3;
39901 var iFirstTransform = curr - 2;
39902 var iFirstPIIXO = curr - 1;
39903
39904 // Look for the quartets.
39905 var i = iFirstSave + 4;
39906 var ii = fnArray.length;
39907 while (i + 3 < ii) {
39908 if (fnArray[i] !== OPS.save ||
39909 fnArray[i + 1] !== OPS.transform ||
39910 fnArray[i + 2] !== OPS.paintInlineImageXObject ||
39911 fnArray[i + 3] !== OPS.restore) {
39912 break; // ops don't match
39913 }
39914 i += 4;
39915 }
39916
39917 // At this point, i is the index of the first op past the last valid
39918 // quartet.
39919 var count = Math.min((i - iFirstSave) / 4,
39920 MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
39921 if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
39922 return i;
39923 }
39924
39925 // assuming that heights of those image is too small (~1 pixel)
39926 // packing as much as possible by lines
39927 var maxX = 0;
39928 var map = [], maxLineHeight = 0;
39929 var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
39930 var q;
39931 for (q = 0; q < count; q++) {
39932 var transform = argsArray[iFirstTransform + (q << 2)];
39933 var img = argsArray[iFirstPIIXO + (q << 2)][0];
39934 if (currentX + img.width > MAX_WIDTH) {
39935 // starting new line
39936 maxX = Math.max(maxX, currentX);
39937 currentY += maxLineHeight + 2 * IMAGE_PADDING;
39938 currentX = 0;
39939 maxLineHeight = 0;
39940 }
39941 map.push({
39942 transform: transform,
39943 x: currentX, y: currentY,
39944 w: img.width, h: img.height
39945 });
39946 currentX += img.width + 2 * IMAGE_PADDING;
39947 maxLineHeight = Math.max(maxLineHeight, img.height);
39948 }
39949 var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
39950 var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
39951 var imgData = new Uint8Array(imgWidth * imgHeight * 4);
39952 var imgRowSize = imgWidth << 2;
39953 for (q = 0; q < count; q++) {
39954 var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
39955 // Copy image by lines and extends pixels into padding.
39956 var rowSize = map[q].w << 2;
39957 var dataOffset = 0;
39958 var offset = (map[q].x + map[q].y * imgWidth) << 2;
39959 imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
39960 for (var k = 0, kk = map[q].h; k < kk; k++) {
39961 imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
39962 dataOffset += rowSize;
39963 offset += imgRowSize;
39964 }
39965 imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
39966 while (offset >= 0) {
39967 data[offset - 4] = data[offset];
39968 data[offset - 3] = data[offset + 1];
39969 data[offset - 2] = data[offset + 2];
39970 data[offset - 1] = data[offset + 3];
39971 data[offset + rowSize] = data[offset + rowSize - 4];
39972 data[offset + rowSize + 1] = data[offset + rowSize - 3];
39973 data[offset + rowSize + 2] = data[offset + rowSize - 2];
39974 data[offset + rowSize + 3] = data[offset + rowSize - 1];
39975 offset -= imgRowSize;
39976 }
39977 }
39978
39979 // Replace queue items.
39980 fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
39981 argsArray.splice(iFirstSave, count * 4,
39982 [{ width: imgWidth, height: imgHeight, kind: ImageKind.RGBA_32BPP,
39983 data: imgData }, map]);
39984
39985 return iFirstSave + 1;
39986 });
39987
39988 // This replaces (save, transform, paintImageMaskXObject, restore)+
39989 // sequences with one |paintImageMaskXObjectGroup| or one
39990 // |paintImageMaskXObjectRepeat| operation.
39991 addState(InitialState,
39992 [OPS.save, OPS.transform, OPS.paintImageMaskXObject, OPS.restore],
39993 function foundImageMaskGroup(context) {
39994 var MIN_IMAGES_IN_MASKS_BLOCK = 10;
39995 var MAX_IMAGES_IN_MASKS_BLOCK = 100;
39996 var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
39997
39998 var fnArray = context.fnArray, argsArray = context.argsArray;
39999 var curr = context.iCurr;
40000 var iFirstSave = curr - 3;
40001 var iFirstTransform = curr - 2;
40002 var iFirstPIMXO = curr - 1;
40003
40004 // Look for the quartets.
40005 var i = iFirstSave + 4;
40006 var ii = fnArray.length;
40007 while (i + 3 < ii) {
40008 if (fnArray[i] !== OPS.save ||
40009 fnArray[i + 1] !== OPS.transform ||
40010 fnArray[i + 2] !== OPS.paintImageMaskXObject ||
40011 fnArray[i + 3] !== OPS.restore) {
40012 break; // ops don't match
40013 }
40014 i += 4;
40015 }
40016
40017 // At this point, i is the index of the first op past the last valid
40018 // quartet.
40019 var count = (i - iFirstSave) / 4;
40020 count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray,
40021 argsArray);
40022 if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
40023 return i;
40024 }
40025
40026 var q;
40027 var isSameImage = false;
40028 var iTransform, transformArgs;
40029 var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
40030 if (argsArray[iFirstTransform][1] === 0 &&
40031 argsArray[iFirstTransform][2] === 0) {
40032 isSameImage = true;
40033 var firstTransformArg0 = argsArray[iFirstTransform][0];
40034 var firstTransformArg3 = argsArray[iFirstTransform][3];
40035 iTransform = iFirstTransform + 4;
40036 var iPIMXO = iFirstPIMXO + 4;
40037 for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
40038 transformArgs = argsArray[iTransform];
40039 if (argsArray[iPIMXO][0] !== firstPIMXOArg0 ||
40040 transformArgs[0] !== firstTransformArg0 ||
40041 transformArgs[1] !== 0 ||
40042 transformArgs[2] !== 0 ||
40043 transformArgs[3] !== firstTransformArg3) {
40044 if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
40045 isSameImage = false;
40046 } else {
40047 count = q;
40048 }
40049 break; // different image or transform
40050 }
40051 }
40052 }
40053
40054 if (isSameImage) {
40055 count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
40056 var positions = new Float32Array(count * 2);
40057 iTransform = iFirstTransform;
40058 for (q = 0; q < count; q++, iTransform += 4) {
40059 transformArgs = argsArray[iTransform];
40060 positions[(q << 1)] = transformArgs[4];
40061 positions[(q << 1) + 1] = transformArgs[5];
40062 }
40063
40064 // Replace queue items.
40065 fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
40066 argsArray.splice(iFirstSave, count * 4,
40067 [firstPIMXOArg0, firstTransformArg0, firstTransformArg3, positions]);
40068 } else {
40069 count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
40070 var images = [];
40071 for (q = 0; q < count; q++) {
40072 transformArgs = argsArray[iFirstTransform + (q << 2)];
40073 var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
40074 images.push({ data: maskParams.data, width: maskParams.width,
40075 height: maskParams.height,
40076 transform: transformArgs });
40077 }
40078
40079 // Replace queue items.
40080 fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
40081 argsArray.splice(iFirstSave, count * 4, [images]);
40082 }
40083
40084 return iFirstSave + 1;
40085 });
40086
40087 // This replaces (save, transform, paintImageXObject, restore)+ sequences
40088 // with one paintImageXObjectRepeat operation, if the |transform| and
40089 // |paintImageXObjectRepeat| ops are appropriate.
40090 addState(InitialState,
40091 [OPS.save, OPS.transform, OPS.paintImageXObject, OPS.restore],
40092 function (context) {
40093 var MIN_IMAGES_IN_BLOCK = 3;
40094 var MAX_IMAGES_IN_BLOCK = 1000;
40095
40096 var fnArray = context.fnArray, argsArray = context.argsArray;
40097 var curr = context.iCurr;
40098 var iFirstSave = curr - 3;
40099 var iFirstTransform = curr - 2;
40100 var iFirstPIXO = curr - 1;
40101 var iFirstRestore = curr;
40102
40103 if (argsArray[iFirstTransform][1] !== 0 ||
40104 argsArray[iFirstTransform][2] !== 0) {
40105 return iFirstRestore + 1; // transform has the wrong form
40106 }
40107
40108 // Look for the quartets.
40109 var firstPIXOArg0 = argsArray[iFirstPIXO][0];
40110 var firstTransformArg0 = argsArray[iFirstTransform][0];
40111 var firstTransformArg3 = argsArray[iFirstTransform][3];
40112 var i = iFirstSave + 4;
40113 var ii = fnArray.length;
40114 while (i + 3 < ii) {
40115 if (fnArray[i] !== OPS.save ||
40116 fnArray[i + 1] !== OPS.transform ||
40117 fnArray[i + 2] !== OPS.paintImageXObject ||
40118 fnArray[i + 3] !== OPS.restore) {
40119 break; // ops don't match
40120 }
40121 if (argsArray[i + 1][0] !== firstTransformArg0 ||
40122 argsArray[i + 1][1] !== 0 ||
40123 argsArray[i + 1][2] !== 0 ||
40124 argsArray[i + 1][3] !== firstTransformArg3) {
40125 break; // transforms don't match
40126 }
40127 if (argsArray[i + 2][0] !== firstPIXOArg0) {
40128 break; // images don't match
40129 }
40130 i += 4;
40131 }
40132
40133 // At this point, i is the index of the first op past the last valid
40134 // quartet.
40135 var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
40136 if (count < MIN_IMAGES_IN_BLOCK) {
40137 return i;
40138 }
40139
40140 // Extract the (x,y) positions from all of the matching transforms.
40141 var positions = new Float32Array(count * 2);
40142 var iTransform = iFirstTransform;
40143 for (var q = 0; q < count; q++, iTransform += 4) {
40144 var transformArgs = argsArray[iTransform];
40145 positions[(q << 1)] = transformArgs[4];
40146 positions[(q << 1) + 1] = transformArgs[5];
40147 }
40148
40149 // Replace queue items.
40150 var args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3,
40151 positions];
40152 fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
40153 argsArray.splice(iFirstSave, count * 4, args);
40154
40155 return iFirstSave + 1;
40156 });
40157
40158 // This replaces (beginText, setFont, setTextMatrix, showText, endText)+
40159 // sequences with (beginText, setFont, (setTextMatrix, showText)+, endText)+
40160 // sequences, if the font for each one is the same.
40161 addState(InitialState,
40162 [OPS.beginText, OPS.setFont, OPS.setTextMatrix, OPS.showText, OPS.endText],
40163 function (context) {
40164 var MIN_CHARS_IN_BLOCK = 3;
40165 var MAX_CHARS_IN_BLOCK = 1000;
40166
40167 var fnArray = context.fnArray, argsArray = context.argsArray;
40168 var curr = context.iCurr;
40169 var iFirstBeginText = curr - 4;
40170 var iFirstSetFont = curr - 3;
40171 var iFirstSetTextMatrix = curr - 2;
40172 var iFirstShowText = curr - 1;
40173 var iFirstEndText = curr;
40174
40175 // Look for the quintets.
40176 var firstSetFontArg0 = argsArray[iFirstSetFont][0];
40177 var firstSetFontArg1 = argsArray[iFirstSetFont][1];
40178 var i = iFirstBeginText + 5;
40179 var ii = fnArray.length;
40180 while (i + 4 < ii) {
40181 if (fnArray[i] !== OPS.beginText ||
40182 fnArray[i + 1] !== OPS.setFont ||
40183 fnArray[i + 2] !== OPS.setTextMatrix ||
40184 fnArray[i + 3] !== OPS.showText ||
40185 fnArray[i + 4] !== OPS.endText) {
40186 break; // ops don't match
40187 }
40188 if (argsArray[i + 1][0] !== firstSetFontArg0 ||
40189 argsArray[i + 1][1] !== firstSetFontArg1) {
40190 break; // fonts don't match
40191 }
40192 i += 5;
40193 }
40194
40195 // At this point, i is the index of the first op past the last valid
40196 // quintet.
40197 var count = Math.min(((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
40198 if (count < MIN_CHARS_IN_BLOCK) {
40199 return i;
40200 }
40201
40202 // If the preceding quintet is (<something>, setFont, setTextMatrix,
40203 // showText, endText), include that as well. (E.g. <something> might be
40204 // |dependency|.)
40205 var iFirst = iFirstBeginText;
40206 if (iFirstBeginText >= 4 &&
40207 fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] &&
40208 fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] &&
40209 fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] &&
40210 fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] &&
40211 argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 &&
40212 argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
40213 count++;
40214 iFirst -= 5;
40215 }
40216
40217 // Remove (endText, beginText, setFont) trios.
40218 var iEndText = iFirst + 4;
40219 for (var q = 1; q < count; q++) {
40220 fnArray.splice(iEndText, 3);
40221 argsArray.splice(iEndText, 3);
40222 iEndText += 2;
40223 }
40224
40225 return iEndText + 1;
40226 });
40227
40228 function QueueOptimizer() {}
40229
40230 QueueOptimizer.prototype = {
40231 optimize: function QueueOptimizer_optimize(queue) {
40232 var fnArray = queue.fnArray, argsArray = queue.argsArray;
40233 var context = {
40234 iCurr: 0,
40235 fnArray: fnArray,
40236 argsArray: argsArray
40237 };
40238 var state;
40239 var i = 0, ii = fnArray.length;
40240 while (i < ii) {
40241 state = (state || InitialState)[fnArray[i]];
40242 if (typeof state === 'function') { // we found some handler
40243 context.iCurr = i;
40244 // state() returns the index of the first non-matching op (if we
40245 // didn't match) or the first op past the modified ops (if we did
40246 // match and replace).
40247 i = state(context);
40248 state = undefined; // reset the state machine
40249 ii = context.fnArray.length;
40250 } else {
40251 i++;
40252 }
40253 }
40254 }
40255 };
40256 return QueueOptimizer;
40257})();
40258
40259exports.OperatorList = OperatorList;
40260exports.PartialEvaluator = PartialEvaluator;
40261}));
40262
40263
40264(function (root, factory) {
40265 {
40266 factory((root.pdfjsCoreAnnotation = {}), root.pdfjsSharedUtil,
40267 root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace,
40268 root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
40269 }
40270}(this, function (exports, sharedUtil, corePrimitives, coreStream,
40271 coreColorSpace, coreObj, coreEvaluator) {
40272
40273var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
40274var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
40275var AnnotationFlag = sharedUtil.AnnotationFlag;
40276var AnnotationType = sharedUtil.AnnotationType;
40277var OPS = sharedUtil.OPS;
40278var Util = sharedUtil.Util;
40279var isBool = sharedUtil.isBool;
40280var isString = sharedUtil.isString;
40281var isArray = sharedUtil.isArray;
40282var isInt = sharedUtil.isInt;
40283var isValidUrl = sharedUtil.isValidUrl;
40284var stringToBytes = sharedUtil.stringToBytes;
40285var stringToPDFString = sharedUtil.stringToPDFString;
40286var stringToUTF8String = sharedUtil.stringToUTF8String;
40287var warn = sharedUtil.warn;
40288var Dict = corePrimitives.Dict;
40289var isDict = corePrimitives.isDict;
40290var isName = corePrimitives.isName;
40291var isRef = corePrimitives.isRef;
40292var Stream = coreStream.Stream;
40293var ColorSpace = coreColorSpace.ColorSpace;
40294var ObjectLoader = coreObj.ObjectLoader;
40295var FileSpec = coreObj.FileSpec;
40296var OperatorList = coreEvaluator.OperatorList;
40297
40298/**
40299 * @class
40300 * @alias AnnotationFactory
40301 */
40302function AnnotationFactory() {}
40303AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ {
40304 /**
40305 * @param {XRef} xref
40306 * @param {Object} ref
40307 * @param {string} uniquePrefix
40308 * @param {Object} idCounters
40309 * @returns {Annotation}
40310 */
40311 create: function AnnotationFactory_create(xref, ref,
40312 uniquePrefix, idCounters) {
40313 var dict = xref.fetchIfRef(ref);
40314 if (!isDict(dict)) {
40315 return;
40316 }
40317 var id = isRef(ref) ? ref.toString() :
40318 'annot_' + (uniquePrefix || '') + (++idCounters.obj);
40319
40320 // Determine the annotation's subtype.
40321 var subtype = dict.get('Subtype');
40322 subtype = isName(subtype) ? subtype.name : null;
40323
40324 // Return the right annotation object based on the subtype and field type.
40325 var parameters = {
40326 xref: xref,
40327 dict: dict,
40328 ref: isRef(ref) ? ref : null,
40329 subtype: subtype,
40330 id: id,
40331 };
40332
40333 switch (subtype) {
40334 case 'Link':
40335 return new LinkAnnotation(parameters);
40336
40337 case 'Text':
40338 return new TextAnnotation(parameters);
40339
40340 case 'Widget':
40341 var fieldType = Util.getInheritableProperty(dict, 'FT');
40342 fieldType = isName(fieldType) ? fieldType.name : null;
40343
40344 switch (fieldType) {
40345 case 'Tx':
40346 return new TextWidgetAnnotation(parameters);
40347 }
40348 warn('Unimplemented widget field type "' + fieldType + '", ' +
40349 'falling back to base field type.');
40350 return new WidgetAnnotation(parameters);
40351
40352 case 'Popup':
40353 return new PopupAnnotation(parameters);
40354
40355 case 'Highlight':
40356 return new HighlightAnnotation(parameters);
40357
40358 case 'Underline':
40359 return new UnderlineAnnotation(parameters);
40360
40361 case 'Squiggly':
40362 return new SquigglyAnnotation(parameters);
40363
40364 case 'StrikeOut':
40365 return new StrikeOutAnnotation(parameters);
40366
40367 case 'FileAttachment':
40368 return new FileAttachmentAnnotation(parameters);
40369
40370 default:
40371 if (!subtype) {
40372 warn('Annotation is missing the required /Subtype.');
40373 } else {
40374 warn('Unimplemented annotation type "' + subtype + '", ' +
40375 'falling back to base annotation.');
40376 }
40377 return new Annotation(parameters);
40378 }
40379 }
40380};
40381
40382var Annotation = (function AnnotationClosure() {
40383 // 12.5.5: Algorithm: Appearance streams
40384 function getTransformMatrix(rect, bbox, matrix) {
40385 var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
40386 var minX = bounds[0];
40387 var minY = bounds[1];
40388 var maxX = bounds[2];
40389 var maxY = bounds[3];
40390
40391 if (minX === maxX || minY === maxY) {
40392 // From real-life file, bbox was [0, 0, 0, 0]. In this case,
40393 // just apply the transform for rect
40394 return [1, 0, 0, 1, rect[0], rect[1]];
40395 }
40396
40397 var xRatio = (rect[2] - rect[0]) / (maxX - minX);
40398 var yRatio = (rect[3] - rect[1]) / (maxY - minY);
40399 return [
40400 xRatio,
40401 0,
40402 0,
40403 yRatio,
40404 rect[0] - minX * xRatio,
40405 rect[1] - minY * yRatio
40406 ];
40407 }
40408
40409 function getDefaultAppearance(dict) {
40410 var appearanceState = dict.get('AP');
40411 if (!isDict(appearanceState)) {
40412 return;
40413 }
40414
40415 var appearance;
40416 var appearances = appearanceState.get('N');
40417 if (isDict(appearances)) {
40418 var as = dict.get('AS');
40419 if (as && appearances.has(as.name)) {
40420 appearance = appearances.get(as.name);
40421 }
40422 } else {
40423 appearance = appearances;
40424 }
40425 return appearance;
40426 }
40427
40428 function Annotation(params) {
40429 var dict = params.dict;
40430
40431 this.setFlags(dict.get('F'));
40432 this.setRectangle(dict.getArray('Rect'));
40433 this.setColor(dict.getArray('C'));
40434 this.setBorderStyle(dict);
40435 this.appearance = getDefaultAppearance(dict);
40436
40437 // Expose public properties using a data object.
40438 this.data = {};
40439 this.data.id = params.id;
40440 this.data.subtype = params.subtype;
40441 this.data.annotationFlags = this.flags;
40442 this.data.rect = this.rectangle;
40443 this.data.color = this.color;
40444 this.data.borderStyle = this.borderStyle;
40445 this.data.hasAppearance = !!this.appearance;
40446 }
40447
40448 Annotation.prototype = {
40449 /**
40450 * @private
40451 */
40452 _hasFlag: function Annotation_hasFlag(flags, flag) {
40453 return !!(flags & flag);
40454 },
40455
40456 /**
40457 * @private
40458 */
40459 _isViewable: function Annotation_isViewable(flags) {
40460 return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) &&
40461 !this._hasFlag(flags, AnnotationFlag.HIDDEN) &&
40462 !this._hasFlag(flags, AnnotationFlag.NOVIEW);
40463 },
40464
40465 /**
40466 * @private
40467 */
40468 _isPrintable: function AnnotationFlag_isPrintable(flags) {
40469 return this._hasFlag(flags, AnnotationFlag.PRINT) &&
40470 !this._hasFlag(flags, AnnotationFlag.INVISIBLE) &&
40471 !this._hasFlag(flags, AnnotationFlag.HIDDEN);
40472 },
40473
40474 /**
40475 * @return {boolean}
40476 */
40477 get viewable() {
40478 if (this.flags === 0) {
40479 return true;
40480 }
40481 return this._isViewable(this.flags);
40482 },
40483
40484 /**
40485 * @return {boolean}
40486 */
40487 get printable() {
40488 if (this.flags === 0) {
40489 return false;
40490 }
40491 return this._isPrintable(this.flags);
40492 },
40493
40494 /**
40495 * Set the flags.
40496 *
40497 * @public
40498 * @memberof Annotation
40499 * @param {number} flags - Unsigned 32-bit integer specifying annotation
40500 * characteristics
40501 * @see {@link shared/util.js}
40502 */
40503 setFlags: function Annotation_setFlags(flags) {
40504 this.flags = (isInt(flags) && flags > 0) ? flags : 0;
40505 },
40506
40507 /**
40508 * Check if a provided flag is set.
40509 *
40510 * @public
40511 * @memberof Annotation
40512 * @param {number} flag - Hexadecimal representation for an annotation
40513 * characteristic
40514 * @return {boolean}
40515 * @see {@link shared/util.js}
40516 */
40517 hasFlag: function Annotation_hasFlag(flag) {
40518 return this._hasFlag(this.flags, flag);
40519 },
40520
40521 /**
40522 * Set the rectangle.
40523 *
40524 * @public
40525 * @memberof Annotation
40526 * @param {Array} rectangle - The rectangle array with exactly four entries
40527 */
40528 setRectangle: function Annotation_setRectangle(rectangle) {
40529 if (isArray(rectangle) && rectangle.length === 4) {
40530 this.rectangle = Util.normalizeRect(rectangle);
40531 } else {
40532 this.rectangle = [0, 0, 0, 0];
40533 }
40534 },
40535
40536 /**
40537 * Set the color and take care of color space conversion.
40538 *
40539 * @public
40540 * @memberof Annotation
40541 * @param {Array} color - The color array containing either 0
40542 * (transparent), 1 (grayscale), 3 (RGB) or
40543 * 4 (CMYK) elements
40544 */
40545 setColor: function Annotation_setColor(color) {
40546 var rgbColor = new Uint8Array(3); // Black in RGB color space (default)
40547 if (!isArray(color)) {
40548 this.color = rgbColor;
40549 return;
40550 }
40551
40552 switch (color.length) {
40553 case 0: // Transparent, which we indicate with a null value
40554 this.color = null;
40555 break;
40556
40557 case 1: // Convert grayscale to RGB
40558 ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
40559 this.color = rgbColor;
40560 break;
40561
40562 case 3: // Convert RGB percentages to RGB
40563 ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
40564 this.color = rgbColor;
40565 break;
40566
40567 case 4: // Convert CMYK to RGB
40568 ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
40569 this.color = rgbColor;
40570 break;
40571
40572 default:
40573 this.color = rgbColor;
40574 break;
40575 }
40576 },
40577
40578 /**
40579 * Set the border style (as AnnotationBorderStyle object).
40580 *
40581 * @public
40582 * @memberof Annotation
40583 * @param {Dict} borderStyle - The border style dictionary
40584 */
40585 setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
40586 this.borderStyle = new AnnotationBorderStyle();
40587 if (!isDict(borderStyle)) {
40588 return;
40589 }
40590 if (borderStyle.has('BS')) {
40591 var dict = borderStyle.get('BS');
40592 var dictType = dict.get('Type');
40593
40594 if (!dictType || isName(dictType, 'Border')) {
40595 this.borderStyle.setWidth(dict.get('W'));
40596 this.borderStyle.setStyle(dict.get('S'));
40597 this.borderStyle.setDashArray(dict.getArray('D'));
40598 }
40599 } else if (borderStyle.has('Border')) {
40600 var array = borderStyle.getArray('Border');
40601 if (isArray(array) && array.length >= 3) {
40602 this.borderStyle.setHorizontalCornerRadius(array[0]);
40603 this.borderStyle.setVerticalCornerRadius(array[1]);
40604 this.borderStyle.setWidth(array[2]);
40605
40606 if (array.length === 4) { // Dash array available
40607 this.borderStyle.setDashArray(array[3]);
40608 }
40609 }
40610 } else {
40611 // There are no border entries in the dictionary. According to the
40612 // specification, we should draw a solid border of width 1 in that
40613 // case, but Adobe Reader did not implement that part of the
40614 // specification and instead draws no border at all, so we do the same.
40615 // See also https://github.com/mozilla/pdf.js/issues/6179.
40616 this.borderStyle.setWidth(0);
40617 }
40618 },
40619
40620 /**
40621 * Prepare the annotation for working with a popup in the display layer.
40622 *
40623 * @private
40624 * @memberof Annotation
40625 * @param {Dict} dict - The annotation's data dictionary
40626 */
40627 _preparePopup: function Annotation_preparePopup(dict) {
40628 if (!dict.has('C')) {
40629 // Fall back to the default background color.
40630 this.data.color = null;
40631 }
40632
40633 this.data.hasPopup = dict.has('Popup');
40634 this.data.title = stringToPDFString(dict.get('T') || '');
40635 this.data.contents = stringToPDFString(dict.get('Contents') || '');
40636 },
40637
40638 loadResources: function Annotation_loadResources(keys) {
40639 return new Promise(function (resolve, reject) {
40640 this.appearance.dict.getAsync('Resources').then(function (resources) {
40641 if (!resources) {
40642 resolve();
40643 return;
40644 }
40645 var objectLoader = new ObjectLoader(resources.map,
40646 keys,
40647 resources.xref);
40648 objectLoader.load().then(function() {
40649 resolve(resources);
40650 }, reject);
40651 }, reject);
40652 }.bind(this));
40653 },
40654
40655 getOperatorList: function Annotation_getOperatorList(evaluator, task,
40656 renderForms) {
40657 if (!this.appearance) {
40658 return Promise.resolve(new OperatorList());
40659 }
40660
40661 var data = this.data;
40662 var appearanceDict = this.appearance.dict;
40663 var resourcesPromise = this.loadResources([
40664 'ExtGState',
40665 'ColorSpace',
40666 'Pattern',
40667 'Shading',
40668 'XObject',
40669 'Font'
40670 // ProcSet
40671 // Properties
40672 ]);
40673 var bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
40674 var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0 ,0];
40675 var transform = getTransformMatrix(data.rect, bbox, matrix);
40676 var self = this;
40677
40678 return resourcesPromise.then(function(resources) {
40679 var opList = new OperatorList();
40680 opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
40681 return evaluator.getOperatorList(self.appearance, task,
40682 resources, opList).
40683 then(function () {
40684 opList.addOp(OPS.endAnnotation, []);
40685 self.appearance.reset();
40686 return opList;
40687 });
40688 });
40689 }
40690 };
40691
40692 Annotation.appendToOperatorList = function Annotation_appendToOperatorList(
40693 annotations, opList, partialEvaluator, task, intent, renderForms) {
40694 var annotationPromises = [];
40695 for (var i = 0, n = annotations.length; i < n; ++i) {
40696 if ((intent === 'display' && annotations[i].viewable) ||
40697 (intent === 'print' && annotations[i].printable)) {
40698 annotationPromises.push(
40699 annotations[i].getOperatorList(partialEvaluator, task, renderForms));
40700 }
40701 }
40702 return Promise.all(annotationPromises).then(function(operatorLists) {
40703 opList.addOp(OPS.beginAnnotations, []);
40704 for (var i = 0, n = operatorLists.length; i < n; ++i) {
40705 opList.addOpList(operatorLists[i]);
40706 }
40707 opList.addOp(OPS.endAnnotations, []);
40708 });
40709 };
40710
40711 return Annotation;
40712})();
40713
40714/**
40715 * Contains all data regarding an annotation's border style.
40716 *
40717 * @class
40718 */
40719var AnnotationBorderStyle = (function AnnotationBorderStyleClosure() {
40720 /**
40721 * @constructor
40722 * @private
40723 */
40724 function AnnotationBorderStyle() {
40725 this.width = 1;
40726 this.style = AnnotationBorderStyleType.SOLID;
40727 this.dashArray = [3];
40728 this.horizontalCornerRadius = 0;
40729 this.verticalCornerRadius = 0;
40730 }
40731
40732 AnnotationBorderStyle.prototype = {
40733 /**
40734 * Set the width.
40735 *
40736 * @public
40737 * @memberof AnnotationBorderStyle
40738 * @param {integer} width - The width
40739 */
40740 setWidth: function AnnotationBorderStyle_setWidth(width) {
40741 if (width === (width | 0)) {
40742 this.width = width;
40743 }
40744 },
40745
40746 /**
40747 * Set the style.
40748 *
40749 * @public
40750 * @memberof AnnotationBorderStyle
40751 * @param {Object} style - The style object
40752 * @see {@link shared/util.js}
40753 */
40754 setStyle: function AnnotationBorderStyle_setStyle(style) {
40755 if (!style) {
40756 return;
40757 }
40758 switch (style.name) {
40759 case 'S':
40760 this.style = AnnotationBorderStyleType.SOLID;
40761 break;
40762
40763 case 'D':
40764 this.style = AnnotationBorderStyleType.DASHED;
40765 break;
40766
40767 case 'B':
40768 this.style = AnnotationBorderStyleType.BEVELED;
40769 break;
40770
40771 case 'I':
40772 this.style = AnnotationBorderStyleType.INSET;
40773 break;
40774
40775 case 'U':
40776 this.style = AnnotationBorderStyleType.UNDERLINE;
40777 break;
40778
40779 default:
40780 break;
40781 }
40782 },
40783
40784 /**
40785 * Set the dash array.
40786 *
40787 * @public
40788 * @memberof AnnotationBorderStyle
40789 * @param {Array} dashArray - The dash array with at least one element
40790 */
40791 setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
40792 // We validate the dash array, but we do not use it because CSS does not
40793 // allow us to change spacing of dashes. For more information, visit
40794 // http://www.w3.org/TR/css3-background/#the-border-style.
40795 if (isArray(dashArray) && dashArray.length > 0) {
40796 // According to the PDF specification: the elements in a dashArray
40797 // shall be numbers that are nonnegative and not all equal to zero.
40798 var isValid = true;
40799 var allZeros = true;
40800 for (var i = 0, len = dashArray.length; i < len; i++) {
40801 var element = dashArray[i];
40802 var validNumber = (+element >= 0);
40803 if (!validNumber) {
40804 isValid = false;
40805 break;
40806 } else if (element > 0) {
40807 allZeros = false;
40808 }
40809 }
40810 if (isValid && !allZeros) {
40811 this.dashArray = dashArray;
40812 } else {
40813 this.width = 0; // Adobe behavior when the array is invalid.
40814 }
40815 } else if (dashArray) {
40816 this.width = 0; // Adobe behavior when the array is invalid.
40817 }
40818 },
40819
40820 /**
40821 * Set the horizontal corner radius (from a Border dictionary).
40822 *
40823 * @public
40824 * @memberof AnnotationBorderStyle
40825 * @param {integer} radius - The horizontal corner radius
40826 */
40827 setHorizontalCornerRadius:
40828 function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
40829 if (radius === (radius | 0)) {
40830 this.horizontalCornerRadius = radius;
40831 }
40832 },
40833
40834 /**
40835 * Set the vertical corner radius (from a Border dictionary).
40836 *
40837 * @public
40838 * @memberof AnnotationBorderStyle
40839 * @param {integer} radius - The vertical corner radius
40840 */
40841 setVerticalCornerRadius:
40842 function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
40843 if (radius === (radius | 0)) {
40844 this.verticalCornerRadius = radius;
40845 }
40846 }
40847 };
40848
40849 return AnnotationBorderStyle;
40850})();
40851
40852var WidgetAnnotation = (function WidgetAnnotationClosure() {
40853 function WidgetAnnotation(params) {
40854 Annotation.call(this, params);
40855
40856 var dict = params.dict;
40857 var data = this.data;
40858
40859 data.annotationType = AnnotationType.WIDGET;
40860 data.fieldValue = stringToPDFString(
40861 Util.getInheritableProperty(dict, 'V') || '');
40862 data.alternativeText = stringToPDFString(dict.get('TU') || '');
40863 data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
40864 var fieldType = Util.getInheritableProperty(dict, 'FT');
40865 data.fieldType = isName(fieldType) ? fieldType.name : null;
40866 this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
40867
40868 data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
40869 if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
40870 data.fieldFlags = 0;
40871 }
40872
40873 // Hide signatures because we cannot validate them.
40874 if (data.fieldType === 'Sig') {
40875 this.setFlags(AnnotationFlag.HIDDEN);
40876 }
40877
40878 // Building the full field name by collecting the field and
40879 // its ancestors 'T' data and joining them using '.'.
40880 var fieldName = [];
40881 var namedItem = dict;
40882 var ref = params.ref;
40883 while (namedItem) {
40884 var parent = namedItem.get('Parent');
40885 var parentRef = namedItem.getRaw('Parent');
40886 var name = namedItem.get('T');
40887 if (name) {
40888 fieldName.unshift(stringToPDFString(name));
40889 } else if (parent && ref) {
40890 // The field name is absent, that means more than one field
40891 // with the same name may exist. Replacing the empty name
40892 // with the '`' plus index in the parent's 'Kids' array.
40893 // This is not in the PDF spec but necessary to id the
40894 // the input controls.
40895 var kids = parent.get('Kids');
40896 var j, jj;
40897 for (j = 0, jj = kids.length; j < jj; j++) {
40898 var kidRef = kids[j];
40899 if (kidRef.num === ref.num && kidRef.gen === ref.gen) {
40900 break;
40901 }
40902 }
40903 fieldName.unshift('`' + j);
40904 }
40905 namedItem = parent;
40906 ref = parentRef;
40907 }
40908 data.fullName = fieldName.join('.');
40909 }
40910
40911 Util.inherit(WidgetAnnotation, Annotation, {
40912 /**
40913 * Check if a provided field flag is set.
40914 *
40915 * @public
40916 * @memberof WidgetAnnotation
40917 * @param {number} flag - Hexadecimal representation for an annotation
40918 * field characteristic
40919 * @return {boolean}
40920 * @see {@link shared/util.js}
40921 */
40922 hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
40923 return !!(this.data.fieldFlags & flag);
40924 },
40925 });
40926
40927 return WidgetAnnotation;
40928})();
40929
40930var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
40931 function TextWidgetAnnotation(params) {
40932 WidgetAnnotation.call(this, params);
40933
40934 // Determine the alignment of text in the field.
40935 var alignment = Util.getInheritableProperty(params.dict, 'Q');
40936 if (!isInt(alignment) || alignment < 0 || alignment > 2) {
40937 alignment = null;
40938 }
40939 this.data.textAlignment = alignment;
40940
40941 // Determine the maximum length of text in the field.
40942 var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
40943 if (!isInt(maximumLength) || maximumLength < 0) {
40944 maximumLength = null;
40945 }
40946 this.data.maxLen = maximumLength;
40947
40948 // Process field flags for the display layer.
40949 this.data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
40950 this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
40951 this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) &&
40952 !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) &&
40953 !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) &&
40954 !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) &&
40955 this.data.maxLen !== null;
40956 }
40957
40958 Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
40959 getOperatorList:
40960 function TextWidgetAnnotation_getOperatorList(evaluator, task,
40961 renderForms) {
40962 var operatorList = new OperatorList();
40963
40964 // Do not render form elements on the canvas when interactive forms are
40965 // enabled. The display layer is responsible for rendering them instead.
40966 if (renderForms) {
40967 return Promise.resolve(operatorList);
40968 }
40969
40970 if (this.appearance) {
40971 return Annotation.prototype.getOperatorList.call(this, evaluator, task,
40972 renderForms);
40973 }
40974
40975 // Even if there is an appearance stream, ignore it. This is the
40976 // behaviour used by Adobe Reader.
40977 if (!this.data.defaultAppearance) {
40978 return Promise.resolve(operatorList);
40979 }
40980
40981 var stream = new Stream(stringToBytes(this.data.defaultAppearance));
40982 return evaluator.getOperatorList(stream, task, this.fieldResources,
40983 operatorList).
40984 then(function () {
40985 return operatorList;
40986 });
40987 }
40988 });
40989
40990 return TextWidgetAnnotation;
40991})();
40992
40993var TextAnnotation = (function TextAnnotationClosure() {
40994 var DEFAULT_ICON_SIZE = 22; // px
40995
40996 function TextAnnotation(parameters) {
40997 Annotation.call(this, parameters);
40998
40999 this.data.annotationType = AnnotationType.TEXT;
41000
41001 if (this.data.hasAppearance) {
41002 this.data.name = 'NoIcon';
41003 } else {
41004 this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
41005 this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
41006 this.data.name = parameters.dict.has('Name') ?
41007 parameters.dict.get('Name').name : 'Note';
41008 }
41009 this._preparePopup(parameters.dict);
41010 }
41011
41012 Util.inherit(TextAnnotation, Annotation, {});
41013
41014 return TextAnnotation;
41015})();
41016
41017var LinkAnnotation = (function LinkAnnotationClosure() {
41018 function LinkAnnotation(params) {
41019 Annotation.call(this, params);
41020
41021 var dict = params.dict;
41022 var data = this.data;
41023 data.annotationType = AnnotationType.LINK;
41024
41025 var action = dict.get('A'), url, dest;
41026 if (action && isDict(action)) {
41027 var linkType = action.get('S').name;
41028 switch (linkType) {
41029 case 'URI':
41030 url = action.get('URI');
41031 if (isName(url)) {
41032 // Some bad PDFs do not put parentheses around relative URLs.
41033 url = '/' + url.name;
41034 } else if (url) {
41035 url = addDefaultProtocolToUrl(url);
41036 }
41037 // TODO: pdf spec mentions urls can be relative to a Base
41038 // entry in the dictionary.
41039 break;
41040
41041 case 'GoTo':
41042 dest = action.get('D');
41043 break;
41044
41045 case 'GoToR':
41046 var urlDict = action.get('F');
41047 if (isDict(urlDict)) {
41048 // We assume that we found a FileSpec dictionary
41049 // and fetch the URL without checking any further.
41050 url = urlDict.get('F') || null;
41051 } else if (isString(urlDict)) {
41052 url = urlDict;
41053 }
41054
41055 // NOTE: the destination is relative to the *remote* document.
41056 var remoteDest = action.get('D');
41057 if (remoteDest) {
41058 if (isName(remoteDest)) {
41059 remoteDest = remoteDest.name;
41060 }
41061 if (isString(url)) {
41062 var baseUrl = url.split('#')[0];
41063 if (isString(remoteDest)) {
41064 // In practice, a named destination may contain only a number.
41065 // If that happens, use the '#nameddest=' form to avoid the link
41066 // redirecting to a page, instead of the correct destination.
41067 url = baseUrl + '#' +
41068 (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
41069 } else if (isArray(remoteDest)) {
41070 url = baseUrl + '#' + JSON.stringify(remoteDest);
41071 }
41072 }
41073 }
41074 // The 'NewWindow' property, equal to `LinkTarget.BLANK`.
41075 var newWindow = action.get('NewWindow');
41076 if (isBool(newWindow)) {
41077 data.newWindow = newWindow;
41078 }
41079 break;
41080
41081 case 'Named':
41082 data.action = action.get('N').name;
41083 break;
41084
41085 default:
41086 warn('unrecognized link type: ' + linkType);
41087 }
41088 } else if (dict.has('Dest')) { // Simple destination link.
41089 dest = dict.get('Dest');
41090 }
41091
41092 if (url) {
41093 if (isValidUrl(url, /* allowRelative = */ false)) {
41094 data.url = tryConvertUrlEncoding(url);
41095 }
41096 }
41097 if (dest) {
41098 data.dest = isName(dest) ? dest.name : dest;
41099 }
41100 }
41101
41102 // Lets URLs beginning with 'www.' default to using the 'http://' protocol.
41103 function addDefaultProtocolToUrl(url) {
41104 if (isString(url) && url.indexOf('www.') === 0) {
41105 return ('http://' + url);
41106 }
41107 return url;
41108 }
41109
41110 function tryConvertUrlEncoding(url) {
41111 // According to ISO 32000-1:2008, section 12.6.4.7, URIs should be encoded
41112 // in 7-bit ASCII. Some bad PDFs use UTF-8 encoding, see Bugzilla 1122280.
41113 try {
41114 return stringToUTF8String(url);
41115 } catch (e) {
41116 return url;
41117 }
41118 }
41119
41120 Util.inherit(LinkAnnotation, Annotation, {});
41121
41122 return LinkAnnotation;
41123})();
41124
41125var PopupAnnotation = (function PopupAnnotationClosure() {
41126 function PopupAnnotation(parameters) {
41127 Annotation.call(this, parameters);
41128
41129 this.data.annotationType = AnnotationType.POPUP;
41130
41131 var dict = parameters.dict;
41132 var parentItem = dict.get('Parent');
41133 if (!parentItem) {
41134 warn('Popup annotation has a missing or invalid parent annotation.');
41135 return;
41136 }
41137
41138 this.data.parentId = dict.getRaw('Parent').toString();
41139 this.data.title = stringToPDFString(parentItem.get('T') || '');
41140 this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
41141
41142 if (!parentItem.has('C')) {
41143 // Fall back to the default background color.
41144 this.data.color = null;
41145 } else {
41146 this.setColor(parentItem.getArray('C'));
41147 this.data.color = this.color;
41148 }
41149
41150 // If the Popup annotation is not viewable, but the parent annotation is,
41151 // that is most likely a bug. Fallback to inherit the flags from the parent
41152 // annotation (this is consistent with the behaviour in Adobe Reader).
41153 if (!this.viewable) {
41154 var parentFlags = parentItem.get('F');
41155 if (this._isViewable(parentFlags)) {
41156 this.setFlags(parentFlags);
41157 }
41158 }
41159 }
41160
41161 Util.inherit(PopupAnnotation, Annotation, {});
41162
41163 return PopupAnnotation;
41164})();
41165
41166var HighlightAnnotation = (function HighlightAnnotationClosure() {
41167 function HighlightAnnotation(parameters) {
41168 Annotation.call(this, parameters);
41169
41170 this.data.annotationType = AnnotationType.HIGHLIGHT;
41171 this._preparePopup(parameters.dict);
41172
41173 // PDF viewers completely ignore any border styles.
41174 this.data.borderStyle.setWidth(0);
41175 }
41176
41177 Util.inherit(HighlightAnnotation, Annotation, {});
41178
41179 return HighlightAnnotation;
41180})();
41181
41182var UnderlineAnnotation = (function UnderlineAnnotationClosure() {
41183 function UnderlineAnnotation(parameters) {
41184 Annotation.call(this, parameters);
41185
41186 this.data.annotationType = AnnotationType.UNDERLINE;
41187 this._preparePopup(parameters.dict);
41188
41189 // PDF viewers completely ignore any border styles.
41190 this.data.borderStyle.setWidth(0);
41191 }
41192
41193 Util.inherit(UnderlineAnnotation, Annotation, {});
41194
41195 return UnderlineAnnotation;
41196})();
41197
41198var SquigglyAnnotation = (function SquigglyAnnotationClosure() {
41199 function SquigglyAnnotation(parameters) {
41200 Annotation.call(this, parameters);
41201
41202 this.data.annotationType = AnnotationType.SQUIGGLY;
41203 this._preparePopup(parameters.dict);
41204
41205 // PDF viewers completely ignore any border styles.
41206 this.data.borderStyle.setWidth(0);
41207 }
41208
41209 Util.inherit(SquigglyAnnotation, Annotation, {});
41210
41211 return SquigglyAnnotation;
41212})();
41213
41214var StrikeOutAnnotation = (function StrikeOutAnnotationClosure() {
41215 function StrikeOutAnnotation(parameters) {
41216 Annotation.call(this, parameters);
41217
41218 this.data.annotationType = AnnotationType.STRIKEOUT;
41219 this._preparePopup(parameters.dict);
41220
41221 // PDF viewers completely ignore any border styles.
41222 this.data.borderStyle.setWidth(0);
41223 }
41224
41225 Util.inherit(StrikeOutAnnotation, Annotation, {});
41226
41227 return StrikeOutAnnotation;
41228})();
41229
41230var FileAttachmentAnnotation = (function FileAttachmentAnnotationClosure() {
41231 function FileAttachmentAnnotation(parameters) {
41232 Annotation.call(this, parameters);
41233
41234 var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
41235
41236 this.data.annotationType = AnnotationType.FILEATTACHMENT;
41237 this.data.file = file.serializable;
41238 this._preparePopup(parameters.dict);
41239 }
41240
41241 Util.inherit(FileAttachmentAnnotation, Annotation, {});
41242
41243 return FileAttachmentAnnotation;
41244})();
41245
41246exports.Annotation = Annotation;
41247exports.AnnotationBorderStyle = AnnotationBorderStyle;
41248exports.AnnotationFactory = AnnotationFactory;
41249}));
41250
41251
41252(function (root, factory) {
41253 {
41254 factory((root.pdfjsCoreDocument = {}), root.pdfjsSharedUtil,
41255 root.pdfjsCorePrimitives, root.pdfjsCoreStream,
41256 root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto,
41257 root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
41258 }
41259}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj,
41260 coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
41261
41262var MissingDataException = sharedUtil.MissingDataException;
41263var Util = sharedUtil.Util;
41264var assert = sharedUtil.assert;
41265var error = sharedUtil.error;
41266var info = sharedUtil.info;
41267var isArray = sharedUtil.isArray;
41268var isArrayBuffer = sharedUtil.isArrayBuffer;
41269var isString = sharedUtil.isString;
41270var shadow = sharedUtil.shadow;
41271var stringToBytes = sharedUtil.stringToBytes;
41272var stringToPDFString = sharedUtil.stringToPDFString;
41273var warn = sharedUtil.warn;
41274var isSpace = sharedUtil.isSpace;
41275var Dict = corePrimitives.Dict;
41276var isDict = corePrimitives.isDict;
41277var isName = corePrimitives.isName;
41278var isStream = corePrimitives.isStream;
41279var NullStream = coreStream.NullStream;
41280var Stream = coreStream.Stream;
41281var StreamsSequenceStream = coreStream.StreamsSequenceStream;
41282var Catalog = coreObj.Catalog;
41283var ObjectLoader = coreObj.ObjectLoader;
41284var XRef = coreObj.XRef;
41285var Linearization = coreParser.Linearization;
41286var calculateMD5 = coreCrypto.calculateMD5;
41287var OperatorList = coreEvaluator.OperatorList;
41288var PartialEvaluator = coreEvaluator.PartialEvaluator;
41289var Annotation = coreAnnotation.Annotation;
41290var AnnotationFactory = coreAnnotation.AnnotationFactory;
41291
41292var Page = (function PageClosure() {
41293
41294 var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
41295
41296 function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
41297 this.pdfManager = pdfManager;
41298 this.pageIndex = pageIndex;
41299 this.pageDict = pageDict;
41300 this.xref = xref;
41301 this.ref = ref;
41302 this.fontCache = fontCache;
41303 this.uniquePrefix = 'p' + this.pageIndex + '_';
41304 this.idCounters = {
41305 obj: 0
41306 };
41307 this.evaluatorOptions = pdfManager.evaluatorOptions;
41308 this.resourcesPromise = null;
41309 }
41310
41311 Page.prototype = {
41312 getPageProp: function Page_getPageProp(key) {
41313 return this.pageDict.get(key);
41314 },
41315
41316 getInheritedPageProp: function Page_getInheritedPageProp(key) {
41317 var dict = this.pageDict, valueArray = null, loopCount = 0;
41318 var MAX_LOOP_COUNT = 100;
41319 // Always walk up the entire parent chain, to be able to find
41320 // e.g. \Resources placed on multiple levels of the tree.
41321 while (dict) {
41322 var value = dict.get(key);
41323 if (value) {
41324 if (!valueArray) {
41325 valueArray = [];
41326 }
41327 valueArray.push(value);
41328 }
41329 if (++loopCount > MAX_LOOP_COUNT) {
41330 warn('Page_getInheritedPageProp: maximum loop count exceeded.');
41331 break;
41332 }
41333 dict = dict.get('Parent');
41334 }
41335 if (!valueArray) {
41336 return Dict.empty;
41337 }
41338 if (valueArray.length === 1 || !isDict(valueArray[0]) ||
41339 loopCount > MAX_LOOP_COUNT) {
41340 return valueArray[0];
41341 }
41342 return Dict.merge(this.xref, valueArray);
41343 },
41344
41345 get content() {
41346 return this.getPageProp('Contents');
41347 },
41348
41349 get resources() {
41350 // For robustness: The spec states that a \Resources entry has to be
41351 // present, but can be empty. Some document omit it still, in this case
41352 // we return an empty dictionary.
41353 return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
41354 },
41355
41356 get mediaBox() {
41357 var obj = this.getInheritedPageProp('MediaBox');
41358 // Reset invalid media box to letter size.
41359 if (!isArray(obj) || obj.length !== 4) {
41360 obj = LETTER_SIZE_MEDIABOX;
41361 }
41362 return shadow(this, 'mediaBox', obj);
41363 },
41364
41365 get view() {
41366 var mediaBox = this.mediaBox;
41367 var cropBox = this.getInheritedPageProp('CropBox');
41368 if (!isArray(cropBox) || cropBox.length !== 4) {
41369 return shadow(this, 'view', mediaBox);
41370 }
41371
41372 // From the spec, 6th ed., p.963:
41373 // "The crop, bleed, trim, and art boxes should not ordinarily
41374 // extend beyond the boundaries of the media box. If they do, they are
41375 // effectively reduced to their intersection with the media box."
41376 cropBox = Util.intersect(cropBox, mediaBox);
41377 if (!cropBox) {
41378 return shadow(this, 'view', mediaBox);
41379 }
41380 return shadow(this, 'view', cropBox);
41381 },
41382
41383 get rotate() {
41384 var rotate = this.getInheritedPageProp('Rotate') || 0;
41385 // Normalize rotation so it's a multiple of 90 and between 0 and 270
41386 if (rotate % 90 !== 0) {
41387 rotate = 0;
41388 } else if (rotate >= 360) {
41389 rotate = rotate % 360;
41390 } else if (rotate < 0) {
41391 // The spec doesn't cover negatives, assume its counterclockwise
41392 // rotation. The following is the other implementation of modulo.
41393 rotate = ((rotate % 360) + 360) % 360;
41394 }
41395 return shadow(this, 'rotate', rotate);
41396 },
41397
41398 getContentStream: function Page_getContentStream() {
41399 var content = this.content;
41400 var stream;
41401 if (isArray(content)) {
41402 // fetching items
41403 var xref = this.xref;
41404 var i, n = content.length;
41405 var streams = [];
41406 for (i = 0; i < n; ++i) {
41407 streams.push(xref.fetchIfRef(content[i]));
41408 }
41409 stream = new StreamsSequenceStream(streams);
41410 } else if (isStream(content)) {
41411 stream = content;
41412 } else {
41413 // replacing non-existent page content with empty one
41414 stream = new NullStream();
41415 }
41416 return stream;
41417 },
41418
41419 loadResources: function Page_loadResources(keys) {
41420 if (!this.resourcesPromise) {
41421 // TODO: add async getInheritedPageProp and remove this.
41422 this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
41423 }
41424 return this.resourcesPromise.then(function resourceSuccess() {
41425 var objectLoader = new ObjectLoader(this.resources.map,
41426 keys,
41427 this.xref);
41428 return objectLoader.load();
41429 }.bind(this));
41430 },
41431
41432 getOperatorList: function Page_getOperatorList(handler, task, intent,
41433 renderInteractiveForms) {
41434 var self = this;
41435
41436 var pdfManager = this.pdfManager;
41437 var contentStreamPromise = pdfManager.ensure(this, 'getContentStream',
41438 []);
41439 var resourcesPromise = this.loadResources([
41440 'ExtGState',
41441 'ColorSpace',
41442 'Pattern',
41443 'Shading',
41444 'XObject',
41445 'Font'
41446 // ProcSet
41447 // Properties
41448 ]);
41449
41450 var partialEvaluator = new PartialEvaluator(pdfManager, this.xref,
41451 handler, this.pageIndex,
41452 this.uniquePrefix,
41453 this.idCounters,
41454 this.fontCache,
41455 this.evaluatorOptions);
41456
41457 var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
41458 var pageListPromise = dataPromises.then(function(data) {
41459 var contentStream = data[0];
41460 var opList = new OperatorList(intent, handler, self.pageIndex);
41461
41462 handler.send('StartRenderPage', {
41463 transparency: partialEvaluator.hasBlendModes(self.resources),
41464 pageIndex: self.pageIndex,
41465 intent: intent
41466 });
41467 return partialEvaluator.getOperatorList(contentStream, task,
41468 self.resources, opList).then(function () {
41469 return opList;
41470 });
41471 });
41472
41473 var annotationsPromise = pdfManager.ensure(this, 'annotations');
41474 return Promise.all([pageListPromise, annotationsPromise]).then(
41475 function(datas) {
41476 var pageOpList = datas[0];
41477 var annotations = datas[1];
41478
41479 if (annotations.length === 0) {
41480 pageOpList.flush(true);
41481 return pageOpList;
41482 }
41483
41484 var annotationsReadyPromise = Annotation.appendToOperatorList(
41485 annotations, pageOpList, partialEvaluator, task, intent,
41486 renderInteractiveForms);
41487 return annotationsReadyPromise.then(function () {
41488 pageOpList.flush(true);
41489 return pageOpList;
41490 });
41491 });
41492 },
41493
41494 extractTextContent: function Page_extractTextContent(task,
41495 normalizeWhitespace,
41496 combineTextItems) {
41497 var handler = {
41498 on: function nullHandlerOn() {},
41499 send: function nullHandlerSend() {}
41500 };
41501
41502 var self = this;
41503
41504 var pdfManager = this.pdfManager;
41505 var contentStreamPromise = pdfManager.ensure(this, 'getContentStream',
41506 []);
41507
41508 var resourcesPromise = this.loadResources([
41509 'ExtGState',
41510 'XObject',
41511 'Font'
41512 ]);
41513
41514 var dataPromises = Promise.all([contentStreamPromise,
41515 resourcesPromise]);
41516 return dataPromises.then(function(data) {
41517 var contentStream = data[0];
41518 var partialEvaluator = new PartialEvaluator(pdfManager, self.xref,
41519 handler, self.pageIndex,
41520 self.uniquePrefix,
41521 self.idCounters,
41522 self.fontCache,
41523 self.evaluatorOptions);
41524
41525 return partialEvaluator.getTextContent(contentStream,
41526 task,
41527 self.resources,
41528 /* stateManager = */ null,
41529 normalizeWhitespace,
41530 combineTextItems);
41531 });
41532 },
41533
41534 getAnnotationsData: function Page_getAnnotationsData(intent) {
41535 var annotations = this.annotations;
41536 var annotationsData = [];
41537 for (var i = 0, n = annotations.length; i < n; ++i) {
41538 if (intent) {
41539 if (!(intent === 'display' && annotations[i].viewable) &&
41540 !(intent === 'print' && annotations[i].printable)) {
41541 continue;
41542 }
41543 }
41544 annotationsData.push(annotations[i].data);
41545 }
41546 return annotationsData;
41547 },
41548
41549 get annotations() {
41550 var annotations = [];
41551 var annotationRefs = this.getInheritedPageProp('Annots') || [];
41552 var annotationFactory = new AnnotationFactory();
41553 for (var i = 0, n = annotationRefs.length; i < n; ++i) {
41554 var annotationRef = annotationRefs[i];
41555 var annotation = annotationFactory.create(this.xref, annotationRef,
41556 this.uniquePrefix,
41557 this.idCounters);
41558 if (annotation) {
41559 annotations.push(annotation);
41560 }
41561 }
41562 return shadow(this, 'annotations', annotations);
41563 }
41564 };
41565
41566 return Page;
41567})();
41568
41569/**
41570 * The `PDFDocument` holds all the data of the PDF file. Compared to the
41571 * `PDFDoc`, this one doesn't have any job management code.
41572 * Right now there exists one PDFDocument on the main thread + one object
41573 * for each worker. If there is no worker support enabled, there are two
41574 * `PDFDocument` objects on the main thread created.
41575 */
41576var PDFDocument = (function PDFDocumentClosure() {
41577 var FINGERPRINT_FIRST_BYTES = 1024;
41578 var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' +
41579 '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
41580
41581 function PDFDocument(pdfManager, arg, password) {
41582 if (isStream(arg)) {
41583 init.call(this, pdfManager, arg, password);
41584 } else if (isArrayBuffer(arg)) {
41585 init.call(this, pdfManager, new Stream(arg), password);
41586 } else {
41587 error('PDFDocument: Unknown argument type');
41588 }
41589 }
41590
41591 function init(pdfManager, stream, password) {
41592 assert(stream.length > 0, 'stream must have data');
41593 this.pdfManager = pdfManager;
41594 this.stream = stream;
41595 var xref = new XRef(this.stream, password, pdfManager);
41596 this.xref = xref;
41597 }
41598
41599 function find(stream, needle, limit, backwards) {
41600 var pos = stream.pos;
41601 var end = stream.end;
41602 var strBuf = [];
41603 if (pos + limit > end) {
41604 limit = end - pos;
41605 }
41606 for (var n = 0; n < limit; ++n) {
41607 strBuf.push(String.fromCharCode(stream.getByte()));
41608 }
41609 var str = strBuf.join('');
41610 stream.pos = pos;
41611 var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
41612 if (index === -1) {
41613 return false; /* not found */
41614 }
41615 stream.pos += index;
41616 return true; /* found */
41617 }
41618
41619 var DocumentInfoValidators = {
41620 get entries() {
41621 // Lazily build this since all the validation functions below are not
41622 // defined until after this file loads.
41623 return shadow(this, 'entries', {
41624 Title: isString,
41625 Author: isString,
41626 Subject: isString,
41627 Keywords: isString,
41628 Creator: isString,
41629 Producer: isString,
41630 CreationDate: isString,
41631 ModDate: isString,
41632 Trapped: isName
41633 });
41634 }
41635 };
41636
41637 PDFDocument.prototype = {
41638 parse: function PDFDocument_parse(recoveryMode) {
41639 this.setup(recoveryMode);
41640 var version = this.catalog.catDict.get('Version');
41641 if (isName(version)) {
41642 this.pdfFormatVersion = version.name;
41643 }
41644 try {
41645 // checking if AcroForm is present
41646 this.acroForm = this.catalog.catDict.get('AcroForm');
41647 if (this.acroForm) {
41648 this.xfa = this.acroForm.get('XFA');
41649 var fields = this.acroForm.get('Fields');
41650 if ((!fields || !isArray(fields) || fields.length === 0) &&
41651 !this.xfa) {
41652 // no fields and no XFA -- not a form (?)
41653 this.acroForm = null;
41654 }
41655 }
41656 } catch (ex) {
41657 info('Something wrong with AcroForm entry');
41658 this.acroForm = null;
41659 }
41660 },
41661
41662 get linearization() {
41663 var linearization = null;
41664 if (this.stream.length) {
41665 try {
41666 linearization = Linearization.create(this.stream);
41667 } catch (err) {
41668 if (err instanceof MissingDataException) {
41669 throw err;
41670 }
41671 info(err);
41672 }
41673 }
41674 // shadow the prototype getter with a data property
41675 return shadow(this, 'linearization', linearization);
41676 },
41677 get startXRef() {
41678 var stream = this.stream;
41679 var startXRef = 0;
41680 var linearization = this.linearization;
41681 if (linearization) {
41682 // Find end of first obj.
41683 stream.reset();
41684 if (find(stream, 'endobj', 1024)) {
41685 startXRef = stream.pos + 6;
41686 }
41687 } else {
41688 // Find startxref by jumping backward from the end of the file.
41689 var step = 1024;
41690 var found = false, pos = stream.end;
41691 while (!found && pos > 0) {
41692 pos -= step - 'startxref'.length;
41693 if (pos < 0) {
41694 pos = 0;
41695 }
41696 stream.pos = pos;
41697 found = find(stream, 'startxref', step, true);
41698 }
41699 if (found) {
41700 stream.skip(9);
41701 var ch;
41702 do {
41703 ch = stream.getByte();
41704 } while (isSpace(ch));
41705 var str = '';
41706 while (ch >= 0x20 && ch <= 0x39) { // < '9'
41707 str += String.fromCharCode(ch);
41708 ch = stream.getByte();
41709 }
41710 startXRef = parseInt(str, 10);
41711 if (isNaN(startXRef)) {
41712 startXRef = 0;
41713 }
41714 }
41715 }
41716 // shadow the prototype getter with a data property
41717 return shadow(this, 'startXRef', startXRef);
41718 },
41719 get mainXRefEntriesOffset() {
41720 var mainXRefEntriesOffset = 0;
41721 var linearization = this.linearization;
41722 if (linearization) {
41723 mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
41724 }
41725 // shadow the prototype getter with a data property
41726 return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
41727 },
41728 // Find the header, remove leading garbage and setup the stream
41729 // starting from the header.
41730 checkHeader: function PDFDocument_checkHeader() {
41731 var stream = this.stream;
41732 stream.reset();
41733 if (find(stream, '%PDF-', 1024)) {
41734 // Found the header, trim off any garbage before it.
41735 stream.moveStart();
41736 // Reading file format version
41737 var MAX_VERSION_LENGTH = 12;
41738 var version = '', ch;
41739 while ((ch = stream.getByte()) > 0x20) { // SPACE
41740 if (version.length >= MAX_VERSION_LENGTH) {
41741 break;
41742 }
41743 version += String.fromCharCode(ch);
41744 }
41745 if (!this.pdfFormatVersion) {
41746 // removing "%PDF-"-prefix
41747 this.pdfFormatVersion = version.substring(5);
41748 }
41749 return;
41750 }
41751 // May not be a PDF file, continue anyway.
41752 },
41753 parseStartXRef: function PDFDocument_parseStartXRef() {
41754 var startXRef = this.startXRef;
41755 this.xref.setStartXRef(startXRef);
41756 },
41757 setup: function PDFDocument_setup(recoveryMode) {
41758 this.xref.parse(recoveryMode);
41759 var self = this;
41760 var pageFactory = {
41761 createPage: function (pageIndex, dict, ref, fontCache) {
41762 return new Page(self.pdfManager, self.xref, pageIndex, dict, ref,
41763 fontCache);
41764 }
41765 };
41766 this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
41767 },
41768 get numPages() {
41769 var linearization = this.linearization;
41770 var num = linearization ? linearization.numPages : this.catalog.numPages;
41771 // shadow the prototype getter
41772 return shadow(this, 'numPages', num);
41773 },
41774 get documentInfo() {
41775 var docInfo = {
41776 PDFFormatVersion: this.pdfFormatVersion,
41777 IsAcroFormPresent: !!this.acroForm,
41778 IsXFAPresent: !!this.xfa
41779 };
41780 var infoDict;
41781 try {
41782 infoDict = this.xref.trailer.get('Info');
41783 } catch (err) {
41784 info('The document information dictionary is invalid.');
41785 }
41786 if (infoDict) {
41787 var validEntries = DocumentInfoValidators.entries;
41788 // Only fill the document info with valid entries from the spec.
41789 for (var key in validEntries) {
41790 if (infoDict.has(key)) {
41791 var value = infoDict.get(key);
41792 // Make sure the value conforms to the spec.
41793 if (validEntries[key](value)) {
41794 docInfo[key] = (typeof value !== 'string' ?
41795 value : stringToPDFString(value));
41796 } else {
41797 info('Bad value in document info for "' + key + '"');
41798 }
41799 }
41800 }
41801 }
41802 return shadow(this, 'documentInfo', docInfo);
41803 },
41804 get fingerprint() {
41805 var xref = this.xref, hash, fileID = '';
41806 var idArray = xref.trailer.get('ID');
41807
41808 if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) &&
41809 idArray[0] !== EMPTY_FINGERPRINT) {
41810 hash = stringToBytes(idArray[0]);
41811 } else {
41812 if (this.stream.ensureRange) {
41813 this.stream.ensureRange(0,
41814 Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
41815 }
41816 hash = calculateMD5(this.stream.bytes.subarray(0,
41817 FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
41818 }
41819
41820 for (var i = 0, n = hash.length; i < n; i++) {
41821 var hex = hash[i].toString(16);
41822 fileID += hex.length === 1 ? '0' + hex : hex;
41823 }
41824
41825 return shadow(this, 'fingerprint', fileID);
41826 },
41827
41828 getPage: function PDFDocument_getPage(pageIndex) {
41829 return this.catalog.getPage(pageIndex);
41830 },
41831
41832 cleanup: function PDFDocument_cleanup() {
41833 return this.catalog.cleanup();
41834 }
41835 };
41836
41837 return PDFDocument;
41838})();
41839
41840exports.Page = Page;
41841exports.PDFDocument = PDFDocument;
41842}));
41843
41844
41845(function (root, factory) {
41846 {
41847 factory((root.pdfjsCorePdfManager = {}), root.pdfjsSharedUtil,
41848 root.pdfjsCoreStream, root.pdfjsCoreChunkedStream,
41849 root.pdfjsCoreDocument);
41850 }
41851}(this, function (exports, sharedUtil, coreStream, coreChunkedStream,
41852 coreDocument) {
41853
41854var NotImplementedException = sharedUtil.NotImplementedException;
41855var MissingDataException = sharedUtil.MissingDataException;
41856var createPromiseCapability = sharedUtil.createPromiseCapability;
41857var Util = sharedUtil.Util;
41858var Stream = coreStream.Stream;
41859var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
41860var PDFDocument = coreDocument.PDFDocument;
41861
41862var BasePdfManager = (function BasePdfManagerClosure() {
41863 function BasePdfManager() {
41864 throw new Error('Cannot initialize BaseManagerManager');
41865 }
41866
41867 BasePdfManager.prototype = {
41868 get docId() {
41869 return this._docId;
41870 },
41871
41872 onLoadedStream: function BasePdfManager_onLoadedStream() {
41873 throw new NotImplementedException();
41874 },
41875
41876 ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
41877 return this.ensure(this.pdfDocument, prop, args);
41878 },
41879
41880 ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
41881 return this.ensure(this.pdfDocument.xref, prop, args);
41882 },
41883
41884 ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
41885 return this.ensure(this.pdfDocument.catalog, prop, args);
41886 },
41887
41888 getPage: function BasePdfManager_getPage(pageIndex) {
41889 return this.pdfDocument.getPage(pageIndex);
41890 },
41891
41892 cleanup: function BasePdfManager_cleanup() {
41893 return this.pdfDocument.cleanup();
41894 },
41895
41896 ensure: function BasePdfManager_ensure(obj, prop, args) {
41897 return new NotImplementedException();
41898 },
41899
41900 requestRange: function BasePdfManager_requestRange(begin, end) {
41901 return new NotImplementedException();
41902 },
41903
41904 requestLoadedStream: function BasePdfManager_requestLoadedStream() {
41905 return new NotImplementedException();
41906 },
41907
41908 sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
41909 return new NotImplementedException();
41910 },
41911
41912 updatePassword: function BasePdfManager_updatePassword(password) {
41913 this.pdfDocument.xref.password = this.password = password;
41914 if (this._passwordChangedCapability) {
41915 this._passwordChangedCapability.resolve();
41916 }
41917 },
41918
41919 passwordChanged: function BasePdfManager_passwordChanged() {
41920 this._passwordChangedCapability = createPromiseCapability();
41921 return this._passwordChangedCapability.promise;
41922 },
41923
41924 terminate: function BasePdfManager_terminate() {
41925 return new NotImplementedException();
41926 }
41927 };
41928
41929 return BasePdfManager;
41930})();
41931
41932var LocalPdfManager = (function LocalPdfManagerClosure() {
41933 function LocalPdfManager(docId, data, password, evaluatorOptions) {
41934 this._docId = docId;
41935 this.evaluatorOptions = evaluatorOptions;
41936 var stream = new Stream(data);
41937 this.pdfDocument = new PDFDocument(this, stream, password);
41938 this._loadedStreamCapability = createPromiseCapability();
41939 this._loadedStreamCapability.resolve(stream);
41940 }
41941
41942 Util.inherit(LocalPdfManager, BasePdfManager, {
41943 ensure: function LocalPdfManager_ensure(obj, prop, args) {
41944 return new Promise(function (resolve, reject) {
41945 try {
41946 var value = obj[prop];
41947 var result;
41948 if (typeof value === 'function') {
41949 result = value.apply(obj, args);
41950 } else {
41951 result = value;
41952 }
41953 resolve(result);
41954 } catch (e) {
41955 reject(e);
41956 }
41957 });
41958 },
41959
41960 requestRange: function LocalPdfManager_requestRange(begin, end) {
41961 return Promise.resolve();
41962 },
41963
41964 requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
41965 return;
41966 },
41967
41968 onLoadedStream: function LocalPdfManager_onLoadedStream() {
41969 return this._loadedStreamCapability.promise;
41970 },
41971
41972 terminate: function LocalPdfManager_terminate() {
41973 return;
41974 }
41975 });
41976
41977 return LocalPdfManager;
41978})();
41979
41980var NetworkPdfManager = (function NetworkPdfManagerClosure() {
41981 function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions) {
41982 this._docId = docId;
41983 this.msgHandler = args.msgHandler;
41984 this.evaluatorOptions = evaluatorOptions;
41985
41986 var params = {
41987 msgHandler: args.msgHandler,
41988 url: args.url,
41989 length: args.length,
41990 disableAutoFetch: args.disableAutoFetch,
41991 rangeChunkSize: args.rangeChunkSize
41992 };
41993 this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
41994 this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(),
41995 args.password);
41996 }
41997
41998 Util.inherit(NetworkPdfManager, BasePdfManager, {
41999 ensure: function NetworkPdfManager_ensure(obj, prop, args) {
42000 var pdfManager = this;
42001
42002 return new Promise(function (resolve, reject) {
42003 function ensureHelper() {
42004 try {
42005 var result;
42006 var value = obj[prop];
42007 if (typeof value === 'function') {
42008 result = value.apply(obj, args);
42009 } else {
42010 result = value;
42011 }
42012 resolve(result);
42013 } catch(e) {
42014 if (!(e instanceof MissingDataException)) {
42015 reject(e);
42016 return;
42017 }
42018 pdfManager.streamManager.requestRange(e.begin, e.end).
42019 then(ensureHelper, reject);
42020 }
42021 }
42022
42023 ensureHelper();
42024 });
42025 },
42026
42027 requestRange: function NetworkPdfManager_requestRange(begin, end) {
42028 return this.streamManager.requestRange(begin, end);
42029 },
42030
42031 requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
42032 this.streamManager.requestAllChunks();
42033 },
42034
42035 sendProgressiveData:
42036 function NetworkPdfManager_sendProgressiveData(chunk) {
42037 this.streamManager.onReceiveData({ chunk: chunk });
42038 },
42039
42040 onLoadedStream: function NetworkPdfManager_onLoadedStream() {
42041 return this.streamManager.onLoadedStream();
42042 },
42043
42044 terminate: function NetworkPdfManager_terminate() {
42045 this.streamManager.abort();
42046 }
42047 });
42048
42049 return NetworkPdfManager;
42050})();
42051
42052exports.LocalPdfManager = LocalPdfManager;
42053exports.NetworkPdfManager = NetworkPdfManager;
42054}));
42055
42056
42057(function (root, factory) {
42058 {
42059 factory((root.pdfjsCoreWorker = {}), root.pdfjsSharedUtil,
42060 root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
42061 }
42062}(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
42063
42064var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
42065var InvalidPDFException = sharedUtil.InvalidPDFException;
42066var MessageHandler = sharedUtil.MessageHandler;
42067var MissingPDFException = sharedUtil.MissingPDFException;
42068var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
42069var PasswordException = sharedUtil.PasswordException;
42070var PasswordResponses = sharedUtil.PasswordResponses;
42071var UnknownErrorException = sharedUtil.UnknownErrorException;
42072var XRefParseException = sharedUtil.XRefParseException;
42073var arrayByteLength = sharedUtil.arrayByteLength;
42074var arraysToBytes = sharedUtil.arraysToBytes;
42075var assert = sharedUtil.assert;
42076var createPromiseCapability = sharedUtil.createPromiseCapability;
42077var error = sharedUtil.error;
42078var info = sharedUtil.info;
42079var warn = sharedUtil.warn;
42080var setVerbosityLevel = sharedUtil.setVerbosityLevel;
42081var Ref = corePrimitives.Ref;
42082var LocalPdfManager = corePdfManager.LocalPdfManager;
42083var NetworkPdfManager = corePdfManager.NetworkPdfManager;
42084var globalScope = sharedUtil.globalScope;
42085
42086var WorkerTask = (function WorkerTaskClosure() {
42087 function WorkerTask(name) {
42088 this.name = name;
42089 this.terminated = false;
42090 this._capability = createPromiseCapability();
42091 }
42092
42093 WorkerTask.prototype = {
42094 get finished() {
42095 return this._capability.promise;
42096 },
42097
42098 finish: function () {
42099 this._capability.resolve();
42100 },
42101
42102 terminate: function () {
42103 this.terminated = true;
42104 },
42105
42106 ensureNotTerminated: function () {
42107 if (this.terminated) {
42108 throw new Error('Worker task was terminated');
42109 }
42110 }
42111 };
42112
42113 return WorkerTask;
42114})();
42115
42116
42117/** @implements {IPDFStream} */
42118var PDFWorkerStream = (function PDFWorkerStreamClosure() {
42119 function PDFWorkerStream(params, msgHandler) {
42120 this._queuedChunks = [];
42121 var initialData = params.initialData;
42122 if (initialData && initialData.length > 0) {
42123 this._queuedChunks.push(initialData);
42124 }
42125 this._msgHandler = msgHandler;
42126
42127 this._isRangeSupported = !(params.disableRange);
42128 this._isStreamingSupported = !(params.disableStream);
42129 this._contentLength = params.length;
42130
42131 this._fullRequestReader = null;
42132 this._rangeReaders = [];
42133
42134 msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
42135 msgHandler.on('OnDataProgress', this._onProgress.bind(this));
42136 }
42137 PDFWorkerStream.prototype = {
42138 _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
42139 if (args.begin === undefined) {
42140 if (this._fullRequestReader) {
42141 this._fullRequestReader._enqueue(args.chunk);
42142 } else {
42143 this._queuedChunks.push(args.chunk);
42144 }
42145 } else {
42146 var found = this._rangeReaders.some(function (rangeReader) {
42147 if (rangeReader._begin !== args.begin) {
42148 return false;
42149 }
42150 rangeReader._enqueue(args.chunk);
42151 return true;
42152 });
42153 assert(found);
42154 }
42155 },
42156
42157 _onProgress: function PDFWorkerStream_onProgress(evt) {
42158 if (this._rangeReaders.length > 0) {
42159 // Reporting to first range reader.
42160 var firstReader = this._rangeReaders[0];
42161 if (firstReader.onProgress) {
42162 firstReader.onProgress({loaded: evt.loaded});
42163 }
42164 }
42165 },
42166
42167 _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
42168 var i = this._rangeReaders.indexOf(reader);
42169 if (i >= 0) {
42170 this._rangeReaders.splice(i, 1);
42171 }
42172 },
42173
42174 getFullReader: function PDFWorkerStream_getFullReader() {
42175 assert(!this._fullRequestReader);
42176 var queuedChunks = this._queuedChunks;
42177 this._queuedChunks = null;
42178 return new PDFWorkerStreamReader(this, queuedChunks);
42179 },
42180
42181 getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
42182 var reader = new PDFWorkerStreamRangeReader(this, begin, end);
42183 this._msgHandler.send('RequestDataRange', { begin: begin, end: end });
42184 this._rangeReaders.push(reader);
42185 return reader;
42186 },
42187
42188 cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
42189 if (this._fullRequestReader) {
42190 this._fullRequestReader.cancel(reason);
42191 }
42192 var readers = this._rangeReaders.slice(0);
42193 readers.forEach(function (rangeReader) {
42194 rangeReader.cancel(reason);
42195 });
42196 }
42197 };
42198
42199 /** @implements {IPDFStreamReader} */
42200 function PDFWorkerStreamReader(stream, queuedChunks) {
42201 this._stream = stream;
42202 this._done = false;
42203 this._queuedChunks = queuedChunks || [];
42204 this._requests = [];
42205 this._headersReady = Promise.resolve();
42206 stream._fullRequestReader = this;
42207
42208 this.onProgress = null; // not used
42209 }
42210 PDFWorkerStreamReader.prototype = {
42211 _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
42212 if (this._done) {
42213 return; // ignore new data
42214 }
42215 if (this._requests.length > 0) {
42216 var requestCapability = this._requests.shift();
42217 requestCapability.resolve({value: chunk, done: false});
42218 return;
42219 }
42220 this._queuedChunks.push(chunk);
42221 },
42222
42223 get headersReady() {
42224 return this._headersReady;
42225 },
42226
42227 get isRangeSupported() {
42228 return this._stream._isRangeSupported;
42229 },
42230
42231 get isStreamingSupported() {
42232 return this._stream._isStreamingSupported;
42233 },
42234
42235 get contentLength() {
42236 return this._stream._contentLength;
42237 },
42238
42239 read: function PDFWorkerStreamReader_read() {
42240 if (this._queuedChunks.length > 0) {
42241 var chunk = this._queuedChunks.shift();
42242 return Promise.resolve({value: chunk, done: false});
42243 }
42244 if (this._done) {
42245 return Promise.resolve({value: undefined, done: true});
42246 }
42247 var requestCapability = createPromiseCapability();
42248 this._requests.push(requestCapability);
42249 return requestCapability.promise;
42250 },
42251
42252 cancel: function PDFWorkerStreamReader_cancel(reason) {
42253 this._done = true;
42254 this._requests.forEach(function (requestCapability) {
42255 requestCapability.resolve({value: undefined, done: true});
42256 });
42257 this._requests = [];
42258 }
42259 };
42260
42261 /** @implements {IPDFStreamRangeReader} */
42262 function PDFWorkerStreamRangeReader(stream, begin, end) {
42263 this._stream = stream;
42264 this._begin = begin;
42265 this._end = end;
42266 this._queuedChunk = null;
42267 this._requests = [];
42268 this._done = false;
42269
42270 this.onProgress = null;
42271 }
42272 PDFWorkerStreamRangeReader.prototype = {
42273 _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
42274 if (this._done) {
42275 return; // ignore new data
42276 }
42277 if (this._requests.length === 0) {
42278 this._queuedChunk = chunk;
42279 } else {
42280 var requestsCapability = this._requests.shift();
42281 requestsCapability.resolve({value: chunk, done: false});
42282 this._requests.forEach(function (requestCapability) {
42283 requestCapability.resolve({value: undefined, done: true});
42284 });
42285 this._requests = [];
42286 }
42287 this._done = true;
42288 this._stream._removeRangeReader(this);
42289 },
42290
42291 get isStreamingSupported() {
42292 return false;
42293 },
42294
42295 read: function PDFWorkerStreamRangeReader_read() {
42296 if (this._queuedChunk) {
42297 return Promise.resolve({value: this._queuedChunk, done: false});
42298 }
42299 if (this._done) {
42300 return Promise.resolve({value: undefined, done: true});
42301 }
42302 var requestCapability = createPromiseCapability();
42303 this._requests.push(requestCapability);
42304 return requestCapability.promise;
42305 },
42306
42307 cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
42308 this._done = true;
42309 this._requests.forEach(function (requestCapability) {
42310 requestCapability.resolve({value: undefined, done: true});
42311 });
42312 this._requests = [];
42313 this._stream._removeRangeReader(this);
42314 }
42315 };
42316
42317 return PDFWorkerStream;
42318})();
42319
42320/** @type IPDFStream */
42321var PDFNetworkStream;
42322
42323/**
42324 * Sets PDFNetworkStream class to be used as alternative PDF data transport.
42325 * @param {IPDFStream} cls - the PDF data transport.
42326 */
42327function setPDFNetworkStreamClass(cls) {
42328 PDFNetworkStream = cls;
42329}
42330
42331var WorkerMessageHandler = {
42332 setup: function wphSetup(handler, port) {
42333 var testMessageProcessed = false;
42334 handler.on('test', function wphSetupTest(data) {
42335 if (testMessageProcessed) {
42336 return; // we already processed 'test' message once
42337 }
42338 testMessageProcessed = true;
42339
42340 // check if Uint8Array can be sent to worker
42341 if (!(data instanceof Uint8Array)) {
42342 handler.send('test', 'main', false);
42343 return;
42344 }
42345 // making sure postMessage transfers are working
42346 var supportTransfers = data[0] === 255;
42347 handler.postMessageTransfers = supportTransfers;
42348 // check if the response property is supported by xhr
42349 var xhr = new XMLHttpRequest();
42350 var responseExists = 'response' in xhr;
42351 // check if the property is actually implemented
42352 try {
42353 var dummy = xhr.responseType;
42354 } catch (e) {
42355 responseExists = false;
42356 }
42357 if (!responseExists) {
42358 handler.send('test', false);
42359 return;
42360 }
42361 handler.send('test', {
42362 supportTypedArray: true,
42363 supportTransfers: supportTransfers
42364 });
42365 });
42366
42367 handler.on('configure', function wphConfigure(data) {
42368 setVerbosityLevel(data.verbosity);
42369 });
42370
42371 handler.on('GetDocRequest', function wphSetupDoc(data) {
42372 return WorkerMessageHandler.createDocumentHandler(data, port);
42373 });
42374 },
42375 createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
42376 // This context is actually holds references on pdfManager and handler,
42377 // until the latter is destroyed.
42378 var pdfManager;
42379 var terminated = false;
42380 var cancelXHRs = null;
42381 var WorkerTasks = [];
42382
42383 var docId = docParams.docId;
42384 var workerHandlerName = docParams.docId + '_worker';
42385 var handler = new MessageHandler(workerHandlerName, docId, port);
42386
42387 // Ensure that postMessage transfers are correctly enabled/disabled,
42388 // to prevent "DataCloneError" in older versions of IE (see issue 6957).
42389 handler.postMessageTransfers = docParams.postMessageTransfers;
42390
42391 function ensureNotTerminated() {
42392 if (terminated) {
42393 throw new Error('Worker was terminated');
42394 }
42395 }
42396
42397 function startWorkerTask(task) {
42398 WorkerTasks.push(task);
42399 }
42400
42401 function finishWorkerTask(task) {
42402 task.finish();
42403 var i = WorkerTasks.indexOf(task);
42404 WorkerTasks.splice(i, 1);
42405 }
42406
42407 function loadDocument(recoveryMode) {
42408 var loadDocumentCapability = createPromiseCapability();
42409
42410 var parseSuccess = function parseSuccess() {
42411 var numPagesPromise = pdfManager.ensureDoc('numPages');
42412 var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
42413 var encryptedPromise = pdfManager.ensureXRef('encrypt');
42414 Promise.all([numPagesPromise, fingerprintPromise,
42415 encryptedPromise]).then(function onDocReady(results) {
42416 var doc = {
42417 numPages: results[0],
42418 fingerprint: results[1],
42419 encrypted: !!results[2],
42420 };
42421 loadDocumentCapability.resolve(doc);
42422 },
42423 parseFailure);
42424 };
42425
42426 var parseFailure = function parseFailure(e) {
42427 loadDocumentCapability.reject(e);
42428 };
42429
42430 pdfManager.ensureDoc('checkHeader', []).then(function() {
42431 pdfManager.ensureDoc('parseStartXRef', []).then(function() {
42432 pdfManager.ensureDoc('parse', [recoveryMode]).then(
42433 parseSuccess, parseFailure);
42434 }, parseFailure);
42435 }, parseFailure);
42436
42437 return loadDocumentCapability.promise;
42438 }
42439
42440 function getPdfManager(data, evaluatorOptions) {
42441 var pdfManagerCapability = createPromiseCapability();
42442 var pdfManager;
42443
42444 var source = data.source;
42445 if (source.data) {
42446 try {
42447 pdfManager = new LocalPdfManager(docId, source.data, source.password,
42448 evaluatorOptions);
42449 pdfManagerCapability.resolve(pdfManager);
42450 } catch (ex) {
42451 pdfManagerCapability.reject(ex);
42452 }
42453 return pdfManagerCapability.promise;
42454 }
42455
42456 var pdfStream;
42457 try {
42458 if (source.chunkedViewerLoading) {
42459 pdfStream = new PDFWorkerStream(source, handler);
42460 } else {
42461 assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
42462 pdfStream = new PDFNetworkStream(data);
42463 }
42464 } catch (ex) {
42465 pdfManagerCapability.reject(ex);
42466 return pdfManagerCapability.promise;
42467 }
42468
42469 var fullRequest = pdfStream.getFullReader();
42470 fullRequest.headersReady.then(function () {
42471 if (!fullRequest.isStreamingSupported ||
42472 !fullRequest.isRangeSupported) {
42473 // If stream or range are disabled, it's our only way to report
42474 // loading progress.
42475 fullRequest.onProgress = function (evt) {
42476 handler.send('DocProgress', {
42477 loaded: evt.loaded,
42478 total: evt.total
42479 });
42480 };
42481 }
42482
42483 if (!fullRequest.isRangeSupported) {
42484 return;
42485 }
42486
42487 // We don't need auto-fetch when streaming is enabled.
42488 var disableAutoFetch = source.disableAutoFetch ||
42489 fullRequest.isStreamingSupported;
42490 pdfManager = new NetworkPdfManager(docId, pdfStream, {
42491 msgHandler: handler,
42492 url: source.url,
42493 password: source.password,
42494 length: fullRequest.contentLength,
42495 disableAutoFetch: disableAutoFetch,
42496 rangeChunkSize: source.rangeChunkSize
42497 }, evaluatorOptions);
42498 pdfManagerCapability.resolve(pdfManager);
42499 cancelXHRs = null;
42500 }).catch(function (reason) {
42501 pdfManagerCapability.reject(reason);
42502 cancelXHRs = null;
42503 });
42504
42505 var cachedChunks = [], loaded = 0;
42506 var flushChunks = function () {
42507 var pdfFile = arraysToBytes(cachedChunks);
42508 if (source.length && pdfFile.length !== source.length) {
42509 warn('reported HTTP length is different from actual');
42510 }
42511 // the data is array, instantiating directly from it
42512 try {
42513 pdfManager = new LocalPdfManager(docId, pdfFile, source.password,
42514 evaluatorOptions);
42515 pdfManagerCapability.resolve(pdfManager);
42516 } catch (ex) {
42517 pdfManagerCapability.reject(ex);
42518 }
42519 cachedChunks = [];
42520 };
42521 var readPromise = new Promise(function (resolve, reject) {
42522 var readChunk = function (chunk) {
42523 try {
42524 ensureNotTerminated();
42525 if (chunk.done) {
42526 if (!pdfManager) {
42527 flushChunks();
42528 }
42529 cancelXHRs = null;
42530 return;
42531 }
42532
42533 var data = chunk.value;
42534 loaded += arrayByteLength(data);
42535 if (!fullRequest.isStreamingSupported) {
42536 handler.send('DocProgress', {
42537 loaded: loaded,
42538 total: Math.max(loaded, fullRequest.contentLength || 0)
42539 });
42540 }
42541
42542 if (pdfManager) {
42543 pdfManager.sendProgressiveData(data);
42544 } else {
42545 cachedChunks.push(data);
42546 }
42547
42548 fullRequest.read().then(readChunk, reject);
42549 } catch (e) {
42550 reject(e);
42551 }
42552 };
42553 fullRequest.read().then(readChunk, reject);
42554 });
42555 readPromise.catch(function (e) {
42556 pdfManagerCapability.reject(e);
42557 cancelXHRs = null;
42558 });
42559
42560 cancelXHRs = function () {
42561 pdfStream.cancelAllRequests('abort');
42562 };
42563
42564 return pdfManagerCapability.promise;
42565 }
42566
42567 var setupDoc = function(data) {
42568 var onSuccess = function(doc) {
42569 ensureNotTerminated();
42570 handler.send('GetDoc', { pdfInfo: doc });
42571 };
42572
42573 var onFailure = function(e) {
42574 if (e instanceof PasswordException) {
42575 if (e.code === PasswordResponses.NEED_PASSWORD) {
42576 handler.send('NeedPassword', e);
42577 } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
42578 handler.send('IncorrectPassword', e);
42579 }
42580 } else if (e instanceof InvalidPDFException) {
42581 handler.send('InvalidPDF', e);
42582 } else if (e instanceof MissingPDFException) {
42583 handler.send('MissingPDF', e);
42584 } else if (e instanceof UnexpectedResponseException) {
42585 handler.send('UnexpectedResponse', e);
42586 } else {
42587 handler.send('UnknownError',
42588 new UnknownErrorException(e.message, e.toString()));
42589 }
42590 };
42591
42592 ensureNotTerminated();
42593
42594 var cMapOptions = {
42595 url: data.cMapUrl === undefined ? null : data.cMapUrl,
42596 packed: data.cMapPacked === true
42597 };
42598 var evaluatorOptions = {
42599 forceDataSchema: data.disableCreateObjectURL,
42600 maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
42601 disableFontFace: data.disableFontFace,
42602 cMapOptions: cMapOptions
42603 };
42604
42605 getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
42606 if (terminated) {
42607 // We were in a process of setting up the manager, but it got
42608 // terminated in the middle.
42609 newPdfManager.terminate();
42610 throw new Error('Worker was terminated');
42611 }
42612
42613 pdfManager = newPdfManager;
42614 handler.send('PDFManagerReady', null);
42615 pdfManager.onLoadedStream().then(function(stream) {
42616 handler.send('DataLoaded', { length: stream.bytes.byteLength });
42617 });
42618 }).then(function pdfManagerReady() {
42619 ensureNotTerminated();
42620
42621 loadDocument(false).then(onSuccess, function loadFailure(ex) {
42622 ensureNotTerminated();
42623
42624 // Try again with recoveryMode == true
42625 if (!(ex instanceof XRefParseException)) {
42626 if (ex instanceof PasswordException) {
42627 // after password exception prepare to receive a new password
42628 // to repeat loading
42629 pdfManager.passwordChanged().then(pdfManagerReady);
42630 }
42631
42632 onFailure(ex);
42633 return;
42634 }
42635
42636 pdfManager.requestLoadedStream();
42637 pdfManager.onLoadedStream().then(function() {
42638 ensureNotTerminated();
42639
42640 loadDocument(true).then(onSuccess, onFailure);
42641 });
42642 }, onFailure);
42643 }, onFailure);
42644 };
42645
42646 handler.on('GetPage', function wphSetupGetPage(data) {
42647 return pdfManager.getPage(data.pageIndex).then(function(page) {
42648 var rotatePromise = pdfManager.ensure(page, 'rotate');
42649 var refPromise = pdfManager.ensure(page, 'ref');
42650 var viewPromise = pdfManager.ensure(page, 'view');
42651
42652 return Promise.all([rotatePromise, refPromise, viewPromise]).then(
42653 function(results) {
42654 return {
42655 rotate: results[0],
42656 ref: results[1],
42657 view: results[2]
42658 };
42659 });
42660 });
42661 });
42662
42663 handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
42664 var ref = new Ref(data.ref.num, data.ref.gen);
42665 var catalog = pdfManager.pdfDocument.catalog;
42666 return catalog.getPageIndex(ref);
42667 });
42668
42669 handler.on('GetDestinations',
42670 function wphSetupGetDestinations(data) {
42671 return pdfManager.ensureCatalog('destinations');
42672 }
42673 );
42674
42675 handler.on('GetDestination',
42676 function wphSetupGetDestination(data) {
42677 return pdfManager.ensureCatalog('getDestination', [data.id]);
42678 }
42679 );
42680
42681 handler.on('GetPageLabels',
42682 function wphSetupGetPageLabels(data) {
42683 return pdfManager.ensureCatalog('pageLabels');
42684 }
42685 );
42686
42687 handler.on('GetAttachments',
42688 function wphSetupGetAttachments(data) {
42689 return pdfManager.ensureCatalog('attachments');
42690 }
42691 );
42692
42693 handler.on('GetJavaScript',
42694 function wphSetupGetJavaScript(data) {
42695 return pdfManager.ensureCatalog('javaScript');
42696 }
42697 );
42698
42699 handler.on('GetOutline',
42700 function wphSetupGetOutline(data) {
42701 return pdfManager.ensureCatalog('documentOutline');
42702 }
42703 );
42704
42705 handler.on('GetMetadata',
42706 function wphSetupGetMetadata(data) {
42707 return Promise.all([pdfManager.ensureDoc('documentInfo'),
42708 pdfManager.ensureCatalog('metadata')]);
42709 }
42710 );
42711
42712 handler.on('GetData', function wphSetupGetData(data) {
42713 pdfManager.requestLoadedStream();
42714 return pdfManager.onLoadedStream().then(function(stream) {
42715 return stream.bytes;
42716 });
42717 });
42718
42719 handler.on('GetStats',
42720 function wphSetupGetStats(data) {
42721 return pdfManager.pdfDocument.xref.stats;
42722 }
42723 );
42724
42725 handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
42726 pdfManager.updatePassword(data);
42727 });
42728
42729 handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
42730 return pdfManager.getPage(data.pageIndex).then(function(page) {
42731 return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
42732 });
42733 });
42734
42735 handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
42736 var pageIndex = data.pageIndex;
42737 pdfManager.getPage(pageIndex).then(function(page) {
42738 var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
42739 startWorkerTask(task);
42740
42741 var pageNum = pageIndex + 1;
42742 var start = Date.now();
42743 // Pre compile the pdf page and fetch the fonts/images.
42744 page.getOperatorList(handler, task, data.intent,
42745 data.renderInteractiveForms).then(
42746 function(operatorList) {
42747 finishWorkerTask(task);
42748
42749 info('page=' + pageNum + ' - getOperatorList: time=' +
42750 (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
42751 }, function(e) {
42752 finishWorkerTask(task);
42753 if (task.terminated) {
42754 return; // ignoring errors from the terminated thread
42755 }
42756
42757 // For compatibility with older behavior, generating unknown
42758 // unsupported feature notification on errors.
42759 handler.send('UnsupportedFeature',
42760 {featureId: UNSUPPORTED_FEATURES.unknown});
42761
42762 var minimumStackMessage =
42763 'worker.js: while trying to getPage() and getOperatorList()';
42764
42765 var wrappedException;
42766
42767 // Turn the error into an obj that can be serialized
42768 if (typeof e === 'string') {
42769 wrappedException = {
42770 message: e,
42771 stack: minimumStackMessage
42772 };
42773 } else if (typeof e === 'object') {
42774 wrappedException = {
42775 message: e.message || e.toString(),
42776 stack: e.stack || minimumStackMessage
42777 };
42778 } else {
42779 wrappedException = {
42780 message: 'Unknown exception type: ' + (typeof e),
42781 stack: minimumStackMessage
42782 };
42783 }
42784
42785 handler.send('PageError', {
42786 pageNum: pageNum,
42787 error: wrappedException,
42788 intent: data.intent
42789 });
42790 });
42791 });
42792 }, this);
42793
42794 handler.on('GetTextContent', function wphExtractText(data) {
42795 var pageIndex = data.pageIndex;
42796 var normalizeWhitespace = data.normalizeWhitespace;
42797 var combineTextItems = data.combineTextItems;
42798 return pdfManager.getPage(pageIndex).then(function(page) {
42799 var task = new WorkerTask('GetTextContent: page ' + pageIndex);
42800 startWorkerTask(task);
42801 var pageNum = pageIndex + 1;
42802 var start = Date.now();
42803 return page.extractTextContent(task, normalizeWhitespace,
42804 combineTextItems).then(
42805 function(textContent) {
42806 finishWorkerTask(task);
42807 info('text indexing: page=' + pageNum + ' - time=' +
42808 (Date.now() - start) + 'ms');
42809 return textContent;
42810 }, function (reason) {
42811 finishWorkerTask(task);
42812 if (task.terminated) {
42813 return; // ignoring errors from the terminated thread
42814 }
42815 throw reason;
42816 });
42817 });
42818 });
42819
42820 handler.on('Cleanup', function wphCleanup(data) {
42821 return pdfManager.cleanup();
42822 });
42823
42824 handler.on('Terminate', function wphTerminate(data) {
42825 terminated = true;
42826 if (pdfManager) {
42827 pdfManager.terminate();
42828 pdfManager = null;
42829 }
42830 if (cancelXHRs) {
42831 cancelXHRs();
42832 }
42833
42834 var waitOn = [];
42835 WorkerTasks.forEach(function (task) {
42836 waitOn.push(task.finished);
42837 task.terminate();
42838 });
42839
42840 return Promise.all(waitOn).then(function () {
42841 // Notice that even if we destroying handler, resolved response promise
42842 // must be sent back.
42843 handler.destroy();
42844 handler = null;
42845 });
42846 });
42847
42848 handler.on('Ready', function wphReady(data) {
42849 setupDoc(docParams);
42850 docParams = null; // we don't need docParams anymore -- saving memory.
42851 });
42852 return workerHandlerName;
42853 }
42854};
42855
42856function initializeWorker() {
42857 if (!('console' in globalScope)) {
42858 var consoleTimer = {};
42859
42860 var workerConsole = {
42861 log: function log() {
42862 var args = Array.prototype.slice.call(arguments);
42863 globalScope.postMessage({
42864 targetName: 'main',
42865 action: 'console_log',
42866 data: args
42867 });
42868 },
42869
42870 error: function error() {
42871 var args = Array.prototype.slice.call(arguments);
42872 globalScope.postMessage({
42873 targetName: 'main',
42874 action: 'console_error',
42875 data: args
42876 });
42877 throw 'pdf.js execution error';
42878 },
42879
42880 time: function time(name) {
42881 consoleTimer[name] = Date.now();
42882 },
42883
42884 timeEnd: function timeEnd(name) {
42885 var time = consoleTimer[name];
42886 if (!time) {
42887 error('Unknown timer name ' + name);
42888 }
42889 this.log('Timer:', name, Date.now() - time);
42890 }
42891 };
42892
42893 globalScope.console = workerConsole;
42894 }
42895
42896 var handler = new MessageHandler('worker', 'main', self);
42897 WorkerMessageHandler.setup(handler, self);
42898 handler.send('ready', null);
42899}
42900
42901// Worker thread (and not node.js)?
42902if (typeof window === 'undefined' &&
42903 !(typeof module !== 'undefined' && module.require)) {
42904 initializeWorker();
42905}
42906
42907exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
42908exports.WorkerTask = WorkerTask;
42909exports.WorkerMessageHandler = WorkerMessageHandler;
42910}));
42911
42912
42913
42914
42915var NetworkManager = (function NetworkManagerClosure() {
42916
42917 var OK_RESPONSE = 200;
42918 var PARTIAL_CONTENT_RESPONSE = 206;
42919
42920 function NetworkManager(url, args) {
42921 this.url = url;
42922 args = args || {};
42923 this.isHttp = /^https?:/i.test(url);
42924 this.httpHeaders = (this.isHttp && args.httpHeaders) || {};
42925 this.withCredentials = args.withCredentials || false;
42926 this.getXhr = args.getXhr ||
42927 function NetworkManager_getXhr() {
42928 return new XMLHttpRequest();
42929 };
42930
42931 this.currXhrId = 0;
42932 this.pendingRequests = Object.create(null);
42933 this.loadedRequests = Object.create(null);
42934 }
42935
42936 function getArrayBuffer(xhr) {
42937 var data = xhr.response;
42938 if (typeof data !== 'string') {
42939 return data;
42940 }
42941 var length = data.length;
42942 var array = new Uint8Array(length);
42943 for (var i = 0; i < length; i++) {
42944 array[i] = data.charCodeAt(i) & 0xFF;
42945 }
42946 return array.buffer;
42947 }
42948
42949 var supportsMozChunked = (function supportsMozChunkedClosure() {
42950 try {
42951 var x = new XMLHttpRequest();
42952 // Firefox 37- required .open() to be called before setting responseType.
42953 // https://bugzilla.mozilla.org/show_bug.cgi?id=707484
42954 // Even though the URL is not visited, .open() could fail if the URL is
42955 // blocked, e.g. via the connect-src CSP directive or the NoScript addon.
42956 // When this error occurs, this feature detection method will mistakenly
42957 // report that moz-chunked-arraybuffer is not supported in Firefox 37-.
42958 x.open('GET', 'https://example.com');
42959 x.responseType = 'moz-chunked-arraybuffer';
42960 return x.responseType === 'moz-chunked-arraybuffer';
42961 } catch (e) {
42962 return false;
42963 }
42964 })();
42965
42966 NetworkManager.prototype = {
42967 requestRange: function NetworkManager_requestRange(begin, end, listeners) {
42968 var args = {
42969 begin: begin,
42970 end: end
42971 };
42972 for (var prop in listeners) {
42973 args[prop] = listeners[prop];
42974 }
42975 return this.request(args);
42976 },
42977
42978 requestFull: function NetworkManager_requestFull(listeners) {
42979 return this.request(listeners);
42980 },
42981
42982 request: function NetworkManager_request(args) {
42983 var xhr = this.getXhr();
42984 var xhrId = this.currXhrId++;
42985 var pendingRequest = this.pendingRequests[xhrId] = {
42986 xhr: xhr
42987 };
42988
42989 xhr.open('GET', this.url);
42990 xhr.withCredentials = this.withCredentials;
42991 for (var property in this.httpHeaders) {
42992 var value = this.httpHeaders[property];
42993 if (typeof value === 'undefined') {
42994 continue;
42995 }
42996 xhr.setRequestHeader(property, value);
42997 }
42998 if (this.isHttp && 'begin' in args && 'end' in args) {
42999 var rangeStr = args.begin + '-' + (args.end - 1);
43000 xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
43001 pendingRequest.expectedStatus = 206;
43002 } else {
43003 pendingRequest.expectedStatus = 200;
43004 }
43005
43006 var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
43007 if (useMozChunkedLoading) {
43008 xhr.responseType = 'moz-chunked-arraybuffer';
43009 pendingRequest.onProgressiveData = args.onProgressiveData;
43010 pendingRequest.mozChunked = true;
43011 } else {
43012 xhr.responseType = 'arraybuffer';
43013 }
43014
43015 if (args.onError) {
43016 xhr.onerror = function(evt) {
43017 args.onError(xhr.status);
43018 };
43019 }
43020 xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
43021 xhr.onprogress = this.onProgress.bind(this, xhrId);
43022
43023 pendingRequest.onHeadersReceived = args.onHeadersReceived;
43024 pendingRequest.onDone = args.onDone;
43025 pendingRequest.onError = args.onError;
43026 pendingRequest.onProgress = args.onProgress;
43027
43028 xhr.send(null);
43029
43030 return xhrId;
43031 },
43032
43033 onProgress: function NetworkManager_onProgress(xhrId, evt) {
43034 var pendingRequest = this.pendingRequests[xhrId];
43035 if (!pendingRequest) {
43036 // Maybe abortRequest was called...
43037 return;
43038 }
43039
43040 if (pendingRequest.mozChunked) {
43041 var chunk = getArrayBuffer(pendingRequest.xhr);
43042 pendingRequest.onProgressiveData(chunk);
43043 }
43044
43045 var onProgress = pendingRequest.onProgress;
43046 if (onProgress) {
43047 onProgress(evt);
43048 }
43049 },
43050
43051 onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
43052 var pendingRequest = this.pendingRequests[xhrId];
43053 if (!pendingRequest) {
43054 // Maybe abortRequest was called...
43055 return;
43056 }
43057
43058 var xhr = pendingRequest.xhr;
43059 if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
43060 pendingRequest.onHeadersReceived();
43061 delete pendingRequest.onHeadersReceived;
43062 }
43063
43064 if (xhr.readyState !== 4) {
43065 return;
43066 }
43067
43068 if (!(xhrId in this.pendingRequests)) {
43069 // The XHR request might have been aborted in onHeadersReceived()
43070 // callback, in which case we should abort request
43071 return;
43072 }
43073
43074 delete this.pendingRequests[xhrId];
43075
43076 // success status == 0 can be on ftp, file and other protocols
43077 if (xhr.status === 0 && this.isHttp) {
43078 if (pendingRequest.onError) {
43079 pendingRequest.onError(xhr.status);
43080 }
43081 return;
43082 }
43083 var xhrStatus = xhr.status || OK_RESPONSE;
43084
43085 // From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2:
43086 // "A server MAY ignore the Range header". This means it's possible to
43087 // get a 200 rather than a 206 response from a range request.
43088 var ok_response_on_range_request =
43089 xhrStatus === OK_RESPONSE &&
43090 pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
43091
43092 if (!ok_response_on_range_request &&
43093 xhrStatus !== pendingRequest.expectedStatus) {
43094 if (pendingRequest.onError) {
43095 pendingRequest.onError(xhr.status);
43096 }
43097 return;
43098 }
43099
43100 this.loadedRequests[xhrId] = true;
43101
43102 var chunk = getArrayBuffer(xhr);
43103 if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
43104 var rangeHeader = xhr.getResponseHeader('Content-Range');
43105 var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
43106 var begin = parseInt(matches[1], 10);
43107 pendingRequest.onDone({
43108 begin: begin,
43109 chunk: chunk
43110 });
43111 } else if (pendingRequest.onProgressiveData) {
43112 pendingRequest.onDone(null);
43113 } else if (chunk) {
43114 pendingRequest.onDone({
43115 begin: 0,
43116 chunk: chunk
43117 });
43118 } else if (pendingRequest.onError) {
43119 pendingRequest.onError(xhr.status);
43120 }
43121 },
43122
43123 hasPendingRequests: function NetworkManager_hasPendingRequests() {
43124 for (var xhrId in this.pendingRequests) {
43125 return true;
43126 }
43127 return false;
43128 },
43129
43130 getRequestXhr: function NetworkManager_getXhr(xhrId) {
43131 return this.pendingRequests[xhrId].xhr;
43132 },
43133
43134 isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
43135 return !!(this.pendingRequests[xhrId].onProgressiveData);
43136 },
43137
43138 isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
43139 return xhrId in this.pendingRequests;
43140 },
43141
43142 isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
43143 return xhrId in this.loadedRequests;
43144 },
43145
43146 abortAllRequests: function NetworkManager_abortAllRequests() {
43147 for (var xhrId in this.pendingRequests) {
43148 this.abortRequest(xhrId | 0);
43149 }
43150 },
43151
43152 abortRequest: function NetworkManager_abortRequest(xhrId) {
43153 var xhr = this.pendingRequests[xhrId].xhr;
43154 delete this.pendingRequests[xhrId];
43155 xhr.abort();
43156 }
43157 };
43158
43159 return NetworkManager;
43160})();
43161
43162(function (root, factory) {
43163 {
43164 factory((root.pdfjsCoreNetwork = {}), root.pdfjsSharedUtil,
43165 root.pdfjsCoreWorker);
43166 }
43167}(this, function (exports, sharedUtil, coreWorker) {
43168
43169 var assert = sharedUtil.assert;
43170 var createPromiseCapability = sharedUtil.createPromiseCapability;
43171 var isInt = sharedUtil.isInt;
43172 var MissingPDFException = sharedUtil.MissingPDFException;
43173 var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
43174
43175 /** @implements {IPDFStream} */
43176 function PDFNetworkStream(options) {
43177 this._options = options;
43178 var source = options.source;
43179 this._manager = new NetworkManager(source.url, {
43180 httpHeaders: source.httpHeaders,
43181 withCredentials: source.withCredentials
43182 });
43183 this._rangeChunkSize = source.rangeChunkSize;
43184 this._fullRequestReader = null;
43185 this._rangeRequestReaders = [];
43186 }
43187
43188 PDFNetworkStream.prototype = {
43189 _onRangeRequestReaderClosed:
43190 function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
43191 var i = this._rangeRequestReaders.indexOf(reader);
43192 if (i >= 0) {
43193 this._rangeRequestReaders.splice(i, 1);
43194 }
43195 },
43196
43197 getFullReader: function PDFNetworkStream_getFullReader() {
43198 assert(!this._fullRequestReader);
43199 this._fullRequestReader =
43200 new PDFNetworkStreamFullRequestReader(this._manager, this._options);
43201 return this._fullRequestReader;
43202 },
43203
43204 getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
43205 var reader = new PDFNetworkStreamRangeRequestReader(this._manager,
43206 begin, end);
43207 reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
43208 this._rangeRequestReaders.push(reader);
43209 return reader;
43210 },
43211
43212 cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
43213 if (this._fullRequestReader) {
43214 this._fullRequestReader.cancel(reason);
43215 }
43216 var readers = this._rangeRequestReaders.slice(0);
43217 readers.forEach(function (reader) {
43218 reader.cancel(reason);
43219 });
43220 }
43221 };
43222
43223 /** @implements {IPDFStreamReader} */
43224 function PDFNetworkStreamFullRequestReader(manager, options) {
43225 this._manager = manager;
43226
43227 var source = options.source;
43228 var args = {
43229 onHeadersReceived: this._onHeadersReceived.bind(this),
43230 onProgressiveData: source.disableStream ? null :
43231 this._onProgressiveData.bind(this),
43232 onDone: this._onDone.bind(this),
43233 onError: this._onError.bind(this),
43234 onProgress: this._onProgress.bind(this)
43235 };
43236 this._url = source.url;
43237 this._fullRequestId = manager.requestFull(args);
43238 this._headersReceivedCapability = createPromiseCapability();
43239 this._disableRange = options.disableRange || false;
43240 this._contentLength = source.length; // optional
43241 this._rangeChunkSize = source.rangeChunkSize;
43242 if (!this._rangeChunkSize && !this._disableRange) {
43243 this._disableRange = true;
43244 }
43245
43246 this._isStreamingSupported = false;
43247 this._isRangeSupported = false;
43248
43249 this._cachedChunks = [];
43250 this._requests = [];
43251 this._done = false;
43252 this._storedError = undefined;
43253
43254 this.onProgress = null;
43255 }
43256
43257 PDFNetworkStreamFullRequestReader.prototype = {
43258 _validateRangeRequestCapabilities: function
43259 PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
43260
43261 if (this._disableRange) {
43262 return false;
43263 }
43264
43265 var networkManager = this._manager;
43266 var fullRequestXhrId = this._fullRequestId;
43267 var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
43268 if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
43269 return false;
43270 }
43271
43272 var contentEncoding =
43273 fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
43274 if (contentEncoding !== 'identity') {
43275 return false;
43276 }
43277
43278 var length = fullRequestXhr.getResponseHeader('Content-Length');
43279 length = parseInt(length, 10);
43280 if (!isInt(length)) {
43281 return false;
43282 }
43283
43284 this._contentLength = length; // setting right content length
43285
43286 if (length <= 2 * this._rangeChunkSize) {
43287 // The file size is smaller than the size of two chunks, so it does
43288 // not make any sense to abort the request and retry with a range
43289 // request.
43290 return false;
43291 }
43292
43293 return true;
43294 },
43295
43296 _onHeadersReceived:
43297 function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
43298
43299 if (this._validateRangeRequestCapabilities()) {
43300 this._isRangeSupported = true;
43301 }
43302
43303 var networkManager = this._manager;
43304 var fullRequestXhrId = this._fullRequestId;
43305 if (networkManager.isStreamingRequest(fullRequestXhrId)) {
43306 // We can continue fetching when progressive loading is enabled,
43307 // and we don't need the autoFetch feature.
43308 this._isStreamingSupported = true;
43309 } else if (this._isRangeSupported) {
43310 // NOTE: by cancelling the full request, and then issuing range
43311 // requests, there will be an issue for sites where you can only
43312 // request the pdf once. However, if this is the case, then the
43313 // server should not be returning that it can support range
43314 // requests.
43315 networkManager.abortRequest(fullRequestXhrId);
43316 }
43317
43318 this._headersReceivedCapability.resolve();
43319 },
43320
43321 _onProgressiveData:
43322 function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
43323 if (this._requests.length > 0) {
43324 var requestCapability = this._requests.shift();
43325 requestCapability.resolve({value: chunk, done: false});
43326 } else {
43327 this._cachedChunks.push(chunk);
43328 }
43329 },
43330
43331 _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
43332 if (args) {
43333 this._onProgressiveData(args.chunk);
43334 }
43335 this._done = true;
43336 if (this._cachedChunks.length > 0) {
43337 return;
43338 }
43339 this._requests.forEach(function (requestCapability) {
43340 requestCapability.resolve({value: undefined, done: true});
43341 });
43342 this._requests = [];
43343 },
43344
43345 _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
43346 var url = this._url;
43347 var exception;
43348 if (status === 404 || status === 0 && /^file:/.test(url)) {
43349 exception = new MissingPDFException('Missing PDF "' + url + '".');
43350 } else {
43351 exception = new UnexpectedResponseException(
43352 'Unexpected server response (' + status +
43353 ') while retrieving PDF "' + url + '".', status);
43354 }
43355 this._storedError = exception;
43356 this._headersReceivedCapability.reject(exception);
43357 this._requests.forEach(function (requestCapability) {
43358 requestCapability.reject(exception);
43359 });
43360 this._requests = [];
43361 this._cachedChunks = [];
43362 },
43363
43364 _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
43365 if (this.onProgress) {
43366 this.onProgress({
43367 loaded: data.loaded,
43368 total: data.lengthComputable ? data.total : this._contentLength
43369 });
43370 }
43371 },
43372
43373 get isRangeSupported() {
43374 return this._isRangeSupported;
43375 },
43376
43377 get isStreamingSupported() {
43378 return this._isStreamingSupported;
43379 },
43380
43381 get contentLength() {
43382 return this._contentLength;
43383 },
43384
43385 get headersReady() {
43386 return this._headersReceivedCapability.promise;
43387 },
43388
43389 read: function PDFNetworkStreamFullRequestReader_read() {
43390 if (this._storedError) {
43391 return Promise.reject(this._storedError);
43392 }
43393 if (this._cachedChunks.length > 0) {
43394 var chunk = this._cachedChunks.shift();
43395 return Promise.resolve(chunk);
43396 }
43397 if (this._done) {
43398 return Promise.resolve({value: undefined, done: true});
43399 }
43400 var requestCapability = createPromiseCapability();
43401 this._requests.push(requestCapability);
43402 return requestCapability.promise;
43403 },
43404
43405 cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
43406 this._done = true;
43407 this._headersReceivedCapability.reject(reason);
43408 this._requests.forEach(function (requestCapability) {
43409 requestCapability.resolve({value: undefined, done: true});
43410 });
43411 this._requests = [];
43412 if (this._manager.isPendingRequest(this._fullRequestId)) {
43413 this._manager.abortRequest(this._fullRequestId);
43414 }
43415 this._fullRequestReader = null;
43416 }
43417 };
43418
43419 /** @implements {IPDFStreamRangeReader} */
43420 function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
43421 this._manager = manager;
43422 var args = {
43423 onDone: this._onDone.bind(this),
43424 onProgress: this._onProgress.bind(this)
43425 };
43426 this._requestId = manager.requestRange(begin, end, args);
43427 this._requests = [];
43428 this._queuedChunk = null;
43429 this._done = false;
43430
43431 this.onProgress = null;
43432 this.onClosed = null;
43433 }
43434
43435 PDFNetworkStreamRangeRequestReader.prototype = {
43436 _close: function PDFNetworkStreamRangeRequestReader_close() {
43437 if (this.onClosed) {
43438 this.onClosed(this);
43439 }
43440 },
43441
43442 _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
43443 var chunk = data.chunk;
43444 if (this._requests.length > 0) {
43445 var requestCapability = this._requests.shift();
43446 requestCapability.resolve({value: chunk, done: false});
43447 } else {
43448 this._queuedChunk = chunk;
43449 }
43450 this._done = true;
43451 this._requests.forEach(function (requestCapability) {
43452 requestCapability.resolve({value: undefined, done: true});
43453 });
43454 this._requests = [];
43455 this._close();
43456 },
43457
43458 _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
43459 if (!this.isStreamingSupported && this.onProgress) {
43460 this.onProgress({
43461 loaded: evt.loaded
43462 });
43463 }
43464 },
43465
43466 get isStreamingSupported() {
43467 return false; // TODO allow progressive range bytes loading
43468 },
43469
43470 read: function PDFNetworkStreamRangeRequestReader_read() {
43471 if (this._queuedChunk !== null) {
43472 var chunk = this._queuedChunk;
43473 this._queuedChunk = null;
43474 return Promise.resolve({value: chunk, done: false});
43475 }
43476 if (this._done) {
43477 return Promise.resolve({value: undefined, done: true});
43478 }
43479 var requestCapability = createPromiseCapability();
43480 this._requests.push(requestCapability);
43481 return requestCapability.promise;
43482 },
43483
43484 cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
43485 this._done = true;
43486 this._requests.forEach(function (requestCapability) {
43487 requestCapability.resolve({value: undefined, done: true});
43488 });
43489 this._requests = [];
43490 if (this._manager.isPendingRequest(this._requestId)) {
43491 this._manager.abortRequest(this._requestId);
43492 }
43493 this._close();
43494 }
43495 };
43496
43497 coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
43498
43499 exports.PDFNetworkStream = PDFNetworkStream;
43500 exports.NetworkManager = NetworkManager;
43501}));
43502 }).call(pdfjsLibs);
43503
43504 exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
43505}));
43506
diff --git a/dist/js/pdf.worker.min.js b/dist/js/pdf.worker.min.js
new file mode 100644
index 00000000..7ac3468a
--- /dev/null
+++ b/dist/js/pdf.worker.min.js
@@ -0,0 +1,28 @@
1(function(root,factory){"use strict";if(typeof define==="function"&&define.amd){define("pdfjs-dist/build/pdf.worker",["exports"],factory)}else if(typeof exports!=="undefined"){factory(exports)}else{factory(root.pdfjsDistBuildPdfWorker={})}})(this,function(exports){"use strict";var pdfjsVersion="1.6.210";var pdfjsBuild="4ce2356";var pdfjsFilePath=typeof document!=="undefined"&&document.currentScript?document.currentScript.src:null;var pdfjsLibs={};(function pdfjsWrapper(){(function(root,factory){{factory(root.pdfjsCoreArithmeticDecoder={})}})(this,function(exports){var ArithmeticDecoder=function ArithmeticDecoderClosure(){var QeTable=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];function ArithmeticDecoder(data,start,end){this.data=data;this.bp=start;this.dataEnd=end;this.chigh=data[start];this.clow=0;this.byteIn();this.chigh=this.chigh<<7&65535|this.clow>>9&127;this.clow=this.clow<<7&65535;this.ct-=7;this.a=32768}ArithmeticDecoder.prototype={byteIn:function ArithmeticDecoder_byteIn(){var data=this.data;var bp=this.bp;if(data[bp]===255){var b1=data[bp+1];if(b1>143){this.clow+=65280;this.ct=8}else{bp++;this.clow+=data[bp]<<9;this.ct=7;this.bp=bp}}else{bp++;this.clow+=bp<this.dataEnd?data[bp]<<8:65280;this.ct=8;this.bp=bp}if(this.clow>65535){this.chigh+=this.clow>>16;this.clow&=65535}},readBit:function ArithmeticDecoder_readBit(contexts,pos){var cx_index=contexts[pos]>>1,cx_mps=contexts[pos]&1;var qeTableIcx=QeTable[cx_index];var qeIcx=qeTableIcx.qe;var d;var a=this.a-qeIcx;if(this.chigh<qeIcx){if(a<qeIcx){a=qeIcx;d=cx_mps;cx_index=qeTableIcx.nmps}else{a=qeIcx;d=1^cx_mps;if(qeTableIcx.switchFlag===1){cx_mps=d}cx_index=qeTableIcx.nlps}}else{this.chigh-=qeIcx;if((a&32768)!==0){this.a=a;return cx_mps}if(a<qeIcx){d=1^cx_mps;if(qeTableIcx.switchFlag===1){cx_mps=d}cx_index=qeTableIcx.nlps}else{d=cx_mps;cx_index=qeTableIcx.nmps}}do{if(this.ct===0){this.byteIn()}a<<=1;this.chigh=this.chigh<<1&65535|this.clow>>15&1;this.clow=this.clow<<1&65535;this.ct--}while((a&32768)===0);this.a=a;contexts[pos]=cx_index<<1|cx_mps;return d}};return ArithmeticDecoder}();exports.ArithmeticDecoder=ArithmeticDecoder});(function(root,factory){{factory(root.pdfjsCoreBidi={})}})(this,function(exports){var 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","ON","CS","ON","CS","ON","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","ON","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","ON","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"];var arabicTypes=["AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","CS","AL","ON","ON","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","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","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","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL"];function isOdd(i){return(i&1)!==0}function isEven(i){return(i&1)===0}function findUnequal(arr,start,value){for(var j=start,jj=arr.length;j<jj;++j){if(arr[j]!==value){return j}}return j}function setValues(arr,start,end,value){for(var j=start;j<end;++j){arr[j]=value}}function reverseValues(arr,start,end){for(var i=start,j=end-1;i<j;++i,--j){var temp=arr[i];arr[i]=arr[j];arr[j]=temp}}function createBidiText(str,isLTR,vertical){return{str:str,dir:vertical?"ttb":isLTR?"ltr":"rtl"}}var chars=[];var types=[];function bidi(str,startLevel,vertical){var isLTR=true;var strLength=str.length;if(strLength===0||vertical){return createBidiText(str,isLTR,vertical)}chars.length=strLength;types.length=strLength;var numBidi=0;var i,ii;for(i=0;i<strLength;++i){chars[i]=str.charAt(i);var charCode=str.charCodeAt(i);var charType="L";if(charCode<=255){charType=baseTypes[charCode]}else if(1424<=charCode&&charCode<=1524){charType="R"}else if(1536<=charCode&&charCode<=1791){charType=arabicTypes[charCode&255]}else if(1792<=charCode&&charCode<=2220){charType="AL"}if(charType==="R"||charType==="AL"||charType==="AN"){numBidi++}types[i]=charType}if(numBidi===0){isLTR=true;return createBidiText(str,isLTR)}if(startLevel===-1){if(strLength/numBidi<.3){isLTR=true;startLevel=0}else{isLTR=false;startLevel=1}}var levels=[];for(i=0;i<strLength;++i){levels[i]=startLevel}var e=isOdd(startLevel)?"R":"L";var sor=e;var eor=sor;var lastType=sor;for(i=0;i<strLength;++i){if(types[i]==="NSM"){types[i]=lastType}else{lastType=types[i]}}lastType=sor;var t;for(i=0;i<strLength;++i){t=types[i];if(t==="EN"){types[i]=lastType==="AL"?"AN":"EN"}else if(t==="R"||t==="L"||t==="AL"){lastType=t}}for(i=0;i<strLength;++i){t=types[i];if(t==="AL"){types[i]="R"}}for(i=1;i<strLength-1;++i){if(types[i]==="ES"&&types[i-1]==="EN"&&types[i+1]==="EN"){types[i]="EN"}if(types[i]==="CS"&&(types[i-1]==="EN"||types[i-1]==="AN")&&types[i+1]===types[i-1]){types[i]=types[i-1]}}for(i=0;i<strLength;++i){if(types[i]==="EN"){var j;for(j=i-1;j>=0;--j){if(types[j]!=="ET"){break}types[j]="EN"}for(j=i+1;j<strLength;++j){if(types[j]!=="ET"){break}types[j]="EN"}}}for(i=0;i<strLength;++i){t=types[i];if(t==="WS"||t==="ES"||t==="ET"||t==="CS"){types[i]="ON"}}lastType=sor;for(i=0;i<strLength;++i){t=types[i];if(t==="EN"){types[i]=lastType==="L"?"L":"EN"}else if(t==="R"||t==="L"){lastType=t}}for(i=0;i<strLength;++i){if(types[i]==="ON"){var end=findUnequal(types,i+1,"ON");var before=sor;if(i>0){before=types[i-1]}var after=eor;if(end+1<strLength){after=types[end+1]}if(before!=="L"){before="R"}if(after!=="L"){after="R"}if(before===after){setValues(types,i,end,before)}i=end-1}}for(i=0;i<strLength;++i){if(types[i]==="ON"){types[i]=e}}for(i=0;i<strLength;++i){t=types[i];if(isEven(levels[i])){if(t==="R"){levels[i]+=1}else if(t==="AN"||t==="EN"){levels[i]+=2}}else{if(t==="L"||t==="AN"||t==="EN"){levels[i]+=1}}}var highestLevel=-1;var lowestOddLevel=99;var level;for(i=0,ii=levels.length;i<ii;++i){level=levels[i];if(highestLevel<level){highestLevel=level}if(lowestOddLevel>level&&isOdd(level)){lowestOddLevel=level}}for(level=highestLevel;level>=lowestOddLevel;--level){var start=-1;for(i=0,ii=levels.length;i<ii;++i){if(levels[i]<level){if(start>=0){reverseValues(chars,start,i);start=-1}}else if(start<0){start=i}}if(start>=0){reverseValues(chars,start,levels.length)}}for(i=0,ii=chars.length;i<ii;++i){var ch=chars[i];if(ch==="<"||ch===">"){chars[i]=""}}return createBidiText(chars.join(""),isLTR)}exports.bidi=bidi});(function(root,factory){{factory(root.pdfjsCoreCharsets={})}})(this,function(exports){var 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"];var 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"];var 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"];exports.ISOAdobeCharset=ISOAdobeCharset;exports.ExpertCharset=ExpertCharset;exports.ExpertSubsetCharset=ExpertSubsetCharset});(function(root,factory){{factory(root.pdfjsCoreEncodings={})}})(this,function(exports){var 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"];var 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"];var 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"];var 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"];var 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"];var 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"];var 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"];function getEncoding(encodingName){switch(encodingName){case"WinAnsiEncoding":return WinAnsiEncoding;case"StandardEncoding":return StandardEncoding;case"MacRomanEncoding":return MacRomanEncoding;case"SymbolSetEncoding":return SymbolSetEncoding;case"ZapfDingbatsEncoding":return ZapfDingbatsEncoding;case"ExpertEncoding":return ExpertEncoding;case"MacExpertEncoding":return MacExpertEncoding;default:return null}}exports.WinAnsiEncoding=WinAnsiEncoding;exports.StandardEncoding=StandardEncoding;exports.MacRomanEncoding=MacRomanEncoding;exports.SymbolSetEncoding=SymbolSetEncoding;exports.ZapfDingbatsEncoding=ZapfDingbatsEncoding;exports.ExpertEncoding=ExpertEncoding;exports.getEncoding=getEncoding});(function(root,factory){{factory(root.pdfjsSharedUtil={})}})(this,function(exports){var globalScope=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:this;var FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];var TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};var ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};var AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};var AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};var AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};
2var AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};var StreamType={UNKNOWN:0,FLATE:1,LZW:2,DCT:3,JPX:4,JBIG:5,A85:6,AHX:7,CCF:8,RL:9};var FontType={UNKNOWN:0,TYPE1:1,TYPE1C:2,CIDFONTTYPE0:3,CIDFONTTYPE0C:4,TRUETYPE:5,CIDFONTTYPE2:6,TYPE3:7,OPENTYPE:8,TYPE0:9,MMTYPE1:10};var VERBOSITY_LEVELS={errors:0,warnings:1,infos:5};var OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};var verbosity=VERBOSITY_LEVELS.warnings;function setVerbosityLevel(level){verbosity=level}function getVerbosityLevel(){return verbosity}function info(msg){if(verbosity>=VERBOSITY_LEVELS.infos){console.log("Info: "+msg)}}function warn(msg){if(verbosity>=VERBOSITY_LEVELS.warnings){console.log("Warning: "+msg)}}function deprecated(details){console.log("Deprecated API usage: "+details)}function error(msg){if(verbosity>=VERBOSITY_LEVELS.errors){console.log("Error: "+msg);console.log(backtrace())}throw new Error(msg)}function backtrace(){try{throw new Error}catch(e){return e.stack?e.stack.split("\n").slice(2).join("\n"):""}}function assert(cond,msg){if(!cond){error(msg)}}var UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",smask:"smask",shadingPattern:"shadingPattern",font:"font"};function isSameOrigin(baseUrl,otherUrl){try{var base=new URL(baseUrl);if(!base.origin||base.origin==="null"){return false}}catch(e){return false}var other=new URL(otherUrl,base);return base.origin===other.origin}function isValidUrl(url,allowRelative){if(!url||typeof url!=="string"){return false}var protocol=/^[a-z][a-z0-9+\-.]*(?=:)/i.exec(url);if(!protocol){return allowRelative}protocol=protocol[0].toLowerCase();switch(protocol){case"http":case"https":case"ftp":case"mailto":case"tel":return true;default:return false}}function shadow(obj,prop,value){Object.defineProperty(obj,prop,{value:value,enumerable:true,configurable:true,writable:false});return value}function getLookupTableFactory(initializer){var lookup;return function(){if(initializer){lookup=Object.create(null);initializer(lookup);initializer=null}return lookup}}var PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};var PasswordException=function PasswordExceptionClosure(){function PasswordException(msg,code){this.name="PasswordException";this.message=msg;this.code=code}PasswordException.prototype=new Error;PasswordException.constructor=PasswordException;return PasswordException}();var UnknownErrorException=function UnknownErrorExceptionClosure(){function UnknownErrorException(msg,details){this.name="UnknownErrorException";this.message=msg;this.details=details}UnknownErrorException.prototype=new Error;UnknownErrorException.constructor=UnknownErrorException;return UnknownErrorException}();var InvalidPDFException=function InvalidPDFExceptionClosure(){function InvalidPDFException(msg){this.name="InvalidPDFException";this.message=msg}InvalidPDFException.prototype=new Error;InvalidPDFException.constructor=InvalidPDFException;return InvalidPDFException}();var MissingPDFException=function MissingPDFExceptionClosure(){function MissingPDFException(msg){this.name="MissingPDFException";this.message=msg}MissingPDFException.prototype=new Error;MissingPDFException.constructor=MissingPDFException;return MissingPDFException}();var UnexpectedResponseException=function UnexpectedResponseExceptionClosure(){function UnexpectedResponseException(msg,status){this.name="UnexpectedResponseException";this.message=msg;this.status=status}UnexpectedResponseException.prototype=new Error;UnexpectedResponseException.constructor=UnexpectedResponseException;return UnexpectedResponseException}();var NotImplementedException=function NotImplementedExceptionClosure(){function NotImplementedException(msg){this.message=msg}NotImplementedException.prototype=new Error;NotImplementedException.prototype.name="NotImplementedException";NotImplementedException.constructor=NotImplementedException;return NotImplementedException}();var MissingDataException=function MissingDataExceptionClosure(){function MissingDataException(begin,end){this.begin=begin;this.end=end;this.message="Missing data ["+begin+", "+end+")"}MissingDataException.prototype=new Error;MissingDataException.prototype.name="MissingDataException";MissingDataException.constructor=MissingDataException;return MissingDataException}();var XRefParseException=function XRefParseExceptionClosure(){function XRefParseException(msg){this.message=msg}XRefParseException.prototype=new Error;XRefParseException.prototype.name="XRefParseException";XRefParseException.constructor=XRefParseException;return XRefParseException}();var NullCharactersRegExp=/\x00/g;function removeNullCharacters(str){if(typeof str!=="string"){warn("The argument for removeNullCharacters must be a string.");return str}return str.replace(NullCharactersRegExp,"")}function bytesToString(bytes){assert(bytes!==null&&typeof bytes==="object"&&bytes.length!==undefined,"Invalid argument for bytesToString");var length=bytes.length;var MAX_ARGUMENT_COUNT=8192;if(length<MAX_ARGUMENT_COUNT){return String.fromCharCode.apply(null,bytes)}var strBuf=[];for(var i=0;i<length;i+=MAX_ARGUMENT_COUNT){var chunkEnd=Math.min(i+MAX_ARGUMENT_COUNT,length);var chunk=bytes.subarray(i,chunkEnd);strBuf.push(String.fromCharCode.apply(null,chunk))}return strBuf.join("")}function stringToBytes(str){assert(typeof str==="string","Invalid argument for stringToBytes");var length=str.length;var bytes=new Uint8Array(length);for(var i=0;i<length;++i){bytes[i]=str.charCodeAt(i)&255}return bytes}function arrayByteLength(arr){if(arr.length!==undefined){return arr.length}assert(arr.byteLength!==undefined);return arr.byteLength}function arraysToBytes(arr){if(arr.length===1&&arr[0]instanceof Uint8Array){return arr[0]}var resultLength=0;var i,ii=arr.length;var item,itemLength;for(i=0;i<ii;i++){item=arr[i];itemLength=arrayByteLength(item);resultLength+=itemLength}var pos=0;var data=new Uint8Array(resultLength);for(i=0;i<ii;i++){item=arr[i];if(!(item instanceof Uint8Array)){if(typeof item==="string"){item=stringToBytes(item)}else{item=new Uint8Array(item)}}itemLength=item.byteLength;data.set(item,pos);pos+=itemLength}return data}function string32(value){return String.fromCharCode(value>>24&255,value>>16&255,value>>8&255,value&255)}function log2(x){var n=1,i=0;while(x>n){n<<=1;i++}return i}function readInt8(data,start){return data[start]<<24>>24}function readUint16(data,offset){return data[offset]<<8|data[offset+1]}function readUint32(data,offset){return(data[offset]<<24|data[offset+1]<<16|data[offset+2]<<8|data[offset+3])>>>0}function isLittleEndian(){var buffer8=new Uint8Array(2);buffer8[0]=1;var buffer16=new Uint16Array(buffer8.buffer);return buffer16[0]===1}function isEvalSupported(){try{new Function("");return true}catch(e){return false}}var Uint32ArrayView=function Uint32ArrayViewClosure(){function Uint32ArrayView(buffer,length){this.buffer=buffer;this.byteLength=buffer.length;this.length=length===undefined?this.byteLength>>2:length;ensureUint32ArrayViewProps(this.length)}Uint32ArrayView.prototype=Object.create(null);var uint32ArrayViewSetters=0;function createUint32ArrayProp(index){return{get:function(){var buffer=this.buffer,offset=index<<2;return(buffer[offset]|buffer[offset+1]<<8|buffer[offset+2]<<16|buffer[offset+3]<<24)>>>0},set:function(value){var buffer=this.buffer,offset=index<<2;buffer[offset]=value&255;buffer[offset+1]=value>>8&255;buffer[offset+2]=value>>16&255;buffer[offset+3]=value>>>24&255}}}function ensureUint32ArrayViewProps(length){while(uint32ArrayViewSetters<length){Object.defineProperty(Uint32ArrayView.prototype,uint32ArrayViewSetters,createUint32ArrayProp(uint32ArrayViewSetters));uint32ArrayViewSetters++}}return Uint32ArrayView}();exports.Uint32ArrayView=Uint32ArrayView;var IDENTITY_MATRIX=[1,0,0,1,0,0];var Util=function UtilClosure(){function Util(){}var rgbBuf=["rgb(",0,",",0,",",0,")"];Util.makeCssRgb=function Util_makeCssRgb(r,g,b){rgbBuf[1]=r;rgbBuf[3]=g;rgbBuf[5]=b;return rgbBuf.join("")};Util.transform=function Util_transform(m1,m2){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]]};Util.applyTransform=function Util_applyTransform(p,m){var xt=p[0]*m[0]+p[1]*m[2]+m[4];var yt=p[0]*m[1]+p[1]*m[3]+m[5];return[xt,yt]};Util.applyInverseTransform=function Util_applyInverseTransform(p,m){var d=m[0]*m[3]-m[1]*m[2];var xt=(p[0]*m[3]-p[1]*m[2]+m[2]*m[5]-m[4]*m[3])/d;var yt=(-p[0]*m[1]+p[1]*m[0]+m[4]*m[1]-m[5]*m[0])/d;return[xt,yt]};Util.getAxialAlignedBoundingBox=function Util_getAxialAlignedBoundingBox(r,m){var p1=Util.applyTransform(r,m);var p2=Util.applyTransform(r.slice(2,4),m);var p3=Util.applyTransform([r[0],r[3]],m);var p4=Util.applyTransform([r[2],r[1]],m);return[Math.min(p1[0],p2[0],p3[0],p4[0]),Math.min(p1[1],p2[1],p3[1],p4[1]),Math.max(p1[0],p2[0],p3[0],p4[0]),Math.max(p1[1],p2[1],p3[1],p4[1])]};Util.inverseTransform=function Util_inverseTransform(m){var d=m[0]*m[3]-m[1]*m[2];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]};Util.apply3dTransform=function Util_apply3dTransform(m,v){return[m[0]*v[0]+m[1]*v[1]+m[2]*v[2],m[3]*v[0]+m[4]*v[1]+m[5]*v[2],m[6]*v[0]+m[7]*v[1]+m[8]*v[2]]};Util.singularValueDecompose2dScale=function Util_singularValueDecompose2dScale(m){var transpose=[m[0],m[2],m[1],m[3]];var a=m[0]*transpose[0]+m[1]*transpose[2];var b=m[0]*transpose[1]+m[1]*transpose[3];var c=m[2]*transpose[0]+m[3]*transpose[2];var d=m[2]*transpose[1]+m[3]*transpose[3];var first=(a+d)/2;var second=Math.sqrt((a+d)*(a+d)-4*(a*d-c*b))/2;var sx=first+second||1;var sy=first-second||1;return[Math.sqrt(sx),Math.sqrt(sy)]};Util.normalizeRect=function Util_normalizeRect(rect){var r=rect.slice(0);if(rect[0]>rect[2]){r[0]=rect[2];r[2]=rect[0]}if(rect[1]>rect[3]){r[1]=rect[3];r[3]=rect[1]}return r};Util.intersect=function Util_intersect(rect1,rect2){function compare(a,b){return a-b}var orderedX=[rect1[0],rect1[2],rect2[0],rect2[2]].sort(compare),orderedY=[rect1[1],rect1[3],rect2[1],rect2[3]].sort(compare),result=[];rect1=Util.normalizeRect(rect1);rect2=Util.normalizeRect(rect2);if(orderedX[0]===rect1[0]&&orderedX[1]===rect2[0]||orderedX[0]===rect2[0]&&orderedX[1]===rect1[0]){result[0]=orderedX[1];result[2]=orderedX[2]}else{return false}if(orderedY[0]===rect1[1]&&orderedY[1]===rect2[1]||orderedY[0]===rect2[1]&&orderedY[1]===rect1[1]){result[1]=orderedY[1];result[3]=orderedY[2]}else{return false}return result};Util.sign=function Util_sign(num){return num<0?-1:1};var 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"];Util.toRoman=function Util_toRoman(number,lowerCase){assert(isInt(number)&&number>0,"The number should be a positive integer.");var pos,romanBuf=[];while(number>=1e3){number-=1e3;romanBuf.push("M")}pos=number/100|0;number%=100;romanBuf.push(ROMAN_NUMBER_MAP[pos]);pos=number/10|0;number%=10;romanBuf.push(ROMAN_NUMBER_MAP[10+pos]);romanBuf.push(ROMAN_NUMBER_MAP[20+number]);var romanStr=romanBuf.join("");return lowerCase?romanStr.toLowerCase():romanStr};Util.appendToArray=function Util_appendToArray(arr1,arr2){Array.prototype.push.apply(arr1,arr2)};Util.prependToArray=function Util_prependToArray(arr1,arr2){Array.prototype.unshift.apply(arr1,arr2)};Util.extendObj=function extendObj(obj1,obj2){for(var key in obj2){obj1[key]=obj2[key]}};Util.getInheritableProperty=function Util_getInheritableProperty(dict,name){while(dict&&!dict.has(name)){dict=dict.get("Parent")}if(!dict){return null}return dict.get(name)};Util.inherit=function Util_inherit(sub,base,prototype){sub.prototype=Object.create(base.prototype);sub.prototype.constructor=sub;for(var prop in prototype){sub.prototype[prop]=prototype[prop]}};Util.loadScript=function Util_loadScript(src,callback){var script=document.createElement("script");var loaded=false;script.setAttribute("src",src);if(callback){script.onload=function(){if(!loaded){callback()}loaded=true}}document.getElementsByTagName("head")[0].appendChild(script)};return Util}();var PageViewport=function PageViewportClosure(){function PageViewport(viewBox,scale,rotation,offsetX,offsetY,dontFlip){this.viewBox=viewBox;this.scale=scale;this.rotation=rotation;this.offsetX=offsetX;this.offsetY=offsetY;var centerX=(viewBox[2]+viewBox[0])/2;var centerY=(viewBox[3]+viewBox[1])/2;var rotateA,rotateB,rotateC,rotateD;rotation=rotation%360;rotation=rotation<0?rotation+360:rotation;switch(rotation){case 180:rotateA=-1;rotateB=0;rotateC=0;rotateD=1;break;case 90:rotateA=0;rotateB=1;rotateC=1;rotateD=0;break;case 270:rotateA=0;rotateB=-1;rotateC=-1;rotateD=0;break;default:rotateA=1;rotateB=0;rotateC=0;rotateD=-1;break}if(dontFlip){rotateC=-rotateC;rotateD=-rotateD}var offsetCanvasX,offsetCanvasY;var width,height;if(rotateA===0){offsetCanvasX=Math.abs(centerY-viewBox[1])*scale+offsetX;offsetCanvasY=Math.abs(centerX-viewBox[0])*scale+offsetY;width=Math.abs(viewBox[3]-viewBox[1])*scale;height=Math.abs(viewBox[2]-viewBox[0])*scale}else{offsetCanvasX=Math.abs(centerX-viewBox[0])*scale+offsetX;offsetCanvasY=Math.abs(centerY-viewBox[1])*scale+offsetY;width=Math.abs(viewBox[2]-viewBox[0])*scale;height=Math.abs(viewBox[3]-viewBox[1])*scale}this.transform=[rotateA*scale,rotateB*scale,rotateC*scale,rotateD*scale,offsetCanvasX-rotateA*scale*centerX-rotateC*scale*centerY,offsetCanvasY-rotateB*scale*centerX-rotateD*scale*centerY];this.width=width;this.height=height;this.fontScale=scale}PageViewport.prototype={clone:function PageViewPort_clone(args){args=args||{};var scale="scale"in args?args.scale:this.scale;var rotation="rotation"in args?args.rotation:this.rotation;return new PageViewport(this.viewBox.slice(),scale,rotation,this.offsetX,this.offsetY,args.dontFlip)},convertToViewportPoint:function PageViewport_convertToViewportPoint(x,y){return Util.applyTransform([x,y],this.transform)},convertToViewportRectangle:function PageViewport_convertToViewportRectangle(rect){var tl=Util.applyTransform([rect[0],rect[1]],this.transform);var br=Util.applyTransform([rect[2],rect[3]],this.transform);return[tl[0],tl[1],br[0],br[1]]},convertToPdfPoint:function PageViewport_convertToPdfPoint(x,y){return Util.applyInverseTransform([x,y],this.transform)}};return PageViewport}();var 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,728,711,710,729,733,731,730,732,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,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToPDFString(str){var i,n=str.length,strBuf=[];if(str[0]==="þ"&&str[1]==="ÿ"){for(i=2;i<n;i+=2){strBuf.push(String.fromCharCode(str.charCodeAt(i)<<8|str.charCodeAt(i+1)))}}else{for(i=0;i<n;++i){var code=PDFStringTranslateTable[str.charCodeAt(i)];strBuf.push(code?String.fromCharCode(code):str.charAt(i))}}return strBuf.join("")}function stringToUTF8String(str){return decodeURIComponent(escape(str))}function utf8StringToString(str){return unescape(encodeURIComponent(str))}function isEmptyObj(obj){for(var key in obj){return false}return true}function isBool(v){return typeof v==="boolean"}function isInt(v){return typeof v==="number"&&(v|0)===v}function isNum(v){return typeof v==="number"}function isString(v){return typeof v==="string"}function isArray(v){return v instanceof Array}function isArrayBuffer(v){return typeof v==="object"&&v!==null&&v.byteLength!==undefined}function isSpace(ch){return ch===32||ch===9||ch===13||ch===10}function createPromiseCapability(){var capability={};capability.promise=new Promise(function(resolve,reject){capability.resolve=resolve;capability.reject=reject});return capability}(function PromiseClosure(){if(globalScope.Promise){if(typeof globalScope.Promise.all!=="function"){globalScope.Promise.all=function(iterable){var count=0,results=[],resolve,reject;var promise=new globalScope.Promise(function(resolve_,reject_){resolve=resolve_;reject=reject_});iterable.forEach(function(p,i){count++;p.then(function(result){results[i]=result;count--;if(count===0){resolve(results)}},reject)});if(count===0){resolve(results)}return promise}}if(typeof globalScope.Promise.resolve!=="function"){globalScope.Promise.resolve=function(value){return new globalScope.Promise(function(resolve){resolve(value)})}}if(typeof globalScope.Promise.reject!=="function"){globalScope.Promise.reject=function(reason){return new globalScope.Promise(function(resolve,reject){reject(reason)})}}if(typeof globalScope.Promise.prototype.catch!=="function"){globalScope.Promise.prototype.catch=function(onReject){return globalScope.Promise.prototype.then(undefined,onReject)}}return}var STATUS_PENDING=0;var STATUS_RESOLVED=1;var STATUS_REJECTED=2;var REJECTION_TIMEOUT=500;var HandlerManager={handlers:[],running:false,unhandledRejections:[],pendingRejectionCheck:false,scheduleHandlers:function scheduleHandlers(promise){if(promise._status===STATUS_PENDING){return}this.handlers=this.handlers.concat(promise._handlers);promise._handlers=[];if(this.running){return}this.running=true;setTimeout(this.runHandlers.bind(this),0)},runHandlers:function runHandlers(){var RUN_TIMEOUT=1;var timeoutAt=Date.now()+RUN_TIMEOUT;while(this.handlers.length>0){var handler=this.handlers.shift();var nextStatus=handler.thisPromise._status;var nextValue=handler.thisPromise._value;try{if(nextStatus===STATUS_RESOLVED){if(typeof handler.onResolve==="function"){nextValue=handler.onResolve(nextValue)}}else if(typeof handler.onReject==="function"){nextValue=handler.onReject(nextValue);nextStatus=STATUS_RESOLVED;if(handler.thisPromise._unhandledRejection){this.removeUnhandeledRejection(handler.thisPromise)}}}catch(ex){nextStatus=STATUS_REJECTED;nextValue=ex}handler.nextPromise._updateStatus(nextStatus,nextValue);if(Date.now()>=timeoutAt){break}}if(this.handlers.length>0){setTimeout(this.runHandlers.bind(this),0);return}this.running=false},addUnhandledRejection:function addUnhandledRejection(promise){this.unhandledRejections.push({promise:promise,time:Date.now()});this.scheduleRejectionCheck()},removeUnhandeledRejection:function removeUnhandeledRejection(promise){promise._unhandledRejection=false;for(var i=0;i<this.unhandledRejections.length;i++){if(this.unhandledRejections[i].promise===promise){this.unhandledRejections.splice(i);i--}}},scheduleRejectionCheck:function scheduleRejectionCheck(){if(this.pendingRejectionCheck){return}this.pendingRejectionCheck=true;setTimeout(function rejectionCheck(){this.pendingRejectionCheck=false;var now=Date.now();for(var i=0;i<this.unhandledRejections.length;i++){if(now-this.unhandledRejections[i].time>REJECTION_TIMEOUT){var unhandled=this.unhandledRejections[i].promise._value;var msg="Unhandled rejection: "+unhandled;if(unhandled.stack){msg+="\n"+unhandled.stack}warn(msg);this.unhandledRejections.splice(i);i--}}if(this.unhandledRejections.length){this.scheduleRejectionCheck()}}.bind(this),REJECTION_TIMEOUT)}};function Promise(resolver){this._status=STATUS_PENDING;this._handlers=[];try{resolver.call(this,this._resolve.bind(this),this._reject.bind(this))}catch(e){this._reject(e)}}Promise.all=function Promise_all(promises){var resolveAll,rejectAll;var deferred=new Promise(function(resolve,reject){resolveAll=resolve;rejectAll=reject});var unresolved=promises.length;var results=[];if(unresolved===0){resolveAll(results);return deferred}function reject(reason){if(deferred._status===STATUS_REJECTED){return}results=[];rejectAll(reason)}for(var i=0,ii=promises.length;i<ii;++i){var promise=promises[i];var resolve=function(i){return function(value){if(deferred._status===STATUS_REJECTED){return}results[i]=value;unresolved--;if(unresolved===0){resolveAll(results)}}}(i);if(Promise.isPromise(promise)){promise.then(resolve,reject)}else{resolve(promise)}}return deferred};Promise.isPromise=function Promise_isPromise(value){return value&&typeof value.then==="function"};Promise.resolve=function Promise_resolve(value){return new Promise(function(resolve){resolve(value)})};Promise.reject=function Promise_reject(reason){return new Promise(function(resolve,reject){reject(reason)})};Promise.prototype={_status:null,_value:null,_handlers:null,_unhandledRejection:null,_updateStatus:function Promise__updateStatus(status,value){if(this._status===STATUS_RESOLVED||this._status===STATUS_REJECTED){return}if(status===STATUS_RESOLVED&&Promise.isPromise(value)){value.then(this._updateStatus.bind(this,STATUS_RESOLVED),this._updateStatus.bind(this,STATUS_REJECTED));return}this._status=status;this._value=value;if(status===STATUS_REJECTED&&this._handlers.length===0){this._unhandledRejection=true;HandlerManager.addUnhandledRejection(this)}HandlerManager.scheduleHandlers(this)},_resolve:function Promise_resolve(value){this._updateStatus(STATUS_RESOLVED,value)},_reject:function Promise_reject(reason){this._updateStatus(STATUS_REJECTED,reason)},then:function Promise_then(onResolve,onReject){var nextPromise=new Promise(function(resolve,reject){this.resolve=resolve;this.reject=reject});this._handlers.push({thisPromise:this,onResolve:onResolve,onReject:onReject,nextPromise:nextPromise});HandlerManager.scheduleHandlers(this);return nextPromise},"catch":function Promise_catch(onReject){return this.then(undefined,onReject)}};globalScope.Promise=Promise})();(function WeakMapClosure(){if(globalScope.WeakMap){return}var id=0;function WeakMap(){this.id="$weakmap"+id++}WeakMap.prototype={has:function(obj){return!!Object.getOwnPropertyDescriptor(obj,this.id)},get:function(obj,defaultValue){return this.has(obj)?obj[this.id]:defaultValue},set:function(obj,value){Object.defineProperty(obj,this.id,{value:value,enumerable:false,configurable:true})},"delete":function(obj){delete obj[this.id]}};globalScope.WeakMap=WeakMap})();var StatTimer=function StatTimerClosure(){function rpad(str,pad,length){while(str.length<length){str+=pad}return str}function StatTimer(){this.started=Object.create(null);this.times=[];this.enabled=true}StatTimer.prototype={time:function StatTimer_time(name){if(!this.enabled){return}if(name in this.started){warn("Timer is already running for "+name)}this.started[name]=Date.now()},timeEnd:function StatTimer_timeEnd(name){if(!this.enabled){return}if(!(name in this.started)){warn("Timer has not been started for "+name)}this.times.push({name:name,start:this.started[name],end:Date.now()});delete this.started[name]},toString:function StatTimer_toString(){var i,ii;var times=this.times;var out="";var longest=0;for(i=0,ii=times.length;i<ii;++i){var name=times[i]["name"];if(name.length>longest){longest=name.length}}for(i=0,ii=times.length;i<ii;++i){var span=times[i];var duration=span.end-span.start;out+=rpad(span["name"]," ",longest)+" "+duration+"ms\n"}return out}};return StatTimer}();var createBlob=function createBlob(data,contentType){if(typeof Blob!=="undefined"){return new Blob([data],{type:contentType})}warn('The "Blob" constructor is not supported.')};var createObjectURL=function createObjectURLClosure(){var digits="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(data,contentType,forceDataSchema){if(!forceDataSchema&&typeof URL!=="undefined"&&URL.createObjectURL){var blob=createBlob(data,contentType);return URL.createObjectURL(blob)}var buffer="data:"+contentType+";base64,";for(var i=0,ii=data.length;i<ii;i+=3){var b1=data[i]&255;var b2=data[i+1]&255;var b3=data[i+2]&255;var d1=b1>>2,d2=(b1&3)<<4|b2>>4;var d3=i+1<ii?(b2&15)<<2|b3>>6:64;var d4=i+2<ii?b3&63:64;buffer+=digits[d1]+digits[d2]+digits[d3]+digits[d4]}return buffer}}();function MessageHandler(sourceName,targetName,comObj){this.sourceName=sourceName;this.targetName=targetName;this.comObj=comObj;this.callbackIndex=1;this.postMessageTransfers=true;var callbacksCapabilities=this.callbacksCapabilities=Object.create(null);var ah=this.actionHandler=Object.create(null);this._onComObjOnMessage=function messageHandlerComObjOnMessage(event){var data=event.data;if(data.targetName!==this.sourceName){return}if(data.isReply){var callbackId=data.callbackId;if(data.callbackId in callbacksCapabilities){var callback=callbacksCapabilities[callbackId];delete callbacksCapabilities[callbackId];if("error"in data){callback.reject(data.error)}else{callback.resolve(data.data)}}else{error("Cannot resolve callback "+callbackId)}}else if(data.action in ah){var action=ah[data.action];if(data.callbackId){var sourceName=this.sourceName;var targetName=data.sourceName;Promise.resolve().then(function(){return action[0].call(action[1],data.data)}).then(function(result){comObj.postMessage({sourceName:sourceName,targetName:targetName,isReply:true,callbackId:data.callbackId,data:result})},function(reason){if(reason instanceof Error){reason=reason+""}comObj.postMessage({sourceName:sourceName,targetName:targetName,isReply:true,callbackId:data.callbackId,error:reason})})}else{action[0].call(action[1],data.data)}}else{error("Unknown action from worker: "+data.action)}}.bind(this);comObj.addEventListener("message",this._onComObjOnMessage)}MessageHandler.prototype={on:function messageHandlerOn(actionName,handler,scope){var ah=this.actionHandler;if(ah[actionName]){error('There is already an actionName called "'+actionName+'"')}ah[actionName]=[handler,scope]},send:function messageHandlerSend(actionName,data,transfers){var message={sourceName:this.sourceName,targetName:this.targetName,action:actionName,data:data};this.postMessage(message,transfers)},sendWithPromise:function messageHandlerSendWithPromise(actionName,data,transfers){var callbackId=this.callbackIndex++;var message={sourceName:this.sourceName,targetName:this.targetName,action:actionName,data:data,callbackId:callbackId};var capability=createPromiseCapability();this.callbacksCapabilities[callbackId]=capability;try{this.postMessage(message,transfers)}catch(e){capability.reject(e)}return capability.promise},postMessage:function(message,transfers){if(transfers&&this.postMessageTransfers){this.comObj.postMessage(message,transfers)}else{this.comObj.postMessage(message)}},destroy:function(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}};function loadJpegStream(id,imageUrl,objs){var img=new Image;img.onload=function loadJpegStream_onloadClosure(){objs.resolve(id,img)};img.onerror=function loadJpegStream_onerrorClosure(){objs.resolve(id,null);warn("Error during JPEG image loading")};img.src=imageUrl}(function checkURLConstructor(scope){var hasWorkingUrl=false;try{if(typeof URL==="function"&&typeof URL.prototype==="object"&&"origin"in URL.prototype){var u=new URL("b","http://a");u.pathname="c%20d";hasWorkingUrl=u.href==="http://a/c%20d"}}catch(e){}if(hasWorkingUrl){return}var relative=Object.create(null);relative["ftp"]=21;relative["file"]=0;relative["gopher"]=70;relative["http"]=80;relative["https"]=443;relative["ws"]=80;relative["wss"]=443;var relativePathDotMapping=Object.create(null);relativePathDotMapping["%2e"]=".";relativePathDotMapping[".%2e"]="..";relativePathDotMapping["%2e."]="..";relativePathDotMapping["%2e%2e"]="..";function isRelativeScheme(scheme){return relative[scheme]!==undefined}function invalid(){clear.call(this);this._isInvalid=true}function IDNAToASCII(h){if(""===h){invalid.call(this)}return h.toLowerCase()}function percentEscape(c){var unicode=c.charCodeAt(0);if(unicode>32&&unicode<127&&[34,35,60,62,63,96].indexOf(unicode)===-1){return c}return encodeURIComponent(c)}function percentEscapeQuery(c){var unicode=c.charCodeAt(0);if(unicode>32&&unicode<127&&[34,35,60,62,96].indexOf(unicode)===-1){return c}return encodeURIComponent(c)}var EOF,ALPHA=/[a-zA-Z]/,ALPHANUMERIC=/[a-zA-Z0-9\+\-\.]/;function parse(input,stateOverride,base){function err(message){errors.push(message)}var state=stateOverride||"scheme start",cursor=0,buffer="",seenAt=false,seenBracket=false,errors=[];loop:while((input[cursor-1]!==EOF||cursor===0)&&!this._isInvalid){var c=input[cursor];switch(state){case"scheme start":if(c&&ALPHA.test(c)){buffer+=c.toLowerCase();state="scheme"}else if(!stateOverride){buffer="";state="no scheme";continue}else{err("Invalid scheme.");break loop}break;case"scheme":if(c&&ALPHANUMERIC.test(c)){buffer+=c.toLowerCase()}else if(":"===c){this._scheme=buffer;buffer="";if(stateOverride){break loop}if(isRelativeScheme(this._scheme)){this._isRelative=true}if("file"===this._scheme){state="relative"}else if(this._isRelative&&base&&base._scheme===this._scheme){state="relative or authority"}else if(this._isRelative){state="authority first slash"}else{state="scheme data"}}else if(!stateOverride){buffer="";cursor=0;state="no scheme";continue}else if(EOF===c){break loop}else{err("Code point not allowed in scheme: "+c);break loop}break;case"scheme data":if("?"===c){this._query="?";state="query"}else if("#"===c){this._fragment="#";state="fragment"}else{if(EOF!==c&&" "!==c&&"\n"!==c&&"\r"!==c){this._schemeData+=percentEscape(c)}}break;case"no scheme":if(!base||!isRelativeScheme(base._scheme)){err("Missing scheme.");invalid.call(this)}else{state="relative";continue}break;case"relative or authority":if("/"===c&&"/"===input[cursor+1]){state="authority ignore slashes"}else{err("Expected /, got: "+c);state="relative";continue}break;case"relative":this._isRelative=true;if("file"!==this._scheme){this._scheme=base._scheme}if(EOF===c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query=base._query;this._username=base._username;this._password=base._password;break loop}else if("/"===c||"\\"===c){if("\\"===c){err("\\ is an invalid code point.")}state="relative slash"}else if("?"===c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query="?";this._username=base._username;this._password=base._password;state="query"}else if("#"===c){this._host=base._host;this._port=base._port;this._path=base._path.slice();this._query=base._query;this._fragment="#";this._username=base._username;this._password=base._password;state="fragment"}else{var nextC=input[cursor+1];var nextNextC=input[cursor+2];if("file"!==this._scheme||!ALPHA.test(c)||nextC!==":"&&nextC!=="|"||EOF!==nextNextC&&"/"!==nextNextC&&"\\"!==nextNextC&&"?"!==nextNextC&&"#"!==nextNextC){this._host=base._host;this._port=base._port;this._username=base._username;this._password=base._password;this._path=base._path.slice();this._path.pop()}state="relative path";continue}break;case"relative slash":if("/"===c||"\\"===c){if("\\"===c){err("\\ is an invalid code point.")
3}if("file"===this._scheme){state="file host"}else{state="authority ignore slashes"}}else{if("file"!==this._scheme){this._host=base._host;this._port=base._port;this._username=base._username;this._password=base._password}state="relative path";continue}break;case"authority first slash":if("/"===c){state="authority second slash"}else{err("Expected '/', got: "+c);state="authority ignore slashes";continue}break;case"authority second slash":state="authority ignore slashes";if("/"!==c){err("Expected '/', got: "+c);continue}break;case"authority ignore slashes":if("/"!==c&&"\\"!==c){state="authority";continue}else{err("Expected authority, got: "+c)}break;case"authority":if("@"===c){if(seenAt){err("@ already seen.");buffer+="%40"}seenAt=true;for(var i=0;i<buffer.length;i++){var cp=buffer[i];if(" "===cp||"\n"===cp||"\r"===cp){err("Invalid whitespace in authority.");continue}if(":"===cp&&null===this._password){this._password="";continue}var tempC=percentEscape(cp);if(null!==this._password){this._password+=tempC}else{this._username+=tempC}}buffer=""}else if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c){cursor-=buffer.length;buffer="";state="host";continue}else{buffer+=c}break;case"file host":if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c){if(buffer.length===2&&ALPHA.test(buffer[0])&&(buffer[1]===":"||buffer[1]==="|")){state="relative path"}else if(buffer.length===0){state="relative path start"}else{this._host=IDNAToASCII.call(this,buffer);buffer="";state="relative path start"}continue}else if(" "===c||"\n"===c||"\r"===c){err("Invalid whitespace in file host.")}else{buffer+=c}break;case"host":case"hostname":if(":"===c&&!seenBracket){this._host=IDNAToASCII.call(this,buffer);buffer="";state="port";if("hostname"===stateOverride){break loop}}else if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c){this._host=IDNAToASCII.call(this,buffer);buffer="";state="relative path start";if(stateOverride){break loop}continue}else if(" "!==c&&"\n"!==c&&"\r"!==c){if("["===c){seenBracket=true}else if("]"===c){seenBracket=false}buffer+=c}else{err("Invalid code point in host/hostname: "+c)}break;case"port":if(/[0-9]/.test(c)){buffer+=c}else if(EOF===c||"/"===c||"\\"===c||"?"===c||"#"===c||stateOverride){if(""!==buffer){var temp=parseInt(buffer,10);if(temp!==relative[this._scheme]){this._port=temp+""}buffer=""}if(stateOverride){break loop}state="relative path start";continue}else if(" "===c||"\n"===c||"\r"===c){err("Invalid code point in port: "+c)}else{invalid.call(this)}break;case"relative path start":if("\\"===c){err("'\\' not allowed in path.")}state="relative path";if("/"!==c&&"\\"!==c){continue}break;case"relative path":if(EOF===c||"/"===c||"\\"===c||!stateOverride&&("?"===c||"#"===c)){if("\\"===c){err("\\ not allowed in relative path.")}var tmp;if(tmp=relativePathDotMapping[buffer.toLowerCase()]){buffer=tmp}if(".."===buffer){this._path.pop();if("/"!==c&&"\\"!==c){this._path.push("")}}else if("."===buffer&&"/"!==c&&"\\"!==c){this._path.push("")}else if("."!==buffer){if("file"===this._scheme&&this._path.length===0&&buffer.length===2&&ALPHA.test(buffer[0])&&buffer[1]==="|"){buffer=buffer[0]+":"}this._path.push(buffer)}buffer="";if("?"===c){this._query="?";state="query"}else if("#"===c){this._fragment="#";state="fragment"}}else if(" "!==c&&"\n"!==c&&"\r"!==c){buffer+=percentEscape(c)}break;case"query":if(!stateOverride&&"#"===c){this._fragment="#";state="fragment"}else if(EOF!==c&&" "!==c&&"\n"!==c&&"\r"!==c){this._query+=percentEscapeQuery(c)}break;case"fragment":if(EOF!==c&&" "!==c&&"\n"!==c&&"\r"!==c){this._fragment+=c}break}cursor++}}function clear(){this._scheme="";this._schemeData="";this._username="";this._password=null;this._host="";this._port="";this._path=[];this._query="";this._fragment="";this._isInvalid=false;this._isRelative=false}function JURL(url,base){if(base!==undefined&&!(base instanceof JURL)){base=new JURL(String(base))}this._url=url;clear.call(this);var input=url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,"");parse.call(this,input,null,base)}JURL.prototype={toString:function(){return this.href},get href(){if(this._isInvalid){return this._url}var authority="";if(""!==this._username||null!==this._password){authority=this._username+(null!==this._password?":"+this._password:"")+"@"}return this.protocol+(this._isRelative?"//"+authority+this.host:"")+this.pathname+this._query+this._fragment},set href(href){clear.call(this);parse.call(this,href)},get protocol(){return this._scheme+":"},set protocol(protocol){if(this._isInvalid){return}parse.call(this,protocol+":","scheme start")},get host(){return this._isInvalid?"":this._port?this._host+":"+this._port:this._host},set host(host){if(this._isInvalid||!this._isRelative){return}parse.call(this,host,"host")},get hostname(){return this._host},set hostname(hostname){if(this._isInvalid||!this._isRelative){return}parse.call(this,hostname,"hostname")},get port(){return this._port},set port(port){if(this._isInvalid||!this._isRelative){return}parse.call(this,port,"port")},get pathname(){return this._isInvalid?"":this._isRelative?"/"+this._path.join("/"):this._schemeData},set pathname(pathname){if(this._isInvalid||!this._isRelative){return}this._path=[];parse.call(this,pathname,"relative path start")},get search(){return this._isInvalid||!this._query||"?"===this._query?"":this._query},set search(search){if(this._isInvalid||!this._isRelative){return}this._query="?";if("?"===search[0]){search=search.slice(1)}parse.call(this,search,"query")},get hash(){return this._isInvalid||!this._fragment||"#"===this._fragment?"":this._fragment},set hash(hash){if(this._isInvalid){return}this._fragment="#";if("#"===hash[0]){hash=hash.slice(1)}parse.call(this,hash,"fragment")},get origin(){var host;if(this._isInvalid||!this._scheme){return""}switch(this._scheme){case"data":case"file":case"javascript":case"mailto":return"null"}host=this.host;if(!host){return""}return this._scheme+"://"+host}};var OriginalURL=scope.URL;if(OriginalURL){JURL.createObjectURL=function(blob){return OriginalURL.createObjectURL.apply(OriginalURL,arguments)};JURL.revokeObjectURL=function(url){OriginalURL.revokeObjectURL(url)}}scope.URL=JURL})(globalScope);exports.FONT_IDENTITY_MATRIX=FONT_IDENTITY_MATRIX;exports.IDENTITY_MATRIX=IDENTITY_MATRIX;exports.OPS=OPS;exports.VERBOSITY_LEVELS=VERBOSITY_LEVELS;exports.UNSUPPORTED_FEATURES=UNSUPPORTED_FEATURES;exports.AnnotationBorderStyleType=AnnotationBorderStyleType;exports.AnnotationFieldFlag=AnnotationFieldFlag;exports.AnnotationFlag=AnnotationFlag;exports.AnnotationType=AnnotationType;exports.FontType=FontType;exports.ImageKind=ImageKind;exports.InvalidPDFException=InvalidPDFException;exports.MessageHandler=MessageHandler;exports.MissingDataException=MissingDataException;exports.MissingPDFException=MissingPDFException;exports.NotImplementedException=NotImplementedException;exports.PageViewport=PageViewport;exports.PasswordException=PasswordException;exports.PasswordResponses=PasswordResponses;exports.StatTimer=StatTimer;exports.StreamType=StreamType;exports.TextRenderingMode=TextRenderingMode;exports.UnexpectedResponseException=UnexpectedResponseException;exports.UnknownErrorException=UnknownErrorException;exports.Util=Util;exports.XRefParseException=XRefParseException;exports.arrayByteLength=arrayByteLength;exports.arraysToBytes=arraysToBytes;exports.assert=assert;exports.bytesToString=bytesToString;exports.createBlob=createBlob;exports.createPromiseCapability=createPromiseCapability;exports.createObjectURL=createObjectURL;exports.deprecated=deprecated;exports.error=error;exports.getLookupTableFactory=getLookupTableFactory;exports.getVerbosityLevel=getVerbosityLevel;exports.globalScope=globalScope;exports.info=info;exports.isArray=isArray;exports.isArrayBuffer=isArrayBuffer;exports.isBool=isBool;exports.isEmptyObj=isEmptyObj;exports.isInt=isInt;exports.isNum=isNum;exports.isString=isString;exports.isSpace=isSpace;exports.isSameOrigin=isSameOrigin;exports.isValidUrl=isValidUrl;exports.isLittleEndian=isLittleEndian;exports.isEvalSupported=isEvalSupported;exports.loadJpegStream=loadJpegStream;exports.log2=log2;exports.readInt8=readInt8;exports.readUint16=readUint16;exports.readUint32=readUint32;exports.removeNullCharacters=removeNullCharacters;exports.setVerbosityLevel=setVerbosityLevel;exports.shadow=shadow;exports.string32=string32;exports.stringToBytes=stringToBytes;exports.stringToPDFString=stringToPDFString;exports.stringToUTF8String=stringToUTF8String;exports.utf8StringToString=utf8StringToString;exports.warn=warn});(function(root,factory){{factory(root.pdfjsCoreCFFParser={},root.pdfjsSharedUtil,root.pdfjsCoreCharsets,root.pdfjsCoreEncodings)}})(this,function(exports,sharedUtil,coreCharsets,coreEncodings){var error=sharedUtil.error;var info=sharedUtil.info;var bytesToString=sharedUtil.bytesToString;var warn=sharedUtil.warn;var isArray=sharedUtil.isArray;var Util=sharedUtil.Util;var stringToBytes=sharedUtil.stringToBytes;var assert=sharedUtil.assert;var ISOAdobeCharset=coreCharsets.ISOAdobeCharset;var ExpertCharset=coreCharsets.ExpertCharset;var ExpertSubsetCharset=coreCharsets.ExpertSubsetCharset;var StandardEncoding=coreEncodings.StandardEncoding;var ExpertEncoding=coreEncodings.ExpertEncoding;var MAX_SUBR_NESTING=10;var 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"];var CFFParser=function CFFParserClosure(){var CharstringValidationData=[null,{id:"hstem",min:2,stackClearing:true,stem:true},null,{id:"vstem",min:2,stackClearing:true,stem:true},{id:"vmoveto",min:1,stackClearing:true},{id:"rlineto",min:2,resetStack:true},{id:"hlineto",min:1,resetStack:true},{id:"vlineto",min:1,resetStack:true},{id:"rrcurveto",min:6,resetStack:true},null,{id:"callsubr",min:1,undefStack:true},{id:"return",min:0,undefStack:true},null,null,{id:"endchar",min:0,stackClearing:true},null,null,null,{id:"hstemhm",min:2,stackClearing:true,stem:true},{id:"hintmask",min:0,stackClearing:true},{id:"cntrmask",min:0,stackClearing:true},{id:"rmoveto",min:2,stackClearing:true},{id:"hmoveto",min:1,stackClearing:true},{id:"vstemhm",min:2,stackClearing:true,stem:true},{id:"rcurveline",min:8,resetStack:true},{id:"rlinecurve",min:8,resetStack:true},{id:"vvcurveto",min:4,resetStack:true},{id:"hhcurveto",min:4,resetStack:true},null,{id:"callgsubr",min:1,undefStack:true},{id:"vhcurveto",min:4,resetStack:true},{id:"hvcurveto",min:4,resetStack:true}];var CharstringValidationData12=[null,null,null,{id:"and",min:2,stackDelta:-1},{id:"or",min:2,stackDelta:-1},{id:"not",min:1,stackDelta:0},null,null,null,{id:"abs",min:1,stackDelta:0},{id:"add",min:2,stackDelta:-1,stackFn:function stack_div(stack,index){stack[index-2]=stack[index-2]+stack[index-1]}},{id:"sub",min:2,stackDelta:-1,stackFn:function stack_div(stack,index){stack[index-2]=stack[index-2]-stack[index-1]}},{id:"div",min:2,stackDelta:-1,stackFn:function stack_div(stack,index){stack[index-2]=stack[index-2]/stack[index-1]}},null,{id:"neg",min:1,stackDelta:0,stackFn:function stack_div(stack,index){stack[index-1]=-stack[index-1]}},{id:"eq",min:2,stackDelta:-1},null,null,{id:"drop",min:1,stackDelta:-1},null,{id:"put",min:2,stackDelta:-2},{id:"get",min:1,stackDelta:0},{id:"ifelse",min:4,stackDelta:-3},{id:"random",min:0,stackDelta:1},{id:"mul",min:2,stackDelta:-1,stackFn:function stack_div(stack,index){stack[index-2]=stack[index-2]*stack[index-1]}},null,{id:"sqrt",min:1,stackDelta:0},{id:"dup",min:1,stackDelta:1},{id:"exch",min:2,stackDelta:0},{id:"index",min:2,stackDelta:0},{id:"roll",min:3,stackDelta:-2},null,null,null,{id:"hflex",min:7,resetStack:true},{id:"flex",min:13,resetStack:true},{id:"hflex1",min:9,resetStack:true},{id:"flex1",min:11,resetStack:true}];function CFFParser(file,properties,seacAnalysisEnabled){this.bytes=file.getBytes();this.properties=properties;this.seacAnalysisEnabled=!!seacAnalysisEnabled}CFFParser.prototype={parse:function CFFParser_parse(){var properties=this.properties;var cff=new CFF;this.cff=cff;var header=this.parseHeader();var nameIndex=this.parseIndex(header.endPos);var topDictIndex=this.parseIndex(nameIndex.endPos);var stringIndex=this.parseIndex(topDictIndex.endPos);var globalSubrIndex=this.parseIndex(stringIndex.endPos);var topDictParsed=this.parseDict(topDictIndex.obj.get(0));var topDict=this.createDict(CFFTopDict,topDictParsed,cff.strings);cff.header=header.obj;cff.names=this.parseNameIndex(nameIndex.obj);cff.strings=this.parseStringIndex(stringIndex.obj);cff.topDict=topDict;cff.globalSubrIndex=globalSubrIndex.obj;this.parsePrivateDict(cff.topDict);cff.isCIDFont=topDict.hasName("ROS");var charStringOffset=topDict.getByName("CharStrings");var charStringIndex=this.parseIndex(charStringOffset).obj;var fontMatrix=topDict.getByName("FontMatrix");if(fontMatrix){properties.fontMatrix=fontMatrix}var fontBBox=topDict.getByName("FontBBox");if(fontBBox){properties.ascent=fontBBox[3];properties.descent=fontBBox[1];properties.ascentScaled=true}var charset,encoding;if(cff.isCIDFont){var fdArrayIndex=this.parseIndex(topDict.getByName("FDArray")).obj;for(var i=0,ii=fdArrayIndex.count;i<ii;++i){var dictRaw=fdArrayIndex.get(i);var fontDict=this.createDict(CFFTopDict,this.parseDict(dictRaw),cff.strings);this.parsePrivateDict(fontDict);cff.fdArray.push(fontDict)}encoding=null;charset=this.parseCharsets(topDict.getByName("charset"),charStringIndex.count,cff.strings,true);cff.fdSelect=this.parseFDSelect(topDict.getByName("FDSelect"),charStringIndex.count)}else{charset=this.parseCharsets(topDict.getByName("charset"),charStringIndex.count,cff.strings,false);encoding=this.parseEncoding(topDict.getByName("Encoding"),properties,cff.strings,charset.charset)}cff.charset=charset;cff.encoding=encoding;var charStringsAndSeacs=this.parseCharStrings(charStringIndex,topDict.privateDict.subrsIndex,globalSubrIndex.obj,cff.fdSelect,cff.fdArray);cff.charStrings=charStringsAndSeacs.charStrings;cff.seacs=charStringsAndSeacs.seacs;cff.widths=charStringsAndSeacs.widths;return cff},parseHeader:function CFFParser_parseHeader(){var bytes=this.bytes;var bytesLength=bytes.length;var offset=0;while(offset<bytesLength&&bytes[offset]!==1){++offset}if(offset>=bytesLength){error("Invalid CFF header")}else if(offset!==0){info("cff data is shifted");bytes=bytes.subarray(offset);this.bytes=bytes}var major=bytes[0];var minor=bytes[1];var hdrSize=bytes[2];var offSize=bytes[3];var header=new CFFHeader(major,minor,hdrSize,offSize);return{obj:header,endPos:hdrSize}},parseDict:function CFFParser_parseDict(dict){var pos=0;function parseOperand(){var value=dict[pos++];if(value===30){return parseFloatOperand()}else if(value===28){value=dict[pos++];value=(value<<24|dict[pos++]<<16)>>16;return value}else if(value===29){value=dict[pos++];value=value<<8|dict[pos++];value=value<<8|dict[pos++];value=value<<8|dict[pos++];return value}else if(value>=32&&value<=246){return value-139}else if(value>=247&&value<=250){return(value-247)*256+dict[pos++]+108}else if(value>=251&&value<=254){return-((value-251)*256)-dict[pos++]-108}else{error("255 is not a valid DICT command")}return-1}function parseFloatOperand(){var str="";var eof=15;var lookup=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];var length=dict.length;while(pos<length){var b=dict[pos++];var b1=b>>4;var b2=b&15;if(b1===eof){break}str+=lookup[b1];if(b2===eof){break}str+=lookup[b2]}return parseFloat(str)}var operands=[];var entries=[];pos=0;var end=dict.length;while(pos<end){var b=dict[pos];if(b<=21){if(b===12){b=b<<8|dict[++pos]}entries.push([b,operands]);operands=[];++pos}else{operands.push(parseOperand())}}return entries},parseIndex:function CFFParser_parseIndex(pos){var cffIndex=new CFFIndex;var bytes=this.bytes;var count=bytes[pos++]<<8|bytes[pos++];var offsets=[];var end=pos;var i,ii;if(count!==0){var offsetSize=bytes[pos++];var startPos=pos+(count+1)*offsetSize-1;for(i=0,ii=count+1;i<ii;++i){var offset=0;for(var j=0;j<offsetSize;++j){offset<<=8;offset+=bytes[pos++]}offsets.push(startPos+offset)}end=offsets[count]}for(i=0,ii=offsets.length-1;i<ii;++i){var offsetStart=offsets[i];var offsetEnd=offsets[i+1];cffIndex.add(bytes.subarray(offsetStart,offsetEnd))}return{obj:cffIndex,endPos:end}},parseNameIndex:function CFFParser_parseNameIndex(index){var names=[];for(var i=0,ii=index.count;i<ii;++i){var name=index.get(i);var length=Math.min(name.length,127);var data=[];for(var j=0;j<length;++j){var c=name[j];if(j===0&&c===0){data[j]=c;continue}if(c<33||c>126||c===91||c===93||c===40||c===41||c===123||c===125||c===60||c===62||c===47||c===37||c===35){data[j]=95;continue}data[j]=c}names.push(bytesToString(data))}return names},parseStringIndex:function CFFParser_parseStringIndex(index){var strings=new CFFStrings;for(var i=0,ii=index.count;i<ii;++i){var data=index.get(i);strings.add(bytesToString(data))}return strings},createDict:function CFFParser_createDict(Type,dict,strings){var cffDict=new Type(strings);for(var i=0,ii=dict.length;i<ii;++i){var pair=dict[i];var key=pair[0];var value=pair[1];cffDict.setByKey(key,value)}return cffDict},parseCharString:function CFFParser_parseCharString(state,data,localSubrIndex,globalSubrIndex){if(state.callDepth>MAX_SUBR_NESTING){return false}var stackSize=state.stackSize;var stack=state.stack;var length=data.length;for(var j=0;j<length;){var value=data[j++];var validationCommand=null;if(value===12){var q=data[j++];if(q===0){data[j-2]=139;data[j-1]=22;stackSize=0}else{validationCommand=CharstringValidationData12[q]}}else if(value===28){stack[stackSize]=(data[j]<<24|data[j+1]<<16)>>16;j+=2;stackSize++}else if(value===14){if(stackSize>=4){stackSize-=4;if(this.seacAnalysisEnabled){state.seac=stack.slice(stackSize,stackSize+4);return false}}validationCommand=CharstringValidationData[value]}else if(value>=32&&value<=246){stack[stackSize]=value-139;stackSize++}else if(value>=247&&value<=254){stack[stackSize]=value<251?(value-247<<8)+data[j]+108:-(value-251<<8)-data[j]-108;j++;stackSize++}else if(value===255){stack[stackSize]=(data[j]<<24|data[j+1]<<16|data[j+2]<<8|data[j+3])/65536;j+=4;stackSize++}else if(value===19||value===20){state.hints+=stackSize>>1;j+=state.hints+7>>3;stackSize%=2;validationCommand=CharstringValidationData[value]}else if(value===10||value===29){var subrsIndex;if(value===10){subrsIndex=localSubrIndex}else{subrsIndex=globalSubrIndex}if(!subrsIndex){validationCommand=CharstringValidationData[value];warn("Missing subrsIndex for "+validationCommand.id);return false}var bias=32768;if(subrsIndex.count<1240){bias=107}else if(subrsIndex.count<33900){bias=1131}var subrNumber=stack[--stackSize]+bias;if(subrNumber<0||subrNumber>=subrsIndex.count){validationCommand=CharstringValidationData[value];warn("Out of bounds subrIndex for "+validationCommand.id);return false}state.stackSize=stackSize;state.callDepth++;var valid=this.parseCharString(state,subrsIndex.get(subrNumber),localSubrIndex,globalSubrIndex);if(!valid){return false}state.callDepth--;stackSize=state.stackSize;continue}else if(value===11){state.stackSize=stackSize;return true}else{validationCommand=CharstringValidationData[value]}if(validationCommand){if(validationCommand.stem){state.hints+=stackSize>>1}if("min"in validationCommand){if(!state.undefStack&&stackSize<validationCommand.min){warn("Not enough parameters for "+validationCommand.id+"; actual: "+stackSize+", expected: "+validationCommand.min);return false}}if(state.firstStackClearing&&validationCommand.stackClearing){state.firstStackClearing=false;stackSize-=validationCommand.min;if(stackSize>=2&&validationCommand.stem){stackSize%=2}else if(stackSize>1){warn("Found too many parameters for stack-clearing command")}if(stackSize>0&&stack[stackSize-1]>=0){state.width=stack[stackSize-1]}}if("stackDelta"in validationCommand){if("stackFn"in validationCommand){validationCommand.stackFn(stack,stackSize)}stackSize+=validationCommand.stackDelta}else if(validationCommand.stackClearing){stackSize=0}else if(validationCommand.resetStack){stackSize=0;state.undefStack=false}else if(validationCommand.undefStack){stackSize=0;state.undefStack=true;state.firstStackClearing=false}}}state.stackSize=stackSize;return true},parseCharStrings:function CFFParser_parseCharStrings(charStrings,localSubrIndex,globalSubrIndex,fdSelect,fdArray){var seacs=[];var widths=[];var count=charStrings.count;for(var i=0;i<count;i++){var charstring=charStrings.get(i);var state={callDepth:0,stackSize:0,stack:[],undefStack:true,hints:0,firstStackClearing:true,seac:null,width:null};var valid=true;var localSubrToUse=null;if(fdSelect&&fdArray.length){var fdIndex=fdSelect.getFDIndex(i);if(fdIndex===-1){warn("Glyph index is not in fd select.");valid=false}if(fdIndex>=fdArray.length){warn("Invalid fd index for glyph index.");valid=false}if(valid){localSubrToUse=fdArray[fdIndex].privateDict.subrsIndex}}else if(localSubrIndex){localSubrToUse=localSubrIndex}if(valid){valid=this.parseCharString(state,charstring,localSubrToUse,globalSubrIndex)}if(state.width!==null){widths[i]=state.width}if(state.seac!==null){seacs[i]=state.seac}if(!valid){charStrings.set(i,new Uint8Array([14]))}}return{charStrings:charStrings,seacs:seacs,widths:widths}},emptyPrivateDictionary:function CFFParser_emptyPrivateDictionary(parentDict){var privateDict=this.createDict(CFFPrivateDict,[],parentDict.strings);parentDict.setByKey(18,[0,0]);parentDict.privateDict=privateDict},parsePrivateDict:function CFFParser_parsePrivateDict(parentDict){if(!parentDict.hasName("Private")){this.emptyPrivateDictionary(parentDict);return}var privateOffset=parentDict.getByName("Private");if(!isArray(privateOffset)||privateOffset.length!==2){parentDict.removeByName("Private");return}var size=privateOffset[0];var offset=privateOffset[1];if(size===0||offset>=this.bytes.length){this.emptyPrivateDictionary(parentDict);return}var privateDictEnd=offset+size;var dictData=this.bytes.subarray(offset,privateDictEnd);var dict=this.parseDict(dictData);var privateDict=this.createDict(CFFPrivateDict,dict,parentDict.strings);parentDict.privateDict=privateDict;if(!privateDict.getByName("Subrs")){return}var subrsOffset=privateDict.getByName("Subrs");var relativeOffset=offset+subrsOffset;if(subrsOffset===0||relativeOffset>=this.bytes.length){this.emptyPrivateDictionary(parentDict);return}var subrsIndex=this.parseIndex(relativeOffset);privateDict.subrsIndex=subrsIndex.obj},parseCharsets:function CFFParser_parseCharsets(pos,length,strings,cid){if(pos===0){return new CFFCharset(true,CFFCharsetPredefinedTypes.ISO_ADOBE,ISOAdobeCharset)}else if(pos===1){return new CFFCharset(true,CFFCharsetPredefinedTypes.EXPERT,ExpertCharset)}else if(pos===2){return new CFFCharset(true,CFFCharsetPredefinedTypes.EXPERT_SUBSET,ExpertSubsetCharset)}var bytes=this.bytes;var start=pos;var format=bytes[pos++];var charset=[".notdef"];var id,count,i;length-=1;switch(format){case 0:for(i=0;i<length;i++){id=bytes[pos++]<<8|bytes[pos++];charset.push(cid?id:strings.get(id))}break;case 1:while(charset.length<=length){id=bytes[pos++]<<8|bytes[pos++];count=bytes[pos++];for(i=0;i<=count;i++){charset.push(cid?id++:strings.get(id++))}}break;case 2:while(charset.length<=length){id=bytes[pos++]<<8|bytes[pos++];count=bytes[pos++]<<8|bytes[pos++];for(i=0;i<=count;i++){charset.push(cid?id++:strings.get(id++))}}break;default:error("Unknown charset format")}var end=pos;var raw=bytes.subarray(start,end);return new CFFCharset(false,format,charset,raw)},parseEncoding:function CFFParser_parseEncoding(pos,properties,strings,charset){var encoding=Object.create(null);var bytes=this.bytes;var predefined=false;var hasSupplement=false;var format,i,ii;var raw=null;function readSupplement(){var supplementsCount=bytes[pos++];for(i=0;i<supplementsCount;i++){var code=bytes[pos++];var sid=(bytes[pos++]<<8)+(bytes[pos++]&255);encoding[code]=charset.indexOf(strings.get(sid))}}if(pos===0||pos===1){predefined=true;format=pos;var baseEncoding=pos?ExpertEncoding:StandardEncoding;for(i=0,ii=charset.length;i<ii;i++){var index=baseEncoding.indexOf(charset[i]);if(index!==-1){encoding[index]=i}}}else{var dataStart=pos;format=bytes[pos++];switch(format&127){case 0:var glyphsCount=bytes[pos++];for(i=1;i<=glyphsCount;i++){encoding[bytes[pos++]]=i}break;case 1:var rangesCount=bytes[pos++];var gid=1;for(i=0;i<rangesCount;i++){var start=bytes[pos++];var left=bytes[pos++];for(var j=start;j<=start+left;j++){encoding[j]=gid++}}break;default:error("Unknown encoding format: "+format+" in CFF");break}var dataEnd=pos;if(format&128){bytes[dataStart]&=127;readSupplement();hasSupplement=true}raw=bytes.subarray(dataStart,dataEnd)}format=format&127;return new CFFEncoding(predefined,format,encoding,raw)},parseFDSelect:function CFFParser_parseFDSelect(pos,length){var start=pos;var bytes=this.bytes;var format=bytes[pos++];var fdSelect=[],rawBytes;var i,invalidFirstGID=false;switch(format){case 0:for(i=0;i<length;++i){var id=bytes[pos++];fdSelect.push(id)}rawBytes=bytes.subarray(start,pos);break;case 3:var rangesCount=bytes[pos++]<<8|bytes[pos++];for(i=0;i<rangesCount;++i){var first=bytes[pos++]<<8|bytes[pos++];if(i===0&&first!==0){warn("parseFDSelect: The first range must have a first GID of 0"+" -- trying to recover.");invalidFirstGID=true;first=0}var fdIndex=bytes[pos++];var next=bytes[pos]<<8|bytes[pos+1];for(var j=first;j<next;++j){fdSelect.push(fdIndex)}}pos+=2;rawBytes=bytes.subarray(start,pos);if(invalidFirstGID){rawBytes[3]=rawBytes[4]=0}break;default:error('parseFDSelect: Unknown format "'+format+'".');break}assert(fdSelect.length===length,"parseFDSelect: Invalid font data.");return new CFFFDSelect(fdSelect,rawBytes)}};return CFFParser}();var CFF=function CFFClosure(){function CFF(){this.header=null;this.names=[];this.topDict=null;this.strings=new CFFStrings;this.globalSubrIndex=null;this.encoding=null;this.charset=null;this.charStrings=null;this.fdArray=[];this.fdSelect=null;this.isCIDFont=false}return CFF}();var CFFHeader=function CFFHeaderClosure(){function CFFHeader(major,minor,hdrSize,offSize){this.major=major;this.minor=minor;this.hdrSize=hdrSize;this.offSize=offSize}return CFFHeader}();var CFFStrings=function CFFStringsClosure(){function CFFStrings(){this.strings=[]}CFFStrings.prototype={get:function CFFStrings_get(index){if(index>=0&&index<=390){return CFFStandardStrings[index]}if(index-391<=this.strings.length){return this.strings[index-391]}return CFFStandardStrings[0]},add:function CFFStrings_add(value){this.strings.push(value)},get count(){return this.strings.length}};return CFFStrings}();var CFFIndex=function CFFIndexClosure(){function CFFIndex(){this.objects=[];this.length=0}CFFIndex.prototype={add:function CFFIndex_add(data){this.length+=data.length;this.objects.push(data)},set:function CFFIndex_set(index,data){this.length+=data.length-this.objects[index].length;this.objects[index]=data},get:function CFFIndex_get(index){return this.objects[index]},get count(){return this.objects.length}};return CFFIndex}();var CFFDict=function CFFDictClosure(){function CFFDict(tables,strings){this.keyToNameMap=tables.keyToNameMap;this.nameToKeyMap=tables.nameToKeyMap;this.defaults=tables.defaults;this.types=tables.types;this.opcodes=tables.opcodes;this.order=tables.order;this.strings=strings;this.values=Object.create(null)}CFFDict.prototype={setByKey:function CFFDict_setByKey(key,value){if(!(key in this.keyToNameMap)){return false}if(value.length===0){return true}var type=this.types[key];if(type==="num"||type==="sid"||type==="offset"){value=value[0];if(isNaN(value)){warn("Invalid CFFDict value: "+value+", for key: "+key+".");return true}}this.values[key]=value;return true},setByName:function CFFDict_setByName(name,value){if(!(name in this.nameToKeyMap)){error('Invalid dictionary name "'+name+'"')}this.values[this.nameToKeyMap[name]]=value},hasName:function CFFDict_hasName(name){return this.nameToKeyMap[name]in this.values},getByName:function CFFDict_getByName(name){if(!(name in this.nameToKeyMap)){error('Invalid dictionary name "'+name+'"')}var key=this.nameToKeyMap[name];if(!(key in this.values)){return this.defaults[key]
4}return this.values[key]},removeByName:function CFFDict_removeByName(name){delete this.values[this.nameToKeyMap[name]]}};CFFDict.createTables=function CFFDict_createTables(layout){var tables={keyToNameMap:{},nameToKeyMap:{},defaults:{},types:{},opcodes:{},order:[]};for(var i=0,ii=layout.length;i<ii;++i){var entry=layout[i];var key=isArray(entry[0])?(entry[0][0]<<8)+entry[0][1]:entry[0];tables.keyToNameMap[key]=entry[1];tables.nameToKeyMap[entry[1]]=key;tables.types[key]=entry[2];tables.defaults[key]=entry[3];tables.opcodes[key]=isArray(entry[0])?entry[0]:[entry[0]];tables.order.push(key)}return tables};return CFFDict}();var CFFTopDict=function CFFTopDictClosure(){var layout=[[[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"],[.001,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]];var tables=null;function CFFTopDict(strings){if(tables===null){tables=CFFDict.createTables(layout)}CFFDict.call(this,tables,strings);this.privateDict=null}CFFTopDict.prototype=Object.create(CFFDict.prototype);return CFFTopDict}();var CFFPrivateDict=function CFFPrivateDictClosure(){var layout=[[6,"BlueValues","delta",null],[7,"OtherBlues","delta",null],[8,"FamilyBlues","delta",null],[9,"FamilyOtherBlues","delta",null],[[12,9],"BlueScale","num",.039625],[[12,10],"BlueShift","num",7],[[12,11],"BlueFuzz","num",1],[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",.06],[[12,19],"initialRandomSeed","num",0],[20,"defaultWidthX","num",0],[21,"nominalWidthX","num",0],[19,"Subrs","offset",null]];var tables=null;function CFFPrivateDict(strings){if(tables===null){tables=CFFDict.createTables(layout)}CFFDict.call(this,tables,strings);this.subrsIndex=null}CFFPrivateDict.prototype=Object.create(CFFDict.prototype);return CFFPrivateDict}();var CFFCharsetPredefinedTypes={ISO_ADOBE:0,EXPERT:1,EXPERT_SUBSET:2};var CFFCharset=function CFFCharsetClosure(){function CFFCharset(predefined,format,charset,raw){this.predefined=predefined;this.format=format;this.charset=charset;this.raw=raw}return CFFCharset}();var CFFEncoding=function CFFEncodingClosure(){function CFFEncoding(predefined,format,encoding,raw){this.predefined=predefined;this.format=format;this.encoding=encoding;this.raw=raw}return CFFEncoding}();var CFFFDSelect=function CFFFDSelectClosure(){function CFFFDSelect(fdSelect,raw){this.fdSelect=fdSelect;this.raw=raw}CFFFDSelect.prototype={getFDIndex:function CFFFDSelect_get(glyphIndex){if(glyphIndex<0||glyphIndex>=this.fdSelect.length){return-1}return this.fdSelect[glyphIndex]}};return CFFFDSelect}();var CFFOffsetTracker=function CFFOffsetTrackerClosure(){function CFFOffsetTracker(){this.offsets=Object.create(null)}CFFOffsetTracker.prototype={isTracking:function CFFOffsetTracker_isTracking(key){return key in this.offsets},track:function CFFOffsetTracker_track(key,location){if(key in this.offsets){error("Already tracking location of "+key)}this.offsets[key]=location},offset:function CFFOffsetTracker_offset(value){for(var key in this.offsets){this.offsets[key]+=value}},setEntryLocation:function CFFOffsetTracker_setEntryLocation(key,values,output){if(!(key in this.offsets)){error("Not tracking location of "+key)}var data=output.data;var dataOffset=this.offsets[key];var size=5;for(var i=0,ii=values.length;i<ii;++i){var offset0=i*size+dataOffset;var offset1=offset0+1;var offset2=offset0+2;var offset3=offset0+3;var offset4=offset0+4;if(data[offset0]!==29||data[offset1]!==0||data[offset2]!==0||data[offset3]!==0||data[offset4]!==0){error("writing to an offset that is not empty")}var value=values[i];data[offset0]=29;data[offset1]=value>>24&255;data[offset2]=value>>16&255;data[offset3]=value>>8&255;data[offset4]=value&255}}};return CFFOffsetTracker}();var CFFCompiler=function CFFCompilerClosure(){function CFFCompiler(cff){this.cff=cff}CFFCompiler.prototype={compile:function CFFCompiler_compile(){var cff=this.cff;var output={data:[],length:0,add:function CFFCompiler_add(data){this.data=this.data.concat(data);this.length=this.data.length}};var header=this.compileHeader(cff.header);output.add(header);var nameIndex=this.compileNameIndex(cff.names);output.add(nameIndex);if(cff.isCIDFont){if(cff.topDict.hasName("FontMatrix")){var base=cff.topDict.getByName("FontMatrix");cff.topDict.removeByName("FontMatrix");for(var i=0,ii=cff.fdArray.length;i<ii;i++){var subDict=cff.fdArray[i];var matrix=base.slice(0);if(subDict.hasName("FontMatrix")){matrix=Util.transform(matrix,subDict.getByName("FontMatrix"))}subDict.setByName("FontMatrix",matrix)}}}var compiled=this.compileTopDicts([cff.topDict],output.length,cff.isCIDFont);output.add(compiled.output);var topDictTracker=compiled.trackers[0];var stringIndex=this.compileStringIndex(cff.strings.strings);output.add(stringIndex);var globalSubrIndex=this.compileIndex(cff.globalSubrIndex);output.add(globalSubrIndex);if(cff.encoding&&cff.topDict.hasName("Encoding")){if(cff.encoding.predefined){topDictTracker.setEntryLocation("Encoding",[cff.encoding.format],output)}else{var encoding=this.compileEncoding(cff.encoding);topDictTracker.setEntryLocation("Encoding",[output.length],output);output.add(encoding)}}if(cff.charset&&cff.topDict.hasName("charset")){if(cff.charset.predefined){topDictTracker.setEntryLocation("charset",[cff.charset.format],output)}else{var charset=this.compileCharset(cff.charset);topDictTracker.setEntryLocation("charset",[output.length],output);output.add(charset)}}var charStrings=this.compileCharStrings(cff.charStrings);topDictTracker.setEntryLocation("CharStrings",[output.length],output);output.add(charStrings);if(cff.isCIDFont){topDictTracker.setEntryLocation("FDSelect",[output.length],output);var fdSelect=this.compileFDSelect(cff.fdSelect.raw);output.add(fdSelect);compiled=this.compileTopDicts(cff.fdArray,output.length,true);topDictTracker.setEntryLocation("FDArray",[output.length],output);output.add(compiled.output);var fontDictTrackers=compiled.trackers;this.compilePrivateDicts(cff.fdArray,fontDictTrackers,output)}this.compilePrivateDicts([cff.topDict],[topDictTracker],output);output.add([0]);return output.data},encodeNumber:function CFFCompiler_encodeNumber(value){if(parseFloat(value)===parseInt(value,10)&&!isNaN(value)){return this.encodeInteger(value)}else{return this.encodeFloat(value)}},encodeFloat:function CFFCompiler_encodeFloat(num){var value=num.toString();var m=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);if(m){var epsilon=parseFloat("1e"+((m[2]?+m[2]:0)+m[1].length));value=(Math.round(num*epsilon)/epsilon).toString()}var nibbles="";var i,ii;for(i=0,ii=value.length;i<ii;++i){var a=value[i];if(a==="e"){nibbles+=value[++i]==="-"?"c":"b"}else if(a==="."){nibbles+="a"}else if(a==="-"){nibbles+="e"}else{nibbles+=a}}nibbles+=nibbles.length&1?"f":"ff";var out=[30];for(i=0,ii=nibbles.length;i<ii;i+=2){out.push(parseInt(nibbles.substr(i,2),16))}return out},encodeInteger:function CFFCompiler_encodeInteger(value){var code;if(value>=-107&&value<=107){code=[value+139]}else if(value>=108&&value<=1131){value=value-108;code=[(value>>8)+247,value&255]}else if(value>=-1131&&value<=-108){value=-value-108;code=[(value>>8)+251,value&255]}else if(value>=-32768&&value<=32767){code=[28,value>>8&255,value&255]}else{code=[29,value>>24&255,value>>16&255,value>>8&255,value&255]}return code},compileHeader:function CFFCompiler_compileHeader(header){return[header.major,header.minor,header.hdrSize,header.offSize]},compileNameIndex:function CFFCompiler_compileNameIndex(names){var nameIndex=new CFFIndex;for(var i=0,ii=names.length;i<ii;++i){nameIndex.add(stringToBytes(names[i]))}return this.compileIndex(nameIndex)},compileTopDicts:function CFFCompiler_compileTopDicts(dicts,length,removeCidKeys){var fontDictTrackers=[];var fdArrayIndex=new CFFIndex;for(var i=0,ii=dicts.length;i<ii;++i){var fontDict=dicts[i];if(removeCidKeys){fontDict.removeByName("CIDFontVersion");fontDict.removeByName("CIDFontRevision");fontDict.removeByName("CIDFontType");fontDict.removeByName("CIDCount");fontDict.removeByName("UIDBase")}var fontDictTracker=new CFFOffsetTracker;var fontDictData=this.compileDict(fontDict,fontDictTracker);fontDictTrackers.push(fontDictTracker);fdArrayIndex.add(fontDictData);fontDictTracker.offset(length)}fdArrayIndex=this.compileIndex(fdArrayIndex,fontDictTrackers);return{trackers:fontDictTrackers,output:fdArrayIndex}},compilePrivateDicts:function CFFCompiler_compilePrivateDicts(dicts,trackers,output){for(var i=0,ii=dicts.length;i<ii;++i){var fontDict=dicts[i];assert(fontDict.privateDict&&fontDict.hasName("Private"),"There must be an private dictionary.");var privateDict=fontDict.privateDict;var privateDictTracker=new CFFOffsetTracker;var privateDictData=this.compileDict(privateDict,privateDictTracker);var outputLength=output.length;privateDictTracker.offset(outputLength);if(!privateDictData.length){outputLength=0}trackers[i].setEntryLocation("Private",[privateDictData.length,outputLength],output);output.add(privateDictData);if(privateDict.subrsIndex&&privateDict.hasName("Subrs")){var subrs=this.compileIndex(privateDict.subrsIndex);privateDictTracker.setEntryLocation("Subrs",[privateDictData.length],output);output.add(subrs)}}},compileDict:function CFFCompiler_compileDict(dict,offsetTracker){var out=[];var order=dict.order;for(var i=0;i<order.length;++i){var key=order[i];if(!(key in dict.values)){continue}var values=dict.values[key];var types=dict.types[key];if(!isArray(types)){types=[types]}if(!isArray(values)){values=[values]}if(values.length===0){continue}for(var j=0,jj=types.length;j<jj;++j){var type=types[j];var value=values[j];switch(type){case"num":case"sid":out=out.concat(this.encodeNumber(value));break;case"offset":var name=dict.keyToNameMap[key];if(!offsetTracker.isTracking(name)){offsetTracker.track(name,out.length)}out=out.concat([29,0,0,0,0]);break;case"array":case"delta":out=out.concat(this.encodeNumber(value));for(var k=1,kk=values.length;k<kk;++k){out=out.concat(this.encodeNumber(values[k]))}break;default:error("Unknown data type of "+type);break}}out=out.concat(dict.opcodes[key])}return out},compileStringIndex:function CFFCompiler_compileStringIndex(strings){var stringIndex=new CFFIndex;for(var i=0,ii=strings.length;i<ii;++i){stringIndex.add(stringToBytes(strings[i]))}return this.compileIndex(stringIndex)},compileGlobalSubrIndex:function CFFCompiler_compileGlobalSubrIndex(){var globalSubrIndex=this.cff.globalSubrIndex;this.out.writeByteArray(this.compileIndex(globalSubrIndex))},compileCharStrings:function CFFCompiler_compileCharStrings(charStrings){return this.compileIndex(charStrings)},compileCharset:function CFFCompiler_compileCharset(charset){return this.compileTypedArray(charset.raw)},compileEncoding:function CFFCompiler_compileEncoding(encoding){return this.compileTypedArray(encoding.raw)},compileFDSelect:function CFFCompiler_compileFDSelect(fdSelect){return this.compileTypedArray(fdSelect)},compileTypedArray:function CFFCompiler_compileTypedArray(data){var out=[];for(var i=0,ii=data.length;i<ii;++i){out[i]=data[i]}return out},compileIndex:function CFFCompiler_compileIndex(index,trackers){trackers=trackers||[];var objects=index.objects;var count=objects.length;if(count===0){return[0,0,0]}var data=[count>>8&255,count&255];var lastOffset=1,i;for(i=0;i<count;++i){lastOffset+=objects[i].length}var offsetSize;if(lastOffset<256){offsetSize=1}else if(lastOffset<65536){offsetSize=2}else if(lastOffset<16777216){offsetSize=3}else{offsetSize=4}data.push(offsetSize);var relativeOffset=1;for(i=0;i<count+1;i++){if(offsetSize===1){data.push(relativeOffset&255)}else if(offsetSize===2){data.push(relativeOffset>>8&255,relativeOffset&255)}else if(offsetSize===3){data.push(relativeOffset>>16&255,relativeOffset>>8&255,relativeOffset&255)}else{data.push(relativeOffset>>>24&255,relativeOffset>>16&255,relativeOffset>>8&255,relativeOffset&255)}if(objects[i]){relativeOffset+=objects[i].length}}for(i=0;i<count;i++){if(trackers[i]){trackers[i].offset(data.length)}for(var j=0,jj=objects[i].length;j<jj;j++){data.push(objects[i][j])}}return data}};return CFFCompiler}();exports.CFFStandardStrings=CFFStandardStrings;exports.CFFParser=CFFParser;exports.CFF=CFF;exports.CFFHeader=CFFHeader;exports.CFFStrings=CFFStrings;exports.CFFIndex=CFFIndex;exports.CFFCharset=CFFCharset;exports.CFFTopDict=CFFTopDict;exports.CFFPrivateDict=CFFPrivateDict;exports.CFFCompiler=CFFCompiler});(function(root,factory){{factory(root.pdfjsCoreChunkedStream={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var MissingDataException=sharedUtil.MissingDataException;var arrayByteLength=sharedUtil.arrayByteLength;var arraysToBytes=sharedUtil.arraysToBytes;var assert=sharedUtil.assert;var createPromiseCapability=sharedUtil.createPromiseCapability;var isInt=sharedUtil.isInt;var isEmptyObj=sharedUtil.isEmptyObj;var ChunkedStream=function ChunkedStreamClosure(){function ChunkedStream(length,chunkSize,manager){this.bytes=new Uint8Array(length);this.start=0;this.pos=0;this.end=length;this.chunkSize=chunkSize;this.loadedChunks=[];this.numChunksLoaded=0;this.numChunks=Math.ceil(length/chunkSize);this.manager=manager;this.progressiveDataLength=0;this.lastSuccessfulEnsureByteChunk=-1}ChunkedStream.prototype={getMissingChunks:function ChunkedStream_getMissingChunks(){var chunks=[];for(var chunk=0,n=this.numChunks;chunk<n;++chunk){if(!this.loadedChunks[chunk]){chunks.push(chunk)}}return chunks},getBaseStreams:function ChunkedStream_getBaseStreams(){return[this]},allChunksLoaded:function ChunkedStream_allChunksLoaded(){return this.numChunksLoaded===this.numChunks},onReceiveData:function ChunkedStream_onReceiveData(begin,chunk){var end=begin+chunk.byteLength;assert(begin%this.chunkSize===0,"Bad begin offset: "+begin);var length=this.bytes.length;assert(end%this.chunkSize===0||end===length,"Bad end offset: "+end);this.bytes.set(new Uint8Array(chunk),begin);var chunkSize=this.chunkSize;var beginChunk=Math.floor(begin/chunkSize);var endChunk=Math.floor((end-1)/chunkSize)+1;var curChunk;for(curChunk=beginChunk;curChunk<endChunk;++curChunk){if(!this.loadedChunks[curChunk]){this.loadedChunks[curChunk]=true;++this.numChunksLoaded}}},onReceiveProgressiveData:function ChunkedStream_onReceiveProgressiveData(data){var position=this.progressiveDataLength;var beginChunk=Math.floor(position/this.chunkSize);this.bytes.set(new Uint8Array(data),position);position+=data.byteLength;this.progressiveDataLength=position;var endChunk=position>=this.end?this.numChunks:Math.floor(position/this.chunkSize);var curChunk;for(curChunk=beginChunk;curChunk<endChunk;++curChunk){if(!this.loadedChunks[curChunk]){this.loadedChunks[curChunk]=true;++this.numChunksLoaded}}},ensureByte:function ChunkedStream_ensureByte(pos){var chunk=Math.floor(pos/this.chunkSize);if(chunk===this.lastSuccessfulEnsureByteChunk){return}if(!this.loadedChunks[chunk]){throw new MissingDataException(pos,pos+1)}this.lastSuccessfulEnsureByteChunk=chunk},ensureRange:function ChunkedStream_ensureRange(begin,end){if(begin>=end){return}if(end<=this.progressiveDataLength){return}var chunkSize=this.chunkSize;var beginChunk=Math.floor(begin/chunkSize);var endChunk=Math.floor((end-1)/chunkSize)+1;for(var chunk=beginChunk;chunk<endChunk;++chunk){if(!this.loadedChunks[chunk]){throw new MissingDataException(begin,end)}}},nextEmptyChunk:function ChunkedStream_nextEmptyChunk(beginChunk){var chunk,numChunks=this.numChunks;for(var i=0;i<numChunks;++i){chunk=(beginChunk+i)%numChunks;if(!this.loadedChunks[chunk]){return chunk}}return null},hasChunk:function ChunkedStream_hasChunk(chunk){return!!this.loadedChunks[chunk]},get length(){return this.end-this.start},get isEmpty(){return this.length===0},getByte:function ChunkedStream_getByte(){var pos=this.pos;if(pos>=this.end){return-1}this.ensureByte(pos);return this.bytes[this.pos++]},getUint16:function ChunkedStream_getUint16(){var b0=this.getByte();var b1=this.getByte();if(b0===-1||b1===-1){return-1}return(b0<<8)+b1},getInt32:function ChunkedStream_getInt32(){var b0=this.getByte();var b1=this.getByte();var b2=this.getByte();var b3=this.getByte();return(b0<<24)+(b1<<16)+(b2<<8)+b3},getBytes:function ChunkedStream_getBytes(length){var bytes=this.bytes;var pos=this.pos;var strEnd=this.end;if(!length){this.ensureRange(pos,strEnd);return bytes.subarray(pos,strEnd)}var end=pos+length;if(end>strEnd){end=strEnd}this.ensureRange(pos,end);this.pos=end;return bytes.subarray(pos,end)},peekByte:function ChunkedStream_peekByte(){var peekedByte=this.getByte();this.pos--;return peekedByte},peekBytes:function ChunkedStream_peekBytes(length){var bytes=this.getBytes(length);this.pos-=bytes.length;return bytes},getByteRange:function ChunkedStream_getBytes(begin,end){this.ensureRange(begin,end);return this.bytes.subarray(begin,end)},skip:function ChunkedStream_skip(n){if(!n){n=1}this.pos+=n},reset:function ChunkedStream_reset(){this.pos=this.start},moveStart:function ChunkedStream_moveStart(){this.start=this.pos},makeSubStream:function ChunkedStream_makeSubStream(start,length,dict){this.ensureRange(start,start+length);function ChunkedStreamSubstream(){}ChunkedStreamSubstream.prototype=Object.create(this);ChunkedStreamSubstream.prototype.getMissingChunks=function(){var chunkSize=this.chunkSize;var beginChunk=Math.floor(this.start/chunkSize);var endChunk=Math.floor((this.end-1)/chunkSize)+1;var missingChunks=[];for(var chunk=beginChunk;chunk<endChunk;++chunk){if(!this.loadedChunks[chunk]){missingChunks.push(chunk)}}return missingChunks};var subStream=new ChunkedStreamSubstream;subStream.pos=subStream.start=start;subStream.end=start+length||this.end;subStream.dict=dict;return subStream},isStream:true};return ChunkedStream}();var ChunkedStreamManager=function ChunkedStreamManagerClosure(){function ChunkedStreamManager(pdfNetworkStream,args){var chunkSize=args.rangeChunkSize;var length=args.length;this.stream=new ChunkedStream(length,chunkSize,this);this.length=length;this.chunkSize=chunkSize;this.pdfNetworkStream=pdfNetworkStream;this.url=args.url;this.disableAutoFetch=args.disableAutoFetch;this.msgHandler=args.msgHandler;this.currRequestId=0;this.chunksNeededByRequest=Object.create(null);this.requestsByChunk=Object.create(null);this.promisesByRequest=Object.create(null);this.progressiveDataLength=0;this.aborted=false;this._loadedStreamCapability=createPromiseCapability()}ChunkedStreamManager.prototype={onLoadedStream:function ChunkedStreamManager_getLoadedStream(){return this._loadedStreamCapability.promise},sendRequest:function ChunkedStreamManager_sendRequest(begin,end){var rangeReader=this.pdfNetworkStream.getRangeReader(begin,end);if(!rangeReader.isStreamingSupported){rangeReader.onProgress=this.onProgress.bind(this)}var chunks=[],loaded=0;var manager=this;var promise=new Promise(function(resolve,reject){var readChunk=function(chunk){try{if(!chunk.done){var data=chunk.value;chunks.push(data);loaded+=arrayByteLength(data);if(rangeReader.isStreamingSupported){manager.onProgress({loaded:loaded})}rangeReader.read().then(readChunk,reject);return}var chunkData=arraysToBytes(chunks);chunks=null;resolve(chunkData)}catch(e){reject(e)}};rangeReader.read().then(readChunk,reject)});promise.then(function(data){if(this.aborted){return}this.onReceiveData({chunk:data,begin:begin})}.bind(this))},requestAllChunks:function ChunkedStreamManager_requestAllChunks(){var missingChunks=this.stream.getMissingChunks();this._requestChunks(missingChunks);return this._loadedStreamCapability.promise},_requestChunks:function ChunkedStreamManager_requestChunks(chunks){var requestId=this.currRequestId++;var i,ii;var chunksNeeded=Object.create(null);this.chunksNeededByRequest[requestId]=chunksNeeded;for(i=0,ii=chunks.length;i<ii;i++){if(!this.stream.hasChunk(chunks[i])){chunksNeeded[chunks[i]]=true}}if(isEmptyObj(chunksNeeded)){return Promise.resolve()}var capability=createPromiseCapability();this.promisesByRequest[requestId]=capability;var chunksToRequest=[];for(var chunk in chunksNeeded){chunk=chunk|0;if(!(chunk in this.requestsByChunk)){this.requestsByChunk[chunk]=[];chunksToRequest.push(chunk)}this.requestsByChunk[chunk].push(requestId)}if(!chunksToRequest.length){return capability.promise}var groupedChunksToRequest=this.groupChunks(chunksToRequest);for(i=0;i<groupedChunksToRequest.length;++i){var groupedChunk=groupedChunksToRequest[i];var begin=groupedChunk.beginChunk*this.chunkSize;var end=Math.min(groupedChunk.endChunk*this.chunkSize,this.length);this.sendRequest(begin,end)}return capability.promise},getStream:function ChunkedStreamManager_getStream(){return this.stream},requestRange:function ChunkedStreamManager_requestRange(begin,end){end=Math.min(end,this.length);var beginChunk=this.getBeginChunk(begin);var endChunk=this.getEndChunk(end);var chunks=[];for(var chunk=beginChunk;chunk<endChunk;++chunk){chunks.push(chunk)}return this._requestChunks(chunks)},requestRanges:function ChunkedStreamManager_requestRanges(ranges){ranges=ranges||[];var chunksToRequest=[];for(var i=0;i<ranges.length;i++){var beginChunk=this.getBeginChunk(ranges[i].begin);var endChunk=this.getEndChunk(ranges[i].end);for(var chunk=beginChunk;chunk<endChunk;++chunk){if(chunksToRequest.indexOf(chunk)<0){chunksToRequest.push(chunk)}}}chunksToRequest.sort(function(a,b){return a-b});return this._requestChunks(chunksToRequest)},groupChunks:function ChunkedStreamManager_groupChunks(chunks){var groupedChunks=[];var beginChunk=-1;var prevChunk=-1;for(var i=0;i<chunks.length;++i){var chunk=chunks[i];if(beginChunk<0){beginChunk=chunk}if(prevChunk>=0&&prevChunk+1!==chunk){groupedChunks.push({beginChunk:beginChunk,endChunk:prevChunk+1});beginChunk=chunk}if(i+1===chunks.length){groupedChunks.push({beginChunk:beginChunk,endChunk:chunk+1})}prevChunk=chunk}return groupedChunks},onProgress:function ChunkedStreamManager_onProgress(args){var bytesLoaded=this.stream.numChunksLoaded*this.chunkSize+args.loaded;this.msgHandler.send("DocProgress",{loaded:bytesLoaded,total:this.length})},onReceiveData:function ChunkedStreamManager_onReceiveData(args){var chunk=args.chunk;var isProgressive=args.begin===undefined;var begin=isProgressive?this.progressiveDataLength:args.begin;var end=begin+chunk.byteLength;var beginChunk=Math.floor(begin/this.chunkSize);var endChunk=end<this.length?Math.floor(end/this.chunkSize):Math.ceil(end/this.chunkSize);if(isProgressive){this.stream.onReceiveProgressiveData(chunk);this.progressiveDataLength=end}else{this.stream.onReceiveData(begin,chunk)}if(this.stream.allChunksLoaded()){this._loadedStreamCapability.resolve(this.stream)}var loadedRequests=[];var i,requestId;for(chunk=beginChunk;chunk<endChunk;++chunk){var requestIds=this.requestsByChunk[chunk]||[];delete this.requestsByChunk[chunk];for(i=0;i<requestIds.length;++i){requestId=requestIds[i];var chunksNeeded=this.chunksNeededByRequest[requestId];if(chunk in chunksNeeded){delete chunksNeeded[chunk]}if(!isEmptyObj(chunksNeeded)){continue}loadedRequests.push(requestId)}}if(!this.disableAutoFetch&&isEmptyObj(this.requestsByChunk)){var nextEmptyChunk;if(this.stream.numChunksLoaded===1){var lastChunk=this.stream.numChunks-1;if(!this.stream.hasChunk(lastChunk)){nextEmptyChunk=lastChunk}}else{nextEmptyChunk=this.stream.nextEmptyChunk(endChunk)}if(isInt(nextEmptyChunk)){this._requestChunks([nextEmptyChunk])}}for(i=0;i<loadedRequests.length;++i){requestId=loadedRequests[i];var capability=this.promisesByRequest[requestId];delete this.promisesByRequest[requestId];capability.resolve()}this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize,total:this.length})},onError:function ChunkedStreamManager_onError(err){this._loadedStreamCapability.reject(err)},getBeginChunk:function ChunkedStreamManager_getBeginChunk(begin){var chunk=Math.floor(begin/this.chunkSize);return chunk},getEndChunk:function ChunkedStreamManager_getEndChunk(end){var chunk=Math.floor((end-1)/this.chunkSize)+1;return chunk},abort:function ChunkedStreamManager_abort(){this.aborted=true;if(this.pdfNetworkStream){this.pdfNetworkStream.cancelAllRequests("abort")}for(var requestId in this.promisesByRequest){var capability=this.promisesByRequest[requestId];capability.reject(new Error("Request was aborted"))}}};return ChunkedStreamManager}();exports.ChunkedStream=ChunkedStream;exports.ChunkedStreamManager=ChunkedStreamManager});(function(root,factory){{factory(root.pdfjsCoreGlyphList={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var getLookupTableFactory=sharedUtil.getLookupTableFactory;var getGlyphsUnicode=getLookupTableFactory(function(t){t["A"]=65;t["AE"]=198;t["AEacute"]=508;t["AEmacron"]=482;t["AEsmall"]=63462;t["Aacute"]=193;t["Aacutesmall"]=63457;t["Abreve"]=258;t["Abreveacute"]=7854;t["Abrevecyrillic"]=1232;t["Abrevedotbelow"]=7862;t["Abrevegrave"]=7856;t["Abrevehookabove"]=7858;t["Abrevetilde"]=7860;t["Acaron"]=461;t["Acircle"]=9398;t["Acircumflex"]=194;t["Acircumflexacute"]=7844;t["Acircumflexdotbelow"]=7852;t["Acircumflexgrave"]=7846;t["Acircumflexhookabove"]=7848;t["Acircumflexsmall"]=63458;t["Acircumflextilde"]=7850;t["Acute"]=63177;t["Acutesmall"]=63412;t["Acyrillic"]=1040;t["Adblgrave"]=512;t["Adieresis"]=196;t["Adieresiscyrillic"]=1234;t["Adieresismacron"]=478;t["Adieresissmall"]=63460;t["Adotbelow"]=7840;t["Adotmacron"]=480;t["Agrave"]=192;t["Agravesmall"]=63456;t["Ahookabove"]=7842;t["Aiecyrillic"]=1236;t["Ainvertedbreve"]=514;t["Alpha"]=913;t["Alphatonos"]=902;t["Amacron"]=256;t["Amonospace"]=65313;t["Aogonek"]=260;t["Aring"]=197;t["Aringacute"]=506;t["Aringbelow"]=7680;t["Aringsmall"]=63461;t["Asmall"]=63329;t["Atilde"]=195;t["Atildesmall"]=63459;t["Aybarmenian"]=1329;t["B"]=66;t["Bcircle"]=9399;t["Bdotaccent"]=7682;t["Bdotbelow"]=7684;t["Becyrillic"]=1041;t["Benarmenian"]=1330;t["Beta"]=914;t["Bhook"]=385;t["Blinebelow"]=7686;t["Bmonospace"]=65314;t["Brevesmall"]=63220;t["Bsmall"]=63330;t["Btopbar"]=386;t["C"]=67;t["Caarmenian"]=1342;t["Cacute"]=262;t["Caron"]=63178;t["Caronsmall"]=63221;t["Ccaron"]=268;t["Ccedilla"]=199;t["Ccedillaacute"]=7688;t["Ccedillasmall"]=63463;t["Ccircle"]=9400;t["Ccircumflex"]=264;t["Cdot"]=266;t["Cdotaccent"]=266;t["Cedillasmall"]=63416;t["Chaarmenian"]=1353;t["Cheabkhasiancyrillic"]=1212;t["Checyrillic"]=1063;t["Chedescenderabkhasiancyrillic"]=1214;t["Chedescendercyrillic"]=1206;t["Chedieresiscyrillic"]=1268;t["Cheharmenian"]=1347;t["Chekhakassiancyrillic"]=1227;t["Cheverticalstrokecyrillic"]=1208;t["Chi"]=935;t["Chook"]=391;t["Circumflexsmall"]=63222;t["Cmonospace"]=65315;t["Coarmenian"]=1361;t["Csmall"]=63331;t["D"]=68;t["DZ"]=497;t["DZcaron"]=452;t["Daarmenian"]=1332;t["Dafrican"]=393;t["Dcaron"]=270;t["Dcedilla"]=7696;t["Dcircle"]=9401;t["Dcircumflexbelow"]=7698;t["Dcroat"]=272;t["Ddotaccent"]=7690;t["Ddotbelow"]=7692;t["Decyrillic"]=1044;t["Deicoptic"]=1006;t["Delta"]=8710;t["Deltagreek"]=916;t["Dhook"]=394;t["Dieresis"]=63179;t["DieresisAcute"]=63180;t["DieresisGrave"]=63181;t["Dieresissmall"]=63400;t["Digammagreek"]=988;t["Djecyrillic"]=1026;t["Dlinebelow"]=7694;t["Dmonospace"]=65316;t["Dotaccentsmall"]=63223;t["Dslash"]=272;t["Dsmall"]=63332;t["Dtopbar"]=395;t["Dz"]=498;t["Dzcaron"]=453;t["Dzeabkhasiancyrillic"]=1248;t["Dzecyrillic"]=1029;t["Dzhecyrillic"]=1039;t["E"]=69;t["Eacute"]=201;t["Eacutesmall"]=63465;t["Ebreve"]=276;t["Ecaron"]=282;t["Ecedillabreve"]=7708;t["Echarmenian"]=1333;t["Ecircle"]=9402;t["Ecircumflex"]=202;t["Ecircumflexacute"]=7870;t["Ecircumflexbelow"]=7704;t["Ecircumflexdotbelow"]=7878;t["Ecircumflexgrave"]=7872;t["Ecircumflexhookabove"]=7874;t["Ecircumflexsmall"]=63466;t["Ecircumflextilde"]=7876;t["Ecyrillic"]=1028;t["Edblgrave"]=516;t["Edieresis"]=203;t["Edieresissmall"]=63467;t["Edot"]=278;t["Edotaccent"]=278;t["Edotbelow"]=7864;t["Efcyrillic"]=1060;t["Egrave"]=200;t["Egravesmall"]=63464;t["Eharmenian"]=1335;t["Ehookabove"]=7866;t["Eightroman"]=8551;t["Einvertedbreve"]=518;t["Eiotifiedcyrillic"]=1124;t["Elcyrillic"]=1051;t["Elevenroman"]=8554;t["Emacron"]=274;t["Emacronacute"]=7702;t["Emacrongrave"]=7700;t["Emcyrillic"]=1052;t["Emonospace"]=65317;t["Encyrillic"]=1053;t["Endescendercyrillic"]=1186;t["Eng"]=330;t["Enghecyrillic"]=1188;t["Enhookcyrillic"]=1223;t["Eogonek"]=280;t["Eopen"]=400;t["Epsilon"]=917;t["Epsilontonos"]=904;t["Ercyrillic"]=1056;t["Ereversed"]=398;t["Ereversedcyrillic"]=1069;t["Escyrillic"]=1057;t["Esdescendercyrillic"]=1194;t["Esh"]=425;t["Esmall"]=63333;t["Eta"]=919;t["Etarmenian"]=1336;t["Etatonos"]=905;t["Eth"]=208;t["Ethsmall"]=63472;t["Etilde"]=7868;t["Etildebelow"]=7706;t["Euro"]=8364;t["Ezh"]=439;t["Ezhcaron"]=494;t["Ezhreversed"]=440;t["F"]=70;t["Fcircle"]=9403;t["Fdotaccent"]=7710;t["Feharmenian"]=1366;t["Feicoptic"]=996;t["Fhook"]=401;t["Fitacyrillic"]=1138;t["Fiveroman"]=8548;t["Fmonospace"]=65318;t["Fourroman"]=8547;t["Fsmall"]=63334;t["G"]=71;t["GBsquare"]=13191;t["Gacute"]=500;t["Gamma"]=915;t["Gammaafrican"]=404;t["Gangiacoptic"]=1002;t["Gbreve"]=286;t["Gcaron"]=486;t["Gcedilla"]=290;t["Gcircle"]=9404;t["Gcircumflex"]=284;t["Gcommaaccent"]=290;t["Gdot"]=288;t["Gdotaccent"]=288;t["Gecyrillic"]=1043;t["Ghadarmenian"]=1346;t["Ghemiddlehookcyrillic"]=1172;t["Ghestrokecyrillic"]=1170;t["Gheupturncyrillic"]=1168;t["Ghook"]=403;t["Gimarmenian"]=1331;t["Gjecyrillic"]=1027;t["Gmacron"]=7712;t["Gmonospace"]=65319;t["Grave"]=63182;t["Gravesmall"]=63328;t["Gsmall"]=63335;t["Gsmallhook"]=667;t["Gstroke"]=484;t["H"]=72;t["H18533"]=9679;t["H18543"]=9642;t["H18551"]=9643;t["H22073"]=9633;t["HPsquare"]=13259;t["Haabkhasiancyrillic"]=1192;t["Hadescendercyrillic"]=1202;t["Hardsigncyrillic"]=1066;t["Hbar"]=294;t["Hbrevebelow"]=7722;t["Hcedilla"]=7720;t["Hcircle"]=9405;t["Hcircumflex"]=292;t["Hdieresis"]=7718;t["Hdotaccent"]=7714;t["Hdotbelow"]=7716;t["Hmonospace"]=65320;t["Hoarmenian"]=1344;t["Horicoptic"]=1e3;t["Hsmall"]=63336;t["Hungarumlaut"]=63183;t["Hungarumlautsmall"]=63224;t["Hzsquare"]=13200;t["I"]=73;t["IAcyrillic"]=1071;t["IJ"]=306;t["IUcyrillic"]=1070;t["Iacute"]=205;t["Iacutesmall"]=63469;t["Ibreve"]=300;t["Icaron"]=463;t["Icircle"]=9406;t["Icircumflex"]=206;t["Icircumflexsmall"]=63470;t["Icyrillic"]=1030;t["Idblgrave"]=520;t["Idieresis"]=207;t["Idieresisacute"]=7726;t["Idieresiscyrillic"]=1252;t["Idieresissmall"]=63471;t["Idot"]=304;t["Idotaccent"]=304;t["Idotbelow"]=7882;t["Iebrevecyrillic"]=1238;t["Iecyrillic"]=1045;t["Ifraktur"]=8465;t["Igrave"]=204;t["Igravesmall"]=63468;t["Ihookabove"]=7880;t["Iicyrillic"]=1048;t["Iinvertedbreve"]=522;t["Iishortcyrillic"]=1049;t["Imacron"]=298;t["Imacroncyrillic"]=1250;t["Imonospace"]=65321;t["Iniarmenian"]=1339;t["Iocyrillic"]=1025;t["Iogonek"]=302;t["Iota"]=921;t["Iotaafrican"]=406;t["Iotadieresis"]=938;t["Iotatonos"]=906;t["Ismall"]=63337;t["Istroke"]=407;t["Itilde"]=296;t["Itildebelow"]=7724;t["Izhitsacyrillic"]=1140;t["Izhitsadblgravecyrillic"]=1142;t["J"]=74;t["Jaarmenian"]=1345;t["Jcircle"]=9407;t["Jcircumflex"]=308;t["Jecyrillic"]=1032;t["Jheharmenian"]=1355;t["Jmonospace"]=65322;t["Jsmall"]=63338;t["K"]=75;t["KBsquare"]=13189;t["KKsquare"]=13261;t["Kabashkircyrillic"]=1184;
5t["Kacute"]=7728;t["Kacyrillic"]=1050;t["Kadescendercyrillic"]=1178;t["Kahookcyrillic"]=1219;t["Kappa"]=922;t["Kastrokecyrillic"]=1182;t["Kaverticalstrokecyrillic"]=1180;t["Kcaron"]=488;t["Kcedilla"]=310;t["Kcircle"]=9408;t["Kcommaaccent"]=310;t["Kdotbelow"]=7730;t["Keharmenian"]=1364;t["Kenarmenian"]=1343;t["Khacyrillic"]=1061;t["Kheicoptic"]=998;t["Khook"]=408;t["Kjecyrillic"]=1036;t["Klinebelow"]=7732;t["Kmonospace"]=65323;t["Koppacyrillic"]=1152;t["Koppagreek"]=990;t["Ksicyrillic"]=1134;t["Ksmall"]=63339;t["L"]=76;t["LJ"]=455;t["LL"]=63167;t["Lacute"]=313;t["Lambda"]=923;t["Lcaron"]=317;t["Lcedilla"]=315;t["Lcircle"]=9409;t["Lcircumflexbelow"]=7740;t["Lcommaaccent"]=315;t["Ldot"]=319;t["Ldotaccent"]=319;t["Ldotbelow"]=7734;t["Ldotbelowmacron"]=7736;t["Liwnarmenian"]=1340;t["Lj"]=456;t["Ljecyrillic"]=1033;t["Llinebelow"]=7738;t["Lmonospace"]=65324;t["Lslash"]=321;t["Lslashsmall"]=63225;t["Lsmall"]=63340;t["M"]=77;t["MBsquare"]=13190;t["Macron"]=63184;t["Macronsmall"]=63407;t["Macute"]=7742;t["Mcircle"]=9410;t["Mdotaccent"]=7744;t["Mdotbelow"]=7746;t["Menarmenian"]=1348;t["Mmonospace"]=65325;t["Msmall"]=63341;t["Mturned"]=412;t["Mu"]=924;t["N"]=78;t["NJ"]=458;t["Nacute"]=323;t["Ncaron"]=327;t["Ncedilla"]=325;t["Ncircle"]=9411;t["Ncircumflexbelow"]=7754;t["Ncommaaccent"]=325;t["Ndotaccent"]=7748;t["Ndotbelow"]=7750;t["Nhookleft"]=413;t["Nineroman"]=8552;t["Nj"]=459;t["Njecyrillic"]=1034;t["Nlinebelow"]=7752;t["Nmonospace"]=65326;t["Nowarmenian"]=1350;t["Nsmall"]=63342;t["Ntilde"]=209;t["Ntildesmall"]=63473;t["Nu"]=925;t["O"]=79;t["OE"]=338;t["OEsmall"]=63226;t["Oacute"]=211;t["Oacutesmall"]=63475;t["Obarredcyrillic"]=1256;t["Obarreddieresiscyrillic"]=1258;t["Obreve"]=334;t["Ocaron"]=465;t["Ocenteredtilde"]=415;t["Ocircle"]=9412;t["Ocircumflex"]=212;t["Ocircumflexacute"]=7888;t["Ocircumflexdotbelow"]=7896;t["Ocircumflexgrave"]=7890;t["Ocircumflexhookabove"]=7892;t["Ocircumflexsmall"]=63476;t["Ocircumflextilde"]=7894;t["Ocyrillic"]=1054;t["Odblacute"]=336;t["Odblgrave"]=524;t["Odieresis"]=214;t["Odieresiscyrillic"]=1254;t["Odieresissmall"]=63478;t["Odotbelow"]=7884;t["Ogoneksmall"]=63227;t["Ograve"]=210;t["Ogravesmall"]=63474;t["Oharmenian"]=1365;t["Ohm"]=8486;t["Ohookabove"]=7886;t["Ohorn"]=416;t["Ohornacute"]=7898;t["Ohorndotbelow"]=7906;t["Ohorngrave"]=7900;t["Ohornhookabove"]=7902;t["Ohorntilde"]=7904;t["Ohungarumlaut"]=336;t["Oi"]=418;t["Oinvertedbreve"]=526;t["Omacron"]=332;t["Omacronacute"]=7762;t["Omacrongrave"]=7760;t["Omega"]=8486;t["Omegacyrillic"]=1120;t["Omegagreek"]=937;t["Omegaroundcyrillic"]=1146;t["Omegatitlocyrillic"]=1148;t["Omegatonos"]=911;t["Omicron"]=927;t["Omicrontonos"]=908;t["Omonospace"]=65327;t["Oneroman"]=8544;t["Oogonek"]=490;t["Oogonekmacron"]=492;t["Oopen"]=390;t["Oslash"]=216;t["Oslashacute"]=510;t["Oslashsmall"]=63480;t["Osmall"]=63343;t["Ostrokeacute"]=510;t["Otcyrillic"]=1150;t["Otilde"]=213;t["Otildeacute"]=7756;t["Otildedieresis"]=7758;t["Otildesmall"]=63477;t["P"]=80;t["Pacute"]=7764;t["Pcircle"]=9413;t["Pdotaccent"]=7766;t["Pecyrillic"]=1055;t["Peharmenian"]=1354;t["Pemiddlehookcyrillic"]=1190;t["Phi"]=934;t["Phook"]=420;t["Pi"]=928;t["Piwrarmenian"]=1363;t["Pmonospace"]=65328;t["Psi"]=936;t["Psicyrillic"]=1136;t["Psmall"]=63344;t["Q"]=81;t["Qcircle"]=9414;t["Qmonospace"]=65329;t["Qsmall"]=63345;t["R"]=82;t["Raarmenian"]=1356;t["Racute"]=340;t["Rcaron"]=344;t["Rcedilla"]=342;t["Rcircle"]=9415;t["Rcommaaccent"]=342;t["Rdblgrave"]=528;t["Rdotaccent"]=7768;t["Rdotbelow"]=7770;t["Rdotbelowmacron"]=7772;t["Reharmenian"]=1360;t["Rfraktur"]=8476;t["Rho"]=929;t["Ringsmall"]=63228;t["Rinvertedbreve"]=530;t["Rlinebelow"]=7774;t["Rmonospace"]=65330;t["Rsmall"]=63346;t["Rsmallinverted"]=641;t["Rsmallinvertedsuperior"]=694;t["S"]=83;t["SF010000"]=9484;t["SF020000"]=9492;t["SF030000"]=9488;t["SF040000"]=9496;t["SF050000"]=9532;t["SF060000"]=9516;t["SF070000"]=9524;t["SF080000"]=9500;t["SF090000"]=9508;t["SF100000"]=9472;t["SF110000"]=9474;t["SF190000"]=9569;t["SF200000"]=9570;t["SF210000"]=9558;t["SF220000"]=9557;t["SF230000"]=9571;t["SF240000"]=9553;t["SF250000"]=9559;t["SF260000"]=9565;t["SF270000"]=9564;t["SF280000"]=9563;t["SF360000"]=9566;t["SF370000"]=9567;t["SF380000"]=9562;t["SF390000"]=9556;t["SF400000"]=9577;t["SF410000"]=9574;t["SF420000"]=9568;t["SF430000"]=9552;t["SF440000"]=9580;t["SF450000"]=9575;t["SF460000"]=9576;t["SF470000"]=9572;t["SF480000"]=9573;t["SF490000"]=9561;t["SF500000"]=9560;t["SF510000"]=9554;t["SF520000"]=9555;t["SF530000"]=9579;t["SF540000"]=9578;t["Sacute"]=346;t["Sacutedotaccent"]=7780;t["Sampigreek"]=992;t["Scaron"]=352;t["Scarondotaccent"]=7782;t["Scaronsmall"]=63229;t["Scedilla"]=350;t["Schwa"]=399;t["Schwacyrillic"]=1240;t["Schwadieresiscyrillic"]=1242;t["Scircle"]=9416;t["Scircumflex"]=348;t["Scommaaccent"]=536;t["Sdotaccent"]=7776;t["Sdotbelow"]=7778;t["Sdotbelowdotaccent"]=7784;t["Seharmenian"]=1357;t["Sevenroman"]=8550;t["Shaarmenian"]=1351;t["Shacyrillic"]=1064;t["Shchacyrillic"]=1065;t["Sheicoptic"]=994;t["Shhacyrillic"]=1210;t["Shimacoptic"]=1004;t["Sigma"]=931;t["Sixroman"]=8549;t["Smonospace"]=65331;t["Softsigncyrillic"]=1068;t["Ssmall"]=63347;t["Stigmagreek"]=986;t["T"]=84;t["Tau"]=932;t["Tbar"]=358;t["Tcaron"]=356;t["Tcedilla"]=354;t["Tcircle"]=9417;t["Tcircumflexbelow"]=7792;t["Tcommaaccent"]=354;t["Tdotaccent"]=7786;t["Tdotbelow"]=7788;t["Tecyrillic"]=1058;t["Tedescendercyrillic"]=1196;t["Tenroman"]=8553;t["Tetsecyrillic"]=1204;t["Theta"]=920;t["Thook"]=428;t["Thorn"]=222;t["Thornsmall"]=63486;t["Threeroman"]=8546;t["Tildesmall"]=63230;t["Tiwnarmenian"]=1359;t["Tlinebelow"]=7790;t["Tmonospace"]=65332;t["Toarmenian"]=1337;t["Tonefive"]=444;t["Tonesix"]=388;t["Tonetwo"]=423;t["Tretroflexhook"]=430;t["Tsecyrillic"]=1062;t["Tshecyrillic"]=1035;t["Tsmall"]=63348;t["Twelveroman"]=8555;t["Tworoman"]=8545;t["U"]=85;t["Uacute"]=218;t["Uacutesmall"]=63482;t["Ubreve"]=364;t["Ucaron"]=467;t["Ucircle"]=9418;t["Ucircumflex"]=219;t["Ucircumflexbelow"]=7798;t["Ucircumflexsmall"]=63483;t["Ucyrillic"]=1059;t["Udblacute"]=368;t["Udblgrave"]=532;t["Udieresis"]=220;t["Udieresisacute"]=471;t["Udieresisbelow"]=7794;t["Udieresiscaron"]=473;t["Udieresiscyrillic"]=1264;t["Udieresisgrave"]=475;t["Udieresismacron"]=469;t["Udieresissmall"]=63484;t["Udotbelow"]=7908;t["Ugrave"]=217;t["Ugravesmall"]=63481;t["Uhookabove"]=7910;t["Uhorn"]=431;t["Uhornacute"]=7912;t["Uhorndotbelow"]=7920;t["Uhorngrave"]=7914;t["Uhornhookabove"]=7916;t["Uhorntilde"]=7918;t["Uhungarumlaut"]=368;t["Uhungarumlautcyrillic"]=1266;t["Uinvertedbreve"]=534;t["Ukcyrillic"]=1144;t["Umacron"]=362;t["Umacroncyrillic"]=1262;t["Umacrondieresis"]=7802;t["Umonospace"]=65333;t["Uogonek"]=370;t["Upsilon"]=933;t["Upsilon1"]=978;t["Upsilonacutehooksymbolgreek"]=979;t["Upsilonafrican"]=433;t["Upsilondieresis"]=939;t["Upsilondieresishooksymbolgreek"]=980;t["Upsilonhooksymbol"]=978;t["Upsilontonos"]=910;t["Uring"]=366;t["Ushortcyrillic"]=1038;t["Usmall"]=63349;t["Ustraightcyrillic"]=1198;t["Ustraightstrokecyrillic"]=1200;t["Utilde"]=360;t["Utildeacute"]=7800;t["Utildebelow"]=7796;t["V"]=86;t["Vcircle"]=9419;t["Vdotbelow"]=7806;t["Vecyrillic"]=1042;t["Vewarmenian"]=1358;t["Vhook"]=434;t["Vmonospace"]=65334;t["Voarmenian"]=1352;t["Vsmall"]=63350;t["Vtilde"]=7804;t["W"]=87;t["Wacute"]=7810;t["Wcircle"]=9420;t["Wcircumflex"]=372;t["Wdieresis"]=7812;t["Wdotaccent"]=7814;t["Wdotbelow"]=7816;t["Wgrave"]=7808;t["Wmonospace"]=65335;t["Wsmall"]=63351;t["X"]=88;t["Xcircle"]=9421;t["Xdieresis"]=7820;t["Xdotaccent"]=7818;t["Xeharmenian"]=1341;t["Xi"]=926;t["Xmonospace"]=65336;t["Xsmall"]=63352;t["Y"]=89;t["Yacute"]=221;t["Yacutesmall"]=63485;t["Yatcyrillic"]=1122;t["Ycircle"]=9422;t["Ycircumflex"]=374;t["Ydieresis"]=376;t["Ydieresissmall"]=63487;t["Ydotaccent"]=7822;t["Ydotbelow"]=7924;t["Yericyrillic"]=1067;t["Yerudieresiscyrillic"]=1272;t["Ygrave"]=7922;t["Yhook"]=435;t["Yhookabove"]=7926;t["Yiarmenian"]=1349;t["Yicyrillic"]=1031;t["Yiwnarmenian"]=1362;t["Ymonospace"]=65337;t["Ysmall"]=63353;t["Ytilde"]=7928;t["Yusbigcyrillic"]=1130;t["Yusbigiotifiedcyrillic"]=1132;t["Yuslittlecyrillic"]=1126;t["Yuslittleiotifiedcyrillic"]=1128;t["Z"]=90;t["Zaarmenian"]=1334;t["Zacute"]=377;t["Zcaron"]=381;t["Zcaronsmall"]=63231;t["Zcircle"]=9423;t["Zcircumflex"]=7824;t["Zdot"]=379;t["Zdotaccent"]=379;t["Zdotbelow"]=7826;t["Zecyrillic"]=1047;t["Zedescendercyrillic"]=1176;t["Zedieresiscyrillic"]=1246;t["Zeta"]=918;t["Zhearmenian"]=1338;t["Zhebrevecyrillic"]=1217;t["Zhecyrillic"]=1046;t["Zhedescendercyrillic"]=1174;t["Zhedieresiscyrillic"]=1244;t["Zlinebelow"]=7828;t["Zmonospace"]=65338;t["Zsmall"]=63354;t["Zstroke"]=437;t["a"]=97;t["aabengali"]=2438;t["aacute"]=225;t["aadeva"]=2310;t["aagujarati"]=2694;t["aagurmukhi"]=2566;t["aamatragurmukhi"]=2622;t["aarusquare"]=13059;t["aavowelsignbengali"]=2494;t["aavowelsigndeva"]=2366;t["aavowelsigngujarati"]=2750;t["abbreviationmarkarmenian"]=1375;t["abbreviationsigndeva"]=2416;t["abengali"]=2437;t["abopomofo"]=12570;t["abreve"]=259;t["abreveacute"]=7855;t["abrevecyrillic"]=1233;t["abrevedotbelow"]=7863;t["abrevegrave"]=7857;t["abrevehookabove"]=7859;t["abrevetilde"]=7861;t["acaron"]=462;t["acircle"]=9424;t["acircumflex"]=226;t["acircumflexacute"]=7845;t["acircumflexdotbelow"]=7853;t["acircumflexgrave"]=7847;t["acircumflexhookabove"]=7849;t["acircumflextilde"]=7851;t["acute"]=180;t["acutebelowcmb"]=791;t["acutecmb"]=769;t["acutecomb"]=769;t["acutedeva"]=2388;t["acutelowmod"]=719;t["acutetonecmb"]=833;t["acyrillic"]=1072;t["adblgrave"]=513;t["addakgurmukhi"]=2673;t["adeva"]=2309;t["adieresis"]=228;t["adieresiscyrillic"]=1235;t["adieresismacron"]=479;t["adotbelow"]=7841;t["adotmacron"]=481;t["ae"]=230;t["aeacute"]=509;t["aekorean"]=12624;t["aemacron"]=483;t["afii00208"]=8213;t["afii08941"]=8356;t["afii10017"]=1040;t["afii10018"]=1041;t["afii10019"]=1042;t["afii10020"]=1043;t["afii10021"]=1044;t["afii10022"]=1045;t["afii10023"]=1025;t["afii10024"]=1046;t["afii10025"]=1047;t["afii10026"]=1048;t["afii10027"]=1049;t["afii10028"]=1050;t["afii10029"]=1051;t["afii10030"]=1052;t["afii10031"]=1053;t["afii10032"]=1054;t["afii10033"]=1055;t["afii10034"]=1056;t["afii10035"]=1057;t["afii10036"]=1058;t["afii10037"]=1059;t["afii10038"]=1060;t["afii10039"]=1061;t["afii10040"]=1062;t["afii10041"]=1063;t["afii10042"]=1064;t["afii10043"]=1065;t["afii10044"]=1066;t["afii10045"]=1067;t["afii10046"]=1068;t["afii10047"]=1069;t["afii10048"]=1070;t["afii10049"]=1071;t["afii10050"]=1168;t["afii10051"]=1026;t["afii10052"]=1027;t["afii10053"]=1028;t["afii10054"]=1029;t["afii10055"]=1030;t["afii10056"]=1031;t["afii10057"]=1032;t["afii10058"]=1033;t["afii10059"]=1034;t["afii10060"]=1035;t["afii10061"]=1036;t["afii10062"]=1038;t["afii10063"]=63172;t["afii10064"]=63173;t["afii10065"]=1072;t["afii10066"]=1073;t["afii10067"]=1074;t["afii10068"]=1075;t["afii10069"]=1076;t["afii10070"]=1077;t["afii10071"]=1105;t["afii10072"]=1078;t["afii10073"]=1079;t["afii10074"]=1080;t["afii10075"]=1081;t["afii10076"]=1082;t["afii10077"]=1083;t["afii10078"]=1084;t["afii10079"]=1085;t["afii10080"]=1086;t["afii10081"]=1087;t["afii10082"]=1088;t["afii10083"]=1089;t["afii10084"]=1090;t["afii10085"]=1091;t["afii10086"]=1092;t["afii10087"]=1093;t["afii10088"]=1094;t["afii10089"]=1095;t["afii10090"]=1096;t["afii10091"]=1097;t["afii10092"]=1098;t["afii10093"]=1099;t["afii10094"]=1100;t["afii10095"]=1101;t["afii10096"]=1102;t["afii10097"]=1103;t["afii10098"]=1169;t["afii10099"]=1106;t["afii10100"]=1107;t["afii10101"]=1108;t["afii10102"]=1109;t["afii10103"]=1110;t["afii10104"]=1111;t["afii10105"]=1112;t["afii10106"]=1113;t["afii10107"]=1114;t["afii10108"]=1115;t["afii10109"]=1116;t["afii10110"]=1118;t["afii10145"]=1039;t["afii10146"]=1122;t["afii10147"]=1138;t["afii10148"]=1140;t["afii10192"]=63174;t["afii10193"]=1119;t["afii10194"]=1123;t["afii10195"]=1139;t["afii10196"]=1141;t["afii10831"]=63175;t["afii10832"]=63176;t["afii10846"]=1241;t["afii299"]=8206;t["afii300"]=8207;t["afii301"]=8205;t["afii57381"]=1642;t["afii57388"]=1548;t["afii57392"]=1632;t["afii57393"]=1633;t["afii57394"]=1634;t["afii57395"]=1635;t["afii57396"]=1636;t["afii57397"]=1637;t["afii57398"]=1638;t["afii57399"]=1639;t["afii57400"]=1640;t["afii57401"]=1641;t["afii57403"]=1563;t["afii57407"]=1567;t["afii57409"]=1569;t["afii57410"]=1570;t["afii57411"]=1571;t["afii57412"]=1572;t["afii57413"]=1573;t["afii57414"]=1574;t["afii57415"]=1575;t["afii57416"]=1576;t["afii57417"]=1577;t["afii57418"]=1578;t["afii57419"]=1579;t["afii57420"]=1580;t["afii57421"]=1581;t["afii57422"]=1582;t["afii57423"]=1583;t["afii57424"]=1584;t["afii57425"]=1585;t["afii57426"]=1586;t["afii57427"]=1587;t["afii57428"]=1588;t["afii57429"]=1589;t["afii57430"]=1590;t["afii57431"]=1591;t["afii57432"]=1592;t["afii57433"]=1593;t["afii57434"]=1594;t["afii57440"]=1600;t["afii57441"]=1601;t["afii57442"]=1602;t["afii57443"]=1603;t["afii57444"]=1604;t["afii57445"]=1605;t["afii57446"]=1606;t["afii57448"]=1608;t["afii57449"]=1609;t["afii57450"]=1610;t["afii57451"]=1611;t["afii57452"]=1612;t["afii57453"]=1613;t["afii57454"]=1614;t["afii57455"]=1615;t["afii57456"]=1616;t["afii57457"]=1617;t["afii57458"]=1618;t["afii57470"]=1607;t["afii57505"]=1700;t["afii57506"]=1662;t["afii57507"]=1670;t["afii57508"]=1688;t["afii57509"]=1711;t["afii57511"]=1657;t["afii57512"]=1672;t["afii57513"]=1681;t["afii57514"]=1722;t["afii57519"]=1746;t["afii57534"]=1749;t["afii57636"]=8362;t["afii57645"]=1470;t["afii57658"]=1475;t["afii57664"]=1488;t["afii57665"]=1489;t["afii57666"]=1490;t["afii57667"]=1491;t["afii57668"]=1492;t["afii57669"]=1493;t["afii57670"]=1494;t["afii57671"]=1495;t["afii57672"]=1496;t["afii57673"]=1497;t["afii57674"]=1498;t["afii57675"]=1499;t["afii57676"]=1500;t["afii57677"]=1501;t["afii57678"]=1502;t["afii57679"]=1503;t["afii57680"]=1504;t["afii57681"]=1505;t["afii57682"]=1506;t["afii57683"]=1507;t["afii57684"]=1508;t["afii57685"]=1509;t["afii57686"]=1510;t["afii57687"]=1511;t["afii57688"]=1512;t["afii57689"]=1513;t["afii57690"]=1514;t["afii57694"]=64298;t["afii57695"]=64299;t["afii57700"]=64331;t["afii57705"]=64287;t["afii57716"]=1520;t["afii57717"]=1521;t["afii57718"]=1522;t["afii57723"]=64309;t["afii57793"]=1460;t["afii57794"]=1461;t["afii57795"]=1462;t["afii57796"]=1467;t["afii57797"]=1464;t["afii57798"]=1463;t["afii57799"]=1456;t["afii57800"]=1458;t["afii57801"]=1457;t["afii57802"]=1459;t["afii57803"]=1474;t["afii57804"]=1473;t["afii57806"]=1465;t["afii57807"]=1468;t["afii57839"]=1469;t["afii57841"]=1471;t["afii57842"]=1472;t["afii57929"]=700;t["afii61248"]=8453;t["afii61289"]=8467;t["afii61352"]=8470;t["afii61573"]=8236;t["afii61574"]=8237;t["afii61575"]=8238;t["afii61664"]=8204;t["afii63167"]=1645;t["afii64937"]=701;t["agrave"]=224;t["agujarati"]=2693;t["agurmukhi"]=2565;t["ahiragana"]=12354;t["ahookabove"]=7843;t["aibengali"]=2448;t["aibopomofo"]=12574;t["aideva"]=2320;t["aiecyrillic"]=1237;t["aigujarati"]=2704;t["aigurmukhi"]=2576;t["aimatragurmukhi"]=2632;t["ainarabic"]=1593;t["ainfinalarabic"]=65226;t["aininitialarabic"]=65227;t["ainmedialarabic"]=65228;t["ainvertedbreve"]=515;t["aivowelsignbengali"]=2504;t["aivowelsigndeva"]=2376;t["aivowelsigngujarati"]=2760;t["akatakana"]=12450;t["akatakanahalfwidth"]=65393;t["akorean"]=12623;t["alef"]=1488;t["alefarabic"]=1575;t["alefdageshhebrew"]=64304;t["aleffinalarabic"]=65166;t["alefhamzaabovearabic"]=1571;t["alefhamzaabovefinalarabic"]=65156;t["alefhamzabelowarabic"]=1573;t["alefhamzabelowfinalarabic"]=65160;t["alefhebrew"]=1488;t["aleflamedhebrew"]=64335;t["alefmaddaabovearabic"]=1570;t["alefmaddaabovefinalarabic"]=65154;t["alefmaksuraarabic"]=1609;t["alefmaksurafinalarabic"]=65264;t["alefmaksurainitialarabic"]=65267;t["alefmaksuramedialarabic"]=65268;t["alefpatahhebrew"]=64302;t["alefqamatshebrew"]=64303;t["aleph"]=8501;t["allequal"]=8780;t["alpha"]=945;t["alphatonos"]=940;t["amacron"]=257;t["amonospace"]=65345;t["ampersand"]=38;t["ampersandmonospace"]=65286;t["ampersandsmall"]=63270;t["amsquare"]=13250;t["anbopomofo"]=12578;t["angbopomofo"]=12580;t["angbracketleft"]=12296;t["angbracketright"]=12297;t["angkhankhuthai"]=3674;t["angle"]=8736;t["anglebracketleft"]=12296;t["anglebracketleftvertical"]=65087;t["anglebracketright"]=12297;t["anglebracketrightvertical"]=65088;t["angleleft"]=9001;t["angleright"]=9002;t["angstrom"]=8491;t["anoteleia"]=903;t["anudattadeva"]=2386;t["anusvarabengali"]=2434;t["anusvaradeva"]=2306;t["anusvaragujarati"]=2690;t["aogonek"]=261;t["apaatosquare"]=13056;t["aparen"]=9372;t["apostrophearmenian"]=1370;t["apostrophemod"]=700;t["apple"]=63743;t["approaches"]=8784;t["approxequal"]=8776;t["approxequalorimage"]=8786;t["approximatelyequal"]=8773;t["araeaekorean"]=12686;t["araeakorean"]=12685;t["arc"]=8978;t["arighthalfring"]=7834;t["aring"]=229;t["aringacute"]=507;t["aringbelow"]=7681;t["arrowboth"]=8596;t["arrowdashdown"]=8675;t["arrowdashleft"]=8672;t["arrowdashright"]=8674;t["arrowdashup"]=8673;t["arrowdblboth"]=8660;t["arrowdbldown"]=8659;t["arrowdblleft"]=8656;t["arrowdblright"]=8658;t["arrowdblup"]=8657;t["arrowdown"]=8595;t["arrowdownleft"]=8601;t["arrowdownright"]=8600;t["arrowdownwhite"]=8681;t["arrowheaddownmod"]=709;t["arrowheadleftmod"]=706;t["arrowheadrightmod"]=707;t["arrowheadupmod"]=708;t["arrowhorizex"]=63719;t["arrowleft"]=8592;t["arrowleftdbl"]=8656;t["arrowleftdblstroke"]=8653;t["arrowleftoverright"]=8646;t["arrowleftwhite"]=8678;t["arrowright"]=8594;t["arrowrightdblstroke"]=8655;t["arrowrightheavy"]=10142;t["arrowrightoverleft"]=8644;t["arrowrightwhite"]=8680;t["arrowtableft"]=8676;t["arrowtabright"]=8677;t["arrowup"]=8593;t["arrowupdn"]=8597;t["arrowupdnbse"]=8616;t["arrowupdownbase"]=8616;t["arrowupleft"]=8598;t["arrowupleftofdown"]=8645;t["arrowupright"]=8599;t["arrowupwhite"]=8679;t["arrowvertex"]=63718;t["asciicircum"]=94;t["asciicircummonospace"]=65342;t["asciitilde"]=126;t["asciitildemonospace"]=65374;t["ascript"]=593;t["ascriptturned"]=594;t["asmallhiragana"]=12353;t["asmallkatakana"]=12449;t["asmallkatakanahalfwidth"]=65383;t["asterisk"]=42;t["asteriskaltonearabic"]=1645;t["asteriskarabic"]=1645;t["asteriskmath"]=8727;t["asteriskmonospace"]=65290;t["asterisksmall"]=65121;t["asterism"]=8258;t["asuperior"]=63209;t["asymptoticallyequal"]=8771;t["at"]=64;t["atilde"]=227;t["atmonospace"]=65312;t["atsmall"]=65131;t["aturned"]=592;t["aubengali"]=2452;t["aubopomofo"]=12576;t["audeva"]=2324;t["augujarati"]=2708;t["augurmukhi"]=2580;t["aulengthmarkbengali"]=2519;t["aumatragurmukhi"]=2636;t["auvowelsignbengali"]=2508;t["auvowelsigndeva"]=2380;t["auvowelsigngujarati"]=2764;t["avagrahadeva"]=2365;t["aybarmenian"]=1377;t["ayin"]=1506;t["ayinaltonehebrew"]=64288;t["ayinhebrew"]=1506;t["b"]=98;t["babengali"]=2476;t["backslash"]=92;t["backslashmonospace"]=65340;t["badeva"]=2348;t["bagujarati"]=2732;t["bagurmukhi"]=2604;t["bahiragana"]=12400;t["bahtthai"]=3647;t["bakatakana"]=12496;t["bar"]=124;t["barmonospace"]=65372;t["bbopomofo"]=12549;t["bcircle"]=9425;t["bdotaccent"]=7683;t["bdotbelow"]=7685;t["beamedsixteenthnotes"]=9836;t["because"]=8757;t["becyrillic"]=1073;t["beharabic"]=1576;t["behfinalarabic"]=65168;t["behinitialarabic"]=65169;t["behiragana"]=12409;t["behmedialarabic"]=65170;t["behmeeminitialarabic"]=64671;t["behmeemisolatedarabic"]=64520;t["behnoonfinalarabic"]=64621;t["bekatakana"]=12505;t["benarmenian"]=1378;t["bet"]=1489;t["beta"]=946;t["betasymbolgreek"]=976;t["betdagesh"]=64305;t["betdageshhebrew"]=64305;t["bethebrew"]=1489;t["betrafehebrew"]=64332;t["bhabengali"]=2477;t["bhadeva"]=2349;t["bhagujarati"]=2733;t["bhagurmukhi"]=2605;t["bhook"]=595;t["bihiragana"]=12403;t["bikatakana"]=12499;t["bilabialclick"]=664;t["bindigurmukhi"]=2562;t["birusquare"]=13105;t["blackcircle"]=9679;t["blackdiamond"]=9670;t["blackdownpointingtriangle"]=9660;t["blackleftpointingpointer"]=9668;t["blackleftpointingtriangle"]=9664;t["blacklenticularbracketleft"]=12304;t["blacklenticularbracketleftvertical"]=65083;t["blacklenticularbracketright"]=12305;t["blacklenticularbracketrightvertical"]=65084;t["blacklowerlefttriangle"]=9699;t["blacklowerrighttriangle"]=9698;t["blackrectangle"]=9644;t["blackrightpointingpointer"]=9658;t["blackrightpointingtriangle"]=9654;t["blacksmallsquare"]=9642;t["blacksmilingface"]=9787;t["blacksquare"]=9632;t["blackstar"]=9733;t["blackupperlefttriangle"]=9700;t["blackupperrighttriangle"]=9701;t["blackuppointingsmalltriangle"]=9652;t["blackuppointingtriangle"]=9650;t["blank"]=9251;t["blinebelow"]=7687;t["block"]=9608;t["bmonospace"]=65346;t["bobaimaithai"]=3610;t["bohiragana"]=12412;t["bokatakana"]=12508;t["bparen"]=9373;t["bqsquare"]=13251;t["braceex"]=63732;t["braceleft"]=123;t["braceleftbt"]=63731;t["braceleftmid"]=63730;t["braceleftmonospace"]=65371;t["braceleftsmall"]=65115;t["bracelefttp"]=63729;t["braceleftvertical"]=65079;t["braceright"]=125;t["bracerightbt"]=63742;t["bracerightmid"]=63741;t["bracerightmonospace"]=65373;t["bracerightsmall"]=65116;t["bracerighttp"]=63740;t["bracerightvertical"]=65080;t["bracketleft"]=91;t["bracketleftbt"]=63728;t["bracketleftex"]=63727;t["bracketleftmonospace"]=65339;t["bracketlefttp"]=63726;t["bracketright"]=93;t["bracketrightbt"]=63739;t["bracketrightex"]=63738;t["bracketrightmonospace"]=65341;t["bracketrighttp"]=63737;t["breve"]=728;t["brevebelowcmb"]=814;t["brevecmb"]=774;t["breveinvertedbelowcmb"]=815;t["breveinvertedcmb"]=785;t["breveinverteddoublecmb"]=865;t["bridgebelowcmb"]=810;t["bridgeinvertedbelowcmb"]=826;t["brokenbar"]=166;t["bstroke"]=384;t["bsuperior"]=63210;t["btopbar"]=387;t["buhiragana"]=12406;t["bukatakana"]=12502;t["bullet"]=8226;t["bulletinverse"]=9688;t["bulletoperator"]=8729;t["bullseye"]=9678;t["c"]=99;t["caarmenian"]=1390;t["cabengali"]=2458;t["cacute"]=263;t["cadeva"]=2330;t["cagujarati"]=2714;t["cagurmukhi"]=2586;t["calsquare"]=13192;t["candrabindubengali"]=2433;t["candrabinducmb"]=784;t["candrabindudeva"]=2305;t["candrabindugujarati"]=2689;t["capslock"]=8682;t["careof"]=8453;t["caron"]=711;t["caronbelowcmb"]=812;t["caroncmb"]=780;t["carriagereturn"]=8629;t["cbopomofo"]=12568;t["ccaron"]=269;t["ccedilla"]=231;t["ccedillaacute"]=7689;t["ccircle"]=9426;t["ccircumflex"]=265;t["ccurl"]=597;t["cdot"]=267;t["cdotaccent"]=267;t["cdsquare"]=13253;t["cedilla"]=184;t["cedillacmb"]=807;t["cent"]=162;t["centigrade"]=8451;t["centinferior"]=63199;t["centmonospace"]=65504;t["centoldstyle"]=63394;t["centsuperior"]=63200;t["chaarmenian"]=1401;t["chabengali"]=2459;t["chadeva"]=2331;t["chagujarati"]=2715;t["chagurmukhi"]=2587;t["chbopomofo"]=12564;t["cheabkhasiancyrillic"]=1213;t["checkmark"]=10003;t["checyrillic"]=1095;t["chedescenderabkhasiancyrillic"]=1215;t["chedescendercyrillic"]=1207;t["chedieresiscyrillic"]=1269;t["cheharmenian"]=1395;t["chekhakassiancyrillic"]=1228;t["cheverticalstrokecyrillic"]=1209;t["chi"]=967;t["chieuchacirclekorean"]=12919;t["chieuchaparenkorean"]=12823;t["chieuchcirclekorean"]=12905;t["chieuchkorean"]=12618;t["chieuchparenkorean"]=12809;t["chochangthai"]=3594;t["chochanthai"]=3592;t["chochingthai"]=3593;t["chochoethai"]=3596;t["chook"]=392;t["cieucacirclekorean"]=12918;t["cieucaparenkorean"]=12822;t["cieuccirclekorean"]=12904;t["cieuckorean"]=12616;t["cieucparenkorean"]=12808;t["cieucuparenkorean"]=12828;t["circle"]=9675;t["circlecopyrt"]=169;t["circlemultiply"]=8855;t["circleot"]=8857;t["circleplus"]=8853;t["circlepostalmark"]=12342;t["circlewithlefthalfblack"]=9680;t["circlewithrighthalfblack"]=9681;t["circumflex"]=710;t["circumflexbelowcmb"]=813;t["circumflexcmb"]=770;t["clear"]=8999;t["clickalveolar"]=450;t["clickdental"]=448;t["clicklateral"]=449;t["clickretroflex"]=451;t["club"]=9827;t["clubsuitblack"]=9827;t["clubsuitwhite"]=9831;t["cmcubedsquare"]=13220;t["cmonospace"]=65347;t["cmsquaredsquare"]=13216;t["coarmenian"]=1409;t["colon"]=58;t["colonmonetary"]=8353;t["colonmonospace"]=65306;t["colonsign"]=8353;t["colonsmall"]=65109;t["colontriangularhalfmod"]=721;t["colontriangularmod"]=720;t["comma"]=44;t["commaabovecmb"]=787;t["commaaboverightcmb"]=789;t["commaaccent"]=63171;t["commaarabic"]=1548;t["commaarmenian"]=1373;t["commainferior"]=63201;t["commamonospace"]=65292;t["commareversedabovecmb"]=788;t["commareversedmod"]=701;t["commasmall"]=65104;t["commasuperior"]=63202;t["commaturnedabovecmb"]=786;t["commaturnedmod"]=699;t["compass"]=9788;t["congruent"]=8773;t["contourintegral"]=8750;t["control"]=8963;t["controlACK"]=6;t["controlBEL"]=7;t["controlBS"]=8;t["controlCAN"]=24;t["controlCR"]=13;t["controlDC1"]=17;t["controlDC2"]=18;t["controlDC3"]=19;t["controlDC4"]=20;t["controlDEL"]=127;t["controlDLE"]=16;t["controlEM"]=25;t["controlENQ"]=5;t["controlEOT"]=4;t["controlESC"]=27;t["controlETB"]=23;t["controlETX"]=3;t["controlFF"]=12;t["controlFS"]=28;t["controlGS"]=29;t["controlHT"]=9;t["controlLF"]=10;t["controlNAK"]=21;t["controlRS"]=30;t["controlSI"]=15;t["controlSO"]=14;t["controlSOT"]=2;t["controlSTX"]=1;t["controlSUB"]=26;t["controlSYN"]=22;t["controlUS"]=31;t["controlVT"]=11;t["copyright"]=169;t["copyrightsans"]=63721;t["copyrightserif"]=63193;t["cornerbracketleft"]=12300;t["cornerbracketlefthalfwidth"]=65378;t["cornerbracketleftvertical"]=65089;t["cornerbracketright"]=12301;t["cornerbracketrighthalfwidth"]=65379;t["cornerbracketrightvertical"]=65090;t["corporationsquare"]=13183;t["cosquare"]=13255;t["coverkgsquare"]=13254;t["cparen"]=9374;t["cruzeiro"]=8354;t["cstretched"]=663;t["curlyand"]=8911;t["curlyor"]=8910;t["currency"]=164;t["cyrBreve"]=63185;t["cyrFlex"]=63186;t["cyrbreve"]=63188;t["cyrflex"]=63189;t["d"]=100;t["daarmenian"]=1380;t["dabengali"]=2470;t["dadarabic"]=1590;t["dadeva"]=2342;t["dadfinalarabic"]=65214;t["dadinitialarabic"]=65215;t["dadmedialarabic"]=65216;t["dagesh"]=1468;t["dageshhebrew"]=1468;t["dagger"]=8224;t["daggerdbl"]=8225;t["dagujarati"]=2726;t["dagurmukhi"]=2598;t["dahiragana"]=12384;t["dakatakana"]=12480;t["dalarabic"]=1583;t["dalet"]=1491;t["daletdagesh"]=64307;t["daletdageshhebrew"]=64307;t["dalethebrew"]=1491;t["dalfinalarabic"]=65194;t["dammaarabic"]=1615;t["dammalowarabic"]=1615;t["dammatanaltonearabic"]=1612;t["dammatanarabic"]=1612;t["danda"]=2404;t["dargahebrew"]=1447;t["dargalefthebrew"]=1447;t["dasiapneumatacyrilliccmb"]=1157;t["dblGrave"]=63187;t["dblanglebracketleft"]=12298;t["dblanglebracketleftvertical"]=65085;t["dblanglebracketright"]=12299;t["dblanglebracketrightvertical"]=65086;t["dblarchinvertedbelowcmb"]=811;t["dblarrowleft"]=8660;t["dblarrowright"]=8658;t["dbldanda"]=2405;t["dblgrave"]=63190;t["dblgravecmb"]=783;t["dblintegral"]=8748;t["dbllowline"]=8215;t["dbllowlinecmb"]=819;t["dbloverlinecmb"]=831;t["dblprimemod"]=698;t["dblverticalbar"]=8214;t["dblverticallineabovecmb"]=782;t["dbopomofo"]=12553;t["dbsquare"]=13256;t["dcaron"]=271;t["dcedilla"]=7697;t["dcircle"]=9427;t["dcircumflexbelow"]=7699;t["dcroat"]=273;t["ddabengali"]=2465;t["ddadeva"]=2337;t["ddagujarati"]=2721;t["ddagurmukhi"]=2593;t["ddalarabic"]=1672;t["ddalfinalarabic"]=64393;t["dddhadeva"]=2396;t["ddhabengali"]=2466;t["ddhadeva"]=2338;t["ddhagujarati"]=2722;t["ddhagurmukhi"]=2594;t["ddotaccent"]=7691;t["ddotbelow"]=7693;t["decimalseparatorarabic"]=1643;t["decimalseparatorpersian"]=1643;t["decyrillic"]=1076;t["degree"]=176;t["dehihebrew"]=1453;t["dehiragana"]=12391;t["deicoptic"]=1007;t["dekatakana"]=12487;t["deleteleft"]=9003;t["deleteright"]=8998;t["delta"]=948;t["deltaturned"]=397;t["denominatorminusonenumeratorbengali"]=2552;t["dezh"]=676;t["dhabengali"]=2471;t["dhadeva"]=2343;t["dhagujarati"]=2727;t["dhagurmukhi"]=2599;t["dhook"]=599;t["dialytikatonos"]=901;t["dialytikatonoscmb"]=836;t["diamond"]=9830;t["diamondsuitwhite"]=9826;t["dieresis"]=168;t["dieresisacute"]=63191;t["dieresisbelowcmb"]=804;t["dieresiscmb"]=776;t["dieresisgrave"]=63192;t["dieresistonos"]=901;t["dihiragana"]=12386;t["dikatakana"]=12482;t["dittomark"]=12291;t["divide"]=247;t["divides"]=8739;t["divisionslash"]=8725;t["djecyrillic"]=1106;t["dkshade"]=9619;t["dlinebelow"]=7695;t["dlsquare"]=13207;t["dmacron"]=273;t["dmonospace"]=65348;t["dnblock"]=9604;t["dochadathai"]=3598;t["dodekthai"]=3604;t["dohiragana"]=12393;t["dokatakana"]=12489;t["dollar"]=36;t["dollarinferior"]=63203;t["dollarmonospace"]=65284;t["dollaroldstyle"]=63268;t["dollarsmall"]=65129;t["dollarsuperior"]=63204;t["dong"]=8363;t["dorusquare"]=13094;t["dotaccent"]=729;t["dotaccentcmb"]=775;t["dotbelowcmb"]=803;t["dotbelowcomb"]=803;t["dotkatakana"]=12539;t["dotlessi"]=305;t["dotlessj"]=63166;t["dotlessjstrokehook"]=644;t["dotmath"]=8901;t["dottedcircle"]=9676;t["doubleyodpatah"]=64287;t["doubleyodpatahhebrew"]=64287;t["downtackbelowcmb"]=798;t["downtackmod"]=725;t["dparen"]=9375;t["dsuperior"]=63211;t["dtail"]=598;t["dtopbar"]=396;t["duhiragana"]=12389;t["dukatakana"]=12485;t["dz"]=499;t["dzaltone"]=675;t["dzcaron"]=454;t["dzcurl"]=677;t["dzeabkhasiancyrillic"]=1249;t["dzecyrillic"]=1109;t["dzhecyrillic"]=1119;t["e"]=101;t["eacute"]=233;t["earth"]=9793;t["ebengali"]=2447;t["ebopomofo"]=12572;t["ebreve"]=277;t["ecandradeva"]=2317;t["ecandragujarati"]=2701;t["ecandravowelsigndeva"]=2373;t["ecandravowelsigngujarati"]=2757;t["ecaron"]=283;t["ecedillabreve"]=7709;t["echarmenian"]=1381;t["echyiwnarmenian"]=1415;t["ecircle"]=9428;t["ecircumflex"]=234;t["ecircumflexacute"]=7871;t["ecircumflexbelow"]=7705;t["ecircumflexdotbelow"]=7879;t["ecircumflexgrave"]=7873;t["ecircumflexhookabove"]=7875;t["ecircumflextilde"]=7877;t["ecyrillic"]=1108;t["edblgrave"]=517;t["edeva"]=2319;t["edieresis"]=235;t["edot"]=279;t["edotaccent"]=279;t["edotbelow"]=7865;t["eegurmukhi"]=2575;t["eematragurmukhi"]=2631;t["efcyrillic"]=1092;t["egrave"]=232;t["egujarati"]=2703;t["eharmenian"]=1383;t["ehbopomofo"]=12573;t["ehiragana"]=12360;t["ehookabove"]=7867;t["eibopomofo"]=12575;t["eight"]=56;t["eightarabic"]=1640;t["eightbengali"]=2542;t["eightcircle"]=9319;t["eightcircleinversesansserif"]=10129;t["eightdeva"]=2414;t["eighteencircle"]=9329;t["eighteenparen"]=9349;t["eighteenperiod"]=9369;t["eightgujarati"]=2798;t["eightgurmukhi"]=2670;t["eighthackarabic"]=1640;t["eighthangzhou"]=12328;t["eighthnotebeamed"]=9835;t["eightideographicparen"]=12839;t["eightinferior"]=8328;t["eightmonospace"]=65304;t["eightoldstyle"]=63288;t["eightparen"]=9339;t["eightperiod"]=9359;t["eightpersian"]=1784;t["eightroman"]=8567;t["eightsuperior"]=8312;t["eightthai"]=3672;t["einvertedbreve"]=519;t["eiotifiedcyrillic"]=1125;t["ekatakana"]=12456;t["ekatakanahalfwidth"]=65396;t["ekonkargurmukhi"]=2676;t["ekorean"]=12628;t["elcyrillic"]=1083;t["element"]=8712;t["elevencircle"]=9322;t["elevenparen"]=9342;t["elevenperiod"]=9362;t["elevenroman"]=8570;t["ellipsis"]=8230;t["ellipsisvertical"]=8942;t["emacron"]=275;t["emacronacute"]=7703;t["emacrongrave"]=7701;t["emcyrillic"]=1084;t["emdash"]=8212;t["emdashvertical"]=65073;t["emonospace"]=65349;t["emphasismarkarmenian"]=1371;t["emptyset"]=8709;t["enbopomofo"]=12579;t["encyrillic"]=1085;t["endash"]=8211;t["endashvertical"]=65074;t["endescendercyrillic"]=1187;t["eng"]=331;t["engbopomofo"]=12581;t["enghecyrillic"]=1189;t["enhookcyrillic"]=1224;t["enspace"]=8194;t["eogonek"]=281;t["eokorean"]=12627;t["eopen"]=603;t["eopenclosed"]=666;t["eopenreversed"]=604;t["eopenreversedclosed"]=606;t["eopenreversedhook"]=605;t["eparen"]=9376;t["epsilon"]=949;t["epsilontonos"]=941;t["equal"]=61;t["equalmonospace"]=65309;t["equalsmall"]=65126;t["equalsuperior"]=8316;t["equivalence"]=8801;t["erbopomofo"]=12582;t["ercyrillic"]=1088;t["ereversed"]=600;t["ereversedcyrillic"]=1101;t["escyrillic"]=1089;t["esdescendercyrillic"]=1195;t["esh"]=643;t["eshcurl"]=646;t["eshortdeva"]=2318;t["eshortvowelsigndeva"]=2374;t["eshreversedloop"]=426;t["eshsquatreversed"]=645;t["esmallhiragana"]=12359;t["esmallkatakana"]=12455;t["esmallkatakanahalfwidth"]=65386;t["estimated"]=8494;t["esuperior"]=63212;t["eta"]=951;t["etarmenian"]=1384;t["etatonos"]=942;t["eth"]=240;t["etilde"]=7869;t["etildebelow"]=7707;t["etnahtafoukhhebrew"]=1425;t["etnahtafoukhlefthebrew"]=1425;t["etnahtahebrew"]=1425;t["etnahtalefthebrew"]=1425;t["eturned"]=477;t["eukorean"]=12641;t["euro"]=8364;t["evowelsignbengali"]=2503;t["evowelsigndeva"]=2375;t["evowelsigngujarati"]=2759;t["exclam"]=33;t["exclamarmenian"]=1372;t["exclamdbl"]=8252;t["exclamdown"]=161;t["exclamdownsmall"]=63393;t["exclammonospace"]=65281;t["exclamsmall"]=63265;t["existential"]=8707;t["ezh"]=658;
6t["ezhcaron"]=495;t["ezhcurl"]=659;t["ezhreversed"]=441;t["ezhtail"]=442;t["f"]=102;t["fadeva"]=2398;t["fagurmukhi"]=2654;t["fahrenheit"]=8457;t["fathaarabic"]=1614;t["fathalowarabic"]=1614;t["fathatanarabic"]=1611;t["fbopomofo"]=12552;t["fcircle"]=9429;t["fdotaccent"]=7711;t["feharabic"]=1601;t["feharmenian"]=1414;t["fehfinalarabic"]=65234;t["fehinitialarabic"]=65235;t["fehmedialarabic"]=65236;t["feicoptic"]=997;t["female"]=9792;t["ff"]=64256;t["ffi"]=64259;t["ffl"]=64260;t["fi"]=64257;t["fifteencircle"]=9326;t["fifteenparen"]=9346;t["fifteenperiod"]=9366;t["figuredash"]=8210;t["filledbox"]=9632;t["filledrect"]=9644;t["finalkaf"]=1498;t["finalkafdagesh"]=64314;t["finalkafdageshhebrew"]=64314;t["finalkafhebrew"]=1498;t["finalmem"]=1501;t["finalmemhebrew"]=1501;t["finalnun"]=1503;t["finalnunhebrew"]=1503;t["finalpe"]=1507;t["finalpehebrew"]=1507;t["finaltsadi"]=1509;t["finaltsadihebrew"]=1509;t["firsttonechinese"]=713;t["fisheye"]=9673;t["fitacyrillic"]=1139;t["five"]=53;t["fivearabic"]=1637;t["fivebengali"]=2539;t["fivecircle"]=9316;t["fivecircleinversesansserif"]=10126;t["fivedeva"]=2411;t["fiveeighths"]=8541;t["fivegujarati"]=2795;t["fivegurmukhi"]=2667;t["fivehackarabic"]=1637;t["fivehangzhou"]=12325;t["fiveideographicparen"]=12836;t["fiveinferior"]=8325;t["fivemonospace"]=65301;t["fiveoldstyle"]=63285;t["fiveparen"]=9336;t["fiveperiod"]=9356;t["fivepersian"]=1781;t["fiveroman"]=8564;t["fivesuperior"]=8309;t["fivethai"]=3669;t["fl"]=64258;t["florin"]=402;t["fmonospace"]=65350;t["fmsquare"]=13209;t["fofanthai"]=3615;t["fofathai"]=3613;t["fongmanthai"]=3663;t["forall"]=8704;t["four"]=52;t["fourarabic"]=1636;t["fourbengali"]=2538;t["fourcircle"]=9315;t["fourcircleinversesansserif"]=10125;t["fourdeva"]=2410;t["fourgujarati"]=2794;t["fourgurmukhi"]=2666;t["fourhackarabic"]=1636;t["fourhangzhou"]=12324;t["fourideographicparen"]=12835;t["fourinferior"]=8324;t["fourmonospace"]=65300;t["fournumeratorbengali"]=2551;t["fouroldstyle"]=63284;t["fourparen"]=9335;t["fourperiod"]=9355;t["fourpersian"]=1780;t["fourroman"]=8563;t["foursuperior"]=8308;t["fourteencircle"]=9325;t["fourteenparen"]=9345;t["fourteenperiod"]=9365;t["fourthai"]=3668;t["fourthtonechinese"]=715;t["fparen"]=9377;t["fraction"]=8260;t["franc"]=8355;t["g"]=103;t["gabengali"]=2455;t["gacute"]=501;t["gadeva"]=2327;t["gafarabic"]=1711;t["gaffinalarabic"]=64403;t["gafinitialarabic"]=64404;t["gafmedialarabic"]=64405;t["gagujarati"]=2711;t["gagurmukhi"]=2583;t["gahiragana"]=12364;t["gakatakana"]=12460;t["gamma"]=947;t["gammalatinsmall"]=611;t["gammasuperior"]=736;t["gangiacoptic"]=1003;t["gbopomofo"]=12557;t["gbreve"]=287;t["gcaron"]=487;t["gcedilla"]=291;t["gcircle"]=9430;t["gcircumflex"]=285;t["gcommaaccent"]=291;t["gdot"]=289;t["gdotaccent"]=289;t["gecyrillic"]=1075;t["gehiragana"]=12370;t["gekatakana"]=12466;t["geometricallyequal"]=8785;t["gereshaccenthebrew"]=1436;t["gereshhebrew"]=1523;t["gereshmuqdamhebrew"]=1437;t["germandbls"]=223;t["gershayimaccenthebrew"]=1438;t["gershayimhebrew"]=1524;t["getamark"]=12307;t["ghabengali"]=2456;t["ghadarmenian"]=1394;t["ghadeva"]=2328;t["ghagujarati"]=2712;t["ghagurmukhi"]=2584;t["ghainarabic"]=1594;t["ghainfinalarabic"]=65230;t["ghaininitialarabic"]=65231;t["ghainmedialarabic"]=65232;t["ghemiddlehookcyrillic"]=1173;t["ghestrokecyrillic"]=1171;t["gheupturncyrillic"]=1169;t["ghhadeva"]=2394;t["ghhagurmukhi"]=2650;t["ghook"]=608;t["ghzsquare"]=13203;t["gihiragana"]=12366;t["gikatakana"]=12462;t["gimarmenian"]=1379;t["gimel"]=1490;t["gimeldagesh"]=64306;t["gimeldageshhebrew"]=64306;t["gimelhebrew"]=1490;t["gjecyrillic"]=1107;t["glottalinvertedstroke"]=446;t["glottalstop"]=660;t["glottalstopinverted"]=662;t["glottalstopmod"]=704;t["glottalstopreversed"]=661;t["glottalstopreversedmod"]=705;t["glottalstopreversedsuperior"]=740;t["glottalstopstroke"]=673;t["glottalstopstrokereversed"]=674;t["gmacron"]=7713;t["gmonospace"]=65351;t["gohiragana"]=12372;t["gokatakana"]=12468;t["gparen"]=9378;t["gpasquare"]=13228;t["gradient"]=8711;t["grave"]=96;t["gravebelowcmb"]=790;t["gravecmb"]=768;t["gravecomb"]=768;t["gravedeva"]=2387;t["gravelowmod"]=718;t["gravemonospace"]=65344;t["gravetonecmb"]=832;t["greater"]=62;t["greaterequal"]=8805;t["greaterequalorless"]=8923;t["greatermonospace"]=65310;t["greaterorequivalent"]=8819;t["greaterorless"]=8823;t["greateroverequal"]=8807;t["greatersmall"]=65125;t["gscript"]=609;t["gstroke"]=485;t["guhiragana"]=12368;t["guillemotleft"]=171;t["guillemotright"]=187;t["guilsinglleft"]=8249;t["guilsinglright"]=8250;t["gukatakana"]=12464;t["guramusquare"]=13080;t["gysquare"]=13257;t["h"]=104;t["haabkhasiancyrillic"]=1193;t["haaltonearabic"]=1729;t["habengali"]=2489;t["hadescendercyrillic"]=1203;t["hadeva"]=2361;t["hagujarati"]=2745;t["hagurmukhi"]=2617;t["haharabic"]=1581;t["hahfinalarabic"]=65186;t["hahinitialarabic"]=65187;t["hahiragana"]=12399;t["hahmedialarabic"]=65188;t["haitusquare"]=13098;t["hakatakana"]=12495;t["hakatakanahalfwidth"]=65418;t["halantgurmukhi"]=2637;t["hamzaarabic"]=1569;t["hamzalowarabic"]=1569;t["hangulfiller"]=12644;t["hardsigncyrillic"]=1098;t["harpoonleftbarbup"]=8636;t["harpoonrightbarbup"]=8640;t["hasquare"]=13258;t["hatafpatah"]=1458;t["hatafpatah16"]=1458;t["hatafpatah23"]=1458;t["hatafpatah2f"]=1458;t["hatafpatahhebrew"]=1458;t["hatafpatahnarrowhebrew"]=1458;t["hatafpatahquarterhebrew"]=1458;t["hatafpatahwidehebrew"]=1458;t["hatafqamats"]=1459;t["hatafqamats1b"]=1459;t["hatafqamats28"]=1459;t["hatafqamats34"]=1459;t["hatafqamatshebrew"]=1459;t["hatafqamatsnarrowhebrew"]=1459;t["hatafqamatsquarterhebrew"]=1459;t["hatafqamatswidehebrew"]=1459;t["hatafsegol"]=1457;t["hatafsegol17"]=1457;t["hatafsegol24"]=1457;t["hatafsegol30"]=1457;t["hatafsegolhebrew"]=1457;t["hatafsegolnarrowhebrew"]=1457;t["hatafsegolquarterhebrew"]=1457;t["hatafsegolwidehebrew"]=1457;t["hbar"]=295;t["hbopomofo"]=12559;t["hbrevebelow"]=7723;t["hcedilla"]=7721;t["hcircle"]=9431;t["hcircumflex"]=293;t["hdieresis"]=7719;t["hdotaccent"]=7715;t["hdotbelow"]=7717;t["he"]=1492;t["heart"]=9829;t["heartsuitblack"]=9829;t["heartsuitwhite"]=9825;t["hedagesh"]=64308;t["hedageshhebrew"]=64308;t["hehaltonearabic"]=1729;t["heharabic"]=1607;t["hehebrew"]=1492;t["hehfinalaltonearabic"]=64423;t["hehfinalalttwoarabic"]=65258;t["hehfinalarabic"]=65258;t["hehhamzaabovefinalarabic"]=64421;t["hehhamzaaboveisolatedarabic"]=64420;t["hehinitialaltonearabic"]=64424;t["hehinitialarabic"]=65259;t["hehiragana"]=12408;t["hehmedialaltonearabic"]=64425;t["hehmedialarabic"]=65260;t["heiseierasquare"]=13179;t["hekatakana"]=12504;t["hekatakanahalfwidth"]=65421;t["hekutaarusquare"]=13110;t["henghook"]=615;t["herutusquare"]=13113;t["het"]=1495;t["hethebrew"]=1495;t["hhook"]=614;t["hhooksuperior"]=689;t["hieuhacirclekorean"]=12923;t["hieuhaparenkorean"]=12827;t["hieuhcirclekorean"]=12909;t["hieuhkorean"]=12622;t["hieuhparenkorean"]=12813;t["hihiragana"]=12402;t["hikatakana"]=12498;t["hikatakanahalfwidth"]=65419;t["hiriq"]=1460;t["hiriq14"]=1460;t["hiriq21"]=1460;t["hiriq2d"]=1460;t["hiriqhebrew"]=1460;t["hiriqnarrowhebrew"]=1460;t["hiriqquarterhebrew"]=1460;t["hiriqwidehebrew"]=1460;t["hlinebelow"]=7830;t["hmonospace"]=65352;t["hoarmenian"]=1392;t["hohipthai"]=3627;t["hohiragana"]=12411;t["hokatakana"]=12507;t["hokatakanahalfwidth"]=65422;t["holam"]=1465;t["holam19"]=1465;t["holam26"]=1465;t["holam32"]=1465;t["holamhebrew"]=1465;t["holamnarrowhebrew"]=1465;t["holamquarterhebrew"]=1465;t["holamwidehebrew"]=1465;t["honokhukthai"]=3630;t["hookabovecomb"]=777;t["hookcmb"]=777;t["hookpalatalizedbelowcmb"]=801;t["hookretroflexbelowcmb"]=802;t["hoonsquare"]=13122;t["horicoptic"]=1001;t["horizontalbar"]=8213;t["horncmb"]=795;t["hotsprings"]=9832;t["house"]=8962;t["hparen"]=9379;t["hsuperior"]=688;t["hturned"]=613;t["huhiragana"]=12405;t["huiitosquare"]=13107;t["hukatakana"]=12501;t["hukatakanahalfwidth"]=65420;t["hungarumlaut"]=733;t["hungarumlautcmb"]=779;t["hv"]=405;t["hyphen"]=45;t["hypheninferior"]=63205;t["hyphenmonospace"]=65293;t["hyphensmall"]=65123;t["hyphensuperior"]=63206;t["hyphentwo"]=8208;t["i"]=105;t["iacute"]=237;t["iacyrillic"]=1103;t["ibengali"]=2439;t["ibopomofo"]=12583;t["ibreve"]=301;t["icaron"]=464;t["icircle"]=9432;t["icircumflex"]=238;t["icyrillic"]=1110;t["idblgrave"]=521;t["ideographearthcircle"]=12943;t["ideographfirecircle"]=12939;t["ideographicallianceparen"]=12863;t["ideographiccallparen"]=12858;t["ideographiccentrecircle"]=12965;t["ideographicclose"]=12294;t["ideographiccomma"]=12289;t["ideographiccommaleft"]=65380;t["ideographiccongratulationparen"]=12855;t["ideographiccorrectcircle"]=12963;t["ideographicearthparen"]=12847;t["ideographicenterpriseparen"]=12861;t["ideographicexcellentcircle"]=12957;t["ideographicfestivalparen"]=12864;t["ideographicfinancialcircle"]=12950;t["ideographicfinancialparen"]=12854;t["ideographicfireparen"]=12843;t["ideographichaveparen"]=12850;t["ideographichighcircle"]=12964;t["ideographiciterationmark"]=12293;t["ideographiclaborcircle"]=12952;t["ideographiclaborparen"]=12856;t["ideographicleftcircle"]=12967;t["ideographiclowcircle"]=12966;t["ideographicmedicinecircle"]=12969;t["ideographicmetalparen"]=12846;t["ideographicmoonparen"]=12842;t["ideographicnameparen"]=12852;t["ideographicperiod"]=12290;t["ideographicprintcircle"]=12958;t["ideographicreachparen"]=12867;t["ideographicrepresentparen"]=12857;t["ideographicresourceparen"]=12862;t["ideographicrightcircle"]=12968;t["ideographicsecretcircle"]=12953;t["ideographicselfparen"]=12866;t["ideographicsocietyparen"]=12851;t["ideographicspace"]=12288;t["ideographicspecialparen"]=12853;t["ideographicstockparen"]=12849;t["ideographicstudyparen"]=12859;t["ideographicsunparen"]=12848;t["ideographicsuperviseparen"]=12860;t["ideographicwaterparen"]=12844;t["ideographicwoodparen"]=12845;t["ideographiczero"]=12295;t["ideographmetalcircle"]=12942;t["ideographmooncircle"]=12938;t["ideographnamecircle"]=12948;t["ideographsuncircle"]=12944;t["ideographwatercircle"]=12940;t["ideographwoodcircle"]=12941;t["ideva"]=2311;t["idieresis"]=239;t["idieresisacute"]=7727;t["idieresiscyrillic"]=1253;t["idotbelow"]=7883;t["iebrevecyrillic"]=1239;t["iecyrillic"]=1077;t["ieungacirclekorean"]=12917;t["ieungaparenkorean"]=12821;t["ieungcirclekorean"]=12903;t["ieungkorean"]=12615;t["ieungparenkorean"]=12807;t["igrave"]=236;t["igujarati"]=2695;t["igurmukhi"]=2567;t["ihiragana"]=12356;t["ihookabove"]=7881;t["iibengali"]=2440;t["iicyrillic"]=1080;t["iideva"]=2312;t["iigujarati"]=2696;t["iigurmukhi"]=2568;t["iimatragurmukhi"]=2624;t["iinvertedbreve"]=523;t["iishortcyrillic"]=1081;t["iivowelsignbengali"]=2496;t["iivowelsigndeva"]=2368;t["iivowelsigngujarati"]=2752;t["ij"]=307;t["ikatakana"]=12452;t["ikatakanahalfwidth"]=65394;t["ikorean"]=12643;t["ilde"]=732;t["iluyhebrew"]=1452;t["imacron"]=299;t["imacroncyrillic"]=1251;t["imageorapproximatelyequal"]=8787;t["imatragurmukhi"]=2623;t["imonospace"]=65353;t["increment"]=8710;t["infinity"]=8734;t["iniarmenian"]=1387;t["integral"]=8747;t["integralbottom"]=8993;t["integralbt"]=8993;t["integralex"]=63733;t["integraltop"]=8992;t["integraltp"]=8992;t["intersection"]=8745;t["intisquare"]=13061;t["invbullet"]=9688;t["invcircle"]=9689;t["invsmileface"]=9787;t["iocyrillic"]=1105;t["iogonek"]=303;t["iota"]=953;t["iotadieresis"]=970;t["iotadieresistonos"]=912;t["iotalatin"]=617;t["iotatonos"]=943;t["iparen"]=9380;t["irigurmukhi"]=2674;t["ismallhiragana"]=12355;t["ismallkatakana"]=12451;t["ismallkatakanahalfwidth"]=65384;t["issharbengali"]=2554;t["istroke"]=616;t["isuperior"]=63213;t["iterationhiragana"]=12445;t["iterationkatakana"]=12541;t["itilde"]=297;t["itildebelow"]=7725;t["iubopomofo"]=12585;t["iucyrillic"]=1102;t["ivowelsignbengali"]=2495;t["ivowelsigndeva"]=2367;t["ivowelsigngujarati"]=2751;t["izhitsacyrillic"]=1141;t["izhitsadblgravecyrillic"]=1143;t["j"]=106;t["jaarmenian"]=1393;t["jabengali"]=2460;t["jadeva"]=2332;t["jagujarati"]=2716;t["jagurmukhi"]=2588;t["jbopomofo"]=12560;t["jcaron"]=496;t["jcircle"]=9433;t["jcircumflex"]=309;t["jcrossedtail"]=669;t["jdotlessstroke"]=607;t["jecyrillic"]=1112;t["jeemarabic"]=1580;t["jeemfinalarabic"]=65182;t["jeeminitialarabic"]=65183;t["jeemmedialarabic"]=65184;t["jeharabic"]=1688;t["jehfinalarabic"]=64395;t["jhabengali"]=2461;t["jhadeva"]=2333;t["jhagujarati"]=2717;t["jhagurmukhi"]=2589;t["jheharmenian"]=1403;t["jis"]=12292;t["jmonospace"]=65354;t["jparen"]=9381;t["jsuperior"]=690;t["k"]=107;t["kabashkircyrillic"]=1185;t["kabengali"]=2453;t["kacute"]=7729;t["kacyrillic"]=1082;t["kadescendercyrillic"]=1179;t["kadeva"]=2325;t["kaf"]=1499;t["kafarabic"]=1603;t["kafdagesh"]=64315;t["kafdageshhebrew"]=64315;t["kaffinalarabic"]=65242;t["kafhebrew"]=1499;t["kafinitialarabic"]=65243;t["kafmedialarabic"]=65244;t["kafrafehebrew"]=64333;t["kagujarati"]=2709;t["kagurmukhi"]=2581;t["kahiragana"]=12363;t["kahookcyrillic"]=1220;t["kakatakana"]=12459;t["kakatakanahalfwidth"]=65398;t["kappa"]=954;t["kappasymbolgreek"]=1008;t["kapyeounmieumkorean"]=12657;t["kapyeounphieuphkorean"]=12676;t["kapyeounpieupkorean"]=12664;t["kapyeounssangpieupkorean"]=12665;t["karoriisquare"]=13069;t["kashidaautoarabic"]=1600;t["kashidaautonosidebearingarabic"]=1600;t["kasmallkatakana"]=12533;t["kasquare"]=13188;t["kasraarabic"]=1616;t["kasratanarabic"]=1613;t["kastrokecyrillic"]=1183;t["katahiraprolongmarkhalfwidth"]=65392;t["kaverticalstrokecyrillic"]=1181;t["kbopomofo"]=12558;t["kcalsquare"]=13193;t["kcaron"]=489;t["kcedilla"]=311;t["kcircle"]=9434;t["kcommaaccent"]=311;t["kdotbelow"]=7731;t["keharmenian"]=1412;t["kehiragana"]=12369;t["kekatakana"]=12465;t["kekatakanahalfwidth"]=65401;t["kenarmenian"]=1391;t["kesmallkatakana"]=12534;t["kgreenlandic"]=312;t["khabengali"]=2454;t["khacyrillic"]=1093;t["khadeva"]=2326;t["khagujarati"]=2710;t["khagurmukhi"]=2582;t["khaharabic"]=1582;t["khahfinalarabic"]=65190;t["khahinitialarabic"]=65191;t["khahmedialarabic"]=65192;t["kheicoptic"]=999;t["khhadeva"]=2393;t["khhagurmukhi"]=2649;t["khieukhacirclekorean"]=12920;t["khieukhaparenkorean"]=12824;t["khieukhcirclekorean"]=12906;t["khieukhkorean"]=12619;t["khieukhparenkorean"]=12810;t["khokhaithai"]=3586;t["khokhonthai"]=3589;t["khokhuatthai"]=3587;t["khokhwaithai"]=3588;t["khomutthai"]=3675;t["khook"]=409;t["khorakhangthai"]=3590;t["khzsquare"]=13201;t["kihiragana"]=12365;t["kikatakana"]=12461;t["kikatakanahalfwidth"]=65399;t["kiroguramusquare"]=13077;t["kiromeetorusquare"]=13078;t["kirosquare"]=13076;t["kiyeokacirclekorean"]=12910;t["kiyeokaparenkorean"]=12814;t["kiyeokcirclekorean"]=12896;t["kiyeokkorean"]=12593;t["kiyeokparenkorean"]=12800;t["kiyeoksioskorean"]=12595;t["kjecyrillic"]=1116;t["klinebelow"]=7733;t["klsquare"]=13208;t["kmcubedsquare"]=13222;t["kmonospace"]=65355;t["kmsquaredsquare"]=13218;t["kohiragana"]=12371;t["kohmsquare"]=13248;t["kokaithai"]=3585;t["kokatakana"]=12467;t["kokatakanahalfwidth"]=65402;t["kooposquare"]=13086;t["koppacyrillic"]=1153;t["koreanstandardsymbol"]=12927;t["koroniscmb"]=835;t["kparen"]=9382;t["kpasquare"]=13226;t["ksicyrillic"]=1135;t["ktsquare"]=13263;t["kturned"]=670;t["kuhiragana"]=12367;t["kukatakana"]=12463;t["kukatakanahalfwidth"]=65400;t["kvsquare"]=13240;t["kwsquare"]=13246;t["l"]=108;t["labengali"]=2482;t["lacute"]=314;t["ladeva"]=2354;t["lagujarati"]=2738;t["lagurmukhi"]=2610;t["lakkhangyaothai"]=3653;t["lamaleffinalarabic"]=65276;t["lamalefhamzaabovefinalarabic"]=65272;t["lamalefhamzaaboveisolatedarabic"]=65271;t["lamalefhamzabelowfinalarabic"]=65274;t["lamalefhamzabelowisolatedarabic"]=65273;t["lamalefisolatedarabic"]=65275;t["lamalefmaddaabovefinalarabic"]=65270;t["lamalefmaddaaboveisolatedarabic"]=65269;t["lamarabic"]=1604;t["lambda"]=955;t["lambdastroke"]=411;t["lamed"]=1500;t["lameddagesh"]=64316;t["lameddageshhebrew"]=64316;t["lamedhebrew"]=1500;t["lamfinalarabic"]=65246;t["lamhahinitialarabic"]=64714;t["laminitialarabic"]=65247;t["lamjeeminitialarabic"]=64713;t["lamkhahinitialarabic"]=64715;t["lamlamhehisolatedarabic"]=65010;t["lammedialarabic"]=65248;t["lammeemhahinitialarabic"]=64904;t["lammeeminitialarabic"]=64716;t["largecircle"]=9711;t["lbar"]=410;t["lbelt"]=620;t["lbopomofo"]=12556;t["lcaron"]=318;t["lcedilla"]=316;t["lcircle"]=9435;t["lcircumflexbelow"]=7741;t["lcommaaccent"]=316;t["ldot"]=320;t["ldotaccent"]=320;t["ldotbelow"]=7735;t["ldotbelowmacron"]=7737;t["leftangleabovecmb"]=794;t["lefttackbelowcmb"]=792;t["less"]=60;t["lessequal"]=8804;t["lessequalorgreater"]=8922;t["lessmonospace"]=65308;t["lessorequivalent"]=8818;t["lessorgreater"]=8822;t["lessoverequal"]=8806;t["lesssmall"]=65124;t["lezh"]=622;t["lfblock"]=9612;t["lhookretroflex"]=621;t["lira"]=8356;t["liwnarmenian"]=1388;t["lj"]=457;t["ljecyrillic"]=1113;t["ll"]=63168;t["lladeva"]=2355;t["llagujarati"]=2739;t["llinebelow"]=7739;t["llladeva"]=2356;t["llvocalicbengali"]=2529;t["llvocalicdeva"]=2401;t["llvocalicvowelsignbengali"]=2531;t["llvocalicvowelsigndeva"]=2403;t["lmiddletilde"]=619;t["lmonospace"]=65356;t["lmsquare"]=13264;t["lochulathai"]=3628;t["logicaland"]=8743;t["logicalnot"]=172;t["logicalnotreversed"]=8976;t["logicalor"]=8744;t["lolingthai"]=3621;t["longs"]=383;t["lowlinecenterline"]=65102;t["lowlinecmb"]=818;t["lowlinedashed"]=65101;t["lozenge"]=9674;t["lparen"]=9383;t["lslash"]=322;t["lsquare"]=8467;t["lsuperior"]=63214;t["ltshade"]=9617;t["luthai"]=3622;t["lvocalicbengali"]=2444;t["lvocalicdeva"]=2316;t["lvocalicvowelsignbengali"]=2530;t["lvocalicvowelsigndeva"]=2402;t["lxsquare"]=13267;t["m"]=109;t["mabengali"]=2478;t["macron"]=175;t["macronbelowcmb"]=817;t["macroncmb"]=772;t["macronlowmod"]=717;t["macronmonospace"]=65507;t["macute"]=7743;t["madeva"]=2350;t["magujarati"]=2734;t["magurmukhi"]=2606;t["mahapakhhebrew"]=1444;t["mahapakhlefthebrew"]=1444;t["mahiragana"]=12414;t["maichattawalowleftthai"]=63637;t["maichattawalowrightthai"]=63636;t["maichattawathai"]=3659;t["maichattawaupperleftthai"]=63635;t["maieklowleftthai"]=63628;t["maieklowrightthai"]=63627;t["maiekthai"]=3656;t["maiekupperleftthai"]=63626;t["maihanakatleftthai"]=63620;t["maihanakatthai"]=3633;t["maitaikhuleftthai"]=63625;t["maitaikhuthai"]=3655;t["maitholowleftthai"]=63631;t["maitholowrightthai"]=63630;t["maithothai"]=3657;t["maithoupperleftthai"]=63629;t["maitrilowleftthai"]=63634;t["maitrilowrightthai"]=63633;t["maitrithai"]=3658;t["maitriupperleftthai"]=63632;t["maiyamokthai"]=3654;t["makatakana"]=12510;t["makatakanahalfwidth"]=65423;t["male"]=9794;t["mansyonsquare"]=13127;t["maqafhebrew"]=1470;t["mars"]=9794;t["masoracirclehebrew"]=1455;t["masquare"]=13187;t["mbopomofo"]=12551;t["mbsquare"]=13268;t["mcircle"]=9436;t["mcubedsquare"]=13221;t["mdotaccent"]=7745;t["mdotbelow"]=7747;t["meemarabic"]=1605;t["meemfinalarabic"]=65250;t["meeminitialarabic"]=65251;t["meemmedialarabic"]=65252;t["meemmeeminitialarabic"]=64721;t["meemmeemisolatedarabic"]=64584;t["meetorusquare"]=13133;t["mehiragana"]=12417;t["meizierasquare"]=13182;t["mekatakana"]=12513;t["mekatakanahalfwidth"]=65426;t["mem"]=1502;t["memdagesh"]=64318;t["memdageshhebrew"]=64318;t["memhebrew"]=1502;t["menarmenian"]=1396;t["merkhahebrew"]=1445;t["merkhakefulahebrew"]=1446;t["merkhakefulalefthebrew"]=1446;t["merkhalefthebrew"]=1445;t["mhook"]=625;t["mhzsquare"]=13202;t["middledotkatakanahalfwidth"]=65381;t["middot"]=183;t["mieumacirclekorean"]=12914;t["mieumaparenkorean"]=12818;t["mieumcirclekorean"]=12900;t["mieumkorean"]=12609;t["mieumpansioskorean"]=12656;t["mieumparenkorean"]=12804;t["mieumpieupkorean"]=12654;t["mieumsioskorean"]=12655;t["mihiragana"]=12415;t["mikatakana"]=12511;t["mikatakanahalfwidth"]=65424;t["minus"]=8722;t["minusbelowcmb"]=800;t["minuscircle"]=8854;t["minusmod"]=727;t["minusplus"]=8723;t["minute"]=8242;t["miribaarusquare"]=13130;t["mirisquare"]=13129;t["mlonglegturned"]=624;t["mlsquare"]=13206;t["mmcubedsquare"]=13219;t["mmonospace"]=65357;t["mmsquaredsquare"]=13215;t["mohiragana"]=12418;t["mohmsquare"]=13249;t["mokatakana"]=12514;t["mokatakanahalfwidth"]=65427;t["molsquare"]=13270;t["momathai"]=3617;t["moverssquare"]=13223;t["moverssquaredsquare"]=13224;t["mparen"]=9384;t["mpasquare"]=13227;t["mssquare"]=13235;t["msuperior"]=63215;t["mturned"]=623;t["mu"]=181;t["mu1"]=181;t["muasquare"]=13186;t["muchgreater"]=8811;t["muchless"]=8810;t["mufsquare"]=13196;t["mugreek"]=956;t["mugsquare"]=13197;t["muhiragana"]=12416;t["mukatakana"]=12512;t["mukatakanahalfwidth"]=65425;t["mulsquare"]=13205;t["multiply"]=215;t["mumsquare"]=13211;t["munahhebrew"]=1443;t["munahlefthebrew"]=1443;t["musicalnote"]=9834;t["musicalnotedbl"]=9835;t["musicflatsign"]=9837;t["musicsharpsign"]=9839;t["mussquare"]=13234;t["muvsquare"]=13238;t["muwsquare"]=13244;t["mvmegasquare"]=13241;t["mvsquare"]=13239;t["mwmegasquare"]=13247;t["mwsquare"]=13245;t["n"]=110;t["nabengali"]=2472;t["nabla"]=8711;t["nacute"]=324;t["nadeva"]=2344;t["nagujarati"]=2728;t["nagurmukhi"]=2600;t["nahiragana"]=12394;t["nakatakana"]=12490;t["nakatakanahalfwidth"]=65413;t["napostrophe"]=329;t["nasquare"]=13185;t["nbopomofo"]=12555;t["nbspace"]=160;t["ncaron"]=328;t["ncedilla"]=326;t["ncircle"]=9437;t["ncircumflexbelow"]=7755;t["ncommaaccent"]=326;t["ndotaccent"]=7749;t["ndotbelow"]=7751;t["nehiragana"]=12397;t["nekatakana"]=12493;t["nekatakanahalfwidth"]=65416;t["newsheqelsign"]=8362;t["nfsquare"]=13195;t["ngabengali"]=2457;t["ngadeva"]=2329;t["ngagujarati"]=2713;t["ngagurmukhi"]=2585;t["ngonguthai"]=3591;t["nhiragana"]=12435;t["nhookleft"]=626;t["nhookretroflex"]=627;t["nieunacirclekorean"]=12911;t["nieunaparenkorean"]=12815;t["nieuncieuckorean"]=12597;t["nieuncirclekorean"]=12897;t["nieunhieuhkorean"]=12598;t["nieunkorean"]=12596;t["nieunpansioskorean"]=12648;t["nieunparenkorean"]=12801;t["nieunsioskorean"]=12647;t["nieuntikeutkorean"]=12646;t["nihiragana"]=12395;t["nikatakana"]=12491;t["nikatakanahalfwidth"]=65414;t["nikhahitleftthai"]=63641;t["nikhahitthai"]=3661;t["nine"]=57;t["ninearabic"]=1641;t["ninebengali"]=2543;t["ninecircle"]=9320;t["ninecircleinversesansserif"]=10130;t["ninedeva"]=2415;t["ninegujarati"]=2799;t["ninegurmukhi"]=2671;t["ninehackarabic"]=1641;t["ninehangzhou"]=12329;t["nineideographicparen"]=12840;t["nineinferior"]=8329;t["ninemonospace"]=65305;t["nineoldstyle"]=63289;t["nineparen"]=9340;t["nineperiod"]=9360;t["ninepersian"]=1785;t["nineroman"]=8568;t["ninesuperior"]=8313;t["nineteencircle"]=9330;t["nineteenparen"]=9350;t["nineteenperiod"]=9370;t["ninethai"]=3673;t["nj"]=460;t["njecyrillic"]=1114;t["nkatakana"]=12531;t["nkatakanahalfwidth"]=65437;t["nlegrightlong"]=414;t["nlinebelow"]=7753;t["nmonospace"]=65358;t["nmsquare"]=13210;t["nnabengali"]=2467;t["nnadeva"]=2339;t["nnagujarati"]=2723;t["nnagurmukhi"]=2595;t["nnnadeva"]=2345;t["nohiragana"]=12398;t["nokatakana"]=12494;t["nokatakanahalfwidth"]=65417;t["nonbreakingspace"]=160;t["nonenthai"]=3603;t["nonuthai"]=3609;t["noonarabic"]=1606;t["noonfinalarabic"]=65254;t["noonghunnaarabic"]=1722;t["noonghunnafinalarabic"]=64415;t["nooninitialarabic"]=65255;t["noonjeeminitialarabic"]=64722;t["noonjeemisolatedarabic"]=64587;t["noonmedialarabic"]=65256;t["noonmeeminitialarabic"]=64725;t["noonmeemisolatedarabic"]=64590;t["noonnoonfinalarabic"]=64653;t["notcontains"]=8716;t["notelement"]=8713;t["notelementof"]=8713;t["notequal"]=8800;t["notgreater"]=8815;t["notgreaternorequal"]=8817;t["notgreaternorless"]=8825;t["notidentical"]=8802;t["notless"]=8814;t["notlessnorequal"]=8816;t["notparallel"]=8742;t["notprecedes"]=8832;t["notsubset"]=8836;t["notsucceeds"]=8833;t["notsuperset"]=8837;t["nowarmenian"]=1398;t["nparen"]=9385;t["nssquare"]=13233;t["nsuperior"]=8319;t["ntilde"]=241;t["nu"]=957;t["nuhiragana"]=12396;t["nukatakana"]=12492;t["nukatakanahalfwidth"]=65415;t["nuktabengali"]=2492;t["nuktadeva"]=2364;t["nuktagujarati"]=2748;t["nuktagurmukhi"]=2620;t["numbersign"]=35;t["numbersignmonospace"]=65283;t["numbersignsmall"]=65119;t["numeralsigngreek"]=884;t["numeralsignlowergreek"]=885;t["numero"]=8470;t["nun"]=1504;t["nundagesh"]=64320;t["nundageshhebrew"]=64320;t["nunhebrew"]=1504;t["nvsquare"]=13237;t["nwsquare"]=13243;t["nyabengali"]=2462;t["nyadeva"]=2334;t["nyagujarati"]=2718;t["nyagurmukhi"]=2590;t["o"]=111;t["oacute"]=243;t["oangthai"]=3629;t["obarred"]=629;t["obarredcyrillic"]=1257;t["obarreddieresiscyrillic"]=1259;t["obengali"]=2451;t["obopomofo"]=12571;t["obreve"]=335;t["ocandradeva"]=2321;t["ocandragujarati"]=2705;t["ocandravowelsigndeva"]=2377;t["ocandravowelsigngujarati"]=2761;t["ocaron"]=466;t["ocircle"]=9438;t["ocircumflex"]=244;t["ocircumflexacute"]=7889;t["ocircumflexdotbelow"]=7897;t["ocircumflexgrave"]=7891;t["ocircumflexhookabove"]=7893;t["ocircumflextilde"]=7895;t["ocyrillic"]=1086;t["odblacute"]=337;t["odblgrave"]=525;t["odeva"]=2323;t["odieresis"]=246;t["odieresiscyrillic"]=1255;t["odotbelow"]=7885;t["oe"]=339;t["oekorean"]=12634;t["ogonek"]=731;t["ogonekcmb"]=808;t["ograve"]=242;t["ogujarati"]=2707;t["oharmenian"]=1413;t["ohiragana"]=12362;t["ohookabove"]=7887;t["ohorn"]=417;t["ohornacute"]=7899;t["ohorndotbelow"]=7907;t["ohorngrave"]=7901;t["ohornhookabove"]=7903;t["ohorntilde"]=7905;t["ohungarumlaut"]=337;t["oi"]=419;t["oinvertedbreve"]=527;t["okatakana"]=12458;t["okatakanahalfwidth"]=65397;t["okorean"]=12631;t["olehebrew"]=1451;t["omacron"]=333;t["omacronacute"]=7763;t["omacrongrave"]=7761;t["omdeva"]=2384;t["omega"]=969;t["omega1"]=982;t["omegacyrillic"]=1121;t["omegalatinclosed"]=631;t["omegaroundcyrillic"]=1147;t["omegatitlocyrillic"]=1149;t["omegatonos"]=974;t["omgujarati"]=2768;t["omicron"]=959;t["omicrontonos"]=972;t["omonospace"]=65359;t["one"]=49;t["onearabic"]=1633;t["onebengali"]=2535;t["onecircle"]=9312;t["onecircleinversesansserif"]=10122;t["onedeva"]=2407;t["onedotenleader"]=8228;t["oneeighth"]=8539;t["onefitted"]=63196;t["onegujarati"]=2791;t["onegurmukhi"]=2663;t["onehackarabic"]=1633;t["onehalf"]=189;t["onehangzhou"]=12321;t["oneideographicparen"]=12832;t["oneinferior"]=8321;t["onemonospace"]=65297;t["onenumeratorbengali"]=2548;t["oneoldstyle"]=63281;t["oneparen"]=9332;t["oneperiod"]=9352;t["onepersian"]=1777;t["onequarter"]=188;t["oneroman"]=8560;t["onesuperior"]=185;t["onethai"]=3665;t["onethird"]=8531;t["oogonek"]=491;t["oogonekmacron"]=493;t["oogurmukhi"]=2579;t["oomatragurmukhi"]=2635;t["oopen"]=596;t["oparen"]=9386;t["openbullet"]=9702;t["option"]=8997;t["ordfeminine"]=170;t["ordmasculine"]=186;t["orthogonal"]=8735;t["oshortdeva"]=2322;t["oshortvowelsigndeva"]=2378;t["oslash"]=248;t["oslashacute"]=511;t["osmallhiragana"]=12361;t["osmallkatakana"]=12457;t["osmallkatakanahalfwidth"]=65387;t["ostrokeacute"]=511;t["osuperior"]=63216;t["otcyrillic"]=1151;t["otilde"]=245;t["otildeacute"]=7757;t["otildedieresis"]=7759;t["oubopomofo"]=12577;t["overline"]=8254;t["overlinecenterline"]=65098;t["overlinecmb"]=773;t["overlinedashed"]=65097;t["overlinedblwavy"]=65100;t["overlinewavy"]=65099;t["overscore"]=175;t["ovowelsignbengali"]=2507;t["ovowelsigndeva"]=2379;t["ovowelsigngujarati"]=2763;t["p"]=112;t["paampssquare"]=13184;t["paasentosquare"]=13099;t["pabengali"]=2474;t["pacute"]=7765;t["padeva"]=2346;t["pagedown"]=8671;t["pageup"]=8670;t["pagujarati"]=2730;t["pagurmukhi"]=2602;t["pahiragana"]=12401;t["paiyannoithai"]=3631;t["pakatakana"]=12497;t["palatalizationcyrilliccmb"]=1156;t["palochkacyrillic"]=1216;t["pansioskorean"]=12671;t["paragraph"]=182;t["parallel"]=8741;t["parenleft"]=40;t["parenleftaltonearabic"]=64830;t["parenleftbt"]=63725;t["parenleftex"]=63724;t["parenleftinferior"]=8333;t["parenleftmonospace"]=65288;t["parenleftsmall"]=65113;t["parenleftsuperior"]=8317;t["parenlefttp"]=63723;t["parenleftvertical"]=65077;t["parenright"]=41;t["parenrightaltonearabic"]=64831;t["parenrightbt"]=63736;t["parenrightex"]=63735;t["parenrightinferior"]=8334;t["parenrightmonospace"]=65289;t["parenrightsmall"]=65114;t["parenrightsuperior"]=8318;t["parenrighttp"]=63734;t["parenrightvertical"]=65078;t["partialdiff"]=8706;t["paseqhebrew"]=1472;t["pashtahebrew"]=1433;t["pasquare"]=13225;t["patah"]=1463;t["patah11"]=1463;t["patah1d"]=1463;t["patah2a"]=1463;t["patahhebrew"]=1463;t["patahnarrowhebrew"]=1463;t["patahquarterhebrew"]=1463;t["patahwidehebrew"]=1463;t["pazerhebrew"]=1441;t["pbopomofo"]=12550;t["pcircle"]=9439;t["pdotaccent"]=7767;t["pe"]=1508;t["pecyrillic"]=1087;t["pedagesh"]=64324;t["pedageshhebrew"]=64324;t["peezisquare"]=13115;t["pefinaldageshhebrew"]=64323;t["peharabic"]=1662;t["peharmenian"]=1402;t["pehebrew"]=1508;t["pehfinalarabic"]=64343;t["pehinitialarabic"]=64344;t["pehiragana"]=12410;t["pehmedialarabic"]=64345;t["pekatakana"]=12506;t["pemiddlehookcyrillic"]=1191;t["perafehebrew"]=64334;t["percent"]=37;t["percentarabic"]=1642;t["percentmonospace"]=65285;t["percentsmall"]=65130;t["period"]=46;t["periodarmenian"]=1417;t["periodcentered"]=183;t["periodhalfwidth"]=65377;t["periodinferior"]=63207;t["periodmonospace"]=65294;t["periodsmall"]=65106;t["periodsuperior"]=63208;t["perispomenigreekcmb"]=834;t["perpendicular"]=8869;t["perthousand"]=8240;t["peseta"]=8359;t["pfsquare"]=13194;t["phabengali"]=2475;t["phadeva"]=2347;t["phagujarati"]=2731;t["phagurmukhi"]=2603;t["phi"]=966;t["phi1"]=981;t["phieuphacirclekorean"]=12922;t["phieuphaparenkorean"]=12826;t["phieuphcirclekorean"]=12908;t["phieuphkorean"]=12621;t["phieuphparenkorean"]=12812;t["philatin"]=632;t["phinthuthai"]=3642;t["phisymbolgreek"]=981;t["phook"]=421;t["phophanthai"]=3614;t["phophungthai"]=3612;t["phosamphaothai"]=3616;t["pi"]=960;t["pieupacirclekorean"]=12915;t["pieupaparenkorean"]=12819;t["pieupcieuckorean"]=12662;t["pieupcirclekorean"]=12901;t["pieupkiyeokkorean"]=12658;t["pieupkorean"]=12610;t["pieupparenkorean"]=12805;t["pieupsioskiyeokkorean"]=12660;t["pieupsioskorean"]=12612;t["pieupsiostikeutkorean"]=12661;t["pieupthieuthkorean"]=12663;t["pieuptikeutkorean"]=12659;t["pihiragana"]=12404;t["pikatakana"]=12500;t["pisymbolgreek"]=982;t["piwrarmenian"]=1411;t["plus"]=43;t["plusbelowcmb"]=799;t["pluscircle"]=8853;t["plusminus"]=177;t["plusmod"]=726;t["plusmonospace"]=65291;t["plussmall"]=65122;t["plussuperior"]=8314;t["pmonospace"]=65360;t["pmsquare"]=13272;t["pohiragana"]=12413;t["pointingindexdownwhite"]=9759;t["pointingindexleftwhite"]=9756;t["pointingindexrightwhite"]=9758;t["pointingindexupwhite"]=9757;t["pokatakana"]=12509;t["poplathai"]=3611;t["postalmark"]=12306;t["postalmarkface"]=12320;t["pparen"]=9387;t["precedes"]=8826;t["prescription"]=8478;t["primemod"]=697;t["primereversed"]=8245;t["product"]=8719;t["projective"]=8965;t["prolongedkana"]=12540;t["propellor"]=8984;t["propersubset"]=8834;t["propersuperset"]=8835;t["proportion"]=8759;t["proportional"]=8733;t["psi"]=968;t["psicyrillic"]=1137;t["psilipneumatacyrilliccmb"]=1158;t["pssquare"]=13232;t["puhiragana"]=12407;t["pukatakana"]=12503;t["pvsquare"]=13236;t["pwsquare"]=13242;t["q"]=113;t["qadeva"]=2392;t["qadmahebrew"]=1448;t["qafarabic"]=1602;t["qaffinalarabic"]=65238;t["qafinitialarabic"]=65239;t["qafmedialarabic"]=65240;t["qamats"]=1464;t["qamats10"]=1464;t["qamats1a"]=1464;t["qamats1c"]=1464;t["qamats27"]=1464;t["qamats29"]=1464;t["qamats33"]=1464;t["qamatsde"]=1464;t["qamatshebrew"]=1464;t["qamatsnarrowhebrew"]=1464;t["qamatsqatanhebrew"]=1464;t["qamatsqatannarrowhebrew"]=1464;t["qamatsqatanquarterhebrew"]=1464;t["qamatsqatanwidehebrew"]=1464;t["qamatsquarterhebrew"]=1464;t["qamatswidehebrew"]=1464;t["qarneyparahebrew"]=1439;t["qbopomofo"]=12561;t["qcircle"]=9440;t["qhook"]=672;t["qmonospace"]=65361;t["qof"]=1511;t["qofdagesh"]=64327;t["qofdageshhebrew"]=64327;t["qofhebrew"]=1511;t["qparen"]=9388;t["quarternote"]=9833;t["qubuts"]=1467;t["qubuts18"]=1467;t["qubuts25"]=1467;t["qubuts31"]=1467;t["qubutshebrew"]=1467;t["qubutsnarrowhebrew"]=1467;t["qubutsquarterhebrew"]=1467;t["qubutswidehebrew"]=1467;t["question"]=63;t["questionarabic"]=1567;t["questionarmenian"]=1374;t["questiondown"]=191;t["questiondownsmall"]=63423;t["questiongreek"]=894;t["questionmonospace"]=65311;t["questionsmall"]=63295;t["quotedbl"]=34;t["quotedblbase"]=8222;t["quotedblleft"]=8220;t["quotedblmonospace"]=65282;t["quotedblprime"]=12318;t["quotedblprimereversed"]=12317;t["quotedblright"]=8221;t["quoteleft"]=8216;t["quoteleftreversed"]=8219;t["quotereversed"]=8219;t["quoteright"]=8217;t["quoterightn"]=329;t["quotesinglbase"]=8218;t["quotesingle"]=39;t["quotesinglemonospace"]=65287;t["r"]=114;t["raarmenian"]=1404;
7t["rabengali"]=2480;t["racute"]=341;t["radeva"]=2352;t["radical"]=8730;t["radicalex"]=63717;t["radoverssquare"]=13230;t["radoverssquaredsquare"]=13231;t["radsquare"]=13229;t["rafe"]=1471;t["rafehebrew"]=1471;t["ragujarati"]=2736;t["ragurmukhi"]=2608;t["rahiragana"]=12425;t["rakatakana"]=12521;t["rakatakanahalfwidth"]=65431;t["ralowerdiagonalbengali"]=2545;t["ramiddlediagonalbengali"]=2544;t["ramshorn"]=612;t["ratio"]=8758;t["rbopomofo"]=12566;t["rcaron"]=345;t["rcedilla"]=343;t["rcircle"]=9441;t["rcommaaccent"]=343;t["rdblgrave"]=529;t["rdotaccent"]=7769;t["rdotbelow"]=7771;t["rdotbelowmacron"]=7773;t["referencemark"]=8251;t["reflexsubset"]=8838;t["reflexsuperset"]=8839;t["registered"]=174;t["registersans"]=63720;t["registerserif"]=63194;t["reharabic"]=1585;t["reharmenian"]=1408;t["rehfinalarabic"]=65198;t["rehiragana"]=12428;t["rekatakana"]=12524;t["rekatakanahalfwidth"]=65434;t["resh"]=1512;t["reshdageshhebrew"]=64328;t["reshhebrew"]=1512;t["reversedtilde"]=8765;t["reviahebrew"]=1431;t["reviamugrashhebrew"]=1431;t["revlogicalnot"]=8976;t["rfishhook"]=638;t["rfishhookreversed"]=639;t["rhabengali"]=2525;t["rhadeva"]=2397;t["rho"]=961;t["rhook"]=637;t["rhookturned"]=635;t["rhookturnedsuperior"]=693;t["rhosymbolgreek"]=1009;t["rhotichookmod"]=734;t["rieulacirclekorean"]=12913;t["rieulaparenkorean"]=12817;t["rieulcirclekorean"]=12899;t["rieulhieuhkorean"]=12608;t["rieulkiyeokkorean"]=12602;t["rieulkiyeoksioskorean"]=12649;t["rieulkorean"]=12601;t["rieulmieumkorean"]=12603;t["rieulpansioskorean"]=12652;t["rieulparenkorean"]=12803;t["rieulphieuphkorean"]=12607;t["rieulpieupkorean"]=12604;t["rieulpieupsioskorean"]=12651;t["rieulsioskorean"]=12605;t["rieulthieuthkorean"]=12606;t["rieultikeutkorean"]=12650;t["rieulyeorinhieuhkorean"]=12653;t["rightangle"]=8735;t["righttackbelowcmb"]=793;t["righttriangle"]=8895;t["rihiragana"]=12426;t["rikatakana"]=12522;t["rikatakanahalfwidth"]=65432;t["ring"]=730;t["ringbelowcmb"]=805;t["ringcmb"]=778;t["ringhalfleft"]=703;t["ringhalfleftarmenian"]=1369;t["ringhalfleftbelowcmb"]=796;t["ringhalfleftcentered"]=723;t["ringhalfright"]=702;t["ringhalfrightbelowcmb"]=825;t["ringhalfrightcentered"]=722;t["rinvertedbreve"]=531;t["rittorusquare"]=13137;t["rlinebelow"]=7775;t["rlongleg"]=636;t["rlonglegturned"]=634;t["rmonospace"]=65362;t["rohiragana"]=12429;t["rokatakana"]=12525;t["rokatakanahalfwidth"]=65435;t["roruathai"]=3619;t["rparen"]=9389;t["rrabengali"]=2524;t["rradeva"]=2353;t["rragurmukhi"]=2652;t["rreharabic"]=1681;t["rrehfinalarabic"]=64397;t["rrvocalicbengali"]=2528;t["rrvocalicdeva"]=2400;t["rrvocalicgujarati"]=2784;t["rrvocalicvowelsignbengali"]=2500;t["rrvocalicvowelsigndeva"]=2372;t["rrvocalicvowelsigngujarati"]=2756;t["rsuperior"]=63217;t["rtblock"]=9616;t["rturned"]=633;t["rturnedsuperior"]=692;t["ruhiragana"]=12427;t["rukatakana"]=12523;t["rukatakanahalfwidth"]=65433;t["rupeemarkbengali"]=2546;t["rupeesignbengali"]=2547;t["rupiah"]=63197;t["ruthai"]=3620;t["rvocalicbengali"]=2443;t["rvocalicdeva"]=2315;t["rvocalicgujarati"]=2699;t["rvocalicvowelsignbengali"]=2499;t["rvocalicvowelsigndeva"]=2371;t["rvocalicvowelsigngujarati"]=2755;t["s"]=115;t["sabengali"]=2488;t["sacute"]=347;t["sacutedotaccent"]=7781;t["sadarabic"]=1589;t["sadeva"]=2360;t["sadfinalarabic"]=65210;t["sadinitialarabic"]=65211;t["sadmedialarabic"]=65212;t["sagujarati"]=2744;t["sagurmukhi"]=2616;t["sahiragana"]=12373;t["sakatakana"]=12469;t["sakatakanahalfwidth"]=65403;t["sallallahoualayhewasallamarabic"]=65018;t["samekh"]=1505;t["samekhdagesh"]=64321;t["samekhdageshhebrew"]=64321;t["samekhhebrew"]=1505;t["saraaathai"]=3634;t["saraaethai"]=3649;t["saraaimaimalaithai"]=3652;t["saraaimaimuanthai"]=3651;t["saraamthai"]=3635;t["saraathai"]=3632;t["saraethai"]=3648;t["saraiileftthai"]=63622;t["saraiithai"]=3637;t["saraileftthai"]=63621;t["saraithai"]=3636;t["saraothai"]=3650;t["saraueeleftthai"]=63624;t["saraueethai"]=3639;t["saraueleftthai"]=63623;t["sarauethai"]=3638;t["sarauthai"]=3640;t["sarauuthai"]=3641;t["sbopomofo"]=12569;t["scaron"]=353;t["scarondotaccent"]=7783;t["scedilla"]=351;t["schwa"]=601;t["schwacyrillic"]=1241;t["schwadieresiscyrillic"]=1243;t["schwahook"]=602;t["scircle"]=9442;t["scircumflex"]=349;t["scommaaccent"]=537;t["sdotaccent"]=7777;t["sdotbelow"]=7779;t["sdotbelowdotaccent"]=7785;t["seagullbelowcmb"]=828;t["second"]=8243;t["secondtonechinese"]=714;t["section"]=167;t["seenarabic"]=1587;t["seenfinalarabic"]=65202;t["seeninitialarabic"]=65203;t["seenmedialarabic"]=65204;t["segol"]=1462;t["segol13"]=1462;t["segol1f"]=1462;t["segol2c"]=1462;t["segolhebrew"]=1462;t["segolnarrowhebrew"]=1462;t["segolquarterhebrew"]=1462;t["segoltahebrew"]=1426;t["segolwidehebrew"]=1462;t["seharmenian"]=1405;t["sehiragana"]=12379;t["sekatakana"]=12475;t["sekatakanahalfwidth"]=65406;t["semicolon"]=59;t["semicolonarabic"]=1563;t["semicolonmonospace"]=65307;t["semicolonsmall"]=65108;t["semivoicedmarkkana"]=12444;t["semivoicedmarkkanahalfwidth"]=65439;t["sentisquare"]=13090;t["sentosquare"]=13091;t["seven"]=55;t["sevenarabic"]=1639;t["sevenbengali"]=2541;t["sevencircle"]=9318;t["sevencircleinversesansserif"]=10128;t["sevendeva"]=2413;t["seveneighths"]=8542;t["sevengujarati"]=2797;t["sevengurmukhi"]=2669;t["sevenhackarabic"]=1639;t["sevenhangzhou"]=12327;t["sevenideographicparen"]=12838;t["seveninferior"]=8327;t["sevenmonospace"]=65303;t["sevenoldstyle"]=63287;t["sevenparen"]=9338;t["sevenperiod"]=9358;t["sevenpersian"]=1783;t["sevenroman"]=8566;t["sevensuperior"]=8311;t["seventeencircle"]=9328;t["seventeenparen"]=9348;t["seventeenperiod"]=9368;t["seventhai"]=3671;t["sfthyphen"]=173;t["shaarmenian"]=1399;t["shabengali"]=2486;t["shacyrillic"]=1096;t["shaddaarabic"]=1617;t["shaddadammaarabic"]=64609;t["shaddadammatanarabic"]=64606;t["shaddafathaarabic"]=64608;t["shaddakasraarabic"]=64610;t["shaddakasratanarabic"]=64607;t["shade"]=9618;t["shadedark"]=9619;t["shadelight"]=9617;t["shademedium"]=9618;t["shadeva"]=2358;t["shagujarati"]=2742;t["shagurmukhi"]=2614;t["shalshelethebrew"]=1427;t["shbopomofo"]=12565;t["shchacyrillic"]=1097;t["sheenarabic"]=1588;t["sheenfinalarabic"]=65206;t["sheeninitialarabic"]=65207;t["sheenmedialarabic"]=65208;t["sheicoptic"]=995;t["sheqel"]=8362;t["sheqelhebrew"]=8362;t["sheva"]=1456;t["sheva115"]=1456;t["sheva15"]=1456;t["sheva22"]=1456;t["sheva2e"]=1456;t["shevahebrew"]=1456;t["shevanarrowhebrew"]=1456;t["shevaquarterhebrew"]=1456;t["shevawidehebrew"]=1456;t["shhacyrillic"]=1211;t["shimacoptic"]=1005;t["shin"]=1513;t["shindagesh"]=64329;t["shindageshhebrew"]=64329;t["shindageshshindot"]=64300;t["shindageshshindothebrew"]=64300;t["shindageshsindot"]=64301;t["shindageshsindothebrew"]=64301;t["shindothebrew"]=1473;t["shinhebrew"]=1513;t["shinshindot"]=64298;t["shinshindothebrew"]=64298;t["shinsindot"]=64299;t["shinsindothebrew"]=64299;t["shook"]=642;t["sigma"]=963;t["sigma1"]=962;t["sigmafinal"]=962;t["sigmalunatesymbolgreek"]=1010;t["sihiragana"]=12375;t["sikatakana"]=12471;t["sikatakanahalfwidth"]=65404;t["siluqhebrew"]=1469;t["siluqlefthebrew"]=1469;t["similar"]=8764;t["sindothebrew"]=1474;t["siosacirclekorean"]=12916;t["siosaparenkorean"]=12820;t["sioscieuckorean"]=12670;t["sioscirclekorean"]=12902;t["sioskiyeokkorean"]=12666;t["sioskorean"]=12613;t["siosnieunkorean"]=12667;t["siosparenkorean"]=12806;t["siospieupkorean"]=12669;t["siostikeutkorean"]=12668;t["six"]=54;t["sixarabic"]=1638;t["sixbengali"]=2540;t["sixcircle"]=9317;t["sixcircleinversesansserif"]=10127;t["sixdeva"]=2412;t["sixgujarati"]=2796;t["sixgurmukhi"]=2668;t["sixhackarabic"]=1638;t["sixhangzhou"]=12326;t["sixideographicparen"]=12837;t["sixinferior"]=8326;t["sixmonospace"]=65302;t["sixoldstyle"]=63286;t["sixparen"]=9337;t["sixperiod"]=9357;t["sixpersian"]=1782;t["sixroman"]=8565;t["sixsuperior"]=8310;t["sixteencircle"]=9327;t["sixteencurrencydenominatorbengali"]=2553;t["sixteenparen"]=9347;t["sixteenperiod"]=9367;t["sixthai"]=3670;t["slash"]=47;t["slashmonospace"]=65295;t["slong"]=383;t["slongdotaccent"]=7835;t["smileface"]=9786;t["smonospace"]=65363;t["sofpasuqhebrew"]=1475;t["softhyphen"]=173;t["softsigncyrillic"]=1100;t["sohiragana"]=12381;t["sokatakana"]=12477;t["sokatakanahalfwidth"]=65407;t["soliduslongoverlaycmb"]=824;t["solidusshortoverlaycmb"]=823;t["sorusithai"]=3625;t["sosalathai"]=3624;t["sosothai"]=3595;t["sosuathai"]=3626;t["space"]=32;t["spacehackarabic"]=32;t["spade"]=9824;t["spadesuitblack"]=9824;t["spadesuitwhite"]=9828;t["sparen"]=9390;t["squarebelowcmb"]=827;t["squarecc"]=13252;t["squarecm"]=13213;t["squarediagonalcrosshatchfill"]=9641;t["squarehorizontalfill"]=9636;t["squarekg"]=13199;t["squarekm"]=13214;t["squarekmcapital"]=13262;t["squareln"]=13265;t["squarelog"]=13266;t["squaremg"]=13198;t["squaremil"]=13269;t["squaremm"]=13212;t["squaremsquared"]=13217;t["squareorthogonalcrosshatchfill"]=9638;t["squareupperlefttolowerrightfill"]=9639;t["squareupperrighttolowerleftfill"]=9640;t["squareverticalfill"]=9637;t["squarewhitewithsmallblack"]=9635;t["srsquare"]=13275;t["ssabengali"]=2487;t["ssadeva"]=2359;t["ssagujarati"]=2743;t["ssangcieuckorean"]=12617;t["ssanghieuhkorean"]=12677;t["ssangieungkorean"]=12672;t["ssangkiyeokkorean"]=12594;t["ssangnieunkorean"]=12645;t["ssangpieupkorean"]=12611;t["ssangsioskorean"]=12614;t["ssangtikeutkorean"]=12600;t["ssuperior"]=63218;t["sterling"]=163;t["sterlingmonospace"]=65505;t["strokelongoverlaycmb"]=822;t["strokeshortoverlaycmb"]=821;t["subset"]=8834;t["subsetnotequal"]=8842;t["subsetorequal"]=8838;t["succeeds"]=8827;t["suchthat"]=8715;t["suhiragana"]=12377;t["sukatakana"]=12473;t["sukatakanahalfwidth"]=65405;t["sukunarabic"]=1618;t["summation"]=8721;t["sun"]=9788;t["superset"]=8835;t["supersetnotequal"]=8843;t["supersetorequal"]=8839;t["svsquare"]=13276;t["syouwaerasquare"]=13180;t["t"]=116;t["tabengali"]=2468;t["tackdown"]=8868;t["tackleft"]=8867;t["tadeva"]=2340;t["tagujarati"]=2724;t["tagurmukhi"]=2596;t["taharabic"]=1591;t["tahfinalarabic"]=65218;t["tahinitialarabic"]=65219;t["tahiragana"]=12383;t["tahmedialarabic"]=65220;t["taisyouerasquare"]=13181;t["takatakana"]=12479;t["takatakanahalfwidth"]=65408;t["tatweelarabic"]=1600;t["tau"]=964;t["tav"]=1514;t["tavdages"]=64330;t["tavdagesh"]=64330;t["tavdageshhebrew"]=64330;t["tavhebrew"]=1514;t["tbar"]=359;t["tbopomofo"]=12554;t["tcaron"]=357;t["tccurl"]=680;t["tcedilla"]=355;t["tcheharabic"]=1670;t["tchehfinalarabic"]=64379;t["tchehinitialarabic"]=64380;t["tchehmedialarabic"]=64381;t["tcircle"]=9443;t["tcircumflexbelow"]=7793;t["tcommaaccent"]=355;t["tdieresis"]=7831;t["tdotaccent"]=7787;t["tdotbelow"]=7789;t["tecyrillic"]=1090;t["tedescendercyrillic"]=1197;t["teharabic"]=1578;t["tehfinalarabic"]=65174;t["tehhahinitialarabic"]=64674;t["tehhahisolatedarabic"]=64524;t["tehinitialarabic"]=65175;t["tehiragana"]=12390;t["tehjeeminitialarabic"]=64673;t["tehjeemisolatedarabic"]=64523;t["tehmarbutaarabic"]=1577;t["tehmarbutafinalarabic"]=65172;t["tehmedialarabic"]=65176;t["tehmeeminitialarabic"]=64676;t["tehmeemisolatedarabic"]=64526;t["tehnoonfinalarabic"]=64627;t["tekatakana"]=12486;t["tekatakanahalfwidth"]=65411;t["telephone"]=8481;t["telephoneblack"]=9742;t["telishagedolahebrew"]=1440;t["telishaqetanahebrew"]=1449;t["tencircle"]=9321;t["tenideographicparen"]=12841;t["tenparen"]=9341;t["tenperiod"]=9361;t["tenroman"]=8569;t["tesh"]=679;t["tet"]=1496;t["tetdagesh"]=64312;t["tetdageshhebrew"]=64312;t["tethebrew"]=1496;t["tetsecyrillic"]=1205;t["tevirhebrew"]=1435;t["tevirlefthebrew"]=1435;t["thabengali"]=2469;t["thadeva"]=2341;t["thagujarati"]=2725;t["thagurmukhi"]=2597;t["thalarabic"]=1584;t["thalfinalarabic"]=65196;t["thanthakhatlowleftthai"]=63640;t["thanthakhatlowrightthai"]=63639;t["thanthakhatthai"]=3660;t["thanthakhatupperleftthai"]=63638;t["theharabic"]=1579;t["thehfinalarabic"]=65178;t["thehinitialarabic"]=65179;t["thehmedialarabic"]=65180;t["thereexists"]=8707;t["therefore"]=8756;t["theta"]=952;t["theta1"]=977;t["thetasymbolgreek"]=977;t["thieuthacirclekorean"]=12921;t["thieuthaparenkorean"]=12825;t["thieuthcirclekorean"]=12907;t["thieuthkorean"]=12620;t["thieuthparenkorean"]=12811;t["thirteencircle"]=9324;t["thirteenparen"]=9344;t["thirteenperiod"]=9364;t["thonangmonthothai"]=3601;t["thook"]=429;t["thophuthaothai"]=3602;t["thorn"]=254;t["thothahanthai"]=3607;t["thothanthai"]=3600;t["thothongthai"]=3608;t["thothungthai"]=3606;t["thousandcyrillic"]=1154;t["thousandsseparatorarabic"]=1644;t["thousandsseparatorpersian"]=1644;t["three"]=51;t["threearabic"]=1635;t["threebengali"]=2537;t["threecircle"]=9314;t["threecircleinversesansserif"]=10124;t["threedeva"]=2409;t["threeeighths"]=8540;t["threegujarati"]=2793;t["threegurmukhi"]=2665;t["threehackarabic"]=1635;t["threehangzhou"]=12323;t["threeideographicparen"]=12834;t["threeinferior"]=8323;t["threemonospace"]=65299;t["threenumeratorbengali"]=2550;t["threeoldstyle"]=63283;t["threeparen"]=9334;t["threeperiod"]=9354;t["threepersian"]=1779;t["threequarters"]=190;t["threequartersemdash"]=63198;t["threeroman"]=8562;t["threesuperior"]=179;t["threethai"]=3667;t["thzsquare"]=13204;t["tihiragana"]=12385;t["tikatakana"]=12481;t["tikatakanahalfwidth"]=65409;t["tikeutacirclekorean"]=12912;t["tikeutaparenkorean"]=12816;t["tikeutcirclekorean"]=12898;t["tikeutkorean"]=12599;t["tikeutparenkorean"]=12802;t["tilde"]=732;t["tildebelowcmb"]=816;t["tildecmb"]=771;t["tildecomb"]=771;t["tildedoublecmb"]=864;t["tildeoperator"]=8764;t["tildeoverlaycmb"]=820;t["tildeverticalcmb"]=830;t["timescircle"]=8855;t["tipehahebrew"]=1430;t["tipehalefthebrew"]=1430;t["tippigurmukhi"]=2672;t["titlocyrilliccmb"]=1155;t["tiwnarmenian"]=1407;t["tlinebelow"]=7791;t["tmonospace"]=65364;t["toarmenian"]=1385;t["tohiragana"]=12392;t["tokatakana"]=12488;t["tokatakanahalfwidth"]=65412;t["tonebarextrahighmod"]=741;t["tonebarextralowmod"]=745;t["tonebarhighmod"]=742;t["tonebarlowmod"]=744;t["tonebarmidmod"]=743;t["tonefive"]=445;t["tonesix"]=389;t["tonetwo"]=424;t["tonos"]=900;t["tonsquare"]=13095;t["topatakthai"]=3599;t["tortoiseshellbracketleft"]=12308;t["tortoiseshellbracketleftsmall"]=65117;t["tortoiseshellbracketleftvertical"]=65081;t["tortoiseshellbracketright"]=12309;t["tortoiseshellbracketrightsmall"]=65118;t["tortoiseshellbracketrightvertical"]=65082;t["totaothai"]=3605;t["tpalatalhook"]=427;t["tparen"]=9391;t["trademark"]=8482;t["trademarksans"]=63722;t["trademarkserif"]=63195;t["tretroflexhook"]=648;t["triagdn"]=9660;t["triaglf"]=9668;t["triagrt"]=9658;t["triagup"]=9650;t["ts"]=678;t["tsadi"]=1510;t["tsadidagesh"]=64326;t["tsadidageshhebrew"]=64326;t["tsadihebrew"]=1510;t["tsecyrillic"]=1094;t["tsere"]=1461;t["tsere12"]=1461;t["tsere1e"]=1461;t["tsere2b"]=1461;t["tserehebrew"]=1461;t["tserenarrowhebrew"]=1461;t["tserequarterhebrew"]=1461;t["tserewidehebrew"]=1461;t["tshecyrillic"]=1115;t["tsuperior"]=63219;t["ttabengali"]=2463;t["ttadeva"]=2335;t["ttagujarati"]=2719;t["ttagurmukhi"]=2591;t["tteharabic"]=1657;t["ttehfinalarabic"]=64359;t["ttehinitialarabic"]=64360;t["ttehmedialarabic"]=64361;t["tthabengali"]=2464;t["tthadeva"]=2336;t["tthagujarati"]=2720;t["tthagurmukhi"]=2592;t["tturned"]=647;t["tuhiragana"]=12388;t["tukatakana"]=12484;t["tukatakanahalfwidth"]=65410;t["tusmallhiragana"]=12387;t["tusmallkatakana"]=12483;t["tusmallkatakanahalfwidth"]=65391;t["twelvecircle"]=9323;t["twelveparen"]=9343;t["twelveperiod"]=9363;t["twelveroman"]=8571;t["twentycircle"]=9331;t["twentyhangzhou"]=21316;t["twentyparen"]=9351;t["twentyperiod"]=9371;t["two"]=50;t["twoarabic"]=1634;t["twobengali"]=2536;t["twocircle"]=9313;t["twocircleinversesansserif"]=10123;t["twodeva"]=2408;t["twodotenleader"]=8229;t["twodotleader"]=8229;t["twodotleadervertical"]=65072;t["twogujarati"]=2792;t["twogurmukhi"]=2664;t["twohackarabic"]=1634;t["twohangzhou"]=12322;t["twoideographicparen"]=12833;t["twoinferior"]=8322;t["twomonospace"]=65298;t["twonumeratorbengali"]=2549;t["twooldstyle"]=63282;t["twoparen"]=9333;t["twoperiod"]=9353;t["twopersian"]=1778;t["tworoman"]=8561;t["twostroke"]=443;t["twosuperior"]=178;t["twothai"]=3666;t["twothirds"]=8532;t["u"]=117;t["uacute"]=250;t["ubar"]=649;t["ubengali"]=2441;t["ubopomofo"]=12584;t["ubreve"]=365;t["ucaron"]=468;t["ucircle"]=9444;t["ucircumflex"]=251;t["ucircumflexbelow"]=7799;t["ucyrillic"]=1091;t["udattadeva"]=2385;t["udblacute"]=369;t["udblgrave"]=533;t["udeva"]=2313;t["udieresis"]=252;t["udieresisacute"]=472;t["udieresisbelow"]=7795;t["udieresiscaron"]=474;t["udieresiscyrillic"]=1265;t["udieresisgrave"]=476;t["udieresismacron"]=470;t["udotbelow"]=7909;t["ugrave"]=249;t["ugujarati"]=2697;t["ugurmukhi"]=2569;t["uhiragana"]=12358;t["uhookabove"]=7911;t["uhorn"]=432;t["uhornacute"]=7913;t["uhorndotbelow"]=7921;t["uhorngrave"]=7915;t["uhornhookabove"]=7917;t["uhorntilde"]=7919;t["uhungarumlaut"]=369;t["uhungarumlautcyrillic"]=1267;t["uinvertedbreve"]=535;t["ukatakana"]=12454;t["ukatakanahalfwidth"]=65395;t["ukcyrillic"]=1145;t["ukorean"]=12636;t["umacron"]=363;t["umacroncyrillic"]=1263;t["umacrondieresis"]=7803;t["umatragurmukhi"]=2625;t["umonospace"]=65365;t["underscore"]=95;t["underscoredbl"]=8215;t["underscoremonospace"]=65343;t["underscorevertical"]=65075;t["underscorewavy"]=65103;t["union"]=8746;t["universal"]=8704;t["uogonek"]=371;t["uparen"]=9392;t["upblock"]=9600;t["upperdothebrew"]=1476;t["upsilon"]=965;t["upsilondieresis"]=971;t["upsilondieresistonos"]=944;t["upsilonlatin"]=650;t["upsilontonos"]=973;t["uptackbelowcmb"]=797;t["uptackmod"]=724;t["uragurmukhi"]=2675;t["uring"]=367;t["ushortcyrillic"]=1118;t["usmallhiragana"]=12357;t["usmallkatakana"]=12453;t["usmallkatakanahalfwidth"]=65385;t["ustraightcyrillic"]=1199;t["ustraightstrokecyrillic"]=1201;t["utilde"]=361;t["utildeacute"]=7801;t["utildebelow"]=7797;t["uubengali"]=2442;t["uudeva"]=2314;t["uugujarati"]=2698;t["uugurmukhi"]=2570;t["uumatragurmukhi"]=2626;t["uuvowelsignbengali"]=2498;t["uuvowelsigndeva"]=2370;t["uuvowelsigngujarati"]=2754;t["uvowelsignbengali"]=2497;t["uvowelsigndeva"]=2369;t["uvowelsigngujarati"]=2753;t["v"]=118;t["vadeva"]=2357;t["vagujarati"]=2741;t["vagurmukhi"]=2613;t["vakatakana"]=12535;t["vav"]=1493;t["vavdagesh"]=64309;t["vavdagesh65"]=64309;t["vavdageshhebrew"]=64309;t["vavhebrew"]=1493;t["vavholam"]=64331;t["vavholamhebrew"]=64331;t["vavvavhebrew"]=1520;t["vavyodhebrew"]=1521;t["vcircle"]=9445;t["vdotbelow"]=7807;t["vecyrillic"]=1074;t["veharabic"]=1700;t["vehfinalarabic"]=64363;t["vehinitialarabic"]=64364;t["vehmedialarabic"]=64365;t["vekatakana"]=12537;t["venus"]=9792;t["verticalbar"]=124;t["verticallineabovecmb"]=781;t["verticallinebelowcmb"]=809;t["verticallinelowmod"]=716;t["verticallinemod"]=712;t["vewarmenian"]=1406;t["vhook"]=651;t["vikatakana"]=12536;t["viramabengali"]=2509;t["viramadeva"]=2381;t["viramagujarati"]=2765;t["visargabengali"]=2435;t["visargadeva"]=2307;t["visargagujarati"]=2691;t["vmonospace"]=65366;t["voarmenian"]=1400;t["voicediterationhiragana"]=12446;t["voicediterationkatakana"]=12542;t["voicedmarkkana"]=12443;t["voicedmarkkanahalfwidth"]=65438;t["vokatakana"]=12538;t["vparen"]=9393;t["vtilde"]=7805;t["vturned"]=652;t["vuhiragana"]=12436;t["vukatakana"]=12532;t["w"]=119;t["wacute"]=7811;t["waekorean"]=12633;t["wahiragana"]=12431;t["wakatakana"]=12527;t["wakatakanahalfwidth"]=65436;t["wakorean"]=12632;t["wasmallhiragana"]=12430;t["wasmallkatakana"]=12526;t["wattosquare"]=13143;t["wavedash"]=12316;t["wavyunderscorevertical"]=65076;t["wawarabic"]=1608;t["wawfinalarabic"]=65262;t["wawhamzaabovearabic"]=1572;t["wawhamzaabovefinalarabic"]=65158;t["wbsquare"]=13277;t["wcircle"]=9446;t["wcircumflex"]=373;t["wdieresis"]=7813;t["wdotaccent"]=7815;t["wdotbelow"]=7817;t["wehiragana"]=12433;t["weierstrass"]=8472;t["wekatakana"]=12529;t["wekorean"]=12638;t["weokorean"]=12637;t["wgrave"]=7809;t["whitebullet"]=9702;t["whitecircle"]=9675;t["whitecircleinverse"]=9689;t["whitecornerbracketleft"]=12302;t["whitecornerbracketleftvertical"]=65091;t["whitecornerbracketright"]=12303;t["whitecornerbracketrightvertical"]=65092;t["whitediamond"]=9671;t["whitediamondcontainingblacksmalldiamond"]=9672;t["whitedownpointingsmalltriangle"]=9663;t["whitedownpointingtriangle"]=9661;t["whiteleftpointingsmalltriangle"]=9667;t["whiteleftpointingtriangle"]=9665;t["whitelenticularbracketleft"]=12310;t["whitelenticularbracketright"]=12311;t["whiterightpointingsmalltriangle"]=9657;t["whiterightpointingtriangle"]=9655;t["whitesmallsquare"]=9643;t["whitesmilingface"]=9786;t["whitesquare"]=9633;t["whitestar"]=9734;t["whitetelephone"]=9743;t["whitetortoiseshellbracketleft"]=12312;t["whitetortoiseshellbracketright"]=12313;t["whiteuppointingsmalltriangle"]=9653;t["whiteuppointingtriangle"]=9651;t["wihiragana"]=12432;t["wikatakana"]=12528;t["wikorean"]=12639;t["wmonospace"]=65367;t["wohiragana"]=12434;t["wokatakana"]=12530;t["wokatakanahalfwidth"]=65382;t["won"]=8361;t["wonmonospace"]=65510;t["wowaenthai"]=3623;t["wparen"]=9394;t["wring"]=7832;t["wsuperior"]=695;t["wturned"]=653;t["wynn"]=447;t["x"]=120;t["xabovecmb"]=829;t["xbopomofo"]=12562;t["xcircle"]=9447;t["xdieresis"]=7821;t["xdotaccent"]=7819;t["xeharmenian"]=1389;t["xi"]=958;t["xmonospace"]=65368;t["xparen"]=9395;t["xsuperior"]=739;t["y"]=121;t["yaadosquare"]=13134;t["yabengali"]=2479;t["yacute"]=253;t["yadeva"]=2351;t["yaekorean"]=12626;t["yagujarati"]=2735;t["yagurmukhi"]=2607;t["yahiragana"]=12420;t["yakatakana"]=12516;t["yakatakanahalfwidth"]=65428;t["yakorean"]=12625;t["yamakkanthai"]=3662;t["yasmallhiragana"]=12419;t["yasmallkatakana"]=12515;t["yasmallkatakanahalfwidth"]=65388;t["yatcyrillic"]=1123;t["ycircle"]=9448;t["ycircumflex"]=375;t["ydieresis"]=255;t["ydotaccent"]=7823;t["ydotbelow"]=7925;t["yeharabic"]=1610;t["yehbarreearabic"]=1746;t["yehbarreefinalarabic"]=64431;t["yehfinalarabic"]=65266;t["yehhamzaabovearabic"]=1574;t["yehhamzaabovefinalarabic"]=65162;t["yehhamzaaboveinitialarabic"]=65163;t["yehhamzaabovemedialarabic"]=65164;t["yehinitialarabic"]=65267;t["yehmedialarabic"]=65268;t["yehmeeminitialarabic"]=64733;t["yehmeemisolatedarabic"]=64600;t["yehnoonfinalarabic"]=64660;t["yehthreedotsbelowarabic"]=1745;t["yekorean"]=12630;t["yen"]=165;t["yenmonospace"]=65509;t["yeokorean"]=12629;t["yeorinhieuhkorean"]=12678;t["yerahbenyomohebrew"]=1450;t["yerahbenyomolefthebrew"]=1450;t["yericyrillic"]=1099;t["yerudieresiscyrillic"]=1273;t["yesieungkorean"]=12673;t["yesieungpansioskorean"]=12675;t["yesieungsioskorean"]=12674;t["yetivhebrew"]=1434;t["ygrave"]=7923;t["yhook"]=436;t["yhookabove"]=7927;t["yiarmenian"]=1397;t["yicyrillic"]=1111;t["yikorean"]=12642;t["yinyang"]=9775;t["yiwnarmenian"]=1410;t["ymonospace"]=65369;t["yod"]=1497;t["yoddagesh"]=64313;t["yoddageshhebrew"]=64313;t["yodhebrew"]=1497;t["yodyodhebrew"]=1522;t["yodyodpatahhebrew"]=64287;t["yohiragana"]=12424;t["yoikorean"]=12681;t["yokatakana"]=12520;t["yokatakanahalfwidth"]=65430;t["yokorean"]=12635;t["yosmallhiragana"]=12423;t["yosmallkatakana"]=12519;t["yosmallkatakanahalfwidth"]=65390;t["yotgreek"]=1011;t["yoyaekorean"]=12680;t["yoyakorean"]=12679;t["yoyakthai"]=3618;t["yoyingthai"]=3597;t["yparen"]=9396;t["ypogegrammeni"]=890;t["ypogegrammenigreekcmb"]=837;t["yr"]=422;t["yring"]=7833;t["ysuperior"]=696;t["ytilde"]=7929;t["yturned"]=654;t["yuhiragana"]=12422;t["yuikorean"]=12684;t["yukatakana"]=12518;t["yukatakanahalfwidth"]=65429;t["yukorean"]=12640;t["yusbigcyrillic"]=1131;t["yusbigiotifiedcyrillic"]=1133;t["yuslittlecyrillic"]=1127;t["yuslittleiotifiedcyrillic"]=1129;t["yusmallhiragana"]=12421;t["yusmallkatakana"]=12517;t["yusmallkatakanahalfwidth"]=65389;t["yuyekorean"]=12683;t["yuyeokorean"]=12682;t["yyabengali"]=2527;t["yyadeva"]=2399;t["z"]=122;t["zaarmenian"]=1382;t["zacute"]=378;t["zadeva"]=2395;t["zagurmukhi"]=2651;t["zaharabic"]=1592;t["zahfinalarabic"]=65222;t["zahinitialarabic"]=65223;t["zahiragana"]=12374;t["zahmedialarabic"]=65224;t["zainarabic"]=1586;t["zainfinalarabic"]=65200;t["zakatakana"]=12470;t["zaqefgadolhebrew"]=1429;t["zaqefqatanhebrew"]=1428;t["zarqahebrew"]=1432;t["zayin"]=1494;t["zayindagesh"]=64310;t["zayindageshhebrew"]=64310;t["zayinhebrew"]=1494;t["zbopomofo"]=12567;t["zcaron"]=382;t["zcircle"]=9449;t["zcircumflex"]=7825;t["zcurl"]=657;t["zdot"]=380;t["zdotaccent"]=380;t["zdotbelow"]=7827;t["zecyrillic"]=1079;t["zedescendercyrillic"]=1177;t["zedieresiscyrillic"]=1247;t["zehiragana"]=12380;t["zekatakana"]=12476;t["zero"]=48;t["zeroarabic"]=1632;t["zerobengali"]=2534;t["zerodeva"]=2406;t["zerogujarati"]=2790;t["zerogurmukhi"]=2662;t["zerohackarabic"]=1632;t["zeroinferior"]=8320;t["zeromonospace"]=65296;t["zerooldstyle"]=63280;t["zeropersian"]=1776;t["zerosuperior"]=8304;t["zerothai"]=3664;t["zerowidthjoiner"]=65279;t["zerowidthnonjoiner"]=8204;t["zerowidthspace"]=8203;t["zeta"]=950;t["zhbopomofo"]=12563;t["zhearmenian"]=1386;t["zhebrevecyrillic"]=1218;t["zhecyrillic"]=1078;t["zhedescendercyrillic"]=1175;t["zhedieresiscyrillic"]=1245;t["zihiragana"]=12376;t["zikatakana"]=12472;t["zinorhebrew"]=1454;t["zlinebelow"]=7829;t["zmonospace"]=65370;t["zohiragana"]=12382;t["zokatakana"]=12478;t["zparen"]=9397;t["zretroflexhook"]=656;t["zstroke"]=438;t["zuhiragana"]=12378;t["zukatakana"]=12474;t[".notdef"]=0});var getDingbatsGlyphsUnicode=getLookupTableFactory(function(t){t["space"]=32;t["a1"]=9985;t["a2"]=9986;t["a202"]=9987;t["a3"]=9988;t["a4"]=9742;t["a5"]=9990;t["a119"]=9991;t["a118"]=9992;t["a117"]=9993;t["a11"]=9755;t["a12"]=9758;t["a13"]=9996;t["a14"]=9997;t["a15"]=9998;t["a16"]=9999;t["a105"]=1e4;t["a17"]=10001;t["a18"]=10002;t["a19"]=10003;t["a20"]=10004;t["a21"]=10005;t["a22"]=10006;t["a23"]=10007;t["a24"]=10008;t["a25"]=10009;t["a26"]=10010;t["a27"]=10011;t["a28"]=10012;t["a6"]=10013;t["a7"]=10014;t["a8"]=10015;t["a9"]=10016;t["a10"]=10017;t["a29"]=10018;t["a30"]=10019;t["a31"]=10020;t["a32"]=10021;t["a33"]=10022;t["a34"]=10023;t["a35"]=9733;t["a36"]=10025;t["a37"]=10026;t["a38"]=10027;t["a39"]=10028;t["a40"]=10029;t["a41"]=10030;t["a42"]=10031;t["a43"]=10032;t["a44"]=10033;t["a45"]=10034;t["a46"]=10035;t["a47"]=10036;t["a48"]=10037;t["a49"]=10038;t["a50"]=10039;t["a51"]=10040;t["a52"]=10041;t["a53"]=10042;t["a54"]=10043;t["a55"]=10044;t["a56"]=10045;t["a57"]=10046;t["a58"]=10047;t["a59"]=10048;t["a60"]=10049;t["a61"]=10050;t["a62"]=10051;t["a63"]=10052;t["a64"]=10053;t["a65"]=10054;t["a66"]=10055;t["a67"]=10056;t["a68"]=10057;t["a69"]=10058;t["a70"]=10059;t["a71"]=9679;t["a72"]=10061;t["a73"]=9632;t["a74"]=10063;t["a203"]=10064;t["a75"]=10065;t["a204"]=10066;t["a76"]=9650;t["a77"]=9660;t["a78"]=9670;t["a79"]=10070;t["a81"]=9687;t["a82"]=10072;t["a83"]=10073;t["a84"]=10074;t["a97"]=10075;t["a98"]=10076;t["a99"]=10077;t["a100"]=10078;t["a101"]=10081;t["a102"]=10082;t["a103"]=10083;t["a104"]=10084;t["a106"]=10085;t["a107"]=10086;t["a108"]=10087;t["a112"]=9827;t["a111"]=9830;t["a110"]=9829;t["a109"]=9824;t["a120"]=9312;t["a121"]=9313;t["a122"]=9314;t["a123"]=9315;t["a124"]=9316;t["a125"]=9317;t["a126"]=9318;t["a127"]=9319;t["a128"]=9320;t["a129"]=9321;t["a130"]=10102;t["a131"]=10103;t["a132"]=10104;t["a133"]=10105;t["a134"]=10106;t["a135"]=10107;t["a136"]=10108;t["a137"]=10109;t["a138"]=10110;t["a139"]=10111;t["a140"]=10112;t["a141"]=10113;t["a142"]=10114;t["a143"]=10115;t["a144"]=10116;t["a145"]=10117;t["a146"]=10118;t["a147"]=10119;t["a148"]=10120;t["a149"]=10121;t["a150"]=10122;t["a151"]=10123;t["a152"]=10124;t["a153"]=10125;t["a154"]=10126;t["a155"]=10127;t["a156"]=10128;t["a157"]=10129;t["a158"]=10130;t["a159"]=10131;t["a160"]=10132;t["a161"]=8594;t["a163"]=8596;t["a164"]=8597;t["a196"]=10136;t["a165"]=10137;t["a192"]=10138;t["a166"]=10139;t["a167"]=10140;t["a168"]=10141;t["a169"]=10142;t["a170"]=10143;t["a171"]=10144;t["a172"]=10145;t["a173"]=10146;t["a162"]=10147;t["a174"]=10148;t["a175"]=10149;t["a176"]=10150;t["a177"]=10151;t["a178"]=10152;t["a179"]=10153;t["a193"]=10154;t["a180"]=10155;t["a199"]=10156;t["a181"]=10157;t["a200"]=10158;t["a182"]=10159;t["a201"]=10161;t["a183"]=10162;t["a184"]=10163;t["a197"]=10164;t["a185"]=10165;t["a194"]=10166;t["a198"]=10167;t["a186"]=10168;t["a195"]=10169;t["a187"]=10170;t["a188"]=10171;t["a189"]=10172;t["a190"]=10173;t["a191"]=10174;t["a89"]=10088;t["a90"]=10089;t["a93"]=10090;t["a94"]=10091;t["a91"]=10092;t["a92"]=10093;t["a205"]=10094;t["a85"]=10095;t["a206"]=10096;t["a86"]=10097;t["a87"]=10098;t["a88"]=10099;t["a95"]=10100;t["a96"]=10101;t[".notdef"]=0});exports.getGlyphsUnicode=getGlyphsUnicode;exports.getDingbatsGlyphsUnicode=getDingbatsGlyphsUnicode});(function(root,factory){{factory(root.pdfjsCoreJbig2={},root.pdfjsSharedUtil,root.pdfjsCoreArithmeticDecoder)}})(this,function(exports,sharedUtil,coreArithmeticDecoder){var error=sharedUtil.error;var log2=sharedUtil.log2;var readInt8=sharedUtil.readInt8;var readUint16=sharedUtil.readUint16;var readUint32=sharedUtil.readUint32;var shadow=sharedUtil.shadow;var ArithmeticDecoder=coreArithmeticDecoder.ArithmeticDecoder;var Jbig2Image=function Jbig2ImageClosure(){function ContextCache(){}ContextCache.prototype={getContexts:function(id){if(id in this){return this[id]}return this[id]=new Int8Array(1<<16)}};function DecodingContext(data,start,end){this.data=data;this.start=start;this.end=end}DecodingContext.prototype={get decoder(){var decoder=new ArithmeticDecoder(this.data,this.start,this.end);return shadow(this,"decoder",decoder)},get contextCache(){var cache=new ContextCache;return shadow(this,"contextCache",cache)}};function decodeInteger(contextCache,procedure,decoder){var contexts=contextCache.getContexts(procedure);var prev=1;function readBits(length){var v=0;for(var i=0;i<length;i++){var bit=decoder.readBit(contexts,prev);prev=prev<256?prev<<1|bit:(prev<<1|bit)&511|256;v=v<<1|bit}return v>>>0}var sign=readBits(1);var value=readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(32)+4436:readBits(12)+340:readBits(8)+84:readBits(6)+20:readBits(4)+4:readBits(2);return sign===0?value:value>0?-value:null}function decodeIAID(contextCache,decoder,codeLength){var contexts=contextCache.getContexts("IAID");var prev=1;for(var i=0;i<codeLength;i++){var bit=decoder.readBit(contexts,prev);prev=prev<<1|bit}if(codeLength<31){return prev&(1<<codeLength)-1}return prev&2147483647}var SegmentTypes=["SymbolDictionary",null,null,null,"IntermediateTextRegion",null,"ImmediateTextRegion","ImmediateLosslessTextRegion",null,null,null,null,null,null,null,null,"patternDictionary",null,null,null,"IntermediateHalftoneRegion",null,"ImmediateHalftoneRegion","ImmediateLosslessHalftoneRegion",null,null,null,null,null,null,null,null,null,null,null,null,"IntermediateGenericRegion",null,"ImmediateGenericRegion","ImmediateLosslessGenericRegion","IntermediateGenericRefinementRegion",null,"ImmediateGenericRefinementRegion","ImmediateLosslessGenericRefinementRegion",null,null,null,null,"PageInformation","EndOfPage","EndOfStripe","EndOfFile","Profiles","Tables",null,null,null,null,null,null,null,null,"Extension"];var CodingTemplates=[[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:2,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-2,y:0},{x:-1,y:0}],[{x:-3,y:-1},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}]];var RefinementTemplates=[{coding:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1}]},{coding:[{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}]}];var ReusedContexts=[39717,1941,229,405];var RefinementReusedContexts=[32,8];function decodeBitmapTemplate0(width,height,decodingContext){var decoder=decodingContext.decoder;var contexts=decodingContext.contextCache.getContexts("GB");var contextLabel,i,j,pixel,row,row1,row2,bitmap=[];var OLD_PIXEL_MASK=31735;for(i=0;i<height;i++){row=bitmap[i]=new Uint8Array(width);row1=i<1?row:bitmap[i-1];row2=i<2?row:bitmap[i-2];contextLabel=row2[0]<<13|row2[1]<<12|row2[2]<<11|row1[0]<<7|row1[1]<<6|row1[2]<<5|row1[3]<<4;for(j=0;j<width;j++){row[j]=pixel=decoder.readBit(contexts,contextLabel);contextLabel=(contextLabel&OLD_PIXEL_MASK)<<1|(j+3<width?row2[j+3]<<11:0)|(j+4<width?row1[j+4]<<4:0)|pixel
8}}return bitmap}function decodeBitmap(mmr,width,height,templateIndex,prediction,skip,at,decodingContext){if(mmr){error("JBIG2 error: MMR encoding is not supported")}if(templateIndex===0&&!skip&&!prediction&&at.length===4&&at[0].x===3&&at[0].y===-1&&at[1].x===-3&&at[1].y===-1&&at[2].x===2&&at[2].y===-2&&at[3].x===-2&&at[3].y===-2){return decodeBitmapTemplate0(width,height,decodingContext)}var useskip=!!skip;var template=CodingTemplates[templateIndex].concat(at);template.sort(function(a,b){return a.y-b.y||a.x-b.x});var templateLength=template.length;var templateX=new Int8Array(templateLength);var templateY=new Int8Array(templateLength);var changingTemplateEntries=[];var reuseMask=0,minX=0,maxX=0,minY=0;var c,k;for(k=0;k<templateLength;k++){templateX[k]=template[k].x;templateY[k]=template[k].y;minX=Math.min(minX,template[k].x);maxX=Math.max(maxX,template[k].x);minY=Math.min(minY,template[k].y);if(k<templateLength-1&&template[k].y===template[k+1].y&&template[k].x===template[k+1].x-1){reuseMask|=1<<templateLength-1-k}else{changingTemplateEntries.push(k)}}var changingEntriesLength=changingTemplateEntries.length;var changingTemplateX=new Int8Array(changingEntriesLength);var changingTemplateY=new Int8Array(changingEntriesLength);var changingTemplateBit=new Uint16Array(changingEntriesLength);for(c=0;c<changingEntriesLength;c++){k=changingTemplateEntries[c];changingTemplateX[c]=template[k].x;changingTemplateY[c]=template[k].y;changingTemplateBit[c]=1<<templateLength-1-k}var sbb_left=-minX;var sbb_top=-minY;var sbb_right=width-maxX;var pseudoPixelContext=ReusedContexts[templateIndex];var row=new Uint8Array(width);var bitmap=[];var decoder=decodingContext.decoder;var contexts=decodingContext.contextCache.getContexts("GB");var ltp=0,j,i0,j0,contextLabel=0,bit,shift;for(var i=0;i<height;i++){if(prediction){var sltp=decoder.readBit(contexts,pseudoPixelContext);ltp^=sltp;if(ltp){bitmap.push(row);continue}}row=new Uint8Array(row);bitmap.push(row);for(j=0;j<width;j++){if(useskip&&skip[i][j]){row[j]=0;continue}if(j>=sbb_left&&j<sbb_right&&i>=sbb_top){contextLabel=contextLabel<<1&reuseMask;for(k=0;k<changingEntriesLength;k++){i0=i+changingTemplateY[k];j0=j+changingTemplateX[k];bit=bitmap[i0][j0];if(bit){bit=changingTemplateBit[k];contextLabel|=bit}}}else{contextLabel=0;shift=templateLength-1;for(k=0;k<templateLength;k++,shift--){j0=j+templateX[k];if(j0>=0&&j0<width){i0=i+templateY[k];if(i0>=0){bit=bitmap[i0][j0];if(bit){contextLabel|=bit<<shift}}}}}var pixel=decoder.readBit(contexts,contextLabel);row[j]=pixel}}return bitmap}function decodeRefinement(width,height,templateIndex,referenceBitmap,offsetX,offsetY,prediction,at,decodingContext){var codingTemplate=RefinementTemplates[templateIndex].coding;if(templateIndex===0){codingTemplate=codingTemplate.concat([at[0]])}var codingTemplateLength=codingTemplate.length;var codingTemplateX=new Int32Array(codingTemplateLength);var codingTemplateY=new Int32Array(codingTemplateLength);var k;for(k=0;k<codingTemplateLength;k++){codingTemplateX[k]=codingTemplate[k].x;codingTemplateY[k]=codingTemplate[k].y}var referenceTemplate=RefinementTemplates[templateIndex].reference;if(templateIndex===0){referenceTemplate=referenceTemplate.concat([at[1]])}var referenceTemplateLength=referenceTemplate.length;var referenceTemplateX=new Int32Array(referenceTemplateLength);var referenceTemplateY=new Int32Array(referenceTemplateLength);for(k=0;k<referenceTemplateLength;k++){referenceTemplateX[k]=referenceTemplate[k].x;referenceTemplateY[k]=referenceTemplate[k].y}var referenceWidth=referenceBitmap[0].length;var referenceHeight=referenceBitmap.length;var pseudoPixelContext=RefinementReusedContexts[templateIndex];var bitmap=[];var decoder=decodingContext.decoder;var contexts=decodingContext.contextCache.getContexts("GR");var ltp=0;for(var i=0;i<height;i++){if(prediction){var sltp=decoder.readBit(contexts,pseudoPixelContext);ltp^=sltp;if(ltp){error("JBIG2 error: prediction is not supported")}}var row=new Uint8Array(width);bitmap.push(row);for(var j=0;j<width;j++){var i0,j0;var contextLabel=0;for(k=0;k<codingTemplateLength;k++){i0=i+codingTemplateY[k];j0=j+codingTemplateX[k];if(i0<0||j0<0||j0>=width){contextLabel<<=1}else{contextLabel=contextLabel<<1|bitmap[i0][j0]}}for(k=0;k<referenceTemplateLength;k++){i0=i+referenceTemplateY[k]+offsetY;j0=j+referenceTemplateX[k]+offsetX;if(i0<0||i0>=referenceHeight||j0<0||j0>=referenceWidth){contextLabel<<=1}else{contextLabel=contextLabel<<1|referenceBitmap[i0][j0]}}var pixel=decoder.readBit(contexts,contextLabel);row[j]=pixel}}return bitmap}function decodeSymbolDictionary(huffman,refinement,symbols,numberOfNewSymbols,numberOfExportedSymbols,huffmanTables,templateIndex,at,refinementTemplateIndex,refinementAt,decodingContext){if(huffman){error("JBIG2 error: huffman is not supported")}var newSymbols=[];var currentHeight=0;var symbolCodeLength=log2(symbols.length+numberOfNewSymbols);var decoder=decodingContext.decoder;var contextCache=decodingContext.contextCache;while(newSymbols.length<numberOfNewSymbols){var deltaHeight=decodeInteger(contextCache,"IADH",decoder);currentHeight+=deltaHeight;var currentWidth=0;var totalWidth=0;while(true){var deltaWidth=decodeInteger(contextCache,"IADW",decoder);if(deltaWidth===null){break}currentWidth+=deltaWidth;totalWidth+=currentWidth;var bitmap;if(refinement){var numberOfInstances=decodeInteger(contextCache,"IAAI",decoder);if(numberOfInstances>1){bitmap=decodeTextRegion(huffman,refinement,currentWidth,currentHeight,0,numberOfInstances,1,symbols.concat(newSymbols),symbolCodeLength,0,0,1,0,huffmanTables,refinementTemplateIndex,refinementAt,decodingContext)}else{var symbolId=decodeIAID(contextCache,decoder,symbolCodeLength);var rdx=decodeInteger(contextCache,"IARDX",decoder);var rdy=decodeInteger(contextCache,"IARDY",decoder);var symbol=symbolId<symbols.length?symbols[symbolId]:newSymbols[symbolId-symbols.length];bitmap=decodeRefinement(currentWidth,currentHeight,refinementTemplateIndex,symbol,rdx,rdy,false,refinementAt,decodingContext)}}else{bitmap=decodeBitmap(false,currentWidth,currentHeight,templateIndex,false,null,at,decodingContext)}newSymbols.push(bitmap)}}var exportedSymbols=[];var flags=[],currentFlag=false;var totalSymbolsLength=symbols.length+numberOfNewSymbols;while(flags.length<totalSymbolsLength){var runLength=decodeInteger(contextCache,"IAEX",decoder);while(runLength--){flags.push(currentFlag)}currentFlag=!currentFlag}for(var i=0,ii=symbols.length;i<ii;i++){if(flags[i]){exportedSymbols.push(symbols[i])}}for(var j=0;j<numberOfNewSymbols;i++,j++){if(flags[i]){exportedSymbols.push(newSymbols[j])}}return exportedSymbols}function decodeTextRegion(huffman,refinement,width,height,defaultPixelValue,numberOfSymbolInstances,stripSize,inputSymbols,symbolCodeLength,transposed,dsOffset,referenceCorner,combinationOperator,huffmanTables,refinementTemplateIndex,refinementAt,decodingContext){if(huffman){error("JBIG2 error: huffman is not supported")}var bitmap=[];var i,row;for(i=0;i<height;i++){row=new Uint8Array(width);if(defaultPixelValue){for(var j=0;j<width;j++){row[j]=defaultPixelValue}}bitmap.push(row)}var decoder=decodingContext.decoder;var contextCache=decodingContext.contextCache;var stripT=-decodeInteger(contextCache,"IADT",decoder);var firstS=0;i=0;while(i<numberOfSymbolInstances){var deltaT=decodeInteger(contextCache,"IADT",decoder);stripT+=deltaT;var deltaFirstS=decodeInteger(contextCache,"IAFS",decoder);firstS+=deltaFirstS;var currentS=firstS;do{var currentT=stripSize===1?0:decodeInteger(contextCache,"IAIT",decoder);var t=stripSize*stripT+currentT;var symbolId=decodeIAID(contextCache,decoder,symbolCodeLength);var applyRefinement=refinement&&decodeInteger(contextCache,"IARI",decoder);var symbolBitmap=inputSymbols[symbolId];var symbolWidth=symbolBitmap[0].length;var symbolHeight=symbolBitmap.length;if(applyRefinement){var rdw=decodeInteger(contextCache,"IARDW",decoder);var rdh=decodeInteger(contextCache,"IARDH",decoder);var rdx=decodeInteger(contextCache,"IARDX",decoder);var rdy=decodeInteger(contextCache,"IARDY",decoder);symbolWidth+=rdw;symbolHeight+=rdh;symbolBitmap=decodeRefinement(symbolWidth,symbolHeight,refinementTemplateIndex,symbolBitmap,(rdw>>1)+rdx,(rdh>>1)+rdy,false,refinementAt,decodingContext)}var offsetT=t-(referenceCorner&1?0:symbolHeight);var offsetS=currentS-(referenceCorner&2?symbolWidth:0);var s2,t2,symbolRow;if(transposed){for(s2=0;s2<symbolHeight;s2++){row=bitmap[offsetS+s2];if(!row){continue}symbolRow=symbolBitmap[s2];var maxWidth=Math.min(width-offsetT,symbolWidth);switch(combinationOperator){case 0:for(t2=0;t2<maxWidth;t2++){row[offsetT+t2]|=symbolRow[t2]}break;case 2:for(t2=0;t2<maxWidth;t2++){row[offsetT+t2]^=symbolRow[t2]}break;default:error("JBIG2 error: operator "+combinationOperator+" is not supported")}}currentS+=symbolHeight-1}else{for(t2=0;t2<symbolHeight;t2++){row=bitmap[offsetT+t2];if(!row){continue}symbolRow=symbolBitmap[t2];switch(combinationOperator){case 0:for(s2=0;s2<symbolWidth;s2++){row[offsetS+s2]|=symbolRow[s2]}break;case 2:for(s2=0;s2<symbolWidth;s2++){row[offsetS+s2]^=symbolRow[s2]}break;default:error("JBIG2 error: operator "+combinationOperator+" is not supported")}}currentS+=symbolWidth-1}i++;var deltaS=decodeInteger(contextCache,"IADS",decoder);if(deltaS===null){break}currentS+=deltaS+dsOffset}while(true)}return bitmap}function readSegmentHeader(data,start){var segmentHeader={};segmentHeader.number=readUint32(data,start);var flags=data[start+4];var segmentType=flags&63;if(!SegmentTypes[segmentType]){error("JBIG2 error: invalid segment type: "+segmentType)}segmentHeader.type=segmentType;segmentHeader.typeName=SegmentTypes[segmentType];segmentHeader.deferredNonRetain=!!(flags&128);var pageAssociationFieldSize=!!(flags&64);var referredFlags=data[start+5];var referredToCount=referredFlags>>5&7;var retainBits=[referredFlags&31];var position=start+6;if(referredFlags===7){referredToCount=readUint32(data,position-1)&536870911;position+=3;var bytes=referredToCount+7>>3;retainBits[0]=data[position++];while(--bytes>0){retainBits.push(data[position++])}}else if(referredFlags===5||referredFlags===6){error("JBIG2 error: invalid referred-to flags")}segmentHeader.retainBits=retainBits;var referredToSegmentNumberSize=segmentHeader.number<=256?1:segmentHeader.number<=65536?2:4;var referredTo=[];var i,ii;for(i=0;i<referredToCount;i++){var number=referredToSegmentNumberSize===1?data[position]:referredToSegmentNumberSize===2?readUint16(data,position):readUint32(data,position);referredTo.push(number);position+=referredToSegmentNumberSize}segmentHeader.referredTo=referredTo;if(!pageAssociationFieldSize){segmentHeader.pageAssociation=data[position++]}else{segmentHeader.pageAssociation=readUint32(data,position);position+=4}segmentHeader.length=readUint32(data,position);position+=4;if(segmentHeader.length===4294967295){if(segmentType===38){var genericRegionInfo=readRegionSegmentInformation(data,position);var genericRegionSegmentFlags=data[position+RegionSegmentInformationFieldLength];var genericRegionMmr=!!(genericRegionSegmentFlags&1);var searchPatternLength=6;var searchPattern=new Uint8Array(searchPatternLength);if(!genericRegionMmr){searchPattern[0]=255;searchPattern[1]=172}searchPattern[2]=genericRegionInfo.height>>>24&255;searchPattern[3]=genericRegionInfo.height>>16&255;searchPattern[4]=genericRegionInfo.height>>8&255;searchPattern[5]=genericRegionInfo.height&255;for(i=position,ii=data.length;i<ii;i++){var j=0;while(j<searchPatternLength&&searchPattern[j]===data[i+j]){j++}if(j===searchPatternLength){segmentHeader.length=i+searchPatternLength;break}}if(segmentHeader.length===4294967295){error("JBIG2 error: segment end was not found")}}else{error("JBIG2 error: invalid unknown segment length")}}segmentHeader.headerEnd=position;return segmentHeader}function readSegments(header,data,start,end){var segments=[];var position=start;while(position<end){var segmentHeader=readSegmentHeader(data,position);position=segmentHeader.headerEnd;var segment={header:segmentHeader,data:data};if(!header.randomAccess){segment.start=position;position+=segmentHeader.length;segment.end=position}segments.push(segment);if(segmentHeader.type===51){break}}if(header.randomAccess){for(var i=0,ii=segments.length;i<ii;i++){segments[i].start=position;position+=segments[i].header.length;segments[i].end=position}}return segments}function readRegionSegmentInformation(data,start){return{width:readUint32(data,start),height:readUint32(data,start+4),x:readUint32(data,start+8),y:readUint32(data,start+12),combinationOperator:data[start+16]&7}}var RegionSegmentInformationFieldLength=17;function processSegment(segment,visitor){var header=segment.header;var data=segment.data,position=segment.start,end=segment.end;var args,at,i,atLength;switch(header.type){case 0:var dictionary={};var dictionaryFlags=readUint16(data,position);dictionary.huffman=!!(dictionaryFlags&1);dictionary.refinement=!!(dictionaryFlags&2);dictionary.huffmanDHSelector=dictionaryFlags>>2&3;dictionary.huffmanDWSelector=dictionaryFlags>>4&3;dictionary.bitmapSizeSelector=dictionaryFlags>>6&1;dictionary.aggregationInstancesSelector=dictionaryFlags>>7&1;dictionary.bitmapCodingContextUsed=!!(dictionaryFlags&256);dictionary.bitmapCodingContextRetained=!!(dictionaryFlags&512);dictionary.template=dictionaryFlags>>10&3;dictionary.refinementTemplate=dictionaryFlags>>12&1;position+=2;if(!dictionary.huffman){atLength=dictionary.template===0?4:1;at=[];for(i=0;i<atLength;i++){at.push({x:readInt8(data,position),y:readInt8(data,position+1)});position+=2}dictionary.at=at}if(dictionary.refinement&&!dictionary.refinementTemplate){at=[];for(i=0;i<2;i++){at.push({x:readInt8(data,position),y:readInt8(data,position+1)});position+=2}dictionary.refinementAt=at}dictionary.numberOfExportedSymbols=readUint32(data,position);position+=4;dictionary.numberOfNewSymbols=readUint32(data,position);position+=4;args=[dictionary,header.number,header.referredTo,data,position,end];break;case 6:case 7:var textRegion={};textRegion.info=readRegionSegmentInformation(data,position);position+=RegionSegmentInformationFieldLength;var textRegionSegmentFlags=readUint16(data,position);position+=2;textRegion.huffman=!!(textRegionSegmentFlags&1);textRegion.refinement=!!(textRegionSegmentFlags&2);textRegion.stripSize=1<<(textRegionSegmentFlags>>2&3);textRegion.referenceCorner=textRegionSegmentFlags>>4&3;textRegion.transposed=!!(textRegionSegmentFlags&64);textRegion.combinationOperator=textRegionSegmentFlags>>7&3;textRegion.defaultPixelValue=textRegionSegmentFlags>>9&1;textRegion.dsOffset=textRegionSegmentFlags<<17>>27;textRegion.refinementTemplate=textRegionSegmentFlags>>15&1;if(textRegion.huffman){var textRegionHuffmanFlags=readUint16(data,position);position+=2;textRegion.huffmanFS=textRegionHuffmanFlags&3;textRegion.huffmanDS=textRegionHuffmanFlags>>2&3;textRegion.huffmanDT=textRegionHuffmanFlags>>4&3;textRegion.huffmanRefinementDW=textRegionHuffmanFlags>>6&3;textRegion.huffmanRefinementDH=textRegionHuffmanFlags>>8&3;textRegion.huffmanRefinementDX=textRegionHuffmanFlags>>10&3;textRegion.huffmanRefinementDY=textRegionHuffmanFlags>>12&3;textRegion.huffmanRefinementSizeSelector=!!(textRegionHuffmanFlags&14)}if(textRegion.refinement&&!textRegion.refinementTemplate){at=[];for(i=0;i<2;i++){at.push({x:readInt8(data,position),y:readInt8(data,position+1)});position+=2}textRegion.refinementAt=at}textRegion.numberOfSymbolInstances=readUint32(data,position);position+=4;if(textRegion.huffman){error("JBIG2 error: huffman is not supported")}args=[textRegion,header.referredTo,data,position,end];break;case 38:case 39:var genericRegion={};genericRegion.info=readRegionSegmentInformation(data,position);position+=RegionSegmentInformationFieldLength;var genericRegionSegmentFlags=data[position++];genericRegion.mmr=!!(genericRegionSegmentFlags&1);genericRegion.template=genericRegionSegmentFlags>>1&3;genericRegion.prediction=!!(genericRegionSegmentFlags&8);if(!genericRegion.mmr){atLength=genericRegion.template===0?4:1;at=[];for(i=0;i<atLength;i++){at.push({x:readInt8(data,position),y:readInt8(data,position+1)});position+=2}genericRegion.at=at}args=[genericRegion,data,position,end];break;case 48:var pageInfo={width:readUint32(data,position),height:readUint32(data,position+4),resolutionX:readUint32(data,position+8),resolutionY:readUint32(data,position+12)};if(pageInfo.height===4294967295){delete pageInfo.height}var pageSegmentFlags=data[position+16];var pageStripingInformation=readUint16(data,position+17);pageInfo.lossless=!!(pageSegmentFlags&1);pageInfo.refinement=!!(pageSegmentFlags&2);pageInfo.defaultPixelValue=pageSegmentFlags>>2&1;pageInfo.combinationOperator=pageSegmentFlags>>3&3;pageInfo.requiresBuffer=!!(pageSegmentFlags&32);pageInfo.combinationOperatorOverride=!!(pageSegmentFlags&64);args=[pageInfo];break;case 49:break;case 50:break;case 51:break;case 62:break;default:error("JBIG2 error: segment type "+header.typeName+"("+header.type+") is not implemented")}var callbackName="on"+header.typeName;if(callbackName in visitor){visitor[callbackName].apply(visitor,args)}}function processSegments(segments,visitor){for(var i=0,ii=segments.length;i<ii;i++){processSegment(segments[i],visitor)}}function parseJbig2(data,start,end){var position=start;if(data[position]!==151||data[position+1]!==74||data[position+2]!==66||data[position+3]!==50||data[position+4]!==13||data[position+5]!==10||data[position+6]!==26||data[position+7]!==10){error("JBIG2 error: invalid header")}var header={};position+=8;var flags=data[position++];header.randomAccess=!(flags&1);if(!(flags&2)){header.numberOfPages=readUint32(data,position);position+=4}var segments=readSegments(header,data,position,end);error("Not implemented")}function parseJbig2Chunks(chunks){var visitor=new SimpleSegmentVisitor;for(var i=0,ii=chunks.length;i<ii;i++){var chunk=chunks[i];var segments=readSegments({},chunk.data,chunk.start,chunk.end);processSegments(segments,visitor)}return visitor.buffer}function SimpleSegmentVisitor(){}SimpleSegmentVisitor.prototype={onPageInformation:function SimpleSegmentVisitor_onPageInformation(info){this.currentPageInfo=info;var rowSize=info.width+7>>3;var buffer=new Uint8Array(rowSize*info.height);if(info.defaultPixelValue){for(var i=0,ii=buffer.length;i<ii;i++){buffer[i]=255}}this.buffer=buffer},drawBitmap:function SimpleSegmentVisitor_drawBitmap(regionInfo,bitmap){var pageInfo=this.currentPageInfo;var width=regionInfo.width,height=regionInfo.height;var rowSize=pageInfo.width+7>>3;var combinationOperator=pageInfo.combinationOperatorOverride?regionInfo.combinationOperator:pageInfo.combinationOperator;var buffer=this.buffer;var mask0=128>>(regionInfo.x&7);var offset0=regionInfo.y*rowSize+(regionInfo.x>>3);var i,j,mask,offset;switch(combinationOperator){case 0:for(i=0;i<height;i++){mask=mask0;offset=offset0;for(j=0;j<width;j++){if(bitmap[i][j]){buffer[offset]|=mask}mask>>=1;if(!mask){mask=128;offset++}}offset0+=rowSize}break;case 2:for(i=0;i<height;i++){mask=mask0;offset=offset0;for(j=0;j<width;j++){if(bitmap[i][j]){buffer[offset]^=mask}mask>>=1;if(!mask){mask=128;offset++}}offset0+=rowSize}break;default:error("JBIG2 error: operator "+combinationOperator+" is not supported")}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(region,data,start,end){var regionInfo=region.info;var decodingContext=new DecodingContext(data,start,end);var bitmap=decodeBitmap(region.mmr,regionInfo.width,regionInfo.height,region.template,region.prediction,null,region.at,decodingContext);this.drawBitmap(regionInfo,bitmap)},onImmediateLosslessGenericRegion:function SimpleSegmentVisitor_onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function SimpleSegmentVisitor_onSymbolDictionary(dictionary,currentSegment,referredSegments,data,start,end){var huffmanTables;if(dictionary.huffman){error("JBIG2 error: huffman is not supported")}var symbols=this.symbols;if(!symbols){this.symbols=symbols={}}var inputSymbols=[];for(var i=0,ii=referredSegments.length;i<ii;i++){inputSymbols=inputSymbols.concat(symbols[referredSegments[i]])}var decodingContext=new DecodingContext(data,start,end);symbols[currentSegment]=decodeSymbolDictionary(dictionary.huffman,dictionary.refinement,inputSymbols,dictionary.numberOfNewSymbols,dictionary.numberOfExportedSymbols,huffmanTables,dictionary.template,dictionary.at,dictionary.refinementTemplate,dictionary.refinementAt,decodingContext)},onImmediateTextRegion:function SimpleSegmentVisitor_onImmediateTextRegion(region,referredSegments,data,start,end){var regionInfo=region.info;var huffmanTables;var symbols=this.symbols;var inputSymbols=[];for(var i=0,ii=referredSegments.length;i<ii;i++){inputSymbols=inputSymbols.concat(symbols[referredSegments[i]])}var symbolCodeLength=log2(inputSymbols.length);var decodingContext=new DecodingContext(data,start,end);var bitmap=decodeTextRegion(region.huffman,region.refinement,regionInfo.width,regionInfo.height,region.defaultPixelValue,region.numberOfSymbolInstances,region.stripSize,inputSymbols,symbolCodeLength,region.transposed,region.dsOffset,region.referenceCorner,region.combinationOperator,huffmanTables,region.refinementTemplate,region.refinementAt,decodingContext);this.drawBitmap(regionInfo,bitmap)},onImmediateLosslessTextRegion:function SimpleSegmentVisitor_onImmediateLosslessTextRegion(){this.onImmediateTextRegion.apply(this,arguments)}};function Jbig2Image(){}Jbig2Image.prototype={parseChunks:function Jbig2Image_parseChunks(chunks){return parseJbig2Chunks(chunks)}};return Jbig2Image}();exports.Jbig2Image=Jbig2Image});(function(root,factory){{factory(root.pdfjsCoreJpg={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var error=sharedUtil.error;var JpegImage=function JpegImageClosure(){var 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]);var dctCos1=4017;var dctSin1=799;var dctCos3=3406;var dctSin3=2276;var dctCos6=1567;var dctSin6=3784;var dctSqrt2=5793;var dctSqrt1d2=2896;function JpegImage(){this.decodeTransform=null;this.colorTransform=-1}function buildHuffmanTable(codeLengths,values){var k=0,code=[],i,j,length=16;while(length>0&&!codeLengths[length-1]){length--}code.push({children:[],index:0});var p=code[0],q;for(i=0;i<length;i++){for(j=0;j<codeLengths[i];j++){p=code.pop();p.children[p.index]=values[k];while(p.index>0){p=code.pop()}p.index++;code.push(p);while(code.length<=i){code.push(q={children:[],index:0});p.children[p.index]=q.children;p=q}k++}if(i+1<length){code.push(q={children:[],index:0});p.children[p.index]=q.children;p=q}}return code[0].children}function getBlockBufferOffset(component,row,col){return 64*((component.blocksPerLine+1)*row+col)}function decodeScan(data,offset,frame,components,resetInterval,spectralStart,spectralEnd,successivePrev,successive){var mcusPerLine=frame.mcusPerLine;var progressive=frame.progressive;var startOffset=offset,bitsData=0,bitsCount=0;function readBit(){if(bitsCount>0){bitsCount--;return bitsData>>bitsCount&1}bitsData=data[offset++];if(bitsData===255){var nextByte=data[offset++];if(nextByte){error("JPEG error: unexpected marker "+(bitsData<<8|nextByte).toString(16))}}bitsCount=7;return bitsData>>>7}function decodeHuffman(tree){var node=tree;while(true){node=node[readBit()];if(typeof node==="number"){return node}if(typeof node!=="object"){error("JPEG error: invalid huffman sequence")}}}function receive(length){var n=0;while(length>0){n=n<<1|readBit();length--}return n}function receiveAndExtend(length){if(length===1){return readBit()===1?1:-1}var n=receive(length);if(n>=1<<length-1){return n}return n+(-1<<length)+1}function decodeBaseline(component,offset){var t=decodeHuffman(component.huffmanTableDC);var diff=t===0?0:receiveAndExtend(t);component.blockData[offset]=component.pred+=diff;var k=1;while(k<64){var rs=decodeHuffman(component.huffmanTableAC);var s=rs&15,r=rs>>4;if(s===0){if(r<15){break}k+=16;continue}k+=r;var z=dctZigZag[k];component.blockData[offset+z]=receiveAndExtend(s);k++}}function decodeDCFirst(component,offset){var t=decodeHuffman(component.huffmanTableDC);var diff=t===0?0:receiveAndExtend(t)<<successive;component.blockData[offset]=component.pred+=diff}function decodeDCSuccessive(component,offset){component.blockData[offset]|=readBit()<<successive}var eobrun=0;function decodeACFirst(component,offset){if(eobrun>0){eobrun--;return}var k=spectralStart,e=spectralEnd;while(k<=e){var rs=decodeHuffman(component.huffmanTableAC);var s=rs&15,r=rs>>4;if(s===0){if(r<15){eobrun=receive(r)+(1<<r)-1;break}k+=16;continue}k+=r;var z=dctZigZag[k];component.blockData[offset+z]=receiveAndExtend(s)*(1<<successive);k++}}var successiveACState=0,successiveACNextValue;function decodeACSuccessive(component,offset){var k=spectralStart;var e=spectralEnd;var r=0;var s;var rs;while(k<=e){var z=dctZigZag[k];switch(successiveACState){case 0:rs=decodeHuffman(component.huffmanTableAC);s=rs&15;r=rs>>4;if(s===0){if(r<15){eobrun=receive(r)+(1<<r);successiveACState=4}else{r=16;successiveACState=1}}else{if(s!==1){error("JPEG error: invalid ACn encoding")}successiveACNextValue=receiveAndExtend(s);successiveACState=r?2:3}continue;case 1:case 2:if(component.blockData[offset+z]){component.blockData[offset+z]+=readBit()<<successive}else{r--;if(r===0){successiveACState=successiveACState===2?3:0}}break;case 3:if(component.blockData[offset+z]){component.blockData[offset+z]+=readBit()<<successive}else{component.blockData[offset+z]=successiveACNextValue<<successive;successiveACState=0}break;case 4:if(component.blockData[offset+z]){component.blockData[offset+z]+=readBit()<<successive}break}k++}if(successiveACState===4){eobrun--;if(eobrun===0){successiveACState=0}}}function decodeMcu(component,decode,mcu,row,col){var mcuRow=mcu/mcusPerLine|0;var mcuCol=mcu%mcusPerLine;var blockRow=mcuRow*component.v+row;var blockCol=mcuCol*component.h+col;var offset=getBlockBufferOffset(component,blockRow,blockCol);decode(component,offset)}function decodeBlock(component,decode,mcu){var blockRow=mcu/component.blocksPerLine|0;var blockCol=mcu%component.blocksPerLine;var offset=getBlockBufferOffset(component,blockRow,blockCol);decode(component,offset)}var componentsLength=components.length;var component,i,j,k,n;var decodeFn;if(progressive){if(spectralStart===0){decodeFn=successivePrev===0?decodeDCFirst:decodeDCSuccessive}else{decodeFn=successivePrev===0?decodeACFirst:decodeACSuccessive}}else{decodeFn=decodeBaseline}var mcu=0,marker;var mcuExpected;if(componentsLength===1){mcuExpected=components[0].blocksPerLine*components[0].blocksPerColumn}else{mcuExpected=mcusPerLine*frame.mcusPerColumn}if(!resetInterval){resetInterval=mcuExpected}var h,v;while(mcu<mcuExpected){for(i=0;i<componentsLength;i++){components[i].pred=0}eobrun=0;if(componentsLength===1){component=components[0];for(n=0;n<resetInterval;n++){decodeBlock(component,decodeFn,mcu);mcu++}}else{for(n=0;n<resetInterval;n++){for(i=0;i<componentsLength;i++){component=components[i];h=component.h;v=component.v;for(j=0;j<v;j++){for(k=0;k<h;k++){decodeMcu(component,decodeFn,mcu,j,k)}}}mcu++}}bitsCount=0;marker=data[offset]<<8|data[offset+1];while(data[offset]===0&&offset<data.length-1){offset++;marker=data[offset]<<8|data[offset+1]}if(marker<=65280){error("JPEG error: marker was not found")}if(marker>=65488&&marker<=65495){offset+=2}else{break}}return offset-startOffset}function quantizeAndInverse(component,blockBufferOffset,p){var qt=component.quantizationTable,blockData=component.blockData;var v0,v1,v2,v3,v4,v5,v6,v7;var p0,p1,p2,p3,p4,p5,p6,p7;var t;if(!qt){error("JPEG error: missing required Quantization Table.")}for(var row=0;row<64;row+=8){p0=blockData[blockBufferOffset+row];p1=blockData[blockBufferOffset+row+1];p2=blockData[blockBufferOffset+row+2];p3=blockData[blockBufferOffset+row+3];p4=blockData[blockBufferOffset+row+4];p5=blockData[blockBufferOffset+row+5];p6=blockData[blockBufferOffset+row+6];p7=blockData[blockBufferOffset+row+7];p0*=qt[row];if((p1|p2|p3|p4|p5|p6|p7)===0){t=dctSqrt2*p0+512>>10;p[row]=t;p[row+1]=t;p[row+2]=t;p[row+3]=t;p[row+4]=t;p[row+5]=t;p[row+6]=t;p[row+7]=t;continue}p1*=qt[row+1];p2*=qt[row+2];p3*=qt[row+3];p4*=qt[row+4];p5*=qt[row+5];p6*=qt[row+6];p7*=qt[row+7];v0=dctSqrt2*p0+128>>8;v1=dctSqrt2*p4+128>>8;v2=p2;v3=p6;v4=dctSqrt1d2*(p1-p7)+128>>8;v7=dctSqrt1d2*(p1+p7)+128>>8;v5=p3<<4;v6=p5<<4;v0=v0+v1+1>>1;v1=v0-v1;t=v2*dctSin6+v3*dctCos6+128>>8;v2=v2*dctCos6-v3*dctSin6+128>>8;v3=t;v4=v4+v6+1>>1;v6=v4-v6;v7=v7+v5+1>>1;v5=v7-v5;v0=v0+v3+1>>1;v3=v0-v3;v1=v1+v2+1>>1;v2=v1-v2;t=v4*dctSin3+v7*dctCos3+2048>>12;v4=v4*dctCos3-v7*dctSin3+2048>>12;v7=t;t=v5*dctSin1+v6*dctCos1+2048>>12;v5=v5*dctCos1-v6*dctSin1+2048>>12;v6=t;p[row]=v0+v7;p[row+7]=v0-v7;p[row+1]=v1+v6;p[row+6]=v1-v6;p[row+2]=v2+v5;p[row+5]=v2-v5;p[row+3]=v3+v4;p[row+4]=v3-v4}for(var col=0;col<8;++col){p0=p[col];p1=p[col+8];p2=p[col+16];p3=p[col+24];p4=p[col+32];p5=p[col+40];p6=p[col+48];p7=p[col+56];if((p1|p2|p3|p4|p5|p6|p7)===0){t=dctSqrt2*p0+8192>>14;t=t<-2040?0:t>=2024?255:t+2056>>4;blockData[blockBufferOffset+col]=t;blockData[blockBufferOffset+col+8]=t;blockData[blockBufferOffset+col+16]=t;blockData[blockBufferOffset+col+24]=t;blockData[blockBufferOffset+col+32]=t;blockData[blockBufferOffset+col+40]=t;blockData[blockBufferOffset+col+48]=t;blockData[blockBufferOffset+col+56]=t;continue}v0=dctSqrt2*p0+2048>>12;v1=dctSqrt2*p4+2048>>12;v2=p2;v3=p6;v4=dctSqrt1d2*(p1-p7)+2048>>12;v7=dctSqrt1d2*(p1+p7)+2048>>12;v5=p3;v6=p5;v0=(v0+v1+1>>1)+4112;v1=v0-v1;t=v2*dctSin6+v3*dctCos6+2048>>12;v2=v2*dctCos6-v3*dctSin6+2048>>12;v3=t;v4=v4+v6+1>>1;v6=v4-v6;v7=v7+v5+1>>1;v5=v7-v5;v0=v0+v3+1>>1;v3=v0-v3;v1=v1+v2+1>>1;v2=v1-v2;t=v4*dctSin3+v7*dctCos3+2048>>12;v4=v4*dctCos3-v7*dctSin3+2048>>12;v7=t;t=v5*dctSin1+v6*dctCos1+2048>>12;v5=v5*dctCos1-v6*dctSin1+2048>>12;v6=t;p0=v0+v7;p7=v0-v7;p1=v1+v6;p6=v1-v6;p2=v2+v5;p5=v2-v5;p3=v3+v4;p4=v3-v4;p0=p0<16?0:p0>=4080?255:p0>>4;p1=p1<16?0:p1>=4080?255:p1>>4;p2=p2<16?0:p2>=4080?255:p2>>4;p3=p3<16?0:p3>=4080?255:p3>>4;p4=p4<16?0:p4>=4080?255:p4>>4;p5=p5<16?0:p5>=4080?255:p5>>4;p6=p6<16?0:p6>=4080?255:p6>>4;p7=p7<16?0:p7>=4080?255:p7>>4;blockData[blockBufferOffset+col]=p0;blockData[blockBufferOffset+col+8]=p1;blockData[blockBufferOffset+col+16]=p2;blockData[blockBufferOffset+col+24]=p3;blockData[blockBufferOffset+col+32]=p4;blockData[blockBufferOffset+col+40]=p5;blockData[blockBufferOffset+col+48]=p6;blockData[blockBufferOffset+col+56]=p7}}function buildComponentData(frame,component){var blocksPerLine=component.blocksPerLine;var blocksPerColumn=component.blocksPerColumn;var computationBuffer=new Int16Array(64);for(var blockRow=0;blockRow<blocksPerColumn;blockRow++){for(var blockCol=0;blockCol<blocksPerLine;blockCol++){var offset=getBlockBufferOffset(component,blockRow,blockCol);quantizeAndInverse(component,offset,computationBuffer)}}return component.blockData}function clamp0to255(a){return a<=0?0:a>=255?255:a}JpegImage.prototype={parse:function parse(data){function readUint16(){var value=data[offset]<<8|data[offset+1];offset+=2;return value}function readDataBlock(){var length=readUint16();var array=data.subarray(offset,offset+length-2);offset+=array.length;return array}function prepareComponents(frame){var mcusPerLine=Math.ceil(frame.samplesPerLine/8/frame.maxH);var mcusPerColumn=Math.ceil(frame.scanLines/8/frame.maxV);for(var i=0;i<frame.components.length;i++){component=frame.components[i];var blocksPerLine=Math.ceil(Math.ceil(frame.samplesPerLine/8)*component.h/frame.maxH);var blocksPerColumn=Math.ceil(Math.ceil(frame.scanLines/8)*component.v/frame.maxV);var blocksPerLineForMcu=mcusPerLine*component.h;var blocksPerColumnForMcu=mcusPerColumn*component.v;var blocksBufferSize=64*blocksPerColumnForMcu*(blocksPerLineForMcu+1);component.blockData=new Int16Array(blocksBufferSize);component.blocksPerLine=blocksPerLine;component.blocksPerColumn=blocksPerColumn}frame.mcusPerLine=mcusPerLine;frame.mcusPerColumn=mcusPerColumn}var offset=0;var jfif=null;
9var adobe=null;var frame,resetInterval;var quantizationTables=[];var huffmanTablesAC=[],huffmanTablesDC=[];var fileMarker=readUint16();if(fileMarker!==65496){error("JPEG error: SOI not found")}fileMarker=readUint16();while(fileMarker!==65497){var i,j,l;switch(fileMarker){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var appData=readDataBlock();if(fileMarker===65504){if(appData[0]===74&&appData[1]===70&&appData[2]===73&&appData[3]===70&&appData[4]===0){jfif={version:{major:appData[5],minor:appData[6]},densityUnits:appData[7],xDensity:appData[8]<<8|appData[9],yDensity:appData[10]<<8|appData[11],thumbWidth:appData[12],thumbHeight:appData[13],thumbData:appData.subarray(14,14+3*appData[12]*appData[13])}}}if(fileMarker===65518){if(appData[0]===65&&appData[1]===100&&appData[2]===111&&appData[3]===98&&appData[4]===101){adobe={version:appData[5]<<8|appData[6],flags0:appData[7]<<8|appData[8],flags1:appData[9]<<8|appData[10],transformCode:appData[11]}}}break;case 65499:var quantizationTablesLength=readUint16();var quantizationTablesEnd=quantizationTablesLength+offset-2;var z;while(offset<quantizationTablesEnd){var quantizationTableSpec=data[offset++];var tableData=new Uint16Array(64);if(quantizationTableSpec>>4===0){for(j=0;j<64;j++){z=dctZigZag[j];tableData[z]=data[offset++]}}else if(quantizationTableSpec>>4===1){for(j=0;j<64;j++){z=dctZigZag[j];tableData[z]=readUint16()}}else{error("JPEG error: DQT - invalid table spec")}quantizationTables[quantizationTableSpec&15]=tableData}break;case 65472:case 65473:case 65474:if(frame){error("JPEG error: Only single frame JPEGs supported")}readUint16();frame={};frame.extended=fileMarker===65473;frame.progressive=fileMarker===65474;frame.precision=data[offset++];frame.scanLines=readUint16();frame.samplesPerLine=readUint16();frame.components=[];frame.componentIds={};var componentsCount=data[offset++],componentId;var maxH=0,maxV=0;for(i=0;i<componentsCount;i++){componentId=data[offset];var h=data[offset+1]>>4;var v=data[offset+1]&15;if(maxH<h){maxH=h}if(maxV<v){maxV=v}var qId=data[offset+2];l=frame.components.push({h:h,v:v,quantizationId:qId,quantizationTable:null});frame.componentIds[componentId]=l-1;offset+=3}frame.maxH=maxH;frame.maxV=maxV;prepareComponents(frame);break;case 65476:var huffmanLength=readUint16();for(i=2;i<huffmanLength;){var huffmanTableSpec=data[offset++];var codeLengths=new Uint8Array(16);var codeLengthSum=0;for(j=0;j<16;j++,offset++){codeLengthSum+=codeLengths[j]=data[offset]}var huffmanValues=new Uint8Array(codeLengthSum);for(j=0;j<codeLengthSum;j++,offset++){huffmanValues[j]=data[offset]}i+=17+codeLengthSum;(huffmanTableSpec>>4===0?huffmanTablesDC:huffmanTablesAC)[huffmanTableSpec&15]=buildHuffmanTable(codeLengths,huffmanValues)}break;case 65501:readUint16();resetInterval=readUint16();break;case 65498:var scanLength=readUint16();var selectorsCount=data[offset++];var components=[],component;for(i=0;i<selectorsCount;i++){var componentIndex=frame.componentIds[data[offset++]];component=frame.components[componentIndex];var tableSpec=data[offset++];component.huffmanTableDC=huffmanTablesDC[tableSpec>>4];component.huffmanTableAC=huffmanTablesAC[tableSpec&15];components.push(component)}var spectralStart=data[offset++];var spectralEnd=data[offset++];var successiveApproximation=data[offset++];var processed=decodeScan(data,offset,frame,components,resetInterval,spectralStart,spectralEnd,successiveApproximation>>4,successiveApproximation&15);offset+=processed;break;case 65535:if(data[offset]!==255){offset--}break;default:if(data[offset-3]===255&&data[offset-2]>=192&&data[offset-2]<=254){offset-=3;break}error("JPEG error: unknown marker "+fileMarker.toString(16))}fileMarker=readUint16()}this.width=frame.samplesPerLine;this.height=frame.scanLines;this.jfif=jfif;this.adobe=adobe;this.components=[];for(i=0;i<frame.components.length;i++){component=frame.components[i];var quantizationTable=quantizationTables[component.quantizationId];if(quantizationTable){component.quantizationTable=quantizationTable}this.components.push({output:buildComponentData(frame,component),scaleX:component.h/frame.maxH,scaleY:component.v/frame.maxV,blocksPerLine:component.blocksPerLine,blocksPerColumn:component.blocksPerColumn})}this.numComponents=this.components.length},_getLinearizedBlockData:function getLinearizedBlockData(width,height){var scaleX=this.width/width,scaleY=this.height/height;var component,componentScaleX,componentScaleY,blocksPerScanline;var x,y,i,j,k;var index;var offset=0;var output;var numComponents=this.components.length;var dataLength=width*height*numComponents;var data=new Uint8Array(dataLength);var xScaleBlockOffset=new Uint32Array(width);var mask3LSB=4294967288;for(i=0;i<numComponents;i++){component=this.components[i];componentScaleX=component.scaleX*scaleX;componentScaleY=component.scaleY*scaleY;offset=i;output=component.output;blocksPerScanline=component.blocksPerLine+1<<3;for(x=0;x<width;x++){j=0|x*componentScaleX;xScaleBlockOffset[x]=(j&mask3LSB)<<3|j&7}for(y=0;y<height;y++){j=0|y*componentScaleY;index=blocksPerScanline*(j&mask3LSB)|(j&7)<<3;for(x=0;x<width;x++){data[offset]=output[index+xScaleBlockOffset[x]];offset+=numComponents}}}var transform=this.decodeTransform;if(transform){for(i=0;i<dataLength;){for(j=0,k=0;j<numComponents;j++,i++,k+=2){data[i]=(data[i]*transform[k]>>8)+transform[k+1]}}}return data},_isColorConversionNeeded:function isColorConversionNeeded(){if(this.adobe&&this.adobe.transformCode){return true}else if(this.numComponents===3){if(!this.adobe&&this.colorTransform===0){return false}return true}else{if(!this.adobe&&this.colorTransform===1){return true}return false}},_convertYccToRgb:function convertYccToRgb(data){var Y,Cb,Cr;for(var i=0,length=data.length;i<length;i+=3){Y=data[i];Cb=data[i+1];Cr=data[i+2];data[i]=clamp0to255(Y-179.456+1.402*Cr);data[i+1]=clamp0to255(Y+135.459-.344*Cb-.714*Cr);data[i+2]=clamp0to255(Y-226.816+1.772*Cb)}return data},_convertYcckToRgb:function convertYcckToRgb(data){var Y,Cb,Cr,k;var offset=0;for(var i=0,length=data.length;i<length;i+=4){Y=data[i];Cb=data[i+1];Cr=data[i+2];k=data[i+3];var r=-122.67195406894+Cb*(-660635669420364e-19*Cb+.000437130475926232*Cr-54080610064599e-18*Y+.00048449797120281*k-.154362151871126)+Cr*(-.000957964378445773*Cr+.000817076911346625*Y-.00477271405408747*k+1.53380253221734)+Y*(.000961250184130688*Y-.00266257332283933*k+.48357088451265)+k*(-.000336197177618394*k+.484791561490776);var g=107.268039397724+Cb*(219927104525741e-19*Cb-.000640992018297945*Cr+.000659397001245577*Y+.000426105652938837*k-.176491792462875)+Cr*(-.000778269941513683*Cr+.00130872261408275*Y+.000770482631801132*k-.151051492775562)+Y*(.00126935368114843*Y-.00265090189010898*k+.25802910206845)+k*(-.000318913117588328*k-.213742400323665);var b=-20.810012546947+Cb*(-.000570115196973677*Cb-263409051004589e-19*Cr+.0020741088115012*Y-.00288260236853442*k+.814272968359295)+Cr*(-153496057440975e-19*Cr-.000132689043961446*Y+.000560833691242812*k-.195152027534049)+Y*(.00174418132927582*Y-.00255243321439347*k+.116935020465145)+k*(-.000343531996510555*k+.24165260232407);data[offset++]=clamp0to255(r);data[offset++]=clamp0to255(g);data[offset++]=clamp0to255(b)}return data},_convertYcckToCmyk:function convertYcckToCmyk(data){var Y,Cb,Cr;for(var i=0,length=data.length;i<length;i+=4){Y=data[i];Cb=data[i+1];Cr=data[i+2];data[i]=clamp0to255(434.456-Y-1.402*Cr);data[i+1]=clamp0to255(119.541-Y+.344*Cb+.714*Cr);data[i+2]=clamp0to255(481.816-Y-1.772*Cb)}return data},_convertCmykToRgb:function convertCmykToRgb(data){var c,m,y,k;var offset=0;var min=-255*255*255;var scale=1/255/255;for(var i=0,length=data.length;i<length;i+=4){c=data[i];m=data[i+1];y=data[i+2];k=data[i+3];var r=c*(-4.387332384609988*c+54.48615194189176*m+18.82290502165302*y+212.25662451639585*k-72734.4411664936)+m*(1.7149763477362134*m-5.6096736904047315*y-17.873870861415444*k-1401.7366389350734)+y*(-2.5217340131683033*y-21.248923337353073*k+4465.541406466231)-k*(21.86122147463605*k+48317.86113160301);var g=c*(8.841041422036149*c+60.118027045597366*m+6.871425592049007*y+31.159100130055922*k-20220.756542821975)+m*(-15.310361306967817*m+17.575251261109482*y+131.35250912493976*k-48691.05921601825)+y*(4.444339102852739*y+9.8632861493405*k-6341.191035517494)-k*(20.737325471181034*k+47890.15695978492);var b=c*(.8842522430003296*c+8.078677503112928*m+30.89978309703729*y-.23883238689178934*k-3616.812083916688)+m*(10.49593273432072*m+63.02378494754052*y+50.606957656360734*k-28620.90484698408)+y*(.03296041114873217*y+115.60384449646641*k-49363.43385999684)-k*(22.33816807309886*k+45932.16563550634);data[offset++]=r>=0?255:r<=min?0:255+r*scale|0;data[offset++]=g>=0?255:g<=min?0:255+g*scale|0;data[offset++]=b>=0?255:b<=min?0:255+b*scale|0}return data},getData:function getData(width,height,forceRGBoutput){if(this.numComponents>4){error("JPEG error: Unsupported color mode")}var data=this._getLinearizedBlockData(width,height);if(this.numComponents===1&&forceRGBoutput){var dataLength=data.length;var rgbData=new Uint8Array(dataLength*3);var offset=0;for(var i=0;i<dataLength;i++){var grayColor=data[i];rgbData[offset++]=grayColor;rgbData[offset++]=grayColor;rgbData[offset++]=grayColor}return rgbData}else if(this.numComponents===3&&this._isColorConversionNeeded()){return this._convertYccToRgb(data)}else if(this.numComponents===4){if(this._isColorConversionNeeded()){if(forceRGBoutput){return this._convertYcckToRgb(data)}else{return this._convertYcckToCmyk(data)}}else if(forceRGBoutput){return this._convertCmykToRgb(data)}}return data}};return JpegImage}();exports.JpegImage=JpegImage});(function(root,factory){{factory(root.pdfjsCoreJpx={},root.pdfjsSharedUtil,root.pdfjsCoreArithmeticDecoder)}})(this,function(exports,sharedUtil,coreArithmeticDecoder){var info=sharedUtil.info;var warn=sharedUtil.warn;var error=sharedUtil.error;var log2=sharedUtil.log2;var readUint16=sharedUtil.readUint16;var readUint32=sharedUtil.readUint32;var ArithmeticDecoder=coreArithmeticDecoder.ArithmeticDecoder;var JpxImage=function JpxImageClosure(){var SubbandsGainLog2={LL:0,LH:1,HL:1,HH:2};function JpxImage(){this.failOnCorruptedImage=false}JpxImage.prototype={parse:function JpxImage_parse(data){var head=readUint16(data,0);if(head===65359){this.parseCodestream(data,0,data.length);return}var position=0,length=data.length;while(position<length){var headerSize=8;var lbox=readUint32(data,position);var tbox=readUint32(data,position+4);position+=headerSize;if(lbox===1){lbox=readUint32(data,position)*4294967296+readUint32(data,position+4);position+=8;headerSize+=8}if(lbox===0){lbox=length-position+headerSize}if(lbox<headerSize){error("JPX Error: Invalid box field size")}var dataLength=lbox-headerSize;var jumpDataLength=true;switch(tbox){case 1785737832:jumpDataLength=false;break;case 1668246642:var method=data[position];if(method===1){var colorspace=readUint32(data,position+3);switch(colorspace){case 16:case 17:case 18:break;default:warn("Unknown colorspace "+colorspace);break}}else if(method===2){info("ICC profile not supported")}break;case 1785737827:this.parseCodestream(data,position,position+dataLength);break;case 1783636e3:if(218793738!==readUint32(data,position)){warn("Invalid JP2 signature")}break;case 1783634458:case 1718909296:case 1920099697:case 1919251232:case 1768449138:break;default:var headerType=String.fromCharCode(tbox>>24&255,tbox>>16&255,tbox>>8&255,tbox&255);warn("Unsupported header type "+tbox+" ("+headerType+")");break}if(jumpDataLength){position+=dataLength}}},parseImageProperties:function JpxImage_parseImageProperties(stream){var newByte=stream.getByte();while(newByte>=0){var oldByte=newByte;newByte=stream.getByte();var code=oldByte<<8|newByte;if(code===65361){stream.skip(4);var Xsiz=stream.getInt32()>>>0;var Ysiz=stream.getInt32()>>>0;var XOsiz=stream.getInt32()>>>0;var YOsiz=stream.getInt32()>>>0;stream.skip(16);var Csiz=stream.getUint16();this.width=Xsiz-XOsiz;this.height=Ysiz-YOsiz;this.componentsCount=Csiz;this.bitsPerComponent=8;return}}error("JPX Error: No size marker found in JPX stream")},parseCodestream:function JpxImage_parseCodestream(data,start,end){var context={};var doNotRecover=false;try{var position=start;while(position+1<end){var code=readUint16(data,position);position+=2;var length=0,j,sqcd,spqcds,spqcdSize,scalarExpounded,tile;switch(code){case 65359:context.mainHeader=true;break;case 65497:break;case 65361:length=readUint16(data,position);var siz={};siz.Xsiz=readUint32(data,position+4);siz.Ysiz=readUint32(data,position+8);siz.XOsiz=readUint32(data,position+12);siz.YOsiz=readUint32(data,position+16);siz.XTsiz=readUint32(data,position+20);siz.YTsiz=readUint32(data,position+24);siz.XTOsiz=readUint32(data,position+28);siz.YTOsiz=readUint32(data,position+32);var componentsCount=readUint16(data,position+36);siz.Csiz=componentsCount;var components=[];j=position+38;for(var i=0;i<componentsCount;i++){var component={precision:(data[j]&127)+1,isSigned:!!(data[j]&128),XRsiz:data[j+1],YRsiz:data[j+1]};calculateComponentDimensions(component,siz);components.push(component)}context.SIZ=siz;context.components=components;calculateTileGrids(context,components);context.QCC=[];context.COC=[];break;case 65372:length=readUint16(data,position);var qcd={};j=position+2;sqcd=data[j++];switch(sqcd&31){case 0:spqcdSize=8;scalarExpounded=true;break;case 1:spqcdSize=16;scalarExpounded=false;break;case 2:spqcdSize=16;scalarExpounded=true;break;default:throw new Error("Invalid SQcd value "+sqcd)}qcd.noQuantization=spqcdSize===8;qcd.scalarExpounded=scalarExpounded;qcd.guardBits=sqcd>>5;spqcds=[];while(j<length+position){var spqcd={};if(spqcdSize===8){spqcd.epsilon=data[j++]>>3;spqcd.mu=0}else{spqcd.epsilon=data[j]>>3;spqcd.mu=(data[j]&7)<<8|data[j+1];j+=2}spqcds.push(spqcd)}qcd.SPqcds=spqcds;if(context.mainHeader){context.QCD=qcd}else{context.currentTile.QCD=qcd;context.currentTile.QCC=[]}break;case 65373:length=readUint16(data,position);var qcc={};j=position+2;var cqcc;if(context.SIZ.Csiz<257){cqcc=data[j++]}else{cqcc=readUint16(data,j);j+=2}sqcd=data[j++];switch(sqcd&31){case 0:spqcdSize=8;scalarExpounded=true;break;case 1:spqcdSize=16;scalarExpounded=false;break;case 2:spqcdSize=16;scalarExpounded=true;break;default:throw new Error("Invalid SQcd value "+sqcd)}qcc.noQuantization=spqcdSize===8;qcc.scalarExpounded=scalarExpounded;qcc.guardBits=sqcd>>5;spqcds=[];while(j<length+position){spqcd={};if(spqcdSize===8){spqcd.epsilon=data[j++]>>3;spqcd.mu=0}else{spqcd.epsilon=data[j]>>3;spqcd.mu=(data[j]&7)<<8|data[j+1];j+=2}spqcds.push(spqcd)}qcc.SPqcds=spqcds;if(context.mainHeader){context.QCC[cqcc]=qcc}else{context.currentTile.QCC[cqcc]=qcc}break;case 65362:length=readUint16(data,position);var cod={};j=position+2;var scod=data[j++];cod.entropyCoderWithCustomPrecincts=!!(scod&1);cod.sopMarkerUsed=!!(scod&2);cod.ephMarkerUsed=!!(scod&4);cod.progressionOrder=data[j++];cod.layersCount=readUint16(data,j);j+=2;cod.multipleComponentTransform=data[j++];cod.decompositionLevelsCount=data[j++];cod.xcb=(data[j++]&15)+2;cod.ycb=(data[j++]&15)+2;var blockStyle=data[j++];cod.selectiveArithmeticCodingBypass=!!(blockStyle&1);cod.resetContextProbabilities=!!(blockStyle&2);cod.terminationOnEachCodingPass=!!(blockStyle&4);cod.verticalyStripe=!!(blockStyle&8);cod.predictableTermination=!!(blockStyle&16);cod.segmentationSymbolUsed=!!(blockStyle&32);cod.reversibleTransformation=data[j++];if(cod.entropyCoderWithCustomPrecincts){var precinctsSizes=[];while(j<length+position){var precinctsSize=data[j++];precinctsSizes.push({PPx:precinctsSize&15,PPy:precinctsSize>>4})}cod.precinctsSizes=precinctsSizes}var unsupported=[];if(cod.selectiveArithmeticCodingBypass){unsupported.push("selectiveArithmeticCodingBypass")}if(cod.resetContextProbabilities){unsupported.push("resetContextProbabilities")}if(cod.terminationOnEachCodingPass){unsupported.push("terminationOnEachCodingPass")}if(cod.verticalyStripe){unsupported.push("verticalyStripe")}if(cod.predictableTermination){unsupported.push("predictableTermination")}if(unsupported.length>0){doNotRecover=true;throw new Error("Unsupported COD options ("+unsupported.join(", ")+")")}if(context.mainHeader){context.COD=cod}else{context.currentTile.COD=cod;context.currentTile.COC=[]}break;case 65424:length=readUint16(data,position);tile={};tile.index=readUint16(data,position+2);tile.length=readUint32(data,position+4);tile.dataEnd=tile.length+position-2;tile.partIndex=data[position+8];tile.partsCount=data[position+9];context.mainHeader=false;if(tile.partIndex===0){tile.COD=context.COD;tile.COC=context.COC.slice(0);tile.QCD=context.QCD;tile.QCC=context.QCC.slice(0)}context.currentTile=tile;break;case 65427:tile=context.currentTile;if(tile.partIndex===0){initializeTile(context,tile.index);buildPackets(context)}length=tile.dataEnd-position;parseTilePackets(context,data,position,length);break;case 65365:case 65367:case 65368:case 65380:length=readUint16(data,position);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is "+"not implemented");default:throw new Error("Unknown codestream code: "+code.toString(16))}position+=length}}catch(e){if(doNotRecover||this.failOnCorruptedImage){error("JPX Error: "+e.message)}else{warn("JPX: Trying to recover from: "+e.message)}}this.tiles=transformComponents(context);this.width=context.SIZ.Xsiz-context.SIZ.XOsiz;this.height=context.SIZ.Ysiz-context.SIZ.YOsiz;this.componentsCount=context.SIZ.Csiz}};function calculateComponentDimensions(component,siz){component.x0=Math.ceil(siz.XOsiz/component.XRsiz);component.x1=Math.ceil(siz.Xsiz/component.XRsiz);component.y0=Math.ceil(siz.YOsiz/component.YRsiz);component.y1=Math.ceil(siz.Ysiz/component.YRsiz);component.width=component.x1-component.x0;component.height=component.y1-component.y0}function calculateTileGrids(context,components){var siz=context.SIZ;var tile,tiles=[];var numXtiles=Math.ceil((siz.Xsiz-siz.XTOsiz)/siz.XTsiz);var numYtiles=Math.ceil((siz.Ysiz-siz.YTOsiz)/siz.YTsiz);for(var q=0;q<numYtiles;q++){for(var p=0;p<numXtiles;p++){tile={};tile.tx0=Math.max(siz.XTOsiz+p*siz.XTsiz,siz.XOsiz);tile.ty0=Math.max(siz.YTOsiz+q*siz.YTsiz,siz.YOsiz);tile.tx1=Math.min(siz.XTOsiz+(p+1)*siz.XTsiz,siz.Xsiz);tile.ty1=Math.min(siz.YTOsiz+(q+1)*siz.YTsiz,siz.Ysiz);tile.width=tile.tx1-tile.tx0;tile.height=tile.ty1-tile.ty0;tile.components=[];tiles.push(tile)}}context.tiles=tiles;var componentsCount=siz.Csiz;for(var i=0,ii=componentsCount;i<ii;i++){var component=components[i];for(var j=0,jj=tiles.length;j<jj;j++){var tileComponent={};tile=tiles[j];tileComponent.tcx0=Math.ceil(tile.tx0/component.XRsiz);tileComponent.tcy0=Math.ceil(tile.ty0/component.YRsiz);tileComponent.tcx1=Math.ceil(tile.tx1/component.XRsiz);tileComponent.tcy1=Math.ceil(tile.ty1/component.YRsiz);tileComponent.width=tileComponent.tcx1-tileComponent.tcx0;tileComponent.height=tileComponent.tcy1-tileComponent.tcy0;tile.components[i]=tileComponent}}}function getBlocksDimensions(context,component,r){var codOrCoc=component.codingStyleParameters;var result={};if(!codOrCoc.entropyCoderWithCustomPrecincts){result.PPx=15;result.PPy=15}else{result.PPx=codOrCoc.precinctsSizes[r].PPx;result.PPy=codOrCoc.precinctsSizes[r].PPy}result.xcb_=r>0?Math.min(codOrCoc.xcb,result.PPx-1):Math.min(codOrCoc.xcb,result.PPx);result.ycb_=r>0?Math.min(codOrCoc.ycb,result.PPy-1):Math.min(codOrCoc.ycb,result.PPy);return result}function buildPrecincts(context,resolution,dimensions){var precinctWidth=1<<dimensions.PPx;var precinctHeight=1<<dimensions.PPy;var isZeroRes=resolution.resLevel===0;var precinctWidthInSubband=1<<dimensions.PPx+(isZeroRes?0:-1);var precinctHeightInSubband=1<<dimensions.PPy+(isZeroRes?0:-1);var numprecinctswide=resolution.trx1>resolution.trx0?Math.ceil(resolution.trx1/precinctWidth)-Math.floor(resolution.trx0/precinctWidth):0;var numprecinctshigh=resolution.try1>resolution.try0?Math.ceil(resolution.try1/precinctHeight)-Math.floor(resolution.try0/precinctHeight):0;var numprecincts=numprecinctswide*numprecinctshigh;resolution.precinctParameters={precinctWidth:precinctWidth,precinctHeight:precinctHeight,numprecinctswide:numprecinctswide,numprecinctshigh:numprecinctshigh,numprecincts:numprecincts,precinctWidthInSubband:precinctWidthInSubband,precinctHeightInSubband:precinctHeightInSubband}}function buildCodeblocks(context,subband,dimensions){var xcb_=dimensions.xcb_;var ycb_=dimensions.ycb_;var codeblockWidth=1<<xcb_;var codeblockHeight=1<<ycb_;var cbx0=subband.tbx0>>xcb_;var cby0=subband.tby0>>ycb_;var cbx1=subband.tbx1+codeblockWidth-1>>xcb_;var cby1=subband.tby1+codeblockHeight-1>>ycb_;var precinctParameters=subband.resolution.precinctParameters;var codeblocks=[];var precincts=[];var i,j,codeblock,precinctNumber;for(j=cby0;j<cby1;j++){for(i=cbx0;i<cbx1;i++){codeblock={cbx:i,cby:j,tbx0:codeblockWidth*i,tby0:codeblockHeight*j,tbx1:codeblockWidth*(i+1),tby1:codeblockHeight*(j+1)};codeblock.tbx0_=Math.max(subband.tbx0,codeblock.tbx0);codeblock.tby0_=Math.max(subband.tby0,codeblock.tby0);codeblock.tbx1_=Math.min(subband.tbx1,codeblock.tbx1);codeblock.tby1_=Math.min(subband.tby1,codeblock.tby1);var pi=Math.floor((codeblock.tbx0_-subband.tbx0)/precinctParameters.precinctWidthInSubband);var pj=Math.floor((codeblock.tby0_-subband.tby0)/precinctParameters.precinctHeightInSubband);precinctNumber=pi+pj*precinctParameters.numprecinctswide;codeblock.precinctNumber=precinctNumber;codeblock.subbandType=subband.type;codeblock.Lblock=3;if(codeblock.tbx1_<=codeblock.tbx0_||codeblock.tby1_<=codeblock.tby0_){continue}codeblocks.push(codeblock);var precinct=precincts[precinctNumber];if(precinct!==undefined){if(i<precinct.cbxMin){precinct.cbxMin=i}else if(i>precinct.cbxMax){precinct.cbxMax=i}if(j<precinct.cbyMin){precinct.cbxMin=j}else if(j>precinct.cbyMax){precinct.cbyMax=j}}else{precincts[precinctNumber]=precinct={cbxMin:i,cbyMin:j,cbxMax:i,cbyMax:j}}codeblock.precinct=precinct}}subband.codeblockParameters={codeblockWidth:xcb_,codeblockHeight:ycb_,numcodeblockwide:cbx1-cbx0+1,numcodeblockhigh:cby1-cby0+1};subband.codeblocks=codeblocks;subband.precincts=precincts}function createPacket(resolution,precinctNumber,layerNumber){var precinctCodeblocks=[];var subbands=resolution.subbands;for(var i=0,ii=subbands.length;i<ii;i++){var subband=subbands[i];var codeblocks=subband.codeblocks;for(var j=0,jj=codeblocks.length;j<jj;j++){var codeblock=codeblocks[j];if(codeblock.precinctNumber!==precinctNumber){continue}precinctCodeblocks.push(codeblock)}}return{layerNumber:layerNumber,codeblocks:precinctCodeblocks}}function LayerResolutionComponentPositionIterator(context){var siz=context.SIZ;var tileIndex=context.currentTile.index;var tile=context.tiles[tileIndex];var layersCount=tile.codingStyleDefaultParameters.layersCount;var componentsCount=siz.Csiz;var maxDecompositionLevelsCount=0;for(var q=0;q<componentsCount;q++){maxDecompositionLevelsCount=Math.max(maxDecompositionLevelsCount,tile.components[q].codingStyleParameters.decompositionLevelsCount)}var l=0,r=0,i=0,k=0;this.nextPacket=function JpxImage_nextPacket(){for(;l<layersCount;l++){for(;r<=maxDecompositionLevelsCount;r++){for(;i<componentsCount;i++){var component=tile.components[i];if(r>component.codingStyleParameters.decompositionLevelsCount){continue}var resolution=component.resolutions[r];var numprecincts=resolution.precinctParameters.numprecincts;for(;k<numprecincts;){var packet=createPacket(resolution,k,l);k++;return packet}k=0}i=0}r=0}error("JPX Error: Out of packets")}}function ResolutionLayerComponentPositionIterator(context){var siz=context.SIZ;var tileIndex=context.currentTile.index;var tile=context.tiles[tileIndex];var layersCount=tile.codingStyleDefaultParameters.layersCount;var componentsCount=siz.Csiz;var maxDecompositionLevelsCount=0;for(var q=0;q<componentsCount;q++){maxDecompositionLevelsCount=Math.max(maxDecompositionLevelsCount,tile.components[q].codingStyleParameters.decompositionLevelsCount)}var r=0,l=0,i=0,k=0;this.nextPacket=function JpxImage_nextPacket(){for(;r<=maxDecompositionLevelsCount;r++){for(;l<layersCount;l++){for(;i<componentsCount;i++){var component=tile.components[i];if(r>component.codingStyleParameters.decompositionLevelsCount){continue}var resolution=component.resolutions[r];var numprecincts=resolution.precinctParameters.numprecincts;for(;k<numprecincts;){var packet=createPacket(resolution,k,l);k++;return packet}k=0}i=0}l=0}error("JPX Error: Out of packets")}}function ResolutionPositionComponentLayerIterator(context){var siz=context.SIZ;var tileIndex=context.currentTile.index;var tile=context.tiles[tileIndex];var layersCount=tile.codingStyleDefaultParameters.layersCount;var componentsCount=siz.Csiz;var l,r,c,p;var maxDecompositionLevelsCount=0;for(c=0;c<componentsCount;c++){var component=tile.components[c];maxDecompositionLevelsCount=Math.max(maxDecompositionLevelsCount,component.codingStyleParameters.decompositionLevelsCount)}var maxNumPrecinctsInLevel=new Int32Array(maxDecompositionLevelsCount+1);for(r=0;r<=maxDecompositionLevelsCount;++r){var maxNumPrecincts=0;for(c=0;c<componentsCount;++c){var resolutions=tile.components[c].resolutions;if(r<resolutions.length){maxNumPrecincts=Math.max(maxNumPrecincts,resolutions[r].precinctParameters.numprecincts)}}maxNumPrecinctsInLevel[r]=maxNumPrecincts}l=0;r=0;c=0;p=0;this.nextPacket=function JpxImage_nextPacket(){for(;r<=maxDecompositionLevelsCount;r++){for(;p<maxNumPrecinctsInLevel[r];p++){for(;c<componentsCount;c++){var component=tile.components[c];if(r>component.codingStyleParameters.decompositionLevelsCount){continue}var resolution=component.resolutions[r];var numprecincts=resolution.precinctParameters.numprecincts;if(p>=numprecincts){continue}for(;l<layersCount;){var packet=createPacket(resolution,p,l);l++;return packet}l=0}c=0}p=0}error("JPX Error: Out of packets")}}function PositionComponentResolutionLayerIterator(context){var siz=context.SIZ;var tileIndex=context.currentTile.index;var tile=context.tiles[tileIndex];var layersCount=tile.codingStyleDefaultParameters.layersCount;var componentsCount=siz.Csiz;var precinctsSizes=getPrecinctSizesInImageScale(tile);var precinctsIterationSizes=precinctsSizes;var l=0,r=0,c=0,px=0,py=0;this.nextPacket=function JpxImage_nextPacket(){for(;py<precinctsIterationSizes.maxNumHigh;py++){for(;px<precinctsIterationSizes.maxNumWide;px++){for(;c<componentsCount;c++){var component=tile.components[c];var decompositionLevelsCount=component.codingStyleParameters.decompositionLevelsCount;for(;r<=decompositionLevelsCount;r++){var resolution=component.resolutions[r];var sizeInImageScale=precinctsSizes.components[c].resolutions[r];var k=getPrecinctIndexIfExist(px,py,sizeInImageScale,precinctsIterationSizes,resolution);if(k===null){continue}for(;l<layersCount;){var packet=createPacket(resolution,k,l);l++;return packet}l=0}r=0}c=0}px=0}error("JPX Error: Out of packets")}}function ComponentPositionResolutionLayerIterator(context){var siz=context.SIZ;var tileIndex=context.currentTile.index;var tile=context.tiles[tileIndex];var layersCount=tile.codingStyleDefaultParameters.layersCount;var componentsCount=siz.Csiz;var precinctsSizes=getPrecinctSizesInImageScale(tile);var l=0,r=0,c=0,px=0,py=0;this.nextPacket=function JpxImage_nextPacket(){for(;c<componentsCount;++c){var component=tile.components[c];var precinctsIterationSizes=precinctsSizes.components[c];var decompositionLevelsCount=component.codingStyleParameters.decompositionLevelsCount;for(;py<precinctsIterationSizes.maxNumHigh;py++){for(;px<precinctsIterationSizes.maxNumWide;px++){for(;r<=decompositionLevelsCount;r++){var resolution=component.resolutions[r];var sizeInImageScale=precinctsIterationSizes.resolutions[r];var k=getPrecinctIndexIfExist(px,py,sizeInImageScale,precinctsIterationSizes,resolution);if(k===null){continue}for(;l<layersCount;){var packet=createPacket(resolution,k,l);l++;return packet}l=0}r=0}px=0}py=0}error("JPX Error: Out of packets")}}function getPrecinctIndexIfExist(pxIndex,pyIndex,sizeInImageScale,precinctIterationSizes,resolution){var posX=pxIndex*precinctIterationSizes.minWidth;var posY=pyIndex*precinctIterationSizes.minHeight;if(posX%sizeInImageScale.width!==0||posY%sizeInImageScale.height!==0){return null}var startPrecinctRowIndex=posY/sizeInImageScale.width*resolution.precinctParameters.numprecinctswide;return posX/sizeInImageScale.height+startPrecinctRowIndex}function getPrecinctSizesInImageScale(tile){var componentsCount=tile.components.length;var minWidth=Number.MAX_VALUE;var minHeight=Number.MAX_VALUE;var maxNumWide=0;var maxNumHigh=0;var sizePerComponent=new Array(componentsCount);for(var c=0;c<componentsCount;c++){var component=tile.components[c];var decompositionLevelsCount=component.codingStyleParameters.decompositionLevelsCount;var sizePerResolution=new Array(decompositionLevelsCount+1);var minWidthCurrentComponent=Number.MAX_VALUE;var minHeightCurrentComponent=Number.MAX_VALUE;var maxNumWideCurrentComponent=0;var maxNumHighCurrentComponent=0;var scale=1;for(var r=decompositionLevelsCount;r>=0;--r){var resolution=component.resolutions[r];var widthCurrentResolution=scale*resolution.precinctParameters.precinctWidth;var heightCurrentResolution=scale*resolution.precinctParameters.precinctHeight;minWidthCurrentComponent=Math.min(minWidthCurrentComponent,widthCurrentResolution);minHeightCurrentComponent=Math.min(minHeightCurrentComponent,heightCurrentResolution);maxNumWideCurrentComponent=Math.max(maxNumWideCurrentComponent,resolution.precinctParameters.numprecinctswide);maxNumHighCurrentComponent=Math.max(maxNumHighCurrentComponent,resolution.precinctParameters.numprecinctshigh);sizePerResolution[r]={width:widthCurrentResolution,height:heightCurrentResolution};scale<<=1}minWidth=Math.min(minWidth,minWidthCurrentComponent);minHeight=Math.min(minHeight,minHeightCurrentComponent);maxNumWide=Math.max(maxNumWide,maxNumWideCurrentComponent);maxNumHigh=Math.max(maxNumHigh,maxNumHighCurrentComponent);sizePerComponent[c]={resolutions:sizePerResolution,minWidth:minWidthCurrentComponent,minHeight:minHeightCurrentComponent,maxNumWide:maxNumWideCurrentComponent,maxNumHigh:maxNumHighCurrentComponent}}return{components:sizePerComponent,minWidth:minWidth,minHeight:minHeight,maxNumWide:maxNumWide,maxNumHigh:maxNumHigh}}function buildPackets(context){var siz=context.SIZ;var tileIndex=context.currentTile.index;var tile=context.tiles[tileIndex];var componentsCount=siz.Csiz;for(var c=0;c<componentsCount;c++){var component=tile.components[c];var decompositionLevelsCount=component.codingStyleParameters.decompositionLevelsCount;var resolutions=[];var subbands=[];for(var r=0;r<=decompositionLevelsCount;r++){var blocksDimensions=getBlocksDimensions(context,component,r);var resolution={};var scale=1<<decompositionLevelsCount-r;resolution.trx0=Math.ceil(component.tcx0/scale);resolution.try0=Math.ceil(component.tcy0/scale);resolution.trx1=Math.ceil(component.tcx1/scale);resolution.try1=Math.ceil(component.tcy1/scale);resolution.resLevel=r;buildPrecincts(context,resolution,blocksDimensions);resolutions.push(resolution);var subband;if(r===0){subband={};subband.type="LL";subband.tbx0=Math.ceil(component.tcx0/scale);subband.tby0=Math.ceil(component.tcy0/scale);subband.tbx1=Math.ceil(component.tcx1/scale);subband.tby1=Math.ceil(component.tcy1/scale);subband.resolution=resolution;buildCodeblocks(context,subband,blocksDimensions);subbands.push(subband);resolution.subbands=[subband]}else{var bscale=1<<decompositionLevelsCount-r+1;var resolutionSubbands=[];subband={};subband.type="HL";subband.tbx0=Math.ceil(component.tcx0/bscale-.5);subband.tby0=Math.ceil(component.tcy0/bscale);subband.tbx1=Math.ceil(component.tcx1/bscale-.5);subband.tby1=Math.ceil(component.tcy1/bscale);subband.resolution=resolution;buildCodeblocks(context,subband,blocksDimensions);subbands.push(subband);resolutionSubbands.push(subband);subband={};subband.type="LH";subband.tbx0=Math.ceil(component.tcx0/bscale);subband.tby0=Math.ceil(component.tcy0/bscale-.5);subband.tbx1=Math.ceil(component.tcx1/bscale);
10subband.tby1=Math.ceil(component.tcy1/bscale-.5);subband.resolution=resolution;buildCodeblocks(context,subband,blocksDimensions);subbands.push(subband);resolutionSubbands.push(subband);subband={};subband.type="HH";subband.tbx0=Math.ceil(component.tcx0/bscale-.5);subband.tby0=Math.ceil(component.tcy0/bscale-.5);subband.tbx1=Math.ceil(component.tcx1/bscale-.5);subband.tby1=Math.ceil(component.tcy1/bscale-.5);subband.resolution=resolution;buildCodeblocks(context,subband,blocksDimensions);subbands.push(subband);resolutionSubbands.push(subband);resolution.subbands=resolutionSubbands}}component.resolutions=resolutions;component.subbands=subbands}var progressionOrder=tile.codingStyleDefaultParameters.progressionOrder;switch(progressionOrder){case 0:tile.packetsIterator=new LayerResolutionComponentPositionIterator(context);break;case 1:tile.packetsIterator=new ResolutionLayerComponentPositionIterator(context);break;case 2:tile.packetsIterator=new ResolutionPositionComponentLayerIterator(context);break;case 3:tile.packetsIterator=new PositionComponentResolutionLayerIterator(context);break;case 4:tile.packetsIterator=new ComponentPositionResolutionLayerIterator(context);break;default:error("JPX Error: Unsupported progression order "+progressionOrder)}}function parseTilePackets(context,data,offset,dataLength){var position=0;var buffer,bufferSize=0,skipNextBit=false;function readBits(count){while(bufferSize<count){var b=data[offset+position];position++;if(skipNextBit){buffer=buffer<<7|b;bufferSize+=7;skipNextBit=false}else{buffer=buffer<<8|b;bufferSize+=8}if(b===255){skipNextBit=true}}bufferSize-=count;return buffer>>>bufferSize&(1<<count)-1}function skipMarkerIfEqual(value){if(data[offset+position-1]===255&&data[offset+position]===value){skipBytes(1);return true}else if(data[offset+position]===255&&data[offset+position+1]===value){skipBytes(2);return true}return false}function skipBytes(count){position+=count}function alignToByte(){bufferSize=0;if(skipNextBit){position++;skipNextBit=false}}function readCodingpasses(){if(readBits(1)===0){return 1}if(readBits(1)===0){return 2}var value=readBits(2);if(value<3){return value+3}value=readBits(5);if(value<31){return value+6}value=readBits(7);return value+37}var tileIndex=context.currentTile.index;var tile=context.tiles[tileIndex];var sopMarkerUsed=context.COD.sopMarkerUsed;var ephMarkerUsed=context.COD.ephMarkerUsed;var packetsIterator=tile.packetsIterator;while(position<dataLength){alignToByte();if(sopMarkerUsed&&skipMarkerIfEqual(145)){skipBytes(4)}var packet=packetsIterator.nextPacket();if(!readBits(1)){continue}var layerNumber=packet.layerNumber;var queue=[],codeblock;for(var i=0,ii=packet.codeblocks.length;i<ii;i++){codeblock=packet.codeblocks[i];var precinct=codeblock.precinct;var codeblockColumn=codeblock.cbx-precinct.cbxMin;var codeblockRow=codeblock.cby-precinct.cbyMin;var codeblockIncluded=false;var firstTimeInclusion=false;var valueReady;if(codeblock["included"]!==undefined){codeblockIncluded=!!readBits(1)}else{precinct=codeblock.precinct;var inclusionTree,zeroBitPlanesTree;if(precinct["inclusionTree"]!==undefined){inclusionTree=precinct.inclusionTree}else{var width=precinct.cbxMax-precinct.cbxMin+1;var height=precinct.cbyMax-precinct.cbyMin+1;inclusionTree=new InclusionTree(width,height,layerNumber);zeroBitPlanesTree=new TagTree(width,height);precinct.inclusionTree=inclusionTree;precinct.zeroBitPlanesTree=zeroBitPlanesTree}if(inclusionTree.reset(codeblockColumn,codeblockRow,layerNumber)){while(true){if(readBits(1)){valueReady=!inclusionTree.nextLevel();if(valueReady){codeblock.included=true;codeblockIncluded=firstTimeInclusion=true;break}}else{inclusionTree.incrementValue(layerNumber);break}}}}if(!codeblockIncluded){continue}if(firstTimeInclusion){zeroBitPlanesTree=precinct.zeroBitPlanesTree;zeroBitPlanesTree.reset(codeblockColumn,codeblockRow);while(true){if(readBits(1)){valueReady=!zeroBitPlanesTree.nextLevel();if(valueReady){break}}else{zeroBitPlanesTree.incrementValue()}}codeblock.zeroBitPlanes=zeroBitPlanesTree.value}var codingpasses=readCodingpasses();while(readBits(1)){codeblock.Lblock++}var codingpassesLog2=log2(codingpasses);var bits=(codingpasses<1<<codingpassesLog2?codingpassesLog2-1:codingpassesLog2)+codeblock.Lblock;var codedDataLength=readBits(bits);queue.push({codeblock:codeblock,codingpasses:codingpasses,dataLength:codedDataLength})}alignToByte();if(ephMarkerUsed){skipMarkerIfEqual(146)}while(queue.length>0){var packetItem=queue.shift();codeblock=packetItem.codeblock;if(codeblock["data"]===undefined){codeblock.data=[]}codeblock.data.push({data:data,start:offset+position,end:offset+position+packetItem.dataLength,codingpasses:packetItem.codingpasses});position+=packetItem.dataLength}}return position}function copyCoefficients(coefficients,levelWidth,levelHeight,subband,delta,mb,reversible,segmentationSymbolUsed){var x0=subband.tbx0;var y0=subband.tby0;var width=subband.tbx1-subband.tbx0;var codeblocks=subband.codeblocks;var right=subband.type.charAt(0)==="H"?1:0;var bottom=subband.type.charAt(1)==="H"?levelWidth:0;for(var i=0,ii=codeblocks.length;i<ii;++i){var codeblock=codeblocks[i];var blockWidth=codeblock.tbx1_-codeblock.tbx0_;var blockHeight=codeblock.tby1_-codeblock.tby0_;if(blockWidth===0||blockHeight===0){continue}if(codeblock["data"]===undefined){continue}var bitModel,currentCodingpassType;bitModel=new BitModel(blockWidth,blockHeight,codeblock.subbandType,codeblock.zeroBitPlanes,mb);currentCodingpassType=2;var data=codeblock.data,totalLength=0,codingpasses=0;var j,jj,dataItem;for(j=0,jj=data.length;j<jj;j++){dataItem=data[j];totalLength+=dataItem.end-dataItem.start;codingpasses+=dataItem.codingpasses}var encodedData=new Uint8Array(totalLength);var position=0;for(j=0,jj=data.length;j<jj;j++){dataItem=data[j];var chunk=dataItem.data.subarray(dataItem.start,dataItem.end);encodedData.set(chunk,position);position+=chunk.length}var decoder=new ArithmeticDecoder(encodedData,0,totalLength);bitModel.setDecoder(decoder);for(j=0;j<codingpasses;j++){switch(currentCodingpassType){case 0:bitModel.runSignificancePropagationPass();break;case 1:bitModel.runMagnitudeRefinementPass();break;case 2:bitModel.runCleanupPass();if(segmentationSymbolUsed){bitModel.checkSegmentationSymbol()}break}currentCodingpassType=(currentCodingpassType+1)%3}var offset=codeblock.tbx0_-x0+(codeblock.tby0_-y0)*width;var sign=bitModel.coefficentsSign;var magnitude=bitModel.coefficentsMagnitude;var bitsDecoded=bitModel.bitsDecoded;var magnitudeCorrection=reversible?0:.5;var k,n,nb;position=0;var interleave=subband.type!=="LL";for(j=0;j<blockHeight;j++){var row=offset/width|0;var levelOffset=2*row*(levelWidth-width)+right+bottom;for(k=0;k<blockWidth;k++){n=magnitude[position];if(n!==0){n=(n+magnitudeCorrection)*delta;if(sign[position]!==0){n=-n}nb=bitsDecoded[position];var pos=interleave?levelOffset+(offset<<1):offset;if(reversible&&nb>=mb){coefficients[pos]=n}else{coefficients[pos]=n*(1<<mb-nb)}}offset++;position++}offset+=width-blockWidth}}}function transformTile(context,tile,c){var component=tile.components[c];var codingStyleParameters=component.codingStyleParameters;var quantizationParameters=component.quantizationParameters;var decompositionLevelsCount=codingStyleParameters.decompositionLevelsCount;var spqcds=quantizationParameters.SPqcds;var scalarExpounded=quantizationParameters.scalarExpounded;var guardBits=quantizationParameters.guardBits;var segmentationSymbolUsed=codingStyleParameters.segmentationSymbolUsed;var precision=context.components[c].precision;var reversible=codingStyleParameters.reversibleTransformation;var transform=reversible?new ReversibleTransform:new IrreversibleTransform;var subbandCoefficients=[];var b=0;for(var i=0;i<=decompositionLevelsCount;i++){var resolution=component.resolutions[i];var width=resolution.trx1-resolution.trx0;var height=resolution.try1-resolution.try0;var coefficients=new Float32Array(width*height);for(var j=0,jj=resolution.subbands.length;j<jj;j++){var mu,epsilon;if(!scalarExpounded){mu=spqcds[0].mu;epsilon=spqcds[0].epsilon+(i>0?1-i:0)}else{mu=spqcds[b].mu;epsilon=spqcds[b].epsilon;b++}var subband=resolution.subbands[j];var gainLog2=SubbandsGainLog2[subband.type];var delta=reversible?1:Math.pow(2,precision+gainLog2-epsilon)*(1+mu/2048);var mb=guardBits+epsilon-1;copyCoefficients(coefficients,width,height,subband,delta,mb,reversible,segmentationSymbolUsed)}subbandCoefficients.push({width:width,height:height,items:coefficients})}var result=transform.calculate(subbandCoefficients,component.tcx0,component.tcy0);return{left:component.tcx0,top:component.tcy0,width:result.width,height:result.height,items:result.items}}function transformComponents(context){var siz=context.SIZ;var components=context.components;var componentsCount=siz.Csiz;var resultImages=[];for(var i=0,ii=context.tiles.length;i<ii;i++){var tile=context.tiles[i];var transformedTiles=[];var c;for(c=0;c<componentsCount;c++){transformedTiles[c]=transformTile(context,tile,c)}var tile0=transformedTiles[0];var out=new Uint8Array(tile0.items.length*componentsCount);var result={left:tile0.left,top:tile0.top,width:tile0.width,height:tile0.height,items:out};var shift,offset,max,min,maxK;var pos=0,j,jj,y0,y1,y2,r,g,b,k,val;if(tile.codingStyleDefaultParameters.multipleComponentTransform){var fourComponents=componentsCount===4;var y0items=transformedTiles[0].items;var y1items=transformedTiles[1].items;var y2items=transformedTiles[2].items;var y3items=fourComponents?transformedTiles[3].items:null;shift=components[0].precision-8;offset=(128<<shift)+.5;max=255*(1<<shift);maxK=max*.5;min=-maxK;var component0=tile.components[0];var alpha01=componentsCount-3;jj=y0items.length;if(!component0.codingStyleParameters.reversibleTransformation){for(j=0;j<jj;j++,pos+=alpha01){y0=y0items[j]+offset;y1=y1items[j];y2=y2items[j];r=y0+1.402*y2;g=y0-.34413*y1-.71414*y2;b=y0+1.772*y1;out[pos++]=r<=0?0:r>=max?255:r>>shift;out[pos++]=g<=0?0:g>=max?255:g>>shift;out[pos++]=b<=0?0:b>=max?255:b>>shift}}else{for(j=0;j<jj;j++,pos+=alpha01){y0=y0items[j]+offset;y1=y1items[j];y2=y2items[j];g=y0-(y2+y1>>2);r=g+y2;b=g+y1;out[pos++]=r<=0?0:r>=max?255:r>>shift;out[pos++]=g<=0?0:g>=max?255:g>>shift;out[pos++]=b<=0?0:b>=max?255:b>>shift}}if(fourComponents){for(j=0,pos=3;j<jj;j++,pos+=4){k=y3items[j];out[pos]=k<=min?0:k>=maxK?255:k+offset>>shift}}}else{for(c=0;c<componentsCount;c++){var items=transformedTiles[c].items;shift=components[c].precision-8;offset=(128<<shift)+.5;max=127.5*(1<<shift);min=-max;for(pos=c,j=0,jj=items.length;j<jj;j++){val=items[j];out[pos]=val<=min?0:val>=max?255:val+offset>>shift;pos+=componentsCount}}}resultImages.push(result)}return resultImages}function initializeTile(context,tileIndex){var siz=context.SIZ;var componentsCount=siz.Csiz;var tile=context.tiles[tileIndex];for(var c=0;c<componentsCount;c++){var component=tile.components[c];var qcdOrQcc=context.currentTile.QCC[c]!==undefined?context.currentTile.QCC[c]:context.currentTile.QCD;component.quantizationParameters=qcdOrQcc;var codOrCoc=context.currentTile.COC[c]!==undefined?context.currentTile.COC[c]:context.currentTile.COD;component.codingStyleParameters=codOrCoc}tile.codingStyleDefaultParameters=context.currentTile.COD}var TagTree=function TagTreeClosure(){function TagTree(width,height){var levelsLength=log2(Math.max(width,height))+1;this.levels=[];for(var i=0;i<levelsLength;i++){var level={width:width,height:height,items:[]};this.levels.push(level);width=Math.ceil(width/2);height=Math.ceil(height/2)}}TagTree.prototype={reset:function TagTree_reset(i,j){var currentLevel=0,value=0,level;while(currentLevel<this.levels.length){level=this.levels[currentLevel];var index=i+j*level.width;if(level.items[index]!==undefined){value=level.items[index];break}level.index=index;i>>=1;j>>=1;currentLevel++}currentLevel--;level=this.levels[currentLevel];level.items[level.index]=value;this.currentLevel=currentLevel;delete this.value},incrementValue:function TagTree_incrementValue(){var level=this.levels[this.currentLevel];level.items[level.index]++},nextLevel:function TagTree_nextLevel(){var currentLevel=this.currentLevel;var level=this.levels[currentLevel];var value=level.items[level.index];currentLevel--;if(currentLevel<0){this.value=value;return false}this.currentLevel=currentLevel;level=this.levels[currentLevel];level.items[level.index]=value;return true}};return TagTree}();var InclusionTree=function InclusionTreeClosure(){function InclusionTree(width,height,defaultValue){var levelsLength=log2(Math.max(width,height))+1;this.levels=[];for(var i=0;i<levelsLength;i++){var items=new Uint8Array(width*height);for(var j=0,jj=items.length;j<jj;j++){items[j]=defaultValue}var level={width:width,height:height,items:items};this.levels.push(level);width=Math.ceil(width/2);height=Math.ceil(height/2)}}InclusionTree.prototype={reset:function InclusionTree_reset(i,j,stopValue){var currentLevel=0;while(currentLevel<this.levels.length){var level=this.levels[currentLevel];var index=i+j*level.width;level.index=index;var value=level.items[index];if(value===255){break}if(value>stopValue){this.currentLevel=currentLevel;this.propagateValues();return false}i>>=1;j>>=1;currentLevel++}this.currentLevel=currentLevel-1;return true},incrementValue:function InclusionTree_incrementValue(stopValue){var level=this.levels[this.currentLevel];level.items[level.index]=stopValue+1;this.propagateValues()},propagateValues:function InclusionTree_propagateValues(){var levelIndex=this.currentLevel;var level=this.levels[levelIndex];var currentValue=level.items[level.index];while(--levelIndex>=0){level=this.levels[levelIndex];level.items[level.index]=currentValue}},nextLevel:function InclusionTree_nextLevel(){var currentLevel=this.currentLevel;var level=this.levels[currentLevel];var value=level.items[level.index];level.items[level.index]=255;currentLevel--;if(currentLevel<0){return false}this.currentLevel=currentLevel;level=this.levels[currentLevel];level.items[level.index]=value;return true}};return InclusionTree}();var BitModel=function BitModelClosure(){var UNIFORM_CONTEXT=17;var RUNLENGTH_CONTEXT=18;var LLAndLHContextsLabel=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]);var HLContextLabel=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]);var HHContextLabel=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);function BitModel(width,height,subband,zeroBitPlanes,mb){this.width=width;this.height=height;this.contextLabelTable=subband==="HH"?HHContextLabel:subband==="HL"?HLContextLabel:LLAndLHContextsLabel;var coefficientCount=width*height;this.neighborsSignificance=new Uint8Array(coefficientCount);this.coefficentsSign=new Uint8Array(coefficientCount);this.coefficentsMagnitude=mb>14?new Uint32Array(coefficientCount):mb>6?new Uint16Array(coefficientCount):new Uint8Array(coefficientCount);this.processingFlags=new Uint8Array(coefficientCount);var bitsDecoded=new Uint8Array(coefficientCount);if(zeroBitPlanes!==0){for(var i=0;i<coefficientCount;i++){bitsDecoded[i]=zeroBitPlanes}}this.bitsDecoded=bitsDecoded;this.reset()}BitModel.prototype={setDecoder:function BitModel_setDecoder(decoder){this.decoder=decoder},reset:function BitModel_reset(){this.contexts=new Int8Array(19);this.contexts[0]=4<<1|0;this.contexts[UNIFORM_CONTEXT]=46<<1|0;this.contexts[RUNLENGTH_CONTEXT]=3<<1|0},setNeighborsSignificance:function BitModel_setNeighborsSignificance(row,column,index){var neighborsSignificance=this.neighborsSignificance;var width=this.width,height=this.height;var left=column>0;var right=column+1<width;var i;if(row>0){i=index-width;if(left){neighborsSignificance[i-1]+=16}if(right){neighborsSignificance[i+1]+=16}neighborsSignificance[i]+=4}if(row+1<height){i=index+width;if(left){neighborsSignificance[i-1]+=16}if(right){neighborsSignificance[i+1]+=16}neighborsSignificance[i]+=4}if(left){neighborsSignificance[index-1]+=1}if(right){neighborsSignificance[index+1]+=1}neighborsSignificance[index]|=128},runSignificancePropagationPass:function BitModel_runSignificancePropagationPass(){var decoder=this.decoder;var width=this.width,height=this.height;var coefficentsMagnitude=this.coefficentsMagnitude;var coefficentsSign=this.coefficentsSign;var neighborsSignificance=this.neighborsSignificance;var processingFlags=this.processingFlags;var contexts=this.contexts;var labels=this.contextLabelTable;var bitsDecoded=this.bitsDecoded;var processedInverseMask=~1;var processedMask=1;var firstMagnitudeBitMask=2;for(var i0=0;i0<height;i0+=4){for(var j=0;j<width;j++){var index=i0*width+j;for(var i1=0;i1<4;i1++,index+=width){var i=i0+i1;if(i>=height){break}processingFlags[index]&=processedInverseMask;if(coefficentsMagnitude[index]||!neighborsSignificance[index]){continue}var contextLabel=labels[neighborsSignificance[index]];var decision=decoder.readBit(contexts,contextLabel);if(decision){var sign=this.decodeSignBit(i,j,index);coefficentsSign[index]=sign;coefficentsMagnitude[index]=1;this.setNeighborsSignificance(i,j,index);processingFlags[index]|=firstMagnitudeBitMask}bitsDecoded[index]++;processingFlags[index]|=processedMask}}}},decodeSignBit:function BitModel_decodeSignBit(row,column,index){var width=this.width,height=this.height;var coefficentsMagnitude=this.coefficentsMagnitude;var coefficentsSign=this.coefficentsSign;var contribution,sign0,sign1,significance1;var contextLabel,decoded;significance1=column>0&&coefficentsMagnitude[index-1]!==0;if(column+1<width&&coefficentsMagnitude[index+1]!==0){sign1=coefficentsSign[index+1];if(significance1){sign0=coefficentsSign[index-1];contribution=1-sign1-sign0}else{contribution=1-sign1-sign1}}else if(significance1){sign0=coefficentsSign[index-1];contribution=1-sign0-sign0}else{contribution=0}var horizontalContribution=3*contribution;significance1=row>0&&coefficentsMagnitude[index-width]!==0;if(row+1<height&&coefficentsMagnitude[index+width]!==0){sign1=coefficentsSign[index+width];if(significance1){sign0=coefficentsSign[index-width];contribution=1-sign1-sign0+horizontalContribution}else{contribution=1-sign1-sign1+horizontalContribution}}else if(significance1){sign0=coefficentsSign[index-width];contribution=1-sign0-sign0+horizontalContribution}else{contribution=horizontalContribution}if(contribution>=0){contextLabel=9+contribution;decoded=this.decoder.readBit(this.contexts,contextLabel)}else{contextLabel=9-contribution;decoded=this.decoder.readBit(this.contexts,contextLabel)^1}return decoded},runMagnitudeRefinementPass:function BitModel_runMagnitudeRefinementPass(){var decoder=this.decoder;var width=this.width,height=this.height;var coefficentsMagnitude=this.coefficentsMagnitude;var neighborsSignificance=this.neighborsSignificance;var contexts=this.contexts;var bitsDecoded=this.bitsDecoded;var processingFlags=this.processingFlags;var processedMask=1;var firstMagnitudeBitMask=2;var length=width*height;var width4=width*4;for(var index0=0,indexNext;index0<length;index0=indexNext){indexNext=Math.min(length,index0+width4);for(var j=0;j<width;j++){for(var index=index0+j;index<indexNext;index+=width){if(!coefficentsMagnitude[index]||(processingFlags[index]&processedMask)!==0){continue}var contextLabel=16;if((processingFlags[index]&firstMagnitudeBitMask)!==0){processingFlags[index]^=firstMagnitudeBitMask;var significance=neighborsSignificance[index]&127;contextLabel=significance===0?15:14}var bit=decoder.readBit(contexts,contextLabel);coefficentsMagnitude[index]=coefficentsMagnitude[index]<<1|bit;bitsDecoded[index]++;processingFlags[index]|=processedMask}}}},runCleanupPass:function BitModel_runCleanupPass(){var decoder=this.decoder;var width=this.width,height=this.height;var neighborsSignificance=this.neighborsSignificance;var coefficentsMagnitude=this.coefficentsMagnitude;var coefficentsSign=this.coefficentsSign;var contexts=this.contexts;var labels=this.contextLabelTable;var bitsDecoded=this.bitsDecoded;var processingFlags=this.processingFlags;var processedMask=1;var firstMagnitudeBitMask=2;var oneRowDown=width;var twoRowsDown=width*2;var threeRowsDown=width*3;var iNext;for(var i0=0;i0<height;i0=iNext){iNext=Math.min(i0+4,height);var indexBase=i0*width;var checkAllEmpty=i0+3<height;for(var j=0;j<width;j++){var index0=indexBase+j;var allEmpty=checkAllEmpty&&processingFlags[index0]===0&&processingFlags[index0+oneRowDown]===0&&processingFlags[index0+twoRowsDown]===0&&processingFlags[index0+threeRowsDown]===0&&neighborsSignificance[index0]===0&&neighborsSignificance[index0+oneRowDown]===0&&neighborsSignificance[index0+twoRowsDown]===0&&neighborsSignificance[index0+threeRowsDown]===0;var i1=0,index=index0;var i=i0,sign;if(allEmpty){var hasSignificantCoefficent=decoder.readBit(contexts,RUNLENGTH_CONTEXT);if(!hasSignificantCoefficent){bitsDecoded[index0]++;bitsDecoded[index0+oneRowDown]++;bitsDecoded[index0+twoRowsDown]++;bitsDecoded[index0+threeRowsDown]++;continue}i1=decoder.readBit(contexts,UNIFORM_CONTEXT)<<1|decoder.readBit(contexts,UNIFORM_CONTEXT);if(i1!==0){i=i0+i1;index+=i1*width}sign=this.decodeSignBit(i,j,index);coefficentsSign[index]=sign;coefficentsMagnitude[index]=1;this.setNeighborsSignificance(i,j,index);processingFlags[index]|=firstMagnitudeBitMask;index=index0;for(var i2=i0;i2<=i;i2++,index+=width){bitsDecoded[index]++}i1++}for(i=i0+i1;i<iNext;i++,index+=width){if(coefficentsMagnitude[index]||(processingFlags[index]&processedMask)!==0){continue}var contextLabel=labels[neighborsSignificance[index]];var decision=decoder.readBit(contexts,contextLabel);if(decision===1){sign=this.decodeSignBit(i,j,index);coefficentsSign[index]=sign;coefficentsMagnitude[index]=1;this.setNeighborsSignificance(i,j,index);processingFlags[index]|=firstMagnitudeBitMask}bitsDecoded[index]++}}}},checkSegmentationSymbol:function BitModel_checkSegmentationSymbol(){var decoder=this.decoder;var contexts=this.contexts;var symbol=decoder.readBit(contexts,UNIFORM_CONTEXT)<<3|decoder.readBit(contexts,UNIFORM_CONTEXT)<<2|decoder.readBit(contexts,UNIFORM_CONTEXT)<<1|decoder.readBit(contexts,UNIFORM_CONTEXT);if(symbol!==10){error("JPX Error: Invalid segmentation symbol")}}};return BitModel}();var Transform=function TransformClosure(){function Transform(){}Transform.prototype.calculate=function transformCalculate(subbands,u0,v0){var ll=subbands[0];for(var i=1,ii=subbands.length;i<ii;i++){ll=this.iterate(ll,subbands[i],u0,v0)}return ll};Transform.prototype.extend=function extend(buffer,offset,size){var i1=offset-1,j1=offset+1;var i2=offset+size-2,j2=offset+size;buffer[i1--]=buffer[j1++];buffer[j2++]=buffer[i2--];buffer[i1--]=buffer[j1++];buffer[j2++]=buffer[i2--];buffer[i1--]=buffer[j1++];buffer[j2++]=buffer[i2--];buffer[i1]=buffer[j1];buffer[j2]=buffer[i2]};Transform.prototype.iterate=function Transform_iterate(ll,hl_lh_hh,u0,v0){var llWidth=ll.width,llHeight=ll.height,llItems=ll.items;var width=hl_lh_hh.width;var height=hl_lh_hh.height;var items=hl_lh_hh.items;var i,j,k,l,u,v;for(k=0,i=0;i<llHeight;i++){l=i*2*width;for(j=0;j<llWidth;j++,k++,l+=2){items[l]=llItems[k]}}llItems=ll.items=null;var bufferPadding=4;var rowBuffer=new Float32Array(width+2*bufferPadding);if(width===1){if((u0&1)!==0){for(v=0,k=0;v<height;v++,k+=width){items[k]*=.5}}}else{for(v=0,k=0;v<height;v++,k+=width){rowBuffer.set(items.subarray(k,k+width),bufferPadding);this.extend(rowBuffer,bufferPadding,width);this.filter(rowBuffer,bufferPadding,width);items.set(rowBuffer.subarray(bufferPadding,bufferPadding+width),k)}}var numBuffers=16;var colBuffers=[];for(i=0;i<numBuffers;i++){colBuffers.push(new Float32Array(height+2*bufferPadding))}var b,currentBuffer=0;ll=bufferPadding+height;if(height===1){if((v0&1)!==0){for(u=0;u<width;u++){items[u]*=.5}}}else{for(u=0;u<width;u++){if(currentBuffer===0){numBuffers=Math.min(width-u,numBuffers);for(k=u,l=bufferPadding;l<ll;k+=width,l++){for(b=0;b<numBuffers;b++){colBuffers[b][l]=items[k+b]}}currentBuffer=numBuffers}currentBuffer--;var buffer=colBuffers[currentBuffer];this.extend(buffer,bufferPadding,height);this.filter(buffer,bufferPadding,height);if(currentBuffer===0){k=u-numBuffers+1;for(l=bufferPadding;l<ll;k+=width,l++){for(b=0;b<numBuffers;b++){items[k+b]=colBuffers[b][l]}}}}}return{width:width,height:height,items:items}};return Transform}();var IrreversibleTransform=function IrreversibleTransformClosure(){function IrreversibleTransform(){Transform.call(this)}IrreversibleTransform.prototype=Object.create(Transform.prototype);IrreversibleTransform.prototype.filter=function irreversibleTransformFilter(x,offset,length){var len=length>>1;offset=offset|0;var j,n,current,next;var alpha=-1.586134342059924;var beta=-.052980118572961;var gamma=.882911075530934;var delta=.443506852043971;var K=1.230174104914001;var K_=1/K;j=offset-3;for(n=len+4;n--;j+=2){x[j]*=K_}j=offset-2;current=delta*x[j-1];for(n=len+3;n--;j+=2){next=delta*x[j+1];x[j]=K*x[j]-current-next;if(n--){j+=2;current=delta*x[j+1];x[j]=K*x[j]-current-next}else{break}}j=offset-1;current=gamma*x[j-1];for(n=len+2;n--;j+=2){next=gamma*x[j+1];x[j]-=current+next;if(n--){j+=2;current=gamma*x[j+1];x[j]-=current+next}else{break}}j=offset;current=beta*x[j-1];for(n=len+1;n--;j+=2){next=beta*x[j+1];x[j]-=current+next;if(n--){j+=2;current=beta*x[j+1];x[j]-=current+next}else{break}}if(len!==0){j=offset+1;current=alpha*x[j-1];for(n=len;n--;j+=2){next=alpha*x[j+1];x[j]-=current+next;if(n--){j+=2;current=alpha*x[j+1];x[j]-=current+next}else{break}}}};return IrreversibleTransform}();var ReversibleTransform=function ReversibleTransformClosure(){function ReversibleTransform(){Transform.call(this)}ReversibleTransform.prototype=Object.create(Transform.prototype);ReversibleTransform.prototype.filter=function reversibleTransformFilter(x,offset,length){var len=length>>1;offset=offset|0;var j,n;for(j=offset,n=len+1;n--;j+=2){x[j]-=x[j-1]+x[j+1]+2>>2}for(j=offset+1,n=len;n--;j+=2){x[j]+=x[j-1]+x[j+1]>>1}};return ReversibleTransform}();return JpxImage}();exports.JpxImage=JpxImage});(function(root,factory){{factory(root.pdfjsCoreMetrics={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var getLookupTableFactory=sharedUtil.getLookupTableFactory;var getMetrics=getLookupTableFactory(function(t){t["Courier"]=600;t["Courier-Bold"]=600;t["Courier-BoldOblique"]=600;t["Courier-Oblique"]=600;t["Helvetica"]=getLookupTableFactory(function(t){t["space"]=278;t["exclam"]=278;t["quotedbl"]=355;t["numbersign"]=556;t["dollar"]=556;t["percent"]=889;t["ampersand"]=667;t["quoteright"]=222;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=389;t["plus"]=584;t["comma"]=278;t["hyphen"]=333;t["period"]=278;t["slash"]=278;t["zero"]=556;t["one"]=556;t["two"]=556;t["three"]=556;t["four"]=556;t["five"]=556;t["six"]=556;t["seven"]=556;t["eight"]=556;t["nine"]=556;t["colon"]=278;t["semicolon"]=278;t["less"]=584;t["equal"]=584;t["greater"]=584;t["question"]=556;t["at"]=1015;t["A"]=667;t["B"]=667;t["C"]=722;t["D"]=722;t["E"]=667;t["F"]=611;t["G"]=778;t["H"]=722;t["I"]=278;t["J"]=500;t["K"]=667;t["L"]=556;t["M"]=833;t["N"]=722;t["O"]=778;t["P"]=667;t["Q"]=778;t["R"]=722;t["S"]=667;t["T"]=611;t["U"]=722;t["V"]=667;t["W"]=944;t["X"]=667;t["Y"]=667;t["Z"]=611;t["bracketleft"]=278;t["backslash"]=278;t["bracketright"]=278;t["asciicircum"]=469;t["underscore"]=556;t["quoteleft"]=222;t["a"]=556;t["b"]=556;t["c"]=500;t["d"]=556;t["e"]=556;t["f"]=278;t["g"]=556;t["h"]=556;t["i"]=222;t["j"]=222;t["k"]=500;t["l"]=222;t["m"]=833;t["n"]=556;t["o"]=556;t["p"]=556;t["q"]=556;t["r"]=333;t["s"]=500;t["t"]=278;t["u"]=556;t["v"]=500;t["w"]=722;t["x"]=500;t["y"]=500;t["z"]=500;t["braceleft"]=334;t["bar"]=260;t["braceright"]=334;t["asciitilde"]=584;t["exclamdown"]=333;t["cent"]=556;t["sterling"]=556;t["fraction"]=167;t["yen"]=556;t["florin"]=556;t["section"]=556;t["currency"]=556;t["quotesingle"]=191;t["quotedblleft"]=333;t["guillemotleft"]=556;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=500;t["fl"]=500;t["endash"]=556;t["dagger"]=556;t["daggerdbl"]=556;t["periodcentered"]=278;t["paragraph"]=537;t["bullet"]=350;t["quotesinglbase"]=222;t["quotedblbase"]=333;t["quotedblright"]=333;t["guillemotright"]=556;t["ellipsis"]=1e3;t["perthousand"]=1e3;t["questiondown"]=611;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=1e3;t["AE"]=1e3;t["ordfeminine"]=370;t["Lslash"]=556;t["Oslash"]=778;t["OE"]=1e3;t["ordmasculine"]=365;t["ae"]=889;t["dotlessi"]=278;t["lslash"]=222;t["oslash"]=611;t["oe"]=944;t["germandbls"]=611;t["Idieresis"]=278;t["eacute"]=556;t["abreve"]=556;t["uhungarumlaut"]=556;t["ecaron"]=556;t["Ydieresis"]=667;t["divide"]=584;t["Yacute"]=667;t["Acircumflex"]=667;t["aacute"]=556;t["Ucircumflex"]=722;t["yacute"]=500;t["scommaaccent"]=500;t["ecircumflex"]=556;t["Uring"]=722;t["Udieresis"]=722;t["aogonek"]=556;t["Uacute"]=722;t["uogonek"]=556;t["Edieresis"]=667;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=737;t["Emacron"]=667;t["ccaron"]=500;t["aring"]=556;t["Ncommaaccent"]=722;t["lacute"]=222;t["agrave"]=556;t["Tcommaaccent"]=611;t["Cacute"]=722;t["atilde"]=556;t["Edotaccent"]=667;t["scaron"]=500;t["scedilla"]=500;t["iacute"]=278;t["lozenge"]=471;t["Rcaron"]=722;t["Gcommaaccent"]=778;t["ucircumflex"]=556;t["acircumflex"]=556;t["Amacron"]=667;t["rcaron"]=333;t["ccedilla"]=500;t["Zdotaccent"]=611;t["Thorn"]=667;t["Omacron"]=778;t["Racute"]=722;t["Sacute"]=667;t["dcaron"]=643;t["Umacron"]=722;t["uring"]=556;t["threesuperior"]=333;t["Ograve"]=778;t["Agrave"]=667;t["Abreve"]=667;t["multiply"]=584;t["uacute"]=556;t["Tcaron"]=611;t["partialdiff"]=476;t["ydieresis"]=500;t["Nacute"]=722;t["icircumflex"]=278;t["Ecircumflex"]=667;t["adieresis"]=556;t["edieresis"]=556;t["cacute"]=500;t["nacute"]=556;t["umacron"]=556;t["Ncaron"]=722;t["Iacute"]=278;t["plusminus"]=584;t["brokenbar"]=260;t["registered"]=737;t["Gbreve"]=778;t["Idotaccent"]=278;t["summation"]=600;t["Egrave"]=667;t["racute"]=333;t["omacron"]=556;t["Zacute"]=611;t["Zcaron"]=611;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=722;t["lcommaaccent"]=222;t["tcaron"]=317;t["eogonek"]=556;t["Uogonek"]=722;t["Aacute"]=667;t["Adieresis"]=667;t["egrave"]=556;t["zacute"]=500;t["iogonek"]=222;t["Oacute"]=778;t["oacute"]=556;t["amacron"]=556;t["sacute"]=500;t["idieresis"]=278;t["Ocircumflex"]=778;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=556;t["twosuperior"]=333;t["Odieresis"]=778;t["mu"]=556;t["igrave"]=278;t["ohungarumlaut"]=556;t["Eogonek"]=667;t["dcroat"]=556;t["threequarters"]=834;t["Scedilla"]=667;t["lcaron"]=299;t["Kcommaaccent"]=667;t["Lacute"]=556;t["trademark"]=1e3;t["edotaccent"]=556;t["Igrave"]=278;t["Imacron"]=278;t["Lcaron"]=556;t["onehalf"]=834;t["lessequal"]=549;t["ocircumflex"]=556;t["ntilde"]=556;t["Uhungarumlaut"]=722;t["Eacute"]=667;t["emacron"]=556;t["gbreve"]=556;t["onequarter"]=834;t["Scaron"]=667;t["Scommaaccent"]=667;t["Ohungarumlaut"]=778;t["degree"]=400;t["ograve"]=556;t["Ccaron"]=722;t["ugrave"]=556;t["radical"]=453;t["Dcaron"]=722;t["rcommaaccent"]=333;t["Ntilde"]=722;t["otilde"]=556;t["Rcommaaccent"]=722;t["Lcommaaccent"]=556;t["Atilde"]=667;t["Aogonek"]=667;t["Aring"]=667;t["Otilde"]=778;t["zdotaccent"]=500;t["Ecaron"]=667;t["Iogonek"]=278;t["kcommaaccent"]=500;t["minus"]=584;t["Icircumflex"]=278;t["ncaron"]=556;t["tcommaaccent"]=278;t["logicalnot"]=584;t["odieresis"]=556;t["udieresis"]=556;t["notequal"]=549;t["gcommaaccent"]=556;t["eth"]=556;t["zcaron"]=500;t["ncommaaccent"]=556;t["onesuperior"]=333;t["imacron"]=278;t["Euro"]=556});t["Helvetica-Bold"]=getLookupTableFactory(function(t){t["space"]=278;t["exclam"]=333;t["quotedbl"]=474;t["numbersign"]=556;t["dollar"]=556;t["percent"]=889;t["ampersand"]=722;t["quoteright"]=278;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=389;t["plus"]=584;t["comma"]=278;t["hyphen"]=333;
11t["period"]=278;t["slash"]=278;t["zero"]=556;t["one"]=556;t["two"]=556;t["three"]=556;t["four"]=556;t["five"]=556;t["six"]=556;t["seven"]=556;t["eight"]=556;t["nine"]=556;t["colon"]=333;t["semicolon"]=333;t["less"]=584;t["equal"]=584;t["greater"]=584;t["question"]=611;t["at"]=975;t["A"]=722;t["B"]=722;t["C"]=722;t["D"]=722;t["E"]=667;t["F"]=611;t["G"]=778;t["H"]=722;t["I"]=278;t["J"]=556;t["K"]=722;t["L"]=611;t["M"]=833;t["N"]=722;t["O"]=778;t["P"]=667;t["Q"]=778;t["R"]=722;t["S"]=667;t["T"]=611;t["U"]=722;t["V"]=667;t["W"]=944;t["X"]=667;t["Y"]=667;t["Z"]=611;t["bracketleft"]=333;t["backslash"]=278;t["bracketright"]=333;t["asciicircum"]=584;t["underscore"]=556;t["quoteleft"]=278;t["a"]=556;t["b"]=611;t["c"]=556;t["d"]=611;t["e"]=556;t["f"]=333;t["g"]=611;t["h"]=611;t["i"]=278;t["j"]=278;t["k"]=556;t["l"]=278;t["m"]=889;t["n"]=611;t["o"]=611;t["p"]=611;t["q"]=611;t["r"]=389;t["s"]=556;t["t"]=333;t["u"]=611;t["v"]=556;t["w"]=778;t["x"]=556;t["y"]=556;t["z"]=500;t["braceleft"]=389;t["bar"]=280;t["braceright"]=389;t["asciitilde"]=584;t["exclamdown"]=333;t["cent"]=556;t["sterling"]=556;t["fraction"]=167;t["yen"]=556;t["florin"]=556;t["section"]=556;t["currency"]=556;t["quotesingle"]=238;t["quotedblleft"]=500;t["guillemotleft"]=556;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=611;t["fl"]=611;t["endash"]=556;t["dagger"]=556;t["daggerdbl"]=556;t["periodcentered"]=278;t["paragraph"]=556;t["bullet"]=350;t["quotesinglbase"]=278;t["quotedblbase"]=500;t["quotedblright"]=500;t["guillemotright"]=556;t["ellipsis"]=1e3;t["perthousand"]=1e3;t["questiondown"]=611;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=1e3;t["AE"]=1e3;t["ordfeminine"]=370;t["Lslash"]=611;t["Oslash"]=778;t["OE"]=1e3;t["ordmasculine"]=365;t["ae"]=889;t["dotlessi"]=278;t["lslash"]=278;t["oslash"]=611;t["oe"]=944;t["germandbls"]=611;t["Idieresis"]=278;t["eacute"]=556;t["abreve"]=556;t["uhungarumlaut"]=611;t["ecaron"]=556;t["Ydieresis"]=667;t["divide"]=584;t["Yacute"]=667;t["Acircumflex"]=722;t["aacute"]=556;t["Ucircumflex"]=722;t["yacute"]=556;t["scommaaccent"]=556;t["ecircumflex"]=556;t["Uring"]=722;t["Udieresis"]=722;t["aogonek"]=556;t["Uacute"]=722;t["uogonek"]=611;t["Edieresis"]=667;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=737;t["Emacron"]=667;t["ccaron"]=556;t["aring"]=556;t["Ncommaaccent"]=722;t["lacute"]=278;t["agrave"]=556;t["Tcommaaccent"]=611;t["Cacute"]=722;t["atilde"]=556;t["Edotaccent"]=667;t["scaron"]=556;t["scedilla"]=556;t["iacute"]=278;t["lozenge"]=494;t["Rcaron"]=722;t["Gcommaaccent"]=778;t["ucircumflex"]=611;t["acircumflex"]=556;t["Amacron"]=722;t["rcaron"]=389;t["ccedilla"]=556;t["Zdotaccent"]=611;t["Thorn"]=667;t["Omacron"]=778;t["Racute"]=722;t["Sacute"]=667;t["dcaron"]=743;t["Umacron"]=722;t["uring"]=611;t["threesuperior"]=333;t["Ograve"]=778;t["Agrave"]=722;t["Abreve"]=722;t["multiply"]=584;t["uacute"]=611;t["Tcaron"]=611;t["partialdiff"]=494;t["ydieresis"]=556;t["Nacute"]=722;t["icircumflex"]=278;t["Ecircumflex"]=667;t["adieresis"]=556;t["edieresis"]=556;t["cacute"]=556;t["nacute"]=611;t["umacron"]=611;t["Ncaron"]=722;t["Iacute"]=278;t["plusminus"]=584;t["brokenbar"]=280;t["registered"]=737;t["Gbreve"]=778;t["Idotaccent"]=278;t["summation"]=600;t["Egrave"]=667;t["racute"]=389;t["omacron"]=611;t["Zacute"]=611;t["Zcaron"]=611;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=722;t["lcommaaccent"]=278;t["tcaron"]=389;t["eogonek"]=556;t["Uogonek"]=722;t["Aacute"]=722;t["Adieresis"]=722;t["egrave"]=556;t["zacute"]=500;t["iogonek"]=278;t["Oacute"]=778;t["oacute"]=611;t["amacron"]=556;t["sacute"]=556;t["idieresis"]=278;t["Ocircumflex"]=778;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=611;t["twosuperior"]=333;t["Odieresis"]=778;t["mu"]=611;t["igrave"]=278;t["ohungarumlaut"]=611;t["Eogonek"]=667;t["dcroat"]=611;t["threequarters"]=834;t["Scedilla"]=667;t["lcaron"]=400;t["Kcommaaccent"]=722;t["Lacute"]=611;t["trademark"]=1e3;t["edotaccent"]=556;t["Igrave"]=278;t["Imacron"]=278;t["Lcaron"]=611;t["onehalf"]=834;t["lessequal"]=549;t["ocircumflex"]=611;t["ntilde"]=611;t["Uhungarumlaut"]=722;t["Eacute"]=667;t["emacron"]=556;t["gbreve"]=611;t["onequarter"]=834;t["Scaron"]=667;t["Scommaaccent"]=667;t["Ohungarumlaut"]=778;t["degree"]=400;t["ograve"]=611;t["Ccaron"]=722;t["ugrave"]=611;t["radical"]=549;t["Dcaron"]=722;t["rcommaaccent"]=389;t["Ntilde"]=722;t["otilde"]=611;t["Rcommaaccent"]=722;t["Lcommaaccent"]=611;t["Atilde"]=722;t["Aogonek"]=722;t["Aring"]=722;t["Otilde"]=778;t["zdotaccent"]=500;t["Ecaron"]=667;t["Iogonek"]=278;t["kcommaaccent"]=556;t["minus"]=584;t["Icircumflex"]=278;t["ncaron"]=611;t["tcommaaccent"]=333;t["logicalnot"]=584;t["odieresis"]=611;t["udieresis"]=611;t["notequal"]=549;t["gcommaaccent"]=611;t["eth"]=611;t["zcaron"]=500;t["ncommaaccent"]=611;t["onesuperior"]=333;t["imacron"]=278;t["Euro"]=556});t["Helvetica-BoldOblique"]=getLookupTableFactory(function(t){t["space"]=278;t["exclam"]=333;t["quotedbl"]=474;t["numbersign"]=556;t["dollar"]=556;t["percent"]=889;t["ampersand"]=722;t["quoteright"]=278;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=389;t["plus"]=584;t["comma"]=278;t["hyphen"]=333;t["period"]=278;t["slash"]=278;t["zero"]=556;t["one"]=556;t["two"]=556;t["three"]=556;t["four"]=556;t["five"]=556;t["six"]=556;t["seven"]=556;t["eight"]=556;t["nine"]=556;t["colon"]=333;t["semicolon"]=333;t["less"]=584;t["equal"]=584;t["greater"]=584;t["question"]=611;t["at"]=975;t["A"]=722;t["B"]=722;t["C"]=722;t["D"]=722;t["E"]=667;t["F"]=611;t["G"]=778;t["H"]=722;t["I"]=278;t["J"]=556;t["K"]=722;t["L"]=611;t["M"]=833;t["N"]=722;t["O"]=778;t["P"]=667;t["Q"]=778;t["R"]=722;t["S"]=667;t["T"]=611;t["U"]=722;t["V"]=667;t["W"]=944;t["X"]=667;t["Y"]=667;t["Z"]=611;t["bracketleft"]=333;t["backslash"]=278;t["bracketright"]=333;t["asciicircum"]=584;t["underscore"]=556;t["quoteleft"]=278;t["a"]=556;t["b"]=611;t["c"]=556;t["d"]=611;t["e"]=556;t["f"]=333;t["g"]=611;t["h"]=611;t["i"]=278;t["j"]=278;t["k"]=556;t["l"]=278;t["m"]=889;t["n"]=611;t["o"]=611;t["p"]=611;t["q"]=611;t["r"]=389;t["s"]=556;t["t"]=333;t["u"]=611;t["v"]=556;t["w"]=778;t["x"]=556;t["y"]=556;t["z"]=500;t["braceleft"]=389;t["bar"]=280;t["braceright"]=389;t["asciitilde"]=584;t["exclamdown"]=333;t["cent"]=556;t["sterling"]=556;t["fraction"]=167;t["yen"]=556;t["florin"]=556;t["section"]=556;t["currency"]=556;t["quotesingle"]=238;t["quotedblleft"]=500;t["guillemotleft"]=556;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=611;t["fl"]=611;t["endash"]=556;t["dagger"]=556;t["daggerdbl"]=556;t["periodcentered"]=278;t["paragraph"]=556;t["bullet"]=350;t["quotesinglbase"]=278;t["quotedblbase"]=500;t["quotedblright"]=500;t["guillemotright"]=556;t["ellipsis"]=1e3;t["perthousand"]=1e3;t["questiondown"]=611;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=1e3;t["AE"]=1e3;t["ordfeminine"]=370;t["Lslash"]=611;t["Oslash"]=778;t["OE"]=1e3;t["ordmasculine"]=365;t["ae"]=889;t["dotlessi"]=278;t["lslash"]=278;t["oslash"]=611;t["oe"]=944;t["germandbls"]=611;t["Idieresis"]=278;t["eacute"]=556;t["abreve"]=556;t["uhungarumlaut"]=611;t["ecaron"]=556;t["Ydieresis"]=667;t["divide"]=584;t["Yacute"]=667;t["Acircumflex"]=722;t["aacute"]=556;t["Ucircumflex"]=722;t["yacute"]=556;t["scommaaccent"]=556;t["ecircumflex"]=556;t["Uring"]=722;t["Udieresis"]=722;t["aogonek"]=556;t["Uacute"]=722;t["uogonek"]=611;t["Edieresis"]=667;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=737;t["Emacron"]=667;t["ccaron"]=556;t["aring"]=556;t["Ncommaaccent"]=722;t["lacute"]=278;t["agrave"]=556;t["Tcommaaccent"]=611;t["Cacute"]=722;t["atilde"]=556;t["Edotaccent"]=667;t["scaron"]=556;t["scedilla"]=556;t["iacute"]=278;t["lozenge"]=494;t["Rcaron"]=722;t["Gcommaaccent"]=778;t["ucircumflex"]=611;t["acircumflex"]=556;t["Amacron"]=722;t["rcaron"]=389;t["ccedilla"]=556;t["Zdotaccent"]=611;t["Thorn"]=667;t["Omacron"]=778;t["Racute"]=722;t["Sacute"]=667;t["dcaron"]=743;t["Umacron"]=722;t["uring"]=611;t["threesuperior"]=333;t["Ograve"]=778;t["Agrave"]=722;t["Abreve"]=722;t["multiply"]=584;t["uacute"]=611;t["Tcaron"]=611;t["partialdiff"]=494;t["ydieresis"]=556;t["Nacute"]=722;t["icircumflex"]=278;t["Ecircumflex"]=667;t["adieresis"]=556;t["edieresis"]=556;t["cacute"]=556;t["nacute"]=611;t["umacron"]=611;t["Ncaron"]=722;t["Iacute"]=278;t["plusminus"]=584;t["brokenbar"]=280;t["registered"]=737;t["Gbreve"]=778;t["Idotaccent"]=278;t["summation"]=600;t["Egrave"]=667;t["racute"]=389;t["omacron"]=611;t["Zacute"]=611;t["Zcaron"]=611;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=722;t["lcommaaccent"]=278;t["tcaron"]=389;t["eogonek"]=556;t["Uogonek"]=722;t["Aacute"]=722;t["Adieresis"]=722;t["egrave"]=556;t["zacute"]=500;t["iogonek"]=278;t["Oacute"]=778;t["oacute"]=611;t["amacron"]=556;t["sacute"]=556;t["idieresis"]=278;t["Ocircumflex"]=778;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=611;t["twosuperior"]=333;t["Odieresis"]=778;t["mu"]=611;t["igrave"]=278;t["ohungarumlaut"]=611;t["Eogonek"]=667;t["dcroat"]=611;t["threequarters"]=834;t["Scedilla"]=667;t["lcaron"]=400;t["Kcommaaccent"]=722;t["Lacute"]=611;t["trademark"]=1e3;t["edotaccent"]=556;t["Igrave"]=278;t["Imacron"]=278;t["Lcaron"]=611;t["onehalf"]=834;t["lessequal"]=549;t["ocircumflex"]=611;t["ntilde"]=611;t["Uhungarumlaut"]=722;t["Eacute"]=667;t["emacron"]=556;t["gbreve"]=611;t["onequarter"]=834;t["Scaron"]=667;t["Scommaaccent"]=667;t["Ohungarumlaut"]=778;t["degree"]=400;t["ograve"]=611;t["Ccaron"]=722;t["ugrave"]=611;t["radical"]=549;t["Dcaron"]=722;t["rcommaaccent"]=389;t["Ntilde"]=722;t["otilde"]=611;t["Rcommaaccent"]=722;t["Lcommaaccent"]=611;t["Atilde"]=722;t["Aogonek"]=722;t["Aring"]=722;t["Otilde"]=778;t["zdotaccent"]=500;t["Ecaron"]=667;t["Iogonek"]=278;t["kcommaaccent"]=556;t["minus"]=584;t["Icircumflex"]=278;t["ncaron"]=611;t["tcommaaccent"]=333;t["logicalnot"]=584;t["odieresis"]=611;t["udieresis"]=611;t["notequal"]=549;t["gcommaaccent"]=611;t["eth"]=611;t["zcaron"]=500;t["ncommaaccent"]=611;t["onesuperior"]=333;t["imacron"]=278;t["Euro"]=556});t["Helvetica-Oblique"]=getLookupTableFactory(function(t){t["space"]=278;t["exclam"]=278;t["quotedbl"]=355;t["numbersign"]=556;t["dollar"]=556;t["percent"]=889;t["ampersand"]=667;t["quoteright"]=222;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=389;t["plus"]=584;t["comma"]=278;t["hyphen"]=333;t["period"]=278;t["slash"]=278;t["zero"]=556;t["one"]=556;t["two"]=556;t["three"]=556;t["four"]=556;t["five"]=556;t["six"]=556;t["seven"]=556;t["eight"]=556;t["nine"]=556;t["colon"]=278;t["semicolon"]=278;t["less"]=584;t["equal"]=584;t["greater"]=584;t["question"]=556;t["at"]=1015;t["A"]=667;t["B"]=667;t["C"]=722;t["D"]=722;t["E"]=667;t["F"]=611;t["G"]=778;t["H"]=722;t["I"]=278;t["J"]=500;t["K"]=667;t["L"]=556;t["M"]=833;t["N"]=722;t["O"]=778;t["P"]=667;t["Q"]=778;t["R"]=722;t["S"]=667;t["T"]=611;t["U"]=722;t["V"]=667;t["W"]=944;t["X"]=667;t["Y"]=667;t["Z"]=611;t["bracketleft"]=278;t["backslash"]=278;t["bracketright"]=278;t["asciicircum"]=469;t["underscore"]=556;t["quoteleft"]=222;t["a"]=556;t["b"]=556;t["c"]=500;t["d"]=556;t["e"]=556;t["f"]=278;t["g"]=556;t["h"]=556;t["i"]=222;t["j"]=222;t["k"]=500;t["l"]=222;t["m"]=833;t["n"]=556;t["o"]=556;t["p"]=556;t["q"]=556;t["r"]=333;t["s"]=500;t["t"]=278;t["u"]=556;t["v"]=500;t["w"]=722;t["x"]=500;t["y"]=500;t["z"]=500;t["braceleft"]=334;t["bar"]=260;t["braceright"]=334;t["asciitilde"]=584;t["exclamdown"]=333;t["cent"]=556;t["sterling"]=556;t["fraction"]=167;t["yen"]=556;t["florin"]=556;t["section"]=556;t["currency"]=556;t["quotesingle"]=191;t["quotedblleft"]=333;t["guillemotleft"]=556;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=500;t["fl"]=500;t["endash"]=556;t["dagger"]=556;t["daggerdbl"]=556;t["periodcentered"]=278;t["paragraph"]=537;t["bullet"]=350;t["quotesinglbase"]=222;t["quotedblbase"]=333;t["quotedblright"]=333;t["guillemotright"]=556;t["ellipsis"]=1e3;t["perthousand"]=1e3;t["questiondown"]=611;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=1e3;t["AE"]=1e3;t["ordfeminine"]=370;t["Lslash"]=556;t["Oslash"]=778;t["OE"]=1e3;t["ordmasculine"]=365;t["ae"]=889;t["dotlessi"]=278;t["lslash"]=222;t["oslash"]=611;t["oe"]=944;t["germandbls"]=611;t["Idieresis"]=278;t["eacute"]=556;t["abreve"]=556;t["uhungarumlaut"]=556;t["ecaron"]=556;t["Ydieresis"]=667;t["divide"]=584;t["Yacute"]=667;t["Acircumflex"]=667;t["aacute"]=556;t["Ucircumflex"]=722;t["yacute"]=500;t["scommaaccent"]=500;t["ecircumflex"]=556;t["Uring"]=722;t["Udieresis"]=722;t["aogonek"]=556;t["Uacute"]=722;t["uogonek"]=556;t["Edieresis"]=667;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=737;t["Emacron"]=667;t["ccaron"]=500;t["aring"]=556;t["Ncommaaccent"]=722;t["lacute"]=222;t["agrave"]=556;t["Tcommaaccent"]=611;t["Cacute"]=722;t["atilde"]=556;t["Edotaccent"]=667;t["scaron"]=500;t["scedilla"]=500;t["iacute"]=278;t["lozenge"]=471;t["Rcaron"]=722;t["Gcommaaccent"]=778;t["ucircumflex"]=556;t["acircumflex"]=556;t["Amacron"]=667;t["rcaron"]=333;t["ccedilla"]=500;t["Zdotaccent"]=611;t["Thorn"]=667;t["Omacron"]=778;t["Racute"]=722;t["Sacute"]=667;t["dcaron"]=643;t["Umacron"]=722;t["uring"]=556;t["threesuperior"]=333;t["Ograve"]=778;t["Agrave"]=667;t["Abreve"]=667;t["multiply"]=584;t["uacute"]=556;t["Tcaron"]=611;t["partialdiff"]=476;t["ydieresis"]=500;t["Nacute"]=722;t["icircumflex"]=278;t["Ecircumflex"]=667;t["adieresis"]=556;t["edieresis"]=556;t["cacute"]=500;t["nacute"]=556;t["umacron"]=556;t["Ncaron"]=722;t["Iacute"]=278;t["plusminus"]=584;t["brokenbar"]=260;t["registered"]=737;t["Gbreve"]=778;t["Idotaccent"]=278;t["summation"]=600;t["Egrave"]=667;t["racute"]=333;t["omacron"]=556;t["Zacute"]=611;t["Zcaron"]=611;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=722;t["lcommaaccent"]=222;t["tcaron"]=317;t["eogonek"]=556;t["Uogonek"]=722;t["Aacute"]=667;t["Adieresis"]=667;t["egrave"]=556;t["zacute"]=500;t["iogonek"]=222;t["Oacute"]=778;t["oacute"]=556;t["amacron"]=556;t["sacute"]=500;t["idieresis"]=278;t["Ocircumflex"]=778;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=556;t["twosuperior"]=333;t["Odieresis"]=778;t["mu"]=556;t["igrave"]=278;t["ohungarumlaut"]=556;t["Eogonek"]=667;t["dcroat"]=556;t["threequarters"]=834;t["Scedilla"]=667;t["lcaron"]=299;t["Kcommaaccent"]=667;t["Lacute"]=556;t["trademark"]=1e3;t["edotaccent"]=556;t["Igrave"]=278;t["Imacron"]=278;t["Lcaron"]=556;t["onehalf"]=834;t["lessequal"]=549;t["ocircumflex"]=556;t["ntilde"]=556;t["Uhungarumlaut"]=722;t["Eacute"]=667;t["emacron"]=556;t["gbreve"]=556;t["onequarter"]=834;t["Scaron"]=667;t["Scommaaccent"]=667;t["Ohungarumlaut"]=778;t["degree"]=400;t["ograve"]=556;t["Ccaron"]=722;t["ugrave"]=556;t["radical"]=453;t["Dcaron"]=722;t["rcommaaccent"]=333;t["Ntilde"]=722;t["otilde"]=556;t["Rcommaaccent"]=722;t["Lcommaaccent"]=556;t["Atilde"]=667;t["Aogonek"]=667;t["Aring"]=667;t["Otilde"]=778;t["zdotaccent"]=500;t["Ecaron"]=667;t["Iogonek"]=278;t["kcommaaccent"]=500;t["minus"]=584;t["Icircumflex"]=278;t["ncaron"]=556;t["tcommaaccent"]=278;t["logicalnot"]=584;t["odieresis"]=556;t["udieresis"]=556;t["notequal"]=549;t["gcommaaccent"]=556;t["eth"]=556;t["zcaron"]=500;t["ncommaaccent"]=556;t["onesuperior"]=333;t["imacron"]=278;t["Euro"]=556});t["Symbol"]=getLookupTableFactory(function(t){t["space"]=250;t["exclam"]=333;t["universal"]=713;t["numbersign"]=500;t["existential"]=549;t["percent"]=833;t["ampersand"]=778;t["suchthat"]=439;t["parenleft"]=333;t["parenright"]=333;t["asteriskmath"]=500;t["plus"]=549;t["comma"]=250;t["minus"]=549;t["period"]=250;t["slash"]=278;t["zero"]=500;t["one"]=500;t["two"]=500;t["three"]=500;t["four"]=500;t["five"]=500;t["six"]=500;t["seven"]=500;t["eight"]=500;t["nine"]=500;t["colon"]=278;t["semicolon"]=278;t["less"]=549;t["equal"]=549;t["greater"]=549;t["question"]=444;t["congruent"]=549;t["Alpha"]=722;t["Beta"]=667;t["Chi"]=722;t["Delta"]=612;t["Epsilon"]=611;t["Phi"]=763;t["Gamma"]=603;t["Eta"]=722;t["Iota"]=333;t["theta1"]=631;t["Kappa"]=722;t["Lambda"]=686;t["Mu"]=889;t["Nu"]=722;t["Omicron"]=722;t["Pi"]=768;t["Theta"]=741;t["Rho"]=556;t["Sigma"]=592;t["Tau"]=611;t["Upsilon"]=690;t["sigma1"]=439;t["Omega"]=768;t["Xi"]=645;t["Psi"]=795;t["Zeta"]=611;t["bracketleft"]=333;t["therefore"]=863;t["bracketright"]=333;t["perpendicular"]=658;t["underscore"]=500;t["radicalex"]=500;t["alpha"]=631;t["beta"]=549;t["chi"]=549;t["delta"]=494;t["epsilon"]=439;t["phi"]=521;t["gamma"]=411;t["eta"]=603;t["iota"]=329;t["phi1"]=603;t["kappa"]=549;t["lambda"]=549;t["mu"]=576;t["nu"]=521;t["omicron"]=549;t["pi"]=549;t["theta"]=521;t["rho"]=549;t["sigma"]=603;t["tau"]=439;t["upsilon"]=576;t["omega1"]=713;t["omega"]=686;t["xi"]=493;t["psi"]=686;t["zeta"]=494;t["braceleft"]=480;t["bar"]=200;t["braceright"]=480;t["similar"]=549;t["Euro"]=750;t["Upsilon1"]=620;t["minute"]=247;t["lessequal"]=549;t["fraction"]=167;t["infinity"]=713;t["florin"]=500;t["club"]=753;t["diamond"]=753;t["heart"]=753;t["spade"]=753;t["arrowboth"]=1042;t["arrowleft"]=987;t["arrowup"]=603;t["arrowright"]=987;t["arrowdown"]=603;t["degree"]=400;t["plusminus"]=549;t["second"]=411;t["greaterequal"]=549;t["multiply"]=549;t["proportional"]=713;t["partialdiff"]=494;t["bullet"]=460;t["divide"]=549;t["notequal"]=549;t["equivalence"]=549;t["approxequal"]=549;t["ellipsis"]=1e3;t["arrowvertex"]=603;t["arrowhorizex"]=1e3;t["carriagereturn"]=658;t["aleph"]=823;t["Ifraktur"]=686;t["Rfraktur"]=795;t["weierstrass"]=987;t["circlemultiply"]=768;t["circleplus"]=768;t["emptyset"]=823;t["intersection"]=768;t["union"]=768;t["propersuperset"]=713;t["reflexsuperset"]=713;t["notsubset"]=713;t["propersubset"]=713;t["reflexsubset"]=713;t["element"]=713;t["notelement"]=713;t["angle"]=768;t["gradient"]=713;t["registerserif"]=790;t["copyrightserif"]=790;t["trademarkserif"]=890;t["product"]=823;t["radical"]=549;t["dotmath"]=250;t["logicalnot"]=713;t["logicaland"]=603;t["logicalor"]=603;t["arrowdblboth"]=1042;t["arrowdblleft"]=987;t["arrowdblup"]=603;t["arrowdblright"]=987;t["arrowdbldown"]=603;t["lozenge"]=494;t["angleleft"]=329;t["registersans"]=790;t["copyrightsans"]=790;t["trademarksans"]=786;t["summation"]=713;t["parenlefttp"]=384;t["parenleftex"]=384;t["parenleftbt"]=384;t["bracketlefttp"]=384;t["bracketleftex"]=384;t["bracketleftbt"]=384;t["bracelefttp"]=494;t["braceleftmid"]=494;t["braceleftbt"]=494;t["braceex"]=494;t["angleright"]=329;t["integral"]=274;t["integraltp"]=686;t["integralex"]=686;t["integralbt"]=686;t["parenrighttp"]=384;t["parenrightex"]=384;t["parenrightbt"]=384;t["bracketrighttp"]=384;t["bracketrightex"]=384;t["bracketrightbt"]=384;t["bracerighttp"]=494;t["bracerightmid"]=494;t["bracerightbt"]=494;t["apple"]=790});t["Times-Roman"]=getLookupTableFactory(function(t){t["space"]=250;t["exclam"]=333;t["quotedbl"]=408;t["numbersign"]=500;t["dollar"]=500;t["percent"]=833;t["ampersand"]=778;t["quoteright"]=333;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=500;t["plus"]=564;t["comma"]=250;t["hyphen"]=333;t["period"]=250;t["slash"]=278;t["zero"]=500;t["one"]=500;t["two"]=500;t["three"]=500;t["four"]=500;t["five"]=500;t["six"]=500;t["seven"]=500;t["eight"]=500;t["nine"]=500;t["colon"]=278;t["semicolon"]=278;t["less"]=564;t["equal"]=564;t["greater"]=564;t["question"]=444;t["at"]=921;t["A"]=722;t["B"]=667;t["C"]=667;t["D"]=722;t["E"]=611;t["F"]=556;t["G"]=722;t["H"]=722;t["I"]=333;t["J"]=389;t["K"]=722;t["L"]=611;t["M"]=889;t["N"]=722;t["O"]=722;t["P"]=556;t["Q"]=722;t["R"]=667;t["S"]=556;t["T"]=611;t["U"]=722;t["V"]=722;t["W"]=944;t["X"]=722;t["Y"]=722;t["Z"]=611;t["bracketleft"]=333;t["backslash"]=278;t["bracketright"]=333;t["asciicircum"]=469;t["underscore"]=500;t["quoteleft"]=333;t["a"]=444;t["b"]=500;t["c"]=444;t["d"]=500;t["e"]=444;t["f"]=333;t["g"]=500;t["h"]=500;t["i"]=278;t["j"]=278;t["k"]=500;t["l"]=278;t["m"]=778;t["n"]=500;t["o"]=500;t["p"]=500;t["q"]=500;t["r"]=333;t["s"]=389;t["t"]=278;t["u"]=500;t["v"]=500;t["w"]=722;t["x"]=500;t["y"]=500;t["z"]=444;t["braceleft"]=480;t["bar"]=200;t["braceright"]=480;t["asciitilde"]=541;t["exclamdown"]=333;t["cent"]=500;t["sterling"]=500;t["fraction"]=167;t["yen"]=500;t["florin"]=500;t["section"]=500;t["currency"]=500;t["quotesingle"]=180;t["quotedblleft"]=444;t["guillemotleft"]=500;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=556;t["fl"]=556;t["endash"]=500;t["dagger"]=500;t["daggerdbl"]=500;t["periodcentered"]=250;t["paragraph"]=453;t["bullet"]=350;t["quotesinglbase"]=333;t["quotedblbase"]=444;t["quotedblright"]=444;t["guillemotright"]=500;t["ellipsis"]=1e3;t["perthousand"]=1e3;t["questiondown"]=444;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=1e3;t["AE"]=889;t["ordfeminine"]=276;t["Lslash"]=611;t["Oslash"]=722;t["OE"]=889;t["ordmasculine"]=310;t["ae"]=667;t["dotlessi"]=278;t["lslash"]=278;t["oslash"]=500;t["oe"]=722;t["germandbls"]=500;t["Idieresis"]=333;t["eacute"]=444;t["abreve"]=444;t["uhungarumlaut"]=500;t["ecaron"]=444;t["Ydieresis"]=722;t["divide"]=564;t["Yacute"]=722;t["Acircumflex"]=722;t["aacute"]=444;t["Ucircumflex"]=722;t["yacute"]=500;t["scommaaccent"]=389;t["ecircumflex"]=444;t["Uring"]=722;t["Udieresis"]=722;t["aogonek"]=444;t["Uacute"]=722;t["uogonek"]=500;t["Edieresis"]=611;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=760;t["Emacron"]=611;t["ccaron"]=444;t["aring"]=444;t["Ncommaaccent"]=722;t["lacute"]=278;t["agrave"]=444;t["Tcommaaccent"]=611;t["Cacute"]=667;t["atilde"]=444;t["Edotaccent"]=611;t["scaron"]=389;t["scedilla"]=389;t["iacute"]=278;t["lozenge"]=471;t["Rcaron"]=667;t["Gcommaaccent"]=722;t["ucircumflex"]=500;t["acircumflex"]=444;t["Amacron"]=722;t["rcaron"]=333;t["ccedilla"]=444;t["Zdotaccent"]=611;t["Thorn"]=556;t["Omacron"]=722;t["Racute"]=667;t["Sacute"]=556;t["dcaron"]=588;t["Umacron"]=722;t["uring"]=500;t["threesuperior"]=300;t["Ograve"]=722;t["Agrave"]=722;t["Abreve"]=722;t["multiply"]=564;t["uacute"]=500;t["Tcaron"]=611;t["partialdiff"]=476;t["ydieresis"]=500;t["Nacute"]=722;t["icircumflex"]=278;t["Ecircumflex"]=611;t["adieresis"]=444;t["edieresis"]=444;t["cacute"]=444;t["nacute"]=500;t["umacron"]=500;t["Ncaron"]=722;t["Iacute"]=333;t["plusminus"]=564;t["brokenbar"]=200;t["registered"]=760;t["Gbreve"]=722;t["Idotaccent"]=333;t["summation"]=600;t["Egrave"]=611;t["racute"]=333;t["omacron"]=500;t["Zacute"]=611;t["Zcaron"]=611;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=667;t["lcommaaccent"]=278;t["tcaron"]=326;t["eogonek"]=444;t["Uogonek"]=722;t["Aacute"]=722;t["Adieresis"]=722;t["egrave"]=444;t["zacute"]=444;t["iogonek"]=278;t["Oacute"]=722;t["oacute"]=500;t["amacron"]=444;t["sacute"]=389;t["idieresis"]=278;t["Ocircumflex"]=722;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=500;t["twosuperior"]=300;t["Odieresis"]=722;t["mu"]=500;t["igrave"]=278;t["ohungarumlaut"]=500;t["Eogonek"]=611;t["dcroat"]=500;t["threequarters"]=750;t["Scedilla"]=556;t["lcaron"]=344;t["Kcommaaccent"]=722;t["Lacute"]=611;t["trademark"]=980;t["edotaccent"]=444;t["Igrave"]=333;t["Imacron"]=333;t["Lcaron"]=611;t["onehalf"]=750;t["lessequal"]=549;t["ocircumflex"]=500;t["ntilde"]=500;t["Uhungarumlaut"]=722;t["Eacute"]=611;t["emacron"]=444;t["gbreve"]=500;t["onequarter"]=750;t["Scaron"]=556;t["Scommaaccent"]=556;t["Ohungarumlaut"]=722;t["degree"]=400;t["ograve"]=500;t["Ccaron"]=667;t["ugrave"]=500;t["radical"]=453;t["Dcaron"]=722;t["rcommaaccent"]=333;t["Ntilde"]=722;t["otilde"]=500;t["Rcommaaccent"]=667;t["Lcommaaccent"]=611;t["Atilde"]=722;t["Aogonek"]=722;t["Aring"]=722;t["Otilde"]=722;t["zdotaccent"]=444;t["Ecaron"]=611;t["Iogonek"]=333;t["kcommaaccent"]=500;t["minus"]=564;t["Icircumflex"]=333;t["ncaron"]=500;t["tcommaaccent"]=278;t["logicalnot"]=564;t["odieresis"]=500;t["udieresis"]=500;t["notequal"]=549;t["gcommaaccent"]=500;t["eth"]=500;t["zcaron"]=444;t["ncommaaccent"]=500;t["onesuperior"]=300;t["imacron"]=278;t["Euro"]=500});t["Times-Bold"]=getLookupTableFactory(function(t){t["space"]=250;t["exclam"]=333;t["quotedbl"]=555;t["numbersign"]=500;t["dollar"]=500;t["percent"]=1e3;t["ampersand"]=833;t["quoteright"]=333;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=500;t["plus"]=570;t["comma"]=250;t["hyphen"]=333;t["period"]=250;t["slash"]=278;t["zero"]=500;t["one"]=500;t["two"]=500;t["three"]=500;t["four"]=500;t["five"]=500;t["six"]=500;t["seven"]=500;t["eight"]=500;t["nine"]=500;t["colon"]=333;t["semicolon"]=333;t["less"]=570;t["equal"]=570;t["greater"]=570;t["question"]=500;t["at"]=930;t["A"]=722;t["B"]=667;t["C"]=722;t["D"]=722;t["E"]=667;t["F"]=611;t["G"]=778;t["H"]=778;t["I"]=389;t["J"]=500;t["K"]=778;t["L"]=667;t["M"]=944;t["N"]=722;t["O"]=778;t["P"]=611;t["Q"]=778;t["R"]=722;t["S"]=556;t["T"]=667;t["U"]=722;t["V"]=722;t["W"]=1e3;t["X"]=722;t["Y"]=722;t["Z"]=667;t["bracketleft"]=333;t["backslash"]=278;t["bracketright"]=333;t["asciicircum"]=581;t["underscore"]=500;t["quoteleft"]=333;t["a"]=500;t["b"]=556;t["c"]=444;t["d"]=556;t["e"]=444;t["f"]=333;t["g"]=500;t["h"]=556;t["i"]=278;t["j"]=333;t["k"]=556;t["l"]=278;t["m"]=833;t["n"]=556;t["o"]=500;t["p"]=556;t["q"]=556;t["r"]=444;t["s"]=389;t["t"]=333;t["u"]=556;t["v"]=500;t["w"]=722;t["x"]=500;t["y"]=500;t["z"]=444;t["braceleft"]=394;t["bar"]=220;t["braceright"]=394;t["asciitilde"]=520;t["exclamdown"]=333;t["cent"]=500;t["sterling"]=500;t["fraction"]=167;t["yen"]=500;t["florin"]=500;t["section"]=500;t["currency"]=500;t["quotesingle"]=278;t["quotedblleft"]=500;t["guillemotleft"]=500;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=556;t["fl"]=556;t["endash"]=500;t["dagger"]=500;t["daggerdbl"]=500;t["periodcentered"]=250;t["paragraph"]=540;t["bullet"]=350;t["quotesinglbase"]=333;t["quotedblbase"]=500;t["quotedblright"]=500;t["guillemotright"]=500;t["ellipsis"]=1e3;t["perthousand"]=1e3;t["questiondown"]=500;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=1e3;t["AE"]=1e3;t["ordfeminine"]=300;t["Lslash"]=667;t["Oslash"]=778;t["OE"]=1e3;t["ordmasculine"]=330;t["ae"]=722;t["dotlessi"]=278;t["lslash"]=278;t["oslash"]=500;t["oe"]=722;t["germandbls"]=556;t["Idieresis"]=389;t["eacute"]=444;t["abreve"]=500;t["uhungarumlaut"]=556;t["ecaron"]=444;t["Ydieresis"]=722;t["divide"]=570;t["Yacute"]=722;t["Acircumflex"]=722;t["aacute"]=500;t["Ucircumflex"]=722;t["yacute"]=500;t["scommaaccent"]=389;t["ecircumflex"]=444;t["Uring"]=722;t["Udieresis"]=722;t["aogonek"]=500;t["Uacute"]=722;t["uogonek"]=556;t["Edieresis"]=667;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=747;t["Emacron"]=667;t["ccaron"]=444;t["aring"]=500;t["Ncommaaccent"]=722;t["lacute"]=278;t["agrave"]=500;t["Tcommaaccent"]=667;t["Cacute"]=722;t["atilde"]=500;t["Edotaccent"]=667;t["scaron"]=389;t["scedilla"]=389;t["iacute"]=278;t["lozenge"]=494;t["Rcaron"]=722;t["Gcommaaccent"]=778;t["ucircumflex"]=556;t["acircumflex"]=500;t["Amacron"]=722;t["rcaron"]=444;t["ccedilla"]=444;t["Zdotaccent"]=667;t["Thorn"]=611;t["Omacron"]=778;t["Racute"]=722;t["Sacute"]=556;t["dcaron"]=672;t["Umacron"]=722;t["uring"]=556;t["threesuperior"]=300;t["Ograve"]=778;t["Agrave"]=722;t["Abreve"]=722;t["multiply"]=570;t["uacute"]=556;t["Tcaron"]=667;t["partialdiff"]=494;t["ydieresis"]=500;t["Nacute"]=722;t["icircumflex"]=278;t["Ecircumflex"]=667;t["adieresis"]=500;t["edieresis"]=444;t["cacute"]=444;t["nacute"]=556;t["umacron"]=556;t["Ncaron"]=722;t["Iacute"]=389;t["plusminus"]=570;t["brokenbar"]=220;t["registered"]=747;t["Gbreve"]=778;t["Idotaccent"]=389;t["summation"]=600;t["Egrave"]=667;t["racute"]=444;t["omacron"]=500;t["Zacute"]=667;t["Zcaron"]=667;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=722;t["lcommaaccent"]=278;t["tcaron"]=416;t["eogonek"]=444;t["Uogonek"]=722;t["Aacute"]=722;t["Adieresis"]=722;t["egrave"]=444;t["zacute"]=444;t["iogonek"]=278;t["Oacute"]=778;t["oacute"]=500;t["amacron"]=500;t["sacute"]=389;t["idieresis"]=278;t["Ocircumflex"]=778;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=556;t["twosuperior"]=300;t["Odieresis"]=778;t["mu"]=556;t["igrave"]=278;t["ohungarumlaut"]=500;t["Eogonek"]=667;t["dcroat"]=556;t["threequarters"]=750;t["Scedilla"]=556;t["lcaron"]=394;t["Kcommaaccent"]=778;t["Lacute"]=667;t["trademark"]=1e3;t["edotaccent"]=444;t["Igrave"]=389;t["Imacron"]=389;t["Lcaron"]=667;t["onehalf"]=750;t["lessequal"]=549;t["ocircumflex"]=500;t["ntilde"]=556;t["Uhungarumlaut"]=722;t["Eacute"]=667;t["emacron"]=444;t["gbreve"]=500;t["onequarter"]=750;t["Scaron"]=556;t["Scommaaccent"]=556;t["Ohungarumlaut"]=778;t["degree"]=400;t["ograve"]=500;t["Ccaron"]=722;t["ugrave"]=556;t["radical"]=549;t["Dcaron"]=722;t["rcommaaccent"]=444;t["Ntilde"]=722;t["otilde"]=500;t["Rcommaaccent"]=722;t["Lcommaaccent"]=667;t["Atilde"]=722;t["Aogonek"]=722;t["Aring"]=722;t["Otilde"]=778;t["zdotaccent"]=444;t["Ecaron"]=667;t["Iogonek"]=389;t["kcommaaccent"]=556;t["minus"]=570;t["Icircumflex"]=389;t["ncaron"]=556;t["tcommaaccent"]=333;t["logicalnot"]=570;t["odieresis"]=500;t["udieresis"]=556;t["notequal"]=549;t["gcommaaccent"]=500;t["eth"]=500;t["zcaron"]=444;t["ncommaaccent"]=556;t["onesuperior"]=300;t["imacron"]=278;t["Euro"]=500});t["Times-BoldItalic"]=getLookupTableFactory(function(t){t["space"]=250;t["exclam"]=389;t["quotedbl"]=555;t["numbersign"]=500;t["dollar"]=500;t["percent"]=833;t["ampersand"]=778;t["quoteright"]=333;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=500;t["plus"]=570;t["comma"]=250;t["hyphen"]=333;t["period"]=250;t["slash"]=278;t["zero"]=500;t["one"]=500;t["two"]=500;t["three"]=500;t["four"]=500;t["five"]=500;t["six"]=500;t["seven"]=500;t["eight"]=500;t["nine"]=500;t["colon"]=333;t["semicolon"]=333;t["less"]=570;t["equal"]=570;t["greater"]=570;t["question"]=500;t["at"]=832;t["A"]=667;t["B"]=667;t["C"]=667;t["D"]=722;t["E"]=667;t["F"]=667;t["G"]=722;t["H"]=778;t["I"]=389;t["J"]=500;t["K"]=667;t["L"]=611;t["M"]=889;t["N"]=722;t["O"]=722;t["P"]=611;t["Q"]=722;t["R"]=667;t["S"]=556;t["T"]=611;t["U"]=722;t["V"]=667;t["W"]=889;t["X"]=667;t["Y"]=611;t["Z"]=611;t["bracketleft"]=333;t["backslash"]=278;t["bracketright"]=333;t["asciicircum"]=570;t["underscore"]=500;t["quoteleft"]=333;t["a"]=500;t["b"]=500;t["c"]=444;t["d"]=500;t["e"]=444;t["f"]=333;t["g"]=500;t["h"]=556;t["i"]=278;t["j"]=278;t["k"]=500;t["l"]=278;t["m"]=778;t["n"]=556;t["o"]=500;t["p"]=500;t["q"]=500;t["r"]=389;t["s"]=389;t["t"]=278;t["u"]=556;t["v"]=444;t["w"]=667;t["x"]=500;t["y"]=444;t["z"]=389;t["braceleft"]=348;t["bar"]=220;t["braceright"]=348;t["asciitilde"]=570;t["exclamdown"]=389;t["cent"]=500;t["sterling"]=500;t["fraction"]=167;t["yen"]=500;t["florin"]=500;t["section"]=500;t["currency"]=500;t["quotesingle"]=278;t["quotedblleft"]=500;t["guillemotleft"]=500;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=556;t["fl"]=556;t["endash"]=500;t["dagger"]=500;t["daggerdbl"]=500;t["periodcentered"]=250;t["paragraph"]=500;t["bullet"]=350;t["quotesinglbase"]=333;t["quotedblbase"]=500;t["quotedblright"]=500;t["guillemotright"]=500;t["ellipsis"]=1e3;t["perthousand"]=1e3;t["questiondown"]=500;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=1e3;t["AE"]=944;t["ordfeminine"]=266;t["Lslash"]=611;t["Oslash"]=722;t["OE"]=944;t["ordmasculine"]=300;t["ae"]=722;t["dotlessi"]=278;t["lslash"]=278;t["oslash"]=500;t["oe"]=722;t["germandbls"]=500;t["Idieresis"]=389;t["eacute"]=444;t["abreve"]=500;t["uhungarumlaut"]=556;t["ecaron"]=444;t["Ydieresis"]=611;t["divide"]=570;t["Yacute"]=611;t["Acircumflex"]=667;t["aacute"]=500;t["Ucircumflex"]=722;t["yacute"]=444;t["scommaaccent"]=389;t["ecircumflex"]=444;t["Uring"]=722;
12t["Udieresis"]=722;t["aogonek"]=500;t["Uacute"]=722;t["uogonek"]=556;t["Edieresis"]=667;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=747;t["Emacron"]=667;t["ccaron"]=444;t["aring"]=500;t["Ncommaaccent"]=722;t["lacute"]=278;t["agrave"]=500;t["Tcommaaccent"]=611;t["Cacute"]=667;t["atilde"]=500;t["Edotaccent"]=667;t["scaron"]=389;t["scedilla"]=389;t["iacute"]=278;t["lozenge"]=494;t["Rcaron"]=667;t["Gcommaaccent"]=722;t["ucircumflex"]=556;t["acircumflex"]=500;t["Amacron"]=667;t["rcaron"]=389;t["ccedilla"]=444;t["Zdotaccent"]=611;t["Thorn"]=611;t["Omacron"]=722;t["Racute"]=667;t["Sacute"]=556;t["dcaron"]=608;t["Umacron"]=722;t["uring"]=556;t["threesuperior"]=300;t["Ograve"]=722;t["Agrave"]=667;t["Abreve"]=667;t["multiply"]=570;t["uacute"]=556;t["Tcaron"]=611;t["partialdiff"]=494;t["ydieresis"]=444;t["Nacute"]=722;t["icircumflex"]=278;t["Ecircumflex"]=667;t["adieresis"]=500;t["edieresis"]=444;t["cacute"]=444;t["nacute"]=556;t["umacron"]=556;t["Ncaron"]=722;t["Iacute"]=389;t["plusminus"]=570;t["brokenbar"]=220;t["registered"]=747;t["Gbreve"]=722;t["Idotaccent"]=389;t["summation"]=600;t["Egrave"]=667;t["racute"]=389;t["omacron"]=500;t["Zacute"]=611;t["Zcaron"]=611;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=667;t["lcommaaccent"]=278;t["tcaron"]=366;t["eogonek"]=444;t["Uogonek"]=722;t["Aacute"]=667;t["Adieresis"]=667;t["egrave"]=444;t["zacute"]=389;t["iogonek"]=278;t["Oacute"]=722;t["oacute"]=500;t["amacron"]=500;t["sacute"]=389;t["idieresis"]=278;t["Ocircumflex"]=722;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=500;t["twosuperior"]=300;t["Odieresis"]=722;t["mu"]=576;t["igrave"]=278;t["ohungarumlaut"]=500;t["Eogonek"]=667;t["dcroat"]=500;t["threequarters"]=750;t["Scedilla"]=556;t["lcaron"]=382;t["Kcommaaccent"]=667;t["Lacute"]=611;t["trademark"]=1e3;t["edotaccent"]=444;t["Igrave"]=389;t["Imacron"]=389;t["Lcaron"]=611;t["onehalf"]=750;t["lessequal"]=549;t["ocircumflex"]=500;t["ntilde"]=556;t["Uhungarumlaut"]=722;t["Eacute"]=667;t["emacron"]=444;t["gbreve"]=500;t["onequarter"]=750;t["Scaron"]=556;t["Scommaaccent"]=556;t["Ohungarumlaut"]=722;t["degree"]=400;t["ograve"]=500;t["Ccaron"]=667;t["ugrave"]=556;t["radical"]=549;t["Dcaron"]=722;t["rcommaaccent"]=389;t["Ntilde"]=722;t["otilde"]=500;t["Rcommaaccent"]=667;t["Lcommaaccent"]=611;t["Atilde"]=667;t["Aogonek"]=667;t["Aring"]=667;t["Otilde"]=722;t["zdotaccent"]=389;t["Ecaron"]=667;t["Iogonek"]=389;t["kcommaaccent"]=500;t["minus"]=606;t["Icircumflex"]=389;t["ncaron"]=556;t["tcommaaccent"]=278;t["logicalnot"]=606;t["odieresis"]=500;t["udieresis"]=556;t["notequal"]=549;t["gcommaaccent"]=500;t["eth"]=500;t["zcaron"]=389;t["ncommaaccent"]=556;t["onesuperior"]=300;t["imacron"]=278;t["Euro"]=500});t["Times-Italic"]=getLookupTableFactory(function(t){t["space"]=250;t["exclam"]=333;t["quotedbl"]=420;t["numbersign"]=500;t["dollar"]=500;t["percent"]=833;t["ampersand"]=778;t["quoteright"]=333;t["parenleft"]=333;t["parenright"]=333;t["asterisk"]=500;t["plus"]=675;t["comma"]=250;t["hyphen"]=333;t["period"]=250;t["slash"]=278;t["zero"]=500;t["one"]=500;t["two"]=500;t["three"]=500;t["four"]=500;t["five"]=500;t["six"]=500;t["seven"]=500;t["eight"]=500;t["nine"]=500;t["colon"]=333;t["semicolon"]=333;t["less"]=675;t["equal"]=675;t["greater"]=675;t["question"]=500;t["at"]=920;t["A"]=611;t["B"]=611;t["C"]=667;t["D"]=722;t["E"]=611;t["F"]=611;t["G"]=722;t["H"]=722;t["I"]=333;t["J"]=444;t["K"]=667;t["L"]=556;t["M"]=833;t["N"]=667;t["O"]=722;t["P"]=611;t["Q"]=722;t["R"]=611;t["S"]=500;t["T"]=556;t["U"]=722;t["V"]=611;t["W"]=833;t["X"]=611;t["Y"]=556;t["Z"]=556;t["bracketleft"]=389;t["backslash"]=278;t["bracketright"]=389;t["asciicircum"]=422;t["underscore"]=500;t["quoteleft"]=333;t["a"]=500;t["b"]=500;t["c"]=444;t["d"]=500;t["e"]=444;t["f"]=278;t["g"]=500;t["h"]=500;t["i"]=278;t["j"]=278;t["k"]=444;t["l"]=278;t["m"]=722;t["n"]=500;t["o"]=500;t["p"]=500;t["q"]=500;t["r"]=389;t["s"]=389;t["t"]=278;t["u"]=500;t["v"]=444;t["w"]=667;t["x"]=444;t["y"]=444;t["z"]=389;t["braceleft"]=400;t["bar"]=275;t["braceright"]=400;t["asciitilde"]=541;t["exclamdown"]=389;t["cent"]=500;t["sterling"]=500;t["fraction"]=167;t["yen"]=500;t["florin"]=500;t["section"]=500;t["currency"]=500;t["quotesingle"]=214;t["quotedblleft"]=556;t["guillemotleft"]=500;t["guilsinglleft"]=333;t["guilsinglright"]=333;t["fi"]=500;t["fl"]=500;t["endash"]=500;t["dagger"]=500;t["daggerdbl"]=500;t["periodcentered"]=250;t["paragraph"]=523;t["bullet"]=350;t["quotesinglbase"]=333;t["quotedblbase"]=556;t["quotedblright"]=556;t["guillemotright"]=500;t["ellipsis"]=889;t["perthousand"]=1e3;t["questiondown"]=500;t["grave"]=333;t["acute"]=333;t["circumflex"]=333;t["tilde"]=333;t["macron"]=333;t["breve"]=333;t["dotaccent"]=333;t["dieresis"]=333;t["ring"]=333;t["cedilla"]=333;t["hungarumlaut"]=333;t["ogonek"]=333;t["caron"]=333;t["emdash"]=889;t["AE"]=889;t["ordfeminine"]=276;t["Lslash"]=556;t["Oslash"]=722;t["OE"]=944;t["ordmasculine"]=310;t["ae"]=667;t["dotlessi"]=278;t["lslash"]=278;t["oslash"]=500;t["oe"]=667;t["germandbls"]=500;t["Idieresis"]=333;t["eacute"]=444;t["abreve"]=500;t["uhungarumlaut"]=500;t["ecaron"]=444;t["Ydieresis"]=556;t["divide"]=675;t["Yacute"]=556;t["Acircumflex"]=611;t["aacute"]=500;t["Ucircumflex"]=722;t["yacute"]=444;t["scommaaccent"]=389;t["ecircumflex"]=444;t["Uring"]=722;t["Udieresis"]=722;t["aogonek"]=500;t["Uacute"]=722;t["uogonek"]=500;t["Edieresis"]=611;t["Dcroat"]=722;t["commaaccent"]=250;t["copyright"]=760;t["Emacron"]=611;t["ccaron"]=444;t["aring"]=500;t["Ncommaaccent"]=667;t["lacute"]=278;t["agrave"]=500;t["Tcommaaccent"]=556;t["Cacute"]=667;t["atilde"]=500;t["Edotaccent"]=611;t["scaron"]=389;t["scedilla"]=389;t["iacute"]=278;t["lozenge"]=471;t["Rcaron"]=611;t["Gcommaaccent"]=722;t["ucircumflex"]=500;t["acircumflex"]=500;t["Amacron"]=611;t["rcaron"]=389;t["ccedilla"]=444;t["Zdotaccent"]=556;t["Thorn"]=611;t["Omacron"]=722;t["Racute"]=611;t["Sacute"]=500;t["dcaron"]=544;t["Umacron"]=722;t["uring"]=500;t["threesuperior"]=300;t["Ograve"]=722;t["Agrave"]=611;t["Abreve"]=611;t["multiply"]=675;t["uacute"]=500;t["Tcaron"]=556;t["partialdiff"]=476;t["ydieresis"]=444;t["Nacute"]=667;t["icircumflex"]=278;t["Ecircumflex"]=611;t["adieresis"]=500;t["edieresis"]=444;t["cacute"]=444;t["nacute"]=500;t["umacron"]=500;t["Ncaron"]=667;t["Iacute"]=333;t["plusminus"]=675;t["brokenbar"]=275;t["registered"]=760;t["Gbreve"]=722;t["Idotaccent"]=333;t["summation"]=600;t["Egrave"]=611;t["racute"]=389;t["omacron"]=500;t["Zacute"]=556;t["Zcaron"]=556;t["greaterequal"]=549;t["Eth"]=722;t["Ccedilla"]=667;t["lcommaaccent"]=278;t["tcaron"]=300;t["eogonek"]=444;t["Uogonek"]=722;t["Aacute"]=611;t["Adieresis"]=611;t["egrave"]=444;t["zacute"]=389;t["iogonek"]=278;t["Oacute"]=722;t["oacute"]=500;t["amacron"]=500;t["sacute"]=389;t["idieresis"]=278;t["Ocircumflex"]=722;t["Ugrave"]=722;t["Delta"]=612;t["thorn"]=500;t["twosuperior"]=300;t["Odieresis"]=722;t["mu"]=500;t["igrave"]=278;t["ohungarumlaut"]=500;t["Eogonek"]=611;t["dcroat"]=500;t["threequarters"]=750;t["Scedilla"]=500;t["lcaron"]=300;t["Kcommaaccent"]=667;t["Lacute"]=556;t["trademark"]=980;t["edotaccent"]=444;t["Igrave"]=333;t["Imacron"]=333;t["Lcaron"]=611;t["onehalf"]=750;t["lessequal"]=549;t["ocircumflex"]=500;t["ntilde"]=500;t["Uhungarumlaut"]=722;t["Eacute"]=611;t["emacron"]=444;t["gbreve"]=500;t["onequarter"]=750;t["Scaron"]=500;t["Scommaaccent"]=500;t["Ohungarumlaut"]=722;t["degree"]=400;t["ograve"]=500;t["Ccaron"]=667;t["ugrave"]=500;t["radical"]=453;t["Dcaron"]=722;t["rcommaaccent"]=389;t["Ntilde"]=667;t["otilde"]=500;t["Rcommaaccent"]=611;t["Lcommaaccent"]=556;t["Atilde"]=611;t["Aogonek"]=611;t["Aring"]=611;t["Otilde"]=722;t["zdotaccent"]=389;t["Ecaron"]=611;t["Iogonek"]=333;t["kcommaaccent"]=444;t["minus"]=675;t["Icircumflex"]=333;t["ncaron"]=500;t["tcommaaccent"]=278;t["logicalnot"]=675;t["odieresis"]=500;t["udieresis"]=500;t["notequal"]=549;t["gcommaaccent"]=500;t["eth"]=500;t["zcaron"]=389;t["ncommaaccent"]=500;t["onesuperior"]=300;t["imacron"]=278;t["Euro"]=500});t["ZapfDingbats"]=getLookupTableFactory(function(t){t["space"]=278;t["a1"]=974;t["a2"]=961;t["a202"]=974;t["a3"]=980;t["a4"]=719;t["a5"]=789;t["a119"]=790;t["a118"]=791;t["a117"]=690;t["a11"]=960;t["a12"]=939;t["a13"]=549;t["a14"]=855;t["a15"]=911;t["a16"]=933;t["a105"]=911;t["a17"]=945;t["a18"]=974;t["a19"]=755;t["a20"]=846;t["a21"]=762;t["a22"]=761;t["a23"]=571;t["a24"]=677;t["a25"]=763;t["a26"]=760;t["a27"]=759;t["a28"]=754;t["a6"]=494;t["a7"]=552;t["a8"]=537;t["a9"]=577;t["a10"]=692;t["a29"]=786;t["a30"]=788;t["a31"]=788;t["a32"]=790;t["a33"]=793;t["a34"]=794;t["a35"]=816;t["a36"]=823;t["a37"]=789;t["a38"]=841;t["a39"]=823;t["a40"]=833;t["a41"]=816;t["a42"]=831;t["a43"]=923;t["a44"]=744;t["a45"]=723;t["a46"]=749;t["a47"]=790;t["a48"]=792;t["a49"]=695;t["a50"]=776;t["a51"]=768;t["a52"]=792;t["a53"]=759;t["a54"]=707;t["a55"]=708;t["a56"]=682;t["a57"]=701;t["a58"]=826;t["a59"]=815;t["a60"]=789;t["a61"]=789;t["a62"]=707;t["a63"]=687;t["a64"]=696;t["a65"]=689;t["a66"]=786;t["a67"]=787;t["a68"]=713;t["a69"]=791;t["a70"]=785;t["a71"]=791;t["a72"]=873;t["a73"]=761;t["a74"]=762;t["a203"]=762;t["a75"]=759;t["a204"]=759;t["a76"]=892;t["a77"]=892;t["a78"]=788;t["a79"]=784;t["a81"]=438;t["a82"]=138;t["a83"]=277;t["a84"]=415;t["a97"]=392;t["a98"]=392;t["a99"]=668;t["a100"]=668;t["a89"]=390;t["a90"]=390;t["a93"]=317;t["a94"]=317;t["a91"]=276;t["a92"]=276;t["a205"]=509;t["a85"]=509;t["a206"]=410;t["a86"]=410;t["a87"]=234;t["a88"]=234;t["a95"]=334;t["a96"]=334;t["a101"]=732;t["a102"]=544;t["a103"]=544;t["a104"]=910;t["a106"]=667;t["a107"]=760;t["a108"]=760;t["a112"]=776;t["a111"]=595;t["a110"]=694;t["a109"]=626;t["a120"]=788;t["a121"]=788;t["a122"]=788;t["a123"]=788;t["a124"]=788;t["a125"]=788;t["a126"]=788;t["a127"]=788;t["a128"]=788;t["a129"]=788;t["a130"]=788;t["a131"]=788;t["a132"]=788;t["a133"]=788;t["a134"]=788;t["a135"]=788;t["a136"]=788;t["a137"]=788;t["a138"]=788;t["a139"]=788;t["a140"]=788;t["a141"]=788;t["a142"]=788;t["a143"]=788;t["a144"]=788;t["a145"]=788;t["a146"]=788;t["a147"]=788;t["a148"]=788;t["a149"]=788;t["a150"]=788;t["a151"]=788;t["a152"]=788;t["a153"]=788;t["a154"]=788;t["a155"]=788;t["a156"]=788;t["a157"]=788;t["a158"]=788;t["a159"]=788;t["a160"]=894;t["a161"]=838;t["a163"]=1016;t["a164"]=458;t["a196"]=748;t["a165"]=924;t["a192"]=748;t["a166"]=918;t["a167"]=927;t["a168"]=928;t["a169"]=928;t["a170"]=834;t["a171"]=873;t["a172"]=828;t["a173"]=924;t["a162"]=924;t["a174"]=917;t["a175"]=930;t["a176"]=931;t["a177"]=463;t["a178"]=883;t["a179"]=836;t["a193"]=836;t["a180"]=867;t["a199"]=867;t["a181"]=696;t["a200"]=696;t["a182"]=874;t["a201"]=874;t["a183"]=760;t["a184"]=946;t["a197"]=771;t["a185"]=865;t["a194"]=771;t["a198"]=888;t["a186"]=967;t["a195"]=888;t["a187"]=831;t["a188"]=873;t["a189"]=927;t["a190"]=970;t["a191"]=918})});exports.getMetrics=getMetrics});(function(root,factory){{factory(root.pdfjsCoreMurmurHash3={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var Uint32ArrayView=sharedUtil.Uint32ArrayView;var MurmurHash3_64=function MurmurHash3_64Closure(seed){var MASK_HIGH=4294901760;var MASK_LOW=65535;function MurmurHash3_64(seed){var SEED=3285377520;this.h1=seed?seed&4294967295:SEED;this.h2=seed?seed&4294967295:SEED}var alwaysUseUint32ArrayView=false;try{new Uint32Array(new Uint8Array(5).buffer,0,1)}catch(e){alwaysUseUint32ArrayView=true}MurmurHash3_64.prototype={update:function MurmurHash3_64_update(input){var useUint32ArrayView=alwaysUseUint32ArrayView;var i;if(typeof input==="string"){var data=new Uint8Array(input.length*2);var length=0;for(i=0;i<input.length;i++){var code=input.charCodeAt(i);if(code<=255){data[length++]=code}else{data[length++]=code>>>8;data[length++]=code&255}}}else if(input instanceof Uint8Array){data=input;length=data.length}else if(typeof input==="object"&&"length"in input){data=input;length=data.length;useUint32ArrayView=true}else{throw new Error("Wrong data format in MurmurHash3_64_update. "+"Input must be a string or array.")}var blockCounts=length>>2;var tailLength=length-blockCounts*4;var dataUint32=useUint32ArrayView?new Uint32ArrayView(data,blockCounts):new Uint32Array(data.buffer,0,blockCounts);var k1=0;var k2=0;var h1=this.h1;var h2=this.h2;var C1=3432918353;var C2=461845907;var C1_LOW=C1&MASK_LOW;var C2_LOW=C2&MASK_LOW;for(i=0;i<blockCounts;i++){if(i&1){k1=dataUint32[i];k1=k1*C1&MASK_HIGH|k1*C1_LOW&MASK_LOW;k1=k1<<15|k1>>>17;k1=k1*C2&MASK_HIGH|k1*C2_LOW&MASK_LOW;h1^=k1;h1=h1<<13|h1>>>19;h1=h1*5+3864292196}else{k2=dataUint32[i];k2=k2*C1&MASK_HIGH|k2*C1_LOW&MASK_LOW;k2=k2<<15|k2>>>17;k2=k2*C2&MASK_HIGH|k2*C2_LOW&MASK_LOW;h2^=k2;h2=h2<<13|h2>>>19;h2=h2*5+3864292196}}k1=0;switch(tailLength){case 3:k1^=data[blockCounts*4+2]<<16;case 2:k1^=data[blockCounts*4+1]<<8;case 1:k1^=data[blockCounts*4];k1=k1*C1&MASK_HIGH|k1*C1_LOW&MASK_LOW;k1=k1<<15|k1>>>17;k1=k1*C2&MASK_HIGH|k1*C2_LOW&MASK_LOW;if(blockCounts&1){h1^=k1}else{h2^=k1}}this.h1=h1;this.h2=h2;return this},hexdigest:function MurmurHash3_64_hexdigest(){var h1=this.h1;var h2=this.h2;h1^=h2>>>1;h1=h1*3981806797&MASK_HIGH|h1*36045&MASK_LOW;h2=h2*4283543511&MASK_HIGH|((h2<<16|h1>>>16)*2950163797&MASK_HIGH)>>>16;h1^=h2>>>1;h1=h1*444984403&MASK_HIGH|h1*60499&MASK_LOW;h2=h2*3301882366&MASK_HIGH|((h2<<16|h1>>>16)*3120437893&MASK_HIGH)>>>16;h1^=h2>>>1;for(var i=0,arr=[h1,h2],str="";i<arr.length;i++){var hex=(arr[i]>>>0).toString(16);while(hex.length<8){hex="0"+hex}str+=hex}return str}};return MurmurHash3_64}();exports.MurmurHash3_64=MurmurHash3_64});(function(root,factory){{factory(root.pdfjsCorePrimitives={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var isArray=sharedUtil.isArray;var Name=function NameClosure(){function Name(name){this.name=name}Name.prototype={};var nameCache=Object.create(null);Name.get=function Name_get(name){var nameValue=nameCache[name];return nameValue?nameValue:nameCache[name]=new Name(name)};return Name}();var Cmd=function CmdClosure(){function Cmd(cmd){this.cmd=cmd}Cmd.prototype={};var cmdCache=Object.create(null);Cmd.get=function Cmd_get(cmd){var cmdValue=cmdCache[cmd];return cmdValue?cmdValue:cmdCache[cmd]=new Cmd(cmd)};return Cmd}();var Dict=function DictClosure(){var nonSerializable=function nonSerializableClosure(){return nonSerializable};function Dict(xref){this.map=Object.create(null);this.xref=xref;this.objId=null;this.__nonSerializable__=nonSerializable}Dict.prototype={assignXref:function Dict_assignXref(newXref){this.xref=newXref},get:function Dict_get(key1,key2,key3){var value;var xref=this.xref;if(typeof(value=this.map[key1])!=="undefined"||key1 in this.map||typeof key2==="undefined"){return xref?xref.fetchIfRef(value):value}if(typeof(value=this.map[key2])!=="undefined"||key2 in this.map||typeof key3==="undefined"){return xref?xref.fetchIfRef(value):value}value=this.map[key3]||null;return xref?xref.fetchIfRef(value):value},getAsync:function Dict_getAsync(key1,key2,key3){var value;var xref=this.xref;if(typeof(value=this.map[key1])!=="undefined"||key1 in this.map||typeof key2==="undefined"){if(xref){return xref.fetchIfRefAsync(value)}return Promise.resolve(value)}if(typeof(value=this.map[key2])!=="undefined"||key2 in this.map||typeof key3==="undefined"){if(xref){return xref.fetchIfRefAsync(value)}return Promise.resolve(value)}value=this.map[key3]||null;if(xref){return xref.fetchIfRefAsync(value)}return Promise.resolve(value)},getArray:function Dict_getArray(key1,key2,key3){var value=this.get(key1,key2,key3);var xref=this.xref;if(!isArray(value)||!xref){return value}value=value.slice();for(var i=0,ii=value.length;i<ii;i++){if(!isRef(value[i])){continue}value[i]=xref.fetch(value[i])}return value},getRaw:function Dict_getRaw(key){return this.map[key]},getKeys:function Dict_getKeys(){return Object.keys(this.map)},set:function Dict_set(key,value){this.map[key]=value},has:function Dict_has(key){return key in this.map},forEach:function Dict_forEach(callback){for(var key in this.map){callback(key,this.get(key))}}};Dict.empty=new Dict(null);Dict.merge=function Dict_merge(xref,dictArray){var mergedDict=new Dict(xref);for(var i=0,ii=dictArray.length;i<ii;i++){var dict=dictArray[i];if(!isDict(dict)){continue}for(var keyName in dict.map){if(mergedDict.map[keyName]){continue}mergedDict.map[keyName]=dict.map[keyName]}}return mergedDict};return Dict}();var Ref=function RefClosure(){function Ref(num,gen){this.num=num;this.gen=gen}Ref.prototype={toString:function Ref_toString(){var str=this.num+"R";if(this.gen!==0){str+=this.gen}return str}};return Ref}();var RefSet=function RefSetClosure(){function RefSet(){this.dict=Object.create(null)}RefSet.prototype={has:function RefSet_has(ref){return ref.toString()in this.dict},put:function RefSet_put(ref){this.dict[ref.toString()]=true},remove:function RefSet_remove(ref){delete this.dict[ref.toString()]}};return RefSet}();var RefSetCache=function RefSetCacheClosure(){function RefSetCache(){this.dict=Object.create(null)}RefSetCache.prototype={get:function RefSetCache_get(ref){return this.dict[ref.toString()]},has:function RefSetCache_has(ref){return ref.toString()in this.dict},put:function RefSetCache_put(ref,obj){this.dict[ref.toString()]=obj},putAlias:function RefSetCache_putAlias(ref,aliasRef){this.dict[ref.toString()]=this.get(aliasRef)},forEach:function RefSetCache_forEach(fn,thisArg){for(var i in this.dict){fn.call(thisArg,this.dict[i])}},clear:function RefSetCache_clear(){this.dict=Object.create(null)}};return RefSetCache}();function isName(v,name){return v instanceof Name&&(name===undefined||v.name===name)}function isCmd(v,cmd){return v instanceof Cmd&&(cmd===undefined||v.cmd===cmd)}function isDict(v,type){return v instanceof Dict&&(type===undefined||isName(v.get("Type"),type))}function isRef(v){return v instanceof Ref}function isRefsEqual(v1,v2){return v1.num===v2.num&&v1.gen===v2.gen}function isStream(v){return typeof v==="object"&&v!==null&&v.getBytes!==undefined}exports.Cmd=Cmd;exports.Dict=Dict;exports.Name=Name;exports.Ref=Ref;exports.RefSet=RefSet;exports.RefSetCache=RefSetCache;exports.isCmd=isCmd;exports.isDict=isDict;exports.isName=isName;exports.isRef=isRef;exports.isRefsEqual=isRefsEqual;exports.isStream=isStream});(function(root,factory){{factory(root.pdfjsCoreStandardFonts={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var getLookupTableFactory=sharedUtil.getLookupTableFactory;var getStdFontMap=getLookupTableFactory(function(t){t["ArialNarrow"]="Helvetica";t["ArialNarrow-Bold"]="Helvetica-Bold";t["ArialNarrow-BoldItalic"]="Helvetica-BoldOblique";t["ArialNarrow-Italic"]="Helvetica-Oblique";t["ArialBlack"]="Helvetica";t["ArialBlack-Bold"]="Helvetica-Bold";t["ArialBlack-BoldItalic"]="Helvetica-BoldOblique";t["ArialBlack-Italic"]="Helvetica-Oblique";t["Arial"]="Helvetica";t["Arial-Bold"]="Helvetica-Bold";t["Arial-BoldItalic"]="Helvetica-BoldOblique";t["Arial-Italic"]="Helvetica-Oblique";t["Arial-BoldItalicMT"]="Helvetica-BoldOblique";t["Arial-BoldMT"]="Helvetica-Bold";t["Arial-ItalicMT"]="Helvetica-Oblique";t["ArialMT"]="Helvetica";t["Courier-Bold"]="Courier-Bold";t["Courier-BoldItalic"]="Courier-BoldOblique";t["Courier-Italic"]="Courier-Oblique";t["CourierNew"]="Courier";t["CourierNew-Bold"]="Courier-Bold";t["CourierNew-BoldItalic"]="Courier-BoldOblique";t["CourierNew-Italic"]="Courier-Oblique";t["CourierNewPS-BoldItalicMT"]="Courier-BoldOblique";t["CourierNewPS-BoldMT"]="Courier-Bold";t["CourierNewPS-ItalicMT"]="Courier-Oblique";t["CourierNewPSMT"]="Courier";t["Helvetica"]="Helvetica";t["Helvetica-Bold"]="Helvetica-Bold";t["Helvetica-BoldItalic"]="Helvetica-BoldOblique";t["Helvetica-BoldOblique"]="Helvetica-BoldOblique";t["Helvetica-Italic"]="Helvetica-Oblique";t["Helvetica-Oblique"]="Helvetica-Oblique";t["Symbol-Bold"]="Symbol";t["Symbol-BoldItalic"]="Symbol";t["Symbol-Italic"]="Symbol";t["TimesNewRoman"]="Times-Roman";t["TimesNewRoman-Bold"]="Times-Bold";t["TimesNewRoman-BoldItalic"]="Times-BoldItalic";t["TimesNewRoman-Italic"]="Times-Italic";t["TimesNewRomanPS"]="Times-Roman";t["TimesNewRomanPS-Bold"]="Times-Bold";t["TimesNewRomanPS-BoldItalic"]="Times-BoldItalic";t["TimesNewRomanPS-BoldItalicMT"]="Times-BoldItalic";t["TimesNewRomanPS-BoldMT"]="Times-Bold";t["TimesNewRomanPS-Italic"]="Times-Italic";t["TimesNewRomanPS-ItalicMT"]="Times-Italic";t["TimesNewRomanPSMT"]="Times-Roman";t["TimesNewRomanPSMT-Bold"]="Times-Bold";t["TimesNewRomanPSMT-BoldItalic"]="Times-BoldItalic";t["TimesNewRomanPSMT-Italic"]="Times-Italic"});var getNonStdFontMap=getLookupTableFactory(function(t){t["CenturyGothic"]="Helvetica";t["CenturyGothic-Bold"]="Helvetica-Bold";t["CenturyGothic-BoldItalic"]="Helvetica-BoldOblique";t["CenturyGothic-Italic"]="Helvetica-Oblique";t["ComicSansMS"]="Comic Sans MS";t["ComicSansMS-Bold"]="Comic Sans MS-Bold";t["ComicSansMS-BoldItalic"]="Comic Sans MS-BoldItalic";t["ComicSansMS-Italic"]="Comic Sans MS-Italic";t["LucidaConsole"]="Courier";t["LucidaConsole-Bold"]="Courier-Bold";t["LucidaConsole-BoldItalic"]="Courier-BoldOblique";t["LucidaConsole-Italic"]="Courier-Oblique";t["MS-Gothic"]="MS Gothic";t["MS-Gothic-Bold"]="MS Gothic-Bold";t["MS-Gothic-BoldItalic"]="MS Gothic-BoldItalic";t["MS-Gothic-Italic"]="MS Gothic-Italic";t["MS-Mincho"]="MS Mincho";t["MS-Mincho-Bold"]="MS Mincho-Bold";t["MS-Mincho-BoldItalic"]="MS Mincho-BoldItalic";t["MS-Mincho-Italic"]="MS Mincho-Italic";t["MS-PGothic"]="MS PGothic";t["MS-PGothic-Bold"]="MS PGothic-Bold";t["MS-PGothic-BoldItalic"]="MS PGothic-BoldItalic";t["MS-PGothic-Italic"]="MS PGothic-Italic";t["MS-PMincho"]="MS PMincho";t["MS-PMincho-Bold"]="MS PMincho-Bold";t["MS-PMincho-BoldItalic"]="MS PMincho-BoldItalic";t["MS-PMincho-Italic"]="MS PMincho-Italic";t["Wingdings"]="ZapfDingbats"});var getSerifFonts=getLookupTableFactory(function(t){t["Adobe Jenson"]=true;t["Adobe Text"]=true;t["Albertus"]=true;t["Aldus"]=true;t["Alexandria"]=true;t["Algerian"]=true;t["American Typewriter"]=true;t["Antiqua"]=true;t["Apex"]=true;t["Arno"]=true;t["Aster"]=true;t["Aurora"]=true;t["Baskerville"]=true;t["Bell"]=true;t["Bembo"]=true;t["Bembo Schoolbook"]=true;t["Benguiat"]=true;t["Berkeley Old Style"]=true;t["Bernhard Modern"]=true;t["Berthold City"]=true;t["Bodoni"]=true;t["Bauer Bodoni"]=true;t["Book Antiqua"]=true;t["Bookman"]=true;t["Bordeaux Roman"]=true;t["Californian FB"]=true;t["Calisto"]=true;t["Calvert"]=true;t["Capitals"]=true;t["Cambria"]=true;t["Cartier"]=true;t["Caslon"]=true;t["Catull"]=true;t["Centaur"]=true;t["Century Old Style"]=true;t["Century Schoolbook"]=true;t["Chaparral"]=true;t["Charis SIL"]=true;t["Cheltenham"]=true;t["Cholla Slab"]=true;t["Clarendon"]=true;t["Clearface"]=true;t["Cochin"]=true;t["Colonna"]=true;t["Computer Modern"]=true;t["Concrete Roman"]=true;t["Constantia"]=true;t["Cooper Black"]=true;t["Corona"]=true;t["Ecotype"]=true;t["Egyptienne"]=true;t["Elephant"]=true;t["Excelsior"]=true;t["Fairfield"]=true;t["FF Scala"]=true;t["Folkard"]=true;t["Footlight"]=true;t["FreeSerif"]=true;t["Friz Quadrata"]=true;t["Garamond"]=true;t["Gentium"]=true;t["Georgia"]=true;t["Gloucester"]=true;t["Goudy Old Style"]=true;t["Goudy Schoolbook"]=true;t["Goudy Pro Font"]=true;t["Granjon"]=true;t["Guardian Egyptian"]=true;t["Heather"]=true;t["Hercules"]=true;t["High Tower Text"]=true;t["Hiroshige"]=true;t["Hoefler Text"]=true;t["Humana Serif"]=true;t["Imprint"]=true;t["Ionic No. 5"]=true;t["Janson"]=true;t["Joanna"]=true;t["Korinna"]=true;t["Lexicon"]=true;t["Liberation Serif"]=true;t["Linux Libertine"]=true;t["Literaturnaya"]=true;t["Lucida"]=true;t["Lucida Bright"]=true;t["Melior"]=true;t["Memphis"]=true;t["Miller"]=true;t["Minion"]=true;t["Modern"]=true;t["Mona Lisa"]=true;t["Mrs Eaves"]=true;t["MS Serif"]=true;t["Museo Slab"]=true;t["New York"]=true;t["Nimbus Roman"]=true;t["NPS Rawlinson Roadway"]=true;t["Palatino"]=true;t["Perpetua"]=true;t["Plantin"]=true;t["Plantin Schoolbook"]=true;t["Playbill"]=true;t["Poor Richard"]=true;t["Rawlinson Roadway"]=true;t["Renault"]=true;t["Requiem"]=true;t["Rockwell"]=true;t["Roman"]=true;t["Rotis Serif"]=true;t["Sabon"]=true;t["Scala"]=true;t["Seagull"]=true;t["Sistina"]=true;t["Souvenir"]=true;t["STIX"]=true;t["Stone Informal"]=true;t["Stone Serif"]=true;t["Sylfaen"]=true;t["Times"]=true;t["Trajan"]=true;t["Trinité"]=true;t["Trump Mediaeval"]=true;t["Utopia"]=true;t["Vale Type"]=true;t["Bitstream Vera"]=true;t["Vera Serif"]=true;t["Versailles"]=true;t["Wanted"]=true;t["Weiss"]=true;t["Wide Latin"]=true;t["Windsor"]=true;t["XITS"]=true});var getSymbolsFonts=getLookupTableFactory(function(t){t["Dingbats"]=true;t["Symbol"]=true;t["ZapfDingbats"]=true});var getGlyphMapForStandardFonts=getLookupTableFactory(function(t){t[2]=10;t[3]=32;t[4]=33;t[5]=34;t[6]=35;t[7]=36;t[8]=37;t[9]=38;t[10]=39;t[11]=40;t[12]=41;t[13]=42;t[14]=43;t[15]=44;t[16]=45;t[17]=46;t[18]=47;t[19]=48;t[20]=49;t[21]=50;t[22]=51;t[23]=52;t[24]=53;t[25]=54;t[26]=55;t[27]=56;t[28]=57;t[29]=58;t[30]=894;t[31]=60;t[32]=61;t[33]=62;t[34]=63;t[35]=64;t[36]=65;t[37]=66;t[38]=67;t[39]=68;t[40]=69;t[41]=70;t[42]=71;t[43]=72;t[44]=73;t[45]=74;t[46]=75;t[47]=76;t[48]=77;t[49]=78;t[50]=79;t[51]=80;t[52]=81;t[53]=82;t[54]=83;t[55]=84;t[56]=85;t[57]=86;t[58]=87;t[59]=88;t[60]=89;t[61]=90;t[62]=91;t[63]=92;t[64]=93;t[65]=94;t[66]=95;t[67]=96;t[68]=97;t[69]=98;t[70]=99;t[71]=100;t[72]=101;t[73]=102;t[74]=103;t[75]=104;t[76]=105;t[77]=106;t[78]=107;t[79]=108;t[80]=109;t[81]=110;t[82]=111;t[83]=112;t[84]=113;t[85]=114;t[86]=115;t[87]=116;t[88]=117;t[89]=118;t[90]=119;t[91]=120;t[92]=121;t[93]=122;t[94]=123;t[95]=124;t[96]=125;t[97]=126;t[98]=196;t[99]=197;t[100]=199;t[101]=201;t[102]=209;t[103]=214;t[104]=220;t[105]=225;t[106]=224;t[107]=226;t[108]=228;t[109]=227;t[110]=229;t[111]=231;t[112]=233;t[113]=232;t[114]=234;t[115]=235;t[116]=237;t[117]=236;t[118]=238;t[119]=239;t[120]=241;t[121]=243;t[122]=242;t[123]=244;t[124]=246;t[125]=245;t[126]=250;t[127]=249;t[128]=251;t[129]=252;t[130]=8224;t[131]=176;t[132]=162;t[133]=163;t[134]=167;t[135]=8226;t[136]=182;t[137]=223;t[138]=174;t[139]=169;t[140]=8482;t[141]=180;t[142]=168;t[143]=8800;t[144]=198;t[145]=216;t[146]=8734;t[147]=177;t[148]=8804;t[149]=8805;t[150]=165;t[151]=181;t[152]=8706;t[153]=8721;t[154]=8719;t[156]=8747;t[157]=170;t[158]=186;t[159]=8486;t[160]=230;t[161]=248;t[162]=191;t[163]=161;t[164]=172;t[165]=8730;t[166]=402;t[167]=8776;t[168]=8710;t[169]=171;t[170]=187;t[171]=8230;t[210]=218;t[223]=711;t[224]=321;t[225]=322;t[227]=353;t[229]=382;t[234]=253;t[252]=263;t[253]=268;t[254]=269;t[258]=258;t[260]=260;t[261]=261;t[265]=280;t[266]=281;t[268]=283;t[269]=313;t[275]=323;t[276]=324;t[278]=328;t[284]=345;t[285]=346;t[286]=347;t[292]=367;t[295]=377;t[296]=378;t[298]=380;t[305]=963;t[306]=964;t[307]=966;t[308]=8215;t[309]=8252;t[310]=8319;t[311]=8359;t[312]=8592;t[313]=8593;t[337]=9552;t[493]=1039;t[494]=1040;t[705]=1524;t[706]=8362;t[710]=64288;t[711]=64298;t[759]=1617;t[761]=1776;t[763]=1778;t[775]=1652;t[777]=1764;t[778]=1780;t[779]=1781;t[780]=1782;t[782]=771;t[783]=64726;t[786]=8363;t[788]=8532;t[790]=768;t[791]=769;t[792]=768;t[795]=803;t[797]=64336;t[798]=64337;t[799]=64342;t[800]=64343;t[801]=64344;t[802]=64345;t[803]=64362;t[804]=64363;t[805]=64364;t[2424]=7821;t[2425]=7822;t[2426]=7823;t[2427]=7824;t[2428]=7825;t[2429]=7826;t[2430]=7827;t[2433]=7682;t[2678]=8045;t[2679]=8046;t[2830]=1552;t[2838]=686;t[2840]=751;t[2842]=753;t[2843]=754;t[2844]=755;t[2846]=757;t[2856]=767;t[2857]=848;t[2858]=849;t[2862]=853;t[2863]=854;t[2864]=855;t[2865]=861;t[2866]=862;t[2906]=7460;t[2908]=7462;t[2909]=7463;t[2910]=7464;t[2912]=7466;t[2913]=7467;t[2914]=7468;t[2916]=7470;t[2917]=7471;t[2918]=7472;t[2920]=7474;t[2921]=7475;t[2922]=7476;t[2924]=7478;t[2925]=7479;t[2926]=7480;t[2928]=7482;t[2929]=7483;t[2930]=7484;t[2932]=7486;t[2933]=7487;t[2934]=7488;t[2936]=7490;t[2937]=7491;t[2938]=7492;t[2940]=7494;t[2941]=7495;t[2942]=7496;t[2944]=7498;t[2946]=7500;t[2948]=7502;t[2950]=7504;t[2951]=7505;t[2952]=7506;t[2954]=7508;t[2955]=7509;t[2956]=7510;t[2958]=7512;t[2959]=7513;t[2960]=7514;t[2962]=7516;t[2963]=7517;t[2964]=7518;t[2966]=7520;t[2967]=7521;t[2968]=7522;t[2970]=7524;t[2971]=7525;t[2972]=7526;t[2974]=7528;t[2975]=7529;t[2976]=7530;t[2978]=1537;t[2979]=1538;t[2980]=1539;t[2982]=1549;t[2983]=1551;t[2984]=1552;t[2986]=1554;t[2987]=1555;t[2988]=1556;t[2990]=1623;t[2991]=1624;t[2995]=1775;t[2999]=1791;t[3002]=64290;t[3003]=64291;t[3004]=64292;t[3006]=64294;t[3007]=64295;t[3008]=64296;t[3011]=1900;t[3014]=8223;t[3015]=8244;t[3017]=7532;t[3018]=7533;t[3019]=7534;t[3075]=7590;t[3076]=7591;t[3079]=7594;t[3080]=7595;t[3083]=7598;t[3084]=7599;t[3087]=7602;t[3088]=7603;t[3091]=7606;t[3092]=7607;t[3095]=7610;t[3096]=7611;t[3099]=7614;t[3100]=7615;t[3103]=7618;t[3104]=7619;t[3107]=8337;t[3108]=8338;t[3116]=1884;t[3119]=1885;t[3120]=1885;t[3123]=1886;t[3124]=1886;t[3127]=1887;t[3128]=1887;t[3131]=1888;t[3132]=1888;t[3135]=1889;t[3136]=1889;t[3139]=1890;t[3140]=1890;t[3143]=1891;t[3144]=1891;t[3147]=1892;t[3148]=1892;t[3153]=580;t[3154]=581;t[3157]=584;t[3158]=585;t[3161]=588;t[3162]=589;t[3165]=891;t[3166]=892;t[3169]=1274;t[3170]=1275;t[3173]=1278;t[3174]=1279;t[3181]=7622;t[3182]=7623;t[3282]=11799;t[3316]=578;t[3379]=42785;t[3393]=1159;t[3416]=8377});var getSupplementalGlyphMapForArialBlack=getLookupTableFactory(function(t){t[227]=322;t[264]=261;t[291]=346});exports.getStdFontMap=getStdFontMap;exports.getNonStdFontMap=getNonStdFontMap;exports.getSerifFonts=getSerifFonts;exports.getSymbolsFonts=getSymbolsFonts;exports.getGlyphMapForStandardFonts=getGlyphMapForStandardFonts;exports.getSupplementalGlyphMapForArialBlack=getSupplementalGlyphMapForArialBlack});(function(root,factory){{factory(root.pdfjsCoreUnicode={},root.pdfjsSharedUtil)}})(this,function(exports,sharedUtil){var getLookupTableFactory=sharedUtil.getLookupTableFactory;var getSpecialPUASymbols=getLookupTableFactory(function(t){t[63721]=169;t[63193]=169;t[63720]=174;t[63194]=174;t[63722]=8482;t[63195]=8482;t[63729]=9127;t[63730]=9128;t[63731]=9129;t[63740]=9131;t[63741]=9132;t[63742]=9133;t[63726]=9121;t[63727]=9122;t[63728]=9123;t[63737]=9124;t[63738]=9125;t[63739]=9126;t[63723]=9115;t[63724]=9116;t[63725]=9117;t[63734]=9118;t[63735]=9119;t[63736]=9120});function mapSpecialUnicodeValues(code){if(code>=65520&&code<=65535){return 0}else if(code>=62976&&code<=63743){return getSpecialPUASymbols()[code]||code}return code}function getUnicodeForGlyph(name,glyphsUnicodeMap){var unicode=glyphsUnicodeMap[name];if(unicode!==undefined){return unicode}if(!name){return-1}if(name[0]==="u"){var nameLen=name.length,hexStr;if(nameLen===7&&name[1]==="n"&&name[2]==="i"){hexStr=name.substr(3)}else if(nameLen>=5&&nameLen<=7){hexStr=name.substr(1)}else{return-1}if(hexStr===hexStr.toUpperCase()){unicode=parseInt(hexStr,16);if(unicode>=0){return unicode}}}return-1}var UnicodeRanges=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];
13function getUnicodeRangeFor(value){for(var i=0,ii=UnicodeRanges.length;i<ii;i++){var range=UnicodeRanges[i];if(value>=range.begin&&value<range.end){return i}}return-1}function isRTLRangeFor(value){var range=UnicodeRanges[13];if(value>=range.begin&&value<range.end){return true}range=UnicodeRanges[11];if(value>=range.begin&&value<range.end){return true}return false}var getNormalizedUnicodes=getLookupTableFactory(function(t){t["¨"]=" ̈";t["¯"]=" ̄";t["´"]=" ́";t["µ"]="μ";t["¸"]=" ̧";t["IJ"]="IJ";t["ij"]="ij";t["Ŀ"]="L·";t["ŀ"]="l·";t["ʼn"]="ʼn";t["ſ"]="s";t["DŽ"]="DŽ";t["Dž"]="Dž";t["dž"]="dž";t["LJ"]="LJ";t["Lj"]="Lj";t["lj"]="lj";t["NJ"]="NJ";t["Nj"]="Nj";t["nj"]="nj";t["DZ"]="DZ";t["Dz"]="Dz";t["dz"]="dz";t["˘"]=" ̆";t["˙"]=" ̇";t["˚"]=" ̊";t["˛"]=" ̨";t["˜"]=" ̃";t["˝"]=" ̋";t["ͺ"]=" ͅ";t["΄"]=" ́";t["ϐ"]="β";t["ϑ"]="θ";t["ϒ"]="Υ";t["ϕ"]="φ";t["ϖ"]="π";t["ϰ"]="κ";t["ϱ"]="ρ";t["ϲ"]="ς";t["ϴ"]="Θ";t["ϵ"]="ε";t["Ϲ"]="Σ";t["և"]="եւ";t["ٵ"]="اٴ";t["ٶ"]="وٴ";t["ٷ"]="ۇٴ";t["ٸ"]="يٴ";t["ำ"]="ํา";t["ຳ"]="ໍາ";t["ໜ"]="ຫນ";t["ໝ"]="ຫມ";t["ཷ"]="ྲཱྀ";t["ཹ"]="ླཱྀ";t["ẚ"]="aʾ";t["᾽"]=" ̓";t["᾿"]=" ̓";t["῀"]=" ͂";t["῾"]=" ̔";t[" "]=" ";t[" "]=" ";t[" "]=" ";t[" "]=" ";t[" "]=" ";t[" "]=" ";t[" "]=" ";t[" "]=" ";t["‗"]=" ̳";t["․"]=".";t["‥"]="..";t["…"]="...";t["″"]="′′";t["‴"]="′′′";t["‶"]="‵‵";t["‷"]="‵‵‵";t["‼"]="!!";t["‾"]=" ̅";t["⁇"]="??";t["⁈"]="?!";t["⁉"]="!?";t["⁗"]="′′′′";t[" "]=" ";t["₨"]="Rs";t["℀"]="a/c";t["℁"]="a/s";t["℃"]="°C";t["℅"]="c/o";t["℆"]="c/u";t["ℇ"]="Ɛ";t["℉"]="°F";t["№"]="No";t["℡"]="TEL";t["ℵ"]="א";t["ℶ"]="ב";t["ℷ"]="ג";t["ℸ"]="ד";t["℻"]="FAX";t["Ⅰ"]="I";t["Ⅱ"]="II";t["Ⅲ"]="III";t["Ⅳ"]="IV";t["Ⅴ"]="V";t["Ⅵ"]="VI";t["Ⅶ"]="VII";t["Ⅷ"]="VIII";t["Ⅸ"]="IX";t["Ⅹ"]="X";t["Ⅺ"]="XI";t["Ⅻ"]="XII";t["Ⅼ"]="L";t["Ⅽ"]="C";t["Ⅾ"]="D";t["Ⅿ"]="M";t["ⅰ"]="i";t["ⅱ"]="ii";t["ⅲ"]="iii";t["ⅳ"]="iv";t["ⅴ"]="v";t["ⅵ"]="vi";t["ⅶ"]="vii";t["ⅷ"]="viii";t["ⅸ"]="ix";t["ⅹ"]="x";t["ⅺ"]="xi";t["ⅻ"]="xii";t["ⅼ"]="l";t["ⅽ"]="c";t["ⅾ"]="d";t["ⅿ"]="m";t["∬"]="∫∫";t["∭"]="∫∫∫";t["∯"]="∮∮";t["∰"]="∮∮∮";t["⑴"]="(1)";t["⑵"]="(2)";t["⑶"]="(3)";t["⑷"]="(4)";t["⑸"]="(5)";t["⑹"]="(6)";t["⑺"]="(7)";t["⑻"]="(8)";t["⑼"]="(9)";t["⑽"]="(10)";t["⑾"]="(11)";t["⑿"]="(12)";t["⒀"]="(13)";t["⒁"]="(14)";t["⒂"]="(15)";t["⒃"]="(16)";t["⒄"]="(17)";t["⒅"]="(18)";t["⒆"]="(19)";t["⒇"]="(20)";t["⒈"]="1.";t["⒉"]="2.";t["⒊"]="3.";t["⒋"]="4.";t["⒌"]="5.";t["⒍"]="6.";t["⒎"]="7.";t["⒏"]="8.";t["⒐"]="9.";t["⒑"]="10.";t["⒒"]="11.";t["⒓"]="12.";t["⒔"]="13.";t["⒕"]="14.";t["⒖"]="15.";t["⒗"]="16.";t["⒘"]="17.";t["⒙"]="18.";t["⒚"]="19.";t["⒛"]="20.";t["⒜"]="(a)";t["⒝"]="(b)";t["⒞"]="(c)";t["⒟"]="(d)";t["⒠"]="(e)";t["⒡"]="(f)";t["⒢"]="(g)";t["⒣"]="(h)";t["⒤"]="(i)";t["⒥"]="(j)";t["⒦"]="(k)";t["⒧"]="(l)";t["⒨"]="(m)";t["⒩"]="(n)";t["⒪"]="(o)";t["⒫"]="(p)";t["⒬"]="(q)";t["⒭"]="(r)";t["⒮"]="(s)";t["⒯"]="(t)";t["⒰"]="(u)";t["⒱"]="(v)";t["⒲"]="(w)";t["⒳"]="(x)";t["⒴"]="(y)";t["⒵"]="(z)";t["⨌"]="∫∫∫∫";t["⩴"]="::=";t["⩵"]="==";t["⩶"]="===";t["⺟"]="母";t["⻳"]="龟";t["⼀"]="一";t["⼁"]="丨";t["⼂"]="丶";t["⼃"]="丿";t["⼄"]="乙";t["⼅"]="亅";t["⼆"]="二";t["⼇"]="亠";t["⼈"]="人";t["⼉"]="儿";t["⼊"]="入";t["⼋"]="八";t["⼌"]="冂";t["⼍"]="冖";t["⼎"]="冫";t["⼏"]="几";t["⼐"]="凵";t["⼑"]="刀";t["⼒"]="力";t["⼓"]="勹";t["⼔"]="匕";t["⼕"]="匚";t["⼖"]="匸";t["⼗"]="十";t["⼘"]="卜";t["⼙"]="卩";t["⼚"]="厂";t["⼛"]="厶";t["⼜"]="又";t["⼝"]="口";t["⼞"]="囗";t["⼟"]="土";t["⼠"]="士";t["⼡"]="夂";t["⼢"]="夊";t["⼣"]="夕";t["⼤"]="大";t["⼥"]="女";t["⼦"]="子";t["⼧"]="宀";t["⼨"]="寸";t["⼩"]="小";t["⼪"]="尢";t["⼫"]="尸";t["⼬"]="屮";t["⼭"]="山";t["⼮"]="巛";t["⼯"]="工";t["⼰"]="己";t["⼱"]="巾";t["⼲"]="干";t["⼳"]="幺";t["⼴"]="广";t["⼵"]="廴";t["⼶"]="廾";t["⼷"]="弋";t["⼸"]="弓";t["⼹"]="彐";t["⼺"]="彡";t["⼻"]="彳";t["⼼"]="心";t["⼽"]="戈";t["⼾"]="戶";t["⼿"]="手";t["⽀"]="支";t["⽁"]="攴";t["⽂"]="文";t["⽃"]="斗";t["⽄"]="斤";t["⽅"]="方";t["⽆"]="无";t["⽇"]="日";t["⽈"]="曰";t["⽉"]="月";t["⽊"]="木";t["⽋"]="欠";t["⽌"]="止";t["⽍"]="歹";t["⽎"]="殳";t["⽏"]="毋";t["⽐"]="比";t["⽑"]="毛";t["⽒"]="氏";t["⽓"]="气";t["⽔"]="水";t["⽕"]="火";t["⽖"]="爪";t["⽗"]="父";t["⽘"]="爻";t["⽙"]="爿";t["⽚"]="片";t["⽛"]="牙";t["⽜"]="牛";t["⽝"]="犬";t["⽞"]="玄";t["⽟"]="玉";t["⽠"]="瓜";t["⽡"]="瓦";t["⽢"]="甘";t["⽣"]="生";t["⽤"]="用";t["⽥"]="田";t["⽦"]="疋";t["⽧"]="疒";t["⽨"]="癶";t["⽩"]="白";t["⽪"]="皮";t["⽫"]="皿";t["⽬"]="目";t["⽭"]="矛";t["⽮"]="矢";t["⽯"]="石";t["⽰"]="示";t["⽱"]="禸";t["⽲"]="禾";t["⽳"]="穴";t["⽴"]="立";t["⽵"]="竹";t["⽶"]="米";t["⽷"]="糸";t["⽸"]="缶";t["⽹"]="网";t["⽺"]="羊";t["⽻"]="羽";t["⽼"]="老";t["⽽"]="而";t["⽾"]="耒";t["⽿"]="耳";t["⾀"]="聿";t["⾁"]="肉";t["⾂"]="臣";t["⾃"]="自";t["⾄"]="至";t["⾅"]="臼";t["⾆"]="舌";t["⾇"]="舛";t["⾈"]="舟";t["⾉"]="艮";t["⾊"]="色";t["⾋"]="艸";t["⾌"]="虍";t["⾍"]="虫";t["⾎"]="血";t["⾏"]="行";t["⾐"]="衣";t["⾑"]="襾";t["⾒"]="見";t["⾓"]="角";t["⾔"]="言";t["⾕"]="谷";t["⾖"]="豆";t["⾗"]="豕";t["⾘"]="豸";t["⾙"]="貝";t["⾚"]="赤";t["⾛"]="走";t["⾜"]="足";t["⾝"]="身";t["⾞"]="車";t["⾟"]="辛";t["⾠"]="辰";t["⾡"]="辵";t["⾢"]="邑";t["⾣"]="酉";t["⾤"]="釆";t["⾥"]="里";t["⾦"]="金";t["⾧"]="長";t["⾨"]="門";t["⾩"]="阜";t["⾪"]="隶";t["⾫"]="隹";t["⾬"]="雨";t["⾭"]="靑";t["⾮"]="非";t["⾯"]="面";t["⾰"]="革";t["⾱"]="韋";t["⾲"]="韭";t["⾳"]="音";t["⾴"]="頁";t["⾵"]="風";t["⾶"]="飛";t["⾷"]="食";t["⾸"]="首";t["⾹"]="香";t["⾺"]="馬";t["⾻"]="骨";t["⾼"]="高";t["⾽"]="髟";t["⾾"]="鬥";t["⾿"]="鬯";t["⿀"]="鬲";t["⿁"]="鬼";t["⿂"]="魚";t["⿃"]="鳥";t["⿄"]="鹵";t["⿅"]="鹿";t["⿆"]="麥";t["⿇"]="麻";t["⿈"]="黃";t["⿉"]="黍";t["⿊"]="黑";t["⿋"]="黹";t["⿌"]="黽";t["⿍"]="鼎";t["⿎"]="鼓";t["⿏"]="鼠";t["⿐"]="鼻";t["⿑"]="齊";t["⿒"]="齒";t["⿓"]="龍";t["⿔"]="龜";t["⿕"]="龠";t["〶"]="〒";t["〸"]="十";t["〹"]="卄";t["〺"]="卅";t["゛"]=" ゙";t["゜"]=" ゚";t["ㄱ"]="ᄀ";t["ㄲ"]="ᄁ";t["ㄳ"]="ᆪ";t["ㄴ"]="ᄂ";t["ㄵ"]="ᆬ";t["ㄶ"]="ᆭ";t["ㄷ"]="ᄃ";t["ㄸ"]="ᄄ";t["ㄹ"]="ᄅ";t["ㄺ"]="ᆰ";t["ㄻ"]="ᆱ";t["ㄼ"]="ᆲ";t["ㄽ"]="ᆳ";t["ㄾ"]="ᆴ";t["ㄿ"]="ᆵ";t["ㅀ"]="ᄚ";t["ㅁ"]="ᄆ";t["ㅂ"]="ᄇ";t["ㅃ"]="ᄈ";t["ㅄ"]="ᄡ";t["ㅅ"]="ᄉ";t["ㅆ"]="ᄊ";t["ㅇ"]="ᄋ";t["ㅈ"]="ᄌ";t["ㅉ"]="ᄍ";t["ㅊ"]="ᄎ";t["ㅋ"]="ᄏ";t["ㅌ"]="ᄐ";t["ㅍ"]="ᄑ";t["ㅎ"]="ᄒ";t["ㅏ"]="ᅡ";t["ㅐ"]="ᅢ";t["ㅑ"]="ᅣ";t["ㅒ"]="ᅤ";t["ㅓ"]="ᅥ";t["ㅔ"]="ᅦ";t["ㅕ"]="ᅧ";t["ㅖ"]="ᅨ";t["ㅗ"]="ᅩ";t["ㅘ"]="ᅪ";t["ㅙ"]="ᅫ";t["ㅚ"]="ᅬ";t["ㅛ"]="ᅭ";t["ㅜ"]="ᅮ";t["ㅝ"]="ᅯ";t["ㅞ"]="ᅰ";t["ㅟ"]="ᅱ";t["ㅠ"]="ᅲ";t["ㅡ"]="ᅳ";t["ㅢ"]="ᅴ";t["ㅣ"]="ᅵ";t["ㅤ"]="ᅠ";t["ㅥ"]="ᄔ";t["ㅦ"]="ᄕ";t["ㅧ"]="ᇇ";t["ㅨ"]="ᇈ";t["ㅩ"]="ᇌ";t["ㅪ"]="ᇎ";t["ㅫ"]="ᇓ";t["ㅬ"]="ᇗ";t["ㅭ"]="ᇙ";t["ㅮ"]="ᄜ";t["ㅯ"]="ᇝ";t["ㅰ"]="ᇟ";t["ㅱ"]="ᄝ";t["ㅲ"]="ᄞ";t["ㅳ"]="ᄠ";t["ㅴ"]="ᄢ";t["ㅵ"]="ᄣ";t["ㅶ"]="ᄧ";t["ㅷ"]="ᄩ";t["ㅸ"]="ᄫ";t["ㅹ"]="ᄬ";t["ㅺ"]="ᄭ";t["ㅻ"]="ᄮ";t["ㅼ"]="ᄯ";t["ㅽ"]="ᄲ";t["ㅾ"]="ᄶ";t["ㅿ"]="ᅀ";t["ㆀ"]="ᅇ";t["ㆁ"]="ᅌ";t["ㆂ"]="ᇱ";t["ㆃ"]="ᇲ";t["ㆄ"]="ᅗ";t["ㆅ"]="ᅘ";t["ㆆ"]="ᅙ";t["ㆇ"]="ᆄ";t["ㆈ"]="ᆅ";t["ㆉ"]="ᆈ";t["ㆊ"]="ᆑ";t["ㆋ"]="ᆒ";t["ㆌ"]="ᆔ";t["ㆍ"]="ᆞ";t["ㆎ"]="ᆡ";t["㈀"]="(ᄀ)";t["㈁"]="(ᄂ)";t["㈂"]="(ᄃ)";t["㈃"]="(ᄅ)";t["㈄"]="(ᄆ)";t["㈅"]="(ᄇ)";t["㈆"]="(ᄉ)";t["㈇"]="(ᄋ)";t["㈈"]="(ᄌ)";t["㈉"]="(ᄎ)";t["㈊"]="(ᄏ)";t["㈋"]="(ᄐ)";t["㈌"]="(ᄑ)";t["㈍"]="(ᄒ)";t["㈎"]="(가)";t["㈏"]="(나)";t["㈐"]="(다)";t["㈑"]="(라)";t["㈒"]="(마)";t["㈓"]="(바)";t["㈔"]="(사)";t["㈕"]="(아)";t["㈖"]="(자)";t["㈗"]="(차)";t["㈘"]="(카)";t["㈙"]="(타)";t["㈚"]="(파)";t["㈛"]="(하)";t["㈜"]="(주)";t["㈝"]="(오전)";t["㈞"]="(오후)";t["㈠"]="(一)";t["㈡"]="(二)";t["㈢"]="(三)";t["㈣"]="(四)";t["㈤"]="(五)";t["㈥"]="(六)";t["㈦"]="(七)";t["㈧"]="(八)";t["㈨"]="(九)";t["㈩"]="(十)";t["㈪"]="(月)";t["㈫"]="(火)";t["㈬"]="(水)";t["㈭"]="(木)";t["㈮"]="(金)";t["㈯"]="(土)";t["㈰"]="(日)";t["㈱"]="(株)";t["㈲"]="(有)";t["㈳"]="(社)";t["㈴"]="(名)";t["㈵"]="(特)";t["㈶"]="(財)";t["㈷"]="(祝)";t["㈸"]="(労)";t["㈹"]="(代)";t["㈺"]="(呼)";t["㈻"]="(学)";t["㈼"]="(監)";t["㈽"]="(企)";t["㈾"]="(資)";t["㈿"]="(協)";t["㉀"]="(祭)";t["㉁"]="(休)";t["㉂"]="(自)";t["㉃"]="(至)";t["㋀"]="1月";t["㋁"]="2月";t["㋂"]="3月";t["㋃"]="4月";t["㋄"]="5月";t["㋅"]="6月";t["㋆"]="7月";t["㋇"]="8月";t["㋈"]="9月";t["㋉"]="10月";t["㋊"]="11月";t["㋋"]="12月";t["㍘"]="0点";t["㍙"]="1点";t["㍚"]="2点";t["㍛"]="3点";t["㍜"]="4点";t["㍝"]="5点";t["㍞"]="6点";t["㍟"]="7点";t["㍠"]="8点";t["㍡"]="9点";t["㍢"]="10点";t["㍣"]="11点";t["㍤"]="12点";t["㍥"]="13点";t["㍦"]="14点";t["㍧"]="15点";t["㍨"]="16点";t["㍩"]="17点";t["㍪"]="18点";t["㍫"]="19点";t["㍬"]="20点";t["㍭"]="21点";t["㍮"]="22点";t["㍯"]="23点";t["㍰"]="24点";t["㏠"]="1日";t["㏡"]="2日";t["㏢"]="3日";t["㏣"]="4日";t["㏤"]="5日";t["㏥"]="6日";t["㏦"]="7日";t["㏧"]="8日";t["㏨"]="9日";t["㏩"]="10日";t["㏪"]="11日";t["㏫"]="12日";t["㏬"]="13日";t["㏭"]="14日";t["㏮"]="15日";t["㏯"]="16日";t["㏰"]="17日";t["㏱"]="18日";t["㏲"]="19日";t["㏳"]="20日";t["㏴"]="21日";t["㏵"]="22日";t["㏶"]="23日";t["㏷"]="24日";t["㏸"]="25日";t["㏹"]="26日";t["㏺"]="27日";t["㏻"]="28日";t["㏼"]="29日";t["㏽"]="30日";t["㏾"]="31日";t["ff"]="ff";t["fi"]="fi";t["fl"]="fl";t["ffi"]="ffi";t["ffl"]="ffl";t["ſt"]="ſt";t["st"]="st";t["ﬓ"]="մն";t["ﬔ"]="մե";t["ﬕ"]="մի";t["ﬖ"]="վն";t["ﬗ"]="մխ";t["ﭏ"]="אל";t["ﭐ"]="ٱ";t["ﭑ"]="ٱ";t["ﭒ"]="ٻ";t["ﭓ"]="ٻ";t["ﭔ"]="ٻ";t["ﭕ"]="ٻ";t["ﭖ"]="پ";t["ﭗ"]="پ";t["ﭘ"]="پ";t["ﭙ"]="پ";t["ﭚ"]="ڀ";t["ﭛ"]="ڀ";t["ﭜ"]="ڀ";t["ﭝ"]="ڀ";t["ﭞ"]="ٺ";t["ﭟ"]="ٺ";t["ﭠ"]="ٺ";t["ﭡ"]="ٺ";t["ﭢ"]="ٿ";t["ﭣ"]="ٿ";t["ﭤ"]="ٿ";t["ﭥ"]="ٿ";t["ﭦ"]="ٹ";t["ﭧ"]="ٹ";t["ﭨ"]="ٹ";t["ﭩ"]="ٹ";t["ﭪ"]="ڤ";t["ﭫ"]="ڤ";t["ﭬ"]="ڤ";t["ﭭ"]="ڤ";t["ﭮ"]="ڦ";t["ﭯ"]="ڦ";t["ﭰ"]="ڦ";t["ﭱ"]="ڦ";t["ﭲ"]="ڄ";t["ﭳ"]="ڄ";t["ﭴ"]="ڄ";t["ﭵ"]="ڄ";t["ﭶ"]="ڃ";t["ﭷ"]="ڃ";t["ﭸ"]="ڃ";t["ﭹ"]="ڃ";t["ﭺ"]="چ";t["ﭻ"]="چ";t["ﭼ"]="چ";t["ﭽ"]="چ";t["ﭾ"]="ڇ";t["ﭿ"]="ڇ";t["ﮀ"]="ڇ";t["ﮁ"]="ڇ";t["ﮂ"]="ڍ";t["ﮃ"]="ڍ";t["ﮄ"]="ڌ";t["ﮅ"]="ڌ";t["ﮆ"]="ڎ";t["ﮇ"]="ڎ";t["ﮈ"]="ڈ";t["ﮉ"]="ڈ";t["ﮊ"]="ژ";t["ﮋ"]="ژ";t["ﮌ"]="ڑ";t["ﮍ"]="ڑ";t["ﮎ"]="ک";t["ﮏ"]="ک";t["ﮐ"]="ک";t["ﮑ"]="ک";t["ﮒ"]="گ";t["ﮓ"]="گ";t["ﮔ"]="گ";t["ﮕ"]="گ";t["ﮖ"]="ڳ";t["ﮗ"]="ڳ";t["ﮘ"]="ڳ";t["ﮙ"]="ڳ";t["ﮚ"]="ڱ";t["ﮛ"]="ڱ";t["ﮜ"]="ڱ";t["ﮝ"]="ڱ";t["ﮞ"]="ں";t["ﮟ"]="ں";t["ﮠ"]="ڻ";t["ﮡ"]="ڻ";t["ﮢ"]="ڻ";t["ﮣ"]="ڻ";t["ﮤ"]="ۀ";t["ﮥ"]="ۀ";t["ﮦ"]="ہ";t["ﮧ"]="ہ";t["ﮨ"]="ہ";t["ﮩ"]="ہ";t["ﮪ"]="ھ";t["ﮫ"]="ھ";t["ﮬ"]="ھ";t["ﮭ"]="ھ";t["ﮮ"]="ے";t["ﮯ"]="ے";t["ﮰ"]="ۓ";t["ﮱ"]="ۓ";t["ﯓ"]="ڭ";t["ﯔ"]="ڭ";t["ﯕ"]="ڭ";t["ﯖ"]="ڭ";t["ﯗ"]="ۇ";t["ﯘ"]="ۇ";t["ﯙ"]="ۆ";t["ﯚ"]="ۆ";t["ﯛ"]="ۈ";t["ﯜ"]="ۈ";t["ﯝ"]="ٷ";t["ﯞ"]="ۋ";t["ﯟ"]="ۋ";t["ﯠ"]="ۅ";t["ﯡ"]="ۅ";t["ﯢ"]="ۉ";t["ﯣ"]="ۉ";t["ﯤ"]="ې";t["ﯥ"]="ې";t["ﯦ"]="ې";t["ﯧ"]="ې";t["ﯨ"]="ى";t["ﯩ"]="ى";t["ﯪ"]="ئا";t["ﯫ"]="ئا";t["ﯬ"]="ئە";t["ﯭ"]="ئە";t["ﯮ"]="ئو";t["ﯯ"]="ئو";t["ﯰ"]="ئۇ";t["ﯱ"]="ئۇ";t["ﯲ"]="ئۆ";t["ﯳ"]="ئۆ";t["ﯴ"]="ئۈ";t["ﯵ"]="ئۈ";t["ﯶ"]="ئې";t["ﯷ"]="ئې";t["ﯸ"]="ئې";t["ﯹ"]="ئى";t["ﯺ"]="ئى";t["ﯻ"]="ئى";t["ﯼ"]="ی";t["ﯽ"]="ی";t["ﯾ"]="ی";t["ﯿ"]="ی";t["ﰀ"]="ئج";t["ﰁ"]="ئح";t["ﰂ"]="ئم";t["ﰃ"]="ئى";t["ﰄ"]="ئي";t["ﰅ"]="بج";t["ﰆ"]="بح";t["ﰇ"]="بخ";t["ﰈ"]="بم";t["ﰉ"]="بى";t["ﰊ"]="بي";t["ﰋ"]="تج";t["ﰌ"]="تح";t["ﰍ"]="تخ";t["ﰎ"]="تم";t["ﰏ"]="تى";t["ﰐ"]="تي";t["ﰑ"]="ثج";t["ﰒ"]="ثم";t["ﰓ"]="ثى";t["ﰔ"]="ثي";t["ﰕ"]="جح";t["ﰖ"]="جم";t["ﰗ"]="حج";t["ﰘ"]="حم";t["ﰙ"]="خج";t["ﰚ"]="خح";t["ﰛ"]="خم";t["ﰜ"]="سج";t["ﰝ"]="سح";t["ﰞ"]="سخ";t["ﰟ"]="سم";t["ﰠ"]="صح";t["ﰡ"]="صم";t["ﰢ"]="ضج";t["ﰣ"]="ضح";t["ﰤ"]="ضخ";t["ﰥ"]="ضم";t["ﰦ"]="طح";t["ﰧ"]="طم";t["ﰨ"]="ظم";t["ﰩ"]="عج";t["ﰪ"]="عم";t["ﰫ"]="غج";t["ﰬ"]="غم";t["ﰭ"]="فج";t["ﰮ"]="فح";t["ﰯ"]="فخ";t["ﰰ"]="فم";t["ﰱ"]="فى";t["ﰲ"]="في";t["ﰳ"]="قح";t["ﰴ"]="قم";t["ﰵ"]="قى";t["ﰶ"]="قي";t["ﰷ"]="كا";t["ﰸ"]="كج";t["ﰹ"]="كح";t["ﰺ"]="كخ";t["ﰻ"]="كل";t["ﰼ"]="كم";t["ﰽ"]="كى";t["ﰾ"]="كي";t["ﰿ"]="لج";t["ﱀ"]="لح";t["ﱁ"]="لخ";t["ﱂ"]="لم";t["ﱃ"]="لى";t["ﱄ"]="لي";t["ﱅ"]="مج";t["ﱆ"]="مح";t["ﱇ"]="مخ";t["ﱈ"]="مم";t["ﱉ"]="مى";t["ﱊ"]="مي";t["ﱋ"]="نج";t["ﱌ"]="نح";t["ﱍ"]="نخ";t["ﱎ"]="نم";t["ﱏ"]="نى";t["ﱐ"]="ني";t["ﱑ"]="هج";t["ﱒ"]="هم";t["ﱓ"]="هى";t["ﱔ"]="هي";t["ﱕ"]="يج";t["ﱖ"]="يح";t["ﱗ"]="يخ";t["ﱘ"]="يم";t["ﱙ"]="يى";t["ﱚ"]="يي";t["ﱛ"]="ذٰ";t["ﱜ"]="رٰ";t["ﱝ"]="ىٰ";t["ﱞ"]=" ٌّ";t["ﱟ"]=" ٍّ";t["ﱠ"]=" َّ";t["ﱡ"]=" ُّ";t["ﱢ"]=" ِّ";t["ﱣ"]=" ّٰ";t["ﱤ"]="ئر";t["ﱥ"]="ئز";t["ﱦ"]="ئم";t["ﱧ"]="ئن";t["ﱨ"]="ئى";t["ﱩ"]="ئي";t["ﱪ"]="بر";t["ﱫ"]="بز";t["ﱬ"]="بم";t["ﱭ"]="بن";t["ﱮ"]="بى";t["ﱯ"]="بي";t["ﱰ"]="تر";t["ﱱ"]="تز";t["ﱲ"]="تم";t["ﱳ"]="تن";t["ﱴ"]="تى";t["ﱵ"]="تي";t["ﱶ"]="ثر";t["ﱷ"]="ثز";t["ﱸ"]="ثم";t["ﱹ"]="ثن";t["ﱺ"]="ثى";t["ﱻ"]="ثي";t["ﱼ"]="فى";t["ﱽ"]="في";t["ﱾ"]="قى";t["ﱿ"]="قي";t["ﲀ"]="كا";t["ﲁ"]="كل";t["ﲂ"]="كم";t["ﲃ"]="كى";t["ﲄ"]="كي";t["ﲅ"]="لم";t["ﲆ"]="لى";t["ﲇ"]="لي";t["ﲈ"]="ما";t["ﲉ"]="مم";t["ﲊ"]="نر";t["ﲋ"]="نز";t["ﲌ"]="نم";t["ﲍ"]="نن";t["ﲎ"]="نى";t["ﲏ"]="ني";t["ﲐ"]="ىٰ";t["ﲑ"]="ير";t["ﲒ"]="يز";t["ﲓ"]="يم";t["ﲔ"]="ين";t["ﲕ"]="يى";t["ﲖ"]="يي";t["ﲗ"]="ئج";t["ﲘ"]="ئح";t["ﲙ"]="ئخ";t["ﲚ"]="ئم";t["ﲛ"]="ئه";t["ﲜ"]="بج";t["ﲝ"]="بح";t["ﲞ"]="بخ";t["ﲟ"]="بم";t["ﲠ"]="به";t["ﲡ"]="تج";t["ﲢ"]="تح";t["ﲣ"]="تخ";t["ﲤ"]="تم";t["ﲥ"]="ته";t["ﲦ"]="ثم";t["ﲧ"]="جح";t["ﲨ"]="جم";t["ﲩ"]="حج";t["ﲪ"]="حم";t["ﲫ"]="خج";t["ﲬ"]="خم";t["ﲭ"]="سج";t["ﲮ"]="سح";t["ﲯ"]="سخ";t["ﲰ"]="سم";t["ﲱ"]="صح";t["ﲲ"]="صخ";t["ﲳ"]="صم";t["ﲴ"]="ضج";t["ﲵ"]="ضح";t["ﲶ"]="ضخ";t["ﲷ"]="ضم";t["ﲸ"]="طح";t["ﲹ"]="ظم";t["ﲺ"]="عج";t["ﲻ"]="عم";t["ﲼ"]="غج";t["ﲽ"]="غم";t["ﲾ"]="فج";t["ﲿ"]="فح";t["ﳀ"]="فخ";t["ﳁ"]="فم";t["ﳂ"]="قح";t["ﳃ"]="قم";t["ﳄ"]="كج";t["ﳅ"]="كح";t["ﳆ"]="كخ";t["ﳇ"]="كل";t["ﳈ"]="كم";t["ﳉ"]="لج";t["ﳊ"]="لح";t["ﳋ"]="لخ";t["ﳌ"]="لم";t["ﳍ"]="له";t["ﳎ"]="مج";t["ﳏ"]="مح";t["ﳐ"]="مخ";t["ﳑ"]="مم";t["ﳒ"]="نج";t["ﳓ"]="نح";t["ﳔ"]="نخ";t["ﳕ"]="نم";t["ﳖ"]="نه";t["ﳗ"]="هج";t["ﳘ"]="هم";t["ﳙ"]="هٰ";t["ﳚ"]="يج";t["ﳛ"]="يح";t["ﳜ"]="يخ";t["ﳝ"]="يم";t["ﳞ"]="يه";t["ﳟ"]="ئم";t["ﳠ"]="ئه";t["ﳡ"]="بم";t["ﳢ"]="به";t["ﳣ"]="تم";t["ﳤ"]="ته";t["ﳥ"]="ثم";t["ﳦ"]="ثه";t["ﳧ"]="سم";t["ﳨ"]="سه";t["ﳩ"]="شم";t["ﳪ"]="شه";t["ﳫ"]="كل";t["ﳬ"]="كم";t["ﳭ"]="لم";t["ﳮ"]="نم";t["ﳯ"]="نه";t["ﳰ"]="يم";t["ﳱ"]="يه";t["ﳲ"]="ـَّ";t["ﳳ"]="ـُّ";t["ﳴ"]="ـِّ";t["ﳵ"]="طى";t["ﳶ"]="طي";t["ﳷ"]="عى";t["ﳸ"]="عي";t["ﳹ"]="غى";t["ﳺ"]="غي";t["ﳻ"]="سى";t["ﳼ"]="سي";t["ﳽ"]="شى";t["ﳾ"]="شي";t["ﳿ"]="حى";t["ﴀ"]="حي";t["ﴁ"]="جى";t["ﴂ"]="جي";t["ﴃ"]="خى";t["ﴄ"]="خي";t["ﴅ"]="صى";t["ﴆ"]="صي";t["ﴇ"]="ضى";t["ﴈ"]="ضي";t["ﴉ"]="شج";t["ﴊ"]="شح";t["ﴋ"]="شخ";t["ﴌ"]="شم";t["ﴍ"]="شر";t["ﴎ"]="سر";t["ﴏ"]="صر";t["ﴐ"]="ضر";t["ﴑ"]="طى";t["ﴒ"]="طي";t["ﴓ"]="عى";t["ﴔ"]="عي";t["ﴕ"]="غى";t["ﴖ"]="غي";t["ﴗ"]="سى";t["ﴘ"]="سي";t["ﴙ"]="شى";t["ﴚ"]="شي";t["ﴛ"]="حى";t["ﴜ"]="حي";t["ﴝ"]="جى";t["ﴞ"]="جي";t["ﴟ"]="خى";t["ﴠ"]="خي";t["ﴡ"]="صى";t["ﴢ"]="صي";t["ﴣ"]="ضى";t["ﴤ"]="ضي";t["ﴥ"]="شج";t["ﴦ"]="شح";t["ﴧ"]="شخ";t["ﴨ"]="شم";t["ﴩ"]="شر";t["ﴪ"]="سر";t["ﴫ"]="صر";t["ﴬ"]="ضر";t["ﴭ"]="شج";t["ﴮ"]="شح";t["ﴯ"]="شخ";t["ﴰ"]="شم";t["ﴱ"]="سه";t["ﴲ"]="شه";t["ﴳ"]="طم";t["ﴴ"]="سج";t["ﴵ"]="سح";t["ﴶ"]="سخ";t["ﴷ"]="شج";t["ﴸ"]="شح";t["ﴹ"]="شخ";t["ﴺ"]="طم";t["ﴻ"]="ظم";t["ﴼ"]="اً";t["ﴽ"]="اً";t["ﵐ"]="تجم";t["ﵑ"]="تحج";t["ﵒ"]="تحج";t["ﵓ"]="تحم";t["ﵔ"]="تخم";t["ﵕ"]="تمج";t["ﵖ"]="تمح";t["ﵗ"]="تمخ";t["ﵘ"]="جمح";t["ﵙ"]="جمح";t["ﵚ"]="حمي";t["ﵛ"]="حمى";t["ﵜ"]="سحج";t["ﵝ"]="سجح";t["ﵞ"]="سجى";t["ﵟ"]="سمح";t["ﵠ"]="سمح";t["ﵡ"]="سمج";t["ﵢ"]="سمم";t["ﵣ"]="سمم";t["ﵤ"]="صحح";t["ﵥ"]="صحح";t["ﵦ"]="صمم";t["ﵧ"]="شحم";t["ﵨ"]="شحم";t["ﵩ"]="شجي";t["ﵪ"]="شمخ";t["ﵫ"]="شمخ";t["ﵬ"]="شمم";t["ﵭ"]="شمم";t["ﵮ"]="ضحى";t["ﵯ"]="ضخم";t["ﵰ"]="ضخم";t["ﵱ"]="طمح";t["ﵲ"]="طمح";t["ﵳ"]="طمم";t["ﵴ"]="طمي";t["ﵵ"]="عجم";t["ﵶ"]="عمم";t["ﵷ"]="عمم";t["ﵸ"]="عمى";t["ﵹ"]="غمم";t["ﵺ"]="غمي";t["ﵻ"]="غمى";t["ﵼ"]="فخم";t["ﵽ"]="فخم";t["ﵾ"]="قمح";t["ﵿ"]="قمم";t["ﶀ"]="لحم";t["ﶁ"]="لحي";t["ﶂ"]="لحى";t["ﶃ"]="لجج";t["ﶄ"]="لجج";t["ﶅ"]="لخم";t["ﶆ"]="لخم";t["ﶇ"]="لمح";t["ﶈ"]="لمح";t["ﶉ"]="محج";t["ﶊ"]="محم";t["ﶋ"]="محي";t["ﶌ"]="مجح";t["ﶍ"]="مجم";t["ﶎ"]="مخج";t["ﶏ"]="مخم";t["ﶒ"]="مجخ";t["ﶓ"]="همج";t["ﶔ"]="همم";t["ﶕ"]="نحم";t["ﶖ"]="نحى";t["ﶗ"]="نجم";t["ﶘ"]="نجم";t["ﶙ"]="نجى";t["ﶚ"]="نمي";t["ﶛ"]="نمى";t["ﶜ"]="يمم";t["ﶝ"]="يمم";t["ﶞ"]="بخي";t["ﶟ"]="تجي";t["ﶠ"]="تجى";t["ﶡ"]="تخي";t["ﶢ"]="تخى";t["ﶣ"]="تمي";t["ﶤ"]="تمى";t["ﶥ"]="جمي";t["ﶦ"]="جحى";t["ﶧ"]="جمى";t["ﶨ"]="سخى";t["ﶩ"]="صحي";t["ﶪ"]="شحي";t["ﶫ"]="ضحي";t["ﶬ"]="لجي";t["ﶭ"]="لمي";t["ﶮ"]="يحي";t["ﶯ"]="يجي";t["ﶰ"]="يمي";t["ﶱ"]="ممي";t["ﶲ"]="قمي";t["ﶳ"]="نحي";t["ﶴ"]="قمح";t["ﶵ"]="لحم";t["ﶶ"]="عمي";t["ﶷ"]="كمي";t["ﶸ"]="نجح";t["ﶹ"]="مخي";t["ﶺ"]="لجم";t["ﶻ"]="كمم";t["ﶼ"]="لجم";t["ﶽ"]="نجح";t["ﶾ"]="جحي";t["ﶿ"]="حجي";t["ﷀ"]="مجي";t["ﷁ"]="فمي";t["ﷂ"]="بحي";t["ﷃ"]="كمم";t["ﷄ"]="عجم";t["ﷅ"]="صمم";t["ﷆ"]="سخي";t["ﷇ"]="نجي";t["﹉"]="‾";t["﹊"]="‾";t["﹋"]="‾";t["﹌"]="‾";t["﹍"]="_";t["﹎"]="_";t["﹏"]="_";t["ﺀ"]="ء";t["ﺁ"]="آ";t["ﺂ"]="آ";t["ﺃ"]="أ";t["ﺄ"]="أ";t["ﺅ"]="ؤ";t["ﺆ"]="ؤ";t["ﺇ"]="إ";t["ﺈ"]="إ";t["ﺉ"]="ئ";t["ﺊ"]="ئ";t["ﺋ"]="ئ";t["ﺌ"]="ئ";t["ﺍ"]="ا";t["ﺎ"]="ا";t["ﺏ"]="ب";t["ﺐ"]="ب";t["ﺑ"]="ب";t["ﺒ"]="ب";t["ﺓ"]="ة";t["ﺔ"]="ة";t["ﺕ"]="ت";t["ﺖ"]="ت";t["ﺗ"]="ت";t["ﺘ"]="ت";t["ﺙ"]="ث";t["ﺚ"]="ث";t["ﺛ"]="ث";t["ﺜ"]="ث";t["ﺝ"]="ج";t["ﺞ"]="ج";t["ﺟ"]="ج";t["ﺠ"]="ج";t["ﺡ"]="ح";t["ﺢ"]="ح";t["ﺣ"]="ح";t["ﺤ"]="ح";t["ﺥ"]="خ";t["ﺦ"]="خ";t["ﺧ"]="خ";t["ﺨ"]="خ";t["ﺩ"]="د";t["ﺪ"]="د";t["ﺫ"]="ذ";t["ﺬ"]="ذ";t["ﺭ"]="ر";t["ﺮ"]="ر";t["ﺯ"]="ز";t["ﺰ"]="ز";t["ﺱ"]="س";t["ﺲ"]="س";t["ﺳ"]="س";t["ﺴ"]="س";t["ﺵ"]="ش";t["ﺶ"]="ش";t["ﺷ"]="ش";t["ﺸ"]="ش";t["ﺹ"]="ص";t["ﺺ"]="ص";t["ﺻ"]="ص";t["ﺼ"]="ص";t["ﺽ"]="ض";t["ﺾ"]="ض";t["ﺿ"]="ض";t["ﻀ"]="ض";t["ﻁ"]="ط";t["ﻂ"]="ط";t["ﻃ"]="ط";t["ﻄ"]="ط";t["ﻅ"]="ظ";t["ﻆ"]="ظ";t["ﻇ"]="ظ";t["ﻈ"]="ظ";t["ﻉ"]="ع";t["ﻊ"]="ع";t["ﻋ"]="ع";t["ﻌ"]="ع";t["ﻍ"]="غ";t["ﻎ"]="غ";t["ﻏ"]="غ";t["ﻐ"]="غ";t["ﻑ"]="ف";t["ﻒ"]="ف";t["ﻓ"]="ف";t["ﻔ"]="ف";t["ﻕ"]="ق";t["ﻖ"]="ق";t["ﻗ"]="ق";t["ﻘ"]="ق";t["ﻙ"]="ك";t["ﻚ"]="ك";t["ﻛ"]="ك";t["ﻜ"]="ك";t["ﻝ"]="ل";t["ﻞ"]="ل";t["ﻟ"]="ل";t["ﻠ"]="ل";t["ﻡ"]="م";t["ﻢ"]="م";t["ﻣ"]="م";t["ﻤ"]="م";t["ﻥ"]="ن";t["ﻦ"]="ن";t["ﻧ"]="ن";t["ﻨ"]="ن";t["ﻩ"]="ه";t["ﻪ"]="ه";t["ﻫ"]="ه";t["ﻬ"]="ه";t["ﻭ"]="و";t["ﻮ"]="و";t["ﻯ"]="ى";t["ﻰ"]="ى";t["ﻱ"]="ي";t["ﻲ"]="ي";t["ﻳ"]="ي";t["ﻴ"]="ي";t["ﻵ"]="لآ";t["ﻶ"]="لآ";t["ﻷ"]="لأ";t["ﻸ"]="لأ";t["ﻹ"]="لإ";t["ﻺ"]="لإ";t["ﻻ"]="لا";t["ﻼ"]="لا"});function reverseIfRtl(chars){var charsLength=chars.length;if(charsLength<=1||!isRTLRangeFor(chars.charCodeAt(0))){return chars}var s="";for(var ii=charsLength-1;ii>=0;ii--){s+=chars[ii]}return s}exports.mapSpecialUnicodeValues=mapSpecialUnicodeValues;exports.reverseIfRtl=reverseIfRtl;exports.getUnicodeRangeFor=getUnicodeRangeFor;exports.getNormalizedUnicodes=getNormalizedUnicodes;exports.getUnicodeForGlyph=getUnicodeForGlyph});(function(root,factory){{factory(root.pdfjsCoreStream={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreJbig2,root.pdfjsCoreJpg,root.pdfjsCoreJpx)}})(this,function(exports,sharedUtil,corePrimitives,coreJbig2,coreJpg,coreJpx){var Util=sharedUtil.Util;var error=sharedUtil.error;var info=sharedUtil.info;var isInt=sharedUtil.isInt;var isArray=sharedUtil.isArray;var createObjectURL=sharedUtil.createObjectURL;var shadow=sharedUtil.shadow;var warn=sharedUtil.warn;var isSpace=sharedUtil.isSpace;var Dict=corePrimitives.Dict;var isDict=corePrimitives.isDict;var Jbig2Image=coreJbig2.Jbig2Image;var JpegImage=coreJpg.JpegImage;var JpxImage=coreJpx.JpxImage;var Stream=function StreamClosure(){function Stream(arrayBuffer,start,length,dict){this.bytes=arrayBuffer instanceof Uint8Array?arrayBuffer:new Uint8Array(arrayBuffer);this.start=start||0;this.pos=this.start;this.end=start+length||this.bytes.length;this.dict=dict}Stream.prototype={get length(){return this.end-this.start},get isEmpty(){return this.length===0},getByte:function Stream_getByte(){if(this.pos>=this.end){return-1}return this.bytes[this.pos++]},getUint16:function Stream_getUint16(){var b0=this.getByte();var b1=this.getByte();if(b0===-1||b1===-1){return-1}return(b0<<8)+b1},getInt32:function Stream_getInt32(){var b0=this.getByte();var b1=this.getByte();var b2=this.getByte();var b3=this.getByte();return(b0<<24)+(b1<<16)+(b2<<8)+b3},getBytes:function Stream_getBytes(length){var bytes=this.bytes;var pos=this.pos;var strEnd=this.end;if(!length){return bytes.subarray(pos,strEnd)}var end=pos+length;if(end>strEnd){end=strEnd}this.pos=end;return bytes.subarray(pos,end)},peekByte:function Stream_peekByte(){var peekedByte=this.getByte();this.pos--;return peekedByte},peekBytes:function Stream_peekBytes(length){var bytes=this.getBytes(length);this.pos-=bytes.length;return bytes},skip:function Stream_skip(n){if(!n){n=1}this.pos+=n},reset:function Stream_reset(){this.pos=this.start},moveStart:function Stream_moveStart(){this.start=this.pos},makeSubStream:function Stream_makeSubStream(start,length,dict){return new Stream(this.bytes.buffer,start,length,dict)},isStream:true};return Stream}();var StringStream=function StringStreamClosure(){function StringStream(str){var length=str.length;var bytes=new Uint8Array(length);for(var n=0;n<length;++n){bytes[n]=str.charCodeAt(n)}Stream.call(this,bytes)}StringStream.prototype=Stream.prototype;return StringStream}();var DecodeStream=function DecodeStreamClosure(){var emptyBuffer=new Uint8Array(0);function DecodeStream(maybeMinBufferLength){this.pos=0;this.bufferLength=0;this.eof=false;this.buffer=emptyBuffer;this.minBufferLength=512;if(maybeMinBufferLength){while(this.minBufferLength<maybeMinBufferLength){this.minBufferLength*=2}}}DecodeStream.prototype={get isEmpty(){while(!this.eof&&this.bufferLength===0){this.readBlock()}return this.bufferLength===0},ensureBuffer:function DecodeStream_ensureBuffer(requested){var buffer=this.buffer;if(requested<=buffer.byteLength){return buffer}var size=this.minBufferLength;while(size<requested){size*=2}var buffer2=new Uint8Array(size);buffer2.set(buffer);return this.buffer=buffer2},getByte:function DecodeStream_getByte(){var pos=this.pos;while(this.bufferLength<=pos){if(this.eof){return-1}this.readBlock()}return this.buffer[this.pos++]},getUint16:function DecodeStream_getUint16(){var b0=this.getByte();var b1=this.getByte();if(b0===-1||b1===-1){return-1}return(b0<<8)+b1},getInt32:function DecodeStream_getInt32(){var b0=this.getByte();var b1=this.getByte();var b2=this.getByte();var b3=this.getByte();return(b0<<24)+(b1<<16)+(b2<<8)+b3},getBytes:function DecodeStream_getBytes(length){var end,pos=this.pos;if(length){this.ensureBuffer(pos+length);end=pos+length;while(!this.eof&&this.bufferLength<end){this.readBlock()}var bufEnd=this.bufferLength;if(end>bufEnd){end=bufEnd}}else{while(!this.eof){this.readBlock()}end=this.bufferLength}this.pos=end;return this.buffer.subarray(pos,end)},peekByte:function DecodeStream_peekByte(){var peekedByte=this.getByte();this.pos--;return peekedByte},peekBytes:function DecodeStream_peekBytes(length){var bytes=this.getBytes(length);this.pos-=bytes.length;return bytes},makeSubStream:function DecodeStream_makeSubStream(start,length,dict){var end=start+length;while(this.bufferLength<=end&&!this.eof){this.readBlock()}return new Stream(this.buffer,start,length,dict)},skip:function DecodeStream_skip(n){if(!n){n=1}this.pos+=n},reset:function DecodeStream_reset(){this.pos=0},getBaseStreams:function DecodeStream_getBaseStreams(){if(this.str&&this.str.getBaseStreams){return this.str.getBaseStreams()}return[]}};return DecodeStream}();var StreamsSequenceStream=function StreamsSequenceStreamClosure(){function StreamsSequenceStream(streams){this.streams=streams;DecodeStream.call(this,null)}StreamsSequenceStream.prototype=Object.create(DecodeStream.prototype);StreamsSequenceStream.prototype.readBlock=function streamSequenceStreamReadBlock(){var streams=this.streams;if(streams.length===0){this.eof=true;return}var stream=streams.shift();var chunk=stream.getBytes();var bufferLength=this.bufferLength;var newLength=bufferLength+chunk.length;var buffer=this.ensureBuffer(newLength);buffer.set(chunk,bufferLength);this.bufferLength=newLength};StreamsSequenceStream.prototype.getBaseStreams=function StreamsSequenceStream_getBaseStreams(){var baseStreams=[];for(var i=0,ii=this.streams.length;i<ii;i++){var stream=this.streams[i];if(stream.getBaseStreams){Util.appendToArray(baseStreams,stream.getBaseStreams())}}return baseStreams};return StreamsSequenceStream}();var FlateStream=function FlateStreamClosure(){var codeLenCodeMap=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);var lengthDecode=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]);var distDecode=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]);var fixedLitCodeTab=[new Int32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9];var fixedDistCodeTab=[new Int32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function FlateStream(str,maybeLength){this.str=str;this.dict=str.dict;var cmf=str.getByte();var flg=str.getByte();if(cmf===-1||flg===-1){error("Invalid header in flate stream: "+cmf+", "+flg)}if((cmf&15)!==8){error("Unknown compression method in flate stream: "+cmf+", "+flg)}if(((cmf<<8)+flg)%31!==0){error("Bad FCHECK in flate stream: "+cmf+", "+flg)}if(flg&32){error("FDICT bit set in flate stream: "+cmf+", "+flg)}this.codeSize=0;this.codeBuf=0;DecodeStream.call(this,maybeLength)}FlateStream.prototype=Object.create(DecodeStream.prototype);FlateStream.prototype.getBits=function FlateStream_getBits(bits){var str=this.str;var codeSize=this.codeSize;var codeBuf=this.codeBuf;var b;while(codeSize<bits){if((b=str.getByte())===-1){error("Bad encoding in flate stream")}codeBuf|=b<<codeSize;codeSize+=8}b=codeBuf&(1<<bits)-1;this.codeBuf=codeBuf>>bits;this.codeSize=codeSize-=bits;return b};FlateStream.prototype.getCode=function FlateStream_getCode(table){var str=this.str;var codes=table[0];var maxLen=table[1];var codeSize=this.codeSize;var codeBuf=this.codeBuf;var b;while(codeSize<maxLen){if((b=str.getByte())===-1){break}codeBuf|=b<<codeSize;codeSize+=8}var code=codes[codeBuf&(1<<maxLen)-1];var codeLen=code>>16;var codeVal=code&65535;if(codeLen<1||codeSize<codeLen){error("Bad encoding in flate stream")}this.codeBuf=codeBuf>>codeLen;this.codeSize=codeSize-codeLen;return codeVal};FlateStream.prototype.generateHuffmanTable=function flateStreamGenerateHuffmanTable(lengths){var n=lengths.length;var maxLen=0;var i;for(i=0;i<n;++i){if(lengths[i]>maxLen){maxLen=lengths[i]}}var size=1<<maxLen;var codes=new Int32Array(size);for(var len=1,code=0,skip=2;len<=maxLen;++len,code<<=1,skip<<=1){for(var val=0;val<n;++val){if(lengths[val]===len){var code2=0;var t=code;for(i=0;i<len;++i){code2=code2<<1|t&1;t>>=1}for(i=code2;i<size;i+=skip){codes[i]=len<<16|val}++code}}}return[codes,maxLen]};FlateStream.prototype.readBlock=function FlateStream_readBlock(){var buffer,len;var str=this.str;var hdr=this.getBits(3);if(hdr&1){this.eof=true}hdr>>=1;if(hdr===0){var b;if((b=str.getByte())===-1){error("Bad block header in flate stream")}var blockLen=b;if((b=str.getByte())===-1){error("Bad block header in flate stream")}blockLen|=b<<8;if((b=str.getByte())===-1){error("Bad block header in flate stream")}var check=b;if((b=str.getByte())===-1){error("Bad block header in flate stream")}check|=b<<8;if(check!==(~blockLen&65535)&&(blockLen!==0||check!==0)){error("Bad uncompressed block length in flate stream")}this.codeBuf=0;this.codeSize=0;var bufferLength=this.bufferLength;buffer=this.ensureBuffer(bufferLength+blockLen);var end=bufferLength+blockLen;this.bufferLength=end;if(blockLen===0){if(str.peekByte()===-1){this.eof=true}}else{for(var n=bufferLength;n<end;++n){if((b=str.getByte())===-1){this.eof=true;break}buffer[n]=b}}return}var litCodeTable;var distCodeTable;if(hdr===1){litCodeTable=fixedLitCodeTab;distCodeTable=fixedDistCodeTab}else if(hdr===2){var numLitCodes=this.getBits(5)+257;var numDistCodes=this.getBits(5)+1;var numCodeLenCodes=this.getBits(4)+4;var codeLenCodeLengths=new Uint8Array(codeLenCodeMap.length);var i;for(i=0;i<numCodeLenCodes;++i){codeLenCodeLengths[codeLenCodeMap[i]]=this.getBits(3)}var codeLenCodeTab=this.generateHuffmanTable(codeLenCodeLengths);len=0;i=0;var codes=numLitCodes+numDistCodes;var codeLengths=new Uint8Array(codes);var bitsLength,bitsOffset,what;while(i<codes){var code=this.getCode(codeLenCodeTab);if(code===16){bitsLength=2;bitsOffset=3;what=len}else if(code===17){bitsLength=3;bitsOffset=3;what=len=0}else if(code===18){bitsLength=7;bitsOffset=11;what=len=0}else{codeLengths[i++]=len=code;continue}var repeatLength=this.getBits(bitsLength)+bitsOffset;while(repeatLength-->0){codeLengths[i++]=what}}litCodeTable=this.generateHuffmanTable(codeLengths.subarray(0,numLitCodes));distCodeTable=this.generateHuffmanTable(codeLengths.subarray(numLitCodes,codes))}else{error("Unknown block type in flate stream")}buffer=this.buffer;var limit=buffer?buffer.length:0;var pos=this.bufferLength;while(true){var code1=this.getCode(litCodeTable);if(code1<256){if(pos+1>=limit){buffer=this.ensureBuffer(pos+1);limit=buffer.length}buffer[pos++]=code1;continue}if(code1===256){this.bufferLength=pos;return}code1-=257;code1=lengthDecode[code1];var code2=code1>>16;if(code2>0){code2=this.getBits(code2)}len=(code1&65535)+code2;code1=this.getCode(distCodeTable);code1=distDecode[code1];code2=code1>>16;if(code2>0){code2=this.getBits(code2)}var dist=(code1&65535)+code2;if(pos+len>=limit){buffer=this.ensureBuffer(pos+len);limit=buffer.length}for(var k=0;k<len;++k,++pos){buffer[pos]=buffer[pos-dist]}}};return FlateStream}();var PredictorStream=function PredictorStreamClosure(){function PredictorStream(str,maybeLength,params){if(!isDict(params)){return str}var predictor=this.predictor=params.get("Predictor")||1;if(predictor<=1){return str
14}if(predictor!==2&&(predictor<10||predictor>15)){error("Unsupported predictor: "+predictor)}if(predictor===2){this.readBlock=this.readBlockTiff}else{this.readBlock=this.readBlockPng}this.str=str;this.dict=str.dict;var colors=this.colors=params.get("Colors")||1;var bits=this.bits=params.get("BitsPerComponent")||8;var columns=this.columns=params.get("Columns")||1;this.pixBytes=colors*bits+7>>3;this.rowBytes=columns*colors*bits+7>>3;DecodeStream.call(this,maybeLength);return this}PredictorStream.prototype=Object.create(DecodeStream.prototype);PredictorStream.prototype.readBlockTiff=function predictorStreamReadBlockTiff(){var rowBytes=this.rowBytes;var bufferLength=this.bufferLength;var buffer=this.ensureBuffer(bufferLength+rowBytes);var bits=this.bits;var colors=this.colors;var rawBytes=this.str.getBytes(rowBytes);this.eof=!rawBytes.length;if(this.eof){return}var inbuf=0,outbuf=0;var inbits=0,outbits=0;var pos=bufferLength;var i;if(bits===1){for(i=0;i<rowBytes;++i){var c=rawBytes[i];inbuf=inbuf<<8|c;buffer[pos++]=(c^inbuf>>colors)&255;inbuf&=65535}}else if(bits===8){for(i=0;i<colors;++i){buffer[pos++]=rawBytes[i]}for(;i<rowBytes;++i){buffer[pos]=buffer[pos-colors]+rawBytes[i];pos++}}else{var compArray=new Uint8Array(colors+1);var bitMask=(1<<bits)-1;var j=0,k=bufferLength;var columns=this.columns;for(i=0;i<columns;++i){for(var kk=0;kk<colors;++kk){if(inbits<bits){inbuf=inbuf<<8|rawBytes[j++]&255;inbits+=8}compArray[kk]=compArray[kk]+(inbuf>>inbits-bits)&bitMask;inbits-=bits;outbuf=outbuf<<bits|compArray[kk];outbits+=bits;if(outbits>=8){buffer[k++]=outbuf>>outbits-8&255;outbits-=8}}}if(outbits>0){buffer[k++]=(outbuf<<8-outbits)+(inbuf&(1<<8-outbits)-1)}}this.bufferLength+=rowBytes};PredictorStream.prototype.readBlockPng=function predictorStreamReadBlockPng(){var rowBytes=this.rowBytes;var pixBytes=this.pixBytes;var predictor=this.str.getByte();var rawBytes=this.str.getBytes(rowBytes);this.eof=!rawBytes.length;if(this.eof){return}var bufferLength=this.bufferLength;var buffer=this.ensureBuffer(bufferLength+rowBytes);var prevRow=buffer.subarray(bufferLength-rowBytes,bufferLength);if(prevRow.length===0){prevRow=new Uint8Array(rowBytes)}var i,j=bufferLength,up,c;switch(predictor){case 0:for(i=0;i<rowBytes;++i){buffer[j++]=rawBytes[i]}break;case 1:for(i=0;i<pixBytes;++i){buffer[j++]=rawBytes[i]}for(;i<rowBytes;++i){buffer[j]=buffer[j-pixBytes]+rawBytes[i]&255;j++}break;case 2:for(i=0;i<rowBytes;++i){buffer[j++]=prevRow[i]+rawBytes[i]&255}break;case 3:for(i=0;i<pixBytes;++i){buffer[j++]=(prevRow[i]>>1)+rawBytes[i]}for(;i<rowBytes;++i){buffer[j]=(prevRow[i]+buffer[j-pixBytes]>>1)+rawBytes[i]&255;j++}break;case 4:for(i=0;i<pixBytes;++i){up=prevRow[i];c=rawBytes[i];buffer[j++]=up+c}for(;i<rowBytes;++i){up=prevRow[i];var upLeft=prevRow[i-pixBytes];var left=buffer[j-pixBytes];var p=left+up-upLeft;var pa=p-left;if(pa<0){pa=-pa}var pb=p-up;if(pb<0){pb=-pb}var pc=p-upLeft;if(pc<0){pc=-pc}c=rawBytes[i];if(pa<=pb&&pa<=pc){buffer[j++]=left+c}else if(pb<=pc){buffer[j++]=up+c}else{buffer[j++]=upLeft+c}}break;default:error("Unsupported predictor: "+predictor)}this.bufferLength+=rowBytes};return PredictorStream}();var JpegStream=function JpegStreamClosure(){function JpegStream(stream,maybeLength,dict){var ch;while((ch=stream.getByte())!==-1){if(ch===255){stream.skip(-1);break}}this.stream=stream;this.maybeLength=maybeLength;this.dict=dict;DecodeStream.call(this,maybeLength)}JpegStream.prototype=Object.create(DecodeStream.prototype);Object.defineProperty(JpegStream.prototype,"bytes",{get:function JpegStream_bytes(){return shadow(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:true});JpegStream.prototype.ensureBuffer=function JpegStream_ensureBuffer(req){if(this.bufferLength){return}var jpegImage=new JpegImage;var decodeArr=this.dict.getArray("Decode","D");if(this.forceRGB&&isArray(decodeArr)){var bitsPerComponent=this.dict.get("BitsPerComponent")||8;var decodeArrLength=decodeArr.length;var transform=new Int32Array(decodeArrLength);var transformNeeded=false;var maxValue=(1<<bitsPerComponent)-1;for(var i=0;i<decodeArrLength;i+=2){transform[i]=(decodeArr[i+1]-decodeArr[i])*256|0;transform[i+1]=decodeArr[i]*maxValue|0;if(transform[i]!==256||transform[i+1]!==0){transformNeeded=true}}if(transformNeeded){jpegImage.decodeTransform=transform}}var decodeParams=this.dict.get("DecodeParms","DP");if(isDict(decodeParams)){var colorTransform=decodeParams.get("ColorTransform");if(isInt(colorTransform)){jpegImage.colorTransform=colorTransform}}jpegImage.parse(this.bytes);var data=jpegImage.getData(this.drawWidth,this.drawHeight,this.forceRGB);this.buffer=data;this.bufferLength=data.length;this.eof=true};JpegStream.prototype.getBytes=function JpegStream_getBytes(length){this.ensureBuffer();return this.buffer};JpegStream.prototype.getIR=function JpegStream_getIR(forceDataSchema){return createObjectURL(this.bytes,"image/jpeg",forceDataSchema)};return JpegStream}();var JpxStream=function JpxStreamClosure(){function JpxStream(stream,maybeLength,dict){this.stream=stream;this.maybeLength=maybeLength;this.dict=dict;DecodeStream.call(this,maybeLength)}JpxStream.prototype=Object.create(DecodeStream.prototype);Object.defineProperty(JpxStream.prototype,"bytes",{get:function JpxStream_bytes(){return shadow(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:true});JpxStream.prototype.ensureBuffer=function JpxStream_ensureBuffer(req){if(this.bufferLength){return}var jpxImage=new JpxImage;jpxImage.parse(this.bytes);var width=jpxImage.width;var height=jpxImage.height;var componentsCount=jpxImage.componentsCount;var tileCount=jpxImage.tiles.length;if(tileCount===1){this.buffer=jpxImage.tiles[0].items}else{var data=new Uint8Array(width*height*componentsCount);for(var k=0;k<tileCount;k++){var tileComponents=jpxImage.tiles[k];var tileWidth=tileComponents.width;var tileHeight=tileComponents.height;var tileLeft=tileComponents.left;var tileTop=tileComponents.top;var src=tileComponents.items;var srcPosition=0;var dataPosition=(width*tileTop+tileLeft)*componentsCount;var imgRowSize=width*componentsCount;var tileRowSize=tileWidth*componentsCount;for(var j=0;j<tileHeight;j++){var rowBytes=src.subarray(srcPosition,srcPosition+tileRowSize);data.set(rowBytes,dataPosition);srcPosition+=tileRowSize;dataPosition+=imgRowSize}}this.buffer=data}this.bufferLength=this.buffer.length;this.eof=true};return JpxStream}();var Jbig2Stream=function Jbig2StreamClosure(){function Jbig2Stream(stream,maybeLength,dict){this.stream=stream;this.maybeLength=maybeLength;this.dict=dict;DecodeStream.call(this,maybeLength)}Jbig2Stream.prototype=Object.create(DecodeStream.prototype);Object.defineProperty(Jbig2Stream.prototype,"bytes",{get:function Jbig2Stream_bytes(){return shadow(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:true});Jbig2Stream.prototype.ensureBuffer=function Jbig2Stream_ensureBuffer(req){if(this.bufferLength){return}var jbig2Image=new Jbig2Image;var chunks=[];var decodeParams=this.dict.getArray("DecodeParms","DP");if(isArray(decodeParams)){if(decodeParams.length>1){warn("JBIG2 - 'DecodeParms' array with multiple elements "+"not supported.")}decodeParams=decodeParams[0]}if(decodeParams&&decodeParams.has("JBIG2Globals")){var globalsStream=decodeParams.get("JBIG2Globals");var globals=globalsStream.getBytes();chunks.push({data:globals,start:0,end:globals.length})}chunks.push({data:this.bytes,start:0,end:this.bytes.length});var data=jbig2Image.parseChunks(chunks);var dataLength=data.length;for(var i=0;i<dataLength;i++){data[i]^=255}this.buffer=data;this.bufferLength=dataLength;this.eof=true};return Jbig2Stream}();var DecryptStream=function DecryptStreamClosure(){function DecryptStream(str,maybeLength,decrypt){this.str=str;this.dict=str.dict;this.decrypt=decrypt;this.nextChunk=null;this.initialized=false;DecodeStream.call(this,maybeLength)}var chunkSize=512;DecryptStream.prototype=Object.create(DecodeStream.prototype);DecryptStream.prototype.readBlock=function DecryptStream_readBlock(){var chunk;if(this.initialized){chunk=this.nextChunk}else{chunk=this.str.getBytes(chunkSize);this.initialized=true}if(!chunk||chunk.length===0){this.eof=true;return}this.nextChunk=this.str.getBytes(chunkSize);var hasMoreData=this.nextChunk&&this.nextChunk.length>0;var decrypt=this.decrypt;chunk=decrypt(chunk,!hasMoreData);var bufferLength=this.bufferLength;var i,n=chunk.length;var buffer=this.ensureBuffer(bufferLength+n);for(i=0;i<n;i++){buffer[bufferLength++]=chunk[i]}this.bufferLength=bufferLength};return DecryptStream}();var Ascii85Stream=function Ascii85StreamClosure(){function Ascii85Stream(str,maybeLength){this.str=str;this.dict=str.dict;this.input=new Uint8Array(5);if(maybeLength){maybeLength=.8*maybeLength}DecodeStream.call(this,maybeLength)}Ascii85Stream.prototype=Object.create(DecodeStream.prototype);Ascii85Stream.prototype.readBlock=function Ascii85Stream_readBlock(){var TILDA_CHAR=126;var Z_LOWER_CHAR=122;var EOF=-1;var str=this.str;var c=str.getByte();while(isSpace(c)){c=str.getByte()}if(c===EOF||c===TILDA_CHAR){this.eof=true;return}var bufferLength=this.bufferLength,buffer;var i;if(c===Z_LOWER_CHAR){buffer=this.ensureBuffer(bufferLength+4);for(i=0;i<4;++i){buffer[bufferLength+i]=0}this.bufferLength+=4}else{var input=this.input;input[0]=c;for(i=1;i<5;++i){c=str.getByte();while(isSpace(c)){c=str.getByte()}input[i]=c;if(c===EOF||c===TILDA_CHAR){break}}buffer=this.ensureBuffer(bufferLength+i-1);this.bufferLength+=i-1;if(i<5){for(;i<5;++i){input[i]=33+84}this.eof=true}var t=0;for(i=0;i<5;++i){t=t*85+(input[i]-33)}for(i=3;i>=0;--i){buffer[bufferLength+i]=t&255;t>>=8}}};return Ascii85Stream}();var AsciiHexStream=function AsciiHexStreamClosure(){function AsciiHexStream(str,maybeLength){this.str=str;this.dict=str.dict;this.firstDigit=-1;if(maybeLength){maybeLength=.5*maybeLength}DecodeStream.call(this,maybeLength)}AsciiHexStream.prototype=Object.create(DecodeStream.prototype);AsciiHexStream.prototype.readBlock=function AsciiHexStream_readBlock(){var UPSTREAM_BLOCK_SIZE=8e3;var bytes=this.str.getBytes(UPSTREAM_BLOCK_SIZE);if(!bytes.length){this.eof=true;return}var maxDecodeLength=bytes.length+1>>1;var buffer=this.ensureBuffer(this.bufferLength+maxDecodeLength);var bufferLength=this.bufferLength;var firstDigit=this.firstDigit;for(var i=0,ii=bytes.length;i<ii;i++){var ch=bytes[i],digit;if(ch>=48&&ch<=57){digit=ch&15}else if(ch>=65&&ch<=70||ch>=97&&ch<=102){digit=(ch&15)+9}else if(ch===62){this.eof=true;break}else{continue}if(firstDigit<0){firstDigit=digit}else{buffer[bufferLength++]=firstDigit<<4|digit;firstDigit=-1}}if(firstDigit>=0&&this.eof){buffer[bufferLength++]=firstDigit<<4;firstDigit=-1}this.firstDigit=firstDigit;this.bufferLength=bufferLength};return AsciiHexStream}();var RunLengthStream=function RunLengthStreamClosure(){function RunLengthStream(str,maybeLength){this.str=str;this.dict=str.dict;DecodeStream.call(this,maybeLength)}RunLengthStream.prototype=Object.create(DecodeStream.prototype);RunLengthStream.prototype.readBlock=function RunLengthStream_readBlock(){var repeatHeader=this.str.getBytes(2);if(!repeatHeader||repeatHeader.length<2||repeatHeader[0]===128){this.eof=true;return}var buffer;var bufferLength=this.bufferLength;var n=repeatHeader[0];if(n<128){buffer=this.ensureBuffer(bufferLength+n+1);buffer[bufferLength++]=repeatHeader[1];if(n>0){var source=this.str.getBytes(n);buffer.set(source,bufferLength);bufferLength+=n}}else{n=257-n;var b=repeatHeader[1];buffer=this.ensureBuffer(bufferLength+n+1);for(var i=0;i<n;i++){buffer[bufferLength++]=b}}this.bufferLength=bufferLength};return RunLengthStream}();var CCITTFaxStream=function CCITTFaxStreamClosure(){var ccittEOL=-2;var ccittEOF=-1;var twoDimPass=0;var twoDimHoriz=1;var twoDimVert0=2;var twoDimVertR1=3;var twoDimVertL1=4;var twoDimVertR2=5;var twoDimVertL2=6;var twoDimVertR3=7;var twoDimVertL3=8;var twoDimTable=[[-1,-1],[-1,-1],[7,twoDimVertL3],[7,twoDimVertR3],[6,twoDimVertL2],[6,twoDimVertL2],[6,twoDimVertR2],[6,twoDimVertR2],[4,twoDimPass],[4,twoDimPass],[4,twoDimPass],[4,twoDimPass],[4,twoDimPass],[4,twoDimPass],[4,twoDimPass],[4,twoDimPass],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimHoriz],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertL1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[3,twoDimVertR1],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0],[1,twoDimVert0]];var whiteTable1=[[-1,-1],[12,ccittEOL],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]];var whiteTable2=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]];var blackTable1=[[-1,-1],[-1,-1],[12,ccittEOL],[12,ccittEOL],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]];var blackTable2=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]];var blackTable3=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];function CCITTFaxStream(str,maybeLength,params){this.str=str;this.dict=str.dict;params=params||Dict.empty;this.encoding=params.get("K")||0;this.eoline=params.get("EndOfLine")||false;this.byteAlign=params.get("EncodedByteAlign")||false;this.columns=params.get("Columns")||1728;this.rows=params.get("Rows")||0;var eoblock=params.get("EndOfBlock");if(eoblock===null||eoblock===undefined){eoblock=true}this.eoblock=eoblock;this.black=params.get("BlackIs1")||false;this.codingLine=new Uint32Array(this.columns+1);this.refLine=new Uint32Array(this.columns+2);this.codingLine[0]=this.columns;this.codingPos=0;this.row=0;this.nextLine2D=this.encoding<0;this.inputBits=0;this.inputBuf=0;this.outputBits=0;var code1;while((code1=this.lookBits(12))===0){this.eatBits(1)}if(code1===1){this.eatBits(12)}if(this.encoding>0){this.nextLine2D=!this.lookBits(1);this.eatBits(1)}DecodeStream.call(this,maybeLength)}CCITTFaxStream.prototype=Object.create(DecodeStream.prototype);CCITTFaxStream.prototype.readBlock=function CCITTFaxStream_readBlock(){while(!this.eof){var c=this.lookChar();this.ensureBuffer(this.bufferLength+1);this.buffer[this.bufferLength++]=c}};CCITTFaxStream.prototype.addPixels=function ccittFaxStreamAddPixels(a1,blackPixels){var codingLine=this.codingLine;var codingPos=this.codingPos;if(a1>codingLine[codingPos]){if(a1>this.columns){info("row is wrong length");this.err=true;a1=this.columns}if(codingPos&1^blackPixels){++codingPos}codingLine[codingPos]=a1}this.codingPos=codingPos};CCITTFaxStream.prototype.addPixelsNeg=function ccittFaxStreamAddPixelsNeg(a1,blackPixels){var codingLine=this.codingLine;var codingPos=this.codingPos;if(a1>codingLine[codingPos]){if(a1>this.columns){info("row is wrong length");this.err=true;a1=this.columns}if(codingPos&1^blackPixels){++codingPos}codingLine[codingPos]=a1}else if(a1<codingLine[codingPos]){if(a1<0){info("invalid code");this.err=true;a1=0}while(codingPos>0&&a1<codingLine[codingPos-1]){--codingPos}codingLine[codingPos]=a1}this.codingPos=codingPos};CCITTFaxStream.prototype.lookChar=function CCITTFaxStream_lookChar(){var refLine=this.refLine;var codingLine=this.codingLine;var columns=this.columns;var refPos,blackPixels,bits,i;if(this.outputBits===0){if(this.eof){return null}this.err=false;var code1,code2,code3;if(this.nextLine2D){for(i=0;codingLine[i]<columns;++i){refLine[i]=codingLine[i]}refLine[i++]=columns;refLine[i]=columns;codingLine[0]=0;this.codingPos=0;refPos=0;blackPixels=0;while(codingLine[this.codingPos]<columns){code1=this.getTwoDimCode();switch(code1){case twoDimPass:this.addPixels(refLine[refPos+1],blackPixels);if(refLine[refPos+1]<columns){refPos+=2}break;case twoDimHoriz:code1=code2=0;if(blackPixels){do{code1+=code3=this.getBlackCode()}while(code3>=64);do{code2+=code3=this.getWhiteCode()}while(code3>=64)}else{do{code1+=code3=this.getWhiteCode()}while(code3>=64);do{code2+=code3=this.getBlackCode()}while(code3>=64)}this.addPixels(codingLine[this.codingPos]+code1,blackPixels);if(codingLine[this.codingPos]<columns){this.addPixels(codingLine[this.codingPos]+code2,blackPixels^1)}while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}break;case twoDimVertR3:this.addPixels(refLine[refPos]+3,blackPixels);blackPixels^=1;if(codingLine[this.codingPos]<columns){++refPos;while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}}break;case twoDimVertR2:this.addPixels(refLine[refPos]+2,blackPixels);blackPixels^=1;if(codingLine[this.codingPos]<columns){++refPos;while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}}break;case twoDimVertR1:this.addPixels(refLine[refPos]+1,blackPixels);blackPixels^=1;if(codingLine[this.codingPos]<columns){++refPos;while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}}break;case twoDimVert0:this.addPixels(refLine[refPos],blackPixels);blackPixels^=1;if(codingLine[this.codingPos]<columns){++refPos;while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}}break;case twoDimVertL3:this.addPixelsNeg(refLine[refPos]-3,blackPixels);blackPixels^=1;if(codingLine[this.codingPos]<columns){if(refPos>0){--refPos}else{++refPos}while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}}break;case twoDimVertL2:this.addPixelsNeg(refLine[refPos]-2,blackPixels);blackPixels^=1;if(codingLine[this.codingPos]<columns){if(refPos>0){--refPos}else{++refPos}while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}}break;case twoDimVertL1:this.addPixelsNeg(refLine[refPos]-1,blackPixels);blackPixels^=1;if(codingLine[this.codingPos]<columns){if(refPos>0){--refPos}else{++refPos}while(refLine[refPos]<=codingLine[this.codingPos]&&refLine[refPos]<columns){refPos+=2}}break;case ccittEOF:this.addPixels(columns,0);this.eof=true;break;default:info("bad 2d code");this.addPixels(columns,0);this.err=true}}}else{codingLine[0]=0;this.codingPos=0;blackPixels=0;while(codingLine[this.codingPos]<columns){code1=0;if(blackPixels){do{code1+=code3=this.getBlackCode()}while(code3>=64)}else{do{code1+=code3=this.getWhiteCode()}while(code3>=64)}this.addPixels(codingLine[this.codingPos]+code1,blackPixels);blackPixels^=1}}var gotEOL=false;if(this.byteAlign){this.inputBits&=~7}if(!this.eoblock&&this.row===this.rows-1){this.eof=true}else{code1=this.lookBits(12);if(this.eoline){while(code1!==ccittEOF&&code1!==1){this.eatBits(1);code1=this.lookBits(12)}}else{while(code1===0){this.eatBits(1);code1=this.lookBits(12)}}if(code1===1){this.eatBits(12);gotEOL=true}else if(code1===ccittEOF){this.eof=true}}if(!this.eof&&this.encoding>0){this.nextLine2D=!this.lookBits(1);this.eatBits(1)}if(this.eoblock&&gotEOL&&this.byteAlign){code1=this.lookBits(12);if(code1===1){this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}if(this.encoding>=0){for(i=0;i<4;++i){code1=this.lookBits(12);if(code1!==1){info("bad rtc code: "+code1)}this.eatBits(12);if(this.encoding>0){this.lookBits(1);this.eatBits(1)}}}this.eof=true}}else if(this.err&&this.eoline){while(true){code1=this.lookBits(13);if(code1===ccittEOF){this.eof=true;return null}if(code1>>1===1){break}this.eatBits(1)}this.eatBits(12);if(this.encoding>0){this.eatBits(1);this.nextLine2D=!(code1&1)}}if(codingLine[0]>0){this.outputBits=codingLine[this.codingPos=0]}else{this.outputBits=codingLine[this.codingPos=1]}this.row++}var c;if(this.outputBits>=8){c=this.codingPos&1?0:255;this.outputBits-=8;if(this.outputBits===0&&codingLine[this.codingPos]<columns){this.codingPos++;this.outputBits=codingLine[this.codingPos]-codingLine[this.codingPos-1]}}else{bits=8;c=0;do{if(this.outputBits>bits){c<<=bits;if(!(this.codingPos&1)){c|=255>>8-bits}this.outputBits-=bits;bits=0}else{c<<=this.outputBits;if(!(this.codingPos&1)){c|=255>>8-this.outputBits}bits-=this.outputBits;this.outputBits=0;if(codingLine[this.codingPos]<columns){this.codingPos++;this.outputBits=codingLine[this.codingPos]-codingLine[this.codingPos-1]}else if(bits>0){c<<=bits;bits=0}}}while(bits)}if(this.black){c^=255}return c};CCITTFaxStream.prototype.findTableCode=function ccittFaxStreamFindTableCode(start,end,table,limit){var limitValue=limit||0;for(var i=start;i<=end;++i){var code=this.lookBits(i);if(code===ccittEOF){return[true,1,false]}if(i<end){code<<=end-i}if(!limitValue||code>=limitValue){var p=table[code-limitValue];if(p[0]===i){this.eatBits(i);return[true,p[1],true]}}}return[false,0,false]};CCITTFaxStream.prototype.getTwoDimCode=function ccittFaxStreamGetTwoDimCode(){var code=0;var p;if(this.eoblock){code=this.lookBits(7);p=twoDimTable[code];if(p&&p[0]>0){this.eatBits(p[0]);return p[1]}}else{var result=this.findTableCode(1,7,twoDimTable);if(result[0]&&result[2]){return result[1]}}info("Bad two dim code");return ccittEOF};CCITTFaxStream.prototype.getWhiteCode=function ccittFaxStreamGetWhiteCode(){var code=0;var p;if(this.eoblock){code=this.lookBits(12);if(code===ccittEOF){return 1}if(code>>5===0){p=whiteTable1[code]}else{p=whiteTable2[code>>3]}if(p[0]>0){this.eatBits(p[0]);return p[1]}}else{var result=this.findTableCode(1,9,whiteTable2);if(result[0]){return result[1]}result=this.findTableCode(11,12,whiteTable1);if(result[0]){return result[1]}}info("bad white code");this.eatBits(1);return 1};CCITTFaxStream.prototype.getBlackCode=function ccittFaxStreamGetBlackCode(){var code,p;if(this.eoblock){code=this.lookBits(13);if(code===ccittEOF){return 1}if(code>>7===0){p=blackTable1[code]}else if(code>>9===0&&code>>7!==0){p=blackTable2[(code>>1)-64]}else{p=blackTable3[code>>7]}if(p[0]>0){this.eatBits(p[0]);return p[1]}}else{var result=this.findTableCode(2,6,blackTable3);if(result[0]){return result[1]}result=this.findTableCode(7,12,blackTable2,64);if(result[0]){return result[1]}result=this.findTableCode(10,13,blackTable1);if(result[0]){return result[1]}}info("bad black code");this.eatBits(1);return 1};CCITTFaxStream.prototype.lookBits=function CCITTFaxStream_lookBits(n){var c;while(this.inputBits<n){if((c=this.str.getByte())===-1){if(this.inputBits===0){return ccittEOF}return this.inputBuf<<n-this.inputBits&65535>>16-n}this.inputBuf=this.inputBuf<<8|c;this.inputBits+=8}return this.inputBuf>>this.inputBits-n&65535>>16-n};CCITTFaxStream.prototype.eatBits=function CCITTFaxStream_eatBits(n){if((this.inputBits-=n)<0){this.inputBits=0}};return CCITTFaxStream}();var LZWStream=function LZWStreamClosure(){function LZWStream(str,maybeLength,earlyChange){this.str=str;this.dict=str.dict;this.cachedData=0;this.bitsCached=0;var maxLzwDictionarySize=4096;var lzwState={earlyChange:earlyChange,codeLength:9,nextCode:258,dictionaryValues:new Uint8Array(maxLzwDictionarySize),dictionaryLengths:new Uint16Array(maxLzwDictionarySize),dictionaryPrevCodes:new Uint16Array(maxLzwDictionarySize),currentSequence:new Uint8Array(maxLzwDictionarySize),currentSequenceLength:0};for(var i=0;i<256;++i){lzwState.dictionaryValues[i]=i;lzwState.dictionaryLengths[i]=1}this.lzwState=lzwState;DecodeStream.call(this,maybeLength)}LZWStream.prototype=Object.create(DecodeStream.prototype);LZWStream.prototype.readBits=function LZWStream_readBits(n){var bitsCached=this.bitsCached;var cachedData=this.cachedData;while(bitsCached<n){var c=this.str.getByte();if(c===-1){this.eof=true;return null}cachedData=cachedData<<8|c;bitsCached+=8}this.bitsCached=bitsCached-=n;this.cachedData=cachedData;this.lastCode=null;return cachedData>>>bitsCached&(1<<n)-1};LZWStream.prototype.readBlock=function LZWStream_readBlock(){var blockSize=512;var estimatedDecodedSize=blockSize*2,decodedSizeDelta=blockSize;var i,j,q;var lzwState=this.lzwState;if(!lzwState){return}var earlyChange=lzwState.earlyChange;var nextCode=lzwState.nextCode;var dictionaryValues=lzwState.dictionaryValues;var dictionaryLengths=lzwState.dictionaryLengths;var dictionaryPrevCodes=lzwState.dictionaryPrevCodes;var codeLength=lzwState.codeLength;var prevCode=lzwState.prevCode;var currentSequence=lzwState.currentSequence;var currentSequenceLength=lzwState.currentSequenceLength;var decodedLength=0;var currentBufferLength=this.bufferLength;var buffer=this.ensureBuffer(this.bufferLength+estimatedDecodedSize);for(i=0;i<blockSize;i++){var code=this.readBits(codeLength);var hasPrev=currentSequenceLength>0;if(code<256){currentSequence[0]=code;currentSequenceLength=1}else if(code>=258){if(code<nextCode){currentSequenceLength=dictionaryLengths[code];
15for(j=currentSequenceLength-1,q=code;j>=0;j--){currentSequence[j]=dictionaryValues[q];q=dictionaryPrevCodes[q]}}else{currentSequence[currentSequenceLength++]=currentSequence[0]}}else if(code===256){codeLength=9;nextCode=258;currentSequenceLength=0;continue}else{this.eof=true;delete this.lzwState;break}if(hasPrev){dictionaryPrevCodes[nextCode]=prevCode;dictionaryLengths[nextCode]=dictionaryLengths[prevCode]+1;dictionaryValues[nextCode]=currentSequence[0];nextCode++;codeLength=nextCode+earlyChange&nextCode+earlyChange-1?codeLength:Math.min(Math.log(nextCode+earlyChange)/.6931471805599453+1,12)|0}prevCode=code;decodedLength+=currentSequenceLength;if(estimatedDecodedSize<decodedLength){do{estimatedDecodedSize+=decodedSizeDelta}while(estimatedDecodedSize<decodedLength);buffer=this.ensureBuffer(this.bufferLength+estimatedDecodedSize)}for(j=0;j<currentSequenceLength;j++){buffer[currentBufferLength++]=currentSequence[j]}}lzwState.nextCode=nextCode;lzwState.codeLength=codeLength;lzwState.prevCode=prevCode;lzwState.currentSequenceLength=currentSequenceLength;this.bufferLength=currentBufferLength};return LZWStream}();var NullStream=function NullStreamClosure(){function NullStream(){Stream.call(this,new Uint8Array(0))}NullStream.prototype=Stream.prototype;return NullStream}();exports.Ascii85Stream=Ascii85Stream;exports.AsciiHexStream=AsciiHexStream;exports.CCITTFaxStream=CCITTFaxStream;exports.DecryptStream=DecryptStream;exports.DecodeStream=DecodeStream;exports.FlateStream=FlateStream;exports.Jbig2Stream=Jbig2Stream;exports.JpegStream=JpegStream;exports.JpxStream=JpxStream;exports.NullStream=NullStream;exports.PredictorStream=PredictorStream;exports.RunLengthStream=RunLengthStream;exports.Stream=Stream;exports.StreamsSequenceStream=StreamsSequenceStream;exports.StringStream=StringStream;exports.LZWStream=LZWStream});(function(root,factory){{factory(root.pdfjsCoreCrypto={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreStream)}})(this,function(exports,sharedUtil,corePrimitives,coreStream){var PasswordException=sharedUtil.PasswordException;var PasswordResponses=sharedUtil.PasswordResponses;var bytesToString=sharedUtil.bytesToString;var error=sharedUtil.error;var isInt=sharedUtil.isInt;var stringToBytes=sharedUtil.stringToBytes;var utf8StringToString=sharedUtil.utf8StringToString;var warn=sharedUtil.warn;var Name=corePrimitives.Name;var isName=corePrimitives.isName;var isDict=corePrimitives.isDict;var DecryptStream=coreStream.DecryptStream;var ARCFourCipher=function ARCFourCipherClosure(){function ARCFourCipher(key){this.a=0;this.b=0;var s=new Uint8Array(256);var i,j=0,tmp,keyLength=key.length;for(i=0;i<256;++i){s[i]=i}for(i=0;i<256;++i){tmp=s[i];j=j+tmp+key[i%keyLength]&255;s[i]=s[j];s[j]=tmp}this.s=s}ARCFourCipher.prototype={encryptBlock:function ARCFourCipher_encryptBlock(data){var i,n=data.length,tmp,tmp2;var a=this.a,b=this.b,s=this.s;var output=new Uint8Array(n);for(i=0;i<n;++i){a=a+1&255;tmp=s[a];b=b+tmp&255;tmp2=s[b];s[a]=tmp2;s[b]=tmp;output[i]=data[i]^s[tmp+tmp2&255]}this.a=a;this.b=b;return output}};ARCFourCipher.prototype.decryptBlock=ARCFourCipher.prototype.encryptBlock;return ARCFourCipher}();var calculateMD5=function calculateMD5Closure(){var 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]);var 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]);function hash(data,offset,length){var h0=1732584193,h1=-271733879,h2=-1732584194,h3=271733878;var paddedLength=length+72&~63;var padded=new Uint8Array(paddedLength);var i,j,n;for(i=0;i<length;++i){padded[i]=data[offset++]}padded[i++]=128;n=paddedLength-8;while(i<n){padded[i++]=0}padded[i++]=length<<3&255;padded[i++]=length>>5&255;padded[i++]=length>>13&255;padded[i++]=length>>21&255;padded[i++]=length>>>29&255;padded[i++]=0;padded[i++]=0;padded[i++]=0;var w=new Int32Array(16);for(i=0;i<paddedLength;){for(j=0;j<16;++j,i+=4){w[j]=padded[i]|padded[i+1]<<8|padded[i+2]<<16|padded[i+3]<<24}var a=h0,b=h1,c=h2,d=h3,f,g;for(j=0;j<64;++j){if(j<16){f=b&c|~b&d;g=j}else if(j<32){f=d&b|~d&c;g=5*j+1&15}else if(j<48){f=b^c^d;g=3*j+5&15}else{f=c^(b|~d);g=7*j&15}var tmp=d,rotateArg=a+f+k[j]+w[g]|0,rotate=r[j];d=c;c=b;b=b+(rotateArg<<rotate|rotateArg>>>32-rotate)|0;a=tmp}h0=h0+a|0;h1=h1+b|0;h2=h2+c|0;h3=h3+d|0}return new Uint8Array([h0&255,h0>>8&255,h0>>16&255,h0>>>24&255,h1&255,h1>>8&255,h1>>16&255,h1>>>24&255,h2&255,h2>>8&255,h2>>16&255,h2>>>24&255,h3&255,h3>>8&255,h3>>16&255,h3>>>24&255])}return hash}();var Word64=function Word64Closure(){function Word64(highInteger,lowInteger){this.high=highInteger|0;this.low=lowInteger|0}Word64.prototype={and:function Word64_and(word){this.high&=word.high;this.low&=word.low},xor:function Word64_xor(word){this.high^=word.high;this.low^=word.low},or:function Word64_or(word){this.high|=word.high;this.low|=word.low},shiftRight:function Word64_shiftRight(places){if(places>=32){this.low=this.high>>>places-32|0;this.high=0}else{this.low=this.low>>>places|this.high<<32-places;this.high=this.high>>>places|0}},shiftLeft:function Word64_shiftLeft(places){if(places>=32){this.high=this.low<<places-32;this.low=0}else{this.high=this.high<<places|this.low>>>32-places;this.low=this.low<<places}},rotateRight:function Word64_rotateRight(places){var low,high;if(places&32){high=this.low;low=this.high}else{low=this.low;high=this.high}places&=31;this.low=low>>>places|high<<32-places;this.high=high>>>places|low<<32-places},not:function Word64_not(){this.high=~this.high;this.low=~this.low},add:function Word64_add(word){var lowAdd=(this.low>>>0)+(word.low>>>0);var highAdd=(this.high>>>0)+(word.high>>>0);if(lowAdd>4294967295){highAdd+=1}this.low=lowAdd|0;this.high=highAdd|0},copyTo:function Word64_copyTo(bytes,offset){bytes[offset]=this.high>>>24&255;bytes[offset+1]=this.high>>16&255;bytes[offset+2]=this.high>>8&255;bytes[offset+3]=this.high&255;bytes[offset+4]=this.low>>>24&255;bytes[offset+5]=this.low>>16&255;bytes[offset+6]=this.low>>8&255;bytes[offset+7]=this.low&255},assign:function Word64_assign(word){this.high=word.high;this.low=word.low}};return Word64}();var calculateSHA256=function calculateSHA256Closure(){function rotr(x,n){return x>>>n|x<<32-n}function ch(x,y,z){return x&y^~x&z}function maj(x,y,z){return x&y^x&z^y&z}function sigma(x){return rotr(x,2)^rotr(x,13)^rotr(x,22)}function sigmaPrime(x){return rotr(x,6)^rotr(x,11)^rotr(x,25)}function littleSigma(x){return rotr(x,7)^rotr(x,18)^x>>>3}function littleSigmaPrime(x){return rotr(x,17)^rotr(x,19)^x>>>10}var k=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function hash(data,offset,length){var h0=1779033703,h1=3144134277,h2=1013904242,h3=2773480762,h4=1359893119,h5=2600822924,h6=528734635,h7=1541459225;var paddedLength=Math.ceil((length+9)/64)*64;var padded=new Uint8Array(paddedLength);var i,j,n;for(i=0;i<length;++i){padded[i]=data[offset++]}padded[i++]=128;n=paddedLength-8;while(i<n){padded[i++]=0}padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=length>>>29&255;padded[i++]=length>>21&255;padded[i++]=length>>13&255;padded[i++]=length>>5&255;padded[i++]=length<<3&255;var w=new Uint32Array(64);for(i=0;i<paddedLength;){for(j=0;j<16;++j){w[j]=padded[i]<<24|padded[i+1]<<16|padded[i+2]<<8|padded[i+3];i+=4}for(j=16;j<64;++j){w[j]=littleSigmaPrime(w[j-2])+w[j-7]+littleSigma(w[j-15])+w[j-16]|0}var a=h0,b=h1,c=h2,d=h3,e=h4,f=h5,g=h6,h=h7,t1,t2;for(j=0;j<64;++j){t1=h+sigmaPrime(e)+ch(e,f,g)+k[j]+w[j];t2=sigma(a)+maj(a,b,c);h=g;g=f;f=e;e=d+t1|0;d=c;c=b;b=a;a=t1+t2|0}h0=h0+a|0;h1=h1+b|0;h2=h2+c|0;h3=h3+d|0;h4=h4+e|0;h5=h5+f|0;h6=h6+g|0;h7=h7+h|0}return new Uint8Array([h0>>24&255,h0>>16&255,h0>>8&255,h0&255,h1>>24&255,h1>>16&255,h1>>8&255,h1&255,h2>>24&255,h2>>16&255,h2>>8&255,h2&255,h3>>24&255,h3>>16&255,h3>>8&255,h3&255,h4>>24&255,h4>>16&255,h4>>8&255,h4&255,h5>>24&255,h5>>16&255,h5>>8&255,h5&255,h6>>24&255,h6>>16&255,h6>>8&255,h6&255,h7>>24&255,h7>>16&255,h7>>8&255,h7&255])}return hash}();var calculateSHA512=function calculateSHA512Closure(){function ch(result,x,y,z,tmp){result.assign(x);result.and(y);tmp.assign(x);tmp.not();tmp.and(z);result.xor(tmp)}function maj(result,x,y,z,tmp){result.assign(x);result.and(y);tmp.assign(x);tmp.and(z);result.xor(tmp);tmp.assign(y);tmp.and(z);result.xor(tmp)}function sigma(result,x,tmp){result.assign(x);result.rotateRight(28);tmp.assign(x);tmp.rotateRight(34);result.xor(tmp);tmp.assign(x);tmp.rotateRight(39);result.xor(tmp)}function sigmaPrime(result,x,tmp){result.assign(x);result.rotateRight(14);tmp.assign(x);tmp.rotateRight(18);result.xor(tmp);tmp.assign(x);tmp.rotateRight(41);result.xor(tmp)}function littleSigma(result,x,tmp){result.assign(x);result.rotateRight(1);tmp.assign(x);tmp.rotateRight(8);result.xor(tmp);tmp.assign(x);tmp.shiftRight(7);result.xor(tmp)}function littleSigmaPrime(result,x,tmp){result.assign(x);result.rotateRight(19);tmp.assign(x);tmp.rotateRight(61);result.xor(tmp);tmp.assign(x);tmp.shiftRight(6);result.xor(tmp)}var k=[new Word64(1116352408,3609767458),new Word64(1899447441,602891725),new Word64(3049323471,3964484399),new Word64(3921009573,2173295548),new Word64(961987163,4081628472),new Word64(1508970993,3053834265),new Word64(2453635748,2937671579),new Word64(2870763221,3664609560),new Word64(3624381080,2734883394),new Word64(310598401,1164996542),new Word64(607225278,1323610764),new Word64(1426881987,3590304994),new Word64(1925078388,4068182383),new Word64(2162078206,991336113),new Word64(2614888103,633803317),new Word64(3248222580,3479774868),new Word64(3835390401,2666613458),new Word64(4022224774,944711139),new Word64(264347078,2341262773),new Word64(604807628,2007800933),new Word64(770255983,1495990901),new Word64(1249150122,1856431235),new Word64(1555081692,3175218132),new Word64(1996064986,2198950837),new Word64(2554220882,3999719339),new Word64(2821834349,766784016),new Word64(2952996808,2566594879),new Word64(3210313671,3203337956),new Word64(3336571891,1034457026),new Word64(3584528711,2466948901),new Word64(113926993,3758326383),new Word64(338241895,168717936),new Word64(666307205,1188179964),new Word64(773529912,1546045734),new Word64(1294757372,1522805485),new Word64(1396182291,2643833823),new Word64(1695183700,2343527390),new Word64(1986661051,1014477480),new Word64(2177026350,1206759142),new Word64(2456956037,344077627),new Word64(2730485921,1290863460),new Word64(2820302411,3158454273),new Word64(3259730800,3505952657),new Word64(3345764771,106217008),new Word64(3516065817,3606008344),new Word64(3600352804,1432725776),new Word64(4094571909,1467031594),new Word64(275423344,851169720),new Word64(430227734,3100823752),new Word64(506948616,1363258195),new Word64(659060556,3750685593),new Word64(883997877,3785050280),new Word64(958139571,3318307427),new Word64(1322822218,3812723403),new Word64(1537002063,2003034995),new Word64(1747873779,3602036899),new Word64(1955562222,1575990012),new Word64(2024104815,1125592928),new Word64(2227730452,2716904306),new Word64(2361852424,442776044),new Word64(2428436474,593698344),new Word64(2756734187,3733110249),new Word64(3204031479,2999351573),new Word64(3329325298,3815920427),new Word64(3391569614,3928383900),new Word64(3515267271,566280711),new Word64(3940187606,3454069534),new Word64(4118630271,4000239992),new Word64(116418474,1914138554),new Word64(174292421,2731055270),new Word64(289380356,3203993006),new Word64(460393269,320620315),new Word64(685471733,587496836),new Word64(852142971,1086792851),new Word64(1017036298,365543100),new Word64(1126000580,2618297676),new Word64(1288033470,3409855158),new Word64(1501505948,4234509866),new Word64(1607167915,987167468),new Word64(1816402316,1246189591)];function hash(data,offset,length,mode384){mode384=!!mode384;var h0,h1,h2,h3,h4,h5,h6,h7;if(!mode384){h0=new Word64(1779033703,4089235720);h1=new Word64(3144134277,2227873595);h2=new Word64(1013904242,4271175723);h3=new Word64(2773480762,1595750129);h4=new Word64(1359893119,2917565137);h5=new Word64(2600822924,725511199);h6=new Word64(528734635,4215389547);h7=new Word64(1541459225,327033209)}else{h0=new Word64(3418070365,3238371032);h1=new Word64(1654270250,914150663);h2=new Word64(2438529370,812702999);h3=new Word64(355462360,4144912697);h4=new Word64(1731405415,4290775857);h5=new Word64(2394180231,1750603025);h6=new Word64(3675008525,1694076839);h7=new Word64(1203062813,3204075428)}var paddedLength=Math.ceil((length+17)/128)*128;var padded=new Uint8Array(paddedLength);var i,j,n;for(i=0;i<length;++i){padded[i]=data[offset++]}padded[i++]=128;n=paddedLength-16;while(i<n){padded[i++]=0}padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=0;padded[i++]=length>>>29&255;padded[i++]=length>>21&255;padded[i++]=length>>13&255;padded[i++]=length>>5&255;padded[i++]=length<<3&255;var w=new Array(80);for(i=0;i<80;i++){w[i]=new Word64(0,0)}var a=new Word64(0,0),b=new Word64(0,0),c=new Word64(0,0);var d=new Word64(0,0),e=new Word64(0,0),f=new Word64(0,0);var g=new Word64(0,0),h=new Word64(0,0);var t1=new Word64(0,0),t2=new Word64(0,0);var tmp1=new Word64(0,0),tmp2=new Word64(0,0),tmp3;for(i=0;i<paddedLength;){for(j=0;j<16;++j){w[j].high=padded[i]<<24|padded[i+1]<<16|padded[i+2]<<8|padded[i+3];w[j].low=padded[i+4]<<24|padded[i+5]<<16|padded[i+6]<<8|padded[i+7];i+=8}for(j=16;j<80;++j){tmp3=w[j];littleSigmaPrime(tmp3,w[j-2],tmp2);tmp3.add(w[j-7]);littleSigma(tmp1,w[j-15],tmp2);tmp3.add(tmp1);tmp3.add(w[j-16])}a.assign(h0);b.assign(h1);c.assign(h2);d.assign(h3);e.assign(h4);f.assign(h5);g.assign(h6);h.assign(h7);for(j=0;j<80;++j){t1.assign(h);sigmaPrime(tmp1,e,tmp2);t1.add(tmp1);ch(tmp1,e,f,g,tmp2);t1.add(tmp1);t1.add(k[j]);t1.add(w[j]);sigma(t2,a,tmp2);maj(tmp1,a,b,c,tmp2);t2.add(tmp1);tmp3=h;h=g;g=f;f=e;d.add(t1);e=d;d=c;c=b;b=a;tmp3.assign(t1);tmp3.add(t2);a=tmp3}h0.add(a);h1.add(b);h2.add(c);h3.add(d);h4.add(e);h5.add(f);h6.add(g);h7.add(h)}var result;if(!mode384){result=new Uint8Array(64);h0.copyTo(result,0);h1.copyTo(result,8);h2.copyTo(result,16);h3.copyTo(result,24);h4.copyTo(result,32);h5.copyTo(result,40);h6.copyTo(result,48);h7.copyTo(result,56)}else{result=new Uint8Array(48);h0.copyTo(result,0);h1.copyTo(result,8);h2.copyTo(result,16);h3.copyTo(result,24);h4.copyTo(result,32);h5.copyTo(result,40)}return result}return hash}();var calculateSHA384=function calculateSHA384Closure(){function hash(data,offset,length){return calculateSHA512(data,offset,length,true)}return hash}();var NullCipher=function NullCipherClosure(){function NullCipher(){}NullCipher.prototype={decryptBlock:function NullCipher_decryptBlock(data){return data}};return NullCipher}();var AES128Cipher=function AES128CipherClosure(){var rcon=new Uint8Array([141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141]);var s=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]);var inv_s=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]);var mixCol=new Uint8Array(256);for(var i=0;i<256;i++){if(i<128){mixCol[i]=i<<1}else{mixCol[i]=i<<1^27}}var mix=new Uint32Array([0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795]);function expandKey128(cipherKey){var b=176,result=new Uint8Array(b);result.set(cipherKey);for(var j=16,i=1;j<b;++i){var t1=result[j-3],t2=result[j-2],t3=result[j-1],t4=result[j-4];t1=s[t1];t2=s[t2];t3=s[t3];t4=s[t4];t1=t1^rcon[i];for(var n=0;n<4;++n){result[j]=t1^=result[j-16];j++;result[j]=t2^=result[j-16];j++;result[j]=t3^=result[j-16];j++;result[j]=t4^=result[j-16];j++}}return result}function decrypt128(input,key){var state=new Uint8Array(16);state.set(input);var i,j,k;var t,u,v;for(j=0,k=160;j<16;++j,++k){state[j]^=key[k]}for(i=9;i>=1;--i){t=state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j){state[j]=inv_s[state[j]]}for(j=0,k=i*16;j<16;++j,++k){state[j]^=key[k]}for(j=0;j<16;j+=4){var s0=mix[state[j]],s1=mix[state[j+1]],s2=mix[state[j+2]],s3=mix[state[j+3]];t=s0^s1>>>8^s1<<24^s2>>>16^s2<<16^s3>>>24^s3<<8;state[j]=t>>>24&255;state[j+1]=t>>16&255;state[j+2]=t>>8&255;state[j+3]=t&255}}t=state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j){state[j]=inv_s[state[j]];state[j]^=key[j]}return state}function encrypt128(input,key){var t,u,v,k;var state=new Uint8Array(16);state.set(input);for(j=0;j<16;++j){state[j]^=key[j]}for(i=1;i<10;i++){for(j=0;j<16;++j){state[j]=s[state[j]]}v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t;for(var j=0;j<16;j+=4){var s0=state[j+0],s1=state[j+1];var s2=state[j+2],s3=state[j+3];t=s0^s1^s2^s3;state[j+0]^=t^mixCol[s0^s1];state[j+1]^=t^mixCol[s1^s2];state[j+2]^=t^mixCol[s2^s3];state[j+3]^=t^mixCol[s3^s0]}for(j=0,k=i*16;j<16;++j,++k){state[j]^=key[k]}}for(j=0;j<16;++j){state[j]=s[state[j]]}v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t;for(j=0,k=160;j<16;++j,++k){state[j]^=key[k]}return state}function AES128Cipher(key){this.key=expandKey128(key);this.buffer=new Uint8Array(16);this.bufferPosition=0}function decryptBlock2(data,finalize){var i,j,ii,sourceLength=data.length,buffer=this.buffer,bufferLength=this.bufferPosition,result=[],iv=this.iv;for(i=0;i<sourceLength;++i){buffer[bufferLength]=data[i];++bufferLength;if(bufferLength<16){continue}var plain=decrypt128(buffer,this.key);for(j=0;j<16;++j){plain[j]^=iv[j]}iv=buffer;result.push(plain);buffer=new Uint8Array(16);bufferLength=0}this.buffer=buffer;this.bufferLength=bufferLength;this.iv=iv;if(result.length===0){return new Uint8Array([])}var outputLength=16*result.length;if(finalize){var lastBlock=result[result.length-1];var psLen=lastBlock[15];if(psLen<=16){for(i=15,ii=16-psLen;i>=ii;--i){if(lastBlock[i]!==psLen){psLen=0;break}}outputLength-=psLen;result[result.length-1]=lastBlock.subarray(0,16-psLen)}}var output=new Uint8Array(outputLength);for(i=0,j=0,ii=result.length;i<ii;++i,j+=16){output.set(result[i],j)}return output}AES128Cipher.prototype={decryptBlock:function AES128Cipher_decryptBlock(data,finalize){var i,sourceLength=data.length;var buffer=this.buffer,bufferLength=this.bufferPosition;for(i=0;bufferLength<16&&i<sourceLength;++i,++bufferLength){buffer[bufferLength]=data[i]}if(bufferLength<16){this.bufferLength=bufferLength;return new Uint8Array([])}this.iv=buffer;this.buffer=new Uint8Array(16);this.bufferLength=0;this.decryptBlock=decryptBlock2;return this.decryptBlock(data.subarray(16),finalize)},encrypt:function AES128Cipher_encrypt(data,iv){var i,j,ii,sourceLength=data.length,buffer=this.buffer,bufferLength=this.bufferPosition,result=[];if(!iv){iv=new Uint8Array(16)}for(i=0;i<sourceLength;++i){buffer[bufferLength]=data[i];++bufferLength;if(bufferLength<16){continue}for(j=0;j<16;++j){buffer[j]^=iv[j]}var cipher=encrypt128(buffer,this.key);iv=cipher;result.push(cipher);buffer=new Uint8Array(16);bufferLength=0}this.buffer=buffer;this.bufferLength=bufferLength;this.iv=iv;if(result.length===0){return new Uint8Array([])}var outputLength=16*result.length;var output=new Uint8Array(outputLength);for(i=0,j=0,ii=result.length;i<ii;++i,j+=16){output.set(result[i],j)}return output}};return AES128Cipher}();var AES256Cipher=function AES256CipherClosure(){var rcon=new Uint8Array([141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141,1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145,57,114,228,211,189,97,194,159,37,74,148,51,102,204,131,29,58,116,232,203,141]);var s=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]);var inv_s=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]);var mixCol=new Uint8Array(256);for(var i=0;i<256;i++){if(i<128){mixCol[i]=i<<1}else{mixCol[i]=i<<1^27}}var mix=new Uint32Array([0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795]);
16function expandKey256(cipherKey){var b=240,result=new Uint8Array(b);var r=1;result.set(cipherKey);for(var j=32,i=1;j<b;++i){if(j%32===16){t1=s[t1];t2=s[t2];t3=s[t3];t4=s[t4]}else if(j%32===0){var t1=result[j-3],t2=result[j-2],t3=result[j-1],t4=result[j-4];t1=s[t1];t2=s[t2];t3=s[t3];t4=s[t4];t1=t1^r;if((r<<=1)>=256){r=(r^27)&255}}for(var n=0;n<4;++n){result[j]=t1^=result[j-32];j++;result[j]=t2^=result[j-32];j++;result[j]=t3^=result[j-32];j++;result[j]=t4^=result[j-32];j++}}return result}function decrypt256(input,key){var state=new Uint8Array(16);state.set(input);var i,j,k;var t,u,v;for(j=0,k=224;j<16;++j,++k){state[j]^=key[k]}for(i=13;i>=1;--i){t=state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j){state[j]=inv_s[state[j]]}for(j=0,k=i*16;j<16;++j,++k){state[j]^=key[k]}for(j=0;j<16;j+=4){var s0=mix[state[j]],s1=mix[state[j+1]],s2=mix[state[j+2]],s3=mix[state[j+3]];t=s0^s1>>>8^s1<<24^s2>>>16^s2<<16^s3>>>24^s3<<8;state[j]=t>>>24&255;state[j+1]=t>>16&255;state[j+2]=t>>8&255;state[j+3]=t&255}}t=state[13];state[13]=state[9];state[9]=state[5];state[5]=state[1];state[1]=t;t=state[14];u=state[10];state[14]=state[6];state[10]=state[2];state[6]=t;state[2]=u;t=state[15];u=state[11];v=state[7];state[15]=state[3];state[11]=t;state[7]=u;state[3]=v;for(j=0;j<16;++j){state[j]=inv_s[state[j]];state[j]^=key[j]}return state}function encrypt256(input,key){var t,u,v,k;var state=new Uint8Array(16);state.set(input);for(j=0;j<16;++j){state[j]^=key[j]}for(i=1;i<14;i++){for(j=0;j<16;++j){state[j]=s[state[j]]}v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t;for(var j=0;j<16;j+=4){var s0=state[j+0],s1=state[j+1];var s2=state[j+2],s3=state[j+3];t=s0^s1^s2^s3;state[j+0]^=t^mixCol[s0^s1];state[j+1]^=t^mixCol[s1^s2];state[j+2]^=t^mixCol[s2^s3];state[j+3]^=t^mixCol[s3^s0]}for(j=0,k=i*16;j<16;++j,++k){state[j]^=key[k]}}for(j=0;j<16;++j){state[j]=s[state[j]]}v=state[1];state[1]=state[5];state[5]=state[9];state[9]=state[13];state[13]=v;v=state[2];u=state[6];state[2]=state[10];state[6]=state[14];state[10]=v;state[14]=u;v=state[3];u=state[7];t=state[11];state[3]=state[15];state[7]=v;state[11]=u;state[15]=t;for(j=0,k=224;j<16;++j,++k){state[j]^=key[k]}return state}function AES256Cipher(key){this.key=expandKey256(key);this.buffer=new Uint8Array(16);this.bufferPosition=0}function decryptBlock2(data,finalize){var i,j,ii,sourceLength=data.length,buffer=this.buffer,bufferLength=this.bufferPosition,result=[],iv=this.iv;for(i=0;i<sourceLength;++i){buffer[bufferLength]=data[i];++bufferLength;if(bufferLength<16){continue}var plain=decrypt256(buffer,this.key);for(j=0;j<16;++j){plain[j]^=iv[j]}iv=buffer;result.push(plain);buffer=new Uint8Array(16);bufferLength=0}this.buffer=buffer;this.bufferLength=bufferLength;this.iv=iv;if(result.length===0){return new Uint8Array([])}var outputLength=16*result.length;if(finalize){var lastBlock=result[result.length-1];var psLen=lastBlock[15];if(psLen<=16){for(i=15,ii=16-psLen;i>=ii;--i){if(lastBlock[i]!==psLen){psLen=0;break}}outputLength-=psLen;result[result.length-1]=lastBlock.subarray(0,16-psLen)}}var output=new Uint8Array(outputLength);for(i=0,j=0,ii=result.length;i<ii;++i,j+=16){output.set(result[i],j)}return output}AES256Cipher.prototype={decryptBlock:function AES256Cipher_decryptBlock(data,finalize,iv){var i,sourceLength=data.length;var buffer=this.buffer,bufferLength=this.bufferPosition;if(iv){this.iv=iv}else{for(i=0;bufferLength<16&&i<sourceLength;++i,++bufferLength){buffer[bufferLength]=data[i]}if(bufferLength<16){this.bufferLength=bufferLength;return new Uint8Array([])}this.iv=buffer;data=data.subarray(16)}this.buffer=new Uint8Array(16);this.bufferLength=0;this.decryptBlock=decryptBlock2;return this.decryptBlock(data,finalize)},encrypt:function AES256Cipher_encrypt(data,iv){var i,j,ii,sourceLength=data.length,buffer=this.buffer,bufferLength=this.bufferPosition,result=[];if(!iv){iv=new Uint8Array(16)}for(i=0;i<sourceLength;++i){buffer[bufferLength]=data[i];++bufferLength;if(bufferLength<16){continue}for(j=0;j<16;++j){buffer[j]^=iv[j]}var cipher=encrypt256(buffer,this.key);this.iv=cipher;result.push(cipher);buffer=new Uint8Array(16);bufferLength=0}this.buffer=buffer;this.bufferLength=bufferLength;this.iv=iv;if(result.length===0){return new Uint8Array([])}var outputLength=16*result.length;var output=new Uint8Array(outputLength);for(i=0,j=0,ii=result.length;i<ii;++i,j+=16){output.set(result[i],j)}return output}};return AES256Cipher}();var PDF17=function PDF17Closure(){function compareByteArrays(array1,array2){if(array1.length!==array2.length){return false}for(var i=0;i<array1.length;i++){if(array1[i]!==array2[i]){return false}}return true}function PDF17(){}PDF17.prototype={checkOwnerPassword:function PDF17_checkOwnerPassword(password,ownerValidationSalt,userBytes,ownerPassword){var hashData=new Uint8Array(password.length+56);hashData.set(password,0);hashData.set(ownerValidationSalt,password.length);hashData.set(userBytes,password.length+ownerValidationSalt.length);var result=calculateSHA256(hashData,0,hashData.length);return compareByteArrays(result,ownerPassword)},checkUserPassword:function PDF17_checkUserPassword(password,userValidationSalt,userPassword){var hashData=new Uint8Array(password.length+8);hashData.set(password,0);hashData.set(userValidationSalt,password.length);var result=calculateSHA256(hashData,0,hashData.length);return compareByteArrays(result,userPassword)},getOwnerKey:function PDF17_getOwnerKey(password,ownerKeySalt,userBytes,ownerEncryption){var hashData=new Uint8Array(password.length+56);hashData.set(password,0);hashData.set(ownerKeySalt,password.length);hashData.set(userBytes,password.length+ownerKeySalt.length);var key=calculateSHA256(hashData,0,hashData.length);var cipher=new AES256Cipher(key);return cipher.decryptBlock(ownerEncryption,false,new Uint8Array(16))},getUserKey:function PDF17_getUserKey(password,userKeySalt,userEncryption){var hashData=new Uint8Array(password.length+8);hashData.set(password,0);hashData.set(userKeySalt,password.length);var key=calculateSHA256(hashData,0,hashData.length);var cipher=new AES256Cipher(key);return cipher.decryptBlock(userEncryption,false,new Uint8Array(16))}};return PDF17}();var PDF20=function PDF20Closure(){function concatArrays(array1,array2){var t=new Uint8Array(array1.length+array2.length);t.set(array1,0);t.set(array2,array1.length);return t}function calculatePDF20Hash(password,input,userBytes){var k=calculateSHA256(input,0,input.length).subarray(0,32);var e=[0];var i=0;while(i<64||e[e.length-1]>i-32){var arrayLength=password.length+k.length+userBytes.length;var k1=new Uint8Array(arrayLength*64);var array=concatArrays(password,k);array=concatArrays(array,userBytes);for(var j=0,pos=0;j<64;j++,pos+=arrayLength){k1.set(array,pos)}var cipher=new AES128Cipher(k.subarray(0,16));e=cipher.encrypt(k1,k.subarray(16,32));var remainder=0;for(var z=0;z<16;z++){remainder*=256%3;remainder%=3;remainder+=(e[z]>>>0)%3;remainder%=3}if(remainder===0){k=calculateSHA256(e,0,e.length)}else if(remainder===1){k=calculateSHA384(e,0,e.length)}else if(remainder===2){k=calculateSHA512(e,0,e.length)}i++}return k.subarray(0,32)}function PDF20(){}function compareByteArrays(array1,array2){if(array1.length!==array2.length){return false}for(var i=0;i<array1.length;i++){if(array1[i]!==array2[i]){return false}}return true}PDF20.prototype={hash:function PDF20_hash(password,concatBytes,userBytes){return calculatePDF20Hash(password,concatBytes,userBytes)},checkOwnerPassword:function PDF20_checkOwnerPassword(password,ownerValidationSalt,userBytes,ownerPassword){var hashData=new Uint8Array(password.length+56);hashData.set(password,0);hashData.set(ownerValidationSalt,password.length);hashData.set(userBytes,password.length+ownerValidationSalt.length);var result=calculatePDF20Hash(password,hashData,userBytes);return compareByteArrays(result,ownerPassword)},checkUserPassword:function PDF20_checkUserPassword(password,userValidationSalt,userPassword){var hashData=new Uint8Array(password.length+8);hashData.set(password,0);hashData.set(userValidationSalt,password.length);var result=calculatePDF20Hash(password,hashData,[]);return compareByteArrays(result,userPassword)},getOwnerKey:function PDF20_getOwnerKey(password,ownerKeySalt,userBytes,ownerEncryption){var hashData=new Uint8Array(password.length+56);hashData.set(password,0);hashData.set(ownerKeySalt,password.length);hashData.set(userBytes,password.length+ownerKeySalt.length);var key=calculatePDF20Hash(password,hashData,userBytes);var cipher=new AES256Cipher(key);return cipher.decryptBlock(ownerEncryption,false,new Uint8Array(16))},getUserKey:function PDF20_getUserKey(password,userKeySalt,userEncryption){var hashData=new Uint8Array(password.length+8);hashData.set(password,0);hashData.set(userKeySalt,password.length);var key=calculatePDF20Hash(password,hashData,[]);var cipher=new AES256Cipher(key);return cipher.decryptBlock(userEncryption,false,new Uint8Array(16))}};return PDF20}();var CipherTransform=function CipherTransformClosure(){function CipherTransform(stringCipherConstructor,streamCipherConstructor){this.stringCipherConstructor=stringCipherConstructor;this.streamCipherConstructor=streamCipherConstructor}CipherTransform.prototype={createStream:function CipherTransform_createStream(stream,length){var cipher=new this.streamCipherConstructor;return new DecryptStream(stream,length,function cipherTransformDecryptStream(data,finalize){return cipher.decryptBlock(data,finalize)})},decryptString:function CipherTransform_decryptString(s){var cipher=new this.stringCipherConstructor;var data=stringToBytes(s);data=cipher.decryptBlock(data,true);return bytesToString(data)}};return CipherTransform}();var CipherTransformFactory=function CipherTransformFactoryClosure(){var defaultPasswordBytes=new Uint8Array([40,191,78,94,78,117,138,65,100,0,78,86,255,250,1,8,46,46,0,182,208,104,62,128,47,12,169,254,100,83,105,122]);function createEncryptionKey20(revision,password,ownerPassword,ownerValidationSalt,ownerKeySalt,uBytes,userPassword,userValidationSalt,userKeySalt,ownerEncryption,userEncryption,perms){if(password){var passwordLength=Math.min(127,password.length);password=password.subarray(0,passwordLength)}else{password=[]}var pdfAlgorithm;if(revision===6){pdfAlgorithm=new PDF20}else{pdfAlgorithm=new PDF17}if(pdfAlgorithm.checkUserPassword(password,userValidationSalt,userPassword)){return pdfAlgorithm.getUserKey(password,userKeySalt,userEncryption)}else if(password.length&&pdfAlgorithm.checkOwnerPassword(password,ownerValidationSalt,uBytes,ownerPassword)){return pdfAlgorithm.getOwnerKey(password,ownerKeySalt,uBytes,ownerEncryption)}return null}function prepareKeyData(fileId,password,ownerPassword,userPassword,flags,revision,keyLength,encryptMetadata){var hashDataSize=40+ownerPassword.length+fileId.length;var hashData=new Uint8Array(hashDataSize),i=0,j,n;if(password){n=Math.min(32,password.length);for(;i<n;++i){hashData[i]=password[i]}}j=0;while(i<32){hashData[i++]=defaultPasswordBytes[j++]}for(j=0,n=ownerPassword.length;j<n;++j){hashData[i++]=ownerPassword[j]}hashData[i++]=flags&255;hashData[i++]=flags>>8&255;hashData[i++]=flags>>16&255;hashData[i++]=flags>>>24&255;for(j=0,n=fileId.length;j<n;++j){hashData[i++]=fileId[j]}if(revision>=4&&!encryptMetadata){hashData[i++]=255;hashData[i++]=255;hashData[i++]=255;hashData[i++]=255}var hash=calculateMD5(hashData,0,i);var keyLengthInBytes=keyLength>>3;if(revision>=3){for(j=0;j<50;++j){hash=calculateMD5(hash,0,keyLengthInBytes)}}var encryptionKey=hash.subarray(0,keyLengthInBytes);var cipher,checkData;if(revision>=3){for(i=0;i<32;++i){hashData[i]=defaultPasswordBytes[i]}for(j=0,n=fileId.length;j<n;++j){hashData[i++]=fileId[j]}cipher=new ARCFourCipher(encryptionKey);checkData=cipher.encryptBlock(calculateMD5(hashData,0,i));n=encryptionKey.length;var derivedKey=new Uint8Array(n),k;for(j=1;j<=19;++j){for(k=0;k<n;++k){derivedKey[k]=encryptionKey[k]^j}cipher=new ARCFourCipher(derivedKey);checkData=cipher.encryptBlock(checkData)}for(j=0,n=checkData.length;j<n;++j){if(userPassword[j]!==checkData[j]){return null}}}else{cipher=new ARCFourCipher(encryptionKey);checkData=cipher.encryptBlock(defaultPasswordBytes);for(j=0,n=checkData.length;j<n;++j){if(userPassword[j]!==checkData[j]){return null}}}return encryptionKey}function decodeUserPassword(password,ownerPassword,revision,keyLength){var hashData=new Uint8Array(32),i=0,j,n;n=Math.min(32,password.length);for(;i<n;++i){hashData[i]=password[i]}j=0;while(i<32){hashData[i++]=defaultPasswordBytes[j++]}var hash=calculateMD5(hashData,0,i);var keyLengthInBytes=keyLength>>3;if(revision>=3){for(j=0;j<50;++j){hash=calculateMD5(hash,0,hash.length)}}var cipher,userPassword;if(revision>=3){userPassword=ownerPassword;var derivedKey=new Uint8Array(keyLengthInBytes),k;for(j=19;j>=0;j--){for(k=0;k<keyLengthInBytes;++k){derivedKey[k]=hash[k]^j}cipher=new ARCFourCipher(derivedKey);userPassword=cipher.encryptBlock(userPassword)}}else{cipher=new ARCFourCipher(hash.subarray(0,keyLengthInBytes));userPassword=cipher.encryptBlock(ownerPassword)}return userPassword}var identityName=Name.get("Identity");function CipherTransformFactory(dict,fileId,password){var filter=dict.get("Filter");if(!isName(filter,"Standard")){error("unknown encryption method")}this.dict=dict;var algorithm=dict.get("V");if(!isInt(algorithm)||algorithm!==1&&algorithm!==2&&algorithm!==4&&algorithm!==5){error("unsupported encryption algorithm")}this.algorithm=algorithm;var keyLength=dict.get("Length");if(!keyLength){if(algorithm<=3){keyLength=40}else{var cfDict=dict.get("CF");var streamCryptoName=dict.get("StmF");if(isDict(cfDict)&&isName(streamCryptoName)){var handlerDict=cfDict.get(streamCryptoName.name);keyLength=handlerDict&&handlerDict.get("Length")||128;if(keyLength<40){keyLength<<=3}}}}if(!isInt(keyLength)||keyLength<40||keyLength%8!==0){error("invalid key length")}var ownerPassword=stringToBytes(dict.get("O")).subarray(0,32);var userPassword=stringToBytes(dict.get("U")).subarray(0,32);var flags=dict.get("P");var revision=dict.get("R");var encryptMetadata=(algorithm===4||algorithm===5)&&dict.get("EncryptMetadata")!==false;this.encryptMetadata=encryptMetadata;var fileIdBytes=stringToBytes(fileId);var passwordBytes;if(password){if(revision===6){try{password=utf8StringToString(password)}catch(ex){warn("CipherTransformFactory: "+"Unable to convert UTF8 encoded password.")}}passwordBytes=stringToBytes(password)}var encryptionKey;if(algorithm!==5){encryptionKey=prepareKeyData(fileIdBytes,passwordBytes,ownerPassword,userPassword,flags,revision,keyLength,encryptMetadata)}else{var ownerValidationSalt=stringToBytes(dict.get("O")).subarray(32,40);var ownerKeySalt=stringToBytes(dict.get("O")).subarray(40,48);var uBytes=stringToBytes(dict.get("U")).subarray(0,48);var userValidationSalt=stringToBytes(dict.get("U")).subarray(32,40);var userKeySalt=stringToBytes(dict.get("U")).subarray(40,48);var ownerEncryption=stringToBytes(dict.get("OE"));var userEncryption=stringToBytes(dict.get("UE"));var perms=stringToBytes(dict.get("Perms"));encryptionKey=createEncryptionKey20(revision,passwordBytes,ownerPassword,ownerValidationSalt,ownerKeySalt,uBytes,userPassword,userValidationSalt,userKeySalt,ownerEncryption,userEncryption,perms)}if(!encryptionKey&&!password){throw new PasswordException("No password given",PasswordResponses.NEED_PASSWORD)}else if(!encryptionKey&&password){var decodedPassword=decodeUserPassword(passwordBytes,ownerPassword,revision,keyLength);encryptionKey=prepareKeyData(fileIdBytes,decodedPassword,ownerPassword,userPassword,flags,revision,keyLength,encryptMetadata)}if(!encryptionKey){throw new PasswordException("Incorrect Password",PasswordResponses.INCORRECT_PASSWORD)}this.encryptionKey=encryptionKey;if(algorithm>=4){this.cf=dict.get("CF");this.stmf=dict.get("StmF")||identityName;this.strf=dict.get("StrF")||identityName;this.eff=dict.get("EFF")||this.stmf}}function buildObjectKey(num,gen,encryptionKey,isAes){var key=new Uint8Array(encryptionKey.length+9),i,n;for(i=0,n=encryptionKey.length;i<n;++i){key[i]=encryptionKey[i]}key[i++]=num&255;key[i++]=num>>8&255;key[i++]=num>>16&255;key[i++]=gen&255;key[i++]=gen>>8&255;if(isAes){key[i++]=115;key[i++]=65;key[i++]=108;key[i++]=84}var hash=calculateMD5(key,0,i);return hash.subarray(0,Math.min(encryptionKey.length+5,16))}function buildCipherConstructor(cf,name,num,gen,key){var cryptFilter=cf.get(name.name);var cfm;if(cryptFilter!==null&&cryptFilter!==undefined){cfm=cryptFilter.get("CFM")}if(!cfm||cfm.name==="None"){return function cipherTransformFactoryBuildCipherConstructorNone(){return new NullCipher}}if("V2"===cfm.name){return function cipherTransformFactoryBuildCipherConstructorV2(){return new ARCFourCipher(buildObjectKey(num,gen,key,false))}}if("AESV2"===cfm.name){return function cipherTransformFactoryBuildCipherConstructorAESV2(){return new AES128Cipher(buildObjectKey(num,gen,key,true))}}if("AESV3"===cfm.name){return function cipherTransformFactoryBuildCipherConstructorAESV3(){return new AES256Cipher(key)}}error("Unknown crypto method")}CipherTransformFactory.prototype={createCipherTransform:function CipherTransformFactory_createCipherTransform(num,gen){if(this.algorithm===4||this.algorithm===5){return new CipherTransform(buildCipherConstructor(this.cf,this.stmf,num,gen,this.encryptionKey),buildCipherConstructor(this.cf,this.strf,num,gen,this.encryptionKey))}var key=buildObjectKey(num,gen,this.encryptionKey,false);var cipherConstructor=function buildCipherCipherConstructor(){return new ARCFourCipher(key)};return new CipherTransform(cipherConstructor,cipherConstructor)}};return CipherTransformFactory}();exports.AES128Cipher=AES128Cipher;exports.AES256Cipher=AES256Cipher;exports.ARCFourCipher=ARCFourCipher;exports.CipherTransformFactory=CipherTransformFactory;exports.PDF17=PDF17;exports.PDF20=PDF20;exports.calculateMD5=calculateMD5;exports.calculateSHA256=calculateSHA256;exports.calculateSHA384=calculateSHA384;exports.calculateSHA512=calculateSHA512});(function(root,factory){{factory(root.pdfjsCoreFontRenderer={},root.pdfjsSharedUtil,root.pdfjsCoreStream,root.pdfjsCoreGlyphList,root.pdfjsCoreEncodings,root.pdfjsCoreCFFParser)}})(this,function(exports,sharedUtil,coreStream,coreGlyphList,coreEncodings,coreCFFParser){var Util=sharedUtil.Util;var bytesToString=sharedUtil.bytesToString;var error=sharedUtil.error;var Stream=coreStream.Stream;var getGlyphsUnicode=coreGlyphList.getGlyphsUnicode;var StandardEncoding=coreEncodings.StandardEncoding;var CFFParser=coreCFFParser.CFFParser;var FontRendererFactory=function FontRendererFactoryClosure(){function getLong(data,offset){return data[offset]<<24|data[offset+1]<<16|data[offset+2]<<8|data[offset+3]}function getUshort(data,offset){return data[offset]<<8|data[offset+1]}function parseCmap(data,start,end){var offset=getUshort(data,start+2)===1?getLong(data,start+8):getLong(data,start+16);var format=getUshort(data,start+offset);var length,ranges,p,i;if(format===4){length=getUshort(data,start+offset+2);var segCount=getUshort(data,start+offset+6)>>1;p=start+offset+14;ranges=[];for(i=0;i<segCount;i++,p+=2){ranges[i]={end:getUshort(data,p)}}p+=2;for(i=0;i<segCount;i++,p+=2){ranges[i].start=getUshort(data,p)}for(i=0;i<segCount;i++,p+=2){ranges[i].idDelta=getUshort(data,p)}for(i=0;i<segCount;i++,p+=2){var idOffset=getUshort(data,p);if(idOffset===0){continue}ranges[i].ids=[];for(var j=0,jj=ranges[i].end-ranges[i].start+1;j<jj;j++){ranges[i].ids[j]=getUshort(data,p+idOffset);idOffset+=2}}return ranges}else if(format===12){length=getLong(data,start+offset+4);var groups=getLong(data,start+offset+12);p=start+offset+16;ranges=[];for(i=0;i<groups;i++){ranges.push({start:getLong(data,p),end:getLong(data,p+4),idDelta:getLong(data,p+8)-getLong(data,p)});p+=12}return ranges}error("not supported cmap: "+format)}function parseCff(data,start,end,seacAnalysisEnabled){var properties={};var parser=new CFFParser(new Stream(data,start,end-start),properties,seacAnalysisEnabled);var cff=parser.parse();return{glyphs:cff.charStrings.objects,subrs:cff.topDict.privateDict&&cff.topDict.privateDict.subrsIndex&&cff.topDict.privateDict.subrsIndex.objects,gsubrs:cff.globalSubrIndex&&cff.globalSubrIndex.objects}}function parseGlyfTable(glyf,loca,isGlyphLocationsLong){var itemSize,itemDecode;if(isGlyphLocationsLong){itemSize=4;itemDecode=function fontItemDecodeLong(data,offset){return data[offset]<<24|data[offset+1]<<16|data[offset+2]<<8|data[offset+3]}}else{itemSize=2;itemDecode=function fontItemDecode(data,offset){return data[offset]<<9|data[offset+1]<<1}}var glyphs=[];var startOffset=itemDecode(loca,0);for(var j=itemSize;j<loca.length;j+=itemSize){var endOffset=itemDecode(loca,j);glyphs.push(glyf.subarray(startOffset,endOffset));startOffset=endOffset}return glyphs}function lookupCmap(ranges,unicode){var code=unicode.charCodeAt(0),gid=0;var l=0,r=ranges.length-1;while(l<r){var c=l+r+1>>1;if(code<ranges[c].start){r=c-1}else{l=c}}if(ranges[l].start<=code&&code<=ranges[l].end){gid=ranges[l].idDelta+(ranges[l].ids?ranges[l].ids[code-ranges[l].start]:code)&65535}return{charCode:code,glyphId:gid}}function compileGlyf(code,cmds,font){function moveTo(x,y){cmds.push({cmd:"moveTo",args:[x,y]})}function lineTo(x,y){cmds.push({cmd:"lineTo",args:[x,y]})}function quadraticCurveTo(xa,ya,x,y){cmds.push({cmd:"quadraticCurveTo",args:[xa,ya,x,y]})}var i=0;var numberOfContours=(code[i]<<24|code[i+1]<<16)>>16;var flags;var x=0,y=0;i+=10;if(numberOfContours<0){do{flags=code[i]<<8|code[i+1];var glyphIndex=code[i+2]<<8|code[i+3];i+=4;var arg1,arg2;if(flags&1){arg1=(code[i]<<24|code[i+1]<<16)>>16;arg2=(code[i+2]<<24|code[i+3]<<16)>>16;i+=4}else{arg1=code[i++];arg2=code[i++]}if(flags&2){x=arg1;y=arg2}else{x=0;y=0}var scaleX=1,scaleY=1,scale01=0,scale10=0;if(flags&8){scaleX=scaleY=(code[i]<<24|code[i+1]<<16)/1073741824;i+=2}else if(flags&64){scaleX=(code[i]<<24|code[i+1]<<16)/1073741824;scaleY=(code[i+2]<<24|code[i+3]<<16)/1073741824;i+=4}else if(flags&128){scaleX=(code[i]<<24|code[i+1]<<16)/1073741824;scale01=(code[i+2]<<24|code[i+3]<<16)/1073741824;scale10=(code[i+4]<<24|code[i+5]<<16)/1073741824;scaleY=(code[i+6]<<24|code[i+7]<<16)/1073741824;i+=8}var subglyph=font.glyphs[glyphIndex];if(subglyph){cmds.push({cmd:"save"});cmds.push({cmd:"transform",args:[scaleX,scale01,scale10,scaleY,x,y]});compileGlyf(subglyph,cmds,font);cmds.push({cmd:"restore"})}}while(flags&32)}else{var endPtsOfContours=[];var j,jj;for(j=0;j<numberOfContours;j++){endPtsOfContours.push(code[i]<<8|code[i+1]);i+=2}var instructionLength=code[i]<<8|code[i+1];i+=2+instructionLength;var numberOfPoints=endPtsOfContours[endPtsOfContours.length-1]+1;var points=[];while(points.length<numberOfPoints){flags=code[i++];var repeat=1;if(flags&8){repeat+=code[i++]}while(repeat-->0){points.push({flags:flags})}}for(j=0;j<numberOfPoints;j++){switch(points[j].flags&18){case 0:x+=(code[i]<<24|code[i+1]<<16)>>16;i+=2;break;case 2:x-=code[i++];break;case 18:x+=code[i++];break}points[j].x=x}for(j=0;j<numberOfPoints;j++){switch(points[j].flags&36){case 0:y+=(code[i]<<24|code[i+1]<<16)>>16;i+=2;break;case 4:y-=code[i++];break;case 36:y+=code[i++];break}points[j].y=y}var startPoint=0;for(i=0;i<numberOfContours;i++){var endPoint=endPtsOfContours[i];var contour=points.slice(startPoint,endPoint+1);if(contour[0].flags&1){contour.push(contour[0])}else if(contour[contour.length-1].flags&1){contour.unshift(contour[contour.length-1])}else{var p={flags:1,x:(contour[0].x+contour[contour.length-1].x)/2,y:(contour[0].y+contour[contour.length-1].y)/2};contour.unshift(p);contour.push(p)}moveTo(contour[0].x,contour[0].y);for(j=1,jj=contour.length;j<jj;j++){if(contour[j].flags&1){lineTo(contour[j].x,contour[j].y)}else if(contour[j+1].flags&1){quadraticCurveTo(contour[j].x,contour[j].y,contour[j+1].x,contour[j+1].y);j++}else{quadraticCurveTo(contour[j].x,contour[j].y,(contour[j].x+contour[j+1].x)/2,(contour[j].y+contour[j+1].y)/2)}}startPoint=endPoint+1}}}function compileCharString(code,cmds,font){var stack=[];var x=0,y=0;var stems=0;function moveTo(x,y){cmds.push({cmd:"moveTo",args:[x,y]})}function lineTo(x,y){cmds.push({cmd:"lineTo",args:[x,y]})}function bezierCurveTo(x1,y1,x2,y2,x,y){cmds.push({cmd:"bezierCurveTo",args:[x1,y1,x2,y2,x,y]})}function parse(code){var i=0;while(i<code.length){var stackClean=false;var v=code[i++];var xa,xb,ya,yb,y1,y2,y3,n,subrCode;switch(v){case 1:stems+=stack.length>>1;stackClean=true;break;case 3:stems+=stack.length>>1;stackClean=true;break;case 4:y+=stack.pop();moveTo(x,y);stackClean=true;break;case 5:while(stack.length>0){x+=stack.shift();y+=stack.shift();lineTo(x,y)}break;case 6:while(stack.length>0){x+=stack.shift();lineTo(x,y);if(stack.length===0){break}y+=stack.shift();lineTo(x,y)}break;case 7:while(stack.length>0){y+=stack.shift();lineTo(x,y);if(stack.length===0){break}x+=stack.shift();lineTo(x,y)}break;case 8:while(stack.length>0){xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 10:n=stack.pop()+font.subrsBias;subrCode=font.subrs[n];if(subrCode){parse(subrCode)}break;case 11:return;case 12:v=code[i++];switch(v){case 34:xa=x+stack.shift();xb=xa+stack.shift();y1=y+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y,xb,y1,x,y1);xa=x+stack.shift();xb=xa+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y1,xb,y,x,y);break;case 35:xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);stack.pop();break;case 36:xa=x+stack.shift();y1=y+stack.shift();xb=xa+stack.shift();y2=y1+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y1,xb,y2,x,y2);xa=x+stack.shift();xb=xa+stack.shift();y3=y2+stack.shift();x=xb+stack.shift();bezierCurveTo(xa,y2,xb,y3,x,y);break;case 37:var x0=x,y0=y;xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb;y=yb;if(Math.abs(x-x0)>Math.abs(y-y0)){x+=stack.shift()}else{y+=stack.shift()}bezierCurveTo(xa,ya,xb,yb,x,y);break;default:error("unknown operator: 12 "+v)}break;case 14:if(stack.length>=4){var achar=stack.pop();var bchar=stack.pop();y=stack.pop();x=stack.pop();cmds.push({cmd:"save"});cmds.push({cmd:"translate",args:[x,y]});var cmap=lookupCmap(font.cmap,String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));compileCharString(font.glyphs[cmap.glyphId],cmds,font);cmds.push({cmd:"restore"});cmap=lookupCmap(font.cmap,String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));compileCharString(font.glyphs[cmap.glyphId],cmds,font)}return;case 18:stems+=stack.length>>1;stackClean=true;break;case 19:stems+=stack.length>>1;i+=stems+7>>3;stackClean=true;break;case 20:stems+=stack.length>>1;i+=stems+7>>3;stackClean=true;break;case 21:y+=stack.pop();x+=stack.pop();moveTo(x,y);stackClean=true;break;case 22:x+=stack.pop();moveTo(x,y);stackClean=true;break;case 23:stems+=stack.length>>1;stackClean=true;break;case 24:while(stack.length>2){xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y)}x+=stack.shift();y+=stack.shift();lineTo(x,y);break;case 25:while(stack.length>6){x+=stack.shift();y+=stack.shift();lineTo(x,y)}xa=x+stack.shift();ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y);break;case 26:if(stack.length%2){x+=stack.shift()}while(stack.length>0){xa=x;ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb;y=yb+stack.shift();bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 27:if(stack.length%2){y+=stack.shift()}while(stack.length>0){xa=x+stack.shift();ya=y;xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb;bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 28:stack.push((code[i]<<24|code[i+1]<<16)>>16);i+=2;break;case 29:n=stack.pop()+font.gsubrsBias;subrCode=font.gsubrs[n];if(subrCode){parse(subrCode)}break;case 30:while(stack.length>0){xa=x;ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+(stack.length===1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y);if(stack.length===0){break}xa=x+stack.shift();ya=y;xb=xa+stack.shift();yb=ya+stack.shift();y=yb+stack.shift();x=xb+(stack.length===1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y)}break;case 31:while(stack.length>0){xa=x+stack.shift();ya=y;xb=xa+stack.shift();yb=ya+stack.shift();y=yb+stack.shift();x=xb+(stack.length===1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y);if(stack.length===0){break}xa=x;ya=y+stack.shift();xb=xa+stack.shift();yb=ya+stack.shift();x=xb+stack.shift();y=yb+(stack.length===1?stack.shift():0);bezierCurveTo(xa,ya,xb,yb,x,y)}break;default:if(v<32){error("unknown operator: "+v)}if(v<247){stack.push(v-139)}else if(v<251){stack.push((v-247)*256+code[i++]+108)}else if(v<255){stack.push(-(v-251)*256-code[i++]-108)}else{stack.push((code[i]<<24|code[i+1]<<16|code[i+2]<<8|code[i+3])/65536);i+=4}break}if(stackClean){stack.length=0}}}parse(code)}var noop="";function CompiledFont(fontMatrix){this.compiledGlyphs=Object.create(null);this.compiledCharCodeToGlyphId=Object.create(null);this.fontMatrix=fontMatrix}CompiledFont.prototype={getPathJs:function(unicode){var cmap=lookupCmap(this.cmap,unicode);var fn=this.compiledGlyphs[cmap.glyphId];if(!fn){fn=this.compileGlyph(this.glyphs[cmap.glyphId]);this.compiledGlyphs[cmap.glyphId]=fn}if(this.compiledCharCodeToGlyphId[cmap.charCode]===undefined){this.compiledCharCodeToGlyphId[cmap.charCode]=cmap.glyphId}return fn},compileGlyph:function(code){if(!code||code.length===0||code[0]===14){return noop}var cmds=[];cmds.push({cmd:"save"});cmds.push({cmd:"transform",args:this.fontMatrix.slice()});cmds.push({cmd:"scale",args:["size","-size"]});this.compileGlyphImpl(code,cmds);cmds.push({cmd:"restore"});return cmds},compileGlyphImpl:function(){error("Children classes should implement this.")},hasBuiltPath:function(unicode){var cmap=lookupCmap(this.cmap,unicode);return this.compiledGlyphs[cmap.glyphId]!==undefined&&this.compiledCharCodeToGlyphId[cmap.charCode]!==undefined}};function TrueTypeCompiled(glyphs,cmap,fontMatrix){fontMatrix=fontMatrix||[488e-6,0,0,488e-6,0,0];CompiledFont.call(this,fontMatrix);this.glyphs=glyphs;this.cmap=cmap}Util.inherit(TrueTypeCompiled,CompiledFont,{compileGlyphImpl:function(code,cmds){compileGlyf(code,cmds,this)}});function Type2Compiled(cffInfo,cmap,fontMatrix,glyphNameMap){fontMatrix=fontMatrix||[.001,0,0,.001,0,0];CompiledFont.call(this,fontMatrix);this.glyphs=cffInfo.glyphs;this.gsubrs=cffInfo.gsubrs||[];this.subrs=cffInfo.subrs||[];this.cmap=cmap;this.glyphNameMap=glyphNameMap||getGlyphsUnicode();this.gsubrsBias=this.gsubrs.length<1240?107:this.gsubrs.length<33900?1131:32768;this.subrsBias=this.subrs.length<1240?107:this.subrs.length<33900?1131:32768}Util.inherit(Type2Compiled,CompiledFont,{compileGlyphImpl:function(code,cmds){compileCharString(code,cmds,this)}});return{create:function FontRendererFactory_create(font,seacAnalysisEnabled){var data=new Uint8Array(font.data);var cmap,glyf,loca,cff,indexToLocFormat,unitsPerEm;var numTables=getUshort(data,4);for(var i=0,p=12;i<numTables;i++,p+=16){var tag=bytesToString(data.subarray(p,p+4));var offset=getLong(data,p+8);var length=getLong(data,p+12);switch(tag){case"cmap":cmap=parseCmap(data,offset,offset+length);break;case"glyf":glyf=data.subarray(offset,offset+length);break;case"loca":loca=data.subarray(offset,offset+length);
17break;case"head":unitsPerEm=getUshort(data,offset+18);indexToLocFormat=getUshort(data,offset+50);break;case"CFF ":cff=parseCff(data,offset,offset+length,seacAnalysisEnabled);break}}if(glyf){var fontMatrix=!unitsPerEm?font.fontMatrix:[1/unitsPerEm,0,0,1/unitsPerEm,0,0];return new TrueTypeCompiled(parseGlyfTable(glyf,loca,indexToLocFormat),cmap,fontMatrix)}else{return new Type2Compiled(cff,cmap,font.fontMatrix,font.glyphNameMap)}}}}();exports.FontRendererFactory=FontRendererFactory});(function(root,factory){{factory(root.pdfjsCoreParser={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreStream)}})(this,function(exports,sharedUtil,corePrimitives,coreStream){var MissingDataException=sharedUtil.MissingDataException;var StreamType=sharedUtil.StreamType;var assert=sharedUtil.assert;var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var isInt=sharedUtil.isInt;var isNum=sharedUtil.isNum;var isString=sharedUtil.isString;var warn=sharedUtil.warn;var Cmd=corePrimitives.Cmd;var Dict=corePrimitives.Dict;var Name=corePrimitives.Name;var Ref=corePrimitives.Ref;var isCmd=corePrimitives.isCmd;var isDict=corePrimitives.isDict;var isName=corePrimitives.isName;var Ascii85Stream=coreStream.Ascii85Stream;var AsciiHexStream=coreStream.AsciiHexStream;var CCITTFaxStream=coreStream.CCITTFaxStream;var FlateStream=coreStream.FlateStream;var Jbig2Stream=coreStream.Jbig2Stream;var JpegStream=coreStream.JpegStream;var JpxStream=coreStream.JpxStream;var LZWStream=coreStream.LZWStream;var NullStream=coreStream.NullStream;var PredictorStream=coreStream.PredictorStream;var RunLengthStream=coreStream.RunLengthStream;var EOF={};function isEOF(v){return v===EOF}var MAX_LENGTH_TO_CACHE=1e3;var Parser=function ParserClosure(){function Parser(lexer,allowStreams,xref,recoveryMode){this.lexer=lexer;this.allowStreams=allowStreams;this.xref=xref;this.recoveryMode=recoveryMode||false;this.imageCache=Object.create(null);this.refill()}Parser.prototype={refill:function Parser_refill(){this.buf1=this.lexer.getObj();this.buf2=this.lexer.getObj()},shift:function Parser_shift(){if(isCmd(this.buf2,"ID")){this.buf1=this.buf2;this.buf2=null}else{this.buf1=this.buf2;this.buf2=this.lexer.getObj()}},tryShift:function Parser_tryShift(){try{this.shift();return true}catch(e){if(e instanceof MissingDataException){throw e}return false}},getObj:function Parser_getObj(cipherTransform){var buf1=this.buf1;this.shift();if(buf1 instanceof Cmd){switch(buf1.cmd){case"BI":return this.makeInlineImage(cipherTransform);case"[":var array=[];while(!isCmd(this.buf1,"]")&&!isEOF(this.buf1)){array.push(this.getObj(cipherTransform))}if(isEOF(this.buf1)){if(!this.recoveryMode){error("End of file inside array")}return array}this.shift();return array;case"<<":var dict=new Dict(this.xref);while(!isCmd(this.buf1,">>")&&!isEOF(this.buf1)){if(!isName(this.buf1)){info("Malformed dictionary: key must be a name object");this.shift();continue}var key=this.buf1.name;this.shift();if(isEOF(this.buf1)){break}dict.set(key,this.getObj(cipherTransform))}if(isEOF(this.buf1)){if(!this.recoveryMode){error("End of file inside dictionary")}return dict}if(isCmd(this.buf2,"stream")){return this.allowStreams?this.makeStream(dict,cipherTransform):dict}this.shift();return dict;default:return buf1}}if(isInt(buf1)){var num=buf1;if(isInt(this.buf1)&&isCmd(this.buf2,"R")){var ref=new Ref(num,this.buf1);this.shift();this.shift();return ref}return num}if(isString(buf1)){var str=buf1;if(cipherTransform){str=cipherTransform.decryptString(str)}return str}return buf1},findDefaultInlineStreamEnd:function Parser_findDefaultInlineStreamEnd(stream){var E=69,I=73,SPACE=32,LF=10,CR=13;var startPos=stream.pos,state=0,ch,i,n,followingBytes;while((ch=stream.getByte())!==-1){if(state===0){state=ch===E?1:0}else if(state===1){state=ch===I?2:0}else{assert(state===2);if(ch===SPACE||ch===LF||ch===CR){n=5;followingBytes=stream.peekBytes(n);for(i=0;i<n;i++){ch=followingBytes[i];if(ch!==LF&&ch!==CR&&(ch<SPACE||ch>127)){state=0;break}}if(state===2){break}}else{state=0}}}return stream.pos-4-startPos},findDCTDecodeInlineStreamEnd:function Parser_findDCTDecodeInlineStreamEnd(stream){var startPos=stream.pos,foundEOI=false,b,markerLength,length;while((b=stream.getByte())!==-1){if(b!==255){continue}switch(stream.getByte()){case 0:break;case 255:stream.skip(-1);break;case 217:foundEOI=true;break;case 192:case 193:case 194:case 195:case 197:case 198:case 199:case 201:case 202:case 203:case 205:case 206:case 207:case 196:case 204:case 218:case 219:case 220:case 221:case 222:case 223:case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:markerLength=stream.getUint16();if(markerLength>2){stream.skip(markerLength-2)}else{stream.skip(-2)}break}if(foundEOI){break}}length=stream.pos-startPos;if(b===-1){warn("Inline DCTDecode image stream: "+"EOI marker not found, searching for /EI/ instead.");stream.skip(-length);return this.findDefaultInlineStreamEnd(stream)}this.inlineStreamSkipEI(stream);return length},findASCII85DecodeInlineStreamEnd:function Parser_findASCII85DecodeInlineStreamEnd(stream){var TILDE=126,GT=62;var startPos=stream.pos,ch,length;while((ch=stream.getByte())!==-1){if(ch===TILDE&&stream.peekByte()===GT){stream.skip();break}}length=stream.pos-startPos;if(ch===-1){warn("Inline ASCII85Decode image stream: "+"EOD marker not found, searching for /EI/ instead.");stream.skip(-length);return this.findDefaultInlineStreamEnd(stream)}this.inlineStreamSkipEI(stream);return length},findASCIIHexDecodeInlineStreamEnd:function Parser_findASCIIHexDecodeInlineStreamEnd(stream){var GT=62;var startPos=stream.pos,ch,length;while((ch=stream.getByte())!==-1){if(ch===GT){break}}length=stream.pos-startPos;if(ch===-1){warn("Inline ASCIIHexDecode image stream: "+"EOD marker not found, searching for /EI/ instead.");stream.skip(-length);return this.findDefaultInlineStreamEnd(stream)}this.inlineStreamSkipEI(stream);return length},inlineStreamSkipEI:function Parser_inlineStreamSkipEI(stream){var E=69,I=73;var state=0,ch;while((ch=stream.getByte())!==-1){if(state===0){state=ch===E?1:0}else if(state===1){state=ch===I?2:0}else if(state===2){break}}},makeInlineImage:function Parser_makeInlineImage(cipherTransform){var lexer=this.lexer;var stream=lexer.stream;var dict=new Dict(this.xref);while(!isCmd(this.buf1,"ID")&&!isEOF(this.buf1)){if(!isName(this.buf1)){error("Dictionary key must be a name object")}var key=this.buf1.name;this.shift();if(isEOF(this.buf1)){break}dict.set(key,this.getObj(cipherTransform))}var filter=dict.get("Filter","F"),filterName;if(isName(filter)){filterName=filter.name}else if(isArray(filter)&&isName(filter[0])){filterName=filter[0].name}var startPos=stream.pos,length,i,ii;if(filterName==="DCTDecode"||filterName==="DCT"){length=this.findDCTDecodeInlineStreamEnd(stream)}else if(filterName==="ASCII85Decide"||filterName==="A85"){length=this.findASCII85DecodeInlineStreamEnd(stream)}else if(filterName==="ASCIIHexDecode"||filterName==="AHx"){length=this.findASCIIHexDecodeInlineStreamEnd(stream)}else{length=this.findDefaultInlineStreamEnd(stream)}var imageStream=stream.makeSubStream(startPos,length,dict);var adler32;if(length<MAX_LENGTH_TO_CACHE){var imageBytes=imageStream.getBytes();imageStream.reset();var a=1;var b=0;for(i=0,ii=imageBytes.length;i<ii;++i){a+=imageBytes[i]&255;b+=a}adler32=b%65521<<16|a%65521;if(this.imageCache.adler32===adler32){this.buf2=Cmd.get("EI");this.shift();this.imageCache[adler32].reset();return this.imageCache[adler32]}}if(cipherTransform){imageStream=cipherTransform.createStream(imageStream,length)}imageStream=this.filter(imageStream,dict,length);imageStream.dict=dict;if(adler32!==undefined){imageStream.cacheKey="inline_"+length+"_"+adler32;this.imageCache[adler32]=imageStream}this.buf2=Cmd.get("EI");this.shift();return imageStream},makeStream:function Parser_makeStream(dict,cipherTransform){var lexer=this.lexer;var stream=lexer.stream;lexer.skipToNextLine();var pos=stream.pos-1;var length=dict.get("Length");if(!isInt(length)){info("Bad "+length+" attribute in stream");length=0}stream.pos=pos+length;lexer.nextChar();if(this.tryShift()&&isCmd(this.buf2,"endstream")){this.shift()}else{stream.pos=pos;var SCAN_BLOCK_SIZE=2048;var ENDSTREAM_SIGNATURE_LENGTH=9;var ENDSTREAM_SIGNATURE=[101,110,100,115,116,114,101,97,109];var skipped=0,found=false,i,j;while(stream.pos<stream.end){var scanBytes=stream.peekBytes(SCAN_BLOCK_SIZE);var scanLength=scanBytes.length-ENDSTREAM_SIGNATURE_LENGTH;if(scanLength<=0){break}found=false;i=0;while(i<scanLength){j=0;while(j<ENDSTREAM_SIGNATURE_LENGTH&&scanBytes[i+j]===ENDSTREAM_SIGNATURE[j]){j++}if(j>=ENDSTREAM_SIGNATURE_LENGTH){found=true;break}i++}if(found){skipped+=i;stream.pos+=i;break}skipped+=scanLength;stream.pos+=scanLength}if(!found){error("Missing endstream")}length=skipped;lexer.nextChar();this.shift();this.shift()}this.shift();stream=stream.makeSubStream(pos,length,dict);if(cipherTransform){stream=cipherTransform.createStream(stream,length)}stream=this.filter(stream,dict,length);stream.dict=dict;return stream},filter:function Parser_filter(stream,dict,length){var filter=dict.get("Filter","F");var params=dict.get("DecodeParms","DP");if(isName(filter)){return this.makeFilter(stream,filter.name,length,params)}var maybeLength=length;if(isArray(filter)){var filterArray=filter;var paramsArray=params;for(var i=0,ii=filterArray.length;i<ii;++i){filter=filterArray[i];if(!isName(filter)){error("Bad filter name: "+filter)}params=null;if(isArray(paramsArray)&&i in paramsArray){params=paramsArray[i]}stream=this.makeFilter(stream,filter.name,maybeLength,params);maybeLength=null}}return stream},makeFilter:function Parser_makeFilter(stream,name,maybeLength,params){if(stream.dict.get("Length")===0&&!maybeLength){warn('Empty "'+name+'" stream.');return new NullStream(stream)}try{if(params&&this.xref){params=this.xref.fetchIfRef(params)}var xrefStreamStats=this.xref.stats.streamTypes;if(name==="FlateDecode"||name==="Fl"){xrefStreamStats[StreamType.FLATE]=true;if(params){return new PredictorStream(new FlateStream(stream,maybeLength),maybeLength,params)}return new FlateStream(stream,maybeLength)}if(name==="LZWDecode"||name==="LZW"){xrefStreamStats[StreamType.LZW]=true;var earlyChange=1;if(params){if(params.has("EarlyChange")){earlyChange=params.get("EarlyChange")}return new PredictorStream(new LZWStream(stream,maybeLength,earlyChange),maybeLength,params)}return new LZWStream(stream,maybeLength,earlyChange)}if(name==="DCTDecode"||name==="DCT"){xrefStreamStats[StreamType.DCT]=true;return new JpegStream(stream,maybeLength,stream.dict)}if(name==="JPXDecode"||name==="JPX"){xrefStreamStats[StreamType.JPX]=true;return new JpxStream(stream,maybeLength,stream.dict)}if(name==="ASCII85Decode"||name==="A85"){xrefStreamStats[StreamType.A85]=true;return new Ascii85Stream(stream,maybeLength)}if(name==="ASCIIHexDecode"||name==="AHx"){xrefStreamStats[StreamType.AHX]=true;return new AsciiHexStream(stream,maybeLength)}if(name==="CCITTFaxDecode"||name==="CCF"){xrefStreamStats[StreamType.CCF]=true;return new CCITTFaxStream(stream,maybeLength,params)}if(name==="RunLengthDecode"||name==="RL"){xrefStreamStats[StreamType.RL]=true;return new RunLengthStream(stream,maybeLength)}if(name==="JBIG2Decode"){xrefStreamStats[StreamType.JBIG]=true;return new Jbig2Stream(stream,maybeLength,stream.dict)}warn('filter "'+name+'" not supported yet');return stream}catch(ex){if(ex instanceof MissingDataException){throw ex}warn('Invalid stream: "'+ex+'"');return new NullStream(stream)}}};return Parser}();var Lexer=function LexerClosure(){function Lexer(stream,knownCommands){this.stream=stream;this.nextChar();this.strBuf=[];this.knownCommands=knownCommands}var 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];function toHexDigit(ch){if(ch>=48&&ch<=57){return ch&15}if(ch>=65&&ch<=70||ch>=97&&ch<=102){return(ch&15)+9}return-1}Lexer.prototype={nextChar:function Lexer_nextChar(){return this.currentChar=this.stream.getByte()},peekChar:function Lexer_peekChar(){return this.stream.peekByte()},getNumber:function Lexer_getNumber(){var ch=this.currentChar;var eNotation=false;var divideBy=0;var sign=1;if(ch===45){sign=-1;ch=this.nextChar();if(ch===45){ch=this.nextChar()}}else if(ch===43){ch=this.nextChar()}if(ch===46){divideBy=10;ch=this.nextChar()}if(ch<48||ch>57){error("Invalid number: "+String.fromCharCode(ch));return 0}var baseValue=ch-48;var powerValue=0;var powerValueSign=1;while((ch=this.nextChar())>=0){if(48<=ch&&ch<=57){var currentDigit=ch-48;if(eNotation){powerValue=powerValue*10+currentDigit}else{if(divideBy!==0){divideBy*=10}baseValue=baseValue*10+currentDigit}}else if(ch===46){if(divideBy===0){divideBy=1}else{break}}else if(ch===45){warn("Badly formatted number")}else if(ch===69||ch===101){ch=this.peekChar();if(ch===43||ch===45){powerValueSign=ch===45?-1:1;this.nextChar()}else if(ch<48||ch>57){break}eNotation=true}else{break}}if(divideBy!==0){baseValue/=divideBy}if(eNotation){baseValue*=Math.pow(10,powerValueSign*powerValue)}return sign*baseValue},getString:function Lexer_getString(){var numParen=1;var done=false;var strBuf=this.strBuf;strBuf.length=0;var ch=this.nextChar();while(true){var charBuffered=false;switch(ch|0){case-1:warn("Unterminated string");done=true;break;case 40:++numParen;strBuf.push("(");break;case 41:if(--numParen===0){this.nextChar();done=true}else{strBuf.push(")")}break;case 92:ch=this.nextChar();switch(ch){case-1:warn("Unterminated string");done=true;break;case 110:strBuf.push("\n");break;case 114:strBuf.push("\r");break;case 116:strBuf.push(" ");break;case 98:strBuf.push("\b");break;case 102:strBuf.push("\f");break;case 92:case 40:case 41:strBuf.push(String.fromCharCode(ch));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:var x=ch&15;ch=this.nextChar();charBuffered=true;if(ch>=48&&ch<=55){x=(x<<3)+(ch&15);ch=this.nextChar();if(ch>=48&&ch<=55){charBuffered=false;x=(x<<3)+(ch&15)}}strBuf.push(String.fromCharCode(x));break;case 13:if(this.peekChar()===10){this.nextChar()}break;case 10:break;default:strBuf.push(String.fromCharCode(ch));break}break;default:strBuf.push(String.fromCharCode(ch));break}if(done){break}if(!charBuffered){ch=this.nextChar()}}return strBuf.join("")},getName:function Lexer_getName(){var ch,previousCh;var strBuf=this.strBuf;strBuf.length=0;while((ch=this.nextChar())>=0&&!specialChars[ch]){if(ch===35){ch=this.nextChar();if(specialChars[ch]){warn("Lexer_getName: "+"NUMBER SIGN (#) should be followed by a hexadecimal number.");strBuf.push("#");break}var x=toHexDigit(ch);if(x!==-1){previousCh=ch;ch=this.nextChar();var x2=toHexDigit(ch);if(x2===-1){warn("Lexer_getName: Illegal digit ("+String.fromCharCode(ch)+") in hexadecimal number.");strBuf.push("#",String.fromCharCode(previousCh));if(specialChars[ch]){break}strBuf.push(String.fromCharCode(ch));continue}strBuf.push(String.fromCharCode(x<<4|x2))}else{strBuf.push("#",String.fromCharCode(ch))}}else{strBuf.push(String.fromCharCode(ch))}}if(strBuf.length>127){warn("name token is longer than allowed by the spec: "+strBuf.length)}return Name.get(strBuf.join(""))},getHexString:function Lexer_getHexString(){var strBuf=this.strBuf;strBuf.length=0;var ch=this.currentChar;var isFirstHex=true;var firstDigit;var secondDigit;while(true){if(ch<0){warn("Unterminated hex string");break}else if(ch===62){this.nextChar();break}else if(specialChars[ch]===1){ch=this.nextChar();continue}else{if(isFirstHex){firstDigit=toHexDigit(ch);if(firstDigit===-1){warn('Ignoring invalid character "'+ch+'" in hex string');ch=this.nextChar();continue}}else{secondDigit=toHexDigit(ch);if(secondDigit===-1){warn('Ignoring invalid character "'+ch+'" in hex string');ch=this.nextChar();continue}strBuf.push(String.fromCharCode(firstDigit<<4|secondDigit))}isFirstHex=!isFirstHex;ch=this.nextChar()}}return strBuf.join("")},getObj:function Lexer_getObj(){var comment=false;var ch=this.currentChar;while(true){if(ch<0){return EOF}if(comment){if(ch===10||ch===13){comment=false}}else if(ch===37){comment=true}else if(specialChars[ch]!==1){break}ch=this.nextChar()}switch(ch|0){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return this.getNumber();case 40:return this.getString();case 47:return this.getName();case 91:this.nextChar();return Cmd.get("[");case 93:this.nextChar();return Cmd.get("]");case 60:ch=this.nextChar();if(ch===60){this.nextChar();return Cmd.get("<<")}return this.getHexString();case 62:ch=this.nextChar();if(ch===62){this.nextChar();return Cmd.get(">>")}return Cmd.get(">");case 123:this.nextChar();return Cmd.get("{");case 125:this.nextChar();return Cmd.get("}");case 41:error("Illegal character: "+ch);break}var str=String.fromCharCode(ch);var knownCommands=this.knownCommands;var knownCommandFound=knownCommands&&knownCommands[str]!==undefined;while((ch=this.nextChar())>=0&&!specialChars[ch]){var possibleCommand=str+String.fromCharCode(ch);if(knownCommandFound&&knownCommands[possibleCommand]===undefined){break}if(str.length===128){error("Command token too long: "+str.length)}str=possibleCommand;knownCommandFound=knownCommands&&knownCommands[str]!==undefined}if(str==="true"){return true}if(str==="false"){return false}if(str==="null"){return null}return Cmd.get(str)},skipToNextLine:function Lexer_skipToNextLine(){var ch=this.currentChar;while(ch>=0){if(ch===13){ch=this.nextChar();if(ch===10){this.nextChar()}break}else if(ch===10){this.nextChar();break}ch=this.nextChar()}}};return Lexer}();var Linearization={create:function LinearizationCreate(stream){function getInt(name,allowZeroValue){var obj=linDict.get(name);if(isInt(obj)&&(allowZeroValue?obj>=0:obj>0)){return obj}throw new Error('The "'+name+'" parameter in the linearization '+"dictionary is invalid.")}function getHints(){var hints=linDict.get("H"),hintsLength,item;if(isArray(hints)&&((hintsLength=hints.length)===2||hintsLength===4)){for(var index=0;index<hintsLength;index++){if(!(isInt(item=hints[index])&&item>0)){throw new Error("Hint ("+index+") in the linearization dictionary is invalid.")}}return hints}throw new Error("Hint array in the linearization dictionary is invalid.")}var parser=new Parser(new Lexer(stream),false,null);var obj1=parser.getObj();var obj2=parser.getObj();var obj3=parser.getObj();var linDict=parser.getObj();var obj,length;if(!(isInt(obj1)&&isInt(obj2)&&isCmd(obj3,"obj")&&isDict(linDict)&&isNum(obj=linDict.get("Linearized"))&&obj>0)){return null}else if((length=getInt("L"))!==stream.length){throw new Error('The "L" parameter in the linearization dictionary '+"does not equal the stream length.")}return{length:length,hints:getHints(),objectNumberFirst:getInt("O"),endFirst:getInt("E"),numPages:getInt("N"),mainXRefEntriesOffset:getInt("T"),pageFirst:linDict.has("P")?getInt("P",true):0}}};exports.EOF=EOF;exports.Lexer=Lexer;exports.Linearization=Linearization;exports.Parser=Parser;exports.isEOF=isEOF});(function(root,factory){{factory(root.pdfjsCoreType1Parser={},root.pdfjsSharedUtil,root.pdfjsCoreStream,root.pdfjsCoreEncodings)}})(this,function(exports,sharedUtil,coreStream,coreEncodings){var warn=sharedUtil.warn;var isSpace=sharedUtil.isSpace;var Stream=coreStream.Stream;var getEncoding=coreEncodings.getEncoding;var HINTING_ENABLED=false;var Type1CharString=function Type1CharStringClosure(){var COMMAND_MAP={hstem:[1],vstem:[3],vmoveto:[4],rlineto:[5],hlineto:[6],vlineto:[7],rrcurveto:[8],callsubr:[10],flex:[12,35],drop:[12,18],endchar:[14],rmoveto:[21],hmoveto:[22],vhcurveto:[30],hvcurveto:[31]};function Type1CharString(){this.width=0;this.lsb=0;this.flexing=false;this.output=[];this.stack=[]}Type1CharString.prototype={convert:function Type1CharString_convert(encoded,subrs,seacAnalysisEnabled){var count=encoded.length;var error=false;var wx,sbx,subrNumber;for(var i=0;i<count;i++){var value=encoded[i];if(value<32){if(value===12){value=(value<<8)+encoded[++i]}switch(value){case 1:if(!HINTING_ENABLED){this.stack=[];break}error=this.executeCommand(2,COMMAND_MAP.hstem);break;case 3:if(!HINTING_ENABLED){this.stack=[];break}error=this.executeCommand(2,COMMAND_MAP.vstem);break;case 4:if(this.flexing){if(this.stack.length<1){error=true;break}var dy=this.stack.pop();this.stack.push(0,dy);break}error=this.executeCommand(1,COMMAND_MAP.vmoveto);break;case 5:error=this.executeCommand(2,COMMAND_MAP.rlineto);break;case 6:error=this.executeCommand(1,COMMAND_MAP.hlineto);break;case 7:error=this.executeCommand(1,COMMAND_MAP.vlineto);break;case 8:error=this.executeCommand(6,COMMAND_MAP.rrcurveto);break;case 9:this.stack=[];break;case 10:if(this.stack.length<1){error=true;break}subrNumber=this.stack.pop();error=this.convert(subrs[subrNumber],subrs,seacAnalysisEnabled);break;case 11:return error;case 13:if(this.stack.length<2){error=true;break}wx=this.stack.pop();sbx=this.stack.pop();this.lsb=sbx;this.width=wx;this.stack.push(wx,sbx);error=this.executeCommand(2,COMMAND_MAP.hmoveto);break;case 14:this.output.push(COMMAND_MAP.endchar[0]);break;case 21:if(this.flexing){break}error=this.executeCommand(2,COMMAND_MAP.rmoveto);break;case 22:if(this.flexing){this.stack.push(0);break}error=this.executeCommand(1,COMMAND_MAP.hmoveto);break;case 30:error=this.executeCommand(4,COMMAND_MAP.vhcurveto);break;case 31:error=this.executeCommand(4,COMMAND_MAP.hvcurveto);break;case(12<<8)+0:this.stack=[];break;case(12<<8)+1:if(!HINTING_ENABLED){this.stack=[];break}error=this.executeCommand(2,COMMAND_MAP.vstem);break;case(12<<8)+2:if(!HINTING_ENABLED){this.stack=[];break}error=this.executeCommand(2,COMMAND_MAP.hstem);break;case(12<<8)+6:if(seacAnalysisEnabled){this.seac=this.stack.splice(-4,4);error=this.executeCommand(0,COMMAND_MAP.endchar)}else{error=this.executeCommand(4,COMMAND_MAP.endchar)}break;case(12<<8)+7:if(this.stack.length<4){error=true;break}var wy=this.stack.pop();wx=this.stack.pop();var sby=this.stack.pop();sbx=this.stack.pop();this.lsb=sbx;this.width=wx;this.stack.push(wx,sbx,sby);error=this.executeCommand(3,COMMAND_MAP.rmoveto);break;case(12<<8)+12:if(this.stack.length<2){error=true;break}var num2=this.stack.pop();var num1=this.stack.pop();this.stack.push(num1/num2);break;case(12<<8)+16:if(this.stack.length<2){error=true;break}subrNumber=this.stack.pop();var numArgs=this.stack.pop();if(subrNumber===0&&numArgs===3){var flexArgs=this.stack.splice(this.stack.length-17,17);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]);error=this.executeCommand(13,COMMAND_MAP.flex,true);this.flexing=false;this.stack.push(flexArgs[15],flexArgs[16])}else if(subrNumber===1&&numArgs===0){this.flexing=true}break;case(12<<8)+17:break;case(12<<8)+33:this.stack=[];break;default:warn('Unknown type 1 charstring command of "'+value+'"');break}if(error){break}continue}else if(value<=246){value=value-139}else if(value<=250){value=(value-247)*256+encoded[++i]+108}else if(value<=254){value=-((value-251)*256)-encoded[++i]-108}else{value=(encoded[++i]&255)<<24|(encoded[++i]&255)<<16|(encoded[++i]&255)<<8|(encoded[++i]&255)<<0}this.stack.push(value)}return error},executeCommand:function(howManyArgs,command,keepStack){var stackLength=this.stack.length;if(howManyArgs>stackLength){return true}var start=stackLength-howManyArgs;for(var i=start;i<stackLength;i++){var value=this.stack[i];if(value===(value|0)){this.output.push(28,value>>8&255,value&255)}else{value=65536*value|0;this.output.push(255,value>>24&255,value>>16&255,value>>8&255,value&255)}}this.output.push.apply(this.output,command);if(keepStack){this.stack.splice(start,howManyArgs)}else{this.stack.length=0}return false}};return Type1CharString}();var Type1Parser=function Type1ParserClosure(){var EEXEC_ENCRYPT_KEY=55665;var CHAR_STRS_ENCRYPT_KEY=4330;function isHexDigit(code){return code>=48&&code<=57||code>=65&&code<=70||code>=97&&code<=102}function decrypt(data,key,discardNumber){if(discardNumber>=data.length){return new Uint8Array(0)}var r=key|0,c1=52845,c2=22719,i,j;for(i=0;i<discardNumber;i++){r=(data[i]+r)*c1+c2&(1<<16)-1}var count=data.length-discardNumber;var decrypted=new Uint8Array(count);for(i=discardNumber,j=0;j<count;i++,j++){var value=data[i];decrypted[j]=value^r>>8;r=(value+r)*c1+c2&(1<<16)-1}return decrypted}function decryptAscii(data,key,discardNumber){var r=key|0,c1=52845,c2=22719;var count=data.length,maybeLength=count>>>1;var decrypted=new Uint8Array(maybeLength);var i,j;for(i=0,j=0;i<count;i++){var digit1=data[i];if(!isHexDigit(digit1)){continue}i++;var digit2;while(i<count&&!isHexDigit(digit2=data[i])){i++}if(i<count){var value=parseInt(String.fromCharCode(digit1,digit2),16);decrypted[j++]=value^r>>8;r=(value+r)*c1+c2&(1<<16)-1}}return Array.prototype.slice.call(decrypted,discardNumber,j)}function isSpecial(c){return c===47||c===91||c===93||c===123||c===125||c===40||c===41}function Type1Parser(stream,encrypted,seacAnalysisEnabled){if(encrypted){var data=stream.getBytes();var isBinary=!(isHexDigit(data[0])&&isHexDigit(data[1])&&isHexDigit(data[2])&&isHexDigit(data[3]));stream=new Stream(isBinary?decrypt(data,EEXEC_ENCRYPT_KEY,4):decryptAscii(data,EEXEC_ENCRYPT_KEY,4))}this.seacAnalysisEnabled=!!seacAnalysisEnabled;this.stream=stream;this.nextChar()}Type1Parser.prototype={readNumberArray:function Type1Parser_readNumberArray(){this.getToken();var array=[];while(true){var token=this.getToken();if(token===null||token==="]"||token==="}"){break}array.push(parseFloat(token||0))}return array},readNumber:function Type1Parser_readNumber(){var token=this.getToken();return parseFloat(token||0)},readInt:function Type1Parser_readInt(){var token=this.getToken();return parseInt(token||0,10)|0},readBoolean:function Type1Parser_readBoolean(){var token=this.getToken();return token==="true"?1:0},nextChar:function Type1_nextChar(){return this.currentChar=this.stream.getByte()},getToken:function Type1Parser_getToken(){var comment=false;var ch=this.currentChar;while(true){if(ch===-1){return null}if(comment){if(ch===10||ch===13){comment=false}}else if(ch===37){comment=true}else if(!isSpace(ch)){break}ch=this.nextChar()}if(isSpecial(ch)){this.nextChar();return String.fromCharCode(ch)}var token="";do{token+=String.fromCharCode(ch);ch=this.nextChar()}while(ch>=0&&!isSpace(ch)&&!isSpecial(ch));return token},extractFontProgram:function Type1Parser_extractFontProgram(){var stream=this.stream;var subrs=[],charstrings=[];var privateData=Object.create(null);privateData["lenIV"]=4;var program={subrs:[],charstrings:[],properties:{privateData:privateData}};var token,length,data,lenIV,encoded;while((token=this.getToken())!==null){if(token!=="/"){continue}token=this.getToken();switch(token){case"CharStrings":this.getToken();this.getToken();this.getToken();this.getToken();while(true){token=this.getToken();if(token===null||token==="end"){break}if(token!=="/"){continue}var glyph=this.getToken();length=this.readInt();this.getToken();data=stream.makeSubStream(stream.pos,length);lenIV=program.properties.privateData["lenIV"];encoded=decrypt(data.getBytes(),CHAR_STRS_ENCRYPT_KEY,lenIV);stream.skip(length);this.nextChar();token=this.getToken();if(token==="noaccess"){this.getToken()}charstrings.push({glyph:glyph,encoded:encoded})}break;case"Subrs":var num=this.readInt();this.getToken();while((token=this.getToken())==="dup"){var index=this.readInt();length=this.readInt();this.getToken();data=stream.makeSubStream(stream.pos,length);lenIV=program.properties.privateData["lenIV"];encoded=decrypt(data.getBytes(),CHAR_STRS_ENCRYPT_KEY,lenIV);stream.skip(length);this.nextChar();token=this.getToken();if(token==="noaccess"){this.getToken()}subrs[index]=encoded}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":var blueArray=this.readNumberArray();if(blueArray.length>0&&blueArray.length%2===0&&HINTING_ENABLED){program.properties.privateData[token]=blueArray}break;case"StemSnapH":case"StemSnapV":program.properties.privateData[token]=this.readNumberArray();break;case"StdHW":case"StdVW":program.properties.privateData[token]=this.readNumberArray()[0];break;case"BlueShift":case"lenIV":case"BlueFuzz":case"BlueScale":case"LanguageGroup":case"ExpansionFactor":program.properties.privateData[token]=this.readNumber();break;case"ForceBold":program.properties.privateData[token]=this.readBoolean();break}}for(var i=0;i<charstrings.length;i++){glyph=charstrings[i].glyph;encoded=charstrings[i].encoded;var charString=new Type1CharString;var error=charString.convert(encoded,subrs,this.seacAnalysisEnabled);var output=charString.output;if(error){output=[14]}program.charstrings.push({glyphName:glyph,charstring:output,width:charString.width,lsb:charString.lsb,seac:charString.seac})}return program},extractFontHeader:function Type1Parser_extractFontHeader(properties){var token;while((token=this.getToken())!==null){if(token!=="/"){continue}token=this.getToken();switch(token){case"FontMatrix":var matrix=this.readNumberArray();properties.fontMatrix=matrix;break;case"Encoding":var encodingArg=this.getToken();var encoding;if(!/^\d+$/.test(encodingArg)){encoding=getEncoding(encodingArg)}else{encoding=[];var size=parseInt(encodingArg,10)|0;this.getToken();for(var j=0;j<size;j++){token=this.getToken();while(token!=="dup"&&token!=="def"){token=this.getToken();if(token===null){return}}if(token==="def"){break}var index=this.readInt();this.getToken();var glyph=this.getToken();encoding[index]=glyph;this.getToken()}}properties.builtInEncoding=encoding;break;case"FontBBox":var fontBBox=this.readNumberArray();properties.ascent=fontBBox[3];properties.descent=fontBBox[1];properties.ascentScaled=true;break}}}};return Type1Parser}();exports.Type1Parser=Type1Parser});(function(root,factory){{factory(root.pdfjsCoreCMap={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreStream,root.pdfjsCoreParser)}})(this,function(exports,sharedUtil,corePrimitives,coreStream,coreParser){var Util=sharedUtil.Util;var assert=sharedUtil.assert;var warn=sharedUtil.warn;var error=sharedUtil.error;var isInt=sharedUtil.isInt;var isString=sharedUtil.isString;var MissingDataException=sharedUtil.MissingDataException;var isName=corePrimitives.isName;var isCmd=corePrimitives.isCmd;var isStream=corePrimitives.isStream;var StringStream=coreStream.StringStream;var Lexer=coreParser.Lexer;var isEOF=coreParser.isEOF;var 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"];
18var CMap=function CMapClosure(){function CMap(builtInCMap){this.codespaceRanges=[[],[],[],[]];this.numCodespaceRanges=0;this._map=[];this.name="";this.vertical=false;this.useCMap=null;this.builtInCMap=builtInCMap}CMap.prototype={addCodespaceRange:function(n,low,high){this.codespaceRanges[n-1].push(low,high);this.numCodespaceRanges++},mapCidRange:function(low,high,dstLow){while(low<=high){this._map[low++]=dstLow++}},mapBfRange:function(low,high,dstLow){var lastByte=dstLow.length-1;while(low<=high){this._map[low++]=dstLow;dstLow=dstLow.substr(0,lastByte)+String.fromCharCode(dstLow.charCodeAt(lastByte)+1)}},mapBfRangeToArray:function(low,high,array){var i=0,ii=array.length;while(low<=high&&i<ii){this._map[low]=array[i++];++low}},mapOne:function(src,dst){this._map[src]=dst},lookup:function(code){return this._map[code]},contains:function(code){return this._map[code]!==undefined},forEach:function(callback){var map=this._map;var length=map.length;var i;if(length<=65536){for(i=0;i<length;i++){if(map[i]!==undefined){callback(i,map[i])}}}else{for(i in this._map){callback(i,map[i])}}},charCodeOf:function(value){return this._map.indexOf(value)},getMap:function(){return this._map},readCharCode:function(str,offset,out){var c=0;var codespaceRanges=this.codespaceRanges;var codespaceRangesLen=this.codespaceRanges.length;for(var n=0;n<codespaceRangesLen;n++){c=(c<<8|str.charCodeAt(offset+n))>>>0;var codespaceRange=codespaceRanges[n];for(var k=0,kk=codespaceRange.length;k<kk;){var low=codespaceRange[k++];var high=codespaceRange[k++];if(c>=low&&c<=high){out.charcode=c;out.length=n+1;return}}}out.charcode=0;out.length=1},get length(){return this._map.length},get isIdentityCMap(){if(!(this.name==="Identity-H"||this.name==="Identity-V")){return false}if(this._map.length!==65536){return false}for(var i=0;i<65536;i++){if(this._map[i]!==i){return false}}return true}};return CMap}();var IdentityCMap=function IdentityCMapClosure(){function IdentityCMap(vertical,n){CMap.call(this);this.vertical=vertical;this.addCodespaceRange(n,0,65535)}Util.inherit(IdentityCMap,CMap,{});IdentityCMap.prototype={addCodespaceRange:CMap.prototype.addCodespaceRange,mapCidRange:function(low,high,dstLow){error("should not call mapCidRange")},mapBfRange:function(low,high,dstLow){error("should not call mapBfRange")},mapBfRangeToArray:function(low,high,array){error("should not call mapBfRangeToArray")},mapOne:function(src,dst){error("should not call mapCidOne")},lookup:function(code){return isInt(code)&&code<=65535?code:undefined},contains:function(code){return isInt(code)&&code<=65535},forEach:function(callback){for(var i=0;i<=65535;i++){callback(i,i)}},charCodeOf:function(value){return isInt(value)&&value<=65535?value:-1},getMap:function(){var map=new Array(65536);for(var i=0;i<=65535;i++){map[i]=i}return map},readCharCode:CMap.prototype.readCharCode,get length(){return 65536},get isIdentityCMap(){error("should not access .isIdentityCMap")}};return IdentityCMap}();var BinaryCMapReader=function BinaryCMapReaderClosure(){function fetchBinaryData(url){return new Promise(function(resolve,reject){var request=new XMLHttpRequest;request.open("GET",url,true);request.responseType="arraybuffer";request.onreadystatechange=function(){if(request.readyState===XMLHttpRequest.DONE){if(!request.response||request.status!==200&&request.status!==0){reject(new Error("Unable to get binary cMap at: "+url))}else{resolve(new Uint8Array(request.response))}}};request.send(null)})}function hexToInt(a,size){var n=0;for(var i=0;i<=size;i++){n=n<<8|a[i]}return n>>>0}function hexToStr(a,size){if(size===1){return String.fromCharCode(a[0],a[1])}if(size===3){return String.fromCharCode(a[0],a[1],a[2],a[3])}return String.fromCharCode.apply(null,a.subarray(0,size+1))}function addHex(a,b,size){var c=0;for(var i=size;i>=0;i--){c+=a[i]+b[i];a[i]=c&255;c>>=8}}function incHex(a,size){var c=1;for(var i=size;i>=0&&c>0;i--){c+=a[i];a[i]=c&255;c>>=8}}var MAX_NUM_SIZE=16;var MAX_ENCODED_NUM_SIZE=19;function BinaryCMapStream(data){this.buffer=data;this.pos=0;this.end=data.length;this.tmpBuf=new Uint8Array(MAX_ENCODED_NUM_SIZE)}BinaryCMapStream.prototype={readByte:function(){if(this.pos>=this.end){return-1}return this.buffer[this.pos++]},readNumber:function(){var n=0;var last;do{var b=this.readByte();if(b<0){error("unexpected EOF in bcmap")}last=!(b&128);n=n<<7|b&127}while(!last);return n},readSigned:function(){var n=this.readNumber();return n&1?~(n>>>1):n>>>1},readHex:function(num,size){num.set(this.buffer.subarray(this.pos,this.pos+size+1));this.pos+=size+1},readHexNumber:function(num,size){var last;var stack=this.tmpBuf,sp=0;do{var b=this.readByte();if(b<0){error("unexpected EOF in bcmap")}last=!(b&128);stack[sp++]=b&127}while(!last);var i=size,buffer=0,bufferSize=0;while(i>=0){while(bufferSize<8&&stack.length>0){buffer=stack[--sp]<<bufferSize|buffer;bufferSize+=7}num[i]=buffer&255;i--;buffer>>=8;bufferSize-=8}},readHexSigned:function(num,size){this.readHexNumber(num,size);var sign=num[size]&1?255:0;var c=0;for(var i=0;i<=size;i++){c=(c&1)<<8|num[i];num[i]=c>>1^sign}},readString:function(){var len=this.readNumber();var s="";for(var i=0;i<len;i++){s+=String.fromCharCode(this.readNumber())}return s}};function processBinaryCMap(url,cMap,extend){return fetchBinaryData(url).then(function(data){var stream=new BinaryCMapStream(data);var header=stream.readByte();cMap.vertical=!!(header&1);var useCMap=null;var start=new Uint8Array(MAX_NUM_SIZE);var end=new Uint8Array(MAX_NUM_SIZE);var char=new Uint8Array(MAX_NUM_SIZE);var charCode=new Uint8Array(MAX_NUM_SIZE);var tmp=new Uint8Array(MAX_NUM_SIZE);var code;var b;while((b=stream.readByte())>=0){var type=b>>5;if(type===7){switch(b&31){case 0:stream.readString();break;case 1:useCMap=stream.readString();break}continue}var sequence=!!(b&16);var dataSize=b&15;assert(dataSize+1<=MAX_NUM_SIZE);var ucs2DataSize=1;var subitemsCount=stream.readNumber();var i;switch(type){case 0:stream.readHex(start,dataSize);stream.readHexNumber(end,dataSize);addHex(end,start,dataSize);cMap.addCodespaceRange(dataSize+1,hexToInt(start,dataSize),hexToInt(end,dataSize));for(i=1;i<subitemsCount;i++){incHex(end,dataSize);stream.readHexNumber(start,dataSize);addHex(start,end,dataSize);stream.readHexNumber(end,dataSize);addHex(end,start,dataSize);cMap.addCodespaceRange(dataSize+1,hexToInt(start,dataSize),hexToInt(end,dataSize))}break;case 1:stream.readHex(start,dataSize);stream.readHexNumber(end,dataSize);addHex(end,start,dataSize);code=stream.readNumber();for(i=1;i<subitemsCount;i++){incHex(end,dataSize);stream.readHexNumber(start,dataSize);addHex(start,end,dataSize);stream.readHexNumber(end,dataSize);addHex(end,start,dataSize);code=stream.readNumber()}break;case 2:stream.readHex(char,dataSize);code=stream.readNumber();cMap.mapOne(hexToInt(char,dataSize),code);for(i=1;i<subitemsCount;i++){incHex(char,dataSize);if(!sequence){stream.readHexNumber(tmp,dataSize);addHex(char,tmp,dataSize)}code=stream.readSigned()+(code+1);cMap.mapOne(hexToInt(char,dataSize),code)}break;case 3:stream.readHex(start,dataSize);stream.readHexNumber(end,dataSize);addHex(end,start,dataSize);code=stream.readNumber();cMap.mapCidRange(hexToInt(start,dataSize),hexToInt(end,dataSize),code);for(i=1;i<subitemsCount;i++){incHex(end,dataSize);if(!sequence){stream.readHexNumber(start,dataSize);addHex(start,end,dataSize)}else{start.set(end)}stream.readHexNumber(end,dataSize);addHex(end,start,dataSize);code=stream.readNumber();cMap.mapCidRange(hexToInt(start,dataSize),hexToInt(end,dataSize),code)}break;case 4:stream.readHex(char,ucs2DataSize);stream.readHex(charCode,dataSize);cMap.mapOne(hexToInt(char,ucs2DataSize),hexToStr(charCode,dataSize));for(i=1;i<subitemsCount;i++){incHex(char,ucs2DataSize);if(!sequence){stream.readHexNumber(tmp,ucs2DataSize);addHex(char,tmp,ucs2DataSize)}incHex(charCode,dataSize);stream.readHexSigned(tmp,dataSize);addHex(charCode,tmp,dataSize);cMap.mapOne(hexToInt(char,ucs2DataSize),hexToStr(charCode,dataSize))}break;case 5:stream.readHex(start,ucs2DataSize);stream.readHexNumber(end,ucs2DataSize);addHex(end,start,ucs2DataSize);stream.readHex(charCode,dataSize);cMap.mapBfRange(hexToInt(start,ucs2DataSize),hexToInt(end,ucs2DataSize),hexToStr(charCode,dataSize));for(i=1;i<subitemsCount;i++){incHex(end,ucs2DataSize);if(!sequence){stream.readHexNumber(start,ucs2DataSize);addHex(start,end,ucs2DataSize)}else{start.set(end)}stream.readHexNumber(end,ucs2DataSize);addHex(end,start,ucs2DataSize);stream.readHex(charCode,dataSize);cMap.mapBfRange(hexToInt(start,ucs2DataSize),hexToInt(end,ucs2DataSize),hexToStr(charCode,dataSize))}break;default:error("Unknown type: "+type);break}}if(useCMap){return extend(useCMap)}return cMap})}function BinaryCMapReader(){}BinaryCMapReader.prototype={read:processBinaryCMap};return BinaryCMapReader}();var CMapFactory=function CMapFactoryClosure(){function strToInt(str){var a=0;for(var i=0;i<str.length;i++){a=a<<8|str.charCodeAt(i)}return a>>>0}function expectString(obj){if(!isString(obj)){error("Malformed CMap: expected string.")}}function expectInt(obj){if(!isInt(obj)){error("Malformed CMap: expected int.")}}function parseBfChar(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj)){break}if(isCmd(obj,"endbfchar")){return}expectString(obj);var src=strToInt(obj);obj=lexer.getObj();expectString(obj);var dst=obj;cMap.mapOne(src,dst)}}function parseBfRange(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj)){break}if(isCmd(obj,"endbfrange")){return}expectString(obj);var low=strToInt(obj);obj=lexer.getObj();expectString(obj);var high=strToInt(obj);obj=lexer.getObj();if(isInt(obj)||isString(obj)){var dstLow=isInt(obj)?String.fromCharCode(obj):obj;cMap.mapBfRange(low,high,dstLow)}else if(isCmd(obj,"[")){obj=lexer.getObj();var array=[];while(!isCmd(obj,"]")&&!isEOF(obj)){array.push(obj);obj=lexer.getObj()}cMap.mapBfRangeToArray(low,high,array)}else{break}}error("Invalid bf range.")}function parseCidChar(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj)){break}if(isCmd(obj,"endcidchar")){return}expectString(obj);var src=strToInt(obj);obj=lexer.getObj();expectInt(obj);var dst=obj;cMap.mapOne(src,dst)}}function parseCidRange(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj)){break}if(isCmd(obj,"endcidrange")){return}expectString(obj);var low=strToInt(obj);obj=lexer.getObj();expectString(obj);var high=strToInt(obj);obj=lexer.getObj();expectInt(obj);var dstLow=obj;cMap.mapCidRange(low,high,dstLow)}}function parseCodespaceRange(cMap,lexer){while(true){var obj=lexer.getObj();if(isEOF(obj)){break}if(isCmd(obj,"endcodespacerange")){return}if(!isString(obj)){break}var low=strToInt(obj);obj=lexer.getObj();if(!isString(obj)){break}var high=strToInt(obj);cMap.addCodespaceRange(obj.length,low,high)}error("Invalid codespace range.")}function parseWMode(cMap,lexer){var obj=lexer.getObj();if(isInt(obj)){cMap.vertical=!!obj}}function parseCMapName(cMap,lexer){var obj=lexer.getObj();if(isName(obj)&&isString(obj.name)){cMap.name=obj.name}}function parseCMap(cMap,lexer,builtInCMapParams,useCMap){var previous;var embededUseCMap;objLoop:while(true){try{var obj=lexer.getObj();if(isEOF(obj)){break}else if(isName(obj)){if(obj.name==="WMode"){parseWMode(cMap,lexer)}else if(obj.name==="CMapName"){parseCMapName(cMap,lexer)}previous=obj}else if(isCmd(obj)){switch(obj.cmd){case"endcmap":break objLoop;case"usecmap":if(isName(previous)){embededUseCMap=previous.name}break;case"begincodespacerange":parseCodespaceRange(cMap,lexer);break;case"beginbfchar":parseBfChar(cMap,lexer);break;case"begincidchar":parseCidChar(cMap,lexer);break;case"beginbfrange":parseBfRange(cMap,lexer);break;case"begincidrange":parseCidRange(cMap,lexer);break}}}catch(ex){if(ex instanceof MissingDataException){throw ex}warn("Invalid cMap data: "+ex);continue}}if(!useCMap&&embededUseCMap){useCMap=embededUseCMap}if(useCMap){return extendCMap(cMap,builtInCMapParams,useCMap)}return Promise.resolve(cMap)}function extendCMap(cMap,builtInCMapParams,useCMap){return createBuiltInCMap(useCMap,builtInCMapParams).then(function(newCMap){cMap.useCMap=newCMap;if(cMap.numCodespaceRanges===0){var useCodespaceRanges=cMap.useCMap.codespaceRanges;for(var i=0;i<useCodespaceRanges.length;i++){cMap.codespaceRanges[i]=useCodespaceRanges[i].slice()}cMap.numCodespaceRanges=cMap.useCMap.numCodespaceRanges}cMap.useCMap.forEach(function(key,value){if(!cMap.contains(key)){cMap.mapOne(key,cMap.useCMap.lookup(key))}});return cMap})}function parseBinaryCMap(name,builtInCMapParams){var url=builtInCMapParams.url+name+".bcmap";var cMap=new CMap(true);return(new BinaryCMapReader).read(url,cMap,function(useCMap){return extendCMap(cMap,builtInCMapParams,useCMap)})}function createBuiltInCMap(name,builtInCMapParams){if(name==="Identity-H"){return Promise.resolve(new IdentityCMap(false,2))}else if(name==="Identity-V"){return Promise.resolve(new IdentityCMap(true,2))}if(BUILT_IN_CMAPS.indexOf(name)===-1){return Promise.reject(new Error("Unknown cMap name: "+name))}assert(builtInCMapParams,"built-in cMap parameters are not provided");if(builtInCMapParams.packed){return parseBinaryCMap(name,builtInCMapParams)}return new Promise(function(resolve,reject){var url=builtInCMapParams.url+name;var request=new XMLHttpRequest;request.onreadystatechange=function(){if(request.readyState===XMLHttpRequest.DONE){if(request.status===200||request.status===0){var cMap=new CMap(true);var lexer=new Lexer(new StringStream(request.responseText));parseCMap(cMap,lexer,builtInCMapParams,null).then(function(parsedCMap){resolve(parsedCMap)})}else{reject(new Error("Unable to get cMap at: "+url))}}};request.open("GET",url,true);request.send(null)})}return{create:function(encoding,builtInCMapParams,useCMap){if(isName(encoding)){return createBuiltInCMap(encoding.name,builtInCMapParams)}else if(isStream(encoding)){var cMap=new CMap;var lexer=new Lexer(encoding);return parseCMap(cMap,lexer,builtInCMapParams,useCMap).then(function(parsedCMap){if(parsedCMap.isIdentityCMap){return createBuiltInCMap(parsedCMap.name,builtInCMapParams)}return parsedCMap})}return Promise.reject(new Error("Encoding required."))}}}();exports.CMap=CMap;exports.CMapFactory=CMapFactory;exports.IdentityCMap=IdentityCMap});(function(root,factory){{factory(root.pdfjsCoreFonts={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreStream,root.pdfjsCoreGlyphList,root.pdfjsCoreFontRenderer,root.pdfjsCoreEncodings,root.pdfjsCoreStandardFonts,root.pdfjsCoreUnicode,root.pdfjsCoreType1Parser,root.pdfjsCoreCFFParser)}})(this,function(exports,sharedUtil,corePrimitives,coreStream,coreGlyphList,coreFontRenderer,coreEncodings,coreStandardFonts,coreUnicode,coreType1Parser,coreCFFParser){var FONT_IDENTITY_MATRIX=sharedUtil.FONT_IDENTITY_MATRIX;var FontType=sharedUtil.FontType;var assert=sharedUtil.assert;var bytesToString=sharedUtil.bytesToString;var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var isInt=sharedUtil.isInt;var isNum=sharedUtil.isNum;var readUint32=sharedUtil.readUint32;var shadow=sharedUtil.shadow;var string32=sharedUtil.string32;var warn=sharedUtil.warn;var MissingDataException=sharedUtil.MissingDataException;var isSpace=sharedUtil.isSpace;var Stream=coreStream.Stream;var getGlyphsUnicode=coreGlyphList.getGlyphsUnicode;var getDingbatsGlyphsUnicode=coreGlyphList.getDingbatsGlyphsUnicode;var FontRendererFactory=coreFontRenderer.FontRendererFactory;var StandardEncoding=coreEncodings.StandardEncoding;var MacRomanEncoding=coreEncodings.MacRomanEncoding;var SymbolSetEncoding=coreEncodings.SymbolSetEncoding;var ZapfDingbatsEncoding=coreEncodings.ZapfDingbatsEncoding;var getEncoding=coreEncodings.getEncoding;var getStdFontMap=coreStandardFonts.getStdFontMap;var getNonStdFontMap=coreStandardFonts.getNonStdFontMap;var getGlyphMapForStandardFonts=coreStandardFonts.getGlyphMapForStandardFonts;var getSupplementalGlyphMapForArialBlack=coreStandardFonts.getSupplementalGlyphMapForArialBlack;var getUnicodeRangeFor=coreUnicode.getUnicodeRangeFor;var mapSpecialUnicodeValues=coreUnicode.mapSpecialUnicodeValues;var getUnicodeForGlyph=coreUnicode.getUnicodeForGlyph;var Type1Parser=coreType1Parser.Type1Parser;var CFFStandardStrings=coreCFFParser.CFFStandardStrings;var CFFParser=coreCFFParser.CFFParser;var CFFCompiler=coreCFFParser.CFFCompiler;var CFF=coreCFFParser.CFF;var CFFHeader=coreCFFParser.CFFHeader;var CFFTopDict=coreCFFParser.CFFTopDict;var CFFPrivateDict=coreCFFParser.CFFPrivateDict;var CFFStrings=coreCFFParser.CFFStrings;var CFFIndex=coreCFFParser.CFFIndex;var CFFCharset=coreCFFParser.CFFCharset;var PRIVATE_USE_OFFSET_START=57344;var PRIVATE_USE_OFFSET_END=63743;var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F=false;var PDF_GLYPH_SPACE_UNITS=1e3;var SEAC_ANALYSIS_ENABLED=false;var FontFlags={FixedPitch:1,Serif:2,Symbolic:4,Script:8,Nonsymbolic:32,Italic:64,AllCap:65536,SmallCap:131072,ForceBold:262144};var 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","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","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"];function adjustWidths(properties){if(!properties.fontMatrix){return}if(properties.fontMatrix[0]===FONT_IDENTITY_MATRIX[0]){return}var scale=.001/properties.fontMatrix[0];var glyphsWidths=properties.widths;for(var glyph in glyphsWidths){glyphsWidths[glyph]*=scale}properties.defaultWidth*=scale}function adjustToUnicode(properties,builtInEncoding){if(properties.hasIncludedToUnicodeMap){return}if(properties.hasEncoding){return}if(builtInEncoding===properties.defaultEncoding){return}if(properties.toUnicode instanceof IdentityToUnicodeMap){return}var toUnicode=[],glyphsUnicodeMap=getGlyphsUnicode();for(var charCode in builtInEncoding){var glyphName=builtInEncoding[charCode];var unicode=getUnicodeForGlyph(glyphName,glyphsUnicodeMap);if(unicode!==-1){toUnicode[charCode]=String.fromCharCode(unicode)}}properties.toUnicode.amend(toUnicode)}function getFontType(type,subtype){switch(type){case"Type1":return subtype==="Type1C"?FontType.TYPE1C:FontType.TYPE1;case"CIDFontType0":return subtype==="CIDFontType0C"?FontType.CIDFONTTYPE0C:FontType.CIDFONTTYPE0;case"OpenType":return FontType.OPENTYPE;case"TrueType":return FontType.TRUETYPE;case"CIDFontType2":return FontType.CIDFONTTYPE2;case"MMType1":return FontType.MMTYPE1;case"Type0":return FontType.TYPE0;default:return FontType.UNKNOWN}}function recoverGlyphName(name,glyphsUnicodeMap){if(glyphsUnicodeMap[name]!==undefined){return name}var unicode=getUnicodeForGlyph(name,glyphsUnicodeMap);if(unicode!==-1){for(var key in glyphsUnicodeMap){if(glyphsUnicodeMap[key]===unicode){return key}}}info("Unable to recover a standard glyph name for: "+name);return name}var Glyph=function GlyphClosure(){function Glyph(fontChar,unicode,accent,width,vmetric,operatorListId,isSpace,isInFont){this.fontChar=fontChar;this.unicode=unicode;this.accent=accent;this.width=width;this.vmetric=vmetric;this.operatorListId=operatorListId;this.isSpace=isSpace;this.isInFont=isInFont}Glyph.prototype.matchesForCache=function(fontChar,unicode,accent,width,vmetric,operatorListId,isSpace,isInFont){return this.fontChar===fontChar&&this.unicode===unicode&&this.accent===accent&&this.width===width&&this.vmetric===vmetric&&this.operatorListId===operatorListId&&this.isSpace===isSpace&&this.isInFont===isInFont};return Glyph}();var ToUnicodeMap=function ToUnicodeMapClosure(){function ToUnicodeMap(cmap){this._map=cmap}ToUnicodeMap.prototype={get length(){return this._map.length},forEach:function(callback){for(var charCode in this._map){callback(charCode,this._map[charCode].charCodeAt(0))}},has:function(i){return this._map[i]!==undefined},get:function(i){return this._map[i]},charCodeOf:function(v){return this._map.indexOf(v)},amend:function(map){for(var charCode in map){this._map[charCode]=map[charCode]}}};return ToUnicodeMap}();var IdentityToUnicodeMap=function IdentityToUnicodeMapClosure(){function IdentityToUnicodeMap(firstChar,lastChar){this.firstChar=firstChar;this.lastChar=lastChar}IdentityToUnicodeMap.prototype={get length(){return this.lastChar+1-this.firstChar},forEach:function(callback){for(var i=this.firstChar,ii=this.lastChar;i<=ii;i++){callback(i,i)}},has:function(i){return this.firstChar<=i&&i<=this.lastChar},get:function(i){if(this.firstChar<=i&&i<=this.lastChar){return String.fromCharCode(i)}return undefined},charCodeOf:function(v){return isInt(v)&&v>=this.firstChar&&v<=this.lastChar?v:-1},amend:function(map){error("Should not call amend()")}};return IdentityToUnicodeMap}();var OpenTypeFileBuilder=function OpenTypeFileBuilderClosure(){function writeInt16(dest,offset,num){dest[offset]=num>>8&255;dest[offset+1]=num&255}function writeInt32(dest,offset,num){dest[offset]=num>>24&255;dest[offset+1]=num>>16&255;dest[offset+2]=num>>8&255;dest[offset+3]=num&255}function writeData(dest,offset,data){var i,ii;if(data instanceof Uint8Array){dest.set(data,offset)}else if(typeof data==="string"){for(i=0,ii=data.length;i<ii;i++){dest[offset++]=data.charCodeAt(i)&255}}else{for(i=0,ii=data.length;i<ii;i++){dest[offset++]=data[i]&255}}}function OpenTypeFileBuilder(sfnt){this.sfnt=sfnt;this.tables=Object.create(null)}OpenTypeFileBuilder.getSearchParams=function OpenTypeFileBuilder_getSearchParams(entriesCount,entrySize){var maxPower2=1,log2=0;while((maxPower2^entriesCount)>maxPower2){maxPower2<<=1;log2++}var searchRange=maxPower2*entrySize;return{range:searchRange,entry:log2,rangeShift:entrySize*entriesCount-searchRange}};var OTF_HEADER_SIZE=12;var OTF_TABLE_ENTRY_SIZE=16;OpenTypeFileBuilder.prototype={toArray:function OpenTypeFileBuilder_toArray(){var sfnt=this.sfnt;var tables=this.tables;var tablesNames=Object.keys(tables);tablesNames.sort();var numTables=tablesNames.length;var i,j,jj,table,tableName;var offset=OTF_HEADER_SIZE+numTables*OTF_TABLE_ENTRY_SIZE;var tableOffsets=[offset];for(i=0;i<numTables;i++){table=tables[tablesNames[i]];var paddedLength=(table.length+3&~3)>>>0;offset+=paddedLength;tableOffsets.push(offset)}var file=new Uint8Array(offset);for(i=0;i<numTables;i++){table=tables[tablesNames[i]];writeData(file,tableOffsets[i],table)}if(sfnt==="true"){sfnt=string32(65536)}file[0]=sfnt.charCodeAt(0)&255;file[1]=sfnt.charCodeAt(1)&255;file[2]=sfnt.charCodeAt(2)&255;file[3]=sfnt.charCodeAt(3)&255;writeInt16(file,4,numTables);var searchParams=OpenTypeFileBuilder.getSearchParams(numTables,16);writeInt16(file,6,searchParams.range);writeInt16(file,8,searchParams.entry);writeInt16(file,10,searchParams.rangeShift);offset=OTF_HEADER_SIZE;for(i=0;i<numTables;i++){tableName=tablesNames[i];file[offset]=tableName.charCodeAt(0)&255;file[offset+1]=tableName.charCodeAt(1)&255;file[offset+2]=tableName.charCodeAt(2)&255;file[offset+3]=tableName.charCodeAt(3)&255;var checksum=0;for(j=tableOffsets[i],jj=tableOffsets[i+1];j<jj;j+=4){var quad=readUint32(file,j);checksum=checksum+quad>>>0}writeInt32(file,offset+4,checksum);writeInt32(file,offset+8,tableOffsets[i]);writeInt32(file,offset+12,tables[tableName].length);offset+=OTF_TABLE_ENTRY_SIZE}return file},addTable:function OpenTypeFileBuilder_addTable(tag,data){if(tag in this.tables){throw new Error("Table "+tag+" already exists")}this.tables[tag]=data}};return OpenTypeFileBuilder}();var ProblematicCharRanges=new Int32Array([0,32,127,161,173,174,1536,1920,2208,4256,6016,6144,7168,7248,8192,8208,8209,8210,8232,8240,8287,8304,9676,9677,12288,12289,43616,43648,65520,65536]);var Font=function FontClosure(){function Font(name,file,properties){var charCode,glyphName,unicode;this.name=name;this.loadedName=properties.loadedName;this.isType3Font=properties.isType3Font;this.sizes=[];this.missingFile=false;this.glyphCache=Object.create(null);var names=name.split("+");names=names.length>1?names[1]:names[0];names=names.split(/[-,_]/g)[0];this.isSerifFont=!!(properties.flags&FontFlags.Serif);this.isSymbolicFont=!!(properties.flags&FontFlags.Symbolic);this.isMonospace=!!(properties.flags&FontFlags.FixedPitch);var type=properties.type;var subtype=properties.subtype;this.type=type;this.fallbackName=this.isMonospace?"monospace":this.isSerifFont?"serif":"sans-serif";this.differences=properties.differences;this.widths=properties.widths;this.defaultWidth=properties.defaultWidth;this.composite=properties.composite;this.wideChars=properties.wideChars;this.cMap=properties.cMap;this.ascent=properties.ascent/PDF_GLYPH_SPACE_UNITS;this.descent=properties.descent/PDF_GLYPH_SPACE_UNITS;this.fontMatrix=properties.fontMatrix;this.bbox=properties.bbox;this.toUnicode=properties.toUnicode;this.toFontChar=[];if(properties.type==="Type3"){for(charCode=0;charCode<256;charCode++){this.toFontChar[charCode]=this.differences[charCode]||properties.defaultEncoding[charCode]}this.fontType=FontType.TYPE3;return}this.cidEncoding=properties.cidEncoding;this.vertical=properties.vertical;if(this.vertical){this.vmetrics=properties.vmetrics;this.defaultVMetrics=properties.defaultVMetrics}var glyphsUnicodeMap;if(!file||file.isEmpty){if(file){warn('Font file is empty in "'+name+'" ('+this.loadedName+")")}this.missingFile=true;var fontName=name.replace(/[,_]/g,"-");var stdFontMap=getStdFontMap(),nonStdFontMap=getNonStdFontMap();var isStandardFont=!!stdFontMap[fontName]||!!(nonStdFontMap[fontName]&&stdFontMap[nonStdFontMap[fontName]]);fontName=stdFontMap[fontName]||nonStdFontMap[fontName]||fontName;this.bold=fontName.search(/bold/gi)!==-1;this.italic=fontName.search(/oblique/gi)!==-1||fontName.search(/italic/gi)!==-1;this.black=name.search(/Black/g)!==-1;this.remeasure=Object.keys(this.widths).length>0;if(isStandardFont&&type==="CIDFontType2"&&properties.cidEncoding.indexOf("Identity-")===0){var GlyphMapForStandardFonts=getGlyphMapForStandardFonts();var map=[];for(charCode in GlyphMapForStandardFonts){map[+charCode]=GlyphMapForStandardFonts[charCode]}if(/ArialBlack/i.test(name)){var SupplementalGlyphMapForArialBlack=getSupplementalGlyphMapForArialBlack();for(charCode in SupplementalGlyphMapForArialBlack){map[+charCode]=SupplementalGlyphMapForArialBlack[charCode]}}var isIdentityUnicode=this.toUnicode instanceof IdentityToUnicodeMap;if(!isIdentityUnicode){this.toUnicode.forEach(function(charCode,unicodeCharCode){map[+charCode]=unicodeCharCode})}this.toFontChar=map;this.toUnicode=new ToUnicodeMap(map)}else if(/Symbol/i.test(fontName)){this.toFontChar=buildToFontChar(SymbolSetEncoding,getGlyphsUnicode(),properties.differences)}else if(/Dingbats/i.test(fontName)){if(/Wingdings/i.test(name)){warn("Non-embedded Wingdings font, falling back to ZapfDingbats.")}this.toFontChar=buildToFontChar(ZapfDingbatsEncoding,getDingbatsGlyphsUnicode(),properties.differences)}else if(isStandardFont){this.toFontChar=buildToFontChar(properties.defaultEncoding,getGlyphsUnicode(),properties.differences)}else{glyphsUnicodeMap=getGlyphsUnicode();this.toUnicode.forEach(function(charCode,unicodeCharCode){if(!this.composite){glyphName=properties.differences[charCode]||properties.defaultEncoding[charCode];unicode=getUnicodeForGlyph(glyphName,glyphsUnicodeMap);if(unicode!==-1){unicodeCharCode=unicode}}this.toFontChar[charCode]=unicodeCharCode}.bind(this))}this.loadedName=fontName.split("-")[0];this.loading=false;this.fontType=getFontType(type,subtype);return}if(subtype==="Type1C"){if(type!=="Type1"&&type!=="MMType1"){if(isTrueTypeFile(file)){subtype="TrueType"}else{type="Type1"}}else if(isOpenTypeFile(file)){type=subtype="OpenType"}}if(subtype==="CIDFontType0C"&&type!=="CIDFontType0"){type="CIDFontType0"}if(subtype==="OpenType"){type="OpenType"}if(type==="CIDFontType0"){if(isType1File(file)){subtype="CIDFontType0"}else if(isOpenTypeFile(file)){type=subtype="OpenType"}else{subtype="CIDFontType0C"}}var data;switch(type){case"MMType1":info("MMType1 font ("+name+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";var cff=subtype==="Type1C"||subtype==="CIDFontType0C"?new CFFFont(file,properties):new Type1Font(name,file,properties);adjustWidths(properties);data=this.convert(name,cff,properties);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype";data=this.checkAndRepair(name,file,properties);if(this.isOpenType){adjustWidths(properties);type="OpenType"}break;default:error("Font "+type+" is not supported");break}this.data=data;this.fontType=getFontType(type,subtype);this.fontMatrix=properties.fontMatrix;this.widths=properties.widths;this.defaultWidth=properties.defaultWidth;this.toUnicode=properties.toUnicode;this.encoding=properties.baseEncoding;this.seacMap=properties.seacMap;this.loading=true}Font.getFontID=function(){var ID=1;return function Font_getFontID(){return String(ID++)}}();function int16(b0,b1){return(b0<<8)+b1}function signedInt16(b0,b1){var value=(b0<<8)+b1;return value&1<<15?value-65536:value}function int32(b0,b1,b2,b3){return(b0<<24)+(b1<<16)+(b2<<8)+b3}function string16(value){return String.fromCharCode(value>>8&255,value&255)}function safeString16(value){value=value>32767?32767:value<-32768?-32768:value;return String.fromCharCode(value>>8&255,value&255)}function isTrueTypeFile(file){var header=file.peekBytes(4);return readUint32(header,0)===65536}function isOpenTypeFile(file){var header=file.peekBytes(4);return bytesToString(header)==="OTTO"}function isType1File(file){var header=file.peekBytes(2);if(header[0]===37&&header[1]===33){return true}if(header[0]===128&&header[1]===1){return true}return false}function buildToFontChar(encoding,glyphsUnicodeMap,differences){var toFontChar=[],unicode;for(var i=0,ii=encoding.length;i<ii;i++){unicode=getUnicodeForGlyph(encoding[i],glyphsUnicodeMap);if(unicode!==-1){toFontChar[i]=unicode}}for(var charCode in differences){unicode=getUnicodeForGlyph(differences[charCode],glyphsUnicodeMap);if(unicode!==-1){toFontChar[+charCode]=unicode}}return toFontChar}function isProblematicUnicodeLocation(code){var i=0,j=ProblematicCharRanges.length-1;while(i<j){var c=i+j+1>>1;if(code<ProblematicCharRanges[c]){j=c-1
19}else{i=c}}return!(i&1)}function adjustMapping(charCodeToGlyphId,properties){var toUnicode=properties.toUnicode;var isSymbolic=!!(properties.flags&FontFlags.Symbolic);var isIdentityUnicode=properties.toUnicode instanceof IdentityToUnicodeMap;var newMap=Object.create(null);var toFontChar=[];var usedFontCharCodes=[];var nextAvailableFontCharCode=PRIVATE_USE_OFFSET_START;for(var originalCharCode in charCodeToGlyphId){originalCharCode|=0;var glyphId=charCodeToGlyphId[originalCharCode];var fontCharCode=originalCharCode;if(!isIdentityUnicode&&toUnicode.has(originalCharCode)){var unicode=toUnicode.get(fontCharCode);if(unicode.length===1){fontCharCode=unicode.charCodeAt(0)}}if((usedFontCharCodes[fontCharCode]!==undefined||isProblematicUnicodeLocation(fontCharCode)||isSymbolic&&isIdentityUnicode)&&nextAvailableFontCharCode<=PRIVATE_USE_OFFSET_END){do{fontCharCode=nextAvailableFontCharCode++;if(SKIP_PRIVATE_USE_RANGE_F000_TO_F01F&&fontCharCode===61440){fontCharCode=61472;nextAvailableFontCharCode=fontCharCode+1}}while(usedFontCharCodes[fontCharCode]!==undefined&&nextAvailableFontCharCode<=PRIVATE_USE_OFFSET_END)}newMap[fontCharCode]=glyphId;toFontChar[originalCharCode]=fontCharCode;usedFontCharCodes[fontCharCode]=true}return{toFontChar:toFontChar,charCodeToGlyphId:newMap,nextAvailableFontCharCode:nextAvailableFontCharCode}}function getRanges(glyphs,numGlyphs){var codes=[];for(var charCode in glyphs){if(glyphs[charCode]>=numGlyphs){continue}codes.push({fontCharCode:charCode|0,glyphId:glyphs[charCode]})}codes.sort(function fontGetRangesSort(a,b){return a.fontCharCode-b.fontCharCode});var ranges=[];var length=codes.length;for(var n=0;n<length;){var start=codes[n].fontCharCode;var codeIndices=[codes[n].glyphId];++n;var end=start;while(n<length&&end+1===codes[n].fontCharCode){codeIndices.push(codes[n].glyphId);++end;++n;if(end===65535){break}}ranges.push([start,end,codeIndices])}return ranges}function createCmapTable(glyphs,numGlyphs){var ranges=getRanges(glyphs,numGlyphs);var numTables=ranges[ranges.length-1][1]>65535?2:1;var cmap="\x00\x00"+string16(numTables)+"\x00"+"\x00"+string32(4+numTables*8);var i,ii,j,jj;for(i=ranges.length-1;i>=0;--i){if(ranges[i][0]<=65535){break}}var bmpLength=i+1;if(ranges[i][0]<65535&&ranges[i][1]===65535){ranges[i][1]=65534}var trailingRangesCount=ranges[i][1]<65535?1:0;var segCount=bmpLength+trailingRangesCount;var searchParams=OpenTypeFileBuilder.getSearchParams(segCount,2);var startCount="";var endCount="";var idDeltas="";var idRangeOffsets="";var glyphsIds="";var bias=0;var range,start,end,codes;for(i=0,ii=bmpLength;i<ii;i++){range=ranges[i];start=range[0];end=range[1];startCount+=string16(start);endCount+=string16(end);codes=range[2];var contiguous=true;for(j=1,jj=codes.length;j<jj;++j){if(codes[j]!==codes[j-1]+1){contiguous=false;break}}if(!contiguous){var offset=(segCount-i)*2+bias*2;bias+=end-start+1;idDeltas+=string16(0);idRangeOffsets+=string16(offset);for(j=0,jj=codes.length;j<jj;++j){glyphsIds+=string16(codes[j])}}else{var startCode=codes[0];idDeltas+=string16(startCode-start&65535);idRangeOffsets+=string16(0)}}if(trailingRangesCount>0){endCount+="ÿÿ";startCount+="ÿÿ";idDeltas+="\x00";idRangeOffsets+="\x00\x00"}var format314="\x00\x00"+string16(2*segCount)+string16(searchParams.range)+string16(searchParams.entry)+string16(searchParams.rangeShift)+endCount+"\x00\x00"+startCount+idDeltas+idRangeOffsets+glyphsIds;var format31012="";var header31012="";if(numTables>1){cmap+="\x00"+"\x00\n"+string32(4+numTables*8+4+format314.length);format31012="";for(i=0,ii=ranges.length;i<ii;i++){range=ranges[i];start=range[0];codes=range[2];var code=codes[0];for(j=1,jj=codes.length;j<jj;++j){if(codes[j]!==codes[j-1]+1){end=range[0]+j-1;format31012+=string32(start)+string32(end)+string32(code);start=end+1;code=codes[j]}}format31012+=string32(start)+string32(range[1])+string32(code)}header31012="\x00\f"+"\x00\x00"+string32(format31012.length+16)+"\x00\x00\x00\x00"+string32(format31012.length/12)}return cmap+"\x00"+string16(format314.length+4)+format314+header31012+format31012}function validateOS2Table(os2){var stream=new Stream(os2.data);var version=stream.getUint16();stream.getBytes(60);var selection=stream.getUint16();if(version<4&&selection&768){return false}var firstChar=stream.getUint16();var lastChar=stream.getUint16();if(firstChar>lastChar){return false}stream.getBytes(6);var usWinAscent=stream.getUint16();if(usWinAscent===0){return false}os2.data[8]=os2.data[9]=0;return true}function createOS2Table(properties,charstrings,override){override=override||{unitsPerEm:0,yMax:0,yMin:0,ascent:0,descent:0};var ulUnicodeRange1=0;var ulUnicodeRange2=0;var ulUnicodeRange3=0;var ulUnicodeRange4=0;var firstCharIndex=null;var lastCharIndex=0;if(charstrings){for(var code in charstrings){code|=0;if(firstCharIndex>code||!firstCharIndex){firstCharIndex=code}if(lastCharIndex<code){lastCharIndex=code}var position=getUnicodeRangeFor(code);if(position<32){ulUnicodeRange1|=1<<position}else if(position<64){ulUnicodeRange2|=1<<position-32}else if(position<96){ulUnicodeRange3|=1<<position-64}else if(position<123){ulUnicodeRange4|=1<<position-96}else{error("Unicode ranges Bits > 123 are reserved for internal usage")}}}else{firstCharIndex=0;lastCharIndex=255}var bbox=properties.bbox||[0,0,0,0];var unitsPerEm=override.unitsPerEm||1/(properties.fontMatrix||FONT_IDENTITY_MATRIX)[0];var scale=properties.ascentScaled?1:unitsPerEm/PDF_GLYPH_SPACE_UNITS;var typoAscent=override.ascent||Math.round(scale*(properties.ascent||bbox[3]));var typoDescent=override.descent||Math.round(scale*(properties.descent||bbox[1]));if(typoDescent>0&&properties.descent>0&&bbox[1]<0){typoDescent=-typoDescent}var winAscent=override.yMax||typoAscent;var winDescent=-override.yMin||-typoDescent;return"\x00"+"$"+"ô"+"\x00"+"\x00\x00"+"Š"+"»"+"\x00\x00"+"\x00Œ"+"Š"+"»"+"\x00\x00"+"ß"+"\x001"+""+"\x00\x00"+"\x00\x00"+String.fromCharCode(properties.fixedPitch?9:0)+"\x00\x00\x00\x00\x00\x00"+string32(ulUnicodeRange1)+string32(ulUnicodeRange2)+string32(ulUnicodeRange3)+string32(ulUnicodeRange4)+"*21*"+string16(properties.italicAngle?1:0)+string16(firstCharIndex||properties.firstChar)+string16(lastCharIndex||properties.lastChar)+string16(typoAscent)+string16(typoDescent)+"\x00d"+string16(winAscent)+string16(winDescent)+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"+string16(properties.xHeight)+string16(properties.capHeight)+string16(0)+string16(firstCharIndex||properties.firstChar)+"\x00"}function createPostTable(properties){var angle=Math.floor(properties.italicAngle*Math.pow(2,16));return"\x00\x00\x00"+string32(angle)+"\x00\x00"+"\x00\x00"+string32(properties.fixedPitch)+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"+"\x00\x00\x00\x00"}function createNameTable(name,proto){if(!proto){proto=[[],[]]}var 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]||"",proto[0][7]||"Unknown",proto[0][8]||"Unknown",proto[0][9]||"Unknown"];var stringsUnicode=[];var i,ii,j,jj,str;for(i=0,ii=strings.length;i<ii;i++){str=proto[1][i]||strings[i];var strBufUnicode=[];for(j=0,jj=str.length;j<jj;j++){strBufUnicode.push(string16(str.charCodeAt(j)))}stringsUnicode.push(strBufUnicode.join(""))}var names=[strings,stringsUnicode];var platforms=["\x00","\x00"];var encodings=["\x00\x00","\x00"];var languages=["\x00\x00"," "];var namesRecordCount=strings.length*platforms.length;var nameTable="\x00\x00"+string16(namesRecordCount)+string16(namesRecordCount*12+6);var strOffset=0;for(i=0,ii=platforms.length;i<ii;i++){var strs=names[i];for(j=0,jj=strs.length;j<jj;j++){str=strs[j];var nameRecord=platforms[i]+encodings[i]+languages[i]+string16(j)+string16(str.length)+string16(strOffset);nameTable+=nameRecord;strOffset+=str.length}}nameTable+=strings.join("")+stringsUnicode.join("");return nameTable}Font.prototype={name:null,font:null,mimetype:null,encoding:null,get renderer(){var renderer=FontRendererFactory.create(this,SEAC_ANALYSIS_ENABLED);return shadow(this,"renderer",renderer)},exportData:function Font_exportData(){var data={};for(var i in this){if(this.hasOwnProperty(i)){data[i]=this[i]}}return data},checkAndRepair:function Font_checkAndRepair(name,font,properties){function readTableEntry(file){var tag=bytesToString(file.getBytes(4));var checksum=file.getInt32()>>>0;var offset=file.getInt32()>>>0;var length=file.getInt32()>>>0;var previousPosition=file.pos;file.pos=file.start?file.start:0;file.skip(offset);var data=file.getBytes(length);file.pos=previousPosition;if(tag==="head"){data[8]=data[9]=data[10]=data[11]=0;data[17]|=32}return{tag:tag,checksum:checksum,length:length,offset:offset,data:data}}function readOpenTypeHeader(ttf){return{version:bytesToString(ttf.getBytes(4)),numTables:ttf.getUint16(),searchRange:ttf.getUint16(),entrySelector:ttf.getUint16(),rangeShift:ttf.getUint16()}}function readCmapTable(cmap,font,isSymbolicFont,hasEncoding){if(!cmap){warn("No cmap table available.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:false}}var segment;var start=(font.start?font.start:0)+cmap.offset;font.pos=start;var version=font.getUint16();var numTables=font.getUint16();var potentialTable;var canBreak=false;for(var i=0;i<numTables;i++){var platformId=font.getUint16();var encodingId=font.getUint16();var offset=font.getInt32()>>>0;var useTable=false;if(platformId===0&&encodingId===0){useTable=true}else if(platformId===1&&encodingId===0){useTable=true}else if(platformId===3&&encodingId===1&&(!isSymbolicFont&&hasEncoding||!potentialTable)){useTable=true;if(!isSymbolicFont){canBreak=true}}else if(isSymbolicFont&&platformId===3&&encodingId===0){useTable=true;canBreak=true}if(useTable){potentialTable={platformId:platformId,encodingId:encodingId,offset:offset}}if(canBreak){break}}if(potentialTable){font.pos=start+potentialTable.offset}if(!potentialTable||font.peekByte()===-1){warn("Could not find a preferred cmap table.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:false}}var format=font.getUint16();var length=font.getUint16();var language=font.getUint16();var hasShortCmap=false;var mappings=[];var j,glyphId;if(format===0){for(j=0;j<256;j++){var index=font.getByte();if(!index){continue}mappings.push({charCode:j,glyphId:index})}hasShortCmap=true}else if(format===4){var segCount=font.getUint16()>>1;font.getBytes(6);var segIndex,segments=[];for(segIndex=0;segIndex<segCount;segIndex++){segments.push({end:font.getUint16()})}font.getUint16();for(segIndex=0;segIndex<segCount;segIndex++){segments[segIndex].start=font.getUint16()}for(segIndex=0;segIndex<segCount;segIndex++){segments[segIndex].delta=font.getUint16()}var offsetsCount=0;for(segIndex=0;segIndex<segCount;segIndex++){segment=segments[segIndex];var rangeOffset=font.getUint16();if(!rangeOffset){segment.offsetIndex=-1;continue}var offsetIndex=(rangeOffset>>1)-(segCount-segIndex);segment.offsetIndex=offsetIndex;offsetsCount=Math.max(offsetsCount,offsetIndex+segment.end-segment.start+1)}var offsets=[];for(j=0;j<offsetsCount;j++){offsets.push(font.getUint16())}for(segIndex=0;segIndex<segCount;segIndex++){segment=segments[segIndex];start=segment.start;var end=segment.end;var delta=segment.delta;offsetIndex=segment.offsetIndex;for(j=start;j<=end;j++){if(j===65535){continue}glyphId=offsetIndex<0?j:offsets[offsetIndex+j-start];glyphId=glyphId+delta&65535;if(glyphId===0){continue}mappings.push({charCode:j,glyphId:glyphId})}}}else if(format===6){var firstCode=font.getUint16();var entryCount=font.getUint16();for(j=0;j<entryCount;j++){glyphId=font.getUint16();var charCode=firstCode+j;mappings.push({charCode:charCode,glyphId:glyphId})}}else{warn("cmap table has unsupported format: "+format);return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:false}}mappings.sort(function(a,b){return a.charCode-b.charCode});for(i=1;i<mappings.length;i++){if(mappings[i-1].charCode===mappings[i].charCode){mappings.splice(i,1);i--}}return{platformId:potentialTable.platformId,encodingId:potentialTable.encodingId,mappings:mappings,hasShortCmap:hasShortCmap}}function sanitizeMetrics(font,header,metrics,numGlyphs){if(!header){if(metrics){metrics.data=null}return}font.pos=(font.start?font.start:0)+header.offset;font.pos+=header.length-2;var numOfMetrics=font.getUint16();if(numOfMetrics>numGlyphs){info("The numOfMetrics ("+numOfMetrics+") should not be "+"greater than the numGlyphs ("+numGlyphs+")");numOfMetrics=numGlyphs;header.data[34]=(numOfMetrics&65280)>>8;header.data[35]=numOfMetrics&255}var numOfSidebearings=numGlyphs-numOfMetrics;var numMissing=numOfSidebearings-(metrics.length-numOfMetrics*4>>1);if(numMissing>0){var entries=new Uint8Array(metrics.length+numMissing*2);entries.set(metrics.data);metrics.data=entries}}function sanitizeGlyph(source,sourceStart,sourceEnd,dest,destStart,hintsValid){if(sourceEnd-sourceStart<=12){return 0}var glyf=source.subarray(sourceStart,sourceEnd);var contoursCount=glyf[0]<<8|glyf[1];if(contoursCount&32768){dest.set(glyf,destStart);return glyf.length}var i,j=10,flagsCount=0;for(i=0;i<contoursCount;i++){var endPoint=glyf[j]<<8|glyf[j+1];flagsCount=endPoint+1;j+=2}var instructionsStart=j;var instructionsLength=glyf[j]<<8|glyf[j+1];j+=2+instructionsLength;var instructionsEnd=j;var coordinatesLength=0;for(i=0;i<flagsCount;i++){var flag=glyf[j++];if(flag&192){glyf[j-1]=flag&63}var xyLength=(flag&2?1:flag&16?0:2)+(flag&4?1:flag&32?0:2);coordinatesLength+=xyLength;if(flag&8){var repeat=glyf[j++];i+=repeat;coordinatesLength+=repeat*xyLength}}if(coordinatesLength===0){return 0}var glyphDataLength=j+coordinatesLength;if(glyphDataLength>glyf.length){return 0}if(!hintsValid&&instructionsLength>0){dest.set(glyf.subarray(0,instructionsStart),destStart);dest.set([0,0],destStart+instructionsStart);dest.set(glyf.subarray(instructionsEnd,glyphDataLength),destStart+instructionsStart+2);glyphDataLength-=instructionsLength;if(glyf.length-glyphDataLength>3){glyphDataLength=glyphDataLength+3&~3}return glyphDataLength}if(glyf.length-glyphDataLength>3){glyphDataLength=glyphDataLength+3&~3;dest.set(glyf.subarray(0,glyphDataLength),destStart);return glyphDataLength}dest.set(glyf,destStart);return glyf.length}function sanitizeHead(head,numGlyphs,locaLength){var data=head.data;var version=int32(data[0],data[1],data[2],data[3]);if(version>>16!==1){info("Attempting to fix invalid version in head table: "+version);data[0]=0;data[1]=1;data[2]=0;data[3]=0}var indexToLocFormat=int16(data[50],data[51]);if(indexToLocFormat<0||indexToLocFormat>1){info("Attempting to fix invalid indexToLocFormat in head table: "+indexToLocFormat);var numGlyphsPlusOne=numGlyphs+1;if(locaLength===numGlyphsPlusOne<<1){data[50]=0;data[51]=0}else if(locaLength===numGlyphsPlusOne<<2){data[50]=0;data[51]=1}else{warn("Could not fix indexToLocFormat: "+indexToLocFormat)}}}function sanitizeGlyphLocations(loca,glyf,numGlyphs,isGlyphLocationsLong,hintsValid,dupFirstEntry){var itemSize,itemDecode,itemEncode;if(isGlyphLocationsLong){itemSize=4;itemDecode=function fontItemDecodeLong(data,offset){return data[offset]<<24|data[offset+1]<<16|data[offset+2]<<8|data[offset+3]};itemEncode=function fontItemEncodeLong(data,offset,value){data[offset]=value>>>24&255;data[offset+1]=value>>16&255;data[offset+2]=value>>8&255;data[offset+3]=value&255}}else{itemSize=2;itemDecode=function fontItemDecode(data,offset){return data[offset]<<9|data[offset+1]<<1};itemEncode=function fontItemEncode(data,offset,value){data[offset]=value>>9&255;data[offset+1]=value>>1&255}}var locaData=loca.data;var locaDataSize=itemSize*(1+numGlyphs);if(locaData.length!==locaDataSize){locaData=new Uint8Array(locaDataSize);locaData.set(loca.data.subarray(0,locaDataSize));loca.data=locaData}var oldGlyfData=glyf.data;var oldGlyfDataLength=oldGlyfData.length;var newGlyfData=new Uint8Array(oldGlyfDataLength);var startOffset=itemDecode(locaData,0);var writeOffset=0;var missingGlyphData=Object.create(null);itemEncode(locaData,0,writeOffset);var i,j;for(i=0,j=itemSize;i<numGlyphs;i++,j+=itemSize){var endOffset=itemDecode(locaData,j);if(endOffset>oldGlyfDataLength&&(oldGlyfDataLength+3&~3)===endOffset){endOffset=oldGlyfDataLength}if(endOffset>oldGlyfDataLength){itemEncode(locaData,j,writeOffset);startOffset=endOffset;continue}if(startOffset===endOffset){missingGlyphData[i]=true}var newLength=sanitizeGlyph(oldGlyfData,startOffset,endOffset,newGlyfData,writeOffset,hintsValid);writeOffset+=newLength;itemEncode(locaData,j,writeOffset);startOffset=endOffset}if(writeOffset===0){var simpleGlyph=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(i=0,j=itemSize;i<numGlyphs;i++,j+=itemSize){itemEncode(locaData,j,simpleGlyph.length)}glyf.data=simpleGlyph;return missingGlyphData}if(dupFirstEntry){var firstEntryLength=itemDecode(locaData,itemSize);if(newGlyfData.length>firstEntryLength+writeOffset){glyf.data=newGlyfData.subarray(0,firstEntryLength+writeOffset)}else{glyf.data=new Uint8Array(firstEntryLength+writeOffset);glyf.data.set(newGlyfData.subarray(0,writeOffset))}glyf.data.set(newGlyfData.subarray(0,firstEntryLength),writeOffset);itemEncode(loca.data,locaData.length-itemSize,writeOffset+firstEntryLength)}else{glyf.data=newGlyfData.subarray(0,writeOffset)}return missingGlyphData}function readPostScriptTable(post,properties,maxpNumGlyphs){var start=(font.start?font.start:0)+post.offset;font.pos=start;var length=post.length,end=start+length;var version=font.getInt32();font.getBytes(28);var glyphNames;var valid=true;var i;switch(version){case 65536:glyphNames=MacStandardGlyphOrdering;break;case 131072:var numGlyphs=font.getUint16();if(numGlyphs!==maxpNumGlyphs){valid=false;break}var glyphNameIndexes=[];for(i=0;i<numGlyphs;++i){var index=font.getUint16();if(index>=32768){valid=false;break}glyphNameIndexes.push(index)}if(!valid){break}var customNames=[];var strBuf=[];while(font.pos<end){var stringLength=font.getByte();strBuf.length=stringLength;for(i=0;i<stringLength;++i){strBuf[i]=String.fromCharCode(font.getByte())}customNames.push(strBuf.join(""))}glyphNames=[];for(i=0;i<numGlyphs;++i){var j=glyphNameIndexes[i];if(j<258){glyphNames.push(MacStandardGlyphOrdering[j]);continue}glyphNames.push(customNames[j-258])}break;case 196608:break;default:warn("Unknown/unsupported post table version "+version);valid=false;if(properties.defaultEncoding){glyphNames=properties.defaultEncoding}break}properties.glyphNames=glyphNames;return valid}function readNameTable(nameTable){var start=(font.start?font.start:0)+nameTable.offset;font.pos=start;var names=[[],[]];var length=nameTable.length,end=start+length;var format=font.getUint16();var FORMAT_0_HEADER_LENGTH=6;if(format!==0||length<FORMAT_0_HEADER_LENGTH){return names}var numRecords=font.getUint16();var stringsStart=font.getUint16();var records=[];var NAME_RECORD_LENGTH=12;var i,ii;for(i=0;i<numRecords&&font.pos+NAME_RECORD_LENGTH<=end;i++){var r={platform:font.getUint16(),encoding:font.getUint16(),language:font.getUint16(),name:font.getUint16(),length:font.getUint16(),offset:font.getUint16()};if(r.platform===1&&r.encoding===0&&r.language===0||r.platform===3&&r.encoding===1&&r.language===1033){records.push(r)}}for(i=0,ii=records.length;i<ii;i++){var record=records[i];if(record.length<=0){continue}var pos=start+stringsStart+record.offset;if(pos+record.length>end){continue}font.pos=pos;var nameIndex=record.name;if(record.encoding){var str="";for(var j=0,jj=record.length;j<jj;j+=2){str+=String.fromCharCode(font.getUint16())}names[1][nameIndex]=str}else{names[0][nameIndex]=bytesToString(font.getBytes(record.length))}}return names}var 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];function sanitizeTTProgram(table,ttContext){var data=table.data;var i=0,j,n,b,funcId,pc,lastEndf=0,lastDeff=0;var stack=[];var callstack=[];var functionsCalled=[];var tooComplexToFollowFunctions=ttContext.tooComplexToFollowFunctions;var inFDEF=false,ifLevel=0,inELSE=0;for(var ii=data.length;i<ii;){var op=data[i++];if(op===64){n=data[i++];if(inFDEF||inELSE){i+=n}else{for(j=0;j<n;j++){stack.push(data[i++])}}}else if(op===65){n=data[i++];if(inFDEF||inELSE){i+=n*2}else{for(j=0;j<n;j++){b=data[i++];stack.push(b<<8|data[i++])}}}else if((op&248)===176){n=op-176+1;if(inFDEF||inELSE){i+=n}else{for(j=0;j<n;j++){stack.push(data[i++])}}}else if((op&248)===184){n=op-184+1;if(inFDEF||inELSE){i+=n*2}else{for(j=0;j<n;j++){b=data[i++];stack.push(b<<8|data[i++])}}}else if(op===43&&!tooComplexToFollowFunctions){if(!inFDEF&&!inELSE){funcId=stack[stack.length-1];ttContext.functionsUsed[funcId]=true;if(funcId in ttContext.functionsStackDeltas){stack.length+=ttContext.functionsStackDeltas[funcId]}else if(funcId in ttContext.functionsDefined&&functionsCalled.indexOf(funcId)<0){callstack.push({data:data,i:i,stackTop:stack.length-1});functionsCalled.push(funcId);pc=ttContext.functionsDefined[funcId];if(!pc){warn("TT: CALL non-existent function");ttContext.hintsValid=false;return}data=pc.data;i=pc.i}}}else if(op===44&&!tooComplexToFollowFunctions){if(inFDEF||inELSE){warn("TT: nested FDEFs not allowed");tooComplexToFollowFunctions=true}inFDEF=true;lastDeff=i;funcId=stack.pop();ttContext.functionsDefined[funcId]={data:data,i:i}}else if(op===45){if(inFDEF){inFDEF=false;lastEndf=i}else{pc=callstack.pop();if(!pc){warn("TT: ENDF bad stack");ttContext.hintsValid=false;return}funcId=functionsCalled.pop();data=pc.data;i=pc.i;ttContext.functionsStackDeltas[funcId]=stack.length-pc.stackTop}}else if(op===137){if(inFDEF||inELSE){warn("TT: nested IDEFs not allowed");tooComplexToFollowFunctions=true}inFDEF=true;lastDeff=i}else if(op===88){++ifLevel}else if(op===27){inELSE=ifLevel}else if(op===89){if(inELSE===ifLevel){inELSE=0}--ifLevel}else if(op===28){if(!inFDEF&&!inELSE){var offset=stack[stack.length-1];if(offset>0){i+=offset-1}}}if(!inFDEF&&!inELSE){var stackDelta=op<=142?TTOpsStackDeltas[op]:op>=192&&op<=223?-1:op>=224?-2:0;if(op>=113&&op<=117){n=stack.pop();if(n===n){stackDelta=-n*2}}while(stackDelta<0&&stack.length>0){stack.pop();stackDelta++}while(stackDelta>0){stack.push(NaN);stackDelta--}}}ttContext.tooComplexToFollowFunctions=tooComplexToFollowFunctions;var content=[data];if(i>data.length){content.push(new Uint8Array(i-data.length))}if(lastDeff>lastEndf){warn("TT: complementing a missing function tail");content.push(new Uint8Array([34,45]))}foldTTTable(table,content)}function checkInvalidFunctions(ttContext,maxFunctionDefs){if(ttContext.tooComplexToFollowFunctions){return}if(ttContext.functionsDefined.length>maxFunctionDefs){warn("TT: more functions defined than expected");ttContext.hintsValid=false;return}for(var j=0,jj=ttContext.functionsUsed.length;j<jj;j++){if(j>maxFunctionDefs){warn("TT: invalid function id: "+j);ttContext.hintsValid=false;return}if(ttContext.functionsUsed[j]&&!ttContext.functionsDefined[j]){warn("TT: undefined function: "+j);ttContext.hintsValid=false;return}}}function foldTTTable(table,content){if(content.length>1){var newLength=0;var j,jj;for(j=0,jj=content.length;j<jj;j++){newLength+=content[j].length}newLength=newLength+3&~3;var result=new Uint8Array(newLength);var pos=0;for(j=0,jj=content.length;j<jj;j++){result.set(content[j],pos);pos+=content[j].length}table.data=result;table.length=newLength}}function sanitizeTTPrograms(fpgm,prep,cvt,maxFunctionDefs){var ttContext={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:false,hintsValid:true};if(fpgm){sanitizeTTProgram(fpgm,ttContext)}if(prep){sanitizeTTProgram(prep,ttContext)}if(fpgm){checkInvalidFunctions(ttContext,maxFunctionDefs)}if(cvt&&cvt.length&1){var cvtData=new Uint8Array(cvt.length+1);cvtData.set(cvt.data);cvt.data=cvtData}return ttContext.hintsValid}font=new Stream(new Uint8Array(font.getBytes()));var VALID_TABLES=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "];var header=readOpenTypeHeader(font);var numTables=header.numTables;var cff,cffFile;var tables=Object.create(null);tables["OS/2"]=null;tables["cmap"]=null;tables["head"]=null;tables["hhea"]=null;tables["hmtx"]=null;tables["maxp"]=null;tables["name"]=null;tables["post"]=null;var table;for(var i=0;i<numTables;i++){table=readTableEntry(font);if(VALID_TABLES.indexOf(table.tag)<0){continue}if(table.length===0){continue}tables[table.tag]=table}var isTrueType=!tables["CFF "];if(!isTrueType){if(header.version==="OTTO"&&properties.type!=="CIDFontType2"||!tables["head"]||!tables["hhea"]||!tables["maxp"]||!tables["post"]){cffFile=new Stream(tables["CFF "].data);cff=new CFFFont(cffFile,properties);adjustWidths(properties);return this.convert(name,cff,properties)}delete tables["glyf"];delete tables["loca"];delete tables["fpgm"];delete tables["prep"];delete tables["cvt "];this.isOpenType=true}else{if(!tables["loca"]){error('Required "loca" table is not found')}if(!tables["glyf"]){warn('Required "glyf" table is not found -- trying to recover.');tables["glyf"]={tag:"glyf",data:new Uint8Array(0)}}this.isOpenType=false}if(!tables["maxp"]){error('Required "maxp" table is not found')}font.pos=(font.start||0)+tables["maxp"].offset;var version=font.getInt32();var numGlyphs=font.getUint16();var maxFunctionDefs=0;if(version>=65536&&tables["maxp"].length>=22){font.pos+=8;var maxZones=font.getUint16();if(maxZones>2){tables["maxp"].data[14]=0;tables["maxp"].data[15]=2}font.pos+=4;maxFunctionDefs=font.getUint16()}var dupFirstEntry=false;if(properties.type==="CIDFontType2"&&properties.toUnicode&&properties.toUnicode.get(0)>"\x00"){dupFirstEntry=true;numGlyphs++;tables["maxp"].data[4]=numGlyphs>>8;tables["maxp"].data[5]=numGlyphs&255}var hintsValid=sanitizeTTPrograms(tables["fpgm"],tables["prep"],tables["cvt "],maxFunctionDefs);if(!hintsValid){delete tables["fpgm"];delete tables["prep"];delete tables["cvt "]}sanitizeMetrics(font,tables["hhea"],tables["hmtx"],numGlyphs);if(!tables["head"]){error('Required "head" table is not found')}sanitizeHead(tables["head"],numGlyphs,isTrueType?tables["loca"].length:0);var missingGlyphs=Object.create(null);if(isTrueType){var isGlyphLocationsLong=int16(tables["head"].data[50],tables["head"].data[51]);missingGlyphs=sanitizeGlyphLocations(tables["loca"],tables["glyf"],numGlyphs,isGlyphLocationsLong,hintsValid,dupFirstEntry)}if(!tables["hhea"]){error('Required "hhea" table is not found')}if(tables["hhea"].data[10]===0&&tables["hhea"].data[11]===0){tables["hhea"].data[10]=255;tables["hhea"].data[11]=255}var metricsOverride={unitsPerEm:int16(tables["head"].data[18],tables["head"].data[19]),yMax:int16(tables["head"].data[42],tables["head"].data[43]),yMin:signedInt16(tables["head"].data[38],tables["head"].data[39]),ascent:int16(tables["hhea"].data[4],tables["hhea"].data[5]),descent:signedInt16(tables["hhea"].data[6],tables["hhea"].data[7])};this.ascent=metricsOverride.ascent/metricsOverride.unitsPerEm;this.descent=metricsOverride.descent/metricsOverride.unitsPerEm;if(tables["post"]){var valid=readPostScriptTable(tables["post"],properties,numGlyphs);if(!valid){tables["post"]=null}}var charCodeToGlyphId=[],charCode;var toUnicode=properties.toUnicode,widths=properties.widths;var skipToUnicode=toUnicode instanceof IdentityToUnicodeMap||toUnicode.length===65536;function hasGlyph(glyphId,charCode,widthCode){if(!missingGlyphs[glyphId]){return true}if(!skipToUnicode&&charCode>=0&&toUnicode.has(charCode)){return true}if(widths&&widthCode>=0&&isNum(widths[widthCode])){return true}return false}if(properties.type==="CIDFontType2"){var cidToGidMap=properties.cidToGidMap||[];var isCidToGidMapEmpty=cidToGidMap.length===0;properties.cMap.forEach(function(charCode,cid){assert(cid<=65535,"Max size of CID is 65,535");var glyphId=-1;if(isCidToGidMapEmpty){glyphId=cid}else if(cidToGidMap[cid]!==undefined){glyphId=cidToGidMap[cid]}if(glyphId>=0&&glyphId<numGlyphs&&hasGlyph(glyphId,charCode,cid)){charCodeToGlyphId[charCode]=glyphId}});if(dupFirstEntry&&(isCidToGidMapEmpty||!charCodeToGlyphId[0])){charCodeToGlyphId[0]=numGlyphs-1}}else{var cmapTable=readCmapTable(tables["cmap"],font,this.isSymbolicFont,properties.hasEncoding);var cmapPlatformId=cmapTable.platformId;var cmapEncodingId=cmapTable.encodingId;var cmapMappings=cmapTable.mappings;var cmapMappingsLength=cmapMappings.length;if(properties.hasEncoding&&(cmapPlatformId===3&&cmapEncodingId===1||cmapPlatformId===1&&cmapEncodingId===0)||cmapPlatformId===-1&&cmapEncodingId===-1&&!!getEncoding(properties.baseEncodingName)){var baseEncoding=[];if(properties.baseEncodingName==="MacRomanEncoding"||properties.baseEncodingName==="WinAnsiEncoding"){baseEncoding=getEncoding(properties.baseEncodingName)}var glyphsUnicodeMap=getGlyphsUnicode();for(charCode=0;charCode<256;charCode++){var glyphName,standardGlyphName;if(this.differences&&charCode in this.differences){glyphName=this.differences[charCode]}else if(charCode in baseEncoding&&baseEncoding[charCode]!==""){glyphName=baseEncoding[charCode]}else{glyphName=StandardEncoding[charCode]}if(!glyphName){continue}standardGlyphName=recoverGlyphName(glyphName,glyphsUnicodeMap);var unicodeOrCharCode,isUnicode=false;if(cmapPlatformId===3&&cmapEncodingId===1){unicodeOrCharCode=glyphsUnicodeMap[standardGlyphName];isUnicode=true}else if(cmapPlatformId===1&&cmapEncodingId===0){unicodeOrCharCode=MacRomanEncoding.indexOf(standardGlyphName)}var found=false;for(i=0;i<cmapMappingsLength;++i){if(cmapMappings[i].charCode!==unicodeOrCharCode){continue}var code=isUnicode?charCode:unicodeOrCharCode;if(hasGlyph(cmapMappings[i].glyphId,code,-1)){charCodeToGlyphId[charCode]=cmapMappings[i].glyphId;found=true;break}}if(!found&&properties.glyphNames){var glyphId=properties.glyphNames.indexOf(glyphName);if(glyphId===-1&&standardGlyphName!==glyphName){glyphId=properties.glyphNames.indexOf(standardGlyphName)}if(glyphId>0&&hasGlyph(glyphId,-1,-1)){charCodeToGlyphId[charCode]=glyphId;found=true}}if(!found){charCodeToGlyphId[charCode]=0}}}else if(cmapPlatformId===0&&cmapEncodingId===0){for(i=0;i<cmapMappingsLength;++i){charCodeToGlyphId[cmapMappings[i].charCode]=cmapMappings[i].glyphId}}else{for(i=0;i<cmapMappingsLength;++i){charCode=cmapMappings[i].charCode&255;charCodeToGlyphId[charCode]=cmapMappings[i].glyphId}}}if(charCodeToGlyphId.length===0){charCodeToGlyphId[0]=0}var newMapping=adjustMapping(charCodeToGlyphId,properties);this.toFontChar=newMapping.toFontChar;tables["cmap"]={tag:"cmap",data:createCmapTable(newMapping.charCodeToGlyphId,numGlyphs)};if(!tables["OS/2"]||!validateOS2Table(tables["OS/2"])){tables["OS/2"]={tag:"OS/2",data:createOS2Table(properties,newMapping.charCodeToGlyphId,metricsOverride)}}if(!tables["post"]){tables["post"]={tag:"post",data:createPostTable(properties)}}if(!isTrueType){try{cffFile=new Stream(tables["CFF "].data);var parser=new CFFParser(cffFile,properties,SEAC_ANALYSIS_ENABLED);cff=parser.parse();var compiler=new CFFCompiler(cff);tables["CFF "].data=compiler.compile()}catch(e){warn("Failed to compile font "+properties.loadedName)}}if(!tables["name"]){tables["name"]={tag:"name",data:createNameTable(this.name)}}else{var namePrototype=readNameTable(tables["name"]);tables["name"].data=createNameTable(name,namePrototype)}var builder=new OpenTypeFileBuilder(header.version);for(var tableTag in tables){builder.addTable(tableTag,tables[tableTag].data)}return builder.toArray()},convert:function Font_convert(fontName,font,properties){properties.fixedPitch=false;if(properties.builtInEncoding){adjustToUnicode(properties,properties.builtInEncoding)}var mapping=font.getGlyphMapping(properties);var newMapping=adjustMapping(mapping,properties);this.toFontChar=newMapping.toFontChar;var numGlyphs=font.numGlyphs;function getCharCodes(charCodeToGlyphId,glyphId){var charCodes=null;for(var charCode in charCodeToGlyphId){if(glyphId===charCodeToGlyphId[charCode]){if(!charCodes){charCodes=[]
20}charCodes.push(charCode|0)}}return charCodes}function createCharCode(charCodeToGlyphId,glyphId){for(var charCode in charCodeToGlyphId){if(glyphId===charCodeToGlyphId[charCode]){return charCode|0}}newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode]=glyphId;return newMapping.nextAvailableFontCharCode++}var seacs=font.seacs;if(SEAC_ANALYSIS_ENABLED&&seacs&&seacs.length){var matrix=properties.fontMatrix||FONT_IDENTITY_MATRIX;var charset=font.getCharset();var seacMap=Object.create(null);for(var glyphId in seacs){glyphId|=0;var seac=seacs[glyphId];var baseGlyphName=StandardEncoding[seac[2]];var accentGlyphName=StandardEncoding[seac[3]];var baseGlyphId=charset.indexOf(baseGlyphName);var accentGlyphId=charset.indexOf(accentGlyphName);if(baseGlyphId<0||accentGlyphId<0){continue}var accentOffset={x:seac[0]*matrix[0]+seac[1]*matrix[2]+matrix[4],y:seac[0]*matrix[1]+seac[1]*matrix[3]+matrix[5]};var charCodes=getCharCodes(mapping,glyphId);if(!charCodes){continue}for(var i=0,ii=charCodes.length;i<ii;i++){var charCode=charCodes[i];var charCodeToGlyphId=newMapping.charCodeToGlyphId;var baseFontCharCode=createCharCode(charCodeToGlyphId,baseGlyphId);var accentFontCharCode=createCharCode(charCodeToGlyphId,accentGlyphId);seacMap[charCode]={baseFontCharCode:baseFontCharCode,accentFontCharCode:accentFontCharCode,accentOffset:accentOffset}}}properties.seacMap=seacMap}var unitsPerEm=1/(properties.fontMatrix||FONT_IDENTITY_MATRIX)[0];var builder=new OpenTypeFileBuilder("OTTO");builder.addTable("CFF ",font.data);builder.addTable("OS/2",createOS2Table(properties,newMapping.charCodeToGlyphId));builder.addTable("cmap",createCmapTable(newMapping.charCodeToGlyphId,numGlyphs));builder.addTable("head","\x00\x00\x00"+"\x00\x00\x00"+"\x00\x00\x00\x00"+"_<õ"+"\x00\x00"+safeString16(unitsPerEm)+"\x00\x00\x00\x00ž ~'"+"\x00\x00\x00\x00ž ~'"+"\x00\x00"+safeString16(properties.descent)+"ÿ"+safeString16(properties.ascent)+string16(properties.italicAngle?2:0)+"\x00"+"\x00\x00"+"\x00\x00"+"\x00\x00");builder.addTable("hhea","\x00\x00\x00"+safeString16(properties.ascent)+safeString16(properties.descent)+"\x00\x00"+"ÿÿ"+"\x00\x00"+"\x00\x00"+"\x00\x00"+safeString16(properties.capHeight)+safeString16(Math.tan(properties.italicAngle)*properties.xHeight)+"\x00\x00"+"\x00\x00"+"\x00\x00"+"\x00\x00"+"\x00\x00"+"\x00\x00"+string16(numGlyphs));builder.addTable("hmtx",function fontFieldsHmtx(){var charstrings=font.charstrings;var cffWidths=font.cff?font.cff.widths:null;var hmtx="\x00\x00\x00\x00";for(var i=1,ii=numGlyphs;i<ii;i++){var width=0;if(charstrings){var charstring=charstrings[i-1];width="width"in charstring?charstring.width:0}else if(cffWidths){width=Math.ceil(cffWidths[i]||0)}hmtx+=string16(width)+string16(0)}return hmtx}());builder.addTable("maxp","\x00\x00P\x00"+string16(numGlyphs));builder.addTable("name",createNameTable(fontName));builder.addTable("post",createPostTable(properties));return builder.toArray()},get spaceWidth(){if("_shadowWidth"in this){return this._shadowWidth}var possibleSpaceReplacements=["space","minus","one","i","I"];var width;for(var i=0,ii=possibleSpaceReplacements.length;i<ii;i++){var glyphName=possibleSpaceReplacements[i];if(glyphName in this.widths){width=this.widths[glyphName];break}var glyphsUnicodeMap=getGlyphsUnicode();var glyphUnicode=glyphsUnicodeMap[glyphName];var charcode=0;if(this.composite){if(this.cMap.contains(glyphUnicode)){charcode=this.cMap.lookup(glyphUnicode)}}if(!charcode&&this.toUnicode){charcode=this.toUnicode.charCodeOf(glyphUnicode)}if(charcode<=0){charcode=glyphUnicode}width=this.widths[charcode];if(width){break}}width=width||this.defaultWidth;this._shadowWidth=width;return width},charToGlyph:function Font_charToGlyph(charcode,isSpace){var fontCharCode,width,operatorListId;var widthCode=charcode;if(this.cMap&&this.cMap.contains(charcode)){widthCode=this.cMap.lookup(charcode)}width=this.widths[widthCode];width=isNum(width)?width:this.defaultWidth;var vmetric=this.vmetrics&&this.vmetrics[widthCode];var unicode=this.toUnicode.get(charcode)||charcode;if(typeof unicode==="number"){unicode=String.fromCharCode(unicode)}var isInFont=charcode in this.toFontChar;fontCharCode=this.toFontChar[charcode]||charcode;if(this.missingFile){fontCharCode=mapSpecialUnicodeValues(fontCharCode)}if(this.isType3Font){operatorListId=fontCharCode}var accent=null;if(this.seacMap&&this.seacMap[charcode]){isInFont=true;var seac=this.seacMap[charcode];fontCharCode=seac.baseFontCharCode;accent={fontChar:String.fromCharCode(seac.accentFontCharCode),offset:seac.accentOffset}}var fontChar=String.fromCharCode(fontCharCode);var glyph=this.glyphCache[charcode];if(!glyph||!glyph.matchesForCache(fontChar,unicode,accent,width,vmetric,operatorListId,isSpace,isInFont)){glyph=new Glyph(fontChar,unicode,accent,width,vmetric,operatorListId,isSpace,isInFont);this.glyphCache[charcode]=glyph}return glyph},charsToGlyphs:function Font_charsToGlyphs(chars){var charsCache=this.charsCache;var glyphs,glyph,charcode;if(charsCache){glyphs=charsCache[chars];if(glyphs){return glyphs}}if(!charsCache){charsCache=this.charsCache=Object.create(null)}glyphs=[];var charsCacheKey=chars;var i=0,ii;if(this.cMap){var c=Object.create(null);while(i<chars.length){this.cMap.readCharCode(chars,i,c);charcode=c.charcode;var length=c.length;i+=length;var isSpace=length===1&&chars.charCodeAt(i-1)===32;glyph=this.charToGlyph(charcode,isSpace);glyphs.push(glyph)}}else{for(i=0,ii=chars.length;i<ii;++i){charcode=chars.charCodeAt(i);glyph=this.charToGlyph(charcode,charcode===32);glyphs.push(glyph)}}return charsCache[charsCacheKey]=glyphs}};return Font}();var ErrorFont=function ErrorFontClosure(){function ErrorFont(error){this.error=error;this.loadedName="g_font_error";this.loading=false}ErrorFont.prototype={charsToGlyphs:function ErrorFont_charsToGlyphs(){return[]},exportData:function ErrorFont_exportData(){return{error:this.error}}};return ErrorFont}();function type1FontGlyphMapping(properties,builtInEncoding,glyphNames){var charCodeToGlyphId=Object.create(null);var glyphId,charCode,baseEncoding;if(properties.baseEncodingName){baseEncoding=getEncoding(properties.baseEncodingName);for(charCode=0;charCode<baseEncoding.length;charCode++){glyphId=glyphNames.indexOf(baseEncoding[charCode]);if(glyphId>=0){charCodeToGlyphId[charCode]=glyphId}else{charCodeToGlyphId[charCode]=0}}}else if(!!(properties.flags&FontFlags.Symbolic)){for(charCode in builtInEncoding){charCodeToGlyphId[charCode]=builtInEncoding[charCode]}}else{baseEncoding=StandardEncoding;for(charCode=0;charCode<baseEncoding.length;charCode++){glyphId=glyphNames.indexOf(baseEncoding[charCode]);if(glyphId>=0){charCodeToGlyphId[charCode]=glyphId}else{charCodeToGlyphId[charCode]=0}}}var differences=properties.differences,glyphsUnicodeMap;if(differences){for(charCode in differences){var glyphName=differences[charCode];glyphId=glyphNames.indexOf(glyphName);if(glyphId===-1){if(!glyphsUnicodeMap){glyphsUnicodeMap=getGlyphsUnicode()}var standardGlyphName=recoverGlyphName(glyphName,glyphsUnicodeMap);if(standardGlyphName!==glyphName){glyphId=glyphNames.indexOf(standardGlyphName)}}if(glyphId>=0){charCodeToGlyphId[charCode]=glyphId}else{charCodeToGlyphId[charCode]=0}}}return charCodeToGlyphId}var Type1Font=function Type1FontClosure(){function findBlock(streamBytes,signature,startIndex){var streamBytesLength=streamBytes.length;var signatureLength=signature.length;var scanLength=streamBytesLength-signatureLength;var i=startIndex,j,found=false;while(i<scanLength){j=0;while(j<signatureLength&&streamBytes[i+j]===signature[j]){j++}if(j>=signatureLength){i+=j;while(i<streamBytesLength&&isSpace(streamBytes[i])){i++}found=true;break}i++}return{found:found,length:i}}function getHeaderBlock(stream,suggestedLength){var EEXEC_SIGNATURE=[101,101,120,101,99];var streamStartPos=stream.pos;var headerBytes,headerBytesLength,block;try{headerBytes=stream.getBytes(suggestedLength);headerBytesLength=headerBytes.length}catch(ex){if(ex instanceof MissingDataException){throw ex}}if(headerBytesLength===suggestedLength){block=findBlock(headerBytes,EEXEC_SIGNATURE,suggestedLength-2*EEXEC_SIGNATURE.length);if(block.found&&block.length===suggestedLength){return{stream:new Stream(headerBytes),length:suggestedLength}}}warn('Invalid "Length1" property in Type1 font -- trying to recover.');stream.pos=streamStartPos;var SCAN_BLOCK_LENGTH=2048;var actualLength;while(true){var scanBytes=stream.peekBytes(SCAN_BLOCK_LENGTH);block=findBlock(scanBytes,EEXEC_SIGNATURE,0);if(block.length===0){break}stream.pos+=block.length;if(block.found){actualLength=stream.pos-streamStartPos;break}}stream.pos=streamStartPos;if(actualLength){return{stream:new Stream(stream.getBytes(actualLength)),length:actualLength}}warn('Unable to recover "Length1" property in Type1 font -- using as is.');return{stream:new Stream(stream.getBytes(suggestedLength)),length:suggestedLength}}function getEexecBlock(stream,suggestedLength){var eexecBytes=stream.getBytes();return{stream:new Stream(eexecBytes),length:eexecBytes.length}}function Type1Font(name,file,properties){var PFB_HEADER_SIZE=6;var headerBlockLength=properties.length1;var eexecBlockLength=properties.length2;var pfbHeader=file.peekBytes(PFB_HEADER_SIZE);var pfbHeaderPresent=pfbHeader[0]===128&&pfbHeader[1]===1;if(pfbHeaderPresent){file.skip(PFB_HEADER_SIZE);headerBlockLength=pfbHeader[5]<<24|pfbHeader[4]<<16|pfbHeader[3]<<8|pfbHeader[2]}var headerBlock=getHeaderBlock(file,headerBlockLength);headerBlockLength=headerBlock.length;var headerBlockParser=new Type1Parser(headerBlock.stream,false,SEAC_ANALYSIS_ENABLED);headerBlockParser.extractFontHeader(properties);if(pfbHeaderPresent){pfbHeader=file.getBytes(PFB_HEADER_SIZE);eexecBlockLength=pfbHeader[5]<<24|pfbHeader[4]<<16|pfbHeader[3]<<8|pfbHeader[2]}var eexecBlock=getEexecBlock(file,eexecBlockLength);eexecBlockLength=eexecBlock.length;var eexecBlockParser=new Type1Parser(eexecBlock.stream,true,SEAC_ANALYSIS_ENABLED);var data=eexecBlockParser.extractFontProgram();for(var info in data.properties){properties[info]=data.properties[info]}var charstrings=data.charstrings;var type2Charstrings=this.getType2Charstrings(charstrings);var subrs=this.getType2Subrs(data.subrs);this.charstrings=charstrings;this.data=this.wrap(name,type2Charstrings,this.charstrings,subrs,properties);this.seacs=this.getSeacs(data.charstrings)}Type1Font.prototype={get numGlyphs(){return this.charstrings.length+1},getCharset:function Type1Font_getCharset(){var charset=[".notdef"];var charstrings=this.charstrings;for(var glyphId=0;glyphId<charstrings.length;glyphId++){charset.push(charstrings[glyphId].glyphName)}return charset},getGlyphMapping:function Type1Font_getGlyphMapping(properties){var charstrings=this.charstrings;var glyphNames=[".notdef"],glyphId;for(glyphId=0;glyphId<charstrings.length;glyphId++){glyphNames.push(charstrings[glyphId].glyphName)}var encoding=properties.builtInEncoding;if(encoding){var builtInEncoding=Object.create(null);for(var charCode in encoding){glyphId=glyphNames.indexOf(encoding[charCode]);if(glyphId>=0){builtInEncoding[charCode]=glyphId}}}return type1FontGlyphMapping(properties,builtInEncoding,glyphNames)},getSeacs:function Type1Font_getSeacs(charstrings){var i,ii;var seacMap=[];for(i=0,ii=charstrings.length;i<ii;i++){var charstring=charstrings[i];if(charstring.seac){seacMap[i+1]=charstring.seac}}return seacMap},getType2Charstrings:function Type1Font_getType2Charstrings(type1Charstrings){var type2Charstrings=[];for(var i=0,ii=type1Charstrings.length;i<ii;i++){type2Charstrings.push(type1Charstrings[i].charstring)}return type2Charstrings},getType2Subrs:function Type1Font_getType2Subrs(type1Subrs){var bias=0;var count=type1Subrs.length;if(count<1133){bias=107}else if(count<33769){bias=1131}else{bias=32768}var type2Subrs=[];var i;for(i=0;i<bias;i++){type2Subrs.push([11])}for(i=0;i<count;i++){type2Subrs.push(type1Subrs[i])}return type2Subrs},wrap:function Type1Font_wrap(name,glyphs,charstrings,subrs,properties){var cff=new CFF;cff.header=new CFFHeader(1,0,4,4);cff.names=[name];var topDict=new CFFTopDict;topDict.setByName("version",391);topDict.setByName("Notice",392);topDict.setByName("FullName",393);topDict.setByName("FamilyName",394);topDict.setByName("Weight",395);topDict.setByName("Encoding",null);topDict.setByName("FontMatrix",properties.fontMatrix);topDict.setByName("FontBBox",properties.bbox);topDict.setByName("charset",null);topDict.setByName("CharStrings",null);topDict.setByName("Private",null);cff.topDict=topDict;var strings=new CFFStrings;strings.add("Version 0.11");strings.add("See original notice");strings.add(name);strings.add(name);strings.add("Medium");cff.strings=strings;cff.globalSubrIndex=new CFFIndex;var count=glyphs.length;var charsetArray=[0];var i,ii;for(i=0;i<count;i++){var index=CFFStandardStrings.indexOf(charstrings[i].glyphName);if(index===-1){index=0}charsetArray.push(index>>8&255,index&255)}cff.charset=new CFFCharset(false,0,[],charsetArray);var charStringsIndex=new CFFIndex;charStringsIndex.add([139,14]);for(i=0;i<count;i++){var glyph=glyphs[i];if(glyph.length===0){charStringsIndex.add([139,14]);continue}charStringsIndex.add(glyph)}cff.charStrings=charStringsIndex;var privateDict=new CFFPrivateDict;privateDict.setByName("Subrs",null);var fields=["BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StemSnapH","StemSnapV","BlueShift","BlueFuzz","BlueScale","LanguageGroup","ExpansionFactor","ForceBold","StdHW","StdVW"];for(i=0,ii=fields.length;i<ii;i++){var field=fields[i];if(!(field in properties.privateData)){continue}var value=properties.privateData[field];if(isArray(value)){for(var j=value.length-1;j>0;j--){value[j]-=value[j-1]}}privateDict.setByName(field,value)}cff.topDict.privateDict=privateDict;var subrIndex=new CFFIndex;for(i=0,ii=subrs.length;i<ii;i++){subrIndex.add(subrs[i])}privateDict.subrsIndex=subrIndex;var compiler=new CFFCompiler(cff);return compiler.compile()}};return Type1Font}();var CFFFont=function CFFFontClosure(){function CFFFont(file,properties){this.properties=properties;var parser=new CFFParser(file,properties,SEAC_ANALYSIS_ENABLED);this.cff=parser.parse();var compiler=new CFFCompiler(this.cff);this.seacs=this.cff.seacs;try{this.data=compiler.compile()}catch(e){warn("Failed to compile font "+properties.loadedName);this.data=file}}CFFFont.prototype={get numGlyphs(){return this.cff.charStrings.count},getCharset:function CFFFont_getCharset(){return this.cff.charset.charset},getGlyphMapping:function CFFFont_getGlyphMapping(){var cff=this.cff;var properties=this.properties;var charsets=cff.charset.charset;var charCodeToGlyphId;var glyphId;if(properties.composite){charCodeToGlyphId=Object.create(null);if(cff.isCIDFont){for(glyphId=0;glyphId<charsets.length;glyphId++){var cid=charsets[glyphId];var charCode=properties.cMap.charCodeOf(cid);charCodeToGlyphId[charCode]=glyphId}}else{for(glyphId=0;glyphId<cff.charStrings.count;glyphId++){charCodeToGlyphId[glyphId]=glyphId}}return charCodeToGlyphId}var encoding=cff.encoding?cff.encoding.encoding:null;charCodeToGlyphId=type1FontGlyphMapping(properties,encoding,charsets);return charCodeToGlyphId}};return CFFFont}();(function checkSeacSupport(){if(typeof navigator!=="undefined"&&/Windows/.test(navigator.userAgent)){SEAC_ANALYSIS_ENABLED=true}})();(function checkChromeWindows(){if(typeof navigator!=="undefined"&&/Windows.*Chrome/.test(navigator.userAgent)){SKIP_PRIVATE_USE_RANGE_F000_TO_F01F=true}})();exports.SEAC_ANALYSIS_ENABLED=SEAC_ANALYSIS_ENABLED;exports.ErrorFont=ErrorFont;exports.Font=Font;exports.FontFlags=FontFlags;exports.IdentityToUnicodeMap=IdentityToUnicodeMap;exports.ToUnicodeMap=ToUnicodeMap;exports.getFontType=getFontType});(function(root,factory){{factory(root.pdfjsCorePsParser={},root.pdfjsSharedUtil,root.pdfjsCoreParser)}})(this,function(exports,sharedUtil,coreParser){var error=sharedUtil.error;var isSpace=sharedUtil.isSpace;var EOF=coreParser.EOF;var PostScriptParser=function PostScriptParserClosure(){function PostScriptParser(lexer){this.lexer=lexer;this.operators=[];this.token=null;this.prev=null}PostScriptParser.prototype={nextToken:function PostScriptParser_nextToken(){this.prev=this.token;this.token=this.lexer.getToken()},accept:function PostScriptParser_accept(type){if(this.token.type===type){this.nextToken();return true}return false},expect:function PostScriptParser_expect(type){if(this.accept(type)){return true}error("Unexpected symbol: found "+this.token.type+" expected "+type+".")},parse:function PostScriptParser_parse(){this.nextToken();this.expect(PostScriptTokenTypes.LBRACE);this.parseBlock();this.expect(PostScriptTokenTypes.RBRACE);return this.operators},parseBlock:function PostScriptParser_parseBlock(){while(true){if(this.accept(PostScriptTokenTypes.NUMBER)){this.operators.push(this.prev.value)}else if(this.accept(PostScriptTokenTypes.OPERATOR)){this.operators.push(this.prev.value)}else if(this.accept(PostScriptTokenTypes.LBRACE)){this.parseCondition()}else{return}}},parseCondition:function PostScriptParser_parseCondition(){var conditionLocation=this.operators.length;this.operators.push(null,null);this.parseBlock();this.expect(PostScriptTokenTypes.RBRACE);if(this.accept(PostScriptTokenTypes.IF)){this.operators[conditionLocation]=this.operators.length;this.operators[conditionLocation+1]="jz"}else if(this.accept(PostScriptTokenTypes.LBRACE)){var jumpLocation=this.operators.length;this.operators.push(null,null);var endOfTrue=this.operators.length;this.parseBlock();this.expect(PostScriptTokenTypes.RBRACE);this.expect(PostScriptTokenTypes.IFELSE);this.operators[jumpLocation]=this.operators.length;this.operators[jumpLocation+1]="j";this.operators[conditionLocation]=endOfTrue;this.operators[conditionLocation+1]="jz"}else{error("PS Function: error parsing conditional.")}}};return PostScriptParser}();var PostScriptTokenTypes={LBRACE:0,RBRACE:1,NUMBER:2,OPERATOR:3,IF:4,IFELSE:5};var PostScriptToken=function PostScriptTokenClosure(){function PostScriptToken(type,value){this.type=type;this.value=value}var opCache=Object.create(null);PostScriptToken.getOperator=function PostScriptToken_getOperator(op){var opValue=opCache[op];if(opValue){return opValue}return opCache[op]=new PostScriptToken(PostScriptTokenTypes.OPERATOR,op)};PostScriptToken.LBRACE=new PostScriptToken(PostScriptTokenTypes.LBRACE,"{");PostScriptToken.RBRACE=new PostScriptToken(PostScriptTokenTypes.RBRACE,"}");PostScriptToken.IF=new PostScriptToken(PostScriptTokenTypes.IF,"IF");PostScriptToken.IFELSE=new PostScriptToken(PostScriptTokenTypes.IFELSE,"IFELSE");return PostScriptToken}();var PostScriptLexer=function PostScriptLexerClosure(){function PostScriptLexer(stream){this.stream=stream;this.nextChar();this.strBuf=[]}PostScriptLexer.prototype={nextChar:function PostScriptLexer_nextChar(){return this.currentChar=this.stream.getByte()},getToken:function PostScriptLexer_getToken(){var comment=false;var ch=this.currentChar;while(true){if(ch<0){return EOF}if(comment){if(ch===10||ch===13){comment=false}}else if(ch===37){comment=true}else if(!isSpace(ch)){break}ch=this.nextChar()}switch(ch|0){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return new PostScriptToken(PostScriptTokenTypes.NUMBER,this.getNumber());case 123:this.nextChar();return PostScriptToken.LBRACE;case 125:this.nextChar();return PostScriptToken.RBRACE}var strBuf=this.strBuf;strBuf.length=0;strBuf[0]=String.fromCharCode(ch);while((ch=this.nextChar())>=0&&(ch>=65&&ch<=90||ch>=97&&ch<=122)){strBuf.push(String.fromCharCode(ch))}var str=strBuf.join("");switch(str.toLowerCase()){case"if":return PostScriptToken.IF;case"ifelse":return PostScriptToken.IFELSE;default:return PostScriptToken.getOperator(str)}},getNumber:function PostScriptLexer_getNumber(){var ch=this.currentChar;var strBuf=this.strBuf;strBuf.length=0;strBuf[0]=String.fromCharCode(ch);while((ch=this.nextChar())>=0){if(ch>=48&&ch<=57||ch===45||ch===46){strBuf.push(String.fromCharCode(ch))}else{break}}var value=parseFloat(strBuf.join(""));if(isNaN(value)){error("Invalid floating point number: "+value)}return value}};return PostScriptLexer}();exports.PostScriptLexer=PostScriptLexer;exports.PostScriptParser=PostScriptParser});(function(root,factory){{factory(root.pdfjsCoreFunction={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCorePsParser)}})(this,function(exports,sharedUtil,corePrimitives,corePsParser){var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var isBool=sharedUtil.isBool;var isDict=corePrimitives.isDict;var isStream=corePrimitives.isStream;var PostScriptLexer=corePsParser.PostScriptLexer;var PostScriptParser=corePsParser.PostScriptParser;var PDFFunction=function PDFFunctionClosure(){var CONSTRUCT_SAMPLED=0;var CONSTRUCT_INTERPOLATED=2;var CONSTRUCT_STICHED=3;var CONSTRUCT_POSTSCRIPT=4;return{getSampleArray:function PDFFunction_getSampleArray(size,outputSize,bps,str){var i,ii;var length=1;for(i=0,ii=size.length;i<ii;i++){length*=size[i]}length*=outputSize;var array=new Array(length);var codeSize=0;var codeBuf=0;var sampleMul=1/(Math.pow(2,bps)-1);var strBytes=str.getBytes((length*bps+7)/8);var strIdx=0;for(i=0;i<length;i++){while(codeSize<bps){codeBuf<<=8;codeBuf|=strBytes[strIdx++];codeSize+=8}codeSize-=bps;array[i]=(codeBuf>>codeSize)*sampleMul;codeBuf&=(1<<codeSize)-1}return array},getIR:function PDFFunction_getIR(xref,fn){var dict=fn.dict;if(!dict){dict=fn}var types=[this.constructSampled,null,this.constructInterpolated,this.constructStiched,this.constructPostScript];var typeNum=dict.get("FunctionType");var typeFn=types[typeNum];if(!typeFn){error("Unknown type of function")}return typeFn.call(this,fn,dict,xref)},fromIR:function PDFFunction_fromIR(IR){var type=IR[0];switch(type){case CONSTRUCT_SAMPLED:return this.constructSampledFromIR(IR);case CONSTRUCT_INTERPOLATED:return this.constructInterpolatedFromIR(IR);case CONSTRUCT_STICHED:return this.constructStichedFromIR(IR);default:return this.constructPostScriptFromIR(IR)}},parse:function PDFFunction_parse(xref,fn){var IR=this.getIR(xref,fn);return this.fromIR(IR)},parseArray:function PDFFunction_parseArray(xref,fnObj){if(!isArray(fnObj)){return this.parse(xref,fnObj)}var fnArray=[];for(var j=0,jj=fnObj.length;j<jj;j++){var obj=xref.fetchIfRef(fnObj[j]);fnArray.push(PDFFunction.parse(xref,obj))}return function(src,srcOffset,dest,destOffset){for(var i=0,ii=fnArray.length;i<ii;i++){fnArray[i](src,srcOffset,dest,destOffset+i)}}},constructSampled:function PDFFunction_constructSampled(str,dict){function toMultiArray(arr){var inputLength=arr.length;var out=[];var index=0;for(var i=0;i<inputLength;i+=2){out[index]=[arr[i],arr[i+1]];++index}return out}var domain=dict.getArray("Domain");var range=dict.getArray("Range");if(!domain||!range){error("No domain or range")}var inputSize=domain.length/2;var outputSize=range.length/2;domain=toMultiArray(domain);range=toMultiArray(range);var size=dict.get("Size");var bps=dict.get("BitsPerSample");var order=dict.get("Order")||1;if(order!==1){info("No support for cubic spline interpolation: "+order)}var encode=dict.getArray("Encode");if(!encode){encode=[];for(var i=0;i<inputSize;++i){encode.push(0);encode.push(size[i]-1)}}encode=toMultiArray(encode);var decode=dict.getArray("Decode");if(!decode){decode=range}else{decode=toMultiArray(decode)}var samples=this.getSampleArray(size,outputSize,bps,str);return[CONSTRUCT_SAMPLED,inputSize,domain,encode,decode,samples,size,outputSize,Math.pow(2,bps)-1,range]},constructSampledFromIR:function PDFFunction_constructSampledFromIR(IR){function interpolate(x,xmin,xmax,ymin,ymax){return ymin+(x-xmin)*((ymax-ymin)/(xmax-xmin))}return function constructSampledFromIRResult(src,srcOffset,dest,destOffset){var m=IR[1];var domain=IR[2];var encode=IR[3];var decode=IR[4];var samples=IR[5];var size=IR[6];var n=IR[7];var range=IR[9];var cubeVertices=1<<m;var cubeN=new Float64Array(cubeVertices);var cubeVertex=new Uint32Array(cubeVertices);var i,j;for(j=0;j<cubeVertices;j++){cubeN[j]=1}var k=n,pos=1;for(i=0;i<m;++i){var domain_2i=domain[i][0];var domain_2i_1=domain[i][1];var xi=Math.min(Math.max(src[srcOffset+i],domain_2i),domain_2i_1);var e=interpolate(xi,domain_2i,domain_2i_1,encode[i][0],encode[i][1]);var size_i=size[i];e=Math.min(Math.max(e,0),size_i-1);var e0=e<size_i-1?Math.floor(e):e-1;var n0=e0+1-e;var n1=e-e0;var offset0=e0*k;var offset1=offset0+k;for(j=0;j<cubeVertices;j++){if(j&pos){cubeN[j]*=n1;cubeVertex[j]+=offset1}else{cubeN[j]*=n0;cubeVertex[j]+=offset0}}k*=size_i;pos<<=1}for(j=0;j<n;++j){var rj=0;for(i=0;i<cubeVertices;i++){rj+=samples[cubeVertex[i]+j]*cubeN[i]}rj=interpolate(rj,0,1,decode[j][0],decode[j][1]);dest[destOffset+j]=Math.min(Math.max(rj,range[j][0]),range[j][1])}}},constructInterpolated:function PDFFunction_constructInterpolated(str,dict){var c0=dict.getArray("C0")||[0];var c1=dict.getArray("C1")||[1];var n=dict.get("N");if(!isArray(c0)||!isArray(c1)){error("Illegal dictionary for interpolated function")}var length=c0.length;var diff=[];for(var i=0;i<length;++i){diff.push(c1[i]-c0[i])}return[CONSTRUCT_INTERPOLATED,c0,diff,n]},constructInterpolatedFromIR:function PDFFunction_constructInterpolatedFromIR(IR){var c0=IR[1];var diff=IR[2];var n=IR[3];var length=diff.length;return function constructInterpolatedFromIRResult(src,srcOffset,dest,destOffset){var x=n===1?src[srcOffset]:Math.pow(src[srcOffset],n);for(var j=0;j<length;++j){dest[destOffset+j]=c0[j]+x*diff[j]}}},constructStiched:function PDFFunction_constructStiched(fn,dict,xref){var domain=dict.getArray("Domain");if(!domain){error("No domain")}var inputSize=domain.length/2;if(inputSize!==1){error("Bad domain for stiched function")}var fnRefs=dict.get("Functions");var fns=[];for(var i=0,ii=fnRefs.length;i<ii;++i){fns.push(PDFFunction.getIR(xref,xref.fetchIfRef(fnRefs[i])))}var bounds=dict.getArray("Bounds");var encode=dict.getArray("Encode");return[CONSTRUCT_STICHED,domain,bounds,encode,fns]},constructStichedFromIR:function PDFFunction_constructStichedFromIR(IR){var domain=IR[1];var bounds=IR[2];var encode=IR[3];var fnsIR=IR[4];var fns=[];var tmpBuf=new Float32Array(1);for(var i=0,ii=fnsIR.length;i<ii;i++){fns.push(PDFFunction.fromIR(fnsIR[i]))}return function constructStichedFromIRResult(src,srcOffset,dest,destOffset){var clip=function constructStichedFromIRClip(v,min,max){if(v>max){v=max}else if(v<min){v=min}return v};var v=clip(src[srcOffset],domain[0],domain[1]);for(var i=0,ii=bounds.length;i<ii;++i){if(v<bounds[i]){break}}var dmin=domain[0];if(i>0){dmin=bounds[i-1]}var dmax=domain[1];if(i<bounds.length){dmax=bounds[i]}var rmin=encode[2*i];var rmax=encode[2*i+1];tmpBuf[0]=dmin===dmax?rmin:rmin+(v-dmin)*(rmax-rmin)/(dmax-dmin);fns[i](tmpBuf,0,dest,destOffset)}},constructPostScript:function PDFFunction_constructPostScript(fn,dict,xref){var domain=dict.getArray("Domain");var range=dict.getArray("Range");if(!domain){error("No domain.")}if(!range){error("No range.")}var lexer=new PostScriptLexer(fn);var parser=new PostScriptParser(lexer);var code=parser.parse();return[CONSTRUCT_POSTSCRIPT,domain,range,code]},constructPostScriptFromIR:function PDFFunction_constructPostScriptFromIR(IR){var domain=IR[1];var range=IR[2];var code=IR[3];var compiled=(new PostScriptCompiler).compile(code,domain,range);if(compiled){return new Function("src","srcOffset","dest","destOffset",compiled)}info("Unable to compile PS function");var numOutputs=range.length>>1;var numInputs=domain.length>>1;var evaluator=new PostScriptEvaluator(code);var cache=Object.create(null);var MAX_CACHE_SIZE=2048*4;var cache_available=MAX_CACHE_SIZE;var tmpBuf=new Float32Array(numInputs);return function constructPostScriptFromIRResult(src,srcOffset,dest,destOffset){var i,value;var key="";var input=tmpBuf;for(i=0;i<numInputs;i++){value=src[srcOffset+i];input[i]=value;key+=value+"_"}var cachedValue=cache[key];if(cachedValue!==undefined){dest.set(cachedValue,destOffset);return}var output=new Float32Array(numOutputs);var stack=evaluator.execute(input);var stackIndex=stack.length-numOutputs;for(i=0;i<numOutputs;i++){value=stack[stackIndex+i];var bound=range[i*2];if(value<bound){value=bound}else{bound=range[i*2+1];if(value>bound){value=bound}}output[i]=value}if(cache_available>0){cache_available--;cache[key]=output}dest.set(output,destOffset)}}}}();function isPDFFunction(v){var fnDict;if(typeof v!=="object"){return false}else if(isDict(v)){fnDict=v}else if(isStream(v)){fnDict=v.dict}else{return false}return fnDict.has("FunctionType")}var PostScriptStack=function PostScriptStackClosure(){var MAX_STACK_SIZE=100;function PostScriptStack(initialStack){this.stack=!initialStack?[]:Array.prototype.slice.call(initialStack,0)}PostScriptStack.prototype={push:function PostScriptStack_push(value){if(this.stack.length>=MAX_STACK_SIZE){error("PostScript function stack overflow.")}this.stack.push(value)},pop:function PostScriptStack_pop(){if(this.stack.length<=0){error("PostScript function stack underflow.")}return this.stack.pop()},copy:function PostScriptStack_copy(n){if(this.stack.length+n>=MAX_STACK_SIZE){error("PostScript function stack overflow.")}var stack=this.stack;for(var i=stack.length-n,j=n-1;j>=0;j--,i++){stack.push(stack[i])}},index:function PostScriptStack_index(n){this.push(this.stack[this.stack.length-n-1])},roll:function PostScriptStack_roll(n,p){var stack=this.stack;var l=stack.length-n;var r=stack.length-1,c=l+(p-Math.floor(p/n)*n),i,j,t;for(i=l,j=r;i<j;i++,j--){t=stack[i];stack[i]=stack[j];stack[j]=t}for(i=l,j=c-1;i<j;i++,j--){t=stack[i];stack[i]=stack[j];stack[j]=t}for(i=c,j=r;i<j;i++,j--){t=stack[i];stack[i]=stack[j];stack[j]=t}}};return PostScriptStack}();var PostScriptEvaluator=function PostScriptEvaluatorClosure(){function PostScriptEvaluator(operators){this.operators=operators}PostScriptEvaluator.prototype={execute:function PostScriptEvaluator_execute(initialStack){var stack=new PostScriptStack(initialStack);var counter=0;var operators=this.operators;var length=operators.length;var operator,a,b;while(counter<length){operator=operators[counter++];if(typeof operator==="number"){stack.push(operator);continue}switch(operator){case"jz":b=stack.pop();a=stack.pop();if(!a){counter=b}break;case"j":a=stack.pop();counter=a;break;case"abs":a=stack.pop();stack.push(Math.abs(a));break;case"add":b=stack.pop();a=stack.pop();stack.push(a+b);break;case"and":b=stack.pop();a=stack.pop();if(isBool(a)&&isBool(b)){stack.push(a&&b)}else{stack.push(a&b)}break;case"atan":a=stack.pop();stack.push(Math.atan(a));break;case"bitshift":b=stack.pop();a=stack.pop();if(a>0){stack.push(a<<b)}else{stack.push(a>>b)}break;case"ceiling":a=stack.pop();stack.push(Math.ceil(a));break;case"copy":a=stack.pop();stack.copy(a);break;case"cos":a=stack.pop();stack.push(Math.cos(a));break;case"cvi":a=stack.pop()|0;stack.push(a);break;case"cvr":break;case"div":b=stack.pop();a=stack.pop();stack.push(a/b);break;case"dup":stack.copy(1);break;case"eq":b=stack.pop();a=stack.pop();stack.push(a===b);break;case"exch":stack.roll(2,1);break;case"exp":b=stack.pop();a=stack.pop();stack.push(Math.pow(a,b));break;case"false":stack.push(false);break;case"floor":a=stack.pop();stack.push(Math.floor(a));break;case"ge":b=stack.pop();a=stack.pop();stack.push(a>=b);break;case"gt":b=stack.pop();a=stack.pop();stack.push(a>b);break;case"idiv":b=stack.pop();a=stack.pop();stack.push(a/b|0);break;case"index":a=stack.pop();stack.index(a);break;case"le":b=stack.pop();a=stack.pop();stack.push(a<=b);break;case"ln":a=stack.pop();stack.push(Math.log(a));break;case"log":a=stack.pop();stack.push(Math.log(a)/Math.LN10);break;case"lt":b=stack.pop();a=stack.pop();stack.push(a<b);break;case"mod":b=stack.pop();a=stack.pop();stack.push(a%b);break;case"mul":b=stack.pop();a=stack.pop();stack.push(a*b);break;case"ne":b=stack.pop();a=stack.pop();stack.push(a!==b);break;case"neg":a=stack.pop();stack.push(-a);break;case"not":a=stack.pop();if(isBool(a)){stack.push(!a)}else{stack.push(~a)}break;case"or":b=stack.pop();a=stack.pop();if(isBool(a)&&isBool(b)){stack.push(a||b)}else{stack.push(a|b)}break;case"pop":stack.pop();break;
21case"roll":b=stack.pop();a=stack.pop();stack.roll(a,b);break;case"round":a=stack.pop();stack.push(Math.round(a));break;case"sin":a=stack.pop();stack.push(Math.sin(a));break;case"sqrt":a=stack.pop();stack.push(Math.sqrt(a));break;case"sub":b=stack.pop();a=stack.pop();stack.push(a-b);break;case"true":stack.push(true);break;case"truncate":a=stack.pop();a=a<0?Math.ceil(a):Math.floor(a);stack.push(a);break;case"xor":b=stack.pop();a=stack.pop();if(isBool(a)&&isBool(b)){stack.push(a!==b)}else{stack.push(a^b)}break;default:error("Unknown operator "+operator);break}}return stack.stack}};return PostScriptEvaluator}();var PostScriptCompiler=function PostScriptCompilerClosure(){function AstNode(type){this.type=type}AstNode.prototype.visit=function(visitor){throw new Error("abstract method")};function AstArgument(index,min,max){AstNode.call(this,"args");this.index=index;this.min=min;this.max=max}AstArgument.prototype=Object.create(AstNode.prototype);AstArgument.prototype.visit=function(visitor){visitor.visitArgument(this)};function AstLiteral(number){AstNode.call(this,"literal");this.number=number;this.min=number;this.max=number}AstLiteral.prototype=Object.create(AstNode.prototype);AstLiteral.prototype.visit=function(visitor){visitor.visitLiteral(this)};function AstBinaryOperation(op,arg1,arg2,min,max){AstNode.call(this,"binary");this.op=op;this.arg1=arg1;this.arg2=arg2;this.min=min;this.max=max}AstBinaryOperation.prototype=Object.create(AstNode.prototype);AstBinaryOperation.prototype.visit=function(visitor){visitor.visitBinaryOperation(this)};function AstMin(arg,max){AstNode.call(this,"max");this.arg=arg;this.min=arg.min;this.max=max}AstMin.prototype=Object.create(AstNode.prototype);AstMin.prototype.visit=function(visitor){visitor.visitMin(this)};function AstVariable(index,min,max){AstNode.call(this,"var");this.index=index;this.min=min;this.max=max}AstVariable.prototype=Object.create(AstNode.prototype);AstVariable.prototype.visit=function(visitor){visitor.visitVariable(this)};function AstVariableDefinition(variable,arg){AstNode.call(this,"definition");this.variable=variable;this.arg=arg}AstVariableDefinition.prototype=Object.create(AstNode.prototype);AstVariableDefinition.prototype.visit=function(visitor){visitor.visitVariableDefinition(this)};function ExpressionBuilderVisitor(){this.parts=[]}ExpressionBuilderVisitor.prototype={visitArgument:function(arg){this.parts.push("Math.max(",arg.min,", Math.min(",arg.max,", src[srcOffset + ",arg.index,"]))")},visitVariable:function(variable){this.parts.push("v",variable.index)},visitLiteral:function(literal){this.parts.push(literal.number)},visitBinaryOperation:function(operation){this.parts.push("(");operation.arg1.visit(this);this.parts.push(" ",operation.op," ");operation.arg2.visit(this);this.parts.push(")")},visitVariableDefinition:function(definition){this.parts.push("var ");definition.variable.visit(this);this.parts.push(" = ");definition.arg.visit(this);this.parts.push(";")},visitMin:function(max){this.parts.push("Math.min(");max.arg.visit(this);this.parts.push(", ",max.max,")")},toString:function(){return this.parts.join("")}};function buildAddOperation(num1,num2){if(num2.type==="literal"&&num2.number===0){return num1}if(num1.type==="literal"&&num1.number===0){return num2}if(num2.type==="literal"&&num1.type==="literal"){return new AstLiteral(num1.number+num2.number)}return new AstBinaryOperation("+",num1,num2,num1.min+num2.min,num1.max+num2.max)}function buildMulOperation(num1,num2){if(num2.type==="literal"){if(num2.number===0){return new AstLiteral(0)}else if(num2.number===1){return num1}else if(num1.type==="literal"){return new AstLiteral(num1.number*num2.number)}}if(num1.type==="literal"){if(num1.number===0){return new AstLiteral(0)}else if(num1.number===1){return num2}}var min=Math.min(num1.min*num2.min,num1.min*num2.max,num1.max*num2.min,num1.max*num2.max);var max=Math.max(num1.min*num2.min,num1.min*num2.max,num1.max*num2.min,num1.max*num2.max);return new AstBinaryOperation("*",num1,num2,min,max)}function buildSubOperation(num1,num2){if(num2.type==="literal"){if(num2.number===0){return num1}else if(num1.type==="literal"){return new AstLiteral(num1.number-num2.number)}}if(num2.type==="binary"&&num2.op==="-"&&num1.type==="literal"&&num1.number===1&&num2.arg1.type==="literal"&&num2.arg1.number===1){return num2.arg2}return new AstBinaryOperation("-",num1,num2,num1.min-num2.max,num1.max-num2.min)}function buildMinOperation(num1,max){if(num1.min>=max){return new AstLiteral(max)}else if(num1.max<=max){return num1}return new AstMin(num1,max)}function PostScriptCompiler(){}PostScriptCompiler.prototype={compile:function PostScriptCompiler_compile(code,domain,range){var stack=[];var i,ii;var instructions=[];var inputSize=domain.length>>1,outputSize=range.length>>1;var lastRegister=0;var n,j;var num1,num2,ast1,ast2,tmpVar,item;for(i=0;i<inputSize;i++){stack.push(new AstArgument(i,domain[i*2],domain[i*2+1]))}for(i=0,ii=code.length;i<ii;i++){item=code[i];if(typeof item==="number"){stack.push(new AstLiteral(item));continue}switch(item){case"add":if(stack.length<2){return null}num2=stack.pop();num1=stack.pop();stack.push(buildAddOperation(num1,num2));break;case"cvr":if(stack.length<1){return null}break;case"mul":if(stack.length<2){return null}num2=stack.pop();num1=stack.pop();stack.push(buildMulOperation(num1,num2));break;case"sub":if(stack.length<2){return null}num2=stack.pop();num1=stack.pop();stack.push(buildSubOperation(num1,num2));break;case"exch":if(stack.length<2){return null}ast1=stack.pop();ast2=stack.pop();stack.push(ast1,ast2);break;case"pop":if(stack.length<1){return null}stack.pop();break;case"index":if(stack.length<1){return null}num1=stack.pop();if(num1.type!=="literal"){return null}n=num1.number;if(n<0||(n|0)!==n||stack.length<n){return null}ast1=stack[stack.length-n-1];if(ast1.type==="literal"||ast1.type==="var"){stack.push(ast1);break}tmpVar=new AstVariable(lastRegister++,ast1.min,ast1.max);stack[stack.length-n-1]=tmpVar;stack.push(tmpVar);instructions.push(new AstVariableDefinition(tmpVar,ast1));break;case"dup":if(stack.length<1){return null}if(typeof code[i+1]==="number"&&code[i+2]==="gt"&&code[i+3]===i+7&&code[i+4]==="jz"&&code[i+5]==="pop"&&code[i+6]===code[i+1]){num1=stack.pop();stack.push(buildMinOperation(num1,code[i+1]));i+=6;break}ast1=stack[stack.length-1];if(ast1.type==="literal"||ast1.type==="var"){stack.push(ast1);break}tmpVar=new AstVariable(lastRegister++,ast1.min,ast1.max);stack[stack.length-1]=tmpVar;stack.push(tmpVar);instructions.push(new AstVariableDefinition(tmpVar,ast1));break;case"roll":if(stack.length<2){return null}num2=stack.pop();num1=stack.pop();if(num2.type!=="literal"||num1.type!=="literal"){return null}j=num2.number;n=num1.number;if(n<=0||(n|0)!==n||(j|0)!==j||stack.length<n){return null}j=(j%n+n)%n;if(j===0){break}Array.prototype.push.apply(stack,stack.splice(stack.length-n,n-j));break;default:return null}}if(stack.length!==outputSize){return null}var result=[];instructions.forEach(function(instruction){var statementBuilder=new ExpressionBuilderVisitor;instruction.visit(statementBuilder);result.push(statementBuilder.toString())});stack.forEach(function(expr,i){var statementBuilder=new ExpressionBuilderVisitor;expr.visit(statementBuilder);var min=range[i*2],max=range[i*2+1];var out=[statementBuilder.toString()];if(min>expr.min){out.unshift("Math.max(",min,", ");out.push(")")}if(max<expr.max){out.unshift("Math.min(",max,", ");out.push(")")}out.unshift("dest[destOffset + ",i,"] = ");out.push(";");result.push(out.join(""))});return result.join("\n")}};return PostScriptCompiler}();exports.isPDFFunction=isPDFFunction;exports.PDFFunction=PDFFunction;exports.PostScriptEvaluator=PostScriptEvaluator;exports.PostScriptCompiler=PostScriptCompiler});(function(root,factory){{factory(root.pdfjsCoreColorSpace={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreFunction)}})(this,function(exports,sharedUtil,corePrimitives,coreFunction){var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var isString=sharedUtil.isString;var shadow=sharedUtil.shadow;var warn=sharedUtil.warn;var isDict=corePrimitives.isDict;var isName=corePrimitives.isName;var isStream=corePrimitives.isStream;var PDFFunction=coreFunction.PDFFunction;var ColorSpace=function ColorSpaceClosure(){function resizeRgbImage(src,bpc,w1,h1,w2,h2,alpha01,dest){var COMPONENTS=3;alpha01=alpha01!==1?0:alpha01;var xRatio=w1/w2;var yRatio=h1/h2;var i,j,py,newIndex=0,oldIndex;var xScaled=new Uint16Array(w2);var w1Scanline=w1*COMPONENTS;for(i=0;i<w2;i++){xScaled[i]=Math.floor(i*xRatio)*COMPONENTS}for(i=0;i<h2;i++){py=Math.floor(i*yRatio)*w1Scanline;for(j=0;j<w2;j++){oldIndex=py+xScaled[j];dest[newIndex++]=src[oldIndex++];dest[newIndex++]=src[oldIndex++];dest[newIndex++]=src[oldIndex++];newIndex+=alpha01}}}function ColorSpace(){error("should not call ColorSpace constructor")}ColorSpace.prototype={getRgb:function ColorSpace_getRgb(src,srcOffset){var rgb=new Uint8Array(3);this.getRgbItem(src,srcOffset,rgb,0);return rgb},getRgbItem:function ColorSpace_getRgbItem(src,srcOffset,dest,destOffset){error("Should not call ColorSpace.getRgbItem")},getRgbBuffer:function ColorSpace_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){error("Should not call ColorSpace.getRgbBuffer")},getOutputLength:function ColorSpace_getOutputLength(inputLength,alpha01){error("Should not call ColorSpace.getOutputLength")},isPassthrough:function ColorSpace_isPassthrough(bits){return false},fillRgb:function ColorSpace_fillRgb(dest,originalWidth,originalHeight,width,height,actualHeight,bpc,comps,alpha01){var count=originalWidth*originalHeight;var rgbBuf=null;var numComponentColors=1<<bpc;var needsResizing=originalHeight!==height||originalWidth!==width;var i,ii;if(this.isPassthrough(bpc)){rgbBuf=comps}else if(this.numComps===1&&count>numComponentColors&&this.name!=="DeviceGray"&&this.name!=="DeviceRGB"){var allColors=bpc<=8?new Uint8Array(numComponentColors):new Uint16Array(numComponentColors);var key;for(i=0;i<numComponentColors;i++){allColors[i]=i}var colorMap=new Uint8Array(numComponentColors*3);this.getRgbBuffer(allColors,0,numComponentColors,colorMap,0,bpc,0);var destPos,rgbPos;if(!needsResizing){destPos=0;for(i=0;i<count;++i){key=comps[i]*3;dest[destPos++]=colorMap[key];dest[destPos++]=colorMap[key+1];dest[destPos++]=colorMap[key+2];destPos+=alpha01}}else{rgbBuf=new Uint8Array(count*3);rgbPos=0;for(i=0;i<count;++i){key=comps[i]*3;rgbBuf[rgbPos++]=colorMap[key];rgbBuf[rgbPos++]=colorMap[key+1];rgbBuf[rgbPos++]=colorMap[key+2]}}}else{if(!needsResizing){this.getRgbBuffer(comps,0,width*actualHeight,dest,0,bpc,alpha01)}else{rgbBuf=new Uint8Array(count*3);this.getRgbBuffer(comps,0,count,rgbBuf,0,bpc,0)}}if(rgbBuf){if(needsResizing){resizeRgbImage(rgbBuf,bpc,originalWidth,originalHeight,width,height,alpha01,dest)}else{rgbPos=0;destPos=0;for(i=0,ii=width*actualHeight;i<ii;i++){dest[destPos++]=rgbBuf[rgbPos++];dest[destPos++]=rgbBuf[rgbPos++];dest[destPos++]=rgbBuf[rgbPos++];destPos+=alpha01}}}},usesZeroToOneRange:true};ColorSpace.parse=function ColorSpace_parse(cs,xref,res){var IR=ColorSpace.parseToIR(cs,xref,res);if(IR instanceof AlternateCS){return IR}return ColorSpace.fromIR(IR)};ColorSpace.fromIR=function ColorSpace_fromIR(IR){var name=isArray(IR)?IR[0]:IR;var whitePoint,blackPoint,gamma;switch(name){case"DeviceGrayCS":return this.singletons.gray;case"DeviceRgbCS":return this.singletons.rgb;case"DeviceCmykCS":return this.singletons.cmyk;case"CalGrayCS":whitePoint=IR[1];blackPoint=IR[2];gamma=IR[3];return new CalGrayCS(whitePoint,blackPoint,gamma);case"CalRGBCS":whitePoint=IR[1];blackPoint=IR[2];gamma=IR[3];var matrix=IR[4];return new CalRGBCS(whitePoint,blackPoint,gamma,matrix);case"PatternCS":var basePatternCS=IR[1];if(basePatternCS){basePatternCS=ColorSpace.fromIR(basePatternCS)}return new PatternCS(basePatternCS);case"IndexedCS":var baseIndexedCS=IR[1];var hiVal=IR[2];var lookup=IR[3];return new IndexedCS(ColorSpace.fromIR(baseIndexedCS),hiVal,lookup);case"AlternateCS":var numComps=IR[1];var alt=IR[2];var tintFnIR=IR[3];return new AlternateCS(numComps,ColorSpace.fromIR(alt),PDFFunction.fromIR(tintFnIR));case"LabCS":whitePoint=IR[1];blackPoint=IR[2];var range=IR[3];return new LabCS(whitePoint,blackPoint,range);default:error("Unknown name "+name)}return null};ColorSpace.parseToIR=function ColorSpace_parseToIR(cs,xref,res){if(isName(cs)){var colorSpaces=res.get("ColorSpace");if(isDict(colorSpaces)){var refcs=colorSpaces.get(cs.name);if(refcs){cs=refcs}}}cs=xref.fetchIfRef(cs);var mode;if(isName(cs)){mode=cs.name;this.mode=mode;switch(mode){case"DeviceGray":case"G":return"DeviceGrayCS";case"DeviceRGB":case"RGB":return"DeviceRgbCS";case"DeviceCMYK":case"CMYK":return"DeviceCmykCS";case"Pattern":return["PatternCS",null];default:error("unrecognized colorspace "+mode)}}else if(isArray(cs)){mode=xref.fetchIfRef(cs[0]).name;this.mode=mode;var numComps,params,alt,whitePoint,blackPoint,gamma;switch(mode){case"DeviceGray":case"G":return"DeviceGrayCS";case"DeviceRGB":case"RGB":return"DeviceRgbCS";case"DeviceCMYK":case"CMYK":return"DeviceCmykCS";case"CalGray":params=xref.fetchIfRef(cs[1]);whitePoint=params.getArray("WhitePoint");blackPoint=params.getArray("BlackPoint");gamma=params.get("Gamma");return["CalGrayCS",whitePoint,blackPoint,gamma];case"CalRGB":params=xref.fetchIfRef(cs[1]);whitePoint=params.getArray("WhitePoint");blackPoint=params.getArray("BlackPoint");gamma=params.getArray("Gamma");var matrix=params.getArray("Matrix");return["CalRGBCS",whitePoint,blackPoint,gamma,matrix];case"ICCBased":var stream=xref.fetchIfRef(cs[1]);var dict=stream.dict;numComps=dict.get("N");alt=dict.get("Alternate");if(alt){var altIR=ColorSpace.parseToIR(alt,xref,res);var altCS=ColorSpace.fromIR(altIR);if(altCS.numComps===numComps){return altIR}warn("ICCBased color space: Ignoring incorrect /Alternate entry.")}if(numComps===1){return"DeviceGrayCS"}else if(numComps===3){return"DeviceRgbCS"}else if(numComps===4){return"DeviceCmykCS"}break;case"Pattern":var basePatternCS=cs[1]||null;if(basePatternCS){basePatternCS=ColorSpace.parseToIR(basePatternCS,xref,res)}return["PatternCS",basePatternCS];case"Indexed":case"I":var baseIndexedCS=ColorSpace.parseToIR(cs[1],xref,res);var hiVal=xref.fetchIfRef(cs[2])+1;var lookup=xref.fetchIfRef(cs[3]);if(isStream(lookup)){lookup=lookup.getBytes()}return["IndexedCS",baseIndexedCS,hiVal,lookup];case"Separation":case"DeviceN":var name=xref.fetchIfRef(cs[1]);numComps=1;if(isName(name)){numComps=1}else if(isArray(name)){numComps=name.length}alt=ColorSpace.parseToIR(cs[2],xref,res);var tintFnIR=PDFFunction.getIR(xref,xref.fetchIfRef(cs[3]));return["AlternateCS",numComps,alt,tintFnIR];case"Lab":params=xref.fetchIfRef(cs[1]);whitePoint=params.getArray("WhitePoint");blackPoint=params.getArray("BlackPoint");var range=params.getArray("Range");return["LabCS",whitePoint,blackPoint,range];default:error('unimplemented color space object "'+mode+'"')}}else{error('unrecognized color space object: "'+cs+'"')}return null};ColorSpace.isDefaultDecode=function ColorSpace_isDefaultDecode(decode,n){if(!isArray(decode)){return true}if(n*2!==decode.length){warn("The decode map is not the correct length");return true}for(var i=0,ii=decode.length;i<ii;i+=2){if(decode[i]!==0||decode[i+1]!==1){return false}}return true};ColorSpace.singletons={get gray(){return shadow(this,"gray",new DeviceGrayCS)},get rgb(){return shadow(this,"rgb",new DeviceRgbCS)},get cmyk(){return shadow(this,"cmyk",new DeviceCmykCS)}};return ColorSpace}();var AlternateCS=function AlternateCSClosure(){function AlternateCS(numComps,base,tintFn){this.name="Alternate";this.numComps=numComps;this.defaultColor=new Float32Array(numComps);for(var i=0;i<numComps;++i){this.defaultColor[i]=1}this.base=base;this.tintFn=tintFn;this.tmpBuf=new Float32Array(base.numComps)}AlternateCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function AlternateCS_getRgbItem(src,srcOffset,dest,destOffset){var tmpBuf=this.tmpBuf;this.tintFn(src,srcOffset,tmpBuf,0);this.base.getRgbItem(tmpBuf,0,dest,destOffset)},getRgbBuffer:function AlternateCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var tintFn=this.tintFn;var base=this.base;var scale=1/((1<<bits)-1);var baseNumComps=base.numComps;var usesZeroToOneRange=base.usesZeroToOneRange;var isPassthrough=(base.isPassthrough(8)||!usesZeroToOneRange)&&alpha01===0;var pos=isPassthrough?destOffset:0;var baseBuf=isPassthrough?dest:new Uint8Array(baseNumComps*count);var numComps=this.numComps;var scaled=new Float32Array(numComps);var tinted=new Float32Array(baseNumComps);var i,j;if(usesZeroToOneRange){for(i=0;i<count;i++){for(j=0;j<numComps;j++){scaled[j]=src[srcOffset++]*scale}tintFn(scaled,0,tinted,0);for(j=0;j<baseNumComps;j++){baseBuf[pos++]=tinted[j]*255}}}else{for(i=0;i<count;i++){for(j=0;j<numComps;j++){scaled[j]=src[srcOffset++]*scale}tintFn(scaled,0,tinted,0);base.getRgbItem(tinted,0,baseBuf,pos);pos+=baseNumComps}}if(!isPassthrough){base.getRgbBuffer(baseBuf,0,count,dest,destOffset,8,alpha01)}},getOutputLength:function AlternateCS_getOutputLength(inputLength,alpha01){return this.base.getOutputLength(inputLength*this.base.numComps/this.numComps,alpha01)},isPassthrough:ColorSpace.prototype.isPassthrough,fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function AlternateCS_isDefaultDecode(decodeMap){return ColorSpace.isDefaultDecode(decodeMap,this.numComps)},usesZeroToOneRange:true};return AlternateCS}();var PatternCS=function PatternCSClosure(){function PatternCS(baseCS){this.name="Pattern";this.base=baseCS}PatternCS.prototype={};return PatternCS}();var IndexedCS=function IndexedCSClosure(){function IndexedCS(base,highVal,lookup){this.name="Indexed";this.numComps=1;this.defaultColor=new Uint8Array([0]);this.base=base;this.highVal=highVal;var baseNumComps=base.numComps;var length=baseNumComps*highVal;var lookupArray;if(isStream(lookup)){lookupArray=new Uint8Array(length);var bytes=lookup.getBytes(length);lookupArray.set(bytes)}else if(isString(lookup)){lookupArray=new Uint8Array(length);for(var i=0;i<length;++i){lookupArray[i]=lookup.charCodeAt(i)}}else if(lookup instanceof Uint8Array||lookup instanceof Array){lookupArray=lookup}else{error("Unrecognized lookup table: "+lookup)}this.lookup=lookupArray}IndexedCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function IndexedCS_getRgbItem(src,srcOffset,dest,destOffset){var numComps=this.base.numComps;var start=src[srcOffset]*numComps;this.base.getRgbItem(this.lookup,start,dest,destOffset)},getRgbBuffer:function IndexedCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var base=this.base;var numComps=base.numComps;var outputDelta=base.getOutputLength(numComps,alpha01);var lookup=this.lookup;for(var i=0;i<count;++i){var lookupPos=src[srcOffset++]*numComps;base.getRgbBuffer(lookup,lookupPos,1,dest,destOffset,8,alpha01);destOffset+=outputDelta}},getOutputLength:function IndexedCS_getOutputLength(inputLength,alpha01){return this.base.getOutputLength(inputLength*this.base.numComps,alpha01)},isPassthrough:ColorSpace.prototype.isPassthrough,fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function IndexedCS_isDefaultDecode(decodeMap){return true},usesZeroToOneRange:true};return IndexedCS}();var DeviceGrayCS=function DeviceGrayCSClosure(){function DeviceGrayCS(){this.name="DeviceGray";this.numComps=1;this.defaultColor=new Float32Array([0])}DeviceGrayCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function DeviceGrayCS_getRgbItem(src,srcOffset,dest,destOffset){var c=src[srcOffset]*255|0;c=c<0?0:c>255?255:c;dest[destOffset]=dest[destOffset+1]=dest[destOffset+2]=c},getRgbBuffer:function DeviceGrayCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var scale=255/((1<<bits)-1);var j=srcOffset,q=destOffset;for(var i=0;i<count;++i){var c=scale*src[j++]|0;dest[q++]=c;dest[q++]=c;dest[q++]=c;q+=alpha01}},getOutputLength:function DeviceGrayCS_getOutputLength(inputLength,alpha01){return inputLength*(3+alpha01)},isPassthrough:ColorSpace.prototype.isPassthrough,fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function DeviceGrayCS_isDefaultDecode(decodeMap){return ColorSpace.isDefaultDecode(decodeMap,this.numComps)},usesZeroToOneRange:true};return DeviceGrayCS}();var DeviceRgbCS=function DeviceRgbCSClosure(){function DeviceRgbCS(){this.name="DeviceRGB";this.numComps=3;this.defaultColor=new Float32Array([0,0,0])}DeviceRgbCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function DeviceRgbCS_getRgbItem(src,srcOffset,dest,destOffset){var r=src[srcOffset]*255|0;var g=src[srcOffset+1]*255|0;var b=src[srcOffset+2]*255|0;dest[destOffset]=r<0?0:r>255?255:r;dest[destOffset+1]=g<0?0:g>255?255:g;dest[destOffset+2]=b<0?0:b>255?255:b},getRgbBuffer:function DeviceRgbCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){if(bits===8&&alpha01===0){dest.set(src.subarray(srcOffset,srcOffset+count*3),destOffset);return}var scale=255/((1<<bits)-1);var j=srcOffset,q=destOffset;for(var i=0;i<count;++i){dest[q++]=scale*src[j++]|0;dest[q++]=scale*src[j++]|0;dest[q++]=scale*src[j++]|0;q+=alpha01}},getOutputLength:function DeviceRgbCS_getOutputLength(inputLength,alpha01){return inputLength*(3+alpha01)/3|0},isPassthrough:function DeviceRgbCS_isPassthrough(bits){return bits===8},fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function DeviceRgbCS_isDefaultDecode(decodeMap){return ColorSpace.isDefaultDecode(decodeMap,this.numComps)},usesZeroToOneRange:true};return DeviceRgbCS}();var DeviceCmykCS=function DeviceCmykCSClosure(){function convertToRgb(src,srcOffset,srcScale,dest,destOffset){var c=src[srcOffset+0]*srcScale;var m=src[srcOffset+1]*srcScale;var y=src[srcOffset+2]*srcScale;var k=src[srcOffset+3]*srcScale;var r=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)+255|0;var g=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)+255|0;var b=c*(.8842522430003296*c+8.078677503112928*m+30.89978309703729*y-.23883238689178934*k+-14.183576799673286)+m*(10.49593273432072*m+63.02378494754052*y+50.606957656360734*k-112.23884253719248)+y*(.03296041114873217*y+115.60384449646641*k+-193.58209356861505)+k*(-22.33816807309886*k-180.12613974708367)+255|0;dest[destOffset]=r>255?255:r<0?0:r;dest[destOffset+1]=g>255?255:g<0?0:g;dest[destOffset+2]=b>255?255:b<0?0:b}function DeviceCmykCS(){this.name="DeviceCMYK";this.numComps=4;this.defaultColor=new Float32Array([0,0,0,1])}DeviceCmykCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function DeviceCmykCS_getRgbItem(src,srcOffset,dest,destOffset){convertToRgb(src,srcOffset,1,dest,destOffset)},getRgbBuffer:function DeviceCmykCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var scale=1/((1<<bits)-1);for(var i=0;i<count;i++){convertToRgb(src,srcOffset,scale,dest,destOffset);srcOffset+=4;destOffset+=3+alpha01}},getOutputLength:function DeviceCmykCS_getOutputLength(inputLength,alpha01){return inputLength/4*(3+alpha01)|0},isPassthrough:ColorSpace.prototype.isPassthrough,fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function DeviceCmykCS_isDefaultDecode(decodeMap){return ColorSpace.isDefaultDecode(decodeMap,this.numComps)},usesZeroToOneRange:true};return DeviceCmykCS}();var CalGrayCS=function CalGrayCSClosure(){function CalGrayCS(whitePoint,blackPoint,gamma){this.name="CalGray";this.numComps=1;this.defaultColor=new Float32Array([0]);if(!whitePoint){error("WhitePoint missing - required for color space CalGray")}blackPoint=blackPoint||[0,0,0];gamma=gamma||1;this.XW=whitePoint[0];this.YW=whitePoint[1];this.ZW=whitePoint[2];this.XB=blackPoint[0];this.YB=blackPoint[1];this.ZB=blackPoint[2];this.G=gamma;if(this.XW<0||this.ZW<0||this.YW!==1){error("Invalid WhitePoint components for "+this.name+", no fallback available")}if(this.XB<0||this.YB<0||this.ZB<0){info("Invalid BlackPoint for "+this.name+", falling back to default");this.XB=this.YB=this.ZB=0}if(this.XB!==0||this.YB!==0||this.ZB!==0){warn(this.name+", BlackPoint: XB: "+this.XB+", YB: "+this.YB+", ZB: "+this.ZB+", only default values are supported.")}if(this.G<1){info("Invalid Gamma: "+this.G+" for "+this.name+", falling back to default");this.G=1}}function convertToRgb(cs,src,srcOffset,dest,destOffset,scale){var A=src[srcOffset]*scale;var AG=Math.pow(A,cs.G);var L=cs.YW*AG;var val=Math.max(295.8*Math.pow(L,.3333333333333333)-40.8,0)|0;dest[destOffset]=val;dest[destOffset+1]=val;dest[destOffset+2]=val}CalGrayCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function CalGrayCS_getRgbItem(src,srcOffset,dest,destOffset){convertToRgb(this,src,srcOffset,dest,destOffset,1)},getRgbBuffer:function CalGrayCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var scale=1/((1<<bits)-1);for(var i=0;i<count;++i){convertToRgb(this,src,srcOffset,dest,destOffset,scale);srcOffset+=1;destOffset+=3+alpha01}},getOutputLength:function CalGrayCS_getOutputLength(inputLength,alpha01){return inputLength*(3+alpha01)},isPassthrough:ColorSpace.prototype.isPassthrough,fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function CalGrayCS_isDefaultDecode(decodeMap){return ColorSpace.isDefaultDecode(decodeMap,this.numComps)},usesZeroToOneRange:true};return CalGrayCS}();var CalRGBCS=function CalRGBCSClosure(){var BRADFORD_SCALE_MATRIX=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]);var BRADFORD_SCALE_INVERSE_MATRIX=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]);var SRGB_D65_XYZ_TO_RGB_MATRIX=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]);var FLAT_WHITEPOINT_MATRIX=new Float32Array([1,1,1]);var tempNormalizeMatrix=new Float32Array(3);var tempConvertMatrix1=new Float32Array(3);var tempConvertMatrix2=new Float32Array(3);var DECODE_L_CONSTANT=Math.pow((8+16)/116,3)/8;function CalRGBCS(whitePoint,blackPoint,gamma,matrix){this.name="CalRGB";this.numComps=3;this.defaultColor=new Float32Array(3);if(!whitePoint){error("WhitePoint missing - required for color space CalRGB")}blackPoint=blackPoint||new Float32Array(3);gamma=gamma||new Float32Array([1,1,1]);matrix=matrix||new Float32Array([1,0,0,0,1,0,0,0,1]);var XW=whitePoint[0];var YW=whitePoint[1];var ZW=whitePoint[2];this.whitePoint=whitePoint;var XB=blackPoint[0];var YB=blackPoint[1];var ZB=blackPoint[2];this.blackPoint=blackPoint;this.GR=gamma[0];this.GG=gamma[1];this.GB=gamma[2];this.MXA=matrix[0];this.MYA=matrix[1];this.MZA=matrix[2];this.MXB=matrix[3];this.MYB=matrix[4];this.MZB=matrix[5];this.MXC=matrix[6];this.MYC=matrix[7];this.MZC=matrix[8];if(XW<0||ZW<0||YW!==1){error("Invalid WhitePoint components for "+this.name+", no fallback available")}if(XB<0||YB<0||ZB<0){info("Invalid BlackPoint for "+this.name+" ["+XB+", "+YB+", "+ZB+"], falling back to default");this.blackPoint=new Float32Array(3)}if(this.GR<0||this.GG<0||this.GB<0){info("Invalid Gamma ["+this.GR+", "+this.GG+", "+this.GB+"] for "+this.name+", falling back to default");this.GR=this.GG=this.GB=1}if(this.MXA<0||this.MYA<0||this.MZA<0||this.MXB<0||this.MYB<0||this.MZB<0||this.MXC<0||this.MYC<0||this.MZC<0){info("Invalid Matrix for "+this.name+" ["+this.MXA+", "+this.MYA+", "+this.MZA+this.MXB+", "+this.MYB+", "+this.MZB+this.MXC+", "+this.MYC+", "+this.MZC+"], falling back to default");this.MXA=this.MYB=this.MZC=1;this.MXB=this.MYA=this.MZA=this.MXC=this.MYC=this.MZB=0}}function matrixProduct(a,b,result){result[0]=a[0]*b[0]+a[1]*b[1]+a[2]*b[2];result[1]=a[3]*b[0]+a[4]*b[1]+a[5]*b[2];result[2]=a[6]*b[0]+a[7]*b[1]+a[8]*b[2]}function convertToFlat(sourceWhitePoint,LMS,result){result[0]=LMS[0]*1/sourceWhitePoint[0];result[1]=LMS[1]*1/sourceWhitePoint[1];result[2]=LMS[2]*1/sourceWhitePoint[2]}function convertToD65(sourceWhitePoint,LMS,result){var D65X=.95047;var D65Y=1;var D65Z=1.08883;result[0]=LMS[0]*D65X/sourceWhitePoint[0];result[1]=LMS[1]*D65Y/sourceWhitePoint[1];result[2]=LMS[2]*D65Z/sourceWhitePoint[2]}function sRGBTransferFunction(color){if(color<=.0031308){return adjustToRange(0,1,12.92*color)}return adjustToRange(0,1,(1+.055)*Math.pow(color,1/2.4)-.055)}function adjustToRange(min,max,value){return Math.max(min,Math.min(max,value))}function decodeL(L){if(L<0){return-decodeL(-L)}if(L>8){return Math.pow((L+16)/116,3)}return L*DECODE_L_CONSTANT}function compensateBlackPoint(sourceBlackPoint,XYZ_Flat,result){if(sourceBlackPoint[0]===0&&sourceBlackPoint[1]===0&&sourceBlackPoint[2]===0){result[0]=XYZ_Flat[0];result[1]=XYZ_Flat[1];result[2]=XYZ_Flat[2];return}var zeroDecodeL=decodeL(0);var X_DST=zeroDecodeL;var X_SRC=decodeL(sourceBlackPoint[0]);var Y_DST=zeroDecodeL;var Y_SRC=decodeL(sourceBlackPoint[1]);var Z_DST=zeroDecodeL;var Z_SRC=decodeL(sourceBlackPoint[2]);var X_Scale=(1-X_DST)/(1-X_SRC);var X_Offset=1-X_Scale;var Y_Scale=(1-Y_DST)/(1-Y_SRC);var Y_Offset=1-Y_Scale;var Z_Scale=(1-Z_DST)/(1-Z_SRC);var Z_Offset=1-Z_Scale;result[0]=XYZ_Flat[0]*X_Scale+X_Offset;result[1]=XYZ_Flat[1]*Y_Scale+Y_Offset;result[2]=XYZ_Flat[2]*Z_Scale+Z_Offset}function normalizeWhitePointToFlat(sourceWhitePoint,XYZ_In,result){if(sourceWhitePoint[0]===1&&sourceWhitePoint[2]===1){result[0]=XYZ_In[0];result[1]=XYZ_In[1];result[2]=XYZ_In[2];return}var LMS=result;matrixProduct(BRADFORD_SCALE_MATRIX,XYZ_In,LMS);var LMS_Flat=tempNormalizeMatrix;convertToFlat(sourceWhitePoint,LMS,LMS_Flat);matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX,LMS_Flat,result)}function normalizeWhitePointToD65(sourceWhitePoint,XYZ_In,result){var LMS=result;matrixProduct(BRADFORD_SCALE_MATRIX,XYZ_In,LMS);var LMS_D65=tempNormalizeMatrix;convertToD65(sourceWhitePoint,LMS,LMS_D65);matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX,LMS_D65,result)}function convertToRgb(cs,src,srcOffset,dest,destOffset,scale){var A=adjustToRange(0,1,src[srcOffset]*scale);var B=adjustToRange(0,1,src[srcOffset+1]*scale);var C=adjustToRange(0,1,src[srcOffset+2]*scale);var AGR=Math.pow(A,cs.GR);var BGG=Math.pow(B,cs.GG);var CGB=Math.pow(C,cs.GB);var X=cs.MXA*AGR+cs.MXB*BGG+cs.MXC*CGB;var Y=cs.MYA*AGR+cs.MYB*BGG+cs.MYC*CGB;var Z=cs.MZA*AGR+cs.MZB*BGG+cs.MZC*CGB;var XYZ=tempConvertMatrix1;XYZ[0]=X;XYZ[1]=Y;XYZ[2]=Z;var XYZ_Flat=tempConvertMatrix2;normalizeWhitePointToFlat(cs.whitePoint,XYZ,XYZ_Flat);var XYZ_Black=tempConvertMatrix1;compensateBlackPoint(cs.blackPoint,XYZ_Flat,XYZ_Black);var XYZ_D65=tempConvertMatrix2;normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX,XYZ_Black,XYZ_D65);var SRGB=tempConvertMatrix1;matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX,XYZ_D65,SRGB);var sR=sRGBTransferFunction(SRGB[0]);var sG=sRGBTransferFunction(SRGB[1]);var sB=sRGBTransferFunction(SRGB[2]);dest[destOffset]=Math.round(sR*255);dest[destOffset+1]=Math.round(sG*255);dest[destOffset+2]=Math.round(sB*255)}CalRGBCS.prototype={getRgb:function CalRGBCS_getRgb(src,srcOffset){var rgb=new Uint8Array(3);this.getRgbItem(src,srcOffset,rgb,0);return rgb},getRgbItem:function CalRGBCS_getRgbItem(src,srcOffset,dest,destOffset){convertToRgb(this,src,srcOffset,dest,destOffset,1)},getRgbBuffer:function CalRGBCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var scale=1/((1<<bits)-1);for(var i=0;i<count;++i){convertToRgb(this,src,srcOffset,dest,destOffset,scale);srcOffset+=3;destOffset+=3+alpha01}},getOutputLength:function CalRGBCS_getOutputLength(inputLength,alpha01){return inputLength*(3+alpha01)/3|0},isPassthrough:ColorSpace.prototype.isPassthrough,fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function CalRGBCS_isDefaultDecode(decodeMap){return ColorSpace.isDefaultDecode(decodeMap,this.numComps)},usesZeroToOneRange:true};return CalRGBCS}();var LabCS=function LabCSClosure(){function LabCS(whitePoint,blackPoint,range){this.name="Lab";
22this.numComps=3;this.defaultColor=new Float32Array([0,0,0]);if(!whitePoint){error("WhitePoint missing - required for color space Lab")}blackPoint=blackPoint||[0,0,0];range=range||[-100,100,-100,100];this.XW=whitePoint[0];this.YW=whitePoint[1];this.ZW=whitePoint[2];this.amin=range[0];this.amax=range[1];this.bmin=range[2];this.bmax=range[3];this.XB=blackPoint[0];this.YB=blackPoint[1];this.ZB=blackPoint[2];if(this.XW<0||this.ZW<0||this.YW!==1){error("Invalid WhitePoint components, no fallback available")}if(this.XB<0||this.YB<0||this.ZB<0){info("Invalid BlackPoint, falling back to default");this.XB=this.YB=this.ZB=0}if(this.amin>this.amax||this.bmin>this.bmax){info("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}function fn_g(x){if(x>=6/29){return x*x*x}else{return 108/841*(x-4/29)}}function decode(value,high1,low2,high2){return low2+value*(high2-low2)/high1}function convertToRgb(cs,src,srcOffset,maxVal,dest,destOffset){var Ls=src[srcOffset];var as=src[srcOffset+1];var bs=src[srcOffset+2];if(maxVal!==false){Ls=decode(Ls,maxVal,0,100);as=decode(as,maxVal,cs.amin,cs.amax);bs=decode(bs,maxVal,cs.bmin,cs.bmax)}as=as>cs.amax?cs.amax:as<cs.amin?cs.amin:as;bs=bs>cs.bmax?cs.bmax:bs<cs.bmin?cs.bmin:bs;var M=(Ls+16)/116;var L=M+as/500;var N=M-bs/200;var X=cs.XW*fn_g(L);var Y=cs.YW*fn_g(M);var Z=cs.ZW*fn_g(N);var r,g,b;if(cs.ZW<1){r=X*3.1339+Y*-1.617+Z*-.4906;g=X*-.9785+Y*1.916+Z*.0333;b=X*.072+Y*-.229+Z*1.4057}else{r=X*3.2406+Y*-1.5372+Z*-.4986;g=X*-.9689+Y*1.8758+Z*.0415;b=X*.0557+Y*-.204+Z*1.057}dest[destOffset]=r<=0?0:r>=1?255:Math.sqrt(r)*255|0;dest[destOffset+1]=g<=0?0:g>=1?255:Math.sqrt(g)*255|0;dest[destOffset+2]=b<=0?0:b>=1?255:Math.sqrt(b)*255|0}LabCS.prototype={getRgb:ColorSpace.prototype.getRgb,getRgbItem:function LabCS_getRgbItem(src,srcOffset,dest,destOffset){convertToRgb(this,src,srcOffset,false,dest,destOffset)},getRgbBuffer:function LabCS_getRgbBuffer(src,srcOffset,count,dest,destOffset,bits,alpha01){var maxVal=(1<<bits)-1;for(var i=0;i<count;i++){convertToRgb(this,src,srcOffset,maxVal,dest,destOffset);srcOffset+=3;destOffset+=3+alpha01}},getOutputLength:function LabCS_getOutputLength(inputLength,alpha01){return inputLength*(3+alpha01)/3|0},isPassthrough:ColorSpace.prototype.isPassthrough,fillRgb:ColorSpace.prototype.fillRgb,isDefaultDecode:function LabCS_isDefaultDecode(decodeMap){return true},usesZeroToOneRange:false};return LabCS}();exports.ColorSpace=ColorSpace});(function(root,factory){{factory(root.pdfjsCoreImage={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreColorSpace,root.pdfjsCoreStream,root.pdfjsCoreJpx)}})(this,function(exports,sharedUtil,corePrimitives,coreColorSpace,coreStream,coreJpx){var ImageKind=sharedUtil.ImageKind;var assert=sharedUtil.assert;var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var warn=sharedUtil.warn;var Name=corePrimitives.Name;var isStream=corePrimitives.isStream;var ColorSpace=coreColorSpace.ColorSpace;var DecodeStream=coreStream.DecodeStream;var JpegStream=coreStream.JpegStream;var JpxImage=coreJpx.JpxImage;var PDFImage=function PDFImageClosure(){function handleImageData(image,nativeDecoder){if(nativeDecoder&&nativeDecoder.canDecode(image)){return nativeDecoder.decode(image)}else{return Promise.resolve(image)}}function decodeAndClamp(value,addend,coefficient,max){value=addend+value*coefficient;return value<0?0:value>max?max:value}function resizeImageMask(src,bpc,w1,h1,w2,h2){var length=w2*h2;var dest=bpc<=8?new Uint8Array(length):bpc<=16?new Uint16Array(length):new Uint32Array(length);var xRatio=w1/w2;var yRatio=h1/h2;var i,j,py,newIndex=0,oldIndex;var xScaled=new Uint16Array(w2);var w1Scanline=w1;for(i=0;i<w2;i++){xScaled[i]=Math.floor(i*xRatio)}for(i=0;i<h2;i++){py=Math.floor(i*yRatio)*w1Scanline;for(j=0;j<w2;j++){oldIndex=py+xScaled[j];dest[newIndex++]=src[oldIndex]}}return dest}function PDFImage(xref,res,image,inline,smask,mask,isMask){this.image=image;var dict=image.dict;if(dict.has("Filter")){var filter=dict.get("Filter").name;if(filter==="JPXDecode"){var jpxImage=new JpxImage;jpxImage.parseImageProperties(image.stream);image.stream.reset();image.bitsPerComponent=jpxImage.bitsPerComponent;image.numComps=jpxImage.componentsCount}else if(filter==="JBIG2Decode"){image.bitsPerComponent=1;image.numComps=1}}this.width=dict.get("Width","W");this.height=dict.get("Height","H");if(this.width<1||this.height<1){error("Invalid image width: "+this.width+" or height: "+this.height)}this.interpolate=dict.get("Interpolate","I")||false;this.imageMask=dict.get("ImageMask","IM")||false;this.matte=dict.get("Matte")||false;var bitsPerComponent=image.bitsPerComponent;if(!bitsPerComponent){bitsPerComponent=dict.get("BitsPerComponent","BPC");if(!bitsPerComponent){if(this.imageMask){bitsPerComponent=1}else{error("Bits per component missing in image: "+this.imageMask)}}}this.bpc=bitsPerComponent;if(!this.imageMask){var colorSpace=dict.get("ColorSpace","CS");if(!colorSpace){info("JPX images (which do not require color spaces)");switch(image.numComps){case 1:colorSpace=Name.get("DeviceGray");break;case 3:colorSpace=Name.get("DeviceRGB");break;case 4:colorSpace=Name.get("DeviceCMYK");break;default:error("JPX images with "+this.numComps+" color components not supported.")}}this.colorSpace=ColorSpace.parse(colorSpace,xref,res);this.numComps=this.colorSpace.numComps}this.decode=dict.getArray("Decode","D");this.needsDecode=false;if(this.decode&&(this.colorSpace&&!this.colorSpace.isDefaultDecode(this.decode)||isMask&&!ColorSpace.isDefaultDecode(this.decode,1))){this.needsDecode=true;var max=(1<<bitsPerComponent)-1;this.decodeCoefficients=[];this.decodeAddends=[];for(var i=0,j=0;i<this.decode.length;i+=2,++j){var dmin=this.decode[i];var dmax=this.decode[i+1];this.decodeCoefficients[j]=dmax-dmin;this.decodeAddends[j]=max*dmin}}if(smask){this.smask=new PDFImage(xref,res,smask,false)}else if(mask){if(isStream(mask)){var maskDict=mask.dict,imageMask=maskDict.get("ImageMask","IM");if(!imageMask){warn("Ignoring /Mask in image without /ImageMask.")}else{this.mask=new PDFImage(xref,res,mask,false,null,null,true)}}else{this.mask=mask}}}PDFImage.buildImage=function PDFImage_buildImage(handler,xref,res,image,inline,nativeDecoder){var imagePromise=handleImageData(image,nativeDecoder);var smaskPromise;var maskPromise;var smask=image.dict.get("SMask");var mask=image.dict.get("Mask");if(smask){smaskPromise=handleImageData(smask,nativeDecoder);maskPromise=Promise.resolve(null)}else{smaskPromise=Promise.resolve(null);if(mask){if(isStream(mask)){maskPromise=handleImageData(mask,nativeDecoder)}else if(isArray(mask)){maskPromise=Promise.resolve(mask)}else{warn("Unsupported mask format.");maskPromise=Promise.resolve(null)}}else{maskPromise=Promise.resolve(null)}}return Promise.all([imagePromise,smaskPromise,maskPromise]).then(function(results){var imageData=results[0];var smaskData=results[1];var maskData=results[2];return new PDFImage(xref,res,imageData,inline,smaskData,maskData)})};PDFImage.createMask=function PDFImage_createMask(imgArray,width,height,imageIsFromDecodeStream,inverseDecode){var computedLength=(width+7>>3)*height;var actualLength=imgArray.byteLength;var haveFullData=computedLength===actualLength;var data,i;if(imageIsFromDecodeStream&&(!inverseDecode||haveFullData)){data=imgArray}else if(!inverseDecode){data=new Uint8Array(actualLength);data.set(imgArray)}else{data=new Uint8Array(computedLength);data.set(imgArray);for(i=actualLength;i<computedLength;i++){data[i]=255}}if(inverseDecode){for(i=0;i<actualLength;i++){data[i]=~data[i]}}return{data:data,width:width,height:height}};PDFImage.prototype={get drawWidth(){return Math.max(this.width,this.smask&&this.smask.width||0,this.mask&&this.mask.width||0)},get drawHeight(){return Math.max(this.height,this.smask&&this.smask.height||0,this.mask&&this.mask.height||0)},decodeBuffer:function PDFImage_decodeBuffer(buffer){var bpc=this.bpc;var numComps=this.numComps;var decodeAddends=this.decodeAddends;var decodeCoefficients=this.decodeCoefficients;var max=(1<<bpc)-1;var i,ii;if(bpc===1){for(i=0,ii=buffer.length;i<ii;i++){buffer[i]=+!buffer[i]}return}var index=0;for(i=0,ii=this.width*this.height;i<ii;i++){for(var j=0;j<numComps;j++){buffer[index]=decodeAndClamp(buffer[index],decodeAddends[j],decodeCoefficients[j],max);index++}}},getComponents:function PDFImage_getComponents(buffer){var bpc=this.bpc;if(bpc===8){return buffer}var width=this.width;var height=this.height;var numComps=this.numComps;var length=width*height*numComps;var bufferPos=0;var output=bpc<=8?new Uint8Array(length):bpc<=16?new Uint16Array(length):new Uint32Array(length);var rowComps=width*numComps;var max=(1<<bpc)-1;var i=0,ii,buf;if(bpc===1){var mask,loop1End,loop2End;for(var j=0;j<height;j++){loop1End=i+(rowComps&~7);loop2End=i+rowComps;while(i<loop1End){buf=buffer[bufferPos++];output[i]=buf>>7&1;output[i+1]=buf>>6&1;output[i+2]=buf>>5&1;output[i+3]=buf>>4&1;output[i+4]=buf>>3&1;output[i+5]=buf>>2&1;output[i+6]=buf>>1&1;output[i+7]=buf&1;i+=8}if(i<loop2End){buf=buffer[bufferPos++];mask=128;while(i<loop2End){output[i++]=+!!(buf&mask);mask>>=1}}}}else{var bits=0;buf=0;for(i=0,ii=length;i<ii;++i){if(i%rowComps===0){buf=0;bits=0}while(bits<bpc){buf=buf<<8|buffer[bufferPos++];bits+=8}var remainingBits=bits-bpc;var value=buf>>remainingBits;output[i]=value<0?0:value>max?max:value;buf=buf&(1<<remainingBits)-1;bits=remainingBits}}return output},fillOpacity:function PDFImage_fillOpacity(rgbaBuf,width,height,actualHeight,image){var smask=this.smask;var mask=this.mask;var alphaBuf,sw,sh,i,ii,j;if(smask){sw=smask.width;sh=smask.height;alphaBuf=new Uint8Array(sw*sh);smask.fillGrayBuffer(alphaBuf);if(sw!==width||sh!==height){alphaBuf=resizeImageMask(alphaBuf,smask.bpc,sw,sh,width,height)}}else if(mask){if(mask instanceof PDFImage){sw=mask.width;sh=mask.height;alphaBuf=new Uint8Array(sw*sh);mask.numComps=1;mask.fillGrayBuffer(alphaBuf);for(i=0,ii=sw*sh;i<ii;++i){alphaBuf[i]=255-alphaBuf[i]}if(sw!==width||sh!==height){alphaBuf=resizeImageMask(alphaBuf,mask.bpc,sw,sh,width,height)}}else if(isArray(mask)){alphaBuf=new Uint8Array(width*height);var numComps=this.numComps;for(i=0,ii=width*height;i<ii;++i){var opacity=0;var imageOffset=i*numComps;for(j=0;j<numComps;++j){var color=image[imageOffset+j];var maskOffset=j*2;if(color<mask[maskOffset]||color>mask[maskOffset+1]){opacity=255;break}}alphaBuf[i]=opacity}}else{error("Unknown mask format.")}}if(alphaBuf){for(i=0,j=3,ii=width*actualHeight;i<ii;++i,j+=4){rgbaBuf[j]=alphaBuf[i]}}else{for(i=0,j=3,ii=width*actualHeight;i<ii;++i,j+=4){rgbaBuf[j]=255}}},undoPreblend:function PDFImage_undoPreblend(buffer,width,height){var matte=this.smask&&this.smask.matte;if(!matte){return}var matteRgb=this.colorSpace.getRgb(matte,0);var matteR=matteRgb[0];var matteG=matteRgb[1];var matteB=matteRgb[2];var length=width*height*4;var r,g,b;for(var i=0;i<length;i+=4){var alpha=buffer[i+3];if(alpha===0){buffer[i]=255;buffer[i+1]=255;buffer[i+2]=255;continue}var k=255/alpha;r=(buffer[i]-matteR)*k+matteR;g=(buffer[i+1]-matteG)*k+matteG;b=(buffer[i+2]-matteB)*k+matteB;buffer[i]=r<=0?0:r>=255?255:r|0;buffer[i+1]=g<=0?0:g>=255?255:g|0;buffer[i+2]=b<=0?0:b>=255?255:b|0}},createImageData:function PDFImage_createImageData(forceRGBA){var drawWidth=this.drawWidth;var drawHeight=this.drawHeight;var imgData={width:drawWidth,height:drawHeight};var numComps=this.numComps;var originalWidth=this.width;var originalHeight=this.height;var bpc=this.bpc;var rowBytes=originalWidth*numComps*bpc+7>>3;var imgArray;if(!forceRGBA){var kind;if(this.colorSpace.name==="DeviceGray"&&bpc===1){kind=ImageKind.GRAYSCALE_1BPP}else if(this.colorSpace.name==="DeviceRGB"&&bpc===8&&!this.needsDecode){kind=ImageKind.RGB_24BPP}if(kind&&!this.smask&&!this.mask&&drawWidth===originalWidth&&drawHeight===originalHeight){imgData.kind=kind;imgArray=this.getImageBytes(originalHeight*rowBytes);if(this.image instanceof DecodeStream){imgData.data=imgArray}else{var newArray=new Uint8Array(imgArray.length);newArray.set(imgArray);imgData.data=newArray}if(this.needsDecode){assert(kind===ImageKind.GRAYSCALE_1BPP);var buffer=imgData.data;for(var i=0,ii=buffer.length;i<ii;i++){buffer[i]^=255}}return imgData}if(this.image instanceof JpegStream&&!this.smask&&!this.mask&&(this.colorSpace.name==="DeviceGray"||this.colorSpace.name==="DeviceRGB"||this.colorSpace.name==="DeviceCMYK")){imgData.kind=ImageKind.RGB_24BPP;imgData.data=this.getImageBytes(originalHeight*rowBytes,drawWidth,drawHeight,true);return imgData}}imgArray=this.getImageBytes(originalHeight*rowBytes);var actualHeight=0|imgArray.length/rowBytes*drawHeight/originalHeight;var comps=this.getComponents(imgArray);var alpha01,maybeUndoPreblend;if(!forceRGBA&&!this.smask&&!this.mask){imgData.kind=ImageKind.RGB_24BPP;imgData.data=new Uint8Array(drawWidth*drawHeight*3);alpha01=0;maybeUndoPreblend=false}else{imgData.kind=ImageKind.RGBA_32BPP;imgData.data=new Uint8Array(drawWidth*drawHeight*4);alpha01=1;maybeUndoPreblend=true;this.fillOpacity(imgData.data,drawWidth,drawHeight,actualHeight,comps)}if(this.needsDecode){this.decodeBuffer(comps)}this.colorSpace.fillRgb(imgData.data,originalWidth,originalHeight,drawWidth,drawHeight,actualHeight,bpc,comps,alpha01);if(maybeUndoPreblend){this.undoPreblend(imgData.data,drawWidth,actualHeight)}return imgData},fillGrayBuffer:function PDFImage_fillGrayBuffer(buffer){var numComps=this.numComps;if(numComps!==1){error("Reading gray scale from a color image: "+numComps)}var width=this.width;var height=this.height;var bpc=this.bpc;var rowBytes=width*numComps*bpc+7>>3;var imgArray=this.getImageBytes(height*rowBytes);var comps=this.getComponents(imgArray);var i,length;if(bpc===1){length=width*height;if(this.needsDecode){for(i=0;i<length;++i){buffer[i]=comps[i]-1&255}}else{for(i=0;i<length;++i){buffer[i]=-comps[i]&255}}return}if(this.needsDecode){this.decodeBuffer(comps)}length=width*height;var scale=255/((1<<bpc)-1);for(i=0;i<length;++i){buffer[i]=scale*comps[i]|0}},getImageBytes:function PDFImage_getImageBytes(length,drawWidth,drawHeight,forceRGB){this.image.reset();this.image.drawWidth=drawWidth||this.width;this.image.drawHeight=drawHeight||this.height;this.image.forceRGB=!!forceRGB;return this.image.getBytes(length)}};return PDFImage}();exports.PDFImage=PDFImage});(function(root,factory){{factory(root.pdfjsCoreObj={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreCrypto,root.pdfjsCoreParser,root.pdfjsCoreChunkedStream,root.pdfjsCoreColorSpace)}})(this,function(exports,sharedUtil,corePrimitives,coreCrypto,coreParser,coreChunkedStream,coreColorSpace){var InvalidPDFException=sharedUtil.InvalidPDFException;var MissingDataException=sharedUtil.MissingDataException;var XRefParseException=sharedUtil.XRefParseException;var assert=sharedUtil.assert;var bytesToString=sharedUtil.bytesToString;var createPromiseCapability=sharedUtil.createPromiseCapability;var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var isInt=sharedUtil.isInt;var isString=sharedUtil.isString;var shadow=sharedUtil.shadow;var stringToPDFString=sharedUtil.stringToPDFString;var stringToUTF8String=sharedUtil.stringToUTF8String;var warn=sharedUtil.warn;var isValidUrl=sharedUtil.isValidUrl;var Util=sharedUtil.Util;var Ref=corePrimitives.Ref;var RefSet=corePrimitives.RefSet;var RefSetCache=corePrimitives.RefSetCache;var isName=corePrimitives.isName;var isCmd=corePrimitives.isCmd;var isDict=corePrimitives.isDict;var isRef=corePrimitives.isRef;var isRefsEqual=corePrimitives.isRefsEqual;var isStream=corePrimitives.isStream;var CipherTransformFactory=coreCrypto.CipherTransformFactory;var Lexer=coreParser.Lexer;var Parser=coreParser.Parser;var ChunkedStream=coreChunkedStream.ChunkedStream;var ColorSpace=coreColorSpace.ColorSpace;var Catalog=function CatalogClosure(){function Catalog(pdfManager,xref,pageFactory){this.pdfManager=pdfManager;this.xref=xref;this.catDict=xref.getCatalogObj();this.fontCache=new RefSetCache;assert(isDict(this.catDict),"catalog object is not a dictionary");this.pageFactory=pageFactory;this.pagePromises=[]}Catalog.prototype={get metadata(){var streamRef=this.catDict.getRaw("Metadata");if(!isRef(streamRef)){return shadow(this,"metadata",null)}var encryptMetadata=!this.xref.encrypt?false:this.xref.encrypt.encryptMetadata;var stream=this.xref.fetch(streamRef,!encryptMetadata);var metadata;if(stream&&isDict(stream.dict)){var type=stream.dict.get("Type");var subtype=stream.dict.get("Subtype");if(isName(type,"Metadata")&&isName(subtype,"XML")){try{metadata=stringToUTF8String(bytesToString(stream.getBytes()))}catch(e){info("Skipping invalid metadata.")}}}return shadow(this,"metadata",metadata)},get toplevelPagesDict(){var pagesObj=this.catDict.get("Pages");assert(isDict(pagesObj),"invalid top-level pages dictionary");return shadow(this,"toplevelPagesDict",pagesObj)},get documentOutline(){var obj=null;try{obj=this.readDocumentOutline()}catch(ex){if(ex instanceof MissingDataException){throw ex}warn("Unable to read document outline")}return shadow(this,"documentOutline",obj)},readDocumentOutline:function Catalog_readDocumentOutline(){var obj=this.catDict.get("Outlines");if(!isDict(obj)){return null}obj=obj.getRaw("First");if(!isRef(obj)){return null}var root={items:[]};var queue=[{obj:obj,parent:root}];var processed=new RefSet;processed.put(obj);var xref=this.xref,blackColor=new Uint8Array(3);while(queue.length>0){var i=queue.shift();var outlineDict=xref.fetchIfRef(i.obj);if(outlineDict===null){continue}assert(outlineDict.has("Title"),"Invalid outline item");var actionDict=outlineDict.get("A"),dest=null,url=null;if(actionDict){var destEntry=actionDict.get("D");if(destEntry){dest=destEntry}else{var uriEntry=actionDict.get("URI");if(isString(uriEntry)&&isValidUrl(uriEntry,false)){url=uriEntry}}}else if(outlineDict.has("Dest")){dest=outlineDict.getRaw("Dest");if(isName(dest)){dest=dest.name}}var title=outlineDict.get("Title");var flags=outlineDict.get("F")||0;var color=outlineDict.getArray("C"),rgbColor=blackColor;if(isArray(color)&&color.length===3&&(color[0]!==0||color[1]!==0||color[2]!==0)){rgbColor=ColorSpace.singletons.rgb.getRgb(color,0)}var outlineItem={dest:dest,url:url,title:stringToPDFString(title),color:rgbColor,count:outlineDict.get("Count"),bold:!!(flags&2),italic:!!(flags&1),items:[]};i.parent.items.push(outlineItem);obj=outlineDict.getRaw("First");if(isRef(obj)&&!processed.has(obj)){queue.push({obj:obj,parent:outlineItem});processed.put(obj)}obj=outlineDict.getRaw("Next");if(isRef(obj)&&!processed.has(obj)){queue.push({obj:obj,parent:i.parent});processed.put(obj)}}return root.items.length>0?root.items:null},get numPages(){var obj=this.toplevelPagesDict.get("Count");assert(isInt(obj),"page count in top level pages object is not an integer");return shadow(this,"num",obj)},get destinations(){function fetchDestination(dest){return isDict(dest)?dest.get("D"):dest}var xref=this.xref;var dests={},nameTreeRef,nameDictionaryRef;var obj=this.catDict.get("Names");if(obj&&obj.has("Dests")){nameTreeRef=obj.getRaw("Dests")}else if(this.catDict.has("Dests")){nameDictionaryRef=this.catDict.get("Dests")}if(nameDictionaryRef){obj=nameDictionaryRef;obj.forEach(function catalogForEach(key,value){if(!value){return}dests[key]=fetchDestination(value)})}if(nameTreeRef){var nameTree=new NameTree(nameTreeRef,xref);var names=nameTree.getAll();for(var name in names){dests[name]=fetchDestination(names[name])}}return shadow(this,"destinations",dests)},getDestination:function Catalog_getDestination(destinationId){function fetchDestination(dest){return isDict(dest)?dest.get("D"):dest}var xref=this.xref;var dest=null,nameTreeRef,nameDictionaryRef;var obj=this.catDict.get("Names");if(obj&&obj.has("Dests")){nameTreeRef=obj.getRaw("Dests")}else if(this.catDict.has("Dests")){nameDictionaryRef=this.catDict.get("Dests")}if(nameDictionaryRef){var value=nameDictionaryRef.get(destinationId);if(value){dest=fetchDestination(value)}}if(nameTreeRef){var nameTree=new NameTree(nameTreeRef,xref);dest=fetchDestination(nameTree.get(destinationId))}return dest},get pageLabels(){var obj=null;try{obj=this.readPageLabels()}catch(ex){if(ex instanceof MissingDataException){throw ex}warn("Unable to read page labels.")}return shadow(this,"pageLabels",obj)},readPageLabels:function Catalog_readPageLabels(){var obj=this.catDict.getRaw("PageLabels");if(!obj){return null}var pageLabels=new Array(this.numPages);var style=null;var prefix="";var start=1;var numberTree=new NumberTree(obj,this.xref);var nums=numberTree.getAll();var currentLabel="",currentIndex=1;for(var i=0,ii=this.numPages;i<ii;i++){if(i in nums){var labelDict=nums[i];assert(isDict(labelDict),"The PageLabel is not a dictionary.");var type=labelDict.get("Type");assert(!type||isName(type,"PageLabel"),"Invalid type in PageLabel dictionary.");var s=labelDict.get("S");assert(!s||isName(s),"Invalid style in PageLabel dictionary.");style=s?s.name:null;prefix=labelDict.get("P")||"";assert(isString(prefix),"Invalid prefix in PageLabel dictionary.");start=labelDict.get("St")||1;assert(isInt(start),"Invalid start in PageLabel dictionary.");currentIndex=start}switch(style){case"D":currentLabel=currentIndex;break;case"R":case"r":currentLabel=Util.toRoman(currentIndex,style==="r");break;case"A":case"a":var LIMIT=26;var A_UPPER_CASE=65,A_LOWER_CASE=97;var baseCharCode=style==="a"?A_LOWER_CASE:A_UPPER_CASE;var letterIndex=currentIndex-1;var character=String.fromCharCode(baseCharCode+letterIndex%LIMIT);var charBuf=[];for(var j=0,jj=letterIndex/LIMIT|0;j<=jj;j++){charBuf.push(character)}currentLabel=charBuf.join("");break;default:assert(!style,'Invalid style "'+style+'" in PageLabel dictionary.')}pageLabels[i]=prefix+currentLabel;currentLabel="";currentIndex++}return pageLabels},get attachments(){var xref=this.xref;var attachments=null,nameTreeRef;var obj=this.catDict.get("Names");if(obj){nameTreeRef=obj.getRaw("EmbeddedFiles")}if(nameTreeRef){var nameTree=new NameTree(nameTreeRef,xref);var names=nameTree.getAll();for(var name in names){var fs=new FileSpec(names[name],xref);if(!attachments){attachments=Object.create(null)}attachments[stringToPDFString(name)]=fs.serializable}}return shadow(this,"attachments",attachments)},get javaScript(){var xref=this.xref;var obj=this.catDict.get("Names");var javaScript=[];function appendIfJavaScriptDict(jsDict){var type=jsDict.get("S");if(!isName(type,"JavaScript")){return}var js=jsDict.get("JS");if(isStream(js)){js=bytesToString(js.getBytes())}else if(!isString(js)){return}javaScript.push(stringToPDFString(js))}if(obj&&obj.has("JavaScript")){var nameTree=new NameTree(obj.getRaw("JavaScript"),xref);var names=nameTree.getAll();for(var name in names){var jsDict=names[name];if(isDict(jsDict)){appendIfJavaScriptDict(jsDict)}}}var openactionDict=this.catDict.get("OpenAction");if(isDict(openactionDict,"Action")){var actionType=openactionDict.get("S");if(isName(actionType,"Named")){var action=openactionDict.get("N");if(isName(action,"Print")){javaScript.push("print({});")}}else{appendIfJavaScriptDict(openactionDict)}}return shadow(this,"javaScript",javaScript)},cleanup:function Catalog_cleanup(){var promises=[];this.fontCache.forEach(function(promise){promises.push(promise)});return Promise.all(promises).then(function(translatedFonts){for(var i=0,ii=translatedFonts.length;i<ii;i++){var font=translatedFonts[i].dict;delete font.translated}this.fontCache.clear()}.bind(this))},getPage:function Catalog_getPage(pageIndex){if(!(pageIndex in this.pagePromises)){this.pagePromises[pageIndex]=this.getPageDict(pageIndex).then(function(a){var dict=a[0];var ref=a[1];return this.pageFactory.createPage(pageIndex,dict,ref,this.fontCache)}.bind(this))}return this.pagePromises[pageIndex]},getPageDict:function Catalog_getPageDict(pageIndex){var capability=createPromiseCapability();var nodesToVisit=[this.catDict.getRaw("Pages")];var currentPageIndex=0;var xref=this.xref;var checkAllKids=false;function next(){while(nodesToVisit.length){var currentNode=nodesToVisit.pop();if(isRef(currentNode)){xref.fetchAsync(currentNode).then(function(obj){if(isDict(obj,"Page")||isDict(obj)&&!obj.has("Kids")){if(pageIndex===currentPageIndex){capability.resolve([obj,currentNode])}else{currentPageIndex++;next()}return}nodesToVisit.push(obj);next()},capability.reject);return}assert(isDict(currentNode),"page dictionary kid reference points to wrong type of object");var count=currentNode.get("Count");if(count===0){checkAllKids=true}if(currentPageIndex+count<=pageIndex){currentPageIndex+=count;continue}var kids=currentNode.get("Kids");assert(isArray(kids),"page dictionary kids object is not an array");if(!checkAllKids&&count===kids.length){nodesToVisit=[kids[pageIndex-currentPageIndex]];currentPageIndex=pageIndex;continue}else{for(var last=kids.length-1;last>=0;last--){nodesToVisit.push(kids[last])}}}capability.reject("Page index "+pageIndex+" not found.")}next();return capability.promise},getPageIndex:function Catalog_getPageIndex(pageRef){var xref=this.xref;function pagesBeforeRef(kidRef){var total=0;var parentRef;return xref.fetchAsync(kidRef).then(function(node){if(isRefsEqual(kidRef,pageRef)&&!isDict(node,"Page")&&!(isDict(node)&&!node.has("Type")&&node.has("Contents"))){throw new Error("The reference does not point to a /Page Dict.")}if(!node){return null}assert(isDict(node),"node must be a Dict.");parentRef=node.getRaw("Parent");return node.getAsync("Parent")}).then(function(parent){if(!parent){return null}assert(isDict(parent),"parent must be a Dict.");return parent.getAsync("Kids")}).then(function(kids){if(!kids){return null}var kidPromises=[];var found=false;for(var i=0;i<kids.length;i++){var kid=kids[i];assert(isRef(kid),"kid must be a Ref.");if(kid.num===kidRef.num){found=true;break}kidPromises.push(xref.fetchAsync(kid).then(function(kid){if(kid.has("Count")){var count=kid.get("Count");total+=count}else{total++}}))}if(!found){error("kid ref not found in parents kids")}return Promise.all(kidPromises).then(function(){return[total,parentRef]})})}var total=0;function next(ref){return pagesBeforeRef(ref).then(function(args){if(!args){return total}var count=args[0];var parentRef=args[1];total+=count;return next(parentRef)})}return next(pageRef)}};return Catalog}();var XRef=function XRefClosure(){function XRef(stream,password){this.stream=stream;this.entries=[];this.xrefstms=Object.create(null);this.cache=[];this.password=password;this.stats={streamTypes:[],fontTypes:[]}}XRef.prototype={setStartXRef:function XRef_setStartXRef(startXRef){this.startXRefQueue=[startXRef]},parse:function XRef_parse(recoveryMode){var trailerDict;if(!recoveryMode){trailerDict=this.readXRef()}else{warn("Indexing all PDF objects");trailerDict=this.indexObjects()}trailerDict.assignXref(this);this.trailer=trailerDict;var encrypt=trailerDict.get("Encrypt");if(encrypt){var ids=trailerDict.get("ID");var fileId=ids&&ids.length?ids[0]:"";this.encrypt=new CipherTransformFactory(encrypt,fileId,this.password)}if(!(this.root=trailerDict.get("Root"))){error("Invalid root reference")}},processXRefTable:function XRef_processXRefTable(parser){if(!("tableState"in this)){this.tableState={entryNum:0,streamPos:parser.lexer.stream.pos,parserBuf1:parser.buf1,parserBuf2:parser.buf2}}var obj=this.readXRefTable(parser);if(!isCmd(obj,"trailer")){error("Invalid XRef table: could not find trailer dictionary")}var dict=parser.getObj();if(!isDict(dict)&&dict.dict){dict=dict.dict}if(!isDict(dict)){error("Invalid XRef table: could not parse trailer dictionary")}delete this.tableState;return dict},readXRefTable:function XRef_readXRefTable(parser){var stream=parser.lexer.stream;var tableState=this.tableState;stream.pos=tableState.streamPos;parser.buf1=tableState.parserBuf1;parser.buf2=tableState.parserBuf2;var obj;while(true){if(!("firstEntryNum"in tableState)||!("entryCount"in tableState)){if(isCmd(obj=parser.getObj(),"trailer")){break}tableState.firstEntryNum=obj;tableState.entryCount=parser.getObj()}var first=tableState.firstEntryNum;var count=tableState.entryCount;if(!isInt(first)||!isInt(count)){error("Invalid XRef table: wrong types in subsection header")}for(var i=tableState.entryNum;i<count;i++){tableState.streamPos=stream.pos;tableState.entryNum=i;tableState.parserBuf1=parser.buf1;tableState.parserBuf2=parser.buf2;var entry={};entry.offset=parser.getObj();entry.gen=parser.getObj();var type=parser.getObj();if(isCmd(type,"f")){entry.free=true}else if(isCmd(type,"n")){entry.uncompressed=true}if(!isInt(entry.offset)||!isInt(entry.gen)||!(entry.free||entry.uncompressed)){error("Invalid entry in XRef subsection: "+first+", "+count)}if(i===0&&entry.free&&first===1){first=0}if(!this.entries[i+first]){this.entries[i+first]=entry}}tableState.entryNum=0;tableState.streamPos=stream.pos;tableState.parserBuf1=parser.buf1;tableState.parserBuf2=parser.buf2;delete tableState.firstEntryNum;delete tableState.entryCount}if(this.entries[0]&&!this.entries[0].free){error("Invalid XRef table: unexpected first object")}return obj},processXRefStream:function XRef_processXRefStream(stream){if(!("streamState"in this)){var streamParameters=stream.dict;var byteWidths=streamParameters.get("W");var range=streamParameters.get("Index");if(!range){range=[0,streamParameters.get("Size")]}this.streamState={entryRanges:range,byteWidths:byteWidths,entryNum:0,streamPos:stream.pos}}this.readXRefStream(stream);delete this.streamState;return stream.dict},readXRefStream:function XRef_readXRefStream(stream){var i,j;var streamState=this.streamState;stream.pos=streamState.streamPos;var byteWidths=streamState.byteWidths;var typeFieldWidth=byteWidths[0];var offsetFieldWidth=byteWidths[1];var generationFieldWidth=byteWidths[2];var entryRanges=streamState.entryRanges;while(entryRanges.length>0){var first=entryRanges[0];var n=entryRanges[1];if(!isInt(first)||!isInt(n)){error("Invalid XRef range fields: "+first+", "+n)}if(!isInt(typeFieldWidth)||!isInt(offsetFieldWidth)||!isInt(generationFieldWidth)){error("Invalid XRef entry fields length: "+first+", "+n)}for(i=streamState.entryNum;i<n;++i){streamState.entryNum=i;streamState.streamPos=stream.pos;var type=0,offset=0,generation=0;for(j=0;j<typeFieldWidth;++j){type=type<<8|stream.getByte()}if(typeFieldWidth===0){type=1}for(j=0;j<offsetFieldWidth;++j){offset=offset<<8|stream.getByte()}for(j=0;j<generationFieldWidth;++j){generation=generation<<8|stream.getByte()}var entry={};entry.offset=offset;entry.gen=generation;switch(type){case 0:entry.free=true;break;case 1:entry.uncompressed=true;break;case 2:break;default:error("Invalid XRef entry type: "+type)}if(!this.entries[first+i]){this.entries[first+i]=entry}}streamState.entryNum=0;streamState.streamPos=stream.pos;entryRanges.splice(0,2)}},indexObjects:function XRef_indexObjects(){var TAB=9,LF=10,CR=13,SPACE=32;var PERCENT=37,LT=60;function readToken(data,offset){var token="",ch=data[offset];while(ch!==LF&&ch!==CR&&ch!==LT){if(++offset>=data.length){break}token+=String.fromCharCode(ch);ch=data[offset]}return token}function skipUntil(data,offset,what){var length=what.length,dataLength=data.length;var skipped=0;while(offset<dataLength){var i=0;while(i<length&&data[offset+i]===what[i]){++i}if(i>=length){break}offset++;skipped++}return skipped}var objRegExp=/^(\d+)\s+(\d+)\s+obj\b/;var trailerBytes=new Uint8Array([116,114,97,105,108,101,114]);var startxrefBytes=new Uint8Array([115,116,97,114,116,120,114,101,102]);var endobjBytes=new Uint8Array([101,110,100,111,98,106]);var xrefBytes=new Uint8Array([47,88,82,101,102]);this.entries.length=0;var stream=this.stream;stream.pos=0;var buffer=stream.getBytes();var position=stream.start,length=buffer.length;var trailers=[],xrefStms=[];while(position<length){var ch=buffer[position];if(ch===TAB||ch===LF||ch===CR||ch===SPACE){++position;continue}if(ch===PERCENT){do{++position;if(position>=length){break}ch=buffer[position]}while(ch!==LF&&ch!==CR);continue}var token=readToken(buffer,position);var m;if(token.indexOf("xref")===0&&(token.length===4||/\s/.test(token[4]))){position+=skipUntil(buffer,position,trailerBytes);trailers.push(position);
23position+=skipUntil(buffer,position,startxrefBytes)}else if(m=objRegExp.exec(token)){if(typeof this.entries[m[1]]==="undefined"){this.entries[m[1]]={offset:position-stream.start,gen:m[2]|0,uncompressed:true}}var contentLength=skipUntil(buffer,position,endobjBytes)+7;var content=buffer.subarray(position,position+contentLength);var xrefTagOffset=skipUntil(content,0,xrefBytes);if(xrefTagOffset<contentLength&&content[xrefTagOffset+5]<64){xrefStms.push(position-stream.start);this.xrefstms[position-stream.start]=1}position+=contentLength}else if(token.indexOf("trailer")===0&&(token.length===7||/\s/.test(token[7]))){trailers.push(position);position+=skipUntil(buffer,position,startxrefBytes)}else{position+=token.length+1}}var i,ii;for(i=0,ii=xrefStms.length;i<ii;++i){this.startXRefQueue.push(xrefStms[i]);this.readXRef(true)}var dict;for(i=0,ii=trailers.length;i<ii;++i){stream.pos=trailers[i];var parser=new Parser(new Lexer(stream),true,this,true);var obj=parser.getObj();if(!isCmd(obj,"trailer")){continue}dict=parser.getObj();if(!isDict(dict)){continue}if(dict.has("ID")){return dict}}if(dict){return dict}throw new InvalidPDFException("Invalid PDF structure")},readXRef:function XRef_readXRef(recoveryMode){var stream=this.stream;try{while(this.startXRefQueue.length){var startXRef=this.startXRefQueue[0];stream.pos=startXRef+stream.start;var parser=new Parser(new Lexer(stream),true,this);var obj=parser.getObj();var dict;if(isCmd(obj,"xref")){dict=this.processXRefTable(parser);if(!this.topDict){this.topDict=dict}obj=dict.get("XRefStm");if(isInt(obj)){var pos=obj;if(!(pos in this.xrefstms)){this.xrefstms[pos]=1;this.startXRefQueue.push(pos)}}}else if(isInt(obj)){if(!isInt(parser.getObj())||!isCmd(parser.getObj(),"obj")||!isStream(obj=parser.getObj())){error("Invalid XRef stream")}dict=this.processXRefStream(obj);if(!this.topDict){this.topDict=dict}if(!dict){error("Failed to read XRef stream")}}else{error("Invalid XRef stream header")}obj=dict.get("Prev");if(isInt(obj)){this.startXRefQueue.push(obj)}else if(isRef(obj)){this.startXRefQueue.push(obj.num)}this.startXRefQueue.shift()}return this.topDict}catch(e){if(e instanceof MissingDataException){throw e}info("(while reading XRef): "+e)}if(recoveryMode){return}throw new XRefParseException},getEntry:function XRef_getEntry(i){var xrefEntry=this.entries[i];if(xrefEntry&&!xrefEntry.free&&xrefEntry.offset){return xrefEntry}return null},fetchIfRef:function XRef_fetchIfRef(obj){if(!isRef(obj)){return obj}return this.fetch(obj)},fetch:function XRef_fetch(ref,suppressEncryption){assert(isRef(ref),"ref object is not a reference");var num=ref.num;if(num in this.cache){var cacheEntry=this.cache[num];return cacheEntry}var xrefEntry=this.getEntry(num);if(xrefEntry===null){return this.cache[num]=null}if(xrefEntry.uncompressed){xrefEntry=this.fetchUncompressed(ref,xrefEntry,suppressEncryption)}else{xrefEntry=this.fetchCompressed(xrefEntry,suppressEncryption)}if(isDict(xrefEntry)){xrefEntry.objId=ref.toString()}else if(isStream(xrefEntry)){xrefEntry.dict.objId=ref.toString()}return xrefEntry},fetchUncompressed:function XRef_fetchUncompressed(ref,xrefEntry,suppressEncryption){var gen=ref.gen;var num=ref.num;if(xrefEntry.gen!==gen){error("inconsistent generation in XRef")}var stream=this.stream.makeSubStream(xrefEntry.offset+this.stream.start);var parser=new Parser(new Lexer(stream),true,this);var obj1=parser.getObj();var obj2=parser.getObj();var obj3=parser.getObj();if(!isInt(obj1)||parseInt(obj1,10)!==num||!isInt(obj2)||parseInt(obj2,10)!==gen||!isCmd(obj3)){error("bad XRef entry")}if(!isCmd(obj3,"obj")){if(obj3.cmd.indexOf("obj")===0){num=parseInt(obj3.cmd.substring(3),10);if(!isNaN(num)){return num}}error("bad XRef entry")}if(this.encrypt&&!suppressEncryption){xrefEntry=parser.getObj(this.encrypt.createCipherTransform(num,gen))}else{xrefEntry=parser.getObj()}if(!isStream(xrefEntry)){this.cache[num]=xrefEntry}return xrefEntry},fetchCompressed:function XRef_fetchCompressed(xrefEntry,suppressEncryption){var tableOffset=xrefEntry.offset;var stream=this.fetch(new Ref(tableOffset,0));if(!isStream(stream)){error("bad ObjStm stream")}var first=stream.dict.get("First");var n=stream.dict.get("N");if(!isInt(first)||!isInt(n)){error("invalid first and n parameters for ObjStm stream")}var parser=new Parser(new Lexer(stream),false,this);parser.allowStreams=true;var i,entries=[],num,nums=[];for(i=0;i<n;++i){num=parser.getObj();if(!isInt(num)){error("invalid object number in the ObjStm stream: "+num)}nums.push(num);var offset=parser.getObj();if(!isInt(offset)){error("invalid object offset in the ObjStm stream: "+offset)}}for(i=0;i<n;++i){entries.push(parser.getObj());if(isCmd(parser.buf1,"endobj")){parser.shift()}num=nums[i];var entry=this.entries[num];if(entry&&entry.offset===tableOffset&&entry.gen===i){this.cache[num]=entries[i]}}xrefEntry=entries[xrefEntry.gen];if(xrefEntry===undefined){error("bad XRef entry for compressed object")}return xrefEntry},fetchIfRefAsync:function XRef_fetchIfRefAsync(obj){if(!isRef(obj)){return Promise.resolve(obj)}return this.fetchAsync(obj)},fetchAsync:function XRef_fetchAsync(ref,suppressEncryption){var streamManager=this.stream.manager;var xref=this;return new Promise(function tryFetch(resolve,reject){try{resolve(xref.fetch(ref,suppressEncryption))}catch(e){if(e instanceof MissingDataException){streamManager.requestRange(e.begin,e.end).then(function(){tryFetch(resolve,reject)},reject);return}reject(e)}})},getCatalogObj:function XRef_getCatalogObj(){return this.root}};return XRef}();var NameOrNumberTree=function NameOrNumberTreeClosure(){function NameOrNumberTree(root,xref){throw new Error("Cannot initialize NameOrNumberTree.")}NameOrNumberTree.prototype={getAll:function NameOrNumberTree_getAll(){var dict=Object.create(null);if(!this.root){return dict}var xref=this.xref;var processed=new RefSet;processed.put(this.root);var queue=[this.root];while(queue.length>0){var i,n;var obj=xref.fetchIfRef(queue.shift());if(!isDict(obj)){continue}if(obj.has("Kids")){var kids=obj.get("Kids");for(i=0,n=kids.length;i<n;i++){var kid=kids[i];assert(!processed.has(kid),'Duplicate entry in "'+this._type+'" tree.');queue.push(kid);processed.put(kid)}continue}var entries=obj.get(this._type);if(isArray(entries)){for(i=0,n=entries.length;i<n;i+=2){dict[xref.fetchIfRef(entries[i])]=xref.fetchIfRef(entries[i+1])}}}return dict},get:function NameOrNumberTree_get(key){if(!this.root){return null}var xref=this.xref;var kidsOrEntries=xref.fetchIfRef(this.root);var loopCount=0;var MAX_LEVELS=10;var l,r,m;while(kidsOrEntries.has("Kids")){if(++loopCount>MAX_LEVELS){warn('Search depth limit reached for "'+this._type+'" tree.');return null}var kids=kidsOrEntries.get("Kids");if(!isArray(kids)){return null}l=0;r=kids.length-1;while(l<=r){m=l+r>>1;var kid=xref.fetchIfRef(kids[m]);var limits=kid.get("Limits");if(key<xref.fetchIfRef(limits[0])){r=m-1}else if(key>xref.fetchIfRef(limits[1])){l=m+1}else{kidsOrEntries=xref.fetchIfRef(kids[m]);break}}if(l>r){return null}}var entries=kidsOrEntries.get(this._type);if(isArray(entries)){l=0;r=entries.length-2;while(l<=r){m=l+r&~1;var currentKey=xref.fetchIfRef(entries[m]);if(key<currentKey){r=m-2}else if(key>currentKey){l=m+2}else{return xref.fetchIfRef(entries[m+1])}}}return null}};return NameOrNumberTree}();var NameTree=function NameTreeClosure(){function NameTree(root,xref){this.root=root;this.xref=xref;this._type="Names"}Util.inherit(NameTree,NameOrNumberTree,{});return NameTree}();var NumberTree=function NumberTreeClosure(){function NumberTree(root,xref){this.root=root;this.xref=xref;this._type="Nums"}Util.inherit(NumberTree,NameOrNumberTree,{});return NumberTree}();var FileSpec=function FileSpecClosure(){function FileSpec(root,xref){if(!root||!isDict(root)){return}this.xref=xref;this.root=root;if(root.has("FS")){this.fs=root.get("FS")}this.description=root.has("Desc")?stringToPDFString(root.get("Desc")):"";if(root.has("RF")){warn("Related file specifications are not supported")}this.contentAvailable=true;if(!root.has("EF")){this.contentAvailable=false;warn("Non-embedded file specifications are not supported")}}function pickPlatformItem(dict){if(dict.has("UF")){return dict.get("UF")}else if(dict.has("F")){return dict.get("F")}else if(dict.has("Unix")){return dict.get("Unix")}else if(dict.has("Mac")){return dict.get("Mac")}else if(dict.has("DOS")){return dict.get("DOS")}else{return null}}FileSpec.prototype={get filename(){if(!this._filename&&this.root){var filename=pickPlatformItem(this.root)||"unnamed";this._filename=stringToPDFString(filename).replace(/\\\\/g,"\\").replace(/\\\//g,"/").replace(/\\/g,"/")}return this._filename},get content(){if(!this.contentAvailable){return null}if(!this.contentRef&&this.root){this.contentRef=pickPlatformItem(this.root.get("EF"))}var content=null;if(this.contentRef){var xref=this.xref;var fileObj=xref.fetchIfRef(this.contentRef);if(fileObj&&isStream(fileObj)){content=fileObj.getBytes()}else{warn("Embedded file specification points to non-existing/invalid "+"content")}}else{warn("Embedded file specification does not have a content")}return content},get serializable(){return{filename:this.filename,content:this.content}}};return FileSpec}();var ObjectLoader=function(){function mayHaveChildren(value){return isRef(value)||isDict(value)||isArray(value)||isStream(value)}function addChildren(node,nodesToVisit){var value;if(isDict(node)||isStream(node)){var map;if(isDict(node)){map=node.map}else{map=node.dict.map}for(var key in map){value=map[key];if(mayHaveChildren(value)){nodesToVisit.push(value)}}}else if(isArray(node)){for(var i=0,ii=node.length;i<ii;i++){value=node[i];if(mayHaveChildren(value)){nodesToVisit.push(value)}}}}function ObjectLoader(obj,keys,xref){this.obj=obj;this.keys=keys;this.xref=xref;this.refSet=null;this.capability=null}ObjectLoader.prototype={load:function ObjectLoader_load(){var keys=this.keys;this.capability=createPromiseCapability();if(!(this.xref.stream instanceof ChunkedStream)||this.xref.stream.getMissingChunks().length===0){this.capability.resolve();return this.capability.promise}this.refSet=new RefSet;var nodesToVisit=[];for(var i=0;i<keys.length;i++){nodesToVisit.push(this.obj[keys[i]])}this._walk(nodesToVisit);return this.capability.promise},_walk:function ObjectLoader_walk(nodesToVisit){var nodesToRevisit=[];var pendingRequests=[];while(nodesToVisit.length){var currentNode=nodesToVisit.pop();if(isRef(currentNode)){if(this.refSet.has(currentNode)){continue}try{var ref=currentNode;this.refSet.put(ref);currentNode=this.xref.fetch(currentNode)}catch(e){if(!(e instanceof MissingDataException)){throw e}nodesToRevisit.push(currentNode);pendingRequests.push({begin:e.begin,end:e.end})}}if(currentNode&&currentNode.getBaseStreams){var baseStreams=currentNode.getBaseStreams();var foundMissingData=false;for(var i=0;i<baseStreams.length;i++){var stream=baseStreams[i];if(stream.getMissingChunks&&stream.getMissingChunks().length){foundMissingData=true;pendingRequests.push({begin:stream.start,end:stream.end})}}if(foundMissingData){nodesToRevisit.push(currentNode)}}addChildren(currentNode,nodesToVisit)}if(pendingRequests.length){this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback(){nodesToVisit=nodesToRevisit;for(var i=0;i<nodesToRevisit.length;i++){var node=nodesToRevisit[i];if(isRef(node)){this.refSet.remove(node)}}this._walk(nodesToVisit)}.bind(this),this.capability.reject);return}this.refSet=null;this.capability.resolve()}};return ObjectLoader}();exports.Catalog=Catalog;exports.ObjectLoader=ObjectLoader;exports.XRef=XRef;exports.FileSpec=FileSpec});(function(root,factory){{factory(root.pdfjsCorePattern={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreFunction,root.pdfjsCoreColorSpace)}})(this,function(exports,sharedUtil,corePrimitives,coreFunction,coreColorSpace){var UNSUPPORTED_FEATURES=sharedUtil.UNSUPPORTED_FEATURES;var MissingDataException=sharedUtil.MissingDataException;var Util=sharedUtil.Util;var assert=sharedUtil.assert;var error=sharedUtil.error;var info=sharedUtil.info;var warn=sharedUtil.warn;var isStream=corePrimitives.isStream;var PDFFunction=coreFunction.PDFFunction;var ColorSpace=coreColorSpace.ColorSpace;var ShadingType={FUNCTION_BASED:1,AXIAL:2,RADIAL:3,FREE_FORM_MESH:4,LATTICE_FORM_MESH:5,COONS_PATCH_MESH:6,TENSOR_PATCH_MESH:7};var Pattern=function PatternClosure(){function Pattern(){error("should not call Pattern constructor")}Pattern.prototype={getPattern:function Pattern_getPattern(ctx){error("Should not call Pattern.getStyle: "+ctx)}};Pattern.parseShading=function Pattern_parseShading(shading,matrix,xref,res,handler){var dict=isStream(shading)?shading.dict:shading;var type=dict.get("ShadingType");try{switch(type){case ShadingType.AXIAL:case ShadingType.RADIAL:return new Shadings.RadialAxial(dict,matrix,xref,res);case ShadingType.FREE_FORM_MESH:case ShadingType.LATTICE_FORM_MESH:case ShadingType.COONS_PATCH_MESH:case ShadingType.TENSOR_PATCH_MESH:return new Shadings.Mesh(shading,matrix,xref,res);default:throw new Error("Unsupported ShadingType: "+type)}}catch(ex){if(ex instanceof MissingDataException){throw ex}handler.send("UnsupportedFeature",{featureId:UNSUPPORTED_FEATURES.shadingPattern});warn(ex);return new Shadings.Dummy}};return Pattern}();var Shadings={};Shadings.SMALL_NUMBER=1e-6;Shadings.RadialAxial=function RadialAxialClosure(){function RadialAxial(dict,matrix,xref,res){this.matrix=matrix;this.coordsArr=dict.getArray("Coords");this.shadingType=dict.get("ShadingType");this.type="Pattern";var cs=dict.get("ColorSpace","CS");cs=ColorSpace.parse(cs,xref,res);this.cs=cs;var t0=0,t1=1;if(dict.has("Domain")){var domainArr=dict.getArray("Domain");t0=domainArr[0];t1=domainArr[1]}var extendStart=false,extendEnd=false;if(dict.has("Extend")){var extendArr=dict.getArray("Extend");extendStart=extendArr[0];extendEnd=extendArr[1]}if(this.shadingType===ShadingType.RADIAL&&(!extendStart||!extendEnd)){var x1=this.coordsArr[0];var y1=this.coordsArr[1];var r1=this.coordsArr[2];var x2=this.coordsArr[3];var y2=this.coordsArr[4];var r2=this.coordsArr[5];var distance=Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));if(r1<=r2+distance&&r2<=r1+distance){warn("Unsupported radial gradient.")}}this.extendStart=extendStart;this.extendEnd=extendEnd;var fnObj=dict.get("Function");var fn=PDFFunction.parseArray(xref,fnObj);var diff=t1-t0;var step=diff/10;var colorStops=this.colorStops=[];if(t0>=t1||step<=0){info("Bad shading domain.");return}var color=new Float32Array(cs.numComps),ratio=new Float32Array(1);var rgbColor;for(var i=t0;i<=t1;i+=step){ratio[0]=i;fn(ratio,0,color,0);rgbColor=cs.getRgb(color,0);var cssColor=Util.makeCssRgb(rgbColor[0],rgbColor[1],rgbColor[2]);colorStops.push([(i-t0)/diff,cssColor])}var background="transparent";if(dict.has("Background")){rgbColor=cs.getRgb(dict.get("Background"),0);background=Util.makeCssRgb(rgbColor[0],rgbColor[1],rgbColor[2])}if(!extendStart){colorStops.unshift([0,background]);colorStops[1][0]+=Shadings.SMALL_NUMBER}if(!extendEnd){colorStops[colorStops.length-1][0]-=Shadings.SMALL_NUMBER;colorStops.push([1,background])}this.colorStops=colorStops}RadialAxial.prototype={getIR:function RadialAxial_getIR(){var coordsArr=this.coordsArr;var shadingType=this.shadingType;var type,p0,p1,r0,r1;if(shadingType===ShadingType.AXIAL){p0=[coordsArr[0],coordsArr[1]];p1=[coordsArr[2],coordsArr[3]];r0=null;r1=null;type="axial"}else if(shadingType===ShadingType.RADIAL){p0=[coordsArr[0],coordsArr[1]];p1=[coordsArr[3],coordsArr[4]];r0=coordsArr[2];r1=coordsArr[5];type="radial"}else{error("getPattern type unknown: "+shadingType)}var matrix=this.matrix;if(matrix){p0=Util.applyTransform(p0,matrix);p1=Util.applyTransform(p1,matrix);if(shadingType===ShadingType.RADIAL){var scale=Util.singularValueDecompose2dScale(matrix);r0*=scale[0];r1*=scale[1]}}return["RadialAxial",type,this.colorStops,p0,p1,r0,r1]}};return RadialAxial}();Shadings.Mesh=function MeshClosure(){function MeshStreamReader(stream,context){this.stream=stream;this.context=context;this.buffer=0;this.bufferLength=0;var numComps=context.numComps;this.tmpCompsBuf=new Float32Array(numComps);var csNumComps=context.colorSpace.numComps;this.tmpCsCompsBuf=context.colorFn?new Float32Array(csNumComps):this.tmpCompsBuf}MeshStreamReader.prototype={get hasData(){if(this.stream.end){return this.stream.pos<this.stream.end}if(this.bufferLength>0){return true}var nextByte=this.stream.getByte();if(nextByte<0){return false}this.buffer=nextByte;this.bufferLength=8;return true},readBits:function MeshStreamReader_readBits(n){var buffer=this.buffer;var bufferLength=this.bufferLength;if(n===32){if(bufferLength===0){return(this.stream.getByte()<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte())>>>0}buffer=buffer<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte();var nextByte=this.stream.getByte();this.buffer=nextByte&(1<<bufferLength)-1;return(buffer<<8-bufferLength|(nextByte&255)>>bufferLength)>>>0}if(n===8&&bufferLength===0){return this.stream.getByte()}while(bufferLength<n){buffer=buffer<<8|this.stream.getByte();bufferLength+=8}bufferLength-=n;this.bufferLength=bufferLength;this.buffer=buffer&(1<<bufferLength)-1;return buffer>>bufferLength},align:function MeshStreamReader_align(){this.buffer=0;this.bufferLength=0},readFlag:function MeshStreamReader_readFlag(){return this.readBits(this.context.bitsPerFlag)},readCoordinate:function MeshStreamReader_readCoordinate(){var bitsPerCoordinate=this.context.bitsPerCoordinate;var xi=this.readBits(bitsPerCoordinate);var yi=this.readBits(bitsPerCoordinate);var decode=this.context.decode;var scale=bitsPerCoordinate<32?1/((1<<bitsPerCoordinate)-1):2.3283064365386963e-10;return[xi*scale*(decode[1]-decode[0])+decode[0],yi*scale*(decode[3]-decode[2])+decode[2]]},readComponents:function MeshStreamReader_readComponents(){var numComps=this.context.numComps;var bitsPerComponent=this.context.bitsPerComponent;var scale=bitsPerComponent<32?1/((1<<bitsPerComponent)-1):2.3283064365386963e-10;var decode=this.context.decode;var components=this.tmpCompsBuf;for(var i=0,j=4;i<numComps;i++,j+=2){var ci=this.readBits(bitsPerComponent);components[i]=ci*scale*(decode[j+1]-decode[j])+decode[j]}var color=this.tmpCsCompsBuf;if(this.context.colorFn){this.context.colorFn(components,0,color,0)}return this.context.colorSpace.getRgb(color,0)}};function decodeType4Shading(mesh,reader){var coords=mesh.coords;var colors=mesh.colors;var operators=[];var ps=[];var verticesLeft=0;while(reader.hasData){var f=reader.readFlag();var coord=reader.readCoordinate();var color=reader.readComponents();if(verticesLeft===0){assert(0<=f&&f<=2,"Unknown type4 flag");switch(f){case 0:verticesLeft=3;break;case 1:ps.push(ps[ps.length-2],ps[ps.length-1]);verticesLeft=1;break;case 2:ps.push(ps[ps.length-3],ps[ps.length-1]);verticesLeft=1;break}operators.push(f)}ps.push(coords.length);coords.push(coord);colors.push(color);verticesLeft--;reader.align()}mesh.figures.push({type:"triangles",coords:new Int32Array(ps),colors:new Int32Array(ps)})}function decodeType5Shading(mesh,reader,verticesPerRow){var coords=mesh.coords;var colors=mesh.colors;var ps=[];while(reader.hasData){var coord=reader.readCoordinate();var color=reader.readComponents();ps.push(coords.length);coords.push(coord);colors.push(color)}mesh.figures.push({type:"lattice",coords:new Int32Array(ps),colors:new Int32Array(ps),verticesPerRow:verticesPerRow})}var MIN_SPLIT_PATCH_CHUNKS_AMOUNT=3;var MAX_SPLIT_PATCH_CHUNKS_AMOUNT=20;var TRIANGLE_DENSITY=20;var getB=function getBClosure(){function buildB(count){var lut=[];for(var i=0;i<=count;i++){var t=i/count,t_=1-t;lut.push(new Float32Array([t_*t_*t_,3*t*t_*t_,3*t*t*t_,t*t*t]))}return lut}var cache=[];return function getB(count){if(!cache[count]){cache[count]=buildB(count)}return cache[count]}}();function buildFigureFromPatch(mesh,index){var figure=mesh.figures[index];assert(figure.type==="patch","Unexpected patch mesh figure");var coords=mesh.coords,colors=mesh.colors;var pi=figure.coords;var ci=figure.colors;var figureMinX=Math.min(coords[pi[0]][0],coords[pi[3]][0],coords[pi[12]][0],coords[pi[15]][0]);var figureMinY=Math.min(coords[pi[0]][1],coords[pi[3]][1],coords[pi[12]][1],coords[pi[15]][1]);var figureMaxX=Math.max(coords[pi[0]][0],coords[pi[3]][0],coords[pi[12]][0],coords[pi[15]][0]);var figureMaxY=Math.max(coords[pi[0]][1],coords[pi[3]][1],coords[pi[12]][1],coords[pi[15]][1]);var splitXBy=Math.ceil((figureMaxX-figureMinX)*TRIANGLE_DENSITY/(mesh.bounds[2]-mesh.bounds[0]));splitXBy=Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT,Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT,splitXBy));var splitYBy=Math.ceil((figureMaxY-figureMinY)*TRIANGLE_DENSITY/(mesh.bounds[3]-mesh.bounds[1]));splitYBy=Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT,Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT,splitYBy));var verticesPerRow=splitXBy+1;var figureCoords=new Int32Array((splitYBy+1)*verticesPerRow);var figureColors=new Int32Array((splitYBy+1)*verticesPerRow);var k=0;var cl=new Uint8Array(3),cr=new Uint8Array(3);var c0=colors[ci[0]],c1=colors[ci[1]],c2=colors[ci[2]],c3=colors[ci[3]];var bRow=getB(splitYBy),bCol=getB(splitXBy);for(var row=0;row<=splitYBy;row++){cl[0]=(c0[0]*(splitYBy-row)+c2[0]*row)/splitYBy|0;cl[1]=(c0[1]*(splitYBy-row)+c2[1]*row)/splitYBy|0;cl[2]=(c0[2]*(splitYBy-row)+c2[2]*row)/splitYBy|0;cr[0]=(c1[0]*(splitYBy-row)+c3[0]*row)/splitYBy|0;cr[1]=(c1[1]*(splitYBy-row)+c3[1]*row)/splitYBy|0;cr[2]=(c1[2]*(splitYBy-row)+c3[2]*row)/splitYBy|0;for(var col=0;col<=splitXBy;col++,k++){if((row===0||row===splitYBy)&&(col===0||col===splitXBy)){continue}var x=0,y=0;var q=0;for(var i=0;i<=3;i++){for(var j=0;j<=3;j++,q++){var m=bRow[row][i]*bCol[col][j];x+=coords[pi[q]][0]*m;y+=coords[pi[q]][1]*m}}figureCoords[k]=coords.length;coords.push([x,y]);figureColors[k]=colors.length;var newColor=new Uint8Array(3);newColor[0]=(cl[0]*(splitXBy-col)+cr[0]*col)/splitXBy|0;newColor[1]=(cl[1]*(splitXBy-col)+cr[1]*col)/splitXBy|0;newColor[2]=(cl[2]*(splitXBy-col)+cr[2]*col)/splitXBy|0;colors.push(newColor)}}figureCoords[0]=pi[0];figureColors[0]=ci[0];figureCoords[splitXBy]=pi[3];figureColors[splitXBy]=ci[1];figureCoords[verticesPerRow*splitYBy]=pi[12];figureColors[verticesPerRow*splitYBy]=ci[2];figureCoords[verticesPerRow*splitYBy+splitXBy]=pi[15];figureColors[verticesPerRow*splitYBy+splitXBy]=ci[3];mesh.figures[index]={type:"lattice",coords:figureCoords,colors:figureColors,verticesPerRow:verticesPerRow}}function decodeType6Shading(mesh,reader){var coords=mesh.coords;var colors=mesh.colors;var ps=new Int32Array(16);var cs=new Int32Array(4);while(reader.hasData){var f=reader.readFlag();assert(0<=f&&f<=3,"Unknown type6 flag");var i,ii;var pi=coords.length;for(i=0,ii=f!==0?8:12;i<ii;i++){coords.push(reader.readCoordinate())}var ci=colors.length;for(i=0,ii=f!==0?2:4;i<ii;i++){colors.push(reader.readComponents())}var tmp1,tmp2,tmp3,tmp4;switch(f){case 0:ps[12]=pi+3;ps[13]=pi+4;ps[14]=pi+5;ps[15]=pi+6;ps[8]=pi+2;ps[11]=pi+7;ps[4]=pi+1;ps[7]=pi+8;ps[0]=pi;ps[1]=pi+11;ps[2]=pi+10;ps[3]=pi+9;cs[2]=ci+1;cs[3]=ci+2;cs[0]=ci;cs[1]=ci+3;break;case 1:tmp1=ps[12];tmp2=ps[13];tmp3=ps[14];tmp4=ps[15];ps[12]=tmp4;ps[13]=pi+0;ps[14]=pi+1;ps[15]=pi+2;ps[8]=tmp3;ps[11]=pi+3;ps[4]=tmp2;ps[7]=pi+4;ps[0]=tmp1;ps[1]=pi+7;ps[2]=pi+6;ps[3]=pi+5;tmp1=cs[2];tmp2=cs[3];cs[2]=tmp2;cs[3]=ci;cs[0]=tmp1;cs[1]=ci+1;break;case 2:tmp1=ps[15];tmp2=ps[11];ps[12]=ps[3];ps[13]=pi+0;ps[14]=pi+1;ps[15]=pi+2;ps[8]=ps[7];ps[11]=pi+3;ps[4]=tmp2;ps[7]=pi+4;ps[0]=tmp1;ps[1]=pi+7;ps[2]=pi+6;ps[3]=pi+5;tmp1=cs[3];cs[2]=cs[1];cs[3]=ci;cs[0]=tmp1;cs[1]=ci+1;break;case 3:ps[12]=ps[0];ps[13]=pi+0;ps[14]=pi+1;ps[15]=pi+2;ps[8]=ps[1];ps[11]=pi+3;ps[4]=ps[2];ps[7]=pi+4;ps[0]=ps[3];ps[1]=pi+7;ps[2]=pi+6;ps[3]=pi+5;cs[2]=cs[0];cs[3]=ci;cs[0]=cs[1];cs[1]=ci+1;break}ps[5]=coords.length;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]);ps[6]=coords.length;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]);ps[9]=coords.length;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]);ps[10]=coords.length;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]);mesh.figures.push({type:"patch",coords:new Int32Array(ps),colors:new Int32Array(cs)})}}function decodeType7Shading(mesh,reader){var coords=mesh.coords;var colors=mesh.colors;var ps=new Int32Array(16);var cs=new Int32Array(4);while(reader.hasData){var f=reader.readFlag();assert(0<=f&&f<=3,"Unknown type7 flag");var i,ii;var pi=coords.length;for(i=0,ii=f!==0?12:16;i<ii;i++){coords.push(reader.readCoordinate())}var ci=colors.length;for(i=0,ii=f!==0?2:4;i<ii;i++){colors.push(reader.readComponents())}var tmp1,tmp2,tmp3,tmp4;switch(f){case 0:ps[12]=pi+3;ps[13]=pi+4;ps[14]=pi+5;ps[15]=pi+6;ps[8]=pi+2;ps[9]=pi+13;ps[10]=pi+14;ps[11]=pi+7;ps[4]=pi+1;ps[5]=pi+12;ps[6]=pi+15;ps[7]=pi+8;ps[0]=pi;ps[1]=pi+11;ps[2]=pi+10;ps[3]=pi+9;cs[2]=ci+1;cs[3]=ci+2;cs[0]=ci;cs[1]=ci+3;break;case 1:tmp1=ps[12];tmp2=ps[13];tmp3=ps[14];tmp4=ps[15];ps[12]=tmp4;ps[13]=pi+0;ps[14]=pi+1;ps[15]=pi+2;ps[8]=tmp3;ps[9]=pi+9;ps[10]=pi+10;ps[11]=pi+3;ps[4]=tmp2;ps[5]=pi+8;ps[6]=pi+11;ps[7]=pi+4;ps[0]=tmp1;ps[1]=pi+7;ps[2]=pi+6;ps[3]=pi+5;tmp1=cs[2];tmp2=cs[3];cs[2]=tmp2;cs[3]=ci;cs[0]=tmp1;cs[1]=ci+1;break;case 2:tmp1=ps[15];tmp2=ps[11];ps[12]=ps[3];ps[13]=pi+0;ps[14]=pi+1;ps[15]=pi+2;ps[8]=ps[7];ps[9]=pi+9;ps[10]=pi+10;ps[11]=pi+3;ps[4]=tmp2;ps[5]=pi+8;ps[6]=pi+11;ps[7]=pi+4;ps[0]=tmp1;ps[1]=pi+7;ps[2]=pi+6;ps[3]=pi+5;tmp1=cs[3];cs[2]=cs[1];cs[3]=ci;cs[0]=tmp1;cs[1]=ci+1;break;case 3:ps[12]=ps[0];ps[13]=pi+0;ps[14]=pi+1;ps[15]=pi+2;ps[8]=ps[1];ps[9]=pi+9;ps[10]=pi+10;ps[11]=pi+3;ps[4]=ps[2];ps[5]=pi+8;ps[6]=pi+11;ps[7]=pi+4;ps[0]=ps[3];ps[1]=pi+7;ps[2]=pi+6;ps[3]=pi+5;cs[2]=cs[0];cs[3]=ci;cs[0]=cs[1];cs[1]=ci+1;break}mesh.figures.push({type:"patch",coords:new Int32Array(ps),colors:new Int32Array(cs)})}}function updateBounds(mesh){var minX=mesh.coords[0][0],minY=mesh.coords[0][1],maxX=minX,maxY=minY;for(var i=1,ii=mesh.coords.length;i<ii;i++){var x=mesh.coords[i][0],y=mesh.coords[i][1];minX=minX>x?x:minX;minY=minY>y?y:minY;maxX=maxX<x?x:maxX;maxY=maxY<y?y:maxY}mesh.bounds=[minX,minY,maxX,maxY]}function packData(mesh){var i,ii,j,jj;var coords=mesh.coords;var coordsPacked=new Float32Array(coords.length*2);for(i=0,j=0,ii=coords.length;i<ii;i++){var xy=coords[i];coordsPacked[j++]=xy[0];coordsPacked[j++]=xy[1]}mesh.coords=coordsPacked;var colors=mesh.colors;var colorsPacked=new Uint8Array(colors.length*3);for(i=0,j=0,ii=colors.length;i<ii;i++){var c=colors[i];colorsPacked[j++]=c[0];colorsPacked[j++]=c[1];colorsPacked[j++]=c[2]}mesh.colors=colorsPacked;var figures=mesh.figures;for(i=0,ii=figures.length;i<ii;i++){var figure=figures[i],ps=figure.coords,cs=figure.colors;for(j=0,jj=ps.length;j<jj;j++){ps[j]*=2;cs[j]*=3}}}function Mesh(stream,matrix,xref,res){assert(isStream(stream),"Mesh data is not a stream");var dict=stream.dict;this.matrix=matrix;this.shadingType=dict.get("ShadingType");this.type="Pattern";this.bbox=dict.getArray("BBox");var cs=dict.get("ColorSpace","CS");cs=ColorSpace.parse(cs,xref,res);this.cs=cs;this.background=dict.has("Background")?cs.getRgb(dict.get("Background"),0):null;var fnObj=dict.get("Function");var fn=fnObj?PDFFunction.parseArray(xref,fnObj):null;this.coords=[];this.colors=[];this.figures=[];var decodeContext={bitsPerCoordinate:dict.get("BitsPerCoordinate"),bitsPerComponent:dict.get("BitsPerComponent"),bitsPerFlag:dict.get("BitsPerFlag"),decode:dict.getArray("Decode"),colorFn:fn,colorSpace:cs,numComps:fn?1:cs.numComps};var reader=new MeshStreamReader(stream,decodeContext);var patchMesh=false;switch(this.shadingType){case ShadingType.FREE_FORM_MESH:decodeType4Shading(this,reader);break;case ShadingType.LATTICE_FORM_MESH:var verticesPerRow=dict.get("VerticesPerRow")|0;assert(verticesPerRow>=2,"Invalid VerticesPerRow");decodeType5Shading(this,reader,verticesPerRow);break;case ShadingType.COONS_PATCH_MESH:decodeType6Shading(this,reader);patchMesh=true;break;case ShadingType.TENSOR_PATCH_MESH:decodeType7Shading(this,reader);patchMesh=true;break;default:error("Unsupported mesh type.");break}if(patchMesh){updateBounds(this);for(var i=0,ii=this.figures.length;i<ii;i++){buildFigureFromPatch(this,i)}}updateBounds(this);packData(this)}Mesh.prototype={getIR:function Mesh_getIR(){return["Mesh",this.shadingType,this.coords,this.colors,this.figures,this.bounds,this.matrix,this.bbox,this.background]}};return Mesh}();Shadings.Dummy=function DummyClosure(){function Dummy(){this.type="Pattern"}Dummy.prototype={getIR:function Dummy_getIR(){return["Dummy"]}};return Dummy}();function getTilingPatternIR(operatorList,dict,args){var matrix=dict.getArray("Matrix");var bbox=dict.getArray("BBox");var xstep=dict.get("XStep");var ystep=dict.get("YStep");var paintType=dict.get("PaintType");var tilingType=dict.get("TilingType");return["TilingPattern",args,operatorList,matrix,bbox,xstep,ystep,paintType,tilingType]}exports.Pattern=Pattern;exports.getTilingPatternIR=getTilingPatternIR});(function(root,factory){{factory(root.pdfjsCoreEvaluator={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreStream,root.pdfjsCoreParser,root.pdfjsCoreImage,root.pdfjsCoreColorSpace,root.pdfjsCoreMurmurHash3,root.pdfjsCoreFonts,root.pdfjsCoreFunction,root.pdfjsCorePattern,root.pdfjsCoreCMap,root.pdfjsCoreMetrics,root.pdfjsCoreBidi,root.pdfjsCoreEncodings,root.pdfjsCoreStandardFonts,root.pdfjsCoreUnicode,root.pdfjsCoreGlyphList)}})(this,function(exports,sharedUtil,corePrimitives,coreStream,coreParser,coreImage,coreColorSpace,coreMurmurHash3,coreFonts,coreFunction,corePattern,coreCMap,coreMetrics,coreBidi,coreEncodings,coreStandardFonts,coreUnicode,coreGlyphList){var FONT_IDENTITY_MATRIX=sharedUtil.FONT_IDENTITY_MATRIX;var IDENTITY_MATRIX=sharedUtil.IDENTITY_MATRIX;var UNSUPPORTED_FEATURES=sharedUtil.UNSUPPORTED_FEATURES;var ImageKind=sharedUtil.ImageKind;var OPS=sharedUtil.OPS;var TextRenderingMode=sharedUtil.TextRenderingMode;var Util=sharedUtil.Util;var assert=sharedUtil.assert;var createPromiseCapability=sharedUtil.createPromiseCapability;var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var isNum=sharedUtil.isNum;var isString=sharedUtil.isString;var getLookupTableFactory=sharedUtil.getLookupTableFactory;var warn=sharedUtil.warn;var Dict=corePrimitives.Dict;var Name=corePrimitives.Name;var isCmd=corePrimitives.isCmd;var isDict=corePrimitives.isDict;var isName=corePrimitives.isName;var isRef=corePrimitives.isRef;var isStream=corePrimitives.isStream;var DecodeStream=coreStream.DecodeStream;var JpegStream=coreStream.JpegStream;var Stream=coreStream.Stream;var Lexer=coreParser.Lexer;var Parser=coreParser.Parser;var isEOF=coreParser.isEOF;var PDFImage=coreImage.PDFImage;var ColorSpace=coreColorSpace.ColorSpace;var MurmurHash3_64=coreMurmurHash3.MurmurHash3_64;var ErrorFont=coreFonts.ErrorFont;var FontFlags=coreFonts.FontFlags;var Font=coreFonts.Font;var IdentityToUnicodeMap=coreFonts.IdentityToUnicodeMap;var ToUnicodeMap=coreFonts.ToUnicodeMap;var getFontType=coreFonts.getFontType;
24var isPDFFunction=coreFunction.isPDFFunction;var PDFFunction=coreFunction.PDFFunction;var Pattern=corePattern.Pattern;var getTilingPatternIR=corePattern.getTilingPatternIR;var CMapFactory=coreCMap.CMapFactory;var IdentityCMap=coreCMap.IdentityCMap;var getMetrics=coreMetrics.getMetrics;var bidi=coreBidi.bidi;var WinAnsiEncoding=coreEncodings.WinAnsiEncoding;var StandardEncoding=coreEncodings.StandardEncoding;var MacRomanEncoding=coreEncodings.MacRomanEncoding;var SymbolSetEncoding=coreEncodings.SymbolSetEncoding;var ZapfDingbatsEncoding=coreEncodings.ZapfDingbatsEncoding;var getEncoding=coreEncodings.getEncoding;var getStdFontMap=coreStandardFonts.getStdFontMap;var getSerifFonts=coreStandardFonts.getSerifFonts;var getSymbolsFonts=coreStandardFonts.getSymbolsFonts;var getNormalizedUnicodes=coreUnicode.getNormalizedUnicodes;var reverseIfRtl=coreUnicode.reverseIfRtl;var getUnicodeForGlyph=coreUnicode.getUnicodeForGlyph;var getGlyphsUnicode=coreGlyphList.getGlyphsUnicode;var PartialEvaluator=function PartialEvaluatorClosure(){var DefaultPartialEvaluatorOptions={forceDataSchema:false,maxImageSize:-1,disableFontFace:false,cMapOptions:{url:null,packed:false}};function NativeImageDecoder(xref,resources,handler,forceDataSchema){this.xref=xref;this.resources=resources;this.handler=handler;this.forceDataSchema=forceDataSchema}NativeImageDecoder.prototype={canDecode:function(image){return image instanceof JpegStream&&NativeImageDecoder.isDecodable(image,this.xref,this.resources)},decode:function(image){var dict=image.dict;var colorSpace=dict.get("ColorSpace","CS");colorSpace=ColorSpace.parse(colorSpace,this.xref,this.resources);var numComps=colorSpace.numComps;var decodePromise=this.handler.sendWithPromise("JpegDecode",[image.getIR(this.forceDataSchema),numComps]);return decodePromise.then(function(message){var data=message.data;return new Stream(data,0,data.length,image.dict)})}};NativeImageDecoder.isSupported=function NativeImageDecoder_isSupported(image,xref,res){var dict=image.dict;if(dict.has("DecodeParms")||dict.has("DP")){return false}var cs=ColorSpace.parse(dict.get("ColorSpace","CS"),xref,res);return(cs.name==="DeviceGray"||cs.name==="DeviceRGB")&&cs.isDefaultDecode(dict.getArray("Decode","D"))};NativeImageDecoder.isDecodable=function NativeImageDecoder_isDecodable(image,xref,res){var dict=image.dict;if(dict.has("DecodeParms")||dict.has("DP")){return false}var cs=ColorSpace.parse(dict.get("ColorSpace","CS"),xref,res);return(cs.numComps===1||cs.numComps===3)&&cs.isDefaultDecode(dict.getArray("Decode","D"))};function PartialEvaluator(pdfManager,xref,handler,pageIndex,uniquePrefix,idCounters,fontCache,options){this.pdfManager=pdfManager;this.xref=xref;this.handler=handler;this.pageIndex=pageIndex;this.uniquePrefix=uniquePrefix;this.idCounters=idCounters;this.fontCache=fontCache;this.options=options||DefaultPartialEvaluatorOptions}var TIME_SLOT_DURATION_MS=20;var CHECK_TIME_EVERY=100;function TimeSlotManager(){this.reset()}TimeSlotManager.prototype={check:function TimeSlotManager_check(){if(++this.checked<CHECK_TIME_EVERY){return false}this.checked=0;return this.endTime<=Date.now()},reset:function TimeSlotManager_reset(){this.endTime=Date.now()+TIME_SLOT_DURATION_MS;this.checked=0}};var deferred=Promise.resolve();var TILING_PATTERN=1,SHADING_PATTERN=2;PartialEvaluator.prototype={hasBlendModes:function PartialEvaluator_hasBlendModes(resources){if(!isDict(resources)){return false}var processed=Object.create(null);if(resources.objId){processed[resources.objId]=true}var nodes=[resources],xref=this.xref;while(nodes.length){var key,i,ii;var node=nodes.shift();var graphicStates=node.get("ExtGState");if(isDict(graphicStates)){var graphicStatesKeys=graphicStates.getKeys();for(i=0,ii=graphicStatesKeys.length;i<ii;i++){key=graphicStatesKeys[i];var graphicState=graphicStates.get(key);var bm=graphicState.get("BM");if(isName(bm)&&bm.name!=="Normal"){return true}}}var xObjects=node.get("XObject");if(!isDict(xObjects)){continue}var xObjectsKeys=xObjects.getKeys();for(i=0,ii=xObjectsKeys.length;i<ii;i++){key=xObjectsKeys[i];var xObject=xObjects.getRaw(key);if(isRef(xObject)){if(processed[xObject.toString()]){continue}xObject=xref.fetch(xObject)}if(!isStream(xObject)){continue}if(xObject.dict.objId){if(processed[xObject.dict.objId]){continue}processed[xObject.dict.objId]=true}var xResources=xObject.dict.get("Resources");if(isDict(xResources)&&(!xResources.objId||!processed[xResources.objId])){nodes.push(xResources);if(xResources.objId){processed[xResources.objId]=true}}}}return false},buildFormXObject:function PartialEvaluator_buildFormXObject(resources,xobj,smask,operatorList,task,initialState){var matrix=xobj.dict.getArray("Matrix");var bbox=xobj.dict.getArray("BBox");var group=xobj.dict.get("Group");if(group){var groupOptions={matrix:matrix,bbox:bbox,smask:smask,isolated:false,knockout:false};var groupSubtype=group.get("S");var colorSpace;if(isName(groupSubtype,"Transparency")){groupOptions.isolated=group.get("I")||false;groupOptions.knockout=group.get("K")||false;colorSpace=group.has("CS")?ColorSpace.parse(group.get("CS"),this.xref,resources):null}if(smask&&smask.backdrop){colorSpace=colorSpace||ColorSpace.singletons.rgb;smask.backdrop=colorSpace.getRgb(smask.backdrop,0)}operatorList.addOp(OPS.beginGroup,[groupOptions])}operatorList.addOp(OPS.paintFormXObjectBegin,[matrix,bbox]);return this.getOperatorList(xobj,task,xobj.dict.get("Resources")||resources,operatorList,initialState).then(function(){operatorList.addOp(OPS.paintFormXObjectEnd,[]);if(group){operatorList.addOp(OPS.endGroup,[groupOptions])}})},buildPaintImageXObject:function PartialEvaluator_buildPaintImageXObject(resources,image,inline,operatorList,cacheKey,imageCache){var self=this;var dict=image.dict;var w=dict.get("Width","W");var h=dict.get("Height","H");if(!(w&&isNum(w))||!(h&&isNum(h))){warn("Image dimensions are missing, or not numbers.");return}var maxImageSize=this.options.maxImageSize;if(maxImageSize!==-1&&w*h>maxImageSize){warn("Image exceeded maximum allowed size and was removed.");return}var imageMask=dict.get("ImageMask","IM")||false;var imgData,args;if(imageMask){var width=dict.get("Width","W");var height=dict.get("Height","H");var bitStrideLength=width+7>>3;var imgArray=image.getBytes(bitStrideLength*height);var decode=dict.getArray("Decode","D");var inverseDecode=!!decode&&decode[0]>0;imgData=PDFImage.createMask(imgArray,width,height,image instanceof DecodeStream,inverseDecode);imgData.cached=true;args=[imgData];operatorList.addOp(OPS.paintImageMaskXObject,args);if(cacheKey){imageCache[cacheKey]={fn:OPS.paintImageMaskXObject,args:args}}return}var softMask=dict.get("SMask","SM")||false;var mask=dict.get("Mask")||false;var SMALL_IMAGE_DIMENSIONS=200;if(inline&&!softMask&&!mask&&!(image instanceof JpegStream)&&w+h<SMALL_IMAGE_DIMENSIONS){var imageObj=new PDFImage(this.xref,resources,image,inline,null,null);imgData=imageObj.createImageData(true);operatorList.addOp(OPS.paintInlineImageXObject,[imgData]);return}var uniquePrefix=this.uniquePrefix||"";var objId="img_"+uniquePrefix+ ++this.idCounters.obj;operatorList.addDependency(objId);args=[objId,w,h];if(!softMask&&!mask&&image instanceof JpegStream&&NativeImageDecoder.isSupported(image,this.xref,resources)){operatorList.addOp(OPS.paintJpegXObject,args);this.handler.send("obj",[objId,this.pageIndex,"JpegStream",image.getIR(this.options.forceDataSchema)]);return}var nativeImageDecoder=null;if(image instanceof JpegStream||mask instanceof JpegStream||softMask instanceof JpegStream){nativeImageDecoder=new NativeImageDecoder(self.xref,resources,self.handler,self.options.forceDataSchema)}PDFImage.buildImage(self.handler,self.xref,resources,image,inline,nativeImageDecoder).then(function(imageObj){var imgData=imageObj.createImageData(false);self.handler.send("obj",[objId,self.pageIndex,"Image",imgData],[imgData.data.buffer])}).then(undefined,function(reason){warn("Unable to decode image: "+reason);self.handler.send("obj",[objId,self.pageIndex,"Image",null])});operatorList.addOp(OPS.paintImageXObject,args);if(cacheKey){imageCache[cacheKey]={fn:OPS.paintImageXObject,args:args}}},handleSMask:function PartialEvaluator_handleSmask(smask,resources,operatorList,task,stateManager){var smaskContent=smask.get("G");var smaskOptions={subtype:smask.get("S").name,backdrop:smask.get("BC")};var transferObj=smask.get("TR");if(isPDFFunction(transferObj)){var transferFn=PDFFunction.parse(this.xref,transferObj);var transferMap=new Uint8Array(256);var tmp=new Float32Array(1);for(var i=0;i<256;i++){tmp[0]=i/255;transferFn(tmp,0,tmp,0);transferMap[i]=tmp[0]*255|0}smaskOptions.transferMap=transferMap}return this.buildFormXObject(resources,smaskContent,smaskOptions,operatorList,task,stateManager.state.clone())},handleTilingType:function PartialEvaluator_handleTilingType(fn,args,resources,pattern,patternDict,operatorList,task){var tilingOpList=new OperatorList;var resourcesArray=[patternDict.get("Resources"),resources];var patternResources=Dict.merge(this.xref,resourcesArray);return this.getOperatorList(pattern,task,patternResources,tilingOpList).then(function(){operatorList.addDependencies(tilingOpList.dependencies);operatorList.addOp(fn,getTilingPatternIR({fnArray:tilingOpList.fnArray,argsArray:tilingOpList.argsArray},patternDict,args))})},handleSetFont:function PartialEvaluator_handleSetFont(resources,fontArgs,fontRef,operatorList,task,state){var fontName;if(fontArgs){fontArgs=fontArgs.slice();fontName=fontArgs[0].name}var self=this;return this.loadFont(fontName,fontRef,this.xref,resources).then(function(translated){if(!translated.font.isType3Font){return translated}return translated.loadType3Data(self,resources,operatorList,task).then(function(){return translated},function(reason){self.handler.send("UnsupportedFeature",{featureId:UNSUPPORTED_FEATURES.font});return new TranslatedFont("g_font_error",new ErrorFont("Type3 font load error: "+reason),translated.font)})}).then(function(translated){state.font=translated.font;translated.send(self.handler);return translated.loadedName})},handleText:function PartialEvaluator_handleText(chars,state){var font=state.font;var glyphs=font.charsToGlyphs(chars);var isAddToPathSet=!!(state.textRenderingMode&TextRenderingMode.ADD_TO_PATH_FLAG);if(font.data&&(isAddToPathSet||this.options.disableFontFace)){var buildPath=function(fontChar){if(!font.renderer.hasBuiltPath(fontChar)){var path=font.renderer.getPathJs(fontChar);this.handler.send("commonobj",[font.loadedName+"_path_"+fontChar,"FontPath",path])}}.bind(this);for(var i=0,ii=glyphs.length;i<ii;i++){var glyph=glyphs[i];buildPath(glyph.fontChar);var accent=glyph.accent;if(accent&&accent.fontChar){buildPath(accent.fontChar)}}}return glyphs},setGState:function PartialEvaluator_setGState(resources,gState,operatorList,task,xref,stateManager){var gStateObj=[];var gStateKeys=gState.getKeys();var self=this;var promise=Promise.resolve();for(var i=0,ii=gStateKeys.length;i<ii;i++){var key=gStateKeys[i];var value=gState.get(key);switch(key){case"Type":break;case"LW":case"LC":case"LJ":case"ML":case"D":case"RI":case"FL":case"CA":case"ca":gStateObj.push([key,value]);break;case"Font":promise=promise.then(function(){return self.handleSetFont(resources,null,value[0],operatorList,task,stateManager.state).then(function(loadedName){operatorList.addDependency(loadedName);gStateObj.push([key,[loadedName,value[1]]])})});break;case"BM":gStateObj.push([key,value]);break;case"SMask":if(isName(value,"None")){gStateObj.push([key,false]);break}if(isDict(value)){promise=promise.then(function(dict){return self.handleSMask(dict,resources,operatorList,task,stateManager)}.bind(this,value));gStateObj.push([key,true])}else{warn("Unsupported SMask type")}break;case"OP":case"op":case"OPM":case"BG":case"BG2":case"UCR":case"UCR2":case"TR":case"TR2":case"HT":case"SM":case"SA":case"AIS":case"TK":info("graphic state operator "+key);break;default:info("Unknown graphic state operator "+key);break}}return promise.then(function(){if(gStateObj.length>0){operatorList.addOp(OPS.setGState,[gStateObj])}})},loadFont:function PartialEvaluator_loadFont(fontName,font,xref,resources){function errorFont(){return Promise.resolve(new TranslatedFont("g_font_error",new ErrorFont("Font "+fontName+" is not available"),font))}var fontRef;if(font){assert(isRef(font));fontRef=font}else{var fontRes=resources.get("Font");if(fontRes){fontRef=fontRes.getRaw(fontName)}else{warn("fontRes not available");return errorFont()}}if(!fontRef){warn("fontRef not available");return errorFont()}if(this.fontCache.has(fontRef)){return this.fontCache.get(fontRef)}font=xref.fetchIfRef(fontRef);if(!isDict(font)){return errorFont()}if(font.translated){return font.translated}var fontCapability=createPromiseCapability();var preEvaluatedFont=this.preEvaluateFont(font,xref);var descriptor=preEvaluatedFont.descriptor;var fontRefIsRef=isRef(fontRef),fontID;if(fontRefIsRef){fontID=fontRef.toString()}if(isDict(descriptor)){if(!descriptor.fontAliases){descriptor.fontAliases=Object.create(null)}var fontAliases=descriptor.fontAliases;var hash=preEvaluatedFont.hash;if(fontAliases[hash]){var aliasFontRef=fontAliases[hash].aliasRef;if(fontRefIsRef&&aliasFontRef&&this.fontCache.has(aliasFontRef)){this.fontCache.putAlias(fontRef,aliasFontRef);return this.fontCache.get(fontRef)}}else{fontAliases[hash]={fontID:Font.getFontID()}}if(fontRefIsRef){fontAliases[hash].aliasRef=fontRef}fontID=fontAliases[hash].fontID}if(fontRefIsRef){this.fontCache.put(fontRef,fontCapability.promise)}else{if(!fontID){fontID=(this.uniquePrefix||"F_")+ ++this.idCounters.obj}this.fontCache.put("id_"+fontID,fontCapability.promise)}assert(fontID,'The "fontID" must be defined.');font.loadedName="g_"+this.pdfManager.docId+"_f"+fontID;font.translated=fontCapability.promise;var translatedPromise;try{translatedPromise=this.translateFont(preEvaluatedFont,xref)}catch(e){translatedPromise=Promise.reject(e)}var self=this;translatedPromise.then(function(translatedFont){if(translatedFont.fontType!==undefined){var xrefFontStats=xref.stats.fontTypes;xrefFontStats[translatedFont.fontType]=true}fontCapability.resolve(new TranslatedFont(font.loadedName,translatedFont,font))},function(reason){self.handler.send("UnsupportedFeature",{featureId:UNSUPPORTED_FEATURES.font});try{var descriptor=preEvaluatedFont.descriptor;var fontFile3=descriptor&&descriptor.get("FontFile3");var subtype=fontFile3&&fontFile3.get("Subtype");var fontType=getFontType(preEvaluatedFont.type,subtype&&subtype.name);var xrefFontStats=xref.stats.fontTypes;xrefFontStats[fontType]=true}catch(ex){}fontCapability.resolve(new TranslatedFont(font.loadedName,new ErrorFont(reason instanceof Error?reason.message:reason),font))});return fontCapability.promise},buildPath:function PartialEvaluator_buildPath(operatorList,fn,args){var lastIndex=operatorList.length-1;if(!args){args=[]}if(lastIndex<0||operatorList.fnArray[lastIndex]!==OPS.constructPath){operatorList.addOp(OPS.constructPath,[[fn],args])}else{var opArgs=operatorList.argsArray[lastIndex];opArgs[0].push(fn);Array.prototype.push.apply(opArgs[1],args)}},handleColorN:function PartialEvaluator_handleColorN(operatorList,fn,args,cs,patterns,resources,task,xref){var patternName=args[args.length-1];var pattern;if(isName(patternName)&&(pattern=patterns.get(patternName.name))){var dict=isStream(pattern)?pattern.dict:pattern;var typeNum=dict.get("PatternType");if(typeNum===TILING_PATTERN){var color=cs.base?cs.base.getRgb(args,0):null;return this.handleTilingType(fn,color,resources,pattern,dict,operatorList,task)}else if(typeNum===SHADING_PATTERN){var shading=dict.get("Shading");var matrix=dict.getArray("Matrix");pattern=Pattern.parseShading(shading,matrix,xref,resources,this.handler);operatorList.addOp(fn,pattern.getIR());return Promise.resolve()}else{return Promise.reject("Unknown PatternType: "+typeNum)}}operatorList.addOp(fn,args);return Promise.resolve()},getOperatorList:function PartialEvaluator_getOperatorList(stream,task,resources,operatorList,initialState){var self=this;var xref=this.xref;var imageCache=Object.create(null);assert(operatorList);resources=resources||Dict.empty;var xobjs=resources.get("XObject")||Dict.empty;var patterns=resources.get("Pattern")||Dict.empty;var stateManager=new StateManager(initialState||new EvalState);var preprocessor=new EvaluatorPreprocessor(stream,xref,stateManager);var timeSlotManager=new TimeSlotManager;return new Promise(function promiseBody(resolve,reject){var next=function(promise){promise.then(function(){try{promiseBody(resolve,reject)}catch(ex){reject(ex)}},reject)};task.ensureNotTerminated();timeSlotManager.reset();var stop,operation={},i,ii,cs;while(!(stop=timeSlotManager.check())){operation.args=null;if(!preprocessor.read(operation)){break}var args=operation.args;var fn=operation.fn;switch(fn|0){case OPS.paintXObject:if(args[0].code){break}var name=args[0].name;if(!name){warn("XObject must be referred to by name.");continue}if(imageCache[name]!==undefined){operatorList.addOp(imageCache[name].fn,imageCache[name].args);args=null;continue}var xobj=xobjs.get(name);if(xobj){assert(isStream(xobj),"XObject should be a stream");var type=xobj.dict.get("Subtype");assert(isName(type),"XObject should have a Name subtype");if(type.name==="Form"){stateManager.save();next(self.buildFormXObject(resources,xobj,null,operatorList,task,stateManager.state.clone()).then(function(){stateManager.restore()}));return}else if(type.name==="Image"){self.buildPaintImageXObject(resources,xobj,false,operatorList,name,imageCache);args=null;continue}else if(type.name==="PS"){info("Ignored XObject subtype PS");continue}else{error("Unhandled XObject subtype "+type.name)}}break;case OPS.setFont:var fontSize=args[1];next(self.handleSetFont(resources,args,null,operatorList,task,stateManager.state).then(function(loadedName){operatorList.addDependency(loadedName);operatorList.addOp(OPS.setFont,[loadedName,fontSize])}));return;case OPS.endInlineImage:var cacheKey=args[0].cacheKey;if(cacheKey){var cacheEntry=imageCache[cacheKey];if(cacheEntry!==undefined){operatorList.addOp(cacheEntry.fn,cacheEntry.args);args=null;continue}}self.buildPaintImageXObject(resources,args[0],true,operatorList,cacheKey,imageCache);args=null;continue;case OPS.showText:args[0]=self.handleText(args[0],stateManager.state);break;case OPS.showSpacedText:var arr=args[0];var combinedGlyphs=[];var arrLength=arr.length;var state=stateManager.state;for(i=0;i<arrLength;++i){var arrItem=arr[i];if(isString(arrItem)){Array.prototype.push.apply(combinedGlyphs,self.handleText(arrItem,state))}else if(isNum(arrItem)){combinedGlyphs.push(arrItem)}}args[0]=combinedGlyphs;fn=OPS.showText;break;case OPS.nextLineShowText:operatorList.addOp(OPS.nextLine);args[0]=self.handleText(args[0],stateManager.state);fn=OPS.showText;break;case OPS.nextLineSetSpacingShowText:operatorList.addOp(OPS.nextLine);operatorList.addOp(OPS.setWordSpacing,[args.shift()]);operatorList.addOp(OPS.setCharSpacing,[args.shift()]);args[0]=self.handleText(args[0],stateManager.state);fn=OPS.showText;break;case OPS.setTextRenderingMode:stateManager.state.textRenderingMode=args[0];break;case OPS.setFillColorSpace:stateManager.state.fillColorSpace=ColorSpace.parse(args[0],xref,resources);continue;case OPS.setStrokeColorSpace:stateManager.state.strokeColorSpace=ColorSpace.parse(args[0],xref,resources);continue;case OPS.setFillColor:cs=stateManager.state.fillColorSpace;args=cs.getRgb(args,0);fn=OPS.setFillRGBColor;break;case OPS.setStrokeColor:cs=stateManager.state.strokeColorSpace;args=cs.getRgb(args,0);fn=OPS.setStrokeRGBColor;break;case OPS.setFillGray:stateManager.state.fillColorSpace=ColorSpace.singletons.gray;args=ColorSpace.singletons.gray.getRgb(args,0);fn=OPS.setFillRGBColor;break;case OPS.setStrokeGray:stateManager.state.strokeColorSpace=ColorSpace.singletons.gray;args=ColorSpace.singletons.gray.getRgb(args,0);fn=OPS.setStrokeRGBColor;break;case OPS.setFillCMYKColor:stateManager.state.fillColorSpace=ColorSpace.singletons.cmyk;args=ColorSpace.singletons.cmyk.getRgb(args,0);fn=OPS.setFillRGBColor;break;case OPS.setStrokeCMYKColor:stateManager.state.strokeColorSpace=ColorSpace.singletons.cmyk;args=ColorSpace.singletons.cmyk.getRgb(args,0);fn=OPS.setStrokeRGBColor;break;case OPS.setFillRGBColor:stateManager.state.fillColorSpace=ColorSpace.singletons.rgb;args=ColorSpace.singletons.rgb.getRgb(args,0);break;case OPS.setStrokeRGBColor:stateManager.state.strokeColorSpace=ColorSpace.singletons.rgb;args=ColorSpace.singletons.rgb.getRgb(args,0);break;case OPS.setFillColorN:cs=stateManager.state.fillColorSpace;if(cs.name==="Pattern"){next(self.handleColorN(operatorList,OPS.setFillColorN,args,cs,patterns,resources,task,xref));return}args=cs.getRgb(args,0);fn=OPS.setFillRGBColor;break;case OPS.setStrokeColorN:cs=stateManager.state.strokeColorSpace;if(cs.name==="Pattern"){next(self.handleColorN(operatorList,OPS.setStrokeColorN,args,cs,patterns,resources,task,xref));return}args=cs.getRgb(args,0);fn=OPS.setStrokeRGBColor;break;case OPS.shadingFill:var shadingRes=resources.get("Shading");if(!shadingRes){error("No shading resource found")}var shading=shadingRes.get(args[0].name);if(!shading){error("No shading object found")}var shadingFill=Pattern.parseShading(shading,null,xref,resources,self.handler);var patternIR=shadingFill.getIR();args=[patternIR];fn=OPS.shadingFill;break;case OPS.setGState:var dictName=args[0];var extGState=resources.get("ExtGState");if(!isDict(extGState)||!extGState.has(dictName.name)){break}var gState=extGState.get(dictName.name);next(self.setGState(resources,gState,operatorList,task,xref,stateManager));return;case OPS.moveTo:case OPS.lineTo:case OPS.curveTo:case OPS.curveTo2:case OPS.curveTo3:case OPS.closePath:self.buildPath(operatorList,fn,args);continue;case OPS.rectangle:self.buildPath(operatorList,fn,args);continue;case OPS.markPoint:case OPS.markPointProps:case OPS.beginMarkedContent:case OPS.beginMarkedContentProps:case OPS.endMarkedContent:case OPS.beginCompat:case OPS.endCompat:continue;default:if(args!==null){for(i=0,ii=args.length;i<ii;i++){if(args[i]instanceof Dict){break}}if(i<ii){warn("getOperatorList - ignoring operator: "+fn);continue}}}operatorList.addOp(fn,args)}if(stop){next(deferred);return}for(i=0,ii=preprocessor.savedStatesDepth;i<ii;i++){operatorList.addOp(OPS.restore,[])}resolve()})},getTextContent:function PartialEvaluator_getTextContent(stream,task,resources,stateManager,normalizeWhitespace,combineTextItems){stateManager=stateManager||new StateManager(new TextState);var WhitespaceRegexp=/\s/g;var textContent={items:[],styles:Object.create(null)};var textContentItem={initialized:false,str:[],width:0,height:0,vertical:false,lastAdvanceWidth:0,lastAdvanceHeight:0,textAdvanceScale:0,spaceWidth:0,fakeSpaceMin:Infinity,fakeMultiSpaceMin:Infinity,fakeMultiSpaceMax:-0,textRunBreakAllowed:false,transform:null,fontName:null};var SPACE_FACTOR=.3;var MULTI_SPACE_FACTOR=1.5;var MULTI_SPACE_FACTOR_MAX=4;var self=this;var xref=this.xref;resources=xref.fetchIfRef(resources)||Dict.empty;var xobjs=null;var xobjsCache=Object.create(null);var preprocessor=new EvaluatorPreprocessor(stream,xref,stateManager);var textState;function ensureTextContentItem(){if(textContentItem.initialized){return textContentItem}var font=textState.font;if(!(font.loadedName in textContent.styles)){textContent.styles[font.loadedName]={fontFamily:font.fallbackName,ascent:font.ascent,descent:font.descent,vertical:font.vertical}}textContentItem.fontName=font.loadedName;var tsm=[textState.fontSize*textState.textHScale,0,0,textState.fontSize,0,textState.textRise];if(font.isType3Font&&textState.fontMatrix!==FONT_IDENTITY_MATRIX&&textState.fontSize===1){var glyphHeight=font.bbox[3]-font.bbox[1];if(glyphHeight>0){glyphHeight=glyphHeight*textState.fontMatrix[3];tsm[3]*=glyphHeight}}var trm=Util.transform(textState.ctm,Util.transform(textState.textMatrix,tsm));textContentItem.transform=trm;if(!font.vertical){textContentItem.width=0;textContentItem.height=Math.sqrt(trm[2]*trm[2]+trm[3]*trm[3]);textContentItem.vertical=false}else{textContentItem.width=Math.sqrt(trm[0]*trm[0]+trm[1]*trm[1]);textContentItem.height=0;textContentItem.vertical=true}var a=textState.textLineMatrix[0];var b=textState.textLineMatrix[1];var scaleLineX=Math.sqrt(a*a+b*b);a=textState.ctm[0];b=textState.ctm[1];var scaleCtmX=Math.sqrt(a*a+b*b);textContentItem.textAdvanceScale=scaleCtmX*scaleLineX;textContentItem.lastAdvanceWidth=0;textContentItem.lastAdvanceHeight=0;var spaceWidth=font.spaceWidth/1e3*textState.fontSize;if(spaceWidth){textContentItem.spaceWidth=spaceWidth;textContentItem.fakeSpaceMin=spaceWidth*SPACE_FACTOR;textContentItem.fakeMultiSpaceMin=spaceWidth*MULTI_SPACE_FACTOR;textContentItem.fakeMultiSpaceMax=spaceWidth*MULTI_SPACE_FACTOR_MAX;textContentItem.textRunBreakAllowed=!font.isMonospace}else{textContentItem.spaceWidth=0;textContentItem.fakeSpaceMin=Infinity;textContentItem.fakeMultiSpaceMin=Infinity;textContentItem.fakeMultiSpaceMax=0;textContentItem.textRunBreakAllowed=false}textContentItem.initialized=true;return textContentItem}function replaceWhitespace(str){var i=0,ii=str.length,code;while(i<ii&&(code=str.charCodeAt(i))>=32&&code<=127){i++}return i<ii?str.replace(WhitespaceRegexp," "):str}function runBidiTransform(textChunk){var str=textChunk.str.join("");var bidiResult=bidi(str,-1,textChunk.vertical);return{str:normalizeWhitespace?replaceWhitespace(bidiResult.str):bidiResult.str,dir:bidiResult.dir,width:textChunk.width,height:textChunk.height,transform:textChunk.transform,fontName:textChunk.fontName}}function handleSetFont(fontName,fontRef){return self.loadFont(fontName,fontRef,xref,resources).then(function(translated){textState.font=translated.font;textState.fontMatrix=translated.font.fontMatrix||FONT_IDENTITY_MATRIX})}function buildTextContentItem(chars){var font=textState.font;var textChunk=ensureTextContentItem();var width=0;var height=0;var glyphs=font.charsToGlyphs(chars);var defaultVMetrics=font.defaultVMetrics;for(var i=0;i<glyphs.length;i++){var glyph=glyphs[i];var vMetricX=null;var vMetricY=null;var glyphWidth=null;if(font.vertical){if(glyph.vmetric){glyphWidth=glyph.vmetric[0];vMetricX=glyph.vmetric[1];vMetricY=glyph.vmetric[2]}else{glyphWidth=glyph.width;vMetricX=glyph.width*.5;vMetricY=defaultVMetrics[2]}}else{glyphWidth=glyph.width}var glyphUnicode=glyph.unicode;var NormalizedUnicodes=getNormalizedUnicodes();if(NormalizedUnicodes[glyphUnicode]!==undefined){glyphUnicode=NormalizedUnicodes[glyphUnicode]}glyphUnicode=reverseIfRtl(glyphUnicode);var charSpacing=textState.charSpacing;if(glyph.isSpace){var wordSpacing=textState.wordSpacing;charSpacing+=wordSpacing;if(wordSpacing>0){addFakeSpaces(wordSpacing,textChunk.str)}}var tx=0;var ty=0;if(!font.vertical){var w0=glyphWidth*textState.fontMatrix[0];tx=(w0*textState.fontSize+charSpacing)*textState.textHScale;width+=tx}else{var w1=glyphWidth*textState.fontMatrix[0];ty=w1*textState.fontSize+charSpacing;height+=ty}textState.translateTextMatrix(tx,ty);textChunk.str.push(glyphUnicode)}if(!font.vertical){textChunk.lastAdvanceWidth=width;textChunk.width+=width*textChunk.textAdvanceScale}else{textChunk.lastAdvanceHeight=height;textChunk.height+=Math.abs(height*textChunk.textAdvanceScale)}return textChunk}function addFakeSpaces(width,strBuf){if(width<textContentItem.fakeSpaceMin){return}if(width<textContentItem.fakeMultiSpaceMin){strBuf.push(" ");return}var fakeSpaces=Math.round(width/textContentItem.spaceWidth);while(fakeSpaces-->0){strBuf.push(" ")}}function flushTextContentItem(){if(!textContentItem.initialized){return}textContent.items.push(runBidiTransform(textContentItem));textContentItem.initialized=false;textContentItem.str.length=0}var timeSlotManager=new TimeSlotManager;return new Promise(function promiseBody(resolve,reject){var next=function(promise){promise.then(function(){try{promiseBody(resolve,reject)}catch(ex){reject(ex)}},reject)};task.ensureNotTerminated();timeSlotManager.reset();var stop,operation={},args=[];while(!(stop=timeSlotManager.check())){args.length=0;operation.args=args;if(!preprocessor.read(operation)){break}textState=stateManager.state;var fn=operation.fn;args=operation.args;var advance,diff;switch(fn|0){case OPS.setFont:var fontNameArg=args[0].name,fontSizeArg=args[1];if(textState.font&&fontNameArg===textState.fontName&&fontSizeArg===textState.fontSize){break}flushTextContentItem();textState.fontName=fontNameArg;textState.fontSize=fontSizeArg;next(handleSetFont(fontNameArg,null));return;case OPS.setTextRise:flushTextContentItem();textState.textRise=args[0];break;case OPS.setHScale:flushTextContentItem();textState.textHScale=args[0]/100;break;case OPS.setLeading:flushTextContentItem();textState.leading=args[0];break;case OPS.moveText:var isSameTextLine=!textState.font?false:(textState.font.vertical?args[0]:args[1])===0;advance=args[0]-args[1];if(combineTextItems&&isSameTextLine&&textContentItem.initialized&&advance>0&&advance<=textContentItem.fakeMultiSpaceMax){textState.translateTextLineMatrix(args[0],args[1]);textContentItem.width+=args[0]-textContentItem.lastAdvanceWidth;textContentItem.height+=args[1]-textContentItem.lastAdvanceHeight;diff=args[0]-textContentItem.lastAdvanceWidth-(args[1]-textContentItem.lastAdvanceHeight);addFakeSpaces(diff,textContentItem.str);break}flushTextContentItem();textState.translateTextLineMatrix(args[0],args[1]);textState.textMatrix=textState.textLineMatrix.slice();break;case OPS.setLeadingMoveText:flushTextContentItem();textState.leading=-args[1];textState.translateTextLineMatrix(args[0],args[1]);textState.textMatrix=textState.textLineMatrix.slice();break;case OPS.nextLine:flushTextContentItem();textState.carriageReturn();break;case OPS.setTextMatrix:advance=textState.calcTextLineMatrixAdvance(args[0],args[1],args[2],args[3],args[4],args[5]);if(combineTextItems&&advance!==null&&textContentItem.initialized&&advance.value>0&&advance.value<=textContentItem.fakeMultiSpaceMax){textState.translateTextLineMatrix(advance.width,advance.height);textContentItem.width+=advance.width-textContentItem.lastAdvanceWidth;textContentItem.height+=advance.height-textContentItem.lastAdvanceHeight;diff=advance.width-textContentItem.lastAdvanceWidth-(advance.height-textContentItem.lastAdvanceHeight);addFakeSpaces(diff,textContentItem.str);break}flushTextContentItem();textState.setTextMatrix(args[0],args[1],args[2],args[3],args[4],args[5]);textState.setTextLineMatrix(args[0],args[1],args[2],args[3],args[4],args[5]);break;case OPS.setCharSpacing:textState.charSpacing=args[0];break;case OPS.setWordSpacing:textState.wordSpacing=args[0];break;case OPS.beginText:flushTextContentItem();textState.textMatrix=IDENTITY_MATRIX.slice();textState.textLineMatrix=IDENTITY_MATRIX.slice();break;case OPS.showSpacedText:var items=args[0];var offset;for(var j=0,jj=items.length;j<jj;j++){if(typeof items[j]==="string"){buildTextContentItem(items[j])}else{ensureTextContentItem();advance=items[j]*textState.fontSize/1e3;var breakTextRun=false;if(textState.font.vertical){offset=advance*(textState.textHScale*textState.textMatrix[2]+textState.textMatrix[3]);textState.translateTextMatrix(0,advance);breakTextRun=textContentItem.textRunBreakAllowed&&advance>textContentItem.fakeMultiSpaceMax;if(!breakTextRun){textContentItem.height+=offset}}else{advance=-advance;offset=advance*(textState.textHScale*textState.textMatrix[0]+textState.textMatrix[1]);textState.translateTextMatrix(advance,0);breakTextRun=textContentItem.textRunBreakAllowed&&advance>textContentItem.fakeMultiSpaceMax;if(!breakTextRun){textContentItem.width+=offset}}if(breakTextRun){flushTextContentItem()}else if(advance>0){addFakeSpaces(advance,textContentItem.str)}}}break;case OPS.showText:buildTextContentItem(args[0]);break;case OPS.nextLineShowText:flushTextContentItem();textState.carriageReturn();buildTextContentItem(args[0]);break;case OPS.nextLineSetSpacingShowText:flushTextContentItem();textState.wordSpacing=args[0];textState.charSpacing=args[1];textState.carriageReturn();buildTextContentItem(args[2]);break;case OPS.paintXObject:flushTextContentItem();
25if(args[0].code){break}if(!xobjs){xobjs=resources.get("XObject")||Dict.empty}var name=args[0].name;if(xobjsCache.key===name){if(xobjsCache.texts){Util.appendToArray(textContent.items,xobjsCache.texts.items);Util.extendObj(textContent.styles,xobjsCache.texts.styles)}break}var xobj=xobjs.get(name);if(!xobj){break}assert(isStream(xobj),"XObject should be a stream");var type=xobj.dict.get("Subtype");assert(isName(type),"XObject should have a Name subtype");if("Form"!==type.name){xobjsCache.key=name;xobjsCache.texts=null;break}stateManager.save();var matrix=xobj.dict.getArray("Matrix");if(isArray(matrix)&&matrix.length===6){stateManager.transform(matrix)}next(self.getTextContent(xobj,task,xobj.dict.get("Resources")||resources,stateManager,normalizeWhitespace,combineTextItems).then(function(formTextContent){Util.appendToArray(textContent.items,formTextContent.items);Util.extendObj(textContent.styles,formTextContent.styles);stateManager.restore();xobjsCache.key=name;xobjsCache.texts=formTextContent}));return;case OPS.setGState:flushTextContentItem();var dictName=args[0];var extGState=resources.get("ExtGState");if(!isDict(extGState)||!isName(dictName)){break}var gState=extGState.get(dictName.name);if(!isDict(gState)){break}var gStateFont=gState.get("Font");if(gStateFont){textState.fontName=null;textState.fontSize=gStateFont[1];next(handleSetFont(null,gStateFont[0]));return}break}}if(stop){next(deferred);return}flushTextContentItem();resolve(textContent)})},extractDataStructures:function PartialEvaluator_extractDataStructures(dict,baseDict,xref,properties){var toUnicode=dict.get("ToUnicode")||baseDict.get("ToUnicode");var toUnicodePromise=toUnicode?this.readToUnicode(toUnicode):Promise.resolve(undefined);if(properties.composite){var cidSystemInfo=dict.get("CIDSystemInfo");if(isDict(cidSystemInfo)){properties.cidSystemInfo={registry:cidSystemInfo.get("Registry"),ordering:cidSystemInfo.get("Ordering"),supplement:cidSystemInfo.get("Supplement")}}var cidToGidMap=dict.get("CIDToGIDMap");if(isStream(cidToGidMap)){properties.cidToGidMap=this.readCidToGidMap(cidToGidMap)}}var differences=[];var baseEncodingName=null;var encoding;if(dict.has("Encoding")){encoding=dict.get("Encoding");if(isDict(encoding)){baseEncodingName=encoding.get("BaseEncoding");baseEncodingName=isName(baseEncodingName)?baseEncodingName.name:null;if(encoding.has("Differences")){var diffEncoding=encoding.get("Differences");var index=0;for(var j=0,jj=diffEncoding.length;j<jj;j++){var data=xref.fetchIfRef(diffEncoding[j]);if(isNum(data)){index=data}else if(isName(data)){differences[index++]=data.name}else{error("Invalid entry in 'Differences' array: "+data)}}}}else if(isName(encoding)){baseEncodingName=encoding.name}else{error("Encoding is not a Name nor a Dict")}if(baseEncodingName!=="MacRomanEncoding"&&baseEncodingName!=="MacExpertEncoding"&&baseEncodingName!=="WinAnsiEncoding"){baseEncodingName=null}}if(baseEncodingName){properties.defaultEncoding=getEncoding(baseEncodingName).slice()}else{encoding=properties.type==="TrueType"?WinAnsiEncoding:StandardEncoding;if(!!(properties.flags&FontFlags.Symbolic)){encoding=MacRomanEncoding;if(!properties.file){if(/Symbol/i.test(properties.name)){encoding=SymbolSetEncoding}else if(/Dingbats/i.test(properties.name)){encoding=ZapfDingbatsEncoding}}}properties.defaultEncoding=encoding}properties.differences=differences;properties.baseEncodingName=baseEncodingName;properties.hasEncoding=!!baseEncodingName||differences.length>0;properties.dict=dict;return toUnicodePromise.then(function(toUnicode){properties.toUnicode=toUnicode;return this.buildToUnicode(properties)}.bind(this)).then(function(toUnicode){properties.toUnicode=toUnicode;return properties})},buildToUnicode:function PartialEvaluator_buildToUnicode(properties){properties.hasIncludedToUnicodeMap=!!properties.toUnicode&&properties.toUnicode.length>0;if(properties.hasIncludedToUnicodeMap){return Promise.resolve(properties.toUnicode)}var toUnicode,charcode,glyphName;if(!properties.composite){toUnicode=[];var encoding=properties.defaultEncoding.slice();var baseEncodingName=properties.baseEncodingName;var differences=properties.differences;for(charcode in differences){glyphName=differences[charcode];if(glyphName===".notdef"){continue}encoding[charcode]=glyphName}var glyphsUnicodeMap=getGlyphsUnicode();for(charcode in encoding){glyphName=encoding[charcode];if(glyphName===""){continue}else if(glyphsUnicodeMap[glyphName]===undefined){var code=0;switch(glyphName[0]){case"G":if(glyphName.length===3){code=parseInt(glyphName.substr(1),16)}break;case"g":if(glyphName.length===5){code=parseInt(glyphName.substr(1),16)}break;case"C":case"c":if(glyphName.length>=3){code=+glyphName.substr(1)}break;default:var unicode=getUnicodeForGlyph(glyphName,glyphsUnicodeMap);if(unicode!==-1){code=unicode}}if(code){if(baseEncodingName&&code===+charcode){var baseEncoding=getEncoding(baseEncodingName);if(baseEncoding&&(glyphName=baseEncoding[charcode])){toUnicode[charcode]=String.fromCharCode(glyphsUnicodeMap[glyphName]);continue}}toUnicode[charcode]=String.fromCharCode(code)}continue}toUnicode[charcode]=String.fromCharCode(glyphsUnicodeMap[glyphName])}return Promise.resolve(new ToUnicodeMap(toUnicode))}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"))){var registry=properties.cidSystemInfo.registry;var ordering=properties.cidSystemInfo.ordering;var ucs2CMapName=Name.get(registry+"-"+ordering+"-UCS2");return CMapFactory.create(ucs2CMapName,this.options.cMapOptions,null).then(function(ucs2CMap){var cMap=properties.cMap;toUnicode=[];cMap.forEach(function(charcode,cid){assert(cid<=65535,"Max size of CID is 65,535");var ucs2=ucs2CMap.lookup(cid);if(ucs2){toUnicode[charcode]=String.fromCharCode((ucs2.charCodeAt(0)<<8)+ucs2.charCodeAt(1))}});return new ToUnicodeMap(toUnicode)})}return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar,properties.lastChar))},readToUnicode:function PartialEvaluator_readToUnicode(toUnicode){var cmapObj=toUnicode;if(isName(cmapObj)){return CMapFactory.create(cmapObj,this.options.cMapOptions,null).then(function(cmap){if(cmap instanceof IdentityCMap){return new IdentityToUnicodeMap(0,65535)}return new ToUnicodeMap(cmap.getMap())})}else if(isStream(cmapObj)){return CMapFactory.create(cmapObj,this.options.cMapOptions,null).then(function(cmap){if(cmap instanceof IdentityCMap){return new IdentityToUnicodeMap(0,65535)}var map=new Array(cmap.length);cmap.forEach(function(charCode,token){var str=[];for(var k=0;k<token.length;k+=2){var w1=token.charCodeAt(k)<<8|token.charCodeAt(k+1);if((w1&63488)!==55296){str.push(w1);continue}k+=2;var w2=token.charCodeAt(k)<<8|token.charCodeAt(k+1);str.push(((w1&1023)<<10)+(w2&1023)+65536)}map[charCode]=String.fromCharCode.apply(String,str)});return new ToUnicodeMap(map)})}return Promise.resolve(null)},readCidToGidMap:function PartialEvaluator_readCidToGidMap(cidToGidStream){var glyphsData=cidToGidStream.getBytes();var result=[];for(var j=0,jj=glyphsData.length;j<jj;j++){var glyphID=glyphsData[j++]<<8|glyphsData[j];if(glyphID===0){continue}var code=j>>1;result[code]=glyphID}return result},extractWidths:function PartialEvaluator_extractWidths(dict,xref,descriptor,properties){var glyphsWidths=[];var defaultWidth=0;var glyphsVMetrics=[];var defaultVMetrics;var i,ii,j,jj,start,code,widths;if(properties.composite){defaultWidth=dict.get("DW")||1e3;widths=dict.get("W");if(widths){for(i=0,ii=widths.length;i<ii;i++){start=widths[i++];code=xref.fetchIfRef(widths[i]);if(isArray(code)){for(j=0,jj=code.length;j<jj;j++){glyphsWidths[start++]=code[j]}}else{var width=widths[++i];for(j=start;j<=code;j++){glyphsWidths[j]=width}}}}if(properties.vertical){var vmetrics=dict.get("DW2")||[880,-1e3];defaultVMetrics=[vmetrics[1],defaultWidth*.5,vmetrics[0]];vmetrics=dict.get("W2");if(vmetrics){for(i=0,ii=vmetrics.length;i<ii;i++){start=vmetrics[i++];code=xref.fetchIfRef(vmetrics[i]);if(isArray(code)){for(j=0,jj=code.length;j<jj;j++){glyphsVMetrics[start++]=[code[j++],code[j++],code[j]]}}else{var vmetric=[vmetrics[++i],vmetrics[++i],vmetrics[++i]];for(j=start;j<=code;j++){glyphsVMetrics[j]=vmetric}}}}}}else{var firstChar=properties.firstChar;widths=dict.get("Widths");if(widths){j=firstChar;for(i=0,ii=widths.length;i<ii;i++){glyphsWidths[j++]=widths[i]}defaultWidth=parseFloat(descriptor.get("MissingWidth"))||0}else{var baseFontName=dict.get("BaseFont");if(isName(baseFontName)){var metrics=this.getBaseFontMetrics(baseFontName.name);glyphsWidths=this.buildCharCodeToWidth(metrics.widths,properties);defaultWidth=metrics.defaultWidth}}}var isMonospace=true;var firstWidth=defaultWidth;for(var glyph in glyphsWidths){var glyphWidth=glyphsWidths[glyph];if(!glyphWidth){continue}if(!firstWidth){firstWidth=glyphWidth;continue}if(firstWidth!==glyphWidth){isMonospace=false;break}}if(isMonospace){properties.flags|=FontFlags.FixedPitch}properties.defaultWidth=defaultWidth;properties.widths=glyphsWidths;properties.defaultVMetrics=defaultVMetrics;properties.vmetrics=glyphsVMetrics},isSerifFont:function PartialEvaluator_isSerifFont(baseFontName){var fontNameWoStyle=baseFontName.split("-")[0];return fontNameWoStyle in getSerifFonts()||fontNameWoStyle.search(/serif/gi)!==-1},getBaseFontMetrics:function PartialEvaluator_getBaseFontMetrics(name){var defaultWidth=0;var widths=[];var monospace=false;var stdFontMap=getStdFontMap();var lookupName=stdFontMap[name]||name;var Metrics=getMetrics();if(!(lookupName in Metrics)){if(this.isSerifFont(name)){lookupName="Times-Roman"}else{lookupName="Helvetica"}}var glyphWidths=Metrics[lookupName];if(isNum(glyphWidths)){defaultWidth=glyphWidths;monospace=true}else{widths=glyphWidths()}return{defaultWidth:defaultWidth,monospace:monospace,widths:widths}},buildCharCodeToWidth:function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName,properties){var widths=Object.create(null);var differences=properties.differences;var encoding=properties.defaultEncoding;for(var charCode=0;charCode<256;charCode++){if(charCode in differences&&widthsByGlyphName[differences[charCode]]){widths[charCode]=widthsByGlyphName[differences[charCode]];continue}if(charCode in encoding&&widthsByGlyphName[encoding[charCode]]){widths[charCode]=widthsByGlyphName[encoding[charCode]];continue}}return widths},preEvaluateFont:function PartialEvaluator_preEvaluateFont(dict,xref){var baseDict=dict;var type=dict.get("Subtype");assert(isName(type),"invalid font Subtype");var composite=false;var uint8array;if(type.name==="Type0"){var df=dict.get("DescendantFonts");if(!df){error("Descendant fonts are not specified")}dict=isArray(df)?xref.fetchIfRef(df[0]):df;type=dict.get("Subtype");assert(isName(type),"invalid font Subtype");composite=true}var descriptor=dict.get("FontDescriptor");if(descriptor){var hash=new MurmurHash3_64;var encoding=baseDict.getRaw("Encoding");if(isName(encoding)){hash.update(encoding.name)}else if(isRef(encoding)){hash.update(encoding.toString())}else if(isDict(encoding)){var keys=encoding.getKeys();for(var i=0,ii=keys.length;i<ii;i++){var entry=encoding.getRaw(keys[i]);if(isName(entry)){hash.update(entry.name)}else if(isRef(entry)){hash.update(entry.toString())}else if(isArray(entry)){hash.update(entry.length.toString())}}}var toUnicode=dict.get("ToUnicode")||baseDict.get("ToUnicode");if(isStream(toUnicode)){var stream=toUnicode.str||toUnicode;uint8array=stream.buffer?new Uint8Array(stream.buffer.buffer,0,stream.bufferLength):new Uint8Array(stream.bytes.buffer,stream.start,stream.end-stream.start);hash.update(uint8array)}else if(isName(toUnicode)){hash.update(toUnicode.name)}var widths=dict.get("Widths")||baseDict.get("Widths");if(widths){uint8array=new Uint8Array(new Uint32Array(widths).buffer);hash.update(uint8array)}}return{descriptor:descriptor,dict:dict,baseDict:baseDict,composite:composite,type:type.name,hash:hash?hash.hexdigest():""}},translateFont:function PartialEvaluator_translateFont(preEvaluatedFont,xref){var baseDict=preEvaluatedFont.baseDict;var dict=preEvaluatedFont.dict;var composite=preEvaluatedFont.composite;var descriptor=preEvaluatedFont.descriptor;var type=preEvaluatedFont.type;var maxCharIndex=composite?65535:255;var cMapOptions=this.options.cMapOptions;var properties;if(!descriptor){if(type==="Type3"){descriptor=new Dict(null);descriptor.set("FontName",Name.get(type));descriptor.set("FontBBox",dict.getArray("FontBBox"))}else{var baseFontName=dict.get("BaseFont");if(!isName(baseFontName)){error("Base font is not specified")}baseFontName=baseFontName.name.replace(/[,_]/g,"-");var metrics=this.getBaseFontMetrics(baseFontName);var fontNameWoStyle=baseFontName.split("-")[0];var flags=(this.isSerifFont(fontNameWoStyle)?FontFlags.Serif:0)|(metrics.monospace?FontFlags.FixedPitch:0)|(getSymbolsFonts()[fontNameWoStyle]?FontFlags.Symbolic:FontFlags.Nonsymbolic);properties={type:type,name:baseFontName,widths:metrics.widths,defaultWidth:metrics.defaultWidth,flags:flags,firstChar:0,lastChar:maxCharIndex};return this.extractDataStructures(dict,dict,xref,properties).then(function(properties){properties.widths=this.buildCharCodeToWidth(metrics.widths,properties);return new Font(baseFontName,null,properties)}.bind(this))}}var firstChar=dict.get("FirstChar")||0;var lastChar=dict.get("LastChar")||maxCharIndex;var fontName=descriptor.get("FontName");var baseFont=dict.get("BaseFont");if(isString(fontName)){fontName=Name.get(fontName)}if(isString(baseFont)){baseFont=Name.get(baseFont)}if(type!=="Type3"){var fontNameStr=fontName&&fontName.name;var baseFontStr=baseFont&&baseFont.name;if(fontNameStr!==baseFontStr){info("The FontDescriptor's FontName is \""+fontNameStr+'" but should be the same as the Font\'s BaseFont "'+baseFontStr+'"');if(fontNameStr&&baseFontStr&&baseFontStr.indexOf(fontNameStr)===0){fontName=baseFont}}}fontName=fontName||baseFont;assert(isName(fontName),"invalid font name");var fontFile=descriptor.get("FontFile","FontFile2","FontFile3");if(fontFile){if(fontFile.dict){var subtype=fontFile.dict.get("Subtype");if(subtype){subtype=subtype.name}var length1=fontFile.dict.get("Length1");var length2=fontFile.dict.get("Length2");var length3=fontFile.dict.get("Length3")}}properties={type:type,name:fontName.name,subtype:subtype,file:fontFile,length1:length1,length2:length2,length3:length3,loadedName:baseDict.loadedName,composite:composite,wideChars:composite,fixedPitch:false,fontMatrix:dict.getArray("FontMatrix")||FONT_IDENTITY_MATRIX,firstChar:firstChar||0,lastChar:lastChar||maxCharIndex,bbox:descriptor.getArray("FontBBox"),ascent:descriptor.get("Ascent"),descent:descriptor.get("Descent"),xHeight:descriptor.get("XHeight"),capHeight:descriptor.get("CapHeight"),flags:descriptor.get("Flags"),italicAngle:descriptor.get("ItalicAngle"),coded:false};var cMapPromise;if(composite){var cidEncoding=baseDict.get("Encoding");if(isName(cidEncoding)){properties.cidEncoding=cidEncoding.name}cMapPromise=CMapFactory.create(cidEncoding,cMapOptions,null).then(function(cMap){properties.cMap=cMap;properties.vertical=properties.cMap.vertical})}else{cMapPromise=Promise.resolve(undefined)}return cMapPromise.then(function(){return this.extractDataStructures(dict,baseDict,xref,properties)}.bind(this)).then(function(properties){this.extractWidths(dict,xref,descriptor,properties);if(type==="Type3"){properties.isType3Font=true}return new Font(fontName.name,fontFile,properties)}.bind(this))}};return PartialEvaluator}();var TranslatedFont=function TranslatedFontClosure(){function TranslatedFont(loadedName,font,dict){this.loadedName=loadedName;this.font=font;this.dict=dict;this.type3Loaded=null;this.sent=false}TranslatedFont.prototype={send:function(handler){if(this.sent){return}var fontData=this.font.exportData();handler.send("commonobj",[this.loadedName,"Font",fontData]);this.sent=true},loadType3Data:function(evaluator,resources,parentOperatorList,task){assert(this.font.isType3Font);if(this.type3Loaded){return this.type3Loaded}var translatedFont=this.font;var loadCharProcsPromise=Promise.resolve();var charProcs=this.dict.get("CharProcs");var fontResources=this.dict.get("Resources")||resources;var charProcKeys=charProcs.getKeys();var charProcOperatorList=Object.create(null);for(var i=0,n=charProcKeys.length;i<n;++i){loadCharProcsPromise=loadCharProcsPromise.then(function(key){var glyphStream=charProcs.get(key);var operatorList=new OperatorList;return evaluator.getOperatorList(glyphStream,task,fontResources,operatorList).then(function(){charProcOperatorList[key]=operatorList.getIR();parentOperatorList.addDependencies(operatorList.dependencies)},function(reason){warn('Type3 font resource "'+key+'" is not available');var operatorList=new OperatorList;charProcOperatorList[key]=operatorList.getIR()})}.bind(this,charProcKeys[i]))}this.type3Loaded=loadCharProcsPromise.then(function(){translatedFont.charProcOperatorList=charProcOperatorList});return this.type3Loaded}};return TranslatedFont}();var OperatorList=function OperatorListClosure(){var CHUNK_SIZE=1e3;var CHUNK_SIZE_ABOUT=CHUNK_SIZE-5;function getTransfers(queue){var transfers=[];var fnArray=queue.fnArray,argsArray=queue.argsArray;for(var i=0,ii=queue.length;i<ii;i++){switch(fnArray[i]){case OPS.paintInlineImageXObject:case OPS.paintInlineImageXObjectGroup:case OPS.paintImageMaskXObject:var arg=argsArray[i][0];if(!arg.cached){transfers.push(arg.data.buffer)}break}}return transfers}function OperatorList(intent,messageHandler,pageIndex){this.messageHandler=messageHandler;this.fnArray=[];this.argsArray=[];this.dependencies=Object.create(null);this._totalLength=0;this.pageIndex=pageIndex;this.intent=intent}OperatorList.prototype={get length(){return this.argsArray.length},get totalLength(){return this._totalLength+this.length},addOp:function(fn,args){this.fnArray.push(fn);this.argsArray.push(args);if(this.messageHandler){if(this.fnArray.length>=CHUNK_SIZE){this.flush()}else if(this.fnArray.length>=CHUNK_SIZE_ABOUT&&(fn===OPS.restore||fn===OPS.endText)){this.flush()}}},addDependency:function(dependency){if(dependency in this.dependencies){return}this.dependencies[dependency]=true;this.addOp(OPS.dependency,[dependency])},addDependencies:function(dependencies){for(var key in dependencies){this.addDependency(key)}},addOpList:function(opList){Util.extendObj(this.dependencies,opList.dependencies);for(var i=0,ii=opList.length;i<ii;i++){this.addOp(opList.fnArray[i],opList.argsArray[i])}},getIR:function(){return{fnArray:this.fnArray,argsArray:this.argsArray,length:this.length}},flush:function(lastChunk){if(this.intent!=="oplist"){(new QueueOptimizer).optimize(this)}var transfers=getTransfers(this);var length=this.length;this._totalLength+=length;this.messageHandler.send("RenderPageChunk",{operatorList:{fnArray:this.fnArray,argsArray:this.argsArray,lastChunk:lastChunk,length:length},pageIndex:this.pageIndex,intent:this.intent},transfers);this.dependencies=Object.create(null);this.fnArray.length=0;this.argsArray.length=0}};return OperatorList}();var StateManager=function StateManagerClosure(){function StateManager(initialState){this.state=initialState;this.stateStack=[]}StateManager.prototype={save:function(){var old=this.state;this.stateStack.push(this.state);this.state=old.clone()},restore:function(){var prev=this.stateStack.pop();if(prev){this.state=prev}},transform:function(args){this.state.ctm=Util.transform(this.state.ctm,args)}};return StateManager}();var TextState=function TextStateClosure(){function TextState(){this.ctm=new Float32Array(IDENTITY_MATRIX);this.fontName=null;this.fontSize=0;this.font=null;this.fontMatrix=FONT_IDENTITY_MATRIX;this.textMatrix=IDENTITY_MATRIX.slice();this.textLineMatrix=IDENTITY_MATRIX.slice();this.charSpacing=0;this.wordSpacing=0;this.leading=0;this.textHScale=1;this.textRise=0}TextState.prototype={setTextMatrix:function TextState_setTextMatrix(a,b,c,d,e,f){var m=this.textMatrix;m[0]=a;m[1]=b;m[2]=c;m[3]=d;m[4]=e;m[5]=f},setTextLineMatrix:function TextState_setTextMatrix(a,b,c,d,e,f){var m=this.textLineMatrix;m[0]=a;m[1]=b;m[2]=c;m[3]=d;m[4]=e;m[5]=f},translateTextMatrix:function TextState_translateTextMatrix(x,y){var m=this.textMatrix;m[4]=m[0]*x+m[2]*y+m[4];m[5]=m[1]*x+m[3]*y+m[5]},translateTextLineMatrix:function TextState_translateTextMatrix(x,y){var m=this.textLineMatrix;m[4]=m[0]*x+m[2]*y+m[4];m[5]=m[1]*x+m[3]*y+m[5]},calcTextLineMatrixAdvance:function TextState_calcTextLineMatrixAdvance(a,b,c,d,e,f){var font=this.font;if(!font){return null}var m=this.textLineMatrix;if(!(a===m[0]&&b===m[1]&&c===m[2]&&d===m[3])){return null}var txDiff=e-m[4],tyDiff=f-m[5];if(font.vertical&&txDiff!==0||!font.vertical&&tyDiff!==0){return null}var tx,ty,denominator=a*d-b*c;if(font.vertical){tx=-tyDiff*c/denominator;ty=tyDiff*a/denominator}else{tx=txDiff*d/denominator;ty=-txDiff*b/denominator}return{width:tx,height:ty,value:font.vertical?ty:tx}},calcRenderMatrix:function TextState_calcRendeMatrix(ctm){var tsm=[this.fontSize*this.textHScale,0,0,this.fontSize,0,this.textRise];return Util.transform(ctm,Util.transform(this.textMatrix,tsm))},carriageReturn:function TextState_carriageReturn(){this.translateTextLineMatrix(0,-this.leading);this.textMatrix=this.textLineMatrix.slice()},clone:function TextState_clone(){var clone=Object.create(this);clone.textMatrix=this.textMatrix.slice();clone.textLineMatrix=this.textLineMatrix.slice();clone.fontMatrix=this.fontMatrix.slice();return clone}};return TextState}();var EvalState=function EvalStateClosure(){function EvalState(){this.ctm=new Float32Array(IDENTITY_MATRIX);this.font=null;this.textRenderingMode=TextRenderingMode.FILL;this.fillColorSpace=ColorSpace.singletons.gray;this.strokeColorSpace=ColorSpace.singletons.gray}EvalState.prototype={clone:function CanvasExtraState_clone(){return Object.create(this)}};return EvalState}();var EvaluatorPreprocessor=function EvaluatorPreprocessorClosure(){var getOPMap=getLookupTableFactory(function(t){t["w"]={id:OPS.setLineWidth,numArgs:1,variableArgs:false};t["J"]={id:OPS.setLineCap,numArgs:1,variableArgs:false};t["j"]={id:OPS.setLineJoin,numArgs:1,variableArgs:false};t["M"]={id:OPS.setMiterLimit,numArgs:1,variableArgs:false};t["d"]={id:OPS.setDash,numArgs:2,variableArgs:false};t["ri"]={id:OPS.setRenderingIntent,numArgs:1,variableArgs:false};t["i"]={id:OPS.setFlatness,numArgs:1,variableArgs:false};t["gs"]={id:OPS.setGState,numArgs:1,variableArgs:false};t["q"]={id:OPS.save,numArgs:0,variableArgs:false};t["Q"]={id:OPS.restore,numArgs:0,variableArgs:false};t["cm"]={id:OPS.transform,numArgs:6,variableArgs:false};t["m"]={id:OPS.moveTo,numArgs:2,variableArgs:false};t["l"]={id:OPS.lineTo,numArgs:2,variableArgs:false};t["c"]={id:OPS.curveTo,numArgs:6,variableArgs:false};t["v"]={id:OPS.curveTo2,numArgs:4,variableArgs:false};t["y"]={id:OPS.curveTo3,numArgs:4,variableArgs:false};t["h"]={id:OPS.closePath,numArgs:0,variableArgs:false};t["re"]={id:OPS.rectangle,numArgs:4,variableArgs:false};t["S"]={id:OPS.stroke,numArgs:0,variableArgs:false};t["s"]={id:OPS.closeStroke,numArgs:0,variableArgs:false};t["f"]={id:OPS.fill,numArgs:0,variableArgs:false};t["F"]={id:OPS.fill,numArgs:0,variableArgs:false};t["f*"]={id:OPS.eoFill,numArgs:0,variableArgs:false};t["B"]={id:OPS.fillStroke,numArgs:0,variableArgs:false};t["B*"]={id:OPS.eoFillStroke,numArgs:0,variableArgs:false};t["b"]={id:OPS.closeFillStroke,numArgs:0,variableArgs:false};t["b*"]={id:OPS.closeEOFillStroke,numArgs:0,variableArgs:false};t["n"]={id:OPS.endPath,numArgs:0,variableArgs:false};t["W"]={id:OPS.clip,numArgs:0,variableArgs:false};t["W*"]={id:OPS.eoClip,numArgs:0,variableArgs:false};t["BT"]={id:OPS.beginText,numArgs:0,variableArgs:false};t["ET"]={id:OPS.endText,numArgs:0,variableArgs:false};t["Tc"]={id:OPS.setCharSpacing,numArgs:1,variableArgs:false};t["Tw"]={id:OPS.setWordSpacing,numArgs:1,variableArgs:false};t["Tz"]={id:OPS.setHScale,numArgs:1,variableArgs:false};t["TL"]={id:OPS.setLeading,numArgs:1,variableArgs:false};t["Tf"]={id:OPS.setFont,numArgs:2,variableArgs:false};t["Tr"]={id:OPS.setTextRenderingMode,numArgs:1,variableArgs:false};t["Ts"]={id:OPS.setTextRise,numArgs:1,variableArgs:false};t["Td"]={id:OPS.moveText,numArgs:2,variableArgs:false};t["TD"]={id:OPS.setLeadingMoveText,numArgs:2,variableArgs:false};t["Tm"]={id:OPS.setTextMatrix,numArgs:6,variableArgs:false};t["T*"]={id:OPS.nextLine,numArgs:0,variableArgs:false};t["Tj"]={id:OPS.showText,numArgs:1,variableArgs:false};t["TJ"]={id:OPS.showSpacedText,numArgs:1,variableArgs:false};t["'"]={id:OPS.nextLineShowText,numArgs:1,variableArgs:false};t['"']={id:OPS.nextLineSetSpacingShowText,numArgs:3,variableArgs:false};t["d0"]={id:OPS.setCharWidth,numArgs:2,variableArgs:false};t["d1"]={id:OPS.setCharWidthAndBounds,numArgs:6,variableArgs:false};t["CS"]={id:OPS.setStrokeColorSpace,numArgs:1,variableArgs:false};t["cs"]={id:OPS.setFillColorSpace,numArgs:1,variableArgs:false};t["SC"]={id:OPS.setStrokeColor,numArgs:4,variableArgs:true};t["SCN"]={id:OPS.setStrokeColorN,numArgs:33,variableArgs:true};t["sc"]={id:OPS.setFillColor,numArgs:4,variableArgs:true};t["scn"]={id:OPS.setFillColorN,numArgs:33,variableArgs:true};t["G"]={id:OPS.setStrokeGray,numArgs:1,variableArgs:false};t["g"]={id:OPS.setFillGray,numArgs:1,variableArgs:false};t["RG"]={id:OPS.setStrokeRGBColor,numArgs:3,variableArgs:false};t["rg"]={id:OPS.setFillRGBColor,numArgs:3,variableArgs:false};t["K"]={id:OPS.setStrokeCMYKColor,numArgs:4,variableArgs:false};t["k"]={id:OPS.setFillCMYKColor,numArgs:4,variableArgs:false};t["sh"]={id:OPS.shadingFill,numArgs:1,variableArgs:false};t["BI"]={id:OPS.beginInlineImage,numArgs:0,variableArgs:false};t["ID"]={id:OPS.beginImageData,numArgs:0,variableArgs:false};t["EI"]={id:OPS.endInlineImage,numArgs:1,variableArgs:false};t["Do"]={id:OPS.paintXObject,numArgs:1,variableArgs:false};t["MP"]={id:OPS.markPoint,numArgs:1,variableArgs:false};t["DP"]={id:OPS.markPointProps,numArgs:2,variableArgs:false};t["BMC"]={id:OPS.beginMarkedContent,numArgs:1,variableArgs:false};t["BDC"]={id:OPS.beginMarkedContentProps,numArgs:2,variableArgs:false};t["EMC"]={id:OPS.endMarkedContent,numArgs:0,variableArgs:false};t["BX"]={id:OPS.beginCompat,numArgs:0,variableArgs:false};t["EX"]={id:OPS.endCompat,numArgs:0,variableArgs:false};t["BM"]=null;t["BD"]=null;t["true"]=null;t["fa"]=null;t["fal"]=null;t["fals"]=null;t["false"]=null;t["nu"]=null;t["nul"]=null;t["null"]=null});function EvaluatorPreprocessor(stream,xref,stateManager){this.opMap=getOPMap();this.parser=new Parser(new Lexer(stream,this.opMap),false,xref);this.stateManager=stateManager;this.nonProcessedArgs=[]}EvaluatorPreprocessor.prototype={get savedStatesDepth(){return this.stateManager.stateStack.length},read:function EvaluatorPreprocessor_read(operation){var args=operation.args;while(true){var obj=this.parser.getObj();if(isCmd(obj)){var cmd=obj.cmd;var opSpec=this.opMap[cmd];if(!opSpec){warn('Unknown command "'+cmd+'"');continue}var fn=opSpec.id;var numArgs=opSpec.numArgs;var argsLength=args!==null?args.length:0;if(!opSpec.variableArgs){if(argsLength!==numArgs){var nonProcessedArgs=this.nonProcessedArgs;while(argsLength>numArgs){nonProcessedArgs.push(args.shift());argsLength--}while(argsLength<numArgs&&nonProcessedArgs.length!==0){if(!args){args=[]}args.unshift(nonProcessedArgs.pop());argsLength++}}if(argsLength<numArgs){info("Command "+fn+": because expected "+numArgs+" args, but received "+argsLength+" args; skipping");args=null;continue}}else if(argsLength>numArgs){info("Command "+fn+": expected [0,"+numArgs+"] args, but received "+argsLength+" args")}this.preprocessCommand(fn,args);operation.fn=fn;operation.args=args;return true}else{if(isEOF(obj)){return false}if(obj!==null){if(!args){args=[]}args.push(obj);assert(args.length<=33,"Too many arguments")}}}},preprocessCommand:function EvaluatorPreprocessor_preprocessCommand(fn,args){switch(fn|0){case OPS.save:this.stateManager.save();break;case OPS.restore:this.stateManager.restore();break;case OPS.transform:this.stateManager.transform(args);break}}};return EvaluatorPreprocessor}();var QueueOptimizer=function QueueOptimizerClosure(){function addState(parentState,pattern,fn){var state=parentState;for(var i=0,ii=pattern.length-1;i<ii;i++){var item=pattern[i];state=state[item]||(state[item]=[])}state[pattern[pattern.length-1]]=fn}function handlePaintSolidColorImageMask(iFirstSave,count,fnArray,argsArray){var iFirstPIMXO=iFirstSave+2;for(var i=0;i<count;i++){var arg=argsArray[iFirstPIMXO+4*i];var imageMask=arg.length===1&&arg[0];if(imageMask&&imageMask.width===1&&imageMask.height===1&&(!imageMask.data.length||imageMask.data.length===1&&imageMask.data[0]===0)){fnArray[iFirstPIMXO+4*i]=OPS.paintSolidColorImageMask;continue}break}return count-i}var InitialState=[];addState(InitialState,[OPS.save,OPS.transform,OPS.paintInlineImageXObject,OPS.restore],function foundInlineImageGroup(context){var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK=10;var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK=200;var MAX_WIDTH=1e3;var IMAGE_PADDING=1;var fnArray=context.fnArray,argsArray=context.argsArray;var curr=context.iCurr;var iFirstSave=curr-3;var iFirstTransform=curr-2;var iFirstPIIXO=curr-1;var i=iFirstSave+4;var ii=fnArray.length;while(i+3<ii){if(fnArray[i]!==OPS.save||fnArray[i+1]!==OPS.transform||fnArray[i+2]!==OPS.paintInlineImageXObject||fnArray[i+3]!==OPS.restore){break}i+=4}var count=Math.min((i-iFirstSave)/4,MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);if(count<MIN_IMAGES_IN_INLINE_IMAGES_BLOCK){return i}var maxX=0;var map=[],maxLineHeight=0;var currentX=IMAGE_PADDING,currentY=IMAGE_PADDING;var q;for(q=0;q<count;q++){var transform=argsArray[iFirstTransform+(q<<2)];var img=argsArray[iFirstPIIXO+(q<<2)][0];if(currentX+img.width>MAX_WIDTH){maxX=Math.max(maxX,currentX);currentY+=maxLineHeight+2*IMAGE_PADDING;currentX=0;maxLineHeight=0}map.push({transform:transform,x:currentX,y:currentY,w:img.width,h:img.height});currentX+=img.width+2*IMAGE_PADDING;maxLineHeight=Math.max(maxLineHeight,img.height)}var imgWidth=Math.max(maxX,currentX)+IMAGE_PADDING;var imgHeight=currentY+maxLineHeight+IMAGE_PADDING;var imgData=new Uint8Array(imgWidth*imgHeight*4);var imgRowSize=imgWidth<<2;for(q=0;q<count;q++){var data=argsArray[iFirstPIIXO+(q<<2)][0].data;var rowSize=map[q].w<<2;var dataOffset=0;var offset=map[q].x+map[q].y*imgWidth<<2;imgData.set(data.subarray(0,rowSize),offset-imgRowSize);for(var k=0,kk=map[q].h;k<kk;k++){imgData.set(data.subarray(dataOffset,dataOffset+rowSize),offset);dataOffset+=rowSize;offset+=imgRowSize}imgData.set(data.subarray(dataOffset-rowSize,dataOffset),offset);while(offset>=0){data[offset-4]=data[offset];data[offset-3]=data[offset+1];data[offset-2]=data[offset+2];data[offset-1]=data[offset+3];data[offset+rowSize]=data[offset+rowSize-4];data[offset+rowSize+1]=data[offset+rowSize-3];data[offset+rowSize+2]=data[offset+rowSize-2];data[offset+rowSize+3]=data[offset+rowSize-1];offset-=imgRowSize}}fnArray.splice(iFirstSave,count*4,OPS.paintInlineImageXObjectGroup);argsArray.splice(iFirstSave,count*4,[{width:imgWidth,height:imgHeight,kind:ImageKind.RGBA_32BPP,data:imgData},map]);return iFirstSave+1});addState(InitialState,[OPS.save,OPS.transform,OPS.paintImageMaskXObject,OPS.restore],function foundImageMaskGroup(context){var MIN_IMAGES_IN_MASKS_BLOCK=10;var MAX_IMAGES_IN_MASKS_BLOCK=100;var MAX_SAME_IMAGES_IN_MASKS_BLOCK=1e3;var fnArray=context.fnArray,argsArray=context.argsArray;var curr=context.iCurr;var iFirstSave=curr-3;var iFirstTransform=curr-2;var iFirstPIMXO=curr-1;var i=iFirstSave+4;var ii=fnArray.length;while(i+3<ii){if(fnArray[i]!==OPS.save||fnArray[i+1]!==OPS.transform||fnArray[i+2]!==OPS.paintImageMaskXObject||fnArray[i+3]!==OPS.restore){break}i+=4}var count=(i-iFirstSave)/4;count=handlePaintSolidColorImageMask(iFirstSave,count,fnArray,argsArray);if(count<MIN_IMAGES_IN_MASKS_BLOCK){return i}var q;var isSameImage=false;var iTransform,transformArgs;var firstPIMXOArg0=argsArray[iFirstPIMXO][0];if(argsArray[iFirstTransform][1]===0&&argsArray[iFirstTransform][2]===0){isSameImage=true;
26var firstTransformArg0=argsArray[iFirstTransform][0];var firstTransformArg3=argsArray[iFirstTransform][3];iTransform=iFirstTransform+4;var iPIMXO=iFirstPIMXO+4;for(q=1;q<count;q++,iTransform+=4,iPIMXO+=4){transformArgs=argsArray[iTransform];if(argsArray[iPIMXO][0]!==firstPIMXOArg0||transformArgs[0]!==firstTransformArg0||transformArgs[1]!==0||transformArgs[2]!==0||transformArgs[3]!==firstTransformArg3){if(q<MIN_IMAGES_IN_MASKS_BLOCK){isSameImage=false}else{count=q}break}}}if(isSameImage){count=Math.min(count,MAX_SAME_IMAGES_IN_MASKS_BLOCK);var positions=new Float32Array(count*2);iTransform=iFirstTransform;for(q=0;q<count;q++,iTransform+=4){transformArgs=argsArray[iTransform];positions[q<<1]=transformArgs[4];positions[(q<<1)+1]=transformArgs[5]}fnArray.splice(iFirstSave,count*4,OPS.paintImageMaskXObjectRepeat);argsArray.splice(iFirstSave,count*4,[firstPIMXOArg0,firstTransformArg0,firstTransformArg3,positions])}else{count=Math.min(count,MAX_IMAGES_IN_MASKS_BLOCK);var images=[];for(q=0;q<count;q++){transformArgs=argsArray[iFirstTransform+(q<<2)];var maskParams=argsArray[iFirstPIMXO+(q<<2)][0];images.push({data:maskParams.data,width:maskParams.width,height:maskParams.height,transform:transformArgs})}fnArray.splice(iFirstSave,count*4,OPS.paintImageMaskXObjectGroup);argsArray.splice(iFirstSave,count*4,[images])}return iFirstSave+1});addState(InitialState,[OPS.save,OPS.transform,OPS.paintImageXObject,OPS.restore],function(context){var MIN_IMAGES_IN_BLOCK=3;var MAX_IMAGES_IN_BLOCK=1e3;var fnArray=context.fnArray,argsArray=context.argsArray;var curr=context.iCurr;var iFirstSave=curr-3;var iFirstTransform=curr-2;var iFirstPIXO=curr-1;var iFirstRestore=curr;if(argsArray[iFirstTransform][1]!==0||argsArray[iFirstTransform][2]!==0){return iFirstRestore+1}var firstPIXOArg0=argsArray[iFirstPIXO][0];var firstTransformArg0=argsArray[iFirstTransform][0];var firstTransformArg3=argsArray[iFirstTransform][3];var i=iFirstSave+4;var ii=fnArray.length;while(i+3<ii){if(fnArray[i]!==OPS.save||fnArray[i+1]!==OPS.transform||fnArray[i+2]!==OPS.paintImageXObject||fnArray[i+3]!==OPS.restore){break}if(argsArray[i+1][0]!==firstTransformArg0||argsArray[i+1][1]!==0||argsArray[i+1][2]!==0||argsArray[i+1][3]!==firstTransformArg3){break}if(argsArray[i+2][0]!==firstPIXOArg0){break}i+=4}var count=Math.min((i-iFirstSave)/4,MAX_IMAGES_IN_BLOCK);if(count<MIN_IMAGES_IN_BLOCK){return i}var positions=new Float32Array(count*2);var iTransform=iFirstTransform;for(var q=0;q<count;q++,iTransform+=4){var transformArgs=argsArray[iTransform];positions[q<<1]=transformArgs[4];positions[(q<<1)+1]=transformArgs[5]}var args=[firstPIXOArg0,firstTransformArg0,firstTransformArg3,positions];fnArray.splice(iFirstSave,count*4,OPS.paintImageXObjectRepeat);argsArray.splice(iFirstSave,count*4,args);return iFirstSave+1});addState(InitialState,[OPS.beginText,OPS.setFont,OPS.setTextMatrix,OPS.showText,OPS.endText],function(context){var MIN_CHARS_IN_BLOCK=3;var MAX_CHARS_IN_BLOCK=1e3;var fnArray=context.fnArray,argsArray=context.argsArray;var curr=context.iCurr;var iFirstBeginText=curr-4;var iFirstSetFont=curr-3;var iFirstSetTextMatrix=curr-2;var iFirstShowText=curr-1;var iFirstEndText=curr;var firstSetFontArg0=argsArray[iFirstSetFont][0];var firstSetFontArg1=argsArray[iFirstSetFont][1];var i=iFirstBeginText+5;var ii=fnArray.length;while(i+4<ii){if(fnArray[i]!==OPS.beginText||fnArray[i+1]!==OPS.setFont||fnArray[i+2]!==OPS.setTextMatrix||fnArray[i+3]!==OPS.showText||fnArray[i+4]!==OPS.endText){break}if(argsArray[i+1][0]!==firstSetFontArg0||argsArray[i+1][1]!==firstSetFontArg1){break}i+=5}var count=Math.min((i-iFirstBeginText)/5,MAX_CHARS_IN_BLOCK);if(count<MIN_CHARS_IN_BLOCK){return i}var iFirst=iFirstBeginText;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){count++;iFirst-=5}var iEndText=iFirst+4;for(var q=1;q<count;q++){fnArray.splice(iEndText,3);argsArray.splice(iEndText,3);iEndText+=2}return iEndText+1});function QueueOptimizer(){}QueueOptimizer.prototype={optimize:function QueueOptimizer_optimize(queue){var fnArray=queue.fnArray,argsArray=queue.argsArray;var context={iCurr:0,fnArray:fnArray,argsArray:argsArray};var state;var i=0,ii=fnArray.length;while(i<ii){state=(state||InitialState)[fnArray[i]];if(typeof state==="function"){context.iCurr=i;i=state(context);state=undefined;ii=context.fnArray.length}else{i++}}}};return QueueOptimizer}();exports.OperatorList=OperatorList;exports.PartialEvaluator=PartialEvaluator});(function(root,factory){{factory(root.pdfjsCoreAnnotation={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreStream,root.pdfjsCoreColorSpace,root.pdfjsCoreObj,root.pdfjsCoreEvaluator)}})(this,function(exports,sharedUtil,corePrimitives,coreStream,coreColorSpace,coreObj,coreEvaluator){var AnnotationBorderStyleType=sharedUtil.AnnotationBorderStyleType;var AnnotationFieldFlag=sharedUtil.AnnotationFieldFlag;var AnnotationFlag=sharedUtil.AnnotationFlag;var AnnotationType=sharedUtil.AnnotationType;var OPS=sharedUtil.OPS;var Util=sharedUtil.Util;var isBool=sharedUtil.isBool;var isString=sharedUtil.isString;var isArray=sharedUtil.isArray;var isInt=sharedUtil.isInt;var isValidUrl=sharedUtil.isValidUrl;var stringToBytes=sharedUtil.stringToBytes;var stringToPDFString=sharedUtil.stringToPDFString;var stringToUTF8String=sharedUtil.stringToUTF8String;var warn=sharedUtil.warn;var Dict=corePrimitives.Dict;var isDict=corePrimitives.isDict;var isName=corePrimitives.isName;var isRef=corePrimitives.isRef;var Stream=coreStream.Stream;var ColorSpace=coreColorSpace.ColorSpace;var ObjectLoader=coreObj.ObjectLoader;var FileSpec=coreObj.FileSpec;var OperatorList=coreEvaluator.OperatorList;function AnnotationFactory(){}AnnotationFactory.prototype={create:function AnnotationFactory_create(xref,ref,uniquePrefix,idCounters){var dict=xref.fetchIfRef(ref);if(!isDict(dict)){return}var id=isRef(ref)?ref.toString():"annot_"+(uniquePrefix||"")+ ++idCounters.obj;var subtype=dict.get("Subtype");subtype=isName(subtype)?subtype.name:null;var parameters={xref:xref,dict:dict,ref:isRef(ref)?ref:null,subtype:subtype,id:id};switch(subtype){case"Link":return new LinkAnnotation(parameters);case"Text":return new TextAnnotation(parameters);case"Widget":var fieldType=Util.getInheritableProperty(dict,"FT");fieldType=isName(fieldType)?fieldType.name:null;switch(fieldType){case"Tx":return new TextWidgetAnnotation(parameters)}warn('Unimplemented widget field type "'+fieldType+'", '+"falling back to base field type.");return new WidgetAnnotation(parameters);case"Popup":return new PopupAnnotation(parameters);case"Highlight":return new HighlightAnnotation(parameters);case"Underline":return new UnderlineAnnotation(parameters);case"Squiggly":return new SquigglyAnnotation(parameters);case"StrikeOut":return new StrikeOutAnnotation(parameters);case"FileAttachment":return new FileAttachmentAnnotation(parameters);default:if(!subtype){warn("Annotation is missing the required /Subtype.")}else{warn('Unimplemented annotation type "'+subtype+'", '+"falling back to base annotation.")}return new Annotation(parameters)}}};var Annotation=function AnnotationClosure(){function getTransformMatrix(rect,bbox,matrix){var bounds=Util.getAxialAlignedBoundingBox(bbox,matrix);var minX=bounds[0];var minY=bounds[1];var maxX=bounds[2];var maxY=bounds[3];if(minX===maxX||minY===maxY){return[1,0,0,1,rect[0],rect[1]]}var xRatio=(rect[2]-rect[0])/(maxX-minX);var yRatio=(rect[3]-rect[1])/(maxY-minY);return[xRatio,0,0,yRatio,rect[0]-minX*xRatio,rect[1]-minY*yRatio]}function getDefaultAppearance(dict){var appearanceState=dict.get("AP");if(!isDict(appearanceState)){return}var appearance;var appearances=appearanceState.get("N");if(isDict(appearances)){var as=dict.get("AS");if(as&&appearances.has(as.name)){appearance=appearances.get(as.name)}}else{appearance=appearances}return appearance}function Annotation(params){var dict=params.dict;this.setFlags(dict.get("F"));this.setRectangle(dict.getArray("Rect"));this.setColor(dict.getArray("C"));this.setBorderStyle(dict);this.appearance=getDefaultAppearance(dict);this.data={};this.data.id=params.id;this.data.subtype=params.subtype;this.data.annotationFlags=this.flags;this.data.rect=this.rectangle;this.data.color=this.color;this.data.borderStyle=this.borderStyle;this.data.hasAppearance=!!this.appearance}Annotation.prototype={_hasFlag:function Annotation_hasFlag(flags,flag){return!!(flags&flag)},_isViewable:function Annotation_isViewable(flags){return!this._hasFlag(flags,AnnotationFlag.INVISIBLE)&&!this._hasFlag(flags,AnnotationFlag.HIDDEN)&&!this._hasFlag(flags,AnnotationFlag.NOVIEW)},_isPrintable:function AnnotationFlag_isPrintable(flags){return this._hasFlag(flags,AnnotationFlag.PRINT)&&!this._hasFlag(flags,AnnotationFlag.INVISIBLE)&&!this._hasFlag(flags,AnnotationFlag.HIDDEN)},get viewable(){if(this.flags===0){return true}return this._isViewable(this.flags)},get printable(){if(this.flags===0){return false}return this._isPrintable(this.flags)},setFlags:function Annotation_setFlags(flags){this.flags=isInt(flags)&&flags>0?flags:0},hasFlag:function Annotation_hasFlag(flag){return this._hasFlag(this.flags,flag)},setRectangle:function Annotation_setRectangle(rectangle){if(isArray(rectangle)&&rectangle.length===4){this.rectangle=Util.normalizeRect(rectangle)}else{this.rectangle=[0,0,0,0]}},setColor:function Annotation_setColor(color){var rgbColor=new Uint8Array(3);if(!isArray(color)){this.color=rgbColor;return}switch(color.length){case 0:this.color=null;break;case 1:ColorSpace.singletons.gray.getRgbItem(color,0,rgbColor,0);this.color=rgbColor;break;case 3:ColorSpace.singletons.rgb.getRgbItem(color,0,rgbColor,0);this.color=rgbColor;break;case 4:ColorSpace.singletons.cmyk.getRgbItem(color,0,rgbColor,0);this.color=rgbColor;break;default:this.color=rgbColor;break}},setBorderStyle:function Annotation_setBorderStyle(borderStyle){this.borderStyle=new AnnotationBorderStyle;if(!isDict(borderStyle)){return}if(borderStyle.has("BS")){var dict=borderStyle.get("BS");var dictType=dict.get("Type");if(!dictType||isName(dictType,"Border")){this.borderStyle.setWidth(dict.get("W"));this.borderStyle.setStyle(dict.get("S"));this.borderStyle.setDashArray(dict.getArray("D"))}}else if(borderStyle.has("Border")){var array=borderStyle.getArray("Border");if(isArray(array)&&array.length>=3){this.borderStyle.setHorizontalCornerRadius(array[0]);this.borderStyle.setVerticalCornerRadius(array[1]);this.borderStyle.setWidth(array[2]);if(array.length===4){this.borderStyle.setDashArray(array[3])}}}else{this.borderStyle.setWidth(0)}},_preparePopup:function Annotation_preparePopup(dict){if(!dict.has("C")){this.data.color=null}this.data.hasPopup=dict.has("Popup");this.data.title=stringToPDFString(dict.get("T")||"");this.data.contents=stringToPDFString(dict.get("Contents")||"")},loadResources:function Annotation_loadResources(keys){return new Promise(function(resolve,reject){this.appearance.dict.getAsync("Resources").then(function(resources){if(!resources){resolve();return}var objectLoader=new ObjectLoader(resources.map,keys,resources.xref);objectLoader.load().then(function(){resolve(resources)},reject)},reject)}.bind(this))},getOperatorList:function Annotation_getOperatorList(evaluator,task,renderForms){if(!this.appearance){return Promise.resolve(new OperatorList)}var data=this.data;var appearanceDict=this.appearance.dict;var resourcesPromise=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]);var bbox=appearanceDict.getArray("BBox")||[0,0,1,1];var matrix=appearanceDict.getArray("Matrix")||[1,0,0,1,0,0];var transform=getTransformMatrix(data.rect,bbox,matrix);var self=this;return resourcesPromise.then(function(resources){var opList=new OperatorList;opList.addOp(OPS.beginAnnotation,[data.rect,transform,matrix]);return evaluator.getOperatorList(self.appearance,task,resources,opList).then(function(){opList.addOp(OPS.endAnnotation,[]);self.appearance.reset();return opList})})}};Annotation.appendToOperatorList=function Annotation_appendToOperatorList(annotations,opList,partialEvaluator,task,intent,renderForms){var annotationPromises=[];for(var i=0,n=annotations.length;i<n;++i){if(intent==="display"&&annotations[i].viewable||intent==="print"&&annotations[i].printable){annotationPromises.push(annotations[i].getOperatorList(partialEvaluator,task,renderForms))}}return Promise.all(annotationPromises).then(function(operatorLists){opList.addOp(OPS.beginAnnotations,[]);for(var i=0,n=operatorLists.length;i<n;++i){opList.addOpList(operatorLists[i])}opList.addOp(OPS.endAnnotations,[])})};return Annotation}();var AnnotationBorderStyle=function AnnotationBorderStyleClosure(){function AnnotationBorderStyle(){this.width=1;this.style=AnnotationBorderStyleType.SOLID;this.dashArray=[3];this.horizontalCornerRadius=0;this.verticalCornerRadius=0}AnnotationBorderStyle.prototype={setWidth:function AnnotationBorderStyle_setWidth(width){if(width===(width|0)){this.width=width}},setStyle:function AnnotationBorderStyle_setStyle(style){if(!style){return}switch(style.name){case"S":this.style=AnnotationBorderStyleType.SOLID;break;case"D":this.style=AnnotationBorderStyleType.DASHED;break;case"B":this.style=AnnotationBorderStyleType.BEVELED;break;case"I":this.style=AnnotationBorderStyleType.INSET;break;case"U":this.style=AnnotationBorderStyleType.UNDERLINE;break;default:break}},setDashArray:function AnnotationBorderStyle_setDashArray(dashArray){if(isArray(dashArray)&&dashArray.length>0){var isValid=true;var allZeros=true;for(var i=0,len=dashArray.length;i<len;i++){var element=dashArray[i];var validNumber=+element>=0;if(!validNumber){isValid=false;break}else if(element>0){allZeros=false}}if(isValid&&!allZeros){this.dashArray=dashArray}else{this.width=0}}else if(dashArray){this.width=0}},setHorizontalCornerRadius:function AnnotationBorderStyle_setHorizontalCornerRadius(radius){if(radius===(radius|0)){this.horizontalCornerRadius=radius}},setVerticalCornerRadius:function AnnotationBorderStyle_setVerticalCornerRadius(radius){if(radius===(radius|0)){this.verticalCornerRadius=radius}}};return AnnotationBorderStyle}();var WidgetAnnotation=function WidgetAnnotationClosure(){function WidgetAnnotation(params){Annotation.call(this,params);var dict=params.dict;var data=this.data;data.annotationType=AnnotationType.WIDGET;data.fieldValue=stringToPDFString(Util.getInheritableProperty(dict,"V")||"");data.alternativeText=stringToPDFString(dict.get("TU")||"");data.defaultAppearance=Util.getInheritableProperty(dict,"DA")||"";var fieldType=Util.getInheritableProperty(dict,"FT");data.fieldType=isName(fieldType)?fieldType.name:null;this.fieldResources=Util.getInheritableProperty(dict,"DR")||Dict.empty;data.fieldFlags=Util.getInheritableProperty(dict,"Ff");if(!isInt(data.fieldFlags)||data.fieldFlags<0){data.fieldFlags=0}if(data.fieldType==="Sig"){this.setFlags(AnnotationFlag.HIDDEN)}var fieldName=[];var namedItem=dict;var ref=params.ref;while(namedItem){var parent=namedItem.get("Parent");var parentRef=namedItem.getRaw("Parent");var name=namedItem.get("T");if(name){fieldName.unshift(stringToPDFString(name))}else if(parent&&ref){var kids=parent.get("Kids");var j,jj;for(j=0,jj=kids.length;j<jj;j++){var kidRef=kids[j];if(kidRef.num===ref.num&&kidRef.gen===ref.gen){break}}fieldName.unshift("`"+j)}namedItem=parent;ref=parentRef}data.fullName=fieldName.join(".")}Util.inherit(WidgetAnnotation,Annotation,{hasFieldFlag:function WidgetAnnotation_hasFieldFlag(flag){return!!(this.data.fieldFlags&flag)}});return WidgetAnnotation}();var TextWidgetAnnotation=function TextWidgetAnnotationClosure(){function TextWidgetAnnotation(params){WidgetAnnotation.call(this,params);var alignment=Util.getInheritableProperty(params.dict,"Q");if(!isInt(alignment)||alignment<0||alignment>2){alignment=null}this.data.textAlignment=alignment;var maximumLength=Util.getInheritableProperty(params.dict,"MaxLen");if(!isInt(maximumLength)||maximumLength<0){maximumLength=null}this.data.maxLen=maximumLength;this.data.readOnly=this.hasFieldFlag(AnnotationFieldFlag.READONLY);this.data.multiLine=this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);this.data.comb=this.hasFieldFlag(AnnotationFieldFlag.COMB)&&!this.hasFieldFlag(AnnotationFieldFlag.MULTILINE)&&!this.hasFieldFlag(AnnotationFieldFlag.PASSWORD)&&!this.hasFieldFlag(AnnotationFieldFlag.FILESELECT)&&this.data.maxLen!==null}Util.inherit(TextWidgetAnnotation,WidgetAnnotation,{getOperatorList:function TextWidgetAnnotation_getOperatorList(evaluator,task,renderForms){var operatorList=new OperatorList;if(renderForms){return Promise.resolve(operatorList)}if(this.appearance){return Annotation.prototype.getOperatorList.call(this,evaluator,task,renderForms)}if(!this.data.defaultAppearance){return Promise.resolve(operatorList)}var stream=new Stream(stringToBytes(this.data.defaultAppearance));return evaluator.getOperatorList(stream,task,this.fieldResources,operatorList).then(function(){return operatorList})}});return TextWidgetAnnotation}();var TextAnnotation=function TextAnnotationClosure(){var DEFAULT_ICON_SIZE=22;function TextAnnotation(parameters){Annotation.call(this,parameters);this.data.annotationType=AnnotationType.TEXT;if(this.data.hasAppearance){this.data.name="NoIcon"}else{this.data.rect[1]=this.data.rect[3]-DEFAULT_ICON_SIZE;this.data.rect[2]=this.data.rect[0]+DEFAULT_ICON_SIZE;this.data.name=parameters.dict.has("Name")?parameters.dict.get("Name").name:"Note"}this._preparePopup(parameters.dict)}Util.inherit(TextAnnotation,Annotation,{});return TextAnnotation}();var LinkAnnotation=function LinkAnnotationClosure(){function LinkAnnotation(params){Annotation.call(this,params);var dict=params.dict;var data=this.data;data.annotationType=AnnotationType.LINK;var action=dict.get("A"),url,dest;if(action&&isDict(action)){var linkType=action.get("S").name;switch(linkType){case"URI":url=action.get("URI");if(isName(url)){url="/"+url.name}else if(url){url=addDefaultProtocolToUrl(url)}break;case"GoTo":dest=action.get("D");break;case"GoToR":var urlDict=action.get("F");if(isDict(urlDict)){url=urlDict.get("F")||null}else if(isString(urlDict)){url=urlDict}var remoteDest=action.get("D");if(remoteDest){if(isName(remoteDest)){remoteDest=remoteDest.name}if(isString(url)){var baseUrl=url.split("#")[0];if(isString(remoteDest)){url=baseUrl+"#"+(/^\d+$/.test(remoteDest)?"nameddest=":"")+remoteDest}else if(isArray(remoteDest)){url=baseUrl+"#"+JSON.stringify(remoteDest)}}}var newWindow=action.get("NewWindow");if(isBool(newWindow)){data.newWindow=newWindow}break;case"Named":data.action=action.get("N").name;break;default:warn("unrecognized link type: "+linkType)}}else if(dict.has("Dest")){dest=dict.get("Dest")}if(url){if(isValidUrl(url,false)){data.url=tryConvertUrlEncoding(url)}}if(dest){data.dest=isName(dest)?dest.name:dest}}function addDefaultProtocolToUrl(url){if(isString(url)&&url.indexOf("www.")===0){return"http://"+url}return url}function tryConvertUrlEncoding(url){try{return stringToUTF8String(url)}catch(e){return url}}Util.inherit(LinkAnnotation,Annotation,{});return LinkAnnotation}();var PopupAnnotation=function PopupAnnotationClosure(){function PopupAnnotation(parameters){Annotation.call(this,parameters);this.data.annotationType=AnnotationType.POPUP;var dict=parameters.dict;var parentItem=dict.get("Parent");if(!parentItem){warn("Popup annotation has a missing or invalid parent annotation.");return}this.data.parentId=dict.getRaw("Parent").toString();this.data.title=stringToPDFString(parentItem.get("T")||"");this.data.contents=stringToPDFString(parentItem.get("Contents")||"");if(!parentItem.has("C")){this.data.color=null}else{this.setColor(parentItem.getArray("C"));this.data.color=this.color}if(!this.viewable){var parentFlags=parentItem.get("F");if(this._isViewable(parentFlags)){this.setFlags(parentFlags)}}}Util.inherit(PopupAnnotation,Annotation,{});return PopupAnnotation}();var HighlightAnnotation=function HighlightAnnotationClosure(){function HighlightAnnotation(parameters){Annotation.call(this,parameters);this.data.annotationType=AnnotationType.HIGHLIGHT;this._preparePopup(parameters.dict);this.data.borderStyle.setWidth(0)}Util.inherit(HighlightAnnotation,Annotation,{});return HighlightAnnotation}();var UnderlineAnnotation=function UnderlineAnnotationClosure(){function UnderlineAnnotation(parameters){Annotation.call(this,parameters);this.data.annotationType=AnnotationType.UNDERLINE;this._preparePopup(parameters.dict);this.data.borderStyle.setWidth(0)}Util.inherit(UnderlineAnnotation,Annotation,{});return UnderlineAnnotation}();var SquigglyAnnotation=function SquigglyAnnotationClosure(){function SquigglyAnnotation(parameters){Annotation.call(this,parameters);this.data.annotationType=AnnotationType.SQUIGGLY;this._preparePopup(parameters.dict);this.data.borderStyle.setWidth(0)}Util.inherit(SquigglyAnnotation,Annotation,{});return SquigglyAnnotation}();var StrikeOutAnnotation=function StrikeOutAnnotationClosure(){function StrikeOutAnnotation(parameters){Annotation.call(this,parameters);this.data.annotationType=AnnotationType.STRIKEOUT;this._preparePopup(parameters.dict);this.data.borderStyle.setWidth(0)}Util.inherit(StrikeOutAnnotation,Annotation,{});return StrikeOutAnnotation}();var FileAttachmentAnnotation=function FileAttachmentAnnotationClosure(){function FileAttachmentAnnotation(parameters){Annotation.call(this,parameters);var file=new FileSpec(parameters.dict.get("FS"),parameters.xref);this.data.annotationType=AnnotationType.FILEATTACHMENT;this.data.file=file.serializable;this._preparePopup(parameters.dict)}Util.inherit(FileAttachmentAnnotation,Annotation,{});return FileAttachmentAnnotation}();exports.Annotation=Annotation;exports.AnnotationBorderStyle=AnnotationBorderStyle;exports.AnnotationFactory=AnnotationFactory});(function(root,factory){{factory(root.pdfjsCoreDocument={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCoreStream,root.pdfjsCoreObj,root.pdfjsCoreParser,root.pdfjsCoreCrypto,root.pdfjsCoreEvaluator,root.pdfjsCoreAnnotation)}})(this,function(exports,sharedUtil,corePrimitives,coreStream,coreObj,coreParser,coreCrypto,coreEvaluator,coreAnnotation){var MissingDataException=sharedUtil.MissingDataException;var Util=sharedUtil.Util;var assert=sharedUtil.assert;var error=sharedUtil.error;var info=sharedUtil.info;var isArray=sharedUtil.isArray;var isArrayBuffer=sharedUtil.isArrayBuffer;var isString=sharedUtil.isString;var shadow=sharedUtil.shadow;var stringToBytes=sharedUtil.stringToBytes;var stringToPDFString=sharedUtil.stringToPDFString;var warn=sharedUtil.warn;var isSpace=sharedUtil.isSpace;var Dict=corePrimitives.Dict;var isDict=corePrimitives.isDict;var isName=corePrimitives.isName;var isStream=corePrimitives.isStream;var NullStream=coreStream.NullStream;var Stream=coreStream.Stream;var StreamsSequenceStream=coreStream.StreamsSequenceStream;var Catalog=coreObj.Catalog;var ObjectLoader=coreObj.ObjectLoader;var XRef=coreObj.XRef;var Linearization=coreParser.Linearization;var calculateMD5=coreCrypto.calculateMD5;var OperatorList=coreEvaluator.OperatorList;var PartialEvaluator=coreEvaluator.PartialEvaluator;var Annotation=coreAnnotation.Annotation;var AnnotationFactory=coreAnnotation.AnnotationFactory;var Page=function PageClosure(){var LETTER_SIZE_MEDIABOX=[0,0,612,792];function Page(pdfManager,xref,pageIndex,pageDict,ref,fontCache){this.pdfManager=pdfManager;this.pageIndex=pageIndex;this.pageDict=pageDict;this.xref=xref;this.ref=ref;this.fontCache=fontCache;this.uniquePrefix="p"+this.pageIndex+"_";this.idCounters={obj:0};this.evaluatorOptions=pdfManager.evaluatorOptions;this.resourcesPromise=null}Page.prototype={getPageProp:function Page_getPageProp(key){return this.pageDict.get(key)},getInheritedPageProp:function Page_getInheritedPageProp(key){var dict=this.pageDict,valueArray=null,loopCount=0;var MAX_LOOP_COUNT=100;while(dict){var value=dict.get(key);if(value){if(!valueArray){valueArray=[]}valueArray.push(value)}if(++loopCount>MAX_LOOP_COUNT){warn("Page_getInheritedPageProp: maximum loop count exceeded.");break}dict=dict.get("Parent")}if(!valueArray){return Dict.empty}if(valueArray.length===1||!isDict(valueArray[0])||loopCount>MAX_LOOP_COUNT){return valueArray[0]}return Dict.merge(this.xref,valueArray)},get content(){return this.getPageProp("Contents")},get resources(){return shadow(this,"resources",this.getInheritedPageProp("Resources"))},get mediaBox(){var obj=this.getInheritedPageProp("MediaBox");if(!isArray(obj)||obj.length!==4){obj=LETTER_SIZE_MEDIABOX}return shadow(this,"mediaBox",obj)},get view(){var mediaBox=this.mediaBox;var cropBox=this.getInheritedPageProp("CropBox");if(!isArray(cropBox)||cropBox.length!==4){return shadow(this,"view",mediaBox)}cropBox=Util.intersect(cropBox,mediaBox);if(!cropBox){return shadow(this,"view",mediaBox)}return shadow(this,"view",cropBox)},get rotate(){var rotate=this.getInheritedPageProp("Rotate")||0;if(rotate%90!==0){rotate=0}else if(rotate>=360){rotate=rotate%360}else if(rotate<0){rotate=(rotate%360+360)%360}return shadow(this,"rotate",rotate)},getContentStream:function Page_getContentStream(){var content=this.content;var stream;if(isArray(content)){var xref=this.xref;var i,n=content.length;var streams=[];for(i=0;i<n;++i){streams.push(xref.fetchIfRef(content[i]))}stream=new StreamsSequenceStream(streams)}else if(isStream(content)){stream=content}else{stream=new NullStream}return stream},loadResources:function Page_loadResources(keys){if(!this.resourcesPromise){this.resourcesPromise=this.pdfManager.ensure(this,"resources")}return this.resourcesPromise.then(function resourceSuccess(){var objectLoader=new ObjectLoader(this.resources.map,keys,this.xref);return objectLoader.load()}.bind(this))},getOperatorList:function Page_getOperatorList(handler,task,intent,renderInteractiveForms){var self=this;var pdfManager=this.pdfManager;var contentStreamPromise=pdfManager.ensure(this,"getContentStream",[]);var resourcesPromise=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]);var partialEvaluator=new PartialEvaluator(pdfManager,this.xref,handler,this.pageIndex,this.uniquePrefix,this.idCounters,this.fontCache,this.evaluatorOptions);var dataPromises=Promise.all([contentStreamPromise,resourcesPromise]);var pageListPromise=dataPromises.then(function(data){var contentStream=data[0];var opList=new OperatorList(intent,handler,self.pageIndex);handler.send("StartRenderPage",{transparency:partialEvaluator.hasBlendModes(self.resources),pageIndex:self.pageIndex,intent:intent});return partialEvaluator.getOperatorList(contentStream,task,self.resources,opList).then(function(){return opList})});var annotationsPromise=pdfManager.ensure(this,"annotations");return Promise.all([pageListPromise,annotationsPromise]).then(function(datas){var pageOpList=datas[0];var annotations=datas[1];if(annotations.length===0){pageOpList.flush(true);return pageOpList}var annotationsReadyPromise=Annotation.appendToOperatorList(annotations,pageOpList,partialEvaluator,task,intent,renderInteractiveForms);return annotationsReadyPromise.then(function(){pageOpList.flush(true);return pageOpList})})},extractTextContent:function Page_extractTextContent(task,normalizeWhitespace,combineTextItems){var handler={on:function nullHandlerOn(){},send:function nullHandlerSend(){}};var self=this;var pdfManager=this.pdfManager;var contentStreamPromise=pdfManager.ensure(this,"getContentStream",[]);var resourcesPromise=this.loadResources(["ExtGState","XObject","Font"]);var dataPromises=Promise.all([contentStreamPromise,resourcesPromise]);return dataPromises.then(function(data){var contentStream=data[0];var partialEvaluator=new PartialEvaluator(pdfManager,self.xref,handler,self.pageIndex,self.uniquePrefix,self.idCounters,self.fontCache,self.evaluatorOptions);return partialEvaluator.getTextContent(contentStream,task,self.resources,null,normalizeWhitespace,combineTextItems)})},getAnnotationsData:function Page_getAnnotationsData(intent){var annotations=this.annotations;var annotationsData=[];for(var i=0,n=annotations.length;i<n;++i){if(intent){if(!(intent==="display"&&annotations[i].viewable)&&!(intent==="print"&&annotations[i].printable)){continue}}annotationsData.push(annotations[i].data)}return annotationsData},get annotations(){var annotations=[];var annotationRefs=this.getInheritedPageProp("Annots")||[];var annotationFactory=new AnnotationFactory;for(var i=0,n=annotationRefs.length;i<n;++i){var annotationRef=annotationRefs[i];var annotation=annotationFactory.create(this.xref,annotationRef,this.uniquePrefix,this.idCounters);if(annotation){annotations.push(annotation)}}return shadow(this,"annotations",annotations)}};return Page}();var PDFDocument=function PDFDocumentClosure(){var FINGERPRINT_FIRST_BYTES=1024;var EMPTY_FINGERPRINT="\x00\x00\x00\x00\x00\x00\x00"+"\x00\x00\x00\x00\x00\x00\x00\x00\x00";function PDFDocument(pdfManager,arg,password){if(isStream(arg)){init.call(this,pdfManager,arg,password)}else if(isArrayBuffer(arg)){init.call(this,pdfManager,new Stream(arg),password)}else{error("PDFDocument: Unknown argument type")}}function init(pdfManager,stream,password){assert(stream.length>0,"stream must have data");this.pdfManager=pdfManager;this.stream=stream;var xref=new XRef(this.stream,password,pdfManager);this.xref=xref}function find(stream,needle,limit,backwards){var pos=stream.pos;var end=stream.end;var strBuf=[];if(pos+limit>end){limit=end-pos}for(var n=0;n<limit;++n){strBuf.push(String.fromCharCode(stream.getByte()))}var str=strBuf.join("");stream.pos=pos;var index=backwards?str.lastIndexOf(needle):str.indexOf(needle);if(index===-1){return false}stream.pos+=index;return true}var DocumentInfoValidators={get entries(){return shadow(this,"entries",{Title:isString,Author:isString,Subject:isString,Keywords:isString,Creator:isString,Producer:isString,CreationDate:isString,ModDate:isString,Trapped:isName})}};PDFDocument.prototype={parse:function PDFDocument_parse(recoveryMode){this.setup(recoveryMode);var version=this.catalog.catDict.get("Version");if(isName(version)){this.pdfFormatVersion=version.name}try{this.acroForm=this.catalog.catDict.get("AcroForm");if(this.acroForm){this.xfa=this.acroForm.get("XFA");var fields=this.acroForm.get("Fields");if((!fields||!isArray(fields)||fields.length===0)&&!this.xfa){this.acroForm=null}}}catch(ex){info("Something wrong with AcroForm entry");this.acroForm=null}},get linearization(){var linearization=null;if(this.stream.length){try{linearization=Linearization.create(this.stream)}catch(err){if(err instanceof MissingDataException){throw err}info(err)}}return shadow(this,"linearization",linearization)},get startXRef(){var stream=this.stream;var startXRef=0;var linearization=this.linearization;if(linearization){stream.reset();if(find(stream,"endobj",1024)){startXRef=stream.pos+6}}else{var step=1024;var found=false,pos=stream.end;while(!found&&pos>0){pos-=step-"startxref".length;if(pos<0){pos=0}stream.pos=pos;found=find(stream,"startxref",step,true)}if(found){stream.skip(9);var ch;do{ch=stream.getByte()}while(isSpace(ch));var str="";while(ch>=32&&ch<=57){str+=String.fromCharCode(ch);ch=stream.getByte()}startXRef=parseInt(str,10);if(isNaN(startXRef)){startXRef=0}}}return shadow(this,"startXRef",startXRef)},get mainXRefEntriesOffset(){var mainXRefEntriesOffset=0;var linearization=this.linearization;if(linearization){mainXRefEntriesOffset=linearization.mainXRefEntriesOffset}return shadow(this,"mainXRefEntriesOffset",mainXRefEntriesOffset)},checkHeader:function PDFDocument_checkHeader(){var stream=this.stream;stream.reset();if(find(stream,"%PDF-",1024)){stream.moveStart();var MAX_VERSION_LENGTH=12;var version="",ch;while((ch=stream.getByte())>32){if(version.length>=MAX_VERSION_LENGTH){break}version+=String.fromCharCode(ch)}if(!this.pdfFormatVersion){this.pdfFormatVersion=version.substring(5)}return}},parseStartXRef:function PDFDocument_parseStartXRef(){var startXRef=this.startXRef;
27this.xref.setStartXRef(startXRef)},setup:function PDFDocument_setup(recoveryMode){this.xref.parse(recoveryMode);var self=this;var pageFactory={createPage:function(pageIndex,dict,ref,fontCache){return new Page(self.pdfManager,self.xref,pageIndex,dict,ref,fontCache)}};this.catalog=new Catalog(this.pdfManager,this.xref,pageFactory)},get numPages(){var linearization=this.linearization;var num=linearization?linearization.numPages:this.catalog.numPages;return shadow(this,"numPages",num)},get documentInfo(){var docInfo={PDFFormatVersion:this.pdfFormatVersion,IsAcroFormPresent:!!this.acroForm,IsXFAPresent:!!this.xfa};var infoDict;try{infoDict=this.xref.trailer.get("Info")}catch(err){info("The document information dictionary is invalid.")}if(infoDict){var validEntries=DocumentInfoValidators.entries;for(var key in validEntries){if(infoDict.has(key)){var value=infoDict.get(key);if(validEntries[key](value)){docInfo[key]=typeof value!=="string"?value:stringToPDFString(value)}else{info('Bad value in document info for "'+key+'"')}}}}return shadow(this,"documentInfo",docInfo)},get fingerprint(){var xref=this.xref,hash,fileID="";var idArray=xref.trailer.get("ID");if(idArray&&isArray(idArray)&&idArray[0]&&isString(idArray[0])&&idArray[0]!==EMPTY_FINGERPRINT){hash=stringToBytes(idArray[0])}else{if(this.stream.ensureRange){this.stream.ensureRange(0,Math.min(FINGERPRINT_FIRST_BYTES,this.stream.end))}hash=calculateMD5(this.stream.bytes.subarray(0,FINGERPRINT_FIRST_BYTES),0,FINGERPRINT_FIRST_BYTES)}for(var i=0,n=hash.length;i<n;i++){var hex=hash[i].toString(16);fileID+=hex.length===1?"0"+hex:hex}return shadow(this,"fingerprint",fileID)},getPage:function PDFDocument_getPage(pageIndex){return this.catalog.getPage(pageIndex)},cleanup:function PDFDocument_cleanup(){return this.catalog.cleanup()}};return PDFDocument}();exports.Page=Page;exports.PDFDocument=PDFDocument});(function(root,factory){{factory(root.pdfjsCorePdfManager={},root.pdfjsSharedUtil,root.pdfjsCoreStream,root.pdfjsCoreChunkedStream,root.pdfjsCoreDocument)}})(this,function(exports,sharedUtil,coreStream,coreChunkedStream,coreDocument){var NotImplementedException=sharedUtil.NotImplementedException;var MissingDataException=sharedUtil.MissingDataException;var createPromiseCapability=sharedUtil.createPromiseCapability;var Util=sharedUtil.Util;var Stream=coreStream.Stream;var ChunkedStreamManager=coreChunkedStream.ChunkedStreamManager;var PDFDocument=coreDocument.PDFDocument;var BasePdfManager=function BasePdfManagerClosure(){function BasePdfManager(){throw new Error("Cannot initialize BaseManagerManager")}BasePdfManager.prototype={get docId(){return this._docId},onLoadedStream:function BasePdfManager_onLoadedStream(){throw new NotImplementedException},ensureDoc:function BasePdfManager_ensureDoc(prop,args){return this.ensure(this.pdfDocument,prop,args)},ensureXRef:function BasePdfManager_ensureXRef(prop,args){return this.ensure(this.pdfDocument.xref,prop,args)},ensureCatalog:function BasePdfManager_ensureCatalog(prop,args){return this.ensure(this.pdfDocument.catalog,prop,args)},getPage:function BasePdfManager_getPage(pageIndex){return this.pdfDocument.getPage(pageIndex)},cleanup:function BasePdfManager_cleanup(){return this.pdfDocument.cleanup()},ensure:function BasePdfManager_ensure(obj,prop,args){return new NotImplementedException},requestRange:function BasePdfManager_requestRange(begin,end){return new NotImplementedException},requestLoadedStream:function BasePdfManager_requestLoadedStream(){return new NotImplementedException},sendProgressiveData:function BasePdfManager_sendProgressiveData(chunk){return new NotImplementedException},updatePassword:function BasePdfManager_updatePassword(password){this.pdfDocument.xref.password=this.password=password;if(this._passwordChangedCapability){this._passwordChangedCapability.resolve()}},passwordChanged:function BasePdfManager_passwordChanged(){this._passwordChangedCapability=createPromiseCapability();return this._passwordChangedCapability.promise},terminate:function BasePdfManager_terminate(){return new NotImplementedException}};return BasePdfManager}();var LocalPdfManager=function LocalPdfManagerClosure(){function LocalPdfManager(docId,data,password,evaluatorOptions){this._docId=docId;this.evaluatorOptions=evaluatorOptions;var stream=new Stream(data);this.pdfDocument=new PDFDocument(this,stream,password);this._loadedStreamCapability=createPromiseCapability();this._loadedStreamCapability.resolve(stream)}Util.inherit(LocalPdfManager,BasePdfManager,{ensure:function LocalPdfManager_ensure(obj,prop,args){return new Promise(function(resolve,reject){try{var value=obj[prop];var result;if(typeof value==="function"){result=value.apply(obj,args)}else{result=value}resolve(result)}catch(e){reject(e)}})},requestRange:function LocalPdfManager_requestRange(begin,end){return Promise.resolve()},requestLoadedStream:function LocalPdfManager_requestLoadedStream(){return},onLoadedStream:function LocalPdfManager_onLoadedStream(){return this._loadedStreamCapability.promise},terminate:function LocalPdfManager_terminate(){return}});return LocalPdfManager}();var NetworkPdfManager=function NetworkPdfManagerClosure(){function NetworkPdfManager(docId,pdfNetworkStream,args,evaluatorOptions){this._docId=docId;this.msgHandler=args.msgHandler;this.evaluatorOptions=evaluatorOptions;var params={msgHandler:args.msgHandler,url:args.url,length:args.length,disableAutoFetch:args.disableAutoFetch,rangeChunkSize:args.rangeChunkSize};this.streamManager=new ChunkedStreamManager(pdfNetworkStream,params);this.pdfDocument=new PDFDocument(this,this.streamManager.getStream(),args.password)}Util.inherit(NetworkPdfManager,BasePdfManager,{ensure:function NetworkPdfManager_ensure(obj,prop,args){var pdfManager=this;return new Promise(function(resolve,reject){function ensureHelper(){try{var result;var value=obj[prop];if(typeof value==="function"){result=value.apply(obj,args)}else{result=value}resolve(result)}catch(e){if(!(e instanceof MissingDataException)){reject(e);return}pdfManager.streamManager.requestRange(e.begin,e.end).then(ensureHelper,reject)}}ensureHelper()})},requestRange:function NetworkPdfManager_requestRange(begin,end){return this.streamManager.requestRange(begin,end)},requestLoadedStream:function NetworkPdfManager_requestLoadedStream(){this.streamManager.requestAllChunks()},sendProgressiveData:function NetworkPdfManager_sendProgressiveData(chunk){this.streamManager.onReceiveData({chunk:chunk})},onLoadedStream:function NetworkPdfManager_onLoadedStream(){return this.streamManager.onLoadedStream()},terminate:function NetworkPdfManager_terminate(){this.streamManager.abort()}});return NetworkPdfManager}();exports.LocalPdfManager=LocalPdfManager;exports.NetworkPdfManager=NetworkPdfManager});(function(root,factory){{factory(root.pdfjsCoreWorker={},root.pdfjsSharedUtil,root.pdfjsCorePrimitives,root.pdfjsCorePdfManager)}})(this,function(exports,sharedUtil,corePrimitives,corePdfManager){var UNSUPPORTED_FEATURES=sharedUtil.UNSUPPORTED_FEATURES;var InvalidPDFException=sharedUtil.InvalidPDFException;var MessageHandler=sharedUtil.MessageHandler;var MissingPDFException=sharedUtil.MissingPDFException;var UnexpectedResponseException=sharedUtil.UnexpectedResponseException;var PasswordException=sharedUtil.PasswordException;var PasswordResponses=sharedUtil.PasswordResponses;var UnknownErrorException=sharedUtil.UnknownErrorException;var XRefParseException=sharedUtil.XRefParseException;var arrayByteLength=sharedUtil.arrayByteLength;var arraysToBytes=sharedUtil.arraysToBytes;var assert=sharedUtil.assert;var createPromiseCapability=sharedUtil.createPromiseCapability;var error=sharedUtil.error;var info=sharedUtil.info;var warn=sharedUtil.warn;var setVerbosityLevel=sharedUtil.setVerbosityLevel;var Ref=corePrimitives.Ref;var LocalPdfManager=corePdfManager.LocalPdfManager;var NetworkPdfManager=corePdfManager.NetworkPdfManager;var globalScope=sharedUtil.globalScope;var WorkerTask=function WorkerTaskClosure(){function WorkerTask(name){this.name=name;this.terminated=false;this._capability=createPromiseCapability()}WorkerTask.prototype={get finished(){return this._capability.promise},finish:function(){this._capability.resolve()},terminate:function(){this.terminated=true},ensureNotTerminated:function(){if(this.terminated){throw new Error("Worker task was terminated")}}};return WorkerTask}();var PDFWorkerStream=function PDFWorkerStreamClosure(){function PDFWorkerStream(params,msgHandler){this._queuedChunks=[];var initialData=params.initialData;if(initialData&&initialData.length>0){this._queuedChunks.push(initialData)}this._msgHandler=msgHandler;this._isRangeSupported=!params.disableRange;this._isStreamingSupported=!params.disableStream;this._contentLength=params.length;this._fullRequestReader=null;this._rangeReaders=[];msgHandler.on("OnDataRange",this._onReceiveData.bind(this));msgHandler.on("OnDataProgress",this._onProgress.bind(this))}PDFWorkerStream.prototype={_onReceiveData:function PDFWorkerStream_onReceiveData(args){if(args.begin===undefined){if(this._fullRequestReader){this._fullRequestReader._enqueue(args.chunk)}else{this._queuedChunks.push(args.chunk)}}else{var found=this._rangeReaders.some(function(rangeReader){if(rangeReader._begin!==args.begin){return false}rangeReader._enqueue(args.chunk);return true});assert(found)}},_onProgress:function PDFWorkerStream_onProgress(evt){if(this._rangeReaders.length>0){var firstReader=this._rangeReaders[0];if(firstReader.onProgress){firstReader.onProgress({loaded:evt.loaded})}}},_removeRangeReader:function PDFWorkerStream_removeRangeReader(reader){var i=this._rangeReaders.indexOf(reader);if(i>=0){this._rangeReaders.splice(i,1)}},getFullReader:function PDFWorkerStream_getFullReader(){assert(!this._fullRequestReader);var queuedChunks=this._queuedChunks;this._queuedChunks=null;return new PDFWorkerStreamReader(this,queuedChunks)},getRangeReader:function PDFWorkerStream_getRangeReader(begin,end){var reader=new PDFWorkerStreamRangeReader(this,begin,end);this._msgHandler.send("RequestDataRange",{begin:begin,end:end});this._rangeReaders.push(reader);return reader},cancelAllRequests:function PDFWorkerStream_cancelAllRequests(reason){if(this._fullRequestReader){this._fullRequestReader.cancel(reason)}var readers=this._rangeReaders.slice(0);readers.forEach(function(rangeReader){rangeReader.cancel(reason)})}};function PDFWorkerStreamReader(stream,queuedChunks){this._stream=stream;this._done=false;this._queuedChunks=queuedChunks||[];this._requests=[];this._headersReady=Promise.resolve();stream._fullRequestReader=this;this.onProgress=null}PDFWorkerStreamReader.prototype={_enqueue:function PDFWorkerStreamReader_enqueue(chunk){if(this._done){return}if(this._requests.length>0){var requestCapability=this._requests.shift();requestCapability.resolve({value:chunk,done:false});return}this._queuedChunks.push(chunk)},get headersReady(){return this._headersReady},get isRangeSupported(){return this._stream._isRangeSupported},get isStreamingSupported(){return this._stream._isStreamingSupported},get contentLength(){return this._stream._contentLength},read:function PDFWorkerStreamReader_read(){if(this._queuedChunks.length>0){var chunk=this._queuedChunks.shift();return Promise.resolve({value:chunk,done:false})}if(this._done){return Promise.resolve({value:undefined,done:true})}var requestCapability=createPromiseCapability();this._requests.push(requestCapability);return requestCapability.promise},cancel:function PDFWorkerStreamReader_cancel(reason){this._done=true;this._requests.forEach(function(requestCapability){requestCapability.resolve({value:undefined,done:true})});this._requests=[]}};function PDFWorkerStreamRangeReader(stream,begin,end){this._stream=stream;this._begin=begin;this._end=end;this._queuedChunk=null;this._requests=[];this._done=false;this.onProgress=null}PDFWorkerStreamRangeReader.prototype={_enqueue:function PDFWorkerStreamRangeReader_enqueue(chunk){if(this._done){return}if(this._requests.length===0){this._queuedChunk=chunk}else{var requestsCapability=this._requests.shift();requestsCapability.resolve({value:chunk,done:false});this._requests.forEach(function(requestCapability){requestCapability.resolve({value:undefined,done:true})});this._requests=[]}this._done=true;this._stream._removeRangeReader(this)},get isStreamingSupported(){return false},read:function PDFWorkerStreamRangeReader_read(){if(this._queuedChunk){return Promise.resolve({value:this._queuedChunk,done:false})}if(this._done){return Promise.resolve({value:undefined,done:true})}var requestCapability=createPromiseCapability();this._requests.push(requestCapability);return requestCapability.promise},cancel:function PDFWorkerStreamRangeReader_cancel(reason){this._done=true;this._requests.forEach(function(requestCapability){requestCapability.resolve({value:undefined,done:true})});this._requests=[];this._stream._removeRangeReader(this)}};return PDFWorkerStream}();var PDFNetworkStream;function setPDFNetworkStreamClass(cls){PDFNetworkStream=cls}var WorkerMessageHandler={setup:function wphSetup(handler,port){var testMessageProcessed=false;handler.on("test",function wphSetupTest(data){if(testMessageProcessed){return}testMessageProcessed=true;if(!(data instanceof Uint8Array)){handler.send("test","main",false);return}var supportTransfers=data[0]===255;handler.postMessageTransfers=supportTransfers;var xhr=new XMLHttpRequest;var responseExists="response"in xhr;try{var dummy=xhr.responseType}catch(e){responseExists=false}if(!responseExists){handler.send("test",false);return}handler.send("test",{supportTypedArray:true,supportTransfers:supportTransfers})});handler.on("configure",function wphConfigure(data){setVerbosityLevel(data.verbosity)});handler.on("GetDocRequest",function wphSetupDoc(data){return WorkerMessageHandler.createDocumentHandler(data,port)})},createDocumentHandler:function wphCreateDocumentHandler(docParams,port){var pdfManager;var terminated=false;var cancelXHRs=null;var WorkerTasks=[];var docId=docParams.docId;var workerHandlerName=docParams.docId+"_worker";var handler=new MessageHandler(workerHandlerName,docId,port);handler.postMessageTransfers=docParams.postMessageTransfers;function ensureNotTerminated(){if(terminated){throw new Error("Worker was terminated")}}function startWorkerTask(task){WorkerTasks.push(task)}function finishWorkerTask(task){task.finish();var i=WorkerTasks.indexOf(task);WorkerTasks.splice(i,1)}function loadDocument(recoveryMode){var loadDocumentCapability=createPromiseCapability();var parseSuccess=function parseSuccess(){var numPagesPromise=pdfManager.ensureDoc("numPages");var fingerprintPromise=pdfManager.ensureDoc("fingerprint");var encryptedPromise=pdfManager.ensureXRef("encrypt");Promise.all([numPagesPromise,fingerprintPromise,encryptedPromise]).then(function onDocReady(results){var doc={numPages:results[0],fingerprint:results[1],encrypted:!!results[2]};loadDocumentCapability.resolve(doc)},parseFailure)};var parseFailure=function parseFailure(e){loadDocumentCapability.reject(e)};pdfManager.ensureDoc("checkHeader",[]).then(function(){pdfManager.ensureDoc("parseStartXRef",[]).then(function(){pdfManager.ensureDoc("parse",[recoveryMode]).then(parseSuccess,parseFailure)},parseFailure)},parseFailure);return loadDocumentCapability.promise}function getPdfManager(data,evaluatorOptions){var pdfManagerCapability=createPromiseCapability();var pdfManager;var source=data.source;if(source.data){try{pdfManager=new LocalPdfManager(docId,source.data,source.password,evaluatorOptions);pdfManagerCapability.resolve(pdfManager)}catch(ex){pdfManagerCapability.reject(ex)}return pdfManagerCapability.promise}var pdfStream;try{if(source.chunkedViewerLoading){pdfStream=new PDFWorkerStream(source,handler)}else{assert(PDFNetworkStream,"pdfjs/core/network module is not loaded");pdfStream=new PDFNetworkStream(data)}}catch(ex){pdfManagerCapability.reject(ex);return pdfManagerCapability.promise}var fullRequest=pdfStream.getFullReader();fullRequest.headersReady.then(function(){if(!fullRequest.isStreamingSupported||!fullRequest.isRangeSupported){fullRequest.onProgress=function(evt){handler.send("DocProgress",{loaded:evt.loaded,total:evt.total})}}if(!fullRequest.isRangeSupported){return}var disableAutoFetch=source.disableAutoFetch||fullRequest.isStreamingSupported;pdfManager=new NetworkPdfManager(docId,pdfStream,{msgHandler:handler,url:source.url,password:source.password,length:fullRequest.contentLength,disableAutoFetch:disableAutoFetch,rangeChunkSize:source.rangeChunkSize},evaluatorOptions);pdfManagerCapability.resolve(pdfManager);cancelXHRs=null}).catch(function(reason){pdfManagerCapability.reject(reason);cancelXHRs=null});var cachedChunks=[],loaded=0;var flushChunks=function(){var pdfFile=arraysToBytes(cachedChunks);if(source.length&&pdfFile.length!==source.length){warn("reported HTTP length is different from actual")}try{pdfManager=new LocalPdfManager(docId,pdfFile,source.password,evaluatorOptions);pdfManagerCapability.resolve(pdfManager)}catch(ex){pdfManagerCapability.reject(ex)}cachedChunks=[]};var readPromise=new Promise(function(resolve,reject){var readChunk=function(chunk){try{ensureNotTerminated();if(chunk.done){if(!pdfManager){flushChunks()}cancelXHRs=null;return}var data=chunk.value;loaded+=arrayByteLength(data);if(!fullRequest.isStreamingSupported){handler.send("DocProgress",{loaded:loaded,total:Math.max(loaded,fullRequest.contentLength||0)})}if(pdfManager){pdfManager.sendProgressiveData(data)}else{cachedChunks.push(data)}fullRequest.read().then(readChunk,reject)}catch(e){reject(e)}};fullRequest.read().then(readChunk,reject)});readPromise.catch(function(e){pdfManagerCapability.reject(e);cancelXHRs=null});cancelXHRs=function(){pdfStream.cancelAllRequests("abort")};return pdfManagerCapability.promise}var setupDoc=function(data){var onSuccess=function(doc){ensureNotTerminated();handler.send("GetDoc",{pdfInfo:doc})};var onFailure=function(e){if(e instanceof PasswordException){if(e.code===PasswordResponses.NEED_PASSWORD){handler.send("NeedPassword",e)}else if(e.code===PasswordResponses.INCORRECT_PASSWORD){handler.send("IncorrectPassword",e)}}else if(e instanceof InvalidPDFException){handler.send("InvalidPDF",e)}else if(e instanceof MissingPDFException){handler.send("MissingPDF",e)}else if(e instanceof UnexpectedResponseException){handler.send("UnexpectedResponse",e)}else{handler.send("UnknownError",new UnknownErrorException(e.message,e.toString()))}};ensureNotTerminated();var cMapOptions={url:data.cMapUrl===undefined?null:data.cMapUrl,packed:data.cMapPacked===true};var evaluatorOptions={forceDataSchema:data.disableCreateObjectURL,maxImageSize:data.maxImageSize===undefined?-1:data.maxImageSize,disableFontFace:data.disableFontFace,cMapOptions:cMapOptions};getPdfManager(data,evaluatorOptions).then(function(newPdfManager){if(terminated){newPdfManager.terminate();throw new Error("Worker was terminated")}pdfManager=newPdfManager;handler.send("PDFManagerReady",null);pdfManager.onLoadedStream().then(function(stream){handler.send("DataLoaded",{length:stream.bytes.byteLength})})}).then(function pdfManagerReady(){ensureNotTerminated();loadDocument(false).then(onSuccess,function loadFailure(ex){ensureNotTerminated();if(!(ex instanceof XRefParseException)){if(ex instanceof PasswordException){pdfManager.passwordChanged().then(pdfManagerReady)}onFailure(ex);return}pdfManager.requestLoadedStream();pdfManager.onLoadedStream().then(function(){ensureNotTerminated();loadDocument(true).then(onSuccess,onFailure)})},onFailure)},onFailure)};handler.on("GetPage",function wphSetupGetPage(data){return pdfManager.getPage(data.pageIndex).then(function(page){var rotatePromise=pdfManager.ensure(page,"rotate");var refPromise=pdfManager.ensure(page,"ref");var viewPromise=pdfManager.ensure(page,"view");return Promise.all([rotatePromise,refPromise,viewPromise]).then(function(results){return{rotate:results[0],ref:results[1],view:results[2]}})})});handler.on("GetPageIndex",function wphSetupGetPageIndex(data){var ref=new Ref(data.ref.num,data.ref.gen);var catalog=pdfManager.pdfDocument.catalog;return catalog.getPageIndex(ref)});handler.on("GetDestinations",function wphSetupGetDestinations(data){return pdfManager.ensureCatalog("destinations")});handler.on("GetDestination",function wphSetupGetDestination(data){return pdfManager.ensureCatalog("getDestination",[data.id])});handler.on("GetPageLabels",function wphSetupGetPageLabels(data){return pdfManager.ensureCatalog("pageLabels")});handler.on("GetAttachments",function wphSetupGetAttachments(data){return pdfManager.ensureCatalog("attachments")});handler.on("GetJavaScript",function wphSetupGetJavaScript(data){return pdfManager.ensureCatalog("javaScript")});handler.on("GetOutline",function wphSetupGetOutline(data){return pdfManager.ensureCatalog("documentOutline")});handler.on("GetMetadata",function wphSetupGetMetadata(data){return Promise.all([pdfManager.ensureDoc("documentInfo"),pdfManager.ensureCatalog("metadata")])});handler.on("GetData",function wphSetupGetData(data){pdfManager.requestLoadedStream();return pdfManager.onLoadedStream().then(function(stream){return stream.bytes})});handler.on("GetStats",function wphSetupGetStats(data){return pdfManager.pdfDocument.xref.stats});handler.on("UpdatePassword",function wphSetupUpdatePassword(data){pdfManager.updatePassword(data)});handler.on("GetAnnotations",function wphSetupGetAnnotations(data){return pdfManager.getPage(data.pageIndex).then(function(page){return pdfManager.ensure(page,"getAnnotationsData",[data.intent])})});handler.on("RenderPageRequest",function wphSetupRenderPage(data){var pageIndex=data.pageIndex;pdfManager.getPage(pageIndex).then(function(page){var task=new WorkerTask("RenderPageRequest: page "+pageIndex);startWorkerTask(task);var pageNum=pageIndex+1;var start=Date.now();page.getOperatorList(handler,task,data.intent,data.renderInteractiveForms).then(function(operatorList){finishWorkerTask(task);info("page="+pageNum+" - getOperatorList: time="+(Date.now()-start)+"ms, len="+operatorList.totalLength)},function(e){finishWorkerTask(task);if(task.terminated){return}handler.send("UnsupportedFeature",{featureId:UNSUPPORTED_FEATURES.unknown});var minimumStackMessage="worker.js: while trying to getPage() and getOperatorList()";var wrappedException;if(typeof e==="string"){wrappedException={message:e,stack:minimumStackMessage}}else if(typeof e==="object"){wrappedException={message:e.message||e.toString(),stack:e.stack||minimumStackMessage}}else{wrappedException={message:"Unknown exception type: "+typeof e,stack:minimumStackMessage}}handler.send("PageError",{pageNum:pageNum,error:wrappedException,intent:data.intent})})})},this);handler.on("GetTextContent",function wphExtractText(data){var pageIndex=data.pageIndex;var normalizeWhitespace=data.normalizeWhitespace;var combineTextItems=data.combineTextItems;return pdfManager.getPage(pageIndex).then(function(page){var task=new WorkerTask("GetTextContent: page "+pageIndex);startWorkerTask(task);var pageNum=pageIndex+1;var start=Date.now();return page.extractTextContent(task,normalizeWhitespace,combineTextItems).then(function(textContent){finishWorkerTask(task);info("text indexing: page="+pageNum+" - time="+(Date.now()-start)+"ms");return textContent},function(reason){finishWorkerTask(task);if(task.terminated){return}throw reason})})});handler.on("Cleanup",function wphCleanup(data){return pdfManager.cleanup()});handler.on("Terminate",function wphTerminate(data){terminated=true;if(pdfManager){pdfManager.terminate();pdfManager=null}if(cancelXHRs){cancelXHRs()}var waitOn=[];WorkerTasks.forEach(function(task){waitOn.push(task.finished);task.terminate()});return Promise.all(waitOn).then(function(){handler.destroy();handler=null})});handler.on("Ready",function wphReady(data){setupDoc(docParams);docParams=null});return workerHandlerName}};function initializeWorker(){if(!("console"in globalScope)){var consoleTimer={};var workerConsole={log:function log(){var args=Array.prototype.slice.call(arguments);globalScope.postMessage({targetName:"main",action:"console_log",data:args})},error:function error(){var args=Array.prototype.slice.call(arguments);globalScope.postMessage({targetName:"main",action:"console_error",data:args});throw"pdf.js execution error"},time:function time(name){consoleTimer[name]=Date.now()},timeEnd:function timeEnd(name){var time=consoleTimer[name];if(!time){error("Unknown timer name "+name)}this.log("Timer:",name,Date.now()-time)}};globalScope.console=workerConsole}var handler=new MessageHandler("worker","main",self);WorkerMessageHandler.setup(handler,self);handler.send("ready",null)}if(typeof window==="undefined"&&!(typeof module!=="undefined"&&module.require)){initializeWorker()}exports.setPDFNetworkStreamClass=setPDFNetworkStreamClass;exports.WorkerTask=WorkerTask;exports.WorkerMessageHandler=WorkerMessageHandler});var NetworkManager=function NetworkManagerClosure(){var OK_RESPONSE=200;var PARTIAL_CONTENT_RESPONSE=206;function NetworkManager(url,args){this.url=url;args=args||{};this.isHttp=/^https?:/i.test(url);this.httpHeaders=this.isHttp&&args.httpHeaders||{};this.withCredentials=args.withCredentials||false;this.getXhr=args.getXhr||function NetworkManager_getXhr(){return new XMLHttpRequest};this.currXhrId=0;this.pendingRequests=Object.create(null);this.loadedRequests=Object.create(null)}function getArrayBuffer(xhr){var data=xhr.response;if(typeof data!=="string"){return data}var length=data.length;var array=new Uint8Array(length);for(var i=0;i<length;i++){array[i]=data.charCodeAt(i)&255}return array.buffer}var supportsMozChunked=function supportsMozChunkedClosure(){try{var x=new XMLHttpRequest;x.open("GET","https://example.com");x.responseType="moz-chunked-arraybuffer";return x.responseType==="moz-chunked-arraybuffer"}catch(e){return false}}();NetworkManager.prototype={requestRange:function NetworkManager_requestRange(begin,end,listeners){var args={begin:begin,end:end};for(var prop in listeners){args[prop]=listeners[prop]}return this.request(args)},requestFull:function NetworkManager_requestFull(listeners){return this.request(listeners)},request:function NetworkManager_request(args){var xhr=this.getXhr();var xhrId=this.currXhrId++;var pendingRequest=this.pendingRequests[xhrId]={xhr:xhr};xhr.open("GET",this.url);xhr.withCredentials=this.withCredentials;for(var property in this.httpHeaders){var value=this.httpHeaders[property];if(typeof value==="undefined"){continue}xhr.setRequestHeader(property,value)}if(this.isHttp&&"begin"in args&&"end"in args){var rangeStr=args.begin+"-"+(args.end-1);xhr.setRequestHeader("Range","bytes="+rangeStr);pendingRequest.expectedStatus=206}else{pendingRequest.expectedStatus=200}var useMozChunkedLoading=supportsMozChunked&&!!args.onProgressiveData;if(useMozChunkedLoading){xhr.responseType="moz-chunked-arraybuffer";pendingRequest.onProgressiveData=args.onProgressiveData;pendingRequest.mozChunked=true}else{xhr.responseType="arraybuffer"}if(args.onError){xhr.onerror=function(evt){args.onError(xhr.status)}}xhr.onreadystatechange=this.onStateChange.bind(this,xhrId);xhr.onprogress=this.onProgress.bind(this,xhrId);pendingRequest.onHeadersReceived=args.onHeadersReceived;pendingRequest.onDone=args.onDone;pendingRequest.onError=args.onError;pendingRequest.onProgress=args.onProgress;xhr.send(null);return xhrId},onProgress:function NetworkManager_onProgress(xhrId,evt){var pendingRequest=this.pendingRequests[xhrId];if(!pendingRequest){return}if(pendingRequest.mozChunked){var chunk=getArrayBuffer(pendingRequest.xhr);pendingRequest.onProgressiveData(chunk)}var onProgress=pendingRequest.onProgress;if(onProgress){onProgress(evt)}},onStateChange:function NetworkManager_onStateChange(xhrId,evt){var pendingRequest=this.pendingRequests[xhrId];if(!pendingRequest){return}var xhr=pendingRequest.xhr;if(xhr.readyState>=2&&pendingRequest.onHeadersReceived){pendingRequest.onHeadersReceived();delete pendingRequest.onHeadersReceived}if(xhr.readyState!==4){return}if(!(xhrId in this.pendingRequests)){return}delete this.pendingRequests[xhrId];if(xhr.status===0&&this.isHttp){if(pendingRequest.onError){pendingRequest.onError(xhr.status)}return}var xhrStatus=xhr.status||OK_RESPONSE;var ok_response_on_range_request=xhrStatus===OK_RESPONSE&&pendingRequest.expectedStatus===PARTIAL_CONTENT_RESPONSE;if(!ok_response_on_range_request&&xhrStatus!==pendingRequest.expectedStatus){if(pendingRequest.onError){pendingRequest.onError(xhr.status)}return}this.loadedRequests[xhrId]=true;var chunk=getArrayBuffer(xhr);if(xhrStatus===PARTIAL_CONTENT_RESPONSE){var rangeHeader=xhr.getResponseHeader("Content-Range");var matches=/bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);var begin=parseInt(matches[1],10);pendingRequest.onDone({begin:begin,chunk:chunk})}else if(pendingRequest.onProgressiveData){pendingRequest.onDone(null)}else if(chunk){pendingRequest.onDone({begin:0,chunk:chunk})}else if(pendingRequest.onError){pendingRequest.onError(xhr.status)}},hasPendingRequests:function NetworkManager_hasPendingRequests(){for(var xhrId in this.pendingRequests){return true}return false},getRequestXhr:function NetworkManager_getXhr(xhrId){return this.pendingRequests[xhrId].xhr},isStreamingRequest:function NetworkManager_isStreamingRequest(xhrId){return!!this.pendingRequests[xhrId].onProgressiveData},isPendingRequest:function NetworkManager_isPendingRequest(xhrId){return xhrId in this.pendingRequests},isLoadedRequest:function NetworkManager_isLoadedRequest(xhrId){return xhrId in this.loadedRequests},abortAllRequests:function NetworkManager_abortAllRequests(){for(var xhrId in this.pendingRequests){this.abortRequest(xhrId|0)}},abortRequest:function NetworkManager_abortRequest(xhrId){var xhr=this.pendingRequests[xhrId].xhr;delete this.pendingRequests[xhrId];xhr.abort()}};return NetworkManager}();(function(root,factory){{factory(root.pdfjsCoreNetwork={},root.pdfjsSharedUtil,root.pdfjsCoreWorker)}})(this,function(exports,sharedUtil,coreWorker){var assert=sharedUtil.assert;var createPromiseCapability=sharedUtil.createPromiseCapability;var isInt=sharedUtil.isInt;var MissingPDFException=sharedUtil.MissingPDFException;var UnexpectedResponseException=sharedUtil.UnexpectedResponseException;function PDFNetworkStream(options){this._options=options;var source=options.source;this._manager=new NetworkManager(source.url,{httpHeaders:source.httpHeaders,withCredentials:source.withCredentials});this._rangeChunkSize=source.rangeChunkSize;this._fullRequestReader=null;this._rangeRequestReaders=[]}PDFNetworkStream.prototype={_onRangeRequestReaderClosed:function PDFNetworkStream_onRangeRequestReaderClosed(reader){var i=this._rangeRequestReaders.indexOf(reader);if(i>=0){this._rangeRequestReaders.splice(i,1)}},getFullReader:function PDFNetworkStream_getFullReader(){assert(!this._fullRequestReader);this._fullRequestReader=new PDFNetworkStreamFullRequestReader(this._manager,this._options);return this._fullRequestReader},getRangeReader:function PDFNetworkStream_getRangeReader(begin,end){var reader=new PDFNetworkStreamRangeRequestReader(this._manager,begin,end);reader.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(reader);return reader},cancelAllRequests:function PDFNetworkStream_cancelAllRequests(reason){if(this._fullRequestReader){this._fullRequestReader.cancel(reason)}var readers=this._rangeRequestReaders.slice(0);readers.forEach(function(reader){reader.cancel(reason)})}};function PDFNetworkStreamFullRequestReader(manager,options){this._manager=manager;var source=options.source;var args={onHeadersReceived:this._onHeadersReceived.bind(this),onProgressiveData:source.disableStream?null:this._onProgressiveData.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=source.url;this._fullRequestId=manager.requestFull(args);this._headersReceivedCapability=createPromiseCapability();this._disableRange=options.disableRange||false;this._contentLength=source.length;this._rangeChunkSize=source.rangeChunkSize;if(!this._rangeChunkSize&&!this._disableRange){this._disableRange=true
28}this._isStreamingSupported=false;this._isRangeSupported=false;this._cachedChunks=[];this._requests=[];this._done=false;this._storedError=undefined;this.onProgress=null}PDFNetworkStreamFullRequestReader.prototype={_validateRangeRequestCapabilities:function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities(){if(this._disableRange){return false}var networkManager=this._manager;var fullRequestXhrId=this._fullRequestId;var fullRequestXhr=networkManager.getRequestXhr(fullRequestXhrId);if(fullRequestXhr.getResponseHeader("Accept-Ranges")!=="bytes"){return false}var contentEncoding=fullRequestXhr.getResponseHeader("Content-Encoding")||"identity";if(contentEncoding!=="identity"){return false}var length=fullRequestXhr.getResponseHeader("Content-Length");length=parseInt(length,10);if(!isInt(length)){return false}this._contentLength=length;if(length<=2*this._rangeChunkSize){return false}return true},_onHeadersReceived:function PDFNetworkStreamFullRequestReader_onHeadersReceived(){if(this._validateRangeRequestCapabilities()){this._isRangeSupported=true}var networkManager=this._manager;var fullRequestXhrId=this._fullRequestId;if(networkManager.isStreamingRequest(fullRequestXhrId)){this._isStreamingSupported=true}else if(this._isRangeSupported){networkManager.abortRequest(fullRequestXhrId)}this._headersReceivedCapability.resolve()},_onProgressiveData:function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk){if(this._requests.length>0){var requestCapability=this._requests.shift();requestCapability.resolve({value:chunk,done:false})}else{this._cachedChunks.push(chunk)}},_onDone:function PDFNetworkStreamFullRequestReader_onDone(args){if(args){this._onProgressiveData(args.chunk)}this._done=true;if(this._cachedChunks.length>0){return}this._requests.forEach(function(requestCapability){requestCapability.resolve({value:undefined,done:true})});this._requests=[]},_onError:function PDFNetworkStreamFullRequestReader_onError(status){var url=this._url;var exception;if(status===404||status===0&&/^file:/.test(url)){exception=new MissingPDFException('Missing PDF "'+url+'".')}else{exception=new UnexpectedResponseException("Unexpected server response ("+status+') while retrieving PDF "'+url+'".',status)}this._storedError=exception;this._headersReceivedCapability.reject(exception);this._requests.forEach(function(requestCapability){requestCapability.reject(exception)});this._requests=[];this._cachedChunks=[]},_onProgress:function PDFNetworkStreamFullRequestReader_onProgress(data){if(this.onProgress){this.onProgress({loaded:data.loaded,total:data.lengthComputable?data.total:this._contentLength})}},get isRangeSupported(){return this._isRangeSupported},get isStreamingSupported(){return this._isStreamingSupported},get contentLength(){return this._contentLength},get headersReady(){return this._headersReceivedCapability.promise},read:function PDFNetworkStreamFullRequestReader_read(){if(this._storedError){return Promise.reject(this._storedError)}if(this._cachedChunks.length>0){var chunk=this._cachedChunks.shift();return Promise.resolve(chunk)}if(this._done){return Promise.resolve({value:undefined,done:true})}var requestCapability=createPromiseCapability();this._requests.push(requestCapability);return requestCapability.promise},cancel:function PDFNetworkStreamFullRequestReader_cancel(reason){this._done=true;this._headersReceivedCapability.reject(reason);this._requests.forEach(function(requestCapability){requestCapability.resolve({value:undefined,done:true})});this._requests=[];if(this._manager.isPendingRequest(this._fullRequestId)){this._manager.abortRequest(this._fullRequestId)}this._fullRequestReader=null}};function PDFNetworkStreamRangeRequestReader(manager,begin,end){this._manager=manager;var args={onDone:this._onDone.bind(this),onProgress:this._onProgress.bind(this)};this._requestId=manager.requestRange(begin,end,args);this._requests=[];this._queuedChunk=null;this._done=false;this.onProgress=null;this.onClosed=null}PDFNetworkStreamRangeRequestReader.prototype={_close:function PDFNetworkStreamRangeRequestReader_close(){if(this.onClosed){this.onClosed(this)}},_onDone:function PDFNetworkStreamRangeRequestReader_onDone(data){var chunk=data.chunk;if(this._requests.length>0){var requestCapability=this._requests.shift();requestCapability.resolve({value:chunk,done:false})}else{this._queuedChunk=chunk}this._done=true;this._requests.forEach(function(requestCapability){requestCapability.resolve({value:undefined,done:true})});this._requests=[];this._close()},_onProgress:function PDFNetworkStreamRangeRequestReader_onProgress(evt){if(!this.isStreamingSupported&&this.onProgress){this.onProgress({loaded:evt.loaded})}},get isStreamingSupported(){return false},read:function PDFNetworkStreamRangeRequestReader_read(){if(this._queuedChunk!==null){var chunk=this._queuedChunk;this._queuedChunk=null;return Promise.resolve({value:chunk,done:false})}if(this._done){return Promise.resolve({value:undefined,done:true})}var requestCapability=createPromiseCapability();this._requests.push(requestCapability);return requestCapability.promise},cancel:function PDFNetworkStreamRangeRequestReader_cancel(reason){this._done=true;this._requests.forEach(function(requestCapability){requestCapability.resolve({value:undefined,done:true})});this._requests=[];if(this._manager.isPendingRequest(this._requestId)){this._manager.abortRequest(this._requestId)}this._close()}};coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);exports.PDFNetworkStream=PDFNetworkStream;exports.NetworkManager=NetworkManager})}).call(pdfjsLibs);exports.WorkerMessageHandler=pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler}); \ No newline at end of file
diff --git a/index.html.j2 b/index.html.j2
index c9cc38fd..40072005 100644
--- a/index.html.j2
+++ b/index.html.j2
@@ -139,6 +139,8 @@
139 </div> 139 </div>
140</div> 140</div>
141</div> 141</div>
142
143
142<div class="container"> 144<div class="container">
143 <div class="row"> 145 <div class="row">
144 <div class="col-lg-6"> 146 <div class="col-lg-6">
diff --git a/investors.html.j2 b/investors.html.j2
index 54d45f40..58e262cc 100644
--- a/investors.html.j2
+++ b/investors.html.j2
@@ -18,11 +18,10 @@
18</div> 18</div>
19 19
20 20
21 21<div class="container adorn_h3_bracket">
22<div class="container"> 22 <div class="row">
23<div class="row">
24 <div class="col-lg-4"> 23 <div class="col-lg-4">
25 <h2>{{ _("The Team") }}</h2> 24 <h3>{{ _("The Team") }}</h3>
26 25
27 <p>{{ _("Our team combines world-class business leaders, 26 <p>{{ _("Our team combines world-class business leaders,
28 cryptographers, software engineers, civil-rights 27 cryptographers, software engineers, civil-rights
@@ -35,7 +34,7 @@
35 automation, and the Renewable Freedom Foundation.") }}</p> 34 automation, and the Renewable Freedom Foundation.") }}</p>
36 </div> 35 </div>
37 <div class="col-lg-4"> 36 <div class="col-lg-4">
38 <h2>{{ _("The Technology") }}</h2> 37 <h3>{{ _("The Technology") }}</h3>
39 38
40 <p>{{ _("All transactions in Taler are secured using modern 39 <p>{{ _("All transactions in Taler are secured using modern
41 cryptography and trust in all parties is 40 cryptography and trust in all parties is
@@ -49,7 +48,7 @@
49 are fractions of a cent.") }}</p> 48 are fractions of a cent.") }}</p>
50 </div> 49 </div>
51 <div class="col-lg-4"> 50 <div class="col-lg-4">
52 <h2>{{ _("The Business") }}</h2> 51 <h3>{{ _("The Business") }}</h3>
53 52
54 <p>{{ _("The scalable business model for Taler is the operation 53 <p>{{ _("The scalable business model for Taler is the operation
55 of the payment service provider, which converts money from 54 of the payment service provider, which converts money from
@@ -63,39 +62,59 @@
63 merchant or both) to facilitate the transactions.") 62 merchant or both) to facilitate the transactions.")
64 }}</p> 63 }}</p>
65 </div> 64 </div>
65 </div>
66</div>
67
68
69<div class="contianer-fluid c_acronym">
70 <div class="container">
71 <h2>{{ _("The Business Case") }}</h2>
72 <div class="row">
73 <div class="col-lg-4">
74 <a href="{{ url('presentations/investors2017.pdf') }}"><img border=0 class="center-block" width=64 height=64 alt="PDF" src="{{ url('images/pdf.svg') }}"><br><p align="center">Download</p></a>
75
76 </div>
77 <div class="col-lg-4" id="canvas-left" style="display:none">
78 <canvas id="the-canvas-right"></canvas>
79 </div>
80 <div class="col-lg-4" id="canvas-right" style="display:none">
81 <canvas id="the-canvas-left"></canvas>
82 </div>
83 <script type="text/javascript" src="{{ url('dist/js/pdf.min.js') }}"></script>
84 <script type="text/javascript" src="{{ url('dist/js/pdf-view.js') }}"></script>
85 </div>
86 </div>
66</div> 87</div>
67<div class="col-lg-12"> 88
68 <h2 id="overview">{{ _("Taler as seen by the payment service operator") }}</h2> 89
69 90<div class="container">
70 <p>{{ _("The payment service operator runs a <em>Taler 91 <div class="row">
71 exchange</em>, which is a Web service portal that 92 <div class="col-lg-12">
72 keeps databases with transaction details and 93 <h2 id="overview">{{ _("Running a Taler payment service operator") }}</h2>
73 cryptographic proofs. Its operational expenses are 94
74 thus related to its interactions with the banking 95 <p>
75 system and the operation of the computing 96 {% trans %}
76 infrastructure, while its income is based on 97 The payment service operator runs the <em>Taler exchange</em>.
77 transaction fees it may charge for the various 98 The exchange charges <b>transaction fees</b> to customers or merchants.
78 interactions. Key interactions of the exchange 99 Its operational expenses are from wire transfers with the banking
79 include: ") }}</p> 100 system and the operation of the computing infrastructure.
101 {% endtrans %}
102 </p>
80 103
81 <p> 104 <p>
82 <img src="{{ url('images/exchange.svg') }}" alt="operator perspective" style="float: right; margin: 50px 5px 5px 5px;" width="50%"> 105 <ul>
83 </p><ul> 106 <li>{{ _("Cryptographic operations, bandwidth and storage costs are less than 0.01 cent per transaction.") }}</li>
84 <li>{{ _("Create a <b>reserve</b> based on an incoming
85 wire transfer from a customer.") }}</li>
86 107
87 <li>{{ _("Allow customers to withdraw (and refresh) 108 <li>{{ _("Multiple Taler transactions can be aggregated into larger wire transfers to merchants to minimize wire transfer costs.") }}</li>
88 digital coins from their reserve.") }}</li>
89 109
90 <li>{{ _("Accept and validate deposits from merchants.") }}</li> 110 <li>{{ _("Correct operation can be automatically assessed by verifying cryptographic proofs in the database.") }}</li>
91 111
92 <li>{{ _("Execute wire transfers to merchants in 112 <li>{{ _("Protocol allows the exchange to charge fees for any expensive operation (withdraw, deposit, refresh, refund or aggregated wire transfers).") }}</li>
93 response to validated deposits.") }}</li> 113
114 <li>{{ _("Financial risk is bounded even if keys are compromised.") }}</li>
94 115
95 <li>{{ _("Preserve and provide cryptographic proofs of
96 correct operation for audits by financial regulators.") }}</li>
97 </ul> 116 </ul>
98 <p></p> 117 </div>
99</div> 118 </div>
100</div> 119</div>
101{% endblock body_content %} 120{% endblock body_content %}
diff --git a/locale/de/LC_MESSAGES/messages.po b/locale/de/LC_MESSAGES/messages.po
index 56a07a34..53217eb5 100644
--- a/locale/de/LC_MESSAGES/messages.po
+++ b/locale/de/LC_MESSAGES/messages.po
@@ -3,16 +3,15 @@ msgid ""
3msgstr "" 3msgstr ""
4"Project-Id-Version: PROJECT VERSION\n" 4"Project-Id-Version: PROJECT VERSION\n"
5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
6"POT-Creation-Date: 2017-03-07 00:44+0100\n" 6"POT-Creation-Date: 2017-03-07 16:25+0100\n"
7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9"Language: de\n"
10"Language-Team: de <LL@li.org>\n" 9"Language-Team: de <LL@li.org>\n"
11"Plural-Forms: nplurals=2; plural=(n!=1)\n" 10"Plural-Forms: nplurals=2; plural=(n!=1)\n"
12"MIME-Version: 1.0\n" 11"MIME-Version: 1.0\n"
13"Content-Type: text/plain; charset=utf-8\n" 12"Content-Type: text/plain; charset=utf-8\n"
14"Content-Transfer-Encoding: 8bit\n" 13"Content-Transfer-Encoding: 8bit\n"
15"Generated-By: Babel 2.3.4\n" 14"Generated-By: Babel 1.3\n"
16 15
17#: about.html.j2:8 16#: about.html.j2:8
18msgid "" 17msgid ""
@@ -323,9 +322,10 @@ msgstr "Taler für Entwickler"
323msgid "Free" 322msgid "Free"
324msgstr "Frei" 323msgstr "Frei"
325 324
326#: developers.html.j2:14 325#: developers.html.j2:15
327msgid "" 326msgid ""
328"Taler is free software implementing an open\n" 327"\n"
328" Taler is free software implementing an open\n"
329" protocol. Anybody is welcome to inspect our code\n" 329" protocol. Anybody is welcome to inspect our code\n"
330" and integrate our reference implementation into\n" 330" and integrate our reference implementation into\n"
331" their applications. Different components of Taler\n" 331" their applications. Different components of Taler\n"
@@ -337,16 +337,18 @@ msgid ""
337" for wallets and related customer-facing software.\n" 337" for wallets and related customer-facing software.\n"
338" We are open for constructive suggestions for\n" 338" We are open for constructive suggestions for\n"
339" maximizing the adoption of this libre payment\n" 339" maximizing the adoption of this libre payment\n"
340" platform. " 340" platform.\n"
341" "
341msgstr "" 342msgstr ""
342 343
343#: developers.html.j2:30 344#: developers.html.j2:34
344msgid "RESTful" 345msgid "RESTful"
345msgstr "REST-basiert" 346msgstr "REST-basiert"
346 347
347#: developers.html.j2:32 348#: developers.html.j2:37
348msgid "" 349msgid ""
349"Taler is designed to work on the Internet. To\n" 350"\n"
351" Taler is designed to work on the Internet. To\n"
350" ensure that Taler payments can work with\n" 352" ensure that Taler payments can work with\n"
351" restrictive network setups, Taler uses a RESTful\n" 353" restrictive network setups, Taler uses a RESTful\n"
352" protocol over HTTP or HTTPS. Taler's security does\n" 354" protocol over HTTP or HTTPS. Taler's security does\n"
@@ -357,17 +359,18 @@ msgid ""
357" structure data, making it easy to integrate Taler\n" 359" structure data, making it easy to integrate Taler\n"
358" with existing Web applications. Taler's protocol\n" 360" with existing Web applications. Taler's protocol\n"
359" is documented in\n" 361" is documented in\n"
360" detail <a href='https://api.taler.net/'>here</a>.\n" 362" detail <a href=\"https://api.taler.net/\">here</a>.\n"
361" " 363" "
362msgstr "" 364msgstr ""
363 365
364#: developers.html.j2:54 366#: developers.html.j2:60
365msgid "Code" 367msgid "Code"
366msgstr "Code" 368msgstr "Code"
367 369
368#: developers.html.j2:56 370#: developers.html.j2:63
369msgid "" 371msgid ""
370"Taler is currently primarily developed by a\n" 372"\n"
373" Taler is currently primarily developed by a\n"
371" research team at Inria and GNUnet e.V. However,\n" 374" research team at Inria and GNUnet e.V. However,\n"
372" contributions from anyone are welcome. Our Git\n" 375" contributions from anyone are welcome. Our Git\n"
373" repositories can be cloned using the Git and HTTP\n" 376" repositories can be cloned using the Git and HTTP\n"
@@ -375,29 +378,31 @@ msgid ""
375" the name of the respective repository. A list of\n" 378" the name of the respective repository. A list of\n"
376" public repositories can be found in\n" 379" public repositories can be found in\n"
377" our <a href='https://git.taler.net/'>GitWeb</a>.\n" 380" our <a href='https://git.taler.net/'>GitWeb</a>.\n"
378" " 381" "
379msgstr "" 382msgstr ""
380 383
381#: developers.html.j2:68 384#: developers.html.j2:76
382msgid "Documentation" 385msgid "Documentation"
383msgstr "Dokumentation" 386msgstr "Dokumentation"
384 387
385#: developers.html.j2:70 388#: developers.html.j2:79
386msgid "" 389msgid ""
387"In addition to this website,\n" 390"\n"
388" the <a href='https://git.taler.net/'>documented\n" 391" In addition to this website,\n"
392" the <a href=\"https://git.taler.net/\">documented\n"
389" code</a> and\n" 393" code</a> and\n"
390" the <a href='https://api.taler.net/'>API\n" 394" the <a href=\"https://api.taler.net/\">API\n"
391" documentation</a>, we are in the process of\n" 395" documentation</a>, we are in the process of\n"
392" preparing a comprehensive design document which\n" 396" preparing a comprehensive design document which\n"
393" will be published here soon. " 397" will be published here soon.\n"
398" "
394msgstr "" 399msgstr ""
395 400
396#: developers.html.j2:79 401#: developers.html.j2:91
397msgid "Discussion" 402msgid "Discussion"
398msgstr "Diskussion" 403msgstr "Diskussion"
399 404
400#: developers.html.j2:81 405#: developers.html.j2:93
401msgid "" 406msgid ""
402"We have a mailinglist for developer discussions.\n" 407"We have a mailinglist for developer discussions.\n"
403" You can subscribe to it or read the list archive at\n" 408" You can subscribe to it or read the list archive at\n"
@@ -405,11 +410,11 @@ msgid ""
405"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>." 410"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>."
406msgstr "" 411msgstr ""
407 412
408#: developers.html.j2:88 413#: developers.html.j2:100
409msgid "Regression Testing" 414msgid "Regression Testing"
410msgstr "Regressionstests" 415msgstr "Regressionstests"
411 416
412#: developers.html.j2:90 417#: developers.html.j2:102
413msgid "" 418msgid ""
414"We have\n" 419"We have\n"
415" <a href='https://buildbot.net/'>Buildbot</a>\n" 420" <a href='https://buildbot.net/'>Buildbot</a>\n"
@@ -419,11 +424,11 @@ msgid ""
419" " 424" "
420msgstr "" 425msgstr ""
421 426
422#: developers.html.j2:98 427#: developers.html.j2:110
423msgid "Code Coverage Analysis" 428msgid "Code Coverage Analysis"
424msgstr "Testabdeckungsanalyse" 429msgstr "Testabdeckungsanalyse"
425 430
426#: developers.html.j2:100 431#: developers.html.j2:112
427msgid "" 432msgid ""
428"We use\n" 433"We use\n"
429" <a " 434" <a "
@@ -434,11 +439,11 @@ msgid ""
434" " 439" "
435msgstr "" 440msgstr ""
436 441
437#: developers.html.j2:108 442#: developers.html.j2:120
438msgid "Performance Analysis" 443msgid "Performance Analysis"
439msgstr "Performanzanalyse" 444msgstr "Performanzanalyse"
440 445
441#: developers.html.j2:110 446#: developers.html.j2:122
442msgid "" 447msgid ""
443"We\n" 448"We\n"
444" use <a href='https://gnunet.org/gauger'>Gauger</a>\n" 449" use <a href='https://gnunet.org/gauger'>Gauger</a>\n"
@@ -449,11 +454,11 @@ msgid ""
449" " 454" "
450msgstr "" 455msgstr ""
451 456
452#: developers.html.j2:124 457#: developers.html.j2:136
453msgid "Taler system overview" 458msgid "Taler system overview"
454msgstr "Das Taler-System im Überblick" 459msgstr "Das Taler-System im Überblick"
455 460
456#: developers.html.j2:126 461#: developers.html.j2:138
457msgid "" 462msgid ""
458"The Taler system consists of protocols executed among\n" 463"The Taler system consists of protocols executed among\n"
459" a number of actors with the help\n" 464" a number of actors with the help\n"
@@ -462,7 +467,7 @@ msgid ""
462" Typical transactions involve the following steps: " 467" Typical transactions involve the following steps: "
463msgstr "" 468msgstr ""
464 469
465#: developers.html.j2:135 470#: developers.html.j2:147
466msgid "" 471msgid ""
467"A customer instructs his <b>bank</b> to\n" 472"A customer instructs his <b>bank</b> to\n"
468" transfer funds from his account to the Taler\n" 473" transfer funds from his account to the Taler\n"
@@ -473,7 +478,7 @@ msgid ""
473" reserve at the exchange. " 478" reserve at the exchange. "
474msgstr "" 479msgstr ""
475 480
476#: developers.html.j2:143 481#: developers.html.j2:155
477msgid "" 482msgid ""
478"Once the exchange has received the wire\n" 483"Once the exchange has received the wire\n"
479" transfer, it allows the customer's electronic\n" 484" transfer, it allows the customer's electronic\n"
@@ -490,7 +495,7 @@ msgid ""
490" exchange may charge for the service). " 495" exchange may charge for the service). "
491msgstr "" 496msgstr ""
492 497
493#: developers.html.j2:158 498#: developers.html.j2:170
494msgid "" 499msgid ""
495"Once the customer has the digital coins in his\n" 500"Once the customer has the digital coins in his\n"
496" wallet, the wallet can be used to <b>spend</b>\n" 501" wallet, the wallet can be used to <b>spend</b>\n"
@@ -511,7 +516,7 @@ msgid ""
511" care of customers getting change). " 516" care of customers getting change). "
512msgstr "" 517msgstr ""
513 518
514#: developers.html.j2:176 519#: developers.html.j2:188
515msgid "" 520msgid ""
516"Merchants receiving digital\n" 521"Merchants receiving digital\n"
517" coins <b>deposit</b> the respective receipts\n" 522" coins <b>deposit</b> the respective receipts\n"
@@ -533,7 +538,7 @@ msgid ""
533" contracts). " 538" contracts). "
534msgstr "" 539msgstr ""
535 540
536#: developers.html.j2:195 541#: developers.html.j2:207
537msgid "" 542msgid ""
538"Finally, the exchange transfers funds\n" 543"Finally, the exchange transfers funds\n"
539" corresponding to the digital coins redeemed by\n" 544" corresponding to the digital coins redeemed by\n"
@@ -546,7 +551,7 @@ msgid ""
546" deposited. " 551" deposited. "
547msgstr "" 552msgstr ""
548 553
549#: developers.html.j2:205 554#: developers.html.j2:217
550msgid "" 555msgid ""
551"Most importantly, the exchange keeps\n" 556"Most importantly, the exchange keeps\n"
552" cryptographic proofs that allow it to\n" 557" cryptographic proofs that allow it to\n"
@@ -560,7 +565,7 @@ msgid ""
560" circulation. " 565" circulation. "
561msgstr "" 566msgstr ""
562 567
563#: developers.html.j2:216 568#: developers.html.j2:228
564msgid "" 569msgid ""
565"Without the auditor, the exchange operators\n" 570"Without the auditor, the exchange operators\n"
566" could embezzle funds they are holding in\n" 571" could embezzle funds they are holding in\n"
@@ -724,40 +729,43 @@ msgid ""
724msgstr "" 729msgstr ""
725 730
726#: governments.html.j2:116 731#: governments.html.j2:116
727msgid "Taler as seen by governments" 732msgid "Taler provides privacy and accountability"
728msgstr "Taler aus Regierungsperspektive" 733msgstr ""
729 734
730#: governments.html.j2:118 735#: governments.html.j2:118
731msgid "" 736msgid ""
732"Governments can observe traditional wire transfers\n" 737"Taler assumes governments can observe traditional wire transfers\n"
733" entering and leaving the Taler system, and require\n" 738" entering and leaving the Taler payment system. Starting with "
734" merchants and exchange operators to provide certain\n" 739"the\n"
735" information during financial audits. Exchange\n" 740" wire transfers, governments can obtain: "
736" operators are expected to be permanently checked by\n"
737" auditors, while merchants may be required to reveal\n"
738" information during regular tax audits. Information\n"
739" available to the government includes: "
740msgstr "" 741msgstr ""
741 742
742#: governments.html.j2:131 743#: governments.html.j2:123
743msgid "" 744msgid ""
744"From the banking system: The total amount of\n" 745"The total amount of digital currency withdrawn by a\n"
745" digital currency obtained by a customer. The\n" 746" customer. The government can impose limits on how much\n"
746" government could impose limits on how many\n" 747" digital cash a customer can withdraw within a\n"
747" digital coins a customer may withdraw within a\n"
748" given timeframe." 748" given timeframe."
749msgstr "" 749msgstr ""
750 750
751#: governments.html.j2:137 751#: governments.html.j2:128
752msgid "" 752msgid ""
753"From the banking system: The total amount of\n" 753"The income received by any merchant via the Taler\n"
754" income received by any merchant via the Taler\n"
755" system." 754" system."
756msgstr "" 755msgstr ""
757 756
758#: governments.html.j2:141 757#: governments.html.j2:131
759msgid "" 758msgid ""
760"From auditing the exchange: The amounts of\n" 759"The exact details of the underlying\n"
760" contract that was signed between customer and\n"
761" merchant. However, this information would\n"
762" typically not include the identity of the\n"
763" customer."
764msgstr ""
765
766#: governments.html.j2:137
767msgid ""
768"The amounts of\n"
761" digital coins legitimately withdrawn by\n" 769" digital coins legitimately withdrawn by\n"
762" customers from the exchange, the value of\n" 770" customers from the exchange, the value of\n"
763" non-redeemed digital coins in customer's\n" 771" non-redeemed digital coins in customer's\n"
@@ -767,22 +775,6 @@ msgid ""
767" the exchange from transaction fees." 775" the exchange from transaction fees."
768msgstr "" 776msgstr ""
769 777
770#: governments.html.j2:150
771msgid ""
772"From auditing merchants: For each deposit\n"
773" operation, the exact details of the underlying\n"
774" contract that was signed between customer and\n"
775" merchant. However, this information would\n"
776" typically not include the identity of the\n"
777" customer. Note that while the customer can\n"
778" decide to prove that it was his transaction\n"
779" (i.e. in court when suing the merchant if the\n"
780" merchant failed to deliver on the contract),\n"
781" merchant, exchange and government cannot find\n"
782" out the customer's identity from the information\n"
783" that Taler collects."
784msgstr ""
785
786#: index.html.j2:10 778#: index.html.j2:10
787msgid "Independent One-Click Payments!" 779msgid "Independent One-Click Payments!"
788msgstr "" 780msgstr ""
@@ -919,11 +911,11 @@ msgid ""
919" " 911" "
920msgstr "" 912msgstr ""
921 913
922#: index.html.j2:145 914#: index.html.j2:147
923msgid "Taler News" 915msgid "Taler News"
924msgstr "" 916msgstr ""
925 917
926#: index.html.j2:149 918#: index.html.j2:151
927msgid "Financial News" 919msgid "Financial News"
928msgstr "" 920msgstr ""
929 921
@@ -941,11 +933,11 @@ msgid ""
941" " 933" "
942msgstr "" 934msgstr ""
943 935
944#: investors.html.j2:25 936#: investors.html.j2:24
945msgid "The Team" 937msgid "The Team"
946msgstr "" 938msgstr ""
947 939
948#: investors.html.j2:27 940#: investors.html.j2:26
949msgid "" 941msgid ""
950"Our team combines world-class business leaders,\n" 942"Our team combines world-class business leaders,\n"
951" cryptographers, software engineers, civil-rights\n" 943" cryptographers, software engineers, civil-rights\n"
@@ -954,18 +946,18 @@ msgid ""
954" imposing this vision upon the world." 946" imposing this vision upon the world."
955msgstr "" 947msgstr ""
956 948
957#: investors.html.j2:33 949#: investors.html.j2:32
958msgid "" 950msgid ""
959"We are currently supported by Inria, the French\n" 951"We are currently supported by Inria, the French\n"
960" national institute for research in informatics and\n" 952" national institute for research in informatics and\n"
961" automation, and the Renewable Freedom Foundation." 953" automation, and the Renewable Freedom Foundation."
962msgstr "" 954msgstr ""
963 955
964#: investors.html.j2:38 956#: investors.html.j2:37
965msgid "The Technology" 957msgid "The Technology"
966msgstr "" 958msgstr ""
967 959
968#: investors.html.j2:40 960#: investors.html.j2:39
969msgid "" 961msgid ""
970"All transactions in Taler are secured using modern\n" 962"All transactions in Taler are secured using modern\n"
971" cryptography and trust in all parties is\n" 963" cryptography and trust in all parties is\n"
@@ -979,11 +971,11 @@ msgid ""
979" are fractions of a cent." 971" are fractions of a cent."
980msgstr "" 972msgstr ""
981 973
982#: investors.html.j2:52 974#: investors.html.j2:51
983msgid "The Business" 975msgid "The Business"
984msgstr "" 976msgstr ""
985 977
986#: investors.html.j2:54 978#: investors.html.j2:53
987msgid "" 979msgid ""
988"The scalable business model for Taler is the operation\n" 980"The scalable business model for Taler is the operation\n"
989" of the payment service provider, which converts money from\n" 981" of the payment service provider, which converts money from\n"
@@ -997,50 +989,51 @@ msgid ""
997" merchant or both) to facilitate the transactions." 989" merchant or both) to facilitate the transactions."
998msgstr "" 990msgstr ""
999 991
1000#: investors.html.j2:68 992#: investors.html.j2:71
1001msgid "Taler as seen by the payment service operator" 993msgid "The Business Case"
1002msgstr "" 994msgstr ""
1003 995
1004#: investors.html.j2:70 996#: investors.html.j2:93
1005msgid "" 997msgid "Running a Taler payment service operator"
1006"The payment service operator runs a <em>Taler\n"
1007" exchange</em>, which is a Web service portal that\n"
1008" keeps databases with transaction details and\n"
1009" cryptographic proofs. Its operational expenses are\n"
1010" thus related to its interactions with the banking\n"
1011" system and the operation of the computing\n"
1012" infrastructure, while its income is based on\n"
1013" transaction fees it may charge for the various\n"
1014" interactions. Key interactions of the exchange\n"
1015" include: "
1016msgstr "" 998msgstr ""
1017 999
1018#: investors.html.j2:84 1000#: investors.html.j2:96
1019msgid "" 1001msgid ""
1020"Create a <b>reserve</b> based on an incoming\n" 1002"\n"
1021" wire transfer from a customer." 1003" The payment service operator runs the <em>Taler exchange</em>.\n"
1004" The exchange charges <b>transaction fees</b> to customers or "
1005"merchants.\n"
1006" Its operational expenses are from wire transfers with the banking\n"
1007" system and the operation of the computing infrastructure.\n"
1008" "
1022msgstr "" 1009msgstr ""
1023 1010
1024#: investors.html.j2:87 1011#: investors.html.j2:106
1025msgid "" 1012msgid ""
1026"Allow customers to withdraw (and refresh)\n" 1013"Cryptographic operations, bandwidth and storage costs are less than 0.01 "
1027" digital coins from their reserve." 1014"cent per transaction."
1028msgstr "" 1015msgstr ""
1029 1016
1030#: investors.html.j2:90 1017#: investors.html.j2:108
1031msgid "Accept and validate deposits from merchants." 1018msgid ""
1032msgstr "Annahme und Validierung von Einzahlungen durch Händler." 1019"Multiple Taler transactions can be aggregated into larger wire transfers "
1020"to merchants to minimize wire transfer costs."
1021msgstr ""
1033 1022
1034#: investors.html.j2:92 1023#: investors.html.j2:110
1035msgid "" 1024msgid ""
1036"Execute wire transfers to merchants in\n" 1025"Correct operation can be automatically assessed by verifying "
1037" response to validated deposits." 1026"cryptographic proofs in the database."
1038msgstr "" 1027msgstr ""
1039 1028
1040#: investors.html.j2:95 1029#: investors.html.j2:112
1041msgid "" 1030msgid ""
1042"Preserve and provide cryptographic proofs of\n" 1031"Protocol allows the exchange to charge fees for any expensive operation "
1043" correct operation for audits by financial regulators." 1032"(withdraw, deposit, refresh, refund or aggregated wire transfers)."
1033msgstr ""
1034
1035#: investors.html.j2:114
1036msgid "Financial risk is bounded even if keys are compromised."
1044msgstr "" 1037msgstr ""
1045 1038
1046#: merchants.html.j2:5 1039#: merchants.html.j2:5
@@ -1343,3 +1336,30 @@ msgstr ""
1343#~ msgid "Open access (PSD2)" 1336#~ msgid "Open access (PSD2)"
1344#~ msgstr "" 1337#~ msgstr ""
1345 1338
1339#~ msgid "Taler as seen by governments"
1340#~ msgstr "Taler aus Regierungsperspektive"
1341
1342#~ msgid "Previous"
1343#~ msgstr ""
1344
1345#~ msgid "Next"
1346#~ msgstr ""
1347
1348#~ msgid "Accept and validate deposits from merchants."
1349#~ msgstr "Annahme und Validierung von Einzahlungen durch Händler."
1350
1351#~ msgid "Taler as seen by the payment service operator"
1352#~ msgstr ""
1353
1354#~ msgid ""
1355#~ "Cryptographic operations, bandwidth and "
1356#~ "storage are less than 0.01 cent "
1357#~ "per transaction."
1358#~ msgstr ""
1359
1360#~ msgid ""
1361#~ "Multiple Taler transactions are "
1362#~ "<b>aggregated</b> into larger wire transfers"
1363#~ " to merchants."
1364#~ msgstr ""
1365
diff --git a/locale/en/LC_MESSAGES/messages.po b/locale/en/LC_MESSAGES/messages.po
index 35ad1698..71410206 100644
--- a/locale/en/LC_MESSAGES/messages.po
+++ b/locale/en/LC_MESSAGES/messages.po
@@ -3,16 +3,15 @@ msgid ""
3msgstr "" 3msgstr ""
4"Project-Id-Version: PROJECT VERSION\n" 4"Project-Id-Version: PROJECT VERSION\n"
5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
6"POT-Creation-Date: 2017-03-07 00:44+0100\n" 6"POT-Creation-Date: 2017-03-07 16:25+0100\n"
7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9"Language: en\n"
10"Language-Team: en <LL@li.org>\n" 9"Language-Team: en <LL@li.org>\n"
11"Plural-Forms: nplurals=2; plural=(n!=1)\n" 10"Plural-Forms: nplurals=2; plural=(n!=1)\n"
12"MIME-Version: 1.0\n" 11"MIME-Version: 1.0\n"
13"Content-Type: text/plain; charset=utf-8\n" 12"Content-Type: text/plain; charset=utf-8\n"
14"Content-Transfer-Encoding: 8bit\n" 13"Content-Transfer-Encoding: 8bit\n"
15"Generated-By: Babel 2.3.4\n" 14"Generated-By: Babel 1.3\n"
16 15
17#: about.html.j2:8 16#: about.html.j2:8
18msgid "" 17msgid ""
@@ -315,9 +314,10 @@ msgstr ""
315msgid "Free" 314msgid "Free"
316msgstr "" 315msgstr ""
317 316
318#: developers.html.j2:14 317#: developers.html.j2:15
319msgid "" 318msgid ""
320"Taler is free software implementing an open\n" 319"\n"
320" Taler is free software implementing an open\n"
321" protocol. Anybody is welcome to inspect our code\n" 321" protocol. Anybody is welcome to inspect our code\n"
322" and integrate our reference implementation into\n" 322" and integrate our reference implementation into\n"
323" their applications. Different components of Taler\n" 323" their applications. Different components of Taler\n"
@@ -329,16 +329,18 @@ msgid ""
329" for wallets and related customer-facing software.\n" 329" for wallets and related customer-facing software.\n"
330" We are open for constructive suggestions for\n" 330" We are open for constructive suggestions for\n"
331" maximizing the adoption of this libre payment\n" 331" maximizing the adoption of this libre payment\n"
332" platform. " 332" platform.\n"
333" "
333msgstr "" 334msgstr ""
334 335
335#: developers.html.j2:30 336#: developers.html.j2:34
336msgid "RESTful" 337msgid "RESTful"
337msgstr "" 338msgstr ""
338 339
339#: developers.html.j2:32 340#: developers.html.j2:37
340msgid "" 341msgid ""
341"Taler is designed to work on the Internet. To\n" 342"\n"
343" Taler is designed to work on the Internet. To\n"
342" ensure that Taler payments can work with\n" 344" ensure that Taler payments can work with\n"
343" restrictive network setups, Taler uses a RESTful\n" 345" restrictive network setups, Taler uses a RESTful\n"
344" protocol over HTTP or HTTPS. Taler's security does\n" 346" protocol over HTTP or HTTPS. Taler's security does\n"
@@ -349,17 +351,18 @@ msgid ""
349" structure data, making it easy to integrate Taler\n" 351" structure data, making it easy to integrate Taler\n"
350" with existing Web applications. Taler's protocol\n" 352" with existing Web applications. Taler's protocol\n"
351" is documented in\n" 353" is documented in\n"
352" detail <a href='https://api.taler.net/'>here</a>.\n" 354" detail <a href=\"https://api.taler.net/\">here</a>.\n"
353" " 355" "
354msgstr "" 356msgstr ""
355 357
356#: developers.html.j2:54 358#: developers.html.j2:60
357msgid "Code" 359msgid "Code"
358msgstr "" 360msgstr ""
359 361
360#: developers.html.j2:56 362#: developers.html.j2:63
361msgid "" 363msgid ""
362"Taler is currently primarily developed by a\n" 364"\n"
365" Taler is currently primarily developed by a\n"
363" research team at Inria and GNUnet e.V. However,\n" 366" research team at Inria and GNUnet e.V. However,\n"
364" contributions from anyone are welcome. Our Git\n" 367" contributions from anyone are welcome. Our Git\n"
365" repositories can be cloned using the Git and HTTP\n" 368" repositories can be cloned using the Git and HTTP\n"
@@ -367,29 +370,31 @@ msgid ""
367" the name of the respective repository. A list of\n" 370" the name of the respective repository. A list of\n"
368" public repositories can be found in\n" 371" public repositories can be found in\n"
369" our <a href='https://git.taler.net/'>GitWeb</a>.\n" 372" our <a href='https://git.taler.net/'>GitWeb</a>.\n"
370" " 373" "
371msgstr "" 374msgstr ""
372 375
373#: developers.html.j2:68 376#: developers.html.j2:76
374msgid "Documentation" 377msgid "Documentation"
375msgstr "" 378msgstr ""
376 379
377#: developers.html.j2:70 380#: developers.html.j2:79
378msgid "" 381msgid ""
379"In addition to this website,\n" 382"\n"
380" the <a href='https://git.taler.net/'>documented\n" 383" In addition to this website,\n"
384" the <a href=\"https://git.taler.net/\">documented\n"
381" code</a> and\n" 385" code</a> and\n"
382" the <a href='https://api.taler.net/'>API\n" 386" the <a href=\"https://api.taler.net/\">API\n"
383" documentation</a>, we are in the process of\n" 387" documentation</a>, we are in the process of\n"
384" preparing a comprehensive design document which\n" 388" preparing a comprehensive design document which\n"
385" will be published here soon. " 389" will be published here soon.\n"
390" "
386msgstr "" 391msgstr ""
387 392
388#: developers.html.j2:79 393#: developers.html.j2:91
389msgid "Discussion" 394msgid "Discussion"
390msgstr "" 395msgstr ""
391 396
392#: developers.html.j2:81 397#: developers.html.j2:93
393msgid "" 398msgid ""
394"We have a mailinglist for developer discussions.\n" 399"We have a mailinglist for developer discussions.\n"
395" You can subscribe to it or read the list archive at\n" 400" You can subscribe to it or read the list archive at\n"
@@ -397,11 +402,11 @@ msgid ""
397"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>." 402"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>."
398msgstr "" 403msgstr ""
399 404
400#: developers.html.j2:88 405#: developers.html.j2:100
401msgid "Regression Testing" 406msgid "Regression Testing"
402msgstr "" 407msgstr ""
403 408
404#: developers.html.j2:90 409#: developers.html.j2:102
405msgid "" 410msgid ""
406"We have\n" 411"We have\n"
407" <a href='https://buildbot.net/'>Buildbot</a>\n" 412" <a href='https://buildbot.net/'>Buildbot</a>\n"
@@ -411,11 +416,11 @@ msgid ""
411" " 416" "
412msgstr "" 417msgstr ""
413 418
414#: developers.html.j2:98 419#: developers.html.j2:110
415msgid "Code Coverage Analysis" 420msgid "Code Coverage Analysis"
416msgstr "" 421msgstr ""
417 422
418#: developers.html.j2:100 423#: developers.html.j2:112
419msgid "" 424msgid ""
420"We use\n" 425"We use\n"
421" <a " 426" <a "
@@ -426,11 +431,11 @@ msgid ""
426" " 431" "
427msgstr "" 432msgstr ""
428 433
429#: developers.html.j2:108 434#: developers.html.j2:120
430msgid "Performance Analysis" 435msgid "Performance Analysis"
431msgstr "" 436msgstr ""
432 437
433#: developers.html.j2:110 438#: developers.html.j2:122
434msgid "" 439msgid ""
435"We\n" 440"We\n"
436" use <a href='https://gnunet.org/gauger'>Gauger</a>\n" 441" use <a href='https://gnunet.org/gauger'>Gauger</a>\n"
@@ -441,11 +446,11 @@ msgid ""
441" " 446" "
442msgstr "" 447msgstr ""
443 448
444#: developers.html.j2:124 449#: developers.html.j2:136
445msgid "Taler system overview" 450msgid "Taler system overview"
446msgstr "" 451msgstr ""
447 452
448#: developers.html.j2:126 453#: developers.html.j2:138
449msgid "" 454msgid ""
450"The Taler system consists of protocols executed among\n" 455"The Taler system consists of protocols executed among\n"
451" a number of actors with the help\n" 456" a number of actors with the help\n"
@@ -454,7 +459,7 @@ msgid ""
454" Typical transactions involve the following steps: " 459" Typical transactions involve the following steps: "
455msgstr "" 460msgstr ""
456 461
457#: developers.html.j2:135 462#: developers.html.j2:147
458msgid "" 463msgid ""
459"A customer instructs his <b>bank</b> to\n" 464"A customer instructs his <b>bank</b> to\n"
460" transfer funds from his account to the Taler\n" 465" transfer funds from his account to the Taler\n"
@@ -465,7 +470,7 @@ msgid ""
465" reserve at the exchange. " 470" reserve at the exchange. "
466msgstr "" 471msgstr ""
467 472
468#: developers.html.j2:143 473#: developers.html.j2:155
469msgid "" 474msgid ""
470"Once the exchange has received the wire\n" 475"Once the exchange has received the wire\n"
471" transfer, it allows the customer's electronic\n" 476" transfer, it allows the customer's electronic\n"
@@ -482,7 +487,7 @@ msgid ""
482" exchange may charge for the service). " 487" exchange may charge for the service). "
483msgstr "" 488msgstr ""
484 489
485#: developers.html.j2:158 490#: developers.html.j2:170
486msgid "" 491msgid ""
487"Once the customer has the digital coins in his\n" 492"Once the customer has the digital coins in his\n"
488" wallet, the wallet can be used to <b>spend</b>\n" 493" wallet, the wallet can be used to <b>spend</b>\n"
@@ -503,7 +508,7 @@ msgid ""
503" care of customers getting change). " 508" care of customers getting change). "
504msgstr "" 509msgstr ""
505 510
506#: developers.html.j2:176 511#: developers.html.j2:188
507msgid "" 512msgid ""
508"Merchants receiving digital\n" 513"Merchants receiving digital\n"
509" coins <b>deposit</b> the respective receipts\n" 514" coins <b>deposit</b> the respective receipts\n"
@@ -525,7 +530,7 @@ msgid ""
525" contracts). " 530" contracts). "
526msgstr "" 531msgstr ""
527 532
528#: developers.html.j2:195 533#: developers.html.j2:207
529msgid "" 534msgid ""
530"Finally, the exchange transfers funds\n" 535"Finally, the exchange transfers funds\n"
531" corresponding to the digital coins redeemed by\n" 536" corresponding to the digital coins redeemed by\n"
@@ -538,7 +543,7 @@ msgid ""
538" deposited. " 543" deposited. "
539msgstr "" 544msgstr ""
540 545
541#: developers.html.j2:205 546#: developers.html.j2:217
542msgid "" 547msgid ""
543"Most importantly, the exchange keeps\n" 548"Most importantly, the exchange keeps\n"
544" cryptographic proofs that allow it to\n" 549" cryptographic proofs that allow it to\n"
@@ -552,7 +557,7 @@ msgid ""
552" circulation. " 557" circulation. "
553msgstr "" 558msgstr ""
554 559
555#: developers.html.j2:216 560#: developers.html.j2:228
556msgid "" 561msgid ""
557"Without the auditor, the exchange operators\n" 562"Without the auditor, the exchange operators\n"
558" could embezzle funds they are holding in\n" 563" could embezzle funds they are holding in\n"
@@ -715,40 +720,43 @@ msgid ""
715msgstr "" 720msgstr ""
716 721
717#: governments.html.j2:116 722#: governments.html.j2:116
718msgid "Taler as seen by governments" 723msgid "Taler provides privacy and accountability"
719msgstr "" 724msgstr ""
720 725
721#: governments.html.j2:118 726#: governments.html.j2:118
722msgid "" 727msgid ""
723"Governments can observe traditional wire transfers\n" 728"Taler assumes governments can observe traditional wire transfers\n"
724" entering and leaving the Taler system, and require\n" 729" entering and leaving the Taler payment system. Starting with "
725" merchants and exchange operators to provide certain\n" 730"the\n"
726" information during financial audits. Exchange\n" 731" wire transfers, governments can obtain: "
727" operators are expected to be permanently checked by\n"
728" auditors, while merchants may be required to reveal\n"
729" information during regular tax audits. Information\n"
730" available to the government includes: "
731msgstr "" 732msgstr ""
732 733
733#: governments.html.j2:131 734#: governments.html.j2:123
734msgid "" 735msgid ""
735"From the banking system: The total amount of\n" 736"The total amount of digital currency withdrawn by a\n"
736" digital currency obtained by a customer. The\n" 737" customer. The government can impose limits on how much\n"
737" government could impose limits on how many\n" 738" digital cash a customer can withdraw within a\n"
738" digital coins a customer may withdraw within a\n"
739" given timeframe." 739" given timeframe."
740msgstr "" 740msgstr ""
741 741
742#: governments.html.j2:137 742#: governments.html.j2:128
743msgid "" 743msgid ""
744"From the banking system: The total amount of\n" 744"The income received by any merchant via the Taler\n"
745" income received by any merchant via the Taler\n"
746" system." 745" system."
747msgstr "" 746msgstr ""
748 747
749#: governments.html.j2:141 748#: governments.html.j2:131
750msgid "" 749msgid ""
751"From auditing the exchange: The amounts of\n" 750"The exact details of the underlying\n"
751" contract that was signed between customer and\n"
752" merchant. However, this information would\n"
753" typically not include the identity of the\n"
754" customer."
755msgstr ""
756
757#: governments.html.j2:137
758msgid ""
759"The amounts of\n"
752" digital coins legitimately withdrawn by\n" 760" digital coins legitimately withdrawn by\n"
753" customers from the exchange, the value of\n" 761" customers from the exchange, the value of\n"
754" non-redeemed digital coins in customer's\n" 762" non-redeemed digital coins in customer's\n"
@@ -758,22 +766,6 @@ msgid ""
758" the exchange from transaction fees." 766" the exchange from transaction fees."
759msgstr "" 767msgstr ""
760 768
761#: governments.html.j2:150
762msgid ""
763"From auditing merchants: For each deposit\n"
764" operation, the exact details of the underlying\n"
765" contract that was signed between customer and\n"
766" merchant. However, this information would\n"
767" typically not include the identity of the\n"
768" customer. Note that while the customer can\n"
769" decide to prove that it was his transaction\n"
770" (i.e. in court when suing the merchant if the\n"
771" merchant failed to deliver on the contract),\n"
772" merchant, exchange and government cannot find\n"
773" out the customer's identity from the information\n"
774" that Taler collects."
775msgstr ""
776
777#: index.html.j2:10 769#: index.html.j2:10
778msgid "Independent One-Click Payments!" 770msgid "Independent One-Click Payments!"
779msgstr "" 771msgstr ""
@@ -910,11 +902,11 @@ msgid ""
910" " 902" "
911msgstr "" 903msgstr ""
912 904
913#: index.html.j2:145 905#: index.html.j2:147
914msgid "Taler News" 906msgid "Taler News"
915msgstr "" 907msgstr ""
916 908
917#: index.html.j2:149 909#: index.html.j2:151
918msgid "Financial News" 910msgid "Financial News"
919msgstr "" 911msgstr ""
920 912
@@ -932,11 +924,11 @@ msgid ""
932" " 924" "
933msgstr "" 925msgstr ""
934 926
935#: investors.html.j2:25 927#: investors.html.j2:24
936msgid "The Team" 928msgid "The Team"
937msgstr "" 929msgstr ""
938 930
939#: investors.html.j2:27 931#: investors.html.j2:26
940msgid "" 932msgid ""
941"Our team combines world-class business leaders,\n" 933"Our team combines world-class business leaders,\n"
942" cryptographers, software engineers, civil-rights\n" 934" cryptographers, software engineers, civil-rights\n"
@@ -945,18 +937,18 @@ msgid ""
945" imposing this vision upon the world." 937" imposing this vision upon the world."
946msgstr "" 938msgstr ""
947 939
948#: investors.html.j2:33 940#: investors.html.j2:32
949msgid "" 941msgid ""
950"We are currently supported by Inria, the French\n" 942"We are currently supported by Inria, the French\n"
951" national institute for research in informatics and\n" 943" national institute for research in informatics and\n"
952" automation, and the Renewable Freedom Foundation." 944" automation, and the Renewable Freedom Foundation."
953msgstr "" 945msgstr ""
954 946
955#: investors.html.j2:38 947#: investors.html.j2:37
956msgid "The Technology" 948msgid "The Technology"
957msgstr "" 949msgstr ""
958 950
959#: investors.html.j2:40 951#: investors.html.j2:39
960msgid "" 952msgid ""
961"All transactions in Taler are secured using modern\n" 953"All transactions in Taler are secured using modern\n"
962" cryptography and trust in all parties is\n" 954" cryptography and trust in all parties is\n"
@@ -970,11 +962,11 @@ msgid ""
970" are fractions of a cent." 962" are fractions of a cent."
971msgstr "" 963msgstr ""
972 964
973#: investors.html.j2:52 965#: investors.html.j2:51
974msgid "The Business" 966msgid "The Business"
975msgstr "" 967msgstr ""
976 968
977#: investors.html.j2:54 969#: investors.html.j2:53
978msgid "" 970msgid ""
979"The scalable business model for Taler is the operation\n" 971"The scalable business model for Taler is the operation\n"
980" of the payment service provider, which converts money from\n" 972" of the payment service provider, which converts money from\n"
@@ -988,50 +980,51 @@ msgid ""
988" merchant or both) to facilitate the transactions." 980" merchant or both) to facilitate the transactions."
989msgstr "" 981msgstr ""
990 982
991#: investors.html.j2:68 983#: investors.html.j2:71
992msgid "Taler as seen by the payment service operator" 984msgid "The Business Case"
993msgstr "" 985msgstr ""
994 986
995#: investors.html.j2:70 987#: investors.html.j2:93
996msgid "" 988msgid "Running a Taler payment service operator"
997"The payment service operator runs a <em>Taler\n"
998" exchange</em>, which is a Web service portal that\n"
999" keeps databases with transaction details and\n"
1000" cryptographic proofs. Its operational expenses are\n"
1001" thus related to its interactions with the banking\n"
1002" system and the operation of the computing\n"
1003" infrastructure, while its income is based on\n"
1004" transaction fees it may charge for the various\n"
1005" interactions. Key interactions of the exchange\n"
1006" include: "
1007msgstr "" 989msgstr ""
1008 990
1009#: investors.html.j2:84 991#: investors.html.j2:96
1010msgid "" 992msgid ""
1011"Create a <b>reserve</b> based on an incoming\n" 993"\n"
1012" wire transfer from a customer." 994" The payment service operator runs the <em>Taler exchange</em>.\n"
995" The exchange charges <b>transaction fees</b> to customers or "
996"merchants.\n"
997" Its operational expenses are from wire transfers with the banking\n"
998" system and the operation of the computing infrastructure.\n"
999" "
1013msgstr "" 1000msgstr ""
1014 1001
1015#: investors.html.j2:87 1002#: investors.html.j2:106
1016msgid "" 1003msgid ""
1017"Allow customers to withdraw (and refresh)\n" 1004"Cryptographic operations, bandwidth and storage costs are less than 0.01 "
1018" digital coins from their reserve." 1005"cent per transaction."
1019msgstr "" 1006msgstr ""
1020 1007
1021#: investors.html.j2:90 1008#: investors.html.j2:108
1022msgid "Accept and validate deposits from merchants." 1009msgid ""
1010"Multiple Taler transactions can be aggregated into larger wire transfers "
1011"to merchants to minimize wire transfer costs."
1023msgstr "" 1012msgstr ""
1024 1013
1025#: investors.html.j2:92 1014#: investors.html.j2:110
1026msgid "" 1015msgid ""
1027"Execute wire transfers to merchants in\n" 1016"Correct operation can be automatically assessed by verifying "
1028" response to validated deposits." 1017"cryptographic proofs in the database."
1029msgstr "" 1018msgstr ""
1030 1019
1031#: investors.html.j2:95 1020#: investors.html.j2:112
1032msgid "" 1021msgid ""
1033"Preserve and provide cryptographic proofs of\n" 1022"Protocol allows the exchange to charge fees for any expensive operation "
1034" correct operation for audits by financial regulators." 1023"(withdraw, deposit, refresh, refund or aggregated wire transfers)."
1024msgstr ""
1025
1026#: investors.html.j2:114
1027msgid "Financial risk is bounded even if keys are compromised."
1035msgstr "" 1028msgstr ""
1036 1029
1037#: merchants.html.j2:5 1030#: merchants.html.j2:5
@@ -1337,3 +1330,30 @@ msgstr ""
1337#~ msgid "Open access (PSD2)" 1330#~ msgid "Open access (PSD2)"
1338#~ msgstr "" 1331#~ msgstr ""
1339 1332
1333#~ msgid "Taler as seen by governments"
1334#~ msgstr ""
1335
1336#~ msgid "Previous"
1337#~ msgstr ""
1338
1339#~ msgid "Next"
1340#~ msgstr ""
1341
1342#~ msgid "Accept and validate deposits from merchants."
1343#~ msgstr ""
1344
1345#~ msgid "Taler as seen by the payment service operator"
1346#~ msgstr ""
1347
1348#~ msgid ""
1349#~ "Cryptographic operations, bandwidth and "
1350#~ "storage are less than 0.01 cent "
1351#~ "per transaction."
1352#~ msgstr ""
1353
1354#~ msgid ""
1355#~ "Multiple Taler transactions are "
1356#~ "<b>aggregated</b> into larger wire transfers"
1357#~ " to merchants."
1358#~ msgstr ""
1359
diff --git a/locale/es/LC_MESSAGES/messages.po b/locale/es/LC_MESSAGES/messages.po
index d65c9039..c9e1e6c5 100644
--- a/locale/es/LC_MESSAGES/messages.po
+++ b/locale/es/LC_MESSAGES/messages.po
@@ -3,16 +3,15 @@ msgid ""
3msgstr "" 3msgstr ""
4"Project-Id-Version: PROJECT VERSION\n" 4"Project-Id-Version: PROJECT VERSION\n"
5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
6"POT-Creation-Date: 2017-03-07 00:44+0100\n" 6"POT-Creation-Date: 2017-03-07 16:25+0100\n"
7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9"Language: es\n"
10"Language-Team: es <LL@li.org>\n" 9"Language-Team: es <LL@li.org>\n"
11"Plural-Forms: nplurals=2; plural=(n!=1)\n" 10"Plural-Forms: nplurals=2; plural=(n!=1)\n"
12"MIME-Version: 1.0\n" 11"MIME-Version: 1.0\n"
13"Content-Type: text/plain; charset=utf-8\n" 12"Content-Type: text/plain; charset=utf-8\n"
14"Content-Transfer-Encoding: 8bit\n" 13"Content-Transfer-Encoding: 8bit\n"
15"Generated-By: Babel 2.3.4\n" 14"Generated-By: Babel 1.3\n"
16 15
17#: about.html.j2:8 16#: about.html.j2:8
18#, fuzzy 17#, fuzzy
@@ -333,9 +332,10 @@ msgstr "Taler para programadores"
333msgid "Free" 332msgid "Free"
334msgstr "Libre" 333msgstr "Libre"
335 334
336#: developers.html.j2:14 335#: developers.html.j2:15
337msgid "" 336msgid ""
338"Taler is free software implementing an open\n" 337"\n"
338" Taler is free software implementing an open\n"
339" protocol. Anybody is welcome to inspect our code\n" 339" protocol. Anybody is welcome to inspect our code\n"
340" and integrate our reference implementation into\n" 340" and integrate our reference implementation into\n"
341" their applications. Different components of Taler\n" 341" their applications. Different components of Taler\n"
@@ -347,16 +347,18 @@ msgid ""
347" for wallets and related customer-facing software.\n" 347" for wallets and related customer-facing software.\n"
348" We are open for constructive suggestions for\n" 348" We are open for constructive suggestions for\n"
349" maximizing the adoption of this libre payment\n" 349" maximizing the adoption of this libre payment\n"
350" platform. " 350" platform.\n"
351" "
351msgstr "" 352msgstr ""
352 353
353#: developers.html.j2:30 354#: developers.html.j2:34
354msgid "RESTful" 355msgid "RESTful"
355msgstr " Basado en REST" 356msgstr " Basado en REST"
356 357
357#: developers.html.j2:32 358#: developers.html.j2:37
358msgid "" 359msgid ""
359"Taler is designed to work on the Internet. To\n" 360"\n"
361" Taler is designed to work on the Internet. To\n"
360" ensure that Taler payments can work with\n" 362" ensure that Taler payments can work with\n"
361" restrictive network setups, Taler uses a RESTful\n" 363" restrictive network setups, Taler uses a RESTful\n"
362" protocol over HTTP or HTTPS. Taler's security does\n" 364" protocol over HTTP or HTTPS. Taler's security does\n"
@@ -367,17 +369,18 @@ msgid ""
367" structure data, making it easy to integrate Taler\n" 369" structure data, making it easy to integrate Taler\n"
368" with existing Web applications. Taler's protocol\n" 370" with existing Web applications. Taler's protocol\n"
369" is documented in\n" 371" is documented in\n"
370" detail <a href='https://api.taler.net/'>here</a>.\n" 372" detail <a href=\"https://api.taler.net/\">here</a>.\n"
371" " 373" "
372msgstr "" 374msgstr ""
373 375
374#: developers.html.j2:54 376#: developers.html.j2:60
375msgid "Code" 377msgid "Code"
376msgstr "Código" 378msgstr "Código"
377 379
378#: developers.html.j2:56 380#: developers.html.j2:63
379msgid "" 381msgid ""
380"Taler is currently primarily developed by a\n" 382"\n"
383" Taler is currently primarily developed by a\n"
381" research team at Inria and GNUnet e.V. However,\n" 384" research team at Inria and GNUnet e.V. However,\n"
382" contributions from anyone are welcome. Our Git\n" 385" contributions from anyone are welcome. Our Git\n"
383" repositories can be cloned using the Git and HTTP\n" 386" repositories can be cloned using the Git and HTTP\n"
@@ -385,29 +388,31 @@ msgid ""
385" the name of the respective repository. A list of\n" 388" the name of the respective repository. A list of\n"
386" public repositories can be found in\n" 389" public repositories can be found in\n"
387" our <a href='https://git.taler.net/'>GitWeb</a>.\n" 390" our <a href='https://git.taler.net/'>GitWeb</a>.\n"
388" " 391" "
389msgstr "" 392msgstr ""
390 393
391#: developers.html.j2:68 394#: developers.html.j2:76
392msgid "Documentation" 395msgid "Documentation"
393msgstr "Documentación" 396msgstr "Documentación"
394 397
395#: developers.html.j2:70 398#: developers.html.j2:79
396msgid "" 399msgid ""
397"In addition to this website,\n" 400"\n"
398" the <a href='https://git.taler.net/'>documented\n" 401" In addition to this website,\n"
402" the <a href=\"https://git.taler.net/\">documented\n"
399" code</a> and\n" 403" code</a> and\n"
400" the <a href='https://api.taler.net/'>API\n" 404" the <a href=\"https://api.taler.net/\">API\n"
401" documentation</a>, we are in the process of\n" 405" documentation</a>, we are in the process of\n"
402" preparing a comprehensive design document which\n" 406" preparing a comprehensive design document which\n"
403" will be published here soon. " 407" will be published here soon.\n"
408" "
404msgstr "" 409msgstr ""
405 410
406#: developers.html.j2:79 411#: developers.html.j2:91
407msgid "Discussion" 412msgid "Discussion"
408msgstr "Debates" 413msgstr "Debates"
409 414
410#: developers.html.j2:81 415#: developers.html.j2:93
411msgid "" 416msgid ""
412"We have a mailinglist for developer discussions.\n" 417"We have a mailinglist for developer discussions.\n"
413" You can subscribe to it or read the list archive at\n" 418" You can subscribe to it or read the list archive at\n"
@@ -415,11 +420,11 @@ msgid ""
415"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>." 420"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>."
416msgstr "" 421msgstr ""
417 422
418#: developers.html.j2:88 423#: developers.html.j2:100
419msgid "Regression Testing" 424msgid "Regression Testing"
420msgstr "Pruebas de regresión" 425msgstr "Pruebas de regresión"
421 426
422#: developers.html.j2:90 427#: developers.html.j2:102
423msgid "" 428msgid ""
424"We have\n" 429"We have\n"
425" <a href='https://buildbot.net/'>Buildbot</a>\n" 430" <a href='https://buildbot.net/'>Buildbot</a>\n"
@@ -429,11 +434,11 @@ msgid ""
429" " 434" "
430msgstr "" 435msgstr ""
431 436
432#: developers.html.j2:98 437#: developers.html.j2:110
433msgid "Code Coverage Analysis" 438msgid "Code Coverage Analysis"
434msgstr "Análisis de cobertura de código" 439msgstr "Análisis de cobertura de código"
435 440
436#: developers.html.j2:100 441#: developers.html.j2:112
437msgid "" 442msgid ""
438"We use\n" 443"We use\n"
439" <a " 444" <a "
@@ -444,11 +449,11 @@ msgid ""
444" " 449" "
445msgstr "" 450msgstr ""
446 451
447#: developers.html.j2:108 452#: developers.html.j2:120
448msgid "Performance Analysis" 453msgid "Performance Analysis"
449msgstr "Performance" 454msgstr "Performance"
450 455
451#: developers.html.j2:110 456#: developers.html.j2:122
452msgid "" 457msgid ""
453"We\n" 458"We\n"
454" use <a href='https://gnunet.org/gauger'>Gauger</a>\n" 459" use <a href='https://gnunet.org/gauger'>Gauger</a>\n"
@@ -459,11 +464,11 @@ msgid ""
459" " 464" "
460msgstr "" 465msgstr ""
461 466
462#: developers.html.j2:124 467#: developers.html.j2:136
463msgid "Taler system overview" 468msgid "Taler system overview"
464msgstr "Diagrama general del sistema Taler" 469msgstr "Diagrama general del sistema Taler"
465 470
466#: developers.html.j2:126 471#: developers.html.j2:138
467msgid "" 472msgid ""
468"The Taler system consists of protocols executed among\n" 473"The Taler system consists of protocols executed among\n"
469" a number of actors with the help\n" 474" a number of actors with the help\n"
@@ -472,7 +477,7 @@ msgid ""
472" Typical transactions involve the following steps: " 477" Typical transactions involve the following steps: "
473msgstr "" 478msgstr ""
474 479
475#: developers.html.j2:135 480#: developers.html.j2:147
476msgid "" 481msgid ""
477"A customer instructs his <b>bank</b> to\n" 482"A customer instructs his <b>bank</b> to\n"
478" transfer funds from his account to the Taler\n" 483" transfer funds from his account to the Taler\n"
@@ -483,7 +488,7 @@ msgid ""
483" reserve at the exchange. " 488" reserve at the exchange. "
484msgstr "" 489msgstr ""
485 490
486#: developers.html.j2:143 491#: developers.html.j2:155
487msgid "" 492msgid ""
488"Once the exchange has received the wire\n" 493"Once the exchange has received the wire\n"
489" transfer, it allows the customer's electronic\n" 494" transfer, it allows the customer's electronic\n"
@@ -500,7 +505,7 @@ msgid ""
500" exchange may charge for the service). " 505" exchange may charge for the service). "
501msgstr "" 506msgstr ""
502 507
503#: developers.html.j2:158 508#: developers.html.j2:170
504msgid "" 509msgid ""
505"Once the customer has the digital coins in his\n" 510"Once the customer has the digital coins in his\n"
506" wallet, the wallet can be used to <b>spend</b>\n" 511" wallet, the wallet can be used to <b>spend</b>\n"
@@ -521,7 +526,7 @@ msgid ""
521" care of customers getting change). " 526" care of customers getting change). "
522msgstr "" 527msgstr ""
523 528
524#: developers.html.j2:176 529#: developers.html.j2:188
525msgid "" 530msgid ""
526"Merchants receiving digital\n" 531"Merchants receiving digital\n"
527" coins <b>deposit</b> the respective receipts\n" 532" coins <b>deposit</b> the respective receipts\n"
@@ -543,7 +548,7 @@ msgid ""
543" contracts). " 548" contracts). "
544msgstr "" 549msgstr ""
545 550
546#: developers.html.j2:195 551#: developers.html.j2:207
547msgid "" 552msgid ""
548"Finally, the exchange transfers funds\n" 553"Finally, the exchange transfers funds\n"
549" corresponding to the digital coins redeemed by\n" 554" corresponding to the digital coins redeemed by\n"
@@ -556,7 +561,7 @@ msgid ""
556" deposited. " 561" deposited. "
557msgstr "" 562msgstr ""
558 563
559#: developers.html.j2:205 564#: developers.html.j2:217
560msgid "" 565msgid ""
561"Most importantly, the exchange keeps\n" 566"Most importantly, the exchange keeps\n"
562" cryptographic proofs that allow it to\n" 567" cryptographic proofs that allow it to\n"
@@ -570,7 +575,7 @@ msgid ""
570" circulation. " 575" circulation. "
571msgstr "" 576msgstr ""
572 577
573#: developers.html.j2:216 578#: developers.html.j2:228
574msgid "" 579msgid ""
575"Without the auditor, the exchange operators\n" 580"Without the auditor, the exchange operators\n"
576" could embezzle funds they are holding in\n" 581" could embezzle funds they are holding in\n"
@@ -733,40 +738,43 @@ msgid ""
733msgstr "" 738msgstr ""
734 739
735#: governments.html.j2:116 740#: governments.html.j2:116
736msgid "Taler as seen by governments" 741msgid "Taler provides privacy and accountability"
737msgstr "Taler desde el punto de vista del gobierno" 742msgstr ""
738 743
739#: governments.html.j2:118 744#: governments.html.j2:118
740msgid "" 745msgid ""
741"Governments can observe traditional wire transfers\n" 746"Taler assumes governments can observe traditional wire transfers\n"
742" entering and leaving the Taler system, and require\n" 747" entering and leaving the Taler payment system. Starting with "
743" merchants and exchange operators to provide certain\n" 748"the\n"
744" information during financial audits. Exchange\n" 749" wire transfers, governments can obtain: "
745" operators are expected to be permanently checked by\n"
746" auditors, while merchants may be required to reveal\n"
747" information during regular tax audits. Information\n"
748" available to the government includes: "
749msgstr "" 750msgstr ""
750 751
751#: governments.html.j2:131 752#: governments.html.j2:123
752msgid "" 753msgid ""
753"From the banking system: The total amount of\n" 754"The total amount of digital currency withdrawn by a\n"
754" digital currency obtained by a customer. The\n" 755" customer. The government can impose limits on how much\n"
755" government could impose limits on how many\n" 756" digital cash a customer can withdraw within a\n"
756" digital coins a customer may withdraw within a\n"
757" given timeframe." 757" given timeframe."
758msgstr "" 758msgstr ""
759 759
760#: governments.html.j2:137 760#: governments.html.j2:128
761msgid "" 761msgid ""
762"From the banking system: The total amount of\n" 762"The income received by any merchant via the Taler\n"
763" income received by any merchant via the Taler\n"
764" system." 763" system."
765msgstr "" 764msgstr ""
766 765
767#: governments.html.j2:141 766#: governments.html.j2:131
768msgid "" 767msgid ""
769"From auditing the exchange: The amounts of\n" 768"The exact details of the underlying\n"
769" contract that was signed between customer and\n"
770" merchant. However, this information would\n"
771" typically not include the identity of the\n"
772" customer."
773msgstr ""
774
775#: governments.html.j2:137
776msgid ""
777"The amounts of\n"
770" digital coins legitimately withdrawn by\n" 778" digital coins legitimately withdrawn by\n"
771" customers from the exchange, the value of\n" 779" customers from the exchange, the value of\n"
772" non-redeemed digital coins in customer's\n" 780" non-redeemed digital coins in customer's\n"
@@ -776,22 +784,6 @@ msgid ""
776" the exchange from transaction fees." 784" the exchange from transaction fees."
777msgstr "" 785msgstr ""
778 786
779#: governments.html.j2:150
780msgid ""
781"From auditing merchants: For each deposit\n"
782" operation, the exact details of the underlying\n"
783" contract that was signed between customer and\n"
784" merchant. However, this information would\n"
785" typically not include the identity of the\n"
786" customer. Note that while the customer can\n"
787" decide to prove that it was his transaction\n"
788" (i.e. in court when suing the merchant if the\n"
789" merchant failed to deliver on the contract),\n"
790" merchant, exchange and government cannot find\n"
791" out the customer's identity from the information\n"
792" that Taler collects."
793msgstr ""
794
795#: index.html.j2:10 787#: index.html.j2:10
796msgid "Independent One-Click Payments!" 788msgid "Independent One-Click Payments!"
797msgstr "" 789msgstr ""
@@ -928,11 +920,11 @@ msgid ""
928" " 920" "
929msgstr "" 921msgstr ""
930 922
931#: index.html.j2:145 923#: index.html.j2:147
932msgid "Taler News" 924msgid "Taler News"
933msgstr "" 925msgstr ""
934 926
935#: index.html.j2:149 927#: index.html.j2:151
936msgid "Financial News" 928msgid "Financial News"
937msgstr "" 929msgstr ""
938 930
@@ -950,11 +942,11 @@ msgid ""
950" " 942" "
951msgstr "" 943msgstr ""
952 944
953#: investors.html.j2:25 945#: investors.html.j2:24
954msgid "The Team" 946msgid "The Team"
955msgstr "" 947msgstr ""
956 948
957#: investors.html.j2:27 949#: investors.html.j2:26
958msgid "" 950msgid ""
959"Our team combines world-class business leaders,\n" 951"Our team combines world-class business leaders,\n"
960" cryptographers, software engineers, civil-rights\n" 952" cryptographers, software engineers, civil-rights\n"
@@ -963,18 +955,18 @@ msgid ""
963" imposing this vision upon the world." 955" imposing this vision upon the world."
964msgstr "" 956msgstr ""
965 957
966#: investors.html.j2:33 958#: investors.html.j2:32
967msgid "" 959msgid ""
968"We are currently supported by Inria, the French\n" 960"We are currently supported by Inria, the French\n"
969" national institute for research in informatics and\n" 961" national institute for research in informatics and\n"
970" automation, and the Renewable Freedom Foundation." 962" automation, and the Renewable Freedom Foundation."
971msgstr "" 963msgstr ""
972 964
973#: investors.html.j2:38 965#: investors.html.j2:37
974msgid "The Technology" 966msgid "The Technology"
975msgstr "" 967msgstr ""
976 968
977#: investors.html.j2:40 969#: investors.html.j2:39
978msgid "" 970msgid ""
979"All transactions in Taler are secured using modern\n" 971"All transactions in Taler are secured using modern\n"
980" cryptography and trust in all parties is\n" 972" cryptography and trust in all parties is\n"
@@ -988,11 +980,11 @@ msgid ""
988" are fractions of a cent." 980" are fractions of a cent."
989msgstr "" 981msgstr ""
990 982
991#: investors.html.j2:52 983#: investors.html.j2:51
992msgid "The Business" 984msgid "The Business"
993msgstr "" 985msgstr ""
994 986
995#: investors.html.j2:54 987#: investors.html.j2:53
996msgid "" 988msgid ""
997"The scalable business model for Taler is the operation\n" 989"The scalable business model for Taler is the operation\n"
998" of the payment service provider, which converts money from\n" 990" of the payment service provider, which converts money from\n"
@@ -1006,50 +998,51 @@ msgid ""
1006" merchant or both) to facilitate the transactions." 998" merchant or both) to facilitate the transactions."
1007msgstr "" 999msgstr ""
1008 1000
1009#: investors.html.j2:68 1001#: investors.html.j2:71
1010msgid "Taler as seen by the payment service operator" 1002msgid "The Business Case"
1011msgstr "" 1003msgstr ""
1012 1004
1013#: investors.html.j2:70 1005#: investors.html.j2:93
1014msgid "" 1006msgid "Running a Taler payment service operator"
1015"The payment service operator runs a <em>Taler\n"
1016" exchange</em>, which is a Web service portal that\n"
1017" keeps databases with transaction details and\n"
1018" cryptographic proofs. Its operational expenses are\n"
1019" thus related to its interactions with the banking\n"
1020" system and the operation of the computing\n"
1021" infrastructure, while its income is based on\n"
1022" transaction fees it may charge for the various\n"
1023" interactions. Key interactions of the exchange\n"
1024" include: "
1025msgstr "" 1007msgstr ""
1026 1008
1027#: investors.html.j2:84 1009#: investors.html.j2:96
1028msgid "" 1010msgid ""
1029"Create a <b>reserve</b> based on an incoming\n" 1011"\n"
1030" wire transfer from a customer." 1012" The payment service operator runs the <em>Taler exchange</em>.\n"
1013" The exchange charges <b>transaction fees</b> to customers or "
1014"merchants.\n"
1015" Its operational expenses are from wire transfers with the banking\n"
1016" system and the operation of the computing infrastructure.\n"
1017" "
1031msgstr "" 1018msgstr ""
1032 1019
1033#: investors.html.j2:87 1020#: investors.html.j2:106
1034msgid "" 1021msgid ""
1035"Allow customers to withdraw (and refresh)\n" 1022"Cryptographic operations, bandwidth and storage costs are less than 0.01 "
1036" digital coins from their reserve." 1023"cent per transaction."
1037msgstr "" 1024msgstr ""
1038 1025
1039#: investors.html.j2:90 1026#: investors.html.j2:108
1040msgid "Accept and validate deposits from merchants." 1027msgid ""
1041msgstr "Aceptar y validar depósitos de los comerciantes." 1028"Multiple Taler transactions can be aggregated into larger wire transfers "
1029"to merchants to minimize wire transfer costs."
1030msgstr ""
1042 1031
1043#: investors.html.j2:92 1032#: investors.html.j2:110
1044msgid "" 1033msgid ""
1045"Execute wire transfers to merchants in\n" 1034"Correct operation can be automatically assessed by verifying "
1046" response to validated deposits." 1035"cryptographic proofs in the database."
1047msgstr "" 1036msgstr ""
1048 1037
1049#: investors.html.j2:95 1038#: investors.html.j2:112
1050msgid "" 1039msgid ""
1051"Preserve and provide cryptographic proofs of\n" 1040"Protocol allows the exchange to charge fees for any expensive operation "
1052" correct operation for audits by financial regulators." 1041"(withdraw, deposit, refresh, refund or aggregated wire transfers)."
1042msgstr ""
1043
1044#: investors.html.j2:114
1045msgid "Financial risk is bounded even if keys are compromised."
1053msgstr "" 1046msgstr ""
1054 1047
1055#: merchants.html.j2:5 1048#: merchants.html.j2:5
@@ -1356,3 +1349,30 @@ msgstr ""
1356#~ msgid "Open access (PSD2)" 1349#~ msgid "Open access (PSD2)"
1357#~ msgstr "" 1350#~ msgstr ""
1358 1351
1352#~ msgid "Taler as seen by governments"
1353#~ msgstr "Taler desde el punto de vista del gobierno"
1354
1355#~ msgid "Previous"
1356#~ msgstr ""
1357
1358#~ msgid "Next"
1359#~ msgstr ""
1360
1361#~ msgid "Accept and validate deposits from merchants."
1362#~ msgstr "Aceptar y validar depósitos de los comerciantes."
1363
1364#~ msgid "Taler as seen by the payment service operator"
1365#~ msgstr ""
1366
1367#~ msgid ""
1368#~ "Cryptographic operations, bandwidth and "
1369#~ "storage are less than 0.01 cent "
1370#~ "per transaction."
1371#~ msgstr ""
1372
1373#~ msgid ""
1374#~ "Multiple Taler transactions are "
1375#~ "<b>aggregated</b> into larger wire transfers"
1376#~ " to merchants."
1377#~ msgstr ""
1378
diff --git a/locale/fr/LC_MESSAGES/messages.po b/locale/fr/LC_MESSAGES/messages.po
index 2ad2c2de..9739b248 100644
--- a/locale/fr/LC_MESSAGES/messages.po
+++ b/locale/fr/LC_MESSAGES/messages.po
@@ -3,16 +3,15 @@ msgid ""
3msgstr "" 3msgstr ""
4"Project-Id-Version: PROJECT VERSION\n" 4"Project-Id-Version: PROJECT VERSION\n"
5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
6"POT-Creation-Date: 2017-03-07 00:44+0100\n" 6"POT-Creation-Date: 2017-03-07 16:25+0100\n"
7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9"Language: fr\n"
10"Language-Team: fr <LL@li.org>\n" 9"Language-Team: fr <LL@li.org>\n"
11"Plural-Forms: nplurals=2; plural=(n!=1)\n" 10"Plural-Forms: nplurals=2; plural=(n!=1)\n"
12"MIME-Version: 1.0\n" 11"MIME-Version: 1.0\n"
13"Content-Type: text/plain; charset=utf-8\n" 12"Content-Type: text/plain; charset=utf-8\n"
14"Content-Transfer-Encoding: 8bit\n" 13"Content-Transfer-Encoding: 8bit\n"
15"Generated-By: Babel 2.3.4\n" 14"Generated-By: Babel 1.3\n"
16 15
17#: about.html.j2:8 16#: about.html.j2:8
18#, fuzzy 17#, fuzzy
@@ -331,9 +330,10 @@ msgstr "Taler pour les développeurs"
331msgid "Free" 330msgid "Free"
332msgstr "Libre" 331msgstr "Libre"
333 332
334#: developers.html.j2:14 333#: developers.html.j2:15
335msgid "" 334msgid ""
336"Taler is free software implementing an open\n" 335"\n"
336" Taler is free software implementing an open\n"
337" protocol. Anybody is welcome to inspect our code\n" 337" protocol. Anybody is welcome to inspect our code\n"
338" and integrate our reference implementation into\n" 338" and integrate our reference implementation into\n"
339" their applications. Different components of Taler\n" 339" their applications. Different components of Taler\n"
@@ -345,16 +345,18 @@ msgid ""
345" for wallets and related customer-facing software.\n" 345" for wallets and related customer-facing software.\n"
346" We are open for constructive suggestions for\n" 346" We are open for constructive suggestions for\n"
347" maximizing the adoption of this libre payment\n" 347" maximizing the adoption of this libre payment\n"
348" platform. " 348" platform.\n"
349" "
349msgstr "" 350msgstr ""
350 351
351#: developers.html.j2:30 352#: developers.html.j2:34
352msgid "RESTful" 353msgid "RESTful"
353msgstr "Avec REST" 354msgstr "Avec REST"
354 355
355#: developers.html.j2:32 356#: developers.html.j2:37
356msgid "" 357msgid ""
357"Taler is designed to work on the Internet. To\n" 358"\n"
359" Taler is designed to work on the Internet. To\n"
358" ensure that Taler payments can work with\n" 360" ensure that Taler payments can work with\n"
359" restrictive network setups, Taler uses a RESTful\n" 361" restrictive network setups, Taler uses a RESTful\n"
360" protocol over HTTP or HTTPS. Taler's security does\n" 362" protocol over HTTP or HTTPS. Taler's security does\n"
@@ -365,17 +367,18 @@ msgid ""
365" structure data, making it easy to integrate Taler\n" 367" structure data, making it easy to integrate Taler\n"
366" with existing Web applications. Taler's protocol\n" 368" with existing Web applications. Taler's protocol\n"
367" is documented in\n" 369" is documented in\n"
368" detail <a href='https://api.taler.net/'>here</a>.\n" 370" detail <a href=\"https://api.taler.net/\">here</a>.\n"
369" " 371" "
370msgstr "" 372msgstr ""
371 373
372#: developers.html.j2:54 374#: developers.html.j2:60
373msgid "Code" 375msgid "Code"
374msgstr "Code" 376msgstr "Code"
375 377
376#: developers.html.j2:56 378#: developers.html.j2:63
377msgid "" 379msgid ""
378"Taler is currently primarily developed by a\n" 380"\n"
381" Taler is currently primarily developed by a\n"
379" research team at Inria and GNUnet e.V. However,\n" 382" research team at Inria and GNUnet e.V. However,\n"
380" contributions from anyone are welcome. Our Git\n" 383" contributions from anyone are welcome. Our Git\n"
381" repositories can be cloned using the Git and HTTP\n" 384" repositories can be cloned using the Git and HTTP\n"
@@ -383,29 +386,31 @@ msgid ""
383" the name of the respective repository. A list of\n" 386" the name of the respective repository. A list of\n"
384" public repositories can be found in\n" 387" public repositories can be found in\n"
385" our <a href='https://git.taler.net/'>GitWeb</a>.\n" 388" our <a href='https://git.taler.net/'>GitWeb</a>.\n"
386" " 389" "
387msgstr "" 390msgstr ""
388 391
389#: developers.html.j2:68 392#: developers.html.j2:76
390msgid "Documentation" 393msgid "Documentation"
391msgstr "Documentation" 394msgstr "Documentation"
392 395
393#: developers.html.j2:70 396#: developers.html.j2:79
394msgid "" 397msgid ""
395"In addition to this website,\n" 398"\n"
396" the <a href='https://git.taler.net/'>documented\n" 399" In addition to this website,\n"
400" the <a href=\"https://git.taler.net/\">documented\n"
397" code</a> and\n" 401" code</a> and\n"
398" the <a href='https://api.taler.net/'>API\n" 402" the <a href=\"https://api.taler.net/\">API\n"
399" documentation</a>, we are in the process of\n" 403" documentation</a>, we are in the process of\n"
400" preparing a comprehensive design document which\n" 404" preparing a comprehensive design document which\n"
401" will be published here soon. " 405" will be published here soon.\n"
406" "
402msgstr "" 407msgstr ""
403 408
404#: developers.html.j2:79 409#: developers.html.j2:91
405msgid "Discussion" 410msgid "Discussion"
406msgstr "Discussion" 411msgstr "Discussion"
407 412
408#: developers.html.j2:81 413#: developers.html.j2:93
409msgid "" 414msgid ""
410"We have a mailinglist for developer discussions.\n" 415"We have a mailinglist for developer discussions.\n"
411" You can subscribe to it or read the list archive at\n" 416" You can subscribe to it or read the list archive at\n"
@@ -413,11 +418,11 @@ msgid ""
413"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>." 418"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>."
414msgstr "" 419msgstr ""
415 420
416#: developers.html.j2:88 421#: developers.html.j2:100
417msgid "Regression Testing" 422msgid "Regression Testing"
418msgstr "Tests de régression" 423msgstr "Tests de régression"
419 424
420#: developers.html.j2:90 425#: developers.html.j2:102
421msgid "" 426msgid ""
422"We have\n" 427"We have\n"
423" <a href='https://buildbot.net/'>Buildbot</a>\n" 428" <a href='https://buildbot.net/'>Buildbot</a>\n"
@@ -427,11 +432,11 @@ msgid ""
427" " 432" "
428msgstr "" 433msgstr ""
429 434
430#: developers.html.j2:98 435#: developers.html.j2:110
431msgid "Code Coverage Analysis" 436msgid "Code Coverage Analysis"
432msgstr "Mesure de couverture du code" 437msgstr "Mesure de couverture du code"
433 438
434#: developers.html.j2:100 439#: developers.html.j2:112
435msgid "" 440msgid ""
436"We use\n" 441"We use\n"
437" <a " 442" <a "
@@ -442,11 +447,11 @@ msgid ""
442" " 447" "
443msgstr "" 448msgstr ""
444 449
445#: developers.html.j2:108 450#: developers.html.j2:120
446msgid "Performance Analysis" 451msgid "Performance Analysis"
447msgstr "Analyse de performances" 452msgstr "Analyse de performances"
448 453
449#: developers.html.j2:110 454#: developers.html.j2:122
450msgid "" 455msgid ""
451"We\n" 456"We\n"
452" use <a href='https://gnunet.org/gauger'>Gauger</a>\n" 457" use <a href='https://gnunet.org/gauger'>Gauger</a>\n"
@@ -457,11 +462,11 @@ msgid ""
457" " 462" "
458msgstr "" 463msgstr ""
459 464
460#: developers.html.j2:124 465#: developers.html.j2:136
461msgid "Taler system overview" 466msgid "Taler system overview"
462msgstr "Vue d'ensemble de Taler" 467msgstr "Vue d'ensemble de Taler"
463 468
464#: developers.html.j2:126 469#: developers.html.j2:138
465msgid "" 470msgid ""
466"The Taler system consists of protocols executed among\n" 471"The Taler system consists of protocols executed among\n"
467" a number of actors with the help\n" 472" a number of actors with the help\n"
@@ -470,7 +475,7 @@ msgid ""
470" Typical transactions involve the following steps: " 475" Typical transactions involve the following steps: "
471msgstr "" 476msgstr ""
472 477
473#: developers.html.j2:135 478#: developers.html.j2:147
474msgid "" 479msgid ""
475"A customer instructs his <b>bank</b> to\n" 480"A customer instructs his <b>bank</b> to\n"
476" transfer funds from his account to the Taler\n" 481" transfer funds from his account to the Taler\n"
@@ -481,7 +486,7 @@ msgid ""
481" reserve at the exchange. " 486" reserve at the exchange. "
482msgstr "" 487msgstr ""
483 488
484#: developers.html.j2:143 489#: developers.html.j2:155
485msgid "" 490msgid ""
486"Once the exchange has received the wire\n" 491"Once the exchange has received the wire\n"
487" transfer, it allows the customer's electronic\n" 492" transfer, it allows the customer's electronic\n"
@@ -498,7 +503,7 @@ msgid ""
498" exchange may charge for the service). " 503" exchange may charge for the service). "
499msgstr "" 504msgstr ""
500 505
501#: developers.html.j2:158 506#: developers.html.j2:170
502msgid "" 507msgid ""
503"Once the customer has the digital coins in his\n" 508"Once the customer has the digital coins in his\n"
504" wallet, the wallet can be used to <b>spend</b>\n" 509" wallet, the wallet can be used to <b>spend</b>\n"
@@ -519,7 +524,7 @@ msgid ""
519" care of customers getting change). " 524" care of customers getting change). "
520msgstr "" 525msgstr ""
521 526
522#: developers.html.j2:176 527#: developers.html.j2:188
523msgid "" 528msgid ""
524"Merchants receiving digital\n" 529"Merchants receiving digital\n"
525" coins <b>deposit</b> the respective receipts\n" 530" coins <b>deposit</b> the respective receipts\n"
@@ -541,7 +546,7 @@ msgid ""
541" contracts). " 546" contracts). "
542msgstr "" 547msgstr ""
543 548
544#: developers.html.j2:195 549#: developers.html.j2:207
545msgid "" 550msgid ""
546"Finally, the exchange transfers funds\n" 551"Finally, the exchange transfers funds\n"
547" corresponding to the digital coins redeemed by\n" 552" corresponding to the digital coins redeemed by\n"
@@ -554,7 +559,7 @@ msgid ""
554" deposited. " 559" deposited. "
555msgstr "" 560msgstr ""
556 561
557#: developers.html.j2:205 562#: developers.html.j2:217
558msgid "" 563msgid ""
559"Most importantly, the exchange keeps\n" 564"Most importantly, the exchange keeps\n"
560" cryptographic proofs that allow it to\n" 565" cryptographic proofs that allow it to\n"
@@ -568,7 +573,7 @@ msgid ""
568" circulation. " 573" circulation. "
569msgstr "" 574msgstr ""
570 575
571#: developers.html.j2:216 576#: developers.html.j2:228
572msgid "" 577msgid ""
573"Without the auditor, the exchange operators\n" 578"Without the auditor, the exchange operators\n"
574" could embezzle funds they are holding in\n" 579" could embezzle funds they are holding in\n"
@@ -731,40 +736,43 @@ msgid ""
731msgstr "" 736msgstr ""
732 737
733#: governments.html.j2:116 738#: governments.html.j2:116
734msgid "Taler as seen by governments" 739msgid "Taler provides privacy and accountability"
735msgstr "Taler, du point de vu des gouvernements" 740msgstr ""
736 741
737#: governments.html.j2:118 742#: governments.html.j2:118
738msgid "" 743msgid ""
739"Governments can observe traditional wire transfers\n" 744"Taler assumes governments can observe traditional wire transfers\n"
740" entering and leaving the Taler system, and require\n" 745" entering and leaving the Taler payment system. Starting with "
741" merchants and exchange operators to provide certain\n" 746"the\n"
742" information during financial audits. Exchange\n" 747" wire transfers, governments can obtain: "
743" operators are expected to be permanently checked by\n"
744" auditors, while merchants may be required to reveal\n"
745" information during regular tax audits. Information\n"
746" available to the government includes: "
747msgstr "" 748msgstr ""
748 749
749#: governments.html.j2:131 750#: governments.html.j2:123
750msgid "" 751msgid ""
751"From the banking system: The total amount of\n" 752"The total amount of digital currency withdrawn by a\n"
752" digital currency obtained by a customer. The\n" 753" customer. The government can impose limits on how much\n"
753" government could impose limits on how many\n" 754" digital cash a customer can withdraw within a\n"
754" digital coins a customer may withdraw within a\n"
755" given timeframe." 755" given timeframe."
756msgstr "" 756msgstr ""
757 757
758#: governments.html.j2:137 758#: governments.html.j2:128
759msgid "" 759msgid ""
760"From the banking system: The total amount of\n" 760"The income received by any merchant via the Taler\n"
761" income received by any merchant via the Taler\n"
762" system." 761" system."
763msgstr "" 762msgstr ""
764 763
765#: governments.html.j2:141 764#: governments.html.j2:131
766msgid "" 765msgid ""
767"From auditing the exchange: The amounts of\n" 766"The exact details of the underlying\n"
767" contract that was signed between customer and\n"
768" merchant. However, this information would\n"
769" typically not include the identity of the\n"
770" customer."
771msgstr ""
772
773#: governments.html.j2:137
774msgid ""
775"The amounts of\n"
768" digital coins legitimately withdrawn by\n" 776" digital coins legitimately withdrawn by\n"
769" customers from the exchange, the value of\n" 777" customers from the exchange, the value of\n"
770" non-redeemed digital coins in customer's\n" 778" non-redeemed digital coins in customer's\n"
@@ -774,22 +782,6 @@ msgid ""
774" the exchange from transaction fees." 782" the exchange from transaction fees."
775msgstr "" 783msgstr ""
776 784
777#: governments.html.j2:150
778msgid ""
779"From auditing merchants: For each deposit\n"
780" operation, the exact details of the underlying\n"
781" contract that was signed between customer and\n"
782" merchant. However, this information would\n"
783" typically not include the identity of the\n"
784" customer. Note that while the customer can\n"
785" decide to prove that it was his transaction\n"
786" (i.e. in court when suing the merchant if the\n"
787" merchant failed to deliver on the contract),\n"
788" merchant, exchange and government cannot find\n"
789" out the customer's identity from the information\n"
790" that Taler collects."
791msgstr ""
792
793#: index.html.j2:10 785#: index.html.j2:10
794msgid "Independent One-Click Payments!" 786msgid "Independent One-Click Payments!"
795msgstr "" 787msgstr ""
@@ -926,11 +918,11 @@ msgid ""
926" " 918" "
927msgstr "" 919msgstr ""
928 920
929#: index.html.j2:145 921#: index.html.j2:147
930msgid "Taler News" 922msgid "Taler News"
931msgstr "" 923msgstr ""
932 924
933#: index.html.j2:149 925#: index.html.j2:151
934msgid "Financial News" 926msgid "Financial News"
935msgstr "" 927msgstr ""
936 928
@@ -948,11 +940,11 @@ msgid ""
948" " 940" "
949msgstr "" 941msgstr ""
950 942
951#: investors.html.j2:25 943#: investors.html.j2:24
952msgid "The Team" 944msgid "The Team"
953msgstr "" 945msgstr ""
954 946
955#: investors.html.j2:27 947#: investors.html.j2:26
956msgid "" 948msgid ""
957"Our team combines world-class business leaders,\n" 949"Our team combines world-class business leaders,\n"
958" cryptographers, software engineers, civil-rights\n" 950" cryptographers, software engineers, civil-rights\n"
@@ -961,18 +953,18 @@ msgid ""
961" imposing this vision upon the world." 953" imposing this vision upon the world."
962msgstr "" 954msgstr ""
963 955
964#: investors.html.j2:33 956#: investors.html.j2:32
965msgid "" 957msgid ""
966"We are currently supported by Inria, the French\n" 958"We are currently supported by Inria, the French\n"
967" national institute for research in informatics and\n" 959" national institute for research in informatics and\n"
968" automation, and the Renewable Freedom Foundation." 960" automation, and the Renewable Freedom Foundation."
969msgstr "" 961msgstr ""
970 962
971#: investors.html.j2:38 963#: investors.html.j2:37
972msgid "The Technology" 964msgid "The Technology"
973msgstr "" 965msgstr ""
974 966
975#: investors.html.j2:40 967#: investors.html.j2:39
976msgid "" 968msgid ""
977"All transactions in Taler are secured using modern\n" 969"All transactions in Taler are secured using modern\n"
978" cryptography and trust in all parties is\n" 970" cryptography and trust in all parties is\n"
@@ -986,11 +978,11 @@ msgid ""
986" are fractions of a cent." 978" are fractions of a cent."
987msgstr "" 979msgstr ""
988 980
989#: investors.html.j2:52 981#: investors.html.j2:51
990msgid "The Business" 982msgid "The Business"
991msgstr "" 983msgstr ""
992 984
993#: investors.html.j2:54 985#: investors.html.j2:53
994msgid "" 986msgid ""
995"The scalable business model for Taler is the operation\n" 987"The scalable business model for Taler is the operation\n"
996" of the payment service provider, which converts money from\n" 988" of the payment service provider, which converts money from\n"
@@ -1004,50 +996,51 @@ msgid ""
1004" merchant or both) to facilitate the transactions." 996" merchant or both) to facilitate the transactions."
1005msgstr "" 997msgstr ""
1006 998
1007#: investors.html.j2:68 999#: investors.html.j2:71
1008msgid "Taler as seen by the payment service operator" 1000msgid "The Business Case"
1009msgstr "" 1001msgstr ""
1010 1002
1011#: investors.html.j2:70 1003#: investors.html.j2:93
1012msgid "" 1004msgid "Running a Taler payment service operator"
1013"The payment service operator runs a <em>Taler\n"
1014" exchange</em>, which is a Web service portal that\n"
1015" keeps databases with transaction details and\n"
1016" cryptographic proofs. Its operational expenses are\n"
1017" thus related to its interactions with the banking\n"
1018" system and the operation of the computing\n"
1019" infrastructure, while its income is based on\n"
1020" transaction fees it may charge for the various\n"
1021" interactions. Key interactions of the exchange\n"
1022" include: "
1023msgstr "" 1005msgstr ""
1024 1006
1025#: investors.html.j2:84 1007#: investors.html.j2:96
1026msgid "" 1008msgid ""
1027"Create a <b>reserve</b> based on an incoming\n" 1009"\n"
1028" wire transfer from a customer." 1010" The payment service operator runs the <em>Taler exchange</em>.\n"
1011" The exchange charges <b>transaction fees</b> to customers or "
1012"merchants.\n"
1013" Its operational expenses are from wire transfers with the banking\n"
1014" system and the operation of the computing infrastructure.\n"
1015" "
1029msgstr "" 1016msgstr ""
1030 1017
1031#: investors.html.j2:87 1018#: investors.html.j2:106
1032msgid "" 1019msgid ""
1033"Allow customers to withdraw (and refresh)\n" 1020"Cryptographic operations, bandwidth and storage costs are less than 0.01 "
1034" digital coins from their reserve." 1021"cent per transaction."
1035msgstr "" 1022msgstr ""
1036 1023
1037#: investors.html.j2:90 1024#: investors.html.j2:108
1038msgid "Accept and validate deposits from merchants." 1025msgid ""
1039msgstr "Accepter et valider les dépos de marchands." 1026"Multiple Taler transactions can be aggregated into larger wire transfers "
1027"to merchants to minimize wire transfer costs."
1028msgstr ""
1040 1029
1041#: investors.html.j2:92 1030#: investors.html.j2:110
1042msgid "" 1031msgid ""
1043"Execute wire transfers to merchants in\n" 1032"Correct operation can be automatically assessed by verifying "
1044" response to validated deposits." 1033"cryptographic proofs in the database."
1045msgstr "" 1034msgstr ""
1046 1035
1047#: investors.html.j2:95 1036#: investors.html.j2:112
1048msgid "" 1037msgid ""
1049"Preserve and provide cryptographic proofs of\n" 1038"Protocol allows the exchange to charge fees for any expensive operation "
1050" correct operation for audits by financial regulators." 1039"(withdraw, deposit, refresh, refund or aggregated wire transfers)."
1040msgstr ""
1041
1042#: investors.html.j2:114
1043msgid "Financial risk is bounded even if keys are compromised."
1051msgstr "" 1044msgstr ""
1052 1045
1053#: merchants.html.j2:5 1046#: merchants.html.j2:5
@@ -1354,3 +1347,30 @@ msgstr ""
1354#~ msgid "Open access (PSD2)" 1347#~ msgid "Open access (PSD2)"
1355#~ msgstr "" 1348#~ msgstr ""
1356 1349
1350#~ msgid "Taler as seen by governments"
1351#~ msgstr "Taler, du point de vu des gouvernements"
1352
1353#~ msgid "Previous"
1354#~ msgstr ""
1355
1356#~ msgid "Next"
1357#~ msgstr ""
1358
1359#~ msgid "Accept and validate deposits from merchants."
1360#~ msgstr "Accepter et valider les dépos de marchands."
1361
1362#~ msgid "Taler as seen by the payment service operator"
1363#~ msgstr ""
1364
1365#~ msgid ""
1366#~ "Cryptographic operations, bandwidth and "
1367#~ "storage are less than 0.01 cent "
1368#~ "per transaction."
1369#~ msgstr ""
1370
1371#~ msgid ""
1372#~ "Multiple Taler transactions are "
1373#~ "<b>aggregated</b> into larger wire transfers"
1374#~ " to merchants."
1375#~ msgstr ""
1376
diff --git a/locale/it/LC_MESSAGES/messages.po b/locale/it/LC_MESSAGES/messages.po
index 3e952d61..3c81cb85 100644
--- a/locale/it/LC_MESSAGES/messages.po
+++ b/locale/it/LC_MESSAGES/messages.po
@@ -3,16 +3,15 @@ msgid ""
3msgstr "" 3msgstr ""
4"Project-Id-Version: PROJECT VERSION\n" 4"Project-Id-Version: PROJECT VERSION\n"
5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 5"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
6"POT-Creation-Date: 2017-03-07 00:44+0100\n" 6"POT-Creation-Date: 2017-03-07 16:25+0100\n"
7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 7"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 8"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
9"Language: it\n"
10"Language-Team: it <LL@li.org>\n" 9"Language-Team: it <LL@li.org>\n"
11"Plural-Forms: nplurals=2; plural=(n!=1)\n" 10"Plural-Forms: nplurals=2; plural=(n!=1)\n"
12"MIME-Version: 1.0\n" 11"MIME-Version: 1.0\n"
13"Content-Type: text/plain; charset=utf-8\n" 12"Content-Type: text/plain; charset=utf-8\n"
14"Content-Transfer-Encoding: 8bit\n" 13"Content-Transfer-Encoding: 8bit\n"
15"Generated-By: Babel 2.3.4\n" 14"Generated-By: Babel 1.3\n"
16 15
17#: about.html.j2:8 16#: about.html.j2:8
18#, fuzzy 17#, fuzzy
@@ -332,9 +331,10 @@ msgstr "Taler per programmatori"
332msgid "Free" 331msgid "Free"
333msgstr "Free" 332msgstr "Free"
334 333
335#: developers.html.j2:14 334#: developers.html.j2:15
336msgid "" 335msgid ""
337"Taler is free software implementing an open\n" 336"\n"
337" Taler is free software implementing an open\n"
338" protocol. Anybody is welcome to inspect our code\n" 338" protocol. Anybody is welcome to inspect our code\n"
339" and integrate our reference implementation into\n" 339" and integrate our reference implementation into\n"
340" their applications. Different components of Taler\n" 340" their applications. Different components of Taler\n"
@@ -346,16 +346,18 @@ msgid ""
346" for wallets and related customer-facing software.\n" 346" for wallets and related customer-facing software.\n"
347" We are open for constructive suggestions for\n" 347" We are open for constructive suggestions for\n"
348" maximizing the adoption of this libre payment\n" 348" maximizing the adoption of this libre payment\n"
349" platform. " 349" platform.\n"
350" "
350msgstr "" 351msgstr ""
351 352
352#: developers.html.j2:30 353#: developers.html.j2:34
353msgid "RESTful" 354msgid "RESTful"
354msgstr "RESTful" 355msgstr "RESTful"
355 356
356#: developers.html.j2:32 357#: developers.html.j2:37
357msgid "" 358msgid ""
358"Taler is designed to work on the Internet. To\n" 359"\n"
360" Taler is designed to work on the Internet. To\n"
359" ensure that Taler payments can work with\n" 361" ensure that Taler payments can work with\n"
360" restrictive network setups, Taler uses a RESTful\n" 362" restrictive network setups, Taler uses a RESTful\n"
361" protocol over HTTP or HTTPS. Taler's security does\n" 363" protocol over HTTP or HTTPS. Taler's security does\n"
@@ -366,17 +368,18 @@ msgid ""
366" structure data, making it easy to integrate Taler\n" 368" structure data, making it easy to integrate Taler\n"
367" with existing Web applications. Taler's protocol\n" 369" with existing Web applications. Taler's protocol\n"
368" is documented in\n" 370" is documented in\n"
369" detail <a href='https://api.taler.net/'>here</a>.\n" 371" detail <a href=\"https://api.taler.net/\">here</a>.\n"
370" " 372" "
371msgstr "" 373msgstr ""
372 374
373#: developers.html.j2:54 375#: developers.html.j2:60
374msgid "Code" 376msgid "Code"
375msgstr "Codice" 377msgstr "Codice"
376 378
377#: developers.html.j2:56 379#: developers.html.j2:63
378msgid "" 380msgid ""
379"Taler is currently primarily developed by a\n" 381"\n"
382" Taler is currently primarily developed by a\n"
380" research team at Inria and GNUnet e.V. However,\n" 383" research team at Inria and GNUnet e.V. However,\n"
381" contributions from anyone are welcome. Our Git\n" 384" contributions from anyone are welcome. Our Git\n"
382" repositories can be cloned using the Git and HTTP\n" 385" repositories can be cloned using the Git and HTTP\n"
@@ -384,29 +387,31 @@ msgid ""
384" the name of the respective repository. A list of\n" 387" the name of the respective repository. A list of\n"
385" public repositories can be found in\n" 388" public repositories can be found in\n"
386" our <a href='https://git.taler.net/'>GitWeb</a>.\n" 389" our <a href='https://git.taler.net/'>GitWeb</a>.\n"
387" " 390" "
388msgstr "" 391msgstr ""
389 392
390#: developers.html.j2:68 393#: developers.html.j2:76
391msgid "Documentation" 394msgid "Documentation"
392msgstr "Documentazione" 395msgstr "Documentazione"
393 396
394#: developers.html.j2:70 397#: developers.html.j2:79
395msgid "" 398msgid ""
396"In addition to this website,\n" 399"\n"
397" the <a href='https://git.taler.net/'>documented\n" 400" In addition to this website,\n"
401" the <a href=\"https://git.taler.net/\">documented\n"
398" code</a> and\n" 402" code</a> and\n"
399" the <a href='https://api.taler.net/'>API\n" 403" the <a href=\"https://api.taler.net/\">API\n"
400" documentation</a>, we are in the process of\n" 404" documentation</a>, we are in the process of\n"
401" preparing a comprehensive design document which\n" 405" preparing a comprehensive design document which\n"
402" will be published here soon. " 406" will be published here soon.\n"
407" "
403msgstr "" 408msgstr ""
404 409
405#: developers.html.j2:79 410#: developers.html.j2:91
406msgid "Discussion" 411msgid "Discussion"
407msgstr "Discussione" 412msgstr "Discussione"
408 413
409#: developers.html.j2:81 414#: developers.html.j2:93
410msgid "" 415msgid ""
411"We have a mailinglist for developer discussions.\n" 416"We have a mailinglist for developer discussions.\n"
412" You can subscribe to it or read the list archive at\n" 417" You can subscribe to it or read the list archive at\n"
@@ -414,11 +419,11 @@ msgid ""
414"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>." 419"href='http://lists.gnu.org/mailman/listinfo/taler'>http://lists.gnu.org/mailman/listinfo/taler</a>."
415msgstr "" 420msgstr ""
416 421
417#: developers.html.j2:88 422#: developers.html.j2:100
418msgid "Regression Testing" 423msgid "Regression Testing"
419msgstr "Test delle regressioni" 424msgstr "Test delle regressioni"
420 425
421#: developers.html.j2:90 426#: developers.html.j2:102
422msgid "" 427msgid ""
423"We have\n" 428"We have\n"
424" <a href='https://buildbot.net/'>Buildbot</a>\n" 429" <a href='https://buildbot.net/'>Buildbot</a>\n"
@@ -428,11 +433,11 @@ msgid ""
428" " 433" "
429msgstr "" 434msgstr ""
430 435
431#: developers.html.j2:98 436#: developers.html.j2:110
432msgid "Code Coverage Analysis" 437msgid "Code Coverage Analysis"
433msgstr "Analisi della copertura del codice" 438msgstr "Analisi della copertura del codice"
434 439
435#: developers.html.j2:100 440#: developers.html.j2:112
436msgid "" 441msgid ""
437"We use\n" 442"We use\n"
438" <a " 443" <a "
@@ -443,11 +448,11 @@ msgid ""
443" " 448" "
444msgstr "" 449msgstr ""
445 450
446#: developers.html.j2:108 451#: developers.html.j2:120
447msgid "Performance Analysis" 452msgid "Performance Analysis"
448msgstr "Analisi delle prestazioni" 453msgstr "Analisi delle prestazioni"
449 454
450#: developers.html.j2:110 455#: developers.html.j2:122
451msgid "" 456msgid ""
452"We\n" 457"We\n"
453" use <a href='https://gnunet.org/gauger'>Gauger</a>\n" 458" use <a href='https://gnunet.org/gauger'>Gauger</a>\n"
@@ -458,11 +463,11 @@ msgid ""
458" " 463" "
459msgstr "" 464msgstr ""
460 465
461#: developers.html.j2:124 466#: developers.html.j2:136
462msgid "Taler system overview" 467msgid "Taler system overview"
463msgstr "Schema generale del sistema Taler" 468msgstr "Schema generale del sistema Taler"
464 469
465#: developers.html.j2:126 470#: developers.html.j2:138
466msgid "" 471msgid ""
467"The Taler system consists of protocols executed among\n" 472"The Taler system consists of protocols executed among\n"
468" a number of actors with the help\n" 473" a number of actors with the help\n"
@@ -471,7 +476,7 @@ msgid ""
471" Typical transactions involve the following steps: " 476" Typical transactions involve the following steps: "
472msgstr "" 477msgstr ""
473 478
474#: developers.html.j2:135 479#: developers.html.j2:147
475msgid "" 480msgid ""
476"A customer instructs his <b>bank</b> to\n" 481"A customer instructs his <b>bank</b> to\n"
477" transfer funds from his account to the Taler\n" 482" transfer funds from his account to the Taler\n"
@@ -482,7 +487,7 @@ msgid ""
482" reserve at the exchange. " 487" reserve at the exchange. "
483msgstr "" 488msgstr ""
484 489
485#: developers.html.j2:143 490#: developers.html.j2:155
486msgid "" 491msgid ""
487"Once the exchange has received the wire\n" 492"Once the exchange has received the wire\n"
488" transfer, it allows the customer's electronic\n" 493" transfer, it allows the customer's electronic\n"
@@ -499,7 +504,7 @@ msgid ""
499" exchange may charge for the service). " 504" exchange may charge for the service). "
500msgstr "" 505msgstr ""
501 506
502#: developers.html.j2:158 507#: developers.html.j2:170
503msgid "" 508msgid ""
504"Once the customer has the digital coins in his\n" 509"Once the customer has the digital coins in his\n"
505" wallet, the wallet can be used to <b>spend</b>\n" 510" wallet, the wallet can be used to <b>spend</b>\n"
@@ -520,7 +525,7 @@ msgid ""
520" care of customers getting change). " 525" care of customers getting change). "
521msgstr "" 526msgstr ""
522 527
523#: developers.html.j2:176 528#: developers.html.j2:188
524msgid "" 529msgid ""
525"Merchants receiving digital\n" 530"Merchants receiving digital\n"
526" coins <b>deposit</b> the respective receipts\n" 531" coins <b>deposit</b> the respective receipts\n"
@@ -542,7 +547,7 @@ msgid ""
542" contracts). " 547" contracts). "
543msgstr "" 548msgstr ""
544 549
545#: developers.html.j2:195 550#: developers.html.j2:207
546msgid "" 551msgid ""
547"Finally, the exchange transfers funds\n" 552"Finally, the exchange transfers funds\n"
548" corresponding to the digital coins redeemed by\n" 553" corresponding to the digital coins redeemed by\n"
@@ -555,7 +560,7 @@ msgid ""
555" deposited. " 560" deposited. "
556msgstr "" 561msgstr ""
557 562
558#: developers.html.j2:205 563#: developers.html.j2:217
559msgid "" 564msgid ""
560"Most importantly, the exchange keeps\n" 565"Most importantly, the exchange keeps\n"
561" cryptographic proofs that allow it to\n" 566" cryptographic proofs that allow it to\n"
@@ -569,7 +574,7 @@ msgid ""
569" circulation. " 574" circulation. "
570msgstr "" 575msgstr ""
571 576
572#: developers.html.j2:216 577#: developers.html.j2:228
573msgid "" 578msgid ""
574"Without the auditor, the exchange operators\n" 579"Without the auditor, the exchange operators\n"
575" could embezzle funds they are holding in\n" 580" could embezzle funds they are holding in\n"
@@ -733,40 +738,43 @@ msgid ""
733msgstr "" 738msgstr ""
734 739
735#: governments.html.j2:116 740#: governments.html.j2:116
736msgid "Taler as seen by governments" 741msgid "Taler provides privacy and accountability"
737msgstr "Taler dal punto di vista dai governi" 742msgstr ""
738 743
739#: governments.html.j2:118 744#: governments.html.j2:118
740msgid "" 745msgid ""
741"Governments can observe traditional wire transfers\n" 746"Taler assumes governments can observe traditional wire transfers\n"
742" entering and leaving the Taler system, and require\n" 747" entering and leaving the Taler payment system. Starting with "
743" merchants and exchange operators to provide certain\n" 748"the\n"
744" information during financial audits. Exchange\n" 749" wire transfers, governments can obtain: "
745" operators are expected to be permanently checked by\n"
746" auditors, while merchants may be required to reveal\n"
747" information during regular tax audits. Information\n"
748" available to the government includes: "
749msgstr "" 750msgstr ""
750 751
751#: governments.html.j2:131 752#: governments.html.j2:123
752msgid "" 753msgid ""
753"From the banking system: The total amount of\n" 754"The total amount of digital currency withdrawn by a\n"
754" digital currency obtained by a customer. The\n" 755" customer. The government can impose limits on how much\n"
755" government could impose limits on how many\n" 756" digital cash a customer can withdraw within a\n"
756" digital coins a customer may withdraw within a\n"
757" given timeframe." 757" given timeframe."
758msgstr "" 758msgstr ""
759 759
760#: governments.html.j2:137 760#: governments.html.j2:128
761msgid "" 761msgid ""
762"From the banking system: The total amount of\n" 762"The income received by any merchant via the Taler\n"
763" income received by any merchant via the Taler\n"
764" system." 763" system."
765msgstr "" 764msgstr ""
766 765
767#: governments.html.j2:141 766#: governments.html.j2:131
768msgid "" 767msgid ""
769"From auditing the exchange: The amounts of\n" 768"The exact details of the underlying\n"
769" contract that was signed between customer and\n"
770" merchant. However, this information would\n"
771" typically not include the identity of the\n"
772" customer."
773msgstr ""
774
775#: governments.html.j2:137
776msgid ""
777"The amounts of\n"
770" digital coins legitimately withdrawn by\n" 778" digital coins legitimately withdrawn by\n"
771" customers from the exchange, the value of\n" 779" customers from the exchange, the value of\n"
772" non-redeemed digital coins in customer's\n" 780" non-redeemed digital coins in customer's\n"
@@ -776,22 +784,6 @@ msgid ""
776" the exchange from transaction fees." 784" the exchange from transaction fees."
777msgstr "" 785msgstr ""
778 786
779#: governments.html.j2:150
780msgid ""
781"From auditing merchants: For each deposit\n"
782" operation, the exact details of the underlying\n"
783" contract that was signed between customer and\n"
784" merchant. However, this information would\n"
785" typically not include the identity of the\n"
786" customer. Note that while the customer can\n"
787" decide to prove that it was his transaction\n"
788" (i.e. in court when suing the merchant if the\n"
789" merchant failed to deliver on the contract),\n"
790" merchant, exchange and government cannot find\n"
791" out the customer's identity from the information\n"
792" that Taler collects."
793msgstr ""
794
795#: index.html.j2:10 787#: index.html.j2:10
796msgid "Independent One-Click Payments!" 788msgid "Independent One-Click Payments!"
797msgstr "" 789msgstr ""
@@ -928,11 +920,11 @@ msgid ""
928" " 920" "
929msgstr "" 921msgstr ""
930 922
931#: index.html.j2:145 923#: index.html.j2:147
932msgid "Taler News" 924msgid "Taler News"
933msgstr "" 925msgstr ""
934 926
935#: index.html.j2:149 927#: index.html.j2:151
936msgid "Financial News" 928msgid "Financial News"
937msgstr "" 929msgstr ""
938 930
@@ -950,11 +942,11 @@ msgid ""
950" " 942" "
951msgstr "" 943msgstr ""
952 944
953#: investors.html.j2:25 945#: investors.html.j2:24
954msgid "The Team" 946msgid "The Team"
955msgstr "" 947msgstr ""
956 948
957#: investors.html.j2:27 949#: investors.html.j2:26
958msgid "" 950msgid ""
959"Our team combines world-class business leaders,\n" 951"Our team combines world-class business leaders,\n"
960" cryptographers, software engineers, civil-rights\n" 952" cryptographers, software engineers, civil-rights\n"
@@ -963,18 +955,18 @@ msgid ""
963" imposing this vision upon the world." 955" imposing this vision upon the world."
964msgstr "" 956msgstr ""
965 957
966#: investors.html.j2:33 958#: investors.html.j2:32
967msgid "" 959msgid ""
968"We are currently supported by Inria, the French\n" 960"We are currently supported by Inria, the French\n"
969" national institute for research in informatics and\n" 961" national institute for research in informatics and\n"
970" automation, and the Renewable Freedom Foundation." 962" automation, and the Renewable Freedom Foundation."
971msgstr "" 963msgstr ""
972 964
973#: investors.html.j2:38 965#: investors.html.j2:37
974msgid "The Technology" 966msgid "The Technology"
975msgstr "" 967msgstr ""
976 968
977#: investors.html.j2:40 969#: investors.html.j2:39
978msgid "" 970msgid ""
979"All transactions in Taler are secured using modern\n" 971"All transactions in Taler are secured using modern\n"
980" cryptography and trust in all parties is\n" 972" cryptography and trust in all parties is\n"
@@ -988,11 +980,11 @@ msgid ""
988" are fractions of a cent." 980" are fractions of a cent."
989msgstr "" 981msgstr ""
990 982
991#: investors.html.j2:52 983#: investors.html.j2:51
992msgid "The Business" 984msgid "The Business"
993msgstr "" 985msgstr ""
994 986
995#: investors.html.j2:54 987#: investors.html.j2:53
996msgid "" 988msgid ""
997"The scalable business model for Taler is the operation\n" 989"The scalable business model for Taler is the operation\n"
998" of the payment service provider, which converts money from\n" 990" of the payment service provider, which converts money from\n"
@@ -1006,52 +998,51 @@ msgid ""
1006" merchant or both) to facilitate the transactions." 998" merchant or both) to facilitate the transactions."
1007msgstr "" 999msgstr ""
1008 1000
1009#: investors.html.j2:68 1001#: investors.html.j2:71
1010msgid "Taler as seen by the payment service operator" 1002msgid "The Business Case"
1011msgstr "" 1003msgstr ""
1012 1004
1013#: investors.html.j2:70 1005#: investors.html.j2:93
1014msgid "" 1006msgid "Running a Taler payment service operator"
1015"The payment service operator runs a <em>Taler\n"
1016" exchange</em>, which is a Web service portal that\n"
1017" keeps databases with transaction details and\n"
1018" cryptographic proofs. Its operational expenses are\n"
1019" thus related to its interactions with the banking\n"
1020" system and the operation of the computing\n"
1021" infrastructure, while its income is based on\n"
1022" transaction fees it may charge for the various\n"
1023" interactions. Key interactions of the exchange\n"
1024" include: "
1025msgstr "" 1007msgstr ""
1026 1008
1027#: investors.html.j2:84 1009#: investors.html.j2:96
1028msgid "" 1010msgid ""
1029"Create a <b>reserve</b> based on an incoming\n" 1011"\n"
1030" wire transfer from a customer." 1012" The payment service operator runs the <em>Taler exchange</em>.\n"
1013" The exchange charges <b>transaction fees</b> to customers or "
1014"merchants.\n"
1015" Its operational expenses are from wire transfers with the banking\n"
1016" system and the operation of the computing infrastructure.\n"
1017" "
1031msgstr "" 1018msgstr ""
1032 1019
1033#: investors.html.j2:87 1020#: investors.html.j2:106
1034msgid "" 1021msgid ""
1035"Allow customers to withdraw (and refresh)\n" 1022"Cryptographic operations, bandwidth and storage costs are less than 0.01 "
1036" digital coins from their reserve." 1023"cent per transaction."
1037msgstr "" 1024msgstr ""
1038 1025
1039#: investors.html.j2:90 1026#: investors.html.j2:108
1040msgid "Accept and validate deposits from merchants." 1027msgid ""
1028"Multiple Taler transactions can be aggregated into larger wire transfers "
1029"to merchants to minimize wire transfer costs."
1041msgstr "" 1030msgstr ""
1042"Accettare e validare depositi di gettoni elettronici\n"
1043"\t da parte dei venditori."
1044 1031
1045#: investors.html.j2:92 1032#: investors.html.j2:110
1046msgid "" 1033msgid ""
1047"Execute wire transfers to merchants in\n" 1034"Correct operation can be automatically assessed by verifying "
1048" response to validated deposits." 1035"cryptographic proofs in the database."
1049msgstr "" 1036msgstr ""
1050 1037
1051#: investors.html.j2:95 1038#: investors.html.j2:112
1052msgid "" 1039msgid ""
1053"Preserve and provide cryptographic proofs of\n" 1040"Protocol allows the exchange to charge fees for any expensive operation "
1054" correct operation for audits by financial regulators." 1041"(withdraw, deposit, refresh, refund or aggregated wire transfers)."
1042msgstr ""
1043
1044#: investors.html.j2:114
1045msgid "Financial risk is bounded even if keys are compromised."
1055msgstr "" 1046msgstr ""
1056 1047
1057#: merchants.html.j2:5 1048#: merchants.html.j2:5
@@ -1358,3 +1349,30 @@ msgstr ""
1358#~ msgid "Open access (PSD2)" 1349#~ msgid "Open access (PSD2)"
1359#~ msgstr "" 1350#~ msgstr ""
1360 1351
1352#~ msgid "Taler as seen by governments"
1353#~ msgstr "Taler dal punto di vista dai governi"
1354
1355#~ msgid "Previous"
1356#~ msgstr ""
1357
1358#~ msgid "Next"
1359#~ msgstr ""
1360
1361#~ msgid "Accept and validate deposits from merchants."
1362#~ msgstr ""
1363
1364#~ msgid "Taler as seen by the payment service operator"
1365#~ msgstr ""
1366
1367#~ msgid ""
1368#~ "Cryptographic operations, bandwidth and "
1369#~ "storage are less than 0.01 cent "
1370#~ "per transaction."
1371#~ msgstr ""
1372
1373#~ msgid ""
1374#~ "Multiple Taler transactions are "
1375#~ "<b>aggregated</b> into larger wire transfers"
1376#~ " to merchants."
1377#~ msgstr ""
1378
diff --git a/presentations/investors2017.pdf b/presentations/investors2017.pdf
new file mode 100644
index 00000000..2af20bf5
--- /dev/null
+++ b/presentations/investors2017.pdf
Binary files differ