diff --git a/package.json b/package.json index 432e5b3..35bad6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "freedatas2html", - "version": "0.3.4", + "version": "0.3.5", "description": "Visualization of data from various sources (CSV, API, HTML...) with filters, classification, pagination, etc.", "main": "index.js", "scripts": { diff --git a/public/JS/firstExample.app.js b/public/JS/firstExample.app.js index 040a7e0..39b6b3b 100644 --- a/public/JS/firstExample.app.js +++ b/public/JS/firstExample.app.js @@ -1,6 +1,649 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ +/***/ "./node_modules/natural-orderby/esm/natural-orderby.js": +/*!*************************************************************!*\ + !*** ./node_modules/natural-orderby/esm/natural-orderby.js ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "orderBy": () => (/* binding */ orderBy), +/* harmony export */ "compare": () => (/* binding */ compare) +/* harmony export */ }); +var compareNumbers = function compareNumbers(numberA, numberB) { + if (numberA < numberB) { + return -1; + } + + if (numberA > numberB) { + return 1; + } + + return 0; +}; + +var RE_NUMBERS = /(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g; +var RE_LEADING_OR_TRAILING_WHITESPACES = /^\s+|\s+$/g; // trim pre-post whitespace + +var RE_WHITESPACES = /\s+/g; // normalize all whitespace to single ' ' character + +var RE_INT_OR_FLOAT = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/; // identify integers and floats + +var RE_DATE = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[/-]\d{1,4}[/-]\d{1,4}|^\w+, \w+ \d+, \d{4})/; // identify date strings + +var RE_LEADING_ZERO = /^0+[1-9]{1}[0-9]*$/; +var RE_UNICODE_CHARACTERS = /[^\x00-\x80]/; + +var compareUnicode = function compareUnicode(stringA, stringB) { + var result = stringA.localeCompare(stringB); + return result ? result / Math.abs(result) : 0; +}; + +var stringCompare = function stringCompare(stringA, stringB) { + if (stringA < stringB) { + return -1; + } + + if (stringA > stringB) { + return 1; + } + + return 0; +}; + +var compareChunks = function compareChunks(chunksA, chunksB) { + var lengthA = chunksA.length; + var lengthB = chunksB.length; + var size = Math.min(lengthA, lengthB); + + for (var i = 0; i < size; i++) { + var chunkA = chunksA[i]; + var chunkB = chunksB[i]; + + if (chunkA.normalizedString !== chunkB.normalizedString) { + if (chunkA.normalizedString === '' !== (chunkB.normalizedString === '')) { + // empty strings have lowest value + return chunkA.normalizedString === '' ? -1 : 1; + } + + if (chunkA.parsedNumber !== undefined && chunkB.parsedNumber !== undefined) { + // compare numbers + var result = compareNumbers(chunkA.parsedNumber, chunkB.parsedNumber); + + if (result === 0) { + // compare string value, if parsed numbers are equal + // Example: + // chunkA = { parsedNumber: 1, normalizedString: "001" } + // chunkB = { parsedNumber: 1, normalizedString: "01" } + // chunkA.parsedNumber === chunkB.parsedNumber + // chunkA.normalizedString < chunkB.normalizedString + return stringCompare(chunkA.normalizedString, chunkB.normalizedString); + } + + return result; + } else if (chunkA.parsedNumber !== undefined || chunkB.parsedNumber !== undefined) { + // number < string + return chunkA.parsedNumber !== undefined ? -1 : 1; + } else if (RE_UNICODE_CHARACTERS.test(chunkA.normalizedString + chunkB.normalizedString) && chunkA.normalizedString.localeCompare) { + // use locale comparison only if one of the chunks contains unicode characters + return compareUnicode(chunkA.normalizedString, chunkB.normalizedString); + } else { + // use common string comparison for performance reason + return stringCompare(chunkA.normalizedString, chunkB.normalizedString); + } + } + } // if the chunks are equal so far, the one which has more chunks is greater than the other one + + + if (lengthA > size || lengthB > size) { + return lengthA <= size ? -1 : 1; + } + + return 0; +}; + +var compareOtherTypes = function compareOtherTypes(valueA, valueB) { + if (!valueA.chunks ? valueB.chunks : !valueB.chunks) { + return !valueA.chunks ? 1 : -1; + } + + if (valueA.isNaN ? !valueB.isNaN : valueB.isNaN) { + return valueA.isNaN ? -1 : 1; + } + + if (valueA.isSymbol ? !valueB.isSymbol : valueB.isSymbol) { + return valueA.isSymbol ? -1 : 1; + } + + if (valueA.isObject ? !valueB.isObject : valueB.isObject) { + return valueA.isObject ? -1 : 1; + } + + if (valueA.isArray ? !valueB.isArray : valueB.isArray) { + return valueA.isArray ? -1 : 1; + } + + if (valueA.isFunction ? !valueB.isFunction : valueB.isFunction) { + return valueA.isFunction ? -1 : 1; + } + + if (valueA.isNull ? !valueB.isNull : valueB.isNull) { + return valueA.isNull ? -1 : 1; + } + + return 0; +}; + +var compareValues = function compareValues(valueA, valueB) { + if (valueA.value === valueB.value) { + return 0; + } + + if (valueA.parsedNumber !== undefined && valueB.parsedNumber !== undefined) { + return compareNumbers(valueA.parsedNumber, valueB.parsedNumber); + } + + if (valueA.chunks && valueB.chunks) { + return compareChunks(valueA.chunks, valueB.chunks); + } + + return compareOtherTypes(valueA, valueB); +}; + +var compareMultiple = function compareMultiple(recordA, recordB, orders) { + var indexA = recordA.index, + valuesA = recordA.values; + var indexB = recordB.index, + valuesB = recordB.values; + var length = valuesA.length; + var ordersLength = orders.length; + + for (var i = 0; i < length; i++) { + var order = i < ordersLength ? orders[i] : null; + + if (order && typeof order === 'function') { + var result = order(valuesA[i].value, valuesB[i].value); + + if (result) { + return result; + } + } else { + var _result = compareValues(valuesA[i], valuesB[i]); + + if (_result) { + return _result * (order === 'desc' ? -1 : 1); + } + } + } + + return indexA - indexB; +}; + +var createIdentifierFn = function createIdentifierFn(identifier) { + if (typeof identifier === 'function') { + // identifier is already a lookup function + return identifier; + } + + return function (value) { + if (Array.isArray(value)) { + var index = Number(identifier); + + if (Number.isInteger(index)) { + return value[index]; + } + } else if (value && typeof value === 'object' && typeof identifier !== 'function') { + return value[identifier]; + } + + return value; + }; +}; + +var stringify = function stringify(value) { + if (typeof value === 'boolean' || value instanceof Boolean) { + return Number(value).toString(); + } + + if (typeof value === 'number' || value instanceof Number) { + return value.toString(); + } + + if (value instanceof Date) { + return value.getTime().toString(); + } + + if (typeof value === 'string' || value instanceof String) { + return value.toLowerCase().replace(RE_LEADING_OR_TRAILING_WHITESPACES, ''); + } + + return ''; +}; + +var parseNumber = function parseNumber(value) { + if (value.length !== 0) { + var parsedNumber = Number(value); + + if (!Number.isNaN(parsedNumber)) { + return parsedNumber; + } + } + + return undefined; +}; + +var parseDate = function parseDate(value) { + if (RE_DATE.test(value)) { + var parsedDate = Date.parse(value); + + if (!Number.isNaN(parsedDate)) { + return parsedDate; + } + } + + return undefined; +}; + +var numberify = function numberify(value) { + var parsedNumber = parseNumber(value); + + if (parsedNumber !== undefined) { + return parsedNumber; + } + + return parseDate(value); +}; + +var createChunks = function createChunks(value) { + return value.replace(RE_NUMBERS, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0'); +}; + +var normalizeAlphaChunk = function normalizeAlphaChunk(chunk) { + return chunk.replace(RE_WHITESPACES, ' ').replace(RE_LEADING_OR_TRAILING_WHITESPACES, ''); +}; + +var normalizeNumericChunk = function normalizeNumericChunk(chunk, index, chunks) { + if (RE_INT_OR_FLOAT.test(chunk)) { + // don´t parse a number, if there´s a preceding decimal point + // to keep significance + // e.g. 1.0020, 1.020 + if (!RE_LEADING_ZERO.test(chunk) || index === 0 || chunks[index - 1] !== '.') { + return parseNumber(chunk) || 0; + } + } + + return undefined; +}; + +var createChunkMap = function createChunkMap(chunk, index, chunks) { + return { + parsedNumber: normalizeNumericChunk(chunk, index, chunks), + normalizedString: normalizeAlphaChunk(chunk) + }; +}; + +var createChunkMaps = function createChunkMaps(value) { + var chunksMaps = createChunks(value).map(createChunkMap); + return chunksMaps; +}; + +var isFunction = function isFunction(value) { + return typeof value === 'function'; +}; + +var isNaN = function isNaN(value) { + return Number.isNaN(value) || value instanceof Number && Number.isNaN(value.valueOf()); +}; + +var isNull = function isNull(value) { + return value === null; +}; + +var isObject = function isObject(value) { + return value !== null && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Number) && !(value instanceof String) && !(value instanceof Boolean) && !(value instanceof Date); +}; + +var isSymbol = function isSymbol(value) { + return typeof value === 'symbol'; +}; + +var isUndefined = function isUndefined(value) { + return value === undefined; +}; + +var getMappedValueRecord = function getMappedValueRecord(value) { + if (typeof value === 'string' || value instanceof String || (typeof value === 'number' || value instanceof Number) && !isNaN(value) || typeof value === 'boolean' || value instanceof Boolean || value instanceof Date) { + var stringValue = stringify(value); + var parsedNumber = numberify(stringValue); + var chunks = createChunkMaps(parsedNumber ? "" + parsedNumber : stringValue); + return { + parsedNumber: parsedNumber, + chunks: chunks, + value: value + }; + } + + return { + isArray: Array.isArray(value), + isFunction: isFunction(value), + isNaN: isNaN(value), + isNull: isNull(value), + isObject: isObject(value), + isSymbol: isSymbol(value), + isUndefined: isUndefined(value), + value: value + }; +}; + +var getValueByIdentifier = function getValueByIdentifier(value, getValue) { + return getValue(value); +}; + +var getElementByIndex = function getElementByIndex(collection, index) { + return collection[index]; +}; + +var baseOrderBy = function baseOrderBy(collection, identifiers, orders) { + var identifierFns = identifiers.length ? identifiers.map(createIdentifierFn) : [function (value) { + return value; + }]; // temporary array holds elements with position and sort-values + + var mappedCollection = collection.map(function (element, index) { + var values = identifierFns.map(function (identifier) { + return getValueByIdentifier(element, identifier); + }).map(getMappedValueRecord); + return { + index: index, + values: values + }; + }); // iterate over values and compare values until a != b or last value reached + + mappedCollection.sort(function (recordA, recordB) { + return compareMultiple(recordA, recordB, orders); + }); + return mappedCollection.map(function (element) { + return getElementByIndex(collection, element.index); + }); +}; + +var getIdentifiers = function getIdentifiers(identifiers) { + if (!identifiers) { + return []; + } + + var identifierList = !Array.isArray(identifiers) ? [identifiers] : [].concat(identifiers); + + if (identifierList.some(function (identifier) { + return typeof identifier !== 'string' && typeof identifier !== 'number' && typeof identifier !== 'function'; + })) { + return []; + } + + return identifierList; +}; + +var getOrders = function getOrders(orders) { + if (!orders) { + return []; + } + + var orderList = !Array.isArray(orders) ? [orders] : [].concat(orders); + + if (orderList.some(function (order) { + return order !== 'asc' && order !== 'desc' && typeof order !== 'function'; + })) { + return []; + } + + return orderList; +}; + +/** + * Creates an array of elements, natural sorted by specified identifiers and + * the corresponding sort orders. This method implements a stable sort + * algorithm, which means the original sort order of equal elements is + * preserved. + * + * If `collection` is an array of primitives, `identifiers` may be unspecified. + * Otherwise, you should specify `identifiers` to sort by or `collection` will + * be returned unsorted. An identifier can expressed by: + * + * - an index position, if `collection` is a nested array, + * - a property name, if `collection` is an array of objects, + * - a function which returns a particular value from an element of a nested array or an array of objects. This function will be invoked by passing one element of `collection`. + * + * If `orders` is unspecified, all values are sorted in ascending order. + * Otherwise, specify an order of `'desc'` for descending or `'asc'` for + * ascending sort order of corresponding values. You may also specify a compare + * function for an order, which will be invoked by two arguments: + * `(valueA, valueB)`. It must return a number representing the sort order. + * + * @example + * + * import { orderBy } from 'natural-orderby'; + * + * const users = [ + * { + * username: 'Bamm-Bamm', + * ip: '192.168.5.2', + * datetime: 'Fri Jun 15 2018 16:48:00 GMT+0200 (CEST)' + * }, + * { + * username: 'Wilma', + * ip: '192.168.10.1', + * datetime: '14 Jun 2018 00:00:00 PDT' + * }, + * { + * username: 'dino', + * ip: '192.168.0.2', + * datetime: 'June 15, 2018 14:48:00' + * }, + * { + * username: 'Barney', + * ip: '192.168.1.1', + * datetime: 'Thu, 14 Jun 2018 07:00:00 GMT' + * }, + * { + * username: 'Pebbles', + * ip: '192.168.1.21', + * datetime: '15 June 2018 14:48 UTC' + * }, + * { + * username: 'Hoppy', + * ip: '192.168.5.10', + * datetime: '2018-06-15T14:48:00.000Z' + * }, + * ]; + * + * orderBy( + * users, + * [v => v.datetime, v => v.ip], + * ['desc', 'asc'] + * ); + * + * // => [ + * // { + * // username: 'dino', + * // ip: '192.168.0.2', + * // datetime: 'June 15, 2018 14:48:00', + * // }, + * // { + * // username: 'Pebbles', + * // ip: '192.168.1.21', + * // datetime: '15 June 2018 14:48 UTC', + * // }, + * // { + * // username: 'Bamm-Bamm', + * // ip: '192.168.5.2', + * // datetime: 'Fri Jun 15 2018 16:48:00 GMT+0200 (CEST)', + * // }, + * // { + * // username: 'Hoppy', + * // ip: '192.168.5.10', + * // datetime: '2018-06-15T14:48:00.000Z', + * // }, + * // { + * // username: 'Barney', + * // ip: '192.168.1.1', + * // datetime: 'Thu, 14 Jun 2018 07:00:00 GMT', + * // }, + * // { + * // username: 'Wilma', + * // ip: '192.168.10.1', + * // datetime: '14 Jun 2018 00:00:00 PDT', + * // }, + * // ] + */ +function orderBy(collection, identifiers, orders) { + if (!collection || !Array.isArray(collection)) { + return []; + } + + var validatedIdentifiers = getIdentifiers(identifiers); + var validatedOrders = getOrders(orders); + return baseOrderBy(collection, validatedIdentifiers, validatedOrders); +} + +var baseCompare = function baseCompare(options) { + return function (valueA, valueB) { + var a = getMappedValueRecord(valueA); + var b = getMappedValueRecord(valueB); + var result = compareValues(a, b); + return result * (options.order === 'desc' ? -1 : 1); + }; +}; + +var isValidOrder = function isValidOrder(value) { + return typeof value === 'string' && (value === 'asc' || value === 'desc'); +}; + +var getOptions = function getOptions(customOptions) { + var order = 'asc'; + + if (typeof customOptions === 'string' && isValidOrder(customOptions)) { + order = customOptions; + } else if (customOptions && typeof customOptions === 'object' && customOptions.order && isValidOrder(customOptions.order)) { + order = customOptions.order; + } + + return { + order: order + }; +}; + +/** + * Creates a compare function that defines the natural sort order considering + * the given `options` which may be passed to [`Array.prototype.sort()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort). + * + * If `options` or its property `order` is unspecified, values are sorted in + * ascending sort order. Otherwise, specify an order of `'desc'` for descending + * or `'asc'` for ascending sort order of values. + * + * @example + * + * import { compare } from 'natural-orderby'; + * + * const users = [ + * { + * username: 'Bamm-Bamm', + * lastLogin: { + * ip: '192.168.5.2', + * datetime: 'Fri Jun 15 2018 16:48:00 GMT+0200 (CEST)' + * }, + * }, + * { + * username: 'Wilma', + * lastLogin: { + * ip: '192.168.10.1', + * datetime: '14 Jun 2018 00:00:00 PDT' + * }, + * }, + * { + * username: 'dino', + * lastLogin: { + * ip: '192.168.0.2', + * datetime: 'June 15, 2018 14:48:00' + * }, + * }, + * { + * username: 'Barney', + * lastLogin: { + * ip: '192.168.1.1', + * datetime: 'Thu, 14 Jun 2018 07:00:00 GMT' + * }, + * }, + * { + * username: 'Pebbles', + * lastLogin: { + * ip: '192.168.1.21', + * datetime: '15 June 2018 14:48 UTC' + * }, + * }, + * { + * username: 'Hoppy', + * lastLogin: { + * ip: '192.168.5.10', + * datetime: '2018-06-15T14:48:00.000Z' + * }, + * }, + * ]; + * + * users.sort((a, b) => compare()(a.ip, b.ip)); + * + * // => [ + * // { + * // username: 'dino', + * // ip: '192.168.0.2', + * // datetime: 'June 15, 2018 14:48:00' + * // }, + * // { + * // username: 'Barney', + * // ip: '192.168.1.1', + * // datetime: 'Thu, 14 Jun 2018 07:00:00 GMT' + * // }, + * // { + * // username: 'Pebbles', + * // ip: '192.168.1.21', + * // datetime: '15 June 2018 14:48 UTC' + * // }, + * // { + * // username: 'Bamm-Bamm', + * // ip: '192.168.5.2', + * // datetime: 'Fri Jun 15 2018 16:48:00 GMT+0200 (CEST)' + * // }, + * // { + * // username: 'Hoppy', + * // ip: '192.168.5.10', + * // datetime: '2018-06-15T14:48:00.000Z' + * // }, + * // { + * // username: 'Wilma', + * // ip: '192.168.10.1', + * // datetime: '14 Jun 2018 00:00:00 PDT' + * // } + * // ] + */ +function compare(options) { + var validatedOptions = getOptions(options); + return baseCompare(validatedOptions); +} + +/* +* Javascript natural sort algorithm with unicode support +* based on chunking idea by Dave Koelle +* +* https://github.com/yobacca/natural-sort-order +* released under MIT License +*/ + + + + +/***/ }), + /***/ "./node_modules/papaparse/papaparse.min.js": /*!*************************************************!*\ !*** ./node_modules/papaparse/papaparse.min.js ***! @@ -69,11 +712,13 @@ var __generator = (undefined && undefined.__generator) || function (thisArg, bod }; var Papa = __webpack_require__(/*! papaparse */ "./node_modules/papaparse/papaparse.min.js"); var errors = __webpack_require__(/*! ./errors.js */ "./src/errors.js"); +var compare = __webpack_require__(/*! natural-orderby */ "./node_modules/natural-orderby/esm/natural-orderby.js").compare; var freeDatas2HTML = (function () { function freeDatas2HTML() { this._datasViewElt = { id: "", eltDOM: undefined }; this._datasSourceUrl = ""; this._datasSelectors = []; + this._datasSortingColumns = []; this.parseMeta = undefined; this.parseDatas = []; this.parseErrors = []; @@ -114,10 +759,12 @@ var freeDatas2HTML = (function () { checkContainerExist = document.getElementById(selectionElts[i].id); if (checkContainerExist === null) console.error(errors.elementNotFound + selectionElts[i].id); - else if (Number.isInteger(selectionElts[i].datasFielNb) === false || selectionElts[i].datasFielNb < 0) + else if (Number.isInteger(selectionElts[i].datasFieldNb) === false || selectionElts[i].datasFieldNb < 0) console.error(errors.needNaturalNumber); else { selectionElts[i].eltDOM = checkContainerExist; + if (selectionElts[i].separator !== undefined && selectionElts[i].separator === "") + selectionElts[i].separator = undefined; this._datasSelectors.push(selectionElts[i]); } } @@ -125,6 +772,24 @@ var freeDatas2HTML = (function () { enumerable: false, configurable: true }); + Object.defineProperty(freeDatas2HTML.prototype, "datasSortingColumns", { + get: function () { + return this._datasSortingColumns; + }, + set: function (sortingColumns) { + this._datasSortingColumns = []; + for (var i = 0; i < sortingColumns.length; i++) { + if (Number.isInteger(sortingColumns[i].datasFieldNb) === false || sortingColumns[i].datasFieldNb < 0) + console.error(errors.needNaturalNumber); + else { + sortingColumns[i].order = undefined; + this._datasSortingColumns.push(sortingColumns[i]); + } + } + }, + enumerable: false, + configurable: true + }); freeDatas2HTML.prototype.parse = function () { return __awaiter(this, void 0, void 0, function () { var converter; @@ -162,7 +827,7 @@ var freeDatas2HTML = (function () { }; freeDatas2HTML.prototype.run = function () { return __awaiter(this, void 0, void 0, function () { - var converter_1, selectorsHTML, i, values, colName, row, j, selectElement; + var converter_1, selectorsHTML, i, values, colName, row, checkedValue, checkedValues, i_1, checkedValue, j, selectElement, i; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -179,21 +844,30 @@ var freeDatas2HTML = (function () { console.error(this.parseErrors); else { converter_1 = this; - this.datasHTML = this.createDatasHTML(this.parseMeta.fields, this.parseDatas); - this._datasViewElt.eltDOM.innerHTML = this.datasHTML; if (this._datasSelectors.length > 0) { selectorsHTML = []; for (i in this._datasSelectors) { - if (this._datasSelectors[i].datasFielNb > (this.parseMeta.fields.length - 1)) + if (this._datasSelectors[i].datasFieldNb > (this.parseMeta.fields.length - 1)) throw new Error(errors.selectorFieldNotFound); else { - values = [], colName = this.parseMeta.fields[this._datasSelectors[i].datasFielNb]; + values = [], colName = this.parseMeta.fields[this._datasSelectors[i].datasFieldNb]; for (row in this.parseDatas) { - if (values.indexOf(this.parseDatas[row][colName].trim()) === -1) - values.push(this.parseDatas[row][colName].trim()); + if (this._datasSelectors[i].separator === undefined) { + checkedValue = this.parseDatas[row][colName].trim(); + if (checkedValue !== "" && values.indexOf(checkedValue) === -1) + values.push(checkedValue); + } + else { + checkedValues = this.parseDatas[row][colName].split(this._datasSelectors[i].separator); + for (i_1 in checkedValues) { + checkedValue = checkedValues[i_1].trim(); + if (checkedValue !== "" && values.indexOf(checkedValue) === -1) + values.push(checkedValue); + } + } } if (values.length > 0) { - values.sort(); + values.sort(compare()); this._datasSelectors[i].name = colName; this._datasSelectors[i].values = values; selectorsHTML[i] = "" + colName + " : ----"; @@ -204,12 +878,18 @@ var freeDatas2HTML = (function () { selectElement = document.getElementById("freeDatas2HTMLSelector" + i); selectElement.addEventListener('change', function (e) { converter_1.datasHTML = converter_1.createDatasHTML(converter_1.parseMeta.fields, converter_1.parseDatas); - converter_1._datasViewElt.eltDOM.innerHTML = converter_1.datasHTML; + converter_1.refreshView(); }); } } } } + for (i in this._datasSortingColumns) { + if (this._datasSortingColumns[i].datasFieldNb > (this.parseMeta.fields.length - 1)) + throw new Error(errors.sortingColumnsFieldNotFound); + } + this.datasHTML = this.createDatasHTML(this.parseMeta.fields, this.parseDatas); + this.refreshView(); return [2, true]; } return [2]; @@ -217,12 +897,50 @@ var freeDatas2HTML = (function () { }); }); }; + freeDatas2HTML.prototype.refreshView = function () { + if (this._datasViewElt.eltDOM !== undefined) { + var converter_2 = this; + this._datasViewElt.eltDOM.innerHTML = this.datasHTML; + if (this._datasSortingColumns.length > 0) { + var getTableTh = document.querySelectorAll("table th"); + if (getTableTh !== null) { + var _loop_1 = function (i) { + var datasFieldNb = this_1._datasSortingColumns[i].datasFieldNb; + var htmlContent = getTableTh[datasFieldNb].innerHTML; + htmlContent = "" + htmlContent + ""; + getTableTh[datasFieldNb].innerHTML = htmlContent; + var sortingElement = document.getElementById("freeDatas2HTMLSorting" + datasFieldNb); + sortingElement.addEventListener('click', function (e) { + e.preventDefault(); + var order = converter_2.datasSortingColumns[i].order; + if (order === undefined || order === "desc") + converter_2.datasSortingColumns[i].order = "asc"; + else + converter_2.datasSortingColumns[i].order = "desc"; + converter_2._datasSortedColumn = converter_2.datasSortingColumns[i]; + converter_2.datasHTML = converter_2.createDatasHTML(converter_2.parseMeta.fields, converter_2.parseDatas); + converter_2.refreshView(); + }); + }; + var this_1 = this; + for (var i in this._datasSortingColumns) { + _loop_1(i); + } + } + } + } + }; freeDatas2HTML.prototype.createDatasHTML = function (fields, datas) { var checkSelectorExist, filters = []; for (var i in this._datasSelectors) { checkSelectorExist = document.querySelector("#" + this._datasSelectors[i].id + " select"); - if (checkSelectorExist != null && checkSelectorExist.value != "0") - filters.push({ field: this._datasSelectors[i].name, value: this._datasSelectors[i].values[checkSelectorExist.selectedIndex - 1] }); + if (checkSelectorExist != null && checkSelectorExist.selectedIndex != 0) + filters.push({ field: this._datasSelectors[i].name, value: this._datasSelectors[i].values[checkSelectorExist.selectedIndex - 1], separator: this._datasSelectors[i].separator }); + } + if (this._datasSortedColumn !== undefined) { + var col_1 = fields[this._datasSortedColumn.datasFieldNb]; + var colOrder_1 = this._datasSortedColumn.order; + datas.sort(function (a, b) { return compare({ order: colOrder_1 })(a[col_1], b[col_1]); }); } var datasHTML = ""; for (var i in fields) @@ -232,8 +950,21 @@ var freeDatas2HTML = (function () { var visible = true; if (filters.length !== 0) { for (var i in filters) { - if (datas[row][filters[i].field].trim() != filters[i].value) - visible = false; + if (filters[i].separator === undefined) { + if (datas[row][filters[i].field].trim() != filters[i].value) + visible = false; + } + else { + var checkedValues = datas[row][filters[i].field].split(filters[i].separator), finded = false; + for (var j in checkedValues) { + if (checkedValues[j].trim() === filters[i].value) { + finded = true; + break; + } + } + if (!finded) + visible = false; + } } } if (visible) { @@ -270,6 +1001,7 @@ module.exports = needUrl: "Merci de fournir une url valide pour le fichier CSV à parser.", parserFail: "La lecture des données du fichier a échoué.", selectorFieldNotFound: "Au moins une des colonnes devant servir à filtrer les données n'existe pas dans le fichier.", + sortingColumnsFieldNotFound: "Au moins une des colonnes devant servir à classer les données n'existe pas dans le fichier.", }; /***/ }) @@ -384,7 +1116,8 @@ var initialise = function () { return __awaiter(void 0, void 0, void 0, function _a.trys.push([0, 2, , 3]); converter = new _freeDatas2HTML__WEBPACK_IMPORTED_MODULE_0__.freeDatas2HTML(); converter.datasViewElt = { id: "datas" }; - converter.datasSelectors = [{ datasFielNb: 3, id: "filtre1" }, { datasFielNb: 4, id: "filtre2" }]; + converter.datasSelectors = [{ datasFieldNb: 3, id: "filtre1" }, { datasFieldNb: 4, id: "filtre2" }, { datasFieldNb: 5, id: "filtre3", separator: "," }]; + converter.datasSortingColumns = [{ datasFieldNb: 0 }, { datasFieldNb: 1 }, { datasFieldNb: 2 }]; converter.datasSourceUrl = "http://localhost:8080/datas/elements-chimiques.csv"; return [4, converter.run()]; case 1: @@ -406,4 +1139,4 @@ initialise(); /******/ })() ; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9KUy9maXJzdEV4YW1wbGUuYXBwLmpzIiwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUF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pLmRvbmUpIHJldHVybiB0O1xuICAgICAgICAgICAgaWYgKHkgPSAwLCB0KSBvcCA9IFtvcFswXSAmIDIsIHQudmFsdWVdO1xuICAgICAgICAgICAgc3dpdGNoIChvcFswXSkge1xuICAgICAgICAgICAgICAgIGNhc2UgMDogY2FzZSAxOiB0ID0gb3A7IGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgNDogXy5sYWJlbCsrOyByZXR1cm4geyB2YWx1ZTogb3BbMV0sIGRvbmU6IGZhbHNlIH07XG4gICAgICAgICAgICAgICAgY2FzZSA1OiBfLmxhYmVsKys7IHkgPSBvcFsxXTsgb3AgPSBbMF07IGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgIGNhc2UgNzogb3AgPSBfLm9wcy5wb3AoKTsgXy50cnlzLnBvcCgpOyBjb250aW51ZTtcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICBpZiAoISh0ID0gXy50cnlzLCB0ID0gdC5sZW5ndGggPiAwICYmIHRbdC5sZW5ndGggLSAxXSkgJiYgKG9wWzBdID09PSA2IHx8IG9wWzBdID09PSAyKSkgeyBfID0gMDsgY29udGludWU7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKG9wWzBdID09PSAzICYmICghdCB8fCAob3BbMV0gPiB0WzBdICYmIG9wWzFdIDwgdFszXSkpKSB7IF8ubGFiZWwgPSBvcFsxXTsgYnJlYWs7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKG9wWzBdID09PSA2ICYmIF8ubGFiZWwgPCB0WzFdKSB7IF8ubGFiZWwgPSB0WzFdOyB0ID0gb3A7IGJyZWFrOyB9XG4gICAgICAgICAgICAgICAgICAgIGlmICh0ICYmIF8ubGFiZWwgPCB0WzJdKSB7IF8ubGFiZWwgPSB0WzJdOyBfLm9wcy5wdXNoKG9wKTsgYnJlYWs7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRbMl0pIF8ub3BzLnBvcCgpO1xuICA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uICAgICAgICBnZXQ6IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9kYXRhc1NlbGVjdG9ycztcbiAgICAgICAgfSxcbiAgICAgICAgc2V0OiBmdW5jdGlvbiAoc2VsZWN0aW9uRWx0cykge1xuICAgICAgICAgICAgdGhpcy5fZGF0YXNTZWxlY3RvcnMgPSBbXTtcbiAgICAgICAgICAgIHZhciBjaGVja0NvbnRhaW5lckV4aXN0O1xuICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBzZWxlY3Rpb25FbHRzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgY2hlY2tDb250YWluZXJFeGlzdCA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKHNlbGVjdGlvbkVsdHNbaV0uaWQpO1xuICAgICAgICAgICAgICAgIGlmIChjaGVja0NvbnRhaW5lckV4aXN0ID09PSBudWxsKVxuICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKGVycm9ycy5lbGVtZW50Tm90Rm91bmQgKyBzZWxlY3Rpb25FbHRzW2ldLmlkKTtcbiAgICAgICAgICAgICAgICBlbHNlIGlmIChOdW1iZXIuaXNJbnRlZ2VyKHNlbGVjdGlvbkVsdHNbaV0uZGF0YXNGaWVsTmIpID09PSBmYWxzZSB8fCBzZWxlY3Rpb25FbHRzW2ldLmRhdGFzRmllbE5iIDwgMClcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihlcnJvcnMubmVlZE5hdHVyYWxOdW1iZXIpO1xuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzZWxlY3Rpb25FbHRzW2ldLmVsdERPTSA9IGNoZWNrQ29udGFpbmVyRXhpc3Q7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2RhdGFzU2VsZWN0b3JzLnB1c2goc2VsZWN0aW9uRWx0c1tpXSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlXG4gICAgfSk7XG4gICAgZnJlZURhdGFzMkhUTUwucHJvdG90eXBlLnBhcnNlID0gZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgY29udmVydGVyO1xuICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIGZ1bmN0aW9uIChfYSkge1xuICAgICAgICAgICAgICAgIGNvbnZlcnRlciA9IHRoaXM7XG4gICAgICAgICAgICAgICAgcmV0dXJuIFsyLCBuZXcgUHJvbWlzZShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29udmVydGVyLl9kYXRhc1NvdXJjZVVybCAhPT0gXCJcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBhcGEucGFyc2UoY29udmVydGVyLl9kYXRhc1NvdXJjZVVybCwge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdW90ZUNoYXI6ICdcIicsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGhlYWRlcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29tcGxldGU6IGZ1bmN0aW9uIChyZXN1bHRzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0ZXIucGFyc2VFcnJvcnMgPSByZXN1bHRzLmVycm9ycztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRlci5wYXJzZURhdGFzID0gcmVzdWx0cy5kYXRhO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJlYWxGaWVsZHMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGkgaW4gcmVzdWx0cy5tZXRhLmZpZWxkcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChyZXN1bHRzLm1ldGEuZmllbGRzW2ldLnRyaW0oKSAhPT0gXCJcIilcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVhbEZpZWxkcy5wdXNoKHJlc3VsdHMubWV0YS5maWVsZHNbaV0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzdWx0cy5tZXRhLmZpZWxkcyA9IHJlYWxGaWVsZHM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0ZXIucGFyc2VNZXRhID0gcmVzdWx0cy5tZXRhO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZSh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3I6IGZ1bmN0aW9uIChlcnJvcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihlcnJvcnMucGFyc2VyRmFpbCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBkb3dubG9hZDogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2tpcEVtcHR5TGluZXM6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVqZWN0KG5ldyBFcnJvcihlcnJvcnMubmVlZFVybCkpO1xuICAgICAgICAgICAgICAgICAgICB9KV07XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfTtcbiAgICBmcmVlRGF0YXMySFRNTC5wcm90b3R5cGUucnVuID0gZnVuY3Rpb24gKCkge1xuICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICB2YXIgY29udmVydGVyXzEsIHNlbGVjdG9yc0hUTUwsIGksIHZhbHVlcywgY29sTmFtZSwgcm93LCBqLCBzZWxlY3RFbGVtZW50O1xuICAgICAgICAgICAgcmV0dXJuIF9fZ2VuZXJhdG9yKHRoaXMsIGZ1bmN0aW9uIChfYSkge1xuICAgICAgICAgICAgICAgIHN3aXRjaCAoX2EubGFiZWwpIHtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAwOlxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RhdGFzVmlld0VsdC5lbHRET00gPT09IHVuZGVmaW5lZClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoZXJyb3JzLm5lZWREYXRhc0VsdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGF0YXNTb3VyY2VVcmwgPT09IFwiXCIpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGVycm9ycy5uZWVkVXJsKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbNCwgdGhpcy5wYXJzZSgpXTtcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAxOlxuICAgICAgICAgICAgICAgICAgICAgICAgX2Euc2VudCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMucGFyc2VEYXRhcy5sZW5ndGggPT09IDAgfHwgdGhpcy5wYXJzZU1ldGEuZmllbGRzID09PSB1bmRlZmluZWQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGVycm9ycy5kYXRhc05vdEZvdW5kKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKHRoaXMuc3RvcElmUGFyc2VFcnJvcnMgJiYgdGhpcy5wYXJzZUVycm9ycy5sZW5ndGggIT09IDApXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcih0aGlzLnBhcnNlRXJyb3JzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRlcl8xID0gdGhpcztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmRhdGFzSFRNTCA9IHRoaXMuY3JlYXRlRGF0YXNIVE1MKHRoaXMucGFyc2VNZXRhLmZpZWxkcywgdGhpcy5wYXJzZURhdGFzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kYXRhc1ZpZXdFbHQuZWx0RE9NLmlubmVySFRNTCA9IHRoaXMuZGF0YXNIVE1MO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kYXRhc1NlbGVjdG9ycy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdG9yc0hUTUwgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpIGluIHRoaXMuX2RhdGFzU2VsZWN0b3JzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGF0YXNTZWxlY3RvcnNbaV0uZGF0YXNGaWVsTmIgPiAodGhpcy5wYXJzZU1ldGEuZmllbGRzLmxlbmd0aCAtIDEpKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMuc2VsZWN0b3JGaWVsZE5vdEZvdW5kKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlcyA9IFtdLCBjb2xOYW1lID0gdGhpcy5wYXJzZU1ldGEuZmllbGRzW3RoaXMuX2RhdGFzU2VsZWN0b3JzW2ldLmRhdGFzRmllbE5iXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHJvdyBpbiB0aGlzLnBhcnNlRGF0YXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlcy5pbmRleE9mKHRoaXMucGFyc2VEYXRhc1tyb3ddW2NvbE5hbWVdLnRyaW0oKSkgPT09IC0xKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzLnB1c2godGhpcy5wYXJzZURhdGFzW3Jvd11bY29sTmFtZV0udHJpbSgpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlcy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlcy5zb3J0KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RhdGFzU2VsZWN0b3JzW2ldLm5hbWUgPSBjb2xOYW1lO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLl9kYXRhc1NlbGVjdG9yc1tpXS52YWx1ZXMgPSB2YWx1ZXM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdG9yc0hUTUxbaV0gPSBcIjxsYWJlbCBmb3I9J2ZyZWVEYXRhczJIVE1MU2VsZWN0b3JcIiArIGkgKyBcIic+XCIgKyBjb2xOYW1lICsgXCIgOiA8L2xhYmVsPjxzZWxlY3QgbmFtZT0nZnJlZURhdGFzMkhUTUxTZWxlY3RvclwiICsgaSArIFwiJyBpZD0nZnJlZURhdGFzMkhUTUxTZWxlY3RvclwiICsgaSArIFwiJz48b3B0aW9uIHZhbHVlPScwJz4tLS0tPC9vcHRpb24+XCI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoaiBpbiB2YWx1ZXMpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RvcnNIVE1MW2ldICs9IFwiPG9wdGlvbiB2YWx1ZT0nXCIgKyAoTnVtYmVyKGopICsgMSkgKyBcIic+XCIgKyB2YWx1ZXNbal0gKyBcIjwvb3B0aW9uPlwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RvcnNIVE1MW2ldICs9IFwiPC9zZWxlY3Q+XCI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RhdGFzU2VsZWN0b3JzW2ldLmVsdERPTS5pbm5lckhUTUwgPSBzZWxlY3RvcnNIVE1MW2ldO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50ID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoXCJmcmVlRGF0YXMySFRNTFNlbGVjdG9yXCIgKyBpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0RWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCdjaGFuZ2UnLCBmdW5jdGlvbiAoZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udmVydGVyXzEuZGF0YXNIVE1MID0gY29udmVydGVyXzEuY3JlYXRlRGF0YXNIVE1MKGNvbnZlcnRlcl8xLnBhcnNlTWV0YS5maWVsZHMsIGNvbnZlcnRlcl8xLnBhcnNlRGF0YXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udmVydGVyXzEuX2RhdGFzVmlld0VsdC5lbHRET00uaW5uZXJIVE1MID0gY29udmVydGVyXzEuZGF0YXNIVE1MO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFsyLCB0cnVlXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMl07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH07XG4gICAgZnJlZURhdGFzMkhUTUwucHJvdG90eXBlLmNyZWF0ZURhdGFzSFRNTCA9IGZ1bmN0aW9uIChmaWVsZHMsIGRhdGFzKSB7XG4gICAgICAgIHZhciBjaGVja1NlbGVjdG9yRXhpc3QsIGZpbHRlcnMgPSBbXTtcbiAgICAgICAgZm9yICh2YXIgaSBpbiB0aGlzLl9kYXRhc1NlbGVjdG9ycykge1xuICAgICAgICAgICAgY2hlY2tTZWxlY3RvckV4aXN0ID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcihcIiNcIiArIHRoaXMuX2RhdGFzU2VsZWN0b3JzW2ldLmlkICsgXCIgc2VsZWN0XCIpO1xuICAgICAgICAgICAgaWYgKGNoZWNrU2VsZWN0b3JFeGlzdCAhPSBudWxsICYmIGNoZWNrU2VsZWN0b3JFeGlzdC52YWx1ZSAhPSBcIjBcIilcbiAgICAgICAgICAgICAgICBmaWx0ZXJzLnB1c2goeyBmaWVsZDogdGhpcy5fZGF0YXNTZWxlY3RvcnNbaV0ubmFtZSwgdmFsdWU6IHRoaXMuX2RhdGFzU2VsZWN0b3JzW2ldLnZhbHVlc1tjaGVja1NlbGVjdG9yRXhpc3Quc2VsZWN0ZWRJbmRleCAtIDFdIH0pO1xuICAgICAgICB9XG4gICAgICAgIHZhciBkYXRhc0hUTUwgPSBcIjx0YWJsZT48dGhlYWQ+XCI7XG4gICAgICAgIGZvciAodmFyIGkgaW4gZmllbGRzKVxuICAgICAgICAgICAgZGF0YXNIVE1MICs9IFwiPHRoPlwiICsgZmllbGRzW2ldICsgXCI8L3RoPlwiO1xuICAgICAgICBkYXRhc0hUTUwgKz0gXCI8L3RoZWFkPjx0Ym9keT5cIjtcbiAgICAgICAgZm9yICh2YXIgcm93IGluIGRhdGFzKSB7XG4gICAgICAgICAgICB2YXIgdmlzaWJsZSA9IHRydWU7XG4gICAgICAgICAgICBpZiAoZmlsdGVycy5sZW5ndGggIT09IDApIHtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpIGluIGZpbHRlcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFzW3Jvd11bZmlsdGVyc1tpXS5maWVsZF0udHJpbSgpICE9IGZpbHRlcnNbaV0udmFsdWUpXG4gICAgICAgICAgICAgICAgICAgICAgICB2aXNpYmxlID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHZpc2libGUpIHtcbiAgICAgICAgICAgICAgICBkYXRhc0hUTUwgKz0gXCI8dHI+XCI7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgZmllbGQgaW4gZGF0YXNbcm93XSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZmllbGRzL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H07XG4gICAgICAgICAgICAgICAgY2FzZSA1OiBfLmxhYmVsKys7IHkgPSBvcFsxXTsgb3AgPSBbMF07IGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgIGNhc2UgNzogb3AgPSBfLm9wcy5wb3AoKTsgXy50cnlzLnBvcCgpOyBjb250aW51ZTtcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICBpZiAoISh0ID0gXy50cnlzLCB0ID0gdC5sZW5ndGggPiAwICYmIHRbdC5sZW5ndGggLSAxXSkgJiYgKG9wWzBdID09PSA2IHx8IG9wWzBdID09PSAyKSkgeyBfID0gMDsgY29udGludWU7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKG9wWzBdID09PSAzICYmICghdCB8fCAob3BbMV0gPiB0WzBdICYmIG9wWzFdIDwgdFszXSkpKSB7IF8ubGFiZWwgPSBvcFsxXTsgYnJlYWs7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKG9wWzBdID09PSA2ICYmIF8ubGFiZWwgPCB0WzFdKSB7IF8ubGFiZWwgPSB0WzFdOyB0ID0gb3A7IGJyZWFrOyB9XG4gICAgICAgICAgICAgICAgICAgIGlmICh0ICYmIF8ubGFiZWwgPCB0WzJdKSB7IF8ubGFiZWwgPSB0WzJdOyBfLm9wcy5wdXNoKG9wKTsgYnJlYWs7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHRbMl0pIF8ub3BzLnBvcCgpO1xuICAgICAgICAgICAgICAgICAgICBfLnRyeXMucG9wKCk7IGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgb3AgPSBib2R5LmNhbGwodGhpc0FyZywgXyk7XG4gICAgICAgIH0gY2F0Y2ggKGUpIHsgb3AgPSBbNiwgZV07IHkgPSAwOyB9IGZpbmFsbHkgeyBmID0gdCA9IDA7IH1cbiAgICAgICAgaWYgKG9wWzBdICYgNSkgdGhyb3cgb3BbMV07IHJldHVybiB7IHZhbHVlOiB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ICAgICAgICBlXzEgPSBfYS5zZW50KCk7XG4gICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihlXzEpO1xuICAgICAgICAgICAgICAgIGlmIChkb2N1bWVudC5nZXRFbGVtZW50QnlJZChcImRhdGFzXCIpICE9PSBudWxsKVxuICAgICAgICAgICAgICAgICAgICBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChcImRhdGFzXCIpLmlubmVySFRNTCA9IFwiPHN0cm9uZz5Ew6lzb2zDqSwgbWFpcyB1biBwcm9ibMOobWUgdGVjaG5pcXVlIGVtcMOqY2hlIGwnYWZmaWNoYWdlIGRlcyBkb25uw6llcy48L3N0cm9uZz5cIjtcbiAgICAgICAgICAgICAgICByZXR1cm4gWzMsIDNdO1xuICAgICAgICAgICAgY2FzZSAzOiByZXR1cm4gWzJdO1xuICAgICAgICB9XG4gICAgfSk7XG59KTsgfTtcbmluaXRpYWxpc2UoKTtcbiJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ== \ No newline at end of file +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi9KUy9maXJzdEV4YW1wbGUuYXBwLmpzIiwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7OztBQUFBO0FBQ0E7QUFDQTtBQUNBOztBQUVBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBOztBQUVBO0FBQ0EsdURBQXVEOztBQUV2RCw2QkFBNkI7O0FBRTdCLHlFQUF5RTs7QUFFekUseUVBQXlFLElBQUksT0FBTyxJQUFJLE9BQU8sSUFBSSxtQkFBbUIsRUFBRSxJQUFJOztBQUU1SCxnQ0FBZ0MsRUFBRTtBQUNsQzs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQTs7QUFFQTtBQUNBO0FBQ0E7QUFDQTs7QUFFQSxrQkFBa0IsV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Chbbiwgdl0pOyB9OyB9XG4gICAgZnVuY3Rpb24gc3RlcChvcCkge1xuICAgICAgICBpZiAoZikgdGhyb3cgbmV3IFR5cGVFcnJvcihcIkdlbmVyYXRvciBpcyBhbHJlYWR5IGV4ZWN1dGluZy5cIik7XG4gICAgICAgIHdoaWxlIChfKSB0cnkge1xuICAgICAgICAgICAgaWYgKGYgPSAxLCB5ICYmICh0ID0gb3BbMF0gJiAyID8geVtcInJldHVyblwiXSA6IG9wWzBdID8geVtcInRocm93XCJdIHx8ICgodCA9IHlbXCJyZXR1cm5cIl0pICYmIHQuY2FsbCh5KSwgMCkgOiB5Lm5leHQpICYmICEodCA9IHQuY2FsbCh5LCBvcFsxXSkpLmRvbmUpIHJldHVybiB0O1xuICAgICAgICAgICAgaWYgKHkgPSAwLCB0KSBvcCA9IFtvcFswXSAmIDIsIHQudmFsdWVdO1xuICAgICAgICAgICAgc3dpdGNoIChvcFswXSkge1xuICAgICAgICAgICAgICAgIGNhc2UgMDogY2FzZSAxOiB0ID0gb3A7IGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgNDogXy5sYWJlbCsrOyByZXR1cm4geyB2YWx1ZTogb3BbMV0sIGRvbmU6IGZhbHNlIH07XG4gICAgICAgICAgICAgICAgY2FzZSA1OiBfLmxhYmVsKys7IHkgPSBvcFsxXTsgb3AgPSBbMF07IGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgIGNhc2UgNzogb3AgPSBfLm9wcy5wb3AoKTsgXy50cnlzLnBvcCgpOyBjb250aW51ZTtcbiAgICAgICAgICAgICAgICBkZWZhdWx0OlxuICAgICAgICAgICAgICAgICAgICBpZiAoISh0ID0gXy50cnlzLCB0ID0gdC5sZW5ndGggPiAwICYmIHRbdC5sZW5ndGggLSAxXSkgJiYgKG9wWzBdID09PSA2IHx8IG9wWzBdID09PSAyKSkgeyBfID0gMDsgY29udGludWU7IH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKG9wWzBdID09PSAzICYmICghdCB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lzLl9kYXRhc1NvdXJjZVVybCA9IFwiXCI7XG4gICAgICAgIHRoaXMuX2RhdGFzU2VsZWN0b3JzID0gW107XG4gICAgICAgIHRoaXMuX2RhdGFzU29ydGluZ0NvbHVtbnMgPSBbXTtcbiAgICAgICAgdGhpcy5wYXJzZU1ldGEgPSB1bmRlZmluZWQ7XG4gICAgICAgIHRoaXMucGFyc2VEYXRhcyA9IFtdO1xuICAgICAgICB0aGlzLnBhcnNlRXJyb3JzID0gW107XG4gICAgICAgIHRoaXMuZGF0YXNIVE1MID0gXCJcIjtcbiAgICAgICAgdGhpcy5zdG9wSWZQYXJzZUVycm9ycyA9IGZhbHNlO1xuICAgIH1cbiAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoZnJlZURhdGFzMkhUTUwucHJvdG90eXBlLCBcImRhdGFzVmlld0VsdFwiLCB7XG4gICAgICAgIHNldDogZnVuY3Rpb24gKGVsdCkge1xuICAgICAgICAgICAgdmFyIGNoZWNrQ29udGFpbmVyRXhpc3QgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChlbHQuaWQpO1xuICAgICAgICAgICAgaWYgKGNoZWNrQ29udGFpbmVyRXhpc3QgPT09IG51bGwpXG4gICAgICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGVycm9ycy5lbGVtZW50Tm90Rm91bmQgKyBlbHQuaWQpO1xuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgdGhpcy5fZGF0YXNWaWV3RWx0LmlkID0gZWx0LmlkO1xuICAgICAgICAgICAgICAgIHRoaXMuX2RhdGFzVmlld0VsdC5lbHRET00gPSBjaGVja0NvbnRhaW5lckV4aXN0O1xuICAgICAgICAgICAgfVxuICAgICAgICB9LFxuICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlXG4gICAgfSk7XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGZyZWVEYXRhczJIVE1MLnByb3RvdHlwZSwgXCJkYXRhc1NvdXJjZVVybFwiLCB7XG4gICAgICAgIHNldDogZnVuY3Rpb24gKHVybCkge1xuICAgICAgICAgICAgaWYgKHVybC50cmltKCkubGVuZ3RoID09PSAwKVxuICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMubmVlZFVybCk7XG4gICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgdGhpcy5fZGF0YXNTb3VyY2VVcmwgPSB1cmwudHJpbSgpO1xuICAgICAgICB9LFxuICAgICAgICBlbnVtZXJhYmxlOiBmYWxzZSxcbiAgICAgICAgY29uZmlndXJhYmxlOiB0cnVlXG4gICAgfSk7XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KGZyZWVEYXRhczJIVE1MLnByb3RvdHlwZSwgXCJkYXRhc1NlbGVjdG9yc1wiLCB7XG4gICAgICAgIGdldDogZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuX2RhdGFzU2VsZWN0b3JzO1xuICAgICAgICB9LFxuICAgICAgICBzZXQ6IGZ1bmN0aW9uIChzZWxlY3Rpb25FbHRzKSB7XG4gICAgICAgICAgICB0aGlzLl9kYXRhc1NlbGVjdG9ycyA9IFtdO1xuICAgICAgICAgICAgdmFyIGNoZWNrQ29udGFpbmVyRXhpc3Q7XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNlbGVjdGlvbkVsdHMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICBjaGVja0NvbnRhaW5lckV4aXN0ID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoc2VsZWN0aW9uRWx0c1tpXS5pZCk7XG4gICAgICAgICAgICAgICAgaWYgKGNoZWNrQ29udGFpbmVyRXhpc3QgPT09IG51bGwpXG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3IoZXJyb3JzLmVsZW1lbnROb3RGb3VuZCArIHNlbGVjdGlvbkVs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5zKSB7XG4gICAgICAgICAgICB0aGlzLl9kYXRhc1NvcnRpbmdDb2x1bW5zID0gW107XG4gICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IHNvcnRpbmdDb2x1bW5zLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKE51bWJlci5pc0ludGVnZXIoc29ydGluZ0NvbHVtbnNbaV0uZGF0YXNGaWVsZE5iKSA9PT0gZmFsc2UgfHwgc29ydGluZ0NvbHVtbnNbaV0uZGF0YXNGaWVsZE5iIDwgMClcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihlcnJvcnMubmVlZE5hdHVyYWxOdW1iZXIpO1xuICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBzb3J0aW5nQ29sdW1uc1tpXS5vcmRlciA9IHVuZGVmaW5lZDtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGF0YXNTb3J0aW5nQ29sdW1ucy5wdXNoKHNvcnRpbmdDb2x1bW5zW2ldKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0sXG4gICAgICAgIGVudW1lcmFibGU6IGZhbHNlLFxuICAgICAgICBjb25maWd1cmFibGU6IHRydWVcbiAgICB9KTtcbiAgICBmcmVlRGF0YXMySFRNTC5wcm90b3R5cGUucGFyc2UgPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiBfX2F3YWl0ZXIodGhpcywgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBjb252ZXJ0ZXI7XG4gICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgZnVuY3Rpb24gKF9hKSB7XG4gICAgICAgICAgICAgICAgY29udmVydGVyID0gdGhpcztcbiAgICAgICAgICAgICAgICByZXR1cm4gWzIsIG5ldyBQcm9taXNlKGZ1bmN0aW9uIChyZXNvbHZlLCByZWplY3QpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjb252ZXJ0ZXIuX2RhdGFzU291cmNlVXJsICE9PSBcIlwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgUGFwYS5wYXJzZShjb252ZXJ0ZXIuX2RhdGFzU291cmNlVXJsLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1b3RlQ2hhcjogJ1wiJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaGVhZGVyOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb21wbGV0ZTogZnVuY3Rpb24gKHJlc3VsdHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRlci5wYXJzZUVycm9ycyA9IHJlc3VsdHMuZXJyb3JzO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udmVydGVyLnBhcnNlRGF0YXMgPSByZXN1bHRzLmRhdGE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVhbEZpZWxkcyA9IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSBpbiByZXN1bHRzLm1ldGEuZmllbGRzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHJlc3VsdHMubWV0YS5maWVsZHNbaV0udHJpbSgpICE9PSBcIlwiKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWFsRmllbGRzLnB1c2gocmVzdWx0cy5tZXRhLmZpZWxkc1tpXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzLm1ldGEuZmllbGRzID0gcmVhbEZpZWxkcztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRlci5wYXJzZU1ldGEgPSByZXN1bHRzLm1ldGE7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcjogZnVuY3Rpb24gKGVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVycm9yKGVycm9ycy5wYXJzZXJGYWlsKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvd25sb2FkOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBza2lwRW1wdHlMaW5lczogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZWplY3QobmV3IEVycm9yKGVycm9ycy5uZWVkVXJsKSk7XG4gICAgICAgICAgICAgICAgICAgIH0pXTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9O1xuICAgIGZyZWVEYXRhczJIVE1MLnByb3RvdHlwZS5ydW4gPSBmdW5jdGlvbiAoKSB7XG4gICAgICAgIHJldHVybiBfX2F3YWl0ZXIodGhpcywgdm9pZCAwLCB2b2lkIDAsIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHZhciBjb252ZXJ0ZXJfMSwgc2VsZWN0b3JzSFRNTCwgaSwgdmFsdWVzLCBjb2xOYW1lLCByb3csIGNoZWNrZWRWYWx1ZSwgY2hlY2tlZFZhbHVlcywgaV8xLCBjaGVja2VkVmFsdWUsIGosIHNlbGVjdEVsZW1lbnQsIGk7XG4gICAgICAgICAgICByZXR1cm4gX19nZW5lcmF0b3IodGhpcywgZnVuY3Rpb24gKF9hKSB7XG4gICAgICAgICAgICAgICAgc3dpdGNoIChfYS5sYWJlbCkge1xuICAgICAgICAgICAgICAgICAgICBjYXNlIDA6XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGF0YXNWaWV3RWx0LmVsdERPTSA9PT0gdW5kZWZpbmVkKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMubmVlZERhdGFzRWx0KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kYXRhc1NvdXJjZVVybCA9PT0gXCJcIilcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoZXJyb3JzLm5lZWRVcmwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFs0LCB0aGlzLnBhcnNlKCldO1xuICAgICAgICAgICAgICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICAgICAgICAgICAgICBfYS5zZW50KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5wYXJzZURhdGFzLmxlbmd0aCA9PT0gMCB8fCB0aGlzLnBhcnNlTWV0YS5maWVsZHMgPT09IHVuZGVmaW5lZClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoZXJyb3JzLmRhdGFzTm90Rm91bmQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiAodGhpcy5zdG9wSWZQYXJzZUVycm9ycyAmJiB0aGlzLnBhcnNlRXJyb3JzLmxlbmd0aCAhPT0gMClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmVycm9yKHRoaXMucGFyc2VFcnJvcnMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29udmVydGVyXzEgPSB0aGlzO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLl9kYXRhc1NlbGVjdG9ycy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdG9yc0hUTUwgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpIGluIHRoaXMuX2RhdGFzU2VsZWN0b3JzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGF0YXNTZWxlY3RvcnNbaV0uZGF0YXNGaWVsZE5iID4gKHRoaXMucGFyc2VNZXRhLmZpZWxkcy5sZW5ndGggLSAxKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoZXJyb3JzLnNlbGVjdG9yRmllbGROb3RGb3VuZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZXMgPSBbXSwgY29sTmFtZSA9IHRoaXMucGFyc2VNZXRhLmZpZWxkc1t0aGlzLl9kYXRhc1NlbGVjdG9yc1tpXS5kYXRhc0ZpZWxkTmJdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAocm93IGluIHRoaXMucGFyc2VEYXRhcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodGhpcy5fZGF0YXNTZWxlY3RvcnNbaV0uc2VwYXJhdG9yID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrZWRWYWx1ZSA9IHRoaXMucGFyc2VEYXRhc1tyb3ddW2NvbE5hbWVdLnRyaW0oKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChjaGVja2VkVmFsdWUgIT09IFwiXCIgJiYgdmFsdWVzLmluZGV4T2YoY2hlY2tlZFZhbHVlKSA9PT0gLTEpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzLnB1c2goY2hlY2tlZFZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrZWRWYWx1ZXMgPSB0aGlzLnBhcnNlRGF0YXNbcm93XVtjb2xOYW1lXS5zcGxpdCh0aGlzLl9kYXRhc1NlbGVjdG9yc1tpXS5zZXBhcmF0b3IpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpXzEgaW4gY2hlY2tlZFZhbHVlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoZWNrZWRWYWx1ZSA9IGNoZWNrZWRWYWx1ZXNbaV8xXS50cmltKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNoZWNrZWRWYWx1ZSAhPT0gXCJcIiAmJiB2YWx1ZXMuaW5kZXhPZihjaGVja2VkVmFsdWUpID09PSAtMSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzLnB1c2goY2hlY2tlZFZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodmFsdWVzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWVzLnNvcnQoY29tcGFyZSgpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGF0YXNTZWxlY3RvcnNbaV0ubmFtZSA9IGNvbE5hbWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMuX2RhdGFzU2VsZWN0b3JzW2ldLnZhbHVlcyA9IHZhbHVlcztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0b3JzSFRNTFtpXSA9IFwiPGxhYmVsIGZvcj0nZnJlZURhdGFzMkhUTUxTZWxlY3RvclwiICsgaSArIFwiJz5cIiArIGNvbE5hbWUgKyBcIiA6IDwvbGFiZWw+PHNlbGVjdCBuYW1lPSdmcmVlRGF0YXMySFRNTFNlbGVjdG9yXCIgKyBpICsgXCInIGlkPSdmcmVlRGF0YXMySFRNTFNlbGVjdG9yXCIgKyBpICsgXCInPjxvcHRpb24gdmFsdWU9JzAnPi0tLS08L29wdGlvbj5cIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChqIGluIHZhbHVlcylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdG9yc0hUTUxbaV0gKz0gXCI8b3B0aW9uIHZhbHVlPSdcIiArIChOdW1iZXIoaikgKyAxKSArIFwiJz5cIiArIHZhbHVlc1tqXSArIFwiPC9vcHRpb24+XCI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdG9yc0hUTUxbaV0gKz0gXCI8L3NlbGVjdD5cIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5fZGF0YXNTZWxlY3RvcnNbaV0uZWx0RE9NLmlubmVySFRNTCA9IHNlbGVjdG9yc0hUTUxbaV07XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHNlbGVjdEVsZW1lbnQgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZChcImZyZWVEYXRhczJIVE1MU2VsZWN0b3JcIiArIGkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RFbGVtZW50LmFkZEV2ZW50TGlzdGVuZXIoJ2NoYW5nZScsIGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0ZXJfMS5kYXRhc0hUTUwgPSBjb252ZXJ0ZXJfMS5jcmVhdGVEYXRhc0hUTUwoY29udmVydGVyXzEucGFyc2VNZXRhLmZpZWxkcywgY29udmVydGVyXzEucGFyc2VEYXRhcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0ZXJfMS5yZWZyZXNoVmlldygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpIGluIHRoaXMuX2RhdGFzU29ydGluZ0NvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMuX2RhdGFzU29ydGluZ0NvbHVtbnNbaV0uZGF0YXNGaWVsZE5iID4gKHRoaXMucGFyc2VNZXRhLmZpZWxkcy5sZW5ndGggLSAxKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihlcnJvcnMuc29ydGluZ0NvbHVtbnNGaWVsZE5vdEZvdW5kKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5kYXRhc0hUTUwgPSB0aGlzLmNyZWF0ZURhdGFzSFRNTCh0aGlzLnBhcnNlTWV0YS5maWVsZHMsIHRoaXMucGFyc2VEYXRhcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yZWZyZXNoVmlldygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBbMiwgdHJ1ZV07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gWzJdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9O1xuICAgIGZyZWVEYXRhczJIVE1MLnByb3RvdHlwZS5yZWZyZXNoVmlldyA9IGZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKHRoaXMuX2RhdGFzVmlld0VsdC5lbHRET00gIT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgdmFyIGNvbnZlcnRlcl8yID0gdGhpcztcbiAgICAgICAgICAgIHRoaXMuX2RhdGFzVmlld0VsdC5lbHRET00uaW5uZXJIVE1MID0gdGhpcy5kYXRhc0hUTUw7XG4gICAgICAgICAgICBpZiAodGhpcy5fZGF0YXNTb3J0aW5nQ29sdW1ucy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgdmFyIGdldFRhYmxlVGggPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yQWxsKFwidGFibGUgdGhcIik7XG4gICAgICAgICAgICAgICAgaWYgKGdldFRhYmxlVGggIT09IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIF9sb29wXzEgPSBmdW5jdGlvbiAoaSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGRhdGFzRmllbGROYiA9IHRoaXNfMS5fZGF0YXNTb3J0aW5nQ29sdW1uc1tpXS5kYXRhc0ZpZWxkTmI7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbENvbnRlbnQgPSBnZXRUYWJsZVRoW2RhdGFzRmllbGROYl0uaW5uZXJIVE1MO1xuICAgICAgICAgICAgICAgICAgICAgICAgaHRtbENvbnRlbnQgPSBcIjxhIGhyZWY9JyNmcmVlRGF0YXMySFRNTFNvcnRpbmdcIiArIGRhdGFzRmllbGROYiArIFwiJyBpZD0nZnJlZURhdGFzMkhUTUxTb3J0aW5nXCIgKyBkYXRhc0ZpZWxkTmIgKyBcIic+XCIgKyBodG1sQ29udGVudCArIFwiPC9hPlwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgZ2V0VGFibGVUaFtkYXRhc0ZpZWxkTmJdLmlubmVySFRNTCA9IGh0bWxDb250ZW50O1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNvcnRpbmdFbGVtZW50ID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoXCJmcmVlRGF0YXMySFRNTFNvcnRpbmdcIiArIGRhdGFzRmllbGROYik7XG4gICAgICAgICAgICAgICAgICAgICAgICBzb3J0aW5nRWxlbWVudC5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGZ1bmN0aW9uIChlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBvcmRlciA9IGNvbnZlcnRlcl8yLmRhdGFzU29ydGluZ0NvbHVtbnNbaV0ub3JkZXI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG9yZGVyID09PSB1bmRlZmluZWQgfHwgb3JkZXIgPT09IFwiZGVzY1wiKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0ZXJfMi5kYXRhc1NvcnRpbmdDb2x1bW5zW2ldLm9yZGVyID0gXCJhc2NcIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRlcl8yLmRhdGFzU29ydGluZ0NvbHVtbnNbaV0ub3JkZXIgPSBcImRlc2NcIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0ZXJfMi5fZGF0YXNTb3J0ZWRDb2x1bW4gPSBjb252ZXJ0ZXJfMi5kYXRhc1NvcnRpbmdDb2x1bW5zW2ldO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnZlcnRlcl8yLmRhdGFzSFRNTCA9IGNvbnZlcnRlcl8yLmNyZWF0ZURhdGFzSFRNTChjb252ZXJ0ZXJfMi5wYXJzZU1ldGEuZmllbGRzLCBjb252ZXJ0ZXJfMi5wYXJzZURhdGFzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb252ZXJ0ZXJfMi5yZWZyZXNoVmlldygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgIHZhciB0aGlzXzEgPSB0aGlzO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBpIGluIHRoaXMuX2RhdGFzU29ydGluZ0NvbHVtbnMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIF9sb29wXzEoaSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9O1xuICAgIGZyZWVEYXRhczJIVE1MLnByb3RvdHlwZS5jcmVhdGVEYXRhc0hUTUwgPSBmdW5jdGlvbiAoZmllbGRzLCBkYXRhcykge1xuICAgICAgICB2YXIgY2hlY2tTZWxlY3RvckV4aXN0LCB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tcbiAgICAgICAgZm9yICh2YXIgaSBpbiBmaWVsZHMpXG4gICAgICAgICAgICBkYXRhc0hUTUwgKz0gXCI8dGg+XCIgKyBmaWVsZHNbaV0gKyBcIjwvdGg+XCI7XG4gICAgICAgIGRhdGFzSFRNTCArPSBcIjwvdGhlYWQ+PHRib2R5PlwiO1xuICAgICAgICBmb3IgKHZhciByb3cgaW4gZGF0YXMpIHtcbiAgICAgICAgICAgIHZhciB2aXNpYmxlID0gdHJ1ZTtcbiAgICAgICAgICAgIGlmIChmaWx0ZXJzLmxlbmd0aCAhPT0gMCkge1xuICAgICAgICAgICAgICAgIGZvciAodmFyIGkgaW4gZmlsdGVycykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZmlsdGVyc1tpXS5zZXBhcmF0b3IgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRhdGFzW3Jvd11bZmlsdGVyc1tpXS5maWVsZF0udHJpbSgpICE9IGZpbHRlcnNbaV0udmFsdWUpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlzaWJsZSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGNoZWNrZWRWYWx1ZXMgPSBkYXRhc1tyb3ddW2ZpbHRlcnNbaV0uZmllbGRdLnNwbGl0KGZpbHRlcnNbaV0uc2VwYXJhdG9yKSwgZmluZGVkID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBqIGluIGNoZWNrZWRWYWx1ZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2hlY2tlZFZhbHVlc1tqXS50cmltKCkgPT09IGZpbHRlcnNbaV0udmFsdWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmluZGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmaW5kZWQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmlzaWJsZSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHZpc2libGUpIHtcbiAgICAgICAgICAgICAgICBkYXRhc0hUTUwgKz0gXCI8dHI+XCI7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgZmllbGQgaW4gZGF0YXNbcm93XSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZmllbGRzLmluZGV4T2YoZmllbGQpICE9PSAtMSlcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFzSFRNTCArPSBcIjx0ZD5cIiArIGRhdGFzW3Jvd11bZmllbGRdICsgXCI8L3RkPlwiO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBkYXRhc0hUTUwgKz0gXCI8L3RyPlwiO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGRhdGFzSFRNTCArPSBcIjwvdGJvZHk+PC90YWJsZT5cIjtcbiAgICAgICAgcmV0dXJuIGRhdGFzSFRNTDtcbiAgICB9O1xuICAgIHJldHVybiBmcmVlRGF0YXMySFRNTDtcbn0oKSk7XG5leHBvcnQgeyBmcmVlRGF0YXMySFRNTCB9O1xuIiwibW9kdWxlLmV4cG9ydHMgPVxue1xuICAgIGRhdGFzTm90Rm91bmQgOiBcIkF1Y3VuZSBkb25uw6llIG4nYSDDqXTDqSB0cm91dsOpZS5cIixcbiAgICBlbGVtZW50Tm90Rm91bmQgOiBcIkF1Y3VuIMOpbMOpbWVudCBIVE1MIG4nYSDDqXTDqSB0cm91dsOpIGF5YW50IGNvbW1lIFxcXCJpZFxcXCIgOiBc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8c3Ryb25nPkTDqXNvbMOpLCBtYWlzIHVuIHByb2Jsw6htZSB0ZWNobmlxdWUgZW1ww6pjaGUgbCdhZmZpY2hhZ2UgZGVzIGRvbm7DqWVzLjwvc3Ryb25nPlwiO1xuICAgICAgICAgICAgICAgIHJldHVybiBbMywgM107XG4gICAgICAgICAgICBjYXNlIDM6IHJldHVybiBbMl07XG4gICAgICAgIH1cbiAgICB9KTtcbn0pOyB9O1xuaW5pdGlhbGlzZSgpO1xuIl0sIm5hbWVzIjpbXSwic291cmNlUm9vdCI6IiJ9 \ No newline at end of file diff --git a/public/index.html b/public/index.html index 8b411a5..0bc8478 100644 --- a/public/index.html +++ b/public/index.html @@ -19,6 +19,7 @@