You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44638 lines
1.4MB

  1. /* Copyright 2017 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. (function webpackUniversalModuleDefinition(root, factory) {
  16. if(typeof exports === 'object' && typeof module === 'object')
  17. module.exports = factory();
  18. else if(typeof define === 'function' && define.amd)
  19. define("pdfjs-dist/build/pdf.worker", [], factory);
  20. else if(typeof exports === 'object')
  21. exports["pdfjs-dist/build/pdf.worker"] = factory();
  22. else
  23. root["pdfjs-dist/build/pdf.worker"] = root.pdfjsDistBuildPdfWorker = factory();
  24. })(this, function() {
  25. return /******/ (function(modules) { // webpackBootstrap
  26. /******/ // The module cache
  27. /******/ var installedModules = {};
  28. /******/
  29. /******/ // The require function
  30. /******/ function __w_pdfjs_require__(moduleId) {
  31. /******/
  32. /******/ // Check if module is in cache
  33. /******/ if(installedModules[moduleId]) {
  34. /******/ return installedModules[moduleId].exports;
  35. /******/ }
  36. /******/ // Create a new module (and put it into the cache)
  37. /******/ var module = installedModules[moduleId] = {
  38. /******/ i: moduleId,
  39. /******/ l: false,
  40. /******/ exports: {}
  41. /******/ };
  42. /******/
  43. /******/ // Execute the module function
  44. /******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  45. /******/
  46. /******/ // Flag the module as loaded
  47. /******/ module.l = true;
  48. /******/
  49. /******/ // Return the exports of the module
  50. /******/ return module.exports;
  51. /******/ }
  52. /******/
  53. /******/
  54. /******/ // expose the modules object (__webpack_modules__)
  55. /******/ __w_pdfjs_require__.m = modules;
  56. /******/
  57. /******/ // expose the module cache
  58. /******/ __w_pdfjs_require__.c = installedModules;
  59. /******/
  60. /******/ // define getter function for harmony exports
  61. /******/ __w_pdfjs_require__.d = function(exports, name, getter) {
  62. /******/ if(!__w_pdfjs_require__.o(exports, name)) {
  63. /******/ Object.defineProperty(exports, name, {
  64. /******/ configurable: false,
  65. /******/ enumerable: true,
  66. /******/ get: getter
  67. /******/ });
  68. /******/ }
  69. /******/ };
  70. /******/
  71. /******/ // getDefaultExport function for compatibility with non-harmony modules
  72. /******/ __w_pdfjs_require__.n = function(module) {
  73. /******/ var getter = module && module.__esModule ?
  74. /******/ function getDefault() { return module['default']; } :
  75. /******/ function getModuleExports() { return module; };
  76. /******/ __w_pdfjs_require__.d(getter, 'a', getter);
  77. /******/ return getter;
  78. /******/ };
  79. /******/
  80. /******/ // Object.prototype.hasOwnProperty.call
  81. /******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  82. /******/
  83. /******/ // __webpack_public_path__
  84. /******/ __w_pdfjs_require__.p = "";
  85. /******/
  86. /******/ // Load entry module and return exports
  87. /******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 70);
  88. /******/ })
  89. /************************************************************************/
  90. /******/ ([
  91. /* 0 */
  92. /***/ (function(module, exports, __w_pdfjs_require__) {
  93. "use strict";
  94. Object.defineProperty(exports, "__esModule", {
  95. value: true
  96. });
  97. exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.loadJpegStream = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isNodeJS = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.createBlob = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.StatTimer = exports.PasswordResponses = exports.PasswordException = exports.PageViewport = exports.NotImplementedException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.MessageHandler = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VERBOSITY_LEVELS = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined;
  98. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  99. __w_pdfjs_require__(72);
  100. var _streams_polyfill = __w_pdfjs_require__(120);
  101. var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  102. var NativeImageDecoding = {
  103. NONE: 'none',
  104. DECODE: 'decode',
  105. DISPLAY: 'display'
  106. };
  107. var TextRenderingMode = {
  108. FILL: 0,
  109. STROKE: 1,
  110. FILL_STROKE: 2,
  111. INVISIBLE: 3,
  112. FILL_ADD_TO_PATH: 4,
  113. STROKE_ADD_TO_PATH: 5,
  114. FILL_STROKE_ADD_TO_PATH: 6,
  115. ADD_TO_PATH: 7,
  116. FILL_STROKE_MASK: 3,
  117. ADD_TO_PATH_FLAG: 4
  118. };
  119. var ImageKind = {
  120. GRAYSCALE_1BPP: 1,
  121. RGB_24BPP: 2,
  122. RGBA_32BPP: 3
  123. };
  124. var AnnotationType = {
  125. TEXT: 1,
  126. LINK: 2,
  127. FREETEXT: 3,
  128. LINE: 4,
  129. SQUARE: 5,
  130. CIRCLE: 6,
  131. POLYGON: 7,
  132. POLYLINE: 8,
  133. HIGHLIGHT: 9,
  134. UNDERLINE: 10,
  135. SQUIGGLY: 11,
  136. STRIKEOUT: 12,
  137. STAMP: 13,
  138. CARET: 14,
  139. INK: 15,
  140. POPUP: 16,
  141. FILEATTACHMENT: 17,
  142. SOUND: 18,
  143. MOVIE: 19,
  144. WIDGET: 20,
  145. SCREEN: 21,
  146. PRINTERMARK: 22,
  147. TRAPNET: 23,
  148. WATERMARK: 24,
  149. THREED: 25,
  150. REDACT: 26
  151. };
  152. var AnnotationFlag = {
  153. INVISIBLE: 0x01,
  154. HIDDEN: 0x02,
  155. PRINT: 0x04,
  156. NOZOOM: 0x08,
  157. NOROTATE: 0x10,
  158. NOVIEW: 0x20,
  159. READONLY: 0x40,
  160. LOCKED: 0x80,
  161. TOGGLENOVIEW: 0x100,
  162. LOCKEDCONTENTS: 0x200
  163. };
  164. var AnnotationFieldFlag = {
  165. READONLY: 0x0000001,
  166. REQUIRED: 0x0000002,
  167. NOEXPORT: 0x0000004,
  168. MULTILINE: 0x0001000,
  169. PASSWORD: 0x0002000,
  170. NOTOGGLETOOFF: 0x0004000,
  171. RADIO: 0x0008000,
  172. PUSHBUTTON: 0x0010000,
  173. COMBO: 0x0020000,
  174. EDIT: 0x0040000,
  175. SORT: 0x0080000,
  176. FILESELECT: 0x0100000,
  177. MULTISELECT: 0x0200000,
  178. DONOTSPELLCHECK: 0x0400000,
  179. DONOTSCROLL: 0x0800000,
  180. COMB: 0x1000000,
  181. RICHTEXT: 0x2000000,
  182. RADIOSINUNISON: 0x2000000,
  183. COMMITONSELCHANGE: 0x4000000
  184. };
  185. var AnnotationBorderStyleType = {
  186. SOLID: 1,
  187. DASHED: 2,
  188. BEVELED: 3,
  189. INSET: 4,
  190. UNDERLINE: 5
  191. };
  192. var StreamType = {
  193. UNKNOWN: 0,
  194. FLATE: 1,
  195. LZW: 2,
  196. DCT: 3,
  197. JPX: 4,
  198. JBIG: 5,
  199. A85: 6,
  200. AHX: 7,
  201. CCF: 8,
  202. RL: 9
  203. };
  204. var FontType = {
  205. UNKNOWN: 0,
  206. TYPE1: 1,
  207. TYPE1C: 2,
  208. CIDFONTTYPE0: 3,
  209. CIDFONTTYPE0C: 4,
  210. TRUETYPE: 5,
  211. CIDFONTTYPE2: 6,
  212. TYPE3: 7,
  213. OPENTYPE: 8,
  214. TYPE0: 9,
  215. MMTYPE1: 10
  216. };
  217. var VERBOSITY_LEVELS = {
  218. errors: 0,
  219. warnings: 1,
  220. infos: 5
  221. };
  222. var CMapCompressionType = {
  223. NONE: 0,
  224. BINARY: 1,
  225. STREAM: 2
  226. };
  227. var OPS = {
  228. dependency: 1,
  229. setLineWidth: 2,
  230. setLineCap: 3,
  231. setLineJoin: 4,
  232. setMiterLimit: 5,
  233. setDash: 6,
  234. setRenderingIntent: 7,
  235. setFlatness: 8,
  236. setGState: 9,
  237. save: 10,
  238. restore: 11,
  239. transform: 12,
  240. moveTo: 13,
  241. lineTo: 14,
  242. curveTo: 15,
  243. curveTo2: 16,
  244. curveTo3: 17,
  245. closePath: 18,
  246. rectangle: 19,
  247. stroke: 20,
  248. closeStroke: 21,
  249. fill: 22,
  250. eoFill: 23,
  251. fillStroke: 24,
  252. eoFillStroke: 25,
  253. closeFillStroke: 26,
  254. closeEOFillStroke: 27,
  255. endPath: 28,
  256. clip: 29,
  257. eoClip: 30,
  258. beginText: 31,
  259. endText: 32,
  260. setCharSpacing: 33,
  261. setWordSpacing: 34,
  262. setHScale: 35,
  263. setLeading: 36,
  264. setFont: 37,
  265. setTextRenderingMode: 38,
  266. setTextRise: 39,
  267. moveText: 40,
  268. setLeadingMoveText: 41,
  269. setTextMatrix: 42,
  270. nextLine: 43,
  271. showText: 44,
  272. showSpacedText: 45,
  273. nextLineShowText: 46,
  274. nextLineSetSpacingShowText: 47,
  275. setCharWidth: 48,
  276. setCharWidthAndBounds: 49,
  277. setStrokeColorSpace: 50,
  278. setFillColorSpace: 51,
  279. setStrokeColor: 52,
  280. setStrokeColorN: 53,
  281. setFillColor: 54,
  282. setFillColorN: 55,
  283. setStrokeGray: 56,
  284. setFillGray: 57,
  285. setStrokeRGBColor: 58,
  286. setFillRGBColor: 59,
  287. setStrokeCMYKColor: 60,
  288. setFillCMYKColor: 61,
  289. shadingFill: 62,
  290. beginInlineImage: 63,
  291. beginImageData: 64,
  292. endInlineImage: 65,
  293. paintXObject: 66,
  294. markPoint: 67,
  295. markPointProps: 68,
  296. beginMarkedContent: 69,
  297. beginMarkedContentProps: 70,
  298. endMarkedContent: 71,
  299. beginCompat: 72,
  300. endCompat: 73,
  301. paintFormXObjectBegin: 74,
  302. paintFormXObjectEnd: 75,
  303. beginGroup: 76,
  304. endGroup: 77,
  305. beginAnnotations: 78,
  306. endAnnotations: 79,
  307. beginAnnotation: 80,
  308. endAnnotation: 81,
  309. paintJpegXObject: 82,
  310. paintImageMaskXObject: 83,
  311. paintImageMaskXObjectGroup: 84,
  312. paintImageXObject: 85,
  313. paintInlineImageXObject: 86,
  314. paintInlineImageXObjectGroup: 87,
  315. paintImageXObjectRepeat: 88,
  316. paintImageMaskXObjectRepeat: 89,
  317. paintSolidColorImageMask: 90,
  318. constructPath: 91
  319. };
  320. var verbosity = VERBOSITY_LEVELS.warnings;
  321. function setVerbosityLevel(level) {
  322. verbosity = level;
  323. }
  324. function getVerbosityLevel() {
  325. return verbosity;
  326. }
  327. function info(msg) {
  328. if (verbosity >= VERBOSITY_LEVELS.infos) {
  329. console.log('Info: ' + msg);
  330. }
  331. }
  332. function warn(msg) {
  333. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  334. console.log('Warning: ' + msg);
  335. }
  336. }
  337. function deprecated(details) {
  338. console.log('Deprecated API usage: ' + details);
  339. }
  340. function unreachable(msg) {
  341. throw new Error(msg);
  342. }
  343. function assert(cond, msg) {
  344. if (!cond) {
  345. unreachable(msg);
  346. }
  347. }
  348. var UNSUPPORTED_FEATURES = {
  349. unknown: 'unknown',
  350. forms: 'forms',
  351. javaScript: 'javaScript',
  352. smask: 'smask',
  353. shadingPattern: 'shadingPattern',
  354. font: 'font'
  355. };
  356. function isSameOrigin(baseUrl, otherUrl) {
  357. try {
  358. var base = new URL(baseUrl);
  359. if (!base.origin || base.origin === 'null') {
  360. return false;
  361. }
  362. } catch (e) {
  363. return false;
  364. }
  365. var other = new URL(otherUrl, base);
  366. return base.origin === other.origin;
  367. }
  368. function isValidProtocol(url) {
  369. if (!url) {
  370. return false;
  371. }
  372. switch (url.protocol) {
  373. case 'http:':
  374. case 'https:':
  375. case 'ftp:':
  376. case 'mailto:':
  377. case 'tel:':
  378. return true;
  379. default:
  380. return false;
  381. }
  382. }
  383. function createValidAbsoluteUrl(url, baseUrl) {
  384. if (!url) {
  385. return null;
  386. }
  387. try {
  388. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  389. if (isValidProtocol(absoluteUrl)) {
  390. return absoluteUrl;
  391. }
  392. } catch (ex) {}
  393. return null;
  394. }
  395. function shadow(obj, prop, value) {
  396. Object.defineProperty(obj, prop, {
  397. value: value,
  398. enumerable: true,
  399. configurable: true,
  400. writable: false
  401. });
  402. return value;
  403. }
  404. function getLookupTableFactory(initializer) {
  405. var lookup;
  406. return function () {
  407. if (initializer) {
  408. lookup = Object.create(null);
  409. initializer(lookup);
  410. initializer = null;
  411. }
  412. return lookup;
  413. };
  414. }
  415. var PasswordResponses = {
  416. NEED_PASSWORD: 1,
  417. INCORRECT_PASSWORD: 2
  418. };
  419. var PasswordException = function PasswordExceptionClosure() {
  420. function PasswordException(msg, code) {
  421. this.name = 'PasswordException';
  422. this.message = msg;
  423. this.code = code;
  424. }
  425. PasswordException.prototype = new Error();
  426. PasswordException.constructor = PasswordException;
  427. return PasswordException;
  428. }();
  429. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  430. function UnknownErrorException(msg, details) {
  431. this.name = 'UnknownErrorException';
  432. this.message = msg;
  433. this.details = details;
  434. }
  435. UnknownErrorException.prototype = new Error();
  436. UnknownErrorException.constructor = UnknownErrorException;
  437. return UnknownErrorException;
  438. }();
  439. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  440. function InvalidPDFException(msg) {
  441. this.name = 'InvalidPDFException';
  442. this.message = msg;
  443. }
  444. InvalidPDFException.prototype = new Error();
  445. InvalidPDFException.constructor = InvalidPDFException;
  446. return InvalidPDFException;
  447. }();
  448. var MissingPDFException = function MissingPDFExceptionClosure() {
  449. function MissingPDFException(msg) {
  450. this.name = 'MissingPDFException';
  451. this.message = msg;
  452. }
  453. MissingPDFException.prototype = new Error();
  454. MissingPDFException.constructor = MissingPDFException;
  455. return MissingPDFException;
  456. }();
  457. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  458. function UnexpectedResponseException(msg, status) {
  459. this.name = 'UnexpectedResponseException';
  460. this.message = msg;
  461. this.status = status;
  462. }
  463. UnexpectedResponseException.prototype = new Error();
  464. UnexpectedResponseException.constructor = UnexpectedResponseException;
  465. return UnexpectedResponseException;
  466. }();
  467. var NotImplementedException = function NotImplementedExceptionClosure() {
  468. function NotImplementedException(msg) {
  469. this.message = msg;
  470. }
  471. NotImplementedException.prototype = new Error();
  472. NotImplementedException.prototype.name = 'NotImplementedException';
  473. NotImplementedException.constructor = NotImplementedException;
  474. return NotImplementedException;
  475. }();
  476. var MissingDataException = function MissingDataExceptionClosure() {
  477. function MissingDataException(begin, end) {
  478. this.begin = begin;
  479. this.end = end;
  480. this.message = 'Missing data [' + begin + ', ' + end + ')';
  481. }
  482. MissingDataException.prototype = new Error();
  483. MissingDataException.prototype.name = 'MissingDataException';
  484. MissingDataException.constructor = MissingDataException;
  485. return MissingDataException;
  486. }();
  487. var XRefParseException = function XRefParseExceptionClosure() {
  488. function XRefParseException(msg) {
  489. this.message = msg;
  490. }
  491. XRefParseException.prototype = new Error();
  492. XRefParseException.prototype.name = 'XRefParseException';
  493. XRefParseException.constructor = XRefParseException;
  494. return XRefParseException;
  495. }();
  496. var FormatError = function FormatErrorClosure() {
  497. function FormatError(msg) {
  498. this.message = msg;
  499. }
  500. FormatError.prototype = new Error();
  501. FormatError.prototype.name = 'FormatError';
  502. FormatError.constructor = FormatError;
  503. return FormatError;
  504. }();
  505. var AbortException = function AbortExceptionClosure() {
  506. function AbortException(msg) {
  507. this.name = 'AbortException';
  508. this.message = msg;
  509. }
  510. AbortException.prototype = new Error();
  511. AbortException.constructor = AbortException;
  512. return AbortException;
  513. }();
  514. var NullCharactersRegExp = /\x00/g;
  515. function removeNullCharacters(str) {
  516. if (typeof str !== 'string') {
  517. warn('The argument for removeNullCharacters must be a string.');
  518. return str;
  519. }
  520. return str.replace(NullCharactersRegExp, '');
  521. }
  522. function bytesToString(bytes) {
  523. assert(bytes !== null && (typeof bytes === 'undefined' ? 'undefined' : _typeof(bytes)) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  524. var length = bytes.length;
  525. var MAX_ARGUMENT_COUNT = 8192;
  526. if (length < MAX_ARGUMENT_COUNT) {
  527. return String.fromCharCode.apply(null, bytes);
  528. }
  529. var strBuf = [];
  530. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  531. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  532. var chunk = bytes.subarray(i, chunkEnd);
  533. strBuf.push(String.fromCharCode.apply(null, chunk));
  534. }
  535. return strBuf.join('');
  536. }
  537. function stringToBytes(str) {
  538. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  539. var length = str.length;
  540. var bytes = new Uint8Array(length);
  541. for (var i = 0; i < length; ++i) {
  542. bytes[i] = str.charCodeAt(i) & 0xFF;
  543. }
  544. return bytes;
  545. }
  546. function arrayByteLength(arr) {
  547. if (arr.length !== undefined) {
  548. return arr.length;
  549. }
  550. assert(arr.byteLength !== undefined);
  551. return arr.byteLength;
  552. }
  553. function arraysToBytes(arr) {
  554. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  555. return arr[0];
  556. }
  557. var resultLength = 0;
  558. var i,
  559. ii = arr.length;
  560. var item, itemLength;
  561. for (i = 0; i < ii; i++) {
  562. item = arr[i];
  563. itemLength = arrayByteLength(item);
  564. resultLength += itemLength;
  565. }
  566. var pos = 0;
  567. var data = new Uint8Array(resultLength);
  568. for (i = 0; i < ii; i++) {
  569. item = arr[i];
  570. if (!(item instanceof Uint8Array)) {
  571. if (typeof item === 'string') {
  572. item = stringToBytes(item);
  573. } else {
  574. item = new Uint8Array(item);
  575. }
  576. }
  577. itemLength = item.byteLength;
  578. data.set(item, pos);
  579. pos += itemLength;
  580. }
  581. return data;
  582. }
  583. function string32(value) {
  584. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  585. }
  586. function log2(x) {
  587. var n = 1,
  588. i = 0;
  589. while (x > n) {
  590. n <<= 1;
  591. i++;
  592. }
  593. return i;
  594. }
  595. function readInt8(data, start) {
  596. return data[start] << 24 >> 24;
  597. }
  598. function readUint16(data, offset) {
  599. return data[offset] << 8 | data[offset + 1];
  600. }
  601. function readUint32(data, offset) {
  602. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  603. }
  604. function isLittleEndian() {
  605. var buffer8 = new Uint8Array(4);
  606. buffer8[0] = 1;
  607. var view32 = new Uint32Array(buffer8.buffer, 0, 1);
  608. return view32[0] === 1;
  609. }
  610. function isEvalSupported() {
  611. try {
  612. new Function('');
  613. return true;
  614. } catch (e) {
  615. return false;
  616. }
  617. }
  618. var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  619. var Util = function UtilClosure() {
  620. function Util() {}
  621. var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
  622. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  623. rgbBuf[1] = r;
  624. rgbBuf[3] = g;
  625. rgbBuf[5] = b;
  626. return rgbBuf.join('');
  627. };
  628. Util.transform = function Util_transform(m1, m2) {
  629. 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]];
  630. };
  631. Util.applyTransform = function Util_applyTransform(p, m) {
  632. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  633. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  634. return [xt, yt];
  635. };
  636. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  637. var d = m[0] * m[3] - m[1] * m[2];
  638. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  639. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  640. return [xt, yt];
  641. };
  642. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  643. var p1 = Util.applyTransform(r, m);
  644. var p2 = Util.applyTransform(r.slice(2, 4), m);
  645. var p3 = Util.applyTransform([r[0], r[3]], m);
  646. var p4 = Util.applyTransform([r[2], r[1]], m);
  647. 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])];
  648. };
  649. Util.inverseTransform = function Util_inverseTransform(m) {
  650. var d = m[0] * m[3] - m[1] * m[2];
  651. 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];
  652. };
  653. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  654. 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]];
  655. };
  656. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  657. var transpose = [m[0], m[2], m[1], m[3]];
  658. var a = m[0] * transpose[0] + m[1] * transpose[2];
  659. var b = m[0] * transpose[1] + m[1] * transpose[3];
  660. var c = m[2] * transpose[0] + m[3] * transpose[2];
  661. var d = m[2] * transpose[1] + m[3] * transpose[3];
  662. var first = (a + d) / 2;
  663. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  664. var sx = first + second || 1;
  665. var sy = first - second || 1;
  666. return [Math.sqrt(sx), Math.sqrt(sy)];
  667. };
  668. Util.normalizeRect = function Util_normalizeRect(rect) {
  669. var r = rect.slice(0);
  670. if (rect[0] > rect[2]) {
  671. r[0] = rect[2];
  672. r[2] = rect[0];
  673. }
  674. if (rect[1] > rect[3]) {
  675. r[1] = rect[3];
  676. r[3] = rect[1];
  677. }
  678. return r;
  679. };
  680. Util.intersect = function Util_intersect(rect1, rect2) {
  681. function compare(a, b) {
  682. return a - b;
  683. }
  684. var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare),
  685. orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare),
  686. result = [];
  687. rect1 = Util.normalizeRect(rect1);
  688. rect2 = Util.normalizeRect(rect2);
  689. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  690. result[0] = orderedX[1];
  691. result[2] = orderedX[2];
  692. } else {
  693. return false;
  694. }
  695. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  696. result[1] = orderedY[1];
  697. result[3] = orderedY[2];
  698. } else {
  699. return false;
  700. }
  701. return result;
  702. };
  703. 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'];
  704. Util.toRoman = function Util_toRoman(number, lowerCase) {
  705. assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.');
  706. var pos,
  707. romanBuf = [];
  708. while (number >= 1000) {
  709. number -= 1000;
  710. romanBuf.push('M');
  711. }
  712. pos = number / 100 | 0;
  713. number %= 100;
  714. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  715. pos = number / 10 | 0;
  716. number %= 10;
  717. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  718. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  719. var romanStr = romanBuf.join('');
  720. return lowerCase ? romanStr.toLowerCase() : romanStr;
  721. };
  722. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  723. Array.prototype.push.apply(arr1, arr2);
  724. };
  725. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  726. Array.prototype.unshift.apply(arr1, arr2);
  727. };
  728. Util.extendObj = function extendObj(obj1, obj2) {
  729. for (var key in obj2) {
  730. obj1[key] = obj2[key];
  731. }
  732. };
  733. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  734. while (dict && !dict.has(name)) {
  735. dict = dict.get('Parent');
  736. }
  737. if (!dict) {
  738. return null;
  739. }
  740. return getArray ? dict.getArray(name) : dict.get(name);
  741. };
  742. Util.inherit = function Util_inherit(sub, base, prototype) {
  743. sub.prototype = Object.create(base.prototype);
  744. sub.prototype.constructor = sub;
  745. for (var prop in prototype) {
  746. sub.prototype[prop] = prototype[prop];
  747. }
  748. };
  749. Util.loadScript = function Util_loadScript(src, callback) {
  750. var script = document.createElement('script');
  751. var loaded = false;
  752. script.setAttribute('src', src);
  753. if (callback) {
  754. script.onload = function () {
  755. if (!loaded) {
  756. callback();
  757. }
  758. loaded = true;
  759. };
  760. }
  761. document.getElementsByTagName('head')[0].appendChild(script);
  762. };
  763. return Util;
  764. }();
  765. var PageViewport = function PageViewportClosure() {
  766. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  767. this.viewBox = viewBox;
  768. this.scale = scale;
  769. this.rotation = rotation;
  770. this.offsetX = offsetX;
  771. this.offsetY = offsetY;
  772. var centerX = (viewBox[2] + viewBox[0]) / 2;
  773. var centerY = (viewBox[3] + viewBox[1]) / 2;
  774. var rotateA, rotateB, rotateC, rotateD;
  775. rotation = rotation % 360;
  776. rotation = rotation < 0 ? rotation + 360 : rotation;
  777. switch (rotation) {
  778. case 180:
  779. rotateA = -1;
  780. rotateB = 0;
  781. rotateC = 0;
  782. rotateD = 1;
  783. break;
  784. case 90:
  785. rotateA = 0;
  786. rotateB = 1;
  787. rotateC = 1;
  788. rotateD = 0;
  789. break;
  790. case 270:
  791. rotateA = 0;
  792. rotateB = -1;
  793. rotateC = -1;
  794. rotateD = 0;
  795. break;
  796. default:
  797. rotateA = 1;
  798. rotateB = 0;
  799. rotateC = 0;
  800. rotateD = -1;
  801. break;
  802. }
  803. if (dontFlip) {
  804. rotateC = -rotateC;
  805. rotateD = -rotateD;
  806. }
  807. var offsetCanvasX, offsetCanvasY;
  808. var width, height;
  809. if (rotateA === 0) {
  810. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  811. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  812. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  813. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  814. } else {
  815. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  816. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  817. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  818. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  819. }
  820. this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
  821. this.width = width;
  822. this.height = height;
  823. this.fontScale = scale;
  824. }
  825. PageViewport.prototype = {
  826. clone: function PageViewPort_clone(args) {
  827. args = args || {};
  828. var scale = 'scale' in args ? args.scale : this.scale;
  829. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  830. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  831. },
  832. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  833. return Util.applyTransform([x, y], this.transform);
  834. },
  835. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  836. var tl = Util.applyTransform([rect[0], rect[1]], this.transform);
  837. var br = Util.applyTransform([rect[2], rect[3]], this.transform);
  838. return [tl[0], tl[1], br[0], br[1]];
  839. },
  840. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  841. return Util.applyInverseTransform([x, y], this.transform);
  842. }
  843. };
  844. return PageViewport;
  845. }();
  846. 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, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC];
  847. function stringToPDFString(str) {
  848. var i,
  849. n = str.length,
  850. strBuf = [];
  851. if (str[0] === '\xFE' && str[1] === '\xFF') {
  852. for (i = 2; i < n; i += 2) {
  853. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  854. }
  855. } else {
  856. for (i = 0; i < n; ++i) {
  857. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  858. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  859. }
  860. }
  861. return strBuf.join('');
  862. }
  863. function stringToUTF8String(str) {
  864. return decodeURIComponent(escape(str));
  865. }
  866. function utf8StringToString(str) {
  867. return unescape(encodeURIComponent(str));
  868. }
  869. function isEmptyObj(obj) {
  870. for (var key in obj) {
  871. return false;
  872. }
  873. return true;
  874. }
  875. function isBool(v) {
  876. return typeof v === 'boolean';
  877. }
  878. function isNum(v) {
  879. return typeof v === 'number';
  880. }
  881. function isString(v) {
  882. return typeof v === 'string';
  883. }
  884. function isArrayBuffer(v) {
  885. return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.byteLength !== undefined;
  886. }
  887. function isSpace(ch) {
  888. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  889. }
  890. function isNodeJS() {
  891. return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && process + '' === '[object process]';
  892. }
  893. function createPromiseCapability() {
  894. var capability = {};
  895. capability.promise = new Promise(function (resolve, reject) {
  896. capability.resolve = resolve;
  897. capability.reject = reject;
  898. });
  899. return capability;
  900. }
  901. var StatTimer = function StatTimerClosure() {
  902. function rpad(str, pad, length) {
  903. while (str.length < length) {
  904. str += pad;
  905. }
  906. return str;
  907. }
  908. function StatTimer() {
  909. this.started = Object.create(null);
  910. this.times = [];
  911. this.enabled = true;
  912. }
  913. StatTimer.prototype = {
  914. time: function StatTimer_time(name) {
  915. if (!this.enabled) {
  916. return;
  917. }
  918. if (name in this.started) {
  919. warn('Timer is already running for ' + name);
  920. }
  921. this.started[name] = Date.now();
  922. },
  923. timeEnd: function StatTimer_timeEnd(name) {
  924. if (!this.enabled) {
  925. return;
  926. }
  927. if (!(name in this.started)) {
  928. warn('Timer has not been started for ' + name);
  929. }
  930. this.times.push({
  931. 'name': name,
  932. 'start': this.started[name],
  933. 'end': Date.now()
  934. });
  935. delete this.started[name];
  936. },
  937. toString: function StatTimer_toString() {
  938. var i, ii;
  939. var times = this.times;
  940. var out = '';
  941. var longest = 0;
  942. for (i = 0, ii = times.length; i < ii; ++i) {
  943. var name = times[i]['name'];
  944. if (name.length > longest) {
  945. longest = name.length;
  946. }
  947. }
  948. for (i = 0, ii = times.length; i < ii; ++i) {
  949. var span = times[i];
  950. var duration = span.end - span.start;
  951. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  952. }
  953. return out;
  954. }
  955. };
  956. return StatTimer;
  957. }();
  958. var createBlob = function createBlob(data, contentType) {
  959. if (typeof Blob !== 'undefined') {
  960. return new Blob([data], { type: contentType });
  961. }
  962. throw new Error('The "Blob" constructor is not supported.');
  963. };
  964. var createObjectURL = function createObjectURLClosure() {
  965. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  966. return function createObjectURL(data, contentType) {
  967. var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  968. if (!forceDataSchema && URL.createObjectURL) {
  969. var blob = createBlob(data, contentType);
  970. return URL.createObjectURL(blob);
  971. }
  972. var buffer = 'data:' + contentType + ';base64,';
  973. for (var i = 0, ii = data.length; i < ii; i += 3) {
  974. var b1 = data[i] & 0xFF;
  975. var b2 = data[i + 1] & 0xFF;
  976. var b3 = data[i + 2] & 0xFF;
  977. var d1 = b1 >> 2,
  978. d2 = (b1 & 3) << 4 | b2 >> 4;
  979. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  980. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  981. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  982. }
  983. return buffer;
  984. };
  985. }();
  986. function resolveCall(fn, args) {
  987. var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  988. if (!fn) {
  989. return Promise.resolve(undefined);
  990. }
  991. return new Promise(function (resolve, reject) {
  992. resolve(fn.apply(thisArg, args));
  993. });
  994. }
  995. function wrapReason(reason) {
  996. if ((typeof reason === 'undefined' ? 'undefined' : _typeof(reason)) !== 'object') {
  997. return reason;
  998. }
  999. switch (reason.name) {
  1000. case 'AbortException':
  1001. return new AbortException(reason.message);
  1002. case 'MissingPDFException':
  1003. return new MissingPDFException(reason.message);
  1004. case 'UnexpectedResponseException':
  1005. return new UnexpectedResponseException(reason.message, reason.status);
  1006. default:
  1007. return new UnknownErrorException(reason.message, reason.details);
  1008. }
  1009. }
  1010. function makeReasonSerializable(reason) {
  1011. if (!(reason instanceof Error) || reason instanceof AbortException || reason instanceof MissingPDFException || reason instanceof UnexpectedResponseException || reason instanceof UnknownErrorException) {
  1012. return reason;
  1013. }
  1014. return new UnknownErrorException(reason.message, reason.toString());
  1015. }
  1016. function resolveOrReject(capability, success, reason) {
  1017. if (success) {
  1018. capability.resolve();
  1019. } else {
  1020. capability.reject(reason);
  1021. }
  1022. }
  1023. function finalize(promise) {
  1024. return Promise.resolve(promise).catch(function () {});
  1025. }
  1026. function MessageHandler(sourceName, targetName, comObj) {
  1027. var _this = this;
  1028. this.sourceName = sourceName;
  1029. this.targetName = targetName;
  1030. this.comObj = comObj;
  1031. this.callbackId = 1;
  1032. this.streamId = 1;
  1033. this.postMessageTransfers = true;
  1034. this.streamSinks = Object.create(null);
  1035. this.streamControllers = Object.create(null);
  1036. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  1037. var ah = this.actionHandler = Object.create(null);
  1038. this._onComObjOnMessage = function (event) {
  1039. var data = event.data;
  1040. if (data.targetName !== _this.sourceName) {
  1041. return;
  1042. }
  1043. if (data.stream) {
  1044. _this._processStreamMessage(data);
  1045. } else if (data.isReply) {
  1046. var callbackId = data.callbackId;
  1047. if (data.callbackId in callbacksCapabilities) {
  1048. var callback = callbacksCapabilities[callbackId];
  1049. delete callbacksCapabilities[callbackId];
  1050. if ('error' in data) {
  1051. callback.reject(wrapReason(data.error));
  1052. } else {
  1053. callback.resolve(data.data);
  1054. }
  1055. } else {
  1056. throw new Error('Cannot resolve callback ' + callbackId);
  1057. }
  1058. } else if (data.action in ah) {
  1059. var action = ah[data.action];
  1060. if (data.callbackId) {
  1061. var _sourceName = _this.sourceName;
  1062. var _targetName = data.sourceName;
  1063. Promise.resolve().then(function () {
  1064. return action[0].call(action[1], data.data);
  1065. }).then(function (result) {
  1066. comObj.postMessage({
  1067. sourceName: _sourceName,
  1068. targetName: _targetName,
  1069. isReply: true,
  1070. callbackId: data.callbackId,
  1071. data: result
  1072. });
  1073. }, function (reason) {
  1074. comObj.postMessage({
  1075. sourceName: _sourceName,
  1076. targetName: _targetName,
  1077. isReply: true,
  1078. callbackId: data.callbackId,
  1079. error: makeReasonSerializable(reason)
  1080. });
  1081. });
  1082. } else if (data.streamId) {
  1083. _this._createStreamSink(data);
  1084. } else {
  1085. action[0].call(action[1], data.data);
  1086. }
  1087. } else {
  1088. throw new Error('Unknown action from worker: ' + data.action);
  1089. }
  1090. };
  1091. comObj.addEventListener('message', this._onComObjOnMessage);
  1092. }
  1093. MessageHandler.prototype = {
  1094. on: function on(actionName, handler, scope) {
  1095. var ah = this.actionHandler;
  1096. if (ah[actionName]) {
  1097. throw new Error('There is already an actionName called "' + actionName + '"');
  1098. }
  1099. ah[actionName] = [handler, scope];
  1100. },
  1101. send: function send(actionName, data, transfers) {
  1102. var message = {
  1103. sourceName: this.sourceName,
  1104. targetName: this.targetName,
  1105. action: actionName,
  1106. data: data
  1107. };
  1108. this.postMessage(message, transfers);
  1109. },
  1110. sendWithPromise: function sendWithPromise(actionName, data, transfers) {
  1111. var callbackId = this.callbackId++;
  1112. var message = {
  1113. sourceName: this.sourceName,
  1114. targetName: this.targetName,
  1115. action: actionName,
  1116. data: data,
  1117. callbackId: callbackId
  1118. };
  1119. var capability = createPromiseCapability();
  1120. this.callbacksCapabilities[callbackId] = capability;
  1121. try {
  1122. this.postMessage(message, transfers);
  1123. } catch (e) {
  1124. capability.reject(e);
  1125. }
  1126. return capability.promise;
  1127. },
  1128. sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) {
  1129. var _this2 = this;
  1130. var streamId = this.streamId++;
  1131. var sourceName = this.sourceName;
  1132. var targetName = this.targetName;
  1133. return new _streams_polyfill.ReadableStream({
  1134. start: function start(controller) {
  1135. var startCapability = createPromiseCapability();
  1136. _this2.streamControllers[streamId] = {
  1137. controller: controller,
  1138. startCall: startCapability,
  1139. isClosed: false
  1140. };
  1141. _this2.postMessage({
  1142. sourceName: sourceName,
  1143. targetName: targetName,
  1144. action: actionName,
  1145. streamId: streamId,
  1146. data: data,
  1147. desiredSize: controller.desiredSize
  1148. });
  1149. return startCapability.promise;
  1150. },
  1151. pull: function pull(controller) {
  1152. var pullCapability = createPromiseCapability();
  1153. _this2.streamControllers[streamId].pullCall = pullCapability;
  1154. _this2.postMessage({
  1155. sourceName: sourceName,
  1156. targetName: targetName,
  1157. stream: 'pull',
  1158. streamId: streamId,
  1159. desiredSize: controller.desiredSize
  1160. });
  1161. return pullCapability.promise;
  1162. },
  1163. cancel: function cancel(reason) {
  1164. var cancelCapability = createPromiseCapability();
  1165. _this2.streamControllers[streamId].cancelCall = cancelCapability;
  1166. _this2.streamControllers[streamId].isClosed = true;
  1167. _this2.postMessage({
  1168. sourceName: sourceName,
  1169. targetName: targetName,
  1170. stream: 'cancel',
  1171. reason: reason,
  1172. streamId: streamId
  1173. });
  1174. return cancelCapability.promise;
  1175. }
  1176. }, queueingStrategy);
  1177. },
  1178. _createStreamSink: function _createStreamSink(data) {
  1179. var _this3 = this;
  1180. var self = this;
  1181. var action = this.actionHandler[data.action];
  1182. var streamId = data.streamId;
  1183. var desiredSize = data.desiredSize;
  1184. var sourceName = this.sourceName;
  1185. var targetName = data.sourceName;
  1186. var capability = createPromiseCapability();
  1187. var sendStreamRequest = function sendStreamRequest(_ref) {
  1188. var stream = _ref.stream,
  1189. chunk = _ref.chunk,
  1190. transfers = _ref.transfers,
  1191. success = _ref.success,
  1192. reason = _ref.reason;
  1193. _this3.postMessage({
  1194. sourceName: sourceName,
  1195. targetName: targetName,
  1196. stream: stream,
  1197. streamId: streamId,
  1198. chunk: chunk,
  1199. success: success,
  1200. reason: reason
  1201. }, transfers);
  1202. };
  1203. var streamSink = {
  1204. enqueue: function enqueue(chunk) {
  1205. var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  1206. var transfers = arguments[2];
  1207. if (this.isCancelled) {
  1208. return;
  1209. }
  1210. var lastDesiredSize = this.desiredSize;
  1211. this.desiredSize -= size;
  1212. if (lastDesiredSize > 0 && this.desiredSize <= 0) {
  1213. this.sinkCapability = createPromiseCapability();
  1214. this.ready = this.sinkCapability.promise;
  1215. }
  1216. sendStreamRequest({
  1217. stream: 'enqueue',
  1218. chunk: chunk,
  1219. transfers: transfers
  1220. });
  1221. },
  1222. close: function close() {
  1223. if (this.isCancelled) {
  1224. return;
  1225. }
  1226. this.isCancelled = true;
  1227. sendStreamRequest({ stream: 'close' });
  1228. delete self.streamSinks[streamId];
  1229. },
  1230. error: function error(reason) {
  1231. if (this.isCancelled) {
  1232. return;
  1233. }
  1234. this.isCancelled = true;
  1235. sendStreamRequest({
  1236. stream: 'error',
  1237. reason: reason
  1238. });
  1239. },
  1240. sinkCapability: capability,
  1241. onPull: null,
  1242. onCancel: null,
  1243. isCancelled: false,
  1244. desiredSize: desiredSize,
  1245. ready: null
  1246. };
  1247. streamSink.sinkCapability.resolve();
  1248. streamSink.ready = streamSink.sinkCapability.promise;
  1249. this.streamSinks[streamId] = streamSink;
  1250. resolveCall(action[0], [data.data, streamSink], action[1]).then(function () {
  1251. sendStreamRequest({
  1252. stream: 'start_complete',
  1253. success: true
  1254. });
  1255. }, function (reason) {
  1256. sendStreamRequest({
  1257. stream: 'start_complete',
  1258. success: false,
  1259. reason: reason
  1260. });
  1261. });
  1262. },
  1263. _processStreamMessage: function _processStreamMessage(data) {
  1264. var _this4 = this;
  1265. var sourceName = this.sourceName;
  1266. var targetName = data.sourceName;
  1267. var streamId = data.streamId;
  1268. var sendStreamResponse = function sendStreamResponse(_ref2) {
  1269. var stream = _ref2.stream,
  1270. success = _ref2.success,
  1271. reason = _ref2.reason;
  1272. _this4.comObj.postMessage({
  1273. sourceName: sourceName,
  1274. targetName: targetName,
  1275. stream: stream,
  1276. success: success,
  1277. streamId: streamId,
  1278. reason: reason
  1279. });
  1280. };
  1281. var deleteStreamController = function deleteStreamController() {
  1282. Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) {
  1283. return capability && finalize(capability.promise);
  1284. })).then(function () {
  1285. delete _this4.streamControllers[data.streamId];
  1286. });
  1287. };
  1288. switch (data.stream) {
  1289. case 'start_complete':
  1290. resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason));
  1291. break;
  1292. case 'pull_complete':
  1293. resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason));
  1294. break;
  1295. case 'pull':
  1296. if (!this.streamSinks[data.streamId]) {
  1297. sendStreamResponse({
  1298. stream: 'pull_complete',
  1299. success: true
  1300. });
  1301. break;
  1302. }
  1303. if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) {
  1304. this.streamSinks[data.streamId].sinkCapability.resolve();
  1305. }
  1306. this.streamSinks[data.streamId].desiredSize = data.desiredSize;
  1307. resolveCall(this.streamSinks[data.streamId].onPull).then(function () {
  1308. sendStreamResponse({
  1309. stream: 'pull_complete',
  1310. success: true
  1311. });
  1312. }, function (reason) {
  1313. sendStreamResponse({
  1314. stream: 'pull_complete',
  1315. success: false,
  1316. reason: reason
  1317. });
  1318. });
  1319. break;
  1320. case 'enqueue':
  1321. assert(this.streamControllers[data.streamId], 'enqueue should have stream controller');
  1322. if (!this.streamControllers[data.streamId].isClosed) {
  1323. this.streamControllers[data.streamId].controller.enqueue(data.chunk);
  1324. }
  1325. break;
  1326. case 'close':
  1327. assert(this.streamControllers[data.streamId], 'close should have stream controller');
  1328. if (this.streamControllers[data.streamId].isClosed) {
  1329. break;
  1330. }
  1331. this.streamControllers[data.streamId].isClosed = true;
  1332. this.streamControllers[data.streamId].controller.close();
  1333. deleteStreamController();
  1334. break;
  1335. case 'error':
  1336. assert(this.streamControllers[data.streamId], 'error should have stream controller');
  1337. this.streamControllers[data.streamId].controller.error(wrapReason(data.reason));
  1338. deleteStreamController();
  1339. break;
  1340. case 'cancel_complete':
  1341. resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason));
  1342. deleteStreamController();
  1343. break;
  1344. case 'cancel':
  1345. if (!this.streamSinks[data.streamId]) {
  1346. break;
  1347. }
  1348. resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () {
  1349. sendStreamResponse({
  1350. stream: 'cancel_complete',
  1351. success: true
  1352. });
  1353. }, function (reason) {
  1354. sendStreamResponse({
  1355. stream: 'cancel_complete',
  1356. success: false,
  1357. reason: reason
  1358. });
  1359. });
  1360. this.streamSinks[data.streamId].sinkCapability.reject(wrapReason(data.reason));
  1361. this.streamSinks[data.streamId].isCancelled = true;
  1362. delete this.streamSinks[data.streamId];
  1363. break;
  1364. default:
  1365. throw new Error('Unexpected stream case');
  1366. }
  1367. },
  1368. postMessage: function postMessage(message, transfers) {
  1369. if (transfers && this.postMessageTransfers) {
  1370. this.comObj.postMessage(message, transfers);
  1371. } else {
  1372. this.comObj.postMessage(message);
  1373. }
  1374. },
  1375. destroy: function destroy() {
  1376. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  1377. }
  1378. };
  1379. function loadJpegStream(id, imageUrl, objs) {
  1380. var img = new Image();
  1381. img.onload = function loadJpegStream_onloadClosure() {
  1382. objs.resolve(id, img);
  1383. };
  1384. img.onerror = function loadJpegStream_onerrorClosure() {
  1385. objs.resolve(id, null);
  1386. warn('Error during JPEG image loading');
  1387. };
  1388. img.src = imageUrl;
  1389. }
  1390. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  1391. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  1392. exports.OPS = OPS;
  1393. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  1394. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  1395. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  1396. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  1397. exports.AnnotationFlag = AnnotationFlag;
  1398. exports.AnnotationType = AnnotationType;
  1399. exports.FontType = FontType;
  1400. exports.ImageKind = ImageKind;
  1401. exports.CMapCompressionType = CMapCompressionType;
  1402. exports.AbortException = AbortException;
  1403. exports.InvalidPDFException = InvalidPDFException;
  1404. exports.MessageHandler = MessageHandler;
  1405. exports.MissingDataException = MissingDataException;
  1406. exports.MissingPDFException = MissingPDFException;
  1407. exports.NativeImageDecoding = NativeImageDecoding;
  1408. exports.NotImplementedException = NotImplementedException;
  1409. exports.PageViewport = PageViewport;
  1410. exports.PasswordException = PasswordException;
  1411. exports.PasswordResponses = PasswordResponses;
  1412. exports.StatTimer = StatTimer;
  1413. exports.StreamType = StreamType;
  1414. exports.TextRenderingMode = TextRenderingMode;
  1415. exports.UnexpectedResponseException = UnexpectedResponseException;
  1416. exports.UnknownErrorException = UnknownErrorException;
  1417. exports.Util = Util;
  1418. exports.XRefParseException = XRefParseException;
  1419. exports.FormatError = FormatError;
  1420. exports.arrayByteLength = arrayByteLength;
  1421. exports.arraysToBytes = arraysToBytes;
  1422. exports.assert = assert;
  1423. exports.bytesToString = bytesToString;
  1424. exports.createBlob = createBlob;
  1425. exports.createPromiseCapability = createPromiseCapability;
  1426. exports.createObjectURL = createObjectURL;
  1427. exports.deprecated = deprecated;
  1428. exports.getLookupTableFactory = getLookupTableFactory;
  1429. exports.getVerbosityLevel = getVerbosityLevel;
  1430. exports.info = info;
  1431. exports.isArrayBuffer = isArrayBuffer;
  1432. exports.isBool = isBool;
  1433. exports.isEmptyObj = isEmptyObj;
  1434. exports.isNum = isNum;
  1435. exports.isString = isString;
  1436. exports.isSpace = isSpace;
  1437. exports.isNodeJS = isNodeJS;
  1438. exports.isSameOrigin = isSameOrigin;
  1439. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  1440. exports.isLittleEndian = isLittleEndian;
  1441. exports.isEvalSupported = isEvalSupported;
  1442. exports.loadJpegStream = loadJpegStream;
  1443. exports.log2 = log2;
  1444. exports.readInt8 = readInt8;
  1445. exports.readUint16 = readUint16;
  1446. exports.readUint32 = readUint32;
  1447. exports.removeNullCharacters = removeNullCharacters;
  1448. exports.ReadableStream = _streams_polyfill.ReadableStream;
  1449. exports.setVerbosityLevel = setVerbosityLevel;
  1450. exports.shadow = shadow;
  1451. exports.string32 = string32;
  1452. exports.stringToBytes = stringToBytes;
  1453. exports.stringToPDFString = stringToPDFString;
  1454. exports.stringToUTF8String = stringToUTF8String;
  1455. exports.utf8StringToString = utf8StringToString;
  1456. exports.warn = warn;
  1457. exports.unreachable = unreachable;
  1458. /***/ }),
  1459. /* 1 */
  1460. /***/ (function(module, exports, __w_pdfjs_require__) {
  1461. "use strict";
  1462. Object.defineProperty(exports, "__esModule", {
  1463. value: true
  1464. });
  1465. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  1466. var EOF = {};
  1467. var Name = function NameClosure() {
  1468. function Name(name) {
  1469. this.name = name;
  1470. }
  1471. Name.prototype = {};
  1472. var nameCache = Object.create(null);
  1473. Name.get = function Name_get(name) {
  1474. var nameValue = nameCache[name];
  1475. return nameValue ? nameValue : nameCache[name] = new Name(name);
  1476. };
  1477. return Name;
  1478. }();
  1479. var Cmd = function CmdClosure() {
  1480. function Cmd(cmd) {
  1481. this.cmd = cmd;
  1482. }
  1483. Cmd.prototype = {};
  1484. var cmdCache = Object.create(null);
  1485. Cmd.get = function Cmd_get(cmd) {
  1486. var cmdValue = cmdCache[cmd];
  1487. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  1488. };
  1489. return Cmd;
  1490. }();
  1491. var Dict = function DictClosure() {
  1492. var nonSerializable = function nonSerializableClosure() {
  1493. return nonSerializable;
  1494. };
  1495. function Dict(xref) {
  1496. this._map = Object.create(null);
  1497. this.xref = xref;
  1498. this.objId = null;
  1499. this.suppressEncryption = false;
  1500. this.__nonSerializable__ = nonSerializable;
  1501. }
  1502. Dict.prototype = {
  1503. assignXref: function Dict_assignXref(newXref) {
  1504. this.xref = newXref;
  1505. },
  1506. get: function Dict_get(key1, key2, key3) {
  1507. var value;
  1508. var xref = this.xref,
  1509. suppressEncryption = this.suppressEncryption;
  1510. if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
  1511. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1512. }
  1513. if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
  1514. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1515. }
  1516. value = this._map[key3] || null;
  1517. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  1518. },
  1519. getAsync: function Dict_getAsync(key1, key2, key3) {
  1520. var value;
  1521. var xref = this.xref,
  1522. suppressEncryption = this.suppressEncryption;
  1523. if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
  1524. if (xref) {
  1525. return xref.fetchIfRefAsync(value, suppressEncryption);
  1526. }
  1527. return Promise.resolve(value);
  1528. }
  1529. if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
  1530. if (xref) {
  1531. return xref.fetchIfRefAsync(value, suppressEncryption);
  1532. }
  1533. return Promise.resolve(value);
  1534. }
  1535. value = this._map[key3] || null;
  1536. if (xref) {
  1537. return xref.fetchIfRefAsync(value, suppressEncryption);
  1538. }
  1539. return Promise.resolve(value);
  1540. },
  1541. getArray: function Dict_getArray(key1, key2, key3) {
  1542. var value = this.get(key1, key2, key3);
  1543. var xref = this.xref,
  1544. suppressEncryption = this.suppressEncryption;
  1545. if (!Array.isArray(value) || !xref) {
  1546. return value;
  1547. }
  1548. value = value.slice();
  1549. for (var i = 0, ii = value.length; i < ii; i++) {
  1550. if (!isRef(value[i])) {
  1551. continue;
  1552. }
  1553. value[i] = xref.fetch(value[i], suppressEncryption);
  1554. }
  1555. return value;
  1556. },
  1557. getRaw: function Dict_getRaw(key) {
  1558. return this._map[key];
  1559. },
  1560. getKeys: function Dict_getKeys() {
  1561. return Object.keys(this._map);
  1562. },
  1563. set: function Dict_set(key, value) {
  1564. this._map[key] = value;
  1565. },
  1566. has: function Dict_has(key) {
  1567. return key in this._map;
  1568. },
  1569. forEach: function Dict_forEach(callback) {
  1570. for (var key in this._map) {
  1571. callback(key, this.get(key));
  1572. }
  1573. }
  1574. };
  1575. Dict.empty = new Dict(null);
  1576. Dict.merge = function (xref, dictArray) {
  1577. var mergedDict = new Dict(xref);
  1578. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  1579. var dict = dictArray[i];
  1580. if (!isDict(dict)) {
  1581. continue;
  1582. }
  1583. for (var keyName in dict._map) {
  1584. if (mergedDict._map[keyName] !== undefined) {
  1585. continue;
  1586. }
  1587. mergedDict._map[keyName] = dict._map[keyName];
  1588. }
  1589. }
  1590. return mergedDict;
  1591. };
  1592. return Dict;
  1593. }();
  1594. var Ref = function RefClosure() {
  1595. function Ref(num, gen) {
  1596. this.num = num;
  1597. this.gen = gen;
  1598. }
  1599. Ref.prototype = {
  1600. toString: function Ref_toString() {
  1601. var str = this.num + 'R';
  1602. if (this.gen !== 0) {
  1603. str += this.gen;
  1604. }
  1605. return str;
  1606. }
  1607. };
  1608. return Ref;
  1609. }();
  1610. var RefSet = function RefSetClosure() {
  1611. function RefSet() {
  1612. this.dict = Object.create(null);
  1613. }
  1614. RefSet.prototype = {
  1615. has: function RefSet_has(ref) {
  1616. return ref.toString() in this.dict;
  1617. },
  1618. put: function RefSet_put(ref) {
  1619. this.dict[ref.toString()] = true;
  1620. },
  1621. remove: function RefSet_remove(ref) {
  1622. delete this.dict[ref.toString()];
  1623. }
  1624. };
  1625. return RefSet;
  1626. }();
  1627. var RefSetCache = function RefSetCacheClosure() {
  1628. function RefSetCache() {
  1629. this.dict = Object.create(null);
  1630. }
  1631. RefSetCache.prototype = {
  1632. get: function RefSetCache_get(ref) {
  1633. return this.dict[ref.toString()];
  1634. },
  1635. has: function RefSetCache_has(ref) {
  1636. return ref.toString() in this.dict;
  1637. },
  1638. put: function RefSetCache_put(ref, obj) {
  1639. this.dict[ref.toString()] = obj;
  1640. },
  1641. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  1642. this.dict[ref.toString()] = this.get(aliasRef);
  1643. },
  1644. forEach: function RefSetCache_forEach(fn, thisArg) {
  1645. for (var i in this.dict) {
  1646. fn.call(thisArg, this.dict[i]);
  1647. }
  1648. },
  1649. clear: function RefSetCache_clear() {
  1650. this.dict = Object.create(null);
  1651. }
  1652. };
  1653. return RefSetCache;
  1654. }();
  1655. function isEOF(v) {
  1656. return v === EOF;
  1657. }
  1658. function isName(v, name) {
  1659. return v instanceof Name && (name === undefined || v.name === name);
  1660. }
  1661. function isCmd(v, cmd) {
  1662. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  1663. }
  1664. function isDict(v, type) {
  1665. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  1666. }
  1667. function isRef(v) {
  1668. return v instanceof Ref;
  1669. }
  1670. function isRefsEqual(v1, v2) {
  1671. return v1.num === v2.num && v1.gen === v2.gen;
  1672. }
  1673. function isStream(v) {
  1674. return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.getBytes !== undefined;
  1675. }
  1676. exports.EOF = EOF;
  1677. exports.Cmd = Cmd;
  1678. exports.Dict = Dict;
  1679. exports.Name = Name;
  1680. exports.Ref = Ref;
  1681. exports.RefSet = RefSet;
  1682. exports.RefSetCache = RefSetCache;
  1683. exports.isEOF = isEOF;
  1684. exports.isCmd = isCmd;
  1685. exports.isDict = isDict;
  1686. exports.isName = isName;
  1687. exports.isRef = isRef;
  1688. exports.isRefsEqual = isRefsEqual;
  1689. exports.isStream = isStream;
  1690. /***/ }),
  1691. /* 2 */
  1692. /***/ (function(module, exports, __w_pdfjs_require__) {
  1693. "use strict";
  1694. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  1695. module.exports = function (it) {
  1696. return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function';
  1697. };
  1698. /***/ }),
  1699. /* 3 */
  1700. /***/ (function(module, exports, __w_pdfjs_require__) {
  1701. "use strict";
  1702. var store = __w_pdfjs_require__(46)('wks');
  1703. var uid = __w_pdfjs_require__(22);
  1704. var _Symbol = __w_pdfjs_require__(4).Symbol;
  1705. var USE_SYMBOL = typeof _Symbol == 'function';
  1706. var $exports = module.exports = function (name) {
  1707. return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name));
  1708. };
  1709. $exports.store = store;
  1710. /***/ }),
  1711. /* 4 */
  1712. /***/ (function(module, exports, __w_pdfjs_require__) {
  1713. "use strict";
  1714. var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  1715. if (typeof __g == 'number') __g = global;
  1716. /***/ }),
  1717. /* 5 */
  1718. /***/ (function(module, exports, __w_pdfjs_require__) {
  1719. "use strict";
  1720. Object.defineProperty(exports, "__esModule", {
  1721. value: true
  1722. });
  1723. exports.LZWStream = exports.StringStream = exports.StreamsSequenceStream = exports.Stream = exports.RunLengthStream = exports.PredictorStream = exports.NullStream = exports.JpxStream = exports.JpegStream = exports.FlateStream = exports.DecodeStream = exports.DecryptStream = exports.AsciiHexStream = exports.Ascii85Stream = undefined;
  1724. var _util = __w_pdfjs_require__(0);
  1725. var _primitives = __w_pdfjs_require__(1);
  1726. var _jpg = __w_pdfjs_require__(124);
  1727. var _jpx = __w_pdfjs_require__(63);
  1728. var Stream = function StreamClosure() {
  1729. function Stream(arrayBuffer, start, length, dict) {
  1730. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  1731. this.start = start || 0;
  1732. this.pos = this.start;
  1733. this.end = start + length || this.bytes.length;
  1734. this.dict = dict;
  1735. }
  1736. Stream.prototype = {
  1737. get length() {
  1738. return this.end - this.start;
  1739. },
  1740. get isEmpty() {
  1741. return this.length === 0;
  1742. },
  1743. getByte: function Stream_getByte() {
  1744. if (this.pos >= this.end) {
  1745. return -1;
  1746. }
  1747. return this.bytes[this.pos++];
  1748. },
  1749. getUint16: function Stream_getUint16() {
  1750. var b0 = this.getByte();
  1751. var b1 = this.getByte();
  1752. if (b0 === -1 || b1 === -1) {
  1753. return -1;
  1754. }
  1755. return (b0 << 8) + b1;
  1756. },
  1757. getInt32: function Stream_getInt32() {
  1758. var b0 = this.getByte();
  1759. var b1 = this.getByte();
  1760. var b2 = this.getByte();
  1761. var b3 = this.getByte();
  1762. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1763. },
  1764. getBytes: function Stream_getBytes(length) {
  1765. var bytes = this.bytes;
  1766. var pos = this.pos;
  1767. var strEnd = this.end;
  1768. if (!length) {
  1769. return bytes.subarray(pos, strEnd);
  1770. }
  1771. var end = pos + length;
  1772. if (end > strEnd) {
  1773. end = strEnd;
  1774. }
  1775. this.pos = end;
  1776. return bytes.subarray(pos, end);
  1777. },
  1778. peekByte: function Stream_peekByte() {
  1779. var peekedByte = this.getByte();
  1780. this.pos--;
  1781. return peekedByte;
  1782. },
  1783. peekBytes: function Stream_peekBytes(length) {
  1784. var bytes = this.getBytes(length);
  1785. this.pos -= bytes.length;
  1786. return bytes;
  1787. },
  1788. skip: function Stream_skip(n) {
  1789. if (!n) {
  1790. n = 1;
  1791. }
  1792. this.pos += n;
  1793. },
  1794. reset: function Stream_reset() {
  1795. this.pos = this.start;
  1796. },
  1797. moveStart: function Stream_moveStart() {
  1798. this.start = this.pos;
  1799. },
  1800. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  1801. return new Stream(this.bytes.buffer, start, length, dict);
  1802. }
  1803. };
  1804. return Stream;
  1805. }();
  1806. var StringStream = function StringStreamClosure() {
  1807. function StringStream(str) {
  1808. var bytes = (0, _util.stringToBytes)(str);
  1809. Stream.call(this, bytes);
  1810. }
  1811. StringStream.prototype = Stream.prototype;
  1812. return StringStream;
  1813. }();
  1814. var DecodeStream = function DecodeStreamClosure() {
  1815. var emptyBuffer = new Uint8Array(0);
  1816. function DecodeStream(maybeMinBufferLength) {
  1817. this.pos = 0;
  1818. this.bufferLength = 0;
  1819. this.eof = false;
  1820. this.buffer = emptyBuffer;
  1821. this.minBufferLength = 512;
  1822. if (maybeMinBufferLength) {
  1823. while (this.minBufferLength < maybeMinBufferLength) {
  1824. this.minBufferLength *= 2;
  1825. }
  1826. }
  1827. }
  1828. DecodeStream.prototype = {
  1829. get isEmpty() {
  1830. while (!this.eof && this.bufferLength === 0) {
  1831. this.readBlock();
  1832. }
  1833. return this.bufferLength === 0;
  1834. },
  1835. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  1836. var buffer = this.buffer;
  1837. if (requested <= buffer.byteLength) {
  1838. return buffer;
  1839. }
  1840. var size = this.minBufferLength;
  1841. while (size < requested) {
  1842. size *= 2;
  1843. }
  1844. var buffer2 = new Uint8Array(size);
  1845. buffer2.set(buffer);
  1846. return this.buffer = buffer2;
  1847. },
  1848. getByte: function DecodeStream_getByte() {
  1849. var pos = this.pos;
  1850. while (this.bufferLength <= pos) {
  1851. if (this.eof) {
  1852. return -1;
  1853. }
  1854. this.readBlock();
  1855. }
  1856. return this.buffer[this.pos++];
  1857. },
  1858. getUint16: function DecodeStream_getUint16() {
  1859. var b0 = this.getByte();
  1860. var b1 = this.getByte();
  1861. if (b0 === -1 || b1 === -1) {
  1862. return -1;
  1863. }
  1864. return (b0 << 8) + b1;
  1865. },
  1866. getInt32: function DecodeStream_getInt32() {
  1867. var b0 = this.getByte();
  1868. var b1 = this.getByte();
  1869. var b2 = this.getByte();
  1870. var b3 = this.getByte();
  1871. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  1872. },
  1873. getBytes: function DecodeStream_getBytes(length) {
  1874. var end,
  1875. pos = this.pos;
  1876. if (length) {
  1877. this.ensureBuffer(pos + length);
  1878. end = pos + length;
  1879. while (!this.eof && this.bufferLength < end) {
  1880. this.readBlock();
  1881. }
  1882. var bufEnd = this.bufferLength;
  1883. if (end > bufEnd) {
  1884. end = bufEnd;
  1885. }
  1886. } else {
  1887. while (!this.eof) {
  1888. this.readBlock();
  1889. }
  1890. end = this.bufferLength;
  1891. }
  1892. this.pos = end;
  1893. return this.buffer.subarray(pos, end);
  1894. },
  1895. peekByte: function DecodeStream_peekByte() {
  1896. var peekedByte = this.getByte();
  1897. this.pos--;
  1898. return peekedByte;
  1899. },
  1900. peekBytes: function DecodeStream_peekBytes(length) {
  1901. var bytes = this.getBytes(length);
  1902. this.pos -= bytes.length;
  1903. return bytes;
  1904. },
  1905. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  1906. var end = start + length;
  1907. while (this.bufferLength <= end && !this.eof) {
  1908. this.readBlock();
  1909. }
  1910. return new Stream(this.buffer, start, length, dict);
  1911. },
  1912. skip: function DecodeStream_skip(n) {
  1913. if (!n) {
  1914. n = 1;
  1915. }
  1916. this.pos += n;
  1917. },
  1918. reset: function DecodeStream_reset() {
  1919. this.pos = 0;
  1920. },
  1921. getBaseStreams: function DecodeStream_getBaseStreams() {
  1922. if (this.str && this.str.getBaseStreams) {
  1923. return this.str.getBaseStreams();
  1924. }
  1925. return [];
  1926. }
  1927. };
  1928. return DecodeStream;
  1929. }();
  1930. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  1931. function StreamsSequenceStream(streams) {
  1932. this.streams = streams;
  1933. DecodeStream.call(this, null);
  1934. }
  1935. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  1936. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  1937. var streams = this.streams;
  1938. if (streams.length === 0) {
  1939. this.eof = true;
  1940. return;
  1941. }
  1942. var stream = streams.shift();
  1943. var chunk = stream.getBytes();
  1944. var bufferLength = this.bufferLength;
  1945. var newLength = bufferLength + chunk.length;
  1946. var buffer = this.ensureBuffer(newLength);
  1947. buffer.set(chunk, bufferLength);
  1948. this.bufferLength = newLength;
  1949. };
  1950. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  1951. var baseStreams = [];
  1952. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  1953. var stream = this.streams[i];
  1954. if (stream.getBaseStreams) {
  1955. _util.Util.appendToArray(baseStreams, stream.getBaseStreams());
  1956. }
  1957. }
  1958. return baseStreams;
  1959. };
  1960. return StreamsSequenceStream;
  1961. }();
  1962. var FlateStream = function FlateStreamClosure() {
  1963. var codeLenCodeMap = new Int32Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
  1964. var lengthDecode = new Int32Array([0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a, 0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f, 0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073, 0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102]);
  1965. var distDecode = new Int32Array([0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d, 0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1, 0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01, 0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001]);
  1966. var fixedLitCodeTab = [new Int32Array([0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0, 0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0, 0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0, 0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8, 0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8, 0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8, 0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4, 0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4, 0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4, 0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc, 0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec, 0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc, 0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2, 0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2, 0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2, 0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca, 0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea, 0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da, 0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6, 0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6, 0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6, 0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce, 0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee, 0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de, 0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe, 0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1, 0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1, 0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1, 0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1, 0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9, 0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9, 0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9, 0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9, 0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5, 0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5, 0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5, 0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5, 0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd, 0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed, 0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd, 0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd, 0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3, 0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3, 0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3, 0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3, 0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb, 0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb, 0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db, 0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb, 0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7, 0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7, 0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7, 0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7, 0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf, 0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef, 0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df, 0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff]), 9];
  1967. var fixedDistCodeTab = [new Int32Array([0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c, 0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000, 0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d, 0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000]), 5];
  1968. function FlateStream(str, maybeLength) {
  1969. this.str = str;
  1970. this.dict = str.dict;
  1971. var cmf = str.getByte();
  1972. var flg = str.getByte();
  1973. if (cmf === -1 || flg === -1) {
  1974. throw new _util.FormatError('Invalid header in flate stream: ' + cmf + ', ' + flg);
  1975. }
  1976. if ((cmf & 0x0f) !== 0x08) {
  1977. throw new _util.FormatError('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  1978. }
  1979. if (((cmf << 8) + flg) % 31 !== 0) {
  1980. throw new _util.FormatError('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  1981. }
  1982. if (flg & 0x20) {
  1983. throw new _util.FormatError('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  1984. }
  1985. this.codeSize = 0;
  1986. this.codeBuf = 0;
  1987. DecodeStream.call(this, maybeLength);
  1988. }
  1989. FlateStream.prototype = Object.create(DecodeStream.prototype);
  1990. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  1991. var str = this.str;
  1992. var codeSize = this.codeSize;
  1993. var codeBuf = this.codeBuf;
  1994. var b;
  1995. while (codeSize < bits) {
  1996. if ((b = str.getByte()) === -1) {
  1997. throw new _util.FormatError('Bad encoding in flate stream');
  1998. }
  1999. codeBuf |= b << codeSize;
  2000. codeSize += 8;
  2001. }
  2002. b = codeBuf & (1 << bits) - 1;
  2003. this.codeBuf = codeBuf >> bits;
  2004. this.codeSize = codeSize -= bits;
  2005. return b;
  2006. };
  2007. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  2008. var str = this.str;
  2009. var codes = table[0];
  2010. var maxLen = table[1];
  2011. var codeSize = this.codeSize;
  2012. var codeBuf = this.codeBuf;
  2013. var b;
  2014. while (codeSize < maxLen) {
  2015. if ((b = str.getByte()) === -1) {
  2016. break;
  2017. }
  2018. codeBuf |= b << codeSize;
  2019. codeSize += 8;
  2020. }
  2021. var code = codes[codeBuf & (1 << maxLen) - 1];
  2022. var codeLen = code >> 16;
  2023. var codeVal = code & 0xffff;
  2024. if (codeLen < 1 || codeSize < codeLen) {
  2025. throw new _util.FormatError('Bad encoding in flate stream');
  2026. }
  2027. this.codeBuf = codeBuf >> codeLen;
  2028. this.codeSize = codeSize - codeLen;
  2029. return codeVal;
  2030. };
  2031. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  2032. var n = lengths.length;
  2033. var maxLen = 0;
  2034. var i;
  2035. for (i = 0; i < n; ++i) {
  2036. if (lengths[i] > maxLen) {
  2037. maxLen = lengths[i];
  2038. }
  2039. }
  2040. var size = 1 << maxLen;
  2041. var codes = new Int32Array(size);
  2042. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  2043. for (var val = 0; val < n; ++val) {
  2044. if (lengths[val] === len) {
  2045. var code2 = 0;
  2046. var t = code;
  2047. for (i = 0; i < len; ++i) {
  2048. code2 = code2 << 1 | t & 1;
  2049. t >>= 1;
  2050. }
  2051. for (i = code2; i < size; i += skip) {
  2052. codes[i] = len << 16 | val;
  2053. }
  2054. ++code;
  2055. }
  2056. }
  2057. }
  2058. return [codes, maxLen];
  2059. };
  2060. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  2061. var buffer, len;
  2062. var str = this.str;
  2063. var hdr = this.getBits(3);
  2064. if (hdr & 1) {
  2065. this.eof = true;
  2066. }
  2067. hdr >>= 1;
  2068. if (hdr === 0) {
  2069. var b;
  2070. if ((b = str.getByte()) === -1) {
  2071. throw new _util.FormatError('Bad block header in flate stream');
  2072. }
  2073. var blockLen = b;
  2074. if ((b = str.getByte()) === -1) {
  2075. throw new _util.FormatError('Bad block header in flate stream');
  2076. }
  2077. blockLen |= b << 8;
  2078. if ((b = str.getByte()) === -1) {
  2079. throw new _util.FormatError('Bad block header in flate stream');
  2080. }
  2081. var check = b;
  2082. if ((b = str.getByte()) === -1) {
  2083. throw new _util.FormatError('Bad block header in flate stream');
  2084. }
  2085. check |= b << 8;
  2086. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  2087. throw new _util.FormatError('Bad uncompressed block length in flate stream');
  2088. }
  2089. this.codeBuf = 0;
  2090. this.codeSize = 0;
  2091. var bufferLength = this.bufferLength;
  2092. buffer = this.ensureBuffer(bufferLength + blockLen);
  2093. var end = bufferLength + blockLen;
  2094. this.bufferLength = end;
  2095. if (blockLen === 0) {
  2096. if (str.peekByte() === -1) {
  2097. this.eof = true;
  2098. }
  2099. } else {
  2100. for (var n = bufferLength; n < end; ++n) {
  2101. if ((b = str.getByte()) === -1) {
  2102. this.eof = true;
  2103. break;
  2104. }
  2105. buffer[n] = b;
  2106. }
  2107. }
  2108. return;
  2109. }
  2110. var litCodeTable;
  2111. var distCodeTable;
  2112. if (hdr === 1) {
  2113. litCodeTable = fixedLitCodeTab;
  2114. distCodeTable = fixedDistCodeTab;
  2115. } else if (hdr === 2) {
  2116. var numLitCodes = this.getBits(5) + 257;
  2117. var numDistCodes = this.getBits(5) + 1;
  2118. var numCodeLenCodes = this.getBits(4) + 4;
  2119. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  2120. var i;
  2121. for (i = 0; i < numCodeLenCodes; ++i) {
  2122. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  2123. }
  2124. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  2125. len = 0;
  2126. i = 0;
  2127. var codes = numLitCodes + numDistCodes;
  2128. var codeLengths = new Uint8Array(codes);
  2129. var bitsLength, bitsOffset, what;
  2130. while (i < codes) {
  2131. var code = this.getCode(codeLenCodeTab);
  2132. if (code === 16) {
  2133. bitsLength = 2;
  2134. bitsOffset = 3;
  2135. what = len;
  2136. } else if (code === 17) {
  2137. bitsLength = 3;
  2138. bitsOffset = 3;
  2139. what = len = 0;
  2140. } else if (code === 18) {
  2141. bitsLength = 7;
  2142. bitsOffset = 11;
  2143. what = len = 0;
  2144. } else {
  2145. codeLengths[i++] = len = code;
  2146. continue;
  2147. }
  2148. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  2149. while (repeatLength-- > 0) {
  2150. codeLengths[i++] = what;
  2151. }
  2152. }
  2153. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  2154. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  2155. } else {
  2156. throw new _util.FormatError('Unknown block type in flate stream');
  2157. }
  2158. buffer = this.buffer;
  2159. var limit = buffer ? buffer.length : 0;
  2160. var pos = this.bufferLength;
  2161. while (true) {
  2162. var code1 = this.getCode(litCodeTable);
  2163. if (code1 < 256) {
  2164. if (pos + 1 >= limit) {
  2165. buffer = this.ensureBuffer(pos + 1);
  2166. limit = buffer.length;
  2167. }
  2168. buffer[pos++] = code1;
  2169. continue;
  2170. }
  2171. if (code1 === 256) {
  2172. this.bufferLength = pos;
  2173. return;
  2174. }
  2175. code1 -= 257;
  2176. code1 = lengthDecode[code1];
  2177. var code2 = code1 >> 16;
  2178. if (code2 > 0) {
  2179. code2 = this.getBits(code2);
  2180. }
  2181. len = (code1 & 0xffff) + code2;
  2182. code1 = this.getCode(distCodeTable);
  2183. code1 = distDecode[code1];
  2184. code2 = code1 >> 16;
  2185. if (code2 > 0) {
  2186. code2 = this.getBits(code2);
  2187. }
  2188. var dist = (code1 & 0xffff) + code2;
  2189. if (pos + len >= limit) {
  2190. buffer = this.ensureBuffer(pos + len);
  2191. limit = buffer.length;
  2192. }
  2193. for (var k = 0; k < len; ++k, ++pos) {
  2194. buffer[pos] = buffer[pos - dist];
  2195. }
  2196. }
  2197. };
  2198. return FlateStream;
  2199. }();
  2200. var PredictorStream = function PredictorStreamClosure() {
  2201. function PredictorStream(str, maybeLength, params) {
  2202. if (!(0, _primitives.isDict)(params)) {
  2203. return str;
  2204. }
  2205. var predictor = this.predictor = params.get('Predictor') || 1;
  2206. if (predictor <= 1) {
  2207. return str;
  2208. }
  2209. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  2210. throw new _util.FormatError('Unsupported predictor: ' + predictor);
  2211. }
  2212. if (predictor === 2) {
  2213. this.readBlock = this.readBlockTiff;
  2214. } else {
  2215. this.readBlock = this.readBlockPng;
  2216. }
  2217. this.str = str;
  2218. this.dict = str.dict;
  2219. var colors = this.colors = params.get('Colors') || 1;
  2220. var bits = this.bits = params.get('BitsPerComponent') || 8;
  2221. var columns = this.columns = params.get('Columns') || 1;
  2222. this.pixBytes = colors * bits + 7 >> 3;
  2223. this.rowBytes = columns * colors * bits + 7 >> 3;
  2224. DecodeStream.call(this, maybeLength);
  2225. return this;
  2226. }
  2227. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  2228. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  2229. var rowBytes = this.rowBytes;
  2230. var bufferLength = this.bufferLength;
  2231. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2232. var bits = this.bits;
  2233. var colors = this.colors;
  2234. var rawBytes = this.str.getBytes(rowBytes);
  2235. this.eof = !rawBytes.length;
  2236. if (this.eof) {
  2237. return;
  2238. }
  2239. var inbuf = 0,
  2240. outbuf = 0;
  2241. var inbits = 0,
  2242. outbits = 0;
  2243. var pos = bufferLength;
  2244. var i;
  2245. if (bits === 1 && colors === 1) {
  2246. for (i = 0; i < rowBytes; ++i) {
  2247. var c = rawBytes[i] ^ inbuf;
  2248. c ^= c >> 1;
  2249. c ^= c >> 2;
  2250. c ^= c >> 4;
  2251. inbuf = (c & 1) << 7;
  2252. buffer[pos++] = c;
  2253. }
  2254. } else if (bits === 8) {
  2255. for (i = 0; i < colors; ++i) {
  2256. buffer[pos++] = rawBytes[i];
  2257. }
  2258. for (; i < rowBytes; ++i) {
  2259. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  2260. pos++;
  2261. }
  2262. } else if (bits === 16) {
  2263. var bytesPerPixel = colors * 2;
  2264. for (i = 0; i < bytesPerPixel; ++i) {
  2265. buffer[pos++] = rawBytes[i];
  2266. }
  2267. for (; i < rowBytes; i += 2) {
  2268. var sum = ((rawBytes[i] & 0xFF) << 8) + (rawBytes[i + 1] & 0xFF) + ((buffer[pos - bytesPerPixel] & 0xFF) << 8) + (buffer[pos - bytesPerPixel + 1] & 0xFF);
  2269. buffer[pos++] = sum >> 8 & 0xFF;
  2270. buffer[pos++] = sum & 0xFF;
  2271. }
  2272. } else {
  2273. var compArray = new Uint8Array(colors + 1);
  2274. var bitMask = (1 << bits) - 1;
  2275. var j = 0,
  2276. k = bufferLength;
  2277. var columns = this.columns;
  2278. for (i = 0; i < columns; ++i) {
  2279. for (var kk = 0; kk < colors; ++kk) {
  2280. if (inbits < bits) {
  2281. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  2282. inbits += 8;
  2283. }
  2284. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  2285. inbits -= bits;
  2286. outbuf = outbuf << bits | compArray[kk];
  2287. outbits += bits;
  2288. if (outbits >= 8) {
  2289. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  2290. outbits -= 8;
  2291. }
  2292. }
  2293. }
  2294. if (outbits > 0) {
  2295. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  2296. }
  2297. }
  2298. this.bufferLength += rowBytes;
  2299. };
  2300. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  2301. var rowBytes = this.rowBytes;
  2302. var pixBytes = this.pixBytes;
  2303. var predictor = this.str.getByte();
  2304. var rawBytes = this.str.getBytes(rowBytes);
  2305. this.eof = !rawBytes.length;
  2306. if (this.eof) {
  2307. return;
  2308. }
  2309. var bufferLength = this.bufferLength;
  2310. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  2311. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  2312. if (prevRow.length === 0) {
  2313. prevRow = new Uint8Array(rowBytes);
  2314. }
  2315. var i,
  2316. j = bufferLength,
  2317. up,
  2318. c;
  2319. switch (predictor) {
  2320. case 0:
  2321. for (i = 0; i < rowBytes; ++i) {
  2322. buffer[j++] = rawBytes[i];
  2323. }
  2324. break;
  2325. case 1:
  2326. for (i = 0; i < pixBytes; ++i) {
  2327. buffer[j++] = rawBytes[i];
  2328. }
  2329. for (; i < rowBytes; ++i) {
  2330. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  2331. j++;
  2332. }
  2333. break;
  2334. case 2:
  2335. for (i = 0; i < rowBytes; ++i) {
  2336. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  2337. }
  2338. break;
  2339. case 3:
  2340. for (i = 0; i < pixBytes; ++i) {
  2341. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  2342. }
  2343. for (; i < rowBytes; ++i) {
  2344. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  2345. j++;
  2346. }
  2347. break;
  2348. case 4:
  2349. for (i = 0; i < pixBytes; ++i) {
  2350. up = prevRow[i];
  2351. c = rawBytes[i];
  2352. buffer[j++] = up + c;
  2353. }
  2354. for (; i < rowBytes; ++i) {
  2355. up = prevRow[i];
  2356. var upLeft = prevRow[i - pixBytes];
  2357. var left = buffer[j - pixBytes];
  2358. var p = left + up - upLeft;
  2359. var pa = p - left;
  2360. if (pa < 0) {
  2361. pa = -pa;
  2362. }
  2363. var pb = p - up;
  2364. if (pb < 0) {
  2365. pb = -pb;
  2366. }
  2367. var pc = p - upLeft;
  2368. if (pc < 0) {
  2369. pc = -pc;
  2370. }
  2371. c = rawBytes[i];
  2372. if (pa <= pb && pa <= pc) {
  2373. buffer[j++] = left + c;
  2374. } else if (pb <= pc) {
  2375. buffer[j++] = up + c;
  2376. } else {
  2377. buffer[j++] = upLeft + c;
  2378. }
  2379. }
  2380. break;
  2381. default:
  2382. throw new _util.FormatError('Unsupported predictor: ' + predictor);
  2383. }
  2384. this.bufferLength += rowBytes;
  2385. };
  2386. return PredictorStream;
  2387. }();
  2388. var JpegStream = function JpegStreamClosure() {
  2389. function JpegStream(stream, maybeLength, dict, params) {
  2390. var ch;
  2391. while ((ch = stream.getByte()) !== -1) {
  2392. if (ch === 0xFF) {
  2393. stream.skip(-1);
  2394. break;
  2395. }
  2396. }
  2397. this.stream = stream;
  2398. this.maybeLength = maybeLength;
  2399. this.dict = dict;
  2400. this.params = params;
  2401. DecodeStream.call(this, maybeLength);
  2402. }
  2403. JpegStream.prototype = Object.create(DecodeStream.prototype);
  2404. Object.defineProperty(JpegStream.prototype, 'bytes', {
  2405. get: function JpegStream_bytes() {
  2406. return (0, _util.shadow)(this, 'bytes', this.stream.getBytes(this.maybeLength));
  2407. },
  2408. configurable: true
  2409. });
  2410. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  2411. if (this.bufferLength) {
  2412. return;
  2413. }
  2414. var jpegImage = new _jpg.JpegImage();
  2415. var decodeArr = this.dict.getArray('Decode', 'D');
  2416. if (this.forceRGB && Array.isArray(decodeArr)) {
  2417. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  2418. var decodeArrLength = decodeArr.length;
  2419. var transform = new Int32Array(decodeArrLength);
  2420. var transformNeeded = false;
  2421. var maxValue = (1 << bitsPerComponent) - 1;
  2422. for (var i = 0; i < decodeArrLength; i += 2) {
  2423. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  2424. transform[i + 1] = decodeArr[i] * maxValue | 0;
  2425. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  2426. transformNeeded = true;
  2427. }
  2428. }
  2429. if (transformNeeded) {
  2430. jpegImage.decodeTransform = transform;
  2431. }
  2432. }
  2433. if ((0, _primitives.isDict)(this.params)) {
  2434. var colorTransform = this.params.get('ColorTransform');
  2435. if (Number.isInteger(colorTransform)) {
  2436. jpegImage.colorTransform = colorTransform;
  2437. }
  2438. }
  2439. jpegImage.parse(this.bytes);
  2440. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  2441. this.buffer = data;
  2442. this.bufferLength = data.length;
  2443. this.eof = true;
  2444. };
  2445. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  2446. this.ensureBuffer();
  2447. return this.buffer;
  2448. };
  2449. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  2450. return (0, _util.createObjectURL)(this.bytes, 'image/jpeg', forceDataSchema);
  2451. };
  2452. return JpegStream;
  2453. }();
  2454. var JpxStream = function JpxStreamClosure() {
  2455. function JpxStream(stream, maybeLength, dict, params) {
  2456. this.stream = stream;
  2457. this.maybeLength = maybeLength;
  2458. this.dict = dict;
  2459. this.params = params;
  2460. DecodeStream.call(this, maybeLength);
  2461. }
  2462. JpxStream.prototype = Object.create(DecodeStream.prototype);
  2463. Object.defineProperty(JpxStream.prototype, 'bytes', {
  2464. get: function JpxStream_bytes() {
  2465. return (0, _util.shadow)(this, 'bytes', this.stream.getBytes(this.maybeLength));
  2466. },
  2467. configurable: true
  2468. });
  2469. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  2470. if (this.bufferLength) {
  2471. return;
  2472. }
  2473. var jpxImage = new _jpx.JpxImage();
  2474. jpxImage.parse(this.bytes);
  2475. var width = jpxImage.width;
  2476. var height = jpxImage.height;
  2477. var componentsCount = jpxImage.componentsCount;
  2478. var tileCount = jpxImage.tiles.length;
  2479. if (tileCount === 1) {
  2480. this.buffer = jpxImage.tiles[0].items;
  2481. } else {
  2482. var data = new Uint8ClampedArray(width * height * componentsCount);
  2483. for (var k = 0; k < tileCount; k++) {
  2484. var tileComponents = jpxImage.tiles[k];
  2485. var tileWidth = tileComponents.width;
  2486. var tileHeight = tileComponents.height;
  2487. var tileLeft = tileComponents.left;
  2488. var tileTop = tileComponents.top;
  2489. var src = tileComponents.items;
  2490. var srcPosition = 0;
  2491. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  2492. var imgRowSize = width * componentsCount;
  2493. var tileRowSize = tileWidth * componentsCount;
  2494. for (var j = 0; j < tileHeight; j++) {
  2495. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  2496. data.set(rowBytes, dataPosition);
  2497. srcPosition += tileRowSize;
  2498. dataPosition += imgRowSize;
  2499. }
  2500. }
  2501. this.buffer = data;
  2502. }
  2503. this.bufferLength = this.buffer.length;
  2504. this.eof = true;
  2505. };
  2506. return JpxStream;
  2507. }();
  2508. var DecryptStream = function DecryptStreamClosure() {
  2509. function DecryptStream(str, maybeLength, decrypt) {
  2510. this.str = str;
  2511. this.dict = str.dict;
  2512. this.decrypt = decrypt;
  2513. this.nextChunk = null;
  2514. this.initialized = false;
  2515. DecodeStream.call(this, maybeLength);
  2516. }
  2517. var chunkSize = 512;
  2518. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  2519. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  2520. var chunk;
  2521. if (this.initialized) {
  2522. chunk = this.nextChunk;
  2523. } else {
  2524. chunk = this.str.getBytes(chunkSize);
  2525. this.initialized = true;
  2526. }
  2527. if (!chunk || chunk.length === 0) {
  2528. this.eof = true;
  2529. return;
  2530. }
  2531. this.nextChunk = this.str.getBytes(chunkSize);
  2532. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  2533. var decrypt = this.decrypt;
  2534. chunk = decrypt(chunk, !hasMoreData);
  2535. var bufferLength = this.bufferLength;
  2536. var i,
  2537. n = chunk.length;
  2538. var buffer = this.ensureBuffer(bufferLength + n);
  2539. for (i = 0; i < n; i++) {
  2540. buffer[bufferLength++] = chunk[i];
  2541. }
  2542. this.bufferLength = bufferLength;
  2543. };
  2544. return DecryptStream;
  2545. }();
  2546. var Ascii85Stream = function Ascii85StreamClosure() {
  2547. function Ascii85Stream(str, maybeLength) {
  2548. this.str = str;
  2549. this.dict = str.dict;
  2550. this.input = new Uint8Array(5);
  2551. if (maybeLength) {
  2552. maybeLength = 0.8 * maybeLength;
  2553. }
  2554. DecodeStream.call(this, maybeLength);
  2555. }
  2556. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  2557. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  2558. var TILDA_CHAR = 0x7E;
  2559. var Z_LOWER_CHAR = 0x7A;
  2560. var EOF = -1;
  2561. var str = this.str;
  2562. var c = str.getByte();
  2563. while ((0, _util.isSpace)(c)) {
  2564. c = str.getByte();
  2565. }
  2566. if (c === EOF || c === TILDA_CHAR) {
  2567. this.eof = true;
  2568. return;
  2569. }
  2570. var bufferLength = this.bufferLength,
  2571. buffer;
  2572. var i;
  2573. if (c === Z_LOWER_CHAR) {
  2574. buffer = this.ensureBuffer(bufferLength + 4);
  2575. for (i = 0; i < 4; ++i) {
  2576. buffer[bufferLength + i] = 0;
  2577. }
  2578. this.bufferLength += 4;
  2579. } else {
  2580. var input = this.input;
  2581. input[0] = c;
  2582. for (i = 1; i < 5; ++i) {
  2583. c = str.getByte();
  2584. while ((0, _util.isSpace)(c)) {
  2585. c = str.getByte();
  2586. }
  2587. input[i] = c;
  2588. if (c === EOF || c === TILDA_CHAR) {
  2589. break;
  2590. }
  2591. }
  2592. buffer = this.ensureBuffer(bufferLength + i - 1);
  2593. this.bufferLength += i - 1;
  2594. if (i < 5) {
  2595. for (; i < 5; ++i) {
  2596. input[i] = 0x21 + 84;
  2597. }
  2598. this.eof = true;
  2599. }
  2600. var t = 0;
  2601. for (i = 0; i < 5; ++i) {
  2602. t = t * 85 + (input[i] - 0x21);
  2603. }
  2604. for (i = 3; i >= 0; --i) {
  2605. buffer[bufferLength + i] = t & 0xFF;
  2606. t >>= 8;
  2607. }
  2608. }
  2609. };
  2610. return Ascii85Stream;
  2611. }();
  2612. var AsciiHexStream = function AsciiHexStreamClosure() {
  2613. function AsciiHexStream(str, maybeLength) {
  2614. this.str = str;
  2615. this.dict = str.dict;
  2616. this.firstDigit = -1;
  2617. if (maybeLength) {
  2618. maybeLength = 0.5 * maybeLength;
  2619. }
  2620. DecodeStream.call(this, maybeLength);
  2621. }
  2622. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  2623. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  2624. var UPSTREAM_BLOCK_SIZE = 8000;
  2625. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  2626. if (!bytes.length) {
  2627. this.eof = true;
  2628. return;
  2629. }
  2630. var maxDecodeLength = bytes.length + 1 >> 1;
  2631. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  2632. var bufferLength = this.bufferLength;
  2633. var firstDigit = this.firstDigit;
  2634. for (var i = 0, ii = bytes.length; i < ii; i++) {
  2635. var ch = bytes[i],
  2636. digit;
  2637. if (ch >= 0x30 && ch <= 0x39) {
  2638. digit = ch & 0x0F;
  2639. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  2640. digit = (ch & 0x0F) + 9;
  2641. } else if (ch === 0x3E) {
  2642. this.eof = true;
  2643. break;
  2644. } else {
  2645. continue;
  2646. }
  2647. if (firstDigit < 0) {
  2648. firstDigit = digit;
  2649. } else {
  2650. buffer[bufferLength++] = firstDigit << 4 | digit;
  2651. firstDigit = -1;
  2652. }
  2653. }
  2654. if (firstDigit >= 0 && this.eof) {
  2655. buffer[bufferLength++] = firstDigit << 4;
  2656. firstDigit = -1;
  2657. }
  2658. this.firstDigit = firstDigit;
  2659. this.bufferLength = bufferLength;
  2660. };
  2661. return AsciiHexStream;
  2662. }();
  2663. var RunLengthStream = function RunLengthStreamClosure() {
  2664. function RunLengthStream(str, maybeLength) {
  2665. this.str = str;
  2666. this.dict = str.dict;
  2667. DecodeStream.call(this, maybeLength);
  2668. }
  2669. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  2670. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  2671. var repeatHeader = this.str.getBytes(2);
  2672. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  2673. this.eof = true;
  2674. return;
  2675. }
  2676. var buffer;
  2677. var bufferLength = this.bufferLength;
  2678. var n = repeatHeader[0];
  2679. if (n < 128) {
  2680. buffer = this.ensureBuffer(bufferLength + n + 1);
  2681. buffer[bufferLength++] = repeatHeader[1];
  2682. if (n > 0) {
  2683. var source = this.str.getBytes(n);
  2684. buffer.set(source, bufferLength);
  2685. bufferLength += n;
  2686. }
  2687. } else {
  2688. n = 257 - n;
  2689. var b = repeatHeader[1];
  2690. buffer = this.ensureBuffer(bufferLength + n + 1);
  2691. for (var i = 0; i < n; i++) {
  2692. buffer[bufferLength++] = b;
  2693. }
  2694. }
  2695. this.bufferLength = bufferLength;
  2696. };
  2697. return RunLengthStream;
  2698. }();
  2699. var LZWStream = function LZWStreamClosure() {
  2700. function LZWStream(str, maybeLength, earlyChange) {
  2701. this.str = str;
  2702. this.dict = str.dict;
  2703. this.cachedData = 0;
  2704. this.bitsCached = 0;
  2705. var maxLzwDictionarySize = 4096;
  2706. var lzwState = {
  2707. earlyChange: earlyChange,
  2708. codeLength: 9,
  2709. nextCode: 258,
  2710. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  2711. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  2712. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  2713. currentSequence: new Uint8Array(maxLzwDictionarySize),
  2714. currentSequenceLength: 0
  2715. };
  2716. for (var i = 0; i < 256; ++i) {
  2717. lzwState.dictionaryValues[i] = i;
  2718. lzwState.dictionaryLengths[i] = 1;
  2719. }
  2720. this.lzwState = lzwState;
  2721. DecodeStream.call(this, maybeLength);
  2722. }
  2723. LZWStream.prototype = Object.create(DecodeStream.prototype);
  2724. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  2725. var bitsCached = this.bitsCached;
  2726. var cachedData = this.cachedData;
  2727. while (bitsCached < n) {
  2728. var c = this.str.getByte();
  2729. if (c === -1) {
  2730. this.eof = true;
  2731. return null;
  2732. }
  2733. cachedData = cachedData << 8 | c;
  2734. bitsCached += 8;
  2735. }
  2736. this.bitsCached = bitsCached -= n;
  2737. this.cachedData = cachedData;
  2738. this.lastCode = null;
  2739. return cachedData >>> bitsCached & (1 << n) - 1;
  2740. };
  2741. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  2742. var blockSize = 512;
  2743. var estimatedDecodedSize = blockSize * 2,
  2744. decodedSizeDelta = blockSize;
  2745. var i, j, q;
  2746. var lzwState = this.lzwState;
  2747. if (!lzwState) {
  2748. return;
  2749. }
  2750. var earlyChange = lzwState.earlyChange;
  2751. var nextCode = lzwState.nextCode;
  2752. var dictionaryValues = lzwState.dictionaryValues;
  2753. var dictionaryLengths = lzwState.dictionaryLengths;
  2754. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  2755. var codeLength = lzwState.codeLength;
  2756. var prevCode = lzwState.prevCode;
  2757. var currentSequence = lzwState.currentSequence;
  2758. var currentSequenceLength = lzwState.currentSequenceLength;
  2759. var decodedLength = 0;
  2760. var currentBufferLength = this.bufferLength;
  2761. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  2762. for (i = 0; i < blockSize; i++) {
  2763. var code = this.readBits(codeLength);
  2764. var hasPrev = currentSequenceLength > 0;
  2765. if (code < 256) {
  2766. currentSequence[0] = code;
  2767. currentSequenceLength = 1;
  2768. } else if (code >= 258) {
  2769. if (code < nextCode) {
  2770. currentSequenceLength = dictionaryLengths[code];
  2771. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  2772. currentSequence[j] = dictionaryValues[q];
  2773. q = dictionaryPrevCodes[q];
  2774. }
  2775. } else {
  2776. currentSequence[currentSequenceLength++] = currentSequence[0];
  2777. }
  2778. } else if (code === 256) {
  2779. codeLength = 9;
  2780. nextCode = 258;
  2781. currentSequenceLength = 0;
  2782. continue;
  2783. } else {
  2784. this.eof = true;
  2785. delete this.lzwState;
  2786. break;
  2787. }
  2788. if (hasPrev) {
  2789. dictionaryPrevCodes[nextCode] = prevCode;
  2790. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  2791. dictionaryValues[nextCode] = currentSequence[0];
  2792. nextCode++;
  2793. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  2794. }
  2795. prevCode = code;
  2796. decodedLength += currentSequenceLength;
  2797. if (estimatedDecodedSize < decodedLength) {
  2798. do {
  2799. estimatedDecodedSize += decodedSizeDelta;
  2800. } while (estimatedDecodedSize < decodedLength);
  2801. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  2802. }
  2803. for (j = 0; j < currentSequenceLength; j++) {
  2804. buffer[currentBufferLength++] = currentSequence[j];
  2805. }
  2806. }
  2807. lzwState.nextCode = nextCode;
  2808. lzwState.codeLength = codeLength;
  2809. lzwState.prevCode = prevCode;
  2810. lzwState.currentSequenceLength = currentSequenceLength;
  2811. this.bufferLength = currentBufferLength;
  2812. };
  2813. return LZWStream;
  2814. }();
  2815. var NullStream = function NullStreamClosure() {
  2816. function NullStream() {
  2817. Stream.call(this, new Uint8Array(0));
  2818. }
  2819. NullStream.prototype = Stream.prototype;
  2820. return NullStream;
  2821. }();
  2822. exports.Ascii85Stream = Ascii85Stream;
  2823. exports.AsciiHexStream = AsciiHexStream;
  2824. exports.DecryptStream = DecryptStream;
  2825. exports.DecodeStream = DecodeStream;
  2826. exports.FlateStream = FlateStream;
  2827. exports.JpegStream = JpegStream;
  2828. exports.JpxStream = JpxStream;
  2829. exports.NullStream = NullStream;
  2830. exports.PredictorStream = PredictorStream;
  2831. exports.RunLengthStream = RunLengthStream;
  2832. exports.Stream = Stream;
  2833. exports.StreamsSequenceStream = StreamsSequenceStream;
  2834. exports.StringStream = StringStream;
  2835. exports.LZWStream = LZWStream;
  2836. /***/ }),
  2837. /* 6 */
  2838. /***/ (function(module, exports, __w_pdfjs_require__) {
  2839. "use strict";
  2840. var global = __w_pdfjs_require__(4);
  2841. var core = __w_pdfjs_require__(7);
  2842. var hide = __w_pdfjs_require__(12);
  2843. var redefine = __w_pdfjs_require__(10);
  2844. var ctx = __w_pdfjs_require__(11);
  2845. var PROTOTYPE = 'prototype';
  2846. var $export = function $export(type, name, source) {
  2847. var IS_FORCED = type & $export.F;
  2848. var IS_GLOBAL = type & $export.G;
  2849. var IS_STATIC = type & $export.S;
  2850. var IS_PROTO = type & $export.P;
  2851. var IS_BIND = type & $export.B;
  2852. var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
  2853. var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
  2854. var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
  2855. var key, own, out, exp;
  2856. if (IS_GLOBAL) source = name;
  2857. for (key in source) {
  2858. own = !IS_FORCED && target && target[key] !== undefined;
  2859. out = (own ? target : source)[key];
  2860. exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  2861. if (target) redefine(target, key, out, type & $export.U);
  2862. if (exports[key] != out) hide(exports, key, exp);
  2863. if (IS_PROTO && expProto[key] != out) expProto[key] = out;
  2864. }
  2865. };
  2866. global.core = core;
  2867. $export.F = 1;
  2868. $export.G = 2;
  2869. $export.S = 4;
  2870. $export.P = 8;
  2871. $export.B = 16;
  2872. $export.W = 32;
  2873. $export.U = 64;
  2874. $export.R = 128;
  2875. module.exports = $export;
  2876. /***/ }),
  2877. /* 7 */
  2878. /***/ (function(module, exports, __w_pdfjs_require__) {
  2879. "use strict";
  2880. var core = module.exports = { version: '2.5.1' };
  2881. if (typeof __e == 'number') __e = core;
  2882. /***/ }),
  2883. /* 8 */
  2884. /***/ (function(module, exports, __w_pdfjs_require__) {
  2885. "use strict";
  2886. var isObject = __w_pdfjs_require__(2);
  2887. module.exports = function (it) {
  2888. if (!isObject(it)) throw TypeError(it + ' is not an object!');
  2889. return it;
  2890. };
  2891. /***/ }),
  2892. /* 9 */
  2893. /***/ (function(module, exports, __w_pdfjs_require__) {
  2894. "use strict";
  2895. var hasOwnProperty = {}.hasOwnProperty;
  2896. module.exports = function (it, key) {
  2897. return hasOwnProperty.call(it, key);
  2898. };
  2899. /***/ }),
  2900. /* 10 */
  2901. /***/ (function(module, exports, __w_pdfjs_require__) {
  2902. "use strict";
  2903. var global = __w_pdfjs_require__(4);
  2904. var hide = __w_pdfjs_require__(12);
  2905. var has = __w_pdfjs_require__(9);
  2906. var SRC = __w_pdfjs_require__(22)('src');
  2907. var TO_STRING = 'toString';
  2908. var $toString = Function[TO_STRING];
  2909. var TPL = ('' + $toString).split(TO_STRING);
  2910. __w_pdfjs_require__(7).inspectSource = function (it) {
  2911. return $toString.call(it);
  2912. };
  2913. (module.exports = function (O, key, val, safe) {
  2914. var isFunction = typeof val == 'function';
  2915. if (isFunction) has(val, 'name') || hide(val, 'name', key);
  2916. if (O[key] === val) return;
  2917. if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  2918. if (O === global) {
  2919. O[key] = val;
  2920. } else if (!safe) {
  2921. delete O[key];
  2922. hide(O, key, val);
  2923. } else if (O[key]) {
  2924. O[key] = val;
  2925. } else {
  2926. hide(O, key, val);
  2927. }
  2928. })(Function.prototype, TO_STRING, function toString() {
  2929. return typeof this == 'function' && this[SRC] || $toString.call(this);
  2930. });
  2931. /***/ }),
  2932. /* 11 */
  2933. /***/ (function(module, exports, __w_pdfjs_require__) {
  2934. "use strict";
  2935. var aFunction = __w_pdfjs_require__(16);
  2936. module.exports = function (fn, that, length) {
  2937. aFunction(fn);
  2938. if (that === undefined) return fn;
  2939. switch (length) {
  2940. case 1:
  2941. return function (a) {
  2942. return fn.call(that, a);
  2943. };
  2944. case 2:
  2945. return function (a, b) {
  2946. return fn.call(that, a, b);
  2947. };
  2948. case 3:
  2949. return function (a, b, c) {
  2950. return fn.call(that, a, b, c);
  2951. };
  2952. }
  2953. return function () {
  2954. return fn.apply(that, arguments);
  2955. };
  2956. };
  2957. /***/ }),
  2958. /* 12 */
  2959. /***/ (function(module, exports, __w_pdfjs_require__) {
  2960. "use strict";
  2961. var dP = __w_pdfjs_require__(15);
  2962. var createDesc = __w_pdfjs_require__(28);
  2963. module.exports = __w_pdfjs_require__(13) ? function (object, key, value) {
  2964. return dP.f(object, key, createDesc(1, value));
  2965. } : function (object, key, value) {
  2966. object[key] = value;
  2967. return object;
  2968. };
  2969. /***/ }),
  2970. /* 13 */
  2971. /***/ (function(module, exports, __w_pdfjs_require__) {
  2972. "use strict";
  2973. module.exports = !__w_pdfjs_require__(14)(function () {
  2974. return Object.defineProperty({}, 'a', {
  2975. get: function get() {
  2976. return 7;
  2977. }
  2978. }).a != 7;
  2979. });
  2980. /***/ }),
  2981. /* 14 */
  2982. /***/ (function(module, exports, __w_pdfjs_require__) {
  2983. "use strict";
  2984. module.exports = function (exec) {
  2985. try {
  2986. return !!exec();
  2987. } catch (e) {
  2988. return true;
  2989. }
  2990. };
  2991. /***/ }),
  2992. /* 15 */
  2993. /***/ (function(module, exports, __w_pdfjs_require__) {
  2994. "use strict";
  2995. var anObject = __w_pdfjs_require__(8);
  2996. var IE8_DOM_DEFINE = __w_pdfjs_require__(43);
  2997. var toPrimitive = __w_pdfjs_require__(44);
  2998. var dP = Object.defineProperty;
  2999. exports.f = __w_pdfjs_require__(13) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
  3000. anObject(O);
  3001. P = toPrimitive(P, true);
  3002. anObject(Attributes);
  3003. if (IE8_DOM_DEFINE) try {
  3004. return dP(O, P, Attributes);
  3005. } catch (e) {}
  3006. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
  3007. if ('value' in Attributes) O[P] = Attributes.value;
  3008. return O;
  3009. };
  3010. /***/ }),
  3011. /* 16 */
  3012. /***/ (function(module, exports, __w_pdfjs_require__) {
  3013. "use strict";
  3014. module.exports = function (it) {
  3015. if (typeof it != 'function') throw TypeError(it + ' is not a function!');
  3016. return it;
  3017. };
  3018. /***/ }),
  3019. /* 17 */
  3020. /***/ (function(module, exports, __w_pdfjs_require__) {
  3021. "use strict";
  3022. var IObject = __w_pdfjs_require__(29);
  3023. var defined = __w_pdfjs_require__(30);
  3024. module.exports = function (it) {
  3025. return IObject(defined(it));
  3026. };
  3027. /***/ }),
  3028. /* 18 */
  3029. /***/ (function(module, exports, __w_pdfjs_require__) {
  3030. "use strict";
  3031. var toString = {}.toString;
  3032. module.exports = function (it) {
  3033. return toString.call(it).slice(8, -1);
  3034. };
  3035. /***/ }),
  3036. /* 19 */
  3037. /***/ (function(module, exports, __w_pdfjs_require__) {
  3038. "use strict";
  3039. module.exports = {};
  3040. /***/ }),
  3041. /* 20 */
  3042. /***/ (function(module, exports, __w_pdfjs_require__) {
  3043. "use strict";
  3044. Object.defineProperty(exports, "__esModule", {
  3045. value: true
  3046. });
  3047. exports.ColorSpace = undefined;
  3048. var _util = __w_pdfjs_require__(0);
  3049. var _primitives = __w_pdfjs_require__(1);
  3050. var ColorSpace = function ColorSpaceClosure() {
  3051. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  3052. var COMPONENTS = 3;
  3053. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  3054. var xRatio = w1 / w2;
  3055. var yRatio = h1 / h2;
  3056. var i,
  3057. j,
  3058. py,
  3059. newIndex = 0,
  3060. oldIndex;
  3061. var xScaled = new Uint16Array(w2);
  3062. var w1Scanline = w1 * COMPONENTS;
  3063. for (i = 0; i < w2; i++) {
  3064. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  3065. }
  3066. for (i = 0; i < h2; i++) {
  3067. py = Math.floor(i * yRatio) * w1Scanline;
  3068. for (j = 0; j < w2; j++) {
  3069. oldIndex = py + xScaled[j];
  3070. dest[newIndex++] = src[oldIndex++];
  3071. dest[newIndex++] = src[oldIndex++];
  3072. dest[newIndex++] = src[oldIndex++];
  3073. newIndex += alpha01;
  3074. }
  3075. }
  3076. }
  3077. function ColorSpace() {
  3078. throw new Error('should not call ColorSpace constructor');
  3079. }
  3080. ColorSpace.prototype = {
  3081. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  3082. var rgb = new Uint8Array(3);
  3083. this.getRgbItem(src, srcOffset, rgb, 0);
  3084. return rgb;
  3085. },
  3086. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  3087. throw new Error('Should not call ColorSpace.getRgbItem');
  3088. },
  3089. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3090. throw new Error('Should not call ColorSpace.getRgbBuffer');
  3091. },
  3092. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  3093. throw new Error('Should not call ColorSpace.getOutputLength');
  3094. },
  3095. isPassthrough: function ColorSpace_isPassthrough(bits) {
  3096. return false;
  3097. },
  3098. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  3099. var count = originalWidth * originalHeight;
  3100. var rgbBuf = null;
  3101. var numComponentColors = 1 << bpc;
  3102. var needsResizing = originalHeight !== height || originalWidth !== width;
  3103. var i, ii;
  3104. if (this.isPassthrough(bpc)) {
  3105. rgbBuf = comps;
  3106. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  3107. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  3108. var key;
  3109. for (i = 0; i < numComponentColors; i++) {
  3110. allColors[i] = i;
  3111. }
  3112. var colorMap = new Uint8Array(numComponentColors * 3);
  3113. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  3114. var destPos, rgbPos;
  3115. if (!needsResizing) {
  3116. destPos = 0;
  3117. for (i = 0; i < count; ++i) {
  3118. key = comps[i] * 3;
  3119. dest[destPos++] = colorMap[key];
  3120. dest[destPos++] = colorMap[key + 1];
  3121. dest[destPos++] = colorMap[key + 2];
  3122. destPos += alpha01;
  3123. }
  3124. } else {
  3125. rgbBuf = new Uint8Array(count * 3);
  3126. rgbPos = 0;
  3127. for (i = 0; i < count; ++i) {
  3128. key = comps[i] * 3;
  3129. rgbBuf[rgbPos++] = colorMap[key];
  3130. rgbBuf[rgbPos++] = colorMap[key + 1];
  3131. rgbBuf[rgbPos++] = colorMap[key + 2];
  3132. }
  3133. }
  3134. } else {
  3135. if (!needsResizing) {
  3136. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  3137. } else {
  3138. rgbBuf = new Uint8Array(count * 3);
  3139. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  3140. }
  3141. }
  3142. if (rgbBuf) {
  3143. if (needsResizing) {
  3144. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  3145. } else {
  3146. rgbPos = 0;
  3147. destPos = 0;
  3148. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  3149. dest[destPos++] = rgbBuf[rgbPos++];
  3150. dest[destPos++] = rgbBuf[rgbPos++];
  3151. dest[destPos++] = rgbBuf[rgbPos++];
  3152. destPos += alpha01;
  3153. }
  3154. }
  3155. }
  3156. },
  3157. usesZeroToOneRange: true
  3158. };
  3159. ColorSpace.parse = function (cs, xref, res, pdfFunctionFactory) {
  3160. var IR = ColorSpace.parseToIR(cs, xref, res, pdfFunctionFactory);
  3161. return ColorSpace.fromIR(IR, pdfFunctionFactory);
  3162. };
  3163. ColorSpace.fromIR = function (IR, pdfFunctionFactory) {
  3164. var name = Array.isArray(IR) ? IR[0] : IR;
  3165. var whitePoint, blackPoint, gamma;
  3166. switch (name) {
  3167. case 'DeviceGrayCS':
  3168. return this.singletons.gray;
  3169. case 'DeviceRgbCS':
  3170. return this.singletons.rgb;
  3171. case 'DeviceCmykCS':
  3172. return this.singletons.cmyk;
  3173. case 'CalGrayCS':
  3174. whitePoint = IR[1];
  3175. blackPoint = IR[2];
  3176. gamma = IR[3];
  3177. return new CalGrayCS(whitePoint, blackPoint, gamma);
  3178. case 'CalRGBCS':
  3179. whitePoint = IR[1];
  3180. blackPoint = IR[2];
  3181. gamma = IR[3];
  3182. var matrix = IR[4];
  3183. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  3184. case 'PatternCS':
  3185. var basePatternCS = IR[1];
  3186. if (basePatternCS) {
  3187. basePatternCS = ColorSpace.fromIR(basePatternCS, pdfFunctionFactory);
  3188. }
  3189. return new PatternCS(basePatternCS);
  3190. case 'IndexedCS':
  3191. var baseIndexedCS = IR[1];
  3192. var hiVal = IR[2];
  3193. var lookup = IR[3];
  3194. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS, pdfFunctionFactory), hiVal, lookup);
  3195. case 'AlternateCS':
  3196. var numComps = IR[1];
  3197. var alt = IR[2];
  3198. var tintFnIR = IR[3];
  3199. return new AlternateCS(numComps, ColorSpace.fromIR(alt, pdfFunctionFactory), pdfFunctionFactory.createFromIR(tintFnIR));
  3200. case 'LabCS':
  3201. whitePoint = IR[1];
  3202. blackPoint = IR[2];
  3203. var range = IR[3];
  3204. return new LabCS(whitePoint, blackPoint, range);
  3205. default:
  3206. throw new _util.FormatError('Unknown colorspace name: ' + name);
  3207. }
  3208. };
  3209. ColorSpace.parseToIR = function (cs, xref, res, pdfFunctionFactory) {
  3210. if ((0, _primitives.isName)(cs)) {
  3211. var colorSpaces = res.get('ColorSpace');
  3212. if ((0, _primitives.isDict)(colorSpaces)) {
  3213. var refcs = colorSpaces.get(cs.name);
  3214. if (refcs) {
  3215. cs = refcs;
  3216. }
  3217. }
  3218. }
  3219. cs = xref.fetchIfRef(cs);
  3220. if ((0, _primitives.isName)(cs)) {
  3221. switch (cs.name) {
  3222. case 'DeviceGray':
  3223. case 'G':
  3224. return 'DeviceGrayCS';
  3225. case 'DeviceRGB':
  3226. case 'RGB':
  3227. return 'DeviceRgbCS';
  3228. case 'DeviceCMYK':
  3229. case 'CMYK':
  3230. return 'DeviceCmykCS';
  3231. case 'Pattern':
  3232. return ['PatternCS', null];
  3233. default:
  3234. throw new _util.FormatError('unrecognized colorspace ' + cs.name);
  3235. }
  3236. }
  3237. if (Array.isArray(cs)) {
  3238. var mode = xref.fetchIfRef(cs[0]).name;
  3239. var numComps, params, alt, whitePoint, blackPoint, gamma;
  3240. switch (mode) {
  3241. case 'DeviceGray':
  3242. case 'G':
  3243. return 'DeviceGrayCS';
  3244. case 'DeviceRGB':
  3245. case 'RGB':
  3246. return 'DeviceRgbCS';
  3247. case 'DeviceCMYK':
  3248. case 'CMYK':
  3249. return 'DeviceCmykCS';
  3250. case 'CalGray':
  3251. params = xref.fetchIfRef(cs[1]);
  3252. whitePoint = params.getArray('WhitePoint');
  3253. blackPoint = params.getArray('BlackPoint');
  3254. gamma = params.get('Gamma');
  3255. return ['CalGrayCS', whitePoint, blackPoint, gamma];
  3256. case 'CalRGB':
  3257. params = xref.fetchIfRef(cs[1]);
  3258. whitePoint = params.getArray('WhitePoint');
  3259. blackPoint = params.getArray('BlackPoint');
  3260. gamma = params.getArray('Gamma');
  3261. var matrix = params.getArray('Matrix');
  3262. return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];
  3263. case 'ICCBased':
  3264. var stream = xref.fetchIfRef(cs[1]);
  3265. var dict = stream.dict;
  3266. numComps = dict.get('N');
  3267. alt = dict.get('Alternate');
  3268. if (alt) {
  3269. var altIR = ColorSpace.parseToIR(alt, xref, res, pdfFunctionFactory);
  3270. var altCS = ColorSpace.fromIR(altIR, pdfFunctionFactory);
  3271. if (altCS.numComps === numComps) {
  3272. return altIR;
  3273. }
  3274. (0, _util.warn)('ICCBased color space: Ignoring incorrect /Alternate entry.');
  3275. }
  3276. if (numComps === 1) {
  3277. return 'DeviceGrayCS';
  3278. } else if (numComps === 3) {
  3279. return 'DeviceRgbCS';
  3280. } else if (numComps === 4) {
  3281. return 'DeviceCmykCS';
  3282. }
  3283. break;
  3284. case 'Pattern':
  3285. var basePatternCS = cs[1] || null;
  3286. if (basePatternCS) {
  3287. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res, pdfFunctionFactory);
  3288. }
  3289. return ['PatternCS', basePatternCS];
  3290. case 'Indexed':
  3291. case 'I':
  3292. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res, pdfFunctionFactory);
  3293. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  3294. var lookup = xref.fetchIfRef(cs[3]);
  3295. if ((0, _primitives.isStream)(lookup)) {
  3296. lookup = lookup.getBytes();
  3297. }
  3298. return ['IndexedCS', baseIndexedCS, hiVal, lookup];
  3299. case 'Separation':
  3300. case 'DeviceN':
  3301. var name = xref.fetchIfRef(cs[1]);
  3302. numComps = Array.isArray(name) ? name.length : 1;
  3303. alt = ColorSpace.parseToIR(cs[2], xref, res, pdfFunctionFactory);
  3304. var tintFnIR = pdfFunctionFactory.createIR(xref.fetchIfRef(cs[3]));
  3305. return ['AlternateCS', numComps, alt, tintFnIR];
  3306. case 'Lab':
  3307. params = xref.fetchIfRef(cs[1]);
  3308. whitePoint = params.getArray('WhitePoint');
  3309. blackPoint = params.getArray('BlackPoint');
  3310. var range = params.getArray('Range');
  3311. return ['LabCS', whitePoint, blackPoint, range];
  3312. default:
  3313. throw new _util.FormatError('unimplemented color space object "' + mode + '"');
  3314. }
  3315. }
  3316. throw new _util.FormatError('unrecognized color space object: "' + cs + '"');
  3317. };
  3318. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  3319. if (!Array.isArray(decode)) {
  3320. return true;
  3321. }
  3322. if (n * 2 !== decode.length) {
  3323. (0, _util.warn)('The decode map is not the correct length');
  3324. return true;
  3325. }
  3326. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  3327. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  3328. return false;
  3329. }
  3330. }
  3331. return true;
  3332. };
  3333. ColorSpace.singletons = {
  3334. get gray() {
  3335. return (0, _util.shadow)(this, 'gray', new DeviceGrayCS());
  3336. },
  3337. get rgb() {
  3338. return (0, _util.shadow)(this, 'rgb', new DeviceRgbCS());
  3339. },
  3340. get cmyk() {
  3341. return (0, _util.shadow)(this, 'cmyk', new DeviceCmykCS());
  3342. }
  3343. };
  3344. return ColorSpace;
  3345. }();
  3346. var AlternateCS = function AlternateCSClosure() {
  3347. function AlternateCS(numComps, base, tintFn) {
  3348. this.name = 'Alternate';
  3349. this.numComps = numComps;
  3350. this.defaultColor = new Float32Array(numComps);
  3351. for (var i = 0; i < numComps; ++i) {
  3352. this.defaultColor[i] = 1;
  3353. }
  3354. this.base = base;
  3355. this.tintFn = tintFn;
  3356. this.tmpBuf = new Float32Array(base.numComps);
  3357. }
  3358. AlternateCS.prototype = {
  3359. getRgb: ColorSpace.prototype.getRgb,
  3360. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3361. var tmpBuf = this.tmpBuf;
  3362. this.tintFn(src, srcOffset, tmpBuf, 0);
  3363. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  3364. },
  3365. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3366. var tintFn = this.tintFn;
  3367. var base = this.base;
  3368. var scale = 1 / ((1 << bits) - 1);
  3369. var baseNumComps = base.numComps;
  3370. var usesZeroToOneRange = base.usesZeroToOneRange;
  3371. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  3372. var pos = isPassthrough ? destOffset : 0;
  3373. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  3374. var numComps = this.numComps;
  3375. var scaled = new Float32Array(numComps);
  3376. var tinted = new Float32Array(baseNumComps);
  3377. var i, j;
  3378. for (i = 0; i < count; i++) {
  3379. for (j = 0; j < numComps; j++) {
  3380. scaled[j] = src[srcOffset++] * scale;
  3381. }
  3382. tintFn(scaled, 0, tinted, 0);
  3383. if (usesZeroToOneRange) {
  3384. for (j = 0; j < baseNumComps; j++) {
  3385. baseBuf[pos++] = tinted[j] * 255;
  3386. }
  3387. } else {
  3388. base.getRgbItem(tinted, 0, baseBuf, pos);
  3389. pos += baseNumComps;
  3390. }
  3391. }
  3392. if (!isPassthrough) {
  3393. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  3394. }
  3395. },
  3396. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  3397. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  3398. },
  3399. isPassthrough: ColorSpace.prototype.isPassthrough,
  3400. fillRgb: ColorSpace.prototype.fillRgb,
  3401. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  3402. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  3403. },
  3404. usesZeroToOneRange: true
  3405. };
  3406. return AlternateCS;
  3407. }();
  3408. var PatternCS = function PatternCSClosure() {
  3409. function PatternCS(baseCS) {
  3410. this.name = 'Pattern';
  3411. this.base = baseCS;
  3412. }
  3413. PatternCS.prototype = {};
  3414. return PatternCS;
  3415. }();
  3416. var IndexedCS = function IndexedCSClosure() {
  3417. function IndexedCS(base, highVal, lookup) {
  3418. this.name = 'Indexed';
  3419. this.numComps = 1;
  3420. this.defaultColor = new Uint8Array(this.numComps);
  3421. this.base = base;
  3422. this.highVal = highVal;
  3423. var baseNumComps = base.numComps;
  3424. var length = baseNumComps * highVal;
  3425. if ((0, _primitives.isStream)(lookup)) {
  3426. this.lookup = new Uint8Array(length);
  3427. var bytes = lookup.getBytes(length);
  3428. this.lookup.set(bytes);
  3429. } else if ((0, _util.isString)(lookup)) {
  3430. this.lookup = new Uint8Array(length);
  3431. for (var i = 0; i < length; ++i) {
  3432. this.lookup[i] = lookup.charCodeAt(i);
  3433. }
  3434. } else if (lookup instanceof Uint8Array) {
  3435. this.lookup = lookup;
  3436. } else {
  3437. throw new _util.FormatError('Unrecognized lookup table: ' + lookup);
  3438. }
  3439. }
  3440. IndexedCS.prototype = {
  3441. getRgb: ColorSpace.prototype.getRgb,
  3442. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3443. var numComps = this.base.numComps;
  3444. var start = src[srcOffset] * numComps;
  3445. this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
  3446. },
  3447. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3448. var base = this.base;
  3449. var numComps = base.numComps;
  3450. var outputDelta = base.getOutputLength(numComps, alpha01);
  3451. var lookup = this.lookup;
  3452. for (var i = 0; i < count; ++i) {
  3453. var lookupPos = src[srcOffset++] * numComps;
  3454. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  3455. destOffset += outputDelta;
  3456. }
  3457. },
  3458. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  3459. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  3460. },
  3461. isPassthrough: ColorSpace.prototype.isPassthrough,
  3462. fillRgb: ColorSpace.prototype.fillRgb,
  3463. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  3464. return true;
  3465. },
  3466. usesZeroToOneRange: true
  3467. };
  3468. return IndexedCS;
  3469. }();
  3470. var DeviceGrayCS = function DeviceGrayCSClosure() {
  3471. function DeviceGrayCS() {
  3472. this.name = 'DeviceGray';
  3473. this.numComps = 1;
  3474. this.defaultColor = new Float32Array(this.numComps);
  3475. }
  3476. DeviceGrayCS.prototype = {
  3477. getRgb: ColorSpace.prototype.getRgb,
  3478. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3479. var c = src[srcOffset] * 255 | 0;
  3480. c = c < 0 ? 0 : c > 255 ? 255 : c;
  3481. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  3482. },
  3483. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3484. var scale = 255 / ((1 << bits) - 1);
  3485. var j = srcOffset,
  3486. q = destOffset;
  3487. for (var i = 0; i < count; ++i) {
  3488. var c = scale * src[j++] | 0;
  3489. dest[q++] = c;
  3490. dest[q++] = c;
  3491. dest[q++] = c;
  3492. q += alpha01;
  3493. }
  3494. },
  3495. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  3496. return inputLength * (3 + alpha01);
  3497. },
  3498. isPassthrough: ColorSpace.prototype.isPassthrough,
  3499. fillRgb: ColorSpace.prototype.fillRgb,
  3500. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  3501. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  3502. },
  3503. usesZeroToOneRange: true
  3504. };
  3505. return DeviceGrayCS;
  3506. }();
  3507. var DeviceRgbCS = function DeviceRgbCSClosure() {
  3508. function DeviceRgbCS() {
  3509. this.name = 'DeviceRGB';
  3510. this.numComps = 3;
  3511. this.defaultColor = new Float32Array(this.numComps);
  3512. }
  3513. DeviceRgbCS.prototype = {
  3514. getRgb: ColorSpace.prototype.getRgb,
  3515. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3516. var r = src[srcOffset] * 255 | 0;
  3517. var g = src[srcOffset + 1] * 255 | 0;
  3518. var b = src[srcOffset + 2] * 255 | 0;
  3519. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  3520. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  3521. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  3522. },
  3523. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3524. if (bits === 8 && alpha01 === 0) {
  3525. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  3526. return;
  3527. }
  3528. var scale = 255 / ((1 << bits) - 1);
  3529. var j = srcOffset,
  3530. q = destOffset;
  3531. for (var i = 0; i < count; ++i) {
  3532. dest[q++] = scale * src[j++] | 0;
  3533. dest[q++] = scale * src[j++] | 0;
  3534. dest[q++] = scale * src[j++] | 0;
  3535. q += alpha01;
  3536. }
  3537. },
  3538. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  3539. return inputLength * (3 + alpha01) / 3 | 0;
  3540. },
  3541. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  3542. return bits === 8;
  3543. },
  3544. fillRgb: ColorSpace.prototype.fillRgb,
  3545. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  3546. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  3547. },
  3548. usesZeroToOneRange: true
  3549. };
  3550. return DeviceRgbCS;
  3551. }();
  3552. var DeviceCmykCS = function DeviceCmykCSClosure() {
  3553. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  3554. var c = src[srcOffset + 0] * srcScale;
  3555. var m = src[srcOffset + 1] * srcScale;
  3556. var y = src[srcOffset + 2] * srcScale;
  3557. var k = src[srcOffset + 3] * srcScale;
  3558. 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;
  3559. 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;
  3560. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367) + 255 | 0;
  3561. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  3562. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  3563. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  3564. }
  3565. function DeviceCmykCS() {
  3566. this.name = 'DeviceCMYK';
  3567. this.numComps = 4;
  3568. this.defaultColor = new Float32Array(this.numComps);
  3569. this.defaultColor[3] = 1;
  3570. }
  3571. DeviceCmykCS.prototype = {
  3572. getRgb: ColorSpace.prototype.getRgb,
  3573. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3574. convertToRgb(src, srcOffset, 1, dest, destOffset);
  3575. },
  3576. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3577. var scale = 1 / ((1 << bits) - 1);
  3578. for (var i = 0; i < count; i++) {
  3579. convertToRgb(src, srcOffset, scale, dest, destOffset);
  3580. srcOffset += 4;
  3581. destOffset += 3 + alpha01;
  3582. }
  3583. },
  3584. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  3585. return inputLength / 4 * (3 + alpha01) | 0;
  3586. },
  3587. isPassthrough: ColorSpace.prototype.isPassthrough,
  3588. fillRgb: ColorSpace.prototype.fillRgb,
  3589. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  3590. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  3591. },
  3592. usesZeroToOneRange: true
  3593. };
  3594. return DeviceCmykCS;
  3595. }();
  3596. var CalGrayCS = function CalGrayCSClosure() {
  3597. function CalGrayCS(whitePoint, blackPoint, gamma) {
  3598. this.name = 'CalGray';
  3599. this.numComps = 1;
  3600. this.defaultColor = new Float32Array(this.numComps);
  3601. if (!whitePoint) {
  3602. throw new _util.FormatError('WhitePoint missing - required for color space CalGray');
  3603. }
  3604. blackPoint = blackPoint || [0, 0, 0];
  3605. gamma = gamma || 1;
  3606. this.XW = whitePoint[0];
  3607. this.YW = whitePoint[1];
  3608. this.ZW = whitePoint[2];
  3609. this.XB = blackPoint[0];
  3610. this.YB = blackPoint[1];
  3611. this.ZB = blackPoint[2];
  3612. this.G = gamma;
  3613. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  3614. throw new _util.FormatError('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  3615. }
  3616. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  3617. (0, _util.info)('Invalid BlackPoint for ' + this.name + ', falling back to default');
  3618. this.XB = this.YB = this.ZB = 0;
  3619. }
  3620. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  3621. (0, _util.warn)(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  3622. }
  3623. if (this.G < 1) {
  3624. (0, _util.info)('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  3625. this.G = 1;
  3626. }
  3627. }
  3628. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  3629. var A = src[srcOffset] * scale;
  3630. var AG = Math.pow(A, cs.G);
  3631. var L = cs.YW * AG;
  3632. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  3633. dest[destOffset] = val;
  3634. dest[destOffset + 1] = val;
  3635. dest[destOffset + 2] = val;
  3636. }
  3637. CalGrayCS.prototype = {
  3638. getRgb: ColorSpace.prototype.getRgb,
  3639. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3640. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  3641. },
  3642. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3643. var scale = 1 / ((1 << bits) - 1);
  3644. for (var i = 0; i < count; ++i) {
  3645. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  3646. srcOffset += 1;
  3647. destOffset += 3 + alpha01;
  3648. }
  3649. },
  3650. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  3651. return inputLength * (3 + alpha01);
  3652. },
  3653. isPassthrough: ColorSpace.prototype.isPassthrough,
  3654. fillRgb: ColorSpace.prototype.fillRgb,
  3655. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  3656. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  3657. },
  3658. usesZeroToOneRange: true
  3659. };
  3660. return CalGrayCS;
  3661. }();
  3662. var CalRGBCS = function CalRGBCSClosure() {
  3663. var BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
  3664. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
  3665. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);
  3666. var FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);
  3667. var tempNormalizeMatrix = new Float32Array(3);
  3668. var tempConvertMatrix1 = new Float32Array(3);
  3669. var tempConvertMatrix2 = new Float32Array(3);
  3670. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  3671. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  3672. this.name = 'CalRGB';
  3673. this.numComps = 3;
  3674. this.defaultColor = new Float32Array(this.numComps);
  3675. if (!whitePoint) {
  3676. throw new _util.FormatError('WhitePoint missing - required for color space CalRGB');
  3677. }
  3678. blackPoint = blackPoint || new Float32Array(3);
  3679. gamma = gamma || new Float32Array([1, 1, 1]);
  3680. matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
  3681. var XW = whitePoint[0];
  3682. var YW = whitePoint[1];
  3683. var ZW = whitePoint[2];
  3684. this.whitePoint = whitePoint;
  3685. var XB = blackPoint[0];
  3686. var YB = blackPoint[1];
  3687. var ZB = blackPoint[2];
  3688. this.blackPoint = blackPoint;
  3689. this.GR = gamma[0];
  3690. this.GG = gamma[1];
  3691. this.GB = gamma[2];
  3692. this.MXA = matrix[0];
  3693. this.MYA = matrix[1];
  3694. this.MZA = matrix[2];
  3695. this.MXB = matrix[3];
  3696. this.MYB = matrix[4];
  3697. this.MZB = matrix[5];
  3698. this.MXC = matrix[6];
  3699. this.MYC = matrix[7];
  3700. this.MZC = matrix[8];
  3701. if (XW < 0 || ZW < 0 || YW !== 1) {
  3702. throw new _util.FormatError('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  3703. }
  3704. if (XB < 0 || YB < 0 || ZB < 0) {
  3705. (0, _util.info)('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  3706. this.blackPoint = new Float32Array(3);
  3707. }
  3708. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  3709. (0, _util.info)('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  3710. this.GR = this.GG = this.GB = 1;
  3711. }
  3712. 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) {
  3713. (0, _util.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');
  3714. this.MXA = this.MYB = this.MZC = 1;
  3715. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  3716. }
  3717. }
  3718. function matrixProduct(a, b, result) {
  3719. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  3720. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  3721. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  3722. }
  3723. function convertToFlat(sourceWhitePoint, LMS, result) {
  3724. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  3725. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  3726. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  3727. }
  3728. function convertToD65(sourceWhitePoint, LMS, result) {
  3729. var D65X = 0.95047;
  3730. var D65Y = 1;
  3731. var D65Z = 1.08883;
  3732. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  3733. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  3734. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  3735. }
  3736. function sRGBTransferFunction(color) {
  3737. if (color <= 0.0031308) {
  3738. return adjustToRange(0, 1, 12.92 * color);
  3739. }
  3740. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  3741. }
  3742. function adjustToRange(min, max, value) {
  3743. return Math.max(min, Math.min(max, value));
  3744. }
  3745. function decodeL(L) {
  3746. if (L < 0) {
  3747. return -decodeL(-L);
  3748. }
  3749. if (L > 8.0) {
  3750. return Math.pow((L + 16) / 116, 3);
  3751. }
  3752. return L * DECODE_L_CONSTANT;
  3753. }
  3754. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  3755. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  3756. result[0] = XYZ_Flat[0];
  3757. result[1] = XYZ_Flat[1];
  3758. result[2] = XYZ_Flat[2];
  3759. return;
  3760. }
  3761. var zeroDecodeL = decodeL(0);
  3762. var X_DST = zeroDecodeL;
  3763. var X_SRC = decodeL(sourceBlackPoint[0]);
  3764. var Y_DST = zeroDecodeL;
  3765. var Y_SRC = decodeL(sourceBlackPoint[1]);
  3766. var Z_DST = zeroDecodeL;
  3767. var Z_SRC = decodeL(sourceBlackPoint[2]);
  3768. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  3769. var X_Offset = 1 - X_Scale;
  3770. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  3771. var Y_Offset = 1 - Y_Scale;
  3772. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  3773. var Z_Offset = 1 - Z_Scale;
  3774. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  3775. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  3776. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  3777. }
  3778. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  3779. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  3780. result[0] = XYZ_In[0];
  3781. result[1] = XYZ_In[1];
  3782. result[2] = XYZ_In[2];
  3783. return;
  3784. }
  3785. var LMS = result;
  3786. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  3787. var LMS_Flat = tempNormalizeMatrix;
  3788. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  3789. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  3790. }
  3791. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  3792. var LMS = result;
  3793. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  3794. var LMS_D65 = tempNormalizeMatrix;
  3795. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  3796. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  3797. }
  3798. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  3799. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  3800. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  3801. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  3802. var AGR = Math.pow(A, cs.GR);
  3803. var BGG = Math.pow(B, cs.GG);
  3804. var CGB = Math.pow(C, cs.GB);
  3805. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  3806. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  3807. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  3808. var XYZ = tempConvertMatrix1;
  3809. XYZ[0] = X;
  3810. XYZ[1] = Y;
  3811. XYZ[2] = Z;
  3812. var XYZ_Flat = tempConvertMatrix2;
  3813. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  3814. var XYZ_Black = tempConvertMatrix1;
  3815. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  3816. var XYZ_D65 = tempConvertMatrix2;
  3817. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  3818. var SRGB = tempConvertMatrix1;
  3819. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  3820. var sR = sRGBTransferFunction(SRGB[0]);
  3821. var sG = sRGBTransferFunction(SRGB[1]);
  3822. var sB = sRGBTransferFunction(SRGB[2]);
  3823. dest[destOffset] = Math.round(sR * 255);
  3824. dest[destOffset + 1] = Math.round(sG * 255);
  3825. dest[destOffset + 2] = Math.round(sB * 255);
  3826. }
  3827. CalRGBCS.prototype = {
  3828. getRgb: ColorSpace.prototype.getRgb,
  3829. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3830. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  3831. },
  3832. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3833. var scale = 1 / ((1 << bits) - 1);
  3834. for (var i = 0; i < count; ++i) {
  3835. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  3836. srcOffset += 3;
  3837. destOffset += 3 + alpha01;
  3838. }
  3839. },
  3840. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  3841. return inputLength * (3 + alpha01) / 3 | 0;
  3842. },
  3843. isPassthrough: ColorSpace.prototype.isPassthrough,
  3844. fillRgb: ColorSpace.prototype.fillRgb,
  3845. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  3846. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  3847. },
  3848. usesZeroToOneRange: true
  3849. };
  3850. return CalRGBCS;
  3851. }();
  3852. var LabCS = function LabCSClosure() {
  3853. function LabCS(whitePoint, blackPoint, range) {
  3854. this.name = 'Lab';
  3855. this.numComps = 3;
  3856. this.defaultColor = new Float32Array(this.numComps);
  3857. if (!whitePoint) {
  3858. throw new _util.FormatError('WhitePoint missing - required for color space Lab');
  3859. }
  3860. blackPoint = blackPoint || [0, 0, 0];
  3861. range = range || [-100, 100, -100, 100];
  3862. this.XW = whitePoint[0];
  3863. this.YW = whitePoint[1];
  3864. this.ZW = whitePoint[2];
  3865. this.amin = range[0];
  3866. this.amax = range[1];
  3867. this.bmin = range[2];
  3868. this.bmax = range[3];
  3869. this.XB = blackPoint[0];
  3870. this.YB = blackPoint[1];
  3871. this.ZB = blackPoint[2];
  3872. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  3873. throw new _util.FormatError('Invalid WhitePoint components, no fallback available');
  3874. }
  3875. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  3876. (0, _util.info)('Invalid BlackPoint, falling back to default');
  3877. this.XB = this.YB = this.ZB = 0;
  3878. }
  3879. if (this.amin > this.amax || this.bmin > this.bmax) {
  3880. (0, _util.info)('Invalid Range, falling back to defaults');
  3881. this.amin = -100;
  3882. this.amax = 100;
  3883. this.bmin = -100;
  3884. this.bmax = 100;
  3885. }
  3886. }
  3887. function fn_g(x) {
  3888. var result;
  3889. if (x >= 6 / 29) {
  3890. result = x * x * x;
  3891. } else {
  3892. result = 108 / 841 * (x - 4 / 29);
  3893. }
  3894. return result;
  3895. }
  3896. function decode(value, high1, low2, high2) {
  3897. return low2 + value * (high2 - low2) / high1;
  3898. }
  3899. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  3900. var Ls = src[srcOffset];
  3901. var as = src[srcOffset + 1];
  3902. var bs = src[srcOffset + 2];
  3903. if (maxVal !== false) {
  3904. Ls = decode(Ls, maxVal, 0, 100);
  3905. as = decode(as, maxVal, cs.amin, cs.amax);
  3906. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  3907. }
  3908. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  3909. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  3910. var M = (Ls + 16) / 116;
  3911. var L = M + as / 500;
  3912. var N = M - bs / 200;
  3913. var X = cs.XW * fn_g(L);
  3914. var Y = cs.YW * fn_g(M);
  3915. var Z = cs.ZW * fn_g(N);
  3916. var r, g, b;
  3917. if (cs.ZW < 1) {
  3918. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  3919. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  3920. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  3921. } else {
  3922. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  3923. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  3924. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  3925. }
  3926. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  3927. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  3928. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  3929. }
  3930. LabCS.prototype = {
  3931. getRgb: ColorSpace.prototype.getRgb,
  3932. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  3933. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  3934. },
  3935. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  3936. var maxVal = (1 << bits) - 1;
  3937. for (var i = 0; i < count; i++) {
  3938. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  3939. srcOffset += 3;
  3940. destOffset += 3 + alpha01;
  3941. }
  3942. },
  3943. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  3944. return inputLength * (3 + alpha01) / 3 | 0;
  3945. },
  3946. isPassthrough: ColorSpace.prototype.isPassthrough,
  3947. fillRgb: ColorSpace.prototype.fillRgb,
  3948. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  3949. return true;
  3950. },
  3951. usesZeroToOneRange: false
  3952. };
  3953. return LabCS;
  3954. }();
  3955. exports.ColorSpace = ColorSpace;
  3956. /***/ }),
  3957. /* 21 */
  3958. /***/ (function(module, exports, __w_pdfjs_require__) {
  3959. "use strict";
  3960. Object.defineProperty(exports, "__esModule", {
  3961. value: true
  3962. });
  3963. 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'];
  3964. 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'];
  3965. 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'];
  3966. 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'];
  3967. 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'];
  3968. 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'];
  3969. 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'];
  3970. function getEncoding(encodingName) {
  3971. switch (encodingName) {
  3972. case 'WinAnsiEncoding':
  3973. return WinAnsiEncoding;
  3974. case 'StandardEncoding':
  3975. return StandardEncoding;
  3976. case 'MacRomanEncoding':
  3977. return MacRomanEncoding;
  3978. case 'SymbolSetEncoding':
  3979. return SymbolSetEncoding;
  3980. case 'ZapfDingbatsEncoding':
  3981. return ZapfDingbatsEncoding;
  3982. case 'ExpertEncoding':
  3983. return ExpertEncoding;
  3984. case 'MacExpertEncoding':
  3985. return MacExpertEncoding;
  3986. default:
  3987. return null;
  3988. }
  3989. }
  3990. exports.WinAnsiEncoding = WinAnsiEncoding;
  3991. exports.StandardEncoding = StandardEncoding;
  3992. exports.MacRomanEncoding = MacRomanEncoding;
  3993. exports.SymbolSetEncoding = SymbolSetEncoding;
  3994. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  3995. exports.ExpertEncoding = ExpertEncoding;
  3996. exports.getEncoding = getEncoding;
  3997. /***/ }),
  3998. /* 22 */
  3999. /***/ (function(module, exports, __w_pdfjs_require__) {
  4000. "use strict";
  4001. var id = 0;
  4002. var px = Math.random();
  4003. module.exports = function (key) {
  4004. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  4005. };
  4006. /***/ }),
  4007. /* 23 */
  4008. /***/ (function(module, exports, __w_pdfjs_require__) {
  4009. "use strict";
  4010. var $keys = __w_pdfjs_require__(77);
  4011. var enumBugKeys = __w_pdfjs_require__(47);
  4012. module.exports = Object.keys || function keys(O) {
  4013. return $keys(O, enumBugKeys);
  4014. };
  4015. /***/ }),
  4016. /* 24 */
  4017. /***/ (function(module, exports, __w_pdfjs_require__) {
  4018. "use strict";
  4019. var def = __w_pdfjs_require__(15).f;
  4020. var has = __w_pdfjs_require__(9);
  4021. var TAG = __w_pdfjs_require__(3)('toStringTag');
  4022. module.exports = function (it, tag, stat) {
  4023. if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, {
  4024. configurable: true,
  4025. value: tag
  4026. });
  4027. };
  4028. /***/ }),
  4029. /* 25 */
  4030. /***/ (function(module, exports, __w_pdfjs_require__) {
  4031. "use strict";
  4032. var ctx = __w_pdfjs_require__(11);
  4033. var call = __w_pdfjs_require__(96);
  4034. var isArrayIter = __w_pdfjs_require__(97);
  4035. var anObject = __w_pdfjs_require__(8);
  4036. var toLength = __w_pdfjs_require__(31);
  4037. var getIterFn = __w_pdfjs_require__(98);
  4038. var BREAK = {};
  4039. var RETURN = {};
  4040. var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
  4041. var iterFn = ITERATOR ? function () {
  4042. return iterable;
  4043. } : getIterFn(iterable);
  4044. var f = ctx(fn, that, entries ? 2 : 1);
  4045. var index = 0;
  4046. var length, step, iterator, result;
  4047. if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
  4048. if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
  4049. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  4050. if (result === BREAK || result === RETURN) return result;
  4051. } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
  4052. result = call(iterator, f, step.value, entries);
  4053. if (result === BREAK || result === RETURN) return result;
  4054. }
  4055. };
  4056. _exports.BREAK = BREAK;
  4057. _exports.RETURN = RETURN;
  4058. /***/ }),
  4059. /* 26 */
  4060. /***/ (function(module, exports, __w_pdfjs_require__) {
  4061. "use strict";
  4062. Object.defineProperty(exports, "__esModule", {
  4063. value: true
  4064. });
  4065. exports.Parser = exports.Linearization = exports.Lexer = undefined;
  4066. var _stream = __w_pdfjs_require__(5);
  4067. var _util = __w_pdfjs_require__(0);
  4068. var _primitives = __w_pdfjs_require__(1);
  4069. var _ccitt_stream = __w_pdfjs_require__(125);
  4070. var _jbig2_stream = __w_pdfjs_require__(127);
  4071. var MAX_LENGTH_TO_CACHE = 1000;
  4072. var Parser = function ParserClosure() {
  4073. function Parser(lexer, allowStreams, xref, recoveryMode) {
  4074. this.lexer = lexer;
  4075. this.allowStreams = allowStreams;
  4076. this.xref = xref;
  4077. this.recoveryMode = recoveryMode || false;
  4078. this.imageCache = Object.create(null);
  4079. this.refill();
  4080. }
  4081. Parser.prototype = {
  4082. refill: function Parser_refill() {
  4083. this.buf1 = this.lexer.getObj();
  4084. this.buf2 = this.lexer.getObj();
  4085. },
  4086. shift: function Parser_shift() {
  4087. if ((0, _primitives.isCmd)(this.buf2, 'ID')) {
  4088. this.buf1 = this.buf2;
  4089. this.buf2 = null;
  4090. } else {
  4091. this.buf1 = this.buf2;
  4092. this.buf2 = this.lexer.getObj();
  4093. }
  4094. },
  4095. tryShift: function Parser_tryShift() {
  4096. try {
  4097. this.shift();
  4098. return true;
  4099. } catch (e) {
  4100. if (e instanceof _util.MissingDataException) {
  4101. throw e;
  4102. }
  4103. return false;
  4104. }
  4105. },
  4106. getObj: function Parser_getObj(cipherTransform) {
  4107. var buf1 = this.buf1;
  4108. this.shift();
  4109. if (buf1 instanceof _primitives.Cmd) {
  4110. switch (buf1.cmd) {
  4111. case 'BI':
  4112. return this.makeInlineImage(cipherTransform);
  4113. case '[':
  4114. var array = [];
  4115. while (!(0, _primitives.isCmd)(this.buf1, ']') && !(0, _primitives.isEOF)(this.buf1)) {
  4116. array.push(this.getObj(cipherTransform));
  4117. }
  4118. if ((0, _primitives.isEOF)(this.buf1)) {
  4119. if (!this.recoveryMode) {
  4120. throw new _util.FormatError('End of file inside array');
  4121. }
  4122. return array;
  4123. }
  4124. this.shift();
  4125. return array;
  4126. case '<<':
  4127. var dict = new _primitives.Dict(this.xref);
  4128. while (!(0, _primitives.isCmd)(this.buf1, '>>') && !(0, _primitives.isEOF)(this.buf1)) {
  4129. if (!(0, _primitives.isName)(this.buf1)) {
  4130. (0, _util.info)('Malformed dictionary: key must be a name object');
  4131. this.shift();
  4132. continue;
  4133. }
  4134. var key = this.buf1.name;
  4135. this.shift();
  4136. if ((0, _primitives.isEOF)(this.buf1)) {
  4137. break;
  4138. }
  4139. dict.set(key, this.getObj(cipherTransform));
  4140. }
  4141. if ((0, _primitives.isEOF)(this.buf1)) {
  4142. if (!this.recoveryMode) {
  4143. throw new _util.FormatError('End of file inside dictionary');
  4144. }
  4145. return dict;
  4146. }
  4147. if ((0, _primitives.isCmd)(this.buf2, 'stream')) {
  4148. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  4149. }
  4150. this.shift();
  4151. return dict;
  4152. default:
  4153. return buf1;
  4154. }
  4155. }
  4156. if (Number.isInteger(buf1)) {
  4157. var num = buf1;
  4158. if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, 'R')) {
  4159. var ref = new _primitives.Ref(num, this.buf1);
  4160. this.shift();
  4161. this.shift();
  4162. return ref;
  4163. }
  4164. return num;
  4165. }
  4166. if ((0, _util.isString)(buf1)) {
  4167. var str = buf1;
  4168. if (cipherTransform) {
  4169. str = cipherTransform.decryptString(str);
  4170. }
  4171. return str;
  4172. }
  4173. return buf1;
  4174. },
  4175. findDefaultInlineStreamEnd: function findDefaultInlineStreamEnd(stream) {
  4176. var E = 0x45,
  4177. I = 0x49,
  4178. SPACE = 0x20,
  4179. LF = 0xA,
  4180. CR = 0xD;
  4181. var n = 10,
  4182. NUL = 0x0;
  4183. var startPos = stream.pos,
  4184. state = 0,
  4185. ch = void 0,
  4186. maybeEIPos = void 0;
  4187. while ((ch = stream.getByte()) !== -1) {
  4188. if (state === 0) {
  4189. state = ch === E ? 1 : 0;
  4190. } else if (state === 1) {
  4191. state = ch === I ? 2 : 0;
  4192. } else {
  4193. (0, _util.assert)(state === 2);
  4194. if (ch === SPACE || ch === LF || ch === CR) {
  4195. maybeEIPos = stream.pos;
  4196. var followingBytes = stream.peekBytes(n);
  4197. for (var i = 0, ii = followingBytes.length; i < ii; i++) {
  4198. ch = followingBytes[i];
  4199. if (ch === NUL && followingBytes[i + 1] !== NUL) {
  4200. continue;
  4201. }
  4202. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  4203. state = 0;
  4204. break;
  4205. }
  4206. }
  4207. if (state === 2) {
  4208. break;
  4209. }
  4210. } else {
  4211. state = 0;
  4212. }
  4213. }
  4214. }
  4215. if (ch === -1) {
  4216. (0, _util.warn)('findDefaultInlineStreamEnd: ' + 'Reached the end of the stream without finding a valid EI marker');
  4217. if (maybeEIPos) {
  4218. (0, _util.warn)('... trying to recover by using the last "EI" occurrence.');
  4219. stream.skip(-(stream.pos - maybeEIPos));
  4220. }
  4221. }
  4222. return stream.pos - 4 - startPos;
  4223. },
  4224. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  4225. var startPos = stream.pos,
  4226. foundEOI = false,
  4227. b,
  4228. markerLength,
  4229. length;
  4230. while ((b = stream.getByte()) !== -1) {
  4231. if (b !== 0xFF) {
  4232. continue;
  4233. }
  4234. switch (stream.getByte()) {
  4235. case 0x00:
  4236. break;
  4237. case 0xFF:
  4238. stream.skip(-1);
  4239. break;
  4240. case 0xD9:
  4241. foundEOI = true;
  4242. break;
  4243. case 0xC0:
  4244. case 0xC1:
  4245. case 0xC2:
  4246. case 0xC3:
  4247. case 0xC5:
  4248. case 0xC6:
  4249. case 0xC7:
  4250. case 0xC9:
  4251. case 0xCA:
  4252. case 0xCB:
  4253. case 0xCD:
  4254. case 0xCE:
  4255. case 0xCF:
  4256. case 0xC4:
  4257. case 0xCC:
  4258. case 0xDA:
  4259. case 0xDB:
  4260. case 0xDC:
  4261. case 0xDD:
  4262. case 0xDE:
  4263. case 0xDF:
  4264. case 0xE0:
  4265. case 0xE1:
  4266. case 0xE2:
  4267. case 0xE3:
  4268. case 0xE4:
  4269. case 0xE5:
  4270. case 0xE6:
  4271. case 0xE7:
  4272. case 0xE8:
  4273. case 0xE9:
  4274. case 0xEA:
  4275. case 0xEB:
  4276. case 0xEC:
  4277. case 0xED:
  4278. case 0xEE:
  4279. case 0xEF:
  4280. case 0xFE:
  4281. markerLength = stream.getUint16();
  4282. if (markerLength > 2) {
  4283. stream.skip(markerLength - 2);
  4284. } else {
  4285. stream.skip(-2);
  4286. }
  4287. break;
  4288. }
  4289. if (foundEOI) {
  4290. break;
  4291. }
  4292. }
  4293. length = stream.pos - startPos;
  4294. if (b === -1) {
  4295. (0, _util.warn)('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  4296. stream.skip(-length);
  4297. return this.findDefaultInlineStreamEnd(stream);
  4298. }
  4299. this.inlineStreamSkipEI(stream);
  4300. return length;
  4301. },
  4302. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  4303. var TILDE = 0x7E,
  4304. GT = 0x3E;
  4305. var startPos = stream.pos,
  4306. ch,
  4307. length;
  4308. while ((ch = stream.getByte()) !== -1) {
  4309. if (ch === TILDE && stream.peekByte() === GT) {
  4310. stream.skip();
  4311. break;
  4312. }
  4313. }
  4314. length = stream.pos - startPos;
  4315. if (ch === -1) {
  4316. (0, _util.warn)('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  4317. stream.skip(-length);
  4318. return this.findDefaultInlineStreamEnd(stream);
  4319. }
  4320. this.inlineStreamSkipEI(stream);
  4321. return length;
  4322. },
  4323. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  4324. var GT = 0x3E;
  4325. var startPos = stream.pos,
  4326. ch,
  4327. length;
  4328. while ((ch = stream.getByte()) !== -1) {
  4329. if (ch === GT) {
  4330. break;
  4331. }
  4332. }
  4333. length = stream.pos - startPos;
  4334. if (ch === -1) {
  4335. (0, _util.warn)('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  4336. stream.skip(-length);
  4337. return this.findDefaultInlineStreamEnd(stream);
  4338. }
  4339. this.inlineStreamSkipEI(stream);
  4340. return length;
  4341. },
  4342. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  4343. var E = 0x45,
  4344. I = 0x49;
  4345. var state = 0,
  4346. ch;
  4347. while ((ch = stream.getByte()) !== -1) {
  4348. if (state === 0) {
  4349. state = ch === E ? 1 : 0;
  4350. } else if (state === 1) {
  4351. state = ch === I ? 2 : 0;
  4352. } else if (state === 2) {
  4353. break;
  4354. }
  4355. }
  4356. },
  4357. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  4358. var lexer = this.lexer;
  4359. var stream = lexer.stream;
  4360. var dict = new _primitives.Dict(this.xref);
  4361. while (!(0, _primitives.isCmd)(this.buf1, 'ID') && !(0, _primitives.isEOF)(this.buf1)) {
  4362. if (!(0, _primitives.isName)(this.buf1)) {
  4363. throw new _util.FormatError('Dictionary key must be a name object');
  4364. }
  4365. var key = this.buf1.name;
  4366. this.shift();
  4367. if ((0, _primitives.isEOF)(this.buf1)) {
  4368. break;
  4369. }
  4370. dict.set(key, this.getObj(cipherTransform));
  4371. }
  4372. var filter = dict.get('Filter', 'F'),
  4373. filterName;
  4374. if ((0, _primitives.isName)(filter)) {
  4375. filterName = filter.name;
  4376. } else if (Array.isArray(filter)) {
  4377. var filterZero = this.xref.fetchIfRef(filter[0]);
  4378. if ((0, _primitives.isName)(filterZero)) {
  4379. filterName = filterZero.name;
  4380. }
  4381. }
  4382. var startPos = stream.pos,
  4383. length,
  4384. i,
  4385. ii;
  4386. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  4387. length = this.findDCTDecodeInlineStreamEnd(stream);
  4388. } else if (filterName === 'ASCII85Decode' || filterName === 'A85') {
  4389. length = this.findASCII85DecodeInlineStreamEnd(stream);
  4390. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  4391. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  4392. } else {
  4393. length = this.findDefaultInlineStreamEnd(stream);
  4394. }
  4395. var imageStream = stream.makeSubStream(startPos, length, dict);
  4396. var adler32;
  4397. if (length < MAX_LENGTH_TO_CACHE) {
  4398. var imageBytes = imageStream.getBytes();
  4399. imageStream.reset();
  4400. var a = 1;
  4401. var b = 0;
  4402. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  4403. a += imageBytes[i] & 0xff;
  4404. b += a;
  4405. }
  4406. adler32 = b % 65521 << 16 | a % 65521;
  4407. var cacheEntry = this.imageCache[adler32];
  4408. if (cacheEntry !== undefined) {
  4409. this.buf2 = _primitives.Cmd.get('EI');
  4410. this.shift();
  4411. cacheEntry.reset();
  4412. return cacheEntry;
  4413. }
  4414. }
  4415. if (cipherTransform) {
  4416. imageStream = cipherTransform.createStream(imageStream, length);
  4417. }
  4418. imageStream = this.filter(imageStream, dict, length);
  4419. imageStream.dict = dict;
  4420. if (adler32 !== undefined) {
  4421. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  4422. this.imageCache[adler32] = imageStream;
  4423. }
  4424. this.buf2 = _primitives.Cmd.get('EI');
  4425. this.shift();
  4426. return imageStream;
  4427. },
  4428. makeStream: function Parser_makeStream(dict, cipherTransform) {
  4429. var lexer = this.lexer;
  4430. var stream = lexer.stream;
  4431. lexer.skipToNextLine();
  4432. var pos = stream.pos - 1;
  4433. var length = dict.get('Length');
  4434. if (!Number.isInteger(length)) {
  4435. (0, _util.info)('Bad ' + length + ' attribute in stream');
  4436. length = 0;
  4437. }
  4438. stream.pos = pos + length;
  4439. lexer.nextChar();
  4440. if (this.tryShift() && (0, _primitives.isCmd)(this.buf2, 'endstream')) {
  4441. this.shift();
  4442. } else {
  4443. stream.pos = pos;
  4444. var SCAN_BLOCK_SIZE = 2048;
  4445. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  4446. var ENDSTREAM_SIGNATURE = [0x65, 0x6E, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6D];
  4447. var skipped = 0,
  4448. found = false,
  4449. i,
  4450. j;
  4451. while (stream.pos < stream.end) {
  4452. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  4453. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  4454. if (scanLength <= 0) {
  4455. break;
  4456. }
  4457. found = false;
  4458. i = 0;
  4459. while (i < scanLength) {
  4460. j = 0;
  4461. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  4462. j++;
  4463. }
  4464. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  4465. found = true;
  4466. break;
  4467. }
  4468. i++;
  4469. }
  4470. if (found) {
  4471. skipped += i;
  4472. stream.pos += i;
  4473. break;
  4474. }
  4475. skipped += scanLength;
  4476. stream.pos += scanLength;
  4477. }
  4478. if (!found) {
  4479. throw new _util.FormatError('Missing endstream');
  4480. }
  4481. length = skipped;
  4482. lexer.nextChar();
  4483. this.shift();
  4484. this.shift();
  4485. }
  4486. this.shift();
  4487. stream = stream.makeSubStream(pos, length, dict);
  4488. if (cipherTransform) {
  4489. stream = cipherTransform.createStream(stream, length);
  4490. }
  4491. stream = this.filter(stream, dict, length);
  4492. stream.dict = dict;
  4493. return stream;
  4494. },
  4495. filter: function Parser_filter(stream, dict, length) {
  4496. var filter = dict.get('Filter', 'F');
  4497. var params = dict.get('DecodeParms', 'DP');
  4498. if ((0, _primitives.isName)(filter)) {
  4499. if (Array.isArray(params)) {
  4500. (0, _util.warn)('/DecodeParms should not contain an Array, ' + 'when /Filter contains a Name.');
  4501. }
  4502. return this.makeFilter(stream, filter.name, length, params);
  4503. }
  4504. var maybeLength = length;
  4505. if (Array.isArray(filter)) {
  4506. var filterArray = filter;
  4507. var paramsArray = params;
  4508. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  4509. filter = this.xref.fetchIfRef(filterArray[i]);
  4510. if (!(0, _primitives.isName)(filter)) {
  4511. throw new _util.FormatError('Bad filter name: ' + filter);
  4512. }
  4513. params = null;
  4514. if (Array.isArray(paramsArray) && i in paramsArray) {
  4515. params = this.xref.fetchIfRef(paramsArray[i]);
  4516. }
  4517. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  4518. maybeLength = null;
  4519. }
  4520. }
  4521. return stream;
  4522. },
  4523. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  4524. if (maybeLength === 0) {
  4525. (0, _util.warn)('Empty "' + name + '" stream.');
  4526. return new _stream.NullStream();
  4527. }
  4528. try {
  4529. var xrefStreamStats = this.xref.stats.streamTypes;
  4530. if (name === 'FlateDecode' || name === 'Fl') {
  4531. xrefStreamStats[_util.StreamType.FLATE] = true;
  4532. if (params) {
  4533. return new _stream.PredictorStream(new _stream.FlateStream(stream, maybeLength), maybeLength, params);
  4534. }
  4535. return new _stream.FlateStream(stream, maybeLength);
  4536. }
  4537. if (name === 'LZWDecode' || name === 'LZW') {
  4538. xrefStreamStats[_util.StreamType.LZW] = true;
  4539. var earlyChange = 1;
  4540. if (params) {
  4541. if (params.has('EarlyChange')) {
  4542. earlyChange = params.get('EarlyChange');
  4543. }
  4544. return new _stream.PredictorStream(new _stream.LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  4545. }
  4546. return new _stream.LZWStream(stream, maybeLength, earlyChange);
  4547. }
  4548. if (name === 'DCTDecode' || name === 'DCT') {
  4549. xrefStreamStats[_util.StreamType.DCT] = true;
  4550. return new _stream.JpegStream(stream, maybeLength, stream.dict, params);
  4551. }
  4552. if (name === 'JPXDecode' || name === 'JPX') {
  4553. xrefStreamStats[_util.StreamType.JPX] = true;
  4554. return new _stream.JpxStream(stream, maybeLength, stream.dict, params);
  4555. }
  4556. if (name === 'ASCII85Decode' || name === 'A85') {
  4557. xrefStreamStats[_util.StreamType.A85] = true;
  4558. return new _stream.Ascii85Stream(stream, maybeLength);
  4559. }
  4560. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  4561. xrefStreamStats[_util.StreamType.AHX] = true;
  4562. return new _stream.AsciiHexStream(stream, maybeLength);
  4563. }
  4564. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  4565. xrefStreamStats[_util.StreamType.CCF] = true;
  4566. return new _ccitt_stream.CCITTFaxStream(stream, maybeLength, params);
  4567. }
  4568. if (name === 'RunLengthDecode' || name === 'RL') {
  4569. xrefStreamStats[_util.StreamType.RL] = true;
  4570. return new _stream.RunLengthStream(stream, maybeLength);
  4571. }
  4572. if (name === 'JBIG2Decode') {
  4573. xrefStreamStats[_util.StreamType.JBIG] = true;
  4574. return new _jbig2_stream.Jbig2Stream(stream, maybeLength, stream.dict, params);
  4575. }
  4576. (0, _util.warn)('filter "' + name + '" not supported yet');
  4577. return stream;
  4578. } catch (ex) {
  4579. if (ex instanceof _util.MissingDataException) {
  4580. throw ex;
  4581. }
  4582. (0, _util.warn)('Invalid stream: \"' + ex + '\"');
  4583. return new _stream.NullStream();
  4584. }
  4585. }
  4586. };
  4587. return Parser;
  4588. }();
  4589. var Lexer = function LexerClosure() {
  4590. function Lexer(stream, knownCommands) {
  4591. this.stream = stream;
  4592. this.nextChar();
  4593. this.strBuf = [];
  4594. this.knownCommands = knownCommands;
  4595. }
  4596. 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];
  4597. function toHexDigit(ch) {
  4598. if (ch >= 0x30 && ch <= 0x39) {
  4599. return ch & 0x0F;
  4600. }
  4601. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  4602. return (ch & 0x0F) + 9;
  4603. }
  4604. return -1;
  4605. }
  4606. Lexer.prototype = {
  4607. nextChar: function Lexer_nextChar() {
  4608. return this.currentChar = this.stream.getByte();
  4609. },
  4610. peekChar: function Lexer_peekChar() {
  4611. return this.stream.peekByte();
  4612. },
  4613. getNumber: function Lexer_getNumber() {
  4614. var ch = this.currentChar;
  4615. var eNotation = false;
  4616. var divideBy = 0;
  4617. var sign = 1;
  4618. if (ch === 0x2D) {
  4619. sign = -1;
  4620. ch = this.nextChar();
  4621. if (ch === 0x2D) {
  4622. ch = this.nextChar();
  4623. }
  4624. } else if (ch === 0x2B) {
  4625. ch = this.nextChar();
  4626. }
  4627. if (ch === 0x2E) {
  4628. divideBy = 10;
  4629. ch = this.nextChar();
  4630. }
  4631. if (ch === 0x0A || ch === 0x0D) {
  4632. do {
  4633. ch = this.nextChar();
  4634. } while (ch === 0x0A || ch === 0x0D);
  4635. }
  4636. if (ch < 0x30 || ch > 0x39) {
  4637. throw new _util.FormatError('Invalid number: ' + String.fromCharCode(ch) + ' (charCode ' + ch + ')');
  4638. }
  4639. var baseValue = ch - 0x30;
  4640. var powerValue = 0;
  4641. var powerValueSign = 1;
  4642. while ((ch = this.nextChar()) >= 0) {
  4643. if (0x30 <= ch && ch <= 0x39) {
  4644. var currentDigit = ch - 0x30;
  4645. if (eNotation) {
  4646. powerValue = powerValue * 10 + currentDigit;
  4647. } else {
  4648. if (divideBy !== 0) {
  4649. divideBy *= 10;
  4650. }
  4651. baseValue = baseValue * 10 + currentDigit;
  4652. }
  4653. } else if (ch === 0x2E) {
  4654. if (divideBy === 0) {
  4655. divideBy = 1;
  4656. } else {
  4657. break;
  4658. }
  4659. } else if (ch === 0x2D) {
  4660. (0, _util.warn)('Badly formatted number');
  4661. } else if (ch === 0x45 || ch === 0x65) {
  4662. ch = this.peekChar();
  4663. if (ch === 0x2B || ch === 0x2D) {
  4664. powerValueSign = ch === 0x2D ? -1 : 1;
  4665. this.nextChar();
  4666. } else if (ch < 0x30 || ch > 0x39) {
  4667. break;
  4668. }
  4669. eNotation = true;
  4670. } else {
  4671. break;
  4672. }
  4673. }
  4674. if (divideBy !== 0) {
  4675. baseValue /= divideBy;
  4676. }
  4677. if (eNotation) {
  4678. baseValue *= Math.pow(10, powerValueSign * powerValue);
  4679. }
  4680. return sign * baseValue;
  4681. },
  4682. getString: function Lexer_getString() {
  4683. var numParen = 1;
  4684. var done = false;
  4685. var strBuf = this.strBuf;
  4686. strBuf.length = 0;
  4687. var ch = this.nextChar();
  4688. while (true) {
  4689. var charBuffered = false;
  4690. switch (ch | 0) {
  4691. case -1:
  4692. (0, _util.warn)('Unterminated string');
  4693. done = true;
  4694. break;
  4695. case 0x28:
  4696. ++numParen;
  4697. strBuf.push('(');
  4698. break;
  4699. case 0x29:
  4700. if (--numParen === 0) {
  4701. this.nextChar();
  4702. done = true;
  4703. } else {
  4704. strBuf.push(')');
  4705. }
  4706. break;
  4707. case 0x5C:
  4708. ch = this.nextChar();
  4709. switch (ch) {
  4710. case -1:
  4711. (0, _util.warn)('Unterminated string');
  4712. done = true;
  4713. break;
  4714. case 0x6E:
  4715. strBuf.push('\n');
  4716. break;
  4717. case 0x72:
  4718. strBuf.push('\r');
  4719. break;
  4720. case 0x74:
  4721. strBuf.push('\t');
  4722. break;
  4723. case 0x62:
  4724. strBuf.push('\b');
  4725. break;
  4726. case 0x66:
  4727. strBuf.push('\f');
  4728. break;
  4729. case 0x5C:
  4730. case 0x28:
  4731. case 0x29:
  4732. strBuf.push(String.fromCharCode(ch));
  4733. break;
  4734. case 0x30:
  4735. case 0x31:
  4736. case 0x32:
  4737. case 0x33:
  4738. case 0x34:
  4739. case 0x35:
  4740. case 0x36:
  4741. case 0x37:
  4742. var x = ch & 0x0F;
  4743. ch = this.nextChar();
  4744. charBuffered = true;
  4745. if (ch >= 0x30 && ch <= 0x37) {
  4746. x = (x << 3) + (ch & 0x0F);
  4747. ch = this.nextChar();
  4748. if (ch >= 0x30 && ch <= 0x37) {
  4749. charBuffered = false;
  4750. x = (x << 3) + (ch & 0x0F);
  4751. }
  4752. }
  4753. strBuf.push(String.fromCharCode(x));
  4754. break;
  4755. case 0x0D:
  4756. if (this.peekChar() === 0x0A) {
  4757. this.nextChar();
  4758. }
  4759. break;
  4760. case 0x0A:
  4761. break;
  4762. default:
  4763. strBuf.push(String.fromCharCode(ch));
  4764. break;
  4765. }
  4766. break;
  4767. default:
  4768. strBuf.push(String.fromCharCode(ch));
  4769. break;
  4770. }
  4771. if (done) {
  4772. break;
  4773. }
  4774. if (!charBuffered) {
  4775. ch = this.nextChar();
  4776. }
  4777. }
  4778. return strBuf.join('');
  4779. },
  4780. getName: function Lexer_getName() {
  4781. var ch, previousCh;
  4782. var strBuf = this.strBuf;
  4783. strBuf.length = 0;
  4784. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  4785. if (ch === 0x23) {
  4786. ch = this.nextChar();
  4787. if (specialChars[ch]) {
  4788. (0, _util.warn)('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  4789. strBuf.push('#');
  4790. break;
  4791. }
  4792. var x = toHexDigit(ch);
  4793. if (x !== -1) {
  4794. previousCh = ch;
  4795. ch = this.nextChar();
  4796. var x2 = toHexDigit(ch);
  4797. if (x2 === -1) {
  4798. (0, _util.warn)('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  4799. strBuf.push('#', String.fromCharCode(previousCh));
  4800. if (specialChars[ch]) {
  4801. break;
  4802. }
  4803. strBuf.push(String.fromCharCode(ch));
  4804. continue;
  4805. }
  4806. strBuf.push(String.fromCharCode(x << 4 | x2));
  4807. } else {
  4808. strBuf.push('#', String.fromCharCode(ch));
  4809. }
  4810. } else {
  4811. strBuf.push(String.fromCharCode(ch));
  4812. }
  4813. }
  4814. if (strBuf.length > 127) {
  4815. (0, _util.warn)('name token is longer than allowed by the spec: ' + strBuf.length);
  4816. }
  4817. return _primitives.Name.get(strBuf.join(''));
  4818. },
  4819. getHexString: function Lexer_getHexString() {
  4820. var strBuf = this.strBuf;
  4821. strBuf.length = 0;
  4822. var ch = this.currentChar;
  4823. var isFirstHex = true;
  4824. var firstDigit;
  4825. var secondDigit;
  4826. while (true) {
  4827. if (ch < 0) {
  4828. (0, _util.warn)('Unterminated hex string');
  4829. break;
  4830. } else if (ch === 0x3E) {
  4831. this.nextChar();
  4832. break;
  4833. } else if (specialChars[ch] === 1) {
  4834. ch = this.nextChar();
  4835. continue;
  4836. } else {
  4837. if (isFirstHex) {
  4838. firstDigit = toHexDigit(ch);
  4839. if (firstDigit === -1) {
  4840. (0, _util.warn)('Ignoring invalid character "' + ch + '" in hex string');
  4841. ch = this.nextChar();
  4842. continue;
  4843. }
  4844. } else {
  4845. secondDigit = toHexDigit(ch);
  4846. if (secondDigit === -1) {
  4847. (0, _util.warn)('Ignoring invalid character "' + ch + '" in hex string');
  4848. ch = this.nextChar();
  4849. continue;
  4850. }
  4851. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  4852. }
  4853. isFirstHex = !isFirstHex;
  4854. ch = this.nextChar();
  4855. }
  4856. }
  4857. return strBuf.join('');
  4858. },
  4859. getObj: function Lexer_getObj() {
  4860. var comment = false;
  4861. var ch = this.currentChar;
  4862. while (true) {
  4863. if (ch < 0) {
  4864. return _primitives.EOF;
  4865. }
  4866. if (comment) {
  4867. if (ch === 0x0A || ch === 0x0D) {
  4868. comment = false;
  4869. }
  4870. } else if (ch === 0x25) {
  4871. comment = true;
  4872. } else if (specialChars[ch] !== 1) {
  4873. break;
  4874. }
  4875. ch = this.nextChar();
  4876. }
  4877. switch (ch | 0) {
  4878. case 0x30:
  4879. case 0x31:
  4880. case 0x32:
  4881. case 0x33:
  4882. case 0x34:
  4883. case 0x35:
  4884. case 0x36:
  4885. case 0x37:
  4886. case 0x38:
  4887. case 0x39:
  4888. case 0x2B:
  4889. case 0x2D:
  4890. case 0x2E:
  4891. return this.getNumber();
  4892. case 0x28:
  4893. return this.getString();
  4894. case 0x2F:
  4895. return this.getName();
  4896. case 0x5B:
  4897. this.nextChar();
  4898. return _primitives.Cmd.get('[');
  4899. case 0x5D:
  4900. this.nextChar();
  4901. return _primitives.Cmd.get(']');
  4902. case 0x3C:
  4903. ch = this.nextChar();
  4904. if (ch === 0x3C) {
  4905. this.nextChar();
  4906. return _primitives.Cmd.get('<<');
  4907. }
  4908. return this.getHexString();
  4909. case 0x3E:
  4910. ch = this.nextChar();
  4911. if (ch === 0x3E) {
  4912. this.nextChar();
  4913. return _primitives.Cmd.get('>>');
  4914. }
  4915. return _primitives.Cmd.get('>');
  4916. case 0x7B:
  4917. this.nextChar();
  4918. return _primitives.Cmd.get('{');
  4919. case 0x7D:
  4920. this.nextChar();
  4921. return _primitives.Cmd.get('}');
  4922. case 0x29:
  4923. this.nextChar();
  4924. throw new _util.FormatError('Illegal character: ' + ch);
  4925. }
  4926. var str = String.fromCharCode(ch);
  4927. var knownCommands = this.knownCommands;
  4928. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  4929. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  4930. var possibleCommand = str + String.fromCharCode(ch);
  4931. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  4932. break;
  4933. }
  4934. if (str.length === 128) {
  4935. throw new _util.FormatError('Command token too long: ' + str.length);
  4936. }
  4937. str = possibleCommand;
  4938. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  4939. }
  4940. if (str === 'true') {
  4941. return true;
  4942. }
  4943. if (str === 'false') {
  4944. return false;
  4945. }
  4946. if (str === 'null') {
  4947. return null;
  4948. }
  4949. return _primitives.Cmd.get(str);
  4950. },
  4951. skipToNextLine: function Lexer_skipToNextLine() {
  4952. var ch = this.currentChar;
  4953. while (ch >= 0) {
  4954. if (ch === 0x0D) {
  4955. ch = this.nextChar();
  4956. if (ch === 0x0A) {
  4957. this.nextChar();
  4958. }
  4959. break;
  4960. } else if (ch === 0x0A) {
  4961. this.nextChar();
  4962. break;
  4963. }
  4964. ch = this.nextChar();
  4965. }
  4966. }
  4967. };
  4968. return Lexer;
  4969. }();
  4970. var Linearization = {
  4971. create: function LinearizationCreate(stream) {
  4972. function getInt(name, allowZeroValue) {
  4973. var obj = linDict.get(name);
  4974. if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  4975. return obj;
  4976. }
  4977. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  4978. }
  4979. function getHints() {
  4980. var hints = linDict.get('H'),
  4981. hintsLength,
  4982. item;
  4983. if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  4984. for (var index = 0; index < hintsLength; index++) {
  4985. if (!(Number.isInteger(item = hints[index]) && item > 0)) {
  4986. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  4987. }
  4988. }
  4989. return hints;
  4990. }
  4991. throw new Error('Hint array in the linearization dictionary is invalid.');
  4992. }
  4993. var parser = new Parser(new Lexer(stream), false, null);
  4994. var obj1 = parser.getObj();
  4995. var obj2 = parser.getObj();
  4996. var obj3 = parser.getObj();
  4997. var linDict = parser.getObj();
  4998. var obj, length;
  4999. if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, 'obj') && (0, _primitives.isDict)(linDict) && (0, _util.isNum)(obj = linDict.get('Linearized')) && obj > 0)) {
  5000. return null;
  5001. } else if ((length = getInt('L')) !== stream.length) {
  5002. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  5003. }
  5004. return {
  5005. length: length,
  5006. hints: getHints(),
  5007. objectNumberFirst: getInt('O'),
  5008. endFirst: getInt('E'),
  5009. numPages: getInt('N'),
  5010. mainXRefEntriesOffset: getInt('T'),
  5011. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  5012. };
  5013. }
  5014. };
  5015. exports.Lexer = Lexer;
  5016. exports.Linearization = Linearization;
  5017. exports.Parser = Parser;
  5018. /***/ }),
  5019. /* 27 */
  5020. /***/ (function(module, exports, __w_pdfjs_require__) {
  5021. "use strict";
  5022. var isObject = __w_pdfjs_require__(2);
  5023. var document = __w_pdfjs_require__(4).document;
  5024. var is = isObject(document) && isObject(document.createElement);
  5025. module.exports = function (it) {
  5026. return is ? document.createElement(it) : {};
  5027. };
  5028. /***/ }),
  5029. /* 28 */
  5030. /***/ (function(module, exports, __w_pdfjs_require__) {
  5031. "use strict";
  5032. module.exports = function (bitmap, value) {
  5033. return {
  5034. enumerable: !(bitmap & 1),
  5035. configurable: !(bitmap & 2),
  5036. writable: !(bitmap & 4),
  5037. value: value
  5038. };
  5039. };
  5040. /***/ }),
  5041. /* 29 */
  5042. /***/ (function(module, exports, __w_pdfjs_require__) {
  5043. "use strict";
  5044. var cof = __w_pdfjs_require__(18);
  5045. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
  5046. return cof(it) == 'String' ? it.split('') : Object(it);
  5047. };
  5048. /***/ }),
  5049. /* 30 */
  5050. /***/ (function(module, exports, __w_pdfjs_require__) {
  5051. "use strict";
  5052. module.exports = function (it) {
  5053. if (it == undefined) throw TypeError("Can't call method on " + it);
  5054. return it;
  5055. };
  5056. /***/ }),
  5057. /* 31 */
  5058. /***/ (function(module, exports, __w_pdfjs_require__) {
  5059. "use strict";
  5060. var toInteger = __w_pdfjs_require__(32);
  5061. var min = Math.min;
  5062. module.exports = function (it) {
  5063. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0;
  5064. };
  5065. /***/ }),
  5066. /* 32 */
  5067. /***/ (function(module, exports, __w_pdfjs_require__) {
  5068. "use strict";
  5069. var ceil = Math.ceil;
  5070. var floor = Math.floor;
  5071. module.exports = function (it) {
  5072. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  5073. };
  5074. /***/ }),
  5075. /* 33 */
  5076. /***/ (function(module, exports, __w_pdfjs_require__) {
  5077. "use strict";
  5078. var shared = __w_pdfjs_require__(46)('keys');
  5079. var uid = __w_pdfjs_require__(22);
  5080. module.exports = function (key) {
  5081. return shared[key] || (shared[key] = uid(key));
  5082. };
  5083. /***/ }),
  5084. /* 34 */
  5085. /***/ (function(module, exports, __w_pdfjs_require__) {
  5086. "use strict";
  5087. exports.f = {}.propertyIsEnumerable;
  5088. /***/ }),
  5089. /* 35 */
  5090. /***/ (function(module, exports, __w_pdfjs_require__) {
  5091. "use strict";
  5092. var cof = __w_pdfjs_require__(18);
  5093. var TAG = __w_pdfjs_require__(3)('toStringTag');
  5094. var ARG = cof(function () {
  5095. return arguments;
  5096. }()) == 'Arguments';
  5097. var tryGet = function tryGet(it, key) {
  5098. try {
  5099. return it[key];
  5100. } catch (e) {}
  5101. };
  5102. module.exports = function (it) {
  5103. var O, T, B;
  5104. return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  5105. };
  5106. /***/ }),
  5107. /* 36 */
  5108. /***/ (function(module, exports, __w_pdfjs_require__) {
  5109. "use strict";
  5110. var defined = __w_pdfjs_require__(30);
  5111. module.exports = function (it) {
  5112. return Object(defined(it));
  5113. };
  5114. /***/ }),
  5115. /* 37 */
  5116. /***/ (function(module, exports, __w_pdfjs_require__) {
  5117. "use strict";
  5118. module.exports = function (it, Constructor, name, forbiddenField) {
  5119. if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) {
  5120. throw TypeError(name + ': incorrect invocation!');
  5121. }
  5122. return it;
  5123. };
  5124. /***/ }),
  5125. /* 38 */
  5126. /***/ (function(module, exports, __w_pdfjs_require__) {
  5127. "use strict";
  5128. var aFunction = __w_pdfjs_require__(16);
  5129. function PromiseCapability(C) {
  5130. var resolve, reject;
  5131. this.promise = new C(function ($$resolve, $$reject) {
  5132. if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
  5133. resolve = $$resolve;
  5134. reject = $$reject;
  5135. });
  5136. this.resolve = aFunction(resolve);
  5137. this.reject = aFunction(reject);
  5138. }
  5139. module.exports.f = function (C) {
  5140. return new PromiseCapability(C);
  5141. };
  5142. /***/ }),
  5143. /* 39 */
  5144. /***/ (function(module, exports, __w_pdfjs_require__) {
  5145. "use strict";
  5146. var redefine = __w_pdfjs_require__(10);
  5147. module.exports = function (target, src, safe) {
  5148. for (var key in src) {
  5149. redefine(target, key, src[key], safe);
  5150. }return target;
  5151. };
  5152. /***/ }),
  5153. /* 40 */
  5154. /***/ (function(module, exports, __w_pdfjs_require__) {
  5155. "use strict";
  5156. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  5157. var META = __w_pdfjs_require__(22)('meta');
  5158. var isObject = __w_pdfjs_require__(2);
  5159. var has = __w_pdfjs_require__(9);
  5160. var setDesc = __w_pdfjs_require__(15).f;
  5161. var id = 0;
  5162. var isExtensible = Object.isExtensible || function () {
  5163. return true;
  5164. };
  5165. var FREEZE = !__w_pdfjs_require__(14)(function () {
  5166. return isExtensible(Object.preventExtensions({}));
  5167. });
  5168. var setMeta = function setMeta(it) {
  5169. setDesc(it, META, {
  5170. value: {
  5171. i: 'O' + ++id,
  5172. w: {}
  5173. }
  5174. });
  5175. };
  5176. var fastKey = function fastKey(it, create) {
  5177. if (!isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  5178. if (!has(it, META)) {
  5179. if (!isExtensible(it)) return 'F';
  5180. if (!create) return 'E';
  5181. setMeta(it);
  5182. }
  5183. return it[META].i;
  5184. };
  5185. var getWeak = function getWeak(it, create) {
  5186. if (!has(it, META)) {
  5187. if (!isExtensible(it)) return true;
  5188. if (!create) return false;
  5189. setMeta(it);
  5190. }
  5191. return it[META].w;
  5192. };
  5193. var onFreeze = function onFreeze(it) {
  5194. if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
  5195. return it;
  5196. };
  5197. var meta = module.exports = {
  5198. KEY: META,
  5199. NEED: false,
  5200. fastKey: fastKey,
  5201. getWeak: getWeak,
  5202. onFreeze: onFreeze
  5203. };
  5204. /***/ }),
  5205. /* 41 */
  5206. /***/ (function(module, exports, __w_pdfjs_require__) {
  5207. "use strict";
  5208. Object.defineProperty(exports, "__esModule", {
  5209. value: true
  5210. });
  5211. exports.OperatorList = undefined;
  5212. var _util = __w_pdfjs_require__(0);
  5213. var QueueOptimizer = function QueueOptimizerClosure() {
  5214. function addState(parentState, pattern, checkFn, iterateFn, processFn) {
  5215. var state = parentState;
  5216. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  5217. var item = pattern[i];
  5218. state = state[item] || (state[item] = []);
  5219. }
  5220. state[pattern[pattern.length - 1]] = {
  5221. checkFn: checkFn,
  5222. iterateFn: iterateFn,
  5223. processFn: processFn
  5224. };
  5225. }
  5226. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  5227. var iFirstPIMXO = iFirstSave + 2;
  5228. for (var i = 0; i < count; i++) {
  5229. var arg = argsArray[iFirstPIMXO + 4 * i];
  5230. var imageMask = arg.length === 1 && arg[0];
  5231. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  5232. fnArray[iFirstPIMXO + 4 * i] = _util.OPS.paintSolidColorImageMask;
  5233. continue;
  5234. }
  5235. break;
  5236. }
  5237. return count - i;
  5238. }
  5239. var InitialState = [];
  5240. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintInlineImageXObject, _util.OPS.restore], null, function iterateInlineImageGroup(context, i) {
  5241. var fnArray = context.fnArray;
  5242. var iFirstSave = context.iCurr - 3;
  5243. var pos = (i - iFirstSave) % 4;
  5244. switch (pos) {
  5245. case 0:
  5246. return fnArray[i] === _util.OPS.save;
  5247. case 1:
  5248. return fnArray[i] === _util.OPS.transform;
  5249. case 2:
  5250. return fnArray[i] === _util.OPS.paintInlineImageXObject;
  5251. case 3:
  5252. return fnArray[i] === _util.OPS.restore;
  5253. }
  5254. }, function foundInlineImageGroup(context, i) {
  5255. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  5256. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  5257. var MAX_WIDTH = 1000;
  5258. var IMAGE_PADDING = 1;
  5259. var fnArray = context.fnArray,
  5260. argsArray = context.argsArray;
  5261. var curr = context.iCurr;
  5262. var iFirstSave = curr - 3;
  5263. var iFirstTransform = curr - 2;
  5264. var iFirstPIIXO = curr - 1;
  5265. var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  5266. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  5267. return i - (i - iFirstSave) % 4;
  5268. }
  5269. var maxX = 0;
  5270. var map = [],
  5271. maxLineHeight = 0;
  5272. var currentX = IMAGE_PADDING,
  5273. currentY = IMAGE_PADDING;
  5274. var q;
  5275. for (q = 0; q < count; q++) {
  5276. var transform = argsArray[iFirstTransform + (q << 2)];
  5277. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  5278. if (currentX + img.width > MAX_WIDTH) {
  5279. maxX = Math.max(maxX, currentX);
  5280. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  5281. currentX = 0;
  5282. maxLineHeight = 0;
  5283. }
  5284. map.push({
  5285. transform: transform,
  5286. x: currentX,
  5287. y: currentY,
  5288. w: img.width,
  5289. h: img.height
  5290. });
  5291. currentX += img.width + 2 * IMAGE_PADDING;
  5292. maxLineHeight = Math.max(maxLineHeight, img.height);
  5293. }
  5294. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  5295. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  5296. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  5297. var imgRowSize = imgWidth << 2;
  5298. for (q = 0; q < count; q++) {
  5299. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  5300. var rowSize = map[q].w << 2;
  5301. var dataOffset = 0;
  5302. var offset = map[q].x + map[q].y * imgWidth << 2;
  5303. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  5304. for (var k = 0, kk = map[q].h; k < kk; k++) {
  5305. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  5306. dataOffset += rowSize;
  5307. offset += imgRowSize;
  5308. }
  5309. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  5310. while (offset >= 0) {
  5311. data[offset - 4] = data[offset];
  5312. data[offset - 3] = data[offset + 1];
  5313. data[offset - 2] = data[offset + 2];
  5314. data[offset - 1] = data[offset + 3];
  5315. data[offset + rowSize] = data[offset + rowSize - 4];
  5316. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  5317. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  5318. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  5319. offset -= imgRowSize;
  5320. }
  5321. }
  5322. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintInlineImageXObjectGroup);
  5323. argsArray.splice(iFirstSave, count * 4, [{
  5324. width: imgWidth,
  5325. height: imgHeight,
  5326. kind: _util.ImageKind.RGBA_32BPP,
  5327. data: imgData
  5328. }, map]);
  5329. return iFirstSave + 1;
  5330. });
  5331. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageMaskXObject, _util.OPS.restore], null, function iterateImageMaskGroup(context, i) {
  5332. var fnArray = context.fnArray;
  5333. var iFirstSave = context.iCurr - 3;
  5334. var pos = (i - iFirstSave) % 4;
  5335. switch (pos) {
  5336. case 0:
  5337. return fnArray[i] === _util.OPS.save;
  5338. case 1:
  5339. return fnArray[i] === _util.OPS.transform;
  5340. case 2:
  5341. return fnArray[i] === _util.OPS.paintImageMaskXObject;
  5342. case 3:
  5343. return fnArray[i] === _util.OPS.restore;
  5344. }
  5345. }, function foundImageMaskGroup(context, i) {
  5346. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  5347. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  5348. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  5349. var fnArray = context.fnArray,
  5350. argsArray = context.argsArray;
  5351. var curr = context.iCurr;
  5352. var iFirstSave = curr - 3;
  5353. var iFirstTransform = curr - 2;
  5354. var iFirstPIMXO = curr - 1;
  5355. var count = Math.floor((i - iFirstSave) / 4);
  5356. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  5357. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  5358. return i - (i - iFirstSave) % 4;
  5359. }
  5360. var q;
  5361. var isSameImage = false;
  5362. var iTransform, transformArgs;
  5363. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  5364. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  5365. isSameImage = true;
  5366. var firstTransformArg0 = argsArray[iFirstTransform][0];
  5367. var firstTransformArg3 = argsArray[iFirstTransform][3];
  5368. iTransform = iFirstTransform + 4;
  5369. var iPIMXO = iFirstPIMXO + 4;
  5370. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  5371. transformArgs = argsArray[iTransform];
  5372. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  5373. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  5374. isSameImage = false;
  5375. } else {
  5376. count = q;
  5377. }
  5378. break;
  5379. }
  5380. }
  5381. }
  5382. if (isSameImage) {
  5383. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  5384. var positions = new Float32Array(count * 2);
  5385. iTransform = iFirstTransform;
  5386. for (q = 0; q < count; q++, iTransform += 4) {
  5387. transformArgs = argsArray[iTransform];
  5388. positions[q << 1] = transformArgs[4];
  5389. positions[(q << 1) + 1] = transformArgs[5];
  5390. }
  5391. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectRepeat);
  5392. argsArray.splice(iFirstSave, count * 4, [firstPIMXOArg0, firstTransformArg0, firstTransformArg3, positions]);
  5393. } else {
  5394. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  5395. var images = [];
  5396. for (q = 0; q < count; q++) {
  5397. transformArgs = argsArray[iFirstTransform + (q << 2)];
  5398. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  5399. images.push({
  5400. data: maskParams.data,
  5401. width: maskParams.width,
  5402. height: maskParams.height,
  5403. transform: transformArgs
  5404. });
  5405. }
  5406. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageMaskXObjectGroup);
  5407. argsArray.splice(iFirstSave, count * 4, [images]);
  5408. }
  5409. return iFirstSave + 1;
  5410. });
  5411. addState(InitialState, [_util.OPS.save, _util.OPS.transform, _util.OPS.paintImageXObject, _util.OPS.restore], function (context) {
  5412. var argsArray = context.argsArray;
  5413. var iFirstTransform = context.iCurr - 2;
  5414. return argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0;
  5415. }, function (context, i) {
  5416. var fnArray = context.fnArray,
  5417. argsArray = context.argsArray;
  5418. var iFirstSave = context.iCurr - 3;
  5419. var pos = (i - iFirstSave) % 4;
  5420. switch (pos) {
  5421. case 0:
  5422. return fnArray[i] === _util.OPS.save;
  5423. case 1:
  5424. if (fnArray[i] !== _util.OPS.transform) {
  5425. return false;
  5426. }
  5427. var iFirstTransform = context.iCurr - 2;
  5428. var firstTransformArg0 = argsArray[iFirstTransform][0];
  5429. var firstTransformArg3 = argsArray[iFirstTransform][3];
  5430. if (argsArray[i][0] !== firstTransformArg0 || argsArray[i][1] !== 0 || argsArray[i][2] !== 0 || argsArray[i][3] !== firstTransformArg3) {
  5431. return false;
  5432. }
  5433. return true;
  5434. case 2:
  5435. if (fnArray[i] !== _util.OPS.paintImageXObject) {
  5436. return false;
  5437. }
  5438. var iFirstPIXO = context.iCurr - 1;
  5439. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  5440. if (argsArray[i][0] !== firstPIXOArg0) {
  5441. return false;
  5442. }
  5443. return true;
  5444. case 3:
  5445. return fnArray[i] === _util.OPS.restore;
  5446. }
  5447. }, function (context, i) {
  5448. var MIN_IMAGES_IN_BLOCK = 3;
  5449. var MAX_IMAGES_IN_BLOCK = 1000;
  5450. var fnArray = context.fnArray,
  5451. argsArray = context.argsArray;
  5452. var curr = context.iCurr;
  5453. var iFirstSave = curr - 3;
  5454. var iFirstTransform = curr - 2;
  5455. var iFirstPIXO = curr - 1;
  5456. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  5457. var firstTransformArg0 = argsArray[iFirstTransform][0];
  5458. var firstTransformArg3 = argsArray[iFirstTransform][3];
  5459. var count = Math.min(Math.floor((i - iFirstSave) / 4), MAX_IMAGES_IN_BLOCK);
  5460. if (count < MIN_IMAGES_IN_BLOCK) {
  5461. return i - (i - iFirstSave) % 4;
  5462. }
  5463. var positions = new Float32Array(count * 2);
  5464. var iTransform = iFirstTransform;
  5465. for (var q = 0; q < count; q++, iTransform += 4) {
  5466. var transformArgs = argsArray[iTransform];
  5467. positions[q << 1] = transformArgs[4];
  5468. positions[(q << 1) + 1] = transformArgs[5];
  5469. }
  5470. var args = [firstPIXOArg0, firstTransformArg0, firstTransformArg3, positions];
  5471. fnArray.splice(iFirstSave, count * 4, _util.OPS.paintImageXObjectRepeat);
  5472. argsArray.splice(iFirstSave, count * 4, args);
  5473. return iFirstSave + 1;
  5474. });
  5475. addState(InitialState, [_util.OPS.beginText, _util.OPS.setFont, _util.OPS.setTextMatrix, _util.OPS.showText, _util.OPS.endText], null, function (context, i) {
  5476. var fnArray = context.fnArray,
  5477. argsArray = context.argsArray;
  5478. var iFirstSave = context.iCurr - 4;
  5479. var pos = (i - iFirstSave) % 5;
  5480. switch (pos) {
  5481. case 0:
  5482. return fnArray[i] === _util.OPS.beginText;
  5483. case 1:
  5484. return fnArray[i] === _util.OPS.setFont;
  5485. case 2:
  5486. return fnArray[i] === _util.OPS.setTextMatrix;
  5487. case 3:
  5488. if (fnArray[i] !== _util.OPS.showText) {
  5489. return false;
  5490. }
  5491. var iFirstSetFont = context.iCurr - 3;
  5492. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  5493. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  5494. if (argsArray[i][0] !== firstSetFontArg0 || argsArray[i][1] !== firstSetFontArg1) {
  5495. return false;
  5496. }
  5497. return true;
  5498. case 4:
  5499. return fnArray[i] === _util.OPS.endText;
  5500. }
  5501. }, function (context, i) {
  5502. var MIN_CHARS_IN_BLOCK = 3;
  5503. var MAX_CHARS_IN_BLOCK = 1000;
  5504. var fnArray = context.fnArray,
  5505. argsArray = context.argsArray;
  5506. var curr = context.iCurr;
  5507. var iFirstBeginText = curr - 4;
  5508. var iFirstSetFont = curr - 3;
  5509. var iFirstSetTextMatrix = curr - 2;
  5510. var iFirstShowText = curr - 1;
  5511. var iFirstEndText = curr;
  5512. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  5513. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  5514. var count = Math.min(Math.floor((i - iFirstBeginText) / 5), MAX_CHARS_IN_BLOCK);
  5515. if (count < MIN_CHARS_IN_BLOCK) {
  5516. return i - (i - iFirstBeginText) % 5;
  5517. }
  5518. var iFirst = iFirstBeginText;
  5519. 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) {
  5520. count++;
  5521. iFirst -= 5;
  5522. }
  5523. var iEndText = iFirst + 4;
  5524. for (var q = 1; q < count; q++) {
  5525. fnArray.splice(iEndText, 3);
  5526. argsArray.splice(iEndText, 3);
  5527. iEndText += 2;
  5528. }
  5529. return iEndText + 1;
  5530. });
  5531. function QueueOptimizer(queue) {
  5532. this.queue = queue;
  5533. this.state = null;
  5534. this.context = {
  5535. iCurr: 0,
  5536. fnArray: queue.fnArray,
  5537. argsArray: queue.argsArray
  5538. };
  5539. this.match = null;
  5540. this.lastProcessed = 0;
  5541. }
  5542. QueueOptimizer.prototype = {
  5543. _optimize: function _optimize() {
  5544. var fnArray = this.queue.fnArray;
  5545. var i = this.lastProcessed,
  5546. ii = fnArray.length;
  5547. var state = this.state;
  5548. var match = this.match;
  5549. if (!state && !match && i + 1 === ii && !InitialState[fnArray[i]]) {
  5550. this.lastProcessed = ii;
  5551. return;
  5552. }
  5553. var context = this.context;
  5554. while (i < ii) {
  5555. if (match) {
  5556. var iterate = (0, match.iterateFn)(context, i);
  5557. if (iterate) {
  5558. i++;
  5559. continue;
  5560. }
  5561. i = (0, match.processFn)(context, i + 1);
  5562. ii = fnArray.length;
  5563. match = null;
  5564. state = null;
  5565. if (i >= ii) {
  5566. break;
  5567. }
  5568. }
  5569. state = (state || InitialState)[fnArray[i]];
  5570. if (!state || Array.isArray(state)) {
  5571. i++;
  5572. continue;
  5573. }
  5574. context.iCurr = i;
  5575. i++;
  5576. if (state.checkFn && !(0, state.checkFn)(context)) {
  5577. state = null;
  5578. continue;
  5579. }
  5580. match = state;
  5581. state = null;
  5582. }
  5583. this.state = state;
  5584. this.match = match;
  5585. this.lastProcessed = i;
  5586. },
  5587. push: function push(fn, args) {
  5588. this.queue.fnArray.push(fn);
  5589. this.queue.argsArray.push(args);
  5590. this._optimize();
  5591. },
  5592. flush: function flush() {
  5593. while (this.match) {
  5594. var length = this.queue.fnArray.length;
  5595. this.lastProcessed = (0, this.match.processFn)(this.context, length);
  5596. this.match = null;
  5597. this.state = null;
  5598. this._optimize();
  5599. }
  5600. },
  5601. reset: function reset() {
  5602. this.state = null;
  5603. this.match = null;
  5604. this.lastProcessed = 0;
  5605. }
  5606. };
  5607. return QueueOptimizer;
  5608. }();
  5609. var NullOptimizer = function NullOptimizerClosure() {
  5610. function NullOptimizer(queue) {
  5611. this.queue = queue;
  5612. }
  5613. NullOptimizer.prototype = {
  5614. push: function push(fn, args) {
  5615. this.queue.fnArray.push(fn);
  5616. this.queue.argsArray.push(args);
  5617. },
  5618. flush: function flush() {}
  5619. };
  5620. return NullOptimizer;
  5621. }();
  5622. var OperatorList = function OperatorListClosure() {
  5623. var CHUNK_SIZE = 1000;
  5624. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  5625. function getTransfers(queue) {
  5626. var transfers = [];
  5627. var fnArray = queue.fnArray,
  5628. argsArray = queue.argsArray;
  5629. for (var i = 0, ii = queue.length; i < ii; i++) {
  5630. switch (fnArray[i]) {
  5631. case _util.OPS.paintInlineImageXObject:
  5632. case _util.OPS.paintInlineImageXObjectGroup:
  5633. case _util.OPS.paintImageMaskXObject:
  5634. var arg = argsArray[i][0];
  5635. if (!arg.cached) {
  5636. transfers.push(arg.data.buffer);
  5637. }
  5638. break;
  5639. }
  5640. }
  5641. return transfers;
  5642. }
  5643. function OperatorList(intent, messageHandler, pageIndex) {
  5644. this.messageHandler = messageHandler;
  5645. this.fnArray = [];
  5646. this.argsArray = [];
  5647. if (messageHandler && this.intent !== 'oplist') {
  5648. this.optimizer = new QueueOptimizer(this);
  5649. } else {
  5650. this.optimizer = new NullOptimizer(this);
  5651. }
  5652. this.dependencies = Object.create(null);
  5653. this._totalLength = 0;
  5654. this.pageIndex = pageIndex;
  5655. this.intent = intent;
  5656. this.weight = 0;
  5657. }
  5658. OperatorList.prototype = {
  5659. get length() {
  5660. return this.argsArray.length;
  5661. },
  5662. get totalLength() {
  5663. return this._totalLength + this.length;
  5664. },
  5665. addOp: function addOp(fn, args) {
  5666. this.optimizer.push(fn, args);
  5667. this.weight++;
  5668. if (this.messageHandler) {
  5669. if (this.weight >= CHUNK_SIZE) {
  5670. this.flush();
  5671. } else if (this.weight >= CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
  5672. this.flush();
  5673. }
  5674. }
  5675. },
  5676. addDependency: function addDependency(dependency) {
  5677. if (dependency in this.dependencies) {
  5678. return;
  5679. }
  5680. this.dependencies[dependency] = true;
  5681. this.addOp(_util.OPS.dependency, [dependency]);
  5682. },
  5683. addDependencies: function addDependencies(dependencies) {
  5684. for (var key in dependencies) {
  5685. this.addDependency(key);
  5686. }
  5687. },
  5688. addOpList: function addOpList(opList) {
  5689. _util.Util.extendObj(this.dependencies, opList.dependencies);
  5690. for (var i = 0, ii = opList.length; i < ii; i++) {
  5691. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  5692. }
  5693. },
  5694. getIR: function getIR() {
  5695. return {
  5696. fnArray: this.fnArray,
  5697. argsArray: this.argsArray,
  5698. length: this.length
  5699. };
  5700. },
  5701. flush: function flush(lastChunk) {
  5702. this.optimizer.flush();
  5703. var transfers = getTransfers(this);
  5704. var length = this.length;
  5705. this._totalLength += length;
  5706. this.messageHandler.send('RenderPageChunk', {
  5707. operatorList: {
  5708. fnArray: this.fnArray,
  5709. argsArray: this.argsArray,
  5710. lastChunk: lastChunk,
  5711. length: length
  5712. },
  5713. pageIndex: this.pageIndex,
  5714. intent: this.intent
  5715. }, transfers);
  5716. this.dependencies = Object.create(null);
  5717. this.fnArray.length = 0;
  5718. this.argsArray.length = 0;
  5719. this.weight = 0;
  5720. this.optimizer.reset();
  5721. }
  5722. };
  5723. return OperatorList;
  5724. }();
  5725. exports.OperatorList = OperatorList;
  5726. /***/ }),
  5727. /* 42 */
  5728. /***/ (function(module, exports, __w_pdfjs_require__) {
  5729. "use strict";
  5730. var getLookupTableFactory = __w_pdfjs_require__(0).getLookupTableFactory;
  5731. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  5732. t['A'] = 0x0041;
  5733. t['AE'] = 0x00C6;
  5734. t['AEacute'] = 0x01FC;
  5735. t['AEmacron'] = 0x01E2;
  5736. t['AEsmall'] = 0xF7E6;
  5737. t['Aacute'] = 0x00C1;
  5738. t['Aacutesmall'] = 0xF7E1;
  5739. t['Abreve'] = 0x0102;
  5740. t['Abreveacute'] = 0x1EAE;
  5741. t['Abrevecyrillic'] = 0x04D0;
  5742. t['Abrevedotbelow'] = 0x1EB6;
  5743. t['Abrevegrave'] = 0x1EB0;
  5744. t['Abrevehookabove'] = 0x1EB2;
  5745. t['Abrevetilde'] = 0x1EB4;
  5746. t['Acaron'] = 0x01CD;
  5747. t['Acircle'] = 0x24B6;
  5748. t['Acircumflex'] = 0x00C2;
  5749. t['Acircumflexacute'] = 0x1EA4;
  5750. t['Acircumflexdotbelow'] = 0x1EAC;
  5751. t['Acircumflexgrave'] = 0x1EA6;
  5752. t['Acircumflexhookabove'] = 0x1EA8;
  5753. t['Acircumflexsmall'] = 0xF7E2;
  5754. t['Acircumflextilde'] = 0x1EAA;
  5755. t['Acute'] = 0xF6C9;
  5756. t['Acutesmall'] = 0xF7B4;
  5757. t['Acyrillic'] = 0x0410;
  5758. t['Adblgrave'] = 0x0200;
  5759. t['Adieresis'] = 0x00C4;
  5760. t['Adieresiscyrillic'] = 0x04D2;
  5761. t['Adieresismacron'] = 0x01DE;
  5762. t['Adieresissmall'] = 0xF7E4;
  5763. t['Adotbelow'] = 0x1EA0;
  5764. t['Adotmacron'] = 0x01E0;
  5765. t['Agrave'] = 0x00C0;
  5766. t['Agravesmall'] = 0xF7E0;
  5767. t['Ahookabove'] = 0x1EA2;
  5768. t['Aiecyrillic'] = 0x04D4;
  5769. t['Ainvertedbreve'] = 0x0202;
  5770. t['Alpha'] = 0x0391;
  5771. t['Alphatonos'] = 0x0386;
  5772. t['Amacron'] = 0x0100;
  5773. t['Amonospace'] = 0xFF21;
  5774. t['Aogonek'] = 0x0104;
  5775. t['Aring'] = 0x00C5;
  5776. t['Aringacute'] = 0x01FA;
  5777. t['Aringbelow'] = 0x1E00;
  5778. t['Aringsmall'] = 0xF7E5;
  5779. t['Asmall'] = 0xF761;
  5780. t['Atilde'] = 0x00C3;
  5781. t['Atildesmall'] = 0xF7E3;
  5782. t['Aybarmenian'] = 0x0531;
  5783. t['B'] = 0x0042;
  5784. t['Bcircle'] = 0x24B7;
  5785. t['Bdotaccent'] = 0x1E02;
  5786. t['Bdotbelow'] = 0x1E04;
  5787. t['Becyrillic'] = 0x0411;
  5788. t['Benarmenian'] = 0x0532;
  5789. t['Beta'] = 0x0392;
  5790. t['Bhook'] = 0x0181;
  5791. t['Blinebelow'] = 0x1E06;
  5792. t['Bmonospace'] = 0xFF22;
  5793. t['Brevesmall'] = 0xF6F4;
  5794. t['Bsmall'] = 0xF762;
  5795. t['Btopbar'] = 0x0182;
  5796. t['C'] = 0x0043;
  5797. t['Caarmenian'] = 0x053E;
  5798. t['Cacute'] = 0x0106;
  5799. t['Caron'] = 0xF6CA;
  5800. t['Caronsmall'] = 0xF6F5;
  5801. t['Ccaron'] = 0x010C;
  5802. t['Ccedilla'] = 0x00C7;
  5803. t['Ccedillaacute'] = 0x1E08;
  5804. t['Ccedillasmall'] = 0xF7E7;
  5805. t['Ccircle'] = 0x24B8;
  5806. t['Ccircumflex'] = 0x0108;
  5807. t['Cdot'] = 0x010A;
  5808. t['Cdotaccent'] = 0x010A;
  5809. t['Cedillasmall'] = 0xF7B8;
  5810. t['Chaarmenian'] = 0x0549;
  5811. t['Cheabkhasiancyrillic'] = 0x04BC;
  5812. t['Checyrillic'] = 0x0427;
  5813. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  5814. t['Chedescendercyrillic'] = 0x04B6;
  5815. t['Chedieresiscyrillic'] = 0x04F4;
  5816. t['Cheharmenian'] = 0x0543;
  5817. t['Chekhakassiancyrillic'] = 0x04CB;
  5818. t['Cheverticalstrokecyrillic'] = 0x04B8;
  5819. t['Chi'] = 0x03A7;
  5820. t['Chook'] = 0x0187;
  5821. t['Circumflexsmall'] = 0xF6F6;
  5822. t['Cmonospace'] = 0xFF23;
  5823. t['Coarmenian'] = 0x0551;
  5824. t['Csmall'] = 0xF763;
  5825. t['D'] = 0x0044;
  5826. t['DZ'] = 0x01F1;
  5827. t['DZcaron'] = 0x01C4;
  5828. t['Daarmenian'] = 0x0534;
  5829. t['Dafrican'] = 0x0189;
  5830. t['Dcaron'] = 0x010E;
  5831. t['Dcedilla'] = 0x1E10;
  5832. t['Dcircle'] = 0x24B9;
  5833. t['Dcircumflexbelow'] = 0x1E12;
  5834. t['Dcroat'] = 0x0110;
  5835. t['Ddotaccent'] = 0x1E0A;
  5836. t['Ddotbelow'] = 0x1E0C;
  5837. t['Decyrillic'] = 0x0414;
  5838. t['Deicoptic'] = 0x03EE;
  5839. t['Delta'] = 0x2206;
  5840. t['Deltagreek'] = 0x0394;
  5841. t['Dhook'] = 0x018A;
  5842. t['Dieresis'] = 0xF6CB;
  5843. t['DieresisAcute'] = 0xF6CC;
  5844. t['DieresisGrave'] = 0xF6CD;
  5845. t['Dieresissmall'] = 0xF7A8;
  5846. t['Digammagreek'] = 0x03DC;
  5847. t['Djecyrillic'] = 0x0402;
  5848. t['Dlinebelow'] = 0x1E0E;
  5849. t['Dmonospace'] = 0xFF24;
  5850. t['Dotaccentsmall'] = 0xF6F7;
  5851. t['Dslash'] = 0x0110;
  5852. t['Dsmall'] = 0xF764;
  5853. t['Dtopbar'] = 0x018B;
  5854. t['Dz'] = 0x01F2;
  5855. t['Dzcaron'] = 0x01C5;
  5856. t['Dzeabkhasiancyrillic'] = 0x04E0;
  5857. t['Dzecyrillic'] = 0x0405;
  5858. t['Dzhecyrillic'] = 0x040F;
  5859. t['E'] = 0x0045;
  5860. t['Eacute'] = 0x00C9;
  5861. t['Eacutesmall'] = 0xF7E9;
  5862. t['Ebreve'] = 0x0114;
  5863. t['Ecaron'] = 0x011A;
  5864. t['Ecedillabreve'] = 0x1E1C;
  5865. t['Echarmenian'] = 0x0535;
  5866. t['Ecircle'] = 0x24BA;
  5867. t['Ecircumflex'] = 0x00CA;
  5868. t['Ecircumflexacute'] = 0x1EBE;
  5869. t['Ecircumflexbelow'] = 0x1E18;
  5870. t['Ecircumflexdotbelow'] = 0x1EC6;
  5871. t['Ecircumflexgrave'] = 0x1EC0;
  5872. t['Ecircumflexhookabove'] = 0x1EC2;
  5873. t['Ecircumflexsmall'] = 0xF7EA;
  5874. t['Ecircumflextilde'] = 0x1EC4;
  5875. t['Ecyrillic'] = 0x0404;
  5876. t['Edblgrave'] = 0x0204;
  5877. t['Edieresis'] = 0x00CB;
  5878. t['Edieresissmall'] = 0xF7EB;
  5879. t['Edot'] = 0x0116;
  5880. t['Edotaccent'] = 0x0116;
  5881. t['Edotbelow'] = 0x1EB8;
  5882. t['Efcyrillic'] = 0x0424;
  5883. t['Egrave'] = 0x00C8;
  5884. t['Egravesmall'] = 0xF7E8;
  5885. t['Eharmenian'] = 0x0537;
  5886. t['Ehookabove'] = 0x1EBA;
  5887. t['Eightroman'] = 0x2167;
  5888. t['Einvertedbreve'] = 0x0206;
  5889. t['Eiotifiedcyrillic'] = 0x0464;
  5890. t['Elcyrillic'] = 0x041B;
  5891. t['Elevenroman'] = 0x216A;
  5892. t['Emacron'] = 0x0112;
  5893. t['Emacronacute'] = 0x1E16;
  5894. t['Emacrongrave'] = 0x1E14;
  5895. t['Emcyrillic'] = 0x041C;
  5896. t['Emonospace'] = 0xFF25;
  5897. t['Encyrillic'] = 0x041D;
  5898. t['Endescendercyrillic'] = 0x04A2;
  5899. t['Eng'] = 0x014A;
  5900. t['Enghecyrillic'] = 0x04A4;
  5901. t['Enhookcyrillic'] = 0x04C7;
  5902. t['Eogonek'] = 0x0118;
  5903. t['Eopen'] = 0x0190;
  5904. t['Epsilon'] = 0x0395;
  5905. t['Epsilontonos'] = 0x0388;
  5906. t['Ercyrillic'] = 0x0420;
  5907. t['Ereversed'] = 0x018E;
  5908. t['Ereversedcyrillic'] = 0x042D;
  5909. t['Escyrillic'] = 0x0421;
  5910. t['Esdescendercyrillic'] = 0x04AA;
  5911. t['Esh'] = 0x01A9;
  5912. t['Esmall'] = 0xF765;
  5913. t['Eta'] = 0x0397;
  5914. t['Etarmenian'] = 0x0538;
  5915. t['Etatonos'] = 0x0389;
  5916. t['Eth'] = 0x00D0;
  5917. t['Ethsmall'] = 0xF7F0;
  5918. t['Etilde'] = 0x1EBC;
  5919. t['Etildebelow'] = 0x1E1A;
  5920. t['Euro'] = 0x20AC;
  5921. t['Ezh'] = 0x01B7;
  5922. t['Ezhcaron'] = 0x01EE;
  5923. t['Ezhreversed'] = 0x01B8;
  5924. t['F'] = 0x0046;
  5925. t['Fcircle'] = 0x24BB;
  5926. t['Fdotaccent'] = 0x1E1E;
  5927. t['Feharmenian'] = 0x0556;
  5928. t['Feicoptic'] = 0x03E4;
  5929. t['Fhook'] = 0x0191;
  5930. t['Fitacyrillic'] = 0x0472;
  5931. t['Fiveroman'] = 0x2164;
  5932. t['Fmonospace'] = 0xFF26;
  5933. t['Fourroman'] = 0x2163;
  5934. t['Fsmall'] = 0xF766;
  5935. t['G'] = 0x0047;
  5936. t['GBsquare'] = 0x3387;
  5937. t['Gacute'] = 0x01F4;
  5938. t['Gamma'] = 0x0393;
  5939. t['Gammaafrican'] = 0x0194;
  5940. t['Gangiacoptic'] = 0x03EA;
  5941. t['Gbreve'] = 0x011E;
  5942. t['Gcaron'] = 0x01E6;
  5943. t['Gcedilla'] = 0x0122;
  5944. t['Gcircle'] = 0x24BC;
  5945. t['Gcircumflex'] = 0x011C;
  5946. t['Gcommaaccent'] = 0x0122;
  5947. t['Gdot'] = 0x0120;
  5948. t['Gdotaccent'] = 0x0120;
  5949. t['Gecyrillic'] = 0x0413;
  5950. t['Ghadarmenian'] = 0x0542;
  5951. t['Ghemiddlehookcyrillic'] = 0x0494;
  5952. t['Ghestrokecyrillic'] = 0x0492;
  5953. t['Gheupturncyrillic'] = 0x0490;
  5954. t['Ghook'] = 0x0193;
  5955. t['Gimarmenian'] = 0x0533;
  5956. t['Gjecyrillic'] = 0x0403;
  5957. t['Gmacron'] = 0x1E20;
  5958. t['Gmonospace'] = 0xFF27;
  5959. t['Grave'] = 0xF6CE;
  5960. t['Gravesmall'] = 0xF760;
  5961. t['Gsmall'] = 0xF767;
  5962. t['Gsmallhook'] = 0x029B;
  5963. t['Gstroke'] = 0x01E4;
  5964. t['H'] = 0x0048;
  5965. t['H18533'] = 0x25CF;
  5966. t['H18543'] = 0x25AA;
  5967. t['H18551'] = 0x25AB;
  5968. t['H22073'] = 0x25A1;
  5969. t['HPsquare'] = 0x33CB;
  5970. t['Haabkhasiancyrillic'] = 0x04A8;
  5971. t['Hadescendercyrillic'] = 0x04B2;
  5972. t['Hardsigncyrillic'] = 0x042A;
  5973. t['Hbar'] = 0x0126;
  5974. t['Hbrevebelow'] = 0x1E2A;
  5975. t['Hcedilla'] = 0x1E28;
  5976. t['Hcircle'] = 0x24BD;
  5977. t['Hcircumflex'] = 0x0124;
  5978. t['Hdieresis'] = 0x1E26;
  5979. t['Hdotaccent'] = 0x1E22;
  5980. t['Hdotbelow'] = 0x1E24;
  5981. t['Hmonospace'] = 0xFF28;
  5982. t['Hoarmenian'] = 0x0540;
  5983. t['Horicoptic'] = 0x03E8;
  5984. t['Hsmall'] = 0xF768;
  5985. t['Hungarumlaut'] = 0xF6CF;
  5986. t['Hungarumlautsmall'] = 0xF6F8;
  5987. t['Hzsquare'] = 0x3390;
  5988. t['I'] = 0x0049;
  5989. t['IAcyrillic'] = 0x042F;
  5990. t['IJ'] = 0x0132;
  5991. t['IUcyrillic'] = 0x042E;
  5992. t['Iacute'] = 0x00CD;
  5993. t['Iacutesmall'] = 0xF7ED;
  5994. t['Ibreve'] = 0x012C;
  5995. t['Icaron'] = 0x01CF;
  5996. t['Icircle'] = 0x24BE;
  5997. t['Icircumflex'] = 0x00CE;
  5998. t['Icircumflexsmall'] = 0xF7EE;
  5999. t['Icyrillic'] = 0x0406;
  6000. t['Idblgrave'] = 0x0208;
  6001. t['Idieresis'] = 0x00CF;
  6002. t['Idieresisacute'] = 0x1E2E;
  6003. t['Idieresiscyrillic'] = 0x04E4;
  6004. t['Idieresissmall'] = 0xF7EF;
  6005. t['Idot'] = 0x0130;
  6006. t['Idotaccent'] = 0x0130;
  6007. t['Idotbelow'] = 0x1ECA;
  6008. t['Iebrevecyrillic'] = 0x04D6;
  6009. t['Iecyrillic'] = 0x0415;
  6010. t['Ifraktur'] = 0x2111;
  6011. t['Igrave'] = 0x00CC;
  6012. t['Igravesmall'] = 0xF7EC;
  6013. t['Ihookabove'] = 0x1EC8;
  6014. t['Iicyrillic'] = 0x0418;
  6015. t['Iinvertedbreve'] = 0x020A;
  6016. t['Iishortcyrillic'] = 0x0419;
  6017. t['Imacron'] = 0x012A;
  6018. t['Imacroncyrillic'] = 0x04E2;
  6019. t['Imonospace'] = 0xFF29;
  6020. t['Iniarmenian'] = 0x053B;
  6021. t['Iocyrillic'] = 0x0401;
  6022. t['Iogonek'] = 0x012E;
  6023. t['Iota'] = 0x0399;
  6024. t['Iotaafrican'] = 0x0196;
  6025. t['Iotadieresis'] = 0x03AA;
  6026. t['Iotatonos'] = 0x038A;
  6027. t['Ismall'] = 0xF769;
  6028. t['Istroke'] = 0x0197;
  6029. t['Itilde'] = 0x0128;
  6030. t['Itildebelow'] = 0x1E2C;
  6031. t['Izhitsacyrillic'] = 0x0474;
  6032. t['Izhitsadblgravecyrillic'] = 0x0476;
  6033. t['J'] = 0x004A;
  6034. t['Jaarmenian'] = 0x0541;
  6035. t['Jcircle'] = 0x24BF;
  6036. t['Jcircumflex'] = 0x0134;
  6037. t['Jecyrillic'] = 0x0408;
  6038. t['Jheharmenian'] = 0x054B;
  6039. t['Jmonospace'] = 0xFF2A;
  6040. t['Jsmall'] = 0xF76A;
  6041. t['K'] = 0x004B;
  6042. t['KBsquare'] = 0x3385;
  6043. t['KKsquare'] = 0x33CD;
  6044. t['Kabashkircyrillic'] = 0x04A0;
  6045. t['Kacute'] = 0x1E30;
  6046. t['Kacyrillic'] = 0x041A;
  6047. t['Kadescendercyrillic'] = 0x049A;
  6048. t['Kahookcyrillic'] = 0x04C3;
  6049. t['Kappa'] = 0x039A;
  6050. t['Kastrokecyrillic'] = 0x049E;
  6051. t['Kaverticalstrokecyrillic'] = 0x049C;
  6052. t['Kcaron'] = 0x01E8;
  6053. t['Kcedilla'] = 0x0136;
  6054. t['Kcircle'] = 0x24C0;
  6055. t['Kcommaaccent'] = 0x0136;
  6056. t['Kdotbelow'] = 0x1E32;
  6057. t['Keharmenian'] = 0x0554;
  6058. t['Kenarmenian'] = 0x053F;
  6059. t['Khacyrillic'] = 0x0425;
  6060. t['Kheicoptic'] = 0x03E6;
  6061. t['Khook'] = 0x0198;
  6062. t['Kjecyrillic'] = 0x040C;
  6063. t['Klinebelow'] = 0x1E34;
  6064. t['Kmonospace'] = 0xFF2B;
  6065. t['Koppacyrillic'] = 0x0480;
  6066. t['Koppagreek'] = 0x03DE;
  6067. t['Ksicyrillic'] = 0x046E;
  6068. t['Ksmall'] = 0xF76B;
  6069. t['L'] = 0x004C;
  6070. t['LJ'] = 0x01C7;
  6071. t['LL'] = 0xF6BF;
  6072. t['Lacute'] = 0x0139;
  6073. t['Lambda'] = 0x039B;
  6074. t['Lcaron'] = 0x013D;
  6075. t['Lcedilla'] = 0x013B;
  6076. t['Lcircle'] = 0x24C1;
  6077. t['Lcircumflexbelow'] = 0x1E3C;
  6078. t['Lcommaaccent'] = 0x013B;
  6079. t['Ldot'] = 0x013F;
  6080. t['Ldotaccent'] = 0x013F;
  6081. t['Ldotbelow'] = 0x1E36;
  6082. t['Ldotbelowmacron'] = 0x1E38;
  6083. t['Liwnarmenian'] = 0x053C;
  6084. t['Lj'] = 0x01C8;
  6085. t['Ljecyrillic'] = 0x0409;
  6086. t['Llinebelow'] = 0x1E3A;
  6087. t['Lmonospace'] = 0xFF2C;
  6088. t['Lslash'] = 0x0141;
  6089. t['Lslashsmall'] = 0xF6F9;
  6090. t['Lsmall'] = 0xF76C;
  6091. t['M'] = 0x004D;
  6092. t['MBsquare'] = 0x3386;
  6093. t['Macron'] = 0xF6D0;
  6094. t['Macronsmall'] = 0xF7AF;
  6095. t['Macute'] = 0x1E3E;
  6096. t['Mcircle'] = 0x24C2;
  6097. t['Mdotaccent'] = 0x1E40;
  6098. t['Mdotbelow'] = 0x1E42;
  6099. t['Menarmenian'] = 0x0544;
  6100. t['Mmonospace'] = 0xFF2D;
  6101. t['Msmall'] = 0xF76D;
  6102. t['Mturned'] = 0x019C;
  6103. t['Mu'] = 0x039C;
  6104. t['N'] = 0x004E;
  6105. t['NJ'] = 0x01CA;
  6106. t['Nacute'] = 0x0143;
  6107. t['Ncaron'] = 0x0147;
  6108. t['Ncedilla'] = 0x0145;
  6109. t['Ncircle'] = 0x24C3;
  6110. t['Ncircumflexbelow'] = 0x1E4A;
  6111. t['Ncommaaccent'] = 0x0145;
  6112. t['Ndotaccent'] = 0x1E44;
  6113. t['Ndotbelow'] = 0x1E46;
  6114. t['Nhookleft'] = 0x019D;
  6115. t['Nineroman'] = 0x2168;
  6116. t['Nj'] = 0x01CB;
  6117. t['Njecyrillic'] = 0x040A;
  6118. t['Nlinebelow'] = 0x1E48;
  6119. t['Nmonospace'] = 0xFF2E;
  6120. t['Nowarmenian'] = 0x0546;
  6121. t['Nsmall'] = 0xF76E;
  6122. t['Ntilde'] = 0x00D1;
  6123. t['Ntildesmall'] = 0xF7F1;
  6124. t['Nu'] = 0x039D;
  6125. t['O'] = 0x004F;
  6126. t['OE'] = 0x0152;
  6127. t['OEsmall'] = 0xF6FA;
  6128. t['Oacute'] = 0x00D3;
  6129. t['Oacutesmall'] = 0xF7F3;
  6130. t['Obarredcyrillic'] = 0x04E8;
  6131. t['Obarreddieresiscyrillic'] = 0x04EA;
  6132. t['Obreve'] = 0x014E;
  6133. t['Ocaron'] = 0x01D1;
  6134. t['Ocenteredtilde'] = 0x019F;
  6135. t['Ocircle'] = 0x24C4;
  6136. t['Ocircumflex'] = 0x00D4;
  6137. t['Ocircumflexacute'] = 0x1ED0;
  6138. t['Ocircumflexdotbelow'] = 0x1ED8;
  6139. t['Ocircumflexgrave'] = 0x1ED2;
  6140. t['Ocircumflexhookabove'] = 0x1ED4;
  6141. t['Ocircumflexsmall'] = 0xF7F4;
  6142. t['Ocircumflextilde'] = 0x1ED6;
  6143. t['Ocyrillic'] = 0x041E;
  6144. t['Odblacute'] = 0x0150;
  6145. t['Odblgrave'] = 0x020C;
  6146. t['Odieresis'] = 0x00D6;
  6147. t['Odieresiscyrillic'] = 0x04E6;
  6148. t['Odieresissmall'] = 0xF7F6;
  6149. t['Odotbelow'] = 0x1ECC;
  6150. t['Ogoneksmall'] = 0xF6FB;
  6151. t['Ograve'] = 0x00D2;
  6152. t['Ogravesmall'] = 0xF7F2;
  6153. t['Oharmenian'] = 0x0555;
  6154. t['Ohm'] = 0x2126;
  6155. t['Ohookabove'] = 0x1ECE;
  6156. t['Ohorn'] = 0x01A0;
  6157. t['Ohornacute'] = 0x1EDA;
  6158. t['Ohorndotbelow'] = 0x1EE2;
  6159. t['Ohorngrave'] = 0x1EDC;
  6160. t['Ohornhookabove'] = 0x1EDE;
  6161. t['Ohorntilde'] = 0x1EE0;
  6162. t['Ohungarumlaut'] = 0x0150;
  6163. t['Oi'] = 0x01A2;
  6164. t['Oinvertedbreve'] = 0x020E;
  6165. t['Omacron'] = 0x014C;
  6166. t['Omacronacute'] = 0x1E52;
  6167. t['Omacrongrave'] = 0x1E50;
  6168. t['Omega'] = 0x2126;
  6169. t['Omegacyrillic'] = 0x0460;
  6170. t['Omegagreek'] = 0x03A9;
  6171. t['Omegaroundcyrillic'] = 0x047A;
  6172. t['Omegatitlocyrillic'] = 0x047C;
  6173. t['Omegatonos'] = 0x038F;
  6174. t['Omicron'] = 0x039F;
  6175. t['Omicrontonos'] = 0x038C;
  6176. t['Omonospace'] = 0xFF2F;
  6177. t['Oneroman'] = 0x2160;
  6178. t['Oogonek'] = 0x01EA;
  6179. t['Oogonekmacron'] = 0x01EC;
  6180. t['Oopen'] = 0x0186;
  6181. t['Oslash'] = 0x00D8;
  6182. t['Oslashacute'] = 0x01FE;
  6183. t['Oslashsmall'] = 0xF7F8;
  6184. t['Osmall'] = 0xF76F;
  6185. t['Ostrokeacute'] = 0x01FE;
  6186. t['Otcyrillic'] = 0x047E;
  6187. t['Otilde'] = 0x00D5;
  6188. t['Otildeacute'] = 0x1E4C;
  6189. t['Otildedieresis'] = 0x1E4E;
  6190. t['Otildesmall'] = 0xF7F5;
  6191. t['P'] = 0x0050;
  6192. t['Pacute'] = 0x1E54;
  6193. t['Pcircle'] = 0x24C5;
  6194. t['Pdotaccent'] = 0x1E56;
  6195. t['Pecyrillic'] = 0x041F;
  6196. t['Peharmenian'] = 0x054A;
  6197. t['Pemiddlehookcyrillic'] = 0x04A6;
  6198. t['Phi'] = 0x03A6;
  6199. t['Phook'] = 0x01A4;
  6200. t['Pi'] = 0x03A0;
  6201. t['Piwrarmenian'] = 0x0553;
  6202. t['Pmonospace'] = 0xFF30;
  6203. t['Psi'] = 0x03A8;
  6204. t['Psicyrillic'] = 0x0470;
  6205. t['Psmall'] = 0xF770;
  6206. t['Q'] = 0x0051;
  6207. t['Qcircle'] = 0x24C6;
  6208. t['Qmonospace'] = 0xFF31;
  6209. t['Qsmall'] = 0xF771;
  6210. t['R'] = 0x0052;
  6211. t['Raarmenian'] = 0x054C;
  6212. t['Racute'] = 0x0154;
  6213. t['Rcaron'] = 0x0158;
  6214. t['Rcedilla'] = 0x0156;
  6215. t['Rcircle'] = 0x24C7;
  6216. t['Rcommaaccent'] = 0x0156;
  6217. t['Rdblgrave'] = 0x0210;
  6218. t['Rdotaccent'] = 0x1E58;
  6219. t['Rdotbelow'] = 0x1E5A;
  6220. t['Rdotbelowmacron'] = 0x1E5C;
  6221. t['Reharmenian'] = 0x0550;
  6222. t['Rfraktur'] = 0x211C;
  6223. t['Rho'] = 0x03A1;
  6224. t['Ringsmall'] = 0xF6FC;
  6225. t['Rinvertedbreve'] = 0x0212;
  6226. t['Rlinebelow'] = 0x1E5E;
  6227. t['Rmonospace'] = 0xFF32;
  6228. t['Rsmall'] = 0xF772;
  6229. t['Rsmallinverted'] = 0x0281;
  6230. t['Rsmallinvertedsuperior'] = 0x02B6;
  6231. t['S'] = 0x0053;
  6232. t['SF010000'] = 0x250C;
  6233. t['SF020000'] = 0x2514;
  6234. t['SF030000'] = 0x2510;
  6235. t['SF040000'] = 0x2518;
  6236. t['SF050000'] = 0x253C;
  6237. t['SF060000'] = 0x252C;
  6238. t['SF070000'] = 0x2534;
  6239. t['SF080000'] = 0x251C;
  6240. t['SF090000'] = 0x2524;
  6241. t['SF100000'] = 0x2500;
  6242. t['SF110000'] = 0x2502;
  6243. t['SF190000'] = 0x2561;
  6244. t['SF200000'] = 0x2562;
  6245. t['SF210000'] = 0x2556;
  6246. t['SF220000'] = 0x2555;
  6247. t['SF230000'] = 0x2563;
  6248. t['SF240000'] = 0x2551;
  6249. t['SF250000'] = 0x2557;
  6250. t['SF260000'] = 0x255D;
  6251. t['SF270000'] = 0x255C;
  6252. t['SF280000'] = 0x255B;
  6253. t['SF360000'] = 0x255E;
  6254. t['SF370000'] = 0x255F;
  6255. t['SF380000'] = 0x255A;
  6256. t['SF390000'] = 0x2554;
  6257. t['SF400000'] = 0x2569;
  6258. t['SF410000'] = 0x2566;
  6259. t['SF420000'] = 0x2560;
  6260. t['SF430000'] = 0x2550;
  6261. t['SF440000'] = 0x256C;
  6262. t['SF450000'] = 0x2567;
  6263. t['SF460000'] = 0x2568;
  6264. t['SF470000'] = 0x2564;
  6265. t['SF480000'] = 0x2565;
  6266. t['SF490000'] = 0x2559;
  6267. t['SF500000'] = 0x2558;
  6268. t['SF510000'] = 0x2552;
  6269. t['SF520000'] = 0x2553;
  6270. t['SF530000'] = 0x256B;
  6271. t['SF540000'] = 0x256A;
  6272. t['Sacute'] = 0x015A;
  6273. t['Sacutedotaccent'] = 0x1E64;
  6274. t['Sampigreek'] = 0x03E0;
  6275. t['Scaron'] = 0x0160;
  6276. t['Scarondotaccent'] = 0x1E66;
  6277. t['Scaronsmall'] = 0xF6FD;
  6278. t['Scedilla'] = 0x015E;
  6279. t['Schwa'] = 0x018F;
  6280. t['Schwacyrillic'] = 0x04D8;
  6281. t['Schwadieresiscyrillic'] = 0x04DA;
  6282. t['Scircle'] = 0x24C8;
  6283. t['Scircumflex'] = 0x015C;
  6284. t['Scommaaccent'] = 0x0218;
  6285. t['Sdotaccent'] = 0x1E60;
  6286. t['Sdotbelow'] = 0x1E62;
  6287. t['Sdotbelowdotaccent'] = 0x1E68;
  6288. t['Seharmenian'] = 0x054D;
  6289. t['Sevenroman'] = 0x2166;
  6290. t['Shaarmenian'] = 0x0547;
  6291. t['Shacyrillic'] = 0x0428;
  6292. t['Shchacyrillic'] = 0x0429;
  6293. t['Sheicoptic'] = 0x03E2;
  6294. t['Shhacyrillic'] = 0x04BA;
  6295. t['Shimacoptic'] = 0x03EC;
  6296. t['Sigma'] = 0x03A3;
  6297. t['Sixroman'] = 0x2165;
  6298. t['Smonospace'] = 0xFF33;
  6299. t['Softsigncyrillic'] = 0x042C;
  6300. t['Ssmall'] = 0xF773;
  6301. t['Stigmagreek'] = 0x03DA;
  6302. t['T'] = 0x0054;
  6303. t['Tau'] = 0x03A4;
  6304. t['Tbar'] = 0x0166;
  6305. t['Tcaron'] = 0x0164;
  6306. t['Tcedilla'] = 0x0162;
  6307. t['Tcircle'] = 0x24C9;
  6308. t['Tcircumflexbelow'] = 0x1E70;
  6309. t['Tcommaaccent'] = 0x0162;
  6310. t['Tdotaccent'] = 0x1E6A;
  6311. t['Tdotbelow'] = 0x1E6C;
  6312. t['Tecyrillic'] = 0x0422;
  6313. t['Tedescendercyrillic'] = 0x04AC;
  6314. t['Tenroman'] = 0x2169;
  6315. t['Tetsecyrillic'] = 0x04B4;
  6316. t['Theta'] = 0x0398;
  6317. t['Thook'] = 0x01AC;
  6318. t['Thorn'] = 0x00DE;
  6319. t['Thornsmall'] = 0xF7FE;
  6320. t['Threeroman'] = 0x2162;
  6321. t['Tildesmall'] = 0xF6FE;
  6322. t['Tiwnarmenian'] = 0x054F;
  6323. t['Tlinebelow'] = 0x1E6E;
  6324. t['Tmonospace'] = 0xFF34;
  6325. t['Toarmenian'] = 0x0539;
  6326. t['Tonefive'] = 0x01BC;
  6327. t['Tonesix'] = 0x0184;
  6328. t['Tonetwo'] = 0x01A7;
  6329. t['Tretroflexhook'] = 0x01AE;
  6330. t['Tsecyrillic'] = 0x0426;
  6331. t['Tshecyrillic'] = 0x040B;
  6332. t['Tsmall'] = 0xF774;
  6333. t['Twelveroman'] = 0x216B;
  6334. t['Tworoman'] = 0x2161;
  6335. t['U'] = 0x0055;
  6336. t['Uacute'] = 0x00DA;
  6337. t['Uacutesmall'] = 0xF7FA;
  6338. t['Ubreve'] = 0x016C;
  6339. t['Ucaron'] = 0x01D3;
  6340. t['Ucircle'] = 0x24CA;
  6341. t['Ucircumflex'] = 0x00DB;
  6342. t['Ucircumflexbelow'] = 0x1E76;
  6343. t['Ucircumflexsmall'] = 0xF7FB;
  6344. t['Ucyrillic'] = 0x0423;
  6345. t['Udblacute'] = 0x0170;
  6346. t['Udblgrave'] = 0x0214;
  6347. t['Udieresis'] = 0x00DC;
  6348. t['Udieresisacute'] = 0x01D7;
  6349. t['Udieresisbelow'] = 0x1E72;
  6350. t['Udieresiscaron'] = 0x01D9;
  6351. t['Udieresiscyrillic'] = 0x04F0;
  6352. t['Udieresisgrave'] = 0x01DB;
  6353. t['Udieresismacron'] = 0x01D5;
  6354. t['Udieresissmall'] = 0xF7FC;
  6355. t['Udotbelow'] = 0x1EE4;
  6356. t['Ugrave'] = 0x00D9;
  6357. t['Ugravesmall'] = 0xF7F9;
  6358. t['Uhookabove'] = 0x1EE6;
  6359. t['Uhorn'] = 0x01AF;
  6360. t['Uhornacute'] = 0x1EE8;
  6361. t['Uhorndotbelow'] = 0x1EF0;
  6362. t['Uhorngrave'] = 0x1EEA;
  6363. t['Uhornhookabove'] = 0x1EEC;
  6364. t['Uhorntilde'] = 0x1EEE;
  6365. t['Uhungarumlaut'] = 0x0170;
  6366. t['Uhungarumlautcyrillic'] = 0x04F2;
  6367. t['Uinvertedbreve'] = 0x0216;
  6368. t['Ukcyrillic'] = 0x0478;
  6369. t['Umacron'] = 0x016A;
  6370. t['Umacroncyrillic'] = 0x04EE;
  6371. t['Umacrondieresis'] = 0x1E7A;
  6372. t['Umonospace'] = 0xFF35;
  6373. t['Uogonek'] = 0x0172;
  6374. t['Upsilon'] = 0x03A5;
  6375. t['Upsilon1'] = 0x03D2;
  6376. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  6377. t['Upsilonafrican'] = 0x01B1;
  6378. t['Upsilondieresis'] = 0x03AB;
  6379. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  6380. t['Upsilonhooksymbol'] = 0x03D2;
  6381. t['Upsilontonos'] = 0x038E;
  6382. t['Uring'] = 0x016E;
  6383. t['Ushortcyrillic'] = 0x040E;
  6384. t['Usmall'] = 0xF775;
  6385. t['Ustraightcyrillic'] = 0x04AE;
  6386. t['Ustraightstrokecyrillic'] = 0x04B0;
  6387. t['Utilde'] = 0x0168;
  6388. t['Utildeacute'] = 0x1E78;
  6389. t['Utildebelow'] = 0x1E74;
  6390. t['V'] = 0x0056;
  6391. t['Vcircle'] = 0x24CB;
  6392. t['Vdotbelow'] = 0x1E7E;
  6393. t['Vecyrillic'] = 0x0412;
  6394. t['Vewarmenian'] = 0x054E;
  6395. t['Vhook'] = 0x01B2;
  6396. t['Vmonospace'] = 0xFF36;
  6397. t['Voarmenian'] = 0x0548;
  6398. t['Vsmall'] = 0xF776;
  6399. t['Vtilde'] = 0x1E7C;
  6400. t['W'] = 0x0057;
  6401. t['Wacute'] = 0x1E82;
  6402. t['Wcircle'] = 0x24CC;
  6403. t['Wcircumflex'] = 0x0174;
  6404. t['Wdieresis'] = 0x1E84;
  6405. t['Wdotaccent'] = 0x1E86;
  6406. t['Wdotbelow'] = 0x1E88;
  6407. t['Wgrave'] = 0x1E80;
  6408. t['Wmonospace'] = 0xFF37;
  6409. t['Wsmall'] = 0xF777;
  6410. t['X'] = 0x0058;
  6411. t['Xcircle'] = 0x24CD;
  6412. t['Xdieresis'] = 0x1E8C;
  6413. t['Xdotaccent'] = 0x1E8A;
  6414. t['Xeharmenian'] = 0x053D;
  6415. t['Xi'] = 0x039E;
  6416. t['Xmonospace'] = 0xFF38;
  6417. t['Xsmall'] = 0xF778;
  6418. t['Y'] = 0x0059;
  6419. t['Yacute'] = 0x00DD;
  6420. t['Yacutesmall'] = 0xF7FD;
  6421. t['Yatcyrillic'] = 0x0462;
  6422. t['Ycircle'] = 0x24CE;
  6423. t['Ycircumflex'] = 0x0176;
  6424. t['Ydieresis'] = 0x0178;
  6425. t['Ydieresissmall'] = 0xF7FF;
  6426. t['Ydotaccent'] = 0x1E8E;
  6427. t['Ydotbelow'] = 0x1EF4;
  6428. t['Yericyrillic'] = 0x042B;
  6429. t['Yerudieresiscyrillic'] = 0x04F8;
  6430. t['Ygrave'] = 0x1EF2;
  6431. t['Yhook'] = 0x01B3;
  6432. t['Yhookabove'] = 0x1EF6;
  6433. t['Yiarmenian'] = 0x0545;
  6434. t['Yicyrillic'] = 0x0407;
  6435. t['Yiwnarmenian'] = 0x0552;
  6436. t['Ymonospace'] = 0xFF39;
  6437. t['Ysmall'] = 0xF779;
  6438. t['Ytilde'] = 0x1EF8;
  6439. t['Yusbigcyrillic'] = 0x046A;
  6440. t['Yusbigiotifiedcyrillic'] = 0x046C;
  6441. t['Yuslittlecyrillic'] = 0x0466;
  6442. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  6443. t['Z'] = 0x005A;
  6444. t['Zaarmenian'] = 0x0536;
  6445. t['Zacute'] = 0x0179;
  6446. t['Zcaron'] = 0x017D;
  6447. t['Zcaronsmall'] = 0xF6FF;
  6448. t['Zcircle'] = 0x24CF;
  6449. t['Zcircumflex'] = 0x1E90;
  6450. t['Zdot'] = 0x017B;
  6451. t['Zdotaccent'] = 0x017B;
  6452. t['Zdotbelow'] = 0x1E92;
  6453. t['Zecyrillic'] = 0x0417;
  6454. t['Zedescendercyrillic'] = 0x0498;
  6455. t['Zedieresiscyrillic'] = 0x04DE;
  6456. t['Zeta'] = 0x0396;
  6457. t['Zhearmenian'] = 0x053A;
  6458. t['Zhebrevecyrillic'] = 0x04C1;
  6459. t['Zhecyrillic'] = 0x0416;
  6460. t['Zhedescendercyrillic'] = 0x0496;
  6461. t['Zhedieresiscyrillic'] = 0x04DC;
  6462. t['Zlinebelow'] = 0x1E94;
  6463. t['Zmonospace'] = 0xFF3A;
  6464. t['Zsmall'] = 0xF77A;
  6465. t['Zstroke'] = 0x01B5;
  6466. t['a'] = 0x0061;
  6467. t['aabengali'] = 0x0986;
  6468. t['aacute'] = 0x00E1;
  6469. t['aadeva'] = 0x0906;
  6470. t['aagujarati'] = 0x0A86;
  6471. t['aagurmukhi'] = 0x0A06;
  6472. t['aamatragurmukhi'] = 0x0A3E;
  6473. t['aarusquare'] = 0x3303;
  6474. t['aavowelsignbengali'] = 0x09BE;
  6475. t['aavowelsigndeva'] = 0x093E;
  6476. t['aavowelsigngujarati'] = 0x0ABE;
  6477. t['abbreviationmarkarmenian'] = 0x055F;
  6478. t['abbreviationsigndeva'] = 0x0970;
  6479. t['abengali'] = 0x0985;
  6480. t['abopomofo'] = 0x311A;
  6481. t['abreve'] = 0x0103;
  6482. t['abreveacute'] = 0x1EAF;
  6483. t['abrevecyrillic'] = 0x04D1;
  6484. t['abrevedotbelow'] = 0x1EB7;
  6485. t['abrevegrave'] = 0x1EB1;
  6486. t['abrevehookabove'] = 0x1EB3;
  6487. t['abrevetilde'] = 0x1EB5;
  6488. t['acaron'] = 0x01CE;
  6489. t['acircle'] = 0x24D0;
  6490. t['acircumflex'] = 0x00E2;
  6491. t['acircumflexacute'] = 0x1EA5;
  6492. t['acircumflexdotbelow'] = 0x1EAD;
  6493. t['acircumflexgrave'] = 0x1EA7;
  6494. t['acircumflexhookabove'] = 0x1EA9;
  6495. t['acircumflextilde'] = 0x1EAB;
  6496. t['acute'] = 0x00B4;
  6497. t['acutebelowcmb'] = 0x0317;
  6498. t['acutecmb'] = 0x0301;
  6499. t['acutecomb'] = 0x0301;
  6500. t['acutedeva'] = 0x0954;
  6501. t['acutelowmod'] = 0x02CF;
  6502. t['acutetonecmb'] = 0x0341;
  6503. t['acyrillic'] = 0x0430;
  6504. t['adblgrave'] = 0x0201;
  6505. t['addakgurmukhi'] = 0x0A71;
  6506. t['adeva'] = 0x0905;
  6507. t['adieresis'] = 0x00E4;
  6508. t['adieresiscyrillic'] = 0x04D3;
  6509. t['adieresismacron'] = 0x01DF;
  6510. t['adotbelow'] = 0x1EA1;
  6511. t['adotmacron'] = 0x01E1;
  6512. t['ae'] = 0x00E6;
  6513. t['aeacute'] = 0x01FD;
  6514. t['aekorean'] = 0x3150;
  6515. t['aemacron'] = 0x01E3;
  6516. t['afii00208'] = 0x2015;
  6517. t['afii08941'] = 0x20A4;
  6518. t['afii10017'] = 0x0410;
  6519. t['afii10018'] = 0x0411;
  6520. t['afii10019'] = 0x0412;
  6521. t['afii10020'] = 0x0413;
  6522. t['afii10021'] = 0x0414;
  6523. t['afii10022'] = 0x0415;
  6524. t['afii10023'] = 0x0401;
  6525. t['afii10024'] = 0x0416;
  6526. t['afii10025'] = 0x0417;
  6527. t['afii10026'] = 0x0418;
  6528. t['afii10027'] = 0x0419;
  6529. t['afii10028'] = 0x041A;
  6530. t['afii10029'] = 0x041B;
  6531. t['afii10030'] = 0x041C;
  6532. t['afii10031'] = 0x041D;
  6533. t['afii10032'] = 0x041E;
  6534. t['afii10033'] = 0x041F;
  6535. t['afii10034'] = 0x0420;
  6536. t['afii10035'] = 0x0421;
  6537. t['afii10036'] = 0x0422;
  6538. t['afii10037'] = 0x0423;
  6539. t['afii10038'] = 0x0424;
  6540. t['afii10039'] = 0x0425;
  6541. t['afii10040'] = 0x0426;
  6542. t['afii10041'] = 0x0427;
  6543. t['afii10042'] = 0x0428;
  6544. t['afii10043'] = 0x0429;
  6545. t['afii10044'] = 0x042A;
  6546. t['afii10045'] = 0x042B;
  6547. t['afii10046'] = 0x042C;
  6548. t['afii10047'] = 0x042D;
  6549. t['afii10048'] = 0x042E;
  6550. t['afii10049'] = 0x042F;
  6551. t['afii10050'] = 0x0490;
  6552. t['afii10051'] = 0x0402;
  6553. t['afii10052'] = 0x0403;
  6554. t['afii10053'] = 0x0404;
  6555. t['afii10054'] = 0x0405;
  6556. t['afii10055'] = 0x0406;
  6557. t['afii10056'] = 0x0407;
  6558. t['afii10057'] = 0x0408;
  6559. t['afii10058'] = 0x0409;
  6560. t['afii10059'] = 0x040A;
  6561. t['afii10060'] = 0x040B;
  6562. t['afii10061'] = 0x040C;
  6563. t['afii10062'] = 0x040E;
  6564. t['afii10063'] = 0xF6C4;
  6565. t['afii10064'] = 0xF6C5;
  6566. t['afii10065'] = 0x0430;
  6567. t['afii10066'] = 0x0431;
  6568. t['afii10067'] = 0x0432;
  6569. t['afii10068'] = 0x0433;
  6570. t['afii10069'] = 0x0434;
  6571. t['afii10070'] = 0x0435;
  6572. t['afii10071'] = 0x0451;
  6573. t['afii10072'] = 0x0436;
  6574. t['afii10073'] = 0x0437;
  6575. t['afii10074'] = 0x0438;
  6576. t['afii10075'] = 0x0439;
  6577. t['afii10076'] = 0x043A;
  6578. t['afii10077'] = 0x043B;
  6579. t['afii10078'] = 0x043C;
  6580. t['afii10079'] = 0x043D;
  6581. t['afii10080'] = 0x043E;
  6582. t['afii10081'] = 0x043F;
  6583. t['afii10082'] = 0x0440;
  6584. t['afii10083'] = 0x0441;
  6585. t['afii10084'] = 0x0442;
  6586. t['afii10085'] = 0x0443;
  6587. t['afii10086'] = 0x0444;
  6588. t['afii10087'] = 0x0445;
  6589. t['afii10088'] = 0x0446;
  6590. t['afii10089'] = 0x0447;
  6591. t['afii10090'] = 0x0448;
  6592. t['afii10091'] = 0x0449;
  6593. t['afii10092'] = 0x044A;
  6594. t['afii10093'] = 0x044B;
  6595. t['afii10094'] = 0x044C;
  6596. t['afii10095'] = 0x044D;
  6597. t['afii10096'] = 0x044E;
  6598. t['afii10097'] = 0x044F;
  6599. t['afii10098'] = 0x0491;
  6600. t['afii10099'] = 0x0452;
  6601. t['afii10100'] = 0x0453;
  6602. t['afii10101'] = 0x0454;
  6603. t['afii10102'] = 0x0455;
  6604. t['afii10103'] = 0x0456;
  6605. t['afii10104'] = 0x0457;
  6606. t['afii10105'] = 0x0458;
  6607. t['afii10106'] = 0x0459;
  6608. t['afii10107'] = 0x045A;
  6609. t['afii10108'] = 0x045B;
  6610. t['afii10109'] = 0x045C;
  6611. t['afii10110'] = 0x045E;
  6612. t['afii10145'] = 0x040F;
  6613. t['afii10146'] = 0x0462;
  6614. t['afii10147'] = 0x0472;
  6615. t['afii10148'] = 0x0474;
  6616. t['afii10192'] = 0xF6C6;
  6617. t['afii10193'] = 0x045F;
  6618. t['afii10194'] = 0x0463;
  6619. t['afii10195'] = 0x0473;
  6620. t['afii10196'] = 0x0475;
  6621. t['afii10831'] = 0xF6C7;
  6622. t['afii10832'] = 0xF6C8;
  6623. t['afii10846'] = 0x04D9;
  6624. t['afii299'] = 0x200E;
  6625. t['afii300'] = 0x200F;
  6626. t['afii301'] = 0x200D;
  6627. t['afii57381'] = 0x066A;
  6628. t['afii57388'] = 0x060C;
  6629. t['afii57392'] = 0x0660;
  6630. t['afii57393'] = 0x0661;
  6631. t['afii57394'] = 0x0662;
  6632. t['afii57395'] = 0x0663;
  6633. t['afii57396'] = 0x0664;
  6634. t['afii57397'] = 0x0665;
  6635. t['afii57398'] = 0x0666;
  6636. t['afii57399'] = 0x0667;
  6637. t['afii57400'] = 0x0668;
  6638. t['afii57401'] = 0x0669;
  6639. t['afii57403'] = 0x061B;
  6640. t['afii57407'] = 0x061F;
  6641. t['afii57409'] = 0x0621;
  6642. t['afii57410'] = 0x0622;
  6643. t['afii57411'] = 0x0623;
  6644. t['afii57412'] = 0x0624;
  6645. t['afii57413'] = 0x0625;
  6646. t['afii57414'] = 0x0626;
  6647. t['afii57415'] = 0x0627;
  6648. t['afii57416'] = 0x0628;
  6649. t['afii57417'] = 0x0629;
  6650. t['afii57418'] = 0x062A;
  6651. t['afii57419'] = 0x062B;
  6652. t['afii57420'] = 0x062C;
  6653. t['afii57421'] = 0x062D;
  6654. t['afii57422'] = 0x062E;
  6655. t['afii57423'] = 0x062F;
  6656. t['afii57424'] = 0x0630;
  6657. t['afii57425'] = 0x0631;
  6658. t['afii57426'] = 0x0632;
  6659. t['afii57427'] = 0x0633;
  6660. t['afii57428'] = 0x0634;
  6661. t['afii57429'] = 0x0635;
  6662. t['afii57430'] = 0x0636;
  6663. t['afii57431'] = 0x0637;
  6664. t['afii57432'] = 0x0638;
  6665. t['afii57433'] = 0x0639;
  6666. t['afii57434'] = 0x063A;
  6667. t['afii57440'] = 0x0640;
  6668. t['afii57441'] = 0x0641;
  6669. t['afii57442'] = 0x0642;
  6670. t['afii57443'] = 0x0643;
  6671. t['afii57444'] = 0x0644;
  6672. t['afii57445'] = 0x0645;
  6673. t['afii57446'] = 0x0646;
  6674. t['afii57448'] = 0x0648;
  6675. t['afii57449'] = 0x0649;
  6676. t['afii57450'] = 0x064A;
  6677. t['afii57451'] = 0x064B;
  6678. t['afii57452'] = 0x064C;
  6679. t['afii57453'] = 0x064D;
  6680. t['afii57454'] = 0x064E;
  6681. t['afii57455'] = 0x064F;
  6682. t['afii57456'] = 0x0650;
  6683. t['afii57457'] = 0x0651;
  6684. t['afii57458'] = 0x0652;
  6685. t['afii57470'] = 0x0647;
  6686. t['afii57505'] = 0x06A4;
  6687. t['afii57506'] = 0x067E;
  6688. t['afii57507'] = 0x0686;
  6689. t['afii57508'] = 0x0698;
  6690. t['afii57509'] = 0x06AF;
  6691. t['afii57511'] = 0x0679;
  6692. t['afii57512'] = 0x0688;
  6693. t['afii57513'] = 0x0691;
  6694. t['afii57514'] = 0x06BA;
  6695. t['afii57519'] = 0x06D2;
  6696. t['afii57534'] = 0x06D5;
  6697. t['afii57636'] = 0x20AA;
  6698. t['afii57645'] = 0x05BE;
  6699. t['afii57658'] = 0x05C3;
  6700. t['afii57664'] = 0x05D0;
  6701. t['afii57665'] = 0x05D1;
  6702. t['afii57666'] = 0x05D2;
  6703. t['afii57667'] = 0x05D3;
  6704. t['afii57668'] = 0x05D4;
  6705. t['afii57669'] = 0x05D5;
  6706. t['afii57670'] = 0x05D6;
  6707. t['afii57671'] = 0x05D7;
  6708. t['afii57672'] = 0x05D8;
  6709. t['afii57673'] = 0x05D9;
  6710. t['afii57674'] = 0x05DA;
  6711. t['afii57675'] = 0x05DB;
  6712. t['afii57676'] = 0x05DC;
  6713. t['afii57677'] = 0x05DD;
  6714. t['afii57678'] = 0x05DE;
  6715. t['afii57679'] = 0x05DF;
  6716. t['afii57680'] = 0x05E0;
  6717. t['afii57681'] = 0x05E1;
  6718. t['afii57682'] = 0x05E2;
  6719. t['afii57683'] = 0x05E3;
  6720. t['afii57684'] = 0x05E4;
  6721. t['afii57685'] = 0x05E5;
  6722. t['afii57686'] = 0x05E6;
  6723. t['afii57687'] = 0x05E7;
  6724. t['afii57688'] = 0x05E8;
  6725. t['afii57689'] = 0x05E9;
  6726. t['afii57690'] = 0x05EA;
  6727. t['afii57694'] = 0xFB2A;
  6728. t['afii57695'] = 0xFB2B;
  6729. t['afii57700'] = 0xFB4B;
  6730. t['afii57705'] = 0xFB1F;
  6731. t['afii57716'] = 0x05F0;
  6732. t['afii57717'] = 0x05F1;
  6733. t['afii57718'] = 0x05F2;
  6734. t['afii57723'] = 0xFB35;
  6735. t['afii57793'] = 0x05B4;
  6736. t['afii57794'] = 0x05B5;
  6737. t['afii57795'] = 0x05B6;
  6738. t['afii57796'] = 0x05BB;
  6739. t['afii57797'] = 0x05B8;
  6740. t['afii57798'] = 0x05B7;
  6741. t['afii57799'] = 0x05B0;
  6742. t['afii57800'] = 0x05B2;
  6743. t['afii57801'] = 0x05B1;
  6744. t['afii57802'] = 0x05B3;
  6745. t['afii57803'] = 0x05C2;
  6746. t['afii57804'] = 0x05C1;
  6747. t['afii57806'] = 0x05B9;
  6748. t['afii57807'] = 0x05BC;
  6749. t['afii57839'] = 0x05BD;
  6750. t['afii57841'] = 0x05BF;
  6751. t['afii57842'] = 0x05C0;
  6752. t['afii57929'] = 0x02BC;
  6753. t['afii61248'] = 0x2105;
  6754. t['afii61289'] = 0x2113;
  6755. t['afii61352'] = 0x2116;
  6756. t['afii61573'] = 0x202C;
  6757. t['afii61574'] = 0x202D;
  6758. t['afii61575'] = 0x202E;
  6759. t['afii61664'] = 0x200C;
  6760. t['afii63167'] = 0x066D;
  6761. t['afii64937'] = 0x02BD;
  6762. t['agrave'] = 0x00E0;
  6763. t['agujarati'] = 0x0A85;
  6764. t['agurmukhi'] = 0x0A05;
  6765. t['ahiragana'] = 0x3042;
  6766. t['ahookabove'] = 0x1EA3;
  6767. t['aibengali'] = 0x0990;
  6768. t['aibopomofo'] = 0x311E;
  6769. t['aideva'] = 0x0910;
  6770. t['aiecyrillic'] = 0x04D5;
  6771. t['aigujarati'] = 0x0A90;
  6772. t['aigurmukhi'] = 0x0A10;
  6773. t['aimatragurmukhi'] = 0x0A48;
  6774. t['ainarabic'] = 0x0639;
  6775. t['ainfinalarabic'] = 0xFECA;
  6776. t['aininitialarabic'] = 0xFECB;
  6777. t['ainmedialarabic'] = 0xFECC;
  6778. t['ainvertedbreve'] = 0x0203;
  6779. t['aivowelsignbengali'] = 0x09C8;
  6780. t['aivowelsigndeva'] = 0x0948;
  6781. t['aivowelsigngujarati'] = 0x0AC8;
  6782. t['akatakana'] = 0x30A2;
  6783. t['akatakanahalfwidth'] = 0xFF71;
  6784. t['akorean'] = 0x314F;
  6785. t['alef'] = 0x05D0;
  6786. t['alefarabic'] = 0x0627;
  6787. t['alefdageshhebrew'] = 0xFB30;
  6788. t['aleffinalarabic'] = 0xFE8E;
  6789. t['alefhamzaabovearabic'] = 0x0623;
  6790. t['alefhamzaabovefinalarabic'] = 0xFE84;
  6791. t['alefhamzabelowarabic'] = 0x0625;
  6792. t['alefhamzabelowfinalarabic'] = 0xFE88;
  6793. t['alefhebrew'] = 0x05D0;
  6794. t['aleflamedhebrew'] = 0xFB4F;
  6795. t['alefmaddaabovearabic'] = 0x0622;
  6796. t['alefmaddaabovefinalarabic'] = 0xFE82;
  6797. t['alefmaksuraarabic'] = 0x0649;
  6798. t['alefmaksurafinalarabic'] = 0xFEF0;
  6799. t['alefmaksurainitialarabic'] = 0xFEF3;
  6800. t['alefmaksuramedialarabic'] = 0xFEF4;
  6801. t['alefpatahhebrew'] = 0xFB2E;
  6802. t['alefqamatshebrew'] = 0xFB2F;
  6803. t['aleph'] = 0x2135;
  6804. t['allequal'] = 0x224C;
  6805. t['alpha'] = 0x03B1;
  6806. t['alphatonos'] = 0x03AC;
  6807. t['amacron'] = 0x0101;
  6808. t['amonospace'] = 0xFF41;
  6809. t['ampersand'] = 0x0026;
  6810. t['ampersandmonospace'] = 0xFF06;
  6811. t['ampersandsmall'] = 0xF726;
  6812. t['amsquare'] = 0x33C2;
  6813. t['anbopomofo'] = 0x3122;
  6814. t['angbopomofo'] = 0x3124;
  6815. t['angbracketleft'] = 0x3008;
  6816. t['angbracketright'] = 0x3009;
  6817. t['angkhankhuthai'] = 0x0E5A;
  6818. t['angle'] = 0x2220;
  6819. t['anglebracketleft'] = 0x3008;
  6820. t['anglebracketleftvertical'] = 0xFE3F;
  6821. t['anglebracketright'] = 0x3009;
  6822. t['anglebracketrightvertical'] = 0xFE40;
  6823. t['angleleft'] = 0x2329;
  6824. t['angleright'] = 0x232A;
  6825. t['angstrom'] = 0x212B;
  6826. t['anoteleia'] = 0x0387;
  6827. t['anudattadeva'] = 0x0952;
  6828. t['anusvarabengali'] = 0x0982;
  6829. t['anusvaradeva'] = 0x0902;
  6830. t['anusvaragujarati'] = 0x0A82;
  6831. t['aogonek'] = 0x0105;
  6832. t['apaatosquare'] = 0x3300;
  6833. t['aparen'] = 0x249C;
  6834. t['apostrophearmenian'] = 0x055A;
  6835. t['apostrophemod'] = 0x02BC;
  6836. t['apple'] = 0xF8FF;
  6837. t['approaches'] = 0x2250;
  6838. t['approxequal'] = 0x2248;
  6839. t['approxequalorimage'] = 0x2252;
  6840. t['approximatelyequal'] = 0x2245;
  6841. t['araeaekorean'] = 0x318E;
  6842. t['araeakorean'] = 0x318D;
  6843. t['arc'] = 0x2312;
  6844. t['arighthalfring'] = 0x1E9A;
  6845. t['aring'] = 0x00E5;
  6846. t['aringacute'] = 0x01FB;
  6847. t['aringbelow'] = 0x1E01;
  6848. t['arrowboth'] = 0x2194;
  6849. t['arrowdashdown'] = 0x21E3;
  6850. t['arrowdashleft'] = 0x21E0;
  6851. t['arrowdashright'] = 0x21E2;
  6852. t['arrowdashup'] = 0x21E1;
  6853. t['arrowdblboth'] = 0x21D4;
  6854. t['arrowdbldown'] = 0x21D3;
  6855. t['arrowdblleft'] = 0x21D0;
  6856. t['arrowdblright'] = 0x21D2;
  6857. t['arrowdblup'] = 0x21D1;
  6858. t['arrowdown'] = 0x2193;
  6859. t['arrowdownleft'] = 0x2199;
  6860. t['arrowdownright'] = 0x2198;
  6861. t['arrowdownwhite'] = 0x21E9;
  6862. t['arrowheaddownmod'] = 0x02C5;
  6863. t['arrowheadleftmod'] = 0x02C2;
  6864. t['arrowheadrightmod'] = 0x02C3;
  6865. t['arrowheadupmod'] = 0x02C4;
  6866. t['arrowhorizex'] = 0xF8E7;
  6867. t['arrowleft'] = 0x2190;
  6868. t['arrowleftdbl'] = 0x21D0;
  6869. t['arrowleftdblstroke'] = 0x21CD;
  6870. t['arrowleftoverright'] = 0x21C6;
  6871. t['arrowleftwhite'] = 0x21E6;
  6872. t['arrowright'] = 0x2192;
  6873. t['arrowrightdblstroke'] = 0x21CF;
  6874. t['arrowrightheavy'] = 0x279E;
  6875. t['arrowrightoverleft'] = 0x21C4;
  6876. t['arrowrightwhite'] = 0x21E8;
  6877. t['arrowtableft'] = 0x21E4;
  6878. t['arrowtabright'] = 0x21E5;
  6879. t['arrowup'] = 0x2191;
  6880. t['arrowupdn'] = 0x2195;
  6881. t['arrowupdnbse'] = 0x21A8;
  6882. t['arrowupdownbase'] = 0x21A8;
  6883. t['arrowupleft'] = 0x2196;
  6884. t['arrowupleftofdown'] = 0x21C5;
  6885. t['arrowupright'] = 0x2197;
  6886. t['arrowupwhite'] = 0x21E7;
  6887. t['arrowvertex'] = 0xF8E6;
  6888. t['asciicircum'] = 0x005E;
  6889. t['asciicircummonospace'] = 0xFF3E;
  6890. t['asciitilde'] = 0x007E;
  6891. t['asciitildemonospace'] = 0xFF5E;
  6892. t['ascript'] = 0x0251;
  6893. t['ascriptturned'] = 0x0252;
  6894. t['asmallhiragana'] = 0x3041;
  6895. t['asmallkatakana'] = 0x30A1;
  6896. t['asmallkatakanahalfwidth'] = 0xFF67;
  6897. t['asterisk'] = 0x002A;
  6898. t['asteriskaltonearabic'] = 0x066D;
  6899. t['asteriskarabic'] = 0x066D;
  6900. t['asteriskmath'] = 0x2217;
  6901. t['asteriskmonospace'] = 0xFF0A;
  6902. t['asterisksmall'] = 0xFE61;
  6903. t['asterism'] = 0x2042;
  6904. t['asuperior'] = 0xF6E9;
  6905. t['asymptoticallyequal'] = 0x2243;
  6906. t['at'] = 0x0040;
  6907. t['atilde'] = 0x00E3;
  6908. t['atmonospace'] = 0xFF20;
  6909. t['atsmall'] = 0xFE6B;
  6910. t['aturned'] = 0x0250;
  6911. t['aubengali'] = 0x0994;
  6912. t['aubopomofo'] = 0x3120;
  6913. t['audeva'] = 0x0914;
  6914. t['augujarati'] = 0x0A94;
  6915. t['augurmukhi'] = 0x0A14;
  6916. t['aulengthmarkbengali'] = 0x09D7;
  6917. t['aumatragurmukhi'] = 0x0A4C;
  6918. t['auvowelsignbengali'] = 0x09CC;
  6919. t['auvowelsigndeva'] = 0x094C;
  6920. t['auvowelsigngujarati'] = 0x0ACC;
  6921. t['avagrahadeva'] = 0x093D;
  6922. t['aybarmenian'] = 0x0561;
  6923. t['ayin'] = 0x05E2;
  6924. t['ayinaltonehebrew'] = 0xFB20;
  6925. t['ayinhebrew'] = 0x05E2;
  6926. t['b'] = 0x0062;
  6927. t['babengali'] = 0x09AC;
  6928. t['backslash'] = 0x005C;
  6929. t['backslashmonospace'] = 0xFF3C;
  6930. t['badeva'] = 0x092C;
  6931. t['bagujarati'] = 0x0AAC;
  6932. t['bagurmukhi'] = 0x0A2C;
  6933. t['bahiragana'] = 0x3070;
  6934. t['bahtthai'] = 0x0E3F;
  6935. t['bakatakana'] = 0x30D0;
  6936. t['bar'] = 0x007C;
  6937. t['barmonospace'] = 0xFF5C;
  6938. t['bbopomofo'] = 0x3105;
  6939. t['bcircle'] = 0x24D1;
  6940. t['bdotaccent'] = 0x1E03;
  6941. t['bdotbelow'] = 0x1E05;
  6942. t['beamedsixteenthnotes'] = 0x266C;
  6943. t['because'] = 0x2235;
  6944. t['becyrillic'] = 0x0431;
  6945. t['beharabic'] = 0x0628;
  6946. t['behfinalarabic'] = 0xFE90;
  6947. t['behinitialarabic'] = 0xFE91;
  6948. t['behiragana'] = 0x3079;
  6949. t['behmedialarabic'] = 0xFE92;
  6950. t['behmeeminitialarabic'] = 0xFC9F;
  6951. t['behmeemisolatedarabic'] = 0xFC08;
  6952. t['behnoonfinalarabic'] = 0xFC6D;
  6953. t['bekatakana'] = 0x30D9;
  6954. t['benarmenian'] = 0x0562;
  6955. t['bet'] = 0x05D1;
  6956. t['beta'] = 0x03B2;
  6957. t['betasymbolgreek'] = 0x03D0;
  6958. t['betdagesh'] = 0xFB31;
  6959. t['betdageshhebrew'] = 0xFB31;
  6960. t['bethebrew'] = 0x05D1;
  6961. t['betrafehebrew'] = 0xFB4C;
  6962. t['bhabengali'] = 0x09AD;
  6963. t['bhadeva'] = 0x092D;
  6964. t['bhagujarati'] = 0x0AAD;
  6965. t['bhagurmukhi'] = 0x0A2D;
  6966. t['bhook'] = 0x0253;
  6967. t['bihiragana'] = 0x3073;
  6968. t['bikatakana'] = 0x30D3;
  6969. t['bilabialclick'] = 0x0298;
  6970. t['bindigurmukhi'] = 0x0A02;
  6971. t['birusquare'] = 0x3331;
  6972. t['blackcircle'] = 0x25CF;
  6973. t['blackdiamond'] = 0x25C6;
  6974. t['blackdownpointingtriangle'] = 0x25BC;
  6975. t['blackleftpointingpointer'] = 0x25C4;
  6976. t['blackleftpointingtriangle'] = 0x25C0;
  6977. t['blacklenticularbracketleft'] = 0x3010;
  6978. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  6979. t['blacklenticularbracketright'] = 0x3011;
  6980. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  6981. t['blacklowerlefttriangle'] = 0x25E3;
  6982. t['blacklowerrighttriangle'] = 0x25E2;
  6983. t['blackrectangle'] = 0x25AC;
  6984. t['blackrightpointingpointer'] = 0x25BA;
  6985. t['blackrightpointingtriangle'] = 0x25B6;
  6986. t['blacksmallsquare'] = 0x25AA;
  6987. t['blacksmilingface'] = 0x263B;
  6988. t['blacksquare'] = 0x25A0;
  6989. t['blackstar'] = 0x2605;
  6990. t['blackupperlefttriangle'] = 0x25E4;
  6991. t['blackupperrighttriangle'] = 0x25E5;
  6992. t['blackuppointingsmalltriangle'] = 0x25B4;
  6993. t['blackuppointingtriangle'] = 0x25B2;
  6994. t['blank'] = 0x2423;
  6995. t['blinebelow'] = 0x1E07;
  6996. t['block'] = 0x2588;
  6997. t['bmonospace'] = 0xFF42;
  6998. t['bobaimaithai'] = 0x0E1A;
  6999. t['bohiragana'] = 0x307C;
  7000. t['bokatakana'] = 0x30DC;
  7001. t['bparen'] = 0x249D;
  7002. t['bqsquare'] = 0x33C3;
  7003. t['braceex'] = 0xF8F4;
  7004. t['braceleft'] = 0x007B;
  7005. t['braceleftbt'] = 0xF8F3;
  7006. t['braceleftmid'] = 0xF8F2;
  7007. t['braceleftmonospace'] = 0xFF5B;
  7008. t['braceleftsmall'] = 0xFE5B;
  7009. t['bracelefttp'] = 0xF8F1;
  7010. t['braceleftvertical'] = 0xFE37;
  7011. t['braceright'] = 0x007D;
  7012. t['bracerightbt'] = 0xF8FE;
  7013. t['bracerightmid'] = 0xF8FD;
  7014. t['bracerightmonospace'] = 0xFF5D;
  7015. t['bracerightsmall'] = 0xFE5C;
  7016. t['bracerighttp'] = 0xF8FC;
  7017. t['bracerightvertical'] = 0xFE38;
  7018. t['bracketleft'] = 0x005B;
  7019. t['bracketleftbt'] = 0xF8F0;
  7020. t['bracketleftex'] = 0xF8EF;
  7021. t['bracketleftmonospace'] = 0xFF3B;
  7022. t['bracketlefttp'] = 0xF8EE;
  7023. t['bracketright'] = 0x005D;
  7024. t['bracketrightbt'] = 0xF8FB;
  7025. t['bracketrightex'] = 0xF8FA;
  7026. t['bracketrightmonospace'] = 0xFF3D;
  7027. t['bracketrighttp'] = 0xF8F9;
  7028. t['breve'] = 0x02D8;
  7029. t['brevebelowcmb'] = 0x032E;
  7030. t['brevecmb'] = 0x0306;
  7031. t['breveinvertedbelowcmb'] = 0x032F;
  7032. t['breveinvertedcmb'] = 0x0311;
  7033. t['breveinverteddoublecmb'] = 0x0361;
  7034. t['bridgebelowcmb'] = 0x032A;
  7035. t['bridgeinvertedbelowcmb'] = 0x033A;
  7036. t['brokenbar'] = 0x00A6;
  7037. t['bstroke'] = 0x0180;
  7038. t['bsuperior'] = 0xF6EA;
  7039. t['btopbar'] = 0x0183;
  7040. t['buhiragana'] = 0x3076;
  7041. t['bukatakana'] = 0x30D6;
  7042. t['bullet'] = 0x2022;
  7043. t['bulletinverse'] = 0x25D8;
  7044. t['bulletoperator'] = 0x2219;
  7045. t['bullseye'] = 0x25CE;
  7046. t['c'] = 0x0063;
  7047. t['caarmenian'] = 0x056E;
  7048. t['cabengali'] = 0x099A;
  7049. t['cacute'] = 0x0107;
  7050. t['cadeva'] = 0x091A;
  7051. t['cagujarati'] = 0x0A9A;
  7052. t['cagurmukhi'] = 0x0A1A;
  7053. t['calsquare'] = 0x3388;
  7054. t['candrabindubengali'] = 0x0981;
  7055. t['candrabinducmb'] = 0x0310;
  7056. t['candrabindudeva'] = 0x0901;
  7057. t['candrabindugujarati'] = 0x0A81;
  7058. t['capslock'] = 0x21EA;
  7059. t['careof'] = 0x2105;
  7060. t['caron'] = 0x02C7;
  7061. t['caronbelowcmb'] = 0x032C;
  7062. t['caroncmb'] = 0x030C;
  7063. t['carriagereturn'] = 0x21B5;
  7064. t['cbopomofo'] = 0x3118;
  7065. t['ccaron'] = 0x010D;
  7066. t['ccedilla'] = 0x00E7;
  7067. t['ccedillaacute'] = 0x1E09;
  7068. t['ccircle'] = 0x24D2;
  7069. t['ccircumflex'] = 0x0109;
  7070. t['ccurl'] = 0x0255;
  7071. t['cdot'] = 0x010B;
  7072. t['cdotaccent'] = 0x010B;
  7073. t['cdsquare'] = 0x33C5;
  7074. t['cedilla'] = 0x00B8;
  7075. t['cedillacmb'] = 0x0327;
  7076. t['cent'] = 0x00A2;
  7077. t['centigrade'] = 0x2103;
  7078. t['centinferior'] = 0xF6DF;
  7079. t['centmonospace'] = 0xFFE0;
  7080. t['centoldstyle'] = 0xF7A2;
  7081. t['centsuperior'] = 0xF6E0;
  7082. t['chaarmenian'] = 0x0579;
  7083. t['chabengali'] = 0x099B;
  7084. t['chadeva'] = 0x091B;
  7085. t['chagujarati'] = 0x0A9B;
  7086. t['chagurmukhi'] = 0x0A1B;
  7087. t['chbopomofo'] = 0x3114;
  7088. t['cheabkhasiancyrillic'] = 0x04BD;
  7089. t['checkmark'] = 0x2713;
  7090. t['checyrillic'] = 0x0447;
  7091. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  7092. t['chedescendercyrillic'] = 0x04B7;
  7093. t['chedieresiscyrillic'] = 0x04F5;
  7094. t['cheharmenian'] = 0x0573;
  7095. t['chekhakassiancyrillic'] = 0x04CC;
  7096. t['cheverticalstrokecyrillic'] = 0x04B9;
  7097. t['chi'] = 0x03C7;
  7098. t['chieuchacirclekorean'] = 0x3277;
  7099. t['chieuchaparenkorean'] = 0x3217;
  7100. t['chieuchcirclekorean'] = 0x3269;
  7101. t['chieuchkorean'] = 0x314A;
  7102. t['chieuchparenkorean'] = 0x3209;
  7103. t['chochangthai'] = 0x0E0A;
  7104. t['chochanthai'] = 0x0E08;
  7105. t['chochingthai'] = 0x0E09;
  7106. t['chochoethai'] = 0x0E0C;
  7107. t['chook'] = 0x0188;
  7108. t['cieucacirclekorean'] = 0x3276;
  7109. t['cieucaparenkorean'] = 0x3216;
  7110. t['cieuccirclekorean'] = 0x3268;
  7111. t['cieuckorean'] = 0x3148;
  7112. t['cieucparenkorean'] = 0x3208;
  7113. t['cieucuparenkorean'] = 0x321C;
  7114. t['circle'] = 0x25CB;
  7115. t['circlecopyrt'] = 0x00A9;
  7116. t['circlemultiply'] = 0x2297;
  7117. t['circleot'] = 0x2299;
  7118. t['circleplus'] = 0x2295;
  7119. t['circlepostalmark'] = 0x3036;
  7120. t['circlewithlefthalfblack'] = 0x25D0;
  7121. t['circlewithrighthalfblack'] = 0x25D1;
  7122. t['circumflex'] = 0x02C6;
  7123. t['circumflexbelowcmb'] = 0x032D;
  7124. t['circumflexcmb'] = 0x0302;
  7125. t['clear'] = 0x2327;
  7126. t['clickalveolar'] = 0x01C2;
  7127. t['clickdental'] = 0x01C0;
  7128. t['clicklateral'] = 0x01C1;
  7129. t['clickretroflex'] = 0x01C3;
  7130. t['club'] = 0x2663;
  7131. t['clubsuitblack'] = 0x2663;
  7132. t['clubsuitwhite'] = 0x2667;
  7133. t['cmcubedsquare'] = 0x33A4;
  7134. t['cmonospace'] = 0xFF43;
  7135. t['cmsquaredsquare'] = 0x33A0;
  7136. t['coarmenian'] = 0x0581;
  7137. t['colon'] = 0x003A;
  7138. t['colonmonetary'] = 0x20A1;
  7139. t['colonmonospace'] = 0xFF1A;
  7140. t['colonsign'] = 0x20A1;
  7141. t['colonsmall'] = 0xFE55;
  7142. t['colontriangularhalfmod'] = 0x02D1;
  7143. t['colontriangularmod'] = 0x02D0;
  7144. t['comma'] = 0x002C;
  7145. t['commaabovecmb'] = 0x0313;
  7146. t['commaaboverightcmb'] = 0x0315;
  7147. t['commaaccent'] = 0xF6C3;
  7148. t['commaarabic'] = 0x060C;
  7149. t['commaarmenian'] = 0x055D;
  7150. t['commainferior'] = 0xF6E1;
  7151. t['commamonospace'] = 0xFF0C;
  7152. t['commareversedabovecmb'] = 0x0314;
  7153. t['commareversedmod'] = 0x02BD;
  7154. t['commasmall'] = 0xFE50;
  7155. t['commasuperior'] = 0xF6E2;
  7156. t['commaturnedabovecmb'] = 0x0312;
  7157. t['commaturnedmod'] = 0x02BB;
  7158. t['compass'] = 0x263C;
  7159. t['congruent'] = 0x2245;
  7160. t['contourintegral'] = 0x222E;
  7161. t['control'] = 0x2303;
  7162. t['controlACK'] = 0x0006;
  7163. t['controlBEL'] = 0x0007;
  7164. t['controlBS'] = 0x0008;
  7165. t['controlCAN'] = 0x0018;
  7166. t['controlCR'] = 0x000D;
  7167. t['controlDC1'] = 0x0011;
  7168. t['controlDC2'] = 0x0012;
  7169. t['controlDC3'] = 0x0013;
  7170. t['controlDC4'] = 0x0014;
  7171. t['controlDEL'] = 0x007F;
  7172. t['controlDLE'] = 0x0010;
  7173. t['controlEM'] = 0x0019;
  7174. t['controlENQ'] = 0x0005;
  7175. t['controlEOT'] = 0x0004;
  7176. t['controlESC'] = 0x001B;
  7177. t['controlETB'] = 0x0017;
  7178. t['controlETX'] = 0x0003;
  7179. t['controlFF'] = 0x000C;
  7180. t['controlFS'] = 0x001C;
  7181. t['controlGS'] = 0x001D;
  7182. t['controlHT'] = 0x0009;
  7183. t['controlLF'] = 0x000A;
  7184. t['controlNAK'] = 0x0015;
  7185. t['controlNULL'] = 0x0000;
  7186. t['controlRS'] = 0x001E;
  7187. t['controlSI'] = 0x000F;
  7188. t['controlSO'] = 0x000E;
  7189. t['controlSOT'] = 0x0002;
  7190. t['controlSTX'] = 0x0001;
  7191. t['controlSUB'] = 0x001A;
  7192. t['controlSYN'] = 0x0016;
  7193. t['controlUS'] = 0x001F;
  7194. t['controlVT'] = 0x000B;
  7195. t['copyright'] = 0x00A9;
  7196. t['copyrightsans'] = 0xF8E9;
  7197. t['copyrightserif'] = 0xF6D9;
  7198. t['cornerbracketleft'] = 0x300C;
  7199. t['cornerbracketlefthalfwidth'] = 0xFF62;
  7200. t['cornerbracketleftvertical'] = 0xFE41;
  7201. t['cornerbracketright'] = 0x300D;
  7202. t['cornerbracketrighthalfwidth'] = 0xFF63;
  7203. t['cornerbracketrightvertical'] = 0xFE42;
  7204. t['corporationsquare'] = 0x337F;
  7205. t['cosquare'] = 0x33C7;
  7206. t['coverkgsquare'] = 0x33C6;
  7207. t['cparen'] = 0x249E;
  7208. t['cruzeiro'] = 0x20A2;
  7209. t['cstretched'] = 0x0297;
  7210. t['curlyand'] = 0x22CF;
  7211. t['curlyor'] = 0x22CE;
  7212. t['currency'] = 0x00A4;
  7213. t['cyrBreve'] = 0xF6D1;
  7214. t['cyrFlex'] = 0xF6D2;
  7215. t['cyrbreve'] = 0xF6D4;
  7216. t['cyrflex'] = 0xF6D5;
  7217. t['d'] = 0x0064;
  7218. t['daarmenian'] = 0x0564;
  7219. t['dabengali'] = 0x09A6;
  7220. t['dadarabic'] = 0x0636;
  7221. t['dadeva'] = 0x0926;
  7222. t['dadfinalarabic'] = 0xFEBE;
  7223. t['dadinitialarabic'] = 0xFEBF;
  7224. t['dadmedialarabic'] = 0xFEC0;
  7225. t['dagesh'] = 0x05BC;
  7226. t['dageshhebrew'] = 0x05BC;
  7227. t['dagger'] = 0x2020;
  7228. t['daggerdbl'] = 0x2021;
  7229. t['dagujarati'] = 0x0AA6;
  7230. t['dagurmukhi'] = 0x0A26;
  7231. t['dahiragana'] = 0x3060;
  7232. t['dakatakana'] = 0x30C0;
  7233. t['dalarabic'] = 0x062F;
  7234. t['dalet'] = 0x05D3;
  7235. t['daletdagesh'] = 0xFB33;
  7236. t['daletdageshhebrew'] = 0xFB33;
  7237. t['dalethebrew'] = 0x05D3;
  7238. t['dalfinalarabic'] = 0xFEAA;
  7239. t['dammaarabic'] = 0x064F;
  7240. t['dammalowarabic'] = 0x064F;
  7241. t['dammatanaltonearabic'] = 0x064C;
  7242. t['dammatanarabic'] = 0x064C;
  7243. t['danda'] = 0x0964;
  7244. t['dargahebrew'] = 0x05A7;
  7245. t['dargalefthebrew'] = 0x05A7;
  7246. t['dasiapneumatacyrilliccmb'] = 0x0485;
  7247. t['dblGrave'] = 0xF6D3;
  7248. t['dblanglebracketleft'] = 0x300A;
  7249. t['dblanglebracketleftvertical'] = 0xFE3D;
  7250. t['dblanglebracketright'] = 0x300B;
  7251. t['dblanglebracketrightvertical'] = 0xFE3E;
  7252. t['dblarchinvertedbelowcmb'] = 0x032B;
  7253. t['dblarrowleft'] = 0x21D4;
  7254. t['dblarrowright'] = 0x21D2;
  7255. t['dbldanda'] = 0x0965;
  7256. t['dblgrave'] = 0xF6D6;
  7257. t['dblgravecmb'] = 0x030F;
  7258. t['dblintegral'] = 0x222C;
  7259. t['dbllowline'] = 0x2017;
  7260. t['dbllowlinecmb'] = 0x0333;
  7261. t['dbloverlinecmb'] = 0x033F;
  7262. t['dblprimemod'] = 0x02BA;
  7263. t['dblverticalbar'] = 0x2016;
  7264. t['dblverticallineabovecmb'] = 0x030E;
  7265. t['dbopomofo'] = 0x3109;
  7266. t['dbsquare'] = 0x33C8;
  7267. t['dcaron'] = 0x010F;
  7268. t['dcedilla'] = 0x1E11;
  7269. t['dcircle'] = 0x24D3;
  7270. t['dcircumflexbelow'] = 0x1E13;
  7271. t['dcroat'] = 0x0111;
  7272. t['ddabengali'] = 0x09A1;
  7273. t['ddadeva'] = 0x0921;
  7274. t['ddagujarati'] = 0x0AA1;
  7275. t['ddagurmukhi'] = 0x0A21;
  7276. t['ddalarabic'] = 0x0688;
  7277. t['ddalfinalarabic'] = 0xFB89;
  7278. t['dddhadeva'] = 0x095C;
  7279. t['ddhabengali'] = 0x09A2;
  7280. t['ddhadeva'] = 0x0922;
  7281. t['ddhagujarati'] = 0x0AA2;
  7282. t['ddhagurmukhi'] = 0x0A22;
  7283. t['ddotaccent'] = 0x1E0B;
  7284. t['ddotbelow'] = 0x1E0D;
  7285. t['decimalseparatorarabic'] = 0x066B;
  7286. t['decimalseparatorpersian'] = 0x066B;
  7287. t['decyrillic'] = 0x0434;
  7288. t['degree'] = 0x00B0;
  7289. t['dehihebrew'] = 0x05AD;
  7290. t['dehiragana'] = 0x3067;
  7291. t['deicoptic'] = 0x03EF;
  7292. t['dekatakana'] = 0x30C7;
  7293. t['deleteleft'] = 0x232B;
  7294. t['deleteright'] = 0x2326;
  7295. t['delta'] = 0x03B4;
  7296. t['deltaturned'] = 0x018D;
  7297. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  7298. t['dezh'] = 0x02A4;
  7299. t['dhabengali'] = 0x09A7;
  7300. t['dhadeva'] = 0x0927;
  7301. t['dhagujarati'] = 0x0AA7;
  7302. t['dhagurmukhi'] = 0x0A27;
  7303. t['dhook'] = 0x0257;
  7304. t['dialytikatonos'] = 0x0385;
  7305. t['dialytikatonoscmb'] = 0x0344;
  7306. t['diamond'] = 0x2666;
  7307. t['diamondsuitwhite'] = 0x2662;
  7308. t['dieresis'] = 0x00A8;
  7309. t['dieresisacute'] = 0xF6D7;
  7310. t['dieresisbelowcmb'] = 0x0324;
  7311. t['dieresiscmb'] = 0x0308;
  7312. t['dieresisgrave'] = 0xF6D8;
  7313. t['dieresistonos'] = 0x0385;
  7314. t['dihiragana'] = 0x3062;
  7315. t['dikatakana'] = 0x30C2;
  7316. t['dittomark'] = 0x3003;
  7317. t['divide'] = 0x00F7;
  7318. t['divides'] = 0x2223;
  7319. t['divisionslash'] = 0x2215;
  7320. t['djecyrillic'] = 0x0452;
  7321. t['dkshade'] = 0x2593;
  7322. t['dlinebelow'] = 0x1E0F;
  7323. t['dlsquare'] = 0x3397;
  7324. t['dmacron'] = 0x0111;
  7325. t['dmonospace'] = 0xFF44;
  7326. t['dnblock'] = 0x2584;
  7327. t['dochadathai'] = 0x0E0E;
  7328. t['dodekthai'] = 0x0E14;
  7329. t['dohiragana'] = 0x3069;
  7330. t['dokatakana'] = 0x30C9;
  7331. t['dollar'] = 0x0024;
  7332. t['dollarinferior'] = 0xF6E3;
  7333. t['dollarmonospace'] = 0xFF04;
  7334. t['dollaroldstyle'] = 0xF724;
  7335. t['dollarsmall'] = 0xFE69;
  7336. t['dollarsuperior'] = 0xF6E4;
  7337. t['dong'] = 0x20AB;
  7338. t['dorusquare'] = 0x3326;
  7339. t['dotaccent'] = 0x02D9;
  7340. t['dotaccentcmb'] = 0x0307;
  7341. t['dotbelowcmb'] = 0x0323;
  7342. t['dotbelowcomb'] = 0x0323;
  7343. t['dotkatakana'] = 0x30FB;
  7344. t['dotlessi'] = 0x0131;
  7345. t['dotlessj'] = 0xF6BE;
  7346. t['dotlessjstrokehook'] = 0x0284;
  7347. t['dotmath'] = 0x22C5;
  7348. t['dottedcircle'] = 0x25CC;
  7349. t['doubleyodpatah'] = 0xFB1F;
  7350. t['doubleyodpatahhebrew'] = 0xFB1F;
  7351. t['downtackbelowcmb'] = 0x031E;
  7352. t['downtackmod'] = 0x02D5;
  7353. t['dparen'] = 0x249F;
  7354. t['dsuperior'] = 0xF6EB;
  7355. t['dtail'] = 0x0256;
  7356. t['dtopbar'] = 0x018C;
  7357. t['duhiragana'] = 0x3065;
  7358. t['dukatakana'] = 0x30C5;
  7359. t['dz'] = 0x01F3;
  7360. t['dzaltone'] = 0x02A3;
  7361. t['dzcaron'] = 0x01C6;
  7362. t['dzcurl'] = 0x02A5;
  7363. t['dzeabkhasiancyrillic'] = 0x04E1;
  7364. t['dzecyrillic'] = 0x0455;
  7365. t['dzhecyrillic'] = 0x045F;
  7366. t['e'] = 0x0065;
  7367. t['eacute'] = 0x00E9;
  7368. t['earth'] = 0x2641;
  7369. t['ebengali'] = 0x098F;
  7370. t['ebopomofo'] = 0x311C;
  7371. t['ebreve'] = 0x0115;
  7372. t['ecandradeva'] = 0x090D;
  7373. t['ecandragujarati'] = 0x0A8D;
  7374. t['ecandravowelsigndeva'] = 0x0945;
  7375. t['ecandravowelsigngujarati'] = 0x0AC5;
  7376. t['ecaron'] = 0x011B;
  7377. t['ecedillabreve'] = 0x1E1D;
  7378. t['echarmenian'] = 0x0565;
  7379. t['echyiwnarmenian'] = 0x0587;
  7380. t['ecircle'] = 0x24D4;
  7381. t['ecircumflex'] = 0x00EA;
  7382. t['ecircumflexacute'] = 0x1EBF;
  7383. t['ecircumflexbelow'] = 0x1E19;
  7384. t['ecircumflexdotbelow'] = 0x1EC7;
  7385. t['ecircumflexgrave'] = 0x1EC1;
  7386. t['ecircumflexhookabove'] = 0x1EC3;
  7387. t['ecircumflextilde'] = 0x1EC5;
  7388. t['ecyrillic'] = 0x0454;
  7389. t['edblgrave'] = 0x0205;
  7390. t['edeva'] = 0x090F;
  7391. t['edieresis'] = 0x00EB;
  7392. t['edot'] = 0x0117;
  7393. t['edotaccent'] = 0x0117;
  7394. t['edotbelow'] = 0x1EB9;
  7395. t['eegurmukhi'] = 0x0A0F;
  7396. t['eematragurmukhi'] = 0x0A47;
  7397. t['efcyrillic'] = 0x0444;
  7398. t['egrave'] = 0x00E8;
  7399. t['egujarati'] = 0x0A8F;
  7400. t['eharmenian'] = 0x0567;
  7401. t['ehbopomofo'] = 0x311D;
  7402. t['ehiragana'] = 0x3048;
  7403. t['ehookabove'] = 0x1EBB;
  7404. t['eibopomofo'] = 0x311F;
  7405. t['eight'] = 0x0038;
  7406. t['eightarabic'] = 0x0668;
  7407. t['eightbengali'] = 0x09EE;
  7408. t['eightcircle'] = 0x2467;
  7409. t['eightcircleinversesansserif'] = 0x2791;
  7410. t['eightdeva'] = 0x096E;
  7411. t['eighteencircle'] = 0x2471;
  7412. t['eighteenparen'] = 0x2485;
  7413. t['eighteenperiod'] = 0x2499;
  7414. t['eightgujarati'] = 0x0AEE;
  7415. t['eightgurmukhi'] = 0x0A6E;
  7416. t['eighthackarabic'] = 0x0668;
  7417. t['eighthangzhou'] = 0x3028;
  7418. t['eighthnotebeamed'] = 0x266B;
  7419. t['eightideographicparen'] = 0x3227;
  7420. t['eightinferior'] = 0x2088;
  7421. t['eightmonospace'] = 0xFF18;
  7422. t['eightoldstyle'] = 0xF738;
  7423. t['eightparen'] = 0x247B;
  7424. t['eightperiod'] = 0x248F;
  7425. t['eightpersian'] = 0x06F8;
  7426. t['eightroman'] = 0x2177;
  7427. t['eightsuperior'] = 0x2078;
  7428. t['eightthai'] = 0x0E58;
  7429. t['einvertedbreve'] = 0x0207;
  7430. t['eiotifiedcyrillic'] = 0x0465;
  7431. t['ekatakana'] = 0x30A8;
  7432. t['ekatakanahalfwidth'] = 0xFF74;
  7433. t['ekonkargurmukhi'] = 0x0A74;
  7434. t['ekorean'] = 0x3154;
  7435. t['elcyrillic'] = 0x043B;
  7436. t['element'] = 0x2208;
  7437. t['elevencircle'] = 0x246A;
  7438. t['elevenparen'] = 0x247E;
  7439. t['elevenperiod'] = 0x2492;
  7440. t['elevenroman'] = 0x217A;
  7441. t['ellipsis'] = 0x2026;
  7442. t['ellipsisvertical'] = 0x22EE;
  7443. t['emacron'] = 0x0113;
  7444. t['emacronacute'] = 0x1E17;
  7445. t['emacrongrave'] = 0x1E15;
  7446. t['emcyrillic'] = 0x043C;
  7447. t['emdash'] = 0x2014;
  7448. t['emdashvertical'] = 0xFE31;
  7449. t['emonospace'] = 0xFF45;
  7450. t['emphasismarkarmenian'] = 0x055B;
  7451. t['emptyset'] = 0x2205;
  7452. t['enbopomofo'] = 0x3123;
  7453. t['encyrillic'] = 0x043D;
  7454. t['endash'] = 0x2013;
  7455. t['endashvertical'] = 0xFE32;
  7456. t['endescendercyrillic'] = 0x04A3;
  7457. t['eng'] = 0x014B;
  7458. t['engbopomofo'] = 0x3125;
  7459. t['enghecyrillic'] = 0x04A5;
  7460. t['enhookcyrillic'] = 0x04C8;
  7461. t['enspace'] = 0x2002;
  7462. t['eogonek'] = 0x0119;
  7463. t['eokorean'] = 0x3153;
  7464. t['eopen'] = 0x025B;
  7465. t['eopenclosed'] = 0x029A;
  7466. t['eopenreversed'] = 0x025C;
  7467. t['eopenreversedclosed'] = 0x025E;
  7468. t['eopenreversedhook'] = 0x025D;
  7469. t['eparen'] = 0x24A0;
  7470. t['epsilon'] = 0x03B5;
  7471. t['epsilontonos'] = 0x03AD;
  7472. t['equal'] = 0x003D;
  7473. t['equalmonospace'] = 0xFF1D;
  7474. t['equalsmall'] = 0xFE66;
  7475. t['equalsuperior'] = 0x207C;
  7476. t['equivalence'] = 0x2261;
  7477. t['erbopomofo'] = 0x3126;
  7478. t['ercyrillic'] = 0x0440;
  7479. t['ereversed'] = 0x0258;
  7480. t['ereversedcyrillic'] = 0x044D;
  7481. t['escyrillic'] = 0x0441;
  7482. t['esdescendercyrillic'] = 0x04AB;
  7483. t['esh'] = 0x0283;
  7484. t['eshcurl'] = 0x0286;
  7485. t['eshortdeva'] = 0x090E;
  7486. t['eshortvowelsigndeva'] = 0x0946;
  7487. t['eshreversedloop'] = 0x01AA;
  7488. t['eshsquatreversed'] = 0x0285;
  7489. t['esmallhiragana'] = 0x3047;
  7490. t['esmallkatakana'] = 0x30A7;
  7491. t['esmallkatakanahalfwidth'] = 0xFF6A;
  7492. t['estimated'] = 0x212E;
  7493. t['esuperior'] = 0xF6EC;
  7494. t['eta'] = 0x03B7;
  7495. t['etarmenian'] = 0x0568;
  7496. t['etatonos'] = 0x03AE;
  7497. t['eth'] = 0x00F0;
  7498. t['etilde'] = 0x1EBD;
  7499. t['etildebelow'] = 0x1E1B;
  7500. t['etnahtafoukhhebrew'] = 0x0591;
  7501. t['etnahtafoukhlefthebrew'] = 0x0591;
  7502. t['etnahtahebrew'] = 0x0591;
  7503. t['etnahtalefthebrew'] = 0x0591;
  7504. t['eturned'] = 0x01DD;
  7505. t['eukorean'] = 0x3161;
  7506. t['euro'] = 0x20AC;
  7507. t['evowelsignbengali'] = 0x09C7;
  7508. t['evowelsigndeva'] = 0x0947;
  7509. t['evowelsigngujarati'] = 0x0AC7;
  7510. t['exclam'] = 0x0021;
  7511. t['exclamarmenian'] = 0x055C;
  7512. t['exclamdbl'] = 0x203C;
  7513. t['exclamdown'] = 0x00A1;
  7514. t['exclamdownsmall'] = 0xF7A1;
  7515. t['exclammonospace'] = 0xFF01;
  7516. t['exclamsmall'] = 0xF721;
  7517. t['existential'] = 0x2203;
  7518. t['ezh'] = 0x0292;
  7519. t['ezhcaron'] = 0x01EF;
  7520. t['ezhcurl'] = 0x0293;
  7521. t['ezhreversed'] = 0x01B9;
  7522. t['ezhtail'] = 0x01BA;
  7523. t['f'] = 0x0066;
  7524. t['fadeva'] = 0x095E;
  7525. t['fagurmukhi'] = 0x0A5E;
  7526. t['fahrenheit'] = 0x2109;
  7527. t['fathaarabic'] = 0x064E;
  7528. t['fathalowarabic'] = 0x064E;
  7529. t['fathatanarabic'] = 0x064B;
  7530. t['fbopomofo'] = 0x3108;
  7531. t['fcircle'] = 0x24D5;
  7532. t['fdotaccent'] = 0x1E1F;
  7533. t['feharabic'] = 0x0641;
  7534. t['feharmenian'] = 0x0586;
  7535. t['fehfinalarabic'] = 0xFED2;
  7536. t['fehinitialarabic'] = 0xFED3;
  7537. t['fehmedialarabic'] = 0xFED4;
  7538. t['feicoptic'] = 0x03E5;
  7539. t['female'] = 0x2640;
  7540. t['ff'] = 0xFB00;
  7541. t['ffi'] = 0xFB03;
  7542. t['ffl'] = 0xFB04;
  7543. t['fi'] = 0xFB01;
  7544. t['fifteencircle'] = 0x246E;
  7545. t['fifteenparen'] = 0x2482;
  7546. t['fifteenperiod'] = 0x2496;
  7547. t['figuredash'] = 0x2012;
  7548. t['filledbox'] = 0x25A0;
  7549. t['filledrect'] = 0x25AC;
  7550. t['finalkaf'] = 0x05DA;
  7551. t['finalkafdagesh'] = 0xFB3A;
  7552. t['finalkafdageshhebrew'] = 0xFB3A;
  7553. t['finalkafhebrew'] = 0x05DA;
  7554. t['finalmem'] = 0x05DD;
  7555. t['finalmemhebrew'] = 0x05DD;
  7556. t['finalnun'] = 0x05DF;
  7557. t['finalnunhebrew'] = 0x05DF;
  7558. t['finalpe'] = 0x05E3;
  7559. t['finalpehebrew'] = 0x05E3;
  7560. t['finaltsadi'] = 0x05E5;
  7561. t['finaltsadihebrew'] = 0x05E5;
  7562. t['firsttonechinese'] = 0x02C9;
  7563. t['fisheye'] = 0x25C9;
  7564. t['fitacyrillic'] = 0x0473;
  7565. t['five'] = 0x0035;
  7566. t['fivearabic'] = 0x0665;
  7567. t['fivebengali'] = 0x09EB;
  7568. t['fivecircle'] = 0x2464;
  7569. t['fivecircleinversesansserif'] = 0x278E;
  7570. t['fivedeva'] = 0x096B;
  7571. t['fiveeighths'] = 0x215D;
  7572. t['fivegujarati'] = 0x0AEB;
  7573. t['fivegurmukhi'] = 0x0A6B;
  7574. t['fivehackarabic'] = 0x0665;
  7575. t['fivehangzhou'] = 0x3025;
  7576. t['fiveideographicparen'] = 0x3224;
  7577. t['fiveinferior'] = 0x2085;
  7578. t['fivemonospace'] = 0xFF15;
  7579. t['fiveoldstyle'] = 0xF735;
  7580. t['fiveparen'] = 0x2478;
  7581. t['fiveperiod'] = 0x248C;
  7582. t['fivepersian'] = 0x06F5;
  7583. t['fiveroman'] = 0x2174;
  7584. t['fivesuperior'] = 0x2075;
  7585. t['fivethai'] = 0x0E55;
  7586. t['fl'] = 0xFB02;
  7587. t['florin'] = 0x0192;
  7588. t['fmonospace'] = 0xFF46;
  7589. t['fmsquare'] = 0x3399;
  7590. t['fofanthai'] = 0x0E1F;
  7591. t['fofathai'] = 0x0E1D;
  7592. t['fongmanthai'] = 0x0E4F;
  7593. t['forall'] = 0x2200;
  7594. t['four'] = 0x0034;
  7595. t['fourarabic'] = 0x0664;
  7596. t['fourbengali'] = 0x09EA;
  7597. t['fourcircle'] = 0x2463;
  7598. t['fourcircleinversesansserif'] = 0x278D;
  7599. t['fourdeva'] = 0x096A;
  7600. t['fourgujarati'] = 0x0AEA;
  7601. t['fourgurmukhi'] = 0x0A6A;
  7602. t['fourhackarabic'] = 0x0664;
  7603. t['fourhangzhou'] = 0x3024;
  7604. t['fourideographicparen'] = 0x3223;
  7605. t['fourinferior'] = 0x2084;
  7606. t['fourmonospace'] = 0xFF14;
  7607. t['fournumeratorbengali'] = 0x09F7;
  7608. t['fouroldstyle'] = 0xF734;
  7609. t['fourparen'] = 0x2477;
  7610. t['fourperiod'] = 0x248B;
  7611. t['fourpersian'] = 0x06F4;
  7612. t['fourroman'] = 0x2173;
  7613. t['foursuperior'] = 0x2074;
  7614. t['fourteencircle'] = 0x246D;
  7615. t['fourteenparen'] = 0x2481;
  7616. t['fourteenperiod'] = 0x2495;
  7617. t['fourthai'] = 0x0E54;
  7618. t['fourthtonechinese'] = 0x02CB;
  7619. t['fparen'] = 0x24A1;
  7620. t['fraction'] = 0x2044;
  7621. t['franc'] = 0x20A3;
  7622. t['g'] = 0x0067;
  7623. t['gabengali'] = 0x0997;
  7624. t['gacute'] = 0x01F5;
  7625. t['gadeva'] = 0x0917;
  7626. t['gafarabic'] = 0x06AF;
  7627. t['gaffinalarabic'] = 0xFB93;
  7628. t['gafinitialarabic'] = 0xFB94;
  7629. t['gafmedialarabic'] = 0xFB95;
  7630. t['gagujarati'] = 0x0A97;
  7631. t['gagurmukhi'] = 0x0A17;
  7632. t['gahiragana'] = 0x304C;
  7633. t['gakatakana'] = 0x30AC;
  7634. t['gamma'] = 0x03B3;
  7635. t['gammalatinsmall'] = 0x0263;
  7636. t['gammasuperior'] = 0x02E0;
  7637. t['gangiacoptic'] = 0x03EB;
  7638. t['gbopomofo'] = 0x310D;
  7639. t['gbreve'] = 0x011F;
  7640. t['gcaron'] = 0x01E7;
  7641. t['gcedilla'] = 0x0123;
  7642. t['gcircle'] = 0x24D6;
  7643. t['gcircumflex'] = 0x011D;
  7644. t['gcommaaccent'] = 0x0123;
  7645. t['gdot'] = 0x0121;
  7646. t['gdotaccent'] = 0x0121;
  7647. t['gecyrillic'] = 0x0433;
  7648. t['gehiragana'] = 0x3052;
  7649. t['gekatakana'] = 0x30B2;
  7650. t['geometricallyequal'] = 0x2251;
  7651. t['gereshaccenthebrew'] = 0x059C;
  7652. t['gereshhebrew'] = 0x05F3;
  7653. t['gereshmuqdamhebrew'] = 0x059D;
  7654. t['germandbls'] = 0x00DF;
  7655. t['gershayimaccenthebrew'] = 0x059E;
  7656. t['gershayimhebrew'] = 0x05F4;
  7657. t['getamark'] = 0x3013;
  7658. t['ghabengali'] = 0x0998;
  7659. t['ghadarmenian'] = 0x0572;
  7660. t['ghadeva'] = 0x0918;
  7661. t['ghagujarati'] = 0x0A98;
  7662. t['ghagurmukhi'] = 0x0A18;
  7663. t['ghainarabic'] = 0x063A;
  7664. t['ghainfinalarabic'] = 0xFECE;
  7665. t['ghaininitialarabic'] = 0xFECF;
  7666. t['ghainmedialarabic'] = 0xFED0;
  7667. t['ghemiddlehookcyrillic'] = 0x0495;
  7668. t['ghestrokecyrillic'] = 0x0493;
  7669. t['gheupturncyrillic'] = 0x0491;
  7670. t['ghhadeva'] = 0x095A;
  7671. t['ghhagurmukhi'] = 0x0A5A;
  7672. t['ghook'] = 0x0260;
  7673. t['ghzsquare'] = 0x3393;
  7674. t['gihiragana'] = 0x304E;
  7675. t['gikatakana'] = 0x30AE;
  7676. t['gimarmenian'] = 0x0563;
  7677. t['gimel'] = 0x05D2;
  7678. t['gimeldagesh'] = 0xFB32;
  7679. t['gimeldageshhebrew'] = 0xFB32;
  7680. t['gimelhebrew'] = 0x05D2;
  7681. t['gjecyrillic'] = 0x0453;
  7682. t['glottalinvertedstroke'] = 0x01BE;
  7683. t['glottalstop'] = 0x0294;
  7684. t['glottalstopinverted'] = 0x0296;
  7685. t['glottalstopmod'] = 0x02C0;
  7686. t['glottalstopreversed'] = 0x0295;
  7687. t['glottalstopreversedmod'] = 0x02C1;
  7688. t['glottalstopreversedsuperior'] = 0x02E4;
  7689. t['glottalstopstroke'] = 0x02A1;
  7690. t['glottalstopstrokereversed'] = 0x02A2;
  7691. t['gmacron'] = 0x1E21;
  7692. t['gmonospace'] = 0xFF47;
  7693. t['gohiragana'] = 0x3054;
  7694. t['gokatakana'] = 0x30B4;
  7695. t['gparen'] = 0x24A2;
  7696. t['gpasquare'] = 0x33AC;
  7697. t['gradient'] = 0x2207;
  7698. t['grave'] = 0x0060;
  7699. t['gravebelowcmb'] = 0x0316;
  7700. t['gravecmb'] = 0x0300;
  7701. t['gravecomb'] = 0x0300;
  7702. t['gravedeva'] = 0x0953;
  7703. t['gravelowmod'] = 0x02CE;
  7704. t['gravemonospace'] = 0xFF40;
  7705. t['gravetonecmb'] = 0x0340;
  7706. t['greater'] = 0x003E;
  7707. t['greaterequal'] = 0x2265;
  7708. t['greaterequalorless'] = 0x22DB;
  7709. t['greatermonospace'] = 0xFF1E;
  7710. t['greaterorequivalent'] = 0x2273;
  7711. t['greaterorless'] = 0x2277;
  7712. t['greateroverequal'] = 0x2267;
  7713. t['greatersmall'] = 0xFE65;
  7714. t['gscript'] = 0x0261;
  7715. t['gstroke'] = 0x01E5;
  7716. t['guhiragana'] = 0x3050;
  7717. t['guillemotleft'] = 0x00AB;
  7718. t['guillemotright'] = 0x00BB;
  7719. t['guilsinglleft'] = 0x2039;
  7720. t['guilsinglright'] = 0x203A;
  7721. t['gukatakana'] = 0x30B0;
  7722. t['guramusquare'] = 0x3318;
  7723. t['gysquare'] = 0x33C9;
  7724. t['h'] = 0x0068;
  7725. t['haabkhasiancyrillic'] = 0x04A9;
  7726. t['haaltonearabic'] = 0x06C1;
  7727. t['habengali'] = 0x09B9;
  7728. t['hadescendercyrillic'] = 0x04B3;
  7729. t['hadeva'] = 0x0939;
  7730. t['hagujarati'] = 0x0AB9;
  7731. t['hagurmukhi'] = 0x0A39;
  7732. t['haharabic'] = 0x062D;
  7733. t['hahfinalarabic'] = 0xFEA2;
  7734. t['hahinitialarabic'] = 0xFEA3;
  7735. t['hahiragana'] = 0x306F;
  7736. t['hahmedialarabic'] = 0xFEA4;
  7737. t['haitusquare'] = 0x332A;
  7738. t['hakatakana'] = 0x30CF;
  7739. t['hakatakanahalfwidth'] = 0xFF8A;
  7740. t['halantgurmukhi'] = 0x0A4D;
  7741. t['hamzaarabic'] = 0x0621;
  7742. t['hamzalowarabic'] = 0x0621;
  7743. t['hangulfiller'] = 0x3164;
  7744. t['hardsigncyrillic'] = 0x044A;
  7745. t['harpoonleftbarbup'] = 0x21BC;
  7746. t['harpoonrightbarbup'] = 0x21C0;
  7747. t['hasquare'] = 0x33CA;
  7748. t['hatafpatah'] = 0x05B2;
  7749. t['hatafpatah16'] = 0x05B2;
  7750. t['hatafpatah23'] = 0x05B2;
  7751. t['hatafpatah2f'] = 0x05B2;
  7752. t['hatafpatahhebrew'] = 0x05B2;
  7753. t['hatafpatahnarrowhebrew'] = 0x05B2;
  7754. t['hatafpatahquarterhebrew'] = 0x05B2;
  7755. t['hatafpatahwidehebrew'] = 0x05B2;
  7756. t['hatafqamats'] = 0x05B3;
  7757. t['hatafqamats1b'] = 0x05B3;
  7758. t['hatafqamats28'] = 0x05B3;
  7759. t['hatafqamats34'] = 0x05B3;
  7760. t['hatafqamatshebrew'] = 0x05B3;
  7761. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  7762. t['hatafqamatsquarterhebrew'] = 0x05B3;
  7763. t['hatafqamatswidehebrew'] = 0x05B3;
  7764. t['hatafsegol'] = 0x05B1;
  7765. t['hatafsegol17'] = 0x05B1;
  7766. t['hatafsegol24'] = 0x05B1;
  7767. t['hatafsegol30'] = 0x05B1;
  7768. t['hatafsegolhebrew'] = 0x05B1;
  7769. t['hatafsegolnarrowhebrew'] = 0x05B1;
  7770. t['hatafsegolquarterhebrew'] = 0x05B1;
  7771. t['hatafsegolwidehebrew'] = 0x05B1;
  7772. t['hbar'] = 0x0127;
  7773. t['hbopomofo'] = 0x310F;
  7774. t['hbrevebelow'] = 0x1E2B;
  7775. t['hcedilla'] = 0x1E29;
  7776. t['hcircle'] = 0x24D7;
  7777. t['hcircumflex'] = 0x0125;
  7778. t['hdieresis'] = 0x1E27;
  7779. t['hdotaccent'] = 0x1E23;
  7780. t['hdotbelow'] = 0x1E25;
  7781. t['he'] = 0x05D4;
  7782. t['heart'] = 0x2665;
  7783. t['heartsuitblack'] = 0x2665;
  7784. t['heartsuitwhite'] = 0x2661;
  7785. t['hedagesh'] = 0xFB34;
  7786. t['hedageshhebrew'] = 0xFB34;
  7787. t['hehaltonearabic'] = 0x06C1;
  7788. t['heharabic'] = 0x0647;
  7789. t['hehebrew'] = 0x05D4;
  7790. t['hehfinalaltonearabic'] = 0xFBA7;
  7791. t['hehfinalalttwoarabic'] = 0xFEEA;
  7792. t['hehfinalarabic'] = 0xFEEA;
  7793. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  7794. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  7795. t['hehinitialaltonearabic'] = 0xFBA8;
  7796. t['hehinitialarabic'] = 0xFEEB;
  7797. t['hehiragana'] = 0x3078;
  7798. t['hehmedialaltonearabic'] = 0xFBA9;
  7799. t['hehmedialarabic'] = 0xFEEC;
  7800. t['heiseierasquare'] = 0x337B;
  7801. t['hekatakana'] = 0x30D8;
  7802. t['hekatakanahalfwidth'] = 0xFF8D;
  7803. t['hekutaarusquare'] = 0x3336;
  7804. t['henghook'] = 0x0267;
  7805. t['herutusquare'] = 0x3339;
  7806. t['het'] = 0x05D7;
  7807. t['hethebrew'] = 0x05D7;
  7808. t['hhook'] = 0x0266;
  7809. t['hhooksuperior'] = 0x02B1;
  7810. t['hieuhacirclekorean'] = 0x327B;
  7811. t['hieuhaparenkorean'] = 0x321B;
  7812. t['hieuhcirclekorean'] = 0x326D;
  7813. t['hieuhkorean'] = 0x314E;
  7814. t['hieuhparenkorean'] = 0x320D;
  7815. t['hihiragana'] = 0x3072;
  7816. t['hikatakana'] = 0x30D2;
  7817. t['hikatakanahalfwidth'] = 0xFF8B;
  7818. t['hiriq'] = 0x05B4;
  7819. t['hiriq14'] = 0x05B4;
  7820. t['hiriq21'] = 0x05B4;
  7821. t['hiriq2d'] = 0x05B4;
  7822. t['hiriqhebrew'] = 0x05B4;
  7823. t['hiriqnarrowhebrew'] = 0x05B4;
  7824. t['hiriqquarterhebrew'] = 0x05B4;
  7825. t['hiriqwidehebrew'] = 0x05B4;
  7826. t['hlinebelow'] = 0x1E96;
  7827. t['hmonospace'] = 0xFF48;
  7828. t['hoarmenian'] = 0x0570;
  7829. t['hohipthai'] = 0x0E2B;
  7830. t['hohiragana'] = 0x307B;
  7831. t['hokatakana'] = 0x30DB;
  7832. t['hokatakanahalfwidth'] = 0xFF8E;
  7833. t['holam'] = 0x05B9;
  7834. t['holam19'] = 0x05B9;
  7835. t['holam26'] = 0x05B9;
  7836. t['holam32'] = 0x05B9;
  7837. t['holamhebrew'] = 0x05B9;
  7838. t['holamnarrowhebrew'] = 0x05B9;
  7839. t['holamquarterhebrew'] = 0x05B9;
  7840. t['holamwidehebrew'] = 0x05B9;
  7841. t['honokhukthai'] = 0x0E2E;
  7842. t['hookabovecomb'] = 0x0309;
  7843. t['hookcmb'] = 0x0309;
  7844. t['hookpalatalizedbelowcmb'] = 0x0321;
  7845. t['hookretroflexbelowcmb'] = 0x0322;
  7846. t['hoonsquare'] = 0x3342;
  7847. t['horicoptic'] = 0x03E9;
  7848. t['horizontalbar'] = 0x2015;
  7849. t['horncmb'] = 0x031B;
  7850. t['hotsprings'] = 0x2668;
  7851. t['house'] = 0x2302;
  7852. t['hparen'] = 0x24A3;
  7853. t['hsuperior'] = 0x02B0;
  7854. t['hturned'] = 0x0265;
  7855. t['huhiragana'] = 0x3075;
  7856. t['huiitosquare'] = 0x3333;
  7857. t['hukatakana'] = 0x30D5;
  7858. t['hukatakanahalfwidth'] = 0xFF8C;
  7859. t['hungarumlaut'] = 0x02DD;
  7860. t['hungarumlautcmb'] = 0x030B;
  7861. t['hv'] = 0x0195;
  7862. t['hyphen'] = 0x002D;
  7863. t['hypheninferior'] = 0xF6E5;
  7864. t['hyphenmonospace'] = 0xFF0D;
  7865. t['hyphensmall'] = 0xFE63;
  7866. t['hyphensuperior'] = 0xF6E6;
  7867. t['hyphentwo'] = 0x2010;
  7868. t['i'] = 0x0069;
  7869. t['iacute'] = 0x00ED;
  7870. t['iacyrillic'] = 0x044F;
  7871. t['ibengali'] = 0x0987;
  7872. t['ibopomofo'] = 0x3127;
  7873. t['ibreve'] = 0x012D;
  7874. t['icaron'] = 0x01D0;
  7875. t['icircle'] = 0x24D8;
  7876. t['icircumflex'] = 0x00EE;
  7877. t['icyrillic'] = 0x0456;
  7878. t['idblgrave'] = 0x0209;
  7879. t['ideographearthcircle'] = 0x328F;
  7880. t['ideographfirecircle'] = 0x328B;
  7881. t['ideographicallianceparen'] = 0x323F;
  7882. t['ideographiccallparen'] = 0x323A;
  7883. t['ideographiccentrecircle'] = 0x32A5;
  7884. t['ideographicclose'] = 0x3006;
  7885. t['ideographiccomma'] = 0x3001;
  7886. t['ideographiccommaleft'] = 0xFF64;
  7887. t['ideographiccongratulationparen'] = 0x3237;
  7888. t['ideographiccorrectcircle'] = 0x32A3;
  7889. t['ideographicearthparen'] = 0x322F;
  7890. t['ideographicenterpriseparen'] = 0x323D;
  7891. t['ideographicexcellentcircle'] = 0x329D;
  7892. t['ideographicfestivalparen'] = 0x3240;
  7893. t['ideographicfinancialcircle'] = 0x3296;
  7894. t['ideographicfinancialparen'] = 0x3236;
  7895. t['ideographicfireparen'] = 0x322B;
  7896. t['ideographichaveparen'] = 0x3232;
  7897. t['ideographichighcircle'] = 0x32A4;
  7898. t['ideographiciterationmark'] = 0x3005;
  7899. t['ideographiclaborcircle'] = 0x3298;
  7900. t['ideographiclaborparen'] = 0x3238;
  7901. t['ideographicleftcircle'] = 0x32A7;
  7902. t['ideographiclowcircle'] = 0x32A6;
  7903. t['ideographicmedicinecircle'] = 0x32A9;
  7904. t['ideographicmetalparen'] = 0x322E;
  7905. t['ideographicmoonparen'] = 0x322A;
  7906. t['ideographicnameparen'] = 0x3234;
  7907. t['ideographicperiod'] = 0x3002;
  7908. t['ideographicprintcircle'] = 0x329E;
  7909. t['ideographicreachparen'] = 0x3243;
  7910. t['ideographicrepresentparen'] = 0x3239;
  7911. t['ideographicresourceparen'] = 0x323E;
  7912. t['ideographicrightcircle'] = 0x32A8;
  7913. t['ideographicsecretcircle'] = 0x3299;
  7914. t['ideographicselfparen'] = 0x3242;
  7915. t['ideographicsocietyparen'] = 0x3233;
  7916. t['ideographicspace'] = 0x3000;
  7917. t['ideographicspecialparen'] = 0x3235;
  7918. t['ideographicstockparen'] = 0x3231;
  7919. t['ideographicstudyparen'] = 0x323B;
  7920. t['ideographicsunparen'] = 0x3230;
  7921. t['ideographicsuperviseparen'] = 0x323C;
  7922. t['ideographicwaterparen'] = 0x322C;
  7923. t['ideographicwoodparen'] = 0x322D;
  7924. t['ideographiczero'] = 0x3007;
  7925. t['ideographmetalcircle'] = 0x328E;
  7926. t['ideographmooncircle'] = 0x328A;
  7927. t['ideographnamecircle'] = 0x3294;
  7928. t['ideographsuncircle'] = 0x3290;
  7929. t['ideographwatercircle'] = 0x328C;
  7930. t['ideographwoodcircle'] = 0x328D;
  7931. t['ideva'] = 0x0907;
  7932. t['idieresis'] = 0x00EF;
  7933. t['idieresisacute'] = 0x1E2F;
  7934. t['idieresiscyrillic'] = 0x04E5;
  7935. t['idotbelow'] = 0x1ECB;
  7936. t['iebrevecyrillic'] = 0x04D7;
  7937. t['iecyrillic'] = 0x0435;
  7938. t['ieungacirclekorean'] = 0x3275;
  7939. t['ieungaparenkorean'] = 0x3215;
  7940. t['ieungcirclekorean'] = 0x3267;
  7941. t['ieungkorean'] = 0x3147;
  7942. t['ieungparenkorean'] = 0x3207;
  7943. t['igrave'] = 0x00EC;
  7944. t['igujarati'] = 0x0A87;
  7945. t['igurmukhi'] = 0x0A07;
  7946. t['ihiragana'] = 0x3044;
  7947. t['ihookabove'] = 0x1EC9;
  7948. t['iibengali'] = 0x0988;
  7949. t['iicyrillic'] = 0x0438;
  7950. t['iideva'] = 0x0908;
  7951. t['iigujarati'] = 0x0A88;
  7952. t['iigurmukhi'] = 0x0A08;
  7953. t['iimatragurmukhi'] = 0x0A40;
  7954. t['iinvertedbreve'] = 0x020B;
  7955. t['iishortcyrillic'] = 0x0439;
  7956. t['iivowelsignbengali'] = 0x09C0;
  7957. t['iivowelsigndeva'] = 0x0940;
  7958. t['iivowelsigngujarati'] = 0x0AC0;
  7959. t['ij'] = 0x0133;
  7960. t['ikatakana'] = 0x30A4;
  7961. t['ikatakanahalfwidth'] = 0xFF72;
  7962. t['ikorean'] = 0x3163;
  7963. t['ilde'] = 0x02DC;
  7964. t['iluyhebrew'] = 0x05AC;
  7965. t['imacron'] = 0x012B;
  7966. t['imacroncyrillic'] = 0x04E3;
  7967. t['imageorapproximatelyequal'] = 0x2253;
  7968. t['imatragurmukhi'] = 0x0A3F;
  7969. t['imonospace'] = 0xFF49;
  7970. t['increment'] = 0x2206;
  7971. t['infinity'] = 0x221E;
  7972. t['iniarmenian'] = 0x056B;
  7973. t['integral'] = 0x222B;
  7974. t['integralbottom'] = 0x2321;
  7975. t['integralbt'] = 0x2321;
  7976. t['integralex'] = 0xF8F5;
  7977. t['integraltop'] = 0x2320;
  7978. t['integraltp'] = 0x2320;
  7979. t['intersection'] = 0x2229;
  7980. t['intisquare'] = 0x3305;
  7981. t['invbullet'] = 0x25D8;
  7982. t['invcircle'] = 0x25D9;
  7983. t['invsmileface'] = 0x263B;
  7984. t['iocyrillic'] = 0x0451;
  7985. t['iogonek'] = 0x012F;
  7986. t['iota'] = 0x03B9;
  7987. t['iotadieresis'] = 0x03CA;
  7988. t['iotadieresistonos'] = 0x0390;
  7989. t['iotalatin'] = 0x0269;
  7990. t['iotatonos'] = 0x03AF;
  7991. t['iparen'] = 0x24A4;
  7992. t['irigurmukhi'] = 0x0A72;
  7993. t['ismallhiragana'] = 0x3043;
  7994. t['ismallkatakana'] = 0x30A3;
  7995. t['ismallkatakanahalfwidth'] = 0xFF68;
  7996. t['issharbengali'] = 0x09FA;
  7997. t['istroke'] = 0x0268;
  7998. t['isuperior'] = 0xF6ED;
  7999. t['iterationhiragana'] = 0x309D;
  8000. t['iterationkatakana'] = 0x30FD;
  8001. t['itilde'] = 0x0129;
  8002. t['itildebelow'] = 0x1E2D;
  8003. t['iubopomofo'] = 0x3129;
  8004. t['iucyrillic'] = 0x044E;
  8005. t['ivowelsignbengali'] = 0x09BF;
  8006. t['ivowelsigndeva'] = 0x093F;
  8007. t['ivowelsigngujarati'] = 0x0ABF;
  8008. t['izhitsacyrillic'] = 0x0475;
  8009. t['izhitsadblgravecyrillic'] = 0x0477;
  8010. t['j'] = 0x006A;
  8011. t['jaarmenian'] = 0x0571;
  8012. t['jabengali'] = 0x099C;
  8013. t['jadeva'] = 0x091C;
  8014. t['jagujarati'] = 0x0A9C;
  8015. t['jagurmukhi'] = 0x0A1C;
  8016. t['jbopomofo'] = 0x3110;
  8017. t['jcaron'] = 0x01F0;
  8018. t['jcircle'] = 0x24D9;
  8019. t['jcircumflex'] = 0x0135;
  8020. t['jcrossedtail'] = 0x029D;
  8021. t['jdotlessstroke'] = 0x025F;
  8022. t['jecyrillic'] = 0x0458;
  8023. t['jeemarabic'] = 0x062C;
  8024. t['jeemfinalarabic'] = 0xFE9E;
  8025. t['jeeminitialarabic'] = 0xFE9F;
  8026. t['jeemmedialarabic'] = 0xFEA0;
  8027. t['jeharabic'] = 0x0698;
  8028. t['jehfinalarabic'] = 0xFB8B;
  8029. t['jhabengali'] = 0x099D;
  8030. t['jhadeva'] = 0x091D;
  8031. t['jhagujarati'] = 0x0A9D;
  8032. t['jhagurmukhi'] = 0x0A1D;
  8033. t['jheharmenian'] = 0x057B;
  8034. t['jis'] = 0x3004;
  8035. t['jmonospace'] = 0xFF4A;
  8036. t['jparen'] = 0x24A5;
  8037. t['jsuperior'] = 0x02B2;
  8038. t['k'] = 0x006B;
  8039. t['kabashkircyrillic'] = 0x04A1;
  8040. t['kabengali'] = 0x0995;
  8041. t['kacute'] = 0x1E31;
  8042. t['kacyrillic'] = 0x043A;
  8043. t['kadescendercyrillic'] = 0x049B;
  8044. t['kadeva'] = 0x0915;
  8045. t['kaf'] = 0x05DB;
  8046. t['kafarabic'] = 0x0643;
  8047. t['kafdagesh'] = 0xFB3B;
  8048. t['kafdageshhebrew'] = 0xFB3B;
  8049. t['kaffinalarabic'] = 0xFEDA;
  8050. t['kafhebrew'] = 0x05DB;
  8051. t['kafinitialarabic'] = 0xFEDB;
  8052. t['kafmedialarabic'] = 0xFEDC;
  8053. t['kafrafehebrew'] = 0xFB4D;
  8054. t['kagujarati'] = 0x0A95;
  8055. t['kagurmukhi'] = 0x0A15;
  8056. t['kahiragana'] = 0x304B;
  8057. t['kahookcyrillic'] = 0x04C4;
  8058. t['kakatakana'] = 0x30AB;
  8059. t['kakatakanahalfwidth'] = 0xFF76;
  8060. t['kappa'] = 0x03BA;
  8061. t['kappasymbolgreek'] = 0x03F0;
  8062. t['kapyeounmieumkorean'] = 0x3171;
  8063. t['kapyeounphieuphkorean'] = 0x3184;
  8064. t['kapyeounpieupkorean'] = 0x3178;
  8065. t['kapyeounssangpieupkorean'] = 0x3179;
  8066. t['karoriisquare'] = 0x330D;
  8067. t['kashidaautoarabic'] = 0x0640;
  8068. t['kashidaautonosidebearingarabic'] = 0x0640;
  8069. t['kasmallkatakana'] = 0x30F5;
  8070. t['kasquare'] = 0x3384;
  8071. t['kasraarabic'] = 0x0650;
  8072. t['kasratanarabic'] = 0x064D;
  8073. t['kastrokecyrillic'] = 0x049F;
  8074. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  8075. t['kaverticalstrokecyrillic'] = 0x049D;
  8076. t['kbopomofo'] = 0x310E;
  8077. t['kcalsquare'] = 0x3389;
  8078. t['kcaron'] = 0x01E9;
  8079. t['kcedilla'] = 0x0137;
  8080. t['kcircle'] = 0x24DA;
  8081. t['kcommaaccent'] = 0x0137;
  8082. t['kdotbelow'] = 0x1E33;
  8083. t['keharmenian'] = 0x0584;
  8084. t['kehiragana'] = 0x3051;
  8085. t['kekatakana'] = 0x30B1;
  8086. t['kekatakanahalfwidth'] = 0xFF79;
  8087. t['kenarmenian'] = 0x056F;
  8088. t['kesmallkatakana'] = 0x30F6;
  8089. t['kgreenlandic'] = 0x0138;
  8090. t['khabengali'] = 0x0996;
  8091. t['khacyrillic'] = 0x0445;
  8092. t['khadeva'] = 0x0916;
  8093. t['khagujarati'] = 0x0A96;
  8094. t['khagurmukhi'] = 0x0A16;
  8095. t['khaharabic'] = 0x062E;
  8096. t['khahfinalarabic'] = 0xFEA6;
  8097. t['khahinitialarabic'] = 0xFEA7;
  8098. t['khahmedialarabic'] = 0xFEA8;
  8099. t['kheicoptic'] = 0x03E7;
  8100. t['khhadeva'] = 0x0959;
  8101. t['khhagurmukhi'] = 0x0A59;
  8102. t['khieukhacirclekorean'] = 0x3278;
  8103. t['khieukhaparenkorean'] = 0x3218;
  8104. t['khieukhcirclekorean'] = 0x326A;
  8105. t['khieukhkorean'] = 0x314B;
  8106. t['khieukhparenkorean'] = 0x320A;
  8107. t['khokhaithai'] = 0x0E02;
  8108. t['khokhonthai'] = 0x0E05;
  8109. t['khokhuatthai'] = 0x0E03;
  8110. t['khokhwaithai'] = 0x0E04;
  8111. t['khomutthai'] = 0x0E5B;
  8112. t['khook'] = 0x0199;
  8113. t['khorakhangthai'] = 0x0E06;
  8114. t['khzsquare'] = 0x3391;
  8115. t['kihiragana'] = 0x304D;
  8116. t['kikatakana'] = 0x30AD;
  8117. t['kikatakanahalfwidth'] = 0xFF77;
  8118. t['kiroguramusquare'] = 0x3315;
  8119. t['kiromeetorusquare'] = 0x3316;
  8120. t['kirosquare'] = 0x3314;
  8121. t['kiyeokacirclekorean'] = 0x326E;
  8122. t['kiyeokaparenkorean'] = 0x320E;
  8123. t['kiyeokcirclekorean'] = 0x3260;
  8124. t['kiyeokkorean'] = 0x3131;
  8125. t['kiyeokparenkorean'] = 0x3200;
  8126. t['kiyeoksioskorean'] = 0x3133;
  8127. t['kjecyrillic'] = 0x045C;
  8128. t['klinebelow'] = 0x1E35;
  8129. t['klsquare'] = 0x3398;
  8130. t['kmcubedsquare'] = 0x33A6;
  8131. t['kmonospace'] = 0xFF4B;
  8132. t['kmsquaredsquare'] = 0x33A2;
  8133. t['kohiragana'] = 0x3053;
  8134. t['kohmsquare'] = 0x33C0;
  8135. t['kokaithai'] = 0x0E01;
  8136. t['kokatakana'] = 0x30B3;
  8137. t['kokatakanahalfwidth'] = 0xFF7A;
  8138. t['kooposquare'] = 0x331E;
  8139. t['koppacyrillic'] = 0x0481;
  8140. t['koreanstandardsymbol'] = 0x327F;
  8141. t['koroniscmb'] = 0x0343;
  8142. t['kparen'] = 0x24A6;
  8143. t['kpasquare'] = 0x33AA;
  8144. t['ksicyrillic'] = 0x046F;
  8145. t['ktsquare'] = 0x33CF;
  8146. t['kturned'] = 0x029E;
  8147. t['kuhiragana'] = 0x304F;
  8148. t['kukatakana'] = 0x30AF;
  8149. t['kukatakanahalfwidth'] = 0xFF78;
  8150. t['kvsquare'] = 0x33B8;
  8151. t['kwsquare'] = 0x33BE;
  8152. t['l'] = 0x006C;
  8153. t['labengali'] = 0x09B2;
  8154. t['lacute'] = 0x013A;
  8155. t['ladeva'] = 0x0932;
  8156. t['lagujarati'] = 0x0AB2;
  8157. t['lagurmukhi'] = 0x0A32;
  8158. t['lakkhangyaothai'] = 0x0E45;
  8159. t['lamaleffinalarabic'] = 0xFEFC;
  8160. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  8161. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  8162. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  8163. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  8164. t['lamalefisolatedarabic'] = 0xFEFB;
  8165. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  8166. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  8167. t['lamarabic'] = 0x0644;
  8168. t['lambda'] = 0x03BB;
  8169. t['lambdastroke'] = 0x019B;
  8170. t['lamed'] = 0x05DC;
  8171. t['lameddagesh'] = 0xFB3C;
  8172. t['lameddageshhebrew'] = 0xFB3C;
  8173. t['lamedhebrew'] = 0x05DC;
  8174. t['lamfinalarabic'] = 0xFEDE;
  8175. t['lamhahinitialarabic'] = 0xFCCA;
  8176. t['laminitialarabic'] = 0xFEDF;
  8177. t['lamjeeminitialarabic'] = 0xFCC9;
  8178. t['lamkhahinitialarabic'] = 0xFCCB;
  8179. t['lamlamhehisolatedarabic'] = 0xFDF2;
  8180. t['lammedialarabic'] = 0xFEE0;
  8181. t['lammeemhahinitialarabic'] = 0xFD88;
  8182. t['lammeeminitialarabic'] = 0xFCCC;
  8183. t['largecircle'] = 0x25EF;
  8184. t['lbar'] = 0x019A;
  8185. t['lbelt'] = 0x026C;
  8186. t['lbopomofo'] = 0x310C;
  8187. t['lcaron'] = 0x013E;
  8188. t['lcedilla'] = 0x013C;
  8189. t['lcircle'] = 0x24DB;
  8190. t['lcircumflexbelow'] = 0x1E3D;
  8191. t['lcommaaccent'] = 0x013C;
  8192. t['ldot'] = 0x0140;
  8193. t['ldotaccent'] = 0x0140;
  8194. t['ldotbelow'] = 0x1E37;
  8195. t['ldotbelowmacron'] = 0x1E39;
  8196. t['leftangleabovecmb'] = 0x031A;
  8197. t['lefttackbelowcmb'] = 0x0318;
  8198. t['less'] = 0x003C;
  8199. t['lessequal'] = 0x2264;
  8200. t['lessequalorgreater'] = 0x22DA;
  8201. t['lessmonospace'] = 0xFF1C;
  8202. t['lessorequivalent'] = 0x2272;
  8203. t['lessorgreater'] = 0x2276;
  8204. t['lessoverequal'] = 0x2266;
  8205. t['lesssmall'] = 0xFE64;
  8206. t['lezh'] = 0x026E;
  8207. t['lfblock'] = 0x258C;
  8208. t['lhookretroflex'] = 0x026D;
  8209. t['lira'] = 0x20A4;
  8210. t['liwnarmenian'] = 0x056C;
  8211. t['lj'] = 0x01C9;
  8212. t['ljecyrillic'] = 0x0459;
  8213. t['ll'] = 0xF6C0;
  8214. t['lladeva'] = 0x0933;
  8215. t['llagujarati'] = 0x0AB3;
  8216. t['llinebelow'] = 0x1E3B;
  8217. t['llladeva'] = 0x0934;
  8218. t['llvocalicbengali'] = 0x09E1;
  8219. t['llvocalicdeva'] = 0x0961;
  8220. t['llvocalicvowelsignbengali'] = 0x09E3;
  8221. t['llvocalicvowelsigndeva'] = 0x0963;
  8222. t['lmiddletilde'] = 0x026B;
  8223. t['lmonospace'] = 0xFF4C;
  8224. t['lmsquare'] = 0x33D0;
  8225. t['lochulathai'] = 0x0E2C;
  8226. t['logicaland'] = 0x2227;
  8227. t['logicalnot'] = 0x00AC;
  8228. t['logicalnotreversed'] = 0x2310;
  8229. t['logicalor'] = 0x2228;
  8230. t['lolingthai'] = 0x0E25;
  8231. t['longs'] = 0x017F;
  8232. t['lowlinecenterline'] = 0xFE4E;
  8233. t['lowlinecmb'] = 0x0332;
  8234. t['lowlinedashed'] = 0xFE4D;
  8235. t['lozenge'] = 0x25CA;
  8236. t['lparen'] = 0x24A7;
  8237. t['lslash'] = 0x0142;
  8238. t['lsquare'] = 0x2113;
  8239. t['lsuperior'] = 0xF6EE;
  8240. t['ltshade'] = 0x2591;
  8241. t['luthai'] = 0x0E26;
  8242. t['lvocalicbengali'] = 0x098C;
  8243. t['lvocalicdeva'] = 0x090C;
  8244. t['lvocalicvowelsignbengali'] = 0x09E2;
  8245. t['lvocalicvowelsigndeva'] = 0x0962;
  8246. t['lxsquare'] = 0x33D3;
  8247. t['m'] = 0x006D;
  8248. t['mabengali'] = 0x09AE;
  8249. t['macron'] = 0x00AF;
  8250. t['macronbelowcmb'] = 0x0331;
  8251. t['macroncmb'] = 0x0304;
  8252. t['macronlowmod'] = 0x02CD;
  8253. t['macronmonospace'] = 0xFFE3;
  8254. t['macute'] = 0x1E3F;
  8255. t['madeva'] = 0x092E;
  8256. t['magujarati'] = 0x0AAE;
  8257. t['magurmukhi'] = 0x0A2E;
  8258. t['mahapakhhebrew'] = 0x05A4;
  8259. t['mahapakhlefthebrew'] = 0x05A4;
  8260. t['mahiragana'] = 0x307E;
  8261. t['maichattawalowleftthai'] = 0xF895;
  8262. t['maichattawalowrightthai'] = 0xF894;
  8263. t['maichattawathai'] = 0x0E4B;
  8264. t['maichattawaupperleftthai'] = 0xF893;
  8265. t['maieklowleftthai'] = 0xF88C;
  8266. t['maieklowrightthai'] = 0xF88B;
  8267. t['maiekthai'] = 0x0E48;
  8268. t['maiekupperleftthai'] = 0xF88A;
  8269. t['maihanakatleftthai'] = 0xF884;
  8270. t['maihanakatthai'] = 0x0E31;
  8271. t['maitaikhuleftthai'] = 0xF889;
  8272. t['maitaikhuthai'] = 0x0E47;
  8273. t['maitholowleftthai'] = 0xF88F;
  8274. t['maitholowrightthai'] = 0xF88E;
  8275. t['maithothai'] = 0x0E49;
  8276. t['maithoupperleftthai'] = 0xF88D;
  8277. t['maitrilowleftthai'] = 0xF892;
  8278. t['maitrilowrightthai'] = 0xF891;
  8279. t['maitrithai'] = 0x0E4A;
  8280. t['maitriupperleftthai'] = 0xF890;
  8281. t['maiyamokthai'] = 0x0E46;
  8282. t['makatakana'] = 0x30DE;
  8283. t['makatakanahalfwidth'] = 0xFF8F;
  8284. t['male'] = 0x2642;
  8285. t['mansyonsquare'] = 0x3347;
  8286. t['maqafhebrew'] = 0x05BE;
  8287. t['mars'] = 0x2642;
  8288. t['masoracirclehebrew'] = 0x05AF;
  8289. t['masquare'] = 0x3383;
  8290. t['mbopomofo'] = 0x3107;
  8291. t['mbsquare'] = 0x33D4;
  8292. t['mcircle'] = 0x24DC;
  8293. t['mcubedsquare'] = 0x33A5;
  8294. t['mdotaccent'] = 0x1E41;
  8295. t['mdotbelow'] = 0x1E43;
  8296. t['meemarabic'] = 0x0645;
  8297. t['meemfinalarabic'] = 0xFEE2;
  8298. t['meeminitialarabic'] = 0xFEE3;
  8299. t['meemmedialarabic'] = 0xFEE4;
  8300. t['meemmeeminitialarabic'] = 0xFCD1;
  8301. t['meemmeemisolatedarabic'] = 0xFC48;
  8302. t['meetorusquare'] = 0x334D;
  8303. t['mehiragana'] = 0x3081;
  8304. t['meizierasquare'] = 0x337E;
  8305. t['mekatakana'] = 0x30E1;
  8306. t['mekatakanahalfwidth'] = 0xFF92;
  8307. t['mem'] = 0x05DE;
  8308. t['memdagesh'] = 0xFB3E;
  8309. t['memdageshhebrew'] = 0xFB3E;
  8310. t['memhebrew'] = 0x05DE;
  8311. t['menarmenian'] = 0x0574;
  8312. t['merkhahebrew'] = 0x05A5;
  8313. t['merkhakefulahebrew'] = 0x05A6;
  8314. t['merkhakefulalefthebrew'] = 0x05A6;
  8315. t['merkhalefthebrew'] = 0x05A5;
  8316. t['mhook'] = 0x0271;
  8317. t['mhzsquare'] = 0x3392;
  8318. t['middledotkatakanahalfwidth'] = 0xFF65;
  8319. t['middot'] = 0x00B7;
  8320. t['mieumacirclekorean'] = 0x3272;
  8321. t['mieumaparenkorean'] = 0x3212;
  8322. t['mieumcirclekorean'] = 0x3264;
  8323. t['mieumkorean'] = 0x3141;
  8324. t['mieumpansioskorean'] = 0x3170;
  8325. t['mieumparenkorean'] = 0x3204;
  8326. t['mieumpieupkorean'] = 0x316E;
  8327. t['mieumsioskorean'] = 0x316F;
  8328. t['mihiragana'] = 0x307F;
  8329. t['mikatakana'] = 0x30DF;
  8330. t['mikatakanahalfwidth'] = 0xFF90;
  8331. t['minus'] = 0x2212;
  8332. t['minusbelowcmb'] = 0x0320;
  8333. t['minuscircle'] = 0x2296;
  8334. t['minusmod'] = 0x02D7;
  8335. t['minusplus'] = 0x2213;
  8336. t['minute'] = 0x2032;
  8337. t['miribaarusquare'] = 0x334A;
  8338. t['mirisquare'] = 0x3349;
  8339. t['mlonglegturned'] = 0x0270;
  8340. t['mlsquare'] = 0x3396;
  8341. t['mmcubedsquare'] = 0x33A3;
  8342. t['mmonospace'] = 0xFF4D;
  8343. t['mmsquaredsquare'] = 0x339F;
  8344. t['mohiragana'] = 0x3082;
  8345. t['mohmsquare'] = 0x33C1;
  8346. t['mokatakana'] = 0x30E2;
  8347. t['mokatakanahalfwidth'] = 0xFF93;
  8348. t['molsquare'] = 0x33D6;
  8349. t['momathai'] = 0x0E21;
  8350. t['moverssquare'] = 0x33A7;
  8351. t['moverssquaredsquare'] = 0x33A8;
  8352. t['mparen'] = 0x24A8;
  8353. t['mpasquare'] = 0x33AB;
  8354. t['mssquare'] = 0x33B3;
  8355. t['msuperior'] = 0xF6EF;
  8356. t['mturned'] = 0x026F;
  8357. t['mu'] = 0x00B5;
  8358. t['mu1'] = 0x00B5;
  8359. t['muasquare'] = 0x3382;
  8360. t['muchgreater'] = 0x226B;
  8361. t['muchless'] = 0x226A;
  8362. t['mufsquare'] = 0x338C;
  8363. t['mugreek'] = 0x03BC;
  8364. t['mugsquare'] = 0x338D;
  8365. t['muhiragana'] = 0x3080;
  8366. t['mukatakana'] = 0x30E0;
  8367. t['mukatakanahalfwidth'] = 0xFF91;
  8368. t['mulsquare'] = 0x3395;
  8369. t['multiply'] = 0x00D7;
  8370. t['mumsquare'] = 0x339B;
  8371. t['munahhebrew'] = 0x05A3;
  8372. t['munahlefthebrew'] = 0x05A3;
  8373. t['musicalnote'] = 0x266A;
  8374. t['musicalnotedbl'] = 0x266B;
  8375. t['musicflatsign'] = 0x266D;
  8376. t['musicsharpsign'] = 0x266F;
  8377. t['mussquare'] = 0x33B2;
  8378. t['muvsquare'] = 0x33B6;
  8379. t['muwsquare'] = 0x33BC;
  8380. t['mvmegasquare'] = 0x33B9;
  8381. t['mvsquare'] = 0x33B7;
  8382. t['mwmegasquare'] = 0x33BF;
  8383. t['mwsquare'] = 0x33BD;
  8384. t['n'] = 0x006E;
  8385. t['nabengali'] = 0x09A8;
  8386. t['nabla'] = 0x2207;
  8387. t['nacute'] = 0x0144;
  8388. t['nadeva'] = 0x0928;
  8389. t['nagujarati'] = 0x0AA8;
  8390. t['nagurmukhi'] = 0x0A28;
  8391. t['nahiragana'] = 0x306A;
  8392. t['nakatakana'] = 0x30CA;
  8393. t['nakatakanahalfwidth'] = 0xFF85;
  8394. t['napostrophe'] = 0x0149;
  8395. t['nasquare'] = 0x3381;
  8396. t['nbopomofo'] = 0x310B;
  8397. t['nbspace'] = 0x00A0;
  8398. t['ncaron'] = 0x0148;
  8399. t['ncedilla'] = 0x0146;
  8400. t['ncircle'] = 0x24DD;
  8401. t['ncircumflexbelow'] = 0x1E4B;
  8402. t['ncommaaccent'] = 0x0146;
  8403. t['ndotaccent'] = 0x1E45;
  8404. t['ndotbelow'] = 0x1E47;
  8405. t['nehiragana'] = 0x306D;
  8406. t['nekatakana'] = 0x30CD;
  8407. t['nekatakanahalfwidth'] = 0xFF88;
  8408. t['newsheqelsign'] = 0x20AA;
  8409. t['nfsquare'] = 0x338B;
  8410. t['ngabengali'] = 0x0999;
  8411. t['ngadeva'] = 0x0919;
  8412. t['ngagujarati'] = 0x0A99;
  8413. t['ngagurmukhi'] = 0x0A19;
  8414. t['ngonguthai'] = 0x0E07;
  8415. t['nhiragana'] = 0x3093;
  8416. t['nhookleft'] = 0x0272;
  8417. t['nhookretroflex'] = 0x0273;
  8418. t['nieunacirclekorean'] = 0x326F;
  8419. t['nieunaparenkorean'] = 0x320F;
  8420. t['nieuncieuckorean'] = 0x3135;
  8421. t['nieuncirclekorean'] = 0x3261;
  8422. t['nieunhieuhkorean'] = 0x3136;
  8423. t['nieunkorean'] = 0x3134;
  8424. t['nieunpansioskorean'] = 0x3168;
  8425. t['nieunparenkorean'] = 0x3201;
  8426. t['nieunsioskorean'] = 0x3167;
  8427. t['nieuntikeutkorean'] = 0x3166;
  8428. t['nihiragana'] = 0x306B;
  8429. t['nikatakana'] = 0x30CB;
  8430. t['nikatakanahalfwidth'] = 0xFF86;
  8431. t['nikhahitleftthai'] = 0xF899;
  8432. t['nikhahitthai'] = 0x0E4D;
  8433. t['nine'] = 0x0039;
  8434. t['ninearabic'] = 0x0669;
  8435. t['ninebengali'] = 0x09EF;
  8436. t['ninecircle'] = 0x2468;
  8437. t['ninecircleinversesansserif'] = 0x2792;
  8438. t['ninedeva'] = 0x096F;
  8439. t['ninegujarati'] = 0x0AEF;
  8440. t['ninegurmukhi'] = 0x0A6F;
  8441. t['ninehackarabic'] = 0x0669;
  8442. t['ninehangzhou'] = 0x3029;
  8443. t['nineideographicparen'] = 0x3228;
  8444. t['nineinferior'] = 0x2089;
  8445. t['ninemonospace'] = 0xFF19;
  8446. t['nineoldstyle'] = 0xF739;
  8447. t['nineparen'] = 0x247C;
  8448. t['nineperiod'] = 0x2490;
  8449. t['ninepersian'] = 0x06F9;
  8450. t['nineroman'] = 0x2178;
  8451. t['ninesuperior'] = 0x2079;
  8452. t['nineteencircle'] = 0x2472;
  8453. t['nineteenparen'] = 0x2486;
  8454. t['nineteenperiod'] = 0x249A;
  8455. t['ninethai'] = 0x0E59;
  8456. t['nj'] = 0x01CC;
  8457. t['njecyrillic'] = 0x045A;
  8458. t['nkatakana'] = 0x30F3;
  8459. t['nkatakanahalfwidth'] = 0xFF9D;
  8460. t['nlegrightlong'] = 0x019E;
  8461. t['nlinebelow'] = 0x1E49;
  8462. t['nmonospace'] = 0xFF4E;
  8463. t['nmsquare'] = 0x339A;
  8464. t['nnabengali'] = 0x09A3;
  8465. t['nnadeva'] = 0x0923;
  8466. t['nnagujarati'] = 0x0AA3;
  8467. t['nnagurmukhi'] = 0x0A23;
  8468. t['nnnadeva'] = 0x0929;
  8469. t['nohiragana'] = 0x306E;
  8470. t['nokatakana'] = 0x30CE;
  8471. t['nokatakanahalfwidth'] = 0xFF89;
  8472. t['nonbreakingspace'] = 0x00A0;
  8473. t['nonenthai'] = 0x0E13;
  8474. t['nonuthai'] = 0x0E19;
  8475. t['noonarabic'] = 0x0646;
  8476. t['noonfinalarabic'] = 0xFEE6;
  8477. t['noonghunnaarabic'] = 0x06BA;
  8478. t['noonghunnafinalarabic'] = 0xFB9F;
  8479. t['nooninitialarabic'] = 0xFEE7;
  8480. t['noonjeeminitialarabic'] = 0xFCD2;
  8481. t['noonjeemisolatedarabic'] = 0xFC4B;
  8482. t['noonmedialarabic'] = 0xFEE8;
  8483. t['noonmeeminitialarabic'] = 0xFCD5;
  8484. t['noonmeemisolatedarabic'] = 0xFC4E;
  8485. t['noonnoonfinalarabic'] = 0xFC8D;
  8486. t['notcontains'] = 0x220C;
  8487. t['notelement'] = 0x2209;
  8488. t['notelementof'] = 0x2209;
  8489. t['notequal'] = 0x2260;
  8490. t['notgreater'] = 0x226F;
  8491. t['notgreaternorequal'] = 0x2271;
  8492. t['notgreaternorless'] = 0x2279;
  8493. t['notidentical'] = 0x2262;
  8494. t['notless'] = 0x226E;
  8495. t['notlessnorequal'] = 0x2270;
  8496. t['notparallel'] = 0x2226;
  8497. t['notprecedes'] = 0x2280;
  8498. t['notsubset'] = 0x2284;
  8499. t['notsucceeds'] = 0x2281;
  8500. t['notsuperset'] = 0x2285;
  8501. t['nowarmenian'] = 0x0576;
  8502. t['nparen'] = 0x24A9;
  8503. t['nssquare'] = 0x33B1;
  8504. t['nsuperior'] = 0x207F;
  8505. t['ntilde'] = 0x00F1;
  8506. t['nu'] = 0x03BD;
  8507. t['nuhiragana'] = 0x306C;
  8508. t['nukatakana'] = 0x30CC;
  8509. t['nukatakanahalfwidth'] = 0xFF87;
  8510. t['nuktabengali'] = 0x09BC;
  8511. t['nuktadeva'] = 0x093C;
  8512. t['nuktagujarati'] = 0x0ABC;
  8513. t['nuktagurmukhi'] = 0x0A3C;
  8514. t['numbersign'] = 0x0023;
  8515. t['numbersignmonospace'] = 0xFF03;
  8516. t['numbersignsmall'] = 0xFE5F;
  8517. t['numeralsigngreek'] = 0x0374;
  8518. t['numeralsignlowergreek'] = 0x0375;
  8519. t['numero'] = 0x2116;
  8520. t['nun'] = 0x05E0;
  8521. t['nundagesh'] = 0xFB40;
  8522. t['nundageshhebrew'] = 0xFB40;
  8523. t['nunhebrew'] = 0x05E0;
  8524. t['nvsquare'] = 0x33B5;
  8525. t['nwsquare'] = 0x33BB;
  8526. t['nyabengali'] = 0x099E;
  8527. t['nyadeva'] = 0x091E;
  8528. t['nyagujarati'] = 0x0A9E;
  8529. t['nyagurmukhi'] = 0x0A1E;
  8530. t['o'] = 0x006F;
  8531. t['oacute'] = 0x00F3;
  8532. t['oangthai'] = 0x0E2D;
  8533. t['obarred'] = 0x0275;
  8534. t['obarredcyrillic'] = 0x04E9;
  8535. t['obarreddieresiscyrillic'] = 0x04EB;
  8536. t['obengali'] = 0x0993;
  8537. t['obopomofo'] = 0x311B;
  8538. t['obreve'] = 0x014F;
  8539. t['ocandradeva'] = 0x0911;
  8540. t['ocandragujarati'] = 0x0A91;
  8541. t['ocandravowelsigndeva'] = 0x0949;
  8542. t['ocandravowelsigngujarati'] = 0x0AC9;
  8543. t['ocaron'] = 0x01D2;
  8544. t['ocircle'] = 0x24DE;
  8545. t['ocircumflex'] = 0x00F4;
  8546. t['ocircumflexacute'] = 0x1ED1;
  8547. t['ocircumflexdotbelow'] = 0x1ED9;
  8548. t['ocircumflexgrave'] = 0x1ED3;
  8549. t['ocircumflexhookabove'] = 0x1ED5;
  8550. t['ocircumflextilde'] = 0x1ED7;
  8551. t['ocyrillic'] = 0x043E;
  8552. t['odblacute'] = 0x0151;
  8553. t['odblgrave'] = 0x020D;
  8554. t['odeva'] = 0x0913;
  8555. t['odieresis'] = 0x00F6;
  8556. t['odieresiscyrillic'] = 0x04E7;
  8557. t['odotbelow'] = 0x1ECD;
  8558. t['oe'] = 0x0153;
  8559. t['oekorean'] = 0x315A;
  8560. t['ogonek'] = 0x02DB;
  8561. t['ogonekcmb'] = 0x0328;
  8562. t['ograve'] = 0x00F2;
  8563. t['ogujarati'] = 0x0A93;
  8564. t['oharmenian'] = 0x0585;
  8565. t['ohiragana'] = 0x304A;
  8566. t['ohookabove'] = 0x1ECF;
  8567. t['ohorn'] = 0x01A1;
  8568. t['ohornacute'] = 0x1EDB;
  8569. t['ohorndotbelow'] = 0x1EE3;
  8570. t['ohorngrave'] = 0x1EDD;
  8571. t['ohornhookabove'] = 0x1EDF;
  8572. t['ohorntilde'] = 0x1EE1;
  8573. t['ohungarumlaut'] = 0x0151;
  8574. t['oi'] = 0x01A3;
  8575. t['oinvertedbreve'] = 0x020F;
  8576. t['okatakana'] = 0x30AA;
  8577. t['okatakanahalfwidth'] = 0xFF75;
  8578. t['okorean'] = 0x3157;
  8579. t['olehebrew'] = 0x05AB;
  8580. t['omacron'] = 0x014D;
  8581. t['omacronacute'] = 0x1E53;
  8582. t['omacrongrave'] = 0x1E51;
  8583. t['omdeva'] = 0x0950;
  8584. t['omega'] = 0x03C9;
  8585. t['omega1'] = 0x03D6;
  8586. t['omegacyrillic'] = 0x0461;
  8587. t['omegalatinclosed'] = 0x0277;
  8588. t['omegaroundcyrillic'] = 0x047B;
  8589. t['omegatitlocyrillic'] = 0x047D;
  8590. t['omegatonos'] = 0x03CE;
  8591. t['omgujarati'] = 0x0AD0;
  8592. t['omicron'] = 0x03BF;
  8593. t['omicrontonos'] = 0x03CC;
  8594. t['omonospace'] = 0xFF4F;
  8595. t['one'] = 0x0031;
  8596. t['onearabic'] = 0x0661;
  8597. t['onebengali'] = 0x09E7;
  8598. t['onecircle'] = 0x2460;
  8599. t['onecircleinversesansserif'] = 0x278A;
  8600. t['onedeva'] = 0x0967;
  8601. t['onedotenleader'] = 0x2024;
  8602. t['oneeighth'] = 0x215B;
  8603. t['onefitted'] = 0xF6DC;
  8604. t['onegujarati'] = 0x0AE7;
  8605. t['onegurmukhi'] = 0x0A67;
  8606. t['onehackarabic'] = 0x0661;
  8607. t['onehalf'] = 0x00BD;
  8608. t['onehangzhou'] = 0x3021;
  8609. t['oneideographicparen'] = 0x3220;
  8610. t['oneinferior'] = 0x2081;
  8611. t['onemonospace'] = 0xFF11;
  8612. t['onenumeratorbengali'] = 0x09F4;
  8613. t['oneoldstyle'] = 0xF731;
  8614. t['oneparen'] = 0x2474;
  8615. t['oneperiod'] = 0x2488;
  8616. t['onepersian'] = 0x06F1;
  8617. t['onequarter'] = 0x00BC;
  8618. t['oneroman'] = 0x2170;
  8619. t['onesuperior'] = 0x00B9;
  8620. t['onethai'] = 0x0E51;
  8621. t['onethird'] = 0x2153;
  8622. t['oogonek'] = 0x01EB;
  8623. t['oogonekmacron'] = 0x01ED;
  8624. t['oogurmukhi'] = 0x0A13;
  8625. t['oomatragurmukhi'] = 0x0A4B;
  8626. t['oopen'] = 0x0254;
  8627. t['oparen'] = 0x24AA;
  8628. t['openbullet'] = 0x25E6;
  8629. t['option'] = 0x2325;
  8630. t['ordfeminine'] = 0x00AA;
  8631. t['ordmasculine'] = 0x00BA;
  8632. t['orthogonal'] = 0x221F;
  8633. t['oshortdeva'] = 0x0912;
  8634. t['oshortvowelsigndeva'] = 0x094A;
  8635. t['oslash'] = 0x00F8;
  8636. t['oslashacute'] = 0x01FF;
  8637. t['osmallhiragana'] = 0x3049;
  8638. t['osmallkatakana'] = 0x30A9;
  8639. t['osmallkatakanahalfwidth'] = 0xFF6B;
  8640. t['ostrokeacute'] = 0x01FF;
  8641. t['osuperior'] = 0xF6F0;
  8642. t['otcyrillic'] = 0x047F;
  8643. t['otilde'] = 0x00F5;
  8644. t['otildeacute'] = 0x1E4D;
  8645. t['otildedieresis'] = 0x1E4F;
  8646. t['oubopomofo'] = 0x3121;
  8647. t['overline'] = 0x203E;
  8648. t['overlinecenterline'] = 0xFE4A;
  8649. t['overlinecmb'] = 0x0305;
  8650. t['overlinedashed'] = 0xFE49;
  8651. t['overlinedblwavy'] = 0xFE4C;
  8652. t['overlinewavy'] = 0xFE4B;
  8653. t['overscore'] = 0x00AF;
  8654. t['ovowelsignbengali'] = 0x09CB;
  8655. t['ovowelsigndeva'] = 0x094B;
  8656. t['ovowelsigngujarati'] = 0x0ACB;
  8657. t['p'] = 0x0070;
  8658. t['paampssquare'] = 0x3380;
  8659. t['paasentosquare'] = 0x332B;
  8660. t['pabengali'] = 0x09AA;
  8661. t['pacute'] = 0x1E55;
  8662. t['padeva'] = 0x092A;
  8663. t['pagedown'] = 0x21DF;
  8664. t['pageup'] = 0x21DE;
  8665. t['pagujarati'] = 0x0AAA;
  8666. t['pagurmukhi'] = 0x0A2A;
  8667. t['pahiragana'] = 0x3071;
  8668. t['paiyannoithai'] = 0x0E2F;
  8669. t['pakatakana'] = 0x30D1;
  8670. t['palatalizationcyrilliccmb'] = 0x0484;
  8671. t['palochkacyrillic'] = 0x04C0;
  8672. t['pansioskorean'] = 0x317F;
  8673. t['paragraph'] = 0x00B6;
  8674. t['parallel'] = 0x2225;
  8675. t['parenleft'] = 0x0028;
  8676. t['parenleftaltonearabic'] = 0xFD3E;
  8677. t['parenleftbt'] = 0xF8ED;
  8678. t['parenleftex'] = 0xF8EC;
  8679. t['parenleftinferior'] = 0x208D;
  8680. t['parenleftmonospace'] = 0xFF08;
  8681. t['parenleftsmall'] = 0xFE59;
  8682. t['parenleftsuperior'] = 0x207D;
  8683. t['parenlefttp'] = 0xF8EB;
  8684. t['parenleftvertical'] = 0xFE35;
  8685. t['parenright'] = 0x0029;
  8686. t['parenrightaltonearabic'] = 0xFD3F;
  8687. t['parenrightbt'] = 0xF8F8;
  8688. t['parenrightex'] = 0xF8F7;
  8689. t['parenrightinferior'] = 0x208E;
  8690. t['parenrightmonospace'] = 0xFF09;
  8691. t['parenrightsmall'] = 0xFE5A;
  8692. t['parenrightsuperior'] = 0x207E;
  8693. t['parenrighttp'] = 0xF8F6;
  8694. t['parenrightvertical'] = 0xFE36;
  8695. t['partialdiff'] = 0x2202;
  8696. t['paseqhebrew'] = 0x05C0;
  8697. t['pashtahebrew'] = 0x0599;
  8698. t['pasquare'] = 0x33A9;
  8699. t['patah'] = 0x05B7;
  8700. t['patah11'] = 0x05B7;
  8701. t['patah1d'] = 0x05B7;
  8702. t['patah2a'] = 0x05B7;
  8703. t['patahhebrew'] = 0x05B7;
  8704. t['patahnarrowhebrew'] = 0x05B7;
  8705. t['patahquarterhebrew'] = 0x05B7;
  8706. t['patahwidehebrew'] = 0x05B7;
  8707. t['pazerhebrew'] = 0x05A1;
  8708. t['pbopomofo'] = 0x3106;
  8709. t['pcircle'] = 0x24DF;
  8710. t['pdotaccent'] = 0x1E57;
  8711. t['pe'] = 0x05E4;
  8712. t['pecyrillic'] = 0x043F;
  8713. t['pedagesh'] = 0xFB44;
  8714. t['pedageshhebrew'] = 0xFB44;
  8715. t['peezisquare'] = 0x333B;
  8716. t['pefinaldageshhebrew'] = 0xFB43;
  8717. t['peharabic'] = 0x067E;
  8718. t['peharmenian'] = 0x057A;
  8719. t['pehebrew'] = 0x05E4;
  8720. t['pehfinalarabic'] = 0xFB57;
  8721. t['pehinitialarabic'] = 0xFB58;
  8722. t['pehiragana'] = 0x307A;
  8723. t['pehmedialarabic'] = 0xFB59;
  8724. t['pekatakana'] = 0x30DA;
  8725. t['pemiddlehookcyrillic'] = 0x04A7;
  8726. t['perafehebrew'] = 0xFB4E;
  8727. t['percent'] = 0x0025;
  8728. t['percentarabic'] = 0x066A;
  8729. t['percentmonospace'] = 0xFF05;
  8730. t['percentsmall'] = 0xFE6A;
  8731. t['period'] = 0x002E;
  8732. t['periodarmenian'] = 0x0589;
  8733. t['periodcentered'] = 0x00B7;
  8734. t['periodhalfwidth'] = 0xFF61;
  8735. t['periodinferior'] = 0xF6E7;
  8736. t['periodmonospace'] = 0xFF0E;
  8737. t['periodsmall'] = 0xFE52;
  8738. t['periodsuperior'] = 0xF6E8;
  8739. t['perispomenigreekcmb'] = 0x0342;
  8740. t['perpendicular'] = 0x22A5;
  8741. t['perthousand'] = 0x2030;
  8742. t['peseta'] = 0x20A7;
  8743. t['pfsquare'] = 0x338A;
  8744. t['phabengali'] = 0x09AB;
  8745. t['phadeva'] = 0x092B;
  8746. t['phagujarati'] = 0x0AAB;
  8747. t['phagurmukhi'] = 0x0A2B;
  8748. t['phi'] = 0x03C6;
  8749. t['phi1'] = 0x03D5;
  8750. t['phieuphacirclekorean'] = 0x327A;
  8751. t['phieuphaparenkorean'] = 0x321A;
  8752. t['phieuphcirclekorean'] = 0x326C;
  8753. t['phieuphkorean'] = 0x314D;
  8754. t['phieuphparenkorean'] = 0x320C;
  8755. t['philatin'] = 0x0278;
  8756. t['phinthuthai'] = 0x0E3A;
  8757. t['phisymbolgreek'] = 0x03D5;
  8758. t['phook'] = 0x01A5;
  8759. t['phophanthai'] = 0x0E1E;
  8760. t['phophungthai'] = 0x0E1C;
  8761. t['phosamphaothai'] = 0x0E20;
  8762. t['pi'] = 0x03C0;
  8763. t['pieupacirclekorean'] = 0x3273;
  8764. t['pieupaparenkorean'] = 0x3213;
  8765. t['pieupcieuckorean'] = 0x3176;
  8766. t['pieupcirclekorean'] = 0x3265;
  8767. t['pieupkiyeokkorean'] = 0x3172;
  8768. t['pieupkorean'] = 0x3142;
  8769. t['pieupparenkorean'] = 0x3205;
  8770. t['pieupsioskiyeokkorean'] = 0x3174;
  8771. t['pieupsioskorean'] = 0x3144;
  8772. t['pieupsiostikeutkorean'] = 0x3175;
  8773. t['pieupthieuthkorean'] = 0x3177;
  8774. t['pieuptikeutkorean'] = 0x3173;
  8775. t['pihiragana'] = 0x3074;
  8776. t['pikatakana'] = 0x30D4;
  8777. t['pisymbolgreek'] = 0x03D6;
  8778. t['piwrarmenian'] = 0x0583;
  8779. t['plus'] = 0x002B;
  8780. t['plusbelowcmb'] = 0x031F;
  8781. t['pluscircle'] = 0x2295;
  8782. t['plusminus'] = 0x00B1;
  8783. t['plusmod'] = 0x02D6;
  8784. t['plusmonospace'] = 0xFF0B;
  8785. t['plussmall'] = 0xFE62;
  8786. t['plussuperior'] = 0x207A;
  8787. t['pmonospace'] = 0xFF50;
  8788. t['pmsquare'] = 0x33D8;
  8789. t['pohiragana'] = 0x307D;
  8790. t['pointingindexdownwhite'] = 0x261F;
  8791. t['pointingindexleftwhite'] = 0x261C;
  8792. t['pointingindexrightwhite'] = 0x261E;
  8793. t['pointingindexupwhite'] = 0x261D;
  8794. t['pokatakana'] = 0x30DD;
  8795. t['poplathai'] = 0x0E1B;
  8796. t['postalmark'] = 0x3012;
  8797. t['postalmarkface'] = 0x3020;
  8798. t['pparen'] = 0x24AB;
  8799. t['precedes'] = 0x227A;
  8800. t['prescription'] = 0x211E;
  8801. t['primemod'] = 0x02B9;
  8802. t['primereversed'] = 0x2035;
  8803. t['product'] = 0x220F;
  8804. t['projective'] = 0x2305;
  8805. t['prolongedkana'] = 0x30FC;
  8806. t['propellor'] = 0x2318;
  8807. t['propersubset'] = 0x2282;
  8808. t['propersuperset'] = 0x2283;
  8809. t['proportion'] = 0x2237;
  8810. t['proportional'] = 0x221D;
  8811. t['psi'] = 0x03C8;
  8812. t['psicyrillic'] = 0x0471;
  8813. t['psilipneumatacyrilliccmb'] = 0x0486;
  8814. t['pssquare'] = 0x33B0;
  8815. t['puhiragana'] = 0x3077;
  8816. t['pukatakana'] = 0x30D7;
  8817. t['pvsquare'] = 0x33B4;
  8818. t['pwsquare'] = 0x33BA;
  8819. t['q'] = 0x0071;
  8820. t['qadeva'] = 0x0958;
  8821. t['qadmahebrew'] = 0x05A8;
  8822. t['qafarabic'] = 0x0642;
  8823. t['qaffinalarabic'] = 0xFED6;
  8824. t['qafinitialarabic'] = 0xFED7;
  8825. t['qafmedialarabic'] = 0xFED8;
  8826. t['qamats'] = 0x05B8;
  8827. t['qamats10'] = 0x05B8;
  8828. t['qamats1a'] = 0x05B8;
  8829. t['qamats1c'] = 0x05B8;
  8830. t['qamats27'] = 0x05B8;
  8831. t['qamats29'] = 0x05B8;
  8832. t['qamats33'] = 0x05B8;
  8833. t['qamatsde'] = 0x05B8;
  8834. t['qamatshebrew'] = 0x05B8;
  8835. t['qamatsnarrowhebrew'] = 0x05B8;
  8836. t['qamatsqatanhebrew'] = 0x05B8;
  8837. t['qamatsqatannarrowhebrew'] = 0x05B8;
  8838. t['qamatsqatanquarterhebrew'] = 0x05B8;
  8839. t['qamatsqatanwidehebrew'] = 0x05B8;
  8840. t['qamatsquarterhebrew'] = 0x05B8;
  8841. t['qamatswidehebrew'] = 0x05B8;
  8842. t['qarneyparahebrew'] = 0x059F;
  8843. t['qbopomofo'] = 0x3111;
  8844. t['qcircle'] = 0x24E0;
  8845. t['qhook'] = 0x02A0;
  8846. t['qmonospace'] = 0xFF51;
  8847. t['qof'] = 0x05E7;
  8848. t['qofdagesh'] = 0xFB47;
  8849. t['qofdageshhebrew'] = 0xFB47;
  8850. t['qofhebrew'] = 0x05E7;
  8851. t['qparen'] = 0x24AC;
  8852. t['quarternote'] = 0x2669;
  8853. t['qubuts'] = 0x05BB;
  8854. t['qubuts18'] = 0x05BB;
  8855. t['qubuts25'] = 0x05BB;
  8856. t['qubuts31'] = 0x05BB;
  8857. t['qubutshebrew'] = 0x05BB;
  8858. t['qubutsnarrowhebrew'] = 0x05BB;
  8859. t['qubutsquarterhebrew'] = 0x05BB;
  8860. t['qubutswidehebrew'] = 0x05BB;
  8861. t['question'] = 0x003F;
  8862. t['questionarabic'] = 0x061F;
  8863. t['questionarmenian'] = 0x055E;
  8864. t['questiondown'] = 0x00BF;
  8865. t['questiondownsmall'] = 0xF7BF;
  8866. t['questiongreek'] = 0x037E;
  8867. t['questionmonospace'] = 0xFF1F;
  8868. t['questionsmall'] = 0xF73F;
  8869. t['quotedbl'] = 0x0022;
  8870. t['quotedblbase'] = 0x201E;
  8871. t['quotedblleft'] = 0x201C;
  8872. t['quotedblmonospace'] = 0xFF02;
  8873. t['quotedblprime'] = 0x301E;
  8874. t['quotedblprimereversed'] = 0x301D;
  8875. t['quotedblright'] = 0x201D;
  8876. t['quoteleft'] = 0x2018;
  8877. t['quoteleftreversed'] = 0x201B;
  8878. t['quotereversed'] = 0x201B;
  8879. t['quoteright'] = 0x2019;
  8880. t['quoterightn'] = 0x0149;
  8881. t['quotesinglbase'] = 0x201A;
  8882. t['quotesingle'] = 0x0027;
  8883. t['quotesinglemonospace'] = 0xFF07;
  8884. t['r'] = 0x0072;
  8885. t['raarmenian'] = 0x057C;
  8886. t['rabengali'] = 0x09B0;
  8887. t['racute'] = 0x0155;
  8888. t['radeva'] = 0x0930;
  8889. t['radical'] = 0x221A;
  8890. t['radicalex'] = 0xF8E5;
  8891. t['radoverssquare'] = 0x33AE;
  8892. t['radoverssquaredsquare'] = 0x33AF;
  8893. t['radsquare'] = 0x33AD;
  8894. t['rafe'] = 0x05BF;
  8895. t['rafehebrew'] = 0x05BF;
  8896. t['ragujarati'] = 0x0AB0;
  8897. t['ragurmukhi'] = 0x0A30;
  8898. t['rahiragana'] = 0x3089;
  8899. t['rakatakana'] = 0x30E9;
  8900. t['rakatakanahalfwidth'] = 0xFF97;
  8901. t['ralowerdiagonalbengali'] = 0x09F1;
  8902. t['ramiddlediagonalbengali'] = 0x09F0;
  8903. t['ramshorn'] = 0x0264;
  8904. t['ratio'] = 0x2236;
  8905. t['rbopomofo'] = 0x3116;
  8906. t['rcaron'] = 0x0159;
  8907. t['rcedilla'] = 0x0157;
  8908. t['rcircle'] = 0x24E1;
  8909. t['rcommaaccent'] = 0x0157;
  8910. t['rdblgrave'] = 0x0211;
  8911. t['rdotaccent'] = 0x1E59;
  8912. t['rdotbelow'] = 0x1E5B;
  8913. t['rdotbelowmacron'] = 0x1E5D;
  8914. t['referencemark'] = 0x203B;
  8915. t['reflexsubset'] = 0x2286;
  8916. t['reflexsuperset'] = 0x2287;
  8917. t['registered'] = 0x00AE;
  8918. t['registersans'] = 0xF8E8;
  8919. t['registerserif'] = 0xF6DA;
  8920. t['reharabic'] = 0x0631;
  8921. t['reharmenian'] = 0x0580;
  8922. t['rehfinalarabic'] = 0xFEAE;
  8923. t['rehiragana'] = 0x308C;
  8924. t['rekatakana'] = 0x30EC;
  8925. t['rekatakanahalfwidth'] = 0xFF9A;
  8926. t['resh'] = 0x05E8;
  8927. t['reshdageshhebrew'] = 0xFB48;
  8928. t['reshhebrew'] = 0x05E8;
  8929. t['reversedtilde'] = 0x223D;
  8930. t['reviahebrew'] = 0x0597;
  8931. t['reviamugrashhebrew'] = 0x0597;
  8932. t['revlogicalnot'] = 0x2310;
  8933. t['rfishhook'] = 0x027E;
  8934. t['rfishhookreversed'] = 0x027F;
  8935. t['rhabengali'] = 0x09DD;
  8936. t['rhadeva'] = 0x095D;
  8937. t['rho'] = 0x03C1;
  8938. t['rhook'] = 0x027D;
  8939. t['rhookturned'] = 0x027B;
  8940. t['rhookturnedsuperior'] = 0x02B5;
  8941. t['rhosymbolgreek'] = 0x03F1;
  8942. t['rhotichookmod'] = 0x02DE;
  8943. t['rieulacirclekorean'] = 0x3271;
  8944. t['rieulaparenkorean'] = 0x3211;
  8945. t['rieulcirclekorean'] = 0x3263;
  8946. t['rieulhieuhkorean'] = 0x3140;
  8947. t['rieulkiyeokkorean'] = 0x313A;
  8948. t['rieulkiyeoksioskorean'] = 0x3169;
  8949. t['rieulkorean'] = 0x3139;
  8950. t['rieulmieumkorean'] = 0x313B;
  8951. t['rieulpansioskorean'] = 0x316C;
  8952. t['rieulparenkorean'] = 0x3203;
  8953. t['rieulphieuphkorean'] = 0x313F;
  8954. t['rieulpieupkorean'] = 0x313C;
  8955. t['rieulpieupsioskorean'] = 0x316B;
  8956. t['rieulsioskorean'] = 0x313D;
  8957. t['rieulthieuthkorean'] = 0x313E;
  8958. t['rieultikeutkorean'] = 0x316A;
  8959. t['rieulyeorinhieuhkorean'] = 0x316D;
  8960. t['rightangle'] = 0x221F;
  8961. t['righttackbelowcmb'] = 0x0319;
  8962. t['righttriangle'] = 0x22BF;
  8963. t['rihiragana'] = 0x308A;
  8964. t['rikatakana'] = 0x30EA;
  8965. t['rikatakanahalfwidth'] = 0xFF98;
  8966. t['ring'] = 0x02DA;
  8967. t['ringbelowcmb'] = 0x0325;
  8968. t['ringcmb'] = 0x030A;
  8969. t['ringhalfleft'] = 0x02BF;
  8970. t['ringhalfleftarmenian'] = 0x0559;
  8971. t['ringhalfleftbelowcmb'] = 0x031C;
  8972. t['ringhalfleftcentered'] = 0x02D3;
  8973. t['ringhalfright'] = 0x02BE;
  8974. t['ringhalfrightbelowcmb'] = 0x0339;
  8975. t['ringhalfrightcentered'] = 0x02D2;
  8976. t['rinvertedbreve'] = 0x0213;
  8977. t['rittorusquare'] = 0x3351;
  8978. t['rlinebelow'] = 0x1E5F;
  8979. t['rlongleg'] = 0x027C;
  8980. t['rlonglegturned'] = 0x027A;
  8981. t['rmonospace'] = 0xFF52;
  8982. t['rohiragana'] = 0x308D;
  8983. t['rokatakana'] = 0x30ED;
  8984. t['rokatakanahalfwidth'] = 0xFF9B;
  8985. t['roruathai'] = 0x0E23;
  8986. t['rparen'] = 0x24AD;
  8987. t['rrabengali'] = 0x09DC;
  8988. t['rradeva'] = 0x0931;
  8989. t['rragurmukhi'] = 0x0A5C;
  8990. t['rreharabic'] = 0x0691;
  8991. t['rrehfinalarabic'] = 0xFB8D;
  8992. t['rrvocalicbengali'] = 0x09E0;
  8993. t['rrvocalicdeva'] = 0x0960;
  8994. t['rrvocalicgujarati'] = 0x0AE0;
  8995. t['rrvocalicvowelsignbengali'] = 0x09C4;
  8996. t['rrvocalicvowelsigndeva'] = 0x0944;
  8997. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  8998. t['rsuperior'] = 0xF6F1;
  8999. t['rtblock'] = 0x2590;
  9000. t['rturned'] = 0x0279;
  9001. t['rturnedsuperior'] = 0x02B4;
  9002. t['ruhiragana'] = 0x308B;
  9003. t['rukatakana'] = 0x30EB;
  9004. t['rukatakanahalfwidth'] = 0xFF99;
  9005. t['rupeemarkbengali'] = 0x09F2;
  9006. t['rupeesignbengali'] = 0x09F3;
  9007. t['rupiah'] = 0xF6DD;
  9008. t['ruthai'] = 0x0E24;
  9009. t['rvocalicbengali'] = 0x098B;
  9010. t['rvocalicdeva'] = 0x090B;
  9011. t['rvocalicgujarati'] = 0x0A8B;
  9012. t['rvocalicvowelsignbengali'] = 0x09C3;
  9013. t['rvocalicvowelsigndeva'] = 0x0943;
  9014. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  9015. t['s'] = 0x0073;
  9016. t['sabengali'] = 0x09B8;
  9017. t['sacute'] = 0x015B;
  9018. t['sacutedotaccent'] = 0x1E65;
  9019. t['sadarabic'] = 0x0635;
  9020. t['sadeva'] = 0x0938;
  9021. t['sadfinalarabic'] = 0xFEBA;
  9022. t['sadinitialarabic'] = 0xFEBB;
  9023. t['sadmedialarabic'] = 0xFEBC;
  9024. t['sagujarati'] = 0x0AB8;
  9025. t['sagurmukhi'] = 0x0A38;
  9026. t['sahiragana'] = 0x3055;
  9027. t['sakatakana'] = 0x30B5;
  9028. t['sakatakanahalfwidth'] = 0xFF7B;
  9029. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  9030. t['samekh'] = 0x05E1;
  9031. t['samekhdagesh'] = 0xFB41;
  9032. t['samekhdageshhebrew'] = 0xFB41;
  9033. t['samekhhebrew'] = 0x05E1;
  9034. t['saraaathai'] = 0x0E32;
  9035. t['saraaethai'] = 0x0E41;
  9036. t['saraaimaimalaithai'] = 0x0E44;
  9037. t['saraaimaimuanthai'] = 0x0E43;
  9038. t['saraamthai'] = 0x0E33;
  9039. t['saraathai'] = 0x0E30;
  9040. t['saraethai'] = 0x0E40;
  9041. t['saraiileftthai'] = 0xF886;
  9042. t['saraiithai'] = 0x0E35;
  9043. t['saraileftthai'] = 0xF885;
  9044. t['saraithai'] = 0x0E34;
  9045. t['saraothai'] = 0x0E42;
  9046. t['saraueeleftthai'] = 0xF888;
  9047. t['saraueethai'] = 0x0E37;
  9048. t['saraueleftthai'] = 0xF887;
  9049. t['sarauethai'] = 0x0E36;
  9050. t['sarauthai'] = 0x0E38;
  9051. t['sarauuthai'] = 0x0E39;
  9052. t['sbopomofo'] = 0x3119;
  9053. t['scaron'] = 0x0161;
  9054. t['scarondotaccent'] = 0x1E67;
  9055. t['scedilla'] = 0x015F;
  9056. t['schwa'] = 0x0259;
  9057. t['schwacyrillic'] = 0x04D9;
  9058. t['schwadieresiscyrillic'] = 0x04DB;
  9059. t['schwahook'] = 0x025A;
  9060. t['scircle'] = 0x24E2;
  9061. t['scircumflex'] = 0x015D;
  9062. t['scommaaccent'] = 0x0219;
  9063. t['sdotaccent'] = 0x1E61;
  9064. t['sdotbelow'] = 0x1E63;
  9065. t['sdotbelowdotaccent'] = 0x1E69;
  9066. t['seagullbelowcmb'] = 0x033C;
  9067. t['second'] = 0x2033;
  9068. t['secondtonechinese'] = 0x02CA;
  9069. t['section'] = 0x00A7;
  9070. t['seenarabic'] = 0x0633;
  9071. t['seenfinalarabic'] = 0xFEB2;
  9072. t['seeninitialarabic'] = 0xFEB3;
  9073. t['seenmedialarabic'] = 0xFEB4;
  9074. t['segol'] = 0x05B6;
  9075. t['segol13'] = 0x05B6;
  9076. t['segol1f'] = 0x05B6;
  9077. t['segol2c'] = 0x05B6;
  9078. t['segolhebrew'] = 0x05B6;
  9079. t['segolnarrowhebrew'] = 0x05B6;
  9080. t['segolquarterhebrew'] = 0x05B6;
  9081. t['segoltahebrew'] = 0x0592;
  9082. t['segolwidehebrew'] = 0x05B6;
  9083. t['seharmenian'] = 0x057D;
  9084. t['sehiragana'] = 0x305B;
  9085. t['sekatakana'] = 0x30BB;
  9086. t['sekatakanahalfwidth'] = 0xFF7E;
  9087. t['semicolon'] = 0x003B;
  9088. t['semicolonarabic'] = 0x061B;
  9089. t['semicolonmonospace'] = 0xFF1B;
  9090. t['semicolonsmall'] = 0xFE54;
  9091. t['semivoicedmarkkana'] = 0x309C;
  9092. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  9093. t['sentisquare'] = 0x3322;
  9094. t['sentosquare'] = 0x3323;
  9095. t['seven'] = 0x0037;
  9096. t['sevenarabic'] = 0x0667;
  9097. t['sevenbengali'] = 0x09ED;
  9098. t['sevencircle'] = 0x2466;
  9099. t['sevencircleinversesansserif'] = 0x2790;
  9100. t['sevendeva'] = 0x096D;
  9101. t['seveneighths'] = 0x215E;
  9102. t['sevengujarati'] = 0x0AED;
  9103. t['sevengurmukhi'] = 0x0A6D;
  9104. t['sevenhackarabic'] = 0x0667;
  9105. t['sevenhangzhou'] = 0x3027;
  9106. t['sevenideographicparen'] = 0x3226;
  9107. t['seveninferior'] = 0x2087;
  9108. t['sevenmonospace'] = 0xFF17;
  9109. t['sevenoldstyle'] = 0xF737;
  9110. t['sevenparen'] = 0x247A;
  9111. t['sevenperiod'] = 0x248E;
  9112. t['sevenpersian'] = 0x06F7;
  9113. t['sevenroman'] = 0x2176;
  9114. t['sevensuperior'] = 0x2077;
  9115. t['seventeencircle'] = 0x2470;
  9116. t['seventeenparen'] = 0x2484;
  9117. t['seventeenperiod'] = 0x2498;
  9118. t['seventhai'] = 0x0E57;
  9119. t['sfthyphen'] = 0x00AD;
  9120. t['shaarmenian'] = 0x0577;
  9121. t['shabengali'] = 0x09B6;
  9122. t['shacyrillic'] = 0x0448;
  9123. t['shaddaarabic'] = 0x0651;
  9124. t['shaddadammaarabic'] = 0xFC61;
  9125. t['shaddadammatanarabic'] = 0xFC5E;
  9126. t['shaddafathaarabic'] = 0xFC60;
  9127. t['shaddakasraarabic'] = 0xFC62;
  9128. t['shaddakasratanarabic'] = 0xFC5F;
  9129. t['shade'] = 0x2592;
  9130. t['shadedark'] = 0x2593;
  9131. t['shadelight'] = 0x2591;
  9132. t['shademedium'] = 0x2592;
  9133. t['shadeva'] = 0x0936;
  9134. t['shagujarati'] = 0x0AB6;
  9135. t['shagurmukhi'] = 0x0A36;
  9136. t['shalshelethebrew'] = 0x0593;
  9137. t['shbopomofo'] = 0x3115;
  9138. t['shchacyrillic'] = 0x0449;
  9139. t['sheenarabic'] = 0x0634;
  9140. t['sheenfinalarabic'] = 0xFEB6;
  9141. t['sheeninitialarabic'] = 0xFEB7;
  9142. t['sheenmedialarabic'] = 0xFEB8;
  9143. t['sheicoptic'] = 0x03E3;
  9144. t['sheqel'] = 0x20AA;
  9145. t['sheqelhebrew'] = 0x20AA;
  9146. t['sheva'] = 0x05B0;
  9147. t['sheva115'] = 0x05B0;
  9148. t['sheva15'] = 0x05B0;
  9149. t['sheva22'] = 0x05B0;
  9150. t['sheva2e'] = 0x05B0;
  9151. t['shevahebrew'] = 0x05B0;
  9152. t['shevanarrowhebrew'] = 0x05B0;
  9153. t['shevaquarterhebrew'] = 0x05B0;
  9154. t['shevawidehebrew'] = 0x05B0;
  9155. t['shhacyrillic'] = 0x04BB;
  9156. t['shimacoptic'] = 0x03ED;
  9157. t['shin'] = 0x05E9;
  9158. t['shindagesh'] = 0xFB49;
  9159. t['shindageshhebrew'] = 0xFB49;
  9160. t['shindageshshindot'] = 0xFB2C;
  9161. t['shindageshshindothebrew'] = 0xFB2C;
  9162. t['shindageshsindot'] = 0xFB2D;
  9163. t['shindageshsindothebrew'] = 0xFB2D;
  9164. t['shindothebrew'] = 0x05C1;
  9165. t['shinhebrew'] = 0x05E9;
  9166. t['shinshindot'] = 0xFB2A;
  9167. t['shinshindothebrew'] = 0xFB2A;
  9168. t['shinsindot'] = 0xFB2B;
  9169. t['shinsindothebrew'] = 0xFB2B;
  9170. t['shook'] = 0x0282;
  9171. t['sigma'] = 0x03C3;
  9172. t['sigma1'] = 0x03C2;
  9173. t['sigmafinal'] = 0x03C2;
  9174. t['sigmalunatesymbolgreek'] = 0x03F2;
  9175. t['sihiragana'] = 0x3057;
  9176. t['sikatakana'] = 0x30B7;
  9177. t['sikatakanahalfwidth'] = 0xFF7C;
  9178. t['siluqhebrew'] = 0x05BD;
  9179. t['siluqlefthebrew'] = 0x05BD;
  9180. t['similar'] = 0x223C;
  9181. t['sindothebrew'] = 0x05C2;
  9182. t['siosacirclekorean'] = 0x3274;
  9183. t['siosaparenkorean'] = 0x3214;
  9184. t['sioscieuckorean'] = 0x317E;
  9185. t['sioscirclekorean'] = 0x3266;
  9186. t['sioskiyeokkorean'] = 0x317A;
  9187. t['sioskorean'] = 0x3145;
  9188. t['siosnieunkorean'] = 0x317B;
  9189. t['siosparenkorean'] = 0x3206;
  9190. t['siospieupkorean'] = 0x317D;
  9191. t['siostikeutkorean'] = 0x317C;
  9192. t['six'] = 0x0036;
  9193. t['sixarabic'] = 0x0666;
  9194. t['sixbengali'] = 0x09EC;
  9195. t['sixcircle'] = 0x2465;
  9196. t['sixcircleinversesansserif'] = 0x278F;
  9197. t['sixdeva'] = 0x096C;
  9198. t['sixgujarati'] = 0x0AEC;
  9199. t['sixgurmukhi'] = 0x0A6C;
  9200. t['sixhackarabic'] = 0x0666;
  9201. t['sixhangzhou'] = 0x3026;
  9202. t['sixideographicparen'] = 0x3225;
  9203. t['sixinferior'] = 0x2086;
  9204. t['sixmonospace'] = 0xFF16;
  9205. t['sixoldstyle'] = 0xF736;
  9206. t['sixparen'] = 0x2479;
  9207. t['sixperiod'] = 0x248D;
  9208. t['sixpersian'] = 0x06F6;
  9209. t['sixroman'] = 0x2175;
  9210. t['sixsuperior'] = 0x2076;
  9211. t['sixteencircle'] = 0x246F;
  9212. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  9213. t['sixteenparen'] = 0x2483;
  9214. t['sixteenperiod'] = 0x2497;
  9215. t['sixthai'] = 0x0E56;
  9216. t['slash'] = 0x002F;
  9217. t['slashmonospace'] = 0xFF0F;
  9218. t['slong'] = 0x017F;
  9219. t['slongdotaccent'] = 0x1E9B;
  9220. t['smileface'] = 0x263A;
  9221. t['smonospace'] = 0xFF53;
  9222. t['sofpasuqhebrew'] = 0x05C3;
  9223. t['softhyphen'] = 0x00AD;
  9224. t['softsigncyrillic'] = 0x044C;
  9225. t['sohiragana'] = 0x305D;
  9226. t['sokatakana'] = 0x30BD;
  9227. t['sokatakanahalfwidth'] = 0xFF7F;
  9228. t['soliduslongoverlaycmb'] = 0x0338;
  9229. t['solidusshortoverlaycmb'] = 0x0337;
  9230. t['sorusithai'] = 0x0E29;
  9231. t['sosalathai'] = 0x0E28;
  9232. t['sosothai'] = 0x0E0B;
  9233. t['sosuathai'] = 0x0E2A;
  9234. t['space'] = 0x0020;
  9235. t['spacehackarabic'] = 0x0020;
  9236. t['spade'] = 0x2660;
  9237. t['spadesuitblack'] = 0x2660;
  9238. t['spadesuitwhite'] = 0x2664;
  9239. t['sparen'] = 0x24AE;
  9240. t['squarebelowcmb'] = 0x033B;
  9241. t['squarecc'] = 0x33C4;
  9242. t['squarecm'] = 0x339D;
  9243. t['squarediagonalcrosshatchfill'] = 0x25A9;
  9244. t['squarehorizontalfill'] = 0x25A4;
  9245. t['squarekg'] = 0x338F;
  9246. t['squarekm'] = 0x339E;
  9247. t['squarekmcapital'] = 0x33CE;
  9248. t['squareln'] = 0x33D1;
  9249. t['squarelog'] = 0x33D2;
  9250. t['squaremg'] = 0x338E;
  9251. t['squaremil'] = 0x33D5;
  9252. t['squaremm'] = 0x339C;
  9253. t['squaremsquared'] = 0x33A1;
  9254. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  9255. t['squareupperlefttolowerrightfill'] = 0x25A7;
  9256. t['squareupperrighttolowerleftfill'] = 0x25A8;
  9257. t['squareverticalfill'] = 0x25A5;
  9258. t['squarewhitewithsmallblack'] = 0x25A3;
  9259. t['srsquare'] = 0x33DB;
  9260. t['ssabengali'] = 0x09B7;
  9261. t['ssadeva'] = 0x0937;
  9262. t['ssagujarati'] = 0x0AB7;
  9263. t['ssangcieuckorean'] = 0x3149;
  9264. t['ssanghieuhkorean'] = 0x3185;
  9265. t['ssangieungkorean'] = 0x3180;
  9266. t['ssangkiyeokkorean'] = 0x3132;
  9267. t['ssangnieunkorean'] = 0x3165;
  9268. t['ssangpieupkorean'] = 0x3143;
  9269. t['ssangsioskorean'] = 0x3146;
  9270. t['ssangtikeutkorean'] = 0x3138;
  9271. t['ssuperior'] = 0xF6F2;
  9272. t['sterling'] = 0x00A3;
  9273. t['sterlingmonospace'] = 0xFFE1;
  9274. t['strokelongoverlaycmb'] = 0x0336;
  9275. t['strokeshortoverlaycmb'] = 0x0335;
  9276. t['subset'] = 0x2282;
  9277. t['subsetnotequal'] = 0x228A;
  9278. t['subsetorequal'] = 0x2286;
  9279. t['succeeds'] = 0x227B;
  9280. t['suchthat'] = 0x220B;
  9281. t['suhiragana'] = 0x3059;
  9282. t['sukatakana'] = 0x30B9;
  9283. t['sukatakanahalfwidth'] = 0xFF7D;
  9284. t['sukunarabic'] = 0x0652;
  9285. t['summation'] = 0x2211;
  9286. t['sun'] = 0x263C;
  9287. t['superset'] = 0x2283;
  9288. t['supersetnotequal'] = 0x228B;
  9289. t['supersetorequal'] = 0x2287;
  9290. t['svsquare'] = 0x33DC;
  9291. t['syouwaerasquare'] = 0x337C;
  9292. t['t'] = 0x0074;
  9293. t['tabengali'] = 0x09A4;
  9294. t['tackdown'] = 0x22A4;
  9295. t['tackleft'] = 0x22A3;
  9296. t['tadeva'] = 0x0924;
  9297. t['tagujarati'] = 0x0AA4;
  9298. t['tagurmukhi'] = 0x0A24;
  9299. t['taharabic'] = 0x0637;
  9300. t['tahfinalarabic'] = 0xFEC2;
  9301. t['tahinitialarabic'] = 0xFEC3;
  9302. t['tahiragana'] = 0x305F;
  9303. t['tahmedialarabic'] = 0xFEC4;
  9304. t['taisyouerasquare'] = 0x337D;
  9305. t['takatakana'] = 0x30BF;
  9306. t['takatakanahalfwidth'] = 0xFF80;
  9307. t['tatweelarabic'] = 0x0640;
  9308. t['tau'] = 0x03C4;
  9309. t['tav'] = 0x05EA;
  9310. t['tavdages'] = 0xFB4A;
  9311. t['tavdagesh'] = 0xFB4A;
  9312. t['tavdageshhebrew'] = 0xFB4A;
  9313. t['tavhebrew'] = 0x05EA;
  9314. t['tbar'] = 0x0167;
  9315. t['tbopomofo'] = 0x310A;
  9316. t['tcaron'] = 0x0165;
  9317. t['tccurl'] = 0x02A8;
  9318. t['tcedilla'] = 0x0163;
  9319. t['tcheharabic'] = 0x0686;
  9320. t['tchehfinalarabic'] = 0xFB7B;
  9321. t['tchehinitialarabic'] = 0xFB7C;
  9322. t['tchehmedialarabic'] = 0xFB7D;
  9323. t['tcircle'] = 0x24E3;
  9324. t['tcircumflexbelow'] = 0x1E71;
  9325. t['tcommaaccent'] = 0x0163;
  9326. t['tdieresis'] = 0x1E97;
  9327. t['tdotaccent'] = 0x1E6B;
  9328. t['tdotbelow'] = 0x1E6D;
  9329. t['tecyrillic'] = 0x0442;
  9330. t['tedescendercyrillic'] = 0x04AD;
  9331. t['teharabic'] = 0x062A;
  9332. t['tehfinalarabic'] = 0xFE96;
  9333. t['tehhahinitialarabic'] = 0xFCA2;
  9334. t['tehhahisolatedarabic'] = 0xFC0C;
  9335. t['tehinitialarabic'] = 0xFE97;
  9336. t['tehiragana'] = 0x3066;
  9337. t['tehjeeminitialarabic'] = 0xFCA1;
  9338. t['tehjeemisolatedarabic'] = 0xFC0B;
  9339. t['tehmarbutaarabic'] = 0x0629;
  9340. t['tehmarbutafinalarabic'] = 0xFE94;
  9341. t['tehmedialarabic'] = 0xFE98;
  9342. t['tehmeeminitialarabic'] = 0xFCA4;
  9343. t['tehmeemisolatedarabic'] = 0xFC0E;
  9344. t['tehnoonfinalarabic'] = 0xFC73;
  9345. t['tekatakana'] = 0x30C6;
  9346. t['tekatakanahalfwidth'] = 0xFF83;
  9347. t['telephone'] = 0x2121;
  9348. t['telephoneblack'] = 0x260E;
  9349. t['telishagedolahebrew'] = 0x05A0;
  9350. t['telishaqetanahebrew'] = 0x05A9;
  9351. t['tencircle'] = 0x2469;
  9352. t['tenideographicparen'] = 0x3229;
  9353. t['tenparen'] = 0x247D;
  9354. t['tenperiod'] = 0x2491;
  9355. t['tenroman'] = 0x2179;
  9356. t['tesh'] = 0x02A7;
  9357. t['tet'] = 0x05D8;
  9358. t['tetdagesh'] = 0xFB38;
  9359. t['tetdageshhebrew'] = 0xFB38;
  9360. t['tethebrew'] = 0x05D8;
  9361. t['tetsecyrillic'] = 0x04B5;
  9362. t['tevirhebrew'] = 0x059B;
  9363. t['tevirlefthebrew'] = 0x059B;
  9364. t['thabengali'] = 0x09A5;
  9365. t['thadeva'] = 0x0925;
  9366. t['thagujarati'] = 0x0AA5;
  9367. t['thagurmukhi'] = 0x0A25;
  9368. t['thalarabic'] = 0x0630;
  9369. t['thalfinalarabic'] = 0xFEAC;
  9370. t['thanthakhatlowleftthai'] = 0xF898;
  9371. t['thanthakhatlowrightthai'] = 0xF897;
  9372. t['thanthakhatthai'] = 0x0E4C;
  9373. t['thanthakhatupperleftthai'] = 0xF896;
  9374. t['theharabic'] = 0x062B;
  9375. t['thehfinalarabic'] = 0xFE9A;
  9376. t['thehinitialarabic'] = 0xFE9B;
  9377. t['thehmedialarabic'] = 0xFE9C;
  9378. t['thereexists'] = 0x2203;
  9379. t['therefore'] = 0x2234;
  9380. t['theta'] = 0x03B8;
  9381. t['theta1'] = 0x03D1;
  9382. t['thetasymbolgreek'] = 0x03D1;
  9383. t['thieuthacirclekorean'] = 0x3279;
  9384. t['thieuthaparenkorean'] = 0x3219;
  9385. t['thieuthcirclekorean'] = 0x326B;
  9386. t['thieuthkorean'] = 0x314C;
  9387. t['thieuthparenkorean'] = 0x320B;
  9388. t['thirteencircle'] = 0x246C;
  9389. t['thirteenparen'] = 0x2480;
  9390. t['thirteenperiod'] = 0x2494;
  9391. t['thonangmonthothai'] = 0x0E11;
  9392. t['thook'] = 0x01AD;
  9393. t['thophuthaothai'] = 0x0E12;
  9394. t['thorn'] = 0x00FE;
  9395. t['thothahanthai'] = 0x0E17;
  9396. t['thothanthai'] = 0x0E10;
  9397. t['thothongthai'] = 0x0E18;
  9398. t['thothungthai'] = 0x0E16;
  9399. t['thousandcyrillic'] = 0x0482;
  9400. t['thousandsseparatorarabic'] = 0x066C;
  9401. t['thousandsseparatorpersian'] = 0x066C;
  9402. t['three'] = 0x0033;
  9403. t['threearabic'] = 0x0663;
  9404. t['threebengali'] = 0x09E9;
  9405. t['threecircle'] = 0x2462;
  9406. t['threecircleinversesansserif'] = 0x278C;
  9407. t['threedeva'] = 0x0969;
  9408. t['threeeighths'] = 0x215C;
  9409. t['threegujarati'] = 0x0AE9;
  9410. t['threegurmukhi'] = 0x0A69;
  9411. t['threehackarabic'] = 0x0663;
  9412. t['threehangzhou'] = 0x3023;
  9413. t['threeideographicparen'] = 0x3222;
  9414. t['threeinferior'] = 0x2083;
  9415. t['threemonospace'] = 0xFF13;
  9416. t['threenumeratorbengali'] = 0x09F6;
  9417. t['threeoldstyle'] = 0xF733;
  9418. t['threeparen'] = 0x2476;
  9419. t['threeperiod'] = 0x248A;
  9420. t['threepersian'] = 0x06F3;
  9421. t['threequarters'] = 0x00BE;
  9422. t['threequartersemdash'] = 0xF6DE;
  9423. t['threeroman'] = 0x2172;
  9424. t['threesuperior'] = 0x00B3;
  9425. t['threethai'] = 0x0E53;
  9426. t['thzsquare'] = 0x3394;
  9427. t['tihiragana'] = 0x3061;
  9428. t['tikatakana'] = 0x30C1;
  9429. t['tikatakanahalfwidth'] = 0xFF81;
  9430. t['tikeutacirclekorean'] = 0x3270;
  9431. t['tikeutaparenkorean'] = 0x3210;
  9432. t['tikeutcirclekorean'] = 0x3262;
  9433. t['tikeutkorean'] = 0x3137;
  9434. t['tikeutparenkorean'] = 0x3202;
  9435. t['tilde'] = 0x02DC;
  9436. t['tildebelowcmb'] = 0x0330;
  9437. t['tildecmb'] = 0x0303;
  9438. t['tildecomb'] = 0x0303;
  9439. t['tildedoublecmb'] = 0x0360;
  9440. t['tildeoperator'] = 0x223C;
  9441. t['tildeoverlaycmb'] = 0x0334;
  9442. t['tildeverticalcmb'] = 0x033E;
  9443. t['timescircle'] = 0x2297;
  9444. t['tipehahebrew'] = 0x0596;
  9445. t['tipehalefthebrew'] = 0x0596;
  9446. t['tippigurmukhi'] = 0x0A70;
  9447. t['titlocyrilliccmb'] = 0x0483;
  9448. t['tiwnarmenian'] = 0x057F;
  9449. t['tlinebelow'] = 0x1E6F;
  9450. t['tmonospace'] = 0xFF54;
  9451. t['toarmenian'] = 0x0569;
  9452. t['tohiragana'] = 0x3068;
  9453. t['tokatakana'] = 0x30C8;
  9454. t['tokatakanahalfwidth'] = 0xFF84;
  9455. t['tonebarextrahighmod'] = 0x02E5;
  9456. t['tonebarextralowmod'] = 0x02E9;
  9457. t['tonebarhighmod'] = 0x02E6;
  9458. t['tonebarlowmod'] = 0x02E8;
  9459. t['tonebarmidmod'] = 0x02E7;
  9460. t['tonefive'] = 0x01BD;
  9461. t['tonesix'] = 0x0185;
  9462. t['tonetwo'] = 0x01A8;
  9463. t['tonos'] = 0x0384;
  9464. t['tonsquare'] = 0x3327;
  9465. t['topatakthai'] = 0x0E0F;
  9466. t['tortoiseshellbracketleft'] = 0x3014;
  9467. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  9468. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  9469. t['tortoiseshellbracketright'] = 0x3015;
  9470. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  9471. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  9472. t['totaothai'] = 0x0E15;
  9473. t['tpalatalhook'] = 0x01AB;
  9474. t['tparen'] = 0x24AF;
  9475. t['trademark'] = 0x2122;
  9476. t['trademarksans'] = 0xF8EA;
  9477. t['trademarkserif'] = 0xF6DB;
  9478. t['tretroflexhook'] = 0x0288;
  9479. t['triagdn'] = 0x25BC;
  9480. t['triaglf'] = 0x25C4;
  9481. t['triagrt'] = 0x25BA;
  9482. t['triagup'] = 0x25B2;
  9483. t['ts'] = 0x02A6;
  9484. t['tsadi'] = 0x05E6;
  9485. t['tsadidagesh'] = 0xFB46;
  9486. t['tsadidageshhebrew'] = 0xFB46;
  9487. t['tsadihebrew'] = 0x05E6;
  9488. t['tsecyrillic'] = 0x0446;
  9489. t['tsere'] = 0x05B5;
  9490. t['tsere12'] = 0x05B5;
  9491. t['tsere1e'] = 0x05B5;
  9492. t['tsere2b'] = 0x05B5;
  9493. t['tserehebrew'] = 0x05B5;
  9494. t['tserenarrowhebrew'] = 0x05B5;
  9495. t['tserequarterhebrew'] = 0x05B5;
  9496. t['tserewidehebrew'] = 0x05B5;
  9497. t['tshecyrillic'] = 0x045B;
  9498. t['tsuperior'] = 0xF6F3;
  9499. t['ttabengali'] = 0x099F;
  9500. t['ttadeva'] = 0x091F;
  9501. t['ttagujarati'] = 0x0A9F;
  9502. t['ttagurmukhi'] = 0x0A1F;
  9503. t['tteharabic'] = 0x0679;
  9504. t['ttehfinalarabic'] = 0xFB67;
  9505. t['ttehinitialarabic'] = 0xFB68;
  9506. t['ttehmedialarabic'] = 0xFB69;
  9507. t['tthabengali'] = 0x09A0;
  9508. t['tthadeva'] = 0x0920;
  9509. t['tthagujarati'] = 0x0AA0;
  9510. t['tthagurmukhi'] = 0x0A20;
  9511. t['tturned'] = 0x0287;
  9512. t['tuhiragana'] = 0x3064;
  9513. t['tukatakana'] = 0x30C4;
  9514. t['tukatakanahalfwidth'] = 0xFF82;
  9515. t['tusmallhiragana'] = 0x3063;
  9516. t['tusmallkatakana'] = 0x30C3;
  9517. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  9518. t['twelvecircle'] = 0x246B;
  9519. t['twelveparen'] = 0x247F;
  9520. t['twelveperiod'] = 0x2493;
  9521. t['twelveroman'] = 0x217B;
  9522. t['twentycircle'] = 0x2473;
  9523. t['twentyhangzhou'] = 0x5344;
  9524. t['twentyparen'] = 0x2487;
  9525. t['twentyperiod'] = 0x249B;
  9526. t['two'] = 0x0032;
  9527. t['twoarabic'] = 0x0662;
  9528. t['twobengali'] = 0x09E8;
  9529. t['twocircle'] = 0x2461;
  9530. t['twocircleinversesansserif'] = 0x278B;
  9531. t['twodeva'] = 0x0968;
  9532. t['twodotenleader'] = 0x2025;
  9533. t['twodotleader'] = 0x2025;
  9534. t['twodotleadervertical'] = 0xFE30;
  9535. t['twogujarati'] = 0x0AE8;
  9536. t['twogurmukhi'] = 0x0A68;
  9537. t['twohackarabic'] = 0x0662;
  9538. t['twohangzhou'] = 0x3022;
  9539. t['twoideographicparen'] = 0x3221;
  9540. t['twoinferior'] = 0x2082;
  9541. t['twomonospace'] = 0xFF12;
  9542. t['twonumeratorbengali'] = 0x09F5;
  9543. t['twooldstyle'] = 0xF732;
  9544. t['twoparen'] = 0x2475;
  9545. t['twoperiod'] = 0x2489;
  9546. t['twopersian'] = 0x06F2;
  9547. t['tworoman'] = 0x2171;
  9548. t['twostroke'] = 0x01BB;
  9549. t['twosuperior'] = 0x00B2;
  9550. t['twothai'] = 0x0E52;
  9551. t['twothirds'] = 0x2154;
  9552. t['u'] = 0x0075;
  9553. t['uacute'] = 0x00FA;
  9554. t['ubar'] = 0x0289;
  9555. t['ubengali'] = 0x0989;
  9556. t['ubopomofo'] = 0x3128;
  9557. t['ubreve'] = 0x016D;
  9558. t['ucaron'] = 0x01D4;
  9559. t['ucircle'] = 0x24E4;
  9560. t['ucircumflex'] = 0x00FB;
  9561. t['ucircumflexbelow'] = 0x1E77;
  9562. t['ucyrillic'] = 0x0443;
  9563. t['udattadeva'] = 0x0951;
  9564. t['udblacute'] = 0x0171;
  9565. t['udblgrave'] = 0x0215;
  9566. t['udeva'] = 0x0909;
  9567. t['udieresis'] = 0x00FC;
  9568. t['udieresisacute'] = 0x01D8;
  9569. t['udieresisbelow'] = 0x1E73;
  9570. t['udieresiscaron'] = 0x01DA;
  9571. t['udieresiscyrillic'] = 0x04F1;
  9572. t['udieresisgrave'] = 0x01DC;
  9573. t['udieresismacron'] = 0x01D6;
  9574. t['udotbelow'] = 0x1EE5;
  9575. t['ugrave'] = 0x00F9;
  9576. t['ugujarati'] = 0x0A89;
  9577. t['ugurmukhi'] = 0x0A09;
  9578. t['uhiragana'] = 0x3046;
  9579. t['uhookabove'] = 0x1EE7;
  9580. t['uhorn'] = 0x01B0;
  9581. t['uhornacute'] = 0x1EE9;
  9582. t['uhorndotbelow'] = 0x1EF1;
  9583. t['uhorngrave'] = 0x1EEB;
  9584. t['uhornhookabove'] = 0x1EED;
  9585. t['uhorntilde'] = 0x1EEF;
  9586. t['uhungarumlaut'] = 0x0171;
  9587. t['uhungarumlautcyrillic'] = 0x04F3;
  9588. t['uinvertedbreve'] = 0x0217;
  9589. t['ukatakana'] = 0x30A6;
  9590. t['ukatakanahalfwidth'] = 0xFF73;
  9591. t['ukcyrillic'] = 0x0479;
  9592. t['ukorean'] = 0x315C;
  9593. t['umacron'] = 0x016B;
  9594. t['umacroncyrillic'] = 0x04EF;
  9595. t['umacrondieresis'] = 0x1E7B;
  9596. t['umatragurmukhi'] = 0x0A41;
  9597. t['umonospace'] = 0xFF55;
  9598. t['underscore'] = 0x005F;
  9599. t['underscoredbl'] = 0x2017;
  9600. t['underscoremonospace'] = 0xFF3F;
  9601. t['underscorevertical'] = 0xFE33;
  9602. t['underscorewavy'] = 0xFE4F;
  9603. t['union'] = 0x222A;
  9604. t['universal'] = 0x2200;
  9605. t['uogonek'] = 0x0173;
  9606. t['uparen'] = 0x24B0;
  9607. t['upblock'] = 0x2580;
  9608. t['upperdothebrew'] = 0x05C4;
  9609. t['upsilon'] = 0x03C5;
  9610. t['upsilondieresis'] = 0x03CB;
  9611. t['upsilondieresistonos'] = 0x03B0;
  9612. t['upsilonlatin'] = 0x028A;
  9613. t['upsilontonos'] = 0x03CD;
  9614. t['uptackbelowcmb'] = 0x031D;
  9615. t['uptackmod'] = 0x02D4;
  9616. t['uragurmukhi'] = 0x0A73;
  9617. t['uring'] = 0x016F;
  9618. t['ushortcyrillic'] = 0x045E;
  9619. t['usmallhiragana'] = 0x3045;
  9620. t['usmallkatakana'] = 0x30A5;
  9621. t['usmallkatakanahalfwidth'] = 0xFF69;
  9622. t['ustraightcyrillic'] = 0x04AF;
  9623. t['ustraightstrokecyrillic'] = 0x04B1;
  9624. t['utilde'] = 0x0169;
  9625. t['utildeacute'] = 0x1E79;
  9626. t['utildebelow'] = 0x1E75;
  9627. t['uubengali'] = 0x098A;
  9628. t['uudeva'] = 0x090A;
  9629. t['uugujarati'] = 0x0A8A;
  9630. t['uugurmukhi'] = 0x0A0A;
  9631. t['uumatragurmukhi'] = 0x0A42;
  9632. t['uuvowelsignbengali'] = 0x09C2;
  9633. t['uuvowelsigndeva'] = 0x0942;
  9634. t['uuvowelsigngujarati'] = 0x0AC2;
  9635. t['uvowelsignbengali'] = 0x09C1;
  9636. t['uvowelsigndeva'] = 0x0941;
  9637. t['uvowelsigngujarati'] = 0x0AC1;
  9638. t['v'] = 0x0076;
  9639. t['vadeva'] = 0x0935;
  9640. t['vagujarati'] = 0x0AB5;
  9641. t['vagurmukhi'] = 0x0A35;
  9642. t['vakatakana'] = 0x30F7;
  9643. t['vav'] = 0x05D5;
  9644. t['vavdagesh'] = 0xFB35;
  9645. t['vavdagesh65'] = 0xFB35;
  9646. t['vavdageshhebrew'] = 0xFB35;
  9647. t['vavhebrew'] = 0x05D5;
  9648. t['vavholam'] = 0xFB4B;
  9649. t['vavholamhebrew'] = 0xFB4B;
  9650. t['vavvavhebrew'] = 0x05F0;
  9651. t['vavyodhebrew'] = 0x05F1;
  9652. t['vcircle'] = 0x24E5;
  9653. t['vdotbelow'] = 0x1E7F;
  9654. t['vecyrillic'] = 0x0432;
  9655. t['veharabic'] = 0x06A4;
  9656. t['vehfinalarabic'] = 0xFB6B;
  9657. t['vehinitialarabic'] = 0xFB6C;
  9658. t['vehmedialarabic'] = 0xFB6D;
  9659. t['vekatakana'] = 0x30F9;
  9660. t['venus'] = 0x2640;
  9661. t['verticalbar'] = 0x007C;
  9662. t['verticallineabovecmb'] = 0x030D;
  9663. t['verticallinebelowcmb'] = 0x0329;
  9664. t['verticallinelowmod'] = 0x02CC;
  9665. t['verticallinemod'] = 0x02C8;
  9666. t['vewarmenian'] = 0x057E;
  9667. t['vhook'] = 0x028B;
  9668. t['vikatakana'] = 0x30F8;
  9669. t['viramabengali'] = 0x09CD;
  9670. t['viramadeva'] = 0x094D;
  9671. t['viramagujarati'] = 0x0ACD;
  9672. t['visargabengali'] = 0x0983;
  9673. t['visargadeva'] = 0x0903;
  9674. t['visargagujarati'] = 0x0A83;
  9675. t['vmonospace'] = 0xFF56;
  9676. t['voarmenian'] = 0x0578;
  9677. t['voicediterationhiragana'] = 0x309E;
  9678. t['voicediterationkatakana'] = 0x30FE;
  9679. t['voicedmarkkana'] = 0x309B;
  9680. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  9681. t['vokatakana'] = 0x30FA;
  9682. t['vparen'] = 0x24B1;
  9683. t['vtilde'] = 0x1E7D;
  9684. t['vturned'] = 0x028C;
  9685. t['vuhiragana'] = 0x3094;
  9686. t['vukatakana'] = 0x30F4;
  9687. t['w'] = 0x0077;
  9688. t['wacute'] = 0x1E83;
  9689. t['waekorean'] = 0x3159;
  9690. t['wahiragana'] = 0x308F;
  9691. t['wakatakana'] = 0x30EF;
  9692. t['wakatakanahalfwidth'] = 0xFF9C;
  9693. t['wakorean'] = 0x3158;
  9694. t['wasmallhiragana'] = 0x308E;
  9695. t['wasmallkatakana'] = 0x30EE;
  9696. t['wattosquare'] = 0x3357;
  9697. t['wavedash'] = 0x301C;
  9698. t['wavyunderscorevertical'] = 0xFE34;
  9699. t['wawarabic'] = 0x0648;
  9700. t['wawfinalarabic'] = 0xFEEE;
  9701. t['wawhamzaabovearabic'] = 0x0624;
  9702. t['wawhamzaabovefinalarabic'] = 0xFE86;
  9703. t['wbsquare'] = 0x33DD;
  9704. t['wcircle'] = 0x24E6;
  9705. t['wcircumflex'] = 0x0175;
  9706. t['wdieresis'] = 0x1E85;
  9707. t['wdotaccent'] = 0x1E87;
  9708. t['wdotbelow'] = 0x1E89;
  9709. t['wehiragana'] = 0x3091;
  9710. t['weierstrass'] = 0x2118;
  9711. t['wekatakana'] = 0x30F1;
  9712. t['wekorean'] = 0x315E;
  9713. t['weokorean'] = 0x315D;
  9714. t['wgrave'] = 0x1E81;
  9715. t['whitebullet'] = 0x25E6;
  9716. t['whitecircle'] = 0x25CB;
  9717. t['whitecircleinverse'] = 0x25D9;
  9718. t['whitecornerbracketleft'] = 0x300E;
  9719. t['whitecornerbracketleftvertical'] = 0xFE43;
  9720. t['whitecornerbracketright'] = 0x300F;
  9721. t['whitecornerbracketrightvertical'] = 0xFE44;
  9722. t['whitediamond'] = 0x25C7;
  9723. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  9724. t['whitedownpointingsmalltriangle'] = 0x25BF;
  9725. t['whitedownpointingtriangle'] = 0x25BD;
  9726. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  9727. t['whiteleftpointingtriangle'] = 0x25C1;
  9728. t['whitelenticularbracketleft'] = 0x3016;
  9729. t['whitelenticularbracketright'] = 0x3017;
  9730. t['whiterightpointingsmalltriangle'] = 0x25B9;
  9731. t['whiterightpointingtriangle'] = 0x25B7;
  9732. t['whitesmallsquare'] = 0x25AB;
  9733. t['whitesmilingface'] = 0x263A;
  9734. t['whitesquare'] = 0x25A1;
  9735. t['whitestar'] = 0x2606;
  9736. t['whitetelephone'] = 0x260F;
  9737. t['whitetortoiseshellbracketleft'] = 0x3018;
  9738. t['whitetortoiseshellbracketright'] = 0x3019;
  9739. t['whiteuppointingsmalltriangle'] = 0x25B5;
  9740. t['whiteuppointingtriangle'] = 0x25B3;
  9741. t['wihiragana'] = 0x3090;
  9742. t['wikatakana'] = 0x30F0;
  9743. t['wikorean'] = 0x315F;
  9744. t['wmonospace'] = 0xFF57;
  9745. t['wohiragana'] = 0x3092;
  9746. t['wokatakana'] = 0x30F2;
  9747. t['wokatakanahalfwidth'] = 0xFF66;
  9748. t['won'] = 0x20A9;
  9749. t['wonmonospace'] = 0xFFE6;
  9750. t['wowaenthai'] = 0x0E27;
  9751. t['wparen'] = 0x24B2;
  9752. t['wring'] = 0x1E98;
  9753. t['wsuperior'] = 0x02B7;
  9754. t['wturned'] = 0x028D;
  9755. t['wynn'] = 0x01BF;
  9756. t['x'] = 0x0078;
  9757. t['xabovecmb'] = 0x033D;
  9758. t['xbopomofo'] = 0x3112;
  9759. t['xcircle'] = 0x24E7;
  9760. t['xdieresis'] = 0x1E8D;
  9761. t['xdotaccent'] = 0x1E8B;
  9762. t['xeharmenian'] = 0x056D;
  9763. t['xi'] = 0x03BE;
  9764. t['xmonospace'] = 0xFF58;
  9765. t['xparen'] = 0x24B3;
  9766. t['xsuperior'] = 0x02E3;
  9767. t['y'] = 0x0079;
  9768. t['yaadosquare'] = 0x334E;
  9769. t['yabengali'] = 0x09AF;
  9770. t['yacute'] = 0x00FD;
  9771. t['yadeva'] = 0x092F;
  9772. t['yaekorean'] = 0x3152;
  9773. t['yagujarati'] = 0x0AAF;
  9774. t['yagurmukhi'] = 0x0A2F;
  9775. t['yahiragana'] = 0x3084;
  9776. t['yakatakana'] = 0x30E4;
  9777. t['yakatakanahalfwidth'] = 0xFF94;
  9778. t['yakorean'] = 0x3151;
  9779. t['yamakkanthai'] = 0x0E4E;
  9780. t['yasmallhiragana'] = 0x3083;
  9781. t['yasmallkatakana'] = 0x30E3;
  9782. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  9783. t['yatcyrillic'] = 0x0463;
  9784. t['ycircle'] = 0x24E8;
  9785. t['ycircumflex'] = 0x0177;
  9786. t['ydieresis'] = 0x00FF;
  9787. t['ydotaccent'] = 0x1E8F;
  9788. t['ydotbelow'] = 0x1EF5;
  9789. t['yeharabic'] = 0x064A;
  9790. t['yehbarreearabic'] = 0x06D2;
  9791. t['yehbarreefinalarabic'] = 0xFBAF;
  9792. t['yehfinalarabic'] = 0xFEF2;
  9793. t['yehhamzaabovearabic'] = 0x0626;
  9794. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  9795. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  9796. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  9797. t['yehinitialarabic'] = 0xFEF3;
  9798. t['yehmedialarabic'] = 0xFEF4;
  9799. t['yehmeeminitialarabic'] = 0xFCDD;
  9800. t['yehmeemisolatedarabic'] = 0xFC58;
  9801. t['yehnoonfinalarabic'] = 0xFC94;
  9802. t['yehthreedotsbelowarabic'] = 0x06D1;
  9803. t['yekorean'] = 0x3156;
  9804. t['yen'] = 0x00A5;
  9805. t['yenmonospace'] = 0xFFE5;
  9806. t['yeokorean'] = 0x3155;
  9807. t['yeorinhieuhkorean'] = 0x3186;
  9808. t['yerahbenyomohebrew'] = 0x05AA;
  9809. t['yerahbenyomolefthebrew'] = 0x05AA;
  9810. t['yericyrillic'] = 0x044B;
  9811. t['yerudieresiscyrillic'] = 0x04F9;
  9812. t['yesieungkorean'] = 0x3181;
  9813. t['yesieungpansioskorean'] = 0x3183;
  9814. t['yesieungsioskorean'] = 0x3182;
  9815. t['yetivhebrew'] = 0x059A;
  9816. t['ygrave'] = 0x1EF3;
  9817. t['yhook'] = 0x01B4;
  9818. t['yhookabove'] = 0x1EF7;
  9819. t['yiarmenian'] = 0x0575;
  9820. t['yicyrillic'] = 0x0457;
  9821. t['yikorean'] = 0x3162;
  9822. t['yinyang'] = 0x262F;
  9823. t['yiwnarmenian'] = 0x0582;
  9824. t['ymonospace'] = 0xFF59;
  9825. t['yod'] = 0x05D9;
  9826. t['yoddagesh'] = 0xFB39;
  9827. t['yoddageshhebrew'] = 0xFB39;
  9828. t['yodhebrew'] = 0x05D9;
  9829. t['yodyodhebrew'] = 0x05F2;
  9830. t['yodyodpatahhebrew'] = 0xFB1F;
  9831. t['yohiragana'] = 0x3088;
  9832. t['yoikorean'] = 0x3189;
  9833. t['yokatakana'] = 0x30E8;
  9834. t['yokatakanahalfwidth'] = 0xFF96;
  9835. t['yokorean'] = 0x315B;
  9836. t['yosmallhiragana'] = 0x3087;
  9837. t['yosmallkatakana'] = 0x30E7;
  9838. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  9839. t['yotgreek'] = 0x03F3;
  9840. t['yoyaekorean'] = 0x3188;
  9841. t['yoyakorean'] = 0x3187;
  9842. t['yoyakthai'] = 0x0E22;
  9843. t['yoyingthai'] = 0x0E0D;
  9844. t['yparen'] = 0x24B4;
  9845. t['ypogegrammeni'] = 0x037A;
  9846. t['ypogegrammenigreekcmb'] = 0x0345;
  9847. t['yr'] = 0x01A6;
  9848. t['yring'] = 0x1E99;
  9849. t['ysuperior'] = 0x02B8;
  9850. t['ytilde'] = 0x1EF9;
  9851. t['yturned'] = 0x028E;
  9852. t['yuhiragana'] = 0x3086;
  9853. t['yuikorean'] = 0x318C;
  9854. t['yukatakana'] = 0x30E6;
  9855. t['yukatakanahalfwidth'] = 0xFF95;
  9856. t['yukorean'] = 0x3160;
  9857. t['yusbigcyrillic'] = 0x046B;
  9858. t['yusbigiotifiedcyrillic'] = 0x046D;
  9859. t['yuslittlecyrillic'] = 0x0467;
  9860. t['yuslittleiotifiedcyrillic'] = 0x0469;
  9861. t['yusmallhiragana'] = 0x3085;
  9862. t['yusmallkatakana'] = 0x30E5;
  9863. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  9864. t['yuyekorean'] = 0x318B;
  9865. t['yuyeokorean'] = 0x318A;
  9866. t['yyabengali'] = 0x09DF;
  9867. t['yyadeva'] = 0x095F;
  9868. t['z'] = 0x007A;
  9869. t['zaarmenian'] = 0x0566;
  9870. t['zacute'] = 0x017A;
  9871. t['zadeva'] = 0x095B;
  9872. t['zagurmukhi'] = 0x0A5B;
  9873. t['zaharabic'] = 0x0638;
  9874. t['zahfinalarabic'] = 0xFEC6;
  9875. t['zahinitialarabic'] = 0xFEC7;
  9876. t['zahiragana'] = 0x3056;
  9877. t['zahmedialarabic'] = 0xFEC8;
  9878. t['zainarabic'] = 0x0632;
  9879. t['zainfinalarabic'] = 0xFEB0;
  9880. t['zakatakana'] = 0x30B6;
  9881. t['zaqefgadolhebrew'] = 0x0595;
  9882. t['zaqefqatanhebrew'] = 0x0594;
  9883. t['zarqahebrew'] = 0x0598;
  9884. t['zayin'] = 0x05D6;
  9885. t['zayindagesh'] = 0xFB36;
  9886. t['zayindageshhebrew'] = 0xFB36;
  9887. t['zayinhebrew'] = 0x05D6;
  9888. t['zbopomofo'] = 0x3117;
  9889. t['zcaron'] = 0x017E;
  9890. t['zcircle'] = 0x24E9;
  9891. t['zcircumflex'] = 0x1E91;
  9892. t['zcurl'] = 0x0291;
  9893. t['zdot'] = 0x017C;
  9894. t['zdotaccent'] = 0x017C;
  9895. t['zdotbelow'] = 0x1E93;
  9896. t['zecyrillic'] = 0x0437;
  9897. t['zedescendercyrillic'] = 0x0499;
  9898. t['zedieresiscyrillic'] = 0x04DF;
  9899. t['zehiragana'] = 0x305C;
  9900. t['zekatakana'] = 0x30BC;
  9901. t['zero'] = 0x0030;
  9902. t['zeroarabic'] = 0x0660;
  9903. t['zerobengali'] = 0x09E6;
  9904. t['zerodeva'] = 0x0966;
  9905. t['zerogujarati'] = 0x0AE6;
  9906. t['zerogurmukhi'] = 0x0A66;
  9907. t['zerohackarabic'] = 0x0660;
  9908. t['zeroinferior'] = 0x2080;
  9909. t['zeromonospace'] = 0xFF10;
  9910. t['zerooldstyle'] = 0xF730;
  9911. t['zeropersian'] = 0x06F0;
  9912. t['zerosuperior'] = 0x2070;
  9913. t['zerothai'] = 0x0E50;
  9914. t['zerowidthjoiner'] = 0xFEFF;
  9915. t['zerowidthnonjoiner'] = 0x200C;
  9916. t['zerowidthspace'] = 0x200B;
  9917. t['zeta'] = 0x03B6;
  9918. t['zhbopomofo'] = 0x3113;
  9919. t['zhearmenian'] = 0x056A;
  9920. t['zhebrevecyrillic'] = 0x04C2;
  9921. t['zhecyrillic'] = 0x0436;
  9922. t['zhedescendercyrillic'] = 0x0497;
  9923. t['zhedieresiscyrillic'] = 0x04DD;
  9924. t['zihiragana'] = 0x3058;
  9925. t['zikatakana'] = 0x30B8;
  9926. t['zinorhebrew'] = 0x05AE;
  9927. t['zlinebelow'] = 0x1E95;
  9928. t['zmonospace'] = 0xFF5A;
  9929. t['zohiragana'] = 0x305E;
  9930. t['zokatakana'] = 0x30BE;
  9931. t['zparen'] = 0x24B5;
  9932. t['zretroflexhook'] = 0x0290;
  9933. t['zstroke'] = 0x01B6;
  9934. t['zuhiragana'] = 0x305A;
  9935. t['zukatakana'] = 0x30BA;
  9936. t['.notdef'] = 0x0000;
  9937. t['angbracketleftbig'] = 0x2329;
  9938. t['angbracketleftBig'] = 0x2329;
  9939. t['angbracketleftbigg'] = 0x2329;
  9940. t['angbracketleftBigg'] = 0x2329;
  9941. t['angbracketrightBig'] = 0x232A;
  9942. t['angbracketrightbig'] = 0x232A;
  9943. t['angbracketrightBigg'] = 0x232A;
  9944. t['angbracketrightbigg'] = 0x232A;
  9945. t['arrowhookleft'] = 0x21AA;
  9946. t['arrowhookright'] = 0x21A9;
  9947. t['arrowlefttophalf'] = 0x21BC;
  9948. t['arrowleftbothalf'] = 0x21BD;
  9949. t['arrownortheast'] = 0x2197;
  9950. t['arrownorthwest'] = 0x2196;
  9951. t['arrowrighttophalf'] = 0x21C0;
  9952. t['arrowrightbothalf'] = 0x21C1;
  9953. t['arrowsoutheast'] = 0x2198;
  9954. t['arrowsouthwest'] = 0x2199;
  9955. t['backslashbig'] = 0x2216;
  9956. t['backslashBig'] = 0x2216;
  9957. t['backslashBigg'] = 0x2216;
  9958. t['backslashbigg'] = 0x2216;
  9959. t['bardbl'] = 0x2016;
  9960. t['bracehtipdownleft'] = 0xFE37;
  9961. t['bracehtipdownright'] = 0xFE37;
  9962. t['bracehtipupleft'] = 0xFE38;
  9963. t['bracehtipupright'] = 0xFE38;
  9964. t['braceleftBig'] = 0x007B;
  9965. t['braceleftbig'] = 0x007B;
  9966. t['braceleftbigg'] = 0x007B;
  9967. t['braceleftBigg'] = 0x007B;
  9968. t['bracerightBig'] = 0x007D;
  9969. t['bracerightbig'] = 0x007D;
  9970. t['bracerightbigg'] = 0x007D;
  9971. t['bracerightBigg'] = 0x007D;
  9972. t['bracketleftbig'] = 0x005B;
  9973. t['bracketleftBig'] = 0x005B;
  9974. t['bracketleftbigg'] = 0x005B;
  9975. t['bracketleftBigg'] = 0x005B;
  9976. t['bracketrightBig'] = 0x005D;
  9977. t['bracketrightbig'] = 0x005D;
  9978. t['bracketrightbigg'] = 0x005D;
  9979. t['bracketrightBigg'] = 0x005D;
  9980. t['ceilingleftbig'] = 0x2308;
  9981. t['ceilingleftBig'] = 0x2308;
  9982. t['ceilingleftBigg'] = 0x2308;
  9983. t['ceilingleftbigg'] = 0x2308;
  9984. t['ceilingrightbig'] = 0x2309;
  9985. t['ceilingrightBig'] = 0x2309;
  9986. t['ceilingrightbigg'] = 0x2309;
  9987. t['ceilingrightBigg'] = 0x2309;
  9988. t['circledotdisplay'] = 0x2299;
  9989. t['circledottext'] = 0x2299;
  9990. t['circlemultiplydisplay'] = 0x2297;
  9991. t['circlemultiplytext'] = 0x2297;
  9992. t['circleplusdisplay'] = 0x2295;
  9993. t['circleplustext'] = 0x2295;
  9994. t['contintegraldisplay'] = 0x222E;
  9995. t['contintegraltext'] = 0x222E;
  9996. t['coproductdisplay'] = 0x2210;
  9997. t['coproducttext'] = 0x2210;
  9998. t['floorleftBig'] = 0x230A;
  9999. t['floorleftbig'] = 0x230A;
  10000. t['floorleftbigg'] = 0x230A;
  10001. t['floorleftBigg'] = 0x230A;
  10002. t['floorrightbig'] = 0x230B;
  10003. t['floorrightBig'] = 0x230B;
  10004. t['floorrightBigg'] = 0x230B;
  10005. t['floorrightbigg'] = 0x230B;
  10006. t['hatwide'] = 0x0302;
  10007. t['hatwider'] = 0x0302;
  10008. t['hatwidest'] = 0x0302;
  10009. t['intercal'] = 0x1D40;
  10010. t['integraldisplay'] = 0x222B;
  10011. t['integraltext'] = 0x222B;
  10012. t['intersectiondisplay'] = 0x22C2;
  10013. t['intersectiontext'] = 0x22C2;
  10014. t['logicalanddisplay'] = 0x2227;
  10015. t['logicalandtext'] = 0x2227;
  10016. t['logicalordisplay'] = 0x2228;
  10017. t['logicalortext'] = 0x2228;
  10018. t['parenleftBig'] = 0x0028;
  10019. t['parenleftbig'] = 0x0028;
  10020. t['parenleftBigg'] = 0x0028;
  10021. t['parenleftbigg'] = 0x0028;
  10022. t['parenrightBig'] = 0x0029;
  10023. t['parenrightbig'] = 0x0029;
  10024. t['parenrightBigg'] = 0x0029;
  10025. t['parenrightbigg'] = 0x0029;
  10026. t['prime'] = 0x2032;
  10027. t['productdisplay'] = 0x220F;
  10028. t['producttext'] = 0x220F;
  10029. t['radicalbig'] = 0x221A;
  10030. t['radicalBig'] = 0x221A;
  10031. t['radicalBigg'] = 0x221A;
  10032. t['radicalbigg'] = 0x221A;
  10033. t['radicalbt'] = 0x221A;
  10034. t['radicaltp'] = 0x221A;
  10035. t['radicalvertex'] = 0x221A;
  10036. t['slashbig'] = 0x002F;
  10037. t['slashBig'] = 0x002F;
  10038. t['slashBigg'] = 0x002F;
  10039. t['slashbigg'] = 0x002F;
  10040. t['summationdisplay'] = 0x2211;
  10041. t['summationtext'] = 0x2211;
  10042. t['tildewide'] = 0x02DC;
  10043. t['tildewider'] = 0x02DC;
  10044. t['tildewidest'] = 0x02DC;
  10045. t['uniondisplay'] = 0x22C3;
  10046. t['unionmultidisplay'] = 0x228E;
  10047. t['unionmultitext'] = 0x228E;
  10048. t['unionsqdisplay'] = 0x2294;
  10049. t['unionsqtext'] = 0x2294;
  10050. t['uniontext'] = 0x22C3;
  10051. t['vextenddouble'] = 0x2225;
  10052. t['vextendsingle'] = 0x2223;
  10053. });
  10054. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  10055. t['space'] = 0x0020;
  10056. t['a1'] = 0x2701;
  10057. t['a2'] = 0x2702;
  10058. t['a202'] = 0x2703;
  10059. t['a3'] = 0x2704;
  10060. t['a4'] = 0x260E;
  10061. t['a5'] = 0x2706;
  10062. t['a119'] = 0x2707;
  10063. t['a118'] = 0x2708;
  10064. t['a117'] = 0x2709;
  10065. t['a11'] = 0x261B;
  10066. t['a12'] = 0x261E;
  10067. t['a13'] = 0x270C;
  10068. t['a14'] = 0x270D;
  10069. t['a15'] = 0x270E;
  10070. t['a16'] = 0x270F;
  10071. t['a105'] = 0x2710;
  10072. t['a17'] = 0x2711;
  10073. t['a18'] = 0x2712;
  10074. t['a19'] = 0x2713;
  10075. t['a20'] = 0x2714;
  10076. t['a21'] = 0x2715;
  10077. t['a22'] = 0x2716;
  10078. t['a23'] = 0x2717;
  10079. t['a24'] = 0x2718;
  10080. t['a25'] = 0x2719;
  10081. t['a26'] = 0x271A;
  10082. t['a27'] = 0x271B;
  10083. t['a28'] = 0x271C;
  10084. t['a6'] = 0x271D;
  10085. t['a7'] = 0x271E;
  10086. t['a8'] = 0x271F;
  10087. t['a9'] = 0x2720;
  10088. t['a10'] = 0x2721;
  10089. t['a29'] = 0x2722;
  10090. t['a30'] = 0x2723;
  10091. t['a31'] = 0x2724;
  10092. t['a32'] = 0x2725;
  10093. t['a33'] = 0x2726;
  10094. t['a34'] = 0x2727;
  10095. t['a35'] = 0x2605;
  10096. t['a36'] = 0x2729;
  10097. t['a37'] = 0x272A;
  10098. t['a38'] = 0x272B;
  10099. t['a39'] = 0x272C;
  10100. t['a40'] = 0x272D;
  10101. t['a41'] = 0x272E;
  10102. t['a42'] = 0x272F;
  10103. t['a43'] = 0x2730;
  10104. t['a44'] = 0x2731;
  10105. t['a45'] = 0x2732;
  10106. t['a46'] = 0x2733;
  10107. t['a47'] = 0x2734;
  10108. t['a48'] = 0x2735;
  10109. t['a49'] = 0x2736;
  10110. t['a50'] = 0x2737;
  10111. t['a51'] = 0x2738;
  10112. t['a52'] = 0x2739;
  10113. t['a53'] = 0x273A;
  10114. t['a54'] = 0x273B;
  10115. t['a55'] = 0x273C;
  10116. t['a56'] = 0x273D;
  10117. t['a57'] = 0x273E;
  10118. t['a58'] = 0x273F;
  10119. t['a59'] = 0x2740;
  10120. t['a60'] = 0x2741;
  10121. t['a61'] = 0x2742;
  10122. t['a62'] = 0x2743;
  10123. t['a63'] = 0x2744;
  10124. t['a64'] = 0x2745;
  10125. t['a65'] = 0x2746;
  10126. t['a66'] = 0x2747;
  10127. t['a67'] = 0x2748;
  10128. t['a68'] = 0x2749;
  10129. t['a69'] = 0x274A;
  10130. t['a70'] = 0x274B;
  10131. t['a71'] = 0x25CF;
  10132. t['a72'] = 0x274D;
  10133. t['a73'] = 0x25A0;
  10134. t['a74'] = 0x274F;
  10135. t['a203'] = 0x2750;
  10136. t['a75'] = 0x2751;
  10137. t['a204'] = 0x2752;
  10138. t['a76'] = 0x25B2;
  10139. t['a77'] = 0x25BC;
  10140. t['a78'] = 0x25C6;
  10141. t['a79'] = 0x2756;
  10142. t['a81'] = 0x25D7;
  10143. t['a82'] = 0x2758;
  10144. t['a83'] = 0x2759;
  10145. t['a84'] = 0x275A;
  10146. t['a97'] = 0x275B;
  10147. t['a98'] = 0x275C;
  10148. t['a99'] = 0x275D;
  10149. t['a100'] = 0x275E;
  10150. t['a101'] = 0x2761;
  10151. t['a102'] = 0x2762;
  10152. t['a103'] = 0x2763;
  10153. t['a104'] = 0x2764;
  10154. t['a106'] = 0x2765;
  10155. t['a107'] = 0x2766;
  10156. t['a108'] = 0x2767;
  10157. t['a112'] = 0x2663;
  10158. t['a111'] = 0x2666;
  10159. t['a110'] = 0x2665;
  10160. t['a109'] = 0x2660;
  10161. t['a120'] = 0x2460;
  10162. t['a121'] = 0x2461;
  10163. t['a122'] = 0x2462;
  10164. t['a123'] = 0x2463;
  10165. t['a124'] = 0x2464;
  10166. t['a125'] = 0x2465;
  10167. t['a126'] = 0x2466;
  10168. t['a127'] = 0x2467;
  10169. t['a128'] = 0x2468;
  10170. t['a129'] = 0x2469;
  10171. t['a130'] = 0x2776;
  10172. t['a131'] = 0x2777;
  10173. t['a132'] = 0x2778;
  10174. t['a133'] = 0x2779;
  10175. t['a134'] = 0x277A;
  10176. t['a135'] = 0x277B;
  10177. t['a136'] = 0x277C;
  10178. t['a137'] = 0x277D;
  10179. t['a138'] = 0x277E;
  10180. t['a139'] = 0x277F;
  10181. t['a140'] = 0x2780;
  10182. t['a141'] = 0x2781;
  10183. t['a142'] = 0x2782;
  10184. t['a143'] = 0x2783;
  10185. t['a144'] = 0x2784;
  10186. t['a145'] = 0x2785;
  10187. t['a146'] = 0x2786;
  10188. t['a147'] = 0x2787;
  10189. t['a148'] = 0x2788;
  10190. t['a149'] = 0x2789;
  10191. t['a150'] = 0x278A;
  10192. t['a151'] = 0x278B;
  10193. t['a152'] = 0x278C;
  10194. t['a153'] = 0x278D;
  10195. t['a154'] = 0x278E;
  10196. t['a155'] = 0x278F;
  10197. t['a156'] = 0x2790;
  10198. t['a157'] = 0x2791;
  10199. t['a158'] = 0x2792;
  10200. t['a159'] = 0x2793;
  10201. t['a160'] = 0x2794;
  10202. t['a161'] = 0x2192;
  10203. t['a163'] = 0x2194;
  10204. t['a164'] = 0x2195;
  10205. t['a196'] = 0x2798;
  10206. t['a165'] = 0x2799;
  10207. t['a192'] = 0x279A;
  10208. t['a166'] = 0x279B;
  10209. t['a167'] = 0x279C;
  10210. t['a168'] = 0x279D;
  10211. t['a169'] = 0x279E;
  10212. t['a170'] = 0x279F;
  10213. t['a171'] = 0x27A0;
  10214. t['a172'] = 0x27A1;
  10215. t['a173'] = 0x27A2;
  10216. t['a162'] = 0x27A3;
  10217. t['a174'] = 0x27A4;
  10218. t['a175'] = 0x27A5;
  10219. t['a176'] = 0x27A6;
  10220. t['a177'] = 0x27A7;
  10221. t['a178'] = 0x27A8;
  10222. t['a179'] = 0x27A9;
  10223. t['a193'] = 0x27AA;
  10224. t['a180'] = 0x27AB;
  10225. t['a199'] = 0x27AC;
  10226. t['a181'] = 0x27AD;
  10227. t['a200'] = 0x27AE;
  10228. t['a182'] = 0x27AF;
  10229. t['a201'] = 0x27B1;
  10230. t['a183'] = 0x27B2;
  10231. t['a184'] = 0x27B3;
  10232. t['a197'] = 0x27B4;
  10233. t['a185'] = 0x27B5;
  10234. t['a194'] = 0x27B6;
  10235. t['a198'] = 0x27B7;
  10236. t['a186'] = 0x27B8;
  10237. t['a195'] = 0x27B9;
  10238. t['a187'] = 0x27BA;
  10239. t['a188'] = 0x27BB;
  10240. t['a189'] = 0x27BC;
  10241. t['a190'] = 0x27BD;
  10242. t['a191'] = 0x27BE;
  10243. t['a89'] = 0x2768;
  10244. t['a90'] = 0x2769;
  10245. t['a93'] = 0x276A;
  10246. t['a94'] = 0x276B;
  10247. t['a91'] = 0x276C;
  10248. t['a92'] = 0x276D;
  10249. t['a205'] = 0x276E;
  10250. t['a85'] = 0x276F;
  10251. t['a206'] = 0x2770;
  10252. t['a86'] = 0x2771;
  10253. t['a87'] = 0x2772;
  10254. t['a88'] = 0x2773;
  10255. t['a95'] = 0x2774;
  10256. t['a96'] = 0x2775;
  10257. t['.notdef'] = 0x0000;
  10258. });
  10259. exports.getGlyphsUnicode = getGlyphsUnicode;
  10260. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  10261. /***/ }),
  10262. /* 43 */
  10263. /***/ (function(module, exports, __w_pdfjs_require__) {
  10264. "use strict";
  10265. module.exports = !__w_pdfjs_require__(13) && !__w_pdfjs_require__(14)(function () {
  10266. return Object.defineProperty(__w_pdfjs_require__(27)('div'), 'a', {
  10267. get: function get() {
  10268. return 7;
  10269. }
  10270. }).a != 7;
  10271. });
  10272. /***/ }),
  10273. /* 44 */
  10274. /***/ (function(module, exports, __w_pdfjs_require__) {
  10275. "use strict";
  10276. var isObject = __w_pdfjs_require__(2);
  10277. module.exports = function (it, S) {
  10278. if (!isObject(it)) return it;
  10279. var fn, val;
  10280. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  10281. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  10282. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  10283. throw TypeError("Can't convert object to primitive value");
  10284. };
  10285. /***/ }),
  10286. /* 45 */
  10287. /***/ (function(module, exports, __w_pdfjs_require__) {
  10288. "use strict";
  10289. var toIObject = __w_pdfjs_require__(17);
  10290. var toLength = __w_pdfjs_require__(31);
  10291. var toAbsoluteIndex = __w_pdfjs_require__(78);
  10292. module.exports = function (IS_INCLUDES) {
  10293. return function ($this, el, fromIndex) {
  10294. var O = toIObject($this);
  10295. var length = toLength(O.length);
  10296. var index = toAbsoluteIndex(fromIndex, length);
  10297. var value;
  10298. if (IS_INCLUDES && el != el) while (length > index) {
  10299. value = O[index++];
  10300. if (value != value) return true;
  10301. } else for (; length > index; index++) {
  10302. if (IS_INCLUDES || index in O) {
  10303. if (O[index] === el) return IS_INCLUDES || index || 0;
  10304. }
  10305. }return !IS_INCLUDES && -1;
  10306. };
  10307. };
  10308. /***/ }),
  10309. /* 46 */
  10310. /***/ (function(module, exports, __w_pdfjs_require__) {
  10311. "use strict";
  10312. var global = __w_pdfjs_require__(4);
  10313. var SHARED = '__core-js_shared__';
  10314. var store = global[SHARED] || (global[SHARED] = {});
  10315. module.exports = function (key) {
  10316. return store[key] || (store[key] = {});
  10317. };
  10318. /***/ }),
  10319. /* 47 */
  10320. /***/ (function(module, exports, __w_pdfjs_require__) {
  10321. "use strict";
  10322. module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(',');
  10323. /***/ }),
  10324. /* 48 */
  10325. /***/ (function(module, exports, __w_pdfjs_require__) {
  10326. "use strict";
  10327. var UNSCOPABLES = __w_pdfjs_require__(3)('unscopables');
  10328. var ArrayProto = Array.prototype;
  10329. if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(12)(ArrayProto, UNSCOPABLES, {});
  10330. module.exports = function (key) {
  10331. ArrayProto[UNSCOPABLES][key] = true;
  10332. };
  10333. /***/ }),
  10334. /* 49 */
  10335. /***/ (function(module, exports, __w_pdfjs_require__) {
  10336. "use strict";
  10337. var classof = __w_pdfjs_require__(35);
  10338. var test = {};
  10339. test[__w_pdfjs_require__(3)('toStringTag')] = 'z';
  10340. if (test + '' != '[object z]') {
  10341. __w_pdfjs_require__(10)(Object.prototype, 'toString', function toString() {
  10342. return '[object ' + classof(this) + ']';
  10343. }, true);
  10344. }
  10345. /***/ }),
  10346. /* 50 */
  10347. /***/ (function(module, exports, __w_pdfjs_require__) {
  10348. "use strict";
  10349. var LIBRARY = __w_pdfjs_require__(51);
  10350. var $export = __w_pdfjs_require__(6);
  10351. var redefine = __w_pdfjs_require__(10);
  10352. var hide = __w_pdfjs_require__(12);
  10353. var has = __w_pdfjs_require__(9);
  10354. var Iterators = __w_pdfjs_require__(19);
  10355. var $iterCreate = __w_pdfjs_require__(89);
  10356. var setToStringTag = __w_pdfjs_require__(24);
  10357. var getPrototypeOf = __w_pdfjs_require__(92);
  10358. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  10359. var BUGGY = !([].keys && 'next' in [].keys());
  10360. var FF_ITERATOR = '@@iterator';
  10361. var KEYS = 'keys';
  10362. var VALUES = 'values';
  10363. var returnThis = function returnThis() {
  10364. return this;
  10365. };
  10366. module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
  10367. $iterCreate(Constructor, NAME, next);
  10368. var getMethod = function getMethod(kind) {
  10369. if (!BUGGY && kind in proto) return proto[kind];
  10370. switch (kind) {
  10371. case KEYS:
  10372. return function keys() {
  10373. return new Constructor(this, kind);
  10374. };
  10375. case VALUES:
  10376. return function values() {
  10377. return new Constructor(this, kind);
  10378. };
  10379. }
  10380. return function entries() {
  10381. return new Constructor(this, kind);
  10382. };
  10383. };
  10384. var TAG = NAME + ' Iterator';
  10385. var DEF_VALUES = DEFAULT == VALUES;
  10386. var VALUES_BUG = false;
  10387. var proto = Base.prototype;
  10388. var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
  10389. var $default = $native || getMethod(DEFAULT);
  10390. var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
  10391. var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
  10392. var methods, key, IteratorPrototype;
  10393. if ($anyNative) {
  10394. IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
  10395. if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
  10396. setToStringTag(IteratorPrototype, TAG, true);
  10397. if (!LIBRARY && !has(IteratorPrototype, ITERATOR)) hide(IteratorPrototype, ITERATOR, returnThis);
  10398. }
  10399. }
  10400. if (DEF_VALUES && $native && $native.name !== VALUES) {
  10401. VALUES_BUG = true;
  10402. $default = function values() {
  10403. return $native.call(this);
  10404. };
  10405. }
  10406. if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
  10407. hide(proto, ITERATOR, $default);
  10408. }
  10409. Iterators[NAME] = $default;
  10410. Iterators[TAG] = returnThis;
  10411. if (DEFAULT) {
  10412. methods = {
  10413. values: DEF_VALUES ? $default : getMethod(VALUES),
  10414. keys: IS_SET ? $default : getMethod(KEYS),
  10415. entries: $entries
  10416. };
  10417. if (FORCED) for (key in methods) {
  10418. if (!(key in proto)) redefine(proto, key, methods[key]);
  10419. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  10420. }
  10421. return methods;
  10422. };
  10423. /***/ }),
  10424. /* 51 */
  10425. /***/ (function(module, exports, __w_pdfjs_require__) {
  10426. "use strict";
  10427. module.exports = false;
  10428. /***/ }),
  10429. /* 52 */
  10430. /***/ (function(module, exports, __w_pdfjs_require__) {
  10431. "use strict";
  10432. var document = __w_pdfjs_require__(4).document;
  10433. module.exports = document && document.documentElement;
  10434. /***/ }),
  10435. /* 53 */
  10436. /***/ (function(module, exports, __w_pdfjs_require__) {
  10437. "use strict";
  10438. var $iterators = __w_pdfjs_require__(93);
  10439. var getKeys = __w_pdfjs_require__(23);
  10440. var redefine = __w_pdfjs_require__(10);
  10441. var global = __w_pdfjs_require__(4);
  10442. var hide = __w_pdfjs_require__(12);
  10443. var Iterators = __w_pdfjs_require__(19);
  10444. var wks = __w_pdfjs_require__(3);
  10445. var ITERATOR = wks('iterator');
  10446. var TO_STRING_TAG = wks('toStringTag');
  10447. var ArrayValues = Iterators.Array;
  10448. var DOMIterables = {
  10449. CSSRuleList: true,
  10450. CSSStyleDeclaration: false,
  10451. CSSValueList: false,
  10452. ClientRectList: false,
  10453. DOMRectList: false,
  10454. DOMStringList: false,
  10455. DOMTokenList: true,
  10456. DataTransferItemList: false,
  10457. FileList: false,
  10458. HTMLAllCollection: false,
  10459. HTMLCollection: false,
  10460. HTMLFormElement: false,
  10461. HTMLSelectElement: false,
  10462. MediaList: true,
  10463. MimeTypeArray: false,
  10464. NamedNodeMap: false,
  10465. NodeList: true,
  10466. PaintRequestList: false,
  10467. Plugin: false,
  10468. PluginArray: false,
  10469. SVGLengthList: false,
  10470. SVGNumberList: false,
  10471. SVGPathSegList: false,
  10472. SVGPointList: false,
  10473. SVGStringList: false,
  10474. SVGTransformList: false,
  10475. SourceBufferList: false,
  10476. StyleSheetList: true,
  10477. TextTrackCueList: false,
  10478. TextTrackList: false,
  10479. TouchList: false
  10480. };
  10481. for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
  10482. var NAME = collections[i];
  10483. var explicit = DOMIterables[NAME];
  10484. var Collection = global[NAME];
  10485. var proto = Collection && Collection.prototype;
  10486. var key;
  10487. if (proto) {
  10488. if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
  10489. if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
  10490. Iterators[NAME] = ArrayValues;
  10491. if (explicit) for (key in $iterators) {
  10492. if (!proto[key]) redefine(proto, key, $iterators[key], true);
  10493. }
  10494. }
  10495. }
  10496. /***/ }),
  10497. /* 54 */
  10498. /***/ (function(module, exports, __w_pdfjs_require__) {
  10499. "use strict";
  10500. var anObject = __w_pdfjs_require__(8);
  10501. var aFunction = __w_pdfjs_require__(16);
  10502. var SPECIES = __w_pdfjs_require__(3)('species');
  10503. module.exports = function (O, D) {
  10504. var C = anObject(O).constructor;
  10505. var S;
  10506. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  10507. };
  10508. /***/ }),
  10509. /* 55 */
  10510. /***/ (function(module, exports, __w_pdfjs_require__) {
  10511. "use strict";
  10512. var ctx = __w_pdfjs_require__(11);
  10513. var invoke = __w_pdfjs_require__(99);
  10514. var html = __w_pdfjs_require__(52);
  10515. var cel = __w_pdfjs_require__(27);
  10516. var global = __w_pdfjs_require__(4);
  10517. var process = global.process;
  10518. var setTask = global.setImmediate;
  10519. var clearTask = global.clearImmediate;
  10520. var MessageChannel = global.MessageChannel;
  10521. var Dispatch = global.Dispatch;
  10522. var counter = 0;
  10523. var queue = {};
  10524. var ONREADYSTATECHANGE = 'onreadystatechange';
  10525. var defer, channel, port;
  10526. var run = function run() {
  10527. var id = +this;
  10528. if (queue.hasOwnProperty(id)) {
  10529. var fn = queue[id];
  10530. delete queue[id];
  10531. fn();
  10532. }
  10533. };
  10534. var listener = function listener(event) {
  10535. run.call(event.data);
  10536. };
  10537. if (!setTask || !clearTask) {
  10538. setTask = function setImmediate(fn) {
  10539. var args = [];
  10540. var i = 1;
  10541. while (arguments.length > i) {
  10542. args.push(arguments[i++]);
  10543. }queue[++counter] = function () {
  10544. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  10545. };
  10546. defer(counter);
  10547. return counter;
  10548. };
  10549. clearTask = function clearImmediate(id) {
  10550. delete queue[id];
  10551. };
  10552. if (__w_pdfjs_require__(18)(process) == 'process') {
  10553. defer = function defer(id) {
  10554. process.nextTick(ctx(run, id, 1));
  10555. };
  10556. } else if (Dispatch && Dispatch.now) {
  10557. defer = function defer(id) {
  10558. Dispatch.now(ctx(run, id, 1));
  10559. };
  10560. } else if (MessageChannel) {
  10561. channel = new MessageChannel();
  10562. port = channel.port2;
  10563. channel.port1.onmessage = listener;
  10564. defer = ctx(port.postMessage, port, 1);
  10565. } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
  10566. defer = function defer(id) {
  10567. global.postMessage(id + '', '*');
  10568. };
  10569. global.addEventListener('message', listener, false);
  10570. } else if (ONREADYSTATECHANGE in cel('script')) {
  10571. defer = function defer(id) {
  10572. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
  10573. html.removeChild(this);
  10574. run.call(id);
  10575. };
  10576. };
  10577. } else {
  10578. defer = function defer(id) {
  10579. setTimeout(ctx(run, id, 1), 0);
  10580. };
  10581. }
  10582. }
  10583. module.exports = {
  10584. set: setTask,
  10585. clear: clearTask
  10586. };
  10587. /***/ }),
  10588. /* 56 */
  10589. /***/ (function(module, exports, __w_pdfjs_require__) {
  10590. "use strict";
  10591. module.exports = function (exec) {
  10592. try {
  10593. return {
  10594. e: false,
  10595. v: exec()
  10596. };
  10597. } catch (e) {
  10598. return {
  10599. e: true,
  10600. v: e
  10601. };
  10602. }
  10603. };
  10604. /***/ }),
  10605. /* 57 */
  10606. /***/ (function(module, exports, __w_pdfjs_require__) {
  10607. "use strict";
  10608. var anObject = __w_pdfjs_require__(8);
  10609. var isObject = __w_pdfjs_require__(2);
  10610. var newPromiseCapability = __w_pdfjs_require__(38);
  10611. module.exports = function (C, x) {
  10612. anObject(C);
  10613. if (isObject(x) && x.constructor === C) return x;
  10614. var promiseCapability = newPromiseCapability.f(C);
  10615. var resolve = promiseCapability.resolve;
  10616. resolve(x);
  10617. return promiseCapability.promise;
  10618. };
  10619. /***/ }),
  10620. /* 58 */
  10621. /***/ (function(module, exports, __w_pdfjs_require__) {
  10622. "use strict";
  10623. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  10624. var SAFE_CLOSING = false;
  10625. try {
  10626. var riter = [7][ITERATOR]();
  10627. riter['return'] = function () {
  10628. SAFE_CLOSING = true;
  10629. };
  10630. Array.from(riter, function () {
  10631. throw 2;
  10632. });
  10633. } catch (e) {}
  10634. module.exports = function (exec, skipClosing) {
  10635. if (!skipClosing && !SAFE_CLOSING) return false;
  10636. var safe = false;
  10637. try {
  10638. var arr = [7];
  10639. var iter = arr[ITERATOR]();
  10640. iter.next = function () {
  10641. return { done: safe = true };
  10642. };
  10643. arr[ITERATOR] = function () {
  10644. return iter;
  10645. };
  10646. exec(arr);
  10647. } catch (e) {}
  10648. return safe;
  10649. };
  10650. /***/ }),
  10651. /* 59 */
  10652. /***/ (function(module, exports, __w_pdfjs_require__) {
  10653. "use strict";
  10654. var ctx = __w_pdfjs_require__(11);
  10655. var IObject = __w_pdfjs_require__(29);
  10656. var toObject = __w_pdfjs_require__(36);
  10657. var toLength = __w_pdfjs_require__(31);
  10658. var asc = __w_pdfjs_require__(106);
  10659. module.exports = function (TYPE, $create) {
  10660. var IS_MAP = TYPE == 1;
  10661. var IS_FILTER = TYPE == 2;
  10662. var IS_SOME = TYPE == 3;
  10663. var IS_EVERY = TYPE == 4;
  10664. var IS_FIND_INDEX = TYPE == 6;
  10665. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  10666. var create = $create || asc;
  10667. return function ($this, callbackfn, that) {
  10668. var O = toObject($this);
  10669. var self = IObject(O);
  10670. var f = ctx(callbackfn, that, 3);
  10671. var length = toLength(self.length);
  10672. var index = 0;
  10673. var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  10674. var val, res;
  10675. for (; length > index; index++) {
  10676. if (NO_HOLES || index in self) {
  10677. val = self[index];
  10678. res = f(val, index, O);
  10679. if (TYPE) {
  10680. if (IS_MAP) result[index] = res;else if (res) switch (TYPE) {
  10681. case 3:
  10682. return true;
  10683. case 5:
  10684. return val;
  10685. case 6:
  10686. return index;
  10687. case 2:
  10688. result.push(val);
  10689. } else if (IS_EVERY) return false;
  10690. }
  10691. }
  10692. }return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  10693. };
  10694. };
  10695. /***/ }),
  10696. /* 60 */
  10697. /***/ (function(module, exports, __w_pdfjs_require__) {
  10698. "use strict";
  10699. var isObject = __w_pdfjs_require__(2);
  10700. module.exports = function (it, TYPE) {
  10701. if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
  10702. return it;
  10703. };
  10704. /***/ }),
  10705. /* 61 */
  10706. /***/ (function(module, exports, __w_pdfjs_require__) {
  10707. "use strict";
  10708. Object.defineProperty(exports, "__esModule", {
  10709. value: true
  10710. });
  10711. exports.ChunkedStreamManager = exports.ChunkedStream = undefined;
  10712. var _util = __w_pdfjs_require__(0);
  10713. var ChunkedStream = function ChunkedStreamClosure() {
  10714. function ChunkedStream(length, chunkSize, manager) {
  10715. this.bytes = new Uint8Array(length);
  10716. this.start = 0;
  10717. this.pos = 0;
  10718. this.end = length;
  10719. this.chunkSize = chunkSize;
  10720. this.loadedChunks = [];
  10721. this.numChunksLoaded = 0;
  10722. this.numChunks = Math.ceil(length / chunkSize);
  10723. this.manager = manager;
  10724. this.progressiveDataLength = 0;
  10725. this.lastSuccessfulEnsureByteChunk = -1;
  10726. }
  10727. ChunkedStream.prototype = {
  10728. getMissingChunks: function ChunkedStream_getMissingChunks() {
  10729. var chunks = [];
  10730. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  10731. if (!this.loadedChunks[chunk]) {
  10732. chunks.push(chunk);
  10733. }
  10734. }
  10735. return chunks;
  10736. },
  10737. getBaseStreams: function ChunkedStream_getBaseStreams() {
  10738. return [this];
  10739. },
  10740. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  10741. return this.numChunksLoaded === this.numChunks;
  10742. },
  10743. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  10744. var end = begin + chunk.byteLength;
  10745. if (begin % this.chunkSize !== 0) {
  10746. throw new Error('Bad begin offset: ' + begin);
  10747. }
  10748. var length = this.bytes.length;
  10749. if (end % this.chunkSize !== 0 && end !== length) {
  10750. throw new Error('Bad end offset: ' + end);
  10751. }
  10752. this.bytes.set(new Uint8Array(chunk), begin);
  10753. var chunkSize = this.chunkSize;
  10754. var beginChunk = Math.floor(begin / chunkSize);
  10755. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  10756. var curChunk;
  10757. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  10758. if (!this.loadedChunks[curChunk]) {
  10759. this.loadedChunks[curChunk] = true;
  10760. ++this.numChunksLoaded;
  10761. }
  10762. }
  10763. },
  10764. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  10765. var position = this.progressiveDataLength;
  10766. var beginChunk = Math.floor(position / this.chunkSize);
  10767. this.bytes.set(new Uint8Array(data), position);
  10768. position += data.byteLength;
  10769. this.progressiveDataLength = position;
  10770. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  10771. var curChunk;
  10772. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  10773. if (!this.loadedChunks[curChunk]) {
  10774. this.loadedChunks[curChunk] = true;
  10775. ++this.numChunksLoaded;
  10776. }
  10777. }
  10778. },
  10779. ensureByte: function ChunkedStream_ensureByte(pos) {
  10780. var chunk = Math.floor(pos / this.chunkSize);
  10781. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  10782. return;
  10783. }
  10784. if (!this.loadedChunks[chunk]) {
  10785. throw new _util.MissingDataException(pos, pos + 1);
  10786. }
  10787. this.lastSuccessfulEnsureByteChunk = chunk;
  10788. },
  10789. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  10790. if (begin >= end) {
  10791. return;
  10792. }
  10793. if (end <= this.progressiveDataLength) {
  10794. return;
  10795. }
  10796. var chunkSize = this.chunkSize;
  10797. var beginChunk = Math.floor(begin / chunkSize);
  10798. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  10799. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  10800. if (!this.loadedChunks[chunk]) {
  10801. throw new _util.MissingDataException(begin, end);
  10802. }
  10803. }
  10804. },
  10805. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  10806. var chunk,
  10807. numChunks = this.numChunks;
  10808. for (var i = 0; i < numChunks; ++i) {
  10809. chunk = (beginChunk + i) % numChunks;
  10810. if (!this.loadedChunks[chunk]) {
  10811. return chunk;
  10812. }
  10813. }
  10814. return null;
  10815. },
  10816. hasChunk: function ChunkedStream_hasChunk(chunk) {
  10817. return !!this.loadedChunks[chunk];
  10818. },
  10819. get length() {
  10820. return this.end - this.start;
  10821. },
  10822. get isEmpty() {
  10823. return this.length === 0;
  10824. },
  10825. getByte: function ChunkedStream_getByte() {
  10826. var pos = this.pos;
  10827. if (pos >= this.end) {
  10828. return -1;
  10829. }
  10830. this.ensureByte(pos);
  10831. return this.bytes[this.pos++];
  10832. },
  10833. getUint16: function ChunkedStream_getUint16() {
  10834. var b0 = this.getByte();
  10835. var b1 = this.getByte();
  10836. if (b0 === -1 || b1 === -1) {
  10837. return -1;
  10838. }
  10839. return (b0 << 8) + b1;
  10840. },
  10841. getInt32: function ChunkedStream_getInt32() {
  10842. var b0 = this.getByte();
  10843. var b1 = this.getByte();
  10844. var b2 = this.getByte();
  10845. var b3 = this.getByte();
  10846. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  10847. },
  10848. getBytes: function ChunkedStream_getBytes(length) {
  10849. var bytes = this.bytes;
  10850. var pos = this.pos;
  10851. var strEnd = this.end;
  10852. if (!length) {
  10853. this.ensureRange(pos, strEnd);
  10854. return bytes.subarray(pos, strEnd);
  10855. }
  10856. var end = pos + length;
  10857. if (end > strEnd) {
  10858. end = strEnd;
  10859. }
  10860. this.ensureRange(pos, end);
  10861. this.pos = end;
  10862. return bytes.subarray(pos, end);
  10863. },
  10864. peekByte: function ChunkedStream_peekByte() {
  10865. var peekedByte = this.getByte();
  10866. this.pos--;
  10867. return peekedByte;
  10868. },
  10869. peekBytes: function ChunkedStream_peekBytes(length) {
  10870. var bytes = this.getBytes(length);
  10871. this.pos -= bytes.length;
  10872. return bytes;
  10873. },
  10874. getByteRange: function ChunkedStream_getBytes(begin, end) {
  10875. this.ensureRange(begin, end);
  10876. return this.bytes.subarray(begin, end);
  10877. },
  10878. skip: function ChunkedStream_skip(n) {
  10879. if (!n) {
  10880. n = 1;
  10881. }
  10882. this.pos += n;
  10883. },
  10884. reset: function ChunkedStream_reset() {
  10885. this.pos = this.start;
  10886. },
  10887. moveStart: function ChunkedStream_moveStart() {
  10888. this.start = this.pos;
  10889. },
  10890. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  10891. this.ensureRange(start, start + length);
  10892. function ChunkedStreamSubstream() {}
  10893. ChunkedStreamSubstream.prototype = Object.create(this);
  10894. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  10895. var chunkSize = this.chunkSize;
  10896. var beginChunk = Math.floor(this.start / chunkSize);
  10897. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  10898. var missingChunks = [];
  10899. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  10900. if (!this.loadedChunks[chunk]) {
  10901. missingChunks.push(chunk);
  10902. }
  10903. }
  10904. return missingChunks;
  10905. };
  10906. var subStream = new ChunkedStreamSubstream();
  10907. subStream.pos = subStream.start = start;
  10908. subStream.end = start + length || this.end;
  10909. subStream.dict = dict;
  10910. return subStream;
  10911. }
  10912. };
  10913. return ChunkedStream;
  10914. }();
  10915. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  10916. function ChunkedStreamManager(pdfNetworkStream, args) {
  10917. var chunkSize = args.rangeChunkSize;
  10918. var length = args.length;
  10919. this.stream = new ChunkedStream(length, chunkSize, this);
  10920. this.length = length;
  10921. this.chunkSize = chunkSize;
  10922. this.pdfNetworkStream = pdfNetworkStream;
  10923. this.url = args.url;
  10924. this.disableAutoFetch = args.disableAutoFetch;
  10925. this.msgHandler = args.msgHandler;
  10926. this.currRequestId = 0;
  10927. this.chunksNeededByRequest = Object.create(null);
  10928. this.requestsByChunk = Object.create(null);
  10929. this.promisesByRequest = Object.create(null);
  10930. this.progressiveDataLength = 0;
  10931. this.aborted = false;
  10932. this._loadedStreamCapability = (0, _util.createPromiseCapability)();
  10933. }
  10934. ChunkedStreamManager.prototype = {
  10935. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  10936. return this._loadedStreamCapability.promise;
  10937. },
  10938. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  10939. var _this = this;
  10940. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  10941. if (!rangeReader.isStreamingSupported) {
  10942. rangeReader.onProgress = this.onProgress.bind(this);
  10943. }
  10944. var chunks = [],
  10945. loaded = 0;
  10946. var manager = this;
  10947. var promise = new Promise(function (resolve, reject) {
  10948. var readChunk = function readChunk(chunk) {
  10949. try {
  10950. if (!chunk.done) {
  10951. var data = chunk.value;
  10952. chunks.push(data);
  10953. loaded += (0, _util.arrayByteLength)(data);
  10954. if (rangeReader.isStreamingSupported) {
  10955. manager.onProgress({ loaded: loaded });
  10956. }
  10957. rangeReader.read().then(readChunk, reject);
  10958. return;
  10959. }
  10960. var chunkData = (0, _util.arraysToBytes)(chunks);
  10961. chunks = null;
  10962. resolve(chunkData);
  10963. } catch (e) {
  10964. reject(e);
  10965. }
  10966. };
  10967. rangeReader.read().then(readChunk, reject);
  10968. });
  10969. promise.then(function (data) {
  10970. if (_this.aborted) {
  10971. return;
  10972. }
  10973. _this.onReceiveData({
  10974. chunk: data,
  10975. begin: begin
  10976. });
  10977. });
  10978. },
  10979. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  10980. var missingChunks = this.stream.getMissingChunks();
  10981. this._requestChunks(missingChunks);
  10982. return this._loadedStreamCapability.promise;
  10983. },
  10984. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  10985. var requestId = this.currRequestId++;
  10986. var i, ii;
  10987. var chunksNeeded = Object.create(null);
  10988. this.chunksNeededByRequest[requestId] = chunksNeeded;
  10989. for (i = 0, ii = chunks.length; i < ii; i++) {
  10990. if (!this.stream.hasChunk(chunks[i])) {
  10991. chunksNeeded[chunks[i]] = true;
  10992. }
  10993. }
  10994. if ((0, _util.isEmptyObj)(chunksNeeded)) {
  10995. return Promise.resolve();
  10996. }
  10997. var capability = (0, _util.createPromiseCapability)();
  10998. this.promisesByRequest[requestId] = capability;
  10999. var chunksToRequest = [];
  11000. for (var chunk in chunksNeeded) {
  11001. chunk = chunk | 0;
  11002. if (!(chunk in this.requestsByChunk)) {
  11003. this.requestsByChunk[chunk] = [];
  11004. chunksToRequest.push(chunk);
  11005. }
  11006. this.requestsByChunk[chunk].push(requestId);
  11007. }
  11008. if (!chunksToRequest.length) {
  11009. return capability.promise;
  11010. }
  11011. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  11012. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  11013. var groupedChunk = groupedChunksToRequest[i];
  11014. var begin = groupedChunk.beginChunk * this.chunkSize;
  11015. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  11016. this.sendRequest(begin, end);
  11017. }
  11018. return capability.promise;
  11019. },
  11020. getStream: function ChunkedStreamManager_getStream() {
  11021. return this.stream;
  11022. },
  11023. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  11024. end = Math.min(end, this.length);
  11025. var beginChunk = this.getBeginChunk(begin);
  11026. var endChunk = this.getEndChunk(end);
  11027. var chunks = [];
  11028. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  11029. chunks.push(chunk);
  11030. }
  11031. return this._requestChunks(chunks);
  11032. },
  11033. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  11034. ranges = ranges || [];
  11035. var chunksToRequest = [];
  11036. for (var i = 0; i < ranges.length; i++) {
  11037. var beginChunk = this.getBeginChunk(ranges[i].begin);
  11038. var endChunk = this.getEndChunk(ranges[i].end);
  11039. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  11040. if (chunksToRequest.indexOf(chunk) < 0) {
  11041. chunksToRequest.push(chunk);
  11042. }
  11043. }
  11044. }
  11045. chunksToRequest.sort(function (a, b) {
  11046. return a - b;
  11047. });
  11048. return this._requestChunks(chunksToRequest);
  11049. },
  11050. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  11051. var groupedChunks = [];
  11052. var beginChunk = -1;
  11053. var prevChunk = -1;
  11054. for (var i = 0; i < chunks.length; ++i) {
  11055. var chunk = chunks[i];
  11056. if (beginChunk < 0) {
  11057. beginChunk = chunk;
  11058. }
  11059. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  11060. groupedChunks.push({
  11061. beginChunk: beginChunk,
  11062. endChunk: prevChunk + 1
  11063. });
  11064. beginChunk = chunk;
  11065. }
  11066. if (i + 1 === chunks.length) {
  11067. groupedChunks.push({
  11068. beginChunk: beginChunk,
  11069. endChunk: chunk + 1
  11070. });
  11071. }
  11072. prevChunk = chunk;
  11073. }
  11074. return groupedChunks;
  11075. },
  11076. onProgress: function ChunkedStreamManager_onProgress(args) {
  11077. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  11078. this.msgHandler.send('DocProgress', {
  11079. loaded: bytesLoaded,
  11080. total: this.length
  11081. });
  11082. },
  11083. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  11084. var chunk = args.chunk;
  11085. var isProgressive = args.begin === undefined;
  11086. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  11087. var end = begin + chunk.byteLength;
  11088. var beginChunk = Math.floor(begin / this.chunkSize);
  11089. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  11090. if (isProgressive) {
  11091. this.stream.onReceiveProgressiveData(chunk);
  11092. this.progressiveDataLength = end;
  11093. } else {
  11094. this.stream.onReceiveData(begin, chunk);
  11095. }
  11096. if (this.stream.allChunksLoaded()) {
  11097. this._loadedStreamCapability.resolve(this.stream);
  11098. }
  11099. var loadedRequests = [];
  11100. var i, requestId;
  11101. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  11102. var requestIds = this.requestsByChunk[chunk] || [];
  11103. delete this.requestsByChunk[chunk];
  11104. for (i = 0; i < requestIds.length; ++i) {
  11105. requestId = requestIds[i];
  11106. var chunksNeeded = this.chunksNeededByRequest[requestId];
  11107. if (chunk in chunksNeeded) {
  11108. delete chunksNeeded[chunk];
  11109. }
  11110. if (!(0, _util.isEmptyObj)(chunksNeeded)) {
  11111. continue;
  11112. }
  11113. loadedRequests.push(requestId);
  11114. }
  11115. }
  11116. if (!this.disableAutoFetch && (0, _util.isEmptyObj)(this.requestsByChunk)) {
  11117. var nextEmptyChunk;
  11118. if (this.stream.numChunksLoaded === 1) {
  11119. var lastChunk = this.stream.numChunks - 1;
  11120. if (!this.stream.hasChunk(lastChunk)) {
  11121. nextEmptyChunk = lastChunk;
  11122. }
  11123. } else {
  11124. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  11125. }
  11126. if (Number.isInteger(nextEmptyChunk)) {
  11127. this._requestChunks([nextEmptyChunk]);
  11128. }
  11129. }
  11130. for (i = 0; i < loadedRequests.length; ++i) {
  11131. requestId = loadedRequests[i];
  11132. var capability = this.promisesByRequest[requestId];
  11133. delete this.promisesByRequest[requestId];
  11134. capability.resolve();
  11135. }
  11136. this.msgHandler.send('DocProgress', {
  11137. loaded: this.stream.numChunksLoaded * this.chunkSize,
  11138. total: this.length
  11139. });
  11140. },
  11141. onError: function ChunkedStreamManager_onError(err) {
  11142. this._loadedStreamCapability.reject(err);
  11143. },
  11144. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  11145. var chunk = Math.floor(begin / this.chunkSize);
  11146. return chunk;
  11147. },
  11148. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  11149. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  11150. return chunk;
  11151. },
  11152. abort: function ChunkedStreamManager_abort() {
  11153. this.aborted = true;
  11154. if (this.pdfNetworkStream) {
  11155. this.pdfNetworkStream.cancelAllRequests('abort');
  11156. }
  11157. for (var requestId in this.promisesByRequest) {
  11158. var capability = this.promisesByRequest[requestId];
  11159. capability.reject(new Error('Request was aborted'));
  11160. }
  11161. }
  11162. };
  11163. return ChunkedStreamManager;
  11164. }();
  11165. exports.ChunkedStream = ChunkedStream;
  11166. exports.ChunkedStreamManager = ChunkedStreamManager;
  11167. /***/ }),
  11168. /* 62 */
  11169. /***/ (function(module, exports, __w_pdfjs_require__) {
  11170. "use strict";
  11171. Object.defineProperty(exports, "__esModule", {
  11172. value: true
  11173. });
  11174. exports.FileSpec = exports.XRef = exports.ObjectLoader = exports.Catalog = undefined;
  11175. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  11176. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  11177. var _util = __w_pdfjs_require__(0);
  11178. var _primitives = __w_pdfjs_require__(1);
  11179. var _parser = __w_pdfjs_require__(26);
  11180. var _chunked_stream = __w_pdfjs_require__(61);
  11181. var _crypto = __w_pdfjs_require__(65);
  11182. var _colorspace = __w_pdfjs_require__(20);
  11183. var Catalog = function CatalogClosure() {
  11184. function Catalog(pdfManager, xref, pageFactory) {
  11185. this.pdfManager = pdfManager;
  11186. this.xref = xref;
  11187. this.catDict = xref.getCatalogObj();
  11188. if (!(0, _primitives.isDict)(this.catDict)) {
  11189. throw new _util.FormatError('catalog object is not a dictionary');
  11190. }
  11191. this.fontCache = new _primitives.RefSetCache();
  11192. this.builtInCMapCache = Object.create(null);
  11193. this.pageKidsCountCache = new _primitives.RefSetCache();
  11194. this.pageFactory = pageFactory;
  11195. this.pagePromises = [];
  11196. }
  11197. Catalog.prototype = {
  11198. get metadata() {
  11199. var streamRef = this.catDict.getRaw('Metadata');
  11200. if (!(0, _primitives.isRef)(streamRef)) {
  11201. return (0, _util.shadow)(this, 'metadata', null);
  11202. }
  11203. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  11204. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  11205. var metadata;
  11206. if (stream && (0, _primitives.isDict)(stream.dict)) {
  11207. var type = stream.dict.get('Type');
  11208. var subtype = stream.dict.get('Subtype');
  11209. if ((0, _primitives.isName)(type, 'Metadata') && (0, _primitives.isName)(subtype, 'XML')) {
  11210. try {
  11211. metadata = (0, _util.stringToUTF8String)((0, _util.bytesToString)(stream.getBytes()));
  11212. } catch (e) {
  11213. if (e instanceof _util.MissingDataException) {
  11214. throw e;
  11215. }
  11216. (0, _util.info)('Skipping invalid metadata.');
  11217. }
  11218. }
  11219. }
  11220. return (0, _util.shadow)(this, 'metadata', metadata);
  11221. },
  11222. get toplevelPagesDict() {
  11223. var pagesObj = this.catDict.get('Pages');
  11224. if (!(0, _primitives.isDict)(pagesObj)) {
  11225. throw new _util.FormatError('invalid top-level pages dictionary');
  11226. }
  11227. return (0, _util.shadow)(this, 'toplevelPagesDict', pagesObj);
  11228. },
  11229. get documentOutline() {
  11230. var obj = null;
  11231. try {
  11232. obj = this.readDocumentOutline();
  11233. } catch (ex) {
  11234. if (ex instanceof _util.MissingDataException) {
  11235. throw ex;
  11236. }
  11237. (0, _util.warn)('Unable to read document outline');
  11238. }
  11239. return (0, _util.shadow)(this, 'documentOutline', obj);
  11240. },
  11241. readDocumentOutline: function Catalog_readDocumentOutline() {
  11242. var obj = this.catDict.get('Outlines');
  11243. if (!(0, _primitives.isDict)(obj)) {
  11244. return null;
  11245. }
  11246. obj = obj.getRaw('First');
  11247. if (!(0, _primitives.isRef)(obj)) {
  11248. return null;
  11249. }
  11250. var root = { items: [] };
  11251. var queue = [{
  11252. obj: obj,
  11253. parent: root
  11254. }];
  11255. var processed = new _primitives.RefSet();
  11256. processed.put(obj);
  11257. var xref = this.xref,
  11258. blackColor = new Uint8Array(3);
  11259. while (queue.length > 0) {
  11260. var i = queue.shift();
  11261. var outlineDict = xref.fetchIfRef(i.obj);
  11262. if (outlineDict === null) {
  11263. continue;
  11264. }
  11265. if (!outlineDict.has('Title')) {
  11266. throw new _util.FormatError('Invalid outline item');
  11267. }
  11268. var data = {
  11269. url: null,
  11270. dest: null
  11271. };
  11272. Catalog.parseDestDictionary({
  11273. destDict: outlineDict,
  11274. resultObj: data,
  11275. docBaseUrl: this.pdfManager.docBaseUrl
  11276. });
  11277. var title = outlineDict.get('Title');
  11278. var flags = outlineDict.get('F') || 0;
  11279. var color = outlineDict.getArray('C'),
  11280. rgbColor = blackColor;
  11281. if (Array.isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  11282. rgbColor = _colorspace.ColorSpace.singletons.rgb.getRgb(color, 0);
  11283. }
  11284. var outlineItem = {
  11285. dest: data.dest,
  11286. url: data.url,
  11287. unsafeUrl: data.unsafeUrl,
  11288. newWindow: data.newWindow,
  11289. title: (0, _util.stringToPDFString)(title),
  11290. color: rgbColor,
  11291. count: outlineDict.get('Count'),
  11292. bold: !!(flags & 2),
  11293. italic: !!(flags & 1),
  11294. items: []
  11295. };
  11296. i.parent.items.push(outlineItem);
  11297. obj = outlineDict.getRaw('First');
  11298. if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
  11299. queue.push({
  11300. obj: obj,
  11301. parent: outlineItem
  11302. });
  11303. processed.put(obj);
  11304. }
  11305. obj = outlineDict.getRaw('Next');
  11306. if ((0, _primitives.isRef)(obj) && !processed.has(obj)) {
  11307. queue.push({
  11308. obj: obj,
  11309. parent: i.parent
  11310. });
  11311. processed.put(obj);
  11312. }
  11313. }
  11314. return root.items.length > 0 ? root.items : null;
  11315. },
  11316. get numPages() {
  11317. var obj = this.toplevelPagesDict.get('Count');
  11318. if (!Number.isInteger(obj)) {
  11319. throw new _util.FormatError('page count in top level pages object is not an integer');
  11320. }
  11321. return (0, _util.shadow)(this, 'numPages', obj);
  11322. },
  11323. get destinations() {
  11324. function fetchDestination(dest) {
  11325. return (0, _primitives.isDict)(dest) ? dest.get('D') : dest;
  11326. }
  11327. var xref = this.xref;
  11328. var dests = {},
  11329. nameTreeRef,
  11330. nameDictionaryRef;
  11331. var obj = this.catDict.get('Names');
  11332. if (obj && obj.has('Dests')) {
  11333. nameTreeRef = obj.getRaw('Dests');
  11334. } else if (this.catDict.has('Dests')) {
  11335. nameDictionaryRef = this.catDict.get('Dests');
  11336. }
  11337. if (nameDictionaryRef) {
  11338. obj = nameDictionaryRef;
  11339. obj.forEach(function catalogForEach(key, value) {
  11340. if (!value) {
  11341. return;
  11342. }
  11343. dests[key] = fetchDestination(value);
  11344. });
  11345. }
  11346. if (nameTreeRef) {
  11347. var nameTree = new NameTree(nameTreeRef, xref);
  11348. var names = nameTree.getAll();
  11349. for (var name in names) {
  11350. dests[name] = fetchDestination(names[name]);
  11351. }
  11352. }
  11353. return (0, _util.shadow)(this, 'destinations', dests);
  11354. },
  11355. getDestination: function Catalog_getDestination(destinationId) {
  11356. function fetchDestination(dest) {
  11357. return (0, _primitives.isDict)(dest) ? dest.get('D') : dest;
  11358. }
  11359. var xref = this.xref;
  11360. var dest = null,
  11361. nameTreeRef,
  11362. nameDictionaryRef;
  11363. var obj = this.catDict.get('Names');
  11364. if (obj && obj.has('Dests')) {
  11365. nameTreeRef = obj.getRaw('Dests');
  11366. } else if (this.catDict.has('Dests')) {
  11367. nameDictionaryRef = this.catDict.get('Dests');
  11368. }
  11369. if (nameDictionaryRef) {
  11370. var value = nameDictionaryRef.get(destinationId);
  11371. if (value) {
  11372. dest = fetchDestination(value);
  11373. }
  11374. }
  11375. if (nameTreeRef) {
  11376. var nameTree = new NameTree(nameTreeRef, xref);
  11377. dest = fetchDestination(nameTree.get(destinationId));
  11378. }
  11379. return dest;
  11380. },
  11381. get pageLabels() {
  11382. var obj = null;
  11383. try {
  11384. obj = this.readPageLabels();
  11385. } catch (ex) {
  11386. if (ex instanceof _util.MissingDataException) {
  11387. throw ex;
  11388. }
  11389. (0, _util.warn)('Unable to read page labels.');
  11390. }
  11391. return (0, _util.shadow)(this, 'pageLabels', obj);
  11392. },
  11393. readPageLabels: function Catalog_readPageLabels() {
  11394. var obj = this.catDict.getRaw('PageLabels');
  11395. if (!obj) {
  11396. return null;
  11397. }
  11398. var pageLabels = new Array(this.numPages);
  11399. var style = null;
  11400. var prefix = '';
  11401. var numberTree = new NumberTree(obj, this.xref);
  11402. var nums = numberTree.getAll();
  11403. var currentLabel = '',
  11404. currentIndex = 1;
  11405. for (var i = 0, ii = this.numPages; i < ii; i++) {
  11406. if (i in nums) {
  11407. var labelDict = nums[i];
  11408. if (!(0, _primitives.isDict)(labelDict)) {
  11409. throw new _util.FormatError('The PageLabel is not a dictionary.');
  11410. }
  11411. var type = labelDict.get('Type');
  11412. if (type && !(0, _primitives.isName)(type, 'PageLabel')) {
  11413. throw new _util.FormatError('Invalid type in PageLabel dictionary.');
  11414. }
  11415. var s = labelDict.get('S');
  11416. if (s && !(0, _primitives.isName)(s)) {
  11417. throw new _util.FormatError('Invalid style in PageLabel dictionary.');
  11418. }
  11419. style = s ? s.name : null;
  11420. var p = labelDict.get('P');
  11421. if (p && !(0, _util.isString)(p)) {
  11422. throw new _util.FormatError('Invalid prefix in PageLabel dictionary.');
  11423. }
  11424. prefix = p ? (0, _util.stringToPDFString)(p) : '';
  11425. var st = labelDict.get('St');
  11426. if (st && !(Number.isInteger(st) && st >= 1)) {
  11427. throw new _util.FormatError('Invalid start in PageLabel dictionary.');
  11428. }
  11429. currentIndex = st || 1;
  11430. }
  11431. switch (style) {
  11432. case 'D':
  11433. currentLabel = currentIndex;
  11434. break;
  11435. case 'R':
  11436. case 'r':
  11437. currentLabel = _util.Util.toRoman(currentIndex, style === 'r');
  11438. break;
  11439. case 'A':
  11440. case 'a':
  11441. var LIMIT = 26;
  11442. var A_UPPER_CASE = 0x41,
  11443. A_LOWER_CASE = 0x61;
  11444. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  11445. var letterIndex = currentIndex - 1;
  11446. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  11447. var charBuf = [];
  11448. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  11449. charBuf.push(character);
  11450. }
  11451. currentLabel = charBuf.join('');
  11452. break;
  11453. default:
  11454. if (style) {
  11455. throw new _util.FormatError('Invalid style "' + style + '" in PageLabel dictionary.');
  11456. }
  11457. }
  11458. pageLabels[i] = prefix + currentLabel;
  11459. currentLabel = '';
  11460. currentIndex++;
  11461. }
  11462. return pageLabels;
  11463. },
  11464. get pageMode() {
  11465. var obj = this.catDict.get('PageMode');
  11466. var pageMode = 'UseNone';
  11467. if ((0, _primitives.isName)(obj)) {
  11468. switch (obj.name) {
  11469. case 'UseNone':
  11470. case 'UseOutlines':
  11471. case 'UseThumbs':
  11472. case 'FullScreen':
  11473. case 'UseOC':
  11474. case 'UseAttachments':
  11475. pageMode = obj.name;
  11476. }
  11477. }
  11478. return (0, _util.shadow)(this, 'pageMode', pageMode);
  11479. },
  11480. get attachments() {
  11481. var xref = this.xref;
  11482. var attachments = null,
  11483. nameTreeRef;
  11484. var obj = this.catDict.get('Names');
  11485. if (obj) {
  11486. nameTreeRef = obj.getRaw('EmbeddedFiles');
  11487. }
  11488. if (nameTreeRef) {
  11489. var nameTree = new NameTree(nameTreeRef, xref);
  11490. var names = nameTree.getAll();
  11491. for (var name in names) {
  11492. var fs = new FileSpec(names[name], xref);
  11493. if (!attachments) {
  11494. attachments = Object.create(null);
  11495. }
  11496. attachments[(0, _util.stringToPDFString)(name)] = fs.serializable;
  11497. }
  11498. }
  11499. return (0, _util.shadow)(this, 'attachments', attachments);
  11500. },
  11501. get javaScript() {
  11502. var xref = this.xref;
  11503. var obj = this.catDict.get('Names');
  11504. var javaScript = null;
  11505. function appendIfJavaScriptDict(jsDict) {
  11506. var type = jsDict.get('S');
  11507. if (!(0, _primitives.isName)(type, 'JavaScript')) {
  11508. return;
  11509. }
  11510. var js = jsDict.get('JS');
  11511. if ((0, _primitives.isStream)(js)) {
  11512. js = (0, _util.bytesToString)(js.getBytes());
  11513. } else if (!(0, _util.isString)(js)) {
  11514. return;
  11515. }
  11516. if (!javaScript) {
  11517. javaScript = [];
  11518. }
  11519. javaScript.push((0, _util.stringToPDFString)(js));
  11520. }
  11521. if (obj && obj.has('JavaScript')) {
  11522. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  11523. var names = nameTree.getAll();
  11524. for (var name in names) {
  11525. var jsDict = names[name];
  11526. if ((0, _primitives.isDict)(jsDict)) {
  11527. appendIfJavaScriptDict(jsDict);
  11528. }
  11529. }
  11530. }
  11531. var openactionDict = this.catDict.get('OpenAction');
  11532. if ((0, _primitives.isDict)(openactionDict, 'Action')) {
  11533. var actionType = openactionDict.get('S');
  11534. if ((0, _primitives.isName)(actionType, 'Named')) {
  11535. var action = openactionDict.get('N');
  11536. if ((0, _primitives.isName)(action, 'Print')) {
  11537. if (!javaScript) {
  11538. javaScript = [];
  11539. }
  11540. javaScript.push('print({});');
  11541. }
  11542. } else {
  11543. appendIfJavaScriptDict(openactionDict);
  11544. }
  11545. }
  11546. return (0, _util.shadow)(this, 'javaScript', javaScript);
  11547. },
  11548. cleanup: function Catalog_cleanup() {
  11549. var _this = this;
  11550. this.pageKidsCountCache.clear();
  11551. var promises = [];
  11552. this.fontCache.forEach(function (promise) {
  11553. promises.push(promise);
  11554. });
  11555. return Promise.all(promises).then(function (translatedFonts) {
  11556. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  11557. var font = translatedFonts[i].dict;
  11558. delete font.translated;
  11559. }
  11560. _this.fontCache.clear();
  11561. _this.builtInCMapCache = Object.create(null);
  11562. });
  11563. },
  11564. getPage: function Catalog_getPage(pageIndex) {
  11565. var _this2 = this;
  11566. if (!(pageIndex in this.pagePromises)) {
  11567. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (_ref) {
  11568. var _ref2 = _slicedToArray(_ref, 2),
  11569. dict = _ref2[0],
  11570. ref = _ref2[1];
  11571. return _this2.pageFactory.createPage(pageIndex, dict, ref, _this2.fontCache, _this2.builtInCMapCache);
  11572. });
  11573. }
  11574. return this.pagePromises[pageIndex];
  11575. },
  11576. getPageDict: function Catalog_getPageDict(pageIndex) {
  11577. var capability = (0, _util.createPromiseCapability)();
  11578. var nodesToVisit = [this.catDict.getRaw('Pages')];
  11579. var count,
  11580. currentPageIndex = 0;
  11581. var xref = this.xref,
  11582. pageKidsCountCache = this.pageKidsCountCache;
  11583. function next() {
  11584. while (nodesToVisit.length) {
  11585. var currentNode = nodesToVisit.pop();
  11586. if ((0, _primitives.isRef)(currentNode)) {
  11587. count = pageKidsCountCache.get(currentNode);
  11588. if (count > 0 && currentPageIndex + count < pageIndex) {
  11589. currentPageIndex += count;
  11590. continue;
  11591. }
  11592. xref.fetchAsync(currentNode).then(function (obj) {
  11593. if ((0, _primitives.isDict)(obj, 'Page') || (0, _primitives.isDict)(obj) && !obj.has('Kids')) {
  11594. if (pageIndex === currentPageIndex) {
  11595. if (currentNode && !pageKidsCountCache.has(currentNode)) {
  11596. pageKidsCountCache.put(currentNode, 1);
  11597. }
  11598. capability.resolve([obj, currentNode]);
  11599. } else {
  11600. currentPageIndex++;
  11601. next();
  11602. }
  11603. return;
  11604. }
  11605. nodesToVisit.push(obj);
  11606. next();
  11607. }, capability.reject);
  11608. return;
  11609. }
  11610. if (!(0, _primitives.isDict)(currentNode)) {
  11611. capability.reject(new _util.FormatError('page dictionary kid reference points to wrong type of object'));
  11612. return;
  11613. }
  11614. count = currentNode.get('Count');
  11615. var objId = currentNode.objId;
  11616. if (objId && !pageKidsCountCache.has(objId)) {
  11617. pageKidsCountCache.put(objId, count);
  11618. }
  11619. if (currentPageIndex + count <= pageIndex) {
  11620. currentPageIndex += count;
  11621. continue;
  11622. }
  11623. var kids = currentNode.get('Kids');
  11624. if (!Array.isArray(kids)) {
  11625. capability.reject(new _util.FormatError('page dictionary kids object is not an array'));
  11626. return;
  11627. }
  11628. for (var last = kids.length - 1; last >= 0; last--) {
  11629. nodesToVisit.push(kids[last]);
  11630. }
  11631. }
  11632. capability.reject(new Error('Page index ' + pageIndex + ' not found.'));
  11633. }
  11634. next();
  11635. return capability.promise;
  11636. },
  11637. getPageIndex: function Catalog_getPageIndex(pageRef) {
  11638. var xref = this.xref;
  11639. function pagesBeforeRef(kidRef) {
  11640. var total = 0;
  11641. var parentRef;
  11642. return xref.fetchAsync(kidRef).then(function (node) {
  11643. if ((0, _primitives.isRefsEqual)(kidRef, pageRef) && !(0, _primitives.isDict)(node, 'Page') && !((0, _primitives.isDict)(node) && !node.has('Type') && node.has('Contents'))) {
  11644. throw new _util.FormatError('The reference does not point to a /Page Dict.');
  11645. }
  11646. if (!node) {
  11647. return null;
  11648. }
  11649. if (!(0, _primitives.isDict)(node)) {
  11650. throw new _util.FormatError('node must be a Dict.');
  11651. }
  11652. parentRef = node.getRaw('Parent');
  11653. return node.getAsync('Parent');
  11654. }).then(function (parent) {
  11655. if (!parent) {
  11656. return null;
  11657. }
  11658. if (!(0, _primitives.isDict)(parent)) {
  11659. throw new _util.FormatError('parent must be a Dict.');
  11660. }
  11661. return parent.getAsync('Kids');
  11662. }).then(function (kids) {
  11663. if (!kids) {
  11664. return null;
  11665. }
  11666. var kidPromises = [];
  11667. var found = false;
  11668. for (var i = 0; i < kids.length; i++) {
  11669. var kid = kids[i];
  11670. if (!(0, _primitives.isRef)(kid)) {
  11671. throw new _util.FormatError('kid must be a Ref.');
  11672. }
  11673. if (kid.num === kidRef.num) {
  11674. found = true;
  11675. break;
  11676. }
  11677. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  11678. if (kid.has('Count')) {
  11679. var count = kid.get('Count');
  11680. total += count;
  11681. } else {
  11682. total++;
  11683. }
  11684. }));
  11685. }
  11686. if (!found) {
  11687. throw new _util.FormatError('kid ref not found in parents kids');
  11688. }
  11689. return Promise.all(kidPromises).then(function () {
  11690. return [total, parentRef];
  11691. });
  11692. });
  11693. }
  11694. var total = 0;
  11695. function next(ref) {
  11696. return pagesBeforeRef(ref).then(function (args) {
  11697. if (!args) {
  11698. return total;
  11699. }
  11700. var count = args[0];
  11701. var parentRef = args[1];
  11702. total += count;
  11703. return next(parentRef);
  11704. });
  11705. }
  11706. return next(pageRef);
  11707. }
  11708. };
  11709. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  11710. function addDefaultProtocolToUrl(url) {
  11711. if (url.indexOf('www.') === 0) {
  11712. return 'http://' + url;
  11713. }
  11714. return url;
  11715. }
  11716. function tryConvertUrlEncoding(url) {
  11717. try {
  11718. return (0, _util.stringToUTF8String)(url);
  11719. } catch (e) {
  11720. return url;
  11721. }
  11722. }
  11723. var destDict = params.destDict;
  11724. if (!(0, _primitives.isDict)(destDict)) {
  11725. (0, _util.warn)('parseDestDictionary: "destDict" must be a dictionary.');
  11726. return;
  11727. }
  11728. var resultObj = params.resultObj;
  11729. if ((typeof resultObj === 'undefined' ? 'undefined' : _typeof(resultObj)) !== 'object') {
  11730. (0, _util.warn)('parseDestDictionary: "resultObj" must be an object.');
  11731. return;
  11732. }
  11733. var docBaseUrl = params.docBaseUrl || null;
  11734. var action = destDict.get('A'),
  11735. url,
  11736. dest;
  11737. if (!(0, _primitives.isDict)(action) && destDict.has('Dest')) {
  11738. action = destDict.get('Dest');
  11739. }
  11740. if ((0, _primitives.isDict)(action)) {
  11741. var actionType = action.get('S');
  11742. if (!(0, _primitives.isName)(actionType)) {
  11743. (0, _util.warn)('parseDestDictionary: Invalid type in Action dictionary.');
  11744. return;
  11745. }
  11746. var actionName = actionType.name;
  11747. switch (actionName) {
  11748. case 'URI':
  11749. url = action.get('URI');
  11750. if ((0, _primitives.isName)(url)) {
  11751. url = '/' + url.name;
  11752. } else if ((0, _util.isString)(url)) {
  11753. url = addDefaultProtocolToUrl(url);
  11754. }
  11755. break;
  11756. case 'GoTo':
  11757. dest = action.get('D');
  11758. break;
  11759. case 'Launch':
  11760. case 'GoToR':
  11761. var urlDict = action.get('F');
  11762. if ((0, _primitives.isDict)(urlDict)) {
  11763. url = urlDict.get('F') || null;
  11764. } else if ((0, _util.isString)(urlDict)) {
  11765. url = urlDict;
  11766. }
  11767. var remoteDest = action.get('D');
  11768. if (remoteDest) {
  11769. if ((0, _primitives.isName)(remoteDest)) {
  11770. remoteDest = remoteDest.name;
  11771. }
  11772. if ((0, _util.isString)(url)) {
  11773. var baseUrl = url.split('#')[0];
  11774. if ((0, _util.isString)(remoteDest)) {
  11775. url = baseUrl + '#' + remoteDest;
  11776. } else if (Array.isArray(remoteDest)) {
  11777. url = baseUrl + '#' + JSON.stringify(remoteDest);
  11778. }
  11779. }
  11780. }
  11781. var newWindow = action.get('NewWindow');
  11782. if ((0, _util.isBool)(newWindow)) {
  11783. resultObj.newWindow = newWindow;
  11784. }
  11785. break;
  11786. case 'Named':
  11787. var namedAction = action.get('N');
  11788. if ((0, _primitives.isName)(namedAction)) {
  11789. resultObj.action = namedAction.name;
  11790. }
  11791. break;
  11792. case 'JavaScript':
  11793. var jsAction = action.get('JS'),
  11794. js;
  11795. if ((0, _primitives.isStream)(jsAction)) {
  11796. js = (0, _util.bytesToString)(jsAction.getBytes());
  11797. } else if ((0, _util.isString)(jsAction)) {
  11798. js = jsAction;
  11799. }
  11800. if (js) {
  11801. var URL_OPEN_METHODS = ['app.launchURL', 'window.open'];
  11802. var regex = new RegExp('^\\s*(' + URL_OPEN_METHODS.join('|').split('.').join('\\.') + ')\\((?:\'|\")([^\'\"]*)(?:\'|\")(?:,\\s*(\\w+)\\)|\\))', 'i');
  11803. var jsUrl = regex.exec((0, _util.stringToPDFString)(js));
  11804. if (jsUrl && jsUrl[2]) {
  11805. url = jsUrl[2];
  11806. if (jsUrl[3] === 'true' && jsUrl[1] === 'app.launchURL') {
  11807. resultObj.newWindow = true;
  11808. }
  11809. break;
  11810. }
  11811. }
  11812. default:
  11813. (0, _util.warn)('parseDestDictionary: Unsupported Action type "' + actionName + '".');
  11814. break;
  11815. }
  11816. } else if (destDict.has('Dest')) {
  11817. dest = destDict.get('Dest');
  11818. }
  11819. if ((0, _util.isString)(url)) {
  11820. url = tryConvertUrlEncoding(url);
  11821. var absoluteUrl = (0, _util.createValidAbsoluteUrl)(url, docBaseUrl);
  11822. if (absoluteUrl) {
  11823. resultObj.url = absoluteUrl.href;
  11824. }
  11825. resultObj.unsafeUrl = url;
  11826. }
  11827. if (dest) {
  11828. if ((0, _primitives.isName)(dest)) {
  11829. dest = dest.name;
  11830. }
  11831. if ((0, _util.isString)(dest) || Array.isArray(dest)) {
  11832. resultObj.dest = dest;
  11833. }
  11834. }
  11835. };
  11836. return Catalog;
  11837. }();
  11838. var XRef = function XRefClosure() {
  11839. function XRef(stream, pdfManager) {
  11840. this.stream = stream;
  11841. this.pdfManager = pdfManager;
  11842. this.entries = [];
  11843. this.xrefstms = Object.create(null);
  11844. this.cache = [];
  11845. this.stats = {
  11846. streamTypes: [],
  11847. fontTypes: []
  11848. };
  11849. }
  11850. XRef.prototype = {
  11851. setStartXRef: function XRef_setStartXRef(startXRef) {
  11852. this.startXRefQueue = [startXRef];
  11853. },
  11854. parse: function XRef_parse(recoveryMode) {
  11855. var trailerDict;
  11856. if (!recoveryMode) {
  11857. trailerDict = this.readXRef();
  11858. } else {
  11859. (0, _util.warn)('Indexing all PDF objects');
  11860. trailerDict = this.indexObjects();
  11861. }
  11862. trailerDict.assignXref(this);
  11863. this.trailer = trailerDict;
  11864. var encrypt = trailerDict.get('Encrypt');
  11865. if ((0, _primitives.isDict)(encrypt)) {
  11866. var ids = trailerDict.get('ID');
  11867. var fileId = ids && ids.length ? ids[0] : '';
  11868. encrypt.suppressEncryption = true;
  11869. this.encrypt = new _crypto.CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  11870. }
  11871. if (!(this.root = trailerDict.get('Root'))) {
  11872. throw new _util.FormatError('Invalid root reference');
  11873. }
  11874. },
  11875. processXRefTable: function XRef_processXRefTable(parser) {
  11876. if (!('tableState' in this)) {
  11877. this.tableState = {
  11878. entryNum: 0,
  11879. streamPos: parser.lexer.stream.pos,
  11880. parserBuf1: parser.buf1,
  11881. parserBuf2: parser.buf2
  11882. };
  11883. }
  11884. var obj = this.readXRefTable(parser);
  11885. if (!(0, _primitives.isCmd)(obj, 'trailer')) {
  11886. throw new _util.FormatError('Invalid XRef table: could not find trailer dictionary');
  11887. }
  11888. var dict = parser.getObj();
  11889. if (!(0, _primitives.isDict)(dict) && dict.dict) {
  11890. dict = dict.dict;
  11891. }
  11892. if (!(0, _primitives.isDict)(dict)) {
  11893. throw new _util.FormatError('Invalid XRef table: could not parse trailer dictionary');
  11894. }
  11895. delete this.tableState;
  11896. return dict;
  11897. },
  11898. readXRefTable: function XRef_readXRefTable(parser) {
  11899. var stream = parser.lexer.stream;
  11900. var tableState = this.tableState;
  11901. stream.pos = tableState.streamPos;
  11902. parser.buf1 = tableState.parserBuf1;
  11903. parser.buf2 = tableState.parserBuf2;
  11904. var obj;
  11905. while (true) {
  11906. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  11907. if ((0, _primitives.isCmd)(obj = parser.getObj(), 'trailer')) {
  11908. break;
  11909. }
  11910. tableState.firstEntryNum = obj;
  11911. tableState.entryCount = parser.getObj();
  11912. }
  11913. var first = tableState.firstEntryNum;
  11914. var count = tableState.entryCount;
  11915. if (!Number.isInteger(first) || !Number.isInteger(count)) {
  11916. throw new _util.FormatError('Invalid XRef table: wrong types in subsection header');
  11917. }
  11918. for (var i = tableState.entryNum; i < count; i++) {
  11919. tableState.streamPos = stream.pos;
  11920. tableState.entryNum = i;
  11921. tableState.parserBuf1 = parser.buf1;
  11922. tableState.parserBuf2 = parser.buf2;
  11923. var entry = {};
  11924. entry.offset = parser.getObj();
  11925. entry.gen = parser.getObj();
  11926. var type = parser.getObj();
  11927. if ((0, _primitives.isCmd)(type, 'f')) {
  11928. entry.free = true;
  11929. } else if ((0, _primitives.isCmd)(type, 'n')) {
  11930. entry.uncompressed = true;
  11931. }
  11932. if (!Number.isInteger(entry.offset) || !Number.isInteger(entry.gen) || !(entry.free || entry.uncompressed)) {
  11933. throw new _util.FormatError('Invalid entry in XRef subsection: ' + first + ', ' + count);
  11934. }
  11935. if (i === 0 && entry.free && first === 1) {
  11936. first = 0;
  11937. }
  11938. if (!this.entries[i + first]) {
  11939. this.entries[i + first] = entry;
  11940. }
  11941. }
  11942. tableState.entryNum = 0;
  11943. tableState.streamPos = stream.pos;
  11944. tableState.parserBuf1 = parser.buf1;
  11945. tableState.parserBuf2 = parser.buf2;
  11946. delete tableState.firstEntryNum;
  11947. delete tableState.entryCount;
  11948. }
  11949. if (this.entries[0] && !this.entries[0].free) {
  11950. throw new _util.FormatError('Invalid XRef table: unexpected first object');
  11951. }
  11952. return obj;
  11953. },
  11954. processXRefStream: function XRef_processXRefStream(stream) {
  11955. if (!('streamState' in this)) {
  11956. var streamParameters = stream.dict;
  11957. var byteWidths = streamParameters.get('W');
  11958. var range = streamParameters.get('Index');
  11959. if (!range) {
  11960. range = [0, streamParameters.get('Size')];
  11961. }
  11962. this.streamState = {
  11963. entryRanges: range,
  11964. byteWidths: byteWidths,
  11965. entryNum: 0,
  11966. streamPos: stream.pos
  11967. };
  11968. }
  11969. this.readXRefStream(stream);
  11970. delete this.streamState;
  11971. return stream.dict;
  11972. },
  11973. readXRefStream: function XRef_readXRefStream(stream) {
  11974. var i, j;
  11975. var streamState = this.streamState;
  11976. stream.pos = streamState.streamPos;
  11977. var byteWidths = streamState.byteWidths;
  11978. var typeFieldWidth = byteWidths[0];
  11979. var offsetFieldWidth = byteWidths[1];
  11980. var generationFieldWidth = byteWidths[2];
  11981. var entryRanges = streamState.entryRanges;
  11982. while (entryRanges.length > 0) {
  11983. var first = entryRanges[0];
  11984. var n = entryRanges[1];
  11985. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  11986. throw new _util.FormatError('Invalid XRef range fields: ' + first + ', ' + n);
  11987. }
  11988. if (!Number.isInteger(typeFieldWidth) || !Number.isInteger(offsetFieldWidth) || !Number.isInteger(generationFieldWidth)) {
  11989. throw new _util.FormatError('Invalid XRef entry fields length: ' + first + ', ' + n);
  11990. }
  11991. for (i = streamState.entryNum; i < n; ++i) {
  11992. streamState.entryNum = i;
  11993. streamState.streamPos = stream.pos;
  11994. var type = 0,
  11995. offset = 0,
  11996. generation = 0;
  11997. for (j = 0; j < typeFieldWidth; ++j) {
  11998. type = type << 8 | stream.getByte();
  11999. }
  12000. if (typeFieldWidth === 0) {
  12001. type = 1;
  12002. }
  12003. for (j = 0; j < offsetFieldWidth; ++j) {
  12004. offset = offset << 8 | stream.getByte();
  12005. }
  12006. for (j = 0; j < generationFieldWidth; ++j) {
  12007. generation = generation << 8 | stream.getByte();
  12008. }
  12009. var entry = {};
  12010. entry.offset = offset;
  12011. entry.gen = generation;
  12012. switch (type) {
  12013. case 0:
  12014. entry.free = true;
  12015. break;
  12016. case 1:
  12017. entry.uncompressed = true;
  12018. break;
  12019. case 2:
  12020. break;
  12021. default:
  12022. throw new _util.FormatError('Invalid XRef entry type: ' + type);
  12023. }
  12024. if (!this.entries[first + i]) {
  12025. this.entries[first + i] = entry;
  12026. }
  12027. }
  12028. streamState.entryNum = 0;
  12029. streamState.streamPos = stream.pos;
  12030. entryRanges.splice(0, 2);
  12031. }
  12032. },
  12033. indexObjects: function XRef_indexObjects() {
  12034. var TAB = 0x9,
  12035. LF = 0xA,
  12036. CR = 0xD,
  12037. SPACE = 0x20;
  12038. var PERCENT = 0x25,
  12039. LT = 0x3C;
  12040. function readToken(data, offset) {
  12041. var token = '',
  12042. ch = data[offset];
  12043. while (ch !== LF && ch !== CR && ch !== LT) {
  12044. if (++offset >= data.length) {
  12045. break;
  12046. }
  12047. token += String.fromCharCode(ch);
  12048. ch = data[offset];
  12049. }
  12050. return token;
  12051. }
  12052. function skipUntil(data, offset, what) {
  12053. var length = what.length,
  12054. dataLength = data.length;
  12055. var skipped = 0;
  12056. while (offset < dataLength) {
  12057. var i = 0;
  12058. while (i < length && data[offset + i] === what[i]) {
  12059. ++i;
  12060. }
  12061. if (i >= length) {
  12062. break;
  12063. }
  12064. offset++;
  12065. skipped++;
  12066. }
  12067. return skipped;
  12068. }
  12069. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  12070. var trailerBytes = new Uint8Array([116, 114, 97, 105, 108, 101, 114]);
  12071. var startxrefBytes = new Uint8Array([115, 116, 97, 114, 116, 120, 114, 101, 102]);
  12072. var endobjBytes = new Uint8Array([101, 110, 100, 111, 98, 106]);
  12073. var xrefBytes = new Uint8Array([47, 88, 82, 101, 102]);
  12074. this.entries.length = 0;
  12075. var stream = this.stream;
  12076. stream.pos = 0;
  12077. var buffer = stream.getBytes();
  12078. var position = stream.start,
  12079. length = buffer.length;
  12080. var trailers = [],
  12081. xrefStms = [];
  12082. while (position < length) {
  12083. var ch = buffer[position];
  12084. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  12085. ++position;
  12086. continue;
  12087. }
  12088. if (ch === PERCENT) {
  12089. do {
  12090. ++position;
  12091. if (position >= length) {
  12092. break;
  12093. }
  12094. ch = buffer[position];
  12095. } while (ch !== LF && ch !== CR);
  12096. continue;
  12097. }
  12098. var token = readToken(buffer, position);
  12099. var m;
  12100. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  12101. position += skipUntil(buffer, position, trailerBytes);
  12102. trailers.push(position);
  12103. position += skipUntil(buffer, position, startxrefBytes);
  12104. } else if (m = objRegExp.exec(token)) {
  12105. if (typeof this.entries[m[1]] === 'undefined') {
  12106. this.entries[m[1]] = {
  12107. offset: position - stream.start,
  12108. gen: m[2] | 0,
  12109. uncompressed: true
  12110. };
  12111. }
  12112. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  12113. var content = buffer.subarray(position, position + contentLength);
  12114. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  12115. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  12116. xrefStms.push(position - stream.start);
  12117. this.xrefstms[position - stream.start] = 1;
  12118. }
  12119. position += contentLength;
  12120. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  12121. trailers.push(position);
  12122. position += skipUntil(buffer, position, startxrefBytes);
  12123. } else {
  12124. position += token.length + 1;
  12125. }
  12126. }
  12127. var i, ii;
  12128. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  12129. this.startXRefQueue.push(xrefStms[i]);
  12130. this.readXRef(true);
  12131. }
  12132. var dict;
  12133. for (i = 0, ii = trailers.length; i < ii; ++i) {
  12134. stream.pos = trailers[i];
  12135. var parser = new _parser.Parser(new _parser.Lexer(stream), true, this, true);
  12136. var obj = parser.getObj();
  12137. if (!(0, _primitives.isCmd)(obj, 'trailer')) {
  12138. continue;
  12139. }
  12140. dict = parser.getObj();
  12141. if (!(0, _primitives.isDict)(dict)) {
  12142. continue;
  12143. }
  12144. if (dict.has('ID')) {
  12145. return dict;
  12146. }
  12147. }
  12148. if (dict) {
  12149. return dict;
  12150. }
  12151. throw new _util.InvalidPDFException('Invalid PDF structure');
  12152. },
  12153. readXRef: function XRef_readXRef(recoveryMode) {
  12154. var stream = this.stream;
  12155. var startXRefParsedCache = Object.create(null);
  12156. try {
  12157. while (this.startXRefQueue.length) {
  12158. var startXRef = this.startXRefQueue[0];
  12159. if (startXRefParsedCache[startXRef]) {
  12160. (0, _util.warn)('readXRef - skipping XRef table since it was already parsed.');
  12161. this.startXRefQueue.shift();
  12162. continue;
  12163. }
  12164. startXRefParsedCache[startXRef] = true;
  12165. stream.pos = startXRef + stream.start;
  12166. var parser = new _parser.Parser(new _parser.Lexer(stream), true, this);
  12167. var obj = parser.getObj();
  12168. var dict;
  12169. if ((0, _primitives.isCmd)(obj, 'xref')) {
  12170. dict = this.processXRefTable(parser);
  12171. if (!this.topDict) {
  12172. this.topDict = dict;
  12173. }
  12174. obj = dict.get('XRefStm');
  12175. if (Number.isInteger(obj)) {
  12176. var pos = obj;
  12177. if (!(pos in this.xrefstms)) {
  12178. this.xrefstms[pos] = 1;
  12179. this.startXRefQueue.push(pos);
  12180. }
  12181. }
  12182. } else if (Number.isInteger(obj)) {
  12183. if (!Number.isInteger(parser.getObj()) || !(0, _primitives.isCmd)(parser.getObj(), 'obj') || !(0, _primitives.isStream)(obj = parser.getObj())) {
  12184. throw new _util.FormatError('Invalid XRef stream');
  12185. }
  12186. dict = this.processXRefStream(obj);
  12187. if (!this.topDict) {
  12188. this.topDict = dict;
  12189. }
  12190. if (!dict) {
  12191. throw new _util.FormatError('Failed to read XRef stream');
  12192. }
  12193. } else {
  12194. throw new _util.FormatError('Invalid XRef stream header');
  12195. }
  12196. obj = dict.get('Prev');
  12197. if (Number.isInteger(obj)) {
  12198. this.startXRefQueue.push(obj);
  12199. } else if ((0, _primitives.isRef)(obj)) {
  12200. this.startXRefQueue.push(obj.num);
  12201. }
  12202. this.startXRefQueue.shift();
  12203. }
  12204. return this.topDict;
  12205. } catch (e) {
  12206. if (e instanceof _util.MissingDataException) {
  12207. throw e;
  12208. }
  12209. (0, _util.info)('(while reading XRef): ' + e);
  12210. }
  12211. if (recoveryMode) {
  12212. return;
  12213. }
  12214. throw new _util.XRefParseException();
  12215. },
  12216. getEntry: function XRef_getEntry(i) {
  12217. var xrefEntry = this.entries[i];
  12218. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  12219. return xrefEntry;
  12220. }
  12221. return null;
  12222. },
  12223. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  12224. if (!(0, _primitives.isRef)(obj)) {
  12225. return obj;
  12226. }
  12227. return this.fetch(obj, suppressEncryption);
  12228. },
  12229. fetch: function XRef_fetch(ref, suppressEncryption) {
  12230. if (!(0, _primitives.isRef)(ref)) {
  12231. throw new Error('ref object is not a reference');
  12232. }
  12233. var num = ref.num;
  12234. if (num in this.cache) {
  12235. var cacheEntry = this.cache[num];
  12236. if (cacheEntry instanceof _primitives.Dict && !cacheEntry.objId) {
  12237. cacheEntry.objId = ref.toString();
  12238. }
  12239. return cacheEntry;
  12240. }
  12241. var xrefEntry = this.getEntry(num);
  12242. if (xrefEntry === null) {
  12243. return this.cache[num] = null;
  12244. }
  12245. if (xrefEntry.uncompressed) {
  12246. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  12247. } else {
  12248. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  12249. }
  12250. if ((0, _primitives.isDict)(xrefEntry)) {
  12251. xrefEntry.objId = ref.toString();
  12252. } else if ((0, _primitives.isStream)(xrefEntry)) {
  12253. xrefEntry.dict.objId = ref.toString();
  12254. }
  12255. return xrefEntry;
  12256. },
  12257. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  12258. var gen = ref.gen;
  12259. var num = ref.num;
  12260. if (xrefEntry.gen !== gen) {
  12261. throw new _util.FormatError('inconsistent generation in XRef');
  12262. }
  12263. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  12264. var parser = new _parser.Parser(new _parser.Lexer(stream), true, this);
  12265. var obj1 = parser.getObj();
  12266. var obj2 = parser.getObj();
  12267. var obj3 = parser.getObj();
  12268. if (!Number.isInteger(obj1)) {
  12269. obj1 = parseInt(obj1, 10);
  12270. }
  12271. if (!Number.isInteger(obj2)) {
  12272. obj2 = parseInt(obj2, 10);
  12273. }
  12274. if (obj1 !== num || obj2 !== gen || !(0, _primitives.isCmd)(obj3)) {
  12275. throw new _util.FormatError('bad XRef entry');
  12276. }
  12277. if (obj3.cmd !== 'obj') {
  12278. if (obj3.cmd.indexOf('obj') === 0) {
  12279. num = parseInt(obj3.cmd.substring(3), 10);
  12280. if (!Number.isNaN(num)) {
  12281. return num;
  12282. }
  12283. }
  12284. throw new _util.FormatError('bad XRef entry');
  12285. }
  12286. if (this.encrypt && !suppressEncryption) {
  12287. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  12288. } else {
  12289. xrefEntry = parser.getObj();
  12290. }
  12291. if (!(0, _primitives.isStream)(xrefEntry)) {
  12292. this.cache[num] = xrefEntry;
  12293. }
  12294. return xrefEntry;
  12295. },
  12296. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  12297. var tableOffset = xrefEntry.offset;
  12298. var stream = this.fetch(new _primitives.Ref(tableOffset, 0));
  12299. if (!(0, _primitives.isStream)(stream)) {
  12300. throw new _util.FormatError('bad ObjStm stream');
  12301. }
  12302. var first = stream.dict.get('First');
  12303. var n = stream.dict.get('N');
  12304. if (!Number.isInteger(first) || !Number.isInteger(n)) {
  12305. throw new _util.FormatError('invalid first and n parameters for ObjStm stream');
  12306. }
  12307. var parser = new _parser.Parser(new _parser.Lexer(stream), false, this);
  12308. parser.allowStreams = true;
  12309. var i,
  12310. entries = [],
  12311. num,
  12312. nums = [];
  12313. for (i = 0; i < n; ++i) {
  12314. num = parser.getObj();
  12315. if (!Number.isInteger(num)) {
  12316. throw new _util.FormatError('invalid object number in the ObjStm stream: ' + num);
  12317. }
  12318. nums.push(num);
  12319. var offset = parser.getObj();
  12320. if (!Number.isInteger(offset)) {
  12321. throw new _util.FormatError('invalid object offset in the ObjStm stream: ' + offset);
  12322. }
  12323. }
  12324. for (i = 0; i < n; ++i) {
  12325. entries.push(parser.getObj());
  12326. if ((0, _primitives.isCmd)(parser.buf1, 'endobj')) {
  12327. parser.shift();
  12328. }
  12329. num = nums[i];
  12330. var entry = this.entries[num];
  12331. if (entry && entry.offset === tableOffset && entry.gen === i) {
  12332. this.cache[num] = entries[i];
  12333. }
  12334. }
  12335. xrefEntry = entries[xrefEntry.gen];
  12336. if (xrefEntry === undefined) {
  12337. throw new _util.FormatError('bad XRef entry for compressed object');
  12338. }
  12339. return xrefEntry;
  12340. },
  12341. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  12342. if (!(0, _primitives.isRef)(obj)) {
  12343. return Promise.resolve(obj);
  12344. }
  12345. return this.fetchAsync(obj, suppressEncryption);
  12346. },
  12347. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  12348. var streamManager = this.stream.manager;
  12349. var xref = this;
  12350. return new Promise(function tryFetch(resolve, reject) {
  12351. try {
  12352. resolve(xref.fetch(ref, suppressEncryption));
  12353. } catch (e) {
  12354. if (e instanceof _util.MissingDataException) {
  12355. streamManager.requestRange(e.begin, e.end).then(function () {
  12356. tryFetch(resolve, reject);
  12357. }, reject);
  12358. return;
  12359. }
  12360. reject(e);
  12361. }
  12362. });
  12363. },
  12364. getCatalogObj: function XRef_getCatalogObj() {
  12365. return this.root;
  12366. }
  12367. };
  12368. return XRef;
  12369. }();
  12370. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  12371. function NameOrNumberTree(root, xref) {
  12372. throw new Error('Cannot initialize NameOrNumberTree.');
  12373. }
  12374. NameOrNumberTree.prototype = {
  12375. getAll: function NameOrNumberTree_getAll() {
  12376. var dict = Object.create(null);
  12377. if (!this.root) {
  12378. return dict;
  12379. }
  12380. var xref = this.xref;
  12381. var processed = new _primitives.RefSet();
  12382. processed.put(this.root);
  12383. var queue = [this.root];
  12384. while (queue.length > 0) {
  12385. var i, n;
  12386. var obj = xref.fetchIfRef(queue.shift());
  12387. if (!(0, _primitives.isDict)(obj)) {
  12388. continue;
  12389. }
  12390. if (obj.has('Kids')) {
  12391. var kids = obj.get('Kids');
  12392. for (i = 0, n = kids.length; i < n; i++) {
  12393. var kid = kids[i];
  12394. if (processed.has(kid)) {
  12395. throw new _util.FormatError('Duplicate entry in "' + this._type + '" tree.');
  12396. }
  12397. queue.push(kid);
  12398. processed.put(kid);
  12399. }
  12400. continue;
  12401. }
  12402. var entries = obj.get(this._type);
  12403. if (Array.isArray(entries)) {
  12404. for (i = 0, n = entries.length; i < n; i += 2) {
  12405. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  12406. }
  12407. }
  12408. }
  12409. return dict;
  12410. },
  12411. get: function NameOrNumberTree_get(key) {
  12412. if (!this.root) {
  12413. return null;
  12414. }
  12415. var xref = this.xref;
  12416. var kidsOrEntries = xref.fetchIfRef(this.root);
  12417. var loopCount = 0;
  12418. var MAX_LEVELS = 10;
  12419. var l, r, m;
  12420. while (kidsOrEntries.has('Kids')) {
  12421. if (++loopCount > MAX_LEVELS) {
  12422. (0, _util.warn)('Search depth limit reached for "' + this._type + '" tree.');
  12423. return null;
  12424. }
  12425. var kids = kidsOrEntries.get('Kids');
  12426. if (!Array.isArray(kids)) {
  12427. return null;
  12428. }
  12429. l = 0;
  12430. r = kids.length - 1;
  12431. while (l <= r) {
  12432. m = l + r >> 1;
  12433. var kid = xref.fetchIfRef(kids[m]);
  12434. var limits = kid.get('Limits');
  12435. if (key < xref.fetchIfRef(limits[0])) {
  12436. r = m - 1;
  12437. } else if (key > xref.fetchIfRef(limits[1])) {
  12438. l = m + 1;
  12439. } else {
  12440. kidsOrEntries = xref.fetchIfRef(kids[m]);
  12441. break;
  12442. }
  12443. }
  12444. if (l > r) {
  12445. return null;
  12446. }
  12447. }
  12448. var entries = kidsOrEntries.get(this._type);
  12449. if (Array.isArray(entries)) {
  12450. l = 0;
  12451. r = entries.length - 2;
  12452. while (l <= r) {
  12453. m = l + r & ~1;
  12454. var currentKey = xref.fetchIfRef(entries[m]);
  12455. if (key < currentKey) {
  12456. r = m - 2;
  12457. } else if (key > currentKey) {
  12458. l = m + 2;
  12459. } else {
  12460. return xref.fetchIfRef(entries[m + 1]);
  12461. }
  12462. }
  12463. }
  12464. return null;
  12465. }
  12466. };
  12467. return NameOrNumberTree;
  12468. }();
  12469. var NameTree = function NameTreeClosure() {
  12470. function NameTree(root, xref) {
  12471. this.root = root;
  12472. this.xref = xref;
  12473. this._type = 'Names';
  12474. }
  12475. _util.Util.inherit(NameTree, NameOrNumberTree, {});
  12476. return NameTree;
  12477. }();
  12478. var NumberTree = function NumberTreeClosure() {
  12479. function NumberTree(root, xref) {
  12480. this.root = root;
  12481. this.xref = xref;
  12482. this._type = 'Nums';
  12483. }
  12484. _util.Util.inherit(NumberTree, NameOrNumberTree, {});
  12485. return NumberTree;
  12486. }();
  12487. var FileSpec = function FileSpecClosure() {
  12488. function FileSpec(root, xref) {
  12489. if (!root || !(0, _primitives.isDict)(root)) {
  12490. return;
  12491. }
  12492. this.xref = xref;
  12493. this.root = root;
  12494. if (root.has('FS')) {
  12495. this.fs = root.get('FS');
  12496. }
  12497. this.description = root.has('Desc') ? (0, _util.stringToPDFString)(root.get('Desc')) : '';
  12498. if (root.has('RF')) {
  12499. (0, _util.warn)('Related file specifications are not supported');
  12500. }
  12501. this.contentAvailable = true;
  12502. if (!root.has('EF')) {
  12503. this.contentAvailable = false;
  12504. (0, _util.warn)('Non-embedded file specifications are not supported');
  12505. }
  12506. }
  12507. function pickPlatformItem(dict) {
  12508. if (dict.has('UF')) {
  12509. return dict.get('UF');
  12510. } else if (dict.has('F')) {
  12511. return dict.get('F');
  12512. } else if (dict.has('Unix')) {
  12513. return dict.get('Unix');
  12514. } else if (dict.has('Mac')) {
  12515. return dict.get('Mac');
  12516. } else if (dict.has('DOS')) {
  12517. return dict.get('DOS');
  12518. }
  12519. return null;
  12520. }
  12521. FileSpec.prototype = {
  12522. get filename() {
  12523. if (!this._filename && this.root) {
  12524. var filename = pickPlatformItem(this.root) || 'unnamed';
  12525. this._filename = (0, _util.stringToPDFString)(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  12526. }
  12527. return this._filename;
  12528. },
  12529. get content() {
  12530. if (!this.contentAvailable) {
  12531. return null;
  12532. }
  12533. if (!this.contentRef && this.root) {
  12534. this.contentRef = pickPlatformItem(this.root.get('EF'));
  12535. }
  12536. var content = null;
  12537. if (this.contentRef) {
  12538. var xref = this.xref;
  12539. var fileObj = xref.fetchIfRef(this.contentRef);
  12540. if (fileObj && (0, _primitives.isStream)(fileObj)) {
  12541. content = fileObj.getBytes();
  12542. } else {
  12543. (0, _util.warn)('Embedded file specification points to non-existing/invalid ' + 'content');
  12544. }
  12545. } else {
  12546. (0, _util.warn)('Embedded file specification does not have a content');
  12547. }
  12548. return content;
  12549. },
  12550. get serializable() {
  12551. return {
  12552. filename: this.filename,
  12553. content: this.content
  12554. };
  12555. }
  12556. };
  12557. return FileSpec;
  12558. }();
  12559. var ObjectLoader = function () {
  12560. function mayHaveChildren(value) {
  12561. return (0, _primitives.isRef)(value) || (0, _primitives.isDict)(value) || Array.isArray(value) || (0, _primitives.isStream)(value);
  12562. }
  12563. function addChildren(node, nodesToVisit) {
  12564. if ((0, _primitives.isDict)(node) || (0, _primitives.isStream)(node)) {
  12565. var dict = (0, _primitives.isDict)(node) ? node : node.dict;
  12566. var dictKeys = dict.getKeys();
  12567. for (var i = 0, ii = dictKeys.length; i < ii; i++) {
  12568. var rawValue = dict.getRaw(dictKeys[i]);
  12569. if (mayHaveChildren(rawValue)) {
  12570. nodesToVisit.push(rawValue);
  12571. }
  12572. }
  12573. } else if (Array.isArray(node)) {
  12574. for (var _i = 0, _ii = node.length; _i < _ii; _i++) {
  12575. var value = node[_i];
  12576. if (mayHaveChildren(value)) {
  12577. nodesToVisit.push(value);
  12578. }
  12579. }
  12580. }
  12581. }
  12582. function ObjectLoader(dict, keys, xref) {
  12583. this.dict = dict;
  12584. this.keys = keys;
  12585. this.xref = xref;
  12586. this.refSet = null;
  12587. this.capability = null;
  12588. }
  12589. ObjectLoader.prototype = {
  12590. load: function load() {
  12591. this.capability = (0, _util.createPromiseCapability)();
  12592. if (!(this.xref.stream instanceof _chunked_stream.ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  12593. this.capability.resolve();
  12594. return this.capability.promise;
  12595. }
  12596. var keys = this.keys,
  12597. dict = this.dict;
  12598. this.refSet = new _primitives.RefSet();
  12599. var nodesToVisit = [];
  12600. for (var i = 0, ii = keys.length; i < ii; i++) {
  12601. var rawValue = dict.getRaw(keys[i]);
  12602. if (rawValue !== undefined) {
  12603. nodesToVisit.push(rawValue);
  12604. }
  12605. }
  12606. this._walk(nodesToVisit);
  12607. return this.capability.promise;
  12608. },
  12609. _walk: function _walk(nodesToVisit) {
  12610. var _this3 = this;
  12611. var nodesToRevisit = [];
  12612. var pendingRequests = [];
  12613. while (nodesToVisit.length) {
  12614. var currentNode = nodesToVisit.pop();
  12615. if ((0, _primitives.isRef)(currentNode)) {
  12616. if (this.refSet.has(currentNode)) {
  12617. continue;
  12618. }
  12619. try {
  12620. this.refSet.put(currentNode);
  12621. currentNode = this.xref.fetch(currentNode);
  12622. } catch (ex) {
  12623. if (!(ex instanceof _util.MissingDataException)) {
  12624. throw ex;
  12625. }
  12626. nodesToRevisit.push(currentNode);
  12627. pendingRequests.push({
  12628. begin: ex.begin,
  12629. end: ex.end
  12630. });
  12631. }
  12632. }
  12633. if (currentNode && currentNode.getBaseStreams) {
  12634. var baseStreams = currentNode.getBaseStreams();
  12635. var foundMissingData = false;
  12636. for (var i = 0, ii = baseStreams.length; i < ii; i++) {
  12637. var stream = baseStreams[i];
  12638. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  12639. foundMissingData = true;
  12640. pendingRequests.push({
  12641. begin: stream.start,
  12642. end: stream.end
  12643. });
  12644. }
  12645. }
  12646. if (foundMissingData) {
  12647. nodesToRevisit.push(currentNode);
  12648. }
  12649. }
  12650. addChildren(currentNode, nodesToVisit);
  12651. }
  12652. if (pendingRequests.length) {
  12653. this.xref.stream.manager.requestRanges(pendingRequests).then(function () {
  12654. for (var _i2 = 0, _ii2 = nodesToRevisit.length; _i2 < _ii2; _i2++) {
  12655. var node = nodesToRevisit[_i2];
  12656. if ((0, _primitives.isRef)(node)) {
  12657. _this3.refSet.remove(node);
  12658. }
  12659. }
  12660. _this3._walk(nodesToRevisit);
  12661. }, this.capability.reject);
  12662. return;
  12663. }
  12664. this.refSet = null;
  12665. this.capability.resolve();
  12666. }
  12667. };
  12668. return ObjectLoader;
  12669. }();
  12670. exports.Catalog = Catalog;
  12671. exports.ObjectLoader = ObjectLoader;
  12672. exports.XRef = XRef;
  12673. exports.FileSpec = FileSpec;
  12674. /***/ }),
  12675. /* 63 */
  12676. /***/ (function(module, exports, __w_pdfjs_require__) {
  12677. "use strict";
  12678. Object.defineProperty(exports, "__esModule", {
  12679. value: true
  12680. });
  12681. exports.JpxImage = undefined;
  12682. var _util = __w_pdfjs_require__(0);
  12683. var _arithmetic_decoder = __w_pdfjs_require__(64);
  12684. var JpxError = function JpxErrorClosure() {
  12685. function JpxError(msg) {
  12686. this.message = 'JPX error: ' + msg;
  12687. }
  12688. JpxError.prototype = new Error();
  12689. JpxError.prototype.name = 'JpxError';
  12690. JpxError.constructor = JpxError;
  12691. return JpxError;
  12692. }();
  12693. var JpxImage = function JpxImageClosure() {
  12694. var SubbandsGainLog2 = {
  12695. 'LL': 0,
  12696. 'LH': 1,
  12697. 'HL': 1,
  12698. 'HH': 2
  12699. };
  12700. function JpxImage() {
  12701. this.failOnCorruptedImage = false;
  12702. }
  12703. JpxImage.prototype = {
  12704. parse: function JpxImage_parse(data) {
  12705. var head = (0, _util.readUint16)(data, 0);
  12706. if (head === 0xFF4F) {
  12707. this.parseCodestream(data, 0, data.length);
  12708. return;
  12709. }
  12710. var position = 0,
  12711. length = data.length;
  12712. while (position < length) {
  12713. var headerSize = 8;
  12714. var lbox = (0, _util.readUint32)(data, position);
  12715. var tbox = (0, _util.readUint32)(data, position + 4);
  12716. position += headerSize;
  12717. if (lbox === 1) {
  12718. lbox = (0, _util.readUint32)(data, position) * 4294967296 + (0, _util.readUint32)(data, position + 4);
  12719. position += 8;
  12720. headerSize += 8;
  12721. }
  12722. if (lbox === 0) {
  12723. lbox = length - position + headerSize;
  12724. }
  12725. if (lbox < headerSize) {
  12726. throw new JpxError('Invalid box field size');
  12727. }
  12728. var dataLength = lbox - headerSize;
  12729. var jumpDataLength = true;
  12730. switch (tbox) {
  12731. case 0x6A703268:
  12732. jumpDataLength = false;
  12733. break;
  12734. case 0x636F6C72:
  12735. var method = data[position];
  12736. if (method === 1) {
  12737. var colorspace = (0, _util.readUint32)(data, position + 3);
  12738. switch (colorspace) {
  12739. case 16:
  12740. case 17:
  12741. case 18:
  12742. break;
  12743. default:
  12744. (0, _util.warn)('Unknown colorspace ' + colorspace);
  12745. break;
  12746. }
  12747. } else if (method === 2) {
  12748. (0, _util.info)('ICC profile not supported');
  12749. }
  12750. break;
  12751. case 0x6A703263:
  12752. this.parseCodestream(data, position, position + dataLength);
  12753. break;
  12754. case 0x6A502020:
  12755. if ((0, _util.readUint32)(data, position) !== 0x0d0a870a) {
  12756. (0, _util.warn)('Invalid JP2 signature');
  12757. }
  12758. break;
  12759. case 0x6A501A1A:
  12760. case 0x66747970:
  12761. case 0x72726571:
  12762. case 0x72657320:
  12763. case 0x69686472:
  12764. break;
  12765. default:
  12766. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  12767. (0, _util.warn)('Unsupported header type ' + tbox + ' (' + headerType + ')');
  12768. break;
  12769. }
  12770. if (jumpDataLength) {
  12771. position += dataLength;
  12772. }
  12773. }
  12774. },
  12775. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  12776. var newByte = stream.getByte();
  12777. while (newByte >= 0) {
  12778. var oldByte = newByte;
  12779. newByte = stream.getByte();
  12780. var code = oldByte << 8 | newByte;
  12781. if (code === 0xFF51) {
  12782. stream.skip(4);
  12783. var Xsiz = stream.getInt32() >>> 0;
  12784. var Ysiz = stream.getInt32() >>> 0;
  12785. var XOsiz = stream.getInt32() >>> 0;
  12786. var YOsiz = stream.getInt32() >>> 0;
  12787. stream.skip(16);
  12788. var Csiz = stream.getUint16();
  12789. this.width = Xsiz - XOsiz;
  12790. this.height = Ysiz - YOsiz;
  12791. this.componentsCount = Csiz;
  12792. this.bitsPerComponent = 8;
  12793. return;
  12794. }
  12795. }
  12796. throw new JpxError('No size marker found in JPX stream');
  12797. },
  12798. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  12799. var context = {};
  12800. var doNotRecover = false;
  12801. try {
  12802. var position = start;
  12803. while (position + 1 < end) {
  12804. var code = (0, _util.readUint16)(data, position);
  12805. position += 2;
  12806. var length = 0,
  12807. j,
  12808. sqcd,
  12809. spqcds,
  12810. spqcdSize,
  12811. scalarExpounded,
  12812. tile;
  12813. switch (code) {
  12814. case 0xFF4F:
  12815. context.mainHeader = true;
  12816. break;
  12817. case 0xFFD9:
  12818. break;
  12819. case 0xFF51:
  12820. length = (0, _util.readUint16)(data, position);
  12821. var siz = {};
  12822. siz.Xsiz = (0, _util.readUint32)(data, position + 4);
  12823. siz.Ysiz = (0, _util.readUint32)(data, position + 8);
  12824. siz.XOsiz = (0, _util.readUint32)(data, position + 12);
  12825. siz.YOsiz = (0, _util.readUint32)(data, position + 16);
  12826. siz.XTsiz = (0, _util.readUint32)(data, position + 20);
  12827. siz.YTsiz = (0, _util.readUint32)(data, position + 24);
  12828. siz.XTOsiz = (0, _util.readUint32)(data, position + 28);
  12829. siz.YTOsiz = (0, _util.readUint32)(data, position + 32);
  12830. var componentsCount = (0, _util.readUint16)(data, position + 36);
  12831. siz.Csiz = componentsCount;
  12832. var components = [];
  12833. j = position + 38;
  12834. for (var i = 0; i < componentsCount; i++) {
  12835. var component = {
  12836. precision: (data[j] & 0x7F) + 1,
  12837. isSigned: !!(data[j] & 0x80),
  12838. XRsiz: data[j + 1],
  12839. YRsiz: data[j + 1]
  12840. };
  12841. calculateComponentDimensions(component, siz);
  12842. components.push(component);
  12843. }
  12844. context.SIZ = siz;
  12845. context.components = components;
  12846. calculateTileGrids(context, components);
  12847. context.QCC = [];
  12848. context.COC = [];
  12849. break;
  12850. case 0xFF5C:
  12851. length = (0, _util.readUint16)(data, position);
  12852. var qcd = {};
  12853. j = position + 2;
  12854. sqcd = data[j++];
  12855. switch (sqcd & 0x1F) {
  12856. case 0:
  12857. spqcdSize = 8;
  12858. scalarExpounded = true;
  12859. break;
  12860. case 1:
  12861. spqcdSize = 16;
  12862. scalarExpounded = false;
  12863. break;
  12864. case 2:
  12865. spqcdSize = 16;
  12866. scalarExpounded = true;
  12867. break;
  12868. default:
  12869. throw new Error('Invalid SQcd value ' + sqcd);
  12870. }
  12871. qcd.noQuantization = spqcdSize === 8;
  12872. qcd.scalarExpounded = scalarExpounded;
  12873. qcd.guardBits = sqcd >> 5;
  12874. spqcds = [];
  12875. while (j < length + position) {
  12876. var spqcd = {};
  12877. if (spqcdSize === 8) {
  12878. spqcd.epsilon = data[j++] >> 3;
  12879. spqcd.mu = 0;
  12880. } else {
  12881. spqcd.epsilon = data[j] >> 3;
  12882. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  12883. j += 2;
  12884. }
  12885. spqcds.push(spqcd);
  12886. }
  12887. qcd.SPqcds = spqcds;
  12888. if (context.mainHeader) {
  12889. context.QCD = qcd;
  12890. } else {
  12891. context.currentTile.QCD = qcd;
  12892. context.currentTile.QCC = [];
  12893. }
  12894. break;
  12895. case 0xFF5D:
  12896. length = (0, _util.readUint16)(data, position);
  12897. var qcc = {};
  12898. j = position + 2;
  12899. var cqcc;
  12900. if (context.SIZ.Csiz < 257) {
  12901. cqcc = data[j++];
  12902. } else {
  12903. cqcc = (0, _util.readUint16)(data, j);
  12904. j += 2;
  12905. }
  12906. sqcd = data[j++];
  12907. switch (sqcd & 0x1F) {
  12908. case 0:
  12909. spqcdSize = 8;
  12910. scalarExpounded = true;
  12911. break;
  12912. case 1:
  12913. spqcdSize = 16;
  12914. scalarExpounded = false;
  12915. break;
  12916. case 2:
  12917. spqcdSize = 16;
  12918. scalarExpounded = true;
  12919. break;
  12920. default:
  12921. throw new Error('Invalid SQcd value ' + sqcd);
  12922. }
  12923. qcc.noQuantization = spqcdSize === 8;
  12924. qcc.scalarExpounded = scalarExpounded;
  12925. qcc.guardBits = sqcd >> 5;
  12926. spqcds = [];
  12927. while (j < length + position) {
  12928. spqcd = {};
  12929. if (spqcdSize === 8) {
  12930. spqcd.epsilon = data[j++] >> 3;
  12931. spqcd.mu = 0;
  12932. } else {
  12933. spqcd.epsilon = data[j] >> 3;
  12934. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  12935. j += 2;
  12936. }
  12937. spqcds.push(spqcd);
  12938. }
  12939. qcc.SPqcds = spqcds;
  12940. if (context.mainHeader) {
  12941. context.QCC[cqcc] = qcc;
  12942. } else {
  12943. context.currentTile.QCC[cqcc] = qcc;
  12944. }
  12945. break;
  12946. case 0xFF52:
  12947. length = (0, _util.readUint16)(data, position);
  12948. var cod = {};
  12949. j = position + 2;
  12950. var scod = data[j++];
  12951. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  12952. cod.sopMarkerUsed = !!(scod & 2);
  12953. cod.ephMarkerUsed = !!(scod & 4);
  12954. cod.progressionOrder = data[j++];
  12955. cod.layersCount = (0, _util.readUint16)(data, j);
  12956. j += 2;
  12957. cod.multipleComponentTransform = data[j++];
  12958. cod.decompositionLevelsCount = data[j++];
  12959. cod.xcb = (data[j++] & 0xF) + 2;
  12960. cod.ycb = (data[j++] & 0xF) + 2;
  12961. var blockStyle = data[j++];
  12962. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  12963. cod.resetContextProbabilities = !!(blockStyle & 2);
  12964. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  12965. cod.verticalyStripe = !!(blockStyle & 8);
  12966. cod.predictableTermination = !!(blockStyle & 16);
  12967. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  12968. cod.reversibleTransformation = data[j++];
  12969. if (cod.entropyCoderWithCustomPrecincts) {
  12970. var precinctsSizes = [];
  12971. while (j < length + position) {
  12972. var precinctsSize = data[j++];
  12973. precinctsSizes.push({
  12974. PPx: precinctsSize & 0xF,
  12975. PPy: precinctsSize >> 4
  12976. });
  12977. }
  12978. cod.precinctsSizes = precinctsSizes;
  12979. }
  12980. var unsupported = [];
  12981. if (cod.selectiveArithmeticCodingBypass) {
  12982. unsupported.push('selectiveArithmeticCodingBypass');
  12983. }
  12984. if (cod.resetContextProbabilities) {
  12985. unsupported.push('resetContextProbabilities');
  12986. }
  12987. if (cod.terminationOnEachCodingPass) {
  12988. unsupported.push('terminationOnEachCodingPass');
  12989. }
  12990. if (cod.verticalyStripe) {
  12991. unsupported.push('verticalyStripe');
  12992. }
  12993. if (cod.predictableTermination) {
  12994. unsupported.push('predictableTermination');
  12995. }
  12996. if (unsupported.length > 0) {
  12997. doNotRecover = true;
  12998. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  12999. }
  13000. if (context.mainHeader) {
  13001. context.COD = cod;
  13002. } else {
  13003. context.currentTile.COD = cod;
  13004. context.currentTile.COC = [];
  13005. }
  13006. break;
  13007. case 0xFF90:
  13008. length = (0, _util.readUint16)(data, position);
  13009. tile = {};
  13010. tile.index = (0, _util.readUint16)(data, position + 2);
  13011. tile.length = (0, _util.readUint32)(data, position + 4);
  13012. tile.dataEnd = tile.length + position - 2;
  13013. tile.partIndex = data[position + 8];
  13014. tile.partsCount = data[position + 9];
  13015. context.mainHeader = false;
  13016. if (tile.partIndex === 0) {
  13017. tile.COD = context.COD;
  13018. tile.COC = context.COC.slice(0);
  13019. tile.QCD = context.QCD;
  13020. tile.QCC = context.QCC.slice(0);
  13021. }
  13022. context.currentTile = tile;
  13023. break;
  13024. case 0xFF93:
  13025. tile = context.currentTile;
  13026. if (tile.partIndex === 0) {
  13027. initializeTile(context, tile.index);
  13028. buildPackets(context);
  13029. }
  13030. length = tile.dataEnd - position;
  13031. parseTilePackets(context, data, position, length);
  13032. break;
  13033. case 0xFF55:
  13034. case 0xFF57:
  13035. case 0xFF58:
  13036. case 0xFF64:
  13037. length = (0, _util.readUint16)(data, position);
  13038. break;
  13039. case 0xFF53:
  13040. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  13041. default:
  13042. throw new Error('Unknown codestream code: ' + code.toString(16));
  13043. }
  13044. position += length;
  13045. }
  13046. } catch (e) {
  13047. if (doNotRecover || this.failOnCorruptedImage) {
  13048. throw new JpxError(e.message);
  13049. } else {
  13050. (0, _util.warn)('JPX: Trying to recover from: ' + e.message);
  13051. }
  13052. }
  13053. this.tiles = transformComponents(context);
  13054. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  13055. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  13056. this.componentsCount = context.SIZ.Csiz;
  13057. }
  13058. };
  13059. function calculateComponentDimensions(component, siz) {
  13060. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  13061. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  13062. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  13063. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  13064. component.width = component.x1 - component.x0;
  13065. component.height = component.y1 - component.y0;
  13066. }
  13067. function calculateTileGrids(context, components) {
  13068. var siz = context.SIZ;
  13069. var tile,
  13070. tiles = [];
  13071. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  13072. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  13073. for (var q = 0; q < numYtiles; q++) {
  13074. for (var p = 0; p < numXtiles; p++) {
  13075. tile = {};
  13076. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  13077. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  13078. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  13079. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  13080. tile.width = tile.tx1 - tile.tx0;
  13081. tile.height = tile.ty1 - tile.ty0;
  13082. tile.components = [];
  13083. tiles.push(tile);
  13084. }
  13085. }
  13086. context.tiles = tiles;
  13087. var componentsCount = siz.Csiz;
  13088. for (var i = 0, ii = componentsCount; i < ii; i++) {
  13089. var component = components[i];
  13090. for (var j = 0, jj = tiles.length; j < jj; j++) {
  13091. var tileComponent = {};
  13092. tile = tiles[j];
  13093. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  13094. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  13095. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  13096. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  13097. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  13098. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  13099. tile.components[i] = tileComponent;
  13100. }
  13101. }
  13102. }
  13103. function getBlocksDimensions(context, component, r) {
  13104. var codOrCoc = component.codingStyleParameters;
  13105. var result = {};
  13106. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  13107. result.PPx = 15;
  13108. result.PPy = 15;
  13109. } else {
  13110. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  13111. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  13112. }
  13113. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  13114. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  13115. return result;
  13116. }
  13117. function buildPrecincts(context, resolution, dimensions) {
  13118. var precinctWidth = 1 << dimensions.PPx;
  13119. var precinctHeight = 1 << dimensions.PPy;
  13120. var isZeroRes = resolution.resLevel === 0;
  13121. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  13122. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  13123. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  13124. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  13125. var numprecincts = numprecinctswide * numprecinctshigh;
  13126. resolution.precinctParameters = {
  13127. precinctWidth: precinctWidth,
  13128. precinctHeight: precinctHeight,
  13129. numprecinctswide: numprecinctswide,
  13130. numprecinctshigh: numprecinctshigh,
  13131. numprecincts: numprecincts,
  13132. precinctWidthInSubband: precinctWidthInSubband,
  13133. precinctHeightInSubband: precinctHeightInSubband
  13134. };
  13135. }
  13136. function buildCodeblocks(context, subband, dimensions) {
  13137. var xcb_ = dimensions.xcb_;
  13138. var ycb_ = dimensions.ycb_;
  13139. var codeblockWidth = 1 << xcb_;
  13140. var codeblockHeight = 1 << ycb_;
  13141. var cbx0 = subband.tbx0 >> xcb_;
  13142. var cby0 = subband.tby0 >> ycb_;
  13143. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  13144. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  13145. var precinctParameters = subband.resolution.precinctParameters;
  13146. var codeblocks = [];
  13147. var precincts = [];
  13148. var i, j, codeblock, precinctNumber;
  13149. for (j = cby0; j < cby1; j++) {
  13150. for (i = cbx0; i < cbx1; i++) {
  13151. codeblock = {
  13152. cbx: i,
  13153. cby: j,
  13154. tbx0: codeblockWidth * i,
  13155. tby0: codeblockHeight * j,
  13156. tbx1: codeblockWidth * (i + 1),
  13157. tby1: codeblockHeight * (j + 1)
  13158. };
  13159. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  13160. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  13161. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  13162. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  13163. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  13164. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  13165. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  13166. codeblock.precinctNumber = precinctNumber;
  13167. codeblock.subbandType = subband.type;
  13168. codeblock.Lblock = 3;
  13169. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  13170. continue;
  13171. }
  13172. codeblocks.push(codeblock);
  13173. var precinct = precincts[precinctNumber];
  13174. if (precinct !== undefined) {
  13175. if (i < precinct.cbxMin) {
  13176. precinct.cbxMin = i;
  13177. } else if (i > precinct.cbxMax) {
  13178. precinct.cbxMax = i;
  13179. }
  13180. if (j < precinct.cbyMin) {
  13181. precinct.cbxMin = j;
  13182. } else if (j > precinct.cbyMax) {
  13183. precinct.cbyMax = j;
  13184. }
  13185. } else {
  13186. precincts[precinctNumber] = precinct = {
  13187. cbxMin: i,
  13188. cbyMin: j,
  13189. cbxMax: i,
  13190. cbyMax: j
  13191. };
  13192. }
  13193. codeblock.precinct = precinct;
  13194. }
  13195. }
  13196. subband.codeblockParameters = {
  13197. codeblockWidth: xcb_,
  13198. codeblockHeight: ycb_,
  13199. numcodeblockwide: cbx1 - cbx0 + 1,
  13200. numcodeblockhigh: cby1 - cby0 + 1
  13201. };
  13202. subband.codeblocks = codeblocks;
  13203. subband.precincts = precincts;
  13204. }
  13205. function createPacket(resolution, precinctNumber, layerNumber) {
  13206. var precinctCodeblocks = [];
  13207. var subbands = resolution.subbands;
  13208. for (var i = 0, ii = subbands.length; i < ii; i++) {
  13209. var subband = subbands[i];
  13210. var codeblocks = subband.codeblocks;
  13211. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  13212. var codeblock = codeblocks[j];
  13213. if (codeblock.precinctNumber !== precinctNumber) {
  13214. continue;
  13215. }
  13216. precinctCodeblocks.push(codeblock);
  13217. }
  13218. }
  13219. return {
  13220. layerNumber: layerNumber,
  13221. codeblocks: precinctCodeblocks
  13222. };
  13223. }
  13224. function LayerResolutionComponentPositionIterator(context) {
  13225. var siz = context.SIZ;
  13226. var tileIndex = context.currentTile.index;
  13227. var tile = context.tiles[tileIndex];
  13228. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  13229. var componentsCount = siz.Csiz;
  13230. var maxDecompositionLevelsCount = 0;
  13231. for (var q = 0; q < componentsCount; q++) {
  13232. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  13233. }
  13234. var l = 0,
  13235. r = 0,
  13236. i = 0,
  13237. k = 0;
  13238. this.nextPacket = function JpxImage_nextPacket() {
  13239. for (; l < layersCount; l++) {
  13240. for (; r <= maxDecompositionLevelsCount; r++) {
  13241. for (; i < componentsCount; i++) {
  13242. var component = tile.components[i];
  13243. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  13244. continue;
  13245. }
  13246. var resolution = component.resolutions[r];
  13247. var numprecincts = resolution.precinctParameters.numprecincts;
  13248. for (; k < numprecincts;) {
  13249. var packet = createPacket(resolution, k, l);
  13250. k++;
  13251. return packet;
  13252. }
  13253. k = 0;
  13254. }
  13255. i = 0;
  13256. }
  13257. r = 0;
  13258. }
  13259. throw new JpxError('Out of packets');
  13260. };
  13261. }
  13262. function ResolutionLayerComponentPositionIterator(context) {
  13263. var siz = context.SIZ;
  13264. var tileIndex = context.currentTile.index;
  13265. var tile = context.tiles[tileIndex];
  13266. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  13267. var componentsCount = siz.Csiz;
  13268. var maxDecompositionLevelsCount = 0;
  13269. for (var q = 0; q < componentsCount; q++) {
  13270. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  13271. }
  13272. var r = 0,
  13273. l = 0,
  13274. i = 0,
  13275. k = 0;
  13276. this.nextPacket = function JpxImage_nextPacket() {
  13277. for (; r <= maxDecompositionLevelsCount; r++) {
  13278. for (; l < layersCount; l++) {
  13279. for (; i < componentsCount; i++) {
  13280. var component = tile.components[i];
  13281. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  13282. continue;
  13283. }
  13284. var resolution = component.resolutions[r];
  13285. var numprecincts = resolution.precinctParameters.numprecincts;
  13286. for (; k < numprecincts;) {
  13287. var packet = createPacket(resolution, k, l);
  13288. k++;
  13289. return packet;
  13290. }
  13291. k = 0;
  13292. }
  13293. i = 0;
  13294. }
  13295. l = 0;
  13296. }
  13297. throw new JpxError('Out of packets');
  13298. };
  13299. }
  13300. function ResolutionPositionComponentLayerIterator(context) {
  13301. var siz = context.SIZ;
  13302. var tileIndex = context.currentTile.index;
  13303. var tile = context.tiles[tileIndex];
  13304. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  13305. var componentsCount = siz.Csiz;
  13306. var l, r, c, p;
  13307. var maxDecompositionLevelsCount = 0;
  13308. for (c = 0; c < componentsCount; c++) {
  13309. var component = tile.components[c];
  13310. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  13311. }
  13312. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  13313. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  13314. var maxNumPrecincts = 0;
  13315. for (c = 0; c < componentsCount; ++c) {
  13316. var resolutions = tile.components[c].resolutions;
  13317. if (r < resolutions.length) {
  13318. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  13319. }
  13320. }
  13321. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  13322. }
  13323. l = 0;
  13324. r = 0;
  13325. c = 0;
  13326. p = 0;
  13327. this.nextPacket = function JpxImage_nextPacket() {
  13328. for (; r <= maxDecompositionLevelsCount; r++) {
  13329. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  13330. for (; c < componentsCount; c++) {
  13331. var component = tile.components[c];
  13332. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  13333. continue;
  13334. }
  13335. var resolution = component.resolutions[r];
  13336. var numprecincts = resolution.precinctParameters.numprecincts;
  13337. if (p >= numprecincts) {
  13338. continue;
  13339. }
  13340. for (; l < layersCount;) {
  13341. var packet = createPacket(resolution, p, l);
  13342. l++;
  13343. return packet;
  13344. }
  13345. l = 0;
  13346. }
  13347. c = 0;
  13348. }
  13349. p = 0;
  13350. }
  13351. throw new JpxError('Out of packets');
  13352. };
  13353. }
  13354. function PositionComponentResolutionLayerIterator(context) {
  13355. var siz = context.SIZ;
  13356. var tileIndex = context.currentTile.index;
  13357. var tile = context.tiles[tileIndex];
  13358. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  13359. var componentsCount = siz.Csiz;
  13360. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  13361. var precinctsIterationSizes = precinctsSizes;
  13362. var l = 0,
  13363. r = 0,
  13364. c = 0,
  13365. px = 0,
  13366. py = 0;
  13367. this.nextPacket = function JpxImage_nextPacket() {
  13368. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  13369. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  13370. for (; c < componentsCount; c++) {
  13371. var component = tile.components[c];
  13372. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  13373. for (; r <= decompositionLevelsCount; r++) {
  13374. var resolution = component.resolutions[r];
  13375. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  13376. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  13377. if (k === null) {
  13378. continue;
  13379. }
  13380. for (; l < layersCount;) {
  13381. var packet = createPacket(resolution, k, l);
  13382. l++;
  13383. return packet;
  13384. }
  13385. l = 0;
  13386. }
  13387. r = 0;
  13388. }
  13389. c = 0;
  13390. }
  13391. px = 0;
  13392. }
  13393. throw new JpxError('Out of packets');
  13394. };
  13395. }
  13396. function ComponentPositionResolutionLayerIterator(context) {
  13397. var siz = context.SIZ;
  13398. var tileIndex = context.currentTile.index;
  13399. var tile = context.tiles[tileIndex];
  13400. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  13401. var componentsCount = siz.Csiz;
  13402. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  13403. var l = 0,
  13404. r = 0,
  13405. c = 0,
  13406. px = 0,
  13407. py = 0;
  13408. this.nextPacket = function JpxImage_nextPacket() {
  13409. for (; c < componentsCount; ++c) {
  13410. var component = tile.components[c];
  13411. var precinctsIterationSizes = precinctsSizes.components[c];
  13412. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  13413. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  13414. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  13415. for (; r <= decompositionLevelsCount; r++) {
  13416. var resolution = component.resolutions[r];
  13417. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  13418. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  13419. if (k === null) {
  13420. continue;
  13421. }
  13422. for (; l < layersCount;) {
  13423. var packet = createPacket(resolution, k, l);
  13424. l++;
  13425. return packet;
  13426. }
  13427. l = 0;
  13428. }
  13429. r = 0;
  13430. }
  13431. px = 0;
  13432. }
  13433. py = 0;
  13434. }
  13435. throw new JpxError('Out of packets');
  13436. };
  13437. }
  13438. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  13439. var posX = pxIndex * precinctIterationSizes.minWidth;
  13440. var posY = pyIndex * precinctIterationSizes.minHeight;
  13441. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  13442. return null;
  13443. }
  13444. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  13445. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  13446. }
  13447. function getPrecinctSizesInImageScale(tile) {
  13448. var componentsCount = tile.components.length;
  13449. var minWidth = Number.MAX_VALUE;
  13450. var minHeight = Number.MAX_VALUE;
  13451. var maxNumWide = 0;
  13452. var maxNumHigh = 0;
  13453. var sizePerComponent = new Array(componentsCount);
  13454. for (var c = 0; c < componentsCount; c++) {
  13455. var component = tile.components[c];
  13456. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  13457. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  13458. var minWidthCurrentComponent = Number.MAX_VALUE;
  13459. var minHeightCurrentComponent = Number.MAX_VALUE;
  13460. var maxNumWideCurrentComponent = 0;
  13461. var maxNumHighCurrentComponent = 0;
  13462. var scale = 1;
  13463. for (var r = decompositionLevelsCount; r >= 0; --r) {
  13464. var resolution = component.resolutions[r];
  13465. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  13466. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  13467. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  13468. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  13469. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  13470. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  13471. sizePerResolution[r] = {
  13472. width: widthCurrentResolution,
  13473. height: heightCurrentResolution
  13474. };
  13475. scale <<= 1;
  13476. }
  13477. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  13478. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  13479. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  13480. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  13481. sizePerComponent[c] = {
  13482. resolutions: sizePerResolution,
  13483. minWidth: minWidthCurrentComponent,
  13484. minHeight: minHeightCurrentComponent,
  13485. maxNumWide: maxNumWideCurrentComponent,
  13486. maxNumHigh: maxNumHighCurrentComponent
  13487. };
  13488. }
  13489. return {
  13490. components: sizePerComponent,
  13491. minWidth: minWidth,
  13492. minHeight: minHeight,
  13493. maxNumWide: maxNumWide,
  13494. maxNumHigh: maxNumHigh
  13495. };
  13496. }
  13497. function buildPackets(context) {
  13498. var siz = context.SIZ;
  13499. var tileIndex = context.currentTile.index;
  13500. var tile = context.tiles[tileIndex];
  13501. var componentsCount = siz.Csiz;
  13502. for (var c = 0; c < componentsCount; c++) {
  13503. var component = tile.components[c];
  13504. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  13505. var resolutions = [];
  13506. var subbands = [];
  13507. for (var r = 0; r <= decompositionLevelsCount; r++) {
  13508. var blocksDimensions = getBlocksDimensions(context, component, r);
  13509. var resolution = {};
  13510. var scale = 1 << decompositionLevelsCount - r;
  13511. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  13512. resolution.try0 = Math.ceil(component.tcy0 / scale);
  13513. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  13514. resolution.try1 = Math.ceil(component.tcy1 / scale);
  13515. resolution.resLevel = r;
  13516. buildPrecincts(context, resolution, blocksDimensions);
  13517. resolutions.push(resolution);
  13518. var subband;
  13519. if (r === 0) {
  13520. subband = {};
  13521. subband.type = 'LL';
  13522. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  13523. subband.tby0 = Math.ceil(component.tcy0 / scale);
  13524. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  13525. subband.tby1 = Math.ceil(component.tcy1 / scale);
  13526. subband.resolution = resolution;
  13527. buildCodeblocks(context, subband, blocksDimensions);
  13528. subbands.push(subband);
  13529. resolution.subbands = [subband];
  13530. } else {
  13531. var bscale = 1 << decompositionLevelsCount - r + 1;
  13532. var resolutionSubbands = [];
  13533. subband = {};
  13534. subband.type = 'HL';
  13535. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  13536. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  13537. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  13538. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  13539. subband.resolution = resolution;
  13540. buildCodeblocks(context, subband, blocksDimensions);
  13541. subbands.push(subband);
  13542. resolutionSubbands.push(subband);
  13543. subband = {};
  13544. subband.type = 'LH';
  13545. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  13546. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  13547. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  13548. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  13549. subband.resolution = resolution;
  13550. buildCodeblocks(context, subband, blocksDimensions);
  13551. subbands.push(subband);
  13552. resolutionSubbands.push(subband);
  13553. subband = {};
  13554. subband.type = 'HH';
  13555. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  13556. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  13557. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  13558. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  13559. subband.resolution = resolution;
  13560. buildCodeblocks(context, subband, blocksDimensions);
  13561. subbands.push(subband);
  13562. resolutionSubbands.push(subband);
  13563. resolution.subbands = resolutionSubbands;
  13564. }
  13565. }
  13566. component.resolutions = resolutions;
  13567. component.subbands = subbands;
  13568. }
  13569. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  13570. switch (progressionOrder) {
  13571. case 0:
  13572. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  13573. break;
  13574. case 1:
  13575. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  13576. break;
  13577. case 2:
  13578. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  13579. break;
  13580. case 3:
  13581. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  13582. break;
  13583. case 4:
  13584. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  13585. break;
  13586. default:
  13587. throw new JpxError('Unsupported progression order ' + progressionOrder);
  13588. }
  13589. }
  13590. function parseTilePackets(context, data, offset, dataLength) {
  13591. var position = 0;
  13592. var buffer,
  13593. bufferSize = 0,
  13594. skipNextBit = false;
  13595. function readBits(count) {
  13596. while (bufferSize < count) {
  13597. var b = data[offset + position];
  13598. position++;
  13599. if (skipNextBit) {
  13600. buffer = buffer << 7 | b;
  13601. bufferSize += 7;
  13602. skipNextBit = false;
  13603. } else {
  13604. buffer = buffer << 8 | b;
  13605. bufferSize += 8;
  13606. }
  13607. if (b === 0xFF) {
  13608. skipNextBit = true;
  13609. }
  13610. }
  13611. bufferSize -= count;
  13612. return buffer >>> bufferSize & (1 << count) - 1;
  13613. }
  13614. function skipMarkerIfEqual(value) {
  13615. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  13616. skipBytes(1);
  13617. return true;
  13618. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  13619. skipBytes(2);
  13620. return true;
  13621. }
  13622. return false;
  13623. }
  13624. function skipBytes(count) {
  13625. position += count;
  13626. }
  13627. function alignToByte() {
  13628. bufferSize = 0;
  13629. if (skipNextBit) {
  13630. position++;
  13631. skipNextBit = false;
  13632. }
  13633. }
  13634. function readCodingpasses() {
  13635. if (readBits(1) === 0) {
  13636. return 1;
  13637. }
  13638. if (readBits(1) === 0) {
  13639. return 2;
  13640. }
  13641. var value = readBits(2);
  13642. if (value < 3) {
  13643. return value + 3;
  13644. }
  13645. value = readBits(5);
  13646. if (value < 31) {
  13647. return value + 6;
  13648. }
  13649. value = readBits(7);
  13650. return value + 37;
  13651. }
  13652. var tileIndex = context.currentTile.index;
  13653. var tile = context.tiles[tileIndex];
  13654. var sopMarkerUsed = context.COD.sopMarkerUsed;
  13655. var ephMarkerUsed = context.COD.ephMarkerUsed;
  13656. var packetsIterator = tile.packetsIterator;
  13657. while (position < dataLength) {
  13658. alignToByte();
  13659. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  13660. skipBytes(4);
  13661. }
  13662. var packet = packetsIterator.nextPacket();
  13663. if (!readBits(1)) {
  13664. continue;
  13665. }
  13666. var layerNumber = packet.layerNumber;
  13667. var queue = [],
  13668. codeblock;
  13669. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  13670. codeblock = packet.codeblocks[i];
  13671. var precinct = codeblock.precinct;
  13672. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  13673. var codeblockRow = codeblock.cby - precinct.cbyMin;
  13674. var codeblockIncluded = false;
  13675. var firstTimeInclusion = false;
  13676. var valueReady;
  13677. if (codeblock['included'] !== undefined) {
  13678. codeblockIncluded = !!readBits(1);
  13679. } else {
  13680. precinct = codeblock.precinct;
  13681. var inclusionTree, zeroBitPlanesTree;
  13682. if (precinct['inclusionTree'] !== undefined) {
  13683. inclusionTree = precinct.inclusionTree;
  13684. } else {
  13685. var width = precinct.cbxMax - precinct.cbxMin + 1;
  13686. var height = precinct.cbyMax - precinct.cbyMin + 1;
  13687. inclusionTree = new InclusionTree(width, height, layerNumber);
  13688. zeroBitPlanesTree = new TagTree(width, height);
  13689. precinct.inclusionTree = inclusionTree;
  13690. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  13691. }
  13692. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  13693. while (true) {
  13694. if (readBits(1)) {
  13695. valueReady = !inclusionTree.nextLevel();
  13696. if (valueReady) {
  13697. codeblock.included = true;
  13698. codeblockIncluded = firstTimeInclusion = true;
  13699. break;
  13700. }
  13701. } else {
  13702. inclusionTree.incrementValue(layerNumber);
  13703. break;
  13704. }
  13705. }
  13706. }
  13707. }
  13708. if (!codeblockIncluded) {
  13709. continue;
  13710. }
  13711. if (firstTimeInclusion) {
  13712. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  13713. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  13714. while (true) {
  13715. if (readBits(1)) {
  13716. valueReady = !zeroBitPlanesTree.nextLevel();
  13717. if (valueReady) {
  13718. break;
  13719. }
  13720. } else {
  13721. zeroBitPlanesTree.incrementValue();
  13722. }
  13723. }
  13724. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  13725. }
  13726. var codingpasses = readCodingpasses();
  13727. while (readBits(1)) {
  13728. codeblock.Lblock++;
  13729. }
  13730. var codingpassesLog2 = (0, _util.log2)(codingpasses);
  13731. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  13732. var codedDataLength = readBits(bits);
  13733. queue.push({
  13734. codeblock: codeblock,
  13735. codingpasses: codingpasses,
  13736. dataLength: codedDataLength
  13737. });
  13738. }
  13739. alignToByte();
  13740. if (ephMarkerUsed) {
  13741. skipMarkerIfEqual(0x92);
  13742. }
  13743. while (queue.length > 0) {
  13744. var packetItem = queue.shift();
  13745. codeblock = packetItem.codeblock;
  13746. if (codeblock['data'] === undefined) {
  13747. codeblock.data = [];
  13748. }
  13749. codeblock.data.push({
  13750. data: data,
  13751. start: offset + position,
  13752. end: offset + position + packetItem.dataLength,
  13753. codingpasses: packetItem.codingpasses
  13754. });
  13755. position += packetItem.dataLength;
  13756. }
  13757. }
  13758. return position;
  13759. }
  13760. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  13761. var x0 = subband.tbx0;
  13762. var y0 = subband.tby0;
  13763. var width = subband.tbx1 - subband.tbx0;
  13764. var codeblocks = subband.codeblocks;
  13765. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  13766. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  13767. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  13768. var codeblock = codeblocks[i];
  13769. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  13770. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  13771. if (blockWidth === 0 || blockHeight === 0) {
  13772. continue;
  13773. }
  13774. if (codeblock['data'] === undefined) {
  13775. continue;
  13776. }
  13777. var bitModel, currentCodingpassType;
  13778. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  13779. currentCodingpassType = 2;
  13780. var data = codeblock.data,
  13781. totalLength = 0,
  13782. codingpasses = 0;
  13783. var j, jj, dataItem;
  13784. for (j = 0, jj = data.length; j < jj; j++) {
  13785. dataItem = data[j];
  13786. totalLength += dataItem.end - dataItem.start;
  13787. codingpasses += dataItem.codingpasses;
  13788. }
  13789. var encodedData = new Uint8Array(totalLength);
  13790. var position = 0;
  13791. for (j = 0, jj = data.length; j < jj; j++) {
  13792. dataItem = data[j];
  13793. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  13794. encodedData.set(chunk, position);
  13795. position += chunk.length;
  13796. }
  13797. var decoder = new _arithmetic_decoder.ArithmeticDecoder(encodedData, 0, totalLength);
  13798. bitModel.setDecoder(decoder);
  13799. for (j = 0; j < codingpasses; j++) {
  13800. switch (currentCodingpassType) {
  13801. case 0:
  13802. bitModel.runSignificancePropagationPass();
  13803. break;
  13804. case 1:
  13805. bitModel.runMagnitudeRefinementPass();
  13806. break;
  13807. case 2:
  13808. bitModel.runCleanupPass();
  13809. if (segmentationSymbolUsed) {
  13810. bitModel.checkSegmentationSymbol();
  13811. }
  13812. break;
  13813. }
  13814. currentCodingpassType = (currentCodingpassType + 1) % 3;
  13815. }
  13816. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  13817. var sign = bitModel.coefficentsSign;
  13818. var magnitude = bitModel.coefficentsMagnitude;
  13819. var bitsDecoded = bitModel.bitsDecoded;
  13820. var magnitudeCorrection = reversible ? 0 : 0.5;
  13821. var k, n, nb;
  13822. position = 0;
  13823. var interleave = subband.type !== 'LL';
  13824. for (j = 0; j < blockHeight; j++) {
  13825. var row = offset / width | 0;
  13826. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  13827. for (k = 0; k < blockWidth; k++) {
  13828. n = magnitude[position];
  13829. if (n !== 0) {
  13830. n = (n + magnitudeCorrection) * delta;
  13831. if (sign[position] !== 0) {
  13832. n = -n;
  13833. }
  13834. nb = bitsDecoded[position];
  13835. var pos = interleave ? levelOffset + (offset << 1) : offset;
  13836. if (reversible && nb >= mb) {
  13837. coefficients[pos] = n;
  13838. } else {
  13839. coefficients[pos] = n * (1 << mb - nb);
  13840. }
  13841. }
  13842. offset++;
  13843. position++;
  13844. }
  13845. offset += width - blockWidth;
  13846. }
  13847. }
  13848. }
  13849. function transformTile(context, tile, c) {
  13850. var component = tile.components[c];
  13851. var codingStyleParameters = component.codingStyleParameters;
  13852. var quantizationParameters = component.quantizationParameters;
  13853. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  13854. var spqcds = quantizationParameters.SPqcds;
  13855. var scalarExpounded = quantizationParameters.scalarExpounded;
  13856. var guardBits = quantizationParameters.guardBits;
  13857. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  13858. var precision = context.components[c].precision;
  13859. var reversible = codingStyleParameters.reversibleTransformation;
  13860. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  13861. var subbandCoefficients = [];
  13862. var b = 0;
  13863. for (var i = 0; i <= decompositionLevelsCount; i++) {
  13864. var resolution = component.resolutions[i];
  13865. var width = resolution.trx1 - resolution.trx0;
  13866. var height = resolution.try1 - resolution.try0;
  13867. var coefficients = new Float32Array(width * height);
  13868. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  13869. var mu, epsilon;
  13870. if (!scalarExpounded) {
  13871. mu = spqcds[0].mu;
  13872. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  13873. } else {
  13874. mu = spqcds[b].mu;
  13875. epsilon = spqcds[b].epsilon;
  13876. b++;
  13877. }
  13878. var subband = resolution.subbands[j];
  13879. var gainLog2 = SubbandsGainLog2[subband.type];
  13880. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  13881. var mb = guardBits + epsilon - 1;
  13882. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  13883. }
  13884. subbandCoefficients.push({
  13885. width: width,
  13886. height: height,
  13887. items: coefficients
  13888. });
  13889. }
  13890. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  13891. return {
  13892. left: component.tcx0,
  13893. top: component.tcy0,
  13894. width: result.width,
  13895. height: result.height,
  13896. items: result.items
  13897. };
  13898. }
  13899. function transformComponents(context) {
  13900. var siz = context.SIZ;
  13901. var components = context.components;
  13902. var componentsCount = siz.Csiz;
  13903. var resultImages = [];
  13904. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  13905. var tile = context.tiles[i];
  13906. var transformedTiles = [];
  13907. var c;
  13908. for (c = 0; c < componentsCount; c++) {
  13909. transformedTiles[c] = transformTile(context, tile, c);
  13910. }
  13911. var tile0 = transformedTiles[0];
  13912. var out = new Uint8ClampedArray(tile0.items.length * componentsCount);
  13913. var result = {
  13914. left: tile0.left,
  13915. top: tile0.top,
  13916. width: tile0.width,
  13917. height: tile0.height,
  13918. items: out
  13919. };
  13920. var shift, offset;
  13921. var pos = 0,
  13922. j,
  13923. jj,
  13924. y0,
  13925. y1,
  13926. y2;
  13927. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  13928. var fourComponents = componentsCount === 4;
  13929. var y0items = transformedTiles[0].items;
  13930. var y1items = transformedTiles[1].items;
  13931. var y2items = transformedTiles[2].items;
  13932. var y3items = fourComponents ? transformedTiles[3].items : null;
  13933. shift = components[0].precision - 8;
  13934. offset = (128 << shift) + 0.5;
  13935. var component0 = tile.components[0];
  13936. var alpha01 = componentsCount - 3;
  13937. jj = y0items.length;
  13938. if (!component0.codingStyleParameters.reversibleTransformation) {
  13939. for (j = 0; j < jj; j++, pos += alpha01) {
  13940. y0 = y0items[j] + offset;
  13941. y1 = y1items[j];
  13942. y2 = y2items[j];
  13943. out[pos++] = y0 + 1.402 * y2 >> shift;
  13944. out[pos++] = y0 - 0.34413 * y1 - 0.71414 * y2 >> shift;
  13945. out[pos++] = y0 + 1.772 * y1 >> shift;
  13946. }
  13947. } else {
  13948. for (j = 0; j < jj; j++, pos += alpha01) {
  13949. y0 = y0items[j] + offset;
  13950. y1 = y1items[j];
  13951. y2 = y2items[j];
  13952. var g = y0 - (y2 + y1 >> 2);
  13953. out[pos++] = g + y2 >> shift;
  13954. out[pos++] = g >> shift;
  13955. out[pos++] = g + y1 >> shift;
  13956. }
  13957. }
  13958. if (fourComponents) {
  13959. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  13960. out[pos] = y3items[j] + offset >> shift;
  13961. }
  13962. }
  13963. } else {
  13964. for (c = 0; c < componentsCount; c++) {
  13965. var items = transformedTiles[c].items;
  13966. shift = components[c].precision - 8;
  13967. offset = (128 << shift) + 0.5;
  13968. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  13969. out[pos] = items[j] + offset >> shift;
  13970. pos += componentsCount;
  13971. }
  13972. }
  13973. }
  13974. resultImages.push(result);
  13975. }
  13976. return resultImages;
  13977. }
  13978. function initializeTile(context, tileIndex) {
  13979. var siz = context.SIZ;
  13980. var componentsCount = siz.Csiz;
  13981. var tile = context.tiles[tileIndex];
  13982. for (var c = 0; c < componentsCount; c++) {
  13983. var component = tile.components[c];
  13984. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  13985. component.quantizationParameters = qcdOrQcc;
  13986. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  13987. component.codingStyleParameters = codOrCoc;
  13988. }
  13989. tile.codingStyleDefaultParameters = context.currentTile.COD;
  13990. }
  13991. var TagTree = function TagTreeClosure() {
  13992. function TagTree(width, height) {
  13993. var levelsLength = (0, _util.log2)(Math.max(width, height)) + 1;
  13994. this.levels = [];
  13995. for (var i = 0; i < levelsLength; i++) {
  13996. var level = {
  13997. width: width,
  13998. height: height,
  13999. items: []
  14000. };
  14001. this.levels.push(level);
  14002. width = Math.ceil(width / 2);
  14003. height = Math.ceil(height / 2);
  14004. }
  14005. }
  14006. TagTree.prototype = {
  14007. reset: function TagTree_reset(i, j) {
  14008. var currentLevel = 0,
  14009. value = 0,
  14010. level;
  14011. while (currentLevel < this.levels.length) {
  14012. level = this.levels[currentLevel];
  14013. var index = i + j * level.width;
  14014. if (level.items[index] !== undefined) {
  14015. value = level.items[index];
  14016. break;
  14017. }
  14018. level.index = index;
  14019. i >>= 1;
  14020. j >>= 1;
  14021. currentLevel++;
  14022. }
  14023. currentLevel--;
  14024. level = this.levels[currentLevel];
  14025. level.items[level.index] = value;
  14026. this.currentLevel = currentLevel;
  14027. delete this.value;
  14028. },
  14029. incrementValue: function TagTree_incrementValue() {
  14030. var level = this.levels[this.currentLevel];
  14031. level.items[level.index]++;
  14032. },
  14033. nextLevel: function TagTree_nextLevel() {
  14034. var currentLevel = this.currentLevel;
  14035. var level = this.levels[currentLevel];
  14036. var value = level.items[level.index];
  14037. currentLevel--;
  14038. if (currentLevel < 0) {
  14039. this.value = value;
  14040. return false;
  14041. }
  14042. this.currentLevel = currentLevel;
  14043. level = this.levels[currentLevel];
  14044. level.items[level.index] = value;
  14045. return true;
  14046. }
  14047. };
  14048. return TagTree;
  14049. }();
  14050. var InclusionTree = function InclusionTreeClosure() {
  14051. function InclusionTree(width, height, defaultValue) {
  14052. var levelsLength = (0, _util.log2)(Math.max(width, height)) + 1;
  14053. this.levels = [];
  14054. for (var i = 0; i < levelsLength; i++) {
  14055. var items = new Uint8Array(width * height);
  14056. for (var j = 0, jj = items.length; j < jj; j++) {
  14057. items[j] = defaultValue;
  14058. }
  14059. var level = {
  14060. width: width,
  14061. height: height,
  14062. items: items
  14063. };
  14064. this.levels.push(level);
  14065. width = Math.ceil(width / 2);
  14066. height = Math.ceil(height / 2);
  14067. }
  14068. }
  14069. InclusionTree.prototype = {
  14070. reset: function InclusionTree_reset(i, j, stopValue) {
  14071. var currentLevel = 0;
  14072. while (currentLevel < this.levels.length) {
  14073. var level = this.levels[currentLevel];
  14074. var index = i + j * level.width;
  14075. level.index = index;
  14076. var value = level.items[index];
  14077. if (value === 0xFF) {
  14078. break;
  14079. }
  14080. if (value > stopValue) {
  14081. this.currentLevel = currentLevel;
  14082. this.propagateValues();
  14083. return false;
  14084. }
  14085. i >>= 1;
  14086. j >>= 1;
  14087. currentLevel++;
  14088. }
  14089. this.currentLevel = currentLevel - 1;
  14090. return true;
  14091. },
  14092. incrementValue: function InclusionTree_incrementValue(stopValue) {
  14093. var level = this.levels[this.currentLevel];
  14094. level.items[level.index] = stopValue + 1;
  14095. this.propagateValues();
  14096. },
  14097. propagateValues: function InclusionTree_propagateValues() {
  14098. var levelIndex = this.currentLevel;
  14099. var level = this.levels[levelIndex];
  14100. var currentValue = level.items[level.index];
  14101. while (--levelIndex >= 0) {
  14102. level = this.levels[levelIndex];
  14103. level.items[level.index] = currentValue;
  14104. }
  14105. },
  14106. nextLevel: function InclusionTree_nextLevel() {
  14107. var currentLevel = this.currentLevel;
  14108. var level = this.levels[currentLevel];
  14109. var value = level.items[level.index];
  14110. level.items[level.index] = 0xFF;
  14111. currentLevel--;
  14112. if (currentLevel < 0) {
  14113. return false;
  14114. }
  14115. this.currentLevel = currentLevel;
  14116. level = this.levels[currentLevel];
  14117. level.items[level.index] = value;
  14118. return true;
  14119. }
  14120. };
  14121. return InclusionTree;
  14122. }();
  14123. var BitModel = function BitModelClosure() {
  14124. var UNIFORM_CONTEXT = 17;
  14125. var RUNLENGTH_CONTEXT = 18;
  14126. 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]);
  14127. 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]);
  14128. 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]);
  14129. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  14130. this.width = width;
  14131. this.height = height;
  14132. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  14133. var coefficientCount = width * height;
  14134. this.neighborsSignificance = new Uint8Array(coefficientCount);
  14135. this.coefficentsSign = new Uint8Array(coefficientCount);
  14136. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  14137. this.processingFlags = new Uint8Array(coefficientCount);
  14138. var bitsDecoded = new Uint8Array(coefficientCount);
  14139. if (zeroBitPlanes !== 0) {
  14140. for (var i = 0; i < coefficientCount; i++) {
  14141. bitsDecoded[i] = zeroBitPlanes;
  14142. }
  14143. }
  14144. this.bitsDecoded = bitsDecoded;
  14145. this.reset();
  14146. }
  14147. BitModel.prototype = {
  14148. setDecoder: function BitModel_setDecoder(decoder) {
  14149. this.decoder = decoder;
  14150. },
  14151. reset: function BitModel_reset() {
  14152. this.contexts = new Int8Array(19);
  14153. this.contexts[0] = 4 << 1 | 0;
  14154. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  14155. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  14156. },
  14157. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  14158. var neighborsSignificance = this.neighborsSignificance;
  14159. var width = this.width,
  14160. height = this.height;
  14161. var left = column > 0;
  14162. var right = column + 1 < width;
  14163. var i;
  14164. if (row > 0) {
  14165. i = index - width;
  14166. if (left) {
  14167. neighborsSignificance[i - 1] += 0x10;
  14168. }
  14169. if (right) {
  14170. neighborsSignificance[i + 1] += 0x10;
  14171. }
  14172. neighborsSignificance[i] += 0x04;
  14173. }
  14174. if (row + 1 < height) {
  14175. i = index + width;
  14176. if (left) {
  14177. neighborsSignificance[i - 1] += 0x10;
  14178. }
  14179. if (right) {
  14180. neighborsSignificance[i + 1] += 0x10;
  14181. }
  14182. neighborsSignificance[i] += 0x04;
  14183. }
  14184. if (left) {
  14185. neighborsSignificance[index - 1] += 0x01;
  14186. }
  14187. if (right) {
  14188. neighborsSignificance[index + 1] += 0x01;
  14189. }
  14190. neighborsSignificance[index] |= 0x80;
  14191. },
  14192. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  14193. var decoder = this.decoder;
  14194. var width = this.width,
  14195. height = this.height;
  14196. var coefficentsMagnitude = this.coefficentsMagnitude;
  14197. var coefficentsSign = this.coefficentsSign;
  14198. var neighborsSignificance = this.neighborsSignificance;
  14199. var processingFlags = this.processingFlags;
  14200. var contexts = this.contexts;
  14201. var labels = this.contextLabelTable;
  14202. var bitsDecoded = this.bitsDecoded;
  14203. var processedInverseMask = ~1;
  14204. var processedMask = 1;
  14205. var firstMagnitudeBitMask = 2;
  14206. for (var i0 = 0; i0 < height; i0 += 4) {
  14207. for (var j = 0; j < width; j++) {
  14208. var index = i0 * width + j;
  14209. for (var i1 = 0; i1 < 4; i1++, index += width) {
  14210. var i = i0 + i1;
  14211. if (i >= height) {
  14212. break;
  14213. }
  14214. processingFlags[index] &= processedInverseMask;
  14215. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  14216. continue;
  14217. }
  14218. var contextLabel = labels[neighborsSignificance[index]];
  14219. var decision = decoder.readBit(contexts, contextLabel);
  14220. if (decision) {
  14221. var sign = this.decodeSignBit(i, j, index);
  14222. coefficentsSign[index] = sign;
  14223. coefficentsMagnitude[index] = 1;
  14224. this.setNeighborsSignificance(i, j, index);
  14225. processingFlags[index] |= firstMagnitudeBitMask;
  14226. }
  14227. bitsDecoded[index]++;
  14228. processingFlags[index] |= processedMask;
  14229. }
  14230. }
  14231. }
  14232. },
  14233. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  14234. var width = this.width,
  14235. height = this.height;
  14236. var coefficentsMagnitude = this.coefficentsMagnitude;
  14237. var coefficentsSign = this.coefficentsSign;
  14238. var contribution, sign0, sign1, significance1;
  14239. var contextLabel, decoded;
  14240. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  14241. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  14242. sign1 = coefficentsSign[index + 1];
  14243. if (significance1) {
  14244. sign0 = coefficentsSign[index - 1];
  14245. contribution = 1 - sign1 - sign0;
  14246. } else {
  14247. contribution = 1 - sign1 - sign1;
  14248. }
  14249. } else if (significance1) {
  14250. sign0 = coefficentsSign[index - 1];
  14251. contribution = 1 - sign0 - sign0;
  14252. } else {
  14253. contribution = 0;
  14254. }
  14255. var horizontalContribution = 3 * contribution;
  14256. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  14257. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  14258. sign1 = coefficentsSign[index + width];
  14259. if (significance1) {
  14260. sign0 = coefficentsSign[index - width];
  14261. contribution = 1 - sign1 - sign0 + horizontalContribution;
  14262. } else {
  14263. contribution = 1 - sign1 - sign1 + horizontalContribution;
  14264. }
  14265. } else if (significance1) {
  14266. sign0 = coefficentsSign[index - width];
  14267. contribution = 1 - sign0 - sign0 + horizontalContribution;
  14268. } else {
  14269. contribution = horizontalContribution;
  14270. }
  14271. if (contribution >= 0) {
  14272. contextLabel = 9 + contribution;
  14273. decoded = this.decoder.readBit(this.contexts, contextLabel);
  14274. } else {
  14275. contextLabel = 9 - contribution;
  14276. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  14277. }
  14278. return decoded;
  14279. },
  14280. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  14281. var decoder = this.decoder;
  14282. var width = this.width,
  14283. height = this.height;
  14284. var coefficentsMagnitude = this.coefficentsMagnitude;
  14285. var neighborsSignificance = this.neighborsSignificance;
  14286. var contexts = this.contexts;
  14287. var bitsDecoded = this.bitsDecoded;
  14288. var processingFlags = this.processingFlags;
  14289. var processedMask = 1;
  14290. var firstMagnitudeBitMask = 2;
  14291. var length = width * height;
  14292. var width4 = width * 4;
  14293. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  14294. indexNext = Math.min(length, index0 + width4);
  14295. for (var j = 0; j < width; j++) {
  14296. for (var index = index0 + j; index < indexNext; index += width) {
  14297. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  14298. continue;
  14299. }
  14300. var contextLabel = 16;
  14301. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  14302. processingFlags[index] ^= firstMagnitudeBitMask;
  14303. var significance = neighborsSignificance[index] & 127;
  14304. contextLabel = significance === 0 ? 15 : 14;
  14305. }
  14306. var bit = decoder.readBit(contexts, contextLabel);
  14307. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  14308. bitsDecoded[index]++;
  14309. processingFlags[index] |= processedMask;
  14310. }
  14311. }
  14312. }
  14313. },
  14314. runCleanupPass: function BitModel_runCleanupPass() {
  14315. var decoder = this.decoder;
  14316. var width = this.width,
  14317. height = this.height;
  14318. var neighborsSignificance = this.neighborsSignificance;
  14319. var coefficentsMagnitude = this.coefficentsMagnitude;
  14320. var coefficentsSign = this.coefficentsSign;
  14321. var contexts = this.contexts;
  14322. var labels = this.contextLabelTable;
  14323. var bitsDecoded = this.bitsDecoded;
  14324. var processingFlags = this.processingFlags;
  14325. var processedMask = 1;
  14326. var firstMagnitudeBitMask = 2;
  14327. var oneRowDown = width;
  14328. var twoRowsDown = width * 2;
  14329. var threeRowsDown = width * 3;
  14330. var iNext;
  14331. for (var i0 = 0; i0 < height; i0 = iNext) {
  14332. iNext = Math.min(i0 + 4, height);
  14333. var indexBase = i0 * width;
  14334. var checkAllEmpty = i0 + 3 < height;
  14335. for (var j = 0; j < width; j++) {
  14336. var index0 = indexBase + j;
  14337. 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;
  14338. var i1 = 0,
  14339. index = index0;
  14340. var i = i0,
  14341. sign;
  14342. if (allEmpty) {
  14343. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  14344. if (!hasSignificantCoefficent) {
  14345. bitsDecoded[index0]++;
  14346. bitsDecoded[index0 + oneRowDown]++;
  14347. bitsDecoded[index0 + twoRowsDown]++;
  14348. bitsDecoded[index0 + threeRowsDown]++;
  14349. continue;
  14350. }
  14351. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  14352. if (i1 !== 0) {
  14353. i = i0 + i1;
  14354. index += i1 * width;
  14355. }
  14356. sign = this.decodeSignBit(i, j, index);
  14357. coefficentsSign[index] = sign;
  14358. coefficentsMagnitude[index] = 1;
  14359. this.setNeighborsSignificance(i, j, index);
  14360. processingFlags[index] |= firstMagnitudeBitMask;
  14361. index = index0;
  14362. for (var i2 = i0; i2 <= i; i2++, index += width) {
  14363. bitsDecoded[index]++;
  14364. }
  14365. i1++;
  14366. }
  14367. for (i = i0 + i1; i < iNext; i++, index += width) {
  14368. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  14369. continue;
  14370. }
  14371. var contextLabel = labels[neighborsSignificance[index]];
  14372. var decision = decoder.readBit(contexts, contextLabel);
  14373. if (decision === 1) {
  14374. sign = this.decodeSignBit(i, j, index);
  14375. coefficentsSign[index] = sign;
  14376. coefficentsMagnitude[index] = 1;
  14377. this.setNeighborsSignificance(i, j, index);
  14378. processingFlags[index] |= firstMagnitudeBitMask;
  14379. }
  14380. bitsDecoded[index]++;
  14381. }
  14382. }
  14383. }
  14384. },
  14385. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  14386. var decoder = this.decoder;
  14387. var contexts = this.contexts;
  14388. 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);
  14389. if (symbol !== 0xA) {
  14390. throw new JpxError('Invalid segmentation symbol');
  14391. }
  14392. }
  14393. };
  14394. return BitModel;
  14395. }();
  14396. var Transform = function TransformClosure() {
  14397. function Transform() {}
  14398. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  14399. var ll = subbands[0];
  14400. for (var i = 1, ii = subbands.length; i < ii; i++) {
  14401. ll = this.iterate(ll, subbands[i], u0, v0);
  14402. }
  14403. return ll;
  14404. };
  14405. Transform.prototype.extend = function extend(buffer, offset, size) {
  14406. var i1 = offset - 1,
  14407. j1 = offset + 1;
  14408. var i2 = offset + size - 2,
  14409. j2 = offset + size;
  14410. buffer[i1--] = buffer[j1++];
  14411. buffer[j2++] = buffer[i2--];
  14412. buffer[i1--] = buffer[j1++];
  14413. buffer[j2++] = buffer[i2--];
  14414. buffer[i1--] = buffer[j1++];
  14415. buffer[j2++] = buffer[i2--];
  14416. buffer[i1] = buffer[j1];
  14417. buffer[j2] = buffer[i2];
  14418. };
  14419. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  14420. var llWidth = ll.width,
  14421. llHeight = ll.height,
  14422. llItems = ll.items;
  14423. var width = hl_lh_hh.width;
  14424. var height = hl_lh_hh.height;
  14425. var items = hl_lh_hh.items;
  14426. var i, j, k, l, u, v;
  14427. for (k = 0, i = 0; i < llHeight; i++) {
  14428. l = i * 2 * width;
  14429. for (j = 0; j < llWidth; j++, k++, l += 2) {
  14430. items[l] = llItems[k];
  14431. }
  14432. }
  14433. llItems = ll.items = null;
  14434. var bufferPadding = 4;
  14435. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  14436. if (width === 1) {
  14437. if ((u0 & 1) !== 0) {
  14438. for (v = 0, k = 0; v < height; v++, k += width) {
  14439. items[k] *= 0.5;
  14440. }
  14441. }
  14442. } else {
  14443. for (v = 0, k = 0; v < height; v++, k += width) {
  14444. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  14445. this.extend(rowBuffer, bufferPadding, width);
  14446. this.filter(rowBuffer, bufferPadding, width);
  14447. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  14448. }
  14449. }
  14450. var numBuffers = 16;
  14451. var colBuffers = [];
  14452. for (i = 0; i < numBuffers; i++) {
  14453. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  14454. }
  14455. var b,
  14456. currentBuffer = 0;
  14457. ll = bufferPadding + height;
  14458. if (height === 1) {
  14459. if ((v0 & 1) !== 0) {
  14460. for (u = 0; u < width; u++) {
  14461. items[u] *= 0.5;
  14462. }
  14463. }
  14464. } else {
  14465. for (u = 0; u < width; u++) {
  14466. if (currentBuffer === 0) {
  14467. numBuffers = Math.min(width - u, numBuffers);
  14468. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  14469. for (b = 0; b < numBuffers; b++) {
  14470. colBuffers[b][l] = items[k + b];
  14471. }
  14472. }
  14473. currentBuffer = numBuffers;
  14474. }
  14475. currentBuffer--;
  14476. var buffer = colBuffers[currentBuffer];
  14477. this.extend(buffer, bufferPadding, height);
  14478. this.filter(buffer, bufferPadding, height);
  14479. if (currentBuffer === 0) {
  14480. k = u - numBuffers + 1;
  14481. for (l = bufferPadding; l < ll; k += width, l++) {
  14482. for (b = 0; b < numBuffers; b++) {
  14483. items[k + b] = colBuffers[b][l];
  14484. }
  14485. }
  14486. }
  14487. }
  14488. }
  14489. return {
  14490. width: width,
  14491. height: height,
  14492. items: items
  14493. };
  14494. };
  14495. return Transform;
  14496. }();
  14497. var IrreversibleTransform = function IrreversibleTransformClosure() {
  14498. function IrreversibleTransform() {
  14499. Transform.call(this);
  14500. }
  14501. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  14502. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  14503. var len = length >> 1;
  14504. offset = offset | 0;
  14505. var j, n, current, next;
  14506. var alpha = -1.586134342059924;
  14507. var beta = -0.052980118572961;
  14508. var gamma = 0.882911075530934;
  14509. var delta = 0.443506852043971;
  14510. var K = 1.230174104914001;
  14511. var K_ = 1 / K;
  14512. j = offset - 3;
  14513. for (n = len + 4; n--; j += 2) {
  14514. x[j] *= K_;
  14515. }
  14516. j = offset - 2;
  14517. current = delta * x[j - 1];
  14518. for (n = len + 3; n--; j += 2) {
  14519. next = delta * x[j + 1];
  14520. x[j] = K * x[j] - current - next;
  14521. if (n--) {
  14522. j += 2;
  14523. current = delta * x[j + 1];
  14524. x[j] = K * x[j] - current - next;
  14525. } else {
  14526. break;
  14527. }
  14528. }
  14529. j = offset - 1;
  14530. current = gamma * x[j - 1];
  14531. for (n = len + 2; n--; j += 2) {
  14532. next = gamma * x[j + 1];
  14533. x[j] -= current + next;
  14534. if (n--) {
  14535. j += 2;
  14536. current = gamma * x[j + 1];
  14537. x[j] -= current + next;
  14538. } else {
  14539. break;
  14540. }
  14541. }
  14542. j = offset;
  14543. current = beta * x[j - 1];
  14544. for (n = len + 1; n--; j += 2) {
  14545. next = beta * x[j + 1];
  14546. x[j] -= current + next;
  14547. if (n--) {
  14548. j += 2;
  14549. current = beta * x[j + 1];
  14550. x[j] -= current + next;
  14551. } else {
  14552. break;
  14553. }
  14554. }
  14555. if (len !== 0) {
  14556. j = offset + 1;
  14557. current = alpha * x[j - 1];
  14558. for (n = len; n--; j += 2) {
  14559. next = alpha * x[j + 1];
  14560. x[j] -= current + next;
  14561. if (n--) {
  14562. j += 2;
  14563. current = alpha * x[j + 1];
  14564. x[j] -= current + next;
  14565. } else {
  14566. break;
  14567. }
  14568. }
  14569. }
  14570. };
  14571. return IrreversibleTransform;
  14572. }();
  14573. var ReversibleTransform = function ReversibleTransformClosure() {
  14574. function ReversibleTransform() {
  14575. Transform.call(this);
  14576. }
  14577. ReversibleTransform.prototype = Object.create(Transform.prototype);
  14578. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  14579. var len = length >> 1;
  14580. offset = offset | 0;
  14581. var j, n;
  14582. for (j = offset, n = len + 1; n--; j += 2) {
  14583. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  14584. }
  14585. for (j = offset + 1, n = len; n--; j += 2) {
  14586. x[j] += x[j - 1] + x[j + 1] >> 1;
  14587. }
  14588. };
  14589. return ReversibleTransform;
  14590. }();
  14591. return JpxImage;
  14592. }();
  14593. exports.JpxImage = JpxImage;
  14594. /***/ }),
  14595. /* 64 */
  14596. /***/ (function(module, exports, __w_pdfjs_require__) {
  14597. "use strict";
  14598. Object.defineProperty(exports, "__esModule", {
  14599. value: true
  14600. });
  14601. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  14602. var QeTable = [{
  14603. qe: 0x5601,
  14604. nmps: 1,
  14605. nlps: 1,
  14606. switchFlag: 1
  14607. }, {
  14608. qe: 0x3401,
  14609. nmps: 2,
  14610. nlps: 6,
  14611. switchFlag: 0
  14612. }, {
  14613. qe: 0x1801,
  14614. nmps: 3,
  14615. nlps: 9,
  14616. switchFlag: 0
  14617. }, {
  14618. qe: 0x0AC1,
  14619. nmps: 4,
  14620. nlps: 12,
  14621. switchFlag: 0
  14622. }, {
  14623. qe: 0x0521,
  14624. nmps: 5,
  14625. nlps: 29,
  14626. switchFlag: 0
  14627. }, {
  14628. qe: 0x0221,
  14629. nmps: 38,
  14630. nlps: 33,
  14631. switchFlag: 0
  14632. }, {
  14633. qe: 0x5601,
  14634. nmps: 7,
  14635. nlps: 6,
  14636. switchFlag: 1
  14637. }, {
  14638. qe: 0x5401,
  14639. nmps: 8,
  14640. nlps: 14,
  14641. switchFlag: 0
  14642. }, {
  14643. qe: 0x4801,
  14644. nmps: 9,
  14645. nlps: 14,
  14646. switchFlag: 0
  14647. }, {
  14648. qe: 0x3801,
  14649. nmps: 10,
  14650. nlps: 14,
  14651. switchFlag: 0
  14652. }, {
  14653. qe: 0x3001,
  14654. nmps: 11,
  14655. nlps: 17,
  14656. switchFlag: 0
  14657. }, {
  14658. qe: 0x2401,
  14659. nmps: 12,
  14660. nlps: 18,
  14661. switchFlag: 0
  14662. }, {
  14663. qe: 0x1C01,
  14664. nmps: 13,
  14665. nlps: 20,
  14666. switchFlag: 0
  14667. }, {
  14668. qe: 0x1601,
  14669. nmps: 29,
  14670. nlps: 21,
  14671. switchFlag: 0
  14672. }, {
  14673. qe: 0x5601,
  14674. nmps: 15,
  14675. nlps: 14,
  14676. switchFlag: 1
  14677. }, {
  14678. qe: 0x5401,
  14679. nmps: 16,
  14680. nlps: 14,
  14681. switchFlag: 0
  14682. }, {
  14683. qe: 0x5101,
  14684. nmps: 17,
  14685. nlps: 15,
  14686. switchFlag: 0
  14687. }, {
  14688. qe: 0x4801,
  14689. nmps: 18,
  14690. nlps: 16,
  14691. switchFlag: 0
  14692. }, {
  14693. qe: 0x3801,
  14694. nmps: 19,
  14695. nlps: 17,
  14696. switchFlag: 0
  14697. }, {
  14698. qe: 0x3401,
  14699. nmps: 20,
  14700. nlps: 18,
  14701. switchFlag: 0
  14702. }, {
  14703. qe: 0x3001,
  14704. nmps: 21,
  14705. nlps: 19,
  14706. switchFlag: 0
  14707. }, {
  14708. qe: 0x2801,
  14709. nmps: 22,
  14710. nlps: 19,
  14711. switchFlag: 0
  14712. }, {
  14713. qe: 0x2401,
  14714. nmps: 23,
  14715. nlps: 20,
  14716. switchFlag: 0
  14717. }, {
  14718. qe: 0x2201,
  14719. nmps: 24,
  14720. nlps: 21,
  14721. switchFlag: 0
  14722. }, {
  14723. qe: 0x1C01,
  14724. nmps: 25,
  14725. nlps: 22,
  14726. switchFlag: 0
  14727. }, {
  14728. qe: 0x1801,
  14729. nmps: 26,
  14730. nlps: 23,
  14731. switchFlag: 0
  14732. }, {
  14733. qe: 0x1601,
  14734. nmps: 27,
  14735. nlps: 24,
  14736. switchFlag: 0
  14737. }, {
  14738. qe: 0x1401,
  14739. nmps: 28,
  14740. nlps: 25,
  14741. switchFlag: 0
  14742. }, {
  14743. qe: 0x1201,
  14744. nmps: 29,
  14745. nlps: 26,
  14746. switchFlag: 0
  14747. }, {
  14748. qe: 0x1101,
  14749. nmps: 30,
  14750. nlps: 27,
  14751. switchFlag: 0
  14752. }, {
  14753. qe: 0x0AC1,
  14754. nmps: 31,
  14755. nlps: 28,
  14756. switchFlag: 0
  14757. }, {
  14758. qe: 0x09C1,
  14759. nmps: 32,
  14760. nlps: 29,
  14761. switchFlag: 0
  14762. }, {
  14763. qe: 0x08A1,
  14764. nmps: 33,
  14765. nlps: 30,
  14766. switchFlag: 0
  14767. }, {
  14768. qe: 0x0521,
  14769. nmps: 34,
  14770. nlps: 31,
  14771. switchFlag: 0
  14772. }, {
  14773. qe: 0x0441,
  14774. nmps: 35,
  14775. nlps: 32,
  14776. switchFlag: 0
  14777. }, {
  14778. qe: 0x02A1,
  14779. nmps: 36,
  14780. nlps: 33,
  14781. switchFlag: 0
  14782. }, {
  14783. qe: 0x0221,
  14784. nmps: 37,
  14785. nlps: 34,
  14786. switchFlag: 0
  14787. }, {
  14788. qe: 0x0141,
  14789. nmps: 38,
  14790. nlps: 35,
  14791. switchFlag: 0
  14792. }, {
  14793. qe: 0x0111,
  14794. nmps: 39,
  14795. nlps: 36,
  14796. switchFlag: 0
  14797. }, {
  14798. qe: 0x0085,
  14799. nmps: 40,
  14800. nlps: 37,
  14801. switchFlag: 0
  14802. }, {
  14803. qe: 0x0049,
  14804. nmps: 41,
  14805. nlps: 38,
  14806. switchFlag: 0
  14807. }, {
  14808. qe: 0x0025,
  14809. nmps: 42,
  14810. nlps: 39,
  14811. switchFlag: 0
  14812. }, {
  14813. qe: 0x0015,
  14814. nmps: 43,
  14815. nlps: 40,
  14816. switchFlag: 0
  14817. }, {
  14818. qe: 0x0009,
  14819. nmps: 44,
  14820. nlps: 41,
  14821. switchFlag: 0
  14822. }, {
  14823. qe: 0x0005,
  14824. nmps: 45,
  14825. nlps: 42,
  14826. switchFlag: 0
  14827. }, {
  14828. qe: 0x0001,
  14829. nmps: 45,
  14830. nlps: 43,
  14831. switchFlag: 0
  14832. }, {
  14833. qe: 0x5601,
  14834. nmps: 46,
  14835. nlps: 46,
  14836. switchFlag: 0
  14837. }];
  14838. function ArithmeticDecoder(data, start, end) {
  14839. this.data = data;
  14840. this.bp = start;
  14841. this.dataEnd = end;
  14842. this.chigh = data[start];
  14843. this.clow = 0;
  14844. this.byteIn();
  14845. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  14846. this.clow = this.clow << 7 & 0xFFFF;
  14847. this.ct -= 7;
  14848. this.a = 0x8000;
  14849. }
  14850. ArithmeticDecoder.prototype = {
  14851. byteIn: function ArithmeticDecoder_byteIn() {
  14852. var data = this.data;
  14853. var bp = this.bp;
  14854. if (data[bp] === 0xFF) {
  14855. var b1 = data[bp + 1];
  14856. if (b1 > 0x8F) {
  14857. this.clow += 0xFF00;
  14858. this.ct = 8;
  14859. } else {
  14860. bp++;
  14861. this.clow += data[bp] << 9;
  14862. this.ct = 7;
  14863. this.bp = bp;
  14864. }
  14865. } else {
  14866. bp++;
  14867. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  14868. this.ct = 8;
  14869. this.bp = bp;
  14870. }
  14871. if (this.clow > 0xFFFF) {
  14872. this.chigh += this.clow >> 16;
  14873. this.clow &= 0xFFFF;
  14874. }
  14875. },
  14876. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  14877. var cx_index = contexts[pos] >> 1,
  14878. cx_mps = contexts[pos] & 1;
  14879. var qeTableIcx = QeTable[cx_index];
  14880. var qeIcx = qeTableIcx.qe;
  14881. var d;
  14882. var a = this.a - qeIcx;
  14883. if (this.chigh < qeIcx) {
  14884. if (a < qeIcx) {
  14885. a = qeIcx;
  14886. d = cx_mps;
  14887. cx_index = qeTableIcx.nmps;
  14888. } else {
  14889. a = qeIcx;
  14890. d = 1 ^ cx_mps;
  14891. if (qeTableIcx.switchFlag === 1) {
  14892. cx_mps = d;
  14893. }
  14894. cx_index = qeTableIcx.nlps;
  14895. }
  14896. } else {
  14897. this.chigh -= qeIcx;
  14898. if ((a & 0x8000) !== 0) {
  14899. this.a = a;
  14900. return cx_mps;
  14901. }
  14902. if (a < qeIcx) {
  14903. d = 1 ^ cx_mps;
  14904. if (qeTableIcx.switchFlag === 1) {
  14905. cx_mps = d;
  14906. }
  14907. cx_index = qeTableIcx.nlps;
  14908. } else {
  14909. d = cx_mps;
  14910. cx_index = qeTableIcx.nmps;
  14911. }
  14912. }
  14913. do {
  14914. if (this.ct === 0) {
  14915. this.byteIn();
  14916. }
  14917. a <<= 1;
  14918. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  14919. this.clow = this.clow << 1 & 0xFFFF;
  14920. this.ct--;
  14921. } while ((a & 0x8000) === 0);
  14922. this.a = a;
  14923. contexts[pos] = cx_index << 1 | cx_mps;
  14924. return d;
  14925. }
  14926. };
  14927. return ArithmeticDecoder;
  14928. }();
  14929. exports.ArithmeticDecoder = ArithmeticDecoder;
  14930. /***/ }),
  14931. /* 65 */
  14932. /***/ (function(module, exports, __w_pdfjs_require__) {
  14933. "use strict";
  14934. Object.defineProperty(exports, "__esModule", {
  14935. value: true
  14936. });
  14937. exports.calculateSHA512 = exports.calculateSHA384 = exports.calculateSHA256 = exports.calculateMD5 = exports.PDF20 = exports.PDF17 = exports.CipherTransformFactory = exports.ARCFourCipher = exports.AES256Cipher = exports.AES128Cipher = undefined;
  14938. var _util = __w_pdfjs_require__(0);
  14939. var _primitives = __w_pdfjs_require__(1);
  14940. var _stream = __w_pdfjs_require__(5);
  14941. var ARCFourCipher = function ARCFourCipherClosure() {
  14942. function ARCFourCipher(key) {
  14943. this.a = 0;
  14944. this.b = 0;
  14945. var s = new Uint8Array(256);
  14946. var i,
  14947. j = 0,
  14948. tmp,
  14949. keyLength = key.length;
  14950. for (i = 0; i < 256; ++i) {
  14951. s[i] = i;
  14952. }
  14953. for (i = 0; i < 256; ++i) {
  14954. tmp = s[i];
  14955. j = j + tmp + key[i % keyLength] & 0xFF;
  14956. s[i] = s[j];
  14957. s[j] = tmp;
  14958. }
  14959. this.s = s;
  14960. }
  14961. ARCFourCipher.prototype = {
  14962. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  14963. var i,
  14964. n = data.length,
  14965. tmp,
  14966. tmp2;
  14967. var a = this.a,
  14968. b = this.b,
  14969. s = this.s;
  14970. var output = new Uint8Array(n);
  14971. for (i = 0; i < n; ++i) {
  14972. a = a + 1 & 0xFF;
  14973. tmp = s[a];
  14974. b = b + tmp & 0xFF;
  14975. tmp2 = s[b];
  14976. s[a] = tmp2;
  14977. s[b] = tmp;
  14978. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  14979. }
  14980. this.a = a;
  14981. this.b = b;
  14982. return output;
  14983. }
  14984. };
  14985. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  14986. return ARCFourCipher;
  14987. }();
  14988. var calculateMD5 = function calculateMD5Closure() {
  14989. 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]);
  14990. 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]);
  14991. function hash(data, offset, length) {
  14992. var h0 = 1732584193,
  14993. h1 = -271733879,
  14994. h2 = -1732584194,
  14995. h3 = 271733878;
  14996. var paddedLength = length + 72 & ~63;
  14997. var padded = new Uint8Array(paddedLength);
  14998. var i, j, n;
  14999. for (i = 0; i < length; ++i) {
  15000. padded[i] = data[offset++];
  15001. }
  15002. padded[i++] = 0x80;
  15003. n = paddedLength - 8;
  15004. while (i < n) {
  15005. padded[i++] = 0;
  15006. }
  15007. padded[i++] = length << 3 & 0xFF;
  15008. padded[i++] = length >> 5 & 0xFF;
  15009. padded[i++] = length >> 13 & 0xFF;
  15010. padded[i++] = length >> 21 & 0xFF;
  15011. padded[i++] = length >>> 29 & 0xFF;
  15012. padded[i++] = 0;
  15013. padded[i++] = 0;
  15014. padded[i++] = 0;
  15015. var w = new Int32Array(16);
  15016. for (i = 0; i < paddedLength;) {
  15017. for (j = 0; j < 16; ++j, i += 4) {
  15018. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  15019. }
  15020. var a = h0,
  15021. b = h1,
  15022. c = h2,
  15023. d = h3,
  15024. f,
  15025. g;
  15026. for (j = 0; j < 64; ++j) {
  15027. if (j < 16) {
  15028. f = b & c | ~b & d;
  15029. g = j;
  15030. } else if (j < 32) {
  15031. f = d & b | ~d & c;
  15032. g = 5 * j + 1 & 15;
  15033. } else if (j < 48) {
  15034. f = b ^ c ^ d;
  15035. g = 3 * j + 5 & 15;
  15036. } else {
  15037. f = c ^ (b | ~d);
  15038. g = 7 * j & 15;
  15039. }
  15040. var tmp = d,
  15041. rotateArg = a + f + k[j] + w[g] | 0,
  15042. rotate = r[j];
  15043. d = c;
  15044. c = b;
  15045. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  15046. a = tmp;
  15047. }
  15048. h0 = h0 + a | 0;
  15049. h1 = h1 + b | 0;
  15050. h2 = h2 + c | 0;
  15051. h3 = h3 + d | 0;
  15052. }
  15053. return new Uint8Array([h0 & 0xFF, h0 >> 8 & 0xFF, h0 >> 16 & 0xFF, h0 >>> 24 & 0xFF, h1 & 0xFF, h1 >> 8 & 0xFF, h1 >> 16 & 0xFF, h1 >>> 24 & 0xFF, h2 & 0xFF, h2 >> 8 & 0xFF, h2 >> 16 & 0xFF, h2 >>> 24 & 0xFF, h3 & 0xFF, h3 >> 8 & 0xFF, h3 >> 16 & 0xFF, h3 >>> 24 & 0xFF]);
  15054. }
  15055. return hash;
  15056. }();
  15057. var Word64 = function Word64Closure() {
  15058. function Word64(highInteger, lowInteger) {
  15059. this.high = highInteger | 0;
  15060. this.low = lowInteger | 0;
  15061. }
  15062. Word64.prototype = {
  15063. and: function Word64_and(word) {
  15064. this.high &= word.high;
  15065. this.low &= word.low;
  15066. },
  15067. xor: function Word64_xor(word) {
  15068. this.high ^= word.high;
  15069. this.low ^= word.low;
  15070. },
  15071. or: function Word64_or(word) {
  15072. this.high |= word.high;
  15073. this.low |= word.low;
  15074. },
  15075. shiftRight: function Word64_shiftRight(places) {
  15076. if (places >= 32) {
  15077. this.low = this.high >>> places - 32 | 0;
  15078. this.high = 0;
  15079. } else {
  15080. this.low = this.low >>> places | this.high << 32 - places;
  15081. this.high = this.high >>> places | 0;
  15082. }
  15083. },
  15084. shiftLeft: function Word64_shiftLeft(places) {
  15085. if (places >= 32) {
  15086. this.high = this.low << places - 32;
  15087. this.low = 0;
  15088. } else {
  15089. this.high = this.high << places | this.low >>> 32 - places;
  15090. this.low = this.low << places;
  15091. }
  15092. },
  15093. rotateRight: function Word64_rotateRight(places) {
  15094. var low, high;
  15095. if (places & 32) {
  15096. high = this.low;
  15097. low = this.high;
  15098. } else {
  15099. low = this.low;
  15100. high = this.high;
  15101. }
  15102. places &= 31;
  15103. this.low = low >>> places | high << 32 - places;
  15104. this.high = high >>> places | low << 32 - places;
  15105. },
  15106. not: function Word64_not() {
  15107. this.high = ~this.high;
  15108. this.low = ~this.low;
  15109. },
  15110. add: function Word64_add(word) {
  15111. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  15112. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  15113. if (lowAdd > 0xFFFFFFFF) {
  15114. highAdd += 1;
  15115. }
  15116. this.low = lowAdd | 0;
  15117. this.high = highAdd | 0;
  15118. },
  15119. copyTo: function Word64_copyTo(bytes, offset) {
  15120. bytes[offset] = this.high >>> 24 & 0xFF;
  15121. bytes[offset + 1] = this.high >> 16 & 0xFF;
  15122. bytes[offset + 2] = this.high >> 8 & 0xFF;
  15123. bytes[offset + 3] = this.high & 0xFF;
  15124. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  15125. bytes[offset + 5] = this.low >> 16 & 0xFF;
  15126. bytes[offset + 6] = this.low >> 8 & 0xFF;
  15127. bytes[offset + 7] = this.low & 0xFF;
  15128. },
  15129. assign: function Word64_assign(word) {
  15130. this.high = word.high;
  15131. this.low = word.low;
  15132. }
  15133. };
  15134. return Word64;
  15135. }();
  15136. var calculateSHA256 = function calculateSHA256Closure() {
  15137. function rotr(x, n) {
  15138. return x >>> n | x << 32 - n;
  15139. }
  15140. function ch(x, y, z) {
  15141. return x & y ^ ~x & z;
  15142. }
  15143. function maj(x, y, z) {
  15144. return x & y ^ x & z ^ y & z;
  15145. }
  15146. function sigma(x) {
  15147. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  15148. }
  15149. function sigmaPrime(x) {
  15150. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  15151. }
  15152. function littleSigma(x) {
  15153. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  15154. }
  15155. function littleSigmaPrime(x) {
  15156. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  15157. }
  15158. var k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2];
  15159. function hash(data, offset, length) {
  15160. var h0 = 0x6a09e667,
  15161. h1 = 0xbb67ae85,
  15162. h2 = 0x3c6ef372,
  15163. h3 = 0xa54ff53a,
  15164. h4 = 0x510e527f,
  15165. h5 = 0x9b05688c,
  15166. h6 = 0x1f83d9ab,
  15167. h7 = 0x5be0cd19;
  15168. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  15169. var padded = new Uint8Array(paddedLength);
  15170. var i, j, n;
  15171. for (i = 0; i < length; ++i) {
  15172. padded[i] = data[offset++];
  15173. }
  15174. padded[i++] = 0x80;
  15175. n = paddedLength - 8;
  15176. while (i < n) {
  15177. padded[i++] = 0;
  15178. }
  15179. padded[i++] = 0;
  15180. padded[i++] = 0;
  15181. padded[i++] = 0;
  15182. padded[i++] = length >>> 29 & 0xFF;
  15183. padded[i++] = length >> 21 & 0xFF;
  15184. padded[i++] = length >> 13 & 0xFF;
  15185. padded[i++] = length >> 5 & 0xFF;
  15186. padded[i++] = length << 3 & 0xFF;
  15187. var w = new Uint32Array(64);
  15188. for (i = 0; i < paddedLength;) {
  15189. for (j = 0; j < 16; ++j) {
  15190. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  15191. i += 4;
  15192. }
  15193. for (j = 16; j < 64; ++j) {
  15194. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  15195. }
  15196. var a = h0,
  15197. b = h1,
  15198. c = h2,
  15199. d = h3,
  15200. e = h4,
  15201. f = h5,
  15202. g = h6,
  15203. h = h7,
  15204. t1,
  15205. t2;
  15206. for (j = 0; j < 64; ++j) {
  15207. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  15208. t2 = sigma(a) + maj(a, b, c);
  15209. h = g;
  15210. g = f;
  15211. f = e;
  15212. e = d + t1 | 0;
  15213. d = c;
  15214. c = b;
  15215. b = a;
  15216. a = t1 + t2 | 0;
  15217. }
  15218. h0 = h0 + a | 0;
  15219. h1 = h1 + b | 0;
  15220. h2 = h2 + c | 0;
  15221. h3 = h3 + d | 0;
  15222. h4 = h4 + e | 0;
  15223. h5 = h5 + f | 0;
  15224. h6 = h6 + g | 0;
  15225. h7 = h7 + h | 0;
  15226. }
  15227. return new Uint8Array([h0 >> 24 & 0xFF, h0 >> 16 & 0xFF, h0 >> 8 & 0xFF, h0 & 0xFF, h1 >> 24 & 0xFF, h1 >> 16 & 0xFF, h1 >> 8 & 0xFF, h1 & 0xFF, h2 >> 24 & 0xFF, h2 >> 16 & 0xFF, h2 >> 8 & 0xFF, h2 & 0xFF, h3 >> 24 & 0xFF, h3 >> 16 & 0xFF, h3 >> 8 & 0xFF, h3 & 0xFF, h4 >> 24 & 0xFF, h4 >> 16 & 0xFF, h4 >> 8 & 0xFF, h4 & 0xFF, h5 >> 24 & 0xFF, h5 >> 16 & 0xFF, h5 >> 8 & 0xFF, h5 & 0xFF, h6 >> 24 & 0xFF, h6 >> 16 & 0xFF, h6 >> 8 & 0xFF, h6 & 0xFF, h7 >> 24 & 0xFF, h7 >> 16 & 0xFF, h7 >> 8 & 0xFF, h7 & 0xFF]);
  15228. }
  15229. return hash;
  15230. }();
  15231. var calculateSHA512 = function calculateSHA512Closure() {
  15232. function ch(result, x, y, z, tmp) {
  15233. result.assign(x);
  15234. result.and(y);
  15235. tmp.assign(x);
  15236. tmp.not();
  15237. tmp.and(z);
  15238. result.xor(tmp);
  15239. }
  15240. function maj(result, x, y, z, tmp) {
  15241. result.assign(x);
  15242. result.and(y);
  15243. tmp.assign(x);
  15244. tmp.and(z);
  15245. result.xor(tmp);
  15246. tmp.assign(y);
  15247. tmp.and(z);
  15248. result.xor(tmp);
  15249. }
  15250. function sigma(result, x, tmp) {
  15251. result.assign(x);
  15252. result.rotateRight(28);
  15253. tmp.assign(x);
  15254. tmp.rotateRight(34);
  15255. result.xor(tmp);
  15256. tmp.assign(x);
  15257. tmp.rotateRight(39);
  15258. result.xor(tmp);
  15259. }
  15260. function sigmaPrime(result, x, tmp) {
  15261. result.assign(x);
  15262. result.rotateRight(14);
  15263. tmp.assign(x);
  15264. tmp.rotateRight(18);
  15265. result.xor(tmp);
  15266. tmp.assign(x);
  15267. tmp.rotateRight(41);
  15268. result.xor(tmp);
  15269. }
  15270. function littleSigma(result, x, tmp) {
  15271. result.assign(x);
  15272. result.rotateRight(1);
  15273. tmp.assign(x);
  15274. tmp.rotateRight(8);
  15275. result.xor(tmp);
  15276. tmp.assign(x);
  15277. tmp.shiftRight(7);
  15278. result.xor(tmp);
  15279. }
  15280. function littleSigmaPrime(result, x, tmp) {
  15281. result.assign(x);
  15282. result.rotateRight(19);
  15283. tmp.assign(x);
  15284. tmp.rotateRight(61);
  15285. result.xor(tmp);
  15286. tmp.assign(x);
  15287. tmp.shiftRight(6);
  15288. result.xor(tmp);
  15289. }
  15290. var k = [new Word64(0x428a2f98, 0xd728ae22), new Word64(0x71374491, 0x23ef65cd), new Word64(0xb5c0fbcf, 0xec4d3b2f), new Word64(0xe9b5dba5, 0x8189dbbc), new Word64(0x3956c25b, 0xf348b538), new Word64(0x59f111f1, 0xb605d019), new Word64(0x923f82a4, 0xaf194f9b), new Word64(0xab1c5ed5, 0xda6d8118), new Word64(0xd807aa98, 0xa3030242), new Word64(0x12835b01, 0x45706fbe), new Word64(0x243185be, 0x4ee4b28c), new Word64(0x550c7dc3, 0xd5ffb4e2), new Word64(0x72be5d74, 0xf27b896f), new Word64(0x80deb1fe, 0x3b1696b1), new Word64(0x9bdc06a7, 0x25c71235), new Word64(0xc19bf174, 0xcf692694), new Word64(0xe49b69c1, 0x9ef14ad2), new Word64(0xefbe4786, 0x384f25e3), new Word64(0x0fc19dc6, 0x8b8cd5b5), new Word64(0x240ca1cc, 0x77ac9c65), new Word64(0x2de92c6f, 0x592b0275), new Word64(0x4a7484aa, 0x6ea6e483), new Word64(0x5cb0a9dc, 0xbd41fbd4), new Word64(0x76f988da, 0x831153b5), new Word64(0x983e5152, 0xee66dfab), new Word64(0xa831c66d, 0x2db43210), new Word64(0xb00327c8, 0x98fb213f), new Word64(0xbf597fc7, 0xbeef0ee4), new Word64(0xc6e00bf3, 0x3da88fc2), new Word64(0xd5a79147, 0x930aa725), new Word64(0x06ca6351, 0xe003826f), new Word64(0x14292967, 0x0a0e6e70), new Word64(0x27b70a85, 0x46d22ffc), new Word64(0x2e1b2138, 0x5c26c926), new Word64(0x4d2c6dfc, 0x5ac42aed), new Word64(0x53380d13, 0x9d95b3df), new Word64(0x650a7354, 0x8baf63de), new Word64(0x766a0abb, 0x3c77b2a8), new Word64(0x81c2c92e, 0x47edaee6), new Word64(0x92722c85, 0x1482353b), new Word64(0xa2bfe8a1, 0x4cf10364), new Word64(0xa81a664b, 0xbc423001), new Word64(0xc24b8b70, 0xd0f89791), new Word64(0xc76c51a3, 0x0654be30), new Word64(0xd192e819, 0xd6ef5218), new Word64(0xd6990624, 0x5565a910), new Word64(0xf40e3585, 0x5771202a), new Word64(0x106aa070, 0x32bbd1b8), new Word64(0x19a4c116, 0xb8d2d0c8), new Word64(0x1e376c08, 0x5141ab53), new Word64(0x2748774c, 0xdf8eeb99), new Word64(0x34b0bcb5, 0xe19b48a8), new Word64(0x391c0cb3, 0xc5c95a63), new Word64(0x4ed8aa4a, 0xe3418acb), new Word64(0x5b9cca4f, 0x7763e373), new Word64(0x682e6ff3, 0xd6b2b8a3), new Word64(0x748f82ee, 0x5defb2fc), new Word64(0x78a5636f, 0x43172f60), new Word64(0x84c87814, 0xa1f0ab72), new Word64(0x8cc70208, 0x1a6439ec), new Word64(0x90befffa, 0x23631e28), new Word64(0xa4506ceb, 0xde82bde9), new Word64(0xbef9a3f7, 0xb2c67915), new Word64(0xc67178f2, 0xe372532b), new Word64(0xca273ece, 0xea26619c), new Word64(0xd186b8c7, 0x21c0c207), new Word64(0xeada7dd6, 0xcde0eb1e), new Word64(0xf57d4f7f, 0xee6ed178), new Word64(0x06f067aa, 0x72176fba), new Word64(0x0a637dc5, 0xa2c898a6), new Word64(0x113f9804, 0xbef90dae), new Word64(0x1b710b35, 0x131c471b), new Word64(0x28db77f5, 0x23047d84), new Word64(0x32caab7b, 0x40c72493), new Word64(0x3c9ebe0a, 0x15c9bebc), new Word64(0x431d67c4, 0x9c100d4c), new Word64(0x4cc5d4be, 0xcb3e42b6), new Word64(0x597f299c, 0xfc657e2a), new Word64(0x5fcb6fab, 0x3ad6faec), new Word64(0x6c44198c, 0x4a475817)];
  15291. function hash(data, offset, length, mode384) {
  15292. mode384 = !!mode384;
  15293. var h0, h1, h2, h3, h4, h5, h6, h7;
  15294. if (!mode384) {
  15295. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  15296. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  15297. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  15298. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  15299. h4 = new Word64(0x510e527f, 0xade682d1);
  15300. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  15301. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  15302. h7 = new Word64(0x5be0cd19, 0x137e2179);
  15303. } else {
  15304. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  15305. h1 = new Word64(0x629a292a, 0x367cd507);
  15306. h2 = new Word64(0x9159015a, 0x3070dd17);
  15307. h3 = new Word64(0x152fecd8, 0xf70e5939);
  15308. h4 = new Word64(0x67332667, 0xffc00b31);
  15309. h5 = new Word64(0x8eb44a87, 0x68581511);
  15310. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  15311. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  15312. }
  15313. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  15314. var padded = new Uint8Array(paddedLength);
  15315. var i, j, n;
  15316. for (i = 0; i < length; ++i) {
  15317. padded[i] = data[offset++];
  15318. }
  15319. padded[i++] = 0x80;
  15320. n = paddedLength - 16;
  15321. while (i < n) {
  15322. padded[i++] = 0;
  15323. }
  15324. padded[i++] = 0;
  15325. padded[i++] = 0;
  15326. padded[i++] = 0;
  15327. padded[i++] = 0;
  15328. padded[i++] = 0;
  15329. padded[i++] = 0;
  15330. padded[i++] = 0;
  15331. padded[i++] = 0;
  15332. padded[i++] = 0;
  15333. padded[i++] = 0;
  15334. padded[i++] = 0;
  15335. padded[i++] = length >>> 29 & 0xFF;
  15336. padded[i++] = length >> 21 & 0xFF;
  15337. padded[i++] = length >> 13 & 0xFF;
  15338. padded[i++] = length >> 5 & 0xFF;
  15339. padded[i++] = length << 3 & 0xFF;
  15340. var w = new Array(80);
  15341. for (i = 0; i < 80; i++) {
  15342. w[i] = new Word64(0, 0);
  15343. }
  15344. var a = new Word64(0, 0),
  15345. b = new Word64(0, 0),
  15346. c = new Word64(0, 0);
  15347. var d = new Word64(0, 0),
  15348. e = new Word64(0, 0),
  15349. f = new Word64(0, 0);
  15350. var g = new Word64(0, 0),
  15351. h = new Word64(0, 0);
  15352. var t1 = new Word64(0, 0),
  15353. t2 = new Word64(0, 0);
  15354. var tmp1 = new Word64(0, 0),
  15355. tmp2 = new Word64(0, 0),
  15356. tmp3;
  15357. for (i = 0; i < paddedLength;) {
  15358. for (j = 0; j < 16; ++j) {
  15359. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  15360. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  15361. i += 8;
  15362. }
  15363. for (j = 16; j < 80; ++j) {
  15364. tmp3 = w[j];
  15365. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  15366. tmp3.add(w[j - 7]);
  15367. littleSigma(tmp1, w[j - 15], tmp2);
  15368. tmp3.add(tmp1);
  15369. tmp3.add(w[j - 16]);
  15370. }
  15371. a.assign(h0);
  15372. b.assign(h1);
  15373. c.assign(h2);
  15374. d.assign(h3);
  15375. e.assign(h4);
  15376. f.assign(h5);
  15377. g.assign(h6);
  15378. h.assign(h7);
  15379. for (j = 0; j < 80; ++j) {
  15380. t1.assign(h);
  15381. sigmaPrime(tmp1, e, tmp2);
  15382. t1.add(tmp1);
  15383. ch(tmp1, e, f, g, tmp2);
  15384. t1.add(tmp1);
  15385. t1.add(k[j]);
  15386. t1.add(w[j]);
  15387. sigma(t2, a, tmp2);
  15388. maj(tmp1, a, b, c, tmp2);
  15389. t2.add(tmp1);
  15390. tmp3 = h;
  15391. h = g;
  15392. g = f;
  15393. f = e;
  15394. d.add(t1);
  15395. e = d;
  15396. d = c;
  15397. c = b;
  15398. b = a;
  15399. tmp3.assign(t1);
  15400. tmp3.add(t2);
  15401. a = tmp3;
  15402. }
  15403. h0.add(a);
  15404. h1.add(b);
  15405. h2.add(c);
  15406. h3.add(d);
  15407. h4.add(e);
  15408. h5.add(f);
  15409. h6.add(g);
  15410. h7.add(h);
  15411. }
  15412. var result;
  15413. if (!mode384) {
  15414. result = new Uint8Array(64);
  15415. h0.copyTo(result, 0);
  15416. h1.copyTo(result, 8);
  15417. h2.copyTo(result, 16);
  15418. h3.copyTo(result, 24);
  15419. h4.copyTo(result, 32);
  15420. h5.copyTo(result, 40);
  15421. h6.copyTo(result, 48);
  15422. h7.copyTo(result, 56);
  15423. } else {
  15424. result = new Uint8Array(48);
  15425. h0.copyTo(result, 0);
  15426. h1.copyTo(result, 8);
  15427. h2.copyTo(result, 16);
  15428. h3.copyTo(result, 24);
  15429. h4.copyTo(result, 32);
  15430. h5.copyTo(result, 40);
  15431. }
  15432. return result;
  15433. }
  15434. return hash;
  15435. }();
  15436. var calculateSHA384 = function calculateSHA384Closure() {
  15437. function hash(data, offset, length) {
  15438. return calculateSHA512(data, offset, length, true);
  15439. }
  15440. return hash;
  15441. }();
  15442. var NullCipher = function NullCipherClosure() {
  15443. function NullCipher() {}
  15444. NullCipher.prototype = {
  15445. decryptBlock: function NullCipher_decryptBlock(data) {
  15446. return data;
  15447. }
  15448. };
  15449. return NullCipher;
  15450. }();
  15451. var AES128Cipher = function AES128CipherClosure() {
  15452. var rcon = new Uint8Array([0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d]);
  15453. var s = new Uint8Array([0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]);
  15454. var inv_s = new Uint8Array([0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]);
  15455. var mixCol = new Uint8Array(256);
  15456. for (var i = 0; i < 256; i++) {
  15457. if (i < 128) {
  15458. mixCol[i] = i << 1;
  15459. } else {
  15460. mixCol[i] = i << 1 ^ 0x1b;
  15461. }
  15462. }
  15463. var mix = new Uint32Array([0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
  15464. function expandKey128(cipherKey) {
  15465. var b = 176,
  15466. result = new Uint8Array(b);
  15467. result.set(cipherKey);
  15468. for (var j = 16, i = 1; j < b; ++i) {
  15469. var t1 = result[j - 3],
  15470. t2 = result[j - 2],
  15471. t3 = result[j - 1],
  15472. t4 = result[j - 4];
  15473. t1 = s[t1];
  15474. t2 = s[t2];
  15475. t3 = s[t3];
  15476. t4 = s[t4];
  15477. t1 = t1 ^ rcon[i];
  15478. for (var n = 0; n < 4; ++n) {
  15479. result[j] = t1 ^= result[j - 16];
  15480. j++;
  15481. result[j] = t2 ^= result[j - 16];
  15482. j++;
  15483. result[j] = t3 ^= result[j - 16];
  15484. j++;
  15485. result[j] = t4 ^= result[j - 16];
  15486. j++;
  15487. }
  15488. }
  15489. return result;
  15490. }
  15491. function decrypt128(input, key) {
  15492. var state = new Uint8Array(16);
  15493. state.set(input);
  15494. var i, j, k;
  15495. var t, u, v;
  15496. for (j = 0, k = 160; j < 16; ++j, ++k) {
  15497. state[j] ^= key[k];
  15498. }
  15499. for (i = 9; i >= 1; --i) {
  15500. t = state[13];
  15501. state[13] = state[9];
  15502. state[9] = state[5];
  15503. state[5] = state[1];
  15504. state[1] = t;
  15505. t = state[14];
  15506. u = state[10];
  15507. state[14] = state[6];
  15508. state[10] = state[2];
  15509. state[6] = t;
  15510. state[2] = u;
  15511. t = state[15];
  15512. u = state[11];
  15513. v = state[7];
  15514. state[15] = state[3];
  15515. state[11] = t;
  15516. state[7] = u;
  15517. state[3] = v;
  15518. for (j = 0; j < 16; ++j) {
  15519. state[j] = inv_s[state[j]];
  15520. }
  15521. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  15522. state[j] ^= key[k];
  15523. }
  15524. for (j = 0; j < 16; j += 4) {
  15525. var s0 = mix[state[j]],
  15526. s1 = mix[state[j + 1]],
  15527. s2 = mix[state[j + 2]],
  15528. s3 = mix[state[j + 3]];
  15529. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  15530. state[j] = t >>> 24 & 0xFF;
  15531. state[j + 1] = t >> 16 & 0xFF;
  15532. state[j + 2] = t >> 8 & 0xFF;
  15533. state[j + 3] = t & 0xFF;
  15534. }
  15535. }
  15536. t = state[13];
  15537. state[13] = state[9];
  15538. state[9] = state[5];
  15539. state[5] = state[1];
  15540. state[1] = t;
  15541. t = state[14];
  15542. u = state[10];
  15543. state[14] = state[6];
  15544. state[10] = state[2];
  15545. state[6] = t;
  15546. state[2] = u;
  15547. t = state[15];
  15548. u = state[11];
  15549. v = state[7];
  15550. state[15] = state[3];
  15551. state[11] = t;
  15552. state[7] = u;
  15553. state[3] = v;
  15554. for (j = 0; j < 16; ++j) {
  15555. state[j] = inv_s[state[j]];
  15556. state[j] ^= key[j];
  15557. }
  15558. return state;
  15559. }
  15560. function encrypt128(input, key) {
  15561. var t, u, v, j, k;
  15562. var state = new Uint8Array(16);
  15563. state.set(input);
  15564. for (j = 0; j < 16; ++j) {
  15565. state[j] ^= key[j];
  15566. }
  15567. for (i = 1; i < 10; i++) {
  15568. for (j = 0; j < 16; ++j) {
  15569. state[j] = s[state[j]];
  15570. }
  15571. v = state[1];
  15572. state[1] = state[5];
  15573. state[5] = state[9];
  15574. state[9] = state[13];
  15575. state[13] = v;
  15576. v = state[2];
  15577. u = state[6];
  15578. state[2] = state[10];
  15579. state[6] = state[14];
  15580. state[10] = v;
  15581. state[14] = u;
  15582. v = state[3];
  15583. u = state[7];
  15584. t = state[11];
  15585. state[3] = state[15];
  15586. state[7] = v;
  15587. state[11] = u;
  15588. state[15] = t;
  15589. for (j = 0; j < 16; j += 4) {
  15590. var s0 = state[j + 0],
  15591. s1 = state[j + 1];
  15592. var s2 = state[j + 2],
  15593. s3 = state[j + 3];
  15594. t = s0 ^ s1 ^ s2 ^ s3;
  15595. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  15596. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  15597. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  15598. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  15599. }
  15600. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  15601. state[j] ^= key[k];
  15602. }
  15603. }
  15604. for (j = 0; j < 16; ++j) {
  15605. state[j] = s[state[j]];
  15606. }
  15607. v = state[1];
  15608. state[1] = state[5];
  15609. state[5] = state[9];
  15610. state[9] = state[13];
  15611. state[13] = v;
  15612. v = state[2];
  15613. u = state[6];
  15614. state[2] = state[10];
  15615. state[6] = state[14];
  15616. state[10] = v;
  15617. state[14] = u;
  15618. v = state[3];
  15619. u = state[7];
  15620. t = state[11];
  15621. state[3] = state[15];
  15622. state[7] = v;
  15623. state[11] = u;
  15624. state[15] = t;
  15625. for (j = 0, k = 160; j < 16; ++j, ++k) {
  15626. state[j] ^= key[k];
  15627. }
  15628. return state;
  15629. }
  15630. function AES128Cipher(key) {
  15631. this.key = expandKey128(key);
  15632. this.buffer = new Uint8Array(16);
  15633. this.bufferPosition = 0;
  15634. }
  15635. function decryptBlock2(data, finalize) {
  15636. var i,
  15637. j,
  15638. ii,
  15639. sourceLength = data.length,
  15640. buffer = this.buffer,
  15641. bufferLength = this.bufferPosition,
  15642. result = [],
  15643. iv = this.iv;
  15644. for (i = 0; i < sourceLength; ++i) {
  15645. buffer[bufferLength] = data[i];
  15646. ++bufferLength;
  15647. if (bufferLength < 16) {
  15648. continue;
  15649. }
  15650. var plain = decrypt128(buffer, this.key);
  15651. for (j = 0; j < 16; ++j) {
  15652. plain[j] ^= iv[j];
  15653. }
  15654. iv = buffer;
  15655. result.push(plain);
  15656. buffer = new Uint8Array(16);
  15657. bufferLength = 0;
  15658. }
  15659. this.buffer = buffer;
  15660. this.bufferLength = bufferLength;
  15661. this.iv = iv;
  15662. if (result.length === 0) {
  15663. return new Uint8Array([]);
  15664. }
  15665. var outputLength = 16 * result.length;
  15666. if (finalize) {
  15667. var lastBlock = result[result.length - 1];
  15668. var psLen = lastBlock[15];
  15669. if (psLen <= 16) {
  15670. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  15671. if (lastBlock[i] !== psLen) {
  15672. psLen = 0;
  15673. break;
  15674. }
  15675. }
  15676. outputLength -= psLen;
  15677. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  15678. }
  15679. }
  15680. var output = new Uint8Array(outputLength);
  15681. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  15682. output.set(result[i], j);
  15683. }
  15684. return output;
  15685. }
  15686. AES128Cipher.prototype = {
  15687. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  15688. var i,
  15689. sourceLength = data.length;
  15690. var buffer = this.buffer,
  15691. bufferLength = this.bufferPosition;
  15692. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  15693. buffer[bufferLength] = data[i];
  15694. }
  15695. if (bufferLength < 16) {
  15696. this.bufferLength = bufferLength;
  15697. return new Uint8Array([]);
  15698. }
  15699. this.iv = buffer;
  15700. this.buffer = new Uint8Array(16);
  15701. this.bufferLength = 0;
  15702. this.decryptBlock = decryptBlock2;
  15703. return this.decryptBlock(data.subarray(16), finalize);
  15704. },
  15705. encrypt: function AES128Cipher_encrypt(data, iv) {
  15706. var i,
  15707. j,
  15708. ii,
  15709. sourceLength = data.length,
  15710. buffer = this.buffer,
  15711. bufferLength = this.bufferPosition,
  15712. result = [];
  15713. if (!iv) {
  15714. iv = new Uint8Array(16);
  15715. }
  15716. for (i = 0; i < sourceLength; ++i) {
  15717. buffer[bufferLength] = data[i];
  15718. ++bufferLength;
  15719. if (bufferLength < 16) {
  15720. continue;
  15721. }
  15722. for (j = 0; j < 16; ++j) {
  15723. buffer[j] ^= iv[j];
  15724. }
  15725. var cipher = encrypt128(buffer, this.key);
  15726. iv = cipher;
  15727. result.push(cipher);
  15728. buffer = new Uint8Array(16);
  15729. bufferLength = 0;
  15730. }
  15731. this.buffer = buffer;
  15732. this.bufferLength = bufferLength;
  15733. this.iv = iv;
  15734. if (result.length === 0) {
  15735. return new Uint8Array([]);
  15736. }
  15737. var outputLength = 16 * result.length;
  15738. var output = new Uint8Array(outputLength);
  15739. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  15740. output.set(result[i], j);
  15741. }
  15742. return output;
  15743. }
  15744. };
  15745. return AES128Cipher;
  15746. }();
  15747. var AES256Cipher = function AES256CipherClosure() {
  15748. var s = new Uint8Array([0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]);
  15749. var inv_s = new Uint8Array([0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]);
  15750. var mixCol = new Uint8Array(256);
  15751. for (var i = 0; i < 256; i++) {
  15752. if (i < 128) {
  15753. mixCol[i] = i << 1;
  15754. } else {
  15755. mixCol[i] = i << 1 ^ 0x1b;
  15756. }
  15757. }
  15758. var mix = new Uint32Array([0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]);
  15759. function expandKey256(cipherKey) {
  15760. var b = 240,
  15761. result = new Uint8Array(b);
  15762. var r = 1;
  15763. result.set(cipherKey);
  15764. for (var j = 32, i = 1; j < b; ++i) {
  15765. var t1, t2, t3, t4;
  15766. if (j % 32 === 16) {
  15767. t1 = s[t1];
  15768. t2 = s[t2];
  15769. t3 = s[t3];
  15770. t4 = s[t4];
  15771. } else if (j % 32 === 0) {
  15772. t1 = result[j - 3];
  15773. t2 = result[j - 2];
  15774. t3 = result[j - 1];
  15775. t4 = result[j - 4];
  15776. t1 = s[t1];
  15777. t2 = s[t2];
  15778. t3 = s[t3];
  15779. t4 = s[t4];
  15780. t1 = t1 ^ r;
  15781. if ((r <<= 1) >= 256) {
  15782. r = (r ^ 0x1b) & 0xFF;
  15783. }
  15784. }
  15785. for (var n = 0; n < 4; ++n) {
  15786. result[j] = t1 ^= result[j - 32];
  15787. j++;
  15788. result[j] = t2 ^= result[j - 32];
  15789. j++;
  15790. result[j] = t3 ^= result[j - 32];
  15791. j++;
  15792. result[j] = t4 ^= result[j - 32];
  15793. j++;
  15794. }
  15795. }
  15796. return result;
  15797. }
  15798. function decrypt256(input, key) {
  15799. var state = new Uint8Array(16);
  15800. state.set(input);
  15801. var i, j, k;
  15802. var t, u, v;
  15803. for (j = 0, k = 224; j < 16; ++j, ++k) {
  15804. state[j] ^= key[k];
  15805. }
  15806. for (i = 13; i >= 1; --i) {
  15807. t = state[13];
  15808. state[13] = state[9];
  15809. state[9] = state[5];
  15810. state[5] = state[1];
  15811. state[1] = t;
  15812. t = state[14];
  15813. u = state[10];
  15814. state[14] = state[6];
  15815. state[10] = state[2];
  15816. state[6] = t;
  15817. state[2] = u;
  15818. t = state[15];
  15819. u = state[11];
  15820. v = state[7];
  15821. state[15] = state[3];
  15822. state[11] = t;
  15823. state[7] = u;
  15824. state[3] = v;
  15825. for (j = 0; j < 16; ++j) {
  15826. state[j] = inv_s[state[j]];
  15827. }
  15828. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  15829. state[j] ^= key[k];
  15830. }
  15831. for (j = 0; j < 16; j += 4) {
  15832. var s0 = mix[state[j]],
  15833. s1 = mix[state[j + 1]],
  15834. s2 = mix[state[j + 2]],
  15835. s3 = mix[state[j + 3]];
  15836. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  15837. state[j] = t >>> 24 & 0xFF;
  15838. state[j + 1] = t >> 16 & 0xFF;
  15839. state[j + 2] = t >> 8 & 0xFF;
  15840. state[j + 3] = t & 0xFF;
  15841. }
  15842. }
  15843. t = state[13];
  15844. state[13] = state[9];
  15845. state[9] = state[5];
  15846. state[5] = state[1];
  15847. state[1] = t;
  15848. t = state[14];
  15849. u = state[10];
  15850. state[14] = state[6];
  15851. state[10] = state[2];
  15852. state[6] = t;
  15853. state[2] = u;
  15854. t = state[15];
  15855. u = state[11];
  15856. v = state[7];
  15857. state[15] = state[3];
  15858. state[11] = t;
  15859. state[7] = u;
  15860. state[3] = v;
  15861. for (j = 0; j < 16; ++j) {
  15862. state[j] = inv_s[state[j]];
  15863. state[j] ^= key[j];
  15864. }
  15865. return state;
  15866. }
  15867. function encrypt256(input, key) {
  15868. var t, u, v, i, j, k;
  15869. var state = new Uint8Array(16);
  15870. state.set(input);
  15871. for (j = 0; j < 16; ++j) {
  15872. state[j] ^= key[j];
  15873. }
  15874. for (i = 1; i < 14; i++) {
  15875. for (j = 0; j < 16; ++j) {
  15876. state[j] = s[state[j]];
  15877. }
  15878. v = state[1];
  15879. state[1] = state[5];
  15880. state[5] = state[9];
  15881. state[9] = state[13];
  15882. state[13] = v;
  15883. v = state[2];
  15884. u = state[6];
  15885. state[2] = state[10];
  15886. state[6] = state[14];
  15887. state[10] = v;
  15888. state[14] = u;
  15889. v = state[3];
  15890. u = state[7];
  15891. t = state[11];
  15892. state[3] = state[15];
  15893. state[7] = v;
  15894. state[11] = u;
  15895. state[15] = t;
  15896. for (j = 0; j < 16; j += 4) {
  15897. var s0 = state[j + 0],
  15898. s1 = state[j + 1];
  15899. var s2 = state[j + 2],
  15900. s3 = state[j + 3];
  15901. t = s0 ^ s1 ^ s2 ^ s3;
  15902. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  15903. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  15904. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  15905. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  15906. }
  15907. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  15908. state[j] ^= key[k];
  15909. }
  15910. }
  15911. for (j = 0; j < 16; ++j) {
  15912. state[j] = s[state[j]];
  15913. }
  15914. v = state[1];
  15915. state[1] = state[5];
  15916. state[5] = state[9];
  15917. state[9] = state[13];
  15918. state[13] = v;
  15919. v = state[2];
  15920. u = state[6];
  15921. state[2] = state[10];
  15922. state[6] = state[14];
  15923. state[10] = v;
  15924. state[14] = u;
  15925. v = state[3];
  15926. u = state[7];
  15927. t = state[11];
  15928. state[3] = state[15];
  15929. state[7] = v;
  15930. state[11] = u;
  15931. state[15] = t;
  15932. for (j = 0, k = 224; j < 16; ++j, ++k) {
  15933. state[j] ^= key[k];
  15934. }
  15935. return state;
  15936. }
  15937. function AES256Cipher(key) {
  15938. this.key = expandKey256(key);
  15939. this.buffer = new Uint8Array(16);
  15940. this.bufferPosition = 0;
  15941. }
  15942. function decryptBlock2(data, finalize) {
  15943. var i,
  15944. j,
  15945. ii,
  15946. sourceLength = data.length,
  15947. buffer = this.buffer,
  15948. bufferLength = this.bufferPosition,
  15949. result = [],
  15950. iv = this.iv;
  15951. for (i = 0; i < sourceLength; ++i) {
  15952. buffer[bufferLength] = data[i];
  15953. ++bufferLength;
  15954. if (bufferLength < 16) {
  15955. continue;
  15956. }
  15957. var plain = decrypt256(buffer, this.key);
  15958. for (j = 0; j < 16; ++j) {
  15959. plain[j] ^= iv[j];
  15960. }
  15961. iv = buffer;
  15962. result.push(plain);
  15963. buffer = new Uint8Array(16);
  15964. bufferLength = 0;
  15965. }
  15966. this.buffer = buffer;
  15967. this.bufferLength = bufferLength;
  15968. this.iv = iv;
  15969. if (result.length === 0) {
  15970. return new Uint8Array([]);
  15971. }
  15972. var outputLength = 16 * result.length;
  15973. if (finalize) {
  15974. var lastBlock = result[result.length - 1];
  15975. var psLen = lastBlock[15];
  15976. if (psLen <= 16) {
  15977. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  15978. if (lastBlock[i] !== psLen) {
  15979. psLen = 0;
  15980. break;
  15981. }
  15982. }
  15983. outputLength -= psLen;
  15984. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  15985. }
  15986. }
  15987. var output = new Uint8Array(outputLength);
  15988. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  15989. output.set(result[i], j);
  15990. }
  15991. return output;
  15992. }
  15993. AES256Cipher.prototype = {
  15994. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  15995. var i,
  15996. sourceLength = data.length;
  15997. var buffer = this.buffer,
  15998. bufferLength = this.bufferPosition;
  15999. if (iv) {
  16000. this.iv = iv;
  16001. } else {
  16002. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  16003. buffer[bufferLength] = data[i];
  16004. }
  16005. if (bufferLength < 16) {
  16006. this.bufferLength = bufferLength;
  16007. return new Uint8Array([]);
  16008. }
  16009. this.iv = buffer;
  16010. data = data.subarray(16);
  16011. }
  16012. this.buffer = new Uint8Array(16);
  16013. this.bufferLength = 0;
  16014. this.decryptBlock = decryptBlock2;
  16015. return this.decryptBlock(data, finalize);
  16016. },
  16017. encrypt: function AES256Cipher_encrypt(data, iv) {
  16018. var i,
  16019. j,
  16020. ii,
  16021. sourceLength = data.length,
  16022. buffer = this.buffer,
  16023. bufferLength = this.bufferPosition,
  16024. result = [];
  16025. if (!iv) {
  16026. iv = new Uint8Array(16);
  16027. }
  16028. for (i = 0; i < sourceLength; ++i) {
  16029. buffer[bufferLength] = data[i];
  16030. ++bufferLength;
  16031. if (bufferLength < 16) {
  16032. continue;
  16033. }
  16034. for (j = 0; j < 16; ++j) {
  16035. buffer[j] ^= iv[j];
  16036. }
  16037. var cipher = encrypt256(buffer, this.key);
  16038. this.iv = cipher;
  16039. result.push(cipher);
  16040. buffer = new Uint8Array(16);
  16041. bufferLength = 0;
  16042. }
  16043. this.buffer = buffer;
  16044. this.bufferLength = bufferLength;
  16045. this.iv = iv;
  16046. if (result.length === 0) {
  16047. return new Uint8Array([]);
  16048. }
  16049. var outputLength = 16 * result.length;
  16050. var output = new Uint8Array(outputLength);
  16051. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  16052. output.set(result[i], j);
  16053. }
  16054. return output;
  16055. }
  16056. };
  16057. return AES256Cipher;
  16058. }();
  16059. var PDF17 = function PDF17Closure() {
  16060. function compareByteArrays(array1, array2) {
  16061. if (array1.length !== array2.length) {
  16062. return false;
  16063. }
  16064. for (var i = 0; i < array1.length; i++) {
  16065. if (array1[i] !== array2[i]) {
  16066. return false;
  16067. }
  16068. }
  16069. return true;
  16070. }
  16071. function PDF17() {}
  16072. PDF17.prototype = {
  16073. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  16074. var hashData = new Uint8Array(password.length + 56);
  16075. hashData.set(password, 0);
  16076. hashData.set(ownerValidationSalt, password.length);
  16077. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  16078. var result = calculateSHA256(hashData, 0, hashData.length);
  16079. return compareByteArrays(result, ownerPassword);
  16080. },
  16081. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  16082. var hashData = new Uint8Array(password.length + 8);
  16083. hashData.set(password, 0);
  16084. hashData.set(userValidationSalt, password.length);
  16085. var result = calculateSHA256(hashData, 0, hashData.length);
  16086. return compareByteArrays(result, userPassword);
  16087. },
  16088. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  16089. var hashData = new Uint8Array(password.length + 56);
  16090. hashData.set(password, 0);
  16091. hashData.set(ownerKeySalt, password.length);
  16092. hashData.set(userBytes, password.length + ownerKeySalt.length);
  16093. var key = calculateSHA256(hashData, 0, hashData.length);
  16094. var cipher = new AES256Cipher(key);
  16095. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  16096. },
  16097. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  16098. var hashData = new Uint8Array(password.length + 8);
  16099. hashData.set(password, 0);
  16100. hashData.set(userKeySalt, password.length);
  16101. var key = calculateSHA256(hashData, 0, hashData.length);
  16102. var cipher = new AES256Cipher(key);
  16103. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  16104. }
  16105. };
  16106. return PDF17;
  16107. }();
  16108. var PDF20 = function PDF20Closure() {
  16109. function concatArrays(array1, array2) {
  16110. var t = new Uint8Array(array1.length + array2.length);
  16111. t.set(array1, 0);
  16112. t.set(array2, array1.length);
  16113. return t;
  16114. }
  16115. function calculatePDF20Hash(password, input, userBytes) {
  16116. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  16117. var e = [0];
  16118. var i = 0;
  16119. while (i < 64 || e[e.length - 1] > i - 32) {
  16120. var arrayLength = password.length + k.length + userBytes.length;
  16121. var k1 = new Uint8Array(arrayLength * 64);
  16122. var array = concatArrays(password, k);
  16123. array = concatArrays(array, userBytes);
  16124. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  16125. k1.set(array, pos);
  16126. }
  16127. var cipher = new AES128Cipher(k.subarray(0, 16));
  16128. e = cipher.encrypt(k1, k.subarray(16, 32));
  16129. var remainder = 0;
  16130. for (var z = 0; z < 16; z++) {
  16131. remainder *= 256 % 3;
  16132. remainder %= 3;
  16133. remainder += (e[z] >>> 0) % 3;
  16134. remainder %= 3;
  16135. }
  16136. if (remainder === 0) {
  16137. k = calculateSHA256(e, 0, e.length);
  16138. } else if (remainder === 1) {
  16139. k = calculateSHA384(e, 0, e.length);
  16140. } else if (remainder === 2) {
  16141. k = calculateSHA512(e, 0, e.length);
  16142. }
  16143. i++;
  16144. }
  16145. return k.subarray(0, 32);
  16146. }
  16147. function PDF20() {}
  16148. function compareByteArrays(array1, array2) {
  16149. if (array1.length !== array2.length) {
  16150. return false;
  16151. }
  16152. for (var i = 0; i < array1.length; i++) {
  16153. if (array1[i] !== array2[i]) {
  16154. return false;
  16155. }
  16156. }
  16157. return true;
  16158. }
  16159. PDF20.prototype = {
  16160. hash: function PDF20_hash(password, concatBytes, userBytes) {
  16161. return calculatePDF20Hash(password, concatBytes, userBytes);
  16162. },
  16163. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  16164. var hashData = new Uint8Array(password.length + 56);
  16165. hashData.set(password, 0);
  16166. hashData.set(ownerValidationSalt, password.length);
  16167. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  16168. var result = calculatePDF20Hash(password, hashData, userBytes);
  16169. return compareByteArrays(result, ownerPassword);
  16170. },
  16171. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  16172. var hashData = new Uint8Array(password.length + 8);
  16173. hashData.set(password, 0);
  16174. hashData.set(userValidationSalt, password.length);
  16175. var result = calculatePDF20Hash(password, hashData, []);
  16176. return compareByteArrays(result, userPassword);
  16177. },
  16178. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  16179. var hashData = new Uint8Array(password.length + 56);
  16180. hashData.set(password, 0);
  16181. hashData.set(ownerKeySalt, password.length);
  16182. hashData.set(userBytes, password.length + ownerKeySalt.length);
  16183. var key = calculatePDF20Hash(password, hashData, userBytes);
  16184. var cipher = new AES256Cipher(key);
  16185. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  16186. },
  16187. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  16188. var hashData = new Uint8Array(password.length + 8);
  16189. hashData.set(password, 0);
  16190. hashData.set(userKeySalt, password.length);
  16191. var key = calculatePDF20Hash(password, hashData, []);
  16192. var cipher = new AES256Cipher(key);
  16193. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  16194. }
  16195. };
  16196. return PDF20;
  16197. }();
  16198. var CipherTransform = function CipherTransformClosure() {
  16199. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  16200. this.StringCipherConstructor = stringCipherConstructor;
  16201. this.StreamCipherConstructor = streamCipherConstructor;
  16202. }
  16203. CipherTransform.prototype = {
  16204. createStream: function CipherTransform_createStream(stream, length) {
  16205. var cipher = new this.StreamCipherConstructor();
  16206. return new _stream.DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  16207. return cipher.decryptBlock(data, finalize);
  16208. });
  16209. },
  16210. decryptString: function CipherTransform_decryptString(s) {
  16211. var cipher = new this.StringCipherConstructor();
  16212. var data = (0, _util.stringToBytes)(s);
  16213. data = cipher.decryptBlock(data, true);
  16214. return (0, _util.bytesToString)(data);
  16215. }
  16216. };
  16217. return CipherTransform;
  16218. }();
  16219. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  16220. var defaultPasswordBytes = new Uint8Array([0x28, 0xBF, 0x4E, 0x5E, 0x4E, 0x75, 0x8A, 0x41, 0x64, 0x00, 0x4E, 0x56, 0xFF, 0xFA, 0x01, 0x08, 0x2E, 0x2E, 0x00, 0xB6, 0xD0, 0x68, 0x3E, 0x80, 0x2F, 0x0C, 0xA9, 0xFE, 0x64, 0x53, 0x69, 0x7A]);
  16221. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  16222. if (password) {
  16223. var passwordLength = Math.min(127, password.length);
  16224. password = password.subarray(0, passwordLength);
  16225. } else {
  16226. password = [];
  16227. }
  16228. var pdfAlgorithm;
  16229. if (revision === 6) {
  16230. pdfAlgorithm = new PDF20();
  16231. } else {
  16232. pdfAlgorithm = new PDF17();
  16233. }
  16234. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  16235. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  16236. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  16237. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  16238. }
  16239. return null;
  16240. }
  16241. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  16242. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  16243. var hashData = new Uint8Array(hashDataSize),
  16244. i = 0,
  16245. j,
  16246. n;
  16247. if (password) {
  16248. n = Math.min(32, password.length);
  16249. for (; i < n; ++i) {
  16250. hashData[i] = password[i];
  16251. }
  16252. }
  16253. j = 0;
  16254. while (i < 32) {
  16255. hashData[i++] = defaultPasswordBytes[j++];
  16256. }
  16257. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  16258. hashData[i++] = ownerPassword[j];
  16259. }
  16260. hashData[i++] = flags & 0xFF;
  16261. hashData[i++] = flags >> 8 & 0xFF;
  16262. hashData[i++] = flags >> 16 & 0xFF;
  16263. hashData[i++] = flags >>> 24 & 0xFF;
  16264. for (j = 0, n = fileId.length; j < n; ++j) {
  16265. hashData[i++] = fileId[j];
  16266. }
  16267. if (revision >= 4 && !encryptMetadata) {
  16268. hashData[i++] = 0xFF;
  16269. hashData[i++] = 0xFF;
  16270. hashData[i++] = 0xFF;
  16271. hashData[i++] = 0xFF;
  16272. }
  16273. var hash = calculateMD5(hashData, 0, i);
  16274. var keyLengthInBytes = keyLength >> 3;
  16275. if (revision >= 3) {
  16276. for (j = 0; j < 50; ++j) {
  16277. hash = calculateMD5(hash, 0, keyLengthInBytes);
  16278. }
  16279. }
  16280. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  16281. var cipher, checkData;
  16282. if (revision >= 3) {
  16283. for (i = 0; i < 32; ++i) {
  16284. hashData[i] = defaultPasswordBytes[i];
  16285. }
  16286. for (j = 0, n = fileId.length; j < n; ++j) {
  16287. hashData[i++] = fileId[j];
  16288. }
  16289. cipher = new ARCFourCipher(encryptionKey);
  16290. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  16291. n = encryptionKey.length;
  16292. var derivedKey = new Uint8Array(n),
  16293. k;
  16294. for (j = 1; j <= 19; ++j) {
  16295. for (k = 0; k < n; ++k) {
  16296. derivedKey[k] = encryptionKey[k] ^ j;
  16297. }
  16298. cipher = new ARCFourCipher(derivedKey);
  16299. checkData = cipher.encryptBlock(checkData);
  16300. }
  16301. for (j = 0, n = checkData.length; j < n; ++j) {
  16302. if (userPassword[j] !== checkData[j]) {
  16303. return null;
  16304. }
  16305. }
  16306. } else {
  16307. cipher = new ARCFourCipher(encryptionKey);
  16308. checkData = cipher.encryptBlock(defaultPasswordBytes);
  16309. for (j = 0, n = checkData.length; j < n; ++j) {
  16310. if (userPassword[j] !== checkData[j]) {
  16311. return null;
  16312. }
  16313. }
  16314. }
  16315. return encryptionKey;
  16316. }
  16317. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  16318. var hashData = new Uint8Array(32),
  16319. i = 0,
  16320. j,
  16321. n;
  16322. n = Math.min(32, password.length);
  16323. for (; i < n; ++i) {
  16324. hashData[i] = password[i];
  16325. }
  16326. j = 0;
  16327. while (i < 32) {
  16328. hashData[i++] = defaultPasswordBytes[j++];
  16329. }
  16330. var hash = calculateMD5(hashData, 0, i);
  16331. var keyLengthInBytes = keyLength >> 3;
  16332. if (revision >= 3) {
  16333. for (j = 0; j < 50; ++j) {
  16334. hash = calculateMD5(hash, 0, hash.length);
  16335. }
  16336. }
  16337. var cipher, userPassword;
  16338. if (revision >= 3) {
  16339. userPassword = ownerPassword;
  16340. var derivedKey = new Uint8Array(keyLengthInBytes),
  16341. k;
  16342. for (j = 19; j >= 0; j--) {
  16343. for (k = 0; k < keyLengthInBytes; ++k) {
  16344. derivedKey[k] = hash[k] ^ j;
  16345. }
  16346. cipher = new ARCFourCipher(derivedKey);
  16347. userPassword = cipher.encryptBlock(userPassword);
  16348. }
  16349. } else {
  16350. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  16351. userPassword = cipher.encryptBlock(ownerPassword);
  16352. }
  16353. return userPassword;
  16354. }
  16355. var identityName = _primitives.Name.get('Identity');
  16356. function CipherTransformFactory(dict, fileId, password) {
  16357. var filter = dict.get('Filter');
  16358. if (!(0, _primitives.isName)(filter, 'Standard')) {
  16359. throw new _util.FormatError('unknown encryption method');
  16360. }
  16361. this.dict = dict;
  16362. var algorithm = dict.get('V');
  16363. if (!Number.isInteger(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  16364. throw new _util.FormatError('unsupported encryption algorithm');
  16365. }
  16366. this.algorithm = algorithm;
  16367. var keyLength = dict.get('Length');
  16368. if (!keyLength) {
  16369. if (algorithm <= 3) {
  16370. keyLength = 40;
  16371. } else {
  16372. var cfDict = dict.get('CF');
  16373. var streamCryptoName = dict.get('StmF');
  16374. if ((0, _primitives.isDict)(cfDict) && (0, _primitives.isName)(streamCryptoName)) {
  16375. cfDict.suppressEncryption = true;
  16376. var handlerDict = cfDict.get(streamCryptoName.name);
  16377. keyLength = handlerDict && handlerDict.get('Length') || 128;
  16378. if (keyLength < 40) {
  16379. keyLength <<= 3;
  16380. }
  16381. }
  16382. }
  16383. }
  16384. if (!Number.isInteger(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  16385. throw new _util.FormatError('invalid key length');
  16386. }
  16387. var ownerPassword = (0, _util.stringToBytes)(dict.get('O')).subarray(0, 32);
  16388. var userPassword = (0, _util.stringToBytes)(dict.get('U')).subarray(0, 32);
  16389. var flags = dict.get('P');
  16390. var revision = dict.get('R');
  16391. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  16392. this.encryptMetadata = encryptMetadata;
  16393. var fileIdBytes = (0, _util.stringToBytes)(fileId);
  16394. var passwordBytes;
  16395. if (password) {
  16396. if (revision === 6) {
  16397. try {
  16398. password = (0, _util.utf8StringToString)(password);
  16399. } catch (ex) {
  16400. (0, _util.warn)('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  16401. }
  16402. }
  16403. passwordBytes = (0, _util.stringToBytes)(password);
  16404. }
  16405. var encryptionKey;
  16406. if (algorithm !== 5) {
  16407. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  16408. } else {
  16409. var ownerValidationSalt = (0, _util.stringToBytes)(dict.get('O')).subarray(32, 40);
  16410. var ownerKeySalt = (0, _util.stringToBytes)(dict.get('O')).subarray(40, 48);
  16411. var uBytes = (0, _util.stringToBytes)(dict.get('U')).subarray(0, 48);
  16412. var userValidationSalt = (0, _util.stringToBytes)(dict.get('U')).subarray(32, 40);
  16413. var userKeySalt = (0, _util.stringToBytes)(dict.get('U')).subarray(40, 48);
  16414. var ownerEncryption = (0, _util.stringToBytes)(dict.get('OE'));
  16415. var userEncryption = (0, _util.stringToBytes)(dict.get('UE'));
  16416. var perms = (0, _util.stringToBytes)(dict.get('Perms'));
  16417. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  16418. }
  16419. if (!encryptionKey && !password) {
  16420. throw new _util.PasswordException('No password given', _util.PasswordResponses.NEED_PASSWORD);
  16421. } else if (!encryptionKey && password) {
  16422. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  16423. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  16424. }
  16425. if (!encryptionKey) {
  16426. throw new _util.PasswordException('Incorrect Password', _util.PasswordResponses.INCORRECT_PASSWORD);
  16427. }
  16428. this.encryptionKey = encryptionKey;
  16429. if (algorithm >= 4) {
  16430. var cf = dict.get('CF');
  16431. if ((0, _primitives.isDict)(cf)) {
  16432. cf.suppressEncryption = true;
  16433. }
  16434. this.cf = cf;
  16435. this.stmf = dict.get('StmF') || identityName;
  16436. this.strf = dict.get('StrF') || identityName;
  16437. this.eff = dict.get('EFF') || this.stmf;
  16438. }
  16439. }
  16440. function buildObjectKey(num, gen, encryptionKey, isAes) {
  16441. var key = new Uint8Array(encryptionKey.length + 9),
  16442. i,
  16443. n;
  16444. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  16445. key[i] = encryptionKey[i];
  16446. }
  16447. key[i++] = num & 0xFF;
  16448. key[i++] = num >> 8 & 0xFF;
  16449. key[i++] = num >> 16 & 0xFF;
  16450. key[i++] = gen & 0xFF;
  16451. key[i++] = gen >> 8 & 0xFF;
  16452. if (isAes) {
  16453. key[i++] = 0x73;
  16454. key[i++] = 0x41;
  16455. key[i++] = 0x6C;
  16456. key[i++] = 0x54;
  16457. }
  16458. var hash = calculateMD5(key, 0, i);
  16459. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  16460. }
  16461. function buildCipherConstructor(cf, name, num, gen, key) {
  16462. if (!(0, _primitives.isName)(name)) {
  16463. throw new _util.FormatError('Invalid crypt filter name.');
  16464. }
  16465. var cryptFilter = cf.get(name.name);
  16466. var cfm;
  16467. if (cryptFilter !== null && cryptFilter !== undefined) {
  16468. cfm = cryptFilter.get('CFM');
  16469. }
  16470. if (!cfm || cfm.name === 'None') {
  16471. return function cipherTransformFactoryBuildCipherConstructorNone() {
  16472. return new NullCipher();
  16473. };
  16474. }
  16475. if (cfm.name === 'V2') {
  16476. return function cipherTransformFactoryBuildCipherConstructorV2() {
  16477. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  16478. };
  16479. }
  16480. if (cfm.name === 'AESV2') {
  16481. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  16482. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  16483. };
  16484. }
  16485. if (cfm.name === 'AESV3') {
  16486. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  16487. return new AES256Cipher(key);
  16488. };
  16489. }
  16490. throw new _util.FormatError('Unknown crypto method');
  16491. }
  16492. CipherTransformFactory.prototype = {
  16493. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  16494. if (this.algorithm === 4 || this.algorithm === 5) {
  16495. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  16496. }
  16497. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  16498. var cipherConstructor = function buildCipherCipherConstructor() {
  16499. return new ARCFourCipher(key);
  16500. };
  16501. return new CipherTransform(cipherConstructor, cipherConstructor);
  16502. }
  16503. };
  16504. return CipherTransformFactory;
  16505. }();
  16506. exports.AES128Cipher = AES128Cipher;
  16507. exports.AES256Cipher = AES256Cipher;
  16508. exports.ARCFourCipher = ARCFourCipher;
  16509. exports.CipherTransformFactory = CipherTransformFactory;
  16510. exports.PDF17 = PDF17;
  16511. exports.PDF20 = PDF20;
  16512. exports.calculateMD5 = calculateMD5;
  16513. exports.calculateSHA256 = calculateSHA256;
  16514. exports.calculateSHA384 = calculateSHA384;
  16515. exports.calculateSHA512 = calculateSHA512;
  16516. /***/ }),
  16517. /* 66 */
  16518. /***/ (function(module, exports, __w_pdfjs_require__) {
  16519. "use strict";
  16520. Object.defineProperty(exports, "__esModule", {
  16521. value: true
  16522. });
  16523. exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = undefined;
  16524. var _util = __w_pdfjs_require__(0);
  16525. var _charsets = __w_pdfjs_require__(133);
  16526. var _encodings = __w_pdfjs_require__(21);
  16527. var MAX_SUBR_NESTING = 10;
  16528. 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'];
  16529. var CFFParser = function CFFParserClosure() {
  16530. var CharstringValidationData = [null, {
  16531. id: 'hstem',
  16532. min: 2,
  16533. stackClearing: true,
  16534. stem: true
  16535. }, null, {
  16536. id: 'vstem',
  16537. min: 2,
  16538. stackClearing: true,
  16539. stem: true
  16540. }, {
  16541. id: 'vmoveto',
  16542. min: 1,
  16543. stackClearing: true
  16544. }, {
  16545. id: 'rlineto',
  16546. min: 2,
  16547. resetStack: true
  16548. }, {
  16549. id: 'hlineto',
  16550. min: 1,
  16551. resetStack: true
  16552. }, {
  16553. id: 'vlineto',
  16554. min: 1,
  16555. resetStack: true
  16556. }, {
  16557. id: 'rrcurveto',
  16558. min: 6,
  16559. resetStack: true
  16560. }, null, {
  16561. id: 'callsubr',
  16562. min: 1,
  16563. undefStack: true
  16564. }, {
  16565. id: 'return',
  16566. min: 0,
  16567. undefStack: true
  16568. }, null, null, {
  16569. id: 'endchar',
  16570. min: 0,
  16571. stackClearing: true
  16572. }, null, null, null, {
  16573. id: 'hstemhm',
  16574. min: 2,
  16575. stackClearing: true,
  16576. stem: true
  16577. }, {
  16578. id: 'hintmask',
  16579. min: 0,
  16580. stackClearing: true
  16581. }, {
  16582. id: 'cntrmask',
  16583. min: 0,
  16584. stackClearing: true
  16585. }, {
  16586. id: 'rmoveto',
  16587. min: 2,
  16588. stackClearing: true
  16589. }, {
  16590. id: 'hmoveto',
  16591. min: 1,
  16592. stackClearing: true
  16593. }, {
  16594. id: 'vstemhm',
  16595. min: 2,
  16596. stackClearing: true,
  16597. stem: true
  16598. }, {
  16599. id: 'rcurveline',
  16600. min: 8,
  16601. resetStack: true
  16602. }, {
  16603. id: 'rlinecurve',
  16604. min: 8,
  16605. resetStack: true
  16606. }, {
  16607. id: 'vvcurveto',
  16608. min: 4,
  16609. resetStack: true
  16610. }, {
  16611. id: 'hhcurveto',
  16612. min: 4,
  16613. resetStack: true
  16614. }, null, {
  16615. id: 'callgsubr',
  16616. min: 1,
  16617. undefStack: true
  16618. }, {
  16619. id: 'vhcurveto',
  16620. min: 4,
  16621. resetStack: true
  16622. }, {
  16623. id: 'hvcurveto',
  16624. min: 4,
  16625. resetStack: true
  16626. }];
  16627. var CharstringValidationData12 = [null, null, null, {
  16628. id: 'and',
  16629. min: 2,
  16630. stackDelta: -1
  16631. }, {
  16632. id: 'or',
  16633. min: 2,
  16634. stackDelta: -1
  16635. }, {
  16636. id: 'not',
  16637. min: 1,
  16638. stackDelta: 0
  16639. }, null, null, null, {
  16640. id: 'abs',
  16641. min: 1,
  16642. stackDelta: 0
  16643. }, {
  16644. id: 'add',
  16645. min: 2,
  16646. stackDelta: -1,
  16647. stackFn: function stack_div(stack, index) {
  16648. stack[index - 2] = stack[index - 2] + stack[index - 1];
  16649. }
  16650. }, {
  16651. id: 'sub',
  16652. min: 2,
  16653. stackDelta: -1,
  16654. stackFn: function stack_div(stack, index) {
  16655. stack[index - 2] = stack[index - 2] - stack[index - 1];
  16656. }
  16657. }, {
  16658. id: 'div',
  16659. min: 2,
  16660. stackDelta: -1,
  16661. stackFn: function stack_div(stack, index) {
  16662. stack[index - 2] = stack[index - 2] / stack[index - 1];
  16663. }
  16664. }, null, {
  16665. id: 'neg',
  16666. min: 1,
  16667. stackDelta: 0,
  16668. stackFn: function stack_div(stack, index) {
  16669. stack[index - 1] = -stack[index - 1];
  16670. }
  16671. }, {
  16672. id: 'eq',
  16673. min: 2,
  16674. stackDelta: -1
  16675. }, null, null, {
  16676. id: 'drop',
  16677. min: 1,
  16678. stackDelta: -1
  16679. }, null, {
  16680. id: 'put',
  16681. min: 2,
  16682. stackDelta: -2
  16683. }, {
  16684. id: 'get',
  16685. min: 1,
  16686. stackDelta: 0
  16687. }, {
  16688. id: 'ifelse',
  16689. min: 4,
  16690. stackDelta: -3
  16691. }, {
  16692. id: 'random',
  16693. min: 0,
  16694. stackDelta: 1
  16695. }, {
  16696. id: 'mul',
  16697. min: 2,
  16698. stackDelta: -1,
  16699. stackFn: function stack_div(stack, index) {
  16700. stack[index - 2] = stack[index - 2] * stack[index - 1];
  16701. }
  16702. }, null, {
  16703. id: 'sqrt',
  16704. min: 1,
  16705. stackDelta: 0
  16706. }, {
  16707. id: 'dup',
  16708. min: 1,
  16709. stackDelta: 1
  16710. }, {
  16711. id: 'exch',
  16712. min: 2,
  16713. stackDelta: 0
  16714. }, {
  16715. id: 'index',
  16716. min: 2,
  16717. stackDelta: 0
  16718. }, {
  16719. id: 'roll',
  16720. min: 3,
  16721. stackDelta: -2
  16722. }, null, null, null, {
  16723. id: 'hflex',
  16724. min: 7,
  16725. resetStack: true
  16726. }, {
  16727. id: 'flex',
  16728. min: 13,
  16729. resetStack: true
  16730. }, {
  16731. id: 'hflex1',
  16732. min: 9,
  16733. resetStack: true
  16734. }, {
  16735. id: 'flex1',
  16736. min: 11,
  16737. resetStack: true
  16738. }];
  16739. function CFFParser(file, properties, seacAnalysisEnabled) {
  16740. this.bytes = file.getBytes();
  16741. this.properties = properties;
  16742. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  16743. }
  16744. CFFParser.prototype = {
  16745. parse: function CFFParser_parse() {
  16746. var properties = this.properties;
  16747. var cff = new CFF();
  16748. this.cff = cff;
  16749. var header = this.parseHeader();
  16750. var nameIndex = this.parseIndex(header.endPos);
  16751. var topDictIndex = this.parseIndex(nameIndex.endPos);
  16752. var stringIndex = this.parseIndex(topDictIndex.endPos);
  16753. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  16754. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  16755. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  16756. cff.header = header.obj;
  16757. cff.names = this.parseNameIndex(nameIndex.obj);
  16758. cff.strings = this.parseStringIndex(stringIndex.obj);
  16759. cff.topDict = topDict;
  16760. cff.globalSubrIndex = globalSubrIndex.obj;
  16761. this.parsePrivateDict(cff.topDict);
  16762. cff.isCIDFont = topDict.hasName('ROS');
  16763. var charStringOffset = topDict.getByName('CharStrings');
  16764. var charStringIndex = this.parseIndex(charStringOffset).obj;
  16765. var fontMatrix = topDict.getByName('FontMatrix');
  16766. if (fontMatrix) {
  16767. properties.fontMatrix = fontMatrix;
  16768. }
  16769. var fontBBox = topDict.getByName('FontBBox');
  16770. if (fontBBox) {
  16771. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  16772. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  16773. properties.ascentScaled = true;
  16774. }
  16775. var charset, encoding;
  16776. if (cff.isCIDFont) {
  16777. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  16778. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  16779. var dictRaw = fdArrayIndex.get(i);
  16780. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  16781. this.parsePrivateDict(fontDict);
  16782. cff.fdArray.push(fontDict);
  16783. }
  16784. encoding = null;
  16785. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  16786. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  16787. } else {
  16788. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  16789. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  16790. }
  16791. cff.charset = charset;
  16792. cff.encoding = encoding;
  16793. var charStringsAndSeacs = this.parseCharStrings({
  16794. charStrings: charStringIndex,
  16795. localSubrIndex: topDict.privateDict.subrsIndex,
  16796. globalSubrIndex: globalSubrIndex.obj,
  16797. fdSelect: cff.fdSelect,
  16798. fdArray: cff.fdArray,
  16799. privateDict: topDict.privateDict
  16800. });
  16801. cff.charStrings = charStringsAndSeacs.charStrings;
  16802. cff.seacs = charStringsAndSeacs.seacs;
  16803. cff.widths = charStringsAndSeacs.widths;
  16804. return cff;
  16805. },
  16806. parseHeader: function CFFParser_parseHeader() {
  16807. var bytes = this.bytes;
  16808. var bytesLength = bytes.length;
  16809. var offset = 0;
  16810. while (offset < bytesLength && bytes[offset] !== 1) {
  16811. ++offset;
  16812. }
  16813. if (offset >= bytesLength) {
  16814. throw new _util.FormatError('Invalid CFF header');
  16815. }
  16816. if (offset !== 0) {
  16817. (0, _util.info)('cff data is shifted');
  16818. bytes = bytes.subarray(offset);
  16819. this.bytes = bytes;
  16820. }
  16821. var major = bytes[0];
  16822. var minor = bytes[1];
  16823. var hdrSize = bytes[2];
  16824. var offSize = bytes[3];
  16825. var header = new CFFHeader(major, minor, hdrSize, offSize);
  16826. return {
  16827. obj: header,
  16828. endPos: hdrSize
  16829. };
  16830. },
  16831. parseDict: function CFFParser_parseDict(dict) {
  16832. var pos = 0;
  16833. function parseOperand() {
  16834. var value = dict[pos++];
  16835. if (value === 30) {
  16836. return parseFloatOperand();
  16837. } else if (value === 28) {
  16838. value = dict[pos++];
  16839. value = (value << 24 | dict[pos++] << 16) >> 16;
  16840. return value;
  16841. } else if (value === 29) {
  16842. value = dict[pos++];
  16843. value = value << 8 | dict[pos++];
  16844. value = value << 8 | dict[pos++];
  16845. value = value << 8 | dict[pos++];
  16846. return value;
  16847. } else if (value >= 32 && value <= 246) {
  16848. return value - 139;
  16849. } else if (value >= 247 && value <= 250) {
  16850. return (value - 247) * 256 + dict[pos++] + 108;
  16851. } else if (value >= 251 && value <= 254) {
  16852. return -((value - 251) * 256) - dict[pos++] - 108;
  16853. }
  16854. (0, _util.warn)('CFFParser_parseDict: "' + value + '" is a reserved command.');
  16855. return NaN;
  16856. }
  16857. function parseFloatOperand() {
  16858. var str = '';
  16859. var eof = 15;
  16860. var lookup = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'E', 'E-', null, '-'];
  16861. var length = dict.length;
  16862. while (pos < length) {
  16863. var b = dict[pos++];
  16864. var b1 = b >> 4;
  16865. var b2 = b & 15;
  16866. if (b1 === eof) {
  16867. break;
  16868. }
  16869. str += lookup[b1];
  16870. if (b2 === eof) {
  16871. break;
  16872. }
  16873. str += lookup[b2];
  16874. }
  16875. return parseFloat(str);
  16876. }
  16877. var operands = [];
  16878. var entries = [];
  16879. pos = 0;
  16880. var end = dict.length;
  16881. while (pos < end) {
  16882. var b = dict[pos];
  16883. if (b <= 21) {
  16884. if (b === 12) {
  16885. b = b << 8 | dict[++pos];
  16886. }
  16887. entries.push([b, operands]);
  16888. operands = [];
  16889. ++pos;
  16890. } else {
  16891. operands.push(parseOperand());
  16892. }
  16893. }
  16894. return entries;
  16895. },
  16896. parseIndex: function CFFParser_parseIndex(pos) {
  16897. var cffIndex = new CFFIndex();
  16898. var bytes = this.bytes;
  16899. var count = bytes[pos++] << 8 | bytes[pos++];
  16900. var offsets = [];
  16901. var end = pos;
  16902. var i, ii;
  16903. if (count !== 0) {
  16904. var offsetSize = bytes[pos++];
  16905. var startPos = pos + (count + 1) * offsetSize - 1;
  16906. for (i = 0, ii = count + 1; i < ii; ++i) {
  16907. var offset = 0;
  16908. for (var j = 0; j < offsetSize; ++j) {
  16909. offset <<= 8;
  16910. offset += bytes[pos++];
  16911. }
  16912. offsets.push(startPos + offset);
  16913. }
  16914. end = offsets[count];
  16915. }
  16916. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  16917. var offsetStart = offsets[i];
  16918. var offsetEnd = offsets[i + 1];
  16919. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  16920. }
  16921. return {
  16922. obj: cffIndex,
  16923. endPos: end
  16924. };
  16925. },
  16926. parseNameIndex: function CFFParser_parseNameIndex(index) {
  16927. var names = [];
  16928. for (var i = 0, ii = index.count; i < ii; ++i) {
  16929. var name = index.get(i);
  16930. names.push((0, _util.bytesToString)(name));
  16931. }
  16932. return names;
  16933. },
  16934. parseStringIndex: function CFFParser_parseStringIndex(index) {
  16935. var strings = new CFFStrings();
  16936. for (var i = 0, ii = index.count; i < ii; ++i) {
  16937. var data = index.get(i);
  16938. strings.add((0, _util.bytesToString)(data));
  16939. }
  16940. return strings;
  16941. },
  16942. createDict: function CFFParser_createDict(Type, dict, strings) {
  16943. var cffDict = new Type(strings);
  16944. for (var i = 0, ii = dict.length; i < ii; ++i) {
  16945. var pair = dict[i];
  16946. var key = pair[0];
  16947. var value = pair[1];
  16948. cffDict.setByKey(key, value);
  16949. }
  16950. return cffDict;
  16951. },
  16952. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  16953. if (!data || state.callDepth > MAX_SUBR_NESTING) {
  16954. return false;
  16955. }
  16956. var stackSize = state.stackSize;
  16957. var stack = state.stack;
  16958. var length = data.length;
  16959. for (var j = 0; j < length;) {
  16960. var value = data[j++];
  16961. var validationCommand = null;
  16962. if (value === 12) {
  16963. var q = data[j++];
  16964. if (q === 0) {
  16965. data[j - 2] = 139;
  16966. data[j - 1] = 22;
  16967. stackSize = 0;
  16968. } else {
  16969. validationCommand = CharstringValidationData12[q];
  16970. }
  16971. } else if (value === 28) {
  16972. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  16973. j += 2;
  16974. stackSize++;
  16975. } else if (value === 14) {
  16976. if (stackSize >= 4) {
  16977. stackSize -= 4;
  16978. if (this.seacAnalysisEnabled) {
  16979. state.seac = stack.slice(stackSize, stackSize + 4);
  16980. return false;
  16981. }
  16982. }
  16983. validationCommand = CharstringValidationData[value];
  16984. } else if (value >= 32 && value <= 246) {
  16985. stack[stackSize] = value - 139;
  16986. stackSize++;
  16987. } else if (value >= 247 && value <= 254) {
  16988. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  16989. j++;
  16990. stackSize++;
  16991. } else if (value === 255) {
  16992. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  16993. j += 4;
  16994. stackSize++;
  16995. } else if (value === 19 || value === 20) {
  16996. state.hints += stackSize >> 1;
  16997. j += state.hints + 7 >> 3;
  16998. stackSize %= 2;
  16999. validationCommand = CharstringValidationData[value];
  17000. } else if (value === 10 || value === 29) {
  17001. var subrsIndex;
  17002. if (value === 10) {
  17003. subrsIndex = localSubrIndex;
  17004. } else {
  17005. subrsIndex = globalSubrIndex;
  17006. }
  17007. if (!subrsIndex) {
  17008. validationCommand = CharstringValidationData[value];
  17009. (0, _util.warn)('Missing subrsIndex for ' + validationCommand.id);
  17010. return false;
  17011. }
  17012. var bias = 32768;
  17013. if (subrsIndex.count < 1240) {
  17014. bias = 107;
  17015. } else if (subrsIndex.count < 33900) {
  17016. bias = 1131;
  17017. }
  17018. var subrNumber = stack[--stackSize] + bias;
  17019. if (subrNumber < 0 || subrNumber >= subrsIndex.count || isNaN(subrNumber)) {
  17020. validationCommand = CharstringValidationData[value];
  17021. (0, _util.warn)('Out of bounds subrIndex for ' + validationCommand.id);
  17022. return false;
  17023. }
  17024. state.stackSize = stackSize;
  17025. state.callDepth++;
  17026. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  17027. if (!valid) {
  17028. return false;
  17029. }
  17030. state.callDepth--;
  17031. stackSize = state.stackSize;
  17032. continue;
  17033. } else if (value === 11) {
  17034. state.stackSize = stackSize;
  17035. return true;
  17036. } else {
  17037. validationCommand = CharstringValidationData[value];
  17038. }
  17039. if (validationCommand) {
  17040. if (validationCommand.stem) {
  17041. state.hints += stackSize >> 1;
  17042. }
  17043. if ('min' in validationCommand) {
  17044. if (!state.undefStack && stackSize < validationCommand.min) {
  17045. (0, _util.warn)('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  17046. return false;
  17047. }
  17048. }
  17049. if (state.firstStackClearing && validationCommand.stackClearing) {
  17050. state.firstStackClearing = false;
  17051. stackSize -= validationCommand.min;
  17052. if (stackSize >= 2 && validationCommand.stem) {
  17053. stackSize %= 2;
  17054. } else if (stackSize > 1) {
  17055. (0, _util.warn)('Found too many parameters for stack-clearing command');
  17056. }
  17057. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  17058. state.width = stack[stackSize - 1];
  17059. }
  17060. }
  17061. if ('stackDelta' in validationCommand) {
  17062. if ('stackFn' in validationCommand) {
  17063. validationCommand.stackFn(stack, stackSize);
  17064. }
  17065. stackSize += validationCommand.stackDelta;
  17066. } else if (validationCommand.stackClearing) {
  17067. stackSize = 0;
  17068. } else if (validationCommand.resetStack) {
  17069. stackSize = 0;
  17070. state.undefStack = false;
  17071. } else if (validationCommand.undefStack) {
  17072. stackSize = 0;
  17073. state.undefStack = true;
  17074. state.firstStackClearing = false;
  17075. }
  17076. }
  17077. }
  17078. state.stackSize = stackSize;
  17079. return true;
  17080. },
  17081. parseCharStrings: function parseCharStrings(_ref) {
  17082. var charStrings = _ref.charStrings,
  17083. localSubrIndex = _ref.localSubrIndex,
  17084. globalSubrIndex = _ref.globalSubrIndex,
  17085. fdSelect = _ref.fdSelect,
  17086. fdArray = _ref.fdArray,
  17087. privateDict = _ref.privateDict;
  17088. var seacs = [];
  17089. var widths = [];
  17090. var count = charStrings.count;
  17091. for (var i = 0; i < count; i++) {
  17092. var charstring = charStrings.get(i);
  17093. var state = {
  17094. callDepth: 0,
  17095. stackSize: 0,
  17096. stack: [],
  17097. undefStack: true,
  17098. hints: 0,
  17099. firstStackClearing: true,
  17100. seac: null,
  17101. width: null
  17102. };
  17103. var valid = true;
  17104. var localSubrToUse = null;
  17105. var privateDictToUse = privateDict;
  17106. if (fdSelect && fdArray.length) {
  17107. var fdIndex = fdSelect.getFDIndex(i);
  17108. if (fdIndex === -1) {
  17109. (0, _util.warn)('Glyph index is not in fd select.');
  17110. valid = false;
  17111. }
  17112. if (fdIndex >= fdArray.length) {
  17113. (0, _util.warn)('Invalid fd index for glyph index.');
  17114. valid = false;
  17115. }
  17116. if (valid) {
  17117. privateDictToUse = fdArray[fdIndex].privateDict;
  17118. localSubrToUse = privateDictToUse.subrsIndex;
  17119. }
  17120. } else if (localSubrIndex) {
  17121. localSubrToUse = localSubrIndex;
  17122. }
  17123. if (valid) {
  17124. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  17125. }
  17126. if (state.width !== null) {
  17127. var nominalWidth = privateDictToUse.getByName('nominalWidthX');
  17128. widths[i] = nominalWidth + state.width;
  17129. } else {
  17130. var defaultWidth = privateDictToUse.getByName('defaultWidthX');
  17131. widths[i] = defaultWidth;
  17132. }
  17133. if (state.seac !== null) {
  17134. seacs[i] = state.seac;
  17135. }
  17136. if (!valid) {
  17137. charStrings.set(i, new Uint8Array([14]));
  17138. }
  17139. }
  17140. return {
  17141. charStrings: charStrings,
  17142. seacs: seacs,
  17143. widths: widths
  17144. };
  17145. },
  17146. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  17147. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  17148. parentDict.setByKey(18, [0, 0]);
  17149. parentDict.privateDict = privateDict;
  17150. },
  17151. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  17152. if (!parentDict.hasName('Private')) {
  17153. this.emptyPrivateDictionary(parentDict);
  17154. return;
  17155. }
  17156. var privateOffset = parentDict.getByName('Private');
  17157. if (!Array.isArray(privateOffset) || privateOffset.length !== 2) {
  17158. parentDict.removeByName('Private');
  17159. return;
  17160. }
  17161. var size = privateOffset[0];
  17162. var offset = privateOffset[1];
  17163. if (size === 0 || offset >= this.bytes.length) {
  17164. this.emptyPrivateDictionary(parentDict);
  17165. return;
  17166. }
  17167. var privateDictEnd = offset + size;
  17168. var dictData = this.bytes.subarray(offset, privateDictEnd);
  17169. var dict = this.parseDict(dictData);
  17170. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  17171. parentDict.privateDict = privateDict;
  17172. if (!privateDict.getByName('Subrs')) {
  17173. return;
  17174. }
  17175. var subrsOffset = privateDict.getByName('Subrs');
  17176. var relativeOffset = offset + subrsOffset;
  17177. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  17178. this.emptyPrivateDictionary(parentDict);
  17179. return;
  17180. }
  17181. var subrsIndex = this.parseIndex(relativeOffset);
  17182. privateDict.subrsIndex = subrsIndex.obj;
  17183. },
  17184. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  17185. if (pos === 0) {
  17186. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, _charsets.ISOAdobeCharset);
  17187. } else if (pos === 1) {
  17188. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, _charsets.ExpertCharset);
  17189. } else if (pos === 2) {
  17190. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, _charsets.ExpertSubsetCharset);
  17191. }
  17192. var bytes = this.bytes;
  17193. var start = pos;
  17194. var format = bytes[pos++];
  17195. var charset = ['.notdef'];
  17196. var id, count, i;
  17197. length -= 1;
  17198. switch (format) {
  17199. case 0:
  17200. for (i = 0; i < length; i++) {
  17201. id = bytes[pos++] << 8 | bytes[pos++];
  17202. charset.push(cid ? id : strings.get(id));
  17203. }
  17204. break;
  17205. case 1:
  17206. while (charset.length <= length) {
  17207. id = bytes[pos++] << 8 | bytes[pos++];
  17208. count = bytes[pos++];
  17209. for (i = 0; i <= count; i++) {
  17210. charset.push(cid ? id++ : strings.get(id++));
  17211. }
  17212. }
  17213. break;
  17214. case 2:
  17215. while (charset.length <= length) {
  17216. id = bytes[pos++] << 8 | bytes[pos++];
  17217. count = bytes[pos++] << 8 | bytes[pos++];
  17218. for (i = 0; i <= count; i++) {
  17219. charset.push(cid ? id++ : strings.get(id++));
  17220. }
  17221. }
  17222. break;
  17223. default:
  17224. throw new _util.FormatError('Unknown charset format');
  17225. }
  17226. var end = pos;
  17227. var raw = bytes.subarray(start, end);
  17228. return new CFFCharset(false, format, charset, raw);
  17229. },
  17230. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  17231. var encoding = Object.create(null);
  17232. var bytes = this.bytes;
  17233. var predefined = false;
  17234. var format, i, ii;
  17235. var raw = null;
  17236. function readSupplement() {
  17237. var supplementsCount = bytes[pos++];
  17238. for (i = 0; i < supplementsCount; i++) {
  17239. var code = bytes[pos++];
  17240. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  17241. encoding[code] = charset.indexOf(strings.get(sid));
  17242. }
  17243. }
  17244. if (pos === 0 || pos === 1) {
  17245. predefined = true;
  17246. format = pos;
  17247. var baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;
  17248. for (i = 0, ii = charset.length; i < ii; i++) {
  17249. var index = baseEncoding.indexOf(charset[i]);
  17250. if (index !== -1) {
  17251. encoding[index] = i;
  17252. }
  17253. }
  17254. } else {
  17255. var dataStart = pos;
  17256. format = bytes[pos++];
  17257. switch (format & 0x7f) {
  17258. case 0:
  17259. var glyphsCount = bytes[pos++];
  17260. for (i = 1; i <= glyphsCount; i++) {
  17261. encoding[bytes[pos++]] = i;
  17262. }
  17263. break;
  17264. case 1:
  17265. var rangesCount = bytes[pos++];
  17266. var gid = 1;
  17267. for (i = 0; i < rangesCount; i++) {
  17268. var start = bytes[pos++];
  17269. var left = bytes[pos++];
  17270. for (var j = start; j <= start + left; j++) {
  17271. encoding[j] = gid++;
  17272. }
  17273. }
  17274. break;
  17275. default:
  17276. throw new _util.FormatError('Unknown encoding format: ' + format + ' in CFF');
  17277. }
  17278. var dataEnd = pos;
  17279. if (format & 0x80) {
  17280. bytes[dataStart] &= 0x7f;
  17281. readSupplement();
  17282. }
  17283. raw = bytes.subarray(dataStart, dataEnd);
  17284. }
  17285. format = format & 0x7f;
  17286. return new CFFEncoding(predefined, format, encoding, raw);
  17287. },
  17288. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  17289. var start = pos;
  17290. var bytes = this.bytes;
  17291. var format = bytes[pos++];
  17292. var fdSelect = [],
  17293. rawBytes;
  17294. var i,
  17295. invalidFirstGID = false;
  17296. switch (format) {
  17297. case 0:
  17298. for (i = 0; i < length; ++i) {
  17299. var id = bytes[pos++];
  17300. fdSelect.push(id);
  17301. }
  17302. rawBytes = bytes.subarray(start, pos);
  17303. break;
  17304. case 3:
  17305. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  17306. for (i = 0; i < rangesCount; ++i) {
  17307. var first = bytes[pos++] << 8 | bytes[pos++];
  17308. if (i === 0 && first !== 0) {
  17309. (0, _util.warn)('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  17310. invalidFirstGID = true;
  17311. first = 0;
  17312. }
  17313. var fdIndex = bytes[pos++];
  17314. var next = bytes[pos] << 8 | bytes[pos + 1];
  17315. for (var j = first; j < next; ++j) {
  17316. fdSelect.push(fdIndex);
  17317. }
  17318. }
  17319. pos += 2;
  17320. rawBytes = bytes.subarray(start, pos);
  17321. if (invalidFirstGID) {
  17322. rawBytes[3] = rawBytes[4] = 0;
  17323. }
  17324. break;
  17325. default:
  17326. throw new _util.FormatError('parseFDSelect: Unknown format "' + format + '".');
  17327. }
  17328. if (fdSelect.length !== length) {
  17329. throw new _util.FormatError('parseFDSelect: Invalid font data.');
  17330. }
  17331. return new CFFFDSelect(fdSelect, rawBytes);
  17332. }
  17333. };
  17334. return CFFParser;
  17335. }();
  17336. var CFF = function CFFClosure() {
  17337. function CFF() {
  17338. this.header = null;
  17339. this.names = [];
  17340. this.topDict = null;
  17341. this.strings = new CFFStrings();
  17342. this.globalSubrIndex = null;
  17343. this.encoding = null;
  17344. this.charset = null;
  17345. this.charStrings = null;
  17346. this.fdArray = [];
  17347. this.fdSelect = null;
  17348. this.isCIDFont = false;
  17349. }
  17350. return CFF;
  17351. }();
  17352. var CFFHeader = function CFFHeaderClosure() {
  17353. function CFFHeader(major, minor, hdrSize, offSize) {
  17354. this.major = major;
  17355. this.minor = minor;
  17356. this.hdrSize = hdrSize;
  17357. this.offSize = offSize;
  17358. }
  17359. return CFFHeader;
  17360. }();
  17361. var CFFStrings = function CFFStringsClosure() {
  17362. function CFFStrings() {
  17363. this.strings = [];
  17364. }
  17365. CFFStrings.prototype = {
  17366. get: function CFFStrings_get(index) {
  17367. if (index >= 0 && index <= 390) {
  17368. return CFFStandardStrings[index];
  17369. }
  17370. if (index - 391 <= this.strings.length) {
  17371. return this.strings[index - 391];
  17372. }
  17373. return CFFStandardStrings[0];
  17374. },
  17375. add: function CFFStrings_add(value) {
  17376. this.strings.push(value);
  17377. },
  17378. get count() {
  17379. return this.strings.length;
  17380. }
  17381. };
  17382. return CFFStrings;
  17383. }();
  17384. var CFFIndex = function CFFIndexClosure() {
  17385. function CFFIndex() {
  17386. this.objects = [];
  17387. this.length = 0;
  17388. }
  17389. CFFIndex.prototype = {
  17390. add: function CFFIndex_add(data) {
  17391. this.length += data.length;
  17392. this.objects.push(data);
  17393. },
  17394. set: function CFFIndex_set(index, data) {
  17395. this.length += data.length - this.objects[index].length;
  17396. this.objects[index] = data;
  17397. },
  17398. get: function CFFIndex_get(index) {
  17399. return this.objects[index];
  17400. },
  17401. get count() {
  17402. return this.objects.length;
  17403. }
  17404. };
  17405. return CFFIndex;
  17406. }();
  17407. var CFFDict = function CFFDictClosure() {
  17408. function CFFDict(tables, strings) {
  17409. this.keyToNameMap = tables.keyToNameMap;
  17410. this.nameToKeyMap = tables.nameToKeyMap;
  17411. this.defaults = tables.defaults;
  17412. this.types = tables.types;
  17413. this.opcodes = tables.opcodes;
  17414. this.order = tables.order;
  17415. this.strings = strings;
  17416. this.values = Object.create(null);
  17417. }
  17418. CFFDict.prototype = {
  17419. setByKey: function CFFDict_setByKey(key, value) {
  17420. if (!(key in this.keyToNameMap)) {
  17421. return false;
  17422. }
  17423. var valueLength = value.length;
  17424. if (valueLength === 0) {
  17425. return true;
  17426. }
  17427. for (var i = 0; i < valueLength; i++) {
  17428. if (isNaN(value[i])) {
  17429. (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  17430. return true;
  17431. }
  17432. }
  17433. var type = this.types[key];
  17434. if (type === 'num' || type === 'sid' || type === 'offset') {
  17435. value = value[0];
  17436. }
  17437. this.values[key] = value;
  17438. return true;
  17439. },
  17440. setByName: function CFFDict_setByName(name, value) {
  17441. if (!(name in this.nameToKeyMap)) {
  17442. throw new _util.FormatError('Invalid dictionary name "' + name + '"');
  17443. }
  17444. this.values[this.nameToKeyMap[name]] = value;
  17445. },
  17446. hasName: function CFFDict_hasName(name) {
  17447. return this.nameToKeyMap[name] in this.values;
  17448. },
  17449. getByName: function CFFDict_getByName(name) {
  17450. if (!(name in this.nameToKeyMap)) {
  17451. throw new _util.FormatError('Invalid dictionary name ' + name + '"');
  17452. }
  17453. var key = this.nameToKeyMap[name];
  17454. if (!(key in this.values)) {
  17455. return this.defaults[key];
  17456. }
  17457. return this.values[key];
  17458. },
  17459. removeByName: function CFFDict_removeByName(name) {
  17460. delete this.values[this.nameToKeyMap[name]];
  17461. }
  17462. };
  17463. CFFDict.createTables = function CFFDict_createTables(layout) {
  17464. var tables = {
  17465. keyToNameMap: {},
  17466. nameToKeyMap: {},
  17467. defaults: {},
  17468. types: {},
  17469. opcodes: {},
  17470. order: []
  17471. };
  17472. for (var i = 0, ii = layout.length; i < ii; ++i) {
  17473. var entry = layout[i];
  17474. var key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  17475. tables.keyToNameMap[key] = entry[1];
  17476. tables.nameToKeyMap[entry[1]] = key;
  17477. tables.types[key] = entry[2];
  17478. tables.defaults[key] = entry[3];
  17479. tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];
  17480. tables.order.push(key);
  17481. }
  17482. return tables;
  17483. };
  17484. return CFFDict;
  17485. }();
  17486. var CFFTopDict = function CFFTopDictClosure() {
  17487. 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'], [0.001, 0, 0, 0.001, 0, 0]], [13, 'UniqueID', 'num', null], [5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]], [[12, 8], 'StrokeWidth', 'num', 0], [14, 'XUID', 'array', null], [15, 'charset', 'offset', 0], [16, 'Encoding', 'offset', 0], [17, 'CharStrings', 'offset', 0], [18, 'Private', ['offset', 'offset'], null], [[12, 21], 'PostScript', 'sid', null], [[12, 22], 'BaseFontName', 'sid', null], [[12, 23], 'BaseFontBlend', 'delta', null], [[12, 31], 'CIDFontVersion', 'num', 0], [[12, 32], 'CIDFontRevision', 'num', 0], [[12, 33], 'CIDFontType', 'num', 0], [[12, 34], 'CIDCount', 'num', 8720], [[12, 35], 'UIDBase', 'num', null], [[12, 37], 'FDSelect', 'offset', null], [[12, 36], 'FDArray', 'offset', null], [[12, 38], 'FontName', 'sid', null]];
  17488. var tables = null;
  17489. function CFFTopDict(strings) {
  17490. if (tables === null) {
  17491. tables = CFFDict.createTables(layout);
  17492. }
  17493. CFFDict.call(this, tables, strings);
  17494. this.privateDict = null;
  17495. }
  17496. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  17497. return CFFTopDict;
  17498. }();
  17499. var CFFPrivateDict = function CFFPrivateDictClosure() {
  17500. var layout = [[6, 'BlueValues', 'delta', null], [7, 'OtherBlues', 'delta', null], [8, 'FamilyBlues', 'delta', null], [9, 'FamilyOtherBlues', 'delta', null], [[12, 9], 'BlueScale', 'num', 0.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', 0.06], [[12, 19], 'initialRandomSeed', 'num', 0], [20, 'defaultWidthX', 'num', 0], [21, 'nominalWidthX', 'num', 0], [19, 'Subrs', 'offset', null]];
  17501. var tables = null;
  17502. function CFFPrivateDict(strings) {
  17503. if (tables === null) {
  17504. tables = CFFDict.createTables(layout);
  17505. }
  17506. CFFDict.call(this, tables, strings);
  17507. this.subrsIndex = null;
  17508. }
  17509. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  17510. return CFFPrivateDict;
  17511. }();
  17512. var CFFCharsetPredefinedTypes = {
  17513. ISO_ADOBE: 0,
  17514. EXPERT: 1,
  17515. EXPERT_SUBSET: 2
  17516. };
  17517. var CFFCharset = function CFFCharsetClosure() {
  17518. function CFFCharset(predefined, format, charset, raw) {
  17519. this.predefined = predefined;
  17520. this.format = format;
  17521. this.charset = charset;
  17522. this.raw = raw;
  17523. }
  17524. return CFFCharset;
  17525. }();
  17526. var CFFEncoding = function CFFEncodingClosure() {
  17527. function CFFEncoding(predefined, format, encoding, raw) {
  17528. this.predefined = predefined;
  17529. this.format = format;
  17530. this.encoding = encoding;
  17531. this.raw = raw;
  17532. }
  17533. return CFFEncoding;
  17534. }();
  17535. var CFFFDSelect = function CFFFDSelectClosure() {
  17536. function CFFFDSelect(fdSelect, raw) {
  17537. this.fdSelect = fdSelect;
  17538. this.raw = raw;
  17539. }
  17540. CFFFDSelect.prototype = {
  17541. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  17542. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  17543. return -1;
  17544. }
  17545. return this.fdSelect[glyphIndex];
  17546. }
  17547. };
  17548. return CFFFDSelect;
  17549. }();
  17550. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  17551. function CFFOffsetTracker() {
  17552. this.offsets = Object.create(null);
  17553. }
  17554. CFFOffsetTracker.prototype = {
  17555. isTracking: function CFFOffsetTracker_isTracking(key) {
  17556. return key in this.offsets;
  17557. },
  17558. track: function CFFOffsetTracker_track(key, location) {
  17559. if (key in this.offsets) {
  17560. throw new _util.FormatError('Already tracking location of ' + key);
  17561. }
  17562. this.offsets[key] = location;
  17563. },
  17564. offset: function CFFOffsetTracker_offset(value) {
  17565. for (var key in this.offsets) {
  17566. this.offsets[key] += value;
  17567. }
  17568. },
  17569. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  17570. if (!(key in this.offsets)) {
  17571. throw new _util.FormatError('Not tracking location of ' + key);
  17572. }
  17573. var data = output.data;
  17574. var dataOffset = this.offsets[key];
  17575. var size = 5;
  17576. for (var i = 0, ii = values.length; i < ii; ++i) {
  17577. var offset0 = i * size + dataOffset;
  17578. var offset1 = offset0 + 1;
  17579. var offset2 = offset0 + 2;
  17580. var offset3 = offset0 + 3;
  17581. var offset4 = offset0 + 4;
  17582. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  17583. throw new _util.FormatError('writing to an offset that is not empty');
  17584. }
  17585. var value = values[i];
  17586. data[offset0] = 0x1d;
  17587. data[offset1] = value >> 24 & 0xFF;
  17588. data[offset2] = value >> 16 & 0xFF;
  17589. data[offset3] = value >> 8 & 0xFF;
  17590. data[offset4] = value & 0xFF;
  17591. }
  17592. }
  17593. };
  17594. return CFFOffsetTracker;
  17595. }();
  17596. var CFFCompiler = function CFFCompilerClosure() {
  17597. function CFFCompiler(cff) {
  17598. this.cff = cff;
  17599. }
  17600. CFFCompiler.prototype = {
  17601. compile: function CFFCompiler_compile() {
  17602. var cff = this.cff;
  17603. var output = {
  17604. data: [],
  17605. length: 0,
  17606. add: function CFFCompiler_add(data) {
  17607. this.data = this.data.concat(data);
  17608. this.length = this.data.length;
  17609. }
  17610. };
  17611. var header = this.compileHeader(cff.header);
  17612. output.add(header);
  17613. var nameIndex = this.compileNameIndex(cff.names);
  17614. output.add(nameIndex);
  17615. if (cff.isCIDFont) {
  17616. if (cff.topDict.hasName('FontMatrix')) {
  17617. var base = cff.topDict.getByName('FontMatrix');
  17618. cff.topDict.removeByName('FontMatrix');
  17619. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  17620. var subDict = cff.fdArray[i];
  17621. var matrix = base.slice(0);
  17622. if (subDict.hasName('FontMatrix')) {
  17623. matrix = _util.Util.transform(matrix, subDict.getByName('FontMatrix'));
  17624. }
  17625. subDict.setByName('FontMatrix', matrix);
  17626. }
  17627. }
  17628. }
  17629. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  17630. output.add(compiled.output);
  17631. var topDictTracker = compiled.trackers[0];
  17632. var stringIndex = this.compileStringIndex(cff.strings.strings);
  17633. output.add(stringIndex);
  17634. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  17635. output.add(globalSubrIndex);
  17636. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  17637. if (cff.encoding.predefined) {
  17638. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  17639. } else {
  17640. var encoding = this.compileEncoding(cff.encoding);
  17641. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  17642. output.add(encoding);
  17643. }
  17644. }
  17645. if (cff.charset && cff.topDict.hasName('charset')) {
  17646. if (cff.charset.predefined) {
  17647. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  17648. } else {
  17649. var charset = this.compileCharset(cff.charset);
  17650. topDictTracker.setEntryLocation('charset', [output.length], output);
  17651. output.add(charset);
  17652. }
  17653. }
  17654. var charStrings = this.compileCharStrings(cff.charStrings);
  17655. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  17656. output.add(charStrings);
  17657. if (cff.isCIDFont) {
  17658. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  17659. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  17660. output.add(fdSelect);
  17661. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  17662. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  17663. output.add(compiled.output);
  17664. var fontDictTrackers = compiled.trackers;
  17665. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  17666. }
  17667. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  17668. output.add([0]);
  17669. return output.data;
  17670. },
  17671. encodeNumber: function CFFCompiler_encodeNumber(value) {
  17672. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  17673. return this.encodeInteger(value);
  17674. }
  17675. return this.encodeFloat(value);
  17676. },
  17677. encodeFloat: function CFFCompiler_encodeFloat(num) {
  17678. var value = num.toString();
  17679. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  17680. if (m) {
  17681. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  17682. value = (Math.round(num * epsilon) / epsilon).toString();
  17683. }
  17684. var nibbles = '';
  17685. var i, ii;
  17686. for (i = 0, ii = value.length; i < ii; ++i) {
  17687. var a = value[i];
  17688. if (a === 'e') {
  17689. nibbles += value[++i] === '-' ? 'c' : 'b';
  17690. } else if (a === '.') {
  17691. nibbles += 'a';
  17692. } else if (a === '-') {
  17693. nibbles += 'e';
  17694. } else {
  17695. nibbles += a;
  17696. }
  17697. }
  17698. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  17699. var out = [30];
  17700. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  17701. out.push(parseInt(nibbles.substr(i, 2), 16));
  17702. }
  17703. return out;
  17704. },
  17705. encodeInteger: function CFFCompiler_encodeInteger(value) {
  17706. var code;
  17707. if (value >= -107 && value <= 107) {
  17708. code = [value + 139];
  17709. } else if (value >= 108 && value <= 1131) {
  17710. value = value - 108;
  17711. code = [(value >> 8) + 247, value & 0xFF];
  17712. } else if (value >= -1131 && value <= -108) {
  17713. value = -value - 108;
  17714. code = [(value >> 8) + 251, value & 0xFF];
  17715. } else if (value >= -32768 && value <= 32767) {
  17716. code = [0x1c, value >> 8 & 0xFF, value & 0xFF];
  17717. } else {
  17718. code = [0x1d, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF];
  17719. }
  17720. return code;
  17721. },
  17722. compileHeader: function CFFCompiler_compileHeader(header) {
  17723. return [header.major, header.minor, header.hdrSize, header.offSize];
  17724. },
  17725. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  17726. var nameIndex = new CFFIndex();
  17727. for (var i = 0, ii = names.length; i < ii; ++i) {
  17728. var name = names[i];
  17729. var length = Math.min(name.length, 127);
  17730. var sanitizedName = new Array(length);
  17731. for (var j = 0; j < length; j++) {
  17732. var char = name[j];
  17733. if (char < '!' || char > '~' || char === '[' || char === ']' || char === '(' || char === ')' || char === '{' || char === '}' || char === '<' || char === '>' || char === '/' || char === '%') {
  17734. char = '_';
  17735. }
  17736. sanitizedName[j] = char;
  17737. }
  17738. sanitizedName = sanitizedName.join('');
  17739. if (sanitizedName === '') {
  17740. sanitizedName = 'Bad_Font_Name';
  17741. }
  17742. nameIndex.add((0, _util.stringToBytes)(sanitizedName));
  17743. }
  17744. return this.compileIndex(nameIndex);
  17745. },
  17746. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  17747. var fontDictTrackers = [];
  17748. var fdArrayIndex = new CFFIndex();
  17749. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  17750. var fontDict = dicts[i];
  17751. if (removeCidKeys) {
  17752. fontDict.removeByName('CIDFontVersion');
  17753. fontDict.removeByName('CIDFontRevision');
  17754. fontDict.removeByName('CIDFontType');
  17755. fontDict.removeByName('CIDCount');
  17756. fontDict.removeByName('UIDBase');
  17757. }
  17758. var fontDictTracker = new CFFOffsetTracker();
  17759. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  17760. fontDictTrackers.push(fontDictTracker);
  17761. fdArrayIndex.add(fontDictData);
  17762. fontDictTracker.offset(length);
  17763. }
  17764. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  17765. return {
  17766. trackers: fontDictTrackers,
  17767. output: fdArrayIndex
  17768. };
  17769. },
  17770. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  17771. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  17772. var fontDict = dicts[i];
  17773. var privateDict = fontDict.privateDict;
  17774. if (!privateDict || !fontDict.hasName('Private')) {
  17775. throw new _util.FormatError('There must be a private dictionary.');
  17776. }
  17777. var privateDictTracker = new CFFOffsetTracker();
  17778. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  17779. var outputLength = output.length;
  17780. privateDictTracker.offset(outputLength);
  17781. if (!privateDictData.length) {
  17782. outputLength = 0;
  17783. }
  17784. trackers[i].setEntryLocation('Private', [privateDictData.length, outputLength], output);
  17785. output.add(privateDictData);
  17786. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  17787. var subrs = this.compileIndex(privateDict.subrsIndex);
  17788. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  17789. output.add(subrs);
  17790. }
  17791. }
  17792. },
  17793. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  17794. var out = [];
  17795. var order = dict.order;
  17796. for (var i = 0; i < order.length; ++i) {
  17797. var key = order[i];
  17798. if (!(key in dict.values)) {
  17799. continue;
  17800. }
  17801. var values = dict.values[key];
  17802. var types = dict.types[key];
  17803. if (!Array.isArray(types)) {
  17804. types = [types];
  17805. }
  17806. if (!Array.isArray(values)) {
  17807. values = [values];
  17808. }
  17809. if (values.length === 0) {
  17810. continue;
  17811. }
  17812. for (var j = 0, jj = types.length; j < jj; ++j) {
  17813. var type = types[j];
  17814. var value = values[j];
  17815. switch (type) {
  17816. case 'num':
  17817. case 'sid':
  17818. out = out.concat(this.encodeNumber(value));
  17819. break;
  17820. case 'offset':
  17821. var name = dict.keyToNameMap[key];
  17822. if (!offsetTracker.isTracking(name)) {
  17823. offsetTracker.track(name, out.length);
  17824. }
  17825. out = out.concat([0x1d, 0, 0, 0, 0]);
  17826. break;
  17827. case 'array':
  17828. case 'delta':
  17829. out = out.concat(this.encodeNumber(value));
  17830. for (var k = 1, kk = values.length; k < kk; ++k) {
  17831. out = out.concat(this.encodeNumber(values[k]));
  17832. }
  17833. break;
  17834. default:
  17835. throw new _util.FormatError('Unknown data type of ' + type);
  17836. }
  17837. }
  17838. out = out.concat(dict.opcodes[key]);
  17839. }
  17840. return out;
  17841. },
  17842. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  17843. var stringIndex = new CFFIndex();
  17844. for (var i = 0, ii = strings.length; i < ii; ++i) {
  17845. stringIndex.add((0, _util.stringToBytes)(strings[i]));
  17846. }
  17847. return this.compileIndex(stringIndex);
  17848. },
  17849. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  17850. var globalSubrIndex = this.cff.globalSubrIndex;
  17851. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  17852. },
  17853. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  17854. return this.compileIndex(charStrings);
  17855. },
  17856. compileCharset: function CFFCompiler_compileCharset(charset) {
  17857. return this.compileTypedArray(charset.raw);
  17858. },
  17859. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  17860. return this.compileTypedArray(encoding.raw);
  17861. },
  17862. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  17863. return this.compileTypedArray(fdSelect);
  17864. },
  17865. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  17866. var out = [];
  17867. for (var i = 0, ii = data.length; i < ii; ++i) {
  17868. out[i] = data[i];
  17869. }
  17870. return out;
  17871. },
  17872. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  17873. trackers = trackers || [];
  17874. var objects = index.objects;
  17875. var count = objects.length;
  17876. if (count === 0) {
  17877. return [0, 0, 0];
  17878. }
  17879. var data = [count >> 8 & 0xFF, count & 0xff];
  17880. var lastOffset = 1,
  17881. i;
  17882. for (i = 0; i < count; ++i) {
  17883. lastOffset += objects[i].length;
  17884. }
  17885. var offsetSize;
  17886. if (lastOffset < 0x100) {
  17887. offsetSize = 1;
  17888. } else if (lastOffset < 0x10000) {
  17889. offsetSize = 2;
  17890. } else if (lastOffset < 0x1000000) {
  17891. offsetSize = 3;
  17892. } else {
  17893. offsetSize = 4;
  17894. }
  17895. data.push(offsetSize);
  17896. var relativeOffset = 1;
  17897. for (i = 0; i < count + 1; i++) {
  17898. if (offsetSize === 1) {
  17899. data.push(relativeOffset & 0xFF);
  17900. } else if (offsetSize === 2) {
  17901. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  17902. } else if (offsetSize === 3) {
  17903. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  17904. } else {
  17905. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  17906. }
  17907. if (objects[i]) {
  17908. relativeOffset += objects[i].length;
  17909. }
  17910. }
  17911. for (i = 0; i < count; i++) {
  17912. if (trackers[i]) {
  17913. trackers[i].offset(data.length);
  17914. }
  17915. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  17916. data.push(objects[i][j]);
  17917. }
  17918. }
  17919. return data;
  17920. }
  17921. };
  17922. return CFFCompiler;
  17923. }();
  17924. exports.CFFStandardStrings = CFFStandardStrings;
  17925. exports.CFFParser = CFFParser;
  17926. exports.CFF = CFF;
  17927. exports.CFFHeader = CFFHeader;
  17928. exports.CFFStrings = CFFStrings;
  17929. exports.CFFIndex = CFFIndex;
  17930. exports.CFFCharset = CFFCharset;
  17931. exports.CFFTopDict = CFFTopDict;
  17932. exports.CFFPrivateDict = CFFPrivateDict;
  17933. exports.CFFCompiler = CFFCompiler;
  17934. /***/ }),
  17935. /* 67 */
  17936. /***/ (function(module, exports, __w_pdfjs_require__) {
  17937. "use strict";
  17938. Object.defineProperty(exports, "__esModule", {
  17939. value: true
  17940. });
  17941. exports.getSupplementalGlyphMapForArialBlack = exports.getGlyphMapForStandardFonts = exports.getSymbolsFonts = exports.getSerifFonts = exports.getNonStdFontMap = exports.getStdFontMap = undefined;
  17942. var _util = __w_pdfjs_require__(0);
  17943. var getStdFontMap = (0, _util.getLookupTableFactory)(function (t) {
  17944. t['ArialNarrow'] = 'Helvetica';
  17945. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  17946. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  17947. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  17948. t['ArialBlack'] = 'Helvetica';
  17949. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  17950. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  17951. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  17952. t['Arial-Black'] = 'Helvetica';
  17953. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  17954. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  17955. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  17956. t['Arial'] = 'Helvetica';
  17957. t['Arial-Bold'] = 'Helvetica-Bold';
  17958. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  17959. t['Arial-Italic'] = 'Helvetica-Oblique';
  17960. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  17961. t['Arial-BoldMT'] = 'Helvetica-Bold';
  17962. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  17963. t['ArialMT'] = 'Helvetica';
  17964. t['Courier-Bold'] = 'Courier-Bold';
  17965. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  17966. t['Courier-Italic'] = 'Courier-Oblique';
  17967. t['CourierNew'] = 'Courier';
  17968. t['CourierNew-Bold'] = 'Courier-Bold';
  17969. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  17970. t['CourierNew-Italic'] = 'Courier-Oblique';
  17971. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  17972. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  17973. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  17974. t['CourierNewPSMT'] = 'Courier';
  17975. t['Helvetica'] = 'Helvetica';
  17976. t['Helvetica-Bold'] = 'Helvetica-Bold';
  17977. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  17978. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  17979. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  17980. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  17981. t['SegoeUISymbol'] = 'Helvetica';
  17982. t['Symbol-Bold'] = 'Symbol';
  17983. t['Symbol-BoldItalic'] = 'Symbol';
  17984. t['Symbol-Italic'] = 'Symbol';
  17985. t['TimesNewRoman'] = 'Times-Roman';
  17986. t['TimesNewRoman-Bold'] = 'Times-Bold';
  17987. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  17988. t['TimesNewRoman-Italic'] = 'Times-Italic';
  17989. t['TimesNewRomanPS'] = 'Times-Roman';
  17990. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  17991. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  17992. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  17993. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  17994. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  17995. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  17996. t['TimesNewRomanPSMT'] = 'Times-Roman';
  17997. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  17998. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  17999. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  18000. });
  18001. var getNonStdFontMap = (0, _util.getLookupTableFactory)(function (t) {
  18002. t['CenturyGothic'] = 'Helvetica';
  18003. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  18004. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  18005. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  18006. t['ComicSansMS'] = 'Comic Sans MS';
  18007. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  18008. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  18009. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  18010. t['LucidaConsole'] = 'Courier';
  18011. t['LucidaConsole-Bold'] = 'Courier-Bold';
  18012. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  18013. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  18014. t['MS-Gothic'] = 'MS Gothic';
  18015. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  18016. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  18017. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  18018. t['MS-Mincho'] = 'MS Mincho';
  18019. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  18020. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  18021. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  18022. t['MS-PGothic'] = 'MS PGothic';
  18023. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  18024. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  18025. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  18026. t['MS-PMincho'] = 'MS PMincho';
  18027. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  18028. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  18029. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  18030. t['NuptialScript'] = 'Times-Italic';
  18031. t['Wingdings'] = 'ZapfDingbats';
  18032. });
  18033. var getSerifFonts = (0, _util.getLookupTableFactory)(function (t) {
  18034. t['Adobe Jenson'] = true;
  18035. t['Adobe Text'] = true;
  18036. t['Albertus'] = true;
  18037. t['Aldus'] = true;
  18038. t['Alexandria'] = true;
  18039. t['Algerian'] = true;
  18040. t['American Typewriter'] = true;
  18041. t['Antiqua'] = true;
  18042. t['Apex'] = true;
  18043. t['Arno'] = true;
  18044. t['Aster'] = true;
  18045. t['Aurora'] = true;
  18046. t['Baskerville'] = true;
  18047. t['Bell'] = true;
  18048. t['Bembo'] = true;
  18049. t['Bembo Schoolbook'] = true;
  18050. t['Benguiat'] = true;
  18051. t['Berkeley Old Style'] = true;
  18052. t['Bernhard Modern'] = true;
  18053. t['Berthold City'] = true;
  18054. t['Bodoni'] = true;
  18055. t['Bauer Bodoni'] = true;
  18056. t['Book Antiqua'] = true;
  18057. t['Bookman'] = true;
  18058. t['Bordeaux Roman'] = true;
  18059. t['Californian FB'] = true;
  18060. t['Calisto'] = true;
  18061. t['Calvert'] = true;
  18062. t['Capitals'] = true;
  18063. t['Cambria'] = true;
  18064. t['Cartier'] = true;
  18065. t['Caslon'] = true;
  18066. t['Catull'] = true;
  18067. t['Centaur'] = true;
  18068. t['Century Old Style'] = true;
  18069. t['Century Schoolbook'] = true;
  18070. t['Chaparral'] = true;
  18071. t['Charis SIL'] = true;
  18072. t['Cheltenham'] = true;
  18073. t['Cholla Slab'] = true;
  18074. t['Clarendon'] = true;
  18075. t['Clearface'] = true;
  18076. t['Cochin'] = true;
  18077. t['Colonna'] = true;
  18078. t['Computer Modern'] = true;
  18079. t['Concrete Roman'] = true;
  18080. t['Constantia'] = true;
  18081. t['Cooper Black'] = true;
  18082. t['Corona'] = true;
  18083. t['Ecotype'] = true;
  18084. t['Egyptienne'] = true;
  18085. t['Elephant'] = true;
  18086. t['Excelsior'] = true;
  18087. t['Fairfield'] = true;
  18088. t['FF Scala'] = true;
  18089. t['Folkard'] = true;
  18090. t['Footlight'] = true;
  18091. t['FreeSerif'] = true;
  18092. t['Friz Quadrata'] = true;
  18093. t['Garamond'] = true;
  18094. t['Gentium'] = true;
  18095. t['Georgia'] = true;
  18096. t['Gloucester'] = true;
  18097. t['Goudy Old Style'] = true;
  18098. t['Goudy Schoolbook'] = true;
  18099. t['Goudy Pro Font'] = true;
  18100. t['Granjon'] = true;
  18101. t['Guardian Egyptian'] = true;
  18102. t['Heather'] = true;
  18103. t['Hercules'] = true;
  18104. t['High Tower Text'] = true;
  18105. t['Hiroshige'] = true;
  18106. t['Hoefler Text'] = true;
  18107. t['Humana Serif'] = true;
  18108. t['Imprint'] = true;
  18109. t['Ionic No. 5'] = true;
  18110. t['Janson'] = true;
  18111. t['Joanna'] = true;
  18112. t['Korinna'] = true;
  18113. t['Lexicon'] = true;
  18114. t['Liberation Serif'] = true;
  18115. t['Linux Libertine'] = true;
  18116. t['Literaturnaya'] = true;
  18117. t['Lucida'] = true;
  18118. t['Lucida Bright'] = true;
  18119. t['Melior'] = true;
  18120. t['Memphis'] = true;
  18121. t['Miller'] = true;
  18122. t['Minion'] = true;
  18123. t['Modern'] = true;
  18124. t['Mona Lisa'] = true;
  18125. t['Mrs Eaves'] = true;
  18126. t['MS Serif'] = true;
  18127. t['Museo Slab'] = true;
  18128. t['New York'] = true;
  18129. t['Nimbus Roman'] = true;
  18130. t['NPS Rawlinson Roadway'] = true;
  18131. t['NuptialScript'] = true;
  18132. t['Palatino'] = true;
  18133. t['Perpetua'] = true;
  18134. t['Plantin'] = true;
  18135. t['Plantin Schoolbook'] = true;
  18136. t['Playbill'] = true;
  18137. t['Poor Richard'] = true;
  18138. t['Rawlinson Roadway'] = true;
  18139. t['Renault'] = true;
  18140. t['Requiem'] = true;
  18141. t['Rockwell'] = true;
  18142. t['Roman'] = true;
  18143. t['Rotis Serif'] = true;
  18144. t['Sabon'] = true;
  18145. t['Scala'] = true;
  18146. t['Seagull'] = true;
  18147. t['Sistina'] = true;
  18148. t['Souvenir'] = true;
  18149. t['STIX'] = true;
  18150. t['Stone Informal'] = true;
  18151. t['Stone Serif'] = true;
  18152. t['Sylfaen'] = true;
  18153. t['Times'] = true;
  18154. t['Trajan'] = true;
  18155. t['Trinité'] = true;
  18156. t['Trump Mediaeval'] = true;
  18157. t['Utopia'] = true;
  18158. t['Vale Type'] = true;
  18159. t['Bitstream Vera'] = true;
  18160. t['Vera Serif'] = true;
  18161. t['Versailles'] = true;
  18162. t['Wanted'] = true;
  18163. t['Weiss'] = true;
  18164. t['Wide Latin'] = true;
  18165. t['Windsor'] = true;
  18166. t['XITS'] = true;
  18167. });
  18168. var getSymbolsFonts = (0, _util.getLookupTableFactory)(function (t) {
  18169. t['Dingbats'] = true;
  18170. t['Symbol'] = true;
  18171. t['ZapfDingbats'] = true;
  18172. });
  18173. var getGlyphMapForStandardFonts = (0, _util.getLookupTableFactory)(function (t) {
  18174. t[2] = 10;
  18175. t[3] = 32;
  18176. t[4] = 33;
  18177. t[5] = 34;
  18178. t[6] = 35;
  18179. t[7] = 36;
  18180. t[8] = 37;
  18181. t[9] = 38;
  18182. t[10] = 39;
  18183. t[11] = 40;
  18184. t[12] = 41;
  18185. t[13] = 42;
  18186. t[14] = 43;
  18187. t[15] = 44;
  18188. t[16] = 45;
  18189. t[17] = 46;
  18190. t[18] = 47;
  18191. t[19] = 48;
  18192. t[20] = 49;
  18193. t[21] = 50;
  18194. t[22] = 51;
  18195. t[23] = 52;
  18196. t[24] = 53;
  18197. t[25] = 54;
  18198. t[26] = 55;
  18199. t[27] = 56;
  18200. t[28] = 57;
  18201. t[29] = 58;
  18202. t[30] = 894;
  18203. t[31] = 60;
  18204. t[32] = 61;
  18205. t[33] = 62;
  18206. t[34] = 63;
  18207. t[35] = 64;
  18208. t[36] = 65;
  18209. t[37] = 66;
  18210. t[38] = 67;
  18211. t[39] = 68;
  18212. t[40] = 69;
  18213. t[41] = 70;
  18214. t[42] = 71;
  18215. t[43] = 72;
  18216. t[44] = 73;
  18217. t[45] = 74;
  18218. t[46] = 75;
  18219. t[47] = 76;
  18220. t[48] = 77;
  18221. t[49] = 78;
  18222. t[50] = 79;
  18223. t[51] = 80;
  18224. t[52] = 81;
  18225. t[53] = 82;
  18226. t[54] = 83;
  18227. t[55] = 84;
  18228. t[56] = 85;
  18229. t[57] = 86;
  18230. t[58] = 87;
  18231. t[59] = 88;
  18232. t[60] = 89;
  18233. t[61] = 90;
  18234. t[62] = 91;
  18235. t[63] = 92;
  18236. t[64] = 93;
  18237. t[65] = 94;
  18238. t[66] = 95;
  18239. t[67] = 96;
  18240. t[68] = 97;
  18241. t[69] = 98;
  18242. t[70] = 99;
  18243. t[71] = 100;
  18244. t[72] = 101;
  18245. t[73] = 102;
  18246. t[74] = 103;
  18247. t[75] = 104;
  18248. t[76] = 105;
  18249. t[77] = 106;
  18250. t[78] = 107;
  18251. t[79] = 108;
  18252. t[80] = 109;
  18253. t[81] = 110;
  18254. t[82] = 111;
  18255. t[83] = 112;
  18256. t[84] = 113;
  18257. t[85] = 114;
  18258. t[86] = 115;
  18259. t[87] = 116;
  18260. t[88] = 117;
  18261. t[89] = 118;
  18262. t[90] = 119;
  18263. t[91] = 120;
  18264. t[92] = 121;
  18265. t[93] = 122;
  18266. t[94] = 123;
  18267. t[95] = 124;
  18268. t[96] = 125;
  18269. t[97] = 126;
  18270. t[98] = 196;
  18271. t[99] = 197;
  18272. t[100] = 199;
  18273. t[101] = 201;
  18274. t[102] = 209;
  18275. t[103] = 214;
  18276. t[104] = 220;
  18277. t[105] = 225;
  18278. t[106] = 224;
  18279. t[107] = 226;
  18280. t[108] = 228;
  18281. t[109] = 227;
  18282. t[110] = 229;
  18283. t[111] = 231;
  18284. t[112] = 233;
  18285. t[113] = 232;
  18286. t[114] = 234;
  18287. t[115] = 235;
  18288. t[116] = 237;
  18289. t[117] = 236;
  18290. t[118] = 238;
  18291. t[119] = 239;
  18292. t[120] = 241;
  18293. t[121] = 243;
  18294. t[122] = 242;
  18295. t[123] = 244;
  18296. t[124] = 246;
  18297. t[125] = 245;
  18298. t[126] = 250;
  18299. t[127] = 249;
  18300. t[128] = 251;
  18301. t[129] = 252;
  18302. t[130] = 8224;
  18303. t[131] = 176;
  18304. t[132] = 162;
  18305. t[133] = 163;
  18306. t[134] = 167;
  18307. t[135] = 8226;
  18308. t[136] = 182;
  18309. t[137] = 223;
  18310. t[138] = 174;
  18311. t[139] = 169;
  18312. t[140] = 8482;
  18313. t[141] = 180;
  18314. t[142] = 168;
  18315. t[143] = 8800;
  18316. t[144] = 198;
  18317. t[145] = 216;
  18318. t[146] = 8734;
  18319. t[147] = 177;
  18320. t[148] = 8804;
  18321. t[149] = 8805;
  18322. t[150] = 165;
  18323. t[151] = 181;
  18324. t[152] = 8706;
  18325. t[153] = 8721;
  18326. t[154] = 8719;
  18327. t[156] = 8747;
  18328. t[157] = 170;
  18329. t[158] = 186;
  18330. t[159] = 8486;
  18331. t[160] = 230;
  18332. t[161] = 248;
  18333. t[162] = 191;
  18334. t[163] = 161;
  18335. t[164] = 172;
  18336. t[165] = 8730;
  18337. t[166] = 402;
  18338. t[167] = 8776;
  18339. t[168] = 8710;
  18340. t[169] = 171;
  18341. t[170] = 187;
  18342. t[171] = 8230;
  18343. t[210] = 218;
  18344. t[223] = 711;
  18345. t[224] = 321;
  18346. t[225] = 322;
  18347. t[227] = 353;
  18348. t[229] = 382;
  18349. t[234] = 253;
  18350. t[252] = 263;
  18351. t[253] = 268;
  18352. t[254] = 269;
  18353. t[258] = 258;
  18354. t[260] = 260;
  18355. t[261] = 261;
  18356. t[265] = 280;
  18357. t[266] = 281;
  18358. t[268] = 283;
  18359. t[269] = 313;
  18360. t[275] = 323;
  18361. t[276] = 324;
  18362. t[278] = 328;
  18363. t[284] = 345;
  18364. t[285] = 346;
  18365. t[286] = 347;
  18366. t[292] = 367;
  18367. t[295] = 377;
  18368. t[296] = 378;
  18369. t[298] = 380;
  18370. t[305] = 963;
  18371. t[306] = 964;
  18372. t[307] = 966;
  18373. t[308] = 8215;
  18374. t[309] = 8252;
  18375. t[310] = 8319;
  18376. t[311] = 8359;
  18377. t[312] = 8592;
  18378. t[313] = 8593;
  18379. t[337] = 9552;
  18380. t[493] = 1039;
  18381. t[494] = 1040;
  18382. t[705] = 1524;
  18383. t[706] = 8362;
  18384. t[710] = 64288;
  18385. t[711] = 64298;
  18386. t[759] = 1617;
  18387. t[761] = 1776;
  18388. t[763] = 1778;
  18389. t[775] = 1652;
  18390. t[777] = 1764;
  18391. t[778] = 1780;
  18392. t[779] = 1781;
  18393. t[780] = 1782;
  18394. t[782] = 771;
  18395. t[783] = 64726;
  18396. t[786] = 8363;
  18397. t[788] = 8532;
  18398. t[790] = 768;
  18399. t[791] = 769;
  18400. t[792] = 768;
  18401. t[795] = 803;
  18402. t[797] = 64336;
  18403. t[798] = 64337;
  18404. t[799] = 64342;
  18405. t[800] = 64343;
  18406. t[801] = 64344;
  18407. t[802] = 64345;
  18408. t[803] = 64362;
  18409. t[804] = 64363;
  18410. t[805] = 64364;
  18411. t[2424] = 7821;
  18412. t[2425] = 7822;
  18413. t[2426] = 7823;
  18414. t[2427] = 7824;
  18415. t[2428] = 7825;
  18416. t[2429] = 7826;
  18417. t[2430] = 7827;
  18418. t[2433] = 7682;
  18419. t[2678] = 8045;
  18420. t[2679] = 8046;
  18421. t[2830] = 1552;
  18422. t[2838] = 686;
  18423. t[2840] = 751;
  18424. t[2842] = 753;
  18425. t[2843] = 754;
  18426. t[2844] = 755;
  18427. t[2846] = 757;
  18428. t[2856] = 767;
  18429. t[2857] = 848;
  18430. t[2858] = 849;
  18431. t[2862] = 853;
  18432. t[2863] = 854;
  18433. t[2864] = 855;
  18434. t[2865] = 861;
  18435. t[2866] = 862;
  18436. t[2906] = 7460;
  18437. t[2908] = 7462;
  18438. t[2909] = 7463;
  18439. t[2910] = 7464;
  18440. t[2912] = 7466;
  18441. t[2913] = 7467;
  18442. t[2914] = 7468;
  18443. t[2916] = 7470;
  18444. t[2917] = 7471;
  18445. t[2918] = 7472;
  18446. t[2920] = 7474;
  18447. t[2921] = 7475;
  18448. t[2922] = 7476;
  18449. t[2924] = 7478;
  18450. t[2925] = 7479;
  18451. t[2926] = 7480;
  18452. t[2928] = 7482;
  18453. t[2929] = 7483;
  18454. t[2930] = 7484;
  18455. t[2932] = 7486;
  18456. t[2933] = 7487;
  18457. t[2934] = 7488;
  18458. t[2936] = 7490;
  18459. t[2937] = 7491;
  18460. t[2938] = 7492;
  18461. t[2940] = 7494;
  18462. t[2941] = 7495;
  18463. t[2942] = 7496;
  18464. t[2944] = 7498;
  18465. t[2946] = 7500;
  18466. t[2948] = 7502;
  18467. t[2950] = 7504;
  18468. t[2951] = 7505;
  18469. t[2952] = 7506;
  18470. t[2954] = 7508;
  18471. t[2955] = 7509;
  18472. t[2956] = 7510;
  18473. t[2958] = 7512;
  18474. t[2959] = 7513;
  18475. t[2960] = 7514;
  18476. t[2962] = 7516;
  18477. t[2963] = 7517;
  18478. t[2964] = 7518;
  18479. t[2966] = 7520;
  18480. t[2967] = 7521;
  18481. t[2968] = 7522;
  18482. t[2970] = 7524;
  18483. t[2971] = 7525;
  18484. t[2972] = 7526;
  18485. t[2974] = 7528;
  18486. t[2975] = 7529;
  18487. t[2976] = 7530;
  18488. t[2978] = 1537;
  18489. t[2979] = 1538;
  18490. t[2980] = 1539;
  18491. t[2982] = 1549;
  18492. t[2983] = 1551;
  18493. t[2984] = 1552;
  18494. t[2986] = 1554;
  18495. t[2987] = 1555;
  18496. t[2988] = 1556;
  18497. t[2990] = 1623;
  18498. t[2991] = 1624;
  18499. t[2995] = 1775;
  18500. t[2999] = 1791;
  18501. t[3002] = 64290;
  18502. t[3003] = 64291;
  18503. t[3004] = 64292;
  18504. t[3006] = 64294;
  18505. t[3007] = 64295;
  18506. t[3008] = 64296;
  18507. t[3011] = 1900;
  18508. t[3014] = 8223;
  18509. t[3015] = 8244;
  18510. t[3017] = 7532;
  18511. t[3018] = 7533;
  18512. t[3019] = 7534;
  18513. t[3075] = 7590;
  18514. t[3076] = 7591;
  18515. t[3079] = 7594;
  18516. t[3080] = 7595;
  18517. t[3083] = 7598;
  18518. t[3084] = 7599;
  18519. t[3087] = 7602;
  18520. t[3088] = 7603;
  18521. t[3091] = 7606;
  18522. t[3092] = 7607;
  18523. t[3095] = 7610;
  18524. t[3096] = 7611;
  18525. t[3099] = 7614;
  18526. t[3100] = 7615;
  18527. t[3103] = 7618;
  18528. t[3104] = 7619;
  18529. t[3107] = 8337;
  18530. t[3108] = 8338;
  18531. t[3116] = 1884;
  18532. t[3119] = 1885;
  18533. t[3120] = 1885;
  18534. t[3123] = 1886;
  18535. t[3124] = 1886;
  18536. t[3127] = 1887;
  18537. t[3128] = 1887;
  18538. t[3131] = 1888;
  18539. t[3132] = 1888;
  18540. t[3135] = 1889;
  18541. t[3136] = 1889;
  18542. t[3139] = 1890;
  18543. t[3140] = 1890;
  18544. t[3143] = 1891;
  18545. t[3144] = 1891;
  18546. t[3147] = 1892;
  18547. t[3148] = 1892;
  18548. t[3153] = 580;
  18549. t[3154] = 581;
  18550. t[3157] = 584;
  18551. t[3158] = 585;
  18552. t[3161] = 588;
  18553. t[3162] = 589;
  18554. t[3165] = 891;
  18555. t[3166] = 892;
  18556. t[3169] = 1274;
  18557. t[3170] = 1275;
  18558. t[3173] = 1278;
  18559. t[3174] = 1279;
  18560. t[3181] = 7622;
  18561. t[3182] = 7623;
  18562. t[3282] = 11799;
  18563. t[3316] = 578;
  18564. t[3379] = 42785;
  18565. t[3393] = 1159;
  18566. t[3416] = 8377;
  18567. });
  18568. var getSupplementalGlyphMapForArialBlack = (0, _util.getLookupTableFactory)(function (t) {
  18569. t[227] = 322;
  18570. t[264] = 261;
  18571. t[291] = 346;
  18572. });
  18573. exports.getStdFontMap = getStdFontMap;
  18574. exports.getNonStdFontMap = getNonStdFontMap;
  18575. exports.getSerifFonts = getSerifFonts;
  18576. exports.getSymbolsFonts = getSymbolsFonts;
  18577. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  18578. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  18579. /***/ }),
  18580. /* 68 */
  18581. /***/ (function(module, exports, __w_pdfjs_require__) {
  18582. "use strict";
  18583. var getLookupTableFactory = __w_pdfjs_require__(0).getLookupTableFactory;
  18584. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  18585. t[63721] = 0x00A9;
  18586. t[63193] = 0x00A9;
  18587. t[63720] = 0x00AE;
  18588. t[63194] = 0x00AE;
  18589. t[63722] = 0x2122;
  18590. t[63195] = 0x2122;
  18591. t[63729] = 0x23A7;
  18592. t[63730] = 0x23A8;
  18593. t[63731] = 0x23A9;
  18594. t[63740] = 0x23AB;
  18595. t[63741] = 0x23AC;
  18596. t[63742] = 0x23AD;
  18597. t[63726] = 0x23A1;
  18598. t[63727] = 0x23A2;
  18599. t[63728] = 0x23A3;
  18600. t[63737] = 0x23A4;
  18601. t[63738] = 0x23A5;
  18602. t[63739] = 0x23A6;
  18603. t[63723] = 0x239B;
  18604. t[63724] = 0x239C;
  18605. t[63725] = 0x239D;
  18606. t[63734] = 0x239E;
  18607. t[63735] = 0x239F;
  18608. t[63736] = 0x23A0;
  18609. });
  18610. function mapSpecialUnicodeValues(code) {
  18611. if (code >= 0xFFF0 && code <= 0xFFFF) {
  18612. return 0;
  18613. } else if (code >= 0xF600 && code <= 0xF8FF) {
  18614. return getSpecialPUASymbols()[code] || code;
  18615. } else if (code === 0x00AD) {
  18616. return 0x002D;
  18617. }
  18618. return code;
  18619. }
  18620. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  18621. var unicode = glyphsUnicodeMap[name];
  18622. if (unicode !== undefined) {
  18623. return unicode;
  18624. }
  18625. if (!name) {
  18626. return -1;
  18627. }
  18628. if (name[0] === 'u') {
  18629. var nameLen = name.length,
  18630. hexStr;
  18631. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  18632. hexStr = name.substr(3);
  18633. } else if (nameLen >= 5 && nameLen <= 7) {
  18634. hexStr = name.substr(1);
  18635. } else {
  18636. return -1;
  18637. }
  18638. if (hexStr === hexStr.toUpperCase()) {
  18639. unicode = parseInt(hexStr, 16);
  18640. if (unicode >= 0) {
  18641. return unicode;
  18642. }
  18643. }
  18644. }
  18645. return -1;
  18646. }
  18647. var UnicodeRanges = [{
  18648. 'begin': 0x0000,
  18649. 'end': 0x007F
  18650. }, {
  18651. 'begin': 0x0080,
  18652. 'end': 0x00FF
  18653. }, {
  18654. 'begin': 0x0100,
  18655. 'end': 0x017F
  18656. }, {
  18657. 'begin': 0x0180,
  18658. 'end': 0x024F
  18659. }, {
  18660. 'begin': 0x0250,
  18661. 'end': 0x02AF
  18662. }, {
  18663. 'begin': 0x02B0,
  18664. 'end': 0x02FF
  18665. }, {
  18666. 'begin': 0x0300,
  18667. 'end': 0x036F
  18668. }, {
  18669. 'begin': 0x0370,
  18670. 'end': 0x03FF
  18671. }, {
  18672. 'begin': 0x2C80,
  18673. 'end': 0x2CFF
  18674. }, {
  18675. 'begin': 0x0400,
  18676. 'end': 0x04FF
  18677. }, {
  18678. 'begin': 0x0530,
  18679. 'end': 0x058F
  18680. }, {
  18681. 'begin': 0x0590,
  18682. 'end': 0x05FF
  18683. }, {
  18684. 'begin': 0xA500,
  18685. 'end': 0xA63F
  18686. }, {
  18687. 'begin': 0x0600,
  18688. 'end': 0x06FF
  18689. }, {
  18690. 'begin': 0x07C0,
  18691. 'end': 0x07FF
  18692. }, {
  18693. 'begin': 0x0900,
  18694. 'end': 0x097F
  18695. }, {
  18696. 'begin': 0x0980,
  18697. 'end': 0x09FF
  18698. }, {
  18699. 'begin': 0x0A00,
  18700. 'end': 0x0A7F
  18701. }, {
  18702. 'begin': 0x0A80,
  18703. 'end': 0x0AFF
  18704. }, {
  18705. 'begin': 0x0B00,
  18706. 'end': 0x0B7F
  18707. }, {
  18708. 'begin': 0x0B80,
  18709. 'end': 0x0BFF
  18710. }, {
  18711. 'begin': 0x0C00,
  18712. 'end': 0x0C7F
  18713. }, {
  18714. 'begin': 0x0C80,
  18715. 'end': 0x0CFF
  18716. }, {
  18717. 'begin': 0x0D00,
  18718. 'end': 0x0D7F
  18719. }, {
  18720. 'begin': 0x0E00,
  18721. 'end': 0x0E7F
  18722. }, {
  18723. 'begin': 0x0E80,
  18724. 'end': 0x0EFF
  18725. }, {
  18726. 'begin': 0x10A0,
  18727. 'end': 0x10FF
  18728. }, {
  18729. 'begin': 0x1B00,
  18730. 'end': 0x1B7F
  18731. }, {
  18732. 'begin': 0x1100,
  18733. 'end': 0x11FF
  18734. }, {
  18735. 'begin': 0x1E00,
  18736. 'end': 0x1EFF
  18737. }, {
  18738. 'begin': 0x1F00,
  18739. 'end': 0x1FFF
  18740. }, {
  18741. 'begin': 0x2000,
  18742. 'end': 0x206F
  18743. }, {
  18744. 'begin': 0x2070,
  18745. 'end': 0x209F
  18746. }, {
  18747. 'begin': 0x20A0,
  18748. 'end': 0x20CF
  18749. }, {
  18750. 'begin': 0x20D0,
  18751. 'end': 0x20FF
  18752. }, {
  18753. 'begin': 0x2100,
  18754. 'end': 0x214F
  18755. }, {
  18756. 'begin': 0x2150,
  18757. 'end': 0x218F
  18758. }, {
  18759. 'begin': 0x2190,
  18760. 'end': 0x21FF
  18761. }, {
  18762. 'begin': 0x2200,
  18763. 'end': 0x22FF
  18764. }, {
  18765. 'begin': 0x2300,
  18766. 'end': 0x23FF
  18767. }, {
  18768. 'begin': 0x2400,
  18769. 'end': 0x243F
  18770. }, {
  18771. 'begin': 0x2440,
  18772. 'end': 0x245F
  18773. }, {
  18774. 'begin': 0x2460,
  18775. 'end': 0x24FF
  18776. }, {
  18777. 'begin': 0x2500,
  18778. 'end': 0x257F
  18779. }, {
  18780. 'begin': 0x2580,
  18781. 'end': 0x259F
  18782. }, {
  18783. 'begin': 0x25A0,
  18784. 'end': 0x25FF
  18785. }, {
  18786. 'begin': 0x2600,
  18787. 'end': 0x26FF
  18788. }, {
  18789. 'begin': 0x2700,
  18790. 'end': 0x27BF
  18791. }, {
  18792. 'begin': 0x3000,
  18793. 'end': 0x303F
  18794. }, {
  18795. 'begin': 0x3040,
  18796. 'end': 0x309F
  18797. }, {
  18798. 'begin': 0x30A0,
  18799. 'end': 0x30FF
  18800. }, {
  18801. 'begin': 0x3100,
  18802. 'end': 0x312F
  18803. }, {
  18804. 'begin': 0x3130,
  18805. 'end': 0x318F
  18806. }, {
  18807. 'begin': 0xA840,
  18808. 'end': 0xA87F
  18809. }, {
  18810. 'begin': 0x3200,
  18811. 'end': 0x32FF
  18812. }, {
  18813. 'begin': 0x3300,
  18814. 'end': 0x33FF
  18815. }, {
  18816. 'begin': 0xAC00,
  18817. 'end': 0xD7AF
  18818. }, {
  18819. 'begin': 0xD800,
  18820. 'end': 0xDFFF
  18821. }, {
  18822. 'begin': 0x10900,
  18823. 'end': 0x1091F
  18824. }, {
  18825. 'begin': 0x4E00,
  18826. 'end': 0x9FFF
  18827. }, {
  18828. 'begin': 0xE000,
  18829. 'end': 0xF8FF
  18830. }, {
  18831. 'begin': 0x31C0,
  18832. 'end': 0x31EF
  18833. }, {
  18834. 'begin': 0xFB00,
  18835. 'end': 0xFB4F
  18836. }, {
  18837. 'begin': 0xFB50,
  18838. 'end': 0xFDFF
  18839. }, {
  18840. 'begin': 0xFE20,
  18841. 'end': 0xFE2F
  18842. }, {
  18843. 'begin': 0xFE10,
  18844. 'end': 0xFE1F
  18845. }, {
  18846. 'begin': 0xFE50,
  18847. 'end': 0xFE6F
  18848. }, {
  18849. 'begin': 0xFE70,
  18850. 'end': 0xFEFF
  18851. }, {
  18852. 'begin': 0xFF00,
  18853. 'end': 0xFFEF
  18854. }, {
  18855. 'begin': 0xFFF0,
  18856. 'end': 0xFFFF
  18857. }, {
  18858. 'begin': 0x0F00,
  18859. 'end': 0x0FFF
  18860. }, {
  18861. 'begin': 0x0700,
  18862. 'end': 0x074F
  18863. }, {
  18864. 'begin': 0x0780,
  18865. 'end': 0x07BF
  18866. }, {
  18867. 'begin': 0x0D80,
  18868. 'end': 0x0DFF
  18869. }, {
  18870. 'begin': 0x1000,
  18871. 'end': 0x109F
  18872. }, {
  18873. 'begin': 0x1200,
  18874. 'end': 0x137F
  18875. }, {
  18876. 'begin': 0x13A0,
  18877. 'end': 0x13FF
  18878. }, {
  18879. 'begin': 0x1400,
  18880. 'end': 0x167F
  18881. }, {
  18882. 'begin': 0x1680,
  18883. 'end': 0x169F
  18884. }, {
  18885. 'begin': 0x16A0,
  18886. 'end': 0x16FF
  18887. }, {
  18888. 'begin': 0x1780,
  18889. 'end': 0x17FF
  18890. }, {
  18891. 'begin': 0x1800,
  18892. 'end': 0x18AF
  18893. }, {
  18894. 'begin': 0x2800,
  18895. 'end': 0x28FF
  18896. }, {
  18897. 'begin': 0xA000,
  18898. 'end': 0xA48F
  18899. }, {
  18900. 'begin': 0x1700,
  18901. 'end': 0x171F
  18902. }, {
  18903. 'begin': 0x10300,
  18904. 'end': 0x1032F
  18905. }, {
  18906. 'begin': 0x10330,
  18907. 'end': 0x1034F
  18908. }, {
  18909. 'begin': 0x10400,
  18910. 'end': 0x1044F
  18911. }, {
  18912. 'begin': 0x1D000,
  18913. 'end': 0x1D0FF
  18914. }, {
  18915. 'begin': 0x1D400,
  18916. 'end': 0x1D7FF
  18917. }, {
  18918. 'begin': 0xFF000,
  18919. 'end': 0xFFFFD
  18920. }, {
  18921. 'begin': 0xFE00,
  18922. 'end': 0xFE0F
  18923. }, {
  18924. 'begin': 0xE0000,
  18925. 'end': 0xE007F
  18926. }, {
  18927. 'begin': 0x1900,
  18928. 'end': 0x194F
  18929. }, {
  18930. 'begin': 0x1950,
  18931. 'end': 0x197F
  18932. }, {
  18933. 'begin': 0x1980,
  18934. 'end': 0x19DF
  18935. }, {
  18936. 'begin': 0x1A00,
  18937. 'end': 0x1A1F
  18938. }, {
  18939. 'begin': 0x2C00,
  18940. 'end': 0x2C5F
  18941. }, {
  18942. 'begin': 0x2D30,
  18943. 'end': 0x2D7F
  18944. }, {
  18945. 'begin': 0x4DC0,
  18946. 'end': 0x4DFF
  18947. }, {
  18948. 'begin': 0xA800,
  18949. 'end': 0xA82F
  18950. }, {
  18951. 'begin': 0x10000,
  18952. 'end': 0x1007F
  18953. }, {
  18954. 'begin': 0x10140,
  18955. 'end': 0x1018F
  18956. }, {
  18957. 'begin': 0x10380,
  18958. 'end': 0x1039F
  18959. }, {
  18960. 'begin': 0x103A0,
  18961. 'end': 0x103DF
  18962. }, {
  18963. 'begin': 0x10450,
  18964. 'end': 0x1047F
  18965. }, {
  18966. 'begin': 0x10480,
  18967. 'end': 0x104AF
  18968. }, {
  18969. 'begin': 0x10800,
  18970. 'end': 0x1083F
  18971. }, {
  18972. 'begin': 0x10A00,
  18973. 'end': 0x10A5F
  18974. }, {
  18975. 'begin': 0x1D300,
  18976. 'end': 0x1D35F
  18977. }, {
  18978. 'begin': 0x12000,
  18979. 'end': 0x123FF
  18980. }, {
  18981. 'begin': 0x1D360,
  18982. 'end': 0x1D37F
  18983. }, {
  18984. 'begin': 0x1B80,
  18985. 'end': 0x1BBF
  18986. }, {
  18987. 'begin': 0x1C00,
  18988. 'end': 0x1C4F
  18989. }, {
  18990. 'begin': 0x1C50,
  18991. 'end': 0x1C7F
  18992. }, {
  18993. 'begin': 0xA880,
  18994. 'end': 0xA8DF
  18995. }, {
  18996. 'begin': 0xA900,
  18997. 'end': 0xA92F
  18998. }, {
  18999. 'begin': 0xA930,
  19000. 'end': 0xA95F
  19001. }, {
  19002. 'begin': 0xAA00,
  19003. 'end': 0xAA5F
  19004. }, {
  19005. 'begin': 0x10190,
  19006. 'end': 0x101CF
  19007. }, {
  19008. 'begin': 0x101D0,
  19009. 'end': 0x101FF
  19010. }, {
  19011. 'begin': 0x102A0,
  19012. 'end': 0x102DF
  19013. }, {
  19014. 'begin': 0x1F030,
  19015. 'end': 0x1F09F
  19016. }];
  19017. function getUnicodeRangeFor(value) {
  19018. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  19019. var range = UnicodeRanges[i];
  19020. if (value >= range.begin && value < range.end) {
  19021. return i;
  19022. }
  19023. }
  19024. return -1;
  19025. }
  19026. function isRTLRangeFor(value) {
  19027. var range = UnicodeRanges[13];
  19028. if (value >= range.begin && value < range.end) {
  19029. return true;
  19030. }
  19031. range = UnicodeRanges[11];
  19032. if (value >= range.begin && value < range.end) {
  19033. return true;
  19034. }
  19035. return false;
  19036. }
  19037. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  19038. t['\xA8'] = ' \u0308';
  19039. t['\xAF'] = ' \u0304';
  19040. t['\xB4'] = ' \u0301';
  19041. t['\xB5'] = '\u03BC';
  19042. t['\xB8'] = ' \u0327';
  19043. t['\u0132'] = 'IJ';
  19044. t['\u0133'] = 'ij';
  19045. t['\u013F'] = 'L\xB7';
  19046. t['\u0140'] = 'l\xB7';
  19047. t['\u0149'] = '\u02BCn';
  19048. t['\u017F'] = 's';
  19049. t['\u01C4'] = 'D\u017D';
  19050. t['\u01C5'] = 'D\u017E';
  19051. t['\u01C6'] = 'd\u017E';
  19052. t['\u01C7'] = 'LJ';
  19053. t['\u01C8'] = 'Lj';
  19054. t['\u01C9'] = 'lj';
  19055. t['\u01CA'] = 'NJ';
  19056. t['\u01CB'] = 'Nj';
  19057. t['\u01CC'] = 'nj';
  19058. t['\u01F1'] = 'DZ';
  19059. t['\u01F2'] = 'Dz';
  19060. t['\u01F3'] = 'dz';
  19061. t['\u02D8'] = ' \u0306';
  19062. t['\u02D9'] = ' \u0307';
  19063. t['\u02DA'] = ' \u030A';
  19064. t['\u02DB'] = ' \u0328';
  19065. t['\u02DC'] = ' \u0303';
  19066. t['\u02DD'] = ' \u030B';
  19067. t['\u037A'] = ' \u0345';
  19068. t['\u0384'] = ' \u0301';
  19069. t['\u03D0'] = '\u03B2';
  19070. t['\u03D1'] = '\u03B8';
  19071. t['\u03D2'] = '\u03A5';
  19072. t['\u03D5'] = '\u03C6';
  19073. t['\u03D6'] = '\u03C0';
  19074. t['\u03F0'] = '\u03BA';
  19075. t['\u03F1'] = '\u03C1';
  19076. t['\u03F2'] = '\u03C2';
  19077. t['\u03F4'] = '\u0398';
  19078. t['\u03F5'] = '\u03B5';
  19079. t['\u03F9'] = '\u03A3';
  19080. t['\u0587'] = '\u0565\u0582';
  19081. t['\u0675'] = '\u0627\u0674';
  19082. t['\u0676'] = '\u0648\u0674';
  19083. t['\u0677'] = '\u06C7\u0674';
  19084. t['\u0678'] = '\u064A\u0674';
  19085. t['\u0E33'] = '\u0E4D\u0E32';
  19086. t['\u0EB3'] = '\u0ECD\u0EB2';
  19087. t['\u0EDC'] = '\u0EAB\u0E99';
  19088. t['\u0EDD'] = '\u0EAB\u0EA1';
  19089. t['\u0F77'] = '\u0FB2\u0F81';
  19090. t['\u0F79'] = '\u0FB3\u0F81';
  19091. t['\u1E9A'] = 'a\u02BE';
  19092. t['\u1FBD'] = ' \u0313';
  19093. t['\u1FBF'] = ' \u0313';
  19094. t['\u1FC0'] = ' \u0342';
  19095. t['\u1FFE'] = ' \u0314';
  19096. t['\u2002'] = ' ';
  19097. t['\u2003'] = ' ';
  19098. t['\u2004'] = ' ';
  19099. t['\u2005'] = ' ';
  19100. t['\u2006'] = ' ';
  19101. t['\u2008'] = ' ';
  19102. t['\u2009'] = ' ';
  19103. t['\u200A'] = ' ';
  19104. t['\u2017'] = ' \u0333';
  19105. t['\u2024'] = '.';
  19106. t['\u2025'] = '..';
  19107. t['\u2026'] = '...';
  19108. t['\u2033'] = '\u2032\u2032';
  19109. t['\u2034'] = '\u2032\u2032\u2032';
  19110. t['\u2036'] = '\u2035\u2035';
  19111. t['\u2037'] = '\u2035\u2035\u2035';
  19112. t['\u203C'] = '!!';
  19113. t['\u203E'] = ' \u0305';
  19114. t['\u2047'] = '??';
  19115. t['\u2048'] = '?!';
  19116. t['\u2049'] = '!?';
  19117. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  19118. t['\u205F'] = ' ';
  19119. t['\u20A8'] = 'Rs';
  19120. t['\u2100'] = 'a/c';
  19121. t['\u2101'] = 'a/s';
  19122. t['\u2103'] = '\xB0C';
  19123. t['\u2105'] = 'c/o';
  19124. t['\u2106'] = 'c/u';
  19125. t['\u2107'] = '\u0190';
  19126. t['\u2109'] = '\xB0F';
  19127. t['\u2116'] = 'No';
  19128. t['\u2121'] = 'TEL';
  19129. t['\u2135'] = '\u05D0';
  19130. t['\u2136'] = '\u05D1';
  19131. t['\u2137'] = '\u05D2';
  19132. t['\u2138'] = '\u05D3';
  19133. t['\u213B'] = 'FAX';
  19134. t['\u2160'] = 'I';
  19135. t['\u2161'] = 'II';
  19136. t['\u2162'] = 'III';
  19137. t['\u2163'] = 'IV';
  19138. t['\u2164'] = 'V';
  19139. t['\u2165'] = 'VI';
  19140. t['\u2166'] = 'VII';
  19141. t['\u2167'] = 'VIII';
  19142. t['\u2168'] = 'IX';
  19143. t['\u2169'] = 'X';
  19144. t['\u216A'] = 'XI';
  19145. t['\u216B'] = 'XII';
  19146. t['\u216C'] = 'L';
  19147. t['\u216D'] = 'C';
  19148. t['\u216E'] = 'D';
  19149. t['\u216F'] = 'M';
  19150. t['\u2170'] = 'i';
  19151. t['\u2171'] = 'ii';
  19152. t['\u2172'] = 'iii';
  19153. t['\u2173'] = 'iv';
  19154. t['\u2174'] = 'v';
  19155. t['\u2175'] = 'vi';
  19156. t['\u2176'] = 'vii';
  19157. t['\u2177'] = 'viii';
  19158. t['\u2178'] = 'ix';
  19159. t['\u2179'] = 'x';
  19160. t['\u217A'] = 'xi';
  19161. t['\u217B'] = 'xii';
  19162. t['\u217C'] = 'l';
  19163. t['\u217D'] = 'c';
  19164. t['\u217E'] = 'd';
  19165. t['\u217F'] = 'm';
  19166. t['\u222C'] = '\u222B\u222B';
  19167. t['\u222D'] = '\u222B\u222B\u222B';
  19168. t['\u222F'] = '\u222E\u222E';
  19169. t['\u2230'] = '\u222E\u222E\u222E';
  19170. t['\u2474'] = '(1)';
  19171. t['\u2475'] = '(2)';
  19172. t['\u2476'] = '(3)';
  19173. t['\u2477'] = '(4)';
  19174. t['\u2478'] = '(5)';
  19175. t['\u2479'] = '(6)';
  19176. t['\u247A'] = '(7)';
  19177. t['\u247B'] = '(8)';
  19178. t['\u247C'] = '(9)';
  19179. t['\u247D'] = '(10)';
  19180. t['\u247E'] = '(11)';
  19181. t['\u247F'] = '(12)';
  19182. t['\u2480'] = '(13)';
  19183. t['\u2481'] = '(14)';
  19184. t['\u2482'] = '(15)';
  19185. t['\u2483'] = '(16)';
  19186. t['\u2484'] = '(17)';
  19187. t['\u2485'] = '(18)';
  19188. t['\u2486'] = '(19)';
  19189. t['\u2487'] = '(20)';
  19190. t['\u2488'] = '1.';
  19191. t['\u2489'] = '2.';
  19192. t['\u248A'] = '3.';
  19193. t['\u248B'] = '4.';
  19194. t['\u248C'] = '5.';
  19195. t['\u248D'] = '6.';
  19196. t['\u248E'] = '7.';
  19197. t['\u248F'] = '8.';
  19198. t['\u2490'] = '9.';
  19199. t['\u2491'] = '10.';
  19200. t['\u2492'] = '11.';
  19201. t['\u2493'] = '12.';
  19202. t['\u2494'] = '13.';
  19203. t['\u2495'] = '14.';
  19204. t['\u2496'] = '15.';
  19205. t['\u2497'] = '16.';
  19206. t['\u2498'] = '17.';
  19207. t['\u2499'] = '18.';
  19208. t['\u249A'] = '19.';
  19209. t['\u249B'] = '20.';
  19210. t['\u249C'] = '(a)';
  19211. t['\u249D'] = '(b)';
  19212. t['\u249E'] = '(c)';
  19213. t['\u249F'] = '(d)';
  19214. t['\u24A0'] = '(e)';
  19215. t['\u24A1'] = '(f)';
  19216. t['\u24A2'] = '(g)';
  19217. t['\u24A3'] = '(h)';
  19218. t['\u24A4'] = '(i)';
  19219. t['\u24A5'] = '(j)';
  19220. t['\u24A6'] = '(k)';
  19221. t['\u24A7'] = '(l)';
  19222. t['\u24A8'] = '(m)';
  19223. t['\u24A9'] = '(n)';
  19224. t['\u24AA'] = '(o)';
  19225. t['\u24AB'] = '(p)';
  19226. t['\u24AC'] = '(q)';
  19227. t['\u24AD'] = '(r)';
  19228. t['\u24AE'] = '(s)';
  19229. t['\u24AF'] = '(t)';
  19230. t['\u24B0'] = '(u)';
  19231. t['\u24B1'] = '(v)';
  19232. t['\u24B2'] = '(w)';
  19233. t['\u24B3'] = '(x)';
  19234. t['\u24B4'] = '(y)';
  19235. t['\u24B5'] = '(z)';
  19236. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  19237. t['\u2A74'] = '::=';
  19238. t['\u2A75'] = '==';
  19239. t['\u2A76'] = '===';
  19240. t['\u2E9F'] = '\u6BCD';
  19241. t['\u2EF3'] = '\u9F9F';
  19242. t['\u2F00'] = '\u4E00';
  19243. t['\u2F01'] = '\u4E28';
  19244. t['\u2F02'] = '\u4E36';
  19245. t['\u2F03'] = '\u4E3F';
  19246. t['\u2F04'] = '\u4E59';
  19247. t['\u2F05'] = '\u4E85';
  19248. t['\u2F06'] = '\u4E8C';
  19249. t['\u2F07'] = '\u4EA0';
  19250. t['\u2F08'] = '\u4EBA';
  19251. t['\u2F09'] = '\u513F';
  19252. t['\u2F0A'] = '\u5165';
  19253. t['\u2F0B'] = '\u516B';
  19254. t['\u2F0C'] = '\u5182';
  19255. t['\u2F0D'] = '\u5196';
  19256. t['\u2F0E'] = '\u51AB';
  19257. t['\u2F0F'] = '\u51E0';
  19258. t['\u2F10'] = '\u51F5';
  19259. t['\u2F11'] = '\u5200';
  19260. t['\u2F12'] = '\u529B';
  19261. t['\u2F13'] = '\u52F9';
  19262. t['\u2F14'] = '\u5315';
  19263. t['\u2F15'] = '\u531A';
  19264. t['\u2F16'] = '\u5338';
  19265. t['\u2F17'] = '\u5341';
  19266. t['\u2F18'] = '\u535C';
  19267. t['\u2F19'] = '\u5369';
  19268. t['\u2F1A'] = '\u5382';
  19269. t['\u2F1B'] = '\u53B6';
  19270. t['\u2F1C'] = '\u53C8';
  19271. t['\u2F1D'] = '\u53E3';
  19272. t['\u2F1E'] = '\u56D7';
  19273. t['\u2F1F'] = '\u571F';
  19274. t['\u2F20'] = '\u58EB';
  19275. t['\u2F21'] = '\u5902';
  19276. t['\u2F22'] = '\u590A';
  19277. t['\u2F23'] = '\u5915';
  19278. t['\u2F24'] = '\u5927';
  19279. t['\u2F25'] = '\u5973';
  19280. t['\u2F26'] = '\u5B50';
  19281. t['\u2F27'] = '\u5B80';
  19282. t['\u2F28'] = '\u5BF8';
  19283. t['\u2F29'] = '\u5C0F';
  19284. t['\u2F2A'] = '\u5C22';
  19285. t['\u2F2B'] = '\u5C38';
  19286. t['\u2F2C'] = '\u5C6E';
  19287. t['\u2F2D'] = '\u5C71';
  19288. t['\u2F2E'] = '\u5DDB';
  19289. t['\u2F2F'] = '\u5DE5';
  19290. t['\u2F30'] = '\u5DF1';
  19291. t['\u2F31'] = '\u5DFE';
  19292. t['\u2F32'] = '\u5E72';
  19293. t['\u2F33'] = '\u5E7A';
  19294. t['\u2F34'] = '\u5E7F';
  19295. t['\u2F35'] = '\u5EF4';
  19296. t['\u2F36'] = '\u5EFE';
  19297. t['\u2F37'] = '\u5F0B';
  19298. t['\u2F38'] = '\u5F13';
  19299. t['\u2F39'] = '\u5F50';
  19300. t['\u2F3A'] = '\u5F61';
  19301. t['\u2F3B'] = '\u5F73';
  19302. t['\u2F3C'] = '\u5FC3';
  19303. t['\u2F3D'] = '\u6208';
  19304. t['\u2F3E'] = '\u6236';
  19305. t['\u2F3F'] = '\u624B';
  19306. t['\u2F40'] = '\u652F';
  19307. t['\u2F41'] = '\u6534';
  19308. t['\u2F42'] = '\u6587';
  19309. t['\u2F43'] = '\u6597';
  19310. t['\u2F44'] = '\u65A4';
  19311. t['\u2F45'] = '\u65B9';
  19312. t['\u2F46'] = '\u65E0';
  19313. t['\u2F47'] = '\u65E5';
  19314. t['\u2F48'] = '\u66F0';
  19315. t['\u2F49'] = '\u6708';
  19316. t['\u2F4A'] = '\u6728';
  19317. t['\u2F4B'] = '\u6B20';
  19318. t['\u2F4C'] = '\u6B62';
  19319. t['\u2F4D'] = '\u6B79';
  19320. t['\u2F4E'] = '\u6BB3';
  19321. t['\u2F4F'] = '\u6BCB';
  19322. t['\u2F50'] = '\u6BD4';
  19323. t['\u2F51'] = '\u6BDB';
  19324. t['\u2F52'] = '\u6C0F';
  19325. t['\u2F53'] = '\u6C14';
  19326. t['\u2F54'] = '\u6C34';
  19327. t['\u2F55'] = '\u706B';
  19328. t['\u2F56'] = '\u722A';
  19329. t['\u2F57'] = '\u7236';
  19330. t['\u2F58'] = '\u723B';
  19331. t['\u2F59'] = '\u723F';
  19332. t['\u2F5A'] = '\u7247';
  19333. t['\u2F5B'] = '\u7259';
  19334. t['\u2F5C'] = '\u725B';
  19335. t['\u2F5D'] = '\u72AC';
  19336. t['\u2F5E'] = '\u7384';
  19337. t['\u2F5F'] = '\u7389';
  19338. t['\u2F60'] = '\u74DC';
  19339. t['\u2F61'] = '\u74E6';
  19340. t['\u2F62'] = '\u7518';
  19341. t['\u2F63'] = '\u751F';
  19342. t['\u2F64'] = '\u7528';
  19343. t['\u2F65'] = '\u7530';
  19344. t['\u2F66'] = '\u758B';
  19345. t['\u2F67'] = '\u7592';
  19346. t['\u2F68'] = '\u7676';
  19347. t['\u2F69'] = '\u767D';
  19348. t['\u2F6A'] = '\u76AE';
  19349. t['\u2F6B'] = '\u76BF';
  19350. t['\u2F6C'] = '\u76EE';
  19351. t['\u2F6D'] = '\u77DB';
  19352. t['\u2F6E'] = '\u77E2';
  19353. t['\u2F6F'] = '\u77F3';
  19354. t['\u2F70'] = '\u793A';
  19355. t['\u2F71'] = '\u79B8';
  19356. t['\u2F72'] = '\u79BE';
  19357. t['\u2F73'] = '\u7A74';
  19358. t['\u2F74'] = '\u7ACB';
  19359. t['\u2F75'] = '\u7AF9';
  19360. t['\u2F76'] = '\u7C73';
  19361. t['\u2F77'] = '\u7CF8';
  19362. t['\u2F78'] = '\u7F36';
  19363. t['\u2F79'] = '\u7F51';
  19364. t['\u2F7A'] = '\u7F8A';
  19365. t['\u2F7B'] = '\u7FBD';
  19366. t['\u2F7C'] = '\u8001';
  19367. t['\u2F7D'] = '\u800C';
  19368. t['\u2F7E'] = '\u8012';
  19369. t['\u2F7F'] = '\u8033';
  19370. t['\u2F80'] = '\u807F';
  19371. t['\u2F81'] = '\u8089';
  19372. t['\u2F82'] = '\u81E3';
  19373. t['\u2F83'] = '\u81EA';
  19374. t['\u2F84'] = '\u81F3';
  19375. t['\u2F85'] = '\u81FC';
  19376. t['\u2F86'] = '\u820C';
  19377. t['\u2F87'] = '\u821B';
  19378. t['\u2F88'] = '\u821F';
  19379. t['\u2F89'] = '\u826E';
  19380. t['\u2F8A'] = '\u8272';
  19381. t['\u2F8B'] = '\u8278';
  19382. t['\u2F8C'] = '\u864D';
  19383. t['\u2F8D'] = '\u866B';
  19384. t['\u2F8E'] = '\u8840';
  19385. t['\u2F8F'] = '\u884C';
  19386. t['\u2F90'] = '\u8863';
  19387. t['\u2F91'] = '\u897E';
  19388. t['\u2F92'] = '\u898B';
  19389. t['\u2F93'] = '\u89D2';
  19390. t['\u2F94'] = '\u8A00';
  19391. t['\u2F95'] = '\u8C37';
  19392. t['\u2F96'] = '\u8C46';
  19393. t['\u2F97'] = '\u8C55';
  19394. t['\u2F98'] = '\u8C78';
  19395. t['\u2F99'] = '\u8C9D';
  19396. t['\u2F9A'] = '\u8D64';
  19397. t['\u2F9B'] = '\u8D70';
  19398. t['\u2F9C'] = '\u8DB3';
  19399. t['\u2F9D'] = '\u8EAB';
  19400. t['\u2F9E'] = '\u8ECA';
  19401. t['\u2F9F'] = '\u8F9B';
  19402. t['\u2FA0'] = '\u8FB0';
  19403. t['\u2FA1'] = '\u8FB5';
  19404. t['\u2FA2'] = '\u9091';
  19405. t['\u2FA3'] = '\u9149';
  19406. t['\u2FA4'] = '\u91C6';
  19407. t['\u2FA5'] = '\u91CC';
  19408. t['\u2FA6'] = '\u91D1';
  19409. t['\u2FA7'] = '\u9577';
  19410. t['\u2FA8'] = '\u9580';
  19411. t['\u2FA9'] = '\u961C';
  19412. t['\u2FAA'] = '\u96B6';
  19413. t['\u2FAB'] = '\u96B9';
  19414. t['\u2FAC'] = '\u96E8';
  19415. t['\u2FAD'] = '\u9751';
  19416. t['\u2FAE'] = '\u975E';
  19417. t['\u2FAF'] = '\u9762';
  19418. t['\u2FB0'] = '\u9769';
  19419. t['\u2FB1'] = '\u97CB';
  19420. t['\u2FB2'] = '\u97ED';
  19421. t['\u2FB3'] = '\u97F3';
  19422. t['\u2FB4'] = '\u9801';
  19423. t['\u2FB5'] = '\u98A8';
  19424. t['\u2FB6'] = '\u98DB';
  19425. t['\u2FB7'] = '\u98DF';
  19426. t['\u2FB8'] = '\u9996';
  19427. t['\u2FB9'] = '\u9999';
  19428. t['\u2FBA'] = '\u99AC';
  19429. t['\u2FBB'] = '\u9AA8';
  19430. t['\u2FBC'] = '\u9AD8';
  19431. t['\u2FBD'] = '\u9ADF';
  19432. t['\u2FBE'] = '\u9B25';
  19433. t['\u2FBF'] = '\u9B2F';
  19434. t['\u2FC0'] = '\u9B32';
  19435. t['\u2FC1'] = '\u9B3C';
  19436. t['\u2FC2'] = '\u9B5A';
  19437. t['\u2FC3'] = '\u9CE5';
  19438. t['\u2FC4'] = '\u9E75';
  19439. t['\u2FC5'] = '\u9E7F';
  19440. t['\u2FC6'] = '\u9EA5';
  19441. t['\u2FC7'] = '\u9EBB';
  19442. t['\u2FC8'] = '\u9EC3';
  19443. t['\u2FC9'] = '\u9ECD';
  19444. t['\u2FCA'] = '\u9ED1';
  19445. t['\u2FCB'] = '\u9EF9';
  19446. t['\u2FCC'] = '\u9EFD';
  19447. t['\u2FCD'] = '\u9F0E';
  19448. t['\u2FCE'] = '\u9F13';
  19449. t['\u2FCF'] = '\u9F20';
  19450. t['\u2FD0'] = '\u9F3B';
  19451. t['\u2FD1'] = '\u9F4A';
  19452. t['\u2FD2'] = '\u9F52';
  19453. t['\u2FD3'] = '\u9F8D';
  19454. t['\u2FD4'] = '\u9F9C';
  19455. t['\u2FD5'] = '\u9FA0';
  19456. t['\u3036'] = '\u3012';
  19457. t['\u3038'] = '\u5341';
  19458. t['\u3039'] = '\u5344';
  19459. t['\u303A'] = '\u5345';
  19460. t['\u309B'] = ' \u3099';
  19461. t['\u309C'] = ' \u309A';
  19462. t['\u3131'] = '\u1100';
  19463. t['\u3132'] = '\u1101';
  19464. t['\u3133'] = '\u11AA';
  19465. t['\u3134'] = '\u1102';
  19466. t['\u3135'] = '\u11AC';
  19467. t['\u3136'] = '\u11AD';
  19468. t['\u3137'] = '\u1103';
  19469. t['\u3138'] = '\u1104';
  19470. t['\u3139'] = '\u1105';
  19471. t['\u313A'] = '\u11B0';
  19472. t['\u313B'] = '\u11B1';
  19473. t['\u313C'] = '\u11B2';
  19474. t['\u313D'] = '\u11B3';
  19475. t['\u313E'] = '\u11B4';
  19476. t['\u313F'] = '\u11B5';
  19477. t['\u3140'] = '\u111A';
  19478. t['\u3141'] = '\u1106';
  19479. t['\u3142'] = '\u1107';
  19480. t['\u3143'] = '\u1108';
  19481. t['\u3144'] = '\u1121';
  19482. t['\u3145'] = '\u1109';
  19483. t['\u3146'] = '\u110A';
  19484. t['\u3147'] = '\u110B';
  19485. t['\u3148'] = '\u110C';
  19486. t['\u3149'] = '\u110D';
  19487. t['\u314A'] = '\u110E';
  19488. t['\u314B'] = '\u110F';
  19489. t['\u314C'] = '\u1110';
  19490. t['\u314D'] = '\u1111';
  19491. t['\u314E'] = '\u1112';
  19492. t['\u314F'] = '\u1161';
  19493. t['\u3150'] = '\u1162';
  19494. t['\u3151'] = '\u1163';
  19495. t['\u3152'] = '\u1164';
  19496. t['\u3153'] = '\u1165';
  19497. t['\u3154'] = '\u1166';
  19498. t['\u3155'] = '\u1167';
  19499. t['\u3156'] = '\u1168';
  19500. t['\u3157'] = '\u1169';
  19501. t['\u3158'] = '\u116A';
  19502. t['\u3159'] = '\u116B';
  19503. t['\u315A'] = '\u116C';
  19504. t['\u315B'] = '\u116D';
  19505. t['\u315C'] = '\u116E';
  19506. t['\u315D'] = '\u116F';
  19507. t['\u315E'] = '\u1170';
  19508. t['\u315F'] = '\u1171';
  19509. t['\u3160'] = '\u1172';
  19510. t['\u3161'] = '\u1173';
  19511. t['\u3162'] = '\u1174';
  19512. t['\u3163'] = '\u1175';
  19513. t['\u3164'] = '\u1160';
  19514. t['\u3165'] = '\u1114';
  19515. t['\u3166'] = '\u1115';
  19516. t['\u3167'] = '\u11C7';
  19517. t['\u3168'] = '\u11C8';
  19518. t['\u3169'] = '\u11CC';
  19519. t['\u316A'] = '\u11CE';
  19520. t['\u316B'] = '\u11D3';
  19521. t['\u316C'] = '\u11D7';
  19522. t['\u316D'] = '\u11D9';
  19523. t['\u316E'] = '\u111C';
  19524. t['\u316F'] = '\u11DD';
  19525. t['\u3170'] = '\u11DF';
  19526. t['\u3171'] = '\u111D';
  19527. t['\u3172'] = '\u111E';
  19528. t['\u3173'] = '\u1120';
  19529. t['\u3174'] = '\u1122';
  19530. t['\u3175'] = '\u1123';
  19531. t['\u3176'] = '\u1127';
  19532. t['\u3177'] = '\u1129';
  19533. t['\u3178'] = '\u112B';
  19534. t['\u3179'] = '\u112C';
  19535. t['\u317A'] = '\u112D';
  19536. t['\u317B'] = '\u112E';
  19537. t['\u317C'] = '\u112F';
  19538. t['\u317D'] = '\u1132';
  19539. t['\u317E'] = '\u1136';
  19540. t['\u317F'] = '\u1140';
  19541. t['\u3180'] = '\u1147';
  19542. t['\u3181'] = '\u114C';
  19543. t['\u3182'] = '\u11F1';
  19544. t['\u3183'] = '\u11F2';
  19545. t['\u3184'] = '\u1157';
  19546. t['\u3185'] = '\u1158';
  19547. t['\u3186'] = '\u1159';
  19548. t['\u3187'] = '\u1184';
  19549. t['\u3188'] = '\u1185';
  19550. t['\u3189'] = '\u1188';
  19551. t['\u318A'] = '\u1191';
  19552. t['\u318B'] = '\u1192';
  19553. t['\u318C'] = '\u1194';
  19554. t['\u318D'] = '\u119E';
  19555. t['\u318E'] = '\u11A1';
  19556. t['\u3200'] = '(\u1100)';
  19557. t['\u3201'] = '(\u1102)';
  19558. t['\u3202'] = '(\u1103)';
  19559. t['\u3203'] = '(\u1105)';
  19560. t['\u3204'] = '(\u1106)';
  19561. t['\u3205'] = '(\u1107)';
  19562. t['\u3206'] = '(\u1109)';
  19563. t['\u3207'] = '(\u110B)';
  19564. t['\u3208'] = '(\u110C)';
  19565. t['\u3209'] = '(\u110E)';
  19566. t['\u320A'] = '(\u110F)';
  19567. t['\u320B'] = '(\u1110)';
  19568. t['\u320C'] = '(\u1111)';
  19569. t['\u320D'] = '(\u1112)';
  19570. t['\u320E'] = '(\u1100\u1161)';
  19571. t['\u320F'] = '(\u1102\u1161)';
  19572. t['\u3210'] = '(\u1103\u1161)';
  19573. t['\u3211'] = '(\u1105\u1161)';
  19574. t['\u3212'] = '(\u1106\u1161)';
  19575. t['\u3213'] = '(\u1107\u1161)';
  19576. t['\u3214'] = '(\u1109\u1161)';
  19577. t['\u3215'] = '(\u110B\u1161)';
  19578. t['\u3216'] = '(\u110C\u1161)';
  19579. t['\u3217'] = '(\u110E\u1161)';
  19580. t['\u3218'] = '(\u110F\u1161)';
  19581. t['\u3219'] = '(\u1110\u1161)';
  19582. t['\u321A'] = '(\u1111\u1161)';
  19583. t['\u321B'] = '(\u1112\u1161)';
  19584. t['\u321C'] = '(\u110C\u116E)';
  19585. t['\u321D'] = '(\u110B\u1169\u110C\u1165\u11AB)';
  19586. t['\u321E'] = '(\u110B\u1169\u1112\u116E)';
  19587. t['\u3220'] = '(\u4E00)';
  19588. t['\u3221'] = '(\u4E8C)';
  19589. t['\u3222'] = '(\u4E09)';
  19590. t['\u3223'] = '(\u56DB)';
  19591. t['\u3224'] = '(\u4E94)';
  19592. t['\u3225'] = '(\u516D)';
  19593. t['\u3226'] = '(\u4E03)';
  19594. t['\u3227'] = '(\u516B)';
  19595. t['\u3228'] = '(\u4E5D)';
  19596. t['\u3229'] = '(\u5341)';
  19597. t['\u322A'] = '(\u6708)';
  19598. t['\u322B'] = '(\u706B)';
  19599. t['\u322C'] = '(\u6C34)';
  19600. t['\u322D'] = '(\u6728)';
  19601. t['\u322E'] = '(\u91D1)';
  19602. t['\u322F'] = '(\u571F)';
  19603. t['\u3230'] = '(\u65E5)';
  19604. t['\u3231'] = '(\u682A)';
  19605. t['\u3232'] = '(\u6709)';
  19606. t['\u3233'] = '(\u793E)';
  19607. t['\u3234'] = '(\u540D)';
  19608. t['\u3235'] = '(\u7279)';
  19609. t['\u3236'] = '(\u8CA1)';
  19610. t['\u3237'] = '(\u795D)';
  19611. t['\u3238'] = '(\u52B4)';
  19612. t['\u3239'] = '(\u4EE3)';
  19613. t['\u323A'] = '(\u547C)';
  19614. t['\u323B'] = '(\u5B66)';
  19615. t['\u323C'] = '(\u76E3)';
  19616. t['\u323D'] = '(\u4F01)';
  19617. t['\u323E'] = '(\u8CC7)';
  19618. t['\u323F'] = '(\u5354)';
  19619. t['\u3240'] = '(\u796D)';
  19620. t['\u3241'] = '(\u4F11)';
  19621. t['\u3242'] = '(\u81EA)';
  19622. t['\u3243'] = '(\u81F3)';
  19623. t['\u32C0'] = '1\u6708';
  19624. t['\u32C1'] = '2\u6708';
  19625. t['\u32C2'] = '3\u6708';
  19626. t['\u32C3'] = '4\u6708';
  19627. t['\u32C4'] = '5\u6708';
  19628. t['\u32C5'] = '6\u6708';
  19629. t['\u32C6'] = '7\u6708';
  19630. t['\u32C7'] = '8\u6708';
  19631. t['\u32C8'] = '9\u6708';
  19632. t['\u32C9'] = '10\u6708';
  19633. t['\u32CA'] = '11\u6708';
  19634. t['\u32CB'] = '12\u6708';
  19635. t['\u3358'] = '0\u70B9';
  19636. t['\u3359'] = '1\u70B9';
  19637. t['\u335A'] = '2\u70B9';
  19638. t['\u335B'] = '3\u70B9';
  19639. t['\u335C'] = '4\u70B9';
  19640. t['\u335D'] = '5\u70B9';
  19641. t['\u335E'] = '6\u70B9';
  19642. t['\u335F'] = '7\u70B9';
  19643. t['\u3360'] = '8\u70B9';
  19644. t['\u3361'] = '9\u70B9';
  19645. t['\u3362'] = '10\u70B9';
  19646. t['\u3363'] = '11\u70B9';
  19647. t['\u3364'] = '12\u70B9';
  19648. t['\u3365'] = '13\u70B9';
  19649. t['\u3366'] = '14\u70B9';
  19650. t['\u3367'] = '15\u70B9';
  19651. t['\u3368'] = '16\u70B9';
  19652. t['\u3369'] = '17\u70B9';
  19653. t['\u336A'] = '18\u70B9';
  19654. t['\u336B'] = '19\u70B9';
  19655. t['\u336C'] = '20\u70B9';
  19656. t['\u336D'] = '21\u70B9';
  19657. t['\u336E'] = '22\u70B9';
  19658. t['\u336F'] = '23\u70B9';
  19659. t['\u3370'] = '24\u70B9';
  19660. t['\u33E0'] = '1\u65E5';
  19661. t['\u33E1'] = '2\u65E5';
  19662. t['\u33E2'] = '3\u65E5';
  19663. t['\u33E3'] = '4\u65E5';
  19664. t['\u33E4'] = '5\u65E5';
  19665. t['\u33E5'] = '6\u65E5';
  19666. t['\u33E6'] = '7\u65E5';
  19667. t['\u33E7'] = '8\u65E5';
  19668. t['\u33E8'] = '9\u65E5';
  19669. t['\u33E9'] = '10\u65E5';
  19670. t['\u33EA'] = '11\u65E5';
  19671. t['\u33EB'] = '12\u65E5';
  19672. t['\u33EC'] = '13\u65E5';
  19673. t['\u33ED'] = '14\u65E5';
  19674. t['\u33EE'] = '15\u65E5';
  19675. t['\u33EF'] = '16\u65E5';
  19676. t['\u33F0'] = '17\u65E5';
  19677. t['\u33F1'] = '18\u65E5';
  19678. t['\u33F2'] = '19\u65E5';
  19679. t['\u33F3'] = '20\u65E5';
  19680. t['\u33F4'] = '21\u65E5';
  19681. t['\u33F5'] = '22\u65E5';
  19682. t['\u33F6'] = '23\u65E5';
  19683. t['\u33F7'] = '24\u65E5';
  19684. t['\u33F8'] = '25\u65E5';
  19685. t['\u33F9'] = '26\u65E5';
  19686. t['\u33FA'] = '27\u65E5';
  19687. t['\u33FB'] = '28\u65E5';
  19688. t['\u33FC'] = '29\u65E5';
  19689. t['\u33FD'] = '30\u65E5';
  19690. t['\u33FE'] = '31\u65E5';
  19691. t['\uFB00'] = 'ff';
  19692. t['\uFB01'] = 'fi';
  19693. t['\uFB02'] = 'fl';
  19694. t['\uFB03'] = 'ffi';
  19695. t['\uFB04'] = 'ffl';
  19696. t['\uFB05'] = '\u017Ft';
  19697. t['\uFB06'] = 'st';
  19698. t['\uFB13'] = '\u0574\u0576';
  19699. t['\uFB14'] = '\u0574\u0565';
  19700. t['\uFB15'] = '\u0574\u056B';
  19701. t['\uFB16'] = '\u057E\u0576';
  19702. t['\uFB17'] = '\u0574\u056D';
  19703. t['\uFB4F'] = '\u05D0\u05DC';
  19704. t['\uFB50'] = '\u0671';
  19705. t['\uFB51'] = '\u0671';
  19706. t['\uFB52'] = '\u067B';
  19707. t['\uFB53'] = '\u067B';
  19708. t['\uFB54'] = '\u067B';
  19709. t['\uFB55'] = '\u067B';
  19710. t['\uFB56'] = '\u067E';
  19711. t['\uFB57'] = '\u067E';
  19712. t['\uFB58'] = '\u067E';
  19713. t['\uFB59'] = '\u067E';
  19714. t['\uFB5A'] = '\u0680';
  19715. t['\uFB5B'] = '\u0680';
  19716. t['\uFB5C'] = '\u0680';
  19717. t['\uFB5D'] = '\u0680';
  19718. t['\uFB5E'] = '\u067A';
  19719. t['\uFB5F'] = '\u067A';
  19720. t['\uFB60'] = '\u067A';
  19721. t['\uFB61'] = '\u067A';
  19722. t['\uFB62'] = '\u067F';
  19723. t['\uFB63'] = '\u067F';
  19724. t['\uFB64'] = '\u067F';
  19725. t['\uFB65'] = '\u067F';
  19726. t['\uFB66'] = '\u0679';
  19727. t['\uFB67'] = '\u0679';
  19728. t['\uFB68'] = '\u0679';
  19729. t['\uFB69'] = '\u0679';
  19730. t['\uFB6A'] = '\u06A4';
  19731. t['\uFB6B'] = '\u06A4';
  19732. t['\uFB6C'] = '\u06A4';
  19733. t['\uFB6D'] = '\u06A4';
  19734. t['\uFB6E'] = '\u06A6';
  19735. t['\uFB6F'] = '\u06A6';
  19736. t['\uFB70'] = '\u06A6';
  19737. t['\uFB71'] = '\u06A6';
  19738. t['\uFB72'] = '\u0684';
  19739. t['\uFB73'] = '\u0684';
  19740. t['\uFB74'] = '\u0684';
  19741. t['\uFB75'] = '\u0684';
  19742. t['\uFB76'] = '\u0683';
  19743. t['\uFB77'] = '\u0683';
  19744. t['\uFB78'] = '\u0683';
  19745. t['\uFB79'] = '\u0683';
  19746. t['\uFB7A'] = '\u0686';
  19747. t['\uFB7B'] = '\u0686';
  19748. t['\uFB7C'] = '\u0686';
  19749. t['\uFB7D'] = '\u0686';
  19750. t['\uFB7E'] = '\u0687';
  19751. t['\uFB7F'] = '\u0687';
  19752. t['\uFB80'] = '\u0687';
  19753. t['\uFB81'] = '\u0687';
  19754. t['\uFB82'] = '\u068D';
  19755. t['\uFB83'] = '\u068D';
  19756. t['\uFB84'] = '\u068C';
  19757. t['\uFB85'] = '\u068C';
  19758. t['\uFB86'] = '\u068E';
  19759. t['\uFB87'] = '\u068E';
  19760. t['\uFB88'] = '\u0688';
  19761. t['\uFB89'] = '\u0688';
  19762. t['\uFB8A'] = '\u0698';
  19763. t['\uFB8B'] = '\u0698';
  19764. t['\uFB8C'] = '\u0691';
  19765. t['\uFB8D'] = '\u0691';
  19766. t['\uFB8E'] = '\u06A9';
  19767. t['\uFB8F'] = '\u06A9';
  19768. t['\uFB90'] = '\u06A9';
  19769. t['\uFB91'] = '\u06A9';
  19770. t['\uFB92'] = '\u06AF';
  19771. t['\uFB93'] = '\u06AF';
  19772. t['\uFB94'] = '\u06AF';
  19773. t['\uFB95'] = '\u06AF';
  19774. t['\uFB96'] = '\u06B3';
  19775. t['\uFB97'] = '\u06B3';
  19776. t['\uFB98'] = '\u06B3';
  19777. t['\uFB99'] = '\u06B3';
  19778. t['\uFB9A'] = '\u06B1';
  19779. t['\uFB9B'] = '\u06B1';
  19780. t['\uFB9C'] = '\u06B1';
  19781. t['\uFB9D'] = '\u06B1';
  19782. t['\uFB9E'] = '\u06BA';
  19783. t['\uFB9F'] = '\u06BA';
  19784. t['\uFBA0'] = '\u06BB';
  19785. t['\uFBA1'] = '\u06BB';
  19786. t['\uFBA2'] = '\u06BB';
  19787. t['\uFBA3'] = '\u06BB';
  19788. t['\uFBA4'] = '\u06C0';
  19789. t['\uFBA5'] = '\u06C0';
  19790. t['\uFBA6'] = '\u06C1';
  19791. t['\uFBA7'] = '\u06C1';
  19792. t['\uFBA8'] = '\u06C1';
  19793. t['\uFBA9'] = '\u06C1';
  19794. t['\uFBAA'] = '\u06BE';
  19795. t['\uFBAB'] = '\u06BE';
  19796. t['\uFBAC'] = '\u06BE';
  19797. t['\uFBAD'] = '\u06BE';
  19798. t['\uFBAE'] = '\u06D2';
  19799. t['\uFBAF'] = '\u06D2';
  19800. t['\uFBB0'] = '\u06D3';
  19801. t['\uFBB1'] = '\u06D3';
  19802. t['\uFBD3'] = '\u06AD';
  19803. t['\uFBD4'] = '\u06AD';
  19804. t['\uFBD5'] = '\u06AD';
  19805. t['\uFBD6'] = '\u06AD';
  19806. t['\uFBD7'] = '\u06C7';
  19807. t['\uFBD8'] = '\u06C7';
  19808. t['\uFBD9'] = '\u06C6';
  19809. t['\uFBDA'] = '\u06C6';
  19810. t['\uFBDB'] = '\u06C8';
  19811. t['\uFBDC'] = '\u06C8';
  19812. t['\uFBDD'] = '\u0677';
  19813. t['\uFBDE'] = '\u06CB';
  19814. t['\uFBDF'] = '\u06CB';
  19815. t['\uFBE0'] = '\u06C5';
  19816. t['\uFBE1'] = '\u06C5';
  19817. t['\uFBE2'] = '\u06C9';
  19818. t['\uFBE3'] = '\u06C9';
  19819. t['\uFBE4'] = '\u06D0';
  19820. t['\uFBE5'] = '\u06D0';
  19821. t['\uFBE6'] = '\u06D0';
  19822. t['\uFBE7'] = '\u06D0';
  19823. t['\uFBE8'] = '\u0649';
  19824. t['\uFBE9'] = '\u0649';
  19825. t['\uFBEA'] = '\u0626\u0627';
  19826. t['\uFBEB'] = '\u0626\u0627';
  19827. t['\uFBEC'] = '\u0626\u06D5';
  19828. t['\uFBED'] = '\u0626\u06D5';
  19829. t['\uFBEE'] = '\u0626\u0648';
  19830. t['\uFBEF'] = '\u0626\u0648';
  19831. t['\uFBF0'] = '\u0626\u06C7';
  19832. t['\uFBF1'] = '\u0626\u06C7';
  19833. t['\uFBF2'] = '\u0626\u06C6';
  19834. t['\uFBF3'] = '\u0626\u06C6';
  19835. t['\uFBF4'] = '\u0626\u06C8';
  19836. t['\uFBF5'] = '\u0626\u06C8';
  19837. t['\uFBF6'] = '\u0626\u06D0';
  19838. t['\uFBF7'] = '\u0626\u06D0';
  19839. t['\uFBF8'] = '\u0626\u06D0';
  19840. t['\uFBF9'] = '\u0626\u0649';
  19841. t['\uFBFA'] = '\u0626\u0649';
  19842. t['\uFBFB'] = '\u0626\u0649';
  19843. t['\uFBFC'] = '\u06CC';
  19844. t['\uFBFD'] = '\u06CC';
  19845. t['\uFBFE'] = '\u06CC';
  19846. t['\uFBFF'] = '\u06CC';
  19847. t['\uFC00'] = '\u0626\u062C';
  19848. t['\uFC01'] = '\u0626\u062D';
  19849. t['\uFC02'] = '\u0626\u0645';
  19850. t['\uFC03'] = '\u0626\u0649';
  19851. t['\uFC04'] = '\u0626\u064A';
  19852. t['\uFC05'] = '\u0628\u062C';
  19853. t['\uFC06'] = '\u0628\u062D';
  19854. t['\uFC07'] = '\u0628\u062E';
  19855. t['\uFC08'] = '\u0628\u0645';
  19856. t['\uFC09'] = '\u0628\u0649';
  19857. t['\uFC0A'] = '\u0628\u064A';
  19858. t['\uFC0B'] = '\u062A\u062C';
  19859. t['\uFC0C'] = '\u062A\u062D';
  19860. t['\uFC0D'] = '\u062A\u062E';
  19861. t['\uFC0E'] = '\u062A\u0645';
  19862. t['\uFC0F'] = '\u062A\u0649';
  19863. t['\uFC10'] = '\u062A\u064A';
  19864. t['\uFC11'] = '\u062B\u062C';
  19865. t['\uFC12'] = '\u062B\u0645';
  19866. t['\uFC13'] = '\u062B\u0649';
  19867. t['\uFC14'] = '\u062B\u064A';
  19868. t['\uFC15'] = '\u062C\u062D';
  19869. t['\uFC16'] = '\u062C\u0645';
  19870. t['\uFC17'] = '\u062D\u062C';
  19871. t['\uFC18'] = '\u062D\u0645';
  19872. t['\uFC19'] = '\u062E\u062C';
  19873. t['\uFC1A'] = '\u062E\u062D';
  19874. t['\uFC1B'] = '\u062E\u0645';
  19875. t['\uFC1C'] = '\u0633\u062C';
  19876. t['\uFC1D'] = '\u0633\u062D';
  19877. t['\uFC1E'] = '\u0633\u062E';
  19878. t['\uFC1F'] = '\u0633\u0645';
  19879. t['\uFC20'] = '\u0635\u062D';
  19880. t['\uFC21'] = '\u0635\u0645';
  19881. t['\uFC22'] = '\u0636\u062C';
  19882. t['\uFC23'] = '\u0636\u062D';
  19883. t['\uFC24'] = '\u0636\u062E';
  19884. t['\uFC25'] = '\u0636\u0645';
  19885. t['\uFC26'] = '\u0637\u062D';
  19886. t['\uFC27'] = '\u0637\u0645';
  19887. t['\uFC28'] = '\u0638\u0645';
  19888. t['\uFC29'] = '\u0639\u062C';
  19889. t['\uFC2A'] = '\u0639\u0645';
  19890. t['\uFC2B'] = '\u063A\u062C';
  19891. t['\uFC2C'] = '\u063A\u0645';
  19892. t['\uFC2D'] = '\u0641\u062C';
  19893. t['\uFC2E'] = '\u0641\u062D';
  19894. t['\uFC2F'] = '\u0641\u062E';
  19895. t['\uFC30'] = '\u0641\u0645';
  19896. t['\uFC31'] = '\u0641\u0649';
  19897. t['\uFC32'] = '\u0641\u064A';
  19898. t['\uFC33'] = '\u0642\u062D';
  19899. t['\uFC34'] = '\u0642\u0645';
  19900. t['\uFC35'] = '\u0642\u0649';
  19901. t['\uFC36'] = '\u0642\u064A';
  19902. t['\uFC37'] = '\u0643\u0627';
  19903. t['\uFC38'] = '\u0643\u062C';
  19904. t['\uFC39'] = '\u0643\u062D';
  19905. t['\uFC3A'] = '\u0643\u062E';
  19906. t['\uFC3B'] = '\u0643\u0644';
  19907. t['\uFC3C'] = '\u0643\u0645';
  19908. t['\uFC3D'] = '\u0643\u0649';
  19909. t['\uFC3E'] = '\u0643\u064A';
  19910. t['\uFC3F'] = '\u0644\u062C';
  19911. t['\uFC40'] = '\u0644\u062D';
  19912. t['\uFC41'] = '\u0644\u062E';
  19913. t['\uFC42'] = '\u0644\u0645';
  19914. t['\uFC43'] = '\u0644\u0649';
  19915. t['\uFC44'] = '\u0644\u064A';
  19916. t['\uFC45'] = '\u0645\u062C';
  19917. t['\uFC46'] = '\u0645\u062D';
  19918. t['\uFC47'] = '\u0645\u062E';
  19919. t['\uFC48'] = '\u0645\u0645';
  19920. t['\uFC49'] = '\u0645\u0649';
  19921. t['\uFC4A'] = '\u0645\u064A';
  19922. t['\uFC4B'] = '\u0646\u062C';
  19923. t['\uFC4C'] = '\u0646\u062D';
  19924. t['\uFC4D'] = '\u0646\u062E';
  19925. t['\uFC4E'] = '\u0646\u0645';
  19926. t['\uFC4F'] = '\u0646\u0649';
  19927. t['\uFC50'] = '\u0646\u064A';
  19928. t['\uFC51'] = '\u0647\u062C';
  19929. t['\uFC52'] = '\u0647\u0645';
  19930. t['\uFC53'] = '\u0647\u0649';
  19931. t['\uFC54'] = '\u0647\u064A';
  19932. t['\uFC55'] = '\u064A\u062C';
  19933. t['\uFC56'] = '\u064A\u062D';
  19934. t['\uFC57'] = '\u064A\u062E';
  19935. t['\uFC58'] = '\u064A\u0645';
  19936. t['\uFC59'] = '\u064A\u0649';
  19937. t['\uFC5A'] = '\u064A\u064A';
  19938. t['\uFC5B'] = '\u0630\u0670';
  19939. t['\uFC5C'] = '\u0631\u0670';
  19940. t['\uFC5D'] = '\u0649\u0670';
  19941. t['\uFC5E'] = ' \u064C\u0651';
  19942. t['\uFC5F'] = ' \u064D\u0651';
  19943. t['\uFC60'] = ' \u064E\u0651';
  19944. t['\uFC61'] = ' \u064F\u0651';
  19945. t['\uFC62'] = ' \u0650\u0651';
  19946. t['\uFC63'] = ' \u0651\u0670';
  19947. t['\uFC64'] = '\u0626\u0631';
  19948. t['\uFC65'] = '\u0626\u0632';
  19949. t['\uFC66'] = '\u0626\u0645';
  19950. t['\uFC67'] = '\u0626\u0646';
  19951. t['\uFC68'] = '\u0626\u0649';
  19952. t['\uFC69'] = '\u0626\u064A';
  19953. t['\uFC6A'] = '\u0628\u0631';
  19954. t['\uFC6B'] = '\u0628\u0632';
  19955. t['\uFC6C'] = '\u0628\u0645';
  19956. t['\uFC6D'] = '\u0628\u0646';
  19957. t['\uFC6E'] = '\u0628\u0649';
  19958. t['\uFC6F'] = '\u0628\u064A';
  19959. t['\uFC70'] = '\u062A\u0631';
  19960. t['\uFC71'] = '\u062A\u0632';
  19961. t['\uFC72'] = '\u062A\u0645';
  19962. t['\uFC73'] = '\u062A\u0646';
  19963. t['\uFC74'] = '\u062A\u0649';
  19964. t['\uFC75'] = '\u062A\u064A';
  19965. t['\uFC76'] = '\u062B\u0631';
  19966. t['\uFC77'] = '\u062B\u0632';
  19967. t['\uFC78'] = '\u062B\u0645';
  19968. t['\uFC79'] = '\u062B\u0646';
  19969. t['\uFC7A'] = '\u062B\u0649';
  19970. t['\uFC7B'] = '\u062B\u064A';
  19971. t['\uFC7C'] = '\u0641\u0649';
  19972. t['\uFC7D'] = '\u0641\u064A';
  19973. t['\uFC7E'] = '\u0642\u0649';
  19974. t['\uFC7F'] = '\u0642\u064A';
  19975. t['\uFC80'] = '\u0643\u0627';
  19976. t['\uFC81'] = '\u0643\u0644';
  19977. t['\uFC82'] = '\u0643\u0645';
  19978. t['\uFC83'] = '\u0643\u0649';
  19979. t['\uFC84'] = '\u0643\u064A';
  19980. t['\uFC85'] = '\u0644\u0645';
  19981. t['\uFC86'] = '\u0644\u0649';
  19982. t['\uFC87'] = '\u0644\u064A';
  19983. t['\uFC88'] = '\u0645\u0627';
  19984. t['\uFC89'] = '\u0645\u0645';
  19985. t['\uFC8A'] = '\u0646\u0631';
  19986. t['\uFC8B'] = '\u0646\u0632';
  19987. t['\uFC8C'] = '\u0646\u0645';
  19988. t['\uFC8D'] = '\u0646\u0646';
  19989. t['\uFC8E'] = '\u0646\u0649';
  19990. t['\uFC8F'] = '\u0646\u064A';
  19991. t['\uFC90'] = '\u0649\u0670';
  19992. t['\uFC91'] = '\u064A\u0631';
  19993. t['\uFC92'] = '\u064A\u0632';
  19994. t['\uFC93'] = '\u064A\u0645';
  19995. t['\uFC94'] = '\u064A\u0646';
  19996. t['\uFC95'] = '\u064A\u0649';
  19997. t['\uFC96'] = '\u064A\u064A';
  19998. t['\uFC97'] = '\u0626\u062C';
  19999. t['\uFC98'] = '\u0626\u062D';
  20000. t['\uFC99'] = '\u0626\u062E';
  20001. t['\uFC9A'] = '\u0626\u0645';
  20002. t['\uFC9B'] = '\u0626\u0647';
  20003. t['\uFC9C'] = '\u0628\u062C';
  20004. t['\uFC9D'] = '\u0628\u062D';
  20005. t['\uFC9E'] = '\u0628\u062E';
  20006. t['\uFC9F'] = '\u0628\u0645';
  20007. t['\uFCA0'] = '\u0628\u0647';
  20008. t['\uFCA1'] = '\u062A\u062C';
  20009. t['\uFCA2'] = '\u062A\u062D';
  20010. t['\uFCA3'] = '\u062A\u062E';
  20011. t['\uFCA4'] = '\u062A\u0645';
  20012. t['\uFCA5'] = '\u062A\u0647';
  20013. t['\uFCA6'] = '\u062B\u0645';
  20014. t['\uFCA7'] = '\u062C\u062D';
  20015. t['\uFCA8'] = '\u062C\u0645';
  20016. t['\uFCA9'] = '\u062D\u062C';
  20017. t['\uFCAA'] = '\u062D\u0645';
  20018. t['\uFCAB'] = '\u062E\u062C';
  20019. t['\uFCAC'] = '\u062E\u0645';
  20020. t['\uFCAD'] = '\u0633\u062C';
  20021. t['\uFCAE'] = '\u0633\u062D';
  20022. t['\uFCAF'] = '\u0633\u062E';
  20023. t['\uFCB0'] = '\u0633\u0645';
  20024. t['\uFCB1'] = '\u0635\u062D';
  20025. t['\uFCB2'] = '\u0635\u062E';
  20026. t['\uFCB3'] = '\u0635\u0645';
  20027. t['\uFCB4'] = '\u0636\u062C';
  20028. t['\uFCB5'] = '\u0636\u062D';
  20029. t['\uFCB6'] = '\u0636\u062E';
  20030. t['\uFCB7'] = '\u0636\u0645';
  20031. t['\uFCB8'] = '\u0637\u062D';
  20032. t['\uFCB9'] = '\u0638\u0645';
  20033. t['\uFCBA'] = '\u0639\u062C';
  20034. t['\uFCBB'] = '\u0639\u0645';
  20035. t['\uFCBC'] = '\u063A\u062C';
  20036. t['\uFCBD'] = '\u063A\u0645';
  20037. t['\uFCBE'] = '\u0641\u062C';
  20038. t['\uFCBF'] = '\u0641\u062D';
  20039. t['\uFCC0'] = '\u0641\u062E';
  20040. t['\uFCC1'] = '\u0641\u0645';
  20041. t['\uFCC2'] = '\u0642\u062D';
  20042. t['\uFCC3'] = '\u0642\u0645';
  20043. t['\uFCC4'] = '\u0643\u062C';
  20044. t['\uFCC5'] = '\u0643\u062D';
  20045. t['\uFCC6'] = '\u0643\u062E';
  20046. t['\uFCC7'] = '\u0643\u0644';
  20047. t['\uFCC8'] = '\u0643\u0645';
  20048. t['\uFCC9'] = '\u0644\u062C';
  20049. t['\uFCCA'] = '\u0644\u062D';
  20050. t['\uFCCB'] = '\u0644\u062E';
  20051. t['\uFCCC'] = '\u0644\u0645';
  20052. t['\uFCCD'] = '\u0644\u0647';
  20053. t['\uFCCE'] = '\u0645\u062C';
  20054. t['\uFCCF'] = '\u0645\u062D';
  20055. t['\uFCD0'] = '\u0645\u062E';
  20056. t['\uFCD1'] = '\u0645\u0645';
  20057. t['\uFCD2'] = '\u0646\u062C';
  20058. t['\uFCD3'] = '\u0646\u062D';
  20059. t['\uFCD4'] = '\u0646\u062E';
  20060. t['\uFCD5'] = '\u0646\u0645';
  20061. t['\uFCD6'] = '\u0646\u0647';
  20062. t['\uFCD7'] = '\u0647\u062C';
  20063. t['\uFCD8'] = '\u0647\u0645';
  20064. t['\uFCD9'] = '\u0647\u0670';
  20065. t['\uFCDA'] = '\u064A\u062C';
  20066. t['\uFCDB'] = '\u064A\u062D';
  20067. t['\uFCDC'] = '\u064A\u062E';
  20068. t['\uFCDD'] = '\u064A\u0645';
  20069. t['\uFCDE'] = '\u064A\u0647';
  20070. t['\uFCDF'] = '\u0626\u0645';
  20071. t['\uFCE0'] = '\u0626\u0647';
  20072. t['\uFCE1'] = '\u0628\u0645';
  20073. t['\uFCE2'] = '\u0628\u0647';
  20074. t['\uFCE3'] = '\u062A\u0645';
  20075. t['\uFCE4'] = '\u062A\u0647';
  20076. t['\uFCE5'] = '\u062B\u0645';
  20077. t['\uFCE6'] = '\u062B\u0647';
  20078. t['\uFCE7'] = '\u0633\u0645';
  20079. t['\uFCE8'] = '\u0633\u0647';
  20080. t['\uFCE9'] = '\u0634\u0645';
  20081. t['\uFCEA'] = '\u0634\u0647';
  20082. t['\uFCEB'] = '\u0643\u0644';
  20083. t['\uFCEC'] = '\u0643\u0645';
  20084. t['\uFCED'] = '\u0644\u0645';
  20085. t['\uFCEE'] = '\u0646\u0645';
  20086. t['\uFCEF'] = '\u0646\u0647';
  20087. t['\uFCF0'] = '\u064A\u0645';
  20088. t['\uFCF1'] = '\u064A\u0647';
  20089. t['\uFCF2'] = '\u0640\u064E\u0651';
  20090. t['\uFCF3'] = '\u0640\u064F\u0651';
  20091. t['\uFCF4'] = '\u0640\u0650\u0651';
  20092. t['\uFCF5'] = '\u0637\u0649';
  20093. t['\uFCF6'] = '\u0637\u064A';
  20094. t['\uFCF7'] = '\u0639\u0649';
  20095. t['\uFCF8'] = '\u0639\u064A';
  20096. t['\uFCF9'] = '\u063A\u0649';
  20097. t['\uFCFA'] = '\u063A\u064A';
  20098. t['\uFCFB'] = '\u0633\u0649';
  20099. t['\uFCFC'] = '\u0633\u064A';
  20100. t['\uFCFD'] = '\u0634\u0649';
  20101. t['\uFCFE'] = '\u0634\u064A';
  20102. t['\uFCFF'] = '\u062D\u0649';
  20103. t['\uFD00'] = '\u062D\u064A';
  20104. t['\uFD01'] = '\u062C\u0649';
  20105. t['\uFD02'] = '\u062C\u064A';
  20106. t['\uFD03'] = '\u062E\u0649';
  20107. t['\uFD04'] = '\u062E\u064A';
  20108. t['\uFD05'] = '\u0635\u0649';
  20109. t['\uFD06'] = '\u0635\u064A';
  20110. t['\uFD07'] = '\u0636\u0649';
  20111. t['\uFD08'] = '\u0636\u064A';
  20112. t['\uFD09'] = '\u0634\u062C';
  20113. t['\uFD0A'] = '\u0634\u062D';
  20114. t['\uFD0B'] = '\u0634\u062E';
  20115. t['\uFD0C'] = '\u0634\u0645';
  20116. t['\uFD0D'] = '\u0634\u0631';
  20117. t['\uFD0E'] = '\u0633\u0631';
  20118. t['\uFD0F'] = '\u0635\u0631';
  20119. t['\uFD10'] = '\u0636\u0631';
  20120. t['\uFD11'] = '\u0637\u0649';
  20121. t['\uFD12'] = '\u0637\u064A';
  20122. t['\uFD13'] = '\u0639\u0649';
  20123. t['\uFD14'] = '\u0639\u064A';
  20124. t['\uFD15'] = '\u063A\u0649';
  20125. t['\uFD16'] = '\u063A\u064A';
  20126. t['\uFD17'] = '\u0633\u0649';
  20127. t['\uFD18'] = '\u0633\u064A';
  20128. t['\uFD19'] = '\u0634\u0649';
  20129. t['\uFD1A'] = '\u0634\u064A';
  20130. t['\uFD1B'] = '\u062D\u0649';
  20131. t['\uFD1C'] = '\u062D\u064A';
  20132. t['\uFD1D'] = '\u062C\u0649';
  20133. t['\uFD1E'] = '\u062C\u064A';
  20134. t['\uFD1F'] = '\u062E\u0649';
  20135. t['\uFD20'] = '\u062E\u064A';
  20136. t['\uFD21'] = '\u0635\u0649';
  20137. t['\uFD22'] = '\u0635\u064A';
  20138. t['\uFD23'] = '\u0636\u0649';
  20139. t['\uFD24'] = '\u0636\u064A';
  20140. t['\uFD25'] = '\u0634\u062C';
  20141. t['\uFD26'] = '\u0634\u062D';
  20142. t['\uFD27'] = '\u0634\u062E';
  20143. t['\uFD28'] = '\u0634\u0645';
  20144. t['\uFD29'] = '\u0634\u0631';
  20145. t['\uFD2A'] = '\u0633\u0631';
  20146. t['\uFD2B'] = '\u0635\u0631';
  20147. t['\uFD2C'] = '\u0636\u0631';
  20148. t['\uFD2D'] = '\u0634\u062C';
  20149. t['\uFD2E'] = '\u0634\u062D';
  20150. t['\uFD2F'] = '\u0634\u062E';
  20151. t['\uFD30'] = '\u0634\u0645';
  20152. t['\uFD31'] = '\u0633\u0647';
  20153. t['\uFD32'] = '\u0634\u0647';
  20154. t['\uFD33'] = '\u0637\u0645';
  20155. t['\uFD34'] = '\u0633\u062C';
  20156. t['\uFD35'] = '\u0633\u062D';
  20157. t['\uFD36'] = '\u0633\u062E';
  20158. t['\uFD37'] = '\u0634\u062C';
  20159. t['\uFD38'] = '\u0634\u062D';
  20160. t['\uFD39'] = '\u0634\u062E';
  20161. t['\uFD3A'] = '\u0637\u0645';
  20162. t['\uFD3B'] = '\u0638\u0645';
  20163. t['\uFD3C'] = '\u0627\u064B';
  20164. t['\uFD3D'] = '\u0627\u064B';
  20165. t['\uFD50'] = '\u062A\u062C\u0645';
  20166. t['\uFD51'] = '\u062A\u062D\u062C';
  20167. t['\uFD52'] = '\u062A\u062D\u062C';
  20168. t['\uFD53'] = '\u062A\u062D\u0645';
  20169. t['\uFD54'] = '\u062A\u062E\u0645';
  20170. t['\uFD55'] = '\u062A\u0645\u062C';
  20171. t['\uFD56'] = '\u062A\u0645\u062D';
  20172. t['\uFD57'] = '\u062A\u0645\u062E';
  20173. t['\uFD58'] = '\u062C\u0645\u062D';
  20174. t['\uFD59'] = '\u062C\u0645\u062D';
  20175. t['\uFD5A'] = '\u062D\u0645\u064A';
  20176. t['\uFD5B'] = '\u062D\u0645\u0649';
  20177. t['\uFD5C'] = '\u0633\u062D\u062C';
  20178. t['\uFD5D'] = '\u0633\u062C\u062D';
  20179. t['\uFD5E'] = '\u0633\u062C\u0649';
  20180. t['\uFD5F'] = '\u0633\u0645\u062D';
  20181. t['\uFD60'] = '\u0633\u0645\u062D';
  20182. t['\uFD61'] = '\u0633\u0645\u062C';
  20183. t['\uFD62'] = '\u0633\u0645\u0645';
  20184. t['\uFD63'] = '\u0633\u0645\u0645';
  20185. t['\uFD64'] = '\u0635\u062D\u062D';
  20186. t['\uFD65'] = '\u0635\u062D\u062D';
  20187. t['\uFD66'] = '\u0635\u0645\u0645';
  20188. t['\uFD67'] = '\u0634\u062D\u0645';
  20189. t['\uFD68'] = '\u0634\u062D\u0645';
  20190. t['\uFD69'] = '\u0634\u062C\u064A';
  20191. t['\uFD6A'] = '\u0634\u0645\u062E';
  20192. t['\uFD6B'] = '\u0634\u0645\u062E';
  20193. t['\uFD6C'] = '\u0634\u0645\u0645';
  20194. t['\uFD6D'] = '\u0634\u0645\u0645';
  20195. t['\uFD6E'] = '\u0636\u062D\u0649';
  20196. t['\uFD6F'] = '\u0636\u062E\u0645';
  20197. t['\uFD70'] = '\u0636\u062E\u0645';
  20198. t['\uFD71'] = '\u0637\u0645\u062D';
  20199. t['\uFD72'] = '\u0637\u0645\u062D';
  20200. t['\uFD73'] = '\u0637\u0645\u0645';
  20201. t['\uFD74'] = '\u0637\u0645\u064A';
  20202. t['\uFD75'] = '\u0639\u062C\u0645';
  20203. t['\uFD76'] = '\u0639\u0645\u0645';
  20204. t['\uFD77'] = '\u0639\u0645\u0645';
  20205. t['\uFD78'] = '\u0639\u0645\u0649';
  20206. t['\uFD79'] = '\u063A\u0645\u0645';
  20207. t['\uFD7A'] = '\u063A\u0645\u064A';
  20208. t['\uFD7B'] = '\u063A\u0645\u0649';
  20209. t['\uFD7C'] = '\u0641\u062E\u0645';
  20210. t['\uFD7D'] = '\u0641\u062E\u0645';
  20211. t['\uFD7E'] = '\u0642\u0645\u062D';
  20212. t['\uFD7F'] = '\u0642\u0645\u0645';
  20213. t['\uFD80'] = '\u0644\u062D\u0645';
  20214. t['\uFD81'] = '\u0644\u062D\u064A';
  20215. t['\uFD82'] = '\u0644\u062D\u0649';
  20216. t['\uFD83'] = '\u0644\u062C\u062C';
  20217. t['\uFD84'] = '\u0644\u062C\u062C';
  20218. t['\uFD85'] = '\u0644\u062E\u0645';
  20219. t['\uFD86'] = '\u0644\u062E\u0645';
  20220. t['\uFD87'] = '\u0644\u0645\u062D';
  20221. t['\uFD88'] = '\u0644\u0645\u062D';
  20222. t['\uFD89'] = '\u0645\u062D\u062C';
  20223. t['\uFD8A'] = '\u0645\u062D\u0645';
  20224. t['\uFD8B'] = '\u0645\u062D\u064A';
  20225. t['\uFD8C'] = '\u0645\u062C\u062D';
  20226. t['\uFD8D'] = '\u0645\u062C\u0645';
  20227. t['\uFD8E'] = '\u0645\u062E\u062C';
  20228. t['\uFD8F'] = '\u0645\u062E\u0645';
  20229. t['\uFD92'] = '\u0645\u062C\u062E';
  20230. t['\uFD93'] = '\u0647\u0645\u062C';
  20231. t['\uFD94'] = '\u0647\u0645\u0645';
  20232. t['\uFD95'] = '\u0646\u062D\u0645';
  20233. t['\uFD96'] = '\u0646\u062D\u0649';
  20234. t['\uFD97'] = '\u0646\u062C\u0645';
  20235. t['\uFD98'] = '\u0646\u062C\u0645';
  20236. t['\uFD99'] = '\u0646\u062C\u0649';
  20237. t['\uFD9A'] = '\u0646\u0645\u064A';
  20238. t['\uFD9B'] = '\u0646\u0645\u0649';
  20239. t['\uFD9C'] = '\u064A\u0645\u0645';
  20240. t['\uFD9D'] = '\u064A\u0645\u0645';
  20241. t['\uFD9E'] = '\u0628\u062E\u064A';
  20242. t['\uFD9F'] = '\u062A\u062C\u064A';
  20243. t['\uFDA0'] = '\u062A\u062C\u0649';
  20244. t['\uFDA1'] = '\u062A\u062E\u064A';
  20245. t['\uFDA2'] = '\u062A\u062E\u0649';
  20246. t['\uFDA3'] = '\u062A\u0645\u064A';
  20247. t['\uFDA4'] = '\u062A\u0645\u0649';
  20248. t['\uFDA5'] = '\u062C\u0645\u064A';
  20249. t['\uFDA6'] = '\u062C\u062D\u0649';
  20250. t['\uFDA7'] = '\u062C\u0645\u0649';
  20251. t['\uFDA8'] = '\u0633\u062E\u0649';
  20252. t['\uFDA9'] = '\u0635\u062D\u064A';
  20253. t['\uFDAA'] = '\u0634\u062D\u064A';
  20254. t['\uFDAB'] = '\u0636\u062D\u064A';
  20255. t['\uFDAC'] = '\u0644\u062C\u064A';
  20256. t['\uFDAD'] = '\u0644\u0645\u064A';
  20257. t['\uFDAE'] = '\u064A\u062D\u064A';
  20258. t['\uFDAF'] = '\u064A\u062C\u064A';
  20259. t['\uFDB0'] = '\u064A\u0645\u064A';
  20260. t['\uFDB1'] = '\u0645\u0645\u064A';
  20261. t['\uFDB2'] = '\u0642\u0645\u064A';
  20262. t['\uFDB3'] = '\u0646\u062D\u064A';
  20263. t['\uFDB4'] = '\u0642\u0645\u062D';
  20264. t['\uFDB5'] = '\u0644\u062D\u0645';
  20265. t['\uFDB6'] = '\u0639\u0645\u064A';
  20266. t['\uFDB7'] = '\u0643\u0645\u064A';
  20267. t['\uFDB8'] = '\u0646\u062C\u062D';
  20268. t['\uFDB9'] = '\u0645\u062E\u064A';
  20269. t['\uFDBA'] = '\u0644\u062C\u0645';
  20270. t['\uFDBB'] = '\u0643\u0645\u0645';
  20271. t['\uFDBC'] = '\u0644\u062C\u0645';
  20272. t['\uFDBD'] = '\u0646\u062C\u062D';
  20273. t['\uFDBE'] = '\u062C\u062D\u064A';
  20274. t['\uFDBF'] = '\u062D\u062C\u064A';
  20275. t['\uFDC0'] = '\u0645\u062C\u064A';
  20276. t['\uFDC1'] = '\u0641\u0645\u064A';
  20277. t['\uFDC2'] = '\u0628\u062D\u064A';
  20278. t['\uFDC3'] = '\u0643\u0645\u0645';
  20279. t['\uFDC4'] = '\u0639\u062C\u0645';
  20280. t['\uFDC5'] = '\u0635\u0645\u0645';
  20281. t['\uFDC6'] = '\u0633\u062E\u064A';
  20282. t['\uFDC7'] = '\u0646\u062C\u064A';
  20283. t['\uFE49'] = '\u203E';
  20284. t['\uFE4A'] = '\u203E';
  20285. t['\uFE4B'] = '\u203E';
  20286. t['\uFE4C'] = '\u203E';
  20287. t['\uFE4D'] = '_';
  20288. t['\uFE4E'] = '_';
  20289. t['\uFE4F'] = '_';
  20290. t['\uFE80'] = '\u0621';
  20291. t['\uFE81'] = '\u0622';
  20292. t['\uFE82'] = '\u0622';
  20293. t['\uFE83'] = '\u0623';
  20294. t['\uFE84'] = '\u0623';
  20295. t['\uFE85'] = '\u0624';
  20296. t['\uFE86'] = '\u0624';
  20297. t['\uFE87'] = '\u0625';
  20298. t['\uFE88'] = '\u0625';
  20299. t['\uFE89'] = '\u0626';
  20300. t['\uFE8A'] = '\u0626';
  20301. t['\uFE8B'] = '\u0626';
  20302. t['\uFE8C'] = '\u0626';
  20303. t['\uFE8D'] = '\u0627';
  20304. t['\uFE8E'] = '\u0627';
  20305. t['\uFE8F'] = '\u0628';
  20306. t['\uFE90'] = '\u0628';
  20307. t['\uFE91'] = '\u0628';
  20308. t['\uFE92'] = '\u0628';
  20309. t['\uFE93'] = '\u0629';
  20310. t['\uFE94'] = '\u0629';
  20311. t['\uFE95'] = '\u062A';
  20312. t['\uFE96'] = '\u062A';
  20313. t['\uFE97'] = '\u062A';
  20314. t['\uFE98'] = '\u062A';
  20315. t['\uFE99'] = '\u062B';
  20316. t['\uFE9A'] = '\u062B';
  20317. t['\uFE9B'] = '\u062B';
  20318. t['\uFE9C'] = '\u062B';
  20319. t['\uFE9D'] = '\u062C';
  20320. t['\uFE9E'] = '\u062C';
  20321. t['\uFE9F'] = '\u062C';
  20322. t['\uFEA0'] = '\u062C';
  20323. t['\uFEA1'] = '\u062D';
  20324. t['\uFEA2'] = '\u062D';
  20325. t['\uFEA3'] = '\u062D';
  20326. t['\uFEA4'] = '\u062D';
  20327. t['\uFEA5'] = '\u062E';
  20328. t['\uFEA6'] = '\u062E';
  20329. t['\uFEA7'] = '\u062E';
  20330. t['\uFEA8'] = '\u062E';
  20331. t['\uFEA9'] = '\u062F';
  20332. t['\uFEAA'] = '\u062F';
  20333. t['\uFEAB'] = '\u0630';
  20334. t['\uFEAC'] = '\u0630';
  20335. t['\uFEAD'] = '\u0631';
  20336. t['\uFEAE'] = '\u0631';
  20337. t['\uFEAF'] = '\u0632';
  20338. t['\uFEB0'] = '\u0632';
  20339. t['\uFEB1'] = '\u0633';
  20340. t['\uFEB2'] = '\u0633';
  20341. t['\uFEB3'] = '\u0633';
  20342. t['\uFEB4'] = '\u0633';
  20343. t['\uFEB5'] = '\u0634';
  20344. t['\uFEB6'] = '\u0634';
  20345. t['\uFEB7'] = '\u0634';
  20346. t['\uFEB8'] = '\u0634';
  20347. t['\uFEB9'] = '\u0635';
  20348. t['\uFEBA'] = '\u0635';
  20349. t['\uFEBB'] = '\u0635';
  20350. t['\uFEBC'] = '\u0635';
  20351. t['\uFEBD'] = '\u0636';
  20352. t['\uFEBE'] = '\u0636';
  20353. t['\uFEBF'] = '\u0636';
  20354. t['\uFEC0'] = '\u0636';
  20355. t['\uFEC1'] = '\u0637';
  20356. t['\uFEC2'] = '\u0637';
  20357. t['\uFEC3'] = '\u0637';
  20358. t['\uFEC4'] = '\u0637';
  20359. t['\uFEC5'] = '\u0638';
  20360. t['\uFEC6'] = '\u0638';
  20361. t['\uFEC7'] = '\u0638';
  20362. t['\uFEC8'] = '\u0638';
  20363. t['\uFEC9'] = '\u0639';
  20364. t['\uFECA'] = '\u0639';
  20365. t['\uFECB'] = '\u0639';
  20366. t['\uFECC'] = '\u0639';
  20367. t['\uFECD'] = '\u063A';
  20368. t['\uFECE'] = '\u063A';
  20369. t['\uFECF'] = '\u063A';
  20370. t['\uFED0'] = '\u063A';
  20371. t['\uFED1'] = '\u0641';
  20372. t['\uFED2'] = '\u0641';
  20373. t['\uFED3'] = '\u0641';
  20374. t['\uFED4'] = '\u0641';
  20375. t['\uFED5'] = '\u0642';
  20376. t['\uFED6'] = '\u0642';
  20377. t['\uFED7'] = '\u0642';
  20378. t['\uFED8'] = '\u0642';
  20379. t['\uFED9'] = '\u0643';
  20380. t['\uFEDA'] = '\u0643';
  20381. t['\uFEDB'] = '\u0643';
  20382. t['\uFEDC'] = '\u0643';
  20383. t['\uFEDD'] = '\u0644';
  20384. t['\uFEDE'] = '\u0644';
  20385. t['\uFEDF'] = '\u0644';
  20386. t['\uFEE0'] = '\u0644';
  20387. t['\uFEE1'] = '\u0645';
  20388. t['\uFEE2'] = '\u0645';
  20389. t['\uFEE3'] = '\u0645';
  20390. t['\uFEE4'] = '\u0645';
  20391. t['\uFEE5'] = '\u0646';
  20392. t['\uFEE6'] = '\u0646';
  20393. t['\uFEE7'] = '\u0646';
  20394. t['\uFEE8'] = '\u0646';
  20395. t['\uFEE9'] = '\u0647';
  20396. t['\uFEEA'] = '\u0647';
  20397. t['\uFEEB'] = '\u0647';
  20398. t['\uFEEC'] = '\u0647';
  20399. t['\uFEED'] = '\u0648';
  20400. t['\uFEEE'] = '\u0648';
  20401. t['\uFEEF'] = '\u0649';
  20402. t['\uFEF0'] = '\u0649';
  20403. t['\uFEF1'] = '\u064A';
  20404. t['\uFEF2'] = '\u064A';
  20405. t['\uFEF3'] = '\u064A';
  20406. t['\uFEF4'] = '\u064A';
  20407. t['\uFEF5'] = '\u0644\u0622';
  20408. t['\uFEF6'] = '\u0644\u0622';
  20409. t['\uFEF7'] = '\u0644\u0623';
  20410. t['\uFEF8'] = '\u0644\u0623';
  20411. t['\uFEF9'] = '\u0644\u0625';
  20412. t['\uFEFA'] = '\u0644\u0625';
  20413. t['\uFEFB'] = '\u0644\u0627';
  20414. t['\uFEFC'] = '\u0644\u0627';
  20415. });
  20416. function reverseIfRtl(chars) {
  20417. var charsLength = chars.length;
  20418. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  20419. return chars;
  20420. }
  20421. var s = '';
  20422. for (var ii = charsLength - 1; ii >= 0; ii--) {
  20423. s += chars[ii];
  20424. }
  20425. return s;
  20426. }
  20427. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  20428. exports.reverseIfRtl = reverseIfRtl;
  20429. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  20430. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  20431. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  20432. /***/ }),
  20433. /* 69 */
  20434. /***/ (function(module, exports, __w_pdfjs_require__) {
  20435. "use strict";
  20436. Object.defineProperty(exports, "__esModule", {
  20437. value: true
  20438. });
  20439. exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = exports.isPDFFunction = undefined;
  20440. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  20441. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  20442. var _util = __w_pdfjs_require__(0);
  20443. var _primitives = __w_pdfjs_require__(1);
  20444. var _ps_parser = __w_pdfjs_require__(139);
  20445. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20446. var IsEvalSupportedCached = {
  20447. get value() {
  20448. return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)());
  20449. }
  20450. };
  20451. var PDFFunctionFactory = function () {
  20452. function PDFFunctionFactory(_ref) {
  20453. var xref = _ref.xref,
  20454. _ref$isEvalSupported = _ref.isEvalSupported,
  20455. isEvalSupported = _ref$isEvalSupported === undefined ? true : _ref$isEvalSupported;
  20456. _classCallCheck(this, PDFFunctionFactory);
  20457. this.xref = xref;
  20458. this.isEvalSupported = isEvalSupported !== false;
  20459. }
  20460. _createClass(PDFFunctionFactory, [{
  20461. key: 'create',
  20462. value: function create(fn) {
  20463. return PDFFunction.parse({
  20464. xref: this.xref,
  20465. isEvalSupported: this.isEvalSupported,
  20466. fn: fn
  20467. });
  20468. }
  20469. }, {
  20470. key: 'createFromArray',
  20471. value: function createFromArray(fnObj) {
  20472. return PDFFunction.parseArray({
  20473. xref: this.xref,
  20474. isEvalSupported: this.isEvalSupported,
  20475. fnObj: fnObj
  20476. });
  20477. }
  20478. }, {
  20479. key: 'createFromIR',
  20480. value: function createFromIR(IR) {
  20481. return PDFFunction.fromIR({
  20482. xref: this.xref,
  20483. isEvalSupported: this.isEvalSupported,
  20484. IR: IR
  20485. });
  20486. }
  20487. }, {
  20488. key: 'createIR',
  20489. value: function createIR(fn) {
  20490. return PDFFunction.getIR({
  20491. xref: this.xref,
  20492. isEvalSupported: this.isEvalSupported,
  20493. fn: fn
  20494. });
  20495. }
  20496. }]);
  20497. return PDFFunctionFactory;
  20498. }();
  20499. var PDFFunction = function PDFFunctionClosure() {
  20500. var CONSTRUCT_SAMPLED = 0;
  20501. var CONSTRUCT_INTERPOLATED = 2;
  20502. var CONSTRUCT_STICHED = 3;
  20503. var CONSTRUCT_POSTSCRIPT = 4;
  20504. return {
  20505. getSampleArray: function getSampleArray(size, outputSize, bps, stream) {
  20506. var i, ii;
  20507. var length = 1;
  20508. for (i = 0, ii = size.length; i < ii; i++) {
  20509. length *= size[i];
  20510. }
  20511. length *= outputSize;
  20512. var array = new Array(length);
  20513. var codeSize = 0;
  20514. var codeBuf = 0;
  20515. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  20516. var strBytes = stream.getBytes((length * bps + 7) / 8);
  20517. var strIdx = 0;
  20518. for (i = 0; i < length; i++) {
  20519. while (codeSize < bps) {
  20520. codeBuf <<= 8;
  20521. codeBuf |= strBytes[strIdx++];
  20522. codeSize += 8;
  20523. }
  20524. codeSize -= bps;
  20525. array[i] = (codeBuf >> codeSize) * sampleMul;
  20526. codeBuf &= (1 << codeSize) - 1;
  20527. }
  20528. return array;
  20529. },
  20530. getIR: function getIR(_ref2) {
  20531. var xref = _ref2.xref,
  20532. isEvalSupported = _ref2.isEvalSupported,
  20533. fn = _ref2.fn;
  20534. var dict = fn.dict;
  20535. if (!dict) {
  20536. dict = fn;
  20537. }
  20538. var types = [this.constructSampled, null, this.constructInterpolated, this.constructStiched, this.constructPostScript];
  20539. var typeNum = dict.get('FunctionType');
  20540. var typeFn = types[typeNum];
  20541. if (!typeFn) {
  20542. throw new _util.FormatError('Unknown type of function');
  20543. }
  20544. return typeFn.call(this, {
  20545. xref: xref,
  20546. isEvalSupported: isEvalSupported,
  20547. fn: fn,
  20548. dict: dict
  20549. });
  20550. },
  20551. fromIR: function fromIR(_ref3) {
  20552. var xref = _ref3.xref,
  20553. isEvalSupported = _ref3.isEvalSupported,
  20554. IR = _ref3.IR;
  20555. var type = IR[0];
  20556. switch (type) {
  20557. case CONSTRUCT_SAMPLED:
  20558. return this.constructSampledFromIR({
  20559. xref: xref,
  20560. isEvalSupported: isEvalSupported,
  20561. IR: IR
  20562. });
  20563. case CONSTRUCT_INTERPOLATED:
  20564. return this.constructInterpolatedFromIR({
  20565. xref: xref,
  20566. isEvalSupported: isEvalSupported,
  20567. IR: IR
  20568. });
  20569. case CONSTRUCT_STICHED:
  20570. return this.constructStichedFromIR({
  20571. xref: xref,
  20572. isEvalSupported: isEvalSupported,
  20573. IR: IR
  20574. });
  20575. default:
  20576. return this.constructPostScriptFromIR({
  20577. xref: xref,
  20578. isEvalSupported: isEvalSupported,
  20579. IR: IR
  20580. });
  20581. }
  20582. },
  20583. parse: function parse(_ref4) {
  20584. var xref = _ref4.xref,
  20585. isEvalSupported = _ref4.isEvalSupported,
  20586. fn = _ref4.fn;
  20587. var IR = this.getIR({
  20588. xref: xref,
  20589. isEvalSupported: isEvalSupported,
  20590. fn: fn
  20591. });
  20592. return this.fromIR({
  20593. xref: xref,
  20594. isEvalSupported: isEvalSupported,
  20595. IR: IR
  20596. });
  20597. },
  20598. parseArray: function parseArray(_ref5) {
  20599. var xref = _ref5.xref,
  20600. isEvalSupported = _ref5.isEvalSupported,
  20601. fnObj = _ref5.fnObj;
  20602. if (!Array.isArray(fnObj)) {
  20603. return this.parse({
  20604. xref: xref,
  20605. isEvalSupported: isEvalSupported,
  20606. fn: fnObj
  20607. });
  20608. }
  20609. var fnArray = [];
  20610. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  20611. fnArray.push(this.parse({
  20612. xref: xref,
  20613. isEvalSupported: isEvalSupported,
  20614. fn: xref.fetchIfRef(fnObj[j])
  20615. }));
  20616. }
  20617. return function (src, srcOffset, dest, destOffset) {
  20618. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  20619. fnArray[i](src, srcOffset, dest, destOffset + i);
  20620. }
  20621. };
  20622. },
  20623. constructSampled: function constructSampled(_ref6) {
  20624. var xref = _ref6.xref,
  20625. isEvalSupported = _ref6.isEvalSupported,
  20626. fn = _ref6.fn,
  20627. dict = _ref6.dict;
  20628. function toMultiArray(arr) {
  20629. var inputLength = arr.length;
  20630. var out = [];
  20631. var index = 0;
  20632. for (var i = 0; i < inputLength; i += 2) {
  20633. out[index] = [arr[i], arr[i + 1]];
  20634. ++index;
  20635. }
  20636. return out;
  20637. }
  20638. var domain = dict.getArray('Domain');
  20639. var range = dict.getArray('Range');
  20640. if (!domain || !range) {
  20641. throw new _util.FormatError('No domain or range');
  20642. }
  20643. var inputSize = domain.length / 2;
  20644. var outputSize = range.length / 2;
  20645. domain = toMultiArray(domain);
  20646. range = toMultiArray(range);
  20647. var size = dict.get('Size');
  20648. var bps = dict.get('BitsPerSample');
  20649. var order = dict.get('Order') || 1;
  20650. if (order !== 1) {
  20651. (0, _util.info)('No support for cubic spline interpolation: ' + order);
  20652. }
  20653. var encode = dict.getArray('Encode');
  20654. if (!encode) {
  20655. encode = [];
  20656. for (var i = 0; i < inputSize; ++i) {
  20657. encode.push(0);
  20658. encode.push(size[i] - 1);
  20659. }
  20660. }
  20661. encode = toMultiArray(encode);
  20662. var decode = dict.getArray('Decode');
  20663. if (!decode) {
  20664. decode = range;
  20665. } else {
  20666. decode = toMultiArray(decode);
  20667. }
  20668. var samples = this.getSampleArray(size, outputSize, bps, fn);
  20669. return [CONSTRUCT_SAMPLED, inputSize, domain, encode, decode, samples, size, outputSize, Math.pow(2, bps) - 1, range];
  20670. },
  20671. constructSampledFromIR: function constructSampledFromIR(_ref7) {
  20672. var xref = _ref7.xref,
  20673. isEvalSupported = _ref7.isEvalSupported,
  20674. IR = _ref7.IR;
  20675. function interpolate(x, xmin, xmax, ymin, ymax) {
  20676. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  20677. }
  20678. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  20679. var m = IR[1];
  20680. var domain = IR[2];
  20681. var encode = IR[3];
  20682. var decode = IR[4];
  20683. var samples = IR[5];
  20684. var size = IR[6];
  20685. var n = IR[7];
  20686. var range = IR[9];
  20687. var cubeVertices = 1 << m;
  20688. var cubeN = new Float64Array(cubeVertices);
  20689. var cubeVertex = new Uint32Array(cubeVertices);
  20690. var i, j;
  20691. for (j = 0; j < cubeVertices; j++) {
  20692. cubeN[j] = 1;
  20693. }
  20694. var k = n,
  20695. pos = 1;
  20696. for (i = 0; i < m; ++i) {
  20697. var domain_2i = domain[i][0];
  20698. var domain_2i_1 = domain[i][1];
  20699. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  20700. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  20701. var size_i = size[i];
  20702. e = Math.min(Math.max(e, 0), size_i - 1);
  20703. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  20704. var n0 = e0 + 1 - e;
  20705. var n1 = e - e0;
  20706. var offset0 = e0 * k;
  20707. var offset1 = offset0 + k;
  20708. for (j = 0; j < cubeVertices; j++) {
  20709. if (j & pos) {
  20710. cubeN[j] *= n1;
  20711. cubeVertex[j] += offset1;
  20712. } else {
  20713. cubeN[j] *= n0;
  20714. cubeVertex[j] += offset0;
  20715. }
  20716. }
  20717. k *= size_i;
  20718. pos <<= 1;
  20719. }
  20720. for (j = 0; j < n; ++j) {
  20721. var rj = 0;
  20722. for (i = 0; i < cubeVertices; i++) {
  20723. rj += samples[cubeVertex[i] + j] * cubeN[i];
  20724. }
  20725. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  20726. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  20727. }
  20728. };
  20729. },
  20730. constructInterpolated: function constructInterpolated(_ref8) {
  20731. var xref = _ref8.xref,
  20732. isEvalSupported = _ref8.isEvalSupported,
  20733. fn = _ref8.fn,
  20734. dict = _ref8.dict;
  20735. var c0 = dict.getArray('C0') || [0];
  20736. var c1 = dict.getArray('C1') || [1];
  20737. var n = dict.get('N');
  20738. if (!Array.isArray(c0) || !Array.isArray(c1)) {
  20739. throw new _util.FormatError('Illegal dictionary for interpolated function');
  20740. }
  20741. var length = c0.length;
  20742. var diff = [];
  20743. for (var i = 0; i < length; ++i) {
  20744. diff.push(c1[i] - c0[i]);
  20745. }
  20746. return [CONSTRUCT_INTERPOLATED, c0, diff, n];
  20747. },
  20748. constructInterpolatedFromIR: function constructInterpolatedFromIR(_ref9) {
  20749. var xref = _ref9.xref,
  20750. isEvalSupported = _ref9.isEvalSupported,
  20751. IR = _ref9.IR;
  20752. var c0 = IR[1];
  20753. var diff = IR[2];
  20754. var n = IR[3];
  20755. var length = diff.length;
  20756. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  20757. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  20758. for (var j = 0; j < length; ++j) {
  20759. dest[destOffset + j] = c0[j] + x * diff[j];
  20760. }
  20761. };
  20762. },
  20763. constructStiched: function constructStiched(_ref10) {
  20764. var xref = _ref10.xref,
  20765. isEvalSupported = _ref10.isEvalSupported,
  20766. fn = _ref10.fn,
  20767. dict = _ref10.dict;
  20768. var domain = dict.getArray('Domain');
  20769. if (!domain) {
  20770. throw new _util.FormatError('No domain');
  20771. }
  20772. var inputSize = domain.length / 2;
  20773. if (inputSize !== 1) {
  20774. throw new _util.FormatError('Bad domain for stiched function');
  20775. }
  20776. var fnRefs = dict.get('Functions');
  20777. var fns = [];
  20778. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  20779. fns.push(this.getIR({
  20780. xref: xref,
  20781. isEvalSupported: isEvalSupported,
  20782. fn: xref.fetchIfRef(fnRefs[i])
  20783. }));
  20784. }
  20785. var bounds = dict.getArray('Bounds');
  20786. var encode = dict.getArray('Encode');
  20787. return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
  20788. },
  20789. constructStichedFromIR: function constructStichedFromIR(_ref11) {
  20790. var xref = _ref11.xref,
  20791. isEvalSupported = _ref11.isEvalSupported,
  20792. IR = _ref11.IR;
  20793. var domain = IR[1];
  20794. var bounds = IR[2];
  20795. var encode = IR[3];
  20796. var fnsIR = IR[4];
  20797. var fns = [];
  20798. var tmpBuf = new Float32Array(1);
  20799. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  20800. fns.push(this.fromIR({
  20801. xref: xref,
  20802. isEvalSupported: isEvalSupported,
  20803. IR: fnsIR[i]
  20804. }));
  20805. }
  20806. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  20807. var clip = function constructStichedFromIRClip(v, min, max) {
  20808. if (v > max) {
  20809. v = max;
  20810. } else if (v < min) {
  20811. v = min;
  20812. }
  20813. return v;
  20814. };
  20815. var v = clip(src[srcOffset], domain[0], domain[1]);
  20816. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  20817. if (v < bounds[i]) {
  20818. break;
  20819. }
  20820. }
  20821. var dmin = domain[0];
  20822. if (i > 0) {
  20823. dmin = bounds[i - 1];
  20824. }
  20825. var dmax = domain[1];
  20826. if (i < bounds.length) {
  20827. dmax = bounds[i];
  20828. }
  20829. var rmin = encode[2 * i];
  20830. var rmax = encode[2 * i + 1];
  20831. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  20832. fns[i](tmpBuf, 0, dest, destOffset);
  20833. };
  20834. },
  20835. constructPostScript: function constructPostScript(_ref12) {
  20836. var xref = _ref12.xref,
  20837. isEvalSupported = _ref12.isEvalSupported,
  20838. fn = _ref12.fn,
  20839. dict = _ref12.dict;
  20840. var domain = dict.getArray('Domain');
  20841. var range = dict.getArray('Range');
  20842. if (!domain) {
  20843. throw new _util.FormatError('No domain.');
  20844. }
  20845. if (!range) {
  20846. throw new _util.FormatError('No range.');
  20847. }
  20848. var lexer = new _ps_parser.PostScriptLexer(fn);
  20849. var parser = new _ps_parser.PostScriptParser(lexer);
  20850. var code = parser.parse();
  20851. return [CONSTRUCT_POSTSCRIPT, domain, range, code];
  20852. },
  20853. constructPostScriptFromIR: function constructPostScriptFromIR(_ref13) {
  20854. var xref = _ref13.xref,
  20855. isEvalSupported = _ref13.isEvalSupported,
  20856. IR = _ref13.IR;
  20857. var domain = IR[1];
  20858. var range = IR[2];
  20859. var code = IR[3];
  20860. if (isEvalSupported && IsEvalSupportedCached.value) {
  20861. var compiled = new PostScriptCompiler().compile(code, domain, range);
  20862. if (compiled) {
  20863. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  20864. }
  20865. }
  20866. (0, _util.info)('Unable to compile PS function');
  20867. var numOutputs = range.length >> 1;
  20868. var numInputs = domain.length >> 1;
  20869. var evaluator = new PostScriptEvaluator(code);
  20870. var cache = Object.create(null);
  20871. var MAX_CACHE_SIZE = 2048 * 4;
  20872. var cache_available = MAX_CACHE_SIZE;
  20873. var tmpBuf = new Float32Array(numInputs);
  20874. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  20875. var i, value;
  20876. var key = '';
  20877. var input = tmpBuf;
  20878. for (i = 0; i < numInputs; i++) {
  20879. value = src[srcOffset + i];
  20880. input[i] = value;
  20881. key += value + '_';
  20882. }
  20883. var cachedValue = cache[key];
  20884. if (cachedValue !== undefined) {
  20885. dest.set(cachedValue, destOffset);
  20886. return;
  20887. }
  20888. var output = new Float32Array(numOutputs);
  20889. var stack = evaluator.execute(input);
  20890. var stackIndex = stack.length - numOutputs;
  20891. for (i = 0; i < numOutputs; i++) {
  20892. value = stack[stackIndex + i];
  20893. var bound = range[i * 2];
  20894. if (value < bound) {
  20895. value = bound;
  20896. } else {
  20897. bound = range[i * 2 + 1];
  20898. if (value > bound) {
  20899. value = bound;
  20900. }
  20901. }
  20902. output[i] = value;
  20903. }
  20904. if (cache_available > 0) {
  20905. cache_available--;
  20906. cache[key] = output;
  20907. }
  20908. dest.set(output, destOffset);
  20909. };
  20910. }
  20911. };
  20912. }();
  20913. function isPDFFunction(v) {
  20914. var fnDict;
  20915. if ((typeof v === 'undefined' ? 'undefined' : _typeof(v)) !== 'object') {
  20916. return false;
  20917. } else if ((0, _primitives.isDict)(v)) {
  20918. fnDict = v;
  20919. } else if ((0, _primitives.isStream)(v)) {
  20920. fnDict = v.dict;
  20921. } else {
  20922. return false;
  20923. }
  20924. return fnDict.has('FunctionType');
  20925. }
  20926. var PostScriptStack = function PostScriptStackClosure() {
  20927. var MAX_STACK_SIZE = 100;
  20928. function PostScriptStack(initialStack) {
  20929. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  20930. }
  20931. PostScriptStack.prototype = {
  20932. push: function PostScriptStack_push(value) {
  20933. if (this.stack.length >= MAX_STACK_SIZE) {
  20934. throw new Error('PostScript function stack overflow.');
  20935. }
  20936. this.stack.push(value);
  20937. },
  20938. pop: function PostScriptStack_pop() {
  20939. if (this.stack.length <= 0) {
  20940. throw new Error('PostScript function stack underflow.');
  20941. }
  20942. return this.stack.pop();
  20943. },
  20944. copy: function PostScriptStack_copy(n) {
  20945. if (this.stack.length + n >= MAX_STACK_SIZE) {
  20946. throw new Error('PostScript function stack overflow.');
  20947. }
  20948. var stack = this.stack;
  20949. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  20950. stack.push(stack[i]);
  20951. }
  20952. },
  20953. index: function PostScriptStack_index(n) {
  20954. this.push(this.stack[this.stack.length - n - 1]);
  20955. },
  20956. roll: function PostScriptStack_roll(n, p) {
  20957. var stack = this.stack;
  20958. var l = stack.length - n;
  20959. var r = stack.length - 1,
  20960. c = l + (p - Math.floor(p / n) * n),
  20961. i,
  20962. j,
  20963. t;
  20964. for (i = l, j = r; i < j; i++, j--) {
  20965. t = stack[i];
  20966. stack[i] = stack[j];
  20967. stack[j] = t;
  20968. }
  20969. for (i = l, j = c - 1; i < j; i++, j--) {
  20970. t = stack[i];
  20971. stack[i] = stack[j];
  20972. stack[j] = t;
  20973. }
  20974. for (i = c, j = r; i < j; i++, j--) {
  20975. t = stack[i];
  20976. stack[i] = stack[j];
  20977. stack[j] = t;
  20978. }
  20979. }
  20980. };
  20981. return PostScriptStack;
  20982. }();
  20983. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  20984. function PostScriptEvaluator(operators) {
  20985. this.operators = operators;
  20986. }
  20987. PostScriptEvaluator.prototype = {
  20988. execute: function PostScriptEvaluator_execute(initialStack) {
  20989. var stack = new PostScriptStack(initialStack);
  20990. var counter = 0;
  20991. var operators = this.operators;
  20992. var length = operators.length;
  20993. var operator, a, b;
  20994. while (counter < length) {
  20995. operator = operators[counter++];
  20996. if (typeof operator === 'number') {
  20997. stack.push(operator);
  20998. continue;
  20999. }
  21000. switch (operator) {
  21001. case 'jz':
  21002. b = stack.pop();
  21003. a = stack.pop();
  21004. if (!a) {
  21005. counter = b;
  21006. }
  21007. break;
  21008. case 'j':
  21009. a = stack.pop();
  21010. counter = a;
  21011. break;
  21012. case 'abs':
  21013. a = stack.pop();
  21014. stack.push(Math.abs(a));
  21015. break;
  21016. case 'add':
  21017. b = stack.pop();
  21018. a = stack.pop();
  21019. stack.push(a + b);
  21020. break;
  21021. case 'and':
  21022. b = stack.pop();
  21023. a = stack.pop();
  21024. if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
  21025. stack.push(a && b);
  21026. } else {
  21027. stack.push(a & b);
  21028. }
  21029. break;
  21030. case 'atan':
  21031. a = stack.pop();
  21032. stack.push(Math.atan(a));
  21033. break;
  21034. case 'bitshift':
  21035. b = stack.pop();
  21036. a = stack.pop();
  21037. if (a > 0) {
  21038. stack.push(a << b);
  21039. } else {
  21040. stack.push(a >> b);
  21041. }
  21042. break;
  21043. case 'ceiling':
  21044. a = stack.pop();
  21045. stack.push(Math.ceil(a));
  21046. break;
  21047. case 'copy':
  21048. a = stack.pop();
  21049. stack.copy(a);
  21050. break;
  21051. case 'cos':
  21052. a = stack.pop();
  21053. stack.push(Math.cos(a));
  21054. break;
  21055. case 'cvi':
  21056. a = stack.pop() | 0;
  21057. stack.push(a);
  21058. break;
  21059. case 'cvr':
  21060. break;
  21061. case 'div':
  21062. b = stack.pop();
  21063. a = stack.pop();
  21064. stack.push(a / b);
  21065. break;
  21066. case 'dup':
  21067. stack.copy(1);
  21068. break;
  21069. case 'eq':
  21070. b = stack.pop();
  21071. a = stack.pop();
  21072. stack.push(a === b);
  21073. break;
  21074. case 'exch':
  21075. stack.roll(2, 1);
  21076. break;
  21077. case 'exp':
  21078. b = stack.pop();
  21079. a = stack.pop();
  21080. stack.push(Math.pow(a, b));
  21081. break;
  21082. case 'false':
  21083. stack.push(false);
  21084. break;
  21085. case 'floor':
  21086. a = stack.pop();
  21087. stack.push(Math.floor(a));
  21088. break;
  21089. case 'ge':
  21090. b = stack.pop();
  21091. a = stack.pop();
  21092. stack.push(a >= b);
  21093. break;
  21094. case 'gt':
  21095. b = stack.pop();
  21096. a = stack.pop();
  21097. stack.push(a > b);
  21098. break;
  21099. case 'idiv':
  21100. b = stack.pop();
  21101. a = stack.pop();
  21102. stack.push(a / b | 0);
  21103. break;
  21104. case 'index':
  21105. a = stack.pop();
  21106. stack.index(a);
  21107. break;
  21108. case 'le':
  21109. b = stack.pop();
  21110. a = stack.pop();
  21111. stack.push(a <= b);
  21112. break;
  21113. case 'ln':
  21114. a = stack.pop();
  21115. stack.push(Math.log(a));
  21116. break;
  21117. case 'log':
  21118. a = stack.pop();
  21119. stack.push(Math.log(a) / Math.LN10);
  21120. break;
  21121. case 'lt':
  21122. b = stack.pop();
  21123. a = stack.pop();
  21124. stack.push(a < b);
  21125. break;
  21126. case 'mod':
  21127. b = stack.pop();
  21128. a = stack.pop();
  21129. stack.push(a % b);
  21130. break;
  21131. case 'mul':
  21132. b = stack.pop();
  21133. a = stack.pop();
  21134. stack.push(a * b);
  21135. break;
  21136. case 'ne':
  21137. b = stack.pop();
  21138. a = stack.pop();
  21139. stack.push(a !== b);
  21140. break;
  21141. case 'neg':
  21142. a = stack.pop();
  21143. stack.push(-a);
  21144. break;
  21145. case 'not':
  21146. a = stack.pop();
  21147. if ((0, _util.isBool)(a)) {
  21148. stack.push(!a);
  21149. } else {
  21150. stack.push(~a);
  21151. }
  21152. break;
  21153. case 'or':
  21154. b = stack.pop();
  21155. a = stack.pop();
  21156. if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
  21157. stack.push(a || b);
  21158. } else {
  21159. stack.push(a | b);
  21160. }
  21161. break;
  21162. case 'pop':
  21163. stack.pop();
  21164. break;
  21165. case 'roll':
  21166. b = stack.pop();
  21167. a = stack.pop();
  21168. stack.roll(a, b);
  21169. break;
  21170. case 'round':
  21171. a = stack.pop();
  21172. stack.push(Math.round(a));
  21173. break;
  21174. case 'sin':
  21175. a = stack.pop();
  21176. stack.push(Math.sin(a));
  21177. break;
  21178. case 'sqrt':
  21179. a = stack.pop();
  21180. stack.push(Math.sqrt(a));
  21181. break;
  21182. case 'sub':
  21183. b = stack.pop();
  21184. a = stack.pop();
  21185. stack.push(a - b);
  21186. break;
  21187. case 'true':
  21188. stack.push(true);
  21189. break;
  21190. case 'truncate':
  21191. a = stack.pop();
  21192. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  21193. stack.push(a);
  21194. break;
  21195. case 'xor':
  21196. b = stack.pop();
  21197. a = stack.pop();
  21198. if ((0, _util.isBool)(a) && (0, _util.isBool)(b)) {
  21199. stack.push(a !== b);
  21200. } else {
  21201. stack.push(a ^ b);
  21202. }
  21203. break;
  21204. default:
  21205. throw new _util.FormatError('Unknown operator ' + operator);
  21206. }
  21207. }
  21208. return stack.stack;
  21209. }
  21210. };
  21211. return PostScriptEvaluator;
  21212. }();
  21213. var PostScriptCompiler = function PostScriptCompilerClosure() {
  21214. function AstNode(type) {
  21215. this.type = type;
  21216. }
  21217. AstNode.prototype.visit = function (visitor) {
  21218. throw new Error('abstract method');
  21219. };
  21220. function AstArgument(index, min, max) {
  21221. AstNode.call(this, 'args');
  21222. this.index = index;
  21223. this.min = min;
  21224. this.max = max;
  21225. }
  21226. AstArgument.prototype = Object.create(AstNode.prototype);
  21227. AstArgument.prototype.visit = function (visitor) {
  21228. visitor.visitArgument(this);
  21229. };
  21230. function AstLiteral(number) {
  21231. AstNode.call(this, 'literal');
  21232. this.number = number;
  21233. this.min = number;
  21234. this.max = number;
  21235. }
  21236. AstLiteral.prototype = Object.create(AstNode.prototype);
  21237. AstLiteral.prototype.visit = function (visitor) {
  21238. visitor.visitLiteral(this);
  21239. };
  21240. function AstBinaryOperation(op, arg1, arg2, min, max) {
  21241. AstNode.call(this, 'binary');
  21242. this.op = op;
  21243. this.arg1 = arg1;
  21244. this.arg2 = arg2;
  21245. this.min = min;
  21246. this.max = max;
  21247. }
  21248. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  21249. AstBinaryOperation.prototype.visit = function (visitor) {
  21250. visitor.visitBinaryOperation(this);
  21251. };
  21252. function AstMin(arg, max) {
  21253. AstNode.call(this, 'max');
  21254. this.arg = arg;
  21255. this.min = arg.min;
  21256. this.max = max;
  21257. }
  21258. AstMin.prototype = Object.create(AstNode.prototype);
  21259. AstMin.prototype.visit = function (visitor) {
  21260. visitor.visitMin(this);
  21261. };
  21262. function AstVariable(index, min, max) {
  21263. AstNode.call(this, 'var');
  21264. this.index = index;
  21265. this.min = min;
  21266. this.max = max;
  21267. }
  21268. AstVariable.prototype = Object.create(AstNode.prototype);
  21269. AstVariable.prototype.visit = function (visitor) {
  21270. visitor.visitVariable(this);
  21271. };
  21272. function AstVariableDefinition(variable, arg) {
  21273. AstNode.call(this, 'definition');
  21274. this.variable = variable;
  21275. this.arg = arg;
  21276. }
  21277. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  21278. AstVariableDefinition.prototype.visit = function (visitor) {
  21279. visitor.visitVariableDefinition(this);
  21280. };
  21281. function ExpressionBuilderVisitor() {
  21282. this.parts = [];
  21283. }
  21284. ExpressionBuilderVisitor.prototype = {
  21285. visitArgument: function visitArgument(arg) {
  21286. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  21287. },
  21288. visitVariable: function visitVariable(variable) {
  21289. this.parts.push('v', variable.index);
  21290. },
  21291. visitLiteral: function visitLiteral(literal) {
  21292. this.parts.push(literal.number);
  21293. },
  21294. visitBinaryOperation: function visitBinaryOperation(operation) {
  21295. this.parts.push('(');
  21296. operation.arg1.visit(this);
  21297. this.parts.push(' ', operation.op, ' ');
  21298. operation.arg2.visit(this);
  21299. this.parts.push(')');
  21300. },
  21301. visitVariableDefinition: function visitVariableDefinition(definition) {
  21302. this.parts.push('var ');
  21303. definition.variable.visit(this);
  21304. this.parts.push(' = ');
  21305. definition.arg.visit(this);
  21306. this.parts.push(';');
  21307. },
  21308. visitMin: function visitMin(max) {
  21309. this.parts.push('Math.min(');
  21310. max.arg.visit(this);
  21311. this.parts.push(', ', max.max, ')');
  21312. },
  21313. toString: function toString() {
  21314. return this.parts.join('');
  21315. }
  21316. };
  21317. function buildAddOperation(num1, num2) {
  21318. if (num2.type === 'literal' && num2.number === 0) {
  21319. return num1;
  21320. }
  21321. if (num1.type === 'literal' && num1.number === 0) {
  21322. return num2;
  21323. }
  21324. if (num2.type === 'literal' && num1.type === 'literal') {
  21325. return new AstLiteral(num1.number + num2.number);
  21326. }
  21327. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  21328. }
  21329. function buildMulOperation(num1, num2) {
  21330. if (num2.type === 'literal') {
  21331. if (num2.number === 0) {
  21332. return new AstLiteral(0);
  21333. } else if (num2.number === 1) {
  21334. return num1;
  21335. } else if (num1.type === 'literal') {
  21336. return new AstLiteral(num1.number * num2.number);
  21337. }
  21338. }
  21339. if (num1.type === 'literal') {
  21340. if (num1.number === 0) {
  21341. return new AstLiteral(0);
  21342. } else if (num1.number === 1) {
  21343. return num2;
  21344. }
  21345. }
  21346. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  21347. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  21348. return new AstBinaryOperation('*', num1, num2, min, max);
  21349. }
  21350. function buildSubOperation(num1, num2) {
  21351. if (num2.type === 'literal') {
  21352. if (num2.number === 0) {
  21353. return num1;
  21354. } else if (num1.type === 'literal') {
  21355. return new AstLiteral(num1.number - num2.number);
  21356. }
  21357. }
  21358. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  21359. return num2.arg2;
  21360. }
  21361. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  21362. }
  21363. function buildMinOperation(num1, max) {
  21364. if (num1.min >= max) {
  21365. return new AstLiteral(max);
  21366. } else if (num1.max <= max) {
  21367. return num1;
  21368. }
  21369. return new AstMin(num1, max);
  21370. }
  21371. function PostScriptCompiler() {}
  21372. PostScriptCompiler.prototype = {
  21373. compile: function PostScriptCompiler_compile(code, domain, range) {
  21374. var stack = [];
  21375. var i, ii;
  21376. var instructions = [];
  21377. var inputSize = domain.length >> 1,
  21378. outputSize = range.length >> 1;
  21379. var lastRegister = 0;
  21380. var n, j;
  21381. var num1, num2, ast1, ast2, tmpVar, item;
  21382. for (i = 0; i < inputSize; i++) {
  21383. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  21384. }
  21385. for (i = 0, ii = code.length; i < ii; i++) {
  21386. item = code[i];
  21387. if (typeof item === 'number') {
  21388. stack.push(new AstLiteral(item));
  21389. continue;
  21390. }
  21391. switch (item) {
  21392. case 'add':
  21393. if (stack.length < 2) {
  21394. return null;
  21395. }
  21396. num2 = stack.pop();
  21397. num1 = stack.pop();
  21398. stack.push(buildAddOperation(num1, num2));
  21399. break;
  21400. case 'cvr':
  21401. if (stack.length < 1) {
  21402. return null;
  21403. }
  21404. break;
  21405. case 'mul':
  21406. if (stack.length < 2) {
  21407. return null;
  21408. }
  21409. num2 = stack.pop();
  21410. num1 = stack.pop();
  21411. stack.push(buildMulOperation(num1, num2));
  21412. break;
  21413. case 'sub':
  21414. if (stack.length < 2) {
  21415. return null;
  21416. }
  21417. num2 = stack.pop();
  21418. num1 = stack.pop();
  21419. stack.push(buildSubOperation(num1, num2));
  21420. break;
  21421. case 'exch':
  21422. if (stack.length < 2) {
  21423. return null;
  21424. }
  21425. ast1 = stack.pop();
  21426. ast2 = stack.pop();
  21427. stack.push(ast1, ast2);
  21428. break;
  21429. case 'pop':
  21430. if (stack.length < 1) {
  21431. return null;
  21432. }
  21433. stack.pop();
  21434. break;
  21435. case 'index':
  21436. if (stack.length < 1) {
  21437. return null;
  21438. }
  21439. num1 = stack.pop();
  21440. if (num1.type !== 'literal') {
  21441. return null;
  21442. }
  21443. n = num1.number;
  21444. if (n < 0 || !Number.isInteger(n) || stack.length < n) {
  21445. return null;
  21446. }
  21447. ast1 = stack[stack.length - n - 1];
  21448. if (ast1.type === 'literal' || ast1.type === 'var') {
  21449. stack.push(ast1);
  21450. break;
  21451. }
  21452. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  21453. stack[stack.length - n - 1] = tmpVar;
  21454. stack.push(tmpVar);
  21455. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  21456. break;
  21457. case 'dup':
  21458. if (stack.length < 1) {
  21459. return null;
  21460. }
  21461. 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]) {
  21462. num1 = stack.pop();
  21463. stack.push(buildMinOperation(num1, code[i + 1]));
  21464. i += 6;
  21465. break;
  21466. }
  21467. ast1 = stack[stack.length - 1];
  21468. if (ast1.type === 'literal' || ast1.type === 'var') {
  21469. stack.push(ast1);
  21470. break;
  21471. }
  21472. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  21473. stack[stack.length - 1] = tmpVar;
  21474. stack.push(tmpVar);
  21475. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  21476. break;
  21477. case 'roll':
  21478. if (stack.length < 2) {
  21479. return null;
  21480. }
  21481. num2 = stack.pop();
  21482. num1 = stack.pop();
  21483. if (num2.type !== 'literal' || num1.type !== 'literal') {
  21484. return null;
  21485. }
  21486. j = num2.number;
  21487. n = num1.number;
  21488. if (n <= 0 || !Number.isInteger(n) || !Number.isInteger(j) || stack.length < n) {
  21489. return null;
  21490. }
  21491. j = (j % n + n) % n;
  21492. if (j === 0) {
  21493. break;
  21494. }
  21495. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  21496. break;
  21497. default:
  21498. return null;
  21499. }
  21500. }
  21501. if (stack.length !== outputSize) {
  21502. return null;
  21503. }
  21504. var result = [];
  21505. instructions.forEach(function (instruction) {
  21506. var statementBuilder = new ExpressionBuilderVisitor();
  21507. instruction.visit(statementBuilder);
  21508. result.push(statementBuilder.toString());
  21509. });
  21510. stack.forEach(function (expr, i) {
  21511. var statementBuilder = new ExpressionBuilderVisitor();
  21512. expr.visit(statementBuilder);
  21513. var min = range[i * 2],
  21514. max = range[i * 2 + 1];
  21515. var out = [statementBuilder.toString()];
  21516. if (min > expr.min) {
  21517. out.unshift('Math.max(', min, ', ');
  21518. out.push(')');
  21519. }
  21520. if (max < expr.max) {
  21521. out.unshift('Math.min(', max, ', ');
  21522. out.push(')');
  21523. }
  21524. out.unshift('dest[destOffset + ', i, '] = ');
  21525. out.push(';');
  21526. result.push(out.join(''));
  21527. });
  21528. return result.join('\n');
  21529. }
  21530. };
  21531. return PostScriptCompiler;
  21532. }();
  21533. exports.isPDFFunction = isPDFFunction;
  21534. exports.PDFFunctionFactory = PDFFunctionFactory;
  21535. exports.PostScriptEvaluator = PostScriptEvaluator;
  21536. exports.PostScriptCompiler = PostScriptCompiler;
  21537. /***/ }),
  21538. /* 70 */
  21539. /***/ (function(module, exports, __w_pdfjs_require__) {
  21540. "use strict";
  21541. var pdfjsVersion = '2.0.114';
  21542. var pdfjsBuild = '85e00672';
  21543. var pdfjsCoreWorker = __w_pdfjs_require__(71);
  21544. exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
  21545. /***/ }),
  21546. /* 71 */
  21547. /***/ (function(module, exports, __w_pdfjs_require__) {
  21548. "use strict";
  21549. Object.defineProperty(exports, "__esModule", {
  21550. value: true
  21551. });
  21552. exports.WorkerMessageHandler = exports.WorkerTask = undefined;
  21553. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  21554. var _util = __w_pdfjs_require__(0);
  21555. var _pdf_manager = __w_pdfjs_require__(122);
  21556. var _primitives = __w_pdfjs_require__(1);
  21557. var WorkerTask = function WorkerTaskClosure() {
  21558. function WorkerTask(name) {
  21559. this.name = name;
  21560. this.terminated = false;
  21561. this._capability = (0, _util.createPromiseCapability)();
  21562. }
  21563. WorkerTask.prototype = {
  21564. get finished() {
  21565. return this._capability.promise;
  21566. },
  21567. finish: function finish() {
  21568. this._capability.resolve();
  21569. },
  21570. terminate: function terminate() {
  21571. this.terminated = true;
  21572. },
  21573. ensureNotTerminated: function ensureNotTerminated() {
  21574. if (this.terminated) {
  21575. throw new Error('Worker task was terminated');
  21576. }
  21577. }
  21578. };
  21579. return WorkerTask;
  21580. }();
  21581. ;
  21582. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  21583. function PDFWorkerStream(msgHandler) {
  21584. this._msgHandler = msgHandler;
  21585. this._contentLength = null;
  21586. this._fullRequestReader = null;
  21587. this._rangeRequestReaders = [];
  21588. }
  21589. PDFWorkerStream.prototype = {
  21590. getFullReader: function getFullReader() {
  21591. (0, _util.assert)(!this._fullRequestReader);
  21592. this._fullRequestReader = new PDFWorkerStreamReader(this._msgHandler);
  21593. return this._fullRequestReader;
  21594. },
  21595. getRangeReader: function getRangeReader(begin, end) {
  21596. var reader = new PDFWorkerStreamRangeReader(begin, end, this._msgHandler);
  21597. this._rangeRequestReaders.push(reader);
  21598. return reader;
  21599. },
  21600. cancelAllRequests: function cancelAllRequests(reason) {
  21601. if (this._fullRequestReader) {
  21602. this._fullRequestReader.cancel(reason);
  21603. }
  21604. var readers = this._rangeRequestReaders.slice(0);
  21605. readers.forEach(function (reader) {
  21606. reader.cancel(reason);
  21607. });
  21608. }
  21609. };
  21610. function PDFWorkerStreamReader(msgHandler) {
  21611. var _this = this;
  21612. this._msgHandler = msgHandler;
  21613. this._contentLength = null;
  21614. this._isRangeSupported = false;
  21615. this._isStreamingSupported = false;
  21616. var readableStream = this._msgHandler.sendWithStream('GetReader');
  21617. this._reader = readableStream.getReader();
  21618. this._headersReady = this._msgHandler.sendWithPromise('ReaderHeadersReady').then(function (data) {
  21619. _this._isStreamingSupported = data.isStreamingSupported;
  21620. _this._isRangeSupported = data.isRangeSupported;
  21621. _this._contentLength = data.contentLength;
  21622. });
  21623. }
  21624. PDFWorkerStreamReader.prototype = {
  21625. get headersReady() {
  21626. return this._headersReady;
  21627. },
  21628. get contentLength() {
  21629. return this._contentLength;
  21630. },
  21631. get isStreamingSupported() {
  21632. return this._isStreamingSupported;
  21633. },
  21634. get isRangeSupported() {
  21635. return this._isRangeSupported;
  21636. },
  21637. read: function read() {
  21638. return this._reader.read().then(function (_ref) {
  21639. var value = _ref.value,
  21640. done = _ref.done;
  21641. if (done) {
  21642. return {
  21643. value: undefined,
  21644. done: true
  21645. };
  21646. }
  21647. return {
  21648. value: value.buffer,
  21649. done: false
  21650. };
  21651. });
  21652. },
  21653. cancel: function cancel(reason) {
  21654. this._reader.cancel(reason);
  21655. }
  21656. };
  21657. function PDFWorkerStreamRangeReader(begin, end, msgHandler) {
  21658. this._msgHandler = msgHandler;
  21659. this.onProgress = null;
  21660. var readableStream = this._msgHandler.sendWithStream('GetRangeReader', {
  21661. begin: begin,
  21662. end: end
  21663. });
  21664. this._reader = readableStream.getReader();
  21665. }
  21666. PDFWorkerStreamRangeReader.prototype = {
  21667. get isStreamingSupported() {
  21668. return false;
  21669. },
  21670. read: function read() {
  21671. return this._reader.read().then(function (_ref2) {
  21672. var value = _ref2.value,
  21673. done = _ref2.done;
  21674. if (done) {
  21675. return {
  21676. value: undefined,
  21677. done: true
  21678. };
  21679. }
  21680. return {
  21681. value: value.buffer,
  21682. done: false
  21683. };
  21684. });
  21685. },
  21686. cancel: function cancel(reason) {
  21687. this._reader.cancel(reason);
  21688. }
  21689. };
  21690. return PDFWorkerStream;
  21691. }();
  21692. var WorkerMessageHandler = {
  21693. setup: function setup(handler, port) {
  21694. var testMessageProcessed = false;
  21695. handler.on('test', function wphSetupTest(data) {
  21696. if (testMessageProcessed) {
  21697. return;
  21698. }
  21699. testMessageProcessed = true;
  21700. if (!(data instanceof Uint8Array)) {
  21701. handler.send('test', 'main', false);
  21702. return;
  21703. }
  21704. var supportTransfers = data[0] === 255;
  21705. handler.postMessageTransfers = supportTransfers;
  21706. var xhr = new XMLHttpRequest();
  21707. var responseExists = 'response' in xhr;
  21708. try {
  21709. xhr.responseType;
  21710. } catch (e) {
  21711. responseExists = false;
  21712. }
  21713. if (!responseExists) {
  21714. handler.send('test', false);
  21715. return;
  21716. }
  21717. handler.send('test', {
  21718. supportTypedArray: true,
  21719. supportTransfers: supportTransfers
  21720. });
  21721. });
  21722. handler.on('configure', function wphConfigure(data) {
  21723. (0, _util.setVerbosityLevel)(data.verbosity);
  21724. });
  21725. handler.on('GetDocRequest', function wphSetupDoc(data) {
  21726. return WorkerMessageHandler.createDocumentHandler(data, port);
  21727. });
  21728. },
  21729. createDocumentHandler: function createDocumentHandler(docParams, port) {
  21730. var pdfManager;
  21731. var terminated = false;
  21732. var cancelXHRs = null;
  21733. var WorkerTasks = [];
  21734. var apiVersion = docParams.apiVersion;
  21735. var workerVersion = '2.0.114';
  21736. if (apiVersion !== null && apiVersion !== workerVersion) {
  21737. throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
  21738. }
  21739. var docId = docParams.docId;
  21740. var docBaseUrl = docParams.docBaseUrl;
  21741. var workerHandlerName = docParams.docId + '_worker';
  21742. var handler = new _util.MessageHandler(workerHandlerName, docId, port);
  21743. handler.postMessageTransfers = docParams.postMessageTransfers;
  21744. function ensureNotTerminated() {
  21745. if (terminated) {
  21746. throw new Error('Worker was terminated');
  21747. }
  21748. }
  21749. function startWorkerTask(task) {
  21750. WorkerTasks.push(task);
  21751. }
  21752. function finishWorkerTask(task) {
  21753. task.finish();
  21754. var i = WorkerTasks.indexOf(task);
  21755. WorkerTasks.splice(i, 1);
  21756. }
  21757. function loadDocument(recoveryMode) {
  21758. var loadDocumentCapability = (0, _util.createPromiseCapability)();
  21759. var parseSuccess = function parseSuccess() {
  21760. var numPagesPromise = pdfManager.ensureDoc('numPages');
  21761. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  21762. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  21763. Promise.all([numPagesPromise, fingerprintPromise, encryptedPromise]).then(function onDocReady(results) {
  21764. var doc = {
  21765. numPages: results[0],
  21766. fingerprint: results[1],
  21767. encrypted: !!results[2]
  21768. };
  21769. loadDocumentCapability.resolve(doc);
  21770. }, parseFailure);
  21771. };
  21772. var parseFailure = function parseFailure(e) {
  21773. loadDocumentCapability.reject(e);
  21774. };
  21775. pdfManager.ensureDoc('checkHeader', []).then(function () {
  21776. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  21777. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  21778. }, parseFailure);
  21779. }, parseFailure);
  21780. return loadDocumentCapability.promise;
  21781. }
  21782. function getPdfManager(data, evaluatorOptions) {
  21783. var pdfManagerCapability = (0, _util.createPromiseCapability)();
  21784. var pdfManager;
  21785. var source = data.source;
  21786. if (source.data) {
  21787. try {
  21788. pdfManager = new _pdf_manager.LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  21789. pdfManagerCapability.resolve(pdfManager);
  21790. } catch (ex) {
  21791. pdfManagerCapability.reject(ex);
  21792. }
  21793. return pdfManagerCapability.promise;
  21794. }
  21795. var pdfStream,
  21796. cachedChunks = [];
  21797. try {
  21798. pdfStream = new PDFWorkerStream(handler);
  21799. } catch (ex) {
  21800. pdfManagerCapability.reject(ex);
  21801. return pdfManagerCapability.promise;
  21802. }
  21803. var fullRequest = pdfStream.getFullReader();
  21804. fullRequest.headersReady.then(function () {
  21805. if (!fullRequest.isRangeSupported) {
  21806. return;
  21807. }
  21808. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  21809. pdfManager = new _pdf_manager.NetworkPdfManager(docId, pdfStream, {
  21810. msgHandler: handler,
  21811. url: source.url,
  21812. password: source.password,
  21813. length: fullRequest.contentLength,
  21814. disableAutoFetch: disableAutoFetch,
  21815. rangeChunkSize: source.rangeChunkSize
  21816. }, evaluatorOptions, docBaseUrl);
  21817. for (var i = 0; i < cachedChunks.length; i++) {
  21818. pdfManager.sendProgressiveData(cachedChunks[i]);
  21819. }
  21820. cachedChunks = [];
  21821. pdfManagerCapability.resolve(pdfManager);
  21822. cancelXHRs = null;
  21823. }).catch(function (reason) {
  21824. pdfManagerCapability.reject(reason);
  21825. cancelXHRs = null;
  21826. });
  21827. var loaded = 0;
  21828. var flushChunks = function flushChunks() {
  21829. var pdfFile = (0, _util.arraysToBytes)(cachedChunks);
  21830. if (source.length && pdfFile.length !== source.length) {
  21831. (0, _util.warn)('reported HTTP length is different from actual');
  21832. }
  21833. try {
  21834. pdfManager = new _pdf_manager.LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  21835. pdfManagerCapability.resolve(pdfManager);
  21836. } catch (ex) {
  21837. pdfManagerCapability.reject(ex);
  21838. }
  21839. cachedChunks = [];
  21840. };
  21841. var readPromise = new Promise(function (resolve, reject) {
  21842. var readChunk = function readChunk(chunk) {
  21843. try {
  21844. ensureNotTerminated();
  21845. if (chunk.done) {
  21846. if (!pdfManager) {
  21847. flushChunks();
  21848. }
  21849. cancelXHRs = null;
  21850. return;
  21851. }
  21852. var data = chunk.value;
  21853. loaded += (0, _util.arrayByteLength)(data);
  21854. if (!fullRequest.isStreamingSupported) {
  21855. handler.send('DocProgress', {
  21856. loaded: loaded,
  21857. total: Math.max(loaded, fullRequest.contentLength || 0)
  21858. });
  21859. }
  21860. if (pdfManager) {
  21861. pdfManager.sendProgressiveData(data);
  21862. } else {
  21863. cachedChunks.push(data);
  21864. }
  21865. fullRequest.read().then(readChunk, reject);
  21866. } catch (e) {
  21867. reject(e);
  21868. }
  21869. };
  21870. fullRequest.read().then(readChunk, reject);
  21871. });
  21872. readPromise.catch(function (e) {
  21873. pdfManagerCapability.reject(e);
  21874. cancelXHRs = null;
  21875. });
  21876. cancelXHRs = function cancelXHRs() {
  21877. pdfStream.cancelAllRequests('abort');
  21878. };
  21879. return pdfManagerCapability.promise;
  21880. }
  21881. function setupDoc(data) {
  21882. function onSuccess(doc) {
  21883. ensureNotTerminated();
  21884. handler.send('GetDoc', { pdfInfo: doc });
  21885. }
  21886. function onFailure(e) {
  21887. ensureNotTerminated();
  21888. if (e instanceof _util.PasswordException) {
  21889. var task = new WorkerTask('PasswordException: response ' + e.code);
  21890. startWorkerTask(task);
  21891. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  21892. finishWorkerTask(task);
  21893. pdfManager.updatePassword(data.password);
  21894. pdfManagerReady();
  21895. }).catch(function (ex) {
  21896. finishWorkerTask(task);
  21897. handler.send('PasswordException', ex);
  21898. }.bind(null, e));
  21899. } else if (e instanceof _util.InvalidPDFException) {
  21900. handler.send('InvalidPDF', e);
  21901. } else if (e instanceof _util.MissingPDFException) {
  21902. handler.send('MissingPDF', e);
  21903. } else if (e instanceof _util.UnexpectedResponseException) {
  21904. handler.send('UnexpectedResponse', e);
  21905. } else {
  21906. handler.send('UnknownError', new _util.UnknownErrorException(e.message, e.toString()));
  21907. }
  21908. }
  21909. function pdfManagerReady() {
  21910. ensureNotTerminated();
  21911. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  21912. ensureNotTerminated();
  21913. if (!(ex instanceof _util.XRefParseException)) {
  21914. onFailure(ex);
  21915. return;
  21916. }
  21917. pdfManager.requestLoadedStream();
  21918. pdfManager.onLoadedStream().then(function () {
  21919. ensureNotTerminated();
  21920. loadDocument(true).then(onSuccess, onFailure);
  21921. });
  21922. }, onFailure);
  21923. }
  21924. ensureNotTerminated();
  21925. var evaluatorOptions = {
  21926. forceDataSchema: data.disableCreateObjectURL,
  21927. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  21928. disableFontFace: data.disableFontFace,
  21929. nativeImageDecoderSupport: data.nativeImageDecoderSupport,
  21930. ignoreErrors: data.ignoreErrors,
  21931. isEvalSupported: data.isEvalSupported
  21932. };
  21933. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  21934. if (terminated) {
  21935. newPdfManager.terminate();
  21936. throw new Error('Worker was terminated');
  21937. }
  21938. pdfManager = newPdfManager;
  21939. handler.send('PDFManagerReady', null);
  21940. pdfManager.onLoadedStream().then(function (stream) {
  21941. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  21942. });
  21943. }).then(pdfManagerReady, onFailure);
  21944. }
  21945. handler.on('GetPage', function wphSetupGetPage(data) {
  21946. return pdfManager.getPage(data.pageIndex).then(function (page) {
  21947. var rotatePromise = pdfManager.ensure(page, 'rotate');
  21948. var refPromise = pdfManager.ensure(page, 'ref');
  21949. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  21950. var viewPromise = pdfManager.ensure(page, 'view');
  21951. return Promise.all([rotatePromise, refPromise, userUnitPromise, viewPromise]).then(function (results) {
  21952. return {
  21953. rotate: results[0],
  21954. ref: results[1],
  21955. userUnit: results[2],
  21956. view: results[3]
  21957. };
  21958. });
  21959. });
  21960. });
  21961. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  21962. var ref = new _primitives.Ref(data.ref.num, data.ref.gen);
  21963. var catalog = pdfManager.pdfDocument.catalog;
  21964. return catalog.getPageIndex(ref);
  21965. });
  21966. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  21967. return pdfManager.ensureCatalog('destinations');
  21968. });
  21969. handler.on('GetDestination', function wphSetupGetDestination(data) {
  21970. return pdfManager.ensureCatalog('getDestination', [data.id]);
  21971. });
  21972. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  21973. return pdfManager.ensureCatalog('pageLabels');
  21974. });
  21975. handler.on('GetPageMode', function wphSetupGetPageMode(data) {
  21976. return pdfManager.ensureCatalog('pageMode');
  21977. });
  21978. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  21979. return pdfManager.ensureCatalog('attachments');
  21980. });
  21981. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  21982. return pdfManager.ensureCatalog('javaScript');
  21983. });
  21984. handler.on('GetOutline', function wphSetupGetOutline(data) {
  21985. return pdfManager.ensureCatalog('documentOutline');
  21986. });
  21987. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  21988. return Promise.all([pdfManager.ensureDoc('documentInfo'), pdfManager.ensureCatalog('metadata')]);
  21989. });
  21990. handler.on('GetData', function wphSetupGetData(data) {
  21991. pdfManager.requestLoadedStream();
  21992. return pdfManager.onLoadedStream().then(function (stream) {
  21993. return stream.bytes;
  21994. });
  21995. });
  21996. handler.on('GetStats', function wphSetupGetStats(data) {
  21997. return pdfManager.pdfDocument.xref.stats;
  21998. });
  21999. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  22000. return pdfManager.getPage(data.pageIndex).then(function (page) {
  22001. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  22002. });
  22003. });
  22004. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  22005. var pageIndex = data.pageIndex;
  22006. pdfManager.getPage(pageIndex).then(function (page) {
  22007. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  22008. startWorkerTask(task);
  22009. var pageNum = pageIndex + 1;
  22010. var start = Date.now();
  22011. page.getOperatorList({
  22012. handler: handler,
  22013. task: task,
  22014. intent: data.intent,
  22015. renderInteractiveForms: data.renderInteractiveForms
  22016. }).then(function (operatorList) {
  22017. finishWorkerTask(task);
  22018. (0, _util.info)('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  22019. }, function (e) {
  22020. finishWorkerTask(task);
  22021. if (task.terminated) {
  22022. return;
  22023. }
  22024. handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
  22025. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  22026. var wrappedException;
  22027. if (typeof e === 'string') {
  22028. wrappedException = {
  22029. message: e,
  22030. stack: minimumStackMessage
  22031. };
  22032. } else if ((typeof e === 'undefined' ? 'undefined' : _typeof(e)) === 'object') {
  22033. wrappedException = {
  22034. message: e.message || e.toString(),
  22035. stack: e.stack || minimumStackMessage
  22036. };
  22037. } else {
  22038. wrappedException = {
  22039. message: 'Unknown exception type: ' + (typeof e === 'undefined' ? 'undefined' : _typeof(e)),
  22040. stack: minimumStackMessage
  22041. };
  22042. }
  22043. handler.send('PageError', {
  22044. pageNum: pageNum,
  22045. error: wrappedException,
  22046. intent: data.intent
  22047. });
  22048. });
  22049. });
  22050. }, this);
  22051. handler.on('GetTextContent', function wphExtractText(data, sink) {
  22052. var pageIndex = data.pageIndex;
  22053. sink.onPull = function (desiredSize) {};
  22054. sink.onCancel = function (reason) {};
  22055. pdfManager.getPage(pageIndex).then(function (page) {
  22056. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  22057. startWorkerTask(task);
  22058. var pageNum = pageIndex + 1;
  22059. var start = Date.now();
  22060. page.extractTextContent({
  22061. handler: handler,
  22062. task: task,
  22063. sink: sink,
  22064. normalizeWhitespace: data.normalizeWhitespace,
  22065. combineTextItems: data.combineTextItems
  22066. }).then(function () {
  22067. finishWorkerTask(task);
  22068. (0, _util.info)('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  22069. sink.close();
  22070. }, function (reason) {
  22071. finishWorkerTask(task);
  22072. if (task.terminated) {
  22073. return;
  22074. }
  22075. sink.error(reason);
  22076. throw reason;
  22077. });
  22078. });
  22079. });
  22080. handler.on('Cleanup', function wphCleanup(data) {
  22081. return pdfManager.cleanup();
  22082. });
  22083. handler.on('Terminate', function wphTerminate(data) {
  22084. terminated = true;
  22085. if (pdfManager) {
  22086. pdfManager.terminate();
  22087. pdfManager = null;
  22088. }
  22089. if (cancelXHRs) {
  22090. cancelXHRs();
  22091. }
  22092. var waitOn = [];
  22093. WorkerTasks.forEach(function (task) {
  22094. waitOn.push(task.finished);
  22095. task.terminate();
  22096. });
  22097. return Promise.all(waitOn).then(function () {
  22098. handler.destroy();
  22099. handler = null;
  22100. });
  22101. });
  22102. handler.on('Ready', function wphReady(data) {
  22103. setupDoc(docParams);
  22104. docParams = null;
  22105. });
  22106. return workerHandlerName;
  22107. },
  22108. initializeFromPort: function initializeFromPort(port) {
  22109. var handler = new _util.MessageHandler('worker', 'main', port);
  22110. WorkerMessageHandler.setup(handler, port);
  22111. handler.send('ready', null);
  22112. }
  22113. };
  22114. function isMessagePort(maybePort) {
  22115. return typeof maybePort.postMessage === 'function' && 'onmessage' in maybePort;
  22116. }
  22117. if (typeof window === 'undefined' && !(0, _util.isNodeJS)() && typeof self !== 'undefined' && isMessagePort(self)) {
  22118. WorkerMessageHandler.initializeFromPort(self);
  22119. }
  22120. exports.WorkerTask = WorkerTask;
  22121. exports.WorkerMessageHandler = WorkerMessageHandler;
  22122. /***/ }),
  22123. /* 72 */
  22124. /***/ (function(module, exports, __w_pdfjs_require__) {
  22125. "use strict";
  22126. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  22127. if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
  22128. var globalScope = __w_pdfjs_require__(73);
  22129. var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
  22130. var isAndroid = /Android/.test(userAgent);
  22131. var isAndroidPre3 = /Android\s[0-2][^\d]/.test(userAgent);
  22132. var isAndroidPre5 = /Android\s[0-4][^\d]/.test(userAgent);
  22133. var isChrome = userAgent.indexOf('Chrom') >= 0;
  22134. var isChromeWithRangeBug = /Chrome\/(39|40)\./.test(userAgent);
  22135. var isIOSChrome = userAgent.indexOf('CriOS') >= 0;
  22136. var isIE = userAgent.indexOf('Trident') >= 0;
  22137. var isIOS = /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent);
  22138. var isOpera = userAgent.indexOf('Opera') >= 0;
  22139. var isSafari = /Safari\//.test(userAgent) && !/(Chrome\/|Android\s)/.test(userAgent);
  22140. var hasDOM = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && (typeof document === 'undefined' ? 'undefined' : _typeof(document)) === 'object';
  22141. if (typeof PDFJS === 'undefined') {
  22142. globalScope.PDFJS = {};
  22143. }
  22144. PDFJS.compatibilityChecked = true;
  22145. (function normalizeURLObject() {
  22146. if (!globalScope.URL) {
  22147. globalScope.URL = globalScope.webkitURL;
  22148. }
  22149. })();
  22150. (function checkObjectDefinePropertyCompatibility() {
  22151. if (typeof Object.defineProperty !== 'undefined') {
  22152. var definePropertyPossible = true;
  22153. try {
  22154. if (hasDOM) {
  22155. Object.defineProperty(new Image(), 'id', { value: 'test' });
  22156. }
  22157. var Test = function Test() {};
  22158. Test.prototype = {
  22159. get id() {}
  22160. };
  22161. Object.defineProperty(new Test(), 'id', {
  22162. value: '',
  22163. configurable: true,
  22164. enumerable: true,
  22165. writable: false
  22166. });
  22167. } catch (e) {
  22168. definePropertyPossible = false;
  22169. }
  22170. if (definePropertyPossible) {
  22171. return;
  22172. }
  22173. }
  22174. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  22175. delete obj[name];
  22176. if ('get' in def) {
  22177. obj.__defineGetter__(name, def['get']);
  22178. }
  22179. if ('set' in def) {
  22180. obj.__defineSetter__(name, def['set']);
  22181. }
  22182. if ('value' in def) {
  22183. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  22184. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  22185. return value;
  22186. });
  22187. return value;
  22188. });
  22189. obj[name] = def.value;
  22190. }
  22191. };
  22192. })();
  22193. (function checkXMLHttpRequestResponseCompatibility() {
  22194. if (typeof XMLHttpRequest === 'undefined') {
  22195. return;
  22196. }
  22197. var xhrPrototype = XMLHttpRequest.prototype;
  22198. var xhr = new XMLHttpRequest();
  22199. if (!('overrideMimeType' in xhr)) {
  22200. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  22201. value: function xmlHttpRequestOverrideMimeType(mimeType) {}
  22202. });
  22203. }
  22204. if ('responseType' in xhr) {
  22205. return;
  22206. }
  22207. Object.defineProperty(xhrPrototype, 'responseType', {
  22208. get: function xmlHttpRequestGetResponseType() {
  22209. return this._responseType || 'text';
  22210. },
  22211. set: function xmlHttpRequestSetResponseType(value) {
  22212. if (value === 'text' || value === 'arraybuffer') {
  22213. this._responseType = value;
  22214. if (value === 'arraybuffer' && typeof this.overrideMimeType === 'function') {
  22215. this.overrideMimeType('text/plain; charset=x-user-defined');
  22216. }
  22217. }
  22218. }
  22219. });
  22220. if (typeof VBArray !== 'undefined') {
  22221. Object.defineProperty(xhrPrototype, 'response', {
  22222. get: function xmlHttpRequestResponseGet() {
  22223. if (this.responseType === 'arraybuffer') {
  22224. return new Uint8Array(new VBArray(this.responseBody).toArray());
  22225. }
  22226. return this.responseText;
  22227. }
  22228. });
  22229. return;
  22230. }
  22231. Object.defineProperty(xhrPrototype, 'response', {
  22232. get: function xmlHttpRequestResponseGet() {
  22233. if (this.responseType !== 'arraybuffer') {
  22234. return this.responseText;
  22235. }
  22236. var text = this.responseText;
  22237. var i,
  22238. n = text.length;
  22239. var result = new Uint8Array(n);
  22240. for (i = 0; i < n; ++i) {
  22241. result[i] = text.charCodeAt(i) & 0xFF;
  22242. }
  22243. return result.buffer;
  22244. }
  22245. });
  22246. })();
  22247. (function checkWindowBtoaCompatibility() {
  22248. if ('btoa' in globalScope) {
  22249. return;
  22250. }
  22251. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  22252. globalScope.btoa = function (chars) {
  22253. var buffer = '';
  22254. var i, n;
  22255. for (i = 0, n = chars.length; i < n; i += 3) {
  22256. var b1 = chars.charCodeAt(i) & 0xFF;
  22257. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  22258. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  22259. var d1 = b1 >> 2,
  22260. d2 = (b1 & 3) << 4 | b2 >> 4;
  22261. var d3 = i + 1 < n ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  22262. var d4 = i + 2 < n ? b3 & 0x3F : 64;
  22263. buffer += digits.charAt(d1) + digits.charAt(d2) + digits.charAt(d3) + digits.charAt(d4);
  22264. }
  22265. return buffer;
  22266. };
  22267. })();
  22268. (function checkWindowAtobCompatibility() {
  22269. if ('atob' in globalScope) {
  22270. return;
  22271. }
  22272. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  22273. globalScope.atob = function (input) {
  22274. input = input.replace(/=+$/, '');
  22275. if (input.length % 4 === 1) {
  22276. throw new Error('bad atob input');
  22277. }
  22278. for (var bc = 0, bs, buffer, idx = 0, output = ''; buffer = input.charAt(idx++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  22279. buffer = digits.indexOf(buffer);
  22280. }
  22281. return output;
  22282. };
  22283. })();
  22284. (function checkFunctionPrototypeBindCompatibility() {
  22285. if (typeof Function.prototype.bind !== 'undefined') {
  22286. return;
  22287. }
  22288. Function.prototype.bind = function functionPrototypeBind(obj) {
  22289. var fn = this,
  22290. headArgs = Array.prototype.slice.call(arguments, 1);
  22291. var bound = function functionPrototypeBindBound() {
  22292. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  22293. return fn.apply(obj, args);
  22294. };
  22295. return bound;
  22296. };
  22297. })();
  22298. (function checkDatasetProperty() {
  22299. if (!hasDOM) {
  22300. return;
  22301. }
  22302. var div = document.createElement('div');
  22303. if ('dataset' in div) {
  22304. return;
  22305. }
  22306. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  22307. get: function get() {
  22308. if (this._dataset) {
  22309. return this._dataset;
  22310. }
  22311. var dataset = {};
  22312. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  22313. var attribute = this.attributes[j];
  22314. if (attribute.name.substring(0, 5) !== 'data-') {
  22315. continue;
  22316. }
  22317. var key = attribute.name.substring(5).replace(/\-([a-z])/g, function (all, ch) {
  22318. return ch.toUpperCase();
  22319. });
  22320. dataset[key] = attribute.value;
  22321. }
  22322. Object.defineProperty(this, '_dataset', {
  22323. value: dataset,
  22324. writable: false,
  22325. enumerable: false
  22326. });
  22327. return dataset;
  22328. },
  22329. enumerable: true
  22330. });
  22331. })();
  22332. (function checkClassListProperty() {
  22333. function changeList(element, itemName, add, remove) {
  22334. var s = element.className || '';
  22335. var list = s.split(/\s+/g);
  22336. if (list[0] === '') {
  22337. list.shift();
  22338. }
  22339. var index = list.indexOf(itemName);
  22340. if (index < 0 && add) {
  22341. list.push(itemName);
  22342. }
  22343. if (index >= 0 && remove) {
  22344. list.splice(index, 1);
  22345. }
  22346. element.className = list.join(' ');
  22347. return index >= 0;
  22348. }
  22349. if (!hasDOM) {
  22350. return;
  22351. }
  22352. var div = document.createElement('div');
  22353. if ('classList' in div) {
  22354. return;
  22355. }
  22356. var classListPrototype = {
  22357. add: function add(name) {
  22358. changeList(this.element, name, true, false);
  22359. },
  22360. contains: function contains(name) {
  22361. return changeList(this.element, name, false, false);
  22362. },
  22363. remove: function remove(name) {
  22364. changeList(this.element, name, false, true);
  22365. },
  22366. toggle: function toggle(name) {
  22367. changeList(this.element, name, true, true);
  22368. }
  22369. };
  22370. Object.defineProperty(HTMLElement.prototype, 'classList', {
  22371. get: function get() {
  22372. if (this._classList) {
  22373. return this._classList;
  22374. }
  22375. var classList = Object.create(classListPrototype, {
  22376. element: {
  22377. value: this,
  22378. writable: false,
  22379. enumerable: true
  22380. }
  22381. });
  22382. Object.defineProperty(this, '_classList', {
  22383. value: classList,
  22384. writable: false,
  22385. enumerable: false
  22386. });
  22387. return classList;
  22388. },
  22389. enumerable: true
  22390. });
  22391. })();
  22392. (function checkWorkerConsoleCompatibility() {
  22393. if (typeof importScripts === 'undefined' || 'console' in globalScope) {
  22394. return;
  22395. }
  22396. var consoleTimer = {};
  22397. var workerConsole = {
  22398. log: function log() {
  22399. var args = Array.prototype.slice.call(arguments);
  22400. globalScope.postMessage({
  22401. targetName: 'main',
  22402. action: 'console_log',
  22403. data: args
  22404. });
  22405. },
  22406. error: function error() {
  22407. var args = Array.prototype.slice.call(arguments);
  22408. globalScope.postMessage({
  22409. targetName: 'main',
  22410. action: 'console_error',
  22411. data: args
  22412. });
  22413. },
  22414. time: function time(name) {
  22415. consoleTimer[name] = Date.now();
  22416. },
  22417. timeEnd: function timeEnd(name) {
  22418. var time = consoleTimer[name];
  22419. if (!time) {
  22420. throw new Error('Unknown timer name ' + name);
  22421. }
  22422. this.log('Timer:', name, Date.now() - time);
  22423. }
  22424. };
  22425. globalScope.console = workerConsole;
  22426. })();
  22427. (function checkConsoleCompatibility() {
  22428. if (!hasDOM) {
  22429. return;
  22430. }
  22431. if (!('console' in window)) {
  22432. window.console = {
  22433. log: function log() {},
  22434. error: function error() {},
  22435. warn: function warn() {}
  22436. };
  22437. return;
  22438. }
  22439. if (!('bind' in console.log)) {
  22440. console.log = function (fn) {
  22441. return function (msg) {
  22442. return fn(msg);
  22443. };
  22444. }(console.log);
  22445. console.error = function (fn) {
  22446. return function (msg) {
  22447. return fn(msg);
  22448. };
  22449. }(console.error);
  22450. console.warn = function (fn) {
  22451. return function (msg) {
  22452. return fn(msg);
  22453. };
  22454. }(console.warn);
  22455. return;
  22456. }
  22457. })();
  22458. (function checkOnClickCompatibility() {
  22459. function ignoreIfTargetDisabled(event) {
  22460. if (isDisabled(event.target)) {
  22461. event.stopPropagation();
  22462. }
  22463. }
  22464. function isDisabled(node) {
  22465. return node.disabled || node.parentNode && isDisabled(node.parentNode);
  22466. }
  22467. if (isOpera) {
  22468. document.addEventListener('click', ignoreIfTargetDisabled, true);
  22469. }
  22470. })();
  22471. (function checkOnBlobSupport() {
  22472. if (isIE || isIOSChrome) {
  22473. PDFJS.disableCreateObjectURL = true;
  22474. }
  22475. })();
  22476. (function checkNavigatorLanguage() {
  22477. if (typeof navigator === 'undefined') {
  22478. return;
  22479. }
  22480. if ('language' in navigator) {
  22481. return;
  22482. }
  22483. PDFJS.locale = navigator.userLanguage || 'en-US';
  22484. })();
  22485. (function checkRangeRequests() {
  22486. if (isSafari || isAndroidPre3 || isChromeWithRangeBug || isIOS) {
  22487. PDFJS.disableRange = true;
  22488. PDFJS.disableStream = true;
  22489. }
  22490. })();
  22491. (function checkHistoryManipulation() {
  22492. if (!hasDOM) {
  22493. return;
  22494. }
  22495. if (!history.pushState || isAndroidPre3) {
  22496. PDFJS.disableHistory = true;
  22497. }
  22498. })();
  22499. (function checkSetPresenceInImageData() {
  22500. if (!hasDOM) {
  22501. return;
  22502. }
  22503. if (window.CanvasPixelArray) {
  22504. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  22505. window.CanvasPixelArray.prototype.set = function (arr) {
  22506. for (var i = 0, ii = this.length; i < ii; i++) {
  22507. this[i] = arr[i];
  22508. }
  22509. };
  22510. }
  22511. } else {
  22512. var polyfill = false,
  22513. versionMatch;
  22514. if (isChrome) {
  22515. versionMatch = userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  22516. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  22517. } else if (isAndroid) {
  22518. polyfill = isAndroidPre5;
  22519. } else if (isSafari) {
  22520. versionMatch = userAgent.match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  22521. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  22522. }
  22523. if (polyfill) {
  22524. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  22525. var createImageData = contextPrototype.createImageData;
  22526. contextPrototype.createImageData = function (w, h) {
  22527. var imageData = createImageData.call(this, w, h);
  22528. imageData.data.set = function (arr) {
  22529. for (var i = 0, ii = this.length; i < ii; i++) {
  22530. this[i] = arr[i];
  22531. }
  22532. };
  22533. return imageData;
  22534. };
  22535. contextPrototype = null;
  22536. }
  22537. }
  22538. })();
  22539. (function checkRequestAnimationFrame() {
  22540. function installFakeAnimationFrameFunctions() {
  22541. window.requestAnimationFrame = function (callback) {
  22542. return window.setTimeout(callback, 20);
  22543. };
  22544. window.cancelAnimationFrame = function (timeoutID) {
  22545. window.clearTimeout(timeoutID);
  22546. };
  22547. }
  22548. if (!hasDOM) {
  22549. return;
  22550. }
  22551. if (isIOS) {
  22552. installFakeAnimationFrameFunctions();
  22553. return;
  22554. }
  22555. if ('requestAnimationFrame' in window) {
  22556. return;
  22557. }
  22558. window.requestAnimationFrame = window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame;
  22559. if (window.requestAnimationFrame) {
  22560. return;
  22561. }
  22562. installFakeAnimationFrameFunctions();
  22563. })();
  22564. (function checkCanvasSizeLimitation() {
  22565. if (isIOS || isAndroid) {
  22566. PDFJS.maxCanvasPixels = 5242880;
  22567. }
  22568. })();
  22569. (function checkFullscreenSupport() {
  22570. if (!hasDOM) {
  22571. return;
  22572. }
  22573. if (isIE && window.parent !== window) {
  22574. PDFJS.disableFullscreen = true;
  22575. }
  22576. })();
  22577. (function checkCurrentScript() {
  22578. if (!hasDOM) {
  22579. return;
  22580. }
  22581. if ('currentScript' in document) {
  22582. return;
  22583. }
  22584. Object.defineProperty(document, 'currentScript', {
  22585. get: function get() {
  22586. var scripts = document.getElementsByTagName('script');
  22587. return scripts[scripts.length - 1];
  22588. },
  22589. enumerable: true,
  22590. configurable: true
  22591. });
  22592. })();
  22593. (function checkInputTypeNumberAssign() {
  22594. if (!hasDOM) {
  22595. return;
  22596. }
  22597. var el = document.createElement('input');
  22598. try {
  22599. el.type = 'number';
  22600. } catch (ex) {
  22601. var inputProto = el.constructor.prototype;
  22602. var typeProperty = Object.getOwnPropertyDescriptor(inputProto, 'type');
  22603. Object.defineProperty(inputProto, 'type', {
  22604. get: function get() {
  22605. return typeProperty.get.call(this);
  22606. },
  22607. set: function set(value) {
  22608. typeProperty.set.call(this, value === 'number' ? 'text' : value);
  22609. },
  22610. enumerable: true,
  22611. configurable: true
  22612. });
  22613. }
  22614. })();
  22615. (function checkDocumentReadyState() {
  22616. if (!hasDOM) {
  22617. return;
  22618. }
  22619. if (!document.attachEvent) {
  22620. return;
  22621. }
  22622. var documentProto = document.constructor.prototype;
  22623. var readyStateProto = Object.getOwnPropertyDescriptor(documentProto, 'readyState');
  22624. Object.defineProperty(documentProto, 'readyState', {
  22625. get: function get() {
  22626. var value = readyStateProto.get.call(this);
  22627. return value === 'interactive' ? 'loading' : value;
  22628. },
  22629. set: function set(value) {
  22630. readyStateProto.set.call(this, value);
  22631. },
  22632. enumerable: true,
  22633. configurable: true
  22634. });
  22635. })();
  22636. (function checkChildNodeRemove() {
  22637. if (!hasDOM) {
  22638. return;
  22639. }
  22640. if (typeof Element.prototype.remove !== 'undefined') {
  22641. return;
  22642. }
  22643. Element.prototype.remove = function () {
  22644. if (this.parentNode) {
  22645. this.parentNode.removeChild(this);
  22646. }
  22647. };
  22648. })();
  22649. (function checkObjectValues() {
  22650. if (Object.values) {
  22651. return;
  22652. }
  22653. Object.values = __w_pdfjs_require__(74);
  22654. })();
  22655. (function checkArrayIncludes() {
  22656. if (Array.prototype.includes) {
  22657. return;
  22658. }
  22659. Array.prototype.includes = __w_pdfjs_require__(79);
  22660. })();
  22661. (function checkNumberIsNaN() {
  22662. if (Number.isNaN) {
  22663. return;
  22664. }
  22665. Number.isNaN = __w_pdfjs_require__(81);
  22666. })();
  22667. (function checkNumberIsInteger() {
  22668. if (Number.isInteger) {
  22669. return;
  22670. }
  22671. Number.isInteger = __w_pdfjs_require__(83);
  22672. })();
  22673. (function checkPromise() {
  22674. if (globalScope.Promise) {
  22675. return;
  22676. }
  22677. globalScope.Promise = __w_pdfjs_require__(86);
  22678. })();
  22679. (function checkWeakMap() {
  22680. if (globalScope.WeakMap) {
  22681. return;
  22682. }
  22683. globalScope.WeakMap = __w_pdfjs_require__(104);
  22684. })();
  22685. (function checkURLConstructor() {
  22686. var hasWorkingUrl = false;
  22687. try {
  22688. if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
  22689. var u = new URL('b', 'http://a');
  22690. u.pathname = 'c%20d';
  22691. hasWorkingUrl = u.href === 'http://a/c%20d';
  22692. }
  22693. } catch (e) {}
  22694. if (hasWorkingUrl) {
  22695. return;
  22696. }
  22697. var relative = Object.create(null);
  22698. relative['ftp'] = 21;
  22699. relative['file'] = 0;
  22700. relative['gopher'] = 70;
  22701. relative['http'] = 80;
  22702. relative['https'] = 443;
  22703. relative['ws'] = 80;
  22704. relative['wss'] = 443;
  22705. var relativePathDotMapping = Object.create(null);
  22706. relativePathDotMapping['%2e'] = '.';
  22707. relativePathDotMapping['.%2e'] = '..';
  22708. relativePathDotMapping['%2e.'] = '..';
  22709. relativePathDotMapping['%2e%2e'] = '..';
  22710. function isRelativeScheme(scheme) {
  22711. return relative[scheme] !== undefined;
  22712. }
  22713. function invalid() {
  22714. clear.call(this);
  22715. this._isInvalid = true;
  22716. }
  22717. function IDNAToASCII(h) {
  22718. if (h === '') {
  22719. invalid.call(this);
  22720. }
  22721. return h.toLowerCase();
  22722. }
  22723. function percentEscape(c) {
  22724. var unicode = c.charCodeAt(0);
  22725. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) {
  22726. return c;
  22727. }
  22728. return encodeURIComponent(c);
  22729. }
  22730. function percentEscapeQuery(c) {
  22731. var unicode = c.charCodeAt(0);
  22732. if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) {
  22733. return c;
  22734. }
  22735. return encodeURIComponent(c);
  22736. }
  22737. var EOF,
  22738. ALPHA = /[a-zA-Z]/,
  22739. ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  22740. function parse(input, stateOverride, base) {
  22741. function err(message) {
  22742. errors.push(message);
  22743. }
  22744. var state = stateOverride || 'scheme start',
  22745. cursor = 0,
  22746. buffer = '',
  22747. seenAt = false,
  22748. seenBracket = false,
  22749. errors = [];
  22750. loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  22751. var c = input[cursor];
  22752. switch (state) {
  22753. case 'scheme start':
  22754. if (c && ALPHA.test(c)) {
  22755. buffer += c.toLowerCase();
  22756. state = 'scheme';
  22757. } else if (!stateOverride) {
  22758. buffer = '';
  22759. state = 'no scheme';
  22760. continue;
  22761. } else {
  22762. err('Invalid scheme.');
  22763. break loop;
  22764. }
  22765. break;
  22766. case 'scheme':
  22767. if (c && ALPHANUMERIC.test(c)) {
  22768. buffer += c.toLowerCase();
  22769. } else if (c === ':') {
  22770. this._scheme = buffer;
  22771. buffer = '';
  22772. if (stateOverride) {
  22773. break loop;
  22774. }
  22775. if (isRelativeScheme(this._scheme)) {
  22776. this._isRelative = true;
  22777. }
  22778. if (this._scheme === 'file') {
  22779. state = 'relative';
  22780. } else if (this._isRelative && base && base._scheme === this._scheme) {
  22781. state = 'relative or authority';
  22782. } else if (this._isRelative) {
  22783. state = 'authority first slash';
  22784. } else {
  22785. state = 'scheme data';
  22786. }
  22787. } else if (!stateOverride) {
  22788. buffer = '';
  22789. cursor = 0;
  22790. state = 'no scheme';
  22791. continue;
  22792. } else if (c === EOF) {
  22793. break loop;
  22794. } else {
  22795. err('Code point not allowed in scheme: ' + c);
  22796. break loop;
  22797. }
  22798. break;
  22799. case 'scheme data':
  22800. if (c === '?') {
  22801. this._query = '?';
  22802. state = 'query';
  22803. } else if (c === '#') {
  22804. this._fragment = '#';
  22805. state = 'fragment';
  22806. } else {
  22807. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  22808. this._schemeData += percentEscape(c);
  22809. }
  22810. }
  22811. break;
  22812. case 'no scheme':
  22813. if (!base || !isRelativeScheme(base._scheme)) {
  22814. err('Missing scheme.');
  22815. invalid.call(this);
  22816. } else {
  22817. state = 'relative';
  22818. continue;
  22819. }
  22820. break;
  22821. case 'relative or authority':
  22822. if (c === '/' && input[cursor + 1] === '/') {
  22823. state = 'authority ignore slashes';
  22824. } else {
  22825. err('Expected /, got: ' + c);
  22826. state = 'relative';
  22827. continue;
  22828. }
  22829. break;
  22830. case 'relative':
  22831. this._isRelative = true;
  22832. if (this._scheme !== 'file') {
  22833. this._scheme = base._scheme;
  22834. }
  22835. if (c === EOF) {
  22836. this._host = base._host;
  22837. this._port = base._port;
  22838. this._path = base._path.slice();
  22839. this._query = base._query;
  22840. this._username = base._username;
  22841. this._password = base._password;
  22842. break loop;
  22843. } else if (c === '/' || c === '\\') {
  22844. if (c === '\\') {
  22845. err('\\ is an invalid code point.');
  22846. }
  22847. state = 'relative slash';
  22848. } else if (c === '?') {
  22849. this._host = base._host;
  22850. this._port = base._port;
  22851. this._path = base._path.slice();
  22852. this._query = '?';
  22853. this._username = base._username;
  22854. this._password = base._password;
  22855. state = 'query';
  22856. } else if (c === '#') {
  22857. this._host = base._host;
  22858. this._port = base._port;
  22859. this._path = base._path.slice();
  22860. this._query = base._query;
  22861. this._fragment = '#';
  22862. this._username = base._username;
  22863. this._password = base._password;
  22864. state = 'fragment';
  22865. } else {
  22866. var nextC = input[cursor + 1];
  22867. var nextNextC = input[cursor + 2];
  22868. if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') {
  22869. this._host = base._host;
  22870. this._port = base._port;
  22871. this._username = base._username;
  22872. this._password = base._password;
  22873. this._path = base._path.slice();
  22874. this._path.pop();
  22875. }
  22876. state = 'relative path';
  22877. continue;
  22878. }
  22879. break;
  22880. case 'relative slash':
  22881. if (c === '/' || c === '\\') {
  22882. if (c === '\\') {
  22883. err('\\ is an invalid code point.');
  22884. }
  22885. if (this._scheme === 'file') {
  22886. state = 'file host';
  22887. } else {
  22888. state = 'authority ignore slashes';
  22889. }
  22890. } else {
  22891. if (this._scheme !== 'file') {
  22892. this._host = base._host;
  22893. this._port = base._port;
  22894. this._username = base._username;
  22895. this._password = base._password;
  22896. }
  22897. state = 'relative path';
  22898. continue;
  22899. }
  22900. break;
  22901. case 'authority first slash':
  22902. if (c === '/') {
  22903. state = 'authority second slash';
  22904. } else {
  22905. err('Expected \'/\', got: ' + c);
  22906. state = 'authority ignore slashes';
  22907. continue;
  22908. }
  22909. break;
  22910. case 'authority second slash':
  22911. state = 'authority ignore slashes';
  22912. if (c !== '/') {
  22913. err('Expected \'/\', got: ' + c);
  22914. continue;
  22915. }
  22916. break;
  22917. case 'authority ignore slashes':
  22918. if (c !== '/' && c !== '\\') {
  22919. state = 'authority';
  22920. continue;
  22921. } else {
  22922. err('Expected authority, got: ' + c);
  22923. }
  22924. break;
  22925. case 'authority':
  22926. if (c === '@') {
  22927. if (seenAt) {
  22928. err('@ already seen.');
  22929. buffer += '%40';
  22930. }
  22931. seenAt = true;
  22932. for (var i = 0; i < buffer.length; i++) {
  22933. var cp = buffer[i];
  22934. if (cp === '\t' || cp === '\n' || cp === '\r') {
  22935. err('Invalid whitespace in authority.');
  22936. continue;
  22937. }
  22938. if (cp === ':' && this._password === null) {
  22939. this._password = '';
  22940. continue;
  22941. }
  22942. var tempC = percentEscape(cp);
  22943. if (this._password !== null) {
  22944. this._password += tempC;
  22945. } else {
  22946. this._username += tempC;
  22947. }
  22948. }
  22949. buffer = '';
  22950. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  22951. cursor -= buffer.length;
  22952. buffer = '';
  22953. state = 'host';
  22954. continue;
  22955. } else {
  22956. buffer += c;
  22957. }
  22958. break;
  22959. case 'file host':
  22960. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  22961. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  22962. state = 'relative path';
  22963. } else if (buffer.length === 0) {
  22964. state = 'relative path start';
  22965. } else {
  22966. this._host = IDNAToASCII.call(this, buffer);
  22967. buffer = '';
  22968. state = 'relative path start';
  22969. }
  22970. continue;
  22971. } else if (c === '\t' || c === '\n' || c === '\r') {
  22972. err('Invalid whitespace in file host.');
  22973. } else {
  22974. buffer += c;
  22975. }
  22976. break;
  22977. case 'host':
  22978. case 'hostname':
  22979. if (c === ':' && !seenBracket) {
  22980. this._host = IDNAToASCII.call(this, buffer);
  22981. buffer = '';
  22982. state = 'port';
  22983. if (stateOverride === 'hostname') {
  22984. break loop;
  22985. }
  22986. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  22987. this._host = IDNAToASCII.call(this, buffer);
  22988. buffer = '';
  22989. state = 'relative path start';
  22990. if (stateOverride) {
  22991. break loop;
  22992. }
  22993. continue;
  22994. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  22995. if (c === '[') {
  22996. seenBracket = true;
  22997. } else if (c === ']') {
  22998. seenBracket = false;
  22999. }
  23000. buffer += c;
  23001. } else {
  23002. err('Invalid code point in host/hostname: ' + c);
  23003. }
  23004. break;
  23005. case 'port':
  23006. if (/[0-9]/.test(c)) {
  23007. buffer += c;
  23008. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  23009. if (buffer !== '') {
  23010. var temp = parseInt(buffer, 10);
  23011. if (temp !== relative[this._scheme]) {
  23012. this._port = temp + '';
  23013. }
  23014. buffer = '';
  23015. }
  23016. if (stateOverride) {
  23017. break loop;
  23018. }
  23019. state = 'relative path start';
  23020. continue;
  23021. } else if (c === '\t' || c === '\n' || c === '\r') {
  23022. err('Invalid code point in port: ' + c);
  23023. } else {
  23024. invalid.call(this);
  23025. }
  23026. break;
  23027. case 'relative path start':
  23028. if (c === '\\') {
  23029. err('\'\\\' not allowed in path.');
  23030. }
  23031. state = 'relative path';
  23032. if (c !== '/' && c !== '\\') {
  23033. continue;
  23034. }
  23035. break;
  23036. case 'relative path':
  23037. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  23038. if (c === '\\') {
  23039. err('\\ not allowed in relative path.');
  23040. }
  23041. var tmp;
  23042. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  23043. buffer = tmp;
  23044. }
  23045. if (buffer === '..') {
  23046. this._path.pop();
  23047. if (c !== '/' && c !== '\\') {
  23048. this._path.push('');
  23049. }
  23050. } else if (buffer === '.' && c !== '/' && c !== '\\') {
  23051. this._path.push('');
  23052. } else if (buffer !== '.') {
  23053. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  23054. buffer = buffer[0] + ':';
  23055. }
  23056. this._path.push(buffer);
  23057. }
  23058. buffer = '';
  23059. if (c === '?') {
  23060. this._query = '?';
  23061. state = 'query';
  23062. } else if (c === '#') {
  23063. this._fragment = '#';
  23064. state = 'fragment';
  23065. }
  23066. } else if (c !== '\t' && c !== '\n' && c !== '\r') {
  23067. buffer += percentEscape(c);
  23068. }
  23069. break;
  23070. case 'query':
  23071. if (!stateOverride && c === '#') {
  23072. this._fragment = '#';
  23073. state = 'fragment';
  23074. } else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  23075. this._query += percentEscapeQuery(c);
  23076. }
  23077. break;
  23078. case 'fragment':
  23079. if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
  23080. this._fragment += c;
  23081. }
  23082. break;
  23083. }
  23084. cursor++;
  23085. }
  23086. }
  23087. function clear() {
  23088. this._scheme = '';
  23089. this._schemeData = '';
  23090. this._username = '';
  23091. this._password = null;
  23092. this._host = '';
  23093. this._port = '';
  23094. this._path = [];
  23095. this._query = '';
  23096. this._fragment = '';
  23097. this._isInvalid = false;
  23098. this._isRelative = false;
  23099. }
  23100. function JURL(url, base) {
  23101. if (base !== undefined && !(base instanceof JURL)) {
  23102. base = new JURL(String(base));
  23103. }
  23104. this._url = url;
  23105. clear.call(this);
  23106. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  23107. parse.call(this, input, null, base);
  23108. }
  23109. JURL.prototype = {
  23110. toString: function toString() {
  23111. return this.href;
  23112. },
  23113. get href() {
  23114. if (this._isInvalid) {
  23115. return this._url;
  23116. }
  23117. var authority = '';
  23118. if (this._username !== '' || this._password !== null) {
  23119. authority = this._username + (this._password !== null ? ':' + this._password : '') + '@';
  23120. }
  23121. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  23122. },
  23123. set href(value) {
  23124. clear.call(this);
  23125. parse.call(this, value);
  23126. },
  23127. get protocol() {
  23128. return this._scheme + ':';
  23129. },
  23130. set protocol(value) {
  23131. if (this._isInvalid) {
  23132. return;
  23133. }
  23134. parse.call(this, value + ':', 'scheme start');
  23135. },
  23136. get host() {
  23137. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  23138. },
  23139. set host(value) {
  23140. if (this._isInvalid || !this._isRelative) {
  23141. return;
  23142. }
  23143. parse.call(this, value, 'host');
  23144. },
  23145. get hostname() {
  23146. return this._host;
  23147. },
  23148. set hostname(value) {
  23149. if (this._isInvalid || !this._isRelative) {
  23150. return;
  23151. }
  23152. parse.call(this, value, 'hostname');
  23153. },
  23154. get port() {
  23155. return this._port;
  23156. },
  23157. set port(value) {
  23158. if (this._isInvalid || !this._isRelative) {
  23159. return;
  23160. }
  23161. parse.call(this, value, 'port');
  23162. },
  23163. get pathname() {
  23164. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  23165. },
  23166. set pathname(value) {
  23167. if (this._isInvalid || !this._isRelative) {
  23168. return;
  23169. }
  23170. this._path = [];
  23171. parse.call(this, value, 'relative path start');
  23172. },
  23173. get search() {
  23174. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  23175. },
  23176. set search(value) {
  23177. if (this._isInvalid || !this._isRelative) {
  23178. return;
  23179. }
  23180. this._query = '?';
  23181. if (value[0] === '?') {
  23182. value = value.slice(1);
  23183. }
  23184. parse.call(this, value, 'query');
  23185. },
  23186. get hash() {
  23187. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  23188. },
  23189. set hash(value) {
  23190. if (this._isInvalid) {
  23191. return;
  23192. }
  23193. this._fragment = '#';
  23194. if (value[0] === '#') {
  23195. value = value.slice(1);
  23196. }
  23197. parse.call(this, value, 'fragment');
  23198. },
  23199. get origin() {
  23200. var host;
  23201. if (this._isInvalid || !this._scheme) {
  23202. return '';
  23203. }
  23204. switch (this._scheme) {
  23205. case 'data':
  23206. case 'file':
  23207. case 'javascript':
  23208. case 'mailto':
  23209. return 'null';
  23210. case 'blob':
  23211. try {
  23212. return new JURL(this._schemeData).origin || 'null';
  23213. } catch (_) {}
  23214. return 'null';
  23215. }
  23216. host = this.host;
  23217. if (!host) {
  23218. return '';
  23219. }
  23220. return this._scheme + '://' + host;
  23221. }
  23222. };
  23223. var OriginalURL = globalScope.URL;
  23224. if (OriginalURL) {
  23225. JURL.createObjectURL = function (blob) {
  23226. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  23227. };
  23228. JURL.revokeObjectURL = function (url) {
  23229. OriginalURL.revokeObjectURL(url);
  23230. };
  23231. }
  23232. globalScope.URL = JURL;
  23233. })();
  23234. }
  23235. /***/ }),
  23236. /* 73 */
  23237. /***/ (function(module, exports, __w_pdfjs_require__) {
  23238. "use strict";
  23239. module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
  23240. /***/ }),
  23241. /* 74 */
  23242. /***/ (function(module, exports, __w_pdfjs_require__) {
  23243. "use strict";
  23244. __w_pdfjs_require__(75);
  23245. module.exports = __w_pdfjs_require__(7).Object.values;
  23246. /***/ }),
  23247. /* 75 */
  23248. /***/ (function(module, exports, __w_pdfjs_require__) {
  23249. "use strict";
  23250. var $export = __w_pdfjs_require__(6);
  23251. var $values = __w_pdfjs_require__(76)(false);
  23252. $export($export.S, 'Object', {
  23253. values: function values(it) {
  23254. return $values(it);
  23255. }
  23256. });
  23257. /***/ }),
  23258. /* 76 */
  23259. /***/ (function(module, exports, __w_pdfjs_require__) {
  23260. "use strict";
  23261. var getKeys = __w_pdfjs_require__(23);
  23262. var toIObject = __w_pdfjs_require__(17);
  23263. var isEnum = __w_pdfjs_require__(34).f;
  23264. module.exports = function (isEntries) {
  23265. return function (it) {
  23266. var O = toIObject(it);
  23267. var keys = getKeys(O);
  23268. var length = keys.length;
  23269. var i = 0;
  23270. var result = [];
  23271. var key;
  23272. while (length > i) {
  23273. if (isEnum.call(O, key = keys[i++])) {
  23274. result.push(isEntries ? [key, O[key]] : O[key]);
  23275. }
  23276. }return result;
  23277. };
  23278. };
  23279. /***/ }),
  23280. /* 77 */
  23281. /***/ (function(module, exports, __w_pdfjs_require__) {
  23282. "use strict";
  23283. var has = __w_pdfjs_require__(9);
  23284. var toIObject = __w_pdfjs_require__(17);
  23285. var arrayIndexOf = __w_pdfjs_require__(45)(false);
  23286. var IE_PROTO = __w_pdfjs_require__(33)('IE_PROTO');
  23287. module.exports = function (object, names) {
  23288. var O = toIObject(object);
  23289. var i = 0;
  23290. var result = [];
  23291. var key;
  23292. for (key in O) {
  23293. if (key != IE_PROTO) has(O, key) && result.push(key);
  23294. }while (names.length > i) {
  23295. if (has(O, key = names[i++])) {
  23296. ~arrayIndexOf(result, key) || result.push(key);
  23297. }
  23298. }return result;
  23299. };
  23300. /***/ }),
  23301. /* 78 */
  23302. /***/ (function(module, exports, __w_pdfjs_require__) {
  23303. "use strict";
  23304. var toInteger = __w_pdfjs_require__(32);
  23305. var max = Math.max;
  23306. var min = Math.min;
  23307. module.exports = function (index, length) {
  23308. index = toInteger(index);
  23309. return index < 0 ? max(index + length, 0) : min(index, length);
  23310. };
  23311. /***/ }),
  23312. /* 79 */
  23313. /***/ (function(module, exports, __w_pdfjs_require__) {
  23314. "use strict";
  23315. __w_pdfjs_require__(80);
  23316. module.exports = __w_pdfjs_require__(7).Array.includes;
  23317. /***/ }),
  23318. /* 80 */
  23319. /***/ (function(module, exports, __w_pdfjs_require__) {
  23320. "use strict";
  23321. var $export = __w_pdfjs_require__(6);
  23322. var $includes = __w_pdfjs_require__(45)(true);
  23323. $export($export.P, 'Array', {
  23324. includes: function includes(el) {
  23325. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  23326. }
  23327. });
  23328. __w_pdfjs_require__(48)('includes');
  23329. /***/ }),
  23330. /* 81 */
  23331. /***/ (function(module, exports, __w_pdfjs_require__) {
  23332. "use strict";
  23333. __w_pdfjs_require__(82);
  23334. module.exports = __w_pdfjs_require__(7).Number.isNaN;
  23335. /***/ }),
  23336. /* 82 */
  23337. /***/ (function(module, exports, __w_pdfjs_require__) {
  23338. "use strict";
  23339. var $export = __w_pdfjs_require__(6);
  23340. $export($export.S, 'Number', {
  23341. isNaN: function isNaN(number) {
  23342. return number != number;
  23343. }
  23344. });
  23345. /***/ }),
  23346. /* 83 */
  23347. /***/ (function(module, exports, __w_pdfjs_require__) {
  23348. "use strict";
  23349. __w_pdfjs_require__(84);
  23350. module.exports = __w_pdfjs_require__(7).Number.isInteger;
  23351. /***/ }),
  23352. /* 84 */
  23353. /***/ (function(module, exports, __w_pdfjs_require__) {
  23354. "use strict";
  23355. var $export = __w_pdfjs_require__(6);
  23356. $export($export.S, 'Number', { isInteger: __w_pdfjs_require__(85) });
  23357. /***/ }),
  23358. /* 85 */
  23359. /***/ (function(module, exports, __w_pdfjs_require__) {
  23360. "use strict";
  23361. var isObject = __w_pdfjs_require__(2);
  23362. var floor = Math.floor;
  23363. module.exports = function isInteger(it) {
  23364. return !isObject(it) && isFinite(it) && floor(it) === it;
  23365. };
  23366. /***/ }),
  23367. /* 86 */
  23368. /***/ (function(module, exports, __w_pdfjs_require__) {
  23369. "use strict";
  23370. __w_pdfjs_require__(49);
  23371. __w_pdfjs_require__(87);
  23372. __w_pdfjs_require__(53);
  23373. __w_pdfjs_require__(95);
  23374. __w_pdfjs_require__(102);
  23375. __w_pdfjs_require__(103);
  23376. module.exports = __w_pdfjs_require__(7).Promise;
  23377. /***/ }),
  23378. /* 87 */
  23379. /***/ (function(module, exports, __w_pdfjs_require__) {
  23380. "use strict";
  23381. var $at = __w_pdfjs_require__(88)(true);
  23382. __w_pdfjs_require__(50)(String, 'String', function (iterated) {
  23383. this._t = String(iterated);
  23384. this._i = 0;
  23385. }, function () {
  23386. var O = this._t;
  23387. var index = this._i;
  23388. var point;
  23389. if (index >= O.length) return {
  23390. value: undefined,
  23391. done: true
  23392. };
  23393. point = $at(O, index);
  23394. this._i += point.length;
  23395. return {
  23396. value: point,
  23397. done: false
  23398. };
  23399. });
  23400. /***/ }),
  23401. /* 88 */
  23402. /***/ (function(module, exports, __w_pdfjs_require__) {
  23403. "use strict";
  23404. var toInteger = __w_pdfjs_require__(32);
  23405. var defined = __w_pdfjs_require__(30);
  23406. module.exports = function (TO_STRING) {
  23407. return function (that, pos) {
  23408. var s = String(defined(that));
  23409. var i = toInteger(pos);
  23410. var l = s.length;
  23411. var a, b;
  23412. if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
  23413. a = s.charCodeAt(i);
  23414. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  23415. };
  23416. };
  23417. /***/ }),
  23418. /* 89 */
  23419. /***/ (function(module, exports, __w_pdfjs_require__) {
  23420. "use strict";
  23421. var create = __w_pdfjs_require__(90);
  23422. var descriptor = __w_pdfjs_require__(28);
  23423. var setToStringTag = __w_pdfjs_require__(24);
  23424. var IteratorPrototype = {};
  23425. __w_pdfjs_require__(12)(IteratorPrototype, __w_pdfjs_require__(3)('iterator'), function () {
  23426. return this;
  23427. });
  23428. module.exports = function (Constructor, NAME, next) {
  23429. Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
  23430. setToStringTag(Constructor, NAME + ' Iterator');
  23431. };
  23432. /***/ }),
  23433. /* 90 */
  23434. /***/ (function(module, exports, __w_pdfjs_require__) {
  23435. "use strict";
  23436. var anObject = __w_pdfjs_require__(8);
  23437. var dPs = __w_pdfjs_require__(91);
  23438. var enumBugKeys = __w_pdfjs_require__(47);
  23439. var IE_PROTO = __w_pdfjs_require__(33)('IE_PROTO');
  23440. var Empty = function Empty() {};
  23441. var PROTOTYPE = 'prototype';
  23442. var _createDict = function createDict() {
  23443. var iframe = __w_pdfjs_require__(27)('iframe');
  23444. var i = enumBugKeys.length;
  23445. var lt = '<';
  23446. var gt = '>';
  23447. var iframeDocument;
  23448. iframe.style.display = 'none';
  23449. __w_pdfjs_require__(52).appendChild(iframe);
  23450. iframe.src = 'javascript:';
  23451. iframeDocument = iframe.contentWindow.document;
  23452. iframeDocument.open();
  23453. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  23454. iframeDocument.close();
  23455. _createDict = iframeDocument.F;
  23456. while (i--) {
  23457. delete _createDict[PROTOTYPE][enumBugKeys[i]];
  23458. }return _createDict();
  23459. };
  23460. module.exports = Object.create || function create(O, Properties) {
  23461. var result;
  23462. if (O !== null) {
  23463. Empty[PROTOTYPE] = anObject(O);
  23464. result = new Empty();
  23465. Empty[PROTOTYPE] = null;
  23466. result[IE_PROTO] = O;
  23467. } else result = _createDict();
  23468. return Properties === undefined ? result : dPs(result, Properties);
  23469. };
  23470. /***/ }),
  23471. /* 91 */
  23472. /***/ (function(module, exports, __w_pdfjs_require__) {
  23473. "use strict";
  23474. var dP = __w_pdfjs_require__(15);
  23475. var anObject = __w_pdfjs_require__(8);
  23476. var getKeys = __w_pdfjs_require__(23);
  23477. module.exports = __w_pdfjs_require__(13) ? Object.defineProperties : function defineProperties(O, Properties) {
  23478. anObject(O);
  23479. var keys = getKeys(Properties);
  23480. var length = keys.length;
  23481. var i = 0;
  23482. var P;
  23483. while (length > i) {
  23484. dP.f(O, P = keys[i++], Properties[P]);
  23485. }return O;
  23486. };
  23487. /***/ }),
  23488. /* 92 */
  23489. /***/ (function(module, exports, __w_pdfjs_require__) {
  23490. "use strict";
  23491. var has = __w_pdfjs_require__(9);
  23492. var toObject = __w_pdfjs_require__(36);
  23493. var IE_PROTO = __w_pdfjs_require__(33)('IE_PROTO');
  23494. var ObjectProto = Object.prototype;
  23495. module.exports = Object.getPrototypeOf || function (O) {
  23496. O = toObject(O);
  23497. if (has(O, IE_PROTO)) return O[IE_PROTO];
  23498. if (typeof O.constructor == 'function' && O instanceof O.constructor) {
  23499. return O.constructor.prototype;
  23500. }
  23501. return O instanceof Object ? ObjectProto : null;
  23502. };
  23503. /***/ }),
  23504. /* 93 */
  23505. /***/ (function(module, exports, __w_pdfjs_require__) {
  23506. "use strict";
  23507. var addToUnscopables = __w_pdfjs_require__(48);
  23508. var step = __w_pdfjs_require__(94);
  23509. var Iterators = __w_pdfjs_require__(19);
  23510. var toIObject = __w_pdfjs_require__(17);
  23511. module.exports = __w_pdfjs_require__(50)(Array, 'Array', function (iterated, kind) {
  23512. this._t = toIObject(iterated);
  23513. this._i = 0;
  23514. this._k = kind;
  23515. }, function () {
  23516. var O = this._t;
  23517. var kind = this._k;
  23518. var index = this._i++;
  23519. if (!O || index >= O.length) {
  23520. this._t = undefined;
  23521. return step(1);
  23522. }
  23523. if (kind == 'keys') return step(0, index);
  23524. if (kind == 'values') return step(0, O[index]);
  23525. return step(0, [index, O[index]]);
  23526. }, 'values');
  23527. Iterators.Arguments = Iterators.Array;
  23528. addToUnscopables('keys');
  23529. addToUnscopables('values');
  23530. addToUnscopables('entries');
  23531. /***/ }),
  23532. /* 94 */
  23533. /***/ (function(module, exports, __w_pdfjs_require__) {
  23534. "use strict";
  23535. module.exports = function (done, value) {
  23536. return {
  23537. value: value,
  23538. done: !!done
  23539. };
  23540. };
  23541. /***/ }),
  23542. /* 95 */
  23543. /***/ (function(module, exports, __w_pdfjs_require__) {
  23544. "use strict";
  23545. var LIBRARY = __w_pdfjs_require__(51);
  23546. var global = __w_pdfjs_require__(4);
  23547. var ctx = __w_pdfjs_require__(11);
  23548. var classof = __w_pdfjs_require__(35);
  23549. var $export = __w_pdfjs_require__(6);
  23550. var isObject = __w_pdfjs_require__(2);
  23551. var aFunction = __w_pdfjs_require__(16);
  23552. var anInstance = __w_pdfjs_require__(37);
  23553. var forOf = __w_pdfjs_require__(25);
  23554. var speciesConstructor = __w_pdfjs_require__(54);
  23555. var task = __w_pdfjs_require__(55).set;
  23556. var microtask = __w_pdfjs_require__(100)();
  23557. var newPromiseCapabilityModule = __w_pdfjs_require__(38);
  23558. var perform = __w_pdfjs_require__(56);
  23559. var promiseResolve = __w_pdfjs_require__(57);
  23560. var PROMISE = 'Promise';
  23561. var TypeError = global.TypeError;
  23562. var process = global.process;
  23563. var $Promise = global[PROMISE];
  23564. var isNode = classof(process) == 'process';
  23565. var empty = function empty() {};
  23566. var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
  23567. var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
  23568. var USE_NATIVE = !!function () {
  23569. try {
  23570. var promise = $Promise.resolve(1);
  23571. var FakePromise = (promise.constructor = {})[__w_pdfjs_require__(3)('species')] = function (exec) {
  23572. exec(empty, empty);
  23573. };
  23574. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  23575. } catch (e) {}
  23576. }();
  23577. var isThenable = function isThenable(it) {
  23578. var then;
  23579. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  23580. };
  23581. var notify = function notify(promise, isReject) {
  23582. if (promise._n) return;
  23583. promise._n = true;
  23584. var chain = promise._c;
  23585. microtask(function () {
  23586. var value = promise._v;
  23587. var ok = promise._s == 1;
  23588. var i = 0;
  23589. var run = function run(reaction) {
  23590. var handler = ok ? reaction.ok : reaction.fail;
  23591. var resolve = reaction.resolve;
  23592. var reject = reaction.reject;
  23593. var domain = reaction.domain;
  23594. var result, then;
  23595. try {
  23596. if (handler) {
  23597. if (!ok) {
  23598. if (promise._h == 2) onHandleUnhandled(promise);
  23599. promise._h = 1;
  23600. }
  23601. if (handler === true) result = value;else {
  23602. if (domain) domain.enter();
  23603. result = handler(value);
  23604. if (domain) domain.exit();
  23605. }
  23606. if (result === reaction.promise) {
  23607. reject(TypeError('Promise-chain cycle'));
  23608. } else if (then = isThenable(result)) {
  23609. then.call(result, resolve, reject);
  23610. } else resolve(result);
  23611. } else reject(value);
  23612. } catch (e) {
  23613. reject(e);
  23614. }
  23615. };
  23616. while (chain.length > i) {
  23617. run(chain[i++]);
  23618. }promise._c = [];
  23619. promise._n = false;
  23620. if (isReject && !promise._h) onUnhandled(promise);
  23621. });
  23622. };
  23623. var onUnhandled = function onUnhandled(promise) {
  23624. task.call(global, function () {
  23625. var value = promise._v;
  23626. var unhandled = isUnhandled(promise);
  23627. var result, handler, console;
  23628. if (unhandled) {
  23629. result = perform(function () {
  23630. if (isNode) {
  23631. process.emit('unhandledRejection', value, promise);
  23632. } else if (handler = global.onunhandledrejection) {
  23633. handler({
  23634. promise: promise,
  23635. reason: value
  23636. });
  23637. } else if ((console = global.console) && console.error) {
  23638. console.error('Unhandled promise rejection', value);
  23639. }
  23640. });
  23641. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  23642. }
  23643. promise._a = undefined;
  23644. if (unhandled && result.e) throw result.v;
  23645. });
  23646. };
  23647. var isUnhandled = function isUnhandled(promise) {
  23648. if (promise._h == 1) return false;
  23649. var chain = promise._a || promise._c;
  23650. var i = 0;
  23651. var reaction;
  23652. while (chain.length > i) {
  23653. reaction = chain[i++];
  23654. if (reaction.fail || !isUnhandled(reaction.promise)) return false;
  23655. }
  23656. return true;
  23657. };
  23658. var onHandleUnhandled = function onHandleUnhandled(promise) {
  23659. task.call(global, function () {
  23660. var handler;
  23661. if (isNode) {
  23662. process.emit('rejectionHandled', promise);
  23663. } else if (handler = global.onrejectionhandled) {
  23664. handler({
  23665. promise: promise,
  23666. reason: promise._v
  23667. });
  23668. }
  23669. });
  23670. };
  23671. var $reject = function $reject(value) {
  23672. var promise = this;
  23673. if (promise._d) return;
  23674. promise._d = true;
  23675. promise = promise._w || promise;
  23676. promise._v = value;
  23677. promise._s = 2;
  23678. if (!promise._a) promise._a = promise._c.slice();
  23679. notify(promise, true);
  23680. };
  23681. var $resolve = function $resolve(value) {
  23682. var promise = this;
  23683. var then;
  23684. if (promise._d) return;
  23685. promise._d = true;
  23686. promise = promise._w || promise;
  23687. try {
  23688. if (promise === value) throw TypeError("Promise can't be resolved itself");
  23689. if (then = isThenable(value)) {
  23690. microtask(function () {
  23691. var wrapper = {
  23692. _w: promise,
  23693. _d: false
  23694. };
  23695. try {
  23696. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  23697. } catch (e) {
  23698. $reject.call(wrapper, e);
  23699. }
  23700. });
  23701. } else {
  23702. promise._v = value;
  23703. promise._s = 1;
  23704. notify(promise, false);
  23705. }
  23706. } catch (e) {
  23707. $reject.call({
  23708. _w: promise,
  23709. _d: false
  23710. }, e);
  23711. }
  23712. };
  23713. if (!USE_NATIVE) {
  23714. $Promise = function Promise(executor) {
  23715. anInstance(this, $Promise, PROMISE, '_h');
  23716. aFunction(executor);
  23717. Internal.call(this);
  23718. try {
  23719. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  23720. } catch (err) {
  23721. $reject.call(this, err);
  23722. }
  23723. };
  23724. Internal = function Promise(executor) {
  23725. this._c = [];
  23726. this._a = undefined;
  23727. this._s = 0;
  23728. this._d = false;
  23729. this._v = undefined;
  23730. this._h = 0;
  23731. this._n = false;
  23732. };
  23733. Internal.prototype = __w_pdfjs_require__(39)($Promise.prototype, {
  23734. then: function then(onFulfilled, onRejected) {
  23735. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  23736. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  23737. reaction.fail = typeof onRejected == 'function' && onRejected;
  23738. reaction.domain = isNode ? process.domain : undefined;
  23739. this._c.push(reaction);
  23740. if (this._a) this._a.push(reaction);
  23741. if (this._s) notify(this, false);
  23742. return reaction.promise;
  23743. },
  23744. 'catch': function _catch(onRejected) {
  23745. return this.then(undefined, onRejected);
  23746. }
  23747. });
  23748. OwnPromiseCapability = function OwnPromiseCapability() {
  23749. var promise = new Internal();
  23750. this.promise = promise;
  23751. this.resolve = ctx($resolve, promise, 1);
  23752. this.reject = ctx($reject, promise, 1);
  23753. };
  23754. newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) {
  23755. return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C);
  23756. };
  23757. }
  23758. $export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
  23759. __w_pdfjs_require__(24)($Promise, PROMISE);
  23760. __w_pdfjs_require__(101)(PROMISE);
  23761. Wrapper = __w_pdfjs_require__(7)[PROMISE];
  23762. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  23763. reject: function reject(r) {
  23764. var capability = newPromiseCapability(this);
  23765. var $$reject = capability.reject;
  23766. $$reject(r);
  23767. return capability.promise;
  23768. }
  23769. });
  23770. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  23771. resolve: function resolve(x) {
  23772. return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
  23773. }
  23774. });
  23775. $export($export.S + $export.F * !(USE_NATIVE && __w_pdfjs_require__(58)(function (iter) {
  23776. $Promise.all(iter)['catch'](empty);
  23777. })), PROMISE, {
  23778. all: function all(iterable) {
  23779. var C = this;
  23780. var capability = newPromiseCapability(C);
  23781. var resolve = capability.resolve;
  23782. var reject = capability.reject;
  23783. var result = perform(function () {
  23784. var values = [];
  23785. var index = 0;
  23786. var remaining = 1;
  23787. forOf(iterable, false, function (promise) {
  23788. var $index = index++;
  23789. var alreadyCalled = false;
  23790. values.push(undefined);
  23791. remaining++;
  23792. C.resolve(promise).then(function (value) {
  23793. if (alreadyCalled) return;
  23794. alreadyCalled = true;
  23795. values[$index] = value;
  23796. --remaining || resolve(values);
  23797. }, reject);
  23798. });
  23799. --remaining || resolve(values);
  23800. });
  23801. if (result.e) reject(result.v);
  23802. return capability.promise;
  23803. },
  23804. race: function race(iterable) {
  23805. var C = this;
  23806. var capability = newPromiseCapability(C);
  23807. var reject = capability.reject;
  23808. var result = perform(function () {
  23809. forOf(iterable, false, function (promise) {
  23810. C.resolve(promise).then(capability.resolve, reject);
  23811. });
  23812. });
  23813. if (result.e) reject(result.v);
  23814. return capability.promise;
  23815. }
  23816. });
  23817. /***/ }),
  23818. /* 96 */
  23819. /***/ (function(module, exports, __w_pdfjs_require__) {
  23820. "use strict";
  23821. var anObject = __w_pdfjs_require__(8);
  23822. module.exports = function (iterator, fn, value, entries) {
  23823. try {
  23824. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  23825. } catch (e) {
  23826. var ret = iterator['return'];
  23827. if (ret !== undefined) anObject(ret.call(iterator));
  23828. throw e;
  23829. }
  23830. };
  23831. /***/ }),
  23832. /* 97 */
  23833. /***/ (function(module, exports, __w_pdfjs_require__) {
  23834. "use strict";
  23835. var Iterators = __w_pdfjs_require__(19);
  23836. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  23837. var ArrayProto = Array.prototype;
  23838. module.exports = function (it) {
  23839. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  23840. };
  23841. /***/ }),
  23842. /* 98 */
  23843. /***/ (function(module, exports, __w_pdfjs_require__) {
  23844. "use strict";
  23845. var classof = __w_pdfjs_require__(35);
  23846. var ITERATOR = __w_pdfjs_require__(3)('iterator');
  23847. var Iterators = __w_pdfjs_require__(19);
  23848. module.exports = __w_pdfjs_require__(7).getIteratorMethod = function (it) {
  23849. if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)];
  23850. };
  23851. /***/ }),
  23852. /* 99 */
  23853. /***/ (function(module, exports, __w_pdfjs_require__) {
  23854. "use strict";
  23855. module.exports = function (fn, args, that) {
  23856. var un = that === undefined;
  23857. switch (args.length) {
  23858. case 0:
  23859. return un ? fn() : fn.call(that);
  23860. case 1:
  23861. return un ? fn(args[0]) : fn.call(that, args[0]);
  23862. case 2:
  23863. return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]);
  23864. case 3:
  23865. return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]);
  23866. case 4:
  23867. return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]);
  23868. }
  23869. return fn.apply(that, args);
  23870. };
  23871. /***/ }),
  23872. /* 100 */
  23873. /***/ (function(module, exports, __w_pdfjs_require__) {
  23874. "use strict";
  23875. var global = __w_pdfjs_require__(4);
  23876. var macrotask = __w_pdfjs_require__(55).set;
  23877. var Observer = global.MutationObserver || global.WebKitMutationObserver;
  23878. var process = global.process;
  23879. var Promise = global.Promise;
  23880. var isNode = __w_pdfjs_require__(18)(process) == 'process';
  23881. module.exports = function () {
  23882. var head, last, notify;
  23883. var flush = function flush() {
  23884. var parent, fn;
  23885. if (isNode && (parent = process.domain)) parent.exit();
  23886. while (head) {
  23887. fn = head.fn;
  23888. head = head.next;
  23889. try {
  23890. fn();
  23891. } catch (e) {
  23892. if (head) notify();else last = undefined;
  23893. throw e;
  23894. }
  23895. }
  23896. last = undefined;
  23897. if (parent) parent.enter();
  23898. };
  23899. if (isNode) {
  23900. notify = function notify() {
  23901. process.nextTick(flush);
  23902. };
  23903. } else if (Observer) {
  23904. var toggle = true;
  23905. var node = document.createTextNode('');
  23906. new Observer(flush).observe(node, { characterData: true });
  23907. notify = function notify() {
  23908. node.data = toggle = !toggle;
  23909. };
  23910. } else if (Promise && Promise.resolve) {
  23911. var promise = Promise.resolve();
  23912. notify = function notify() {
  23913. promise.then(flush);
  23914. };
  23915. } else {
  23916. notify = function notify() {
  23917. macrotask.call(global, flush);
  23918. };
  23919. }
  23920. return function (fn) {
  23921. var task = {
  23922. fn: fn,
  23923. next: undefined
  23924. };
  23925. if (last) last.next = task;
  23926. if (!head) {
  23927. head = task;
  23928. notify();
  23929. }
  23930. last = task;
  23931. };
  23932. };
  23933. /***/ }),
  23934. /* 101 */
  23935. /***/ (function(module, exports, __w_pdfjs_require__) {
  23936. "use strict";
  23937. var global = __w_pdfjs_require__(4);
  23938. var dP = __w_pdfjs_require__(15);
  23939. var DESCRIPTORS = __w_pdfjs_require__(13);
  23940. var SPECIES = __w_pdfjs_require__(3)('species');
  23941. module.exports = function (KEY) {
  23942. var C = global[KEY];
  23943. if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
  23944. configurable: true,
  23945. get: function get() {
  23946. return this;
  23947. }
  23948. });
  23949. };
  23950. /***/ }),
  23951. /* 102 */
  23952. /***/ (function(module, exports, __w_pdfjs_require__) {
  23953. "use strict";
  23954. var $export = __w_pdfjs_require__(6);
  23955. var core = __w_pdfjs_require__(7);
  23956. var global = __w_pdfjs_require__(4);
  23957. var speciesConstructor = __w_pdfjs_require__(54);
  23958. var promiseResolve = __w_pdfjs_require__(57);
  23959. $export($export.P + $export.R, 'Promise', {
  23960. 'finally': function _finally(onFinally) {
  23961. var C = speciesConstructor(this, core.Promise || global.Promise);
  23962. var isFunction = typeof onFinally == 'function';
  23963. return this.then(isFunction ? function (x) {
  23964. return promiseResolve(C, onFinally()).then(function () {
  23965. return x;
  23966. });
  23967. } : onFinally, isFunction ? function (e) {
  23968. return promiseResolve(C, onFinally()).then(function () {
  23969. throw e;
  23970. });
  23971. } : onFinally);
  23972. }
  23973. });
  23974. /***/ }),
  23975. /* 103 */
  23976. /***/ (function(module, exports, __w_pdfjs_require__) {
  23977. "use strict";
  23978. var $export = __w_pdfjs_require__(6);
  23979. var newPromiseCapability = __w_pdfjs_require__(38);
  23980. var perform = __w_pdfjs_require__(56);
  23981. $export($export.S, 'Promise', {
  23982. 'try': function _try(callbackfn) {
  23983. var promiseCapability = newPromiseCapability.f(this);
  23984. var result = perform(callbackfn);
  23985. (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
  23986. return promiseCapability.promise;
  23987. }
  23988. });
  23989. /***/ }),
  23990. /* 104 */
  23991. /***/ (function(module, exports, __w_pdfjs_require__) {
  23992. "use strict";
  23993. __w_pdfjs_require__(49);
  23994. __w_pdfjs_require__(53);
  23995. __w_pdfjs_require__(105);
  23996. __w_pdfjs_require__(116);
  23997. __w_pdfjs_require__(118);
  23998. module.exports = __w_pdfjs_require__(7).WeakMap;
  23999. /***/ }),
  24000. /* 105 */
  24001. /***/ (function(module, exports, __w_pdfjs_require__) {
  24002. "use strict";
  24003. var each = __w_pdfjs_require__(59)(0);
  24004. var redefine = __w_pdfjs_require__(10);
  24005. var meta = __w_pdfjs_require__(40);
  24006. var assign = __w_pdfjs_require__(109);
  24007. var weak = __w_pdfjs_require__(111);
  24008. var isObject = __w_pdfjs_require__(2);
  24009. var fails = __w_pdfjs_require__(14);
  24010. var validate = __w_pdfjs_require__(60);
  24011. var WEAK_MAP = 'WeakMap';
  24012. var getWeak = meta.getWeak;
  24013. var isExtensible = Object.isExtensible;
  24014. var uncaughtFrozenStore = weak.ufstore;
  24015. var tmp = {};
  24016. var InternalMap;
  24017. var wrapper = function wrapper(get) {
  24018. return function WeakMap() {
  24019. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  24020. };
  24021. };
  24022. var methods = {
  24023. get: function get(key) {
  24024. if (isObject(key)) {
  24025. var data = getWeak(key);
  24026. if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
  24027. return data ? data[this._i] : undefined;
  24028. }
  24029. },
  24030. set: function set(key, value) {
  24031. return weak.def(validate(this, WEAK_MAP), key, value);
  24032. }
  24033. };
  24034. var $WeakMap = module.exports = __w_pdfjs_require__(112)(WEAK_MAP, wrapper, methods, weak, true, true);
  24035. if (fails(function () {
  24036. return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7;
  24037. })) {
  24038. InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  24039. assign(InternalMap.prototype, methods);
  24040. meta.NEED = true;
  24041. each(['delete', 'has', 'get', 'set'], function (key) {
  24042. var proto = $WeakMap.prototype;
  24043. var method = proto[key];
  24044. redefine(proto, key, function (a, b) {
  24045. if (isObject(a) && !isExtensible(a)) {
  24046. if (!this._f) this._f = new InternalMap();
  24047. var result = this._f[key](a, b);
  24048. return key == 'set' ? this : result;
  24049. }
  24050. return method.call(this, a, b);
  24051. });
  24052. });
  24053. }
  24054. /***/ }),
  24055. /* 106 */
  24056. /***/ (function(module, exports, __w_pdfjs_require__) {
  24057. "use strict";
  24058. var speciesConstructor = __w_pdfjs_require__(107);
  24059. module.exports = function (original, length) {
  24060. return new (speciesConstructor(original))(length);
  24061. };
  24062. /***/ }),
  24063. /* 107 */
  24064. /***/ (function(module, exports, __w_pdfjs_require__) {
  24065. "use strict";
  24066. var isObject = __w_pdfjs_require__(2);
  24067. var isArray = __w_pdfjs_require__(108);
  24068. var SPECIES = __w_pdfjs_require__(3)('species');
  24069. module.exports = function (original) {
  24070. var C;
  24071. if (isArray(original)) {
  24072. C = original.constructor;
  24073. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  24074. if (isObject(C)) {
  24075. C = C[SPECIES];
  24076. if (C === null) C = undefined;
  24077. }
  24078. }
  24079. return C === undefined ? Array : C;
  24080. };
  24081. /***/ }),
  24082. /* 108 */
  24083. /***/ (function(module, exports, __w_pdfjs_require__) {
  24084. "use strict";
  24085. var cof = __w_pdfjs_require__(18);
  24086. module.exports = Array.isArray || function isArray(arg) {
  24087. return cof(arg) == 'Array';
  24088. };
  24089. /***/ }),
  24090. /* 109 */
  24091. /***/ (function(module, exports, __w_pdfjs_require__) {
  24092. "use strict";
  24093. var getKeys = __w_pdfjs_require__(23);
  24094. var gOPS = __w_pdfjs_require__(110);
  24095. var pIE = __w_pdfjs_require__(34);
  24096. var toObject = __w_pdfjs_require__(36);
  24097. var IObject = __w_pdfjs_require__(29);
  24098. var $assign = Object.assign;
  24099. module.exports = !$assign || __w_pdfjs_require__(14)(function () {
  24100. var A = {};
  24101. var B = {};
  24102. var S = Symbol();
  24103. var K = 'abcdefghijklmnopqrst';
  24104. A[S] = 7;
  24105. K.split('').forEach(function (k) {
  24106. B[k] = k;
  24107. });
  24108. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  24109. }) ? function assign(target, source) {
  24110. var T = toObject(target);
  24111. var aLen = arguments.length;
  24112. var index = 1;
  24113. var getSymbols = gOPS.f;
  24114. var isEnum = pIE.f;
  24115. while (aLen > index) {
  24116. var S = IObject(arguments[index++]);
  24117. var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
  24118. var length = keys.length;
  24119. var j = 0;
  24120. var key;
  24121. while (length > j) {
  24122. if (isEnum.call(S, key = keys[j++])) T[key] = S[key];
  24123. }
  24124. }
  24125. return T;
  24126. } : $assign;
  24127. /***/ }),
  24128. /* 110 */
  24129. /***/ (function(module, exports, __w_pdfjs_require__) {
  24130. "use strict";
  24131. exports.f = Object.getOwnPropertySymbols;
  24132. /***/ }),
  24133. /* 111 */
  24134. /***/ (function(module, exports, __w_pdfjs_require__) {
  24135. "use strict";
  24136. var redefineAll = __w_pdfjs_require__(39);
  24137. var getWeak = __w_pdfjs_require__(40).getWeak;
  24138. var anObject = __w_pdfjs_require__(8);
  24139. var isObject = __w_pdfjs_require__(2);
  24140. var anInstance = __w_pdfjs_require__(37);
  24141. var forOf = __w_pdfjs_require__(25);
  24142. var createArrayMethod = __w_pdfjs_require__(59);
  24143. var $has = __w_pdfjs_require__(9);
  24144. var validate = __w_pdfjs_require__(60);
  24145. var arrayFind = createArrayMethod(5);
  24146. var arrayFindIndex = createArrayMethod(6);
  24147. var id = 0;
  24148. var uncaughtFrozenStore = function uncaughtFrozenStore(that) {
  24149. return that._l || (that._l = new UncaughtFrozenStore());
  24150. };
  24151. var UncaughtFrozenStore = function UncaughtFrozenStore() {
  24152. this.a = [];
  24153. };
  24154. var findUncaughtFrozen = function findUncaughtFrozen(store, key) {
  24155. return arrayFind(store.a, function (it) {
  24156. return it[0] === key;
  24157. });
  24158. };
  24159. UncaughtFrozenStore.prototype = {
  24160. get: function get(key) {
  24161. var entry = findUncaughtFrozen(this, key);
  24162. if (entry) return entry[1];
  24163. },
  24164. has: function has(key) {
  24165. return !!findUncaughtFrozen(this, key);
  24166. },
  24167. set: function set(key, value) {
  24168. var entry = findUncaughtFrozen(this, key);
  24169. if (entry) entry[1] = value;else this.a.push([key, value]);
  24170. },
  24171. 'delete': function _delete(key) {
  24172. var index = arrayFindIndex(this.a, function (it) {
  24173. return it[0] === key;
  24174. });
  24175. if (~index) this.a.splice(index, 1);
  24176. return !!~index;
  24177. }
  24178. };
  24179. module.exports = {
  24180. getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) {
  24181. var C = wrapper(function (that, iterable) {
  24182. anInstance(that, C, NAME, '_i');
  24183. that._t = NAME;
  24184. that._i = id++;
  24185. that._l = undefined;
  24186. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  24187. });
  24188. redefineAll(C.prototype, {
  24189. 'delete': function _delete(key) {
  24190. if (!isObject(key)) return false;
  24191. var data = getWeak(key);
  24192. if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
  24193. return data && $has(data, this._i) && delete data[this._i];
  24194. },
  24195. has: function has(key) {
  24196. if (!isObject(key)) return false;
  24197. var data = getWeak(key);
  24198. if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
  24199. return data && $has(data, this._i);
  24200. }
  24201. });
  24202. return C;
  24203. },
  24204. def: function def(that, key, value) {
  24205. var data = getWeak(anObject(key), true);
  24206. if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value;
  24207. return that;
  24208. },
  24209. ufstore: uncaughtFrozenStore
  24210. };
  24211. /***/ }),
  24212. /* 112 */
  24213. /***/ (function(module, exports, __w_pdfjs_require__) {
  24214. "use strict";
  24215. var global = __w_pdfjs_require__(4);
  24216. var $export = __w_pdfjs_require__(6);
  24217. var redefine = __w_pdfjs_require__(10);
  24218. var redefineAll = __w_pdfjs_require__(39);
  24219. var meta = __w_pdfjs_require__(40);
  24220. var forOf = __w_pdfjs_require__(25);
  24221. var anInstance = __w_pdfjs_require__(37);
  24222. var isObject = __w_pdfjs_require__(2);
  24223. var fails = __w_pdfjs_require__(14);
  24224. var $iterDetect = __w_pdfjs_require__(58);
  24225. var setToStringTag = __w_pdfjs_require__(24);
  24226. var inheritIfRequired = __w_pdfjs_require__(113);
  24227. module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
  24228. var Base = global[NAME];
  24229. var C = Base;
  24230. var ADDER = IS_MAP ? 'set' : 'add';
  24231. var proto = C && C.prototype;
  24232. var O = {};
  24233. var fixMethod = function fixMethod(KEY) {
  24234. var fn = proto[KEY];
  24235. redefine(proto, KEY, KEY == 'delete' ? function (a) {
  24236. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  24237. } : KEY == 'has' ? function has(a) {
  24238. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  24239. } : KEY == 'get' ? function get(a) {
  24240. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  24241. } : KEY == 'add' ? function add(a) {
  24242. fn.call(this, a === 0 ? 0 : a);
  24243. return this;
  24244. } : function set(a, b) {
  24245. fn.call(this, a === 0 ? 0 : a, b);
  24246. return this;
  24247. });
  24248. };
  24249. if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
  24250. new C().entries().next();
  24251. }))) {
  24252. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  24253. redefineAll(C.prototype, methods);
  24254. meta.NEED = true;
  24255. } else {
  24256. var instance = new C();
  24257. var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
  24258. var THROWS_ON_PRIMITIVES = fails(function () {
  24259. instance.has(1);
  24260. });
  24261. var ACCEPT_ITERABLES = $iterDetect(function (iter) {
  24262. new C(iter);
  24263. });
  24264. var BUGGY_ZERO = !IS_WEAK && fails(function () {
  24265. var $instance = new C();
  24266. var index = 5;
  24267. while (index--) {
  24268. $instance[ADDER](index, index);
  24269. }return !$instance.has(-0);
  24270. });
  24271. if (!ACCEPT_ITERABLES) {
  24272. C = wrapper(function (target, iterable) {
  24273. anInstance(target, C, NAME);
  24274. var that = inheritIfRequired(new Base(), target, C);
  24275. if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
  24276. return that;
  24277. });
  24278. C.prototype = proto;
  24279. proto.constructor = C;
  24280. }
  24281. if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
  24282. fixMethod('delete');
  24283. fixMethod('has');
  24284. IS_MAP && fixMethod('get');
  24285. }
  24286. if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
  24287. if (IS_WEAK && proto.clear) delete proto.clear;
  24288. }
  24289. setToStringTag(C, NAME);
  24290. O[NAME] = C;
  24291. $export($export.G + $export.W + $export.F * (C != Base), O);
  24292. if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
  24293. return C;
  24294. };
  24295. /***/ }),
  24296. /* 113 */
  24297. /***/ (function(module, exports, __w_pdfjs_require__) {
  24298. "use strict";
  24299. var isObject = __w_pdfjs_require__(2);
  24300. var setPrototypeOf = __w_pdfjs_require__(114).set;
  24301. module.exports = function (that, target, C) {
  24302. var S = target.constructor;
  24303. var P;
  24304. if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
  24305. setPrototypeOf(that, P);
  24306. }
  24307. return that;
  24308. };
  24309. /***/ }),
  24310. /* 114 */
  24311. /***/ (function(module, exports, __w_pdfjs_require__) {
  24312. "use strict";
  24313. var isObject = __w_pdfjs_require__(2);
  24314. var anObject = __w_pdfjs_require__(8);
  24315. var check = function check(O, proto) {
  24316. anObject(O);
  24317. if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
  24318. };
  24319. module.exports = {
  24320. set: Object.setPrototypeOf || ('__proto__' in {} ? function (test, buggy, set) {
  24321. try {
  24322. set = __w_pdfjs_require__(11)(Function.call, __w_pdfjs_require__(115).f(Object.prototype, '__proto__').set, 2);
  24323. set(test, []);
  24324. buggy = !(test instanceof Array);
  24325. } catch (e) {
  24326. buggy = true;
  24327. }
  24328. return function setPrototypeOf(O, proto) {
  24329. check(O, proto);
  24330. if (buggy) O.__proto__ = proto;else set(O, proto);
  24331. return O;
  24332. };
  24333. }({}, false) : undefined),
  24334. check: check
  24335. };
  24336. /***/ }),
  24337. /* 115 */
  24338. /***/ (function(module, exports, __w_pdfjs_require__) {
  24339. "use strict";
  24340. var pIE = __w_pdfjs_require__(34);
  24341. var createDesc = __w_pdfjs_require__(28);
  24342. var toIObject = __w_pdfjs_require__(17);
  24343. var toPrimitive = __w_pdfjs_require__(44);
  24344. var has = __w_pdfjs_require__(9);
  24345. var IE8_DOM_DEFINE = __w_pdfjs_require__(43);
  24346. var gOPD = Object.getOwnPropertyDescriptor;
  24347. exports.f = __w_pdfjs_require__(13) ? gOPD : function getOwnPropertyDescriptor(O, P) {
  24348. O = toIObject(O);
  24349. P = toPrimitive(P, true);
  24350. if (IE8_DOM_DEFINE) try {
  24351. return gOPD(O, P);
  24352. } catch (e) {}
  24353. if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
  24354. };
  24355. /***/ }),
  24356. /* 116 */
  24357. /***/ (function(module, exports, __w_pdfjs_require__) {
  24358. "use strict";
  24359. __w_pdfjs_require__(117)('WeakMap');
  24360. /***/ }),
  24361. /* 117 */
  24362. /***/ (function(module, exports, __w_pdfjs_require__) {
  24363. "use strict";
  24364. var $export = __w_pdfjs_require__(6);
  24365. module.exports = function (COLLECTION) {
  24366. $export($export.S, COLLECTION, {
  24367. of: function of() {
  24368. var length = arguments.length;
  24369. var A = Array(length);
  24370. while (length--) {
  24371. A[length] = arguments[length];
  24372. }return new this(A);
  24373. }
  24374. });
  24375. };
  24376. /***/ }),
  24377. /* 118 */
  24378. /***/ (function(module, exports, __w_pdfjs_require__) {
  24379. "use strict";
  24380. __w_pdfjs_require__(119)('WeakMap');
  24381. /***/ }),
  24382. /* 119 */
  24383. /***/ (function(module, exports, __w_pdfjs_require__) {
  24384. "use strict";
  24385. var $export = __w_pdfjs_require__(6);
  24386. var aFunction = __w_pdfjs_require__(16);
  24387. var ctx = __w_pdfjs_require__(11);
  24388. var forOf = __w_pdfjs_require__(25);
  24389. module.exports = function (COLLECTION) {
  24390. $export($export.S, COLLECTION, {
  24391. from: function from(source) {
  24392. var mapFn = arguments[1];
  24393. var mapping, A, n, cb;
  24394. aFunction(this);
  24395. mapping = mapFn !== undefined;
  24396. if (mapping) aFunction(mapFn);
  24397. if (source == undefined) return new this();
  24398. A = [];
  24399. if (mapping) {
  24400. n = 0;
  24401. cb = ctx(mapFn, arguments[2], 2);
  24402. forOf(source, false, function (nextItem) {
  24403. A.push(cb(nextItem, n++));
  24404. });
  24405. } else {
  24406. forOf(source, false, A.push, A);
  24407. }
  24408. return new this(A);
  24409. }
  24410. });
  24411. };
  24412. /***/ }),
  24413. /* 120 */
  24414. /***/ (function(module, exports, __w_pdfjs_require__) {
  24415. "use strict";
  24416. var isReadableStreamSupported = false;
  24417. if (typeof ReadableStream !== 'undefined') {
  24418. try {
  24419. new ReadableStream({
  24420. start: function start(controller) {
  24421. controller.close();
  24422. }
  24423. });
  24424. isReadableStreamSupported = true;
  24425. } catch (e) {}
  24426. }
  24427. if (isReadableStreamSupported) {
  24428. exports.ReadableStream = ReadableStream;
  24429. } else {
  24430. exports.ReadableStream = __w_pdfjs_require__(121).ReadableStream;
  24431. }
  24432. /***/ }),
  24433. /* 121 */
  24434. /***/ (function(module, exports, __w_pdfjs_require__) {
  24435. "use strict";
  24436. var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  24437. (function (e, a) {
  24438. for (var i in a) {
  24439. e[i] = a[i];
  24440. }
  24441. })(exports, function (modules) {
  24442. var installedModules = {};
  24443. function __w_pdfjs_require__(moduleId) {
  24444. if (installedModules[moduleId]) return installedModules[moduleId].exports;
  24445. var module = installedModules[moduleId] = {
  24446. i: moduleId,
  24447. l: false,
  24448. exports: {}
  24449. };
  24450. modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__);
  24451. module.l = true;
  24452. return module.exports;
  24453. }
  24454. __w_pdfjs_require__.m = modules;
  24455. __w_pdfjs_require__.c = installedModules;
  24456. __w_pdfjs_require__.i = function (value) {
  24457. return value;
  24458. };
  24459. __w_pdfjs_require__.d = function (exports, name, getter) {
  24460. if (!__w_pdfjs_require__.o(exports, name)) {
  24461. Object.defineProperty(exports, name, {
  24462. configurable: false,
  24463. enumerable: true,
  24464. get: getter
  24465. });
  24466. }
  24467. };
  24468. __w_pdfjs_require__.n = function (module) {
  24469. var getter = module && module.__esModule ? function getDefault() {
  24470. return module['default'];
  24471. } : function getModuleExports() {
  24472. return module;
  24473. };
  24474. __w_pdfjs_require__.d(getter, 'a', getter);
  24475. return getter;
  24476. };
  24477. __w_pdfjs_require__.o = function (object, property) {
  24478. return Object.prototype.hasOwnProperty.call(object, property);
  24479. };
  24480. __w_pdfjs_require__.p = "";
  24481. return __w_pdfjs_require__(__w_pdfjs_require__.s = 7);
  24482. }([function (module, exports, __w_pdfjs_require__) {
  24483. "use strict";
  24484. var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
  24485. return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  24486. } : function (obj) {
  24487. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
  24488. };
  24489. var _require = __w_pdfjs_require__(1),
  24490. assert = _require.assert;
  24491. function IsPropertyKey(argument) {
  24492. return typeof argument === 'string' || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) === 'symbol';
  24493. }
  24494. exports.typeIsObject = function (x) {
  24495. return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function';
  24496. };
  24497. exports.createDataProperty = function (o, p, v) {
  24498. assert(exports.typeIsObject(o));
  24499. Object.defineProperty(o, p, {
  24500. value: v,
  24501. writable: true,
  24502. enumerable: true,
  24503. configurable: true
  24504. });
  24505. };
  24506. exports.createArrayFromList = function (elements) {
  24507. return elements.slice();
  24508. };
  24509. exports.ArrayBufferCopy = function (dest, destOffset, src, srcOffset, n) {
  24510. new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
  24511. };
  24512. exports.CreateIterResultObject = function (value, done) {
  24513. assert(typeof done === 'boolean');
  24514. var obj = {};
  24515. Object.defineProperty(obj, 'value', {
  24516. value: value,
  24517. enumerable: true,
  24518. writable: true,
  24519. configurable: true
  24520. });
  24521. Object.defineProperty(obj, 'done', {
  24522. value: done,
  24523. enumerable: true,
  24524. writable: true,
  24525. configurable: true
  24526. });
  24527. return obj;
  24528. };
  24529. exports.IsFiniteNonNegativeNumber = function (v) {
  24530. if (Number.isNaN(v)) {
  24531. return false;
  24532. }
  24533. if (v === Infinity) {
  24534. return false;
  24535. }
  24536. if (v < 0) {
  24537. return false;
  24538. }
  24539. return true;
  24540. };
  24541. function Call(F, V, args) {
  24542. if (typeof F !== 'function') {
  24543. throw new TypeError('Argument is not a function');
  24544. }
  24545. return Function.prototype.apply.call(F, V, args);
  24546. }
  24547. exports.InvokeOrNoop = function (O, P, args) {
  24548. assert(O !== undefined);
  24549. assert(IsPropertyKey(P));
  24550. assert(Array.isArray(args));
  24551. var method = O[P];
  24552. if (method === undefined) {
  24553. return undefined;
  24554. }
  24555. return Call(method, O, args);
  24556. };
  24557. exports.PromiseInvokeOrNoop = function (O, P, args) {
  24558. assert(O !== undefined);
  24559. assert(IsPropertyKey(P));
  24560. assert(Array.isArray(args));
  24561. try {
  24562. return Promise.resolve(exports.InvokeOrNoop(O, P, args));
  24563. } catch (returnValueE) {
  24564. return Promise.reject(returnValueE);
  24565. }
  24566. };
  24567. exports.PromiseInvokeOrPerformFallback = function (O, P, args, F, argsF) {
  24568. assert(O !== undefined);
  24569. assert(IsPropertyKey(P));
  24570. assert(Array.isArray(args));
  24571. assert(Array.isArray(argsF));
  24572. var method = void 0;
  24573. try {
  24574. method = O[P];
  24575. } catch (methodE) {
  24576. return Promise.reject(methodE);
  24577. }
  24578. if (method === undefined) {
  24579. return F.apply(null, argsF);
  24580. }
  24581. try {
  24582. return Promise.resolve(Call(method, O, args));
  24583. } catch (e) {
  24584. return Promise.reject(e);
  24585. }
  24586. };
  24587. exports.TransferArrayBuffer = function (O) {
  24588. return O.slice();
  24589. };
  24590. exports.ValidateAndNormalizeHighWaterMark = function (highWaterMark) {
  24591. highWaterMark = Number(highWaterMark);
  24592. if (Number.isNaN(highWaterMark) || highWaterMark < 0) {
  24593. throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN');
  24594. }
  24595. return highWaterMark;
  24596. };
  24597. exports.ValidateAndNormalizeQueuingStrategy = function (size, highWaterMark) {
  24598. if (size !== undefined && typeof size !== 'function') {
  24599. throw new TypeError('size property of a queuing strategy must be a function');
  24600. }
  24601. highWaterMark = exports.ValidateAndNormalizeHighWaterMark(highWaterMark);
  24602. return {
  24603. size: size,
  24604. highWaterMark: highWaterMark
  24605. };
  24606. };
  24607. }, function (module, exports, __w_pdfjs_require__) {
  24608. "use strict";
  24609. function rethrowAssertionErrorRejection(e) {
  24610. if (e && e.constructor === AssertionError) {
  24611. setTimeout(function () {
  24612. throw e;
  24613. }, 0);
  24614. }
  24615. }
  24616. function AssertionError(message) {
  24617. this.name = 'AssertionError';
  24618. this.message = message || '';
  24619. this.stack = new Error().stack;
  24620. }
  24621. AssertionError.prototype = Object.create(Error.prototype);
  24622. AssertionError.prototype.constructor = AssertionError;
  24623. function assert(value, message) {
  24624. if (!value) {
  24625. throw new AssertionError(message);
  24626. }
  24627. }
  24628. module.exports = {
  24629. rethrowAssertionErrorRejection: rethrowAssertionErrorRejection,
  24630. AssertionError: AssertionError,
  24631. assert: assert
  24632. };
  24633. }, function (module, exports, __w_pdfjs_require__) {
  24634. "use strict";
  24635. var _createClass = function () {
  24636. function defineProperties(target, props) {
  24637. for (var i = 0; i < props.length; i++) {
  24638. var descriptor = props[i];
  24639. descriptor.enumerable = descriptor.enumerable || false;
  24640. descriptor.configurable = true;
  24641. if ("value" in descriptor) descriptor.writable = true;
  24642. Object.defineProperty(target, descriptor.key, descriptor);
  24643. }
  24644. }
  24645. return function (Constructor, protoProps, staticProps) {
  24646. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  24647. if (staticProps) defineProperties(Constructor, staticProps);
  24648. return Constructor;
  24649. };
  24650. }();
  24651. function _classCallCheck(instance, Constructor) {
  24652. if (!(instance instanceof Constructor)) {
  24653. throw new TypeError("Cannot call a class as a function");
  24654. }
  24655. }
  24656. var _require = __w_pdfjs_require__(0),
  24657. InvokeOrNoop = _require.InvokeOrNoop,
  24658. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  24659. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  24660. typeIsObject = _require.typeIsObject;
  24661. var _require2 = __w_pdfjs_require__(1),
  24662. assert = _require2.assert,
  24663. rethrowAssertionErrorRejection = _require2.rethrowAssertionErrorRejection;
  24664. var _require3 = __w_pdfjs_require__(3),
  24665. DequeueValue = _require3.DequeueValue,
  24666. EnqueueValueWithSize = _require3.EnqueueValueWithSize,
  24667. PeekQueueValue = _require3.PeekQueueValue,
  24668. ResetQueue = _require3.ResetQueue;
  24669. var WritableStream = function () {
  24670. function WritableStream() {
  24671. var underlyingSink = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  24672. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  24673. size = _ref.size,
  24674. _ref$highWaterMark = _ref.highWaterMark,
  24675. highWaterMark = _ref$highWaterMark === undefined ? 1 : _ref$highWaterMark;
  24676. _classCallCheck(this, WritableStream);
  24677. this._state = 'writable';
  24678. this._storedError = undefined;
  24679. this._writer = undefined;
  24680. this._writableStreamController = undefined;
  24681. this._writeRequests = [];
  24682. this._inFlightWriteRequest = undefined;
  24683. this._closeRequest = undefined;
  24684. this._inFlightCloseRequest = undefined;
  24685. this._pendingAbortRequest = undefined;
  24686. this._backpressure = false;
  24687. var type = underlyingSink.type;
  24688. if (type !== undefined) {
  24689. throw new RangeError('Invalid type is specified');
  24690. }
  24691. this._writableStreamController = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark);
  24692. this._writableStreamController.__startSteps();
  24693. }
  24694. _createClass(WritableStream, [{
  24695. key: 'abort',
  24696. value: function abort(reason) {
  24697. if (IsWritableStream(this) === false) {
  24698. return Promise.reject(streamBrandCheckException('abort'));
  24699. }
  24700. if (IsWritableStreamLocked(this) === true) {
  24701. return Promise.reject(new TypeError('Cannot abort a stream that already has a writer'));
  24702. }
  24703. return WritableStreamAbort(this, reason);
  24704. }
  24705. }, {
  24706. key: 'getWriter',
  24707. value: function getWriter() {
  24708. if (IsWritableStream(this) === false) {
  24709. throw streamBrandCheckException('getWriter');
  24710. }
  24711. return AcquireWritableStreamDefaultWriter(this);
  24712. }
  24713. }, {
  24714. key: 'locked',
  24715. get: function get() {
  24716. if (IsWritableStream(this) === false) {
  24717. throw streamBrandCheckException('locked');
  24718. }
  24719. return IsWritableStreamLocked(this);
  24720. }
  24721. }]);
  24722. return WritableStream;
  24723. }();
  24724. module.exports = {
  24725. AcquireWritableStreamDefaultWriter: AcquireWritableStreamDefaultWriter,
  24726. IsWritableStream: IsWritableStream,
  24727. IsWritableStreamLocked: IsWritableStreamLocked,
  24728. WritableStream: WritableStream,
  24729. WritableStreamAbort: WritableStreamAbort,
  24730. WritableStreamDefaultControllerError: WritableStreamDefaultControllerError,
  24731. WritableStreamDefaultWriterCloseWithErrorPropagation: WritableStreamDefaultWriterCloseWithErrorPropagation,
  24732. WritableStreamDefaultWriterRelease: WritableStreamDefaultWriterRelease,
  24733. WritableStreamDefaultWriterWrite: WritableStreamDefaultWriterWrite,
  24734. WritableStreamCloseQueuedOrInFlight: WritableStreamCloseQueuedOrInFlight
  24735. };
  24736. function AcquireWritableStreamDefaultWriter(stream) {
  24737. return new WritableStreamDefaultWriter(stream);
  24738. }
  24739. function IsWritableStream(x) {
  24740. if (!typeIsObject(x)) {
  24741. return false;
  24742. }
  24743. if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) {
  24744. return false;
  24745. }
  24746. return true;
  24747. }
  24748. function IsWritableStreamLocked(stream) {
  24749. assert(IsWritableStream(stream) === true, 'IsWritableStreamLocked should only be used on known writable streams');
  24750. if (stream._writer === undefined) {
  24751. return false;
  24752. }
  24753. return true;
  24754. }
  24755. function WritableStreamAbort(stream, reason) {
  24756. var state = stream._state;
  24757. if (state === 'closed') {
  24758. return Promise.resolve(undefined);
  24759. }
  24760. if (state === 'errored') {
  24761. return Promise.reject(stream._storedError);
  24762. }
  24763. var error = new TypeError('Requested to abort');
  24764. if (stream._pendingAbortRequest !== undefined) {
  24765. return Promise.reject(error);
  24766. }
  24767. assert(state === 'writable' || state === 'erroring', 'state must be writable or erroring');
  24768. var wasAlreadyErroring = false;
  24769. if (state === 'erroring') {
  24770. wasAlreadyErroring = true;
  24771. reason = undefined;
  24772. }
  24773. var promise = new Promise(function (resolve, reject) {
  24774. stream._pendingAbortRequest = {
  24775. _resolve: resolve,
  24776. _reject: reject,
  24777. _reason: reason,
  24778. _wasAlreadyErroring: wasAlreadyErroring
  24779. };
  24780. });
  24781. if (wasAlreadyErroring === false) {
  24782. WritableStreamStartErroring(stream, error);
  24783. }
  24784. return promise;
  24785. }
  24786. function WritableStreamAddWriteRequest(stream) {
  24787. assert(IsWritableStreamLocked(stream) === true);
  24788. assert(stream._state === 'writable');
  24789. var promise = new Promise(function (resolve, reject) {
  24790. var writeRequest = {
  24791. _resolve: resolve,
  24792. _reject: reject
  24793. };
  24794. stream._writeRequests.push(writeRequest);
  24795. });
  24796. return promise;
  24797. }
  24798. function WritableStreamDealWithRejection(stream, error) {
  24799. var state = stream._state;
  24800. if (state === 'writable') {
  24801. WritableStreamStartErroring(stream, error);
  24802. return;
  24803. }
  24804. assert(state === 'erroring');
  24805. WritableStreamFinishErroring(stream);
  24806. }
  24807. function WritableStreamStartErroring(stream, reason) {
  24808. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  24809. assert(stream._state === 'writable', 'state must be writable');
  24810. var controller = stream._writableStreamController;
  24811. assert(controller !== undefined, 'controller must not be undefined');
  24812. stream._state = 'erroring';
  24813. stream._storedError = reason;
  24814. var writer = stream._writer;
  24815. if (writer !== undefined) {
  24816. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
  24817. }
  24818. if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) {
  24819. WritableStreamFinishErroring(stream);
  24820. }
  24821. }
  24822. function WritableStreamFinishErroring(stream) {
  24823. assert(stream._state === 'erroring', 'stream._state === erroring');
  24824. assert(WritableStreamHasOperationMarkedInFlight(stream) === false, 'WritableStreamHasOperationMarkedInFlight(stream) === false');
  24825. stream._state = 'errored';
  24826. stream._writableStreamController.__errorSteps();
  24827. var storedError = stream._storedError;
  24828. for (var i = 0; i < stream._writeRequests.length; i++) {
  24829. var writeRequest = stream._writeRequests[i];
  24830. writeRequest._reject(storedError);
  24831. }
  24832. stream._writeRequests = [];
  24833. if (stream._pendingAbortRequest === undefined) {
  24834. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  24835. return;
  24836. }
  24837. var abortRequest = stream._pendingAbortRequest;
  24838. stream._pendingAbortRequest = undefined;
  24839. if (abortRequest._wasAlreadyErroring === true) {
  24840. abortRequest._reject(storedError);
  24841. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  24842. return;
  24843. }
  24844. var promise = stream._writableStreamController.__abortSteps(abortRequest._reason);
  24845. promise.then(function () {
  24846. abortRequest._resolve();
  24847. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  24848. }, function (reason) {
  24849. abortRequest._reject(reason);
  24850. WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
  24851. });
  24852. }
  24853. function WritableStreamFinishInFlightWrite(stream) {
  24854. assert(stream._inFlightWriteRequest !== undefined);
  24855. stream._inFlightWriteRequest._resolve(undefined);
  24856. stream._inFlightWriteRequest = undefined;
  24857. }
  24858. function WritableStreamFinishInFlightWriteWithError(stream, error) {
  24859. assert(stream._inFlightWriteRequest !== undefined);
  24860. stream._inFlightWriteRequest._reject(error);
  24861. stream._inFlightWriteRequest = undefined;
  24862. assert(stream._state === 'writable' || stream._state === 'erroring');
  24863. WritableStreamDealWithRejection(stream, error);
  24864. }
  24865. function WritableStreamFinishInFlightClose(stream) {
  24866. assert(stream._inFlightCloseRequest !== undefined);
  24867. stream._inFlightCloseRequest._resolve(undefined);
  24868. stream._inFlightCloseRequest = undefined;
  24869. var state = stream._state;
  24870. assert(state === 'writable' || state === 'erroring');
  24871. if (state === 'erroring') {
  24872. stream._storedError = undefined;
  24873. if (stream._pendingAbortRequest !== undefined) {
  24874. stream._pendingAbortRequest._resolve();
  24875. stream._pendingAbortRequest = undefined;
  24876. }
  24877. }
  24878. stream._state = 'closed';
  24879. var writer = stream._writer;
  24880. if (writer !== undefined) {
  24881. defaultWriterClosedPromiseResolve(writer);
  24882. }
  24883. assert(stream._pendingAbortRequest === undefined, 'stream._pendingAbortRequest === undefined');
  24884. assert(stream._storedError === undefined, 'stream._storedError === undefined');
  24885. }
  24886. function WritableStreamFinishInFlightCloseWithError(stream, error) {
  24887. assert(stream._inFlightCloseRequest !== undefined);
  24888. stream._inFlightCloseRequest._reject(error);
  24889. stream._inFlightCloseRequest = undefined;
  24890. assert(stream._state === 'writable' || stream._state === 'erroring');
  24891. if (stream._pendingAbortRequest !== undefined) {
  24892. stream._pendingAbortRequest._reject(error);
  24893. stream._pendingAbortRequest = undefined;
  24894. }
  24895. WritableStreamDealWithRejection(stream, error);
  24896. }
  24897. function WritableStreamCloseQueuedOrInFlight(stream) {
  24898. if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) {
  24899. return false;
  24900. }
  24901. return true;
  24902. }
  24903. function WritableStreamHasOperationMarkedInFlight(stream) {
  24904. if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) {
  24905. return false;
  24906. }
  24907. return true;
  24908. }
  24909. function WritableStreamMarkCloseRequestInFlight(stream) {
  24910. assert(stream._inFlightCloseRequest === undefined);
  24911. assert(stream._closeRequest !== undefined);
  24912. stream._inFlightCloseRequest = stream._closeRequest;
  24913. stream._closeRequest = undefined;
  24914. }
  24915. function WritableStreamMarkFirstWriteRequestInFlight(stream) {
  24916. assert(stream._inFlightWriteRequest === undefined, 'there must be no pending write request');
  24917. assert(stream._writeRequests.length !== 0, 'writeRequests must not be empty');
  24918. stream._inFlightWriteRequest = stream._writeRequests.shift();
  24919. }
  24920. function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
  24921. assert(stream._state === 'errored', '_stream_.[[state]] is `"errored"`');
  24922. if (stream._closeRequest !== undefined) {
  24923. assert(stream._inFlightCloseRequest === undefined);
  24924. stream._closeRequest._reject(stream._storedError);
  24925. stream._closeRequest = undefined;
  24926. }
  24927. var writer = stream._writer;
  24928. if (writer !== undefined) {
  24929. defaultWriterClosedPromiseReject(writer, stream._storedError);
  24930. writer._closedPromise.catch(function () {});
  24931. }
  24932. }
  24933. function WritableStreamUpdateBackpressure(stream, backpressure) {
  24934. assert(stream._state === 'writable');
  24935. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  24936. var writer = stream._writer;
  24937. if (writer !== undefined && backpressure !== stream._backpressure) {
  24938. if (backpressure === true) {
  24939. defaultWriterReadyPromiseReset(writer);
  24940. } else {
  24941. assert(backpressure === false);
  24942. defaultWriterReadyPromiseResolve(writer);
  24943. }
  24944. }
  24945. stream._backpressure = backpressure;
  24946. }
  24947. var WritableStreamDefaultWriter = function () {
  24948. function WritableStreamDefaultWriter(stream) {
  24949. _classCallCheck(this, WritableStreamDefaultWriter);
  24950. if (IsWritableStream(stream) === false) {
  24951. throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance');
  24952. }
  24953. if (IsWritableStreamLocked(stream) === true) {
  24954. throw new TypeError('This stream has already been locked for exclusive writing by another writer');
  24955. }
  24956. this._ownerWritableStream = stream;
  24957. stream._writer = this;
  24958. var state = stream._state;
  24959. if (state === 'writable') {
  24960. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) {
  24961. defaultWriterReadyPromiseInitialize(this);
  24962. } else {
  24963. defaultWriterReadyPromiseInitializeAsResolved(this);
  24964. }
  24965. defaultWriterClosedPromiseInitialize(this);
  24966. } else if (state === 'erroring') {
  24967. defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError);
  24968. this._readyPromise.catch(function () {});
  24969. defaultWriterClosedPromiseInitialize(this);
  24970. } else if (state === 'closed') {
  24971. defaultWriterReadyPromiseInitializeAsResolved(this);
  24972. defaultWriterClosedPromiseInitializeAsResolved(this);
  24973. } else {
  24974. assert(state === 'errored', 'state must be errored');
  24975. var storedError = stream._storedError;
  24976. defaultWriterReadyPromiseInitializeAsRejected(this, storedError);
  24977. this._readyPromise.catch(function () {});
  24978. defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
  24979. this._closedPromise.catch(function () {});
  24980. }
  24981. }
  24982. _createClass(WritableStreamDefaultWriter, [{
  24983. key: 'abort',
  24984. value: function abort(reason) {
  24985. if (IsWritableStreamDefaultWriter(this) === false) {
  24986. return Promise.reject(defaultWriterBrandCheckException('abort'));
  24987. }
  24988. if (this._ownerWritableStream === undefined) {
  24989. return Promise.reject(defaultWriterLockException('abort'));
  24990. }
  24991. return WritableStreamDefaultWriterAbort(this, reason);
  24992. }
  24993. }, {
  24994. key: 'close',
  24995. value: function close() {
  24996. if (IsWritableStreamDefaultWriter(this) === false) {
  24997. return Promise.reject(defaultWriterBrandCheckException('close'));
  24998. }
  24999. var stream = this._ownerWritableStream;
  25000. if (stream === undefined) {
  25001. return Promise.reject(defaultWriterLockException('close'));
  25002. }
  25003. if (WritableStreamCloseQueuedOrInFlight(stream) === true) {
  25004. return Promise.reject(new TypeError('cannot close an already-closing stream'));
  25005. }
  25006. return WritableStreamDefaultWriterClose(this);
  25007. }
  25008. }, {
  25009. key: 'releaseLock',
  25010. value: function releaseLock() {
  25011. if (IsWritableStreamDefaultWriter(this) === false) {
  25012. throw defaultWriterBrandCheckException('releaseLock');
  25013. }
  25014. var stream = this._ownerWritableStream;
  25015. if (stream === undefined) {
  25016. return;
  25017. }
  25018. assert(stream._writer !== undefined);
  25019. WritableStreamDefaultWriterRelease(this);
  25020. }
  25021. }, {
  25022. key: 'write',
  25023. value: function write(chunk) {
  25024. if (IsWritableStreamDefaultWriter(this) === false) {
  25025. return Promise.reject(defaultWriterBrandCheckException('write'));
  25026. }
  25027. if (this._ownerWritableStream === undefined) {
  25028. return Promise.reject(defaultWriterLockException('write to'));
  25029. }
  25030. return WritableStreamDefaultWriterWrite(this, chunk);
  25031. }
  25032. }, {
  25033. key: 'closed',
  25034. get: function get() {
  25035. if (IsWritableStreamDefaultWriter(this) === false) {
  25036. return Promise.reject(defaultWriterBrandCheckException('closed'));
  25037. }
  25038. return this._closedPromise;
  25039. }
  25040. }, {
  25041. key: 'desiredSize',
  25042. get: function get() {
  25043. if (IsWritableStreamDefaultWriter(this) === false) {
  25044. throw defaultWriterBrandCheckException('desiredSize');
  25045. }
  25046. if (this._ownerWritableStream === undefined) {
  25047. throw defaultWriterLockException('desiredSize');
  25048. }
  25049. return WritableStreamDefaultWriterGetDesiredSize(this);
  25050. }
  25051. }, {
  25052. key: 'ready',
  25053. get: function get() {
  25054. if (IsWritableStreamDefaultWriter(this) === false) {
  25055. return Promise.reject(defaultWriterBrandCheckException('ready'));
  25056. }
  25057. return this._readyPromise;
  25058. }
  25059. }]);
  25060. return WritableStreamDefaultWriter;
  25061. }();
  25062. function IsWritableStreamDefaultWriter(x) {
  25063. if (!typeIsObject(x)) {
  25064. return false;
  25065. }
  25066. if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) {
  25067. return false;
  25068. }
  25069. return true;
  25070. }
  25071. function WritableStreamDefaultWriterAbort(writer, reason) {
  25072. var stream = writer._ownerWritableStream;
  25073. assert(stream !== undefined);
  25074. return WritableStreamAbort(stream, reason);
  25075. }
  25076. function WritableStreamDefaultWriterClose(writer) {
  25077. var stream = writer._ownerWritableStream;
  25078. assert(stream !== undefined);
  25079. var state = stream._state;
  25080. if (state === 'closed' || state === 'errored') {
  25081. return Promise.reject(new TypeError('The stream (in ' + state + ' state) is not in the writable state and cannot be closed'));
  25082. }
  25083. assert(state === 'writable' || state === 'erroring');
  25084. assert(WritableStreamCloseQueuedOrInFlight(stream) === false);
  25085. var promise = new Promise(function (resolve, reject) {
  25086. var closeRequest = {
  25087. _resolve: resolve,
  25088. _reject: reject
  25089. };
  25090. stream._closeRequest = closeRequest;
  25091. });
  25092. if (stream._backpressure === true && state === 'writable') {
  25093. defaultWriterReadyPromiseResolve(writer);
  25094. }
  25095. WritableStreamDefaultControllerClose(stream._writableStreamController);
  25096. return promise;
  25097. }
  25098. function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
  25099. var stream = writer._ownerWritableStream;
  25100. assert(stream !== undefined);
  25101. var state = stream._state;
  25102. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  25103. return Promise.resolve();
  25104. }
  25105. if (state === 'errored') {
  25106. return Promise.reject(stream._storedError);
  25107. }
  25108. assert(state === 'writable' || state === 'erroring');
  25109. return WritableStreamDefaultWriterClose(writer);
  25110. }
  25111. function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
  25112. if (writer._closedPromiseState === 'pending') {
  25113. defaultWriterClosedPromiseReject(writer, error);
  25114. } else {
  25115. defaultWriterClosedPromiseResetToRejected(writer, error);
  25116. }
  25117. writer._closedPromise.catch(function () {});
  25118. }
  25119. function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
  25120. if (writer._readyPromiseState === 'pending') {
  25121. defaultWriterReadyPromiseReject(writer, error);
  25122. } else {
  25123. defaultWriterReadyPromiseResetToRejected(writer, error);
  25124. }
  25125. writer._readyPromise.catch(function () {});
  25126. }
  25127. function WritableStreamDefaultWriterGetDesiredSize(writer) {
  25128. var stream = writer._ownerWritableStream;
  25129. var state = stream._state;
  25130. if (state === 'errored' || state === 'erroring') {
  25131. return null;
  25132. }
  25133. if (state === 'closed') {
  25134. return 0;
  25135. }
  25136. return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
  25137. }
  25138. function WritableStreamDefaultWriterRelease(writer) {
  25139. var stream = writer._ownerWritableStream;
  25140. assert(stream !== undefined);
  25141. assert(stream._writer === writer);
  25142. var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness');
  25143. WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
  25144. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
  25145. stream._writer = undefined;
  25146. writer._ownerWritableStream = undefined;
  25147. }
  25148. function WritableStreamDefaultWriterWrite(writer, chunk) {
  25149. var stream = writer._ownerWritableStream;
  25150. assert(stream !== undefined);
  25151. var controller = stream._writableStreamController;
  25152. var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
  25153. if (stream !== writer._ownerWritableStream) {
  25154. return Promise.reject(defaultWriterLockException('write to'));
  25155. }
  25156. var state = stream._state;
  25157. if (state === 'errored') {
  25158. return Promise.reject(stream._storedError);
  25159. }
  25160. if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') {
  25161. return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to'));
  25162. }
  25163. if (state === 'erroring') {
  25164. return Promise.reject(stream._storedError);
  25165. }
  25166. assert(state === 'writable');
  25167. var promise = WritableStreamAddWriteRequest(stream);
  25168. WritableStreamDefaultControllerWrite(controller, chunk, chunkSize);
  25169. return promise;
  25170. }
  25171. var WritableStreamDefaultController = function () {
  25172. function WritableStreamDefaultController(stream, underlyingSink, size, highWaterMark) {
  25173. _classCallCheck(this, WritableStreamDefaultController);
  25174. if (IsWritableStream(stream) === false) {
  25175. throw new TypeError('WritableStreamDefaultController can only be constructed with a WritableStream instance');
  25176. }
  25177. if (stream._writableStreamController !== undefined) {
  25178. throw new TypeError('WritableStreamDefaultController instances can only be created by the WritableStream constructor');
  25179. }
  25180. this._controlledWritableStream = stream;
  25181. this._underlyingSink = underlyingSink;
  25182. this._queue = undefined;
  25183. this._queueTotalSize = undefined;
  25184. ResetQueue(this);
  25185. this._started = false;
  25186. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  25187. this._strategySize = normalizedStrategy.size;
  25188. this._strategyHWM = normalizedStrategy.highWaterMark;
  25189. var backpressure = WritableStreamDefaultControllerGetBackpressure(this);
  25190. WritableStreamUpdateBackpressure(stream, backpressure);
  25191. }
  25192. _createClass(WritableStreamDefaultController, [{
  25193. key: 'error',
  25194. value: function error(e) {
  25195. if (IsWritableStreamDefaultController(this) === false) {
  25196. throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController');
  25197. }
  25198. var state = this._controlledWritableStream._state;
  25199. if (state !== 'writable') {
  25200. return;
  25201. }
  25202. WritableStreamDefaultControllerError(this, e);
  25203. }
  25204. }, {
  25205. key: '__abortSteps',
  25206. value: function __abortSteps(reason) {
  25207. return PromiseInvokeOrNoop(this._underlyingSink, 'abort', [reason]);
  25208. }
  25209. }, {
  25210. key: '__errorSteps',
  25211. value: function __errorSteps() {
  25212. ResetQueue(this);
  25213. }
  25214. }, {
  25215. key: '__startSteps',
  25216. value: function __startSteps() {
  25217. var _this = this;
  25218. var startResult = InvokeOrNoop(this._underlyingSink, 'start', [this]);
  25219. var stream = this._controlledWritableStream;
  25220. Promise.resolve(startResult).then(function () {
  25221. assert(stream._state === 'writable' || stream._state === 'erroring');
  25222. _this._started = true;
  25223. WritableStreamDefaultControllerAdvanceQueueIfNeeded(_this);
  25224. }, function (r) {
  25225. assert(stream._state === 'writable' || stream._state === 'erroring');
  25226. _this._started = true;
  25227. WritableStreamDealWithRejection(stream, r);
  25228. }).catch(rethrowAssertionErrorRejection);
  25229. }
  25230. }]);
  25231. return WritableStreamDefaultController;
  25232. }();
  25233. function WritableStreamDefaultControllerClose(controller) {
  25234. EnqueueValueWithSize(controller, 'close', 0);
  25235. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  25236. }
  25237. function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
  25238. var strategySize = controller._strategySize;
  25239. if (strategySize === undefined) {
  25240. return 1;
  25241. }
  25242. try {
  25243. return strategySize(chunk);
  25244. } catch (chunkSizeE) {
  25245. WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  25246. return 1;
  25247. }
  25248. }
  25249. function WritableStreamDefaultControllerGetDesiredSize(controller) {
  25250. return controller._strategyHWM - controller._queueTotalSize;
  25251. }
  25252. function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
  25253. var writeRecord = { chunk: chunk };
  25254. try {
  25255. EnqueueValueWithSize(controller, writeRecord, chunkSize);
  25256. } catch (enqueueE) {
  25257. WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  25258. return;
  25259. }
  25260. var stream = controller._controlledWritableStream;
  25261. if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') {
  25262. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  25263. WritableStreamUpdateBackpressure(stream, backpressure);
  25264. }
  25265. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  25266. }
  25267. function IsWritableStreamDefaultController(x) {
  25268. if (!typeIsObject(x)) {
  25269. return false;
  25270. }
  25271. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSink')) {
  25272. return false;
  25273. }
  25274. return true;
  25275. }
  25276. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
  25277. var stream = controller._controlledWritableStream;
  25278. if (controller._started === false) {
  25279. return;
  25280. }
  25281. if (stream._inFlightWriteRequest !== undefined) {
  25282. return;
  25283. }
  25284. var state = stream._state;
  25285. if (state === 'closed' || state === 'errored') {
  25286. return;
  25287. }
  25288. if (state === 'erroring') {
  25289. WritableStreamFinishErroring(stream);
  25290. return;
  25291. }
  25292. if (controller._queue.length === 0) {
  25293. return;
  25294. }
  25295. var writeRecord = PeekQueueValue(controller);
  25296. if (writeRecord === 'close') {
  25297. WritableStreamDefaultControllerProcessClose(controller);
  25298. } else {
  25299. WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk);
  25300. }
  25301. }
  25302. function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
  25303. if (controller._controlledWritableStream._state === 'writable') {
  25304. WritableStreamDefaultControllerError(controller, error);
  25305. }
  25306. }
  25307. function WritableStreamDefaultControllerProcessClose(controller) {
  25308. var stream = controller._controlledWritableStream;
  25309. WritableStreamMarkCloseRequestInFlight(stream);
  25310. DequeueValue(controller);
  25311. assert(controller._queue.length === 0, 'queue must be empty once the final write record is dequeued');
  25312. var sinkClosePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'close', []);
  25313. sinkClosePromise.then(function () {
  25314. WritableStreamFinishInFlightClose(stream);
  25315. }, function (reason) {
  25316. WritableStreamFinishInFlightCloseWithError(stream, reason);
  25317. }).catch(rethrowAssertionErrorRejection);
  25318. }
  25319. function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
  25320. var stream = controller._controlledWritableStream;
  25321. WritableStreamMarkFirstWriteRequestInFlight(stream);
  25322. var sinkWritePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'write', [chunk, controller]);
  25323. sinkWritePromise.then(function () {
  25324. WritableStreamFinishInFlightWrite(stream);
  25325. var state = stream._state;
  25326. assert(state === 'writable' || state === 'erroring');
  25327. DequeueValue(controller);
  25328. if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') {
  25329. var backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
  25330. WritableStreamUpdateBackpressure(stream, backpressure);
  25331. }
  25332. WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
  25333. }, function (reason) {
  25334. WritableStreamFinishInFlightWriteWithError(stream, reason);
  25335. }).catch(rethrowAssertionErrorRejection);
  25336. }
  25337. function WritableStreamDefaultControllerGetBackpressure(controller) {
  25338. var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
  25339. return desiredSize <= 0;
  25340. }
  25341. function WritableStreamDefaultControllerError(controller, error) {
  25342. var stream = controller._controlledWritableStream;
  25343. assert(stream._state === 'writable');
  25344. WritableStreamStartErroring(stream, error);
  25345. }
  25346. function streamBrandCheckException(name) {
  25347. return new TypeError('WritableStream.prototype.' + name + ' can only be used on a WritableStream');
  25348. }
  25349. function defaultWriterBrandCheckException(name) {
  25350. return new TypeError('WritableStreamDefaultWriter.prototype.' + name + ' can only be used on a WritableStreamDefaultWriter');
  25351. }
  25352. function defaultWriterLockException(name) {
  25353. return new TypeError('Cannot ' + name + ' a stream using a released writer');
  25354. }
  25355. function defaultWriterClosedPromiseInitialize(writer) {
  25356. writer._closedPromise = new Promise(function (resolve, reject) {
  25357. writer._closedPromise_resolve = resolve;
  25358. writer._closedPromise_reject = reject;
  25359. writer._closedPromiseState = 'pending';
  25360. });
  25361. }
  25362. function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
  25363. writer._closedPromise = Promise.reject(reason);
  25364. writer._closedPromise_resolve = undefined;
  25365. writer._closedPromise_reject = undefined;
  25366. writer._closedPromiseState = 'rejected';
  25367. }
  25368. function defaultWriterClosedPromiseInitializeAsResolved(writer) {
  25369. writer._closedPromise = Promise.resolve(undefined);
  25370. writer._closedPromise_resolve = undefined;
  25371. writer._closedPromise_reject = undefined;
  25372. writer._closedPromiseState = 'resolved';
  25373. }
  25374. function defaultWriterClosedPromiseReject(writer, reason) {
  25375. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  25376. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  25377. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  25378. writer._closedPromise_reject(reason);
  25379. writer._closedPromise_resolve = undefined;
  25380. writer._closedPromise_reject = undefined;
  25381. writer._closedPromiseState = 'rejected';
  25382. }
  25383. function defaultWriterClosedPromiseResetToRejected(writer, reason) {
  25384. assert(writer._closedPromise_resolve === undefined, 'writer._closedPromise_resolve === undefined');
  25385. assert(writer._closedPromise_reject === undefined, 'writer._closedPromise_reject === undefined');
  25386. assert(writer._closedPromiseState !== 'pending', 'writer._closedPromiseState is not pending');
  25387. writer._closedPromise = Promise.reject(reason);
  25388. writer._closedPromiseState = 'rejected';
  25389. }
  25390. function defaultWriterClosedPromiseResolve(writer) {
  25391. assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined');
  25392. assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined');
  25393. assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending');
  25394. writer._closedPromise_resolve(undefined);
  25395. writer._closedPromise_resolve = undefined;
  25396. writer._closedPromise_reject = undefined;
  25397. writer._closedPromiseState = 'resolved';
  25398. }
  25399. function defaultWriterReadyPromiseInitialize(writer) {
  25400. writer._readyPromise = new Promise(function (resolve, reject) {
  25401. writer._readyPromise_resolve = resolve;
  25402. writer._readyPromise_reject = reject;
  25403. });
  25404. writer._readyPromiseState = 'pending';
  25405. }
  25406. function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
  25407. writer._readyPromise = Promise.reject(reason);
  25408. writer._readyPromise_resolve = undefined;
  25409. writer._readyPromise_reject = undefined;
  25410. writer._readyPromiseState = 'rejected';
  25411. }
  25412. function defaultWriterReadyPromiseInitializeAsResolved(writer) {
  25413. writer._readyPromise = Promise.resolve(undefined);
  25414. writer._readyPromise_resolve = undefined;
  25415. writer._readyPromise_reject = undefined;
  25416. writer._readyPromiseState = 'fulfilled';
  25417. }
  25418. function defaultWriterReadyPromiseReject(writer, reason) {
  25419. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  25420. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  25421. writer._readyPromise_reject(reason);
  25422. writer._readyPromise_resolve = undefined;
  25423. writer._readyPromise_reject = undefined;
  25424. writer._readyPromiseState = 'rejected';
  25425. }
  25426. function defaultWriterReadyPromiseReset(writer) {
  25427. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  25428. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  25429. writer._readyPromise = new Promise(function (resolve, reject) {
  25430. writer._readyPromise_resolve = resolve;
  25431. writer._readyPromise_reject = reject;
  25432. });
  25433. writer._readyPromiseState = 'pending';
  25434. }
  25435. function defaultWriterReadyPromiseResetToRejected(writer, reason) {
  25436. assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined');
  25437. assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined');
  25438. writer._readyPromise = Promise.reject(reason);
  25439. writer._readyPromiseState = 'rejected';
  25440. }
  25441. function defaultWriterReadyPromiseResolve(writer) {
  25442. assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined');
  25443. assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined');
  25444. writer._readyPromise_resolve(undefined);
  25445. writer._readyPromise_resolve = undefined;
  25446. writer._readyPromise_reject = undefined;
  25447. writer._readyPromiseState = 'fulfilled';
  25448. }
  25449. }, function (module, exports, __w_pdfjs_require__) {
  25450. "use strict";
  25451. var _require = __w_pdfjs_require__(0),
  25452. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber;
  25453. var _require2 = __w_pdfjs_require__(1),
  25454. assert = _require2.assert;
  25455. exports.DequeueValue = function (container) {
  25456. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: DequeueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  25457. assert(container._queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.');
  25458. var pair = container._queue.shift();
  25459. container._queueTotalSize -= pair.size;
  25460. if (container._queueTotalSize < 0) {
  25461. container._queueTotalSize = 0;
  25462. }
  25463. return pair.value;
  25464. };
  25465. exports.EnqueueValueWithSize = function (container, value, size) {
  25466. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: EnqueueValueWithSize should only be used on containers with [[queue]] and ' + '[[queueTotalSize]].');
  25467. size = Number(size);
  25468. if (!IsFiniteNonNegativeNumber(size)) {
  25469. throw new RangeError('Size must be a finite, non-NaN, non-negative number.');
  25470. }
  25471. container._queue.push({
  25472. value: value,
  25473. size: size
  25474. });
  25475. container._queueTotalSize += size;
  25476. };
  25477. exports.PeekQueueValue = function (container) {
  25478. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: PeekQueueValue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  25479. assert(container._queue.length > 0, 'Spec-level failure: should never peek at an empty queue.');
  25480. var pair = container._queue[0];
  25481. return pair.value;
  25482. };
  25483. exports.ResetQueue = function (container) {
  25484. assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].');
  25485. container._queue = [];
  25486. container._queueTotalSize = 0;
  25487. };
  25488. }, function (module, exports, __w_pdfjs_require__) {
  25489. "use strict";
  25490. var _createClass = function () {
  25491. function defineProperties(target, props) {
  25492. for (var i = 0; i < props.length; i++) {
  25493. var descriptor = props[i];
  25494. descriptor.enumerable = descriptor.enumerable || false;
  25495. descriptor.configurable = true;
  25496. if ("value" in descriptor) descriptor.writable = true;
  25497. Object.defineProperty(target, descriptor.key, descriptor);
  25498. }
  25499. }
  25500. return function (Constructor, protoProps, staticProps) {
  25501. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  25502. if (staticProps) defineProperties(Constructor, staticProps);
  25503. return Constructor;
  25504. };
  25505. }();
  25506. function _classCallCheck(instance, Constructor) {
  25507. if (!(instance instanceof Constructor)) {
  25508. throw new TypeError("Cannot call a class as a function");
  25509. }
  25510. }
  25511. var _require = __w_pdfjs_require__(0),
  25512. ArrayBufferCopy = _require.ArrayBufferCopy,
  25513. CreateIterResultObject = _require.CreateIterResultObject,
  25514. IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber,
  25515. InvokeOrNoop = _require.InvokeOrNoop,
  25516. PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop,
  25517. TransferArrayBuffer = _require.TransferArrayBuffer,
  25518. ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy,
  25519. ValidateAndNormalizeHighWaterMark = _require.ValidateAndNormalizeHighWaterMark;
  25520. var _require2 = __w_pdfjs_require__(0),
  25521. createArrayFromList = _require2.createArrayFromList,
  25522. createDataProperty = _require2.createDataProperty,
  25523. typeIsObject = _require2.typeIsObject;
  25524. var _require3 = __w_pdfjs_require__(1),
  25525. assert = _require3.assert,
  25526. rethrowAssertionErrorRejection = _require3.rethrowAssertionErrorRejection;
  25527. var _require4 = __w_pdfjs_require__(3),
  25528. DequeueValue = _require4.DequeueValue,
  25529. EnqueueValueWithSize = _require4.EnqueueValueWithSize,
  25530. ResetQueue = _require4.ResetQueue;
  25531. var _require5 = __w_pdfjs_require__(2),
  25532. AcquireWritableStreamDefaultWriter = _require5.AcquireWritableStreamDefaultWriter,
  25533. IsWritableStream = _require5.IsWritableStream,
  25534. IsWritableStreamLocked = _require5.IsWritableStreamLocked,
  25535. WritableStreamAbort = _require5.WritableStreamAbort,
  25536. WritableStreamDefaultWriterCloseWithErrorPropagation = _require5.WritableStreamDefaultWriterCloseWithErrorPropagation,
  25537. WritableStreamDefaultWriterRelease = _require5.WritableStreamDefaultWriterRelease,
  25538. WritableStreamDefaultWriterWrite = _require5.WritableStreamDefaultWriterWrite,
  25539. WritableStreamCloseQueuedOrInFlight = _require5.WritableStreamCloseQueuedOrInFlight;
  25540. var ReadableStream = function () {
  25541. function ReadableStream() {
  25542. var underlyingSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  25543. var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  25544. size = _ref.size,
  25545. highWaterMark = _ref.highWaterMark;
  25546. _classCallCheck(this, ReadableStream);
  25547. this._state = 'readable';
  25548. this._reader = undefined;
  25549. this._storedError = undefined;
  25550. this._disturbed = false;
  25551. this._readableStreamController = undefined;
  25552. var type = underlyingSource.type;
  25553. var typeString = String(type);
  25554. if (typeString === 'bytes') {
  25555. if (highWaterMark === undefined) {
  25556. highWaterMark = 0;
  25557. }
  25558. this._readableStreamController = new ReadableByteStreamController(this, underlyingSource, highWaterMark);
  25559. } else if (type === undefined) {
  25560. if (highWaterMark === undefined) {
  25561. highWaterMark = 1;
  25562. }
  25563. this._readableStreamController = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark);
  25564. } else {
  25565. throw new RangeError('Invalid type is specified');
  25566. }
  25567. }
  25568. _createClass(ReadableStream, [{
  25569. key: 'cancel',
  25570. value: function cancel(reason) {
  25571. if (IsReadableStream(this) === false) {
  25572. return Promise.reject(streamBrandCheckException('cancel'));
  25573. }
  25574. if (IsReadableStreamLocked(this) === true) {
  25575. return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader'));
  25576. }
  25577. return ReadableStreamCancel(this, reason);
  25578. }
  25579. }, {
  25580. key: 'getReader',
  25581. value: function getReader() {
  25582. var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
  25583. mode = _ref2.mode;
  25584. if (IsReadableStream(this) === false) {
  25585. throw streamBrandCheckException('getReader');
  25586. }
  25587. if (mode === undefined) {
  25588. return AcquireReadableStreamDefaultReader(this);
  25589. }
  25590. mode = String(mode);
  25591. if (mode === 'byob') {
  25592. return AcquireReadableStreamBYOBReader(this);
  25593. }
  25594. throw new RangeError('Invalid mode is specified');
  25595. }
  25596. }, {
  25597. key: 'pipeThrough',
  25598. value: function pipeThrough(_ref3, options) {
  25599. var writable = _ref3.writable,
  25600. readable = _ref3.readable;
  25601. var promise = this.pipeTo(writable, options);
  25602. ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise);
  25603. return readable;
  25604. }
  25605. }, {
  25606. key: 'pipeTo',
  25607. value: function pipeTo(dest) {
  25608. var _this = this;
  25609. var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  25610. preventClose = _ref4.preventClose,
  25611. preventAbort = _ref4.preventAbort,
  25612. preventCancel = _ref4.preventCancel;
  25613. if (IsReadableStream(this) === false) {
  25614. return Promise.reject(streamBrandCheckException('pipeTo'));
  25615. }
  25616. if (IsWritableStream(dest) === false) {
  25617. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream'));
  25618. }
  25619. preventClose = Boolean(preventClose);
  25620. preventAbort = Boolean(preventAbort);
  25621. preventCancel = Boolean(preventCancel);
  25622. if (IsReadableStreamLocked(this) === true) {
  25623. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream'));
  25624. }
  25625. if (IsWritableStreamLocked(dest) === true) {
  25626. return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream'));
  25627. }
  25628. var reader = AcquireReadableStreamDefaultReader(this);
  25629. var writer = AcquireWritableStreamDefaultWriter(dest);
  25630. var shuttingDown = false;
  25631. var currentWrite = Promise.resolve();
  25632. return new Promise(function (resolve, reject) {
  25633. function pipeLoop() {
  25634. currentWrite = Promise.resolve();
  25635. if (shuttingDown === true) {
  25636. return Promise.resolve();
  25637. }
  25638. return writer._readyPromise.then(function () {
  25639. return ReadableStreamDefaultReaderRead(reader).then(function (_ref5) {
  25640. var value = _ref5.value,
  25641. done = _ref5.done;
  25642. if (done === true) {
  25643. return;
  25644. }
  25645. currentWrite = WritableStreamDefaultWriterWrite(writer, value).catch(function () {});
  25646. });
  25647. }).then(pipeLoop);
  25648. }
  25649. isOrBecomesErrored(_this, reader._closedPromise, function (storedError) {
  25650. if (preventAbort === false) {
  25651. shutdownWithAction(function () {
  25652. return WritableStreamAbort(dest, storedError);
  25653. }, true, storedError);
  25654. } else {
  25655. shutdown(true, storedError);
  25656. }
  25657. });
  25658. isOrBecomesErrored(dest, writer._closedPromise, function (storedError) {
  25659. if (preventCancel === false) {
  25660. shutdownWithAction(function () {
  25661. return ReadableStreamCancel(_this, storedError);
  25662. }, true, storedError);
  25663. } else {
  25664. shutdown(true, storedError);
  25665. }
  25666. });
  25667. isOrBecomesClosed(_this, reader._closedPromise, function () {
  25668. if (preventClose === false) {
  25669. shutdownWithAction(function () {
  25670. return WritableStreamDefaultWriterCloseWithErrorPropagation(writer);
  25671. });
  25672. } else {
  25673. shutdown();
  25674. }
  25675. });
  25676. if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') {
  25677. var destClosed = new TypeError('the destination writable stream closed before all data could be piped to it');
  25678. if (preventCancel === false) {
  25679. shutdownWithAction(function () {
  25680. return ReadableStreamCancel(_this, destClosed);
  25681. }, true, destClosed);
  25682. } else {
  25683. shutdown(true, destClosed);
  25684. }
  25685. }
  25686. pipeLoop().catch(function (err) {
  25687. currentWrite = Promise.resolve();
  25688. rethrowAssertionErrorRejection(err);
  25689. });
  25690. function waitForWritesToFinish() {
  25691. var oldCurrentWrite = currentWrite;
  25692. return currentWrite.then(function () {
  25693. return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined;
  25694. });
  25695. }
  25696. function isOrBecomesErrored(stream, promise, action) {
  25697. if (stream._state === 'errored') {
  25698. action(stream._storedError);
  25699. } else {
  25700. promise.catch(action).catch(rethrowAssertionErrorRejection);
  25701. }
  25702. }
  25703. function isOrBecomesClosed(stream, promise, action) {
  25704. if (stream._state === 'closed') {
  25705. action();
  25706. } else {
  25707. promise.then(action).catch(rethrowAssertionErrorRejection);
  25708. }
  25709. }
  25710. function shutdownWithAction(action, originalIsError, originalError) {
  25711. if (shuttingDown === true) {
  25712. return;
  25713. }
  25714. shuttingDown = true;
  25715. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  25716. waitForWritesToFinish().then(doTheRest);
  25717. } else {
  25718. doTheRest();
  25719. }
  25720. function doTheRest() {
  25721. action().then(function () {
  25722. return finalize(originalIsError, originalError);
  25723. }, function (newError) {
  25724. return finalize(true, newError);
  25725. }).catch(rethrowAssertionErrorRejection);
  25726. }
  25727. }
  25728. function shutdown(isError, error) {
  25729. if (shuttingDown === true) {
  25730. return;
  25731. }
  25732. shuttingDown = true;
  25733. if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) {
  25734. waitForWritesToFinish().then(function () {
  25735. return finalize(isError, error);
  25736. }).catch(rethrowAssertionErrorRejection);
  25737. } else {
  25738. finalize(isError, error);
  25739. }
  25740. }
  25741. function finalize(isError, error) {
  25742. WritableStreamDefaultWriterRelease(writer);
  25743. ReadableStreamReaderGenericRelease(reader);
  25744. if (isError) {
  25745. reject(error);
  25746. } else {
  25747. resolve(undefined);
  25748. }
  25749. }
  25750. });
  25751. }
  25752. }, {
  25753. key: 'tee',
  25754. value: function tee() {
  25755. if (IsReadableStream(this) === false) {
  25756. throw streamBrandCheckException('tee');
  25757. }
  25758. var branches = ReadableStreamTee(this, false);
  25759. return createArrayFromList(branches);
  25760. }
  25761. }, {
  25762. key: 'locked',
  25763. get: function get() {
  25764. if (IsReadableStream(this) === false) {
  25765. throw streamBrandCheckException('locked');
  25766. }
  25767. return IsReadableStreamLocked(this);
  25768. }
  25769. }]);
  25770. return ReadableStream;
  25771. }();
  25772. module.exports = {
  25773. ReadableStream: ReadableStream,
  25774. IsReadableStreamDisturbed: IsReadableStreamDisturbed,
  25775. ReadableStreamDefaultControllerClose: ReadableStreamDefaultControllerClose,
  25776. ReadableStreamDefaultControllerEnqueue: ReadableStreamDefaultControllerEnqueue,
  25777. ReadableStreamDefaultControllerError: ReadableStreamDefaultControllerError,
  25778. ReadableStreamDefaultControllerGetDesiredSize: ReadableStreamDefaultControllerGetDesiredSize
  25779. };
  25780. function AcquireReadableStreamBYOBReader(stream) {
  25781. return new ReadableStreamBYOBReader(stream);
  25782. }
  25783. function AcquireReadableStreamDefaultReader(stream) {
  25784. return new ReadableStreamDefaultReader(stream);
  25785. }
  25786. function IsReadableStream(x) {
  25787. if (!typeIsObject(x)) {
  25788. return false;
  25789. }
  25790. if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) {
  25791. return false;
  25792. }
  25793. return true;
  25794. }
  25795. function IsReadableStreamDisturbed(stream) {
  25796. assert(IsReadableStream(stream) === true, 'IsReadableStreamDisturbed should only be used on known readable streams');
  25797. return stream._disturbed;
  25798. }
  25799. function IsReadableStreamLocked(stream) {
  25800. assert(IsReadableStream(stream) === true, 'IsReadableStreamLocked should only be used on known readable streams');
  25801. if (stream._reader === undefined) {
  25802. return false;
  25803. }
  25804. return true;
  25805. }
  25806. function ReadableStreamTee(stream, cloneForBranch2) {
  25807. assert(IsReadableStream(stream) === true);
  25808. assert(typeof cloneForBranch2 === 'boolean');
  25809. var reader = AcquireReadableStreamDefaultReader(stream);
  25810. var teeState = {
  25811. closedOrErrored: false,
  25812. canceled1: false,
  25813. canceled2: false,
  25814. reason1: undefined,
  25815. reason2: undefined
  25816. };
  25817. teeState.promise = new Promise(function (resolve) {
  25818. teeState._resolve = resolve;
  25819. });
  25820. var pull = create_ReadableStreamTeePullFunction();
  25821. pull._reader = reader;
  25822. pull._teeState = teeState;
  25823. pull._cloneForBranch2 = cloneForBranch2;
  25824. var cancel1 = create_ReadableStreamTeeBranch1CancelFunction();
  25825. cancel1._stream = stream;
  25826. cancel1._teeState = teeState;
  25827. var cancel2 = create_ReadableStreamTeeBranch2CancelFunction();
  25828. cancel2._stream = stream;
  25829. cancel2._teeState = teeState;
  25830. var underlyingSource1 = Object.create(Object.prototype);
  25831. createDataProperty(underlyingSource1, 'pull', pull);
  25832. createDataProperty(underlyingSource1, 'cancel', cancel1);
  25833. var branch1Stream = new ReadableStream(underlyingSource1);
  25834. var underlyingSource2 = Object.create(Object.prototype);
  25835. createDataProperty(underlyingSource2, 'pull', pull);
  25836. createDataProperty(underlyingSource2, 'cancel', cancel2);
  25837. var branch2Stream = new ReadableStream(underlyingSource2);
  25838. pull._branch1 = branch1Stream._readableStreamController;
  25839. pull._branch2 = branch2Stream._readableStreamController;
  25840. reader._closedPromise.catch(function (r) {
  25841. if (teeState.closedOrErrored === true) {
  25842. return;
  25843. }
  25844. ReadableStreamDefaultControllerError(pull._branch1, r);
  25845. ReadableStreamDefaultControllerError(pull._branch2, r);
  25846. teeState.closedOrErrored = true;
  25847. });
  25848. return [branch1Stream, branch2Stream];
  25849. }
  25850. function create_ReadableStreamTeePullFunction() {
  25851. function f() {
  25852. var reader = f._reader,
  25853. branch1 = f._branch1,
  25854. branch2 = f._branch2,
  25855. teeState = f._teeState;
  25856. return ReadableStreamDefaultReaderRead(reader).then(function (result) {
  25857. assert(typeIsObject(result));
  25858. var value = result.value;
  25859. var done = result.done;
  25860. assert(typeof done === 'boolean');
  25861. if (done === true && teeState.closedOrErrored === false) {
  25862. if (teeState.canceled1 === false) {
  25863. ReadableStreamDefaultControllerClose(branch1);
  25864. }
  25865. if (teeState.canceled2 === false) {
  25866. ReadableStreamDefaultControllerClose(branch2);
  25867. }
  25868. teeState.closedOrErrored = true;
  25869. }
  25870. if (teeState.closedOrErrored === true) {
  25871. return;
  25872. }
  25873. var value1 = value;
  25874. var value2 = value;
  25875. if (teeState.canceled1 === false) {
  25876. ReadableStreamDefaultControllerEnqueue(branch1, value1);
  25877. }
  25878. if (teeState.canceled2 === false) {
  25879. ReadableStreamDefaultControllerEnqueue(branch2, value2);
  25880. }
  25881. });
  25882. }
  25883. return f;
  25884. }
  25885. function create_ReadableStreamTeeBranch1CancelFunction() {
  25886. function f(reason) {
  25887. var stream = f._stream,
  25888. teeState = f._teeState;
  25889. teeState.canceled1 = true;
  25890. teeState.reason1 = reason;
  25891. if (teeState.canceled2 === true) {
  25892. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  25893. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  25894. teeState._resolve(cancelResult);
  25895. }
  25896. return teeState.promise;
  25897. }
  25898. return f;
  25899. }
  25900. function create_ReadableStreamTeeBranch2CancelFunction() {
  25901. function f(reason) {
  25902. var stream = f._stream,
  25903. teeState = f._teeState;
  25904. teeState.canceled2 = true;
  25905. teeState.reason2 = reason;
  25906. if (teeState.canceled1 === true) {
  25907. var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]);
  25908. var cancelResult = ReadableStreamCancel(stream, compositeReason);
  25909. teeState._resolve(cancelResult);
  25910. }
  25911. return teeState.promise;
  25912. }
  25913. return f;
  25914. }
  25915. function ReadableStreamAddReadIntoRequest(stream) {
  25916. assert(IsReadableStreamBYOBReader(stream._reader) === true);
  25917. assert(stream._state === 'readable' || stream._state === 'closed');
  25918. var promise = new Promise(function (resolve, reject) {
  25919. var readIntoRequest = {
  25920. _resolve: resolve,
  25921. _reject: reject
  25922. };
  25923. stream._reader._readIntoRequests.push(readIntoRequest);
  25924. });
  25925. return promise;
  25926. }
  25927. function ReadableStreamAddReadRequest(stream) {
  25928. assert(IsReadableStreamDefaultReader(stream._reader) === true);
  25929. assert(stream._state === 'readable');
  25930. var promise = new Promise(function (resolve, reject) {
  25931. var readRequest = {
  25932. _resolve: resolve,
  25933. _reject: reject
  25934. };
  25935. stream._reader._readRequests.push(readRequest);
  25936. });
  25937. return promise;
  25938. }
  25939. function ReadableStreamCancel(stream, reason) {
  25940. stream._disturbed = true;
  25941. if (stream._state === 'closed') {
  25942. return Promise.resolve(undefined);
  25943. }
  25944. if (stream._state === 'errored') {
  25945. return Promise.reject(stream._storedError);
  25946. }
  25947. ReadableStreamClose(stream);
  25948. var sourceCancelPromise = stream._readableStreamController.__cancelSteps(reason);
  25949. return sourceCancelPromise.then(function () {
  25950. return undefined;
  25951. });
  25952. }
  25953. function ReadableStreamClose(stream) {
  25954. assert(stream._state === 'readable');
  25955. stream._state = 'closed';
  25956. var reader = stream._reader;
  25957. if (reader === undefined) {
  25958. return undefined;
  25959. }
  25960. if (IsReadableStreamDefaultReader(reader) === true) {
  25961. for (var i = 0; i < reader._readRequests.length; i++) {
  25962. var _resolve = reader._readRequests[i]._resolve;
  25963. _resolve(CreateIterResultObject(undefined, true));
  25964. }
  25965. reader._readRequests = [];
  25966. }
  25967. defaultReaderClosedPromiseResolve(reader);
  25968. return undefined;
  25969. }
  25970. function ReadableStreamError(stream, e) {
  25971. assert(IsReadableStream(stream) === true, 'stream must be ReadableStream');
  25972. assert(stream._state === 'readable', 'state must be readable');
  25973. stream._state = 'errored';
  25974. stream._storedError = e;
  25975. var reader = stream._reader;
  25976. if (reader === undefined) {
  25977. return undefined;
  25978. }
  25979. if (IsReadableStreamDefaultReader(reader) === true) {
  25980. for (var i = 0; i < reader._readRequests.length; i++) {
  25981. var readRequest = reader._readRequests[i];
  25982. readRequest._reject(e);
  25983. }
  25984. reader._readRequests = [];
  25985. } else {
  25986. assert(IsReadableStreamBYOBReader(reader), 'reader must be ReadableStreamBYOBReader');
  25987. for (var _i = 0; _i < reader._readIntoRequests.length; _i++) {
  25988. var readIntoRequest = reader._readIntoRequests[_i];
  25989. readIntoRequest._reject(e);
  25990. }
  25991. reader._readIntoRequests = [];
  25992. }
  25993. defaultReaderClosedPromiseReject(reader, e);
  25994. reader._closedPromise.catch(function () {});
  25995. }
  25996. function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
  25997. var reader = stream._reader;
  25998. assert(reader._readIntoRequests.length > 0);
  25999. var readIntoRequest = reader._readIntoRequests.shift();
  26000. readIntoRequest._resolve(CreateIterResultObject(chunk, done));
  26001. }
  26002. function ReadableStreamFulfillReadRequest(stream, chunk, done) {
  26003. var reader = stream._reader;
  26004. assert(reader._readRequests.length > 0);
  26005. var readRequest = reader._readRequests.shift();
  26006. readRequest._resolve(CreateIterResultObject(chunk, done));
  26007. }
  26008. function ReadableStreamGetNumReadIntoRequests(stream) {
  26009. return stream._reader._readIntoRequests.length;
  26010. }
  26011. function ReadableStreamGetNumReadRequests(stream) {
  26012. return stream._reader._readRequests.length;
  26013. }
  26014. function ReadableStreamHasBYOBReader(stream) {
  26015. var reader = stream._reader;
  26016. if (reader === undefined) {
  26017. return false;
  26018. }
  26019. if (IsReadableStreamBYOBReader(reader) === false) {
  26020. return false;
  26021. }
  26022. return true;
  26023. }
  26024. function ReadableStreamHasDefaultReader(stream) {
  26025. var reader = stream._reader;
  26026. if (reader === undefined) {
  26027. return false;
  26028. }
  26029. if (IsReadableStreamDefaultReader(reader) === false) {
  26030. return false;
  26031. }
  26032. return true;
  26033. }
  26034. var ReadableStreamDefaultReader = function () {
  26035. function ReadableStreamDefaultReader(stream) {
  26036. _classCallCheck(this, ReadableStreamDefaultReader);
  26037. if (IsReadableStream(stream) === false) {
  26038. throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance');
  26039. }
  26040. if (IsReadableStreamLocked(stream) === true) {
  26041. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  26042. }
  26043. ReadableStreamReaderGenericInitialize(this, stream);
  26044. this._readRequests = [];
  26045. }
  26046. _createClass(ReadableStreamDefaultReader, [{
  26047. key: 'cancel',
  26048. value: function cancel(reason) {
  26049. if (IsReadableStreamDefaultReader(this) === false) {
  26050. return Promise.reject(defaultReaderBrandCheckException('cancel'));
  26051. }
  26052. if (this._ownerReadableStream === undefined) {
  26053. return Promise.reject(readerLockException('cancel'));
  26054. }
  26055. return ReadableStreamReaderGenericCancel(this, reason);
  26056. }
  26057. }, {
  26058. key: 'read',
  26059. value: function read() {
  26060. if (IsReadableStreamDefaultReader(this) === false) {
  26061. return Promise.reject(defaultReaderBrandCheckException('read'));
  26062. }
  26063. if (this._ownerReadableStream === undefined) {
  26064. return Promise.reject(readerLockException('read from'));
  26065. }
  26066. return ReadableStreamDefaultReaderRead(this);
  26067. }
  26068. }, {
  26069. key: 'releaseLock',
  26070. value: function releaseLock() {
  26071. if (IsReadableStreamDefaultReader(this) === false) {
  26072. throw defaultReaderBrandCheckException('releaseLock');
  26073. }
  26074. if (this._ownerReadableStream === undefined) {
  26075. return;
  26076. }
  26077. if (this._readRequests.length > 0) {
  26078. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  26079. }
  26080. ReadableStreamReaderGenericRelease(this);
  26081. }
  26082. }, {
  26083. key: 'closed',
  26084. get: function get() {
  26085. if (IsReadableStreamDefaultReader(this) === false) {
  26086. return Promise.reject(defaultReaderBrandCheckException('closed'));
  26087. }
  26088. return this._closedPromise;
  26089. }
  26090. }]);
  26091. return ReadableStreamDefaultReader;
  26092. }();
  26093. var ReadableStreamBYOBReader = function () {
  26094. function ReadableStreamBYOBReader(stream) {
  26095. _classCallCheck(this, ReadableStreamBYOBReader);
  26096. if (!IsReadableStream(stream)) {
  26097. throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source');
  26098. }
  26099. if (IsReadableByteStreamController(stream._readableStreamController) === false) {
  26100. throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source');
  26101. }
  26102. if (IsReadableStreamLocked(stream)) {
  26103. throw new TypeError('This stream has already been locked for exclusive reading by another reader');
  26104. }
  26105. ReadableStreamReaderGenericInitialize(this, stream);
  26106. this._readIntoRequests = [];
  26107. }
  26108. _createClass(ReadableStreamBYOBReader, [{
  26109. key: 'cancel',
  26110. value: function cancel(reason) {
  26111. if (!IsReadableStreamBYOBReader(this)) {
  26112. return Promise.reject(byobReaderBrandCheckException('cancel'));
  26113. }
  26114. if (this._ownerReadableStream === undefined) {
  26115. return Promise.reject(readerLockException('cancel'));
  26116. }
  26117. return ReadableStreamReaderGenericCancel(this, reason);
  26118. }
  26119. }, {
  26120. key: 'read',
  26121. value: function read(view) {
  26122. if (!IsReadableStreamBYOBReader(this)) {
  26123. return Promise.reject(byobReaderBrandCheckException('read'));
  26124. }
  26125. if (this._ownerReadableStream === undefined) {
  26126. return Promise.reject(readerLockException('read from'));
  26127. }
  26128. if (!ArrayBuffer.isView(view)) {
  26129. return Promise.reject(new TypeError('view must be an array buffer view'));
  26130. }
  26131. if (view.byteLength === 0) {
  26132. return Promise.reject(new TypeError('view must have non-zero byteLength'));
  26133. }
  26134. return ReadableStreamBYOBReaderRead(this, view);
  26135. }
  26136. }, {
  26137. key: 'releaseLock',
  26138. value: function releaseLock() {
  26139. if (!IsReadableStreamBYOBReader(this)) {
  26140. throw byobReaderBrandCheckException('releaseLock');
  26141. }
  26142. if (this._ownerReadableStream === undefined) {
  26143. return;
  26144. }
  26145. if (this._readIntoRequests.length > 0) {
  26146. throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled');
  26147. }
  26148. ReadableStreamReaderGenericRelease(this);
  26149. }
  26150. }, {
  26151. key: 'closed',
  26152. get: function get() {
  26153. if (!IsReadableStreamBYOBReader(this)) {
  26154. return Promise.reject(byobReaderBrandCheckException('closed'));
  26155. }
  26156. return this._closedPromise;
  26157. }
  26158. }]);
  26159. return ReadableStreamBYOBReader;
  26160. }();
  26161. function IsReadableStreamBYOBReader(x) {
  26162. if (!typeIsObject(x)) {
  26163. return false;
  26164. }
  26165. if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) {
  26166. return false;
  26167. }
  26168. return true;
  26169. }
  26170. function IsReadableStreamDefaultReader(x) {
  26171. if (!typeIsObject(x)) {
  26172. return false;
  26173. }
  26174. if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) {
  26175. return false;
  26176. }
  26177. return true;
  26178. }
  26179. function ReadableStreamReaderGenericInitialize(reader, stream) {
  26180. reader._ownerReadableStream = stream;
  26181. stream._reader = reader;
  26182. if (stream._state === 'readable') {
  26183. defaultReaderClosedPromiseInitialize(reader);
  26184. } else if (stream._state === 'closed') {
  26185. defaultReaderClosedPromiseInitializeAsResolved(reader);
  26186. } else {
  26187. assert(stream._state === 'errored', 'state must be errored');
  26188. defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
  26189. reader._closedPromise.catch(function () {});
  26190. }
  26191. }
  26192. function ReadableStreamReaderGenericCancel(reader, reason) {
  26193. var stream = reader._ownerReadableStream;
  26194. assert(stream !== undefined);
  26195. return ReadableStreamCancel(stream, reason);
  26196. }
  26197. function ReadableStreamReaderGenericRelease(reader) {
  26198. assert(reader._ownerReadableStream !== undefined);
  26199. assert(reader._ownerReadableStream._reader === reader);
  26200. if (reader._ownerReadableStream._state === 'readable') {
  26201. defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  26202. } else {
  26203. defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness'));
  26204. }
  26205. reader._closedPromise.catch(function () {});
  26206. reader._ownerReadableStream._reader = undefined;
  26207. reader._ownerReadableStream = undefined;
  26208. }
  26209. function ReadableStreamBYOBReaderRead(reader, view) {
  26210. var stream = reader._ownerReadableStream;
  26211. assert(stream !== undefined);
  26212. stream._disturbed = true;
  26213. if (stream._state === 'errored') {
  26214. return Promise.reject(stream._storedError);
  26215. }
  26216. return ReadableByteStreamControllerPullInto(stream._readableStreamController, view);
  26217. }
  26218. function ReadableStreamDefaultReaderRead(reader) {
  26219. var stream = reader._ownerReadableStream;
  26220. assert(stream !== undefined);
  26221. stream._disturbed = true;
  26222. if (stream._state === 'closed') {
  26223. return Promise.resolve(CreateIterResultObject(undefined, true));
  26224. }
  26225. if (stream._state === 'errored') {
  26226. return Promise.reject(stream._storedError);
  26227. }
  26228. assert(stream._state === 'readable');
  26229. return stream._readableStreamController.__pullSteps();
  26230. }
  26231. var ReadableStreamDefaultController = function () {
  26232. function ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark) {
  26233. _classCallCheck(this, ReadableStreamDefaultController);
  26234. if (IsReadableStream(stream) === false) {
  26235. throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance');
  26236. }
  26237. if (stream._readableStreamController !== undefined) {
  26238. throw new TypeError('ReadableStreamDefaultController instances can only be created by the ReadableStream constructor');
  26239. }
  26240. this._controlledReadableStream = stream;
  26241. this._underlyingSource = underlyingSource;
  26242. this._queue = undefined;
  26243. this._queueTotalSize = undefined;
  26244. ResetQueue(this);
  26245. this._started = false;
  26246. this._closeRequested = false;
  26247. this._pullAgain = false;
  26248. this._pulling = false;
  26249. var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark);
  26250. this._strategySize = normalizedStrategy.size;
  26251. this._strategyHWM = normalizedStrategy.highWaterMark;
  26252. var controller = this;
  26253. var startResult = InvokeOrNoop(underlyingSource, 'start', [this]);
  26254. Promise.resolve(startResult).then(function () {
  26255. controller._started = true;
  26256. assert(controller._pulling === false);
  26257. assert(controller._pullAgain === false);
  26258. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  26259. }, function (r) {
  26260. ReadableStreamDefaultControllerErrorIfNeeded(controller, r);
  26261. }).catch(rethrowAssertionErrorRejection);
  26262. }
  26263. _createClass(ReadableStreamDefaultController, [{
  26264. key: 'close',
  26265. value: function close() {
  26266. if (IsReadableStreamDefaultController(this) === false) {
  26267. throw defaultControllerBrandCheckException('close');
  26268. }
  26269. if (this._closeRequested === true) {
  26270. throw new TypeError('The stream has already been closed; do not close it again!');
  26271. }
  26272. var state = this._controlledReadableStream._state;
  26273. if (state !== 'readable') {
  26274. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  26275. }
  26276. ReadableStreamDefaultControllerClose(this);
  26277. }
  26278. }, {
  26279. key: 'enqueue',
  26280. value: function enqueue(chunk) {
  26281. if (IsReadableStreamDefaultController(this) === false) {
  26282. throw defaultControllerBrandCheckException('enqueue');
  26283. }
  26284. if (this._closeRequested === true) {
  26285. throw new TypeError('stream is closed or draining');
  26286. }
  26287. var state = this._controlledReadableStream._state;
  26288. if (state !== 'readable') {
  26289. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  26290. }
  26291. return ReadableStreamDefaultControllerEnqueue(this, chunk);
  26292. }
  26293. }, {
  26294. key: 'error',
  26295. value: function error(e) {
  26296. if (IsReadableStreamDefaultController(this) === false) {
  26297. throw defaultControllerBrandCheckException('error');
  26298. }
  26299. var stream = this._controlledReadableStream;
  26300. if (stream._state !== 'readable') {
  26301. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  26302. }
  26303. ReadableStreamDefaultControllerError(this, e);
  26304. }
  26305. }, {
  26306. key: '__cancelSteps',
  26307. value: function __cancelSteps(reason) {
  26308. ResetQueue(this);
  26309. return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]);
  26310. }
  26311. }, {
  26312. key: '__pullSteps',
  26313. value: function __pullSteps() {
  26314. var stream = this._controlledReadableStream;
  26315. if (this._queue.length > 0) {
  26316. var chunk = DequeueValue(this);
  26317. if (this._closeRequested === true && this._queue.length === 0) {
  26318. ReadableStreamClose(stream);
  26319. } else {
  26320. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  26321. }
  26322. return Promise.resolve(CreateIterResultObject(chunk, false));
  26323. }
  26324. var pendingPromise = ReadableStreamAddReadRequest(stream);
  26325. ReadableStreamDefaultControllerCallPullIfNeeded(this);
  26326. return pendingPromise;
  26327. }
  26328. }, {
  26329. key: 'desiredSize',
  26330. get: function get() {
  26331. if (IsReadableStreamDefaultController(this) === false) {
  26332. throw defaultControllerBrandCheckException('desiredSize');
  26333. }
  26334. return ReadableStreamDefaultControllerGetDesiredSize(this);
  26335. }
  26336. }]);
  26337. return ReadableStreamDefaultController;
  26338. }();
  26339. function IsReadableStreamDefaultController(x) {
  26340. if (!typeIsObject(x)) {
  26341. return false;
  26342. }
  26343. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) {
  26344. return false;
  26345. }
  26346. return true;
  26347. }
  26348. function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
  26349. var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller);
  26350. if (shouldPull === false) {
  26351. return undefined;
  26352. }
  26353. if (controller._pulling === true) {
  26354. controller._pullAgain = true;
  26355. return undefined;
  26356. }
  26357. assert(controller._pullAgain === false);
  26358. controller._pulling = true;
  26359. var pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]);
  26360. pullPromise.then(function () {
  26361. controller._pulling = false;
  26362. if (controller._pullAgain === true) {
  26363. controller._pullAgain = false;
  26364. return ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  26365. }
  26366. return undefined;
  26367. }, function (e) {
  26368. ReadableStreamDefaultControllerErrorIfNeeded(controller, e);
  26369. }).catch(rethrowAssertionErrorRejection);
  26370. return undefined;
  26371. }
  26372. function ReadableStreamDefaultControllerShouldCallPull(controller) {
  26373. var stream = controller._controlledReadableStream;
  26374. if (stream._state === 'closed' || stream._state === 'errored') {
  26375. return false;
  26376. }
  26377. if (controller._closeRequested === true) {
  26378. return false;
  26379. }
  26380. if (controller._started === false) {
  26381. return false;
  26382. }
  26383. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  26384. return true;
  26385. }
  26386. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  26387. if (desiredSize > 0) {
  26388. return true;
  26389. }
  26390. return false;
  26391. }
  26392. function ReadableStreamDefaultControllerClose(controller) {
  26393. var stream = controller._controlledReadableStream;
  26394. assert(controller._closeRequested === false);
  26395. assert(stream._state === 'readable');
  26396. controller._closeRequested = true;
  26397. if (controller._queue.length === 0) {
  26398. ReadableStreamClose(stream);
  26399. }
  26400. }
  26401. function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
  26402. var stream = controller._controlledReadableStream;
  26403. assert(controller._closeRequested === false);
  26404. assert(stream._state === 'readable');
  26405. if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  26406. ReadableStreamFulfillReadRequest(stream, chunk, false);
  26407. } else {
  26408. var chunkSize = 1;
  26409. if (controller._strategySize !== undefined) {
  26410. var strategySize = controller._strategySize;
  26411. try {
  26412. chunkSize = strategySize(chunk);
  26413. } catch (chunkSizeE) {
  26414. ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE);
  26415. throw chunkSizeE;
  26416. }
  26417. }
  26418. try {
  26419. EnqueueValueWithSize(controller, chunk, chunkSize);
  26420. } catch (enqueueE) {
  26421. ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
  26422. throw enqueueE;
  26423. }
  26424. }
  26425. ReadableStreamDefaultControllerCallPullIfNeeded(controller);
  26426. return undefined;
  26427. }
  26428. function ReadableStreamDefaultControllerError(controller, e) {
  26429. var stream = controller._controlledReadableStream;
  26430. assert(stream._state === 'readable');
  26431. ResetQueue(controller);
  26432. ReadableStreamError(stream, e);
  26433. }
  26434. function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) {
  26435. if (controller._controlledReadableStream._state === 'readable') {
  26436. ReadableStreamDefaultControllerError(controller, e);
  26437. }
  26438. }
  26439. function ReadableStreamDefaultControllerGetDesiredSize(controller) {
  26440. var stream = controller._controlledReadableStream;
  26441. var state = stream._state;
  26442. if (state === 'errored') {
  26443. return null;
  26444. }
  26445. if (state === 'closed') {
  26446. return 0;
  26447. }
  26448. return controller._strategyHWM - controller._queueTotalSize;
  26449. }
  26450. var ReadableStreamBYOBRequest = function () {
  26451. function ReadableStreamBYOBRequest(controller, view) {
  26452. _classCallCheck(this, ReadableStreamBYOBRequest);
  26453. this._associatedReadableByteStreamController = controller;
  26454. this._view = view;
  26455. }
  26456. _createClass(ReadableStreamBYOBRequest, [{
  26457. key: 'respond',
  26458. value: function respond(bytesWritten) {
  26459. if (IsReadableStreamBYOBRequest(this) === false) {
  26460. throw byobRequestBrandCheckException('respond');
  26461. }
  26462. if (this._associatedReadableByteStreamController === undefined) {
  26463. throw new TypeError('This BYOB request has been invalidated');
  26464. }
  26465. ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
  26466. }
  26467. }, {
  26468. key: 'respondWithNewView',
  26469. value: function respondWithNewView(view) {
  26470. if (IsReadableStreamBYOBRequest(this) === false) {
  26471. throw byobRequestBrandCheckException('respond');
  26472. }
  26473. if (this._associatedReadableByteStreamController === undefined) {
  26474. throw new TypeError('This BYOB request has been invalidated');
  26475. }
  26476. if (!ArrayBuffer.isView(view)) {
  26477. throw new TypeError('You can only respond with array buffer views');
  26478. }
  26479. ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
  26480. }
  26481. }, {
  26482. key: 'view',
  26483. get: function get() {
  26484. return this._view;
  26485. }
  26486. }]);
  26487. return ReadableStreamBYOBRequest;
  26488. }();
  26489. var ReadableByteStreamController = function () {
  26490. function ReadableByteStreamController(stream, underlyingByteSource, highWaterMark) {
  26491. _classCallCheck(this, ReadableByteStreamController);
  26492. if (IsReadableStream(stream) === false) {
  26493. throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' + 'a byte source');
  26494. }
  26495. if (stream._readableStreamController !== undefined) {
  26496. throw new TypeError('ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' + 'source');
  26497. }
  26498. this._controlledReadableStream = stream;
  26499. this._underlyingByteSource = underlyingByteSource;
  26500. this._pullAgain = false;
  26501. this._pulling = false;
  26502. ReadableByteStreamControllerClearPendingPullIntos(this);
  26503. this._queue = this._queueTotalSize = undefined;
  26504. ResetQueue(this);
  26505. this._closeRequested = false;
  26506. this._started = false;
  26507. this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark);
  26508. var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
  26509. if (autoAllocateChunkSize !== undefined) {
  26510. if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
  26511. throw new RangeError('autoAllocateChunkSize must be a positive integer');
  26512. }
  26513. }
  26514. this._autoAllocateChunkSize = autoAllocateChunkSize;
  26515. this._pendingPullIntos = [];
  26516. var controller = this;
  26517. var startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]);
  26518. Promise.resolve(startResult).then(function () {
  26519. controller._started = true;
  26520. assert(controller._pulling === false);
  26521. assert(controller._pullAgain === false);
  26522. ReadableByteStreamControllerCallPullIfNeeded(controller);
  26523. }, function (r) {
  26524. if (stream._state === 'readable') {
  26525. ReadableByteStreamControllerError(controller, r);
  26526. }
  26527. }).catch(rethrowAssertionErrorRejection);
  26528. }
  26529. _createClass(ReadableByteStreamController, [{
  26530. key: 'close',
  26531. value: function close() {
  26532. if (IsReadableByteStreamController(this) === false) {
  26533. throw byteStreamControllerBrandCheckException('close');
  26534. }
  26535. if (this._closeRequested === true) {
  26536. throw new TypeError('The stream has already been closed; do not close it again!');
  26537. }
  26538. var state = this._controlledReadableStream._state;
  26539. if (state !== 'readable') {
  26540. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed');
  26541. }
  26542. ReadableByteStreamControllerClose(this);
  26543. }
  26544. }, {
  26545. key: 'enqueue',
  26546. value: function enqueue(chunk) {
  26547. if (IsReadableByteStreamController(this) === false) {
  26548. throw byteStreamControllerBrandCheckException('enqueue');
  26549. }
  26550. if (this._closeRequested === true) {
  26551. throw new TypeError('stream is closed or draining');
  26552. }
  26553. var state = this._controlledReadableStream._state;
  26554. if (state !== 'readable') {
  26555. throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to');
  26556. }
  26557. if (!ArrayBuffer.isView(chunk)) {
  26558. throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController');
  26559. }
  26560. ReadableByteStreamControllerEnqueue(this, chunk);
  26561. }
  26562. }, {
  26563. key: 'error',
  26564. value: function error(e) {
  26565. if (IsReadableByteStreamController(this) === false) {
  26566. throw byteStreamControllerBrandCheckException('error');
  26567. }
  26568. var stream = this._controlledReadableStream;
  26569. if (stream._state !== 'readable') {
  26570. throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored');
  26571. }
  26572. ReadableByteStreamControllerError(this, e);
  26573. }
  26574. }, {
  26575. key: '__cancelSteps',
  26576. value: function __cancelSteps(reason) {
  26577. if (this._pendingPullIntos.length > 0) {
  26578. var firstDescriptor = this._pendingPullIntos[0];
  26579. firstDescriptor.bytesFilled = 0;
  26580. }
  26581. ResetQueue(this);
  26582. return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]);
  26583. }
  26584. }, {
  26585. key: '__pullSteps',
  26586. value: function __pullSteps() {
  26587. var stream = this._controlledReadableStream;
  26588. assert(ReadableStreamHasDefaultReader(stream) === true);
  26589. if (this._queueTotalSize > 0) {
  26590. assert(ReadableStreamGetNumReadRequests(stream) === 0);
  26591. var entry = this._queue.shift();
  26592. this._queueTotalSize -= entry.byteLength;
  26593. ReadableByteStreamControllerHandleQueueDrain(this);
  26594. var view = void 0;
  26595. try {
  26596. view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
  26597. } catch (viewE) {
  26598. return Promise.reject(viewE);
  26599. }
  26600. return Promise.resolve(CreateIterResultObject(view, false));
  26601. }
  26602. var autoAllocateChunkSize = this._autoAllocateChunkSize;
  26603. if (autoAllocateChunkSize !== undefined) {
  26604. var buffer = void 0;
  26605. try {
  26606. buffer = new ArrayBuffer(autoAllocateChunkSize);
  26607. } catch (bufferE) {
  26608. return Promise.reject(bufferE);
  26609. }
  26610. var pullIntoDescriptor = {
  26611. buffer: buffer,
  26612. byteOffset: 0,
  26613. byteLength: autoAllocateChunkSize,
  26614. bytesFilled: 0,
  26615. elementSize: 1,
  26616. ctor: Uint8Array,
  26617. readerType: 'default'
  26618. };
  26619. this._pendingPullIntos.push(pullIntoDescriptor);
  26620. }
  26621. var promise = ReadableStreamAddReadRequest(stream);
  26622. ReadableByteStreamControllerCallPullIfNeeded(this);
  26623. return promise;
  26624. }
  26625. }, {
  26626. key: 'byobRequest',
  26627. get: function get() {
  26628. if (IsReadableByteStreamController(this) === false) {
  26629. throw byteStreamControllerBrandCheckException('byobRequest');
  26630. }
  26631. if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
  26632. var firstDescriptor = this._pendingPullIntos[0];
  26633. var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled);
  26634. this._byobRequest = new ReadableStreamBYOBRequest(this, view);
  26635. }
  26636. return this._byobRequest;
  26637. }
  26638. }, {
  26639. key: 'desiredSize',
  26640. get: function get() {
  26641. if (IsReadableByteStreamController(this) === false) {
  26642. throw byteStreamControllerBrandCheckException('desiredSize');
  26643. }
  26644. return ReadableByteStreamControllerGetDesiredSize(this);
  26645. }
  26646. }]);
  26647. return ReadableByteStreamController;
  26648. }();
  26649. function IsReadableByteStreamController(x) {
  26650. if (!typeIsObject(x)) {
  26651. return false;
  26652. }
  26653. if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) {
  26654. return false;
  26655. }
  26656. return true;
  26657. }
  26658. function IsReadableStreamBYOBRequest(x) {
  26659. if (!typeIsObject(x)) {
  26660. return false;
  26661. }
  26662. if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) {
  26663. return false;
  26664. }
  26665. return true;
  26666. }
  26667. function ReadableByteStreamControllerCallPullIfNeeded(controller) {
  26668. var shouldPull = ReadableByteStreamControllerShouldCallPull(controller);
  26669. if (shouldPull === false) {
  26670. return undefined;
  26671. }
  26672. if (controller._pulling === true) {
  26673. controller._pullAgain = true;
  26674. return undefined;
  26675. }
  26676. assert(controller._pullAgain === false);
  26677. controller._pulling = true;
  26678. var pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]);
  26679. pullPromise.then(function () {
  26680. controller._pulling = false;
  26681. if (controller._pullAgain === true) {
  26682. controller._pullAgain = false;
  26683. ReadableByteStreamControllerCallPullIfNeeded(controller);
  26684. }
  26685. }, function (e) {
  26686. if (controller._controlledReadableStream._state === 'readable') {
  26687. ReadableByteStreamControllerError(controller, e);
  26688. }
  26689. }).catch(rethrowAssertionErrorRejection);
  26690. return undefined;
  26691. }
  26692. function ReadableByteStreamControllerClearPendingPullIntos(controller) {
  26693. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  26694. controller._pendingPullIntos = [];
  26695. }
  26696. function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
  26697. assert(stream._state !== 'errored', 'state must not be errored');
  26698. var done = false;
  26699. if (stream._state === 'closed') {
  26700. assert(pullIntoDescriptor.bytesFilled === 0);
  26701. done = true;
  26702. }
  26703. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  26704. if (pullIntoDescriptor.readerType === 'default') {
  26705. ReadableStreamFulfillReadRequest(stream, filledView, done);
  26706. } else {
  26707. assert(pullIntoDescriptor.readerType === 'byob');
  26708. ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
  26709. }
  26710. }
  26711. function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
  26712. var bytesFilled = pullIntoDescriptor.bytesFilled;
  26713. var elementSize = pullIntoDescriptor.elementSize;
  26714. assert(bytesFilled <= pullIntoDescriptor.byteLength);
  26715. assert(bytesFilled % elementSize === 0);
  26716. return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
  26717. }
  26718. function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
  26719. controller._queue.push({
  26720. buffer: buffer,
  26721. byteOffset: byteOffset,
  26722. byteLength: byteLength
  26723. });
  26724. controller._queueTotalSize += byteLength;
  26725. }
  26726. function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
  26727. var elementSize = pullIntoDescriptor.elementSize;
  26728. var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
  26729. var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
  26730. var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
  26731. var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
  26732. var totalBytesToCopyRemaining = maxBytesToCopy;
  26733. var ready = false;
  26734. if (maxAlignedBytes > currentAlignedBytes) {
  26735. totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
  26736. ready = true;
  26737. }
  26738. var queue = controller._queue;
  26739. while (totalBytesToCopyRemaining > 0) {
  26740. var headOfQueue = queue[0];
  26741. var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength);
  26742. var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  26743. ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy);
  26744. if (headOfQueue.byteLength === bytesToCopy) {
  26745. queue.shift();
  26746. } else {
  26747. headOfQueue.byteOffset += bytesToCopy;
  26748. headOfQueue.byteLength -= bytesToCopy;
  26749. }
  26750. controller._queueTotalSize -= bytesToCopy;
  26751. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor);
  26752. totalBytesToCopyRemaining -= bytesToCopy;
  26753. }
  26754. if (ready === false) {
  26755. assert(controller._queueTotalSize === 0, 'queue must be empty');
  26756. assert(pullIntoDescriptor.bytesFilled > 0);
  26757. assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
  26758. }
  26759. return ready;
  26760. }
  26761. function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
  26762. assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor);
  26763. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  26764. pullIntoDescriptor.bytesFilled += size;
  26765. }
  26766. function ReadableByteStreamControllerHandleQueueDrain(controller) {
  26767. assert(controller._controlledReadableStream._state === 'readable');
  26768. if (controller._queueTotalSize === 0 && controller._closeRequested === true) {
  26769. ReadableStreamClose(controller._controlledReadableStream);
  26770. } else {
  26771. ReadableByteStreamControllerCallPullIfNeeded(controller);
  26772. }
  26773. }
  26774. function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
  26775. if (controller._byobRequest === undefined) {
  26776. return;
  26777. }
  26778. controller._byobRequest._associatedReadableByteStreamController = undefined;
  26779. controller._byobRequest._view = undefined;
  26780. controller._byobRequest = undefined;
  26781. }
  26782. function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
  26783. assert(controller._closeRequested === false);
  26784. while (controller._pendingPullIntos.length > 0) {
  26785. if (controller._queueTotalSize === 0) {
  26786. return;
  26787. }
  26788. var pullIntoDescriptor = controller._pendingPullIntos[0];
  26789. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  26790. ReadableByteStreamControllerShiftPendingPullInto(controller);
  26791. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  26792. }
  26793. }
  26794. }
  26795. function ReadableByteStreamControllerPullInto(controller, view) {
  26796. var stream = controller._controlledReadableStream;
  26797. var elementSize = 1;
  26798. if (view.constructor !== DataView) {
  26799. elementSize = view.constructor.BYTES_PER_ELEMENT;
  26800. }
  26801. var ctor = view.constructor;
  26802. var pullIntoDescriptor = {
  26803. buffer: view.buffer,
  26804. byteOffset: view.byteOffset,
  26805. byteLength: view.byteLength,
  26806. bytesFilled: 0,
  26807. elementSize: elementSize,
  26808. ctor: ctor,
  26809. readerType: 'byob'
  26810. };
  26811. if (controller._pendingPullIntos.length > 0) {
  26812. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  26813. controller._pendingPullIntos.push(pullIntoDescriptor);
  26814. return ReadableStreamAddReadIntoRequest(stream);
  26815. }
  26816. if (stream._state === 'closed') {
  26817. var emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
  26818. return Promise.resolve(CreateIterResultObject(emptyView, true));
  26819. }
  26820. if (controller._queueTotalSize > 0) {
  26821. if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) {
  26822. var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
  26823. ReadableByteStreamControllerHandleQueueDrain(controller);
  26824. return Promise.resolve(CreateIterResultObject(filledView, false));
  26825. }
  26826. if (controller._closeRequested === true) {
  26827. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  26828. ReadableByteStreamControllerError(controller, e);
  26829. return Promise.reject(e);
  26830. }
  26831. }
  26832. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  26833. controller._pendingPullIntos.push(pullIntoDescriptor);
  26834. var promise = ReadableStreamAddReadIntoRequest(stream);
  26835. ReadableByteStreamControllerCallPullIfNeeded(controller);
  26836. return promise;
  26837. }
  26838. function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
  26839. firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer);
  26840. assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0');
  26841. var stream = controller._controlledReadableStream;
  26842. if (ReadableStreamHasBYOBReader(stream) === true) {
  26843. while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  26844. var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
  26845. ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
  26846. }
  26847. }
  26848. }
  26849. function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
  26850. if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) {
  26851. throw new RangeError('bytesWritten out of range');
  26852. }
  26853. ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
  26854. if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
  26855. return;
  26856. }
  26857. ReadableByteStreamControllerShiftPendingPullInto(controller);
  26858. var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
  26859. if (remainderSize > 0) {
  26860. var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
  26861. var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end);
  26862. ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
  26863. }
  26864. pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer);
  26865. pullIntoDescriptor.bytesFilled -= remainderSize;
  26866. ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor);
  26867. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  26868. }
  26869. function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
  26870. var firstDescriptor = controller._pendingPullIntos[0];
  26871. var stream = controller._controlledReadableStream;
  26872. if (stream._state === 'closed') {
  26873. if (bytesWritten !== 0) {
  26874. throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream');
  26875. }
  26876. ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
  26877. } else {
  26878. assert(stream._state === 'readable');
  26879. ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
  26880. }
  26881. }
  26882. function ReadableByteStreamControllerShiftPendingPullInto(controller) {
  26883. var descriptor = controller._pendingPullIntos.shift();
  26884. ReadableByteStreamControllerInvalidateBYOBRequest(controller);
  26885. return descriptor;
  26886. }
  26887. function ReadableByteStreamControllerShouldCallPull(controller) {
  26888. var stream = controller._controlledReadableStream;
  26889. if (stream._state !== 'readable') {
  26890. return false;
  26891. }
  26892. if (controller._closeRequested === true) {
  26893. return false;
  26894. }
  26895. if (controller._started === false) {
  26896. return false;
  26897. }
  26898. if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) {
  26899. return true;
  26900. }
  26901. if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) {
  26902. return true;
  26903. }
  26904. if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {
  26905. return true;
  26906. }
  26907. return false;
  26908. }
  26909. function ReadableByteStreamControllerClose(controller) {
  26910. var stream = controller._controlledReadableStream;
  26911. assert(controller._closeRequested === false);
  26912. assert(stream._state === 'readable');
  26913. if (controller._queueTotalSize > 0) {
  26914. controller._closeRequested = true;
  26915. return;
  26916. }
  26917. if (controller._pendingPullIntos.length > 0) {
  26918. var firstPendingPullInto = controller._pendingPullIntos[0];
  26919. if (firstPendingPullInto.bytesFilled > 0) {
  26920. var e = new TypeError('Insufficient bytes to fill elements in the given buffer');
  26921. ReadableByteStreamControllerError(controller, e);
  26922. throw e;
  26923. }
  26924. }
  26925. ReadableStreamClose(stream);
  26926. }
  26927. function ReadableByteStreamControllerEnqueue(controller, chunk) {
  26928. var stream = controller._controlledReadableStream;
  26929. assert(controller._closeRequested === false);
  26930. assert(stream._state === 'readable');
  26931. var buffer = chunk.buffer;
  26932. var byteOffset = chunk.byteOffset;
  26933. var byteLength = chunk.byteLength;
  26934. var transferredBuffer = TransferArrayBuffer(buffer);
  26935. if (ReadableStreamHasDefaultReader(stream) === true) {
  26936. if (ReadableStreamGetNumReadRequests(stream) === 0) {
  26937. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  26938. } else {
  26939. assert(controller._queue.length === 0);
  26940. var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
  26941. ReadableStreamFulfillReadRequest(stream, transferredView, false);
  26942. }
  26943. } else if (ReadableStreamHasBYOBReader(stream) === true) {
  26944. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  26945. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
  26946. } else {
  26947. assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked');
  26948. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
  26949. }
  26950. }
  26951. function ReadableByteStreamControllerError(controller, e) {
  26952. var stream = controller._controlledReadableStream;
  26953. assert(stream._state === 'readable');
  26954. ReadableByteStreamControllerClearPendingPullIntos(controller);
  26955. ResetQueue(controller);
  26956. ReadableStreamError(stream, e);
  26957. }
  26958. function ReadableByteStreamControllerGetDesiredSize(controller) {
  26959. var stream = controller._controlledReadableStream;
  26960. var state = stream._state;
  26961. if (state === 'errored') {
  26962. return null;
  26963. }
  26964. if (state === 'closed') {
  26965. return 0;
  26966. }
  26967. return controller._strategyHWM - controller._queueTotalSize;
  26968. }
  26969. function ReadableByteStreamControllerRespond(controller, bytesWritten) {
  26970. bytesWritten = Number(bytesWritten);
  26971. if (IsFiniteNonNegativeNumber(bytesWritten) === false) {
  26972. throw new RangeError('bytesWritten must be a finite');
  26973. }
  26974. assert(controller._pendingPullIntos.length > 0);
  26975. ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
  26976. }
  26977. function ReadableByteStreamControllerRespondWithNewView(controller, view) {
  26978. assert(controller._pendingPullIntos.length > 0);
  26979. var firstDescriptor = controller._pendingPullIntos[0];
  26980. if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) {
  26981. throw new RangeError('The region specified by view does not match byobRequest');
  26982. }
  26983. if (firstDescriptor.byteLength !== view.byteLength) {
  26984. throw new RangeError('The buffer of view has different capacity than byobRequest');
  26985. }
  26986. firstDescriptor.buffer = view.buffer;
  26987. ReadableByteStreamControllerRespondInternal(controller, view.byteLength);
  26988. }
  26989. function streamBrandCheckException(name) {
  26990. return new TypeError('ReadableStream.prototype.' + name + ' can only be used on a ReadableStream');
  26991. }
  26992. function readerLockException(name) {
  26993. return new TypeError('Cannot ' + name + ' a stream using a released reader');
  26994. }
  26995. function defaultReaderBrandCheckException(name) {
  26996. return new TypeError('ReadableStreamDefaultReader.prototype.' + name + ' can only be used on a ReadableStreamDefaultReader');
  26997. }
  26998. function defaultReaderClosedPromiseInitialize(reader) {
  26999. reader._closedPromise = new Promise(function (resolve, reject) {
  27000. reader._closedPromise_resolve = resolve;
  27001. reader._closedPromise_reject = reject;
  27002. });
  27003. }
  27004. function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
  27005. reader._closedPromise = Promise.reject(reason);
  27006. reader._closedPromise_resolve = undefined;
  27007. reader._closedPromise_reject = undefined;
  27008. }
  27009. function defaultReaderClosedPromiseInitializeAsResolved(reader) {
  27010. reader._closedPromise = Promise.resolve(undefined);
  27011. reader._closedPromise_resolve = undefined;
  27012. reader._closedPromise_reject = undefined;
  27013. }
  27014. function defaultReaderClosedPromiseReject(reader, reason) {
  27015. assert(reader._closedPromise_resolve !== undefined);
  27016. assert(reader._closedPromise_reject !== undefined);
  27017. reader._closedPromise_reject(reason);
  27018. reader._closedPromise_resolve = undefined;
  27019. reader._closedPromise_reject = undefined;
  27020. }
  27021. function defaultReaderClosedPromiseResetToRejected(reader, reason) {
  27022. assert(reader._closedPromise_resolve === undefined);
  27023. assert(reader._closedPromise_reject === undefined);
  27024. reader._closedPromise = Promise.reject(reason);
  27025. }
  27026. function defaultReaderClosedPromiseResolve(reader) {
  27027. assert(reader._closedPromise_resolve !== undefined);
  27028. assert(reader._closedPromise_reject !== undefined);
  27029. reader._closedPromise_resolve(undefined);
  27030. reader._closedPromise_resolve = undefined;
  27031. reader._closedPromise_reject = undefined;
  27032. }
  27033. function byobReaderBrandCheckException(name) {
  27034. return new TypeError('ReadableStreamBYOBReader.prototype.' + name + ' can only be used on a ReadableStreamBYOBReader');
  27035. }
  27036. function defaultControllerBrandCheckException(name) {
  27037. return new TypeError('ReadableStreamDefaultController.prototype.' + name + ' can only be used on a ReadableStreamDefaultController');
  27038. }
  27039. function byobRequestBrandCheckException(name) {
  27040. return new TypeError('ReadableStreamBYOBRequest.prototype.' + name + ' can only be used on a ReadableStreamBYOBRequest');
  27041. }
  27042. function byteStreamControllerBrandCheckException(name) {
  27043. return new TypeError('ReadableByteStreamController.prototype.' + name + ' can only be used on a ReadableByteStreamController');
  27044. }
  27045. function ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise) {
  27046. try {
  27047. Promise.prototype.then.call(promise, undefined, function () {});
  27048. } catch (e) {}
  27049. }
  27050. }, function (module, exports, __w_pdfjs_require__) {
  27051. "use strict";
  27052. var transformStream = __w_pdfjs_require__(6);
  27053. var readableStream = __w_pdfjs_require__(4);
  27054. var writableStream = __w_pdfjs_require__(2);
  27055. exports.TransformStream = transformStream.TransformStream;
  27056. exports.ReadableStream = readableStream.ReadableStream;
  27057. exports.IsReadableStreamDisturbed = readableStream.IsReadableStreamDisturbed;
  27058. exports.ReadableStreamDefaultControllerClose = readableStream.ReadableStreamDefaultControllerClose;
  27059. exports.ReadableStreamDefaultControllerEnqueue = readableStream.ReadableStreamDefaultControllerEnqueue;
  27060. exports.ReadableStreamDefaultControllerError = readableStream.ReadableStreamDefaultControllerError;
  27061. exports.ReadableStreamDefaultControllerGetDesiredSize = readableStream.ReadableStreamDefaultControllerGetDesiredSize;
  27062. exports.AcquireWritableStreamDefaultWriter = writableStream.AcquireWritableStreamDefaultWriter;
  27063. exports.IsWritableStream = writableStream.IsWritableStream;
  27064. exports.IsWritableStreamLocked = writableStream.IsWritableStreamLocked;
  27065. exports.WritableStream = writableStream.WritableStream;
  27066. exports.WritableStreamAbort = writableStream.WritableStreamAbort;
  27067. exports.WritableStreamDefaultControllerError = writableStream.WritableStreamDefaultControllerError;
  27068. exports.WritableStreamDefaultWriterCloseWithErrorPropagation = writableStream.WritableStreamDefaultWriterCloseWithErrorPropagation;
  27069. exports.WritableStreamDefaultWriterRelease = writableStream.WritableStreamDefaultWriterRelease;
  27070. exports.WritableStreamDefaultWriterWrite = writableStream.WritableStreamDefaultWriterWrite;
  27071. }, function (module, exports, __w_pdfjs_require__) {
  27072. "use strict";
  27073. var _createClass = function () {
  27074. function defineProperties(target, props) {
  27075. for (var i = 0; i < props.length; i++) {
  27076. var descriptor = props[i];
  27077. descriptor.enumerable = descriptor.enumerable || false;
  27078. descriptor.configurable = true;
  27079. if ("value" in descriptor) descriptor.writable = true;
  27080. Object.defineProperty(target, descriptor.key, descriptor);
  27081. }
  27082. }
  27083. return function (Constructor, protoProps, staticProps) {
  27084. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  27085. if (staticProps) defineProperties(Constructor, staticProps);
  27086. return Constructor;
  27087. };
  27088. }();
  27089. function _classCallCheck(instance, Constructor) {
  27090. if (!(instance instanceof Constructor)) {
  27091. throw new TypeError("Cannot call a class as a function");
  27092. }
  27093. }
  27094. var _require = __w_pdfjs_require__(1),
  27095. assert = _require.assert;
  27096. var _require2 = __w_pdfjs_require__(0),
  27097. InvokeOrNoop = _require2.InvokeOrNoop,
  27098. PromiseInvokeOrPerformFallback = _require2.PromiseInvokeOrPerformFallback,
  27099. PromiseInvokeOrNoop = _require2.PromiseInvokeOrNoop,
  27100. typeIsObject = _require2.typeIsObject;
  27101. var _require3 = __w_pdfjs_require__(4),
  27102. ReadableStream = _require3.ReadableStream,
  27103. ReadableStreamDefaultControllerClose = _require3.ReadableStreamDefaultControllerClose,
  27104. ReadableStreamDefaultControllerEnqueue = _require3.ReadableStreamDefaultControllerEnqueue,
  27105. ReadableStreamDefaultControllerError = _require3.ReadableStreamDefaultControllerError,
  27106. ReadableStreamDefaultControllerGetDesiredSize = _require3.ReadableStreamDefaultControllerGetDesiredSize;
  27107. var _require4 = __w_pdfjs_require__(2),
  27108. WritableStream = _require4.WritableStream,
  27109. WritableStreamDefaultControllerError = _require4.WritableStreamDefaultControllerError;
  27110. function TransformStreamCloseReadable(transformStream) {
  27111. if (transformStream._errored === true) {
  27112. throw new TypeError('TransformStream is already errored');
  27113. }
  27114. if (transformStream._readableClosed === true) {
  27115. throw new TypeError('Readable side is already closed');
  27116. }
  27117. TransformStreamCloseReadableInternal(transformStream);
  27118. }
  27119. function TransformStreamEnqueueToReadable(transformStream, chunk) {
  27120. if (transformStream._errored === true) {
  27121. throw new TypeError('TransformStream is already errored');
  27122. }
  27123. if (transformStream._readableClosed === true) {
  27124. throw new TypeError('Readable side is already closed');
  27125. }
  27126. var controller = transformStream._readableController;
  27127. try {
  27128. ReadableStreamDefaultControllerEnqueue(controller, chunk);
  27129. } catch (e) {
  27130. transformStream._readableClosed = true;
  27131. TransformStreamErrorIfNeeded(transformStream, e);
  27132. throw transformStream._storedError;
  27133. }
  27134. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
  27135. var maybeBackpressure = desiredSize <= 0;
  27136. if (maybeBackpressure === true && transformStream._backpressure === false) {
  27137. TransformStreamSetBackpressure(transformStream, true);
  27138. }
  27139. }
  27140. function TransformStreamError(transformStream, e) {
  27141. if (transformStream._errored === true) {
  27142. throw new TypeError('TransformStream is already errored');
  27143. }
  27144. TransformStreamErrorInternal(transformStream, e);
  27145. }
  27146. function TransformStreamCloseReadableInternal(transformStream) {
  27147. assert(transformStream._errored === false);
  27148. assert(transformStream._readableClosed === false);
  27149. try {
  27150. ReadableStreamDefaultControllerClose(transformStream._readableController);
  27151. } catch (e) {
  27152. assert(false);
  27153. }
  27154. transformStream._readableClosed = true;
  27155. }
  27156. function TransformStreamErrorIfNeeded(transformStream, e) {
  27157. if (transformStream._errored === false) {
  27158. TransformStreamErrorInternal(transformStream, e);
  27159. }
  27160. }
  27161. function TransformStreamErrorInternal(transformStream, e) {
  27162. assert(transformStream._errored === false);
  27163. transformStream._errored = true;
  27164. transformStream._storedError = e;
  27165. if (transformStream._writableDone === false) {
  27166. WritableStreamDefaultControllerError(transformStream._writableController, e);
  27167. }
  27168. if (transformStream._readableClosed === false) {
  27169. ReadableStreamDefaultControllerError(transformStream._readableController, e);
  27170. }
  27171. }
  27172. function TransformStreamReadableReadyPromise(transformStream) {
  27173. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  27174. if (transformStream._backpressure === false) {
  27175. return Promise.resolve();
  27176. }
  27177. assert(transformStream._backpressure === true, '_backpressure should have been initialized');
  27178. return transformStream._backpressureChangePromise;
  27179. }
  27180. function TransformStreamSetBackpressure(transformStream, backpressure) {
  27181. assert(transformStream._backpressure !== backpressure, 'TransformStreamSetBackpressure() should be called only when backpressure is changed');
  27182. if (transformStream._backpressureChangePromise !== undefined) {
  27183. transformStream._backpressureChangePromise_resolve(backpressure);
  27184. }
  27185. transformStream._backpressureChangePromise = new Promise(function (resolve) {
  27186. transformStream._backpressureChangePromise_resolve = resolve;
  27187. });
  27188. transformStream._backpressureChangePromise.then(function (resolution) {
  27189. assert(resolution !== backpressure, '_backpressureChangePromise should be fulfilled only when backpressure is changed');
  27190. });
  27191. transformStream._backpressure = backpressure;
  27192. }
  27193. function TransformStreamDefaultTransform(chunk, transformStreamController) {
  27194. var transformStream = transformStreamController._controlledTransformStream;
  27195. TransformStreamEnqueueToReadable(transformStream, chunk);
  27196. return Promise.resolve();
  27197. }
  27198. function TransformStreamTransform(transformStream, chunk) {
  27199. assert(transformStream._errored === false);
  27200. assert(transformStream._transforming === false);
  27201. assert(transformStream._backpressure === false);
  27202. transformStream._transforming = true;
  27203. var transformer = transformStream._transformer;
  27204. var controller = transformStream._transformStreamController;
  27205. var transformPromise = PromiseInvokeOrPerformFallback(transformer, 'transform', [chunk, controller], TransformStreamDefaultTransform, [chunk, controller]);
  27206. return transformPromise.then(function () {
  27207. transformStream._transforming = false;
  27208. return TransformStreamReadableReadyPromise(transformStream);
  27209. }, function (e) {
  27210. TransformStreamErrorIfNeeded(transformStream, e);
  27211. return Promise.reject(e);
  27212. });
  27213. }
  27214. function IsTransformStreamDefaultController(x) {
  27215. if (!typeIsObject(x)) {
  27216. return false;
  27217. }
  27218. if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) {
  27219. return false;
  27220. }
  27221. return true;
  27222. }
  27223. function IsTransformStream(x) {
  27224. if (!typeIsObject(x)) {
  27225. return false;
  27226. }
  27227. if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) {
  27228. return false;
  27229. }
  27230. return true;
  27231. }
  27232. var TransformStreamSink = function () {
  27233. function TransformStreamSink(transformStream, startPromise) {
  27234. _classCallCheck(this, TransformStreamSink);
  27235. this._transformStream = transformStream;
  27236. this._startPromise = startPromise;
  27237. }
  27238. _createClass(TransformStreamSink, [{
  27239. key: 'start',
  27240. value: function start(c) {
  27241. var transformStream = this._transformStream;
  27242. transformStream._writableController = c;
  27243. return this._startPromise.then(function () {
  27244. return TransformStreamReadableReadyPromise(transformStream);
  27245. });
  27246. }
  27247. }, {
  27248. key: 'write',
  27249. value: function write(chunk) {
  27250. var transformStream = this._transformStream;
  27251. return TransformStreamTransform(transformStream, chunk);
  27252. }
  27253. }, {
  27254. key: 'abort',
  27255. value: function abort() {
  27256. var transformStream = this._transformStream;
  27257. transformStream._writableDone = true;
  27258. TransformStreamErrorInternal(transformStream, new TypeError('Writable side aborted'));
  27259. }
  27260. }, {
  27261. key: 'close',
  27262. value: function close() {
  27263. var transformStream = this._transformStream;
  27264. assert(transformStream._transforming === false);
  27265. transformStream._writableDone = true;
  27266. var flushPromise = PromiseInvokeOrNoop(transformStream._transformer, 'flush', [transformStream._transformStreamController]);
  27267. return flushPromise.then(function () {
  27268. if (transformStream._errored === true) {
  27269. return Promise.reject(transformStream._storedError);
  27270. }
  27271. if (transformStream._readableClosed === false) {
  27272. TransformStreamCloseReadableInternal(transformStream);
  27273. }
  27274. return Promise.resolve();
  27275. }).catch(function (r) {
  27276. TransformStreamErrorIfNeeded(transformStream, r);
  27277. return Promise.reject(transformStream._storedError);
  27278. });
  27279. }
  27280. }]);
  27281. return TransformStreamSink;
  27282. }();
  27283. var TransformStreamSource = function () {
  27284. function TransformStreamSource(transformStream, startPromise) {
  27285. _classCallCheck(this, TransformStreamSource);
  27286. this._transformStream = transformStream;
  27287. this._startPromise = startPromise;
  27288. }
  27289. _createClass(TransformStreamSource, [{
  27290. key: 'start',
  27291. value: function start(c) {
  27292. var transformStream = this._transformStream;
  27293. transformStream._readableController = c;
  27294. return this._startPromise.then(function () {
  27295. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  27296. if (transformStream._backpressure === true) {
  27297. return Promise.resolve();
  27298. }
  27299. assert(transformStream._backpressure === false, '_backpressure should have been initialized');
  27300. return transformStream._backpressureChangePromise;
  27301. });
  27302. }
  27303. }, {
  27304. key: 'pull',
  27305. value: function pull() {
  27306. var transformStream = this._transformStream;
  27307. assert(transformStream._backpressure === true, 'pull() should be never called while _backpressure is false');
  27308. assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized');
  27309. TransformStreamSetBackpressure(transformStream, false);
  27310. return transformStream._backpressureChangePromise;
  27311. }
  27312. }, {
  27313. key: 'cancel',
  27314. value: function cancel() {
  27315. var transformStream = this._transformStream;
  27316. transformStream._readableClosed = true;
  27317. TransformStreamErrorInternal(transformStream, new TypeError('Readable side canceled'));
  27318. }
  27319. }]);
  27320. return TransformStreamSource;
  27321. }();
  27322. var TransformStreamDefaultController = function () {
  27323. function TransformStreamDefaultController(transformStream) {
  27324. _classCallCheck(this, TransformStreamDefaultController);
  27325. if (IsTransformStream(transformStream) === false) {
  27326. throw new TypeError('TransformStreamDefaultController can only be ' + 'constructed with a TransformStream instance');
  27327. }
  27328. if (transformStream._transformStreamController !== undefined) {
  27329. throw new TypeError('TransformStreamDefaultController instances can ' + 'only be created by the TransformStream constructor');
  27330. }
  27331. this._controlledTransformStream = transformStream;
  27332. }
  27333. _createClass(TransformStreamDefaultController, [{
  27334. key: 'enqueue',
  27335. value: function enqueue(chunk) {
  27336. if (IsTransformStreamDefaultController(this) === false) {
  27337. throw defaultControllerBrandCheckException('enqueue');
  27338. }
  27339. TransformStreamEnqueueToReadable(this._controlledTransformStream, chunk);
  27340. }
  27341. }, {
  27342. key: 'close',
  27343. value: function close() {
  27344. if (IsTransformStreamDefaultController(this) === false) {
  27345. throw defaultControllerBrandCheckException('close');
  27346. }
  27347. TransformStreamCloseReadable(this._controlledTransformStream);
  27348. }
  27349. }, {
  27350. key: 'error',
  27351. value: function error(reason) {
  27352. if (IsTransformStreamDefaultController(this) === false) {
  27353. throw defaultControllerBrandCheckException('error');
  27354. }
  27355. TransformStreamError(this._controlledTransformStream, reason);
  27356. }
  27357. }, {
  27358. key: 'desiredSize',
  27359. get: function get() {
  27360. if (IsTransformStreamDefaultController(this) === false) {
  27361. throw defaultControllerBrandCheckException('desiredSize');
  27362. }
  27363. var transformStream = this._controlledTransformStream;
  27364. var readableController = transformStream._readableController;
  27365. return ReadableStreamDefaultControllerGetDesiredSize(readableController);
  27366. }
  27367. }]);
  27368. return TransformStreamDefaultController;
  27369. }();
  27370. var TransformStream = function () {
  27371. function TransformStream() {
  27372. var transformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  27373. _classCallCheck(this, TransformStream);
  27374. this._transformer = transformer;
  27375. var readableStrategy = transformer.readableStrategy,
  27376. writableStrategy = transformer.writableStrategy;
  27377. this._transforming = false;
  27378. this._errored = false;
  27379. this._storedError = undefined;
  27380. this._writableController = undefined;
  27381. this._readableController = undefined;
  27382. this._transformStreamController = undefined;
  27383. this._writableDone = false;
  27384. this._readableClosed = false;
  27385. this._backpressure = undefined;
  27386. this._backpressureChangePromise = undefined;
  27387. this._backpressureChangePromise_resolve = undefined;
  27388. this._transformStreamController = new TransformStreamDefaultController(this);
  27389. var startPromise_resolve = void 0;
  27390. var startPromise = new Promise(function (resolve) {
  27391. startPromise_resolve = resolve;
  27392. });
  27393. var source = new TransformStreamSource(this, startPromise);
  27394. this._readable = new ReadableStream(source, readableStrategy);
  27395. var sink = new TransformStreamSink(this, startPromise);
  27396. this._writable = new WritableStream(sink, writableStrategy);
  27397. assert(this._writableController !== undefined);
  27398. assert(this._readableController !== undefined);
  27399. var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(this._readableController);
  27400. TransformStreamSetBackpressure(this, desiredSize <= 0);
  27401. var transformStream = this;
  27402. var startResult = InvokeOrNoop(transformer, 'start', [transformStream._transformStreamController]);
  27403. startPromise_resolve(startResult);
  27404. startPromise.catch(function (e) {
  27405. if (transformStream._errored === false) {
  27406. transformStream._errored = true;
  27407. transformStream._storedError = e;
  27408. }
  27409. });
  27410. }
  27411. _createClass(TransformStream, [{
  27412. key: 'readable',
  27413. get: function get() {
  27414. if (IsTransformStream(this) === false) {
  27415. throw streamBrandCheckException('readable');
  27416. }
  27417. return this._readable;
  27418. }
  27419. }, {
  27420. key: 'writable',
  27421. get: function get() {
  27422. if (IsTransformStream(this) === false) {
  27423. throw streamBrandCheckException('writable');
  27424. }
  27425. return this._writable;
  27426. }
  27427. }]);
  27428. return TransformStream;
  27429. }();
  27430. module.exports = { TransformStream: TransformStream };
  27431. function defaultControllerBrandCheckException(name) {
  27432. return new TypeError('TransformStreamDefaultController.prototype.' + name + ' can only be used on a TransformStreamDefaultController');
  27433. }
  27434. function streamBrandCheckException(name) {
  27435. return new TypeError('TransformStream.prototype.' + name + ' can only be used on a TransformStream');
  27436. }
  27437. }, function (module, exports, __w_pdfjs_require__) {
  27438. module.exports = __w_pdfjs_require__(5);
  27439. }]));
  27440. /***/ }),
  27441. /* 122 */
  27442. /***/ (function(module, exports, __w_pdfjs_require__) {
  27443. "use strict";
  27444. Object.defineProperty(exports, "__esModule", {
  27445. value: true
  27446. });
  27447. exports.NetworkPdfManager = exports.LocalPdfManager = undefined;
  27448. var _util = __w_pdfjs_require__(0);
  27449. var _chunked_stream = __w_pdfjs_require__(61);
  27450. var _document = __w_pdfjs_require__(123);
  27451. var _stream = __w_pdfjs_require__(5);
  27452. var BasePdfManager = function BasePdfManagerClosure() {
  27453. function BasePdfManager() {
  27454. throw new Error('Cannot initialize BaseManagerManager');
  27455. }
  27456. BasePdfManager.prototype = {
  27457. get docId() {
  27458. return this._docId;
  27459. },
  27460. get password() {
  27461. return this._password;
  27462. },
  27463. get docBaseUrl() {
  27464. var docBaseUrl = null;
  27465. if (this._docBaseUrl) {
  27466. var absoluteUrl = (0, _util.createValidAbsoluteUrl)(this._docBaseUrl);
  27467. if (absoluteUrl) {
  27468. docBaseUrl = absoluteUrl.href;
  27469. } else {
  27470. (0, _util.warn)('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  27471. }
  27472. }
  27473. return (0, _util.shadow)(this, 'docBaseUrl', docBaseUrl);
  27474. },
  27475. onLoadedStream: function BasePdfManager_onLoadedStream() {
  27476. throw new _util.NotImplementedException();
  27477. },
  27478. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  27479. return this.ensure(this.pdfDocument, prop, args);
  27480. },
  27481. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  27482. return this.ensure(this.pdfDocument.xref, prop, args);
  27483. },
  27484. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  27485. return this.ensure(this.pdfDocument.catalog, prop, args);
  27486. },
  27487. getPage: function BasePdfManager_getPage(pageIndex) {
  27488. return this.pdfDocument.getPage(pageIndex);
  27489. },
  27490. cleanup: function BasePdfManager_cleanup() {
  27491. return this.pdfDocument.cleanup();
  27492. },
  27493. ensure: function BasePdfManager_ensure(obj, prop, args) {
  27494. return new _util.NotImplementedException();
  27495. },
  27496. requestRange: function BasePdfManager_requestRange(begin, end) {
  27497. return new _util.NotImplementedException();
  27498. },
  27499. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  27500. return new _util.NotImplementedException();
  27501. },
  27502. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  27503. return new _util.NotImplementedException();
  27504. },
  27505. updatePassword: function BasePdfManager_updatePassword(password) {
  27506. this._password = password;
  27507. },
  27508. terminate: function BasePdfManager_terminate() {
  27509. return new _util.NotImplementedException();
  27510. }
  27511. };
  27512. return BasePdfManager;
  27513. }();
  27514. var LocalPdfManager = function LocalPdfManagerClosure() {
  27515. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  27516. this._docId = docId;
  27517. this._password = password;
  27518. this._docBaseUrl = docBaseUrl;
  27519. this.evaluatorOptions = evaluatorOptions;
  27520. var stream = new _stream.Stream(data);
  27521. this.pdfDocument = new _document.PDFDocument(this, stream);
  27522. this._loadedStreamCapability = (0, _util.createPromiseCapability)();
  27523. this._loadedStreamCapability.resolve(stream);
  27524. }
  27525. _util.Util.inherit(LocalPdfManager, BasePdfManager, {
  27526. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  27527. return new Promise(function (resolve, reject) {
  27528. try {
  27529. var value = obj[prop];
  27530. var result;
  27531. if (typeof value === 'function') {
  27532. result = value.apply(obj, args);
  27533. } else {
  27534. result = value;
  27535. }
  27536. resolve(result);
  27537. } catch (e) {
  27538. reject(e);
  27539. }
  27540. });
  27541. },
  27542. requestRange: function LocalPdfManager_requestRange(begin, end) {
  27543. return Promise.resolve();
  27544. },
  27545. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {},
  27546. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  27547. return this._loadedStreamCapability.promise;
  27548. },
  27549. terminate: function LocalPdfManager_terminate() {}
  27550. });
  27551. return LocalPdfManager;
  27552. }();
  27553. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  27554. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  27555. this._docId = docId;
  27556. this._password = args.password;
  27557. this._docBaseUrl = docBaseUrl;
  27558. this.msgHandler = args.msgHandler;
  27559. this.evaluatorOptions = evaluatorOptions;
  27560. var params = {
  27561. msgHandler: args.msgHandler,
  27562. url: args.url,
  27563. length: args.length,
  27564. disableAutoFetch: args.disableAutoFetch,
  27565. rangeChunkSize: args.rangeChunkSize
  27566. };
  27567. this.streamManager = new _chunked_stream.ChunkedStreamManager(pdfNetworkStream, params);
  27568. this.pdfDocument = new _document.PDFDocument(this, this.streamManager.getStream());
  27569. }
  27570. _util.Util.inherit(NetworkPdfManager, BasePdfManager, {
  27571. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  27572. var pdfManager = this;
  27573. return new Promise(function (resolve, reject) {
  27574. function ensureHelper() {
  27575. try {
  27576. var result;
  27577. var value = obj[prop];
  27578. if (typeof value === 'function') {
  27579. result = value.apply(obj, args);
  27580. } else {
  27581. result = value;
  27582. }
  27583. resolve(result);
  27584. } catch (e) {
  27585. if (!(e instanceof _util.MissingDataException)) {
  27586. reject(e);
  27587. return;
  27588. }
  27589. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  27590. }
  27591. }
  27592. ensureHelper();
  27593. });
  27594. },
  27595. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  27596. return this.streamManager.requestRange(begin, end);
  27597. },
  27598. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  27599. this.streamManager.requestAllChunks();
  27600. },
  27601. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  27602. this.streamManager.onReceiveData({ chunk: chunk });
  27603. },
  27604. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  27605. return this.streamManager.onLoadedStream();
  27606. },
  27607. terminate: function NetworkPdfManager_terminate() {
  27608. this.streamManager.abort();
  27609. }
  27610. });
  27611. return NetworkPdfManager;
  27612. }();
  27613. exports.LocalPdfManager = LocalPdfManager;
  27614. exports.NetworkPdfManager = NetworkPdfManager;
  27615. /***/ }),
  27616. /* 123 */
  27617. /***/ (function(module, exports, __w_pdfjs_require__) {
  27618. "use strict";
  27619. Object.defineProperty(exports, "__esModule", {
  27620. value: true
  27621. });
  27622. exports.PDFDocument = exports.Page = undefined;
  27623. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  27624. var _obj = __w_pdfjs_require__(62);
  27625. var _primitives = __w_pdfjs_require__(1);
  27626. var _util = __w_pdfjs_require__(0);
  27627. var _stream = __w_pdfjs_require__(5);
  27628. var _annotation = __w_pdfjs_require__(129);
  27629. var _crypto = __w_pdfjs_require__(65);
  27630. var _parser = __w_pdfjs_require__(26);
  27631. var _operator_list = __w_pdfjs_require__(41);
  27632. var _evaluator = __w_pdfjs_require__(130);
  27633. var _function = __w_pdfjs_require__(69);
  27634. var Page = function PageClosure() {
  27635. var DEFAULT_USER_UNIT = 1.0;
  27636. var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
  27637. function isAnnotationRenderable(annotation, intent) {
  27638. return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
  27639. }
  27640. function Page(_ref) {
  27641. var pdfManager = _ref.pdfManager,
  27642. xref = _ref.xref,
  27643. pageIndex = _ref.pageIndex,
  27644. pageDict = _ref.pageDict,
  27645. ref = _ref.ref,
  27646. fontCache = _ref.fontCache,
  27647. builtInCMapCache = _ref.builtInCMapCache,
  27648. pdfFunctionFactory = _ref.pdfFunctionFactory;
  27649. this.pdfManager = pdfManager;
  27650. this.pageIndex = pageIndex;
  27651. this.pageDict = pageDict;
  27652. this.xref = xref;
  27653. this.ref = ref;
  27654. this.fontCache = fontCache;
  27655. this.builtInCMapCache = builtInCMapCache;
  27656. this.pdfFunctionFactory = pdfFunctionFactory;
  27657. this.evaluatorOptions = pdfManager.evaluatorOptions;
  27658. this.resourcesPromise = null;
  27659. var uniquePrefix = 'p' + this.pageIndex + '_';
  27660. var idCounters = { obj: 0 };
  27661. this.idFactory = {
  27662. createObjId: function createObjId() {
  27663. return uniquePrefix + ++idCounters.obj;
  27664. }
  27665. };
  27666. }
  27667. Page.prototype = {
  27668. getPageProp: function Page_getPageProp(key) {
  27669. return this.pageDict.get(key);
  27670. },
  27671. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  27672. var dict = this.pageDict,
  27673. valueArray = null,
  27674. loopCount = 0;
  27675. var MAX_LOOP_COUNT = 100;
  27676. getArray = getArray || false;
  27677. while (dict) {
  27678. var value = getArray ? dict.getArray(key) : dict.get(key);
  27679. if (value !== undefined) {
  27680. if (!valueArray) {
  27681. valueArray = [];
  27682. }
  27683. valueArray.push(value);
  27684. }
  27685. if (++loopCount > MAX_LOOP_COUNT) {
  27686. (0, _util.warn)('getInheritedPageProp: maximum loop count exceeded for ' + key);
  27687. return valueArray ? valueArray[0] : undefined;
  27688. }
  27689. dict = dict.get('Parent');
  27690. }
  27691. if (!valueArray) {
  27692. return undefined;
  27693. }
  27694. if (valueArray.length === 1 || !(0, _primitives.isDict)(valueArray[0])) {
  27695. return valueArray[0];
  27696. }
  27697. return _primitives.Dict.merge(this.xref, valueArray);
  27698. },
  27699. get content() {
  27700. return this.getPageProp('Contents');
  27701. },
  27702. get resources() {
  27703. return (0, _util.shadow)(this, 'resources', this.getInheritedPageProp('Resources') || _primitives.Dict.empty);
  27704. },
  27705. get mediaBox() {
  27706. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  27707. if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
  27708. return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  27709. }
  27710. return (0, _util.shadow)(this, 'mediaBox', mediaBox);
  27711. },
  27712. get cropBox() {
  27713. var cropBox = this.getInheritedPageProp('CropBox', true);
  27714. if (!Array.isArray(cropBox) || cropBox.length !== 4) {
  27715. return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
  27716. }
  27717. return (0, _util.shadow)(this, 'cropBox', cropBox);
  27718. },
  27719. get userUnit() {
  27720. var obj = this.getPageProp('UserUnit');
  27721. if (!(0, _util.isNum)(obj) || obj <= 0) {
  27722. obj = DEFAULT_USER_UNIT;
  27723. }
  27724. return (0, _util.shadow)(this, 'userUnit', obj);
  27725. },
  27726. get view() {
  27727. var mediaBox = this.mediaBox,
  27728. cropBox = this.cropBox;
  27729. if (mediaBox === cropBox) {
  27730. return (0, _util.shadow)(this, 'view', mediaBox);
  27731. }
  27732. var intersection = _util.Util.intersect(cropBox, mediaBox);
  27733. return (0, _util.shadow)(this, 'view', intersection || mediaBox);
  27734. },
  27735. get rotate() {
  27736. var rotate = this.getInheritedPageProp('Rotate') || 0;
  27737. if (rotate % 90 !== 0) {
  27738. rotate = 0;
  27739. } else if (rotate >= 360) {
  27740. rotate = rotate % 360;
  27741. } else if (rotate < 0) {
  27742. rotate = (rotate % 360 + 360) % 360;
  27743. }
  27744. return (0, _util.shadow)(this, 'rotate', rotate);
  27745. },
  27746. getContentStream: function Page_getContentStream() {
  27747. var content = this.content;
  27748. var stream;
  27749. if (Array.isArray(content)) {
  27750. var xref = this.xref;
  27751. var i,
  27752. n = content.length;
  27753. var streams = [];
  27754. for (i = 0; i < n; ++i) {
  27755. streams.push(xref.fetchIfRef(content[i]));
  27756. }
  27757. stream = new _stream.StreamsSequenceStream(streams);
  27758. } else if ((0, _primitives.isStream)(content)) {
  27759. stream = content;
  27760. } else {
  27761. stream = new _stream.NullStream();
  27762. }
  27763. return stream;
  27764. },
  27765. loadResources: function Page_loadResources(keys) {
  27766. var _this = this;
  27767. if (!this.resourcesPromise) {
  27768. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  27769. }
  27770. return this.resourcesPromise.then(function () {
  27771. var objectLoader = new _obj.ObjectLoader(_this.resources, keys, _this.xref);
  27772. return objectLoader.load();
  27773. });
  27774. },
  27775. getOperatorList: function getOperatorList(_ref2) {
  27776. var _this2 = this;
  27777. var handler = _ref2.handler,
  27778. task = _ref2.task,
  27779. intent = _ref2.intent,
  27780. renderInteractiveForms = _ref2.renderInteractiveForms;
  27781. var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
  27782. var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
  27783. var partialEvaluator = new _evaluator.PartialEvaluator({
  27784. pdfManager: this.pdfManager,
  27785. xref: this.xref,
  27786. handler: handler,
  27787. pageIndex: this.pageIndex,
  27788. idFactory: this.idFactory,
  27789. fontCache: this.fontCache,
  27790. builtInCMapCache: this.builtInCMapCache,
  27791. options: this.evaluatorOptions,
  27792. pdfFunctionFactory: this.pdfFunctionFactory
  27793. });
  27794. var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  27795. var pageListPromise = dataPromises.then(function (_ref3) {
  27796. var _ref4 = _slicedToArray(_ref3, 1),
  27797. contentStream = _ref4[0];
  27798. var opList = new _operator_list.OperatorList(intent, handler, _this2.pageIndex);
  27799. handler.send('StartRenderPage', {
  27800. transparency: partialEvaluator.hasBlendModes(_this2.resources),
  27801. pageIndex: _this2.pageIndex,
  27802. intent: intent
  27803. });
  27804. return partialEvaluator.getOperatorList({
  27805. stream: contentStream,
  27806. task: task,
  27807. resources: _this2.resources,
  27808. operatorList: opList
  27809. }).then(function () {
  27810. return opList;
  27811. });
  27812. });
  27813. var annotationsPromise = this.pdfManager.ensure(this, 'annotations');
  27814. return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref5) {
  27815. var _ref6 = _slicedToArray(_ref5, 2),
  27816. pageOpList = _ref6[0],
  27817. annotations = _ref6[1];
  27818. if (annotations.length === 0) {
  27819. pageOpList.flush(true);
  27820. return pageOpList;
  27821. }
  27822. var i,
  27823. ii,
  27824. opListPromises = [];
  27825. for (i = 0, ii = annotations.length; i < ii; i++) {
  27826. if (isAnnotationRenderable(annotations[i], intent)) {
  27827. opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
  27828. }
  27829. }
  27830. return Promise.all(opListPromises).then(function (opLists) {
  27831. pageOpList.addOp(_util.OPS.beginAnnotations, []);
  27832. for (i = 0, ii = opLists.length; i < ii; i++) {
  27833. pageOpList.addOpList(opLists[i]);
  27834. }
  27835. pageOpList.addOp(_util.OPS.endAnnotations, []);
  27836. pageOpList.flush(true);
  27837. return pageOpList;
  27838. });
  27839. });
  27840. },
  27841. extractTextContent: function extractTextContent(_ref7) {
  27842. var _this3 = this;
  27843. var handler = _ref7.handler,
  27844. task = _ref7.task,
  27845. normalizeWhitespace = _ref7.normalizeWhitespace,
  27846. sink = _ref7.sink,
  27847. combineTextItems = _ref7.combineTextItems;
  27848. var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
  27849. var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
  27850. var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
  27851. return dataPromises.then(function (_ref8) {
  27852. var _ref9 = _slicedToArray(_ref8, 1),
  27853. contentStream = _ref9[0];
  27854. var partialEvaluator = new _evaluator.PartialEvaluator({
  27855. pdfManager: _this3.pdfManager,
  27856. xref: _this3.xref,
  27857. handler: handler,
  27858. pageIndex: _this3.pageIndex,
  27859. idFactory: _this3.idFactory,
  27860. fontCache: _this3.fontCache,
  27861. builtInCMapCache: _this3.builtInCMapCache,
  27862. options: _this3.evaluatorOptions,
  27863. pdfFunctionFactory: _this3.pdfFunctionFactory
  27864. });
  27865. return partialEvaluator.getTextContent({
  27866. stream: contentStream,
  27867. task: task,
  27868. resources: _this3.resources,
  27869. normalizeWhitespace: normalizeWhitespace,
  27870. combineTextItems: combineTextItems,
  27871. sink: sink
  27872. });
  27873. });
  27874. },
  27875. getAnnotationsData: function Page_getAnnotationsData(intent) {
  27876. var annotations = this.annotations;
  27877. var annotationsData = [];
  27878. for (var i = 0, n = annotations.length; i < n; ++i) {
  27879. if (!intent || isAnnotationRenderable(annotations[i], intent)) {
  27880. annotationsData.push(annotations[i].data);
  27881. }
  27882. }
  27883. return annotationsData;
  27884. },
  27885. get annotations() {
  27886. var annotations = [];
  27887. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  27888. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  27889. var annotationRef = annotationRefs[i];
  27890. var annotation = _annotation.AnnotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  27891. if (annotation) {
  27892. annotations.push(annotation);
  27893. }
  27894. }
  27895. return (0, _util.shadow)(this, 'annotations', annotations);
  27896. }
  27897. };
  27898. return Page;
  27899. }();
  27900. var PDFDocument = function PDFDocumentClosure() {
  27901. var FINGERPRINT_FIRST_BYTES = 1024;
  27902. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  27903. function PDFDocument(pdfManager, arg) {
  27904. var stream;
  27905. if ((0, _primitives.isStream)(arg)) {
  27906. stream = arg;
  27907. } else if ((0, _util.isArrayBuffer)(arg)) {
  27908. stream = new _stream.Stream(arg);
  27909. } else {
  27910. throw new Error('PDFDocument: Unknown argument type');
  27911. }
  27912. if (stream.length <= 0) {
  27913. throw new Error('PDFDocument: stream must have data');
  27914. }
  27915. this.pdfManager = pdfManager;
  27916. this.stream = stream;
  27917. this.xref = new _obj.XRef(stream, pdfManager);
  27918. var evaluatorOptions = pdfManager.evaluatorOptions;
  27919. this.pdfFunctionFactory = new _function.PDFFunctionFactory({
  27920. xref: this.xref,
  27921. isEvalSupported: evaluatorOptions.isEvalSupported
  27922. });
  27923. }
  27924. function find(stream, needle, limit, backwards) {
  27925. var pos = stream.pos;
  27926. var end = stream.end;
  27927. var strBuf = [];
  27928. if (pos + limit > end) {
  27929. limit = end - pos;
  27930. }
  27931. for (var n = 0; n < limit; ++n) {
  27932. strBuf.push(String.fromCharCode(stream.getByte()));
  27933. }
  27934. var str = strBuf.join('');
  27935. stream.pos = pos;
  27936. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  27937. if (index === -1) {
  27938. return false;
  27939. }
  27940. stream.pos += index;
  27941. return true;
  27942. }
  27943. var DocumentInfoValidators = {
  27944. get entries() {
  27945. return (0, _util.shadow)(this, 'entries', {
  27946. Title: _util.isString,
  27947. Author: _util.isString,
  27948. Subject: _util.isString,
  27949. Keywords: _util.isString,
  27950. Creator: _util.isString,
  27951. Producer: _util.isString,
  27952. CreationDate: _util.isString,
  27953. ModDate: _util.isString,
  27954. Trapped: _primitives.isName
  27955. });
  27956. }
  27957. };
  27958. PDFDocument.prototype = {
  27959. parse: function PDFDocument_parse(recoveryMode) {
  27960. this.setup(recoveryMode);
  27961. var version = this.catalog.catDict.get('Version');
  27962. if ((0, _primitives.isName)(version)) {
  27963. this.pdfFormatVersion = version.name;
  27964. }
  27965. try {
  27966. this.acroForm = this.catalog.catDict.get('AcroForm');
  27967. if (this.acroForm) {
  27968. this.xfa = this.acroForm.get('XFA');
  27969. var fields = this.acroForm.get('Fields');
  27970. if ((!fields || !Array.isArray(fields) || fields.length === 0) && !this.xfa) {
  27971. this.acroForm = null;
  27972. }
  27973. }
  27974. } catch (ex) {
  27975. if (ex instanceof _util.MissingDataException) {
  27976. throw ex;
  27977. }
  27978. (0, _util.info)('Something wrong with AcroForm entry');
  27979. this.acroForm = null;
  27980. }
  27981. },
  27982. get linearization() {
  27983. var linearization = null;
  27984. if (this.stream.length) {
  27985. try {
  27986. linearization = _parser.Linearization.create(this.stream);
  27987. } catch (err) {
  27988. if (err instanceof _util.MissingDataException) {
  27989. throw err;
  27990. }
  27991. (0, _util.info)(err);
  27992. }
  27993. }
  27994. return (0, _util.shadow)(this, 'linearization', linearization);
  27995. },
  27996. get startXRef() {
  27997. var stream = this.stream;
  27998. var startXRef = 0;
  27999. var linearization = this.linearization;
  28000. if (linearization) {
  28001. stream.reset();
  28002. if (find(stream, 'endobj', 1024)) {
  28003. startXRef = stream.pos + 6;
  28004. }
  28005. } else {
  28006. var step = 1024;
  28007. var found = false,
  28008. pos = stream.end;
  28009. while (!found && pos > 0) {
  28010. pos -= step - 'startxref'.length;
  28011. if (pos < 0) {
  28012. pos = 0;
  28013. }
  28014. stream.pos = pos;
  28015. found = find(stream, 'startxref', step, true);
  28016. }
  28017. if (found) {
  28018. stream.skip(9);
  28019. var ch;
  28020. do {
  28021. ch = stream.getByte();
  28022. } while ((0, _util.isSpace)(ch));
  28023. var str = '';
  28024. while (ch >= 0x20 && ch <= 0x39) {
  28025. str += String.fromCharCode(ch);
  28026. ch = stream.getByte();
  28027. }
  28028. startXRef = parseInt(str, 10);
  28029. if (isNaN(startXRef)) {
  28030. startXRef = 0;
  28031. }
  28032. }
  28033. }
  28034. return (0, _util.shadow)(this, 'startXRef', startXRef);
  28035. },
  28036. get mainXRefEntriesOffset() {
  28037. var mainXRefEntriesOffset = 0;
  28038. var linearization = this.linearization;
  28039. if (linearization) {
  28040. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  28041. }
  28042. return (0, _util.shadow)(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  28043. },
  28044. checkHeader: function PDFDocument_checkHeader() {
  28045. var stream = this.stream;
  28046. stream.reset();
  28047. if (find(stream, '%PDF-', 1024)) {
  28048. stream.moveStart();
  28049. var MAX_VERSION_LENGTH = 12;
  28050. var version = '',
  28051. ch;
  28052. while ((ch = stream.getByte()) > 0x20) {
  28053. if (version.length >= MAX_VERSION_LENGTH) {
  28054. break;
  28055. }
  28056. version += String.fromCharCode(ch);
  28057. }
  28058. if (!this.pdfFormatVersion) {
  28059. this.pdfFormatVersion = version.substring(5);
  28060. }
  28061. return;
  28062. }
  28063. },
  28064. parseStartXRef: function PDFDocument_parseStartXRef() {
  28065. var startXRef = this.startXRef;
  28066. this.xref.setStartXRef(startXRef);
  28067. },
  28068. setup: function PDFDocument_setup(recoveryMode) {
  28069. var _this4 = this;
  28070. this.xref.parse(recoveryMode);
  28071. var pageFactory = {
  28072. createPage: function createPage(pageIndex, dict, ref, fontCache, builtInCMapCache) {
  28073. return new Page({
  28074. pdfManager: _this4.pdfManager,
  28075. xref: _this4.xref,
  28076. pageIndex: pageIndex,
  28077. pageDict: dict,
  28078. ref: ref,
  28079. fontCache: fontCache,
  28080. builtInCMapCache: builtInCMapCache,
  28081. pdfFunctionFactory: _this4.pdfFunctionFactory
  28082. });
  28083. }
  28084. };
  28085. this.catalog = new _obj.Catalog(this.pdfManager, this.xref, pageFactory);
  28086. },
  28087. get numPages() {
  28088. var linearization = this.linearization;
  28089. var num = linearization ? linearization.numPages : this.catalog.numPages;
  28090. return (0, _util.shadow)(this, 'numPages', num);
  28091. },
  28092. get documentInfo() {
  28093. var docInfo = {
  28094. PDFFormatVersion: this.pdfFormatVersion,
  28095. IsAcroFormPresent: !!this.acroForm,
  28096. IsXFAPresent: !!this.xfa
  28097. };
  28098. var infoDict;
  28099. try {
  28100. infoDict = this.xref.trailer.get('Info');
  28101. } catch (err) {
  28102. if (err instanceof _util.MissingDataException) {
  28103. throw err;
  28104. }
  28105. (0, _util.info)('The document information dictionary is invalid.');
  28106. }
  28107. if (infoDict) {
  28108. var validEntries = DocumentInfoValidators.entries;
  28109. for (var key in validEntries) {
  28110. if (infoDict.has(key)) {
  28111. var value = infoDict.get(key);
  28112. if (validEntries[key](value)) {
  28113. docInfo[key] = typeof value !== 'string' ? value : (0, _util.stringToPDFString)(value);
  28114. } else {
  28115. (0, _util.info)('Bad value in document info for "' + key + '"');
  28116. }
  28117. }
  28118. }
  28119. }
  28120. return (0, _util.shadow)(this, 'documentInfo', docInfo);
  28121. },
  28122. get fingerprint() {
  28123. var xref = this.xref,
  28124. hash,
  28125. fileID = '';
  28126. var idArray = xref.trailer.get('ID');
  28127. if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  28128. hash = (0, _util.stringToBytes)(idArray[0]);
  28129. } else {
  28130. if (this.stream.ensureRange) {
  28131. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  28132. }
  28133. hash = (0, _crypto.calculateMD5)(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  28134. }
  28135. for (var i = 0, n = hash.length; i < n; i++) {
  28136. var hex = hash[i].toString(16);
  28137. fileID += hex.length === 1 ? '0' + hex : hex;
  28138. }
  28139. return (0, _util.shadow)(this, 'fingerprint', fileID);
  28140. },
  28141. getPage: function PDFDocument_getPage(pageIndex) {
  28142. return this.catalog.getPage(pageIndex);
  28143. },
  28144. cleanup: function PDFDocument_cleanup() {
  28145. return this.catalog.cleanup();
  28146. }
  28147. };
  28148. return PDFDocument;
  28149. }();
  28150. exports.Page = Page;
  28151. exports.PDFDocument = PDFDocument;
  28152. /***/ }),
  28153. /* 124 */
  28154. /***/ (function(module, exports, __w_pdfjs_require__) {
  28155. "use strict";
  28156. Object.defineProperty(exports, "__esModule", {
  28157. value: true
  28158. });
  28159. exports.JpegImage = undefined;
  28160. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  28161. var _util = __w_pdfjs_require__(0);
  28162. var JpegError = function JpegErrorClosure() {
  28163. function JpegError(msg) {
  28164. this.message = 'JPEG error: ' + msg;
  28165. }
  28166. JpegError.prototype = new Error();
  28167. JpegError.prototype.name = 'JpegError';
  28168. JpegError.constructor = JpegError;
  28169. return JpegError;
  28170. }();
  28171. var JpegImage = function JpegImageClosure() {
  28172. 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]);
  28173. var dctCos1 = 4017;
  28174. var dctSin1 = 799;
  28175. var dctCos3 = 3406;
  28176. var dctSin3 = 2276;
  28177. var dctCos6 = 1567;
  28178. var dctSin6 = 3784;
  28179. var dctSqrt2 = 5793;
  28180. var dctSqrt1d2 = 2896;
  28181. function JpegImage() {
  28182. this.decodeTransform = null;
  28183. this.colorTransform = -1;
  28184. }
  28185. function buildHuffmanTable(codeLengths, values) {
  28186. var k = 0,
  28187. code = [],
  28188. i,
  28189. j,
  28190. length = 16;
  28191. while (length > 0 && !codeLengths[length - 1]) {
  28192. length--;
  28193. }
  28194. code.push({
  28195. children: [],
  28196. index: 0
  28197. });
  28198. var p = code[0],
  28199. q;
  28200. for (i = 0; i < length; i++) {
  28201. for (j = 0; j < codeLengths[i]; j++) {
  28202. p = code.pop();
  28203. p.children[p.index] = values[k];
  28204. while (p.index > 0) {
  28205. p = code.pop();
  28206. }
  28207. p.index++;
  28208. code.push(p);
  28209. while (code.length <= i) {
  28210. code.push(q = {
  28211. children: [],
  28212. index: 0
  28213. });
  28214. p.children[p.index] = q.children;
  28215. p = q;
  28216. }
  28217. k++;
  28218. }
  28219. if (i + 1 < length) {
  28220. code.push(q = {
  28221. children: [],
  28222. index: 0
  28223. });
  28224. p.children[p.index] = q.children;
  28225. p = q;
  28226. }
  28227. }
  28228. return code[0].children;
  28229. }
  28230. function getBlockBufferOffset(component, row, col) {
  28231. return 64 * ((component.blocksPerLine + 1) * row + col);
  28232. }
  28233. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  28234. var mcusPerLine = frame.mcusPerLine;
  28235. var progressive = frame.progressive;
  28236. var startOffset = offset,
  28237. bitsData = 0,
  28238. bitsCount = 0;
  28239. function readBit() {
  28240. if (bitsCount > 0) {
  28241. bitsCount--;
  28242. return bitsData >> bitsCount & 1;
  28243. }
  28244. bitsData = data[offset++];
  28245. if (bitsData === 0xFF) {
  28246. var nextByte = data[offset++];
  28247. if (nextByte) {
  28248. throw new JpegError('unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  28249. }
  28250. }
  28251. bitsCount = 7;
  28252. return bitsData >>> 7;
  28253. }
  28254. function decodeHuffman(tree) {
  28255. var node = tree;
  28256. while (true) {
  28257. node = node[readBit()];
  28258. if (typeof node === 'number') {
  28259. return node;
  28260. }
  28261. if ((typeof node === 'undefined' ? 'undefined' : _typeof(node)) !== 'object') {
  28262. throw new JpegError('invalid huffman sequence');
  28263. }
  28264. }
  28265. }
  28266. function receive(length) {
  28267. var n = 0;
  28268. while (length > 0) {
  28269. n = n << 1 | readBit();
  28270. length--;
  28271. }
  28272. return n;
  28273. }
  28274. function receiveAndExtend(length) {
  28275. if (length === 1) {
  28276. return readBit() === 1 ? 1 : -1;
  28277. }
  28278. var n = receive(length);
  28279. if (n >= 1 << length - 1) {
  28280. return n;
  28281. }
  28282. return n + (-1 << length) + 1;
  28283. }
  28284. function decodeBaseline(component, offset) {
  28285. var t = decodeHuffman(component.huffmanTableDC);
  28286. var diff = t === 0 ? 0 : receiveAndExtend(t);
  28287. component.blockData[offset] = component.pred += diff;
  28288. var k = 1;
  28289. while (k < 64) {
  28290. var rs = decodeHuffman(component.huffmanTableAC);
  28291. var s = rs & 15,
  28292. r = rs >> 4;
  28293. if (s === 0) {
  28294. if (r < 15) {
  28295. break;
  28296. }
  28297. k += 16;
  28298. continue;
  28299. }
  28300. k += r;
  28301. var z = dctZigZag[k];
  28302. component.blockData[offset + z] = receiveAndExtend(s);
  28303. k++;
  28304. }
  28305. }
  28306. function decodeDCFirst(component, offset) {
  28307. var t = decodeHuffman(component.huffmanTableDC);
  28308. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  28309. component.blockData[offset] = component.pred += diff;
  28310. }
  28311. function decodeDCSuccessive(component, offset) {
  28312. component.blockData[offset] |= readBit() << successive;
  28313. }
  28314. var eobrun = 0;
  28315. function decodeACFirst(component, offset) {
  28316. if (eobrun > 0) {
  28317. eobrun--;
  28318. return;
  28319. }
  28320. var k = spectralStart,
  28321. e = spectralEnd;
  28322. while (k <= e) {
  28323. var rs = decodeHuffman(component.huffmanTableAC);
  28324. var s = rs & 15,
  28325. r = rs >> 4;
  28326. if (s === 0) {
  28327. if (r < 15) {
  28328. eobrun = receive(r) + (1 << r) - 1;
  28329. break;
  28330. }
  28331. k += 16;
  28332. continue;
  28333. }
  28334. k += r;
  28335. var z = dctZigZag[k];
  28336. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  28337. k++;
  28338. }
  28339. }
  28340. var successiveACState = 0,
  28341. successiveACNextValue;
  28342. function decodeACSuccessive(component, offset) {
  28343. var k = spectralStart;
  28344. var e = spectralEnd;
  28345. var r = 0;
  28346. var s;
  28347. var rs;
  28348. while (k <= e) {
  28349. var z = dctZigZag[k];
  28350. switch (successiveACState) {
  28351. case 0:
  28352. rs = decodeHuffman(component.huffmanTableAC);
  28353. s = rs & 15;
  28354. r = rs >> 4;
  28355. if (s === 0) {
  28356. if (r < 15) {
  28357. eobrun = receive(r) + (1 << r);
  28358. successiveACState = 4;
  28359. } else {
  28360. r = 16;
  28361. successiveACState = 1;
  28362. }
  28363. } else {
  28364. if (s !== 1) {
  28365. throw new JpegError('invalid ACn encoding');
  28366. }
  28367. successiveACNextValue = receiveAndExtend(s);
  28368. successiveACState = r ? 2 : 3;
  28369. }
  28370. continue;
  28371. case 1:
  28372. case 2:
  28373. if (component.blockData[offset + z]) {
  28374. component.blockData[offset + z] += readBit() << successive;
  28375. } else {
  28376. r--;
  28377. if (r === 0) {
  28378. successiveACState = successiveACState === 2 ? 3 : 0;
  28379. }
  28380. }
  28381. break;
  28382. case 3:
  28383. if (component.blockData[offset + z]) {
  28384. component.blockData[offset + z] += readBit() << successive;
  28385. } else {
  28386. component.blockData[offset + z] = successiveACNextValue << successive;
  28387. successiveACState = 0;
  28388. }
  28389. break;
  28390. case 4:
  28391. if (component.blockData[offset + z]) {
  28392. component.blockData[offset + z] += readBit() << successive;
  28393. }
  28394. break;
  28395. }
  28396. k++;
  28397. }
  28398. if (successiveACState === 4) {
  28399. eobrun--;
  28400. if (eobrun === 0) {
  28401. successiveACState = 0;
  28402. }
  28403. }
  28404. }
  28405. function decodeMcu(component, decode, mcu, row, col) {
  28406. var mcuRow = mcu / mcusPerLine | 0;
  28407. var mcuCol = mcu % mcusPerLine;
  28408. var blockRow = mcuRow * component.v + row;
  28409. var blockCol = mcuCol * component.h + col;
  28410. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  28411. decode(component, offset);
  28412. }
  28413. function decodeBlock(component, decode, mcu) {
  28414. var blockRow = mcu / component.blocksPerLine | 0;
  28415. var blockCol = mcu % component.blocksPerLine;
  28416. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  28417. decode(component, offset);
  28418. }
  28419. var componentsLength = components.length;
  28420. var component, i, j, k, n;
  28421. var decodeFn;
  28422. if (progressive) {
  28423. if (spectralStart === 0) {
  28424. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  28425. } else {
  28426. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  28427. }
  28428. } else {
  28429. decodeFn = decodeBaseline;
  28430. }
  28431. var mcu = 0,
  28432. fileMarker;
  28433. var mcuExpected;
  28434. if (componentsLength === 1) {
  28435. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  28436. } else {
  28437. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  28438. }
  28439. var h, v;
  28440. while (mcu < mcuExpected) {
  28441. var mcuToRead = resetInterval ? Math.min(mcuExpected - mcu, resetInterval) : mcuExpected;
  28442. for (i = 0; i < componentsLength; i++) {
  28443. components[i].pred = 0;
  28444. }
  28445. eobrun = 0;
  28446. if (componentsLength === 1) {
  28447. component = components[0];
  28448. for (n = 0; n < mcuToRead; n++) {
  28449. decodeBlock(component, decodeFn, mcu);
  28450. mcu++;
  28451. }
  28452. } else {
  28453. for (n = 0; n < mcuToRead; n++) {
  28454. for (i = 0; i < componentsLength; i++) {
  28455. component = components[i];
  28456. h = component.h;
  28457. v = component.v;
  28458. for (j = 0; j < v; j++) {
  28459. for (k = 0; k < h; k++) {
  28460. decodeMcu(component, decodeFn, mcu, j, k);
  28461. }
  28462. }
  28463. }
  28464. mcu++;
  28465. }
  28466. }
  28467. bitsCount = 0;
  28468. fileMarker = findNextFileMarker(data, offset);
  28469. if (fileMarker && fileMarker.invalid) {
  28470. (0, _util.warn)('decodeScan - unexpected MCU data, next marker is: ' + fileMarker.invalid);
  28471. offset = fileMarker.offset;
  28472. }
  28473. var marker = fileMarker && fileMarker.marker;
  28474. if (!marker || marker <= 0xFF00) {
  28475. throw new JpegError('marker was not found');
  28476. }
  28477. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  28478. offset += 2;
  28479. } else {
  28480. break;
  28481. }
  28482. }
  28483. fileMarker = findNextFileMarker(data, offset);
  28484. if (fileMarker && fileMarker.invalid) {
  28485. (0, _util.warn)('decodeScan - unexpected Scan data, next marker is: ' + fileMarker.invalid);
  28486. offset = fileMarker.offset;
  28487. }
  28488. return offset - startOffset;
  28489. }
  28490. function quantizeAndInverse(component, blockBufferOffset, p) {
  28491. var qt = component.quantizationTable,
  28492. blockData = component.blockData;
  28493. var v0, v1, v2, v3, v4, v5, v6, v7;
  28494. var p0, p1, p2, p3, p4, p5, p6, p7;
  28495. var t;
  28496. if (!qt) {
  28497. throw new JpegError('missing required Quantization Table.');
  28498. }
  28499. for (var row = 0; row < 64; row += 8) {
  28500. p0 = blockData[blockBufferOffset + row];
  28501. p1 = blockData[blockBufferOffset + row + 1];
  28502. p2 = blockData[blockBufferOffset + row + 2];
  28503. p3 = blockData[blockBufferOffset + row + 3];
  28504. p4 = blockData[blockBufferOffset + row + 4];
  28505. p5 = blockData[blockBufferOffset + row + 5];
  28506. p6 = blockData[blockBufferOffset + row + 6];
  28507. p7 = blockData[blockBufferOffset + row + 7];
  28508. p0 *= qt[row];
  28509. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  28510. t = dctSqrt2 * p0 + 512 >> 10;
  28511. p[row] = t;
  28512. p[row + 1] = t;
  28513. p[row + 2] = t;
  28514. p[row + 3] = t;
  28515. p[row + 4] = t;
  28516. p[row + 5] = t;
  28517. p[row + 6] = t;
  28518. p[row + 7] = t;
  28519. continue;
  28520. }
  28521. p1 *= qt[row + 1];
  28522. p2 *= qt[row + 2];
  28523. p3 *= qt[row + 3];
  28524. p4 *= qt[row + 4];
  28525. p5 *= qt[row + 5];
  28526. p6 *= qt[row + 6];
  28527. p7 *= qt[row + 7];
  28528. v0 = dctSqrt2 * p0 + 128 >> 8;
  28529. v1 = dctSqrt2 * p4 + 128 >> 8;
  28530. v2 = p2;
  28531. v3 = p6;
  28532. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  28533. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  28534. v5 = p3 << 4;
  28535. v6 = p5 << 4;
  28536. v0 = v0 + v1 + 1 >> 1;
  28537. v1 = v0 - v1;
  28538. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  28539. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  28540. v3 = t;
  28541. v4 = v4 + v6 + 1 >> 1;
  28542. v6 = v4 - v6;
  28543. v7 = v7 + v5 + 1 >> 1;
  28544. v5 = v7 - v5;
  28545. v0 = v0 + v3 + 1 >> 1;
  28546. v3 = v0 - v3;
  28547. v1 = v1 + v2 + 1 >> 1;
  28548. v2 = v1 - v2;
  28549. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  28550. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  28551. v7 = t;
  28552. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  28553. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  28554. v6 = t;
  28555. p[row] = v0 + v7;
  28556. p[row + 7] = v0 - v7;
  28557. p[row + 1] = v1 + v6;
  28558. p[row + 6] = v1 - v6;
  28559. p[row + 2] = v2 + v5;
  28560. p[row + 5] = v2 - v5;
  28561. p[row + 3] = v3 + v4;
  28562. p[row + 4] = v3 - v4;
  28563. }
  28564. for (var col = 0; col < 8; ++col) {
  28565. p0 = p[col];
  28566. p1 = p[col + 8];
  28567. p2 = p[col + 16];
  28568. p3 = p[col + 24];
  28569. p4 = p[col + 32];
  28570. p5 = p[col + 40];
  28571. p6 = p[col + 48];
  28572. p7 = p[col + 56];
  28573. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  28574. t = dctSqrt2 * p0 + 8192 >> 14;
  28575. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  28576. blockData[blockBufferOffset + col] = t;
  28577. blockData[blockBufferOffset + col + 8] = t;
  28578. blockData[blockBufferOffset + col + 16] = t;
  28579. blockData[blockBufferOffset + col + 24] = t;
  28580. blockData[blockBufferOffset + col + 32] = t;
  28581. blockData[blockBufferOffset + col + 40] = t;
  28582. blockData[blockBufferOffset + col + 48] = t;
  28583. blockData[blockBufferOffset + col + 56] = t;
  28584. continue;
  28585. }
  28586. v0 = dctSqrt2 * p0 + 2048 >> 12;
  28587. v1 = dctSqrt2 * p4 + 2048 >> 12;
  28588. v2 = p2;
  28589. v3 = p6;
  28590. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  28591. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  28592. v5 = p3;
  28593. v6 = p5;
  28594. v0 = (v0 + v1 + 1 >> 1) + 4112;
  28595. v1 = v0 - v1;
  28596. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  28597. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  28598. v3 = t;
  28599. v4 = v4 + v6 + 1 >> 1;
  28600. v6 = v4 - v6;
  28601. v7 = v7 + v5 + 1 >> 1;
  28602. v5 = v7 - v5;
  28603. v0 = v0 + v3 + 1 >> 1;
  28604. v3 = v0 - v3;
  28605. v1 = v1 + v2 + 1 >> 1;
  28606. v2 = v1 - v2;
  28607. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  28608. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  28609. v7 = t;
  28610. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  28611. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  28612. v6 = t;
  28613. p0 = v0 + v7;
  28614. p7 = v0 - v7;
  28615. p1 = v1 + v6;
  28616. p6 = v1 - v6;
  28617. p2 = v2 + v5;
  28618. p5 = v2 - v5;
  28619. p3 = v3 + v4;
  28620. p4 = v3 - v4;
  28621. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  28622. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  28623. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  28624. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  28625. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  28626. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  28627. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  28628. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  28629. blockData[blockBufferOffset + col] = p0;
  28630. blockData[blockBufferOffset + col + 8] = p1;
  28631. blockData[blockBufferOffset + col + 16] = p2;
  28632. blockData[blockBufferOffset + col + 24] = p3;
  28633. blockData[blockBufferOffset + col + 32] = p4;
  28634. blockData[blockBufferOffset + col + 40] = p5;
  28635. blockData[blockBufferOffset + col + 48] = p6;
  28636. blockData[blockBufferOffset + col + 56] = p7;
  28637. }
  28638. }
  28639. function buildComponentData(frame, component) {
  28640. var blocksPerLine = component.blocksPerLine;
  28641. var blocksPerColumn = component.blocksPerColumn;
  28642. var computationBuffer = new Int16Array(64);
  28643. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  28644. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  28645. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  28646. quantizeAndInverse(component, offset, computationBuffer);
  28647. }
  28648. }
  28649. return component.blockData;
  28650. }
  28651. function findNextFileMarker(data, currentPos, startPos) {
  28652. function peekUint16(pos) {
  28653. return data[pos] << 8 | data[pos + 1];
  28654. }
  28655. var maxPos = data.length - 1;
  28656. var newPos = startPos < currentPos ? startPos : currentPos;
  28657. if (currentPos >= maxPos) {
  28658. return null;
  28659. }
  28660. var currentMarker = peekUint16(currentPos);
  28661. if (currentMarker >= 0xFFC0 && currentMarker <= 0xFFFE) {
  28662. return {
  28663. invalid: null,
  28664. marker: currentMarker,
  28665. offset: currentPos
  28666. };
  28667. }
  28668. var newMarker = peekUint16(newPos);
  28669. while (!(newMarker >= 0xFFC0 && newMarker <= 0xFFFE)) {
  28670. if (++newPos >= maxPos) {
  28671. return null;
  28672. }
  28673. newMarker = peekUint16(newPos);
  28674. }
  28675. return {
  28676. invalid: currentMarker.toString(16),
  28677. marker: newMarker,
  28678. offset: newPos
  28679. };
  28680. }
  28681. JpegImage.prototype = {
  28682. parse: function parse(data) {
  28683. function readUint16() {
  28684. var value = data[offset] << 8 | data[offset + 1];
  28685. offset += 2;
  28686. return value;
  28687. }
  28688. function readDataBlock() {
  28689. var length = readUint16();
  28690. var endOffset = offset + length - 2;
  28691. var fileMarker = findNextFileMarker(data, endOffset, offset);
  28692. if (fileMarker && fileMarker.invalid) {
  28693. (0, _util.warn)('readDataBlock - incorrect length, next marker is: ' + fileMarker.invalid);
  28694. endOffset = fileMarker.offset;
  28695. }
  28696. var array = data.subarray(offset, endOffset);
  28697. offset += array.length;
  28698. return array;
  28699. }
  28700. function prepareComponents(frame) {
  28701. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  28702. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  28703. for (var i = 0; i < frame.components.length; i++) {
  28704. component = frame.components[i];
  28705. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  28706. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  28707. var blocksPerLineForMcu = mcusPerLine * component.h;
  28708. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  28709. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  28710. component.blockData = new Int16Array(blocksBufferSize);
  28711. component.blocksPerLine = blocksPerLine;
  28712. component.blocksPerColumn = blocksPerColumn;
  28713. }
  28714. frame.mcusPerLine = mcusPerLine;
  28715. frame.mcusPerColumn = mcusPerColumn;
  28716. }
  28717. var offset = 0;
  28718. var jfif = null;
  28719. var adobe = null;
  28720. var frame, resetInterval;
  28721. var quantizationTables = [];
  28722. var huffmanTablesAC = [],
  28723. huffmanTablesDC = [];
  28724. var fileMarker = readUint16();
  28725. if (fileMarker !== 0xFFD8) {
  28726. throw new JpegError('SOI not found');
  28727. }
  28728. fileMarker = readUint16();
  28729. while (fileMarker !== 0xFFD9) {
  28730. var i, j, l;
  28731. switch (fileMarker) {
  28732. case 0xFFE0:
  28733. case 0xFFE1:
  28734. case 0xFFE2:
  28735. case 0xFFE3:
  28736. case 0xFFE4:
  28737. case 0xFFE5:
  28738. case 0xFFE6:
  28739. case 0xFFE7:
  28740. case 0xFFE8:
  28741. case 0xFFE9:
  28742. case 0xFFEA:
  28743. case 0xFFEB:
  28744. case 0xFFEC:
  28745. case 0xFFED:
  28746. case 0xFFEE:
  28747. case 0xFFEF:
  28748. case 0xFFFE:
  28749. var appData = readDataBlock();
  28750. if (fileMarker === 0xFFE0) {
  28751. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  28752. jfif = {
  28753. version: {
  28754. major: appData[5],
  28755. minor: appData[6]
  28756. },
  28757. densityUnits: appData[7],
  28758. xDensity: appData[8] << 8 | appData[9],
  28759. yDensity: appData[10] << 8 | appData[11],
  28760. thumbWidth: appData[12],
  28761. thumbHeight: appData[13],
  28762. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  28763. };
  28764. }
  28765. }
  28766. if (fileMarker === 0xFFEE) {
  28767. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  28768. adobe = {
  28769. version: appData[5] << 8 | appData[6],
  28770. flags0: appData[7] << 8 | appData[8],
  28771. flags1: appData[9] << 8 | appData[10],
  28772. transformCode: appData[11]
  28773. };
  28774. }
  28775. }
  28776. break;
  28777. case 0xFFDB:
  28778. var quantizationTablesLength = readUint16();
  28779. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  28780. var z;
  28781. while (offset < quantizationTablesEnd) {
  28782. var quantizationTableSpec = data[offset++];
  28783. var tableData = new Uint16Array(64);
  28784. if (quantizationTableSpec >> 4 === 0) {
  28785. for (j = 0; j < 64; j++) {
  28786. z = dctZigZag[j];
  28787. tableData[z] = data[offset++];
  28788. }
  28789. } else if (quantizationTableSpec >> 4 === 1) {
  28790. for (j = 0; j < 64; j++) {
  28791. z = dctZigZag[j];
  28792. tableData[z] = readUint16();
  28793. }
  28794. } else {
  28795. throw new JpegError('DQT - invalid table spec');
  28796. }
  28797. quantizationTables[quantizationTableSpec & 15] = tableData;
  28798. }
  28799. break;
  28800. case 0xFFC0:
  28801. case 0xFFC1:
  28802. case 0xFFC2:
  28803. if (frame) {
  28804. throw new JpegError('Only single frame JPEGs supported');
  28805. }
  28806. readUint16();
  28807. frame = {};
  28808. frame.extended = fileMarker === 0xFFC1;
  28809. frame.progressive = fileMarker === 0xFFC2;
  28810. frame.precision = data[offset++];
  28811. frame.scanLines = readUint16();
  28812. frame.samplesPerLine = readUint16();
  28813. frame.components = [];
  28814. frame.componentIds = {};
  28815. var componentsCount = data[offset++],
  28816. componentId;
  28817. var maxH = 0,
  28818. maxV = 0;
  28819. for (i = 0; i < componentsCount; i++) {
  28820. componentId = data[offset];
  28821. var h = data[offset + 1] >> 4;
  28822. var v = data[offset + 1] & 15;
  28823. if (maxH < h) {
  28824. maxH = h;
  28825. }
  28826. if (maxV < v) {
  28827. maxV = v;
  28828. }
  28829. var qId = data[offset + 2];
  28830. l = frame.components.push({
  28831. h: h,
  28832. v: v,
  28833. quantizationId: qId,
  28834. quantizationTable: null
  28835. });
  28836. frame.componentIds[componentId] = l - 1;
  28837. offset += 3;
  28838. }
  28839. frame.maxH = maxH;
  28840. frame.maxV = maxV;
  28841. prepareComponents(frame);
  28842. break;
  28843. case 0xFFC4:
  28844. var huffmanLength = readUint16();
  28845. for (i = 2; i < huffmanLength;) {
  28846. var huffmanTableSpec = data[offset++];
  28847. var codeLengths = new Uint8Array(16);
  28848. var codeLengthSum = 0;
  28849. for (j = 0; j < 16; j++, offset++) {
  28850. codeLengthSum += codeLengths[j] = data[offset];
  28851. }
  28852. var huffmanValues = new Uint8Array(codeLengthSum);
  28853. for (j = 0; j < codeLengthSum; j++, offset++) {
  28854. huffmanValues[j] = data[offset];
  28855. }
  28856. i += 17 + codeLengthSum;
  28857. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  28858. }
  28859. break;
  28860. case 0xFFDD:
  28861. readUint16();
  28862. resetInterval = readUint16();
  28863. break;
  28864. case 0xFFDA:
  28865. readUint16();
  28866. var selectorsCount = data[offset++];
  28867. var components = [],
  28868. component;
  28869. for (i = 0; i < selectorsCount; i++) {
  28870. var componentIndex = frame.componentIds[data[offset++]];
  28871. component = frame.components[componentIndex];
  28872. var tableSpec = data[offset++];
  28873. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  28874. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  28875. components.push(component);
  28876. }
  28877. var spectralStart = data[offset++];
  28878. var spectralEnd = data[offset++];
  28879. var successiveApproximation = data[offset++];
  28880. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  28881. offset += processed;
  28882. break;
  28883. case 0xFFFF:
  28884. if (data[offset] !== 0xFF) {
  28885. offset--;
  28886. }
  28887. break;
  28888. default:
  28889. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  28890. offset -= 3;
  28891. break;
  28892. }
  28893. throw new JpegError('unknown marker ' + fileMarker.toString(16));
  28894. }
  28895. fileMarker = readUint16();
  28896. }
  28897. this.width = frame.samplesPerLine;
  28898. this.height = frame.scanLines;
  28899. this.jfif = jfif;
  28900. this.adobe = adobe;
  28901. this.components = [];
  28902. for (i = 0; i < frame.components.length; i++) {
  28903. component = frame.components[i];
  28904. var quantizationTable = quantizationTables[component.quantizationId];
  28905. if (quantizationTable) {
  28906. component.quantizationTable = quantizationTable;
  28907. }
  28908. this.components.push({
  28909. output: buildComponentData(frame, component),
  28910. scaleX: component.h / frame.maxH,
  28911. scaleY: component.v / frame.maxV,
  28912. blocksPerLine: component.blocksPerLine,
  28913. blocksPerColumn: component.blocksPerColumn
  28914. });
  28915. }
  28916. this.numComponents = this.components.length;
  28917. },
  28918. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  28919. var scaleX = this.width / width,
  28920. scaleY = this.height / height;
  28921. var component, componentScaleX, componentScaleY, blocksPerScanline;
  28922. var x, y, i, j, k;
  28923. var index;
  28924. var offset = 0;
  28925. var output;
  28926. var numComponents = this.components.length;
  28927. var dataLength = width * height * numComponents;
  28928. var data = new Uint8ClampedArray(dataLength);
  28929. var xScaleBlockOffset = new Uint32Array(width);
  28930. var mask3LSB = 0xfffffff8;
  28931. for (i = 0; i < numComponents; i++) {
  28932. component = this.components[i];
  28933. componentScaleX = component.scaleX * scaleX;
  28934. componentScaleY = component.scaleY * scaleY;
  28935. offset = i;
  28936. output = component.output;
  28937. blocksPerScanline = component.blocksPerLine + 1 << 3;
  28938. for (x = 0; x < width; x++) {
  28939. j = 0 | x * componentScaleX;
  28940. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  28941. }
  28942. for (y = 0; y < height; y++) {
  28943. j = 0 | y * componentScaleY;
  28944. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  28945. for (x = 0; x < width; x++) {
  28946. data[offset] = output[index + xScaleBlockOffset[x]];
  28947. offset += numComponents;
  28948. }
  28949. }
  28950. }
  28951. var transform = this.decodeTransform;
  28952. if (transform) {
  28953. for (i = 0; i < dataLength;) {
  28954. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  28955. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  28956. }
  28957. }
  28958. }
  28959. return data;
  28960. },
  28961. _isColorConversionNeeded: function _isColorConversionNeeded() {
  28962. if (this.adobe) {
  28963. return !!this.adobe.transformCode;
  28964. }
  28965. if (this.numComponents === 3) {
  28966. if (this.colorTransform === 0) {
  28967. return false;
  28968. }
  28969. return true;
  28970. }
  28971. if (this.colorTransform === 1) {
  28972. return true;
  28973. }
  28974. return false;
  28975. },
  28976. _convertYccToRgb: function convertYccToRgb(data) {
  28977. var Y, Cb, Cr;
  28978. for (var i = 0, length = data.length; i < length; i += 3) {
  28979. Y = data[i];
  28980. Cb = data[i + 1];
  28981. Cr = data[i + 2];
  28982. data[i] = Y - 179.456 + 1.402 * Cr;
  28983. data[i + 1] = Y + 135.459 - 0.344 * Cb - 0.714 * Cr;
  28984. data[i + 2] = Y - 226.816 + 1.772 * Cb;
  28985. }
  28986. return data;
  28987. },
  28988. _convertYcckToRgb: function convertYcckToRgb(data) {
  28989. var Y, Cb, Cr, k;
  28990. var offset = 0;
  28991. for (var i = 0, length = data.length; i < length; i += 4) {
  28992. Y = data[i];
  28993. Cb = data[i + 1];
  28994. Cr = data[i + 2];
  28995. k = data[i + 3];
  28996. data[offset++] = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  28997. data[offset++] = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  28998. data[offset++] = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  28999. }
  29000. return data;
  29001. },
  29002. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  29003. var Y, Cb, Cr;
  29004. for (var i = 0, length = data.length; i < length; i += 4) {
  29005. Y = data[i];
  29006. Cb = data[i + 1];
  29007. Cr = data[i + 2];
  29008. data[i] = 434.456 - Y - 1.402 * Cr;
  29009. data[i + 1] = 119.541 - Y + 0.344 * Cb + 0.714 * Cr;
  29010. data[i + 2] = 481.816 - Y - 1.772 * Cb;
  29011. }
  29012. return data;
  29013. },
  29014. _convertCmykToRgb: function convertCmykToRgb(data) {
  29015. var c, m, y, k;
  29016. var offset = 0;
  29017. var scale = 1 / 255;
  29018. for (var i = 0, length = data.length; i < length; i += 4) {
  29019. c = data[i] * scale;
  29020. m = data[i + 1] * scale;
  29021. y = data[i + 2] * scale;
  29022. k = data[i + 3] * scale;
  29023. data[offset++] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) - k * (21.86122147463605 * k + 189.48180835922747);
  29024. data[offset++] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) - k * (20.737325471181034 * k + 187.80453709719578);
  29025. data[offset++] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 193.58209356861505) - k * (22.33816807309886 * k + 180.12613974708367);
  29026. }
  29027. return data;
  29028. },
  29029. getData: function getData(width, height, forceRGBoutput) {
  29030. if (this.numComponents > 4) {
  29031. throw new JpegError('Unsupported color mode');
  29032. }
  29033. var data = this._getLinearizedBlockData(width, height);
  29034. if (this.numComponents === 1 && forceRGBoutput) {
  29035. var dataLength = data.length;
  29036. var rgbData = new Uint8ClampedArray(dataLength * 3);
  29037. var offset = 0;
  29038. for (var i = 0; i < dataLength; i++) {
  29039. var grayColor = data[i];
  29040. rgbData[offset++] = grayColor;
  29041. rgbData[offset++] = grayColor;
  29042. rgbData[offset++] = grayColor;
  29043. }
  29044. return rgbData;
  29045. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  29046. return this._convertYccToRgb(data);
  29047. } else if (this.numComponents === 4) {
  29048. if (this._isColorConversionNeeded()) {
  29049. if (forceRGBoutput) {
  29050. return this._convertYcckToRgb(data);
  29051. }
  29052. return this._convertYcckToCmyk(data);
  29053. } else if (forceRGBoutput) {
  29054. return this._convertCmykToRgb(data);
  29055. }
  29056. }
  29057. return data;
  29058. }
  29059. };
  29060. return JpegImage;
  29061. }();
  29062. exports.JpegImage = JpegImage;
  29063. /***/ }),
  29064. /* 125 */
  29065. /***/ (function(module, exports, __w_pdfjs_require__) {
  29066. "use strict";
  29067. Object.defineProperty(exports, "__esModule", {
  29068. value: true
  29069. });
  29070. exports.CCITTFaxStream = undefined;
  29071. var _primitives = __w_pdfjs_require__(1);
  29072. var _ccitt = __w_pdfjs_require__(126);
  29073. var _stream = __w_pdfjs_require__(5);
  29074. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  29075. function CCITTFaxStream(str, maybeLength, params) {
  29076. this.str = str;
  29077. this.dict = str.dict;
  29078. if (!(0, _primitives.isDict)(params)) {
  29079. params = _primitives.Dict.empty;
  29080. }
  29081. var source = {
  29082. next: function next() {
  29083. return str.getByte();
  29084. }
  29085. };
  29086. this.ccittFaxDecoder = new _ccitt.CCITTFaxDecoder(source, {
  29087. K: params.get('K'),
  29088. EndOfLine: params.get('EndOfLine'),
  29089. EncodedByteAlign: params.get('EncodedByteAlign'),
  29090. Columns: params.get('Columns'),
  29091. Rows: params.get('Rows'),
  29092. EndOfBlock: params.get('EndOfBlock'),
  29093. BlackIs1: params.get('BlackIs1')
  29094. });
  29095. _stream.DecodeStream.call(this, maybeLength);
  29096. }
  29097. CCITTFaxStream.prototype = Object.create(_stream.DecodeStream.prototype);
  29098. CCITTFaxStream.prototype.readBlock = function () {
  29099. while (!this.eof) {
  29100. var c = this.ccittFaxDecoder.readNextChar();
  29101. if (c === -1) {
  29102. this.eof = true;
  29103. return;
  29104. }
  29105. this.ensureBuffer(this.bufferLength + 1);
  29106. this.buffer[this.bufferLength++] = c;
  29107. }
  29108. };
  29109. return CCITTFaxStream;
  29110. }();
  29111. exports.CCITTFaxStream = CCITTFaxStream;
  29112. /***/ }),
  29113. /* 126 */
  29114. /***/ (function(module, exports, __w_pdfjs_require__) {
  29115. "use strict";
  29116. Object.defineProperty(exports, "__esModule", {
  29117. value: true
  29118. });
  29119. exports.CCITTFaxDecoder = undefined;
  29120. var _util = __w_pdfjs_require__(0);
  29121. var CCITTFaxDecoder = function CCITTFaxDecoder() {
  29122. var ccittEOL = -2;
  29123. var ccittEOF = -1;
  29124. var twoDimPass = 0;
  29125. var twoDimHoriz = 1;
  29126. var twoDimVert0 = 2;
  29127. var twoDimVertR1 = 3;
  29128. var twoDimVertL1 = 4;
  29129. var twoDimVertR2 = 5;
  29130. var twoDimVertL2 = 6;
  29131. var twoDimVertR3 = 7;
  29132. var twoDimVertL3 = 8;
  29133. 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]];
  29134. 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]];
  29135. 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]];
  29136. 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]];
  29137. 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]];
  29138. 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]];
  29139. function CCITTFaxDecoder(source) {
  29140. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  29141. if (!source || typeof source.next !== 'function') {
  29142. throw new Error('CCITTFaxDecoder - invalid "source" parameter.');
  29143. }
  29144. this.source = source;
  29145. this.eof = false;
  29146. this.encoding = options['K'] || 0;
  29147. this.eoline = options['EndOfLine'] || false;
  29148. this.byteAlign = options['EncodedByteAlign'] || false;
  29149. this.columns = options['Columns'] || 1728;
  29150. this.rows = options['Rows'] || 0;
  29151. var eoblock = options['EndOfBlock'];
  29152. if (eoblock === null || eoblock === undefined) {
  29153. eoblock = true;
  29154. }
  29155. this.eoblock = eoblock;
  29156. this.black = options['BlackIs1'] || false;
  29157. this.codingLine = new Uint32Array(this.columns + 1);
  29158. this.refLine = new Uint32Array(this.columns + 2);
  29159. this.codingLine[0] = this.columns;
  29160. this.codingPos = 0;
  29161. this.row = 0;
  29162. this.nextLine2D = this.encoding < 0;
  29163. this.inputBits = 0;
  29164. this.inputBuf = 0;
  29165. this.outputBits = 0;
  29166. this.rowsDone = false;
  29167. var code1 = void 0;
  29168. while ((code1 = this._lookBits(12)) === 0) {
  29169. this._eatBits(1);
  29170. }
  29171. if (code1 === 1) {
  29172. this._eatBits(12);
  29173. }
  29174. if (this.encoding > 0) {
  29175. this.nextLine2D = !this._lookBits(1);
  29176. this._eatBits(1);
  29177. }
  29178. }
  29179. CCITTFaxDecoder.prototype = {
  29180. readNextChar: function readNextChar() {
  29181. if (this.eof) {
  29182. return -1;
  29183. }
  29184. var refLine = this.refLine;
  29185. var codingLine = this.codingLine;
  29186. var columns = this.columns;
  29187. var refPos = void 0,
  29188. blackPixels = void 0,
  29189. bits = void 0,
  29190. i = void 0;
  29191. if (this.outputBits === 0) {
  29192. if (this.rowsDone) {
  29193. this.eof = true;
  29194. }
  29195. if (this.eof) {
  29196. return -1;
  29197. }
  29198. this.err = false;
  29199. var code1 = void 0,
  29200. code2 = void 0,
  29201. code3 = void 0;
  29202. if (this.nextLine2D) {
  29203. for (i = 0; codingLine[i] < columns; ++i) {
  29204. refLine[i] = codingLine[i];
  29205. }
  29206. refLine[i++] = columns;
  29207. refLine[i] = columns;
  29208. codingLine[0] = 0;
  29209. this.codingPos = 0;
  29210. refPos = 0;
  29211. blackPixels = 0;
  29212. while (codingLine[this.codingPos] < columns) {
  29213. code1 = this._getTwoDimCode();
  29214. switch (code1) {
  29215. case twoDimPass:
  29216. this._addPixels(refLine[refPos + 1], blackPixels);
  29217. if (refLine[refPos + 1] < columns) {
  29218. refPos += 2;
  29219. }
  29220. break;
  29221. case twoDimHoriz:
  29222. code1 = code2 = 0;
  29223. if (blackPixels) {
  29224. do {
  29225. code1 += code3 = this._getBlackCode();
  29226. } while (code3 >= 64);
  29227. do {
  29228. code2 += code3 = this._getWhiteCode();
  29229. } while (code3 >= 64);
  29230. } else {
  29231. do {
  29232. code1 += code3 = this._getWhiteCode();
  29233. } while (code3 >= 64);
  29234. do {
  29235. code2 += code3 = this._getBlackCode();
  29236. } while (code3 >= 64);
  29237. }
  29238. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29239. if (codingLine[this.codingPos] < columns) {
  29240. this._addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  29241. }
  29242. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29243. refPos += 2;
  29244. }
  29245. break;
  29246. case twoDimVertR3:
  29247. this._addPixels(refLine[refPos] + 3, blackPixels);
  29248. blackPixels ^= 1;
  29249. if (codingLine[this.codingPos] < columns) {
  29250. ++refPos;
  29251. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29252. refPos += 2;
  29253. }
  29254. }
  29255. break;
  29256. case twoDimVertR2:
  29257. this._addPixels(refLine[refPos] + 2, blackPixels);
  29258. blackPixels ^= 1;
  29259. if (codingLine[this.codingPos] < columns) {
  29260. ++refPos;
  29261. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29262. refPos += 2;
  29263. }
  29264. }
  29265. break;
  29266. case twoDimVertR1:
  29267. this._addPixels(refLine[refPos] + 1, blackPixels);
  29268. blackPixels ^= 1;
  29269. if (codingLine[this.codingPos] < columns) {
  29270. ++refPos;
  29271. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29272. refPos += 2;
  29273. }
  29274. }
  29275. break;
  29276. case twoDimVert0:
  29277. this._addPixels(refLine[refPos], blackPixels);
  29278. blackPixels ^= 1;
  29279. if (codingLine[this.codingPos] < columns) {
  29280. ++refPos;
  29281. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29282. refPos += 2;
  29283. }
  29284. }
  29285. break;
  29286. case twoDimVertL3:
  29287. this._addPixelsNeg(refLine[refPos] - 3, blackPixels);
  29288. blackPixels ^= 1;
  29289. if (codingLine[this.codingPos] < columns) {
  29290. if (refPos > 0) {
  29291. --refPos;
  29292. } else {
  29293. ++refPos;
  29294. }
  29295. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29296. refPos += 2;
  29297. }
  29298. }
  29299. break;
  29300. case twoDimVertL2:
  29301. this._addPixelsNeg(refLine[refPos] - 2, blackPixels);
  29302. blackPixels ^= 1;
  29303. if (codingLine[this.codingPos] < columns) {
  29304. if (refPos > 0) {
  29305. --refPos;
  29306. } else {
  29307. ++refPos;
  29308. }
  29309. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29310. refPos += 2;
  29311. }
  29312. }
  29313. break;
  29314. case twoDimVertL1:
  29315. this._addPixelsNeg(refLine[refPos] - 1, blackPixels);
  29316. blackPixels ^= 1;
  29317. if (codingLine[this.codingPos] < columns) {
  29318. if (refPos > 0) {
  29319. --refPos;
  29320. } else {
  29321. ++refPos;
  29322. }
  29323. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29324. refPos += 2;
  29325. }
  29326. }
  29327. break;
  29328. case ccittEOF:
  29329. this._addPixels(columns, 0);
  29330. this.eof = true;
  29331. break;
  29332. default:
  29333. (0, _util.info)('bad 2d code');
  29334. this._addPixels(columns, 0);
  29335. this.err = true;
  29336. }
  29337. }
  29338. } else {
  29339. codingLine[0] = 0;
  29340. this.codingPos = 0;
  29341. blackPixels = 0;
  29342. while (codingLine[this.codingPos] < columns) {
  29343. code1 = 0;
  29344. if (blackPixels) {
  29345. do {
  29346. code1 += code3 = this._getBlackCode();
  29347. } while (code3 >= 64);
  29348. } else {
  29349. do {
  29350. code1 += code3 = this._getWhiteCode();
  29351. } while (code3 >= 64);
  29352. }
  29353. this._addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29354. blackPixels ^= 1;
  29355. }
  29356. }
  29357. var gotEOL = false;
  29358. if (this.byteAlign) {
  29359. this.inputBits &= ~7;
  29360. }
  29361. if (!this.eoblock && this.row === this.rows - 1) {
  29362. this.rowsDone = true;
  29363. } else {
  29364. code1 = this._lookBits(12);
  29365. if (this.eoline) {
  29366. while (code1 !== ccittEOF && code1 !== 1) {
  29367. this._eatBits(1);
  29368. code1 = this._lookBits(12);
  29369. }
  29370. } else {
  29371. while (code1 === 0) {
  29372. this._eatBits(1);
  29373. code1 = this._lookBits(12);
  29374. }
  29375. }
  29376. if (code1 === 1) {
  29377. this._eatBits(12);
  29378. gotEOL = true;
  29379. } else if (code1 === ccittEOF) {
  29380. this.eof = true;
  29381. }
  29382. }
  29383. if (!this.eof && this.encoding > 0 && !this.rowsDone) {
  29384. this.nextLine2D = !this._lookBits(1);
  29385. this._eatBits(1);
  29386. }
  29387. if (this.eoblock && gotEOL && this.byteAlign) {
  29388. code1 = this._lookBits(12);
  29389. if (code1 === 1) {
  29390. this._eatBits(12);
  29391. if (this.encoding > 0) {
  29392. this._lookBits(1);
  29393. this._eatBits(1);
  29394. }
  29395. if (this.encoding >= 0) {
  29396. for (i = 0; i < 4; ++i) {
  29397. code1 = this._lookBits(12);
  29398. if (code1 !== 1) {
  29399. (0, _util.info)('bad rtc code: ' + code1);
  29400. }
  29401. this._eatBits(12);
  29402. if (this.encoding > 0) {
  29403. this._lookBits(1);
  29404. this._eatBits(1);
  29405. }
  29406. }
  29407. }
  29408. this.eof = true;
  29409. }
  29410. } else if (this.err && this.eoline) {
  29411. while (true) {
  29412. code1 = this._lookBits(13);
  29413. if (code1 === ccittEOF) {
  29414. this.eof = true;
  29415. return -1;
  29416. }
  29417. if (code1 >> 1 === 1) {
  29418. break;
  29419. }
  29420. this._eatBits(1);
  29421. }
  29422. this._eatBits(12);
  29423. if (this.encoding > 0) {
  29424. this._eatBits(1);
  29425. this.nextLine2D = !(code1 & 1);
  29426. }
  29427. }
  29428. if (codingLine[0] > 0) {
  29429. this.outputBits = codingLine[this.codingPos = 0];
  29430. } else {
  29431. this.outputBits = codingLine[this.codingPos = 1];
  29432. }
  29433. this.row++;
  29434. }
  29435. var c = void 0;
  29436. if (this.outputBits >= 8) {
  29437. c = this.codingPos & 1 ? 0 : 0xFF;
  29438. this.outputBits -= 8;
  29439. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  29440. this.codingPos++;
  29441. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29442. }
  29443. } else {
  29444. bits = 8;
  29445. c = 0;
  29446. do {
  29447. if (this.outputBits > bits) {
  29448. c <<= bits;
  29449. if (!(this.codingPos & 1)) {
  29450. c |= 0xFF >> 8 - bits;
  29451. }
  29452. this.outputBits -= bits;
  29453. bits = 0;
  29454. } else {
  29455. c <<= this.outputBits;
  29456. if (!(this.codingPos & 1)) {
  29457. c |= 0xFF >> 8 - this.outputBits;
  29458. }
  29459. bits -= this.outputBits;
  29460. this.outputBits = 0;
  29461. if (codingLine[this.codingPos] < columns) {
  29462. this.codingPos++;
  29463. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29464. } else if (bits > 0) {
  29465. c <<= bits;
  29466. bits = 0;
  29467. }
  29468. }
  29469. } while (bits);
  29470. }
  29471. if (this.black) {
  29472. c ^= 0xFF;
  29473. }
  29474. return c;
  29475. },
  29476. _addPixels: function _addPixels(a1, blackPixels) {
  29477. var codingLine = this.codingLine;
  29478. var codingPos = this.codingPos;
  29479. if (a1 > codingLine[codingPos]) {
  29480. if (a1 > this.columns) {
  29481. (0, _util.info)('row is wrong length');
  29482. this.err = true;
  29483. a1 = this.columns;
  29484. }
  29485. if (codingPos & 1 ^ blackPixels) {
  29486. ++codingPos;
  29487. }
  29488. codingLine[codingPos] = a1;
  29489. }
  29490. this.codingPos = codingPos;
  29491. },
  29492. _addPixelsNeg: function _addPixelsNeg(a1, blackPixels) {
  29493. var codingLine = this.codingLine;
  29494. var codingPos = this.codingPos;
  29495. if (a1 > codingLine[codingPos]) {
  29496. if (a1 > this.columns) {
  29497. (0, _util.info)('row is wrong length');
  29498. this.err = true;
  29499. a1 = this.columns;
  29500. }
  29501. if (codingPos & 1 ^ blackPixels) {
  29502. ++codingPos;
  29503. }
  29504. codingLine[codingPos] = a1;
  29505. } else if (a1 < codingLine[codingPos]) {
  29506. if (a1 < 0) {
  29507. (0, _util.info)('invalid code');
  29508. this.err = true;
  29509. a1 = 0;
  29510. }
  29511. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  29512. --codingPos;
  29513. }
  29514. codingLine[codingPos] = a1;
  29515. }
  29516. this.codingPos = codingPos;
  29517. },
  29518. _findTableCode: function _findTableCode(start, end, table, limit) {
  29519. var limitValue = limit || 0;
  29520. for (var i = start; i <= end; ++i) {
  29521. var code = this._lookBits(i);
  29522. if (code === ccittEOF) {
  29523. return [true, 1, false];
  29524. }
  29525. if (i < end) {
  29526. code <<= end - i;
  29527. }
  29528. if (!limitValue || code >= limitValue) {
  29529. var p = table[code - limitValue];
  29530. if (p[0] === i) {
  29531. this._eatBits(i);
  29532. return [true, p[1], true];
  29533. }
  29534. }
  29535. }
  29536. return [false, 0, false];
  29537. },
  29538. _getTwoDimCode: function _getTwoDimCode() {
  29539. var code = 0;
  29540. var p = void 0;
  29541. if (this.eoblock) {
  29542. code = this._lookBits(7);
  29543. p = twoDimTable[code];
  29544. if (p && p[0] > 0) {
  29545. this._eatBits(p[0]);
  29546. return p[1];
  29547. }
  29548. } else {
  29549. var result = this._findTableCode(1, 7, twoDimTable);
  29550. if (result[0] && result[2]) {
  29551. return result[1];
  29552. }
  29553. }
  29554. (0, _util.info)('Bad two dim code');
  29555. return ccittEOF;
  29556. },
  29557. _getWhiteCode: function _getWhiteCode() {
  29558. var code = 0;
  29559. var p = void 0;
  29560. if (this.eoblock) {
  29561. code = this._lookBits(12);
  29562. if (code === ccittEOF) {
  29563. return 1;
  29564. }
  29565. if (code >> 5 === 0) {
  29566. p = whiteTable1[code];
  29567. } else {
  29568. p = whiteTable2[code >> 3];
  29569. }
  29570. if (p[0] > 0) {
  29571. this._eatBits(p[0]);
  29572. return p[1];
  29573. }
  29574. } else {
  29575. var result = this._findTableCode(1, 9, whiteTable2);
  29576. if (result[0]) {
  29577. return result[1];
  29578. }
  29579. result = this._findTableCode(11, 12, whiteTable1);
  29580. if (result[0]) {
  29581. return result[1];
  29582. }
  29583. }
  29584. (0, _util.info)('bad white code');
  29585. this._eatBits(1);
  29586. return 1;
  29587. },
  29588. _getBlackCode: function _getBlackCode() {
  29589. var code = void 0,
  29590. p = void 0;
  29591. if (this.eoblock) {
  29592. code = this._lookBits(13);
  29593. if (code === ccittEOF) {
  29594. return 1;
  29595. }
  29596. if (code >> 7 === 0) {
  29597. p = blackTable1[code];
  29598. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  29599. p = blackTable2[(code >> 1) - 64];
  29600. } else {
  29601. p = blackTable3[code >> 7];
  29602. }
  29603. if (p[0] > 0) {
  29604. this._eatBits(p[0]);
  29605. return p[1];
  29606. }
  29607. } else {
  29608. var result = this._findTableCode(2, 6, blackTable3);
  29609. if (result[0]) {
  29610. return result[1];
  29611. }
  29612. result = this._findTableCode(7, 12, blackTable2, 64);
  29613. if (result[0]) {
  29614. return result[1];
  29615. }
  29616. result = this._findTableCode(10, 13, blackTable1);
  29617. if (result[0]) {
  29618. return result[1];
  29619. }
  29620. }
  29621. (0, _util.info)('bad black code');
  29622. this._eatBits(1);
  29623. return 1;
  29624. },
  29625. _lookBits: function _lookBits(n) {
  29626. var c = void 0;
  29627. while (this.inputBits < n) {
  29628. if ((c = this.source.next()) === -1) {
  29629. if (this.inputBits === 0) {
  29630. return ccittEOF;
  29631. }
  29632. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  29633. }
  29634. this.inputBuf = this.inputBuf << 8 | c;
  29635. this.inputBits += 8;
  29636. }
  29637. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  29638. },
  29639. _eatBits: function _eatBits(n) {
  29640. if ((this.inputBits -= n) < 0) {
  29641. this.inputBits = 0;
  29642. }
  29643. }
  29644. };
  29645. return CCITTFaxDecoder;
  29646. }();
  29647. exports.CCITTFaxDecoder = CCITTFaxDecoder;
  29648. /***/ }),
  29649. /* 127 */
  29650. /***/ (function(module, exports, __w_pdfjs_require__) {
  29651. "use strict";
  29652. Object.defineProperty(exports, "__esModule", {
  29653. value: true
  29654. });
  29655. exports.Jbig2Stream = undefined;
  29656. var _primitives = __w_pdfjs_require__(1);
  29657. var _stream = __w_pdfjs_require__(5);
  29658. var _jbig = __w_pdfjs_require__(128);
  29659. var _util = __w_pdfjs_require__(0);
  29660. var Jbig2Stream = function Jbig2StreamClosure() {
  29661. function Jbig2Stream(stream, maybeLength, dict, params) {
  29662. this.stream = stream;
  29663. this.maybeLength = maybeLength;
  29664. this.dict = dict;
  29665. this.params = params;
  29666. _stream.DecodeStream.call(this, maybeLength);
  29667. }
  29668. Jbig2Stream.prototype = Object.create(_stream.DecodeStream.prototype);
  29669. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  29670. get: function get() {
  29671. return (0, _util.shadow)(this, 'bytes', this.stream.getBytes(this.maybeLength));
  29672. },
  29673. configurable: true
  29674. });
  29675. Jbig2Stream.prototype.ensureBuffer = function (req) {
  29676. if (this.bufferLength) {
  29677. return;
  29678. }
  29679. var jbig2Image = new _jbig.Jbig2Image();
  29680. var chunks = [];
  29681. if ((0, _primitives.isDict)(this.params)) {
  29682. var globalsStream = this.params.get('JBIG2Globals');
  29683. if ((0, _primitives.isStream)(globalsStream)) {
  29684. var globals = globalsStream.getBytes();
  29685. chunks.push({
  29686. data: globals,
  29687. start: 0,
  29688. end: globals.length
  29689. });
  29690. }
  29691. }
  29692. chunks.push({
  29693. data: this.bytes,
  29694. start: 0,
  29695. end: this.bytes.length
  29696. });
  29697. var data = jbig2Image.parseChunks(chunks);
  29698. var dataLength = data.length;
  29699. for (var i = 0; i < dataLength; i++) {
  29700. data[i] ^= 0xFF;
  29701. }
  29702. this.buffer = data;
  29703. this.bufferLength = dataLength;
  29704. this.eof = true;
  29705. };
  29706. return Jbig2Stream;
  29707. }();
  29708. exports.Jbig2Stream = Jbig2Stream;
  29709. /***/ }),
  29710. /* 128 */
  29711. /***/ (function(module, exports, __w_pdfjs_require__) {
  29712. "use strict";
  29713. Object.defineProperty(exports, "__esModule", {
  29714. value: true
  29715. });
  29716. exports.Jbig2Image = undefined;
  29717. var _util = __w_pdfjs_require__(0);
  29718. var _arithmetic_decoder = __w_pdfjs_require__(64);
  29719. var Jbig2Error = function Jbig2ErrorClosure() {
  29720. function Jbig2Error(msg) {
  29721. this.message = 'JBIG2 error: ' + msg;
  29722. }
  29723. Jbig2Error.prototype = new Error();
  29724. Jbig2Error.prototype.name = 'Jbig2Error';
  29725. Jbig2Error.constructor = Jbig2Error;
  29726. return Jbig2Error;
  29727. }();
  29728. var Jbig2Image = function Jbig2ImageClosure() {
  29729. function ContextCache() {}
  29730. ContextCache.prototype = {
  29731. getContexts: function getContexts(id) {
  29732. if (id in this) {
  29733. return this[id];
  29734. }
  29735. return this[id] = new Int8Array(1 << 16);
  29736. }
  29737. };
  29738. function DecodingContext(data, start, end) {
  29739. this.data = data;
  29740. this.start = start;
  29741. this.end = end;
  29742. }
  29743. DecodingContext.prototype = {
  29744. get decoder() {
  29745. var decoder = new _arithmetic_decoder.ArithmeticDecoder(this.data, this.start, this.end);
  29746. return (0, _util.shadow)(this, 'decoder', decoder);
  29747. },
  29748. get contextCache() {
  29749. var cache = new ContextCache();
  29750. return (0, _util.shadow)(this, 'contextCache', cache);
  29751. }
  29752. };
  29753. function decodeInteger(contextCache, procedure, decoder) {
  29754. var contexts = contextCache.getContexts(procedure);
  29755. var prev = 1;
  29756. function readBits(length) {
  29757. var v = 0;
  29758. for (var i = 0; i < length; i++) {
  29759. var bit = decoder.readBit(contexts, prev);
  29760. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  29761. v = v << 1 | bit;
  29762. }
  29763. return v >>> 0;
  29764. }
  29765. var sign = readBits(1);
  29766. 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);
  29767. return sign === 0 ? value : value > 0 ? -value : null;
  29768. }
  29769. function decodeIAID(contextCache, decoder, codeLength) {
  29770. var contexts = contextCache.getContexts('IAID');
  29771. var prev = 1;
  29772. for (var i = 0; i < codeLength; i++) {
  29773. var bit = decoder.readBit(contexts, prev);
  29774. prev = prev << 1 | bit;
  29775. }
  29776. if (codeLength < 31) {
  29777. return prev & (1 << codeLength) - 1;
  29778. }
  29779. return prev & 0x7FFFFFFF;
  29780. }
  29781. 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'];
  29782. var CodingTemplates = [[{
  29783. x: -1,
  29784. y: -2
  29785. }, {
  29786. x: 0,
  29787. y: -2
  29788. }, {
  29789. x: 1,
  29790. y: -2
  29791. }, {
  29792. x: -2,
  29793. y: -1
  29794. }, {
  29795. x: -1,
  29796. y: -1
  29797. }, {
  29798. x: 0,
  29799. y: -1
  29800. }, {
  29801. x: 1,
  29802. y: -1
  29803. }, {
  29804. x: 2,
  29805. y: -1
  29806. }, {
  29807. x: -4,
  29808. y: 0
  29809. }, {
  29810. x: -3,
  29811. y: 0
  29812. }, {
  29813. x: -2,
  29814. y: 0
  29815. }, {
  29816. x: -1,
  29817. y: 0
  29818. }], [{
  29819. x: -1,
  29820. y: -2
  29821. }, {
  29822. x: 0,
  29823. y: -2
  29824. }, {
  29825. x: 1,
  29826. y: -2
  29827. }, {
  29828. x: 2,
  29829. y: -2
  29830. }, {
  29831. x: -2,
  29832. y: -1
  29833. }, {
  29834. x: -1,
  29835. y: -1
  29836. }, {
  29837. x: 0,
  29838. y: -1
  29839. }, {
  29840. x: 1,
  29841. y: -1
  29842. }, {
  29843. x: 2,
  29844. y: -1
  29845. }, {
  29846. x: -3,
  29847. y: 0
  29848. }, {
  29849. x: -2,
  29850. y: 0
  29851. }, {
  29852. x: -1,
  29853. y: 0
  29854. }], [{
  29855. x: -1,
  29856. y: -2
  29857. }, {
  29858. x: 0,
  29859. y: -2
  29860. }, {
  29861. x: 1,
  29862. y: -2
  29863. }, {
  29864. x: -2,
  29865. y: -1
  29866. }, {
  29867. x: -1,
  29868. y: -1
  29869. }, {
  29870. x: 0,
  29871. y: -1
  29872. }, {
  29873. x: 1,
  29874. y: -1
  29875. }, {
  29876. x: -2,
  29877. y: 0
  29878. }, {
  29879. x: -1,
  29880. y: 0
  29881. }], [{
  29882. x: -3,
  29883. y: -1
  29884. }, {
  29885. x: -2,
  29886. y: -1
  29887. }, {
  29888. x: -1,
  29889. y: -1
  29890. }, {
  29891. x: 0,
  29892. y: -1
  29893. }, {
  29894. x: 1,
  29895. y: -1
  29896. }, {
  29897. x: -4,
  29898. y: 0
  29899. }, {
  29900. x: -3,
  29901. y: 0
  29902. }, {
  29903. x: -2,
  29904. y: 0
  29905. }, {
  29906. x: -1,
  29907. y: 0
  29908. }]];
  29909. var RefinementTemplates = [{
  29910. coding: [{
  29911. x: 0,
  29912. y: -1
  29913. }, {
  29914. x: 1,
  29915. y: -1
  29916. }, {
  29917. x: -1,
  29918. y: 0
  29919. }],
  29920. reference: [{
  29921. x: 0,
  29922. y: -1
  29923. }, {
  29924. x: 1,
  29925. y: -1
  29926. }, {
  29927. x: -1,
  29928. y: 0
  29929. }, {
  29930. x: 0,
  29931. y: 0
  29932. }, {
  29933. x: 1,
  29934. y: 0
  29935. }, {
  29936. x: -1,
  29937. y: 1
  29938. }, {
  29939. x: 0,
  29940. y: 1
  29941. }, {
  29942. x: 1,
  29943. y: 1
  29944. }]
  29945. }, {
  29946. coding: [{
  29947. x: -1,
  29948. y: -1
  29949. }, {
  29950. x: 0,
  29951. y: -1
  29952. }, {
  29953. x: 1,
  29954. y: -1
  29955. }, {
  29956. x: -1,
  29957. y: 0
  29958. }],
  29959. reference: [{
  29960. x: 0,
  29961. y: -1
  29962. }, {
  29963. x: -1,
  29964. y: 0
  29965. }, {
  29966. x: 0,
  29967. y: 0
  29968. }, {
  29969. x: 1,
  29970. y: 0
  29971. }, {
  29972. x: 0,
  29973. y: 1
  29974. }, {
  29975. x: 1,
  29976. y: 1
  29977. }]
  29978. }];
  29979. var ReusedContexts = [0x9B25, 0x0795, 0x00E5, 0x0195];
  29980. var RefinementReusedContexts = [0x0020, 0x0008];
  29981. function decodeBitmapTemplate0(width, height, decodingContext) {
  29982. var decoder = decodingContext.decoder;
  29983. var contexts = decodingContext.contextCache.getContexts('GB');
  29984. var contextLabel,
  29985. i,
  29986. j,
  29987. pixel,
  29988. row,
  29989. row1,
  29990. row2,
  29991. bitmap = [];
  29992. var OLD_PIXEL_MASK = 0x7BF7;
  29993. for (i = 0; i < height; i++) {
  29994. row = bitmap[i] = new Uint8Array(width);
  29995. row1 = i < 1 ? row : bitmap[i - 1];
  29996. row2 = i < 2 ? row : bitmap[i - 2];
  29997. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  29998. for (j = 0; j < width; j++) {
  29999. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  30000. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  30001. }
  30002. }
  30003. return bitmap;
  30004. }
  30005. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  30006. if (mmr) {
  30007. throw new Jbig2Error('MMR encoding is not supported');
  30008. }
  30009. 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) {
  30010. return decodeBitmapTemplate0(width, height, decodingContext);
  30011. }
  30012. var useskip = !!skip;
  30013. var template = CodingTemplates[templateIndex].concat(at);
  30014. template.sort(function (a, b) {
  30015. return a.y - b.y || a.x - b.x;
  30016. });
  30017. var templateLength = template.length;
  30018. var templateX = new Int8Array(templateLength);
  30019. var templateY = new Int8Array(templateLength);
  30020. var changingTemplateEntries = [];
  30021. var reuseMask = 0,
  30022. minX = 0,
  30023. maxX = 0,
  30024. minY = 0;
  30025. var c, k;
  30026. for (k = 0; k < templateLength; k++) {
  30027. templateX[k] = template[k].x;
  30028. templateY[k] = template[k].y;
  30029. minX = Math.min(minX, template[k].x);
  30030. maxX = Math.max(maxX, template[k].x);
  30031. minY = Math.min(minY, template[k].y);
  30032. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  30033. reuseMask |= 1 << templateLength - 1 - k;
  30034. } else {
  30035. changingTemplateEntries.push(k);
  30036. }
  30037. }
  30038. var changingEntriesLength = changingTemplateEntries.length;
  30039. var changingTemplateX = new Int8Array(changingEntriesLength);
  30040. var changingTemplateY = new Int8Array(changingEntriesLength);
  30041. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  30042. for (c = 0; c < changingEntriesLength; c++) {
  30043. k = changingTemplateEntries[c];
  30044. changingTemplateX[c] = template[k].x;
  30045. changingTemplateY[c] = template[k].y;
  30046. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  30047. }
  30048. var sbb_left = -minX;
  30049. var sbb_top = -minY;
  30050. var sbb_right = width - maxX;
  30051. var pseudoPixelContext = ReusedContexts[templateIndex];
  30052. var row = new Uint8Array(width);
  30053. var bitmap = [];
  30054. var decoder = decodingContext.decoder;
  30055. var contexts = decodingContext.contextCache.getContexts('GB');
  30056. var ltp = 0,
  30057. j,
  30058. i0,
  30059. j0,
  30060. contextLabel = 0,
  30061. bit,
  30062. shift;
  30063. for (var i = 0; i < height; i++) {
  30064. if (prediction) {
  30065. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  30066. ltp ^= sltp;
  30067. if (ltp) {
  30068. bitmap.push(row);
  30069. continue;
  30070. }
  30071. }
  30072. row = new Uint8Array(row);
  30073. bitmap.push(row);
  30074. for (j = 0; j < width; j++) {
  30075. if (useskip && skip[i][j]) {
  30076. row[j] = 0;
  30077. continue;
  30078. }
  30079. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  30080. contextLabel = contextLabel << 1 & reuseMask;
  30081. for (k = 0; k < changingEntriesLength; k++) {
  30082. i0 = i + changingTemplateY[k];
  30083. j0 = j + changingTemplateX[k];
  30084. bit = bitmap[i0][j0];
  30085. if (bit) {
  30086. bit = changingTemplateBit[k];
  30087. contextLabel |= bit;
  30088. }
  30089. }
  30090. } else {
  30091. contextLabel = 0;
  30092. shift = templateLength - 1;
  30093. for (k = 0; k < templateLength; k++, shift--) {
  30094. j0 = j + templateX[k];
  30095. if (j0 >= 0 && j0 < width) {
  30096. i0 = i + templateY[k];
  30097. if (i0 >= 0) {
  30098. bit = bitmap[i0][j0];
  30099. if (bit) {
  30100. contextLabel |= bit << shift;
  30101. }
  30102. }
  30103. }
  30104. }
  30105. }
  30106. var pixel = decoder.readBit(contexts, contextLabel);
  30107. row[j] = pixel;
  30108. }
  30109. }
  30110. return bitmap;
  30111. }
  30112. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  30113. var codingTemplate = RefinementTemplates[templateIndex].coding;
  30114. if (templateIndex === 0) {
  30115. codingTemplate = codingTemplate.concat([at[0]]);
  30116. }
  30117. var codingTemplateLength = codingTemplate.length;
  30118. var codingTemplateX = new Int32Array(codingTemplateLength);
  30119. var codingTemplateY = new Int32Array(codingTemplateLength);
  30120. var k;
  30121. for (k = 0; k < codingTemplateLength; k++) {
  30122. codingTemplateX[k] = codingTemplate[k].x;
  30123. codingTemplateY[k] = codingTemplate[k].y;
  30124. }
  30125. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  30126. if (templateIndex === 0) {
  30127. referenceTemplate = referenceTemplate.concat([at[1]]);
  30128. }
  30129. var referenceTemplateLength = referenceTemplate.length;
  30130. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  30131. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  30132. for (k = 0; k < referenceTemplateLength; k++) {
  30133. referenceTemplateX[k] = referenceTemplate[k].x;
  30134. referenceTemplateY[k] = referenceTemplate[k].y;
  30135. }
  30136. var referenceWidth = referenceBitmap[0].length;
  30137. var referenceHeight = referenceBitmap.length;
  30138. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  30139. var bitmap = [];
  30140. var decoder = decodingContext.decoder;
  30141. var contexts = decodingContext.contextCache.getContexts('GR');
  30142. var ltp = 0;
  30143. for (var i = 0; i < height; i++) {
  30144. if (prediction) {
  30145. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  30146. ltp ^= sltp;
  30147. if (ltp) {
  30148. throw new Jbig2Error('prediction is not supported');
  30149. }
  30150. }
  30151. var row = new Uint8Array(width);
  30152. bitmap.push(row);
  30153. for (var j = 0; j < width; j++) {
  30154. var i0, j0;
  30155. var contextLabel = 0;
  30156. for (k = 0; k < codingTemplateLength; k++) {
  30157. i0 = i + codingTemplateY[k];
  30158. j0 = j + codingTemplateX[k];
  30159. if (i0 < 0 || j0 < 0 || j0 >= width) {
  30160. contextLabel <<= 1;
  30161. } else {
  30162. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  30163. }
  30164. }
  30165. for (k = 0; k < referenceTemplateLength; k++) {
  30166. i0 = i + referenceTemplateY[k] - offsetY;
  30167. j0 = j + referenceTemplateX[k] - offsetX;
  30168. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  30169. contextLabel <<= 1;
  30170. } else {
  30171. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  30172. }
  30173. }
  30174. var pixel = decoder.readBit(contexts, contextLabel);
  30175. row[j] = pixel;
  30176. }
  30177. }
  30178. return bitmap;
  30179. }
  30180. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  30181. if (huffman) {
  30182. throw new Jbig2Error('huffman is not supported');
  30183. }
  30184. var newSymbols = [];
  30185. var currentHeight = 0;
  30186. var symbolCodeLength = (0, _util.log2)(symbols.length + numberOfNewSymbols);
  30187. var decoder = decodingContext.decoder;
  30188. var contextCache = decodingContext.contextCache;
  30189. while (newSymbols.length < numberOfNewSymbols) {
  30190. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  30191. currentHeight += deltaHeight;
  30192. var currentWidth = 0;
  30193. while (true) {
  30194. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  30195. if (deltaWidth === null) {
  30196. break;
  30197. }
  30198. currentWidth += deltaWidth;
  30199. var bitmap;
  30200. if (refinement) {
  30201. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  30202. if (numberOfInstances > 1) {
  30203. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  30204. } else {
  30205. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  30206. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  30207. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  30208. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  30209. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  30210. }
  30211. } else {
  30212. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  30213. }
  30214. newSymbols.push(bitmap);
  30215. }
  30216. }
  30217. var exportedSymbols = [];
  30218. var flags = [],
  30219. currentFlag = false;
  30220. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  30221. while (flags.length < totalSymbolsLength) {
  30222. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  30223. while (runLength--) {
  30224. flags.push(currentFlag);
  30225. }
  30226. currentFlag = !currentFlag;
  30227. }
  30228. for (var i = 0, ii = symbols.length; i < ii; i++) {
  30229. if (flags[i]) {
  30230. exportedSymbols.push(symbols[i]);
  30231. }
  30232. }
  30233. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  30234. if (flags[i]) {
  30235. exportedSymbols.push(newSymbols[j]);
  30236. }
  30237. }
  30238. return exportedSymbols;
  30239. }
  30240. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  30241. if (huffman) {
  30242. throw new Jbig2Error('huffman is not supported');
  30243. }
  30244. var bitmap = [];
  30245. var i, row;
  30246. for (i = 0; i < height; i++) {
  30247. row = new Uint8Array(width);
  30248. if (defaultPixelValue) {
  30249. for (var j = 0; j < width; j++) {
  30250. row[j] = defaultPixelValue;
  30251. }
  30252. }
  30253. bitmap.push(row);
  30254. }
  30255. var decoder = decodingContext.decoder;
  30256. var contextCache = decodingContext.contextCache;
  30257. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  30258. var firstS = 0;
  30259. i = 0;
  30260. while (i < numberOfSymbolInstances) {
  30261. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  30262. stripT += deltaT;
  30263. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  30264. firstS += deltaFirstS;
  30265. var currentS = firstS;
  30266. do {
  30267. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  30268. var t = stripSize * stripT + currentT;
  30269. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  30270. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  30271. var symbolBitmap = inputSymbols[symbolId];
  30272. var symbolWidth = symbolBitmap[0].length;
  30273. var symbolHeight = symbolBitmap.length;
  30274. if (applyRefinement) {
  30275. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  30276. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  30277. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  30278. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  30279. symbolWidth += rdw;
  30280. symbolHeight += rdh;
  30281. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  30282. }
  30283. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
  30284. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
  30285. var s2, t2, symbolRow;
  30286. if (transposed) {
  30287. for (s2 = 0; s2 < symbolHeight; s2++) {
  30288. row = bitmap[offsetS + s2];
  30289. if (!row) {
  30290. continue;
  30291. }
  30292. symbolRow = symbolBitmap[s2];
  30293. var maxWidth = Math.min(width - offsetT, symbolWidth);
  30294. switch (combinationOperator) {
  30295. case 0:
  30296. for (t2 = 0; t2 < maxWidth; t2++) {
  30297. row[offsetT + t2] |= symbolRow[t2];
  30298. }
  30299. break;
  30300. case 2:
  30301. for (t2 = 0; t2 < maxWidth; t2++) {
  30302. row[offsetT + t2] ^= symbolRow[t2];
  30303. }
  30304. break;
  30305. default:
  30306. throw new Jbig2Error('operator ' + combinationOperator + ' is not supported');
  30307. }
  30308. }
  30309. currentS += symbolHeight - 1;
  30310. } else {
  30311. for (t2 = 0; t2 < symbolHeight; t2++) {
  30312. row = bitmap[offsetT + t2];
  30313. if (!row) {
  30314. continue;
  30315. }
  30316. symbolRow = symbolBitmap[t2];
  30317. switch (combinationOperator) {
  30318. case 0:
  30319. for (s2 = 0; s2 < symbolWidth; s2++) {
  30320. row[offsetS + s2] |= symbolRow[s2];
  30321. }
  30322. break;
  30323. case 2:
  30324. for (s2 = 0; s2 < symbolWidth; s2++) {
  30325. row[offsetS + s2] ^= symbolRow[s2];
  30326. }
  30327. break;
  30328. default:
  30329. throw new Jbig2Error('operator ' + combinationOperator + ' is not supported');
  30330. }
  30331. }
  30332. currentS += symbolWidth - 1;
  30333. }
  30334. i++;
  30335. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  30336. if (deltaS === null) {
  30337. break;
  30338. }
  30339. currentS += deltaS + dsOffset;
  30340. } while (true);
  30341. }
  30342. return bitmap;
  30343. }
  30344. function decodePatternDictionary(mmr, patternWidth, patternHeight, maxPatternIndex, template, decodingContext) {
  30345. var at = [];
  30346. at.push({
  30347. x: -patternWidth,
  30348. y: 0
  30349. });
  30350. if (template === 0) {
  30351. at.push({
  30352. x: -3,
  30353. y: -1
  30354. });
  30355. at.push({
  30356. x: 2,
  30357. y: -2
  30358. });
  30359. at.push({
  30360. x: -2,
  30361. y: -2
  30362. });
  30363. }
  30364. var collectiveWidth = (maxPatternIndex + 1) * patternWidth;
  30365. var collectiveBitmap = decodeBitmap(mmr, collectiveWidth, patternHeight, template, false, null, at, decodingContext);
  30366. var patterns = [],
  30367. i = 0,
  30368. patternBitmap = void 0,
  30369. xMin = void 0,
  30370. xMax = void 0,
  30371. y = void 0;
  30372. while (i <= maxPatternIndex) {
  30373. patternBitmap = [];
  30374. xMin = patternWidth * i;
  30375. xMax = xMin + patternWidth;
  30376. for (y = 0; y < patternHeight; y++) {
  30377. patternBitmap.push(collectiveBitmap[y].subarray(xMin, xMax));
  30378. }
  30379. patterns.push(patternBitmap);
  30380. i++;
  30381. }
  30382. return patterns;
  30383. }
  30384. function decodeHalftoneRegion(mmr, patterns, template, regionWidth, regionHeight, defaultPixelValue, enableSkip, combinationOperator, gridWidth, gridHeight, gridOffsetX, gridOffsetY, gridVectorX, gridVectorY, decodingContext) {
  30385. var skip = null;
  30386. if (enableSkip) {
  30387. throw new Jbig2Error('skip is not supported');
  30388. }
  30389. if (combinationOperator !== 0) {
  30390. throw new Jbig2Error('operator ' + combinationOperator + ' is not supported in halftone region');
  30391. }
  30392. var regionBitmap = [];
  30393. var i = void 0,
  30394. j = void 0,
  30395. row = void 0;
  30396. for (i = 0; i < regionHeight; i++) {
  30397. row = new Uint8Array(regionWidth);
  30398. if (defaultPixelValue) {
  30399. for (j = 0; j < regionWidth; j++) {
  30400. row[j] = defaultPixelValue;
  30401. }
  30402. }
  30403. regionBitmap.push(row);
  30404. }
  30405. var numberOfPatterns = patterns.length;
  30406. var pattern0 = patterns[0];
  30407. var patternWidth = pattern0[0].length,
  30408. patternHeight = pattern0.length;
  30409. var bitsPerValue = (0, _util.log2)(numberOfPatterns);
  30410. var at = [];
  30411. at.push({
  30412. x: template <= 1 ? 3 : 2,
  30413. y: -1
  30414. });
  30415. if (template === 0) {
  30416. at.push({
  30417. x: -3,
  30418. y: -1
  30419. });
  30420. at.push({
  30421. x: 2,
  30422. y: -2
  30423. });
  30424. at.push({
  30425. x: -2,
  30426. y: -2
  30427. });
  30428. }
  30429. var grayScaleBitPlanes = [];
  30430. for (i = bitsPerValue - 1; i >= 0; i--) {
  30431. grayScaleBitPlanes[i] = decodeBitmap(mmr, gridWidth, gridHeight, template, false, skip, at, decodingContext);
  30432. }
  30433. var mg = void 0,
  30434. ng = void 0,
  30435. bit = void 0,
  30436. patternIndex = void 0,
  30437. patternBitmap = void 0,
  30438. x = void 0,
  30439. y = void 0,
  30440. patternRow = void 0,
  30441. regionRow = void 0;
  30442. for (mg = 0; mg < gridHeight; mg++) {
  30443. for (ng = 0; ng < gridWidth; ng++) {
  30444. bit = 0;
  30445. patternIndex = 0;
  30446. for (j = bitsPerValue - 1; j >= 0; j--) {
  30447. bit = grayScaleBitPlanes[j][mg][ng] ^ bit;
  30448. patternIndex |= bit << j;
  30449. }
  30450. patternBitmap = patterns[patternIndex];
  30451. x = gridOffsetX + mg * gridVectorY + ng * gridVectorX >> 8;
  30452. y = gridOffsetY + mg * gridVectorX - ng * gridVectorY >> 8;
  30453. if (x >= 0 && x + patternWidth <= regionWidth && y >= 0 && y + patternHeight <= regionHeight) {
  30454. for (i = 0; i < patternHeight; i++) {
  30455. regionRow = regionBitmap[y + i];
  30456. patternRow = patternBitmap[i];
  30457. for (j = 0; j < patternWidth; j++) {
  30458. regionRow[x + j] |= patternRow[j];
  30459. }
  30460. }
  30461. } else {
  30462. var regionX = void 0,
  30463. regionY = void 0;
  30464. for (i = 0; i < patternHeight; i++) {
  30465. regionY = y + i;
  30466. if (regionY < 0 || regionY >= regionHeight) {
  30467. continue;
  30468. }
  30469. regionRow = regionBitmap[regionY];
  30470. patternRow = patternBitmap[i];
  30471. for (j = 0; j < patternWidth; j++) {
  30472. regionX = x + j;
  30473. if (regionX >= 0 && regionX < regionWidth) {
  30474. regionRow[regionX] |= patternRow[j];
  30475. }
  30476. }
  30477. }
  30478. }
  30479. }
  30480. }
  30481. return regionBitmap;
  30482. }
  30483. function readSegmentHeader(data, start) {
  30484. var segmentHeader = {};
  30485. segmentHeader.number = (0, _util.readUint32)(data, start);
  30486. var flags = data[start + 4];
  30487. var segmentType = flags & 0x3F;
  30488. if (!SegmentTypes[segmentType]) {
  30489. throw new Jbig2Error('invalid segment type: ' + segmentType);
  30490. }
  30491. segmentHeader.type = segmentType;
  30492. segmentHeader.typeName = SegmentTypes[segmentType];
  30493. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  30494. var pageAssociationFieldSize = !!(flags & 0x40);
  30495. var referredFlags = data[start + 5];
  30496. var referredToCount = referredFlags >> 5 & 7;
  30497. var retainBits = [referredFlags & 31];
  30498. var position = start + 6;
  30499. if (referredFlags === 7) {
  30500. referredToCount = (0, _util.readUint32)(data, position - 1) & 0x1FFFFFFF;
  30501. position += 3;
  30502. var bytes = referredToCount + 7 >> 3;
  30503. retainBits[0] = data[position++];
  30504. while (--bytes > 0) {
  30505. retainBits.push(data[position++]);
  30506. }
  30507. } else if (referredFlags === 5 || referredFlags === 6) {
  30508. throw new Jbig2Error('invalid referred-to flags');
  30509. }
  30510. segmentHeader.retainBits = retainBits;
  30511. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  30512. var referredTo = [];
  30513. var i, ii;
  30514. for (i = 0; i < referredToCount; i++) {
  30515. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? (0, _util.readUint16)(data, position) : (0, _util.readUint32)(data, position);
  30516. referredTo.push(number);
  30517. position += referredToSegmentNumberSize;
  30518. }
  30519. segmentHeader.referredTo = referredTo;
  30520. if (!pageAssociationFieldSize) {
  30521. segmentHeader.pageAssociation = data[position++];
  30522. } else {
  30523. segmentHeader.pageAssociation = (0, _util.readUint32)(data, position);
  30524. position += 4;
  30525. }
  30526. segmentHeader.length = (0, _util.readUint32)(data, position);
  30527. position += 4;
  30528. if (segmentHeader.length === 0xFFFFFFFF) {
  30529. if (segmentType === 38) {
  30530. var genericRegionInfo = readRegionSegmentInformation(data, position);
  30531. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  30532. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  30533. var searchPatternLength = 6;
  30534. var searchPattern = new Uint8Array(searchPatternLength);
  30535. if (!genericRegionMmr) {
  30536. searchPattern[0] = 0xFF;
  30537. searchPattern[1] = 0xAC;
  30538. }
  30539. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  30540. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  30541. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  30542. searchPattern[5] = genericRegionInfo.height & 0xFF;
  30543. for (i = position, ii = data.length; i < ii; i++) {
  30544. var j = 0;
  30545. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  30546. j++;
  30547. }
  30548. if (j === searchPatternLength) {
  30549. segmentHeader.length = i + searchPatternLength;
  30550. break;
  30551. }
  30552. }
  30553. if (segmentHeader.length === 0xFFFFFFFF) {
  30554. throw new Jbig2Error('segment end was not found');
  30555. }
  30556. } else {
  30557. throw new Jbig2Error('invalid unknown segment length');
  30558. }
  30559. }
  30560. segmentHeader.headerEnd = position;
  30561. return segmentHeader;
  30562. }
  30563. function readSegments(header, data, start, end) {
  30564. var segments = [];
  30565. var position = start;
  30566. while (position < end) {
  30567. var segmentHeader = readSegmentHeader(data, position);
  30568. position = segmentHeader.headerEnd;
  30569. var segment = {
  30570. header: segmentHeader,
  30571. data: data
  30572. };
  30573. if (!header.randomAccess) {
  30574. segment.start = position;
  30575. position += segmentHeader.length;
  30576. segment.end = position;
  30577. }
  30578. segments.push(segment);
  30579. if (segmentHeader.type === 51) {
  30580. break;
  30581. }
  30582. }
  30583. if (header.randomAccess) {
  30584. for (var i = 0, ii = segments.length; i < ii; i++) {
  30585. segments[i].start = position;
  30586. position += segments[i].header.length;
  30587. segments[i].end = position;
  30588. }
  30589. }
  30590. return segments;
  30591. }
  30592. function readRegionSegmentInformation(data, start) {
  30593. return {
  30594. width: (0, _util.readUint32)(data, start),
  30595. height: (0, _util.readUint32)(data, start + 4),
  30596. x: (0, _util.readUint32)(data, start + 8),
  30597. y: (0, _util.readUint32)(data, start + 12),
  30598. combinationOperator: data[start + 16] & 7
  30599. };
  30600. }
  30601. var RegionSegmentInformationFieldLength = 17;
  30602. function processSegment(segment, visitor) {
  30603. var header = segment.header;
  30604. var data = segment.data,
  30605. position = segment.start,
  30606. end = segment.end;
  30607. var args, at, i, atLength;
  30608. switch (header.type) {
  30609. case 0:
  30610. var dictionary = {};
  30611. var dictionaryFlags = (0, _util.readUint16)(data, position);
  30612. dictionary.huffman = !!(dictionaryFlags & 1);
  30613. dictionary.refinement = !!(dictionaryFlags & 2);
  30614. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  30615. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  30616. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  30617. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  30618. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  30619. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  30620. dictionary.template = dictionaryFlags >> 10 & 3;
  30621. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  30622. position += 2;
  30623. if (!dictionary.huffman) {
  30624. atLength = dictionary.template === 0 ? 4 : 1;
  30625. at = [];
  30626. for (i = 0; i < atLength; i++) {
  30627. at.push({
  30628. x: (0, _util.readInt8)(data, position),
  30629. y: (0, _util.readInt8)(data, position + 1)
  30630. });
  30631. position += 2;
  30632. }
  30633. dictionary.at = at;
  30634. }
  30635. if (dictionary.refinement && !dictionary.refinementTemplate) {
  30636. at = [];
  30637. for (i = 0; i < 2; i++) {
  30638. at.push({
  30639. x: (0, _util.readInt8)(data, position),
  30640. y: (0, _util.readInt8)(data, position + 1)
  30641. });
  30642. position += 2;
  30643. }
  30644. dictionary.refinementAt = at;
  30645. }
  30646. dictionary.numberOfExportedSymbols = (0, _util.readUint32)(data, position);
  30647. position += 4;
  30648. dictionary.numberOfNewSymbols = (0, _util.readUint32)(data, position);
  30649. position += 4;
  30650. args = [dictionary, header.number, header.referredTo, data, position, end];
  30651. break;
  30652. case 6:
  30653. case 7:
  30654. var textRegion = {};
  30655. textRegion.info = readRegionSegmentInformation(data, position);
  30656. position += RegionSegmentInformationFieldLength;
  30657. var textRegionSegmentFlags = (0, _util.readUint16)(data, position);
  30658. position += 2;
  30659. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  30660. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  30661. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  30662. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  30663. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  30664. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  30665. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  30666. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  30667. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  30668. if (textRegion.huffman) {
  30669. var textRegionHuffmanFlags = (0, _util.readUint16)(data, position);
  30670. position += 2;
  30671. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  30672. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  30673. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  30674. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  30675. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  30676. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  30677. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  30678. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  30679. }
  30680. if (textRegion.refinement && !textRegion.refinementTemplate) {
  30681. at = [];
  30682. for (i = 0; i < 2; i++) {
  30683. at.push({
  30684. x: (0, _util.readInt8)(data, position),
  30685. y: (0, _util.readInt8)(data, position + 1)
  30686. });
  30687. position += 2;
  30688. }
  30689. textRegion.refinementAt = at;
  30690. }
  30691. textRegion.numberOfSymbolInstances = (0, _util.readUint32)(data, position);
  30692. position += 4;
  30693. if (textRegion.huffman) {
  30694. throw new Jbig2Error('huffman is not supported');
  30695. }
  30696. args = [textRegion, header.referredTo, data, position, end];
  30697. break;
  30698. case 16:
  30699. var patternDictionary = {};
  30700. var patternDictionaryFlags = data[position++];
  30701. patternDictionary.mmr = !!(patternDictionaryFlags & 1);
  30702. patternDictionary.template = patternDictionaryFlags >> 1 & 3;
  30703. patternDictionary.patternWidth = data[position++];
  30704. patternDictionary.patternHeight = data[position++];
  30705. patternDictionary.maxPatternIndex = (0, _util.readUint32)(data, position);
  30706. position += 4;
  30707. args = [patternDictionary, header.number, data, position, end];
  30708. break;
  30709. case 22:
  30710. case 23:
  30711. var halftoneRegion = {};
  30712. halftoneRegion.info = readRegionSegmentInformation(data, position);
  30713. position += RegionSegmentInformationFieldLength;
  30714. var halftoneRegionFlags = data[position++];
  30715. halftoneRegion.mmr = !!(halftoneRegionFlags & 1);
  30716. halftoneRegion.template = halftoneRegionFlags >> 1 & 3;
  30717. halftoneRegion.enableSkip = !!(halftoneRegionFlags & 8);
  30718. halftoneRegion.combinationOperator = halftoneRegionFlags >> 4 & 7;
  30719. halftoneRegion.defaultPixelValue = halftoneRegionFlags >> 7 & 1;
  30720. halftoneRegion.gridWidth = (0, _util.readUint32)(data, position);
  30721. position += 4;
  30722. halftoneRegion.gridHeight = (0, _util.readUint32)(data, position);
  30723. position += 4;
  30724. halftoneRegion.gridOffsetX = (0, _util.readUint32)(data, position) & 0xFFFFFFFF;
  30725. position += 4;
  30726. halftoneRegion.gridOffsetY = (0, _util.readUint32)(data, position) & 0xFFFFFFFF;
  30727. position += 4;
  30728. halftoneRegion.gridVectorX = (0, _util.readUint16)(data, position);
  30729. position += 2;
  30730. halftoneRegion.gridVectorY = (0, _util.readUint16)(data, position);
  30731. position += 2;
  30732. args = [halftoneRegion, header.referredTo, data, position, end];
  30733. break;
  30734. case 38:
  30735. case 39:
  30736. var genericRegion = {};
  30737. genericRegion.info = readRegionSegmentInformation(data, position);
  30738. position += RegionSegmentInformationFieldLength;
  30739. var genericRegionSegmentFlags = data[position++];
  30740. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  30741. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  30742. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  30743. if (!genericRegion.mmr) {
  30744. atLength = genericRegion.template === 0 ? 4 : 1;
  30745. at = [];
  30746. for (i = 0; i < atLength; i++) {
  30747. at.push({
  30748. x: (0, _util.readInt8)(data, position),
  30749. y: (0, _util.readInt8)(data, position + 1)
  30750. });
  30751. position += 2;
  30752. }
  30753. genericRegion.at = at;
  30754. }
  30755. args = [genericRegion, data, position, end];
  30756. break;
  30757. case 48:
  30758. var pageInfo = {
  30759. width: (0, _util.readUint32)(data, position),
  30760. height: (0, _util.readUint32)(data, position + 4),
  30761. resolutionX: (0, _util.readUint32)(data, position + 8),
  30762. resolutionY: (0, _util.readUint32)(data, position + 12)
  30763. };
  30764. if (pageInfo.height === 0xFFFFFFFF) {
  30765. delete pageInfo.height;
  30766. }
  30767. var pageSegmentFlags = data[position + 16];
  30768. (0, _util.readUint16)(data, position + 17);
  30769. pageInfo.lossless = !!(pageSegmentFlags & 1);
  30770. pageInfo.refinement = !!(pageSegmentFlags & 2);
  30771. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  30772. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  30773. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  30774. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  30775. args = [pageInfo];
  30776. break;
  30777. case 49:
  30778. break;
  30779. case 50:
  30780. break;
  30781. case 51:
  30782. break;
  30783. case 62:
  30784. break;
  30785. default:
  30786. throw new Jbig2Error('segment type ' + header.typeName + '(' + header.type + ')' + ' is not implemented');
  30787. }
  30788. var callbackName = 'on' + header.typeName;
  30789. if (callbackName in visitor) {
  30790. visitor[callbackName].apply(visitor, args);
  30791. }
  30792. }
  30793. function processSegments(segments, visitor) {
  30794. for (var i = 0, ii = segments.length; i < ii; i++) {
  30795. processSegment(segments[i], visitor);
  30796. }
  30797. }
  30798. function parseJbig2(data, start, end) {
  30799. var position = start;
  30800. if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0D || data[position + 5] !== 0x0A || data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
  30801. throw new Jbig2Error('invalid header');
  30802. }
  30803. var header = {};
  30804. position += 8;
  30805. var flags = data[position++];
  30806. header.randomAccess = !(flags & 1);
  30807. if (!(flags & 2)) {
  30808. header.numberOfPages = (0, _util.readUint32)(data, position);
  30809. position += 4;
  30810. }
  30811. readSegments(header, data, position, end);
  30812. throw new Error('Not implemented');
  30813. }
  30814. function parseJbig2Chunks(chunks) {
  30815. var visitor = new SimpleSegmentVisitor();
  30816. for (var i = 0, ii = chunks.length; i < ii; i++) {
  30817. var chunk = chunks[i];
  30818. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  30819. processSegments(segments, visitor);
  30820. }
  30821. return visitor.buffer;
  30822. }
  30823. function SimpleSegmentVisitor() {}
  30824. SimpleSegmentVisitor.prototype = {
  30825. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  30826. this.currentPageInfo = info;
  30827. var rowSize = info.width + 7 >> 3;
  30828. var buffer = new Uint8ClampedArray(rowSize * info.height);
  30829. if (info.defaultPixelValue) {
  30830. for (var i = 0, ii = buffer.length; i < ii; i++) {
  30831. buffer[i] = 0xFF;
  30832. }
  30833. }
  30834. this.buffer = buffer;
  30835. },
  30836. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  30837. var pageInfo = this.currentPageInfo;
  30838. var width = regionInfo.width,
  30839. height = regionInfo.height;
  30840. var rowSize = pageInfo.width + 7 >> 3;
  30841. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  30842. var buffer = this.buffer;
  30843. var mask0 = 128 >> (regionInfo.x & 7);
  30844. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  30845. var i, j, mask, offset;
  30846. switch (combinationOperator) {
  30847. case 0:
  30848. for (i = 0; i < height; i++) {
  30849. mask = mask0;
  30850. offset = offset0;
  30851. for (j = 0; j < width; j++) {
  30852. if (bitmap[i][j]) {
  30853. buffer[offset] |= mask;
  30854. }
  30855. mask >>= 1;
  30856. if (!mask) {
  30857. mask = 128;
  30858. offset++;
  30859. }
  30860. }
  30861. offset0 += rowSize;
  30862. }
  30863. break;
  30864. case 2:
  30865. for (i = 0; i < height; i++) {
  30866. mask = mask0;
  30867. offset = offset0;
  30868. for (j = 0; j < width; j++) {
  30869. if (bitmap[i][j]) {
  30870. buffer[offset] ^= mask;
  30871. }
  30872. mask >>= 1;
  30873. if (!mask) {
  30874. mask = 128;
  30875. offset++;
  30876. }
  30877. }
  30878. offset0 += rowSize;
  30879. }
  30880. break;
  30881. default:
  30882. throw new Jbig2Error('operator ' + combinationOperator + ' is not supported');
  30883. }
  30884. },
  30885. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  30886. var regionInfo = region.info;
  30887. var decodingContext = new DecodingContext(data, start, end);
  30888. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  30889. this.drawBitmap(regionInfo, bitmap);
  30890. },
  30891. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  30892. this.onImmediateGenericRegion.apply(this, arguments);
  30893. },
  30894. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  30895. var huffmanTables;
  30896. if (dictionary.huffman) {
  30897. throw new Jbig2Error('huffman is not supported');
  30898. }
  30899. var symbols = this.symbols;
  30900. if (!symbols) {
  30901. this.symbols = symbols = {};
  30902. }
  30903. var inputSymbols = [];
  30904. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  30905. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  30906. }
  30907. var decodingContext = new DecodingContext(data, start, end);
  30908. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  30909. },
  30910. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  30911. var regionInfo = region.info;
  30912. var huffmanTables;
  30913. var symbols = this.symbols;
  30914. var inputSymbols = [];
  30915. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  30916. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  30917. }
  30918. var symbolCodeLength = (0, _util.log2)(inputSymbols.length);
  30919. var decodingContext = new DecodingContext(data, start, end);
  30920. 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);
  30921. this.drawBitmap(regionInfo, bitmap);
  30922. },
  30923. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  30924. this.onImmediateTextRegion.apply(this, arguments);
  30925. },
  30926. onPatternDictionary: function onPatternDictionary(dictionary, currentSegment, data, start, end) {
  30927. var patterns = this.patterns;
  30928. if (!patterns) {
  30929. this.patterns = patterns = {};
  30930. }
  30931. var decodingContext = new DecodingContext(data, start, end);
  30932. patterns[currentSegment] = decodePatternDictionary(dictionary.mmr, dictionary.patternWidth, dictionary.patternHeight, dictionary.maxPatternIndex, dictionary.template, decodingContext);
  30933. },
  30934. onImmediateHalftoneRegion: function onImmediateHalftoneRegion(region, referredSegments, data, start, end) {
  30935. var patterns = this.patterns[referredSegments[0]];
  30936. var regionInfo = region.info;
  30937. var decodingContext = new DecodingContext(data, start, end);
  30938. var bitmap = decodeHalftoneRegion(region.mmr, patterns, region.template, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.enableSkip, region.combinationOperator, region.gridWidth, region.gridHeight, region.gridOffsetX, region.gridOffsetY, region.gridVectorX, region.gridVectorY, decodingContext);
  30939. this.drawBitmap(regionInfo, bitmap);
  30940. },
  30941. onImmediateLosslessHalftoneRegion: function onImmediateLosslessHalftoneRegion() {
  30942. this.onImmediateHalftoneRegion.apply(this, arguments);
  30943. }
  30944. };
  30945. function Jbig2Image() {}
  30946. Jbig2Image.prototype = {
  30947. parseChunks: function Jbig2Image_parseChunks(chunks) {
  30948. return parseJbig2Chunks(chunks);
  30949. }
  30950. };
  30951. return Jbig2Image;
  30952. }();
  30953. exports.Jbig2Image = Jbig2Image;
  30954. /***/ }),
  30955. /* 129 */
  30956. /***/ (function(module, exports, __w_pdfjs_require__) {
  30957. "use strict";
  30958. Object.defineProperty(exports, "__esModule", {
  30959. value: true
  30960. });
  30961. exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = undefined;
  30962. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  30963. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  30964. var _util = __w_pdfjs_require__(0);
  30965. var _obj = __w_pdfjs_require__(62);
  30966. var _primitives = __w_pdfjs_require__(1);
  30967. var _colorspace = __w_pdfjs_require__(20);
  30968. var _operator_list = __w_pdfjs_require__(41);
  30969. var _stream = __w_pdfjs_require__(5);
  30970. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  30971. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  30972. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30973. var AnnotationFactory = function () {
  30974. function AnnotationFactory() {
  30975. _classCallCheck(this, AnnotationFactory);
  30976. }
  30977. _createClass(AnnotationFactory, null, [{
  30978. key: 'create',
  30979. value: function create(xref, ref, pdfManager, idFactory) {
  30980. var dict = xref.fetchIfRef(ref);
  30981. if (!(0, _primitives.isDict)(dict)) {
  30982. return;
  30983. }
  30984. var id = (0, _primitives.isRef)(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  30985. var subtype = dict.get('Subtype');
  30986. subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
  30987. var parameters = {
  30988. xref: xref,
  30989. dict: dict,
  30990. ref: (0, _primitives.isRef)(ref) ? ref : null,
  30991. subtype: subtype,
  30992. id: id,
  30993. pdfManager: pdfManager
  30994. };
  30995. switch (subtype) {
  30996. case 'Link':
  30997. return new LinkAnnotation(parameters);
  30998. case 'Text':
  30999. return new TextAnnotation(parameters);
  31000. case 'Widget':
  31001. var fieldType = _util.Util.getInheritableProperty(dict, 'FT');
  31002. fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
  31003. switch (fieldType) {
  31004. case 'Tx':
  31005. return new TextWidgetAnnotation(parameters);
  31006. case 'Btn':
  31007. return new ButtonWidgetAnnotation(parameters);
  31008. case 'Ch':
  31009. return new ChoiceWidgetAnnotation(parameters);
  31010. }
  31011. (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  31012. return new WidgetAnnotation(parameters);
  31013. case 'Popup':
  31014. return new PopupAnnotation(parameters);
  31015. case 'Line':
  31016. return new LineAnnotation(parameters);
  31017. case 'Square':
  31018. return new SquareAnnotation(parameters);
  31019. case 'Circle':
  31020. return new CircleAnnotation(parameters);
  31021. case 'PolyLine':
  31022. return new PolylineAnnotation(parameters);
  31023. case 'Polygon':
  31024. return new PolygonAnnotation(parameters);
  31025. case 'Highlight':
  31026. return new HighlightAnnotation(parameters);
  31027. case 'Underline':
  31028. return new UnderlineAnnotation(parameters);
  31029. case 'Squiggly':
  31030. return new SquigglyAnnotation(parameters);
  31031. case 'StrikeOut':
  31032. return new StrikeOutAnnotation(parameters);
  31033. case 'Stamp':
  31034. return new StampAnnotation(parameters);
  31035. case 'FileAttachment':
  31036. return new FileAttachmentAnnotation(parameters);
  31037. default:
  31038. if (!subtype) {
  31039. (0, _util.warn)('Annotation is missing the required /Subtype.');
  31040. } else {
  31041. (0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  31042. }
  31043. return new Annotation(parameters);
  31044. }
  31045. }
  31046. }]);
  31047. return AnnotationFactory;
  31048. }();
  31049. function getTransformMatrix(rect, bbox, matrix) {
  31050. var bounds = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
  31051. var minX = bounds[0];
  31052. var minY = bounds[1];
  31053. var maxX = bounds[2];
  31054. var maxY = bounds[3];
  31055. if (minX === maxX || minY === maxY) {
  31056. return [1, 0, 0, 1, rect[0], rect[1]];
  31057. }
  31058. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  31059. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  31060. return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
  31061. }
  31062. var Annotation = function () {
  31063. function Annotation(params) {
  31064. _classCallCheck(this, Annotation);
  31065. var dict = params.dict;
  31066. this.setFlags(dict.get('F'));
  31067. this.setRectangle(dict.getArray('Rect'));
  31068. this.setColor(dict.getArray('C'));
  31069. this.setBorderStyle(dict);
  31070. this.setAppearance(dict);
  31071. this.data = {
  31072. annotationFlags: this.flags,
  31073. borderStyle: this.borderStyle,
  31074. color: this.color,
  31075. hasAppearance: !!this.appearance,
  31076. id: params.id,
  31077. rect: this.rectangle,
  31078. subtype: params.subtype
  31079. };
  31080. }
  31081. _createClass(Annotation, [{
  31082. key: '_hasFlag',
  31083. value: function _hasFlag(flags, flag) {
  31084. return !!(flags & flag);
  31085. }
  31086. }, {
  31087. key: '_isViewable',
  31088. value: function _isViewable(flags) {
  31089. return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
  31090. }
  31091. }, {
  31092. key: '_isPrintable',
  31093. value: function _isPrintable(flags) {
  31094. return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN);
  31095. }
  31096. }, {
  31097. key: 'setFlags',
  31098. value: function setFlags(flags) {
  31099. this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
  31100. }
  31101. }, {
  31102. key: 'hasFlag',
  31103. value: function hasFlag(flag) {
  31104. return this._hasFlag(this.flags, flag);
  31105. }
  31106. }, {
  31107. key: 'setRectangle',
  31108. value: function setRectangle(rectangle) {
  31109. if (Array.isArray(rectangle) && rectangle.length === 4) {
  31110. this.rectangle = _util.Util.normalizeRect(rectangle);
  31111. } else {
  31112. this.rectangle = [0, 0, 0, 0];
  31113. }
  31114. }
  31115. }, {
  31116. key: 'setColor',
  31117. value: function setColor(color) {
  31118. var rgbColor = new Uint8Array(3);
  31119. if (!Array.isArray(color)) {
  31120. this.color = rgbColor;
  31121. return;
  31122. }
  31123. switch (color.length) {
  31124. case 0:
  31125. this.color = null;
  31126. break;
  31127. case 1:
  31128. _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  31129. this.color = rgbColor;
  31130. break;
  31131. case 3:
  31132. _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  31133. this.color = rgbColor;
  31134. break;
  31135. case 4:
  31136. _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  31137. this.color = rgbColor;
  31138. break;
  31139. default:
  31140. this.color = rgbColor;
  31141. break;
  31142. }
  31143. }
  31144. }, {
  31145. key: 'setBorderStyle',
  31146. value: function setBorderStyle(borderStyle) {
  31147. this.borderStyle = new AnnotationBorderStyle();
  31148. if (!(0, _primitives.isDict)(borderStyle)) {
  31149. return;
  31150. }
  31151. if (borderStyle.has('BS')) {
  31152. var dict = borderStyle.get('BS');
  31153. var dictType = dict.get('Type');
  31154. if (!dictType || (0, _primitives.isName)(dictType, 'Border')) {
  31155. this.borderStyle.setWidth(dict.get('W'));
  31156. this.borderStyle.setStyle(dict.get('S'));
  31157. this.borderStyle.setDashArray(dict.getArray('D'));
  31158. }
  31159. } else if (borderStyle.has('Border')) {
  31160. var array = borderStyle.getArray('Border');
  31161. if (Array.isArray(array) && array.length >= 3) {
  31162. this.borderStyle.setHorizontalCornerRadius(array[0]);
  31163. this.borderStyle.setVerticalCornerRadius(array[1]);
  31164. this.borderStyle.setWidth(array[2]);
  31165. if (array.length === 4) {
  31166. this.borderStyle.setDashArray(array[3]);
  31167. }
  31168. }
  31169. } else {
  31170. this.borderStyle.setWidth(0);
  31171. }
  31172. }
  31173. }, {
  31174. key: 'setAppearance',
  31175. value: function setAppearance(dict) {
  31176. this.appearance = null;
  31177. var appearanceStates = dict.get('AP');
  31178. if (!(0, _primitives.isDict)(appearanceStates)) {
  31179. return;
  31180. }
  31181. var normalAppearanceState = appearanceStates.get('N');
  31182. if ((0, _primitives.isStream)(normalAppearanceState)) {
  31183. this.appearance = normalAppearanceState;
  31184. return;
  31185. }
  31186. if (!(0, _primitives.isDict)(normalAppearanceState)) {
  31187. return;
  31188. }
  31189. var as = dict.get('AS');
  31190. if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
  31191. return;
  31192. }
  31193. this.appearance = normalAppearanceState.get(as.name);
  31194. }
  31195. }, {
  31196. key: '_preparePopup',
  31197. value: function _preparePopup(dict) {
  31198. if (!dict.has('C')) {
  31199. this.data.color = null;
  31200. }
  31201. this.data.hasPopup = dict.has('Popup');
  31202. this.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
  31203. this.data.contents = (0, _util.stringToPDFString)(dict.get('Contents') || '');
  31204. }
  31205. }, {
  31206. key: 'loadResources',
  31207. value: function loadResources(keys) {
  31208. return this.appearance.dict.getAsync('Resources').then(function (resources) {
  31209. if (!resources) {
  31210. return;
  31211. }
  31212. var objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
  31213. return objectLoader.load().then(function () {
  31214. return resources;
  31215. });
  31216. });
  31217. }
  31218. }, {
  31219. key: 'getOperatorList',
  31220. value: function getOperatorList(evaluator, task, renderForms) {
  31221. var _this = this;
  31222. if (!this.appearance) {
  31223. return Promise.resolve(new _operator_list.OperatorList());
  31224. }
  31225. var data = this.data;
  31226. var appearanceDict = this.appearance.dict;
  31227. var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
  31228. var bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
  31229. var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
  31230. var transform = getTransformMatrix(data.rect, bbox, matrix);
  31231. return resourcesPromise.then(function (resources) {
  31232. var opList = new _operator_list.OperatorList();
  31233. opList.addOp(_util.OPS.beginAnnotation, [data.rect, transform, matrix]);
  31234. return evaluator.getOperatorList({
  31235. stream: _this.appearance,
  31236. task: task,
  31237. resources: resources,
  31238. operatorList: opList
  31239. }).then(function () {
  31240. opList.addOp(_util.OPS.endAnnotation, []);
  31241. _this.appearance.reset();
  31242. return opList;
  31243. });
  31244. });
  31245. }
  31246. }, {
  31247. key: 'viewable',
  31248. get: function get() {
  31249. if (this.flags === 0) {
  31250. return true;
  31251. }
  31252. return this._isViewable(this.flags);
  31253. }
  31254. }, {
  31255. key: 'printable',
  31256. get: function get() {
  31257. if (this.flags === 0) {
  31258. return false;
  31259. }
  31260. return this._isPrintable(this.flags);
  31261. }
  31262. }]);
  31263. return Annotation;
  31264. }();
  31265. var AnnotationBorderStyle = function () {
  31266. function AnnotationBorderStyle() {
  31267. _classCallCheck(this, AnnotationBorderStyle);
  31268. this.width = 1;
  31269. this.style = _util.AnnotationBorderStyleType.SOLID;
  31270. this.dashArray = [3];
  31271. this.horizontalCornerRadius = 0;
  31272. this.verticalCornerRadius = 0;
  31273. }
  31274. _createClass(AnnotationBorderStyle, [{
  31275. key: 'setWidth',
  31276. value: function setWidth(width) {
  31277. if (Number.isInteger(width)) {
  31278. this.width = width;
  31279. }
  31280. }
  31281. }, {
  31282. key: 'setStyle',
  31283. value: function setStyle(style) {
  31284. if (!style) {
  31285. return;
  31286. }
  31287. switch (style.name) {
  31288. case 'S':
  31289. this.style = _util.AnnotationBorderStyleType.SOLID;
  31290. break;
  31291. case 'D':
  31292. this.style = _util.AnnotationBorderStyleType.DASHED;
  31293. break;
  31294. case 'B':
  31295. this.style = _util.AnnotationBorderStyleType.BEVELED;
  31296. break;
  31297. case 'I':
  31298. this.style = _util.AnnotationBorderStyleType.INSET;
  31299. break;
  31300. case 'U':
  31301. this.style = _util.AnnotationBorderStyleType.UNDERLINE;
  31302. break;
  31303. default:
  31304. break;
  31305. }
  31306. }
  31307. }, {
  31308. key: 'setDashArray',
  31309. value: function setDashArray(dashArray) {
  31310. if (Array.isArray(dashArray) && dashArray.length > 0) {
  31311. var isValid = true;
  31312. var allZeros = true;
  31313. for (var i = 0, len = dashArray.length; i < len; i++) {
  31314. var element = dashArray[i];
  31315. var validNumber = +element >= 0;
  31316. if (!validNumber) {
  31317. isValid = false;
  31318. break;
  31319. } else if (element > 0) {
  31320. allZeros = false;
  31321. }
  31322. }
  31323. if (isValid && !allZeros) {
  31324. this.dashArray = dashArray;
  31325. } else {
  31326. this.width = 0;
  31327. }
  31328. } else if (dashArray) {
  31329. this.width = 0;
  31330. }
  31331. }
  31332. }, {
  31333. key: 'setHorizontalCornerRadius',
  31334. value: function setHorizontalCornerRadius(radius) {
  31335. if (Number.isInteger(radius)) {
  31336. this.horizontalCornerRadius = radius;
  31337. }
  31338. }
  31339. }, {
  31340. key: 'setVerticalCornerRadius',
  31341. value: function setVerticalCornerRadius(radius) {
  31342. if (Number.isInteger(radius)) {
  31343. this.verticalCornerRadius = radius;
  31344. }
  31345. }
  31346. }]);
  31347. return AnnotationBorderStyle;
  31348. }();
  31349. var WidgetAnnotation = function (_Annotation) {
  31350. _inherits(WidgetAnnotation, _Annotation);
  31351. function WidgetAnnotation(params) {
  31352. _classCallCheck(this, WidgetAnnotation);
  31353. var _this2 = _possibleConstructorReturn(this, (WidgetAnnotation.__proto__ || Object.getPrototypeOf(WidgetAnnotation)).call(this, params));
  31354. var dict = params.dict;
  31355. var data = _this2.data;
  31356. data.annotationType = _util.AnnotationType.WIDGET;
  31357. data.fieldName = _this2._constructFieldName(dict);
  31358. data.fieldValue = _util.Util.getInheritableProperty(dict, 'V', true);
  31359. data.alternativeText = (0, _util.stringToPDFString)(dict.get('TU') || '');
  31360. data.defaultAppearance = _util.Util.getInheritableProperty(dict, 'DA') || '';
  31361. var fieldType = _util.Util.getInheritableProperty(dict, 'FT');
  31362. data.fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
  31363. _this2.fieldResources = _util.Util.getInheritableProperty(dict, 'DR') || _primitives.Dict.empty;
  31364. data.fieldFlags = _util.Util.getInheritableProperty(dict, 'Ff');
  31365. if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
  31366. data.fieldFlags = 0;
  31367. }
  31368. data.readOnly = _this2.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
  31369. if (data.fieldType === 'Sig') {
  31370. //_this2.setFlags(_util.AnnotationFlag.HIDDEN);
  31371. }
  31372. return _this2;
  31373. }
  31374. _createClass(WidgetAnnotation, [{
  31375. key: '_constructFieldName',
  31376. value: function _constructFieldName(dict) {
  31377. if (!dict.has('T') && !dict.has('Parent')) {
  31378. (0, _util.warn)('Unknown field name, falling back to empty field name.');
  31379. return '';
  31380. }
  31381. if (!dict.has('Parent')) {
  31382. return (0, _util.stringToPDFString)(dict.get('T'));
  31383. }
  31384. var fieldName = [];
  31385. if (dict.has('T')) {
  31386. fieldName.unshift((0, _util.stringToPDFString)(dict.get('T')));
  31387. }
  31388. var loopDict = dict;
  31389. while (loopDict.has('Parent')) {
  31390. loopDict = loopDict.get('Parent');
  31391. if (!(0, _primitives.isDict)(loopDict)) {
  31392. break;
  31393. }
  31394. if (loopDict.has('T')) {
  31395. fieldName.unshift((0, _util.stringToPDFString)(loopDict.get('T')));
  31396. }
  31397. }
  31398. return fieldName.join('.');
  31399. }
  31400. }, {
  31401. key: 'hasFieldFlag',
  31402. value: function hasFieldFlag(flag) {
  31403. return !!(this.data.fieldFlags & flag);
  31404. }
  31405. }, {
  31406. key: 'getOperatorList',
  31407. value: function getOperatorList(evaluator, task, renderForms) {
  31408. if (renderForms) {
  31409. return Promise.resolve(new _operator_list.OperatorList());
  31410. }
  31411. return _get(WidgetAnnotation.prototype.__proto__ || Object.getPrototypeOf(WidgetAnnotation.prototype), 'getOperatorList', this).call(this, evaluator, task, renderForms);
  31412. }
  31413. }]);
  31414. return WidgetAnnotation;
  31415. }(Annotation);
  31416. var TextWidgetAnnotation = function (_WidgetAnnotation) {
  31417. _inherits(TextWidgetAnnotation, _WidgetAnnotation);
  31418. function TextWidgetAnnotation(params) {
  31419. _classCallCheck(this, TextWidgetAnnotation);
  31420. var _this3 = _possibleConstructorReturn(this, (TextWidgetAnnotation.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation)).call(this, params));
  31421. _this3.data.fieldValue = (0, _util.stringToPDFString)(_this3.data.fieldValue || '');
  31422. var alignment = _util.Util.getInheritableProperty(params.dict, 'Q');
  31423. if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
  31424. alignment = null;
  31425. }
  31426. _this3.data.textAlignment = alignment;
  31427. var maximumLength = _util.Util.getInheritableProperty(params.dict, 'MaxLen');
  31428. if (!Number.isInteger(maximumLength) || maximumLength < 0) {
  31429. maximumLength = null;
  31430. }
  31431. _this3.data.maxLen = maximumLength;
  31432. _this3.data.multiLine = _this3.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
  31433. _this3.data.comb = _this3.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !_this3.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !_this3.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !_this3.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && _this3.data.maxLen !== null;
  31434. return _this3;
  31435. }
  31436. _createClass(TextWidgetAnnotation, [{
  31437. key: 'getOperatorList',
  31438. value: function getOperatorList(evaluator, task, renderForms) {
  31439. if (renderForms || this.appearance) {
  31440. return _get(TextWidgetAnnotation.prototype.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation.prototype), 'getOperatorList', this).call(this, evaluator, task, renderForms);
  31441. }
  31442. var operatorList = new _operator_list.OperatorList();
  31443. if (!this.data.defaultAppearance) {
  31444. return Promise.resolve(operatorList);
  31445. }
  31446. var stream = new _stream.Stream((0, _util.stringToBytes)(this.data.defaultAppearance));
  31447. return evaluator.getOperatorList({
  31448. stream: stream,
  31449. task: task,
  31450. resources: this.fieldResources,
  31451. operatorList: operatorList
  31452. }).then(function () {
  31453. return operatorList;
  31454. });
  31455. }
  31456. }]);
  31457. return TextWidgetAnnotation;
  31458. }(WidgetAnnotation);
  31459. var ButtonWidgetAnnotation = function (_WidgetAnnotation2) {
  31460. _inherits(ButtonWidgetAnnotation, _WidgetAnnotation2);
  31461. function ButtonWidgetAnnotation(params) {
  31462. _classCallCheck(this, ButtonWidgetAnnotation);
  31463. var _this4 = _possibleConstructorReturn(this, (ButtonWidgetAnnotation.__proto__ || Object.getPrototypeOf(ButtonWidgetAnnotation)).call(this, params));
  31464. _this4.data.checkBox = !_this4.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !_this4.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  31465. if (_this4.data.checkBox) {
  31466. if (!(0, _primitives.isName)(_this4.data.fieldValue)) {
  31467. return _possibleConstructorReturn(_this4);
  31468. }
  31469. _this4.data.fieldValue = _this4.data.fieldValue.name;
  31470. }
  31471. _this4.data.radioButton = _this4.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !_this4.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
  31472. if (_this4.data.radioButton) {
  31473. _this4.data.fieldValue = _this4.data.buttonValue = null;
  31474. var fieldParent = params.dict.get('Parent');
  31475. if ((0, _primitives.isDict)(fieldParent) && fieldParent.has('V')) {
  31476. var fieldParentValue = fieldParent.get('V');
  31477. if ((0, _primitives.isName)(fieldParentValue)) {
  31478. _this4.data.fieldValue = fieldParentValue.name;
  31479. }
  31480. }
  31481. var appearanceStates = params.dict.get('AP');
  31482. if (!(0, _primitives.isDict)(appearanceStates)) {
  31483. return _possibleConstructorReturn(_this4);
  31484. }
  31485. var normalAppearanceState = appearanceStates.get('N');
  31486. if (!(0, _primitives.isDict)(normalAppearanceState)) {
  31487. return _possibleConstructorReturn(_this4);
  31488. }
  31489. var keys = normalAppearanceState.getKeys();
  31490. for (var i = 0, ii = keys.length; i < ii; i++) {
  31491. if (keys[i] !== 'Off') {
  31492. _this4.data.buttonValue = keys[i];
  31493. break;
  31494. }
  31495. }
  31496. }
  31497. return _this4;
  31498. }
  31499. return ButtonWidgetAnnotation;
  31500. }(WidgetAnnotation);
  31501. var ChoiceWidgetAnnotation = function (_WidgetAnnotation3) {
  31502. _inherits(ChoiceWidgetAnnotation, _WidgetAnnotation3);
  31503. function ChoiceWidgetAnnotation(params) {
  31504. _classCallCheck(this, ChoiceWidgetAnnotation);
  31505. var _this5 = _possibleConstructorReturn(this, (ChoiceWidgetAnnotation.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotation)).call(this, params));
  31506. _this5.data.options = [];
  31507. var options = _util.Util.getInheritableProperty(params.dict, 'Opt');
  31508. if (Array.isArray(options)) {
  31509. var xref = params.xref;
  31510. for (var i = 0, ii = options.length; i < ii; i++) {
  31511. var option = xref.fetchIfRef(options[i]);
  31512. var isOptionArray = Array.isArray(option);
  31513. _this5.data.options[i] = {
  31514. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  31515. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  31516. };
  31517. }
  31518. }
  31519. if (!Array.isArray(_this5.data.fieldValue)) {
  31520. _this5.data.fieldValue = [_this5.data.fieldValue];
  31521. }
  31522. _this5.data.combo = _this5.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
  31523. _this5.data.multiSelect = _this5.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
  31524. return _this5;
  31525. }
  31526. return ChoiceWidgetAnnotation;
  31527. }(WidgetAnnotation);
  31528. var TextAnnotation = function (_Annotation2) {
  31529. _inherits(TextAnnotation, _Annotation2);
  31530. function TextAnnotation(parameters) {
  31531. _classCallCheck(this, TextAnnotation);
  31532. var DEFAULT_ICON_SIZE = 22;
  31533. var _this6 = _possibleConstructorReturn(this, (TextAnnotation.__proto__ || Object.getPrototypeOf(TextAnnotation)).call(this, parameters));
  31534. _this6.data.annotationType = _util.AnnotationType.TEXT;
  31535. if (_this6.data.hasAppearance) {
  31536. _this6.data.name = 'NoIcon';
  31537. } else {
  31538. _this6.data.rect[1] = _this6.data.rect[3] - DEFAULT_ICON_SIZE;
  31539. _this6.data.rect[2] = _this6.data.rect[0] + DEFAULT_ICON_SIZE;
  31540. _this6.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  31541. }
  31542. _this6._preparePopup(parameters.dict);
  31543. return _this6;
  31544. }
  31545. return TextAnnotation;
  31546. }(Annotation);
  31547. var LinkAnnotation = function (_Annotation3) {
  31548. _inherits(LinkAnnotation, _Annotation3);
  31549. function LinkAnnotation(params) {
  31550. _classCallCheck(this, LinkAnnotation);
  31551. var _this7 = _possibleConstructorReturn(this, (LinkAnnotation.__proto__ || Object.getPrototypeOf(LinkAnnotation)).call(this, params));
  31552. _this7.data.annotationType = _util.AnnotationType.LINK;
  31553. _obj.Catalog.parseDestDictionary({
  31554. destDict: params.dict,
  31555. resultObj: _this7.data,
  31556. docBaseUrl: params.pdfManager.docBaseUrl
  31557. });
  31558. return _this7;
  31559. }
  31560. return LinkAnnotation;
  31561. }(Annotation);
  31562. var PopupAnnotation = function (_Annotation4) {
  31563. _inherits(PopupAnnotation, _Annotation4);
  31564. function PopupAnnotation(parameters) {
  31565. _classCallCheck(this, PopupAnnotation);
  31566. var _this8 = _possibleConstructorReturn(this, (PopupAnnotation.__proto__ || Object.getPrototypeOf(PopupAnnotation)).call(this, parameters));
  31567. _this8.data.annotationType = _util.AnnotationType.POPUP;
  31568. var dict = parameters.dict;
  31569. var parentItem = dict.get('Parent');
  31570. if (!parentItem) {
  31571. (0, _util.warn)('Popup annotation has a missing or invalid parent annotation.');
  31572. return _possibleConstructorReturn(_this8);
  31573. }
  31574. var parentSubtype = parentItem.get('Subtype');
  31575. _this8.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
  31576. _this8.data.parentId = dict.getRaw('Parent').toString();
  31577. _this8.data.title = (0, _util.stringToPDFString)(parentItem.get('T') || '');
  31578. _this8.data.contents = (0, _util.stringToPDFString)(parentItem.get('Contents') || '');
  31579. if (!parentItem.has('C')) {
  31580. _this8.data.color = null;
  31581. } else {
  31582. _this8.setColor(parentItem.getArray('C'));
  31583. _this8.data.color = _this8.color;
  31584. }
  31585. if (!_this8.viewable) {
  31586. var parentFlags = parentItem.get('F');
  31587. if (_this8._isViewable(parentFlags)) {
  31588. _this8.setFlags(parentFlags);
  31589. }
  31590. }
  31591. return _this8;
  31592. }
  31593. return PopupAnnotation;
  31594. }(Annotation);
  31595. var LineAnnotation = function (_Annotation5) {
  31596. _inherits(LineAnnotation, _Annotation5);
  31597. function LineAnnotation(parameters) {
  31598. _classCallCheck(this, LineAnnotation);
  31599. var _this9 = _possibleConstructorReturn(this, (LineAnnotation.__proto__ || Object.getPrototypeOf(LineAnnotation)).call(this, parameters));
  31600. _this9.data.annotationType = _util.AnnotationType.LINE;
  31601. var dict = parameters.dict;
  31602. _this9.data.lineCoordinates = _util.Util.normalizeRect(dict.getArray('L'));
  31603. _this9._preparePopup(dict);
  31604. return _this9;
  31605. }
  31606. return LineAnnotation;
  31607. }(Annotation);
  31608. var SquareAnnotation = function (_Annotation6) {
  31609. _inherits(SquareAnnotation, _Annotation6);
  31610. function SquareAnnotation(parameters) {
  31611. _classCallCheck(this, SquareAnnotation);
  31612. var _this10 = _possibleConstructorReturn(this, (SquareAnnotation.__proto__ || Object.getPrototypeOf(SquareAnnotation)).call(this, parameters));
  31613. _this10.data.annotationType = _util.AnnotationType.SQUARE;
  31614. _this10._preparePopup(parameters.dict);
  31615. return _this10;
  31616. }
  31617. return SquareAnnotation;
  31618. }(Annotation);
  31619. var CircleAnnotation = function (_Annotation7) {
  31620. _inherits(CircleAnnotation, _Annotation7);
  31621. function CircleAnnotation(parameters) {
  31622. _classCallCheck(this, CircleAnnotation);
  31623. var _this11 = _possibleConstructorReturn(this, (CircleAnnotation.__proto__ || Object.getPrototypeOf(CircleAnnotation)).call(this, parameters));
  31624. _this11.data.annotationType = _util.AnnotationType.CIRCLE;
  31625. _this11._preparePopup(parameters.dict);
  31626. return _this11;
  31627. }
  31628. return CircleAnnotation;
  31629. }(Annotation);
  31630. var PolylineAnnotation = function (_Annotation8) {
  31631. _inherits(PolylineAnnotation, _Annotation8);
  31632. function PolylineAnnotation(parameters) {
  31633. _classCallCheck(this, PolylineAnnotation);
  31634. var _this12 = _possibleConstructorReturn(this, (PolylineAnnotation.__proto__ || Object.getPrototypeOf(PolylineAnnotation)).call(this, parameters));
  31635. _this12.data.annotationType = _util.AnnotationType.POLYLINE;
  31636. var dict = parameters.dict;
  31637. var rawVertices = dict.getArray('Vertices');
  31638. _this12.data.vertices = [];
  31639. for (var i = 0, ii = rawVertices.length; i < ii; i += 2) {
  31640. _this12.data.vertices.push({
  31641. x: rawVertices[i],
  31642. y: rawVertices[i + 1]
  31643. });
  31644. }
  31645. _this12._preparePopup(dict);
  31646. return _this12;
  31647. }
  31648. return PolylineAnnotation;
  31649. }(Annotation);
  31650. var PolygonAnnotation = function (_PolylineAnnotation) {
  31651. _inherits(PolygonAnnotation, _PolylineAnnotation);
  31652. function PolygonAnnotation(parameters) {
  31653. _classCallCheck(this, PolygonAnnotation);
  31654. var _this13 = _possibleConstructorReturn(this, (PolygonAnnotation.__proto__ || Object.getPrototypeOf(PolygonAnnotation)).call(this, parameters));
  31655. _this13.data.annotationType = _util.AnnotationType.POLYGON;
  31656. return _this13;
  31657. }
  31658. return PolygonAnnotation;
  31659. }(PolylineAnnotation);
  31660. var HighlightAnnotation = function (_Annotation9) {
  31661. _inherits(HighlightAnnotation, _Annotation9);
  31662. function HighlightAnnotation(parameters) {
  31663. _classCallCheck(this, HighlightAnnotation);
  31664. var _this14 = _possibleConstructorReturn(this, (HighlightAnnotation.__proto__ || Object.getPrototypeOf(HighlightAnnotation)).call(this, parameters));
  31665. _this14.data.annotationType = _util.AnnotationType.HIGHLIGHT;
  31666. _this14._preparePopup(parameters.dict);
  31667. return _this14;
  31668. }
  31669. return HighlightAnnotation;
  31670. }(Annotation);
  31671. var UnderlineAnnotation = function (_Annotation10) {
  31672. _inherits(UnderlineAnnotation, _Annotation10);
  31673. function UnderlineAnnotation(parameters) {
  31674. _classCallCheck(this, UnderlineAnnotation);
  31675. var _this15 = _possibleConstructorReturn(this, (UnderlineAnnotation.__proto__ || Object.getPrototypeOf(UnderlineAnnotation)).call(this, parameters));
  31676. _this15.data.annotationType = _util.AnnotationType.UNDERLINE;
  31677. _this15._preparePopup(parameters.dict);
  31678. return _this15;
  31679. }
  31680. return UnderlineAnnotation;
  31681. }(Annotation);
  31682. var SquigglyAnnotation = function (_Annotation11) {
  31683. _inherits(SquigglyAnnotation, _Annotation11);
  31684. function SquigglyAnnotation(parameters) {
  31685. _classCallCheck(this, SquigglyAnnotation);
  31686. var _this16 = _possibleConstructorReturn(this, (SquigglyAnnotation.__proto__ || Object.getPrototypeOf(SquigglyAnnotation)).call(this, parameters));
  31687. _this16.data.annotationType = _util.AnnotationType.SQUIGGLY;
  31688. _this16._preparePopup(parameters.dict);
  31689. return _this16;
  31690. }
  31691. return SquigglyAnnotation;
  31692. }(Annotation);
  31693. var StrikeOutAnnotation = function (_Annotation12) {
  31694. _inherits(StrikeOutAnnotation, _Annotation12);
  31695. function StrikeOutAnnotation(parameters) {
  31696. _classCallCheck(this, StrikeOutAnnotation);
  31697. var _this17 = _possibleConstructorReturn(this, (StrikeOutAnnotation.__proto__ || Object.getPrototypeOf(StrikeOutAnnotation)).call(this, parameters));
  31698. _this17.data.annotationType = _util.AnnotationType.STRIKEOUT;
  31699. _this17._preparePopup(parameters.dict);
  31700. return _this17;
  31701. }
  31702. return StrikeOutAnnotation;
  31703. }(Annotation);
  31704. var StampAnnotation = function (_Annotation13) {
  31705. _inherits(StampAnnotation, _Annotation13);
  31706. function StampAnnotation(parameters) {
  31707. _classCallCheck(this, StampAnnotation);
  31708. var _this18 = _possibleConstructorReturn(this, (StampAnnotation.__proto__ || Object.getPrototypeOf(StampAnnotation)).call(this, parameters));
  31709. _this18.data.annotationType = _util.AnnotationType.STAMP;
  31710. _this18._preparePopup(parameters.dict);
  31711. return _this18;
  31712. }
  31713. return StampAnnotation;
  31714. }(Annotation);
  31715. var FileAttachmentAnnotation = function (_Annotation14) {
  31716. _inherits(FileAttachmentAnnotation, _Annotation14);
  31717. function FileAttachmentAnnotation(parameters) {
  31718. _classCallCheck(this, FileAttachmentAnnotation);
  31719. var _this19 = _possibleConstructorReturn(this, (FileAttachmentAnnotation.__proto__ || Object.getPrototypeOf(FileAttachmentAnnotation)).call(this, parameters));
  31720. var file = new _obj.FileSpec(parameters.dict.get('FS'), parameters.xref);
  31721. _this19.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
  31722. _this19.data.file = file.serializable;
  31723. _this19._preparePopup(parameters.dict);
  31724. return _this19;
  31725. }
  31726. return FileAttachmentAnnotation;
  31727. }(Annotation);
  31728. exports.Annotation = Annotation;
  31729. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  31730. exports.AnnotationFactory = AnnotationFactory;
  31731. /***/ }),
  31732. /* 130 */
  31733. /***/ (function(module, exports, __w_pdfjs_require__) {
  31734. "use strict";
  31735. Object.defineProperty(exports, "__esModule", {
  31736. value: true
  31737. });
  31738. exports.PartialEvaluator = undefined;
  31739. var _util = __w_pdfjs_require__(0);
  31740. var _cmap = __w_pdfjs_require__(131);
  31741. var _stream = __w_pdfjs_require__(5);
  31742. var _primitives = __w_pdfjs_require__(1);
  31743. var _fonts = __w_pdfjs_require__(132);
  31744. var _encodings = __w_pdfjs_require__(21);
  31745. var _unicode = __w_pdfjs_require__(68);
  31746. var _standard_fonts = __w_pdfjs_require__(67);
  31747. var _pattern = __w_pdfjs_require__(136);
  31748. var _parser = __w_pdfjs_require__(26);
  31749. var _bidi = __w_pdfjs_require__(137);
  31750. var _colorspace = __w_pdfjs_require__(20);
  31751. var _glyphlist = __w_pdfjs_require__(42);
  31752. var _metrics = __w_pdfjs_require__(138);
  31753. var _function = __w_pdfjs_require__(69);
  31754. var _murmurhash = __w_pdfjs_require__(140);
  31755. var _operator_list = __w_pdfjs_require__(41);
  31756. var _image = __w_pdfjs_require__(141);
  31757. var PartialEvaluator = function PartialEvaluatorClosure() {
  31758. var DefaultPartialEvaluatorOptions = {
  31759. forceDataSchema: false,
  31760. maxImageSize: -1,
  31761. disableFontFace: false,
  31762. nativeImageDecoderSupport: _util.NativeImageDecoding.DECODE,
  31763. ignoreErrors: false,
  31764. isEvalSupported: true
  31765. };
  31766. function NativeImageDecoder(_ref) {
  31767. var xref = _ref.xref,
  31768. resources = _ref.resources,
  31769. handler = _ref.handler,
  31770. _ref$forceDataSchema = _ref.forceDataSchema,
  31771. forceDataSchema = _ref$forceDataSchema === undefined ? false : _ref$forceDataSchema,
  31772. pdfFunctionFactory = _ref.pdfFunctionFactory;
  31773. this.xref = xref;
  31774. this.resources = resources;
  31775. this.handler = handler;
  31776. this.forceDataSchema = forceDataSchema;
  31777. this.pdfFunctionFactory = pdfFunctionFactory;
  31778. }
  31779. NativeImageDecoder.prototype = {
  31780. canDecode: function canDecode(image) {
  31781. return image instanceof _stream.JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources, this.pdfFunctionFactory);
  31782. },
  31783. decode: function decode(image) {
  31784. var dict = image.dict;
  31785. var colorSpace = dict.get('ColorSpace', 'CS');
  31786. colorSpace = _colorspace.ColorSpace.parse(colorSpace, this.xref, this.resources, this.pdfFunctionFactory);
  31787. var numComps = colorSpace.numComps;
  31788. var decodePromise = this.handler.sendWithPromise('JpegDecode', [image.getIR(this.forceDataSchema), numComps]);
  31789. return decodePromise.then(function (message) {
  31790. var data = message.data;
  31791. return new _stream.Stream(data, 0, data.length, image.dict);
  31792. });
  31793. }
  31794. };
  31795. NativeImageDecoder.isSupported = function (image, xref, res, pdfFunctionFactory) {
  31796. var dict = image.dict;
  31797. if (dict.has('DecodeParms') || dict.has('DP')) {
  31798. return false;
  31799. }
  31800. var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
  31801. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  31802. };
  31803. NativeImageDecoder.isDecodable = function (image, xref, res, pdfFunctionFactory) {
  31804. var dict = image.dict;
  31805. if (dict.has('DecodeParms') || dict.has('DP')) {
  31806. return false;
  31807. }
  31808. var cs = _colorspace.ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res, pdfFunctionFactory);
  31809. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  31810. };
  31811. function PartialEvaluator(_ref2) {
  31812. var _this = this;
  31813. var pdfManager = _ref2.pdfManager,
  31814. xref = _ref2.xref,
  31815. handler = _ref2.handler,
  31816. pageIndex = _ref2.pageIndex,
  31817. idFactory = _ref2.idFactory,
  31818. fontCache = _ref2.fontCache,
  31819. builtInCMapCache = _ref2.builtInCMapCache,
  31820. _ref2$options = _ref2.options,
  31821. options = _ref2$options === undefined ? null : _ref2$options,
  31822. pdfFunctionFactory = _ref2.pdfFunctionFactory;
  31823. this.pdfManager = pdfManager;
  31824. this.xref = xref;
  31825. this.handler = handler;
  31826. this.pageIndex = pageIndex;
  31827. this.idFactory = idFactory;
  31828. this.fontCache = fontCache;
  31829. this.builtInCMapCache = builtInCMapCache;
  31830. this.options = options || DefaultPartialEvaluatorOptions;
  31831. this.pdfFunctionFactory = pdfFunctionFactory;
  31832. this.fetchBuiltInCMap = function (name) {
  31833. var cachedCMap = _this.builtInCMapCache[name];
  31834. if (cachedCMap) {
  31835. return Promise.resolve(cachedCMap);
  31836. }
  31837. return _this.handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
  31838. if (data.compressionType !== _util.CMapCompressionType.NONE) {
  31839. _this.builtInCMapCache[name] = data;
  31840. }
  31841. return data;
  31842. });
  31843. };
  31844. }
  31845. var TIME_SLOT_DURATION_MS = 20;
  31846. var CHECK_TIME_EVERY = 100;
  31847. function TimeSlotManager() {
  31848. this.reset();
  31849. }
  31850. TimeSlotManager.prototype = {
  31851. check: function TimeSlotManager_check() {
  31852. if (++this.checked < CHECK_TIME_EVERY) {
  31853. return false;
  31854. }
  31855. this.checked = 0;
  31856. return this.endTime <= Date.now();
  31857. },
  31858. reset: function TimeSlotManager_reset() {
  31859. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  31860. this.checked = 0;
  31861. }
  31862. };
  31863. function normalizeBlendMode(value) {
  31864. if (!(0, _primitives.isName)(value)) {
  31865. return 'source-over';
  31866. }
  31867. switch (value.name) {
  31868. case 'Normal':
  31869. case 'Compatible':
  31870. return 'source-over';
  31871. case 'Multiply':
  31872. return 'multiply';
  31873. case 'Screen':
  31874. return 'screen';
  31875. case 'Overlay':
  31876. return 'overlay';
  31877. case 'Darken':
  31878. return 'darken';
  31879. case 'Lighten':
  31880. return 'lighten';
  31881. case 'ColorDodge':
  31882. return 'color-dodge';
  31883. case 'ColorBurn':
  31884. return 'color-burn';
  31885. case 'HardLight':
  31886. return 'hard-light';
  31887. case 'SoftLight':
  31888. return 'soft-light';
  31889. case 'Difference':
  31890. return 'difference';
  31891. case 'Exclusion':
  31892. return 'exclusion';
  31893. case 'Hue':
  31894. return 'hue';
  31895. case 'Saturation':
  31896. return 'saturation';
  31897. case 'Color':
  31898. return 'color';
  31899. case 'Luminosity':
  31900. return 'luminosity';
  31901. }
  31902. (0, _util.warn)('Unsupported blend mode: ' + value.name);
  31903. return 'source-over';
  31904. }
  31905. var deferred = Promise.resolve();
  31906. var TILING_PATTERN = 1,
  31907. SHADING_PATTERN = 2;
  31908. PartialEvaluator.prototype = {
  31909. clone: function clone() {
  31910. var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DefaultPartialEvaluatorOptions;
  31911. var newEvaluator = Object.create(this);
  31912. newEvaluator.options = newOptions;
  31913. return newEvaluator;
  31914. },
  31915. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  31916. if (!(0, _primitives.isDict)(resources)) {
  31917. return false;
  31918. }
  31919. var processed = Object.create(null);
  31920. if (resources.objId) {
  31921. processed[resources.objId] = true;
  31922. }
  31923. var nodes = [resources],
  31924. xref = this.xref;
  31925. while (nodes.length) {
  31926. var key, i, ii;
  31927. var node = nodes.shift();
  31928. var graphicStates = node.get('ExtGState');
  31929. if ((0, _primitives.isDict)(graphicStates)) {
  31930. var graphicStatesKeys = graphicStates.getKeys();
  31931. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  31932. key = graphicStatesKeys[i];
  31933. var graphicState = graphicStates.get(key);
  31934. var bm = graphicState.get('BM');
  31935. if ((0, _primitives.isName)(bm) && bm.name !== 'Normal') {
  31936. return true;
  31937. }
  31938. }
  31939. }
  31940. var xObjects = node.get('XObject');
  31941. if (!(0, _primitives.isDict)(xObjects)) {
  31942. continue;
  31943. }
  31944. var xObjectsKeys = xObjects.getKeys();
  31945. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  31946. key = xObjectsKeys[i];
  31947. var xObject = xObjects.getRaw(key);
  31948. if ((0, _primitives.isRef)(xObject)) {
  31949. if (processed[xObject.toString()]) {
  31950. continue;
  31951. }
  31952. xObject = xref.fetch(xObject);
  31953. }
  31954. if (!(0, _primitives.isStream)(xObject)) {
  31955. continue;
  31956. }
  31957. if (xObject.dict.objId) {
  31958. if (processed[xObject.dict.objId]) {
  31959. continue;
  31960. }
  31961. processed[xObject.dict.objId] = true;
  31962. }
  31963. var xResources = xObject.dict.get('Resources');
  31964. if ((0, _primitives.isDict)(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  31965. nodes.push(xResources);
  31966. if (xResources.objId) {
  31967. processed[xResources.objId] = true;
  31968. }
  31969. }
  31970. }
  31971. }
  31972. return false;
  31973. },
  31974. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  31975. var dict = xobj.dict;
  31976. var matrix = dict.getArray('Matrix');
  31977. var bbox = dict.getArray('BBox');
  31978. var group = dict.get('Group');
  31979. if (group) {
  31980. var groupOptions = {
  31981. matrix: matrix,
  31982. bbox: bbox,
  31983. smask: smask,
  31984. isolated: false,
  31985. knockout: false
  31986. };
  31987. var groupSubtype = group.get('S');
  31988. var colorSpace = null;
  31989. if ((0, _primitives.isName)(groupSubtype, 'Transparency')) {
  31990. groupOptions.isolated = group.get('I') || false;
  31991. groupOptions.knockout = group.get('K') || false;
  31992. if (group.has('CS')) {
  31993. colorSpace = _colorspace.ColorSpace.parse(group.get('CS'), this.xref, resources, this.pdfFunctionFactory);
  31994. }
  31995. }
  31996. if (smask && smask.backdrop) {
  31997. colorSpace = colorSpace || _colorspace.ColorSpace.singletons.rgb;
  31998. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  31999. }
  32000. operatorList.addOp(_util.OPS.beginGroup, [groupOptions]);
  32001. }
  32002. operatorList.addOp(_util.OPS.paintFormXObjectBegin, [matrix, bbox]);
  32003. return this.getOperatorList({
  32004. stream: xobj,
  32005. task: task,
  32006. resources: dict.get('Resources') || resources,
  32007. operatorList: operatorList,
  32008. initialState: initialState
  32009. }).then(function () {
  32010. operatorList.addOp(_util.OPS.paintFormXObjectEnd, []);
  32011. if (group) {
  32012. operatorList.addOp(_util.OPS.endGroup, [groupOptions]);
  32013. }
  32014. });
  32015. },
  32016. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  32017. var _this2 = this;
  32018. var dict = image.dict;
  32019. var w = dict.get('Width', 'W');
  32020. var h = dict.get('Height', 'H');
  32021. if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
  32022. (0, _util.warn)('Image dimensions are missing, or not numbers.');
  32023. return;
  32024. }
  32025. var maxImageSize = this.options.maxImageSize;
  32026. if (maxImageSize !== -1 && w * h > maxImageSize) {
  32027. (0, _util.warn)('Image exceeded maximum allowed size and was removed.');
  32028. return;
  32029. }
  32030. var imageMask = dict.get('ImageMask', 'IM') || false;
  32031. var imgData, args;
  32032. if (imageMask) {
  32033. var width = dict.get('Width', 'W');
  32034. var height = dict.get('Height', 'H');
  32035. var bitStrideLength = width + 7 >> 3;
  32036. var imgArray = image.getBytes(bitStrideLength * height);
  32037. var decode = dict.getArray('Decode', 'D');
  32038. imgData = _image.PDFImage.createMask({
  32039. imgArray: imgArray,
  32040. width: width,
  32041. height: height,
  32042. imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
  32043. inverseDecode: !!decode && decode[0] > 0
  32044. });
  32045. imgData.cached = true;
  32046. args = [imgData];
  32047. operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
  32048. if (cacheKey) {
  32049. imageCache[cacheKey] = {
  32050. fn: _util.OPS.paintImageMaskXObject,
  32051. args: args
  32052. };
  32053. }
  32054. return;
  32055. }
  32056. var softMask = dict.get('SMask', 'SM') || false;
  32057. var mask = dict.get('Mask') || false;
  32058. var SMALL_IMAGE_DIMENSIONS = 200;
  32059. if (inline && !softMask && !mask && !(image instanceof _stream.JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  32060. var imageObj = new _image.PDFImage({
  32061. xref: this.xref,
  32062. res: resources,
  32063. image: image,
  32064. pdfFunctionFactory: this.pdfFunctionFactory
  32065. });
  32066. imgData = imageObj.createImageData(true);
  32067. operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
  32068. return;
  32069. }
  32070. var nativeImageDecoderSupport = this.options.nativeImageDecoderSupport;
  32071. var objId = 'img_' + this.idFactory.createObjId();
  32072. operatorList.addDependency(objId);
  32073. args = [objId, w, h];
  32074. if (nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && !softMask && !mask && image instanceof _stream.JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources, this.pdfFunctionFactory)) {
  32075. operatorList.addOp(_util.OPS.paintJpegXObject, args);
  32076. this.handler.send('obj', [objId, this.pageIndex, 'JpegStream', image.getIR(this.options.forceDataSchema)]);
  32077. if (cacheKey) {
  32078. imageCache[cacheKey] = {
  32079. fn: _util.OPS.paintJpegXObject,
  32080. args: args
  32081. };
  32082. }
  32083. return;
  32084. }
  32085. var nativeImageDecoder = null;
  32086. if (nativeImageDecoderSupport === _util.NativeImageDecoding.DECODE && (image instanceof _stream.JpegStream || mask instanceof _stream.JpegStream || softMask instanceof _stream.JpegStream)) {
  32087. nativeImageDecoder = new NativeImageDecoder({
  32088. xref: this.xref,
  32089. resources: resources,
  32090. handler: this.handler,
  32091. forceDataSchema: this.options.forceDataSchema,
  32092. pdfFunctionFactory: this.pdfFunctionFactory
  32093. });
  32094. }
  32095. _image.PDFImage.buildImage({
  32096. handler: this.handler,
  32097. xref: this.xref,
  32098. res: resources,
  32099. image: image,
  32100. nativeDecoder: nativeImageDecoder,
  32101. pdfFunctionFactory: this.pdfFunctionFactory
  32102. }).then(function (imageObj) {
  32103. var imgData = imageObj.createImageData(false);
  32104. _this2.handler.send('obj', [objId, _this2.pageIndex, 'Image', imgData], [imgData.data.buffer]);
  32105. }).catch(function (reason) {
  32106. (0, _util.warn)('Unable to decode image: ' + reason);
  32107. _this2.handler.send('obj', [objId, _this2.pageIndex, 'Image', null]);
  32108. });
  32109. operatorList.addOp(_util.OPS.paintImageXObject, args);
  32110. if (cacheKey) {
  32111. imageCache[cacheKey] = {
  32112. fn: _util.OPS.paintImageXObject,
  32113. args: args
  32114. };
  32115. }
  32116. },
  32117. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  32118. var smaskContent = smask.get('G');
  32119. var smaskOptions = {
  32120. subtype: smask.get('S').name,
  32121. backdrop: smask.get('BC')
  32122. };
  32123. var transferObj = smask.get('TR');
  32124. if ((0, _function.isPDFFunction)(transferObj)) {
  32125. var transferFn = this.pdfFunctionFactory.create(transferObj);
  32126. var transferMap = new Uint8Array(256);
  32127. var tmp = new Float32Array(1);
  32128. for (var i = 0; i < 256; i++) {
  32129. tmp[0] = i / 255;
  32130. transferFn(tmp, 0, tmp, 0);
  32131. transferMap[i] = tmp[0] * 255 | 0;
  32132. }
  32133. smaskOptions.transferMap = transferMap;
  32134. }
  32135. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  32136. },
  32137. handleTilingType: function handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  32138. var _this3 = this;
  32139. var tilingOpList = new _operator_list.OperatorList();
  32140. var resourcesArray = [patternDict.get('Resources'), resources];
  32141. var patternResources = _primitives.Dict.merge(this.xref, resourcesArray);
  32142. return this.getOperatorList({
  32143. stream: pattern,
  32144. task: task,
  32145. resources: patternResources,
  32146. operatorList: tilingOpList
  32147. }).then(function () {
  32148. return (0, _pattern.getTilingPatternIR)({
  32149. fnArray: tilingOpList.fnArray,
  32150. argsArray: tilingOpList.argsArray
  32151. }, patternDict, args);
  32152. }).then(function (tilingPatternIR) {
  32153. operatorList.addDependencies(tilingOpList.dependencies);
  32154. operatorList.addOp(fn, tilingPatternIR);
  32155. }, function (reason) {
  32156. if (_this3.options.ignoreErrors) {
  32157. _this3.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
  32158. (0, _util.warn)('handleTilingType - ignoring pattern: "' + reason + '".');
  32159. return;
  32160. }
  32161. throw reason;
  32162. });
  32163. },
  32164. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  32165. var _this4 = this;
  32166. var fontName;
  32167. if (fontArgs) {
  32168. fontArgs = fontArgs.slice();
  32169. fontName = fontArgs[0].name;
  32170. }
  32171. return this.loadFont(fontName, fontRef, resources).then(function (translated) {
  32172. if (!translated.font.isType3Font) {
  32173. return translated;
  32174. }
  32175. return translated.loadType3Data(_this4, resources, operatorList, task).then(function () {
  32176. return translated;
  32177. }).catch(function (reason) {
  32178. _this4.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.font });
  32179. return new TranslatedFont('g_font_error', new _fonts.ErrorFont('Type3 font load error: ' + reason), translated.font);
  32180. });
  32181. }).then(function (translated) {
  32182. state.font = translated.font;
  32183. translated.send(_this4.handler);
  32184. return translated.loadedName;
  32185. });
  32186. },
  32187. handleText: function PartialEvaluator_handleText(chars, state) {
  32188. var _this5 = this;
  32189. var font = state.font;
  32190. var glyphs = font.charsToGlyphs(chars);
  32191. var isAddToPathSet = !!(state.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
  32192. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  32193. var buildPath = function buildPath(fontChar) {
  32194. if (!font.renderer.hasBuiltPath(fontChar)) {
  32195. var path = font.renderer.getPathJs(fontChar);
  32196. _this5.handler.send('commonobj', [font.loadedName + '_path_' + fontChar, 'FontPath', path]);
  32197. }
  32198. };
  32199. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  32200. var glyph = glyphs[i];
  32201. buildPath(glyph.fontChar);
  32202. var accent = glyph.accent;
  32203. if (accent && accent.fontChar) {
  32204. buildPath(accent.fontChar);
  32205. }
  32206. }
  32207. }
  32208. return glyphs;
  32209. },
  32210. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, stateManager) {
  32211. var _this6 = this;
  32212. var gStateObj = [];
  32213. var gStateKeys = gState.getKeys();
  32214. var promise = Promise.resolve();
  32215. var _loop = function _loop() {
  32216. var key = gStateKeys[i];
  32217. var value = gState.get(key);
  32218. switch (key) {
  32219. case 'Type':
  32220. break;
  32221. case 'LW':
  32222. case 'LC':
  32223. case 'LJ':
  32224. case 'ML':
  32225. case 'D':
  32226. case 'RI':
  32227. case 'FL':
  32228. case 'CA':
  32229. case 'ca':
  32230. gStateObj.push([key, value]);
  32231. break;
  32232. case 'Font':
  32233. promise = promise.then(function () {
  32234. return _this6.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  32235. operatorList.addDependency(loadedName);
  32236. gStateObj.push([key, [loadedName, value[1]]]);
  32237. });
  32238. });
  32239. break;
  32240. case 'BM':
  32241. gStateObj.push([key, normalizeBlendMode(value)]);
  32242. break;
  32243. case 'SMask':
  32244. if ((0, _primitives.isName)(value, 'None')) {
  32245. gStateObj.push([key, false]);
  32246. break;
  32247. }
  32248. if ((0, _primitives.isDict)(value)) {
  32249. promise = promise.then(function () {
  32250. return _this6.handleSMask(value, resources, operatorList, task, stateManager);
  32251. });
  32252. gStateObj.push([key, true]);
  32253. } else {
  32254. (0, _util.warn)('Unsupported SMask type');
  32255. }
  32256. break;
  32257. case 'OP':
  32258. case 'op':
  32259. case 'OPM':
  32260. case 'BG':
  32261. case 'BG2':
  32262. case 'UCR':
  32263. case 'UCR2':
  32264. case 'TR':
  32265. case 'TR2':
  32266. case 'HT':
  32267. case 'SM':
  32268. case 'SA':
  32269. case 'AIS':
  32270. case 'TK':
  32271. (0, _util.info)('graphic state operator ' + key);
  32272. break;
  32273. default:
  32274. (0, _util.info)('Unknown graphic state operator ' + key);
  32275. break;
  32276. }
  32277. };
  32278. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  32279. _loop();
  32280. }
  32281. return promise.then(function () {
  32282. if (gStateObj.length > 0) {
  32283. operatorList.addOp(_util.OPS.setGState, [gStateObj]);
  32284. }
  32285. });
  32286. },
  32287. loadFont: function PartialEvaluator_loadFont(fontName, font, resources) {
  32288. var _this7 = this;
  32289. function errorFont() {
  32290. return Promise.resolve(new TranslatedFont('g_font_error', new _fonts.ErrorFont('Font ' + fontName + ' is not available'), font));
  32291. }
  32292. var fontRef,
  32293. xref = this.xref;
  32294. if (font) {
  32295. if (!(0, _primitives.isRef)(font)) {
  32296. throw new Error('The "font" object should be a reference.');
  32297. }
  32298. fontRef = font;
  32299. } else {
  32300. var fontRes = resources.get('Font');
  32301. if (fontRes) {
  32302. fontRef = fontRes.getRaw(fontName);
  32303. } else {
  32304. (0, _util.warn)('fontRes not available');
  32305. return errorFont();
  32306. }
  32307. }
  32308. if (!fontRef) {
  32309. (0, _util.warn)('fontRef not available');
  32310. return errorFont();
  32311. }
  32312. if (this.fontCache.has(fontRef)) {
  32313. return this.fontCache.get(fontRef);
  32314. }
  32315. font = xref.fetchIfRef(fontRef);
  32316. if (!(0, _primitives.isDict)(font)) {
  32317. return errorFont();
  32318. }
  32319. if (font.translated) {
  32320. return font.translated;
  32321. }
  32322. var fontCapability = (0, _util.createPromiseCapability)();
  32323. var preEvaluatedFont = this.preEvaluateFont(font);
  32324. var descriptor = preEvaluatedFont.descriptor;
  32325. var fontRefIsRef = (0, _primitives.isRef)(fontRef),
  32326. fontID;
  32327. if (fontRefIsRef) {
  32328. fontID = fontRef.toString();
  32329. }
  32330. if ((0, _primitives.isDict)(descriptor)) {
  32331. if (!descriptor.fontAliases) {
  32332. descriptor.fontAliases = Object.create(null);
  32333. }
  32334. var fontAliases = descriptor.fontAliases;
  32335. var hash = preEvaluatedFont.hash;
  32336. if (fontAliases[hash]) {
  32337. var aliasFontRef = fontAliases[hash].aliasRef;
  32338. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  32339. this.fontCache.putAlias(fontRef, aliasFontRef);
  32340. return this.fontCache.get(fontRef);
  32341. }
  32342. } else {
  32343. fontAliases[hash] = { fontID: _fonts.Font.getFontID() };
  32344. }
  32345. if (fontRefIsRef) {
  32346. fontAliases[hash].aliasRef = fontRef;
  32347. }
  32348. fontID = fontAliases[hash].fontID;
  32349. }
  32350. if (fontRefIsRef) {
  32351. this.fontCache.put(fontRef, fontCapability.promise);
  32352. } else {
  32353. if (!fontID) {
  32354. fontID = this.idFactory.createObjId();
  32355. }
  32356. this.fontCache.put('id_' + fontID, fontCapability.promise);
  32357. }
  32358. (0, _util.assert)(fontID, 'The "fontID" must be defined.');
  32359. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  32360. font.translated = fontCapability.promise;
  32361. var translatedPromise;
  32362. try {
  32363. translatedPromise = this.translateFont(preEvaluatedFont);
  32364. } catch (e) {
  32365. translatedPromise = Promise.reject(e);
  32366. }
  32367. translatedPromise.then(function (translatedFont) {
  32368. if (translatedFont.fontType !== undefined) {
  32369. var xrefFontStats = xref.stats.fontTypes;
  32370. xrefFontStats[translatedFont.fontType] = true;
  32371. }
  32372. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  32373. }).catch(function (reason) {
  32374. _this7.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.font });
  32375. try {
  32376. var descriptor = preEvaluatedFont.descriptor;
  32377. var fontFile3 = descriptor && descriptor.get('FontFile3');
  32378. var subtype = fontFile3 && fontFile3.get('Subtype');
  32379. var fontType = (0, _fonts.getFontType)(preEvaluatedFont.type, subtype && subtype.name);
  32380. var xrefFontStats = xref.stats.fontTypes;
  32381. xrefFontStats[fontType] = true;
  32382. } catch (ex) {}
  32383. fontCapability.resolve(new TranslatedFont(font.loadedName, new _fonts.ErrorFont(reason instanceof Error ? reason.message : reason), font));
  32384. });
  32385. return fontCapability.promise;
  32386. },
  32387. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  32388. var lastIndex = operatorList.length - 1;
  32389. if (!args) {
  32390. args = [];
  32391. }
  32392. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== _util.OPS.constructPath) {
  32393. operatorList.addOp(_util.OPS.constructPath, [[fn], args]);
  32394. } else {
  32395. var opArgs = operatorList.argsArray[lastIndex];
  32396. opArgs[0].push(fn);
  32397. Array.prototype.push.apply(opArgs[1], args);
  32398. }
  32399. },
  32400. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
  32401. var patternName = args[args.length - 1];
  32402. var pattern;
  32403. if ((0, _primitives.isName)(patternName) && (pattern = patterns.get(patternName.name))) {
  32404. var dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
  32405. var typeNum = dict.get('PatternType');
  32406. if (typeNum === TILING_PATTERN) {
  32407. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  32408. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  32409. } else if (typeNum === SHADING_PATTERN) {
  32410. var shading = dict.get('Shading');
  32411. var matrix = dict.getArray('Matrix');
  32412. pattern = _pattern.Pattern.parseShading(shading, matrix, this.xref, resources, this.handler, this.pdfFunctionFactory);
  32413. operatorList.addOp(fn, pattern.getIR());
  32414. return Promise.resolve();
  32415. }
  32416. return Promise.reject(new Error('Unknown PatternType: ' + typeNum));
  32417. }
  32418. operatorList.addOp(fn, args);
  32419. return Promise.resolve();
  32420. },
  32421. getOperatorList: function getOperatorList(_ref3) {
  32422. var _this8 = this;
  32423. var stream = _ref3.stream,
  32424. task = _ref3.task,
  32425. resources = _ref3.resources,
  32426. operatorList = _ref3.operatorList,
  32427. _ref3$initialState = _ref3.initialState,
  32428. initialState = _ref3$initialState === undefined ? null : _ref3$initialState;
  32429. resources = resources || _primitives.Dict.empty;
  32430. initialState = initialState || new EvalState();
  32431. if (!operatorList) {
  32432. throw new Error('getOperatorList: missing "operatorList" parameter');
  32433. }
  32434. var self = this;
  32435. var xref = this.xref;
  32436. var imageCache = Object.create(null);
  32437. var xobjs = resources.get('XObject') || _primitives.Dict.empty;
  32438. var patterns = resources.get('Pattern') || _primitives.Dict.empty;
  32439. var stateManager = new StateManager(initialState);
  32440. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  32441. var timeSlotManager = new TimeSlotManager();
  32442. function closePendingRestoreOPS(argument) {
  32443. for (var i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  32444. operatorList.addOp(_util.OPS.restore, []);
  32445. }
  32446. }
  32447. return new Promise(function promiseBody(resolve, reject) {
  32448. var next = function next(promise) {
  32449. promise.then(function () {
  32450. try {
  32451. promiseBody(resolve, reject);
  32452. } catch (ex) {
  32453. reject(ex);
  32454. }
  32455. }, reject);
  32456. };
  32457. task.ensureNotTerminated();
  32458. timeSlotManager.reset();
  32459. var stop,
  32460. operation = {},
  32461. i,
  32462. ii,
  32463. cs;
  32464. while (!(stop = timeSlotManager.check())) {
  32465. operation.args = null;
  32466. if (!preprocessor.read(operation)) {
  32467. break;
  32468. }
  32469. var args = operation.args;
  32470. var fn = operation.fn;
  32471. switch (fn | 0) {
  32472. case _util.OPS.paintXObject:
  32473. var name = args[0].name;
  32474. if (name && imageCache[name] !== undefined) {
  32475. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  32476. args = null;
  32477. continue;
  32478. }
  32479. next(new Promise(function (resolveXObject, rejectXObject) {
  32480. if (!name) {
  32481. throw new _util.FormatError('XObject must be referred to by name.');
  32482. }
  32483. var xobj = xobjs.get(name);
  32484. if (!xobj) {
  32485. operatorList.addOp(fn, args);
  32486. resolveXObject();
  32487. return;
  32488. }
  32489. if (!(0, _primitives.isStream)(xobj)) {
  32490. throw new _util.FormatError('XObject should be a stream');
  32491. }
  32492. var type = xobj.dict.get('Subtype');
  32493. if (!(0, _primitives.isName)(type)) {
  32494. throw new _util.FormatError('XObject should have a Name subtype');
  32495. }
  32496. if (type.name === 'Form') {
  32497. stateManager.save();
  32498. self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  32499. stateManager.restore();
  32500. resolveXObject();
  32501. }, rejectXObject);
  32502. return;
  32503. } else if (type.name === 'Image') {
  32504. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  32505. } else if (type.name === 'PS') {
  32506. (0, _util.info)('Ignored XObject subtype PS');
  32507. } else {
  32508. throw new _util.FormatError('Unhandled XObject subtype ' + type.name);
  32509. }
  32510. resolveXObject();
  32511. }).catch(function (reason) {
  32512. if (self.options.ignoreErrors) {
  32513. self.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
  32514. (0, _util.warn)('getOperatorList - ignoring XObject: "' + reason + '".');
  32515. return;
  32516. }
  32517. throw reason;
  32518. }));
  32519. return;
  32520. case _util.OPS.setFont:
  32521. var fontSize = args[1];
  32522. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  32523. operatorList.addDependency(loadedName);
  32524. operatorList.addOp(_util.OPS.setFont, [loadedName, fontSize]);
  32525. }));
  32526. return;
  32527. case _util.OPS.endInlineImage:
  32528. var cacheKey = args[0].cacheKey;
  32529. if (cacheKey) {
  32530. var cacheEntry = imageCache[cacheKey];
  32531. if (cacheEntry !== undefined) {
  32532. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  32533. args = null;
  32534. continue;
  32535. }
  32536. }
  32537. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  32538. args = null;
  32539. continue;
  32540. case _util.OPS.showText:
  32541. args[0] = self.handleText(args[0], stateManager.state);
  32542. break;
  32543. case _util.OPS.showSpacedText:
  32544. var arr = args[0];
  32545. var combinedGlyphs = [];
  32546. var arrLength = arr.length;
  32547. var state = stateManager.state;
  32548. for (i = 0; i < arrLength; ++i) {
  32549. var arrItem = arr[i];
  32550. if ((0, _util.isString)(arrItem)) {
  32551. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  32552. } else if ((0, _util.isNum)(arrItem)) {
  32553. combinedGlyphs.push(arrItem);
  32554. }
  32555. }
  32556. args[0] = combinedGlyphs;
  32557. fn = _util.OPS.showText;
  32558. break;
  32559. case _util.OPS.nextLineShowText:
  32560. operatorList.addOp(_util.OPS.nextLine);
  32561. args[0] = self.handleText(args[0], stateManager.state);
  32562. fn = _util.OPS.showText;
  32563. break;
  32564. case _util.OPS.nextLineSetSpacingShowText:
  32565. operatorList.addOp(_util.OPS.nextLine);
  32566. operatorList.addOp(_util.OPS.setWordSpacing, [args.shift()]);
  32567. operatorList.addOp(_util.OPS.setCharSpacing, [args.shift()]);
  32568. args[0] = self.handleText(args[0], stateManager.state);
  32569. fn = _util.OPS.showText;
  32570. break;
  32571. case _util.OPS.setTextRenderingMode:
  32572. stateManager.state.textRenderingMode = args[0];
  32573. break;
  32574. case _util.OPS.setFillColorSpace:
  32575. stateManager.state.fillColorSpace = _colorspace.ColorSpace.parse(args[0], xref, resources, self.pdfFunctionFactory);
  32576. continue;
  32577. case _util.OPS.setStrokeColorSpace:
  32578. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.parse(args[0], xref, resources, self.pdfFunctionFactory);
  32579. continue;
  32580. case _util.OPS.setFillColor:
  32581. cs = stateManager.state.fillColorSpace;
  32582. args = cs.getRgb(args, 0);
  32583. fn = _util.OPS.setFillRGBColor;
  32584. break;
  32585. case _util.OPS.setStrokeColor:
  32586. cs = stateManager.state.strokeColorSpace;
  32587. args = cs.getRgb(args, 0);
  32588. fn = _util.OPS.setStrokeRGBColor;
  32589. break;
  32590. case _util.OPS.setFillGray:
  32591. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  32592. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  32593. fn = _util.OPS.setFillRGBColor;
  32594. break;
  32595. case _util.OPS.setStrokeGray:
  32596. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  32597. args = _colorspace.ColorSpace.singletons.gray.getRgb(args, 0);
  32598. fn = _util.OPS.setStrokeRGBColor;
  32599. break;
  32600. case _util.OPS.setFillCMYKColor:
  32601. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  32602. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  32603. fn = _util.OPS.setFillRGBColor;
  32604. break;
  32605. case _util.OPS.setStrokeCMYKColor:
  32606. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.cmyk;
  32607. args = _colorspace.ColorSpace.singletons.cmyk.getRgb(args, 0);
  32608. fn = _util.OPS.setStrokeRGBColor;
  32609. break;
  32610. case _util.OPS.setFillRGBColor:
  32611. stateManager.state.fillColorSpace = _colorspace.ColorSpace.singletons.rgb;
  32612. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  32613. break;
  32614. case _util.OPS.setStrokeRGBColor:
  32615. stateManager.state.strokeColorSpace = _colorspace.ColorSpace.singletons.rgb;
  32616. args = _colorspace.ColorSpace.singletons.rgb.getRgb(args, 0);
  32617. break;
  32618. case _util.OPS.setFillColorN:
  32619. cs = stateManager.state.fillColorSpace;
  32620. if (cs.name === 'Pattern') {
  32621. next(self.handleColorN(operatorList, _util.OPS.setFillColorN, args, cs, patterns, resources, task));
  32622. return;
  32623. }
  32624. args = cs.getRgb(args, 0);
  32625. fn = _util.OPS.setFillRGBColor;
  32626. break;
  32627. case _util.OPS.setStrokeColorN:
  32628. cs = stateManager.state.strokeColorSpace;
  32629. if (cs.name === 'Pattern') {
  32630. next(self.handleColorN(operatorList, _util.OPS.setStrokeColorN, args, cs, patterns, resources, task));
  32631. return;
  32632. }
  32633. args = cs.getRgb(args, 0);
  32634. fn = _util.OPS.setStrokeRGBColor;
  32635. break;
  32636. case _util.OPS.shadingFill:
  32637. var shadingRes = resources.get('Shading');
  32638. if (!shadingRes) {
  32639. throw new _util.FormatError('No shading resource found');
  32640. }
  32641. var shading = shadingRes.get(args[0].name);
  32642. if (!shading) {
  32643. throw new _util.FormatError('No shading object found');
  32644. }
  32645. var shadingFill = _pattern.Pattern.parseShading(shading, null, xref, resources, self.handler, self.pdfFunctionFactory);
  32646. var patternIR = shadingFill.getIR();
  32647. args = [patternIR];
  32648. fn = _util.OPS.shadingFill;
  32649. break;
  32650. case _util.OPS.setGState:
  32651. var dictName = args[0];
  32652. var extGState = resources.get('ExtGState');
  32653. if (!(0, _primitives.isDict)(extGState) || !extGState.has(dictName.name)) {
  32654. break;
  32655. }
  32656. var gState = extGState.get(dictName.name);
  32657. next(self.setGState(resources, gState, operatorList, task, stateManager));
  32658. return;
  32659. case _util.OPS.moveTo:
  32660. case _util.OPS.lineTo:
  32661. case _util.OPS.curveTo:
  32662. case _util.OPS.curveTo2:
  32663. case _util.OPS.curveTo3:
  32664. case _util.OPS.closePath:
  32665. self.buildPath(operatorList, fn, args);
  32666. continue;
  32667. case _util.OPS.rectangle:
  32668. self.buildPath(operatorList, fn, args);
  32669. continue;
  32670. case _util.OPS.markPoint:
  32671. case _util.OPS.markPointProps:
  32672. case _util.OPS.beginMarkedContent:
  32673. case _util.OPS.beginMarkedContentProps:
  32674. case _util.OPS.endMarkedContent:
  32675. case _util.OPS.beginCompat:
  32676. case _util.OPS.endCompat:
  32677. continue;
  32678. default:
  32679. if (args !== null) {
  32680. for (i = 0, ii = args.length; i < ii; i++) {
  32681. if (args[i] instanceof _primitives.Dict) {
  32682. break;
  32683. }
  32684. }
  32685. if (i < ii) {
  32686. (0, _util.warn)('getOperatorList - ignoring operator: ' + fn);
  32687. continue;
  32688. }
  32689. }
  32690. }
  32691. operatorList.addOp(fn, args);
  32692. }
  32693. if (stop) {
  32694. next(deferred);
  32695. return;
  32696. }
  32697. closePendingRestoreOPS();
  32698. resolve();
  32699. }).catch(function (reason) {
  32700. if (_this8.options.ignoreErrors) {
  32701. _this8.handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.unknown });
  32702. (0, _util.warn)('getOperatorList - ignoring errors during task: ' + task.name);
  32703. closePendingRestoreOPS();
  32704. return;
  32705. }
  32706. throw reason;
  32707. });
  32708. },
  32709. getTextContent: function getTextContent(_ref4) {
  32710. var _this9 = this;
  32711. var stream = _ref4.stream,
  32712. task = _ref4.task,
  32713. resources = _ref4.resources,
  32714. _ref4$stateManager = _ref4.stateManager,
  32715. stateManager = _ref4$stateManager === undefined ? null : _ref4$stateManager,
  32716. _ref4$normalizeWhites = _ref4.normalizeWhitespace,
  32717. normalizeWhitespace = _ref4$normalizeWhites === undefined ? false : _ref4$normalizeWhites,
  32718. _ref4$combineTextItem = _ref4.combineTextItems,
  32719. combineTextItems = _ref4$combineTextItem === undefined ? false : _ref4$combineTextItem,
  32720. sink = _ref4.sink,
  32721. _ref4$seenStyles = _ref4.seenStyles,
  32722. seenStyles = _ref4$seenStyles === undefined ? Object.create(null) : _ref4$seenStyles;
  32723. resources = resources || _primitives.Dict.empty;
  32724. stateManager = stateManager || new StateManager(new TextState());
  32725. var WhitespaceRegexp = /\s/g;
  32726. var textContent = {
  32727. items: [],
  32728. styles: Object.create(null)
  32729. };
  32730. var textContentItem = {
  32731. initialized: false,
  32732. str: [],
  32733. width: 0,
  32734. height: 0,
  32735. vertical: false,
  32736. lastAdvanceWidth: 0,
  32737. lastAdvanceHeight: 0,
  32738. textAdvanceScale: 0,
  32739. spaceWidth: 0,
  32740. fakeSpaceMin: Infinity,
  32741. fakeMultiSpaceMin: Infinity,
  32742. fakeMultiSpaceMax: -0,
  32743. textRunBreakAllowed: false,
  32744. transform: null,
  32745. fontName: null
  32746. };
  32747. var SPACE_FACTOR = 0.3;
  32748. var MULTI_SPACE_FACTOR = 1.5;
  32749. var MULTI_SPACE_FACTOR_MAX = 4;
  32750. var self = this;
  32751. var xref = this.xref;
  32752. var xobjs = null;
  32753. var skipEmptyXObjs = Object.create(null);
  32754. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  32755. var textState;
  32756. function ensureTextContentItem() {
  32757. if (textContentItem.initialized) {
  32758. return textContentItem;
  32759. }
  32760. var font = textState.font;
  32761. if (!(font.loadedName in seenStyles)) {
  32762. seenStyles[font.loadedName] = true;
  32763. textContent.styles[font.loadedName] = {
  32764. fontFamily: font.fallbackName,
  32765. ascent: font.ascent,
  32766. descent: font.descent,
  32767. vertical: font.vertical
  32768. };
  32769. }
  32770. textContentItem.fontName = font.loadedName;
  32771. var tsm = [textState.fontSize * textState.textHScale, 0, 0, textState.fontSize, 0, textState.textRise];
  32772. if (font.isType3Font && textState.fontMatrix !== _util.FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  32773. var glyphHeight = font.bbox[3] - font.bbox[1];
  32774. if (glyphHeight > 0) {
  32775. glyphHeight = glyphHeight * textState.fontMatrix[3];
  32776. tsm[3] *= glyphHeight;
  32777. }
  32778. }
  32779. var trm = _util.Util.transform(textState.ctm, _util.Util.transform(textState.textMatrix, tsm));
  32780. textContentItem.transform = trm;
  32781. if (!font.vertical) {
  32782. textContentItem.width = 0;
  32783. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  32784. textContentItem.vertical = false;
  32785. } else {
  32786. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  32787. textContentItem.height = 0;
  32788. textContentItem.vertical = true;
  32789. }
  32790. var a = textState.textLineMatrix[0];
  32791. var b = textState.textLineMatrix[1];
  32792. var scaleLineX = Math.sqrt(a * a + b * b);
  32793. a = textState.ctm[0];
  32794. b = textState.ctm[1];
  32795. var scaleCtmX = Math.sqrt(a * a + b * b);
  32796. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  32797. textContentItem.lastAdvanceWidth = 0;
  32798. textContentItem.lastAdvanceHeight = 0;
  32799. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  32800. if (spaceWidth) {
  32801. textContentItem.spaceWidth = spaceWidth;
  32802. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  32803. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  32804. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  32805. textContentItem.textRunBreakAllowed = !font.isMonospace;
  32806. } else {
  32807. textContentItem.spaceWidth = 0;
  32808. textContentItem.fakeSpaceMin = Infinity;
  32809. textContentItem.fakeMultiSpaceMin = Infinity;
  32810. textContentItem.fakeMultiSpaceMax = 0;
  32811. textContentItem.textRunBreakAllowed = false;
  32812. }
  32813. textContentItem.initialized = true;
  32814. return textContentItem;
  32815. }
  32816. function replaceWhitespace(str) {
  32817. var i = 0,
  32818. ii = str.length,
  32819. code;
  32820. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  32821. i++;
  32822. }
  32823. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  32824. }
  32825. function runBidiTransform(textChunk) {
  32826. var str = textChunk.str.join('');
  32827. var bidiResult = (0, _bidi.bidi)(str, -1, textChunk.vertical);
  32828. return {
  32829. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  32830. dir: bidiResult.dir,
  32831. width: textChunk.width,
  32832. height: textChunk.height,
  32833. transform: textChunk.transform,
  32834. fontName: textChunk.fontName
  32835. };
  32836. }
  32837. function handleSetFont(fontName, fontRef) {
  32838. return self.loadFont(fontName, fontRef, resources).then(function (translated) {
  32839. textState.font = translated.font;
  32840. textState.fontMatrix = translated.font.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  32841. });
  32842. }
  32843. function buildTextContentItem(chars) {
  32844. var font = textState.font;
  32845. var textChunk = ensureTextContentItem();
  32846. var width = 0;
  32847. var height = 0;
  32848. var glyphs = font.charsToGlyphs(chars);
  32849. for (var i = 0; i < glyphs.length; i++) {
  32850. var glyph = glyphs[i];
  32851. var glyphWidth = null;
  32852. if (font.vertical && glyph.vmetric) {
  32853. glyphWidth = glyph.vmetric[0];
  32854. } else {
  32855. glyphWidth = glyph.width;
  32856. }
  32857. var glyphUnicode = glyph.unicode;
  32858. var NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
  32859. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  32860. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  32861. }
  32862. glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode);
  32863. var charSpacing = textState.charSpacing;
  32864. if (glyph.isSpace) {
  32865. var wordSpacing = textState.wordSpacing;
  32866. charSpacing += wordSpacing;
  32867. if (wordSpacing > 0) {
  32868. addFakeSpaces(wordSpacing, textChunk.str);
  32869. }
  32870. }
  32871. var tx = 0;
  32872. var ty = 0;
  32873. if (!font.vertical) {
  32874. var w0 = glyphWidth * textState.fontMatrix[0];
  32875. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  32876. width += tx;
  32877. } else {
  32878. var w1 = glyphWidth * textState.fontMatrix[0];
  32879. ty = w1 * textState.fontSize + charSpacing;
  32880. height += ty;
  32881. }
  32882. textState.translateTextMatrix(tx, ty);
  32883. textChunk.str.push(glyphUnicode);
  32884. }
  32885. if (!font.vertical) {
  32886. textChunk.lastAdvanceWidth = width;
  32887. textChunk.width += width;
  32888. } else {
  32889. textChunk.lastAdvanceHeight = height;
  32890. textChunk.height += Math.abs(height);
  32891. }
  32892. return textChunk;
  32893. }
  32894. function addFakeSpaces(width, strBuf) {
  32895. if (width < textContentItem.fakeSpaceMin) {
  32896. return;
  32897. }
  32898. if (width < textContentItem.fakeMultiSpaceMin) {
  32899. strBuf.push(' ');
  32900. return;
  32901. }
  32902. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  32903. while (fakeSpaces-- > 0) {
  32904. strBuf.push(' ');
  32905. }
  32906. }
  32907. function flushTextContentItem() {
  32908. if (!textContentItem.initialized) {
  32909. return;
  32910. }
  32911. textContentItem.width *= textContentItem.textAdvanceScale;
  32912. textContentItem.height *= textContentItem.textAdvanceScale;
  32913. textContent.items.push(runBidiTransform(textContentItem));
  32914. textContentItem.initialized = false;
  32915. textContentItem.str.length = 0;
  32916. }
  32917. function enqueueChunk() {
  32918. var length = textContent.items.length;
  32919. if (length > 0) {
  32920. sink.enqueue(textContent, length);
  32921. textContent.items = [];
  32922. textContent.styles = Object.create(null);
  32923. }
  32924. }
  32925. var timeSlotManager = new TimeSlotManager();
  32926. return new Promise(function promiseBody(resolve, reject) {
  32927. var next = function next(promise) {
  32928. enqueueChunk();
  32929. Promise.all([promise, sink.ready]).then(function () {
  32930. try {
  32931. promiseBody(resolve, reject);
  32932. } catch (ex) {
  32933. reject(ex);
  32934. }
  32935. }, reject);
  32936. };
  32937. task.ensureNotTerminated();
  32938. timeSlotManager.reset();
  32939. var stop,
  32940. operation = {},
  32941. args = [];
  32942. while (!(stop = timeSlotManager.check())) {
  32943. args.length = 0;
  32944. operation.args = args;
  32945. if (!preprocessor.read(operation)) {
  32946. break;
  32947. }
  32948. textState = stateManager.state;
  32949. var fn = operation.fn;
  32950. args = operation.args;
  32951. var advance, diff;
  32952. switch (fn | 0) {
  32953. case _util.OPS.setFont:
  32954. var fontNameArg = args[0].name,
  32955. fontSizeArg = args[1];
  32956. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  32957. break;
  32958. }
  32959. flushTextContentItem();
  32960. textState.fontName = fontNameArg;
  32961. textState.fontSize = fontSizeArg;
  32962. next(handleSetFont(fontNameArg, null));
  32963. return;
  32964. case _util.OPS.setTextRise:
  32965. flushTextContentItem();
  32966. textState.textRise = args[0];
  32967. break;
  32968. case _util.OPS.setHScale:
  32969. flushTextContentItem();
  32970. textState.textHScale = args[0] / 100;
  32971. break;
  32972. case _util.OPS.setLeading:
  32973. flushTextContentItem();
  32974. textState.leading = args[0];
  32975. break;
  32976. case _util.OPS.moveText:
  32977. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  32978. advance = args[0] - args[1];
  32979. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  32980. textState.translateTextLineMatrix(args[0], args[1]);
  32981. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  32982. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  32983. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  32984. addFakeSpaces(diff, textContentItem.str);
  32985. break;
  32986. }
  32987. flushTextContentItem();
  32988. textState.translateTextLineMatrix(args[0], args[1]);
  32989. textState.textMatrix = textState.textLineMatrix.slice();
  32990. break;
  32991. case _util.OPS.setLeadingMoveText:
  32992. flushTextContentItem();
  32993. textState.leading = -args[1];
  32994. textState.translateTextLineMatrix(args[0], args[1]);
  32995. textState.textMatrix = textState.textLineMatrix.slice();
  32996. break;
  32997. case _util.OPS.nextLine:
  32998. flushTextContentItem();
  32999. textState.carriageReturn();
  33000. break;
  33001. case _util.OPS.setTextMatrix:
  33002. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  33003. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  33004. textState.translateTextLineMatrix(advance.width, advance.height);
  33005. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  33006. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  33007. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  33008. addFakeSpaces(diff, textContentItem.str);
  33009. break;
  33010. }
  33011. flushTextContentItem();
  33012. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  33013. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  33014. break;
  33015. case _util.OPS.setCharSpacing:
  33016. textState.charSpacing = args[0];
  33017. break;
  33018. case _util.OPS.setWordSpacing:
  33019. textState.wordSpacing = args[0];
  33020. break;
  33021. case _util.OPS.beginText:
  33022. flushTextContentItem();
  33023. textState.textMatrix = _util.IDENTITY_MATRIX.slice();
  33024. textState.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  33025. break;
  33026. case _util.OPS.showSpacedText:
  33027. var items = args[0];
  33028. var offset;
  33029. for (var j = 0, jj = items.length; j < jj; j++) {
  33030. if (typeof items[j] === 'string') {
  33031. buildTextContentItem(items[j]);
  33032. } else if ((0, _util.isNum)(items[j])) {
  33033. ensureTextContentItem();
  33034. advance = items[j] * textState.fontSize / 1000;
  33035. var breakTextRun = false;
  33036. if (textState.font.vertical) {
  33037. offset = advance;
  33038. textState.translateTextMatrix(0, offset);
  33039. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  33040. if (!breakTextRun) {
  33041. textContentItem.height += offset;
  33042. }
  33043. } else {
  33044. advance = -advance;
  33045. offset = advance * textState.textHScale;
  33046. textState.translateTextMatrix(offset, 0);
  33047. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  33048. if (!breakTextRun) {
  33049. textContentItem.width += offset;
  33050. }
  33051. }
  33052. if (breakTextRun) {
  33053. flushTextContentItem();
  33054. } else if (advance > 0) {
  33055. addFakeSpaces(advance, textContentItem.str);
  33056. }
  33057. }
  33058. }
  33059. break;
  33060. case _util.OPS.showText:
  33061. buildTextContentItem(args[0]);
  33062. break;
  33063. case _util.OPS.nextLineShowText:
  33064. flushTextContentItem();
  33065. textState.carriageReturn();
  33066. buildTextContentItem(args[0]);
  33067. break;
  33068. case _util.OPS.nextLineSetSpacingShowText:
  33069. flushTextContentItem();
  33070. textState.wordSpacing = args[0];
  33071. textState.charSpacing = args[1];
  33072. textState.carriageReturn();
  33073. buildTextContentItem(args[2]);
  33074. break;
  33075. case _util.OPS.paintXObject:
  33076. flushTextContentItem();
  33077. if (!xobjs) {
  33078. xobjs = resources.get('XObject') || _primitives.Dict.empty;
  33079. }
  33080. var name = args[0].name;
  33081. if (name && skipEmptyXObjs[name] !== undefined) {
  33082. break;
  33083. }
  33084. next(new Promise(function (resolveXObject, rejectXObject) {
  33085. if (!name) {
  33086. throw new _util.FormatError('XObject must be referred to by name.');
  33087. }
  33088. var xobj = xobjs.get(name);
  33089. if (!xobj) {
  33090. resolveXObject();
  33091. return;
  33092. }
  33093. if (!(0, _primitives.isStream)(xobj)) {
  33094. throw new _util.FormatError('XObject should be a stream');
  33095. }
  33096. var type = xobj.dict.get('Subtype');
  33097. if (!(0, _primitives.isName)(type)) {
  33098. throw new _util.FormatError('XObject should have a Name subtype');
  33099. }
  33100. if (type.name !== 'Form') {
  33101. skipEmptyXObjs[name] = true;
  33102. resolveXObject();
  33103. return;
  33104. }
  33105. var currentState = stateManager.state.clone();
  33106. var xObjStateManager = new StateManager(currentState);
  33107. var matrix = xobj.dict.getArray('Matrix');
  33108. if (Array.isArray(matrix) && matrix.length === 6) {
  33109. xObjStateManager.transform(matrix);
  33110. }
  33111. enqueueChunk();
  33112. var sinkWrapper = {
  33113. enqueueInvoked: false,
  33114. enqueue: function enqueue(chunk, size) {
  33115. this.enqueueInvoked = true;
  33116. sink.enqueue(chunk, size);
  33117. },
  33118. get desiredSize() {
  33119. return sink.desiredSize;
  33120. },
  33121. get ready() {
  33122. return sink.ready;
  33123. }
  33124. };
  33125. self.getTextContent({
  33126. stream: xobj,
  33127. task: task,
  33128. resources: xobj.dict.get('Resources') || resources,
  33129. stateManager: xObjStateManager,
  33130. normalizeWhitespace: normalizeWhitespace,
  33131. combineTextItems: combineTextItems,
  33132. sink: sinkWrapper,
  33133. seenStyles: seenStyles
  33134. }).then(function () {
  33135. if (!sinkWrapper.enqueueInvoked) {
  33136. skipEmptyXObjs[name] = true;
  33137. }
  33138. resolveXObject();
  33139. }, rejectXObject);
  33140. }).catch(function (reason) {
  33141. if (reason instanceof _util.AbortException) {
  33142. return;
  33143. }
  33144. if (self.options.ignoreErrors) {
  33145. (0, _util.warn)('getTextContent - ignoring XObject: "' + reason + '".');
  33146. return;
  33147. }
  33148. throw reason;
  33149. }));
  33150. return;
  33151. case _util.OPS.setGState:
  33152. flushTextContentItem();
  33153. var dictName = args[0];
  33154. var extGState = resources.get('ExtGState');
  33155. if (!(0, _primitives.isDict)(extGState) || !(0, _primitives.isName)(dictName)) {
  33156. break;
  33157. }
  33158. var gState = extGState.get(dictName.name);
  33159. if (!(0, _primitives.isDict)(gState)) {
  33160. break;
  33161. }
  33162. var gStateFont = gState.get('Font');
  33163. if (gStateFont) {
  33164. textState.fontName = null;
  33165. textState.fontSize = gStateFont[1];
  33166. next(handleSetFont(null, gStateFont[0]));
  33167. return;
  33168. }
  33169. break;
  33170. }
  33171. if (textContent.items.length >= sink.desiredSize) {
  33172. stop = true;
  33173. break;
  33174. }
  33175. }
  33176. if (stop) {
  33177. next(deferred);
  33178. return;
  33179. }
  33180. flushTextContentItem();
  33181. enqueueChunk();
  33182. resolve();
  33183. }).catch(function (reason) {
  33184. if (reason instanceof _util.AbortException) {
  33185. return;
  33186. }
  33187. if (_this9.options.ignoreErrors) {
  33188. (0, _util.warn)('getTextContent - ignoring errors during task: ' + task.name);
  33189. flushTextContentItem();
  33190. enqueueChunk();
  33191. return;
  33192. }
  33193. throw reason;
  33194. });
  33195. },
  33196. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
  33197. var _this10 = this;
  33198. var xref = this.xref;
  33199. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  33200. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  33201. if (properties.composite) {
  33202. var cidSystemInfo = dict.get('CIDSystemInfo');
  33203. if ((0, _primitives.isDict)(cidSystemInfo)) {
  33204. properties.cidSystemInfo = {
  33205. registry: cidSystemInfo.get('Registry'),
  33206. ordering: cidSystemInfo.get('Ordering'),
  33207. supplement: cidSystemInfo.get('Supplement')
  33208. };
  33209. }
  33210. var cidToGidMap = dict.get('CIDToGIDMap');
  33211. if ((0, _primitives.isStream)(cidToGidMap)) {
  33212. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  33213. }
  33214. }
  33215. var differences = [];
  33216. var baseEncodingName = null;
  33217. var encoding;
  33218. if (dict.has('Encoding')) {
  33219. encoding = dict.get('Encoding');
  33220. if ((0, _primitives.isDict)(encoding)) {
  33221. baseEncodingName = encoding.get('BaseEncoding');
  33222. baseEncodingName = (0, _primitives.isName)(baseEncodingName) ? baseEncodingName.name : null;
  33223. if (encoding.has('Differences')) {
  33224. var diffEncoding = encoding.get('Differences');
  33225. var index = 0;
  33226. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  33227. var data = xref.fetchIfRef(diffEncoding[j]);
  33228. if ((0, _util.isNum)(data)) {
  33229. index = data;
  33230. } else if ((0, _primitives.isName)(data)) {
  33231. differences[index++] = data.name;
  33232. } else {
  33233. throw new _util.FormatError('Invalid entry in \'Differences\' array: ' + data);
  33234. }
  33235. }
  33236. }
  33237. } else if ((0, _primitives.isName)(encoding)) {
  33238. baseEncodingName = encoding.name;
  33239. } else {
  33240. throw new _util.FormatError('Encoding is not a Name nor a Dict');
  33241. }
  33242. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  33243. baseEncodingName = null;
  33244. }
  33245. }
  33246. if (baseEncodingName) {
  33247. properties.defaultEncoding = (0, _encodings.getEncoding)(baseEncodingName).slice();
  33248. } else {
  33249. var isSymbolicFont = !!(properties.flags & _fonts.FontFlags.Symbolic);
  33250. var isNonsymbolicFont = !!(properties.flags & _fonts.FontFlags.Nonsymbolic);
  33251. encoding = _encodings.StandardEncoding;
  33252. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  33253. encoding = _encodings.WinAnsiEncoding;
  33254. }
  33255. if (isSymbolicFont) {
  33256. encoding = _encodings.MacRomanEncoding;
  33257. if (!properties.file) {
  33258. if (/Symbol/i.test(properties.name)) {
  33259. encoding = _encodings.SymbolSetEncoding;
  33260. } else if (/Dingbats/i.test(properties.name)) {
  33261. encoding = _encodings.ZapfDingbatsEncoding;
  33262. }
  33263. }
  33264. }
  33265. properties.defaultEncoding = encoding;
  33266. }
  33267. properties.differences = differences;
  33268. properties.baseEncodingName = baseEncodingName;
  33269. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  33270. properties.dict = dict;
  33271. return toUnicodePromise.then(function (toUnicode) {
  33272. properties.toUnicode = toUnicode;
  33273. return _this10.buildToUnicode(properties);
  33274. }).then(function (toUnicode) {
  33275. properties.toUnicode = toUnicode;
  33276. return properties;
  33277. });
  33278. },
  33279. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  33280. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  33281. if (properties.hasIncludedToUnicodeMap) {
  33282. return Promise.resolve(properties.toUnicode);
  33283. }
  33284. var toUnicode, charcode, glyphName;
  33285. if (!properties.composite) {
  33286. toUnicode = [];
  33287. var encoding = properties.defaultEncoding.slice();
  33288. var baseEncodingName = properties.baseEncodingName;
  33289. var differences = properties.differences;
  33290. for (charcode in differences) {
  33291. glyphName = differences[charcode];
  33292. if (glyphName === '.notdef') {
  33293. continue;
  33294. }
  33295. encoding[charcode] = glyphName;
  33296. }
  33297. var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  33298. for (charcode in encoding) {
  33299. glyphName = encoding[charcode];
  33300. if (glyphName === '') {
  33301. continue;
  33302. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  33303. var code = 0;
  33304. switch (glyphName[0]) {
  33305. case 'G':
  33306. if (glyphName.length === 3) {
  33307. code = parseInt(glyphName.substr(1), 16);
  33308. }
  33309. break;
  33310. case 'g':
  33311. if (glyphName.length === 5) {
  33312. code = parseInt(glyphName.substr(1), 16);
  33313. }
  33314. break;
  33315. case 'C':
  33316. case 'c':
  33317. if (glyphName.length >= 3) {
  33318. code = +glyphName.substr(1);
  33319. }
  33320. break;
  33321. default:
  33322. var unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  33323. if (unicode !== -1) {
  33324. code = unicode;
  33325. }
  33326. }
  33327. if (code) {
  33328. if (baseEncodingName && code === +charcode) {
  33329. var baseEncoding = (0, _encodings.getEncoding)(baseEncodingName);
  33330. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  33331. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  33332. continue;
  33333. }
  33334. }
  33335. toUnicode[charcode] = String.fromCharCode(code);
  33336. }
  33337. continue;
  33338. }
  33339. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  33340. }
  33341. return Promise.resolve(new _fonts.ToUnicodeMap(toUnicode));
  33342. }
  33343. if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof _cmap.IdentityCMap) || properties.cidSystemInfo.registry === 'Adobe' && (properties.cidSystemInfo.ordering === 'GB1' || properties.cidSystemInfo.ordering === 'CNS1' || properties.cidSystemInfo.ordering === 'Japan1' || properties.cidSystemInfo.ordering === 'Korea1'))) {
  33344. var registry = properties.cidSystemInfo.registry;
  33345. var ordering = properties.cidSystemInfo.ordering;
  33346. var ucs2CMapName = _primitives.Name.get(registry + '-' + ordering + '-UCS2');
  33347. return _cmap.CMapFactory.create({
  33348. encoding: ucs2CMapName,
  33349. fetchBuiltInCMap: this.fetchBuiltInCMap,
  33350. useCMap: null
  33351. }).then(function (ucs2CMap) {
  33352. var cMap = properties.cMap;
  33353. toUnicode = [];
  33354. cMap.forEach(function (charcode, cid) {
  33355. if (cid > 0xffff) {
  33356. throw new _util.FormatError('Max size of CID is 65,535');
  33357. }
  33358. var ucs2 = ucs2CMap.lookup(cid);
  33359. if (ucs2) {
  33360. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  33361. }
  33362. });
  33363. return new _fonts.ToUnicodeMap(toUnicode);
  33364. });
  33365. }
  33366. return Promise.resolve(new _fonts.IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  33367. },
  33368. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  33369. var cmapObj = toUnicode;
  33370. if ((0, _primitives.isName)(cmapObj)) {
  33371. return _cmap.CMapFactory.create({
  33372. encoding: cmapObj,
  33373. fetchBuiltInCMap: this.fetchBuiltInCMap,
  33374. useCMap: null
  33375. }).then(function (cmap) {
  33376. if (cmap instanceof _cmap.IdentityCMap) {
  33377. return new _fonts.IdentityToUnicodeMap(0, 0xFFFF);
  33378. }
  33379. return new _fonts.ToUnicodeMap(cmap.getMap());
  33380. });
  33381. } else if ((0, _primitives.isStream)(cmapObj)) {
  33382. return _cmap.CMapFactory.create({
  33383. encoding: cmapObj,
  33384. fetchBuiltInCMap: this.fetchBuiltInCMap,
  33385. useCMap: null
  33386. }).then(function (cmap) {
  33387. if (cmap instanceof _cmap.IdentityCMap) {
  33388. return new _fonts.IdentityToUnicodeMap(0, 0xFFFF);
  33389. }
  33390. var map = new Array(cmap.length);
  33391. cmap.forEach(function (charCode, token) {
  33392. var str = [];
  33393. for (var k = 0; k < token.length; k += 2) {
  33394. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  33395. if ((w1 & 0xF800) !== 0xD800) {
  33396. str.push(w1);
  33397. continue;
  33398. }
  33399. k += 2;
  33400. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  33401. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  33402. }
  33403. map[charCode] = String.fromCharCode.apply(String, str);
  33404. });
  33405. return new _fonts.ToUnicodeMap(map);
  33406. });
  33407. }
  33408. return Promise.resolve(null);
  33409. },
  33410. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  33411. var glyphsData = cidToGidStream.getBytes();
  33412. var result = [];
  33413. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  33414. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  33415. if (glyphID === 0) {
  33416. continue;
  33417. }
  33418. var code = j >> 1;
  33419. result[code] = glyphID;
  33420. }
  33421. return result;
  33422. },
  33423. extractWidths: function PartialEvaluator_extractWidths(dict, descriptor, properties) {
  33424. var xref = this.xref;
  33425. var glyphsWidths = [];
  33426. var defaultWidth = 0;
  33427. var glyphsVMetrics = [];
  33428. var defaultVMetrics;
  33429. var i, ii, j, jj, start, code, widths;
  33430. if (properties.composite) {
  33431. defaultWidth = dict.has('DW') ? dict.get('DW') : 1000;
  33432. widths = dict.get('W');
  33433. if (widths) {
  33434. for (i = 0, ii = widths.length; i < ii; i++) {
  33435. start = xref.fetchIfRef(widths[i++]);
  33436. code = xref.fetchIfRef(widths[i]);
  33437. if (Array.isArray(code)) {
  33438. for (j = 0, jj = code.length; j < jj; j++) {
  33439. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  33440. }
  33441. } else {
  33442. var width = xref.fetchIfRef(widths[++i]);
  33443. for (j = start; j <= code; j++) {
  33444. glyphsWidths[j] = width;
  33445. }
  33446. }
  33447. }
  33448. }
  33449. if (properties.vertical) {
  33450. var vmetrics = dict.getArray('DW2') || [880, -1000];
  33451. defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
  33452. vmetrics = dict.get('W2');
  33453. if (vmetrics) {
  33454. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  33455. start = xref.fetchIfRef(vmetrics[i++]);
  33456. code = xref.fetchIfRef(vmetrics[i]);
  33457. if (Array.isArray(code)) {
  33458. for (j = 0, jj = code.length; j < jj; j++) {
  33459. glyphsVMetrics[start++] = [xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j++]), xref.fetchIfRef(code[j])];
  33460. }
  33461. } else {
  33462. var vmetric = [xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i]), xref.fetchIfRef(vmetrics[++i])];
  33463. for (j = start; j <= code; j++) {
  33464. glyphsVMetrics[j] = vmetric;
  33465. }
  33466. }
  33467. }
  33468. }
  33469. }
  33470. } else {
  33471. var firstChar = properties.firstChar;
  33472. widths = dict.get('Widths');
  33473. if (widths) {
  33474. j = firstChar;
  33475. for (i = 0, ii = widths.length; i < ii; i++) {
  33476. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  33477. }
  33478. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  33479. } else {
  33480. var baseFontName = dict.get('BaseFont');
  33481. if ((0, _primitives.isName)(baseFontName)) {
  33482. var metrics = this.getBaseFontMetrics(baseFontName.name);
  33483. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  33484. defaultWidth = metrics.defaultWidth;
  33485. }
  33486. }
  33487. }
  33488. var isMonospace = true;
  33489. var firstWidth = defaultWidth;
  33490. for (var glyph in glyphsWidths) {
  33491. var glyphWidth = glyphsWidths[glyph];
  33492. if (!glyphWidth) {
  33493. continue;
  33494. }
  33495. if (!firstWidth) {
  33496. firstWidth = glyphWidth;
  33497. continue;
  33498. }
  33499. if (firstWidth !== glyphWidth) {
  33500. isMonospace = false;
  33501. break;
  33502. }
  33503. }
  33504. if (isMonospace) {
  33505. properties.flags |= _fonts.FontFlags.FixedPitch;
  33506. }
  33507. properties.defaultWidth = defaultWidth;
  33508. properties.widths = glyphsWidths;
  33509. properties.defaultVMetrics = defaultVMetrics;
  33510. properties.vmetrics = glyphsVMetrics;
  33511. },
  33512. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  33513. var fontNameWoStyle = baseFontName.split('-')[0];
  33514. return fontNameWoStyle in (0, _standard_fonts.getSerifFonts)() || fontNameWoStyle.search(/serif/gi) !== -1;
  33515. },
  33516. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  33517. var defaultWidth = 0;
  33518. var widths = [];
  33519. var monospace = false;
  33520. var stdFontMap = (0, _standard_fonts.getStdFontMap)();
  33521. var lookupName = stdFontMap[name] || name;
  33522. var Metrics = (0, _metrics.getMetrics)();
  33523. if (!(lookupName in Metrics)) {
  33524. if (this.isSerifFont(name)) {
  33525. lookupName = 'Times-Roman';
  33526. } else {
  33527. lookupName = 'Helvetica';
  33528. }
  33529. }
  33530. var glyphWidths = Metrics[lookupName];
  33531. if ((0, _util.isNum)(glyphWidths)) {
  33532. defaultWidth = glyphWidths;
  33533. monospace = true;
  33534. } else {
  33535. widths = glyphWidths();
  33536. }
  33537. return {
  33538. defaultWidth: defaultWidth,
  33539. monospace: monospace,
  33540. widths: widths
  33541. };
  33542. },
  33543. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  33544. var widths = Object.create(null);
  33545. var differences = properties.differences;
  33546. var encoding = properties.defaultEncoding;
  33547. for (var charCode = 0; charCode < 256; charCode++) {
  33548. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  33549. widths[charCode] = widthsByGlyphName[differences[charCode]];
  33550. continue;
  33551. }
  33552. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  33553. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  33554. continue;
  33555. }
  33556. }
  33557. return widths;
  33558. },
  33559. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict) {
  33560. var baseDict = dict;
  33561. var type = dict.get('Subtype');
  33562. if (!(0, _primitives.isName)(type)) {
  33563. throw new _util.FormatError('invalid font Subtype');
  33564. }
  33565. var composite = false;
  33566. var uint8array;
  33567. if (type.name === 'Type0') {
  33568. var df = dict.get('DescendantFonts');
  33569. if (!df) {
  33570. throw new _util.FormatError('Descendant fonts are not specified');
  33571. }
  33572. dict = Array.isArray(df) ? this.xref.fetchIfRef(df[0]) : df;
  33573. type = dict.get('Subtype');
  33574. if (!(0, _primitives.isName)(type)) {
  33575. throw new _util.FormatError('invalid font Subtype');
  33576. }
  33577. composite = true;
  33578. }
  33579. var descriptor = dict.get('FontDescriptor');
  33580. if (descriptor) {
  33581. var hash = new _murmurhash.MurmurHash3_64();
  33582. var encoding = baseDict.getRaw('Encoding');
  33583. if ((0, _primitives.isName)(encoding)) {
  33584. hash.update(encoding.name);
  33585. } else if ((0, _primitives.isRef)(encoding)) {
  33586. hash.update(encoding.toString());
  33587. } else if ((0, _primitives.isDict)(encoding)) {
  33588. var keys = encoding.getKeys();
  33589. for (var i = 0, ii = keys.length; i < ii; i++) {
  33590. var entry = encoding.getRaw(keys[i]);
  33591. if ((0, _primitives.isName)(entry)) {
  33592. hash.update(entry.name);
  33593. } else if ((0, _primitives.isRef)(entry)) {
  33594. hash.update(entry.toString());
  33595. } else if (Array.isArray(entry)) {
  33596. var diffLength = entry.length,
  33597. diffBuf = new Array(diffLength);
  33598. for (var j = 0; j < diffLength; j++) {
  33599. var diffEntry = entry[j];
  33600. if ((0, _primitives.isName)(diffEntry)) {
  33601. diffBuf[j] = diffEntry.name;
  33602. } else if ((0, _util.isNum)(diffEntry) || (0, _primitives.isRef)(diffEntry)) {
  33603. diffBuf[j] = diffEntry.toString();
  33604. }
  33605. }
  33606. hash.update(diffBuf.join());
  33607. }
  33608. }
  33609. }
  33610. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  33611. if ((0, _primitives.isStream)(toUnicode)) {
  33612. var stream = toUnicode.str || toUnicode;
  33613. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  33614. hash.update(uint8array);
  33615. } else if ((0, _primitives.isName)(toUnicode)) {
  33616. hash.update(toUnicode.name);
  33617. }
  33618. var widths = dict.get('Widths') || baseDict.get('Widths');
  33619. if (widths) {
  33620. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  33621. hash.update(uint8array);
  33622. }
  33623. }
  33624. return {
  33625. descriptor: descriptor,
  33626. dict: dict,
  33627. baseDict: baseDict,
  33628. composite: composite,
  33629. type: type.name,
  33630. hash: hash ? hash.hexdigest() : ''
  33631. };
  33632. },
  33633. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont) {
  33634. var _this11 = this;
  33635. var baseDict = preEvaluatedFont.baseDict;
  33636. var dict = preEvaluatedFont.dict;
  33637. var composite = preEvaluatedFont.composite;
  33638. var descriptor = preEvaluatedFont.descriptor;
  33639. var type = preEvaluatedFont.type;
  33640. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  33641. var properties;
  33642. if (!descriptor) {
  33643. if (type === 'Type3') {
  33644. descriptor = new _primitives.Dict(null);
  33645. descriptor.set('FontName', _primitives.Name.get(type));
  33646. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  33647. } else {
  33648. var baseFontName = dict.get('BaseFont');
  33649. if (!(0, _primitives.isName)(baseFontName)) {
  33650. throw new _util.FormatError('Base font is not specified');
  33651. }
  33652. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  33653. var metrics = this.getBaseFontMetrics(baseFontName);
  33654. var fontNameWoStyle = baseFontName.split('-')[0];
  33655. var flags = (this.isSerifFont(fontNameWoStyle) ? _fonts.FontFlags.Serif : 0) | (metrics.monospace ? _fonts.FontFlags.FixedPitch : 0) | ((0, _standard_fonts.getSymbolsFonts)()[fontNameWoStyle] ? _fonts.FontFlags.Symbolic : _fonts.FontFlags.Nonsymbolic);
  33656. properties = {
  33657. type: type,
  33658. name: baseFontName,
  33659. widths: metrics.widths,
  33660. defaultWidth: metrics.defaultWidth,
  33661. flags: flags,
  33662. firstChar: 0,
  33663. lastChar: maxCharIndex
  33664. };
  33665. return this.extractDataStructures(dict, dict, properties).then(function (properties) {
  33666. properties.widths = _this11.buildCharCodeToWidth(metrics.widths, properties);
  33667. return new _fonts.Font(baseFontName, null, properties);
  33668. });
  33669. }
  33670. }
  33671. var firstChar = dict.get('FirstChar') || 0;
  33672. var lastChar = dict.get('LastChar') || maxCharIndex;
  33673. var fontName = descriptor.get('FontName');
  33674. var baseFont = dict.get('BaseFont');
  33675. if ((0, _util.isString)(fontName)) {
  33676. fontName = _primitives.Name.get(fontName);
  33677. }
  33678. if ((0, _util.isString)(baseFont)) {
  33679. baseFont = _primitives.Name.get(baseFont);
  33680. }
  33681. if (type !== 'Type3') {
  33682. var fontNameStr = fontName && fontName.name;
  33683. var baseFontStr = baseFont && baseFont.name;
  33684. if (fontNameStr !== baseFontStr) {
  33685. (0, _util.info)('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  33686. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  33687. fontName = baseFont;
  33688. }
  33689. }
  33690. }
  33691. fontName = fontName || baseFont;
  33692. if (!(0, _primitives.isName)(fontName)) {
  33693. throw new _util.FormatError('invalid font name');
  33694. }
  33695. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  33696. if (fontFile) {
  33697. if (fontFile.dict) {
  33698. var subtype = fontFile.dict.get('Subtype');
  33699. if (subtype) {
  33700. subtype = subtype.name;
  33701. }
  33702. var length1 = fontFile.dict.get('Length1');
  33703. var length2 = fontFile.dict.get('Length2');
  33704. var length3 = fontFile.dict.get('Length3');
  33705. }
  33706. }
  33707. properties = {
  33708. type: type,
  33709. name: fontName.name,
  33710. subtype: subtype,
  33711. file: fontFile,
  33712. length1: length1,
  33713. length2: length2,
  33714. length3: length3,
  33715. loadedName: baseDict.loadedName,
  33716. composite: composite,
  33717. wideChars: composite,
  33718. fixedPitch: false,
  33719. fontMatrix: dict.getArray('FontMatrix') || _util.FONT_IDENTITY_MATRIX,
  33720. firstChar: firstChar || 0,
  33721. lastChar: lastChar || maxCharIndex,
  33722. bbox: descriptor.getArray('FontBBox'),
  33723. ascent: descriptor.get('Ascent'),
  33724. descent: descriptor.get('Descent'),
  33725. xHeight: descriptor.get('XHeight'),
  33726. capHeight: descriptor.get('CapHeight'),
  33727. flags: descriptor.get('Flags'),
  33728. italicAngle: descriptor.get('ItalicAngle'),
  33729. isType3Font: false
  33730. };
  33731. var cMapPromise;
  33732. if (composite) {
  33733. var cidEncoding = baseDict.get('Encoding');
  33734. if ((0, _primitives.isName)(cidEncoding)) {
  33735. properties.cidEncoding = cidEncoding.name;
  33736. }
  33737. cMapPromise = _cmap.CMapFactory.create({
  33738. encoding: cidEncoding,
  33739. fetchBuiltInCMap: this.fetchBuiltInCMap,
  33740. useCMap: null
  33741. }).then(function (cMap) {
  33742. properties.cMap = cMap;
  33743. properties.vertical = properties.cMap.vertical;
  33744. });
  33745. } else {
  33746. cMapPromise = Promise.resolve(undefined);
  33747. }
  33748. return cMapPromise.then(function () {
  33749. return _this11.extractDataStructures(dict, baseDict, properties);
  33750. }).then(function (properties) {
  33751. _this11.extractWidths(dict, descriptor, properties);
  33752. if (type === 'Type3') {
  33753. properties.isType3Font = true;
  33754. }
  33755. return new _fonts.Font(fontName.name, fontFile, properties);
  33756. });
  33757. }
  33758. };
  33759. return PartialEvaluator;
  33760. }();
  33761. var TranslatedFont = function TranslatedFontClosure() {
  33762. function TranslatedFont(loadedName, font, dict) {
  33763. this.loadedName = loadedName;
  33764. this.font = font;
  33765. this.dict = dict;
  33766. this.type3Loaded = null;
  33767. this.sent = false;
  33768. }
  33769. TranslatedFont.prototype = {
  33770. send: function send(handler) {
  33771. if (this.sent) {
  33772. return;
  33773. }
  33774. var fontData = this.font.exportData();
  33775. handler.send('commonobj', [this.loadedName, 'Font', fontData]);
  33776. this.sent = true;
  33777. },
  33778. loadType3Data: function loadType3Data(evaluator, resources, parentOperatorList, task) {
  33779. if (!this.font.isType3Font) {
  33780. throw new Error('Must be a Type3 font.');
  33781. }
  33782. if (this.type3Loaded) {
  33783. return this.type3Loaded;
  33784. }
  33785. var type3Options = Object.create(evaluator.options);
  33786. type3Options.ignoreErrors = false;
  33787. var type3Evaluator = evaluator.clone(type3Options);
  33788. var translatedFont = this.font;
  33789. var loadCharProcsPromise = Promise.resolve();
  33790. var charProcs = this.dict.get('CharProcs');
  33791. var fontResources = this.dict.get('Resources') || resources;
  33792. var charProcKeys = charProcs.getKeys();
  33793. var charProcOperatorList = Object.create(null);
  33794. var _loop2 = function _loop2() {
  33795. var key = charProcKeys[i];
  33796. loadCharProcsPromise = loadCharProcsPromise.then(function () {
  33797. var glyphStream = charProcs.get(key);
  33798. var operatorList = new _operator_list.OperatorList();
  33799. return type3Evaluator.getOperatorList({
  33800. stream: glyphStream,
  33801. task: task,
  33802. resources: fontResources,
  33803. operatorList: operatorList
  33804. }).then(function () {
  33805. charProcOperatorList[key] = operatorList.getIR();
  33806. parentOperatorList.addDependencies(operatorList.dependencies);
  33807. }).catch(function (reason) {
  33808. (0, _util.warn)('Type3 font resource "' + key + '" is not available.');
  33809. var operatorList = new _operator_list.OperatorList();
  33810. charProcOperatorList[key] = operatorList.getIR();
  33811. });
  33812. });
  33813. };
  33814. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  33815. _loop2();
  33816. }
  33817. this.type3Loaded = loadCharProcsPromise.then(function () {
  33818. translatedFont.charProcOperatorList = charProcOperatorList;
  33819. });
  33820. return this.type3Loaded;
  33821. }
  33822. };
  33823. return TranslatedFont;
  33824. }();
  33825. var StateManager = function StateManagerClosure() {
  33826. function StateManager(initialState) {
  33827. this.state = initialState;
  33828. this.stateStack = [];
  33829. }
  33830. StateManager.prototype = {
  33831. save: function save() {
  33832. var old = this.state;
  33833. this.stateStack.push(this.state);
  33834. this.state = old.clone();
  33835. },
  33836. restore: function restore() {
  33837. var prev = this.stateStack.pop();
  33838. if (prev) {
  33839. this.state = prev;
  33840. }
  33841. },
  33842. transform: function transform(args) {
  33843. this.state.ctm = _util.Util.transform(this.state.ctm, args);
  33844. }
  33845. };
  33846. return StateManager;
  33847. }();
  33848. var TextState = function TextStateClosure() {
  33849. function TextState() {
  33850. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  33851. this.fontName = null;
  33852. this.fontSize = 0;
  33853. this.font = null;
  33854. this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
  33855. this.textMatrix = _util.IDENTITY_MATRIX.slice();
  33856. this.textLineMatrix = _util.IDENTITY_MATRIX.slice();
  33857. this.charSpacing = 0;
  33858. this.wordSpacing = 0;
  33859. this.leading = 0;
  33860. this.textHScale = 1;
  33861. this.textRise = 0;
  33862. }
  33863. TextState.prototype = {
  33864. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  33865. var m = this.textMatrix;
  33866. m[0] = a;
  33867. m[1] = b;
  33868. m[2] = c;
  33869. m[3] = d;
  33870. m[4] = e;
  33871. m[5] = f;
  33872. },
  33873. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  33874. var m = this.textLineMatrix;
  33875. m[0] = a;
  33876. m[1] = b;
  33877. m[2] = c;
  33878. m[3] = d;
  33879. m[4] = e;
  33880. m[5] = f;
  33881. },
  33882. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  33883. var m = this.textMatrix;
  33884. m[4] = m[0] * x + m[2] * y + m[4];
  33885. m[5] = m[1] * x + m[3] * y + m[5];
  33886. },
  33887. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  33888. var m = this.textLineMatrix;
  33889. m[4] = m[0] * x + m[2] * y + m[4];
  33890. m[5] = m[1] * x + m[3] * y + m[5];
  33891. },
  33892. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  33893. var font = this.font;
  33894. if (!font) {
  33895. return null;
  33896. }
  33897. var m = this.textLineMatrix;
  33898. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  33899. return null;
  33900. }
  33901. var txDiff = e - m[4],
  33902. tyDiff = f - m[5];
  33903. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  33904. return null;
  33905. }
  33906. var tx,
  33907. ty,
  33908. denominator = a * d - b * c;
  33909. if (font.vertical) {
  33910. tx = -tyDiff * c / denominator;
  33911. ty = tyDiff * a / denominator;
  33912. } else {
  33913. tx = txDiff * d / denominator;
  33914. ty = -txDiff * b / denominator;
  33915. }
  33916. return {
  33917. width: tx,
  33918. height: ty,
  33919. value: font.vertical ? ty : tx
  33920. };
  33921. },
  33922. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  33923. var tsm = [this.fontSize * this.textHScale, 0, 0, this.fontSize, 0, this.textRise];
  33924. return _util.Util.transform(ctm, _util.Util.transform(this.textMatrix, tsm));
  33925. },
  33926. carriageReturn: function TextState_carriageReturn() {
  33927. this.translateTextLineMatrix(0, -this.leading);
  33928. this.textMatrix = this.textLineMatrix.slice();
  33929. },
  33930. clone: function TextState_clone() {
  33931. var clone = Object.create(this);
  33932. clone.textMatrix = this.textMatrix.slice();
  33933. clone.textLineMatrix = this.textLineMatrix.slice();
  33934. clone.fontMatrix = this.fontMatrix.slice();
  33935. return clone;
  33936. }
  33937. };
  33938. return TextState;
  33939. }();
  33940. var EvalState = function EvalStateClosure() {
  33941. function EvalState() {
  33942. this.ctm = new Float32Array(_util.IDENTITY_MATRIX);
  33943. this.font = null;
  33944. this.textRenderingMode = _util.TextRenderingMode.FILL;
  33945. this.fillColorSpace = _colorspace.ColorSpace.singletons.gray;
  33946. this.strokeColorSpace = _colorspace.ColorSpace.singletons.gray;
  33947. }
  33948. EvalState.prototype = {
  33949. clone: function CanvasExtraState_clone() {
  33950. return Object.create(this);
  33951. }
  33952. };
  33953. return EvalState;
  33954. }();
  33955. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  33956. var getOPMap = (0, _util.getLookupTableFactory)(function (t) {
  33957. t['w'] = {
  33958. id: _util.OPS.setLineWidth,
  33959. numArgs: 1,
  33960. variableArgs: false
  33961. };
  33962. t['J'] = {
  33963. id: _util.OPS.setLineCap,
  33964. numArgs: 1,
  33965. variableArgs: false
  33966. };
  33967. t['j'] = {
  33968. id: _util.OPS.setLineJoin,
  33969. numArgs: 1,
  33970. variableArgs: false
  33971. };
  33972. t['M'] = {
  33973. id: _util.OPS.setMiterLimit,
  33974. numArgs: 1,
  33975. variableArgs: false
  33976. };
  33977. t['d'] = {
  33978. id: _util.OPS.setDash,
  33979. numArgs: 2,
  33980. variableArgs: false
  33981. };
  33982. t['ri'] = {
  33983. id: _util.OPS.setRenderingIntent,
  33984. numArgs: 1,
  33985. variableArgs: false
  33986. };
  33987. t['i'] = {
  33988. id: _util.OPS.setFlatness,
  33989. numArgs: 1,
  33990. variableArgs: false
  33991. };
  33992. t['gs'] = {
  33993. id: _util.OPS.setGState,
  33994. numArgs: 1,
  33995. variableArgs: false
  33996. };
  33997. t['q'] = {
  33998. id: _util.OPS.save,
  33999. numArgs: 0,
  34000. variableArgs: false
  34001. };
  34002. t['Q'] = {
  34003. id: _util.OPS.restore,
  34004. numArgs: 0,
  34005. variableArgs: false
  34006. };
  34007. t['cm'] = {
  34008. id: _util.OPS.transform,
  34009. numArgs: 6,
  34010. variableArgs: false
  34011. };
  34012. t['m'] = {
  34013. id: _util.OPS.moveTo,
  34014. numArgs: 2,
  34015. variableArgs: false
  34016. };
  34017. t['l'] = {
  34018. id: _util.OPS.lineTo,
  34019. numArgs: 2,
  34020. variableArgs: false
  34021. };
  34022. t['c'] = {
  34023. id: _util.OPS.curveTo,
  34024. numArgs: 6,
  34025. variableArgs: false
  34026. };
  34027. t['v'] = {
  34028. id: _util.OPS.curveTo2,
  34029. numArgs: 4,
  34030. variableArgs: false
  34031. };
  34032. t['y'] = {
  34033. id: _util.OPS.curveTo3,
  34034. numArgs: 4,
  34035. variableArgs: false
  34036. };
  34037. t['h'] = {
  34038. id: _util.OPS.closePath,
  34039. numArgs: 0,
  34040. variableArgs: false
  34041. };
  34042. t['re'] = {
  34043. id: _util.OPS.rectangle,
  34044. numArgs: 4,
  34045. variableArgs: false
  34046. };
  34047. t['S'] = {
  34048. id: _util.OPS.stroke,
  34049. numArgs: 0,
  34050. variableArgs: false
  34051. };
  34052. t['s'] = {
  34053. id: _util.OPS.closeStroke,
  34054. numArgs: 0,
  34055. variableArgs: false
  34056. };
  34057. t['f'] = {
  34058. id: _util.OPS.fill,
  34059. numArgs: 0,
  34060. variableArgs: false
  34061. };
  34062. t['F'] = {
  34063. id: _util.OPS.fill,
  34064. numArgs: 0,
  34065. variableArgs: false
  34066. };
  34067. t['f*'] = {
  34068. id: _util.OPS.eoFill,
  34069. numArgs: 0,
  34070. variableArgs: false
  34071. };
  34072. t['B'] = {
  34073. id: _util.OPS.fillStroke,
  34074. numArgs: 0,
  34075. variableArgs: false
  34076. };
  34077. t['B*'] = {
  34078. id: _util.OPS.eoFillStroke,
  34079. numArgs: 0,
  34080. variableArgs: false
  34081. };
  34082. t['b'] = {
  34083. id: _util.OPS.closeFillStroke,
  34084. numArgs: 0,
  34085. variableArgs: false
  34086. };
  34087. t['b*'] = {
  34088. id: _util.OPS.closeEOFillStroke,
  34089. numArgs: 0,
  34090. variableArgs: false
  34091. };
  34092. t['n'] = {
  34093. id: _util.OPS.endPath,
  34094. numArgs: 0,
  34095. variableArgs: false
  34096. };
  34097. t['W'] = {
  34098. id: _util.OPS.clip,
  34099. numArgs: 0,
  34100. variableArgs: false
  34101. };
  34102. t['W*'] = {
  34103. id: _util.OPS.eoClip,
  34104. numArgs: 0,
  34105. variableArgs: false
  34106. };
  34107. t['BT'] = {
  34108. id: _util.OPS.beginText,
  34109. numArgs: 0,
  34110. variableArgs: false
  34111. };
  34112. t['ET'] = {
  34113. id: _util.OPS.endText,
  34114. numArgs: 0,
  34115. variableArgs: false
  34116. };
  34117. t['Tc'] = {
  34118. id: _util.OPS.setCharSpacing,
  34119. numArgs: 1,
  34120. variableArgs: false
  34121. };
  34122. t['Tw'] = {
  34123. id: _util.OPS.setWordSpacing,
  34124. numArgs: 1,
  34125. variableArgs: false
  34126. };
  34127. t['Tz'] = {
  34128. id: _util.OPS.setHScale,
  34129. numArgs: 1,
  34130. variableArgs: false
  34131. };
  34132. t['TL'] = {
  34133. id: _util.OPS.setLeading,
  34134. numArgs: 1,
  34135. variableArgs: false
  34136. };
  34137. t['Tf'] = {
  34138. id: _util.OPS.setFont,
  34139. numArgs: 2,
  34140. variableArgs: false
  34141. };
  34142. t['Tr'] = {
  34143. id: _util.OPS.setTextRenderingMode,
  34144. numArgs: 1,
  34145. variableArgs: false
  34146. };
  34147. t['Ts'] = {
  34148. id: _util.OPS.setTextRise,
  34149. numArgs: 1,
  34150. variableArgs: false
  34151. };
  34152. t['Td'] = {
  34153. id: _util.OPS.moveText,
  34154. numArgs: 2,
  34155. variableArgs: false
  34156. };
  34157. t['TD'] = {
  34158. id: _util.OPS.setLeadingMoveText,
  34159. numArgs: 2,
  34160. variableArgs: false
  34161. };
  34162. t['Tm'] = {
  34163. id: _util.OPS.setTextMatrix,
  34164. numArgs: 6,
  34165. variableArgs: false
  34166. };
  34167. t['T*'] = {
  34168. id: _util.OPS.nextLine,
  34169. numArgs: 0,
  34170. variableArgs: false
  34171. };
  34172. t['Tj'] = {
  34173. id: _util.OPS.showText,
  34174. numArgs: 1,
  34175. variableArgs: false
  34176. };
  34177. t['TJ'] = {
  34178. id: _util.OPS.showSpacedText,
  34179. numArgs: 1,
  34180. variableArgs: false
  34181. };
  34182. t['\''] = {
  34183. id: _util.OPS.nextLineShowText,
  34184. numArgs: 1,
  34185. variableArgs: false
  34186. };
  34187. t['"'] = {
  34188. id: _util.OPS.nextLineSetSpacingShowText,
  34189. numArgs: 3,
  34190. variableArgs: false
  34191. };
  34192. t['d0'] = {
  34193. id: _util.OPS.setCharWidth,
  34194. numArgs: 2,
  34195. variableArgs: false
  34196. };
  34197. t['d1'] = {
  34198. id: _util.OPS.setCharWidthAndBounds,
  34199. numArgs: 6,
  34200. variableArgs: false
  34201. };
  34202. t['CS'] = {
  34203. id: _util.OPS.setStrokeColorSpace,
  34204. numArgs: 1,
  34205. variableArgs: false
  34206. };
  34207. t['cs'] = {
  34208. id: _util.OPS.setFillColorSpace,
  34209. numArgs: 1,
  34210. variableArgs: false
  34211. };
  34212. t['SC'] = {
  34213. id: _util.OPS.setStrokeColor,
  34214. numArgs: 4,
  34215. variableArgs: true
  34216. };
  34217. t['SCN'] = {
  34218. id: _util.OPS.setStrokeColorN,
  34219. numArgs: 33,
  34220. variableArgs: true
  34221. };
  34222. t['sc'] = {
  34223. id: _util.OPS.setFillColor,
  34224. numArgs: 4,
  34225. variableArgs: true
  34226. };
  34227. t['scn'] = {
  34228. id: _util.OPS.setFillColorN,
  34229. numArgs: 33,
  34230. variableArgs: true
  34231. };
  34232. t['G'] = {
  34233. id: _util.OPS.setStrokeGray,
  34234. numArgs: 1,
  34235. variableArgs: false
  34236. };
  34237. t['g'] = {
  34238. id: _util.OPS.setFillGray,
  34239. numArgs: 1,
  34240. variableArgs: false
  34241. };
  34242. t['RG'] = {
  34243. id: _util.OPS.setStrokeRGBColor,
  34244. numArgs: 3,
  34245. variableArgs: false
  34246. };
  34247. t['rg'] = {
  34248. id: _util.OPS.setFillRGBColor,
  34249. numArgs: 3,
  34250. variableArgs: false
  34251. };
  34252. t['K'] = {
  34253. id: _util.OPS.setStrokeCMYKColor,
  34254. numArgs: 4,
  34255. variableArgs: false
  34256. };
  34257. t['k'] = {
  34258. id: _util.OPS.setFillCMYKColor,
  34259. numArgs: 4,
  34260. variableArgs: false
  34261. };
  34262. t['sh'] = {
  34263. id: _util.OPS.shadingFill,
  34264. numArgs: 1,
  34265. variableArgs: false
  34266. };
  34267. t['BI'] = {
  34268. id: _util.OPS.beginInlineImage,
  34269. numArgs: 0,
  34270. variableArgs: false
  34271. };
  34272. t['ID'] = {
  34273. id: _util.OPS.beginImageData,
  34274. numArgs: 0,
  34275. variableArgs: false
  34276. };
  34277. t['EI'] = {
  34278. id: _util.OPS.endInlineImage,
  34279. numArgs: 1,
  34280. variableArgs: false
  34281. };
  34282. t['Do'] = {
  34283. id: _util.OPS.paintXObject,
  34284. numArgs: 1,
  34285. variableArgs: false
  34286. };
  34287. t['MP'] = {
  34288. id: _util.OPS.markPoint,
  34289. numArgs: 1,
  34290. variableArgs: false
  34291. };
  34292. t['DP'] = {
  34293. id: _util.OPS.markPointProps,
  34294. numArgs: 2,
  34295. variableArgs: false
  34296. };
  34297. t['BMC'] = {
  34298. id: _util.OPS.beginMarkedContent,
  34299. numArgs: 1,
  34300. variableArgs: false
  34301. };
  34302. t['BDC'] = {
  34303. id: _util.OPS.beginMarkedContentProps,
  34304. numArgs: 2,
  34305. variableArgs: false
  34306. };
  34307. t['EMC'] = {
  34308. id: _util.OPS.endMarkedContent,
  34309. numArgs: 0,
  34310. variableArgs: false
  34311. };
  34312. t['BX'] = {
  34313. id: _util.OPS.beginCompat,
  34314. numArgs: 0,
  34315. variableArgs: false
  34316. };
  34317. t['EX'] = {
  34318. id: _util.OPS.endCompat,
  34319. numArgs: 0,
  34320. variableArgs: false
  34321. };
  34322. t['BM'] = null;
  34323. t['BD'] = null;
  34324. t['true'] = null;
  34325. t['fa'] = null;
  34326. t['fal'] = null;
  34327. t['fals'] = null;
  34328. t['false'] = null;
  34329. t['nu'] = null;
  34330. t['nul'] = null;
  34331. t['null'] = null;
  34332. });
  34333. function EvaluatorPreprocessor(stream, xref, stateManager) {
  34334. this.opMap = getOPMap();
  34335. this.parser = new _parser.Parser(new _parser.Lexer(stream, this.opMap), false, xref);
  34336. this.stateManager = stateManager;
  34337. this.nonProcessedArgs = [];
  34338. }
  34339. EvaluatorPreprocessor.prototype = {
  34340. get savedStatesDepth() {
  34341. return this.stateManager.stateStack.length;
  34342. },
  34343. read: function EvaluatorPreprocessor_read(operation) {
  34344. var args = operation.args;
  34345. while (true) {
  34346. var obj = this.parser.getObj();
  34347. if ((0, _primitives.isCmd)(obj)) {
  34348. var cmd = obj.cmd;
  34349. var opSpec = this.opMap[cmd];
  34350. if (!opSpec) {
  34351. (0, _util.warn)('Unknown command "' + cmd + '"');
  34352. continue;
  34353. }
  34354. var fn = opSpec.id;
  34355. var numArgs = opSpec.numArgs;
  34356. var argsLength = args !== null ? args.length : 0;
  34357. if (!opSpec.variableArgs) {
  34358. if (argsLength !== numArgs) {
  34359. var nonProcessedArgs = this.nonProcessedArgs;
  34360. while (argsLength > numArgs) {
  34361. nonProcessedArgs.push(args.shift());
  34362. argsLength--;
  34363. }
  34364. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  34365. if (args === null) {
  34366. args = [];
  34367. }
  34368. args.unshift(nonProcessedArgs.pop());
  34369. argsLength++;
  34370. }
  34371. }
  34372. if (argsLength < numArgs) {
  34373. (0, _util.warn)('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  34374. if (args !== null) {
  34375. args.length = 0;
  34376. }
  34377. continue;
  34378. }
  34379. } else if (argsLength > numArgs) {
  34380. (0, _util.info)('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  34381. }
  34382. this.preprocessCommand(fn, args);
  34383. operation.fn = fn;
  34384. operation.args = args;
  34385. return true;
  34386. }
  34387. if ((0, _primitives.isEOF)(obj)) {
  34388. return false;
  34389. }
  34390. if (obj !== null) {
  34391. if (args === null) {
  34392. args = [];
  34393. }
  34394. args.push(obj);
  34395. if (args.length > 33) {
  34396. throw new _util.FormatError('Too many arguments');
  34397. }
  34398. }
  34399. }
  34400. },
  34401. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  34402. switch (fn | 0) {
  34403. case _util.OPS.save:
  34404. this.stateManager.save();
  34405. break;
  34406. case _util.OPS.restore:
  34407. this.stateManager.restore();
  34408. break;
  34409. case _util.OPS.transform:
  34410. this.stateManager.transform(args);
  34411. break;
  34412. }
  34413. }
  34414. };
  34415. return EvaluatorPreprocessor;
  34416. }();
  34417. exports.PartialEvaluator = PartialEvaluator;
  34418. /***/ }),
  34419. /* 131 */
  34420. /***/ (function(module, exports, __w_pdfjs_require__) {
  34421. "use strict";
  34422. Object.defineProperty(exports, "__esModule", {
  34423. value: true
  34424. });
  34425. exports.CMapFactory = exports.IdentityCMap = exports.CMap = undefined;
  34426. var _util = __w_pdfjs_require__(0);
  34427. var _primitives = __w_pdfjs_require__(1);
  34428. var _parser = __w_pdfjs_require__(26);
  34429. var _stream = __w_pdfjs_require__(5);
  34430. 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'];
  34431. var CMap = function CMapClosure() {
  34432. function CMap(builtInCMap) {
  34433. this.codespaceRanges = [[], [], [], []];
  34434. this.numCodespaceRanges = 0;
  34435. this._map = [];
  34436. this.name = '';
  34437. this.vertical = false;
  34438. this.useCMap = null;
  34439. this.builtInCMap = builtInCMap;
  34440. }
  34441. CMap.prototype = {
  34442. addCodespaceRange: function addCodespaceRange(n, low, high) {
  34443. this.codespaceRanges[n - 1].push(low, high);
  34444. this.numCodespaceRanges++;
  34445. },
  34446. mapCidRange: function mapCidRange(low, high, dstLow) {
  34447. while (low <= high) {
  34448. this._map[low++] = dstLow++;
  34449. }
  34450. },
  34451. mapBfRange: function mapBfRange(low, high, dstLow) {
  34452. var lastByte = dstLow.length - 1;
  34453. while (low <= high) {
  34454. this._map[low++] = dstLow;
  34455. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  34456. }
  34457. },
  34458. mapBfRangeToArray: function mapBfRangeToArray(low, high, array) {
  34459. var i = 0,
  34460. ii = array.length;
  34461. while (low <= high && i < ii) {
  34462. this._map[low] = array[i++];
  34463. ++low;
  34464. }
  34465. },
  34466. mapOne: function mapOne(src, dst) {
  34467. this._map[src] = dst;
  34468. },
  34469. lookup: function lookup(code) {
  34470. return this._map[code];
  34471. },
  34472. contains: function contains(code) {
  34473. return this._map[code] !== undefined;
  34474. },
  34475. forEach: function forEach(callback) {
  34476. var map = this._map;
  34477. var length = map.length;
  34478. if (length <= 0x10000) {
  34479. for (var i = 0; i < length; i++) {
  34480. if (map[i] !== undefined) {
  34481. callback(i, map[i]);
  34482. }
  34483. }
  34484. } else {
  34485. for (var _i in map) {
  34486. callback(_i, map[_i]);
  34487. }
  34488. }
  34489. },
  34490. charCodeOf: function charCodeOf(value) {
  34491. var map = this._map;
  34492. if (map.length <= 0x10000) {
  34493. return map.indexOf(value);
  34494. }
  34495. for (var charCode in map) {
  34496. if (map[charCode] === value) {
  34497. return charCode | 0;
  34498. }
  34499. }
  34500. return -1;
  34501. },
  34502. getMap: function getMap() {
  34503. return this._map;
  34504. },
  34505. readCharCode: function readCharCode(str, offset, out) {
  34506. var c = 0;
  34507. var codespaceRanges = this.codespaceRanges;
  34508. var codespaceRangesLen = this.codespaceRanges.length;
  34509. for (var n = 0; n < codespaceRangesLen; n++) {
  34510. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  34511. var codespaceRange = codespaceRanges[n];
  34512. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  34513. var low = codespaceRange[k++];
  34514. var high = codespaceRange[k++];
  34515. if (c >= low && c <= high) {
  34516. out.charcode = c;
  34517. out.length = n + 1;
  34518. return;
  34519. }
  34520. }
  34521. }
  34522. out.charcode = 0;
  34523. out.length = 1;
  34524. },
  34525. get length() {
  34526. return this._map.length;
  34527. },
  34528. get isIdentityCMap() {
  34529. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  34530. return false;
  34531. }
  34532. if (this._map.length !== 0x10000) {
  34533. return false;
  34534. }
  34535. for (var i = 0; i < 0x10000; i++) {
  34536. if (this._map[i] !== i) {
  34537. return false;
  34538. }
  34539. }
  34540. return true;
  34541. }
  34542. };
  34543. return CMap;
  34544. }();
  34545. var IdentityCMap = function IdentityCMapClosure() {
  34546. function IdentityCMap(vertical, n) {
  34547. CMap.call(this);
  34548. this.vertical = vertical;
  34549. this.addCodespaceRange(n, 0, 0xffff);
  34550. }
  34551. _util.Util.inherit(IdentityCMap, CMap, {});
  34552. IdentityCMap.prototype = {
  34553. addCodespaceRange: CMap.prototype.addCodespaceRange,
  34554. mapCidRange: function mapCidRange(low, high, dstLow) {
  34555. throw new Error('should not call mapCidRange');
  34556. },
  34557. mapBfRange: function mapBfRange(low, high, dstLow) {
  34558. throw new Error('should not call mapBfRange');
  34559. },
  34560. mapBfRangeToArray: function mapBfRangeToArray(low, high, array) {
  34561. throw new Error('should not call mapBfRangeToArray');
  34562. },
  34563. mapOne: function mapOne(src, dst) {
  34564. throw new Error('should not call mapCidOne');
  34565. },
  34566. lookup: function lookup(code) {
  34567. return Number.isInteger(code) && code <= 0xffff ? code : undefined;
  34568. },
  34569. contains: function contains(code) {
  34570. return Number.isInteger(code) && code <= 0xffff;
  34571. },
  34572. forEach: function forEach(callback) {
  34573. for (var i = 0; i <= 0xffff; i++) {
  34574. callback(i, i);
  34575. }
  34576. },
  34577. charCodeOf: function charCodeOf(value) {
  34578. return Number.isInteger(value) && value <= 0xffff ? value : -1;
  34579. },
  34580. getMap: function getMap() {
  34581. var map = new Array(0x10000);
  34582. for (var i = 0; i <= 0xffff; i++) {
  34583. map[i] = i;
  34584. }
  34585. return map;
  34586. },
  34587. readCharCode: CMap.prototype.readCharCode,
  34588. get length() {
  34589. return 0x10000;
  34590. },
  34591. get isIdentityCMap() {
  34592. throw new Error('should not access .isIdentityCMap');
  34593. }
  34594. };
  34595. return IdentityCMap;
  34596. }();
  34597. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  34598. function hexToInt(a, size) {
  34599. var n = 0;
  34600. for (var i = 0; i <= size; i++) {
  34601. n = n << 8 | a[i];
  34602. }
  34603. return n >>> 0;
  34604. }
  34605. function hexToStr(a, size) {
  34606. if (size === 1) {
  34607. return String.fromCharCode(a[0], a[1]);
  34608. }
  34609. if (size === 3) {
  34610. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  34611. }
  34612. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  34613. }
  34614. function addHex(a, b, size) {
  34615. var c = 0;
  34616. for (var i = size; i >= 0; i--) {
  34617. c += a[i] + b[i];
  34618. a[i] = c & 255;
  34619. c >>= 8;
  34620. }
  34621. }
  34622. function incHex(a, size) {
  34623. var c = 1;
  34624. for (var i = size; i >= 0 && c > 0; i--) {
  34625. c += a[i];
  34626. a[i] = c & 255;
  34627. c >>= 8;
  34628. }
  34629. }
  34630. var MAX_NUM_SIZE = 16;
  34631. var MAX_ENCODED_NUM_SIZE = 19;
  34632. function BinaryCMapStream(data) {
  34633. this.buffer = data;
  34634. this.pos = 0;
  34635. this.end = data.length;
  34636. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  34637. }
  34638. BinaryCMapStream.prototype = {
  34639. readByte: function readByte() {
  34640. if (this.pos >= this.end) {
  34641. return -1;
  34642. }
  34643. return this.buffer[this.pos++];
  34644. },
  34645. readNumber: function readNumber() {
  34646. var n = 0;
  34647. var last;
  34648. do {
  34649. var b = this.readByte();
  34650. if (b < 0) {
  34651. throw new _util.FormatError('unexpected EOF in bcmap');
  34652. }
  34653. last = !(b & 0x80);
  34654. n = n << 7 | b & 0x7F;
  34655. } while (!last);
  34656. return n;
  34657. },
  34658. readSigned: function readSigned() {
  34659. var n = this.readNumber();
  34660. return n & 1 ? ~(n >>> 1) : n >>> 1;
  34661. },
  34662. readHex: function readHex(num, size) {
  34663. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  34664. this.pos += size + 1;
  34665. },
  34666. readHexNumber: function readHexNumber(num, size) {
  34667. var last;
  34668. var stack = this.tmpBuf,
  34669. sp = 0;
  34670. do {
  34671. var b = this.readByte();
  34672. if (b < 0) {
  34673. throw new _util.FormatError('unexpected EOF in bcmap');
  34674. }
  34675. last = !(b & 0x80);
  34676. stack[sp++] = b & 0x7F;
  34677. } while (!last);
  34678. var i = size,
  34679. buffer = 0,
  34680. bufferSize = 0;
  34681. while (i >= 0) {
  34682. while (bufferSize < 8 && stack.length > 0) {
  34683. buffer = stack[--sp] << bufferSize | buffer;
  34684. bufferSize += 7;
  34685. }
  34686. num[i] = buffer & 255;
  34687. i--;
  34688. buffer >>= 8;
  34689. bufferSize -= 8;
  34690. }
  34691. },
  34692. readHexSigned: function readHexSigned(num, size) {
  34693. this.readHexNumber(num, size);
  34694. var sign = num[size] & 1 ? 255 : 0;
  34695. var c = 0;
  34696. for (var i = 0; i <= size; i++) {
  34697. c = (c & 1) << 8 | num[i];
  34698. num[i] = c >> 1 ^ sign;
  34699. }
  34700. },
  34701. readString: function readString() {
  34702. var len = this.readNumber();
  34703. var s = '';
  34704. for (var i = 0; i < len; i++) {
  34705. s += String.fromCharCode(this.readNumber());
  34706. }
  34707. return s;
  34708. }
  34709. };
  34710. function processBinaryCMap(data, cMap, extend) {
  34711. return new Promise(function (resolve, reject) {
  34712. var stream = new BinaryCMapStream(data);
  34713. var header = stream.readByte();
  34714. cMap.vertical = !!(header & 1);
  34715. var useCMap = null;
  34716. var start = new Uint8Array(MAX_NUM_SIZE);
  34717. var end = new Uint8Array(MAX_NUM_SIZE);
  34718. var char = new Uint8Array(MAX_NUM_SIZE);
  34719. var charCode = new Uint8Array(MAX_NUM_SIZE);
  34720. var tmp = new Uint8Array(MAX_NUM_SIZE);
  34721. var code;
  34722. var b;
  34723. while ((b = stream.readByte()) >= 0) {
  34724. var type = b >> 5;
  34725. if (type === 7) {
  34726. switch (b & 0x1F) {
  34727. case 0:
  34728. stream.readString();
  34729. break;
  34730. case 1:
  34731. useCMap = stream.readString();
  34732. break;
  34733. }
  34734. continue;
  34735. }
  34736. var sequence = !!(b & 0x10);
  34737. var dataSize = b & 15;
  34738. if (dataSize + 1 > MAX_NUM_SIZE) {
  34739. throw new Error('processBinaryCMap: Invalid dataSize.');
  34740. }
  34741. var ucs2DataSize = 1;
  34742. var subitemsCount = stream.readNumber();
  34743. var i;
  34744. switch (type) {
  34745. case 0:
  34746. stream.readHex(start, dataSize);
  34747. stream.readHexNumber(end, dataSize);
  34748. addHex(end, start, dataSize);
  34749. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  34750. for (i = 1; i < subitemsCount; i++) {
  34751. incHex(end, dataSize);
  34752. stream.readHexNumber(start, dataSize);
  34753. addHex(start, end, dataSize);
  34754. stream.readHexNumber(end, dataSize);
  34755. addHex(end, start, dataSize);
  34756. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  34757. }
  34758. break;
  34759. case 1:
  34760. stream.readHex(start, dataSize);
  34761. stream.readHexNumber(end, dataSize);
  34762. addHex(end, start, dataSize);
  34763. stream.readNumber();
  34764. for (i = 1; i < subitemsCount; i++) {
  34765. incHex(end, dataSize);
  34766. stream.readHexNumber(start, dataSize);
  34767. addHex(start, end, dataSize);
  34768. stream.readHexNumber(end, dataSize);
  34769. addHex(end, start, dataSize);
  34770. stream.readNumber();
  34771. }
  34772. break;
  34773. case 2:
  34774. stream.readHex(char, dataSize);
  34775. code = stream.readNumber();
  34776. cMap.mapOne(hexToInt(char, dataSize), code);
  34777. for (i = 1; i < subitemsCount; i++) {
  34778. incHex(char, dataSize);
  34779. if (!sequence) {
  34780. stream.readHexNumber(tmp, dataSize);
  34781. addHex(char, tmp, dataSize);
  34782. }
  34783. code = stream.readSigned() + (code + 1);
  34784. cMap.mapOne(hexToInt(char, dataSize), code);
  34785. }
  34786. break;
  34787. case 3:
  34788. stream.readHex(start, dataSize);
  34789. stream.readHexNumber(end, dataSize);
  34790. addHex(end, start, dataSize);
  34791. code = stream.readNumber();
  34792. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  34793. for (i = 1; i < subitemsCount; i++) {
  34794. incHex(end, dataSize);
  34795. if (!sequence) {
  34796. stream.readHexNumber(start, dataSize);
  34797. addHex(start, end, dataSize);
  34798. } else {
  34799. start.set(end);
  34800. }
  34801. stream.readHexNumber(end, dataSize);
  34802. addHex(end, start, dataSize);
  34803. code = stream.readNumber();
  34804. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  34805. }
  34806. break;
  34807. case 4:
  34808. stream.readHex(char, ucs2DataSize);
  34809. stream.readHex(charCode, dataSize);
  34810. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  34811. for (i = 1; i < subitemsCount; i++) {
  34812. incHex(char, ucs2DataSize);
  34813. if (!sequence) {
  34814. stream.readHexNumber(tmp, ucs2DataSize);
  34815. addHex(char, tmp, ucs2DataSize);
  34816. }
  34817. incHex(charCode, dataSize);
  34818. stream.readHexSigned(tmp, dataSize);
  34819. addHex(charCode, tmp, dataSize);
  34820. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  34821. }
  34822. break;
  34823. case 5:
  34824. stream.readHex(start, ucs2DataSize);
  34825. stream.readHexNumber(end, ucs2DataSize);
  34826. addHex(end, start, ucs2DataSize);
  34827. stream.readHex(charCode, dataSize);
  34828. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  34829. for (i = 1; i < subitemsCount; i++) {
  34830. incHex(end, ucs2DataSize);
  34831. if (!sequence) {
  34832. stream.readHexNumber(start, ucs2DataSize);
  34833. addHex(start, end, ucs2DataSize);
  34834. } else {
  34835. start.set(end);
  34836. }
  34837. stream.readHexNumber(end, ucs2DataSize);
  34838. addHex(end, start, ucs2DataSize);
  34839. stream.readHex(charCode, dataSize);
  34840. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  34841. }
  34842. break;
  34843. default:
  34844. reject(new Error('processBinaryCMap: Unknown type: ' + type));
  34845. return;
  34846. }
  34847. }
  34848. if (useCMap) {
  34849. resolve(extend(useCMap));
  34850. return;
  34851. }
  34852. resolve(cMap);
  34853. });
  34854. }
  34855. function BinaryCMapReader() {}
  34856. BinaryCMapReader.prototype = { process: processBinaryCMap };
  34857. return BinaryCMapReader;
  34858. }();
  34859. var CMapFactory = function CMapFactoryClosure() {
  34860. function strToInt(str) {
  34861. var a = 0;
  34862. for (var i = 0; i < str.length; i++) {
  34863. a = a << 8 | str.charCodeAt(i);
  34864. }
  34865. return a >>> 0;
  34866. }
  34867. function expectString(obj) {
  34868. if (!(0, _util.isString)(obj)) {
  34869. throw new _util.FormatError('Malformed CMap: expected string.');
  34870. }
  34871. }
  34872. function expectInt(obj) {
  34873. if (!Number.isInteger(obj)) {
  34874. throw new _util.FormatError('Malformed CMap: expected int.');
  34875. }
  34876. }
  34877. function parseBfChar(cMap, lexer) {
  34878. while (true) {
  34879. var obj = lexer.getObj();
  34880. if ((0, _primitives.isEOF)(obj)) {
  34881. break;
  34882. }
  34883. if ((0, _primitives.isCmd)(obj, 'endbfchar')) {
  34884. return;
  34885. }
  34886. expectString(obj);
  34887. var src = strToInt(obj);
  34888. obj = lexer.getObj();
  34889. expectString(obj);
  34890. var dst = obj;
  34891. cMap.mapOne(src, dst);
  34892. }
  34893. }
  34894. function parseBfRange(cMap, lexer) {
  34895. while (true) {
  34896. var obj = lexer.getObj();
  34897. if ((0, _primitives.isEOF)(obj)) {
  34898. break;
  34899. }
  34900. if ((0, _primitives.isCmd)(obj, 'endbfrange')) {
  34901. return;
  34902. }
  34903. expectString(obj);
  34904. var low = strToInt(obj);
  34905. obj = lexer.getObj();
  34906. expectString(obj);
  34907. var high = strToInt(obj);
  34908. obj = lexer.getObj();
  34909. if (Number.isInteger(obj) || (0, _util.isString)(obj)) {
  34910. var dstLow = Number.isInteger(obj) ? String.fromCharCode(obj) : obj;
  34911. cMap.mapBfRange(low, high, dstLow);
  34912. } else if ((0, _primitives.isCmd)(obj, '[')) {
  34913. obj = lexer.getObj();
  34914. var array = [];
  34915. while (!(0, _primitives.isCmd)(obj, ']') && !(0, _primitives.isEOF)(obj)) {
  34916. array.push(obj);
  34917. obj = lexer.getObj();
  34918. }
  34919. cMap.mapBfRangeToArray(low, high, array);
  34920. } else {
  34921. break;
  34922. }
  34923. }
  34924. throw new _util.FormatError('Invalid bf range.');
  34925. }
  34926. function parseCidChar(cMap, lexer) {
  34927. while (true) {
  34928. var obj = lexer.getObj();
  34929. if ((0, _primitives.isEOF)(obj)) {
  34930. break;
  34931. }
  34932. if ((0, _primitives.isCmd)(obj, 'endcidchar')) {
  34933. return;
  34934. }
  34935. expectString(obj);
  34936. var src = strToInt(obj);
  34937. obj = lexer.getObj();
  34938. expectInt(obj);
  34939. var dst = obj;
  34940. cMap.mapOne(src, dst);
  34941. }
  34942. }
  34943. function parseCidRange(cMap, lexer) {
  34944. while (true) {
  34945. var obj = lexer.getObj();
  34946. if ((0, _primitives.isEOF)(obj)) {
  34947. break;
  34948. }
  34949. if ((0, _primitives.isCmd)(obj, 'endcidrange')) {
  34950. return;
  34951. }
  34952. expectString(obj);
  34953. var low = strToInt(obj);
  34954. obj = lexer.getObj();
  34955. expectString(obj);
  34956. var high = strToInt(obj);
  34957. obj = lexer.getObj();
  34958. expectInt(obj);
  34959. var dstLow = obj;
  34960. cMap.mapCidRange(low, high, dstLow);
  34961. }
  34962. }
  34963. function parseCodespaceRange(cMap, lexer) {
  34964. while (true) {
  34965. var obj = lexer.getObj();
  34966. if ((0, _primitives.isEOF)(obj)) {
  34967. break;
  34968. }
  34969. if ((0, _primitives.isCmd)(obj, 'endcodespacerange')) {
  34970. return;
  34971. }
  34972. if (!(0, _util.isString)(obj)) {
  34973. break;
  34974. }
  34975. var low = strToInt(obj);
  34976. obj = lexer.getObj();
  34977. if (!(0, _util.isString)(obj)) {
  34978. break;
  34979. }
  34980. var high = strToInt(obj);
  34981. cMap.addCodespaceRange(obj.length, low, high);
  34982. }
  34983. throw new _util.FormatError('Invalid codespace range.');
  34984. }
  34985. function parseWMode(cMap, lexer) {
  34986. var obj = lexer.getObj();
  34987. if (Number.isInteger(obj)) {
  34988. cMap.vertical = !!obj;
  34989. }
  34990. }
  34991. function parseCMapName(cMap, lexer) {
  34992. var obj = lexer.getObj();
  34993. if ((0, _primitives.isName)(obj) && (0, _util.isString)(obj.name)) {
  34994. cMap.name = obj.name;
  34995. }
  34996. }
  34997. function parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap) {
  34998. var previous;
  34999. var embededUseCMap;
  35000. objLoop: while (true) {
  35001. try {
  35002. var obj = lexer.getObj();
  35003. if ((0, _primitives.isEOF)(obj)) {
  35004. break;
  35005. } else if ((0, _primitives.isName)(obj)) {
  35006. if (obj.name === 'WMode') {
  35007. parseWMode(cMap, lexer);
  35008. } else if (obj.name === 'CMapName') {
  35009. parseCMapName(cMap, lexer);
  35010. }
  35011. previous = obj;
  35012. } else if ((0, _primitives.isCmd)(obj)) {
  35013. switch (obj.cmd) {
  35014. case 'endcmap':
  35015. break objLoop;
  35016. case 'usecmap':
  35017. if ((0, _primitives.isName)(previous)) {
  35018. embededUseCMap = previous.name;
  35019. }
  35020. break;
  35021. case 'begincodespacerange':
  35022. parseCodespaceRange(cMap, lexer);
  35023. break;
  35024. case 'beginbfchar':
  35025. parseBfChar(cMap, lexer);
  35026. break;
  35027. case 'begincidchar':
  35028. parseCidChar(cMap, lexer);
  35029. break;
  35030. case 'beginbfrange':
  35031. parseBfRange(cMap, lexer);
  35032. break;
  35033. case 'begincidrange':
  35034. parseCidRange(cMap, lexer);
  35035. break;
  35036. }
  35037. }
  35038. } catch (ex) {
  35039. if (ex instanceof _util.MissingDataException) {
  35040. throw ex;
  35041. }
  35042. (0, _util.warn)('Invalid cMap data: ' + ex);
  35043. continue;
  35044. }
  35045. }
  35046. if (!useCMap && embededUseCMap) {
  35047. useCMap = embededUseCMap;
  35048. }
  35049. if (useCMap) {
  35050. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  35051. }
  35052. return Promise.resolve(cMap);
  35053. }
  35054. function extendCMap(cMap, fetchBuiltInCMap, useCMap) {
  35055. return createBuiltInCMap(useCMap, fetchBuiltInCMap).then(function (newCMap) {
  35056. cMap.useCMap = newCMap;
  35057. if (cMap.numCodespaceRanges === 0) {
  35058. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  35059. for (var i = 0; i < useCodespaceRanges.length; i++) {
  35060. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  35061. }
  35062. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  35063. }
  35064. cMap.useCMap.forEach(function (key, value) {
  35065. if (!cMap.contains(key)) {
  35066. cMap.mapOne(key, cMap.useCMap.lookup(key));
  35067. }
  35068. });
  35069. return cMap;
  35070. });
  35071. }
  35072. function createBuiltInCMap(name, fetchBuiltInCMap) {
  35073. if (name === 'Identity-H') {
  35074. return Promise.resolve(new IdentityCMap(false, 2));
  35075. } else if (name === 'Identity-V') {
  35076. return Promise.resolve(new IdentityCMap(true, 2));
  35077. }
  35078. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  35079. return Promise.reject(new Error('Unknown CMap name: ' + name));
  35080. }
  35081. if (!fetchBuiltInCMap) {
  35082. return Promise.reject(new Error('Built-in CMap parameters are not provided.'));
  35083. }
  35084. return fetchBuiltInCMap(name).then(function (data) {
  35085. var cMapData = data.cMapData,
  35086. compressionType = data.compressionType;
  35087. var cMap = new CMap(true);
  35088. if (compressionType === _util.CMapCompressionType.BINARY) {
  35089. return new BinaryCMapReader().process(cMapData, cMap, function (useCMap) {
  35090. return extendCMap(cMap, fetchBuiltInCMap, useCMap);
  35091. });
  35092. }
  35093. if (compressionType === _util.CMapCompressionType.NONE) {
  35094. var lexer = new _parser.Lexer(new _stream.Stream(cMapData));
  35095. return parseCMap(cMap, lexer, fetchBuiltInCMap, null);
  35096. }
  35097. return Promise.reject(new Error('TODO: Only BINARY/NONE CMap compression is currently supported.'));
  35098. });
  35099. }
  35100. return {
  35101. create: function create(params) {
  35102. var encoding = params.encoding;
  35103. var fetchBuiltInCMap = params.fetchBuiltInCMap;
  35104. var useCMap = params.useCMap;
  35105. if ((0, _primitives.isName)(encoding)) {
  35106. return createBuiltInCMap(encoding.name, fetchBuiltInCMap);
  35107. } else if ((0, _primitives.isStream)(encoding)) {
  35108. var cMap = new CMap();
  35109. var lexer = new _parser.Lexer(encoding);
  35110. return parseCMap(cMap, lexer, fetchBuiltInCMap, useCMap).then(function (parsedCMap) {
  35111. if (parsedCMap.isIdentityCMap) {
  35112. return createBuiltInCMap(parsedCMap.name, fetchBuiltInCMap);
  35113. }
  35114. return parsedCMap;
  35115. });
  35116. }
  35117. return Promise.reject(new Error('Encoding required.'));
  35118. }
  35119. };
  35120. }();
  35121. exports.CMap = CMap;
  35122. exports.IdentityCMap = IdentityCMap;
  35123. exports.CMapFactory = CMapFactory;
  35124. /***/ }),
  35125. /* 132 */
  35126. /***/ (function(module, exports, __w_pdfjs_require__) {
  35127. "use strict";
  35128. Object.defineProperty(exports, "__esModule", {
  35129. value: true
  35130. });
  35131. exports.getFontType = exports.ProblematicCharRanges = exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.PRIVATE_USE_OFFSET_END = exports.PRIVATE_USE_OFFSET_START = exports.SEAC_ANALYSIS_ENABLED = undefined;
  35132. var _util = __w_pdfjs_require__(0);
  35133. var _cff_parser = __w_pdfjs_require__(66);
  35134. var _glyphlist = __w_pdfjs_require__(42);
  35135. var _encodings = __w_pdfjs_require__(21);
  35136. var _standard_fonts = __w_pdfjs_require__(67);
  35137. var _unicode = __w_pdfjs_require__(68);
  35138. var _font_renderer = __w_pdfjs_require__(134);
  35139. var _stream = __w_pdfjs_require__(5);
  35140. var _type1_parser = __w_pdfjs_require__(135);
  35141. var PRIVATE_USE_OFFSET_START = 0xE000;
  35142. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  35143. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  35144. var PDF_GLYPH_SPACE_UNITS = 1000;
  35145. var SEAC_ANALYSIS_ENABLED = false;
  35146. var FontFlags = {
  35147. FixedPitch: 1,
  35148. Serif: 2,
  35149. Symbolic: 4,
  35150. Script: 8,
  35151. Nonsymbolic: 32,
  35152. Italic: 64,
  35153. AllCap: 65536,
  35154. SmallCap: 131072,
  35155. ForceBold: 262144
  35156. };
  35157. 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'];
  35158. function adjustWidths(properties) {
  35159. if (!properties.fontMatrix) {
  35160. return;
  35161. }
  35162. if (properties.fontMatrix[0] === _util.FONT_IDENTITY_MATRIX[0]) {
  35163. return;
  35164. }
  35165. var scale = 0.001 / properties.fontMatrix[0];
  35166. var glyphsWidths = properties.widths;
  35167. for (var glyph in glyphsWidths) {
  35168. glyphsWidths[glyph] *= scale;
  35169. }
  35170. properties.defaultWidth *= scale;
  35171. }
  35172. function adjustToUnicode(properties, builtInEncoding) {
  35173. if (properties.hasIncludedToUnicodeMap) {
  35174. return;
  35175. }
  35176. if (properties.hasEncoding) {
  35177. return;
  35178. }
  35179. if (builtInEncoding === properties.defaultEncoding) {
  35180. return;
  35181. }
  35182. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  35183. return;
  35184. }
  35185. var toUnicode = [],
  35186. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  35187. for (var charCode in builtInEncoding) {
  35188. var glyphName = builtInEncoding[charCode];
  35189. var unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  35190. if (unicode !== -1) {
  35191. toUnicode[charCode] = String.fromCharCode(unicode);
  35192. }
  35193. }
  35194. properties.toUnicode.amend(toUnicode);
  35195. }
  35196. function getFontType(type, subtype) {
  35197. switch (type) {
  35198. case 'Type1':
  35199. return subtype === 'Type1C' ? _util.FontType.TYPE1C : _util.FontType.TYPE1;
  35200. case 'CIDFontType0':
  35201. return subtype === 'CIDFontType0C' ? _util.FontType.CIDFONTTYPE0C : _util.FontType.CIDFONTTYPE0;
  35202. case 'OpenType':
  35203. return _util.FontType.OPENTYPE;
  35204. case 'TrueType':
  35205. return _util.FontType.TRUETYPE;
  35206. case 'CIDFontType2':
  35207. return _util.FontType.CIDFONTTYPE2;
  35208. case 'MMType1':
  35209. return _util.FontType.MMTYPE1;
  35210. case 'Type0':
  35211. return _util.FontType.TYPE0;
  35212. default:
  35213. return _util.FontType.UNKNOWN;
  35214. }
  35215. }
  35216. function recoverGlyphName(name, glyphsUnicodeMap) {
  35217. if (glyphsUnicodeMap[name] !== undefined) {
  35218. return name;
  35219. }
  35220. var unicode = (0, _unicode.getUnicodeForGlyph)(name, glyphsUnicodeMap);
  35221. if (unicode !== -1) {
  35222. for (var key in glyphsUnicodeMap) {
  35223. if (glyphsUnicodeMap[key] === unicode) {
  35224. return key;
  35225. }
  35226. }
  35227. }
  35228. (0, _util.info)('Unable to recover a standard glyph name for: ' + name);
  35229. return name;
  35230. }
  35231. var Glyph = function GlyphClosure() {
  35232. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  35233. this.fontChar = fontChar;
  35234. this.unicode = unicode;
  35235. this.accent = accent;
  35236. this.width = width;
  35237. this.vmetric = vmetric;
  35238. this.operatorListId = operatorListId;
  35239. this.isSpace = isSpace;
  35240. this.isInFont = isInFont;
  35241. }
  35242. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  35243. 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;
  35244. };
  35245. return Glyph;
  35246. }();
  35247. var ToUnicodeMap = function ToUnicodeMapClosure() {
  35248. function ToUnicodeMap(cmap) {
  35249. this._map = cmap;
  35250. }
  35251. ToUnicodeMap.prototype = {
  35252. get length() {
  35253. return this._map.length;
  35254. },
  35255. forEach: function forEach(callback) {
  35256. for (var charCode in this._map) {
  35257. callback(charCode, this._map[charCode].charCodeAt(0));
  35258. }
  35259. },
  35260. has: function has(i) {
  35261. return this._map[i] !== undefined;
  35262. },
  35263. get: function get(i) {
  35264. return this._map[i];
  35265. },
  35266. charCodeOf: function charCodeOf(value) {
  35267. var map = this._map;
  35268. if (map.length <= 0x10000) {
  35269. return map.indexOf(value);
  35270. }
  35271. for (var charCode in map) {
  35272. if (map[charCode] === value) {
  35273. return charCode | 0;
  35274. }
  35275. }
  35276. return -1;
  35277. },
  35278. amend: function amend(map) {
  35279. for (var charCode in map) {
  35280. this._map[charCode] = map[charCode];
  35281. }
  35282. }
  35283. };
  35284. return ToUnicodeMap;
  35285. }();
  35286. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  35287. function IdentityToUnicodeMap(firstChar, lastChar) {
  35288. this.firstChar = firstChar;
  35289. this.lastChar = lastChar;
  35290. }
  35291. IdentityToUnicodeMap.prototype = {
  35292. get length() {
  35293. return this.lastChar + 1 - this.firstChar;
  35294. },
  35295. forEach: function forEach(callback) {
  35296. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  35297. callback(i, i);
  35298. }
  35299. },
  35300. has: function has(i) {
  35301. return this.firstChar <= i && i <= this.lastChar;
  35302. },
  35303. get: function get(i) {
  35304. if (this.firstChar <= i && i <= this.lastChar) {
  35305. return String.fromCharCode(i);
  35306. }
  35307. return undefined;
  35308. },
  35309. charCodeOf: function charCodeOf(v) {
  35310. return Number.isInteger(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  35311. },
  35312. amend: function amend(map) {
  35313. throw new Error('Should not call amend()');
  35314. }
  35315. };
  35316. return IdentityToUnicodeMap;
  35317. }();
  35318. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  35319. function writeInt16(dest, offset, num) {
  35320. dest[offset] = num >> 8 & 0xFF;
  35321. dest[offset + 1] = num & 0xFF;
  35322. }
  35323. function writeInt32(dest, offset, num) {
  35324. dest[offset] = num >> 24 & 0xFF;
  35325. dest[offset + 1] = num >> 16 & 0xFF;
  35326. dest[offset + 2] = num >> 8 & 0xFF;
  35327. dest[offset + 3] = num & 0xFF;
  35328. }
  35329. function writeData(dest, offset, data) {
  35330. var i, ii;
  35331. if (data instanceof Uint8Array) {
  35332. dest.set(data, offset);
  35333. } else if (typeof data === 'string') {
  35334. for (i = 0, ii = data.length; i < ii; i++) {
  35335. dest[offset++] = data.charCodeAt(i) & 0xFF;
  35336. }
  35337. } else {
  35338. for (i = 0, ii = data.length; i < ii; i++) {
  35339. dest[offset++] = data[i] & 0xFF;
  35340. }
  35341. }
  35342. }
  35343. function OpenTypeFileBuilder(sfnt) {
  35344. this.sfnt = sfnt;
  35345. this.tables = Object.create(null);
  35346. }
  35347. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  35348. var maxPower2 = 1,
  35349. log2 = 0;
  35350. while ((maxPower2 ^ entriesCount) > maxPower2) {
  35351. maxPower2 <<= 1;
  35352. log2++;
  35353. }
  35354. var searchRange = maxPower2 * entrySize;
  35355. return {
  35356. range: searchRange,
  35357. entry: log2,
  35358. rangeShift: entrySize * entriesCount - searchRange
  35359. };
  35360. };
  35361. var OTF_HEADER_SIZE = 12;
  35362. var OTF_TABLE_ENTRY_SIZE = 16;
  35363. OpenTypeFileBuilder.prototype = {
  35364. toArray: function OpenTypeFileBuilder_toArray() {
  35365. var sfnt = this.sfnt;
  35366. var tables = this.tables;
  35367. var tablesNames = Object.keys(tables);
  35368. tablesNames.sort();
  35369. var numTables = tablesNames.length;
  35370. var i, j, jj, table, tableName;
  35371. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  35372. var tableOffsets = [offset];
  35373. for (i = 0; i < numTables; i++) {
  35374. table = tables[tablesNames[i]];
  35375. var paddedLength = (table.length + 3 & ~3) >>> 0;
  35376. offset += paddedLength;
  35377. tableOffsets.push(offset);
  35378. }
  35379. var file = new Uint8Array(offset);
  35380. for (i = 0; i < numTables; i++) {
  35381. table = tables[tablesNames[i]];
  35382. writeData(file, tableOffsets[i], table);
  35383. }
  35384. if (sfnt === 'true') {
  35385. sfnt = (0, _util.string32)(0x00010000);
  35386. }
  35387. file[0] = sfnt.charCodeAt(0) & 0xFF;
  35388. file[1] = sfnt.charCodeAt(1) & 0xFF;
  35389. file[2] = sfnt.charCodeAt(2) & 0xFF;
  35390. file[3] = sfnt.charCodeAt(3) & 0xFF;
  35391. writeInt16(file, 4, numTables);
  35392. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  35393. writeInt16(file, 6, searchParams.range);
  35394. writeInt16(file, 8, searchParams.entry);
  35395. writeInt16(file, 10, searchParams.rangeShift);
  35396. offset = OTF_HEADER_SIZE;
  35397. for (i = 0; i < numTables; i++) {
  35398. tableName = tablesNames[i];
  35399. file[offset] = tableName.charCodeAt(0) & 0xFF;
  35400. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  35401. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  35402. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  35403. var checksum = 0;
  35404. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  35405. var quad = (0, _util.readUint32)(file, j);
  35406. checksum = checksum + quad >>> 0;
  35407. }
  35408. writeInt32(file, offset + 4, checksum);
  35409. writeInt32(file, offset + 8, tableOffsets[i]);
  35410. writeInt32(file, offset + 12, tables[tableName].length);
  35411. offset += OTF_TABLE_ENTRY_SIZE;
  35412. }
  35413. return file;
  35414. },
  35415. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  35416. if (tag in this.tables) {
  35417. throw new Error('Table ' + tag + ' already exists');
  35418. }
  35419. this.tables[tag] = data;
  35420. }
  35421. };
  35422. return OpenTypeFileBuilder;
  35423. }();
  35424. var ProblematicCharRanges = new Int32Array([0x0000, 0x0020, 0x007F, 0x00A1, 0x00AD, 0x00AE, 0x0600, 0x0780, 0x08A0, 0x10A0, 0x1780, 0x1800, 0x1C00, 0x1C50, 0x2000, 0x2010, 0x2011, 0x2012, 0x2028, 0x2030, 0x205F, 0x2070, 0x25CC, 0x25CD, 0x3000, 0x3001, 0x3164, 0x3165, 0xAA60, 0xAA80, 0xFFF0, 0x10000]);
  35425. var Font = function FontClosure() {
  35426. function Font(name, file, properties) {
  35427. var charCode;
  35428. this.name = name;
  35429. this.loadedName = properties.loadedName;
  35430. this.isType3Font = properties.isType3Font;
  35431. this.sizes = [];
  35432. this.missingFile = false;
  35433. this.glyphCache = Object.create(null);
  35434. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  35435. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  35436. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  35437. var type = properties.type;
  35438. var subtype = properties.subtype;
  35439. this.type = type;
  35440. this.subtype = subtype;
  35441. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  35442. this.differences = properties.differences;
  35443. this.widths = properties.widths;
  35444. this.defaultWidth = properties.defaultWidth;
  35445. this.composite = properties.composite;
  35446. this.wideChars = properties.wideChars;
  35447. this.cMap = properties.cMap;
  35448. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  35449. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  35450. this.fontMatrix = properties.fontMatrix;
  35451. this.bbox = properties.bbox;
  35452. this.defaultEncoding = properties.defaultEncoding;
  35453. this.toUnicode = properties.toUnicode;
  35454. this.toFontChar = [];
  35455. if (properties.type === 'Type3') {
  35456. for (charCode = 0; charCode < 256; charCode++) {
  35457. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  35458. }
  35459. this.fontType = _util.FontType.TYPE3;
  35460. return;
  35461. }
  35462. this.cidEncoding = properties.cidEncoding;
  35463. this.vertical = properties.vertical;
  35464. if (this.vertical) {
  35465. this.vmetrics = properties.vmetrics;
  35466. this.defaultVMetrics = properties.defaultVMetrics;
  35467. }
  35468. if (!file || file.isEmpty) {
  35469. if (file) {
  35470. (0, _util.warn)('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  35471. }
  35472. this.fallbackToSystemFont();
  35473. return;
  35474. }
  35475. if (subtype === 'Type1C') {
  35476. if (type !== 'Type1' && type !== 'MMType1') {
  35477. if (isTrueTypeFile(file)) {
  35478. subtype = 'TrueType';
  35479. } else {
  35480. type = 'Type1';
  35481. }
  35482. } else if (isOpenTypeFile(file)) {
  35483. subtype = 'OpenType';
  35484. }
  35485. }
  35486. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  35487. type = 'CIDFontType0';
  35488. }
  35489. if (type === 'CIDFontType0') {
  35490. if (isType1File(file)) {
  35491. subtype = 'CIDFontType0';
  35492. } else if (isOpenTypeFile(file)) {
  35493. subtype = 'OpenType';
  35494. } else {
  35495. subtype = 'CIDFontType0C';
  35496. }
  35497. }
  35498. if (subtype === 'OpenType' && type !== 'OpenType') {
  35499. type = 'OpenType';
  35500. }
  35501. try {
  35502. var data;
  35503. switch (type) {
  35504. case 'MMType1':
  35505. (0, _util.info)('MMType1 font (' + name + '), falling back to Type1.');
  35506. case 'Type1':
  35507. case 'CIDFontType0':
  35508. this.mimetype = 'font/opentype';
  35509. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  35510. adjustWidths(properties);
  35511. data = this.convert(name, cff, properties);
  35512. break;
  35513. case 'OpenType':
  35514. case 'TrueType':
  35515. case 'CIDFontType2':
  35516. this.mimetype = 'font/opentype';
  35517. data = this.checkAndRepair(name, file, properties);
  35518. if (this.isOpenType) {
  35519. adjustWidths(properties);
  35520. type = 'OpenType';
  35521. }
  35522. break;
  35523. default:
  35524. throw new _util.FormatError('Font ' + type + ' is not supported');
  35525. }
  35526. } catch (e) {
  35527. if (!(e instanceof _util.FormatError)) {
  35528. throw e;
  35529. }
  35530. (0, _util.warn)(e);
  35531. this.fallbackToSystemFont();
  35532. return;
  35533. }
  35534. this.data = data;
  35535. this.fontType = getFontType(type, subtype);
  35536. this.fontMatrix = properties.fontMatrix;
  35537. this.widths = properties.widths;
  35538. this.defaultWidth = properties.defaultWidth;
  35539. this.toUnicode = properties.toUnicode;
  35540. this.encoding = properties.baseEncoding;
  35541. this.seacMap = properties.seacMap;
  35542. this.loading = true;
  35543. }
  35544. Font.getFontID = function () {
  35545. var ID = 1;
  35546. return function Font_getFontID() {
  35547. return String(ID++);
  35548. };
  35549. }();
  35550. function int16(b0, b1) {
  35551. return (b0 << 8) + b1;
  35552. }
  35553. function writeSignedInt16(bytes, index, value) {
  35554. bytes[index + 1] = value;
  35555. bytes[index] = value >>> 8;
  35556. }
  35557. function signedInt16(b0, b1) {
  35558. var value = (b0 << 8) + b1;
  35559. return value & 1 << 15 ? value - 0x10000 : value;
  35560. }
  35561. function int32(b0, b1, b2, b3) {
  35562. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  35563. }
  35564. function string16(value) {
  35565. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  35566. }
  35567. function safeString16(value) {
  35568. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  35569. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  35570. }
  35571. function isTrueTypeFile(file) {
  35572. var header = file.peekBytes(4);
  35573. return (0, _util.readUint32)(header, 0) === 0x00010000;
  35574. }
  35575. function isOpenTypeFile(file) {
  35576. var header = file.peekBytes(4);
  35577. return (0, _util.bytesToString)(header) === 'OTTO';
  35578. }
  35579. function isType1File(file) {
  35580. var header = file.peekBytes(2);
  35581. if (header[0] === 0x25 && header[1] === 0x21) {
  35582. return true;
  35583. }
  35584. if (header[0] === 0x80 && header[1] === 0x01) {
  35585. return true;
  35586. }
  35587. return false;
  35588. }
  35589. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  35590. var toFontChar = [],
  35591. unicode;
  35592. for (var i = 0, ii = encoding.length; i < ii; i++) {
  35593. unicode = (0, _unicode.getUnicodeForGlyph)(encoding[i], glyphsUnicodeMap);
  35594. if (unicode !== -1) {
  35595. toFontChar[i] = unicode;
  35596. }
  35597. }
  35598. for (var charCode in differences) {
  35599. unicode = (0, _unicode.getUnicodeForGlyph)(differences[charCode], glyphsUnicodeMap);
  35600. if (unicode !== -1) {
  35601. toFontChar[+charCode] = unicode;
  35602. }
  35603. }
  35604. return toFontChar;
  35605. }
  35606. function isProblematicUnicodeLocation(code) {
  35607. var i = 0,
  35608. j = ProblematicCharRanges.length - 1;
  35609. while (i < j) {
  35610. var c = i + j + 1 >> 1;
  35611. if (code < ProblematicCharRanges[c]) {
  35612. j = c - 1;
  35613. } else {
  35614. i = c;
  35615. }
  35616. }
  35617. return !(i & 1);
  35618. }
  35619. function adjustMapping(charCodeToGlyphId, properties, missingGlyphs) {
  35620. var toUnicode = properties.toUnicode;
  35621. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  35622. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  35623. var newMap = Object.create(null);
  35624. var toFontChar = [];
  35625. var usedFontCharCodes = [];
  35626. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  35627. for (var originalCharCode in charCodeToGlyphId) {
  35628. originalCharCode |= 0;
  35629. var glyphId = charCodeToGlyphId[originalCharCode];
  35630. if (missingGlyphs[glyphId]) {
  35631. continue;
  35632. }
  35633. var fontCharCode = originalCharCode;
  35634. var hasUnicodeValue = false;
  35635. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  35636. hasUnicodeValue = true;
  35637. var unicode = toUnicode.get(fontCharCode);
  35638. if (unicode.length === 1) {
  35639. fontCharCode = unicode.charCodeAt(0);
  35640. }
  35641. }
  35642. if (usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) {
  35643. do {
  35644. if (nextAvailableFontCharCode > PRIVATE_USE_OFFSET_END) {
  35645. (0, _util.warn)('Ran out of space in font private use area.');
  35646. break;
  35647. }
  35648. fontCharCode = nextAvailableFontCharCode++;
  35649. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  35650. fontCharCode = 0xF020;
  35651. nextAvailableFontCharCode = fontCharCode + 1;
  35652. }
  35653. } while (usedFontCharCodes[fontCharCode] !== undefined);
  35654. }
  35655. newMap[fontCharCode] = glyphId;
  35656. toFontChar[originalCharCode] = fontCharCode;
  35657. usedFontCharCodes[fontCharCode] = true;
  35658. }
  35659. return {
  35660. toFontChar: toFontChar,
  35661. charCodeToGlyphId: newMap,
  35662. nextAvailableFontCharCode: nextAvailableFontCharCode
  35663. };
  35664. }
  35665. function getRanges(glyphs, numGlyphs) {
  35666. var codes = [];
  35667. for (var charCode in glyphs) {
  35668. if (glyphs[charCode] >= numGlyphs) {
  35669. continue;
  35670. }
  35671. codes.push({
  35672. fontCharCode: charCode | 0,
  35673. glyphId: glyphs[charCode]
  35674. });
  35675. }
  35676. if (codes.length === 0) {
  35677. codes.push({
  35678. fontCharCode: 0,
  35679. glyphId: 0
  35680. });
  35681. }
  35682. codes.sort(function fontGetRangesSort(a, b) {
  35683. return a.fontCharCode - b.fontCharCode;
  35684. });
  35685. var ranges = [];
  35686. var length = codes.length;
  35687. for (var n = 0; n < length;) {
  35688. var start = codes[n].fontCharCode;
  35689. var codeIndices = [codes[n].glyphId];
  35690. ++n;
  35691. var end = start;
  35692. while (n < length && end + 1 === codes[n].fontCharCode) {
  35693. codeIndices.push(codes[n].glyphId);
  35694. ++end;
  35695. ++n;
  35696. if (end === 0xFFFF) {
  35697. break;
  35698. }
  35699. }
  35700. ranges.push([start, end, codeIndices]);
  35701. }
  35702. return ranges;
  35703. }
  35704. function createCmapTable(glyphs, numGlyphs) {
  35705. var ranges = getRanges(glyphs, numGlyphs);
  35706. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  35707. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + (0, _util.string32)(4 + numTables * 8);
  35708. var i, ii, j, jj;
  35709. for (i = ranges.length - 1; i >= 0; --i) {
  35710. if (ranges[i][0] <= 0xFFFF) {
  35711. break;
  35712. }
  35713. }
  35714. var bmpLength = i + 1;
  35715. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  35716. ranges[i][1] = 0xFFFE;
  35717. }
  35718. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  35719. var segCount = bmpLength + trailingRangesCount;
  35720. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  35721. var startCount = '';
  35722. var endCount = '';
  35723. var idDeltas = '';
  35724. var idRangeOffsets = '';
  35725. var glyphsIds = '';
  35726. var bias = 0;
  35727. var range, start, end, codes;
  35728. for (i = 0, ii = bmpLength; i < ii; i++) {
  35729. range = ranges[i];
  35730. start = range[0];
  35731. end = range[1];
  35732. startCount += string16(start);
  35733. endCount += string16(end);
  35734. codes = range[2];
  35735. var contiguous = true;
  35736. for (j = 1, jj = codes.length; j < jj; ++j) {
  35737. if (codes[j] !== codes[j - 1] + 1) {
  35738. contiguous = false;
  35739. break;
  35740. }
  35741. }
  35742. if (!contiguous) {
  35743. var offset = (segCount - i) * 2 + bias * 2;
  35744. bias += end - start + 1;
  35745. idDeltas += string16(0);
  35746. idRangeOffsets += string16(offset);
  35747. for (j = 0, jj = codes.length; j < jj; ++j) {
  35748. glyphsIds += string16(codes[j]);
  35749. }
  35750. } else {
  35751. var startCode = codes[0];
  35752. idDeltas += string16(startCode - start & 0xFFFF);
  35753. idRangeOffsets += string16(0);
  35754. }
  35755. }
  35756. if (trailingRangesCount > 0) {
  35757. endCount += '\xFF\xFF';
  35758. startCount += '\xFF\xFF';
  35759. idDeltas += '\x00\x01';
  35760. idRangeOffsets += '\x00\x00';
  35761. }
  35762. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  35763. var format31012 = '';
  35764. var header31012 = '';
  35765. if (numTables > 1) {
  35766. cmap += '\x00\x03' + '\x00\x0A' + (0, _util.string32)(4 + numTables * 8 + 4 + format314.length);
  35767. format31012 = '';
  35768. for (i = 0, ii = ranges.length; i < ii; i++) {
  35769. range = ranges[i];
  35770. start = range[0];
  35771. codes = range[2];
  35772. var code = codes[0];
  35773. for (j = 1, jj = codes.length; j < jj; ++j) {
  35774. if (codes[j] !== codes[j - 1] + 1) {
  35775. end = range[0] + j - 1;
  35776. format31012 += (0, _util.string32)(start) + (0, _util.string32)(end) + (0, _util.string32)(code);
  35777. start = end + 1;
  35778. code = codes[j];
  35779. }
  35780. }
  35781. format31012 += (0, _util.string32)(start) + (0, _util.string32)(range[1]) + (0, _util.string32)(code);
  35782. }
  35783. header31012 = '\x00\x0C' + '\x00\x00' + (0, _util.string32)(format31012.length + 16) + '\x00\x00\x00\x00' + (0, _util.string32)(format31012.length / 12);
  35784. }
  35785. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  35786. }
  35787. function validateOS2Table(os2) {
  35788. var stream = new _stream.Stream(os2.data);
  35789. var version = stream.getUint16();
  35790. stream.getBytes(60);
  35791. var selection = stream.getUint16();
  35792. if (version < 4 && selection & 0x0300) {
  35793. return false;
  35794. }
  35795. var firstChar = stream.getUint16();
  35796. var lastChar = stream.getUint16();
  35797. if (firstChar > lastChar) {
  35798. return false;
  35799. }
  35800. stream.getBytes(6);
  35801. var usWinAscent = stream.getUint16();
  35802. if (usWinAscent === 0) {
  35803. return false;
  35804. }
  35805. os2.data[8] = os2.data[9] = 0;
  35806. return true;
  35807. }
  35808. function createOS2Table(properties, charstrings, override) {
  35809. override = override || {
  35810. unitsPerEm: 0,
  35811. yMax: 0,
  35812. yMin: 0,
  35813. ascent: 0,
  35814. descent: 0
  35815. };
  35816. var ulUnicodeRange1 = 0;
  35817. var ulUnicodeRange2 = 0;
  35818. var ulUnicodeRange3 = 0;
  35819. var ulUnicodeRange4 = 0;
  35820. var firstCharIndex = null;
  35821. var lastCharIndex = 0;
  35822. if (charstrings) {
  35823. for (var code in charstrings) {
  35824. code |= 0;
  35825. if (firstCharIndex > code || !firstCharIndex) {
  35826. firstCharIndex = code;
  35827. }
  35828. if (lastCharIndex < code) {
  35829. lastCharIndex = code;
  35830. }
  35831. var position = (0, _unicode.getUnicodeRangeFor)(code);
  35832. if (position < 32) {
  35833. ulUnicodeRange1 |= 1 << position;
  35834. } else if (position < 64) {
  35835. ulUnicodeRange2 |= 1 << position - 32;
  35836. } else if (position < 96) {
  35837. ulUnicodeRange3 |= 1 << position - 64;
  35838. } else if (position < 123) {
  35839. ulUnicodeRange4 |= 1 << position - 96;
  35840. } else {
  35841. throw new _util.FormatError('Unicode ranges Bits > 123 are reserved for internal usage');
  35842. }
  35843. }
  35844. } else {
  35845. firstCharIndex = 0;
  35846. lastCharIndex = 255;
  35847. }
  35848. var bbox = properties.bbox || [0, 0, 0, 0];
  35849. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  35850. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  35851. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  35852. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  35853. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  35854. typoDescent = -typoDescent;
  35855. }
  35856. var winAscent = override.yMax || typoAscent;
  35857. var winDescent = -override.yMin || -typoDescent;
  35858. return '\x00\x03' + '\x02\x24' + '\x01\xF4' + '\x00\x05' + '\x00\x00' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x00\x8C' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x01\xDF' + '\x00\x31' + '\x01\x02' + '\x00\x00' + '\x00\x00\x06' + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + '\x00\x00\x00\x00\x00\x00' + (0, _util.string32)(ulUnicodeRange1) + (0, _util.string32)(ulUnicodeRange2) + (0, _util.string32)(ulUnicodeRange3) + (0, _util.string32)(ulUnicodeRange4) + '\x2A\x32\x31\x2A' + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + '\x00\x64' + 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\x03';
  35859. }
  35860. function createPostTable(properties) {
  35861. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  35862. return '\x00\x03\x00\x00' + (0, _util.string32)(angle) + '\x00\x00' + '\x00\x00' + (0, _util.string32)(properties.fixedPitch) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00';
  35863. }
  35864. function createNameTable(name, proto) {
  35865. if (!proto) {
  35866. proto = [[], []];
  35867. }
  35868. 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'];
  35869. var stringsUnicode = [];
  35870. var i, ii, j, jj, str;
  35871. for (i = 0, ii = strings.length; i < ii; i++) {
  35872. str = proto[1][i] || strings[i];
  35873. var strBufUnicode = [];
  35874. for (j = 0, jj = str.length; j < jj; j++) {
  35875. strBufUnicode.push(string16(str.charCodeAt(j)));
  35876. }
  35877. stringsUnicode.push(strBufUnicode.join(''));
  35878. }
  35879. var names = [strings, stringsUnicode];
  35880. var platforms = ['\x00\x01', '\x00\x03'];
  35881. var encodings = ['\x00\x00', '\x00\x01'];
  35882. var languages = ['\x00\x00', '\x04\x09'];
  35883. var namesRecordCount = strings.length * platforms.length;
  35884. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  35885. var strOffset = 0;
  35886. for (i = 0, ii = platforms.length; i < ii; i++) {
  35887. var strs = names[i];
  35888. for (j = 0, jj = strs.length; j < jj; j++) {
  35889. str = strs[j];
  35890. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  35891. nameTable += nameRecord;
  35892. strOffset += str.length;
  35893. }
  35894. }
  35895. nameTable += strings.join('') + stringsUnicode.join('');
  35896. return nameTable;
  35897. }
  35898. Font.prototype = {
  35899. name: null,
  35900. font: null,
  35901. mimetype: null,
  35902. encoding: null,
  35903. get renderer() {
  35904. var renderer = _font_renderer.FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  35905. return (0, _util.shadow)(this, 'renderer', renderer);
  35906. },
  35907. exportData: function Font_exportData() {
  35908. var data = {};
  35909. for (var i in this) {
  35910. if (this.hasOwnProperty(i)) {
  35911. data[i] = this[i];
  35912. }
  35913. }
  35914. return data;
  35915. },
  35916. fallbackToSystemFont: function Font_fallbackToSystemFont() {
  35917. var _this = this;
  35918. this.missingFile = true;
  35919. var charCode, unicode;
  35920. var name = this.name;
  35921. var type = this.type;
  35922. var subtype = this.subtype;
  35923. var fontName = name.replace(/[,_]/g, '-');
  35924. var stdFontMap = (0, _standard_fonts.getStdFontMap)(),
  35925. nonStdFontMap = (0, _standard_fonts.getNonStdFontMap)();
  35926. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  35927. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  35928. this.bold = fontName.search(/bold/gi) !== -1;
  35929. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  35930. this.black = name.search(/Black/g) !== -1;
  35931. this.remeasure = Object.keys(this.widths).length > 0;
  35932. if (isStandardFont && type === 'CIDFontType2' && this.cidEncoding.indexOf('Identity-') === 0) {
  35933. var GlyphMapForStandardFonts = (0, _standard_fonts.getGlyphMapForStandardFonts)();
  35934. var map = [];
  35935. for (charCode in GlyphMapForStandardFonts) {
  35936. map[+charCode] = GlyphMapForStandardFonts[charCode];
  35937. }
  35938. if (/Arial-?Black/i.test(name)) {
  35939. var SupplementalGlyphMapForArialBlack = (0, _standard_fonts.getSupplementalGlyphMapForArialBlack)();
  35940. for (charCode in SupplementalGlyphMapForArialBlack) {
  35941. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  35942. }
  35943. }
  35944. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  35945. if (!isIdentityUnicode) {
  35946. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  35947. map[+charCode] = unicodeCharCode;
  35948. });
  35949. }
  35950. this.toFontChar = map;
  35951. this.toUnicode = new ToUnicodeMap(map);
  35952. } else if (/Symbol/i.test(fontName)) {
  35953. this.toFontChar = buildToFontChar(_encodings.SymbolSetEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  35954. } else if (/Dingbats/i.test(fontName)) {
  35955. if (/Wingdings/i.test(name)) {
  35956. (0, _util.warn)('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  35957. }
  35958. this.toFontChar = buildToFontChar(_encodings.ZapfDingbatsEncoding, (0, _glyphlist.getDingbatsGlyphsUnicode)(), this.differences);
  35959. } else if (isStandardFont) {
  35960. this.toFontChar = buildToFontChar(this.defaultEncoding, (0, _glyphlist.getGlyphsUnicode)(), this.differences);
  35961. } else {
  35962. var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  35963. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  35964. if (!_this.composite) {
  35965. var glyphName = _this.differences[charCode] || _this.defaultEncoding[charCode];
  35966. unicode = (0, _unicode.getUnicodeForGlyph)(glyphName, glyphsUnicodeMap);
  35967. if (unicode !== -1) {
  35968. unicodeCharCode = unicode;
  35969. }
  35970. }
  35971. _this.toFontChar[charCode] = unicodeCharCode;
  35972. });
  35973. }
  35974. this.loadedName = fontName.split('-')[0];
  35975. this.loading = false;
  35976. this.fontType = getFontType(type, subtype);
  35977. },
  35978. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  35979. function readTableEntry(file) {
  35980. var tag = (0, _util.bytesToString)(file.getBytes(4));
  35981. var checksum = file.getInt32() >>> 0;
  35982. var offset = file.getInt32() >>> 0;
  35983. var length = file.getInt32() >>> 0;
  35984. var previousPosition = file.pos;
  35985. file.pos = file.start ? file.start : 0;
  35986. file.skip(offset);
  35987. var data = file.getBytes(length);
  35988. file.pos = previousPosition;
  35989. if (tag === 'head') {
  35990. data[8] = data[9] = data[10] = data[11] = 0;
  35991. data[17] |= 0x20;
  35992. }
  35993. return {
  35994. tag: tag,
  35995. checksum: checksum,
  35996. length: length,
  35997. offset: offset,
  35998. data: data
  35999. };
  36000. }
  36001. function readOpenTypeHeader(ttf) {
  36002. return {
  36003. version: (0, _util.bytesToString)(ttf.getBytes(4)),
  36004. numTables: ttf.getUint16(),
  36005. searchRange: ttf.getUint16(),
  36006. entrySelector: ttf.getUint16(),
  36007. rangeShift: ttf.getUint16()
  36008. };
  36009. }
  36010. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  36011. if (!cmap) {
  36012. (0, _util.warn)('No cmap table available.');
  36013. return {
  36014. platformId: -1,
  36015. encodingId: -1,
  36016. mappings: [],
  36017. hasShortCmap: false
  36018. };
  36019. }
  36020. var segment;
  36021. var start = (font.start ? font.start : 0) + cmap.offset;
  36022. font.pos = start;
  36023. font.getUint16();
  36024. var numTables = font.getUint16();
  36025. var potentialTable;
  36026. var canBreak = false;
  36027. for (var i = 0; i < numTables; i++) {
  36028. var platformId = font.getUint16();
  36029. var encodingId = font.getUint16();
  36030. var offset = font.getInt32() >>> 0;
  36031. var useTable = false;
  36032. if (potentialTable && potentialTable.platformId === platformId && potentialTable.encodingId === encodingId) {
  36033. continue;
  36034. }
  36035. if (platformId === 0 && encodingId === 0) {
  36036. useTable = true;
  36037. } else if (platformId === 1 && encodingId === 0) {
  36038. useTable = true;
  36039. } else if (platformId === 3 && encodingId === 1 && (hasEncoding || !potentialTable)) {
  36040. useTable = true;
  36041. if (!isSymbolicFont) {
  36042. canBreak = true;
  36043. }
  36044. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  36045. useTable = true;
  36046. canBreak = true;
  36047. }
  36048. if (useTable) {
  36049. potentialTable = {
  36050. platformId: platformId,
  36051. encodingId: encodingId,
  36052. offset: offset
  36053. };
  36054. }
  36055. if (canBreak) {
  36056. break;
  36057. }
  36058. }
  36059. if (potentialTable) {
  36060. font.pos = start + potentialTable.offset;
  36061. }
  36062. if (!potentialTable || font.peekByte() === -1) {
  36063. (0, _util.warn)('Could not find a preferred cmap table.');
  36064. return {
  36065. platformId: -1,
  36066. encodingId: -1,
  36067. mappings: [],
  36068. hasShortCmap: false
  36069. };
  36070. }
  36071. var format = font.getUint16();
  36072. font.getUint16();
  36073. font.getUint16();
  36074. var hasShortCmap = false;
  36075. var mappings = [];
  36076. var j, glyphId;
  36077. if (format === 0) {
  36078. for (j = 0; j < 256; j++) {
  36079. var index = font.getByte();
  36080. if (!index) {
  36081. continue;
  36082. }
  36083. mappings.push({
  36084. charCode: j,
  36085. glyphId: index
  36086. });
  36087. }
  36088. hasShortCmap = true;
  36089. } else if (format === 4) {
  36090. var segCount = font.getUint16() >> 1;
  36091. font.getBytes(6);
  36092. var segIndex,
  36093. segments = [];
  36094. for (segIndex = 0; segIndex < segCount; segIndex++) {
  36095. segments.push({ end: font.getUint16() });
  36096. }
  36097. font.getUint16();
  36098. for (segIndex = 0; segIndex < segCount; segIndex++) {
  36099. segments[segIndex].start = font.getUint16();
  36100. }
  36101. for (segIndex = 0; segIndex < segCount; segIndex++) {
  36102. segments[segIndex].delta = font.getUint16();
  36103. }
  36104. var offsetsCount = 0;
  36105. for (segIndex = 0; segIndex < segCount; segIndex++) {
  36106. segment = segments[segIndex];
  36107. var rangeOffset = font.getUint16();
  36108. if (!rangeOffset) {
  36109. segment.offsetIndex = -1;
  36110. continue;
  36111. }
  36112. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  36113. segment.offsetIndex = offsetIndex;
  36114. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  36115. }
  36116. var offsets = [];
  36117. for (j = 0; j < offsetsCount; j++) {
  36118. offsets.push(font.getUint16());
  36119. }
  36120. for (segIndex = 0; segIndex < segCount; segIndex++) {
  36121. segment = segments[segIndex];
  36122. start = segment.start;
  36123. var end = segment.end;
  36124. var delta = segment.delta;
  36125. offsetIndex = segment.offsetIndex;
  36126. for (j = start; j <= end; j++) {
  36127. if (j === 0xFFFF) {
  36128. continue;
  36129. }
  36130. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  36131. glyphId = glyphId + delta & 0xFFFF;
  36132. mappings.push({
  36133. charCode: j,
  36134. glyphId: glyphId
  36135. });
  36136. }
  36137. }
  36138. } else if (format === 6) {
  36139. var firstCode = font.getUint16();
  36140. var entryCount = font.getUint16();
  36141. for (j = 0; j < entryCount; j++) {
  36142. glyphId = font.getUint16();
  36143. var charCode = firstCode + j;
  36144. mappings.push({
  36145. charCode: charCode,
  36146. glyphId: glyphId
  36147. });
  36148. }
  36149. } else {
  36150. (0, _util.warn)('cmap table has unsupported format: ' + format);
  36151. return {
  36152. platformId: -1,
  36153. encodingId: -1,
  36154. mappings: [],
  36155. hasShortCmap: false
  36156. };
  36157. }
  36158. mappings.sort(function (a, b) {
  36159. return a.charCode - b.charCode;
  36160. });
  36161. for (i = 1; i < mappings.length; i++) {
  36162. if (mappings[i - 1].charCode === mappings[i].charCode) {
  36163. mappings.splice(i, 1);
  36164. i--;
  36165. }
  36166. }
  36167. return {
  36168. platformId: potentialTable.platformId,
  36169. encodingId: potentialTable.encodingId,
  36170. mappings: mappings,
  36171. hasShortCmap: hasShortCmap
  36172. };
  36173. }
  36174. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  36175. if (!header) {
  36176. if (metrics) {
  36177. metrics.data = null;
  36178. }
  36179. return;
  36180. }
  36181. font.pos = (font.start ? font.start : 0) + header.offset;
  36182. font.pos += header.length - 2;
  36183. var numOfMetrics = font.getUint16();
  36184. if (numOfMetrics > numGlyphs) {
  36185. (0, _util.info)('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  36186. numOfMetrics = numGlyphs;
  36187. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  36188. header.data[35] = numOfMetrics & 0x00ff;
  36189. }
  36190. var numOfSidebearings = numGlyphs - numOfMetrics;
  36191. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  36192. if (numMissing > 0) {
  36193. var entries = new Uint8Array(metrics.length + numMissing * 2);
  36194. entries.set(metrics.data);
  36195. metrics.data = entries;
  36196. }
  36197. }
  36198. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  36199. var glyphProfile = {
  36200. length: 0,
  36201. sizeOfInstructions: 0
  36202. };
  36203. if (sourceEnd - sourceStart <= 12) {
  36204. return glyphProfile;
  36205. }
  36206. var glyf = source.subarray(sourceStart, sourceEnd);
  36207. var contoursCount = signedInt16(glyf[0], glyf[1]);
  36208. if (contoursCount < 0) {
  36209. contoursCount = -1;
  36210. writeSignedInt16(glyf, 0, contoursCount);
  36211. dest.set(glyf, destStart);
  36212. glyphProfile.length = glyf.length;
  36213. return glyphProfile;
  36214. }
  36215. var i,
  36216. j = 10,
  36217. flagsCount = 0;
  36218. for (i = 0; i < contoursCount; i++) {
  36219. var endPoint = glyf[j] << 8 | glyf[j + 1];
  36220. flagsCount = endPoint + 1;
  36221. j += 2;
  36222. }
  36223. var instructionsStart = j;
  36224. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  36225. glyphProfile.sizeOfInstructions = instructionsLength;
  36226. j += 2 + instructionsLength;
  36227. var instructionsEnd = j;
  36228. var coordinatesLength = 0;
  36229. for (i = 0; i < flagsCount; i++) {
  36230. var flag = glyf[j++];
  36231. if (flag & 0xC0) {
  36232. glyf[j - 1] = flag & 0x3F;
  36233. }
  36234. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  36235. coordinatesLength += xyLength;
  36236. if (flag & 8) {
  36237. var repeat = glyf[j++];
  36238. i += repeat;
  36239. coordinatesLength += repeat * xyLength;
  36240. }
  36241. }
  36242. if (coordinatesLength === 0) {
  36243. return glyphProfile;
  36244. }
  36245. var glyphDataLength = j + coordinatesLength;
  36246. if (glyphDataLength > glyf.length) {
  36247. return glyphProfile;
  36248. }
  36249. if (!hintsValid && instructionsLength > 0) {
  36250. dest.set(glyf.subarray(0, instructionsStart), destStart);
  36251. dest.set([0, 0], destStart + instructionsStart);
  36252. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  36253. glyphDataLength -= instructionsLength;
  36254. if (glyf.length - glyphDataLength > 3) {
  36255. glyphDataLength = glyphDataLength + 3 & ~3;
  36256. }
  36257. glyphProfile.length = glyphDataLength;
  36258. return glyphProfile;
  36259. }
  36260. if (glyf.length - glyphDataLength > 3) {
  36261. glyphDataLength = glyphDataLength + 3 & ~3;
  36262. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  36263. glyphProfile.length = glyphDataLength;
  36264. return glyphProfile;
  36265. }
  36266. dest.set(glyf, destStart);
  36267. glyphProfile.length = glyf.length;
  36268. return glyphProfile;
  36269. }
  36270. function sanitizeHead(head, numGlyphs, locaLength) {
  36271. var data = head.data;
  36272. var version = int32(data[0], data[1], data[2], data[3]);
  36273. if (version >> 16 !== 1) {
  36274. (0, _util.info)('Attempting to fix invalid version in head table: ' + version);
  36275. data[0] = 0;
  36276. data[1] = 1;
  36277. data[2] = 0;
  36278. data[3] = 0;
  36279. }
  36280. var indexToLocFormat = int16(data[50], data[51]);
  36281. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  36282. (0, _util.info)('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  36283. var numGlyphsPlusOne = numGlyphs + 1;
  36284. if (locaLength === numGlyphsPlusOne << 1) {
  36285. data[50] = 0;
  36286. data[51] = 0;
  36287. } else if (locaLength === numGlyphsPlusOne << 2) {
  36288. data[50] = 0;
  36289. data[51] = 1;
  36290. } else {
  36291. throw new _util.FormatError('Could not fix indexToLocFormat: ' + indexToLocFormat);
  36292. }
  36293. }
  36294. }
  36295. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions) {
  36296. var itemSize, itemDecode, itemEncode;
  36297. if (isGlyphLocationsLong) {
  36298. itemSize = 4;
  36299. itemDecode = function fontItemDecodeLong(data, offset) {
  36300. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36301. };
  36302. itemEncode = function fontItemEncodeLong(data, offset, value) {
  36303. data[offset] = value >>> 24 & 0xFF;
  36304. data[offset + 1] = value >> 16 & 0xFF;
  36305. data[offset + 2] = value >> 8 & 0xFF;
  36306. data[offset + 3] = value & 0xFF;
  36307. };
  36308. } else {
  36309. itemSize = 2;
  36310. itemDecode = function fontItemDecode(data, offset) {
  36311. return data[offset] << 9 | data[offset + 1] << 1;
  36312. };
  36313. itemEncode = function fontItemEncode(data, offset, value) {
  36314. data[offset] = value >> 9 & 0xFF;
  36315. data[offset + 1] = value >> 1 & 0xFF;
  36316. };
  36317. }
  36318. var locaData = loca.data;
  36319. var locaDataSize = itemSize * (1 + numGlyphs);
  36320. if (locaData.length !== locaDataSize) {
  36321. locaData = new Uint8Array(locaDataSize);
  36322. locaData.set(loca.data.subarray(0, locaDataSize));
  36323. loca.data = locaData;
  36324. }
  36325. var oldGlyfData = glyf.data;
  36326. var oldGlyfDataLength = oldGlyfData.length;
  36327. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  36328. var startOffset = itemDecode(locaData, 0);
  36329. var writeOffset = 0;
  36330. var missingGlyphs = Object.create(null);
  36331. itemEncode(locaData, 0, writeOffset);
  36332. var i, j;
  36333. var locaCount = dupFirstEntry ? numGlyphs - 1 : numGlyphs;
  36334. for (i = 0, j = itemSize; i < locaCount; i++, j += itemSize) {
  36335. var endOffset = itemDecode(locaData, j);
  36336. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  36337. endOffset = oldGlyfDataLength;
  36338. }
  36339. if (endOffset > oldGlyfDataLength) {
  36340. startOffset = endOffset;
  36341. }
  36342. var glyphProfile = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  36343. var newLength = glyphProfile.length;
  36344. if (newLength === 0) {
  36345. missingGlyphs[i] = true;
  36346. }
  36347. if (glyphProfile.sizeOfInstructions > maxSizeOfInstructions) {
  36348. maxSizeOfInstructions = glyphProfile.sizeOfInstructions;
  36349. }
  36350. writeOffset += newLength;
  36351. itemEncode(locaData, j, writeOffset);
  36352. startOffset = endOffset;
  36353. }
  36354. if (writeOffset === 0) {
  36355. var simpleGlyph = new Uint8Array([0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
  36356. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  36357. itemEncode(locaData, j, simpleGlyph.length);
  36358. }
  36359. glyf.data = simpleGlyph;
  36360. } else if (dupFirstEntry) {
  36361. var firstEntryLength = itemDecode(locaData, itemSize);
  36362. if (newGlyfData.length > firstEntryLength + writeOffset) {
  36363. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  36364. } else {
  36365. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  36366. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  36367. }
  36368. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  36369. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  36370. } else {
  36371. glyf.data = newGlyfData.subarray(0, writeOffset);
  36372. }
  36373. return {
  36374. missingGlyphs: missingGlyphs,
  36375. maxSizeOfInstructions: maxSizeOfInstructions
  36376. };
  36377. }
  36378. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  36379. var start = (font.start ? font.start : 0) + post.offset;
  36380. font.pos = start;
  36381. var length = post.length,
  36382. end = start + length;
  36383. var version = font.getInt32();
  36384. font.getBytes(28);
  36385. var glyphNames;
  36386. var valid = true;
  36387. var i;
  36388. switch (version) {
  36389. case 0x00010000:
  36390. glyphNames = MacStandardGlyphOrdering;
  36391. break;
  36392. case 0x00020000:
  36393. var numGlyphs = font.getUint16();
  36394. if (numGlyphs !== maxpNumGlyphs) {
  36395. valid = false;
  36396. break;
  36397. }
  36398. var glyphNameIndexes = [];
  36399. for (i = 0; i < numGlyphs; ++i) {
  36400. var index = font.getUint16();
  36401. if (index >= 32768) {
  36402. valid = false;
  36403. break;
  36404. }
  36405. glyphNameIndexes.push(index);
  36406. }
  36407. if (!valid) {
  36408. break;
  36409. }
  36410. var customNames = [];
  36411. var strBuf = [];
  36412. while (font.pos < end) {
  36413. var stringLength = font.getByte();
  36414. strBuf.length = stringLength;
  36415. for (i = 0; i < stringLength; ++i) {
  36416. strBuf[i] = String.fromCharCode(font.getByte());
  36417. }
  36418. customNames.push(strBuf.join(''));
  36419. }
  36420. glyphNames = [];
  36421. for (i = 0; i < numGlyphs; ++i) {
  36422. var j = glyphNameIndexes[i];
  36423. if (j < 258) {
  36424. glyphNames.push(MacStandardGlyphOrdering[j]);
  36425. continue;
  36426. }
  36427. glyphNames.push(customNames[j - 258]);
  36428. }
  36429. break;
  36430. case 0x00030000:
  36431. break;
  36432. default:
  36433. (0, _util.warn)('Unknown/unsupported post table version ' + version);
  36434. valid = false;
  36435. if (properties.defaultEncoding) {
  36436. glyphNames = properties.defaultEncoding;
  36437. }
  36438. break;
  36439. }
  36440. properties.glyphNames = glyphNames;
  36441. return valid;
  36442. }
  36443. function readNameTable(nameTable) {
  36444. var start = (font.start ? font.start : 0) + nameTable.offset;
  36445. font.pos = start;
  36446. var names = [[], []];
  36447. var length = nameTable.length,
  36448. end = start + length;
  36449. var format = font.getUint16();
  36450. var FORMAT_0_HEADER_LENGTH = 6;
  36451. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  36452. return names;
  36453. }
  36454. var numRecords = font.getUint16();
  36455. var stringsStart = font.getUint16();
  36456. var records = [];
  36457. var NAME_RECORD_LENGTH = 12;
  36458. var i, ii;
  36459. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  36460. var r = {
  36461. platform: font.getUint16(),
  36462. encoding: font.getUint16(),
  36463. language: font.getUint16(),
  36464. name: font.getUint16(),
  36465. length: font.getUint16(),
  36466. offset: font.getUint16()
  36467. };
  36468. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  36469. records.push(r);
  36470. }
  36471. }
  36472. for (i = 0, ii = records.length; i < ii; i++) {
  36473. var record = records[i];
  36474. if (record.length <= 0) {
  36475. continue;
  36476. }
  36477. var pos = start + stringsStart + record.offset;
  36478. if (pos + record.length > end) {
  36479. continue;
  36480. }
  36481. font.pos = pos;
  36482. var nameIndex = record.name;
  36483. if (record.encoding) {
  36484. var str = '';
  36485. for (var j = 0, jj = record.length; j < jj; j += 2) {
  36486. str += String.fromCharCode(font.getUint16());
  36487. }
  36488. names[1][nameIndex] = str;
  36489. } else {
  36490. names[0][nameIndex] = (0, _util.bytesToString)(font.getBytes(record.length));
  36491. }
  36492. }
  36493. return names;
  36494. }
  36495. 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];
  36496. function sanitizeTTProgram(table, ttContext) {
  36497. var data = table.data;
  36498. var i = 0,
  36499. j,
  36500. n,
  36501. b,
  36502. funcId,
  36503. pc,
  36504. lastEndf = 0,
  36505. lastDeff = 0;
  36506. var stack = [];
  36507. var callstack = [];
  36508. var functionsCalled = [];
  36509. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  36510. var inFDEF = false,
  36511. ifLevel = 0,
  36512. inELSE = 0;
  36513. for (var ii = data.length; i < ii;) {
  36514. var op = data[i++];
  36515. if (op === 0x40) {
  36516. n = data[i++];
  36517. if (inFDEF || inELSE) {
  36518. i += n;
  36519. } else {
  36520. for (j = 0; j < n; j++) {
  36521. stack.push(data[i++]);
  36522. }
  36523. }
  36524. } else if (op === 0x41) {
  36525. n = data[i++];
  36526. if (inFDEF || inELSE) {
  36527. i += n * 2;
  36528. } else {
  36529. for (j = 0; j < n; j++) {
  36530. b = data[i++];
  36531. stack.push(b << 8 | data[i++]);
  36532. }
  36533. }
  36534. } else if ((op & 0xF8) === 0xB0) {
  36535. n = op - 0xB0 + 1;
  36536. if (inFDEF || inELSE) {
  36537. i += n;
  36538. } else {
  36539. for (j = 0; j < n; j++) {
  36540. stack.push(data[i++]);
  36541. }
  36542. }
  36543. } else if ((op & 0xF8) === 0xB8) {
  36544. n = op - 0xB8 + 1;
  36545. if (inFDEF || inELSE) {
  36546. i += n * 2;
  36547. } else {
  36548. for (j = 0; j < n; j++) {
  36549. b = data[i++];
  36550. stack.push(b << 8 | data[i++]);
  36551. }
  36552. }
  36553. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  36554. if (!inFDEF && !inELSE) {
  36555. funcId = stack[stack.length - 1];
  36556. ttContext.functionsUsed[funcId] = true;
  36557. if (funcId in ttContext.functionsStackDeltas) {
  36558. stack.length += ttContext.functionsStackDeltas[funcId];
  36559. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  36560. callstack.push({
  36561. data: data,
  36562. i: i,
  36563. stackTop: stack.length - 1
  36564. });
  36565. functionsCalled.push(funcId);
  36566. pc = ttContext.functionsDefined[funcId];
  36567. if (!pc) {
  36568. (0, _util.warn)('TT: CALL non-existent function');
  36569. ttContext.hintsValid = false;
  36570. return;
  36571. }
  36572. data = pc.data;
  36573. i = pc.i;
  36574. }
  36575. }
  36576. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  36577. if (inFDEF || inELSE) {
  36578. (0, _util.warn)('TT: nested FDEFs not allowed');
  36579. tooComplexToFollowFunctions = true;
  36580. }
  36581. inFDEF = true;
  36582. lastDeff = i;
  36583. funcId = stack.pop();
  36584. ttContext.functionsDefined[funcId] = {
  36585. data: data,
  36586. i: i
  36587. };
  36588. } else if (op === 0x2D) {
  36589. if (inFDEF) {
  36590. inFDEF = false;
  36591. lastEndf = i;
  36592. } else {
  36593. pc = callstack.pop();
  36594. if (!pc) {
  36595. (0, _util.warn)('TT: ENDF bad stack');
  36596. ttContext.hintsValid = false;
  36597. return;
  36598. }
  36599. funcId = functionsCalled.pop();
  36600. data = pc.data;
  36601. i = pc.i;
  36602. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  36603. }
  36604. } else if (op === 0x89) {
  36605. if (inFDEF || inELSE) {
  36606. (0, _util.warn)('TT: nested IDEFs not allowed');
  36607. tooComplexToFollowFunctions = true;
  36608. }
  36609. inFDEF = true;
  36610. lastDeff = i;
  36611. } else if (op === 0x58) {
  36612. ++ifLevel;
  36613. } else if (op === 0x1B) {
  36614. inELSE = ifLevel;
  36615. } else if (op === 0x59) {
  36616. if (inELSE === ifLevel) {
  36617. inELSE = 0;
  36618. }
  36619. --ifLevel;
  36620. } else if (op === 0x1C) {
  36621. if (!inFDEF && !inELSE) {
  36622. var offset = stack[stack.length - 1];
  36623. if (offset > 0) {
  36624. i += offset - 1;
  36625. }
  36626. }
  36627. }
  36628. if (!inFDEF && !inELSE) {
  36629. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  36630. if (op >= 0x71 && op <= 0x75) {
  36631. n = stack.pop();
  36632. if (!isNaN(n)) {
  36633. stackDelta = -n * 2;
  36634. }
  36635. }
  36636. while (stackDelta < 0 && stack.length > 0) {
  36637. stack.pop();
  36638. stackDelta++;
  36639. }
  36640. while (stackDelta > 0) {
  36641. stack.push(NaN);
  36642. stackDelta--;
  36643. }
  36644. }
  36645. }
  36646. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  36647. var content = [data];
  36648. if (i > data.length) {
  36649. content.push(new Uint8Array(i - data.length));
  36650. }
  36651. if (lastDeff > lastEndf) {
  36652. (0, _util.warn)('TT: complementing a missing function tail');
  36653. content.push(new Uint8Array([0x22, 0x2D]));
  36654. }
  36655. foldTTTable(table, content);
  36656. }
  36657. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  36658. if (ttContext.tooComplexToFollowFunctions) {
  36659. return;
  36660. }
  36661. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  36662. (0, _util.warn)('TT: more functions defined than expected');
  36663. ttContext.hintsValid = false;
  36664. return;
  36665. }
  36666. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  36667. if (j > maxFunctionDefs) {
  36668. (0, _util.warn)('TT: invalid function id: ' + j);
  36669. ttContext.hintsValid = false;
  36670. return;
  36671. }
  36672. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  36673. (0, _util.warn)('TT: undefined function: ' + j);
  36674. ttContext.hintsValid = false;
  36675. return;
  36676. }
  36677. }
  36678. }
  36679. function foldTTTable(table, content) {
  36680. if (content.length > 1) {
  36681. var newLength = 0;
  36682. var j, jj;
  36683. for (j = 0, jj = content.length; j < jj; j++) {
  36684. newLength += content[j].length;
  36685. }
  36686. newLength = newLength + 3 & ~3;
  36687. var result = new Uint8Array(newLength);
  36688. var pos = 0;
  36689. for (j = 0, jj = content.length; j < jj; j++) {
  36690. result.set(content[j], pos);
  36691. pos += content[j].length;
  36692. }
  36693. table.data = result;
  36694. table.length = newLength;
  36695. }
  36696. }
  36697. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  36698. var ttContext = {
  36699. functionsDefined: [],
  36700. functionsUsed: [],
  36701. functionsStackDeltas: [],
  36702. tooComplexToFollowFunctions: false,
  36703. hintsValid: true
  36704. };
  36705. if (fpgm) {
  36706. sanitizeTTProgram(fpgm, ttContext);
  36707. }
  36708. if (prep) {
  36709. sanitizeTTProgram(prep, ttContext);
  36710. }
  36711. if (fpgm) {
  36712. checkInvalidFunctions(ttContext, maxFunctionDefs);
  36713. }
  36714. if (cvt && cvt.length & 1) {
  36715. var cvtData = new Uint8Array(cvt.length + 1);
  36716. cvtData.set(cvt.data);
  36717. cvt.data = cvtData;
  36718. }
  36719. return ttContext.hintsValid;
  36720. }
  36721. font = new _stream.Stream(new Uint8Array(font.getBytes()));
  36722. var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
  36723. var header = readOpenTypeHeader(font);
  36724. var numTables = header.numTables;
  36725. var cff, cffFile;
  36726. var tables = Object.create(null);
  36727. tables['OS/2'] = null;
  36728. tables['cmap'] = null;
  36729. tables['head'] = null;
  36730. tables['hhea'] = null;
  36731. tables['hmtx'] = null;
  36732. tables['maxp'] = null;
  36733. tables['name'] = null;
  36734. tables['post'] = null;
  36735. var table;
  36736. for (var i = 0; i < numTables; i++) {
  36737. table = readTableEntry(font);
  36738. if (VALID_TABLES.indexOf(table.tag) < 0) {
  36739. continue;
  36740. }
  36741. if (table.length === 0) {
  36742. continue;
  36743. }
  36744. tables[table.tag] = table;
  36745. }
  36746. var isTrueType = !tables['CFF '];
  36747. if (!isTrueType) {
  36748. if (header.version === 'OTTO' && !(properties.composite && properties.cidToGidMap) || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  36749. cffFile = new _stream.Stream(tables['CFF '].data);
  36750. cff = new CFFFont(cffFile, properties);
  36751. adjustWidths(properties);
  36752. return this.convert(name, cff, properties);
  36753. }
  36754. delete tables['glyf'];
  36755. delete tables['loca'];
  36756. delete tables['fpgm'];
  36757. delete tables['prep'];
  36758. delete tables['cvt '];
  36759. this.isOpenType = true;
  36760. } else {
  36761. if (!tables['loca']) {
  36762. throw new _util.FormatError('Required "loca" table is not found');
  36763. }
  36764. if (!tables['glyf']) {
  36765. (0, _util.warn)('Required "glyf" table is not found -- trying to recover.');
  36766. tables['glyf'] = {
  36767. tag: 'glyf',
  36768. data: new Uint8Array(0)
  36769. };
  36770. }
  36771. this.isOpenType = false;
  36772. }
  36773. if (!tables['maxp']) {
  36774. throw new _util.FormatError('Required "maxp" table is not found');
  36775. }
  36776. font.pos = (font.start || 0) + tables['maxp'].offset;
  36777. var version = font.getInt32();
  36778. var numGlyphs = font.getUint16();
  36779. var maxFunctionDefs = 0;
  36780. var maxSizeOfInstructions = 0;
  36781. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  36782. font.pos += 8;
  36783. var maxZones = font.getUint16();
  36784. if (maxZones > 2) {
  36785. tables['maxp'].data[14] = 0;
  36786. tables['maxp'].data[15] = 2;
  36787. }
  36788. font.pos += 4;
  36789. maxFunctionDefs = font.getUint16();
  36790. font.pos += 6;
  36791. maxSizeOfInstructions = font.getUint16();
  36792. }
  36793. var dupFirstEntry = false;
  36794. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\0') {
  36795. dupFirstEntry = true;
  36796. numGlyphs++;
  36797. tables['maxp'].data[4] = numGlyphs >> 8;
  36798. tables['maxp'].data[5] = numGlyphs & 255;
  36799. }
  36800. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  36801. if (!hintsValid) {
  36802. delete tables['fpgm'];
  36803. delete tables['prep'];
  36804. delete tables['cvt '];
  36805. }
  36806. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  36807. if (!tables['head']) {
  36808. throw new _util.FormatError('Required "head" table is not found');
  36809. }
  36810. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  36811. var missingGlyphs = Object.create(null);
  36812. if (isTrueType) {
  36813. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  36814. var glyphsInfo = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry, maxSizeOfInstructions);
  36815. missingGlyphs = glyphsInfo.missingGlyphs;
  36816. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  36817. tables['maxp'].data[26] = glyphsInfo.maxSizeOfInstructions >> 8;
  36818. tables['maxp'].data[27] = glyphsInfo.maxSizeOfInstructions & 255;
  36819. }
  36820. }
  36821. if (!tables['hhea']) {
  36822. throw new _util.FormatError('Required "hhea" table is not found');
  36823. }
  36824. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  36825. tables['hhea'].data[10] = 0xFF;
  36826. tables['hhea'].data[11] = 0xFF;
  36827. }
  36828. var metricsOverride = {
  36829. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  36830. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  36831. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  36832. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  36833. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  36834. };
  36835. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  36836. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  36837. if (tables['post']) {
  36838. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  36839. if (!valid) {
  36840. tables['post'] = null;
  36841. }
  36842. }
  36843. var charCodeToGlyphId = [],
  36844. charCode;
  36845. function hasGlyph(glyphId) {
  36846. return !missingGlyphs[glyphId];
  36847. }
  36848. if (properties.composite) {
  36849. var cidToGidMap = properties.cidToGidMap || [];
  36850. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  36851. properties.cMap.forEach(function (charCode, cid) {
  36852. if (cid > 0xffff) {
  36853. throw new _util.FormatError('Max size of CID is 65,535');
  36854. }
  36855. var glyphId = -1;
  36856. if (isCidToGidMapEmpty) {
  36857. glyphId = cid;
  36858. } else if (cidToGidMap[cid] !== undefined) {
  36859. glyphId = cidToGidMap[cid];
  36860. }
  36861. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId)) {
  36862. charCodeToGlyphId[charCode] = glyphId;
  36863. }
  36864. });
  36865. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  36866. charCodeToGlyphId[0] = numGlyphs - 1;
  36867. }
  36868. } else {
  36869. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  36870. var cmapPlatformId = cmapTable.platformId;
  36871. var cmapEncodingId = cmapTable.encodingId;
  36872. var cmapMappings = cmapTable.mappings;
  36873. var cmapMappingsLength = cmapMappings.length;
  36874. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!(0, _encodings.getEncoding)(properties.baseEncodingName)) {
  36875. var baseEncoding = [];
  36876. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  36877. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  36878. }
  36879. var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  36880. for (charCode = 0; charCode < 256; charCode++) {
  36881. var glyphName, standardGlyphName;
  36882. if (this.differences && charCode in this.differences) {
  36883. glyphName = this.differences[charCode];
  36884. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  36885. glyphName = baseEncoding[charCode];
  36886. } else {
  36887. glyphName = _encodings.StandardEncoding[charCode];
  36888. }
  36889. if (!glyphName) {
  36890. continue;
  36891. }
  36892. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  36893. var unicodeOrCharCode;
  36894. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  36895. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  36896. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  36897. unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
  36898. }
  36899. var found = false;
  36900. for (i = 0; i < cmapMappingsLength; ++i) {
  36901. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  36902. continue;
  36903. }
  36904. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  36905. found = true;
  36906. break;
  36907. }
  36908. if (!found && properties.glyphNames) {
  36909. var glyphId = properties.glyphNames.indexOf(glyphName);
  36910. if (glyphId === -1 && standardGlyphName !== glyphName) {
  36911. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  36912. }
  36913. if (glyphId > 0 && hasGlyph(glyphId)) {
  36914. charCodeToGlyphId[charCode] = glyphId;
  36915. }
  36916. }
  36917. }
  36918. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  36919. for (i = 0; i < cmapMappingsLength; ++i) {
  36920. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  36921. }
  36922. } else {
  36923. for (i = 0; i < cmapMappingsLength; ++i) {
  36924. charCode = cmapMappings[i].charCode;
  36925. if (cmapPlatformId === 3 && charCode >= 0xF000 && charCode <= 0xF0FF) {
  36926. charCode &= 0xFF;
  36927. }
  36928. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  36929. }
  36930. }
  36931. }
  36932. if (charCodeToGlyphId.length === 0) {
  36933. charCodeToGlyphId[0] = 0;
  36934. }
  36935. var newMapping = adjustMapping(charCodeToGlyphId, properties, missingGlyphs);
  36936. this.toFontChar = newMapping.toFontChar;
  36937. tables['cmap'] = {
  36938. tag: 'cmap',
  36939. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  36940. };
  36941. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  36942. tables['OS/2'] = {
  36943. tag: 'OS/2',
  36944. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  36945. };
  36946. }
  36947. if (!tables['post']) {
  36948. tables['post'] = {
  36949. tag: 'post',
  36950. data: createPostTable(properties)
  36951. };
  36952. }
  36953. if (!isTrueType) {
  36954. try {
  36955. cffFile = new _stream.Stream(tables['CFF '].data);
  36956. var parser = new _cff_parser.CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  36957. cff = parser.parse();
  36958. var compiler = new _cff_parser.CFFCompiler(cff);
  36959. tables['CFF '].data = compiler.compile();
  36960. } catch (e) {
  36961. (0, _util.warn)('Failed to compile font ' + properties.loadedName);
  36962. }
  36963. }
  36964. if (!tables['name']) {
  36965. tables['name'] = {
  36966. tag: 'name',
  36967. data: createNameTable(this.name)
  36968. };
  36969. } else {
  36970. var namePrototype = readNameTable(tables['name']);
  36971. tables['name'].data = createNameTable(name, namePrototype);
  36972. }
  36973. var builder = new OpenTypeFileBuilder(header.version);
  36974. for (var tableTag in tables) {
  36975. builder.addTable(tableTag, tables[tableTag].data);
  36976. }
  36977. return builder.toArray();
  36978. },
  36979. convert: function Font_convert(fontName, font, properties) {
  36980. properties.fixedPitch = false;
  36981. if (properties.builtInEncoding) {
  36982. adjustToUnicode(properties, properties.builtInEncoding);
  36983. }
  36984. var mapping = font.getGlyphMapping(properties);
  36985. var newMapping = adjustMapping(mapping, properties, Object.create(null));
  36986. this.toFontChar = newMapping.toFontChar;
  36987. var numGlyphs = font.numGlyphs;
  36988. function getCharCodes(charCodeToGlyphId, glyphId) {
  36989. var charCodes = null;
  36990. for (var charCode in charCodeToGlyphId) {
  36991. if (glyphId === charCodeToGlyphId[charCode]) {
  36992. if (!charCodes) {
  36993. charCodes = [];
  36994. }
  36995. charCodes.push(charCode | 0);
  36996. }
  36997. }
  36998. return charCodes;
  36999. }
  37000. function createCharCode(charCodeToGlyphId, glyphId) {
  37001. for (var charCode in charCodeToGlyphId) {
  37002. if (glyphId === charCodeToGlyphId[charCode]) {
  37003. return charCode | 0;
  37004. }
  37005. }
  37006. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  37007. return newMapping.nextAvailableFontCharCode++;
  37008. }
  37009. var seacs = font.seacs;
  37010. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  37011. var matrix = properties.fontMatrix || _util.FONT_IDENTITY_MATRIX;
  37012. var charset = font.getCharset();
  37013. var seacMap = Object.create(null);
  37014. for (var glyphId in seacs) {
  37015. glyphId |= 0;
  37016. var seac = seacs[glyphId];
  37017. var baseGlyphName = _encodings.StandardEncoding[seac[2]];
  37018. var accentGlyphName = _encodings.StandardEncoding[seac[3]];
  37019. var baseGlyphId = charset.indexOf(baseGlyphName);
  37020. var accentGlyphId = charset.indexOf(accentGlyphName);
  37021. if (baseGlyphId < 0 || accentGlyphId < 0) {
  37022. continue;
  37023. }
  37024. var accentOffset = {
  37025. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  37026. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  37027. };
  37028. var charCodes = getCharCodes(mapping, glyphId);
  37029. if (!charCodes) {
  37030. continue;
  37031. }
  37032. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  37033. var charCode = charCodes[i];
  37034. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  37035. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  37036. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  37037. seacMap[charCode] = {
  37038. baseFontCharCode: baseFontCharCode,
  37039. accentFontCharCode: accentFontCharCode,
  37040. accentOffset: accentOffset
  37041. };
  37042. }
  37043. }
  37044. properties.seacMap = seacMap;
  37045. }
  37046. var unitsPerEm = 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];
  37047. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  37048. builder.addTable('CFF ', font.data);
  37049. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  37050. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  37051. builder.addTable('head', '\x00\x01\x00\x00' + '\x00\x00\x10\x00' + '\x00\x00\x00\x00' + '\x5F\x0F\x3C\xF5' + '\x00\x00' + safeString16(unitsPerEm) + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00' + safeString16(properties.descent) + '\x0F\xFF' + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + '\x00\x11' + '\x00\x00' + '\x00\x00' + '\x00\x00');
  37052. builder.addTable('hhea', '\x00\x01\x00\x00' + safeString16(properties.ascent) + safeString16(properties.descent) + '\x00\x00' + '\xFF\xFF' + '\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));
  37053. builder.addTable('hmtx', function fontFieldsHmtx() {
  37054. var charstrings = font.charstrings;
  37055. var cffWidths = font.cff ? font.cff.widths : null;
  37056. var hmtx = '\x00\x00\x00\x00';
  37057. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  37058. var width = 0;
  37059. if (charstrings) {
  37060. var charstring = charstrings[i - 1];
  37061. width = 'width' in charstring ? charstring.width : 0;
  37062. } else if (cffWidths) {
  37063. width = Math.ceil(cffWidths[i] || 0);
  37064. }
  37065. hmtx += string16(width) + string16(0);
  37066. }
  37067. return hmtx;
  37068. }());
  37069. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  37070. builder.addTable('name', createNameTable(fontName));
  37071. builder.addTable('post', createPostTable(properties));
  37072. return builder.toArray();
  37073. },
  37074. get spaceWidth() {
  37075. if ('_shadowWidth' in this) {
  37076. return this._shadowWidth;
  37077. }
  37078. var possibleSpaceReplacements = ['space', 'minus', 'one', 'i', 'I'];
  37079. var width;
  37080. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  37081. var glyphName = possibleSpaceReplacements[i];
  37082. if (glyphName in this.widths) {
  37083. width = this.widths[glyphName];
  37084. break;
  37085. }
  37086. var glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  37087. var glyphUnicode = glyphsUnicodeMap[glyphName];
  37088. var charcode = 0;
  37089. if (this.composite) {
  37090. if (this.cMap.contains(glyphUnicode)) {
  37091. charcode = this.cMap.lookup(glyphUnicode);
  37092. }
  37093. }
  37094. if (!charcode && this.toUnicode) {
  37095. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  37096. }
  37097. if (charcode <= 0) {
  37098. charcode = glyphUnicode;
  37099. }
  37100. width = this.widths[charcode];
  37101. if (width) {
  37102. break;
  37103. }
  37104. }
  37105. width = width || this.defaultWidth;
  37106. this._shadowWidth = width;
  37107. return width;
  37108. },
  37109. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  37110. var fontCharCode, width, operatorListId;
  37111. var widthCode = charcode;
  37112. if (this.cMap && this.cMap.contains(charcode)) {
  37113. widthCode = this.cMap.lookup(charcode);
  37114. }
  37115. width = this.widths[widthCode];
  37116. width = (0, _util.isNum)(width) ? width : this.defaultWidth;
  37117. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  37118. var unicode = this.toUnicode.get(charcode) || charcode;
  37119. if (typeof unicode === 'number') {
  37120. unicode = String.fromCharCode(unicode);
  37121. }
  37122. var isInFont = charcode in this.toFontChar;
  37123. fontCharCode = this.toFontChar[charcode] || charcode;
  37124. if (this.missingFile) {
  37125. fontCharCode = (0, _unicode.mapSpecialUnicodeValues)(fontCharCode);
  37126. }
  37127. if (this.isType3Font) {
  37128. operatorListId = fontCharCode;
  37129. }
  37130. var accent = null;
  37131. if (this.seacMap && this.seacMap[charcode]) {
  37132. isInFont = true;
  37133. var seac = this.seacMap[charcode];
  37134. fontCharCode = seac.baseFontCharCode;
  37135. accent = {
  37136. fontChar: String.fromCharCode(seac.accentFontCharCode),
  37137. offset: seac.accentOffset
  37138. };
  37139. }
  37140. var fontChar = String.fromCharCode(fontCharCode);
  37141. var glyph = this.glyphCache[charcode];
  37142. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  37143. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  37144. this.glyphCache[charcode] = glyph;
  37145. }
  37146. return glyph;
  37147. },
  37148. charsToGlyphs: function Font_charsToGlyphs(chars) {
  37149. var charsCache = this.charsCache;
  37150. var glyphs, glyph, charcode;
  37151. if (charsCache) {
  37152. glyphs = charsCache[chars];
  37153. if (glyphs) {
  37154. return glyphs;
  37155. }
  37156. }
  37157. if (!charsCache) {
  37158. charsCache = this.charsCache = Object.create(null);
  37159. }
  37160. glyphs = [];
  37161. var charsCacheKey = chars;
  37162. var i = 0,
  37163. ii;
  37164. if (this.cMap) {
  37165. var c = Object.create(null);
  37166. while (i < chars.length) {
  37167. this.cMap.readCharCode(chars, i, c);
  37168. charcode = c.charcode;
  37169. var length = c.length;
  37170. i += length;
  37171. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  37172. glyph = this.charToGlyph(charcode, isSpace);
  37173. glyphs.push(glyph);
  37174. }
  37175. } else {
  37176. for (i = 0, ii = chars.length; i < ii; ++i) {
  37177. charcode = chars.charCodeAt(i);
  37178. glyph = this.charToGlyph(charcode, charcode === 0x20);
  37179. glyphs.push(glyph);
  37180. }
  37181. }
  37182. return charsCache[charsCacheKey] = glyphs;
  37183. }
  37184. };
  37185. return Font;
  37186. }();
  37187. var ErrorFont = function ErrorFontClosure() {
  37188. function ErrorFont(error) {
  37189. this.error = error;
  37190. this.loadedName = 'g_font_error';
  37191. this.loading = false;
  37192. }
  37193. ErrorFont.prototype = {
  37194. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  37195. return [];
  37196. },
  37197. exportData: function ErrorFont_exportData() {
  37198. return { error: this.error };
  37199. }
  37200. };
  37201. return ErrorFont;
  37202. }();
  37203. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  37204. var charCodeToGlyphId = Object.create(null);
  37205. var glyphId, charCode, baseEncoding;
  37206. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  37207. if (properties.baseEncodingName) {
  37208. baseEncoding = (0, _encodings.getEncoding)(properties.baseEncodingName);
  37209. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  37210. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  37211. if (glyphId >= 0) {
  37212. charCodeToGlyphId[charCode] = glyphId;
  37213. } else {
  37214. charCodeToGlyphId[charCode] = 0;
  37215. }
  37216. }
  37217. } else if (isSymbolicFont) {
  37218. for (charCode in builtInEncoding) {
  37219. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  37220. }
  37221. } else {
  37222. baseEncoding = _encodings.StandardEncoding;
  37223. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  37224. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  37225. if (glyphId >= 0) {
  37226. charCodeToGlyphId[charCode] = glyphId;
  37227. } else {
  37228. charCodeToGlyphId[charCode] = 0;
  37229. }
  37230. }
  37231. }
  37232. var differences = properties.differences,
  37233. glyphsUnicodeMap;
  37234. if (differences) {
  37235. for (charCode in differences) {
  37236. var glyphName = differences[charCode];
  37237. glyphId = glyphNames.indexOf(glyphName);
  37238. if (glyphId === -1) {
  37239. if (!glyphsUnicodeMap) {
  37240. glyphsUnicodeMap = (0, _glyphlist.getGlyphsUnicode)();
  37241. }
  37242. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  37243. if (standardGlyphName !== glyphName) {
  37244. glyphId = glyphNames.indexOf(standardGlyphName);
  37245. }
  37246. }
  37247. if (glyphId >= 0) {
  37248. charCodeToGlyphId[charCode] = glyphId;
  37249. } else {
  37250. charCodeToGlyphId[charCode] = 0;
  37251. }
  37252. }
  37253. }
  37254. return charCodeToGlyphId;
  37255. }
  37256. var Type1Font = function Type1FontClosure() {
  37257. function findBlock(streamBytes, signature, startIndex) {
  37258. var streamBytesLength = streamBytes.length;
  37259. var signatureLength = signature.length;
  37260. var scanLength = streamBytesLength - signatureLength;
  37261. var i = startIndex,
  37262. j,
  37263. found = false;
  37264. while (i < scanLength) {
  37265. j = 0;
  37266. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  37267. j++;
  37268. }
  37269. if (j >= signatureLength) {
  37270. i += j;
  37271. while (i < streamBytesLength && (0, _util.isSpace)(streamBytes[i])) {
  37272. i++;
  37273. }
  37274. found = true;
  37275. break;
  37276. }
  37277. i++;
  37278. }
  37279. return {
  37280. found: found,
  37281. length: i
  37282. };
  37283. }
  37284. function getHeaderBlock(stream, suggestedLength) {
  37285. var EEXEC_SIGNATURE = [0x65, 0x65, 0x78, 0x65, 0x63];
  37286. var streamStartPos = stream.pos;
  37287. var headerBytes, headerBytesLength, block;
  37288. try {
  37289. headerBytes = stream.getBytes(suggestedLength);
  37290. headerBytesLength = headerBytes.length;
  37291. } catch (ex) {
  37292. if (ex instanceof _util.MissingDataException) {
  37293. throw ex;
  37294. }
  37295. }
  37296. if (headerBytesLength === suggestedLength) {
  37297. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  37298. if (block.found && block.length === suggestedLength) {
  37299. return {
  37300. stream: new _stream.Stream(headerBytes),
  37301. length: suggestedLength
  37302. };
  37303. }
  37304. }
  37305. (0, _util.warn)('Invalid "Length1" property in Type1 font -- trying to recover.');
  37306. stream.pos = streamStartPos;
  37307. var SCAN_BLOCK_LENGTH = 2048;
  37308. var actualLength;
  37309. while (true) {
  37310. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  37311. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  37312. if (block.length === 0) {
  37313. break;
  37314. }
  37315. stream.pos += block.length;
  37316. if (block.found) {
  37317. actualLength = stream.pos - streamStartPos;
  37318. break;
  37319. }
  37320. }
  37321. stream.pos = streamStartPos;
  37322. if (actualLength) {
  37323. return {
  37324. stream: new _stream.Stream(stream.getBytes(actualLength)),
  37325. length: actualLength
  37326. };
  37327. }
  37328. (0, _util.warn)('Unable to recover "Length1" property in Type1 font -- using as is.');
  37329. return {
  37330. stream: new _stream.Stream(stream.getBytes(suggestedLength)),
  37331. length: suggestedLength
  37332. };
  37333. }
  37334. function getEexecBlock(stream, suggestedLength) {
  37335. var eexecBytes = stream.getBytes();
  37336. return {
  37337. stream: new _stream.Stream(eexecBytes),
  37338. length: eexecBytes.length
  37339. };
  37340. }
  37341. function Type1Font(name, file, properties) {
  37342. var PFB_HEADER_SIZE = 6;
  37343. var headerBlockLength = properties.length1;
  37344. var eexecBlockLength = properties.length2;
  37345. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  37346. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  37347. if (pfbHeaderPresent) {
  37348. file.skip(PFB_HEADER_SIZE);
  37349. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  37350. }
  37351. var headerBlock = getHeaderBlock(file, headerBlockLength);
  37352. var headerBlockParser = new _type1_parser.Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  37353. headerBlockParser.extractFontHeader(properties);
  37354. if (pfbHeaderPresent) {
  37355. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  37356. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  37357. }
  37358. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  37359. var eexecBlockParser = new _type1_parser.Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  37360. var data = eexecBlockParser.extractFontProgram();
  37361. for (var info in data.properties) {
  37362. properties[info] = data.properties[info];
  37363. }
  37364. var charstrings = data.charstrings;
  37365. var type2Charstrings = this.getType2Charstrings(charstrings);
  37366. var subrs = this.getType2Subrs(data.subrs);
  37367. this.charstrings = charstrings;
  37368. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  37369. this.seacs = this.getSeacs(data.charstrings);
  37370. }
  37371. Type1Font.prototype = {
  37372. get numGlyphs() {
  37373. return this.charstrings.length + 1;
  37374. },
  37375. getCharset: function Type1Font_getCharset() {
  37376. var charset = ['.notdef'];
  37377. var charstrings = this.charstrings;
  37378. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  37379. charset.push(charstrings[glyphId].glyphName);
  37380. }
  37381. return charset;
  37382. },
  37383. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  37384. var charstrings = this.charstrings;
  37385. var glyphNames = ['.notdef'],
  37386. glyphId;
  37387. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  37388. glyphNames.push(charstrings[glyphId].glyphName);
  37389. }
  37390. var encoding = properties.builtInEncoding;
  37391. if (encoding) {
  37392. var builtInEncoding = Object.create(null);
  37393. for (var charCode in encoding) {
  37394. glyphId = glyphNames.indexOf(encoding[charCode]);
  37395. if (glyphId >= 0) {
  37396. builtInEncoding[charCode] = glyphId;
  37397. }
  37398. }
  37399. }
  37400. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  37401. },
  37402. getSeacs: function Type1Font_getSeacs(charstrings) {
  37403. var i, ii;
  37404. var seacMap = [];
  37405. for (i = 0, ii = charstrings.length; i < ii; i++) {
  37406. var charstring = charstrings[i];
  37407. if (charstring.seac) {
  37408. seacMap[i + 1] = charstring.seac;
  37409. }
  37410. }
  37411. return seacMap;
  37412. },
  37413. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  37414. var type2Charstrings = [];
  37415. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  37416. type2Charstrings.push(type1Charstrings[i].charstring);
  37417. }
  37418. return type2Charstrings;
  37419. },
  37420. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  37421. var bias = 0;
  37422. var count = type1Subrs.length;
  37423. if (count < 1133) {
  37424. bias = 107;
  37425. } else if (count < 33769) {
  37426. bias = 1131;
  37427. } else {
  37428. bias = 32768;
  37429. }
  37430. var type2Subrs = [];
  37431. var i;
  37432. for (i = 0; i < bias; i++) {
  37433. type2Subrs.push([0x0B]);
  37434. }
  37435. for (i = 0; i < count; i++) {
  37436. type2Subrs.push(type1Subrs[i]);
  37437. }
  37438. return type2Subrs;
  37439. },
  37440. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  37441. var cff = new _cff_parser.CFF();
  37442. cff.header = new _cff_parser.CFFHeader(1, 0, 4, 4);
  37443. cff.names = [name];
  37444. var topDict = new _cff_parser.CFFTopDict();
  37445. topDict.setByName('version', 391);
  37446. topDict.setByName('Notice', 392);
  37447. topDict.setByName('FullName', 393);
  37448. topDict.setByName('FamilyName', 394);
  37449. topDict.setByName('Weight', 395);
  37450. topDict.setByName('Encoding', null);
  37451. topDict.setByName('FontMatrix', properties.fontMatrix);
  37452. topDict.setByName('FontBBox', properties.bbox);
  37453. topDict.setByName('charset', null);
  37454. topDict.setByName('CharStrings', null);
  37455. topDict.setByName('Private', null);
  37456. cff.topDict = topDict;
  37457. var strings = new _cff_parser.CFFStrings();
  37458. strings.add('Version 0.11');
  37459. strings.add('See original notice');
  37460. strings.add(name);
  37461. strings.add(name);
  37462. strings.add('Medium');
  37463. cff.strings = strings;
  37464. cff.globalSubrIndex = new _cff_parser.CFFIndex();
  37465. var count = glyphs.length;
  37466. var charsetArray = [0];
  37467. var i, ii;
  37468. for (i = 0; i < count; i++) {
  37469. var index = _cff_parser.CFFStandardStrings.indexOf(charstrings[i].glyphName);
  37470. if (index === -1) {
  37471. index = 0;
  37472. }
  37473. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  37474. }
  37475. cff.charset = new _cff_parser.CFFCharset(false, 0, [], charsetArray);
  37476. var charStringsIndex = new _cff_parser.CFFIndex();
  37477. charStringsIndex.add([0x8B, 0x0E]);
  37478. for (i = 0; i < count; i++) {
  37479. var glyph = glyphs[i];
  37480. if (glyph.length === 0) {
  37481. charStringsIndex.add([0x8B, 0x0E]);
  37482. continue;
  37483. }
  37484. charStringsIndex.add(glyph);
  37485. }
  37486. cff.charStrings = charStringsIndex;
  37487. var privateDict = new _cff_parser.CFFPrivateDict();
  37488. privateDict.setByName('Subrs', null);
  37489. var fields = ['BlueValues', 'OtherBlues', 'FamilyBlues', 'FamilyOtherBlues', 'StemSnapH', 'StemSnapV', 'BlueShift', 'BlueFuzz', 'BlueScale', 'LanguageGroup', 'ExpansionFactor', 'ForceBold', 'StdHW', 'StdVW'];
  37490. for (i = 0, ii = fields.length; i < ii; i++) {
  37491. var field = fields[i];
  37492. if (!(field in properties.privateData)) {
  37493. continue;
  37494. }
  37495. var value = properties.privateData[field];
  37496. if (Array.isArray(value)) {
  37497. for (var j = value.length - 1; j > 0; j--) {
  37498. value[j] -= value[j - 1];
  37499. }
  37500. }
  37501. privateDict.setByName(field, value);
  37502. }
  37503. cff.topDict.privateDict = privateDict;
  37504. var subrIndex = new _cff_parser.CFFIndex();
  37505. for (i = 0, ii = subrs.length; i < ii; i++) {
  37506. subrIndex.add(subrs[i]);
  37507. }
  37508. privateDict.subrsIndex = subrIndex;
  37509. var compiler = new _cff_parser.CFFCompiler(cff);
  37510. return compiler.compile();
  37511. }
  37512. };
  37513. return Type1Font;
  37514. }();
  37515. var CFFFont = function CFFFontClosure() {
  37516. function CFFFont(file, properties) {
  37517. this.properties = properties;
  37518. var parser = new _cff_parser.CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  37519. this.cff = parser.parse();
  37520. var compiler = new _cff_parser.CFFCompiler(this.cff);
  37521. this.seacs = this.cff.seacs;
  37522. try {
  37523. this.data = compiler.compile();
  37524. } catch (e) {
  37525. (0, _util.warn)('Failed to compile font ' + properties.loadedName);
  37526. this.data = file;
  37527. }
  37528. }
  37529. CFFFont.prototype = {
  37530. get numGlyphs() {
  37531. return this.cff.charStrings.count;
  37532. },
  37533. getCharset: function CFFFont_getCharset() {
  37534. return this.cff.charset.charset;
  37535. },
  37536. getGlyphMapping: function CFFFont_getGlyphMapping() {
  37537. var cff = this.cff;
  37538. var properties = this.properties;
  37539. var charsets = cff.charset.charset;
  37540. var charCodeToGlyphId;
  37541. var glyphId;
  37542. if (properties.composite) {
  37543. charCodeToGlyphId = Object.create(null);
  37544. if (cff.isCIDFont) {
  37545. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  37546. var cid = charsets[glyphId];
  37547. var charCode = properties.cMap.charCodeOf(cid);
  37548. charCodeToGlyphId[charCode] = glyphId;
  37549. }
  37550. } else {
  37551. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  37552. charCodeToGlyphId[glyphId] = glyphId;
  37553. }
  37554. }
  37555. return charCodeToGlyphId;
  37556. }
  37557. var encoding = cff.encoding ? cff.encoding.encoding : null;
  37558. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  37559. return charCodeToGlyphId;
  37560. }
  37561. };
  37562. return CFFFont;
  37563. }();
  37564. (function checkSeacSupport() {
  37565. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  37566. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED = true;
  37567. }
  37568. })();
  37569. (function checkChromeWindows() {
  37570. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  37571. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  37572. }
  37573. })();
  37574. exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
  37575. exports.PRIVATE_USE_OFFSET_START = PRIVATE_USE_OFFSET_START;
  37576. exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END;
  37577. exports.ErrorFont = ErrorFont;
  37578. exports.Font = Font;
  37579. exports.FontFlags = FontFlags;
  37580. exports.ToUnicodeMap = ToUnicodeMap;
  37581. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  37582. exports.ProblematicCharRanges = ProblematicCharRanges;
  37583. exports.getFontType = getFontType;
  37584. /***/ }),
  37585. /* 133 */
  37586. /***/ (function(module, exports, __w_pdfjs_require__) {
  37587. "use strict";
  37588. Object.defineProperty(exports, "__esModule", {
  37589. value: true
  37590. });
  37591. 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'];
  37592. 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'];
  37593. 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'];
  37594. exports.ISOAdobeCharset = ISOAdobeCharset;
  37595. exports.ExpertCharset = ExpertCharset;
  37596. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  37597. /***/ }),
  37598. /* 134 */
  37599. /***/ (function(module, exports, __w_pdfjs_require__) {
  37600. "use strict";
  37601. Object.defineProperty(exports, "__esModule", {
  37602. value: true
  37603. });
  37604. exports.FontRendererFactory = undefined;
  37605. var _util = __w_pdfjs_require__(0);
  37606. var _cff_parser = __w_pdfjs_require__(66);
  37607. var _glyphlist = __w_pdfjs_require__(42);
  37608. var _encodings = __w_pdfjs_require__(21);
  37609. var _stream = __w_pdfjs_require__(5);
  37610. var FontRendererFactory = function FontRendererFactoryClosure() {
  37611. function getLong(data, offset) {
  37612. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  37613. }
  37614. function getUshort(data, offset) {
  37615. return data[offset] << 8 | data[offset + 1];
  37616. }
  37617. function parseCmap(data, start, end) {
  37618. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  37619. var format = getUshort(data, start + offset);
  37620. var ranges, p, i;
  37621. if (format === 4) {
  37622. getUshort(data, start + offset + 2);
  37623. var segCount = getUshort(data, start + offset + 6) >> 1;
  37624. p = start + offset + 14;
  37625. ranges = [];
  37626. for (i = 0; i < segCount; i++, p += 2) {
  37627. ranges[i] = { end: getUshort(data, p) };
  37628. }
  37629. p += 2;
  37630. for (i = 0; i < segCount; i++, p += 2) {
  37631. ranges[i].start = getUshort(data, p);
  37632. }
  37633. for (i = 0; i < segCount; i++, p += 2) {
  37634. ranges[i].idDelta = getUshort(data, p);
  37635. }
  37636. for (i = 0; i < segCount; i++, p += 2) {
  37637. var idOffset = getUshort(data, p);
  37638. if (idOffset === 0) {
  37639. continue;
  37640. }
  37641. ranges[i].ids = [];
  37642. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  37643. ranges[i].ids[j] = getUshort(data, p + idOffset);
  37644. idOffset += 2;
  37645. }
  37646. }
  37647. return ranges;
  37648. } else if (format === 12) {
  37649. getLong(data, start + offset + 4);
  37650. var groups = getLong(data, start + offset + 12);
  37651. p = start + offset + 16;
  37652. ranges = [];
  37653. for (i = 0; i < groups; i++) {
  37654. ranges.push({
  37655. start: getLong(data, p),
  37656. end: getLong(data, p + 4),
  37657. idDelta: getLong(data, p + 8) - getLong(data, p)
  37658. });
  37659. p += 12;
  37660. }
  37661. return ranges;
  37662. }
  37663. throw new _util.FormatError('unsupported cmap: ' + format);
  37664. }
  37665. function parseCff(data, start, end, seacAnalysisEnabled) {
  37666. var properties = {};
  37667. var parser = new _cff_parser.CFFParser(new _stream.Stream(data, start, end - start), properties, seacAnalysisEnabled);
  37668. var cff = parser.parse();
  37669. return {
  37670. glyphs: cff.charStrings.objects,
  37671. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  37672. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  37673. };
  37674. }
  37675. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  37676. var itemSize, itemDecode;
  37677. if (isGlyphLocationsLong) {
  37678. itemSize = 4;
  37679. itemDecode = function fontItemDecodeLong(data, offset) {
  37680. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  37681. };
  37682. } else {
  37683. itemSize = 2;
  37684. itemDecode = function fontItemDecode(data, offset) {
  37685. return data[offset] << 9 | data[offset + 1] << 1;
  37686. };
  37687. }
  37688. var glyphs = [];
  37689. var startOffset = itemDecode(loca, 0);
  37690. for (var j = itemSize; j < loca.length; j += itemSize) {
  37691. var endOffset = itemDecode(loca, j);
  37692. glyphs.push(glyf.subarray(startOffset, endOffset));
  37693. startOffset = endOffset;
  37694. }
  37695. return glyphs;
  37696. }
  37697. function lookupCmap(ranges, unicode) {
  37698. var code = unicode.charCodeAt(0),
  37699. gid = 0;
  37700. var l = 0,
  37701. r = ranges.length - 1;
  37702. while (l < r) {
  37703. var c = l + r + 1 >> 1;
  37704. if (code < ranges[c].start) {
  37705. r = c - 1;
  37706. } else {
  37707. l = c;
  37708. }
  37709. }
  37710. if (ranges[l].start <= code && code <= ranges[l].end) {
  37711. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  37712. }
  37713. return {
  37714. charCode: code,
  37715. glyphId: gid
  37716. };
  37717. }
  37718. function compileGlyf(code, cmds, font) {
  37719. function moveTo(x, y) {
  37720. cmds.push({
  37721. cmd: 'moveTo',
  37722. args: [x, y]
  37723. });
  37724. }
  37725. function lineTo(x, y) {
  37726. cmds.push({
  37727. cmd: 'lineTo',
  37728. args: [x, y]
  37729. });
  37730. }
  37731. function quadraticCurveTo(xa, ya, x, y) {
  37732. cmds.push({
  37733. cmd: 'quadraticCurveTo',
  37734. args: [xa, ya, x, y]
  37735. });
  37736. }
  37737. var i = 0;
  37738. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  37739. var flags;
  37740. var x = 0,
  37741. y = 0;
  37742. i += 10;
  37743. if (numberOfContours < 0) {
  37744. do {
  37745. flags = code[i] << 8 | code[i + 1];
  37746. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  37747. i += 4;
  37748. var arg1, arg2;
  37749. if (flags & 0x01) {
  37750. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  37751. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  37752. i += 4;
  37753. } else {
  37754. arg1 = code[i++];
  37755. arg2 = code[i++];
  37756. }
  37757. if (flags & 0x02) {
  37758. x = arg1;
  37759. y = arg2;
  37760. } else {
  37761. x = 0;
  37762. y = 0;
  37763. }
  37764. var scaleX = 1,
  37765. scaleY = 1,
  37766. scale01 = 0,
  37767. scale10 = 0;
  37768. if (flags & 0x08) {
  37769. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  37770. i += 2;
  37771. } else if (flags & 0x40) {
  37772. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  37773. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  37774. i += 4;
  37775. } else if (flags & 0x80) {
  37776. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  37777. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  37778. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  37779. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  37780. i += 8;
  37781. }
  37782. var subglyph = font.glyphs[glyphIndex];
  37783. if (subglyph) {
  37784. cmds.push({ cmd: 'save' });
  37785. cmds.push({
  37786. cmd: 'transform',
  37787. args: [scaleX, scale01, scale10, scaleY, x, y]
  37788. });
  37789. compileGlyf(subglyph, cmds, font);
  37790. cmds.push({ cmd: 'restore' });
  37791. }
  37792. } while (flags & 0x20);
  37793. } else {
  37794. var endPtsOfContours = [];
  37795. var j, jj;
  37796. for (j = 0; j < numberOfContours; j++) {
  37797. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  37798. i += 2;
  37799. }
  37800. var instructionLength = code[i] << 8 | code[i + 1];
  37801. i += 2 + instructionLength;
  37802. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  37803. var points = [];
  37804. while (points.length < numberOfPoints) {
  37805. flags = code[i++];
  37806. var repeat = 1;
  37807. if (flags & 0x08) {
  37808. repeat += code[i++];
  37809. }
  37810. while (repeat-- > 0) {
  37811. points.push({ flags: flags });
  37812. }
  37813. }
  37814. for (j = 0; j < numberOfPoints; j++) {
  37815. switch (points[j].flags & 0x12) {
  37816. case 0x00:
  37817. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  37818. i += 2;
  37819. break;
  37820. case 0x02:
  37821. x -= code[i++];
  37822. break;
  37823. case 0x12:
  37824. x += code[i++];
  37825. break;
  37826. }
  37827. points[j].x = x;
  37828. }
  37829. for (j = 0; j < numberOfPoints; j++) {
  37830. switch (points[j].flags & 0x24) {
  37831. case 0x00:
  37832. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  37833. i += 2;
  37834. break;
  37835. case 0x04:
  37836. y -= code[i++];
  37837. break;
  37838. case 0x24:
  37839. y += code[i++];
  37840. break;
  37841. }
  37842. points[j].y = y;
  37843. }
  37844. var startPoint = 0;
  37845. for (i = 0; i < numberOfContours; i++) {
  37846. var endPoint = endPtsOfContours[i];
  37847. var contour = points.slice(startPoint, endPoint + 1);
  37848. if (contour[0].flags & 1) {
  37849. contour.push(contour[0]);
  37850. } else if (contour[contour.length - 1].flags & 1) {
  37851. contour.unshift(contour[contour.length - 1]);
  37852. } else {
  37853. var p = {
  37854. flags: 1,
  37855. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  37856. y: (contour[0].y + contour[contour.length - 1].y) / 2
  37857. };
  37858. contour.unshift(p);
  37859. contour.push(p);
  37860. }
  37861. moveTo(contour[0].x, contour[0].y);
  37862. for (j = 1, jj = contour.length; j < jj; j++) {
  37863. if (contour[j].flags & 1) {
  37864. lineTo(contour[j].x, contour[j].y);
  37865. } else if (contour[j + 1].flags & 1) {
  37866. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  37867. j++;
  37868. } else {
  37869. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  37870. }
  37871. }
  37872. startPoint = endPoint + 1;
  37873. }
  37874. }
  37875. }
  37876. function compileCharString(code, cmds, font) {
  37877. var stack = [];
  37878. var x = 0,
  37879. y = 0;
  37880. var stems = 0;
  37881. function moveTo(x, y) {
  37882. cmds.push({
  37883. cmd: 'moveTo',
  37884. args: [x, y]
  37885. });
  37886. }
  37887. function lineTo(x, y) {
  37888. cmds.push({
  37889. cmd: 'lineTo',
  37890. args: [x, y]
  37891. });
  37892. }
  37893. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  37894. cmds.push({
  37895. cmd: 'bezierCurveTo',
  37896. args: [x1, y1, x2, y2, x, y]
  37897. });
  37898. }
  37899. function parse(code) {
  37900. var i = 0;
  37901. while (i < code.length) {
  37902. var stackClean = false;
  37903. var v = code[i++];
  37904. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  37905. switch (v) {
  37906. case 1:
  37907. stems += stack.length >> 1;
  37908. stackClean = true;
  37909. break;
  37910. case 3:
  37911. stems += stack.length >> 1;
  37912. stackClean = true;
  37913. break;
  37914. case 4:
  37915. y += stack.pop();
  37916. moveTo(x, y);
  37917. stackClean = true;
  37918. break;
  37919. case 5:
  37920. while (stack.length > 0) {
  37921. x += stack.shift();
  37922. y += stack.shift();
  37923. lineTo(x, y);
  37924. }
  37925. break;
  37926. case 6:
  37927. while (stack.length > 0) {
  37928. x += stack.shift();
  37929. lineTo(x, y);
  37930. if (stack.length === 0) {
  37931. break;
  37932. }
  37933. y += stack.shift();
  37934. lineTo(x, y);
  37935. }
  37936. break;
  37937. case 7:
  37938. while (stack.length > 0) {
  37939. y += stack.shift();
  37940. lineTo(x, y);
  37941. if (stack.length === 0) {
  37942. break;
  37943. }
  37944. x += stack.shift();
  37945. lineTo(x, y);
  37946. }
  37947. break;
  37948. case 8:
  37949. while (stack.length > 0) {
  37950. xa = x + stack.shift();
  37951. ya = y + stack.shift();
  37952. xb = xa + stack.shift();
  37953. yb = ya + stack.shift();
  37954. x = xb + stack.shift();
  37955. y = yb + stack.shift();
  37956. bezierCurveTo(xa, ya, xb, yb, x, y);
  37957. }
  37958. break;
  37959. case 10:
  37960. n = stack.pop() + font.subrsBias;
  37961. subrCode = font.subrs[n];
  37962. if (subrCode) {
  37963. parse(subrCode);
  37964. }
  37965. break;
  37966. case 11:
  37967. return;
  37968. case 12:
  37969. v = code[i++];
  37970. switch (v) {
  37971. case 34:
  37972. xa = x + stack.shift();
  37973. xb = xa + stack.shift();
  37974. y1 = y + stack.shift();
  37975. x = xb + stack.shift();
  37976. bezierCurveTo(xa, y, xb, y1, x, y1);
  37977. xa = x + stack.shift();
  37978. xb = xa + stack.shift();
  37979. x = xb + stack.shift();
  37980. bezierCurveTo(xa, y1, xb, y, x, y);
  37981. break;
  37982. case 35:
  37983. xa = x + stack.shift();
  37984. ya = y + stack.shift();
  37985. xb = xa + stack.shift();
  37986. yb = ya + stack.shift();
  37987. x = xb + stack.shift();
  37988. y = yb + stack.shift();
  37989. bezierCurveTo(xa, ya, xb, yb, x, y);
  37990. xa = x + stack.shift();
  37991. ya = y + stack.shift();
  37992. xb = xa + stack.shift();
  37993. yb = ya + stack.shift();
  37994. x = xb + stack.shift();
  37995. y = yb + stack.shift();
  37996. bezierCurveTo(xa, ya, xb, yb, x, y);
  37997. stack.pop();
  37998. break;
  37999. case 36:
  38000. xa = x + stack.shift();
  38001. y1 = y + stack.shift();
  38002. xb = xa + stack.shift();
  38003. y2 = y1 + stack.shift();
  38004. x = xb + stack.shift();
  38005. bezierCurveTo(xa, y1, xb, y2, x, y2);
  38006. xa = x + stack.shift();
  38007. xb = xa + stack.shift();
  38008. y3 = y2 + stack.shift();
  38009. x = xb + stack.shift();
  38010. bezierCurveTo(xa, y2, xb, y3, x, y);
  38011. break;
  38012. case 37:
  38013. var x0 = x,
  38014. y0 = y;
  38015. xa = x + stack.shift();
  38016. ya = y + stack.shift();
  38017. xb = xa + stack.shift();
  38018. yb = ya + stack.shift();
  38019. x = xb + stack.shift();
  38020. y = yb + stack.shift();
  38021. bezierCurveTo(xa, ya, xb, yb, x, y);
  38022. xa = x + stack.shift();
  38023. ya = y + stack.shift();
  38024. xb = xa + stack.shift();
  38025. yb = ya + stack.shift();
  38026. x = xb;
  38027. y = yb;
  38028. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  38029. x += stack.shift();
  38030. } else {
  38031. y += stack.shift();
  38032. }
  38033. bezierCurveTo(xa, ya, xb, yb, x, y);
  38034. break;
  38035. default:
  38036. throw new _util.FormatError('unknown operator: 12 ' + v);
  38037. }
  38038. break;
  38039. case 14:
  38040. if (stack.length >= 4) {
  38041. var achar = stack.pop();
  38042. var bchar = stack.pop();
  38043. y = stack.pop();
  38044. x = stack.pop();
  38045. cmds.push({ cmd: 'save' });
  38046. cmds.push({
  38047. cmd: 'translate',
  38048. args: [x, y]
  38049. });
  38050. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]]));
  38051. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  38052. cmds.push({ cmd: 'restore' });
  38053. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]]));
  38054. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  38055. }
  38056. return;
  38057. case 18:
  38058. stems += stack.length >> 1;
  38059. stackClean = true;
  38060. break;
  38061. case 19:
  38062. stems += stack.length >> 1;
  38063. i += stems + 7 >> 3;
  38064. stackClean = true;
  38065. break;
  38066. case 20:
  38067. stems += stack.length >> 1;
  38068. i += stems + 7 >> 3;
  38069. stackClean = true;
  38070. break;
  38071. case 21:
  38072. y += stack.pop();
  38073. x += stack.pop();
  38074. moveTo(x, y);
  38075. stackClean = true;
  38076. break;
  38077. case 22:
  38078. x += stack.pop();
  38079. moveTo(x, y);
  38080. stackClean = true;
  38081. break;
  38082. case 23:
  38083. stems += stack.length >> 1;
  38084. stackClean = true;
  38085. break;
  38086. case 24:
  38087. while (stack.length > 2) {
  38088. xa = x + stack.shift();
  38089. ya = y + stack.shift();
  38090. xb = xa + stack.shift();
  38091. yb = ya + stack.shift();
  38092. x = xb + stack.shift();
  38093. y = yb + stack.shift();
  38094. bezierCurveTo(xa, ya, xb, yb, x, y);
  38095. }
  38096. x += stack.shift();
  38097. y += stack.shift();
  38098. lineTo(x, y);
  38099. break;
  38100. case 25:
  38101. while (stack.length > 6) {
  38102. x += stack.shift();
  38103. y += stack.shift();
  38104. lineTo(x, y);
  38105. }
  38106. xa = x + stack.shift();
  38107. ya = y + stack.shift();
  38108. xb = xa + stack.shift();
  38109. yb = ya + stack.shift();
  38110. x = xb + stack.shift();
  38111. y = yb + stack.shift();
  38112. bezierCurveTo(xa, ya, xb, yb, x, y);
  38113. break;
  38114. case 26:
  38115. if (stack.length % 2) {
  38116. x += stack.shift();
  38117. }
  38118. while (stack.length > 0) {
  38119. xa = x;
  38120. ya = y + stack.shift();
  38121. xb = xa + stack.shift();
  38122. yb = ya + stack.shift();
  38123. x = xb;
  38124. y = yb + stack.shift();
  38125. bezierCurveTo(xa, ya, xb, yb, x, y);
  38126. }
  38127. break;
  38128. case 27:
  38129. if (stack.length % 2) {
  38130. y += stack.shift();
  38131. }
  38132. while (stack.length > 0) {
  38133. xa = x + stack.shift();
  38134. ya = y;
  38135. xb = xa + stack.shift();
  38136. yb = ya + stack.shift();
  38137. x = xb + stack.shift();
  38138. y = yb;
  38139. bezierCurveTo(xa, ya, xb, yb, x, y);
  38140. }
  38141. break;
  38142. case 28:
  38143. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  38144. i += 2;
  38145. break;
  38146. case 29:
  38147. n = stack.pop() + font.gsubrsBias;
  38148. subrCode = font.gsubrs[n];
  38149. if (subrCode) {
  38150. parse(subrCode);
  38151. }
  38152. break;
  38153. case 30:
  38154. while (stack.length > 0) {
  38155. xa = x;
  38156. ya = y + stack.shift();
  38157. xb = xa + stack.shift();
  38158. yb = ya + stack.shift();
  38159. x = xb + stack.shift();
  38160. y = yb + (stack.length === 1 ? stack.shift() : 0);
  38161. bezierCurveTo(xa, ya, xb, yb, x, y);
  38162. if (stack.length === 0) {
  38163. break;
  38164. }
  38165. xa = x + stack.shift();
  38166. ya = y;
  38167. xb = xa + stack.shift();
  38168. yb = ya + stack.shift();
  38169. y = yb + stack.shift();
  38170. x = xb + (stack.length === 1 ? stack.shift() : 0);
  38171. bezierCurveTo(xa, ya, xb, yb, x, y);
  38172. }
  38173. break;
  38174. case 31:
  38175. while (stack.length > 0) {
  38176. xa = x + stack.shift();
  38177. ya = y;
  38178. xb = xa + stack.shift();
  38179. yb = ya + stack.shift();
  38180. y = yb + stack.shift();
  38181. x = xb + (stack.length === 1 ? stack.shift() : 0);
  38182. bezierCurveTo(xa, ya, xb, yb, x, y);
  38183. if (stack.length === 0) {
  38184. break;
  38185. }
  38186. xa = x;
  38187. ya = y + stack.shift();
  38188. xb = xa + stack.shift();
  38189. yb = ya + stack.shift();
  38190. x = xb + stack.shift();
  38191. y = yb + (stack.length === 1 ? stack.shift() : 0);
  38192. bezierCurveTo(xa, ya, xb, yb, x, y);
  38193. }
  38194. break;
  38195. default:
  38196. if (v < 32) {
  38197. throw new _util.FormatError('unknown operator: ' + v);
  38198. }
  38199. if (v < 247) {
  38200. stack.push(v - 139);
  38201. } else if (v < 251) {
  38202. stack.push((v - 247) * 256 + code[i++] + 108);
  38203. } else if (v < 255) {
  38204. stack.push(-(v - 251) * 256 - code[i++] - 108);
  38205. } else {
  38206. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  38207. i += 4;
  38208. }
  38209. break;
  38210. }
  38211. if (stackClean) {
  38212. stack.length = 0;
  38213. }
  38214. }
  38215. }
  38216. parse(code);
  38217. }
  38218. var noop = '';
  38219. function CompiledFont(fontMatrix) {
  38220. this.compiledGlyphs = Object.create(null);
  38221. this.compiledCharCodeToGlyphId = Object.create(null);
  38222. this.fontMatrix = fontMatrix;
  38223. }
  38224. CompiledFont.prototype = {
  38225. getPathJs: function getPathJs(unicode) {
  38226. var cmap = lookupCmap(this.cmap, unicode);
  38227. var fn = this.compiledGlyphs[cmap.glyphId];
  38228. if (!fn) {
  38229. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  38230. this.compiledGlyphs[cmap.glyphId] = fn;
  38231. }
  38232. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  38233. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  38234. }
  38235. return fn;
  38236. },
  38237. compileGlyph: function compileGlyph(code) {
  38238. if (!code || code.length === 0 || code[0] === 14) {
  38239. return noop;
  38240. }
  38241. var cmds = [];
  38242. cmds.push({ cmd: 'save' });
  38243. cmds.push({
  38244. cmd: 'transform',
  38245. args: this.fontMatrix.slice()
  38246. });
  38247. cmds.push({
  38248. cmd: 'scale',
  38249. args: ['size', '-size']
  38250. });
  38251. this.compileGlyphImpl(code, cmds);
  38252. cmds.push({ cmd: 'restore' });
  38253. return cmds;
  38254. },
  38255. compileGlyphImpl: function compileGlyphImpl() {
  38256. throw new Error('Children classes should implement this.');
  38257. },
  38258. hasBuiltPath: function hasBuiltPath(unicode) {
  38259. var cmap = lookupCmap(this.cmap, unicode);
  38260. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  38261. }
  38262. };
  38263. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  38264. fontMatrix = fontMatrix || [0.000488, 0, 0, 0.000488, 0, 0];
  38265. CompiledFont.call(this, fontMatrix);
  38266. this.glyphs = glyphs;
  38267. this.cmap = cmap;
  38268. }
  38269. _util.Util.inherit(TrueTypeCompiled, CompiledFont, {
  38270. compileGlyphImpl: function compileGlyphImpl(code, cmds) {
  38271. compileGlyf(code, cmds, this);
  38272. }
  38273. });
  38274. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  38275. fontMatrix = fontMatrix || [0.001, 0, 0, 0.001, 0, 0];
  38276. CompiledFont.call(this, fontMatrix);
  38277. this.glyphs = cffInfo.glyphs;
  38278. this.gsubrs = cffInfo.gsubrs || [];
  38279. this.subrs = cffInfo.subrs || [];
  38280. this.cmap = cmap;
  38281. this.glyphNameMap = glyphNameMap || (0, _glyphlist.getGlyphsUnicode)();
  38282. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  38283. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  38284. }
  38285. _util.Util.inherit(Type2Compiled, CompiledFont, {
  38286. compileGlyphImpl: function compileGlyphImpl(code, cmds) {
  38287. compileCharString(code, cmds, this);
  38288. }
  38289. });
  38290. return {
  38291. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  38292. var data = new Uint8Array(font.data);
  38293. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  38294. var numTables = getUshort(data, 4);
  38295. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  38296. var tag = (0, _util.bytesToString)(data.subarray(p, p + 4));
  38297. var offset = getLong(data, p + 8);
  38298. var length = getLong(data, p + 12);
  38299. switch (tag) {
  38300. case 'cmap':
  38301. cmap = parseCmap(data, offset, offset + length);
  38302. break;
  38303. case 'glyf':
  38304. glyf = data.subarray(offset, offset + length);
  38305. break;
  38306. case 'loca':
  38307. loca = data.subarray(offset, offset + length);
  38308. break;
  38309. case 'head':
  38310. unitsPerEm = getUshort(data, offset + 18);
  38311. indexToLocFormat = getUshort(data, offset + 50);
  38312. break;
  38313. case 'CFF ':
  38314. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  38315. break;
  38316. }
  38317. }
  38318. if (glyf) {
  38319. var fontMatrix = !unitsPerEm ? font.fontMatrix : [1 / unitsPerEm, 0, 0, 1 / unitsPerEm, 0, 0];
  38320. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  38321. }
  38322. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  38323. }
  38324. };
  38325. }();
  38326. exports.FontRendererFactory = FontRendererFactory;
  38327. /***/ }),
  38328. /* 135 */
  38329. /***/ (function(module, exports, __w_pdfjs_require__) {
  38330. "use strict";
  38331. Object.defineProperty(exports, "__esModule", {
  38332. value: true
  38333. });
  38334. exports.Type1Parser = undefined;
  38335. var _util = __w_pdfjs_require__(0);
  38336. var _encodings = __w_pdfjs_require__(21);
  38337. var _stream = __w_pdfjs_require__(5);
  38338. var HINTING_ENABLED = false;
  38339. var Type1CharString = function Type1CharStringClosure() {
  38340. var COMMAND_MAP = {
  38341. 'hstem': [1],
  38342. 'vstem': [3],
  38343. 'vmoveto': [4],
  38344. 'rlineto': [5],
  38345. 'hlineto': [6],
  38346. 'vlineto': [7],
  38347. 'rrcurveto': [8],
  38348. 'callsubr': [10],
  38349. 'flex': [12, 35],
  38350. 'drop': [12, 18],
  38351. 'endchar': [14],
  38352. 'rmoveto': [21],
  38353. 'hmoveto': [22],
  38354. 'vhcurveto': [30],
  38355. 'hvcurveto': [31]
  38356. };
  38357. function Type1CharString() {
  38358. this.width = 0;
  38359. this.lsb = 0;
  38360. this.flexing = false;
  38361. this.output = [];
  38362. this.stack = [];
  38363. }
  38364. Type1CharString.prototype = {
  38365. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38366. var count = encoded.length;
  38367. var error = false;
  38368. var wx, sbx, subrNumber;
  38369. for (var i = 0; i < count; i++) {
  38370. var value = encoded[i];
  38371. if (value < 32) {
  38372. if (value === 12) {
  38373. value = (value << 8) + encoded[++i];
  38374. }
  38375. switch (value) {
  38376. case 1:
  38377. if (!HINTING_ENABLED) {
  38378. this.stack = [];
  38379. break;
  38380. }
  38381. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38382. break;
  38383. case 3:
  38384. if (!HINTING_ENABLED) {
  38385. this.stack = [];
  38386. break;
  38387. }
  38388. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38389. break;
  38390. case 4:
  38391. if (this.flexing) {
  38392. if (this.stack.length < 1) {
  38393. error = true;
  38394. break;
  38395. }
  38396. var dy = this.stack.pop();
  38397. this.stack.push(0, dy);
  38398. break;
  38399. }
  38400. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38401. break;
  38402. case 5:
  38403. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38404. break;
  38405. case 6:
  38406. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38407. break;
  38408. case 7:
  38409. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38410. break;
  38411. case 8:
  38412. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38413. break;
  38414. case 9:
  38415. this.stack = [];
  38416. break;
  38417. case 10:
  38418. if (this.stack.length < 1) {
  38419. error = true;
  38420. break;
  38421. }
  38422. subrNumber = this.stack.pop();
  38423. if (!subrs[subrNumber]) {
  38424. error = true;
  38425. break;
  38426. }
  38427. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38428. break;
  38429. case 11:
  38430. return error;
  38431. case 13:
  38432. if (this.stack.length < 2) {
  38433. error = true;
  38434. break;
  38435. }
  38436. wx = this.stack.pop();
  38437. sbx = this.stack.pop();
  38438. this.lsb = sbx;
  38439. this.width = wx;
  38440. this.stack.push(wx, sbx);
  38441. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38442. break;
  38443. case 14:
  38444. this.output.push(COMMAND_MAP.endchar[0]);
  38445. break;
  38446. case 21:
  38447. if (this.flexing) {
  38448. break;
  38449. }
  38450. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38451. break;
  38452. case 22:
  38453. if (this.flexing) {
  38454. this.stack.push(0);
  38455. break;
  38456. }
  38457. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38458. break;
  38459. case 30:
  38460. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38461. break;
  38462. case 31:
  38463. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38464. break;
  38465. case (12 << 8) + 0:
  38466. this.stack = [];
  38467. break;
  38468. case (12 << 8) + 1:
  38469. if (!HINTING_ENABLED) {
  38470. this.stack = [];
  38471. break;
  38472. }
  38473. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38474. break;
  38475. case (12 << 8) + 2:
  38476. if (!HINTING_ENABLED) {
  38477. this.stack = [];
  38478. break;
  38479. }
  38480. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38481. break;
  38482. case (12 << 8) + 6:
  38483. if (seacAnalysisEnabled) {
  38484. this.seac = this.stack.splice(-4, 4);
  38485. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38486. } else {
  38487. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38488. }
  38489. break;
  38490. case (12 << 8) + 7:
  38491. if (this.stack.length < 4) {
  38492. error = true;
  38493. break;
  38494. }
  38495. this.stack.pop();
  38496. wx = this.stack.pop();
  38497. var sby = this.stack.pop();
  38498. sbx = this.stack.pop();
  38499. this.lsb = sbx;
  38500. this.width = wx;
  38501. this.stack.push(wx, sbx, sby);
  38502. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38503. break;
  38504. case (12 << 8) + 12:
  38505. if (this.stack.length < 2) {
  38506. error = true;
  38507. break;
  38508. }
  38509. var num2 = this.stack.pop();
  38510. var num1 = this.stack.pop();
  38511. this.stack.push(num1 / num2);
  38512. break;
  38513. case (12 << 8) + 16:
  38514. if (this.stack.length < 2) {
  38515. error = true;
  38516. break;
  38517. }
  38518. subrNumber = this.stack.pop();
  38519. var numArgs = this.stack.pop();
  38520. if (subrNumber === 0 && numArgs === 3) {
  38521. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38522. 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]);
  38523. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38524. this.flexing = false;
  38525. this.stack.push(flexArgs[15], flexArgs[16]);
  38526. } else if (subrNumber === 1 && numArgs === 0) {
  38527. this.flexing = true;
  38528. }
  38529. break;
  38530. case (12 << 8) + 17:
  38531. break;
  38532. case (12 << 8) + 33:
  38533. this.stack = [];
  38534. break;
  38535. default:
  38536. (0, _util.warn)('Unknown type 1 charstring command of "' + value + '"');
  38537. break;
  38538. }
  38539. if (error) {
  38540. break;
  38541. }
  38542. continue;
  38543. } else if (value <= 246) {
  38544. value = value - 139;
  38545. } else if (value <= 250) {
  38546. value = (value - 247) * 256 + encoded[++i] + 108;
  38547. } else if (value <= 254) {
  38548. value = -((value - 251) * 256) - encoded[++i] - 108;
  38549. } else {
  38550. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38551. }
  38552. this.stack.push(value);
  38553. }
  38554. return error;
  38555. },
  38556. executeCommand: function executeCommand(howManyArgs, command, keepStack) {
  38557. var stackLength = this.stack.length;
  38558. if (howManyArgs > stackLength) {
  38559. return true;
  38560. }
  38561. var start = stackLength - howManyArgs;
  38562. for (var i = start; i < stackLength; i++) {
  38563. var value = this.stack[i];
  38564. if (Number.isInteger(value)) {
  38565. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38566. } else {
  38567. value = 65536 * value | 0;
  38568. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38569. }
  38570. }
  38571. this.output.push.apply(this.output, command);
  38572. if (keepStack) {
  38573. this.stack.splice(start, howManyArgs);
  38574. } else {
  38575. this.stack.length = 0;
  38576. }
  38577. return false;
  38578. }
  38579. };
  38580. return Type1CharString;
  38581. }();
  38582. var Type1Parser = function Type1ParserClosure() {
  38583. var EEXEC_ENCRYPT_KEY = 55665;
  38584. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38585. function isHexDigit(code) {
  38586. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38587. }
  38588. function decrypt(data, key, discardNumber) {
  38589. if (discardNumber >= data.length) {
  38590. return new Uint8Array(0);
  38591. }
  38592. var r = key | 0,
  38593. c1 = 52845,
  38594. c2 = 22719,
  38595. i,
  38596. j;
  38597. for (i = 0; i < discardNumber; i++) {
  38598. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38599. }
  38600. var count = data.length - discardNumber;
  38601. var decrypted = new Uint8Array(count);
  38602. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38603. var value = data[i];
  38604. decrypted[j] = value ^ r >> 8;
  38605. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38606. }
  38607. return decrypted;
  38608. }
  38609. function decryptAscii(data, key, discardNumber) {
  38610. var r = key | 0,
  38611. c1 = 52845,
  38612. c2 = 22719;
  38613. var count = data.length,
  38614. maybeLength = count >>> 1;
  38615. var decrypted = new Uint8Array(maybeLength);
  38616. var i, j;
  38617. for (i = 0, j = 0; i < count; i++) {
  38618. var digit1 = data[i];
  38619. if (!isHexDigit(digit1)) {
  38620. continue;
  38621. }
  38622. i++;
  38623. var digit2;
  38624. while (i < count && !isHexDigit(digit2 = data[i])) {
  38625. i++;
  38626. }
  38627. if (i < count) {
  38628. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38629. decrypted[j++] = value ^ r >> 8;
  38630. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38631. }
  38632. }
  38633. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38634. }
  38635. function isSpecial(c) {
  38636. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38637. }
  38638. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38639. if (encrypted) {
  38640. var data = stream.getBytes();
  38641. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38642. stream = new _stream.Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38643. }
  38644. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38645. this.stream = stream;
  38646. this.nextChar();
  38647. }
  38648. Type1Parser.prototype = {
  38649. readNumberArray: function Type1Parser_readNumberArray() {
  38650. this.getToken();
  38651. var array = [];
  38652. while (true) {
  38653. var token = this.getToken();
  38654. if (token === null || token === ']' || token === '}') {
  38655. break;
  38656. }
  38657. array.push(parseFloat(token || 0));
  38658. }
  38659. return array;
  38660. },
  38661. readNumber: function Type1Parser_readNumber() {
  38662. var token = this.getToken();
  38663. return parseFloat(token || 0);
  38664. },
  38665. readInt: function Type1Parser_readInt() {
  38666. var token = this.getToken();
  38667. return parseInt(token || 0, 10) | 0;
  38668. },
  38669. readBoolean: function Type1Parser_readBoolean() {
  38670. var token = this.getToken();
  38671. return token === 'true' ? 1 : 0;
  38672. },
  38673. nextChar: function Type1_nextChar() {
  38674. return this.currentChar = this.stream.getByte();
  38675. },
  38676. getToken: function Type1Parser_getToken() {
  38677. var comment = false;
  38678. var ch = this.currentChar;
  38679. while (true) {
  38680. if (ch === -1) {
  38681. return null;
  38682. }
  38683. if (comment) {
  38684. if (ch === 0x0A || ch === 0x0D) {
  38685. comment = false;
  38686. }
  38687. } else if (ch === 0x25) {
  38688. comment = true;
  38689. } else if (!(0, _util.isSpace)(ch)) {
  38690. break;
  38691. }
  38692. ch = this.nextChar();
  38693. }
  38694. if (isSpecial(ch)) {
  38695. this.nextChar();
  38696. return String.fromCharCode(ch);
  38697. }
  38698. var token = '';
  38699. do {
  38700. token += String.fromCharCode(ch);
  38701. ch = this.nextChar();
  38702. } while (ch >= 0 && !(0, _util.isSpace)(ch) && !isSpecial(ch));
  38703. return token;
  38704. },
  38705. readCharStrings: function Type1Parser_readCharStrings(bytes, lenIV) {
  38706. if (lenIV === -1) {
  38707. return bytes;
  38708. }
  38709. return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
  38710. },
  38711. extractFontProgram: function Type1Parser_extractFontProgram() {
  38712. var stream = this.stream;
  38713. var subrs = [],
  38714. charstrings = [];
  38715. var privateData = Object.create(null);
  38716. privateData['lenIV'] = 4;
  38717. var program = {
  38718. subrs: [],
  38719. charstrings: [],
  38720. properties: { 'privateData': privateData }
  38721. };
  38722. var token, length, data, lenIV, encoded;
  38723. while ((token = this.getToken()) !== null) {
  38724. if (token !== '/') {
  38725. continue;
  38726. }
  38727. token = this.getToken();
  38728. switch (token) {
  38729. case 'CharStrings':
  38730. this.getToken();
  38731. this.getToken();
  38732. this.getToken();
  38733. this.getToken();
  38734. while (true) {
  38735. token = this.getToken();
  38736. if (token === null || token === 'end') {
  38737. break;
  38738. }
  38739. if (token !== '/') {
  38740. continue;
  38741. }
  38742. var glyph = this.getToken();
  38743. length = this.readInt();
  38744. this.getToken();
  38745. data = stream.makeSubStream(stream.pos, length);
  38746. lenIV = program.properties.privateData['lenIV'];
  38747. encoded = this.readCharStrings(data.getBytes(), lenIV);
  38748. stream.skip(length);
  38749. this.nextChar();
  38750. token = this.getToken();
  38751. if (token === 'noaccess') {
  38752. this.getToken();
  38753. }
  38754. charstrings.push({
  38755. glyph: glyph,
  38756. encoded: encoded
  38757. });
  38758. }
  38759. break;
  38760. case 'Subrs':
  38761. this.readInt();
  38762. this.getToken();
  38763. while (this.getToken() === 'dup') {
  38764. var index = this.readInt();
  38765. length = this.readInt();
  38766. this.getToken();
  38767. data = stream.makeSubStream(stream.pos, length);
  38768. lenIV = program.properties.privateData['lenIV'];
  38769. encoded = this.readCharStrings(data.getBytes(), lenIV);
  38770. stream.skip(length);
  38771. this.nextChar();
  38772. token = this.getToken();
  38773. if (token === 'noaccess') {
  38774. this.getToken();
  38775. }
  38776. subrs[index] = encoded;
  38777. }
  38778. break;
  38779. case 'BlueValues':
  38780. case 'OtherBlues':
  38781. case 'FamilyBlues':
  38782. case 'FamilyOtherBlues':
  38783. var blueArray = this.readNumberArray();
  38784. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  38785. program.properties.privateData[token] = blueArray;
  38786. }
  38787. break;
  38788. case 'StemSnapH':
  38789. case 'StemSnapV':
  38790. program.properties.privateData[token] = this.readNumberArray();
  38791. break;
  38792. case 'StdHW':
  38793. case 'StdVW':
  38794. program.properties.privateData[token] = this.readNumberArray()[0];
  38795. break;
  38796. case 'BlueShift':
  38797. case 'lenIV':
  38798. case 'BlueFuzz':
  38799. case 'BlueScale':
  38800. case 'LanguageGroup':
  38801. case 'ExpansionFactor':
  38802. program.properties.privateData[token] = this.readNumber();
  38803. break;
  38804. case 'ForceBold':
  38805. program.properties.privateData[token] = this.readBoolean();
  38806. break;
  38807. }
  38808. }
  38809. for (var i = 0; i < charstrings.length; i++) {
  38810. glyph = charstrings[i].glyph;
  38811. encoded = charstrings[i].encoded;
  38812. var charString = new Type1CharString();
  38813. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  38814. var output = charString.output;
  38815. if (error) {
  38816. output = [14];
  38817. }
  38818. program.charstrings.push({
  38819. glyphName: glyph,
  38820. charstring: output,
  38821. width: charString.width,
  38822. lsb: charString.lsb,
  38823. seac: charString.seac
  38824. });
  38825. }
  38826. return program;
  38827. },
  38828. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  38829. var token;
  38830. while ((token = this.getToken()) !== null) {
  38831. if (token !== '/') {
  38832. continue;
  38833. }
  38834. token = this.getToken();
  38835. switch (token) {
  38836. case 'FontMatrix':
  38837. var matrix = this.readNumberArray();
  38838. properties.fontMatrix = matrix;
  38839. break;
  38840. case 'Encoding':
  38841. var encodingArg = this.getToken();
  38842. var encoding;
  38843. if (!/^\d+$/.test(encodingArg)) {
  38844. encoding = (0, _encodings.getEncoding)(encodingArg);
  38845. } else {
  38846. encoding = [];
  38847. var size = parseInt(encodingArg, 10) | 0;
  38848. this.getToken();
  38849. for (var j = 0; j < size; j++) {
  38850. token = this.getToken();
  38851. while (token !== 'dup' && token !== 'def') {
  38852. token = this.getToken();
  38853. if (token === null) {
  38854. return;
  38855. }
  38856. }
  38857. if (token === 'def') {
  38858. break;
  38859. }
  38860. var index = this.readInt();
  38861. this.getToken();
  38862. var glyph = this.getToken();
  38863. encoding[index] = glyph;
  38864. this.getToken();
  38865. }
  38866. }
  38867. properties.builtInEncoding = encoding;
  38868. break;
  38869. case 'FontBBox':
  38870. var fontBBox = this.readNumberArray();
  38871. properties.ascent = Math.max(fontBBox[3], fontBBox[1]);
  38872. properties.descent = Math.min(fontBBox[1], fontBBox[3]);
  38873. properties.ascentScaled = true;
  38874. break;
  38875. }
  38876. }
  38877. }
  38878. };
  38879. return Type1Parser;
  38880. }();
  38881. exports.Type1Parser = Type1Parser;
  38882. /***/ }),
  38883. /* 136 */
  38884. /***/ (function(module, exports, __w_pdfjs_require__) {
  38885. "use strict";
  38886. Object.defineProperty(exports, "__esModule", {
  38887. value: true
  38888. });
  38889. exports.getTilingPatternIR = exports.Pattern = undefined;
  38890. var _util = __w_pdfjs_require__(0);
  38891. var _colorspace = __w_pdfjs_require__(20);
  38892. var _primitives = __w_pdfjs_require__(1);
  38893. var ShadingType = {
  38894. FUNCTION_BASED: 1,
  38895. AXIAL: 2,
  38896. RADIAL: 3,
  38897. FREE_FORM_MESH: 4,
  38898. LATTICE_FORM_MESH: 5,
  38899. COONS_PATCH_MESH: 6,
  38900. TENSOR_PATCH_MESH: 7
  38901. };
  38902. var Pattern = function PatternClosure() {
  38903. function Pattern() {
  38904. throw new Error('should not call Pattern constructor');
  38905. }
  38906. Pattern.prototype = {
  38907. getPattern: function Pattern_getPattern(ctx) {
  38908. throw new Error('Should not call Pattern.getStyle: ' + ctx);
  38909. }
  38910. };
  38911. Pattern.parseShading = function (shading, matrix, xref, res, handler, pdfFunctionFactory) {
  38912. var dict = (0, _primitives.isStream)(shading) ? shading.dict : shading;
  38913. var type = dict.get('ShadingType');
  38914. try {
  38915. switch (type) {
  38916. case ShadingType.AXIAL:
  38917. case ShadingType.RADIAL:
  38918. return new Shadings.RadialAxial(dict, matrix, xref, res, pdfFunctionFactory);
  38919. case ShadingType.FREE_FORM_MESH:
  38920. case ShadingType.LATTICE_FORM_MESH:
  38921. case ShadingType.COONS_PATCH_MESH:
  38922. case ShadingType.TENSOR_PATCH_MESH:
  38923. return new Shadings.Mesh(shading, matrix, xref, res, pdfFunctionFactory);
  38924. default:
  38925. throw new _util.FormatError('Unsupported ShadingType: ' + type);
  38926. }
  38927. } catch (ex) {
  38928. if (ex instanceof _util.MissingDataException) {
  38929. throw ex;
  38930. }
  38931. handler.send('UnsupportedFeature', { featureId: _util.UNSUPPORTED_FEATURES.shadingPattern });
  38932. (0, _util.warn)(ex);
  38933. return new Shadings.Dummy();
  38934. }
  38935. };
  38936. return Pattern;
  38937. }();
  38938. var Shadings = {};
  38939. Shadings.SMALL_NUMBER = 1e-6;
  38940. Shadings.RadialAxial = function RadialAxialClosure() {
  38941. function RadialAxial(dict, matrix, xref, res, pdfFunctionFactory) {
  38942. this.matrix = matrix;
  38943. this.coordsArr = dict.getArray('Coords');
  38944. this.shadingType = dict.get('ShadingType');
  38945. this.type = 'Pattern';
  38946. var cs = dict.get('ColorSpace', 'CS');
  38947. cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
  38948. this.cs = cs;
  38949. var t0 = 0.0,
  38950. t1 = 1.0;
  38951. if (dict.has('Domain')) {
  38952. var domainArr = dict.getArray('Domain');
  38953. t0 = domainArr[0];
  38954. t1 = domainArr[1];
  38955. }
  38956. var extendStart = false,
  38957. extendEnd = false;
  38958. if (dict.has('Extend')) {
  38959. var extendArr = dict.getArray('Extend');
  38960. extendStart = extendArr[0];
  38961. extendEnd = extendArr[1];
  38962. }
  38963. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  38964. var x1 = this.coordsArr[0];
  38965. var y1 = this.coordsArr[1];
  38966. var r1 = this.coordsArr[2];
  38967. var x2 = this.coordsArr[3];
  38968. var y2 = this.coordsArr[4];
  38969. var r2 = this.coordsArr[5];
  38970. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  38971. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  38972. (0, _util.warn)('Unsupported radial gradient.');
  38973. }
  38974. }
  38975. this.extendStart = extendStart;
  38976. this.extendEnd = extendEnd;
  38977. var fnObj = dict.get('Function');
  38978. var fn = pdfFunctionFactory.createFromArray(fnObj);
  38979. var diff = t1 - t0;
  38980. var step = diff / 10;
  38981. var colorStops = this.colorStops = [];
  38982. if (t0 >= t1 || step <= 0) {
  38983. (0, _util.info)('Bad shading domain.');
  38984. return;
  38985. }
  38986. var color = new Float32Array(cs.numComps),
  38987. ratio = new Float32Array(1);
  38988. var rgbColor;
  38989. for (var i = t0; i <= t1; i += step) {
  38990. ratio[0] = i;
  38991. fn(ratio, 0, color, 0);
  38992. rgbColor = cs.getRgb(color, 0);
  38993. var cssColor = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  38994. colorStops.push([(i - t0) / diff, cssColor]);
  38995. }
  38996. var background = 'transparent';
  38997. if (dict.has('Background')) {
  38998. rgbColor = cs.getRgb(dict.get('Background'), 0);
  38999. background = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  39000. }
  39001. if (!extendStart) {
  39002. colorStops.unshift([0, background]);
  39003. colorStops[1][0] += Shadings.SMALL_NUMBER;
  39004. }
  39005. if (!extendEnd) {
  39006. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  39007. colorStops.push([1, background]);
  39008. }
  39009. this.colorStops = colorStops;
  39010. }
  39011. RadialAxial.prototype = {
  39012. getIR: function RadialAxial_getIR() {
  39013. var coordsArr = this.coordsArr;
  39014. var shadingType = this.shadingType;
  39015. var type, p0, p1, r0, r1;
  39016. if (shadingType === ShadingType.AXIAL) {
  39017. p0 = [coordsArr[0], coordsArr[1]];
  39018. p1 = [coordsArr[2], coordsArr[3]];
  39019. r0 = null;
  39020. r1 = null;
  39021. type = 'axial';
  39022. } else if (shadingType === ShadingType.RADIAL) {
  39023. p0 = [coordsArr[0], coordsArr[1]];
  39024. p1 = [coordsArr[3], coordsArr[4]];
  39025. r0 = coordsArr[2];
  39026. r1 = coordsArr[5];
  39027. type = 'radial';
  39028. } else {
  39029. (0, _util.unreachable)('getPattern type unknown: ' + shadingType);
  39030. }
  39031. var matrix = this.matrix;
  39032. if (matrix) {
  39033. p0 = _util.Util.applyTransform(p0, matrix);
  39034. p1 = _util.Util.applyTransform(p1, matrix);
  39035. if (shadingType === ShadingType.RADIAL) {
  39036. var scale = _util.Util.singularValueDecompose2dScale(matrix);
  39037. r0 *= scale[0];
  39038. r1 *= scale[1];
  39039. }
  39040. }
  39041. return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1];
  39042. }
  39043. };
  39044. return RadialAxial;
  39045. }();
  39046. Shadings.Mesh = function MeshClosure() {
  39047. function MeshStreamReader(stream, context) {
  39048. this.stream = stream;
  39049. this.context = context;
  39050. this.buffer = 0;
  39051. this.bufferLength = 0;
  39052. var numComps = context.numComps;
  39053. this.tmpCompsBuf = new Float32Array(numComps);
  39054. var csNumComps = context.colorSpace.numComps;
  39055. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  39056. }
  39057. MeshStreamReader.prototype = {
  39058. get hasData() {
  39059. if (this.stream.end) {
  39060. return this.stream.pos < this.stream.end;
  39061. }
  39062. if (this.bufferLength > 0) {
  39063. return true;
  39064. }
  39065. var nextByte = this.stream.getByte();
  39066. if (nextByte < 0) {
  39067. return false;
  39068. }
  39069. this.buffer = nextByte;
  39070. this.bufferLength = 8;
  39071. return true;
  39072. },
  39073. readBits: function MeshStreamReader_readBits(n) {
  39074. var buffer = this.buffer;
  39075. var bufferLength = this.bufferLength;
  39076. if (n === 32) {
  39077. if (bufferLength === 0) {
  39078. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  39079. }
  39080. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  39081. var nextByte = this.stream.getByte();
  39082. this.buffer = nextByte & (1 << bufferLength) - 1;
  39083. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  39084. }
  39085. if (n === 8 && bufferLength === 0) {
  39086. return this.stream.getByte();
  39087. }
  39088. while (bufferLength < n) {
  39089. buffer = buffer << 8 | this.stream.getByte();
  39090. bufferLength += 8;
  39091. }
  39092. bufferLength -= n;
  39093. this.bufferLength = bufferLength;
  39094. this.buffer = buffer & (1 << bufferLength) - 1;
  39095. return buffer >> bufferLength;
  39096. },
  39097. align: function MeshStreamReader_align() {
  39098. this.buffer = 0;
  39099. this.bufferLength = 0;
  39100. },
  39101. readFlag: function MeshStreamReader_readFlag() {
  39102. return this.readBits(this.context.bitsPerFlag);
  39103. },
  39104. readCoordinate: function MeshStreamReader_readCoordinate() {
  39105. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  39106. var xi = this.readBits(bitsPerCoordinate);
  39107. var yi = this.readBits(bitsPerCoordinate);
  39108. var decode = this.context.decode;
  39109. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  39110. return [xi * scale * (decode[1] - decode[0]) + decode[0], yi * scale * (decode[3] - decode[2]) + decode[2]];
  39111. },
  39112. readComponents: function MeshStreamReader_readComponents() {
  39113. var numComps = this.context.numComps;
  39114. var bitsPerComponent = this.context.bitsPerComponent;
  39115. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  39116. var decode = this.context.decode;
  39117. var components = this.tmpCompsBuf;
  39118. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  39119. var ci = this.readBits(bitsPerComponent);
  39120. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  39121. }
  39122. var color = this.tmpCsCompsBuf;
  39123. if (this.context.colorFn) {
  39124. this.context.colorFn(components, 0, color, 0);
  39125. }
  39126. return this.context.colorSpace.getRgb(color, 0);
  39127. }
  39128. };
  39129. function decodeType4Shading(mesh, reader) {
  39130. var coords = mesh.coords;
  39131. var colors = mesh.colors;
  39132. var operators = [];
  39133. var ps = [];
  39134. var verticesLeft = 0;
  39135. while (reader.hasData) {
  39136. var f = reader.readFlag();
  39137. var coord = reader.readCoordinate();
  39138. var color = reader.readComponents();
  39139. if (verticesLeft === 0) {
  39140. if (!(0 <= f && f <= 2)) {
  39141. throw new _util.FormatError('Unknown type4 flag');
  39142. }
  39143. switch (f) {
  39144. case 0:
  39145. verticesLeft = 3;
  39146. break;
  39147. case 1:
  39148. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  39149. verticesLeft = 1;
  39150. break;
  39151. case 2:
  39152. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  39153. verticesLeft = 1;
  39154. break;
  39155. }
  39156. operators.push(f);
  39157. }
  39158. ps.push(coords.length);
  39159. coords.push(coord);
  39160. colors.push(color);
  39161. verticesLeft--;
  39162. reader.align();
  39163. }
  39164. mesh.figures.push({
  39165. type: 'triangles',
  39166. coords: new Int32Array(ps),
  39167. colors: new Int32Array(ps)
  39168. });
  39169. }
  39170. function decodeType5Shading(mesh, reader, verticesPerRow) {
  39171. var coords = mesh.coords;
  39172. var colors = mesh.colors;
  39173. var ps = [];
  39174. while (reader.hasData) {
  39175. var coord = reader.readCoordinate();
  39176. var color = reader.readComponents();
  39177. ps.push(coords.length);
  39178. coords.push(coord);
  39179. colors.push(color);
  39180. }
  39181. mesh.figures.push({
  39182. type: 'lattice',
  39183. coords: new Int32Array(ps),
  39184. colors: new Int32Array(ps),
  39185. verticesPerRow: verticesPerRow
  39186. });
  39187. }
  39188. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  39189. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  39190. var TRIANGLE_DENSITY = 20;
  39191. var getB = function getBClosure() {
  39192. function buildB(count) {
  39193. var lut = [];
  39194. for (var i = 0; i <= count; i++) {
  39195. var t = i / count,
  39196. t_ = 1 - t;
  39197. lut.push(new Float32Array([t_ * t_ * t_, 3 * t * t_ * t_, 3 * t * t * t_, t * t * t]));
  39198. }
  39199. return lut;
  39200. }
  39201. var cache = [];
  39202. return function getB(count) {
  39203. if (!cache[count]) {
  39204. cache[count] = buildB(count);
  39205. }
  39206. return cache[count];
  39207. };
  39208. }();
  39209. function buildFigureFromPatch(mesh, index) {
  39210. var figure = mesh.figures[index];
  39211. (0, _util.assert)(figure.type === 'patch', 'Unexpected patch mesh figure');
  39212. var coords = mesh.coords,
  39213. colors = mesh.colors;
  39214. var pi = figure.coords;
  39215. var ci = figure.colors;
  39216. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  39217. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  39218. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  39219. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  39220. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  39221. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  39222. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  39223. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  39224. var verticesPerRow = splitXBy + 1;
  39225. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  39226. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  39227. var k = 0;
  39228. var cl = new Uint8Array(3),
  39229. cr = new Uint8Array(3);
  39230. var c0 = colors[ci[0]],
  39231. c1 = colors[ci[1]],
  39232. c2 = colors[ci[2]],
  39233. c3 = colors[ci[3]];
  39234. var bRow = getB(splitYBy),
  39235. bCol = getB(splitXBy);
  39236. for (var row = 0; row <= splitYBy; row++) {
  39237. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  39238. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  39239. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  39240. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  39241. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  39242. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  39243. for (var col = 0; col <= splitXBy; col++, k++) {
  39244. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  39245. continue;
  39246. }
  39247. var x = 0,
  39248. y = 0;
  39249. var q = 0;
  39250. for (var i = 0; i <= 3; i++) {
  39251. for (var j = 0; j <= 3; j++, q++) {
  39252. var m = bRow[row][i] * bCol[col][j];
  39253. x += coords[pi[q]][0] * m;
  39254. y += coords[pi[q]][1] * m;
  39255. }
  39256. }
  39257. figureCoords[k] = coords.length;
  39258. coords.push([x, y]);
  39259. figureColors[k] = colors.length;
  39260. var newColor = new Uint8Array(3);
  39261. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  39262. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  39263. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  39264. colors.push(newColor);
  39265. }
  39266. }
  39267. figureCoords[0] = pi[0];
  39268. figureColors[0] = ci[0];
  39269. figureCoords[splitXBy] = pi[3];
  39270. figureColors[splitXBy] = ci[1];
  39271. figureCoords[verticesPerRow * splitYBy] = pi[12];
  39272. figureColors[verticesPerRow * splitYBy] = ci[2];
  39273. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  39274. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  39275. mesh.figures[index] = {
  39276. type: 'lattice',
  39277. coords: figureCoords,
  39278. colors: figureColors,
  39279. verticesPerRow: verticesPerRow
  39280. };
  39281. }
  39282. function decodeType6Shading(mesh, reader) {
  39283. var coords = mesh.coords;
  39284. var colors = mesh.colors;
  39285. var ps = new Int32Array(16);
  39286. var cs = new Int32Array(4);
  39287. while (reader.hasData) {
  39288. var f = reader.readFlag();
  39289. if (!(0 <= f && f <= 3)) {
  39290. throw new _util.FormatError('Unknown type6 flag');
  39291. }
  39292. var i, ii;
  39293. var pi = coords.length;
  39294. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  39295. coords.push(reader.readCoordinate());
  39296. }
  39297. var ci = colors.length;
  39298. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  39299. colors.push(reader.readComponents());
  39300. }
  39301. var tmp1, tmp2, tmp3, tmp4;
  39302. switch (f) {
  39303. case 0:
  39304. ps[12] = pi + 3;
  39305. ps[13] = pi + 4;
  39306. ps[14] = pi + 5;
  39307. ps[15] = pi + 6;
  39308. ps[8] = pi + 2;
  39309. ps[11] = pi + 7;
  39310. ps[4] = pi + 1;
  39311. ps[7] = pi + 8;
  39312. ps[0] = pi;
  39313. ps[1] = pi + 11;
  39314. ps[2] = pi + 10;
  39315. ps[3] = pi + 9;
  39316. cs[2] = ci + 1;
  39317. cs[3] = ci + 2;
  39318. cs[0] = ci;
  39319. cs[1] = ci + 3;
  39320. break;
  39321. case 1:
  39322. tmp1 = ps[12];
  39323. tmp2 = ps[13];
  39324. tmp3 = ps[14];
  39325. tmp4 = ps[15];
  39326. ps[12] = tmp4;
  39327. ps[13] = pi + 0;
  39328. ps[14] = pi + 1;
  39329. ps[15] = pi + 2;
  39330. ps[8] = tmp3;
  39331. ps[11] = pi + 3;
  39332. ps[4] = tmp2;
  39333. ps[7] = pi + 4;
  39334. ps[0] = tmp1;
  39335. ps[1] = pi + 7;
  39336. ps[2] = pi + 6;
  39337. ps[3] = pi + 5;
  39338. tmp1 = cs[2];
  39339. tmp2 = cs[3];
  39340. cs[2] = tmp2;
  39341. cs[3] = ci;
  39342. cs[0] = tmp1;
  39343. cs[1] = ci + 1;
  39344. break;
  39345. case 2:
  39346. tmp1 = ps[15];
  39347. tmp2 = ps[11];
  39348. ps[12] = ps[3];
  39349. ps[13] = pi + 0;
  39350. ps[14] = pi + 1;
  39351. ps[15] = pi + 2;
  39352. ps[8] = ps[7];
  39353. ps[11] = pi + 3;
  39354. ps[4] = tmp2;
  39355. ps[7] = pi + 4;
  39356. ps[0] = tmp1;
  39357. ps[1] = pi + 7;
  39358. ps[2] = pi + 6;
  39359. ps[3] = pi + 5;
  39360. tmp1 = cs[3];
  39361. cs[2] = cs[1];
  39362. cs[3] = ci;
  39363. cs[0] = tmp1;
  39364. cs[1] = ci + 1;
  39365. break;
  39366. case 3:
  39367. ps[12] = ps[0];
  39368. ps[13] = pi + 0;
  39369. ps[14] = pi + 1;
  39370. ps[15] = pi + 2;
  39371. ps[8] = ps[1];
  39372. ps[11] = pi + 3;
  39373. ps[4] = ps[2];
  39374. ps[7] = pi + 4;
  39375. ps[0] = ps[3];
  39376. ps[1] = pi + 7;
  39377. ps[2] = pi + 6;
  39378. ps[3] = pi + 5;
  39379. cs[2] = cs[0];
  39380. cs[3] = ci;
  39381. cs[0] = cs[1];
  39382. cs[1] = ci + 1;
  39383. break;
  39384. }
  39385. ps[5] = coords.length;
  39386. 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]);
  39387. ps[6] = coords.length;
  39388. 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]);
  39389. ps[9] = coords.length;
  39390. 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]);
  39391. ps[10] = coords.length;
  39392. 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]);
  39393. mesh.figures.push({
  39394. type: 'patch',
  39395. coords: new Int32Array(ps),
  39396. colors: new Int32Array(cs)
  39397. });
  39398. }
  39399. }
  39400. function decodeType7Shading(mesh, reader) {
  39401. var coords = mesh.coords;
  39402. var colors = mesh.colors;
  39403. var ps = new Int32Array(16);
  39404. var cs = new Int32Array(4);
  39405. while (reader.hasData) {
  39406. var f = reader.readFlag();
  39407. if (!(0 <= f && f <= 3)) {
  39408. throw new _util.FormatError('Unknown type7 flag');
  39409. }
  39410. var i, ii;
  39411. var pi = coords.length;
  39412. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  39413. coords.push(reader.readCoordinate());
  39414. }
  39415. var ci = colors.length;
  39416. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  39417. colors.push(reader.readComponents());
  39418. }
  39419. var tmp1, tmp2, tmp3, tmp4;
  39420. switch (f) {
  39421. case 0:
  39422. ps[12] = pi + 3;
  39423. ps[13] = pi + 4;
  39424. ps[14] = pi + 5;
  39425. ps[15] = pi + 6;
  39426. ps[8] = pi + 2;
  39427. ps[9] = pi + 13;
  39428. ps[10] = pi + 14;
  39429. ps[11] = pi + 7;
  39430. ps[4] = pi + 1;
  39431. ps[5] = pi + 12;
  39432. ps[6] = pi + 15;
  39433. ps[7] = pi + 8;
  39434. ps[0] = pi;
  39435. ps[1] = pi + 11;
  39436. ps[2] = pi + 10;
  39437. ps[3] = pi + 9;
  39438. cs[2] = ci + 1;
  39439. cs[3] = ci + 2;
  39440. cs[0] = ci;
  39441. cs[1] = ci + 3;
  39442. break;
  39443. case 1:
  39444. tmp1 = ps[12];
  39445. tmp2 = ps[13];
  39446. tmp3 = ps[14];
  39447. tmp4 = ps[15];
  39448. ps[12] = tmp4;
  39449. ps[13] = pi + 0;
  39450. ps[14] = pi + 1;
  39451. ps[15] = pi + 2;
  39452. ps[8] = tmp3;
  39453. ps[9] = pi + 9;
  39454. ps[10] = pi + 10;
  39455. ps[11] = pi + 3;
  39456. ps[4] = tmp2;
  39457. ps[5] = pi + 8;
  39458. ps[6] = pi + 11;
  39459. ps[7] = pi + 4;
  39460. ps[0] = tmp1;
  39461. ps[1] = pi + 7;
  39462. ps[2] = pi + 6;
  39463. ps[3] = pi + 5;
  39464. tmp1 = cs[2];
  39465. tmp2 = cs[3];
  39466. cs[2] = tmp2;
  39467. cs[3] = ci;
  39468. cs[0] = tmp1;
  39469. cs[1] = ci + 1;
  39470. break;
  39471. case 2:
  39472. tmp1 = ps[15];
  39473. tmp2 = ps[11];
  39474. ps[12] = ps[3];
  39475. ps[13] = pi + 0;
  39476. ps[14] = pi + 1;
  39477. ps[15] = pi + 2;
  39478. ps[8] = ps[7];
  39479. ps[9] = pi + 9;
  39480. ps[10] = pi + 10;
  39481. ps[11] = pi + 3;
  39482. ps[4] = tmp2;
  39483. ps[5] = pi + 8;
  39484. ps[6] = pi + 11;
  39485. ps[7] = pi + 4;
  39486. ps[0] = tmp1;
  39487. ps[1] = pi + 7;
  39488. ps[2] = pi + 6;
  39489. ps[3] = pi + 5;
  39490. tmp1 = cs[3];
  39491. cs[2] = cs[1];
  39492. cs[3] = ci;
  39493. cs[0] = tmp1;
  39494. cs[1] = ci + 1;
  39495. break;
  39496. case 3:
  39497. ps[12] = ps[0];
  39498. ps[13] = pi + 0;
  39499. ps[14] = pi + 1;
  39500. ps[15] = pi + 2;
  39501. ps[8] = ps[1];
  39502. ps[9] = pi + 9;
  39503. ps[10] = pi + 10;
  39504. ps[11] = pi + 3;
  39505. ps[4] = ps[2];
  39506. ps[5] = pi + 8;
  39507. ps[6] = pi + 11;
  39508. ps[7] = pi + 4;
  39509. ps[0] = ps[3];
  39510. ps[1] = pi + 7;
  39511. ps[2] = pi + 6;
  39512. ps[3] = pi + 5;
  39513. cs[2] = cs[0];
  39514. cs[3] = ci;
  39515. cs[0] = cs[1];
  39516. cs[1] = ci + 1;
  39517. break;
  39518. }
  39519. mesh.figures.push({
  39520. type: 'patch',
  39521. coords: new Int32Array(ps),
  39522. colors: new Int32Array(cs)
  39523. });
  39524. }
  39525. }
  39526. function updateBounds(mesh) {
  39527. var minX = mesh.coords[0][0],
  39528. minY = mesh.coords[0][1],
  39529. maxX = minX,
  39530. maxY = minY;
  39531. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  39532. var x = mesh.coords[i][0],
  39533. y = mesh.coords[i][1];
  39534. minX = minX > x ? x : minX;
  39535. minY = minY > y ? y : minY;
  39536. maxX = maxX < x ? x : maxX;
  39537. maxY = maxY < y ? y : maxY;
  39538. }
  39539. mesh.bounds = [minX, minY, maxX, maxY];
  39540. }
  39541. function packData(mesh) {
  39542. var i, ii, j, jj;
  39543. var coords = mesh.coords;
  39544. var coordsPacked = new Float32Array(coords.length * 2);
  39545. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  39546. var xy = coords[i];
  39547. coordsPacked[j++] = xy[0];
  39548. coordsPacked[j++] = xy[1];
  39549. }
  39550. mesh.coords = coordsPacked;
  39551. var colors = mesh.colors;
  39552. var colorsPacked = new Uint8Array(colors.length * 3);
  39553. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  39554. var c = colors[i];
  39555. colorsPacked[j++] = c[0];
  39556. colorsPacked[j++] = c[1];
  39557. colorsPacked[j++] = c[2];
  39558. }
  39559. mesh.colors = colorsPacked;
  39560. var figures = mesh.figures;
  39561. for (i = 0, ii = figures.length; i < ii; i++) {
  39562. var figure = figures[i],
  39563. ps = figure.coords,
  39564. cs = figure.colors;
  39565. for (j = 0, jj = ps.length; j < jj; j++) {
  39566. ps[j] *= 2;
  39567. cs[j] *= 3;
  39568. }
  39569. }
  39570. }
  39571. function Mesh(stream, matrix, xref, res, pdfFunctionFactory) {
  39572. if (!(0, _primitives.isStream)(stream)) {
  39573. throw new _util.FormatError('Mesh data is not a stream');
  39574. }
  39575. var dict = stream.dict;
  39576. this.matrix = matrix;
  39577. this.shadingType = dict.get('ShadingType');
  39578. this.type = 'Pattern';
  39579. this.bbox = dict.getArray('BBox');
  39580. var cs = dict.get('ColorSpace', 'CS');
  39581. cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
  39582. this.cs = cs;
  39583. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  39584. var fnObj = dict.get('Function');
  39585. var fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
  39586. this.coords = [];
  39587. this.colors = [];
  39588. this.figures = [];
  39589. var decodeContext = {
  39590. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  39591. bitsPerComponent: dict.get('BitsPerComponent'),
  39592. bitsPerFlag: dict.get('BitsPerFlag'),
  39593. decode: dict.getArray('Decode'),
  39594. colorFn: fn,
  39595. colorSpace: cs,
  39596. numComps: fn ? 1 : cs.numComps
  39597. };
  39598. var reader = new MeshStreamReader(stream, decodeContext);
  39599. var patchMesh = false;
  39600. switch (this.shadingType) {
  39601. case ShadingType.FREE_FORM_MESH:
  39602. decodeType4Shading(this, reader);
  39603. break;
  39604. case ShadingType.LATTICE_FORM_MESH:
  39605. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  39606. if (verticesPerRow < 2) {
  39607. throw new _util.FormatError('Invalid VerticesPerRow');
  39608. }
  39609. decodeType5Shading(this, reader, verticesPerRow);
  39610. break;
  39611. case ShadingType.COONS_PATCH_MESH:
  39612. decodeType6Shading(this, reader);
  39613. patchMesh = true;
  39614. break;
  39615. case ShadingType.TENSOR_PATCH_MESH:
  39616. decodeType7Shading(this, reader);
  39617. patchMesh = true;
  39618. break;
  39619. default:
  39620. (0, _util.unreachable)('Unsupported mesh type.');
  39621. break;
  39622. }
  39623. if (patchMesh) {
  39624. updateBounds(this);
  39625. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  39626. buildFigureFromPatch(this, i);
  39627. }
  39628. }
  39629. updateBounds(this);
  39630. packData(this);
  39631. }
  39632. Mesh.prototype = {
  39633. getIR: function Mesh_getIR() {
  39634. return ['Mesh', this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.matrix, this.bbox, this.background];
  39635. }
  39636. };
  39637. return Mesh;
  39638. }();
  39639. Shadings.Dummy = function DummyClosure() {
  39640. function Dummy() {
  39641. this.type = 'Pattern';
  39642. }
  39643. Dummy.prototype = {
  39644. getIR: function Dummy_getIR() {
  39645. return ['Dummy'];
  39646. }
  39647. };
  39648. return Dummy;
  39649. }();
  39650. function getTilingPatternIR(operatorList, dict, args) {
  39651. var matrix = dict.getArray('Matrix');
  39652. var bbox = _util.Util.normalizeRect(dict.getArray('BBox'));
  39653. var xstep = dict.get('XStep');
  39654. var ystep = dict.get('YStep');
  39655. var paintType = dict.get('PaintType');
  39656. var tilingType = dict.get('TilingType');
  39657. if (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
  39658. throw new _util.FormatError('Invalid getTilingPatternIR /BBox array: [' + bbox + '].');
  39659. }
  39660. return ['TilingPattern', args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
  39661. }
  39662. exports.Pattern = Pattern;
  39663. exports.getTilingPatternIR = getTilingPatternIR;
  39664. /***/ }),
  39665. /* 137 */
  39666. /***/ (function(module, exports, __w_pdfjs_require__) {
  39667. "use strict";
  39668. Object.defineProperty(exports, "__esModule", {
  39669. value: true
  39670. });
  39671. exports.bidi = undefined;
  39672. var _util = __w_pdfjs_require__(0);
  39673. 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', 'ES', 'CS', 'ES', 'CS', 'CS', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'CS', 'ON', 'ON', 'ON', 'ON', 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON', 'ON', 'ON', 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON', 'ON', 'ON', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'B', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'CS', 'ON', 'ET', 'ET', 'ET', 'ET', 'ON', 'ON', 'ON', 'ON', 'L', 'ON', 'ON', 'BN', 'ON', 'ON', 'ET', 'ET', 'EN', 'EN', 'ON', 'L', 'ON', 'ON', 'ON', 'EN', 'L', 'ON', 'ON', 'ON', 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L'];
  39674. var arabicTypes = ['AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'ON', 'ON', 'AL', 'ET', 'ET', 'AL', 'CS', 'AL', 'ON', 'ON', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AL', 'AL', '', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'ET', 'AN', 'AN', 'AL', 'AL', 'AL', 'NSM', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AN', 'ON', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AL', 'AL', 'NSM', 'NSM', 'ON', 'NSM', 'NSM', 'NSM', 'NSM', 'AL', 'AL', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL'];
  39675. function isOdd(i) {
  39676. return (i & 1) !== 0;
  39677. }
  39678. function isEven(i) {
  39679. return (i & 1) === 0;
  39680. }
  39681. function findUnequal(arr, start, value) {
  39682. for (var j = start, jj = arr.length; j < jj; ++j) {
  39683. if (arr[j] !== value) {
  39684. return j;
  39685. }
  39686. }
  39687. return j;
  39688. }
  39689. function setValues(arr, start, end, value) {
  39690. for (var j = start; j < end; ++j) {
  39691. arr[j] = value;
  39692. }
  39693. }
  39694. function reverseValues(arr, start, end) {
  39695. for (var i = start, j = end - 1; i < j; ++i, --j) {
  39696. var temp = arr[i];
  39697. arr[i] = arr[j];
  39698. arr[j] = temp;
  39699. }
  39700. }
  39701. function createBidiText(str, isLTR, vertical) {
  39702. return {
  39703. str: str,
  39704. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  39705. };
  39706. }
  39707. var chars = [];
  39708. var types = [];
  39709. function bidi(str, startLevel, vertical) {
  39710. var isLTR = true;
  39711. var strLength = str.length;
  39712. if (strLength === 0 || vertical) {
  39713. return createBidiText(str, isLTR, vertical);
  39714. }
  39715. chars.length = strLength;
  39716. types.length = strLength;
  39717. var numBidi = 0;
  39718. var i, ii;
  39719. for (i = 0; i < strLength; ++i) {
  39720. chars[i] = str.charAt(i);
  39721. var charCode = str.charCodeAt(i);
  39722. var charType = 'L';
  39723. if (charCode <= 0x00ff) {
  39724. charType = baseTypes[charCode];
  39725. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  39726. charType = 'R';
  39727. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  39728. charType = arabicTypes[charCode & 0xff];
  39729. if (!charType) {
  39730. (0, _util.warn)('Bidi: invalid Unicode character ' + charCode.toString(16));
  39731. }
  39732. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  39733. charType = 'AL';
  39734. }
  39735. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  39736. numBidi++;
  39737. }
  39738. types[i] = charType;
  39739. }
  39740. if (numBidi === 0) {
  39741. isLTR = true;
  39742. return createBidiText(str, isLTR);
  39743. }
  39744. if (startLevel === -1) {
  39745. if (numBidi / strLength < 0.3) {
  39746. isLTR = true;
  39747. startLevel = 0;
  39748. } else {
  39749. isLTR = false;
  39750. startLevel = 1;
  39751. }
  39752. }
  39753. var levels = [];
  39754. for (i = 0; i < strLength; ++i) {
  39755. levels[i] = startLevel;
  39756. }
  39757. var e = isOdd(startLevel) ? 'R' : 'L';
  39758. var sor = e;
  39759. var eor = sor;
  39760. var lastType = sor;
  39761. for (i = 0; i < strLength; ++i) {
  39762. if (types[i] === 'NSM') {
  39763. types[i] = lastType;
  39764. } else {
  39765. lastType = types[i];
  39766. }
  39767. }
  39768. lastType = sor;
  39769. var t;
  39770. for (i = 0; i < strLength; ++i) {
  39771. t = types[i];
  39772. if (t === 'EN') {
  39773. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  39774. } else if (t === 'R' || t === 'L' || t === 'AL') {
  39775. lastType = t;
  39776. }
  39777. }
  39778. for (i = 0; i < strLength; ++i) {
  39779. t = types[i];
  39780. if (t === 'AL') {
  39781. types[i] = 'R';
  39782. }
  39783. }
  39784. for (i = 1; i < strLength - 1; ++i) {
  39785. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  39786. types[i] = 'EN';
  39787. }
  39788. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  39789. types[i] = types[i - 1];
  39790. }
  39791. }
  39792. for (i = 0; i < strLength; ++i) {
  39793. if (types[i] === 'EN') {
  39794. var j;
  39795. for (j = i - 1; j >= 0; --j) {
  39796. if (types[j] !== 'ET') {
  39797. break;
  39798. }
  39799. types[j] = 'EN';
  39800. }
  39801. for (j = i + 1; j < strLength; ++j) {
  39802. if (types[j] !== 'ET') {
  39803. break;
  39804. }
  39805. types[j] = 'EN';
  39806. }
  39807. }
  39808. }
  39809. for (i = 0; i < strLength; ++i) {
  39810. t = types[i];
  39811. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  39812. types[i] = 'ON';
  39813. }
  39814. }
  39815. lastType = sor;
  39816. for (i = 0; i < strLength; ++i) {
  39817. t = types[i];
  39818. if (t === 'EN') {
  39819. types[i] = lastType === 'L' ? 'L' : 'EN';
  39820. } else if (t === 'R' || t === 'L') {
  39821. lastType = t;
  39822. }
  39823. }
  39824. for (i = 0; i < strLength; ++i) {
  39825. if (types[i] === 'ON') {
  39826. var end = findUnequal(types, i + 1, 'ON');
  39827. var before = sor;
  39828. if (i > 0) {
  39829. before = types[i - 1];
  39830. }
  39831. var after = eor;
  39832. if (end + 1 < strLength) {
  39833. after = types[end + 1];
  39834. }
  39835. if (before !== 'L') {
  39836. before = 'R';
  39837. }
  39838. if (after !== 'L') {
  39839. after = 'R';
  39840. }
  39841. if (before === after) {
  39842. setValues(types, i, end, before);
  39843. }
  39844. i = end - 1;
  39845. }
  39846. }
  39847. for (i = 0; i < strLength; ++i) {
  39848. if (types[i] === 'ON') {
  39849. types[i] = e;
  39850. }
  39851. }
  39852. for (i = 0; i < strLength; ++i) {
  39853. t = types[i];
  39854. if (isEven(levels[i])) {
  39855. if (t === 'R') {
  39856. levels[i] += 1;
  39857. } else if (t === 'AN' || t === 'EN') {
  39858. levels[i] += 2;
  39859. }
  39860. } else {
  39861. if (t === 'L' || t === 'AN' || t === 'EN') {
  39862. levels[i] += 1;
  39863. }
  39864. }
  39865. }
  39866. var highestLevel = -1;
  39867. var lowestOddLevel = 99;
  39868. var level;
  39869. for (i = 0, ii = levels.length; i < ii; ++i) {
  39870. level = levels[i];
  39871. if (highestLevel < level) {
  39872. highestLevel = level;
  39873. }
  39874. if (lowestOddLevel > level && isOdd(level)) {
  39875. lowestOddLevel = level;
  39876. }
  39877. }
  39878. for (level = highestLevel; level >= lowestOddLevel; --level) {
  39879. var start = -1;
  39880. for (i = 0, ii = levels.length; i < ii; ++i) {
  39881. if (levels[i] < level) {
  39882. if (start >= 0) {
  39883. reverseValues(chars, start, i);
  39884. start = -1;
  39885. }
  39886. } else if (start < 0) {
  39887. start = i;
  39888. }
  39889. }
  39890. if (start >= 0) {
  39891. reverseValues(chars, start, levels.length);
  39892. }
  39893. }
  39894. for (i = 0, ii = chars.length; i < ii; ++i) {
  39895. var ch = chars[i];
  39896. if (ch === '<' || ch === '>') {
  39897. chars[i] = '';
  39898. }
  39899. }
  39900. return createBidiText(chars.join(''), isLTR);
  39901. }
  39902. exports.bidi = bidi;
  39903. /***/ }),
  39904. /* 138 */
  39905. /***/ (function(module, exports, __w_pdfjs_require__) {
  39906. "use strict";
  39907. Object.defineProperty(exports, "__esModule", {
  39908. value: true
  39909. });
  39910. exports.getMetrics = undefined;
  39911. var _util = __w_pdfjs_require__(0);
  39912. var getMetrics = (0, _util.getLookupTableFactory)(function (t) {
  39913. t['Courier'] = 600;
  39914. t['Courier-Bold'] = 600;
  39915. t['Courier-BoldOblique'] = 600;
  39916. t['Courier-Oblique'] = 600;
  39917. t['Helvetica'] = (0, _util.getLookupTableFactory)(function (t) {
  39918. t['space'] = 278;
  39919. t['exclam'] = 278;
  39920. t['quotedbl'] = 355;
  39921. t['numbersign'] = 556;
  39922. t['dollar'] = 556;
  39923. t['percent'] = 889;
  39924. t['ampersand'] = 667;
  39925. t['quoteright'] = 222;
  39926. t['parenleft'] = 333;
  39927. t['parenright'] = 333;
  39928. t['asterisk'] = 389;
  39929. t['plus'] = 584;
  39930. t['comma'] = 278;
  39931. t['hyphen'] = 333;
  39932. t['period'] = 278;
  39933. t['slash'] = 278;
  39934. t['zero'] = 556;
  39935. t['one'] = 556;
  39936. t['two'] = 556;
  39937. t['three'] = 556;
  39938. t['four'] = 556;
  39939. t['five'] = 556;
  39940. t['six'] = 556;
  39941. t['seven'] = 556;
  39942. t['eight'] = 556;
  39943. t['nine'] = 556;
  39944. t['colon'] = 278;
  39945. t['semicolon'] = 278;
  39946. t['less'] = 584;
  39947. t['equal'] = 584;
  39948. t['greater'] = 584;
  39949. t['question'] = 556;
  39950. t['at'] = 1015;
  39951. t['A'] = 667;
  39952. t['B'] = 667;
  39953. t['C'] = 722;
  39954. t['D'] = 722;
  39955. t['E'] = 667;
  39956. t['F'] = 611;
  39957. t['G'] = 778;
  39958. t['H'] = 722;
  39959. t['I'] = 278;
  39960. t['J'] = 500;
  39961. t['K'] = 667;
  39962. t['L'] = 556;
  39963. t['M'] = 833;
  39964. t['N'] = 722;
  39965. t['O'] = 778;
  39966. t['P'] = 667;
  39967. t['Q'] = 778;
  39968. t['R'] = 722;
  39969. t['S'] = 667;
  39970. t['T'] = 611;
  39971. t['U'] = 722;
  39972. t['V'] = 667;
  39973. t['W'] = 944;
  39974. t['X'] = 667;
  39975. t['Y'] = 667;
  39976. t['Z'] = 611;
  39977. t['bracketleft'] = 278;
  39978. t['backslash'] = 278;
  39979. t['bracketright'] = 278;
  39980. t['asciicircum'] = 469;
  39981. t['underscore'] = 556;
  39982. t['quoteleft'] = 222;
  39983. t['a'] = 556;
  39984. t['b'] = 556;
  39985. t['c'] = 500;
  39986. t['d'] = 556;
  39987. t['e'] = 556;
  39988. t['f'] = 278;
  39989. t['g'] = 556;
  39990. t['h'] = 556;
  39991. t['i'] = 222;
  39992. t['j'] = 222;
  39993. t['k'] = 500;
  39994. t['l'] = 222;
  39995. t['m'] = 833;
  39996. t['n'] = 556;
  39997. t['o'] = 556;
  39998. t['p'] = 556;
  39999. t['q'] = 556;
  40000. t['r'] = 333;
  40001. t['s'] = 500;
  40002. t['t'] = 278;
  40003. t['u'] = 556;
  40004. t['v'] = 500;
  40005. t['w'] = 722;
  40006. t['x'] = 500;
  40007. t['y'] = 500;
  40008. t['z'] = 500;
  40009. t['braceleft'] = 334;
  40010. t['bar'] = 260;
  40011. t['braceright'] = 334;
  40012. t['asciitilde'] = 584;
  40013. t['exclamdown'] = 333;
  40014. t['cent'] = 556;
  40015. t['sterling'] = 556;
  40016. t['fraction'] = 167;
  40017. t['yen'] = 556;
  40018. t['florin'] = 556;
  40019. t['section'] = 556;
  40020. t['currency'] = 556;
  40021. t['quotesingle'] = 191;
  40022. t['quotedblleft'] = 333;
  40023. t['guillemotleft'] = 556;
  40024. t['guilsinglleft'] = 333;
  40025. t['guilsinglright'] = 333;
  40026. t['fi'] = 500;
  40027. t['fl'] = 500;
  40028. t['endash'] = 556;
  40029. t['dagger'] = 556;
  40030. t['daggerdbl'] = 556;
  40031. t['periodcentered'] = 278;
  40032. t['paragraph'] = 537;
  40033. t['bullet'] = 350;
  40034. t['quotesinglbase'] = 222;
  40035. t['quotedblbase'] = 333;
  40036. t['quotedblright'] = 333;
  40037. t['guillemotright'] = 556;
  40038. t['ellipsis'] = 1000;
  40039. t['perthousand'] = 1000;
  40040. t['questiondown'] = 611;
  40041. t['grave'] = 333;
  40042. t['acute'] = 333;
  40043. t['circumflex'] = 333;
  40044. t['tilde'] = 333;
  40045. t['macron'] = 333;
  40046. t['breve'] = 333;
  40047. t['dotaccent'] = 333;
  40048. t['dieresis'] = 333;
  40049. t['ring'] = 333;
  40050. t['cedilla'] = 333;
  40051. t['hungarumlaut'] = 333;
  40052. t['ogonek'] = 333;
  40053. t['caron'] = 333;
  40054. t['emdash'] = 1000;
  40055. t['AE'] = 1000;
  40056. t['ordfeminine'] = 370;
  40057. t['Lslash'] = 556;
  40058. t['Oslash'] = 778;
  40059. t['OE'] = 1000;
  40060. t['ordmasculine'] = 365;
  40061. t['ae'] = 889;
  40062. t['dotlessi'] = 278;
  40063. t['lslash'] = 222;
  40064. t['oslash'] = 611;
  40065. t['oe'] = 944;
  40066. t['germandbls'] = 611;
  40067. t['Idieresis'] = 278;
  40068. t['eacute'] = 556;
  40069. t['abreve'] = 556;
  40070. t['uhungarumlaut'] = 556;
  40071. t['ecaron'] = 556;
  40072. t['Ydieresis'] = 667;
  40073. t['divide'] = 584;
  40074. t['Yacute'] = 667;
  40075. t['Acircumflex'] = 667;
  40076. t['aacute'] = 556;
  40077. t['Ucircumflex'] = 722;
  40078. t['yacute'] = 500;
  40079. t['scommaaccent'] = 500;
  40080. t['ecircumflex'] = 556;
  40081. t['Uring'] = 722;
  40082. t['Udieresis'] = 722;
  40083. t['aogonek'] = 556;
  40084. t['Uacute'] = 722;
  40085. t['uogonek'] = 556;
  40086. t['Edieresis'] = 667;
  40087. t['Dcroat'] = 722;
  40088. t['commaaccent'] = 250;
  40089. t['copyright'] = 737;
  40090. t['Emacron'] = 667;
  40091. t['ccaron'] = 500;
  40092. t['aring'] = 556;
  40093. t['Ncommaaccent'] = 722;
  40094. t['lacute'] = 222;
  40095. t['agrave'] = 556;
  40096. t['Tcommaaccent'] = 611;
  40097. t['Cacute'] = 722;
  40098. t['atilde'] = 556;
  40099. t['Edotaccent'] = 667;
  40100. t['scaron'] = 500;
  40101. t['scedilla'] = 500;
  40102. t['iacute'] = 278;
  40103. t['lozenge'] = 471;
  40104. t['Rcaron'] = 722;
  40105. t['Gcommaaccent'] = 778;
  40106. t['ucircumflex'] = 556;
  40107. t['acircumflex'] = 556;
  40108. t['Amacron'] = 667;
  40109. t['rcaron'] = 333;
  40110. t['ccedilla'] = 500;
  40111. t['Zdotaccent'] = 611;
  40112. t['Thorn'] = 667;
  40113. t['Omacron'] = 778;
  40114. t['Racute'] = 722;
  40115. t['Sacute'] = 667;
  40116. t['dcaron'] = 643;
  40117. t['Umacron'] = 722;
  40118. t['uring'] = 556;
  40119. t['threesuperior'] = 333;
  40120. t['Ograve'] = 778;
  40121. t['Agrave'] = 667;
  40122. t['Abreve'] = 667;
  40123. t['multiply'] = 584;
  40124. t['uacute'] = 556;
  40125. t['Tcaron'] = 611;
  40126. t['partialdiff'] = 476;
  40127. t['ydieresis'] = 500;
  40128. t['Nacute'] = 722;
  40129. t['icircumflex'] = 278;
  40130. t['Ecircumflex'] = 667;
  40131. t['adieresis'] = 556;
  40132. t['edieresis'] = 556;
  40133. t['cacute'] = 500;
  40134. t['nacute'] = 556;
  40135. t['umacron'] = 556;
  40136. t['Ncaron'] = 722;
  40137. t['Iacute'] = 278;
  40138. t['plusminus'] = 584;
  40139. t['brokenbar'] = 260;
  40140. t['registered'] = 737;
  40141. t['Gbreve'] = 778;
  40142. t['Idotaccent'] = 278;
  40143. t['summation'] = 600;
  40144. t['Egrave'] = 667;
  40145. t['racute'] = 333;
  40146. t['omacron'] = 556;
  40147. t['Zacute'] = 611;
  40148. t['Zcaron'] = 611;
  40149. t['greaterequal'] = 549;
  40150. t['Eth'] = 722;
  40151. t['Ccedilla'] = 722;
  40152. t['lcommaaccent'] = 222;
  40153. t['tcaron'] = 317;
  40154. t['eogonek'] = 556;
  40155. t['Uogonek'] = 722;
  40156. t['Aacute'] = 667;
  40157. t['Adieresis'] = 667;
  40158. t['egrave'] = 556;
  40159. t['zacute'] = 500;
  40160. t['iogonek'] = 222;
  40161. t['Oacute'] = 778;
  40162. t['oacute'] = 556;
  40163. t['amacron'] = 556;
  40164. t['sacute'] = 500;
  40165. t['idieresis'] = 278;
  40166. t['Ocircumflex'] = 778;
  40167. t['Ugrave'] = 722;
  40168. t['Delta'] = 612;
  40169. t['thorn'] = 556;
  40170. t['twosuperior'] = 333;
  40171. t['Odieresis'] = 778;
  40172. t['mu'] = 556;
  40173. t['igrave'] = 278;
  40174. t['ohungarumlaut'] = 556;
  40175. t['Eogonek'] = 667;
  40176. t['dcroat'] = 556;
  40177. t['threequarters'] = 834;
  40178. t['Scedilla'] = 667;
  40179. t['lcaron'] = 299;
  40180. t['Kcommaaccent'] = 667;
  40181. t['Lacute'] = 556;
  40182. t['trademark'] = 1000;
  40183. t['edotaccent'] = 556;
  40184. t['Igrave'] = 278;
  40185. t['Imacron'] = 278;
  40186. t['Lcaron'] = 556;
  40187. t['onehalf'] = 834;
  40188. t['lessequal'] = 549;
  40189. t['ocircumflex'] = 556;
  40190. t['ntilde'] = 556;
  40191. t['Uhungarumlaut'] = 722;
  40192. t['Eacute'] = 667;
  40193. t['emacron'] = 556;
  40194. t['gbreve'] = 556;
  40195. t['onequarter'] = 834;
  40196. t['Scaron'] = 667;
  40197. t['Scommaaccent'] = 667;
  40198. t['Ohungarumlaut'] = 778;
  40199. t['degree'] = 400;
  40200. t['ograve'] = 556;
  40201. t['Ccaron'] = 722;
  40202. t['ugrave'] = 556;
  40203. t['radical'] = 453;
  40204. t['Dcaron'] = 722;
  40205. t['rcommaaccent'] = 333;
  40206. t['Ntilde'] = 722;
  40207. t['otilde'] = 556;
  40208. t['Rcommaaccent'] = 722;
  40209. t['Lcommaaccent'] = 556;
  40210. t['Atilde'] = 667;
  40211. t['Aogonek'] = 667;
  40212. t['Aring'] = 667;
  40213. t['Otilde'] = 778;
  40214. t['zdotaccent'] = 500;
  40215. t['Ecaron'] = 667;
  40216. t['Iogonek'] = 278;
  40217. t['kcommaaccent'] = 500;
  40218. t['minus'] = 584;
  40219. t['Icircumflex'] = 278;
  40220. t['ncaron'] = 556;
  40221. t['tcommaaccent'] = 278;
  40222. t['logicalnot'] = 584;
  40223. t['odieresis'] = 556;
  40224. t['udieresis'] = 556;
  40225. t['notequal'] = 549;
  40226. t['gcommaaccent'] = 556;
  40227. t['eth'] = 556;
  40228. t['zcaron'] = 500;
  40229. t['ncommaaccent'] = 556;
  40230. t['onesuperior'] = 333;
  40231. t['imacron'] = 278;
  40232. t['Euro'] = 556;
  40233. });
  40234. t['Helvetica-Bold'] = (0, _util.getLookupTableFactory)(function (t) {
  40235. t['space'] = 278;
  40236. t['exclam'] = 333;
  40237. t['quotedbl'] = 474;
  40238. t['numbersign'] = 556;
  40239. t['dollar'] = 556;
  40240. t['percent'] = 889;
  40241. t['ampersand'] = 722;
  40242. t['quoteright'] = 278;
  40243. t['parenleft'] = 333;
  40244. t['parenright'] = 333;
  40245. t['asterisk'] = 389;
  40246. t['plus'] = 584;
  40247. t['comma'] = 278;
  40248. t['hyphen'] = 333;
  40249. t['period'] = 278;
  40250. t['slash'] = 278;
  40251. t['zero'] = 556;
  40252. t['one'] = 556;
  40253. t['two'] = 556;
  40254. t['three'] = 556;
  40255. t['four'] = 556;
  40256. t['five'] = 556;
  40257. t['six'] = 556;
  40258. t['seven'] = 556;
  40259. t['eight'] = 556;
  40260. t['nine'] = 556;
  40261. t['colon'] = 333;
  40262. t['semicolon'] = 333;
  40263. t['less'] = 584;
  40264. t['equal'] = 584;
  40265. t['greater'] = 584;
  40266. t['question'] = 611;
  40267. t['at'] = 975;
  40268. t['A'] = 722;
  40269. t['B'] = 722;
  40270. t['C'] = 722;
  40271. t['D'] = 722;
  40272. t['E'] = 667;
  40273. t['F'] = 611;
  40274. t['G'] = 778;
  40275. t['H'] = 722;
  40276. t['I'] = 278;
  40277. t['J'] = 556;
  40278. t['K'] = 722;
  40279. t['L'] = 611;
  40280. t['M'] = 833;
  40281. t['N'] = 722;
  40282. t['O'] = 778;
  40283. t['P'] = 667;
  40284. t['Q'] = 778;
  40285. t['R'] = 722;
  40286. t['S'] = 667;
  40287. t['T'] = 611;
  40288. t['U'] = 722;
  40289. t['V'] = 667;
  40290. t['W'] = 944;
  40291. t['X'] = 667;
  40292. t['Y'] = 667;
  40293. t['Z'] = 611;
  40294. t['bracketleft'] = 333;
  40295. t['backslash'] = 278;
  40296. t['bracketright'] = 333;
  40297. t['asciicircum'] = 584;
  40298. t['underscore'] = 556;
  40299. t['quoteleft'] = 278;
  40300. t['a'] = 556;
  40301. t['b'] = 611;
  40302. t['c'] = 556;
  40303. t['d'] = 611;
  40304. t['e'] = 556;
  40305. t['f'] = 333;
  40306. t['g'] = 611;
  40307. t['h'] = 611;
  40308. t['i'] = 278;
  40309. t['j'] = 278;
  40310. t['k'] = 556;
  40311. t['l'] = 278;
  40312. t['m'] = 889;
  40313. t['n'] = 611;
  40314. t['o'] = 611;
  40315. t['p'] = 611;
  40316. t['q'] = 611;
  40317. t['r'] = 389;
  40318. t['s'] = 556;
  40319. t['t'] = 333;
  40320. t['u'] = 611;
  40321. t['v'] = 556;
  40322. t['w'] = 778;
  40323. t['x'] = 556;
  40324. t['y'] = 556;
  40325. t['z'] = 500;
  40326. t['braceleft'] = 389;
  40327. t['bar'] = 280;
  40328. t['braceright'] = 389;
  40329. t['asciitilde'] = 584;
  40330. t['exclamdown'] = 333;
  40331. t['cent'] = 556;
  40332. t['sterling'] = 556;
  40333. t['fraction'] = 167;
  40334. t['yen'] = 556;
  40335. t['florin'] = 556;
  40336. t['section'] = 556;
  40337. t['currency'] = 556;
  40338. t['quotesingle'] = 238;
  40339. t['quotedblleft'] = 500;
  40340. t['guillemotleft'] = 556;
  40341. t['guilsinglleft'] = 333;
  40342. t['guilsinglright'] = 333;
  40343. t['fi'] = 611;
  40344. t['fl'] = 611;
  40345. t['endash'] = 556;
  40346. t['dagger'] = 556;
  40347. t['daggerdbl'] = 556;
  40348. t['periodcentered'] = 278;
  40349. t['paragraph'] = 556;
  40350. t['bullet'] = 350;
  40351. t['quotesinglbase'] = 278;
  40352. t['quotedblbase'] = 500;
  40353. t['quotedblright'] = 500;
  40354. t['guillemotright'] = 556;
  40355. t['ellipsis'] = 1000;
  40356. t['perthousand'] = 1000;
  40357. t['questiondown'] = 611;
  40358. t['grave'] = 333;
  40359. t['acute'] = 333;
  40360. t['circumflex'] = 333;
  40361. t['tilde'] = 333;
  40362. t['macron'] = 333;
  40363. t['breve'] = 333;
  40364. t['dotaccent'] = 333;
  40365. t['dieresis'] = 333;
  40366. t['ring'] = 333;
  40367. t['cedilla'] = 333;
  40368. t['hungarumlaut'] = 333;
  40369. t['ogonek'] = 333;
  40370. t['caron'] = 333;
  40371. t['emdash'] = 1000;
  40372. t['AE'] = 1000;
  40373. t['ordfeminine'] = 370;
  40374. t['Lslash'] = 611;
  40375. t['Oslash'] = 778;
  40376. t['OE'] = 1000;
  40377. t['ordmasculine'] = 365;
  40378. t['ae'] = 889;
  40379. t['dotlessi'] = 278;
  40380. t['lslash'] = 278;
  40381. t['oslash'] = 611;
  40382. t['oe'] = 944;
  40383. t['germandbls'] = 611;
  40384. t['Idieresis'] = 278;
  40385. t['eacute'] = 556;
  40386. t['abreve'] = 556;
  40387. t['uhungarumlaut'] = 611;
  40388. t['ecaron'] = 556;
  40389. t['Ydieresis'] = 667;
  40390. t['divide'] = 584;
  40391. t['Yacute'] = 667;
  40392. t['Acircumflex'] = 722;
  40393. t['aacute'] = 556;
  40394. t['Ucircumflex'] = 722;
  40395. t['yacute'] = 556;
  40396. t['scommaaccent'] = 556;
  40397. t['ecircumflex'] = 556;
  40398. t['Uring'] = 722;
  40399. t['Udieresis'] = 722;
  40400. t['aogonek'] = 556;
  40401. t['Uacute'] = 722;
  40402. t['uogonek'] = 611;
  40403. t['Edieresis'] = 667;
  40404. t['Dcroat'] = 722;
  40405. t['commaaccent'] = 250;
  40406. t['copyright'] = 737;
  40407. t['Emacron'] = 667;
  40408. t['ccaron'] = 556;
  40409. t['aring'] = 556;
  40410. t['Ncommaaccent'] = 722;
  40411. t['lacute'] = 278;
  40412. t['agrave'] = 556;
  40413. t['Tcommaaccent'] = 611;
  40414. t['Cacute'] = 722;
  40415. t['atilde'] = 556;
  40416. t['Edotaccent'] = 667;
  40417. t['scaron'] = 556;
  40418. t['scedilla'] = 556;
  40419. t['iacute'] = 278;
  40420. t['lozenge'] = 494;
  40421. t['Rcaron'] = 722;
  40422. t['Gcommaaccent'] = 778;
  40423. t['ucircumflex'] = 611;
  40424. t['acircumflex'] = 556;
  40425. t['Amacron'] = 722;
  40426. t['rcaron'] = 389;
  40427. t['ccedilla'] = 556;
  40428. t['Zdotaccent'] = 611;
  40429. t['Thorn'] = 667;
  40430. t['Omacron'] = 778;
  40431. t['Racute'] = 722;
  40432. t['Sacute'] = 667;
  40433. t['dcaron'] = 743;
  40434. t['Umacron'] = 722;
  40435. t['uring'] = 611;
  40436. t['threesuperior'] = 333;
  40437. t['Ograve'] = 778;
  40438. t['Agrave'] = 722;
  40439. t['Abreve'] = 722;
  40440. t['multiply'] = 584;
  40441. t['uacute'] = 611;
  40442. t['Tcaron'] = 611;
  40443. t['partialdiff'] = 494;
  40444. t['ydieresis'] = 556;
  40445. t['Nacute'] = 722;
  40446. t['icircumflex'] = 278;
  40447. t['Ecircumflex'] = 667;
  40448. t['adieresis'] = 556;
  40449. t['edieresis'] = 556;
  40450. t['cacute'] = 556;
  40451. t['nacute'] = 611;
  40452. t['umacron'] = 611;
  40453. t['Ncaron'] = 722;
  40454. t['Iacute'] = 278;
  40455. t['plusminus'] = 584;
  40456. t['brokenbar'] = 280;
  40457. t['registered'] = 737;
  40458. t['Gbreve'] = 778;
  40459. t['Idotaccent'] = 278;
  40460. t['summation'] = 600;
  40461. t['Egrave'] = 667;
  40462. t['racute'] = 389;
  40463. t['omacron'] = 611;
  40464. t['Zacute'] = 611;
  40465. t['Zcaron'] = 611;
  40466. t['greaterequal'] = 549;
  40467. t['Eth'] = 722;
  40468. t['Ccedilla'] = 722;
  40469. t['lcommaaccent'] = 278;
  40470. t['tcaron'] = 389;
  40471. t['eogonek'] = 556;
  40472. t['Uogonek'] = 722;
  40473. t['Aacute'] = 722;
  40474. t['Adieresis'] = 722;
  40475. t['egrave'] = 556;
  40476. t['zacute'] = 500;
  40477. t['iogonek'] = 278;
  40478. t['Oacute'] = 778;
  40479. t['oacute'] = 611;
  40480. t['amacron'] = 556;
  40481. t['sacute'] = 556;
  40482. t['idieresis'] = 278;
  40483. t['Ocircumflex'] = 778;
  40484. t['Ugrave'] = 722;
  40485. t['Delta'] = 612;
  40486. t['thorn'] = 611;
  40487. t['twosuperior'] = 333;
  40488. t['Odieresis'] = 778;
  40489. t['mu'] = 611;
  40490. t['igrave'] = 278;
  40491. t['ohungarumlaut'] = 611;
  40492. t['Eogonek'] = 667;
  40493. t['dcroat'] = 611;
  40494. t['threequarters'] = 834;
  40495. t['Scedilla'] = 667;
  40496. t['lcaron'] = 400;
  40497. t['Kcommaaccent'] = 722;
  40498. t['Lacute'] = 611;
  40499. t['trademark'] = 1000;
  40500. t['edotaccent'] = 556;
  40501. t['Igrave'] = 278;
  40502. t['Imacron'] = 278;
  40503. t['Lcaron'] = 611;
  40504. t['onehalf'] = 834;
  40505. t['lessequal'] = 549;
  40506. t['ocircumflex'] = 611;
  40507. t['ntilde'] = 611;
  40508. t['Uhungarumlaut'] = 722;
  40509. t['Eacute'] = 667;
  40510. t['emacron'] = 556;
  40511. t['gbreve'] = 611;
  40512. t['onequarter'] = 834;
  40513. t['Scaron'] = 667;
  40514. t['Scommaaccent'] = 667;
  40515. t['Ohungarumlaut'] = 778;
  40516. t['degree'] = 400;
  40517. t['ograve'] = 611;
  40518. t['Ccaron'] = 722;
  40519. t['ugrave'] = 611;
  40520. t['radical'] = 549;
  40521. t['Dcaron'] = 722;
  40522. t['rcommaaccent'] = 389;
  40523. t['Ntilde'] = 722;
  40524. t['otilde'] = 611;
  40525. t['Rcommaaccent'] = 722;
  40526. t['Lcommaaccent'] = 611;
  40527. t['Atilde'] = 722;
  40528. t['Aogonek'] = 722;
  40529. t['Aring'] = 722;
  40530. t['Otilde'] = 778;
  40531. t['zdotaccent'] = 500;
  40532. t['Ecaron'] = 667;
  40533. t['Iogonek'] = 278;
  40534. t['kcommaaccent'] = 556;
  40535. t['minus'] = 584;
  40536. t['Icircumflex'] = 278;
  40537. t['ncaron'] = 611;
  40538. t['tcommaaccent'] = 333;
  40539. t['logicalnot'] = 584;
  40540. t['odieresis'] = 611;
  40541. t['udieresis'] = 611;
  40542. t['notequal'] = 549;
  40543. t['gcommaaccent'] = 611;
  40544. t['eth'] = 611;
  40545. t['zcaron'] = 500;
  40546. t['ncommaaccent'] = 611;
  40547. t['onesuperior'] = 333;
  40548. t['imacron'] = 278;
  40549. t['Euro'] = 556;
  40550. });
  40551. t['Helvetica-BoldOblique'] = (0, _util.getLookupTableFactory)(function (t) {
  40552. t['space'] = 278;
  40553. t['exclam'] = 333;
  40554. t['quotedbl'] = 474;
  40555. t['numbersign'] = 556;
  40556. t['dollar'] = 556;
  40557. t['percent'] = 889;
  40558. t['ampersand'] = 722;
  40559. t['quoteright'] = 278;
  40560. t['parenleft'] = 333;
  40561. t['parenright'] = 333;
  40562. t['asterisk'] = 389;
  40563. t['plus'] = 584;
  40564. t['comma'] = 278;
  40565. t['hyphen'] = 333;
  40566. t['period'] = 278;
  40567. t['slash'] = 278;
  40568. t['zero'] = 556;
  40569. t['one'] = 556;
  40570. t['two'] = 556;
  40571. t['three'] = 556;
  40572. t['four'] = 556;
  40573. t['five'] = 556;
  40574. t['six'] = 556;
  40575. t['seven'] = 556;
  40576. t['eight'] = 556;
  40577. t['nine'] = 556;
  40578. t['colon'] = 333;
  40579. t['semicolon'] = 333;
  40580. t['less'] = 584;
  40581. t['equal'] = 584;
  40582. t['greater'] = 584;
  40583. t['question'] = 611;
  40584. t['at'] = 975;
  40585. t['A'] = 722;
  40586. t['B'] = 722;
  40587. t['C'] = 722;
  40588. t['D'] = 722;
  40589. t['E'] = 667;
  40590. t['F'] = 611;
  40591. t['G'] = 778;
  40592. t['H'] = 722;
  40593. t['I'] = 278;
  40594. t['J'] = 556;
  40595. t['K'] = 722;
  40596. t['L'] = 611;
  40597. t['M'] = 833;
  40598. t['N'] = 722;
  40599. t['O'] = 778;
  40600. t['P'] = 667;
  40601. t['Q'] = 778;
  40602. t['R'] = 722;
  40603. t['S'] = 667;
  40604. t['T'] = 611;
  40605. t['U'] = 722;
  40606. t['V'] = 667;
  40607. t['W'] = 944;
  40608. t['X'] = 667;
  40609. t['Y'] = 667;
  40610. t['Z'] = 611;
  40611. t['bracketleft'] = 333;
  40612. t['backslash'] = 278;
  40613. t['bracketright'] = 333;
  40614. t['asciicircum'] = 584;
  40615. t['underscore'] = 556;
  40616. t['quoteleft'] = 278;
  40617. t['a'] = 556;
  40618. t['b'] = 611;
  40619. t['c'] = 556;
  40620. t['d'] = 611;
  40621. t['e'] = 556;
  40622. t['f'] = 333;
  40623. t['g'] = 611;
  40624. t['h'] = 611;
  40625. t['i'] = 278;
  40626. t['j'] = 278;
  40627. t['k'] = 556;
  40628. t['l'] = 278;
  40629. t['m'] = 889;
  40630. t['n'] = 611;
  40631. t['o'] = 611;
  40632. t['p'] = 611;
  40633. t['q'] = 611;
  40634. t['r'] = 389;
  40635. t['s'] = 556;
  40636. t['t'] = 333;
  40637. t['u'] = 611;
  40638. t['v'] = 556;
  40639. t['w'] = 778;
  40640. t['x'] = 556;
  40641. t['y'] = 556;
  40642. t['z'] = 500;
  40643. t['braceleft'] = 389;
  40644. t['bar'] = 280;
  40645. t['braceright'] = 389;
  40646. t['asciitilde'] = 584;
  40647. t['exclamdown'] = 333;
  40648. t['cent'] = 556;
  40649. t['sterling'] = 556;
  40650. t['fraction'] = 167;
  40651. t['yen'] = 556;
  40652. t['florin'] = 556;
  40653. t['section'] = 556;
  40654. t['currency'] = 556;
  40655. t['quotesingle'] = 238;
  40656. t['quotedblleft'] = 500;
  40657. t['guillemotleft'] = 556;
  40658. t['guilsinglleft'] = 333;
  40659. t['guilsinglright'] = 333;
  40660. t['fi'] = 611;
  40661. t['fl'] = 611;
  40662. t['endash'] = 556;
  40663. t['dagger'] = 556;
  40664. t['daggerdbl'] = 556;
  40665. t['periodcentered'] = 278;
  40666. t['paragraph'] = 556;
  40667. t['bullet'] = 350;
  40668. t['quotesinglbase'] = 278;
  40669. t['quotedblbase'] = 500;
  40670. t['quotedblright'] = 500;
  40671. t['guillemotright'] = 556;
  40672. t['ellipsis'] = 1000;
  40673. t['perthousand'] = 1000;
  40674. t['questiondown'] = 611;
  40675. t['grave'] = 333;
  40676. t['acute'] = 333;
  40677. t['circumflex'] = 333;
  40678. t['tilde'] = 333;
  40679. t['macron'] = 333;
  40680. t['breve'] = 333;
  40681. t['dotaccent'] = 333;
  40682. t['dieresis'] = 333;
  40683. t['ring'] = 333;
  40684. t['cedilla'] = 333;
  40685. t['hungarumlaut'] = 333;
  40686. t['ogonek'] = 333;
  40687. t['caron'] = 333;
  40688. t['emdash'] = 1000;
  40689. t['AE'] = 1000;
  40690. t['ordfeminine'] = 370;
  40691. t['Lslash'] = 611;
  40692. t['Oslash'] = 778;
  40693. t['OE'] = 1000;
  40694. t['ordmasculine'] = 365;
  40695. t['ae'] = 889;
  40696. t['dotlessi'] = 278;
  40697. t['lslash'] = 278;
  40698. t['oslash'] = 611;
  40699. t['oe'] = 944;
  40700. t['germandbls'] = 611;
  40701. t['Idieresis'] = 278;
  40702. t['eacute'] = 556;
  40703. t['abreve'] = 556;
  40704. t['uhungarumlaut'] = 611;
  40705. t['ecaron'] = 556;
  40706. t['Ydieresis'] = 667;
  40707. t['divide'] = 584;
  40708. t['Yacute'] = 667;
  40709. t['Acircumflex'] = 722;
  40710. t['aacute'] = 556;
  40711. t['Ucircumflex'] = 722;
  40712. t['yacute'] = 556;
  40713. t['scommaaccent'] = 556;
  40714. t['ecircumflex'] = 556;
  40715. t['Uring'] = 722;
  40716. t['Udieresis'] = 722;
  40717. t['aogonek'] = 556;
  40718. t['Uacute'] = 722;
  40719. t['uogonek'] = 611;
  40720. t['Edieresis'] = 667;
  40721. t['Dcroat'] = 722;
  40722. t['commaaccent'] = 250;
  40723. t['copyright'] = 737;
  40724. t['Emacron'] = 667;
  40725. t['ccaron'] = 556;
  40726. t['aring'] = 556;
  40727. t['Ncommaaccent'] = 722;
  40728. t['lacute'] = 278;
  40729. t['agrave'] = 556;
  40730. t['Tcommaaccent'] = 611;
  40731. t['Cacute'] = 722;
  40732. t['atilde'] = 556;
  40733. t['Edotaccent'] = 667;
  40734. t['scaron'] = 556;
  40735. t['scedilla'] = 556;
  40736. t['iacute'] = 278;
  40737. t['lozenge'] = 494;
  40738. t['Rcaron'] = 722;
  40739. t['Gcommaaccent'] = 778;
  40740. t['ucircumflex'] = 611;
  40741. t['acircumflex'] = 556;
  40742. t['Amacron'] = 722;
  40743. t['rcaron'] = 389;
  40744. t['ccedilla'] = 556;
  40745. t['Zdotaccent'] = 611;
  40746. t['Thorn'] = 667;
  40747. t['Omacron'] = 778;
  40748. t['Racute'] = 722;
  40749. t['Sacute'] = 667;
  40750. t['dcaron'] = 743;
  40751. t['Umacron'] = 722;
  40752. t['uring'] = 611;
  40753. t['threesuperior'] = 333;
  40754. t['Ograve'] = 778;
  40755. t['Agrave'] = 722;
  40756. t['Abreve'] = 722;
  40757. t['multiply'] = 584;
  40758. t['uacute'] = 611;
  40759. t['Tcaron'] = 611;
  40760. t['partialdiff'] = 494;
  40761. t['ydieresis'] = 556;
  40762. t['Nacute'] = 722;
  40763. t['icircumflex'] = 278;
  40764. t['Ecircumflex'] = 667;
  40765. t['adieresis'] = 556;
  40766. t['edieresis'] = 556;
  40767. t['cacute'] = 556;
  40768. t['nacute'] = 611;
  40769. t['umacron'] = 611;
  40770. t['Ncaron'] = 722;
  40771. t['Iacute'] = 278;
  40772. t['plusminus'] = 584;
  40773. t['brokenbar'] = 280;
  40774. t['registered'] = 737;
  40775. t['Gbreve'] = 778;
  40776. t['Idotaccent'] = 278;
  40777. t['summation'] = 600;
  40778. t['Egrave'] = 667;
  40779. t['racute'] = 389;
  40780. t['omacron'] = 611;
  40781. t['Zacute'] = 611;
  40782. t['Zcaron'] = 611;
  40783. t['greaterequal'] = 549;
  40784. t['Eth'] = 722;
  40785. t['Ccedilla'] = 722;
  40786. t['lcommaaccent'] = 278;
  40787. t['tcaron'] = 389;
  40788. t['eogonek'] = 556;
  40789. t['Uogonek'] = 722;
  40790. t['Aacute'] = 722;
  40791. t['Adieresis'] = 722;
  40792. t['egrave'] = 556;
  40793. t['zacute'] = 500;
  40794. t['iogonek'] = 278;
  40795. t['Oacute'] = 778;
  40796. t['oacute'] = 611;
  40797. t['amacron'] = 556;
  40798. t['sacute'] = 556;
  40799. t['idieresis'] = 278;
  40800. t['Ocircumflex'] = 778;
  40801. t['Ugrave'] = 722;
  40802. t['Delta'] = 612;
  40803. t['thorn'] = 611;
  40804. t['twosuperior'] = 333;
  40805. t['Odieresis'] = 778;
  40806. t['mu'] = 611;
  40807. t['igrave'] = 278;
  40808. t['ohungarumlaut'] = 611;
  40809. t['Eogonek'] = 667;
  40810. t['dcroat'] = 611;
  40811. t['threequarters'] = 834;
  40812. t['Scedilla'] = 667;
  40813. t['lcaron'] = 400;
  40814. t['Kcommaaccent'] = 722;
  40815. t['Lacute'] = 611;
  40816. t['trademark'] = 1000;
  40817. t['edotaccent'] = 556;
  40818. t['Igrave'] = 278;
  40819. t['Imacron'] = 278;
  40820. t['Lcaron'] = 611;
  40821. t['onehalf'] = 834;
  40822. t['lessequal'] = 549;
  40823. t['ocircumflex'] = 611;
  40824. t['ntilde'] = 611;
  40825. t['Uhungarumlaut'] = 722;
  40826. t['Eacute'] = 667;
  40827. t['emacron'] = 556;
  40828. t['gbreve'] = 611;
  40829. t['onequarter'] = 834;
  40830. t['Scaron'] = 667;
  40831. t['Scommaaccent'] = 667;
  40832. t['Ohungarumlaut'] = 778;
  40833. t['degree'] = 400;
  40834. t['ograve'] = 611;
  40835. t['Ccaron'] = 722;
  40836. t['ugrave'] = 611;
  40837. t['radical'] = 549;
  40838. t['Dcaron'] = 722;
  40839. t['rcommaaccent'] = 389;
  40840. t['Ntilde'] = 722;
  40841. t['otilde'] = 611;
  40842. t['Rcommaaccent'] = 722;
  40843. t['Lcommaaccent'] = 611;
  40844. t['Atilde'] = 722;
  40845. t['Aogonek'] = 722;
  40846. t['Aring'] = 722;
  40847. t['Otilde'] = 778;
  40848. t['zdotaccent'] = 500;
  40849. t['Ecaron'] = 667;
  40850. t['Iogonek'] = 278;
  40851. t['kcommaaccent'] = 556;
  40852. t['minus'] = 584;
  40853. t['Icircumflex'] = 278;
  40854. t['ncaron'] = 611;
  40855. t['tcommaaccent'] = 333;
  40856. t['logicalnot'] = 584;
  40857. t['odieresis'] = 611;
  40858. t['udieresis'] = 611;
  40859. t['notequal'] = 549;
  40860. t['gcommaaccent'] = 611;
  40861. t['eth'] = 611;
  40862. t['zcaron'] = 500;
  40863. t['ncommaaccent'] = 611;
  40864. t['onesuperior'] = 333;
  40865. t['imacron'] = 278;
  40866. t['Euro'] = 556;
  40867. });
  40868. t['Helvetica-Oblique'] = (0, _util.getLookupTableFactory)(function (t) {
  40869. t['space'] = 278;
  40870. t['exclam'] = 278;
  40871. t['quotedbl'] = 355;
  40872. t['numbersign'] = 556;
  40873. t['dollar'] = 556;
  40874. t['percent'] = 889;
  40875. t['ampersand'] = 667;
  40876. t['quoteright'] = 222;
  40877. t['parenleft'] = 333;
  40878. t['parenright'] = 333;
  40879. t['asterisk'] = 389;
  40880. t['plus'] = 584;
  40881. t['comma'] = 278;
  40882. t['hyphen'] = 333;
  40883. t['period'] = 278;
  40884. t['slash'] = 278;
  40885. t['zero'] = 556;
  40886. t['one'] = 556;
  40887. t['two'] = 556;
  40888. t['three'] = 556;
  40889. t['four'] = 556;
  40890. t['five'] = 556;
  40891. t['six'] = 556;
  40892. t['seven'] = 556;
  40893. t['eight'] = 556;
  40894. t['nine'] = 556;
  40895. t['colon'] = 278;
  40896. t['semicolon'] = 278;
  40897. t['less'] = 584;
  40898. t['equal'] = 584;
  40899. t['greater'] = 584;
  40900. t['question'] = 556;
  40901. t['at'] = 1015;
  40902. t['A'] = 667;
  40903. t['B'] = 667;
  40904. t['C'] = 722;
  40905. t['D'] = 722;
  40906. t['E'] = 667;
  40907. t['F'] = 611;
  40908. t['G'] = 778;
  40909. t['H'] = 722;
  40910. t['I'] = 278;
  40911. t['J'] = 500;
  40912. t['K'] = 667;
  40913. t['L'] = 556;
  40914. t['M'] = 833;
  40915. t['N'] = 722;
  40916. t['O'] = 778;
  40917. t['P'] = 667;
  40918. t['Q'] = 778;
  40919. t['R'] = 722;
  40920. t['S'] = 667;
  40921. t['T'] = 611;
  40922. t['U'] = 722;
  40923. t['V'] = 667;
  40924. t['W'] = 944;
  40925. t['X'] = 667;
  40926. t['Y'] = 667;
  40927. t['Z'] = 611;
  40928. t['bracketleft'] = 278;
  40929. t['backslash'] = 278;
  40930. t['bracketright'] = 278;
  40931. t['asciicircum'] = 469;
  40932. t['underscore'] = 556;
  40933. t['quoteleft'] = 222;
  40934. t['a'] = 556;
  40935. t['b'] = 556;
  40936. t['c'] = 500;
  40937. t['d'] = 556;
  40938. t['e'] = 556;
  40939. t['f'] = 278;
  40940. t['g'] = 556;
  40941. t['h'] = 556;
  40942. t['i'] = 222;
  40943. t['j'] = 222;
  40944. t['k'] = 500;
  40945. t['l'] = 222;
  40946. t['m'] = 833;
  40947. t['n'] = 556;
  40948. t['o'] = 556;
  40949. t['p'] = 556;
  40950. t['q'] = 556;
  40951. t['r'] = 333;
  40952. t['s'] = 500;
  40953. t['t'] = 278;
  40954. t['u'] = 556;
  40955. t['v'] = 500;
  40956. t['w'] = 722;
  40957. t['x'] = 500;
  40958. t['y'] = 500;
  40959. t['z'] = 500;
  40960. t['braceleft'] = 334;
  40961. t['bar'] = 260;
  40962. t['braceright'] = 334;
  40963. t['asciitilde'] = 584;
  40964. t['exclamdown'] = 333;
  40965. t['cent'] = 556;
  40966. t['sterling'] = 556;
  40967. t['fraction'] = 167;
  40968. t['yen'] = 556;
  40969. t['florin'] = 556;
  40970. t['section'] = 556;
  40971. t['currency'] = 556;
  40972. t['quotesingle'] = 191;
  40973. t['quotedblleft'] = 333;
  40974. t['guillemotleft'] = 556;
  40975. t['guilsinglleft'] = 333;
  40976. t['guilsinglright'] = 333;
  40977. t['fi'] = 500;
  40978. t['fl'] = 500;
  40979. t['endash'] = 556;
  40980. t['dagger'] = 556;
  40981. t['daggerdbl'] = 556;
  40982. t['periodcentered'] = 278;
  40983. t['paragraph'] = 537;
  40984. t['bullet'] = 350;
  40985. t['quotesinglbase'] = 222;
  40986. t['quotedblbase'] = 333;
  40987. t['quotedblright'] = 333;
  40988. t['guillemotright'] = 556;
  40989. t['ellipsis'] = 1000;
  40990. t['perthousand'] = 1000;
  40991. t['questiondown'] = 611;
  40992. t['grave'] = 333;
  40993. t['acute'] = 333;
  40994. t['circumflex'] = 333;
  40995. t['tilde'] = 333;
  40996. t['macron'] = 333;
  40997. t['breve'] = 333;
  40998. t['dotaccent'] = 333;
  40999. t['dieresis'] = 333;
  41000. t['ring'] = 333;
  41001. t['cedilla'] = 333;
  41002. t['hungarumlaut'] = 333;
  41003. t['ogonek'] = 333;
  41004. t['caron'] = 333;
  41005. t['emdash'] = 1000;
  41006. t['AE'] = 1000;
  41007. t['ordfeminine'] = 370;
  41008. t['Lslash'] = 556;
  41009. t['Oslash'] = 778;
  41010. t['OE'] = 1000;
  41011. t['ordmasculine'] = 365;
  41012. t['ae'] = 889;
  41013. t['dotlessi'] = 278;
  41014. t['lslash'] = 222;
  41015. t['oslash'] = 611;
  41016. t['oe'] = 944;
  41017. t['germandbls'] = 611;
  41018. t['Idieresis'] = 278;
  41019. t['eacute'] = 556;
  41020. t['abreve'] = 556;
  41021. t['uhungarumlaut'] = 556;
  41022. t['ecaron'] = 556;
  41023. t['Ydieresis'] = 667;
  41024. t['divide'] = 584;
  41025. t['Yacute'] = 667;
  41026. t['Acircumflex'] = 667;
  41027. t['aacute'] = 556;
  41028. t['Ucircumflex'] = 722;
  41029. t['yacute'] = 500;
  41030. t['scommaaccent'] = 500;
  41031. t['ecircumflex'] = 556;
  41032. t['Uring'] = 722;
  41033. t['Udieresis'] = 722;
  41034. t['aogonek'] = 556;
  41035. t['Uacute'] = 722;
  41036. t['uogonek'] = 556;
  41037. t['Edieresis'] = 667;
  41038. t['Dcroat'] = 722;
  41039. t['commaaccent'] = 250;
  41040. t['copyright'] = 737;
  41041. t['Emacron'] = 667;
  41042. t['ccaron'] = 500;
  41043. t['aring'] = 556;
  41044. t['Ncommaaccent'] = 722;
  41045. t['lacute'] = 222;
  41046. t['agrave'] = 556;
  41047. t['Tcommaaccent'] = 611;
  41048. t['Cacute'] = 722;
  41049. t['atilde'] = 556;
  41050. t['Edotaccent'] = 667;
  41051. t['scaron'] = 500;
  41052. t['scedilla'] = 500;
  41053. t['iacute'] = 278;
  41054. t['lozenge'] = 471;
  41055. t['Rcaron'] = 722;
  41056. t['Gcommaaccent'] = 778;
  41057. t['ucircumflex'] = 556;
  41058. t['acircumflex'] = 556;
  41059. t['Amacron'] = 667;
  41060. t['rcaron'] = 333;
  41061. t['ccedilla'] = 500;
  41062. t['Zdotaccent'] = 611;
  41063. t['Thorn'] = 667;
  41064. t['Omacron'] = 778;
  41065. t['Racute'] = 722;
  41066. t['Sacute'] = 667;
  41067. t['dcaron'] = 643;
  41068. t['Umacron'] = 722;
  41069. t['uring'] = 556;
  41070. t['threesuperior'] = 333;
  41071. t['Ograve'] = 778;
  41072. t['Agrave'] = 667;
  41073. t['Abreve'] = 667;
  41074. t['multiply'] = 584;
  41075. t['uacute'] = 556;
  41076. t['Tcaron'] = 611;
  41077. t['partialdiff'] = 476;
  41078. t['ydieresis'] = 500;
  41079. t['Nacute'] = 722;
  41080. t['icircumflex'] = 278;
  41081. t['Ecircumflex'] = 667;
  41082. t['adieresis'] = 556;
  41083. t['edieresis'] = 556;
  41084. t['cacute'] = 500;
  41085. t['nacute'] = 556;
  41086. t['umacron'] = 556;
  41087. t['Ncaron'] = 722;
  41088. t['Iacute'] = 278;
  41089. t['plusminus'] = 584;
  41090. t['brokenbar'] = 260;
  41091. t['registered'] = 737;
  41092. t['Gbreve'] = 778;
  41093. t['Idotaccent'] = 278;
  41094. t['summation'] = 600;
  41095. t['Egrave'] = 667;
  41096. t['racute'] = 333;
  41097. t['omacron'] = 556;
  41098. t['Zacute'] = 611;
  41099. t['Zcaron'] = 611;
  41100. t['greaterequal'] = 549;
  41101. t['Eth'] = 722;
  41102. t['Ccedilla'] = 722;
  41103. t['lcommaaccent'] = 222;
  41104. t['tcaron'] = 317;
  41105. t['eogonek'] = 556;
  41106. t['Uogonek'] = 722;
  41107. t['Aacute'] = 667;
  41108. t['Adieresis'] = 667;
  41109. t['egrave'] = 556;
  41110. t['zacute'] = 500;
  41111. t['iogonek'] = 222;
  41112. t['Oacute'] = 778;
  41113. t['oacute'] = 556;
  41114. t['amacron'] = 556;
  41115. t['sacute'] = 500;
  41116. t['idieresis'] = 278;
  41117. t['Ocircumflex'] = 778;
  41118. t['Ugrave'] = 722;
  41119. t['Delta'] = 612;
  41120. t['thorn'] = 556;
  41121. t['twosuperior'] = 333;
  41122. t['Odieresis'] = 778;
  41123. t['mu'] = 556;
  41124. t['igrave'] = 278;
  41125. t['ohungarumlaut'] = 556;
  41126. t['Eogonek'] = 667;
  41127. t['dcroat'] = 556;
  41128. t['threequarters'] = 834;
  41129. t['Scedilla'] = 667;
  41130. t['lcaron'] = 299;
  41131. t['Kcommaaccent'] = 667;
  41132. t['Lacute'] = 556;
  41133. t['trademark'] = 1000;
  41134. t['edotaccent'] = 556;
  41135. t['Igrave'] = 278;
  41136. t['Imacron'] = 278;
  41137. t['Lcaron'] = 556;
  41138. t['onehalf'] = 834;
  41139. t['lessequal'] = 549;
  41140. t['ocircumflex'] = 556;
  41141. t['ntilde'] = 556;
  41142. t['Uhungarumlaut'] = 722;
  41143. t['Eacute'] = 667;
  41144. t['emacron'] = 556;
  41145. t['gbreve'] = 556;
  41146. t['onequarter'] = 834;
  41147. t['Scaron'] = 667;
  41148. t['Scommaaccent'] = 667;
  41149. t['Ohungarumlaut'] = 778;
  41150. t['degree'] = 400;
  41151. t['ograve'] = 556;
  41152. t['Ccaron'] = 722;
  41153. t['ugrave'] = 556;
  41154. t['radical'] = 453;
  41155. t['Dcaron'] = 722;
  41156. t['rcommaaccent'] = 333;
  41157. t['Ntilde'] = 722;
  41158. t['otilde'] = 556;
  41159. t['Rcommaaccent'] = 722;
  41160. t['Lcommaaccent'] = 556;
  41161. t['Atilde'] = 667;
  41162. t['Aogonek'] = 667;
  41163. t['Aring'] = 667;
  41164. t['Otilde'] = 778;
  41165. t['zdotaccent'] = 500;
  41166. t['Ecaron'] = 667;
  41167. t['Iogonek'] = 278;
  41168. t['kcommaaccent'] = 500;
  41169. t['minus'] = 584;
  41170. t['Icircumflex'] = 278;
  41171. t['ncaron'] = 556;
  41172. t['tcommaaccent'] = 278;
  41173. t['logicalnot'] = 584;
  41174. t['odieresis'] = 556;
  41175. t['udieresis'] = 556;
  41176. t['notequal'] = 549;
  41177. t['gcommaaccent'] = 556;
  41178. t['eth'] = 556;
  41179. t['zcaron'] = 500;
  41180. t['ncommaaccent'] = 556;
  41181. t['onesuperior'] = 333;
  41182. t['imacron'] = 278;
  41183. t['Euro'] = 556;
  41184. });
  41185. t['Symbol'] = (0, _util.getLookupTableFactory)(function (t) {
  41186. t['space'] = 250;
  41187. t['exclam'] = 333;
  41188. t['universal'] = 713;
  41189. t['numbersign'] = 500;
  41190. t['existential'] = 549;
  41191. t['percent'] = 833;
  41192. t['ampersand'] = 778;
  41193. t['suchthat'] = 439;
  41194. t['parenleft'] = 333;
  41195. t['parenright'] = 333;
  41196. t['asteriskmath'] = 500;
  41197. t['plus'] = 549;
  41198. t['comma'] = 250;
  41199. t['minus'] = 549;
  41200. t['period'] = 250;
  41201. t['slash'] = 278;
  41202. t['zero'] = 500;
  41203. t['one'] = 500;
  41204. t['two'] = 500;
  41205. t['three'] = 500;
  41206. t['four'] = 500;
  41207. t['five'] = 500;
  41208. t['six'] = 500;
  41209. t['seven'] = 500;
  41210. t['eight'] = 500;
  41211. t['nine'] = 500;
  41212. t['colon'] = 278;
  41213. t['semicolon'] = 278;
  41214. t['less'] = 549;
  41215. t['equal'] = 549;
  41216. t['greater'] = 549;
  41217. t['question'] = 444;
  41218. t['congruent'] = 549;
  41219. t['Alpha'] = 722;
  41220. t['Beta'] = 667;
  41221. t['Chi'] = 722;
  41222. t['Delta'] = 612;
  41223. t['Epsilon'] = 611;
  41224. t['Phi'] = 763;
  41225. t['Gamma'] = 603;
  41226. t['Eta'] = 722;
  41227. t['Iota'] = 333;
  41228. t['theta1'] = 631;
  41229. t['Kappa'] = 722;
  41230. t['Lambda'] = 686;
  41231. t['Mu'] = 889;
  41232. t['Nu'] = 722;
  41233. t['Omicron'] = 722;
  41234. t['Pi'] = 768;
  41235. t['Theta'] = 741;
  41236. t['Rho'] = 556;
  41237. t['Sigma'] = 592;
  41238. t['Tau'] = 611;
  41239. t['Upsilon'] = 690;
  41240. t['sigma1'] = 439;
  41241. t['Omega'] = 768;
  41242. t['Xi'] = 645;
  41243. t['Psi'] = 795;
  41244. t['Zeta'] = 611;
  41245. t['bracketleft'] = 333;
  41246. t['therefore'] = 863;
  41247. t['bracketright'] = 333;
  41248. t['perpendicular'] = 658;
  41249. t['underscore'] = 500;
  41250. t['radicalex'] = 500;
  41251. t['alpha'] = 631;
  41252. t['beta'] = 549;
  41253. t['chi'] = 549;
  41254. t['delta'] = 494;
  41255. t['epsilon'] = 439;
  41256. t['phi'] = 521;
  41257. t['gamma'] = 411;
  41258. t['eta'] = 603;
  41259. t['iota'] = 329;
  41260. t['phi1'] = 603;
  41261. t['kappa'] = 549;
  41262. t['lambda'] = 549;
  41263. t['mu'] = 576;
  41264. t['nu'] = 521;
  41265. t['omicron'] = 549;
  41266. t['pi'] = 549;
  41267. t['theta'] = 521;
  41268. t['rho'] = 549;
  41269. t['sigma'] = 603;
  41270. t['tau'] = 439;
  41271. t['upsilon'] = 576;
  41272. t['omega1'] = 713;
  41273. t['omega'] = 686;
  41274. t['xi'] = 493;
  41275. t['psi'] = 686;
  41276. t['zeta'] = 494;
  41277. t['braceleft'] = 480;
  41278. t['bar'] = 200;
  41279. t['braceright'] = 480;
  41280. t['similar'] = 549;
  41281. t['Euro'] = 750;
  41282. t['Upsilon1'] = 620;
  41283. t['minute'] = 247;
  41284. t['lessequal'] = 549;
  41285. t['fraction'] = 167;
  41286. t['infinity'] = 713;
  41287. t['florin'] = 500;
  41288. t['club'] = 753;
  41289. t['diamond'] = 753;
  41290. t['heart'] = 753;
  41291. t['spade'] = 753;
  41292. t['arrowboth'] = 1042;
  41293. t['arrowleft'] = 987;
  41294. t['arrowup'] = 603;
  41295. t['arrowright'] = 987;
  41296. t['arrowdown'] = 603;
  41297. t['degree'] = 400;
  41298. t['plusminus'] = 549;
  41299. t['second'] = 411;
  41300. t['greaterequal'] = 549;
  41301. t['multiply'] = 549;
  41302. t['proportional'] = 713;
  41303. t['partialdiff'] = 494;
  41304. t['bullet'] = 460;
  41305. t['divide'] = 549;
  41306. t['notequal'] = 549;
  41307. t['equivalence'] = 549;
  41308. t['approxequal'] = 549;
  41309. t['ellipsis'] = 1000;
  41310. t['arrowvertex'] = 603;
  41311. t['arrowhorizex'] = 1000;
  41312. t['carriagereturn'] = 658;
  41313. t['aleph'] = 823;
  41314. t['Ifraktur'] = 686;
  41315. t['Rfraktur'] = 795;
  41316. t['weierstrass'] = 987;
  41317. t['circlemultiply'] = 768;
  41318. t['circleplus'] = 768;
  41319. t['emptyset'] = 823;
  41320. t['intersection'] = 768;
  41321. t['union'] = 768;
  41322. t['propersuperset'] = 713;
  41323. t['reflexsuperset'] = 713;
  41324. t['notsubset'] = 713;
  41325. t['propersubset'] = 713;
  41326. t['reflexsubset'] = 713;
  41327. t['element'] = 713;
  41328. t['notelement'] = 713;
  41329. t['angle'] = 768;
  41330. t['gradient'] = 713;
  41331. t['registerserif'] = 790;
  41332. t['copyrightserif'] = 790;
  41333. t['trademarkserif'] = 890;
  41334. t['product'] = 823;
  41335. t['radical'] = 549;
  41336. t['dotmath'] = 250;
  41337. t['logicalnot'] = 713;
  41338. t['logicaland'] = 603;
  41339. t['logicalor'] = 603;
  41340. t['arrowdblboth'] = 1042;
  41341. t['arrowdblleft'] = 987;
  41342. t['arrowdblup'] = 603;
  41343. t['arrowdblright'] = 987;
  41344. t['arrowdbldown'] = 603;
  41345. t['lozenge'] = 494;
  41346. t['angleleft'] = 329;
  41347. t['registersans'] = 790;
  41348. t['copyrightsans'] = 790;
  41349. t['trademarksans'] = 786;
  41350. t['summation'] = 713;
  41351. t['parenlefttp'] = 384;
  41352. t['parenleftex'] = 384;
  41353. t['parenleftbt'] = 384;
  41354. t['bracketlefttp'] = 384;
  41355. t['bracketleftex'] = 384;
  41356. t['bracketleftbt'] = 384;
  41357. t['bracelefttp'] = 494;
  41358. t['braceleftmid'] = 494;
  41359. t['braceleftbt'] = 494;
  41360. t['braceex'] = 494;
  41361. t['angleright'] = 329;
  41362. t['integral'] = 274;
  41363. t['integraltp'] = 686;
  41364. t['integralex'] = 686;
  41365. t['integralbt'] = 686;
  41366. t['parenrighttp'] = 384;
  41367. t['parenrightex'] = 384;
  41368. t['parenrightbt'] = 384;
  41369. t['bracketrighttp'] = 384;
  41370. t['bracketrightex'] = 384;
  41371. t['bracketrightbt'] = 384;
  41372. t['bracerighttp'] = 494;
  41373. t['bracerightmid'] = 494;
  41374. t['bracerightbt'] = 494;
  41375. t['apple'] = 790;
  41376. });
  41377. t['Times-Roman'] = (0, _util.getLookupTableFactory)(function (t) {
  41378. t['space'] = 250;
  41379. t['exclam'] = 333;
  41380. t['quotedbl'] = 408;
  41381. t['numbersign'] = 500;
  41382. t['dollar'] = 500;
  41383. t['percent'] = 833;
  41384. t['ampersand'] = 778;
  41385. t['quoteright'] = 333;
  41386. t['parenleft'] = 333;
  41387. t['parenright'] = 333;
  41388. t['asterisk'] = 500;
  41389. t['plus'] = 564;
  41390. t['comma'] = 250;
  41391. t['hyphen'] = 333;
  41392. t['period'] = 250;
  41393. t['slash'] = 278;
  41394. t['zero'] = 500;
  41395. t['one'] = 500;
  41396. t['two'] = 500;
  41397. t['three'] = 500;
  41398. t['four'] = 500;
  41399. t['five'] = 500;
  41400. t['six'] = 500;
  41401. t['seven'] = 500;
  41402. t['eight'] = 500;
  41403. t['nine'] = 500;
  41404. t['colon'] = 278;
  41405. t['semicolon'] = 278;
  41406. t['less'] = 564;
  41407. t['equal'] = 564;
  41408. t['greater'] = 564;
  41409. t['question'] = 444;
  41410. t['at'] = 921;
  41411. t['A'] = 722;
  41412. t['B'] = 667;
  41413. t['C'] = 667;
  41414. t['D'] = 722;
  41415. t['E'] = 611;
  41416. t['F'] = 556;
  41417. t['G'] = 722;
  41418. t['H'] = 722;
  41419. t['I'] = 333;
  41420. t['J'] = 389;
  41421. t['K'] = 722;
  41422. t['L'] = 611;
  41423. t['M'] = 889;
  41424. t['N'] = 722;
  41425. t['O'] = 722;
  41426. t['P'] = 556;
  41427. t['Q'] = 722;
  41428. t['R'] = 667;
  41429. t['S'] = 556;
  41430. t['T'] = 611;
  41431. t['U'] = 722;
  41432. t['V'] = 722;
  41433. t['W'] = 944;
  41434. t['X'] = 722;
  41435. t['Y'] = 722;
  41436. t['Z'] = 611;
  41437. t['bracketleft'] = 333;
  41438. t['backslash'] = 278;
  41439. t['bracketright'] = 333;
  41440. t['asciicircum'] = 469;
  41441. t['underscore'] = 500;
  41442. t['quoteleft'] = 333;
  41443. t['a'] = 444;
  41444. t['b'] = 500;
  41445. t['c'] = 444;
  41446. t['d'] = 500;
  41447. t['e'] = 444;
  41448. t['f'] = 333;
  41449. t['g'] = 500;
  41450. t['h'] = 500;
  41451. t['i'] = 278;
  41452. t['j'] = 278;
  41453. t['k'] = 500;
  41454. t['l'] = 278;
  41455. t['m'] = 778;
  41456. t['n'] = 500;
  41457. t['o'] = 500;
  41458. t['p'] = 500;
  41459. t['q'] = 500;
  41460. t['r'] = 333;
  41461. t['s'] = 389;
  41462. t['t'] = 278;
  41463. t['u'] = 500;
  41464. t['v'] = 500;
  41465. t['w'] = 722;
  41466. t['x'] = 500;
  41467. t['y'] = 500;
  41468. t['z'] = 444;
  41469. t['braceleft'] = 480;
  41470. t['bar'] = 200;
  41471. t['braceright'] = 480;
  41472. t['asciitilde'] = 541;
  41473. t['exclamdown'] = 333;
  41474. t['cent'] = 500;
  41475. t['sterling'] = 500;
  41476. t['fraction'] = 167;
  41477. t['yen'] = 500;
  41478. t['florin'] = 500;
  41479. t['section'] = 500;
  41480. t['currency'] = 500;
  41481. t['quotesingle'] = 180;
  41482. t['quotedblleft'] = 444;
  41483. t['guillemotleft'] = 500;
  41484. t['guilsinglleft'] = 333;
  41485. t['guilsinglright'] = 333;
  41486. t['fi'] = 556;
  41487. t['fl'] = 556;
  41488. t['endash'] = 500;
  41489. t['dagger'] = 500;
  41490. t['daggerdbl'] = 500;
  41491. t['periodcentered'] = 250;
  41492. t['paragraph'] = 453;
  41493. t['bullet'] = 350;
  41494. t['quotesinglbase'] = 333;
  41495. t['quotedblbase'] = 444;
  41496. t['quotedblright'] = 444;
  41497. t['guillemotright'] = 500;
  41498. t['ellipsis'] = 1000;
  41499. t['perthousand'] = 1000;
  41500. t['questiondown'] = 444;
  41501. t['grave'] = 333;
  41502. t['acute'] = 333;
  41503. t['circumflex'] = 333;
  41504. t['tilde'] = 333;
  41505. t['macron'] = 333;
  41506. t['breve'] = 333;
  41507. t['dotaccent'] = 333;
  41508. t['dieresis'] = 333;
  41509. t['ring'] = 333;
  41510. t['cedilla'] = 333;
  41511. t['hungarumlaut'] = 333;
  41512. t['ogonek'] = 333;
  41513. t['caron'] = 333;
  41514. t['emdash'] = 1000;
  41515. t['AE'] = 889;
  41516. t['ordfeminine'] = 276;
  41517. t['Lslash'] = 611;
  41518. t['Oslash'] = 722;
  41519. t['OE'] = 889;
  41520. t['ordmasculine'] = 310;
  41521. t['ae'] = 667;
  41522. t['dotlessi'] = 278;
  41523. t['lslash'] = 278;
  41524. t['oslash'] = 500;
  41525. t['oe'] = 722;
  41526. t['germandbls'] = 500;
  41527. t['Idieresis'] = 333;
  41528. t['eacute'] = 444;
  41529. t['abreve'] = 444;
  41530. t['uhungarumlaut'] = 500;
  41531. t['ecaron'] = 444;
  41532. t['Ydieresis'] = 722;
  41533. t['divide'] = 564;
  41534. t['Yacute'] = 722;
  41535. t['Acircumflex'] = 722;
  41536. t['aacute'] = 444;
  41537. t['Ucircumflex'] = 722;
  41538. t['yacute'] = 500;
  41539. t['scommaaccent'] = 389;
  41540. t['ecircumflex'] = 444;
  41541. t['Uring'] = 722;
  41542. t['Udieresis'] = 722;
  41543. t['aogonek'] = 444;
  41544. t['Uacute'] = 722;
  41545. t['uogonek'] = 500;
  41546. t['Edieresis'] = 611;
  41547. t['Dcroat'] = 722;
  41548. t['commaaccent'] = 250;
  41549. t['copyright'] = 760;
  41550. t['Emacron'] = 611;
  41551. t['ccaron'] = 444;
  41552. t['aring'] = 444;
  41553. t['Ncommaaccent'] = 722;
  41554. t['lacute'] = 278;
  41555. t['agrave'] = 444;
  41556. t['Tcommaaccent'] = 611;
  41557. t['Cacute'] = 667;
  41558. t['atilde'] = 444;
  41559. t['Edotaccent'] = 611;
  41560. t['scaron'] = 389;
  41561. t['scedilla'] = 389;
  41562. t['iacute'] = 278;
  41563. t['lozenge'] = 471;
  41564. t['Rcaron'] = 667;
  41565. t['Gcommaaccent'] = 722;
  41566. t['ucircumflex'] = 500;
  41567. t['acircumflex'] = 444;
  41568. t['Amacron'] = 722;
  41569. t['rcaron'] = 333;
  41570. t['ccedilla'] = 444;
  41571. t['Zdotaccent'] = 611;
  41572. t['Thorn'] = 556;
  41573. t['Omacron'] = 722;
  41574. t['Racute'] = 667;
  41575. t['Sacute'] = 556;
  41576. t['dcaron'] = 588;
  41577. t['Umacron'] = 722;
  41578. t['uring'] = 500;
  41579. t['threesuperior'] = 300;
  41580. t['Ograve'] = 722;
  41581. t['Agrave'] = 722;
  41582. t['Abreve'] = 722;
  41583. t['multiply'] = 564;
  41584. t['uacute'] = 500;
  41585. t['Tcaron'] = 611;
  41586. t['partialdiff'] = 476;
  41587. t['ydieresis'] = 500;
  41588. t['Nacute'] = 722;
  41589. t['icircumflex'] = 278;
  41590. t['Ecircumflex'] = 611;
  41591. t['adieresis'] = 444;
  41592. t['edieresis'] = 444;
  41593. t['cacute'] = 444;
  41594. t['nacute'] = 500;
  41595. t['umacron'] = 500;
  41596. t['Ncaron'] = 722;
  41597. t['Iacute'] = 333;
  41598. t['plusminus'] = 564;
  41599. t['brokenbar'] = 200;
  41600. t['registered'] = 760;
  41601. t['Gbreve'] = 722;
  41602. t['Idotaccent'] = 333;
  41603. t['summation'] = 600;
  41604. t['Egrave'] = 611;
  41605. t['racute'] = 333;
  41606. t['omacron'] = 500;
  41607. t['Zacute'] = 611;
  41608. t['Zcaron'] = 611;
  41609. t['greaterequal'] = 549;
  41610. t['Eth'] = 722;
  41611. t['Ccedilla'] = 667;
  41612. t['lcommaaccent'] = 278;
  41613. t['tcaron'] = 326;
  41614. t['eogonek'] = 444;
  41615. t['Uogonek'] = 722;
  41616. t['Aacute'] = 722;
  41617. t['Adieresis'] = 722;
  41618. t['egrave'] = 444;
  41619. t['zacute'] = 444;
  41620. t['iogonek'] = 278;
  41621. t['Oacute'] = 722;
  41622. t['oacute'] = 500;
  41623. t['amacron'] = 444;
  41624. t['sacute'] = 389;
  41625. t['idieresis'] = 278;
  41626. t['Ocircumflex'] = 722;
  41627. t['Ugrave'] = 722;
  41628. t['Delta'] = 612;
  41629. t['thorn'] = 500;
  41630. t['twosuperior'] = 300;
  41631. t['Odieresis'] = 722;
  41632. t['mu'] = 500;
  41633. t['igrave'] = 278;
  41634. t['ohungarumlaut'] = 500;
  41635. t['Eogonek'] = 611;
  41636. t['dcroat'] = 500;
  41637. t['threequarters'] = 750;
  41638. t['Scedilla'] = 556;
  41639. t['lcaron'] = 344;
  41640. t['Kcommaaccent'] = 722;
  41641. t['Lacute'] = 611;
  41642. t['trademark'] = 980;
  41643. t['edotaccent'] = 444;
  41644. t['Igrave'] = 333;
  41645. t['Imacron'] = 333;
  41646. t['Lcaron'] = 611;
  41647. t['onehalf'] = 750;
  41648. t['lessequal'] = 549;
  41649. t['ocircumflex'] = 500;
  41650. t['ntilde'] = 500;
  41651. t['Uhungarumlaut'] = 722;
  41652. t['Eacute'] = 611;
  41653. t['emacron'] = 444;
  41654. t['gbreve'] = 500;
  41655. t['onequarter'] = 750;
  41656. t['Scaron'] = 556;
  41657. t['Scommaaccent'] = 556;
  41658. t['Ohungarumlaut'] = 722;
  41659. t['degree'] = 400;
  41660. t['ograve'] = 500;
  41661. t['Ccaron'] = 667;
  41662. t['ugrave'] = 500;
  41663. t['radical'] = 453;
  41664. t['Dcaron'] = 722;
  41665. t['rcommaaccent'] = 333;
  41666. t['Ntilde'] = 722;
  41667. t['otilde'] = 500;
  41668. t['Rcommaaccent'] = 667;
  41669. t['Lcommaaccent'] = 611;
  41670. t['Atilde'] = 722;
  41671. t['Aogonek'] = 722;
  41672. t['Aring'] = 722;
  41673. t['Otilde'] = 722;
  41674. t['zdotaccent'] = 444;
  41675. t['Ecaron'] = 611;
  41676. t['Iogonek'] = 333;
  41677. t['kcommaaccent'] = 500;
  41678. t['minus'] = 564;
  41679. t['Icircumflex'] = 333;
  41680. t['ncaron'] = 500;
  41681. t['tcommaaccent'] = 278;
  41682. t['logicalnot'] = 564;
  41683. t['odieresis'] = 500;
  41684. t['udieresis'] = 500;
  41685. t['notequal'] = 549;
  41686. t['gcommaaccent'] = 500;
  41687. t['eth'] = 500;
  41688. t['zcaron'] = 444;
  41689. t['ncommaaccent'] = 500;
  41690. t['onesuperior'] = 300;
  41691. t['imacron'] = 278;
  41692. t['Euro'] = 500;
  41693. });
  41694. t['Times-Bold'] = (0, _util.getLookupTableFactory)(function (t) {
  41695. t['space'] = 250;
  41696. t['exclam'] = 333;
  41697. t['quotedbl'] = 555;
  41698. t['numbersign'] = 500;
  41699. t['dollar'] = 500;
  41700. t['percent'] = 1000;
  41701. t['ampersand'] = 833;
  41702. t['quoteright'] = 333;
  41703. t['parenleft'] = 333;
  41704. t['parenright'] = 333;
  41705. t['asterisk'] = 500;
  41706. t['plus'] = 570;
  41707. t['comma'] = 250;
  41708. t['hyphen'] = 333;
  41709. t['period'] = 250;
  41710. t['slash'] = 278;
  41711. t['zero'] = 500;
  41712. t['one'] = 500;
  41713. t['two'] = 500;
  41714. t['three'] = 500;
  41715. t['four'] = 500;
  41716. t['five'] = 500;
  41717. t['six'] = 500;
  41718. t['seven'] = 500;
  41719. t['eight'] = 500;
  41720. t['nine'] = 500;
  41721. t['colon'] = 333;
  41722. t['semicolon'] = 333;
  41723. t['less'] = 570;
  41724. t['equal'] = 570;
  41725. t['greater'] = 570;
  41726. t['question'] = 500;
  41727. t['at'] = 930;
  41728. t['A'] = 722;
  41729. t['B'] = 667;
  41730. t['C'] = 722;
  41731. t['D'] = 722;
  41732. t['E'] = 667;
  41733. t['F'] = 611;
  41734. t['G'] = 778;
  41735. t['H'] = 778;
  41736. t['I'] = 389;
  41737. t['J'] = 500;
  41738. t['K'] = 778;
  41739. t['L'] = 667;
  41740. t['M'] = 944;
  41741. t['N'] = 722;
  41742. t['O'] = 778;
  41743. t['P'] = 611;
  41744. t['Q'] = 778;
  41745. t['R'] = 722;
  41746. t['S'] = 556;
  41747. t['T'] = 667;
  41748. t['U'] = 722;
  41749. t['V'] = 722;
  41750. t['W'] = 1000;
  41751. t['X'] = 722;
  41752. t['Y'] = 722;
  41753. t['Z'] = 667;
  41754. t['bracketleft'] = 333;
  41755. t['backslash'] = 278;
  41756. t['bracketright'] = 333;
  41757. t['asciicircum'] = 581;
  41758. t['underscore'] = 500;
  41759. t['quoteleft'] = 333;
  41760. t['a'] = 500;
  41761. t['b'] = 556;
  41762. t['c'] = 444;
  41763. t['d'] = 556;
  41764. t['e'] = 444;
  41765. t['f'] = 333;
  41766. t['g'] = 500;
  41767. t['h'] = 556;
  41768. t['i'] = 278;
  41769. t['j'] = 333;
  41770. t['k'] = 556;
  41771. t['l'] = 278;
  41772. t['m'] = 833;
  41773. t['n'] = 556;
  41774. t['o'] = 500;
  41775. t['p'] = 556;
  41776. t['q'] = 556;
  41777. t['r'] = 444;
  41778. t['s'] = 389;
  41779. t['t'] = 333;
  41780. t['u'] = 556;
  41781. t['v'] = 500;
  41782. t['w'] = 722;
  41783. t['x'] = 500;
  41784. t['y'] = 500;
  41785. t['z'] = 444;
  41786. t['braceleft'] = 394;
  41787. t['bar'] = 220;
  41788. t['braceright'] = 394;
  41789. t['asciitilde'] = 520;
  41790. t['exclamdown'] = 333;
  41791. t['cent'] = 500;
  41792. t['sterling'] = 500;
  41793. t['fraction'] = 167;
  41794. t['yen'] = 500;
  41795. t['florin'] = 500;
  41796. t['section'] = 500;
  41797. t['currency'] = 500;
  41798. t['quotesingle'] = 278;
  41799. t['quotedblleft'] = 500;
  41800. t['guillemotleft'] = 500;
  41801. t['guilsinglleft'] = 333;
  41802. t['guilsinglright'] = 333;
  41803. t['fi'] = 556;
  41804. t['fl'] = 556;
  41805. t['endash'] = 500;
  41806. t['dagger'] = 500;
  41807. t['daggerdbl'] = 500;
  41808. t['periodcentered'] = 250;
  41809. t['paragraph'] = 540;
  41810. t['bullet'] = 350;
  41811. t['quotesinglbase'] = 333;
  41812. t['quotedblbase'] = 500;
  41813. t['quotedblright'] = 500;
  41814. t['guillemotright'] = 500;
  41815. t['ellipsis'] = 1000;
  41816. t['perthousand'] = 1000;
  41817. t['questiondown'] = 500;
  41818. t['grave'] = 333;
  41819. t['acute'] = 333;
  41820. t['circumflex'] = 333;
  41821. t['tilde'] = 333;
  41822. t['macron'] = 333;
  41823. t['breve'] = 333;
  41824. t['dotaccent'] = 333;
  41825. t['dieresis'] = 333;
  41826. t['ring'] = 333;
  41827. t['cedilla'] = 333;
  41828. t['hungarumlaut'] = 333;
  41829. t['ogonek'] = 333;
  41830. t['caron'] = 333;
  41831. t['emdash'] = 1000;
  41832. t['AE'] = 1000;
  41833. t['ordfeminine'] = 300;
  41834. t['Lslash'] = 667;
  41835. t['Oslash'] = 778;
  41836. t['OE'] = 1000;
  41837. t['ordmasculine'] = 330;
  41838. t['ae'] = 722;
  41839. t['dotlessi'] = 278;
  41840. t['lslash'] = 278;
  41841. t['oslash'] = 500;
  41842. t['oe'] = 722;
  41843. t['germandbls'] = 556;
  41844. t['Idieresis'] = 389;
  41845. t['eacute'] = 444;
  41846. t['abreve'] = 500;
  41847. t['uhungarumlaut'] = 556;
  41848. t['ecaron'] = 444;
  41849. t['Ydieresis'] = 722;
  41850. t['divide'] = 570;
  41851. t['Yacute'] = 722;
  41852. t['Acircumflex'] = 722;
  41853. t['aacute'] = 500;
  41854. t['Ucircumflex'] = 722;
  41855. t['yacute'] = 500;
  41856. t['scommaaccent'] = 389;
  41857. t['ecircumflex'] = 444;
  41858. t['Uring'] = 722;
  41859. t['Udieresis'] = 722;
  41860. t['aogonek'] = 500;
  41861. t['Uacute'] = 722;
  41862. t['uogonek'] = 556;
  41863. t['Edieresis'] = 667;
  41864. t['Dcroat'] = 722;
  41865. t['commaaccent'] = 250;
  41866. t['copyright'] = 747;
  41867. t['Emacron'] = 667;
  41868. t['ccaron'] = 444;
  41869. t['aring'] = 500;
  41870. t['Ncommaaccent'] = 722;
  41871. t['lacute'] = 278;
  41872. t['agrave'] = 500;
  41873. t['Tcommaaccent'] = 667;
  41874. t['Cacute'] = 722;
  41875. t['atilde'] = 500;
  41876. t['Edotaccent'] = 667;
  41877. t['scaron'] = 389;
  41878. t['scedilla'] = 389;
  41879. t['iacute'] = 278;
  41880. t['lozenge'] = 494;
  41881. t['Rcaron'] = 722;
  41882. t['Gcommaaccent'] = 778;
  41883. t['ucircumflex'] = 556;
  41884. t['acircumflex'] = 500;
  41885. t['Amacron'] = 722;
  41886. t['rcaron'] = 444;
  41887. t['ccedilla'] = 444;
  41888. t['Zdotaccent'] = 667;
  41889. t['Thorn'] = 611;
  41890. t['Omacron'] = 778;
  41891. t['Racute'] = 722;
  41892. t['Sacute'] = 556;
  41893. t['dcaron'] = 672;
  41894. t['Umacron'] = 722;
  41895. t['uring'] = 556;
  41896. t['threesuperior'] = 300;
  41897. t['Ograve'] = 778;
  41898. t['Agrave'] = 722;
  41899. t['Abreve'] = 722;
  41900. t['multiply'] = 570;
  41901. t['uacute'] = 556;
  41902. t['Tcaron'] = 667;
  41903. t['partialdiff'] = 494;
  41904. t['ydieresis'] = 500;
  41905. t['Nacute'] = 722;
  41906. t['icircumflex'] = 278;
  41907. t['Ecircumflex'] = 667;
  41908. t['adieresis'] = 500;
  41909. t['edieresis'] = 444;
  41910. t['cacute'] = 444;
  41911. t['nacute'] = 556;
  41912. t['umacron'] = 556;
  41913. t['Ncaron'] = 722;
  41914. t['Iacute'] = 389;
  41915. t['plusminus'] = 570;
  41916. t['brokenbar'] = 220;
  41917. t['registered'] = 747;
  41918. t['Gbreve'] = 778;
  41919. t['Idotaccent'] = 389;
  41920. t['summation'] = 600;
  41921. t['Egrave'] = 667;
  41922. t['racute'] = 444;
  41923. t['omacron'] = 500;
  41924. t['Zacute'] = 667;
  41925. t['Zcaron'] = 667;
  41926. t['greaterequal'] = 549;
  41927. t['Eth'] = 722;
  41928. t['Ccedilla'] = 722;
  41929. t['lcommaaccent'] = 278;
  41930. t['tcaron'] = 416;
  41931. t['eogonek'] = 444;
  41932. t['Uogonek'] = 722;
  41933. t['Aacute'] = 722;
  41934. t['Adieresis'] = 722;
  41935. t['egrave'] = 444;
  41936. t['zacute'] = 444;
  41937. t['iogonek'] = 278;
  41938. t['Oacute'] = 778;
  41939. t['oacute'] = 500;
  41940. t['amacron'] = 500;
  41941. t['sacute'] = 389;
  41942. t['idieresis'] = 278;
  41943. t['Ocircumflex'] = 778;
  41944. t['Ugrave'] = 722;
  41945. t['Delta'] = 612;
  41946. t['thorn'] = 556;
  41947. t['twosuperior'] = 300;
  41948. t['Odieresis'] = 778;
  41949. t['mu'] = 556;
  41950. t['igrave'] = 278;
  41951. t['ohungarumlaut'] = 500;
  41952. t['Eogonek'] = 667;
  41953. t['dcroat'] = 556;
  41954. t['threequarters'] = 750;
  41955. t['Scedilla'] = 556;
  41956. t['lcaron'] = 394;
  41957. t['Kcommaaccent'] = 778;
  41958. t['Lacute'] = 667;
  41959. t['trademark'] = 1000;
  41960. t['edotaccent'] = 444;
  41961. t['Igrave'] = 389;
  41962. t['Imacron'] = 389;
  41963. t['Lcaron'] = 667;
  41964. t['onehalf'] = 750;
  41965. t['lessequal'] = 549;
  41966. t['ocircumflex'] = 500;
  41967. t['ntilde'] = 556;
  41968. t['Uhungarumlaut'] = 722;
  41969. t['Eacute'] = 667;
  41970. t['emacron'] = 444;
  41971. t['gbreve'] = 500;
  41972. t['onequarter'] = 750;
  41973. t['Scaron'] = 556;
  41974. t['Scommaaccent'] = 556;
  41975. t['Ohungarumlaut'] = 778;
  41976. t['degree'] = 400;
  41977. t['ograve'] = 500;
  41978. t['Ccaron'] = 722;
  41979. t['ugrave'] = 556;
  41980. t['radical'] = 549;
  41981. t['Dcaron'] = 722;
  41982. t['rcommaaccent'] = 444;
  41983. t['Ntilde'] = 722;
  41984. t['otilde'] = 500;
  41985. t['Rcommaaccent'] = 722;
  41986. t['Lcommaaccent'] = 667;
  41987. t['Atilde'] = 722;
  41988. t['Aogonek'] = 722;
  41989. t['Aring'] = 722;
  41990. t['Otilde'] = 778;
  41991. t['zdotaccent'] = 444;
  41992. t['Ecaron'] = 667;
  41993. t['Iogonek'] = 389;
  41994. t['kcommaaccent'] = 556;
  41995. t['minus'] = 570;
  41996. t['Icircumflex'] = 389;
  41997. t['ncaron'] = 556;
  41998. t['tcommaaccent'] = 333;
  41999. t['logicalnot'] = 570;
  42000. t['odieresis'] = 500;
  42001. t['udieresis'] = 556;
  42002. t['notequal'] = 549;
  42003. t['gcommaaccent'] = 500;
  42004. t['eth'] = 500;
  42005. t['zcaron'] = 444;
  42006. t['ncommaaccent'] = 556;
  42007. t['onesuperior'] = 300;
  42008. t['imacron'] = 278;
  42009. t['Euro'] = 500;
  42010. });
  42011. t['Times-BoldItalic'] = (0, _util.getLookupTableFactory)(function (t) {
  42012. t['space'] = 250;
  42013. t['exclam'] = 389;
  42014. t['quotedbl'] = 555;
  42015. t['numbersign'] = 500;
  42016. t['dollar'] = 500;
  42017. t['percent'] = 833;
  42018. t['ampersand'] = 778;
  42019. t['quoteright'] = 333;
  42020. t['parenleft'] = 333;
  42021. t['parenright'] = 333;
  42022. t['asterisk'] = 500;
  42023. t['plus'] = 570;
  42024. t['comma'] = 250;
  42025. t['hyphen'] = 333;
  42026. t['period'] = 250;
  42027. t['slash'] = 278;
  42028. t['zero'] = 500;
  42029. t['one'] = 500;
  42030. t['two'] = 500;
  42031. t['three'] = 500;
  42032. t['four'] = 500;
  42033. t['five'] = 500;
  42034. t['six'] = 500;
  42035. t['seven'] = 500;
  42036. t['eight'] = 500;
  42037. t['nine'] = 500;
  42038. t['colon'] = 333;
  42039. t['semicolon'] = 333;
  42040. t['less'] = 570;
  42041. t['equal'] = 570;
  42042. t['greater'] = 570;
  42043. t['question'] = 500;
  42044. t['at'] = 832;
  42045. t['A'] = 667;
  42046. t['B'] = 667;
  42047. t['C'] = 667;
  42048. t['D'] = 722;
  42049. t['E'] = 667;
  42050. t['F'] = 667;
  42051. t['G'] = 722;
  42052. t['H'] = 778;
  42053. t['I'] = 389;
  42054. t['J'] = 500;
  42055. t['K'] = 667;
  42056. t['L'] = 611;
  42057. t['M'] = 889;
  42058. t['N'] = 722;
  42059. t['O'] = 722;
  42060. t['P'] = 611;
  42061. t['Q'] = 722;
  42062. t['R'] = 667;
  42063. t['S'] = 556;
  42064. t['T'] = 611;
  42065. t['U'] = 722;
  42066. t['V'] = 667;
  42067. t['W'] = 889;
  42068. t['X'] = 667;
  42069. t['Y'] = 611;
  42070. t['Z'] = 611;
  42071. t['bracketleft'] = 333;
  42072. t['backslash'] = 278;
  42073. t['bracketright'] = 333;
  42074. t['asciicircum'] = 570;
  42075. t['underscore'] = 500;
  42076. t['quoteleft'] = 333;
  42077. t['a'] = 500;
  42078. t['b'] = 500;
  42079. t['c'] = 444;
  42080. t['d'] = 500;
  42081. t['e'] = 444;
  42082. t['f'] = 333;
  42083. t['g'] = 500;
  42084. t['h'] = 556;
  42085. t['i'] = 278;
  42086. t['j'] = 278;
  42087. t['k'] = 500;
  42088. t['l'] = 278;
  42089. t['m'] = 778;
  42090. t['n'] = 556;
  42091. t['o'] = 500;
  42092. t['p'] = 500;
  42093. t['q'] = 500;
  42094. t['r'] = 389;
  42095. t['s'] = 389;
  42096. t['t'] = 278;
  42097. t['u'] = 556;
  42098. t['v'] = 444;
  42099. t['w'] = 667;
  42100. t['x'] = 500;
  42101. t['y'] = 444;
  42102. t['z'] = 389;
  42103. t['braceleft'] = 348;
  42104. t['bar'] = 220;
  42105. t['braceright'] = 348;
  42106. t['asciitilde'] = 570;
  42107. t['exclamdown'] = 389;
  42108. t['cent'] = 500;
  42109. t['sterling'] = 500;
  42110. t['fraction'] = 167;
  42111. t['yen'] = 500;
  42112. t['florin'] = 500;
  42113. t['section'] = 500;
  42114. t['currency'] = 500;
  42115. t['quotesingle'] = 278;
  42116. t['quotedblleft'] = 500;
  42117. t['guillemotleft'] = 500;
  42118. t['guilsinglleft'] = 333;
  42119. t['guilsinglright'] = 333;
  42120. t['fi'] = 556;
  42121. t['fl'] = 556;
  42122. t['endash'] = 500;
  42123. t['dagger'] = 500;
  42124. t['daggerdbl'] = 500;
  42125. t['periodcentered'] = 250;
  42126. t['paragraph'] = 500;
  42127. t['bullet'] = 350;
  42128. t['quotesinglbase'] = 333;
  42129. t['quotedblbase'] = 500;
  42130. t['quotedblright'] = 500;
  42131. t['guillemotright'] = 500;
  42132. t['ellipsis'] = 1000;
  42133. t['perthousand'] = 1000;
  42134. t['questiondown'] = 500;
  42135. t['grave'] = 333;
  42136. t['acute'] = 333;
  42137. t['circumflex'] = 333;
  42138. t['tilde'] = 333;
  42139. t['macron'] = 333;
  42140. t['breve'] = 333;
  42141. t['dotaccent'] = 333;
  42142. t['dieresis'] = 333;
  42143. t['ring'] = 333;
  42144. t['cedilla'] = 333;
  42145. t['hungarumlaut'] = 333;
  42146. t['ogonek'] = 333;
  42147. t['caron'] = 333;
  42148. t['emdash'] = 1000;
  42149. t['AE'] = 944;
  42150. t['ordfeminine'] = 266;
  42151. t['Lslash'] = 611;
  42152. t['Oslash'] = 722;
  42153. t['OE'] = 944;
  42154. t['ordmasculine'] = 300;
  42155. t['ae'] = 722;
  42156. t['dotlessi'] = 278;
  42157. t['lslash'] = 278;
  42158. t['oslash'] = 500;
  42159. t['oe'] = 722;
  42160. t['germandbls'] = 500;
  42161. t['Idieresis'] = 389;
  42162. t['eacute'] = 444;
  42163. t['abreve'] = 500;
  42164. t['uhungarumlaut'] = 556;
  42165. t['ecaron'] = 444;
  42166. t['Ydieresis'] = 611;
  42167. t['divide'] = 570;
  42168. t['Yacute'] = 611;
  42169. t['Acircumflex'] = 667;
  42170. t['aacute'] = 500;
  42171. t['Ucircumflex'] = 722;
  42172. t['yacute'] = 444;
  42173. t['scommaaccent'] = 389;
  42174. t['ecircumflex'] = 444;
  42175. t['Uring'] = 722;
  42176. t['Udieresis'] = 722;
  42177. t['aogonek'] = 500;
  42178. t['Uacute'] = 722;
  42179. t['uogonek'] = 556;
  42180. t['Edieresis'] = 667;
  42181. t['Dcroat'] = 722;
  42182. t['commaaccent'] = 250;
  42183. t['copyright'] = 747;
  42184. t['Emacron'] = 667;
  42185. t['ccaron'] = 444;
  42186. t['aring'] = 500;
  42187. t['Ncommaaccent'] = 722;
  42188. t['lacute'] = 278;
  42189. t['agrave'] = 500;
  42190. t['Tcommaaccent'] = 611;
  42191. t['Cacute'] = 667;
  42192. t['atilde'] = 500;
  42193. t['Edotaccent'] = 667;
  42194. t['scaron'] = 389;
  42195. t['scedilla'] = 389;
  42196. t['iacute'] = 278;
  42197. t['lozenge'] = 494;
  42198. t['Rcaron'] = 667;
  42199. t['Gcommaaccent'] = 722;
  42200. t['ucircumflex'] = 556;
  42201. t['acircumflex'] = 500;
  42202. t['Amacron'] = 667;
  42203. t['rcaron'] = 389;
  42204. t['ccedilla'] = 444;
  42205. t['Zdotaccent'] = 611;
  42206. t['Thorn'] = 611;
  42207. t['Omacron'] = 722;
  42208. t['Racute'] = 667;
  42209. t['Sacute'] = 556;
  42210. t['dcaron'] = 608;
  42211. t['Umacron'] = 722;
  42212. t['uring'] = 556;
  42213. t['threesuperior'] = 300;
  42214. t['Ograve'] = 722;
  42215. t['Agrave'] = 667;
  42216. t['Abreve'] = 667;
  42217. t['multiply'] = 570;
  42218. t['uacute'] = 556;
  42219. t['Tcaron'] = 611;
  42220. t['partialdiff'] = 494;
  42221. t['ydieresis'] = 444;
  42222. t['Nacute'] = 722;
  42223. t['icircumflex'] = 278;
  42224. t['Ecircumflex'] = 667;
  42225. t['adieresis'] = 500;
  42226. t['edieresis'] = 444;
  42227. t['cacute'] = 444;
  42228. t['nacute'] = 556;
  42229. t['umacron'] = 556;
  42230. t['Ncaron'] = 722;
  42231. t['Iacute'] = 389;
  42232. t['plusminus'] = 570;
  42233. t['brokenbar'] = 220;
  42234. t['registered'] = 747;
  42235. t['Gbreve'] = 722;
  42236. t['Idotaccent'] = 389;
  42237. t['summation'] = 600;
  42238. t['Egrave'] = 667;
  42239. t['racute'] = 389;
  42240. t['omacron'] = 500;
  42241. t['Zacute'] = 611;
  42242. t['Zcaron'] = 611;
  42243. t['greaterequal'] = 549;
  42244. t['Eth'] = 722;
  42245. t['Ccedilla'] = 667;
  42246. t['lcommaaccent'] = 278;
  42247. t['tcaron'] = 366;
  42248. t['eogonek'] = 444;
  42249. t['Uogonek'] = 722;
  42250. t['Aacute'] = 667;
  42251. t['Adieresis'] = 667;
  42252. t['egrave'] = 444;
  42253. t['zacute'] = 389;
  42254. t['iogonek'] = 278;
  42255. t['Oacute'] = 722;
  42256. t['oacute'] = 500;
  42257. t['amacron'] = 500;
  42258. t['sacute'] = 389;
  42259. t['idieresis'] = 278;
  42260. t['Ocircumflex'] = 722;
  42261. t['Ugrave'] = 722;
  42262. t['Delta'] = 612;
  42263. t['thorn'] = 500;
  42264. t['twosuperior'] = 300;
  42265. t['Odieresis'] = 722;
  42266. t['mu'] = 576;
  42267. t['igrave'] = 278;
  42268. t['ohungarumlaut'] = 500;
  42269. t['Eogonek'] = 667;
  42270. t['dcroat'] = 500;
  42271. t['threequarters'] = 750;
  42272. t['Scedilla'] = 556;
  42273. t['lcaron'] = 382;
  42274. t['Kcommaaccent'] = 667;
  42275. t['Lacute'] = 611;
  42276. t['trademark'] = 1000;
  42277. t['edotaccent'] = 444;
  42278. t['Igrave'] = 389;
  42279. t['Imacron'] = 389;
  42280. t['Lcaron'] = 611;
  42281. t['onehalf'] = 750;
  42282. t['lessequal'] = 549;
  42283. t['ocircumflex'] = 500;
  42284. t['ntilde'] = 556;
  42285. t['Uhungarumlaut'] = 722;
  42286. t['Eacute'] = 667;
  42287. t['emacron'] = 444;
  42288. t['gbreve'] = 500;
  42289. t['onequarter'] = 750;
  42290. t['Scaron'] = 556;
  42291. t['Scommaaccent'] = 556;
  42292. t['Ohungarumlaut'] = 722;
  42293. t['degree'] = 400;
  42294. t['ograve'] = 500;
  42295. t['Ccaron'] = 667;
  42296. t['ugrave'] = 556;
  42297. t['radical'] = 549;
  42298. t['Dcaron'] = 722;
  42299. t['rcommaaccent'] = 389;
  42300. t['Ntilde'] = 722;
  42301. t['otilde'] = 500;
  42302. t['Rcommaaccent'] = 667;
  42303. t['Lcommaaccent'] = 611;
  42304. t['Atilde'] = 667;
  42305. t['Aogonek'] = 667;
  42306. t['Aring'] = 667;
  42307. t['Otilde'] = 722;
  42308. t['zdotaccent'] = 389;
  42309. t['Ecaron'] = 667;
  42310. t['Iogonek'] = 389;
  42311. t['kcommaaccent'] = 500;
  42312. t['minus'] = 606;
  42313. t['Icircumflex'] = 389;
  42314. t['ncaron'] = 556;
  42315. t['tcommaaccent'] = 278;
  42316. t['logicalnot'] = 606;
  42317. t['odieresis'] = 500;
  42318. t['udieresis'] = 556;
  42319. t['notequal'] = 549;
  42320. t['gcommaaccent'] = 500;
  42321. t['eth'] = 500;
  42322. t['zcaron'] = 389;
  42323. t['ncommaaccent'] = 556;
  42324. t['onesuperior'] = 300;
  42325. t['imacron'] = 278;
  42326. t['Euro'] = 500;
  42327. });
  42328. t['Times-Italic'] = (0, _util.getLookupTableFactory)(function (t) {
  42329. t['space'] = 250;
  42330. t['exclam'] = 333;
  42331. t['quotedbl'] = 420;
  42332. t['numbersign'] = 500;
  42333. t['dollar'] = 500;
  42334. t['percent'] = 833;
  42335. t['ampersand'] = 778;
  42336. t['quoteright'] = 333;
  42337. t['parenleft'] = 333;
  42338. t['parenright'] = 333;
  42339. t['asterisk'] = 500;
  42340. t['plus'] = 675;
  42341. t['comma'] = 250;
  42342. t['hyphen'] = 333;
  42343. t['period'] = 250;
  42344. t['slash'] = 278;
  42345. t['zero'] = 500;
  42346. t['one'] = 500;
  42347. t['two'] = 500;
  42348. t['three'] = 500;
  42349. t['four'] = 500;
  42350. t['five'] = 500;
  42351. t['six'] = 500;
  42352. t['seven'] = 500;
  42353. t['eight'] = 500;
  42354. t['nine'] = 500;
  42355. t['colon'] = 333;
  42356. t['semicolon'] = 333;
  42357. t['less'] = 675;
  42358. t['equal'] = 675;
  42359. t['greater'] = 675;
  42360. t['question'] = 500;
  42361. t['at'] = 920;
  42362. t['A'] = 611;
  42363. t['B'] = 611;
  42364. t['C'] = 667;
  42365. t['D'] = 722;
  42366. t['E'] = 611;
  42367. t['F'] = 611;
  42368. t['G'] = 722;
  42369. t['H'] = 722;
  42370. t['I'] = 333;
  42371. t['J'] = 444;
  42372. t['K'] = 667;
  42373. t['L'] = 556;
  42374. t['M'] = 833;
  42375. t['N'] = 667;
  42376. t['O'] = 722;
  42377. t['P'] = 611;
  42378. t['Q'] = 722;
  42379. t['R'] = 611;
  42380. t['S'] = 500;
  42381. t['T'] = 556;
  42382. t['U'] = 722;
  42383. t['V'] = 611;
  42384. t['W'] = 833;
  42385. t['X'] = 611;
  42386. t['Y'] = 556;
  42387. t['Z'] = 556;
  42388. t['bracketleft'] = 389;
  42389. t['backslash'] = 278;
  42390. t['bracketright'] = 389;
  42391. t['asciicircum'] = 422;
  42392. t['underscore'] = 500;
  42393. t['quoteleft'] = 333;
  42394. t['a'] = 500;
  42395. t['b'] = 500;
  42396. t['c'] = 444;
  42397. t['d'] = 500;
  42398. t['e'] = 444;
  42399. t['f'] = 278;
  42400. t['g'] = 500;
  42401. t['h'] = 500;
  42402. t['i'] = 278;
  42403. t['j'] = 278;
  42404. t['k'] = 444;
  42405. t['l'] = 278;
  42406. t['m'] = 722;
  42407. t['n'] = 500;
  42408. t['o'] = 500;
  42409. t['p'] = 500;
  42410. t['q'] = 500;
  42411. t['r'] = 389;
  42412. t['s'] = 389;
  42413. t['t'] = 278;
  42414. t['u'] = 500;
  42415. t['v'] = 444;
  42416. t['w'] = 667;
  42417. t['x'] = 444;
  42418. t['y'] = 444;
  42419. t['z'] = 389;
  42420. t['braceleft'] = 400;
  42421. t['bar'] = 275;
  42422. t['braceright'] = 400;
  42423. t['asciitilde'] = 541;
  42424. t['exclamdown'] = 389;
  42425. t['cent'] = 500;
  42426. t['sterling'] = 500;
  42427. t['fraction'] = 167;
  42428. t['yen'] = 500;
  42429. t['florin'] = 500;
  42430. t['section'] = 500;
  42431. t['currency'] = 500;
  42432. t['quotesingle'] = 214;
  42433. t['quotedblleft'] = 556;
  42434. t['guillemotleft'] = 500;
  42435. t['guilsinglleft'] = 333;
  42436. t['guilsinglright'] = 333;
  42437. t['fi'] = 500;
  42438. t['fl'] = 500;
  42439. t['endash'] = 500;
  42440. t['dagger'] = 500;
  42441. t['daggerdbl'] = 500;
  42442. t['periodcentered'] = 250;
  42443. t['paragraph'] = 523;
  42444. t['bullet'] = 350;
  42445. t['quotesinglbase'] = 333;
  42446. t['quotedblbase'] = 556;
  42447. t['quotedblright'] = 556;
  42448. t['guillemotright'] = 500;
  42449. t['ellipsis'] = 889;
  42450. t['perthousand'] = 1000;
  42451. t['questiondown'] = 500;
  42452. t['grave'] = 333;
  42453. t['acute'] = 333;
  42454. t['circumflex'] = 333;
  42455. t['tilde'] = 333;
  42456. t['macron'] = 333;
  42457. t['breve'] = 333;
  42458. t['dotaccent'] = 333;
  42459. t['dieresis'] = 333;
  42460. t['ring'] = 333;
  42461. t['cedilla'] = 333;
  42462. t['hungarumlaut'] = 333;
  42463. t['ogonek'] = 333;
  42464. t['caron'] = 333;
  42465. t['emdash'] = 889;
  42466. t['AE'] = 889;
  42467. t['ordfeminine'] = 276;
  42468. t['Lslash'] = 556;
  42469. t['Oslash'] = 722;
  42470. t['OE'] = 944;
  42471. t['ordmasculine'] = 310;
  42472. t['ae'] = 667;
  42473. t['dotlessi'] = 278;
  42474. t['lslash'] = 278;
  42475. t['oslash'] = 500;
  42476. t['oe'] = 667;
  42477. t['germandbls'] = 500;
  42478. t['Idieresis'] = 333;
  42479. t['eacute'] = 444;
  42480. t['abreve'] = 500;
  42481. t['uhungarumlaut'] = 500;
  42482. t['ecaron'] = 444;
  42483. t['Ydieresis'] = 556;
  42484. t['divide'] = 675;
  42485. t['Yacute'] = 556;
  42486. t['Acircumflex'] = 611;
  42487. t['aacute'] = 500;
  42488. t['Ucircumflex'] = 722;
  42489. t['yacute'] = 444;
  42490. t['scommaaccent'] = 389;
  42491. t['ecircumflex'] = 444;
  42492. t['Uring'] = 722;
  42493. t['Udieresis'] = 722;
  42494. t['aogonek'] = 500;
  42495. t['Uacute'] = 722;
  42496. t['uogonek'] = 500;
  42497. t['Edieresis'] = 611;
  42498. t['Dcroat'] = 722;
  42499. t['commaaccent'] = 250;
  42500. t['copyright'] = 760;
  42501. t['Emacron'] = 611;
  42502. t['ccaron'] = 444;
  42503. t['aring'] = 500;
  42504. t['Ncommaaccent'] = 667;
  42505. t['lacute'] = 278;
  42506. t['agrave'] = 500;
  42507. t['Tcommaaccent'] = 556;
  42508. t['Cacute'] = 667;
  42509. t['atilde'] = 500;
  42510. t['Edotaccent'] = 611;
  42511. t['scaron'] = 389;
  42512. t['scedilla'] = 389;
  42513. t['iacute'] = 278;
  42514. t['lozenge'] = 471;
  42515. t['Rcaron'] = 611;
  42516. t['Gcommaaccent'] = 722;
  42517. t['ucircumflex'] = 500;
  42518. t['acircumflex'] = 500;
  42519. t['Amacron'] = 611;
  42520. t['rcaron'] = 389;
  42521. t['ccedilla'] = 444;
  42522. t['Zdotaccent'] = 556;
  42523. t['Thorn'] = 611;
  42524. t['Omacron'] = 722;
  42525. t['Racute'] = 611;
  42526. t['Sacute'] = 500;
  42527. t['dcaron'] = 544;
  42528. t['Umacron'] = 722;
  42529. t['uring'] = 500;
  42530. t['threesuperior'] = 300;
  42531. t['Ograve'] = 722;
  42532. t['Agrave'] = 611;
  42533. t['Abreve'] = 611;
  42534. t['multiply'] = 675;
  42535. t['uacute'] = 500;
  42536. t['Tcaron'] = 556;
  42537. t['partialdiff'] = 476;
  42538. t['ydieresis'] = 444;
  42539. t['Nacute'] = 667;
  42540. t['icircumflex'] = 278;
  42541. t['Ecircumflex'] = 611;
  42542. t['adieresis'] = 500;
  42543. t['edieresis'] = 444;
  42544. t['cacute'] = 444;
  42545. t['nacute'] = 500;
  42546. t['umacron'] = 500;
  42547. t['Ncaron'] = 667;
  42548. t['Iacute'] = 333;
  42549. t['plusminus'] = 675;
  42550. t['brokenbar'] = 275;
  42551. t['registered'] = 760;
  42552. t['Gbreve'] = 722;
  42553. t['Idotaccent'] = 333;
  42554. t['summation'] = 600;
  42555. t['Egrave'] = 611;
  42556. t['racute'] = 389;
  42557. t['omacron'] = 500;
  42558. t['Zacute'] = 556;
  42559. t['Zcaron'] = 556;
  42560. t['greaterequal'] = 549;
  42561. t['Eth'] = 722;
  42562. t['Ccedilla'] = 667;
  42563. t['lcommaaccent'] = 278;
  42564. t['tcaron'] = 300;
  42565. t['eogonek'] = 444;
  42566. t['Uogonek'] = 722;
  42567. t['Aacute'] = 611;
  42568. t['Adieresis'] = 611;
  42569. t['egrave'] = 444;
  42570. t['zacute'] = 389;
  42571. t['iogonek'] = 278;
  42572. t['Oacute'] = 722;
  42573. t['oacute'] = 500;
  42574. t['amacron'] = 500;
  42575. t['sacute'] = 389;
  42576. t['idieresis'] = 278;
  42577. t['Ocircumflex'] = 722;
  42578. t['Ugrave'] = 722;
  42579. t['Delta'] = 612;
  42580. t['thorn'] = 500;
  42581. t['twosuperior'] = 300;
  42582. t['Odieresis'] = 722;
  42583. t['mu'] = 500;
  42584. t['igrave'] = 278;
  42585. t['ohungarumlaut'] = 500;
  42586. t['Eogonek'] = 611;
  42587. t['dcroat'] = 500;
  42588. t['threequarters'] = 750;
  42589. t['Scedilla'] = 500;
  42590. t['lcaron'] = 300;
  42591. t['Kcommaaccent'] = 667;
  42592. t['Lacute'] = 556;
  42593. t['trademark'] = 980;
  42594. t['edotaccent'] = 444;
  42595. t['Igrave'] = 333;
  42596. t['Imacron'] = 333;
  42597. t['Lcaron'] = 611;
  42598. t['onehalf'] = 750;
  42599. t['lessequal'] = 549;
  42600. t['ocircumflex'] = 500;
  42601. t['ntilde'] = 500;
  42602. t['Uhungarumlaut'] = 722;
  42603. t['Eacute'] = 611;
  42604. t['emacron'] = 444;
  42605. t['gbreve'] = 500;
  42606. t['onequarter'] = 750;
  42607. t['Scaron'] = 500;
  42608. t['Scommaaccent'] = 500;
  42609. t['Ohungarumlaut'] = 722;
  42610. t['degree'] = 400;
  42611. t['ograve'] = 500;
  42612. t['Ccaron'] = 667;
  42613. t['ugrave'] = 500;
  42614. t['radical'] = 453;
  42615. t['Dcaron'] = 722;
  42616. t['rcommaaccent'] = 389;
  42617. t['Ntilde'] = 667;
  42618. t['otilde'] = 500;
  42619. t['Rcommaaccent'] = 611;
  42620. t['Lcommaaccent'] = 556;
  42621. t['Atilde'] = 611;
  42622. t['Aogonek'] = 611;
  42623. t['Aring'] = 611;
  42624. t['Otilde'] = 722;
  42625. t['zdotaccent'] = 389;
  42626. t['Ecaron'] = 611;
  42627. t['Iogonek'] = 333;
  42628. t['kcommaaccent'] = 444;
  42629. t['minus'] = 675;
  42630. t['Icircumflex'] = 333;
  42631. t['ncaron'] = 500;
  42632. t['tcommaaccent'] = 278;
  42633. t['logicalnot'] = 675;
  42634. t['odieresis'] = 500;
  42635. t['udieresis'] = 500;
  42636. t['notequal'] = 549;
  42637. t['gcommaaccent'] = 500;
  42638. t['eth'] = 500;
  42639. t['zcaron'] = 389;
  42640. t['ncommaaccent'] = 500;
  42641. t['onesuperior'] = 300;
  42642. t['imacron'] = 278;
  42643. t['Euro'] = 500;
  42644. });
  42645. t['ZapfDingbats'] = (0, _util.getLookupTableFactory)(function (t) {
  42646. t['space'] = 278;
  42647. t['a1'] = 974;
  42648. t['a2'] = 961;
  42649. t['a202'] = 974;
  42650. t['a3'] = 980;
  42651. t['a4'] = 719;
  42652. t['a5'] = 789;
  42653. t['a119'] = 790;
  42654. t['a118'] = 791;
  42655. t['a117'] = 690;
  42656. t['a11'] = 960;
  42657. t['a12'] = 939;
  42658. t['a13'] = 549;
  42659. t['a14'] = 855;
  42660. t['a15'] = 911;
  42661. t['a16'] = 933;
  42662. t['a105'] = 911;
  42663. t['a17'] = 945;
  42664. t['a18'] = 974;
  42665. t['a19'] = 755;
  42666. t['a20'] = 846;
  42667. t['a21'] = 762;
  42668. t['a22'] = 761;
  42669. t['a23'] = 571;
  42670. t['a24'] = 677;
  42671. t['a25'] = 763;
  42672. t['a26'] = 760;
  42673. t['a27'] = 759;
  42674. t['a28'] = 754;
  42675. t['a6'] = 494;
  42676. t['a7'] = 552;
  42677. t['a8'] = 537;
  42678. t['a9'] = 577;
  42679. t['a10'] = 692;
  42680. t['a29'] = 786;
  42681. t['a30'] = 788;
  42682. t['a31'] = 788;
  42683. t['a32'] = 790;
  42684. t['a33'] = 793;
  42685. t['a34'] = 794;
  42686. t['a35'] = 816;
  42687. t['a36'] = 823;
  42688. t['a37'] = 789;
  42689. t['a38'] = 841;
  42690. t['a39'] = 823;
  42691. t['a40'] = 833;
  42692. t['a41'] = 816;
  42693. t['a42'] = 831;
  42694. t['a43'] = 923;
  42695. t['a44'] = 744;
  42696. t['a45'] = 723;
  42697. t['a46'] = 749;
  42698. t['a47'] = 790;
  42699. t['a48'] = 792;
  42700. t['a49'] = 695;
  42701. t['a50'] = 776;
  42702. t['a51'] = 768;
  42703. t['a52'] = 792;
  42704. t['a53'] = 759;
  42705. t['a54'] = 707;
  42706. t['a55'] = 708;
  42707. t['a56'] = 682;
  42708. t['a57'] = 701;
  42709. t['a58'] = 826;
  42710. t['a59'] = 815;
  42711. t['a60'] = 789;
  42712. t['a61'] = 789;
  42713. t['a62'] = 707;
  42714. t['a63'] = 687;
  42715. t['a64'] = 696;
  42716. t['a65'] = 689;
  42717. t['a66'] = 786;
  42718. t['a67'] = 787;
  42719. t['a68'] = 713;
  42720. t['a69'] = 791;
  42721. t['a70'] = 785;
  42722. t['a71'] = 791;
  42723. t['a72'] = 873;
  42724. t['a73'] = 761;
  42725. t['a74'] = 762;
  42726. t['a203'] = 762;
  42727. t['a75'] = 759;
  42728. t['a204'] = 759;
  42729. t['a76'] = 892;
  42730. t['a77'] = 892;
  42731. t['a78'] = 788;
  42732. t['a79'] = 784;
  42733. t['a81'] = 438;
  42734. t['a82'] = 138;
  42735. t['a83'] = 277;
  42736. t['a84'] = 415;
  42737. t['a97'] = 392;
  42738. t['a98'] = 392;
  42739. t['a99'] = 668;
  42740. t['a100'] = 668;
  42741. t['a89'] = 390;
  42742. t['a90'] = 390;
  42743. t['a93'] = 317;
  42744. t['a94'] = 317;
  42745. t['a91'] = 276;
  42746. t['a92'] = 276;
  42747. t['a205'] = 509;
  42748. t['a85'] = 509;
  42749. t['a206'] = 410;
  42750. t['a86'] = 410;
  42751. t['a87'] = 234;
  42752. t['a88'] = 234;
  42753. t['a95'] = 334;
  42754. t['a96'] = 334;
  42755. t['a101'] = 732;
  42756. t['a102'] = 544;
  42757. t['a103'] = 544;
  42758. t['a104'] = 910;
  42759. t['a106'] = 667;
  42760. t['a107'] = 760;
  42761. t['a108'] = 760;
  42762. t['a112'] = 776;
  42763. t['a111'] = 595;
  42764. t['a110'] = 694;
  42765. t['a109'] = 626;
  42766. t['a120'] = 788;
  42767. t['a121'] = 788;
  42768. t['a122'] = 788;
  42769. t['a123'] = 788;
  42770. t['a124'] = 788;
  42771. t['a125'] = 788;
  42772. t['a126'] = 788;
  42773. t['a127'] = 788;
  42774. t['a128'] = 788;
  42775. t['a129'] = 788;
  42776. t['a130'] = 788;
  42777. t['a131'] = 788;
  42778. t['a132'] = 788;
  42779. t['a133'] = 788;
  42780. t['a134'] = 788;
  42781. t['a135'] = 788;
  42782. t['a136'] = 788;
  42783. t['a137'] = 788;
  42784. t['a138'] = 788;
  42785. t['a139'] = 788;
  42786. t['a140'] = 788;
  42787. t['a141'] = 788;
  42788. t['a142'] = 788;
  42789. t['a143'] = 788;
  42790. t['a144'] = 788;
  42791. t['a145'] = 788;
  42792. t['a146'] = 788;
  42793. t['a147'] = 788;
  42794. t['a148'] = 788;
  42795. t['a149'] = 788;
  42796. t['a150'] = 788;
  42797. t['a151'] = 788;
  42798. t['a152'] = 788;
  42799. t['a153'] = 788;
  42800. t['a154'] = 788;
  42801. t['a155'] = 788;
  42802. t['a156'] = 788;
  42803. t['a157'] = 788;
  42804. t['a158'] = 788;
  42805. t['a159'] = 788;
  42806. t['a160'] = 894;
  42807. t['a161'] = 838;
  42808. t['a163'] = 1016;
  42809. t['a164'] = 458;
  42810. t['a196'] = 748;
  42811. t['a165'] = 924;
  42812. t['a192'] = 748;
  42813. t['a166'] = 918;
  42814. t['a167'] = 927;
  42815. t['a168'] = 928;
  42816. t['a169'] = 928;
  42817. t['a170'] = 834;
  42818. t['a171'] = 873;
  42819. t['a172'] = 828;
  42820. t['a173'] = 924;
  42821. t['a162'] = 924;
  42822. t['a174'] = 917;
  42823. t['a175'] = 930;
  42824. t['a176'] = 931;
  42825. t['a177'] = 463;
  42826. t['a178'] = 883;
  42827. t['a179'] = 836;
  42828. t['a193'] = 836;
  42829. t['a180'] = 867;
  42830. t['a199'] = 867;
  42831. t['a181'] = 696;
  42832. t['a200'] = 696;
  42833. t['a182'] = 874;
  42834. t['a201'] = 874;
  42835. t['a183'] = 760;
  42836. t['a184'] = 946;
  42837. t['a197'] = 771;
  42838. t['a185'] = 865;
  42839. t['a194'] = 771;
  42840. t['a198'] = 888;
  42841. t['a186'] = 967;
  42842. t['a195'] = 888;
  42843. t['a187'] = 831;
  42844. t['a188'] = 873;
  42845. t['a189'] = 927;
  42846. t['a190'] = 970;
  42847. t['a191'] = 918;
  42848. });
  42849. });
  42850. exports.getMetrics = getMetrics;
  42851. /***/ }),
  42852. /* 139 */
  42853. /***/ (function(module, exports, __w_pdfjs_require__) {
  42854. "use strict";
  42855. Object.defineProperty(exports, "__esModule", {
  42856. value: true
  42857. });
  42858. exports.PostScriptParser = exports.PostScriptLexer = undefined;
  42859. var _util = __w_pdfjs_require__(0);
  42860. var _primitives = __w_pdfjs_require__(1);
  42861. var PostScriptParser = function PostScriptParserClosure() {
  42862. function PostScriptParser(lexer) {
  42863. this.lexer = lexer;
  42864. this.operators = [];
  42865. this.token = null;
  42866. this.prev = null;
  42867. }
  42868. PostScriptParser.prototype = {
  42869. nextToken: function PostScriptParser_nextToken() {
  42870. this.prev = this.token;
  42871. this.token = this.lexer.getToken();
  42872. },
  42873. accept: function PostScriptParser_accept(type) {
  42874. if (this.token.type === type) {
  42875. this.nextToken();
  42876. return true;
  42877. }
  42878. return false;
  42879. },
  42880. expect: function PostScriptParser_expect(type) {
  42881. if (this.accept(type)) {
  42882. return true;
  42883. }
  42884. throw new _util.FormatError('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  42885. },
  42886. parse: function PostScriptParser_parse() {
  42887. this.nextToken();
  42888. this.expect(PostScriptTokenTypes.LBRACE);
  42889. this.parseBlock();
  42890. this.expect(PostScriptTokenTypes.RBRACE);
  42891. return this.operators;
  42892. },
  42893. parseBlock: function PostScriptParser_parseBlock() {
  42894. while (true) {
  42895. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  42896. this.operators.push(this.prev.value);
  42897. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  42898. this.operators.push(this.prev.value);
  42899. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  42900. this.parseCondition();
  42901. } else {
  42902. return;
  42903. }
  42904. }
  42905. },
  42906. parseCondition: function PostScriptParser_parseCondition() {
  42907. var conditionLocation = this.operators.length;
  42908. this.operators.push(null, null);
  42909. this.parseBlock();
  42910. this.expect(PostScriptTokenTypes.RBRACE);
  42911. if (this.accept(PostScriptTokenTypes.IF)) {
  42912. this.operators[conditionLocation] = this.operators.length;
  42913. this.operators[conditionLocation + 1] = 'jz';
  42914. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  42915. var jumpLocation = this.operators.length;
  42916. this.operators.push(null, null);
  42917. var endOfTrue = this.operators.length;
  42918. this.parseBlock();
  42919. this.expect(PostScriptTokenTypes.RBRACE);
  42920. this.expect(PostScriptTokenTypes.IFELSE);
  42921. this.operators[jumpLocation] = this.operators.length;
  42922. this.operators[jumpLocation + 1] = 'j';
  42923. this.operators[conditionLocation] = endOfTrue;
  42924. this.operators[conditionLocation + 1] = 'jz';
  42925. } else {
  42926. throw new _util.FormatError('PS Function: error parsing conditional.');
  42927. }
  42928. }
  42929. };
  42930. return PostScriptParser;
  42931. }();
  42932. var PostScriptTokenTypes = {
  42933. LBRACE: 0,
  42934. RBRACE: 1,
  42935. NUMBER: 2,
  42936. OPERATOR: 3,
  42937. IF: 4,
  42938. IFELSE: 5
  42939. };
  42940. var PostScriptToken = function PostScriptTokenClosure() {
  42941. function PostScriptToken(type, value) {
  42942. this.type = type;
  42943. this.value = value;
  42944. }
  42945. var opCache = Object.create(null);
  42946. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  42947. var opValue = opCache[op];
  42948. if (opValue) {
  42949. return opValue;
  42950. }
  42951. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  42952. };
  42953. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  42954. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  42955. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  42956. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  42957. return PostScriptToken;
  42958. }();
  42959. var PostScriptLexer = function PostScriptLexerClosure() {
  42960. function PostScriptLexer(stream) {
  42961. this.stream = stream;
  42962. this.nextChar();
  42963. this.strBuf = [];
  42964. }
  42965. PostScriptLexer.prototype = {
  42966. nextChar: function PostScriptLexer_nextChar() {
  42967. return this.currentChar = this.stream.getByte();
  42968. },
  42969. getToken: function PostScriptLexer_getToken() {
  42970. var comment = false;
  42971. var ch = this.currentChar;
  42972. while (true) {
  42973. if (ch < 0) {
  42974. return _primitives.EOF;
  42975. }
  42976. if (comment) {
  42977. if (ch === 0x0A || ch === 0x0D) {
  42978. comment = false;
  42979. }
  42980. } else if (ch === 0x25) {
  42981. comment = true;
  42982. } else if (!(0, _util.isSpace)(ch)) {
  42983. break;
  42984. }
  42985. ch = this.nextChar();
  42986. }
  42987. switch (ch | 0) {
  42988. case 0x30:
  42989. case 0x31:
  42990. case 0x32:
  42991. case 0x33:
  42992. case 0x34:
  42993. case 0x35:
  42994. case 0x36:
  42995. case 0x37:
  42996. case 0x38:
  42997. case 0x39:
  42998. case 0x2B:
  42999. case 0x2D:
  43000. case 0x2E:
  43001. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43002. case 0x7B:
  43003. this.nextChar();
  43004. return PostScriptToken.LBRACE;
  43005. case 0x7D:
  43006. this.nextChar();
  43007. return PostScriptToken.RBRACE;
  43008. }
  43009. var strBuf = this.strBuf;
  43010. strBuf.length = 0;
  43011. strBuf[0] = String.fromCharCode(ch);
  43012. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43013. strBuf.push(String.fromCharCode(ch));
  43014. }
  43015. var str = strBuf.join('');
  43016. switch (str.toLowerCase()) {
  43017. case 'if':
  43018. return PostScriptToken.IF;
  43019. case 'ifelse':
  43020. return PostScriptToken.IFELSE;
  43021. default:
  43022. return PostScriptToken.getOperator(str);
  43023. }
  43024. },
  43025. getNumber: function PostScriptLexer_getNumber() {
  43026. var ch = this.currentChar;
  43027. var strBuf = this.strBuf;
  43028. strBuf.length = 0;
  43029. strBuf[0] = String.fromCharCode(ch);
  43030. while ((ch = this.nextChar()) >= 0) {
  43031. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43032. strBuf.push(String.fromCharCode(ch));
  43033. } else {
  43034. break;
  43035. }
  43036. }
  43037. var value = parseFloat(strBuf.join(''));
  43038. if (isNaN(value)) {
  43039. throw new _util.FormatError('Invalid floating point number: ' + value);
  43040. }
  43041. return value;
  43042. }
  43043. };
  43044. return PostScriptLexer;
  43045. }();
  43046. exports.PostScriptLexer = PostScriptLexer;
  43047. exports.PostScriptParser = PostScriptParser;
  43048. /***/ }),
  43049. /* 140 */
  43050. /***/ (function(module, exports, __w_pdfjs_require__) {
  43051. "use strict";
  43052. Object.defineProperty(exports, "__esModule", {
  43053. value: true
  43054. });
  43055. exports.MurmurHash3_64 = undefined;
  43056. var _util = __w_pdfjs_require__(0);
  43057. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  43058. var MASK_HIGH = 0xffff0000;
  43059. var MASK_LOW = 0xffff;
  43060. function MurmurHash3_64(seed) {
  43061. var SEED = 0xc3d2e1f0;
  43062. this.h1 = seed ? seed & 0xffffffff : SEED;
  43063. this.h2 = seed ? seed & 0xffffffff : SEED;
  43064. }
  43065. MurmurHash3_64.prototype = {
  43066. update: function MurmurHash3_64_update(input) {
  43067. var data = void 0,
  43068. length = void 0;
  43069. if ((0, _util.isString)(input)) {
  43070. data = new Uint8Array(input.length * 2);
  43071. length = 0;
  43072. for (var i = 0, ii = input.length; i < ii; i++) {
  43073. var code = input.charCodeAt(i);
  43074. if (code <= 0xff) {
  43075. data[length++] = code;
  43076. } else {
  43077. data[length++] = code >>> 8;
  43078. data[length++] = code & 0xff;
  43079. }
  43080. }
  43081. } else if ((0, _util.isArrayBuffer)(input)) {
  43082. data = input;
  43083. length = data.byteLength;
  43084. } else {
  43085. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  43086. }
  43087. var blockCounts = length >> 2;
  43088. var tailLength = length - blockCounts * 4;
  43089. var dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
  43090. var k1 = 0;
  43091. var k2 = 0;
  43092. var h1 = this.h1;
  43093. var h2 = this.h2;
  43094. var C1 = 0xcc9e2d51;
  43095. var C2 = 0x1b873593;
  43096. var C1_LOW = C1 & MASK_LOW;
  43097. var C2_LOW = C2 & MASK_LOW;
  43098. for (var _i = 0; _i < blockCounts; _i++) {
  43099. if (_i & 1) {
  43100. k1 = dataUint32[_i];
  43101. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  43102. k1 = k1 << 15 | k1 >>> 17;
  43103. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  43104. h1 ^= k1;
  43105. h1 = h1 << 13 | h1 >>> 19;
  43106. h1 = h1 * 5 + 0xe6546b64;
  43107. } else {
  43108. k2 = dataUint32[_i];
  43109. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  43110. k2 = k2 << 15 | k2 >>> 17;
  43111. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  43112. h2 ^= k2;
  43113. h2 = h2 << 13 | h2 >>> 19;
  43114. h2 = h2 * 5 + 0xe6546b64;
  43115. }
  43116. }
  43117. k1 = 0;
  43118. switch (tailLength) {
  43119. case 3:
  43120. k1 ^= data[blockCounts * 4 + 2] << 16;
  43121. case 2:
  43122. k1 ^= data[blockCounts * 4 + 1] << 8;
  43123. case 1:
  43124. k1 ^= data[blockCounts * 4];
  43125. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  43126. k1 = k1 << 15 | k1 >>> 17;
  43127. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  43128. if (blockCounts & 1) {
  43129. h1 ^= k1;
  43130. } else {
  43131. h2 ^= k1;
  43132. }
  43133. }
  43134. this.h1 = h1;
  43135. this.h2 = h2;
  43136. return this;
  43137. },
  43138. hexdigest: function MurmurHash3_64_hexdigest() {
  43139. var h1 = this.h1;
  43140. var h2 = this.h2;
  43141. h1 ^= h2 >>> 1;
  43142. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  43143. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  43144. h1 ^= h2 >>> 1;
  43145. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  43146. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  43147. h1 ^= h2 >>> 1;
  43148. for (var i = 0, arr = [h1, h2], str = ''; i < arr.length; i++) {
  43149. var hex = (arr[i] >>> 0).toString(16);
  43150. while (hex.length < 8) {
  43151. hex = '0' + hex;
  43152. }
  43153. str += hex;
  43154. }
  43155. return str;
  43156. }
  43157. };
  43158. return MurmurHash3_64;
  43159. }();
  43160. exports.MurmurHash3_64 = MurmurHash3_64;
  43161. /***/ }),
  43162. /* 141 */
  43163. /***/ (function(module, exports, __w_pdfjs_require__) {
  43164. "use strict";
  43165. Object.defineProperty(exports, "__esModule", {
  43166. value: true
  43167. });
  43168. exports.PDFImage = undefined;
  43169. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  43170. var _util = __w_pdfjs_require__(0);
  43171. var _stream = __w_pdfjs_require__(5);
  43172. var _primitives = __w_pdfjs_require__(1);
  43173. var _colorspace = __w_pdfjs_require__(20);
  43174. var _jpx = __w_pdfjs_require__(63);
  43175. var PDFImage = function PDFImageClosure() {
  43176. function handleImageData(image, nativeDecoder) {
  43177. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  43178. return nativeDecoder.decode(image);
  43179. }
  43180. return Promise.resolve(image);
  43181. }
  43182. function decodeAndClamp(value, addend, coefficient, max) {
  43183. value = addend + value * coefficient;
  43184. return value < 0 ? 0 : value > max ? max : value;
  43185. }
  43186. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  43187. var length = w2 * h2;
  43188. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  43189. var xRatio = w1 / w2;
  43190. var yRatio = h1 / h2;
  43191. var i,
  43192. j,
  43193. py,
  43194. newIndex = 0,
  43195. oldIndex;
  43196. var xScaled = new Uint16Array(w2);
  43197. var w1Scanline = w1;
  43198. for (i = 0; i < w2; i++) {
  43199. xScaled[i] = Math.floor(i * xRatio);
  43200. }
  43201. for (i = 0; i < h2; i++) {
  43202. py = Math.floor(i * yRatio) * w1Scanline;
  43203. for (j = 0; j < w2; j++) {
  43204. oldIndex = py + xScaled[j];
  43205. dest[newIndex++] = src[oldIndex];
  43206. }
  43207. }
  43208. return dest;
  43209. }
  43210. function PDFImage(_ref) {
  43211. var xref = _ref.xref,
  43212. res = _ref.res,
  43213. image = _ref.image,
  43214. _ref$smask = _ref.smask,
  43215. smask = _ref$smask === undefined ? null : _ref$smask,
  43216. _ref$mask = _ref.mask,
  43217. mask = _ref$mask === undefined ? null : _ref$mask,
  43218. _ref$isMask = _ref.isMask,
  43219. isMask = _ref$isMask === undefined ? false : _ref$isMask,
  43220. pdfFunctionFactory = _ref.pdfFunctionFactory;
  43221. this.image = image;
  43222. var dict = image.dict;
  43223. if (dict.has('Filter')) {
  43224. var filter = dict.get('Filter').name;
  43225. if (filter === 'JPXDecode') {
  43226. var jpxImage = new _jpx.JpxImage();
  43227. jpxImage.parseImageProperties(image.stream);
  43228. image.stream.reset();
  43229. image.bitsPerComponent = jpxImage.bitsPerComponent;
  43230. image.numComps = jpxImage.componentsCount;
  43231. } else if (filter === 'JBIG2Decode') {
  43232. image.bitsPerComponent = 1;
  43233. image.numComps = 1;
  43234. }
  43235. }
  43236. this.width = dict.get('Width', 'W');
  43237. this.height = dict.get('Height', 'H');
  43238. if (this.width < 1 || this.height < 1) {
  43239. throw new _util.FormatError('Invalid image width: ' + this.width + ' or ' + ('height: ' + this.height));
  43240. }
  43241. this.interpolate = dict.get('Interpolate', 'I') || false;
  43242. this.imageMask = dict.get('ImageMask', 'IM') || false;
  43243. this.matte = dict.get('Matte') || false;
  43244. var bitsPerComponent = image.bitsPerComponent;
  43245. if (!bitsPerComponent) {
  43246. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  43247. if (!bitsPerComponent) {
  43248. if (this.imageMask) {
  43249. bitsPerComponent = 1;
  43250. } else {
  43251. throw new _util.FormatError('Bits per component missing in image: ' + this.imageMask);
  43252. }
  43253. }
  43254. }
  43255. this.bpc = bitsPerComponent;
  43256. if (!this.imageMask) {
  43257. var colorSpace = dict.get('ColorSpace', 'CS');
  43258. if (!colorSpace) {
  43259. (0, _util.info)('JPX images (which do not require color spaces)');
  43260. switch (image.numComps) {
  43261. case 1:
  43262. colorSpace = _primitives.Name.get('DeviceGray');
  43263. break;
  43264. case 3:
  43265. colorSpace = _primitives.Name.get('DeviceRGB');
  43266. break;
  43267. case 4:
  43268. colorSpace = _primitives.Name.get('DeviceCMYK');
  43269. break;
  43270. default:
  43271. throw new Error('JPX images with ' + this.numComps + ' ' + 'color components not supported.');
  43272. }
  43273. }
  43274. this.colorSpace = _colorspace.ColorSpace.parse(colorSpace, xref, res, pdfFunctionFactory);
  43275. this.numComps = this.colorSpace.numComps;
  43276. }
  43277. this.decode = dict.getArray('Decode', 'D');
  43278. this.needsDecode = false;
  43279. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !_colorspace.ColorSpace.isDefaultDecode(this.decode, 1))) {
  43280. this.needsDecode = true;
  43281. var max = (1 << bitsPerComponent) - 1;
  43282. this.decodeCoefficients = [];
  43283. this.decodeAddends = [];
  43284. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  43285. var dmin = this.decode[i];
  43286. var dmax = this.decode[i + 1];
  43287. this.decodeCoefficients[j] = dmax - dmin;
  43288. this.decodeAddends[j] = max * dmin;
  43289. }
  43290. }
  43291. if (smask) {
  43292. this.smask = new PDFImage({
  43293. xref: xref,
  43294. res: res,
  43295. image: smask,
  43296. pdfFunctionFactory: pdfFunctionFactory
  43297. });
  43298. } else if (mask) {
  43299. if ((0, _primitives.isStream)(mask)) {
  43300. var maskDict = mask.dict,
  43301. imageMask = maskDict.get('ImageMask', 'IM');
  43302. if (!imageMask) {
  43303. (0, _util.warn)('Ignoring /Mask in image without /ImageMask.');
  43304. } else {
  43305. this.mask = new PDFImage({
  43306. xref: xref,
  43307. res: res,
  43308. image: mask,
  43309. isMask: true,
  43310. pdfFunctionFactory: pdfFunctionFactory
  43311. });
  43312. }
  43313. } else {
  43314. this.mask = mask;
  43315. }
  43316. }
  43317. }
  43318. PDFImage.buildImage = function (_ref2) {
  43319. var handler = _ref2.handler,
  43320. xref = _ref2.xref,
  43321. res = _ref2.res,
  43322. image = _ref2.image,
  43323. _ref2$nativeDecoder = _ref2.nativeDecoder,
  43324. nativeDecoder = _ref2$nativeDecoder === undefined ? null : _ref2$nativeDecoder,
  43325. pdfFunctionFactory = _ref2.pdfFunctionFactory;
  43326. var imagePromise = handleImageData(image, nativeDecoder);
  43327. var smaskPromise;
  43328. var maskPromise;
  43329. var smask = image.dict.get('SMask');
  43330. var mask = image.dict.get('Mask');
  43331. if (smask) {
  43332. smaskPromise = handleImageData(smask, nativeDecoder);
  43333. maskPromise = Promise.resolve(null);
  43334. } else {
  43335. smaskPromise = Promise.resolve(null);
  43336. if (mask) {
  43337. if ((0, _primitives.isStream)(mask)) {
  43338. maskPromise = handleImageData(mask, nativeDecoder);
  43339. } else if (Array.isArray(mask)) {
  43340. maskPromise = Promise.resolve(mask);
  43341. } else {
  43342. (0, _util.warn)('Unsupported mask format.');
  43343. maskPromise = Promise.resolve(null);
  43344. }
  43345. } else {
  43346. maskPromise = Promise.resolve(null);
  43347. }
  43348. }
  43349. return Promise.all([imagePromise, smaskPromise, maskPromise]).then(function (_ref3) {
  43350. var _ref4 = _slicedToArray(_ref3, 3),
  43351. imageData = _ref4[0],
  43352. smaskData = _ref4[1],
  43353. maskData = _ref4[2];
  43354. return new PDFImage({
  43355. xref: xref,
  43356. res: res,
  43357. image: imageData,
  43358. smask: smaskData,
  43359. mask: maskData,
  43360. pdfFunctionFactory: pdfFunctionFactory
  43361. });
  43362. });
  43363. };
  43364. PDFImage.createMask = function (_ref5) {
  43365. var imgArray = _ref5.imgArray,
  43366. width = _ref5.width,
  43367. height = _ref5.height,
  43368. imageIsFromDecodeStream = _ref5.imageIsFromDecodeStream,
  43369. inverseDecode = _ref5.inverseDecode;
  43370. var computedLength = (width + 7 >> 3) * height;
  43371. var actualLength = imgArray.byteLength;
  43372. var haveFullData = computedLength === actualLength;
  43373. var data, i;
  43374. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  43375. data = imgArray;
  43376. } else if (!inverseDecode) {
  43377. data = new Uint8Array(actualLength);
  43378. data.set(imgArray);
  43379. } else {
  43380. data = new Uint8Array(computedLength);
  43381. data.set(imgArray);
  43382. for (i = actualLength; i < computedLength; i++) {
  43383. data[i] = 0xff;
  43384. }
  43385. }
  43386. if (inverseDecode) {
  43387. for (i = 0; i < actualLength; i++) {
  43388. data[i] ^= 0xFF;
  43389. }
  43390. }
  43391. return {
  43392. data: data,
  43393. width: width,
  43394. height: height
  43395. };
  43396. };
  43397. PDFImage.prototype = {
  43398. get drawWidth() {
  43399. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  43400. },
  43401. get drawHeight() {
  43402. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  43403. },
  43404. decodeBuffer: function decodeBuffer(buffer) {
  43405. var bpc = this.bpc;
  43406. var numComps = this.numComps;
  43407. var decodeAddends = this.decodeAddends;
  43408. var decodeCoefficients = this.decodeCoefficients;
  43409. var max = (1 << bpc) - 1;
  43410. var i, ii;
  43411. if (bpc === 1) {
  43412. for (i = 0, ii = buffer.length; i < ii; i++) {
  43413. buffer[i] = +!buffer[i];
  43414. }
  43415. return;
  43416. }
  43417. var index = 0;
  43418. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  43419. for (var j = 0; j < numComps; j++) {
  43420. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  43421. index++;
  43422. }
  43423. }
  43424. },
  43425. getComponents: function getComponents(buffer) {
  43426. var bpc = this.bpc;
  43427. if (bpc === 8) {
  43428. return buffer;
  43429. }
  43430. var width = this.width;
  43431. var height = this.height;
  43432. var numComps = this.numComps;
  43433. var length = width * height * numComps;
  43434. var bufferPos = 0;
  43435. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  43436. var rowComps = width * numComps;
  43437. var max = (1 << bpc) - 1;
  43438. var i = 0,
  43439. ii,
  43440. buf;
  43441. if (bpc === 1) {
  43442. var mask, loop1End, loop2End;
  43443. for (var j = 0; j < height; j++) {
  43444. loop1End = i + (rowComps & ~7);
  43445. loop2End = i + rowComps;
  43446. while (i < loop1End) {
  43447. buf = buffer[bufferPos++];
  43448. output[i] = buf >> 7 & 1;
  43449. output[i + 1] = buf >> 6 & 1;
  43450. output[i + 2] = buf >> 5 & 1;
  43451. output[i + 3] = buf >> 4 & 1;
  43452. output[i + 4] = buf >> 3 & 1;
  43453. output[i + 5] = buf >> 2 & 1;
  43454. output[i + 6] = buf >> 1 & 1;
  43455. output[i + 7] = buf & 1;
  43456. i += 8;
  43457. }
  43458. if (i < loop2End) {
  43459. buf = buffer[bufferPos++];
  43460. mask = 128;
  43461. while (i < loop2End) {
  43462. output[i++] = +!!(buf & mask);
  43463. mask >>= 1;
  43464. }
  43465. }
  43466. }
  43467. } else {
  43468. var bits = 0;
  43469. buf = 0;
  43470. for (i = 0, ii = length; i < ii; ++i) {
  43471. if (i % rowComps === 0) {
  43472. buf = 0;
  43473. bits = 0;
  43474. }
  43475. while (bits < bpc) {
  43476. buf = buf << 8 | buffer[bufferPos++];
  43477. bits += 8;
  43478. }
  43479. var remainingBits = bits - bpc;
  43480. var value = buf >> remainingBits;
  43481. output[i] = value < 0 ? 0 : value > max ? max : value;
  43482. buf = buf & (1 << remainingBits) - 1;
  43483. bits = remainingBits;
  43484. }
  43485. }
  43486. return output;
  43487. },
  43488. fillOpacity: function fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  43489. var smask = this.smask;
  43490. var mask = this.mask;
  43491. var alphaBuf, sw, sh, i, ii, j;
  43492. if (smask) {
  43493. sw = smask.width;
  43494. sh = smask.height;
  43495. alphaBuf = new Uint8Array(sw * sh);
  43496. smask.fillGrayBuffer(alphaBuf);
  43497. if (sw !== width || sh !== height) {
  43498. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  43499. }
  43500. } else if (mask) {
  43501. if (mask instanceof PDFImage) {
  43502. sw = mask.width;
  43503. sh = mask.height;
  43504. alphaBuf = new Uint8Array(sw * sh);
  43505. mask.numComps = 1;
  43506. mask.fillGrayBuffer(alphaBuf);
  43507. for (i = 0, ii = sw * sh; i < ii; ++i) {
  43508. alphaBuf[i] = 255 - alphaBuf[i];
  43509. }
  43510. if (sw !== width || sh !== height) {
  43511. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  43512. }
  43513. } else if (Array.isArray(mask)) {
  43514. alphaBuf = new Uint8Array(width * height);
  43515. var numComps = this.numComps;
  43516. for (i = 0, ii = width * height; i < ii; ++i) {
  43517. var opacity = 0;
  43518. var imageOffset = i * numComps;
  43519. for (j = 0; j < numComps; ++j) {
  43520. var color = image[imageOffset + j];
  43521. var maskOffset = j * 2;
  43522. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  43523. opacity = 255;
  43524. break;
  43525. }
  43526. }
  43527. alphaBuf[i] = opacity;
  43528. }
  43529. } else {
  43530. throw new _util.FormatError('Unknown mask format.');
  43531. }
  43532. }
  43533. if (alphaBuf) {
  43534. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  43535. rgbaBuf[j] = alphaBuf[i];
  43536. }
  43537. } else {
  43538. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  43539. rgbaBuf[j] = 255;
  43540. }
  43541. }
  43542. },
  43543. undoPreblend: function undoPreblend(buffer, width, height) {
  43544. var matte = this.smask && this.smask.matte;
  43545. if (!matte) {
  43546. return;
  43547. }
  43548. var matteRgb = this.colorSpace.getRgb(matte, 0);
  43549. var matteR = matteRgb[0];
  43550. var matteG = matteRgb[1];
  43551. var matteB = matteRgb[2];
  43552. var length = width * height * 4;
  43553. var r, g, b;
  43554. for (var i = 0; i < length; i += 4) {
  43555. var alpha = buffer[i + 3];
  43556. if (alpha === 0) {
  43557. buffer[i] = 255;
  43558. buffer[i + 1] = 255;
  43559. buffer[i + 2] = 255;
  43560. continue;
  43561. }
  43562. var k = 255 / alpha;
  43563. r = (buffer[i] - matteR) * k + matteR;
  43564. g = (buffer[i + 1] - matteG) * k + matteG;
  43565. b = (buffer[i + 2] - matteB) * k + matteB;
  43566. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  43567. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  43568. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  43569. }
  43570. },
  43571. createImageData: function createImageData() {
  43572. var forceRGBA = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  43573. var drawWidth = this.drawWidth;
  43574. var drawHeight = this.drawHeight;
  43575. var imgData = {
  43576. width: drawWidth,
  43577. height: drawHeight
  43578. };
  43579. var numComps = this.numComps;
  43580. var originalWidth = this.width;
  43581. var originalHeight = this.height;
  43582. var bpc = this.bpc;
  43583. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  43584. var imgArray;
  43585. if (!forceRGBA) {
  43586. var kind;
  43587. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  43588. kind = _util.ImageKind.GRAYSCALE_1BPP;
  43589. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  43590. kind = _util.ImageKind.RGB_24BPP;
  43591. }
  43592. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  43593. imgData.kind = kind;
  43594. imgArray = this.getImageBytes(originalHeight * rowBytes);
  43595. if (this.image instanceof _stream.DecodeStream) {
  43596. imgData.data = imgArray;
  43597. } else {
  43598. var newArray = new Uint8Array(imgArray.length);
  43599. newArray.set(imgArray);
  43600. imgData.data = newArray;
  43601. }
  43602. if (this.needsDecode) {
  43603. (0, _util.assert)(kind === _util.ImageKind.GRAYSCALE_1BPP);
  43604. var buffer = imgData.data;
  43605. for (var i = 0, ii = buffer.length; i < ii; i++) {
  43606. buffer[i] ^= 0xff;
  43607. }
  43608. }
  43609. return imgData;
  43610. }
  43611. if (this.image instanceof _stream.JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  43612. imgData.kind = _util.ImageKind.RGB_24BPP;
  43613. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  43614. return imgData;
  43615. }
  43616. }
  43617. imgArray = this.getImageBytes(originalHeight * rowBytes);
  43618. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  43619. var comps = this.getComponents(imgArray);
  43620. var alpha01, maybeUndoPreblend;
  43621. if (!forceRGBA && !this.smask && !this.mask) {
  43622. imgData.kind = _util.ImageKind.RGB_24BPP;
  43623. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  43624. alpha01 = 0;
  43625. maybeUndoPreblend = false;
  43626. } else {
  43627. imgData.kind = _util.ImageKind.RGBA_32BPP;
  43628. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  43629. alpha01 = 1;
  43630. maybeUndoPreblend = true;
  43631. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  43632. }
  43633. if (this.needsDecode) {
  43634. this.decodeBuffer(comps);
  43635. }
  43636. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  43637. if (maybeUndoPreblend) {
  43638. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  43639. }
  43640. return imgData;
  43641. },
  43642. fillGrayBuffer: function fillGrayBuffer(buffer) {
  43643. var numComps = this.numComps;
  43644. if (numComps !== 1) {
  43645. throw new _util.FormatError('Reading gray scale from a color image: ' + numComps);
  43646. }
  43647. var width = this.width;
  43648. var height = this.height;
  43649. var bpc = this.bpc;
  43650. var rowBytes = width * numComps * bpc + 7 >> 3;
  43651. var imgArray = this.getImageBytes(height * rowBytes);
  43652. var comps = this.getComponents(imgArray);
  43653. var i, length;
  43654. if (bpc === 1) {
  43655. length = width * height;
  43656. if (this.needsDecode) {
  43657. for (i = 0; i < length; ++i) {
  43658. buffer[i] = comps[i] - 1 & 255;
  43659. }
  43660. } else {
  43661. for (i = 0; i < length; ++i) {
  43662. buffer[i] = -comps[i] & 255;
  43663. }
  43664. }
  43665. return;
  43666. }
  43667. if (this.needsDecode) {
  43668. this.decodeBuffer(comps);
  43669. }
  43670. length = width * height;
  43671. var scale = 255 / ((1 << bpc) - 1);
  43672. for (i = 0; i < length; ++i) {
  43673. buffer[i] = scale * comps[i] | 0;
  43674. }
  43675. },
  43676. getImageBytes: function getImageBytes(length, drawWidth, drawHeight) {
  43677. var forceRGB = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  43678. this.image.reset();
  43679. this.image.drawWidth = drawWidth || this.width;
  43680. this.image.drawHeight = drawHeight || this.height;
  43681. this.image.forceRGB = !!forceRGB;
  43682. return this.image.getBytes(length);
  43683. }
  43684. };
  43685. return PDFImage;
  43686. }();
  43687. exports.PDFImage = PDFImage;
  43688. /***/ })
  43689. /******/ ]);
  43690. });
  43691. //# sourceMappingURL=pdf.worker.js.map