UNPKG

@digicole/pdfmake-rtl

Version:

Enhanced PDFMake with automatic RTL (Arabic/Persian/Urdu) support - Complete standalone package

1,605 lines (1,407 loc) 2.88 MB
/*! pdfmake-rtl v1.0.0, @license MIT, @link https://github.com/aysnet1/pdfmake-rtl#readme */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(typeof self !== 'undefined' ? self : this, function() { return /******/ (function() { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 464: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var IS_PURE = __webpack_require__(63432); var store = __webpack_require__(55480); (module.exports = function (key, value) { return store[key] || (store[key] = value !== undefined ? value : {}); })('versions', []).push({ version: '3.19.0', mode: IS_PURE ? 'pure' : 'global', copyright: '© 2021 Denis Pushkarev (zloirock.ru)' }); /***/ }), /***/ 520: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var getBuiltIn = __webpack_require__(38486); module.exports = getBuiltIn('document', 'documentElement'); /***/ }), /***/ 664: /***/ (function(module, __unused_webpack_exports, __webpack_require__) { var userAgent = __webpack_require__(40715); module.exports = /web0s(?!.*chrome)/i.test(userAgent); /***/ }), /***/ 1083: /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { // TODO: Remove from `core-js@4` __webpack_require__(71768); /***/ }), /***/ 1239: /***/ (function(module, exports, __webpack_require__) { "use strict"; ; (function (root, factory) { if (true) { // CommonJS module.exports = exports = factory(__webpack_require__(48352)); } else // removed by dead control flow {} })(void 0, function (CryptoJS) { /** @preserve (c) 2012 by Cédric Mesnil. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ (function (Math) { // Shortcuts var C = CryptoJS; var C_lib = C.lib; var WordArray = C_lib.WordArray; var Hasher = C_lib.Hasher; var C_algo = C.algo; // Constants table var _zl = WordArray.create([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]); var _zr = WordArray.create([5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]); var _sl = WordArray.create([11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]); var _sr = WordArray.create([8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]); var _hl = WordArray.create([0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); var _hr = WordArray.create([0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); /** * RIPEMD160 hash algorithm. */ var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({ _doReset: function _doReset() { this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); }, _doProcessBlock: function _doProcessBlock(M, offset) { // Swap endian for (var i = 0; i < 16; i++) { // Shortcuts var offset_i = offset + i; var M_offset_i = M[offset_i]; // Swap M[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 0x00ff00ff | (M_offset_i << 24 | M_offset_i >>> 8) & 0xff00ff00; } // Shortcut var H = this._hash.words; var hl = _hl.words; var hr = _hr.words; var zl = _zl.words; var zr = _zr.words; var sl = _sl.words; var sr = _sr.words; // Working variables var al, bl, cl, dl, el; var ar, br, cr, dr, er; ar = al = H[0]; br = bl = H[1]; cr = cl = H[2]; dr = dl = H[3]; er = el = H[4]; // Computation var t; for (var i = 0; i < 80; i += 1) { t = al + M[offset + zl[i]] | 0; if (i < 16) { t += f1(bl, cl, dl) + hl[0]; } else if (i < 32) { t += f2(bl, cl, dl) + hl[1]; } else if (i < 48) { t += f3(bl, cl, dl) + hl[2]; } else if (i < 64) { t += f4(bl, cl, dl) + hl[3]; } else { // if (i<80) { t += f5(bl, cl, dl) + hl[4]; } t = t | 0; t = rotl(t, sl[i]); t = t + el | 0; al = el; el = dl; dl = rotl(cl, 10); cl = bl; bl = t; t = ar + M[offset + zr[i]] | 0; if (i < 16) { t += f5(br, cr, dr) + hr[0]; } else if (i < 32) { t += f4(br, cr, dr) + hr[1]; } else if (i < 48) { t += f3(br, cr, dr) + hr[2]; } else if (i < 64) { t += f2(br, cr, dr) + hr[3]; } else { // if (i<80) { t += f1(br, cr, dr) + hr[4]; } t = t | 0; t = rotl(t, sr[i]); t = t + er | 0; ar = er; er = dr; dr = rotl(cr, 10); cr = br; br = t; } // Intermediate hash value t = H[1] + cl + dr | 0; H[1] = H[2] + dl + er | 0; H[2] = H[3] + el + ar | 0; H[3] = H[4] + al + br | 0; H[4] = H[0] + bl + cr | 0; H[0] = t; }, _doFinalize: function _doFinalize() { // Shortcuts var data = this._data; var dataWords = data.words; var nBitsTotal = this._nDataBytes * 8; var nBitsLeft = data.sigBytes * 8; // Add padding dataWords[nBitsLeft >>> 5] |= 0x80 << 24 - nBitsLeft % 32; dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotal << 8 | nBitsTotal >>> 24) & 0x00ff00ff | (nBitsTotal << 24 | nBitsTotal >>> 8) & 0xff00ff00; data.sigBytes = (dataWords.length + 1) * 4; // Hash final blocks this._process(); // Shortcuts var hash = this._hash; var H = hash.words; // Swap endian for (var i = 0; i < 5; i++) { // Shortcut var H_i = H[i]; // Swap H[i] = (H_i << 8 | H_i >>> 24) & 0x00ff00ff | (H_i << 24 | H_i >>> 8) & 0xff00ff00; } // Return final computed hash return hash; }, clone: function clone() { var clone = Hasher.clone.call(this); clone._hash = this._hash.clone(); return clone; } }); function f1(x, y, z) { return x ^ y ^ z; } function f2(x, y, z) { return x & y | ~x & z; } function f3(x, y, z) { return (x | ~y) ^ z; } function f4(x, y, z) { return x & z | y & ~z; } function f5(x, y, z) { return x ^ (y | ~z); } function rotl(x, n) { return x << n | x >>> 32 - n; } /** * Shortcut function to the hasher's object interface. * * @param {WordArray|string} message The message to hash. * * @return {WordArray} The hash. * * @static * * @example * * var hash = CryptoJS.RIPEMD160('message'); * var hash = CryptoJS.RIPEMD160(wordArray); */ C.RIPEMD160 = Hasher._createHelper(RIPEMD160); /** * Shortcut function to the HMAC's object interface. * * @param {WordArray|string} message The message to hash. * @param {WordArray|string} key The secret key. * * @return {WordArray} The HMAC. * * @static * * @example * * var hmac = CryptoJS.HmacRIPEMD160(message, key); */ C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160); })(Math); return CryptoJS.RIPEMD160; }); /***/ }), /***/ 1387: /***/ (function(module) { "use strict"; /** * RTL (Right-to-Left) utilities for handling Arabic, Persian (Farsi), and Urdu languages */ // Unicode ranges for Arabic script (includes Persian and Urdu characters) var ARABIC_RANGE = [ [0x0600, 0x06FF], // Arabic block [0x0750, 0x077F], // Arabic Supplement [0x08A0, 0x08FF], // Arabic Extended-A [0xFB50, 0xFDFF], // Arabic Presentation Forms-A [0xFE70, 0xFEFF] // Arabic Presentation Forms-B ]; // Unicode ranges for Persian (Farsi) specific characters var PERSIAN_RANGE = [ [0x06A9, 0x06AF], // Persian Kaf, Gaf [0x06C0, 0x06C3], // Persian Heh, Teh Marbuta variants [0x06CC, 0x06CE], // Persian Yeh variants [0x06D0, 0x06D5], // Persian Yeh Barree, Arabic-Indic digits [0x200C, 0x200D] // Zero Width Non-Joiner, Zero Width Joiner (used in Persian) ]; // Unicode ranges for Urdu specific characters var URDU_RANGE = [ [0x0679, 0x0679], // Urdu Tteh [0x067E, 0x067E], // Urdu Peh [0x0686, 0x0686], // Urdu Tcheh [0x0688, 0x0688], // Urdu Ddal [0x0691, 0x0691], // Urdu Rreh [0x0698, 0x0698], // Urdu Jeh [0x06A9, 0x06A9], // Urdu Keheh [0x06AF, 0x06AF], // Urdu Gaf [0x06BA, 0x06BA], // Urdu Noon Ghunna [0x06BE, 0x06BE], // Urdu Heh Doachashmee [0x06C1, 0x06C1], // Urdu Heh Goal [0x06D2, 0x06D2], // Urdu Yeh Barree [0x06D3, 0x06D3] // Urdu Yeh Barree with Hamza ]; // Strong RTL characters (Arabic, Persian, Urdu) var RTL_CHARS = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF\u200C-\u200D]/; // Strong LTR characters (Latin, etc.) var LTR_CHARS = /[A-Za-z\u00C0-\u024F\u1E00-\u1EFF]/; /** * Check if a character is in Arabic script (includes Persian and Urdu) * @param {string} char - Single character to check * @return {boolean} - True if character is Arabic/Persian/Urdu */ function isArabicChar(char) { var code = char.charCodeAt(0); return ARABIC_RANGE.some(function(range) { return code >= range[0] && code <= range[1]; }); } /** * Check if a character is in Persian (Farsi) script * @param {string} char - Single character to check * @return {boolean} - True if character is Persian */ function isPersianChar(char) { var code = char.charCodeAt(0); return PERSIAN_RANGE.some(function(range) { return code >= range[0] && code <= range[1]; }) || isArabicChar(char); // Persian uses Arabic base + extensions } /** * Check if a character is in Urdu script * @param {string} char - Single character to check * @return {boolean} - True if character is Urdu */ function isUrduChar(char) { var code = char.charCodeAt(0); return URDU_RANGE.some(function(range) { return code >= range[0] && code <= range[1]; }) || isArabicChar(char); // Urdu uses Arabic base + extensions } /** * Check if a character requires RTL rendering * @param {string} char - Single character to check * @return {boolean} - True if character requires RTL */ function isRTLChar(char) { return RTL_CHARS.test(char); } /** * Check if a character is strongly LTR * @param {string} char - Single character to check * @return {boolean} - True if character is strongly LTR */ function isLTRChar(char) { return LTR_CHARS.test(char); } /** * Determine the predominant text direction of a string * @param {string} text - Text to analyze * @return {string} - 'rtl', 'ltr', or 'neutral' */ function getTextDirection(text) { if (!text || typeof text !== 'string') { return 'neutral'; } var rtlCount = 0; var ltrCount = 0; for (var i = 0; i < text.length; i++) { var char = text.charAt(i); if (isRTLChar(char)) { rtlCount++; } else if (isLTRChar(char)) { ltrCount++; } } // If we have any strong directional characters if (rtlCount > 0 || ltrCount > 0) { if (rtlCount > ltrCount) { return 'rtl'; } else if (ltrCount > rtlCount) { return 'ltr'; } else { // Equal counts - slight preference for RTL if both exist return rtlCount > 0 ? 'rtl' : 'ltr'; } } return 'neutral'; } /** * Check if text contains any RTL characters * @param {string} text - Text to check * @return {boolean} - True if text contains RTL characters */ function containsRTL(text) { if (!text || typeof text !== 'string') { return false; } return RTL_CHARS.test(text); } /** * Check if text is primarily Arabic, Persian, or Urdu * @param {string} text - Text to check * @return {boolean} - True if text is primarily Arabic/Persian/Urdu */ function isArabicText(text) { if (!text || typeof text !== 'string') { return false; } var rtlCount = 0; var totalStrongChars = 0; for (var i = 0; i < text.length; i++) { var char = text.charAt(i); if (isArabicChar(char) || isPersianChar(char) || isUrduChar(char)) { rtlCount++; totalStrongChars++; } else if (isRTLChar(char) || isLTRChar(char)) { totalStrongChars++; } } // If we have any strong characters and RTL represents at least 30% // (lowered threshold for mixed text) return totalStrongChars > 0 && (rtlCount / totalStrongChars) >= 0.3; } /** * Process RTL text for proper display * For modern PDF libraries, we rely on the underlying engine for BiDi processing * We should NOT reverse word order manually - that breaks Arabic text * @param {string} text - Text to process * @return {string} - Text (unchanged for proper BiDi handling) */ function reverseRTLText(text) { if (!text || typeof text !== 'string') { return text; } // DO NOT reverse Arabic text word order! // Arabic text should maintain its natural word order // Only the display direction (alignment) should be RTL // The PDF engine handles proper BiDi rendering return text; } /** * Apply RTL processing to text if needed * @param {string} text - Original text * @param {string} direction - Explicit direction override ('rtl', 'ltr', or null) * @return {Object} - { text: processedText, isRTL: boolean } */ function processRTLText(text, direction) { if (!text || typeof text !== 'string' || getTextDirection(text) !== 'rtl') { return { text: text, isRTL: false }; } var isRTL = false; if (direction === 'rtl') { isRTL = true; } else if (direction === 'ltr') { isRTL = false; } else { // Auto-detect direction var textDir = getTextDirection(text); isRTL = textDir === 'rtl'; } // Keep original text - no word reversal needed // The PDF engine handles proper BiDi rendering return { text: text, isRTL: isRTL }; } /** * Reverse table row cells for RTL layout * @param {Array} row - Table row array * @return {Array} - Reversed row array */ function reverseTableRow(row) { if (!Array.isArray(row)) { return row; } return row.slice().reverse(); } /** * Process table for RTL layout if supportRTL is enabled * @param {Object} tableNode - Table definition object * @return {Object} - Processed table node */ function processRTLTable(tableNode) { if (!tableNode || !tableNode.supportRTL || !tableNode.table || !tableNode.table.body) { return tableNode; } // Don't clone the entire object - just modify the table data in place // Reverse each row in the table body for RTL layout tableNode.table.body = tableNode.table.body.map(function(row) { return reverseTableRow(row); }); // Also reverse the widths array if it exists if (tableNode.table.widths && Array.isArray(tableNode.table.widths)) { tableNode.table.widths = tableNode.table.widths.slice().reverse(); } return tableNode; } /** * Apply automatic RTL detection and formatting to any text element * @param {Object|string} element - Text element or string * @return {Object} - Enhanced element with RTL properties */ function autoApplyRTL(element) { if (!element) return element; // Handle string elements if (typeof element === 'string') { var direction = getTextDirection(element); if (direction === 'rtl') { return { text: element, alignment: 'right', font: 'Nillima' // Use Arabic font for RTL text }; } return element; } // Handle object elements if (typeof element === 'object' && element.text) { var textDirection = getTextDirection(element.text); if (textDirection === 'rtl') { // Auto-apply RTL properties if not already set if (!element.alignment) { element.alignment = 'right'; } if (!element.font && isArabicText(element.text)) { element.font = 'Nillima'; } } else if (textDirection === 'ltr') { // Auto-apply LTR properties if not already set if (!element.alignment) { element.alignment = 'left'; } if (!element.font) { element.font = 'Roboto'; } } } return element; } /** * Process list items for RTL support including bullet positioning * @param {Array|Object} listItems - ul/ol content * @return {Array|Object} - Processed list with RTL support */ function processRTLList(listItems) { if (!listItems) return listItems; function processListItem(item) { if (typeof item === 'string') { var direction = getTextDirection(item); if (direction === 'rtl') { return { text: item, alignment: 'right', font: 'Nillima', markerColor: '#2c5282' }; } return item; } if (typeof item === 'object') { // Process the main text if (item.text) { var textDirection = getTextDirection(item.text); if (textDirection === 'rtl') { if (!item.alignment) item.alignment = 'right'; if (!item.font && isArabicText(item.text)) item.font = 'Nillima'; if (!item.markerColor) item.markerColor = '#2c5282'; } } // Process nested ul/ol recursively if (item.ul) { item.ul = processRTLList(item.ul); } if (item.ol) { item.ol = processRTLList(item.ol); } } return item; } if (Array.isArray(listItems)) { return listItems.map(processListItem); } return processListItem(listItems); } /** * Process table for automatic RTL detection and layout * @param {Object} tableNode - Table definition object * @return {Object} - Processed table node */ function processAutoRTLTable(tableNode) { if (!tableNode || !tableNode.table || !tableNode.table.body) { return tableNode; } // Check if table contains RTL content var hasRTLContent = false; var rtlCellCount = 0; var totalCells = 0; tableNode.table.body.forEach(function(row) { if (Array.isArray(row)) { row.forEach(function(cell) { totalCells++; var cellText = typeof cell === 'string' ? cell : (cell && cell.text ? cell.text : ''); if (containsRTL(cellText)) { rtlCellCount++; } }); } }); // If more than 30% of cells contain RTL content, treat as RTL table hasRTLContent = totalCells > 0 && (rtlCellCount / totalCells) >= 0.3; if (hasRTLContent) { // Reverse table columns for RTL layout tableNode.table.body = tableNode.table.body.map(function(row) { return reverseTableRow(row); }); // Reverse widths if defined if (tableNode.table.widths && Array.isArray(tableNode.table.widths)) { tableNode.table.widths = tableNode.table.widths.slice().reverse(); } // Auto-apply RTL styles to cells tableNode.table.body = tableNode.table.body.map(function(row) { if (Array.isArray(row)) { return row.map(function(cell) { return autoApplyRTL(cell); }); } return row; }); } else { // For non-RTL tables, still auto-apply font and alignment per cell tableNode.table.body = tableNode.table.body.map(function(row) { if (Array.isArray(row)) { return row.map(function(cell) { return autoApplyRTL(cell); }); } return row; }); } return tableNode; } /** * Process any document element for automatic RTL detection * @param {Object|Array|string} element - Document element * @return {Object|Array|string} - Processed element */ function processAutoRTLElement(element) { if (!element) return element; // Handle arrays (like content arrays) if (Array.isArray(element)) { return element.map(processAutoRTLElement); } // Handle text elements if (typeof element === 'string' || (element && element.text)) { element = autoApplyRTL(element); } // Handle tables if (element && element.table) { element = processAutoRTLTable(element); } // Handle lists if (element && element.ul) { element.ul = processRTLList(element.ul); } if (element && element.ol) { element.ol = processRTLList(element.ol); } // Handle columns if (element && element.columns && Array.isArray(element.columns)) { element.columns = element.columns.map(processAutoRTLElement); } return element; } module.exports = { isArabicChar: isArabicChar, isPersianChar: isPersianChar, isUrduChar: isUrduChar, isRTLChar: isRTLChar, isLTRChar: isLTRChar, getTextDirection: getTextDirection, containsRTL: containsRTL, isArabicText: isArabicText, reverseRTLText: reverseRTLText, processRTLText: processRTLText, reverseTableRow: reverseTableRow, processRTLTable: processRTLTable, autoApplyRTL: autoApplyRTL, processRTLList: processRTLList, processAutoRTLTable: processAutoRTLTable, processAutoRTLElement: processAutoRTLElement }; /***/ }), /***/ 1593: /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { "use strict"; var $ = __webpack_require__(56475); var global = __webpack_require__(32010); var call = __webpack_require__(2834); var uncurryThis = __webpack_require__(38347); var requireObjectCoercible = __webpack_require__(83943); var isCallable = __webpack_require__(94578); var isRegExp = __webpack_require__(28831); var toString = __webpack_require__(25096); var getMethod = __webpack_require__(51839); var regExpFlags = __webpack_require__(21182); var getSubstitution = __webpack_require__(29519); var wellKnownSymbol = __webpack_require__(38688); var IS_PURE = __webpack_require__(63432); var REPLACE = wellKnownSymbol('replace'); var RegExpPrototype = RegExp.prototype; var TypeError = global.TypeError; var getFlags = uncurryThis(regExpFlags); var indexOf = uncurryThis(''.indexOf); var replace = uncurryThis(''.replace); var stringSlice = uncurryThis(''.slice); var max = Math.max; var stringIndexOf = function (string, searchValue, fromIndex) { if (fromIndex > string.length) return -1; if (searchValue === '') return fromIndex; return indexOf(string, searchValue, fromIndex); }; // `String.prototype.replaceAll` method // https://tc39.es/ecma262/#sec-string.prototype.replaceall $({ target: 'String', proto: true }, { replaceAll: function replaceAll(searchValue, replaceValue) { var O = requireObjectCoercible(this); var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; var position = 0; var endOfLastMatch = 0; var result = ''; if (searchValue != null) { IS_REG_EXP = isRegExp(searchValue); if (IS_REG_EXP) { flags = toString(requireObjectCoercible('flags' in RegExpPrototype ? searchValue.flags : getFlags(searchValue) )); if (!~indexOf(flags, 'g')) throw TypeError('`.replaceAll` does not allow non-global regexes'); } replacer = getMethod(searchValue, REPLACE); if (replacer) { return call(replacer, searchValue, O, replaceValue); } else if (IS_PURE && IS_REG_EXP) { return replace(toString(O), searchValue, replaceValue); } } string = toString(O); searchString = toString(searchValue); functionalReplace = isCallable(replaceValue); if (!functionalReplace) replaceValue = toString(replaceValue); searchLength = searchString.length; advanceBy = max(1, searchLength); position = stringIndexOf(string, searchString, 0); while (position !== -1) { replacement = functionalReplace ? toString(replaceValue(searchString, position, string)) : getSubstitution(searchString, string, position, [], undefined, replaceValue); result += stringSlice(string, endOfLastMatch, position) + replacement; endOfLastMatch = position + searchLength; position = stringIndexOf(string, searchString, position + advanceBy); } if (endOfLastMatch < string.length) { result += stringSlice(string, endOfLastMatch); } return result; } }); /***/ }), /***/ 2256: /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(94845); ; (function (root, factory) { if (true) { // CommonJS module.exports = exports = factory(__webpack_require__(48352)); } else // removed by dead control flow {} })(void 0, function (CryptoJS) { (function () { // Shortcuts var C = CryptoJS; var C_lib = C.lib; var WordArray = C_lib.WordArray; var C_enc = C.enc; /** * UTF-16 BE encoding strategy. */ var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = { /** * Converts a word array to a UTF-16 BE string. * * @param {WordArray} wordArray The word array. * * @return {string} The UTF-16 BE string. * * @static * * @example * * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray); */ stringify: function stringify(wordArray) { // Shortcuts var words = wordArray.words; var sigBytes = wordArray.sigBytes; // Convert var utf16Chars = []; for (var i = 0; i < sigBytes; i += 2) { var codePoint = words[i >>> 2] >>> 16 - i % 4 * 8 & 0xffff; utf16Chars.push(String.fromCharCode(codePoint)); } return utf16Chars.join(''); }, /** * Converts a UTF-16 BE string to a word array. * * @param {string} utf16Str The UTF-16 BE string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Utf16.parse(utf16String); */ parse: function parse(utf16Str) { // Shortcut var utf16StrLength = utf16Str.length; // Convert var words = []; for (var i = 0; i < utf16StrLength; i++) { words[i >>> 1] |= utf16Str.charCodeAt(i) << 16 - i % 2 * 16; } return WordArray.create(words, utf16StrLength * 2); } }; /** * UTF-16 LE encoding strategy. */ C_enc.Utf16LE = { /** * Converts a word array to a UTF-16 LE string. * * @param {WordArray} wordArray The word array. * * @return {string} The UTF-16 LE string. * * @static * * @example * * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); */ stringify: function stringify(wordArray) { // Shortcuts var words = wordArray.words; var sigBytes = wordArray.sigBytes; // Convert var utf16Chars = []; for (var i = 0; i < sigBytes; i += 2) { var codePoint = swapEndian(words[i >>> 2] >>> 16 - i % 4 * 8 & 0xffff); utf16Chars.push(String.fromCharCode(codePoint)); } return utf16Chars.join(''); }, /** * Converts a UTF-16 LE string to a word array. * * @param {string} utf16Str The UTF-16 LE string. * * @return {WordArray} The word array. * * @static * * @example * * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); */ parse: function parse(utf16Str) { // Shortcut var utf16StrLength = utf16Str.length; // Convert var words = []; for (var i = 0; i < utf16StrLength; i++) { words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << 16 - i % 2 * 16); } return WordArray.create(words, utf16StrLength * 2); } }; function swapEndian(word) { return word << 8 & 0xff00ff00 | word >>> 8 & 0x00ff00ff; } })(); return CryptoJS.enc.Utf16; }); /***/ }), /***/ 2269: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; // (C) 1995-2013 Jean-loup Gailly and Mark Adler // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // 3. This notice may not be removed or altered from any source distribution. var utils = __webpack_require__(72519); var adler32 = __webpack_require__(46911); var crc32 = __webpack_require__(99049); var inflate_fast = __webpack_require__(96395); var inflate_table = __webpack_require__(92920); var CODES = 0; var LENS = 1; var DISTS = 2; /* Public constants ==========================================================*/ /* ===========================================================================*/ /* Allowed flush values; see deflate() and inflate() below for details */ //var Z_NO_FLUSH = 0; //var Z_PARTIAL_FLUSH = 1; //var Z_SYNC_FLUSH = 2; //var Z_FULL_FLUSH = 3; var Z_FINISH = 4; var Z_BLOCK = 5; var Z_TREES = 6; /* Return codes for the compression/decompression functions. Negative values * are errors, positive values are used for special but normal events. */ var Z_OK = 0; var Z_STREAM_END = 1; var Z_NEED_DICT = 2; //var Z_ERRNO = -1; var Z_STREAM_ERROR = -2; var Z_DATA_ERROR = -3; var Z_MEM_ERROR = -4; var Z_BUF_ERROR = -5; //var Z_VERSION_ERROR = -6; /* The deflate compression method */ var Z_DEFLATED = 8; /* STATES ====================================================================*/ /* ===========================================================================*/ var HEAD = 1; /* i: waiting for magic header */ var FLAGS = 2; /* i: waiting for method and flags (gzip) */ var TIME = 3; /* i: waiting for modification time (gzip) */ var OS = 4; /* i: waiting for extra flags and operating system (gzip) */ var EXLEN = 5; /* i: waiting for extra length (gzip) */ var EXTRA = 6; /* i: waiting for extra bytes (gzip) */ var NAME = 7; /* i: waiting for end of file name (gzip) */ var COMMENT = 8; /* i: waiting for end of comment (gzip) */ var HCRC = 9; /* i: waiting for header crc (gzip) */ var DICTID = 10; /* i: waiting for dictionary check value */ var DICT = 11; /* waiting for inflateSetDictionary() call */ var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */ var STORED = 14; /* i: waiting for stored size (length and complement) */ var COPY_ = 15; /* i/o: same as COPY below, but only first time in */ var COPY = 16; /* i/o: waiting for input or output to copy stored block */ var TABLE = 17; /* i: waiting for dynamic block table lengths */ var LENLENS = 18; /* i: waiting for code length code lengths */ var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */ var LEN_ = 20; /* i: same as LEN below, but only first time in */ var LEN = 21; /* i: waiting for length/lit/eob code */ var LENEXT = 22; /* i: waiting for length extra bits */ var DIST = 23; /* i: waiting for distance code */ var DISTEXT = 24; /* i: waiting for distance extra bits */ var MATCH = 25; /* o: waiting for output space to copy string */ var LIT = 26; /* o: waiting for output space to write literal */ var CHECK = 27; /* i: waiting for 32-bit check value */ var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */ var DONE = 29; /* finished check, done -- remain here until reset */ var BAD = 30; /* got a data error -- remain here until reset */ var MEM = 31; /* got an inflate() memory error -- remain here until reset */ var SYNC = 32; /* looking for synchronization bytes to restart inflate() */ /* ===========================================================================*/ var ENOUGH_LENS = 852; var ENOUGH_DISTS = 592; //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); var MAX_WBITS = 15; /* 32K LZ77 window */ var DEF_WBITS = MAX_WBITS; function zswap32(q) { return (((q >>> 24) & 0xff) + ((q >>> 8) & 0xff00) + ((q & 0xff00) << 8) + ((q & 0xff) << 24)); } function InflateState() { this.mode = 0; /* current inflate mode */ this.last = false; /* true if processing last block */ this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */ this.havedict = false; /* true if dictionary provided */ this.flags = 0; /* gzip header method and flags (0 if zlib) */ this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */ this.check = 0; /* protected copy of check value */ this.total = 0; /* protected copy of output count */ // TODO: may be {} this.head = null; /* where to save gzip header information */ /* sliding window */ this.wbits = 0; /* log base 2 of requested window size */ this.wsize = 0; /* window size or zero if not using window */ this.whave = 0; /* valid bytes in the window */ this.wnext = 0; /* window write index */ this.window = null; /* allocated sliding window, if needed */ /* bit accumulator */ this.hold = 0; /* input bit accumulator */ this.bits = 0; /* number of bits in "in" */ /* for string and stored block copying */ this.length = 0; /* literal or length of data to copy */ this.offset = 0; /* distance back to copy string from */ /* for table and code decoding */ this.extra = 0; /* extra bits needed */ /* fixed and dynamic code tables */ this.lencode = null; /* starting table for length/literal codes */ this.distcode = null; /* starting table for distance codes */ this.lenbits = 0; /* index bits for lencode */ this.distbits = 0; /* index bits for distcode */ /* dynamic table building */ this.ncode = 0; /* number of code length code lengths */ this.nlen = 0; /* number of length code lengths */ this.ndist = 0; /* number of distance code lengths */ this.have = 0; /* number of code lengths in lens[] */ this.next = null; /* next available space in codes[] */ this.lens = new utils.Buf16(320); /* temporary storage for code lengths */ this.work = new utils.Buf16(288); /* work area for code table building */ /* because we don't have pointers in js, we use lencode and distcode directly as buffers so we don't need codes */ //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */ this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */ this.distdyn = null; /* dynamic table for distance codes (JS specific) */ this.sane = 0; /* if false, allow invalid distance too far */ this.back = 0; /* bits back of last unprocessed length/lit */ this.was = 0; /* initial length of match */ } function inflateResetKeep(strm) { var state; if (!strm || !strm.state) { return Z_STREAM_ERROR; } state = strm.state; strm.total_in = strm.total_out = state.total = 0; strm.msg = ''; /*Z_NULL*/ if (state.wrap) { /* to support ill-conceived Java test suite */ strm.adler = state.wrap & 1; } state.mode = HEAD; state.last = 0; state.havedict = 0; state.dmax = 32768; state.head = null/*Z_NULL*/; state.hold = 0; state.bits = 0; //state.lencode = state.distcode = state.next = state.codes; state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS); state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS); state.sane = 1; state.back = -1; //Tracev((stderr, "inflate: reset\n")); return Z_OK; } function inflateReset(strm) { var state; if (!strm || !strm.state) { return Z_STREAM_ERROR; } state = strm.state; state.wsize = 0; state.whave = 0; state.wnext = 0; return inflateResetKeep(strm); } function inflateReset2(strm, windowBits) { var wrap; var state; /* get the state */ if (!strm || !strm.state) { return Z_STREAM_ERROR; } state = strm.state; /* extract wrap request from windowBits parameter */ if (windowBits < 0) { wrap = 0; windowBits = -windowBits; } else { wrap = (windowBits >> 4) + 1; if (windowBits < 48) { windowBits &= 15; } } /* set number of window bits, free window if different */ if (windowBits && (windowBits < 8 || windowBits > 15)) { return Z_STREAM_ERROR; } if (state.window !== null && state.wbits !== windowBits) { state.window = null; } /* update state and reset the rest of it */ state.wrap = wrap; state.wbits = windowBits; return inflateReset(strm); } function inflateInit2(strm, windowBits) { var ret; var state; if (!strm) { return Z_STREAM_ERROR; } //strm.msg = Z_NULL; /* in case we return an error */ state = new InflateState(); //if (state === Z_NULL) return Z_MEM_ERROR; //Tracev((stderr, "inflate: allocated\n")); strm.state = state; state.window = null/*Z_NULL*/; ret = inflateReset2(strm, windowBits); if (ret !== Z_OK) { strm.state = null/*Z_NULL*/; } return ret; } function inflateInit(strm) { return inflateInit2(strm, DEF_WBITS); } /* Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little execution time. However, BUILDFIXED should not be used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ var virgin = true; var lenfix, distfix; // We have no pointers in JS, so keep tables separate function fixedtables(state) { /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { var sym; lenfix = new utils.Buf32(512); distfix = new utils.Buf32(32); /* literal/length table */ sym = 0; while (sym < 144) { state.lens[sym++] = 8; } while (sym < 256) { state.lens[sym++] = 9; } while (sym < 280) { state.lens[sym++] = 7; } while (sym < 288) { state.lens[sym++] = 8; } inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 }); /* distance table */ sym = 0; while (sym < 32) { state.lens[sym++] = 5; } inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 }); /* do this just once */ virgin = false; } state.lencode = lenfix; state.lenbits = 9; state.distcode = distfix; state.distbits = 5; } /* Update the window with the last wsize (normally 32K) bytes written before returning. If window does not exist yet, create it. This is only called when a window is already in use, or when output has been written during this inflate call, but the end of the deflate stream has not been reached yet. It is also called to create a window for dictionary data when a dictionary is loaded. Providing output buffers larger than 32K to inflate() should provide a speed advantage, since only the last 32K of output is copied to the sliding window upon return from inflate(), and since all distances after the first 32K of output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ function updatewindow(strm, src, end, copy) { var dist; var state = strm.state; /* if it hasn't been done already, allocate space for the window */ if (state.window === null) { state.wsize = 1 << state.wbits; state.wnext = 0; state.whave = 0; state.window = new utils.Buf8(state.wsize); } /* copy state->wsize or less output bytes into the circular window */ if (copy >= state.wsize) { utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0); state.wnext = 0; state.whave = state.wsize; } else { dist = state.wsize - state.wnext; if (dist > copy) { dist = copy; } //zmemcpy(state->window + state->wnext, end - copy, dist); utils.arraySet(state.window, src, end - copy, dist, state.wnext); copy -= dist; if (copy) { //zmemcpy(state->window, end - copy, copy); utils.arraySet(state.window, src, end - copy, copy, 0); state.wnext = copy; state.whave = state.wsize; } else { state.wnext += dist; if (state.wnext === state.wsize) { state.wnext = 0; } if (state.whave < state.wsize) { state.whave += dist; } } } return 0; } function inflate(strm, flush) { var state; var input, output; // input/output buffers var next; /* next input INDEX */ var put; /* next output INDEX */ var have, left; /* available input and output */ var hold; /* bit buffer */ var bits; /* bits in bit buffer */ var _in, _out; /* save starting available input and output */ var copy; /* number of stored or match bytes to copy */ var from; /* where to copy match bytes from */ var from_source; var here = 0; /* current decoding table entry */ var here_bits, here_op, here_val; // paked "here" denormalized (JS specific) //var last; /* parent table entry */ var last_bits, last_op, last_val; // paked "last" denormalized (JS specific) var len; /* length to copy for repeats, bits to drop */ var ret; /* return code */ var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */ var opts; var n; // temporary var for NEED_BITS var order = /* permutation of code lengths */ [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ]; if (!strm || !strm.state || !strm.output || (!strm.input && strm.avail_in !== 0)) { return Z_STREAM_ERROR; } state = strm.state; if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */ //--- LOAD() --- put = strm.next_out; output = strm.output; left = strm.avail_out; next = strm.next_in; input = strm.input; have = strm.avail_in; hold = state.hold; bits = state.bits; //--- _in = have; _out = left; ret = Z_OK; inf_leave: // goto emulation for (;;) { switch (state.mode) { case HEAD: if (state.wrap === 0) { state.mode = TYPEDO; break; } //=== NEEDBITS(16); while (bits < 16) { if (have === 0) { break inf_leave; } have--; hold += input[next++] << bits; bits += 8; } //===// if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */ state.check = 0/*crc32(0L, Z_NULL, 0)*/; //=== CRC2(state.check, hold); hbuf[0] = hold & 0xff; hbuf[1] = (hold >>> 8) & 0xff; state.check = crc32(state.check, hbuf, 2, 0); //===// //=== INITBITS(); hold = 0; bits = 0; //===// state.mode = FLAGS; break; } state.flags = 0; /* expect zlib header */ if (state.head) { state.head.done = false; } if (!(state.wrap & 1) || /* check if zlib header allowed */ (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) { strm.msg = 'incorrect header check'; state.mode = BAD; break; } if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) { strm.msg = 'unknown compression method'; state.mode = BAD; break; } //--- DROPBITS(4) ---// hold >>>= 4; bits -= 4; //---// len = (hold & 0x0f)/*BITS(4)*/ + 8; if (state.wbits === 0) { state.wbits = len; } else if (len > state.wbits) { strm.msg = 'invalid window size'; state.mode = BAD; break; } state.dmax = 1 << len; //Tracev((stderr, "inflate: zlib header ok\n")); strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/; state.mode = hold & 0x200 ? DICTID : TYPE; //=== INITBITS(); hold = 0; bits = 0; //===// break; case FLAGS: //=== NEEDBITS(16); */ while (bits < 16) { if (have === 0) { break inf_leave; } have--; hold += input[next++] << bits; bits += 8; } //===// state.flags = hold; if ((state.flags & 0xff) !== Z_DEFLATED) { strm.msg = 'unknown compression method'; state.mode = BAD; break; } if (state.flags & 0xe000) { strm.msg = 'unknown header flags set'; state.mode = BAD; break; } if (state.head) { state.head.text = ((hold >> 8) & 1); } if (state.flags & 0x0200) { //=== CRC2(state.check, hold); hbuf[0] = hold & 0xff; hbuf[1] = (hold >>> 8) & 0xff; state.check = crc32(state.check, hbuf, 2, 0); //===// } //=== INITBITS(); hold = 0; bits = 0; //===// state.mode = TIME; /* falls through */ case TIME: //=== NEEDBITS(32); */ while (bits < 32) { if (have === 0) { break inf_leave; } have--; hold += input[next++] << bits; bits += 8; } //===// if (state.head) { state.head.time = hold; } if (state.flags & 0x0200) { //=== CRC4(state.check, hold) hbuf[0] = hold & 0xff; hbuf[1] = (hold >>> 8) & 0xff; hbuf[2] = (hold >>> 16) & 0xff; hbuf[3] = (hold >>> 24) & 0xff; state.check = crc32(state.check, hbuf, 4, 0); //=== } //=== INITBITS(); hold = 0; bits = 0; //===// state.mode = OS; /* falls through */ case OS: //=== NEEDBITS(16); */ while (bits < 16) { if (have === 0) { break inf_leave; } have--; hold += input[next++] << bits; bits += 8; } //===// if (state.head) { state.head.xflags = (hold & 0xff); state.head.os = (hold >> 8); } if (state.flags & 0x0200) { //=== CRC2(state.check, hold); hbuf[0] = hold & 0xff; hbuf[1] = (hold >>> 8) & 0xff; state.check = crc32(state.check, hbuf, 2, 0); //===// } //=== INITBITS(); hold = 0; bits = 0; //===// state.mode = EXLEN; /* falls through */ case EXLEN: if (state.flags & 0x0400) { //=== NEEDBITS(16); */ while (bits < 16) { if (have === 0) { break inf_leave; } have--; hold += input[next++] << bits; bits += 8; } //===// state.length = hold; if (state.head) { state.head.extra_len = hold; } if (state.flags & 0x0